Home | History | Annotate | Line # | Download | only in dev
sh.h revision 1.4.70.1
      1  1.4.70.1  yamt /* -*-C++-*-	$NetBSD: sh.h,v 1.4.70.1 2008/05/18 12:32:02 yamt Exp $	*/
      2       1.1   uch 
      3       1.1   uch /*-
      4       1.1   uch  * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
      5       1.1   uch  * All rights reserved.
      6       1.1   uch  *
      7       1.1   uch  * This code is derived from software contributed to The NetBSD Foundation
      8       1.1   uch  * by UCHIYAMA Yasushi.
      9       1.1   uch  *
     10       1.1   uch  * Redistribution and use in source and binary forms, with or without
     11       1.1   uch  * modification, are permitted provided that the following conditions
     12       1.1   uch  * are met:
     13       1.1   uch  * 1. Redistributions of source code must retain the above copyright
     14       1.1   uch  *    notice, this list of conditions and the following disclaimer.
     15       1.1   uch  * 2. Redistributions in binary form must reproduce the above copyright
     16       1.1   uch  *    notice, this list of conditions and the following disclaimer in the
     17       1.1   uch  *    documentation and/or other materials provided with the distribution.
     18       1.1   uch  *
     19       1.1   uch  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20       1.1   uch  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21       1.1   uch  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22       1.1   uch  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23       1.1   uch  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24       1.1   uch  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25       1.1   uch  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26       1.1   uch  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27       1.1   uch  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28       1.1   uch  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29       1.1   uch  * POSSIBILITY OF SUCH DAMAGE.
     30       1.1   uch  */
     31       1.1   uch 
     32       1.1   uch #ifndef _HPCBOOT_SH_DEV_SH_H_
     33       1.2   uch #define	_HPCBOOT_SH_DEV_SH_H_
     34       1.1   uch 
     35       1.1   uch /*
     36       1.1   uch  * SH3, SH4 embeded devices.
     37       1.1   uch  */
     38       1.1   uch 
     39       1.1   uch /*
     40       1.1   uch  * INTC
     41       1.1   uch  */
     42       1.1   uch /* SH7709/7709A */
     43       1.1   uch /* R/W 16bit */
     44       1.2   uch #define	SH3_ICR0		0xfffffee0
     45       1.2   uch #define	SH3_ICR1		0xa4000010
     46       1.2   uch #define	SH3_ICR2		0xa4000012
     47       1.2   uch #define	SH3_PINTER		0xa4000014
     48       1.2   uch #define	SH3_IPRA		0xfffffee2
     49       1.2   uch #define	SH3_IPRB		0xfffffee4
     50       1.2   uch #define	SH3_IPRC		0xa4000016
     51       1.2   uch #define	SH3_IPRD		0xa4000018
     52       1.2   uch #define	SH3_IPRE		0xa400001a
     53       1.2   uch /* R/W 8bit */
     54       1.2   uch #define	SH3_IRR0		0xa4000004
     55       1.2   uch /* R 8bit */
     56       1.2   uch #define	SH3_IRR1		0xa4000006
     57       1.2   uch #define	SH3_IRR2		0xa4000008
     58       1.2   uch 
     59       1.2   uch #define	SH3_ICR0_NMIL		  0x8000
     60       1.2   uch #define	SH3_ICR0_NMIE		  0x0100
     61       1.2   uch 
     62       1.2   uch #define	SH3_ICR1_MAI		  0x8000
     63       1.2   uch #define	SH3_ICR1_IRQLVL		  0x4000
     64       1.2   uch #define	SH3_ICR1_BLMSK		  0x2000
     65       1.2   uch #define	SH3_ICR1_IRLSEN		  0x1000
     66       1.2   uch #define	SH3_ICR1_IRQ51S		  0x0800
     67       1.2   uch #define	SH3_ICR1_IRQ50S		  0x0400
     68       1.2   uch #define	SH3_ICR1_IRQ41S		  0x0200
     69       1.2   uch #define	SH3_ICR1_IRQ40S		  0x0100
     70       1.2   uch #define	SH3_ICR1_IRQ31S		  0x0080
     71       1.2   uch #define	SH3_ICR1_IRQ30S		  0x0040
     72       1.2   uch #define	SH3_ICR1_IRQ21S		  0x0020
     73       1.2   uch #define	SH3_ICR1_IRQ20S		  0x0010
     74       1.2   uch #define	SH3_ICR1_IRQ11S		  0x0008
     75       1.2   uch #define	SH3_ICR1_IRQ10S		  0x0004
     76       1.2   uch #define	SH3_ICR1_IRQ01S		  0x0002
     77       1.2   uch #define	SH3_ICR1_IRQ00S		  0x0001
     78       1.2   uch 
     79       1.2   uch #define	SH3_SENSE_SELECT_MASK		  0x3
     80       1.2   uch #define	SH3_SENSE_SELECT_FALLING_EDGE	  0x0
     81       1.2   uch #define	SH3_SENSE_SELECT_RAISING_EDGE	  0x1
     82       1.2   uch #define	SH3_SENSE_SELECT_LOW_LEVEL	  0x2
     83       1.2   uch #define	SH3_SENSE_SELECT_RESERVED	  0x3
     84       1.2   uch 
     85       1.2   uch #define	SH3_ICR2_PINT15S	  0x8000
     86       1.2   uch #define	SH3_ICR2_PINT14S	  0x4000
     87       1.2   uch #define	SH3_ICR2_PINT13S	  0x2000
     88       1.2   uch #define	SH3_ICR2_PINT12S	  0x1000
     89       1.2   uch #define	SH3_ICR2_PINT11S	  0x0800
     90       1.2   uch #define	SH3_ICR2_PINT10S	  0x0400
     91       1.2   uch #define	SH3_ICR2_PINT9S		  0x0200
     92       1.2   uch #define	SH3_ICR2_PINT8S		  0x0100
     93       1.2   uch #define	SH3_ICR2_PINT7S		  0x0080
     94       1.2   uch #define	SH3_ICR2_PINT6S		  0x0040
     95       1.2   uch #define	SH3_ICR2_PINT5S		  0x0020
     96       1.2   uch #define	SH3_ICR2_PINT4S		  0x0010
     97       1.2   uch #define	SH3_ICR2_PINT3S		  0x0008
     98       1.2   uch #define	SH3_ICR2_PINT2S		  0x0004
     99       1.2   uch #define	SH3_ICR2_PINT1S		  0x0002
    100       1.2   uch #define	SH3_ICR2_PINT0S		  0x0001
    101       1.1   uch 
    102       1.2   uch #define	SH_IPR_MASK		0xf
    103       1.1   uch 
    104       1.1   uch /* SH7750 */
    105       1.2   uch #define	SH4_ICR			0xffd00000
    106       1.2   uch #define	  SH4_ICR_NMIL		  0x8000
    107       1.2   uch #define	  SH4_ICR_MAI		  0x4000
    108       1.2   uch #define	  SH4_ICR_NMIB		  0x0200
    109       1.2   uch #define	  SH4_ICR_NMIE		  0x0100
    110       1.2   uch #define	  SH4_ICR_IRLM		  0x0080
    111       1.2   uch #define	SH4_IPRA		0xffd00004
    112       1.2   uch #define	SH4_IPRB		0xffd00008
    113       1.2   uch #define	SH4_IPRC		0xffd0000c
    114       1.1   uch /* SH7750S */
    115       1.2   uch #define	SH4_IPRD		0xffd00010
    116       1.1   uch 
    117       1.1   uch /*
    118       1.1   uch  * Bus State Controller
    119       1.1   uch  */
    120       1.2   uch #define	SH3_BCR1	        0xffffff60
    121       1.2   uch #define	SH3_BCR2	        0xffffff62
    122       1.2   uch #define	SH3_WCR1	        0xffffff64
    123       1.2   uch #define	SH3_WCR2	        0xffffff66
    124       1.2   uch #define	SH3_MCR		        0xffffff68
    125       1.2   uch #define	SH3_DCR		        0xffffff6a
    126       1.2   uch #define	SH3_PCR		        0xffffff6c
    127       1.2   uch #define	SH3_RTCSR	        0xffffff6e
    128       1.2   uch #define	SH3_RTCNT	        0xffffff70
    129       1.2   uch #define	SH3_RTCOR	        0xffffff72
    130       1.2   uch #define	SH3_RFCR	        0xffffff74
    131       1.2   uch #define	SH3_BCR3	        0xffffff7e
    132       1.1   uch 
    133       1.1   uch /*
    134       1.1   uch  * Pin Function Controller
    135       1.2   uch  */
    136       1.2   uch #define	SH3_PACR		0xa4000100
    137       1.2   uch #define	SH3_PBCR		0xa4000102
    138       1.2   uch #define	SH3_PCCR		0xa4000104
    139       1.2   uch #define	SH3_PDCR		0xa4000106
    140       1.2   uch #define	SH3_PECR		0xa4000108
    141       1.2   uch #define	SH3_PFCR		0xa400010a
    142       1.2   uch #define	SH3_PGCR		0xa400010c
    143       1.2   uch #define	SH3_PHCR		0xa400010e
    144       1.2   uch #define	SH3_PJCR		0xa4000110
    145       1.2   uch #define	SH3_PKCR		0xa4000112
    146       1.2   uch #define	SH3_PLCR		0xa4000114
    147       1.2   uch #define	SH3_SCPCR		0xa4000116
    148       1.1   uch 
    149       1.1   uch /*
    150       1.1   uch  * I/O port
    151       1.1   uch  */
    152       1.2   uch #define	SH3_PADR		0xa4000120
    153       1.2   uch #define	SH3_PBDR		0xa4000122
    154       1.2   uch #define	SH3_PCDR		0xa4000124
    155       1.2   uch #define	SH3_PDDR		0xa4000126
    156       1.2   uch #define	SH3_PEDR		0xa4000128
    157       1.2   uch #define	SH3_PFDR		0xa400012a
    158       1.2   uch #define	SH3_PGDR		0xa400012c
    159       1.2   uch #define	SH3_PHDR		0xa400012e
    160       1.2   uch #define	SH3_PJDR		0xa4000130
    161       1.2   uch #define	SH3_PKDR		0xa4000132
    162       1.2   uch #define	SH3_PLDR		0xa4000134
    163       1.2   uch #define	SH3_SCPDR		0xa4000136
    164       1.1   uch 
    165       1.1   uch /*
    166       1.1   uch  * TMU
    167       1.1   uch  */
    168       1.2   uch #define	SH3_TOCR		0xfffffe90
    169       1.2   uch #define	  SH3_TOCR_TCOE		  0x01
    170       1.2   uch #define	SH3_TSTR		0xfffffe92
    171       1.2   uch #define	  SH3_TSTR_STR2		  0x04
    172       1.2   uch #define	  SH3_TSTR_STR1		  0x02
    173       1.2   uch #define	  SH3_TSTR_STR0		  0x01
    174       1.2   uch #define	SH3_TCOR0		0xfffffe94
    175       1.2   uch #define	SH3_TCNT0		0xfffffe98
    176       1.2   uch #define	SH3_TCR0		0xfffffe9c
    177       1.2   uch #define	SH3_TCOR1		0xfffffea0
    178       1.2   uch #define	SH3_TCNT1		0xfffffea4
    179       1.2   uch #define	SH3_TCR1		0xfffffea8
    180       1.2   uch #define	SH3_TCOR2		0xfffffeac
    181       1.2   uch #define	SH3_TCNT2		0xfffffeb0
    182       1.2   uch #define	SH3_TCR2		0xfffffeb4
    183       1.2   uch #define	SH3_TCPR2		0xfffffeb8
    184       1.2   uch #define	  SH3_TCR_ICPF		  0x0200
    185       1.2   uch #define	  SH3_TCR_UNF		  0x0100
    186       1.2   uch #define	  SH3_TCR_ICPE1		  0x0080
    187       1.2   uch #define	  SH3_TCR_ICPE0		  0x0040
    188       1.2   uch #define	  SH3_TCR_UNIE		  0x0020
    189       1.2   uch #define	  SH3_TCR_CKEG1		  0x0010
    190       1.2   uch #define	  SH3_TCR_CKEG0		  0x0008
    191       1.2   uch #define	  SH3_TCR_TPSC2		  0x0004
    192       1.2   uch #define	  SH3_TCR_TPSC1		  0x0002
    193       1.2   uch #define	  SH3_TCR_TPSC0		  0x0001
    194       1.2   uch 
    195       1.2   uch #define	  SH3_TCR_TPSC_P4	  0x0000
    196       1.2   uch #define	  SH3_TCR_TPSC_P16	  0x0001
    197       1.2   uch #define	  SH3_TCR_TPSC_P64	  0x0002
    198       1.2   uch #define	  SH3_TCR_TPSC_P256	  0x0003
    199       1.1   uch 
    200       1.1   uch /*
    201       1.1   uch  * SCI
    202       1.1   uch  */
    203       1.2   uch #define	SH4_SCSMR		0xffe00000
    204       1.2   uch #define	SH4_SCBRR		0xffe00004
    205       1.2   uch #define	SH4_SCSCR		0xffe00008
    206       1.2   uch #define	SH4_SCTDR		0xffe0000c
    207       1.2   uch #define	SH4_SCSSR		0xffe00010
    208       1.2   uch #define	SH4_SCRDR		0xffe00014
    209       1.2   uch 
    210       1.2   uch #define	SH3_SCRSR		/* can't access from CPU */
    211       1.2   uch #define	SH3_SCTSR		/* can't access from CPU */
    212       1.2   uch #define	SH3_SCSMR		0xfffffe80
    213       1.2   uch #define	SH3_SCBRR		0xfffffe82
    214       1.2   uch #define	SH3_SCSCR		0xfffffe84
    215       1.2   uch #define	SH3_SCTDR		0xfffffe86
    216       1.2   uch #define	SH3_SCSSR		0xfffffe88
    217       1.2   uch #define	SH3_SCRDR		0xfffffe8a
    218       1.2   uch #define	SH3_SCPCR		0xa4000116
    219       1.2   uch #define	SH3_SCPDR		0xa4000136
    220       1.1   uch 
    221       1.2   uch #define	SCSSR_TDRE		  0x80
    222       1.1   uch 
    223       1.2   uch #define	SH3_SCI_TX_BUSY()						\
    224       1.1   uch 	while ((_reg_read_1(SH3_SCSSR) & SCSSR_TDRE) == 0)
    225       1.1   uch 
    226       1.2   uch #define	SH3_SCI_PUTC(c)							\
    227       1.1   uch __BEGIN_MACRO								\
    228       1.1   uch 	SH3_SCI_TX_BUSY();						\
    229       1.1   uch 	_reg_write_1(SH3_SCTDR, c);					\
    230       1.1   uch 	_reg_write_1(SH3_SCSSR,						\
    231       1.1   uch 	    _reg_read_1(SH3_SCSSR) & ~SCSSR_TDRE);			\
    232       1.1   uch __END_MACRO
    233       1.1   uch 
    234       1.2   uch #define	SH3_SCI_PRINT(s)							\
    235       1.1   uch __BEGIN_MACRO								\
    236       1.1   uch 	char *__s =(char *)(s);						\
    237       1.1   uch 	int __i;							\
    238       1.1   uch 	for (__i = 0; __s[__i] != '\0'; __i++) {			\
    239       1.1   uch 		char __c = __s[__i];					\
    240       1.1   uch 		if (__c == '\n')					\
    241       1.1   uch 			SH3_SCI_PUTC('\r');				\
    242       1.1   uch 		SH3_SCI_PUTC(__c);					\
    243       1.1   uch 	}								\
    244       1.1   uch __END_MACRO
    245       1.1   uch 
    246       1.2   uch /*
    247       1.1   uch  * SCIF
    248       1.1   uch  */
    249       1.2   uch #define	SH4_SCSMR2		0xffe80000
    250       1.2   uch #define	SH4_SCBRR2		0xffe80004
    251       1.2   uch #define	SH4_SCSCR2		0xffe80008
    252       1.2   uch #define	SH4_SCFTDR2		0xffe8000c
    253       1.2   uch #define	SH4_SCFSR2		0xffe80010
    254       1.2   uch #define	SH4_SCFRDR2		0xffe80014
    255       1.2   uch #define	SH4_SCFCR2		0xffe80018
    256       1.2   uch #define	SH4_SCFDR2		0xffe8001c
    257       1.2   uch #define	SH4_SCSPTR2		0xffe80020
    258       1.2   uch #define	SH4_SCLSR2		0xffe80024
    259       1.2   uch #define	SH4_SCSMR2		0xffe80000
    260       1.2   uch #define	SH4_SCBRR2		0xffe80004
    261       1.2   uch #define	SH4_SCSCR2		0xffe80008
    262       1.2   uch #define	SH4_SCFTDR2		0xffe8000c
    263       1.2   uch #define	SH4_SCFSR2		0xffe80010
    264       1.2   uch #define	SH4_SCFRDR2		0xffe80014
    265       1.2   uch #define	SH4_SCFCR2		0xffe80018
    266       1.2   uch #define	SH4_SCFDR2		0xffe8001c
    267       1.2   uch #define	SH4_SCSPTR2		0xffe80020
    268       1.2   uch #define	SH4_SCLSR2		0xffe80024
    269       1.1   uch 
    270       1.1   uch #define	SH4_SCSSR2		SH4_SCFSR2
    271       1.1   uch #define	SH4_SCSSR2		SH4_SCFSR2
    272       1.1   uch 
    273       1.2   uch #define	SH3_SCSMR2		0xa4000150	/* R/W */
    274       1.2   uch #define	SH3_SCBRR2		0xa4000152	/* R/W */
    275       1.2   uch #define	SH3_SCSCR2		0xa4000154	/* R/W */
    276       1.2   uch #define	SH3_SCFTDR2		0xa4000156	/* W */
    277       1.2   uch #define	SH3_SCSSR2		0xa4000158	/* R/W(0 write only) */
    278       1.2   uch #define	SH3_SCFRDR2		0xa400015a	/* R */
    279       1.2   uch #define	SH3_SCFCR2		0xa400015c	/* R/W */
    280       1.2   uch #define	SH3_SCFDR2		0xa400015e	/* R */
    281       1.2   uch #define	SH3_SCSMR2		0xa4000150	/* R/W */
    282       1.2   uch #define	SH3_SCBRR2		0xa4000152	/* R/W */
    283       1.2   uch #define	SH3_SCSCR2		0xa4000154	/* R/W */
    284       1.2   uch #define	SH3_SCFTDR2		0xa4000156	/* W */
    285       1.2   uch #define	SH3_SCSSR2		0xa4000158	/* R/W(0 write only) */
    286       1.2   uch #define	SH3_SCFRDR2		0xa400015a	/* R */
    287       1.2   uch #define	SH3_SCFCR2		0xa400015c	/* R/W */
    288       1.2   uch #define	SH3_SCFDR2		0xa400015e	/* R */
    289       1.2   uch 
    290       1.2   uch #define	SCSCR2_TIE	          0x0080	/* Transmit Interrupt Enable */
    291       1.2   uch #define	SCSCR2_RIE	          0x0040	/* Receive Interrupt Enable */
    292       1.2   uch #define	SCSCR2_TE	          0x0020	/* Transmit Enable */
    293       1.2   uch #define	SCSCR2_RE	          0x0010	/* Receive Enable */
    294       1.2   uch #define	SCSCR2_CKE1	          0x0002	/* ClocK Enable 1 */
    295       1.2   uch #define	SCSCR2_CKE0	          0x0001	/* ClocK Enable 0 */
    296       1.2   uch #define	SCSCR2_CKE	          0x0003	/* ClocK Enable mask */
    297       1.2   uch 
    298       1.2   uch #define	SCSSR2_ER	          0x0080	/* ERror */
    299       1.2   uch #define	SCSSR2_TEND	          0x0040	/* Transmit END */
    300       1.2   uch #define	SCSSR2_TDFE	          0x0020	/* Transmit Data Fifo Empty */
    301       1.2   uch #define	SCSSR2_BRK	          0x0010	/* BReaK detection */
    302       1.2   uch #define	SCSSR2_FER	          0x0008	/* Framing ERror */
    303       1.2   uch #define	SCSSR2_PER	          0x0004	/* Parity ERror */
    304       1.2   uch #define	SCSSR2_RDF	          0x0002	/* Receive fifo Data Full */
    305       1.2   uch #define	SCSSR2_DR	          0x0001	/* Data Ready */
    306       1.2   uch 
    307       1.2   uch #define	SCFCR2_RTRG1		  0x0080	/* Receive TRiGger 1 */
    308       1.2   uch #define	SCFCR2_RTRG0		  0x0040	/* Receive TRiGger 0 */
    309       1.2   uch #define	SCFCR2_TTRG1		  0x0020	/* Transmit TRiGger 1 */
    310       1.2   uch #define	SCFCR2_TTRG0		  0x0010	/* Transmit TRiGger 0 */
    311       1.2   uch #define	SCFCR2_MCE		  0x0008	/* Modem Control Enable */
    312       1.2   uch #define	SCFCR2_TFRST		  0x0004	/* Transmit Fifo register ReSeT */
    313       1.2   uch #define	SCFCR2_RFRST		  0x0002	/* Receive Fifo register ReSeT */
    314       1.2   uch #define	SCFCR2_LOOP		  0x0001	/* LOOP back test */
    315       1.2   uch #define	FIFO_RCV_TRIGGER_1	  0x0000
    316       1.2   uch #define	FIFO_RCV_TRIGGER_4	  0x0040
    317       1.2   uch #define	FIFO_RCV_TRIGGER_8	  0x0080
    318       1.2   uch #define	FIFO_RCV_TRIGGER_14	  0x00c0
    319       1.2   uch #define	FIFO_XMT_TRIGGER_8	  0x0000
    320       1.2   uch #define	FIFO_XMT_TRIGGER_4	  0x0010
    321       1.2   uch #define	FIFO_XMT_TRIGGER_2	  0x0020
    322       1.2   uch #define	FIFO_XMT_TRIGGER_1	  0x0030
    323       1.2   uch 
    324       1.2   uch #define	SCFDR2_TXCNT		  0xff00	/* Tx CouNT */
    325       1.2   uch #define	SCFDR2_RECVCNT		  0x00ff	/* Rx CouNT */
    326       1.2   uch #define	SCFDR2_TXF_FULL		  0x1000	/* Tx FULL */
    327       1.2   uch #define	SCFDR2_RXF_EPTY		  0x0000	/* Rx EMPTY */
    328       1.2   uch 
    329       1.2   uch #define	SCSMR2_CHR		  0x40		/* Character length */
    330       1.2   uch #define	SCSMR2_PE		  0x20		/* Parity enable */
    331       1.2   uch #define	SCSMR2_OE		  0x10		/* Parity mode */
    332       1.2   uch #define	SCSMR2_STOP		  0x08		/* Stop bit length */
    333       1.2   uch #define	SCSMR2_CKS		  0x03		/* Clock select */
    334       1.1   uch 
    335       1.1   uch /* simple serial console macros. */
    336       1.2   uch #define	SH3_SCIF_TX_BUSY()						\
    337       1.1   uch 	while ((_reg_read_2(SH3_SCSSR2) & SCSSR2_TDFE) == 0)
    338       1.1   uch 
    339       1.2   uch #define	SH3_SCIF_PUTC(c)						\
    340       1.1   uch __BEGIN_MACRO								\
    341       1.1   uch 	SH3_SCIF_TX_BUSY();						\
    342       1.1   uch 	/*  wait until previous transmit done. */			\
    343       1.1   uch 	_reg_write_1(SH3_SCFTDR2, c);					\
    344       1.1   uch 	/* Clear transmit FIFO empty flag */				\
    345       1.1   uch 	_reg_write_1(SH3_SCSSR2,					\
    346       1.1   uch 	    _reg_read_1(SH3_SCSSR2) & ~(SCSSR2_TDFE | SCSSR2_TEND));	\
    347       1.1   uch __END_MACRO
    348       1.1   uch 
    349       1.2   uch #define	SH3_SCIF_PRINT(s)						\
    350       1.1   uch __BEGIN_MACRO								\
    351       1.1   uch 	char *__s =(char *)(s);						\
    352       1.1   uch 	int __i;							\
    353       1.1   uch 	for (__i = 0; __s[__i] != '\0'; __i++) {			\
    354       1.1   uch 		char __c = __s[__i];					\
    355       1.1   uch 		if (__c == '\n')					\
    356       1.1   uch 			SH3_SCIF_PUTC('\r');				\
    357       1.1   uch 		SH3_SCIF_PUTC(__c);					\
    358       1.1   uch 	}								\
    359       1.1   uch __END_MACRO
    360       1.1   uch 
    361       1.2   uch #define	SH3_SCIF_PRINT_HEX(h)						\
    362       1.1   uch __BEGIN_MACRO								\
    363       1.4   uwe 	uint32_t __h =(uint32_t)(h);					\
    364       1.1   uch 	int __i;							\
    365       1.1   uch 	SH3_SCIF_PUTC('0'); SH3_SCIF_PUTC('x');				\
    366       1.1   uch 	for (__i = 0; __i < 8; __i++, __h <<= 4) {			\
    367       1.1   uch 		int __n =(__h >> 28) & 0xf;				\
    368       1.1   uch 		char __c = __n > 9 ? 'A' + __n - 10 : '0' + __n;	\
    369       1.1   uch 		SH3_SCIF_PUTC(__c);					\
    370       1.1   uch 	}								\
    371       1.1   uch 	SH3_SCIF_PUTC('\r'); SH3_SCIF_PUTC('\n');			\
    372       1.1   uch __END_MACRO
    373       1.1   uch 
    374       1.1   uch #endif /* _HPCBOOT_SH_DEV_SH_H_ */
    375