Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FlightOS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Armin Luntzer
FlightOS
Commits
ecc6e102
Commit
ecc6e102
authored
8 years ago
by
Armin Luntzer
Browse files
Options
Downloads
Patches
Plain Diff
ELF: must byte swap more than one header entry, d'oh!
parent
b0ade261
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
dsp/xentium/Makefile
+10
-12
10 additions, 12 deletions
dsp/xentium/Makefile
dsp/xentium/xen_dummy.c
+191
-0
191 additions, 0 deletions
dsp/xentium/xen_dummy.c
lib/elf.c
+6
-4
6 additions, 4 deletions
lib/elf.c
with
207 additions
and
16 deletions
dsp/xentium/Makefile
+
10
−
12
View file @
ecc6e102
...
...
@@ -18,6 +18,7 @@
#
# kbuild trick to avoid linker error. Can be omitted if a module is built.
obj-
:=
dummy.o
...
...
@@ -25,24 +26,21 @@ HOSTCC := xentium-clang
HOSTLD
:=
xentium-ld
HOSTCFLAGS
=
-Wall
-Wmissing-prototypes
-Wstrict-prototypes
-O2
-Idsp
/xentium
HOSTLDFLAGS
+=
-Tdsp
/xentium/sysroot/lib/default.ld
HOSTLDFLAGS
+=
--sysroot
=
dsp/xentium/sysroot
hostprogs-y
:=
testkernel.xen
hostprogs-y
+=
otherkernel.xen
testkernelkernel.xen
:
HOSTLOADLIBES_testkernel.xen
:=
testkernel.xen-objs
:=
testkernel.o xen_printf.o
xen_dummy.xen
:
HOSTLOADLIBES_xen_dummy.xen
:=
xen_dummy.xen-objs
:=
xen_dummy.o xen_printf.o
hostprogs-y
:=
xen_dummy.xen
otherkernel.xen
:
testkernel.xen
HOSTLOADLIBES_otherkernel.xen
:=
-Ttext
$$(
readelf
-s
dsp/xentium/testkernel.xen|grep
-w
_end |awk
'{print $$2
}
'
)
otherkernel.xen-objs
:=
testkernel.o xen_printf.o
otherkernel.xen
:
xen_dummy.xen
HOSTLOADLIBES_otherkernel.xen
:=
-Ttext
$$(
readelf
-s
dsp/xentium/xen_dummy.xen|grep
-w
_end |awk
'{print $$2
}
'
)
otherkernel.xen-objs
:=
xen_dummy.o xen_printf.o
#hostprogs-y += otherkernel.xen
...
...
This diff is collapsed.
Click to expand it.
dsp/xentium/xen_dummy.c
0 → 100644
+
191
−
0
View file @
ecc6e102
#include
<xen_wrapper.h>
#include
<xen_printf.h>
const
unsigned
int
_crit_buf_lvl
__attribute__
((
used
))
=
1234
;
int
main
(
void
)
{
int
i
=
0
;
while
(
i
++
<
10
)
{
x_printf
(
"hello there!
\n
"
);
XEN_WAIT_CYCLES
(
25000000
);
}
x_printf
(
"bye
\n
"
);
#if 0
/**
* stats
*/
unsigned int elapsed = 0;
unsigned int cycles_used = 0;
unsigned int samples_processed = 0;
unsigned int samples_processed_last = 0;
unsigned int tmp_critical_words;
unsigned int uiTmpBufferCnt = 0;
volatile unsigned int msg = 0;
unsigned int *p_tmp_critical;
unsigned int *p_tmp_buffer;
unsigned int *ptBANK0 = (unsigned int *) p_xen->tcm;
unsigned int *ptBANK2 = (unsigned int *) p_xen->tcm + ((unsigned int) BANK_SIZE >> 1);
/default.ld
struct xen_data *p_xen_data;
enum {NONE, REQUEST_DATA, STORE_OUTPUT, YIELD} last_action = NONE;
XEN_WAIT_INIT(p_xen_data);
p_tmp_buffer = p_xen_data->tmp_buffer_1;
// 50% fill, Size is in words;
// @note: adjust size so this round of processing will always fit
// @note: we have two options here: check the element fill counter or do it by checking the pointer difference
// @note: both ways work, but it depends on how an AlgoLib function is constructed (we really don't want to change them if possible)
tmp_critical_words = p_xen_data->tmp_buffer_1_size >> 1;
p_tmp_critical = p_tmp_buffer + tmp_critical_words;
x_printf("Reducer @Xen %u. Critical tmp buffer state is %u\n", p_xen_data->xen_id, tmp_critical_words);
XEN_RESET_CYCLES_COUNTER();
// lead-in: fetch data
xen_request_data(p_xen_data, ptBANK0, TCM_WORDSIZE);
last_action = REQUEST_DATA;
XEN_MSG_LEON();
while(1)
{
XEN_GET_MSG(msg);
x_printf("msg\n");
elapsed = XEN_GET_CYCLES_ELAPSED();
cycles_used += elapsed;
XEN_RESET_CYCLES_COUNTER();
samples_processed += samples_processed_last;
samples_processed_last = 0;
switch(last_action) {
case YIELD:
if(msg == XEN_GO)
uiTmpBufferCnt = 0; // store was successful, reset
if(msg == XEN_WAIT) { // wait, then try to continue, setup new new data request
XEN_WAIT_CYCLES(XEN_DEFAULT_WAIT);
xen_request_data(p_xen_data, ptBANK0, TCM_WORDSIZE);
last_action = REQUEST_DATA;
break;
}
if(uiTmpBufferCnt > 0) { // try to flush
xen_req_store_data(p_xen_data, p_tmp_buffer, uiTmpBufferCnt);
last_action = YIELD;
break;
} else {
XEN_SET_CYCLES_MSG(cycles_used/samples_processed);
XEN_YIELD();
}
break;
case STORE_OUTPUT:
if(msg == XEN_WAIT) { // retry
XEN_WAIT_CYCLES(XEN_DEFAULT_WAIT);
xen_req_store_data(p_xen_data, p_tmp_buffer, uiTmpBufferCnt);
last_action = STORE_OUTPUT;
break;
}
if(msg == XEN_GO) { // success, continue processing
uiTmpBufferCnt = 0;
xen_request_data(p_xen_data, ptBANK0, TCM_WORDSIZE);
last_action = REQUEST_DATA;
break;
}
break;
case REQUEST_DATA:
if(msg == XEN_GO) { // execute kernel function
uiTmpBufferCnt += execute_this_function(ptBANK0, p_tmp_buffer, TCM_WORDSIZE);
samples_processed_last=TCM_WORDSIZE;
}
if(msg == XEN_WAIT)
XEN_WAIT_CYCLES(XEN_DEFAULT_WAIT);
if(msg == XEN_NODATA) {
XEN_WAIT_CYCLES(XEN_DEFAULT_WAIT);
if(uiTmpBufferCnt > 0) { // try to flush
xen_req_store_data(p_xen_data, p_tmp_buffer, uiTmpBufferCnt);
last_action = STORE_OUTPUT;
break;
} else { // offer to yield
XEN_SET_REQUEST(XEN_I_YIELD);
last_action = YIELD;
}
break;
}
if(uiTmpBufferCnt < tmp_critical_words) { // setup next block request
xen_request_data(p_xen_data, ptBANK0, TCM_WORDSIZE);
last_action = REQUEST_DATA;
} else { // output is critical, flush
xen_req_store_data(p_xen_data, p_tmp_buffer, uiTmpBufferCnt);
last_action = STORE_OUTPUT;
}
break;
default:
break;
}
switch(p_xen_data->ctrl_msg)
{
case XEN_PLEASEYIELD:
p_xen_data->ctrl_msg = 0;
if(uiTmpBufferCnt > 0) { // flush. takes precendence over other requests
xen_req_store_data(p_xen_data, p_tmp_buffer, uiTmpBufferCnt);
last_action = YIELD;
} else {
XEN_SET_CYCLES_MSG(cycles_used/samples_processed);
XEN_YIELD();
}
default:
break;
}
XEN_MSG_LEON();
}
#endif
return
0
;
}
This diff is collapsed.
Click to expand it.
lib/elf.c
+
6
−
4
View file @
ecc6e102
...
...
@@ -172,7 +172,6 @@ void elf_hdr_endianess_swap(Elf_Ehdr *ehdr)
ehdr
->
e_shnum
=
swab16
(
ehdr
->
e_shnum
);
ehdr
->
e_shstrndx
=
swab16
(
ehdr
->
e_shstrndx
);
/* everything after is in 32 bit words */
phdr
=
(
Elf_Phdr
*
)
((
char
*
)
ehdr
+
ehdr
->
e_phoff
);
...
...
@@ -202,13 +201,16 @@ void elf_hdr_endianess_swap(Elf_Ehdr *ehdr)
shdr
[
i
].
sh_entsize
=
swab32
(
shdr
[
i
].
sh_entsize
);
}
shdr
=
elf_find_sec
(
ehdr
,
".symtab"
);
if
(
shdr
)
{
sym
=
(
Elf_Sym
*
)
(((
char
*
)
ehdr
)
+
shdr
->
sh_offset
);
for
(
i
=
0
;
i
<
shdr
->
sh_size
/
shdr
->
sh_entsize
;
i
++
)
sym
[
i
].
st_name
=
swab32
(
sym
[
i
].
st_name
);
for
(
i
=
0
;
i
<
shdr
->
sh_size
/
shdr
->
sh_entsize
;
i
++
)
{
sym
[
i
].
st_name
=
swab32
(
sym
[
i
].
st_name
);
sym
[
i
].
st_value
=
swab32
(
sym
[
i
].
st_value
);
sym
[
i
].
st_size
=
swab32
(
sym
[
i
].
st_size
);
sym
[
i
].
st_shndx
=
swab16
(
sym
[
i
].
st_shndx
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment