Understanding Memory Sections in config.bib, boot.bib, and OEMAddressTable in Windows CE 5.0 and 6.0

本文深入讲解了Windows CE中.bib文件的作用与配置方法,重点介绍了OEMAddressTable、config.bib及boot.bib文件如何定义内存布局,并通过实例展示了如何确保内存在启动加载器与操作系统间的正确分配。
Introduction

Windows CE uses .bib (binary image builder) files to track, among other things, the memory layout of bootloaders as well as OS images.  If you’re writing a new BSP, you’ll definitely need a config.bib file for your OS, and you’ll likely need a boot.bib file for your bootloader.

 

Let’s take a few minutes to understand how .bib files relate to memory usage.  It’s going to be muddy at the beginning, but I promise if you stick with me through the end you’ll be glad that you did.  Well, maybe you won’t be glad but you’ll know more about .bib files.  Let’s get to it!

 

OEMAddressTable

Before we look at the .bib files themselves, it’s important to understand the OEMAddressTable.  This table defines the mappings between physical and virtual addresses.  For MIPS and SH processors, this table is hard coded into the processor.  For x86 and ARM, the mapping is defined in a variable called OEMAddressTable.  Since .bib files operate largely on virtual addresses, we need to remember to reference the OEMAddressTable to address any confusion about what is happening at a particular physical address.

 

The table’s layout is quite simple.  Each line creates a mapping of virtual addresses to physical addresses.  The syntax is: Base virtual address, base physical address, size.  Let’s take an example from the Mainstone BSP:

 

DCD     0x80000000, 0xA0000000,  64     ; MAINSTONEII: SDRAM (64MB).

DCD     0x88000000, 0x5C000000,   1     ; BULVERDE: Internal SRAM (64KB bank 0).

DCD     0x88100000, 0x58000000,   1     ; BULVERDE: Internal memory PM registers.

DCD     0x88200000, 0x4C000000,   1     ; BULVERDE: USB host controller.

 

So in the first line, we are mapping the 64MB of RAM at physical address 0xA0000000 to the virtual address 0x80000000.  Since 64MB = 0x04000000 this means that the physical addresses 0xA000000-0xA4000000 are now mapped to virtual addresses 0x80000000-0x84000000.  Likewise, we’ve mapped the USB host controller which resides at physical addresses 0x4C000000-0x4C100000 to virtual addresses 0x88200000-0x8300000.

 

Inside Windows CE, memory access is virtual by default.  So when we access memory at 0x81005000, we’ll be accessing some physical memory in the Mainstone’s 64MB SDRAM bank.  If we access memory at 0x88201000, we’ll be accessing the USB host controller, physically.  If we access memory at 0x86001000, we’ll get a page fault because this virtual address has no corresponding physical address.

 

Now that we understand the OEMAddressTable, let’s talk about the .bib files.

 

Config.bib – this contains a lot of configuration info for a CE OS image.  The MEMORY section is what we’ll focus on – it defines the memory blueprint for the CE image.  Here are the important terms:

 

RAMIMAGE – This is the virtual address region that the kernel and any other components you select for your image will be placed in.  This can be RAM or linearly addressable flash.  Your config.bib file should have exactly one RAMIMAGE section.  It needs to be virtually contiguous, and it needs to be large enough to hold whatever components you’ve selected.

 

RAM – This is the virtual address region of RAM that the kernel can allocate to applications and RAM-based file systems.  It needs to be virtually contiguous.  (If you need a non-contiguous section, you can allocate another, non-virtually-contiguous section at run-time by implementing the OEMGetExtensionDRAM function, but that’s outside our scope)

 

RESERVED – These are virtual address regions that are set aside – the kernel won’t allocate memory in these addresses and components won’t be placed in these addresses.

 

AUTOSIZE - In the CONFIG section, we have the AUTOSIZE=ON (or OFF) variable.  If this variable is on, it will treat the RAMIMAGE and RAM regions as a single region, allocating just enough space to hold all of the components to the RAMIMAGE section and making the rest of the space available as RAM.  This is a pretty convenient and easy way to make sure you’re getting maximal use out of your RAM.  One thing autosize won’t do is interfere with reserved or unallocated regions.

 

Eboot.bib (sometimes known as boot.bib) – this works identically to config.bib, except we’re building a bootloader image as opposed to one with a full kernel.  All of the terminology is exactly the same.  The only difference is, in the case where we’re not using an MMU in the bootloader (CEPC is an example of these), the addresses will be physical as opposed to virtual.  Otherwise, the layout is identical.

 

