Andes Workshop

It is currently Tue Sep 26, 2017 6:27 pm

All times are UTC + 8 hours [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Specify the location of "common_ISR_wrapper"
PostPosted: Wed Oct 08, 2014 6:28 am 
Offline
User avatar

Joined: Fri Mar 04, 2011 9:36 pm
Posts: 500
We can assign the address of a C function.
We can specify the location of assembly code as well.

Here is a example:
We put common_ISR_wrapper to a section ".nds32_aa".
.section .nds32_aa, "ax"
(The file is crt0.S)
Code:
   .section .nds32_aa, "ax"
   .align 2
common_ISR_wrapper:
   SAVE_ALL_HW
   la  $r1, ISR_TABLE
   lw  $r1, [$r1+$r0<<2]
   jral $r1
   RESTORE_ALL_HW
   iret


Then we modify the sag file, add the following lines:

Code:
QUICKSRAM 0x00005000
{
   QEXEC 0x00005000
   {
      * (.nds32_aa)
   }
}

Use nds_ldsag to convert the sag file to a *.ld file.
Code:
cindy@cindy-PC /cygdrive/c/Andestech/AndeSight201MCU/mcu_64/workspace/demo-int-wrapper
$ ../../../utils/nds_ldsag.exe nds32.sag -o nds32.ld
The output file is placed "nds32.ld"


The output is what we want
Code:
00005000 <common_ISR_wrapper>:

/*Cindy*/
   .section .nds32_aa, "ax"
   .align 2
common_ISR_wrapper:
   SAVE_ALL_HW
    5000:   3a 1f 94 3c    smw.adm $r1,[$sp],$r5,#0x0    ! {$r1~$r5}
    5004:   3a ff ef bc    smw.adm $r15,[$sp],$p1,#0xe    ! {$r15~$p1, $fp, $gp, $lp}
    5008:   42 21 00 20    mfusr $r2,$d1.lo
    500c:   42 31 80 20    mfusr $r3,$d1.hi
    5010:   42 40 00 20    mfusr $r4,$d0.lo
....


Note: I move OS_Trap_Interrupt_UNDEF upper, as the following figure:
Attachment:
isr.gif
isr.gif [ 36.57 KiB | Viewed 2531 times ]


Sample code download:
Attachment:
demo-int-wrapper.zip [122.89 KiB]
Downloaded 145 times


Last edited by cindy on Fri Oct 10, 2014 12:27 pm, edited 2 times in total.

Top
 Profile Send private message E-mail  
 
 Post subject: Re: Specify the location of "common_ISR_wrapper"
PostPosted: Wed Oct 08, 2014 2:58 pm 
Offline

Joined: Thu Apr 03, 2014 10:09 am
Posts: 42
For XIP mode

We put common_ISR_wrapper to a section ".nds32_aa".
.section .nds32_aa, "ax"
(The file is crt0.S)
Code:
.section .nds32_aa, "ax"
   .align 2
common_ISR_wrapper:
   SAVE_ALL_HW
   la  $r1, ISR_TABLE
   lw  $r1, [$r1+$r0<<2]
   jral $r1
   RESTORE_ALL_HW
   iret


Then we modify the sag file, add the following lines:
Code:
   QEXEC 0x00800000
   {
      LOADADDR lma_QEXEC_S
      ADDR vma_QEXEC
      * (.nds32_aa)
      LOADADDR lma_QEXEC_e
      
   }


copy the data to .nds32_aa
(file init-default.c)
Code:
   extern char lma_QEXEC_S;
   extern char lma_QEXEC_e;
   extern char vma_QEXEC;
   /* Copy data section to RAM */
   size = &lma_QEXEC_e - &lma_QEXEC_S;
   MEMCPY(&vma_QEXEC, &lma_QEXEC_S, size);


Out file
Code:
.section .nds32_aa, "ax"
common_ISR_wrapper:
   SAVE_ALL_HW
80000000:   3a 1f 94 3c    smw.adm $r1,[$sp],$r5,#0x0    ! {$r1~$r5}
80000004:   3a ff ef bc    smw.adm $r15,[$sp],$p1,#0xe    ! {$r15~$p1, $fp, $gp, $lp}
80000008:   42 21 00 20    mfusr $r2,$d1.lo
8000000c:   42 31 80 20    mfusr $r3,$d1.hi
80000010:   42 40 00 20    mfusr $r4,$d0.lo
80000014:   42 50 80 20    mfusr $r5,$d0.hi
80000018:   3a 2f 94 3c    smw.adm $r2,[$sp],$r5,#0x0    ! {$r2~$r5}
8000001c:   64 13 00 02    mfsr $r1,$INT_MASK


Attachment:
demo-int-xip.zip [123.78 KiB]
Downloaded 153 times


Top
 Profile Send private message E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group