<?xml version="1.0" encoding="gb2312"?>
<rss version="2.0">
<channel>
<title><![CDATA[学习笔记]]></title>
        <image>
        <title>http://hi.baidu.com</title>
        <link>http://hi.baidu.com</link>
        <url>http://img.baidu.com/img/logo-hi.gif</url>
        </image>
<description><![CDATA[just for fun]]></description>
<link>http://hi.baidu.com/%5Fpsoc</link>
<language>zh-cn</language>
<generator>www.baidu.com</generator>
<ttl>5</ttl>


<item>
        <title><![CDATA[ecos 一]]></title>
        <link><![CDATA[http://hi.baidu.com/%5Fpsoc/blog/item/b01a40b30bc232aed8335a5e.html]]></link>
        <description><![CDATA[
		
		<p>终于摆脱了 redhat9.0.&nbsp;&nbsp;  刚刚搭建了个 cygwin+GNUARM 的环境, 以后都在这下面了, 不用vmware 了</p>
<p>恩, 做个记录,</p> 
		
		<br/><b>类别：</b><a href="http://hi.baidu.com/%5Fpsoc/blog/category/Ecos">Ecos</a>&nbsp;<a href="http://hi.baidu.com/%5Fpsoc/blog/item/b01a40b30bc232aed8335a5e.html#comment">查看评论</a>]]></description>
        <pubDate>2009年07月23日 星期四  17:08</pubDate>
        <category><![CDATA[Ecos]]></category>
        <author><![CDATA[microshark]]></author>
		<guid>http://hi.baidu.com/%5Fpsoc/blog/item/b01a40b30bc232aed8335a5e.html</guid>
</item>

<item>
        <title><![CDATA[keil, startup]]></title>
        <link><![CDATA[http://hi.baidu.com/%5Fpsoc/blog/item/e6b78cce291c920693457e56.html]]></link>
        <description><![CDATA[
		
		<p><font color="#0000ff">Many new microcontrollers have been developed in the past few years. Some of these devices require special startup code in order to properly initialize all on-chip peripherals and memory.</font></p>
<font color="#0000ff">
<h3>QUESTION</h3>
<p>I've compiled and linked my 8051 program. I noticed that there is some startup code and variable initialization code that's included in my program. Where did it come from?</p>
<h3>ANSWER</h3>
<p>The startup code is stored in the STARTUP.A51 file (found in the \C51\LIB directory).</p>
<p>The initialization code is stored in the INIT.A51 file (also found in the \C51\LIB directory).</p>
<p>These 2 files are executed before your main C function. Immediately after RESET, STARTUP is executed. STARTUP calls INIT which initializes your programs global variables. INIT then calls the main C function.</p>
<p>These 2 files are assembled and included in the Keil C library. If you do not copy and modify the STARTUP and INIT files and include them in your project, the linker automatically includes the default ones from the library</p>
<h3>QUESTION</h3>
<p>I'm creating a project that is made up of C and assembly files. Do I need to use the STARTUP.A51 file that you provide, or can I use my own version?</p>
<h3>ANSWER</h3>
<p>We strongly urge you to use the STARTUP.A51 file that we provide as the basis for your startup routines. The Keil startup code performs the following operations:</p>
<ul>
    <li>Clears DATA and optionally PDATA and XDATA memory,</li>
    <li>Sets up the reentrant stacks (if necessary)),</li>
    <li>Initializes C Global Variables (see INIT.A51),</li>
    <li>Sets the Stack Pointer (SP),</li>
    <li>Jumps to your MAIN C function.</li>
</ul>
<p>Your startup code must do all of these. If it doesn't, you may encounter run-time problems that are difficult to debug and diagnose.</p>
<p>Note that if you do include some form of a startup file, Keil will automatically include a start up file that is in the Keil library.</p>
<p> </p>
<h3>SYMPTOMS</h3>
<p><font color="#ff0000">Some users have reported problems using the on-chip SRAM of the Dallas DS89C420, DS89C430, or DS89C450 devices. The memory appears to be disabled.</font></p>
<h3>CAUSE</h3>
<p>The on-chip SRAM is disabled after CPU reset and needs to be enabled. By default the devices accesses only external XDATA memory.</p>
<h3>RESOLUTION</h3>
<p>The on-chip XDATA SRAM of the Dallas devices behaves like off-chip XDATA. So, in your program, variables that are located in XDATA will be stored in the on-chip SRAM.</p>
<p>There are several steps you must follow to use the on-chip XRAM.</p>
<ol>
    <li>&micro;Vision2 must know to place variables in the on-chip SRAM (XRAM) memory. To do that, in &micro;Vision2 you must:
    <ul>
        <li>Select the correct device for your project (from the device database)</li>
        <li>Enable <strong>Use on-chip ROM</strong> and <strong>Use on-chip XRAM</strong> from the Project-Options for Target-Target dialog.</li>
    </ul>
    </li>
    <li>The on-chip SRAM must be enabled before you use it. You must do this in the startup code (so that the XRAM is on when global variables are initialized).</li>
</ol>
<p>Add <strong>STARTUP.A51</strong> to your project. To do this, copy the file \C51\LIB\STARTUP.A51 to your project folder and add it to the project. Then, in the STARTUP.A51 file, enable the on-chip SRAM by setting bit 0 (DME0) in the PMR SFR. The following lines in STARTUP.A51 will do this:</p>
<pre>RSEG ?C_C51STARTUP

PMR DATA  0C4H                 ; add SFR definition

STARTUP1:
                               ; enable on-chip xdata RAM
          ORL PMR,#1           ; PMR.DME0 = 1 (set to 1 to enable SRAM)</pre>
<pre> </pre>
<pre><h3>SYMPTOMS</h3><p>Some users have reported problems using the on-chip XRAM of the Philips 80C66x and 80C51Rx devices. The memory appears to be disabled.</p><h3>CAUSE</h3><p>We have observed that by default, the Philips devices do not enable on-chip XRAM. This is contrary to the datasheets which, in several places, contain incorrect reset values for the AUXR register.</p><h3>RESOLUTION</h3><p>The on-chip XDATA RAM (XRAM) of the Philips 80C66x and 80C51Rx behaves like off-chip XDATA. So, in your program, variables that are located in XDATA will be stored in the on-chip XRAM.</p><p>There are several steps you must follow to use the on-chip XRAM.</p><ol><li>&micro;Vision2 must know to place variables in the on-chip XRAM memory. To do that, in &micro;Vision2 you must: <ul><li>Select the correct device for your project (from the device database)</li><li>Enable <strong>Use on-chip ROM</strong> and <strong>Use on-chip XRAM</strong> from the Project-Options for Target-Target dialog.</li></ul></li><li>The on-chip XRAM must be enabled before you use it. You must do this in the startup code (so that the XRAM is on when global variables are initialized).</li></ol><p>Add <strong>STARTUP.A51</strong> to your project. To do this, copy the file \C51\LIB\STARTUP.A51 to your project folder and add it to the project. Then, in the STARTUP.A51 file, enable the on-chip XRAM by clearing bit 1 in the AUXR1 SFR. The following lines in STARTUP.A51 will do this:</p><pre>RSEG ?C_C51STARTUP

AUXR1 DATA  08EH               ; add SFR definition

STARTUP1:
                               ; enable on-chip xdata RAM
          ANL AUXR1,#NOT 02H   ; AUXR1/Bit 1 (clear to 0 to enable on-chip XRAM)</pre>
</pre>
<pre><h3>QUESTION</h3><p>I'm using a chip with on-chip XDATA memory. I want to use one 256-byte page as PDATA. How do I do that?</p><p>Does the upper address byte come from P2?</p><h3>ANSWER</h3><p>Accessing a 256-byte page (PDATA) of on-chip XDATA is possible and often desirable since PDATA is more efficient than XDATA.</p><h4>When On-chip XDATA is Enabled...</h4><ul><li>Most devices allow PDATA access (MOVX @Rx) to only the first 256 bytes of XDATA (0x0000-0x00FF). On such devices, there is nothing to configure. You don't need to enable the PPAGEENABLE setting in the startup code since the PPAGE is fixed by the chip to 0.</li><li>Some devices have a special SFR that contains the upper address byte to use for PDATA accesses. Devices like the Infineon C517A have an SFR called XPAGE at address 0x91. In the startup code, you must set this SFR to the page number for PDATA. We recommend you use the first available memory page for the PDATA space (0xF8 in the case of the Infineon device).</li></ul><h5>To configure the tools for PDATA access, you must...</h5><ul><li>Copy the startup code to your project directory, modify it for PDATA access, and add it to the project.</li><li>In the startup code, you must set <strong>PPAGEENABLE EQU 1</strong>, <strong>PPAGE EQU 0F8h</strong> and <strong>PPAGE_SFR DATA 091h</strong>. This configuration reflects the Infineon C517A hardware. It will be different depending on the chip you use.</li><li>In the BL51 Linker options, you must specify the starting address for the PDATA memory. For the Infineon C517A device this value is 0xF800. Enter 0xF800 under <strong>Options for Target &mdash; BL51 Locate &mdash; Pdata:</strong></li><li>In the Lx51 Linker options, you must specify the range of PDATA memory. <strong>Options for Target &mdash; LX51 Locate &mdash; User Class:</strong> PDATA(X:0xF800-X:0xF8FF)</li></ul><h4>When On-chip XDATA is Disabled...</h4><p>Most 8051 devices use the value of Port 2 as the upper address byte for PDATA accesses. With such a configuration, the required startup code settings are nearly identical to the above except that the PPAGE SFR must be specified as <strong>PPAGE_SFR DATA 0A0H</strong>.</p></pre>
</font> <a href="http://hi.baidu.com/%5Fpsoc/blog/item/e6b78cce291c920693457e56.html">阅读全文</a>
		
		<br/><b>类别：</b><a href="http://hi.baidu.com/%5Fpsoc/blog/category/c%D1%A7%CF%B0%B1%CA%BC%C7">c学习笔记</a>&nbsp;<a href="http://hi.baidu.com/%5Fpsoc/blog/item/e6b78cce291c920693457e56.html#comment">查看评论</a>]]></description>
        <pubDate>2008年05月21日 星期三  14:33</pubDate>
        <category><![CDATA[c学习笔记]]></category>
        <author><![CDATA[microshark]]></author>
		<guid>http://hi.baidu.com/%5Fpsoc/blog/item/e6b78cce291c920693457e56.html</guid>
</item>

<item>
        <title><![CDATA[$(LD) $(LDFLAGS) head.o -o system &#62; System.map]]></title>
        <link><![CDATA[http://hi.baidu.com/%5Fpsoc/blog/item/d5a6e46443393af5f73654a2.html]]></link>
        <description><![CDATA[
		
		<p><font color="#0000ff">实验环境: FC8, bochs2.1.1 代码linux0.00(改的乱七八糟了~ ~)</font></p>
<p><font color="#0000ff">快要疯...&nbsp;&nbsp;  到PMODEL 下, 刚跳过去, bochs 就出错... 然后自动关闭....</font></p>
<p><font color="#0000ff"><img src="http://img.baidu.com/hi/face/i_f31.gif"><img src="http://img.baidu.com/hi/face/i_f31.gif"></font></p>
<p># &quot;-m elf_i386&quot;: Output 32-bit code for the i386 in elf format. <br>
# &quot;-Ttext 0&quot;: Code should be loaded\aligned at 0. <br>
# &quot;-e startup_32&quot;: startup_32 is the entry point.</p>
<p>&nbsp;&nbsp;  这个 一个人给的解释.....&nbsp;&nbsp;&nbsp;  不明白 哈哈</p>
<p>LDFLAGS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  =-m elf_i386 -Ttext 0 -e startup_32</p>
<p>$(LD) $(LDFLAGS) head.o -o system &gt; System.map</p>
<p>我靠&nbsp;&nbsp;  system.map 是空的.... 日... 跳不到 head...<img src="http://img.baidu.com/hi/face/i_f15.gif"><img src="http://img.baidu.com/hi/face/i_f15.gif"></p>
<p> </p>
<p><font color="#0000ff">今天绝对是比较糟糕的一天,通过 copy 别人的命令 终于在system.map 中写如了数据...</font></p>
<p><font color="#0000ff">但是那参数好多啊, 真的没理解....然后用BOCHS&nbsp;&nbsp;  做调试 虽然在编译的时候没有任何错误</font></p>
<p><font color="#0000ff">但是, 依然不是代码所写的那样. 到OSDEV 上 求解 还被人 BS了一通&nbsp;&nbsp;<img src="http://img.baidu.com/hi/face/i_f31.gif"><img src="http://img.baidu.com/hi/face/i_f34.gif"> ,&nbsp;&nbsp;</font></p>
<p><font color="#0000ff">没办法 自己又开始 胡乱的捣鼓....&nbsp;&nbsp;  无意间 用了下 GDB ...</font></p>
<p><font color="#0000ff">问题也因此而出现了.&quot;XXXXXXsigmal ... segmentation fault&nbsp;&nbsp;  &quot;&nbsp;&nbsp;&nbsp;<img src="http://img.baidu.com/hi/face/i_f31.gif">狂汗</font></p>
<p><font color="#0000ff">&nbsp;&nbsp;&nbsp;  日子好难过, 不过有点欣喜, 以为和庐山面对面了....&nbsp;&nbsp;&nbsp;  </font></p>
<p><font color="#0000ff">事与愿违啊....&nbsp;&nbsp;  原来这是个很 普遍 可以理解为 通用错误.... 我靠&nbsp;&nbsp;  再汗一次&nbsp;&nbsp;<img src="http://img.baidu.com/hi/face/i_f31.gif"></font></p>
<p><font color="#0000ff">于是 又把 之前的 GDT 拿出来 LOOK ,&nbsp;&nbsp;&nbsp;  发现 确实有模糊的地方....</font></p>
<p><font color="#0000ff">日子继续....<img src="http://img.baidu.com/hi/face/i_f27.gif"> 问题依旧.... 我靠...</font></p> <a href="http://hi.baidu.com/%5Fpsoc/blog/item/d5a6e46443393af5f73654a2.html">阅读全文</a>
		
		<br/><b>类别：</b><a href="http://hi.baidu.com/%5Fpsoc/blog/category/linux1%2E0%20%D1%A7%CF%B0%B1%CA%BC%C7">linux1.0 学习笔记</a>&nbsp;<a href="http://hi.baidu.com/%5Fpsoc/blog/item/d5a6e46443393af5f73654a2.html#comment">查看评论</a>]]></description>
        <pubDate>2008年05月04日 星期日  17:34</pubDate>
        <category><![CDATA[linux1.0 学习笔记]]></category>
        <author><![CDATA[microshark]]></author>
		<guid>http://hi.baidu.com/%5Fpsoc/blog/item/d5a6e46443393af5f73654a2.html</guid>
</item>

<item>
        <title><![CDATA[一个简单的 boot]]></title>
        <link><![CDATA[http://hi.baidu.com/%5Fpsoc/blog/item/5cc00810a792fff9c3ce79b4.html]]></link>
        <description><![CDATA[
		
		<p>&nbsp;&nbsp;  <font color="#0000ff">实验 环境 FC8&nbsp;&nbsp;  bochs2.1.1</font></p>
<p><font color="#0000ff">boot.s 文件 代码如下:</font></p>
<p><em>.text<br>
entry _start<br>
_start:<br>
jmpi boot1 ,#0x07c0<br>
boot1:<br>
mov ax,cs<br>
mov ds,ax<br>
mov es,ax<br>
mov ss,ax<br>
print_msg:<br>
mov ah,#0x03<br>
xor bh,bh<br>
int 0x10<br>
mov cx,#29<br>
mov bx,#0x0007<br>
mov bp,#msg<br>
mov ax,#0x1301<br>
int 0x10<br>
jmp print_msg</em></p>
<p><em>msg:<br>
.byte 13,10<br>
.ascii &quot;Aha , i am a boot process!&quot;<br>
.byte 13,10<br>
.org 510<br>
.word 0xAA55</em></p>
<p><font color="#0000ff">makefile 代码如下:</font></p>
<p><em>#dd bs=32 if=boot of=Image skip=1<br>
AS86 =as86 -0 -a<br>
LD86 =ld86 -0</em></p>
<p><em>all:boot<br>
<br>
boot: boot.s<br>
$(AS86) -o boot.o boot.s<br>
$(LD86) -s -o boot boot.o</em></p>
<p><em>disk:boot<br>
<strong><font color="#ff6600">dd bs=32 if=boot of=Image skip=1</font></strong><br>
dd bs=8192 if=boot of=12.img</em></p>
<p><em>clean:<br>
rm -f *.o core<br>
rm -f boot<br>
rm -f 12.img<br>
rm -f Image</em></p>
<p><font color="#0000ff">请注意红色的部分 ^ ^ 死在他 下面一天.......&nbsp;&nbsp;  很感谢赵老师....</font></p>
<p><font color="#0000ff">#******************************************<br>
#***********************************************************************************<br>
# ***********add by the user***************&nbsp;&nbsp;</font></p>
<p><font color="#0000ff"><font size="+0"># file of bochsrc-hd.bxrc <br>
# please pay attention to this <br>
<font color="#ff6600"># just change bootimage-0.11-hd to your own IMG file<br>
#&nbsp;&nbsp;  no more than that</font><br>
#floppya: 1_44=/dev/fd0, status=inserted<br>
#floppya: file=../1.44, status=inserted<br>
#floppya: 1_44=/dev/fd0H1440, status=inserted<br>
#floppya: 1_2=../1_2, status=inserted<br>
#floppya: 1_44=a:, status=inserted&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  # for win32<br>
floppya: 1_44=&quot;12.img&quot;, status=inserted<br>
#bootimage-0.11-hd&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  just change this to your IMG</font> <br>
#**********************************************<br>
#**********************************************<br>
#********************************************</font></p>
<p><font color="#0000ff">好了&nbsp;&nbsp;  ~ ~　　继续继续....</font></p> <a href="http://hi.baidu.com/%5Fpsoc/blog/item/5cc00810a792fff9c3ce79b4.html">阅读全文</a>
		
		<br/><b>类别：</b><a href="http://hi.baidu.com/%5Fpsoc/blog/category/linux1%2E0%20%D1%A7%CF%B0%B1%CA%BC%C7">linux1.0 学习笔记</a>&nbsp;<a href="http://hi.baidu.com/%5Fpsoc/blog/item/5cc00810a792fff9c3ce79b4.html#comment">查看评论</a>]]></description>
        <pubDate>2008年04月30日 星期三  17:42</pubDate>
        <category><![CDATA[linux1.0 学习笔记]]></category>
        <author><![CDATA[microshark]]></author>
		<guid>http://hi.baidu.com/%5Fpsoc/blog/item/5cc00810a792fff9c3ce79b4.html</guid>
</item>

<item>
        <title><![CDATA[继续继续]]></title>
        <link><![CDATA[http://hi.baidu.com/%5Fpsoc/blog/item/146262f513ffab20bc310936.html]]></link>
        <description><![CDATA[
		
		<p><font color="#0000ff">#define do_div(n,base) ({ \<br>
int __res; \<br>
__asm__(&quot;divl %4&quot;:&quot;=a&quot; (n),&quot;=d&quot; (__res):&quot;0&quot; (n),&quot;1&quot; (0),&quot;r&quot; (base)); \<br>
__res; })</font></p>
<p><font color="#0000ff">这是在linux/kernel/vsprintf.c 中的 一点点代码, 会了他是没什么值的炫耀. </font></p>
<p><font color="#0000ff">不过我还是很高兴, 因为之前看到嵌入 汇编的情况都要 去查看嵌入汇编的规则</font></p>
<p><font color="#0000ff"> 再回头进行分析,  但是这次没有, 所以我觉得有必要 记录下来, 纪念一下. ~ ~ </font></p>
<p><font color="#0000ff">读代码的过程是艰辛的, 但是XX之后是叫人雀跃的...</font></p> <a href="http://hi.baidu.com/%5Fpsoc/blog/item/146262f513ffab20bc310936.html">阅读全文</a>
		
		<br/><b>类别：</b><a href="http://hi.baidu.com/%5Fpsoc/blog/category/linux1%2E0%20%D1%A7%CF%B0%B1%CA%BC%C7">linux1.0 学习笔记</a>&nbsp;<a href="http://hi.baidu.com/%5Fpsoc/blog/item/146262f513ffab20bc310936.html#comment">查看评论</a>]]></description>
        <pubDate>2008年04月28日 星期一  12:57</pubDate>
        <category><![CDATA[linux1.0 学习笔记]]></category>
        <author><![CDATA[microshark]]></author>
		<guid>http://hi.baidu.com/%5Fpsoc/blog/item/146262f513ffab20bc310936.html</guid>
</item>


</channel>
</rss>