|
|
1.1 root 1: #ifndef lint
2: static char *rcsid_display_c = "$Header: display.c,v 10.2 86/12/17 18:04:40 swick Exp $";
3: #endif lint
4: /* display.c - Routines to initialize screen, and allocate space??
5: *
6: * OpenDisplay Open it
7: * InitDisplay Do display initialization
8: * DisplayDead Check if dead
9: * AllocateSpace Allocate some temporary storage
10: *
11: * Author:
12: *
13: * Scott Bates
14: * Brown University
15: * IRIS, Box 1946
16: * Providence, RI 02912
17: *
18: *
19: * Copyright (c) 1986 Brown University
20: *
21: * Permission to use, copy, modify and distribute this software and its
22: * documentation for any purpose and without fee is hereby granted, provided
23: * that the above copyright notice appear in all copies, and that both
24: * that copyright notice and this permission notice appear in supporting
25: * documentation, and that the name of Brown University not be used in
26: * advertising or publicity pertaining to distribution of the software
27: * without specific, written prior permission. Brown University makes no
28: * representations about the suitability of this software for any purpose.
29: * It is provided "as-is" without express or implied warranty.
30: */
31:
32: #include "private.h"
33: #include "bitblt.h"
34:
35: #ifdef APA16
36: #include "apa16.h"
37: #endif APA16
38:
39: #ifdef AED
40: #include "aed.h"
41: #endif AED
42:
43: #ifdef APA8
44: #include "apa8.h"
45: #endif APA8
46:
47: #ifdef APA8C
48: #include "apa8c.h"
49: #endif APA8C
50:
51: #ifdef PQD
52: #include "pqd.h"
53: #endif PQD
54:
55: /*
56: * Open the display
57: */
58:
59: /*ARGSUSED*/
60: OpenDisplay (xNumber)
61: char *xNumber;
62: {
63: char *MouseType = getenv("MOUSETYPE");
64: char *MouseName = getenv("MOUSENAME");
65: extern int mdev;
66: int emul;
67:
68: #ifdef TRACE_X
69: fprintf(stderr, "In OpenDisplay\n");
70: fflush(stderr);
71: #endif TRACE_X
72:
73: /*
74: * Open Minor device for correct screen and switch
75: * to that screen
76: */
77:
78: if ((xdev = open (SCREEN_DEVICE, O_RDWR|O_NDELAY)) < 0) {
79: fprintf(stderr, "Unable to open device (%s)\n", SCREEN_DEVICE);
80: fflush(stderr);
81: exit(2);
82: }
83:
84:
85: /*
86: * Get mouse device name
87: */
88:
89: if (!MouseName)
90: MouseName = MOUSE_DEVICE;
91:
92: /*
93: * Open mouse
94: */
95:
96:
97: if ((mdev = open (MouseName, O_RDWR|O_NDELAY)) < 0) {
98: fprintf (stderr, "Error in open of (%s)\n", MouseName);
99: fflush(stderr);
100: exit (2);
101: }
102:
103: /*
104: * Set X Input and Output Emulators for this display
105: */
106:
107: emul = E_XINPUT;
108: if (ioctl (xdev, EISETD, (caddr_t)&emul) < 0) {
109: fprintf(stderr, "Unable to set E_XINPUT (%s)\n",SCREEN_DEVICE);
110: fflush(stderr);
111: exit(2);
112: }
113: emul = E_XOUTPUT;
114: if (ioctl (xdev, EOSETD, (caddr_t)&emul) < 0) {
115: fprintf(stderr, "Unable to set E_XOUTPUT (%s)\n",SCREEN_DEVICE);
116: fflush(stderr);
117: exit(2);
118: }
119:
120: /*
121: * Gain access to I/O address space
122: */
123:
124: if (open ("/dev/bus", O_RDONLY|O_NDELAY) < 0) {
125: DeviceError ("Unable to open /dev/bus\n");
126: exit(2);
127: }
128:
129: /*
130: * Return displays file descriptor
131: */
132:
133: return(xdev);
134: }
135:
136: /*
137: * Do display specific initialization
138: */
139:
140: InitDisplay (info)
141: register DEVICE *info;
142: {
143: #ifdef TRACE_X
144: fprintf(stderr, "In InitDisplay\n");
145: fflush(stderr);
146: #endif TRACE_X
147:
148: /*
149: * Get address of shared memory
150: */
151:
152: if (ioctl(xdev, QIOCADDR, (caddr_t)&XAddr) < 0) {
153: DeviceError("Ioctl to set XAddr failed");
154: exit(2);
155: }
156:
157: /*
158: * Initialize (reset) the display
159: */
160:
161: DISPLAY_INIT();
162:
163: /*
164: * Initialize bitblt()
165: */
166:
167: bitblt_init(SCREEN_BASE, REAL_SCREEN_WIDTH,
168: REAL_SCREEN_HEIGHT, CURSOR_TYPE);
169:
170: /*
171: * Set up the physical bitmap structure. This is used
172: * by device dependent code to talk to bitblt().
173: */
174:
175: pbm.width = REAL_SCREEN_WIDTH;
176: pbm.height = REAL_SCREEN_HEIGHT;
177: pbm.refcnt = 1;
178: pbm.data = (caddr_t) SCREEN_BASE;
179:
180: /*
181: * Fill in device and queue information
182: */
183:
184: info->id = XDEV_ID;
185: info->width = X_SCREEN_WIDTH;
186: info->height = X_SCREEN_HEIGHT;
187: info->planes = 1;
188: info->entries = 0;
189: info->mouse = (vsCursor *)(&(XAddr->mouse));
190: info->mbox = (vsBox *) (&(XAddr->mbox));
191: info->queue = (vsEventQueue *) (&XAddr->ibuff);
192:
193: return (0);
194: }
195:
196: /*
197: * Check if display is dead
198: */
199:
200: DisplayDead ()
201: {
202: #ifdef TRACE_X
203: fprintf(stderr, "In DisplayDead\n");
204: fflush(stderr);
205: #endif TRACE_X
206:
207: return(0);
208: }
209:
210: /*
211: * The presumption here is that only one AllocateSpace
212: * call is made/request
213: */
214:
215: #define ABUFSIZE 3072
216: static char ABuffer[3072]; /* random size buffer for allocate space */
217:
218: caddr_t AllocateSpace (size)
219: register int size;
220: {
221: #ifdef TRACE_X
222: fprintf(stderr, "In AllocateSpace\n");
223: fflush(stderr);
224: #endif TRACE_X
225:
226: if (size < ABUFSIZE)
227: return(ABuffer);
228: errno = ENOMEM;
229: return (NULL);
230: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.