SH4 and HD64465(SH4 companion chip) serial console support.

This commit is contained in:
uch 2002-02-04 17:38:26 +00:00
parent e79ccc5b22
commit 2e968e7e37
13 changed files with 367 additions and 59 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.9 2002/01/31 19:15:23 tv Exp $
# $NetBSD: Makefile,v 1.10 2002/02/04 17:38:26 uch Exp $
#
PROJECT_DIRS= hpcboot libz libsa
@ -62,7 +62,7 @@ distclean: clean
# WCE210 or later binary
install:
for a in SH3 ARM MIPS; do \
for a in SH3 SH4 ARM MIPS; do \
file=`echo "compile/"$$a"Release/hpcboot.exe"`; \
cp $$file binary/$$a/hpcboot.exe; \
done

View File

@ -1,12 +1,13 @@
$NetBSD: README,v 1.2 2001/06/19 17:50:39 uch Exp $
$NetBSD: README,v 1.3 2002/02/04 17:38:26 uch Exp $
How to use
'make all' uudecode all binaries.
hpcboot.exe were compiled for H/PC Pro 2.11 by eMbedded Visual C++ 3.0
executable are located in
binary/ARM/hpcboot.exe
binary/SH3/hpcboot.exe
binary/MIPS/hpcboot.exe *
binary/SH3/hpcboot.exe
binary/SH4/hpcboot.exe
* for MIPS, use pbsdboot.exe (sys/arch/hpcmips/stand/pbsdboot)
How to compile

View File

@ -1,4 +1,40 @@
/* $NetBSD: hd64461.h,v 1.2 2001/03/22 18:27:51 uch Exp $ */
/* $NetBSD: hd64461.h,v 1.3 2002/02/04 17:38:27 uch Exp $ */
/*-
* Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by UCHIYAMA Yasushi.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "../../../../hpcsh/dev/hd64461/hd64461reg.h"
#include "../../../../hpcsh/dev/hd64461/hd64461intcreg.h"

View File

@ -0,0 +1,63 @@
/* $NetBSD: hd64465.h,v 1.1 2002/02/04 17:38:27 uch Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by UCHIYAMA Yasushi.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "../../../../hpcsh/dev/hd64465/hd64465uartreg.h"
#define LSR_TXRDY 0x20 /* Transmitter buffer empty */
#define HD64465COM_TX_BUSY() \
while ((VOLATILE_REF8(HD64465_ULSR_REG8) & LSR_TXRDY) == 0)
#define HD64465COM_PUTC(c) \
__BEGIN_MACRO \
HD64465COM_TX_BUSY(); \
VOLATILE_REF8(HD64465_UTBR_REG8) = (c); \
HD64465COM_TX_BUSY(); \
__END_MACRO
#define HD64465COM_PRINT(s) \
__BEGIN_MACRO \
char *__s =(char *)(s); \
int __i; \
for (__i = 0; __s[__i] != '\0'; __i++) { \
char __c = __s[__i]; \
if (__c == '\n') \
HD64465COM_PUTC('\r'); \
HD64465COM_PUTC(__c); \
} \
__END_MACRO

View File