Bringing it together

In almost all cases, the bootloader and OS use the same OEMAddressTable.  Thus, they have the same virtual address space.

 

This is especially useful when it comes to RESERVED regions.  Since nothing will be allocated or placed in these addresses, only components that refer directly to the address will have access.  That means we can use these regions for special buffers (say, DMA) or passing arguments passed in from the bootloader to the OS.  It also means that, if you want, you can leave the bootloader in RAM.

 

Keep in mind that while RESERVED means that we won’t allocate/place components in those virtual addresses, by default if an area isn’t specified in a .bib file then we won’t allocate/place in it.  This means RESERVED is really more of a comment then anything.  However, it is useful in our .bib files because it helps us identify the location of special buffers and arguments so that we know not to overwrite them in other modules.

 

An Example

Let’s take a look at a simplified example in the CEPC BSP:

Here’s our OEMAddressTable (platform/common/src/x86/common/startup/startup.asm):

_OEMAddressTable:

        dd  80000000h,     0,      04000000h

This means that we’re mapping physical addresses 0x00000000-0x04000000 to virtual addresses 0x80000000-0x84000000.  That’s 64MB of RAM.

 

Here’s our boot.bib (platform/CEPC/src/bootloader/eboot/boot.bib):

MEMORY

;   Name     Start     Size      Type

;   -------  --------  --------  ----

    EBOOT    00130000  00020000  RAMIMAGE

    RAM      00150000  00070000  RAM

    ETHDMA   00200000  00020000  RESERVED

 

Remember the CEPC bootloader uses physical addresses.  So in virtual address terms, our bootloader code is living at 0x80130000-0x80150000, with RAM available from 0x80150000-0x801C0000.  We’re reserving a buffer for our Ethernet card from 0x80200000-0x80220000.

 

And a condensed version of config.bib (platform/CEPC/files/config.bib):

 

MEMORY

;   Name     Start     Size      Type

;   -------  --------  --------  ----

; 64 MB of RAM (note: AUTOSIZE will adjust boundary)

    NK       80220000  009E0000  RAMIMAGE

    RAM      80C00000  03400000  RAM

    DMA      80100000  00030000  RESERVED   ; Native DMA reserved.

    BOOTARGS 801FFF00  00000100  RESERVED   ; Boot arguments

    EDBG_DMA 80200000  00020000  RESERVED   ; EDBG DMA buffer

 

 

There are several interesting things going on here:

 

First, our OS image (NK) starts at 0x80220000, and RAM resides directly above it.  That means we’re not allowing any components or allocation to write below 0x80220000, and thus our bootloader code is protected.

 

Second, note that we have also reserved some regions.  The EDBG_DMA corresponds to the same addresses that the bootloader reserved.  This way we can make a smooth transition from bootloader to kernel without worrying about the contents of this memory being tampered with. 

 

Another region has been reserved from 0x80100000-0x80130000.  This is very close to the start of our bootloader.  If we reserved even a byte more, we would not expect our bootloader to continue to be executable after we boot the OS.  However, since the bootloader’s address space isn’t referenced by any region in config.bib, we know that it will remain untouched by the OS.  This way we can jump back to the bootloader code during a warm reset, if desired.

 

We’re not required to keep our bootloader in memory, though.  We could easily place the bootloader (in boot.bib) at the end of the RAM space (in config.bib).  This way after the image was successfully downloaded we could allocate memory over the top of the bootloader and make full use of all of our system RAM.  What you don’t want to do is intersect the bootloader with the RAMIMAGE part of config.bib – this means you’ll overwrite the code you’re running to download, during download!

 

Finally, notice we have a special reserved region called “boot arguments”.  If we at the CEPC’s bootloader we will see that it writes explicitly to the (physical) 0x001FFF00-0x002000000.  You’ll also notice this isn’t used anywhere in the boot.bib layout.  That means we can be assured it will be untouched (unless, of course, something else in the bootloader writes explicitly to that address range).

 

This is how we pass arguments from the bootloader to the OS – the OS can read directly from 0x801FFF00 and be assured that the kernel won’t tamper with it because it is RESERVED.  Technically, we could have indicated that area as RESERVED in the bootloader as well.

 

Hopefully this has given you some insight into .bib memory layouts.

 

update: In response to a comment generated by this entry I'd like to point out that the virtual addresses used in both OEMAddressTable and config.bib must fall between 0x80000000 and 0xA0000000 - the kernel virtual memory space reserved for cachable access.

