#132770 - Ant6n - Fri Jun 29, 2007 6:30 am
I am trying to run code in shared iwram on the arm9 side. I started with the devkitpro arm7/arm9 template. My main is this:
and the function to run is this:
I use this awkward way of doing things because the standard linkscript doesnt define a shared wram section, and i dont know how modify it appropriately.
This works in nogba, albeit only if the function is small. If i use .rept 100, then the rom crashes. On real hardware this thing doesnt work at all (crashes before printing anything). I tried memcpy, dmacpy and swicopy, but none seem to work. If I remove the comments and actually run the testfunction in shared ram, the rom crashes, even if the copying worked.
Code: |
#include <nds/arm9/console.h> //basic print funcionality
#include "asm.h" #include "dssystem.h" #define SHARED ((vuint32*)0x03000000) typedef u32 testfunction(u32 in) __attribute__ ((long_call)); int main(void) { videoSetMode(0); videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE); vramSetBankC(VRAM_C_SUB_BG); SUB_BG0_CR = BG_MAP_BASE(31); BG_PALETTE_SUB[255] = RGB15(31,31,31); consoleInitDefault((u16*)SCREEN_BASE_BLOCK_SUB(31), (u16*)CHAR_BASE_BLOCK_SUB(0), 16); //set iwram to belong to DS REG_WRAMCNT = 0; //copy the asm stuff testfunction *ptest2 = (testfunction *)SHARED; memcpy(test,SHARED,testlength/4); iprintf("\n\nshared wram register of arm9: %d\n",REG_WRAMCNT); iprintf("location of 'test' function: %x\n",test); iprintf("testlength %d\n",testlength); iprintf("first byte of test/sharedram: %x / %x\n",((u32*)test)[0],SHARED[0]); int n; //n = ((*ptest2)(0x4000100)); iprintf("Test returned: %d\n",n); ...etc |
and the function to run is this:
Code: |
.SECTION .ewram,"ax",%progbits .ALIGN .POOL .ALIGN .GLOBAL test .GLOBAL test_end @test: u32 -> u32; r0 holds 4000100h, returns time of execution in 33MHz cycles test: @first set up timer mov r1,r0 mov r2,#0 @timer0count = 0 strh r2,[r1] mov r2,#(1<<7) @timer0control = tmr-mode1 | timer-start strh r2,[r1, +#2] .rept 20 add r2,r4,r5 add r3,r6,r6 .endr ldrh r0,[r1] @read timer value bx lr test_end: nop |
I use this awkward way of doing things because the standard linkscript doesnt define a shared wram section, and i dont know how modify it appropriately.
This works in nogba, albeit only if the function is small. If i use .rept 100, then the rom crashes. On real hardware this thing doesnt work at all (crashes before printing anything). I tried memcpy, dmacpy and swicopy, but none seem to work. If I remove the comments and actually run the testfunction in shared ram, the rom crashes, even if the copying worked.