免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2464 | 回复: 5
打印 上一主题 下一主题

<<Professional Linux Kernel Architecture>> p170 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-12-29 17:53 |只看该作者 |倒序浏览



The figure shows the first megabytes of physical memory — how much is exactly required depends on
how big the kernel binary is. The first 4,096 KiB — the first page frame — are omitted because they are
oftenreservedfortheBIOS.Thenext640KiBwouldbeusableinprinciple,butareagainnotusedfor
kernel loading. The reason is that this area is immediately followed by an area reserved for the system
into which various ROM ranges are mapped (typically the system BIOS and the graphic card ROM). It
is not possible to write to these areas. However, the kernel should always be loaded into a contiguous
memory range, and this would be possible only for kernels smaller than 640 KiB if the start address of
RAM memory were used as the start position for the kernel image.

请教:0x9e800地址是怎么计算出来的,4k+640k不等于这个地址?

论坛徽章:
0
2 [报告]
发表于 2011-12-29 18:00 |只看该作者


中文版

论坛徽章:
1
拜羊年徽章
日期:2015-03-03 16:15:43
3 [报告]
发表于 2011-12-30 03:05 |只看该作者
本帖最后由 linuxfellow 于 2011-12-30 03:11 编辑

我想应该这么来理解:
如果内核被下载到0x100000的位置,在内核之前,系统要保留大约390K的memeory用于各种ROM映射。0x100000-390K=0x9e800. 0x9e800--0x100000为系统保留,不能用。从0x1000--09xe800 =630K,原则上可用, 但太小,可能装不下kernel. 这些数据可能是从作者的系统里得到的,只是用于理解系统memory layout.
刚好有这本书,英文的。老外真能写。这本书1000页;ULK3 800页,memory management 800页,读起来头疼。

论坛徽章:
2
CU十二周年纪念徽章
日期:2013-10-24 15:41:34处女座
日期:2013-12-27 22:22:41
4 [报告]
发表于 2011-12-30 09:33 |只看该作者
不知道这个图是作者参照什么BIOS画出来的。我印象中640K(0xA000)这个地址开始就是显存了,没有额外除开第一个4K;临近1M的一段内存被映射到BIOS。光640K就到0xA0000了,0x9e800还倒退了几6K,何况最开始还空了4K,不明白是什么意思。总之似乎是想解释为什么x86上内核会跳过第1M物理内存。

PS1:中文版图下标注错了,尼玛。

PS2:我倒是在上海图书馆见过这本书的英文版,但市面上似乎没买的,不知LS在哪搞的。如果买得到,我可能会买一本。

论坛徽章:
0
5 [报告]
发表于 2011-12-30 09:59 |只看该作者
ulk3:

A page contained in a reserved page frame can never be dynamically assigned or swapped to disk.

As a general rule, the Linux kernel is installed in RAM starting from the physical address 0x00100000 i.e., from the second megabyte. The total number of page frames required depends on how the kernel is configured. A typical configuration yields a kernel that can be loaded in less than 3 MB of RAM.

Why isn't the kernel loaded starting with the first available megabyte of RAM? Well, the PC
architecture has several peculiarities that must be taken into account. For example:


     Page frame 0 is used by BIOS to store the system hardware configuration detected during the Power-On Self-Test(POST); the BIOS of many laptops, moreover, writes data on this page frame even after the system is initialized.
     
    Physical addresses ranging from 0x000a0000 to 0x000fffff are usually reserved to BIOS
routines and to map the internal memory of ISA graphics cards. This area is the well-known
hole from 640 KB to 1 MB in all IBM-compatible PCs: the physical addresses exist but they are reserved, and the corresponding page frames cannot be used by the operating system.

     Additional page frames within the first megabyte may be reserved by specific computer
models. For example, the IBM ThinkPad maps the 0xa0 page frame into the 0x9f one.

In the early stage of the boot sequence (see Appendix A), the kernel queries the BIOS and learns the size of the physical memory. In recent computers, the kernel also invokes a BIOS procedure to build a list of physical address ranges and their corresponding memory types.