<think>好的,我现在需要帮助用户解决关于Mybib.bib文件提交时缺少关联的Mybib.tex文件的问题。首先,我需要理解用户的具体情况。用户提到在提交时遇到了错误,提示Mybib.bib文件缺少对应的Mybib.tex文件。这可能发生在使用LaTeX进行文档编写,特别是涉及参考文献管理的时候。 首先,我应该回忆一下LaTeX中.bib.tex文件的关系。通常,.bib文件是参考文献数据库,里面存储了各个条目的引用信息。而.tex文件是主文档,其中通过\bibliography{Mybib}命令来引用.bib文件。当编译LaTeX文档时,需要生成.bbl文件,这个过程可能用到BibTeX或Biber工具。如果系统提示缺少关联的.tex文件,可能是因为编译过程中某些步骤没有正确执行,或者文件路径、文件名不一致。 接下来,我需要考虑可能的原因和解决方案。常见的情况包括: 1. **文件名不匹配**:用户可能在.tex文件中使用了错误的名称来引用.bib文件。例如,主文档中\bibliography{Mybib}但实际文件名是mybib.bib(大小写不一致),或者拼写错误。 2. **编译步骤缺失**:使用BibTeX或Biber处理参考文献时,需要执行特定的编译顺序,如LaTeX -> BibTeX -> LaTeX -> LaTeX。如果用户跳过了BibTeX步骤,可能导致系统找不到关联的文件。 3. **文件路径问题**:如果.bib文件和.tex文件不在同一目录下,或者编译时的工作目录不正确,系统可能无法找到对应的文件。 4. **未正确调用参考文献命令**:用户可能在.tex文件中没有正确使用\bibliographystyle和\bibliography命令,导致无法关联.bib文件。 根据这些可能性,我需要逐步指导用户检查这些方面。首先确认文件名是否正确,包括大小写和扩展名。然后检查编译流程是否正确,特别是是否运行了BibTeX。接着验证文件路径是否正确,确保所有相关文件都在同一目录下。最后,检查.tex文件中参考文献部分的命令是否正确。 此外,可能还需要考虑用户使用的编辑器和编译工具,不同的工具可能有不同的配置要求。例如,在Overleaf、TeXShop或本地安装的TeX发行版中,处理方式可能略有不同。需要提醒用户根据他们的具体环境进行调整。 最后,建议用户提供更多细节,如具体的错误信息、文件结构以及使用的编译命令,以便更准确地诊断问题。</think>### Mybib.bib文件缺少关联Mybib.tex文件的解决方案 当遇到`Mybib.bib`文件提交时提示缺少关联的`Mybib.tex`文件,通常是由于以下原因及解决方法: --- #### **1. 检查文件名与路径** - **文件名一致性**:确保`.tex`主文件中通过`\bibliography{Mybib}`调用的文件名与`.bib`文件**完全一致**(包括大小写)。例如: ```latex \bibliographystyle{plain} \bibliography{Mybib} % 对应文件应为 Mybib.bib ``` - **文件路径**:将`.bib`文件与`.tex`主文件放在**同一目录下**。若使用子目录(如`/references`),需在编译命令中指定路径[^1]。 --- #### **2. 确认编译流程** 正确编译含参考文献的LaTeX文档需按顺序执行以下步骤(以`pdflatex`为例): 1. 首次编译`.tex`文件:生成`.aux`引用标记 ```bash pdflatex main.tex ``` 2. 运行BibTeX处理参考文献:生成`.bbl`文件 ```bash bibtex main.aux ``` 3. 再次编译`.tex`文件:插入参考文献引用 ```bash pdflatex main.tex ``` 4. 最后编译:解决交叉引用 ```bash pdflatex main.tex ``` 若跳过BibTeX步骤,系统将无法关联`.bib`与`.tex`文件[^1]。 --- #### **3. 验证LaTeX代码** 在`.tex`文件中需包含以下关键命令: ```latex % 参考文献样式(如APA、IEEE等) \bibliographystyle{plainnat} % 指定.bib文件(无扩展名) \bibliography{Mybib} ``` 若未添加`\bibliographystyle`,部分编译工具会报错。 --- #### **4. 检查工具链配置** - **编辑器设置**:在TeX编辑器(如TeXShop、Overleaf)中确认BibTeX/Biber引擎已启用。 - **命令行工具**:若手动编译,确保BibTeX已安装且环境变量配置正确。 --- #### **5. 示例文件结构** ``` project/ ├── main.tex # 主文档 ├── Mybib.bib # 参考文献数据库 └── figures/ # 图片目录(可选) ``` ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值