在启动时分配内存
我需要在启动时分配一些内存。我需要它的物理地址,而不是虚拟地址。另外,我不希望它来自 DMA 区域,这不是我的目的。
我尝试了 alloc_bootmem()、alloc_bootmem_pages() 但它们返回虚拟地址。 我还查看了 alloc_low_page()...并没有按预期工作。
问题是,我需要 RAM 中的某种保留区域.. 不必由内核映射.. 我将尝试自己管理该区域。我需要每次启动时的物理区域都相同。
我还尝试在 init/main.c : start_kernel() 中分配一些内存,但这也不起作用。
现在有点困惑要在哪里/寻找什么。
我更喜欢将答案作为指向正确方向的指针,而不是告诉 do_it_here_in_this_way 。
谢谢 :)
I need some memory allocated during boot time. and I need its physical address, not the virtual one. Also, I don't want it from DMA region, that's not my purpose.
I tried alloc_bootmem(), alloc_bootmem_pages() but they return virtual address.
I also looked at alloc_low_page()... didn't quite work as expected.
Thing is, I need some sort of reserved area in RAM.. that doesn't have to be mapped by kernel.. I'll be trying to manage that area myself. I need physical area to be same on every boot.
I also tried allocating some memory in init/main.c : start_kernel() but that too did not work.
Kind of stuck now as where/what to look for.
I'd prefer answer as a pointer to right direction rather than telling do_it_here_in_this_way .
Thanks :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
AFAIK 购买 bootmem 分配器返回的内存是连续的物理内存,因此您只需调用 alloc_bootmem() 并使用 virt_to_phys 即可获取物理地址。
不能保证每次启动时都会获得相同的地址,但只要您不更改内核,分配总是会以相同的顺序(和大小)发生,以便您期望获得什么。
AFAIK the memory returned buy the bootmem allocator is contigious is physical memory so you can just call alloc_bootmem() and use virt_to_phys to get the physical address.
There is no guarantee to get the same address on every boot, but so long as you wont change the kernel the allocation will always happen in the same order (and size) so that what is you are expected to get.