Later, the kernel executes the machine_specific_memory_setup( ) function, which builds the physical addresses map (see Table 2-9 for an example). Of course, the kernel builds this table on the basis of the BIOS list, if this is available; otherwise the kernel builds the table following the conservative default setup: all page frames with numbers from 0x9f (LOWMEMSIZE( )) to 0x100 (HIGH_MEMORY) are marked as reserved.



Figure 2-13. The first 768 page frames (3 MB) in Linux 2.6




ulk3 这个地方地址是0x000a0000

请问一下linuxfellow,memory management是指哪一本书?

论坛徽章:
0
6 [报告]
发表于 2011-12-30 11:31 |只看该作者
p139




Linux version 2.6.23.1-49.fc8 (kojibuilder@xenbuilder4.fedora.phx.redhat.com) (gcc ver
sion 4.1.2 20070925 (Red Hat 4.1.2-33)) #1 SMP Thu Nov 8 21:41:26 EST 2007
BIOS-provided physical RAM map:
BIOS-e820: 0000000000000000 - 000000000009fc00 (usable)
BIOS-e820: 000000000009fc00 - 00000000000a0000 (reserved)
BIOS-e820: 00000000000f0000 - 0000000000100000 (reserved)
BIOS-e820: 0000000000100000 - 000000003f7f0000 (usable)
BIOS-e820: 000000003f7f0000 - 000000003f7f3000 (ACPI NVS)
BIOS-e820: 000000003f7f3000 - 000000003f800000 (ACPI data)
BIOS-e820: 00000000fec00000 - 0000000100000000 (reserved)

[    0.000000] Linux version 2.6.35.6-45.fc14.i686 (mockbuild@x86-16.phx2.fedoraproject.org) (gcc version 4.5.1 20100924 (Red Hat 4.5.1-4) (GCC) ) #1 SMP Mon Oct 18 23:56:17 UTC 2010
[    0.000000] BIOS-provided physical RAM map:
[    0.000000]  BIOS-e820: 0000000000000000 - 0000000000098c00 (usable)
[    0.000000]  BIOS-e820: 0000000000098c00 - 00000000000a0000 (reserved)
[    0.000000]  BIOS-e820: 00000000000f0000 - 0000000000100000 (reserved)
[    0.000000]  BIOS-e820: 0000000000100000 - 000000003f800000 (usable)
[    0.000000]  BIOS-e820: 00000000e0000000 - 00000000f0000000 (reserved)
[    0.000000]  BIOS-e820: 00000000fec00000 - 0000000100000000 (reserved)

[    0.000000] Linux version 3.1.5-1.fc16.i686 (mockbuild@x86-10.phx2.fedoraproject.org) (gcc version 4.6.2 20111027 (Red Hat 4.6.2-1) (GCC) ) #1 SMP Fri Dec 9 18:11:07 UTC 2011
[    0.000000] Disabled fast string operations
[    0.000000] BIOS-provided physical RAM map:
[    0.000000]  BIOS-e820: 0000000000000000 - 000000000009f800 (usable)
[    0.000000]  BIOS-e820: 000000000009f800 - 00000000000a0000 (reserved)
[    0.000000]  BIOS-e820: 00000000000ca000 - 00000000000cc000 (reserved)
[    0.000000]  BIOS-e820: 00000000000dc000 - 00000000000e4000 (reserved)
[    0.000000]  BIOS-e820: 00000000000e8000 - 0000000000100000 (reserved)
[    0.000000]  BIOS-e820: 0000000000100000 - 0000000015af0000 (usable)
[    0.000000]  BIOS-e820: 0000000015af0000 - 0000000015aff000 (ACPI data)
[    0.000000]  BIOS-e820: 0000000015aff000 - 0000000015b00000 (ACPI NVS)
[    0.000000]  BIOS-e820: 0000000015b00000 - 0000000015c00000 (usable)
[    0.000000]  BIOS-e820: 00000000e0000000 - 00000000f0000000 (reserved)
[    0.000000]  BIOS-e820: 00000000fec00000 - 00000000fec10000 (reserved)
[    0.000000]  BIOS-e820: 00000000fee00000 - 00000000fee01000 (reserved)
[    0.000000]  BIOS-e820: 00000000fffe0000 - 0000000100000000 (reserved)


0x100000之前的空间是有BIOS决定的,linux kernel不会去动这个空间的值。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP