动态内存分配模块接口¶
axalloc 全局内存分配器模块¶
GlobalAllocator 全局内存分配器特性¶
1. new¶
1 2 3 4 5 6 7 | |
GlobalAllocator 实例,初始化字节分配器 balloc 和页分配器 palloc。
- 用例:在初始化全局分配器时,可能会使用该接口创建一个新的分配器实例。
2. name¶
1 2 3 4 5 6 7 8 9 10 11 | |
3. init¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | |
4. add_memory¶
1 2 3 | |
5. alloc¶
1 2 3 4 5 6 7 | |
Layout 分配内存,返回一个指向分配内存的指针。如果分配失败,调用 handle_alloc_error 处理错误。
- 用例:在需要动态分配内存的地方调用该接口,例如在 arceos/modules/axdma/src/dma.rs 中,DmaAllocator 的 alloc_coherent_bytes 方法可能会间接使用该接口进行内存分配。
6. alloc_pages¶
1 2 3 | |
7. dealloc¶
1 2 3 | |
Layout。
- 用例:在不再需要使用分配的内存时调用该接口。
8. dealloc_pages¶
1 2 3 4 | |
9. used_bytes¶
1 2 3 4 | |
10. used_pages¶
1 2 3 4 | |
11. vailable_bytes¶
1 2 3 4 | |
GlobalPage 全局页面特性¶
1. alloc¶
1 | |
- 功能:分配指定数量和对齐要求的页面,返回分配的起始虚拟地址。
- 用例:在需要分配页面的地方调用该接口,例如在
arceos/modules/axhal/src/paging.rs中,alloc_frame函数调用该接口分配单个页面。
2. alloc_zero¶
1 | |
- 功能:分配指定数量和对齐要求的页面,并将其内容清零,返回分配的起始虚拟地址。
3. alloc_contiguous¶
1 | |
- 功能:分配连续的指定数量和对齐要求的页面,返回分配的起始虚拟地址。
4. start_vaddr¶
1 | |
5. start_paddr¶
1 | |
6. size¶
1 | |
7. as_ptr¶
1 | |
- 功能:返回分配的页面的指针。
8. as_mut_ptr¶
1 | |
9. fill¶
1 | |
10. zero¶
1 | |
11. as_slice¶
1 | |
12. as_mut_slice¶
1 | |
接口¶
1. global_allocator¶
1 2 3 | |
2. global_init¶
1 2 3 4 5 6 7 8 | |
axdma 模块¶
DmaAllocator DMA 分配器特性¶
1 alloc_coherent¶
1 | |
Layout 分配连贯内存,并返回一个 DMAInfo 结构体,包含 CPU 地址和总线地址。
2 dealloc_coherent¶
1 | |
alloc_coherent 分配的连贯内存。
3 phys_to_bus¶
1 2 3 | |
4 virt_to_bus¶
1 2 3 4 | |
phys_to_bus 方法将物理地址转换为总线地址。
评论
作者: