Line 142: |
Line 142: |
| |- | | |- |
| | 0x08000000 | | | 0x08000000 |
− | | For applications: FCRAM + GSP heap size | + | | 用于应用程序的FCRAM和GSP的堆大小 |
| | 0x08000000 | | | 0x08000000 |
− | | Heap mapped by [[SVC|ControlMemory]] | + | | 用[[SVC|内存控制]]映射的堆 |
| |- | | |- |
− | | 0x10000000-StackSize | + | | 0x10000000-栈大小 |
− | | .bss physical address - total stack pages | + | | .bss物理地址- 总栈页面 |
− | | StackSize from process exheader | + | | 从进程exheader获得的栈大小 |
− | | Stack for the main-thread, initialized by the ARM11 kernel. The StackSize from the exheader is usually 0x4000, therefore the stack-bottom is usually 0x0FFFC000. The stack for the other threads is normally located in the process .data section however this can be arbitrary. | + | | 主线程的栈,被ARM11内核初始化。exheader中的栈大小一般是0x4000,而栈底常是0x0FFFC000。其他线程的栈一般定位到进程的.data位置,不过可以随意。 |
| |- | | |- |
| | 0x10000000 | | | 0x10000000 |
| | | | | |
| | 0x04000000 | | | 0x04000000 |
− | | [[SVC|Shared]] memory | + | | [[SVC|共享]]内存 |
| |- | | |- |
| | 0x14000000 | | | 0x14000000 |
| | FCRAM+0 | | | FCRAM+0 |
| | 0x08000000 | | | 0x08000000 |
− | | Can be mapped by [[SVC|ControlMemory]], this is used for the application's GSP heap. | + | | 可以用[[SVC|内存控制]]映射,这是用于应用程序的GSP的堆。 |
| |- | | |- |
| | 0x1EC00000 | | | 0x1EC00000 |
| | 0x10100000 | | | 0x10100000 |
| | 0x01000000 | | | 0x01000000 |
− | | [[IO]] registers, the mapped IO pages which each process can access is specified in the [[NCCH#CXI|CXI]] exheader.(Applications normally don't have access to registers in this range) | + | | [[IO]]寄存器,是每个进程都可以在[[NCCH#CXI|CXI]]中指定访问的IO映射页面。(应用程序一般没有在此范围寄存器的访问权限) |
| |- | | |- |
| | 0x1F000000 | | | 0x1F000000 |
| | 0x18000000 | | | 0x18000000 |
| | 0x00600000 | | | 0x00600000 |
− | | VRAM, access to this is specified by the exheader. | + | | VRAM,用exheader指定访问权限。 |
| |- | | |- |
| | 0x1FF00000 | | | 0x1FF00000 |
| | 0x1FF00000 | | | 0x1FF00000 |
| | 0x00080000 | | | 0x00080000 |
− | | DSP memory, access to this is specified by the exheader. | + | | DSP内存,用exheader指定访问权限。 |
| |- | | |- |
| | 0x1FF80000 | | | 0x1FF80000 |
| | | | | |
| | 0x1000 | | | 0x1000 |
− | | [[Configuration Memory]], all processes have access to this however write-permission to this page is specified by the exheader "Shared page writing" kernel flag. | + | | [[Configuration Memory|设置信息内存]],任何进程都对这里有访问权限,但是需要在exheader "Shared page writing"标记指定页面的写权限。 |
| |- | | |- |
| | 0x1FF81000 | | | 0x1FF81000 |
| | | | | |
| | 0x1000 | | | 0x1000 |
− | | Shared page, access to this is the same as 0x1FF80000. | + | | 共享页面,访问方式和0x1FF80000相同。 |
| |} | | |} |
| | | |
− | All executable pages are read-only, and data pages have the execute-never permission set. Normally .text from the loaded ExeFS:/.code is the only mapped executable memory. Executable [[RO Services|CROs]] can be loaded into memory, once loaded the CRO .text section memory page permissions are changed via [[SVC|ControlProcessMemory]] from RW- to R-X. The address and size of each ExeFS:/.code section is stored in the exheader, the permissions for each section is: .text R-X, .rodata R--, .data RW-, and .bss RW-. The loaded .code is mapped to the addresses specified in the exheader by the ARM11 kernel. The stack permissions is initialized by the ARM11 kernel: RW-. The heap permissions is normally RW-.
| + | 所有的可执行页面都是只读的,数据页面则有不可许可执行的标记。一般的,ExeFS:/.code里面的.text只能映射到可执行内存。可执行文件的[[RO Services|CROs]]可以被装载到内存,一旦装载完CRO的.text区域,内存页面的权限就被[[SVC|控制进程内存]]从RW-改到R-X。每个ExeFS:/.code区域的地址和大小都在exheader里面,对应各个区域的权限是:.text R-X, .rodata R--, .data RW-, and .bss RW-。装载过的.code会被ARM11内核根据exheader中指定的地址映射。栈的权限被ARM11内核初始化为RW-。堆的权限一般是RW-。 |
| | | |
− | All userland memory is mapped with RW permissions for privileged-mode. However, normally the ARM11 kernel only uses userland read/write instructions(or checks that the memory can be written from userland first) for accessing memory specified by [[SVC|SVCs]].
| + | 所有用户空间的内存都在特权模式下映射为RW权限。不过一般ARM11内核访问内存根据[[SVC|SVCs]]的指定,只用用户空间读写指令(或者检查内存可以先从用户空间写入)。 |
| | | |
− | The virtual memory located below 0x20000000 is process-unique, processes can't directly access memory for other processes. The virtual memory starting at 0x20000000 is only accessible in privileged-mode. When service [[Services API|commands]] are used, the kernel maps memory in the destination process for input/output buffers, where the addresses in the command received by the process is replaced by this mapped memory. When this is an input buffer, the buffer data is copied to the mapped memory. When this is an output buffer, the data stored in the mapped memory is copied to the destination buffer specified in the command.
| + | 低于0x20000000的虚拟内存是进程独立的,进程不能直接访问其他进程的内存。从0x20000000开始的内存只有在特权模式下才能访问。当调用服务[[Services API|命令]]时,内核会映射目标进程的内存作为IO缓冲区,将进程接到的命令地址替换为这个映射内存。如果是一块输入缓冲,缓冲数据会复制到映射内存。如果是输出缓冲,在映射内存中存储的数据会复制到命令指定的目标缓冲区。 |
| | | |
− | The physical address which memory for the application memory-type is mapped to begins at FCRAM+0, the total memory allocated for this memory-type is stored in [[Configuration_Memory]]. Applications' exefs:/.code under the application memory-type is mapped at FCRAM + APPMEMALLOC - exefs:/.code size aligned to the page size. The application .bss is mapped at CODEADDR - .bss size aligned down to the page size. Once the application exefs:/.code, .bss, and stack are mapped, APPMEMALLOC is set to APPMEMALLOC - (stacksize + bss_size + codesize), where stacksize, bss_size, and code_size are aligned to the page size.
| + | 应用程序内存类型的内存物理地址会映射到FCRAM+0,总共为此内存类型分配的内存会存储到[[Configuration_Memory|设置信息内存]]。低于应用程序内存类的应用程序的exefs:/.code 会映射到FCRAM + APPMEMALLOC - exefs:/.code大小,根据页面大小向上对齐。应用程序的.bss会映射到CODEADDR - .bss大小, 根据页面大小向下对齐。当应用程序的exefs:/.code,.bss和栈都被映射后,APPMEMALLOC会设置为APPMEMALLOC - (栈大小 + bss大小 + code大小),将栈大小,bss大小,code大小都对齐到页面大小。 |
| | | |
| == 系统内存细节 == | | == 系统内存细节 == |
Line 201: |
Line 201: |
| 句柄0xFFFF8001是到当前KProcess的引用。 | | 句柄0xFFFF8001是到当前KProcess的引用。 |
| | | |
− | == VRAM Map While Running Webbrowser == | + | == 运行网络浏览器时候的VRAM映射 == |
− | *0x1e6000-0x22C500 -- top screen framebuffer 0(240x400x3) | + | *0x1e6000-0x22C500 -- 上屏幕帧缓冲0(240x400x3) |
− | *0x22C800-0x272D00 -- top screen framebuffer 1(240x400x3) | + | *0x22C800-0x272D00 -- 上屏幕帧缓冲1(240x400x3) |
− | *0x273000-0x2B9500 -- top screen framebuffer 2(240x400x3) | + | *0x273000-0x2B9500 -- 上屏幕帧缓冲2(240x400x3) |
− | *0x2B9800-0x2FFD00 -- top screen framebuffer 3(240x400x3) | + | *0x2B9800-0x2FFD00 -- 上屏幕帧缓冲3(240x400x3) |
− | *0x48F000-0x4C7400 -- bottom screen framebuffer 0(240x320x3) | + | *0x48F000-0x4C7400 -- 下屏幕帧缓冲0(240x320x3) |
− | *0x4C7800-0x4FF800 -- bottom screen framebuffer 1(240x320x3) | + | *0x4C7800-0x4FF800 -- 下屏幕帧缓冲1(240x320x3) |