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
7fc3b8b2
Commit
7fc3b8b2
authored
5 years ago
by
Armin Luntzer
Browse files
Options
Downloads
Patches
Plain Diff
consolidate application loader
parent
74081fd8
No related branches found
No related tags found
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
include/kernel/sched.h
+3
-3
3 additions, 3 deletions
include/kernel/sched.h
init/main.c
+17
-126
17 additions, 126 deletions
init/main.c
kernel/kthread.c
+14
-0
14 additions, 0 deletions
kernel/kthread.c
lib/string.c
+7
-0
7 additions, 0 deletions
lib/string.c
lib/vsnprintf.c
+0
-26
0 additions, 26 deletions
lib/vsnprintf.c
with
41 additions
and
155 deletions
include/kernel/sched.h
+
3
−
3
View file @
7fc3b8b2
...
...
@@ -6,8 +6,10 @@
#ifndef _KERNEL_SCHED_H_
#define _KERNEL_SCHED_H_
#include
<generated/autoconf.h>
/*XXX */
#include
<list.h>
#include
<kernel/time.h>
#include
<generated/autoconf.h>
/*XXX */
/* scheduler priority levels */
#define SCHED_PRIORITY_RR 0
...
...
@@ -114,8 +116,6 @@ void switch_to(struct task_struct *next);
void
schedule
(
void
);
void
sched_yield
(
void
);
void
sched_print_edf_list
(
void
);
int
sched_set_attr
(
struct
task_struct
*
task
,
struct
sched_attr
*
attr
);
int
sched_get_attr
(
struct
task_struct
*
task
,
struct
sched_attr
*
attr
);
...
...
This diff is collapsed.
Click to expand it.
init/main.c
+
17
−
126
View file @
7fc3b8b2
...
...
@@ -46,6 +46,8 @@
#endif
/* __OPTIMIZE__ */
#endif
/* GCC_VERSION */
/** XXX dummy **/
extern
int
cpu_ready
[
CONFIG_SMP_CPUS_MAX
];
/**
* @brief kernel initialisation routines
...
...
@@ -63,74 +65,16 @@ static int kernel_init(void)
arch_initcall
(
kernel_init
);
/** XXX dummy **/
extern
int
cpu1_ready
;
volatile
int
xp
;
int
task1
(
void
*
p
)
{
while
(
1
)
{
xp
++
;
}
}
volatile
int
xd
;
int
task2
(
void
*
p
)
{
while
(
1
)
xd
++
;
}
int
task
(
void
*
p
)
{
char
buf1
[
64
];
char
buf2
[
64
];
char
buf3
[
64
];
struct
sysobj
*
sys_irq
=
NULL
;
sys_irq
=
sysset_find_obj
(
sys_set
,
"/sys/irl/primary"
);
if
(
!
sys_irq
)
{
printk
(
"Error locating sysctl entry
\n
"
);
return
-
1
;
}
while
(
1
)
{
sysobj_show_attr
(
sys_irq
,
"irl"
,
buf1
);
sysobj_show_attr
(
sys_irq
,
"8"
,
buf2
);
sysobj_show_attr
(
sys_irq
,
"9"
,
buf3
);
printk
(
"IRQ total: %s timer1: %s timer2: %s, %d %d
\n
"
,
buf1
,
buf2
,
buf3
,
ioread32be
(
&
xp
),
xd
);
sched_yield
();
}
return
0
;
}
/** XXX dummy **/
extern
int
cpu_ready
[
CONFIG_SMP_CPUS_MAX
];
/**
* @brief kernel main functionputchar( *((char *) data) );
*/
int
kernel_main
(
void
)
{
int
i
;
struct
task_struct
*
t
;
struct
sched_attr
attr
;
#if 0
void *addr;
struct elf_module m;
#endif
void
*
addr
__attribute__
((
unused
));
struct
elf_module
m
__attribute__
((
unused
));
printk
(
MSG
"Loading module image
\n
"
);
...
...
@@ -164,26 +108,6 @@ int kernel_main(void)
#endif
#ifdef CONFIG_EMBED_APPLICATION
/* dummy demonstrator */
{
void
*
addr
;
struct
elf_module
m
;
addr
=
module_read_embedded
(
"CrApp1"
);
pr_debug
(
MSG
"test executable address is %p
\n
"
,
addr
);
if
(
addr
)
module_load
(
&
m
,
addr
);
#if 0
modules_list_loaded();
#endif
}
#endif
#ifdef CONFIG_MPPB
/* The mppbv2 LEON's cache would really benefit from cache sniffing...
* Interactions with DMA or Xentiums are a pain when using the lower
...
...
@@ -217,52 +141,19 @@ int kernel_main(void)
printk
(
MSG
"Boot complete
\n
"
);
#ifdef CONFIG_EMBED_APPLICATION
/* dummy demonstrator */
addr
=
module_read_embedded
(
"executable_demo"
);
t
=
kthread_create
(
task
,
NULL
,
KTHREAD_CPU_AFFINITY_NONE
,
"task"
);
if
(
!
IS_ERR
(
t
))
{
sched_get_attr
(
t
,
&
attr
);
attr
.
policy
=
SCHED_EDF
;
attr
.
period
=
ms_to_ktime
(
1000
);
attr
.
deadline_rel
=
ms_to_ktime
(
999
);
attr
.
wcet
=
ms_to_ktime
(
300
);
sched_set_attr
(
t
,
&
attr
);
if
(
kthread_wake_up
(
t
)
<
0
)
printk
(
"---- %s NOT SCHEDUL-ABLE---
\n
"
,
t
->
name
);
}
else
{
printk
(
"Got an error in kthread_create!"
);
}
printk
(
"%s runs on CPU %d
\n
"
,
t
->
name
,
t
->
on_cpu
);
t
=
kthread_create
(
task1
,
NULL
,
KTHREAD_CPU_AFFINITY_NONE
,
"task1"
);
if
(
!
IS_ERR
(
t
))
{
sched_get_attr
(
t
,
&
attr
);
attr
.
policy
=
SCHED_EDF
;
attr
.
period
=
us_to_ktime
(
300
);
attr
.
deadline_rel
=
us_to_ktime
(
200
);
attr
.
wcet
=
us_to_ktime
(
100
);
sched_set_attr
(
t
,
&
attr
);
if
(
kthread_wake_up
(
t
)
<
0
)
printk
(
"---- %s NOT SCHEDUL-ABLE---
\n
"
,
t
->
name
);
}
else
{
printk
(
"Got an error in kthread_create!"
);
}
printk
(
"%s runs on CPU %d
\n
"
,
t
->
name
,
t
->
on_cpu
);
t
=
kthread_create
(
task2
,
NULL
,
KTHREAD_CPU_AFFINITY_NONE
,
"task2"
);
if
(
!
IS_ERR
(
t
))
{
sched_get_attr
(
t
,
&
attr
);
attr
.
policy
=
SCHED_EDF
;
attr
.
period
=
us_to_ktime
(
300
);
attr
.
deadline_rel
=
us_to_ktime
(
200
);
attr
.
wcet
=
us_to_ktime
(
100
);
sched_set_attr
(
t
,
&
attr
);
if
(
kthread_wake_up
(
t
)
<
0
)
printk
(
"---- %s NOT SCHEDUL-ABLE---
\n
"
,
t
->
name
);
}
else
{
printk
(
"Got an error in kthread_create!"
);
}
printk
(
"%s runs on CPU %d
\n
"
,
t
->
name
,
t
->
on_cpu
);
pr_debug
(
MSG
"test executable address is %p
\n
"
,
addr
);
if
(
addr
)
module_load
(
&
m
,
addr
);
#if 0
modules_list_loaded();
#endif
#endif
while
(
1
)
...
...
This diff is collapsed.
Click to expand it.
kernel/kthread.c
+
14
−
0
View file @
7fc3b8b2
...
...
@@ -50,6 +50,20 @@ static void kthread_unlock(void)
}
void
kthread_set_sched_edf
(
struct
task_struct
*
task
,
unsigned
long
period_us
,
unsigned
long
wcet_us
,
unsigned
long
deadline_rel_us
)
{
struct
sched_attr
attr
;
sched_get_attr
(
task
,
&
attr
);
attr
.
policy
=
SCHED_EDF
;
attr
.
period
=
us_to_ktime
(
period_us
);
attr
.
deadline_rel
=
us_to_ktime
(
wcet_us
);
attr
.
wcet
=
us_to_ktime
(
deadline_rel_us
);
sched_set_attr
(
task
,
&
attr
);
}
/* we should have a thread with a semaphore which is unlocked by schedule()
* if dead tasks were added to the "dead" list
*/
...
...
This diff is collapsed.
Click to expand it.
lib/string.c
+
7
−
0
View file @
7fc3b8b2
...
...
@@ -462,8 +462,14 @@ EXPORT_SYMBOL(puts);
int
putchar
(
int
c
)
{
#define TREADY 4
#if defined(CONFIG_LEON3)
static
volatile
int
*
console
=
(
int
*
)
0x80000100
;
#endif
#if defined(CONFIG_LEON4)
static
volatile
int
*
console
=
(
int
*
)
0xFF900000
;
#endif
while
(
!
(
console
[
1
]
&
TREADY
));
console
[
0
]
=
0x0ff
&
c
;
...
...
@@ -479,6 +485,7 @@ int putchar(int c)
/**
* @brief print a string into a buffer
*
...
...
This diff is collapsed.
Click to expand it.
lib/vsnprintf.c
+
0
−
26
View file @
7fc3b8b2
...
...
@@ -58,32 +58,6 @@ struct fmt_spec {
#define TREADY 4
#if defined(CONFIG_LEON3)
static
volatile
int
*
console
=
(
int
*
)
0x80000100
;
#endif
#if defined(CONFIG_LEON4)
static
volatile
int
*
console
=
(
int
*
)
0xFF900000
;
#endif
static
int
putchar
(
int
c
)
{
while
(
!
(
console
[
1
]
&
TREADY
));
console
[
0
]
=
0x0ff
&
c
;
if
(
c
==
'\n'
)
{
while
(
!
(
console
[
1
]
&
TREADY
));
console
[
0
]
=
(
int
)
'\r'
;
}
return
c
;
}
/**
* @brief print a single character
*
...
...
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