- #define the physical start of RAM.

- Set up a Panic Stack,
 - Don't pre-map the sysfpga at this time.
 - Calculate the CPU speed only if SH5_CPU_SPEED isn't defined.
 - On a related note, make the CPU speed probing code more accurate.
 - Print the CPU speed at startup.
 - Force RB_SINGLE for now, at least until I get a bootloader written.
This commit is contained in:
scw 2002-09-04 15:14:46 +00:00
parent e94347123e
commit 4b8905020d
1 changed files with 36 additions and 13 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.3 2002/08/25 20:21:36 thorpej Exp $ */
/* $NetBSD: machdep.c,v 1.4 2002/09/04 15:14:46 scw Exp $ */
/*
* Copyright 2002 Wasabi Systems, Inc.
@ -35,6 +35,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "opt_sh5_debug.h"
#include "opt_sh5_cpu.h"
#include "dtfcons.h"
#include <sys/param.h>
@ -67,8 +69,10 @@
#include <evbsh5/evbsh5/machdep.h>
#ifndef SH5_CPU_SPEED
static void compute_ctc_tick_per_us(void);
#endif
struct boot_params evbsh5_bootparams;
struct vm_map *exec_map;
@ -79,6 +83,8 @@ char machine[] = MACHINE;
char cpu_model[128];
#define EVBSH5_RAM_START_PHYS 0x80000000
/*
* Physical addresses of important devices on the Cayman board
* which need to be mapped early on during bootstrap to gain
@ -106,7 +112,7 @@ evbsh5_memory_init(vaddr_t endkernel, struct mem_region *mr)
ksize = endkernel - SH5_KSEG0_BASE;
mr[0].mr_start = 0x80000000 + ksize;
mr[0].mr_start = EVBSH5_RAM_START_PHYS + ksize;
mr[0].mr_kvastart = SH5_KSEG0_BASE + ksize;
mr[0].mr_size = sh5_trunc_page(evbsh5_bootparams.bp_physramsize)- ksize;
mr[1].mr_start = 0;
@ -118,6 +124,7 @@ evbsh5_memory_init(vaddr_t endkernel, struct mem_region *mr)
void
evbsh5_init(void)
{
extern char sh5_panic_stack[];
#if NDTFCONS > 0
extern char *_dtf_buffer;
extern void _dtf_trap_frob(void);
@ -125,6 +132,11 @@ evbsh5_init(void)
paddr_t frob_p;
#endif
/* XXX: Will need to be revisited for SMP */
curcpu()->ci_panicstkphys = EVBSH5_RAM_START_PHYS +
(((uintptr_t)&sh5_panic_stack[0]) - SH5_KSEG0_BASE) +
(USPACE - sizeof(struct trapframe));
/*
* Fix up the cpu-specific TLB/cache manipulation functions
*/
@ -138,10 +150,11 @@ evbsh5_init(void)
#if NDTFCONS > 0
dtfbuf = (vaddr_t) &_dtf_buffer;
frob_p = (paddr_t) (uintptr_t) _dtf_trap_frob;
frob_p = 0x80000000 + (frob_p - SH5_KSEG0_BASE);
frob_p = EVBSH5_RAM_START_PHYS + (frob_p - SH5_KSEG0_BASE);
dtf_init(0xc100018, frob_p,
(paddr_t)(0x80000000 + (dtfbuf - SH5_KSEG0_BASE)), dtfbuf);
(paddr_t)(EVBSH5_RAM_START_PHYS + (dtfbuf - SH5_KSEG0_BASE)),
dtfbuf);
#endif
/*
@ -150,20 +163,22 @@ evbsh5_init(void)
bus_space_map(&_sh5_bus_space_tag, EVBSH5_PBRIDGE_PHYS_ADDR,
EVBSH5_PBRIDGE_LEN, 0, &_evbsh5_bh_pbridge);
#ifdef notyet
/*
* Map the system FPGA/Super IO area
*/
bus_space_map(&_sh5_bus_space_tag, EVBSH5_SYSFPGA_PHYS_ADDR,
EVBSH5_SYSFPGA_LEN, 0, &_evbsh5_bh_sysfpga);
#endif
/*
* Figure out how fast the CPU is
*
* XXX: Should just read the relevant system FPGA bits ...
*/
#ifndef SH5_CPU_SPEED
compute_ctc_tick_per_us();
#else
_sh5_ctc_ticks_per_us = SH5_CPU_SPEED;
#endif
}
#ifndef SH5_CPU_SPEED
static void
compute_ctc_tick_per_us(void)
{
@ -193,10 +208,14 @@ compute_ctc_tick_per_us(void)
* Fetch the current value of the 128Hz RTC counter and
* add 16 so we can time the loop to pretty much exactly 125mS
*/
r64cnt = (rtc_read_r64cnt(bt, bh) + 16) & RTC_R64CNT_MASK;
r64cnt = rtc_read_r64cnt(bt, bh);
while (r64cnt == rtc_read_r64cnt(bt, bh))
;
__asm __volatile("putcon %0, ctc" :: "r"(ctcstart));
r64cnt = (r64cnt + 17) & RTC_R64CNT_MASK;
/*
* Wait 125mS
*/
@ -213,6 +232,7 @@ compute_ctc_tick_per_us(void)
bus_space_unmap(bt, bh, RTC_REG_SIZE);
}
#endif
void
cpu_startup(void)
@ -223,7 +243,7 @@ cpu_startup(void)
vsize_t size;
char pbuf[16];
strcpy(cpu_model, "SuperH SH-5 STB1");
boothowto = RB_SINGLE;
/*
* Find out how much space we need, allocate it,
@ -295,7 +315,10 @@ cpu_startup(void)
nmbclusters * mclbytes, VM_MAP_INTRSAFE,
FALSE, NULL);
printf("%s%s\n", version, cpu_model);
strcpy(cpu_model, "SuperH SH5");
printf("%s%s running at %dMHz\n", version, cpu_model,
(u_int)_sh5_ctc_ticks_per_us);
format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
printf("total memory = %s\n", pbuf);
format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free));