<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://wiki.jackslab.org/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-cn">
		<id>http://wiki.jackslab.org/index.php?action=history&amp;feed=atom&amp;title=%E6%8D%89%E8%99%AB%E6%97%A5%E8%AE%B0_0001%3A_Cache_initialize_issue_on_4KEc_%28MIPS32r2%29</id>
		<title>捉虫日记 0001: Cache initialize issue on 4KEc (MIPS32r2) - 版本历史</title>
		<link rel="self" type="application/atom+xml" href="http://wiki.jackslab.org/index.php?action=history&amp;feed=atom&amp;title=%E6%8D%89%E8%99%AB%E6%97%A5%E8%AE%B0_0001%3A_Cache_initialize_issue_on_4KEc_%28MIPS32r2%29"/>
		<link rel="alternate" type="text/html" href="http://wiki.jackslab.org/index.php?title=%E6%8D%89%E8%99%AB%E6%97%A5%E8%AE%B0_0001:_Cache_initialize_issue_on_4KEc_(MIPS32r2)&amp;action=history"/>
		<updated>2026-05-21T09:31:34Z</updated>
		<subtitle>本wiki的该页面的版本历史</subtitle>
		<generator>MediaWiki 1.19.2</generator>

	<entry>
		<id>http://wiki.jackslab.org/index.php?title=%E6%8D%89%E8%99%AB%E6%97%A5%E8%AE%B0_0001:_Cache_initialize_issue_on_4KEc_(MIPS32r2)&amp;diff=18552&amp;oldid=prev</id>
		<title>2025年12月4日 (四) 02:48 Comcat</title>
		<link rel="alternate" type="text/html" href="http://wiki.jackslab.org/index.php?title=%E6%8D%89%E8%99%AB%E6%97%A5%E8%AE%B0_0001:_Cache_initialize_issue_on_4KEc_(MIPS32r2)&amp;diff=18552&amp;oldid=prev"/>
				<updated>2025-12-04T02:48:55Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
			&lt;tr valign='top'&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←上一版本&lt;/td&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;2025年12月4日 (四) 02:48的版本&lt;/td&gt;
			&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第182行：&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第182行：&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Don't use these register before they are saved in fw_argx.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Don't use these register before they are saved in fw_argx.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;br&amp;gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;br&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;== Reference ==&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;* [[GNU/Linux 内核移植捉虫笔记 (Linux Kernel Debug Notes)]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Comcat</name></author>	</entry>

	<entry>
		<id>http://wiki.jackslab.org/index.php?title=%E6%8D%89%E8%99%AB%E6%97%A5%E8%AE%B0_0001:_Cache_initialize_issue_on_4KEc_(MIPS32r2)&amp;diff=18551&amp;oldid=prev</id>
		<title>Comcat：/* Solution */</title>
		<link rel="alternate" type="text/html" href="http://wiki.jackslab.org/index.php?title=%E6%8D%89%E8%99%AB%E6%97%A5%E8%AE%B0_0001:_Cache_initialize_issue_on_4KEc_(MIPS32r2)&amp;diff=18551&amp;oldid=prev"/>
				<updated>2025-12-04T02:47:47Z</updated>
		
		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Solution&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
			&lt;tr valign='top'&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←上一版本&lt;/td&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;2025年12月4日 (四) 02:47的版本&lt;/td&gt;
			&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第182行：&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第182行：&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Don't use these register before they are saved in fw_argx.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Don't use these register before they are saved in fw_argx.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;br&amp;gt;&lt;/del&gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Comcat</name></author>	</entry>

	<entry>
		<id>http://wiki.jackslab.org/index.php?title=%E6%8D%89%E8%99%AB%E6%97%A5%E8%AE%B0_0001:_Cache_initialize_issue_on_4KEc_(MIPS32r2)&amp;diff=2282&amp;oldid=prev</id>
		<title>Comcat：以“== Phenomenon ==  Initialize the 4KEc's cache like following code in head.S:  &lt;pre&gt;     li       a0, 0x2000      # icache size is 8KB     lui     a2, 0x8000     addu...”为内容创建页面</title>
		<link rel="alternate" type="text/html" href="http://wiki.jackslab.org/index.php?title=%E6%8D%89%E8%99%AB%E6%97%A5%E8%AE%B0_0001:_Cache_initialize_issue_on_4KEc_(MIPS32r2)&amp;diff=2282&amp;oldid=prev"/>
				<updated>2014-05-19T08:06:41Z</updated>
		
		<summary type="html">&lt;p&gt;以“== Phenomenon ==  Initialize the 4KEc&amp;#039;s cache like following code in head.S:  &amp;lt;pre&amp;gt;     li       a0, 0x2000      # icache size is 8KB     lui     a2, 0x8000     addu...”为内容创建页面&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Phenomenon ==&lt;br /&gt;
&lt;br /&gt;
Initialize the 4KEc's cache like following code in head.S:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    li       a0, 0x2000      # icache size is 8KB&lt;br /&gt;
    lui     a2, 0x8000&lt;br /&gt;
    addu    a3, a2, a0&lt;br /&gt;
   &lt;br /&gt;
21:&lt;br /&gt;
    cache   Index_Store_Tag_I, 0(a2)&lt;br /&gt;
    addiu   a2, 16&lt;br /&gt;
    ble     a2, a3, 21b&lt;br /&gt;
    nop&lt;br /&gt;
&lt;br /&gt;
    /* setup dcache */&lt;br /&gt;
    lui     a2, 0x8000&lt;br /&gt;
    li       a0, 0x2000      # dcache size is also 8KB&lt;br /&gt;
    addu    a3, a2, a0&lt;br /&gt;
22:&lt;br /&gt;
    cache   Index_Store_Tag_D, 0(a2)&lt;br /&gt;
    addiu   a2, 16&lt;br /&gt;
    ble     a2, a3, 22b&lt;br /&gt;
    nop&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Above code defined in kernel_entry_setup (include/asm/mach-emma3p/kernel-entry-init.h)&lt;br /&gt;
&lt;br /&gt;
The kernel can not boot up properly (No printk out, serial console can not be used).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Analysis ==&lt;br /&gt;
&lt;br /&gt;
;;Removed the setup_cache code the kernel can boot up properly.&lt;br /&gt;
&lt;br /&gt;
;;Add Led support(asm) for indicating where the executing point is. By this way I found that the head.S executed properly but when executing stream enter the start_kernel the kernel would enter an unknown path.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;;Think about the cache initializing code issue&lt;br /&gt;
&lt;br /&gt;
Modify the icache initializing like this:&lt;br /&gt;
&lt;br /&gt;
   Index_Store_Tag_I   ---&amp;gt; Fill ---&amp;gt; Index_Store_Tag_I&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    li      a0, 0x2000&lt;br /&gt;
    lui     a2, 0x8000&lt;br /&gt;
    addu    a3, a2, a0&lt;br /&gt;
    move    k0, a2&lt;br /&gt;
&lt;br /&gt;
21:&lt;br /&gt;
    cache   Index_Store_Tag_I, 0(a2)&lt;br /&gt;
    addiu   a2, 16&lt;br /&gt;
    ble     a2, a3, 21b&lt;br /&gt;
    nop&lt;br /&gt;
&lt;br /&gt;
20:&lt;br /&gt;
    cache   Fill, 0(k0)&lt;br /&gt;
    addiu   k0, 16&lt;br /&gt;
    ble     k0, a3, 20b&lt;br /&gt;
    nop&lt;br /&gt;
&lt;br /&gt;
    li      a2, KSEG0&lt;br /&gt;
25:&lt;br /&gt;
    cache   Index_Store_Tag_I, 0(a2)&lt;br /&gt;
    addiu   a2, 16&lt;br /&gt;
    ble     a2, a3, 25b&lt;br /&gt;
    nop&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Modify the dcache initializing code like this:&lt;br /&gt;
&lt;br /&gt;
   Index_Store_Tag_D ---&amp;gt; load ---&amp;gt; Index_Store_Tag_D&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    lui     a2, 0x8000&lt;br /&gt;
    li      a0, 0x2000&lt;br /&gt;
    addu    a3, a2, a0&lt;br /&gt;
    move    k0, a2&lt;br /&gt;
22:&lt;br /&gt;
    cache   Index_Store_Tag_D, 0(a2)&lt;br /&gt;
    addiu   a2, 16&lt;br /&gt;
    ble     a2, a3, 22b&lt;br /&gt;
    nop&lt;br /&gt;
&lt;br /&gt;
23:&lt;br /&gt;
    lw      t3, 0(k0)&lt;br /&gt;
    addiu   k0, 16&lt;br /&gt;
    ble     k0, a3, 23b&lt;br /&gt;
    nop&lt;br /&gt;
&lt;br /&gt;
    lui     a2, 0x8000&lt;br /&gt;
24:&lt;br /&gt;
    cache   Index_Store_Tag_D, 0(a2)&lt;br /&gt;
    addiu   a2, 16&lt;br /&gt;
    ble     a2, a3, 24b&lt;br /&gt;
    nop&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The issue is also exist.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;;Doubt the Index_* cache ops function&lt;br /&gt;
&lt;br /&gt;
Add the following initializing code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    /* initialize way select array */&lt;br /&gt;
&lt;br /&gt;
    li           k0, 0x0400            # TagLo[15:10] is LRU bit&lt;br /&gt;
    mtc0    k0, CP0_TAGLO&lt;br /&gt;
&lt;br /&gt;
    /* enable ws */&lt;br /&gt;
    lui         k0, 0x2000&lt;br /&gt;
    mtc0    k0, $26         # CP0_ErrCtl&lt;br /&gt;
    ssnop&lt;br /&gt;
    ssnop&lt;br /&gt;
    ssnop&lt;br /&gt;
    sll     zero, 3&lt;br /&gt;
&lt;br /&gt;
    li      a0, 0x1000&lt;br /&gt;
    li      a2, KSEG0&lt;br /&gt;
    addu    a3, a2, a0&lt;br /&gt;
    /* set way select value is 1 */&lt;br /&gt;
28:&lt;br /&gt;
    cache   Index_Store_Tag_I, 0(a2)&lt;br /&gt;
    cache   Index_Store_Tag_D, 0(a2)&lt;br /&gt;
    addu    a2, 16&lt;br /&gt;
    bne     a2, a3, 28b&lt;br /&gt;
    nop&lt;br /&gt;
&lt;br /&gt;
    mtc0    zero, CP0_TAGLO&lt;br /&gt;
&lt;br /&gt;
    /* clear way 1 tag */&lt;br /&gt;
    li      a0, 0x1000&lt;br /&gt;
    li      a2, KSEG0&lt;br /&gt;
    addu    a3, a2, a0&lt;br /&gt;
28:&lt;br /&gt;
    cache   Index_Store_Tag_I, 0(a2)&lt;br /&gt;
    cache   Index_Store_Tag_D, 0(k0)&lt;br /&gt;
    addu    a2, 16&lt;br /&gt;
    bne     a2, a3, 28b&lt;br /&gt;
    nop    &lt;br /&gt;
&lt;br /&gt;
    /* disable ws */&lt;br /&gt;
    mtc0    zero, $26&lt;br /&gt;
    ssnop&lt;br /&gt;
    ssnop&lt;br /&gt;
    ssnop&lt;br /&gt;
    sll     zero, 3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The issue is also exist.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;;By Chance&lt;br /&gt;
&lt;br /&gt;
When I enable_cached in the end of setup_cache macro and disable_cached before the j start_kernel the kernel can boot up properly.&lt;br /&gt;
&lt;br /&gt;
I moved the enable_cached/disable_cached pair and found that the issue is disappear so long as the pair braket following code block:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    enable_cached&lt;br /&gt;
&lt;br /&gt;
    LONG_S     a0, fw_arg0     # firmware arguments&lt;br /&gt;
    LONG_S     a1, fw_arg1&lt;br /&gt;
    LONG_S     a2, fw_arg2&lt;br /&gt;
    LONG_S     a3, fw_arg3&lt;br /&gt;
&lt;br /&gt;
    disable_cached&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
I reviewed the setup_cp0 and setup_cache macro defined in include/asm-mips/mach-emma3p/subcore-init.h and found that they use the a0, a2 and a3 register and these vaules is also up 0x8000_0000. So the kernel get the incorrect value and make the kernel enter an unknown path.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Solution ==&lt;br /&gt;
&lt;br /&gt;
Don't use these register before they are saved in fw_argx.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Comcat</name></author>	</entry>

	</feed>