是否可以访问物理地址0? [英] Is it possible to access physical address 0?

查看:128
本文介绍了是否可以访问物理地址0?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在C/C ++中,不允许访问地址0处的数据.

In C/C++, it is not allowed to access data at address 0.

但是,物理内存的编号是从0开始的.在DOS时代,中断向量表位于物理地址0.第一个中断向量是被零除异常的处理程序.

However, the physical memory are numbered from 0. And, in DOS era, the interrupt vector table was located at physical address 0. The first interrupt vector was the handler of the division-by-zero exception.

我的问题是:

在什么情况下可以访问物理地址0?

Under what cases is it allowed to access physical address 0?

推荐答案

要访问物理地址零,取决于您正在使用的平台. 该语言对底层寻址模型一无所知,它取决于操作系统.

To access physical address zero, it depends on which platform you are talking. The language has no idea on the underlying addressing model, it depends on the OS.

  • 在裸机环境中,如果启用了分页,则可以完全控制页表;如果未启用分页,则仅取消对零的引用.
  • 在某些Unix和Linux版本上,您执行mmap,也许还打开/dev/mem以获取逻辑地址非零但物理地址为零的非空指针,它可能需要一些访问权限.
  • 我不确定在Windows上.
  • On bare metal environment, you have total control on the page table if paging is enabled, or just de-reference zero if paging is not enabled.
  • On some Unix and Linux variation, you do mmap and perhaps also open /dev/mem to get a non-null pointer with logical address non-zero but physical address zero, it may require some access rights.
  • I'm not sure on Windows.

PS.其他答案似乎使语言级别的指针和物理地址混乱.

PS. Other answers seems make a confusion on language level pointer and physical address.

这篇关于是否可以访问物理地址0?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