151712e49SCosta Shulyupin.. SPDX-License-Identifier: GPL-2.0 251712e49SCosta Shulyupin 351712e49SCosta Shulyupin.. include:: ../../disclaimer-zh_CN.rst 451712e49SCosta Shulyupin 551712e49SCosta Shulyupin:Original: Documentation/arch/loongarch/introduction.rst 651712e49SCosta Shulyupin:Translator: Huacai Chen <chenhuacai@loongson.cn> 751712e49SCosta Shulyupin 851712e49SCosta Shulyupin============= 951712e49SCosta ShulyupinLoongArch介绍 1051712e49SCosta Shulyupin============= 1151712e49SCosta Shulyupin 1251712e49SCosta ShulyupinLoongArch是一种新的RISC ISA,在一定程度上类似于MIPS和RISC-V。LoongArch指令集 1351712e49SCosta Shulyupin包括一个精简32位版(LA32R)、一个标准32位版(LA32S)、一个64位版(LA64)。 1451712e49SCosta ShulyupinLoongArch定义了四个特权级(PLV0~PLV3),其中PLV0是最高特权级,用于内核;而PLV3 1551712e49SCosta Shulyupin是最低特权级,用于应用程序。本文档介绍了LoongArch的寄存器、基础指令集、虚拟内 1651712e49SCosta Shulyupin存以及其他一些主题。 1751712e49SCosta Shulyupin 1851712e49SCosta Shulyupin寄存器 1951712e49SCosta Shulyupin====== 2051712e49SCosta Shulyupin 2151712e49SCosta ShulyupinLoongArch的寄存器包括通用寄存器(GPRs)、浮点寄存器(FPRs)、向量寄存器(VRs) 2251712e49SCosta Shulyupin和用于特权模式(PLV0)的控制状态寄存器(CSRs)。 2351712e49SCosta Shulyupin 2451712e49SCosta Shulyupin通用寄存器 2551712e49SCosta Shulyupin---------- 2651712e49SCosta Shulyupin 2751712e49SCosta ShulyupinLoongArch包括32个通用寄存器( ``$r0`` ~ ``$r31`` ),LA32中每个寄存器为32位宽, 2851712e49SCosta ShulyupinLA64中每个寄存器为64位宽。 ``$r0`` 的内容总是固定为0,而其他寄存器在体系结构层面 2951712e49SCosta Shulyupin没有特殊功能。( ``$r1`` 算是一个例外,在BL指令中固定用作链接返回寄存器。) 3051712e49SCosta Shulyupin 3151712e49SCosta Shulyupin内核使用了一套LoongArch寄存器约定,定义在LoongArch ELF psABI规范中,详细描述参见 3251712e49SCosta Shulyupin:ref:`参考文献 <loongarch-references-zh_CN>`: 3351712e49SCosta Shulyupin 3451712e49SCosta Shulyupin================= =============== =================== ========== 3551712e49SCosta Shulyupin寄存器名 别名 用途 跨调用保持 3651712e49SCosta Shulyupin================= =============== =================== ========== 3751712e49SCosta Shulyupin``$r0`` ``$zero`` 常量0 不使用 3851712e49SCosta Shulyupin``$r1`` ``$ra`` 返回地址 否 3951712e49SCosta Shulyupin``$r2`` ``$tp`` TLS/线程信息指针 不使用 4051712e49SCosta Shulyupin``$r3`` ``$sp`` 栈指针 是 4151712e49SCosta Shulyupin``$r4``-``$r11`` ``$a0``-``$a7`` 参数寄存器 否 4251712e49SCosta Shulyupin``$r4``-``$r5`` ``$v0``-``$v1`` 返回值 否 4351712e49SCosta Shulyupin``$r12``-``$r20`` ``$t0``-``$t8`` 临时寄存器 否 4451712e49SCosta Shulyupin``$r21`` ``$u0`` 每CPU变量基地址 不使用 4551712e49SCosta Shulyupin``$r22`` ``$fp`` 帧指针 是 4651712e49SCosta Shulyupin``$r23``-``$r31`` ``$s0``-``$s8`` 静态寄存器 是 4751712e49SCosta Shulyupin================= =============== =================== ========== 4851712e49SCosta Shulyupin 4951712e49SCosta Shulyupin.. note:: 5051712e49SCosta Shulyupin 注意: ``$r21`` 寄存器在ELF psABI中保留未使用,但是在Linux内核用于保 5151712e49SCosta Shulyupin 存每CPU变量基地址。该寄存器没有ABI命名,不过在内核中称为 ``$u0`` 。在 5251712e49SCosta Shulyupin 一些遗留代码中有时可能见到 ``$v0`` 和 ``$v1`` ,它们是 ``$a0`` 和 5351712e49SCosta Shulyupin ``$a1`` 的别名,属于已经废弃的用法。 5451712e49SCosta Shulyupin 5551712e49SCosta Shulyupin浮点寄存器 5651712e49SCosta Shulyupin---------- 5751712e49SCosta Shulyupin 5851712e49SCosta Shulyupin当系统中存在FPU时,LoongArch有32个浮点寄存器( ``$f0`` ~ ``$f31`` )。在LA64 5951712e49SCosta Shulyupin的CPU核上,每个寄存器均为64位宽。 6051712e49SCosta Shulyupin 6151712e49SCosta Shulyupin浮点寄存器的使用约定与LoongArch ELF psABI规范的描述相同: 6251712e49SCosta Shulyupin 6351712e49SCosta Shulyupin================= ================== =================== ========== 6451712e49SCosta Shulyupin寄存器名 别名 用途 跨调用保持 6551712e49SCosta Shulyupin================= ================== =================== ========== 6651712e49SCosta Shulyupin``$f0``-``$f7`` ``$fa0``-``$fa7`` 参数寄存器 否 6751712e49SCosta Shulyupin``$f0``-``$f1`` ``$fv0``-``$fv1`` 返回值 否 6851712e49SCosta Shulyupin``$f8``-``$f23`` ``$ft0``-``$ft15`` 临时寄存器 否 6951712e49SCosta Shulyupin``$f24``-``$f31`` ``$fs0``-``$fs7`` 静态寄存器 是 7051712e49SCosta Shulyupin================= ================== =================== ========== 7151712e49SCosta Shulyupin 7251712e49SCosta Shulyupin.. note:: 7351712e49SCosta Shulyupin 注意:在一些遗留代码中有时可能见到 ``$fv0`` 和 ``$fv1`` ,它们是 7451712e49SCosta Shulyupin ``$fa0`` 和 ``$fa1`` 的别名,属于已经废弃的用法。 7551712e49SCosta Shulyupin 7651712e49SCosta Shulyupin 7751712e49SCosta Shulyupin向量寄存器 7851712e49SCosta Shulyupin---------- 7951712e49SCosta Shulyupin 8051712e49SCosta ShulyupinLoongArch现有两种向量扩展: 8151712e49SCosta Shulyupin 8251712e49SCosta Shulyupin- 128位向量扩展LSX(全称Loongson SIMD eXtention), 8351712e49SCosta Shulyupin- 256位向量扩展LASX(全称Loongson Advanced SIMD eXtention)。 8451712e49SCosta Shulyupin 8551712e49SCosta ShulyupinLSX使用 ``$v0`` ~ ``$v31`` 向量寄存器,而LASX则使用 ``$x0`` ~ ``$x31`` 。 8651712e49SCosta Shulyupin 8751712e49SCosta Shulyupin浮点寄存器和向量寄存器是复用的,比如:在一个实现了LSX和LASX的核上, ``$x0`` 的 8851712e49SCosta Shulyupin低128位与 ``$v0`` 共用, ``$v0`` 的低64位与 ``$f0`` 共用,其他寄存器依此类推。 8951712e49SCosta Shulyupin 9051712e49SCosta Shulyupin控制状态寄存器 9151712e49SCosta Shulyupin-------------- 9251712e49SCosta Shulyupin 9351712e49SCosta Shulyupin控制状态寄存器只能在特权模式(PLV0)下访问: 9451712e49SCosta Shulyupin 9551712e49SCosta Shulyupin================= ==================================== ========== 9651712e49SCosta Shulyupin地址 全称描述 简称 9751712e49SCosta Shulyupin================= ==================================== ========== 9851712e49SCosta Shulyupin0x0 当前模式信息 CRMD 9951712e49SCosta Shulyupin0x1 异常前模式信息 PRMD 10051712e49SCosta Shulyupin0x2 扩展部件使能 EUEN 10151712e49SCosta Shulyupin0x3 杂项控制 MISC 10251712e49SCosta Shulyupin0x4 异常配置 ECFG 10351712e49SCosta Shulyupin0x5 异常状态 ESTAT 10451712e49SCosta Shulyupin0x6 异常返回地址 ERA 10551712e49SCosta Shulyupin0x7 出错(Faulting)虚拟地址 BADV 10651712e49SCosta Shulyupin0x8 出错(Faulting)指令字 BADI 10751712e49SCosta Shulyupin0xC 异常入口地址 EENTRY 10851712e49SCosta Shulyupin0x10 TLB索引 TLBIDX 10951712e49SCosta Shulyupin0x11 TLB表项高位 TLBEHI 11051712e49SCosta Shulyupin0x12 TLB表项低位0 TLBELO0 11151712e49SCosta Shulyupin0x13 TLB表项低位1 TLBELO1 11251712e49SCosta Shulyupin0x18 地址空间标识符 ASID 11351712e49SCosta Shulyupin0x19 低半地址空间页全局目录基址 PGDL 11451712e49SCosta Shulyupin0x1A 高半地址空间页全局目录基址 PGDH 11551712e49SCosta Shulyupin0x1B 页全局目录基址 PGD 11651712e49SCosta Shulyupin0x1C 页表遍历控制低半部分 PWCL 11751712e49SCosta Shulyupin0x1D 页表遍历控制高半部分 PWCH 11851712e49SCosta Shulyupin0x1E STLB页大小 STLBPS 11951712e49SCosta Shulyupin0x1F 缩减虚地址配置 RVACFG 12051712e49SCosta Shulyupin0x20 CPU编号 CPUID 12151712e49SCosta Shulyupin0x21 特权资源配置信息1 PRCFG1 12251712e49SCosta Shulyupin0x22 特权资源配置信息2 PRCFG2 12351712e49SCosta Shulyupin0x23 特权资源配置信息3 PRCFG3 12451712e49SCosta Shulyupin0x30+n (0≤n≤15) 数据保存寄存器 SAVEn 12551712e49SCosta Shulyupin0x40 定时器编号 TID 12651712e49SCosta Shulyupin0x41 定时器配置 TCFG 12751712e49SCosta Shulyupin0x42 定时器值 TVAL 12851712e49SCosta Shulyupin0x43 计时器补偿 CNTC 12951712e49SCosta Shulyupin0x44 定时器中断清除 TICLR 13051712e49SCosta Shulyupin0x60 LLBit相关控制 LLBCTL 13151712e49SCosta Shulyupin0x80 实现相关控制1 IMPCTL1 13251712e49SCosta Shulyupin0x81 实现相关控制2 IMPCTL2 13351712e49SCosta Shulyupin0x88 TLB重填异常入口地址 TLBRENTRY 13451712e49SCosta Shulyupin0x89 TLB重填异常出错(Faulting)虚地址 TLBRBADV 13551712e49SCosta Shulyupin0x8A TLB重填异常返回地址 TLBRERA 13651712e49SCosta Shulyupin0x8B TLB重填异常数据保存 TLBRSAVE 13751712e49SCosta Shulyupin0x8C TLB重填异常表项低位0 TLBRELO0 13851712e49SCosta Shulyupin0x8D TLB重填异常表项低位1 TLBRELO1 13951712e49SCosta Shulyupin0x8E TLB重填异常表项高位 TLBEHI 14051712e49SCosta Shulyupin0x8F TLB重填异常前模式信息 TLBRPRMD 14151712e49SCosta Shulyupin0x90 机器错误控制 MERRCTL 14251712e49SCosta Shulyupin0x91 机器错误信息1 MERRINFO1 14351712e49SCosta Shulyupin0x92 机器错误信息2 MERRINFO2 14451712e49SCosta Shulyupin0x93 机器错误异常入口地址 MERRENTRY 14551712e49SCosta Shulyupin0x94 机器错误异常返回地址 MERRERA 14651712e49SCosta Shulyupin0x95 机器错误异常数据保存 MERRSAVE 14751712e49SCosta Shulyupin0x98 高速缓存标签 CTAG 14851712e49SCosta Shulyupin0x180+n (0≤n≤3) 直接映射配置窗口n DMWn 14951712e49SCosta Shulyupin0x200+2n (0≤n≤31) 性能监测配置n PMCFGn 15051712e49SCosta Shulyupin0x201+2n (0≤n≤31) 性能监测计数器n PMCNTn 15151712e49SCosta Shulyupin0x300 内存读写监视点整体控制 MWPC 15251712e49SCosta Shulyupin0x301 内存读写监视点整体状态 MWPS 15351712e49SCosta Shulyupin0x310+8n (0≤n≤7) 内存读写监视点n配置1 MWPnCFG1 15451712e49SCosta Shulyupin0x311+8n (0≤n≤7) 内存读写监视点n配置2 MWPnCFG2 15551712e49SCosta Shulyupin0x312+8n (0≤n≤7) 内存读写监视点n配置3 MWPnCFG3 15651712e49SCosta Shulyupin0x313+8n (0≤n≤7) 内存读写监视点n配置4 MWPnCFG4 15751712e49SCosta Shulyupin0x380 取指监视点整体控制 FWPC 15851712e49SCosta Shulyupin0x381 取指监视点整体状态 FWPS 15951712e49SCosta Shulyupin0x390+8n (0≤n≤7) 取指监视点n配置1 FWPnCFG1 16051712e49SCosta Shulyupin0x391+8n (0≤n≤7) 取指监视点n配置2 FWPnCFG2 16151712e49SCosta Shulyupin0x392+8n (0≤n≤7) 取指监视点n配置3 FWPnCFG3 16251712e49SCosta Shulyupin0x393+8n (0≤n≤7) 取指监视点n配置4 FWPnCFG4 16351712e49SCosta Shulyupin0x500 调试寄存器 DBG 16451712e49SCosta Shulyupin0x501 调试异常返回地址 DERA 16551712e49SCosta Shulyupin0x502 调试数据保存 DSAVE 16651712e49SCosta Shulyupin================= ==================================== ========== 16751712e49SCosta Shulyupin 16851712e49SCosta ShulyupinERA,TLBRERA,MERRERA和DERA有时也分别称为EPC,TLBREPC,MERREPC和DEPC。 16951712e49SCosta Shulyupin 17051712e49SCosta Shulyupin基础指令集 17151712e49SCosta Shulyupin========== 17251712e49SCosta Shulyupin 17351712e49SCosta Shulyupin指令格式 17451712e49SCosta Shulyupin-------- 17551712e49SCosta Shulyupin 17651712e49SCosta ShulyupinLoongArch的指令字长为32位,一共有9种基本指令格式(以及一些变体): 17751712e49SCosta Shulyupin 17851712e49SCosta Shulyupin=========== ========================== 17951712e49SCosta Shulyupin格式名称 指令构成 18051712e49SCosta Shulyupin=========== ========================== 18151712e49SCosta Shulyupin2R Opcode + Rj + Rd 18251712e49SCosta Shulyupin3R Opcode + Rk + Rj + Rd 18351712e49SCosta Shulyupin4R Opcode + Ra + Rk + Rj + Rd 18451712e49SCosta Shulyupin2RI8 Opcode + I8 + Rj + Rd 18551712e49SCosta Shulyupin2RI12 Opcode + I12 + Rj + Rd 18651712e49SCosta Shulyupin2RI14 Opcode + I14 + Rj + Rd 18751712e49SCosta Shulyupin2RI16 Opcode + I16 + Rj + Rd 18851712e49SCosta Shulyupin1RI21 Opcode + I21L + Rj + I21H 18951712e49SCosta ShulyupinI26 Opcode + I26L + I26H 19051712e49SCosta Shulyupin=========== ========================== 19151712e49SCosta Shulyupin 19251712e49SCosta ShulyupinOpcode是指令操作码,Rj和Rk是源操作数(寄存器),Rd是目标操作数(寄存器),Ra是 19351712e49SCosta Shulyupin4R-type格式特有的附加操作数(寄存器)。I8/I12/I14/I16/I21/I26分别是8位/12位/14位/ 19451712e49SCosta Shulyupin16位/21位/26位的立即数。其中较长的21位和26位立即数在指令字中被分割为高位部分与低位 19551712e49SCosta Shulyupin部分,所以你们在这里的格式描述中能够看到I21L/I21H和I26L/I26H这样带后缀的表述。 19651712e49SCosta Shulyupin 19751712e49SCosta Shulyupin指令列表 19851712e49SCosta Shulyupin-------- 19951712e49SCosta Shulyupin 20051712e49SCosta Shulyupin为了简便起见,我们在此只罗列一下指令名称(助记符),需要详细信息请阅读 20151712e49SCosta Shulyupin:ref:`参考文献 <loongarch-references-zh_CN>` 中的文档。 20251712e49SCosta Shulyupin 20351712e49SCosta Shulyupin1. 算术运算指令:: 20451712e49SCosta Shulyupin 20551712e49SCosta Shulyupin ADD.W SUB.W ADDI.W ADD.D SUB.D ADDI.D 20651712e49SCosta Shulyupin SLT SLTU SLTI SLTUI 20751712e49SCosta Shulyupin AND OR NOR XOR ANDN ORN ANDI ORI XORI 20851712e49SCosta Shulyupin MUL.W MULH.W MULH.WU DIV.W DIV.WU MOD.W MOD.WU 20951712e49SCosta Shulyupin MUL.D MULH.D MULH.DU DIV.D DIV.DU MOD.D MOD.DU 21051712e49SCosta Shulyupin PCADDI PCADDU12I PCADDU18I 21151712e49SCosta Shulyupin LU12I.W LU32I.D LU52I.D ADDU16I.D 21251712e49SCosta Shulyupin 21351712e49SCosta Shulyupin2. 移位运算指令:: 21451712e49SCosta Shulyupin 21551712e49SCosta Shulyupin SLL.W SRL.W SRA.W ROTR.W SLLI.W SRLI.W SRAI.W ROTRI.W 21651712e49SCosta Shulyupin SLL.D SRL.D SRA.D ROTR.D SLLI.D SRLI.D SRAI.D ROTRI.D 21751712e49SCosta Shulyupin 21851712e49SCosta Shulyupin3. 位域操作指令:: 21951712e49SCosta Shulyupin 22051712e49SCosta Shulyupin EXT.W.B EXT.W.H CLO.W CLO.D SLZ.W CLZ.D CTO.W CTO.D CTZ.W CTZ.D 22151712e49SCosta Shulyupin BYTEPICK.W BYTEPICK.D BSTRINS.W BSTRINS.D BSTRPICK.W BSTRPICK.D 22251712e49SCosta Shulyupin REVB.2H REVB.4H REVB.2W REVB.D REVH.2W REVH.D BITREV.4B BITREV.8B BITREV.W BITREV.D 22351712e49SCosta Shulyupin MASKEQZ MASKNEZ 22451712e49SCosta Shulyupin 22551712e49SCosta Shulyupin4. 分支转移指令:: 22651712e49SCosta Shulyupin 22751712e49SCosta Shulyupin BEQ BNE BLT BGE BLTU BGEU BEQZ BNEZ B BL JIRL 22851712e49SCosta Shulyupin 22951712e49SCosta Shulyupin5. 访存读写指令:: 23051712e49SCosta Shulyupin 23151712e49SCosta Shulyupin LD.B LD.BU LD.H LD.HU LD.W LD.WU LD.D ST.B ST.H ST.W ST.D 23251712e49SCosta Shulyupin LDX.B LDX.BU LDX.H LDX.HU LDX.W LDX.WU LDX.D STX.B STX.H STX.W STX.D 23351712e49SCosta Shulyupin LDPTR.W LDPTR.D STPTR.W STPTR.D 23451712e49SCosta Shulyupin PRELD PRELDX 23551712e49SCosta Shulyupin 23651712e49SCosta Shulyupin6. 原子操作指令:: 23751712e49SCosta Shulyupin 23851712e49SCosta Shulyupin LL.W SC.W LL.D SC.D 23951712e49SCosta Shulyupin AMSWAP.W AMSWAP.D AMADD.W AMADD.D AMAND.W AMAND.D AMOR.W AMOR.D AMXOR.W AMXOR.D 24051712e49SCosta Shulyupin AMMAX.W AMMAX.D AMMIN.W AMMIN.D 24151712e49SCosta Shulyupin 24251712e49SCosta Shulyupin7. 栅障指令:: 24351712e49SCosta Shulyupin 24451712e49SCosta Shulyupin IBAR DBAR 24551712e49SCosta Shulyupin 24651712e49SCosta Shulyupin8. 特殊指令:: 24751712e49SCosta Shulyupin 24851712e49SCosta Shulyupin SYSCALL BREAK CPUCFG NOP IDLE ERTN(ERET) DBCL(DBGCALL) RDTIMEL.W RDTIMEH.W RDTIME.D 24951712e49SCosta Shulyupin ASRTLE.D ASRTGT.D 25051712e49SCosta Shulyupin 25151712e49SCosta Shulyupin9. 特权指令:: 25251712e49SCosta Shulyupin 25351712e49SCosta Shulyupin CSRRD CSRWR CSRXCHG 25451712e49SCosta Shulyupin IOCSRRD.B IOCSRRD.H IOCSRRD.W IOCSRRD.D IOCSRWR.B IOCSRWR.H IOCSRWR.W IOCSRWR.D 25551712e49SCosta Shulyupin CACOP TLBP(TLBSRCH) TLBRD TLBWR TLBFILL TLBCLR TLBFLUSH INVTLB LDDIR LDPTE 25651712e49SCosta Shulyupin 25751712e49SCosta Shulyupin虚拟内存 25851712e49SCosta Shulyupin======== 25951712e49SCosta Shulyupin 26051712e49SCosta ShulyupinLoongArch可以使用直接映射虚拟内存和分页映射虚拟内存。 26151712e49SCosta Shulyupin 26251712e49SCosta Shulyupin直接映射虚拟内存通过CSR.DMWn(n=0~3)来进行配置,虚拟地址(VA)和物理地址(PA) 26351712e49SCosta Shulyupin之间有简单的映射关系:: 26451712e49SCosta Shulyupin 26551712e49SCosta Shulyupin VA = PA + 固定偏移 26651712e49SCosta Shulyupin 26751712e49SCosta Shulyupin分页映射的虚拟地址(VA)和物理地址(PA)有任意的映射关系,这种关系记录在TLB和页 26851712e49SCosta Shulyupin表中。LoongArch的TLB包括一个全相联的MTLB(Multiple Page Size TLB,多样页大小TLB) 26951712e49SCosta Shulyupin和一个组相联的STLB(Single Page Size TLB,单一页大小TLB)。 27051712e49SCosta Shulyupin 27151712e49SCosta Shulyupin缺省状态下,LA32的整个虚拟地址空间配置如下: 27251712e49SCosta Shulyupin 27351712e49SCosta Shulyupin============ =========================== =========================== 27451712e49SCosta Shulyupin区段名 地址范围 属性 27551712e49SCosta Shulyupin============ =========================== =========================== 27651712e49SCosta Shulyupin``UVRANGE`` ``0x00000000 - 0x7FFFFFFF`` 分页映射, 可缓存, PLV0~3 27751712e49SCosta Shulyupin``KPRANGE0`` ``0x80000000 - 0x9FFFFFFF`` 直接映射, 非缓存, PLV0 27851712e49SCosta Shulyupin``KPRANGE1`` ``0xA0000000 - 0xBFFFFFFF`` 直接映射, 可缓存, PLV0 27951712e49SCosta Shulyupin``KVRANGE`` ``0xC0000000 - 0xFFFFFFFF`` 分页映射, 可缓存, PLV0 28051712e49SCosta Shulyupin============ =========================== =========================== 28151712e49SCosta Shulyupin 28251712e49SCosta Shulyupin用户态(PLV3)只能访问UVRANGE,对于直接映射的KPRANGE0和KPRANGE1,将虚拟地址的第 28351712e49SCosta Shulyupin30~31位清零就等于物理地址。例如:物理地址0x00001000对应的非缓存直接映射虚拟地址 28451712e49SCosta Shulyupin是0x80001000,而其可缓存直接映射虚拟地址是0xA0001000。 28551712e49SCosta Shulyupin 28651712e49SCosta Shulyupin缺省状态下,LA64的整个虚拟地址空间配置如下: 28751712e49SCosta Shulyupin 28851712e49SCosta Shulyupin============ ====================== ================================== 28951712e49SCosta Shulyupin区段名 地址范围 属性 29051712e49SCosta Shulyupin============ ====================== ================================== 29151712e49SCosta Shulyupin``XUVRANGE`` ``0x0000000000000000 - 分页映射, 可缓存, PLV0~3 29251712e49SCosta Shulyupin 0x3FFFFFFFFFFFFFFF`` 29351712e49SCosta Shulyupin``XSPRANGE`` ``0x4000000000000000 - 直接映射, 可缓存 / 非缓存, PLV0 29451712e49SCosta Shulyupin 0x7FFFFFFFFFFFFFFF`` 29551712e49SCosta Shulyupin``XKPRANGE`` ``0x8000000000000000 - 直接映射, 可缓存 / 非缓存, PLV0 29651712e49SCosta Shulyupin 0xBFFFFFFFFFFFFFFF`` 29751712e49SCosta Shulyupin``XKVRANGE`` ``0xC000000000000000 - 分页映射, 可缓存, PLV0 29851712e49SCosta Shulyupin 0xFFFFFFFFFFFFFFFF`` 29951712e49SCosta Shulyupin============ ====================== ================================== 30051712e49SCosta Shulyupin 30151712e49SCosta Shulyupin用户态(PLV3)只能访问XUVRANGE,对于直接映射的XSPRANGE和XKPRANGE,将虚拟地址的第 30251712e49SCosta Shulyupin60~63位清零就等于物理地址,而其缓存属性是通过虚拟地址的第60~61位配置的(0表示强序 30351712e49SCosta Shulyupin非缓存,1表示一致可缓存,2表示弱序非缓存)。 30451712e49SCosta Shulyupin 30551712e49SCosta Shulyupin目前,我们仅用XKPRANGE来进行直接映射,XSPRANGE保留给以后用。 30651712e49SCosta Shulyupin 30751712e49SCosta Shulyupin此处给出一个直接映射的例子:物理地址0x00000000_00001000的强序非缓存直接映射虚拟地址 30851712e49SCosta Shulyupin(在XKPRANGE中)是0x80000000_00001000,其一致可缓存直接映射虚拟地址(在XKPRANGE中) 30951712e49SCosta Shulyupin是0x90000000_00001000,而其弱序非缓存直接映射虚拟地址(在XKPRANGE中)是0xA0000000_ 31051712e49SCosta Shulyupin00001000。 31151712e49SCosta Shulyupin 31251712e49SCosta ShulyupinLoongson与LoongArch的关系 31351712e49SCosta Shulyupin========================= 31451712e49SCosta Shulyupin 31551712e49SCosta ShulyupinLoongArch是一种RISC指令集架构(ISA),不同于现存的任何一种ISA,而Loongson(即龙 31651712e49SCosta Shulyupin芯)是一个处理器家族。龙芯包括三个系列:Loongson-1(龙芯1号)是32位处理器系列, 31751712e49SCosta ShulyupinLoongson-2(龙芯2号)是低端64位处理器系列,而Loongson-3(龙芯3号)是高端64位处理 31851712e49SCosta Shulyupin器系列。旧的龙芯处理器基于MIPS架构,而新的龙芯处理器基于LoongArch架构。以龙芯3号 31951712e49SCosta Shulyupin为例:龙芯3A1000/3B1500/3A2000/3A3000/3A4000都是兼容MIPS的,而龙芯3A5000(以及将 32051712e49SCosta Shulyupin来的型号)都是基于LoongArch的。 32151712e49SCosta Shulyupin 32251712e49SCosta Shulyupin.. _loongarch-references-zh_CN: 32351712e49SCosta Shulyupin 32451712e49SCosta Shulyupin参考文献 32551712e49SCosta Shulyupin======== 32651712e49SCosta Shulyupin 32751712e49SCosta ShulyupinLoongson官方网站(龙芯中科技术股份有限公司): 32851712e49SCosta Shulyupin 32951712e49SCosta Shulyupin http://www.loongson.cn/ 33051712e49SCosta Shulyupin 33151712e49SCosta ShulyupinLoongson与LoongArch的开发者网站(软件与文档资源): 33251712e49SCosta Shulyupin 33351712e49SCosta Shulyupin http://www.loongnix.cn/ 33451712e49SCosta Shulyupin 33551712e49SCosta Shulyupin https://github.com/loongson/ 33651712e49SCosta Shulyupin 33751712e49SCosta Shulyupin https://loongson.github.io/LoongArch-Documentation/ 33851712e49SCosta Shulyupin 33951712e49SCosta ShulyupinLoongArch指令集架构的文档: 34051712e49SCosta Shulyupin 34151712e49SCosta Shulyupin https://github.com/loongson/LoongArch-Documentation/releases/latest/download/LoongArch-Vol1-v1.02-CN.pdf (中文版) 34251712e49SCosta Shulyupin 34351712e49SCosta Shulyupin https://github.com/loongson/LoongArch-Documentation/releases/latest/download/LoongArch-Vol1-v1.02-EN.pdf (英文版) 34451712e49SCosta Shulyupin 34551712e49SCosta ShulyupinLoongArch的ELF psABI文档: 34651712e49SCosta Shulyupin 347*e74a6b7fSTiezhu Yang https://github.com/loongson/LoongArch-Documentation/releases/latest/download/LoongArch-ELF-ABI-v2.01-CN.pdf (中文版) 34851712e49SCosta Shulyupin 349*e74a6b7fSTiezhu Yang https://github.com/loongson/LoongArch-Documentation/releases/latest/download/LoongArch-ELF-ABI-v2.01-EN.pdf (英文版) 35051712e49SCosta Shulyupin 35151712e49SCosta ShulyupinLoongson与LoongArch的Linux内核源码仓库: 35251712e49SCosta Shulyupin 35351712e49SCosta Shulyupin https://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson.git 354