<p>Xiang Wang has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/27770">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">riscv: add suport to check machine length at runtime<br><br>Highest two bits of misa can be used to check machine length. Add code to support this.<br><br>Change-Id: I3bab301d38ea8aabf2c70437e179287814298b25<br>Signed-off-by: Xiang Wang <wxjstz@126.com><br>---<br>M src/arch/riscv/include/arch/cpu.h<br>1 file changed, 12 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://review.coreboot.org:29418/coreboot refs/changes/70/27770/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/arch/riscv/include/arch/cpu.h b/src/arch/riscv/include/arch/cpu.h</span><br><span>index 6008c75..d8a49b8 100644</span><br><span>--- a/src/arch/riscv/include/arch/cpu.h</span><br><span>+++ b/src/arch/riscv/include/arch/cpu.h</span><br><span>@@ -51,5 +51,17 @@</span><br><span>       return read_csr(misa) & (1 << (ext - 'A'));</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+static inline int xlen(void)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+       long t = read_csr(misa);</span><br><span style="color: hsl(120, 100%, 40%);">+      if (t < 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+               t = t << 1;</span><br><span style="color: hsl(120, 100%, 40%);">+             if (t < 0)</span><br><span style="color: hsl(120, 100%, 40%);">+                 return 128;</span><br><span style="color: hsl(120, 100%, 40%);">+           return 64;</span><br><span style="color: hsl(120, 100%, 40%);">+    }</span><br><span style="color: hsl(120, 100%, 40%);">+     return 32;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> struct cpu_info *cpu_info(void);</span><br><span> #endif /* __ARCH_CPU_H__ */</span><br><span></span><br></pre><p>To view, visit <a href="https://review.coreboot.org/27770">change 27770</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://review.coreboot.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://review.coreboot.org/27770"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: coreboot </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I3bab301d38ea8aabf2c70437e179287814298b25 </div>
<div style="display:none"> Gerrit-Change-Number: 27770 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Xiang Wang <wxjstz@126.com> </div>