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

Specify the location of "common_ISR_wrapper"
http://forum.andestech.com/viewtopic.php?f=25&t=891
Page 1 of 1

Author:  cindy [ Wed Oct 08, 2014 6:28 am ]
Post subject:  Specify the location of "common_ISR_wrapper"

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 4975 times ]


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

Author:  jerry [ Wed Oct 08, 2014 2:58 pm ]
Post subject:  Re: Specify the location of "common_ISR_wrapper"

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 308 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/