1*16d86563SAlexander Pyhalov /*
2*16d86563SAlexander Pyhalov  * CDDL HEADER START
3*16d86563SAlexander Pyhalov  *
4*16d86563SAlexander Pyhalov  * The contents of this file are subject to the terms of the
5*16d86563SAlexander Pyhalov  * Common Development and Distribution License (the "License").
6*16d86563SAlexander Pyhalov  * You may not use this file except in compliance with the License.
7*16d86563SAlexander Pyhalov  *
8*16d86563SAlexander Pyhalov  * You can obtain a copy of the license at src/OPENSOLARIS.LICENSE
9*16d86563SAlexander Pyhalov  * or http://www.opensolaris.org/os/licensing.
10*16d86563SAlexander Pyhalov  * See the License for the specific language governing permissions
11*16d86563SAlexander Pyhalov  * and limitations under the License.
12*16d86563SAlexander Pyhalov  *
13*16d86563SAlexander Pyhalov  * When distributing Covered Code, include this CDDL HEADER in each
14*16d86563SAlexander Pyhalov  * file and include the License file at src/OPENSOLARIS.LICENSE.
15*16d86563SAlexander Pyhalov  * If applicable, add the following below this CDDL HEADER, with the
16*16d86563SAlexander Pyhalov  * fields enclosed by brackets "[]" replaced with your own identifying
17*16d86563SAlexander Pyhalov  * information: Portions Copyright [yyyy] [name of copyright owner]
18*16d86563SAlexander Pyhalov  *
19*16d86563SAlexander Pyhalov  * CDDL HEADER END
20*16d86563SAlexander Pyhalov  */
21*16d86563SAlexander Pyhalov /*
22*16d86563SAlexander Pyhalov  * Copyright (c) 1996 by Sun Microsystems, Inc.
23*16d86563SAlexander Pyhalov  */
24*16d86563SAlexander Pyhalov 
25*16d86563SAlexander Pyhalov 
26*16d86563SAlexander Pyhalov #ifndef _COMMON_HAN_H_
27*16d86563SAlexander Pyhalov #define	_COMMON_HAN_H_
28*16d86563SAlexander Pyhalov 
29*16d86563SAlexander Pyhalov #include <sys/isa_defs.h>
30*16d86563SAlexander Pyhalov 
31*16d86563SAlexander Pyhalov #ifdef	_BIG_ENDIAN
32*16d86563SAlexander Pyhalov 
33*16d86563SAlexander Pyhalov typedef union {
34*16d86563SAlexander Pyhalov         unsigned int code;
35*16d86563SAlexander Pyhalov         struct {
36*16d86563SAlexander Pyhalov                 unsigned short high;
37*16d86563SAlexander Pyhalov                 unsigned short low;
38*16d86563SAlexander Pyhalov         } word;
39*16d86563SAlexander Pyhalov         struct {
40*16d86563SAlexander Pyhalov                 unsigned char byte1;
41*16d86563SAlexander Pyhalov                 unsigned char byte2;
42*16d86563SAlexander Pyhalov                 unsigned char byte3;
43*16d86563SAlexander Pyhalov                 unsigned char byte4;
44*16d86563SAlexander Pyhalov         } byte;
45*16d86563SAlexander Pyhalov         struct {
46*16d86563SAlexander Pyhalov                 unsigned int    high16bits:     16;	/* should be 0x00 */
47*16d86563SAlexander Pyhalov                 unsigned int    msb1:           1;	/* should be 0x01 */
48*16d86563SAlexander Pyhalov                 unsigned int    data1:       	7;
49*16d86563SAlexander Pyhalov                 unsigned int    msb2:           1;	/* should be 0x01 */
50*16d86563SAlexander Pyhalov                 unsigned int    data2:       	7;
51*16d86563SAlexander Pyhalov         } wansung;
52*16d86563SAlexander Pyhalov         struct {
53*16d86563SAlexander Pyhalov                 unsigned int    high16bits:     16;	/* should be 0x00 */
54*16d86563SAlexander Pyhalov                 unsigned int    msb:            1;	/* should be 0x01 */
55*16d86563SAlexander Pyhalov                 unsigned int    chosung:        5;
56*16d86563SAlexander Pyhalov                 unsigned int    joongsung:      5;
57*16d86563SAlexander Pyhalov                 unsigned int    jongsung:       5;
58*16d86563SAlexander Pyhalov         } johap;
59*16d86563SAlexander Pyhalov         struct {
60*16d86563SAlexander Pyhalov                 unsigned int    high16bits:     16;	/* should be 0x00 */
61*16d86563SAlexander Pyhalov                 unsigned int    data1:          4;
62*16d86563SAlexander Pyhalov                 unsigned int    data2:          6;
63*16d86563SAlexander Pyhalov                 unsigned int    data3:          6;
64*16d86563SAlexander Pyhalov         } unicode;
65*16d86563SAlexander Pyhalov         struct {
66*16d86563SAlexander Pyhalov                 unsigned int    high8bits:      8;	/* should be 0x00 */
67*16d86563SAlexander Pyhalov                 unsigned int    sign1:          4;	/* should be 0x0E */
68*16d86563SAlexander Pyhalov                 unsigned int    data1:          4;
69*16d86563SAlexander Pyhalov                 unsigned int    sign2:          2;	/* should be 0x02 */
70*16d86563SAlexander Pyhalov                 unsigned int    data2:          6;
71*16d86563SAlexander Pyhalov                 unsigned int    sign3:          2;	/* should be 0x02 */
72*16d86563SAlexander Pyhalov                 unsigned int    data3:          6;
73*16d86563SAlexander Pyhalov         } utf8;
74*16d86563SAlexander Pyhalov } hcode_type;
75*16d86563SAlexander Pyhalov 
76*16d86563SAlexander Pyhalov #else /* _BIG_ENDIAN */
77*16d86563SAlexander Pyhalov 
78*16d86563SAlexander Pyhalov typedef union {
79*16d86563SAlexander Pyhalov         unsigned int code;
80*16d86563SAlexander Pyhalov         struct {
81*16d86563SAlexander Pyhalov                 unsigned short low;
82*16d86563SAlexander Pyhalov                 unsigned short high;
83*16d86563SAlexander Pyhalov         } word;
84*16d86563SAlexander Pyhalov         struct {
85*16d86563SAlexander Pyhalov                 unsigned char byte4;
86*16d86563SAlexander Pyhalov                 unsigned char byte3;
87*16d86563SAlexander Pyhalov                 unsigned char byte2;
88*16d86563SAlexander Pyhalov                 unsigned char byte1;
89*16d86563SAlexander Pyhalov         } byte;
90*16d86563SAlexander Pyhalov         struct {
91*16d86563SAlexander Pyhalov                 unsigned int    data2:       	7;
92*16d86563SAlexander Pyhalov                 unsigned int    msb2:           1;	/* should be 0x01 */
93*16d86563SAlexander Pyhalov                 unsigned int    data1:       	7;
94*16d86563SAlexander Pyhalov                 unsigned int    msb1:           1;	/* should be 0x01 */
95*16d86563SAlexander Pyhalov                 unsigned int    high16bits:     16;	/* should be 0x00 */
96*16d86563SAlexander Pyhalov         } wansung;
97*16d86563SAlexander Pyhalov         struct {
98*16d86563SAlexander Pyhalov                 unsigned int    jongsung:       5;
99*16d86563SAlexander Pyhalov                 unsigned int    joongsung:      5;
100*16d86563SAlexander Pyhalov                 unsigned int    chosung:        5;
101*16d86563SAlexander Pyhalov                 unsigned int    msb:            1;	/* should be 0x01 */
102*16d86563SAlexander Pyhalov                 unsigned int    high16bits:     16;	/* should be 0x00 */
103*16d86563SAlexander Pyhalov         } johap;
104*16d86563SAlexander Pyhalov         struct {
105*16d86563SAlexander Pyhalov                 unsigned int    data3:          6;
106*16d86563SAlexander Pyhalov                 unsigned int    data2:          6;
107*16d86563SAlexander Pyhalov                 unsigned int    data1:          4;
108*16d86563SAlexander Pyhalov                 unsigned int    high16bits:     16;	/* should be 0x00 */
109*16d86563SAlexander Pyhalov         } unicode;
110*16d86563SAlexander Pyhalov         struct {
111*16d86563SAlexander Pyhalov                 unsigned int    data3:          6;
112*16d86563SAlexander Pyhalov                 unsigned int    sign3:          2;	/* should be 0x02 */
113*16d86563SAlexander Pyhalov                 unsigned int    data2:          6;
114*16d86563SAlexander Pyhalov                 unsigned int    sign2:          2;	/* should be 0x02 */
115*16d86563SAlexander Pyhalov                 unsigned int    data1:          4;
116*16d86563SAlexander Pyhalov                 unsigned int    sign1:          4;	/* should be 0x0E */
117*16d86563SAlexander Pyhalov                 unsigned int    high8bits:      8;	/* should be 0x00 */
118*16d86563SAlexander Pyhalov         } utf8;
119*16d86563SAlexander Pyhalov } hcode_type;
120*16d86563SAlexander Pyhalov 
121*16d86563SAlexander Pyhalov #endif /* _BIG_ENDIAN */
122*16d86563SAlexander Pyhalov 
123*16d86563SAlexander Pyhalov #endif	/* _COMMON_HAN_H_ */
124