@ -1,7 +1,7 @@
/* -*-C++-*- $NetBSD: sh3.h,v 1.4 2001/03/22 18:27:51 uch Exp $ */
/* -*-C++-*- $NetBSD: sh3.h,v 1.5 2002/02/04 17:38:27 uch Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -69,14 +69,20 @@
#define MMU_WAY 4
#define MMU_ENTRY 32
/* Windows CE uses 1Kbyte page */
#define PAGE_SIZE 0x400
#define PAGE_MASK (~(PAGE_SIZE - 1))
/* Windows CE uses 1Kbyte page for SH3, 4Kbyte for SH4 */
#define SH3_PAGE_SIZE 0x400
#define SH3_PAGE_MASK (~(SH3_PAGE_SIZE - 1))
#define SH4_PAGE_SIZE 0x1000
#define SH4_PAGE_MASK (~(SH4_PAGE_SIZE - 1))
#define MMUPTEH 0xfffffff0
#define MMUPTEH_ASID_MASK 0x0000000f
#define MMUPTEH_VPN_MASK 0xfffffc00
#ifdef SH4
#define MMUCR 0xff000010
#else
#define MMUCR 0xffffffe0
#endif
#define MMUCR_AT 0x00000001
#define MMUCR_IX 0x00000002
#define MMUCR_TF 0x00000004
@ -265,6 +271,14 @@ __END_DECLS
/*
* SCI
*/
#ifdef SH4
#define SCI_SCSMR_REG8 0xffe00000
#define SCI_SCBRR_REG8 0xffe00004
#define SCI_SCSCR_REG8 0xffe00008
#define SCI_SCTDR_REG8 0xffe0000c
#define SCI_SCSSR_REG8 0xffe00010
#define SCI_SCRDR_REG8 0xffe00014
#else
#define SCI_SCRSR_REG8 /* can't access from CPU */
#define SCI_SCTSR_REG8 /* can't access from CPU */
#define SCI_SCSMR_REG8 0xfffffe80
@ -272,10 +286,11 @@ __END_DECLS
#define SCI_SCSCR_REG8 0xfffffe84
#define SCI_SCTDR_REG8 0xfffffe86
#define SCI_SCSSR_REG8 0xfffffe88
#define SCI_SCSSR_TDRE 0x80
#define SCI_SCRDR_REG8 0xfffffe8a
#define SCI_SCPCR_REG16 0xa4000116
#define SCI_SCPDR_REG16 0xa4000136
#endif
#define SCI_SCSSR_TDRE 0x80
#define SCI_TX_BUSY() \
while ((VOLATILE_REF8(SCI_SCSSR_REG8) & SCI_SCSSR_TDRE) == 0)
@ -302,6 +317,19 @@ __END_MACRO
/*
* SCIF
*/
#ifdef SH4
#define SCIF_SCSMR2_REG16 0xffe80000
#define SCIF_SCBRR2_REG8 0xffe80004
#define SCIF_SCSCR2_REG16 0xffe80008
#define SCIF_SCFTDR2_REG8 0xffe8000c
#define SCIF_SCFSR2_REG16 0xffe80010
#define SCIF_SCFRDR2_REG8 0xffe80014
#define SCIF_SCFCR2_REG16 0xffe80018
#define SCIF_SCFDR2_REG16 0xffe8001c
#define SCIF_SCSPTR2_REG16 0xffe80020
#define SCIF_SCLSR2_REG16 0xffe80024
#define SCIF_SCSSR2_REG16 SCIF_SCFSR2_REG16
#else
#define SCIF_SCSMR2_REG8 0xa4000150 /* R/W */
#define SCIF_SCBRR2_REG8 0xa4000152 /* R/W */
#define SCIF_SCSCR2_REG8 0xa4000154 /* R/W */
@ -310,6 +338,7 @@ __END_MACRO
#define SCIF_SCFRDR2_REG8 0xa400015a /* R */
#define SCIF_SCFCR2_REG8 0xa400015c /* R/W */
#define SCIF_SCFDR2_REG16 0xa400015e /* R */
#endif
/* Transmit FIFO Data Empty */
#define SCIF_SCSSR2_TDFE 0x00000020
@ -361,5 +390,6 @@ __END_MACRO
#include <sh3/sh_7707.h>
#include <sh3/sh_7709.h>
#include <sh3/sh_7709a.h>
#include <sh3/sh_7750.h>
#endif // _HPCBOOT_SH3_H_

View File

