x68kInit.c revision 80c54d45
1/* $NetBSD: x68kInit.c,v 1.4 2020/04/10 16:49:36 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 75static int nscreens; 76 77void 78OsVendorInit(void) 79{ 80} 81 82/*------------------------------------------------------------------------- 83 * function "InitOutput" [ called by DIX ] 84 * 85 * purpose: initialize outputs ( screens ) 86 * argument: (ScreenInfo *)pScreenInfo : screen info struct 87 * (int)argc, (char *)argv : standard arguments 88 * returns: nothing 89 *-----------------------------------------------------------------------*/ 90void 91InitOutput(ScreenInfo *pScreenInfo, int argc, char *argv[]) 92{ 93 int i; 94 X68kScreenRec *screen; 95 X68kFbProcRec *fb; 96 97 pScreenInfo->imageByteOrder = IMAGE_BYTE_ORDER; 98 pScreenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT; 99 pScreenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD; 100 pScreenInfo->bitmapBitOrder = BITMAP_BIT_ORDER; 101 102 /* read configuration file */ 103 nscreens = x68kConfig(); 104 105 /* register pixmap formats */ 106 x68kRegisterPixmapFormats(pScreenInfo); 107 108 /* open and initialize frame buffer for each screen */ 109 for (i = 0; i < nscreens; i++) { 110 screen = x68kGetScreenRec(i); 111 fb = x68kGetFbProcRec(i); 112 if ( !(*fb->open)(screen) ) 113 return; 114 if ( AddScreen(fb->init, argc, argv) < 0 ) 115 FatalError("AddScreen failed\n"); 116 } 117} 118 119/*------------------------------------------------------------------------- 120 * function "InitInput" [ called by DIX ] 121 * 122 * purpose: initialize inputs ( keyboard and mouse ) 123 * argument: (int)argc, (char *)argv : standard arguments 124 * returns: nothing 125 *-----------------------------------------------------------------------*/ 126void 127InitInput(int argc, char *argv[]) 128{ 129 x68kPointerDevice = AddInputDevice(serverClient, x68kMouseProc, TRUE); 130 x68kKeyboardDevice = AddInputDevice(serverClient, x68kKbdProc, TRUE); 131 132 if ( !mieqInit() ) 133 FatalError("mieqInit failed\n"); 134 135 /* setup SIGIO handler for asynchronous event handling */ 136 (void)OsSignal(SIGIO, x68kSigIOHandler); 137} 138 139void 140CloseInput(void) 141{ 142 mieqFini(); 143} 144 145/*------------------------------------------------------------------------- 146 * function "AbortDDX" [ called by OS ] 147 * 148 * purpose: free signal handler and close frame buffers 149 * argument: ExitCode 150 * returns: nothing 151 *-----------------------------------------------------------------------*/ 152void 153AbortDDX(enum ExitCode error) 154{ 155 int i; 156 X68kScreenRec *screen; 157 X68kFbProcRec *fb; 158 159 /* give up SIGIO handling */ 160 (void) OsSignal(SIGIO, SIG_IGN); 161 162 /* close all frame buffers */ 163 for (i = 0; i < nscreens; i++) { 164 screen = x68kGetScreenRec(i); 165 fb = x68kGetFbProcRec(i); 166 (*fb->close)(screen); 167 } 168} 169 170/*------------------------------------------------------------------------- 171 * function "ddxGiveUp" [ called by DIX ] 172 * 173 * purpose: do nothing but call AbortDDX. 174 * argument: nothing 175 * returns: nothing 176 *-----------------------------------------------------------------------*/ 177void 178ddxGiveUp(enum ExitCode error) 179{ 180 AbortDDX(error); 181} 182 183/*------------------------------------------------------------------------- 184 * function "ddxProcessArgument" [ called by OS ] 185 * 186 * purpose: process X68k dependent arguments 187 * currently only `x68kconfig' will be recognized. 188 * argument: (int)argc, (char **)argv: standard C arguments 189 * (int)i : index of current argument 190 * returns: number of arguments eaten 191 *-----------------------------------------------------------------------*/ 192int 193ddxProcessArgument(int argc, char *argv[], int i) 194{ 195 196 if (strcmp(argv[i], "-x68kconfig") == 0) { 197 if (++i >= argc) 198 UseMsg(); 199 configFilename = strdup(argv[i]); 200 return 2; 201 } 202 return 0; 203} 204 205/*------------------------------------------------------------------------- 206 * function "ddxUseMsg" [ called by OS ] 207 * 208 * purpose: print X68k dependent usage 209 * argument: nothing 210 * returns: nothing 211 *-----------------------------------------------------------------------*/ 212void 213ddxUseMsg(void) 214{ 215 ErrorF("\nX68k dependent options\n"); 216 ErrorF("-x68kconfig filename specify configuration file\n"); 217} 218 219_X_EXPORT void 220OsVendorFatalError(const char *f, va_list args) 221{ 222} 223 224/* EOF x68kInit.c */ 225