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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Armin Luntzer
FlightOS
Commits
871eb103
Commit
871eb103
authored
Mar 15, 2017
by
Armin Luntzer
Browse files
Options
Downloads
Patches
Plain Diff
xentium kernel configuration, saving changes
parent
ecc6e102
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
dsp/xentium/xen_dummy.c
+11
-1
11 additions, 1 deletion
dsp/xentium/xen_dummy.c
kernel/xentium.c
+92
-15
92 additions, 15 deletions
kernel/xentium.c
with
103 additions
and
16 deletions
dsp/xentium/xen_dummy.c
+
11
−
1
View file @
871eb103
...
@@ -3,8 +3,18 @@
...
@@ -3,8 +3,18 @@
#include
<xen_printf.h>
#include
<xen_printf.h>
struct
xen_kernel_cfg
{
char
*
name
;
unsigned
long
capabilities
;
unsigned
long
crit_buf_lvl
;
};
const
struct
xen_kernel_cfg
_xen_kernel_param
__attribute__
((
used
))
=
{
"xen_dummy"
,
0xdeadbeef
,
123
};
const
unsigned
int
_crit_buf_lvl
__attribute__
((
used
))
=
1234
;
...
...
This diff is collapsed.
Click to expand it.
kernel/xentium.c
+
92
−
15
View file @
871eb103
...
@@ -110,7 +110,7 @@ static int xentium_setup_kernel(struct xen_kernel *m)
...
@@ -110,7 +110,7 @@ static int xentium_setup_kernel(struct xen_kernel *m)
return
-
1
;
return
-
1
;
if
(
shdr
->
sh_flags
&
SHF_ALLOC
)
{
if
(
shdr
->
sh_flags
&
SHF_ALLOC
)
{
pr
intk
(
MSG
"found alloc section: %s, size %ld
\n
"
,
pr
_debug
(
MSG
"found alloc section: %s, size %ld
\n
"
,
elf_get_shstrtab_str
(
m
->
ehdr
,
i
),
elf_get_shstrtab_str
(
m
->
ehdr
,
i
),
shdr
->
sh_size
);
shdr
->
sh_size
);
...
@@ -118,7 +118,7 @@ static int xentium_setup_kernel(struct xen_kernel *m)
...
@@ -118,7 +118,7 @@ static int xentium_setup_kernel(struct xen_kernel *m)
if
(
shdr
->
sh_addralign
>
m
->
align
)
{
if
(
shdr
->
sh_addralign
>
m
->
align
)
{
m
->
align
=
shdr
->
sh_addralign
;
m
->
align
=
shdr
->
sh_addralign
;
pr
intk
(
MSG
"align: %d
\n
"
,
m
->
align
);
pr
_debug
(
MSG
"align: %d
\n
"
,
m
->
align
);
}
}
}
}
...
@@ -212,7 +212,7 @@ static int xentium_load_kernel(struct xen_kernel *x)
...
@@ -212,7 +212,7 @@ static int xentium_load_kernel(struct xen_kernel *x)
int
i
;
int
i
;
pr
intk
(
MSG
"
\n
"
MSG
"
\n
"
pr
_debug
(
MSG
"
\n
"
MSG
"
\n
"
MSG
"Loading kernel run-time sections
\n
"
);
MSG
"Loading kernel run-time sections
\n
"
);
x
->
num_sec
=
elf_get_num_alloc_sections
(
x
->
ehdr
);
x
->
num_sec
=
elf_get_num_alloc_sections
(
x
->
ehdr
);
...
@@ -248,13 +248,13 @@ static int xentium_load_kernel(struct xen_kernel *x)
...
@@ -248,13 +248,13 @@ static int xentium_load_kernel(struct xen_kernel *x)
strcpy
(
s
->
name
,
src
);
strcpy
(
s
->
name
,
src
);
if
(
sec
->
sh_type
&
SHT_NOBITS
)
{
if
(
sec
->
sh_type
&
SHT_NOBITS
)
{
pr
intk
(
MSG
"
\t
Zero segment %10s at %p size %ld
\n
"
,
pr
_debug
(
MSG
"
\t
Zero segment %10s at %p size %ld
\n
"
,
s
->
name
,
(
char
*
)
sec
->
sh_addr
,
s
->
name
,
(
char
*
)
sec
->
sh_addr
,
sec
->
sh_size
);
sec
->
sh_size
);
bzero
((
void
*
)
sec
->
sh_addr
,
s
->
size
);
bzero
((
void
*
)
sec
->
sh_addr
,
s
->
size
);
}
else
{
}
else
{
pr
intk
(
MSG
"
\t
copy segment %10s from %p to %p size %ld
\n
"
,
pr
_debug
(
MSG
"
\t
copy segment %10s from %p to %p size %ld
\n
"
,
s
->
name
,
s
->
name
,
(
char
*
)
x
->
ehdr
+
sec
->
sh_offset
,
(
char
*
)
x
->
ehdr
+
sec
->
sh_offset
,
(
char
*
)
sec
->
sh_addr
,
(
char
*
)
sec
->
sh_addr
,
...
@@ -264,7 +264,10 @@ static int xentium_load_kernel(struct xen_kernel *x)
...
@@ -264,7 +264,10 @@ static int xentium_load_kernel(struct xen_kernel *x)
(
char
*
)
x
->
ehdr
+
sec
->
sh_offset
,
(
char
*
)
x
->
ehdr
+
sec
->
sh_offset
,
sec
->
sh_size
);
sec
->
sh_size
);
printk
(
MSG
"
\t
adjust byte ordering
\n
"
);
/* we byte-swap all loadable sections, because the DMA
* of the Xentium reverses everything back into little
* endian words */
p
=
(
uint32_t
*
)
sec
->
sh_addr
;
p
=
(
uint32_t
*
)
sec
->
sh_addr
;
for
(
i
=
0
;
i
<
sec
->
sh_size
/
sizeof
(
uint32_t
);
i
++
)
for
(
i
=
0
;
i
<
sec
->
sh_size
/
sizeof
(
uint32_t
);
i
++
)
...
@@ -279,7 +282,7 @@ static int xentium_load_kernel(struct xen_kernel *x)
...
@@ -279,7 +282,7 @@ static int xentium_load_kernel(struct xen_kernel *x)
s
++
;
s
++
;
if
(
s
>
&
x
->
sec
[
x
->
num_sec
])
{
if
(
s
>
&
x
->
sec
[
x
->
num_sec
])
{
pr
intk
(
MSG
"Error out of section memory
\n
"
);
pr
_debug
(
MSG
"Error out of section memory
\n
"
);
goto
error
;
goto
error
;
}
}
}
}
...
@@ -297,24 +300,89 @@ error:
...
@@ -297,24 +300,89 @@ error:
}
}
struct
xen_kernel_cfg
{
char
*
name
;
unsigned
long
capabilities
;
unsigned
long
crit_buf_lvl
;
};
/**
* load the kernels configuration data
*/
int
xentium_config_kernel
(
struct
xen_kernel
*
x
)
{
unsigned
long
symaddr
;
struct
xen_kernel_cfg
x_cfg
;
size_t
len
=
0
;
uint32_t
*
p
;
char
*
name
;
if
(
!
elf_get_symbol_value
(
x
->
ehdr
,
"_xen_kernel_param"
,
&
symaddr
))
{
pr_warn
(
MSG
"Error, _xen_kernel_param not found
\n
"
);
return
-
1
;
}
memcpy
((
void
*
)
&
x_cfg
,
(
void
*
)
symaddr
,
sizeof
(
struct
xen_kernel
));
/* everything but the "name" entry (which is mashed up from our
* perspective) is already in correct (big endian) order.
* Since the string stored in .rodata is aligned to 4 bytes,
* we'll locate the first occurence of '\0', round up to the next word
* boundary, then swab32() on the buffer to restore the string.
* The Xentium DMA will reverse endianess to little endian on the
* relevant run time sections, we don't need to care about that.
*/
while
(
x_cfg
.
name
[
len
]
!=
'\0'
)
len
++
;
len
=
ALIGN
(
len
,
sizeof
(
uint32_t
));
name
=
kmalloc
(
len
);
if
(
!
name
)
return
-
1
;
p
=
(
uint32_t
*
)
name
;
memcpy
(
name
,
(
void
*
)
x_cfg
.
name
,
len
);
len
=
len
/
sizeof
(
uint32_t
);
do
{
len
--
;
p
[
len
]
=
swab32
(
p
[
len
]);
}
while
(
len
);
x_cfg
.
name
=
name
;
printk
(
MSG
"Configuration of kernel %s:
\n
"
MSG
"
\t
capabilities: %x
\n
"
MSG
"
\t
critical buffer level: %d
\n
"
,
x_cfg
.
name
,
x_cfg
.
capabilities
,
x_cfg
.
crit_buf_lvl
);
return
0
;
}
#include
<asm-generic/swab.h>
int
xentium_kernel_load
(
struct
xen_kernel
*
x
,
void
*
p
)
int
xentium_kernel_load
(
struct
xen_kernel
*
x
,
void
*
p
)
{
{
unsigned
long
symval
;
/* the ELF binary starts with the ELF header */
/* the ELF binary starts with the ELF header */
x
->
ehdr
=
(
Elf_Ehdr
*
)
p
;
x
->
ehdr
=
(
Elf_Ehdr
*
)
p
;
pr
intk
(
MSG
"Checking ELF header
\n
"
);
pr
_debug
(
MSG
"Checking ELF header
\n
"
);
if
(
xentium_elf_header_check
(
x
->
ehdr
))
if
(
xentium_elf_header_check
(
x
->
ehdr
))
goto
error
;
goto
error
;
pr
intk
(
MSG
"Setting up module configuration
\n
"
);
pr
_debug
(
MSG
"Setting up module configuration
\n
"
);
if
(
xentium_setup_kernel
(
x
))
if
(
xentium_setup_kernel
(
x
))
goto
error
;
goto
error
;
...
@@ -322,8 +390,17 @@ int xentium_kernel_load(struct xen_kernel *x, void *p)
...
@@ -322,8 +390,17 @@ int xentium_kernel_load(struct xen_kernel *x, void *p)
if
(
xentium_load_kernel
(
x
))
if
(
xentium_load_kernel
(
x
))
goto
cleanup
;
goto
cleanup
;
p_xen0
->
mlbx
[
0
]
=
0x30000000
;
// p_xen1->mlbx[0] = 0x30000000;
if
(
xentium_config_kernel
(
x
))
goto
cleanup
;
printk
(
"starting xentium with ep %x
\n
"
,
x
->
ep
);
#if 1
p_xen0
->
mlbx
[
0
]
=
x
->
ep
;
#else
p_xen1
->
mlbx
[
0
]
=
x
->
ep
;
#endif
if
(
_xen
.
cnt
==
_xen
.
sz
)
{
if
(
_xen
.
cnt
==
_xen
.
sz
)
{
...
@@ -339,12 +416,12 @@ int xentium_kernel_load(struct xen_kernel *x, void *p)
...
@@ -339,12 +416,12 @@ int xentium_kernel_load(struct xen_kernel *x, void *p)
return
0
;
return
0
;
cleanup:
cleanup:
pr
intk
(
"cleanup
\n
"
);
pr
_err
(
"cleanup
\n
"
);
#if 0
#if 0
xentium_kernel_unload(m);
xentium_kernel_unload(m);
#endif
#endif
error:
error:
pr
intk
(
"error
\n
"
);
pr
_err
(
"error
\n
"
);
return
-
1
;
return
-
1
;
}
}
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