From bf50352a26ba8690512fdcbbc4bdbdbfafd886ca Mon Sep 17 00:00:00 2001 From: shkolnick-kun Date: Fri, 3 Jul 2015 10:54:34 +0500 Subject: [PATCH] Backpoerted vsmp from 0.8.x --- arch/avr/gcc-vsmp/vsmp.c | 18 +- arch/avr/gcc-vsmp/vsmp.h | 253 +++++++++--------- .../arch/avr/gcc-vsmp/avr-vsmp-test.workspace | 4 +- tests/arch/avr/gcc-vsmp/ipc/ipc.cbp | 1 + tests/arch/avr/gcc-vsmp/mutex/mutex.cbp | 1 + tests/arch/avr/gcc-vsmp/mutex/mutex.layout | 3 + tests/arch/avr/gcc-vsmp/proc/proc.cbp | 1 + tests/arch/avr/gcc-vsmp/sched/sched.cbp | 1 + tests/arch/avr/gcc-vsmp/sched/sched.layout | 4 +- tests/arch/avr/gcc-vsmp/sem/sem.cbp | 1 + tests/arch/avr/gcc-vsmp/sig/sig.cbp | 1 + 11 files changed, 149 insertions(+), 139 deletions(-) diff --git a/arch/avr/gcc-vsmp/vsmp.c b/arch/avr/gcc-vsmp/vsmp.c index e2e49b9a..40964c83 100644 --- a/arch/avr/gcc-vsmp/vsmp.c +++ b/arch/avr/gcc-vsmp/vsmp.c @@ -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 @@ -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; @@ -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(); @@ -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) { diff --git a/arch/avr/gcc-vsmp/vsmp.h b/arch/avr/gcc-vsmp/vsmp.h index d0e2fd63..797491d2 100644 --- a/arch/avr/gcc-vsmp/vsmp.h +++ b/arch/avr/gcc-vsmp/vsmp.h @@ -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 . - - Please contact with me by E-mail: shkolnick.kun@gmail.com - - 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 . + + Please contact with me by E-mail: shkolnick.kun@gmail.com + + 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_ diff --git a/tests/arch/avr/gcc-vsmp/avr-vsmp-test.workspace b/tests/arch/avr/gcc-vsmp/avr-vsmp-test.workspace index 3983795c..dbb5dc45 100644 --- a/tests/arch/avr/gcc-vsmp/avr-vsmp-test.workspace +++ b/tests/arch/avr/gcc-vsmp/avr-vsmp-test.workspace @@ -1,11 +1,11 @@ - + - + diff --git a/tests/arch/avr/gcc-vsmp/ipc/ipc.cbp b/tests/arch/avr/gcc-vsmp/ipc/ipc.cbp index 29f10a00..a96b6622 100644 --- a/tests/arch/avr/gcc-vsmp/ipc/ipc.cbp +++ b/tests/arch/avr/gcc-vsmp/ipc/ipc.cbp @@ -12,6 +12,7 @@