145f60b5bStsutsui/* $NetBSD: x68kInit.c,v 1.13 2025/06/22 22:29:23 tsutsui Exp $ */ 2ba64b02eStsutsui/*------------------------------------------------------------------------- 3ba64b02eStsutsui * Copyright (c) 1996 Yasushi Yamasaki 4ba64b02eStsutsui * All rights reserved. 5ba64b02eStsutsui * 6ba64b02eStsutsui * Redistribution and use in source and binary forms, with or without 7ba64b02eStsutsui * modification, are permitted provided that the following conditions 8ba64b02eStsutsui * are met: 9ba64b02eStsutsui * 1. Redistributions of source code must retain the above copyright 10ba64b02eStsutsui * notice, this list of conditions and the following disclaimer. 11ba64b02eStsutsui * 2. Redistributions in binary form must reproduce the above copyright 12ba64b02eStsutsui * notice, this list of conditions and the following disclaimer in the 13ba64b02eStsutsui * documentation and/or other materials provided with the distribution. 14ba64b02eStsutsui * 15ba64b02eStsutsui * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16ba64b02eStsutsui * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17ba64b02eStsutsui * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18ba64b02eStsutsui * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19ba64b02eStsutsui * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20ba64b02eStsutsui * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21ba64b02eStsutsui * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22ba64b02eStsutsui * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23ba64b02eStsutsui * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24ba64b02eStsutsui * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25ba64b02eStsutsui *-----------------------------------------------------------------------*/ 26ba64b02eStsutsui 27ba64b02eStsutsui/* 28ba64b02eStsutsui * 29ba64b02eStsutsui * Copyright (c) 1987 by the Regents of the University of California 30ba64b02eStsutsui * 31ba64b02eStsutsui * Permission to use, copy, modify, and distribute this 32ba64b02eStsutsui * software and its documentation for any purpose and without 33ba64b02eStsutsui * fee is hereby granted, provided that the above copyright 34ba64b02eStsutsui * notice appear in all copies. The University of California 35ba64b02eStsutsui * makes no representations about the suitability of this 36ba64b02eStsutsui * software for any purpose. It is provided "as is" without 37ba64b02eStsutsui * express or implied warranty. 38ba64b02eStsutsui * 39ba64b02eStsutsui * 40ba64b02eStsutsui */ 41ba64b02eStsutsui 42ba64b02eStsutsui/************************************************************ 43ba64b02eStsutsuiCopyright 1987 by Sun Microsystems, Inc. Mountain View, CA. 44ba64b02eStsutsui 45ba64b02eStsutsui All Rights Reserved 46ba64b02eStsutsui 47ba64b02eStsutsuiPermission to use, copy, modify, and distribute this 48ba64b02eStsutsuisoftware and its documentation for any purpose and without 49ba64b02eStsutsuifee is hereby granted, provided that the above copyright no- 50ba64b02eStsutsuitice appear in all copies and that both that copyright no- 51ba64b02eStsutsuitice and this permission notice appear in supporting docu- 52ba64b02eStsutsuimentation, and that the names of Sun or X Consortium 53ab290810Stsutsuinot be used in advertising or publicity pertaining to 54ab290810Stsutsuidistribution of the software without specific prior 55ab290810Stsutsuiwritten permission. Sun and X Consortium make no 56ab290810Stsutsuirepresentations about the suitability of this software for 57ab290810Stsutsuiany purpose. It is provided "as is" without any express or 58ba64b02eStsutsuiimplied warranty. 59ba64b02eStsutsui 60ba64b02eStsutsuiSUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 61ba64b02eStsutsuiINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT- 62ba64b02eStsutsuiNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI- 63ba64b02eStsutsuiABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR 64ba64b02eStsutsuiANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 65ba64b02eStsutsuiPROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 66ba64b02eStsutsuiOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH 67ba64b02eStsutsuiTHE USE OR PERFORMANCE OF THIS SOFTWARE. 68ba64b02eStsutsui 69ba64b02eStsutsui*******************************************************/ 70ba64b02eStsutsui 7147cf8911Stsutsui#include <X11/Xos.h> 72ba64b02eStsutsui#include "x68k.h" 73ba64b02eStsutsui#include "mi.h" 7401f81e7bStsutsui#include "extinit.h" 75ba64b02eStsutsui 76ba64b02eStsutsuistatic int nscreens; 77ba64b02eStsutsui 789979d90aStsutsui/* default log file paths */ 799979d90aStsutsui#ifndef DEFAULT_LOGDIR 809979d90aStsutsui#define DEFAULT_LOGDIR "/var/log" 819979d90aStsutsui#endif 829979d90aStsutsui#ifndef DEFAULT_LOGPREFIX 839979d90aStsutsui#define DEFAULT_LOGPREFIX "X68K." 849979d90aStsutsui#endif 859979d90aStsutsui 86ba64b02eStsutsuivoid 87ba64b02eStsutsuiOsVendorInit(void) 88ba64b02eStsutsui{ 899979d90aStsutsui static int inited; 909979d90aStsutsui 919979d90aStsutsui if (!inited) { 929979d90aStsutsui const char *logfile; 939979d90aStsutsui char *lf; 949979d90aStsutsui 959979d90aStsutsui#define LOGSUFFIX ".log" 969979d90aStsutsui#define LOGOLDSUFFIX ".old" 979979d90aStsutsui logfile = DEFAULT_LOGDIR "/" DEFAULT_LOGPREFIX; 989979d90aStsutsui if (asprintf(&lf, "%s%%s" LOGSUFFIX, logfile) == -1) 999979d90aStsutsui FatalError("Cannot allocate space for the log file name\n"); 1009979d90aStsutsui LogInit(lf, LOGOLDSUFFIX); 1019979d90aStsutsui#undef LOGSUFFIX 1029979d90aStsutsui#undef LOGOLDSUFFIX 1039979d90aStsutsui free(lf); 1049979d90aStsutsui 1059979d90aStsutsui inited = 1; 1069979d90aStsutsui } 107ba64b02eStsutsui} 108ba64b02eStsutsui 10901f81e7bStsutsui#ifdef GLXEXT 11001f81e7bStsutsuivoid 11101f81e7bStsutsuiGlxExtensionInit(void) 11201f81e7bStsutsui{ 11301f81e7bStsutsui} 11401f81e7bStsutsui#endif 11501f81e7bStsutsui 116ba64b02eStsutsui/*------------------------------------------------------------------------- 117ba64b02eStsutsui * function "InitOutput" [ called by DIX ] 118ba64b02eStsutsui * 119ba64b02eStsutsui * purpose: initialize outputs ( screens ) 120ba64b02eStsutsui * argument: (ScreenInfo *)pScreenInfo : screen info struct 121ba64b02eStsutsui * (int)argc, (char *)argv : standard arguments 122ba64b02eStsutsui * returns: nothing 123ba64b02eStsutsui *-----------------------------------------------------------------------*/ 124ba64b02eStsutsuivoid 125ba64b02eStsutsuiInitOutput(ScreenInfo *pScreenInfo, int argc, char *argv[]) 126ba64b02eStsutsui{ 127ba64b02eStsutsui int i; 128ba64b02eStsutsui X68kScreenRec *screen; 129ba64b02eStsutsui X68kFbProcRec *fb; 130ab290810Stsutsui 131ba64b02eStsutsui pScreenInfo->imageByteOrder = IMAGE_BYTE_ORDER; 132ba64b02eStsutsui pScreenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT; 133ba64b02eStsutsui pScreenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD; 134ba64b02eStsutsui pScreenInfo->bitmapBitOrder = BITMAP_BIT_ORDER; 135ba64b02eStsutsui 136ba64b02eStsutsui /* read configuration file */ 137ba64b02eStsutsui nscreens = x68kConfig(); 138ba64b02eStsutsui 139ba64b02eStsutsui /* register pixmap formats */ 140ba64b02eStsutsui x68kRegisterPixmapFormats(pScreenInfo); 141ab290810Stsutsui 142ba64b02eStsutsui /* open and initialize frame buffer for each screen */ 143ba64b02eStsutsui for (i = 0; i < nscreens; i++) { 144ba64b02eStsutsui screen = x68kGetScreenRec(i); 145ba64b02eStsutsui fb = x68kGetFbProcRec(i); 146ba64b02eStsutsui if ( !(*fb->open)(screen) ) 147ba64b02eStsutsui return; 148ba64b02eStsutsui if ( AddScreen(fb->init, argc, argv) < 0 ) 149ba64b02eStsutsui FatalError("AddScreen failed\n"); 150ba64b02eStsutsui } 151ba64b02eStsutsui} 152ba64b02eStsutsui 153ba64b02eStsutsui/*------------------------------------------------------------------------- 154ba64b02eStsutsui * function "InitInput" [ called by DIX ] 155ba64b02eStsutsui * 156ba64b02eStsutsui * purpose: initialize inputs ( keyboard and mouse ) 157ba64b02eStsutsui * argument: (int)argc, (char *)argv : standard arguments 158ba64b02eStsutsui * returns: nothing 159ba64b02eStsutsui *-----------------------------------------------------------------------*/ 160ba64b02eStsutsuivoid 161ab290810StsutsuiInitInput(int argc, char *argv[]) 162ba64b02eStsutsui{ 1631dfa130eStsutsui int rc; 1641dfa130eStsutsui 1651dfa130eStsutsui rc = AllocDevicePair(serverClient, "x68k", 1661dfa130eStsutsui &x68kPointerDevice, &x68kKeyboardDevice, 1671dfa130eStsutsui x68kMouseProc,x68kKbdProc, FALSE); 1681dfa130eStsutsui if (rc != Success) 1691dfa130eStsutsui FatalError("Failed to init x68k default input devices.\n"); 170ba64b02eStsutsui 171ba64b02eStsutsui if ( !mieqInit() ) 172ba64b02eStsutsui FatalError("mieqInit failed\n"); 173ba64b02eStsutsui} 174ba64b02eStsutsui 175ba64b02eStsutsuivoid 176ba64b02eStsutsuiCloseInput(void) 177ba64b02eStsutsui{ 178bddeb3e5Stsutsui mieqFini(); 179ba64b02eStsutsui} 180ba64b02eStsutsui 181ba64b02eStsutsui/*------------------------------------------------------------------------- 182357cbbceStsutsui * function "ddxGiveUp" [ called by DIX ] 183ba64b02eStsutsui * 184ba64b02eStsutsui * purpose: free signal handler and close frame buffers 185909daefdSmrg * argument: ExitCode 186ba64b02eStsutsui * returns: nothing 187ba64b02eStsutsui *-----------------------------------------------------------------------*/ 188357cbbceStsutsuivoid 189357cbbceStsutsuiddxGiveUp(enum ExitCode error) 190ba64b02eStsutsui{ 191ba64b02eStsutsui int i; 192ba64b02eStsutsui X68kScreenRec *screen; 193ba64b02eStsutsui X68kFbProcRec *fb; 194ba64b02eStsutsui 195ba64b02eStsutsui /* close all frame buffers */ 196ba64b02eStsutsui for (i = 0; i < nscreens; i++) { 197ba64b02eStsutsui screen = x68kGetScreenRec(i); 198ba64b02eStsutsui fb = x68kGetFbProcRec(i); 199ba64b02eStsutsui (*fb->close)(screen); 200ba64b02eStsutsui } 2019979d90aStsutsui LogClose(error); 202ba64b02eStsutsui} 203ba64b02eStsutsui 204ba64b02eStsutsui/*------------------------------------------------------------------------- 205ba64b02eStsutsui * function "ddxProcessArgument" [ called by OS ] 206ba64b02eStsutsui * 207ba64b02eStsutsui * purpose: process X68k dependent arguments 208ba64b02eStsutsui * currently only `x68kconfig' will be recognized. 209ba64b02eStsutsui * argument: (int)argc, (char **)argv: standard C arguments 210ba64b02eStsutsui * (int)i : index of current argument 211ba64b02eStsutsui * returns: number of arguments eaten 212ba64b02eStsutsui *-----------------------------------------------------------------------*/ 213ba64b02eStsutsuiint 214ba64b02eStsutsuiddxProcessArgument(int argc, char *argv[], int i) 215ba64b02eStsutsui{ 216ba64b02eStsutsui 217ba64b02eStsutsui if (strcmp(argv[i], "-x68kconfig") == 0) { 218ba64b02eStsutsui if (++i >= argc) 219ba64b02eStsutsui UseMsg(); 220ba64b02eStsutsui configFilename = strdup(argv[i]); 221ba64b02eStsutsui return 2; 222ba64b02eStsutsui } 223ba64b02eStsutsui return 0; 224ba64b02eStsutsui} 225ba64b02eStsutsui 226ba64b02eStsutsui/*------------------------------------------------------------------------- 227ba64b02eStsutsui * function "ddxUseMsg" [ called by OS ] 228ba64b02eStsutsui * 229ba64b02eStsutsui * purpose: print X68k dependent usage 230ba64b02eStsutsui * argument: nothing 231ba64b02eStsutsui * returns: nothing 232ba64b02eStsutsui *-----------------------------------------------------------------------*/ 233ba64b02eStsutsuivoid 234ba64b02eStsutsuiddxUseMsg(void) 235ba64b02eStsutsui{ 236ba64b02eStsutsui ErrorF("\nX68k dependent options\n"); 237ba64b02eStsutsui ErrorF("-x68kconfig filename specify configuration file\n"); 238ba64b02eStsutsui} 239ba64b02eStsutsui 240909daefdSmrg_X_EXPORT void 241909daefdSmrgOsVendorFatalError(const char *f, va_list args) 242ba64b02eStsutsui{ 243ba64b02eStsutsui} 244ba64b02eStsutsui 24509f8ca91Smrg#if INPUTTHREAD 24609f8ca91Smrg/** This function is called in Xserver/os/inputthread.c when starting 24709f8ca91Smrg the input thread. */ 24809f8ca91Smrgvoid 24909f8ca91SmrgddxInputThreadInit(void) 25009f8ca91Smrg{ 25109f8ca91Smrg} 25209f8ca91Smrg#endif 25309f8ca91Smrg 254ba64b02eStsutsui/* EOF x68kInit.c */ 255