Flush all cache data at the beginning of the bootloader.

Fixes silent hangs after loading 4.0_BETA2 GENERIC kernel
on Qube2 (and RaQ2) with 256MB RAM, reported and tested
by James Hartley on port-cobalt.

Obviously this should be pulled up to netbsd-4.
This commit is contained in:
tsutsui 2007-07-25 14:11:06 +00:00
parent bd8aee308c
commit 49773e5f60
2 changed files with 41 additions and 2 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: start.S,v 1.3 2005/12/11 12:17:06 christos Exp $ */
/* $NetBSD: start.S,v 1.4 2007/07/25 14:11:06 tsutsui Exp $ */
/*
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -37,9 +37,11 @@
*/
#include <mips/asm.h>
#include <mips/cache_r4k.h>
LEAF(start)
.set noreorder
.set mips3
#ifdef __GP_SUPPORT__
la gp, _C_LABEL (_gp)
#endif
@ -49,6 +51,9 @@ LEAF(start)
move s0, a0 # save argc
move s1, a1 # save argv
jal _C_LABEL(flushcache)
nop
la a0, _C_LABEL (edata) # clear BSS
move a1, zero
la a2, _C_LABEL (end)
@ -63,3 +68,36 @@ XLEAF(_xtt)
jal _C_LABEL(cpu_reboot) # failed, reboot
nop
END(start)
LEAF(flushcache)
li t0, 0x80000000
addu t1, t0, 32*1024 /* flush 32KB */
subu t1, t1, 0x100 /* per 256 bytes */
1:
/* flush I-cache */
cache CACHE_R4K_I | CACHEOP_R4K_INDEX_INV, 0x000(t0)
cache CACHE_R4K_I | CACHEOP_R4K_INDEX_INV, 0x020(t0)
cache CACHE_R4K_I | CACHEOP_R4K_INDEX_INV, 0x040(t0)
cache CACHE_R4K_I | CACHEOP_R4K_INDEX_INV, 0x060(t0)
cache CACHE_R4K_I | CACHEOP_R4K_INDEX_INV, 0x080(t0)
cache CACHE_R4K_I | CACHEOP_R4K_INDEX_INV, 0x0a0(t0)
cache CACHE_R4K_I | CACHEOP_R4K_INDEX_INV, 0x0c0(t0)
cache CACHE_R4K_I | CACHEOP_R4K_INDEX_INV, 0x0e0(t0)
/* flush D-cache */
cache CACHE_R4K_D | CACHEOP_R4K_INDEX_WB_INV, 0x000(t0)
cache CACHE_R4K_D | CACHEOP_R4K_INDEX_WB_INV, 0x020(t0)
cache CACHE_R4K_D | CACHEOP_R4K_INDEX_WB_INV, 0x040(t0)
cache CACHE_R4K_D | CACHEOP_R4K_INDEX_WB_INV, 0x060(t0)
cache CACHE_R4K_D | CACHEOP_R4K_INDEX_WB_INV, 0x080(t0)
cache CACHE_R4K_D | CACHEOP_R4K_INDEX_WB_INV, 0x0a0(t0)
cache CACHE_R4K_D | CACHEOP_R4K_INDEX_WB_INV, 0x0c0(t0)
cache CACHE_R4K_D | CACHEOP_R4K_INDEX_WB_INV, 0x0e0(t0)
bne t0, t1, 1b
addu t0, t0, 0x100
j ra
nop
END(flushcache)

View File

@ -1,7 +1,8 @@
$NetBSD: version,v 1.1 2003/06/25 17:25:05 cdi Exp $
$NetBSD: version,v 1.2 2007/07/25 14:11:06 tsutsui Exp $
NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE. The format of this
file is important - make sure the entries are appended on end, last item
is taken as the current.
0.1: Initial revision, only booting from the harddrive is supported
0.2: Flush all cache data in start.S