Andes Workshop
http://forum.andestech.com/

改變ivb位址的example
http://forum.andestech.com/viewtopic.php?f=16&t=602
Page 1 of 1

Author:  cindy [ Wed Aug 01, 2012 5:18 pm ]
Post subject:  改變ivb位址的example

分享一個改變ivb位址的example 。

一般的程式,有1個vector table。

這個程式有2個vector table。
Andes cpu中的IVBASE是可以改變的。
這個程式裡設計有2個vector table,
1個在0x0,另一個在0x10000。

請看程式裡的readelf,
0x0裡的是.nds32_init,原本的vector table。
0x10000裡的是.nds32_vector2,新的vector table。

簡介做法如下:
(1)我多做一個新的vector table .nds32_vector2,放在crt1.S裡,
它的內容大致上是抄ctr0.S的內容。
只是ISR不同。

(2)要在linker script裡指定.nds32_vector2的位址。
Code:
  .nds32_vector2 ORIGIN(SDRAM) : { KEEP(*(.nds32_vector2)) } > SDRAM


(3)crt0.S裡,我把IVB和ESZ改掉。
IVB改成0x10000,ESZ改成4 bytes。
剛才這裡我debug找了很久,後來我發現ESZ的default值是16 bytes,
與我的程式不符,所以它一直跳錯地址。
Code:
! change IVB
    mfsr $r0, $ir3
    li  $r1, 0x10000
    or $r0,$r1,$r0
    mtsr $r0, $ir3
! set EZS of IVB to 0
    mfsr $r0, $ir3
    li  $r1, 0xFFFF3FFF
    and $r0,$r1,$r0
    mtsr $r0, $ir3
! jump to new _start1
    li  $r1, 0x10000
    jr $r1


(4) 程式執行結果:
Attachment:
result.png
result.png [ 6.31 KiB | Viewed 8546 times ]


(註:上面的
* ========== new HW0_ISR1 ========== *
* ==========End of HW0 ISR it takes 6 secs ==========*
這2行,是我按下GPIO按鈕後才會有的字)
Attachment:
demo-int.zip [104.88 KiB]
Downloaded 913 times

Page 1 of 1 All times are UTC + 8 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/