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