@ -0,0 +1,94 @@
/* $NetBSD: sh_7750.h,v 1.1 2002/02/04 17:38:28 uch Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by UCHIYAMA Yasushi.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _HPCBOOT_SH_7750_H_
#define _HPCBOOT_SH_7750_H_
#ifndef _HPCBOOT_SH3_H_
#error "include sh3.h"
#endif
#define SH4_ICACHE_SIZE 8192
#define SH4_DCACHE_SIZE 16384
#define SH4_CACHE_LINESZ 32
/* I-cache address/data array */
#define SH4REG_CCIA 0xf0000000
/* address specification */
#define CCIA_A 0x00000008 /* associate bit */
#define CCIA_ENTRY_SHIFT 5 /* line size 32B */
#define CCIA_ENTRY_MASK 0x00001fe0 /* [12:5] 256-entries */
/* data specification */
#define CCIA_V 0x00000001
#define CCIA_TAGADDR_MASK 0xfffffc00 /* [31:10] */
#define SH4REG_CCID 0xf1000000
/* address specification */
#define CCID_L_SHIFT 2
#define CCID_L_MASK 0x1c /* line-size is 32B */
#define CCID_ENTRY_MASK 0x00001fe0 /* [12:5] 128-entries */
/* D-cache address/data array */
#define SH4REG_CCDA 0xf4000000
/* address specification */
#define CCDA_A 0x00000008 /* associate bit */
#define CCDA_ENTRY_SHIFT 5 /* line size 32B */
#define CCDA_ENTRY_MASK 0x00003fe0 /* [13:5] 512-entries */
/* data specification */
#define CCDA_V 0x00000001
#define CCDA_U 0x00000002
#define CCDA_TAGADDR_MASK 0xfffffc00 /* [31:10] */
#define SH4REG_CCDD 0xf5000000
#define SH7750_CACHE_FLUSH() \
__BEGIN_MACRO \
u_int32_t __e, __a; \
\
/* D-cache */ \
for (__e = 0; __e < (SH4_DCACHE_SIZE / SH4_CACHE_LINESZ); __e++) {\
__a = SH4REG_CCDA | (__e << CCDA_ENTRY_SHIFT); \
VOLATILE_REF(__a) &= ~(CCDA_U | CCDA_V); \
} \
/* I-cache XXX bogus. make sure to run P2 */ \
for (__e = 0; __e < (SH4_ICACHE_SIZE / SH4_CACHE_LINESZ); __e++) {\
__a = SH4REG_CCIA | (__e << CCIA_ENTRY_SHIFT); \
VOLATILE_REF(__a) &= ~(CCIA_V); \
} \
__END_MACRO
#endif // _HPCBOOT_SH_7750_H_

View File

