Skip to content

Commit

Permalink
Backpoerted vsmp from 0.8.x
Browse files Browse the repository at this point in the history
  • Loading branch information
shkolnick-kun committed Jul 3, 2015
1 parent e8cb1a7 commit bf50352
Show file tree
Hide file tree
Showing 11 changed files with 149 additions and 139 deletions.
18 changes: 9 additions & 9 deletions arch/avr/gcc-vsmp/vsmp.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**************************************************************************
BuguRTOS-0.6.x(Bugurt real time operating system)
Copyright (C) 2013 anonimous
BuguRTOS-0.6.x (Bugurt real time operating system)
Copyright (C) 2015 anonimous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -83,9 +83,9 @@ vsmp_vm_t vm_state[MAX_CORES];
stack_t vm_stack[MAX_CORES -1][VM_STACK_SIZE];
stack_t vm_int_stack[MAX_CORES][VM_INT_STACK_SIZE];

core_id_t current_vm;
void * vm_buf;
void (*vsmp_systimer_hook)(void);
volatile core_id_t current_vm;
volatile void * vm_buf;
hook_t vsmp_systimer_hook;



Expand Down Expand Up @@ -191,10 +191,10 @@ chained_vinterrupt_return: \
Local variable is used to call virtual ISR, so wrapper must have two parts.
*/
// Nested part, uses local variables, so compiler generated prologue and epilogue are needed.
static void _vinterrupt_wrapper(void)
void _vinterrupt_wrapper(void)
{
void (*isr)(void);
vm_state[current_vm].int_enabled = (bool_t)0; // Virtual interrupt nesting is not alowed by default.
vm_state[current_vm].int_enabled = (bool_t)0; // Virtual interrupt nesting is not allowed by default.
isr = (void (*)(void))vm_buf;
// After vm-buf read we can reenable real interrupts!
sei();
Expand All @@ -207,10 +207,10 @@ __attribute__ (( naked )) void vinterrupt_wrapper(void)
cli();
// Virtual interrupts are enabled after interrupt processing.
vm_state[current_vm].int_enabled = (bool_t)1;
// Tail recursion, will return to it self entry point untill all virtual interrupts are processed, lol!
// Tail recursion, will return to it self entry point until all virtual interrupts are processed, lol!
_vsmp_interrupt_epilogue();
}
// System timer interrupt, round robbin scheduler.
// System timer interrupt, round robin scheduler.
__attribute__ (( signal, naked )) void SYSTEM_TIMER_ISR(void);
void SYSTEM_TIMER_ISR(void)
{
Expand Down
253 changes: 127 additions & 126 deletions arch/avr/gcc-vsmp/vsmp.h
Original file line number Diff line number Diff line change
@@ -1,133 +1,134 @@
/**************************************************************************
BuguRTOS-0.6.x(Bugurt real time operating system)
Copyright (C) 2013 anonimous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Please contact with me by E-mail: [email protected]
A special exception to the GPL can be applied should you wish to distribute
a combined work that includes BuguRTOS, without being obliged to provide
the source code for any proprietary components. See the file exception.txt
for full details of how and when the exception can be applied.
**************************************************************************/

/*****************************************************************************************
```````````````````````````````..:+oyhdmNNMMMMMMNmmdhyo+:..```````````````````````````````
``````````````````````````.:oydNMMMMMMMMMNNNNNNNNMMMMMMMMMNdy+:.``````````````````````````
```````````````````````:sdNMMMMMNdys+/::----------::/osydNMMMMMNds:```````````````````````
```````````````````.+hNMMMMmho/-..........................-/shmMMMMNh/.```````````````````
````````````````./hNMMMNho:...................................-:ohNMMMNh/`````````````````
``````````````.smMMMNy/-.......:////ss++/+-.......................-+yNMMMmo.``````````````
````````````-sNMMMd+-.....:////:-...-/s::..............+o/-..........-odMMMNs.````````````
``````````.sNMMNh/....................................-o:--............./hMMMNo.``````````
`````````+mMMMh:-........................................-...............-/dMMMm/`````````
```````.yMMMm/...................-::--..................:-........--........+mMMMy.```````
``````:mMMMy-.......................-::-...............-:.........-::........-yMMMd:``````
`````/NMMN+-..................::-.....-:-............../--.........-:/-.......-+NMMN:`````
````+NMMm::o/-..--/+o+o+++++o+osys+//::-::.............:/....-:-::-..-++-.......:NMMN/````
```/NMMm:.-++-+yhs/-`` `dMMMMMmho+:-..............:-/+yho/:/+oyo//o-......./mMMN:```
``-NMMm/....-/--::/o+o+oo+oo++oosyss+smyo/.............:yyho-` smMMddh-......./NMMN.``
`.hMMM/......-++:-.-:oooooooooosyyhhys/...............-+osyyyyysssssooo+ohhs-......+MMMh.`
`+MMMy.......-::/++:-.....-:/++++o+o/--................--/oooo+o++o+++////-y/.......hMMM/`
.mMMN:.........--:---...-::/+//::--.......................--//+//-...-.....+/......./NMMd`
/MMMy............-::----------....----/+-.....................-++/:---....-o-........hMMN:
yMMM/.............--:://///oo+++/+++oo+-.......................-://+/:--::::.........+MMMs
mMMN:................----:/h:::/:/::---.........................--/osss+++:..........:NMMd
MMMd-....................:mNs:-....................................--:odo:-..........:mMMN
MMMd-....................yoshyoso:--................................../mm/...........:mMMM
MMMm:..................../-o/h.y-:+dooo+/:--....................-/osydddmh...........:mMMN
mMMN:........................+mNs `h. -d/:/+h++ooooy+++s++y+++mo+y` yh.do...........:NMMh
sMMM+........................-hmMo/ds oMo`.-o :h s:`h` `Nysd.-Ny-h:...........+MMMo
/MMMh........................./smMMMMd+NMMNNMh` sN: .mNNMddNMMMMNmN+..............hMMN:
.dMMN/........................./+hMMMMMMMMMMMMmhyyyNMNNMMMMMMMMMMMNsoo-............./NMMd`
`+MMMh.........................-/+omMMMMMMMMMMMMMMMMMMMMMMMMMMMMms-/+...............hMMM/`
`.hMMM+..........................:/-omMMMMMMMMMMMMMMMdmMdhMMMds/-..-...............oMMMy``
``.NMMN/............................--/hNN/h.`ys:dmsd:-syos+--+.................../NMMN.``
```/NMMm:...........................:+/--:+s++oo+osoo+/:-..-/+::-................/mMMN:```
````/NMMN:............................-/++/:-..........-//+/-..:+.--............/NMMN/````
`````:NMMN+-.............../+-.............-://////////:-.......+s+::.........-oNMMN:`````
``````:mMMMy-..............:/o-.................................:yo//........-hMMMd-``````
```````.yMMMm+.............:o:++-...............................+y+o-......-+mMMMs.```````
`````````/mMMMd/-...........-++:+/-.---........................-ho+/.....-/dMMMm/`````````
``````````.oNMMMh/............-++:++/////:....................-yo:o-...-+hMMMNo.``````````
````````````.sNMMMdo-...........-++::++:-:/+//:..............:o:/o-..-omMMMNo.````````````
``````````````.omMMMNy+-..........-/+-.:/+/:--:+++/++//:/::/+/-+/.-+hMMMMmo```````````````
`````````````````/hNMMMNho:-...............-:/:-....--::::--..-/ohNMMMNy:`````````````````
```````````````````./hNMMMMmhs/-..........................-/shNMMMMNy/.```````````````````
```````````````````````:sdNMMMMMNdhso+/:----------:/+oshdNMMMMMNho:```````````````````````
``````````````````````````.:+ydNMMMMMMMMMMNNNNNNMMMMMMMMMMmds+:```````````````````````````
````````````````````````````````.:/osyhdmNNMMMMNNmdhyso/:.````````````````````````````````
******************************************************************************************
* *
* This logo was graciously delivered by 10003-kun ITT: *
* *
* http://www.0chan.ru/r/res/9996.html *
* *
*****************************************************************************************/

/**************************************************************************
BuguRTOS-0.6.x (Bugurt real time operating system)
Copyright (C) 2015 anonimous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Please contact with me by E-mail: [email protected]
A special exception to the GPL can be applied should you wish to distribute
a combined work that includes BuguRTOS, without being obliged to provide
the source code for any proprietary components. See the file exception.txt
for full details of how and when the exception can be applied.
**************************************************************************/

/*****************************************************************************************
```````````````````````````````..:+oyhdmNNMMMMMMNmmdhyo+:..```````````````````````````````
``````````````````````````.:oydNMMMMMMMMMNNNNNNNNMMMMMMMMMNdy+:.``````````````````````````
```````````````````````:sdNMMMMMNdys+/::----------::/osydNMMMMMNds:```````````````````````
```````````````````.+hNMMMMmho/-..........................-/shmMMMMNh/.```````````````````
````````````````./hNMMMNho:...................................-:ohNMMMNh/`````````````````
``````````````.smMMMNy/-.......:////ss++/+-.......................-+yNMMMmo.``````````````
````````````-sNMMMd+-.....:////:-...-/s::..............+o/-..........-odMMMNs.````````````
``````````.sNMMNh/....................................-o:--............./hMMMNo.``````````
`````````+mMMMh:-........................................-...............-/dMMMm/`````````
```````.yMMMm/...................-::--..................:-........--........+mMMMy.```````
``````:mMMMy-.......................-::-...............-:.........-::........-yMMMd:``````
`````/NMMN+-..................::-.....-:-............../--.........-:/-.......-+NMMN:`````
````+NMMm::o/-..--/+o+o+++++o+osys+//::-::.............:/....-:-::-..-++-.......:NMMN/````
```/NMMm:.-++-+yhs/-`` `dMMMMMmho+:-..............:-/+yho/:/+oyo//o-......./mMMN:```
``-NMMm/....-/--::/o+o+oo+oo++oosyss+smyo/.............:yyho-` smMMddh-......./NMMN.``
`.hMMM/......-++:-.-:oooooooooosyyhhys/...............-+osyyyyysssssooo+ohhs-......+MMMh.`
`+MMMy.......-::/++:-.....-:/++++o+o/--................--/oooo+o++o+++////-y/.......hMMM/`
.mMMN:.........--:---...-::/+//::--.......................--//+//-...-.....+/......./NMMd`
/MMMy............-::----------....----/+-.....................-++/:---....-o-........hMMN:
yMMM/.............--:://///oo+++/+++oo+-.......................-://+/:--::::.........+MMMs
mMMN:................----:/h:::/:/::---.........................--/osss+++:..........:NMMd
MMMd-....................:mNs:-....................................--:odo:-..........:mMMN
MMMd-....................yoshyoso:--................................../mm/...........:mMMM
MMMm:..................../-o/h.y-:+dooo+/:--....................-/osydddmh...........:mMMN
mMMN:........................+mNs `h. -d/:/+h++ooooy+++s++y+++mo+y` yh.do...........:NMMh
sMMM+........................-hmMo/ds oMo`.-o :h s:`h` `Nysd.-Ny-h:...........+MMMo
/MMMh........................./smMMMMd+NMMNNMh` sN: .mNNMddNMMMMNmN+..............hMMN:
.dMMN/........................./+hMMMMMMMMMMMMmhyyyNMNNMMMMMMMMMMMNsoo-............./NMMd`
`+MMMh.........................-/+omMMMMMMMMMMMMMMMMMMMMMMMMMMMMms-/+...............hMMM/`
`.hMMM+..........................:/-omMMMMMMMMMMMMMMMdmMdhMMMds/-..-...............oMMMy``
``.NMMN/............................--/hNN/h.`ys:dmsd:-syos+--+.................../NMMN.``
```/NMMm:...........................:+/--:+s++oo+osoo+/:-..-/+::-................/mMMN:```
````/NMMN:............................-/++/:-..........-//+/-..:+.--............/NMMN/````
`````:NMMN+-.............../+-.............-://////////:-.......+s+::.........-oNMMN:`````
``````:mMMMy-..............:/o-.................................:yo//........-hMMMd-``````
```````.yMMMm+.............:o:++-...............................+y+o-......-+mMMMs.```````
`````````/mMMMd/-...........-++:+/-.---........................-ho+/.....-/dMMMm/`````````
``````````.oNMMMh/............-++:++/////:....................-yo:o-...-+hMMMNo.``````````
````````````.sNMMMdo-...........-++::++:-:/+//:..............:o:/o-..-omMMMNo.````````````
``````````````.omMMMNy+-..........-/+-.:/+/:--:+++/++//:/::/+/-+/.-+hMMMMmo```````````````
`````````````````/hNMMMNho:-...............-:/:-....--::::--..-/ohNMMMNy:`````````````````
```````````````````./hNMMMMmhs/-..........................-/shNMMMMNy/.```````````````````
```````````````````````:sdNMMMMMNdhso+/:----------:/+oshdNMMMMMNho:```````````````````````
``````````````````````````.:+ydNMMMMMMMMMMNNNNNNMMMMMMMMMMmds+:```````````````````````````
````````````````````````````````.:/osyhdmNNMMMMNNmdhyso/:.````````````````````````````````
******************************************************************************************
* *
* This logo was graciously delivered by 10003-kun ITT: *
* *
* http://www.0chan.ru/r/res/9996.html *
* *
*****************************************************************************************/

#ifndef _VSMP_H_
#define _VSMP_H_

#include "../../../include/bugurt.h"


#include "../../../include/bugurt.h"

extern stack_t * bugurt_save_context( void );
extern void bugurt_restore_context( stack_t * new_sp );
extern void bugurt_restore_context( stack_t * new_sp );
extern void bugurt_pop_context(void);
extern void bugurt_set_stack_pointer( stack_t * new_sp );
extern void bugurt_push_pointer( void * pointer );
extern void bugurt_set_stack_pointer( stack_t * new_sp );
extern void bugurt_push_pointer( void * pointer );
extern stack_t * bugurt_reverse_byte_order ( stack_t * arg );

typedef struct _vsmp_vm_t vsmp_vm_t;
struct _vsmp_vm_t
{
item_t * int_fifo; // Virtual interrupt fifo;
bool_t int_enabled;// Virtual interrupts enabled flag;
count_t int_nest_count;
stack_t * sp; // VM stack pointer
stack_t * int_sp; // VM virtual interrupt stack pointer
};

typedef struct _vinterrupt_t vinterrupt_t;
struct _vinterrupt_t
{
item_t parent;
count_t num_pending;
void (*isr)(void); // Virtual Interrupt Service Routine
};

vsmp_vm_t vm_state[MAX_CORES];
stack_t vm_stack[MAX_CORES -1][VM_STACK_SIZE];
stack_t vm_int_stack[MAX_CORES][VM_INT_STACK_SIZE];
core_id_t current_vm;
void * vm_buf;
void (*vsmp_systimer_hook)(void);

#define VINTERRUPT_INIT(v, f) { INIT_ITEM_T(v), (count_t)0, f }

void vsmp_vm_init( vsmp_vm_t * vm, stack_t * sp, stack_t * int_sp );

void vsmp_init( void );
void vsmp_run( void );

void vsmp_idle_main( void * arg );

void _vsmp_vinterrupt(void);
void vsmp_vinterrupt_init( vinterrupt_t * vector, void (*isr)(void) );
bool_t vsmp_vinterrupt_isr( core_id_t vm, vinterrupt_t * vector );
void vsmp_vinterrupt( core_id_t vm, vinterrupt_t * vector );

void vinterrupt_wrapper(void);

typedef struct _vsmp_vm_t vsmp_vm_t;
struct _vsmp_vm_t
{
volatile item_t * int_fifo; // Virtual interrupt fifo;
volatile bool_t int_enabled;// Virtual interrupts enabled flag;
volatile count_t int_nest_count;
stack_t * sp; // VM stack pointer
stack_t * int_sp; // VM virtual interrupt stack pointer
};

typedef struct _vinterrupt_t vinterrupt_t;
struct _vinterrupt_t
{
item_t parent;
count_t num_pending;
void (*isr)(void); // Virtual Interrupt Service Routine
};

vsmp_vm_t vm_state[MAX_CORES];
stack_t vm_stack[MAX_CORES -1][VM_STACK_SIZE];
stack_t vm_int_stack[MAX_CORES][VM_INT_STACK_SIZE];
volatile core_id_t current_vm;
volatile void * vm_buf;
typedef void (*hook_t)(void);
hook_t vsmp_systimer_hook;

#define VINTERRUPT_INIT(v, f) { INIT_ITEM_T(v), (count_t)0, f }

void vsmp_vm_init( vsmp_vm_t * vm, stack_t * sp, stack_t * int_sp );

void vsmp_init( void );
void vsmp_run( void );

void vsmp_idle_main( void * arg );

void _vsmp_vinterrupt(void);
void vsmp_vinterrupt_init( vinterrupt_t * vector, void (*isr)(void) );
bool_t vsmp_vinterrupt_isr( core_id_t vm, vinterrupt_t * vector );
void vsmp_vinterrupt( core_id_t vm, vinterrupt_t * vector );

void vinterrupt_wrapper(void);
bool_t vsmp_do_interrupt(void);
#endif // _VSMP_H_
4 changes: 2 additions & 2 deletions tests/arch/avr/gcc-vsmp/avr-vsmp-test.workspace
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_workspace_file>
<Workspace title="Workspace">
<Project filename="sched/sched.cbp" />
<Project filename="sched/sched.cbp" active="1" />
<Project filename="proc/proc.cbp" />
<Project filename="sig/sig.cbp" />
<Project filename="ipc/ipc.cbp" />
<Project filename="sem/sem.cbp" active="1" />
<Project filename="sem/sem.cbp" />
<Project filename="mutex/mutex.cbp" />
</Workspace>
</CodeBlocks_workspace_file>
1 change: 1 addition & 0 deletions tests/arch/avr/gcc-vsmp/ipc/ipc.cbp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<Option type="1" />
<Option compiler="avrgcc" />
<Compiler>
<Add option="-Os" />
<Add option="-g" />
</Compiler>
</Target>
Expand Down
1 change: 1 addition & 0 deletions tests/arch/avr/gcc-vsmp/mutex/mutex.cbp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<Option type="1" />
<Option compiler="avrgcc" />
<Compiler>
<Add option="-Os" />
<Add option="-g" />
</Compiler>
</Target>
Expand Down
3 changes: 3 additions & 0 deletions tests/arch/avr/gcc-vsmp/mutex/mutex.layout
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
<File name="../../../../../arch/avr/gcc-vsmp/vsmp.c" open="0" top="0" tabpos="0">
<Cursor position="11753" topLine="237" />
</File>
<File name="../../../../../arch/avr/gcc-vsmp/vsmp.h" open="0" top="0" tabpos="0">
<Cursor position="6148" topLine="103" />
</File>
<File name="../../../../../include/mutex.h" open="0" top="0" tabpos="0">
<Cursor position="0" topLine="111" />
</File>
Expand Down
1 change: 1 addition & 0 deletions tests/arch/avr/gcc-vsmp/proc/proc.cbp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<Option type="1" />
<Option compiler="avrgcc" />
<Compiler>
<Add option="-Os" />
<Add option="-g" />
<Add option="-O0" />
</Compiler>
Expand Down
1 change: 1 addition & 0 deletions tests/arch/avr/gcc-vsmp/sched/sched.cbp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<Option type="1" />
<Option compiler="avrgcc" />
<Compiler>
<Add option="-Os" />
<Add option="-g" />
</Compiler>
</Target>
Expand Down
4 changes: 2 additions & 2 deletions tests/arch/avr/gcc-vsmp/sched/sched.layout
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
<File name="../../../../../arch/avr/gcc-vsmp/bugurt_kernel.h" open="0" top="0" tabpos="0">
<Cursor position="94" topLine="1" />
</File>
<File name="../../../../../arch/avr/gcc-vsmp/vsmp.c" open="1" top="0" tabpos="3">
<File name="../../../../../arch/avr/gcc-vsmp/vsmp.c" open="1" top="0" tabpos="1">
<Cursor position="9560" topLine="162" />
</File>
<File name="../../../../../arch/avr/gcc-vsmp/vsmp.h" open="0" top="0" tabpos="4">
<File name="../../../../../arch/avr/gcc-vsmp/vsmp.h" open="1" top="0" tabpos="4">
<Cursor position="6322" topLine="78" />
</File>
<File name="../../../../../arch/avr/gcc/bugurt_kernel_asm.S" open="0" top="0" tabpos="0">
Expand Down
1 change: 1 addition & 0 deletions tests/arch/avr/gcc-vsmp/sem/sem.cbp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<Option type="1" />
<Option compiler="avrgcc" />
<Compiler>
<Add option="-Os" />
<Add option="-g" />
</Compiler>
</Target>
Expand Down
1 change: 1 addition & 0 deletions tests/arch/avr/gcc-vsmp/sig/sig.cbp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<Option type="1" />
<Option compiler="avrgcc" />
<Compiler>
<Add option="-Os" />
<Add option="-g" />
</Compiler>
</Target>
Expand Down

0 comments on commit bf50352

Please sign in to comment.