x68k.h revision ba64b02e
1/* $NetBSD: x68k.h,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/* system */
33#include <stdlib.h>
34#include <stdio.h>
35#include <errno.h>
36#include <signal.h>
37#include <sys/types.h>
38#include <sys/time.h>
39#include <sys/ioctl.h>
40#include <sys/mman.h>
41#include <fcntl.h>
42#include <unistd.h>
43
44/* machine dependent */
45#include <machine/vuid_event.h>
46#include <machine/kbd.h>
47#include <machine/kbio.h>
48#include <machine/grfioctl.h>
49
50/* generic X */
51#include <X.h>
52#include <Xmd.h>
53#define XK_KATAKANA
54#include <keysym.h>
55#define NEED_EVENTS
56#include <Xproto.h>
57
58/* dix */
59#include <misc.h>
60#include <scrnintstr.h>
61#include <screenint.h>
62#include <input.h>
63#include <inputstr.h>
64#include <servermd.h>
65#include <colormap.h>
66#include <colormapst.h>
67
68/* mi */
69#include <mipointer.h>
70
71#include "x68kReg.h"
72
73/*
74 * X68k dependent screen record
75 */
76typedef struct _X68kScreenRec {
77    int type;                   /* frame buffer type   */
78    int class;                  /* visual class        */
79    int fd;                     /* file descriptor     */
80    int depth;                  /* depth               */
81    int fb_width;               /* frame buffer width  */
82    int fb_height;              /* frame buffer height */
83    int scr_width;              /* screen width        */
84    int scr_height;             /* screen height       */
85    int dpi;                    /* dots per inch       */
86    uint8_t *fb;                /* frame buffer VA     */
87    volatile FbReg *reg;        /* control register VA */
88    X68kFbReg x68kreg;          /* control register    */
89    int mapsize;                /* size of mapped memory */
90    ColormapPtr installedMap;   /* installed colormap    */
91} X68kScreenRec;
92
93/*
94 * frame buffer procedures
95 */
96typedef struct _X68kFbProcRec {
97    Bool (*open)(X68kScreenRec *);		 /* open procedure       */
98    Bool (*init)(int, ScreenPtr, int, char *[]); /* initialize procedure */
99    void (*close)(X68kScreenRec *);		 /* close procedure      */
100} X68kFbProcRec;
101
102/* frame buffer types */
103#define X68K_FB_NULL    0
104#define X68K_FB_TEXT    1       /* text VRAM frame buffer */
105#define X68K_FB_GRAPHIC 2       /* graphic VRAM frame buffer */
106#if 0
107#define X68K_FB_CIRRUS  3       /* not yet */
108#endif
109#define X68K_FB_TYPES   2
110
111typedef struct _X68kMousePriv {
112    int fd;
113    int bmask;
114} X68kMousePriv, *X68kMousePrivPtr;
115
116typedef struct _X68kKbdPriv {
117    int type;
118    int fd;
119    Leds leds;
120} X68kKbdPriv, *X68kKbdPrivPtr;
121
122/* keyboard types */
123#define X68K_KB_STANDARD 0      /* standard keyboard */
124#define X68K_KB_ASCII    1      /* ascii map keyboard */
125
126#define MAXEVENTS 32
127
128extern DevPrivateKeyRec x68kScreenPrivateKeyRec;
129#define x68kScreenPrivateKey (&x68kScreenPrivateKeyRec)
130#define x68kSetScreenPrivate(pScreen, v) \
131    dixSetPrivate(&(pScreen)->devPrivates, x68kScreenPrivateKey, (v))
132#define x68kGetScreenPrivate(pScreen) ((X68kScreenRec *) \
133    dixLookupPrivate(&(pScreen)->devPrivates, x68kScreenPrivateKey))
134
135/* in x68kConfig.c */
136X68kScreenRec *x68kGetScreenRec(int);
137X68kScreenRec *x68kGetScreenRecByType(int);
138X68kFbProcRec *x68kGetFbProcRec(int index);
139void x68kRegisterPixmapFormats(ScreenInfo *);
140int x68kConfig(void);
141extern const char *configFilename;
142
143/* x68kFB.c */
144Bool x68kFbCommonOpen(X68kScreenRec *, const char *);
145void x68kFbCommonClose(X68kScreenRec *);
146Bool x68kSaveScreen(ScreenPtr, int);
147
148/* x68kGraph.c */
149Bool x68kGraphOpen(X68kScreenRec *);
150Bool x68kGraphInit(int, ScreenPtr, int, char *[]);
151void x68kGraphClose(X68kScreenRec *);
152
153/* in x68kInit.c */
154extern EventList *x68kEvents;
155
156/* in x68kIo.c */
157void x68kSigIOHandler(int);
158
159/* in x68kMouse.c */
160int x68kMouseProc(DeviceIntPtr, int);
161Firm_event *x68kMouseGetEvents(int, int *, Bool *);
162void x68kMouseEnqueueEvent(DeviceIntPtr, Firm_event *);
163extern miPointerScreenFuncRec x68kPointerScreenFuncs;
164extern DeviceIntPtr x68kPointerDevice;
165
166/* in x68kKbd.c */
167int x68kKbdProc(DeviceIntPtr, int);
168Firm_event *x68kKbdGetEvents(int, int *, Bool *);
169void x68kKbdEnqueueEvent(DeviceIntPtr, Firm_event *);
170extern X68kKbdPriv x68kKbdPriv;
171extern DeviceIntPtr x68kKeyboardDevice;
172
173/* in x68kKeyMap.c */
174extern KeySymsRec jisKeySyms, asciiKeySyms, *x68kKeySyms;
175
176/* x68kText.c */
177Bool x68kTextOpen(X68kScreenRec *);
178Bool x68kTextInit(int, ScreenPtr, int, char *[]);
179void x68kTextClose(X68kScreenRec *);
180
181/* EOF x68k.h */
182