@ -1,7 +1,7 @@
/* $NetBSD: sh_arch.cpp,v 1.7 2001/05/08 18:51:25 uch Exp $ */
/* $NetBSD: sh_arch.cpp,v 1.8 2002/02/04 17:38:27 uch Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -36,9 +36,11 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <hpcboot.h>
#include <hpcmenu.h>
#include <sh3/sh_arch.h>
#include <sh3/hd64461.h>
#include <sh3/hd64465.h>
#include "scifreg.h"
static void __tmu_channel_info(int, paddr_t, paddr_t, paddr_t);
@ -70,11 +72,13 @@ struct SHArchitecture::intr_priority SHArchitecture::ipr_table[] = {
BOOL
SHArchitecture::init(void)
{
if (!_mem->init()) {
DPRINTF((TEXT("can't initialize memory manager.\n")));
return FALSE;
}
// set D-RAM information
DPRINTF((TEXT("Memory Bank:\n")));
_mem->loadBank(DRAM_BANK0_START, DRAM_BANK_SIZE);
_mem->loadBank(DRAM_BANK1_START, DRAM_BANK_SIZE);
@ -94,7 +98,6 @@ SHArchitecture::setupLoader()
(unsigned)v,(unsigned)_loader_addr));
memcpy(LPVOID(v), LPVOID(_boot_func), _mem->getPageSize());
DPRINTF((TEXT("2nd bootloader copy done.\n")));
return TRUE;
}
@ -113,22 +116,27 @@ SHArchitecture::jump(paddr_t info, paddr_t pvec)
info = ptokv(info);
pvec = ptokv(pvec);
_loader_addr = ptokv(_loader_addr);
DPRINTF((TEXT("BootArgs 0x%08x Stack 0x%08x\nBooting kernel...\n"),
DPRINTF((TEXT("boot arg: 0x%08x stack: 0x%08x\nBooting kernel...\n"),
info, sp));
// Change to privilege-mode.
SetKMode(1);
// Cache flush(for 2nd bootloader)
//
// SH4 uses WinCE CacheSync(). this routine may causes TLB
// exception. so calls before suspendIntr().
//
cache_flush();
// Disable external interrupt.
suspendIntr();
// Cache flush(for 2nd bootloader)
cache_flush();
// jump to 2nd loader.(run P1) at this time I still use MMU.
__asm("mov r6, r15\n"
__asm(
"mov r6, r15\n"
"jmp @r7\n"
"nop\n", info, pvec, sp, _loader_addr);
"nop \n", info, pvec, sp, _loader_addr);
// NOTREACHED
}
@ -137,7 +145,9 @@ u_int32_t
suspendIntr(void)
{
u_int32_t sr;
__asm("stc sr, r0\n"
__asm(
"stc sr, r0\n"
"mov.l r0, @r4\n"
"or r5, r0\n"
"ldc r0, sr\n", &sr, 0x000000f0);
@ -148,6 +158,7 @@ suspendIntr(void)
void
resumeIntr(u_int32_t s)
{
__asm("stc sr, r0\n"
"and r5, r0\n"
"or r4, r0\n"
@ -158,6 +169,7 @@ void
SHArchitecture::print_stack_pointer(void)
{
int sp;
__asm("mov.l r15, @r4", &sp);
DPRINTF((TEXT("SP 0x%08x\n"), sp));
}
@ -232,6 +244,7 @@ SHArchitecture::systemInfo()
void
SHArchitecture::icu_dump(void)
{
DPRINTF((TEXT("<<<Interrupt Controller>>>\n")));
print_stack_pointer();
@ -255,6 +268,7 @@ void
SHArchitecture::icu_priority(void)
{
struct intr_priority *tab;
DPRINTF((TEXT("----interrupt priority----\n")));
for (tab = ipr_table; tab->name; tab++) {
DPRINTF((TEXT("%-10S %d\n"), tab->name,
@ -305,6 +319,7 @@ SHArchitecture::icu_control(void)
SH_BOOT_FUNC_(7709);
SH_BOOT_FUNC_(7709A);
SH_BOOT_FUNC_(7750);
//
// Debug Functions.
@ -312,6 +327,7 @@ SH_BOOT_FUNC_(7709A);
void
SHArchitecture::bsc_dump()
{
DPRINTF((TEXT("<<<Bus State Controller>>>\n")));
#define DUMP_BSC_REG(x) \
DPRINTF((TEXT("%-8S"), #x)); \
@ -335,7 +351,11 @@ void
SHArchitecture::scif_dump(int bps)
{
u_int16_t r16;
#ifdef SH4
u_int16_t r8;
#else
u_int8_t r8;
#endif
int n;
DPRINTF((TEXT("<<<SCIF>>>\n")));
@ -344,7 +364,7 @@ SHArchitecture::scif_dump(int bps)
n = 1 <<((r8 & SCSMR2_CKS) << 1);
DPRINTF((TEXT("mode: %dbit %S-parity %d stop bit clock PCLOCK/%d\n"),
r8 & SCSMR2_CHR ? 7 : 8,
r8 & SCSMR2_PE ? r8 & SCSMR2_OE ? "odd" : "even" : "non",
r8 & SCSMR2_PE ? r8 & SCSMR2_OE ? "odd" : "even" : "non",
r8 & SCSMR2_STOP ? 2 : 1,
n));
/* bit rate */

View File

