顯示具有 windows 標籤的文章。 顯示所有文章
顯示具有 windows 標籤的文章。 顯示所有文章

2011年7月11日 星期一

[轉]MFC 學習筆記,Invalidate()、RedrawWindow()、UpdateWindow()的差異

出處:http://zhirong.blogspot.com/2009/06/mfc-invalidateredrawwindowupdatewindow.html

 

Invalidate()是強制系統進行重繪,但是不一定就馬上進行重繪。因為Invalidate()只是通知系統,此 時的視窗已經變為無效。強制系統調用WM_PAINT,而這個消息只是Post(寄送)就是將該消息放入訊息佇列。當執行到WM_PAINT消息時才會對 視窗進行重繪。
  UpdateWindow只向表單發送WM_PAINT消息,在發送之前判斷GetUpdateRect(hWnd,NULL,TRUE)看有無可繪製的 用戶端區域,如果沒有,則不發送WM_PAINT。發送即不經過訊息佇列,直接發送到對應視窗,因此此函數可以立即更新視窗。
  RedrawWindow()則是具有Invalidate()和UpdateWindow()的雙特性。聲明視窗的狀態為無效,並立即更新視窗,立即調用WM_PAINT消息處理。

 

2010年8月4日 星期三

Bib in WinCE

CE用*.bib來决定(reloade?) memory layout。
一般的project中會包含兩個 image : bootloader , OS,所以Project中會有 boot.bib和config.bib。
bib文件是用来指导WinCE的编译系统产生可执行二进制文件的,其中使用的地址都是虚拟地址。

必须在Config.bib中设置ROMSIZE参数。
如ROMSIZE=02000000,设置NK.NB0的大小为32M,若Image的大小超过32M,则还会产生NK.NB1,NK.NB2…


RAMIMAGE - 所有Kernel, conpoment都會被放置在這個區域。(大概就是code,const region?)
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 - Kernel 會利用這部份的區域作為application或kernel自己需要的RAM 空間(data,stack ?)
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 - Kernel 不會使用這部份區域。programmer可以用hard-coded對此 區域位址存取。
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 - 這是一個option,當設定ON時,builder會把RAMIMAGE和RAM合
併成一個region
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.






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.



2010年5月27日 星期四

[轉]nk.bin和nk.nb0文件格式分析

作者:wogoyixikexie@gliet

借用别人的解释:
这里提到的bin是一种二进制镜像格式,以片断(section)为单位组织数据,每个片断都包括一个头,头里指定了起始地址,长度,校验值。 Platform Builder调用工具将WINCE内核所有文件以bin格式合并成一个文件,默认文件名为nk.bin。BootLoader又以同样的格式将 nk.bin分解成多个文件放到RAM中。可以在命令行中键入“viewbin nk.bin”来查看bin文件中具体包括了哪些内容。键入Cvrtbin命令转换.bin格式文件为.sre格式或者.abx格式。
nb0格式是原始的二进制镜像,它不包括头,一般情况下将内核下载到设备的RAM中运行都采用nb0格式。要生成nbx格式的文件,需要在相关.bib文 件中确定如下值:ROMSTART、ROMWIDTH、ROMSIZE

那么nk.bin是如何生成的?

Romimage.exe is a locator application that creates Windows CE binary image (.bin) files, usually limited to a single file called Nk.bin. This means that Romimage

  • Reads Ce.bib to determine which %_FLATRELEASEDIR% binaries and files to include in the run-time image.
  • Assigns physical memory addresses to these binaries and files. (这部是如何实现的?)
  • Creates the run-time image Nk.bin.

For more information about Ce.bib, see Make Binary Image Tool.

最近想搞multi bin后来发现我的bootloader是优龙的,不支持binfs分区格式化, 我想把eboot下的代码移植过来,应该可以的。

但是我对则个binfs有点疑惑。按照道理说,binfs是针对nk.bin的,但是我们下载的时候却是nk.nb0,有些人下载nk.bin,但是下载 完还是要解压成nk.nb0的。
我想问,binfs是怎么和nk.nb0联系起来的?
==============================来看看bin文件的格式=========================

一个bin 文件在存储上是按下面的结构存储的

组成:标记(7)+Image开始地址(1)+Image长度(1)
记录0地址+记录0长+记录0校验和+记录0内容(文件内容)
记录1地址+记录1长+记录1校验和+记录1内容(文件内容)
......
最后一条记录是表示结束,Start = 0x00000000, Length = 0x8C072C3C是StartUp地址, Chksum = 0x00000000

bin 文件的头部(不包括记录)可以用下面的结构表示
struct BinFile{
BYTE signature[7]; // = { ''B'', ''0'', ''0'', ''0'', ''F'', ''F'', ''\a'' }
DWORD ImageStart
DWORD ImageLength
};


一般xipkernel.bin,nk.bin 都符合正常bin文件格式,包含记录开始0,1,2 记录为特殊记录,2做为cece的标记,其后4byte表示 TOC地址(指向ROMHDR结构的数据),3记录开始都是文件记录,
———但是,我们实际用到却是nk.nb0文件,这个文件才是和文件系统帮顶起来的。我等下要找出他的格式来。先去吃午饭。

再借别人的解释

首先,NK.BIN中的内容是被压缩过的,NK.NB0中的内容是没有压缩的。 两者大小的区别是因为在生成过程中BIN会将你设定的后面的NULL自动去掉,而NB0就不会。

现在来用微软自带工具来看看这两个文件的格式到底有什么不同。

这幅图结合上面的解释可以知道,这个NK.bin文件的标志是BOOOFF,nk.nb0是没有这个标志的,要知道具体的信息,还是看MSDN好。

At the end of the boot loader development process described in the topic How to Develop a Boot Loader, you will have two different binary images for the boot loader: a .bin file and an .nb0 file. The Microsoft Windows® CE binary image data format (.bin) file is the most common format for Windows CE binary images. It is a binary file that consists of a number of individual records with associated per-record bookkeeping data. The format is convenient for minimizing the amount of data to be downloaded to the target device by removing the need to pad between records. For more information about the .bin file format, see Windows CE Binary Image Data Format (.bin).

The .nb0 file format is a raw binary image of the boot loader. The image is as it appears in the memory on the target device and does not contain the header information that the .bin file includes. The .nb0 file is typically larger than the .bin file. The .nb0 file is useful for placing the initial boot loader image on the target device. This is usually done with a built-in monitor program provided by the board manufacturer. You can also place the initial boot loader image on the target device through a JTAG connection using a JTAG probe. Once the .nb0 image is stored on the device, it should be able to download and update itself using the .bin file format from then on.

我使用的是ADS开发的bootloader,这个bin文件不存在什么段的问题吧,应该和微软不一样的,全局变量的问题在哪里呢?但是现在造成偶 尔不能启动是什么原因呢?最后发现又回到了原点。看来ADS下的bin文件格式也要搞清楚才行哦。