2 * Copyright (c) 2007-2011 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 /* charset conversions */
27 extern u8 ascii2ebcdic_table
[256];
28 extern u8 ebcdic2ascii_table
[256];
30 /* ASCII transforms */
31 extern u8 ascii2upper_table
[256];
34 * Generic translate buffer function.
36 static inline void __translate(u8
*buf
, int len
, const u8
*table
)
39 " sgr %%r0,%%r0\n" /* test byte = 0 */
40 " la %%r2,0(%0)\n" /* buffer */
41 " lgr %%r3,%2\n" /* length */
42 " la %%r4,0(%1)\n" /* table */
51 "cc", "r0", "r2", "r3", "r4"
55 #define ascii2ebcdic(buf, len) \
56 __translate((buf), (len), ascii2ebcdic_table)
57 #define ebcdic2ascii(buf, len) \
58 __translate((buf), (len), ebcdic2ascii_table)
60 #define ascii2upper(buf, len) \
61 __translate((buf), (len), ascii2upper_table)