@ -1,7 +1,7 @@
/* -*-C++-*- $NetBSD: sh_arch.h,v 1.4 2001/03/22 18:27:51 uch Exp $ */
/* -*-C++-*- $NetBSD: sh_arch.h,v 1.5 2002/02/04 17:38:27 uch Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -44,6 +44,8 @@
#include <memory.h>
#include <arch.h>
#include <sh3/sh3.h>
#include <sh3/hd64461.h>
#include <sh3/hd64465.h>
template <class T>
inline T
@ -93,7 +95,7 @@ protected:
// should be created as actual product insntnce.
SHArchitecture(Console *&cons, MemoryManager *&mem, boot_func_t bootfunc)
: _boot_func(bootfunc), Architecture(cons, mem) {
DPRINTF((TEXT("SH architecture.\n")));
// NO-OP
}
virtual ~SHArchitecture(void) { /* NO-OP */ }
@ -108,15 +110,19 @@ public:
virtual void cache_flush(void) { /* NO-OP */ }
};
/*
* SH product. setup cache flush routine and 2nd-bootloader.
*/
//
// SH product. setup cache flush routine and 2nd-bootloader.
//
//
// SH3 series.
///
#define SH_(x) \
class SH##x : public SHArchitecture { \
public: \
SH##x(Console *&cons, MemoryManager *&mem, boot_func_t bootfunc)\
: SHArchitecture(cons, mem, bootfunc) { \
DPRINTF((TEXT("SH") TEXT(#x) TEXT("\n"))); \
DPRINTF((TEXT("CPU: SH") TEXT(#x) TEXT("\n"))); \
} \
~SH##x(void) { /* NO-OP */ } \
\
@ -127,10 +133,10 @@ public: \
static void boot_func(struct BootArgs *, struct PageTag *); \
}
/*
* 2nd-bootloader. make sure that PIC and its size is lower than page size.
* and can't call subroutine.
*/
//
// 2nd-bootloader. make sure that PIC and its size is lower than page size.
// and can't call subroutine.
//
#define SH_BOOT_FUNC_(x) \
void \
SH##x##::boot_func(struct BootArgs *bi, struct PageTag *p) \
@ -140,10 +146,9 @@ SH##x##::boot_func(struct BootArgs *bi, struct PageTag *p) \
__asm("stc sr, r5\n" \
"or r4, r5\n" \
"ldc r5, sr\n", 0x500000f0, tmp); \
\
/* Now I run on P1, TLB flush. and disable. */ \
\
VOLATILE_REF(MMUCR) = MMUCR_TF; \
\
do { \
u_int32_t *dst =(u_int32_t *)p->dst; \
u_int32_t *src =(u_int32_t *)p->src; \
@ -167,4 +172,27 @@ SH##x##::boot_func(struct BootArgs *bi, struct PageTag *p) \
SH_(7709);
SH_(7709A);
//
// SH4 series.
///
class SH7750 : public SHArchitecture {
public:
SH7750(Console *&cons, MemoryManager *&mem, boot_func_t bootfunc)
: SHArchitecture(cons, mem, bootfunc) {
DPRINTF((TEXT("CPU: SH7750\n")));
}
~SH7750(void) { /* NO-OP */ }
void cache_flush(void) {
//
// To invalidate I-cache, program must run on P2. I can't
// do it myself, use WinCE API. (WCE2.10 or later)
//
CacheSync(CACHE_D_WBINV);
CacheSync(CACHE_I_INV);
}
static void boot_func(struct BootArgs *, struct PageTag *);
};
#endif // _HPCBOOT_SH_ARCH_H_

View File

@ -1,7 +1,7 @@
/* $NetBSD: sh_boot.cpp,v 1.4 2001/05/21 15:54:25 uch Exp $ */
/* $NetBSD: sh_boot.cpp,v 1.5 2002/02/04 17:38:27 uch Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -73,8 +73,12 @@ SHBoot::setup()
args.architecture = ARCHITECTURE_SH3_7709;
} else if (platid_match(&platid, &platid_mask_CPU_SH_3_7709A)) {
args.architecture = ARCHITECTURE_SH3_7709A;
} else
} else if (platid_match(&platid, &platid_mask_CPU_SH_4_7750)) {
args.architecture = ARCHITECTURE_SH4_7750;
} else {
DPRINTF((TEXT("CPU not supported.")));
return FALSE;
}
return super::setup();
}
@ -84,6 +88,7 @@ SHBoot::create()
{
BOOL(*lock_pages)(LPVOID, DWORD, PDWORD, int);
BOOL(*unlock_pages)(LPVOID, DWORD);
size_t page_size;
// Setup console. this setting is passed to kernel bootinfo.
if (args.console == CONSOLE_SERIAL) {
@ -104,9 +109,15 @@ SHBoot::create()
return FALSE;
case ARCHITECTURE_SH3_7709:
_arch = new SH7709(_cons, _mem, SH7709::boot_func);
page_size = SH3_PAGE_SIZE;
break;
case ARCHITECTURE_SH3_7709A:
_arch = new SH7709A(_cons, _mem, SH7709A::boot_func);
page_size = SH3_PAGE_SIZE;
break;
case ARCHITECTURE_SH4_7750:
_arch = new SH7750(_cons, _mem, SH7750::boot_func);
page_size = SH4_PAGE_SIZE;
break;
}
_arch->setDebug() = args.architectureDebug;
@ -114,7 +125,7 @@ SHBoot::create()
lock_pages = _arch->_load_LockPages();
unlock_pages = _arch->_load_UnlockPages();
if (lock_pages == 0 || unlock_pages == 0)
args.memory = MEMORY_MANAGER_HARDMMU;
args.memory = MEMORY_MANAGER_HARDMMU;
else
args.memory = MEMORY_MANAGER_LOCKPAGES;
@ -123,16 +134,21 @@ SHBoot::create()
default:
case MEMORY_MANAGER_VIRTUALCOPY:
// VirtualCopy method causes Windows CE unstable.
// FALLTHROUGH
/* FALLTHROUGH */
case MEMORY_MANAGER_SOFTMMU:
DPRINTF((TEXT("unsupported address detection method.\n")));
return FALSE;
case MEMORY_MANAGER_HARDMMU:
_mem = new MemoryManager_SHMMU(_cons, PAGE_SIZE);
if (args.architecture == ARCHITECTURE_SH4_7750) {
DPRINTF((TEXT("No SH4 MMU code.\n")));
return FALSE;
}
_mem = new MemoryManager_SHMMU(_cons, page_size);
break;
case MEMORY_MANAGER_LOCKPAGES:
_mem = new MemoryManager_LockPages(lock_pages, unlock_pages,
_cons, PAGE_SIZE);
_cons, page_size);
break;
}
_mem->setDebug() = args.memorymanagerDebug;

View File

@ -1,7 +1,7 @@
/* -*-C++-*- $NetBSD: sh_console.cpp,v 1.7 2001/05/21 15:54:25 uch Exp $ */
/* -*-C++-*- $NetBSD: sh_console.cpp,v 1.8 2002/02/04 17:38:27 uch Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -39,20 +39,24 @@
#include <hpcmenu.h>
#include <sh3/sh_console.h>
#include <sh3/hd64461.h>
#include <sh3/hd64465.h>
// XXX don't define here. arch/hpcsh/include/bootinfo.h
#define BI_CNUSE_SCI 2
#define BI_CNUSE_SCIF 3
#define BI_CNUSE_HD64461COM 4
#define BI_CNUSE_HD64461VIDEO 5
#define BI_CNUSE_HD64465COM 6
#define BI_CNUSE_MQ100 7
SHConsole *SHConsole::_instance = 0;
struct SHConsole::console_info
SHConsole::_console_info[] = {
{ PLATID_CPU_SH_3 , PLATID_MACH_HP , SCIFPrint , BI_CNUSE_SCIF , BI_CNUSE_HD64461VIDEO},
{ PLATID_CPU_SH_3_7709 , PLATID_MACH_HITACHI , HD64461COMPrint , BI_CNUSE_HD64461COM , BI_CNUSE_HD64461VIDEO},
{ PLATID_CPU_SH_3 , PLATID_MACH_HP , SCIFPrint , BI_CNUSE_SCIF , BI_CNUSE_HD64461VIDEO },
{ PLATID_CPU_SH_3_7709 , PLATID_MACH_HITACHI , HD64461COMPrint , BI_CNUSE_HD64461COM , BI_CNUSE_HD64461VIDEO },
{ PLATID_CPU_SH_3_7709 , PLATID_MACH_CASIO_CASSIOPEIAA_A55V , 0 , BI_CNUSE_BUILTIN , BI_CNUSE_BUILTIN },
{ PLATID_CPU_SH_4_7750 , PLATID_MACH_HITACHI_PERSONA_HPW650PA , HD64465COMPrint , BI_CNUSE_HD64465COM , BI_CNUSE_MQ100 },
{ 0, 0, 0 } // terminator.
};
@ -73,19 +77,20 @@ SHConsole::selectBootConsole(Console &cons, enum consoleSelect select)
switch (select) {
case SERIAL:
cons.setBootConsole(tab->serial_console);
break;
return tab;
case VIDEO:
cons.setBootConsole(tab->video_console);
break;
return tab;
}
}
}
return tab;
return NULL;
}
SHConsole::SHConsole()
{
_print = 0;
}
@ -97,6 +102,7 @@ SHConsole::~SHConsole()
SHConsole *
SHConsole::Instance()
{
if (!_instance)
_instance = new SHConsole();
@ -122,6 +128,7 @@ SHConsole::init()
void
SHConsole::print(const TCHAR *fmt, ...)
{
SETUP_WIDECHAR_BUFFER();
if (!setupMultibyteBuffer())
@ -136,17 +143,27 @@ SHConsole::print(const TCHAR *fmt, ...)
void
SHConsole::SCIPrint(const char *buf)
{
SCI_PRINT(buf);
}
void
SHConsole::SCIFPrint(const char *buf)
{
SCIF_PRINT(buf);
}
void
SHConsole::HD64461COMPrint(const char *buf)
{
HD64461COM_PRINT(buf);
}
void
SHConsole::HD64465COMPrint(const char *buf)
{
HD64465COM_PRINT(buf);
}

View File

@ -1,7 +1,7 @@
/* -*-C++-*- $NetBSD: sh_console.h,v 1.6 2001/05/21 15:54:25 uch Exp $ */
/* -*-C++-*- $NetBSD: sh_console.h,v 1.7 2002/02/04 17:38:27 uch Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -63,6 +63,7 @@ public:
static void SCIPrint(const char *);
static void SCIFPrint(const char *);
static void HD64461COMPrint(const char *);
static void HD64465COMPrint(const char *);
private:
static SHConsole *_instance;

View File

@ -1,7 +1,7 @@
/* $NetBSD: sh_mmu.cpp,v 1.1 2001/02/09 18:35:19 uch Exp $ */
/* $NetBSD: sh_mmu.cpp,v 1.2 2002/02/04 17:38:27 uch Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -42,6 +42,7 @@
BOOL
MemoryManager_SHMMU::init(void)
{
_kmode = SetKMode(1);
_asid = VOLATILE_REF(MMUPTEH) & MMUPTEH_ASID_MASK;
@ -52,6 +53,7 @@ MemoryManager_SHMMU::init(void)
MemoryManager_SHMMU::~MemoryManager_SHMMU(void)
{
SetKMode(_kmode);
}
@ -63,7 +65,7 @@ MemoryManager_SHMMU::searchPage(vaddr_t vaddr)
paddr_t paddr = ~0;
int way;
vpn = vaddr & PAGE_MASK;
vpn = vaddr & SH3_PAGE_MASK;
// Windows CE uses VPN-only index-mode.
idx = vaddr & MMUAA_VPN_MASK;
@ -82,13 +84,13 @@ MemoryManager_SHMMU::searchPage(vaddr_t vaddr)
if (!(aae & MMUAA_D_VALID) ||
((aae & MMUAA_D_ASID_MASK) != _asid) ||
(((aae | idx) & PAGE_MASK) != vpn))
(((aae | idx) & SH3_PAGE_MASK) != vpn))
continue;
// entry found.
// inquire MMU data array to get its physical address.
dae = VOLATILE_REF(MMUDA | entry_idx);
paddr = (dae & PAGE_MASK) | (vaddr & ~PAGE_MASK);
paddr = (dae & SH3_PAGE_MASK) | (vaddr & ~SH3_PAGE_MASK);
break;
}
} while (paddr == ~0);

View File

@ -1,7 +1,7 @@
/* -*-C++-*- $NetBSD: sh_mmu.h,v 1.1 2001/02/09 18:35:19 uch Exp $ */
/* -*-C++-*- $NetBSD: sh_mmu.h,v 1.2 2002/02/04 17:38:27 uch Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -50,7 +50,7 @@ private:
public:
MemoryManager_SHMMU(Console *&cons, size_t pagesize)
: MemoryManager(cons, pagesize) {
DPRINTF((TEXT("Use SH hardware MMU.\n")));
DPRINTF((TEXT("MemoryManager: SH3 MMU\n")));
}
virtual ~MemoryManager_SHMMU();
BOOL init(void);