18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * EBCDIC -> ASCII, ASCII -> EBCDIC conversion routines. 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * S390 version 68c2ecf20Sopenharmony_ci * Copyright IBM Corp. 1999 78c2ecf20Sopenharmony_ci * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com> 88c2ecf20Sopenharmony_ci */ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#ifndef _EBCDIC_H 118c2ecf20Sopenharmony_ci#define _EBCDIC_H 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#include <linux/types.h> 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ciextern __u8 _ascebc_500[256]; /* ASCII -> EBCDIC 500 conversion table */ 168c2ecf20Sopenharmony_ciextern __u8 _ebcasc_500[256]; /* EBCDIC 500 -> ASCII conversion table */ 178c2ecf20Sopenharmony_ciextern __u8 _ascebc[256]; /* ASCII -> EBCDIC conversion table */ 188c2ecf20Sopenharmony_ciextern __u8 _ebcasc[256]; /* EBCDIC -> ASCII conversion table */ 198c2ecf20Sopenharmony_ciextern __u8 _ebc_tolower[256]; /* EBCDIC -> lowercase */ 208c2ecf20Sopenharmony_ciextern __u8 _ebc_toupper[256]; /* EBCDIC -> uppercase */ 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_cistatic inline void 238c2ecf20Sopenharmony_cicodepage_convert(const __u8 *codepage, volatile char *addr, unsigned long nr) 248c2ecf20Sopenharmony_ci{ 258c2ecf20Sopenharmony_ci if (nr-- <= 0) 268c2ecf20Sopenharmony_ci return; 278c2ecf20Sopenharmony_ci asm volatile( 288c2ecf20Sopenharmony_ci " bras 1,1f\n" 298c2ecf20Sopenharmony_ci " tr 0(1,%0),0(%2)\n" 308c2ecf20Sopenharmony_ci "0: tr 0(256,%0),0(%2)\n" 318c2ecf20Sopenharmony_ci " la %0,256(%0)\n" 328c2ecf20Sopenharmony_ci "1: ahi %1,-256\n" 338c2ecf20Sopenharmony_ci " jnm 0b\n" 348c2ecf20Sopenharmony_ci " ex %1,0(1)" 358c2ecf20Sopenharmony_ci : "+&a" (addr), "+&a" (nr) 368c2ecf20Sopenharmony_ci : "a" (codepage) : "cc", "memory", "1"); 378c2ecf20Sopenharmony_ci} 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci#define ASCEBC(addr,nr) codepage_convert(_ascebc, addr, nr) 408c2ecf20Sopenharmony_ci#define EBCASC(addr,nr) codepage_convert(_ebcasc, addr, nr) 418c2ecf20Sopenharmony_ci#define ASCEBC_500(addr,nr) codepage_convert(_ascebc_500, addr, nr) 428c2ecf20Sopenharmony_ci#define EBCASC_500(addr,nr) codepage_convert(_ebcasc_500, addr, nr) 438c2ecf20Sopenharmony_ci#define EBC_TOLOWER(addr,nr) codepage_convert(_ebc_tolower, addr, nr) 448c2ecf20Sopenharmony_ci#define EBC_TOUPPER(addr,nr) codepage_convert(_ebc_toupper, addr, nr) 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci#endif 478c2ecf20Sopenharmony_ci 48