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
89451005
Commit
89451005
authored
8 years ago
by
Armin Luntzer
Browse files
Options
Downloads
Patches
Plain Diff
modules image: add new function module_read_embedded()
parent
eb6d6e2f
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
init/main.c
+8
-4
8 additions, 4 deletions
init/main.c
init/modules-image.c
+21
-0
21 additions, 0 deletions
init/modules-image.c
with
29 additions
and
4 deletions
init/main.c
+
8
−
4
View file @
89451005
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
void
module_image_load_embedded
(
void
);
void
module_image_load_embedded
(
void
);
void
*
module_lookup_embedded
(
char
*
mod_name
);
void
*
module_lookup_embedded
(
char
*
mod_name
);
void
*
module_lookup_symbol_embedded
(
char
*
sym_name
);
void
*
module_lookup_symbol_embedded
(
char
*
sym_name
);
void
*
module_read_embedded
(
char
*
mod_name
);
static
void
kernel_init
(
void
)
static
void
kernel_init
(
void
)
{
{
...
@@ -40,7 +40,6 @@ int main(void)
...
@@ -40,7 +40,6 @@ int main(void)
module_image_load_embedded
();
module_image_load_embedded
();
/* look up a kernel symbol */
/* look up a kernel symbol */
printk
(
"%s at %p
\n
"
,
"printk"
,
lookup_symbol
(
"printk"
));
printk
(
"%s at %p
\n
"
,
"printk"
,
lookup_symbol
(
"printk"
));
...
@@ -48,7 +47,6 @@ int main(void)
...
@@ -48,7 +47,6 @@ int main(void)
printk
(
"%s at %p
\n
"
,
"testmodule.ko"
,
printk
(
"%s at %p
\n
"
,
"testmodule.ko"
,
module_lookup_embedded
(
"testmodule.ko"
));
module_lookup_embedded
(
"testmodule.ko"
));
/* to load an arbitrary image, you may upload it via grmon, e.g.
/* to load an arbitrary image, you may upload it via grmon, e.g.
* load -binary kernel/test.ko 0xA0000000
* load -binary kernel/test.ko 0xA0000000
* then load it:
* then load it:
...
@@ -56,7 +54,13 @@ int main(void)
...
@@ -56,7 +54,13 @@ int main(void)
*/
*/
/* lookup the module containing <symbol> */
/* lookup the module containing <symbol> */
addr
=
module_lookup_symbol_embedded
(
"somefunction"
);
/* addr = module_lookup_symbol_embedded("somefunction"); */
/* XXX the image is not necessary aligned properly, so we can't access
* it directly, until we have a MNA trap */
addr
=
module_read_embedded
(
"testmodule.ko"
);
if
(
addr
)
if
(
addr
)
module_load
(
&
m
,
addr
);
module_load
(
&
m
,
addr
);
...
...
This diff is collapsed.
Click to expand it.
init/modules-image.c
+
21
−
0
View file @
89451005
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
#include
<kernel/printk.h>
#include
<kernel/printk.h>
#include
<kernel/ar.h>
#include
<kernel/ar.h>
#include
<kernel/kmem.h>
extern
unsigned
char
_binary_modules_image_start
__attribute__
((
weak
));
extern
unsigned
char
_binary_modules_image_start
__attribute__
((
weak
));
extern
unsigned
char
_binary_modules_image_end
__attribute__
((
weak
));
extern
unsigned
char
_binary_modules_image_end
__attribute__
((
weak
));
...
@@ -31,3 +32,23 @@ void *module_lookup_embedded(char *mod_name)
...
@@ -31,3 +32,23 @@ void *module_lookup_embedded(char *mod_name)
{
{
return
ar_find_file
(
&
mod_ar
,
mod_name
);
return
ar_find_file
(
&
mod_ar
,
mod_name
);
}
}
void
*
module_read_embedded
(
char
*
mod_name
)
{
unsigned
int
fsize
;
void
*
ptr
;
fsize
=
ar_read_file
(
&
mod_ar
,
mod_name
,
NULL
);
ptr
=
kmalloc
(
fsize
);
if
(
!
ptr
)
return
NULL
;
if
(
!
ar_read_file
(
&
mod_ar
,
mod_name
,
ptr
))
{
kfree
(
ptr
);
return
NULL
;
}
return
ptr
;
}
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