It takes exactly the same number of assembly instructions to call the function and only one extra instruction (ldr) is needed to evaluate the result ( (shm.size > 0) vs. (0 == ret) ). You are not seriously calling this difficult, are you ?
Yes but you have to know to pass a pointer to the structure in r0 and shift all other arguments, which is non-obvious and rarely used. Having +/- a few instructions is non-issue of course.
hmm earlier this evening I wrote a simple test program and looked at the compiler's assembly output.
here's what it looks like when calling a function "
extern test_t test_fxn_a(unsigned int _sz)":
(
test_t is just a
struct { int a; int b; int c; })
test_a:
.fnstart
@ args = 0, pretend = 0, frame = 16
@ frame_needed = 0, uses_anonymous_args = 0
str lr, [sp, #-4]!
.save {lr}
.pad #20
sub sp, sp, #20
add r0, sp, #4
mov r1, #4096
bl test_fxn_a
and this is with "
extern int test_fxn_b(unsigned int _sz, test_t *_ret)":
test_b:
.fnstart
@ args = 0, pretend = 0, frame = 16
@ frame_needed = 0, uses_anonymous_args = 0
str lr, [sp, #-4]!
.save {lr}
.pad #20
sub sp, sp, #20
mov r0, #4096
add r1, sp, #4
bl test_fxn_b
the functions are called like this:
test_t r = test_fxn_a(0x1000u);
and
test_t r;
int r2;
r2 = test_fxn_b(0x1000u, &r);
as you can see, the code is basically the same and in both cases you do have to know how to pass a pointer to the struct.
But agreed, it's not very common. Hopefully no-one wants support for using libc64 in asm code
Last but not least, who in his right mind does system programming in assembly ? ppl (including me) did that 20 years ago because C compilers were not as efficient as they are today, and for performance critical loops I can still understand but for one-time alloc/free calls.. *shakes head*
We had one such person, maybe he was working on optimize-for-size demo (4K and the likes)? He disappeared without releasing anything though.
Of course, I forgot about the 4k intro programmers. Quite insane. And sometimes incompatible with newer OS versions because some assumed default values changed or some default OS .wav files disappeared
(okokok, most 4ks don't 'cheat' that way
)
Anyways.. time to check out eDMA3. Have you found any video sequencer / hardware accelerator related docs, btw ? the omap3530 TRM (spruf98x) does not seem to cover it..?!
It's undocumented and super secret.. Early versions of TRM didn't even mention ARM9 and separate video blocks, it was all just one "video accelerator" box. Now at least we have some elements and their registers described.
Hmm.. maybe we should try to ask TI for the docs ?!.
Usually companies pay royalties for including hardware blocks / IP in their products, and the HW is definitely there.
I don't see any good reason why they would withhold the documentation for it.
The TRM does not really say what exactly this "video accelerator" actually accelerates (
just a few lines that say "improved motion estimation", "loop filtering" and "dedicated sequencer" .. you have read them).
In earlier versions of the TRM the whole DSP was only mentioned with the comment "
documentation not publically available". Fortunately that has changed later on.
This is an ASM game I believe http://boards.openpa...rc/?hl=assembly
quite crazy. but.. then again.. not so crazy if you haven't done something like that before / do it for practice and to learn how the OS works.
Today I spent quite some time analyzing the reason why the DSP does not see the correct values of global variables in overlay images (
except for the component struct but that only worked since it was linked to a dedicated section).
Here are my findings ("
doc/overlay_cinit_analysis-22Oct2013.txt"):
----------------------------------------------------------------------------------------------------
test #1:
in makefile.c64p: OPTFLAGS+= $(OPTFLAGS_SIZE)
in test_logbuf.c:<global> : int cnt_i = 42;
in map file: 8620189c _cnt_i
in test_logbuf.c:loc_init(): syscalls.mlb_debug_usr(3, (sU32)cnt_i);
result: [dbg] dsp_debug_usr_print: debug_usr[3]=0x00000000.
==> whoops, debug should read 0x2a (42)!!
----------------------------------------------------------------------------------------------------
test #2:
in makefile.c64p: OPTFLAGS+= $(OPTFLAGS_SIZE)
in test_logbuf.c:<global> : int cnt_i = 42;
in map file: 8620189c _cnt_i
in test_logbuf.c:loc_init(): syscalls.mlb_debug_usr(3, *(volatile sS32*) 0x8620189c); //cnt_i
result: [dbg] dsp_debug_usr_print: debug_usr[3]=0x0000002a.
==> correct data, cinit works
----------------------------------------------------------------------------------------------------
test #3:
in makefile.c64p: OPTFLAGS+= $(OPTFLAGS_SIZE)
in test_logbuf.c:<global> : int cnt_i = 64;
in map file: 8620189c _cnt_i
in test_logbuf.c:loc_init(): syscalls.mlb_debug_usr(3, (sU32) &cnt_i);
result: [dbg] dsp_debug_usr_print: debug_usr[3]=0x860555c0.
==> whoops, DSP uses wrong address of cnt_i although it's listed correctly in the .map file!
----------------------------------------------------------------------------------------------------
test #4:
in makefile.c64p: OPTFLAGS+= $(OPTFLAGS_NONE)
in test_logbuf.c:<global> : int cnt_i = 64;
in map file: 86201854 _cnt_i
in test_logbuf.c:loc_init(): syscalls.mlb_debug_usr(3, (sU32) &cnt_i);
result: [dbg] dsp_debug_usr_print: debug_usr[3]=0x860555c0.
==> still the wrong address
----------------------------------------------------------------------------------------------------
test #5:
in makefile.c64p: OPTFLAGS+= $(OPTFLAGS_NONE_INTERLIST)
in install.mk: CFLAGS+= --mem_model:data=far (note: default is far_aggregate)
in test_logbuf.c:<global> : int cnt_i = 64;
in map file: 86201880 _cnt_i
in test_logbuf.c:loc_init(): syscalls.mlb_debug_usr(3, (sU32) &cnt_i);
result: [dbg] dsp_debug_usr_print: debug_usr[3]=0x86201880.
==> correct address, yay!
I.e. changing the memory model fixes it!
Here's the changelog / update for today:
+ add dsp_cache_wbinvall() API call
+ change GPP-side cache type of overlay region to write-through (instead of noncached)
+ add C64_IOCTL_CACHE action C64_CACHE_AC_WBINVALL to kmod/dev.c
+ analyze DSP-side global var issue (see doc/overlay_cinit_analysis-22Oct2013.txt)
+ change DSP const/data memory model to 'far' (instead of 'far_aggregate')
--> DSP code now uses correct addresses for global vars.
--> malloc()/free() also work now but should probably not be used (at least not across RPCs)
+ add redirects for DSP-side puts/printf/vprintf/ calls (trigger linker errors)
(--> please use syscalls.puts(), syscalls.printf(), .. instead)
+ GPP side dsp_logbuf_print() now omits <begin>, <end>, <no new message> unless debug level is >=20
+ DSP logbuf message lines are now prefixed with "DSP: " on GPP side
+ fix logbuf message lines that are composed via multiple printf()s
+ add TC_LOGBUF_SPLITLINE testcase to tests/c64_tc.c
+ auto-append linefeed in dsp_logbuf_print() to last message if it did not end with LF already
+ add TC_LOGBUF_NO_LF testcase to tests/c64_tc.c
+ fix dsp_shm_alloc(), dsp_fshm_alloc() inline docs (regarding their return values)
+ release
http://tkscript.de/c64_tools/c64_tools-22Oct2013_snapshot.tar.gz