bicons.c revision 1.2.2.2 1 1.2.2.2 bouyer /* $NetBSD: bicons.c,v 1.2.2.2 2001/02/11 19:15:21 bouyer Exp $ */
2 1.2.2.2 bouyer
3 1.2.2.2 bouyer /*-
4 1.2.2.2 bouyer * Copyright (c) 1999-2001
5 1.2.2.2 bouyer * Shin Takemura and PocketBSD Project. All rights reserved.
6 1.2.2.2 bouyer *
7 1.2.2.2 bouyer * Redistribution and use in source and binary forms, with or without
8 1.2.2.2 bouyer * modification, are permitted provided that the following conditions
9 1.2.2.2 bouyer * are met:
10 1.2.2.2 bouyer * 1. Redistributions of source code must retain the above copyright
11 1.2.2.2 bouyer * notice, this list of conditions and the following disclaimer.
12 1.2.2.2 bouyer * 2. Redistributions in binary form must reproduce the above copyright
13 1.2.2.2 bouyer * notice, this list of conditions and the following disclaimer in the
14 1.2.2.2 bouyer * documentation and/or other materials provided with the distribution.
15 1.2.2.2 bouyer * 3. All advertising materials mentioning features or use of this software
16 1.2.2.2 bouyer * must display the following acknowledgement:
17 1.2.2.2 bouyer * This product includes software developed by the PocketBSD project
18 1.2.2.2 bouyer * and its contributors.
19 1.2.2.2 bouyer * 4. Neither the name of the project nor the names of its contributors
20 1.2.2.2 bouyer * may be used to endorse or promote products derived from this software
21 1.2.2.2 bouyer * without specific prior written permission.
22 1.2.2.2 bouyer *
23 1.2.2.2 bouyer * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 1.2.2.2 bouyer * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 1.2.2.2 bouyer * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 1.2.2.2 bouyer * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 1.2.2.2 bouyer * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 1.2.2.2 bouyer * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 1.2.2.2 bouyer * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 1.2.2.2 bouyer * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 1.2.2.2 bouyer * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 1.2.2.2 bouyer * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 1.2.2.2 bouyer * SUCH DAMAGE.
34 1.2.2.2 bouyer *
35 1.2.2.2 bouyer */
36 1.2.2.2 bouyer
37 1.2.2.2 bouyer #define HALF_FONT
38 1.2.2.2 bouyer
39 1.2.2.2 bouyer #include <sys/param.h>
40 1.2.2.2 bouyer #include <sys/device.h>
41 1.2.2.2 bouyer #include <sys/systm.h>
42 1.2.2.2 bouyer #include <sys/conf.h>
43 1.2.2.2 bouyer #include <dev/cons.h>
44 1.2.2.2 bouyer
45 1.2.2.2 bouyer #include <machine/bootinfo.h>
46 1.2.2.2 bouyer #include <machine/bus.h>
47 1.2.2.2 bouyer #include <machine/platid.h>
48 1.2.2.2 bouyer #include <machine/stdarg.h>
49 1.2.2.2 bouyer
50 1.2.2.2 bouyer #include <dev/hpc/biconsvar.h>
51 1.2.2.2 bouyer #include <dev/hpc/bicons.h>
52 1.2.2.2 bouyer extern u_int8_t font_clR8x8_data[];
53 1.2.2.2 bouyer extern u_int8_t font_clB8x8_data[];
54 1.2.2.2 bouyer #define FONT_HEIGHT 8
55 1.2.2.2 bouyer #define FONT_WIDTH 1
56 1.2.2.2 bouyer
57 1.2.2.2 bouyer static void put_oxel_D2_M2L_3(u_int8_t *, u_int8_t, u_int8_t);
58 1.2.2.2 bouyer static void put_oxel_D2_M2L_3x2(u_int8_t *, u_int8_t, u_int8_t);
59 1.2.2.2 bouyer static void put_oxel_D2_M2L_0(u_int8_t *, u_int8_t, u_int8_t);
60 1.2.2.2 bouyer static void put_oxel_D2_M2L_0x2(u_int8_t *, u_int8_t, u_int8_t);
61 1.2.2.2 bouyer static void put_oxel_D4_M2L_F(u_int8_t *, u_int8_t, u_int8_t);
62 1.2.2.2 bouyer static void put_oxel_D4_M2L_Fx2(u_int8_t *, u_int8_t, u_int8_t);
63 1.2.2.2 bouyer static void put_oxel_D4_M2L_0(u_int8_t *, u_int8_t, u_int8_t);
64 1.2.2.2 bouyer static void put_oxel_D4_M2L_0x2(u_int8_t *, u_int8_t, u_int8_t);
65 1.2.2.2 bouyer static void put_oxel_D8_00(u_int8_t *, u_int8_t, u_int8_t);
66 1.2.2.2 bouyer static void put_oxel_D8_FF(u_int8_t *, u_int8_t, u_int8_t);
67 1.2.2.2 bouyer static void put_oxel_D16_0000(u_int8_t *, u_int8_t, u_int8_t);
68 1.2.2.2 bouyer static void put_oxel_D16_FFFF(u_int8_t *, u_int8_t, u_int8_t);
69 1.2.2.2 bouyer
70 1.2.2.2 bouyer struct {
71 1.2.2.2 bouyer int type;
72 1.2.2.2 bouyer char *name;
73 1.2.2.2 bouyer void (*func)(u_int8_t *, u_int8_t, u_int8_t);
74 1.2.2.2 bouyer u_int8_t clear_byte;
75 1.2.2.2 bouyer int16_t oxel_bytes;
76 1.2.2.2 bouyer } fb_table[] = {
77 1.2.2.2 bouyer { BIFB_D2_M2L_3, BIFBN_D2_M2L_3,
78 1.2.2.2 bouyer put_oxel_D2_M2L_3, 0, 2 },
79 1.2.2.2 bouyer { BIFB_D2_M2L_3x2, BIFBN_D2_M2L_3x2,
80 1.2.2.2 bouyer put_oxel_D2_M2L_3x2, 0, 1 },
81 1.2.2.2 bouyer { BIFB_D2_M2L_0, BIFBN_D2_M2L_0,
82 1.2.2.2 bouyer put_oxel_D2_M2L_0, 0xff, 2 },
83 1.2.2.2 bouyer { BIFB_D2_M2L_0x2, BIFBN_D2_M2L_0x2,
84 1.2.2.2 bouyer put_oxel_D2_M2L_0x2, 0xff, 1 },
85 1.2.2.2 bouyer { BIFB_D4_M2L_F, BIFBN_D4_M2L_F,
86 1.2.2.2 bouyer put_oxel_D4_M2L_F, 0x00, 4 },
87 1.2.2.2 bouyer { BIFB_D4_M2L_Fx2, BIFBN_D4_M2L_Fx2,
88 1.2.2.2 bouyer put_oxel_D4_M2L_Fx2, 0x00, 2 },
89 1.2.2.2 bouyer { BIFB_D4_M2L_0, BIFBN_D4_M2L_0,
90 1.2.2.2 bouyer put_oxel_D4_M2L_0, 0xff, 4 },
91 1.2.2.2 bouyer { BIFB_D4_M2L_0x2, BIFBN_D4_M2L_0x2,
92 1.2.2.2 bouyer put_oxel_D4_M2L_0x2, 0xff, 2 },
93 1.2.2.2 bouyer { BIFB_D8_00, BIFBN_D8_00,
94 1.2.2.2 bouyer put_oxel_D8_00, 0xff, 8 },
95 1.2.2.2 bouyer { BIFB_D8_FF, BIFBN_D8_FF,
96 1.2.2.2 bouyer put_oxel_D8_FF, 0x00, 8 },
97 1.2.2.2 bouyer { BIFB_D16_0000, BIFBN_D16_0000,
98 1.2.2.2 bouyer put_oxel_D16_0000, 0xff, 16 },
99 1.2.2.2 bouyer { BIFB_D16_FFFF, BIFBN_D16_FFFF,
100 1.2.2.2 bouyer put_oxel_D16_FFFF, 0x00, 16 },
101 1.2.2.2 bouyer };
102 1.2.2.2 bouyer #define FB_TABLE_SIZE (sizeof(fb_table)/sizeof(*fb_table))
103 1.2.2.2 bouyer
104 1.2.2.2 bouyer static u_int8_t *fb_vram;
105 1.2.2.2 bouyer static int16_t fb_line_bytes;
106 1.2.2.2 bouyer static u_int8_t fb_clear_byte;
107 1.2.2.2 bouyer int16_t bicons_ypixel;
108 1.2.2.2 bouyer int16_t bicons_xpixel;
109 1.2.2.2 bouyer #ifdef HALF_FONT
110 1.2.2.2 bouyer static int16_t fb_oxel_bytes = 1;
111 1.2.2.2 bouyer int16_t bicons_width = 80;
112 1.2.2.2 bouyer void (*fb_put_oxel)(u_int8_t *, u_int8_t, u_int8_t) = put_oxel_D2_M2L_3x2;
113 1.2.2.2 bouyer #else /* HALF_FONT */
114 1.2.2.2 bouyer static int16_t fb_oxel_bytes = 2;
115 1.2.2.2 bouyer int16_t bicons_width = 40;
116 1.2.2.2 bouyer void (*fb_put_oxel)(u_int8_t *, u_int8_t, u_int8_t) = put_oxel_D2_M2L_3;
117 1.2.2.2 bouyer #endif /* HALF_FONT */
118 1.2.2.2 bouyer int16_t bicons_height;
119 1.2.2.2 bouyer static int16_t curs_x;
120 1.2.2.2 bouyer static int16_t curs_y;
121 1.2.2.2 bouyer
122 1.2.2.2 bouyer cdev_decl(biconsdev);
123 1.2.2.2 bouyer
124 1.2.2.2 bouyer static int bicons_priority;
125 1.2.2.2 bouyer void biconscninit(struct consdev *);
126 1.2.2.2 bouyer void biconscnprobe(struct consdev *);
127 1.2.2.2 bouyer void biconscnputc(dev_t, int);
128 1.2.2.2 bouyer int biconscngetc(dev_t); /* harmless place holder */
129 1.2.2.2 bouyer
130 1.2.2.2 bouyer static void draw_char(int, int, int);
131 1.2.2.2 bouyer static void clear(int, int);
132 1.2.2.2 bouyer static void scroll(int, int, int);
133 1.2.2.2 bouyer static void bicons_puts(char *);
134 1.2.2.2 bouyer static void bicons_printf(const char *, ...) __attribute__((__unused__));
135 1.2.2.2 bouyer
136 1.2.2.2 bouyer void
137 1.2.2.2 bouyer bicons_init(struct consdev *cndev)
138 1.2.2.2 bouyer {
139 1.2.2.2 bouyer biconscninit(cndev);
140 1.2.2.2 bouyer biconscnprobe(cndev);
141 1.2.2.2 bouyer }
142 1.2.2.2 bouyer
143 1.2.2.2 bouyer void
144 1.2.2.2 bouyer biconscninit(struct consdev *cndev)
145 1.2.2.2 bouyer {
146 1.2.2.2 bouyer int fb_index = -1;
147 1.2.2.2 bouyer
148 1.2.2.2 bouyer for (fb_index = 0; fb_index < FB_TABLE_SIZE; fb_index++)
149 1.2.2.2 bouyer if (fb_table[fb_index].type == bootinfo->fb_type)
150 1.2.2.2 bouyer break;
151 1.2.2.2 bouyer
152 1.2.2.2 bouyer if (FB_TABLE_SIZE <= fb_index || fb_index == -1) {
153 1.2.2.2 bouyer /*
154 1.2.2.2 bouyer * Unknown frame buffer type, but what can I do ?
155 1.2.2.2 bouyer */
156 1.2.2.2 bouyer fb_index = 0;
157 1.2.2.2 bouyer }
158 1.2.2.2 bouyer
159 1.2.2.2 bouyer fb_vram = (u_int8_t *)bootinfo->fb_addr;
160 1.2.2.2 bouyer fb_line_bytes = bootinfo->fb_line_bytes;
161 1.2.2.2 bouyer bicons_xpixel = bootinfo->fb_width;
162 1.2.2.2 bouyer bicons_ypixel = bootinfo->fb_height;
163 1.2.2.2 bouyer
164 1.2.2.2 bouyer fb_put_oxel = fb_table[fb_index].func;
165 1.2.2.2 bouyer fb_clear_byte = fb_table[fb_index].clear_byte;
166 1.2.2.2 bouyer fb_oxel_bytes = fb_table[fb_index].oxel_bytes;
167 1.2.2.2 bouyer
168 1.2.2.2 bouyer bicons_width = bicons_xpixel / (8 * FONT_WIDTH);
169 1.2.2.2 bouyer bicons_height = bicons_ypixel / FONT_HEIGHT;
170 1.2.2.2 bouyer clear(0, bicons_ypixel);
171 1.2.2.2 bouyer
172 1.2.2.2 bouyer curs_x = 0;
173 1.2.2.2 bouyer curs_y = 0;
174 1.2.2.2 bouyer
175 1.2.2.2 bouyer bicons_puts("builtin console type = ");
176 1.2.2.2 bouyer bicons_puts(fb_table[fb_index].name);
177 1.2.2.2 bouyer bicons_puts("\n");
178 1.2.2.2 bouyer }
179 1.2.2.2 bouyer
180 1.2.2.2 bouyer void
181 1.2.2.2 bouyer biconscnprobe(struct consdev *cndev)
182 1.2.2.2 bouyer {
183 1.2.2.2 bouyer int maj;
184 1.2.2.2 bouyer
185 1.2.2.2 bouyer /* locate the major number */
186 1.2.2.2 bouyer for (maj = 0; maj < nchrdev; maj++)
187 1.2.2.2 bouyer if (cdevsw[maj].d_open == biconsdevopen)
188 1.2.2.2 bouyer break;
189 1.2.2.2 bouyer
190 1.2.2.2 bouyer cndev->cn_dev = makedev(maj, 0);
191 1.2.2.2 bouyer cndev->cn_pri = bicons_priority;
192 1.2.2.2 bouyer }
193 1.2.2.2 bouyer
194 1.2.2.2 bouyer void
195 1.2.2.2 bouyer bicons_set_priority(int priority)
196 1.2.2.2 bouyer {
197 1.2.2.2 bouyer bicons_priority = priority;
198 1.2.2.2 bouyer }
199 1.2.2.2 bouyer
200 1.2.2.2 bouyer int
201 1.2.2.2 bouyer biconscngetc(dev_t dev)
202 1.2.2.2 bouyer {
203 1.2.2.2 bouyer printf("no input method. reboot me.\n");
204 1.2.2.2 bouyer while (1)
205 1.2.2.2 bouyer ;
206 1.2.2.2 bouyer /* NOTREACHED */
207 1.2.2.2 bouyer }
208 1.2.2.2 bouyer
209 1.2.2.2 bouyer void
210 1.2.2.2 bouyer biconscnputc(dev_t dev, int c)
211 1.2.2.2 bouyer {
212 1.2.2.2 bouyer int line_feed = 0;
213 1.2.2.2 bouyer
214 1.2.2.2 bouyer switch (c) {
215 1.2.2.2 bouyer case 0x08: /* back space */
216 1.2.2.2 bouyer if (--curs_x < 0) {
217 1.2.2.2 bouyer curs_x = 0;
218 1.2.2.2 bouyer }
219 1.2.2.2 bouyer /* erase character ar cursor position */
220 1.2.2.2 bouyer draw_char(curs_x, curs_y, ' ');
221 1.2.2.2 bouyer break;
222 1.2.2.2 bouyer case '\r':
223 1.2.2.2 bouyer curs_x = 0;
224 1.2.2.2 bouyer break;
225 1.2.2.2 bouyer case '\n':
226 1.2.2.2 bouyer curs_x = 0;
227 1.2.2.2 bouyer line_feed = 1;
228 1.2.2.2 bouyer break;
229 1.2.2.2 bouyer default:
230 1.2.2.2 bouyer draw_char(curs_x, curs_y, c);
231 1.2.2.2 bouyer if (bicons_width <= ++curs_x) {
232 1.2.2.2 bouyer curs_x = 0;
233 1.2.2.2 bouyer line_feed = 1;
234 1.2.2.2 bouyer }
235 1.2.2.2 bouyer }
236 1.2.2.2 bouyer
237 1.2.2.2 bouyer if (line_feed) {
238 1.2.2.2 bouyer if (bicons_height <= ++curs_y) {
239 1.2.2.2 bouyer /* scroll up */
240 1.2.2.2 bouyer scroll(FONT_HEIGHT, (bicons_height - 1) * FONT_HEIGHT,
241 1.2.2.2 bouyer - FONT_HEIGHT);
242 1.2.2.2 bouyer clear((bicons_height - 1) * FONT_HEIGHT, FONT_HEIGHT);
243 1.2.2.2 bouyer curs_y--;
244 1.2.2.2 bouyer }
245 1.2.2.2 bouyer }
246 1.2.2.2 bouyer }
247 1.2.2.2 bouyer
248 1.2.2.2 bouyer void
249 1.2.2.2 bouyer bicons_puts(char *s)
250 1.2.2.2 bouyer {
251 1.2.2.2 bouyer while (*s)
252 1.2.2.2 bouyer biconscnputc(NULL, *s++);
253 1.2.2.2 bouyer }
254 1.2.2.2 bouyer
255 1.2.2.2 bouyer
256 1.2.2.2 bouyer void
257 1.2.2.2 bouyer bicons_putn(const char *s, int n)
258 1.2.2.2 bouyer {
259 1.2.2.2 bouyer while (0 < n--)
260 1.2.2.2 bouyer biconscnputc(NULL, *s++);
261 1.2.2.2 bouyer }
262 1.2.2.2 bouyer
263 1.2.2.2 bouyer void
264 1.2.2.2 bouyer #ifdef __STDC__
265 1.2.2.2 bouyer bicons_printf(const char *fmt, ...)
266 1.2.2.2 bouyer #else
267 1.2.2.2 bouyer bicons_printf(fmt, va_alist)
268 1.2.2.2 bouyer char *fmt;
269 1.2.2.2 bouyer va_dcl
270 1.2.2.2 bouyer #endif
271 1.2.2.2 bouyer {
272 1.2.2.2 bouyer va_list ap;
273 1.2.2.2 bouyer char buf[0x100];
274 1.2.2.2 bouyer
275 1.2.2.2 bouyer va_start(ap, fmt);
276 1.2.2.2 bouyer vsnprintf(buf, sizeof(buf), fmt, ap);
277 1.2.2.2 bouyer va_end(ap);
278 1.2.2.2 bouyer bicons_puts(buf);
279 1.2.2.2 bouyer }
280 1.2.2.2 bouyer
281 1.2.2.2 bouyer static void
282 1.2.2.2 bouyer draw_char(int x, int y, int c)
283 1.2.2.2 bouyer {
284 1.2.2.2 bouyer int i;
285 1.2.2.2 bouyer u_int8_t *p;
286 1.2.2.2 bouyer
287 1.2.2.2 bouyer if (!fb_vram)
288 1.2.2.2 bouyer return;
289 1.2.2.2 bouyer
290 1.2.2.2 bouyer p = &fb_vram[(y * FONT_HEIGHT * fb_line_bytes) +
291 1.2.2.2 bouyer x * FONT_WIDTH * fb_oxel_bytes];
292 1.2.2.2 bouyer for (i = 0; i < FONT_HEIGHT; i++) {
293 1.2.2.2 bouyer (*fb_put_oxel)(p, font_clR8x8_data
294 1.2.2.2 bouyer [FONT_WIDTH * (FONT_HEIGHT * c + i)], 0xff);
295 1.2.2.2 bouyer p += (fb_line_bytes);
296 1.2.2.2 bouyer }
297 1.2.2.2 bouyer }
298 1.2.2.2 bouyer
299 1.2.2.2 bouyer static void
300 1.2.2.2 bouyer clear(int y, int height)
301 1.2.2.2 bouyer {
302 1.2.2.2 bouyer u_int8_t *p;
303 1.2.2.2 bouyer
304 1.2.2.2 bouyer if (!fb_vram)
305 1.2.2.2 bouyer return;
306 1.2.2.2 bouyer
307 1.2.2.2 bouyer p = &fb_vram[y * fb_line_bytes];
308 1.2.2.2 bouyer
309 1.2.2.2 bouyer while (0 < height--) {
310 1.2.2.2 bouyer memset(p, fb_clear_byte,
311 1.2.2.2 bouyer bicons_width * fb_oxel_bytes * FONT_WIDTH);
312 1.2.2.2 bouyer p += fb_line_bytes;
313 1.2.2.2 bouyer }
314 1.2.2.2 bouyer }
315 1.2.2.2 bouyer
316 1.2.2.2 bouyer static void
317 1.2.2.2 bouyer scroll(int y, int height, int d)
318 1.2.2.2 bouyer {
319 1.2.2.2 bouyer u_int8_t *from, *to;
320 1.2.2.2 bouyer
321 1.2.2.2 bouyer if (!fb_vram)
322 1.2.2.2 bouyer return;
323 1.2.2.2 bouyer
324 1.2.2.2 bouyer if (d < 0) {
325 1.2.2.2 bouyer from = &fb_vram[y * fb_line_bytes];
326 1.2.2.2 bouyer to = from + d * fb_line_bytes;
327 1.2.2.2 bouyer while (0 < height--) {
328 1.2.2.2 bouyer memcpy(to, from, bicons_width * fb_oxel_bytes);
329 1.2.2.2 bouyer from += fb_line_bytes;
330 1.2.2.2 bouyer to += fb_line_bytes;
331 1.2.2.2 bouyer }
332 1.2.2.2 bouyer } else {
333 1.2.2.2 bouyer from = &fb_vram[(y + height - 1) * fb_line_bytes];
334 1.2.2.2 bouyer to = from + d * fb_line_bytes;
335 1.2.2.2 bouyer while (0 < height--) {
336 1.2.2.2 bouyer memcpy(to, from, bicons_xpixel * fb_oxel_bytes / 8);
337 1.2.2.2 bouyer from -= fb_line_bytes;
338 1.2.2.2 bouyer to -= fb_line_bytes;
339 1.2.2.2 bouyer }
340 1.2.2.2 bouyer }
341 1.2.2.2 bouyer }
342 1.2.2.2 bouyer
343 1.2.2.2 bouyer /*=============================================================================
344 1.2.2.2 bouyer *
345 1.2.2.2 bouyer * D2_M2L_3
346 1.2.2.2 bouyer *
347 1.2.2.2 bouyer */
348 1.2.2.2 bouyer static void
349 1.2.2.2 bouyer put_oxel_D2_M2L_3(u_int8_t *xaddr, u_int8_t data, u_int8_t mask)
350 1.2.2.2 bouyer {
351 1.2.2.2 bouyer #if 1
352 1.2.2.2 bouyer u_int16_t *addr = (u_int16_t *)xaddr;
353 1.2.2.2 bouyer static u_int16_t map0[] = {
354 1.2.2.2 bouyer 0x0000, 0x0300, 0x0c00, 0x0f00, 0x3000, 0x3300, 0x3c00, 0x3f00,
355 1.2.2.2 bouyer 0xc000, 0xc300, 0xcc00, 0xcf00, 0xf000, 0xf300, 0xfc00, 0xff00,
356 1.2.2.2 bouyer };
357 1.2.2.2 bouyer static u_int16_t map1[] = {
358 1.2.2.2 bouyer 0x0000, 0x0003, 0x000c, 0x000f, 0x0030, 0x0033, 0x003c, 0x003f,
359 1.2.2.2 bouyer 0x00c0, 0x00c3, 0x00cc, 0x00cf, 0x00f0, 0x00f3, 0x00fc, 0x00ff,
360 1.2.2.2 bouyer };
361 1.2.2.2 bouyer *addr = (map1[data >> 4] | map0[data & 0x0f]);
362 1.2.2.2 bouyer #else
363 1.2.2.2 bouyer static u_int8_t map[] = {
364 1.2.2.2 bouyer 0x00, 0x03, 0x0c, 0x0f, 0x30, 0x33, 0x3c, 0x3f,
365 1.2.2.2 bouyer 0xc0, 0xc3, 0xcc, 0xcf, 0xf0, 0xf3, 0xfc, 0xff,
366 1.2.2.2 bouyer };
367 1.2.2.2 bouyer u_int8_t *addr = xaddr;
368 1.2.2.2 bouyer
369 1.2.2.2 bouyer *addr++ = (map[(data >> 4) & 0x0f] & map[(mask >> 4) & 0x0f]) |
370 1.2.2.2 bouyer (*addr & ~map[(mask >> 4) & 0x0f]);
371 1.2.2.2 bouyer *addr = (map[(data >> 0) & 0x0f] & map[(mask >> 0) & 0x0f]) |
372 1.2.2.2 bouyer (*addr & ~map[(mask >> 0) & 0x0f]);
373 1.2.2.2 bouyer #endif
374 1.2.2.2 bouyer }
375 1.2.2.2 bouyer
376 1.2.2.2 bouyer /*=============================================================================
377 1.2.2.2 bouyer *
378 1.2.2.2 bouyer * D2_M2L_3x2
379 1.2.2.2 bouyer *
380 1.2.2.2 bouyer */
381 1.2.2.2 bouyer static void
382 1.2.2.2 bouyer put_oxel_D2_M2L_3x2(u_int8_t *xaddr, u_int8_t data, u_int8_t mask)
383 1.2.2.2 bouyer {
384 1.2.2.2 bouyer register u_int8_t odd = (data & 0xaa);
385 1.2.2.2 bouyer register u_int8_t even = (data & 0x55);
386 1.2.2.2 bouyer
387 1.2.2.2 bouyer *xaddr = (odd | (even << 1)) | ((odd >> 1) & even);
388 1.2.2.2 bouyer }
389 1.2.2.2 bouyer
390 1.2.2.2 bouyer /*=============================================================================
391 1.2.2.2 bouyer *
392 1.2.2.2 bouyer * D2_M2L_0
393 1.2.2.2 bouyer *
394 1.2.2.2 bouyer */
395 1.2.2.2 bouyer static void
396 1.2.2.2 bouyer put_oxel_D2_M2L_0(u_int8_t *xaddr, u_int8_t data, u_int8_t mask)
397 1.2.2.2 bouyer {
398 1.2.2.2 bouyer #if 1
399 1.2.2.2 bouyer u_int16_t *addr = (u_int16_t *)xaddr;
400 1.2.2.2 bouyer static u_int16_t map0[] = {
401 1.2.2.2 bouyer 0xff00, 0xfc00, 0xf300, 0xf000, 0xcf00, 0xcc00, 0xc300, 0xc000,
402 1.2.2.2 bouyer 0x3f00, 0x3c00, 0x3300, 0x3000, 0x0f00, 0x0c00, 0x0300, 0x0000,
403 1.2.2.2 bouyer };
404 1.2.2.2 bouyer static u_int16_t map1[] = {
405 1.2.2.2 bouyer 0x00ff, 0x00fc, 0x00f3, 0x00f0, 0x00cf, 0x00cc, 0x00c3, 0x00c0,
406 1.2.2.2 bouyer 0x003f, 0x003c, 0x0033, 0x0030, 0x000f, 0x000c, 0x0003, 0x0000,
407 1.2.2.2 bouyer };
408 1.2.2.2 bouyer *addr = (map1[data >> 4] | map0[data & 0x0f]);
409 1.2.2.2 bouyer #else
410 1.2.2.2 bouyer static u_int8_t map[] = {
411 1.2.2.2 bouyer 0x00, 0x03, 0x0c, 0x0f, 0x30, 0x33, 0x3c, 0x3f,
412 1.2.2.2 bouyer 0xc0, 0xc3, 0xcc, 0xcf, 0xf0, 0xf3, 0xfc, 0xff,
413 1.2.2.2 bouyer };
414 1.2.2.2 bouyer u_int8_t *addr = xaddr;
415 1.2.2.2 bouyer
416 1.2.2.2 bouyer *addr++ = (~(map[(data >> 4) & 0x0f] & map[(mask >> 4) & 0x0f])) |
417 1.2.2.2 bouyer (*addr & ~map[(mask >> 4) & 0x0f]);
418 1.2.2.2 bouyer *addr = (~(map[(data >> 0) & 0x0f] & map[(mask >> 0) & 0x0f])) |
419 1.2.2.2 bouyer (*addr & ~map[(mask >> 0) & 0x0f]);
420 1.2.2.2 bouyer #endif
421 1.2.2.2 bouyer }
422 1.2.2.2 bouyer
423 1.2.2.2 bouyer /*=============================================================================
424 1.2.2.2 bouyer *
425 1.2.2.2 bouyer * D2_M2L_0x2
426 1.2.2.2 bouyer *
427 1.2.2.2 bouyer */
428 1.2.2.2 bouyer static void
429 1.2.2.2 bouyer put_oxel_D2_M2L_0x2(u_int8_t *xaddr, u_int8_t data, u_int8_t mask)
430 1.2.2.2 bouyer {
431 1.2.2.2 bouyer register u_int8_t odd = (data & 0xaa);
432 1.2.2.2 bouyer register u_int8_t even = (data & 0x55);
433 1.2.2.2 bouyer
434 1.2.2.2 bouyer *xaddr = ~((odd | (even << 1)) | ((odd >> 1) & even));
435 1.2.2.2 bouyer }
436 1.2.2.2 bouyer
437 1.2.2.2 bouyer /*=============================================================================
438 1.2.2.2 bouyer *
439 1.2.2.2 bouyer * D4_M2L_F
440 1.2.2.2 bouyer *
441 1.2.2.2 bouyer */
442 1.2.2.2 bouyer static void
443 1.2.2.2 bouyer put_oxel_D4_M2L_F(u_int8_t *xaddr, u_int8_t data, u_int8_t mask)
444 1.2.2.2 bouyer {
445 1.2.2.2 bouyer u_int32_t *addr = (u_int32_t *)xaddr;
446 1.2.2.2 bouyer static u_int32_t map[] = {
447 1.2.2.2 bouyer 0x0000, 0x0f00, 0xf000, 0xff00, 0x000f, 0x0f0f, 0xf00f, 0xff0f,
448 1.2.2.2 bouyer 0x00f0, 0x0ff0, 0xf0f0, 0xfff0, 0x00ff, 0x0fff, 0xf0ff, 0xffff,
449 1.2.2.2 bouyer };
450 1.2.2.2 bouyer *addr = (map[data >> 4] | (map[data & 0x0f] << 16));
451 1.2.2.2 bouyer }
452 1.2.2.2 bouyer
453 1.2.2.2 bouyer /*=============================================================================
454 1.2.2.2 bouyer *
455 1.2.2.2 bouyer * D4_M2L_Fx2
456 1.2.2.2 bouyer *
457 1.2.2.2 bouyer */
458 1.2.2.2 bouyer static void
459 1.2.2.2 bouyer put_oxel_D4_M2L_Fx2(u_int8_t *xaddr, u_int8_t data, u_int8_t mask)
460 1.2.2.2 bouyer {
461 1.2.2.2 bouyer u_int16_t *addr = (u_int16_t *)xaddr;
462 1.2.2.2 bouyer static u_int16_t map[] = {
463 1.2.2.2 bouyer 0x00, 0x08, 0x08, 0x0f, 0x80, 0x88, 0x88, 0x8f,
464 1.2.2.2 bouyer 0x80, 0x88, 0x88, 0x8f, 0xf0, 0xf8, 0xf8, 0xff,
465 1.2.2.2 bouyer };
466 1.2.2.2 bouyer
467 1.2.2.2 bouyer *addr = (map[data >> 4] | (map[data & 0x0f] << 8));
468 1.2.2.2 bouyer }
469 1.2.2.2 bouyer
470 1.2.2.2 bouyer /*=============================================================================
471 1.2.2.2 bouyer *
472 1.2.2.2 bouyer * D4_M2L_0
473 1.2.2.2 bouyer *
474 1.2.2.2 bouyer */
475 1.2.2.2 bouyer static void
476 1.2.2.2 bouyer put_oxel_D4_M2L_0(u_int8_t *xaddr, u_int8_t data, u_int8_t mask)
477 1.2.2.2 bouyer {
478 1.2.2.2 bouyer u_int32_t *addr = (u_int32_t *)xaddr;
479 1.2.2.2 bouyer static u_int32_t map[] = {
480 1.2.2.2 bouyer 0xffff, 0xf0ff, 0x0fff, 0x00ff, 0xfff0, 0xf0f0, 0x0ff0, 0x00f0,
481 1.2.2.2 bouyer 0xff0f, 0xf00f, 0x0f0f, 0x000f, 0xff00, 0xf000, 0x0f00, 0x0000,
482 1.2.2.2 bouyer };
483 1.2.2.2 bouyer *addr = (map[data >> 4] | (map[data & 0x0f] << 16));
484 1.2.2.2 bouyer }
485 1.2.2.2 bouyer
486 1.2.2.2 bouyer /*=============================================================================
487 1.2.2.2 bouyer *
488 1.2.2.2 bouyer * D4_M2L_0x2
489 1.2.2.2 bouyer *
490 1.2.2.2 bouyer */
491 1.2.2.2 bouyer static void
492 1.2.2.2 bouyer put_oxel_D4_M2L_0x2(u_int8_t *xaddr, u_int8_t data, u_int8_t mask)
493 1.2.2.2 bouyer {
494 1.2.2.2 bouyer u_int16_t *addr = (u_int16_t *)xaddr;
495 1.2.2.2 bouyer static u_int16_t map[] = {
496 1.2.2.2 bouyer 0xff, 0xf8, 0xf8, 0xf0, 0x8f, 0x88, 0x88, 0x80,
497 1.2.2.2 bouyer 0x8f, 0x88, 0x88, 0x80, 0x0f, 0x08, 0x08, 0x00,
498 1.2.2.2 bouyer };
499 1.2.2.2 bouyer
500 1.2.2.2 bouyer *addr = (map[data >> 4] | (map[data & 0x0f] << 8));
501 1.2.2.2 bouyer }
502 1.2.2.2 bouyer
503 1.2.2.2 bouyer /*=============================================================================
504 1.2.2.2 bouyer *
505 1.2.2.2 bouyer * D8_00
506 1.2.2.2 bouyer *
507 1.2.2.2 bouyer */
508 1.2.2.2 bouyer static void
509 1.2.2.2 bouyer put_oxel_D8_00(u_int8_t *xaddr, u_int8_t data, u_int8_t mask)
510 1.2.2.2 bouyer {
511 1.2.2.2 bouyer int i;
512 1.2.2.2 bouyer u_int8_t *addr = xaddr;
513 1.2.2.2 bouyer
514 1.2.2.2 bouyer for (i = 0; i < 8; i++) {
515 1.2.2.2 bouyer if (mask & 0x80) {
516 1.2.2.2 bouyer *addr = (data & 0x80) ? 0x00 : 0xFF;
517 1.2.2.2 bouyer }
518 1.2.2.2 bouyer addr++;
519 1.2.2.2 bouyer data <<= 1;
520 1.2.2.2 bouyer mask <<= 1;
521 1.2.2.2 bouyer }
522 1.2.2.2 bouyer }
523 1.2.2.2 bouyer
524 1.2.2.2 bouyer /*=============================================================================
525 1.2.2.2 bouyer *
526 1.2.2.2 bouyer * D8_FF
527 1.2.2.2 bouyer *
528 1.2.2.2 bouyer */
529 1.2.2.2 bouyer static void
530 1.2.2.2 bouyer put_oxel_D8_FF(u_int8_t *xaddr, u_int8_t data, u_int8_t mask)
531 1.2.2.2 bouyer {
532 1.2.2.2 bouyer int i;
533 1.2.2.2 bouyer u_int8_t *addr = xaddr;
534 1.2.2.2 bouyer
535 1.2.2.2 bouyer for (i = 0; i < 8; i++) {
536 1.2.2.2 bouyer if (mask & 0x80) {
537 1.2.2.2 bouyer *addr = (data & 0x80) ? 0xFF : 0x00;
538 1.2.2.2 bouyer }
539 1.2.2.2 bouyer addr++;
540 1.2.2.2 bouyer data <<= 1;
541 1.2.2.2 bouyer mask <<= 1;
542 1.2.2.2 bouyer }
543 1.2.2.2 bouyer }
544 1.2.2.2 bouyer
545 1.2.2.2 bouyer /*=============================================================================
546 1.2.2.2 bouyer *
547 1.2.2.2 bouyer * D16_0000
548 1.2.2.2 bouyer *
549 1.2.2.2 bouyer */
550 1.2.2.2 bouyer static void
551 1.2.2.2 bouyer put_oxel_D16_0000(u_int8_t *xaddr, u_int8_t data, u_int8_t mask)
552 1.2.2.2 bouyer {
553 1.2.2.2 bouyer int i;
554 1.2.2.2 bouyer u_int16_t *addr = (u_int16_t *)xaddr;
555 1.2.2.2 bouyer
556 1.2.2.2 bouyer for (i = 0; i < 8; i++) {
557 1.2.2.2 bouyer if (mask & 0x80) {
558 1.2.2.2 bouyer *addr = (data & 0x80) ? 0x0000 : 0xFFFF;
559 1.2.2.2 bouyer }
560 1.2.2.2 bouyer addr++;
561 1.2.2.2 bouyer data <<= 1;
562 1.2.2.2 bouyer mask <<= 1;
563 1.2.2.2 bouyer }
564 1.2.2.2 bouyer }
565 1.2.2.2 bouyer
566 1.2.2.2 bouyer /*=============================================================================
567 1.2.2.2 bouyer *
568 1.2.2.2 bouyer * D16_FFFF
569 1.2.2.2 bouyer *
570 1.2.2.2 bouyer */
571 1.2.2.2 bouyer static void
572 1.2.2.2 bouyer put_oxel_D16_FFFF(u_int8_t *xaddr, u_int8_t data, u_int8_t mask)
573 1.2.2.2 bouyer {
574 1.2.2.2 bouyer int i;
575 1.2.2.2 bouyer u_int16_t *addr = (u_int16_t *)xaddr;
576 1.2.2.2 bouyer
577 1.2.2.2 bouyer for (i = 0; i < 8; i++) {
578 1.2.2.2 bouyer if (mask & 0x80) {
579 1.2.2.2 bouyer *addr = (data & 0x80) ? 0xFFFF : 0x0000;
580 1.2.2.2 bouyer }
581 1.2.2.2 bouyer addr++;
582 1.2.2.2 bouyer data <<= 1;
583 1.2.2.2 bouyer mask <<= 1;
584 1.2.2.2 bouyer }
585 1.2.2.2 bouyer }
586