Home | History | Annotate | Line # | Download | only in sh3
sh_arch.h revision 1.2.2.1
      1  1.2.2.1  nathanw /* -*-C++-*-	$NetBSD: sh_arch.h,v 1.2.2.1 2001/04/09 01:52:46 nathanw Exp $	*/
      2      1.1      uch 
      3      1.1      uch /*-
      4      1.1      uch  * Copyright (c) 2001 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  * 3. All advertising materials mentioning features or use of this software
     19      1.1      uch  *    must display the following acknowledgement:
     20      1.1      uch  *        This product includes software developed by the NetBSD
     21      1.1      uch  *        Foundation, Inc. and its contributors.
     22      1.1      uch  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23      1.1      uch  *    contributors may be used to endorse or promote products derived
     24      1.1      uch  *    from this software without specific prior written permission.
     25      1.1      uch  *
     26      1.1      uch  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27      1.1      uch  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28      1.1      uch  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29      1.1      uch  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30      1.1      uch  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31      1.1      uch  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32      1.1      uch  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33      1.1      uch  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34      1.1      uch  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35      1.1      uch  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36      1.1      uch  * POSSIBILITY OF SUCH DAMAGE.
     37      1.1      uch  */
     38      1.1      uch 
     39      1.1      uch #ifndef _HPCBOOT_SH_ARCH_H_
     40      1.1      uch #define _HPCBOOT_SH_ARCH_H_
     41      1.1      uch 
     42      1.1      uch #include <hpcboot.h>
     43      1.1      uch #include <console.h>
     44      1.1      uch #include <memory.h>
     45      1.1      uch #include <arch.h>
     46      1.1      uch #include <sh3/sh3.h>
     47      1.1      uch 
     48      1.1      uch template <class T>
     49      1.1      uch inline T
     50      1.1      uch REG_READ(paddr_t r)
     51      1.1      uch {
     52      1.1      uch 	return r & SH_P1_START ? *(T *)r :  *(T *)(r | SH_P2_START);
     53      1.1      uch }
     54      1.1      uch 
     55      1.1      uch class SHArchitecture : public Architecture {
     56      1.1      uch protected:
     57      1.1      uch 	typedef void(*boot_func_t)(struct BootArgs *, struct PageTag *);
     58      1.1      uch 
     59      1.2      uch 	u_int8_t reg_read_1(paddr_t reg) {
     60      1.1      uch 		return REG_READ <u_int8_t>(reg);
     61      1.1      uch 	}
     62      1.2      uch 	u_int16_t reg_read_2(paddr_t reg) {
     63      1.1      uch 		return REG_READ <u_int16_t>(reg);
     64      1.1      uch 	}
     65      1.2      uch 	u_int32_t reg_read_4(paddr_t reg) {
     66      1.1      uch 		return REG_READ <u_int32_t>(reg);
     67      1.1      uch 	}
     68      1.2      uch 	void hd64461_dump(platid_t &);
     69      1.2      uch 	void bsc_dump(void);
     70      1.2      uch 	void pfc_dump(void);
     71  1.2.2.1  nathanw 	void tmu_dump(void);
     72  1.2.2.1  nathanw 	void tmu_channel_dump(int, paddr_t, paddr_t, paddr_t);
     73      1.1      uch 	void icu_dump(void);
     74      1.1      uch 	void icu_priority(void);
     75      1.1      uch 	void icu_control(void);
     76      1.1      uch 	void scif_dump(int);
     77      1.1      uch 
     78      1.1      uch public:
     79      1.1      uch 	struct intr_priority {
     80      1.1      uch 		const char *name;
     81      1.1      uch 		paddr_t reg;
     82      1.1      uch 		int shift;
     83      1.1      uch 	};
     84      1.1      uch 	static struct intr_priority ipr_table[];
     85      1.1      uch 
     86      1.1      uch private:
     87      1.1      uch 	int _kmode;
     88      1.1      uch 	boot_func_t _boot_func;
     89      1.1      uch 	void print_stack_pointer(void);
     90      1.1      uch 
     91      1.1      uch protected:
     92      1.1      uch 
     93      1.1      uch 	// should be created as actual product insntnce.
     94      1.1      uch 	SHArchitecture(Console *&cons, MemoryManager *&mem, boot_func_t bootfunc)
     95      1.1      uch 		: _boot_func(bootfunc), Architecture(cons, mem) {
     96      1.1      uch 		DPRINTF((TEXT("SH architecture.\n")));
     97      1.1      uch 	}
     98      1.1      uch 	virtual ~SHArchitecture(void) { /* NO-OP */ }
     99      1.1      uch 
    100      1.1      uch public:
    101      1.1      uch 	BOOL init(void);
    102      1.1      uch 	BOOL setupLoader(void);
    103  1.2.2.1  nathanw 	paddr_t setupBootInfo(Loader &);
    104  1.2.2.1  nathanw 
    105      1.1      uch 	void systemInfo(void);
    106      1.1      uch 	void jump(kaddr_t info, kaddr_t pvce);
    107      1.1      uch 
    108      1.1      uch 	virtual void cache_flush(void) { /* NO-OP */ }
    109      1.1      uch };
    110      1.1      uch 
    111      1.1      uch /*
    112      1.1      uch  * SH product. setup cache flush routine and 2nd-bootloader.
    113      1.1      uch  */
    114      1.1      uch #define SH_(x)								\
    115      1.1      uch class SH##x : public SHArchitecture {					\
    116      1.1      uch public:									\
    117      1.1      uch 	SH##x(Console *&cons, MemoryManager *&mem, boot_func_t bootfunc)\
    118      1.1      uch 		: SHArchitecture(cons, mem, bootfunc) {			\
    119      1.1      uch 		DPRINTF((TEXT("SH") TEXT(#x) TEXT("\n")));		\
    120      1.1      uch 	}								\
    121      1.1      uch 	~SH##x(void) { /* NO-OP */ }					\
    122      1.1      uch 									\
    123      1.1      uch 	void cache_flush(void) {					\
    124      1.1      uch 		SH##x##_CACHE_FLUSH();					\
    125      1.1      uch 	}								\
    126      1.1      uch 									\
    127      1.1      uch 	static void boot_func(struct BootArgs *, struct PageTag *);	\
    128      1.1      uch }
    129      1.1      uch 
    130      1.1      uch /*
    131      1.1      uch  * 2nd-bootloader.  make sure that PIC and its size is lower than page size.
    132      1.1      uch  * and can't call subroutine.
    133      1.1      uch  */
    134      1.1      uch #define SH_BOOT_FUNC_(x)						\
    135      1.1      uch void									\
    136      1.1      uch SH##x##::boot_func(struct BootArgs *bi, struct PageTag *p)		\
    137      1.1      uch {									\
    138      1.1      uch /* Disable interrupt. block exception.(TLB exception don't occur) */	\
    139      1.1      uch 	int tmp;							\
    140      1.1      uch 	__asm("stc	sr, r5\n"					\
    141      1.1      uch 	      "or	r4, r5\n"					\
    142      1.1      uch 	      "ldc	r5, sr\n", 0x500000f0, tmp);			\
    143      1.1      uch 									\
    144      1.1      uch 	/* Now I run on P1, TLB flush. and disable. */			\
    145      1.1      uch 	VOLATILE_REF(MMUCR) = MMUCR_TF;					\
    146      1.1      uch   									\
    147      1.1      uch 	do {								\
    148      1.1      uch 		u_int32_t *dst =(u_int32_t *)p->dst;			\
    149      1.1      uch 		u_int32_t *src =(u_int32_t *)p->src;			\
    150      1.1      uch 		u_int32_t sz = p->sz / sizeof (int);			\
    151      1.1      uch 		if (p->src == ~0)					\
    152      1.1      uch 			while (sz--)					\
    153      1.1      uch 				*dst++ = 0;				\
    154      1.1      uch 		else	    						\
    155      1.1      uch 			while (sz--)					\
    156      1.1      uch 				*dst++ = *src++;			\
    157      1.1      uch 	} while ((p =(struct PageTag *)p->next) != ~0);			\
    158      1.1      uch 									\
    159      1.1      uch 	SH##x##_CACHE_FLUSH();						\
    160      1.1      uch 									\
    161      1.1      uch 	/* jump to kernel entry. */					\
    162      1.1      uch 	__asm("jmp	@r7\n"						\
    163      1.1      uch 	      "nop\n", bi->argc, bi->argv,				\
    164      1.1      uch 		 bi->bootinfo, bi->kernel_entry);			\
    165      1.1      uch }
    166      1.1      uch 
    167      1.1      uch SH_(7709);
    168      1.1      uch SH_(7709A);
    169      1.1      uch 
    170      1.1      uch #endif // _HPCBOOT_SH_ARCH_H_
    171