/demos/tags/rel_1_22/servo/initfile.c |
File deleted |
|
Property changes: |
Deleted: svn:executable |
## -1 +0,0 ## |
-* |
\ No newline at end of property |
Index: tags/rel_1_22/servo/ctrl.c |
=================================================================== |
--- tags/rel_1_22/servo/ctrl.c (revision 1310) |
+++ tags/rel_1_22/servo/ctrl.c (nonexistent) |
@@ -1,294 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: Giorgio Buttazzo <giorgio@sssup.it> |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include "kernel/kern.h" |
-#include "drivers/keyb.h" |
- |
-#include "servo.h" |
- |
-int main () { |
- |
- int res; |
- char ch; |
- |
- servo_open(COM2, 19200); |
- |
- /*cprintf("servo_set_RS232_baudrate\n"); |
- res = servo_set_RS232_baudrate(COM2, 115200); |
- cprintf("Res = %d\n",res);*/ |
- |
- cprintf("servo_get_RS232_baudrate\n"); |
- res = servo_get_RS232_baudrate(COM2); |
- cprintf("Res = %d\n",res); |
- |
- /*cprintf("servo_store_RS232_baudrate\n"); |
- res = servo_store_RS232_baudrate(COM2); |
- cprintf("Res = %d\n\n",res);*/ |
- |
- ch = keyb_getch(BLOCK); |
- |
- |
- cprintf("servo_set_period\n"); |
- res = servo_set_period(COM2, 20000); |
- cprintf("Res = %d\n",res); |
- |
- cprintf("servo_get_period\n"); |
- res = servo_get_period(COM2); |
- cprintf("Res = %d\n",res); |
- |
- /*cprintf("servo_store_period\n"); |
- res = servo_store_period(COM2); |
- cprintf("Res = %d\n\n",res);*/ |
- |
- ch = keyb_getch(BLOCK); |
- |
- |
- cprintf("servo_get_setup_switch\n"); |
- res = servo_get_setup_switch(COM2); |
- cprintf("Res = %d\n",res); |
- |
- cprintf("servo_set_RC5_switch\n"); |
- res = servo_set_RC5_switch(COM2, 1); |
- cprintf("Res = %d\n\n",res); |
- |
- ch = keyb_getch(BLOCK); |
- |
- |
- cprintf("servo_set_levels\n"); |
- res = servo_set_levels(COM2, 0x00,0x01); |
- cprintf("Res = %d\n",res); |
- |
- cprintf("servo_get_levels\n"); |
- res = servo_get_levels(COM2, 1); |
- cprintf("Res = %d\n\n",res); |
- |
- ch = keyb_getch(BLOCK); |
- |
- cprintf("servo_turn_off\n"); |
- res = servo_turn_off(COM2, 1); |
- cprintf("Res = %d\n\n",res); |
- |
- ch = keyb_getch(BLOCK); |
- |
- cprintf("servo_turn_on\n"); |
- res = servo_turn_on(COM2, 1); |
- cprintf("Res = %d\n\n",res); |
- |
- ch = keyb_getch(BLOCK); |
- |
- cprintf("servo_turn_off_all\n"); |
- res = servo_turn_off_all(COM2); |
- cprintf("Res = %d\n\n",res); |
- |
- ch = keyb_getch(BLOCK); |
- |
- cprintf("servo_turn_on_all\n"); |
- res = servo_turn_on_all(COM2); |
- cprintf("Res = %d\n\n",res); |
- |
- ch = keyb_getch(BLOCK); |
- |
- /*cprintf("servo_store_levels\n"); |
- res = servo_store_levels(COM2); |
- cprintf("Res = %d\n\n",res); |
- |
- ch = keyb_getch(BLOCK);*/ |
- |
- |
- cprintf("servo_get_analog\n"); |
- res = servo_get_analog(COM2, 0); |
- cprintf("Res = %d\n\n",res); |
- |
- ch = keyb_getch(BLOCK); |
- |
- |
- cprintf("servo_set_angle_sec\n"); |
- res = servo_set_angle_sec(COM2, 0,ANGLE2SEC(45,0,0)); |
- cprintf("Res = %d\n",res); |
- |
- cprintf("servo_get_angle_sec\n"); |
- res = servo_get_angle_sec(COM2, 0); |
- cprintf("Res = %d\n\n",res); |
- |
- ch = keyb_getch(BLOCK); |
- |
-/*----------------------------------------- */ |
- |
- cprintf("servo_set_angle_sec\n"); |
- res = servo_set_angle_sec(COM2, 0,ANGLE2SEC(0,0,0)); |
- cprintf("Res = %d\n",res); |
- /*cprintf("servo_store_default_position\n"); |
- res = servo_store_default_position(COM2, 0); |
- cprintf("Res = %d\n",res); |
- |
- ch = keyb_getch(BLOCK); */ |
- |
- cprintf("servo_set_angle_sec\n"); |
- res = servo_set_angle_sec(COM2, 1,ANGLE2SEC(0,0,0)); |
- cprintf("Res = %d\n",res); |
- /*cprintf("servo_store_default_position\n"); |
- res = servo_store_default_position(COM2, 0); |
- cprintf("Res = %d\n",res); |
- |
- ch = keyb_getch(BLOCK); */ |
- |
- cprintf("servo_set_angle_sec\n"); |
- res = servo_set_angle_sec(COM2, 2,ANGLE2SEC(0,0,0)); |
- cprintf("Res = %d\n",res); |
- /*cprintf("servo_store_default_position\n"); |
- res = servo_store_default_position(COM2, 2); |
- cprintf("Res = %d\n",res); |
- |
- ch = keyb_getch(BLOCK); */ |
- |
- cprintf("servo_set_angle_sec\n"); |
- res = servo_set_angle_sec(COM2, 3,ANGLE2SEC(0,0,0)); |
- cprintf("Res = %d\n",res); |
- /*cprintf("servo_store_default_position\n"); |
- res = servo_store_default_position(COM2, 3); |
- cprintf("Res = %d\n",res); |
- |
- ch = keyb_getch(BLOCK); */ |
- |
- cprintf("servo_set_angle_sec\n"); |
- res = servo_set_angle_sec(COM2, 4,ANGLE2SEC(0,0,0)); |
- cprintf("Res = %d\n",res); |
- /*cprintf("servo_store_default_position\n"); |
- res = servo_store_default_position(COM2, 4); |
- cprintf("Res = %d\n",res); |
- |
- ch = keyb_getch(BLOCK); */ |
- |
- cprintf("servo_set_angle_sec\n"); |
- res = servo_set_angle_sec(COM2, 5,ANGLE2SEC(0,0,0)); |
- cprintf("Res = %d\n",res); |
- /*cprintf("servo_store_default_position\n"); |
- res = servo_store_default_position(COM2, 5); |
- cprintf("Res = %d\n",res); |
- |
- ch = keyb_getch(BLOCK); */ |
- |
- cprintf("servo_set_angle_sec\n"); |
- res = servo_set_angle_sec(COM2, 6,ANGLE2SEC(0,0,0)); |
- cprintf("Res = %d\n",res); |
- /*cprintf("servo_store_default_position\n"); |
- res = servo_store_default_position(COM2, 6); |
- cprintf("Res = %d\n",res); |
- |
- ch = keyb_getch(BLOCK); */ |
- |
- cprintf("servo_set_angle_sec\n"); |
- res = servo_set_angle_sec(COM2, 7,ANGLE2SEC(0,0,0)); |
- cprintf("Res = %d\n",res); |
- /*cprintf("servo_store_default_position\n"); |
- res = servo_store_default_position(COM2, 7); |
- cprintf("Res = %d\n",res); |
- |
- ch = keyb_getch(BLOCK);*/ |
- |
- cprintf("servo_set_angle_sec\n"); |
- res = servo_set_angle_sec(COM2, 8,ANGLE2SEC(0,0,0)); |
- cprintf("Res = %d\n",res); |
- /*cprintf("servo_store_default_position\n"); |
- res = servo_store_default_position(COM2, 8); |
- cprintf("Res = %d\n",res); |
- |
- ch = keyb_getch(BLOCK);*/ |
- |
- cprintf("servo_set_angle_sec\n"); |
- res = servo_set_angle_sec(COM2, 9,ANGLE2SEC(0,0,0)); |
- cprintf("Res = %d\n",res); |
- /*cprintf("servo_store_default_position\n"); |
- res = servo_store_default_position(COM2, 9); |
- cprintf("Res = %d\n",res); |
- |
- ch = keyb_getch(BLOCK);*/ |
- |
- cprintf("servo_set_angle_sec\n"); |
- res = servo_set_angle_sec(COM2, 10,ANGLE2SEC(0,0,0)); |
- cprintf("Res = %d\n",res); |
- /*cprintf("servo_store_default_position\n"); |
- res = servo_store_default_position(COM2, 10); |
- cprintf("Res = %d\n",res); |
- |
- ch = keyb_getch(BLOCK);*/ |
- |
- cprintf("servo_set_angle_sec\n"); |
- res = servo_set_angle_sec(COM2, 11,ANGLE2SEC(0,0,0)); |
- cprintf("Res = %d\n",res); |
- /*cprintf("servo_store_default_position\n"); |
- res = servo_store_default_position(COM2, 11); |
- cprintf("Res = %d\n",res); |
- |
- ch = keyb_getch(BLOCK);*/ |
- |
- cprintf("servo_set_angle_sec\n"); |
- res = servo_set_angle_sec(COM2, 12,ANGLE2SEC(0,0,0)); |
- cprintf("Res = %d\n",res); |
- /*cprintf("servo_store_default_position\n"); |
- res = servo_store_default_position(COM2, 12); |
- cprintf("Res = %d\n",res); |
- |
- ch = keyb_getch(BLOCK);*/ |
- |
- cprintf("servo_set_angle_sec\n"); |
- res = servo_set_angle_sec(COM2, 13,ANGLE2SEC(0,0,0)); |
- cprintf("Res = %d\n",res); |
- /*cprintf("servo_store_default_position\n"); |
- res = servo_store_default_position(COM2, 13); |
- cprintf("Res = %d\n",res); |
- |
- ch = keyb_getch(BLOCK);*/ |
- |
- cprintf("servo_set_angle_sec\n"); |
- res = servo_set_angle_sec(COM2, 14,ANGLE2SEC(0,0,0)); |
- cprintf("Res = %d\n",res); |
- /*cprintf("servo_store_default_position\n"); |
- res = servo_store_default_position(COM2, 14); |
- cprintf("Res = %d\n",res); |
- |
- ch = keyb_getch(BLOCK);*/ |
- |
- cprintf("servo_set_angle_sec\n"); |
- res = servo_set_angle_sec(COM2, 15,ANGLE2SEC(0,0,0)); |
- cprintf("Res = %d\n",res); |
- /*cprintf("servo_store_default_position\n"); |
- res = servo_store_default_position(COM2, 15); |
- cprintf("Res = %d\n",res); |
- |
- ch = keyb_getch(BLOCK);*/ |
- |
- servo_close(COM2); |
- |
- return 0; |
- |
-} |
- |
Index: tags/rel_1_22/servo/leg.c |
=================================================================== |
--- tags/rel_1_22/servo/leg.c (revision 1310) |
+++ tags/rel_1_22/servo/leg.c (nonexistent) |
@@ -1,63 +0,0 @@ |
-#include <kernel/kern.h> |
-#include <math.h> |
- |
-#include "servo.h" |
- |
-#define LEG_A 10.0 |
-#define LEG_B 10.0 |
- |
-const double c0 = LEG_A * LEG_A; |
-const double c1 = LEG_A * LEG_A - LEG_B * LEG_B; |
-const double todeg = 180.0 / PI; |
- |
-int set_leg_position(double px, double py, double pz) |
-{ |
- |
- double px2 = px * px; |
- double py2 = py * py; |
- double pz2 = pz * pz; |
- |
- double pxz2 = pz2 + px2; |
- double gamma1 = asin(pz/sqrt(pxz2)) * todeg; |
- |
- double s = pxz2 + py2; |
- double k = c1 + s; |
- double k2 = k * k; |
- |
- double delta_xy = py2 * k2 - s * (k2 - 4.0 * pxz2 * c0); |
- double y1,dsqrt; |
- double alfa1,beta1,alfa2,beta2; |
- int alfa = 0, beta = 0, gamma = 0; |
- |
- if (delta_xy >= 0.0) { |
- dsqrt = sqrt(delta_xy); |
- y1 = (py * k + dsqrt) / (2.0 * s); |
- alfa1 = asin(y1/LEG_A) * todeg; |
- beta1 = asin((y1 - py)/LEG_B) * todeg + alfa1; |
- y1 = (py * k - dsqrt) / (2.0 * s); |
- alfa2 = asin(y1/LEG_A) * todeg; |
- beta2 = asin((y1 - py)/LEG_B) * todeg + alfa2; |
- cprintf("Alfa1 = %d Beta1 = %d\n",(int)alfa1,(int)beta1); |
- cprintf("Alfa2 = %d Beta2 = %d\n",(int)alfa2,(int)beta2); |
- if ((alfa1 >= -90.0 && alfa1 <= 90.0) && (beta1 >= 0.0 && beta1 <= 180.0)) { |
- alfa = (int)(alfa1 * 3600.0); |
- beta = (int)(beta1 * 3600.0); |
- gamma = (int)(gamma1 * 3600.0); |
- cprintf("Alfa Sec = %d Beta Sec = %d Gamma Sec = %d\n",alfa,beta,gamma); |
- return 0; |
- } else if ((alfa2 >= -90.0 && alfa2 <= 90.0) && (beta2 >= 0.0 && beta2 <= 180.0)) { |
- alfa = (int)(alfa2 * 3600.0); |
- beta = (int)(beta2 * 3600.0); |
- gamma = (int)(gamma1 * 3600.0); |
- cprintf("Alfa Sec = %d Beta Sec = %d Gamma Sec = %d\n",alfa,beta,gamma); |
- return 0; |
- } else { |
- cprintf("No possible !\n"); |
- return 1; |
- } |
- } else { |
- cprintf("No possible !\n"); |
- return 1; |
- } |
- |
-} |
Index: tags/rel_1_22/servo/README |
=================================================================== |
--- tags/rel_1_22/servo/README (revision 1310) |
+++ tags/rel_1_22/servo/README (nonexistent) |
@@ -1,2 +0,0 @@ |
-TODO |
- |
Index: tags/rel_1_22/servo/leg.h |
=================================================================== |
--- tags/rel_1_22/servo/leg.h (revision 1310) |
+++ tags/rel_1_22/servo/leg.h (nonexistent) |
@@ -1,6 +0,0 @@ |
-#ifndef __LEG_H__ |
-#define __LEG_H__ |
- |
-int set_leg_position(double px, double py, double pz); |
- |
-#endif |
Index: tags/rel_1_22/servo/makefile |
=================================================================== |
--- tags/rel_1_22/servo/makefile (revision 1310) |
+++ tags/rel_1_22/servo/makefile (nonexistent) |
@@ -1,18 +0,0 @@ |
-# |
-# |
-# |
- |
-ifndef BASE |
-BASE=../.. |
-endif |
-include $(BASE)/config/config.mk |
- |
-PROGS = ctrl load |
- |
-include $(BASE)/config/example.mk |
- |
-ctrl: |
- make -f $(SUBMAKE) APP=ctrl INIT= OTHEROBJS="initfile.o" OTHERINCL= SHARKOPT="__OLDCHAR__ __SERVO__" |
- |
-load: |
- make -f $(SUBMAKE) APP=load INIT= OTHEROBJS="initfile.o" OTHERINCL= SHARKOPT="__OLDCHAR__ __SERVO__" |
/tags/rel_1_22/servo/makefile |
Property changes: |
Deleted: svn:executable |
## -1 +0,0 ## |
-* |
\ No newline at end of property |
Index: tags/rel_1_22/telesco/makefile |
=================================================================== |
--- tags/rel_1_22/telesco/makefile (revision 1310) |
+++ tags/rel_1_22/telesco/makefile (nonexistent) |
@@ -1,16 +0,0 @@ |
-# |
-# |
-# |
- |
-ifndef BASE |
-BASE=../.. |
-endif |
-include $(BASE)/config/config.mk |
- |
-PROGS= tel |
- |
-include $(BASE)/config/example.mk |
- |
-tel: |
- make -f $(SUBMAKE) APP=tel INIT= OTHEROBJS="initfile.o" OTHERINCL= SHARKOPT="__OLDCHAR__ __GRX__" |
- |
Index: tags/rel_1_22/telesco/moon.h |
=================================================================== |
--- tags/rel_1_22/telesco/moon.h (revision 1310) |
+++ tags/rel_1_22/telesco/moon.h (nonexistent) |
@@ -1,43 +0,0 @@ |
-// Immagine luna |
-BYTE luna[900]={ |
-0, 0 , 0, 0, 0, 0, 0, 0, 4, 57, 212, 228, 204, 214, 235, 237, 208, 190, 179, 197, 229, 89, 4, 0, |
-0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 208, 213, 178, 155, 139, 129, 123, 169, 170, 173, 157, |
-191, 209, 236, 215, 5, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 36, 103, 146, 116, 93, 143, 119, 96, |
-134, 123, 117, 120, 113, 102, 93, 156, 210, 184, 66, 4, 0, 0, 0, 0, 0, 0, 0, 0, 2, 64, 83, 88, |
-72, 156, 144, 127, 99, 87, 91, 156, 158, 124, 144, 120, 109, 119, 175, 167, 180, 119, 3, 0, |
-0, 0, 0, 0, 0, 5, 56, 59, 63, 58, 138, 104, 71, 46, 55, 68, 79, 89, 172, 146, 141, 152, 110, 126, |
-134, 179, 148, 145, 134, 4, 0, 0, 0, 0, 4, 32, 58, 50, 49, 56, 105, 58, 38, 42, 45, 69, 64, 93, |
-144, 155, 157, 147, 95, 111, 122, 158, 162, 174, 171, 79, 4, 0, 0, 0, 4, 67, 49, 47, 54, 63, |
-51, 55, 43, 38, 48, 62, 55, 86, 89, 145, 92, 60, 99, 72, 97, 130, 184, 169, 195, 171, 3, 0, 0, |
-3, 77, 52, 37, 51, 72, 54, 63, 48, 46, 46, 48, 55, 54, 92, 95, 80, 55, 47, 47, 52, 56, 170, 187, |
-196, 190, 177, 190, 6, 0, 45, 84, 38, 40, 79, 73, 56, 43, 41, 46, 45, 51, 74, 98, 89, 68, 89, |
-46, 40, 48, 45, 38, 171, 176, 152, 165, 133, 157, 107, 3, 154, 42, 34, 42, 68, 66, 47, 52, 62, |
-55, 60, 50, 56, 50, 106, 127, 74, 38, 39, 58, 38, 42, 116, 87, 128, 148, 69, 59, 170, 2, 100, |
-41, 31, 38, 41, 53, 53, 62, 63, 64, 62, 65, 63, 58, 105, 71, 60, 57, 44, 43, 38, 36, 81, 58, 125, |
-205, 61, 43, 130, 37, 88, 39, 31, 33, 43, 52, 76, 66, 97, 116, 101, 96, 90, 56, 76, 47, 43, 135, |
-46, 87, 40, 30, 33, 37, 84, 152, 86, 43, 131, 81, 131, 36, 35, 33, 36, 53, 91, 73, 124, 145, |
-132, 95, 80, 50, 45, 45, 35, 49, 70, 59, 32, 30, 30, 30, 39, 75, 158, 92, 133, 138, 151, 41, |
-39, 38, 39, 82, 125, 59, 89, 98, 84, 64, 68, 40, 104, 107, 85, 78, 115, 75, 34, 43, 39, 36, 47, |
-78, 98, 142, 104, 122, 155, 49, 32, 36, 32, 57, 71, 58, 85, 97, 69, 49, 53, 40, 88, 124, 133, |
-169, 141, 94, 40, 40, 46, 53, 52, 81, 49, 77, 107, 122, 146, 79, 31, 38, 31, 37, 37, 51, 64, |
-59, 84, 72, 64, 96, 88, 132, 153, 158, 154, 149, 140, 109, 77, 125, 120, 54, 51, 59, 123, 86, |
-111, 122, 35, 44, 35, 34, 38, 63, 55, 55, 87, 76, 103, 133, 148, 146, 160, 151, 145, 163, 194, |
-92, 104, 136, 109, 54, 46, 65, 123, 53, 160, 144, 56, 46, 41, 39, 39, 91, 41, 47, 70, 75, 57, |
-112, 116, 140, 168, 179, 161, 164, 188, 123, 100, 145, 162, 87, 51, 111, 140, 5, 172, 148, |
-134, 86, 72, 75, 48, 50, 40, 45, 53, 106, 60, 108, 137, 135, 160, 157, 152, 169, 179, 191, |
-109, 70, 150, 122, 94, 104, 128, 4, 167, 144, 140, 103, 98, 116, 64, 56, 84, 62, 60, 59, 48, |
-80, 150, 143, 151, 187, 161, 147, 178, 219, 79, 69, 163, 132, 87, 108, 128, 0, 83, 195, 195, |
-125, 138, 67, 35, 106, 98, 90, 58, 44, 60, 131, 161, 152, 178, 157, 149, 164, 164, 177, 107, |
-119, 129, 119, 145, 133, 104, 0, 5, 181, 233, 190, 150, 78, 43, 62, 63, 87, 50, 53, 46, 81, |
-157, 187, 155, 181, 189, 145, 166, 211, 170, 137, 166, 189, 188, 164, 5, 0, 0, 5, 167, 175, |
-193, 193, 108, 114, 63, 118, 139, 125, 130, 202, 209, 221, 213, 180, 172, 201, 170, 175, |
-186, 177, 210, 236, 204, 14, 0, 0, 0, 3, 62, 166, 183, 166, 106, 139, 102, 129, 179, 206, 212, |
-240, 232, 224, 210, 208, 196, 173, 179, 177, 186, 191, 227, 185, 100, 2, 0, 0, 0, 0, 5, 125, |
-196, 143, 163, 169, 169, 152, 181, 212, 239, 241, 237, 234, 217, 180, 206, 188, 199, 188, |
-194, 202, 164, 120, 4, 0, 0, 0, 0, 0, 0, 5, 123, 180, 145, 147, 184, 184, 197, 223, 232, 224, |
-227, 227, 220, 190, 179, 192, 192, 197, 204, 165, 120, 4, 0, 0, 0, 0, 0, 0, 0, 0, 5, 74, 162, |
-135, 153, 176, 178, 204, 235, 232, 235, 231, 212, 201, 190, 189, 196, 202, 189, 70, 4, 0, |
-0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 5, 182, 167, 170, 184, 208, 218, 215, 206, 209, 179, 205, 196, 188, |
-184, 193, 12, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 103, 202, 197, 201, 208, 235, 217, 203, |
-197, 188, 185, 217, 131, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 5, 89, 130, 218, |
-195, 179, 165, 102, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0}; |
Index: tags/rel_1_22/telesco/initfile.c |
=================================================================== |
--- tags/rel_1_22/telesco/initfile.c (revision 1310) |
+++ tags/rel_1_22/telesco/initfile.c (nonexistent) |
@@ -1,133 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- ------------ |
- CVS : $Id: initfile.c,v 1.1 2003-06-04 09:41:01 giacomo Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1 $ |
- Last update: $Date: 2003-06-04 09:41:01 $ |
- ------------ |
- |
- System initialization file |
- |
- This file contains the 2 functions needed to initialize the system. |
- |
- These functions register the following levels: |
- |
- an EDF (Earliest Deadline First) level |
- a RR (Round Robin) level |
- a CBS (Costant Bandwidth Server) level |
- a Dummy level |
- |
- It can accept these task models: |
- |
- HARD_TASK_MODEL (wcet+mit) at level 0 |
- SOFT_TASK_MODEL (met, period) at level 1 |
- NRT_TASK_MODEL at level 2 |
- |
- This file is similar to the configuration of kernel/init/hartik3.c |
- |
- TICK is set to 0 (one-shot timer is used) |
-*/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/cbs.h" |
-#include "modules/rr.h" |
-#include "modules/dummy.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
- |
-#include "drivers/keyb.h" |
- |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 0 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 10000 |
- |
-int argc; |
-char *argv[100]; |
- |
-void read_cfg_file(int argc, char **argv); |
- |
-int main(int argc, char **argv); |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- EDF_register_level(EDF_ENABLE_ALL); |
- CBS_register_level(CBS_ENABLE_ALL, 0); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- |
- CABS_register_module(); |
- |
- __compute_args__(mb, &argc, argv); |
- |
- read_cfg_file(argc, argv); |
- |
- //read_cfg_file(argc, argv); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- KEYB_PARMS kparms = BASE_KEYB; |
- |
- HARTPORT_init(); |
- |
- keyb_def_ctrlC(kparms, NULL); |
- keyb_def_map(kparms,itaMap); |
- KEYB_init(&kparms); |
- |
- //__call_main__(mb); |
- return (void *)main(argc,argv); |
- //return (void *)0; |
-} |
- |
Index: tags/rel_1_22/telesco/tel.c |
=================================================================== |
--- tags/rel_1_22/telesco/tel.c (revision 1310) |
+++ tags/rel_1_22/telesco/tel.c (nonexistent) |
@@ -1,709 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Bera Marco mbera@libero.it |
- * Varasio Gabriele varasio@odino.unipv.it |
- * |
- * Universita' degli studi di Pavia |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: tel.c,v 1.1 2003-06-04 09:41:01 giacomo Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1 $ |
- Last update: $Date: 2003-06-04 09:41:01 $ |
- ------------ |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai and Giorgio Buttazzo |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-/****************************************************************/ |
-/* PERIODIC PROCESS TEST */ |
-/****************************************************************/ |
- |
-#include <ll/i386/x-dos.h> |
-#include <kernel/kern.h> |
-#include <modules/cabs.h> |
-#include <drivers/glib.h> |
-#include <drivers/keyb.h> |
-#include <math.h> |
-#include <semaphore.h> |
-#include <stdlib.h> |
-#include "moon.h" |
- |
- |
-#define N_MAX_TELESCOPI 5 |
-#define X0 10 |
-#define pi 3.14 |
-#define ex 2.71 |
-#define NCAB N_MAX_TELESCOPI+1 |
-#define dim_msg 8 |
-#define dim_x 49 |
-#define dim_y 49 |
-#define radius 9 |
-#define Y_TELESCOPI 300 |
-/* task periods */ |
-#define PERIOD_T1 80000 |
-#define PERIOD_T4 100000 |
-#define PERIOD_T5 100000 |
-#define WCET_T 5000 |
-int period_t1=0; |
-#define SOGLIA 8 |
- |
-char *cname[NCAB] = {"cab1", "cab2", "cab3", "cab4","cab5","cab6"}; |
- |
-// posizioni dei telescopi e rispettivi poli |
- |
-int x[5] = {100, 200, 300, 400,500}; |
-//double poli[5]={-50,-30,-1, -20, -5}; |
-double poli[5]; |
-// guadagno proporzionale |
-double kp=0.0; |
-// flag per rilevare la pressione del tasto spazio |
-int numero_telescopi=0; |
-int flag=0; |
-KEY_EVT move_tasto; |
-// Immagini ausiliarie per il disegno della luna |
-BYTE lunabkg[900]; |
-BYTE lunadest[900]; |
- |
- |
-/* A semaphore used to access Video Cards in mutual exclusion */ |
-sem_t mutex; |
-sem_t mutex_tasto; |
- |
-/***************************************************************/ |
- |
-// cab necessari allo scambio delle coordinate dell'oggetto e delle |
-// immagini dei rispettivi telescopi |
- |
-CAB cid[NCAB]; |
- |
-// vettori per memorizzare le immagini |
-BYTE videobuf[dim_x*dim_y]; |
-BYTE videobuf1[dim_x*dim_y]; |
-BYTE videobuf2[dim_x*dim_y]; |
-BYTE videobuf3[dim_x*dim_y]; |
-BYTE videobuf4[dim_x*dim_y]; |
-BYTE videobuf5[dim_x*dim_y]; |
- |
- // Variabili per il disegno delle stelle sullo sfondo |
- int num_p; |
- int y_p[7]; |
- int x_p[7]; |
- int dim_p[7]; |
- int col_p[7]; |
- |
- |
- |
-TASK media(void *arg) |
-{ |
-char *p; |
- |
-int i=0; |
-int j=0; |
-while(1) |
-{ |
- p = cab_getmes(cid[1]); |
- memcpy(videobuf,p,dim_x*dim_y*sizeof(BYTE)); |
- cab_unget(cid[1], p); |
- p = cab_getmes(cid[2]); |
- memcpy(videobuf1,p,dim_x*dim_y*sizeof(BYTE)); |
- cab_unget(cid[2], p); |
- p = cab_getmes(cid[3]); |
- memcpy(videobuf2,p,dim_x*dim_y*sizeof(BYTE)); |
- cab_unget(cid[3], p); |
- p = cab_getmes(cid[4]); |
- memcpy(videobuf4,p,dim_x*dim_y*sizeof(BYTE)); |
- cab_unget(cid[4], p); |
- |
- p = cab_getmes(cid[5]); |
- memcpy(videobuf5,p,dim_x*dim_y*sizeof(BYTE)); |
- cab_unget(cid[5], p); |
- |
- // calcolo media |
- |
- for (i=0;i<dim_x;i++) |
- |
- { |
- for(j=0;j<dim_y;j++) |
- { |
- videobuf3[i*dim_x+j]=(double)(videobuf[i*dim_x+j]+videobuf1[i*dim_x+j]+videobuf2[i*dim_x+j]+videobuf4[i*dim_x+j]+videobuf5[i*dim_x+j])/numero_telescopi; |
- } |
- } |
- |
- // visualizza immagine mediata |
- sem_wait(&mutex); |
- grx_putimage(570,10,570+dim_x-1,10+dim_y-1,videobuf3); |
- sem_post(&mutex); |
- task_endcycle(); |
- } |
-} |
- |
-TASK move(void *arg) |
-{ |
-//int i = (int)arg; |
-char *p; |
-int x_object=300; // posizione dell'oggetto da rilevare |
-int y_object=200; |
-// variabile contatore |
-int z=0; |
-char coord_x[dim_msg]; |
-p = cab_reserve(cid[0]); |
-sprintf(coord_x,"%d %d",x_object,y_object); |
-memcpy(p,coord_x,dim_msg*sizeof(char)); |
-cab_putmes(cid[0], p); |
- |
- //Normalizzazione |
- for(z=0;z<900;z++) |
- { |
- if (luna[z]>0) |
- { |
- luna[z]=((luna[z])*16.0/255.0)+16; |
- } |
- |
- } |
- |
- |
- task_endcycle(); |
- while (1) |
- { |
- |
- // Cancellazione Luna |
- sem_wait(&mutex); |
- grx_box(x_object-15,y_object-15,x_object+14,y_object+14,0); |
- sem_post(&mutex); |
- if (keyb_getcode(&move_tasto,NON_BLOCK)) |
- { |
- if (move_tasto.ascii=='4') |
- x_object=x_object-5; |
- if (move_tasto.ascii=='6') |
- x_object=x_object+5; |
- if (move_tasto.ascii=='2') |
- y_object=y_object+5; |
- if (move_tasto.ascii=='8') |
- y_object=y_object-5; |
- if (move_tasto.ascii=='9'){ |
- y_object=y_object-5; |
- x_object=x_object+5; } |
- if (move_tasto.ascii=='1'){ |
- y_object=y_object+5; |
- x_object=x_object-5; } |
- if (move_tasto.ascii=='7'){ |
- y_object=y_object-5; |
- x_object=x_object-5; } |
- if (move_tasto.ascii=='3'){ |
- y_object=y_object+5; |
- x_object=x_object+5;} |
- if (move_tasto.ascii==' '){ |
- sem_wait(&mutex_tasto); |
- flag=1; |
- if(numero_telescopi<N_MAX_TELESCOPI) |
- { |
- numero_telescopi++; |
- } |
- sem_post(&mutex_tasto); |
- } |
- //CONTROLLI SULLA POSIZIONE |
- if(y_object<(dim_y/2+70)) y_object=dim_y/2+70; |
- if(y_object>(240-dim_y/2)) y_object=(240-dim_y/2); |
- if(x_object<(dim_x/2+20 )) x_object=dim_x/2+20; |
- if(x_object>(630-dim_x/2-10)) x_object=(630-dim_x/2-10); |
- } |
- p = cab_reserve(cid[0]); |
- sprintf(coord_x,"%d %d",x_object,y_object); |
- memcpy(p,coord_x,dim_msg*sizeof(char)); |
- cab_putmes(cid[0], p); |
- |
- for(z=0;z<7;z++) |
- { |
- if (sqrt(pow((x_object-x_p[z]),2)+pow((y_object-y_p[z]),2))<20+dim_p[z]+radius) |
- grx_disc(x_p[z],y_p[z],dim_p[z],col_p[z]); |
- } |
- |
- |
- sem_wait(&mutex); |
- // Gestione sfondo |
- grx_getimage(x_object-15,y_object-15,x_object+14, y_object+14,lunabkg); |
- for(z=0;z<900;z++) |
- { |
- if( luna[z]==0 && lunabkg!=0 ) |
- { |
- lunadest[z]=lunabkg[z]; |
- } |
- else |
- { |
- lunadest[z]=luna[z]; |
- } |
- } |
- grx_putimage(x_object-15,y_object-15,x_object+14, y_object+14,lunadest); |
- sem_post(&mutex); |
- task_endcycle(); |
- } |
-} |
- |
- |
-TASK tele(void *arg) |
-{ |
-int i = (int)arg; |
-int passi; |
-char s[100]; |
-int x_object=300; // posizione dell'oggetto da rilevare |
-int y_object=200; |
-int x_start=500; // posizione iniziale dei telescopi |
-int y_start=190; |
-int x_current=x_start; // posizione corrente dei telescopi |
-int y_current=y_start; |
-int x_current_d[9]; |
-int y_current_d[9]; |
-int y= Y_TELESCOPI; // coordinata y dei telescopi |
-double alpha_new=atan((y-(double)y_current)/((x[i]-(double)x_current))); |
-double alpha=alpha_new; |
-double distance=0.0; |
-double alpha_target=0.0; |
-double tc=0.1; |
-double u=0.0; |
-double u_old=0.0; |
-double errore=0.0; |
-double delta_x=0; |
-double delta_y=0; |
- |
-char *p; |
-//int j=0; |
-// indice matrice per aggiunta di rumore |
-int k=0; |
-int q=0; |
-double polo=poli[i]; |
-int val=0; |
- |
- |
- |
-BYTE videobuf[dim_x*dim_y]; |
- |
- passi = 0; |
- //srand(i); |
- //srand(i+sys_gettime(NULL)); |
- alpha_target=atan((y-(double)y_object)/((double)x_object-x[i])); |
- |
- sem_wait(&mutex); |
- grx_text("targ",4,340,12,0); |
- sprintf(s,"%f",poli[i]); |
- grx_text(s,x[i],y+60,12,0); |
- grx_text("polo",4,y+60,12,0); |
- grx_text("new",4,y+50,12,0); |
- sprintf(s,"%1.6f",alpha_target); |
- grx_text(s, x[i]-25,y+50,12,0); |
- grx_rect(x[i]-40,y+25,x[i]+40,y+85,2); |
- grx_rect(x[i]-40,y+90,x[i]+40,y+150,2); |
- sem_post(&mutex); |
- |
- // Disegno telescopio |
- grx_disc(x[i],y,19,i+1); |
- grx_box( x[i]-19,y,x[i]+19,y+20,i+1); |
- |
- |
- task_endcycle(); |
- |
- while (1) { |
- // legge di controllo |
- passi++; |
- //sprintf(s,"%d",passi); |
- //grx_text(s, 50,110,12,0); |
- p = cab_getmes(cid[0]); |
- sscanf(p,"%d %d",&val,&y_object); |
- cab_unget(cid[0], p); |
- x_object=val; |
- alpha_target=atan((y-(double)y_object)/((double)x_object-x[i])); |
- if (alpha_target <0) |
- { |
- alpha_target=3.14+alpha_target; |
- } |
- |
- errore=alpha_target-alpha_new; |
- u=u_old+kp*tc*errore; |
- //alpha_new=0.13*alpha+0.87*u; |
- alpha_new=(exp(polo*tc))*alpha+(1-exp(polo*tc))*u; |
- u_old=u; |
- alpha=alpha_new; |
- |
- // implementazione dei limiti degli attuattori |
- if (alpha_new > 3.14) |
- alpha_new=3.14; |
- if (alpha_new <0) |
- alpha_new=0; |
- |
- distance=sqrt(((y-y_object)*(y-y_object))+((x_object-x[i])*(x_object-x[i]))); |
- |
- sem_wait(&mutex); |
- // Cancello braccio telescopio |
- if (passi>1) |
- { |
- for (k=0; k<9 ; k++) |
- { |
- grx_line(delta_x,delta_y,x_current_d[k],y_current_d[k],0); |
- } |
- } |
- x_current=x[i]+distance*cos(alpha_new); |
- y_current=300-distance*sin(alpha_new); |
- |
- // lettura immagine |
- |
- grx_getimage(x_current-(dim_x/2),y_current-(dim_y/2),x_current+(dim_x/2),y_current+(dim_y/2),videobuf); |
- |
- //aggiunta rumore |
- |
- sem_post(&mutex); |
- for (k=0;k<dim_x;k++) |
- { |
- for(q=0;q<dim_y;q++) |
- { |
- int num=0; |
- num=rand(); |
- num=(num%10)+1; |
- if (num>SOGLIA) |
- { |
- videobuf[k*dim_x+q]=videobuf[k*dim_x+q]+1; |
- } |
- } |
- } |
- sem_wait(&mutex); |
- |
- grx_putimage(x[i]-25,y+92,x[i]-25+dim_x-1,y+92+dim_y-1,videobuf); |
- |
- sprintf(s,"%3.4f",(180*(alpha_target/pi))); |
- grx_text(s, x[i]-25,y+40,12,0); |
- sprintf(s,"%3.4f",180*(alpha_new/pi)); |
- grx_text(s, x[i]-25,y+50,12,0); |
- |
- delta_x=x[i]+20*cos(alpha_new); |
- delta_y=y-20*sin(alpha_new); |
- |
- for ( k=0; k<9 ; k++) { |
- x_current_d[k]=x[i]+50*cos(alpha_new+(k-4)*0.01); |
- y_current_d[k]=300-50*sin(alpha_new+(k-4)*0.01); } |
- |
- // Disegno braccio telescopio |
- for(k=0 ; k<9 ; k++) |
- grx_line(delta_x,delta_y,x_current_d[k],y_current_d[k],i+1); |
- |
- sem_post(&mutex); |
- |
- // scrive immagine nel cab |
- p = cab_reserve(cid[i+1]); |
- memcpy(p,videobuf,dim_x*dim_y*sizeof(BYTE)); |
- cab_putmes(cid[i+1], p); |
- |
- task_endcycle(); |
- |
- } |
- |
-} |
- |
- |
-/****************************************************************/ |
- |
-/* This is the exception handler. It is called when an exception |
- is raised. |
- It exits from the graphical mode, then it prints a message and |
- shutdown the kernel using sys_abort() |
-*/ |
- |
-void demo_exc_handler(int signo, siginfo_t *info, void *extra) |
-{ |
- struct timespec t; |
- |
- grx_close(); |
- |
- /* Default action for an kern exception is */ |
- kern_cli(); |
- ll_gettime(TIME_EXACT, &t), |
- kern_printf("\nS.Ha.R.K. Exception raised!!!" |
- "\nTime (s:ns) :%ld:%ld" |
- "\nException number:%d (numbers in include/bits/errno.h)" |
- "\nPID :%d\n", |
- t.tv_sec, t.tv_nsec, info->si_value.sival_int, |
- info->si_task); |
- sys_abort(1); |
-} |
- |
-/******************************************************************/ |
- |
-/* This function is called when Alt-X is pressed. |
- It simply shutdown the system using sys_end. |
- Note that the byebye() function is called only if we exit from |
- the system using sys_end()!!!! |
-*/ |
-void my_end(KEY_EVT* e) |
-{ |
- sys_end(); |
-} |
- |
-/******************************************************************/ |
- |
-/* This function is called when the system exit correctly after Alt-X. |
- It exits from the graphic mode and then it prints a small greeting. |
- Note that: |
- - The function calls grx_exit, so it must be registered using |
- RUNLEVEL_BEFORE_EXIT (RUNLEVEL_AFTER_EXIT does not work because |
- at that point the kernel is already returned in real mode!!!) |
- - When an exception is raised, the exception handler is called. |
- Since the exception handler already exits from the graphic mode, |
- this funcion has not to be called. For this reason: |
- . we registered byebye using the flag NO_AT_ABORT |
- . the exception handler exits using sys_abort; in that way byebye is |
- NOT called |
-*/ |
- |
-void byebye(void *arg) |
-{ |
- grx_close(); |
- kern_printf("Bye Bye!\n"); |
-} |
- |
-/****************************** MAIN ******************************/ |
- |
-int main(int argc, char **argv) |
-{ |
- PID pid1, pid4,pid5; |
- KEY_EVT emerg; |
- int i=0; |
- int z=0; // contatore per disegno dei pianeti |
- HARD_TASK_MODEL m1, m4,m5; |
- //FILE *fp; |
- |
- struct sigaction action; |
- |
- cid[0] = cab_create(cname[0], dim_msg, 5); |
- cid[1] = cab_create(cname[1], dim_x*dim_y, 3); |
- cid[2] = cab_create(cname[2], dim_x*dim_y, 3); |
- cid[3] = cab_create(cname[3], dim_x*dim_y, 3); |
- cid[4] = cab_create(cname[4], dim_x*dim_y, 4); |
- cid[5] = cab_create(cname[5], dim_x*dim_y, 3); |
- cid[6] = cab_create(cname[6], dim_x*dim_y, 3); |
- |
- /*fp=fopen("file.txt","r"); |
- fscanf(fp,"%d",a); |
- fclose(fp); |
- */ |
- |
- /* Init the standard S.Ha.R.K. exception handler */ |
- action.sa_flags = SA_SIGINFO; /* Set the signal action */ |
- action.sa_sigaction = demo_exc_handler; |
- action.sa_handler = 0; |
- sigfillset(&action.sa_mask); /* we block all the other signals... */ |
- |
- if (sigaction(SIGHEXC, &action, NULL) == -1) { /* set the signal */ |
- perror("Error initializing signals..."); |
- sys_end(); |
- } |
- |
- /* Set the closing function */ |
- sys_atrunlevel(byebye, NULL, RUNLEVEL_BEFORE_EXIT|NO_AT_ABORT); |
- |
- /* Initializes the semaphore */ |
- sem_init(&mutex,0,1); |
- |
- /* graphic card Initialization */ |
- if (grx_init() < 1) { |
- sys_abort(1); |
- } |
- |
- if (grx_open(640, 480, 8) < 0) { |
- kern_printf("GRX Err\n"); |
- sys_abort(1); |
- } |
- kern_printf("Video card ok!\n"); |
- |
- |
- |
- /* set the keyboard handler to exit correctly */ |
- emerg.ascii = 'x'; |
- emerg.scan = KEY_X; |
- emerg.flag = ALTL_BIT; |
- keyb_hook(emerg,my_end); |
- |
- srand(i+sys_gettime(NULL)); |
- |
- emerg.ascii = 'x'; |
- emerg.scan = KEY_X; |
- emerg.flag = ALTR_BIT; |
- keyb_hook(emerg,my_end); |
- sem_wait(&mutex); |
- /* a small banner */ |
- grx_clear(0); |
- |
- grx_text("REALTIME TELESCOPES di Marco Bera e Gabriele Varasio",8,8,WHITE,0); |
- grx_text("Premere Spazio per creare un telescopio",8,22,WHITE,0); |
- grx_text("Premere Alt-X per uscire",8,32,WHITE,0); |
- grx_text("Usare il tastierino numerico per muovere l'oggetto",8,42,WHITE,0); |
- |
- // DISEGNARE BORDI |
- grx_rect(1,1,638,478,2); |
- grx_rect(558,1,638,61,2); |
- grx_rect(1,1,638,61,2); |
- |
- |
- // Disegno sfondo |
- for(z=0;z<7;z++) |
- { |
- num_p=rand(); |
- y_p[z]=100+((num_p%130)+1); |
- x_p[z]=50+((num_p%540)+1); |
- dim_p[z]=2+((num_p%5)+1); |
- col_p[z]=((num_p%10)+1); |
- grx_disc(x_p[z],y_p[z],dim_p[z],col_p[z]); |
- } |
- sem_post(&mutex); |
- |
- |
- hard_task_default_model(m4); |
- hard_task_def_ctrl_jet (m4); |
- hard_task_def_arg (m4, (void *)3); |
- hard_task_def_wcet (m4, 19000); |
- hard_task_def_mit (m4, PERIOD_T4); |
- hard_task_def_group (m4,1); |
- pid4 = task_create("move", move, &m4, NULL); |
- if (pid4 == NIL) { |
- grx_close(); |
- perror("Could not create task <move>"); |
- sys_abort(1); |
- } |
- task_activate(pid4); |
- hard_task_default_model(m5); |
- hard_task_def_ctrl_jet (m5); |
- hard_task_def_arg (m5, (void *)3); |
- hard_task_def_wcet (m5, 19000); |
- hard_task_def_mit (m5, PERIOD_T5); |
- hard_task_def_group (m5,1); |
- pid5 = task_create("media", media, &m5, NULL); |
- |
- if (pid5 == NIL) { |
- grx_close(); |
- perror("Could not create task <move>"); |
- sys_abort(1); |
- } |
- task_activate(pid5); |
- /* and finally we activate the three threads... */ |
- |
- |
- |
- do { |
- int val_flag=0; |
- sem_wait(&mutex_tasto); |
- val_flag=flag; |
- sem_post(&mutex_tasto); |
- |
- if ((val_flag==1) && (i < N_MAX_TELESCOPI)) |
- { |
- flag=0; |
- hard_task_default_model(m1); |
- hard_task_def_ctrl_jet (m1); |
- hard_task_def_arg (m1, (void *)i); |
- hard_task_def_wcet (m1, WCET_T); |
-// hard_task_def_mit (m1, PERIOD_T1); |
- hard_task_def_mit (m1, period_t1); |
- |
- hard_task_def_group (m1,1); |
- pid1 = task_create("tele1", tele, &m1, NULL); |
- if (pid1 == NIL) |
- { |
- grx_close(); |
- perror("Could not create task <tele1>"); |
- sys_abort(1); |
- } |
- task_activate(pid1); |
- i++; |
- } |
- } while (1); |
- |
- /* |
- now the task main ends, but the system does not shutdown because |
- there are others. |
- |
- The demo will finish if a Alt-X key is pressed. |
- */ |
- |
- return 0; |
-} |
-/*********** lettura da file ********************/ |
-void read_cfg_file(int argc, char **argv) |
-{ |
- int err; |
- DOS_FILE *fp; |
- char myfilebuf[1000]; |
- int myfilebuf_length; |
- |
- |
- |
- if (2) |
- { |
- fp = DOS_fopen("dati.cnf","r"); |
- |
- if (fp) |
- { |
- /* read up to 1000 chars */ |
- myfilebuf_length = DOS_fread(&myfilebuf,1,1000,fp); |
- |
- /* check for errors */ |
- err = DOS_error(); |
- |
- cprintf("Read %d bytes...\n", myfilebuf_length); |
- |
- if (err) |
- { |
- cprintf("Error %d reading file...Using default values\n", err); |
- } |
- else |
- { |
- //geti(myfilebuf, &pos, &NMouses); // Number of Mouses |
- sscanf(myfilebuf,"%lf %lf %lf %lf %lf %lf %d",&poli[0],&poli[1],&poli[2],&poli[3],&poli[4],&kp,&period_t1); |
- } |
- |
- DOS_fclose(fp); |
- return; |
- |
- } |
- else { |
- /* error!! */ |
- err = DOS_error(); |
- /* note that if you call DOS_error() here, it return 0!!! */ |
- cprintf("Error %d opening myfile.txt...Using default values\n", err); |
- } |
- |
- } |
- else { |
- cprintf("Wrong number of arguments...\n"); |
- l1_exit(0); |
- } |
-} |
- |
- |
-/****************************************************************/ |
Index: tags/rel_1_22/telesco/dati.cnf |
=================================================================== |
--- tags/rel_1_22/telesco/dati.cnf (revision 1310) |
+++ tags/rel_1_22/telesco/dati.cnf (nonexistent) |
@@ -1,3 +0,0 @@ |
--1 -20 -30 -40 -50 0.5 100000 |
-# 5 poli kp(guadagno) periodo telescopio |
- |
Index: tags/rel_1_22/cbs_ft/cbs_ft.c |
=================================================================== |
--- tags/rel_1_22/cbs_ft/cbs_ft.c (revision 1310) |
+++ tags/rel_1_22/cbs_ft/cbs_ft.c (nonexistent) |
@@ -1,811 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@hartik.sssup.it> |
- * |
- * Authors : Marco Caccamo and Paolo Gai |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: cbs_ft.c,v 1.5 2003-12-17 13:52:46 giacomo Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.5 $ |
- Last update: $Date: 2003-12-17 13:52:46 $ |
- ------------ |
- |
- This file contains the server CBS_FT |
- |
- Read CBS_FT.h for further details. |
- |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Marco Caccamo and Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
- |
-#include "cbs_ft.h" |
- |
-/*+ Status used in the level +*/ |
-#define CBS_FT_IDLE APER_STATUS_BASE /*+ waiting the activation +*/ |
-#define CBS_FT_ZOMBIE APER_STATUS_BASE+1 /*+ waiting the period end +*/ |
- |
-/* structure of an element of the capacity queue */ |
-struct cap_queue { |
- int cap; |
- struct timespec dead; |
- struct cap_queue *next; |
-}; |
- |
-/*+ the level redefinition for the CBS_FT level +*/ |
-typedef struct { |
- level_des l; /*+ the standard level descriptor +*/ |
- |
- /* The wcet are stored in the task descriptor, but we need |
- an array for the deadlines. We can't use the timespec_priority |
- field because it is used by the master level!!!... |
- Notice that however the use of the timespec_priority field |
- does not cause any problem... */ |
- |
- struct timespec cbs_ft_dline[MAX_PROC]; /*+ CBS_FT deadlines +*/ |
- |
- |
- TIME period[MAX_PROC]; /*+ CBS_FT activation period +*/ |
- |
- |
- int maxcap[MAX_PROC]; /* amount of capacity reserved to a primary+backup |
- couple */ |
- |
- PID backup[MAX_PROC]; /* Backup task pointers, defined for primary tasks */ |
- |
- char CP[MAX_PROC]; /* checkpoint flag */ |
- |
- char P_or_B[MAX_PROC]; /* Type of task: PRIMARY or BACKUP */ |
- |
- |
- struct timespec reactivation_time[MAX_PROC]; |
- /*+ the time at witch the reactivation timer is post +*/ |
- |
- int reactivation_timer[MAX_PROC]; /*+ the recativation timer +*/ |
- |
- struct cap_queue *queue; /* pointer to the spare capacity queue */ |
- |
- int flags; /*+ the init flags... +*/ |
- |
- bandwidth_t U; /*+ the used bandwidth by the server +*/ |
- |
- int idle; /* the idle flag... */ |
- |
- struct timespec start_idle; /*gives the start time of the last idle period */ |
- |
- LEVEL scheduling_level; |
- |
-} CBS_FT_level_des; |
- |
- |
- |
-/* insert a capacity in the queue capacity ordering by deadline */ |
- |
-static int c_insert(struct timespec dead, int cap, struct cap_queue **que, |
- PID p) |
-{ |
- struct cap_queue *prev, *n, *new; |
- |
- prev = NULL; |
- n = *que; |
- |
- while ((n != NULL) && |
- !TIMESPEC_A_LT_B(&dead, &n->dead)) { |
- prev = n; |
- n = n->next; |
- } |
- |
- |
- new = (struct cap_queue *)kern_alloc(sizeof(struct cap_queue)); |
- if (new == NULL) { |
- kern_printf("\nNew cash_queue element failed\n"); |
- kern_raise(XINVALID_TASK, p); |
- return -1; |
- } |
- new->next = NULL; |
- new->cap = cap; |
- new->dead = dead; |
- |
- if (prev != NULL) |
- prev->next = new; |
- else |
- *que = new; |
- |
- if (n != NULL) |
- new->next = n; |
- return 0; |
- |
-} |
- |
-/* extract the first element from the capacity queue */ |
- |
-int c_extractfirst(struct cap_queue **que) |
-{ |
- struct cap_queue *p = *que; |
- |
- |
- if (*que == NULL) return(-1); |
- |
- *que = (*que)->next; |
- |
- kern_free(p, sizeof(struct cap_queue)); |
- return(1); |
-} |
- |
-/* read data of the first element from the capacity queue */ |
- |
-static void c_readfirst(struct timespec *d, int *c, struct cap_queue *que) |
-{ |
- *d = que->dead; |
- *c = que->cap; |
-} |
- |
-/* write data of the first element from the capacity queue */ |
- |
-static void c_writefirst(struct timespec dead, int cap, struct cap_queue *que) |
-{ |
- que->dead = dead; |
- que->cap = cap; |
-} |
- |
- |
-static void CBS_FT_activation(CBS_FT_level_des *lev, |
- PID p, |
- struct timespec *acttime) |
-{ |
- JOB_TASK_MODEL job; |
- int capacity; |
- |
- /* This rule is used when we recharge the budget at initial task activation |
- and each time a new task instance must be activated */ |
- |
- if (TIMESPEC_A_GT_B(acttime, &lev->cbs_ft_dline[p])) { |
- /* we modify the deadline ... */ |
- TIMESPEC_ASSIGN(&lev->cbs_ft_dline[p], acttime); |
- } |
- |
- |
- if (proc_table[p].avail_time > 0) |
- proc_table[p].avail_time = 0; |
- |
- |
- |
- /* A spare capacity is inserted in the capacity queue!! */ |
- ADDUSEC2TIMESPEC(lev->period[p], &lev->cbs_ft_dline[p]); |
- capacity = lev->maxcap[p] - proc_table[ lev->backup[p] ].wcet; |
- c_insert(lev->cbs_ft_dline[p], capacity, &lev->queue, p); |
- |
- |
- /* it exploits available capacities from the capacity queue */ |
- while (proc_table[p].avail_time < proc_table[p].wcet && |
- lev->queue != NULL) { |
- struct timespec dead; |
- int cap, delta; |
- delta = proc_table[p].wcet - proc_table[p].avail_time; |
- c_readfirst(&dead, &cap, lev->queue); |
- if (!TIMESPEC_A_GT_B(&dead, &lev->cbs_ft_dline[p])) { |
- if (cap > delta) { |
- proc_table[p].avail_time += delta; |
- c_writefirst(dead, cap - delta, lev->queue); |
- } |
- else { |
- proc_table[p].avail_time += cap; |
- c_extractfirst(&lev->queue); |
- } |
- } |
- else |
- break; |
- } |
- |
- /* If the budget is still less than 0, an exception is raised */ |
- if (proc_table[p].avail_time <= 0) { |
- kern_printf("\nnegative value for the budget!\n"); |
- kern_raise(XINVALID_TASK, p); |
- return; |
- } |
- |
- |
- |
- /*if (p==6) |
- kern_printf("(act_time:%d dead:%d av_time:%d)\n", |
- acttime->tv_sec*1000000+ |
- acttime->tv_nsec/1000, |
- lev->cbs_ft_dline[p].tv_sec*1000000+ |
- lev->cbs_ft_dline[p].tv_nsec/1000, |
- proc_table[p].avail_time); */ |
- |
- |
- |
- |
- |
- |
-#ifdef TESTG |
- if (starttime && p == 3) { |
- oldx = x; |
- x = ((lev->cbs_ft_dline[p].tv_sec*1000000+lev->cbs_ft_dline[p].tv_nsec/1000)/5000 - starttime) + 20; |
- // kern_printf("(a%d)",lev->cbs_ft_dline[p].tv_sec*1000000+lev->cbs_ft_dline[p].tv_nsec/1000); |
- if (oldx > x) sys_end(); |
- if (x<640) |
- grx_plot(x, 15, 8); |
- } |
-#endif |
- |
- /* and, finally, we reinsert the task in the master level */ |
- job_task_default_model(job, lev->cbs_ft_dline[p]); |
- job_task_def_yesexc(job); |
- level_table[ lev->scheduling_level ]-> |
- private_insert(lev->scheduling_level, p, (TASK_MODEL *)&job); |
-} |
- |
- |
-/* this is the periodic reactivation of the task... */ |
-static void CBS_FT_timer_reactivate(void *par) |
-{ |
- PID p = (PID) par; |
- CBS_FT_level_des *lev; |
- struct timespec t; |
- |
- lev = (CBS_FT_level_des *)level_table[proc_table[p].task_level]; |
- |
- if (proc_table[p].status == CBS_FT_IDLE) { |
- /* the task has finished the current activation and must be |
- reactivated */ |
- |
- /* request_time represents the time of the last instance release!! */ |
- TIMESPEC_ASSIGN(&t, &lev->reactivation_time[p]); |
- |
- /* If idle=1, then we have to discharge the capacities stored in |
- the capacity queue up to the length of the idle interval */ |
- if (lev->idle == 1) { |
- TIME interval; |
- struct timespec delta; |
- lev->idle = 0; |
- SUBTIMESPEC(&t, &lev->start_idle, &delta); |
- /* length of the idle interval expressed in usec! */ |
- interval = TIMESPEC2NANOSEC(&delta) / 1000; |
- |
- /* it discharges the available capacities from the capacity queue */ |
- while (interval > 0 && lev->queue != NULL) { |
- struct timespec dead; |
- int cap; |
- c_readfirst(&dead, &cap, lev->queue); |
- if (cap > interval) { |
- c_writefirst(dead, cap - interval, lev->queue); |
- interval = 0; |
- } |
- else { |
- interval -= cap; |
- c_extractfirst(&lev->queue); |
- } |
- } |
- } |
- |
- CBS_FT_activation(lev,p,&lev->reactivation_time[p]); |
- |
- |
- /* Set the reactivation timer */ |
- TIMESPEC_ASSIGN(&lev->reactivation_time[p], &lev->cbs_ft_dline[p]); |
- lev->reactivation_timer[p] = kern_event_post(&lev->reactivation_time[p], |
- CBS_FT_timer_reactivate, |
- (void *)p); |
- event_need_reschedule(); |
- } |
- else { |
- /* this situation cannot occur */ |
- kern_printf("\nTrying to reactivate a primary task which is not IDLE!\n"); |
- kern_raise(XINVALID_TASK,p); |
- } |
-} |
- |
- |
- |
-static void CBS_FT_avail_time_check(CBS_FT_level_des *lev, PID p) |
-{ |
- |
- /*+ if the capacity became negative the remaining computation time |
- is diminuished.... +*/ |
- /* if (p==4) |
- kern_printf("(old dead:%d av_time:%d)\n", |
- lev->cbs_ft_dline[p].tv_sec*1000000+ |
- lev->cbs_ft_dline[p].tv_nsec/1000, |
- proc_table[p].avail_time); */ |
- |
- |
- int newcap = proc_table[p].wcet / 100 * 30; |
- if (newcap <= 0) |
- newcap = proc_table[p].wcet; |
- /* it exploits available capacities from the capacity queue */ |
- while (proc_table[p].avail_time < newcap |
- && lev->queue != NULL) { |
- struct timespec dead; |
- int cap, delta; |
- delta = newcap - proc_table[p].avail_time; |
- c_readfirst(&dead, &cap, lev->queue); |
- if (!TIMESPEC_A_GT_B(&dead, &lev->cbs_ft_dline[p])) { |
- if (cap > delta) { |
- proc_table[p].avail_time += delta; |
- c_writefirst(dead, cap - delta, lev->queue); |
- } |
- else { |
- proc_table[p].avail_time += cap; |
- c_extractfirst(&lev->queue); |
- } |
- } |
- else |
- break; |
- } |
- |
- |
- |
- /*if (p==6) |
- kern_printf("(ATC dead:%d av_time:%d)\n", |
- lev->cbs_ft_dline[p].tv_sec*1000000+ |
- lev->cbs_ft_dline[p].tv_nsec/1000, |
- proc_table[p].avail_time); */ |
- |
- |
- |
- /* if the budget is still empty, the backup task must be woken up. |
- Remind that a short chunk of primary will go ahead executing |
- before the task switch occurs */ |
- if (proc_table[p].avail_time <= 0) { |
- lev->CP[p] = 1; |
- proc_table[p].avail_time += proc_table[ lev->backup[p] ].wcet; |
- } |
- |
- |
- /*if (p==6) |
- kern_printf("(ATC1 dead:%d av_time:%d)\n", |
- lev->cbs_ft_dline[p].tv_sec*1000000+ |
- lev->cbs_ft_dline[p].tv_nsec/1000, |
- proc_table[p].avail_time); */ |
- |
- |
- |
-} |
- |
- |
-/*+ this function is called when a killed or ended task reach the |
- period end +*/ |
-static void CBS_FT_timer_zombie(void *par) |
-{ |
- PID p = (PID) par; |
- CBS_FT_level_des *lev; |
- |
- lev = (CBS_FT_level_des *)level_table[proc_table[p].task_level]; |
- |
- /* we finally put the task in the FREE status */ |
- proc_table[p].status = FREE; |
- iq_insertfirst(p,&freedesc); |
- |
- |
- /* and free the allocated bandwidth */ |
- lev->U -= (MAX_BANDWIDTH / lev->period[p]) * (TIME)lev->maxcap[p]; |
-} |
- |
-static PID CBS_FT_public_scheduler(LEVEL l) |
-{ |
- CBS_FT_level_des *lev = (CBS_FT_level_des *)(level_table[l]); |
- |
- /* it stores the actual time and set the IDLE flag in order to handle |
- the capacity queue discharging!!! */ |
- lev->idle = 1; |
- kern_gettime(&lev->start_idle); |
- |
- |
- /* the CBS_FT don't schedule anything... |
- it's an EDF level or similar that do it! */ |
- return NIL; |
-} |
- |
- |
-/* The on-line guarantee is enabled only if the appropriate flag is set... */ |
-static int CBS_FT_public_guarantee(LEVEL l, bandwidth_t *freebandwidth) |
-{ |
- CBS_FT_level_des *lev = (CBS_FT_level_des *)(level_table[l]); |
- |
- if (lev->flags & CBS_FT_FAILED_GUARANTEE) { |
- *freebandwidth = 0; |
- kern_printf("guarantee :garanzia fallita!!!!!!\n"); |
- return 0; |
- } |
- else if (*freebandwidth >= lev->U) { |
- *freebandwidth -= lev->U; |
- return 1; |
- } |
- else { |
- kern_printf("guarantee :garanzia fallita per mancanza di banda!!!!!!\n"); |
- kern_printf("freeband: %d request band: %d", *freebandwidth, lev->U); |
- return 0; |
- } |
-} |
- |
- |
-static int CBS_FT_public_create(LEVEL l, PID p, TASK_MODEL *m) |
- |
-{ |
- CBS_FT_level_des *lev = (CBS_FT_level_des *)(level_table[l]); |
- FT_TASK_MODEL *s; |
- |
- if (m->pclass != FT_PCLASS) return -1; |
- if (m->level != 0 && m->level != l) return -1; |
- s = (FT_TASK_MODEL *) m; |
- //kern_printf("accept :FAULT TOLERANT TASK found!!!!!!\n"); */ |
- if (!(s->type == PRIMARY && s->execP > 0 && s->budget < (int)s->period |
- && s->backup != NIL)) return -1; |
- if (!(s->type == BACKUP && s->wcetB > 0)) |
- return -1; |
- /* now we know that m is a valid model */ |
- |
- /* Enable budget check */ |
- proc_table[p].control |= CONTROL_CAP; |
- |
- proc_table[p].avail_time = 0; |
- NULL_TIMESPEC(&lev->cbs_ft_dline[p]); |
- |
- |
- if (s->type == PRIMARY) { |
- proc_table[p].wcet = (int)s->execP; |
- lev->period[p] = s->period; |
- lev->maxcap[p] = s->budget; |
- lev->backup[p] = s->backup; |
- lev->CP[p] = 0; |
- lev->P_or_B[p] = PRIMARY; |
- |
- /* update the bandwidth... */ |
- if (lev->flags & CBS_FT_ENABLE_GUARANTEE) { |
- bandwidth_t b; |
- b = (MAX_BANDWIDTH / lev->period[p]) * (TIME)lev->maxcap[p]; |
- |
- /* really update lev->U, checking an overflow... */ |
- if (MAX_BANDWIDTH - lev->U > b) |
- lev->U += b; |
- else |
- /* The task can NOT be guaranteed (U>MAX_BANDWIDTH)... |
- (see EDF.c) */ |
- lev->flags |= CBS_FT_FAILED_GUARANTEE; |
- } |
- } |
- else { |
- proc_table[p].wcet = (int)s->wcetB; |
- lev->P_or_B[p] = BACKUP; |
- |
- /* Backup tasks are unkillable tasks! */ |
- proc_table[p].control |= NO_KILL; |
- } |
- |
- return 0; /* OK, also if the task cannot be guaranteed... */ |
-} |
- |
- |
-static void CBS_FT_public_detach(LEVEL l, PID p) |
-{ |
- /* the CBS_FT level doesn't introduce any dynamic allocated new field. |
- we have only to reset the NO_GUARANTEE FIELD and decrement the allocated |
- bandwidth */ |
- |
- CBS_FT_level_des *lev = (CBS_FT_level_des *)(level_table[l]); |
- |
- if (lev->flags & CBS_FT_FAILED_GUARANTEE) |
- lev->flags &= ~CBS_FT_FAILED_GUARANTEE; |
- else |
- lev->U -= (MAX_BANDWIDTH / lev->period[p]) * (TIME)lev->maxcap[p]; |
-} |
- |
- |
-static void CBS_FT_public_dispatch(LEVEL l, PID p, int nostop) |
-{ |
- CBS_FT_level_des *lev = (CBS_FT_level_des *)(level_table[l]); |
- level_table[ lev->scheduling_level ]-> |
- private_dispatch(lev->scheduling_level,p,nostop); |
-} |
- |
-static void CBS_FT_public_epilogue(LEVEL l, PID p) |
-{ |
- CBS_FT_level_des *lev = (CBS_FT_level_des *)(level_table[l]); |
- |
- /* check if the budget is finished... */ |
- if (proc_table[p].avail_time <= 0) { |
- |
- /* A backup task cannot ever exhaust its budget! */ |
- if (lev->P_or_B[p] == BACKUP) { |
- kern_printf("\nBACKUP wcet violation!\n"); |
- kern_raise(XWCET_VIOLATION,p); |
- /* we kill the current activation */ |
- level_table[ lev->scheduling_level ]-> |
- private_extract(lev->scheduling_level, p); |
- return; |
- } |
- |
- /* we try to recharge the budget */ |
- CBS_FT_avail_time_check(lev, p); |
- |
- /* The budget must be greater than 0! */ |
- if (proc_table[p].avail_time <= 0) { |
- kern_printf("\nBackup task starting with exhausted budget\n"); |
- kern_raise(XINVALID_TASK, p); |
- lev->CP[p] = 0; |
- /* we kill the current activation */ |
- level_table[ lev->scheduling_level ]-> |
- private_extract(lev->scheduling_level, p); |
- return; |
- } |
- } |
- |
- /* the task returns into the ready queue by |
- calling the guest_epilogue... */ |
- level_table[ lev->scheduling_level ]-> |
- private_epilogue(lev->scheduling_level,p); |
-} |
- |
- |
-static void CBS_FT_public_activate(LEVEL l, PID p) |
-{ |
- CBS_FT_level_des *lev = (CBS_FT_level_des *)(level_table[l]); |
- struct timespec t; |
- |
- kern_gettime(&t); |
- |
- if (lev->P_or_B[p] == BACKUP) { |
- kern_printf("\nTrying to activate a BACKUP task!\n"); |
- kern_raise(XINVALID_TASK, p); |
- } |
- else { |
- |
- /* If idle=1, then we have to discharge the capacities stored in |
- the capacity queue up to the length of the idle interval */ |
- if (lev->idle == 1) { |
- TIME interval; |
- struct timespec delta; |
- lev->idle = 0; |
- SUBTIMESPEC(&t, &lev->start_idle, &delta); |
- /* length of the idle interval expressed in usec! */ |
- interval = TIMESPEC2NANOSEC(&delta) / 1000; |
- |
- /* it discharge the available capacities from the capacity queue */ |
- while (interval > 0 && lev->queue != NULL) { |
- struct timespec dead; |
- int cap; |
- c_readfirst(&dead, &cap, lev->queue); |
- if (cap > interval) { |
- c_writefirst(dead, cap - interval, lev->queue); |
- interval = 0; |
- } |
- else { |
- interval -= cap; |
- c_extractfirst(&lev->queue); |
- } |
- } |
- } |
- |
- CBS_FT_activation(lev, p, &t); |
- |
- |
- /* Set the reactivation timer */ |
- TIMESPEC_ASSIGN(&lev->reactivation_time[p], &lev->cbs_ft_dline[p]); |
- lev->reactivation_timer[p] = kern_event_post(&lev->reactivation_time[p], |
- CBS_FT_timer_reactivate, |
- (void *)p); |
- |
- // kern_printf("act : %d %d |",lev->cbs_ft_dline[p].tv_nsec/1000,p); |
- } |
-} |
- |
-static int CBS_FT_public_message(LEVEL l, PID p, void *m) |
-{ |
- CBS_FT_level_des *lev = (CBS_FT_level_des *)(level_table[l]); |
- |
- |
- level_table[ lev->scheduling_level ]-> |
- private_extract(lev->scheduling_level,p); |
- |
- |
- proc_table[p].status = CBS_FT_IDLE; |
- |
- |
- if (lev->P_or_B[p] == PRIMARY) { |
- if (lev->CP[p]) { |
- JOB_TASK_MODEL job; |
- |
- /* We have to start the backup task */ |
- TIMESPEC_ASSIGN(&lev->cbs_ft_dline[ lev->backup[p] ], |
- &lev->cbs_ft_dline[p]); |
- proc_table[ lev->backup[p] ].avail_time = proc_table[p].avail_time; |
- lev->CP[p] = 0; |
- |
- /* and, finally, we insert the backup task in the master level */ |
- job_task_default_model(job, lev->cbs_ft_dline[p]); |
- job_task_def_yesexc(job); |
- level_table[ lev->scheduling_level ]-> |
- private_insert(lev->scheduling_level, lev->backup[p], |
- (TASK_MODEL *)&job); |
- } |
- else { |
- /* A spare capacity is inserted in the capacity queue!! */ |
- proc_table[p].avail_time += proc_table[ lev->backup[p] ].wcet; |
- if (proc_table[p].avail_time > 0) { |
- c_insert(lev->cbs_ft_dline[p], proc_table[p].avail_time, |
- &lev->queue, p); |
- proc_table[p].avail_time = 0; |
- } |
- } |
- } |
- else { |
- /* this branch is for backup tasks: |
- A spare capacity is inserted in the capacity queue!! */ |
- if (proc_table[p].avail_time > 0) { |
- c_insert(lev->cbs_ft_dline[p], proc_table[p].avail_time, |
- &lev->queue, p); |
- proc_table[p].avail_time = 0; |
- } |
- } |
- |
- jet_update_endcycle(); /* Update the Jet data... */ |
- |
- return 0; |
-} |
- |
- |
-static void CBS_FT_public_end(LEVEL l, PID p) |
-{ |
- CBS_FT_level_des *lev = (CBS_FT_level_des *)(level_table[l]); |
- |
- /* A backup task cannot be killed, this behaviour can be modified |
- in a new release */ |
- if (lev->P_or_B[p] == BACKUP) { |
- kern_printf("\nKilling a BACKUP task!\n"); |
- kern_raise(XINVALID_TASK, p); |
- return; |
- } |
- |
- /* check if the capacity becomes negative... */ |
- /* there is a while because if the wcet is << than the system tick |
- we need to postpone the deadline many times */ |
- while (proc_table[p].avail_time < 0) { |
- /* the CBS_FT rule for recharging the capacity */ |
- proc_table[p].avail_time += lev->maxcap[p]; |
- ADDUSEC2TIMESPEC(lev->period[p], &lev->cbs_ft_dline[p]); |
- } |
- |
- level_table[ lev->scheduling_level ]-> |
- private_extract(lev->scheduling_level,p); |
- |
- |
- /* we delete the reactivation timer */ |
- kern_event_delete(lev->reactivation_timer[p]); |
- lev->reactivation_timer[p] = -1; |
- |
- |
- /* Finally, we post the zombie event. when the end period is reached, |
- the task descriptor and banwidth are freed */ |
- proc_table[p].status = CBS_FT_ZOMBIE; |
- lev->reactivation_timer[p] = kern_event_post(&lev->cbs_ft_dline[p], |
- CBS_FT_timer_zombie, |
- (void *)p); |
-} |
- |
-/* Registration functions */ |
- |
-/*+ Registration function: |
- int flags the init flags ... see CBS.h +*/ |
-LEVEL CBS_FT_register_level(int flags, LEVEL master) |
-{ |
- LEVEL l; /* the level that we register */ |
- CBS_FT_level_des *lev; /* for readableness only */ |
- PID i; /* a counter */ |
- |
- printk("CBS_FT_register_level\n"); |
- |
- /* request an entry in the level_table */ |
- l = level_alloc_descriptor(sizeof(CBS_FT_level_des)); |
- |
- lev = (CBS_FT_level_des *)level_table[l]; |
- |
- printk(" lev=%d\n",(int)lev); |
- |
- /* fill the standard descriptor */ |
- lev->l.public_scheduler = CBS_FT_public_scheduler; |
- |
- if (flags & CBS_FT_ENABLE_GUARANTEE) |
- lev->l.public_guarantee = CBS_FT_public_guarantee; |
- else |
- lev->l.public_guarantee = NULL; |
- |
- lev->l.public_create = CBS_FT_public_create; |
- lev->l.public_detach = CBS_FT_public_detach; |
- lev->l.public_end = CBS_FT_public_end; |
- lev->l.public_dispatch = CBS_FT_public_dispatch; |
- lev->l.public_epilogue = CBS_FT_public_epilogue; |
- lev->l.public_activate = CBS_FT_public_activate; |
- lev->l.public_message = CBS_FT_public_message; |
- |
- /* fill the CBS_FT descriptor part */ |
- for (i=0; i<MAX_PROC; i++) { |
- NULL_TIMESPEC(&lev->cbs_ft_dline[i]); |
- lev->period[i] = 0; |
- NULL_TIMESPEC(&lev->reactivation_time[i]); |
- lev->reactivation_timer[i] = -1; |
- lev->maxcap[i] = 0; |
- lev->backup[i] = NIL; |
- lev->CP[i] = 0; |
- lev->P_or_B[i] = PRIMARY; |
- } |
- |
- lev->U = 0; |
- lev->idle = 0; |
- lev->queue = NULL; |
- |
- lev->scheduling_level = master; |
- |
- lev->flags = flags & 0x07; |
- |
- return l; |
-} |
- |
- |
- |
-bandwidth_t CBS_FT_usedbandwidth(LEVEL l) |
-{ |
- CBS_FT_level_des *lev = (CBS_FT_level_des *)(level_table[l]); |
- |
- return lev->U; |
-} |
- |
- |
- |
-void CBS_FT_Primary_Abort() |
-{ |
- PID p; |
- CBS_FT_level_des *lev; |
- |
- kern_cli(); |
- p = exec_shadow; |
- lev = (CBS_FT_level_des *)level_table[proc_table[p].task_level]; |
- lev->CP[p] = 1; |
- kern_sti(); |
-} |
- |
- |
-char CBS_FT_Checkpoint() |
-{ |
- char f; |
- PID p; |
- CBS_FT_level_des *lev; |
- |
- kern_cli(); |
- p = exec_shadow; |
- lev = (CBS_FT_level_des *)level_table[proc_table[p].task_level]; |
- f = lev->CP[p]; |
- kern_sti(); |
- return f; |
-} |
- |
Index: tags/rel_1_22/cbs_ft/initfile.c |
=================================================================== |
--- tags/rel_1_22/cbs_ft/initfile.c (revision 1310) |
+++ tags/rel_1_22/cbs_ft/initfile.c (nonexistent) |
@@ -1,112 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@hartik.sssup.it> |
- * |
- * Authors : Marco caccamo and Paolo Gai |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: initfile.c,v 1.1.1.1 2002-09-02 09:37:41 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1.1.1 $ |
- Last update: $Date: 2002-09-02 09:37:41 $ |
- ------------ |
- |
- This file contains the server CBS_FT |
- |
- Read CBS_FT.h for further details. |
- |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Marco Caccamo and Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include "kernel/kern.h" |
-#include <modules/edf.h> |
-#include <modules/rr.h> |
-#include "cbs_ft.h" |
-#include <modules/cbs.h> |
-#include <modules/dummy.h> |
-#include <drivers/keyb.h> |
-#include <modules/hartport.h> |
-#include <modules/sem.h> |
-#include <modules/cabs.h> |
- |
-/*+ system tick in us +*/ |
-#define TICK 300 |
-#define RRTICK 5000 |
- |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- EDF_register_level(EDF_ENABLE_ALL); |
- CBS_FT_register_level(CBS_FT_ENABLE_ALL, 0); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- CBS_register_level(CBS_ENABLE_ALL, 0); |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- CABS_register_module(); |
- |
- // periodic timer |
- return TICK; |
- // one-shot timer |
- // return 0 |
-} |
- |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- HARTPORT_init(); |
- |
- KEYB_init(NULL); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
Index: tags/rel_1_22/cbs_ft/cbs_ft.h |
=================================================================== |
--- tags/rel_1_22/cbs_ft/cbs_ft.h (revision 1310) |
+++ tags/rel_1_22/cbs_ft/cbs_ft.h (nonexistent) |
@@ -1,166 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@hartik.sssup.it> |
- * |
- * Authors : Marco Caccamo and Paolo Gai |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: cbs_ft.h,v 1.3 2003-12-17 13:52:46 giacomo Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.3 $ |
- Last update: $Date: 2003-12-17 13:52:46 $ |
- ------------ |
- |
- This file contains the server CBS_FT |
- |
- Read CBS_FT.h for further details. |
- |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Marco Caccamo and Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#ifndef __CBS_FT__ |
-#define __CBS_FT__ |
- |
- |
- |
-#include <ll/string.h> |
-#include <kernel/model.h> |
-#include <kernel/descr.h> |
-#include <kernel/var.h> |
-#include <kernel/func.h> |
- |
- |
- |
- |
- |
- |
-/*+ flags... +*/ |
-#define CBS_FT_ENABLE_GUARANTEE 1 /*+ Task Guarantee enabled +*/ |
-#define CBS_FT_ENABLE_ALL 1 |
- |
-#define CBS_FT_FAILED_GUARANTEE 8 /*+ used in the module, unsettable |
- in EDF_register_level... +*/ |
- |
- |
-#define PRIMARY 1 |
-#define BACKUP 2 |
-#define FT_PCLASS 0x0700 // Nuova classe di task, quelli fault_tolerant |
- |
-#define CBS_FT_LEVELNAME "CBSFT base" |
-#define CBS_FT_LEVEL_CODE 110 |
-#define CBS_FT_LEVEL_VERSION 1 |
- |
- |
-/* The Fault-Tolerant Task model extends the base task model |
- This model cannot be APERIODIC, only PERIODIC tasks are allowed. |
- A faut-tolerant application is composed by two different tasks (primary and |
- backup). The backup task is characterized by its WCET and its type (BACKUP). |
- The primary task must define the task period, its average execution time |
- (used as sort of prediction in order to recharge the budget using the |
- capacity cash queue!), the budget (budget / period = U that is, the |
- bandwidth assigned to the fault-tolerant application), its type (PRIMARY) |
- and finally the PID of the corresponding backup task. */ |
- |
-typedef struct { |
- TASK_MODEL t; |
- |
- TIME wcetB; // WCET of the backup job (BACKUP TASK ONLY) |
- |
- TIME execP; // average exec. time of the primary job (PRIMARY TASK ONLY) |
- |
- TIME period; // period of the fault-tolerant task (PRIMARY TASK ONLY) |
- |
- int budget; // amount of guaranteed capacity (PRIMARY TASK ONLY) |
- |
- char type; // PRIMARY or BACKUP |
- |
- PID backup; // (PRIMARY TASK ONLY) |
- |
-} FT_TASK_MODEL; |
- |
- |
-#define ft_task_default_model(m) \ |
- task_default_model((m).t,FT_PCLASS), \ |
- (m).period = 0, \ |
- (m).wcetB = 0, \ |
- (m).execP = 0, \ |
- (m).budget = 0, \ |
- (m).type = BACKUP, \ |
- (m).backup = NIL |
- |
-#define ft_task_def_level(m,l) task_def_level((m).t,l) |
-#define ft_task_def_arg(m,a) task_def_arg((m).t,a) |
-#define ft_task_def_stack(m,s) task_def_stack((m).t,s) |
-#define ft_task_def_stackaddr(m,s) task_def_stackaddr((m).t,s) |
-#define ft_task_def_usemath(m) task_def_usemath((m).t) |
-#define ft_task_def_ctrl_jet(m) task_def_ctrl_jet((m).t) |
-#define ft_task_def_group(m,g) task_def_group((m).t,g) |
-#define ft_task_def_period(m,o) (m).period = (o) |
-#define ft_task_def_budget(m,o) (m).budget = (o) |
-#define ft_task_def_backup(m) (m).type = BACKUP |
-#define ft_task_def_primary(m) (m).type = PRIMARY |
-#define ft_task_def_backup_task(m,b) (m).backup = b |
-#define ft_task_def_backup_wcet(m,b) (m).wcetB = b |
-#define ft_task_def_primary_exec(m,b) (m).execP = b |
- |
-/************************************************************************/ |
-LEVEL CBS_FT_register_level(int flags, LEVEL master); |
- |
- |
-bandwidth_t CBS_FT_usedbandwidth(LEVEL l); |
- |
- |
- |
-/* This function notifies to a primary task that the task itself has to |
- suspend its execution (the task has to suspend itself with a |
- task_endcycle() */ |
-char CBS_FT_Checkpoint(void); |
- |
- |
- |
-/* This function sets the checkpoint flag! hence, at the next checkpoint, |
- that is: |
- |
- if (CBS_FT_Checkpoint()) { |
- task_endcycle(); |
- continue; |
- } |
- |
- the primary task will suspend itself switching to the backup task */ |
-void CBS_FT_Primary_Abort(void); |
- |
-/***************************************************************************/ |
- |
- |
- |
- |
-#endif |
Index: tags/rel_1_22/cbs_ft/prova.c |
=================================================================== |
--- tags/rel_1_22/cbs_ft/prova.c (revision 1310) |
+++ tags/rel_1_22/cbs_ft/prova.c (nonexistent) |
@@ -1,429 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@hartik.sssup.it> |
- * |
- * Authors : Marco Caccamo and Paolo Gai |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: prova.c,v 1.1.1.1 2002-09-02 09:37:41 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1.1.1 $ |
- Last update: $Date: 2002-09-02 09:37:41 $ |
- ------------ |
- |
- testcash.c |
- test for the CASH Module, directly derived from Test Number 13 (D) |
- |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Marco Caccamo and Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
- |
-#include <modules/edf.h> |
-#include "cbs_ft.h" |
-#include <math.h> |
-#include <stdlib.h> |
- |
-#define ASTER_LIM 60 |
-#define DISPLAY_MAX 15 |
- |
-#define STAT_Y 9 |
- |
-#define INPUT 0.5 |
- |
- |
- |
-#define MAX_STAT 10000 |
-#define RVAL 1 |
-#define XVAL 2 |
-#define DVAL 3 |
- |
- |
-struct statistic { |
- TIME r_time; |
- TIME ex_time; |
- long dead_post; |
-}; |
- |
- |
- |
- struct statistic stat[MAX_STAT]; |
- TIME val[MAX_STAT]; |
- |
-int n_stat = 0; |
- |
-TASK hard_aster1p(void) |
-{ |
- int i; |
- int y = 1; |
- int load1,j; |
- |
- char s[2]; |
- |
- s[0] = 'P'; s[1] = 0; |
- |
- |
- for (;;) { |
- i = 1; |
- while (i < ASTER_LIM) { |
- load1 = 20000; //+ rand() % 25000; |
- for (j=0; j<load1; j++) { |
- if (CBS_FT_Checkpoint()) |
- break; |
- puts_xy(i,y,rand()%15+1,s); |
- } |
- //kern_cli(); |
- //stat[n_stat].r_time = CBSGHD_get_response_time(1, exec_shadow); |
- //jet_gettable(exec_shadow, &stat[n_stat].ex_time, 1); |
- //kern_sti(); |
- //n_stat++; |
- task_endcycle(); |
- puts_xy(i,y,WHITE," "); |
- i++; |
- } |
- } |
-} |
- |
- |
-TASK hard_aster1b(void) |
-{ |
- int i; |
- int y = 1; |
- |
- int load1,j; |
- |
- char s[2]; |
- |
- s[0] = 'B'; s[1] = 0; |
- |
- for (;;) { |
- i = 1; |
- while (i < ASTER_LIM) { |
- load1 = 20000;// + rand()%4000; |
- for (j=0; j<load1; j++) { |
- puts_xy(i,y,rand()%15+1,s); |
- } |
- //kern_cli(); |
- //stat[n_stat].r_time = CBSGHD_get_response_time(1, exec_shadow); |
- //jet_gettable(exec_shadow, &stat[n_stat].ex_time, 1); |
- //kern_sti(); |
- //n_stat++; |
- task_endcycle(); |
- puts_xy(i,y,WHITE," "); |
- i++; |
- } |
- } |
-} |
- |
- |
-TASK hard_aster2p(void) |
-{ |
- int i; |
- int y = 3; |
- |
- int load1,j; |
- |
- char s[2]; |
- |
- s[0] = 'P'; s[1] = 0; |
- |
- for (;;) { |
- i = 1; |
- while (i < ASTER_LIM) { |
- load1 = 20000 + rand() % 20000; |
- for (j=0; j<load1; j++) { |
- if (CBS_FT_Checkpoint()) |
- break; |
- puts_xy(i,y,rand()%15+1,s); |
- } |
- //kern_cli(); |
- //stat[n_stat].r_time = CBSGHD_get_response_time(5, exec_shadow); |
- //jet_gettable(exec_shadow, &stat[n_stat].ex_time, 1); |
- //kern_sti(); |
- //n_stat++; |
- task_endcycle(); |
- puts_xy(i,y,WHITE," "); |
- i++; |
- } |
- } |
-} |
- |
-TASK hard_aster2b(void) |
-{ |
- int i; |
- int y = 3; |
- |
- int load1,j; |
- |
- char s[2]; |
- |
- s[0] = 'T'; s[1] = 0; |
- |
- for (;;) { |
- i = 1; |
- while (i < ASTER_LIM) { |
- load1 = 20000; |
- for (j=0; j<load1; j++) { |
- puts_xy(i,y,rand()%15+1,s); |
- } |
- //kern_cli(); |
- //stat[n_stat].r_time = CBSGHD_get_response_time(5, exec_shadow); |
- //jet_gettable(exec_shadow, &stat[n_stat].ex_time, 1); |
- //kern_sti(); |
- //n_stat++; |
- task_endcycle(); |
- puts_xy(i,y,WHITE," "); |
- i++; |
- } |
- } |
-} |
- |
- |
-TASK clock() |
-{ |
- int s = 0, m = 0; |
- |
- while(1) { |
- printf_xy(62,1,WHITE,"%2d:%2d",m,s); |
- printf_xy(62,2,WHITE,"Utot=%12u",MAX_BANDWIDTH); |
- printf_xy(62,3,WHITE,"Uedf=%12u",EDF_usedbandwidth(0)); |
- printf_xy(62,4,WHITE,"Ucbs=%12u",CBS_FT_usedbandwidth(1)); |
- task_endcycle(); |
- |
- if (++s > 59) { |
- s = 0; |
- m++; |
- } |
- printf_xy(62,1,WHITE,"%2d:%2d",m,s); |
- printf_xy(62,2,WHITE,"Utot=%12u",MAX_BANDWIDTH); |
- printf_xy(62,3,WHITE,"Uedf=%12u",EDF_usedbandwidth(0)); |
- printf_xy(62,4,WHITE,"Ucbs=%12u",CBS_FT_usedbandwidth(1)); |
- task_endcycle(); |
- } |
-} |
- |
- |
- |
-/* we consider the first ASTER_MAX + 2 tasks from the PID 2 |
- and plot on the screen the elapsed times... */ |
-TASK jetcontrol() |
-{ |
- int i; /* a counter */ |
- TIME sum, max, curr, last[5]; |
- int nact; |
- int j; /* the elements set by jet_gettable */ |
- PID p; |
- |
- |
- kern_cli(); |
- printf_xy(0,STAT_Y,WHITE,"PID ³ Mean T.³ Max T. ³ N.A. ³ Curr. ³ Last1 ³ Last2 ³ Last3 ³ Last4 ³ Last5"); |
- kern_sti(); |
- |
- for (;;) { |
- for (i=0,p=0; i<DISPLAY_MAX+5 && p<MAX_PROC; p++) { |
- if (jet_getstat(p, &sum, &max, &nact, &curr) == -1) continue; |
- |
- for (j=0; j<5; j++) last[j] = 0; |
- jet_gettable(p, &last[0], 5); |
- kern_cli(); |
- printf_xy(0,STAT_Y+i+1,WHITE,"%-3d ³ %-6ld ³ %-6ld ³ %-4d ³ %-7ld ³ %-5ld ³ %-5ld ³ %-5ld ³ %-5ld ³ %-5ld", p, sum/(nact==0 ? 1 : nact), max, |
- nact, curr, last[0], last[1], last[2], last[3], last[4]); |
- kern_sti(); |
- i++; |
- } |
- task_endcycle(); |
- } |
-} |
- |
- |
-void save_stat(struct statistic p[], int n, char *name, int type) |
-{ |
- DOS_FILE *f; |
- int i; |
- char outstring[500]; |
- |
- |
- for(i = 0; i < 500; i++) |
- outstring[i] = '0'; |
- |
- f = DOS_fopen(name, "w"); |
- if (!f) { |
- cprintf("Cannot open %s!!!", name); |
- goto end1; |
- } |
- |
- for(i = 0; i < n; i++) { |
- if (type == RVAL) |
- val[i] = p[i].r_time; |
- if (type == XVAL) |
- val[i] = p[i].ex_time; |
- if (type == DVAL) |
- val[i] = p[i].dead_post; |
- } |
- |
- memset(outstring, 0, 300); |
- sprintf(outstring, "%ld \n", (long int)n); |
- cprintf("%s", outstring); |
- DOS_fwrite(outstring, 1, strlen(outstring), f); |
- |
- for(i = 0; i < n; i++) { |
- memset(outstring, 0, 300); |
- sprintf(outstring, "%ld %lu\n", (long int)i, val[i]); |
- //cprintf("%s", outstring); |
- DOS_fwrite(outstring, 1, strlen(outstring), f); |
- } |
- DOS_fclose(f); |
-end1:cprintf("OK?"); |
-} |
- |
- |
-void result_save(void *p) |
-{ |
- save_stat(stat, n_stat, "stat1.tim", RVAL); |
-} |
- |
- |
-void fine() |
-{ |
- ll_abort(666); |
-} |
- |
-int main(int argc, char **argv) |
-{ |
- PID p1,p2,p3, p4, p5, p6; |
- |
- HARD_TASK_MODEL m; |
- FT_TASK_MODEL ftb; |
- FT_TASK_MODEL ftp; |
- |
- // int i; |
- struct timespec fineprg; |
- |
- |
- //sys_atrunlevel(result_save, NULL, RUNLEVEL_AFTER_EXIT); |
- srand(7); |
- |
- hard_task_default_model(m); |
- hard_task_def_wcet(m,500); |
- hard_task_def_mit(m,500000); |
- hard_task_def_periodic(m); |
- hard_task_def_group(m,1); |
- hard_task_def_ctrl_jet(m); |
- |
- |
- p1 = task_create("Clock",clock,&m,NULL); |
- if (p1 == -1) { |
- perror("testhd.c(main): Could not create task <Clock> ..."); |
- sys_end(); |
- } |
- |
- |
- hard_task_def_wcet(m,500); |
- hard_task_def_periodic(m); |
- hard_task_def_mit(m,100000); |
- |
- |
- p2 = task_create("JetControl",jetcontrol,&m,NULL); |
- if (p2 == -1) { |
- perror("testhd.c(main): Could not create task <JetControl> ..."); |
- sys_end(); |
- } |
- |
- |
- ft_task_default_model(ftb); |
- ft_task_def_usemath(ftb); |
- ft_task_def_backup(ftb); |
- ft_task_def_ctrl_jet(ftb); |
- ft_task_def_backup_wcet(ftb, 7000); |
- |
- |
- |
- p3 = task_create("Hard_aster1b", hard_aster1b, &ftb,NULL); |
- if (p3 == -1) { |
- perror("testhd.c(main): Could not create task <aster1b> ..."); |
- sys_end(); |
- } |
- |
- ft_task_default_model(ftp); |
- ft_task_def_usemath(ftp); |
- ft_task_def_ctrl_jet(ftp); |
- ft_task_def_group(ftp, 1); |
- ft_task_def_period(ftp, 50000); |
- ft_task_def_budget(ftp, 15000); |
- ft_task_def_primary_exec(ftp, 7300); |
- ft_task_def_primary(ftp); |
- ft_task_def_backup_task(ftp, p3); |
- |
- |
- p4 = task_create("Hard_aster1p", hard_aster1p, &ftp, NULL); |
- if (p4 == -1) { |
- perror("testhd.c(main): Could not create task <aster1p> ..."); |
- sys_end(); |
- } |
- |
- |
- ft_task_def_backup_wcet(ftb, 6700); |
- |
- |
- p5 = task_create("Hard_aster2b", hard_aster2b, &ftb, NULL); |
- if (p5 == -1) { |
- perror("testhd.c(main): Could not create task <aster2b> ..."); |
- sys_end(); |
- } |
- |
- |
- ft_task_def_period(ftp, 100000); |
- ft_task_def_budget(ftp, 8000); |
- ft_task_def_primary_exec(ftp, 11000); |
- ft_task_def_backup_task(ftp, p5); |
- |
- |
- p6 = task_create("Hard_aster2p", hard_aster2p, &ftp, NULL); |
- if (p6 == -1) { |
- perror("testhd.c(main): Could not create task <aster2p> ..."); |
- sys_end(); |
- } |
- |
- |
- printf_xy(0,STAT_Y + 15,WHITE,"Hard asteroide PID= %-3d ",p3); |
- printf_xy(0,STAT_Y + 17,WHITE,"Clock PID= %-3d ",p1); |
- printf_xy(0,STAT_Y + 18,WHITE,"JetControl PID= %-3d ",p2); |
- |
- |
- |
- task_nopreempt(); |
- fineprg.tv_sec = 10; |
- fineprg.tv_nsec = 0; |
- kern_event_post(&fineprg,fine,NULL); |
- group_activate(1); |
- return 0; |
-} |
- |
Index: tags/rel_1_22/cbs_ft/readme.txt |
=================================================================== |
--- tags/rel_1_22/cbs_ft/readme.txt (revision 1310) |
+++ tags/rel_1_22/cbs_ft/readme.txt (nonexistent) |
@@ -1,6 +0,0 @@ |
-This Example has been made by Marco Caccamo. |
- |
-There is not a lot of documentation available, so if you have problems please |
-send an e-mail to Marco ( http://gandalf.sssup.it/~caccamo/ ) |
- |
-Paolo |
Index: tags/rel_1_22/cbs_ft/makefile |
=================================================================== |
--- tags/rel_1_22/cbs_ft/makefile (revision 1310) |
+++ tags/rel_1_22/cbs_ft/makefile (nonexistent) |
@@ -1,17 +0,0 @@ |
-# |
-# |
-# |
- |
-ifndef BASE |
-BASE=../.. |
-endif |
-include $(BASE)/config/config.mk |
- |
-PROGS= prova |
- |
-include $(BASE)/config/example.mk |
- |
-prova: |
- make -f $(SUBMAKE) APP=prova INIT= OTHEROBJS="initfile.o cbs_ft.o" OTHERINCL= SHARKOPT="__OLDCHAR__ __GRX__" |
- |
- |
Index: tags/rel_1_22/autostr/autostr.c |
=================================================================== |
--- tags/rel_1_22/autostr/autostr.c (revision 1310) |
+++ tags/rel_1_22/autostr/autostr.c (nonexistent) |
@@ -1,1171 +0,0 @@ |
-/*************************************************************************** |
- ************************************************************************** |
- *** Universita' di Pavia *** |
- *** Corso : Informatoca Industriale *** |
- ************************************************************************** |
- *** Progetto : MONITORAGGIO AUTOSTRADA *** |
- ************************************************************************** |
- *** Realizzato da : Nino Verzellesi e Quadrubbi Giacomo *** |
- ************************************************************************** |
- ***************************************************************************/ |
- |
- |
-/* ----------------------------------------------------------------------------- */ |
- |
-#include <kernel/kern.h> |
-#include <drivers/glib.h> |
-#include <drivers/keyb.h> |
-#include <semaphore.h> |
-#include <stdlib.h> |
-#include <math.h> |
- |
-/* ----------------------------------------------------------------------------- */ |
- |
- |
-/********************* DEFINIZIONE DELLE COSTANTI **************************/ |
- |
-#define ESC 27 /* codice ASCII del tasto ESCAPE */ |
-#define MAX_V 35 /* massimo numero di veicoli */ |
-#define GRUPPO 1 |
-#define LUNGCAMION 40 /* lunghezza del camion */ |
-#define LARGCAMION 10 /* larghezza del camion */ |
-#define LUNGLENTA 16 /* lunghezza della macchina lenta */ |
-#define LARGLENTA 8 /* larghezza della macchina lenta */ |
-#define LUNGVELOCE 20 /* lunghezza della macchina veloce */ |
-#define LARGVELOCE 8 /* larghezza della macchina veloce */ |
-#define DT 0.04 /* passo del campionamento */ |
-#define CENTROCORSIA1 477 /* coordinata del centro della corsia 1 */ |
-#define CENTROCORSIA2 459 /* coordinata del centro della corsia 2 */ |
-#define CENTROCARREGGIATA 469 /* coordinata del centro della carreggiata */ |
- |
- |
-/* ----------------------------------------------------------------------------- */ |
- |
- |
-/****************** DEFINIZIONE DELLE VARIABILI GLOBALI ********************/ |
- |
-double tick = 1.0; /* system tick = 1 ms */ |
-int periodo = 40000; /* periodo */ |
-int wcet = 1000; /* deadline */ |
-PID pid; |
-sem_t mutex; /* semaforo per la grafica */ |
-sem_t strada; /* semaforo per le variabili corsia1 e corsia2 */ |
-int MAX_X; /* dimensione x della modalita' di visualizzazione dello schermo */ |
-int MAX_Y; /* dimensione y della modalita' di visualizzazione dello schermo */ |
-short corsia1[40000]; /* vettore della corsia1 */ |
-short corsia2[40000]; /* vettore della corsia2 */ |
-int xelic; /* cordinata dell'elicottero */ |
-char c; /* carattere da tastiera */ |
- |
- |
-/* ----------------------------------------------------------------------------- */ |
- |
- |
-/****************** FUNZIONE CHE DISEGNA I VEICOLI *************************/ |
- |
-void draw_veicolo(int x, int y, int colore,int lunghezza,int larghezza) |
-{ |
- int u; /* indice di ciclo */ |
- int v; /* variabile ausiliaria per la ricostruzione della segnaletica */ |
- int xreal; /* coordinata di fine veicolo */ |
- |
- xreal=x-lunghezza; /* calcola la coordinata di fine veicolo */ |
- if (xreal<0) /* la pone a zero nel caso in cui sia minore di zero (veicolo non ancora interamente entrato in autostrada) */ |
- xreal=0; |
- |
- /* disegna il veicolo nella posizione indicata e con il colore indicato */ |
- sem_wait(&mutex); |
- grx_box(xreal,(int)(y-larghezza/2),x,(int)(y+larghezza/2),colore); |
- sem_post(&mutex); |
- |
- /* ricostruisce la segnaletica orrizzontale della strada nel caso in cui si sta' cancellando il veicolo dalla posizione precedente (ridisegna solo quella parte che e' stata cancellata) */ |
- if (colore==0) |
- for (u=xreal;u<x;u++) |
- { |
- v=u%8; |
- if ((v==0) || (v==1)) |
- { |
- sem_wait(&mutex); |
- grx_plot(u,CENTROCARREGGIATA,rgb16(255,255,255)); |
- sem_post(&mutex); |
- } |
- } |
-} |
- |
- |
-/* ----------------------------------------------------------------------------- */ |
- |
- |
-/** FUNZIONE CHE CALCOLA LA DISTANZA DAL VEICOLO CHE PRECEDE SULLA CORSIA **/ |
- |
-int dist_ant(int pos_x,int pos_y,int distsic) |
-{ |
- int libero; /* variabile che indica se l'attuale posizione puntata dal veicolo e' libera */ |
- int distant; /* distanza dal veicolo che ci precede */ |
- int fine; /* variabile ausiliaria per capire se sto' arrivando alla fine della strada */ |
- |
- /* inizializzazione delle variabili */ |
- libero=0; |
- distant=0; |
- |
- /* calcola la distanza da un eventuale veicolo che ci precede */ |
- sem_wait(&strada); |
- if (pos_y<CENTROCARREGGIATA) /* controlla se il veicolo e' nella prima corsia, altrimenti e' in seconda corsia */ |
- while (libero==0 && distant<distsic) /* il calcolo della distanza da un veicolo che ci precede termina quando viene trovato un veicolo o si raggiunge la lunghezza massima di visione del sensore */ |
- { |
- fine=pos_x+distant; /* nel caso in cui il veicolo si giunto alla fine dell'autostrada si assume che il sensore ritorni un valore come nel caso in cui non sia preceduto da nessun veicolo */ |
- if (fine>40000) |
- distant=distsic; |
- else |
- if (corsia2[fine]!=0) /* se la strada e' occupata da un'altro veicolo pongo la variabile libero ad uno (strada occupata), altrimenti in caso contrario incremento la distanza analizzata dal sensore */ |
- libero=1; |
- else |
- distant++; |
- } |
- else /* il veicolo e' nella seconda corsia */ |
- while (libero==0 && distant<distsic) /* il calcolo della distanza da un veicolo che ci precede termina quando viene trovato un veicolo o si raggiunge la lunghezza massima di visione del sensore */ |
- { |
- fine=pos_x+distant; /* nel caso in cui il veicolo si giunto alla fine dell'autostrada si assume che il sensore ritorni un valore come nel caso in cui non sia preceduto da nessun veicolo */ |
- if (fine>40000) |
- distant=distsic; |
- else |
- if (corsia1[fine]!=0) /* se la strada e' occupata da un'altro veicolo pongo la variabile libero ad uno (strada occupata), altrimenti in caso contrario incremento la distanza analizzata dal sensore */ |
- libero=1; |
- else |
- distant++; |
- } |
- sem_post(&strada); |
- |
- return(distant); /* ritorna il valore della distanza misurata dal sensore , se non ha trovato nessun veicolo tale distanza e' pari alla massima lunghezza a cui puo' arrivare il sensore */ |
-} |
- |
- |
-/* ----------------------------------------------------------------------------- */ |
- |
- |
-/** FUNZIONE CHE CALCOLA LA DISTANZA ANTERIORE DESTRA DI UN VEICOLO CHE PRECEDE **/ |
- |
-int dist_ant_dx(int pos_x,int pos_y,int distsicdx) |
-{ |
- int distantdx; /* distanza dal veicolo che ci precede a destra */ |
- int libero; /* variabile che indica se l'attuale posizione puntata dal veicolo e' libera */ |
- int fine; /* variabile ausiliaria per capire se sto' arrivando alla fine della strada */ |
- |
- /* inizializzazione delle variabili */ |
- libero=0; |
- distantdx=0; |
- |
- sem_wait(&strada); |
- while (libero==0 && distantdx<distsicdx) /* il calcolo della distanza da un veicolo che ci precede a destra termina quando viene trovato un veicolo o si raggiunge la lunghezza massima di visione del sensore */ |
- { |
- fine=pos_x+distantdx; /* nel caso in cui il veicolo sia giunto alla fine dell'autostrada si assume che il sensore ritorni un valore come nel caso in cui non sia preceduto da nessun veicolo */ |
- if (fine>40000) |
- distantdx=distsicdx; |
- else |
- if (corsia1[fine]!=0) /* se la strada e' occupata da un'altro veicolo pongo la variabile libero ad uno (strada occupata), altrimenti in caso contrario incremento la distanza analizzata dal sensore */ |
- libero=1; |
- else |
- distantdx++; |
- } |
- sem_post(&strada); |
- |
- return(distantdx); /* ritorna il valore della distanza misurata dal sensore , se non ha trovato nessun veicolo tale distanza e' pari alla massima lunghezza a cui puo' arrivare il sensore */ |
-} |
- |
- |
-/* ----------------------------------------------------------------------------- */ |
- |
- |
-/** FUNZIONE CHE CALCOLA LA DISTANZA ANTERIORE SINISTRA DI UN VEICOLO CHE PRECEDE **/ |
- |
-int dist_ant_sx(int pos_x,int pos_y,int distsicsx) |
-{ |
- int distantsx; /* distanza dal veicolo che ci precede a sinistra */ |
- int libero; /* variabile che indica se l'attuale posizione puntata dal veicolo e' libera */ |
- int fine; /* variabile ausiliaria per capire se sto' arrivando alla fine della strada */ |
- |
- /* inizializzazione delle variabili */ |
- libero=0; |
- distantsx=0; |
- |
- sem_wait(&strada); |
- while (libero==0 && distantsx<distsicsx) /* il calcolo della distanza da un veicolo che ci precede a sinistra termina quando viene trovato un veicolo o si raggiunge la lunghezza massima di visione del sensore */ |
- { |
- fine=pos_x+distantsx; /* nel caso in cui il veicolo si giunto alla fine dell'autostrada si assume che il sensore ritorni un valore come nel caso in cui non sia preceduto da nessun veicolo */ |
- if (fine>40000) |
- distantsx=distsicsx; |
- else |
- if (corsia2[fine]!=0) /* se la strada e' occupata da un'altro veicolo pongo la variabile libero ad uno (strada occupata), altrimenti in caso contrario incremento la distanza analizzata dal sensore */ |
- libero=1; |
- else |
- distantsx++; |
- } |
- sem_post(&strada); |
- |
- return(distantsx); /* ritorna il valore della distanza misurata dal sensore , se non ha trovato nessun veicolo tale distanza e' pari alla massima lunghezza a cui puo' arrivare il sensore */ |
-} |
- |
- |
-/* ----------------------------------------------------------------------------- */ |
- |
- |
-/** FUNZIONE CHE CALCOLA LA DISTANZA POSTERIORE SINISTRA DI UN VEICOLO CHE INSEGUE **/ |
- |
-int dist_postsx (int pos_x,int pos_y,int distsorp) |
-{ |
- int distpostsx; /* distanza dal veicolo che ci insegue a sinistra */ |
- int libero; /* variabile che indica se l'attuale posizione puntata dal veicolo e' libera */ |
- int inizio; /* variabile ausiliaria per capire se sono all'inizio della strada */ |
- |
- /* inizializzazione delle variabili */ |
- distpostsx=0; |
- libero=0; |
- |
- sem_wait(&strada); |
- while (libero==0 && distpostsx<distsorp) /* il calcolo della distanza da un veicolo che ci insegue a sinistra termina quando viene trovato un veicolo o si raggiunge la lunghezza massima di visione del sensore */ |
- { |
- inizio=pos_x-distpostsx; /* nel caso in cui il veicolo si giunto alla fine dell'autostrada si assume che il sensore ritorni un valore come nel caso in cui non sia insuguito da nessun veicolo */ |
- if (inizio<0) |
- distpostsx=distsorp; |
- else |
- if (corsia2[inizio]!=0) /* se la strada e' occupata da un'altro veicolo pongo la variabile libero ad uno (strada occupata), altrimenti in caso contrario incremento la distanza analizzata dal sensore */ |
- libero=1; |
- else |
- distpostsx++; |
- } |
- sem_post(&strada); |
- |
- return(distpostsx); /* ritorna il valore della distanza misurata dal sensore , se non ha trovato nessun veicolo tale distanza e' pari alla massima lunghezza a cui puo' arrivare il sensore */ |
-} |
- |
- |
-/* ----------------------------------------------------------------------------- */ |
- |
- |
-/** FUNZIONE CHE CALCOLA LA DISTANZA POSTERIORE DESTRA DI UN VEICOLO CHE INSEGUE **/ |
- |
-int dist_postdx (int pos_x,int pos_y,int distrientro) |
-{ |
- int distpostdx; /* distanza dal veicolo che ci insegue a destra */ |
- int libero; /* variabile che indica se l'attuale posizione puntata dal veicolo e' libera */ |
- int inizio; /* variabile ausiliaria per capire se sono all'inizio della strada */ |
- |
- /* inizializzazione delle variabili */ |
- libero=0; |
- distpostdx=0; |
- |
- sem_wait(&strada); |
- while (libero==0 && distpostdx<distrientro) /* il calcolo della distanza da un veicolo che ci insegue a destra termina quando viene trovato un veicolo o si raggiunge la lunghezza massima di visione del sensore */ |
- { |
- inizio=pos_x-distpostdx; /* nel caso in cui il veicolo si giunto alla fine dell'autostrada si assume che il sensore ritorni un valore come nel caso in cui non sia inseguito da nessun veicolo */ |
- if (inizio<0) |
- distpostdx=distrientro; |
- else |
- if (corsia1[inizio]!=0) /* se la strada e' occupata da un'altro veicolo pongo la variabile libero ad uno (strada occupata), altrimenti in caso contrario incremento la distanza analizzata dal sensore */ |
- libero=1; |
- else |
- distpostdx++; |
- } |
- sem_post(&strada); |
- |
- return(distpostdx); /* ritorna il valore della distanza misurata dal sensore , se non ha trovato nessun veicolo tale distanza e' pari alla massima lunghezza a cui puo' arrivare il sensore */ |
-} |
- |
- |
-/* ----------------------------------------------------------------------------- */ |
- |
- |
-/**************************** TASK AUTO LENTA ******************************/ |
- |
-TASK auto_lenta(void *arg) |
-{ |
- int x; /* posizione x assunta dal veicolo */ |
- int y; /* posizione y assunta dal veicolo */ |
- int oxelic; /* posizione vecchia dell'elicottero */ |
- int ox; /* posizione vecchia x dall'auto lenta */ |
- int oy; /* posizione vecchia y dall'auto lenta */ |
- int k; /* indice di ciclo */ |
- int estremo; /* distanza massima a cui ci possiamo spostare dall'elicottero (sia a destra che a sinistra) */ |
- int sorpasso; /* indica se il veicolo e' in fase di sorpasso */ |
- int rientro; /* indica se il veicolo e' in fase di rientro */ |
- int precedentedritto; /* distanza anteriore da un veicolo */ |
- int od; /* vecchia distanza anteriore da un veicolo */ |
- int tot; /* distanza massima raggiungibile del sensore posteriore sinistro */ |
- int tot3; /* distanza massima raggiungibile del sensore anteriore destro */ |
- int tot2; /* distanza massima raggiungibile del sensore posteriore destro */ |
- int i = (int)arg; |
- int sensore_ant=200; /* distanza massima raggiungibile del sensore anteriore */ |
- char stri[22]; /* vettore di caratteri */ |
- char ostri[22]; /* vettore di caratteri */ |
- float vcrociera; /* velocita' desiderata */ |
- float vmax2=35.0; /* velocita' massima raggiungibile in seconda corsia */ |
- float vmax1=25.0; /* velocita' massima raggiungibile in prima corsia */ |
- float frenata=-7.0; /* valore massimo della frenata */ |
- float amax=10.0; /* valore massimo dell'accellerazione */ |
- float v; /* velocita' attuale */ |
- float a; /* accellerazione attuale */ |
- float ov; /* velocita' precedente */ |
- float oa; /* accellerazione precedente */ |
- |
- /* inizializzazione delle variabili */ |
- v=5.0; |
- a=0.0; |
- x=LUNGLENTA; |
- y=CENTROCORSIA1; |
- sorpasso=0; |
- rientro=0; |
- tot=100; |
- tot2=150; |
- tot3=100; |
- vcrociera=vmax1; |
- oa=a; |
- ov=v; |
- od=0; |
- oxelic=xelic; |
- estremo=(int)((MAX_X/2)-1); |
- |
- while (1) |
- { |
- /* cancella il veicolo se era presente sull'autostrada vista dall'elicottero */ |
- if (abs(oxelic-ox)<estremo) |
- draw_veicolo(ox-oxelic+estremo, oy, 0,LUNGLENTA,LARGLENTA); |
- |
- /* salva le vecchie coordinate */ |
- ox = x; |
- oy = y; |
- |
- /* cancella il veicolo dalla vecchia posizione sulla corsia , andando a cancellarlo nel vettore della corsia in cui si trovava */ |
- sem_wait(&strada); |
- for (k=0;k<LUNGLENTA;k++) |
- { |
- if ((oy<CENTROCORSIA1) && (oy>CENTROCORSIA2)) |
- { |
- corsia1[ox-k]=0; |
- corsia2[ox-k]=0; |
- } |
- else |
- if (oy==CENTROCORSIA1) |
- corsia1[ox-k]=0; |
- else |
- if (oy==CENTROCORSIA2) |
- corsia2[ox-k]=0; |
- } |
- sem_post(&strada); |
- |
- /* cancella tutte le vecchie informazioni che compaiono sullo schermo */ |
- sprintf(stri,"posizione %d",(int)(ox*0.25)); |
- sem_wait(&mutex); |
- grx_text(stri,70,50+i*10,rgb16(0,0,0),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- sprintf(ostri,"a %nf",oa); |
- sem_wait(&mutex); |
- grx_text(ostri,300,50+i*10,rgb16(0,0,0),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- sprintf(ostri,"v %nf",ov); |
- sem_wait(&mutex); |
- grx_text(ostri,200,50+i*10,rgb16(0,0,0),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- /* legge la distanza dal sensore anteriore e nel caso in cui sia attaccato alla macchina che precede vengo eliminato */ |
- precedentedritto=dist_ant(x,y,sensore_ant); |
- if (precedentedritto==1) |
- task_abort(i); |
- |
- /* disegna il veicolo nella nuova posizione */ |
- if (abs(xelic-x)<estremo) |
- draw_veicolo(x-xelic+estremo, y, rgb16(255,0,0),LUNGLENTA,LARGLENTA); |
- |
- /* varia la massima distanza vista dal sensore posteriore sinistro a seconda della velocita' */ |
- tot=(int)(v*4); |
- if (tot<50) |
- tot=50; |
- |
- if (precedentedritto<100) /* ci siamo avvicinando troppo alla macchina che ci precede */ |
- if ((sorpasso==0) && (dist_postsx(x,y,200)>tot)&&(dist_ant_sx(x,y,50)>40)) |
- { |
- /* c'e' uno davanti e non sopraggiunge nessuno sulla corsia di sorpasso */ |
- sorpasso=1; |
- rientro=0; |
- vcrociera=vmax2; |
- } |
- else |
- a=frenata; /* c'e qualcuno davanti ,ma non possiamo sorpassare */ |
- else /* siamo lontani da un veicolo che ci precede o non ci precede nessuno */ |
- if (v<vcrociera) /* accelleriamo gradualmente fino a portarci alla velocita' di crociera desiderata */ |
- a=amax-(amax/vcrociera)*v; |
- else |
- if(v>vcrociera) /* freniamo per portarci al valore della velocita'di crociera */ |
- a=frenata/3; |
- else |
- a=0.0; /* siamo alla velocita' di crociera */ |
- |
- /* controlla se e' possibile la manovra di rientro dal sorpasso, aggiustando tutti i parametri nel modo corretto */ |
- if ((dist_postdx(x,y,200)>tot2) && (dist_ant_dx(x,y,200)>tot3) && (sorpasso==1)) |
- { |
- rientro=1; |
- sorpasso=0; |
- vcrociera=vmax1; |
- } |
- |
- /* aggiusta la cordinata y per far visualizzare il sorpasso o il rientro della macchina in modo graduale */ |
- if(y>CENTROCORSIA2 && sorpasso==1) |
- y=y-1; |
- |
- if(y<CENTROCORSIA1 && rientro==1) |
- y=y+1; |
- |
- /* calcola la velocita' e nel caso di v elocita' negative la pone a zero (non sono permesse le retromarcie) */ |
- v=v+a*DT; |
- if (v<0) |
- v=0.0; |
- |
- /* calcola la cordinata x a cui si trova la macchina */ |
- x=x+(int)((v*DT)/0.25); |
- |
- /* scrive a video i nuovi parametri appena calcolati */ |
- sprintf(stri,"posizione %d",(int)(x*0.25)); |
- sem_wait(&mutex); |
- grx_text(stri,70,50+i*10,rgb16(255,255,255),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- sprintf(ostri,"v %nf",v); |
- sem_wait(&mutex); |
- grx_text(ostri,200,50+i*10,rgb16(255,255,255),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- sprintf(ostri,"a %nf",a); |
- sem_wait(&mutex); |
- grx_text(ostri,300,50+i*10,rgb16(255,255,255),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- /* quando il veicolo arriva alla fine dell'autostrada viene eliminato */ |
- if (x>=40000) |
- task_abort(i); |
- |
- /* salva la nuova posizione del veicolo */ |
- sem_wait(&strada); |
- for (k=0;k<LUNGLENTA;k++) |
- { |
- if ((y<CENTROCORSIA1) && (y>CENTROCORSIA2)) |
- { |
- corsia2[x-k]=1; |
- corsia1[x-k]=1; |
- } |
- else |
- if (y==CENTROCORSIA1) |
- corsia1[x-k]=1; |
- else |
- if (y==CENTROCORSIA2) |
- corsia2[x-k]=1; |
- } |
- sem_post(&strada); |
- |
- /* salvo i parametri che occorrono per il prossimo ciclo */ |
- oxelic=xelic; |
- od=precedentedritto; |
- ov=v; |
- oa=a; |
- |
- task_endcycle(); /* termina le operazioni che il task deve eseguire */ |
- } |
-} |
- |
- |
-/* ----------------------------------------------------------------------------- */ |
- |
- |
-/************************** TASK AUTO VELOCE *******************************/ |
- |
-TASK auto_veloce(void *arg) |
-{ |
- int x; /* posizione x assunta dal veicolo */ |
- int y; /* posizione y assunta dal veicolo */ |
- int oxelic; /* posizione vecchia dell'elicottero */ |
- int ox; /* posizione vecchia x dall'auto veloce */ |
- int oy; /* posizione vecchia y dall'auto veloce */ |
- int k; /* indice di ciclo */ |
- int estremo; /* distanza massima a cui ci possiamo spostare dall'elicottero (sia a destra che a sinistra) */ |
- int sorpasso; /* indica se il veicolo e' in fase di sorpasso */ |
- int rientro; /* indica se il veicolo e' in fase di rientro */ |
- int precedentedritto; /* distanza anteriore da un veicolo */ |
- int od; /* vecchia distanza anteriore da un veicolo */ |
- int tot; /* distanza massima raggiungibile del sensore posteriore sinistro */ |
- int tot3; /* distanza massima raggiungibile del sensore anteriore destro */ |
- int tot2; /* distanza massima raggiungibile del sensore posteriore destro */ |
- int i = (int)arg; |
- int sensore_ant=200; /* distanza massima raggiungibile del sensore anteriore */ |
- char stri[22]; /* vettore di caratteri */ |
- char ostri[22]; /* vettore di caratteri */ |
- float vcrociera; /* velocita' desiderata */ |
- float vmax1=35.0; /* velocita' massima raggiungibile in prima corsia */ |
- float vmax2=40.0; /* velocita' massima raggiungibile in seconda corsia */ |
- float frenata=-7.0; /* valore massimo della frenata */ |
- float amax=15.0; /* valore massimo del'accellerazione */ |
- float v; /* velocita' attuale */ |
- float a; /* accellerazione attuale */ |
- float ov; /* velocita' precedente */ |
- float oa; /* accellerazione precedente */ |
- |
- /* inizializzazione delle variabili */ |
- v=5.0; |
- a=0.0; |
- x=LUNGVELOCE; |
- y=CENTROCORSIA1; |
- sorpasso=0; |
- rientro=0; |
- tot=100; |
- tot2=150; |
- tot3=100; |
- oa=a; |
- vcrociera=vmax1; |
- ov=v; |
- od=0; |
- oxelic=xelic; |
- estremo=(int)((MAX_X/2)-1); |
- |
- while (1) |
- { |
- /* cancella il veicolo se era presente sull'autostrada vista dall'elicottero */ |
- if (abs(oxelic-ox)<estremo) |
- draw_veicolo(ox-oxelic+estremo, oy, 0,LUNGVELOCE,LARGVELOCE); |
- |
- /* salva le vecchie coordinate */ |
- ox = x; |
- oy = y; |
- |
- /* cancella il veicolo dalla vecchia posizione sulla corsia , andando a cancellarlo nel vettore della corsia in cui si trovava */ |
- sem_wait(&strada); |
- for (k=0;k<LUNGVELOCE;k++) |
- { |
- if ((oy<CENTROCORSIA1) && (oy>CENTROCORSIA2)) |
- { |
- corsia1[ox-k]=0; |
- corsia2[ox-k]=0; |
- } |
- else |
- if (oy==CENTROCORSIA1) |
- corsia1[ox-k]=0; |
- else |
- if (oy==CENTROCORSIA2) |
- corsia2[ox-k]=0; |
- } |
- sem_post(&strada); |
- |
- /* cancella tutte le vecchie informazioni che compaiono sullo schermo */ |
- sprintf(stri,"posizione %d",(int)(ox*0.25)); |
- sem_wait(&mutex); |
- grx_text(stri,70,50+i*10,rgb16(0,0,0),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- sprintf(ostri,"v %nf",ov); |
- sem_wait(&mutex); |
- grx_text(ostri,200,50+i*10,rgb16(0,0,0),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- sprintf(ostri,"a %nf",oa); |
- sem_wait(&mutex); |
- grx_text(ostri,300,50+i*10,rgb16(0,0,0),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- /* legge la distanza dal sensore anteriore e nel caso in cui sia attaccato alla macchina che precede vengo eliminato */ |
- precedentedritto=dist_ant(x,y,sensore_ant); |
- if (precedentedritto==1) |
- task_abort(i); |
- |
- /* disegna il veicolo nella nuova posizione */ |
- if (abs(xelic-x)<estremo) |
- draw_veicolo(x-xelic+estremo, y, rgb16(0,255,0),LUNGVELOCE,LARGVELOCE); |
- |
- |
- /* varia la massima distanza vista dal sensore posteriore sinistro a seconda della velocita' */ |
- tot=(int)(v*4); |
- if (tot<50) |
- tot=50; |
- |
- if (precedentedritto<150) /* ci siamo avvicinando troppo alla macchina che ci precede */ |
- if ((sorpasso==0) && (dist_postsx(x,y,200)>tot)&&(dist_ant_sx(x,y,50)>40)) |
- { |
- /* c'e' uno davanti e non sopraggiunge nessuno sulla corsia di sorpasso */ |
- sorpasso=1; |
- rientro=0; |
- vcrociera=vmax2; |
- } |
- else /* c'e qualcuno davanti ,ma non possiamo sorpassare */ |
- a=frenata; |
- else /* siamo lontani da un veicolo che ci precede o non ci precede nessuno */ |
- if (v<vcrociera) /* accelleriamo gradualmente fino a portarci alla velocita' di crociera desiderata */ |
- a=amax-(amax/vcrociera)*v; |
- else |
- if(v>vcrociera) /* freniamo per portarci al valore della velocita'di crociera */ |
- a=frenata/3; |
- else |
- a=0.0; /* siamo alla velocita' di crociera */ |
- |
- /* controlla se e' possibile la manovra di rientro dal sorpasso, aggiustando tutti i parametri nel modo corretto */ |
- if ((dist_postdx(x,y,200)>tot2) && (dist_ant_dx(x,y,200)>tot3) && (sorpasso==1)) |
- { |
- rientro=1; |
- sorpasso=0; |
- vcrociera=vmax1; |
- } |
- |
- /* aggiusta la cordinata y per far visualizzare il sorpasso o il rientro della macchina in modo graduale */ |
- if(y>CENTROCORSIA2 && sorpasso==1) |
- y=y-1; |
- |
- if(y<CENTROCORSIA1 && rientro==1) |
- y=y+1; |
- |
- /* calcola la velocita' e nel caso di v elocita' negative la pone a zero (non sono permesse le retromarcie) */ |
- v=v+a*DT; |
- if (v<0) |
- v=0.0; |
- |
- /* calcola la cordinata x a cui si trova la macchina */ |
- x=x+(int)((v*DT)/0.25); |
- |
- /* scrive a video i nuovi parametri appena calcolati */ |
- sprintf(stri,"posizione %d",(int)(x*0.25)); |
- sem_wait(&mutex); |
- grx_text(stri,70,50+i*10,rgb16(255,255,255),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- sprintf(ostri,"v %nf",v); |
- sem_wait(&mutex); |
- grx_text(ostri,200,50+i*10,rgb16(255,255,255),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- sprintf(ostri,"a %nf",a); |
- sem_wait(&mutex); |
- grx_text(ostri,300,50+i*10,rgb16(255,255,255),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- /* quando il veicolo arriva alla fine dell'autostrada viene eliminato */ |
- if (x>=40000) |
- task_abort(i); |
- |
- /* salva la nuova posizione del veicolo */ |
- sem_wait(&strada); |
- for (k=0;k<LUNGVELOCE;k++) |
- { |
- if ((y<CENTROCORSIA1) && (y>CENTROCORSIA2)) |
- { |
- corsia2[x-k]=1; |
- corsia1[x-k]=1; |
- } |
- else |
- if (y==CENTROCORSIA1) |
- corsia1[x-k]=1; |
- else |
- if (y==CENTROCORSIA2) |
- corsia2[x-k]=1; |
- } |
- sem_post(&strada); |
- |
- /* salvo i parametri che occorrono per il prossimo ciclo */ |
- oxelic=xelic; |
- od=precedentedritto; |
- ov=v; |
- oa=a; |
- |
- task_endcycle(); /* termina le operazioni che il task deve eseguire */ |
- } |
-} |
- |
- |
-/* ----------------------------------------------------------------------------- */ |
- |
- |
-/***************************** TASK AUTOCARRO ******************************/ |
- |
-TASK auto_carro(void *arg) |
-{ |
- int x; /* posizione x assunta dal veicolo */ |
- int y; /* posizione y assunta dal veicolo */ |
- int oxelic; /* posizione vecchia dell'elicottero */ |
- int ox; /* posizione vecchia x assunta dal camion */ |
- int oy; /* posizione vecchia y assunta dal camion */ |
- int k; /* indice di ciclo */ |
- int estremo; /* distanza massima a cui ci possiamo spostare dall'elicottero (sia a destra che a sinistra) */ |
- int sorpasso; /* indica se il veicolo e' in fase di sorpasso */ |
- int rientro; /* indica se il veicolo e' in fase di rientro */ |
- int precedentedritto; /* distanza anteriore da un veicolo */ |
- int od; /* vecchia distanza anteriore da un veicolo */ |
- int tot; /* distanza massima raggiungibile del sensore posteriore sinistro */ |
- int tot3; /* distanza massima raggiungibile del sensore anteriore destro */ |
- int tot2; /* distanza massima raggiungibile del sensore posteriore destro */ |
- int i = (int)arg; |
- int sensore_ant=200; /* distanza massima raggiungibile del sensore anteriore */ |
- char stri[22]; /* vettore di caratteri */ |
- char ostri[22]; /* vettore di caratteri */ |
- float vcrociera; /* velocita' desiderata */ |
- float vmax1=15.0; /* velocita' massima raggiungibile in prima corsia */ |
- float vmax2=20.0; /* velocita' massima raggiungibile in seconda corsia */ |
- float frenata=-5.0; /* valore massimo della frenata */ |
- float amax=3.0; /* valore massimo del'accellerazione */ |
- float v; /* velocita' attuale */ |
- float a; /* accellerazione attuale */ |
- float ov; /* velocita' precedente */ |
- float oa; /* accellerazione precedente */ |
- |
- /* inizializzazione delle variabili */ |
- v=5.0; |
- a=0.0; |
- x=LUNGCAMION; |
- y=CENTROCORSIA1; |
- sorpasso=0; |
- rientro=0; |
- tot=100; |
- tot2=150; |
- tot3=100; |
- oa=a; |
- vcrociera=vmax1; |
- ov=v; |
- od=0; |
- oxelic=xelic; |
- estremo=(int)((MAX_X/2)-1); |
- |
- while (1) |
- { |
- /* cancella il veicolo se era presente sull'autostrada vista dall'elicottero */ |
- if (abs(oxelic-ox)<estremo) |
- draw_veicolo(ox-oxelic+estremo, oy, 0,LUNGCAMION,LARGCAMION); |
- |
- /* salva le vecchie coordinate */ |
- ox = x; |
- oy = y; |
- |
- /* cancella il veicolo dalla vecchia posizione sulla corsia , andando a cancellarlo nel vettore della corsia in cui si trovava */ |
- sem_wait(&strada); |
- for (k=0;k<LUNGCAMION;k++) |
- { |
- if ((oy<CENTROCORSIA1) && (oy>CENTROCORSIA2)) |
- { |
- corsia1[ox-k]=0; |
- corsia2[ox-k]=0; |
- } |
- else |
- if (oy==CENTROCORSIA1) |
- corsia1[ox-k]=0; |
- else |
- if (oy==CENTROCORSIA2) |
- corsia2[ox-k]=0; |
- } |
- sem_post(&strada); |
- |
- /* cancella tutte le vecchie informazioni che compaiono sullo schermo */ |
- sprintf(stri,"posizione %d",(int)(ox*0.25)); |
- sem_wait(&mutex); |
- grx_text(stri,70,50+i*10,rgb16(0,0,0),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- sprintf(ostri,"v %nf",ov); |
- sem_wait(&mutex); |
- grx_text(ostri,200,50+i*10,rgb16(0,0,0),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- sprintf(ostri,"a %nf",oa); |
- sem_wait(&mutex); |
- grx_text(ostri,300,50+i*10,rgb16(0,0,0),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- /* legge la distanza dal sensore anteriore e nel caso in cui sia attaccato alla macchina che precede vengo eliminato */ |
- precedentedritto=dist_ant(x,y,sensore_ant); |
- if (precedentedritto==1) |
- task_abort(i); |
- |
- /* disegna il veicolo nella nuova posizione */ |
- if (abs(xelic-x)<estremo) |
- draw_veicolo(x-xelic+estremo, y, rgb16(0,0,255),LUNGCAMION,LARGCAMION); |
- |
- /* varia la massima distanza vista dal sensore posteriore sinistro a seconda della velocita' */ |
- tot=(int)(v*4); |
- if (tot<50) |
- tot=50; |
- |
- if (precedentedritto<100) /* ci siamo avvicinando troppo alla macchina che ci precede */ |
- if ((sorpasso==0) && (dist_postsx(x,y,200)>tot)&&(dist_ant_sx(x,y,50)>40)) |
- { |
- /* c'e' uno davanti e non sopraggiunge nessuno sulla corsia di sorpasso */ |
- sorpasso=1; |
- rientro=0; |
- vcrociera=vmax2; |
- } |
- else /* c'e qualcuno davanti ,ma non possiamo sorpassare */ |
- a=frenata; |
- else /* siamo lontani da un veicolo che ci precede o non ci precede nessuno */ |
- if (v<vcrociera) /* accelleriamo gradualmente fino a portarci alla velocita' di crociera desiderata */ |
- a=amax-(amax/vcrociera)*v; |
- else |
- if(v>vcrociera) /* freniamo per portarci al valore della velocita'di crociera */ |
- a=frenata/3; |
- else |
- a=0.0; /* siamo alla velocita' di crociera */ |
- |
- /* controlla se e' possibile la manovra di rientro dal sorpasso, aggiustando tutti i parametri nel modo corretto */ |
- if ((dist_postdx(x,y,200)>tot2) && (dist_ant_dx(x,y,200)>tot3) && (sorpasso==1)) |
- { |
- rientro=1; |
- sorpasso=0; |
- vcrociera=vmax1; |
- } |
- |
- /* aggiusta la cordinata y per far visualizzare il sorpasso o il rientro della macchina in modo graduale */ |
- if(y>CENTROCORSIA2 && sorpasso==1) |
- y=y-1; |
- |
- if(y<CENTROCORSIA1 && rientro==1) |
- y=y+1; |
- |
- /* calcola la velocita' e nel caso di v elocita' negative la pone a zero (non sono permesse le retromarcie) */ |
- v=v+a*DT; |
- if (v<0) |
- v=0.0; |
- |
- /* calcola la cordinata x a cui si trova la macchina */ |
- x=x+(int)((v*DT)/0.25); |
- |
- /* scrive a video i nuovi parametri appena calcolati */ |
- sprintf(stri,"posizione %d",(int)(x*0.25)); |
- sem_wait(&mutex); |
- grx_text(stri,70,50+i*10,rgb16(255,255,255),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- sprintf(ostri,"v %nf",v); |
- sem_wait(&mutex); |
- grx_text(ostri,200,50+i*10,rgb16(255,255,255),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- sprintf(ostri,"a %nf",a); |
- sem_wait(&mutex); |
- grx_text(ostri,300,50+i*10,rgb16(255,255,255),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- /* quando il veicolo arriva alla fine dell'autostrada viene eliminato */ |
- if (x>=40000) |
- task_abort(i); |
- |
- /* salva la nuova posizione del veicolo */ |
- sem_wait(&strada); |
- for (k=0;k<LUNGCAMION;k++) |
- { |
- if ((y<CENTROCORSIA1) && (y>CENTROCORSIA2)) |
- { |
- corsia2[x-k]=1; |
- corsia1[x-k]=1; |
- } |
- else |
- if (y==CENTROCORSIA1) |
- corsia1[x-k]=1; |
- else |
- if (y==CENTROCORSIA2) |
- corsia2[x-k]=1; |
- } |
- sem_post(&strada); |
- |
- /* salvo i parametri che occorrono per il prossimo ciclo */ |
- oxelic=xelic; |
- od=precedentedritto; |
- ov=v; |
- oa=a; |
- |
- task_endcycle(); /* termina le operazioni che il task deve eseguire */ |
- } |
-} |
- |
- |
-/* ----------------------------------------------------------------------------- */ |
- |
- |
-/***************************** TASK ELICOTTERO *****************************/ |
- |
-TASK eli_cottero(void *arg) |
-{ |
- int i = (int)arg; |
- int oxelic; /* vecchia posizione dell'elicottero */ |
- char stri[22]; /* vettore di caratteri */ |
- char ostri[22]; /* vettore di caratteri */ |
- |
- /* disegna le scritte per l'indicatore a barra e finestra della posizione dell'elicottero */ |
- sprintf(stri,"0 Km"); |
- sem_wait(&mutex); |
- grx_text(stri,100,560,rgb16(255,255,255),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- sprintf(stri,"10 Km"); |
- sem_wait(&mutex); |
- grx_text(stri,700,560,rgb16(255,255,255),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- while (1) |
- { |
- oxelic=xelic; /* salva la posizione precedente dell'elicottero */ |
- |
- if (c == '+') /* sposta l'elicottero a destra (verso la fine dell'autostrada */ |
- { |
- xelic=xelic+50; |
- if (xelic>40000-(int)((MAX_X/2)-1)) |
- xelic=40000-(int)((MAX_X/2)-1); |
- } |
- else |
- if (c =='-') /* sposta l'elicottero a sinistra (verso l'inizio dell'autostrada */ |
- { |
- xelic=xelic-30; |
- if (xelic<(int)((MAX_X/2)-1)) |
- xelic=(int)((MAX_X/2)-1); |
- } |
- |
- /* disegna le scritte innerenti all'elicottero e il valore della sua posizione (mediante scritta ed indicatore a barra con una finestra scorrevole) */ |
- sprintf(stri,"- <- xelic %d -> +",(int)(xelic*0.25)); |
- sprintf(ostri,"- <- xelic %d -> +",(int)(oxelic*0.25)); |
- |
- sem_wait(&mutex); |
- grx_text(ostri,MAX_X/2-50,500,rgb16(0,0,0),rgb16(0,0,0)); |
- grx_text(stri,MAX_X/2-50,500,rgb16(255,255,255),rgb16(0,0,0)); |
- grx_line(150,560,650,560,rgb16(255,255,255)); |
- grx_rect((int)((oxelic-(MAX_X/2))/80+150),540,(int)((oxelic+(MAX_X/2))/80+150) ,580 ,rgb16(0,0,0)); |
- grx_rect((int)((xelic-(MAX_X/2))/80+150),540,(int)((xelic+(MAX_X/2))/80+150) ,580 ,rgb16(255,255,255)); |
- sem_post(&mutex); |
- |
- c=' '; /* setta il carattere c */ |
- |
- task_endcycle(); /* termina le operazioni che il task deve eseguire */ |
- } |
-} |
- |
- |
-/* -----------------------------------------------------------------------------*/ |
- |
- |
-/************* FUNZIONE DI USCITA DAL SISTEMA ******************************/ |
- |
-void byebye(void *arg) |
-{ /* questa funzione e' chiamata quando il sistema esce */ |
- grx_close(); /* chiude la grafica */ |
- kern_printf("Ciao Ciao "); /* scrive il messaggio indicato sul terminale */ |
-} |
- |
- |
-/* -----------------------------------------------------------------------------*/ |
- |
- |
-/********************************* MAIN ************************************/ |
- |
-int main(int argc, char **argv) |
-{ |
- int n_task = 0; /* numero di task creati */ |
- int u; |
- int v; |
- char introduzione[100]; /* vettore di caratteri */ |
- HARD_TASK_MODEL autolenta; /* task auto lenta */ |
- HARD_TASK_MODEL autoveloce; /* task auto veloce */ |
- HARD_TASK_MODEL autocarro; /* task camion */ |
- HARD_TASK_MODEL elicottero; /* task elicottero */ |
- |
- |
- /* inizializza le corsie dell'autostrada */ |
- sem_wait(&strada); |
- for (u=0;u<=40000;u++) |
- { |
- corsia1[u]=0; |
- corsia2[u]=0; |
- } |
- sem_post(&strada); |
- |
- /* Set the exception handler */ |
- //set_exchandler_grx(); |
- |
- /* Set the closing function */ |
- sys_atrunlevel(byebye, NULL, RUNLEVEL_BEFORE_EXIT); |
- |
- /* inizializzazione grafica */ |
- if (grx_init() < 1) |
- sys_abort(1); |
- |
- /* scelta automatica della risoluzione applicabile con quella scheda video (scegliendola tra 800*600 e 1024*768 ) */ |
- if(grx_getmode(1024,768,16)==-1) |
- { |
- if (grx_open(800, 600, 16) < 0) |
- { |
- kern_printf("GRX Err\n"); |
- sys_abort(1); |
- } |
- MAX_X=800; |
- MAX_Y=600; |
- } |
- else |
- { |
- if (grx_open(1024,768, 16) < 0) |
- { |
- kern_printf("GRX Err\n"); |
- sys_abort(1); |
- } |
- MAX_X=1024; |
- MAX_Y=768; |
- } |
- |
- kern_printf("La scheda video va'!!\n"); |
- |
- /* posizione iniziale elicottero */ |
- xelic=(int)((MAX_X/2)-1); |
- |
- /* disegna lo scenario della strada ed il menu */ |
- sprintf(introduzione,"Monitoraggio dei mezzi che transitano su una autostrada."); |
- sem_wait(&mutex); |
- grx_text(introduzione,50,10,rgb16(255,255,255),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- sprintf(introduzione,"Sviluppato da: Verzellesi Quadrubbi"); |
- sem_wait(&mutex); |
- grx_text(introduzione,50,20,rgb16(255,255,255),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- sprintf(introduzione,"MENU"); |
- sem_wait(&mutex); |
- grx_text(introduzione,480,70,rgb16(255,255,255),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- sprintf(introduzione,"s = macchina sportiva"); |
- sem_wait(&mutex); |
- grx_text(introduzione,480,80,rgb16(255,255,255),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- sprintf(introduzione,"c = mezzo pesante"); |
- sem_wait(&mutex); |
- grx_text(introduzione,480,90,rgb16(255,255,255),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- sprintf(introduzione,"l = macchina lenta"); |
- sem_wait(&mutex); |
- grx_text(introduzione,480,100,rgb16(255,255,255),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- sprintf(introduzione,"+ = sposta l'elicottero verso destra"); |
- sem_wait(&mutex); |
- grx_text(introduzione,480,110,rgb16(255,255,255),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- sprintf(introduzione,"- = sposta l'elicottero verso sinistra"); |
- sem_wait(&mutex); |
- grx_text(introduzione,480,120,rgb16(255,255,255),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- sprintf(introduzione,"esc = uscita"); |
- sem_wait(&mutex); |
- grx_text(introduzione,480,130,rgb16(255,255,255),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- sprintf(introduzione,"NOTA"); |
- sem_wait(&mutex); |
- grx_text(introduzione,480,140,rgb16(255,0,0),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- sprintf(introduzione,"Se i veicoli tamponano "); |
- sem_wait(&mutex); |
- grx_text(introduzione,480,150,rgb16(255,255,255),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- sprintf(introduzione," vengono eliminati"); |
- sem_wait(&mutex); |
- grx_text(introduzione,480,160,rgb16(255,255,255),rgb16(0,0,0)); |
- sem_post(&mutex); |
- |
- grx_line(1,450,MAX_X,450,rgb16(255,255,255)); |
- grx_line(1,486,MAX_X,486,rgb16(255,255,255)); |
- |
- for (u=0;u<MAX_X;u++) |
- { |
- v=u%8; |
- if ((v==0) || (v==1)) |
- { |
- sem_wait(&mutex); |
- grx_plot(u,CENTROCARREGGIATA,rgb16(255,255,255)); |
- sem_post(&mutex); |
- } |
- } |
- |
- n_task=0; /* inizializzazione del numero dei task */ |
- |
- /* definisce e crea il task elicottero */ |
- kern_printf("elicottero"); |
- hard_task_default_model (elicottero); |
- hard_task_def_ctrl_jet (elicottero); |
- hard_task_def_arg (elicottero, (void *)n_task); |
- hard_task_def_wcet (elicottero,wcet); |
- hard_task_def_mit (elicottero, periodo); |
- hard_task_def_group (elicottero, GRUPPO); |
- hard_task_def_usemath (elicottero); |
- pid = task_create ("elicottero",eli_cottero, &elicottero, NULL); |
- if (pid == NIL) |
- { |
- grx_close(); |
- perror("Non si puo' creare il task"); |
- sys_abort(1); |
- } |
- task_activate(pid); |
- |
- n_task=1; /* incremente il numero dei task (ha creato l'elicottero */ |
- |
- /*Attesa di un carattere per creare un veicolo */ |
- c = keyb_getch(BLOCK); |
- do { |
- if (((c == 'c')||(c=='s')||(c=='l')) && (n_task < MAX_V)) /* in base al tasto premuto crea il task opportuno */ |
- { |
- if (c == 'l') /* definisce e crea il task autolenta */ |
- { |
- kern_printf("lenta"); |
- hard_task_default_model (autolenta); |
- hard_task_def_ctrl_jet (autolenta); |
- hard_task_def_arg (autolenta, (void *)n_task); |
- hard_task_def_wcet (autolenta, wcet); |
- hard_task_def_mit (autolenta, periodo); |
- hard_task_def_group (autolenta, GRUPPO); |
- hard_task_def_usemath (autolenta); |
- pid = task_create ("autolenta",auto_lenta, &autolenta, NULL); |
- } |
- else |
- if (c == 's') /* definisce e crea il task autoveloce */ |
- { |
- hard_task_default_model (autoveloce); |
- hard_task_def_ctrl_jet (autoveloce); |
- hard_task_def_arg (autoveloce, (void *)n_task); |
- hard_task_def_wcet (autoveloce, wcet); |
- hard_task_def_mit (autoveloce, periodo); |
- hard_task_def_group (autoveloce, GRUPPO); |
- hard_task_def_usemath (autoveloce); |
- pid = task_create ("autoveloce",auto_veloce, &autoveloce, NULL); |
- } |
- else |
- if (c == 'c') /* definisce e crea il task autocarro */ |
- { |
- hard_task_default_model (autocarro); |
- hard_task_def_ctrl_jet (autocarro); |
- hard_task_def_arg (autocarro, (void *)n_task); |
- hard_task_def_wcet (autocarro, wcet); |
- hard_task_def_mit (autocarro, periodo); |
- hard_task_def_group (autocarro, GRUPPO); |
- hard_task_def_usemath (autocarro); |
- pid = task_create ("camion",auto_carro, &autocarro, NULL); |
- } |
- |
- if (pid == NIL) /* nel caso in non si possano creare dei task chiude la grafica e con un messaggio segnala l'errore */ |
- { |
- grx_close(); |
- perror("Non si puo' creare il task"); |
- sys_abort(1); |
- } |
- |
- task_activate(pid); /* attiva i task */ |
- n_task++; /* incrementa il numero dei task creati */ |
- } |
- |
- c = keyb_getch(BLOCK); |
- |
- } while (c != ESC); /* termino il tutto solo quando e' stato premuto il tasto esc */ |
- |
- sys_end(); /* esco dal sistema */ |
- |
- return 0; |
-} |
Index: tags/rel_1_22/autostr/initfile.c |
=================================================================== |
--- tags/rel_1_22/autostr/initfile.c (revision 1310) |
+++ tags/rel_1_22/autostr/initfile.c (nonexistent) |
@@ -1,120 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- ------------ |
- CVS : $Id: initfile.c,v 1.1 2003-06-04 09:41:15 giacomo Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1 $ |
- Last update: $Date: 2003-06-04 09:41:15 $ |
- ------------ |
- |
- System initialization file |
- |
- This file contains the 2 functions needed to initialize the system. |
- |
- These functions register the following levels: |
- |
- an EDF (Earliest Deadline First) level |
- a RR (Round Robin) level |
- a CBS (Costant Bandwidth Server) level |
- a Dummy level |
- |
- It can accept these task models: |
- |
- HARD_TASK_MODEL (wcet+mit) at level 0 |
- SOFT_TASK_MODEL (met, period) at level 1 |
- NRT_TASK_MODEL at level 2 |
- |
- This file is similar to the configuration of kernel/init/hartik3.c |
- |
- TICK is set to 0 (one-shot timer is used) |
-*/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/cbs.h" |
-#include "modules/rr.h" |
-#include "modules/dummy.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
- |
-#include "drivers/keyb.h" |
- |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 0 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 10000 |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- EDF_register_level(EDF_ENABLE_ALL); |
- CBS_register_level(CBS_ENABLE_ALL, 0); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- |
- CABS_register_module(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- KEYB_PARMS kparms = BASE_KEYB; |
- |
- HARTPORT_init(); |
- |
- keyb_def_ctrlC(kparms, NULL); |
- keyb_def_map(kparms,itaMap); |
- KEYB_init(&kparms); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
Index: tags/rel_1_22/autostr/makefile |
=================================================================== |
--- tags/rel_1_22/autostr/makefile (revision 1310) |
+++ tags/rel_1_22/autostr/makefile (nonexistent) |
@@ -1,17 +0,0 @@ |
-# |
-# |
-# |
- |
-ifndef BASE |
-BASE=../.. |
-endif |
-include $(BASE)/config/config.mk |
- |
-PROGS= autostr |
- |
-include $(BASE)/config/example.mk |
- |
-autostr: |
- make -f $(SUBMAKE) APP=autostr INIT= OTHEROBJS="initfile.o" OTHERINCL= SHARKOPT="__OLDCHAR__ __GRX__" |
- |
- |
Index: tags/rel_1_22/svgademo/svgademo.c |
=================================================================== |
--- tags/rel_1_22/svgademo/svgademo.c (revision 1310) |
+++ tags/rel_1_22/svgademo/svgademo.c (nonexistent) |
@@ -1,196 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Giacomo Guidi <giacomo@gandalf.sssup.it> |
- * |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-#include <drivers/vga.h> |
-#include <drivers/keyb.h> |
- |
-#include <math.h> |
-#include <stdlib.h> |
- |
-#include <kernel/log.h> |
-#include <kernel/kern.h> |
- |
-#define WIDTH 800 |
-#define HEIGHT 600 |
-#define BYTES_PP 2 |
-#define INITSTR G800x600x64K //SVGAlib standard mode definitions |
-#define CARD VESA //Video driver |
- |
-unsigned char *rgb_565_buf = NULL; //RGB 16 bpp Buffer |
-unsigned char *video_buf = NULL; //Video Buffer |
-unsigned long int VMEMLONG = WIDTH * HEIGHT * BYTES_PP / 4; // Used by copy_videomem_16to16 |
-unsigned long int RGB565MEM = WIDTH * HEIGHT * BYTES_PP; // Total video mem |
- |
-unsigned long int PERIOD_REFRESH = 100000; |
-unsigned long int PERIOD_DISEGNA = 100000; |
- |
-unsigned long int WCET_REFRESH, WCET_DISEGNA; |
- |
-TASK refesh(void); |
-TASK disegna(void); |
- |
-PID refresh_PID, disegna_PID; |
- |
-static int screen(int mode) |
-{ |
- |
- vga_modeinfo *minf; |
- |
- vga_setmode(mode,CARD); |
- minf = vga_getmodeinfo(mode); |
- if(! (minf->flags & CAPABLE_LINEAR)){ |
- vga_setmode(TEXT,CARD); |
- printk(KERN_INFO "The mode %d is not capable of linear\n",mode); |
- return 1; |
- } |
- vga_setpage(0); |
- if(vga_setlinearaddressing() == -1) { |
- vga_setmode(TEXT,CARD); |
- printk(KERN_INFO "Could not set linear addressing for mode %d\n",mode); |
- return 1; |
- } |
- |
- video_buf = vga_getgraphmem(); |
- rgb_565_buf = malloc(RGB565MEM); |
- |
- grx_setbuffer(rgb_565_buf, WIDTH, HEIGHT); //Init of RGBA version of grx functions |
- //created to work with Mesa buffer |
- return 0; |
- |
-} |
- |
-void program_end(void *arg) |
-{ |
- |
- free(rgb_565_buf); |
- |
- vga_setmode(TEXT,CARD); |
- |
- sys_end(); |
- |
-} |
- |
-void program_key_end(KEY_EVT *k) |
-{ |
- |
- sys_end(); |
- |
-} |
- |
-TASK refresh(void) |
-{ |
- |
- while(1) { |
- |
- copy_videomem_16to16(rgb_565_buf, video_buf, VMEMLONG); |
- task_endcycle(); |
- |
- } |
- |
- sys_end(); |
- |
-} |
- |
- |
-TASK disegna(void) |
-{ |
- |
- char text[100]; |
- TIME disegna_TIME, refresh_TIME; |
- |
- while(1) { |
- |
- jet_gettable(refresh_PID, &refresh_TIME, 1); |
- jet_gettable(disegna_PID, &disegna_TIME, 1); |
- |
- sprintf(text,"Hard Task Refresh PER:%6d us EX:%6d us",(int)PERIOD_REFRESH,(int)refresh_TIME); |
- grx_text(text,10,5,rgb16(0,0,255),0); |
- sprintf(text,"Hard Task Draw PER:%6d us EX:%6d us",(int)PERIOD_DISEGNA,(int)disegna_TIME); |
- grx_text(text,10,15,rgb16(0,0,255),0); |
- |
- grx_text("SVGADEMO", 10,25,rgb16(255,0,0), 0); |
- grx_line(50,50,100,100,rgb16(0,255,0)); |
- grx_box(110,50,160,100,rgb16(0,0,255)); |
- grx_rect(170,50,220,100,rgb16(0,255,255)); |
- |
- task_endcycle(); |
- |
- } |
- |
- sys_end(); |
- |
-} |
- |
-int main (int argc, char *argv[]) |
-{ |
- |
- HARD_TASK_MODEL ht_refresh, ht_disegna; |
- |
- sys_atrunlevel(program_end,NULL, RUNLEVEL_BEFORE_EXIT); |
- |
- clear(); |
- |
- WCET_REFRESH =((long int) PERIOD_REFRESH * (0.45)); |
- WCET_DISEGNA =((long int) PERIOD_DISEGNA * (0.45)); |
- |
- hard_task_default_model(ht_refresh); |
- hard_task_def_wcet(ht_refresh,WCET_REFRESH); |
- hard_task_def_mit(ht_refresh,PERIOD_REFRESH); |
- hard_task_def_usemath(ht_refresh); |
- hard_task_def_group(ht_refresh,1); |
- hard_task_def_ctrl_jet(ht_refresh); |
- |
- refresh_PID = task_create("refresh", refresh, &ht_refresh, NULL); |
- if (refresh_PID == -1) { |
- sys_end(); |
- exit(4); |
- } |
- |
- hard_task_default_model(ht_disegna); |
- hard_task_def_mit(ht_disegna,PERIOD_DISEGNA); |
- hard_task_def_wcet(ht_disegna,WCET_DISEGNA); |
- hard_task_def_group(ht_disegna,1); |
- hard_task_def_ctrl_jet(ht_disegna); |
- hard_task_def_usemath(ht_disegna); |
- |
- disegna_PID = task_create("disegna", disegna, &ht_disegna, NULL); |
- if (disegna_PID == -1) { |
- sys_end(); |
- exit(4); |
- } |
- |
- { |
- KEY_EVT k; |
- k.flag = ALTL_BIT; |
- k.scan = KEY_C; |
- k.ascii = 'c'; |
- keyb_hook(k,program_key_end); |
- } |
- |
- if (screen(INITSTR)) { |
- printk(KERN_INFO "Graphical initialization failed !!\n"); |
- sys_end(); |
- } |
- |
- memset(rgb_565_buf, 0, RGB565MEM); |
- |
- group_activate(1); |
- |
- return 0; |
- |
-} |
Index: tags/rel_1_22/svgademo/readme.txt |
=================================================================== |
--- tags/rel_1_22/svgademo/readme.txt (revision 1310) |
+++ tags/rel_1_22/svgademo/readme.txt (nonexistent) |
@@ -1,34 +0,0 @@ |
--------------------------------------- |
-SVGA Demo |
- |
-by |
- |
-Giacomo Guidi <giacomo@gandalf.sssup.it> |
- |
-Last update 17/03/2003 |
--------------------------------------- |
- |
-This is a simple test demo for the new graphic |
-drivers ported from SVGAlib 1.9.17 |
- |
-See drivers/svga/readme for supported cards |
- |
--------------------------------------- |
- |
-The demo is composed by: |
- |
-MAKEFILE The makefile used to compile the application |
-README.TXT This file |
-INITFILE.C The init file |
-SVGADEMO.C The SVGA Demo |
- |
--------------------------------------- |
- |
-- To specify your card change the line |
- |
-#define CARD <driver name> |
- |
-- The demo calls the grx functions modified for the new |
-drivers. The resolution must be 16 bitsperpixel (64K colors) |
-and the graphic access mode must be linear. |
- |
Index: tags/rel_1_22/svgademo/makefile |
=================================================================== |
--- tags/rel_1_22/svgademo/makefile (revision 1310) |
+++ tags/rel_1_22/svgademo/makefile (nonexistent) |
@@ -1,16 +0,0 @@ |
-# |
-# |
-# |
- |
-ifndef BASE |
-BASE=../.. |
-endif |
-include $(BASE)/config/config.mk |
- |
-PROGS = svgademo |
- |
-include $(BASE)/config/example.mk |
- |
-svgademo: |
- make -f $(SUBMAKE) APP=svgademo INIT= OTHEROBJS="initfile.o" OTHERINCL= SHARKOPT="__OLDCHAR__ __SVGA__" |
- |
Index: tags/rel_1_22/svgademo/initfile.c |
=================================================================== |
--- tags/rel_1_22/svgademo/initfile.c (revision 1310) |
+++ tags/rel_1_22/svgademo/initfile.c (nonexistent) |
@@ -1,119 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- ------------ |
- CVS : $Id: initfile.c,v 1.2 2003-04-28 11:51:11 giacomo Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.2 $ |
- Last update: $Date: 2003-04-28 11:51:11 $ |
- ------------ |
- |
- System initialization file |
- |
- This file contains the 2 functions needed to initialize the system. |
- |
- These functions register the following levels: |
- |
- an EDF (Earliest Deadline First) level |
- a RR (Round Robin) level |
- a CBS (Costant Bandwidth Server) level |
- a Dummy level |
- |
- It can accept these task models: |
- |
- HARD_TASK_MODEL (wcet+mit) at level 0 |
- SOFT_TASK_MODEL (met, period) at level 1 |
- NRT_TASK_MODEL at level 2 |
- |
- This file is similar to the configuration of kernel/init/hartik3.c |
- |
- TICK is set to 0 (one-shot timer is used) |
-*/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/cbs.h" |
-#include "modules/rr.h" |
-#include "modules/dummy.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
- |
-#include "drivers/keyb.h" |
- |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 1000 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 10000 |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- EDF_register_level(EDF_ENABLE_ALL); |
- CBS_register_level(CBS_ENABLE_ALL, 0); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- |
- CABS_register_module(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- KEYB_PARMS kparms = BASE_KEYB; |
- |
- HARTPORT_init(); |
- |
- keyb_def_ctrlC(kparms, NULL); |
- KEYB_init(&kparms); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
Index: tags/rel_1_22/mesatex/readme.txt |
=================================================================== |
--- tags/rel_1_22/mesatex/readme.txt (revision 1310) |
+++ tags/rel_1_22/mesatex/readme.txt (nonexistent) |
@@ -1,44 +0,0 @@ |
--------------------------------------- |
-MESA Demo (tex) |
- |
-by |
- |
-Giacomo Guidi <giacomo@gandalf.sssup.it> |
- |
-Last update 17/03/2003 |
--------------------------------------- |
- |
-This is a simple test demo for the MESA (5.0) |
-libraries, the low level graphic drivers is |
-the SVGA (from the SVGAlib) |
- |
-See drivers/svga/readme for supported cards |
- |
--------------------------------------- |
- |
-The demo is composed by: |
- |
-MAKEFILE The makefile used to compile the application |
-README.TXT This file |
-INITFILE.C The init file |
-MESATEX.C The MESA Demo |
- |
--------------------------------------- |
- |
-- To specify your card change the line |
- |
-#define CARD <driver name> |
- |
-- The demo calls the grx and off-screen Mesa functions. |
-The resolution must be 16 bitsperpixel (64K colors) and |
-the graphic access mode must be linear. |
- |
-- There are two buffers |
- |
- The video buffer (video_buf) |
- The virtual buffer (rgb_565_buf) |
- |
- copy_videomem_16to16 links these buffers |
- |
- |
- |
Index: tags/rel_1_22/mesatex/makefile |
=================================================================== |
--- tags/rel_1_22/mesatex/makefile (revision 1310) |
+++ tags/rel_1_22/mesatex/makefile (nonexistent) |
@@ -1,16 +0,0 @@ |
-# |
-# |
-# |
- |
-ifndef BASE |
-BASE=../.. |
-endif |
-include $(BASE)/config/config.mk |
- |
-PROGS = mesatex |
- |
-include $(BASE)/config/example.mk |
- |
-mesatex: |
- make -f $(SUBMAKE) APP=mesatex INIT= OTHEROBJS="initfile.o" SHARKOPT="__OSMESA__ __OLDCHAR__ __SVGA__" |
- |
Index: tags/rel_1_22/mesatex/initfile.c |
=================================================================== |
--- tags/rel_1_22/mesatex/initfile.c (revision 1310) |
+++ tags/rel_1_22/mesatex/initfile.c (nonexistent) |
@@ -1,119 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- ------------ |
- CVS : $Id: initfile.c,v 1.2 2003-04-28 11:14:08 giacomo Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.2 $ |
- Last update: $Date: 2003-04-28 11:14:08 $ |
- ------------ |
- |
- System initialization file |
- |
- This file contains the 2 functions needed to initialize the system. |
- |
- These functions register the following levels: |
- |
- an EDF (Earliest Deadline First) level |
- a RR (Round Robin) level |
- a CBS (Costant Bandwidth Server) level |
- a Dummy level |
- |
- It can accept these task models: |
- |
- HARD_TASK_MODEL (wcet+mit) at level 0 |
- SOFT_TASK_MODEL (met, period) at level 1 |
- NRT_TASK_MODEL at level 2 |
- |
- This file is similar to the configuration of kernel/init/hartik3.c |
- |
- TICK is set to 0 (one-shot timer is used) |
-*/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/cbs.h" |
-#include "modules/rr.h" |
-#include "modules/dummy.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
- |
-#include "drivers/keyb.h" |
- |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 1000 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 10000 |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- EDF_register_level(EDF_ENABLE_ALL); |
- CBS_register_level(CBS_ENABLE_ALL, 0); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- |
- CABS_register_module(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- KEYB_PARMS kparms = BASE_KEYB; |
- |
- HARTPORT_init(); |
- |
- keyb_def_ctrlC(kparms, NULL); |
- KEYB_init(&kparms); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
Index: tags/rel_1_22/mesatex/mesatex.c |
=================================================================== |
--- tags/rel_1_22/mesatex/mesatex.c (revision 1310) |
+++ tags/rel_1_22/mesatex/mesatex.c (nonexistent) |
@@ -1,407 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Giacomo Guidi <giacomo@gandalf.sssup.it> |
- * |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-#include <drivers/vga.h> |
-#include <drivers/keyb.h> |
- |
-#include <GL/osmesa.h> |
-#include <GL/glut.h> |
- |
-#include <math.h> |
-#include <stdlib.h> |
-#include <assert.h> |
-#include <kernel/log.h> |
-#include <kernel/kern.h> |
- |
-#ifndef M_PI |
-#define M_PI 3.14159265 |
-#endif |
- |
-#define WIDTH 640 |
-#define HEIGHT 480 |
-#define BYTES_PP 2 //BytesPerPixel |
-#define INITSTR G640x480x64K //SVGAlib standard mode definitions |
-#define CARD VESA //Video driver |
- |
-OSMesaContext ctx; |
- |
-static GLuint TexObj[2]; |
-static GLfloat Angle = 0.0f; |
-static GLboolean UseObj = GL_FALSE; |
- |
-#if defined(GL_VERSION_1_1) || defined(GL_VERSION_1_2) |
-# define TEXTURE_OBJECT 1 |
-#elif defined(GL_EXT_texture_object) |
-# define TEXTURE_OBJECT 1 |
-# define glBindTexture(A,B) glBindTextureEXT(A,B) |
-# define glGenTextures(A,B) glGenTexturesEXT(A,B) |
-# define glDeleteTextures(A,B) glDeleteTexturesEXT(A,B) |
-#endif |
- |
-unsigned char *rgb_565_buf = NULL; //RGB 16 bpp Buffer |
-unsigned char *video_buf = NULL; //Video Buffer |
- |
-unsigned long int VMEMLONG = WIDTH * HEIGHT * BYTES_PP / 4; // Used by copy_videomem_16to16 |
-unsigned long int RGB565MEM = WIDTH * HEIGHT * BYTES_PP; // Total video mem |
- |
-unsigned long int PERIOD_REFRESH = 60000; |
-unsigned long int PERIOD_DISEGNA = 60000; |
- |
-unsigned long int WCET_REFRESH, WCET_DISEGNA; |
- |
-TASK refesh(void); |
-TASK disegna(void); |
- |
-PID refresh_PID, disegna_PID; |
- |
-static void draw( void ) |
-{ |
- glDepthFunc(GL_EQUAL); |
- /* glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );*/ |
- glClear( GL_COLOR_BUFFER_BIT ); |
- |
- glColor3f( 1.0, 1.0, 1.0 ); |
- |
- /* draw first polygon */ |
- glPushMatrix(); |
- glTranslatef( -1.0, 0.0, 0.0 ); |
- glRotatef( Angle, 0.0, 0.0, 1.0 ); |
- if (UseObj) { |
-#ifdef TEXTURE_OBJECT |
- glBindTexture( GL_TEXTURE_2D, TexObj[0] ); |
-#endif |
- } |
- else { |
- glCallList( TexObj[0] ); |
- } |
- glBegin( GL_POLYGON ); |
- glTexCoord2f( 0.0, 0.0 ); glVertex2f( -1.0, -1.0 ); |
- glTexCoord2f( 1.0, 0.0 ); glVertex2f( 1.0, -1.0 ); |
- glTexCoord2f( 1.0, 1.0 ); glVertex2f( 1.0, 1.0 ); |
- glTexCoord2f( 0.0, 1.0 ); glVertex2f( -1.0, 1.0 ); |
- glEnd(); |
- glPopMatrix(); |
- |
- /* draw second polygon */ |
- glPushMatrix(); |
- glTranslatef( 1.0, 0.0, 0.0 ); |
- glRotatef( Angle-90.0, 0.0, 1.0, 0.0 ); |
- if (UseObj) { |
-#ifdef TEXTURE_OBJECT |
- glBindTexture( GL_TEXTURE_2D, TexObj[1] ); |
-#endif |
- } |
- else { |
- glCallList( TexObj[1] ); |
- } |
- glBegin( GL_POLYGON ); |
- glTexCoord2f( 0.0, 0.0 ); glVertex2f( -1.0, -1.0 ); |
- glTexCoord2f( 1.0, 0.0 ); glVertex2f( 1.0, -1.0 ); |
- glTexCoord2f( 1.0, 1.0 ); glVertex2f( 1.0, 1.0 ); |
- glTexCoord2f( 0.0, 1.0 ); glVertex2f( -1.0, 1.0 ); |
- glEnd(); |
- glPopMatrix(); |
- |
-} |
- |
- |
-static void gl_init() |
-{ |
- |
- static GLfloat h = (GLfloat) HEIGHT / (GLfloat) WIDTH; |
- static int twidth=8, theight=8; |
- static GLubyte tex1[] = { |
- 0, 0, 0, 0, 0, 0, 0, 0, |
- 0, 0, 0, 0, 1, 0, 0, 0, |
- 0, 0, 0, 1, 1, 0, 0, 0, |
- 0, 0, 0, 0, 1, 0, 0, 0, |
- 0, 0, 0, 0, 1, 0, 0, 0, |
- 0, 0, 0, 0, 1, 0, 0, 0, |
- 0, 0, 0, 1, 1, 1, 0, 0, |
- 0, 0, 0, 0, 0, 0, 0, 0 }; |
- |
- static GLubyte tex2[] = { |
- 0, 0, 0, 0, 0, 0, 0, 0, |
- 0, 0, 0, 2, 2, 0, 0, 0, |
- 0, 0, 2, 0, 0, 2, 0, 0, |
- 0, 0, 0, 0, 0, 2, 0, 0, |
- 0, 0, 0, 0, 2, 0, 0, 0, |
- 0, 0, 0, 2, 0, 0, 0, 0, |
- 0, 0, 2, 2, 2, 2, 0, 0, |
- 0, 0, 0, 0, 0, 0, 0, 0 }; |
- |
- GLubyte tex[64][3]; |
- GLint i, j; |
- |
- //Create the OSMesa Context |
- ctx = OSMesaCreateContext(OSMESA_RGB_565, NULL); |
- |
- //Make Current Context |
- OSMesaMakeCurrent(ctx, rgb_565_buf, GL_UNSIGNED_SHORT_5_6_5, WIDTH, HEIGHT); |
- |
- UseObj = GL_TRUE; |
- |
- glDisable( GL_DITHER ); |
- |
- /* Setup texturing */ |
- glEnable( GL_TEXTURE_2D ); |
- glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL ); |
- glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST ); |
- |
- /* generate texture object IDs */ |
- if (UseObj) { |
-#ifdef TEXTURE_OBJECT |
- glGenTextures( 2, TexObj ); |
-#endif |
- } |
- else { |
- TexObj[0] = glGenLists(2); |
- TexObj[1] = TexObj[0]+1; |
- } |
- |
- /* setup first texture object */ |
- if (UseObj) { |
-#ifdef TEXTURE_OBJECT |
- glBindTexture( GL_TEXTURE_2D, TexObj[0] ); |
- assert(glIsTexture(TexObj[0])); |
-#endif |
- } |
- else { |
- glNewList( TexObj[0], GL_COMPILE ); |
- } |
- /* red on white */ |
- for (i=0;i<theight;i++) { |
- for (j=0;j<twidth;j++) { |
- int p = i*twidth+j; |
- if (tex1[(theight-i-1)*twidth+j]) { |
- tex[p][0] = 255; tex[p][1] = 0; tex[p][2] = 0; |
- } |
- else { |
- tex[p][0] = 255; tex[p][1] = 255; tex[p][2] = 255; |
- } |
- } |
- } |
- |
- glTexImage2D( GL_TEXTURE_2D, 0, 3, twidth, theight, 0, |
- GL_RGB, GL_UNSIGNED_BYTE, tex ); |
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); |
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); |
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT ); |
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT ); |
- if (!UseObj) { |
- glEndList(); |
- } |
- /* end of texture object */ |
- |
- /* setup second texture object */ |
- if (UseObj) { |
-#ifdef TEXTURE_OBJECT |
- glBindTexture( GL_TEXTURE_2D, TexObj[1] ); |
- assert(glIsTexture(TexObj[1])); |
-#endif |
- assert(!glIsTexture(TexObj[1] + 999)); |
- } |
- else { |
- glNewList( TexObj[1], GL_COMPILE ); |
- } |
- /* green on blue */ |
- for (i=0;i<theight;i++) { |
- for (j=0;j<twidth;j++) { |
- int p = i*twidth+j; |
- if (tex2[(theight-i-1)*twidth+j]) { |
- tex[p][0] = 0; tex[p][1] = 255; tex[p][2] = 0; |
- } |
- else { |
- tex[p][0] = 0; tex[p][1] = 0; tex[p][2] = 255; |
- } |
- } |
- } |
- glTexImage2D( GL_TEXTURE_2D, 0, 3, twidth, theight, 0, |
- GL_RGB, GL_UNSIGNED_BYTE, tex ); |
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); |
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); |
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT ); |
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT ); |
- if (!UseObj) { |
- glEndList(); |
- } |
- /* end texture object */ |
- |
- glViewport(0, 0, (GLint)WIDTH, (GLint)HEIGHT); |
- glMatrixMode(GL_PROJECTION); |
- glLoadIdentity(); |
- /* glOrtho( -3.0, 3.0, -3.0, 3.0, -10.0, 10.0 );*/ |
- glFrustum( -2.0, 2.0, 2.0, -2.0, 6.0, 20.0 ); |
- glMatrixMode(GL_MODELVIEW); |
- glLoadIdentity(); |
- glTranslatef( 0.0, 0.0, -8.0 ); |
- |
-} |
- |
-static int screen(int mode) |
-{ |
- |
- vga_modeinfo *minf; |
- |
- vga_setmode(mode,CARD); |
- minf = vga_getmodeinfo(mode); |
- if(! (minf->flags & CAPABLE_LINEAR)){ |
- vga_setmode(TEXT,CARD); |
- printk(KERN_INFO "The mode %d is not capable of linear\n",mode); |
- return 1; |
- } |
- vga_setpage(0); |
- if(vga_setlinearaddressing() == -1) { |
- vga_setmode(TEXT,CARD); |
- printk(KERN_INFO "Could not set linear addressing for mode %d\n",mode); |
- return 1; |
- } |
- |
- video_buf = vga_getgraphmem(); |
- |
- grx_setbuffer(rgb_565_buf, WIDTH, HEIGHT); //Init of RGB16 version of grx functions |
- //created to work with Mesa buffer |
- return 0; |
- |
-} |
- |
-void program_end(void *arg) |
-{ |
- |
- OSMesaDestroyContext(ctx); |
- free(rgb_565_buf); |
- |
- vga_setmode(TEXT,CARD); |
- |
- sys_end(); |
- |
-} |
- |
-void program_key_end(KEY_EVT *k) |
-{ |
- |
- sys_end(); |
- |
-} |
- |
-TASK refresh(void) |
-{ |
- |
- while(1) { |
- |
- copy_videomem_16to16(rgb_565_buf, video_buf, VMEMLONG); |
- task_endcycle(); |
- |
- } |
- |
- sys_end(); |
- |
-} |
- |
- |
-TASK disegna(void) |
-{ |
- |
- char text[100]; |
- TIME disegna_TIME, refresh_TIME; |
- |
- while(1) { |
- |
- jet_gettable(refresh_PID, &refresh_TIME, 1); |
- jet_gettable(disegna_PID, &disegna_TIME, 1); |
- |
- Angle += 2.0; |
- |
- draw(); |
- |
- sprintf(text,"Hard Task Refresh PER:%6d us EX:%6d us",(int)PERIOD_REFRESH,(int)refresh_TIME); |
- grx_text(text,10,5,rgb16(0,0,255),0); |
- sprintf(text,"Hard Task Draw PER:%6d us EX:%6d us",(int)PERIOD_DISEGNA,(int)disegna_TIME); |
- grx_text(text,10,15,rgb16(0,0,255),0); |
- |
- task_endcycle(); |
- |
- } |
- |
- sys_end(); |
- |
-} |
- |
-int main (int argc, char *argv[]) |
-{ |
- |
- HARD_TASK_MODEL ht_refresh, ht_disegna; |
- |
- sys_atrunlevel(program_end,NULL, RUNLEVEL_BEFORE_EXIT); |
- |
- clear(); |
- |
- WCET_REFRESH =((long int) PERIOD_REFRESH * (0.45)); |
- WCET_DISEGNA =((long int) PERIOD_DISEGNA * (0.45)); |
- |
- hard_task_default_model(ht_refresh); |
- hard_task_def_wcet(ht_refresh,WCET_REFRESH); |
- hard_task_def_mit(ht_refresh,PERIOD_REFRESH); |
- hard_task_def_usemath(ht_refresh); |
- hard_task_def_group(ht_refresh,1); |
- hard_task_def_ctrl_jet(ht_refresh); |
- |
- refresh_PID = task_create("refresh", refresh, &ht_refresh, NULL); |
- if (refresh_PID == -1) { |
- sys_end(); |
- exit(4); |
- } |
- |
- hard_task_default_model(ht_disegna); |
- hard_task_def_mit(ht_disegna,PERIOD_DISEGNA); |
- hard_task_def_wcet(ht_disegna,WCET_DISEGNA); |
- hard_task_def_group(ht_disegna,1); |
- hard_task_def_ctrl_jet(ht_disegna); |
- hard_task_def_usemath(ht_disegna); |
- hard_task_def_stack(ht_disegna,30000); |
- |
- disegna_PID = task_create("disegna", disegna, &ht_disegna, NULL); |
- if (disegna_PID == -1) { |
- sys_end(); |
- exit(4); |
- } |
- |
- { |
- KEY_EVT k; |
- k.flag = ALTL_BIT; |
- k.scan = KEY_C; |
- k.ascii = 'c'; |
- keyb_hook(k,program_key_end); |
- } |
- |
- rgb_565_buf = malloc(RGB565MEM); |
- |
- gl_init(); |
- |
- if (screen(INITSTR)) { |
- printk(KERN_INFO "Graphical initialization failed !!\n"); |
- sys_end(); |
- } |
- |
- memset(rgb_565_buf, 0, RGB565MEM); |
- |
- group_activate(1); |
- |
- return 0; |
- |
-} |
Index: tags/rel_1_22/loader/common/nload.h |
=================================================================== |
--- tags/rel_1_22/loader/common/nload.h (revision 1310) |
+++ tags/rel_1_22/loader/common/nload.h (nonexistent) |
@@ -1,45 +0,0 @@ |
-/* Generic Struct for loader task */ |
-#ifndef __NLOAD_H__ |
-#define __NLOAD_H__ |
- |
-#include "func.h" //Constant definition for loader and linux parser |
- |
-struct loader_task { |
- |
- char name[20]; //Task name |
- int task_type; //Tast type (OS,CT,BT) |
- int contract; //Contract number |
- int local_scheduler; //Local scheduler for the task |
- int number; //How many copies of this task |
- int group; //Group number |
- |
- struct timespec deadline; //Task deadline |
- struct timespec wcet; //Task wcet |
- |
- int act_number; //Number of activations precalcolated |
- int act_current; //Actual activation number |
- |
- int resource; |
- int muxstatus; |
- |
- struct timespec *act; //Activation list |
- struct timespec *exec; //Execution time list |
- struct timespec *block; //Blocking time |
- |
-}; |
- |
-struct loader_contract { |
- |
- int number; //Contract number |
- struct timespec cmin; |
- struct timespec tmax; |
- struct timespec cmax; |
- struct timespec tmin; |
- int workload; |
- int local_scheduler; |
- int server; //Server number linked to this contract |
- |
-}; |
- |
-#endif |
- |
Index: tags/rel_1_22/loader/common/time.h |
=================================================================== |
--- tags/rel_1_22/loader/common/time.h (revision 1310) |
+++ tags/rel_1_22/loader/common/time.h (nonexistent) |
@@ -1,65 +0,0 @@ |
-#ifndef __TIME_H__ |
-#define __TIME_H__ |
- |
-#define TIMESPEC2NANOSEC(t) ((t)->tv_sec * 1000000000 + (t)->tv_nsec) |
-#define TIMESPEC2USEC(t) ((t)->tv_sec * 1000000 + (t)->tv_nsec / 1000) |
-#define NULL_TIMESPEC(t) ((t)->tv_sec = (t)->tv_nsec = 0) |
-#define ADDNANO2TIMESPEC(n, t) ((t)->tv_nsec += (n), \ |
- (t)->tv_sec += (t)->tv_nsec / 1000000000, \ |
- (t)->tv_nsec %= 1000000000) |
- |
-#define SUBTIMESPEC(s1, s2, d) \ |
- ((d)->tv_nsec = ((s1)->tv_nsec >= (s2)->tv_nsec) ? \ |
- (((d)->tv_sec = (s1)->tv_sec - (s2)->tv_sec), \ |
- (s1)->tv_nsec - (s2)->tv_nsec) \ |
- : \ |
- (((d)->tv_sec = (s1)->tv_sec - (s2)->tv_sec - 1), \ |
- (1000000000 + (s1)->tv_nsec - (s2)->tv_nsec))) |
- |
-/* |
- * ...and these not! |
- */ |
- |
-extern __inline__ void ADDTIMESPEC(const struct timespec *s1, |
- const struct timespec *s2, |
- struct timespec *d) |
-{ |
- d->tv_sec = s1->tv_sec + s2->tv_sec; |
- d->tv_nsec = s1->tv_nsec + s2->tv_nsec; |
- |
- if (d->tv_nsec < 0) { |
- d->tv_sec--; |
- d->tv_nsec += 1000000000; |
- } else if (d->tv_nsec >= 1000000000) { |
- d->tv_sec++; |
- d->tv_nsec -= 1000000000; |
- } |
-} |
- |
- |
-#define ADDUSEC2TIMESPEC(m, t) ((t)->tv_nsec += (m%1000000)*1000, \ |
- (t)->tv_sec += ((t)->tv_nsec / 1000000000) + (m/1000000), \ |
- (t)->tv_nsec %= 1000000000) |
- |
-#define TIMESPEC_A_LT_B(a,b) \ |
- ( \ |
- ((a)->tv_sec < (b)->tv_sec) || \ |
- ((a)->tv_sec == (b)->tv_sec && (a)->tv_nsec < (b)->tv_nsec) \ |
- ) |
- |
-#define TIMESPEC_A_GT_B(a,b) \ |
- ( \ |
- ((a)->tv_sec > (b)->tv_sec) || \ |
- ((a)->tv_sec == (b)->tv_sec && (a)->tv_nsec > (b)->tv_nsec) \ |
- ) |
- |
-#define TIMESPEC_A_EQ_B(a,b) \ |
- ((a)->tv_sec == (b)->tv_sec && (a)->tv_nsec == (b)->tv_nsec) |
- |
-#define TIMESPEC_A_NEQ_B(a,b) \ |
- ((a)->tv_sec != (b)->tv_sec || (a)->tv_nsec != (b)->tv_nsec) |
- |
-#define TIMESPEC_ASSIGN(t1,t2) \ |
- ((t1)->tv_sec = (t2)->tv_sec, (t1)->tv_nsec = (t2)->tv_nsec) |
- |
-#endif |
Index: tags/rel_1_22/loader/common/lconst.h |
=================================================================== |
--- tags/rel_1_22/loader/common/lconst.h (revision 1310) |
+++ tags/rel_1_22/loader/common/lconst.h (nonexistent) |
@@ -1,36 +0,0 @@ |
-#define PAR_TOTAL_EXEC_TIME 0 |
-#define PAR_TIME 1 |
-#define PAR_ACT_TYPE 2 |
-#define PAR_TASK_NUMBER 3 |
-#define PAR_EXEC_TYPE 4 |
-#define PAR_TASK_TYPE 5 |
-#define PAR_NOTHING 6 |
-#define PAR_DEADLINE 7 |
-#define PAR_ERROR 8 |
-#define PAR_FOUND 9 |
-#define PAR_CRIT_SESSION 10 |
-#define PAR_END 11 |
- |
-#define PAR_EXEC_CONST 12 |
-#define PAR_EXEC_MEAN 13 |
- |
-#define PAR_CONTRACT_SECTION 14 |
-#define PAR_TASK_SECTION 15 |
- |
-#define PAR_ACT_SINGLE 16 |
-#define PAR_ACT_PERIODIC 17 |
-#define PAR_ACT_MEAN 18 |
- |
-#define PAR_TASK_OS 21 |
-#define PAR_TASK_CT 22 |
-#define PAR_TASK_BT 23 |
- |
-#define PAR_NO_CRIT 26 |
-#define PAR_CRIT 27 |
- |
-#define PAR_LOCAL_SCHEDULER 29 |
-#define PAR_POSIX 30 |
-#define PAR_EDF 31 |
-#define PAR_RM 32 |
- |
-#define PAR_FSF_SERVER 33 |
Index: tags/rel_1_22/loader/common/calibrate.h |
=================================================================== |
--- tags/rel_1_22/loader/common/calibrate.h (revision 1310) |
+++ tags/rel_1_22/loader/common/calibrate.h (nonexistent) |
@@ -1,8 +0,0 @@ |
- |
-/* Nunber of calibration iterations */ |
-#define CALIBRATION_DELTA 100000 |
- |
-/* Usec of exec time for CALIBRATING_DELTA iterations |
- Set to 0 if you calibrate during loader execution */ |
-#define CALIBRATION_RESULT 0 |
- |
Index: tags/rel_1_22/loader/common/nload.c |
=================================================================== |
--- tags/rel_1_22/loader/common/nload.c (revision 1310) |
+++ tags/rel_1_22/loader/common/nload.c (nonexistent) |
@@ -1,315 +0,0 @@ |
-/* FSF Loader |
- * |
- * Load and run a specific set of tasks/contracts |
- * |
- * This is the system indipendent part |
- * |
- * Giacomo Guidi <giacomo@gandalf.sssup.it> |
- * Michael Timarchi <trimarchi@gandalf.sssup.it> |
- * |
- */ |
- |
-#include "fsf_contract.h" //Framework main header |
-#include "calibrate.h" |
-#include "func.h" //Generic function definitions |
-#include "lconst.h" |
- |
-/* Activate task output debug */ |
-#define TASK_OUTPUT |
- |
-int cal_cycles = CALIBRATION_RESULT; //Calibration const, it converts usec to cycles |
-struct timespec zero_time; //Zero time of the simulation |
-extern struct loader_task loader_task_list[]; //Loader task array |
-extern int total_loader_task; //Loader task number |
- |
-/* OS: Oneshot Task: |
- begin |
- - execution |
- end |
-*/ |
-void *oneshot_task(void *arg) |
-{ |
- long long i,exec_cycles = 0; |
- struct loader_task *l = (struct loader_task *)(arg); |
- #ifdef TASK_OUTPUT |
- #ifdef OS_SHARK |
- char tmp[20]; |
- #endif |
- #endif |
- |
- start_oneshot_task(); |
- |
- /* to avoid problem if the task start inside the create function */ |
- if (l->act_current == 0) l->act_current = 1; |
- #ifdef TASK_OUTPUT |
- #ifdef OS_SHARK |
- sprintf(tmp,"[ONESHOT]"); |
- printf_xy((get_current_exec_task() % 5) * 9 + 34,get_current_exec_task() / 5 + 5, GREEN, tmp); |
- #endif |
- #endif |
- |
- exec_cycles = (long long)(TIMESPEC2USEC(&l->exec[l->act_current-1])) * CALIBRATION_DELTA / cal_cycles; |
- |
- /* Execution delay */ |
- for (i=0;i<exec_cycles;i++) |
- __asm__ __volatile__ ("xorl %%eax,%%eax\n\t" |
- "cpuid\n\t" |
- :::"eax","ebx","ecx","edx"); |
- |
- end_oneshot_task(); |
- |
- #ifdef TASK_OUTPUT |
- #ifdef OS_SHARK |
- sprintf(tmp,"[--END--]"); |
- printf_xy((get_current_exec_task() % 5) * 9 + 34,get_current_exec_task() / 5 + 5, GREEN, tmp); |
- #endif |
- #endif |
- |
- return NULL; |
- |
-} |
- |
-/* CT: Cyclical Task: |
- begin |
- while (1) { |
- - execution |
- - end_cycle |
- } |
- end (never end) |
-*/ |
-void *periodic_task(void *arg) |
-{ |
- long long i,exec_cycles = 0,block_cycles = 0; |
- int act = 0; |
- struct loader_task *l = (struct loader_task *)(arg); |
- |
- #ifdef TASK_OUTPUT |
- #ifdef OS_SHARK |
- char tmp[20]; |
- #endif |
- #endif |
- |
- start_periodic_task(); |
- |
- if (l->act_current == 0) l->act_current = 1; |
- |
- while(1) { |
- |
- start_job_periodic_task(); |
- |
- #ifdef TASK_OUTPUT |
- #ifdef OS_SHARK |
- sprintf(tmp,"C[%06d]",act); |
- printf_xy((get_current_exec_task() % 5) * 9 + 34,get_current_exec_task() / 5 + 5, GREEN, tmp); |
- #endif |
- #endif |
- |
- exec_cycles = (long long)(TIMESPEC2USEC(&l->exec[l->act_current-1])) * CALIBRATION_DELTA / cal_cycles; |
- block_cycles = (long long)(TIMESPEC2USEC(&l->block[l->act_current-1])) * CALIBRATION_DELTA / cal_cycles; |
- |
- /* Execution delay */ |
- for (i=0;i<exec_cycles;i++) |
- __asm__ __volatile__ ("xorl %%eax,%%eax\n\t" |
- "cpuid\n\t" |
- :::"eax","ebx","ecx","edx"); |
- if (l->muxstatus == 2) { |
- |
- #ifdef TASK_OUTPUT |
- #ifdef OS_SHARK |
- sprintf(tmp,"C[LOCK%02d]",l->resource); |
- printf_xy((get_current_exec_task() % 5) * 9 + 34,get_current_exec_task() / 5 + 5, RED, tmp); |
- #endif |
- #endif |
- |
- generic_lock_mutex(l->resource); |
- for (i=0;i<block_cycles;i++) |
- __asm__ __volatile__ ("xorl %%eax,%%eax\n\t" |
- "cpuid\n\t" |
- :::"eax","ebx","ecx","edx"); |
- generic_unlock_mutex(l->resource); |
- |
- #ifdef TASK_OUTPUT |
- #ifdef OS_SHARK |
- sprintf(tmp,"C[FREE%02d]",l->resource); |
- printf_xy((get_current_exec_task() % 5) * 9 + 34,get_current_exec_task() / 5 + 5, GREEN, tmp); |
- #endif |
- #endif |
- |
- } |
- |
- end_job_periodic_task(); |
- |
- generic_task_endcycle(); |
- |
- act++; |
- |
- } |
- |
- end_periodic_task(); |
- |
- #ifdef TASK_OUTPUT |
- #ifdef OS_SHARK |
- sprintf(tmp,"[--END--]"); |
- printf_xy((get_current_exec_task() % 5) * 9 + 34,get_current_exec_task() / 5 + 5, GREEN, tmp); |
- #endif |
- #endif |
- |
- return NULL; |
- |
-} |
- |
-/* BT: Background Task: |
- begin |
- while (1) { |
- - execution |
- } |
- end (never end) |
-*/ |
-void *back_task(void *arg) |
-{ |
- long long i,exec_cycles = 0,block_cycles = 0; |
- int act = 0; |
- struct loader_task *l = (struct loader_task *)(arg); |
- #ifdef TASK_OUTPUT |
- #ifdef OS_SHARK |
- char tmp[20]; |
- #endif |
- #endif |
- |
- start_back_task(); |
- |
- if (l->act_current == 0) l->act_current = 1; |
- |
- while(1) { |
- |
- start_job_back_task(); |
- |
- #ifdef TASK_OUTPUT |
- #ifdef OS_SHARK |
- sprintf(tmp,"B[%06d]",act); |
- printf_xy((get_current_exec_task() % 5) * 9 + 34,get_current_exec_task() / 5 + 5, GREEN, tmp); |
- #endif |
- #endif |
- |
- exec_cycles = (long long)(TIMESPEC2USEC(&l->exec[l->act_current-1])) * CALIBRATION_DELTA / cal_cycles; |
- block_cycles = (long long)(TIMESPEC2USEC(&l->block[l->act_current-1])) * CALIBRATION_DELTA / cal_cycles; |
- |
- /* Execution delay */ |
- for (i=0;i<exec_cycles;i++) |
- __asm__ __volatile__ ("xorl %%eax,%%eax\n\t" |
- "cpuid\n\t" |
- :::"eax","ebx","ecx","edx"); |
- if (l->muxstatus == 2) { |
- |
- #ifdef TASK_OUTPUT |
- #ifdef OS_SHARK |
- sprintf(tmp,"B[LOCK%02d]",l->resource); |
- printf_xy((get_current_exec_task() % 5) * 9 + 34,get_current_exec_task() / 5 + 5, RED, tmp); |
- #endif |
- #endif |
- |
- generic_lock_mutex(l->resource); |
- for (i=0;i<block_cycles;i++) |
- __asm__ __volatile__ ("xorl %%eax,%%eax\n\t" |
- "cpuid\n\t" |
- :::"eax","ebx","ecx","edx"); |
- generic_unlock_mutex(l->resource); |
- |
- #ifdef TASK_OUTPUT |
- #ifdef OS_SHARK |
- sprintf(tmp,"C[FREE%02d]",l->resource); |
- printf_xy((get_current_exec_task() % 5) * 9 + 34,get_current_exec_task() / 5 + 5, GREEN, tmp); |
- #endif |
- #endif |
- |
- } |
- |
- end_job_back_task(); |
- |
- act++; |
- |
- } |
- |
- end_back_task(); |
- |
- #ifdef TASK_OUTPUT |
- #ifdef OS_SHARK |
- sprintf(tmp,"[--END--]"); |
- printf_xy((get_current_exec_task() % 5) * 9 + 34,get_current_exec_task() / 5 + 5, GREEN, tmp); |
- #endif |
- #endif |
- |
- return NULL; |
- |
-} |
- |
-/* Task create */ |
-/* this function create the task struct in memory */ |
-void loader_task_create() |
-{ |
- |
- struct loader_task *current = loader_task_list; |
- int i=0, k=0; |
- |
- while (k <total_loader_task) { |
- k++; |
- |
- for (i=0; i < current->number; i++) { |
- |
- pthread_t j; |
- int err = 0; |
- |
- switch(current->task_type) { |
- case PAR_TASK_OS: |
- err = generic_create_thread(generic_get_server_from_contract(current->contract),&j,NULL, |
- oneshot_task,(void *)current,generic_get_task_model(current)); |
- break; |
- case PAR_TASK_BT: |
- err = generic_create_thread(generic_get_server_from_contract(current->contract),&j,NULL, |
- back_task,(void *)current,generic_get_task_model(current)); |
- break; |
- case PAR_TASK_CT: |
- err = generic_create_thread(generic_get_server_from_contract(current->contract),&j,NULL, |
- periodic_task,(void *)current,generic_get_task_model(current)); |
- break; |
- } |
- if (err) { |
- printf("Error fsf task creating\n"); |
- generic_end_simulation(); |
- } |
- |
- } |
- |
- current = &loader_task_list[k]; |
- |
- } |
- |
- printf("Created %d loader tasks\n",k); |
- |
- |
-} |
- |
-/* Main Function */ |
-int start_environment() |
-{ |
- |
- extern struct timespec total_time; |
- |
- /* Calibrate the exec time */ |
- generic_calibrate_cycle(); |
- |
- /* Create the servers usign defined contracts */ |
- generic_fsfinit(); |
- |
- /* Create the tasks */ |
- loader_task_create(); |
- |
- /* Start the simulation */ |
- generic_start_simulation(); |
- |
- /* Set the simulation end time */ |
- generic_set_simulation_time(&total_time); |
- |
- return 0; |
- |
-} |
Index: tags/rel_1_22/loader/marte/makefile.in |
=================================================================== |
--- tags/rel_1_22/loader/marte/makefile.in (revision 1310) |
+++ tags/rel_1_22/loader/marte/makefile.in (nonexistent) |
@@ -1,7 +0,0 @@ |
-# |
-# MaRTE OS dependecies |
-# |
- |
-os_specific_dep: |
- echo MaRTE dependencies here |
- |
Index: tags/rel_1_22/loader/shark/shark.mak |
=================================================================== |
--- tags/rel_1_22/loader/shark/shark.mak (revision 1310) |
+++ tags/rel_1_22/loader/shark/shark.mak (nonexistent) |
@@ -1,13 +0,0 @@ |
-ifndef BASE |
-BASE=../../.. |
-endif |
- |
-include $(BASE)/config/config.mk |
- |
-PROGS = TEST |
- |
-include $(BASE)/config/example.mk |
- |
-TEST: |
- make -f $(SUBMAKE) APP="nload" BASE=../../.. INIT= OTHEROBJS="event.o initfile.o shark.o fsfinit.o" OTHERINCL="-I." SHARKOPT="__OLDCHAR__ __FIRST__" |
- cp nload TEST |
Index: tags/rel_1_22/loader/shark/func.h |
=================================================================== |
--- tags/rel_1_22/loader/shark/func.h (revision 1310) |
+++ tags/rel_1_22/loader/shark/func.h (nonexistent) |
@@ -1,123 +0,0 @@ |
-#ifndef __FUNC_H__ |
-#define __FUNC_H__ |
- |
-#include "kernel/kern.h" |
-#include "shark.h" |
- |
-#define OS_SHARK |
- |
-#define get_current_exec_task() exec_shadow |
-/* Return the PID/pthread_t of calling task */ |
- |
-#define generic_get_server_from_contract get_server_from_contract |
-/* Return the server_id from the contract number used |
- * inside .fsf file to define contract parameters |
- * |
- * generic_get_server_from_contract(int contract_number) */ |
- |
-#define generic_create_thread fsf_create_thread |
-/* Create a task/thread inside a specific server. |
- * it's very similar to fsf_create_thread, but we need a parameter |
- * to set the local scheduler task and actually it's outside |
- * the framework |
- * |
- * generic_task_create( |
- * server number, |
- * pthread_t of created task (-1 if failed), |
- * pthread_attr_t, |
- * task_body, |
- * arg of the body (must be "(void *)current"), |
- * arg for real-time task specification) |
- */ |
- |
-#define generic_calibrate_cycle calibrate_cycle |
-/* Set the calibration parameter "cal_cycle" |
- * only if it's initialized to 0. The calibration routine |
- * calculates cal_cycle from CALIBRATION_DELTA. |
- * This step can also be performed outside the demo. |
- * Inside calibrate.h you can set the calibration parameters |
- * for calibration step performed outside. |
- * |
- * cal_cycle is the number of cycles that are needed to |
- * make CALIBRATION_DELTA number of iteration. |
- * |
- * kern_cli(); |
- * kern_gettime(&start); |
- * for (i=0;i<CALIBRATION_DELTA;i++) |
- * __asm__ __volatile__ ("xorl %%eax,%%eax\n\t" |
- * "cpuid\n\t" |
- * :::"eax","ebx","ecx","edx"); |
- * kern_gettime(&end); |
- * kern_sti(); |
- * |
- * SUBTIMESPEC(&end,&start,&diff); |
- * cal_cycles = TIMESPEC2USEC(&diff); |
- * |
- */ |
- |
-#define generic_set_next_activation set_next_activation |
-/* Set the next activation time. It's like fsf_schedule_next_timed_job |
- * but it don't return nothing |
- */ |
- |
-#define generic_set_simulation_time set_simulation_time |
-/* Set the end time of simulation */ |
- |
-#define generic_get_task_model get_task_model |
-/* Return a pointer to the struct that contains the |
- * local shceduler parameter */ |
- |
-#define generic_start_simulation start_simulation |
-/* Start the simulation */ |
- |
-#define generic_fsfinit() fsfinit() |
-/* Create the fsf_server */ |
- |
-#define generic_task_endcycle() task_endcycle() |
-/* The job is finished */ |
- |
-#define generic_end_simulation() sys_end() |
-/* Exit from simulation */ |
- |
-#define printf cprintf |
-/* Printf standard function */ |
- |
-/* Mutex */ |
-extern __inline__ void generic_lock_mutex(int res) { |
- extern mutex_t mutex_table[MAX_MUTEX]; |
- |
- mutex_lock(&mutex_table[res]); |
-} |
- |
-extern __inline__ void generic_unlock_mutex(int res) { |
- extern mutex_t mutex_table[MAX_MUTEX]; |
- |
- mutex_unlock(&mutex_table[res]); |
-} |
- |
-/* TASK RUNTIME FUNCTIONS */ |
- |
-extern __inline__ void start_oneshot_task(void) {} |
-extern __inline__ void end_oneshot_task(void) {} |
- |
-extern __inline__ void start_periodic_task(void) {} |
-extern __inline__ void start_job_periodic_task(void) { |
- task_testcancel(); |
-} |
-extern __inline__ void end_job_periodic_task(void) { |
- task_testcancel(); |
-} |
-extern __inline__ void end_periodic_task(void) {} |
- |
-extern __inline__ void start_back_task(void) {} |
-extern __inline__ void start_job_back_task(void) { |
- task_testcancel(); |
-} |
-extern __inline__ void end_job_back_task(void) { |
- task_testcancel(); |
-} |
-extern __inline__ void end_back_task(void) {} |
- |
-#endif |
- |
- |
Index: tags/rel_1_22/loader/shark/makefile.in |
=================================================================== |
--- tags/rel_1_22/loader/shark/makefile.in (revision 1310) |
+++ tags/rel_1_22/loader/shark/makefile.in (nonexistent) |
@@ -1,14 +0,0 @@ |
-# |
-# Shark dependecies |
-# |
- |
-os_specific_dep: out/shark.done out/makefile |
- |
- |
-out/shark.done: |
- cd out; cp -sf ../shark/*.c . |
- cd out; cp -sf ../shark/*.h . |
- touch out/shark.done |
- |
-out/makefile: shark/shark.mak |
- sed -e "s/TEST/$(TEST)/" shark/shark.mak > out/makefile |
Index: tags/rel_1_22/loader/shark/fsfinit.c |
=================================================================== |
--- tags/rel_1_22/loader/shark/fsfinit.c (revision 1310) |
+++ tags/rel_1_22/loader/shark/fsfinit.c (nonexistent) |
@@ -1,48 +0,0 @@ |
-#include "kernel/kern.h" |
-#include "fsf_server.h" |
-#include "fsf_contract.h" |
-#include "func.h" |
- |
-extern struct loader_contract loader_contract_list[]; |
-extern int total_loader_contract; |
- |
-void fsfinit() |
-{ |
- |
- struct loader_contract *c; |
- fsf_contract_parameters_t contract; |
- fsf_server_id_t server; |
- int i; |
- long long bw; |
- |
- for (i=0;i<total_loader_contract;i++) { |
- |
- c = &loader_contract_list[i]; |
- |
- fsf_initialize_contract(&contract); |
- |
- fsf_set_contract_basic_parameters(&contract,&c->cmin,&c->tmax,&c->cmax,&c->tmin,c->workload); |
- |
- if (c->local_scheduler != PAR_POSIX) { |
- |
- switch (c->local_scheduler) { |
- case PAR_EDF: |
- fsf_set_local_scheduler_parameter(&contract,FSF_SCHEDULER_EDF); |
- break; |
- case PAR_RM: |
- fsf_set_local_scheduler_parameter(&contract,FSF_SCHEDULER_RM); |
- break; |
- } |
- |
- } |
- |
- fsf_negotiate_contract(&contract,&server); |
- c->server = server; |
- bw = (long long)(MAX_BANDWIDTH) * TIMESPEC2USEC(&c->cmin) / TIMESPEC2USEC(&c->tmax); |
- cprintf("FSF CONTRACT %d SERVER %d MIN BW %d.%03d\n", c->number, c->server, |
- (int)(bw * 100 / MAX_BANDWIDTH), |
- (int)(bw * 100000 / MAX_BANDWIDTH % 1000)); |
- |
- } |
- |
-} |
Index: tags/rel_1_22/loader/shark/initfile.c |
=================================================================== |
--- tags/rel_1_22/loader/shark/initfile.c (revision 1310) |
+++ tags/rel_1_22/loader/shark/initfile.c (nonexistent) |
@@ -1,98 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Giacomo Guidi <giacomo@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/cbs.h" |
-#include "modules/posix.h" |
-#include "pthread.h" |
-#include "drivers/keyb.h" |
-#include "modules/sem.h" |
-#include "modules/dummy.h" |
-#include "modules/hartport.h" |
- |
-#include "fsf_contract.h" |
-#include "fsf_server.h" |
- |
-#include "modules/pi.h" |
-#include "modules/pc.h" |
- |
-#define TICK 0 |
- |
-#define RRTICK 10000 |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- int grubstar_level; |
- |
- EDF_register_level(EDF_ENABLE_ALL); |
- POSIX_register_level(RRTICK, 1, mb, 32); |
- grubstar_level = GRUBSTAR_register_level(FSF_MAX_N_SERVERS, 0); |
- FSF_register_module(grubstar_level); |
- dummy_register_level(); |
- |
- CBS_register_level(CBS_ENABLE_ALL,0); |
- |
- SEM_register_module(); |
- |
- PI_register_module(); |
- PC_register_module(); |
- |
- PTHREAD_register_module(1, 0, 1); |
- |
- return TICK; |
- |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- HARTPORT_init(); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
-int main() { |
- |
- return start_environment(); |
- |
-} |
- |
Index: tags/rel_1_22/loader/shark/shark.c |
=================================================================== |
--- tags/rel_1_22/loader/shark/shark.c (revision 1310) |
+++ tags/rel_1_22/loader/shark/shark.c (nonexistent) |
@@ -1,244 +0,0 @@ |
-#include "func.h" |
-#include "calibrate.h" |
-#include <tracer.h> |
- |
-extern int cal_cycles; |
-extern struct timespec zero_time; |
-extern struct loader_task loader_task_list[]; |
-extern struct loader_contract loader_contract_list[]; |
-extern int total_loader_task; |
-extern int total_loader_contract; |
- |
-mutex_t mutex_table[MAX_MUTEX]; |
- |
-/* Runtime Calibration */ |
-int calibrate_cycle() |
-{ |
- long long i; |
- struct timespec start,end,diff; |
- |
- if (cal_cycles != 0) return 0; |
- |
- kern_cli(); |
- __asm__ __volatile__ ("xorl %%eax,%%eax\n\t" |
- "cpuid\n\t" |
- :::"eax","ebx","ecx","edx"); |
- kern_gettime(&start); |
- for (i=0;i<CALIBRATION_DELTA;i++) |
- __asm__ __volatile__ ("xorl %%eax,%%eax\n\t" |
- "cpuid\n\t" |
- :::"eax","ebx","ecx","edx"); |
- __asm__ __volatile__ ("xorl %%eax,%%eax\n\t" |
- "cpuid\n\t" |
- :::"eax","ebx","ecx","edx"); |
- kern_gettime(&end); |
- kern_sti(); |
- |
- SUBTIMESPEC(&end,&start,&diff); |
- cal_cycles = TIMESPEC2USEC(&diff); |
- cprintf("Calibration usec/[%d cycles] = %d\n",CALIBRATION_DELTA,cal_cycles); |
- |
- return 0; |
- |
-} |
- |
-int get_server_from_contract(int contract) |
-{ |
- |
- int i; |
- |
- for(i=0;i<total_loader_contract;i++) |
- if (loader_contract_list[i].number == contract) |
- return loader_contract_list[i].server; |
- |
- return -1; |
- |
-} |
- |
-void *get_task_model(struct loader_task *current) { |
- if (current->local_scheduler == PAR_POSIX) { |
- static NRT_TASK_MODEL nrt; |
- |
- nrt_task_default_model(nrt); |
- nrt_task_def_save_arrivals(nrt); |
- nrt_task_def_ctrl_jet(nrt); |
- nrt_task_def_group(nrt,current->group); |
- nrt_task_def_usemath(nrt); |
- |
- return &nrt; |
- |
- } |
- |
- if (current->local_scheduler == PAR_EDF) { |
- static HARD_TASK_MODEL ht; |
- |
- hard_task_default_model(ht); |
- hard_task_def_ctrl_jet(ht); |
- hard_task_def_mit(ht,TIMESPEC2USEC(¤t->deadline)); |
- hard_task_def_wcet(ht,TIMESPEC2USEC(¤t->wcet)); |
- hard_task_def_group(ht,current->group); |
- hard_task_def_aperiodic(ht); |
- hard_task_def_usemath(ht); |
- return &ht; |
- } |
- |
- |
- if (current->local_scheduler == PAR_RM) { |
- static HARD_TASK_MODEL ht; |
- |
- hard_task_default_model(ht); |
- hard_task_def_mit(ht,TIMESPEC2USEC(¤t->deadline)); |
- hard_task_def_wcet(ht,TIMESPEC2USEC(¤t->wcet)); |
- hard_task_def_ctrl_jet(ht); |
- hard_task_def_group(ht,current->group); |
- hard_task_def_usemath(ht); |
- return &ht; |
- } |
- |
- return NULL; |
- |
-} |
- |
-TASK finish_task() { |
- |
- #ifdef __NEW_TRACER__ |
- |
- extern __volatile__ unsigned int TracerEventsPresent; |
- unsigned int k; |
- |
- SYS_FLAGS f; |
- |
- sleep(1); |
- |
- tracer_init_udp(1,"192.168.1.10","192.168.1.1"); |
- |
- tracer_create_udp_task(NULL,80); |
- |
- f = kern_fsave(); |
- k = TracerEventsPresent; |
- kern_frestore(f); |
- while(k > 0) { |
- f = kern_fsave(); |
- printf_xy(0,5,WHITE,"REM = %08d",k); |
- k = TracerEventsPresent; |
- kern_frestore(f); |
- } |
- |
- tracer_flush_sent_events(); |
- |
- #endif |
- |
- sys_end(); |
- |
- return NULL; |
- |
-} |
- |
-void end_simulation() { |
- |
- int i; |
- struct loader_task *l = loader_task_list; |
- extern __volatile__ unsigned int TracerEventsPresent; |
- |
- NRT_TASK_MODEL nrt; |
- |
- TRACER_LOGEVENT(FTrace_EVT_trace_stop,0,0,0); |
- |
- #ifdef __NEW_TRACER__ |
- |
- tracer_disable(); |
- |
- cprintf("Total Events Present %d\n",TracerEventsPresent); |
- |
- i = 0; |
- while (i < total_loader_task) { |
- |
- group_kill(l->group); |
- |
- i++; |
- l=&loader_task_list[i]; |
- |
- } |
- |
- nrt_task_default_model(nrt); |
- |
- task_activate(task_create("Finish",finish_task,&nrt,NULL)); |
- |
- #else |
- |
- sys_end(); |
- |
- #endif |
- |
-} |
- |
-void set_simulation_time (struct timespec *total) { |
- struct timespec end_time; |
- |
- ADDTIMESPEC(&zero_time,total,&end_time); |
- kern_event_post(&end_time,(void *)((void *)(end_simulation)),NULL); |
- |
-} |
- |
-/* Set the zero_time and post the first activation event */ |
-void start_simulation() { |
- |
- int i; |
- struct loader_task *l = loader_task_list; |
- struct timespec end_time; |
- PI_mutexattr_t a; |
- |
- PI_mutexattr_default(a); |
- |
- i = 0; |
- |
- #ifdef __NEW_TRACER__ |
- |
- tracer_initialize(10000000); |
- |
- tracer_enable(); |
- |
- #endif |
- |
- TRACER_LOGEVENT(FTrace_EVT_trace_start,0,0,0); |
- |
- kern_gettime(&zero_time); |
- |
- while (i < total_loader_task) { |
- |
- if (l->muxstatus == 1) { |
- mutex_init(&mutex_table[l->resource],&a); |
- l->muxstatus = 2; |
- } |
- |
- if (l->act_number > 0) { |
- ADDTIMESPEC(&zero_time, &l->act[0], &end_time); |
- l->act_current++; |
- kern_event_post(&end_time,(void *)((void *)(loader_task_activate)),l); |
- } |
- |
- i++; |
- l=&loader_task_list[i]; |
- |
- } |
- |
-} |
- |
-/* Activate task and post the new activation event */ |
-void loader_task_activate(struct loader_task *l) { |
- |
- struct timespec actual_time,end_time; |
- |
- kern_gettime(&actual_time); |
- group_activate(l->group); |
- |
- if (l->act_number > l->act_current) { |
- |
- ADDTIMESPEC(&actual_time, &l->act[l->act_current], &end_time); |
- |
- l->act_current++; |
- kern_event_post(&end_time,(void *)((void *)(loader_task_activate)),l); |
- |
- } |
- |
-} |
Index: tags/rel_1_22/loader/shark/shark.h |
=================================================================== |
--- tags/rel_1_22/loader/shark/shark.h (revision 1310) |
+++ tags/rel_1_22/loader/shark/shark.h (nonexistent) |
@@ -1,19 +0,0 @@ |
-#ifndef __SHARK_H__ |
-#define __SHARK_H__ |
- |
-#include "nload.h" |
-#include "lconst.h" |
- |
-#define MAX_MUTEX 20 |
- |
-int calibrate_cycle(); |
-void start_simulation(); |
-void *get_task_model(struct loader_task *current); |
-void set_simulation_time (struct timespec *total); |
-void set_next_activation(struct timespec *next); |
-void loader_task_activate(struct loader_task *l); |
-int get_server_from_contract(int contract); |
- |
-void fsfinit(); |
- |
-#endif |
Index: tags/rel_1_22/loader/generators/lread.c |
=================================================================== |
--- tags/rel_1_22/loader/generators/lread.c (revision 1310) |
+++ tags/rel_1_22/loader/generators/lread.c (nonexistent) |
@@ -1,95 +0,0 @@ |
-#include <stdio.h> |
-#include <stdlib.h> |
-#include "lparser.h" |
-#include "common/time.h" |
- |
-int dos_preload(char *file_name, long max_size, void **start_file, void **end_file) |
-{ |
- FILE *file; |
- void *buf; |
- long rd; |
- |
- |
- file = fopen(file_name,"r"); |
- if (file == NULL) return -1; |
- |
- buf = malloc(max_size); |
- *start_file = buf; |
- |
- while(((rd = fread(buf, 1, 2048, file)) == 2048) && |
- ((buf - *start_file + rd) < (max_size-2048))) { |
- buf += rd; |
- } |
- |
- *end_file = buf + rd; |
- |
- fclose(file); |
- return(0); |
- |
-} |
- |
-int line_reader(void *start_file, void *end_file, struct timespec *total, |
- struct loader_task **start_loader_task, struct loader_contract **start_loader_contract) |
-{ |
- |
- char *pbuf = start_file; |
- int res,line_num,total_loader_task,total_loader_contract; |
- struct loader_task *current_t = NULL; |
- struct loader_contract *current_c = NULL; |
- |
- NULL_TIMESPEC(total); |
- |
- line_num = 0; |
- total_loader_task = 0; |
- total_loader_contract = 0; |
- |
- while ((void *)(pbuf) < end_file) { |
- |
- line_num++; |
- |
- if (*start_loader_contract == NULL) |
- res = line_parser_contract(&pbuf, line_num, total, ¤t_c); |
- else |
- res = line_parser_contract(&pbuf, line_num, total, ¤t_c->next); |
- |
- if (res == 2) { |
- total_loader_contract++; |
- if (*start_loader_contract == NULL) |
- *start_loader_contract = current_c; |
- else |
- current_c = current_c->next; |
- } |
- |
- if (res == 3) break; |
- |
- } |
- |
- while ((void *)(pbuf) < end_file) { |
- |
- line_num++; |
- |
- if (*start_loader_task == NULL) |
- res = line_parser_task(&pbuf, line_num, ¤t_t); |
- else |
- res = line_parser_task(&pbuf, line_num, ¤t_t->next); |
- |
- if (res == 2) { |
- total_loader_task++; |
- if (*start_loader_task == NULL) |
- *start_loader_task = current_t; |
- else |
- current_t = current_t->next; |
- } |
- |
- if (res == 3) break; |
- |
- } |
- |
- printf("Total decoded lines %d\n",line_num); |
- printf("Total loader contract %d\n",total_loader_contract); |
- printf("Total loader task %d\n",total_loader_task); |
- printf("Simulation time sec = %ld usec = %ld\n",total->tv_sec,total->tv_nsec/1000); |
- |
- return 0; |
- |
-} |
Index: tags/rel_1_22/loader/generators/lparser.c |
=================================================================== |
--- tags/rel_1_22/loader/generators/lparser.c (revision 1310) |
+++ tags/rel_1_22/loader/generators/lparser.c (nonexistent) |
@@ -1,471 +0,0 @@ |
-#include <stdlib.h> |
-#include <string.h> |
-#include <stdio.h> |
-#include "lparser.h" |
-#include "common/time.h" |
- |
-#define PARSER_DEBUG |
- |
-static int find_break(char **buf, int find_type, struct timespec *time, int *val) |
-{ |
- |
- int i; |
- char str[20]; |
- |
- i = 0; |
- while (((char *)(*buf))[i] == ' ' || ((char *)(*buf))[i] == ':' || |
- ((char *)(*buf))[i] == '\n' || ((char *)(*buf))[i] == '\r') i++; |
- *buf += i; |
- |
- if (!strncmp(*buf,"END",3) && find_type == PAR_NOTHING) { |
- *buf += 3; |
- return PAR_END; |
- } |
- |
- if (!strncmp(*buf,"CONTRACT SECTION",16) && find_type == PAR_NOTHING) { |
- *buf += 16; |
- return PAR_CONTRACT_SECTION; |
- } |
- |
- if (!strncmp(*buf,"TASK SECTION",12) && find_type == PAR_NOTHING) { |
- *buf += 12; |
- return PAR_TASK_SECTION; |
- } |
- |
- i = 0; |
- if (((char *)(*buf))[0] == '#' && find_type == PAR_NOTHING) { |
- while (((char *)(*buf))[i] != '\n' && ((char *)(*buf))[i] != '\r') i++; |
- *buf += i; |
- return PAR_FOUND; |
- } |
- |
- switch (find_type) { |
- |
- case PAR_NOTHING: |
- if (((char *)(*buf))[0] == ';' || |
- ((char *)(*buf))[0] < 32) { |
- *buf += 1; |
- return PAR_FOUND; |
- } |
- break; |
- |
- case PAR_TOTAL_EXEC_TIME: |
- if (!strncmp(*buf, "TOTAL_EXEC_TIME:",16)) { |
- *buf += 16; |
- return PAR_FOUND; |
- } |
- break; |
- |
- case PAR_TIME: |
- if (((char *)(*buf))[0] != '[') return PAR_ERROR; |
- *buf += 1; |
- i = 0; |
- while (((char *)(*buf))[i] >= '0' && ((char *)(*buf))[i] <= '9') { |
- str[i] = ((char *)(*buf))[i]; |
- i++; |
- } |
- if (((char *)(*buf))[i] != ']') return PAR_ERROR; |
- str[i] = 0; |
- time->tv_sec = atoi(str); |
- i += 2; |
- *buf += i; |
- i = 0; |
- while (((char *)(*buf))[i] >= '0' && ((char *)(*buf))[i] <= '9') { |
- str[i] = ((char *)(*buf))[i]; |
- i++; |
- } |
- if (((char *)(*buf))[i] != ']') return PAR_ERROR; |
- str[i] = 0; |
- time->tv_nsec = atoi(str) * 1000; |
- i += 2; |
- *buf += i; |
- return PAR_FOUND; |
- break; |
- |
- case PAR_TASK_TYPE: |
- if (!strncmp(*buf, "OS:",3)) { |
- *val = PAR_TASK_OS; |
- *buf += 3; |
- return PAR_FOUND; |
- } |
- if (!strncmp(*buf, "CT:",3)) { |
- *val = PAR_TASK_CT; |
- *buf += 3; |
- return PAR_FOUND; |
- } |
- if (!strncmp(*buf, "BT:",3)) { |
- *val = PAR_TASK_BT; |
- *buf += 3; |
- return PAR_FOUND; |
- } |
- break; |
- |
- case PAR_TASK_NUMBER: |
- if (((char *)(*buf))[0] != '[') return PAR_ERROR; |
- *buf += 1; |
- i = 0; |
- while (((char *)(*buf))[i] >= '0' && ((char *)(*buf))[i] <= '9') { |
- str[i] = ((char *)(*buf))[i]; |
- i++; |
- } |
- if (((char *)(*buf))[i] != ']') return PAR_ERROR; |
- str[i] = 0; |
- *val = atoi(str); |
- i += 2; |
- *buf += i; |
- return PAR_FOUND; |
- break; |
- |
- case PAR_ACT_TYPE: |
- if (!strncmp(*buf,"ACT_SINGLE(",11)) { |
- *buf += 11; |
- *val = PAR_ACT_SINGLE; |
- return PAR_FOUND; |
- } |
- if (!strncmp(*buf,"ACT_PERIODIC(",13)) { |
- *buf += 13; |
- *val = PAR_ACT_PERIODIC; |
- return PAR_FOUND; |
- } |
- if (!strncmp(*buf,"ACT_MEAN(",9)) { |
- *buf += 9; |
- *val = PAR_ACT_MEAN; |
- return PAR_FOUND; |
- } |
- return PAR_ERROR; |
- break; |
- |
- case PAR_LOCAL_SCHEDULER: |
- if (!strncmp(*buf,"POSIX",5)) { |
- *buf += 5; |
- *val = PAR_POSIX; |
- return PAR_FOUND; |
- } |
- if (!strncmp(*buf,"EDF",3)) { |
- *buf += 3; |
- *val = PAR_EDF; |
- return PAR_FOUND; |
- } |
- if (!strncmp(*buf,"RM",2)) { |
- *buf += 2; |
- *val = PAR_RM; |
- return PAR_FOUND; |
- } |
- return PAR_ERROR; |
- break; |
- |
- case PAR_EXEC_TYPE: |
- if (!strncmp(*buf,"EXEC_CONST(",11)) { |
- *buf += 11; |
- *val = PAR_EXEC_CONST; |
- return PAR_FOUND; |
- } |
- if (!strncmp(*buf,"EXEC_MEAN(",10)) { |
- *buf += 10; |
- *val = PAR_EXEC_MEAN; |
- return PAR_FOUND; |
- } |
- return PAR_ERROR; |
- break; |
- |
- case PAR_CRIT_SESSION: |
- if (!strncmp(*buf,"NO_CRIT",7)) { |
- *buf += 7; |
- *val = PAR_NO_CRIT; |
- return PAR_FOUND; |
- } |
- if (!strncmp(*buf,"CRIT(",5)) { |
- *buf += 5; |
- *val = PAR_CRIT; |
- return PAR_FOUND; |
- } |
- return PAR_ERROR; |
- break; |
- |
- } |
- |
- return PAR_ERROR; |
- |
-} |
- |
-void par_error(int line_num) |
-{ |
- |
- printf("\nParser error: line [%d]\n",line_num); |
- exit(1); |
- |
-} |
- |
-/* result: |
- * 0 -> nothing |
- * 1 -> total |
- * 2 -> new task-loader |
- * 3 -> end file |
- */ |
-int line_parser_task(char **pbuf, int line_num, struct loader_task **last) |
-{ |
- struct timespec time; |
- struct loader_task *ld = NULL; |
- int val, res; |
- |
- res = find_break(pbuf, PAR_NOTHING, &time, &val); |
- if (res == PAR_FOUND) return 0; |
- if (res == PAR_END) return 3; |
- |
- res = find_break(pbuf,PAR_TASK_TYPE, &time, &val); |
- if (res == PAR_FOUND) { |
- #ifdef PARSER_DEBUG |
- printf("TASK TYPE = %d\n",val); |
- #endif |
- |
- ld = malloc(sizeof(struct loader_task)); |
- if (ld == NULL) par_error(line_num); |
- |
- ld->next = NULL; |
- *last = ld; |
- |
- ld->task_type = val; |
- |
- } else par_error(line_num); |
- |
- res = find_break(pbuf,PAR_TASK_NUMBER, &time, &val); |
- if (res == PAR_FOUND) { |
- #ifdef PARSER_DEBUG |
- printf("TASK SERVER = %d\n",val); |
- #endif |
- |
- ld->server = val; |
- } else par_error(line_num); |
- |
- res = find_break(pbuf,PAR_LOCAL_SCHEDULER, &time, &val); |
- if (res == PAR_FOUND) { |
- #ifdef PARSER_DEBUG |
- printf("TASK LOCAL SCHEDULER = %d\n",val); |
- #endif |
- |
- ld->local_scheduler = val; |
- } else par_error(line_num); |
- |
- res = find_break(pbuf,PAR_TASK_NUMBER, &time, &val); |
- if (res == PAR_FOUND) { |
- #ifdef PARSER_DEBUG |
- printf("TASK NUMBER = %d\n",val); |
- #endif |
- |
- ld->number = val; |
- |
- } else par_error(line_num); |
- |
- res = find_break(pbuf,PAR_TIME, &time, &val); |
- if (res == PAR_FOUND) { |
- #ifdef PARSER_DEBUG |
- printf("DEADLINE: [%ld][%ld]\n",time.tv_sec,time.tv_nsec/1000); |
- #endif |
- TIMESPEC_ASSIGN(&ld->deadline,&time); |
- } else par_error(line_num); |
- |
- res = find_break(pbuf,PAR_TIME, &time, &val); |
- if (res == PAR_FOUND) { |
- #ifdef PARSER_DEBUG |
- printf("WCET: [%ld][%ld]\n",time.tv_sec,time.tv_nsec/1000); |
- #endif |
- TIMESPEC_ASSIGN(&ld->wcet,&time); |
- } else par_error(line_num); |
- |
- res = find_break(pbuf,PAR_ACT_TYPE, &time, &val); |
- if (res == PAR_FOUND) { |
- #ifdef PARSER_DEBUG |
- printf("ACTIVATION TYPE: %d (",val); |
- #endif |
- |
- ld->act_type = val; |
- |
- res = find_break(pbuf,PAR_TIME, &time, &val); |
- if (res == PAR_FOUND) { |
- #ifdef PARSER_DEBUG |
- printf("[%ld][%ld]",time.tv_sec,time.tv_nsec/1000); |
- #endif |
- TIMESPEC_ASSIGN(&ld->act_par_1,&time); |
- } else par_error(line_num); |
- |
- if (ld->act_type != PAR_ACT_SINGLE) { |
- res = find_break(pbuf,PAR_TIME, &time, &val); |
- if (res == PAR_FOUND) { |
- #ifdef PARSER_DEBUG |
- printf(",[%ld][%ld]",time.tv_sec,time.tv_nsec/1000); |
- #endif |
- TIMESPEC_ASSIGN(&ld->act_par_2,&time); |
- } else par_error(line_num); |
- } |
- |
- if (ld->act_type != PAR_ACT_SINGLE && ld->act_type != PAR_ACT_PERIODIC) { |
- res = find_break(pbuf,PAR_TIME, &time, &val); |
- if (res == PAR_FOUND) { |
- #ifdef PARSER_DEBUG |
- printf(",[%ld][%ld]",time.tv_sec,time.tv_nsec/1000); |
- #endif |
- TIMESPEC_ASSIGN(&ld->act_par_3,&time); |
- } else par_error(line_num); |
- } |
- |
- #ifdef PARSER_DEBUG |
- printf(")\n"); |
- #endif |
- |
- } else par_error(line_num); |
- |
- res = find_break(pbuf,PAR_EXEC_TYPE, &time, &val); |
- if (res == PAR_FOUND) { |
- #ifdef PARSER_DEBUG |
- printf("EXEC TYPE: %d (",val); |
- #endif |
- ld->exec_type = val; |
- res = find_break(pbuf,PAR_TIME, &time, &val); |
- if (res == PAR_FOUND) { |
- #ifdef PARSER_DEBUG |
- printf("[%ld][%ld]",time.tv_sec,time.tv_nsec/1000); |
- #endif |
- TIMESPEC_ASSIGN(&ld->exec_par_1,&time); |
- } else par_error(line_num); |
- |
- if (ld->exec_type != PAR_EXEC_CONST) { |
- res = find_break(pbuf,PAR_TIME, &time, &val); |
- if (res == PAR_FOUND) { |
- #ifdef PARSER_DEBUG |
- printf(",[%ld][%ld]",time.tv_sec,time.tv_nsec/1000); |
- #endif |
- TIMESPEC_ASSIGN(&ld->exec_par_2,&time); |
- } else par_error(line_num); |
- } |
- |
- #ifdef PARSER_DEBUG |
- printf(")\n"); |
- #endif |
- |
- } else par_error(line_num); |
- |
- res = find_break(pbuf,PAR_CRIT_SESSION, &time, &val); |
- if (res == PAR_FOUND) { |
- #ifdef PARSER_DEBUG |
- printf("CRITITCAL SESSION: %d (",val); |
- #endif |
- ld->crit_type = val; |
- if (ld->crit_type == PAR_CRIT) { |
- res = find_break(pbuf,PAR_TASK_NUMBER, &time, &val); |
- if (res == PAR_FOUND) { |
- #ifdef PARSER_DEBUG |
- printf("[%d]",val); |
- #endif |
- ld->resource = val; |
- } else par_error(line_num); |
- res = find_break(pbuf,PAR_TIME, &time, &val); |
- if (res == PAR_FOUND) { |
- #ifdef PARSER_DEBUG |
- printf(",[%ld][%ld]",time.tv_sec,time.tv_nsec/1000); |
- #endif |
- TIMESPEC_ASSIGN(&ld->crit_par,&time); |
- } else par_error(line_num); |
- } |
- |
- #ifdef PARSER_DEBUG |
- printf(")\n"); |
- #endif |
- |
- } else par_error(line_num); |
- |
- return 2; |
- |
-} |
- |
-int line_parser_contract(char **pbuf, int line_num, struct timespec *total, struct loader_contract **last) |
-{ |
- |
- struct timespec time; |
- struct loader_contract *lc = NULL; |
- int val, res; |
- |
- res = find_break(pbuf, PAR_NOTHING, &time, &val); |
- if (res == PAR_FOUND) return 0; |
- if (res == PAR_END) return 3; |
- |
- res = find_break(pbuf,PAR_TOTAL_EXEC_TIME, &time, &val); |
- if (res == PAR_FOUND) { |
- NULL_TIMESPEC(total); |
- res = find_break(pbuf, PAR_TIME, &time, &val); |
- if (res == PAR_FOUND) { |
- TIMESPEC_ASSIGN(total,&time); |
- #ifdef PARSER_DEBUG |
- printf("TOTAL EXEC TIME SEC = %ld NSEC = %ld\n",total->tv_sec,total->tv_nsec); |
- #endif |
- return 1; |
- } else par_error(line_num); |
- } |
- |
- res = find_break(pbuf,PAR_TASK_NUMBER, &time, &val); |
- if (res == PAR_FOUND) { |
- #ifdef PARSER_DEBUG |
- printf("CONTRACT [%d]",val); |
- #endif |
- |
- lc = malloc(sizeof(struct loader_contract)); |
- if (lc == NULL) par_error(line_num); |
- |
- lc->next = NULL; |
- *last = lc; |
- |
- lc->number = val; |
- } else par_error(line_num); |
- |
- res = find_break(pbuf,PAR_TIME, &time, &val); |
- if (res == PAR_FOUND) { |
- #ifdef PARSER_DEBUG |
- printf(",[%ld][%ld]",time.tv_sec,time.tv_nsec/1000); |
- #endif |
- TIMESPEC_ASSIGN(&lc->cmin,&time); |
- } else par_error(line_num); |
- |
- res = find_break(pbuf,PAR_TIME, &time, &val); |
- if (res == PAR_FOUND) { |
- #ifdef PARSER_DEBUG |
- printf(",[%ld][%ld]",time.tv_sec,time.tv_nsec/1000); |
- #endif |
- TIMESPEC_ASSIGN(&lc->tmax,&time); |
- } else par_error(line_num); |
- |
- res = find_break(pbuf,PAR_TIME, &time, &val); |
- if (res == PAR_FOUND) { |
- #ifdef PARSER_DEBUG |
- printf(",[%ld][%ld]",time.tv_sec,time.tv_nsec/1000); |
- #endif |
- TIMESPEC_ASSIGN(&lc->cmax,&time); |
- } else par_error(line_num); |
- |
- res = find_break(pbuf,PAR_TIME, &time, &val); |
- if (res == PAR_FOUND) { |
- #ifdef PARSER_DEBUG |
- printf(",[%ld][%ld],",time.tv_sec,time.tv_nsec/1000); |
- #endif |
- TIMESPEC_ASSIGN(&lc->tmin,&time); |
- } else par_error(line_num); |
- |
- res = find_break(pbuf,PAR_TASK_NUMBER, &time, &val); |
- if (res == PAR_FOUND) { |
- #ifdef PARSER_DEBUG |
- printf(",[%d]\n",val); |
- #endif |
- |
- lc->workload = val; |
- } else par_error(line_num); |
- |
- res = find_break(pbuf,PAR_LOCAL_SCHEDULER, &time, &val); |
- if (res == PAR_FOUND) { |
- #ifdef PARSER_DEBUG |
- printf("LOCAL SCHEDULER = %d\n",val); |
- #endif |
- |
- lc->local_scheduler = val; |
- } else par_error(line_num); |
- |
- return 2; |
- |
-} |
Index: tags/rel_1_22/loader/generators/event_gen.c |
=================================================================== |
--- tags/rel_1_22/loader/generators/event_gen.c (revision 1310) |
+++ tags/rel_1_22/loader/generators/event_gen.c (nonexistent) |
@@ -1,472 +0,0 @@ |
-/* Event Generator |
- * |
- * Giacomo Guidi |
- */ |
- |
-#include <stdio.h> |
-#include <stdlib.h> |
- |
-#include "lparser.h" |
-#include "lread.h" |
-#include "time.h" |
-#include "common/time.h" |
- |
-#define LOADFILE_DIR "../loadfile/" |
- |
-#define EVENT_DEFINE "event.c" |
-#define ACT_LIST "event.c" |
- |
-int write_struct(void) |
-{ |
- |
- FILE *file_event_header; |
- |
- file_event_header = fopen(EVENT_DEFINE,"w"); |
- if (file_event_header == NULL) return 1; |
- |
- fprintf(file_event_header, "\n#include \"func.h\"\n"); |
- |
- fclose(file_event_header); |
- |
- return 0; |
- |
-} |
- |
-int write_basic_par_start(void) |
-{ |
- |
- FILE *file_event_header; |
- |
- file_event_header = fopen(EVENT_DEFINE,"a+"); |
- if (file_event_header == NULL) return 1; |
- |
- fprintf(file_event_header, "struct loader_task loader_task_list[] = {\n"); |
- |
- fclose(file_event_header); |
- |
- return 0; |
- |
-} |
- |
-int write_contract_start(void) |
-{ |
- |
- FILE *file_event_header; |
- |
- file_event_header = fopen(EVENT_DEFINE,"a+"); |
- if (file_event_header == NULL) return 1; |
- |
- fprintf(file_event_header, "struct loader_contract loader_contract_list[] = {\n"); |
- |
- fclose(file_event_header); |
- |
- return 0; |
- |
-} |
- |
-int write_basic_par(struct loader_task *c) |
-{ |
- |
- FILE *file_event_header; |
- int muxpres; |
- char muxtemp[30]; |
- |
- file_event_header = fopen(EVENT_DEFINE,"a+"); |
- if (file_event_header == NULL) return 1; |
- |
- if (c->crit_type == PAR_CRIT) { |
- muxpres = 1; |
- sprintf(muxtemp,"block_%s",c->name); |
- } else { |
- muxpres = 0; |
- sprintf(muxtemp,"NULL"); |
- } |
- |
- fprintf(file_event_header, " {\"%s\",%d,%d,%d,%d,%d,{%d,%d},{%d,%d},%d,0,%d,%d,act_%s,exec_%s,%s},\n", |
- c->name,(int)c->task_type,(int)c->server,(int)c->local_scheduler,(int)c->number,(int)c->group, |
- (int)c->deadline.tv_sec, (int)c->deadline.tv_nsec, |
- (int)c->wcet.tv_sec, (int)c->wcet.tv_nsec, |
- (int)c->act_number, (int)c->resource, muxpres, c->name, c->name, muxtemp); |
- |
- fclose(file_event_header); |
- |
- return 0; |
- |
-} |
- |
-int write_contract(struct loader_contract *c) |
-{ |
- |
- FILE *file_event_header; |
- |
- file_event_header = fopen(EVENT_DEFINE,"a+"); |
- if (file_event_header == NULL) return 1; |
- |
- fprintf(file_event_header, " {%d,{%d,%d},{%d,%d},{%d,%d},{%d,%d},%d,%d,-1},\n", |
- (int)c->number,(int)c->cmin.tv_sec,(int)c->cmin.tv_nsec, |
- (int)c->tmax.tv_sec,(int)c->tmax.tv_nsec, |
- (int)c->cmax.tv_sec,(int)c->cmax.tv_nsec, |
- (int)c->tmin.tv_sec,(int)c->tmin.tv_nsec, |
- (int)c->workload,(int)c->local_scheduler); |
- |
- fclose(file_event_header); |
- |
- return 0; |
- |
-} |
- |
-int close_loader_task(int total_task_number) |
-{ |
- |
- FILE *file_event_header; |
- |
- file_event_header = fopen(EVENT_DEFINE,"a+"); |
- if (file_event_header == NULL) return 1; |
- |
- fprintf(file_event_header,"};\n\n"); |
- |
- fprintf(file_event_header,"int total_loader_task = %d;\n\n",total_task_number); |
- |
- fclose(file_event_header); |
- |
- return 0; |
- |
-} |
- |
-int close_loader_contract(int total_contract_number) |
-{ |
- |
- FILE *file_event_header; |
- |
- file_event_header = fopen(EVENT_DEFINE,"a+"); |
- if (file_event_header == NULL) return 1; |
- |
- fprintf(file_event_header,"};\n\n"); |
- |
- fprintf(file_event_header,"int total_loader_contract = %d;\n\n",total_contract_number); |
- |
- fclose(file_event_header); |
- |
- return 0; |
- |
-} |
- |
-int write_simulation_time(struct timespec *total) |
-{ |
- |
- FILE *file_event_header; |
- |
- file_event_header = fopen(EVENT_DEFINE,"a+"); |
- if (file_event_header == NULL) return 1; |
- |
- fprintf(file_event_header,"struct timespec total_time = {%d,%d};\n\n",(int)total->tv_sec,(int)total->tv_nsec); |
- |
- fclose(file_event_header); |
- |
- return 0; |
- |
- |
-} |
- |
-int write_single_act(struct timespec *t, struct loader_task *c) |
-{ |
- |
- FILE *file_act_header; |
- |
- file_act_header = fopen(ACT_LIST,"a+"); |
- if (file_act_header == NULL) return 1; |
- |
- if (TIMESPEC_A_GT_B(t,&c->act_par_1)) { |
- fprintf(file_act_header,"struct timespec act_%s[] = {{%d,%d}};\n\n",c->name, |
- (int)c->act_par_1.tv_sec,(int)c->act_par_1.tv_nsec); |
- c->act_number = 1; |
- } else { |
- fprintf(file_act_header,"struct timespec act_%s[] = {{0,0}};\n\n",c->name); |
- c->act_number = 0; |
- } |
- |
- fclose(file_act_header); |
- |
- return 0; |
- |
-} |
- |
-int write_periodic_act(struct timespec *t, struct loader_task *c) |
-{ |
- |
- FILE *file_act_header; |
- struct timespec tot_time; |
- int period; |
- |
- file_act_header = fopen(ACT_LIST,"a+"); |
- if (file_act_header == NULL) return 1; |
- |
- fprintf(file_act_header,"struct timespec act_%s[] = {{%d,%d},\n",c->name, |
- (int)c->act_par_1.tv_sec,(int)c->act_par_1.tv_nsec); |
- |
- c->act_number = 1; |
- TIMESPEC_ASSIGN(&tot_time,&c->act_par_1); |
- period = TIMESPEC2USEC(&c->act_par_2); |
- while (TIMESPEC_A_GT_B(t, &tot_time)) { |
- c->act_number++; |
- ADDUSEC2TIMESPEC(period,&tot_time); |
- fprintf(file_act_header," {%d,%d},\n", |
- (int)c->act_par_2.tv_sec,(int)c->act_par_2.tv_nsec); |
- } |
- |
- fprintf(file_act_header," };\n\n"); |
- |
- fclose(file_act_header); |
- |
- return 0; |
- |
-} |
- |
-int write_mean_act(struct timespec *t,struct loader_task *c) |
-{ |
- |
- FILE *file_act_header; |
- struct timespec tot_time; |
- int next_act; |
- |
- file_act_header = fopen(ACT_LIST,"a+"); |
- if (file_act_header == NULL) return 1; |
- |
- fprintf(file_act_header,"struct timespec act_%s[] = {{%d,%d},\n",c->name, |
- (int)c->act_par_1.tv_sec,(int)c->act_par_1.tv_nsec); |
- |
- c->act_number = 1; |
- TIMESPEC_ASSIGN(&tot_time,&c->act_par_1); |
- while (TIMESPEC_A_GT_B(t, &tot_time)) { |
- c->act_number++; |
- next_act = TIMESPEC2USEC(&c->act_par_2) + random() % TIMESPEC2USEC(&c->act_par_3) - TIMESPEC2USEC(&c->act_par_3) / 2; |
- ADDUSEC2TIMESPEC(next_act,&tot_time); |
- fprintf(file_act_header," {%d,%d},\n", |
- next_act / 1000000, next_act % 1000000 * 1000); |
- } |
- |
- fprintf(file_act_header," };\n\n"); |
- |
- fclose(file_act_header); |
- |
- return 0; |
- |
-} |
- |
-int write_block_const(struct loader_task *c) |
-{ |
- |
- FILE *file_block_header; |
- int i; |
- |
- file_block_header = fopen(ACT_LIST,"a+"); |
- if (file_block_header == NULL) return 1; |
- |
- fprintf(file_block_header,"struct timespec block_%s[] = {{%d,%d},\n",c->name, |
- (int)c->crit_par.tv_sec,(int)c->crit_par.tv_nsec); |
- |
- for (i=0; i< c->act_number-1; i++) |
- fprintf(file_block_header," {%d,%d},\n", |
- (int)c->crit_par.tv_sec,(int)c->crit_par.tv_nsec); |
- |
- fprintf(file_block_header," };\n\n"); |
- |
- fclose(file_block_header); |
- |
- return 0; |
- |
-} |
- |
-int write_exec_const(struct loader_task *c) |
-{ |
- |
- FILE *file_exec_header; |
- int i; |
- |
- file_exec_header = fopen(ACT_LIST,"a+"); |
- if (file_exec_header == NULL) return 1; |
- |
- fprintf(file_exec_header,"struct timespec exec_%s[] = {{%d,%d},\n",c->name, |
- (int)c->exec_par_1.tv_sec,(int)c->exec_par_1.tv_nsec); |
- |
- for (i=0; i< c->act_number-1; i++) |
- fprintf(file_exec_header," {%d,%d},\n", |
- (int)c->exec_par_1.tv_sec,(int)c->exec_par_1.tv_nsec); |
- |
- fprintf(file_exec_header," };\n\n"); |
- |
- fclose(file_exec_header); |
- |
- return 0; |
- |
-} |
- |
-int write_exec_mean(struct loader_task *c) |
-{ |
- |
- FILE *file_exec_header; |
- int exec_time_usec; |
- int i; |
- |
- file_exec_header = fopen(ACT_LIST,"a+"); |
- if (file_exec_header == NULL) return 1; |
- |
- exec_time_usec = TIMESPEC2USEC(&c->exec_par_1) |
- + random() % TIMESPEC2USEC(&c->exec_par_2) - TIMESPEC2USEC(&c->exec_par_2) / 2; |
- fprintf(file_exec_header,"struct timespec exec_%s[] = {{%d,%d},\n",c->name, |
- exec_time_usec / 1000000, exec_time_usec % 1000000 * 1000); |
- |
- for (i=0; i< c->act_number-1; i++) { |
- exec_time_usec = TIMESPEC2USEC(&c->exec_par_1) |
- + random() % TIMESPEC2USEC(&c->exec_par_2) - TIMESPEC2USEC(&c->exec_par_2) / 2; |
- fprintf(file_exec_header," {%d,%d},\n", |
- exec_time_usec / 1000000, exec_time_usec % 1000000 * 1000); |
- } |
- |
- fprintf(file_exec_header," };\n\n"); |
- |
- fclose(file_exec_header); |
- |
- return 0; |
- |
-} |
- |
-void *start; |
-void *end; |
- |
-int main(int argc, char **argv) { |
- |
- char loadfile[100]; |
- struct timespec total_time; |
- struct loader_task *start_loader_task = NULL, *current_t; |
- struct loader_contract *start_loader_contract = NULL, *current_c; |
- int err,ldnum; |
- int total_task_number; |
- int total_contract_number; |
- |
- printf("\nEvent Generator\n"); |
- |
- if (argc < 2) { |
- printf("Error: event_gen loadfile.fsf\n"); |
- exit(1); |
- } |
- |
- printf("Read loader file %s\n",argv[1]); |
- |
- sprintf(loadfile,"%s%s",LOADFILE_DIR,argv[1]); |
- err = dos_preload(loadfile,100000,&start,&end); |
- |
- if (err != 0) { |
- printf("Error: File not found\n"); |
- exit(1); |
- } |
- |
- printf("Parsing file\n"); |
- |
- line_reader(start, end, &total_time, &start_loader_task, &start_loader_contract); |
- |
- srandom(time(NULL)); |
- |
- write_struct(); |
- |
- current_t = start_loader_task; |
- ldnum = 1; |
- |
- while(current_t != NULL) { |
- |
- sprintf(current_t->name,"ltask%d",ldnum); |
- current_t->group = ldnum; |
- ldnum++; |
- |
- switch (current_t->act_type) { |
- case PAR_ACT_SINGLE: |
- err = write_single_act(&total_time,current_t); |
- if (err != 0) { |
- printf("Error writing activation header\n"); |
- exit(1); |
- } |
- break; |
- case PAR_ACT_PERIODIC: |
- err = write_periodic_act(&total_time,current_t); |
- if (err != 0) { |
- printf("Error writing activation header\n"); |
- exit(1); |
- } |
- break; |
- case PAR_ACT_MEAN: |
- err = write_mean_act(&total_time,current_t); |
- if (err != 0) { |
- printf("Error writing activation header\n"); |
- exit(1); |
- } |
- break; |
- } |
- |
- switch (current_t->exec_type) { |
- case PAR_EXEC_CONST: |
- err = write_exec_const(current_t); |
- if (err != 0) { |
- printf("Error writing exec header\n"); |
- exit(1); |
- } |
- break; |
- case PAR_EXEC_MEAN: |
- err = write_exec_mean(current_t); |
- if (err != 0) { |
- printf("Error writing exec header\n"); |
- exit(1); |
- } |
- break; |
- } |
- |
- switch (current_t->crit_type) { |
- case PAR_CRIT: |
- err = write_block_const(current_t); |
- if (err != 0) { |
- printf("Error writing block header\n"); |
- exit(1); |
- } |
- break; |
- } |
- |
- current_t = current_t->next; |
- |
- } |
- |
- write_basic_par_start(); |
- |
- total_task_number = 0; |
- current_t = start_loader_task; |
- while(current_t != NULL) { |
- |
- write_basic_par(current_t); |
- |
- current_t = current_t->next; |
- |
- total_task_number++; |
- |
- } |
- |
- close_loader_task(total_task_number); |
- |
- write_contract_start(); |
- |
- total_contract_number = 0; |
- current_c = start_loader_contract; |
- while(current_c != NULL) { |
- |
- write_contract(current_c); |
- |
- current_c = current_c->next; |
- |
- total_contract_number++; |
- |
- } |
- |
- close_loader_contract(total_contract_number); |
- |
- write_simulation_time(&total_time); |
- |
- return 0; |
- |
-} |
Index: tags/rel_1_22/loader/generators/lread.h |
=================================================================== |
--- tags/rel_1_22/loader/generators/lread.h (revision 1310) |
+++ tags/rel_1_22/loader/generators/lread.h (nonexistent) |
@@ -1,11 +0,0 @@ |
-#ifndef __LREAD_H__ |
-#define __LREAD_H__ |
- |
-#include "lparser.h" |
- |
-int dos_preload(char *file_name, long max_size, void **start, void **end); |
- |
-int line_reader(void *start, void *end, struct timespec *total, |
- struct loader_task **start_loader_task, struct loader_contract **start_loader_contract); |
- |
-#endif |
Index: tags/rel_1_22/loader/generators/makefile |
=================================================================== |
--- tags/rel_1_22/loader/generators/makefile (revision 1310) |
+++ tags/rel_1_22/loader/generators/makefile (nonexistent) |
@@ -1,9 +0,0 @@ |
-event_gen: |
- gcc -o lparser.o -c -Wall lparser.c -I. -I.. |
- gcc -o lread.o -c -Wall lread.c -I. -I.. |
- gcc -o event_gen -Wall lparser.o lread.o -I. -I.. -lc event_gen.c |
- |
-clean: |
- rm -f *.o |
- rm -f event_gen |
- |
Index: tags/rel_1_22/loader/generators/lparser.h |
=================================================================== |
--- tags/rel_1_22/loader/generators/lparser.h (revision 1310) |
+++ tags/rel_1_22/loader/generators/lparser.h (nonexistent) |
@@ -1,57 +0,0 @@ |
-#ifndef __LPARSER_H__ |
-#define __LPARSER_H__ |
- |
-#include "common/lconst.h" |
- |
-struct loader_task { |
- |
- char name[20]; |
- int number; |
- int group; |
- int server; |
- int local_scheduler; |
- int task_type; |
- |
- int act_type; |
- struct timespec act_par_1; |
- struct timespec act_par_2; |
- struct timespec act_par_3; |
- int exec_type; |
- struct timespec exec_par_1; |
- struct timespec exec_par_2; |
- |
- struct timespec deadline; |
- struct timespec wcet; |
- |
- int act_number; |
- struct timespec *act; |
- struct timespec *exec; |
- |
- int crit_type; |
- int resource; |
- struct timespec crit_par; |
- |
- struct loader_task *next; |
- |
-}; |
- |
-struct loader_contract { |
- |
- int number; |
- struct timespec cmin; |
- struct timespec tmax; |
- struct timespec cmax; |
- struct timespec tmin; |
- int workload; |
- int local_scheduler; |
- |
- struct loader_contract *next; |
- |
-}; |
- |
-int line_parser_contract(char **buf, int line_num, struct timespec *total_time, struct loader_contract **last); |
- |
-int line_parser_task(char **buf, int line_num, struct loader_task **last); |
- |
-#endif |
- |
Index: tags/rel_1_22/loader/generators/java/task_class.java |
=================================================================== |
--- tags/rel_1_22/loader/generators/java/task_class.java (revision 1310) |
+++ tags/rel_1_22/loader/generators/java/task_class.java (nonexistent) |
@@ -1,26 +0,0 @@ |
-//package first_filter; |
- |
-/** |
- * <p>Title: First XML filter</p> |
- * <p>Description: </p> |
- * <p>Copyright: Copyright (c) 2003</p> |
- * <p>Company: Retis Lab</p> |
- * @author not attributable |
- * @version 1.0 |
- */ |
- |
-public class task_class { |
- String name; |
- int task_type; |
- int contract; |
- int localscheduler; |
- int number; |
- int group; |
- timespec deadline; |
- timespec wcet; |
- int act_number; |
- |
- public task_class() { |
- } |
- |
-} |
Index: tags/rel_1_22/loader/generators/java/fsf-schema.xsd |
=================================================================== |
--- tags/rel_1_22/loader/generators/java/fsf-schema.xsd (revision 1310) |
+++ tags/rel_1_22/loader/generators/java/fsf-schema.xsd (nonexistent) |
@@ -1,75 +0,0 @@ |
-<?xml version="1.0" encoding="UTF-8"?> |
-<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'> |
- |
-<xs:element name="fsf_framework"> |
- <xs:complexType> |
- <xs:sequence> |
- <xs:element ref="simulation"/> |
- <xs:element ref="contract" minOccurs='1' maxOccurs='unbounded'/> |
- </xs:sequence> |
- </xs:complexType> |
-</xs:element> |
- |
-<xs:element name="simulation"> |
- <xs:complexType> |
- <xs:sequence> |
- <xs:element name="time" type="xs:string"/> |
- </xs:sequence> |
- </xs:complexType> |
-</xs:element> |
- |
-<xs:element name="contract"> |
- <xs:complexType> |
- <xs:sequence> |
- <xs:element name="cmin" type="xs:string"/> |
- <xs:element name="tmax" type="xs:string" /> |
- <xs:element name="cmax" type="xs:string" /> |
- <xs:element name="tmin" type="xs:string" /> |
- <xs:element name="workload" type="xs:string" /> |
- <xs:element ref="localscheduler"/> |
- </xs:sequence> |
- </xs:complexType> |
-</xs:element> |
- |
-<xs:element name="localscheduler"> |
- <xs:complexType> |
- <xs:sequence> |
- <xs:element ref="task_section" minOccurs='1' maxOccurs='unbounded'/> |
- </xs:sequence> |
- <xs:attribute name="type" type="xs:string" use='required'/> |
- </xs:complexType> |
-</xs:element> |
- |
-<xs:element name="task_section"> |
- <xs:complexType> |
- <xs:sequence> |
- <xs:element name="number" type="xs:integer"/> |
- <xs:element name="dline" type="xs:string" minOccurs="0" /> |
- <xs:element name="wcet" type="xs:string" minOccurs="0"/> |
- <xs:element ref="act_section"/> |
- <xs:element ref="exec_section"/> |
- </xs:sequence> |
- <xs:attribute name="type" type="xs:string" use='required'/> |
- </xs:complexType> |
-</xs:element> |
- |
-<xs:element name="act_section"> |
- <xs:complexType> |
- <xs:sequence> |
- <xs:element name="start_time" type="xs:string"/> |
- <xs:element name="period_time" type="xs:string" minOccurs="0" /> |
- <xs:element name="delta_time" type="xs:string" minOccurs="0" /> |
- </xs:sequence> |
- </xs:complexType> |
-</xs:element> |
- |
-<xs:element name="exec_section"> |
- <xs:complexType> |
- <xs:sequence> |
- <xs:element name="exec_time" type="xs:string"/> |
- <xs:element name="delta_time" type="xs:string" minOccurs="0" /> |
- </xs:sequence> |
- </xs:complexType> |
-</xs:element> |
- |
-</xs:schema> |
Index: tags/rel_1_22/loader/generators/java/timespec.java |
=================================================================== |
--- tags/rel_1_22/loader/generators/java/timespec.java (revision 1310) |
+++ tags/rel_1_22/loader/generators/java/timespec.java (nonexistent) |
@@ -1,37 +0,0 @@ |
-//package first_filter; |
- |
-/** |
- * <p>Title: First XML filter</p> |
- * <p>Description: </p> |
- * <p>Copyright: Copyright (c) 2003</p> |
- * <p>Company: Retis Lab</p> |
- * @author not attributable |
- * @version 1.0 |
- */ |
- |
-public class timespec { |
- long tv_sec; |
- long tv_nsec; |
- |
- public timespec() { |
- tv_sec=0; |
- tv_nsec=0; |
- } |
- |
- |
- void ADDUSEC2TIMESPEC(long t1) { |
- tv_nsec+=(t1%1000000)*1000; |
- tv_sec+=(tv_nsec / 1000000000)+(t1/1000000); |
- tv_nsec%=1000000000; |
- } |
- long TIMESPEC2USEC() { |
- return (tv_sec*1000000+tv_nsec/1000); |
- } |
- boolean TIMESPEC_A_GT_B(timespec t1) { |
- |
- return (tv_sec>t1.tv_sec || |
- (tv_sec==t1.tv_sec && tv_nsec>t1.tv_nsec)); |
- |
- } |
- |
-} |
Index: tags/rel_1_22/loader/generators/java/java_gen |
=================================================================== |
--- tags/rel_1_22/loader/generators/java/java_gen (revision 1310) |
+++ tags/rel_1_22/loader/generators/java/java_gen (nonexistent) |
@@ -1,10 +0,0 @@ |
-#!/bin/bash |
- |
-#if $CLASSPATH; then |
-#echo Please define the CLASSPATH environment variable!!! |
-#echo ...something like: export CLASSPATH=/usr/java/j2sdk1.4.2/jre/lib |
-#exit 1; |
-#fi |
- |
-java -classpath ".:$CLASSPATH/jdom.jar:$CLASSPATH/xercesImpl.jar:$CLASSPATH/xml-apis.jar" Application $1 |
- |
/tags/rel_1_22/loader/generators/java/java_gen |
Property changes: |
Deleted: svn:executable |
## -1 +0,0 ## |
-* |
\ No newline at end of property |
Index: tags/rel_1_22/loader/generators/java/makefile |
=================================================================== |
--- tags/rel_1_22/loader/generators/java/makefile (revision 1310) |
+++ tags/rel_1_22/loader/generators/java/makefile (nonexistent) |
@@ -1,17 +0,0 @@ |
-ifdef CLASSPATH |
-all: |
- javac Application.java timespec.java task_class.java -classpath "$(CLASSPATH)/jdom.jar" |
-else |
-all: |
- @echo ---------------------------------------------------------------- |
- @echo Please define the CLASSPATH environment variable!!! |
- @echo ...something like: export CLASSPATH=/usr/java/j2sdk1.4.2/jre/lib |
- @echo ---------------------------------------------------------------- |
- @exit 1 |
-endif |
- |
- |
-clean: |
- rm -f *.class |
- rm -f event.c |
- |
Index: tags/rel_1_22/loader/generators/java/Application.java |
=================================================================== |
--- tags/rel_1_22/loader/generators/java/Application.java (revision 1310) |
+++ tags/rel_1_22/loader/generators/java/Application.java (nonexistent) |
@@ -1,856 +0,0 @@ |
-//package first_filter; |
- |
-import java.io.*; |
-import java.net.*; |
-import java.util.List; |
-import java.util.ArrayList; |
-import java.util.Iterator; |
-import org.jdom.*; |
-import org.jdom.input.SAXBuilder; |
-import org.jdom.output.XMLOutputter; |
-import java.util.regex.*; |
-import java.util.Random; |
- |
-/** |
- * <p>Title: First XML filter</p> |
- * <p>Description: </p> |
- * <p>Copyright: Copyright (c) 2003</p> |
- * <p>Company: Retis Lab</p> |
- * @author not attributable |
- * @version 1.0 |
- */ |
- |
-public class Application { |
- private int numElements = 0; |
- final String LOADFILE_DIR="../loadfile/"; |
- final String EVENT_DEFINE="event.c"; |
- final String ACT_LIST="event.c"; |
- private int servernumber=0; |
- private timespec simulation_time=new timespec(); |
- ArrayList local_scheduler=new ArrayList(); |
- ArrayList Task_Section=new ArrayList(); |
- private int task_group=0; |
- private int task_server=0; |
- private int current_scheduler=0; |
- |
- |
- |
- //Construct the frame |
- public Application() { |
- try { |
- jbInit(); |
- } |
- catch(Exception e) { |
- e.printStackTrace(); |
- } |
- } |
- //Component initialization |
- private void jbInit() throws Exception { |
- } |
- |
- public void process (String url) throws MalformedURLException { |
- try { |
- // Use SAXBuilder |
- SAXBuilder builder = new SAXBuilder("org.apache.xerces.parsers.SAXParser", true); |
- builder.setFeature("http://apache.org/xml/features/validation/schema", true); |
- |
- |
- Document doc = builder.build(url); |
- Element root = doc.getRootElement(); |
- |
- try { |
- // Funzione per il salvataggio del file XML |
- OutputStream fout = new FileOutputStream(EVENT_DEFINE); |
- OutputStream bout = new BufferedOutputStream(fout); |
- OutputStreamWriter out = new OutputStreamWriter(bout, "8859_1"); |
- out.write("\n#include \"func.h\"\n"); |
- |
- processElement (root,out); |
- out.flush(); |
- out.close(); |
- } catch (UnsupportedEncodingException e) { |
- System.out.println("Non sono supportati i caratteri latini"); |
- System.exit(1); |
- |
- } catch (IOException e){ |
- System.out.println("Salvatagio fallito"); |
- System.exit(1); |
- } |
- |
- |
- |
- System.out.println ("Total Number of Elements Processed: " |
- +numElements); |
- } catch (JDOMException e) { |
- System.out.println ("JDOM Exception: "+e.getMessage()); |
- } catch (java.io.IOException e) { |
- System.out.println ("File Exception: "+e.getMessage()); |
- |
- } |
-} |
- |
-// Recursive Function to Process Elements |
-// Prints the Element Name and keeps a running count |
-// out total number of elements. |
-private void processElement(Element element, OutputStreamWriter out) { |
- numElements++; |
- String elementName = element.getName(); |
- |
- System.out.println(elementName); |
- List servers = element.getChildren(); |
- Iterator iterator = servers.iterator(); |
- /* get simulation parameter */ |
- Element SimulationInfo = (Element) iterator.next(); |
- |
- Pattern pattern = Pattern.compile("[us\\s]+"); |
- try { |
- /*simulation time */ |
- |
- String[] stime = pattern.split(SimulationInfo.getChild("time").getText()); |
- out.write("struct timespec total_time={" + stime[0] + "," + stime[1] + |
- "};\n\n"); |
- simulation_time.tv_sec = Long.valueOf(stime[0].trim()).longValue(); |
- simulation_time.tv_nsec = Long.valueOf(stime[1].trim()).longValue() / |
- 1000; |
-//float f = Float.valueOf(s.trim()).floatValue(); |
- /* server section start */ |
- out.write("struct loader_contract loader_contract_list[] = {\n"); |
- int total_server=0; |
- while (iterator.hasNext()) { |
- /* get server */ |
- Element server = (Element) iterator.next(); |
- process_server_section(server, out); |
- total_server++; |
- } |
- |
- out.write("};\n\n"); |
- |
- out.write("int total_loader_contract="+total_server+";\n\n"); |
- iterator = local_scheduler.iterator(); |
- while (iterator.hasNext()) { |
- /* get server */ |
- Element loc_sched = (Element) iterator.next(); |
- process_scheduler_section(loc_sched, out); |
- task_server++; |
- } |
- |
- iterator = Task_Section.iterator(); |
- int total_task_section=0; |
- out.write("\nstruct loader_task loader_task_list[] = {\n"); |
- while (iterator.hasNext()) { |
- /* get server */ |
- task_class tsk_sec = (task_class) iterator.next(); |
- out.write(" {\"" + tsk_sec.name + "\"," + tsk_sec.task_type + "," + |
- tsk_sec.contract + |
- "," + tsk_sec.localscheduler + "," + tsk_sec.number + "," |
- + tsk_sec.group + ",{" + tsk_sec.deadline.tv_sec + |
- "," + |
- tsk_sec.deadline.tv_nsec + "}," + "{" + |
- tsk_sec.wcet.tv_sec + "," + |
- tsk_sec.wcet.tv_nsec + "}," + tsk_sec.act_number + |
- ",0,act_" + tsk_sec.name + |
- ",exec_" + tsk_sec.name + "},\n"); |
- total_task_section++; |
- } |
- out.write("};\n\n"); |
- out.write("int total_loader_task="+total_task_section+";\n\n"); |
- |
- |
- } |
- catch (java.io.IOException e) { |
- System.out.println("File Exception: " + e.getMessage()); |
- |
- } |
- |
-} |
- |
-void process_scheduler_section(Element e, OutputStreamWriter out) { |
- Attribute t; |
- t=e.getAttribute("type"); |
- |
- List localpars = e.getChildren(); |
- Iterator iterator = localpars.iterator(); |
- while (iterator.hasNext()) { |
- /* get task section */ |
- Element loc_task = (Element) iterator.next(); |
- process_task_section(loc_task, out, t); |
- |
- } |
- |
-} |
- |
-void process_task_section(Element e, OutputStreamWriter out, Attribute loc) { |
- Attribute t; |
- int act; |
- act=1; |
- int task_type=0; |
- int localscheduler=0; |
- timespec time = new timespec(); |
- Pattern pattern = Pattern.compile("[us\\s]+"); |
- String scheduler=loc.getValue(); |
- if (scheduler.equals("POSIX")) { |
- localscheduler=30; |
- } |
- else if (scheduler.equals("EDF")) { |
- localscheduler=31; |
- } |
- else if (scheduler.equals("RM")) { |
- localscheduler=32; |
- } |
- |
- /* get task section */ |
- t=e.getAttribute("type"); |
- |
- if (t.getValue().equals("BackTask")) { |
- process_back_task(e, out); |
- task_type=23; |
- } else if (t.getValue().equals("OneShot")) { |
- process_oneshot_task(e, out); |
- task_type=21; |
- } else if (t.getValue().equals("CyclicalTask")) { |
- task_type=22; |
- act=process_cyclical_task(e, out); |
- } |
- |
- task_class section=new task_class(); |
- section.deadline=new timespec(); |
- section.wcet=new timespec(); |
- section.name="task"+task_group; |
- section.contract=task_server; |
- section.group=task_group; |
- section.act_number=act; |
- section.task_type=task_type; |
- section.localscheduler=localscheduler; |
- section.number=Integer.valueOf(e.getChild("number").getText()).intValue(); |
- |
- Element dl = e.getChild("dline"); |
- if (dl != null) { |
- |
- String[] dline=pattern.split(dl.getText()); |
- time.tv_sec = Long.valueOf(dline[0]).longValue(); |
- time.tv_nsec = Long.valueOf(dline[1]).longValue() * 1000; |
- |
- section.deadline.tv_sec=time.tv_sec; |
- section.deadline.tv_nsec=time.tv_nsec; |
- |
- } |
- |
- |
- Element wc = e.getChild("wcet"); |
- if (wc != null) { |
- |
- String[] wcet=pattern.split(e.getChild("wcet").getText()); |
- time.tv_sec = Long.valueOf(wcet[0]).longValue(); |
- time.tv_nsec = Long.valueOf(wcet[1]).longValue() * 1000; |
- |
- section.wcet.tv_sec=time.tv_sec; |
- section.wcet.tv_nsec=time.tv_nsec; |
- |
- } |
- |
- Task_Section.add(section); |
- task_group++; |
- |
-} |
- |
-void process_back_task(Element e, OutputStreamWriter out) { |
- |
- Pattern pattern = Pattern.compile("[us\\s]+"); |
- |
- Element act_section=e.getChild("act_section"); |
- String[] start_time=pattern.split(act_section.getChild("start_time").getText()); |
- Element exec_section=e.getChild("exec_section"); |
- |
- String[] exec_const=pattern.split(exec_section.getChild("exec_time").getText()); |
- try { |
- out.write("struct timespec act_task"+task_group+"[]={{"+start_time[0]+","+start_time[1]+"},};\n\n"); |
- out.write("struct timespec exec_task"+task_group+"[]={{"+exec_const[0]+","+exec_const[1]+"},};\n\n"); |
- |
- } |
- catch (java.io.IOException ex) { |
- System.out.println("File Exception: " + ex.getMessage()); |
- |
- } |
-} |
-void process_oneshot_task(Element e, OutputStreamWriter out) { |
- Pattern pattern = Pattern.compile("[us\\s]+"); |
- |
- Element act_section=e.getChild("act_section"); |
- String[] start_time=pattern.split(act_section.getChild("start_time").getText()); |
- |
- Element exec_section=e.getChild("exec_section"); |
- String[] exec_const=pattern.split(exec_section.getChild("exec_time").getText()); |
- |
- try { |
- out.write("struct timespec act_task"+task_group+"[]={{"+start_time[0]+","+start_time[1]+"},};\n\n"); |
- out.write("struct timespec exec_task"+task_group+"[]={{"+exec_const[0]+","+exec_const[1]+"},};\n\n"); |
- } |
- catch (java.io.IOException ex) { |
- System.out.println("File Exception: " + ex.getMessage()); |
- } |
-} |
- |
-int process_cyclical_task(Element e, OutputStreamWriter out) { |
- |
- int activated=1; |
- Pattern pattern = Pattern.compile("[us\\s]+"); |
- Element act_section=e.getChild("act_section"); |
- String[] start_time=pattern.split(act_section.getChild("start_time").getText()); |
- String[] period=pattern.split(act_section.getChild("period_time").getText()); |
- Element deltatime=act_section.getChild("delta_time"); |
- String[] delta_time; |
- |
- long act_delta=0; |
- timespec delta_act_ts = new timespec(); |
- |
- if (deltatime != null) { |
- delta_time = pattern.split(deltatime.getText()); |
- delta_act_ts.tv_sec = Long.valueOf(delta_time[0]).longValue(); |
- delta_act_ts.tv_nsec = Long.valueOf(delta_time[1]).longValue() * 1000; |
- act_delta = delta_act_ts.TIMESPEC2USEC(); |
- } |
- |
- Element exec_section=e.getChild("exec_section"); |
- String[] exec_const=pattern.split(exec_section.getChild("exec_time").getText()); |
- Element execdelta=exec_section.getChild("delta_time"); |
- String[] exec_delta; |
- |
- long exec_delta_long = 0; |
- timespec exec_delta_ts = new timespec(); |
- |
- if (execdelta != null) { |
- exec_delta=pattern.split(execdelta.getText()); |
- exec_delta_ts.tv_sec = Long.valueOf(exec_delta[0]).longValue(); |
- exec_delta_ts.tv_nsec = Long.valueOf(exec_delta[1]).longValue() * 1000; |
- exec_delta_long = exec_delta_ts.TIMESPEC2USEC(); |
- } |
- |
- try { |
- out.write("struct timespec act_task"+task_group+"[]={{"+ |
- start_time[0]+","+start_time[1]+"},\n"); |
- |
- timespec time = new timespec(); |
- time.tv_sec = Long.valueOf(period[0]).longValue(); |
- time.tv_nsec = Long.valueOf(period[1]).longValue() * 1000; |
- |
- long usecperiod = time.TIMESPEC2USEC(); |
- timespec nextact = new timespec(); |
- |
- time.tv_sec = Long.valueOf(start_time[0]).longValue(); |
- time.tv_nsec = Long.valueOf(start_time[1]).longValue() * 1000; |
- |
- Random rd = new Random(); |
- |
- while (simulation_time.TIMESPEC_A_GT_B(time)) { |
- |
- nextact.tv_sec = Long.valueOf(period[0]).longValue(); |
- nextact.tv_nsec = Long.valueOf(period[1]).longValue() * 1000; |
- |
- if (act_delta != 0) { |
- nextact.ADDUSEC2TIMESPEC((rd.nextInt() & Integer.MAX_VALUE) % act_delta - act_delta/2); |
- } |
- |
- time.ADDUSEC2TIMESPEC(usecperiod); |
- out.write(" {"+nextact.tv_sec+","+nextact.tv_nsec/1000+"},\n"); |
- activated++; |
- } |
- out.write("};\n"); |
- |
- out.write("struct timespec exec_task"+task_group+"[]={\n"); |
- |
- timespec nextexec = new timespec(); |
- |
- for (int i=0; i<activated; i++) { |
- |
- nextexec.tv_sec = Long.valueOf(exec_const[0]).longValue(); |
- nextexec.tv_nsec = Long.valueOf(exec_const[1]).longValue() * 1000; |
- |
- if (exec_delta_long != 0) { |
- nextexec.ADDUSEC2TIMESPEC((rd.nextInt() & Integer.MAX_VALUE) % exec_delta_long - exec_delta_long/2); |
- } |
- |
- out.write(" {"+nextexec.tv_sec+","+nextexec.tv_nsec/1000+"},\n"); |
- |
- } |
- out.write("};\n"); |
- } |
- catch (java.io.IOException ex) { |
- System.out.println("File Exception: " + ex.getMessage()); |
- } |
- |
- return activated; |
-} |
- |
-void process_server_section(Element e, OutputStreamWriter out) { |
- |
- |
- List serverpars = e.getChildren(); |
- Iterator iterator = serverpars.iterator(); |
- Element serverpar = (Element) iterator.next(); |
- String current_value; |
- current_value=serverpar.getText(); |
- try { |
- out.write("{" + servernumber + ",{"); |
- servernumber++; |
- |
- Pattern pattern = Pattern.compile("[us\\s]+"); |
- /* cmin */ |
- String[] cmin = pattern.split(current_value); |
- out.write(cmin[0] + "," + Long.valueOf(cmin[1]).longValue()*1000+"},{"); |
- |
- /* tmax */ |
- serverpar = (Element) iterator.next(); |
- current_value=serverpar.getText(); |
- String[] tmax = pattern.split(current_value); |
- out.write(tmax[0] + "," + Long.valueOf(tmax[1]).longValue()*1000+"},{"); |
- |
- /* cmax */ |
- serverpar = (Element) iterator.next(); |
- current_value=serverpar.getText(); |
- String[] cmax = pattern.split(current_value); |
- out.write(cmax[0] + "," + Long.valueOf(cmax[1]).longValue()*1000+"},{"); |
- |
- /* tmin */ |
- serverpar = (Element) iterator.next(); |
- current_value=serverpar.getText(); |
- String[] tmin = pattern.split(current_value); |
- out.write(tmin[0] + "," + Long.valueOf(tmin[1]).longValue()*1000+"},"); |
- |
- /*work load */ |
- serverpar = (Element) iterator.next(); |
- current_value=serverpar.getText(); |
- out.write(current_value+","); |
- |
- serverpar = (Element) iterator.next(); |
- current_value=serverpar.getName(); |
- Attribute loc_type=serverpar.getAttribute("type"); |
- String scheduler=loc_type.getValue(); |
- if (scheduler.equals("POSIX")) { |
- out.write("30"); |
- } |
- else if (scheduler.equals("EDF")) { |
- out.write("31"); |
- } |
- else if (scheduler.equals("RM")) { |
- out.write("32"); |
- } |
- out.write(",-1},\n"); |
- local_scheduler.add(servernumber-1,serverpar); |
- |
- } catch (java.io.IOException ex) { |
- System.out.println ("File Exception: "+ex.getMessage()); |
- } |
- |
- /* |
- fprintf(file_event_header, " {%d,{%d,%d},{%d,%d},{%d,%d},{%d,%d},%d,%d,-1},\n", |
- (int)c->number,(int)c->cmin.tv_sec,(int)c->cmin.tv_nsec, |
- (int)c->tmax.tv_sec,(int)c->tmax.tv_nsec, |
- (int)c->cmax.tv_sec,(int)c->cmax.tv_nsec, |
- (int)c->tmin.tv_sec,(int)c->tmin.tv_nsec, |
- (int)c->workload,(int)c->local_scheduler); |
- |
-*/ |
- //processElement (kid); |
- } |
- |
- |
- |
-public static void main(String[] args) throws Exception { |
- System.out.println("Parser Versione 1.0"); |
- Application app = new Application(); |
- if (args.length > 0) |
- app.process(args[0]); |
-} |
- |
-/* Event Generator |
- * |
- * Giacomo Guidi |
- */ |
- |
- |
- |
- |
- |
-/* |
-int write_basic_par_start(void) |
-{ |
- |
- FILE *file_event_header; |
- |
- file_event_header = fopen(EVENT_DEFINE,"a+"); |
- if (file_event_header == NULL) return 1; |
- |
- fprintf(file_event_header, "struct loader_task loader_task_list[] = {\n"); |
- |
- fclose(file_event_header); |
- |
- return 0; |
- |
-} |
- |
- |
-int write_basic_par(struct loader_task *c) |
-{ |
- |
- FILE *file_event_header; |
- |
- file_event_header = fopen(EVENT_DEFINE,"a+"); |
- if (file_event_header == NULL) return 1; |
- |
- fprintf(file_event_header, " {\"%s\",%d,%d,%d,%d,%d,{%d,%d},{%d,%d},%d,0,act_%s,exec_%s},\n", |
- c->name,(int)c->task_type,(int)c->server,(int)c->local_scheduler,(int)c->number,(int)c->group, |
- (int)c->deadline.tv_sec, (int)c->deadline.tv_nsec, |
- (int)c->wcet.tv_sec, (int)c->wcet.tv_nsec, |
- (int)c->act_number, c->name, c->name); |
- |
- fclose(file_event_header); |
- |
- return 0; |
- |
-} |
- |
-int write_contract(struct loader_contract *c) |
-{ |
- |
- FILE *file_event_header; |
- |
- file_event_header = fopen(EVENT_DEFINE,"a+"); |
- if (file_event_header == NULL) return 1; |
- |
- fprintf(file_event_header, " {%d,{%d,%d},{%d,%d},{%d,%d},{%d,%d},%d,%d,-1},\n", |
- (int)c->number,(int)c->cmin.tv_sec,(int)c->cmin.tv_nsec, |
- (int)c->tmax.tv_sec,(int)c->tmax.tv_nsec, |
- (int)c->cmax.tv_sec,(int)c->cmax.tv_nsec, |
- (int)c->tmin.tv_sec,(int)c->tmin.tv_nsec, |
- (int)c->workload,(int)c->local_scheduler); |
- |
- fclose(file_event_header); |
- |
- return 0; |
- |
-} |
- |
-int close_loader_task(int total_task_number) |
-{ |
- |
- FILE *file_event_header; |
- |
- file_event_header = fopen(EVENT_DEFINE,"a+"); |
- if (file_event_header == NULL) return 1; |
- |
- fprintf(file_event_header,"};\n\n"); |
- |
- fprintf(file_event_header,"int total_loader_task = %d;\n\n",total_task_number); |
- |
- fclose(file_event_header); |
- |
- return 0; |
- |
-} |
- |
-int close_loader_contract(int total_contract_number) |
-{ |
- |
- FILE *file_event_header; |
- |
- file_event_header = fopen(EVENT_DEFINE,"a+"); |
- if (file_event_header == NULL) return 1; |
- |
- fprintf(file_event_header,"};\n\n"); |
- |
- fprintf(file_event_header,"int total_loader_contract = %d;\n\n",total_contract_number); |
- |
- fclose(file_event_header); |
- |
- return 0; |
- |
-} |
- |
-int write_simulation_time(struct timespec *total) |
-{ |
- |
- FILE *file_event_header; |
- |
- file_event_header = fopen(EVENT_DEFINE,"a+"); |
- if (file_event_header == NULL) return 1; |
- |
- fprintf(file_event_header,"struct timespec total_time = {%d,%d};\n\n",(int)total->tv_sec,(int)total->tv_nsec); |
- |
- fclose(file_event_header); |
- |
- return 0; |
- |
- |
-} |
- |
-int write_single_act(struct timespec *t, struct loader_task *c) |
-{ |
- |
- FILE *file_act_header; |
- |
- file_act_header = fopen(ACT_LIST,"a+"); |
- if (file_act_header == NULL) return 1; |
- |
- if (TIMESPEC_A_GT_B(t,&c->act_par_1)) { |
- fprintf(file_act_header,"struct timespec act_%s[] = {{%d,%d}};\n\n",c->name, |
- (int)c->act_par_1.tv_sec,(int)c->act_par_1.tv_nsec); |
- c->act_number = 1; |
- } else { |
- fprintf(file_act_header,"struct timespec act_%s[] = {{0,0}};\n\n",c->name); |
- c->act_number = 0; |
- } |
- |
- fclose(file_act_header); |
- |
- return 0; |
- |
-} |
- |
-int write_periodic_act(struct timespec *t, struct loader_task *c) |
-{ |
- |
- FILE *file_act_header; |
- struct timespec tot_time; |
- int period; |
- |
- file_act_header = fopen(ACT_LIST,"a+"); |
- if (file_act_header == NULL) return 1; |
- |
- fprintf(file_act_header,"struct timespec act_%s[] = {{%d,%d},\n",c->name, |
- (int)c->act_par_1.tv_sec,(int)c->act_par_1.tv_nsec); |
- |
- c->act_number = 1; |
- TIMESPEC_ASSIGN(&tot_time,&c->act_par_1); |
- period = TIMESPEC2USEC(&c->act_par_2); |
- while (TIMESPEC_A_GT_B(t, &tot_time)) { |
- c->act_number++; |
- ADDUSEC2TIMESPEC(period,&tot_time); |
- fprintf(file_act_header," {%d,%d},\n", |
- (int)c->act_par_2.tv_sec,(int)c->act_par_2.tv_nsec); |
- } |
- |
- fprintf(file_act_header," };\n\n"); |
- |
- fclose(file_act_header); |
- |
- return 0; |
- |
-} |
- |
-int write_mean_act(struct timespec *t,struct loader_task *c) |
-{ |
- |
- FILE *file_act_header; |
- struct timespec tot_time; |
- int next_act; |
- |
- file_act_header = fopen(ACT_LIST,"a+"); |
- if (file_act_header == NULL) return 1; |
- |
- fprintf(file_act_header,"struct timespec act_%s[] = {{%d,%d},\n",c->name, |
- (int)c->act_par_1.tv_sec,(int)c->act_par_1.tv_nsec); |
- |
- c->act_number = 1; |
- TIMESPEC_ASSIGN(&tot_time,&c->act_par_1); |
- while (TIMESPEC_A_GT_B(t, &tot_time)) { |
- c->act_number++; |
- next_act = TIMESPEC2USEC(&c->act_par_2) + random() % TIMESPEC2USEC(&c->act_par_3) - TIMESPEC2USEC(&c->act_par_3) / 2; |
- ADDUSEC2TIMESPEC(next_act,&tot_time); |
- fprintf(file_act_header," {%d,%d},\n", |
- next_act / 1000000, next_act % 1000000 * 1000); |
- } |
- |
- fprintf(file_act_header," };\n\n"); |
- |
- fclose(file_act_header); |
- |
- return 0; |
- |
-} |
- |
-int write_exec_const(struct loader_task *c) |
-{ |
- |
- FILE *file_exec_header; |
- int i; |
- |
- file_exec_header = fopen(ACT_LIST,"a+"); |
- if (file_exec_header == NULL) return 1; |
- |
- fprintf(file_exec_header,"struct timespec exec_%s[] = {{%d,%d},\n",c->name, |
- (int)c->exec_par_1.tv_sec,(int)c->exec_par_1.tv_nsec); |
- |
- for (i=0; i< c->act_number-1; i++) |
- fprintf(file_exec_header," {%d,%d},\n", |
- (int)c->exec_par_1.tv_sec,(int)c->exec_par_1.tv_nsec); |
- |
- fprintf(file_exec_header," };\n\n"); |
- |
- fclose(file_exec_header); |
- |
- return 0; |
- |
-} |
- |
-int write_exec_mean(struct loader_task *c) |
-{ |
- |
- FILE *file_exec_header; |
- int exec_time_usec; |
- int i; |
- |
- file_exec_header = fopen(ACT_LIST,"a+"); |
- if (file_exec_header == NULL) return 1; |
- |
- exec_time_usec = TIMESPEC2USEC(&c->exec_par_1) |
- + random() % TIMESPEC2USEC(&c->exec_par_2) - TIMESPEC2USEC(&c->exec_par_2) / 2; |
- fprintf(file_exec_header,"struct timespec exec_%s[] = {{%d,%d},\n",c->name, |
- exec_time_usec / 1000000, exec_time_usec % 1000000 * 1000); |
- |
- for (i=0; i< c->act_number-1; i++) { |
- exec_time_usec = TIMESPEC2USEC(&c->exec_par_1) |
- + random() % TIMESPEC2USEC(&c->exec_par_2) - TIMESPEC2USEC(&c->exec_par_2) / 2; |
- fprintf(file_exec_header," {%d,%d},\n", |
- exec_time_usec / 1000000, exec_time_usec % 1000000 * 1000); |
- } |
- |
- fprintf(file_exec_header," };\n\n"); |
- |
- fclose(file_exec_header); |
- |
- return 0; |
- |
-} |
- |
-void *start; |
-void *end; |
- |
-int main(int argc, char **argv) { |
- |
- char loadfile[100]; |
- struct timespec total_time; |
- struct loader_task *start_loader_task = NULL, *current_t; |
- struct loader_contract *start_loader_contract = NULL, *current_c; |
- int err,ldnum; |
- int total_task_number; |
- int total_contract_number; |
- |
- printf("\nEvent Generator\n"); |
- |
- if (argc < 2) { |
- printf("Error: event_gen loadfile.fsf\n"); |
- exit(1); |
- } |
- |
- printf("Read loader file %s\n",argv[1]); |
- |
- sprintf(loadfile,"%s%s",LOADFILE_DIR,argv[1]); |
- err = dos_preload(loadfile,100000,&start,&end); |
- |
- if (err != 0) { |
- printf("Error: File not found\n"); |
- exit(1); |
- } |
- |
- printf("Parsing file\n"); |
- |
- line_reader(start, end, &total_time, &start_loader_task, &start_loader_contract); |
- |
- srandom(time(NULL)); |
- |
- write_struct(); |
- |
- current_t = start_loader_task; |
- ldnum = 1; |
- |
- while(current_t != NULL) { |
- |
- sprintf(current_t->name,"ltask%d",ldnum); |
- current_t->group = ldnum; |
- ldnum++; |
- |
- switch (current_t->act_type) { |
- case PAR_ACT_SINGLE: |
- err = write_single_act(&total_time,current_t); |
- if (err != 0) { |
- printf("Error writing activation header\n"); |
- exit(1); |
- } |
- break; |
- case PAR_ACT_PERIODIC: |
- err = write_periodic_act(&total_time,current_t); |
- if (err != 0) { |
- printf("Error writing activation header\n"); |
- exit(1); |
- } |
- break; |
- case PAR_ACT_MEAN: |
- err = write_mean_act(&total_time,current_t); |
- if (err != 0) { |
- printf("Error writing activation header\n"); |
- exit(1); |
- } |
- break; |
- } |
- |
- switch (current_t->exec_type) { |
- case PAR_EXEC_CONST: |
- err = write_exec_const(current_t); |
- if (err != 0) { |
- printf("Error writing exec header\n"); |
- exit(1); |
- } |
- break; |
- case PAR_EXEC_MEAN: |
- err = write_exec_mean(current_t); |
- if (err != 0) { |
- printf("Error writing exec header\n"); |
- exit(1); |
- } |
- break; |
- } |
- |
- current_t = current_t->next; |
- |
- } |
- |
- write_basic_par_start(); |
- |
- total_task_number = 0; |
- current_t = start_loader_task; |
- while(current_t != NULL) { |
- |
- write_basic_par(current_t); |
- |
- current_t = current_t->next; |
- |
- total_task_number++; |
- |
- } |
- |
- close_loader_task(total_task_number); |
- |
- write_contract_start(); |
- |
- total_contract_number = 0; |
- current_c = start_loader_contract; |
- while(current_c != NULL) { |
- |
- write_contract(current_c); |
- |
- current_c = current_c->next; |
- |
- total_contract_number++; |
- |
- } |
- |
- close_loader_contract(total_contract_number); |
- |
- write_simulation_time(&total_time); |
- |
- return 0; |
- |
-} |
- |
-*/ |
-} |
Index: tags/rel_1_22/loader/readme.txt |
=================================================================== |
--- tags/rel_1_22/loader/readme.txt (revision 1310) |
+++ tags/rel_1_22/loader/readme.txt (nonexistent) |
@@ -1,64 +0,0 @@ |
-FIRST Framework Evaluation architecture |
---------------------------------------- |
- |
-makefile usage: |
- |
-$ make OS=<osname> TEST=<demo> all |
- |
-where: |
- |
-<osname> is the name of the target operating system and it can be: |
- |
-- MARTE for MaRTE OS |
-- SHARK for Shark |
- |
-<demo> is the name of the test case that have to be compiled. The |
-specification of the test case is contained inside the loadfile |
-directory. |
- |
-Valid extensions for the test case specification files are: |
-.fsf - old script file |
-.fsf2 - XML version |
-(other extensions can be added easily) |
- |
-For example: |
- |
-make OS=SHARK TEST=load all |
- |
-these makefile will: |
-- prepare the out directory with the common files |
-- add the shark initialization files |
-- parse a file loadfile/load.fsf (the file extension is guessed automatically |
- by the makefile) to produce source code inside out |
-- compile the resulting shark application |
- |
-------------------------------------------------------------------------- |
- |
-XML Parser & Java setup |
- |
-To use the XML parser (file extension .fsf2) you need to properly setup |
-your system, and you need toinstall the following libraries: |
- |
-- JDOM BETA 9 - http://www.jdom.org |
-- XERCES (Parser SAX with XSD support) - http://xml.apache.org |
- |
-On my Linux system, after installing the Sun's j2re, |
-I did the following commands (as root): |
- |
-# mkdir j |
-# cd j |
-# wget http://www.jdom.org/dist/binary/jdom-b9.tar.gz |
-# tar xvzf jdom-b9.tar.gz |
-# cp jdom-b9/build/jdom.jar /usr/java/j2re1.4.1_02/lib/ |
-# wget http://www.apache.org/dist/xml/xerces-j/Xerces-J-bin.2.6.0.tar.gz |
-# tar xvzf Xerces-J-bin.2.6.0.tar.gz |
-# cp ./xerces-2_6_0/xercesImpl.jar /usr/java/j2re1.4.1_02/lib/ |
-# cp ./xerces-2_6_0/xml-apis.jar /usr/java/j2re1.4.1_02/lib/ |
- |
-then, as user, I did |
- |
-$ export CLASSPATH=/usr/java/j2re1.4.1_02/lib |
- |
-Enjoy, |
- |
-Michael, Giacomo, PJ |
Index: tags/rel_1_22/loader/makefile |
=================================================================== |
--- tags/rel_1_22/loader/makefile (revision 1310) |
+++ tags/rel_1_22/loader/makefile (nonexistent) |
@@ -1,88 +0,0 @@ |
-# |
-# help can be found in readme.txt |
-# |
- |
-# ----------------------------------------------------- |
-# |
-# OS dependent variables: |
- |
-# all the OS dependent variables and dependencies are under $(OS)/makefile.in |
- |
-# This makefile will execute the dependency os_specific_dep to "fill" |
-# the out directory with OS-specific stuffs; Then, the makefile |
-# generated in the out directory will be executed with $(TEST) as |
-# parameter. |
- |
-ifndef $(BASE) |
-BASE=../.. |
-endif |
- |
-include $(BASE)/config/config.mk |
- |
-ifeq ($(OS),MARTE) |
-OSINCLUDE=marte/makefile.in |
-endif |
- |
-ifeq ($(OS),SHARK) |
-OSINCLUDE=shark/makefile.in |
-endif |
- |
-# ----------------------------------------------------- |
- |
-.PHONY: all clean help |
- |
-help: |
-ifeq ($(CAT),cat) |
- cat readme.txt |
-endif |
- |
-all: out out/common.done out/$(TEST).done os_specific_dep |
- make -C out $(TEST) |
- |
-clean: |
- make -C generators clean |
- make -C generators/java clean |
- rm -rf out |
- |
-out/common.done: |
- cd out; cp -sf ../common/*.c . |
- cd out; cp -sf ../common/*.h . |
- touch out/common.done |
- |
-# note: the out dependency is present only in the "all" dependency |
-# (there is some strange case with the updating of the out date that I |
-# do not know how to resolve... |
-out: |
- mkdir out |
- |
-# ----------------------------------------------------- |
-# |
-# Testcase generation |
- |
-# .FSF Format |
-# ----------------------- |
- |
-generators/event_gen: |
- make -C generators event_gen |
- |
-out/%.done: loadfile/%.fsf generators/event_gen |
- cd out; ../generators/event_gen ../loadfile/$(TEST).fsf |
- touch out/$*.done |
- |
-# .FSF2 Format |
-# ----------------------- |
- |
-generators/java/Applicazione.class: |
- make -C generators/java all |
- |
-out/%.done: loadfile/%.fsf2 generators/java/Applicazione.class |
- cd generators/java; ./java_gen ../../loadfile/$(TEST).fsf2; mv event.c ../../out/ |
- touch out/$*.done |
- |
-# other file formats |
-# ----------------------- |
-out/%.done: loadfile/%.otherformat |
- echo Other file formats that are not specified yet... |
- touch out/$*.done |
- |
-include $(OSINCLUDE) |
Index: tags/rel_1_22/loader/loadfile/load.fsf |
=================================================================== |
--- tags/rel_1_22/loader/loadfile/load.fsf (revision 1310) |
+++ tags/rel_1_22/loader/loadfile/load.fsf (nonexistent) |
@@ -1,75 +0,0 @@ |
-# CONTRACT SECTION |
-# |
-# CONTRACT NUMBER:CMIN:TMAX:CMAX:TMIN:WORKLOAD:LOCAL SCHEDULER |
-# |
-# YOU WILL HAVE A SERVER FOR EACH SPECIFIED CONTRACT, |
-# SO IN THE TASK SECTION YOU CAN SPECIFY THE "CONTRACT NUMBER" |
-# INSTEAD OF THE SERVER NUMBER, WHICH IS CALCULATED INSIDE THE |
-# LOADER |
-# |
-# ALL THE TIME PARAMETERS INSIDE THIS FILE ARE ALWAYS EXPRESSED AS |
-# "[SECONDS][MICROSECONDS]" TO AVOID FLOATING POINT CALCULATIONS |
-# |
-# WORKLOAD |
-# 0 BOUNDED |
-# 1 INDETERMINATED |
-# |
-# LOCAL SCHEDULER |
-# POSIX - DEFAULT FOR THE FRAMEWORK |
-# EDF |
-# RM |
-# |
-# TASK SECTION |
-# |
-# TASK TYPE:CONTRACT NUMBER:LOCAL SCHEDULER:NUMBER OF TASK:DEADLINE:WCET:TASK ACT TYPE (PAR1,PAR2,...): |
-# :TASK EXEC TYPE (PAR1,PAR2,...):CRITICAL SESSION (PAR1,PAR2,PAR3,PAR4); |
-# |
-# TASK TYPE |
-# OS - ONE_SHOT |
-# CT - CYCLICAL_TASK |
-# BT - BACKGROUND_TASK |
-# |
-# TASK EXEC TYPE |
-# EXEC_CONST(TIME) |
-# - CONSTANT EXEC TIME |
-# EXEC_MEAN(MEAN, DELTA) |
-# - VARIABLE EXEC TIME WITH CONSTANT DISTRIBUTION |
-# |
-# TASK ACTIVATION TIME |
-# ACT_SINGLE(START_TIME) |
-# ACT_PERIODIC(START_TIME, PERIOD) |
-# ACT_MEAN(START_TIME, MEAN, DELTA) |
-# |
-# CRITICAL SESSION |
-# CRIT(RES NUMBER, BLOCKING_TIME) |
-# NO_CRIT |
-# |
- |
-TOTAL_EXEC_TIME:[20][0]; |
-# SIMULATION TOTAL TIME |
- |
-CONTRACT SECTION |
- |
-[0]:[0][3000]:[0][10000]:[0][3000]:[0][10000]:[0]:POSIX; |
-[1]:[0][6000]:[0][30000]:[0][6000]:[0][30000]:[0]:POSIX; |
-[2]:[0][3000]:[0][30000]:[0][3000]:[0][30000]:[0]:POSIX; |
-[3]:[0][3000]:[0][20000]:[0][3000]:[0][20000]:[0]:POSIX; |
- |
-END |
- |
-TASK SECTION |
- |
-BT:[0]:POSIX:[1]:[0][0]:[0][0]:ACT_SINGLE([1][0]): |
-:EXEC_CONST([0][25000]):NO_CRIT; |
- |
-BT:[1]:POSIX:[1]:[0][0]:[0][0]:ACT_SINGLE([2][0]): |
-:EXEC_CONST([0][16000]):NO_CRIT; |
- |
-OS:[2]:POSIX:[1]:[0][0]:[0][0]:ACT_SINGLE([3][0]): |
-:EXEC_CONST([1][0]):NO_CRIT; |
- |
-BT:[3]:POSIX:[5]:[0][0]:[0][0]:ACT_SINGLE([4][0]): |
-:EXEC_CONST([0][10000]):NO_CRIT; |
- |
-END |
- |
Index: tags/rel_1_22/loader/loadfile/loadxml.fsf2 |
=================================================================== |
--- tags/rel_1_22/loader/loadfile/loadxml.fsf2 (revision 1310) |
+++ tags/rel_1_22/loader/loadfile/loadxml.fsf2 (nonexistent) |
@@ -1,59 +0,0 @@ |
-<?xml version="1.0" encoding="UTF-8"?> |
-<fsf_framework xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../generators/java/fsf-schema.xsd"> |
- |
-<simulation> |
-<time>20s 0u</time> |
-</simulation> |
-<contract> |
- <cmin>0s 3000u</cmin> |
- <tmax>0s 10000u</tmax> |
- <cmax>0s 3000u</cmax> |
- <tmin>0s 10000u</tmin> |
- <workload>0</workload> |
- <localscheduler type="POSIX"> |
- <task_section type="BackTask"> |
- <number>1</number> |
- <act_section> |
- <start_time>3s 0u</start_time> |
- </act_section> |
- <exec_section> |
- <exec_time>3s 0u</exec_time> |
- </exec_section> |
- </task_section> |
- <task_section type="OneShot"> |
- <number>2</number> |
- <dline>0s 0u</dline> |
- <wcet>0s 0u</wcet> |
- <act_section> |
- <start_time>3s 0u</start_time> |
- </act_section> |
- <exec_section> |
- <exec_time>3s 0u</exec_time> |
- </exec_section> |
- </task_section> |
- </localscheduler> |
-</contract> |
-<contract> |
- <cmin>0s 3000u</cmin> |
- <tmax>0s 10000u</tmax> |
- <cmax>0s 3000u</cmax> |
- <tmin>0s 10000u</tmin> |
- <workload>0</workload> |
- <localscheduler type="EDF"> |
- <task_section type="CyclicalTask"> |
- <number>1</number> |
- <dline>1s 0u</dline> |
- <wcet>0s 100000u</wcet> |
- <act_section> |
- <start_time>3s 0u</start_time> |
- <period_time>1s 0u</period_time> |
- </act_section> |
- <exec_section> |
- <exec_time>0s 10000u</exec_time> |
- <delta_time>0s 10000u</delta_time> |
- </exec_section> |
- </task_section> |
- </localscheduler> |
-</contract> |
- |
-</fsf_framework> |
Index: tags/rel_1_22/jumpball/rrp.c |
=================================================================== |
--- tags/rel_1_22/jumpball/rrp.c (revision 1310) |
+++ tags/rel_1_22/jumpball/rrp.c (nonexistent) |
@@ -1,107 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: rrp.c,v 1.1 2003-05-01 19:43:17 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1 $ |
- Last update: $Date: 2003-05-01 19:43:17 $ |
- ------------ |
-**/ |
- |
-/* |
- * Copyright (C) 2003 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/rr.h" |
-#include "modules/rrsoft.h" |
-#include "modules/dummy.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
-#include "modules/pi.h" |
- |
-#include "drivers/keyb.h" |
- |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 0 |
- |
-/*+ RR tick in us +*/ |
-//#define RRTICK 10000 |
-#define RRTICK 2000 |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- RRSOFT_register_level(RRTICK, RR_MAIN_NO, mb, RRSOFT_ONLY_HARD); |
- RRSOFT_register_level(RRTICK, RR_MAIN_NO, mb, RRSOFT_ONLY_SOFT); |
- |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- |
- SEM_register_module(); |
- CABS_register_module(); |
- PI_register_module(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- HARTPORT_init(); |
- |
- KEYB_init(NULL); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
-void app_mutex_init(mutex_t *m) |
-{ |
- PI_mutexattr_t attr; |
- |
- PI_mutexattr_default(attr); |
- |
- mutex_init(m, &attr); |
-} |
Index: tags/rel_1_22/jumpball/demo.c |
=================================================================== |
--- tags/rel_1_22/jumpball/demo.c (revision 1310) |
+++ tags/rel_1_22/jumpball/demo.c (nonexistent) |
@@ -1,217 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: demo.c,v 1.4 2003-05-01 19:43:16 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.4 $ |
- Last update: $Date: 2003-05-01 19:43:16 $ |
- ------------ |
-**/ |
- |
-/* |
- * Copyright (C) 2000-2003 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include "demo.h" |
-#include <kernel/func.h> |
-#include <string.h> |
-#include <stdlib.h> |
-#include <drivers/keyb.h> |
-#include <drivers/glib.h> |
- |
-/* graphic mutex... */ |
-mutex_t mutex; |
- |
-/* useful colors... */ |
-int white; |
-int black; |
-int red; |
-int gray; |
- |
-void app_mutex_init(mutex_t *m); |
- |
-static void version( void ) |
-{ |
- cprintf( "S.Ha.R.K. Jumpball Demo 1.0\n" ); |
- cprintf( "---------------------------\n" ); |
- cprintf( "by Paolo Gai 1999-2001\n" ); |
- cprintf( " <pj@sssup.it>\n" ); |
- cprintf( "---------------------------\n" ); |
-} |
- |
-int myrand(int x) |
-{ |
- return rand()%x; |
-} |
- |
-void reverse(char s[]) |
-{ |
- int c, i, j; |
- |
- for (i = 0, j = strlen(s)-1; i<j; i++, j--) |
- { |
- c = s[i]; |
- s[i] = s[j]; |
- s[j] = c; |
- } |
-} |
- |
-char * itoa(int n, char *s) |
-{ |
- int i, sign; |
- |
- if ((sign = n) < 0) |
- n = -n; |
- |
- i = 0; |
- |
- do |
- { |
- s[i++] = n % 10 + '0'; |
- } while ((n /= 10) > 0); |
- |
- if (sign < 0) |
- s[i++] = '-'; |
- |
- s[i] = 0; |
- |
- reverse(s); |
- |
- return s; |
-} |
- |
- |
-void scenario() |
-{ |
- grx_text("S.Ha.R.K. Jumpball Demo 1.0", 0, 0, rgb16(0,255,0), black ); |
- grx_text(" by Paolo Gai 1999-2001" , 0, 8, rgb16(0,255,0), black ); |
- grx_text(" pj@sssup.it" , 0,16, rgb16(0,255,0), black ); |
- |
- grx_text("Ctrl-C, Ctrr-C, Enter: exit" ,320, 0, gray, black ); |
- grx_text("Alt-C : void statistics" ,320, 8, gray, black ); |
- grx_text("Space : create noise ball",320,16, gray, black ); |
- grx_text("Backspace : kill noise balls" ,320,24, gray, black ); |
- |
- |
- #ifdef JET_ON |
- scenario_jetcontrol(); |
- #endif |
- |
- #ifdef BALL_ON |
- scenario_ball(); |
- #endif |
-} |
- |
-void my_close(void *arg) |
-{ |
- grx_close(); |
- kern_printf("my_close\n"); |
-} |
- |
- |
-void endfun(KEY_EVT *k) |
-{ |
- cprintf("Ending...\n"); |
- sys_end(); |
-} |
- |
-void zerofun(KEY_EVT *k) |
-{ |
- int i; |
- for (i=0; i<MAX_PROC; i++) jet_delstat(i); |
-} |
- |
-int main(int argc, char **argv) |
-{ |
- int modenum; |
- |
- KEY_EVT k; |
- |
- srand(4); |
- |
- version(); |
- |
- keyb_set_map(itaMap); |
- k.flag = CNTR_BIT; |
- k.scan = KEY_C; |
- k.ascii = 'c'; |
- keyb_hook(k,endfun); |
- k.flag = CNTL_BIT; |
- k.scan = KEY_C; |
- k.ascii = 'c'; |
- keyb_hook(k,endfun); |
- k.flag = ALTL_BIT; |
- k.scan = KEY_C; |
- k.ascii = 'c'; |
- keyb_hook(k,zerofun); |
- k.flag = 0; |
- k.scan = KEY_ENT; |
- k.ascii = 13; |
- keyb_hook(k,endfun); |
- |
- sys_atrunlevel(my_close, NULL, RUNLEVEL_BEFORE_EXIT); |
- |
- |
- grx_init(); |
- modenum = grx_getmode(640, 480, 16); |
- |
- grx_setmode(modenum); |
- |
- /* init the graphic mutex */ |
- app_mutex_init(&mutex); |
- |
- /* useful colors ... */ |
- white = rgb16(255,255,255); |
- black = rgb16(0,0,0); |
- red = rgb16(255,0,0); |
- gray = rgb16(128,128,128); |
- |
- scenario(); |
- |
- #ifdef JET_ON |
- init_jetcontrol(); |
- #endif |
- |
- #ifdef BALL_ON |
- init_ball(); |
- #endif |
- |
- group_activate(1); |
- |
- return 0; |
-} |
- |
- |
Index: tags/rel_1_22/jumpball/ern.c |
=================================================================== |
--- tags/rel_1_22/jumpball/ern.c (revision 1310) |
+++ tags/rel_1_22/jumpball/ern.c (nonexistent) |
@@ -1,108 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: ern.c,v 1.1 2003-05-01 19:43:16 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1 $ |
- Last update: $Date: 2003-05-01 19:43:16 $ |
- ------------ |
-**/ |
- |
-/* |
- * Copyright (C) 2003 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/rr.h" |
-#include "modules/rrsoft.h" |
-#include "modules/dummy.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
-#include "modules/nop.h" |
- |
-#include "drivers/keyb.h" |
- |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 0 |
- |
-/*+ RR tick in us +*/ |
-//#define RRTICK 10000 |
-#define RRTICK 2000 |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- EDF_register_level(EDF_ENABLE_ALL); |
- RRSOFT_register_level(RRTICK, RR_MAIN_NO, mb, RRSOFT_ONLY_HARD|RRSOFT_ONLY_SOFT); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- |
- SEM_register_module(); |
- |
- CABS_register_module(); |
- |
- NOP_register_module(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- HARTPORT_init(); |
- |
- KEYB_init(NULL); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
-void app_mutex_init(mutex_t *m) |
-{ |
- NOP_mutexattr_t attr; |
- |
- NOP_mutexattr_default(attr); |
- |
- mutex_init(m, &attr); |
-} |
Index: tags/rel_1_22/jumpball/ecp.c |
=================================================================== |
--- tags/rel_1_22/jumpball/ecp.c (revision 1310) |
+++ tags/rel_1_22/jumpball/ecp.c (nonexistent) |
@@ -1,106 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: ecp.c,v 1.1 2003-05-01 19:43:16 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1 $ |
- Last update: $Date: 2003-05-01 19:43:16 $ |
- ------------ |
-**/ |
- |
-/* |
- * Copyright (C) 2003 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/cbs.h" |
-#include "modules/rr.h" |
-#include "modules/dummy.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
-#include "modules/pi.h" |
- |
-#include "drivers/keyb.h" |
- |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 0 |
- |
-/*+ RR tick in us +*/ |
-//#define RRTICK 10000 |
-#define RRTICK 2000 |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- EDF_register_level(EDF_ENABLE_ALL); |
- CBS_register_level(CBS_ENABLE_ALL, 0); |
- |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- CABS_register_module(); |
- PI_register_module(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- HARTPORT_init(); |
- |
- KEYB_init(NULL); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
-void app_mutex_init(mutex_t *m) |
-{ |
- PI_mutexattr_t attr; |
- |
- PI_mutexattr_default(attr); |
- |
- mutex_init(m, &attr); |
-} |
Index: tags/rel_1_22/jumpball/jetctrl.c |
=================================================================== |
--- tags/rel_1_22/jumpball/jetctrl.c (revision 1310) |
+++ tags/rel_1_22/jumpball/jetctrl.c (nonexistent) |
@@ -1,244 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: jetctrl.c,v 1.2 2003-05-01 19:43:17 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.2 $ |
- Last update: $Date: 2003-05-01 19:43:17 $ |
- ------------ |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
- |
-// JetControl |
- |
-#include "demo.h" |
-#include "kernel/func.h" |
- |
-TASK jetdummy_task(void *arg) |
-{ |
- TIME now_dummy, last_dummy, diff_dummy, slice; |
- struct timespec now, last, diff; |
- int x = 0; |
- int height; |
- |
- NULL_TIMESPEC(&last); |
- last_dummy = 0; |
- for (;;) { |
- task_nopreempt(); |
- jet_getstat(DUMMY_PID, NULL, NULL, NULL, &now_dummy); |
- sys_gettime(&now); |
- task_preempt(); |
- |
- SUBTIMESPEC(&now, &last, &diff); |
- slice = diff.tv_sec * 1000000 + diff.tv_nsec/1000; |
- diff_dummy = now_dummy - last_dummy; |
- |
- height = (int)(JET_DUMMY_HEIGHT*((float)diff_dummy)/((float)slice)); |
- |
- TIMESPEC_ASSIGN(&last, &now); |
- last_dummy = now_dummy; |
- |
- mutex_lock(&mutex); |
- grx_line(JET_DUMMY_X+x,JET_DUMMY_Y, |
- JET_DUMMY_X+x,JET_DUMMY_Y+height ,black); |
- grx_line(JET_DUMMY_X+x,JET_DUMMY_Y+height, |
- JET_DUMMY_X+x,JET_DUMMY_Y+JET_DUMMY_HEIGHT,white); |
- grx_line(JET_DUMMY_X+(x+1)%JET_DUMMY_WIDTH,JET_DUMMY_Y, |
- JET_DUMMY_X+(x+1)%JET_DUMMY_WIDTH,JET_DUMMY_Y+JET_DUMMY_HEIGHT,255); |
- mutex_unlock(&mutex); |
- |
- x = (x+1)%JET_DUMMY_WIDTH; |
- |
- task_endcycle(); |
- } |
-} |
- |
- |
-TASK jetctrl_task(void *arg) |
-{ |
- char st[50]; |
- TIME sum, max; |
- int n; |
- |
- PID i; |
- int printed = 0; |
- |
- for (;;) { |
- for (i=2, printed=0; i<MAX_PROC && printed<JET_NTASK; i++) { |
- if (jet_getstat(i, &sum, &max, &n, NULL) != -1) { |
- if (!n) n=1; |
- sprintf(st, "%6d %6d %10s", (int)sum/n, (int)max, proc_table[i].name); |
- mutex_lock(&mutex); |
- grx_text(st, 384, JET_Y_NAME+16+printed*8, gray, black); |
- mutex_unlock(&mutex); |
- printed++; |
- } |
- } |
- while (printed<JET_NTASK) { |
- mutex_lock(&mutex); |
- grx_text(" ", |
- 384, JET_Y_NAME+16+printed*8, gray, black); |
- mutex_unlock(&mutex); |
- printed++; |
- } |
- task_endcycle(); |
- } |
-} |
- |
-TASK jetslide_task(void *arg) |
-{ |
- TIME sum, curr, max; |
- |
- TIME total[JET_NTASK]; |
- int slides[JET_NTASK]; |
- |
- PID i; |
- int printed = 0; |
- |
- for (;;) { |
- // Fill the total array in a nonpreemptive section |
- task_nopreempt(); |
- for (i=2, printed=0; i<MAX_PROC && printed<JET_NTASK; i++) { |
- if (jet_getstat(i, &sum, NULL, NULL, &curr) != -1) { |
- total[printed] = sum+curr; |
- printed++; |
- } |
- } |
- task_preempt(); |
- |
- while (printed < JET_NTASK) |
- total[printed++] = 0; |
- |
- // Compute the Max elapsed time |
- max = 0; |
- for (i=0; i<JET_NTASK; i++) |
- if (total[i] > max) max = total[i]; |
- if (!max) max = 1; |
- |
- // Compute the slides width |
- for (i=0; i<JET_NTASK; i++) |
- slides[i] = (int)( (((float)total[i])/max) * JET_SLIDE_WIDTH); |
- |
- // print the data |
- mutex_lock(&mutex); |
- for (i=0; i<JET_NTASK; i++) { |
- grx_box(JET_SLIDE_X, JET_Y_NAME+16+i*8, |
- JET_SLIDE_X+slides[i], JET_Y_NAME+23+i*8, gray); |
- grx_box(JET_SLIDE_X+slides[i], JET_Y_NAME+16+i*8, |
- JET_SLIDE_X+JET_SLIDE_WIDTH, JET_Y_NAME+23+i*8, black); |
- } |
- |
- while (i<JET_NTASK) { |
- grx_box(JET_SLIDE_X, JET_Y_NAME+16+i*8, |
- JET_SLIDE_X+JET_SLIDE_WIDTH, JET_Y_NAME+20+i*8, black); |
- i++; |
- } |
- mutex_unlock(&mutex); |
- task_endcycle(); |
- } |
-} |
- |
- |
-void scenario_jetcontrol(void) |
-{ |
- grx_text("System load" , 384, 45, rgb16(0,0,255), black); |
- grx_line(384,55,639,55,red); |
- |
- grx_text(" Mean Max Name Slide", 384, JET_Y_NAME, gray, black); |
- grx_line(384,JET_Y_NAME+10,639,JET_Y_NAME+10,gray); |
- |
- grx_rect(JET_DUMMY_X-1, JET_DUMMY_Y-1, |
- JET_DUMMY_X+JET_DUMMY_WIDTH, JET_DUMMY_Y+JET_DUMMY_HEIGHT+1, gray); |
- |
- grx_text("100%", JET_DUMMY_X-40, JET_DUMMY_Y, gray, black); |
- grx_text(" 0%", JET_DUMMY_X-40, JET_DUMMY_Y+JET_DUMMY_HEIGHT-8, gray, black); |
- |
- grx_line(JET_DUMMY_X-1, JET_DUMMY_Y, JET_DUMMY_X-5, JET_DUMMY_Y, gray); |
- grx_line(JET_DUMMY_X-1, JET_DUMMY_Y+JET_DUMMY_HEIGHT, JET_DUMMY_X-5, JET_DUMMY_Y+JET_DUMMY_HEIGHT, gray); |
-} |
- |
-void init_jetcontrol(void) |
-{ |
- SOFT_TASK_MODEL m3, m4, m5; |
- |
- PID p3, p4, p5; |
- |
- soft_task_default_model(m3); |
- soft_task_def_level(m3,1); |
- soft_task_def_period(m3, PERIOD_JETCTRL); |
- soft_task_def_met(m3, WCET_JETCTRL); |
- soft_task_def_ctrl_jet(m3); |
- soft_task_def_group(m3, 1); |
- p3 = task_create("jctrl", jetctrl_task, &m3, NULL); |
- if (p3 == -1) { |
- sys_shutdown_message("Could not create task <jetctrl> errno=%d", |
- errno); |
- sys_end(); |
- } |
- |
- soft_task_default_model(m4); |
- soft_task_def_level(m4,1); |
- soft_task_def_period(m4, PERIOD_JETDUMMY); |
- soft_task_def_met(m4, WCET_JETDUMMY); |
- soft_task_def_group(m4, 1); |
- soft_task_def_usemath(m4); |
- soft_task_def_ctrl_jet(m4); |
- p4 = task_create("jdmy", jetdummy_task, &m4, NULL); |
- if (p4 == -1) { |
- sys_shutdown_message("Could not create task <jetdummy> errno=%d", |
- errno); |
- sys_end(); |
- } |
- |
- soft_task_default_model(m5); |
- soft_task_def_level(m5,1); |
- soft_task_def_period(m5, PERIOD_JETSLIDE); |
- soft_task_def_met(m5, WCET_JETSLIDE); |
- soft_task_def_group(m5, 1); |
- soft_task_def_usemath(m5); |
- soft_task_def_ctrl_jet(m5); |
- p5 = task_create("jsli", jetslide_task, &m5, NULL); |
- if (p5 == -1) { |
- sys_shutdown_message("Could not create task <jetslide> errno=%d", |
- errno); |
- sys_end(); |
- } |
-} |
- |
Index: tags/rel_1_22/jumpball/demo.h |
=================================================================== |
--- tags/rel_1_22/jumpball/demo.h (revision 1310) |
+++ tags/rel_1_22/jumpball/demo.h (nonexistent) |
@@ -1,171 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: demo.h,v 1.3 2003-05-05 09:21:55 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.3 $ |
- Last update: $Date: 2003-05-05 09:21:55 $ |
- ------------ |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
- |
-#include <ll/ll.h> |
-#include <kernel/types.h> |
-#include <kernel/descr.h> |
-#include <math.h> |
-#include <drivers/glib.h> |
-#include <drivers/keyb.h> |
- |
- |
-/* Subparts */ |
-#define JET_ON |
-#define BALL_ON |
- |
- |
-/* CPU Speed Selection |
- -------------------------------------------------------------------- |
- 1700 - Pentium 4 1.7 GHz |
- 400 - Pentium 2 400 MHz |
- 133 - Pentium 1 133 MHz |
-*/ |
-#define CPU 1700 |
- |
-/* |
- * |
- * WCET, Periods and Models |
- * |
- */ |
- |
-#if CPU==133 |
-#define WCET_JETCTRL 10000 |
-#define WCET_JETDUMMY 300 |
-#define WCET_JETSLIDE 2000 |
-#define WCET_BALL 250 |
-#define WCET_HARD_BALL 1000 |
-#define BALL_DELAY 10000 |
-#endif |
- |
-#if CPU==400 |
-#define WCET_JETCTRL 7500 |
-#define WCET_JETDUMMY 200 |
-#define WCET_JETSLIDE 2100 |
-#define WCET_BALL 100 |
-#define WCET_HARD_BALL 380 |
-#define BALL_DELAY 10000 |
-#endif |
- |
-#if CPU==1700 |
-#define WCET_JETCTRL 4500 |
-#define WCET_JETDUMMY 100 |
-#define WCET_JETSLIDE 1300 |
-#define WCET_BALL 100 |
-#define WCET_HARD_BALL 410 |
-#define BALL_DELAY 100000 |
-#endif |
- |
-#define PERIOD_JETCTRL 100000 |
-#define PERIOD_JETDUMMY 100000 |
-#define PERIOD_JETSLIDE 100000 |
-#define PERIOD_BALL 10000 |
- |
-/* |
- * |
- * Global Stuffs |
- * |
- */ |
- |
-/* graphic mutex... */ |
-extern mutex_t mutex; |
- |
-/* useful colors... */ |
-extern int white; |
-extern int black; |
-extern int red; |
-extern int gray; |
- |
-void init_jetcontrol(); |
-void init_ball(void); |
-void scenario_jetcontrol(); |
-void scenario_ball(); |
-char *itoa(int n, char *s); |
-int myrand(int x); |
- |
- |
- |
-/* |
- * |
- * JETCONTROL stuffs |
- * |
- */ |
- |
-#define JET_NTASK 35 |
-#define JET_Y_NAME 170 |
- |
-#define DUMMY_PID 1 |
- |
-#define JET_DUMMY_WIDTH 210 |
-#define JET_DUMMY_HEIGHT 80 |
- |
-/* the point (x, y) is the top left corner */ |
-#define JET_DUMMY_X 428 |
-#define JET_DUMMY_Y 65 |
- |
-#define JET_SLIDE_WIDTH 50 |
-#define JET_SLIDE_X 576 |
- |
- |
- |
- |
-/* |
- * |
- * BALL stuffs |
- * |
- */ |
- |
-// x and y corners are specified whithout consider a border of 3 pixels |
-#define BALL_Y 450 /* position of the floor */ |
-#define BALL_HEIGHT 385 /* initial height of the ball */ |
-#define BALL_XMIN 10 /* min position X of the ball */ |
-#define BALL_XMAX 370 /* max position X of the ball */ |
-#define BALL_VELX 5. /* horizontal ball velocity */ |
-#define BALL_VYMIN 11. /* min ground speed */ |
-#define BALL_MAX_P 60 /* max number of balls */ |
- |
-#define BALL_GROUP 2 /* task group of the balls */ |
Index: tags/rel_1_22/jumpball/readme.txt |
=================================================================== |
--- tags/rel_1_22/jumpball/readme.txt (revision 1310) |
+++ tags/rel_1_22/jumpball/readme.txt (nonexistent) |
@@ -1,94 +0,0 @@ |
----------------------------------- |
-Jumping Balls demo |
- |
-by |
- |
-Paolo Gai 1999-2001 - pj@sssup.it |
- |
----------------------------------- |
- |
-This demo was created to show some S.Ha.R.K. functionalities in the course |
-of Informatica Industriale , University of Pavia, Italy. |
- |
-The demo is composed by an application (derived by the template application |
-distributed on the web site) and two init files. |
- |
-The demo is composed by: |
- |
-MAKEFILE The makefile used to compile the application; |
- demo is the rule to compile the application with a CBS scheduler |
- demo2 is the rule to compile the application with a RR scheduler |
-README.TXT This file |
-DEMO.H Some constants used into the demo |
-ECP.C, ERN.C, RRP.C, RRN.C Various initfiles |
-INITFIL2.C The EDF initfile |
-INITFILE.C A makefile that cover either EDF+CBS and RR |
-BALL.C The Jumping balls part of the demo |
-DEMO.C The main() function and some other utility function |
-JETCTRL.C The JET part of the demo |
- |
-The demo works as follows: |
-- It works at 640x480 16 bit colors |
-- on the left, there is the jumping ball arena, on the rigth there is the |
- statistics about the tasks into the system. |
- |
-- the tasks are guaranteed using CBS and EDF. The wcet and mean execution |
- time on my portable after a few minutes are (us): |
- |
- JetCtrl 7400 max 7500 CBS met |
- JetDummy 135 max 200 CBS met |
- JetSlide 2100 max 2100 CBS met |
- Balls 276 max 380 EDF wcet for hard ball,100 CBS met for soft ones |
- |
- The system should go overloaded with 40 soft balls. |
- |
-- The idea is the following: |
- - first, an edf guaranteed ball is created. |
- - then, create a set of soft ball using space. since their met is < than the |
- real met, they posticipate the deadlines. |
- - if they are killed, they remain for some seconds in the zombie state |
- - if a set of soft ball arde created (i.e., 10), and after a while all the |
- others are created, the bandwidth is fully used, and the task posticipate |
- their deadlines. the first set of tasks stops jumping when the bandwidth |
- is full utilized by the newest balls until all the tasks have similar |
- deadlines. |
- - Note on the left the slides that represents the relative ratio |
- between the tasks. |
- - Note that in overload conditions the EDF task is still guaranteed |
- - Note that PI is used with EDF, also if no theory says that it is good: |
- - S.Ha.R.K. allows that, it is the user that have to choose if that is |
- a non-sense |
- - PI is independent from the implemnentation of the scheduling modules |
- - if the second init file is used, RR is used instead of EDF+CBS. |
- - In overload condition RR perform differently from EDF+CBS, giving to |
- each task an equal fraction of bandwidth |
- |
- - note also: |
- - the redefinition of the standard exception handler |
- - the redefinition of the keys and the initialization of the keyboard |
- - the myend exit function |
- - the main() that terminates |
- - the two parts (ball and jet) can be excluded using a #define |
- |
-If You have any question, please contact the author... |
- |
-Update (2003/12/19): |
-Just some more notes... |
-I usually show the four demos in the following order: |
- |
-(first of all, tune the demo depending on how fast your notebook is; see demo.h) |
- |
-ECP - EDF with CBS and PI... the white EDF ball still work also in overload; CBS balls just slow down but they still get their guaranteed bandwidth |
- |
-RRP - Round Robin with Priority inheritance ... the EDF ball is at the same level of the others, all slow down... |
- |
-RRN - 2 levels of Round Robin, without Priority inheritance ... when |
-there is overload, the white ball works ok, but the other have an impredicible |
-behavior (they execute many instances in one RR period) |
- |
-ERN - EDF, RR, no priority inheritance - the white ball misses his deadline |
-just when there is an overload (all the other balls are queued on the same |
-semaphore, so the blocking time increase, and when there is overload the EDF |
-task misses also if it has not consumed his bandwidth). Note that it happens |
-also if the EDF task consume just a few microseconds... Real time does not |
-means "fast" :-) |
Index: tags/rel_1_22/jumpball/ball.c |
=================================================================== |
--- tags/rel_1_22/jumpball/ball.c (revision 1310) |
+++ tags/rel_1_22/jumpball/ball.c (nonexistent) |
@@ -1,246 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: ball.c,v 1.3 2003-05-05 09:21:55 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.3 $ |
- Last update: $Date: 2003-05-05 09:21:55 $ |
- ------------ |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-/*--------------------------------------------------------------*/ |
-/* SIMULATION OF JUMPING BALLS */ |
-/*--------------------------------------------------------------*/ |
- |
-#include "demo.h" |
-#include <kernel/func.h> |
-#include <stdlib.h> |
- |
-#define R 8 /* dimension of a ball */ |
-#define G 9.8 /* acceleration of gravity */ |
- |
-static int ballexit = 0; |
-static int npc = 0; /* number of tasks created */ |
- |
-/*--------------------------------------------------------------*/ |
-/* Delay function for jumping balls */ |
-/*--------------------------------------------------------------*/ |
- |
-void my_delay(void) |
-{ |
- int xxx; |
- for (xxx=0; xxx<BALL_DELAY; xxx++); |
-} |
- |
-/*--------------------------------------------------------------*/ |
-/* Periodic task for ball simulation */ |
-/*--------------------------------------------------------------*/ |
- |
-TASK palla(int i) |
-{ |
-int x, y; /* coordinate grafiche pallina */ |
-int ox, oy; /* vecchia posizione pallina */ |
-int x0, y0; /* posizione iniziale X pallina */ |
-float vx, vy; /* velocitÂ… della pallina */ |
-float vy0; /* velocita' pallina al primo rimbalzo */ |
-float ty, tx; /* variabile temporale */ |
-float dt; /* incremento temporale */ |
- |
- y = oy = y0 = BALL_HEIGHT; |
- x = ox = x0 = BALL_XMIN; |
- |
- vy0= sqrt(2. * G * (float)BALL_HEIGHT); |
- vy = 0; |
- vx = BALL_VELX + myrand(9); |
- tx = 0; |
- ty = 0; |
- dt = ((float)PERIOD_BALL)/100000; |
- |
- while (1) { |
- y = y0 + vy*ty - .5*G*ty*ty; |
- x = x0 + vx * tx; |
- |
- if (y < 0) { |
- y = 0; |
- |
- if (vy == 0.0) |
- vy = vy0; |
- else if (vy < BALL_VYMIN) |
- vy = vy0 * (1.0 - myrand(50)/100.0); |
- else |
- vy = 0.9 * vy; |
- |
- ty = 0.0; |
- y0 = 0; |
- } |
- |
- if (x > BALL_XMAX) { |
- tx = 0.0; |
- x0 = BALL_XMAX; |
- vx = -vx; |
- x = x0 + vx * tx; |
- } |
- |
- if (x < BALL_XMIN) { |
- tx = 0.0; |
- x0 = BALL_XMIN; |
- vx = -vx; |
- x = x0 + vx * tx; |
- } |
- |
- mutex_lock(&mutex); |
- grx_disc(ox, oy, R, 0); |
- ox = x; |
- oy = BALL_Y - y; |
- mutex_unlock(&mutex); |
- |
- if (ballexit && i!=0xFFFF) { |
- npc--; |
- return 0; |
- } |
- |
- mutex_lock(&mutex); |
- grx_disc(ox, oy, R, i); |
- mutex_unlock(&mutex); |
- |
- my_delay(); |
- |
- ty += dt; |
- tx += dt; |
- task_endcycle(); |
- } |
-} |
- |
-void killball(KEY_EVT *k) |
-{ |
- ballexit = 1; |
-} |
- |
-void ballfun(KEY_EVT *k) |
-{ |
- SOFT_TASK_MODEL mp; |
- int r,g,b; |
- PID pid; |
- char palla_str[]="palla "; |
- |
- if (npc == BALL_MAX_P) return; |
- |
- ballexit = 0; |
- |
- r = 64 + myrand(190); |
- g = 64 + myrand(190); |
- b = 64 + myrand(190); |
- |
- itoa(npc,palla_str+5); |
- |
- soft_task_default_model(mp); |
- soft_task_def_level(mp,1); |
- soft_task_def_ctrl_jet(mp); |
- soft_task_def_arg(mp, (void *)rgb16(r,g,b)); |
- soft_task_def_group(mp, BALL_GROUP); |
- soft_task_def_met(mp, WCET_BALL); |
- soft_task_def_period(mp,PERIOD_BALL); |
- soft_task_def_usemath(mp); |
- pid = task_create(palla_str, palla, &mp, NULL); |
- |
- if (pid != NIL) { |
- task_activate(pid); |
- npc++; |
- } |
-} |
- |
-void hardball() |
-{ |
- HARD_TASK_MODEL mp; |
- int r,g,b; |
- PID pid; |
- |
- r = 255; |
- g = 255; |
- b = 255; |
- |
- hard_task_default_model(mp); |
- hard_task_def_ctrl_jet(mp); |
- hard_task_def_arg(mp, (void *)rgb16(r,g,b)); |
- hard_task_def_wcet(mp, WCET_HARD_BALL); |
- hard_task_def_mit(mp,PERIOD_BALL); |
- hard_task_def_usemath(mp); |
- pid = task_create("pallaEDF", palla, &mp, NULL); |
- if (pid == NIL) { |
- sys_shutdown_message("Could not create task <pallaEDF>"); |
- sys_end(); |
- } |
- else |
- task_activate(pid); |
-} |
- |
- |
-/*--------------------------------------------------------------*/ |
-/* MAIN process */ |
-/*--------------------------------------------------------------*/ |
- |
-void scenario_ball() |
-{ |
- grx_text("Noise", 0, 45 /*BALL_Y-BALL_HEIGHT-15*/, rgb16(0,0,255), black); |
- grx_line(0,55,383,55,red); |
-//grx_line(0,BALL_Y-BALL_HEIGHT-6,383,BALL_Y-BALL_HEIGHT-6,red); |
- |
- grx_rect(BALL_XMIN-R-1, BALL_Y-BALL_HEIGHT-R-1, |
- BALL_XMAX+R+1, BALL_Y+R+1, rgb16(0,200,0)); |
-} |
- |
-void init_ball(void) |
-{ |
- KEY_EVT k; |
- |
- hardball(); |
- |
- k.flag = 0; |
- k.scan = KEY_SPC; |
- k.ascii = ' '; |
- keyb_hook(k,ballfun); |
- |
- k.flag = 0; |
- k.scan = KEY_BKS; |
- k.ascii = ' '; |
- keyb_hook(k,killball); |
-} |
- |
-/*--------------------------------------------------------------*/ |
Index: tags/rel_1_22/jumpball/makefile |
=================================================================== |
--- tags/rel_1_22/jumpball/makefile (revision 1310) |
+++ tags/rel_1_22/jumpball/makefile (nonexistent) |
@@ -1,24 +0,0 @@ |
-# |
-# |
-# |
- |
-ifndef BASE |
-BASE=../.. |
-endif |
-include $(BASE)/config/config.mk |
- |
-PROGS= ecp ern rrp rrn |
- |
-include $(BASE)/config/example.mk |
- |
-ecp: |
- make -f $(SUBMAKE) APP=ecp INIT= OTHEROBJS="demo.o ball.o jetctrl.o" OTHERINCL= SHARKOPT="__OLDCHAR__ __GRX__" |
- |
-ern: |
- make -f $(SUBMAKE) APP=ern INIT= OTHEROBJS="demo.o ball.o jetctrl.o" OTHERINCL= SHARKOPT="__OLDCHAR__ __GRX__" |
- |
-rrp: |
- make -f $(SUBMAKE) APP=rrp INIT= OTHEROBJS="demo.o ball.o jetctrl.o" OTHERINCL= SHARKOPT="__OLDCHAR__ __GRX__" |
- |
-rrn: |
- make -f $(SUBMAKE) APP=rrn INIT= OTHEROBJS="demo.o ball.o jetctrl.o" OTHERINCL= SHARKOPT="__OLDCHAR__ __GRX__" |
Index: tags/rel_1_22/jumpball/rrn.c |
=================================================================== |
--- tags/rel_1_22/jumpball/rrn.c (revision 1310) |
+++ tags/rel_1_22/jumpball/rrn.c (nonexistent) |
@@ -1,109 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: rrn.c,v 1.1 2003-05-01 19:43:17 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1 $ |
- Last update: $Date: 2003-05-01 19:43:17 $ |
- ------------ |
-**/ |
- |
-/* |
- * Copyright (C) 2003 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/rr.h" |
-#include "modules/rrsoft.h" |
-#include "modules/dummy.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
-#include "modules/nop.h" |
- |
-#include "drivers/keyb.h" |
- |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 0 |
- |
-/*+ RR tick in us +*/ |
-//#define RRTICK 10000 |
-#define RRTICK 2000 |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- RR_register_level(RRTICK, RR_MAIN_NO, mb); // this module remains empty!!! |
- RRSOFT_register_level(RRTICK, RR_MAIN_NO, mb, RRSOFT_ONLY_HARD|RRSOFT_ONLY_SOFT); |
- |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- |
- SEM_register_module(); |
- |
- CABS_register_module(); |
- |
- NOP_register_module(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- HARTPORT_init(); |
- |
- KEYB_init(NULL); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
-void app_mutex_init(mutex_t *m) |
-{ |
- NOP_mutexattr_t attr; |
- |
- NOP_mutexattr_default(attr); |
- |
- mutex_init(m, &attr); |
-} |
Index: tags/rel_1_22/slsh/slshtest.c |
=================================================================== |
--- tags/rel_1_22/slsh/slshtest.c (revision 1310) |
+++ tags/rel_1_22/slsh/slshtest.c (nonexistent) |
@@ -1,173 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * Massimiliano Giorgi <massy@gandalf.sssup.it> |
- * Luca Abeni <luca@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: slshtest.c,v 1.1.1.1 2002-09-02 09:37:41 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1.1.1 $ |
- Last update: $Date: 2002-09-02 09:37:41 $ |
- ------------ |
- |
- Slot shifting test |
- |
- |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai and Tomas Lennvall |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include <kernel/config.h> |
-#include "kernel/kern.h" |
-#include "slsh.h" |
-#include "drivers/keyb.h" |
- |
-/* a slot length of 100 ms */ |
-#define SLOT_LENGTH 100000 |
- |
- |
-TASK static1(void) |
-{ |
- int i = 0; |
- |
- kern_printf("Static1\n"); |
- while(sys_gettime(NULL) < 10000) i++; |
- |
- return 0; |
-} |
- |
-TASK static2(void) |
-{ |
- int i = 0; |
- |
- kern_printf("Static2\n"); |
- while(sys_gettime(NULL) < 10000) i++; |
- |
- return 0; |
-} |
- |
- |
-TASK static3(void) |
-{ |
- kern_printf("Static3\n"); |
- |
- return 0; |
-} |
- |
-void my_end(KEY_EVT *e) |
-{ |
- sys_end(); |
-} |
- |
-int main(int argc, char** argv) |
-{ |
- STATIC_TASK_MODEL s; |
- // HARD_TASK_MODEL h_aper; |
- // SOFT_TASK_MODEL u; |
- PID p1,p2,p3; |
- struct timespec x; |
- |
- KEY_EVT emerg; |
- |
- kern_cli(); |
- x.tv_sec=5; |
- kern_event_post(&x,(void (*)(void *))sys_end,NULL); |
- kern_sti(); |
- |
- //keyb_set_map(itaMap); |
- emerg.ascii = 'x'; |
- emerg.scan = KEY_X; |
- emerg.flag = ALTL_BIT; |
- keyb_hook(emerg,my_end); |
- |
- /* set som variables in the scheduling level */ |
- SLSH_set_interval(0, 0, 8, 5); |
- SLSH_set_interval(0, 8, 17, 7); |
- SLSH_set_interval(0, 17, 20, 1); |
- |
- SLSH_set_variables(0, SLOT_LENGTH); |
- |
- static_task_default_model(s); |
- static_task_def_group(s, 1); |
- |
- /* define time i ms */ |
- /* static1 task */ |
- static_task_def_est(s, 0); |
- static_task_def_dabs(s, 800000); |
- static_task_def_wcet(s, 500000); |
- static_task_def_interval(s, 0); |
- |
- kern_printf("In main, before task creation\n"); |
- |
- p1 = task_create("Static 1", static1, &s, NULL); |
- if(p1 == NIL) |
- kern_printf("Cannot create: Static1!\n"); |
- |
- /* Static2 task */ |
- static_task_def_est(s, 800000); |
- static_task_def_dabs(s, 1700000); |
- static_task_def_wcet(s, 700000); |
- static_task_def_interval(s, 1); |
- |
- p2 = task_create("Static 2", static2, &s, NULL); |
- if(p2 == NIL) |
- kern_printf("Cannot create: Static2!\n"); |
- |
- /* Static3 task */ |
- static_task_def_est(s, 1700000); |
- static_task_def_dabs(s, 2000000); |
- static_task_def_wcet(s, 100000); |
- static_task_def_interval(s, 2); |
- |
- |
- p3 = task_create("Static3", static3, &s, NULL); |
- if(p3 == NIL) |
- kern_printf("Cannot create: Static3!\n"); |
- |
- |
- /* End task */ |
- /*hard_task_default_model(h_aper); |
- |
- |
- hard_task_def_wcet(h_aper, 100000); |
- */ |
- kern_printf("After task creation\n"); |
- |
- group_activate(1); |
- |
- return 0; |
-} |
Index: tags/rel_1_22/slsh/slsh.c |
=================================================================== |
--- tags/rel_1_22/slsh/slsh.c (revision 1310) |
+++ tags/rel_1_22/slsh/slsh.c (nonexistent) |
@@ -1,750 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * Massimiliano Giorgi <massy@gandalf.sssup.it> |
- * Luca Abeni <luca@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: slsh.c,v 1.5 2003-12-17 13:52:47 giacomo Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.5 $ |
- Last update: $Date: 2003-12-17 13:52:47 $ |
- ------------ |
- |
- This file contains the scheduling module for Slot-Shifting. |
- |
- Read slsh.h for further details. |
- |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
- |
-#include "slsh.h" |
-#include <ll/stdio.h> |
-#include <ll/stdlib.h> |
-#include <ll/string.h> |
-#include <ll/math.h> /* for ceil(...) */ |
-#include <ll/ll.h> /* for memcpy(...) */ |
-#include <kernel/model.h> |
-#include <kernel/descr.h> |
-#include <kernel/var.h> |
-#include <kernel/func.h> |
- |
-//#define eslsh_printf kern_printf |
-#define slsh_printf printk |
- |
-/* Keeps information about static and guaranteed tasks */ |
-typedef struct { |
- int est; |
- int dabs; |
- int interval; |
-} SLSH_task; |
- |
-/*+ Status used in the level +*/ |
-#define SLSH_READY MODULE_STATUS_BASE |
-#define SLSH_WAIT MODULE_STATUS_BASE + 1 |
-#define SLSH_IDLE MODULE_STATUS_BASE + 2 |
-#define SLSH_WCET_VIOLATED MODULE_STATUS_BASE + 3 |
- |
-/*+ defines +*/ |
-#define MAX_INTERVALS 1000 /* 1000 intervals is max, for now */ |
- |
-/******+ the level redefinition for the SLOT SHIFT level +*******/ |
-typedef struct { |
- level_des l; /*+ the standard level descriptor+*/ |
- |
- /* task lists */ |
- SLSH_task tasks[MAX_PROC]; /* est and dl's for static and guaranteed task */ |
- |
- IQUEUE idle_statics; /* finished static tasks */ |
- |
- IQUEUE unspecified; /* tasks with only a wcet */ |
- |
- /* the Intervals list */ |
- SLSH_interval intervals[MAX_INTERVALS]; |
- int current; /* current interval */ |
- int last; /* last interval */ |
- |
- int slot; /* slot shifting time */ |
- TIME slot_length; /* slothlength in real system time*/ |
- int LCM; /* length (in slots) of ofline schedule */ |
- |
- int slot_event; /* save the event */ |
-} SLSH_level_des; |
- |
- |
-/* check if some tasks are ready, return 0 if ready, -1 otherwise */ |
-static int SLSH_R(SLSH_task* tasks) |
-{ |
- int s; |
- |
- /* for all static tasks */ |
- for(s = 0; tasks[s].est != -1; ++s) |
- { |
- if(proc_table[s].status == SLSH_READY) |
- return 0; |
- } |
- return -1; |
-} |
- |
-/* check if unspecified exists, return 0 if it exists, -1 otherwise */ |
-static int SLSH_T(IQUEUE *unspecified) |
-{ |
- if(!iq_isempty(unspecified)) |
- return 0; |
- else |
- return -1; |
-} |
- |
-/* return the sc in an interval */ |
-static int SLSH_sc(SLSH_interval* intervals, int i) |
-{ |
- return intervals[i].sc; |
-} |
-/* return a static task from current interval or a guaranted task */ |
-static PID SLSH_staticOrGuaranteed(SLSH_level_des* lev) |
-{ |
- int lowest_dl = 0; /* lowest dl found */ |
- PID pid = 0; /* static or guaranteed task */ |
- int t; |
- |
- /* Decide according to EDF, go through all static & guaranteed tasks */ |
- for(t = 0; t < MAX_PROC; ++t) |
- { |
- /* static tasks */ |
- if(proc_table[t].pclass == STATIC_PCLASS) |
- { |
- /* static task must belong to current interval */ |
- if(lev->tasks[t].interval == lev->current) |
- { |
- /* only ready tasks */ |
- if(proc_table[t].status == SLSH_READY) |
- { |
- /* a new lower dl was found */ |
- if(lev->tasks[t].dabs < lowest_dl) |
- { |
- lowest_dl = lev->tasks[t].dabs; |
- pid = t; |
- } |
- } |
- } |
- } /* guaranteed tasks */ |
- else if(proc_table[t].pclass == HARD_PCLASS) |
- { |
- /* only ready tasks */ |
- if(proc_table[t].status == SLSH_READY) |
- { |
- /* a new lower dl was found */ |
- if(lev->tasks[t].dabs < lowest_dl) |
- { |
- lowest_dl = lev->tasks[t].dabs; |
- pid = t; |
- } |
- } |
- } |
- }/* for all tasks */ |
- |
- return pid; |
-} |
- |
-/* return a static task among the candidates, all ready statics */ |
-static PID SLSH_candidates(SLSH_task* tasks) |
-{ |
- int lowest_dl = 0; |
- PID pid = -1; |
- int t; |
- |
- /* Use the EDL algorithm again to decide which task to run */ |
- for(t = 0; t < MAX_PROC; ++t) |
- { |
- /* only static tasks */ |
- if(proc_table[t].pclass == STATIC_PCLASS) |
- { |
- /* only ready tasks */ |
- if(proc_table[t].status == SLSH_READY) |
- { |
- /* a new lower dl was found */ |
- if(tasks[t].dabs < lowest_dl) |
- { |
- lowest_dl = tasks[t].dabs; |
- pid = t; |
- } |
- }/* all ready tasks */ |
- }/* all static tasks */ |
- }/* for all tasks */ |
- |
- return pid; |
-} |
- |
-/* decrease the sc in a interval by amount */ |
-void SLSH_decSc(SLSH_interval* intervals, int i, int amount) |
-{ |
- intervals[i].sc -= amount; |
-} |
- |
-void SLSH_incSc(SLSH_interval* intervals, int i, int amount) |
-{ |
- intervals[i].sc += amount; |
-} |
- |
-/* swap the sc between intervals, also consider intervals with negative sc */ |
-void SLSH_swapSc(SLSH_interval* intervals, int current, int task_interval) |
-{ |
- /* decrease the sc in the current interval */ |
- SLSH_decSc(intervals, current, 1); |
- |
- /* update the other interval(s) */ |
- if(intervals[task_interval].sc < 0) /* negative sc */ |
- { |
- /* special case, increase next interval sc by 1 and also current interval (borrowing) */ |
- if(task_interval == current + 1) |
- { |
- SLSH_incSc(intervals, task_interval, 1); |
- SLSH_incSc(intervals, current, 1); |
- } |
- else /* increase every interval sc that is negative between current and task_interval */ |
- { |
- while(task_interval > current && intervals[task_interval].sc < 0) |
- { |
- SLSH_incSc(intervals, task_interval, 1); |
- task_interval--; |
- } |
- } |
- } |
- else /* ordinary swapping */ |
- SLSH_incSc(intervals, task_interval, 1); |
-} |
- |
-/* The scheduler, decides which task to run. */ |
-static PID SLSH_public_scheduler(LEVEL l) |
-{ |
- SLSH_level_des* lev = (SLSH_level_des *)(level_table[l]); |
- PID pid; |
- |
- /* The scheduler choses among static, guaranteed (hard aperiodic) and |
- unspecified (soft aperiodic) tasks */ |
- /* no ready tasks and no sc, execute idle task */ |
- if(SLSH_R(lev->tasks) == 0 && SLSH_sc(lev->intervals, lev->current) == 0) |
- return NIL; |
- /* must execute a static from current intervall or a guaranteed task */ |
- else if(SLSH_R(lev->tasks) > 0 && SLSH_sc(lev->intervals, lev->current) == 0) |
- return SLSH_staticOrGuaranteed(lev); |
- /* sc available... */ |
- else if(SLSH_R(lev->tasks) > 0 && SLSH_sc(lev->intervals, lev->current) > 0) |
- { |
- /* If unspecified exist, execute it according to FIFO order */ |
- if(SLSH_T(&lev->unspecified) == 0) |
- { |
- SLSH_decSc(lev->intervals, lev->current, 1); /* decrease sc by 1 */ |
- return iq_getfirst(&lev->unspecified); |
- } |
- else /* No unspecified, execute task from candidates (statics) */ |
- { |
- pid = SLSH_candidates(lev->tasks); |
- |
- /* sc needs to be swapped */ |
- if(lev->tasks[pid].interval != lev->current) |
- SLSH_swapSc(lev->intervals, lev->tasks[pid].interval, lev->current); |
- |
- return pid; |
- } |
- } |
- |
- kern_printf("(SLSH s)"); |
- return NIL; |
-} |
- |
-/* not used, slot-shifting handles all guarantees itself, it handles all bandwidth */ |
-static int SLSH_public_guarantee(LEVEL l, bandwidth_t *freebandwidth) |
-{ |
- *freebandwidth = 0; |
- return 1; |
-} |
- |
-/* get the interval that x is in */ |
-static int SLSH_getInterval(SLSH_interval* intervals, int x, int last) |
-{ |
- int i; |
- |
- /* search through the intervals */ |
- for(i = 0; i <= last; ++i) |
- { |
- /* I is in the interval where start is smaller or equal and end is bigger */ |
- if(intervals[i].start <= x && x < intervals[i].end) |
- return i; |
- } |
- return -1; |
-} |
- |
-/* get the start of the interval I */ |
-static int SLSH_intervalStart(SLSH_interval* intervals, int I) |
-{ |
- return intervals[I].start; |
-} |
- |
-/* split interval I into two parts, slow because of copying. OBS!!! no check if there is |
- enough space in the intervals array */ |
-static void SLSH_splitInterval(SLSH_level_des* lev, int I, int dabs) |
-{ |
- SLSH_interval left_interval; |
- int i; |
- |
- |
- lev->last++; |
- |
- /* move every interval above and including I */ |
- for(i = lev->last; i > I; --i) |
- memcpy(&lev->intervals[i], &lev->intervals[i - 1], sizeof(SLSH_interval)); |
- |
- /* Left interval start, end and length */ |
- left_interval.start = lev->intervals[I].start; |
- left_interval.end = dabs; |
- left_interval.length = left_interval.end - left_interval.start; |
- |
- /* Right interval (uses old interval struct) start and length end remains as the old value */ |
- lev->intervals[I + 1].start = dabs; |
- lev->intervals[I + 1].length = lev->intervals[I + 1].end - lev->intervals[I + 1].start; |
- |
- /* check if sc still exists in the right interval */ |
- if(lev->intervals[I + 1].length - lev->intervals[I + 1].maxt > 0) |
- { |
- lev->intervals[I + 1].sc = lev->intervals[I + 1].length - lev->intervals[I + 1].maxt; |
- left_interval.sc = left_interval.length; /* the whole interval is free, for now... */ |
- } |
- else /* no sc in the right interval */ |
- { |
- lev->intervals[I + 1].maxt = lev->intervals[I + 1].length; |
- left_interval.sc = lev->intervals[I + 1].sc; /* all sc in left interval */ |
- lev->intervals[I + 1].sc = 0; |
- } |
- |
- /* insert the new interval */ |
- memcpy(&lev->intervals[I], &left_interval, sizeof(SLSH_interval)); |
-} |
- |
-/* Reduce the sc from back to front by the wcet amount, interval splitting may be neccesary */ |
-static void SLSH_updateSc(SLSH_level_des* lev, HARD_TASK_MODEL* h) |
-{ |
- int dabs = ceil((lev->slot + h->drel)/lev->slot_length); /* absolute deadline of request */ |
- int dabs_interval = SLSH_getInterval(lev->intervals, dabs, lev->last); /* interval where dabs is */ |
- int C = ceil(h->wcet/lev->slot_length); /* amount of sc to reduce */ |
- int sc = 0; |
- int i; |
- |
- /* check if interval splitting is neccesary */ |
- if(lev->intervals[dabs_interval].end != dabs) |
- SLSH_splitInterval(lev, dabs_interval, dabs); |
- |
- /* decrease sc in all intervals that are neccesary from dabs_interval o current */ |
- for(i = dabs_interval; i >= lev->current && C > 0; --i) |
- { |
- if((sc = SLSH_sc(lev->intervals, i)) >= 0) /* only decrease where sc exists */ |
- { |
- if(sc > C) /* the last sc dec */ |
- { |
- SLSH_decSc(lev->intervals, i, C); |
- C = 0; |
- } |
- else /* to little sc in this interval, decrease it to 0 */ |
- { |
- C -= SLSH_sc(lev->intervals, i); |
- SLSH_decSc(lev->intervals, i, SLSH_sc(lev->intervals, i)); |
- } |
- } |
- }/* for all intervals */ |
-} |
- |
-/* the guarantee algorithm for hard aperiodic requests */ |
-static int SLSH_guarantee(SLSH_level_des* lev, HARD_TASK_MODEL* h) |
-{ |
- int total_sc = 0; |
- int temp, i; |
- int dabs = ceil((lev->slot + h->drel)/lev->slot_length); /* absolute deadline of request */ |
- int dabs_interval = SLSH_getInterval(lev->intervals, dabs, lev->last); /* interval where dabs is */ |
- |
- /* check if the sc up until request deadline is >= request wcet */ |
- /* 1. the sc of the current interal */ |
- total_sc = SLSH_sc(lev->intervals, lev->current); |
- |
- /* 2. the sc for all whole intervals between current and the interval |
- with the request deadline */ |
- for(i = (lev->current) + 1; i < dabs_interval; ++i) |
- { |
- if((temp = SLSH_sc(lev->intervals, i)) > 0) |
- total_sc += temp; |
- } |
- |
- /* 3. the min of sc or the execution need in the last interval */ |
- total_sc += min(SLSH_sc(lev->intervals, dabs_interval), |
- dabs - SLSH_intervalStart(lev->intervals, |
- dabs_interval)); |
- |
- if(total_sc >= h->wcet) |
- { /* update the sc in the intervals from back to front */ |
- SLSH_updateSc(lev, h); |
- return 0; |
- } |
- else |
- return -1; |
-} |
- |
-/* check if task model is accepted and store nessecary parameters */ |
-static int SLSH_public_create(LEVEL l, PID p, TASK_MODEL *m) |
-{ |
- SLSH_level_des *lev = (SLSH_level_des *)(level_table[l]); |
- STATIC_TASK_MODEL* s; |
- HARD_TASK_MODEL* h; |
- SOFT_TASK_MODEL* u; |
- |
- |
- /* Check the models */ |
- switch(m->pclass) |
- { |
- case STATIC_PCLASS: /* offline scheduled tasks */ |
- break; |
- case HARD_PCLASS: /* hard aperiodic tasks */ |
- h = (HARD_TASK_MODEL *) m; |
- if (h->drel == 0 || h->wcet == 0) /* must be set */ |
- return -1; |
- break; |
- case SOFT_PCLASS: /* soft aperiodic tasks */ |
- u = (SOFT_TASK_MODEL *) m; |
- if(u->wcet == 0) /* must be set */ |
- return -1; |
- break; |
- default: |
- return -1; |
- } |
- |
- |
- /* if the SLSH_task_create is called, then the pclass must be a |
- valid pclass. Slot-shifting accepts STATIC_TASK, HARD_TASK |
- and SOFT_TASK models with some restrictions */ |
- |
- /* est, dl and wcet is saved in slotlengths */ |
- switch(m->pclass) |
- { |
- case STATIC_PCLASS: /* offline scheduled tasks */ |
- s = (STATIC_TASK_MODEL *) m; |
- lev->tasks[p].est = ceil(s->est/lev->slot_length); |
- lev->tasks[p].dabs = ceil(s->dabs/lev->slot_length); |
- lev->tasks[p].interval = s->interval; |
- proc_table[p].avail_time = s->wcet; |
- proc_table[p].wcet = s->wcet; |
- break; |
- case HARD_PCLASS: /* hard aperiodic tasks */ |
- h = (HARD_TASK_MODEL *) m; |
- if(SLSH_guarantee(lev, h) == 0) |
- { |
- /* convert drel to dabs */ |
- lev->tasks[p].dabs = ceil((lev->slot + h->drel)/lev->slot_length); |
- proc_table[p].avail_time = h->wcet; |
- proc_table[p].wcet = h->wcet; |
- } |
- else /* task not guaranteed */ |
- return -1; |
- break; |
- case SOFT_PCLASS: |
- u = (SOFT_TASK_MODEL *) m; |
- proc_table[p].avail_time = u->wcet; |
- proc_table[p].wcet = u->wcet; |
- iq_insertlast(p, &lev->unspecified); /* respect FIFO order */ |
- break; |
- default: /* a task model not supported */ |
- return -1; |
- } |
- /* enable wcet check in the kernel */ |
- proc_table[p].control |= CONTROL_CAP; |
- |
- return 0; |
-} |
- |
-/************* The slot end event handler *************/ |
-static void SLSH_slot_end(void* p) |
-{ |
- SLSH_level_des* lev = (SLSH_level_des *) p; |
- PID pid; |
- int i; |
- |
- /* increase slot "time" by 1 */ |
- if(lev->slot < lev->LCM) |
- { |
- lev->slot++; |
- /* check if new statics are ready */ |
- for(i = 0; lev->tasks[i].interval != -1; ++i) |
- { |
- if(lev->tasks[i].est <= lev->slot && proc_table[i].status == SLSH_WAIT) |
- proc_table[i].status = SLSH_READY; |
- } |
- |
- /* check if current (interval) needs updating */ |
- if(lev->current < SLSH_getInterval(lev->intervals, lev->slot, lev->last)) |
- lev->current++; |
- |
- } |
- else /* restart from the beginning of the offline schedule */ |
- { |
- lev->slot = 0; |
- |
- while((pid = iq_getfirst(&lev->idle_statics)) != NIL) |
- { |
- if(lev->tasks[pid].est <= lev->slot) |
- proc_table[pid].status = SLSH_READY; |
- else |
- proc_table[pid].status = SLSH_WAIT; |
- } |
- } |
- |
- /* call for a rescheduling, reset event flag and increase slot by 1 */ |
- lev->slot_event = -1; |
- kern_printf("*"); |
- event_need_reschedule(); |
-} |
- |
-/* when a task becomes executing (EXE status) */ |
-static void SLSH_public_dispatch(LEVEL l, PID pid, int nostop) |
-{ |
- SLSH_level_des *lev = (SLSH_level_des *)(level_table[l]); |
- struct timespec t; |
- |
- /* the task state is set EXE by the scheduler() |
- we extract the task from the unspecified queue. |
- NB: we can't assume that p is the first task in the queue!!! */ |
- |
- if(proc_table[pid].pclass == SOFT_PCLASS) |
- iq_extract(pid, &lev->unspecified); |
- |
- /* also start the timer for one slot length */ |
- lev->slot_event = kern_event_post(&TIME2TIMESPEC(lev->slot_length, t), |
- SLSH_slot_end, (void*) lev); |
-} |
- |
-/* called when task is moved from EXE status */ |
-static void SLSH_public_epilogue(LEVEL l, PID pid) |
-{ |
- SLSH_level_des *lev = (SLSH_level_des *)(level_table[l]); |
- |
- /* check if the wcet is finished... */ |
- if (proc_table[pid].avail_time <= 0) |
- { |
- /* if it is, raise a XWCET_VIOLATION exception */ |
- kern_raise(XWCET_VIOLATION, pid); |
- proc_table[pid].status = SLSH_WCET_VIOLATED; |
- } |
- else /* the end of a slot. the task returns into the ready queue... */ |
- { |
- if(proc_table[pid].pclass == SOFT_PCLASS) |
- iq_insertfirst(pid,&lev->unspecified); |
- |
- proc_table[pid].status = SLSH_READY; |
- } |
-} |
- |
-/* when task go from SLEEP to SLSH_READY or SLSH_WAIT */ |
-static void SLSH_public_activate(LEVEL l, PID pid) |
-{ |
- SLSH_level_des *lev = (SLSH_level_des *)(level_table[l]); |
- WORD type = proc_table[pid].pclass; |
- |
- /* Test if we are trying to activate a non sleeping task */ |
- /* Ignore this; the task is already active */ |
- if (proc_table[pid].status != SLEEP && proc_table[pid].status != SLSH_WCET_VIOLATED) |
- return; |
- |
- /* make task ready or waiting, dependong on slot (the time) for static tasks only*/ |
- if(type == STATIC_PCLASS && lev->tasks[pid].est <= lev->slot) |
- proc_table[pid].status = SLSH_READY; |
- else |
- proc_table[pid].status = SLSH_WAIT; |
- |
- if(type == HARD_PCLASS) |
- proc_table[pid].status = SLSH_READY; |
- |
- /* insert unspecified tasks in QQUEUE and make it ready */ |
- if(type == SOFT_PCLASS) |
- { |
- iq_insertlast(pid ,&lev->unspecified); |
- proc_table[pid].status = SLSH_READY; |
- } |
-} |
- |
-/* when a task i returned to module from a semaphore, mutex ... */ |
-static void SLSH_public_unblock(LEVEL l, PID pid) |
-{ |
- SLSH_level_des *lev = (SLSH_level_des *)(level_table[l]); |
- |
- /* change staus of task */ |
- proc_table[pid].status = SLSH_READY; |
- |
- if(proc_table[pid].pclass == SOFT_PCLASS) |
- iq_insertfirst(pid ,&lev->unspecified); |
-} |
- |
-/* when a semaphore, mutex ... taskes a task from module */ |
-static void SLSH_public_block(LEVEL l, PID pid) |
-{ |
- /* Extract the running task from the level |
- . we have already extract it from the ready queue at the dispatch time. |
- . the capacity event have to be removed by the generic kernel |
- . the wcet don't need modification... |
- . the state of the task is set by the calling function |
- . the deadline must remain... |
- |
- So, we do nothing!!! |
- */ |
-} |
- |
-/* the task has finihed its wcet, kill task (dont kill static tasks) */ |
-static void SLSH_public_end(LEVEL l, PID pid) |
-{ |
- SLSH_level_des *lev = (SLSH_level_des *)(level_table[l]); |
- |
- if(proc_table[pid].pclass == SOFT_PCLASS) |
- { |
- if (proc_table[pid].status == SLSH_READY) |
- iq_extract(pid, &lev->unspecified); |
- } |
- else if(proc_table[pid].pclass == HARD_PCLASS) |
- { |
- if (proc_table[pid].status == SLSH_READY) |
- lev->tasks[pid].dabs = 0; |
- |
- } |
- /* static tasks: put them in idle QUEUE, reset status and avail_time */ |
- else if(proc_table[pid].pclass == STATIC_PCLASS) |
- { |
- proc_table[pid].avail_time = proc_table[pid].wcet; |
- proc_table[pid].status = SLSH_IDLE; |
- iq_priority_insert(pid, &lev->idle_statics); |
- } |
- |
- proc_table[pid].status = FREE; |
-} |
- |
-/* called when a task should sleep but not execute for awhile, mabe a mode change */ |
-//static void SLSH_task_sleep(LEVEL l, PID pid) |
-//{ |
-// |
-// /* the task has terminated his job before it consume the wcet. All OK! */ |
-// proc_table[pid].status = SLEEP; |
-// |
-// /* we reset the capacity counters... only for static tasks */ |
-// if (proc_table[pid].pclass == STATIC_PCLASS) |
-// proc_table[pid].avail_time = proc_table[pid].wcet; |
-// |
-//} |
- |
- |
-/** Guest Functions, slot shifing accepts no guests, so all generates exceptions **/ |
- |
-/******* Registration functions *******/ |
- |
-/*+ Registration function: */ |
-LEVEL SLSH_register_level() |
-{ |
- LEVEL l; /* the level that we register */ |
- SLSH_level_des *lev; /* for readableness only */ |
- PID i; /* a counter */ |
- |
- kern_printf("SLSH_register_level\n"); |
- |
- /* request an entry in the level_table */ |
- l = level_alloc_descriptor(sizeof(SLSH_level_des)); |
- |
- lev = (SLSH_level_des *)level_table[l]; |
- |
- printk(" lev=%d\n",(int)lev); |
- |
- /* fill the standard descriptor */ |
- lev->l.public_scheduler = SLSH_public_scheduler; |
- lev->l.public_guarantee = SLSH_public_guarantee; |
- lev->l.public_create = SLSH_public_create; |
- lev->l.public_end = SLSH_public_end; |
- lev->l.public_dispatch = SLSH_public_dispatch; |
- lev->l.public_epilogue = SLSH_public_epilogue; |
- lev->l.public_activate = SLSH_public_activate; |
- lev->l.public_unblock = SLSH_public_unblock; |
- lev->l.public_block = SLSH_public_block; |
- |
- /* fill the SLSH descriptor part */ |
- for(i = 0; i < MAX_PROC; i++) |
- { |
- lev->tasks[i].est = -1; |
- lev->tasks[i].dabs = 0; |
- lev->tasks[i].interval = -1; |
- } |
- |
- for(i = 0; i < MAX_INTERVALS; i++) |
- { |
- lev->intervals[i].start = -1; |
- lev->intervals[i].end = -1; |
- lev->intervals[i].length = 0; |
- lev->intervals[i].maxt = 0; |
- lev->intervals[i].sc = 0; |
- } |
- |
- lev->current = 0; |
- lev->last = NIL; |
- lev->slot = 0; |
- lev->slot_length = 0; |
- lev->slot_event = -1; |
- |
- return l; |
-} |
- |
- |
-void SLSH_set_interval(LEVEL l, int start, int end, int maxt) |
-{ |
- SLSH_level_des* lev = (SLSH_level_des *)(level_table[l]); |
- static int i = -1; |
- |
- i++; |
- lev->intervals[i].start = start; |
- lev->intervals[i].end = end; |
- lev->intervals[i].length = end - start; |
- lev->intervals[i].maxt = maxt; |
- lev->intervals[i].sc = lev->intervals[i].length - maxt; |
- |
- lev->last = i; |
-} |
- |
-void SLSH_set_variables(LEVEL l, TIME length) |
-{ |
- SLSH_level_des* lev = (SLSH_level_des *)(level_table[l]); |
- |
- lev->slot_length = length; |
-} |
Index: tags/rel_1_22/slsh/readme.txt |
=================================================================== |
--- tags/rel_1_22/slsh/readme.txt (revision 1310) |
+++ tags/rel_1_22/slsh/readme.txt (nonexistent) |
@@ -1,6 +0,0 @@ |
-This Example has been made by Tomas Lenvall. |
- |
-There is not a lot of documentation available, so if you have problems please |
-send an e-mail to Tomas ( mailto:tlv@mdh.se ) |
- |
-Paolo |
Index: tags/rel_1_22/slsh/makefile |
=================================================================== |
--- tags/rel_1_22/slsh/makefile (revision 1310) |
+++ tags/rel_1_22/slsh/makefile (nonexistent) |
@@ -1,16 +0,0 @@ |
-# |
-# |
-# |
- |
-ifndef BASE |
-BASE=../.. |
-endif |
- |
-include $(BASE)/config/config.mk |
- |
-PROGS=slshtest |
- |
-include $(BASE)/config/example.mk |
- |
-slshtest: |
- make -f $(SUBMAKE) APP=slshtest INIT= OTHEROBJS="slshinit.o slsh.o" OTHERINCL= SHARKOPT=__OLDCHAR__ |
Index: tags/rel_1_22/slsh/slshinit.c |
=================================================================== |
--- tags/rel_1_22/slsh/slshinit.c (revision 1310) |
+++ tags/rel_1_22/slsh/slshinit.c (nonexistent) |
@@ -1,117 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: slshinit.c,v 1.1.1.1 2002-09-02 09:37:41 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1.1.1 $ |
- Last update: $Date: 2002-09-02 09:37:41 $ |
- ------------ |
- |
- System initialization file |
- |
- The tick is set to TICK ms. |
- |
- This file contains the 2 functions needed to initialize the system. |
- |
- These functions register the following levels: |
- |
- a Slot Shifting level |
- a Dummy level |
- |
- It can accept these task models: |
- |
- STATIC_TASK_MODEL |
- HARD_TASK_MODEL(aperiodic) |
- SOFT_TASK_MODEL |
- |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
- |
- |
-#include "kernel/kern.h" |
-#include "slsh.h" |
-#include "modules/rr2.h" |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "drivers/keyb.h" |
-#include "modules/dummy.h" |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 300 |
- |
-/* define RR tick in us*/ |
-#define RRTICK 10000 |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- SLSH_register_level(); |
- RR2_register_level(RRTICK, RR2_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- |
- return TICK; |
-} |
- |
-NRT_TASK_MODEL nrt; |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- KEYB_PARMS k = BASE_KEYB; |
- |
- nrt_task_default_model(nrt); |
- keyb_def_task(k,&nrt); |
- |
- |
- |
- HARTPORT_init(); |
- |
- KEYB_init(NULL); |
- |
- __call_main__(mb); |
- |
- return 0; |
-} |
- |
- |
Index: tags/rel_1_22/slsh/slsh.h |
=================================================================== |
--- tags/rel_1_22/slsh/slsh.h (revision 1310) |
+++ tags/rel_1_22/slsh/slsh.h (nonexistent) |
@@ -1,204 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * Massimiliano Giorgi <massy@gandalf.sssup.it> |
- * Luca Abeni <luca@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
- |
-/** |
- ------------ |
- CVS : $Id: slsh.h,v 1.2 2003-01-07 17:10:18 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.2 $ |
- Last update: $Date: 2003-01-07 17:10:18 $ |
- ------------ |
- Author: Tomas Lennvall, Date: Feb 2000. |
- |
- This file contains the scheduling module for Slot shifting. |
- |
- Title: |
- Slot Shifting |
- |
- Task Models Accepted: |
- STATIC_TASK_MODEL - Periodic Hard tasks that are scheduled by |
- an off-line scheduler, so that all guarantees regarding precedence, mutex |
- deadline violation is taken care of. The tasks are in an executione schedule, |
- that is the order in when they become ready. They have the following fields: |
- est (earliest start time), wcet and absolute deadline. |
- |
- HARD_TASK_MODEL - Hard Tasks (Hard aperiodic requests) |
- wcet field and drel field must be != 0. They are used to set the wcet |
- and deadline of the tasks. |
- periodicity field must be APERIODIC |
- mit field is ignored. |
- |
- SOFT_TASK_MODEL - Soft Tasks (Unspecified tasks) |
- wcet field must be != 0. periodicity filed must be APERIODIC |
- period and met filed is ignored. |
- |
- Guest Models Accepted: |
- NONE - Slot shifting handles all tasks by itself (at this moment). |
- |
- Description: |
- This module schedules the offline scheduled tasks according to the slot- |
- shifting paradigm, dividing time into slots of a fixed length and assigning |
- tasks to execute in those slots. Slot-shifting also keeps track of the free |
- bandwidth in the schedule by using disjoint intervals and sc (spare capacity). |
- Each interval has a sc nr that represents the free bandwidth in that interval, |
- the sc can be used by hard aperiodic tasks, static tasks from later interval or |
- soft aperiodic tasks. Hard aperiodic tasks are guaranteed an incorporated in |
- the schedule by reduction of sc before they execute. No guarantee is |
- performed on the soft aperiodic tasks, they are run when no other task wants |
- to execute and sc is available. |
- |
- Description: |
- This module implements the Slot shifting algorithm, by Gerhard Fohler. Slot shifting |
- schedules off-line scheduled tasks and also handles hard aperiodic requests by the |
- guarantee alorithm. Slot shifting can also handle soft aperiodic tasks, |
- called unspecified. That is tasks without a deadline. |
- |
- Exceptions raised: |
- These exceptions are pclass-dependent... |
- XDEADLINE_MISS |
- If a task miss his deadline, the exception is raised. |
- |
- XWCET_VIOLATION |
- If a task doesn't end the current cycle before if consume the wcet, |
- an exception is raised, and the task is put in the EDF_WCET_VIOLATED |
- state. To reactivate it, use EDF_task_activate via task_activate or |
- manage directly the EDF data structure. Note that the exception is not |
- handled properly, an XDEADLINE_MISS exeeption will also be raised at |
- the period end... |
- |
- Restrictions & special features: |
- - This level doesn't manage the main task. |
- - At init time we can choose if the level have to activate |
- . the wcet check |
- (If a task require more time than declared, it is stopped and put in |
- the state EDF_WCET_VIOLATED; a XWCET_VIOLATION exception is raised) |
- . the task guarantee algorithm |
- (when all task are created the system will check that the task_set |
- will not use more than the available bandwidth) |
- - The level use the priority and timespec_priority fields. |
- - A function to return the used bandwidth of a level is provided. |
- - The guest tasks don't provide the guest_endcycle function |
- |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
- |
-#ifndef __SLSH_H__ |
-#define __SLSH_H__ |
- |
-#include <ll/ll.h> |
-#include <kernel/config.h> |
-#include <sys/types.h> |
-#include <kernel/types.h> |
- |
-#define STATIC_PCLASS 0x0500 |
- |
-#define SLSH_LEVELNAME "Slot Shifting" |
-#define SLSH_LEVEL_CODE 5 |
-#define SLSH_LEVEL_VERSION 1 |
- |
- |
- |
-/* ----------------------------------------------------------------------- |
- STATIC_TASK_MODEL: offline scheduled Tasks |
- ----------------------------------------------------------------------- */ |
-/* Offline-scheduled tasks are hard periodic tasks that have been |
- scheduled before runtime. All guarantees are made by the off- |
- line scheduler so the tasks are already guaranteed. |
-*/ |
- |
-typedef struct { |
- TASK_MODEL t; |
- TIME est; |
- TIME wcet; |
- TIME dabs; |
- int interval; /* used in slot shifting */ |
-} STATIC_TASK_MODEL; |
- |
-#define static_task_default_model(m) \ |
- task_default_model((m).t,STATIC_PCLASS), \ |
- (m).est = -1, \ |
- (m).dabs = 0, \ |
- (m).wcet = 0, \ |
- (m).interval = -1; |
-#define static_task_def_level(m,l) task_def_level((m).t,l) |
-#define static_task_def_arg(m,a) task_def_arg((m).t,a) |
-#define static_task_def_stack(m,s) task_def_stack((m).t,s) |
-#define static_task_def_group(m,g) task_def_group((m).t,g) |
-#define static_task_def_usemath(m) task_def_usemath((m).t) |
-#define static_task_def_system(m) task_def_system((m).t) |
-#define static_task_def_nokill(m) task_def_nokill((m).t) |
-#define static_task_def_ctrl_jet(m) task_def_ctrl_jet((m).t) |
-#define static_task_def_est(m,p) (m).est = (p) |
-#define static_task_def_dabs(m,d) (m).dabs = (d) |
-#define static_task_def_wcet(m,w) (m).wcet = (w) |
-#define static_task_def_interval(m,i) (m).interval = (i) |
-#define static_task_def_trace(m) task_def_trace((m).t) |
-#define static_task_def_notrace(m) task_def_notrace((m).t) |
- |
- |
- |
- |
-/*#define min(a, b) ((a) < (b) ? (a) : (b))*/ |
- |
-#define TIME2TIMESPEC(T, TS) \ |
-( \ |
- ((TS).tv_sec = ((T)/1000000)), \ |
- ((TS).tv_nsec = (((T)%1000000) * 1000)), \ |
- (TS) \ |
-) |
- |
-/* define the interval struct */ |
-typedef struct { |
- int start; /* start of interval */ |
- int end; /* end of interval */ |
- int length; /* Length of interval */ |
- int maxt; /* maximum execution time in interval */ |
- int sc; /* spare capacity in interval */ |
-} SLSH_interval; |
- |
-/*+ Registration function: */ |
-LEVEL SLSH_register_level(); |
- |
-void SLSH_set_interval(LEVEL l, int start, int end, int maxt); |
-void SLSH_set_variables(LEVEL l, TIME length); |
- |
-#endif |
- |
Index: tags/rel_1_22/base/semdemo.c |
=================================================================== |
--- tags/rel_1_22/base/semdemo.c (revision 1310) |
+++ tags/rel_1_22/base/semdemo.c (nonexistent) |
@@ -1,97 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * |
- * CVS : $Id: semdemo.c,v 1.1 2002-11-11 08:22:46 pj Exp $ |
- |
- This is a really simple semaphore demo. |
- |
-*/ |
- |
-#include "kernel/kern.h" |
- |
-#include "semaphore.h" |
- |
-sem_t s; |
- |
-void *goofy(void *a) |
-{ |
- struct timespec t; |
- char *n = proc_table[exec_shadow].name; |
- |
- cprintf("Task %s: Locking semaphore...\n", n); |
- |
- sem_wait(&s); |
- cprintf("Task %s: Semaphore locked...\n", n); |
- |
- do { |
- sys_gettime(&t); |
- } while (t.tv_sec < (int)a); |
- |
- cprintf("Task %s: Unlocking semaphore...\n", n); |
- |
- sem_post(&s); |
- |
- cprintf("Task %s: Semaphore unlocked...\n", n); |
- |
- return 0; |
-} |
- |
-int main(int argc, char **argv) |
-{ |
- NRT_TASK_MODEL m; |
- PID p2,p3; |
- |
- nrt_task_default_model(m); |
- nrt_task_def_group(m,1); |
- |
- nrt_task_def_arg(m,(void *)1); |
- p2 = task_create("goofy1", goofy, &m, NULL); |
- if (p2 == NIL) |
- { cprintf("Can't create goofy1 task...\n"); return 1; } |
- |
- nrt_task_def_arg(m,(void *)2); |
- p3 = task_create("goofy2", goofy, &m, NULL); |
- if (p3 == NIL) |
- { cprintf("Can't create goofy2 task...\n"); return 1; } |
- |
- cprintf("Initializing semaphore...\n"); |
- |
- sem_init(&s,0,1); |
- |
- group_activate(1); |
- |
- return 0; |
-} |
Index: tags/rel_1_22/base/time.c |
=================================================================== |
--- tags/rel_1_22/base/time.c (revision 1310) |
+++ tags/rel_1_22/base/time.c (nonexistent) |
@@ -1,69 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * |
- * CVS : $Id: time.c,v 1.1 2002-10-28 08:13:37 pj Exp $ |
- * |
- * Timer correctness test |
- */ |
- |
-#include "kernel/kern.h" |
- |
-#define NT 10 |
- |
-int main(int argc, char **argv) |
-{ |
- struct timespec t[NT]; |
- int i; |
- |
- cprintf("Timer correctness test (1 second).\n"); |
- |
- for (i=0; i<NT; i++) NULL_TIMESPEC(&t[i]); |
- |
- do { |
- for (i=0; i<NT-1; i++) t[i+1] = t[i]; |
- |
- sys_gettime(&t[0]); |
- |
- if (TIMESPEC_A_LT_B(&t[0],&t[1])) { |
- for (i=0; i<NT; i++) |
- cprintf("%d %ld\n",i, t[i].tv_nsec); |
- sys_end(); |
- } |
- } while (t[0].tv_sec < 1); |
- |
- return 0; |
-} |
- |
Index: tags/rel_1_22/base/intsem.c |
=================================================================== |
--- tags/rel_1_22/base/intsem.c (revision 1310) |
+++ tags/rel_1_22/base/intsem.c (nonexistent) |
@@ -1,101 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Giorgio Buttazzo, Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * |
- * CVS : $Id: intsem.c,v 1.1 2002-11-11 08:22:45 pj Exp $ |
- |
- this test is a simple main() function with one other task. |
- |
- This test verify the correctness of the internal_sem functions. |
- |
-*/ |
- |
-#include "kernel/kern.h" |
- |
-#include <kernel/int_sem.h> |
- |
-internal_sem_t s; |
- |
-TASK pippo(void *a) |
-{ |
- int i=0; |
- struct timespec t; |
- |
- do { |
- sys_gettime(&t); |
- |
- if (i==0 && t.tv_sec == (int)a) { |
- i = 1; |
- cprintf("before internal_sem_wait %d\n",(int)a); |
- internal_sem_wait(&s); |
- cprintf("after internal_sem_wait %d\n",(int)a); |
- } |
- |
- if (i==1 && t.tv_sec == 2+(int)a) { |
- i = 2; |
- cprintf("before internal_sem_post %d\n",(int)a); |
- internal_sem_post(&s); |
- cprintf("after internal_sem_post %d\n",(int)a); |
- return 0; |
- } |
- |
- |
- } while (1); |
-} |
- |
-int main(int argc, char **argv) |
-{ |
- NRT_TASK_MODEL m; |
- PID p2,p3; |
- |
- nrt_task_default_model(m); |
- nrt_task_def_group(m,1); |
- |
- nrt_task_def_arg(m,(void *)1); |
- p2 = task_create("pippo1", pippo, &m, NULL); |
- if (p2 == NIL) |
- { cprintf("Can't create pippo1 task...\n"); return 1; } |
- |
- nrt_task_def_arg(m,(void *)2); |
- p3 = task_create("pippo2", pippo, &m, NULL); |
- if (p3 == NIL) |
- { cprintf("Can't create pippo2 task...\n"); return 1; } |
- |
- internal_sem_init(&s,1); |
- |
- group_activate(1); |
- |
- return 0; |
-} |
Index: tags/rel_1_22/base/isched.c |
=================================================================== |
--- tags/rel_1_22/base/isched.c (revision 1310) |
+++ tags/rel_1_22/base/isched.c (nonexistent) |
@@ -1,207 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: isched.c,v 1.1 2002-11-11 08:22:45 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1 $ |
- Last update: $Date: 2002-11-11 08:22:45 $ |
- ------------ |
- |
- System initialization file |
- |
- The tick is set to TICK ms. |
- |
- This file contains the 2 functions needed to initialize the system. |
- |
- These functions register the following levels: |
- |
- an EDF (Earliest Deadline First) level |
- a RR (Round Robin) level |
- a CBS (Costant Bandwidth Server) level |
- a Dummy level |
- |
- It can accept these task models: |
- |
- HARD_TASK_MODEL (wcet+mit) at level 0 |
- NRT_TASK_MODEL at level 1 |
- SOFT_TASK_MODEL (met, period) at level 2 |
- |
- This file is similar to the configuration of Hartik 3.3.1 |
- |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
- |
- |
-#include "kernel/kern.h" |
- |
-#include "modules/edf.h" |
-#include "modules/rm.h" |
- |
-#include "modules/cbs.h" |
-#include "modules/tbs.h" |
-#include "modules/ps.h" |
-#include "modules/ds.h" |
- |
-#include "modules/rr.h" |
-#include "modules/rr2.h" |
- |
-#include "modules/dummy.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
- |
-#include "drivers/keyb.h" |
- |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 300 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 10000 |
- |
- |
-/* the mouse task use 160 us approx on my Celeron 366 */ |
-#define NUM 2000 |
-#define DEN 64000 |
-//#define DEN 8000 |
- |
-//#undef XXX |
-//#define XXX |
- |
-int argc; |
-char *argv[100]; |
- |
-extern char *title; |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- int conf; |
- |
- __compute_args__(mb,&argc, argv); |
- |
- if (argc < 2) |
- conf = '0'; // default |
- else |
- conf = *argv[1]; |
- |
- switch (conf) { |
- case '1': |
- RM_register_level(0); // NO GUARANTEE!!! |
- PS_register_level(PS_ENABLE_BACKGROUND, 0, NUM, DEN); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- title = "1 - RM + PS ( bkg, U=1/16) + RR, no check Ulub < 0.69"; |
- break; |
- |
- case '2': |
- RM_register_level(0); // NO GUARANTEE!!! |
- PS_register_level(0, 0, NUM, DEN); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- title = "2 - RM + PS (nobkg, U=1/16) + RR, no check Ulub < 0.69\n"; |
- break; |
- |
- case '3': |
- EDF_register_level(2); |
- PS_register_level(PS_ENABLE_ALL_EDF, 0, NUM, DEN); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- title = "3 - EDF + PS ( bkg, U=1/16) + RR"; |
- break; |
- |
- case '4': |
- EDF_register_level(2); |
- PS_register_level(PS_ENABLE_GUARANTEE_EDF, 0, NUM, DEN); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- title = "4 - EDF + PS (nobkg, U=1/16) + RR"; |
- break; |
- |
- case '5': |
- EDF_register_level(2); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- TBS_register_level(TBS_ENABLE_ALL, 0, NUM, DEN); |
- title = "5 - EDF + TBS( U=1/16) + RR"; |
- break; |
- |
- case '6': |
- RM_register_level(0); // NO GUARANTEE!!! |
- DS_register_level(DS_ENABLE_BACKGROUND, 0, NUM, DEN); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- title = "6 - RM + DS ( bkg, U=1/16) + RR, no check Ulub < 0.69"; |
- break; |
- |
- case '7': |
- RM_register_level(0); // NO GUARANTEE!!! |
- DS_register_level(0, 0, NUM, DEN); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- title = "7 - RM + DS (nobkg, U=1/16) + RR, no check Ulub < 0.69\n"; |
- break; |
- |
- default: // '0' |
- EDF_register_level(2); |
- RR2_register_level(RRTICK, RR2_MAIN_YES, mb); |
- CBS_register_level(CBS_ENABLE_ALL, 0); |
- title = "0 - EDF + CBS + RR"; |
- } |
- |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- |
- CABS_register_module(); |
- |
- return TICK; |
-} |
- |
-int main(int argc, char **argv); |
- |
-TASK __init__(void *arg) |
-{ |
-// struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- HARTPORT_init(); |
- |
- KEYB_init(NULL); |
- |
- main(argc,argv); |
- |
- return (void *)0; |
-} |
- |
Index: tags/rel_1_22/base/mdemo.c |
=================================================================== |
--- tags/rel_1_22/base/mdemo.c (revision 1310) |
+++ tags/rel_1_22/base/mdemo.c (nonexistent) |
@@ -1,200 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * |
- * CVS : $Id: mdemo.c,v 1.1 2002-11-11 08:22:46 pj Exp $ |
- |
- This test verify the correctness of the NOP module. It works with the |
- PI, PC, SRP module, too. |
- |
- The test uses one mutex |
- |
- the main task (NRT) creates three tasks. |
- |
- J1 with PC priority 0 |
- starts at t=0.5 sec and lock m0 |
- |
- J2 with PC priority 1 |
- starts at t=1 sec and doesn't lock any mutex |
- |
- J3 with PC priority 2 |
- it starts and locks m0 |
- at t=2 sec it unlocks m1 |
- |
- |
- The example is similar to the scheduling diagram shown at p. 188 of the |
- book "Sistemi in tempo Reale", by Giorgio Buttazzo, Pitagora Editrice |
- |
-*/ |
- |
-#include "kernel/kern.h" |
-#include "drivers/keyb.h" |
-#include "modules/srp.h" |
- |
-mutex_t m0; |
- |
- |
-void startJ(void *a) |
-{ |
- task_activate((PID)a); |
-} |
- |
-TASK j1() |
-{ |
- cprintf("J1: before locking m0\n"); |
- mutex_lock(&m0); |
- cprintf("J1: locked m0\n"); |
- mutex_unlock(&m0); |
- cprintf("J1: unlocked m0, end task\n"); |
- return 0; |
-} |
- |
- |
-TASK j2() |
-{ |
- cprintf("J2: waiting t=1.5 sec\n"); |
- |
- while (sys_gettime(NULL) < 1500000); |
- |
- cprintf("J2: end task\n"); |
- return 0; |
-} |
- |
- |
-TASK j3() |
-{ |
- cprintf("J3: before locking m0\n"); |
- mutex_lock(&m0); |
- cprintf("J3: locked m0, waiting to t=2 sec\n"); |
- |
- while (sys_gettime(NULL) < 2000000); |
- |
- cprintf("J3: t = 1 sec reached, unlocking m0\n"); |
- mutex_unlock(&m0); |
- cprintf("J3: unlocked m0, end task\n"); |
- return 0; |
-} |
- |
-void fine(KEY_EVT *e) |
-{ |
- sys_end(); |
-} |
- |
- |
-int main(int argc, char **argv) |
-{ |
- struct timespec t; |
- |
- HARD_TASK_MODEL m; |
- PID p0,p1,p2; |
- |
- PC_mutexattr_t a; |
- PI_mutexattr_t a2; |
- NOP_mutexattr_t a3; |
- SRP_mutexattr_t a4; |
- NPP_mutexattr_t a5; |
- |
- PC_RES_MODEL r; |
- SRP_RES_MODEL srp; |
- |
- KEY_EVT emerg; |
- |
- //keyb_set_map(itaMap); |
- emerg.ascii = 'x'; |
- emerg.scan = KEY_X; |
- emerg.flag = ALTL_BIT; |
- keyb_hook(emerg,fine); |
- |
- /* --------------------------------------------------------------------- |
- Mutex creation |
- --------------------------------------------------------------------- */ |
- |
- PC_mutexattr_default(a,0); |
- PI_mutexattr_default(a2); |
- NOP_mutexattr_default(a3); |
- SRP_mutexattr_default(a4); |
- NPP_mutexattr_default(a5); |
- mutex_init(&m0,&a4); |
- |
- /* --------------------------------------------------------------------- |
- Task creation |
- --------------------------------------------------------------------- */ |
- |
- hard_task_default_model(m); |
- hard_task_def_wcet(m,20000); |
- hard_task_def_mit(m,10000000); |
- PC_res_default_model(r,0); |
- SRP_res_default_model(srp,3); |
- p0 = task_createn("J1", j1, (TASK_MODEL *)&m, &r, &srp, SRP_usemutex(&m0), NULL); |
- if (p0 == NIL) |
- { cprintf("Can't create J1 task...\n"); return 1; } |
- |
- hard_task_def_wcet(m,1600000); |
- hard_task_def_mit(m,21000000); |
- PC_res_default_model(r,1); |
- SRP_res_default_model(srp,2); |
- p1 = task_createn("J2", j2, (TASK_MODEL *)&m, &r, &srp, NULL); |
- if (p1 == NIL) |
- { cprintf("Can't create J2 task...\n"); return 1; } |
- |
- hard_task_def_wcet(m,3000000); |
- hard_task_def_mit(m,100000000); |
- PC_res_default_model(r,2); |
- SRP_res_default_model(srp,1); |
- p2 = task_createn("J3", j3, (TASK_MODEL *)&m, &r, &srp, SRP_usemutex(&m0), NULL); |
- if (p2 == NIL) |
- { cprintf("Can't create J3 task...\n"); return 1; } |
- |
- |
- /* --------------------------------------------------------------------- |
- Event post |
- --------------------------------------------------------------------- */ |
- |
- t.tv_sec = 0; |
- t.tv_nsec = 500000000; |
- |
- kern_cli(); |
- kern_event_post(&t,startJ,(void *)p0); |
- |
- t.tv_sec = 1; |
- kern_event_post(&t,startJ,(void *)p1); |
- kern_sti(); |
- |
- task_activate(p2); |
- |
- cprintf("END main\n"); |
- |
- return 0; |
-} |
Index: tags/rel_1_22/base/hello.c |
=================================================================== |
--- tags/rel_1_22/base/hello.c (revision 1310) |
+++ tags/rel_1_22/base/hello.c (nonexistent) |
@@ -1,53 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- */ |
- |
-/* |
- CVS : $Id: hello.c,v 1.1 2002-10-28 08:13:37 pj Exp $ |
- |
- hello.c: |
- |
- This test is a simple hello world function. |
- |
-*/ |
- |
-#include "kernel/kern.h" |
- |
-int main(int argc, char **argv) |
-{ |
- cprintf("Hello, world!\n"); |
- |
- return 0; |
-} |
Index: tags/rel_1_22/base/initfile.c |
=================================================================== |
--- tags/rel_1_22/base/initfile.c (revision 1310) |
+++ tags/rel_1_22/base/initfile.c (nonexistent) |
@@ -1,120 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- ------------ |
- CVS : $Id: initfile.c,v 1.1.1.1 2002-09-02 09:37:41 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1.1.1 $ |
- Last update: $Date: 2002-09-02 09:37:41 $ |
- ------------ |
- |
- System initialization file |
- |
- This file contains the 2 functions needed to initialize the system. |
- |
- These functions register the following levels: |
- |
- an EDF (Earliest Deadline First) level |
- a RR (Round Robin) level |
- a CBS (Costant Bandwidth Server) level |
- a Dummy level |
- |
- It can accept these task models: |
- |
- HARD_TASK_MODEL (wcet+mit) at level 0 |
- SOFT_TASK_MODEL (met, period) at level 1 |
- NRT_TASK_MODEL at level 2 |
- |
- This file is similar to the configuration of kernel/init/hartik3.c |
- |
- TICK is set to 0 (one-shot timer is used) |
-*/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/cbs.h" |
-#include "modules/rr.h" |
-#include "modules/dummy.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
- |
-#include "drivers/keyb.h" |
- |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 0 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 10000 |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- EDF_register_level(EDF_ENABLE_ALL); |
- CBS_register_level(CBS_ENABLE_ALL, 0); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- |
- CABS_register_module(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- KEYB_PARMS kparms = BASE_KEYB; |
- |
- HARTPORT_init(); |
- |
- keyb_def_ctrlC(kparms, NULL); |
- keyb_def_map(kparms,itaMap); |
- KEYB_init(&kparms); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
Index: tags/rel_1_22/base/pcdemo.c |
=================================================================== |
--- tags/rel_1_22/base/pcdemo.c (revision 1310) |
+++ tags/rel_1_22/base/pcdemo.c (nonexistent) |
@@ -1,214 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * |
- * CVS : $Id: pcdemo.c,v 1.2 2003-01-07 17:10:15 pj Exp $ |
- |
- This test verify the correctness of the PC module. |
- |
- The test uses 3 mutexes |
- m0 with ceiling 0 |
- m1 with ceiling 0 |
- m2 with ceiling 1 |
- |
- the main task (NRT) creates three tasks. |
- |
- J0 with PC priority 0 |
- starts at t=1.5 sec and lock m0, unlock m0, then lock and unlock m1 |
- |
- J1 with PC priority 1 |
- starts at t=0.5 sec and try to lock m2 |
- |
- J2 with PC priority 2 |
- it starts and locks m2 |
- at t=1 sec it locks m1 |
- at t=1.5 sec it unlocks m1 |
- |
- |
- The example is similar to the scheduling diagram shown at p. 197 of the |
- book "Sistemi in tempo Reale", by Giorgio Buttazzo, Pitagora Editrice |
- |
-*/ |
- |
-#include "kernel/kern.h" |
-#include "drivers/keyb.h" |
- |
-mutex_t m0,m1,m2; |
- |
- |
-void startJ(void *a) |
-{ |
- task_activate((PID)a); |
-} |
- |
-TASK j0() |
-{ |
- cprintf("J0: before locking m0\n"); |
- mutex_lock(&m0); |
- cprintf("J0: locked m0\n"); |
- mutex_unlock(&m0); |
- cprintf("J0: unlocked m0, locking m1\n"); |
- |
- mutex_lock(&m1); |
- cprintf("J0: locked m1\n"); |
- mutex_unlock(&m1); |
- cprintf("J0: unlocked m1, end task\n"); |
- return 0; |
-} |
- |
- |
-TASK j1() |
-{ |
- cprintf("J1: before locking m2\n"); |
- mutex_lock(&m2); |
- cprintf("J1: locked m2\n"); |
- mutex_unlock(&m2); |
- cprintf("J1: unlocked m2, end task\n"); |
- return 0; |
-} |
- |
- |
-TASK j2() |
-{ |
- cprintf("J2: before locking m2\n"); |
- mutex_lock(&m2); |
- cprintf("J2: locked m2, waiting to t=1 sec\n"); |
- |
- while (sys_gettime(NULL) < 1000000); |
- |
- cprintf("J2: t = 1 sec reached\n"); |
- mutex_lock(&m1); |
- cprintf("J2: locked m1, waiting to t=2 sec\n"); |
- |
- while (sys_gettime(NULL) < 2000000); |
- |
- cprintf("J2: t = 2 sec reached\n"); |
- mutex_unlock(&m1); |
- cprintf("J2: unlocked m1\n"); |
- |
- mutex_unlock(&m2); |
- cprintf("J2: unlocked m2, end task\n"); |
- return 0; |
-} |
- |
-void fine(KEY_EVT *e) |
-{ |
- sys_end(); |
-} |
- |
- |
-int main(int argc, char **argv) |
-{ |
- struct timespec t; |
- |
- HARD_TASK_MODEL m; |
- PID p0,p1,p2; |
- |
- PC_mutexattr_t a; |
- PI_mutexattr_t a2; |
- PC_RES_MODEL r; |
- |
- KEY_EVT emerg; |
- |
- clear(); |
- |
- cprintf("Priority Ceiling demo. Press Alt-X to exit the demo\n"); |
- |
- //keyb_set_map(itaMap); |
- emerg.ascii = 'x'; |
- emerg.scan = KEY_X; |
- emerg.flag = ALTL_BIT; |
- keyb_hook(emerg,fine); |
- |
- /* --------------------------------------------------------------------- |
- Task creation |
- --------------------------------------------------------------------- */ |
- |
- hard_task_default_model(m); |
- hard_task_def_mit(m, 1000000); |
- hard_task_def_wcet(m, 20000); |
- PC_res_default_model(r,0); |
- p0 = task_create("J0", j0, &m, &r); |
- if (p0 == NIL) |
- { cprintf("Can't create J0 task...\n"); return 1; } |
- |
- hard_task_default_model(m); |
- hard_task_def_mit(m, 2100000); |
- hard_task_def_wcet(m, 20000); |
- PC_res_default_model(r,1); |
- p1 = task_create("J1", j1, &m, &r); |
- if (p1 == NIL) |
- { cprintf("Can't create J1 task...\n"); return 1; } |
- |
- hard_task_default_model(m); |
- hard_task_def_mit(m, 10000000); |
- hard_task_def_wcet(m, 3000000); |
- PC_res_default_model(r,2); |
- p2 = task_create("J2", j2, &m, &r); |
- if (p2 == NIL) |
- { cprintf("Can't create J2 task...\n"); return 1; } |
- |
- /* --------------------------------------------------------------------- |
- Mutex creation |
- --------------------------------------------------------------------- */ |
- |
- PI_mutexattr_default(a2); |
- PC_mutexattr_default(a,0); |
- mutex_init(&m0,(mutexattr_t *)&a); |
- mutex_init(&m1,(mutexattr_t *)&a); |
- |
- PC_mutexattr_default(a,1); |
- mutex_init(&m2,(mutexattr_t *)&a); |
- |
- /* --------------------------------------------------------------------- |
- Event post |
- --------------------------------------------------------------------- */ |
- |
- t.tv_sec = 0; |
- t.tv_nsec = 500000000; |
- |
- kern_cli(); |
- kern_event_post(&t,startJ,(void *)p1); |
- |
- t.tv_sec = 1; |
- kern_event_post(&t,startJ,(void *)p0); |
- kern_sti(); |
- |
- task_activate(p2); |
- |
- cprintf("END main\n"); |
- |
- return 0; |
-} |
Index: tags/rel_1_22/base/readme |
=================================================================== |
--- tags/rel_1_22/base/readme (revision 1310) |
+++ tags/rel_1_22/base/readme (nonexistent) |
@@ -1,50 +0,0 @@ |
-This directory contains a set of simple examples, useful to understand |
-How to make a Shark application. |
- |
-Text mode demos: |
-- hello.c --> a hello world application |
-- timer.c --> tests if the time reads are always increasing |
- (useful for debugging purposes) |
-- sig.c --> simple example that sends signals |
-- semdemo.c --> simple example that uses a semaphore for mutual exclusion |
-- pidemo.c --> simple example that uses PI mutexes between NRT and Hard tasks |
-- pcdemo.c --> simple example that uses PC mutexes between NRT and Hard tasks |
-- srpdemo.c --> simple example that uses SRP mutexes between NRT and Hard tasks |
-- mdemo.c --> simple example that uses a mutex, initialized with whatever |
- protocol you want ;-) |
-- aster.c --> Wow! the original Hartik ASTER demo!!! (EDF, CABs, ...) |
-- aster1.c --> a -lot- of periodic tasks that are created and then die |
- (6 seconds demo) |
-- aster2.c --> a simple stress test: a lot of tasks are created until Utot=1; |
- uses jet functions to dump statistics. (60 seconds demo) |
-- aster3.c --> aster2 + 8 tasks handled by 2 different TBS servers |
-- aster4.c --> aster3 + CBS tasks + Shutdown demo with system tasks |
-- aster5.c --> aster3 + only CBS tasks + mutexes... Really interesting! |
-- aster6.c --> aster5 + Polling Server to serve the JetCtrl task |
-- aster7.c --> another aster clone with Rate monotonic and Polling server |
-- aster8.c --> aster5 + Sporadic Server |
-- preempt.c --> simple test for CBS, task_preempt, task_nopreempt, and |
- save/skip arrivals |
-- pcidemo.c --> PCI Bus scan |
-- talk.c --> UDP Unix Talk clone (useful to understand the network driver) |
-- mousfind.c--> Simple text mouse protocol finder |
-- jointest.c--> Simple test that uses the task_join primitive |
-- condtest.c--> Simple test that uses condition variables |
-- intsem.c --> Simple test that uses internal semaphores |
-- keycode.c --> Prints Keyboard Keycodes on the screen |
-- memtest.c --> Do you need to use malloc, kern_alloc & co? |
- |
-Graphical demos: |
-- fly.c --> Random flies going around the screen |
-- ego.c --> Periodic tasks that writes a phrease on the screen |
-- cabs.c --> Example that uses cabs |
-- sched.c --> Scheduling example (mouse, EDF, RM, DS, PS, TBS) |
- |
-Note on the init files: |
-- ihello.c (RR+dummy) |
-- isemdemo.c (iaster1+Semaphores) |
-- iaster1.c (EDF+RR+dummy) |
-- iaster3.c (EDF+RR+TBS(0.1)+TBS(0.3)+dummy) |
-- iaster4.c (iaster3+CBS) |
-- initfile.c (EDF+CBS+RR+dummy, SEMaphores, CABS, HARTPORTs and Keyboard) |
-- isched.c (Configurable scheduling architecture) |
Index: tags/rel_1_22/base/pidemo.c |
=================================================================== |
--- tags/rel_1_22/base/pidemo.c (revision 1310) |
+++ tags/rel_1_22/base/pidemo.c (nonexistent) |
@@ -1,114 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * |
- * CVS : $Id: pidemo.c,v 1.2 2003-01-07 17:10:15 pj Exp $ |
- |
- This test verify the correctness of the PI module. |
- |
- the main task (NRT) lock a PI mutex. |
- then 2 tasks arrives, with priority higher than the main |
- |
- the first try to lock the mutex, but it can't, so the main inherit |
- his priority. The second simply prints a string. |
- |
- If all works, the string of the second task is printed after the end of |
- the first task. |
- |
-*/ |
- |
-#include "kernel/kern.h" |
- |
-mutex_t m1; |
- |
- |
-TASK goofy1(void *a) |
-{ |
- cprintf("goofy1 before mutex_lock\n"); |
- mutex_lock(&m1); |
- cprintf("goofy1 after mutex_lock\n"); |
- |
- mutex_unlock(&m1); |
- cprintf("goofy1 after mutex_unlock\n"); |
- |
- return 0; |
-} |
- |
-TASK goofy2() |
-{ |
- cprintf("goofy2 inside goofy2\n"); |
- return 0; |
-} |
- |
-int main(int argc, char **argv) |
-{ |
- HARD_TASK_MODEL m; |
- PID p2,p3; |
- |
- PI_mutexattr_t a; |
- |
- hard_task_default_model(m); |
- hard_task_def_mit(m,50000); |
- hard_task_def_wcet(m,20000); |
- hard_task_def_group(m,1); |
- |
- hard_task_def_arg(m,(void *)1); |
- p2 = task_create("goofy1", goofy1, &m, NULL); |
- if (p2 == NIL) |
- { cprintf("Can't create goofy1 task...\n"); return 1; } |
- |
- hard_task_def_mit(m,100000); |
- p3 = task_create("goofy2", goofy2, &m, NULL); |
- if (p3 == NIL) |
- { cprintf("Can't create goofy2 task...\n"); return 1; } |
- |
- PI_mutexattr_default(a); |
- mutex_init(&m1,&a); |
- |
- cprintf("main before mutex_lock\n"); |
- mutex_lock(&m1); |
- cprintf("main after mutex_lock\n"); |
- |
- group_activate(1); |
- |
- cprintf("main after group_activate\n"); |
- mutex_unlock(&m1); |
- cprintf("main after mutex_unlock\n"); |
- |
- mutex_destroy(&m1); |
- cprintf("main after mutex_destroy\n"); |
- |
- return 0; |
-} |
Index: tags/rel_1_22/base/memtest.c |
=================================================================== |
--- tags/rel_1_22/base/memtest.c (revision 1310) |
+++ tags/rel_1_22/base/memtest.c (nonexistent) |
@@ -1,101 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Giorgio Buttazzo, Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * |
- * CVS : $Id: memtest.c,v 1.1 2002-11-11 08:22:46 pj Exp $ |
- */ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include <kernel/kern.h> |
-#include <stdlib.h> |
- |
-int main(int argc, char **argv) |
-{ |
- void *a; |
- |
- clear(); |
- |
- a = malloc(4500); |
- cprintf("malloc : %ld\n", (DWORD)a); |
- free(a); |
- |
- kern_cli(); a = DOS_alloc(4500); kern_sti(); |
- cprintf("below 1 M: %ld\n", (DWORD)a); |
- kern_cli(); DOS_free(a,4500); kern_sti(); |
- |
- kern_cli(); a = kern_alloc_aligned(10000,MEMORY_UNDER_16M,10,0); kern_sti(); |
- cprintf("below 16M: %ld\n", (DWORD)a); |
- kern_cli(); kern_free(a,10000); kern_sti(); |
- |
- kern_cli(); a = kern_alloc_aligned(10000,MEMORY_FROM_1M_TO_16M,2,0); kern_sti(); |
- cprintf(">1M <16M : %ld\n", (DWORD)a); |
- kern_cli(); kern_free(a,10000); kern_sti(); |
- |
- kern_cli(); a = kern_alloc(10000); kern_sti(); |
- cprintf("normal : %ld\n", (DWORD)a); |
- kern_cli(); kern_free(a,10000); kern_sti(); |
- |
- kern_cli(); a = kern_alloc_page(MEMORY_UNDER_1M); kern_sti(); |
- cprintf("page <1M : %ld\n", (DWORD)a); |
- kern_cli(); kern_free_page(a); kern_sti(); |
- |
- kern_cli(); a = kern_alloc_page(MEMORY_FROM_1M_TO_16M); kern_sti(); |
- cprintf("p>1<16M : %ld\n", (DWORD)a); |
- kern_cli(); kern_free_page(a); kern_sti(); |
- |
- kern_cli(); a = kern_alloc_page(0); kern_sti(); |
- cprintf("page : %ld\n", (DWORD)a); |
- kern_cli(); kern_free_page(a); kern_sti(); |
- |
- return 0; |
-} |
Index: tags/rel_1_22/base/condtest.c |
=================================================================== |
--- tags/rel_1_22/base/condtest.c (revision 1310) |
+++ tags/rel_1_22/base/condtest.c (nonexistent) |
@@ -1,222 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Giorgio Buttazzo, Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * |
- * CVS : $Id: condtest.c,v 1.1 2002-11-11 08:22:45 pj Exp $ |
- |
- This test verify the correctness of the condition variables. |
- (... it doesn't test all...) |
- |
- The test uses 1 mutex |
- |
- the main task (NRT) creates three tasks. |
- |
- J0, J1, J3 |
- starts, lock the mutex, and wait on a condition variable |
- |
- J2 |
- at t = 0.5 lock the mutex and call cond_signal |
- at t = 1 lock the mutex and call cond_signal |
- |
-*/ |
- |
-#include "kernel/kern.h" |
-#include "drivers/keyb.h" |
- |
- |
-mutex_t m0; |
-cond_t c0; |
- |
-int number = 0; |
- |
-PID p0,p1,p2,p3; |
- |
-TASK j0() |
-{ |
- cprintf("J0: before locking m0\n"); |
- mutex_lock(&m0); |
- cprintf("J0: locked m0, waiting on c0, number =%d\n", number); |
- while (!number) { |
- cond_wait(&c0,&m0); |
- cprintf("J0: number = %d, if >0 unlocking m0\n",number); |
- } |
- number--; |
- mutex_unlock(&m0); |
- cprintf("J0: unlocked m0, end task\n"); |
- return 0; |
-} |
- |
- |
-TASK j1() |
-{ |
- cprintf("J1: before locking m0\n"); |
- mutex_lock(&m0); |
- cprintf("J1: locked m0, waiting on c0, number =%d\n", number); |
- while (!number) { |
- cond_wait(&c0,&m0); |
- cprintf("J1: number = %d, if >0 unlocking m0\n",number); |
- } |
- number--; |
- mutex_unlock(&m0); |
- cprintf("J1: unlocked m0, end task\n"); |
- return 0; |
-} |
- |
- |
-TASK j2() |
-{ |
-// struct timespec t; |
- |
- cprintf("J2: started, waiting t=0.5 sec\n"); |
- while (sys_gettime(NULL) < 500000); |
- |
- cprintf("J2: before locking m0\n"); |
- mutex_lock(&m0); |
- cprintf("J2: locked m0, number++ (was %d), cond_signal\n", number); |
- |
- number++; |
- cond_signal(&c0); |
-// cond_broadcast(&c0); |
- |
- cprintf("J2: unlocking m0\n"); |
- mutex_unlock(&m0); |
- |
- cprintf("J2: waiting t=1 sec\n"); |
- while (sys_gettime(NULL) < 1000000); |
- |
- cprintf("J2: Killing J3\n"); |
- task_kill(p3); |
- cprintf("J2: before locking m0\n"); |
- mutex_lock(&m0); |
- cprintf("J2: locked m0, number++ (was %d), cond_signal\n", number); |
- |
- number++; |
- cond_signal(&c0); |
-// cond_broadcast(&c0); |
- |
- cprintf("J2: unlocking m0\n"); |
- mutex_unlock(&m0); |
- cprintf("J2: unlocked m0, end task\n"); |
- return 0; |
-} |
- |
-void cleanup_lock(void *arg) |
-{ |
- cprintf("J3: KILL!!!\n"); |
- mutex_unlock(&m0); |
- cprintf("J3: unlocked m0 by the cleanup function\n"); |
-} |
- |
-TASK j3() |
-{ |
- cprintf("J3: before locking m0\n"); |
- mutex_lock(&m0); |
- cprintf("J3: locked m0, waiting on c0, number =%d\n", number); |
- task_cleanup_push(cleanup_lock, (void *)&m0); |
- while (!number) { |
- cond_wait(&c0,&m0); |
- cprintf("J3: number = %d, if >0 unlocking m0\n",number); |
- } |
- task_cleanup_pop(0); |
- // I hope this task never reach this point... it is killed by J2!!! |
- number--; |
- mutex_unlock(&m0); |
- cprintf("J3: unlocked m0, end task\n"); |
- return 0; |
-} |
- |
-void fine(KEY_EVT *e) |
-{ |
- sys_end(); |
-} |
- |
- |
-int main(int argc, char **argv) |
-{ |
-// struct timespec t; |
- |
- NRT_TASK_MODEL m; |
- |
- PI_mutexattr_t a; |
- |
- KEY_EVT emerg; |
- |
- //keyb_set_map(itaMap); |
- emerg.ascii = 'x'; |
- emerg.scan = KEY_X; |
- emerg.flag = ALTL_BIT; |
- keyb_hook(emerg,fine); |
- |
- /* --------------------------------------------------------------------- |
- Task creation |
- --------------------------------------------------------------------- */ |
- |
- nrt_task_default_model(m); |
- nrt_task_def_group(m,1); |
- p0 = task_create("J0", j0, &m, NULL); |
- if (p0 == NIL) |
- { cprintf("Can't create J0 task...\n"); return 1; } |
- |
- p1 = task_create("J1", j1, &m, NULL); |
- if (p1 == NIL) |
- { cprintf("Can't create J1 task...\n"); return 1; } |
- |
- p2 = task_create("J2", j2, &m, NULL); |
- if (p2 == NIL) |
- { cprintf("Can't create J2 task...\n"); return 1; } |
- |
- p3 = task_create("J3", j3, &m, NULL); |
- if (p3 == NIL) |
- { cprintf("Can't create J3 task...\n"); return 1; } |
- |
- /* --------------------------------------------------------------------- |
- Mutex creation |
- --------------------------------------------------------------------- */ |
- |
- PI_mutexattr_default(a); |
- mutex_init(&m0,&a); |
- |
- cond_init(&c0); |
- |
- /* --------------------------------------------------------------------- |
- Event post |
- --------------------------------------------------------------------- */ |
- |
- group_activate(1); |
- |
- cprintf("END main\n"); |
- |
- return 0; |
-} |
Index: tags/rel_1_22/base/mousfind.c |
=================================================================== |
--- tags/rel_1_22/base/mousfind.c (revision 1310) |
+++ tags/rel_1_22/base/mousfind.c (nonexistent) |
@@ -1,216 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Giorgio Buttazzo, Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * |
- * CVS : $Id: mousfind.c,v 1.2 2003-03-24 11:18:19 pj Exp $ |
- */ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai, Massimiliano Giorgi |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include <kernel/kern.h> |
-#include <drivers/mouse.h> |
-#include <drivers/keyb.h> |
- |
-/* don't include this into real applications!!! */ |
-#include <../drivers/oldchar/_mouse.h> |
- |
-int done; |
- |
-void my_mouse_hook(MOUSE_EVT *m) |
-{ |
- static int buttons=-1; |
- if (buttons!=m->buttons) { |
- buttons=m->buttons; |
- //mouse_off(); |
- if (isLeftButton(*m)) puts_xy(9,22,RED,"active"); |
- else puts_xy(9,22,RED," "); |
- if (isCentralButton(*m)) puts_xy(9,23,RED,"active"); |
- else puts_xy(9,23,RED," "); |
- if (isRightButton(*m)) puts_xy(9,24,RED,"active"); |
- else puts_xy(9,24,RED," "); |
- //mouse_on(); |
- } |
- |
- |
- /* |
- if (tindex>20&&first) { |
- int i; |
- cprintf("\nSTART\n"); |
- for (i=0;i<tindex;i++) { |
- cprintf("%i\n",(int)tdata[i]); |
- } |
- for (i=1;i<tindex;i++) { |
- cprintf("%i ",(int)(tdata[i]-tdata[i-1])); |
- } |
- first=0; |
- } |
- */ |
- |
-} |
- |
-int main(int argc,char *argv[]) |
-{ |
- MOUSE_PARMS mouse=BASE_MOUSE; |
- int ch,running,nm; |
- int sens=5; |
- |
- /* screen */ |
- clear(); |
- |
- nm=0; |
- while (*vmouse[nm].name!='\0') { |
- cprintf("%c %s:\t %s\n",(char)('a'+nm),vmouse[nm].name,vmouse[nm].desc); |
- nm++; |
- } |
- |
- cprintf("\n[a-%c]\t select a mouse server\n",(char)(nm+'a'-1)); |
- cprintf("[z]\t decrement mouse threshold\n"); |
- cprintf("[x]\t incremnet mouse threshold\n"); |
- cprintf("[1-4]\t COM port\n"); |
- cprintf("[ENTER]\t exit\n"); |
- place(0,20); |
- cputs("mouse server:\n"); |
- cputs("threshold:\n"); |
- cputs("left :\n"); |
- cputs("central:\n"); |
- cputs("right :"); |
- CRSR_OFF(); |
- |
- /* main loop */ |
- running=done=0; |
- |
- mouse_def_ms(mouse,0); |
- |
- while (!done) { |
- ch=keyb_getch(TRUE); |
- switch(ch) { |
- |
- /* exit demo */ |
- |
- case ENTER: |
- done = 1; |
- break; |
- |
- /* decrement threshold */ |
- |
- case 'z': |
- sens--; |
- if (sens<2) sens=2; |
- mouse_threshold(sens); |
- /* threshold */ |
- place(11,21); |
- cprintf("%i ",sens); |
- break; |
- |
- /* increment threshold */ |
- |
- case 'x': |
- sens++; |
- if (sens>100) sens=100; |
- mouse_threshold(sens); |
- /* threshold */ |
- place(11,21); |
- cprintf("%i ",sens); |
- break; |
- |
- /* change mouse protocol */ |
- |
- default: |
- if (ch>='a'&&ch<='a'+nm-1) { |
- /* don't use this method to change a mouse protocol */ |
- /* use mouse_def_???? macros instead */ |
- mouse.type=ch-'a'; |
- } else |
- if (ch>='1'&&ch<='4') { |
- /* don't use this method to change a mouse com port */ |
- /* use mouse_def_???? macros instead */ |
- mouse.port = ch-'1'; |
- } |
- else |
- break; |
- |
- /* check if a mouse server is running... */ |
- if (running) { |
- /* disable autocursor */ |
- mouse_txtcursor(DISABLE); |
- /* destroy actual mouse server */ |
- mouse_end(); |
- } |
- /* mouse server name */ |
- puts_xy(14,20,GREEN," "); |
- puts_xy(14,20,GREEN,vmouse[mouse.type].name); |
- /* threshold */ |
- place(11,21); |
- cprintf("%i ",sens); |
- /* start a new server */ |
- running=(mouse_init(&mouse)==0?1:0); |
- /* if running ...*/ |
- if (running) { |
- /* set mouse limit */ |
- mouse_limit(0,0,cons_columns-1,cons_rows-1); |
- /* enable autocursor */ |
- mouse_txtcursor(ENABLE|AUTOOFF); |
- /* hook my function */ |
- mouse_hook(my_mouse_hook); |
- /* show mouse cursor */ |
- mouse_on(); |
- } |
- break; |
- |
- } |
- } |
- |
- CRSR_STD(); |
- clear(); |
- sys_end(); |
- return 0; |
-} |
Index: tags/rel_1_22/base/sched.c |
=================================================================== |
--- tags/rel_1_22/base/sched.c (revision 1310) |
+++ tags/rel_1_22/base/sched.c (nonexistent) |
@@ -1,472 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Giorgio Buttazzo, Paolo Gai, Massimiliano Giorgi |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * |
- * CVS : $Id: sched.c,v 1.3 2003-05-01 19:44:07 pj Exp $ |
- |
- This demo is derived from the cbsmouse.c Hartik's example. |
- |
- It only prints the task scheduling in graphic mode... |
- |
- There is a parameter to choose the type of scheduling module |
- to initialize. |
- |
- to init correctly the module and task bandwidth parameters, set the defines |
- NUM and DEN in initg.c and testg.c and remember the "s" (soft) parameter!!! |
- |
- to plot the deadlines assigned by CBS or TBS, compile cbs.c or tbs.c with |
- the TESTG define |
- (gray dots over the mouse line are the deadlines, green dots are CBS |
- shifts) |
- |
- Note that a lot of times the demo exits with an exception; to avoid |
- these exception you have to properly tune the task parameters. |
- |
- On a well configured machine, you will notice the little differences |
- between different servers when moving the mouse ;-) |
- |
-*/ |
- |
-#include <kernel/kern.h> |
-#include <drivers/glib.h> |
-#include <drivers/keyb.h> |
-#include <drivers/mouse.h> |
-#include <semaphore.h> |
- |
-/*--------------------------------------------------------------*/ |
-/* TEST ON EDF SCHEDULING */ |
-/*--------------------------------------------------------------*/ |
- |
-#define LMOUSE 20 |
-#define LM 40 /* line of main */ |
-#define OFFSET 20 /* initial phase */ |
-#define CHAR_DIM 8 /* Height of chars in pixels */ |
- |
-#define DX (640/5-1) |
- |
-int col[3] = {2, 4, 14}; /* colors of timelines */ |
-int lev[3] = {80, 120, 160}; /* level of timelines */ |
-int ptime[3] = {10, 20, 25}; /* number of cycles */ |
-int period[3] = {40, 50,100}; /* tasks' periods */ |
-int tick = 1; /* system tick */ |
-int tscale = 1; /* time scale */ |
-TIME starttime = 0; /* Simulation start time (scaled) */ |
- |
-char *title; /* used in initg.c */ |
- |
-/* period[] is scaled with a factor of PERIODSCALE usec */ |
-#define PERIODSCALE 5000 |
- |
-// update also isched.c!!! |
-#define NUM 2000 |
-#define DEN 64000 |
- |
-sem_t mutex; /* Semaphore for graphix*/ |
- |
-//#define IY(y) (480 - y) |
-#define IY(y) y |
- |
-/* |
- * mouse cursor |
- * |
- */ |
- |
-#define W WHITE |
-#define R RED |
-#define G GREEN |
-#define M MAGENTA |
- |
-/* shape */ |
- |
-BYTE mycursor[16*16]= { |
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, |
- 0,W,W,W,W,0,0,0,0,0,0,W,W,W,W,0, |
- 0,W,M,0,0,0,0,0,0,0,0,0,0,M,W,0, |
- 0,W,0,M,0,0,0,0,0,0,0,0,M,0,W,0, |
- 0,W,0,0,M,0,0,0,0,0,0,M,0,0,W,0, |
- 0,0,0,0,0,M,0,0,0,0,M,0,0,0,0,0, |
- 0,0,0,0,0,0,G,G,G,G,0,0,0,0,0,0, |
- 0,0,0,0,0,0,G,0,0,G,0,0,0,0,0,0, |
- 0,0,0,0,0,0,G,0,0,G,0,0,0,0,0,0, |
- 0,0,0,0,0,0,G,0,0,G,0,0,0,0,0,0, |
- 0,0,0,0,0,0,G,G,G,G,0,0,0,0,0,0, |
- 0,0,0,0,0,0,M,M,M,M,0,0,0,0,0,0, |
- 0,0,0,0,0,0,M,M,M,M,0,0,0,0,0,0, |
- 0,0,0,0,0,M,M,M,M,M,M,0,0,0,0,0, |
- 0,0,0,0,M,M,M,M,M,M,M,M,0,0,0,0, |
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, |
-}; |
- |
-#define F 0xff |
-#define B 0x00 |
- |
-/* mask */ |
-BYTE mybkg[16*16]= { |
- B,B,B,B,B,B,F,F,F,F,B,B,B,B,B,B, |
- B,0,0,0,0,B,F,F,F,F,B,0,0,0,0,B, |
- B,0,0,B,B,F,F,F,F,F,B,B,B,0,0,B, |
- B,0,B,0,B,F,F,F,F,F,F,B,0,B,0,B, |
- B,0,B,B,0,B,F,F,F,F,B,0,B,B,0,B, |
- B,B,B,F,B,0,B,B,B,B,0,B,F,B,B,B, |
- F,F,F,F,F,B,0,0,0,0,B,F,F,F,F,F, |
- F,F,F,F,F,B,0,B,B,0,B,F,F,F,F,F, |
- F,F,F,F,F,B,0,B,B,0,B,F,F,F,F,F, |
- F,F,F,F,F,B,0,B,B,0,B,F,F,F,F,F, |
- F,F,F,F,F,B,0,0,0,0,B,F,F,F,F,F, |
- F,F,F,F,F,B,0,0,0,0,B,F,F,F,F,F, |
- F,F,F,F,F,B,0,0,0,0,B,F,F,F,F,F, |
- F,F,F,F,B,0,0,0,0,0,0,B,F,F,F,F, |
- F,F,F,B,0,0,0,0,0,0,0,0,B,F,F,F, |
- F,F,F,B,B,B,B,B,B,B,B,B,B,F,F,F, |
-}; |
- |
-#undef B |
-#define B 0xff |
- |
-/* bad mask */ |
-BYTE mybadbkg[16*16]= { |
- B,B,B,B,B,B,F,F,F,F,B,B,B,B,B,B, |
- B,0,0,0,0,B,F,F,F,F,B,0,0,0,0,B, |
- B,0,0,B,B,F,F,F,F,F,B,B,B,0,0,B, |
- B,0,B,0,B,F,F,F,F,F,F,B,0,B,0,B, |
- B,0,B,B,0,B,F,F,F,F,B,0,B,B,0,B, |
- B,B,B,F,B,0,B,B,B,B,0,B,F,B,B,B, |
- F,F,F,F,F,B,0,0,0,0,B,F,F,F,F,F, |
- F,F,F,F,F,B,0,B,B,0,B,F,F,F,F,F, |
- F,F,F,F,F,B,0,B,B,0,B,F,F,F,F,F, |
- F,F,F,F,F,B,0,B,B,0,B,F,F,F,F,F, |
- F,F,F,F,F,B,0,0,0,0,B,F,F,F,F,F, |
- F,F,F,F,F,B,0,0,0,0,B,F,F,F,F,F, |
- F,F,F,F,F,B,0,0,0,0,B,F,F,F,F,F, |
- F,F,F,F,B,0,0,0,0,0,0,B,F,F,F,F, |
- F,F,F,B,0,0,0,0,0,0,0,0,B,F,F,F, |
- F,F,F,B,B,B,B,B,B,B,B,B,B,F,F,F, |
-}; |
- |
-/* very bad mask */ |
-BYTE myverybadbkg[16*16]= { |
- F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F, |
- F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F, |
- F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F, |
- F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F, |
- F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F, |
- F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F, |
- F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F, |
- F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F, |
- F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F, |
- F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F, |
- F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F, |
- F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F, |
- F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F, |
- F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F, |
- F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F, |
- F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F, |
-}; |
- |
- |
-/*--------------------------------------------------------------*/ |
-/* Prints a grid to show task periods during execution */ |
-/*--------------------------------------------------------------*/ |
- |
-void print_grid() |
-{ |
- int i; |
- int a1, a2, a3; |
- int temp; |
- |
- a1 = 0; |
- a2 = 0; |
- a3 = 0; |
- temp = 0; |
- |
- grx_text(title, 0, 240-10 ,10, 0); |
- |
- grx_line(OFFSET, lev[0], 639, lev[0], 5); |
- grx_line(OFFSET, lev[1], 639, lev[1], 5); |
- grx_line(OFFSET, lev[2], 639, lev[2], 5); |
- grx_text("T1", 0, lev[0]-8, 9, 0); |
- grx_text("T2", 0, lev[1]-8, 9, 0); |
- grx_text("T3", 0, lev[2]-8, 9, 0); |
- grx_text("MA", 0, LM, 8, 0); |
- grx_text("MO", 0, LMOUSE, 8, 0); |
- |
- for (i = OFFSET; i < 640; i++) { |
- if (temp >= a1) { |
- grx_line(i, lev[0] - 1, i, lev[0] - 20, 3); |
- a1 += period[0]; |
- } |
- if (temp >= a2) { |
- grx_line(i, lev[1] - 1, i, lev[1] - 20, 3); |
- a2 += period[1]; |
- } |
- if (temp >= a3) { |
- grx_line(i, lev[2] - 1, i, lev[2] - 20, 3); |
- a3 += period[2]; |
- } |
- temp += tick/tscale; |
- } |
-} |
- |
-/*--------------------------------------------------------------*/ |
-/* This function is called at system termination */ |
-/*--------------------------------------------------------------*/ |
- |
-void my_end() |
-{ |
- grx_close(); |
-} |
- |
-/*--------------------------------------------------------------*/ |
-/* GENERIC PERIODIC PROCESS */ |
-/*--------------------------------------------------------------*/ |
- |
-TASK color(int k) |
-{ |
- int i; |
- DWORD x = OFFSET; |
- TIME t; |
- while ( x < 640L) { |
- for (i = 0; i < ptime[k]; i++) { |
- |
- t = sys_gettime(NULL) / PERIODSCALE; |
- x = (t - starttime) + OFFSET; |
- if (x>=640) break; |
- sem_wait(&mutex); |
- grx_plot(x, lev[k] - 4, col[k]); |
- grx_plot(x, lev[k] - 5, col[k]); |
- grx_plot(x, lev[k] - 6, col[k]); |
- grx_plot(x, lev[k] - 7, col[k]); |
- sem_post(&mutex); |
- while (sys_gettime(NULL)/PERIODSCALE == t); |
- } |
- task_endcycle(); |
- } |
- return 0; |
-} |
- |
-void my_mouse_handler(MOUSE_EVT *ev) |
-{ |
- int x; |
- |
- x = (sys_gettime(NULL)/PERIODSCALE - starttime) + OFFSET; |
- if (x>=640) return; |
- sem_wait(&mutex); |
- grx_plot(x, LMOUSE, 8); |
- sem_post(&mutex); |
-} |
- |
-/*--------------------------------------------------------------*/ |
-/* MAIN PROCESS */ |
-/*--------------------------------------------------------------*/ |
- |
-int main(int argc, char *argv[]) |
-{ |
- int x = OFFSET; |
- |
- MOUSE_PARMS mouse = BASE_MOUSE; |
- HARD_TASK_MODEL mouse_hard; |
- SOFT_TASK_MODEL mouse_soft; |
- NRT_TASK_MODEL mouse_nrt; |
- |
- char c; |
- KEY_EVT emerg; |
- |
- HARD_TASK_MODEL m_per; |
- int modenum; |
- |
- if (argc>=3) |
- switch(*argv[2]) { |
- case 'h': |
- /* this is not correct, because it don't remember activations */ |
- hard_task_default_model(mouse_hard); |
- hard_task_def_mit(mouse_hard,DEN); |
- hard_task_def_wcet(mouse_hard,NUM); |
- hard_task_def_system(mouse_hard); |
- hard_task_def_nokill(mouse_hard); |
- hard_task_def_aperiodic(mouse_hard); |
- mouse_def_task(mouse,(TASK_MODEL *)&mouse_hard); |
- break; |
- case 's': |
- soft_task_default_model(mouse_soft); |
- soft_task_def_wcet(mouse_soft,NUM); |
- soft_task_def_met(mouse_soft,NUM); |
- soft_task_def_period(mouse_soft,DEN); |
- soft_task_def_system(mouse_soft); |
- soft_task_def_nokill(mouse_soft); |
- soft_task_def_aperiodic(mouse_soft); |
- mouse_def_task(mouse,(TASK_MODEL *)&mouse_soft); |
- break; |
- case 'n': |
- /* this is not correct, because it don't remember activations */ |
- nrt_task_default_model(mouse_nrt); |
- nrt_task_def_system(mouse_nrt); |
- nrt_task_def_nokill(mouse_nrt); |
- mouse_def_task(mouse,(TASK_MODEL *)&mouse_nrt); |
- break; |
- default: |
- argc=0; |
- break; |
- } |
- |
- /* Serial mous on COM3 */ |
- mouse_def_ms(mouse,2); |
- |
- if (argc>=4) { |
- period[0]=atoi(argv[3]); |
- if (period[0]<ptime[0]) period[0]=ptime[0]+5; |
- } |
- if (argc>=5) { |
- period[1]=atoi(argv[4]); |
- if (period[1]<ptime[1]) period[1]=ptime[1]+5; |
- } |
- if (argc>=6) { |
- period[2]=atoi(argv[5]); |
- if (period[2]<ptime[2]) period[2]=ptime[2]+5; |
- } |
- |
- if (argc<2) { |
- cprintf("syntax: x testg <config> <mouse-task> [t1] [t2] [t3]\n"); |
- cprintf("where <config> can be:\n"); |
- cprintf("\t0 - EDF + CBS + RR\n"); |
- cprintf("\t1 - RM + PS ( bkg, U=1/16) + RR, no check Ulub < 0.69\n"); |
- cprintf("\t2 - RM + PS (nobkg, U=1/16) + RR, no check Ulub < 0.69\n"); |
- cprintf("\t3 - EDF + PS ( bkg, U=1/16) + RR\n"); |
- cprintf("\t4 - EDF + PS (nobkg, U=1/16) + RR\n"); |
- cprintf("\t5 - EDF + TBS( U=1/16) + RR\n"); |
- cprintf("\t6 - RM + DS ( bkg, U=1/16) + RR, no check Ulub < 0.69\n"); |
- cprintf("\t7 - RM + DS (nobkg, U=1/16) + RR, no check Ulub < 0.69\n"); |
- cprintf("\nwhere <mouse-task> can be:\n"); |
- cprintf("\th - Hard\n"); |
- cprintf("\ts - Soft (understimated wcet)\n"); |
- cprintf("\tn - NRT\n"); |
- sys_end(); |
- return -1; |
- } |
- |
- if (grx_init() == -1) { |
- sys_shutdown_message("Error initing GraphLib!!!\n"); |
- sys_end(); |
- } |
- modenum = grx_getmode(640, 480, 8); |
- cprintf("Modenum :%d\n", modenum); |
- |
- if (grx_setmode(modenum) == -1) { |
- sys_shutdown_message("No SetMode!!!\n"); |
- sys_end(); |
- } |
- |
- /* this trick can be useful when debugging ... */ |
- //grx_close(); |
- |
- |
- |
- print_grid(); |
- grx_box(DX*0,240,DX*1-1,479,GREEN); |
- grx_box(DX*1,240,DX*2-1,479,WHITE); |
- grx_box(DX*2,240,DX*3-1,479,RED); |
- grx_box(DX*3,240,DX*4-1,479,MAGENTA); |
- grx_box(DX*4,240,DX*5-1,479,BLACK); |
- |
- |
- sys_atrunlevel(my_end, NULL, RUNLEVEL_BEFORE_EXIT); |
- |
- /* mutex */ |
- sem_init(&mutex,0,1); |
- |
- /* keyboard */ |
- emerg.ascii = 'x'; |
- emerg.scan = KEY_X; |
- emerg.flag = ALTL_BIT; |
- keyb_hook(emerg,(void (*)(KEY_EVT *))sys_end); |
- keyb_getchar(); |
- |
- /* mouse */ |
- mouse_init(&mouse); |
- mouse_limit(XMINLIMIT(640,480), |
- 240, |
- XMAXLIMIT(640,480), |
- YMAXLIMIT(640,480)); |
- mouse_position(320,280); |
- mouse_threshold(2); |
- //grx_setcolor(255,255,255,255); |
- mouse_grxshape(mycursor,mybkg); |
- mouse_grxcursor(ENABLE); |
- mouse_on(); |
- mouse_hook(my_mouse_handler); |
- |
- /* hard task creation */ |
- |
- hard_task_default_model(m_per); |
- hard_task_def_mit(m_per,period[0]*PERIODSCALE); |
- hard_task_def_wcet(m_per,ptime[0]*PERIODSCALE); |
- hard_task_def_group(m_per, 1); |
- //task_def_wcet(m, ptime[0] * sys_tick); |
- if (task_create("verde", color, &m_per, NULL) == -1) { |
- sys_shutdown_message("Edf.C(main) Could not create <green>:"); |
- sys_end(); |
- } |
- hard_task_def_arg(m_per, (void *)1); |
- hard_task_def_wcet(m_per, ptime[1]*PERIODSCALE); |
- hard_task_def_mit(m_per,period[1]*PERIODSCALE); |
- if (task_create("red", color, &m_per, NULL) == -1) { |
- sys_shutdown_message("Edf.C(main) Could not create <red>:"); |
- sys_end(); |
- } |
- hard_task_def_arg(m_per, (void *)2); |
- hard_task_def_wcet(m_per, ptime[2]*PERIODSCALE); |
- hard_task_def_mit(m_per,period[2]*PERIODSCALE); |
- if (task_create("yellow", color, &m_per, NULL) == -1) { |
- sys_shutdown_message("Edf.C(main) Could not create <yellow>:"); |
- sys_end(); |
- } |
- starttime = sys_gettime(NULL) / PERIODSCALE; |
- group_activate(1); |
- |
- /* main loop */ |
- while (x < 640L) { |
- x = (sys_gettime(NULL)/PERIODSCALE - starttime) + OFFSET; |
- if (x>=640) break; |
- sem_wait(&mutex); |
- grx_plot(x, LM, 7); |
- sem_post(&mutex); |
- } |
- |
- c = keyb_getchar(); |
- |
- sys_end(); |
- return 0; |
-} |
- |
-/*--------------------------------------------------------------*/ |
Index: tags/rel_1_22/base/fly.c |
=================================================================== |
--- tags/rel_1_22/base/fly.c (revision 1310) |
+++ tags/rel_1_22/base/fly.c (nonexistent) |
@@ -1,216 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: fly.c,v 1.3 2003-01-07 17:10:15 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.3 $ |
- Last update: $Date: 2003-01-07 17:10:15 $ |
- ------------ |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai and Giorgio Buttazzo |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-/*--------------------------------------------------------------*/ |
-/* SIMULATION OF RANDOM FLIES */ |
-/*--------------------------------------------------------------*/ |
- |
-#include <kernel/kern.h> |
-#include <drivers/glib.h> |
-#include <drivers/keyb.h> |
-#include <semaphore.h> |
-#include <stdlib.h> |
-#include <math.h> |
- |
-#define YMENU 10 /* menu level */ |
-#define XMIN 50 |
-#define XMAX 600 |
-#define YMIN 100 |
-#define YMAX 450 |
-#define VEL 5 /* linear velocity (def. = 5) */ |
-#define ANG 30 /* angolo massimo sterzata (30) */ |
-#define D 3 /* raggio mosca */ |
-#define ESC 27 /* ASCII code of ESCAPE key */ |
-#define MAX_P 35 /* max number of flies */ |
-#define FLYGROUP 1 |
- |
-double tick = 1.0; /* system tick = 1 ms */ |
-int fly_period = 40000; /* task period */ |
-int fly_wcet = 1000; /* task wcet */ |
-PID pid; |
-sem_t mutex; |
- |
-/*--------------------------------------------------------------*/ |
- |
-void draw_fly(int x, int y, int c) |
-{ |
- sem_wait(&mutex); |
- grx_disc(x, y, D, c); |
- sem_post(&mutex); |
-} |
- |
-/******************************************************************/ |
- |
-TASK fly(void *arg) |
-{ |
-int x, y; |
-int ox, oy; |
-int dx, dy, da; |
-int teta, col; |
-int outx, outy; |
-double r; |
-int i = (int)arg; |
- |
- x = ox = (XMIN+XMAX)/2; |
- y = oy = (YMIN+YMAX)/2; |
- teta = 0; |
- col = 2 + i; /* colore fly */ |
- |
- while (1) { |
- |
- da = rand()%(2*ANG) - ANG; /* da = [-ANG,ANG] */ |
- teta += da; |
- |
- if (teta > 360) teta -= 360; |
- if (teta < 0) teta += 360; |
- r = (double)teta * PI / 180.; |
- |
- dx = (float)(VEL * cos(r)); |
- dy = (float)(VEL * sin(r)); |
- x += dx; |
- y += dy; |
- |
- outx = (x >= XMAX) || (x <= XMIN); |
- outy = (y >= YMAX) || (y <= YMIN); |
- |
- if (outx || outy) { |
- x = x - dx; |
- y = y - dy; |
- if (outx) teta = 180 - teta; |
- if (outy) teta = -teta; |
- if (teta > 360) teta -= 360; |
- if (teta < 0) teta += 360; |
- r = (double)teta * PI / 180.; |
- |
- dx = (float)(VEL * cos(r)); |
- dy = (float)(VEL * sin(r)); |
- |
- x += dx; |
- y += dy; |
- } |
- |
- draw_fly(ox, oy, 0); |
- draw_fly(x, y, col); |
- ox = x; oy = y; |
- |
- task_endcycle(); |
- } |
-} |
- |
-/****************************************************************/ |
- |
-/* This function is called when the system exits */ |
-void byebye(void *arg) |
-{ |
- grx_close(); |
- cprintf("Bye Bye!\n"); |
-} |
- |
-/****************************** MAIN ******************************/ |
- |
-int main(int argc, char **argv) |
-{ |
- HARD_TASK_MODEL m; |
- |
- char c; /* character from keyboard */ |
- int i = 0; /* number of tasks created */ |
- TIME seme; /* used to init the random seed */ |
- |
- /* Set the closing function */ |
- sys_atrunlevel(byebye, NULL, RUNLEVEL_BEFORE_EXIT); |
- |
- /* graphic card Initialization */ |
- if (grx_init() < 1) { |
- sys_abort(1); |
- } |
- |
- if (grx_open(640, 480, 8) < 0) { |
- cprintf("GRX Err\n"); |
- sys_abort(1); |
- } |
- |
- /* The scenario */ |
- grx_rect(XMIN-D-1, YMIN-D-1, XMAX+D+1, YMAX+D+1, 14); |
- grx_text("Simulation of Random Flies", XMIN, YMENU+10, 13, 0); |
- grx_text("SPACE create a fly" , XMIN, YMENU+20, 12, 0); |
- grx_text("ESC exit to DOS" , XMIN, YMENU+30, 12, 0); |
- |
- /* The program waits a space to create a fly */ |
- c = keyb_getch(BLOCK); |
- |
- /* randomize!!!! */ |
- seme = sys_gettime(NULL); |
- srand(seme); |
- |
- do { |
- if ((c == ' ') && (i < MAX_P)) { |
- hard_task_default_model(m); |
- hard_task_def_ctrl_jet (m); |
- hard_task_def_arg (m, (void *)i); |
- hard_task_def_wcet (m, fly_wcet); |
- hard_task_def_mit (m, fly_period); |
- hard_task_def_group (m, FLYGROUP); |
- hard_task_def_usemath (m); |
- pid = task_create("fly", fly, &m, NULL); |
- if (pid == NIL) { |
- grx_close(); |
- perror("Could not create task <fly>"); |
- sys_abort(1); |
- } |
- task_activate(pid); |
- i++; |
- } |
- c = keyb_getch(BLOCK); |
- |
- } while (c != ESC); |
- |
- sys_end(); |
- |
- return 0; |
-} |
- |
-/*--------------------------------------------------------------*/ |
Index: tags/rel_1_22/base/talk.c |
=================================================================== |
--- tags/rel_1_22/base/talk.c (revision 1310) |
+++ tags/rel_1_22/base/talk.c (nonexistent) |
@@ -1,209 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Luca Abeni, Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * |
- * CVS : $Id: aster1.c,v 1.1 2002/10/28 08:13:37 pj Exp |
- |
- This is the talkdx.c Hartik's example. |
- |
- File: Talk.C |
- Revision: 1.00 |
- Author: Luca Abeni |
- |
- |
- Simple Netlib demo: nothing of seriously real-time, only another Unix |
- Talk clone. |
- Read it to see how the UDP/IP layers of the networ library work. |
- |
-*/ |
- |
-#include <kernel/kern.h> |
-#include <string.h> |
- |
-#include <drivers/crtwin.h> |
-#include <drivers/keyb.h> |
- |
-#include <drivers/udpip.h> |
- |
- |
-WIN dbg; |
-BYTE esc = FALSE; |
- |
-char talk_myipaddr[20]; |
-char talk_toipaddr[20]; |
- |
-/* |
- This non real-time task reads UDP packets from the network and writes |
- them in a window |
-*/ |
-TASK scrittore(void) |
-{ |
- char str[2000]; |
- UDP_ADDR from, local; |
- WIN displ; |
- int s,n; |
- |
- /* Connect on the local port #100 */ |
- local.s_port = 100; |
- s = udp_bind(&local, NULL); |
- |
- /* Open the window */ |
- win_init(&displ,0,0,79,6); |
- win_frame(&displ,BLACK,WHITE,"Remote",2); |
- |
- while (1) { |
- /* Clear the buffer for receiving the packet...*/ |
- memset(str, 0, 1999); |
- /*...and receive the packet (block until a packet arrives */ |
- n = udp_recvfrom(s, str, &from); |
- win_puts(&displ, str); |
- } |
-} |
- |
-/* |
- This non real-time task reads strings from the keyoard and sends them |
- to the remote host |
-*/ |
-TASK write(void) |
-{ |
- WIN wr; |
- UDP_ADDR to,local; |
- char str[80]; |
- int s; |
- IP_ADDR bindlist[5]; |
- |
- /* Create a socket for transitting */ |
- ip_str2addr(talk_myipaddr,&(local.s_addr)); |
- local.s_port = 101; |
- |
- /* |
- If we want the address of the remote host in the ARP table before |
- begginning the transmission (to eliminate a possible source of |
- unpredictability), we can use the bindlist, otherwise we set the |
- second parameter of udp_bind to NULL |
- */ |
- ip_str2addr(talk_toipaddr,&(bindlist[0])); |
- memset(&(bindlist[1]), 0, sizeof(IP_ADDR)); |
- s = udp_bind(&local, /*bindlist*/NULL); |
- |
- win_init(&wr,0,7,79,6); |
- win_frame(&wr,BLACK,WHITE,"Local",2); |
- ip_str2addr(talk_toipaddr,&(to.s_addr)); |
- to.s_port = 100; |
- sprintf(str,"Local IP address %d.%d.%d.%d\n", local.s_addr.ad[0], |
- local.s_addr.ad[1], local.s_addr.ad[2], |
- local.s_addr.ad[3]); |
- win_puts(&dbg,str); |
- sprintf(str,"Talk to %d.%d.%d.%d ",to.s_addr.ad[0],to.s_addr.ad[1], |
- to.s_addr.ad[2],to.s_addr.ad[3]); |
- win_puts(&dbg,str); |
- while (1) { |
- /* Get the string...*/ |
- win_gets(&wr,str,78); |
- strcat(str,"\n"); |
- /*...and send it!!! */ |
- udp_sendto(s,str,strlen(str)+2,&to); |
- } |
-} |
- |
-/* This function is called when the user presses CTRL-C (stops the systems) */ |
-void esci(KEY_EVT *k) |
-{ |
- esc = TRUE; |
- cprintf("Ctrl-Brk pressed!\n"); |
- sys_end(); |
-} |
- |
-int main(int argc, char **argv) |
-{ |
- KEY_EVT k; |
- |
- struct net_model m = net_base; |
- |
- NRT_TASK_MODEL m_nrt; |
- |
- k.flag = CNTL_BIT; |
- k.scan = KEY_C; |
- k.ascii = 'c'; |
- keyb_hook(k,esci); |
- k.flag = CNTR_BIT; |
- k.scan = KEY_C; |
- k.ascii = 'c'; |
- keyb_hook(k,esci); |
- |
- clear(); |
- cprintf(" Hartik Talk! Ver. 1.00\n"); |
- |
- if (argc != 3) { |
- cprintf("Hartik Talk usage: talk fromIP toIP\n"); |
- return 0; |
- } |
- |
- strcpy(talk_myipaddr, argv[1]); |
- strcpy(talk_toipaddr, argv[2]); |
- |
- /* We want a task for TX mutual exclusion */ |
- net_setmode(m, TXTASK); |
- /* We use UDP/IP stack */ |
- net_setudpip(m, talk_myipaddr, "255.255.255.255"); |
- /* OK: let's start the NetLib! */ |
- if (net_init(&m) == 1) { |
- cprintf("Net Init OK...\n"); |
- } else { |
- cprintf("Net Init Failed...\n"); |
- sys_abort(300); |
- } |
- |
- |
- //dump_irq(); |
- |
- cprintf("\n\n\n\tPress ENTER\n"); |
- while (!esc) { |
- keyb_getcode(&k,BLOCK); |
- if (k.ascii == 13) esc = TRUE; |
- } |
- |
- esc = FALSE; |
- clear(); |
- win_init(&dbg,0,20,60,3); |
- win_frame(&dbg,BLACK,WHITE,"Debug",2); |
- |
- /* Start the sender and receiver tasks...*/ |
- nrt_task_default_model(m_nrt); |
- task_activate(task_create("aaa",scrittore,&m_nrt,NULL)); |
- task_activate(task_create("bbb",write,&m_nrt,NULL)); |
- |
- return 0; |
-} |
Index: tags/rel_1_22/base/makefile |
=================================================================== |
--- tags/rel_1_22/base/makefile (revision 1310) |
+++ tags/rel_1_22/base/makefile (nonexistent) |
@@ -1,111 +0,0 @@ |
-# |
-# |
-# |
- |
-ifndef BASE |
-BASE=../.. |
-endif |
-include $(BASE)/config/config.mk |
- |
-PROGS = hello sig time preempt |
-PROGS += aster aster1 aster2 aster3 aster4 aster5 aster6 aster7 aster8 |
-PROGS += pcidemo talk mousfind keycode memtest |
-PROGS += jointest condtest intsem semdemo pidemo pcdemo srpdemo mdemo |
-PROGS += ego fly cabs sched |
- |
-include $(BASE)/config/example.mk |
- |
- |
-# Text applications |
-hello: |
- make -f $(SUBMAKE) APP=hello INIT= OTHEROBJS="ihello.o" OTHERINCL= SHARKOPT=__OLDCHAR__ |
- |
-time: |
- make -f $(SUBMAKE) APP=time INIT= OTHEROBJS="ihello.o" OTHERINCL= SHARKOPT=__OLDCHAR__ |
- |
-sig: |
- make -f $(SUBMAKE) APP=sig INIT= OTHEROBJS="ihello.o" OTHERINCL= SHARKOPT=__OLDCHAR__ |
- |
-preempt: |
- make -f $(SUBMAKE) APP=preempt INIT= OTHEROBJS="initfile.o" OTHERINCL= SHARKOPT=__OLDCHAR__ |
- |
-semdemo: |
- make -f $(SUBMAKE) APP=semdemo INIT= OTHEROBJS="isemdemo.o" OTHERINCL= SHARKOPT=__OLDCHAR__ |
- |
-pidemo: |
- make -f $(SUBMAKE) APP=pidemo INIT= OTHEROBJS="imdemo.o" OTHERINCL= SHARKOPT=__OLDCHAR__ |
- |
-pcdemo: |
- make -f $(SUBMAKE) APP=pcdemo INIT= OTHEROBJS="imdemo.o" OTHERINCL= SHARKOPT=__OLDCHAR__ |
- |
-srpdemo: |
- make -f $(SUBMAKE) APP=srpdemo INIT= OTHEROBJS="imdemo.o" OTHERINCL= SHARKOPT=__OLDCHAR__ |
- |
-mdemo: |
- make -f $(SUBMAKE) APP=mdemo INIT= OTHEROBJS="imdemo.o" OTHERINCL= SHARKOPT=__OLDCHAR__ |
- |
-aster: |
- make -f $(SUBMAKE) APP=aster INIT= OTHEROBJS="initfile.o" OTHERINCL= SHARKOPT=__OLDCHAR__ |
- |
-aster1: |
- make -f $(SUBMAKE) APP=aster1 INIT= OTHEROBJS="iaster1.o" OTHERINCL= SHARKOPT=__OLDCHAR__ |
- |
-aster2: |
- make -f $(SUBMAKE) APP=aster2 INIT= OTHEROBJS="iaster1.o" OTHERINCL= SHARKOPT=__OLDCHAR__ |
- |
-aster3: |
- make -f $(SUBMAKE) APP=aster3 INIT= OTHEROBJS="iaster3.o" OTHERINCL= SHARKOPT=__OLDCHAR__ |
- |
-aster4: |
- make -f $(SUBMAKE) APP=aster4 INIT= OTHEROBJS="iaster4.o" OTHERINCL= SHARKOPT=__OLDCHAR__ |
- |
-aster5: |
- make -f $(SUBMAKE) APP=aster5 INIT= OTHEROBJS="imdemo.o" OTHERINCL= SHARKOPT=__OLDCHAR__ |
- |
-aster6: |
- make -f $(SUBMAKE) APP=aster6 INIT= OTHEROBJS="iaster6.o" OTHERINCL= SHARKOPT=__OLDCHAR__ |
- |
-aster7: |
- make -f $(SUBMAKE) APP=aster7 INIT= OTHEROBJS="iaster7.o" OTHERINCL= SHARKOPT=__OLDCHAR__ |
- |
-aster8: |
- make -f $(SUBMAKE) APP=aster8 INIT= OTHEROBJS="iaster8.o" OTHERINCL= SHARKOPT=__OLDCHAR__ |
- |
-pcidemo: |
- make -f $(SUBMAKE) APP=pcidemo INIT= OTHEROBJS="initfile.o" OTHERINCL= SHARKOPT=__OLDCHAR__ |
- |
-talk: |
- make -f $(SUBMAKE) APP=talk INIT= OTHEROBJS="initfile.o" OTHERINCL= SHARKOPT=__OLDCHAR__ |
- |
-mousfind: |
- make -f $(SUBMAKE) APP=mousfind INIT= OTHEROBJS="initfile.o" OTHERINCL= SHARKOPT=__OLDCHAR__ |
- |
-jointest: |
- make -f $(SUBMAKE) APP=jointest INIT= OTHEROBJS="imdemo.o" OTHERINCL= SHARKOPT=__OLDCHAR__ |
- |
-condtest: |
- make -f $(SUBMAKE) APP=condtest INIT= OTHEROBJS="imdemo.o" OTHERINCL= SHARKOPT=__OLDCHAR__ |
- |
-intsem: |
- make -f $(SUBMAKE) APP=intsem INIT= OTHEROBJS="imdemo.o" OTHERINCL= SHARKOPT=__OLDCHAR__ |
- |
-keycode: |
- make -f $(SUBMAKE) APP=keycode INIT= OTHEROBJS="initfile.o" OTHERINCL= SHARKOPT=__OLDCHAR__ |
- |
-memtest: |
- make -f $(SUBMAKE) APP=memtest INIT= OTHEROBJS="initfile.o" OTHERINCL= SHARKOPT=__OLDCHAR__ |
- |
-# Graphical applications |
- |
-ego: |
- make -f $(SUBMAKE) APP=ego INIT= OTHEROBJS="initfile.o" OTHERINCL= SHARKOPT="__OLDCHAR__ __GRX__" |
- |
-fly: |
- make -f $(SUBMAKE) APP=fly INIT= OTHEROBJS="initfile.o" OTHERINCL= SHARKOPT="__OLDCHAR__ __GRX__" |
- |
-cabs: |
- make -f $(SUBMAKE) APP=cabs INIT= OTHEROBJS="initfile.o" OTHERINCL= SHARKOPT="__OLDCHAR__ __GRX__" |
- |
-sched: |
- make -f $(SUBMAKE) APP=sched INIT= OTHEROBJS="isched.o" OTHERINCL= SHARKOPT="__OLDCHAR__ __GRX__" |
- |
Index: tags/rel_1_22/base/cabs.dat |
=================================================================== |
--- tags/rel_1_22/base/cabs.dat (revision 1310) |
+++ tags/rel_1_22/base/cabs.dat (nonexistent) |
@@ -1,11 +0,0 @@ |
----------------------------------------------------- |
-system tick (ms): 1 |
----------------------------------------------------- |
- |
-task periods (ticks) |
----------------------------------------------------- |
-producer 1: 200 consumer 1: 400 |
-producer 2: 100 consumer 2: 400 |
-producer 3: 300 consumer 3: 150 |
-producer 4: 800 consumer 4: 200 |
----------------------------------------------------- |
Index: tags/rel_1_22/base/aster1.c |
=================================================================== |
--- tags/rel_1_22/base/aster1.c (revision 1310) |
+++ tags/rel_1_22/base/aster1.c (nonexistent) |
@@ -1,174 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * |
- * CVS : $Id: aster1.c,v 1.2 2003-01-07 17:10:15 pj Exp $ |
- |
- this is a reduced verion of the classic Hartik demo Aster. |
- |
- It uses: |
- - EDF module |
- . periodic tasks |
- - an high number of task executing concurrently |
- |
- The demo ends after 6 seconds. |
- |
-*/ |
- |
-/* |
- Well, this is only a stupid demo which intend to show many |
- HARTIK+ capabilities; the application is structured in the followig |
- way: there is an ASTER task wich randomly creates some ASTEROID tasks |
- which are displayed into the first window; each task is HARD/PERIODIC |
- and auto-kills itself when it reaches the window end! |
- Finally a CLOCK task is implemented to test system clock. |
- Please note that usually the HARTIK+ application is made up of a task |
- group which interacts among them, while the main() function, which |
- became a task itself when the kernel is activated, is suspended until |
- the system is ready to terminate; the MAIN task can also be used to make |
- other background activities, but it should not be killed; when the |
- application terminates, the control is passed to MAIN which kills |
- everybody, shut down the system and can handle other operations using |
- the services available with the previou operating system (I.E. the DOS). |
- If you need to manage sudden abort/exception you should install your own |
- exception handler and raise it through the exc_raise() primitive to |
- make the system abort safely! |
- Remember that the exit functions posted through sys_atexit() will be |
- executed in both cases, to allow clean system shutdown. |
-*/ |
- |
-#include "kernel/kern.h" |
- |
-int num_aster = 0; |
-#define ASTER_LIM 67 |
-#define ASTER_MAX 90 |
- |
-TASK asteroide(void) |
-{ |
- int i = 1; |
- int y = rand() % 20 + 1; |
- while (i < ASTER_LIM) { |
- puts_xy(i,y,WHITE,"*"); |
- task_endcycle(); |
- |
- puts_xy(i,y,WHITE," "); |
- i++; |
- } |
- num_aster--; |
- return 0; |
-} |
- |
-DWORD taskCreated = 0; |
- |
-TASK aster(void) |
-{ |
- PID p; |
- |
- HARD_TASK_MODEL m; |
- int r; |
- |
- hard_task_default_model(m); |
- hard_task_def_wcet(m,500); |
- |
- srand(7); |
- while (1) { |
- if (num_aster < ASTER_MAX) { |
- r = (rand() % 50) - 25; |
- |
- hard_task_def_arg(m,(void *)((rand() % 7)+1)); |
- hard_task_def_mit(m, (50+r)*1000); |
- p = task_create("aaa",asteroide,&m,NULL); |
- taskCreated++; |
- task_activate(p); |
- num_aster++; |
- } |
- |
- task_endcycle(); |
- } |
-} |
- |
-TASK clock() |
-{ |
- int s = 0, m = 0; |
- |
- while(1) { |
- printf_xy(70,1,WHITE,"%2d : %2d",m,s); |
- task_endcycle(); |
- |
- if (++s > 59) { |
- s = 0; |
- m++; |
- } |
- printf_xy(70,1,WHITE,"%2d : %2d",m,s); |
- task_endcycle(); |
- } |
-} |
- |
-int main(int argc, char **argv) |
-{ |
- PID p1,p2; |
- HARD_TASK_MODEL m; |
- struct timespec t; |
- |
- clear(); |
- |
- hard_task_default_model(m); |
- hard_task_def_mit(m,10000); |
- hard_task_def_wcet(m,2000); |
- hard_task_def_group(m,1); |
- |
- p1 = task_create("Aster",aster,&m,NULL); |
- if (p1 == -1) { |
- perror("Aster.C(main): Could not create task <aster> ..."); |
- sys_end(); |
- } |
- |
- hard_task_def_mit(m,500000); |
- p2 = task_create("Clock",clock,&m,NULL); |
- if (p2 == -1) { |
- perror("Aster.C(main): Could not create task <Clock> ..."); |
- sys_end(); |
- } |
- |
- group_activate(1); |
- |
- do { |
- sys_gettime(&t); |
- } while (t.tv_sec < 6); |
- |
- sys_end(); |
- return 0; |
-} |
- |
Index: tags/rel_1_22/base/jointest.c |
=================================================================== |
--- tags/rel_1_22/base/jointest.c (revision 1310) |
+++ tags/rel_1_22/base/jointest.c (nonexistent) |
@@ -1,220 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Giorgio Buttazzo, Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * |
- * CVS : $Id: jointest.c,v 1.1 2002-11-11 08:22:45 pj Exp $ |
- |
- This test verify the correctness of the task_join primitive. (that |
- function is the same as pthread_join... someday I will change the |
- names...) |
- |
- There are 4 taks, J1, J2, J3, are created as joinable, J4 as detached |
- |
- The main task: |
- Creates J1 and J2, locks m1 (a PI mitex), creates C3. |
- at t=0.8 sec it calls a task_join on J3 (that returns EDEADLK), |
- it unlocks m1, then it makes task_join on J3 another time. |
- Next it creates J4 as detached and finally it does a task_join on J4 |
- (that returns EINVAL). |
- |
- J1: |
- at t=0.2 sec it calls task_join on J2, the it ends. |
- |
- J2: |
- it simply waits t=0.4 sec and it ends. |
- |
- J3: |
- First, it calls task_join on J1. |
- Then, at t=0.6 sec it locks m1, then unlocks it |
- |
- J4: |
- it simply waits t=1 sec and it ends. |
- |
-*/ |
- |
-#include "kernel/kern.h" |
-#include "drivers/keyb.h" |
- |
- |
-PID j0, j1, j2, j3, j4; |
-mutex_t m1; |
- |
-void fine(KEY_EVT *e) |
-{ |
- sys_end(); |
-} |
- |
-TASK J1() |
-{ |
- int err; |
- void *ret; |
- |
- cprintf("J1: started, waiting 0.2 sec\n"); |
- |
- while (sys_gettime(NULL) < 200000); |
- |
- cprintf("J1: 0.2 sec reached, joining J2\n"); |
- |
- err = task_join(j2, &ret); |
- |
- cprintf("J1: join J2 returns %d error %d, exiting\n", |
- (int)ret,err); |
- return (void *)11; |
-} |
- |
-TASK J2() |
-{ |
- cprintf("J2: started, waiting 0.4 sec\n"); |
- |
- while (sys_gettime(NULL) < 400000); |
- |
- cprintf("J2: 0.4 sec reached, exiting\n"); |
- |
- return (void *)22; |
-} |
- |
-TASK J3() |
-{ |
- int err; |
- void *ret; |
- |
- cprintf("J3: started, joining J1\n"); |
- |
- err = task_join(j1, &ret); |
- |
- cprintf("J3: join J1 returns %d error %d, waiting 0.6sec\n", (int)ret, err); |
- |
- while (sys_gettime(NULL) < 600000); |
- |
- cprintf("J1: 0.6 sec reached, locking m1\n"); |
- |
- mutex_lock(&m1); |
- |
- cprintf("J3: locked m1, unlocking m1\n"); |
- |
- mutex_unlock(&m1); |
- |
- cprintf("J3: unlocked m1, exiting\n"); |
- |
- return (void *)33; |
-} |
- |
-TASK J4() |
-{ |
- cprintf("J4: started, waiting 1 sec\n"); |
- |
- while (sys_gettime(NULL) < 1000000); |
- |
- cprintf("J4: 1 sec reached, exiting\n"); |
- |
- return (void *)44; |
-} |
- |
-int main(int argc, char **argv) |
-{ |
- NRT_TASK_MODEL m; |
- |
- PI_mutexattr_t a; |
- |
- KEY_EVT emerg; |
- |
- int err; |
- void *ret; |
- |
- //keyb_set_map(itaMap); |
- emerg.ascii = 'x'; |
- emerg.scan = KEY_X; |
- emerg.flag = ALTL_BIT; |
- keyb_hook(emerg,fine); |
- |
- j0 = exec_shadow; |
- nrt_task_default_model(m); |
- nrt_task_def_joinable(m); |
- |
- /* --------------------------------------------------------------------- |
- Mutex creation |
- --------------------------------------------------------------------- */ |
- |
- PI_mutexattr_default(a); |
- mutex_init(&m1,&a); |
- |
- |
- /* --------------------------------------------------------------------- |
- Let's go !!!! |
- --------------------------------------------------------------------- */ |
- |
- cprintf("main: creating J1,J2,J3, locking m1\n"); |
- |
- j1 = task_create("J1", J1, &m, NULL); |
- if (j1 == NIL) { cprintf("Can't create J1 task...\n"); return 1; } |
- task_activate(j1); |
- |
- j2 = task_create("J2", J2, &m, NULL); |
- if (j2 == NIL) { cprintf("Can't create J2 task...\n"); return 1; } |
- task_activate(j2); |
- |
- mutex_lock(&m1); |
- |
- j3 = task_create("J3", J3, &m, NULL); |
- if (j3 == NIL) { cprintf("Can't create J3 task...\n"); return 1; } |
- task_activate(j3); |
- |
- cprintf("main: waiting t=0.8 sec\n"); |
- |
- while (sys_gettime(NULL) < 800000); |
- |
- err = task_join(j3, NULL); |
- |
- cprintf("main: join J3 error %d, unlocking m1\n",err); |
- |
- mutex_unlock(&m1); |
- |
- err = task_join(j3, &ret); |
- |
- cprintf("main: join J3 returns %d error %d, unlocked m1, creating J4\n", |
- (int)ret,err); |
- |
- nrt_task_def_unjoinable(m); |
- j4 = task_create("J4", J4, &m, NULL); |
- if (j4 == NIL) { cprintf("Can't create J4 task...\n"); return 1; } |
- |
- task_activate(j4); |
- |
- err = task_join(j4,&ret); |
- |
- cprintf("main: join J4 returns %d error %d, exiting\n", (int)ret, err); |
- |
- return 0; |
-} |
Index: tags/rel_1_22/base/aster2.c |
=================================================================== |
--- tags/rel_1_22/base/aster2.c (revision 1310) |
+++ tags/rel_1_22/base/aster2.c (nonexistent) |
@@ -1,241 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * |
- * CVS : $Id: aster2.c,v 1.2 2002-11-11 08:20:44 pj Exp $ |
- |
- this is a part of the classic Hartik demo Aster. |
- |
- It checks: |
- - jet functions |
- - The EDF level with many task, with almost full bandwidth used |
- |
-*/ |
- |
- |
-#include "kernel/kern.h" |
-#include "modules//edf.h" |
- |
-int num_aster = 0; |
-#define ASTER_LIM 60 |
-#define DISPLAY_MAX 15 |
-#define ASTER_MAX 70 |
-#define STAT_Y 9 |
- |
-// first numbers for wcet and periods are for a 486/25, the others for a |
-// celeron 366 |
- |
-#define PER_WCET 13000 /*6200*/ |
-#define CLOCK_WCET 1200 /* 100*/ |
-#define ASTER_WCET 1200 /* 100*/ |
- |
-#define ASTER_MEAN_PERIOD 64 /*64*/ |
- |
-#define END_TEST_TIME 60 |
- |
-TASK asteroide(void) |
-{ |
- int i; |
- int y = rand() % 7 + 1; |
- |
- int load1,j; |
- |
- char s[2]; |
- |
- s[0] = '*'; s[1] = 0; |
- |
- /*for (;;)*/ { |
- i = 1; |
- while (i < ASTER_LIM) { |
- load1 = 1000; //10000; // 5000 + rand()%5000; |
- for (j=0; j<load1; j++) { |
- s[0] = '*' + rand() % 100; |
- puts_xy(i,y,rand()%15+1,s); |
- } |
- |
- task_endcycle(); |
- |
- puts_xy(i,y,WHITE," "); |
- i++; |
- } |
- } |
- num_aster--; |
- return 0; |
-} |
- |
-TASK aster() |
-{ |
- PID p; |
- |
- HARD_TASK_MODEL m; |
- int r; |
- int x; // adaptive bandwidth... |
- |
- hard_task_default_model(m); |
- hard_task_def_wcet(m,PER_WCET); |
- hard_task_def_ctrl_jet(m); |
- |
- x = ASTER_MEAN_PERIOD; |
- |
- srand(7); |
- while (1) { |
- if (num_aster < ASTER_MAX) { |
- r = (rand() % 200); |
- |
- hard_task_def_arg(m,(void *)((rand() % 7)+1)); |
- hard_task_def_mit(m, (x+r)*1000); |
- p = task_create("aaa",asteroide,&m,NULL); |
- if (p == -1) |
- { |
- if (x < 500 && errno != ENO_AVAIL_TASK) x += 1; |
- printf_xy(62,3,WHITE,"adapt=%3u err=%d", |
- iq_query_first(&freedesc),errno); |
- } |
- else { |
- num_aster++; |
- printf_xy(62,3,WHITE,"adapt=%3u ",x);//,errno); |
- task_activate(p); |
- x /= 2; |
- if (x<50) x = 50; |
- } |
- } |
- task_endcycle(); |
- } |
-} |
- |
-TASK clock() |
-{ |
- int s = 0, m = 0; |
- |
- while(1) { |
- printf_xy(62,1,WHITE,"%2d:%2d ast=%d",m,s, num_aster); |
- printf_xy(62,2,WHITE,"U=%12u",EDF_usedbandwidth(0)); |
- task_endcycle(); |
- |
- if (++s > 59) { |
- s = 0; |
- m++; |
- } |
- printf_xy(62,1,WHITE,"%2d:%2d ast=%d",m,s, num_aster); |
- printf_xy(62,2,WHITE,"U=%12u",EDF_usedbandwidth(0)); |
- task_endcycle(); |
- } |
-} |
- |
- |
- |
-/* we consider the first ASTER_MAX + 2 tasks from the PID 2 |
- and plot on the screen the elapsed times... */ |
-TASK jetcontrol() |
-{ |
- int i; /* a counter */ |
- TIME sum, max, curr, last[5]; |
- int nact; |
- int j; /* the elements set by jet_gettable */ |
- PID p; |
- |
- |
- kern_cli(); |
- printf_xy(0,STAT_Y,WHITE,"PID ³ Mean T.³ Max T. ³ N.A. ³ Curr. ³ Last1 ³ Last2 ³ Last3 ³ Last4 ³ Last5"); |
- kern_sti(); |
- |
- for (;;) { |
- for (i=0,p=0; i<DISPLAY_MAX+5 && p<MAX_PROC; p++) { |
- if (jet_getstat(p, &sum, &max, &nact, &curr) == -1) continue; |
- |
- for (j=0; j<5; j++) last[j] = 0; |
- jet_gettable(p, &last[0], 5); |
- kern_cli(); |
- printf_xy(0,STAT_Y+i+1,WHITE,"%-3d ³ %-6d ³ %-6d ³ %-4d ³ %-7d ³ %-5d ³ %-5d ³ %-5d ³ %-5d ³ %-5d", |
- p, (int)sum/(nact==0 ? 1 : nact), (int)max, nact, (int)curr, (int)last[0], (int)last[1], (int)last[2], (int)last[3], (int)last[4]); |
- kern_sti(); |
- i++; |
- } |
- } |
-} |
- |
-int main(int argc, char **argv) |
-{ |
- PID p1,p2,p3; //,p4,p5,p6; |
- HARD_TASK_MODEL m; |
- NRT_TASK_MODEL m_nrt; |
- struct timespec t; |
- |
- clear(); |
- |
- hard_task_default_model(m); |
- hard_task_def_wcet(m,ASTER_WCET); |
- hard_task_def_mit(m,10000); |
- hard_task_def_group(m,1); |
- hard_task_def_ctrl_jet(m); |
- |
- nrt_task_default_model(m_nrt); |
- nrt_task_def_group(m_nrt,1); |
- nrt_task_def_ctrl_jet(m_nrt); |
- |
- p1 = task_create("Aster",aster,&m,NULL); |
- if (p1 == -1) { |
- perror("test7.c(main): Could not create task <aster> ..."); |
- sys_end(); |
- } |
- |
- hard_task_def_mit(m,500000); |
- hard_task_def_wcet(m,CLOCK_WCET); |
- p2 = task_create("Clock",clock,&m,NULL); |
- if (p2 == -1) { |
- perror("test7.c(main): Could not create task <Clock> ..."); |
- sys_end(); |
- } |
- |
- p3 = task_create("JetControl",jetcontrol,&m_nrt,NULL); |
- if (p2 == -1) { |
- perror("test7.c(main): Could not create task <JetControl> ..."); |
- sys_end(); |
- } |
- |
- group_activate(1); |
- |
- do { |
- sys_gettime(&t); |
- } while (t.tv_sec < END_TEST_TIME); |
- |
- sys_end(); |
- |
- return 0; |
-} |
- |
- |
- |
- |
Index: tags/rel_1_22/base/aster3.c |
=================================================================== |
--- tags/rel_1_22/base/aster3.c (revision 1310) |
+++ tags/rel_1_22/base/aster3.c (nonexistent) |
@@ -1,300 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * |
- * CVS : $Id: aster3.c,v 1.3 2003-01-07 17:10:15 pj Exp $ |
- |
- Test Number 10 (A): |
- |
- this is a part of the classic Hartik demo Aster. |
- |
- it is based on aster2.c, with the use of TBS to serve a set of aperiodic |
- tasks. |
- |
- There are APER_MAX tasks sleeping, and when an asteroide task finish |
- the current activation, it activate also an aperiodic task chosen |
- randomly (if the task chosen is already active, the task_activate do |
- nothing!) |
- |
- |
-*/ |
- |
-#include "kernel/kern.h" |
-#include "modules//edf.h" |
- |
-int num_aster = 0; |
-#define ASTER_LIM 60 |
-#define DISPLAY_MAX 15 |
-#define ASTER_MAX 70 |
-#define STAT_Y 9 |
- |
-#define APER_MAX 8 |
- |
-/* first numbers runs on a pentium 133, second numbers on a celeron 366 */ |
-#define PER_WCET 30000 /* 6200 */ |
-#define APER_WCET 50000 /* 18400 */ |
-#define CLOCK_WCET 1000 /* 200 */ |
-#define ASTER_WCET 1000 /* 200 */ |
-#define MIN_PERIOD 200 /* 64, in ms */ |
- |
-#define APER_REP 22000 |
- |
-PID aper_table[APER_MAX]; |
- |
-TASK asteroide(void) |
-{ |
- int i; |
- int y = rand() % 7 + 1; |
- |
- int load1,j; |
- |
- char s[2]; |
- |
- s[0] = '*'; s[1] = 0; |
- |
- /*for (;;)*/ { |
- i = 1; |
- while (i < ASTER_LIM) { |
- load1 = 10000; //8000 + rand()%2000; |
- for (j=0; j<load1; j++) { |
- s[0] = '*' + rand() % 100; |
- puts_xy(i,y,rand()%15+1,s); |
- } |
- |
- task_activate(aper_table[rand()%APER_MAX]); |
- task_endcycle(); |
- |
- puts_xy(i,y,WHITE," "); |
- i++; |
- } |
- } |
- num_aster--; |
- return 0; |
-} |
- |
-TASK aper_asteroid(void *a) |
-{ |
- int i; |
- int y = rand() % 7 + 1; |
- |
- int load1,j; |
- int c; |
- |
- char s[2]; |
- |
- c = (int)a; |
- s[0] = '*'; s[1] = 0; |
- |
- for (;;) { |
- i = 1; |
- while (i < ASTER_LIM) { |
- load1 = APER_REP; //8000 + rand()%2000; |
- for (j=0; j<load1; j++) { |
- s[0] = '*' + rand() % 100; |
- puts_xy(i,y,rand()%15+1,s); |
- } |
- s[0] = c; |
- puts_xy(i,y,rand()%15+1,s); |
- |
- task_endcycle(); |
- |
- puts_xy(i,y,WHITE," "); |
- i++; |
- } |
- } |
-} |
- |
-TASK aster() |
-{ |
- PID p; |
- |
- HARD_TASK_MODEL m; |
- int r; |
- int x; // adaptive bandwidth... |
- |
- hard_task_default_model(m); |
- hard_task_def_wcet(m,PER_WCET); |
- hard_task_def_ctrl_jet(m); |
- |
- x = MIN_PERIOD; |
- |
- srand(7); |
- while (1) { |
- if (num_aster < ASTER_MAX) { |
- r = (rand() % 200); |
- |
- hard_task_def_arg(m,(void *)((rand() % 7)+1)); |
- hard_task_def_mit(m, (x+r)*1000); |
- p = task_create("aaa",asteroide,&m,NULL); |
- if (p == -1) |
- { |
- if (x < 500 && errno != ENO_AVAIL_TASK) x += 1; |
- printf_xy(62,3,WHITE,"adapt=%3u err=%d", |
- iq_query_first(&freedesc),errno); |
- } |
- else { |
- num_aster++; |
- printf_xy(62,3,WHITE,"adapt=%3u ",x);//,errno); |
- task_activate(p); |
- x /= 2; |
- if (x<50) x = 50; |
- } |
- } |
- task_endcycle(); |
- } |
-} |
- |
-TASK clock() |
-{ |
- int s = 0, m = 0; |
- |
- while(1) { |
- printf_xy(62,1,WHITE,"%2d:%2d ast=%d",m,s, num_aster); |
- printf_xy(62,2,WHITE,"U=%12u",EDF_usedbandwidth(0)); |
- task_endcycle(); |
- |
- if (++s > 59) { |
- s = 0; |
- m++; |
- } |
- printf_xy(62,1,WHITE,"%2d:%2d ast=%d",m,s, num_aster); |
- printf_xy(62,2,WHITE,"U=%12u",EDF_usedbandwidth(0)); |
- task_endcycle(); |
- } |
-} |
- |
- |
- |
-/* we consider the first ASTER_MAX + 2 tasks from the PID 2 |
- and plot on the screen the elapsed times... */ |
-TASK jetcontrol() |
-{ |
- int i; /* a counter */ |
- TIME sum, max, curr, last[5]; |
- int nact; |
- int j; /* the elements set by jet_gettable */ |
- PID p; |
- |
- |
- kern_cli(); |
- printf_xy(0,STAT_Y,WHITE,"PID ³ Mean T.³ Max T. ³ N.A. ³ Curr. ³ Last1 ³ Last2 ³ Last3 ³ Last4 ³ Last5"); |
- kern_sti(); |
- |
- for (;;) { |
- for (i=0,p=0; i<DISPLAY_MAX+5 && p<MAX_PROC; p++) { |
- if (jet_getstat(p, &sum, &max, &nact, &curr) == -1) continue; |
- |
- for (j=0; j<5; j++) last[j] = 0; |
- jet_gettable(p, &last[0], 5); |
- kern_cli(); |
- printf_xy(0,STAT_Y+i+1,WHITE,"%-3d ³ %-6d ³ %-6d ³ %-4d ³ %-7d ³ %-5d ³ %-5d ³ %-5d ³ %-5d ³ %-5d", |
- p, (int)sum/(nact==0 ? 1 : nact), (int)max, (int)nact, (int)curr, (int)last[0], (int)last[1], (int)last[2], (int)last[3], (int)last[4]); |
- kern_sti(); |
- i++; |
- } |
- task_endcycle(); |
- } |
-} |
- |
-int main(int argc, char **argv) |
-{ |
- PID p1,p2;//,p3,p4,p5,p6; |
- HARD_TASK_MODEL m; |
- NRT_TASK_MODEL m_nrt; |
- SOFT_TASK_MODEL m_aper; |
- int i; |
- |
- clear(); |
- |
- hard_task_default_model(m); |
- hard_task_def_wcet(m,ASTER_WCET); |
- hard_task_def_mit(m,10000); |
- hard_task_def_group(m,1); |
- hard_task_def_ctrl_jet(m); |
- |
- nrt_task_default_model(m_nrt); |
- nrt_task_def_group(m_nrt,1); |
- nrt_task_def_ctrl_jet(m_nrt); |
- |
- p1 = task_create("Aster",aster,&m,NULL); |
- if (p1 == -1) { |
- perror("test7.c(main): Could not create task <aster> ..."); |
- sys_end(); |
- } |
- |
- hard_task_def_mit(m,500000); |
- hard_task_def_wcet(m,CLOCK_WCET); |
- p2 = task_create("Clock",clock,&m,NULL); |
- if (p2 == -1) { |
- perror("test7.c(main): Could not create task <Clock> ..."); |
- sys_end(); |
- } |
- |
- soft_task_default_model(m_aper); |
- soft_task_def_wcet(m_aper,APER_WCET); |
- soft_task_def_ctrl_jet(m_aper); |
- soft_task_def_aperiodic(m_aper); |
- |
- soft_task_def_level(m_aper, 2); |
- aper_table[0] = task_create("JetControl",jetcontrol,&m_aper,NULL); |
- if (aper_table[0] == -1) { |
- perror("test7.c(main): Could not create task <JetControl> ..."); |
- sys_end(); |
- } |
- |
- for (i=1; i<APER_MAX; i++) { |
- soft_task_def_level(m_aper, i/4 + 2); |
- soft_task_def_arg(m_aper, (void *)(i/4 ? 'Û' : '±')); |
- aper_table[i] = task_create("aper",aper_asteroid,&m_aper,NULL); |
- if (aper_table[i] == -1) { |
- perror("test7.c(main): Could not create task <aper> ..."); |
- sys_end(); |
- } |
- } |
- |
- |
- group_activate(1); |
- |
- { |
- struct timespec t; |
- do { |
- sys_gettime(&t); |
- } while (t.tv_sec < 60); |
- } |
- |
- sys_end(); |
- return 0; |
-} |
- |
Index: tags/rel_1_22/base/aster4.c |
=================================================================== |
--- tags/rel_1_22/base/aster4.c (revision 1310) |
+++ tags/rel_1_22/base/aster4.c (nonexistent) |
@@ -1,399 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * |
- * CVS : $Id: aster4.c,v 1.1 2002-11-11 08:22:45 pj Exp $ |
- |
- Test Number 13 (D): |
- |
- this is a part of the classic Hartik demo Aster, and it is based on aster 3. |
- |
- The demo creates: |
- - a set of TBS tasks assigned to 2 TBS servers initialized with different bandwidth. |
- |
- - a set of periodic tasks, just to make noise (function asteroide) |
- |
- - a set of CBS tasks that are created to fill the available free |
- bandwidth (function soft_aster) |
- |
- - a few service task (the one that creates the CBS tasks (aster), a clock, |
- JET info visualization |
- |
- - a set of never ending "system tasks" that simulate a device driver |
- task that will end only at shutdown (function aper_asteroid) |
- |
- - a keyboard task that will execute an hook to terminate the system |
- |
-*/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/cbs.h" |
-#include "drivers/keyb.h" |
- |
-int num_aster = 0; |
-#define ASTER_LIM 60 |
-#define DISPLAY_MAX 15 |
-#define ASTER_MAX 70 |
-#define STAT_Y 9 |
- |
-#define PER_MAX 5 |
-#define APER_MAX 8 |
- |
-// These numbers works on a Pentium 133 */ |
-#define PER_WCET 25000 |
-#define APER_WCET 53000 |
-#define CLOCK_WCET 1000 |
-#define ASTER_WCET 1000 |
-#define SOFT_MET 6300 |
- |
-#define APER_REP 22000 |
- |
-PID aper_table[APER_MAX]; |
- |
-int shutting_down = 0; |
- |
-TASK asteroide(void) |
-{ |
- int i; |
- int y = rand() % 7 + 1; |
- |
- int load1,j; |
- |
- char s[2]; |
- |
- s[0] = '*'; s[1] = 0; |
- |
- for (;;) { |
- i = 1; |
- while (i < ASTER_LIM) { |
- load1 = 10000; //8000 + rand()%2000; |
- for (j=0; j<load1; j++) { |
- s[0] = '*' + rand() % 100; |
- puts_xy(i,y,rand()%15+1,s); |
- } |
- |
- task_activate(aper_table[rand()%APER_MAX]); |
- task_endcycle(); |
- |
- puts_xy(i,y,WHITE," "); |
- i++; |
- } |
- } |
- //num_aster--; |
-} |
- |
-TASK aper_asteroid(void *a) |
-{ |
- int i; |
- int y = rand() % 7 + 1; |
- |
- int load1,j; |
- int c; |
- |
- char s[2]; |
- |
- c = (int)a; |
- s[0] = '*'; s[1] = 0; |
- |
- for (;;) { |
- i = 1; |
- while (i < ASTER_LIM) { |
- load1 = APER_REP; //8000 + rand()%2000; |
- for (j=0; j<load1; j++) { |
- s[0] = '*' + rand() % 100; |
- puts_xy(i,y,rand()%15+1,s); |
- } |
- s[0] = c; |
- puts_xy(i,y,rand()%15+1,s); |
- |
- if (shutting_down) { |
- cprintf("Ending System Task %d\n",exec_shadow); |
- return 0; |
- } |
- |
- task_endcycle(); |
- |
- puts_xy(i,y,WHITE," "); |
- i++; |
- } |
- } |
-} |
- |
-TASK soft_aster(void) |
-{ |
- int i; |
- int y = rand() % 7 + 1; |
- |
- int load1,j; |
- |
- char s[2]; |
- |
- s[0] = '*'; s[1] = 0; |
- |
- i = 1; |
- while (i < ASTER_LIM) { |
- load1 = 1000 + rand()%9000; |
- for (j=0; j<load1; j++) { |
- s[0] = '*' + rand() % 100; |
- puts_xy(i,y,rand()%15+1,s); |
- } |
- s[0] = 1; |
- puts_xy(i,y,rand()%15+1,s); |
- |
- task_activate(aper_table[rand()%APER_MAX]); |
- task_endcycle(); |
- |
- puts_xy(i,y,WHITE," "); |
- i++; |
- } |
- num_aster--; |
- return 0; |
-} |
- |
-TASK aster() |
-{ |
- PID p; |
- |
- HARD_TASK_MODEL m; |
- SOFT_TASK_MODEL m_soft; |
- int r; |
- int x; // adaptive bandwidth... |
- |
- srand(7); |
- |
- /* create a set of periodic tasks, just to make noise */ |
- hard_task_default_model(m); |
- hard_task_def_wcet(m,PER_WCET); |
- hard_task_def_ctrl_jet(m); |
- for (x=0; x<PER_MAX; x++) { |
- r = (rand() % 200); |
- hard_task_def_mit(m, (64+r)*1000); |
- p = task_create("per",asteroide,&m,NULL); |
- if (p!=-1) task_activate(p); |
- } |
- |
- soft_task_default_model(m_soft); |
- soft_task_def_met(m_soft,SOFT_MET); |
- soft_task_def_ctrl_jet(m_soft); |
- |
- x = 64; |
- |
- while (1) { |
- if (num_aster < ASTER_MAX) { |
- r = (rand() % 200); |
- |
- soft_task_def_period(m_soft, (x+r)*1000); |
- p = task_create("aaa",soft_aster,&m_soft,NULL); |
- if (p == -1) |
- { |
- if (x < 500 && errno != ENO_AVAIL_TASK) x += 1; |
- printf_xy(62,3,WHITE,"adapt=%3u err=%d", |
- iq_query_first(&freedesc),errno); |
- } |
- else { |
- num_aster++; |
- printf_xy(62,3,WHITE,"adapt=%3u ",x);//,errno); |
- task_activate(p); |
- x /= 2; |
- if (x<50) x = 50; |
- } |
- } |
- task_endcycle(); |
- } |
-} |
- |
-TASK clock() |
-{ |
- int s = 0, m = 0; |
- |
- while(1) { |
- printf_xy(62,1,WHITE,"%2d:%2d ast=%d",m,s, num_aster); |
- printf_xy(62,2,WHITE,"Uedf=%12u",EDF_usedbandwidth(0)); |
- printf_xy(62,4,WHITE,"Ucbs=%12u",CBS_usedbandwidth(4)); |
- task_endcycle(); |
- |
- if (++s > 59) { |
- s = 0; |
- m++; |
- } |
- printf_xy(62,1,WHITE,"%2d:%2d ast=%d",m,s, num_aster); |
- printf_xy(62,2,WHITE,"Uedf=%12u",EDF_usedbandwidth(0)); |
- printf_xy(62,4,WHITE,"Ucbs=%12u",CBS_usedbandwidth(4)); |
- task_endcycle(); |
- } |
-} |
- |
- |
- |
-/* we consider the first ASTER_MAX + 2 tasks from the PID 2 |
- and plot on the screen the elapsed times... */ |
-TASK jetcontrol() |
-{ |
- int i; /* a counter */ |
- TIME sum, max, curr, last[5]; |
- int nact; |
- int j; /* the elements set by jet_gettable */ |
- PID p; |
- |
- |
- kern_cli(); |
- printf_xy(0,STAT_Y,WHITE,"PID ³ Mean T.³ Max T. ³ N.A. ³ Curr. ³ Last1 ³ Last2 ³ Last3 ³ Last4 ³ Last5"); |
- kern_sti(); |
- |
- for (;;) { |
- for (i=0,p=0; i<DISPLAY_MAX+5 && p<MAX_PROC; p++) { |
- if (jet_getstat(p, &sum, &max, &nact, &curr) == -1 || |
- (proc_table[p].pclass & 0xFF00) == HARD_PCLASS) continue; |
- |
- for (j=0; j<5; j++) last[j] = 0; |
- jet_gettable(p, &last[0], 5); |
- kern_cli(); |
- if (proc_table[p].task_level == 4) |
- printf_xy(0,STAT_Y+i+1,WHITE,"%-3d ³ %-6d ³ %-6d ³ %-4d ³ %-7d ³ %-5d ³ %-5d ³ %-5d ³ %-5d ³ %-5d", |
- p, (int)sum/(nact==0 ? 1 : nact), (int)max, nact, (int)CBS_get_nact(4,p), (int)last[0], (int)last[1], (int)last[2], (int)last[3], (int)last[4]); |
- else |
- printf_xy(0,STAT_Y+i+1,WHITE,"%-3d ³ %-6d ³ %-6d ³ %-4d ³ %-7d ³ %-5d ³ %-5d ³ %-5d ³ %-5d ³ %-5d", |
- p, (int)sum/(nact==0 ? 1 : nact), (int)max, nact, (int)curr, (int)last[0], (int)last[1], (int)last[2], (int)last[3], (int)last[4]); |
- kern_sti(); |
- i++; |
- } |
- } |
-} |
- |
-void endfun(KEY_EVT *k) |
-{ |
- sys_end(); |
-} |
- |
-void exiting(void *arg) |
-{ |
- cprintf("System shut down...\n"); |
- shutting_down = 1; |
-} |
- |
-int main(int argc, char **argv) |
-{ |
- KEY_EVT k; |
- |
- PID p1,p2,p3; |
- HARD_TASK_MODEL m; |
- SOFT_TASK_MODEL m_aper; |
- SOFT_TASK_MODEL m_soft; |
- int i; |
- |
- k.flag = 0; |
- k.scan = KEY_ENT; |
- k.ascii = 13; |
- keyb_hook(k, endfun); |
- |
- clear(); |
- cprintf("Press ENTER to end the demo..."); |
- |
- sys_atrunlevel(exiting, NULL, RUNLEVEL_SHUTDOWN); |
- |
- hard_task_default_model(m); |
- hard_task_def_wcet(m,ASTER_WCET); |
- hard_task_def_mit(m,10000); |
- hard_task_def_group(m,1); |
- hard_task_def_ctrl_jet(m); |
- |
- soft_task_default_model(m_soft); |
- soft_task_def_met(m_soft,1000); |
- soft_task_def_period(m_soft,100000); |
- soft_task_def_group(m_soft,1); |
- soft_task_def_ctrl_jet(m_soft); |
- soft_task_def_aperiodic(m_soft); |
- |
- |
- p1 = task_create("Aster",aster,&m,NULL); |
- if (p1 == -1) { |
- perror("aster4.c(main): Could not create task <aster> ..."); |
- sys_end(); |
- } |
- |
- hard_task_def_mit(m,500000); |
- hard_task_def_wcet(m,CLOCK_WCET); |
- p2 = task_create("Clock",clock,&m,NULL); |
- if (p2 == -1) { |
- perror("aster4.c(main): Could not create task <Clock> ..."); |
- sys_end(); |
- } |
- |
- p3 = task_create("JetControl",jetcontrol,&m_soft,NULL); |
- if (p3 == -1) { |
- perror("aster4.c(main): Could not create task <JetControl> ..."); |
- sys_end(); |
- } |
- |
- soft_task_default_model(m_aper); |
- soft_task_def_wcet(m_aper,APER_WCET); |
- soft_task_def_ctrl_jet(m_aper); |
- soft_task_def_system(m_aper); |
- soft_task_def_aperiodic(m_aper); |
- |
- for (i=0; i<APER_MAX; i++) { |
- soft_task_def_level(m_aper, i/4 + 2); |
- soft_task_def_arg(m_aper, (void *)(i/4 ? 'Û' : '±')); |
- aper_table[i] = task_create("aper",aper_asteroid,&m_aper,NULL); |
- if (aper_table[i] == -1) { |
- perror("aster4.c(main): Could not create task <aper> ..."); |
- sys_end(); |
- } |
- } |
- |
- group_activate(1); |
- return 0; |
-} |
- |
Index: tags/rel_1_22/base/isemdemo.c |
=================================================================== |
--- tags/rel_1_22/base/isemdemo.c (revision 1310) |
+++ tags/rel_1_22/base/isemdemo.c (nonexistent) |
@@ -1,98 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: isemdemo.c,v 1.1 2002-11-11 08:22:45 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1 $ |
- Last update: $Date: 2002-11-11 08:22:45 $ |
- ------------ |
- |
- The simplest initialization file |
- |
- The tick is set to TICK ms. |
- |
- This file contains the 2 functions needed to initialize the system. |
- |
- These functions register the following levels: |
- |
- a RR (Round Robin) level |
- a Dummy level |
- |
- It can accept these task models: |
- |
- NRT_TASK_MODEL at level 0 |
- |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
- |
- |
-#include "kernel/kern.h" |
-#include "modules/rr.h" |
-#include "modules/dummy.h" |
-#include "modules/sem.h" |
- |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 300 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 10000 |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
Index: tags/rel_1_22/base/aster5.c |
=================================================================== |
--- tags/rel_1_22/base/aster5.c (revision 1310) |
+++ tags/rel_1_22/base/aster5.c (nonexistent) |
@@ -1,490 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai, Gerardo Lamastra and Giuseppe Lipari |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * |
- * CVS : $Id: aster5.c,v 1.2 2003-01-07 17:10:15 pj Exp $ |
- |
- this is a part of the classic Hartik demo Aster. |
- |
- it is based on test 13 (d), and use the CBS to serve the periodic tasks. |
- |
- There are not periodic tasks, only CBS tasks. |
- |
- The tasks use a PI, NPP or NOP mutex to access the video memory. |
- |
- A flag (LONGSC) is provided to try long and short critical sections. |
- |
- This demo is really interesting because you can note the behavior of |
- the system, and the differences between the various protocols... |
- |
-*/ |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/cbs.h" |
-#include "drivers/keyb.h" |
- |
-int num_aster = 0; |
-#define ASTER_LIM 60 |
-#define DISPLAY_MAX 15 |
-#define ASTER_MAX 70 |
-#define STAT_Y 9 |
- |
-#define PER_MAX 5 |
-#define APER_MAX 8 |
- |
-#define PER_WCET 6200 |
-#define APER_WCET 18400 |
-#define JET_WCET 10000 |
-#define JET_PERIOD 100000 |
- |
-#define APER_REP 22000 |
- |
-//PID aper_table[APER_MAX]; |
- |
-mutex_t m1; |
- |
- |
-#define PIMUTEX |
-//#define NPPMUTEX |
-//#define NOPMUTEX |
- |
-#define LONGSC |
- |
-#ifdef LONGSC |
-#define SOFT_MET 3000 /* 3000 12000 */ |
-#define CLOCK_WCET 400 /* 200 300*/ |
-#define ASTER_WCET 400 /* 200 300*/ |
-#else |
-#define SOFT_MET 80000 /* 4500 */ |
-#define CLOCK_WCET 2000 /* 200*/ |
-#define ASTER_WCET 2000 /* 200*/ |
-#endif |
- |
-TASK asteroide(void) |
-{ |
- int i; |
- int y = rand() % 7 + 1; |
- |
- int load1,j; |
- |
- char s[2]; |
- |
- s[0] = '*'; s[1] = 0; |
- |
- for (;;) { |
- i = 1; |
- while (i < ASTER_LIM) { |
- load1 = 10000; //8000 + rand()%2000; |
-#ifdef LONGSC |
- mutex_lock(&m1); |
-#endif |
- for (j=0; j<load1; j++) { |
- s[0] = '*' + rand() % 100; |
-#ifndef LONGSC |
- mutex_lock(&m1); |
-#endif |
- puts_xy(i,y,rand()%15+1,s); |
-#ifndef LONGSC |
- mutex_unlock(&m1); |
-#endif |
- } |
-#ifdef LONGSC |
- mutex_unlock(&m1); |
-#endif |
- |
- // task_activate(aper_table[rand()%APER_MAX]); |
- task_endcycle(); |
- |
- mutex_lock(&m1); |
- puts_xy(i,y,WHITE," "); |
- mutex_unlock(&m1); |
- i++; |
- } |
- } |
- //num_aster--; |
-} |
- |
-TASK aper_asteroid(void *a) |
-{ |
- int i; |
- int y = rand() % 7 + 1; |
- |
- int load1,j; |
- int c; |
- |
- char s[2]; |
- |
- c = (int)a; |
- s[0] = '*'; s[1] = 0; |
- |
- for (;;) { |
- i = 1; |
- while (i < ASTER_LIM) { |
- load1 = APER_REP; //8000 + rand()%2000; |
-#ifdef LONGSC |
- mutex_lock(&m1); |
-#endif |
- for (j=0; j<load1; j++) { |
- s[0] = '*' + rand() % 100; |
-#ifndef LONGSC |
- mutex_lock(&m1); |
-#endif |
- puts_xy(i,y,rand()%15+1,s); |
-#ifndef LONGSC |
- mutex_unlock(&m1); |
-#endif |
- } |
- s[0] = c; |
-#ifndef LONGSC |
- mutex_lock(&m1); |
-#endif |
- puts_xy(i,y,rand()%15+1,s); |
- mutex_unlock(&m1); |
- |
- task_endcycle(); |
- |
- mutex_lock(&m1); |
- puts_xy(i,y,WHITE," "); |
- mutex_unlock(&m1); |
- i++; |
- } |
- } |
-} |
- |
-TASK soft_aster(void) |
-{ |
- int i; |
- int y = rand() % 7 + 1; |
- |
- int load1,j; |
- |
- char s[2]; |
- |
- s[0] = '*'; s[1] = 0; |
- |
- /*for (;;)*/ { |
- i = 1; |
- while (i < ASTER_LIM) { |
- load1 = 1000 + rand()%9000; |
-#ifdef LONGSC |
- mutex_lock(&m1); |
-#endif |
- for (j=0; j<load1; j++) { |
- s[0] = '*' + rand() % 100; |
-#ifndef LONGSC |
- mutex_lock(&m1); |
-#endif |
- puts_xy(i,y,rand()%15+1,s); |
-#ifndef LONGSC |
- mutex_unlock(&m1); |
-#endif |
- } |
- s[0] = 1; |
-#ifndef LONGSC |
- mutex_lock(&m1); |
-#endif |
- puts_xy(i,y,rand()%15+1,s); |
- mutex_unlock(&m1); |
- |
- // task_activate(aper_table[rand()%APER_MAX]); |
- task_endcycle(); |
- |
- mutex_lock(&m1); |
- puts_xy(i,y,WHITE," "); |
- mutex_unlock(&m1); |
- i++; |
- } |
- } |
- num_aster--; |
- return 0; |
-} |
- |
-TASK aster() |
-{ |
- PID p; |
- // HARD_TASK_MODEL m; |
- SOFT_TASK_MODEL m_soft; |
- int r; |
- int x; // adaptive bandwidth... |
- |
- srand(7); |
- |
- /* periodic_task_default_model(m,0,PER_WCET); |
- periodic_task_def_ctrl_jet(m); |
- for (x=0; x<PER_MAX; x++) { |
- r = (rand() % 200); |
- periodic_task_def_period(m, (64+r)*1000); |
- p = task_create("per",asteroide,&m,NULL); |
- if (p!=-1) task_activate(p); |
- } |
- */ |
- soft_task_default_model(m_soft); |
- soft_task_def_met(m_soft,SOFT_MET); |
- soft_task_def_ctrl_jet(m_soft); |
- |
- x = 128; //64; |
- |
- while (1) { |
- /* { |
- PID p; |
- int x; |
- p = level_table[0]->level_scheduler(0); |
- printf_xy(1,8,WHITE," "); |
- |
- x = 0; |
- do { |
- printf_xy(3*x+1,8,WHITE,"%3d",p); |
- p = proc_table[p].next; |
- x++; |
- } while (p != NIL); |
- } |
- */ |
- if (num_aster < ASTER_MAX) { |
- r = (rand() % 200); |
- |
- soft_task_def_period(m_soft, (x+r)*1000); |
- p = task_create("aaa",soft_aster,&m_soft,NULL); |
- if (p == -1) |
- { |
- if (x < 500 && errno != ENO_AVAIL_TASK) x += 1; |
- mutex_lock(&m1); |
- printf_xy(62,3,WHITE,"adapt=%3u err=%d", |
- iq_query_first(&freedesc),errno); |
- mutex_unlock(&m1); |
- } |
- else { |
- num_aster++; |
- mutex_lock(&m1); |
- printf_xy(62,3,WHITE,"adapt=%3u ",x);//,errno); |
- mutex_unlock(&m1); |
- |
- task_activate(p); |
- x /= 2; |
- if (x<50) x = 50; |
- } |
- } |
- task_endcycle(); |
- } |
-} |
- |
-TASK clock() |
-{ |
- int s = 0, m = 0; |
- |
- while(1) { |
- mutex_lock(&m1); |
- printf_xy(62,1,WHITE,"%2d:%2d ast=%d",m,s, num_aster); |
- printf_xy(62,2,WHITE,"Uedf=%12u",EDF_usedbandwidth(0)); |
- printf_xy(62,4,WHITE,"Ucbs=%12u",CBS_usedbandwidth(2)); |
- |
- mutex_unlock(&m1); |
- task_endcycle(); |
- |
- if (++s > 59) { |
- s = 0; |
- m++; |
- } |
- mutex_lock(&m1); |
- printf_xy(62,1,WHITE,"%2d:%2d ast=%d",m,s, num_aster); |
- printf_xy(62,2,WHITE,"Uedf=%12u",EDF_usedbandwidth(0)); |
- printf_xy(62,4,WHITE,"Ucbs=%12u",CBS_usedbandwidth(2)); |
- mutex_unlock(&m1); |
- task_endcycle(); |
- } |
-} |
- |
- |
- |
-/* we consider the first ASTER_MAX + 2 tasks from the PID 2 |
- and plot on the screen the elapsed times... */ |
-TASK jetcontrol() |
-{ |
- int i; /* a counter */ |
- TIME sum, max, curr, last[5]; |
- int nact; |
- int j; /* the elements set by jet_gettable */ |
- PID p; |
- |
- |
- mutex_lock(&m1); |
- printf_xy(0,STAT_Y,WHITE,"PID ³ Mean T.³ Max T. ³ N.A. ³ Curr. ³ Last1 ³ Last2 ³ Last3 ³ Last4 ³ Last5"); |
- mutex_unlock(&m1); |
- |
- for (;;) { |
- for (i=0,p=0; i<DISPLAY_MAX+5 && p<MAX_PROC; p++) { |
- if (jet_getstat(p, &sum, &max, &nact, &curr) == -1 /*|| |
- (proc_table[p].pclass & 0xFF00) == APERIODIC_PCLASS || |
- (proc_table[p].pclass & 0xFF00) == PERIODIC_PCLASS*/ ) continue; |
- |
- for (j=0; j<5; j++) last[j] = 0; |
- jet_gettable(p, &last[0], 5); |
- mutex_lock(&m1); |
- if (proc_table[p].task_level == 2) |
- printf_xy(0,STAT_Y+i+1,WHITE,"%-3d ³ %-6d ³ %-6d ³ %-4d ³p%-7d ³ %-5d ³ %-5d ³ %-5d ³ %-5d ³ %-5d", |
- p, (int)sum/(nact==0 ? 1 : nact), (int)max, nact, (int)CBS_get_nact(2,p), (int)last[0], (int)last[1], (int)last[2], (int)last[3], (int)last[4]); |
- // p, sum/(nact==0 ? 1 : nact), max, proc_table[p].avail_time, proc_table[p].status, proc_table[p].shadow, proc_table[p].timespec_priority.tv_sec,proc_table[p].timespec_priority.tv_nsec/1000 , CBS_get_nact(2,p), last[4]); |
- else |
- printf_xy(0,STAT_Y+i+1,WHITE,"%-3d ³ %-6d ³ %-6d ³ %-4d ³ %-7d ³ %-5d ³ %-5d ³ %-5d ³ %-5d ³ %-5d", |
- p, (int)sum/(nact==0 ? 1 : nact), (int)max, nact, (int)curr, (int)last[0], (int)last[1], (int)last[2], (int)last[3], (int)last[4]); |
- // p, (int)sum/(nact==0 ? 1 : nact), (int)max, nact, (int)proc_table[p].status, (int)proc_table[p].shadow, (int)proc_table[p].timespec_priority.tv_sec,(int)proc_table[p].timespec_priority.tv_nsec/1000 , (int)last[3], (int)last[4]); |
- mutex_unlock(&m1); |
- i++; |
- } |
- } |
-} |
- |
-void fine(KEY_EVT *e) |
-{ |
- sys_end(); |
-} |
- |
-int main(int argc, char **argv) |
-{ |
- PID p1,p2,p3;//,p4,p5,p6; |
- HARD_TASK_MODEL m; |
- // NRT_TASK_MODEL m_nrt; |
- SOFT_TASK_MODEL m_aper; |
- SOFT_TASK_MODEL m_soft; |
- // int i; |
- struct timespec fineprg; |
- |
-#ifdef PIMUTEX |
- PI_mutexattr_t a; |
-#endif |
- |
-#ifdef NPPMUTEX |
- NPP_mutexattr_t a; |
-#endif |
- |
-#ifdef NOPMUTEX |
- NOP_mutexattr_t a; |
-#endif |
- |
- KEY_EVT emerg; |
- //keyb_set_map(itaMap); |
- emerg.ascii = 'x'; |
- emerg.scan = KEY_X; |
- emerg.flag = ALTL_BIT; |
- keyb_hook(emerg,fine); |
- |
- clear(); |
- |
- hard_task_default_model(m); |
- hard_task_def_wcet(m,ASTER_WCET); |
- hard_task_def_mit(m,100000); |
- hard_task_def_group(m,1); |
- hard_task_def_ctrl_jet(m); |
- |
- // nrt_task_default_model(m_nrt); |
- // nrt_task_def_group(m_nrt,1); |
- // nrt_task_def_ctrl_jet(m_nrt); |
- |
- |
- soft_task_default_model(m_aper); |
- soft_task_def_group(m_aper,1); |
- soft_task_def_ctrl_jet(m_aper); |
- soft_task_def_aperiodic(m_aper); |
- |
- soft_task_default_model(m_soft); |
- soft_task_def_period(m_soft,JET_PERIOD); |
- soft_task_def_met(m_soft,JET_WCET); |
- soft_task_def_group(m_soft,1); |
- soft_task_def_ctrl_jet(m_soft); |
- soft_task_def_aperiodic(m_soft); |
- |
- |
- p1 = task_create("Aster",aster,&m,NULL); |
- if (p1 == -1) { |
- perror("test7.c(main): Could not create task <aster> ..."); |
- sys_end(); |
- l1_exit(-1); |
- } |
- |
- hard_task_def_mit(m,500000); |
- hard_task_def_wcet(m,CLOCK_WCET); |
- p2 = task_create("Clock",clock,&m,NULL); |
- if (p2 == -1) { |
- perror("test7.c(main): Could not create task <Clock> ..."); |
- sys_end(); |
- l1_exit(-1); |
- } |
- |
- // p3 = task_create("JetControl",jetcontrol,&m_nrt,NULL); |
- p3 = task_create("JetControl",jetcontrol,&m_soft,NULL); |
- if (p2 == -1) { |
- perror("test7.c(main): Could not create task <JetControl> ..."); |
- sys_end(); |
- l1_exit(-1); |
- } |
- /* |
- aperiodic_task_default_model(m_aper,APER_WCET); |
- aperiodic_task_def_ctrl_jet(m_aper); |
- aperiodic_task_def_system(m_aper); |
- |
- for (i=0; i<APER_MAX; i++) { |
- aperiodic_task_def_level(m_aper, i/4 + 2); |
- aperiodic_task_def_arg(m_aper, (i/4 ? 'Û' : '±')); |
- aper_table[i] = task_create("aper",aper_asteroid,&m_aper,NULL); |
- if (aper_table[i] == -1) { |
- perror("test7.c(main): Could not create task <aper> ..."); |
- sys_end(); |
- l1_exit(-1); |
- } |
- } |
- */ |
- task_nopreempt(); |
- |
-#ifdef PIMUTEX |
- PI_mutexattr_default(a); |
-#endif |
- |
-#ifdef NPPMUTEX |
- NPP_mutexattr_default(a); |
-#endif |
- |
-#ifdef NOPMUTEX |
- NOP_mutexattr_default(a); |
-#endif |
- |
- mutex_init(&m1, &a); |
- |
- fineprg.tv_sec = 1800; |
- fineprg.tv_nsec = 0; |
- //kern_event_post(&fineprg,(void (*)(void *))fine,NULL); |
- group_activate(1); |
- return 0; |
-} |
- |
Index: tags/rel_1_22/base/aster6.c |
=================================================================== |
--- tags/rel_1_22/base/aster6.c (revision 1310) |
+++ tags/rel_1_22/base/aster6.c (nonexistent) |
@@ -1,484 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai, Gerardo Lamastra and Giuseppe Lipari |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * |
- * CVS : $Id: aster6.c,v 1.3 2004-01-17 18:43:07 giacomo Exp $ |
- |
- this is a part of the classic Hartik demo Aster. |
- |
- it is based on test 17 (h), and the JobControl Task uses an |
- SOFT_TASK_MODEL served by a polling server |
- |
-*/ |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/cbs.h" |
-#include "drivers/keyb.h" |
- |
-int num_aster = 0; |
-#define ASTER_LIM 60 |
-#define DISPLAY_MAX 15 |
-#define ASTER_MAX 70 |
-#define STAT_Y 9 |
- |
-#define PER_MAX 5 |
-#define APER_MAX 8 |
- |
-#define PER_WCET 6200 |
-#define APER_WCET 18400 |
-#define JET_WCET 10000 |
- |
-#define APER_REP 22000 |
- |
-PID aper_table[APER_MAX]; |
- |
-mutex_t m1; |
- |
- |
-#define PIMUTEX |
-//#define NPPMUTEX |
-//#define NOPMUTEX |
- |
-//#define LONGSC |
- |
-#ifdef LONGSC |
-#define SOFT_MET 3000 /* 12000 */ |
-#define CLOCK_WCET 200 /* 300*/ |
-#define ASTER_WCET 200 /* 300*/ |
-#else |
-#define SOFT_MET 80000 /* 4500 */ |
-#define CLOCK_WCET 2000 /* 200*/ |
-#define ASTER_WCET 2000 /* 200*/ |
-#endif |
- |
-TASK asteroide(void) |
-{ |
- int i; |
- int y = rand() % 7 + 1; |
- |
- int load1,j; |
- |
- char s[2]; |
- |
- s[0] = '*'; s[1] = 0; |
- |
- for (;;) { |
- i = 1; |
- while (i < ASTER_LIM) { |
- load1 = 10000; //8000 + rand()%2000; |
-#ifdef LONGSC |
- mutex_lock(&m1); |
-#endif |
- for (j=0; j<load1; j++) { |
- s[0] = '*' + rand() % 100; |
-#ifndef LONGSC |
- mutex_lock(&m1); |
-#endif |
- puts_xy(i,y,rand()%15+1,s); |
-#ifndef LONGSC |
- mutex_unlock(&m1); |
-#endif |
- } |
-#ifdef LONGSC |
- mutex_unlock(&m1); |
-#endif |
- |
- task_activate(aper_table[rand()%APER_MAX]); |
- task_endcycle(); |
- |
- mutex_lock(&m1); |
- puts_xy(i,y,WHITE," "); |
- mutex_unlock(&m1); |
- i++; |
- } |
- } |
- //num_aster--; |
-} |
- |
-TASK aper_asteroid(void *a) |
-{ |
- int i; |
- int y = rand() % 7 + 1; |
- |
- int load1,j; |
- int c; |
- |
- char s[2]; |
- |
- c = (int)a; |
- s[0] = '*'; s[1] = 0; |
- |
- for (;;) { |
- i = 1; |
- while (i < ASTER_LIM) { |
- load1 = APER_REP; //8000 + rand()%2000; |
-#ifdef LONGSC |
- mutex_lock(&m1); |
-#endif |
- for (j=0; j<load1; j++) { |
- s[0] = '*' + rand() % 100; |
-#ifndef LONGSC |
- mutex_lock(&m1); |
-#endif |
- puts_xy(i,y,rand()%15+1,s); |
-#ifndef LONGSC |
- mutex_unlock(&m1); |
-#endif |
- } |
- s[0] = c; |
-#ifndef LONGSC |
- mutex_lock(&m1); |
-#endif |
- puts_xy(i,y,rand()%15+1,s); |
- mutex_unlock(&m1); |
- |
- task_endcycle(); |
- |
- mutex_lock(&m1); |
- puts_xy(i,y,WHITE," "); |
- mutex_unlock(&m1); |
- i++; |
- } |
- } |
-} |
- |
-TASK soft_aster(void) |
-{ |
- int i; |
- int y = rand() % 7 + 1; |
- |
- int load1,j; |
- |
- char s[2]; |
- |
- s[0] = '*'; s[1] = 0; |
- |
- /*for (;;)*/ { |
- i = 1; |
- while (i < ASTER_LIM) { |
- load1 = 1000 + rand()%9000; |
-#ifdef LONGSC |
- mutex_lock(&m1); |
-#endif |
- for (j=0; j<load1; j++) { |
- s[0] = '*' + rand() % 100; |
-#ifndef LONGSC |
- mutex_lock(&m1); |
-#endif |
- puts_xy(i,y,rand()%15+1,s); |
-#ifndef LONGSC |
- mutex_unlock(&m1); |
-#endif |
- } |
- s[0] = 1; |
-#ifndef LONGSC |
- mutex_lock(&m1); |
-#endif |
- puts_xy(i,y,rand()%15+1,s); |
- mutex_unlock(&m1); |
- |
- task_activate(aper_table[rand()%APER_MAX]); |
- task_endcycle(); |
- |
- mutex_lock(&m1); |
- puts_xy(i,y,WHITE," "); |
- mutex_unlock(&m1); |
- i++; |
- } |
- } |
- num_aster--; |
- return 0; |
-} |
- |
-TASK aster() |
-{ |
- PID p; |
- |
- // HARD_TASK_MODEL m; |
- SOFT_TASK_MODEL m_soft; |
- int r; |
- int x; // adaptive bandwidth... |
- |
- srand(7); |
- |
- /* periodic_task_default_model(m,0,PER_WCET); |
- periodic_task_def_ctrl_jet(m); |
- for (x=0; x<PER_MAX; x++) { |
- r = (rand() % 200); |
- periodic_task_def_period(m, (64+r)*1000); |
- p = task_create("per",asteroide,&m,NULL); |
- if (p!=-1) task_activate(p); |
- } |
- */ |
- soft_task_default_model(m_soft); |
- soft_task_def_met(m_soft,SOFT_MET); |
- soft_task_def_ctrl_jet(m_soft); |
- |
- x = 128; //64; |
- |
- while (1) { |
- /* { |
- PID p; |
- int x; |
- p = level_table[0]->level_scheduler(0); |
- printf_xy(1,8,WHITE," "); |
- |
- x = 0; |
- do { |
- printf_xy(3*x+1,8,WHITE,"%3d",p); |
- p = proc_table[p].next; |
- x++; |
- } while (p != NIL); |
- } |
- */ |
- if (num_aster < ASTER_MAX) { |
- r = (rand() % 200); |
- |
- soft_task_def_period(m_soft, (x+r)*1000); |
- p = task_create("aaa",soft_aster,&m_soft,NULL); |
- if (p == -1) |
- { |
- if (x < 500 && errno != ENO_AVAIL_TASK) x += 1; |
- mutex_lock(&m1); |
- printf_xy(62,3,WHITE,"adapt=%3u err=%d", |
- iq_query_first(&freedesc),errno); |
- mutex_unlock(&m1); |
- } |
- else { |
- num_aster++; |
- mutex_lock(&m1); |
- printf_xy(62,3,WHITE,"adapt=%3u ",x);//,errno); |
- mutex_unlock(&m1); |
- task_activate(p); |
- x /= 2; |
- if (x<50) x = 50; |
- } |
- } |
- task_endcycle(); |
- } |
-} |
- |
-TASK clock() |
-{ |
- int s = 0, m = 0; |
- |
- while(1) { |
- mutex_lock(&m1); |
- printf_xy(62,1,WHITE,"%2d:%2d ast=%d",m,s, num_aster); |
- printf_xy(62,2,WHITE,"Uedf=%12u",EDF_usedbandwidth(0)); |
- printf_xy(62,4,WHITE,"Ucbs=%12u",CBS_usedbandwidth(2)); |
- |
- mutex_unlock(&m1); |
- |
- task_endcycle(); |
- |
- if (++s > 59) { |
- s = 0; |
- m++; |
- } |
- mutex_lock(&m1); |
- printf_xy(62,1,WHITE,"%2d:%2d ast=%d",m,s, num_aster); |
- printf_xy(62,2,WHITE,"Uedf=%12u",EDF_usedbandwidth(0)); |
- printf_xy(62,4,WHITE,"Ucbs=%12u",CBS_usedbandwidth(2)); |
- mutex_unlock(&m1); |
- task_endcycle(); |
- } |
-} |
- |
- |
- |
-/* we consider the first ASTER_MAX + 2 tasks from the PID 2 |
- and plot on the screen the elapsed times... */ |
-TASK jetcontrol() |
-{ |
- int i; /* a counter */ |
- TIME sum, max, curr, last[5]; |
- int nact; |
- int j; /* the elements set by jet_gettable */ |
- PID p; |
- |
- |
- mutex_lock(&m1); |
- printf_xy(0,STAT_Y,WHITE,"PID ³ Mean T.³ Max T. ³ N.A. ³ Curr. ³ Last1 ³ Last2 ³ Last3 ³ Last4 ³ Last5"); |
- mutex_unlock(&m1); |
- |
- for (;;) { |
- for (i=0,p=0; i<DISPLAY_MAX+5 && p<MAX_PROC; p++) { |
- if (jet_getstat(p, &sum, &max, &nact, &curr) == -1 /*|| |
- (proc_table[p].pclass & 0xFF00) == APERIODIC_PCLASS || |
- (proc_table[p].pclass & 0xFF00) == PERIODIC_PCLASS*/ ) continue; |
- |
- for (j=0; j<5; j++) last[j] = 0; |
- jet_gettable(p, &last[0], 5); |
- mutex_lock(&m1); |
- if (proc_table[p].task_level == 2) |
- printf_xy(0,STAT_Y+i+1,WHITE,"%-3d ³ %-6d ³ %-6d ³ %-4d ³ %-7d ³ %-5d ³ %-5d ³ %-5d ³ %-5d ³ %-5d", |
- p, (int)sum/(nact==0 ? 1 : nact), (int)max, nact, (int)CBS_get_nact(2,p), (int)last[0], (int)last[1], (int)last[2], (int)last[3], (int)last[4]); |
- // p, sum/(nact==0 ? 1 : nact), max, proc_table[p].avail_time, proc_table[p].status, proc_table[p].shadow, proc_table[p].timespec_priority.tv_sec,proc_table[p].timespec_priority.tv_nsec/1000 , CBS_get_nact(2,p), last[4]); |
- else |
- printf_xy(0,STAT_Y+i+1,WHITE,"%-3d ³ %-6d ³ %-6d ³ %-4d ³ %-7d ³ %-5d ³ %-5d ³ %-5d ³ %-5d ³ %-5d", |
- p, (int)sum/(nact==0 ? 1 : nact), (int)max, (int)nact, (int)curr, (int)last[0], (int)last[1], (int)last[2], (int)last[3], (int)last[4]); |
- // p, sum/(nact==0 ? 1 : nact), max, nact, proc_table[p].status, proc_table[p].shadow, proc_table[p].timespec_priority.tv_sec,proc_table[p].timespec_priority.tv_nsec/1000 , last[3], last[4]); |
- mutex_unlock(&m1); |
- i++; |
- } |
- } |
-} |
- |
-void fine(KEY_EVT *e) |
-{ |
- sys_end(); |
-} |
- |
-int main(int argc, char **argv) |
-{ |
- PID p1,p2,p3; //,p4,p5,p6; |
- HARD_TASK_MODEL m; |
- // NRT_TASK_MODEL m_nrt; |
- SOFT_TASK_MODEL m_aper; |
- SOFT_TASK_MODEL m_soft; |
- // int i; |
- struct timespec fineprg; |
- |
-#ifdef PIMUTEX |
- PI_mutexattr_t a; |
-#endif |
- |
-#ifdef NPPMUTEX |
- NPP_mutexattr_t a; |
-#endif |
- |
-#ifdef NOPMUTEX |
- NOP_mutexattr_t a; |
-#endif |
- |
- |
- KEY_EVT emerg; |
- //keyb_set_map(itaMap); |
- emerg.ascii = 'x'; |
- emerg.scan = KEY_X; |
- emerg.flag = ALTL_BIT; |
- keyb_hook(emerg,fine); |
- |
- clear(); |
- |
- hard_task_default_model(m); |
- hard_task_def_mit(m,100000); |
- hard_task_def_wcet(m,ASTER_WCET); |
- hard_task_def_group(m,1); |
- hard_task_def_ctrl_jet(m); |
- |
- // nrt_task_default_model(m_nrt); |
- // nrt_task_def_group(m_nrt,1); |
- // nrt_task_def_ctrl_jet(m_nrt); |
- |
- |
- soft_task_default_model(m_aper); |
- soft_task_def_group(m_aper,1); |
- soft_task_def_ctrl_jet(m_aper); |
- soft_task_def_aperiodic(m_aper); |
- |
- soft_task_default_model(m_soft); |
- soft_task_def_period(m_soft,100000); |
- soft_task_def_met(m_soft,JET_WCET); |
- soft_task_def_group(m_soft,1); |
- soft_task_def_ctrl_jet(m_soft); |
- soft_task_def_aperiodic(m_soft); |
- |
- |
- p1 = task_create("Aster",aster,&m,NULL); |
- if (p1 == -1) { |
- perror("test7.c(main): Could not create task <aster> ..."); |
- sys_end(); |
- l1_exit(-1); |
- } |
- |
- hard_task_def_mit(m,500000); |
- hard_task_def_wcet(m,CLOCK_WCET); |
- p2 = task_create("Clock",clock,&m,NULL); |
- if (p2 == -1) { |
- perror("test7.c(main): Could not create task <Clock> ..."); |
- sys_end(); |
- l1_exit(-1); |
- } |
- |
- // p3 = task_create("JetControl",jetcontrol,&m_nrt,NULL); |
- p3 = task_create("JetControl",jetcontrol,&m_aper,NULL); |
- if (p3 == -1) { |
- perror("test7.c(main): Could not create task <JetControl> ..."); |
- sys_end(); |
- l1_exit(-1); |
- } |
- /* |
- aperiodic_task_default_model(m_aper,APER_WCET); |
- aperiodic_task_def_ctrl_jet(m_aper); |
- aperiodic_task_def_system(m_aper); |
- |
- for (i=0; i<APER_MAX; i++) { |
- aperiodic_task_def_level(m_aper, i/4 + 2); |
- aperiodic_task_def_arg(m_aper, (i/4 ? 'Û' : '±')); |
- aper_table[i] = task_create("aper",aper_asteroid,&m_aper,NULL); |
- if (aper_table[i] == -1) { |
- perror("test7.c(main): Could not create task <aper> ..."); |
- sys_end(); |
- l1_exit(-1); |
- } |
- } |
- */ |
- task_nopreempt(); |
- |
-#ifdef PIMUTEX |
- PI_mutexattr_default(a); |
-#endif |
- |
-#ifdef NPPMUTEX |
- NPP_mutexattr_default(a); |
-#endif |
- |
-#ifdef NOPMUTEX |
- NOP_mutexattr_default(a); |
-#endif |
- |
- mutex_init(&m1, &a); |
- |
- fineprg.tv_sec = 1800; |
- fineprg.tv_nsec = 0; |
- kern_event_post(&fineprg,(void (*)(void *))fine,NULL); |
- group_activate(1); |
- |
- return 0; |
-} |
- |
Index: tags/rel_1_22/base/aster7.c |
=================================================================== |
--- tags/rel_1_22/base/aster7.c (revision 1310) |
+++ tags/rel_1_22/base/aster7.c (nonexistent) |
@@ -1,307 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Giorgio Buttazzo, Paolo Gai, Massimiliano Giorgi |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * |
- * CVS : $Id: aster7.c,v 1.2 2003-01-07 17:10:15 pj Exp $ |
- |
- this is a part of the classic Hartik demo Aster. |
- |
- it is based on test 10(A), and test the PS with RM. |
- |
- The JetControl is served by a dedicated Polling Server, too. |
- |
- There are APER_MAX tasks sleeping, and when an asteroide task finish |
- the current activation, it activate also an aperiodic task chosen |
- randomly (if the task chosen is already active, the task_activate do |
- nothing!) |
- |
-*/ |
- |
-#include "kernel/kern.h" |
-#include "modules//edf.h" |
-#include "drivers/keyb.h" |
- |
-int num_aster = 0; |
-#define ASTER_LIM 60 |
-#define DISPLAY_MAX 15 |
-#define ASTER_MAX 70 |
-#define STAT_Y 9 |
- |
-#define APER_MAX 8 |
- |
-/* Pentium 133 / Celeron 366 */ |
-#define PER_WCET 25000 /* 7800 */ |
-#define APER_WCET 5500 /* 1400 */ |
-#define CLOCK_WCET 500 /* 200 */ |
-#define ASTER_WCET 500 /* 200 */ |
- |
-#define APER_REP 2200 |
- |
-PID aper_table[APER_MAX]; |
- |
-TASK asteroide(void) |
-{ |
- int i; |
- int y = rand() % 7 + 1; |
- |
- int load1,j; |
- |
- char s[2]; |
- |
- s[0] = '*'; s[1] = 0; |
- |
- /*for (;;)*/ { |
- i = 1; |
- while (i < ASTER_LIM) { |
- load1 = 10000; //8000 + rand()%2000; |
- for (j=0; j<load1; j++) { |
- s[0] = '*' + rand() % 100; |
- puts_xy(i,y,rand()%15+1,s); |
- } |
- |
- task_activate(aper_table[rand()%APER_MAX]); |
- task_endcycle(); |
- |
- puts_xy(i,y,WHITE," "); |
- i++; |
- } |
- } |
- num_aster--; |
- return 0; |
-} |
- |
-TASK aper_asteroid(void *a) |
-{ |
- int i; |
- int y = rand() % 7 + 1; |
- |
- int load1,j; |
- int c; |
- |
- char s[2]; |
- |
- c = (int)a; |
- s[0] = '*'; s[1] = 0; |
- |
- for (;;) { |
- i = 1; |
- while (i < ASTER_LIM) { |
- load1 = APER_REP; //8000 + rand()%2000; |
- for (j=0; j<load1; j++) { |
- s[0] = '*' + rand() % 100; |
- puts_xy(i,y,rand()%15+1,s); |
- } |
- s[0] = c; |
- puts_xy(i,y,rand()%15+1,s); |
- |
- task_endcycle(); |
- |
- puts_xy(i,y,WHITE," "); |
- i++; |
- } |
- } |
-} |
- |
-TASK aster() |
-{ |
- PID p; |
- |
- HARD_TASK_MODEL m; |
- int r; |
- int x; // adaptive bandwidth... |
- |
- hard_task_default_model(m); |
- hard_task_def_wcet(m,PER_WCET); |
- hard_task_def_ctrl_jet(m); |
- |
- x = 200; |
- |
- srand(7); |
- while (1) { |
- if (num_aster < ASTER_MAX) { |
- r = (rand() % 200); |
- |
- hard_task_def_arg(m,(void *)((rand() % 7)+1)); |
- hard_task_def_mit(m, (x+r)*1000); |
- p = task_create("aaa",asteroide,&m,NULL); |
- if (p == -1) |
- { |
- if (x < 500 && errno != ENO_AVAIL_TASK) x += 1; |
- printf_xy(62,3,WHITE,"adapt=%3u err=%d", |
- iq_query_first(&freedesc),errno); |
- } |
- else { |
- num_aster++; |
- printf_xy(62,3,WHITE,"adapt=%3u ",x);//,errno); |
- task_activate(p); |
- x /= 2; |
- if (x<50) x = 50; |
- } |
- } |
- task_endcycle(); |
- } |
-} |
- |
-TASK clock() |
-{ |
- int s = 0, m = 0; |
- |
- while(1) { |
- printf_xy(62,1,WHITE,"%2d:%2d ast=%d",m,s, num_aster); |
- printf_xy(62,2,WHITE,"U=%12u",EDF_usedbandwidth(0)); |
- task_endcycle(); |
- |
- if (++s > 59) { |
- s = 0; |
- m++; |
- } |
- printf_xy(62,1,WHITE,"%2d:%2d ast=%d",m,s, num_aster); |
- printf_xy(62,2,WHITE,"U=%12u",EDF_usedbandwidth(0)); |
- task_endcycle(); |
- } |
-} |
- |
- |
- |
-/* we consider the first ASTER_MAX + 2 tasks from the PID 2 |
- and plot on the screen the elapsed times... */ |
-TASK jetcontrol() |
-{ |
- int i; /* a counter */ |
- TIME sum, max, curr, last[5]; |
- int nact; |
- int j; /* the elements set by jet_gettable */ |
- PID p; |
- |
- |
- kern_cli(); |
- printf_xy(0,STAT_Y,WHITE,"PID ³ Mean T.³ Max T. ³ N.A. ³ Curr. ³ Last1 ³ Last2 ³ Last3 ³ Last4 ³ Last5"); |
- kern_sti(); |
- |
- for (;;) { |
- for (i=0,p=0; i<DISPLAY_MAX+5 && p<MAX_PROC; p++) { |
- if (jet_getstat(p, &sum, &max, &nact, &curr) == -1) continue; |
- |
- for (j=0; j<5; j++) last[j] = 0; |
- jet_gettable(p, &last[0], 5); |
- kern_cli(); |
- printf_xy(0,STAT_Y+i+1,WHITE,"%-3d ³ %-6d ³ %-6d ³ %-4d ³ %-7d ³ %-5d ³ %-5d ³ %-5d ³ %-5d ³ %-5d", |
- p, (int)sum/(nact==0 ? 1 : nact), (int)max, nact, (int)curr, (int)last[0], (int)last[1], (int)last[2], (int)last[3], (int)last[4]); |
- kern_sti(); |
- i++; |
- } |
- } |
-} |
- |
- |
-void fine(KEY_EVT *e) |
-{ |
- sys_end(); |
-} |
- |
- |
-int main(int argc, char **argv) |
-{ |
- PID p1,p2,p3; //,p4,p5,p6; |
- HARD_TASK_MODEL m; |
- NRT_TASK_MODEL m_nrt; |
- SOFT_TASK_MODEL m_aper; |
- int i; |
- |
- KEY_EVT emerg; |
- |
- clear(); |
- |
- cprintf("Press Alt-x to end the demo..."); |
- |
- //keyb_set_map(itaMap); |
- emerg.ascii = 'x'; |
- emerg.scan = KEY_X; |
- emerg.flag = ALTL_BIT; |
- keyb_hook(emerg,fine); |
- |
- hard_task_default_model(m); |
- hard_task_def_wcet(m,ASTER_WCET); |
- hard_task_def_mit(m,10000); |
- hard_task_def_group(m,1); |
- hard_task_def_ctrl_jet(m); |
- |
- nrt_task_default_model(m_nrt); |
- nrt_task_def_group(m_nrt,1); |
- nrt_task_def_ctrl_jet(m_nrt); |
- |
- p1 = task_create("Aster",aster,&m,NULL); |
- if (p1 == -1) { |
- perror("test7.c(main): Could not create task <aster> ..."); |
- sys_end(); |
- } |
- |
- hard_task_def_mit(m,500000); |
- hard_task_def_wcet(m,CLOCK_WCET); |
- p2 = task_create("Clock",clock,&m,NULL); |
- if (p2 == -1) { |
- perror("test7.c(main): Could not create task <Clock> ..."); |
- sys_end(); |
- } |
- |
- soft_task_default_model(m_aper); |
- soft_task_def_ctrl_jet(m_aper); |
- soft_task_def_level(m_aper, 1); |
- soft_task_def_group(m_aper,1); |
- soft_task_def_aperiodic(m_aper); |
- p3 = task_create("JetControl",jetcontrol,&m_aper,NULL); |
- if (p3 == -1) { |
- perror("test7.c(main): Could not create task <JetControl> ..."); |
- sys_end(); |
- } |
- |
- soft_task_def_wcet(m_aper,APER_WCET); |
- soft_task_def_ctrl_jet(m_aper); |
- soft_task_def_aperiodic(m_aper); |
- |
- for (i=0; i<APER_MAX; i++) { |
- soft_task_def_level(m_aper, i/4 + 3); |
- soft_task_def_arg(m_aper, (void *)(i/4 ? 'Û' : '±')); |
- aper_table[i] = task_create("aper",aper_asteroid,&m_aper,NULL); |
- if (aper_table[i] == -1) { |
- perror("test7.c(main): Could not create task <aper> ..."); |
- sys_end(); |
- } |
- } |
- |
- group_activate(1); |
- return 0; |
-} |
- |
Index: tags/rel_1_22/base/aster8.c |
=================================================================== |
--- tags/rel_1_22/base/aster8.c (revision 1310) |
+++ tags/rel_1_22/base/aster8.c (nonexistent) |
@@ -1,542 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Giorgio Buttazzo, Paolo Gai, Massimiliano Giorgi |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * |
- * CVS : $Id: aster8.c,v 1.2 2003-01-07 17:10:15 pj Exp $ |
- |
- Test for Sporadic Server (ss): |
- |
- this is a part of the classic Hartik demo Aster. |
- |
- it is based on test 17 (h), and the JobControl Task uses an |
- SOFT_TASK_MODEL served by a sporadic server |
- There are two "dummy" tasks that increment a counter and print |
- the value. One uses a SOFT_TASK_MODEL served by sporadic server, |
- the other uses a NRT_TASK_MODEL handled by RR module. |
- |
-*/ |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/cbs.h" |
-#include "modules/ss.h" |
-#include "drivers/keyb.h" |
- |
-int num_aster = 0; |
-#define EDF_LEV 0 |
-#define CBS_LEV 1 |
-#define SS_LEV 2 |
- |
-#define ASTER_LIM 60 |
-#define DISPLAY_MAX 8 |
-#define ASTER_MAX 70 |
-#define STAT_Y 9 |
- |
-#define PER_MAX 5 |
-#define APER_MAX 8 |
- |
-#define PER_WCET 16000 |
-#define APER_WCET 22000 |
-#define JET_WCET 20000 |
- |
-#define APER_REP 22000 |
- |
-PID aper_table[APER_MAX]; |
- |
-mutex_t m1; |
- |
- |
-#define PIMUTEX |
-//#define PCMUTEX |
-//#define NPPMUTEX |
-//#define NOPMUTEX |
- |
-#define LONGSC |
- |
-#ifdef LONGSC |
-#define SOFT_MET 12000 /* 12000 */ |
-#define CLOCK_WCET 300 /* 300*/ |
-#define ASTER_WCET 300 /* 300*/ |
-#else |
-#define SOFT_MET 5000 /* 4500 */ |
-#define CLOCK_WCET 2000 /* 200*/ |
-#define ASTER_WCET 2000 /* 200*/ |
-#endif |
- |
-PID p1,p2,p3,p4,p5; |
- |
-TASK asteroide(void) |
-{ |
- int i; |
- int y = rand() % 7 + 1; |
- |
- int load1,j; |
- |
- char s[2]; |
- |
- s[0] = '*'; s[1] = 0; |
- |
- for (;;) { |
- i = 1; |
- while (i < ASTER_LIM) { |
- load1 = 10000; //8000 + rand()%2000; |
- #ifdef LONGSC |
- mutex_lock(&m1); |
- #endif |
- for (j=0; j<load1; j++) { |
- s[0] = '*' + rand() % 100; |
- #ifndef LONGSC |
- mutex_lock(&m1); |
- #endif |
- puts_xy(i,y,rand()%15+1,s); |
- #ifndef LONGSC |
- mutex_unlock(&m1); |
- #endif |
- } |
- #ifdef LONGSC |
- mutex_unlock(&m1); |
- #endif |
- |
- task_activate(aper_table[rand()%APER_MAX]); |
- task_endcycle(); |
- |
- mutex_lock(&m1); |
- puts_xy(i,y,WHITE," "); |
- mutex_unlock(&m1); |
- i++; |
- } |
- } |
- //num_aster--; |
-} |
- |
-TASK aper_asteroid(void *a) |
-{ |
- int i; |
- int y = rand() % 7 + 1; |
- |
- int load1,j; |
- int c; |
- |
- char s[2]; |
- |
- c = (int)a; |
- s[0] = '*'; s[1] = 0; |
- |
- for (;;) { |
- i = 1; |
- while (i < ASTER_LIM) { |
- load1 = APER_REP; //8000 + rand()%2000; |
- #ifdef LONGSC |
- mutex_lock(&m1); |
- #endif |
- for (j=0; j<load1; j++) { |
- s[0] = '*' + rand() % 100; |
- #ifndef LONGSC |
- mutex_lock(&m1); |
- #endif |
- puts_xy(i,y,rand()%15+1,s); |
- #ifndef LONGSC |
- mutex_unlock(&m1); |
- #endif |
- } |
- s[0] = c; |
- #ifndef LONGSC |
- mutex_unlock(&m1); |
- #endif |
- mutex_lock(&m1); |
- puts_xy(i,y,rand()%15+1,s); |
- mutex_unlock(&m1); |
- |
- task_endcycle(); |
- |
- mutex_lock(&m1); |
- puts_xy(i,y,WHITE," "); |
- mutex_unlock(&m1); |
- i++; |
- } |
- } |
-} |
- |
-TASK soft_aster(void) |
-{ |
- int i; |
- int y = rand() % 7 + 1; |
- |
- int load1,j; |
- |
- char s[2]; |
- |
- s[0] = '*'; s[1] = 0; |
- |
- /*for (;;)*/ { |
- i = 1; |
- while (i < ASTER_LIM) { |
- load1 = 1000 + rand()%9000; |
- #ifdef LONGSC |
- mutex_lock(&m1); |
- #endif |
- for (j=0; j<load1; j++) { |
- s[0] = '*' + rand() % 100; |
- #ifndef LONGSC |
- mutex_lock(&m1); |
- #endif |
- puts_xy(i,y,rand()%15+1,s); |
- #ifndef LONGSC |
- mutex_unlock(&m1); |
- #endif |
- } |
- s[0] = 1; |
- #ifndef LONGSC |
- mutex_lock(&m1); |
- #endif |
- //mutex_lock(&m1); |
- puts_xy(i,y,rand()%15+1,s); |
- mutex_unlock(&m1); |
- |
- task_activate(aper_table[rand()%APER_MAX]); |
- task_endcycle(); |
- |
- mutex_lock(&m1); |
- puts_xy(i,y,WHITE," "); |
- mutex_unlock(&m1); |
- i++; |
- } |
- } |
- num_aster--; |
- return 0; |
-} |
- |
-TASK aster() |
-{ |
- PID p; |
- |
-// HARD_TASK_MODEL m; |
- SOFT_TASK_MODEL m_soft; |
- int r; |
- int x; // adaptive bandwidth... |
- |
- srand(7); |
- |
-/* periodic_task_default_model(m,0,PER_WCET); |
- periodic_task_def_ctrl_jet(m); |
- for (x=0; x<PER_MAX; x++) { |
- r = (rand() % 200); |
- periodic_task_def_period(m, (64+r)*1000); |
- p = task_create("per",asteroide,&m,NULL); |
- if (p!=-1) task_activate(p); |
- } |
-*/ |
- soft_task_default_model(m_soft); |
- soft_task_def_met(m_soft,SOFT_MET); |
- soft_task_def_ctrl_jet(m_soft); |
-// soft_task_def_aperiodic(m_soft); |
- |
- x = 128; //64; |
- |
- while (1) { |
-/* { |
- PID p; |
- int x; |
- p = level_table[0]->level_scheduler(0); |
- printf_xy(1,8,WHITE," "); |
- |
- x = 0; |
- do { |
- printf_xy(3*x+1,8,WHITE,"%3d",p); |
- p = proc_table[p].next; |
- x++; |
- } while (p != NIL); |
- } |
-*/ |
- if (num_aster < ASTER_MAX) { |
- r = (rand() % 200); |
- |
- soft_task_def_period(m_soft, (x+r)*1000); |
- p = task_create("aaa",soft_aster,&m_soft,NULL); |
- if (p == -1) |
- { |
- if (x < 500 && errno != ENO_AVAIL_TASK) x += 1; |
- mutex_lock(&m1); |
- printf_xy(62,3,WHITE,"adapt=%3u err=%d", |
- iq_query_first(&freedesc), errno); |
- mutex_unlock(&m1); |
- } |
- else { |
- num_aster++; |
- mutex_lock(&m1); |
- printf_xy(62,3,WHITE,"adapt=%3u ",x); |
- mutex_unlock(&m1); |
- task_activate(p); |
- x /= 2; |
- if (x<50) x = 50; |
- } |
- } |
- task_endcycle(); |
- } |
-} |
- |
-TASK clock() |
-{ |
- int s = 0, m = 0; |
- |
- while(1) { |
- mutex_lock(&m1); |
- printf_xy(62,1,WHITE,"%2d:%2d ast=%d",m,s, num_aster); |
- printf_xy(62,2,WHITE,"Uedf=%12u",EDF_usedbandwidth(EDF_LEV)); |
- printf_xy(62,4,WHITE,"Ucbs=%12u",CBS_usedbandwidth(CBS_LEV)); |
- printf_xy(62,5,WHITE,"CSss=%6d",SS_availCs(SS_LEV)); |
- mutex_unlock(&m1); |
- |
- task_endcycle(); |
- |
- if (++s > 59) { |
- s = 0; |
- m++; |
- } |
- mutex_lock(&m1); |
- printf_xy(62,1,WHITE,"%2d:%2d ast=%d",m,s, num_aster); |
- printf_xy(62,2,WHITE,"Uedf=%12u",EDF_usedbandwidth(EDF_LEV)); |
- printf_xy(62,4,WHITE,"Ucbs=%12u",CBS_usedbandwidth(CBS_LEV)); |
- printf_xy(62,5,WHITE,"CSss=%6d",SS_availCs(SS_LEV)); |
- mutex_unlock(&m1); |
- task_endcycle(); |
- } |
-} |
- |
- |
- |
-/* we consider the first ASTER_MAX + 2 tasks from the PID 2 |
- and plot on the screen the elapsed times... */ |
-TASK jetcontrol() |
-{ |
- int i; /* a counter */ |
- TIME sum, max, curr, last[5]; |
- int nact; |
- int j; /* the elements set by jet_gettable */ |
- PID p; |
- |
- |
- mutex_lock(&m1); |
- printf_xy(0,STAT_Y,WHITE,"PID ³ Mean T.³ Max T. ³ N.A. ³ Curr. ³ Last1 ³ Last2 ³ Last3 ³ Last4 ³ Last5"); |
- mutex_unlock(&m1); |
- |
- for (;;) { |
- for (i=0,p=0; i<DISPLAY_MAX+5 && p<MAX_PROC; p++) { |
- if (jet_getstat(p, &sum, &max, &nact, &curr) == -1 /*|| |
- (proc_table[p].pclass & 0xFF00) == APERIODIC_PCLASS || |
- (proc_table[p].pclass & 0xFF00) == PERIODIC_PCLASS*/ ) continue; |
- |
- for (j=0; j<5; j++) last[j] = 0; |
- jet_gettable(p, &last[0], 5); |
- mutex_lock(&m1); |
- if (proc_table[p].task_level == 1) |
- printf_xy(0,STAT_Y+i+1,WHITE,"%-3d ³ %-6d ³ %-6d ³ %-4d ³ %-7d ³ %-5d ³ %-5d ³ %-5d ³ %-5d ³ %-5d", |
- p, (int)sum/(nact==0 ? 1 : nact), (int)max, nact, (int)CBS_get_nact(2,p), (int)last[0], (int)last[1], (int)last[2], (int)last[3], (int)last[4]); |
-// p, sum/(nact==0 ? 1 : nact), max, proc_table[p].avail_time, proc_table[p].status, proc_table[p].shadow, proc_table[p].timespec_priority.tv_sec,proc_table[p].timespec_priority.tv_nsec/1000 , CBS_get_nact(2,p), last[4]); |
- else |
- printf_xy(0,STAT_Y+i+1,WHITE,"%-3d ³ %-6d ³ %-6d ³ %-4d ³ %-7d ³ %-5d ³ %-5d ³ %-5d ³ %-5d ³ %-5d", |
- p, (int)sum/(nact==0 ? 1 : nact), (int)max, (int)nact, (int)curr, (int)last[0], (int)last[1], (int)last[2], (int)last[3], (int)last[4]); |
-// p, sum/(nact==0 ? 1 : nact), max, nact, proc_table[p].status, proc_table[p].shadow, proc_table[p].timespec_priority.tv_sec,proc_table[p].timespec_priority.tv_nsec/1000 , last[3], last[4]); |
- mutex_unlock(&m1); |
- i++; |
- task_activate(p3); |
- task_endcycle(); |
- } |
- } |
-} |
- |
-void fine(KEY_EVT *e) |
-{ |
- sys_end(); |
-} |
- |
-void mydummyaper(void) { |
- int i=0; |
- while(1) { |
- mutex_lock(&m1); |
- printf_xy(1,24,RED,"dummyAPER pid=%d: %d",p4,i++); |
- mutex_unlock(&m1); |
- task_activate(p4); |
- task_endcycle(); |
- } |
-} |
- |
-void mydummynrt(void) { |
- int i=0; |
- while(1) { |
- mutex_lock(&m1); |
- printf_xy(40,24,RED,"dummyNRT pid=%d: %d",p5,i++); |
- mutex_unlock(&m1); |
- } |
-} |
- |
-int main(int argc, char **argv) |
-{ |
-// PID p1,p2,p5; |
- HARD_TASK_MODEL m; |
- NRT_TASK_MODEL m_nrt; |
- SOFT_TASK_MODEL m_aper; |
- SOFT_TASK_MODEL m_soft; |
- |
- #ifdef PIMUTEX |
- PI_mutexattr_t a; |
- #endif |
- |
- #ifdef PCMUTEX |
- PC_mutexattr_t a; |
- #endif |
- |
- #ifdef NPPMUTEX |
- NPP_mutexattr_t a; |
- #endif |
- |
- #ifdef NOPMUTEX |
- NOP_mutexattr_t a; |
- #endif |
- |
- |
- KEY_EVT emerg; |
- //keyb_set_map(itaMap); |
- emerg.ascii = 'x'; |
- emerg.scan = KEY_X; |
- emerg.flag = ALTL_BIT; |
- keyb_hook(emerg,fine); |
- |
- clear(); |
- |
- cprintf("Press Alt-x to end the demo..."); |
- |
- hard_task_default_model(m); |
- hard_task_def_mit(m,100000); |
- hard_task_def_wcet(m,ASTER_WCET); |
- hard_task_def_group(m,1); |
- hard_task_def_ctrl_jet(m); |
- |
- nrt_task_default_model(m_nrt); |
- nrt_task_def_group(m_nrt,1); |
- nrt_task_def_ctrl_jet(m_nrt); |
- |
- |
- soft_task_default_model(m_aper); |
- soft_task_def_group(m_aper,1); |
- soft_task_def_ctrl_jet(m_aper); |
- soft_task_def_aperiodic(m_aper); |
- |
- soft_task_default_model(m_soft); |
- soft_task_def_period(m_soft,10000); |
- soft_task_def_met(m_soft,JET_WCET); |
- soft_task_def_group(m_soft,1); |
- soft_task_def_ctrl_jet(m_soft); |
- soft_task_def_aperiodic(m_soft); |
- |
- |
- p1 = task_create("Aster",aster,&m,NULL); |
- if (p1 == -1) { |
- perror("test7.c(main): Could not create task <aster> ..."); |
- sys_end(); |
- l1_exit(-1); |
- } |
- |
- hard_task_def_mit(m,50000); |
- hard_task_def_wcet(m,CLOCK_WCET); |
- p2 = task_create("Clock",clock,&m,NULL); |
- if (p2 == -1) { |
- perror("test7.c(main): Could not create task <Clock> ..."); |
- sys_end(); |
- l1_exit(-1); |
- } |
- |
-// p3 = task_create("JetControl",jetcontrol,&m_nrt,NULL); |
- p3 = task_create("JetControl",jetcontrol,&m_aper,NULL); |
- if (p3 == -1) { |
- perror("test7.c(main): Could not create task <JetControl> ..."); |
- sys_end(); |
- l1_exit(-1); |
- } |
- |
- p4 = task_create("MyDummyAper",(void *(*)(void*))mydummyaper,&m_aper,NULL); |
- if (p4 == -1) { |
- perror("Could not create task <MyDummyAper> ..."); |
- sys_end(); |
- l1_exit(-1); |
- } |
- |
- p5 = task_create("MyDummyNRT",(void *(*)(void*))mydummynrt,&m_nrt,NULL); |
- if (p5 == -1) { |
- perror("Could not create task <MyDummyNRT> ..."); |
- sys_end(); |
- l1_exit(-1); |
- } |
-/* |
- aperiodic_task_default_model(m_aper,APER_WCET); |
- aperiodic_task_def_ctrl_jet(m_aper); |
- aperiodic_task_def_system(m_aper); |
- |
- for (i=0; i<APER_MAX; i++) { |
- aperiodic_task_def_level(m_aper, i/4 + 2); |
- aperiodic_task_def_arg(m_aper, (i/4 ? 'Û' : '±')); |
- aper_table[i] = task_create("aper",aper_asteroid,&m_aper,NULL); |
- if (aper_table[i] == -1) { |
- perror("test7.c(main): Could not create task <aper> ..."); |
- sys_end(); |
- l1_exit(-1); |
- } |
- } |
-*/ |
-// task_nopreempt(); |
- |
- |
- #ifdef PIMUTEX |
- PI_mutexattr_default(a); |
- #endif |
- |
- #ifdef PCMUTEX |
- PC_mutexattr_default(a); |
- #endif |
- |
- #ifdef NPPMUTEX |
- NPP_mutexattr_default(a); |
- #endif |
- |
- #ifdef NOPMUTEX |
- NOP_mutexattr_default(a); |
- #endif |
- |
- mutex_init(&m1, &a); |
- |
- group_activate(1); |
- return 0; |
-} |
- |
Index: tags/rel_1_22/base/cabs.c |
=================================================================== |
--- tags/rel_1_22/base/cabs.c (revision 1310) |
+++ tags/rel_1_22/base/cabs.c (nonexistent) |
@@ -1,322 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Giorgio Buttazzo, Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * |
- * CVS : $Id: cabs.c,v 1.3 2003-01-07 17:10:15 pj Exp $ |
- */ |
- |
-/*--------------------------------------------------------------*/ |
-/* TEST ON CABS */ |
-/*--------------------------------------------------------------*/ |
- |
-#include <kernel/kern.h> |
-#include <modules/cabs.h> |
-#include <drivers/glib.h> |
-#include <drivers/keyb.h> |
-#include <string.h> |
- |
-#define NCAB 4 /* max number of CABs */ |
-#define NCAR 26 /* generated characters */ |
- |
-#define YP 32 /* level of arrows */ |
-#define R 20 /* task radius */ |
-#define YY (YP+R+32) /* level of writing */ |
-#define DELTA (2*R+72) /* total channel hight */ |
-#define X1 120 /* start column for P1 */ |
-#define X2 360 /* start column for P2 */ |
- |
-#define XP1 (X1+64) /* X position of task 1 */ |
-#define XP2 (X2+64) /* X position of task 2 */ |
-#define XC (XP1+96) /* X position of CAB */ |
-#define L 52 /* CAB rectangle length */ |
- |
-void my_exit(KEY_EVT *k); |
-void draw_channel(int i); |
-void create_channel(int i); |
-void get_data(); |
- |
-TASK producer(void *arg); |
-TASK consumer(void *arg); |
- |
-char *cname[NCAB] = {"cab1", "cab2", "cab3", "cab4"}; |
-char *pname1[NCAB] = {"wr1", "wr2", "wr3", "wr4"}; |
-char *pname2[NCAB] = {"rd1", "rd2", "rd3", "rd4"}; |
- |
-CAB cid[NCAB]; /* CAB identifiers */ |
-PID p1[NCAB], p2[NCAB]; /* task identifiers */ |
- |
-/* Task Periods */ |
-TIME t1[NCAB] = {200000, 100000, 300000, 800000}; |
-TIME t2[NCAB] = {400000, 400000, 150000, 200000}; |
- |
-/* Task WCETS */ |
-TIME w1[NCAB] = {10000, 10000, 10000, 10000}; |
-TIME w2[NCAB] = {10000, 10000, 10000, 10000}; |
- |
- |
-/****************************************************************/ |
- |
-/* This function is called when Alt-X is pressed. |
- It simply shutdown the system using sys_end. |
- Note that the byebye() function is called only if we exit from |
- the system using sys_end()!!!! |
-*/ |
-void my_end(KEY_EVT* e) |
-{ |
- sys_end(); |
-} |
- |
-/******************************************************************/ |
- |
-/* This function is called when the system exit correctly after Alt-X. |
- It exits from the graphic mode and then it prints a small greeting. |
- Note that: |
- - The function calls grx_exit, so it must be registered using |
- RUNLEVEL_BEFORE_EXIT (RUNLEVEL_AFTER_EXIT does not work because |
- at that point the kernel is already returned in real mode!!!) |
- - When an exception is raised, the exception handler is called. |
- Since the exception handler already exits from the graphic mode, |
- this funcion has not to be called. For this reason: |
- . we registered byebye using the flag NO_AT_ABORT |
- . the exception handler exits using sys_abort; in that way byebye is |
- NOT called |
-*/ |
- |
- |
-/*--------------------------------------------------------------*/ |
-/* User exit function */ |
-/*--------------------------------------------------------------*/ |
- |
-void byebye(void *arg) |
-{ |
- grx_close(); |
- cprintf("Bye Bye!\n"); |
-} |
- |
-/*--------------------------------------------------------------*/ |
-/* Main task */ |
-/*--------------------------------------------------------------*/ |
- |
- |
-/****************************** MAIN ******************************/ |
- |
-int main(int argc, char **argv) |
-{ |
- char c = 0; /* character from keyboard */ |
- |
- /* Set the closing function */ |
- sys_atrunlevel(byebye, NULL, RUNLEVEL_BEFORE_EXIT); |
- |
- /* graphic card Initialization */ |
- if (grx_init() < 1) { |
- sys_abort(1); |
- } |
- |
- if (grx_open(640, 480, 8) < 0) { |
- cprintf("GRX Err\n"); |
- sys_abort(1); |
- } |
- |
- grx_clear(BLACK); |
- |
- grx_text("Press a key [1-4]", 10, 16, 7, 0); |
- grx_text("to create a pair", 10, 24, 7, 0); |
- grx_text("ESC to exit demo", 10, 48, 7, 0); |
- |
- while (c != 27) { |
- c = keyb_getch(BLOCK); |
- if ((c >= '1') && (c <= '1'+NCAB-1)) |
- create_channel(c-'1'); |
- } |
- |
- sys_end(); |
- |
- return 0; |
-} |
- |
- |
-/*--------------------------------------------------------------*/ |
-/* write data in a cab */ |
-/*--------------------------------------------------------------*/ |
- |
-TASK producer(void *arg) |
-{ |
-int i = (int)arg; |
-char c; /* message character */ |
-char *p; /* pointer to a cab buffer */ |
-char s[2]; /* string to display */ |
-int k = 0; |
-int x, y; |
-int col = 13; |
-int ybase = YY + i*DELTA; |
- |
- x = X1; |
- y = ybase; |
- s[1] = 0; |
- |
- k = 0; |
- while (1) { |
- c = 'A' + k; |
- p = cab_reserve(cid[i]); |
- *p = c; |
- cab_putmes(cid[i], p); |
- |
- s[0] = c; |
- k = (k + 1) % NCAR; |
- grx_text(s,x,y,col,0); |
- |
- x += 8; |
- if (x >= (X1 + NCAR*8)) { |
- x = X1; |
- y = y + 8; |
- if (y >= ybase+16) { |
- y = ybase; |
- col = col % 15 + 1; |
- } |
- } |
- |
- task_endcycle(); |
- } |
-} |
- |
-/*--------------------------------------------------------------*/ |
-/* read data from a cab */ |
-/*--------------------------------------------------------------*/ |
- |
-TASK consumer(void *arg) |
-{ |
-int i = (int)arg; |
-char *p; |
-char s[2]; |
-int x, y; |
-int col = 13; |
-int ybase = YY + i*DELTA; |
- |
- x = X2; |
- y = ybase; |
- s[1] = 0; |
- |
- while (1) { |
- p = cab_getmes(cid[i]); |
- s[0] = *p - 'A' + 'a'; |
- cab_unget(cid[i], p); |
- |
- grx_text(s,x,y,col,0); |
- x += 8; |
- |
- if (x >= (X2 + NCAR*8)) { |
- x = X2; |
- y = y + 8; |
- if (y >= ybase+16) { |
- y = ybase; |
- col = col % 15 + 1; |
- } |
- } |
- task_endcycle(); |
- } |
-} |
- |
-/*--------------------------------------------------------------*/ |
-/* create the two tasks and a channel */ |
-/*--------------------------------------------------------------*/ |
- |
-void create_channel(int i) |
-{ |
- HARD_TASK_MODEL m; |
- |
- draw_channel(i); |
- cid[i] = cab_create(cname[i], 1, 2); |
- |
- hard_task_default_model(m); |
- hard_task_def_ctrl_jet (m); |
- hard_task_def_arg (m, (void *)i); |
- hard_task_def_wcet (m, w1[i]); |
- hard_task_def_mit (m, t1[i]); |
- hard_task_def_usemath (m); |
- p1[i] = task_create(pname1[i], producer, &m, NULL); |
- if (p1[i] == NIL) { |
- grx_close(); |
- perror("Could not create task <producer>"); |
- sys_abort(1); |
- } |
- task_activate(p1[i]); |
- |
- hard_task_default_model(m); |
- hard_task_def_ctrl_jet (m); |
- hard_task_def_arg (m, (void *)i); |
- hard_task_def_wcet (m, w2[i]); |
- hard_task_def_mit (m, t2[i]); |
- hard_task_def_usemath (m); |
- p2[i] = task_create(pname2[i], consumer, &m, NULL); |
- if (p2[i] == NIL) { |
- grx_close(); |
- perror("Could not create task <consumer>"); |
- sys_abort(1); |
- } |
- task_activate(p2[i]); |
-} |
- |
-/*--------------------------------------------------------------*/ |
-/* Disegna i processi e il canale di comunicazione */ |
-/*--------------------------------------------------------------*/ |
- |
-void draw_channel(int i) |
-{ |
-char buffer[32]; /* buffer per sprintf */ |
-int yc = YP + i*DELTA; /* altezza del canale */ |
- |
- grx_circle(XP1,yc,R,2); |
- grx_text("P1",XP1-8,yc-4,12,0); |
- |
- grx_circle(XP2,yc,R,2); |
- grx_text("P2",XP2-8,yc-4,12,0); |
- |
- grx_rect(XC,yc-R,XC+L,yc+R,3); |
- grx_text("CAB",XC+16,yc-4,12,0); |
- |
- grx_line(XP1+R,yc,XC,yc,4); |
- grx_line(XC+L,yc,XP2-R,yc,4); |
- |
- grx_text("T1 = ms",X1+40,yc+R+16,14,0); |
- sprintf(buffer,"%ld", t1[i]); |
- grx_text(buffer,X1+88,yc+R+16,14,0); |
- |
- grx_text("T2 = ms",X2+40,yc+R+16,14,0); |
- sprintf(buffer,"%ld", t2[i]); |
- grx_text(buffer,X2+88,yc+R+16,14,0); |
-} |
- |
-/*--------------------------------------------------------------*/ |
- |
Index: tags/rel_1_22/base/iaster1.c |
=================================================================== |
--- tags/rel_1_22/base/iaster1.c (revision 1310) |
+++ tags/rel_1_22/base/iaster1.c (nonexistent) |
@@ -1,99 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: iaster1.c,v 1.2 2003-04-15 10:21:22 giacomo Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.2 $ |
- Last update: $Date: 2003-04-15 10:21:22 $ |
- ------------ |
- |
- System initialization file |
- |
- The tick is set to TICK ms. |
- |
- This file contains the 2 functions needed to initialize the system. |
- |
- These functions register the following levels: |
- |
- an EDF (Earliest Deadline First) level |
- a RR (Round Robin) level |
- a Dummy level |
- |
- It can accept these task models (into () the mandatory fields): |
- |
- HARD_TASK_MODEL (wcet+mit) at level 0 |
- NRT_TASK_MODEL at level 1 |
- |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
- |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/rr.h" |
-#include "modules/dummy.h" |
- |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 1000 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 10000 |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- EDF_register_level(EDF_ENABLE_ALL); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
Index: tags/rel_1_22/base/srpdemo.c |
=================================================================== |
--- tags/rel_1_22/base/srpdemo.c (revision 1310) |
+++ tags/rel_1_22/base/srpdemo.c (nonexistent) |
@@ -1,246 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * |
- * CVS : $Id: srpdemo.c,v 1.2 2003-01-07 17:10:16 pj Exp $ |
- |
- This test verify the correctness of the SRP module. |
- |
- There are 3 taks, Jh, Jm, Jl that uses 3 mutexes m1, m2, m3 |
- |
- the main task (NRT) creates the three tasks. |
- |
- Jh with preemption level 3 |
- starts at t=1.5 sec and lock m3, lock m1, unlock m1, unlock m3 |
- |
- Jm with preemption level 2 |
- starts at t=0.5 sec and lock m3, lock m2, unlock m2, unlock m3 |
- then lock and unlock m1 |
- |
- Jl with preemption level 1 |
- it starts and locks m2 |
- at t=1 sec it locks m1 |
- at t=1.5 sec it unlocks m1 |
- then it unlocks m2, and finally it locks and unlocks m3 |
- |
- |
- The example is similar to the scheduling diagram shown at p. 210 of the |
- book "Sistemi in tempo Reale", by Giorgio Buttazzo, Pitagora Editrice |
- |
-*/ |
- |
-#include "kernel/kern.h" |
-#include "drivers/keyb.h" |
- |
-#include "modules/srp.h" |
- |
-mutex_t m1,m2,m3; |
- |
-void startJ(void *a) |
-{ |
- task_activate((PID)a); |
-} |
- |
-TASK Jlobby() |
-{ |
- cprintf("(*) JLobby!!!\n"); |
- return 0; |
-} |
- |
-TASK Jh() |
-{ |
- PID l; |
- HARD_TASK_MODEL m; |
- SRP_RES_MODEL r; |
- |
- cprintf("JH: creating Jy before locking m3\n"); |
- |
- hard_task_default_model(m); |
- hard_task_def_mit(m,30000); |
- hard_task_def_wcet(m,1000); |
- SRP_res_default_model(r,4); |
- l = task_create("Jlobby",Jlobby,&m,&r); |
- task_activate(l); |
- |
- mutex_lock(&m3); |
- cprintf("JH: locked m3, locking m1\n"); |
- mutex_lock(&m1); |
- cprintf("JH: locked m1, unlocking m1\n"); |
- mutex_unlock(&m1); |
- cprintf("JH: unlocked m1, unlocking m3\n"); |
- mutex_unlock(&m3); |
- cprintf("JH: unlocked m3, end task\n"); |
- return 0; |
-} |
- |
- |
-TASK Jm() |
-{ |
- cprintf("JM: before locking m3\n"); |
- mutex_lock(&m3); |
- cprintf("JM: locked m3, locking m2\n"); |
- mutex_lock(&m2); |
- cprintf("JM: locked m2, unlocking m2\n"); |
- mutex_unlock(&m2); |
- cprintf("JM: unlocked m2, unlocking m3\n"); |
- mutex_unlock(&m3); |
- cprintf("JM: unlocked m3, locking m1\n"); |
- mutex_lock(&m1); |
- cprintf("JM: locked m1, unlocking m1\n"); |
- mutex_unlock(&m1); |
- cprintf("JM: unlocked m1, end task\n"); |
- return 0; |
-} |
- |
- |
-TASK Jl() |
-{ |
- cprintf("JL: before locking m2\n"); |
- mutex_lock(&m2); |
- cprintf("JL: locked m2, waiting to t=1 sec\n"); |
- |
- while (sys_gettime(NULL) < 1000000); |
- |
- cprintf("JL: t = 1 sec reached, locking m1\n"); |
- mutex_lock(&m1); |
- cprintf("JL: locked m1, waiting to t=2 sec\n"); |
- |
- while (sys_gettime(NULL) < 2000000); |
- |
- cprintf("JL: t = 2 sec reached, unlocking m1\n"); |
- mutex_unlock(&m1); |
- cprintf("JL: unlocked m1, unlocking m2\n"); |
- |
- mutex_unlock(&m2); |
- |
- cprintf("JL: unlocked m2, locking m3\n"); |
- mutex_lock(&m3); |
- cprintf("JL: locked m3, unlocking m3\n"); |
- mutex_unlock(&m3); |
- cprintf("JL: unlocked m3, end task\n"); |
- return 0; |
-} |
- |
-void fine(KEY_EVT *e) |
-{ |
- sys_end(); |
-} |
- |
- |
-int main(int argc, char **argv) |
-{ |
- struct timespec t; |
- |
- HARD_TASK_MODEL m; |
- PID p0,p1,p2; |
- |
- SRP_mutexattr_t a; |
- SRP_RES_MODEL r; |
- |
- PI_mutexattr_t a2; |
- |
- KEY_EVT emerg; |
- |
- clear(); |
- |
- cprintf("Stack resource Policy demo. Press Alt-X to exit the demo\n"); |
- |
- //keyb_set_map(itaMap); |
- emerg.ascii = 'x'; |
- emerg.scan = KEY_X; |
- emerg.flag = ALTL_BIT; |
- keyb_hook(emerg,fine); |
- |
- /* --------------------------------------------------------------------- |
- Mutex creation |
- --------------------------------------------------------------------- */ |
- |
- PI_mutexattr_default(a2); |
- SRP_mutexattr_default(a); |
- mutex_init(&m1,&a); |
- mutex_init(&m2,&a); |
- mutex_init(&m3,&a); |
- |
- |
- /* --------------------------------------------------------------------- |
- Task creation |
- --------------------------------------------------------------------- */ |
- |
- hard_task_default_model(m); |
- hard_task_def_mit(m, 1000000); |
- hard_task_def_wcet(m, 80000); |
- SRP_res_default_model(r, 3); |
- p0 = task_createn("JH", Jh, (TASK_MODEL *)&m, &r, SRP_usemutex(&m3), SRP_usemutex(&m1), NULL); |
- if (p0 == NIL) |
- { cprintf("Can't create JH task...\n"); return 1; } |
- |
- hard_task_default_model(m); |
- hard_task_def_mit(m, 2100000); |
- hard_task_def_wcet(m, 80000); |
- SRP_res_default_model(r, 2); |
- p1 = task_createn("JM", Jm, (TASK_MODEL *)&m, &r, SRP_usemutex(&m3), SRP_usemutex(&m1), |
- SRP_usemutex(&m2), NULL); |
- if (p1 == NIL) |
- { cprintf("Can't create JM task...\n"); return 1; } |
- |
- hard_task_default_model(m); |
- hard_task_def_mit(m, 10000000); |
- hard_task_def_wcet(m, 3000000); |
- SRP_res_default_model(r, 1); |
- p2 = task_createn("JL", Jl, (TASK_MODEL *)&m, &r, SRP_usemutex(&m3), SRP_usemutex(&m1), |
- SRP_usemutex(&m2), NULL); |
- if (p2 == NIL) |
- { cprintf("Can't create JL task...\n"); return 1; } |
- |
- /* --------------------------------------------------------------------- |
- Event post |
- --------------------------------------------------------------------- */ |
- |
- t.tv_sec = 0; |
- t.tv_nsec = 500000000; |
- |
- kern_cli(); |
- kern_event_post(&t,startJ,(void *)p1); |
- |
- t.tv_sec = 1; |
- kern_event_post(&t,startJ,(void *)p0); |
- kern_sti(); |
- |
- task_activate(p2); |
- |
- cprintf("END main\n"); |
- |
- return 0; |
-} |
Index: tags/rel_1_22/base/imdemo.c |
=================================================================== |
--- tags/rel_1_22/base/imdemo.c (revision 1310) |
+++ tags/rel_1_22/base/imdemo.c (nonexistent) |
@@ -1,99 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * |
- * CVS : $Id: imdemo.c,v 1.1 2002-11-11 08:22:45 pj Exp $ |
-**/ |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/cbs.h" |
-#include "modules/rr.h" |
-#include "modules/dummy.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
-#include "modules/pi.h" |
-#include "modules/pc.h" |
-#include "modules/srp.h" |
-#include "modules/npp.h" |
-#include "modules/nop.h" |
- |
-#include "drivers/keyb.h" |
- |
- |
-/*+ sysyem tick in us +*/ |
-//#define TICK 1000 |
-#define TICK 0 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 10000 |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- EDF_register_level(EDF_ENABLE_ALL); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- CBS_register_level(CBS_ENABLE_ALL, 0); |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- |
- CABS_register_module(); |
- |
- PI_register_module(); |
- PC_register_module(); |
- NPP_register_module(); |
- SRP_register_module(); |
- NOP_register_module(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- HARTPORT_init(); |
- |
- KEYB_init(NULL); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
Index: tags/rel_1_22/base/iaster3.c |
=================================================================== |
--- tags/rel_1_22/base/iaster3.c (revision 1310) |
+++ tags/rel_1_22/base/iaster3.c (nonexistent) |
@@ -1,111 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: iaster3.c,v 1.1 2002-10-28 08:13:37 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1 $ |
- Last update: $Date: 2002-10-28 08:13:37 $ |
- ------------ |
- |
- System initialization file |
- |
- The tick is set to TICK ms. |
- |
- This file contains the 2 functions needed to initialize the system. |
- |
- These functions register the following levels: |
- |
- an EDF (Earliest Deadline First) level |
- a RR (Round Robin) level |
- a TBS (Total Bandwidth Server) level 0.1 Us |
- a TBS (Total Bandwidth Server) level 0.3 Us |
- a Dummy level |
- |
- The TBS bandwidth is TBS_NUM/TBS_DEN |
- |
- |
- It can accept these task models (into () the mandatory fields): |
- |
- HARD_TASK_MODEL (wcet+mit) at level 0 |
- NRT_TASK_MODEL at level 1 |
- SOFT_TASK_MODEL (wcet, periodicity=APERIODIC) at level 2,3 |
- |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
- |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/rr.h" |
-#include "modules/tbs.h" |
-#include "modules/dummy.h" |
-#include "drivers/keyb.h" |
- |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 1200 |
- |
-#define RRTICK 5000 |
-#define TBS_NUM 1 |
-#define TBS_DEN 10 |
- |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- EDF_register_level(EDF_ENABLE_ALL); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- TBS_register_level(TBS_ENABLE_ALL, 0, TBS_NUM, TBS_DEN); |
- TBS_register_level(TBS_ENABLE_ALL, 0, TBS_NUM*3, TBS_DEN); |
- dummy_register_level(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
Index: tags/rel_1_22/base/ego.c |
=================================================================== |
--- tags/rel_1_22/base/ego.c (revision 1310) |
+++ tags/rel_1_22/base/ego.c (nonexistent) |
@@ -1,240 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: ego.c,v 1.3 2003-01-07 17:10:15 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.3 $ |
- Last update: $Date: 2003-01-07 17:10:15 $ |
- ------------ |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai and Giorgio Buttazzo |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-/****************************************************************/ |
-/* PERIODIC PROCESS TEST */ |
-/****************************************************************/ |
- |
-#include <kernel/kern.h> |
-#include <drivers/glib.h> |
-#include <drivers/keyb.h> |
- |
-#include <semaphore.h> |
- |
-#define X0 10 |
- |
-/* task periods */ |
-#define PERIOD_T1 100000 |
-#define PERIOD_T2 200000 |
-#define PERIOD_T3 300000 |
- |
-/* X position of the text printed by each task */ |
-int y[3] = {100, 180, 260}; |
- |
-/* text printed by each task */ |
-char talk[3][50] = { "I am ego1 and I print a character every 100 ms", |
- "I am ego2 and I print a character every 200 ms", |
- "I am ego3 and I print a character every 300 ms"}; |
- |
-/* A semaphore used to access Video Cards in mutual exclusion */ |
-sem_t mutex; |
- |
-/***************************************************************/ |
- |
-TASK ego(void *arg) |
-{ |
-int i = (int)arg; |
-int leng; |
-char s[2]; |
-int x; |
-int j = 0; |
- |
- /* compute the length of the string to print */ |
- leng = 0; |
- while (talk[i][leng] != 0) leng++; |
- |
- x = X0; |
- s[1] = 0; |
- task_endcycle(); |
- |
- while (1) { |
- s[0] = talk[i][j]; |
- sem_wait(&mutex); |
- /* grx_text("TEST", 100,100,12,0); */ |
- grx_text(s,x,y[i],12+i,0); |
- sem_post(&mutex); |
- x += 8; |
- if (++j == leng) { |
- j = 0; |
- x = X0; |
- y[i] += 8; |
- if (y[i]>340) y[i]=100; |
- } |
- task_endcycle(); |
- } |
-} |
- |
- |
-/****************************************************************/ |
- |
-/* This function is called when Alt-X is pressed. |
- It simply shutdown the system using sys_end. |
- Note that the byebye() function is called only if we exit from |
- the system using sys_end()!!!! |
-*/ |
-void my_end(KEY_EVT* e) |
-{ |
- sys_end(); |
-} |
- |
-/******************************************************************/ |
- |
-/* This function is called when the system exit correctly after Alt-X. |
- It exits from the graphic mode and then it prints a small greeting. |
- Note that: |
- - The function calls grx_exit, so it must be registered using |
- RUNLEVEL_BEFORE_EXIT (RUNLEVEL_AFTER_EXIT does not work because |
- at that point the kernel is already returned in real mode!!!) |
- - When an exception is raised, the exception handler is called. |
- Since the exception handler already exits from the graphic mode, |
- this funcion has not to be called. For this reason: |
- . we registered byebye using the flag NO_AT_ABORT |
- . the exception handler exits using sys_abort; in that way byebye is |
- NOT called |
-*/ |
- |
-void byebye(void *arg) |
-{ |
- grx_close(); |
- cprintf("Bye Bye!\n"); |
-} |
- |
-/****************************** MAIN ******************************/ |
- |
-int main(int argc, char **argv) |
-{ |
- PID pid1, pid2, pid3; |
- KEY_EVT emerg; |
- HARD_TASK_MODEL m1, m2, m3; |
- |
- /* Set the closing function */ |
- sys_atrunlevel(byebye, NULL, RUNLEVEL_BEFORE_EXIT); |
- |
- /* Initializes the semaphore */ |
- sem_init(&mutex,0,1); |
- |
- /* graphic card Initialization */ |
- if (grx_init() < 1) { |
- sys_abort(1); |
- } |
- |
- if (grx_open(640, 480, 8) < 0) { |
- cprintf("GRX Err\n"); |
- sys_abort(1); |
- } |
- |
- /* set the keyboard handler to exit correctly */ |
- emerg.ascii = 'x'; |
- emerg.scan = KEY_X; |
- emerg.flag = ALTL_BIT; |
- keyb_hook(emerg,my_end); |
- |
- emerg.ascii = 'x'; |
- emerg.scan = KEY_X; |
- emerg.flag = ALTR_BIT; |
- keyb_hook(emerg,my_end); |
- |
- /* a small banner */ |
- grx_text("EGO Test",8,8,WHITE,0); |
- grx_text("Press Alt-X to exit",8,16,WHITE,0); |
- |
- /* ego1 creation */ |
- hard_task_default_model(m1); |
- hard_task_def_ctrl_jet (m1); |
- hard_task_def_arg (m1, (void *)0); |
- hard_task_def_wcet (m1, 5000); |
- hard_task_def_mit (m1, PERIOD_T1); |
- hard_task_def_group (m1,1); |
- pid1 = task_create("ego1", ego, &m1, NULL); |
- if (pid1 == NIL) { |
- grx_close(); |
- perror("Could not create task <ego1>"); |
- sys_abort(1); |
- } |
- |
- /* ego2 creation */ |
- hard_task_default_model(m2); |
- hard_task_def_ctrl_jet (m2); |
- hard_task_def_arg (m2, (void *)1); |
- hard_task_def_wcet (m2, 5000); |
- hard_task_def_mit (m2, PERIOD_T2); |
- hard_task_def_group (m2,1); |
- pid2 = task_create("ego2", ego, &m2, NULL); |
- if (pid2 == NIL) { |
- grx_close(); |
- perror("Could not create task <ego2>"); |
- sys_abort(1); |
- } |
- |
- /* ego3 creation */ |
- hard_task_default_model(m3); |
- hard_task_def_ctrl_jet (m3); |
- hard_task_def_arg (m3, (void *)2); |
- hard_task_def_wcet (m3, 5000); |
- hard_task_def_mit (m3, PERIOD_T3); |
- hard_task_def_group (m3,1); |
- pid3 = task_create("ego3", ego, &m3, NULL); |
- if (pid3 == NIL) { |
- grx_close(); |
- perror("Could not create task <ego3>"); |
- sys_abort(1); |
- } |
- |
- /* and finally we activate the three threads... */ |
- group_activate(1); |
- |
- /* |
- now the task main ends, but the system does not shutdown because |
- there are the three task ego1, ego2, and ego3 running. |
- |
- The demo will finish if a Alt-X key is pressed. |
- */ |
- |
- return 0; |
-} |
- |
-/****************************************************************/ |
Index: tags/rel_1_22/base/iaster4.c |
=================================================================== |
--- tags/rel_1_22/base/iaster4.c (revision 1310) |
+++ tags/rel_1_22/base/iaster4.c (nonexistent) |
@@ -1,133 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: iaster4.c,v 1.1 2002-11-11 08:22:45 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1 $ |
- Last update: $Date: 2002-11-11 08:22:45 $ |
- ------------ |
- |
- System initialization file |
- |
- The tick is set to TICK ms. |
- |
- This file contains the 2 functions needed to initialize the system. |
- |
- These functions register the following levels: |
- |
- an EDF (Earliest Deadline First) level |
- a RR (Round Robin) level |
- a TBS (Total Bandwidth Server) level 0.1 Us |
- a TBS (Total Bandwidth Server) level 0.3 Us |
- a CBS (Constant Bandwidth Server) level |
- a Dummy level |
- |
- The TBS bandwidth is TBS_NUM/TBS_DEN |
- |
- |
- It can accept these task models (into () the mandatory fields): |
- |
- HARD_TASK_MODEL (wcet+mit) at level 0 |
- NRT_TASK_MODEL at level 1 |
- SOFT_TASK_MODEL (wcet, periodicity=APERIODIC) at level 2,3 |
- SOFT_TASK_MODEL (met,period) at level 4 |
- |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
- |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/rr.h" |
-#include "modules/tbs.h" |
-#include "modules/cbs.h" |
-#include "modules/rrsoft.h" |
-#include "modules/dummy.h" |
-#include "drivers/keyb.h" |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
- |
-/*+ sysyem tick in us +*/ |
-//#define TICK 300 |
-#define TICK 0 |
- |
-#define RRTICK 5000 |
-#define TBS_NUM 1 |
-#define TBS_DEN 10 |
- |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- EDF_register_level(EDF_ENABLE_ALL); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- TBS_register_level(TBS_ENABLE_ALL, 0, TBS_NUM, TBS_DEN); |
- TBS_register_level(TBS_ENABLE_ALL, 0, TBS_NUM*3, TBS_DEN); |
- CBS_register_level(CBS_ENABLE_ALL, 0); |
- |
-/* RRSOFT_register_level(RRTICK, RR_MAIN_NO, mb, RRSOFT_ONLY_HARD); |
- RR_register_level(RRTICK, RR_MAIN_NO, mb); |
- RRSOFT_register_level(RRTICK, RR_MAIN_NO, mb, RRSOFT_ONLY_SOFT); //cbs |
- RRSOFT_register_level(RRTICK, RR_MAIN_NO, mb, RRSOFT_ONLY_SOFT); //tbs |
- RRSOFT_register_level(RRTICK, RR_MAIN_NO, mb, RRSOFT_ONLY_SOFT); //tbs |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
-*/ |
- |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- HARTPORT_init(); |
- |
- KEYB_init(NULL); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
Index: tags/rel_1_22/base/preempt.c |
=================================================================== |
--- tags/rel_1_22/base/preempt.c (revision 1310) |
+++ tags/rel_1_22/base/preempt.c (nonexistent) |
@@ -1,149 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * |
- * CVS : $Id: preempt.c,v 1.2 2003-01-07 17:10:15 pj Exp $ |
- |
- CBS test with preemption disabling |
- |
-*/ |
- |
-#include "kernel/kern.h" |
- |
-void *periodic(void *arg) |
-{ |
- int i; |
- int y = (int)arg; |
- |
- for (i = 19; i < 60; i++) { |
- puts_xy(i,y,7,"*"); |
- |
- task_endcycle(); |
- } |
- |
- cprintf("Periodic: Task %d end.\n", exec_shadow); |
- |
- return 0; |
-} |
- |
-void *blocker(void *arg) |
-{ |
- struct timespec t; |
- |
- task_nopreempt(); |
- cprintf("Blocker: Task nopreempt\n"); |
- |
- do { |
- sys_gettime(&t); |
- } while (t.tv_sec < 5); |
- |
- cprintf("Blocker: Task preempt\n"); |
- task_preempt(); |
- |
- cprintf("Blocker: end\n"); |
- |
- return 0; |
-} |
- |
- |
- |
-int main(int argc, char **argv) |
-{ |
- struct timespec t; |
- NRT_TASK_MODEL m; |
- SOFT_TASK_MODEL m_aper; |
- PID p; |
- |
- clear(); |
- cprintf("Preemption Test.\n"); |
- cprintf("Start time: two periodic tasks and a blocker are created and activated.\n"); |
- cprintf("2 seconds : blocker calls task_nopreempt.\n"); |
- cprintf("5 seconds : task_preempt is called.\n"); |
- cprintf(" The blocked task exec its pending activations.\n"); |
- cprintf("10 seconds: the test stops.\n"); |
- puts_xy(1,20,7,"save task:"); |
- puts_xy(1,21,7,"skip task:"); |
- |
- nrt_task_default_model(m); |
- |
- soft_task_default_model(m_aper); |
- soft_task_def_met(m_aper,10000); |
- soft_task_def_period(m_aper,200000); |
- soft_task_def_group(m_aper,1); |
- soft_task_def_arg(m_aper, (void *)20); |
- soft_task_def_periodic(m_aper); |
- |
- p = task_create("save", periodic, &m_aper, NULL); |
- if (p == NIL) |
- { |
- perror("Can't create save task...\n"); |
- sys_end(); |
- } |
- |
- soft_task_def_skip_arrivals(m_aper); |
- soft_task_def_arg(m_aper, (void *)21); |
- |
- p = task_create("skip", periodic, &m_aper, NULL); |
- if (p == NIL) |
- { |
- perror("Can't create skip task...\n"); |
- sys_end(); |
- } |
- |
- p = task_create("blocker", blocker, &m, NULL); |
- if (p == NIL) |
- { |
- perror("Can't create blocker task...\n"); |
- sys_end(); |
- } |
- |
- cprintf("main : save & skip tasks activated.\n"); |
- group_activate(1); |
- |
- do { |
- sys_gettime(&t); |
- } while (t.tv_sec < 2); |
- |
- cprintf("main : blocker activated.\n"); |
- task_activate(p); |
- |
- do { |
- sys_gettime(&t); |
- } while (t.tv_sec < 10); |
- |
- cprintf("main : End!!!\n"); |
- |
- return 0; |
-} |
Index: tags/rel_1_22/base/ihello.c |
=================================================================== |
--- tags/rel_1_22/base/ihello.c (revision 1310) |
+++ tags/rel_1_22/base/ihello.c (nonexistent) |
@@ -1,95 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: ihello.c,v 1.1 2002-10-28 08:13:37 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1 $ |
- Last update: $Date: 2002-10-28 08:13:37 $ |
- ------------ |
- |
- The simplest initialization file |
- |
- The tick is set to TICK ms. |
- |
- This file contains the 2 functions needed to initialize the system. |
- |
- These functions register the following levels: |
- |
- a RR (Round Robin) level |
- a Dummy level |
- |
- It can accept these task models: |
- |
- NRT_TASK_MODEL at level 0 |
- |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
- |
- |
-#include "kernel/kern.h" |
-#include "modules/rr.h" |
-#include "modules/dummy.h" |
- |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 300 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 10000 |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
Index: tags/rel_1_22/base/iaster6.c |
=================================================================== |
--- tags/rel_1_22/base/iaster6.c (revision 1310) |
+++ tags/rel_1_22/base/iaster6.c (nonexistent) |
@@ -1,130 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: iaster6.c,v 1.1 2002-11-11 08:22:45 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1 $ |
- Last update: $Date: 2002-11-11 08:22:45 $ |
- ------------ |
- |
- System initialization file |
- |
- h3pips.c |
- |
- These functions register the following levels: |
- |
- an EDF (Earliest Deadline First) level |
- a RR (Round Robin) level |
- a CBS (Costant Bandwidth Server) level |
- a PS (Polling Server) level |
- a Dummy level |
- |
- It can accept these task models: |
- |
- HARD_TASK_MODEL (wcet+mit) at level 0 |
- NRT_TASK_MODEL at level 1 |
- SOFT_TASK_MODEL (met, period) at level 2 |
- SOFT_TASK_MODEL (periodicity=APERIODIC) at level 3 |
- |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
- |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/cbs.h" |
-#include "modules/rr.h" |
-#include "modules/dummy.h" |
-#include "modules/ps.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
-#include "modules/pi.h" |
-#include "modules/pc.h" |
-#include "modules/srp.h" |
-#include "modules/npp.h" |
-#include "modules/nop.h" |
- |
-#include "drivers/keyb.h" |
- |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 1000 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 10000 |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- EDF_register_level(EDF_ENABLE_ALL); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- CBS_register_level(CBS_ENABLE_ALL, 0); |
- PS_register_level(2 /*PS_ENABLE_ALL_EDF*/,0,500,100000); |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- |
- CABS_register_module(); |
- |
- PI_register_module(); |
- PC_register_module(); |
- NPP_register_module(); |
- SRP_register_module(); |
- NOP_register_module(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- HARTPORT_init(); |
- |
- KEYB_init(NULL); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
Index: tags/rel_1_22/base/iaster7.c |
=================================================================== |
--- tags/rel_1_22/base/iaster7.c (revision 1310) |
+++ tags/rel_1_22/base/iaster7.c (nonexistent) |
@@ -1,144 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: iaster7.c,v 1.1 2002-11-11 08:22:45 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1 $ |
- Last update: $Date: 2002-11-11 08:22:45 $ |
- ------------ |
- |
- System initialization file |
- |
- The tick is set to TICK ms. |
- |
- This file contains the 2 functions needed to initialize the system. |
- |
- These functions register a set of scheduling modules, in a fixed or |
- dynamic priority way... |
- |
- It can accept these task models: |
- |
- HARD_TASK_MODEL (wcet+mit) at level 0 |
- SOFT_TASK_MODEL (periodicity=APERIODIC) at level 1 |
- NRT_TASK_MODEL at level 2 |
- SOFT_TASK_MODEL (periodicity=APERIODIC, wcet (only if TBS) ) at level 3,4 |
- |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
- |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/tbs.h" |
- |
-#include "modules/rm.h" |
-#include "modules/rr.h" |
-#include "modules/ps.h" |
- |
-#include "modules/dummy.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
- |
-#include "drivers/keyb.h" |
- |
-#include <ll/stdio.h> |
- |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 300 |
- |
-#define RRTICK 5000 |
- |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
-// EDF_register_level(EDF_ENABLE_ALL); |
-// PS_register_level(2 /*PS_ENABLE_ALL_EDF*/,0,1000,100000); |
-// RR_register_level(RRTICK, RR_MAIN_YES, mb); |
-// TBS_register_level(TBS_ENABLE_ALL, 0, 1, 10); |
-// PS_register_level(2,0,3000,10000); |
-// TBS_register_level(TBS_ENABLE_ALL, 0, 3, 10); |
- |
- |
- RM_register_level(RM_ENABLE_ALL); |
- PS_register_level(PS_ENABLE_ALL_RM,0,1000,100000); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- PS_register_level(4,0,10000,100000); |
- PS_register_level(4,0,30000,100000); |
- |
- |
- |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- |
- return TICK; |
-} |
- |
-SOFT_TASK_MODEL m; |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- KEYB_PARMS k = BASE_KEYB; |
- |
- soft_task_default_model(m); |
- soft_task_def_wcet(m,2000); |
- soft_task_def_met(m,800); |
- soft_task_def_period(m,25000); |
- soft_task_def_system(m); |
- soft_task_def_nokill(m); |
- soft_task_def_aperiodic(m); |
- soft_task_def_level(m,4); |
- keyb_def_task(k,&m); |
- |
- HARTPORT_init(); |
- |
- if (KEYB_init(&k) < 0) |
- cprintf("Error during the init of the Keyboard!!!"); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
Index: tags/rel_1_22/base/aster.c |
=================================================================== |
--- tags/rel_1_22/base/aster.c (revision 1310) |
+++ tags/rel_1_22/base/aster.c (nonexistent) |
@@ -1,413 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai, Gerardo Lamastra and Giuseppe Lipari |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * |
- * CVS : $Id: aster.c,v 1.2 2003-01-07 17:10:15 pj Exp $ |
- |
- Author: Gerardo Lamastra |
- Giuseppe Lipari |
- Date: 1/10/96 |
- |
- File: Aster.C |
- Revision: 1.6 |
- |
-*/ |
- |
-/* |
- Well, this is only a stupid demo which intend to show many |
- HARTIK+ capabilities; the application is structured in the followig |
- way: there is an ASTER task wich randomly creates some ASTEROID tasks |
- which are displayed into the first window; each task is HARD/PERIODIC |
- and auto-kills itself when it reaches the window end! |
- An other couple of tasks, TITLE & PUT give an example of port |
- communication facility; the server task creates the port, the client |
- task connect to it and uses the server to accomplish some stuff. |
- Port can be declared READ/WRITE and can model ONE-TO-ONE communication |
- or MANY-TO-ONE communication. |
- Finally a second couple of tasks realizes a communiation through CABs; |
- each time a key is pressed, the ascii code is posted into the CAB by the |
- CCC task while the second task, WRITE, displays it on the screen and |
- perform other silly actions. |
- Finally a CLOCK task is implemented to test system clock. |
- Please note that usually the HARTIK+ application is made up of a task |
- group which interacts among them, while the main() function, which |
- became a task itself when the kernel is activated, is suspended until |
- the system is ready to terminate; the MAIN task can also be used to make |
- other background activities, but it should not be killed; when the |
- application terminates, the control is passed to MAIN which kills |
- everybody, shut down the system and can handle other operations using |
- the services available with the previou operating system (I.E. the DOS). |
- If you need to manage sudden abort/exception you should install your own |
- exception handler and raise it through the exc_raise() primitive to |
- make the system abort safely! |
- Remember that the exit functions posted through sys_atexit() will be |
- executed in both cases, to allow clean system shutdown. |
-*/ |
- |
-//#include <string.h> |
-//#include <stdlib.h> |
- |
-#include <kernel/kern.h> |
-#include <modules/sem.h> |
-#include <modules/hartport.h> |
-#include <modules/cabs.h> |
-#include <drivers/keyb.h> |
-#include <string.h> |
- |
- |
-#define __VPAGING__ |
- |
-#include <drivers/keyb.h> |
-#include <drivers/crtwin.h> |
- |
-int num_aster = 0; |
-#define ASTER_LIM 67 |
- |
-CAB cc; |
-BYTE esc = FALSE; |
- |
-TASK asteroide(void) |
-{ |
- int i = 1; |
- int y = rand() % 7 + 1; |
- while (i < ASTER_LIM) { |
- puts_xy(i,y,WHITE,"*"); |
- task_endcycle(); |
- |
- puts_xy(i,y,WHITE," "); |
- i++; |
- } |
- num_aster--; |
- return 0; |
-} |
- |
-DWORD taskCreated = 0; |
- |
-TASK aster(void) |
-{ |
- PID p; |
- SOFT_TASK_MODEL m_soft; |
- int r; |
- WIN w; |
- |
- win_init(&w,0,0,ASTER_LIM,8); |
- win_frame(&w,BLACK,WHITE,"Asteroids",2); |
- |
- soft_task_default_model(m_soft); |
- soft_task_def_met(m_soft,2000); |
- soft_task_def_ctrl_jet(m_soft); |
- |
- srand(7); |
- while (1) { |
- if (num_aster < 5) { |
- r = (rand() % 50) - 25; |
- soft_task_def_arg(m_soft,(void *)((rand() % 7)+1)); |
- soft_task_def_period(m_soft,(50 + r)*1000); |
- p = task_create("aaa",asteroide,(TASK_MODEL *)&m_soft,NULL); |
- taskCreated++; |
- task_activate(p); |
- num_aster++; |
- } |
- |
- task_endcycle(); |
- } |
-} |
- |
-TASK clock() |
-{ |
- WIN w; |
- int s = 0, m = 0; |
- |
- win_init(&w,68,0,11,2); |
- win_frame(&w,BLACK,WHITE,"Clk",1); |
- |
- while(1) { |
- printf_xy(70,1,WHITE,"%2d : %2d",m,s); |
- task_endcycle(); |
- |
- if (++s > 59) { |
- s = 0; |
- m++; |
- } |
- printf_xy(70,1,WHITE,"%2d : %2d",m,s); |
- task_endcycle(); |
- } |
-} |
- |
-TASK title() |
-{ |
- PORT t; |
- WIN w; |
- int i,pos = 77; |
- char msg[85],tmp[85],ss[2]; |
- BYTE c; |
- |
- win_init(&w,0,9,79,2); |
- win_frame(&w,BLACK,WHITE,"Title",2); |
- |
- for (i=0; i < 77; i++) msg[i] = ' '; |
- msg[77] = 0; |
- |
- t = port_connect("title",1,STREAM,READ); |
- |
- while (1) { |
- port_receive(t,&c,BLOCK); |
- ss[0] = c; |
- ss[1] = 0; |
- strcat(msg,ss); |
- puts_xy(1,10,WHITE,msg); |
- pos++; |
- if (pos > 77) { |
- strcpy(tmp,&(msg[1])); |
- tmp[pos-1] = 0; |
- pos -= 1; |
- strcpy(msg,tmp); |
- } |
- task_endcycle(); |
- } |
-} |
- |
-#define STR "..................... Hartik+ ....................."\ |
- " Guarantees hard tasks "\ |
- " Includes soft periodic tasks "\ |
- "TB server for decrementing the aperiodic response time "\ |
- "SRP for both hard & soft aperiodic tasks "\ |
- "Portability toward other compilers/system "\ |
- "Support for different C compiler: Watcom C 16 bit & 32 bit"\ |
- " -- GNU C (32 bit) -- Borland C (16 bit) -- MS C (16 bit)"\ |
- " "\ |
- "Programmers : Gerardo Lamastra (lamastra@sssup2.sssup.it) "\ |
- " Giuseppe Lipari (lipari@sssup2.sssup.it) "\ |
- "Alpha AXP PCI-33 porting by Antonino Casile "\ |
- "(casile@sssup1.sssup.it) "\ |
- "Research coordinator: Giorgio Buttazzo (giorgio@sssup1.sssup.it)"\ |
- " "\ |
- " "\ |
- " " |
- |
-static char GreetMsg[1600]; |
- |
-TASK put(void) |
-{ |
- PORT p; |
- |
- strcpy(GreetMsg,STR); |
- |
- p = port_create("title",strlen(GreetMsg),1,STREAM,WRITE); |
- while(1) { |
- port_send(p,GreetMsg,BLOCK); |
- task_endcycle(); |
- } |
-} |
- |
-TASK ccc(void) |
-{ |
- WIN w; |
- char *m; |
- |
- win_init(&w,68,3,10,3); |
- win_frame(&w,BLACK,WHITE,"CCC",2); |
- puts_xy(70,4,WHITE,"Cab"); |
- |
- while(1) { |
- m = cab_getmes(cc); |
- puts_xy(72,5,WHITE,m); |
- cab_unget(cc,m); |
- task_endcycle(); |
- } |
-} |
- |
- |
-TASK write_keyb() |
-{ |
- BYTE c; |
- char *msg; |
- |
- while (1) { |
- c = keyb_getchar(); |
- if (c == ESC) { |
- esc = TRUE; |
- task_endcycle(); |
- } |
- else { |
-#ifdef __VPAGING__ |
- if (c == 's') { |
- if (get_visual_page() == 0) set_visual_page(1); |
- else if (get_visual_page() == 1) set_visual_page(0); |
- } |
-#endif |
- msg = cab_reserve(cc); |
- msg[0] = c; |
- msg[1] = 0; |
- cab_putmes(cc,msg); |
- } |
- } |
-} |
- |
-#define DELTA 200000.0 |
-double carico(double rif,BYTE init) |
-{ |
- double i; |
- DWORD t1 = 0,t2 = 1000; |
- double u; |
- |
- i = 0.0; |
- do { |
- i += 1; |
- } while (i <= DELTA); |
- |
- u = i / ((double) (t2 - t1)); |
- |
- if (init) return u; |
- else return (1.0 - u/rif); |
-} |
- |
-void my_end(KEY_EVT *e) |
-{ |
- set_active_page(0); |
- set_visual_page(0); |
- cprintf("Ctrl-Brk pressed!\n"); |
- sys_end(); |
-} |
- |
-int main(int argc, char **argv) |
-{ |
- PID p1,p2,p3,p4,p5,p6; |
- |
- HARD_TASK_MODEL m_per; |
- SOFT_TASK_MODEL m_soft; |
- NRT_TASK_MODEL m_nrt; |
- |
- KEY_EVT emerg; |
- // double rif; |
- struct timespec t; |
- |
- //keyb_set_map(itaMap); |
- emerg.ascii = 'x'; |
- emerg.scan = KEY_X; |
- emerg.flag = ALTL_BIT; |
- keyb_hook(emerg,my_end); |
- |
-#ifdef __VPAGING__ |
- set_active_page(1); |
- set_visual_page(1); |
-#endif |
- |
- |
- CRSR_OFF(); |
- clear(); |
- puts_xy(0,20,WHITE,"Press ESC to exit demo."); |
- cc = cab_create("Cab",2,2); |
- |
- soft_task_default_model(m_soft); |
- soft_task_def_period(m_soft,500000); |
- soft_task_def_met(m_soft,1000); |
- soft_task_def_group(m_soft, 1); |
- p1 = task_create("Aster",aster,&m_soft,NULL); |
- if (p1 == -1) { |
- perror("Aster.C(main): Could not create task <aster>"); |
- sys_abort(-1); |
- } |
- |
- hard_task_default_model(m_per); |
- hard_task_def_mit(m_per,500000); |
- hard_task_def_wcet(m_per,1000); |
- hard_task_def_group(m_per, 1); |
- p2 = task_create("Clock",clock,&m_per,NULL); |
- if (p2 == -1) { |
- perror("Aster.C(main): Could not create task <Clock>"); |
- sys_abort(-1); |
- } |
- |
- soft_task_def_period(m_soft, 50000); |
- p3 = task_create("Title",title,&m_soft, NULL); |
- if (p3 == -1) { |
- perror("Aster.C(main): Could not create task <Title>"); |
- sys_abort(-1); |
- } |
- |
- soft_task_def_period(m_soft, 1000000); |
- p4 = task_create("Put",put,&m_soft, NULL); |
- if (p4 == -1) { |
- perror("Aster.C(main): Could not create task <Put>"); |
- sys_abort(-1); |
- } |
- |
- nrt_task_default_model(m_nrt); |
- nrt_task_def_group(m_nrt, 1); |
- p5 = task_create("Write",write_keyb,&m_nrt,NULL); |
- if (p5 == -1) { |
- perror("Aster.C(main): Could not create task <Write>"); |
- sys_abort(-1); |
- } |
- |
- hard_task_def_mit(m_per, 50000); |
- p6 = task_create("CabTask",ccc,&m_per,NULL); |
- if (p6 == -1) { |
- perror("Aster.C(main): Could not create task <CabTask>\n"); |
- sys_abort(-1); |
- } |
- |
- /* |
- task_activate(p1); |
- task_activate(p2); |
- task_activate(p3); |
- task_activate(p4); |
- task_activate(p5); |
- task_activate(p6); |
- */ |
- group_activate(1); |
- |
- while (!esc) { |
- sys_gettime(&t); |
- printf_xy(0,21,WHITE,"Clock : %-9ds %-9dns",(int)t.tv_sec, (int)t.tv_nsec); |
- } |
- |
- group_kill(1); |
- clear(); |
- CRSR_STD(); |
-#ifdef __VPAGING__ |
- set_active_page(0); |
- set_visual_page(0); |
-#endif |
- cprintf("System closed\n"); |
- sys_end(); |
- /* |
- sys_status(NORM_STATUS|BLOCKED_STATUS|SLEEP_STATUS|IDLE_STATUS); |
- sys_status(NORM_STATUS|SLEEP_STATUS); |
- */ |
- return 0; |
-} |
- |
Index: tags/rel_1_22/base/iaster8.c |
=================================================================== |
--- tags/rel_1_22/base/iaster8.c (revision 1310) |
+++ tags/rel_1_22/base/iaster8.c (nonexistent) |
@@ -1,128 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: iaster8.c,v 1.1 2002-11-11 08:22:45 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1 $ |
- Last update: $Date: 2002-11-11 08:22:45 $ |
- ------------ |
- |
- System initialization file |
- |
- h3piss.c |
- |
- These functions register the following levels: |
- |
- an EDF (Earliest Deadline First) level |
- a CBS (Costant Bandwidth Server) level |
- a SS (Sporadic Server) level |
- a RR (Round Robin) level |
- a Dummy level |
- |
- It can accept these task models: |
- |
- HARD_TASK_MODEL (wcet+mit) at level 0 |
- SOFT_TASK_MODEL (met, period) at level 1 |
- SOFT_TASK_MODEL (periodicity=APERIODIC) at level 2 |
- NRT_TASK_MODEL at level 3 |
- |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
- |
- |
-#include "kernel/kern.h" |
-#include "modules/rm.h" |
-#include "modules/edf.h" |
-#include "modules/cbs.h" |
-#include "modules/rr.h" |
-#include "modules/dummy.h" |
-#include "modules/ss.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
-#include "modules/pi.h" |
-#include "modules/pc.h" |
-#include "modules/srp.h" |
-#include "modules/npp.h" |
-#include "modules/nop.h" |
- |
-#include "drivers/keyb.h" |
- |
- |
-/*+ system tick in us +*/ |
-#define TICK 1000 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 10000 |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- EDF_register_level(EDF_ENABLE_ALL); |
- CBS_register_level(CBS_ENABLE_ALL, 0); |
- SS_register_level(SS_ENABLE_GUARANTEE_EDF,0,5000,20000); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- |
- CABS_register_module(); |
- |
- PC_register_module(); |
- PI_register_module(); |
- NPP_register_module(); |
- SRP_register_module(); |
- NOP_register_module(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- HARTPORT_init(); |
- KEYB_init(NULL); |
- __call_main__(mb); |
- return (void *)0; |
-} |
- |
Index: tags/rel_1_22/base/pcidemo.c |
=================================================================== |
--- tags/rel_1_22/base/pcidemo.c (revision 1310) |
+++ tags/rel_1_22/base/pcidemo.c (nonexistent) |
@@ -1,86 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai, Luca Abeni |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * |
- * CVS : $Id: pcidemo.c,v 1.1 2002-11-11 08:22:46 pj Exp $ |
- |
- This is the pcitest Hartik's example. |
- |
-*/ |
- |
-#include "kernel/kern.h" |
-#include "drivers/keyb.h" |
- |
-#include "drivers/llpci.h" |
-#include "drivers/pci.h" |
- |
-void scan() |
-{ |
- BYTE bus, dev; |
- |
- /* Scan the devices connected to the PCI bus */ |
- if (pci_init() == 1) { |
- clear(); |
- pci_show(); |
- bus = 0; dev = 0; |
- if (pcibios_find_device(0x8086, 0x7000, 0, &bus, &dev) == NULL) |
- cprintf("Not found... %d %d\n", bus, dev); |
- else cprintf("Found: %d \t %d\n", bus, dev); |
- |
- if (pcibios_find_class(0x300, 0, &bus, &dev) == NULL) |
- cprintf("Not found... %d %d\n", bus, dev); |
- else cprintf("Found: %d \t %d\n", bus, dev); |
- } else cprintf("PCI not found!!!\n"); |
-} |
- |
-void endfun(KEY_EVT *k) |
-{ |
- sys_end(); |
-} |
- |
-int main (int argc, char *argv[]) |
-{ |
- KEY_EVT k; |
- |
- k.flag = CNTR_BIT; |
- k.scan = KEY_C; |
- k.ascii = 'c'; |
- keyb_hook(k,endfun); |
- |
- scan(); |
- |
- sys_end(); |
- return 0; |
-} |
Index: tags/rel_1_22/base/sig.c |
=================================================================== |
--- tags/rel_1_22/base/sig.c (revision 1310) |
+++ tags/rel_1_22/base/sig.c (nonexistent) |
@@ -1,168 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: sig.c,v 1.3 2003-01-07 17:10:15 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.3 $ |
- Last update: $Date: 2003-01-07 17:10:15 $ |
- ------------ |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai and Giorgio Buttazzo |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-/* |
- Test Number 5: |
- |
- this test is a simple main() function with one other task |
- |
- This test can be useful to test functions like: |
- |
- sys_gettime |
- sigemptyset |
- sigaddset |
- hartik_deliver_pending_signals |
- sys_end |
- task_sigmask |
- sigaction |
- sigqueue |
- task_signal |
-*/ |
- |
-#include "kernel/kern.h" |
- |
- |
-TASK goofy(void *arg) |
-{ |
- struct timespec t; |
- |
- cprintf("Goofy: waiting 2 secs...\n"); |
- |
- do { |
- sys_gettime(&t); |
- } while (t.tv_sec < 2); // wait until 2 sec |
- |
- cprintf("Goofy: ok, I'm ready :-)\n"); |
- |
- return 0; |
-} |
- |
-void catchit_RT(int signo, siginfo_t *info, void *extra) |
-{ |
- cprintf("RT signal: Current Running Task = %d signo=%d code=%d value=%d from pid=%d\n", |
- exec_shadow, |
- info->si_signo, info->si_code, |
- info->si_value.sival_int, info->si_task); |
-} |
- |
-void catchit(int signo) |
-{ |
- cprintf("RT signal: Current Running Task = %d signo=%d\n", |
- exec_shadow, signo); |
-} |
- |
-int main(int argc, char **argv) |
-{ |
- struct timespec t; |
- NRT_TASK_MODEL m; |
- PID p2; |
- |
- sigset_t newmask; |
- sigset_t oldmask; |
- struct sigaction action; |
- union sigval sval; |
- |
- clear(); |
- |
- /* Set the signal action */ |
- action.sa_flags = SA_SIGINFO; |
- action.sa_sigaction = catchit_RT; |
- action.sa_handler = 0; |
- action.sa_mask = 0; |
- |
- if (sigaction(SIGUSR1, &action, NULL) == -1) { |
- perror("Error using sigaction."); |
- return -1; |
- } |
- |
- action.sa_flags = 0; |
- action.sa_handler = (void (*)(int))catchit; |
- |
- if (sigaction(SIGILL, &action, NULL) == -1) { |
- perror("Error using sigaction."); |
- return -1; |
- } |
- |
- /* create another task */ |
- nrt_task_default_model(m); |
- nrt_task_def_group(m,1); |
- |
- p2 = task_create("goofy", goofy, &m, NULL); |
- if (p2 == NIL) |
- { |
- cprintf("Can't create goofy task...\n"); |
- return 1; |
- } |
- |
- group_activate(1); |
- |
- /* block the signal for the main task */ |
- sigemptyset(&newmask); |
- sigaddset(&newmask,SIGUSR1); |
- task_sigmask(SIG_BLOCK, &newmask, &oldmask); // pthread_sigmask |
- |
- cprintf("main: Sending 2 signals ...\n"); |
- |
- sval.sival_int = 123; |
- sigqueue(0,SIGUSR1,sval); |
- sval.sival_int = 999; |
- sigqueue(0,SIGUSR1,sval); |
- |
- cprintf("main: Now sending a signal to myself," |
- " then wait until 4 secs...\n"); |
- |
- task_signal(0 /* main */, SIGILL); // pthread_kill |
- |
- NULL_TIMESPEC(&t); |
- do { |
- sys_gettime(&t); |
- } while (t.tv_sec < 4); // wait until 4 s |
- |
- cprintf("main: ending...\n"); |
- |
- return 0; |
-} |
Index: tags/rel_1_22/base/keycode.c |
=================================================================== |
--- tags/rel_1_22/base/keycode.c (revision 1310) |
+++ tags/rel_1_22/base/keycode.c (nonexistent) |
@@ -1,80 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Giorgio Buttazzo, Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * |
- * CVS : $Id: keycode.c,v 1.1 2002-11-11 08:22:46 pj Exp $ |
- */ |
- |
-#include <kernel/kern.h> |
-#include <drivers/keyb.h> |
- |
-int main(int argc, char **argv) |
-{ |
- KEY_EVT k; |
- |
- clear(); |
- k.ascii = 0; |
- |
- cprintf("Press ESC to end the demo, 2 for itamap, 3 for engmap\n"); |
- while (k.ascii != ESC) { |
- keyb_getcode(&k,BLOCK); |
- if (k.ascii == '2') { |
- keyb_set_map(itaMap); |
- cprintf("\nItalian Keymap set\n"); |
- } |
- if (k.ascii == '3') { |
- keyb_set_map(engMap); |
- cprintf("\nEnglish Keymap set\n"); |
- } |
- if (isLeftCtrl(k)) putc_xy(72+0,0,RED,'L'); |
- else putc_xy(72+0,0,RED,' '); |
- if (isRightCtrl(k)) putc_xy(72+1,0,RED,'R'); |
- else putc_xy(72+1,0,RED,' '); |
- if (isLeftAlt(k)) putc_xy(72+2,0,GREEN,'L'); |
- else putc_xy(72+2,0,RED,' '); |
- if (isRightAlt(k)) putc_xy(72+3,0,GREEN,'R'); |
- else putc_xy(72+3,0,RED,' '); |
- if (isLeftShift(k)) putc_xy(72+4,0,YELLOW,'L'); |
- else putc_xy(72+4,0,RED,' '); |
- if (isRightShift(k)) putc_xy(72+5,0,YELLOW,'R'); |
- else putc_xy(72+5,0,RED,' '); |
- |
- cprintf("%d [%c]\t",k.scan,k.ascii); |
- |
- } |
- |
- sys_end(); |
- return 0; |
-} |
Index: tags/rel_1_22/kalm3d/carrello.c |
=================================================================== |
--- tags/rel_1_22/kalm3d/carrello.c (revision 1310) |
+++ tags/rel_1_22/kalm3d/carrello.c (nonexistent) |
@@ -1,198 +0,0 @@ |
-#include <math.h> |
- |
-#include <modules/hartport.h> |
-#include <kernel/kern.h> |
-#include <kernel/func.h> |
-#include <ll/i386/x-dos.h> |
- |
-#include "drivers/pclab.h" |
- |
-#include "const.h" |
- |
-float vmax = 0.0, vmin = 0.0, vmaxth = 0.0, vminth = 0.0; |
- |
-int da_motor(float v) |
-{ |
- |
- da_conv( 2.5 , 2 ); |
- da_conv( v + 2.5 , 1 ); |
- |
- return(0); |
- |
-} |
- |
-float v2x(float v) |
-{ |
- float x; |
- |
- x= LUNGH * (v-(vmax+vmin)/2 ) / (vmax-vmin); |
- |
- return x; |
- |
-} |
- |
-float v2theta(float v) |
-{ |
- float theta; |
- |
- theta=2.0*(THETAMAX/FCA) * (v-(vmaxth+vminth)/2 ) / (vmaxth-vminth); |
- |
- return theta; |
- |
-} |
- |
-float bass1(float u) |
-{ |
- float y; |
- static float oldy=0; |
- |
- y=(oldy + prm.WCUT * DEADSECX(PERIOD_CARRELLO) *u)/(1+ prm.WCUT * DEADSECX(PERIOD_CARRELLO)); |
- oldy=y; |
- |
- return y; |
- |
-} |
- |
-float bass2(float u) |
-{ |
- float y; |
- static float oldy=0; |
- |
- y=(oldy + prm.WCUT1 * DEADSECX(PERIOD_CARRELLO) *u)/(1+ prm.WCUT1 * DEADSECX(PERIOD_CARRELLO)); |
- oldy=y; |
- |
- return y; |
- |
-} |
- |
-float bass3(float u) |
-{ |
- float y; |
- static float oldy=0; |
- |
- y=(oldy + prm.WCUT * DEADSECTH(PERIOD_CARRELLO) *u)/(1+ prm.WCUT * DEADSECTH(PERIOD_CARRELLO)); |
- oldy=y; |
- |
- return y; |
- |
-} |
- |
-float bass4(float u) |
-{ |
- float y; |
- static float oldy=0; |
- |
- y=(oldy + prm.WCUT1 * DEADSECTH(PERIOD_CARRELLO) *u)/(1+ prm.WCUT1 * DEADSECTH(PERIOD_CARRELLO)); |
- oldy=y; |
- |
- return y; |
- |
-} |
- |
-float dx(float u) |
-{ |
- static float oldu=0; |
- float y; |
- |
- y=(u-oldu)/DEADSECX(PERIOD_CARRELLO); |
- oldu=u; |
- |
- return y; |
- |
-} |
- |
-float dth(float u) |
-{ |
- static float oldu=0; |
- float y; |
- |
- y=(u-oldu)/DEADSECTH(PERIOD_CARRELLO); |
- oldu=u; |
- |
- return y; |
- |
-} |
- |
-TASK carrello(void) |
-{ |
- float y[2]={0,0}, yp[2]={0,0}; |
- PORT px, pth; |
- |
- float th_input = 0.0,arr_th_input[AVR],th_eff,av_th_input; |
- float x_input = 0.0,arr_x_input[AVR],x_eff,av_x_input; |
- |
- int flag_th=1,flag_x=1,index_th=0,index_x=0; |
- |
- int i; |
- float offset,vout,vout_total; |
- |
- px = port_create("porta1",sizeof(float),1,STICK,WRITE); |
- pth = port_create("porta2",sizeof(float),1,STICK,WRITE); |
- |
- while (1) { |
- |
- task_nopreempt(); |
- th_input=ad_conv(10); |
- task_preempt(); |
- |
- if(flag_th==1) { |
- for(i=0; i<AVR;++i) arr_th_input[i] = th_input; |
- flag_th=0; |
- } |
- av_th_input=0; |
- for(i=0;i<AVR;++i) av_th_input += arr_th_input[i]; |
- av_th_input /= AVR ; |
- |
- if(fabs(th_input-av_th_input)>=prm.NOISE) th_input=av_th_input; |
- |
- arr_th_input[index_th]=th_input; |
- index_th = (index_th+1) % AVR ; |
- |
- th_eff = v2theta(th_input); |
- y[1] = bass3(th_eff); |
- yp[1] = bass4(dth(y[1])); |
- |
- task_nopreempt(); |
- x_input=ad_conv(11); |
- task_preempt(); |
- |
- if(flag_x==1) { |
- for(i=0; i<AVR;++i) arr_x_input[i] = x_input; |
- flag_x=0; |
- } |
- av_x_input=0; |
- for(i=0;i<AVR;++i) av_x_input += arr_x_input[i]; |
- av_x_input /= AVR; |
- if(fabs(x_input-av_x_input)>=prm.NOISE) x_input = av_x_input; |
- |
- arr_x_input[index_x] = x_input; |
- index_x = (index_x+1) % AVR ; |
- |
- x_eff = v2x(x_input); |
- y[0] = bass1(x_eff); |
- yp[0] = bass2(dx(y[0])); |
- |
- vout = prm.COST * (prm.GUAD[0] * (y[0]-v2x((vmax+vmin)/2)) + prm.GUAD[1] * th_eff\ |
- + prm.GUAD[2] * yp[0] + prm.GUAD[3] * yp[1]); |
- |
- if(vout >= 0) offset=prm.OFFSVAL; |
- else offset=-prm.OFFSVAL; |
- |
- vout_total = vout + offset; |
- |
- if(vout_total >= VDANG ) vout_total = VDANG ; |
- if(vout_total <= -VDANG ) vout_total = -VDANG ; |
- |
- da_motor(vout_total); |
- |
- port_send(px, &y[0], NON_BLOCK); |
- port_send(pth, &y[1], NON_BLOCK); |
- |
- task_endcycle(); |
- |
- } |
- |
- port_delete(px); |
- port_delete(pth); |
- |
-} /* FINE DEL TASK CARRELLO */ |
Index: tags/rel_1_22/kalm3d/initfile.c |
=================================================================== |
--- tags/rel_1_22/kalm3d/initfile.c (revision 1310) |
+++ tags/rel_1_22/kalm3d/initfile.c (nonexistent) |
@@ -1,120 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- ------------ |
- CVS : $Id: initfile.c,v 1.1 2003-03-13 13:11:40 giacomo Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1 $ |
- Last update: $Date: 2003-03-13 13:11:40 $ |
- ------------ |
- |
- System initialization file |
- |
- This file contains the 2 functions needed to initialize the system. |
- |
- These functions register the following levels: |
- |
- an EDF (Earliest Deadline First) level |
- a RR (Round Robin) level |
- a CBS (Costant Bandwidth Server) level |
- a Dummy level |
- |
- It can accept these task models: |
- |
- HARD_TASK_MODEL (wcet+mit) at level 0 |
- SOFT_TASK_MODEL (met, period) at level 1 |
- NRT_TASK_MODEL at level 2 |
- |
- This file is similar to the configuration of kernel/init/hartik3.c |
- |
- TICK is set to 0 (one-shot timer is used) |
-*/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/cbs.h" |
-#include "modules/rr.h" |
-#include "modules/dummy.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
- |
-#include "drivers/keyb.h" |
- |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 0 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 10000 |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- EDF_register_level(EDF_ENABLE_ALL); |
- CBS_register_level(CBS_ENABLE_ALL, 0); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- |
- CABS_register_module(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- KEYB_PARMS kparms = BASE_KEYB; |
- |
- HARTPORT_init(); |
- |
- keyb_def_ctrlC(kparms, NULL); |
- keyb_def_map(kparms,itaMap); |
- KEYB_init(&kparms); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
Index: tags/rel_1_22/kalm3d/readme.txt |
=================================================================== |
--- tags/rel_1_22/kalm3d/readme.txt (revision 1310) |
+++ tags/rel_1_22/kalm3d/readme.txt (nonexistent) |
@@ -1,51 +0,0 @@ |
--------------------------------------- |
-Inverted Pendulum Demo with Mesa |
- |
-by |
- |
-Giacomo Guidi <giacomo@gandalf.sssup.it> |
- |
-Last update 17/03/2003 |
--------------------------------------- |
- |
-This is the old Inverted Pendulum control |
-demo rewrited usigng the Mesa support |
- |
-The demo needs a PCL812 card present and |
-the inv.pendulum hardware |
- |
-The graphic cards actually supported are: |
- |
-GEFORCE TNT TNT2 - driver name NV3 |
-RAGE128 RADEON - driver name R128 |
-SAVAGE VIRGE - driver neme SAVAGE |
- |
--------------------------------------- |
- |
-The demo is composed by: |
- |
-MAKEFILE The makefile used to compile the application |
-README.TXT This file |
-INITFILE.C The init file |
-KALM3D.C The Inv.Pendulum Demo |
-CARRELLO.C The control task |
- |
--------------------------------------- |
- |
-- To specify your card change the line |
- |
-#define CARD <driver name> |
- |
-- The demo calls the grx and off-screen Mesa functions. |
-The resolution must be 16 bitsperpixel (64K colors) and |
-the graphic access mode must be linear. |
- |
-- There are two buffers |
- |
- The video buffer (video_buf) |
- The virtual buffer (rgb_565_buf) |
- |
- copy_videomem_16to16 links these buffers |
- |
- |
- |
Index: tags/rel_1_22/kalm3d/const.h |
=================================================================== |
--- tags/rel_1_22/kalm3d/const.h (revision 1310) |
+++ tags/rel_1_22/kalm3d/const.h (nonexistent) |
@@ -1,36 +0,0 @@ |
-#ifndef __CONST__ |
-#define __CONST__ |
- |
-extern unsigned long int PERIOD_CARRELLO; |
-extern unsigned long int PERIOD_DISEGNA; |
- |
-#define DEADSECX(x) (x * 1.0e-6 ) |
-#define DEADSECTH(x) (x * 1.0e-6 ) |
- |
-#define PARAM {{ 1. , 300 , 0.79 , 23 },0.70 ,2.5 ,20.,20., 0.1, 1 , 1, 0.} |
- |
-#define LUNGH 35.0 |
-#define THETAMAX 45.0 |
-#define FCA 57.29578 |
-#define AVR 10 |
-#define VDANG 2.4 |
-#define NMAX 300 |
-#define SEC_ID 7.0 |
-#define MAXRUN_ID 9 //16 |
- |
-struct Parametri{ |
- float GUAD[4]; |
- float COST; |
- float NOISE; |
- float WCUT; |
- float WCUT1; |
- float OFFSVAL; |
- int DEADLINE; |
- int SCAN; |
- float XTRASL; |
-}; |
- |
-extern struct Parametri prm; |
-extern float vmax, vmin, vmaxth, vminth; |
- |
-#endif |
Index: tags/rel_1_22/kalm3d/kalm3d.c |
=================================================================== |
--- tags/rel_1_22/kalm3d/kalm3d.c (revision 1310) |
+++ tags/rel_1_22/kalm3d/kalm3d.c (nonexistent) |
@@ -1,454 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Giacomo Guidi <giacomo@gandalf.sssup.it> |
- * |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-#include <ll/i386/defs.h> |
- |
-#include <drivers/vga.h> |
-#include <drivers/pclab.h> |
- |
-#include <math.h> |
-#include <stdlib.h> |
-#include <kernel/log.h> |
-#include <GL/osmesa.h> |
-#include <GL/glut.h> |
- |
-#include <modules/hartport.h> |
-#include <kernel/kern.h> |
-#include <kernel/func.h> |
-#include <ll/i386/x-dos.h> |
-#include <drivers/keyb.h> |
- |
-#include "const.h" |
- |
-#define WIDTH 640 |
-#define HEIGHT 480 |
-#define BYTES_PP 2 |
-#define INITSTR G640x480x64K |
-#define CARD SAVAGE |
- |
-unsigned long int PERIOD_CARRELLO = 10000; |
-unsigned long int PERIOD_DISEGNA = 80000; |
-struct Parametri prm=PARAM; |
- |
-unsigned long int WCET_CARRELLO, WCET_DISEGNA; |
- |
-TASK carrello(void *); |
- |
-PID carrello_PID, disegna_PID; |
- |
-unsigned char *buffers = NULL; |
-unsigned char *vbuf = NULL; |
-OSMesaContext ctx; |
- |
-static GLfloat view_rotx = 170.0, view_roty = -200.0, view_rotz = 0.0; |
-static GLfloat angle; |
- |
-GLUquadricObj *quadratic; |
- |
-static GLfloat SUP_W = 110.0; |
-static GLfloat SUP_P = 30.0; |
- |
-extern void da_motor(float v); |
- |
-#ifndef M_PI |
-#define M_PI 3.14159265 |
-#endif |
- |
-void program_end(void) |
-{ |
- |
- da_motor(0.0); |
- |
- OSMesaDestroyContext(ctx); |
- free(buffers); |
- |
- vga_setmode(TEXT,CARD); |
- |
- sys_end(); |
- |
-} |
- |
-void program_key_end(KEY_EVT *k) |
-{ |
- |
- sys_end(); |
- |
-} |
- |
-static void draw_box(GLfloat p1x, GLfloat p1y ,GLfloat p1z, GLfloat p2x, GLfloat p2y, GLfloat p2z) { |
- |
- glBegin(GL_QUADS); |
- |
- // Front Face |
- glVertex3f(p1x, p1y, p1z); |
- glVertex3f(p2x, p1y, p1z); |
- glVertex3f(p2x, p2y, p1z); |
- glVertex3f(p1x, p2y, p1z); |
- |
- // Back Face |
- glVertex3f(p1x, p1y, p2z); |
- glVertex3f(p1x, p2y, p2z); |
- glVertex3f(p2x, p2y, p2z); |
- glVertex3f(p2x, p1y, p2z); |
- |
- // Top Face |
- glVertex3f(p1x, p2y, p2z); |
- glVertex3f(p1x, p2y, p1z); |
- glVertex3f(p2x, p2y, p1z); |
- glVertex3f(p2x, p2y, p2z); |
- |
- // Bottom Face |
- glVertex3f(p1x, p1y, p2z); |
- glVertex3f(p2x, p1y, p2z); |
- glVertex3f(p2x, p1y, p1z); |
- glVertex3f(p1x, p1y, p1z); |
- |
- // Right face |
- glVertex3f(p2x, p1y, p2z); |
- glVertex3f(p2x, p2y, p2z); |
- glVertex3f(p2x, p2y, p1z); |
- glVertex3f(p2x, p1y, p1z); |
- |
- // Left Face |
- glVertex3f(p1x, p1y, p2z); |
- glVertex3f(p1x, p1y, p1z); |
- glVertex3f(p1x, p2y, p1z); |
- glVertex3f(p1x, p2y, p2z); |
- |
- glEnd(); |
- |
-} |
- |
-static void draw_carrello(GLfloat x_scene, GLfloat angle_scene) { |
- |
- static GLfloat gl_white[3] = {1.0f, 1.0f, 1.0f}; |
- static GLfloat gl_dark_gray[3] = {0.3f, 0.3f, 0.3f}; |
- static GLfloat gl_gray[3] = {0.7f, 0.7f, 0.7f}; |
- |
- glPushMatrix(); |
- |
- glColor3fv(gl_dark_gray); |
- |
- glShadeModel(GL_FLAT); |
- |
- glTranslatef(x_scene, 0.0f, 0.0f); |
- |
- draw_box(-6.0f, -6.0f, 9.0f, 6.0f, -2.0f, -9.0f); |
- draw_box(-6.0f, -2.0f, 9.0f, 6.0f, -1.0f, 4.0f); |
- |
- glColor3fv(gl_white); |
- |
- draw_box(-8.0f, -2.0f, -3.0f, 8.0f, -1.0f, -10.0f); |
- |
- glColor3fv(gl_dark_gray); |
- |
- draw_box(-5.0f, 1.0f, 8.0f, 5.0f, 9.0f, 6.0f); |
- draw_box(-5.0f,1.0f,-6.0f,5.0f,9.0f,-8.0f); |
- draw_box(-5.0f,-1.0f,8.0f,5.0f,1.0f,-8.0f); |
- |
- glShadeModel(GL_SMOOTH); |
- |
- glColor3fv(gl_white); |
- |
- glTranslatef(0.0f, 4.5f, -6.0f); |
- gluCylinder(quadratic, 2.2f, 2.2f, 12.0f, 16, 16); |
- |
- glColor3fv(gl_gray); |
- |
- glTranslatef(0.0f, 0.0f, 6.0f); |
- glRotatef(-90.0f, 1.0f, 0.0f, 0.0f); |
- glRotatef(angle_scene, 0.0f, 1.0f, 0.0f); |
- gluCylinder(quadratic, 1.3f, 1.3f, 160.0f, 16, 16); |
- glRotatef(-angle_scene, 0.0f, 1.0f, 0.0f); |
- glRotatef(-90.0f, 1.0f, 0.0f, 0.0f); |
- |
- glTranslatef(-4.0f, -2.5f, -6.0f); |
- gluCylinder(quadratic, 0.5f, 0.5f, 12.0f, 16, 16); |
- |
- glTranslatef(8.0f, 0.0f, 0.0f); |
- gluCylinder(quadratic, 0.5f, 0.5f, 12.0f, 16, 16); |
- |
- glPopMatrix(); |
- |
-} |
- |
-static void draw_support() { |
- |
- static GLfloat gl_dark_gray[3] = {0.3f, 0.3f, 0.3f}; |
- static GLfloat gl_gray[3] = {0.7f, 0.7f, 0.7f}; |
- |
- glPushMatrix(); |
- |
- glColor3fv(gl_gray); |
- |
- glShadeModel(GL_FLAT); |
- |
- draw_box(-SUP_W/2, -0.1f, SUP_P/2, SUP_W/2, 0.1f, -SUP_P/2); |
- |
- glColor3fv(gl_dark_gray); |
- |
- draw_box(-SUP_W/2-3.0f, -0.1f, SUP_P/2, -SUP_W/2, 14.0f, -SUP_P/2-0.2f); |
- draw_box(SUP_W/2, -0.1f, SUP_P/2, SUP_W/2+3.0f, 14.0f, -SUP_P/2-0.2f); |
- |
- glShadeModel(GL_SMOOTH); |
- |
- glColor3fv(gl_gray); |
- |
- glTranslatef(-SUP_W/2, 6.0f, 0.0f); |
- glRotatef(90.0f, 0.0f, 1.0f, 0.0f); |
- gluCylinder(quadratic, 1.5f, 1.5f, SUP_W, 16, 16); |
- |
- glPopMatrix(); |
- |
-} |
- |
-static void draw(GLfloat prm_x, GLfloat prm_th) |
-{ |
- |
- prm_x = -prm_x / LUNGH * (SUP_W-20.0f); |
- prm_th = -prm_th * FCA; |
- |
- glPushMatrix(); |
- |
- glRotatef(view_rotx, 1.0f, 0.0f, 0.0f); |
- glRotatef(view_roty, 0.0f, 1.0f, 0.0f); |
- glRotatef(view_rotz, 0.0f, 0.0f, 1.0f); |
- |
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
- |
- glRotatef(angle, 0.0f, 1.0f, 0.0f); |
- |
- draw_support(); |
- glTranslatef(0.0f, 10.0f, -4.0f); |
- draw_carrello(prm_x,prm_th); |
- |
- glPopMatrix(); |
- |
- glFinish(); |
- |
-} |
- |
-static void init_gl() |
-{ |
- |
- static GLfloat pos0[4] = {40.0f, -70.0f, 180.0f, 1.0f}; |
- |
- glClearColor(0.8f, 0.8f, 0.8f, 1.0f); |
- |
- glLightfv(GL_LIGHT0, GL_POSITION, pos0); |
- glEnable(GL_LIGHTING); |
- glEnable(GL_LIGHT0); |
- glEnable(GL_DEPTH_TEST); |
- glEnable(GL_CULL_FACE); |
- |
- glViewport(0, 0, (GLint) WIDTH, (GLint) HEIGHT); |
- glMatrixMode(GL_PROJECTION); |
- glLoadIdentity(); |
- gluPerspective(45.0f,(GLfloat)WIDTH/(GLfloat)HEIGHT,0.1f,250.0f); |
- glMatrixMode(GL_MODELVIEW); |
- glLoadIdentity(); |
- glTranslatef(0.0f, 30.0f, -120.0f); |
- |
- glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); |
- |
- quadratic=gluNewQuadric(); |
- |
- glEnable(GL_AUTO_NORMAL); |
- glEnable(GL_COLOR_MATERIAL); |
- glEnable(GL_NORMALIZE); |
- glDepthFunc(GL_LEQUAL); |
- |
-} |
- |
-TASK disegna(void) |
-{ |
- |
- PORT pr_x, pr_th; |
- float prm_x, prm_th; |
- |
- char text[100]; |
- TIME disegna_TIME, carrello_TIME; |
- |
- static unsigned long int count = WIDTH * HEIGHT / 2; |
- |
- pr_x = port_connect("porta1",sizeof(float),STICK,READ); |
- pr_th = port_connect("porta2",sizeof(float),STICK,READ); |
- |
- //vbuf = malloc(WIDTH * HEIGHT * 2); //Debug line |
- |
- while(1) { |
- |
- port_receive(pr_x, &prm_x, BLOCK); |
- port_receive(pr_th, &prm_th, BLOCK); |
- |
- angle += 0.2; |
- |
- draw(prm_x,prm_th); |
- |
- jet_gettable(carrello_PID, &carrello_TIME, 1); |
- jet_gettable(disegna_PID, &disegna_TIME, 1); |
- |
- sprintf(text,"Hard Task Control PER:%6d us EX:%6d us",(int)PERIOD_CARRELLO,(int)carrello_TIME); |
- grx_text(text,10,5,rgb16(0,0,255),rgb16(255,255,255)); |
- sprintf(text,"Hard Task Draw PER:%6d us EX:%6d us",(int)PERIOD_DISEGNA,(int)disegna_TIME); |
- grx_text(text,10,15,rgb16(0,0,255),rgb16(255,255,255)); |
- |
- copy_videomem_16to16(buffers,vbuf,count); |
- |
- task_endcycle(); |
- |
- } |
- |
- port_disconnect(pr_x); |
- port_disconnect(pr_th); |
- |
- sys_end(); |
- |
-} |
- |
-static void screen(int mode) |
-{ |
- vga_modeinfo *minf; |
- int mem; |
- |
- vga_setmode(mode,CARD); |
- minf = vga_getmodeinfo(mode); |
- if(! (minf->flags & CAPABLE_LINEAR)){ |
- vga_setmode(TEXT,CARD); |
- printk(KERN_INFO "The mode %d is not capable of linear\n",mode); |
- return; |
- } |
- vga_setpage(0); |
- if(vga_setlinearaddressing() == -1) { |
- vga_setmode(TEXT,CARD); |
- printk(KERN_INFO "Could not set linear addressing for mode %d\n",mode); |
- return; |
- } |
- |
- mem = minf->linewidth*minf->height; |
- |
- vbuf = vga_getgraphmem(); |
- printk(KERN_INFO "Memory mapped to %08x. Mode = %d.\n",(int) vbuf,mode); |
- memset(vbuf,0,mem); |
- |
-} |
- |
-void waitenter() { |
- |
- KEY_EVT k; |
- char esc = FALSE; |
- |
- while(!esc) { |
- keyb_getcode(&k,BLOCK); |
- if (k.ascii == 13) esc = TRUE; |
- } |
- |
-} |
- |
- |
-void init_motor(void) |
-{ |
- |
- da_motor(0.0); |
- |
- cprintf("Calibrazione pendolo inverso...\n"); |
- |
- cprintf("Carr a sx e premi enter\n"); |
- waitenter(); |
- vmin=ad_conv(11); |
- |
- cprintf("Carr a dx e premi enter\n"); |
- waitenter(); |
- vmax=ad_conv(11); |
- |
- cprintf("Asta a sx e premi enter\n"); |
- waitenter(); |
- vminth=ad_conv(10); |
- |
- cprintf("Asta a dx e premi enter\n"); |
- waitenter(); |
- vmaxth=ad_conv(10); |
- |
- cprintf("Vxmax:%f Vxmin:%f Vthmax:%f Vthmin:%f\n",vmax,vmin,vmaxth,vminth); |
- waitenter(); |
- |
-} |
- |
-int main (int argc, char *argv[]) |
-{ |
- HARD_TASK_MODEL ht_carrello, ht_disegna; |
- |
- WCET_CARRELLO =((long int) PERIOD_CARRELLO * (0.05)); |
- WCET_DISEGNA =((long int) PERIOD_DISEGNA * (0.875)); |
- |
- clear(); |
- |
- sys_atrunlevel((void *) program_end,NULL, RUNLEVEL_BEFORE_EXIT); |
- |
- hard_task_default_model(ht_carrello); |
- hard_task_def_wcet(ht_carrello,WCET_CARRELLO); |
- hard_task_def_mit(ht_carrello,PERIOD_CARRELLO); |
- hard_task_def_usemath(ht_carrello); |
- hard_task_def_group(ht_carrello,1); |
- hard_task_def_ctrl_jet(ht_carrello); |
- |
- carrello_PID = task_create("carrello", carrello, &ht_carrello, NULL); |
- if (carrello_PID == -1) { |
- sys_end(); |
- exit(4); |
- } |
- |
- hard_task_default_model(ht_disegna); |
- hard_task_def_mit(ht_disegna,PERIOD_DISEGNA); |
- hard_task_def_wcet(ht_disegna,WCET_DISEGNA); |
- hard_task_def_group(ht_disegna,1); |
- hard_task_def_ctrl_jet(ht_disegna); |
- hard_task_def_usemath(ht_disegna); |
- hard_task_def_stack(ht_disegna,60000); |
- |
- disegna_PID = task_create("disegna", disegna, &ht_disegna, NULL); |
- if (disegna_PID == -1) { |
- sys_end(); |
- exit(4); |
- } |
- |
- { |
- KEY_EVT k; |
- k.flag = ALTL_BIT; |
- k.scan = KEY_C; |
- k.ascii = 'c'; |
- keyb_hook(k,program_key_end); |
- } |
- |
- init_motor(); |
- |
- screen(INITSTR); |
- |
- ctx = OSMesaCreateContext(OSMESA_RGB_565, NULL ); |
- buffers = malloc(WIDTH * HEIGHT * 2); |
- |
- grx_setbuffer(buffers, WIDTH, HEIGHT); |
- OSMesaMakeCurrent(ctx, buffers, GL_UNSIGNED_SHORT_5_6_5, WIDTH, HEIGHT); |
- |
- init_gl(); |
- |
- group_activate(1); |
- |
- return 0; |
- |
-} |
Index: tags/rel_1_22/kalm3d/makefile |
=================================================================== |
--- tags/rel_1_22/kalm3d/makefile (revision 1310) |
+++ tags/rel_1_22/kalm3d/makefile (nonexistent) |
@@ -1,16 +0,0 @@ |
-# |
-# |
-# |
- |
-ifndef BASE |
-BASE=../.. |
-endif |
-include $(BASE)/config/config.mk |
- |
-PROGS = kalm3d |
- |
-include $(BASE)/config/example.mk |
- |
-kalm3d: |
- make -f $(SUBMAKE) APP=kalm3d INIT= OTHEROBJS="initfile.o carrello.o" SHARKOPT="__OSMESA__ __PCLAB__ __OLDCHAR__ __SVGA__" |
- |
Index: tags/rel_1_22/readme.txt |
=================================================================== |
--- tags/rel_1_22/readme.txt (revision 1310) |
+++ tags/rel_1_22/readme.txt (nonexistent) |
@@ -1,7 +0,0 @@ |
-Hi, these are the S.Ha.R.K. demos... |
- |
-the old examples directory is now called demos/oldexamples... |
- |
-Enjoy |
- |
-PJ |
Index: tags/rel_1_22/advtimer/initfile.c |
=================================================================== |
--- tags/rel_1_22/advtimer/initfile.c (revision 1310) |
+++ tags/rel_1_22/advtimer/initfile.c (nonexistent) |
@@ -1,120 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- ------------ |
- CVS : $Id: initfile.c,v 1.1 2003-04-23 09:15:48 giacomo Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1 $ |
- Last update: $Date: 2003-04-23 09:15:48 $ |
- ------------ |
- |
- System initialization file |
- |
- This file contains the 2 functions needed to initialize the system. |
- |
- These functions register the following levels: |
- |
- an EDF (Earliest Deadline First) level |
- a RR (Round Robin) level |
- a CBS (Costant Bandwidth Server) level |
- a Dummy level |
- |
- It can accept these task models: |
- |
- HARD_TASK_MODEL (wcet+mit) at level 0 |
- SOFT_TASK_MODEL (met, period) at level 1 |
- NRT_TASK_MODEL at level 2 |
- |
- This file is similar to the configuration of kernel/init/hartik3.c |
- |
- TICK is set to 0 (one-shot timer is used) |
-*/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/cbs.h" |
-#include "modules/rr.h" |
-#include "modules/dummy.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
- |
-#include "drivers/keyb.h" |
- |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 1000 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 10000 |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- EDF_register_level(EDF_ENABLE_ALL); |
- CBS_register_level(CBS_ENABLE_ALL, 0); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- |
- CABS_register_module(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- KEYB_PARMS kparms = BASE_KEYB; |
- |
- HARTPORT_init(); |
- |
- keyb_def_ctrlC(kparms, NULL); |
- keyb_def_map(kparms,itaMap); |
- KEYB_init(&kparms); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
Index: tags/rel_1_22/advtimer/readme.txt |
=================================================================== |
--- tags/rel_1_22/advtimer/readme.txt (revision 1310) |
+++ tags/rel_1_22/advtimer/readme.txt (nonexistent) |
@@ -1,39 +0,0 @@ |
--------------------------------------- |
-Advanced Timer Demo |
- |
-by |
- |
-Giacomo Guidi <giacomo@gandalf.sssup.it> |
- |
-Last update 23/04/2003 |
--------------------------------------- |
- |
-This demo shows the new timer management |
-code of S.Ha.R.K. |
- |
--------------------------------------- |
- |
-The demo is composed by: |
- |
-MAKEFILE The makefile used to compile the application |
-README.TXT This file |
-INITFILE.C The init file |
-ADVTIMER.C The Advanced Timer Demo |
- |
--------------------------------------- |
- |
-To change the timer mode, you have to |
-modify two global variable in: |
- |
-oslib/kl/advtimer.c |
- |
-use_tsc (BOOL) |
-use_cmos (BOOL) |
- |
-and to recompile. |
- |
-The default setting is |
- |
-use_tsc = 1; |
-use_cmos = 0; |
- |
Index: tags/rel_1_22/advtimer/advtimer.c |
=================================================================== |
--- tags/rel_1_22/advtimer/advtimer.c (revision 1310) |
+++ tags/rel_1_22/advtimer/advtimer.c (nonexistent) |
@@ -1,165 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Giacomo Guidi <giacomo@gandalf.sssup.it> |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- */ |
- |
-/* |
- * Advanced Timer Demo |
- * |
- */ |
- |
-#include "kernel/kern.h" |
-#include "ll/i386/cons.h" |
-#include "ll/i386/advtimer.h" |
- |
-#include "drivers/keyb.h" |
- |
-#define UPDATE_PERIOD 10000 |
-#define UPDATE_WCET 1000 |
- |
-extern unsigned int clk_per_msec; |
-extern unsigned int apic_clk_per_msec; |
- |
-void program_key_end(KEY_EVT *k) |
-{ |
- |
- sys_end(); |
- |
-} |
- |
-TASK Update(void *arg) |
-{ |
- struct timespec actual_timer; |
- |
- long nsec,sec,min,hrs,day; |
- long mean_delay,tot_delay,num_delay; |
- |
- signed long long start,end,res; |
- struct timespec s_test,startts,endts; |
- |
- task_nopreempt(); |
- |
- num_delay = tot_delay = mean_delay = 0; |
- |
- while (1) { |
- |
- if (clk_per_msec != 0) { |
- |
- rdtscll(start); |
- sys_gettime(&actual_timer); |
- rdtscll(end); |
- res = end - start; |
- rdtscll(start); |
- rdtscll(end); |
- res -= (end - start); |
- s_test.tv_nsec = res * 1000000 / clk_per_msec; |
- |
- |
- } else { |
- |
- sys_gettime(&startts); |
- sys_gettime(&actual_timer); |
- sys_gettime(&endts); |
- SUBTIMESPEC(&endts,&startts,&s_test); |
- sys_gettime(&startts); |
- sys_gettime(&endts); |
- SUBTIMESPEC(&endts,&startts,&endts); |
- SUBTIMESPEC(&s_test,&endts,&s_test); |
- |
- } |
- |
- if (tot_delay < 1000000000) { |
- tot_delay += s_test.tv_nsec; |
- num_delay ++; |
- mean_delay = tot_delay / num_delay; |
- } |
- |
- nsec = actual_timer.tv_nsec; |
- sec = actual_timer.tv_sec; |
- min = sec / 60; |
- sec %= 60; |
- hrs = min / 60; |
- min %= 60; |
- day = hrs / 24; |
- hrs %= 24; |
- |
- printf_xy(0,5,WHITE,"Actual CPU Clk/msec: %12d",clk_per_msec); |
- printf_xy(0,6,WHITE,"Actual APIC Clk/msec: %12d",apic_clk_per_msec); |
- printf_xy(0,7,WHITE,"Actual Timer: %2ld d %2ld h %2ld m %2ld s %12ld ns",day,hrs,min,sec,(long)nsec); |
- |
- printf_xy(0,9,WHITE,"Timer Access Delay: %12ld ns",mean_delay); |
- |
- task_endcycle(); |
- |
- } |
- |
- sys_end(); |
- |
-} |
- |
-void set_screen() |
-{ |
- |
- printf_xy(20,0,WHITE," Advanced Timer Demo "); |
- printf_xy(20,1,WHITE,"Giacomo Guidi <giacomo@gandalf.sssup.it>"); |
- printf_xy(20,2,WHITE," Press Alt + c to exit "); |
- |
-} |
- |
- |
-int main(int argc, char **argv) |
-{ |
- |
- HARD_TASK_MODEL mp; //Show current setting |
- PID update; |
- KEY_EVT k; |
- |
- k.flag = ALTL_BIT; |
- k.scan = KEY_C; |
- k.ascii = 'c'; |
- keyb_hook(k,program_key_end); |
- |
- set_screen(); |
- |
- hard_task_default_model(mp); |
- hard_task_def_ctrl_jet(mp); |
- hard_task_def_group(mp, 1); |
- hard_task_def_wcet(mp,UPDATE_WCET); |
- hard_task_def_mit(mp,UPDATE_PERIOD); |
- hard_task_def_usemath(mp); |
- update = task_create("Update", Update, &mp, NULL); |
- if (update != NIL) task_activate(update); |
- |
- return 0; |
- |
-} |
Index: tags/rel_1_22/advtimer/makefile |
=================================================================== |
--- tags/rel_1_22/advtimer/makefile (revision 1310) |
+++ tags/rel_1_22/advtimer/makefile (nonexistent) |
@@ -1,18 +0,0 @@ |
-# |
-# |
-# |
- |
-ifndef BASE |
-BASE=../.. |
-endif |
-include $(BASE)/config/config.mk |
- |
-PROGS = advtimer |
- |
-include $(BASE)/config/example.mk |
- |
-# Text applications |
-advtimer: |
- make -f $(SUBMAKE) APP=advtimer INIT= OTHEROBJS="initfile.o" SHARKOPT="__OLDCHAR__" |
- |
- |
Index: tags/rel_1_22/base_cpp/readme |
=================================================================== |
--- tags/rel_1_22/base_cpp/readme (revision 1310) |
+++ tags/rel_1_22/base_cpp/readme (nonexistent) |
@@ -1,8 +0,0 @@ |
-This directory contains a few C++ demos: |
- |
-- hello.cpp - this is a simple hello world written in C++, similar to that in demos/base |
- |
- |
-Initialization files: |
- |
-- ihello.c - same as in demos/base |
Index: tags/rel_1_22/base_cpp/ihello.c |
=================================================================== |
--- tags/rel_1_22/base_cpp/ihello.c (revision 1310) |
+++ tags/rel_1_22/base_cpp/ihello.c (nonexistent) |
@@ -1,95 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: ihello.c,v 1.1 2003-03-17 09:29:39 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1 $ |
- Last update: $Date: 2003-03-17 09:29:39 $ |
- ------------ |
- |
- The simplest initialization file |
- |
- The tick is set to TICK ms. |
- |
- This file contains the 2 functions needed to initialize the system. |
- |
- These functions register the following levels: |
- |
- a RR (Round Robin) level |
- a Dummy level |
- |
- It can accept these task models: |
- |
- NRT_TASK_MODEL at level 0 |
- |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
- |
- |
-#include "kernel/kern.h" |
-#include "modules/rr.h" |
-#include "modules/dummy.h" |
- |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 300 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 10000 |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
Index: tags/rel_1_22/base_cpp/makefile |
=================================================================== |
--- tags/rel_1_22/base_cpp/makefile (revision 1310) |
+++ tags/rel_1_22/base_cpp/makefile (nonexistent) |
@@ -1,13 +0,0 @@ |
-ifndef BASE |
-BASE=../.. |
-endif |
-include $(BASE)/config/config.mk |
- |
-PROGS = hello |
- |
-include $(BASE)/config/example.mk |
- |
- |
-# Text applications |
-hello: |
- make -f $(SUBMAKE) APP=hello INIT= OTHEROBJS="ihello.o" OTHERINCL= |
Index: tags/rel_1_22/base_cpp/hello.cpp |
=================================================================== |
--- tags/rel_1_22/base_cpp/hello.cpp (revision 1310) |
+++ tags/rel_1_22/base_cpp/hello.cpp (nonexistent) |
@@ -1,72 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2003 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- */ |
- |
-/* |
- CVS : $Id: hello.cpp,v 1.1 2003-03-17 09:29:39 pj Exp $ |
- |
- hello.c: |
- |
- This test is a simple hello world function. |
- |
-*/ |
- |
-#include "kernel/kern.h" |
- |
-class myHello { |
- int i; |
-public: |
- |
- myHello(int anumber) |
- { |
- i = anumber; |
- } |
- |
- void myprint(void) |
- { |
- cprintf("myHello objecy prints %d.", i); |
- } |
-}; |
- |
-int main(int argc, char **argv) |
-{ |
- cprintf("Hello, world!\n"); |
- |
- myHello h(1234); |
- |
- h.myprint(); |
- |
- return 0; |
-} |
Index: tags/rel_1_22/makefile |
=================================================================== |
--- tags/rel_1_22/makefile (revision 1310) |
+++ tags/rel_1_22/makefile (nonexistent) |
@@ -1,31 +0,0 @@ |
-include ../shark.cfg |
- |
-ifeq ($(findstring NEW,$(TRACER)) , NEW) |
-TRC = newtrace |
-endif |
-ifeq ($(findstring OLD,$(TRACER)) , OLD) |
-TRC = tracer |
-endif |
- |
-dirs := $(filter-out CVS cvs base_cpp makefile readme.txt tracer newtrace README.TXT, $(wildcard *)) |
-dirs += $(TRC) |
-p_all := $(addprefix prefixall_, $(dirs)) |
-p_install := $(addprefix prefixinstall_, $(dirs)) |
-p_clean := $(addprefix prefixclean_, $(dirs)) |
-pcleanall := $(addprefix prefixcleanall_, $(dirs)) |
-pdepend := $(addprefix prefixdepend_, $(dirs)) |
- |
- |
-.PHONY: all clean |
- |
- |
- |
-all: $(p_all) |
- |
-clean: $(p_clean) |
- |
-prefixall_%: |
- make -C $* |
- |
-prefixclean_%: |
- make -C $* clean |
Index: tags/rel_1_22/fsf/initfile.c |
=================================================================== |
--- tags/rel_1_22/fsf/initfile.c (revision 1310) |
+++ tags/rel_1_22/fsf/initfile.c (nonexistent) |
@@ -1,116 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Giacomo Guidi <giacomo@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/cbs.h" |
-#include "modules/posix.h" |
-#include "pthread.h" |
-#include "drivers/keyb.h" |
-#include "modules/sem.h" |
-#include "modules/dummy.h" |
-#include "modules/hartport.h" |
- |
-#include "fsf_contract.h" |
-#include "fsf_server.h" |
- |
-#include "modules/pi.h" |
-#include "modules/pc.h" |
- |
-#define TICK 0 |
- |
-#define RRTICK 10000 |
- |
-void load_file(); |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- int grubstar_level; |
- |
- EDF_register_level(EDF_ENABLE_ALL); |
- POSIX_register_level(RRTICK, 1, mb, 32); |
- grubstar_level = GRUBSTAR_register_level(FSF_MAX_N_SERVERS, 0); |
- FSF_register_module(grubstar_level); |
- dummy_register_level(); |
- |
- CBS_register_level(CBS_ENABLE_ALL,0); |
- |
- SEM_register_module(); |
- |
- PI_register_module(); |
- PC_register_module(); |
- |
- PTHREAD_register_module(1, 0, 1); |
- |
- load_file(); |
- |
- return TICK; |
- |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- HARTPORT_init(); |
- |
- KEYB_init(NULL); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
-int dos_video_preload(void *filename, long max_size, void **start, void **end); |
- |
-void *start_file; |
-void *end_file; |
- |
-void load_file() |
-{ |
- start_file = NULL; |
- end_file = NULL; |
- |
- dos_video_preload("test.m2v",5000000,&start_file,&end_file); |
- |
- cprintf("Start file ptr = %08lx\n",(long)(start_file)); |
- cprintf("End file ptr = %08lx\n",(long)(end_file)); |
- cprintf("Size = %8ld\n",(long)(end_file - start_file)); |
- |
-} |
- |
Index: tags/rel_1_22/fsf/demos.txt |
=================================================================== |
--- tags/rel_1_22/fsf/demos.txt (revision 1310) |
+++ tags/rel_1_22/fsf/demos.txt (nonexistent) |
@@ -1,48 +0,0 @@ |
-FSF demo for S.Ha.R.K |
- |
-test1.c: |
- |
-This demo shows the main feature of service contract implementation. |
- |
-A set of 4 threads is created using the pthread standard functions. |
-At the beginning, these threads run without temporal restrictions |
-and they don't respect any deadline. |
- |
-Two service contracts are initialized and set |
- |
-fsf_initialize_contract(&contract1); |
-fsf_initialize_contract(&contract2); |
-fsf_set_contract_basic_parameters(&contract1,&budget1,&period1,NULL,NULL,FSF_DEFAULT_WORKLOAD); |
-fsf_set_contract_basic_parameters(&contract2,&budget2,&period2,NULL,NULL,FSF_DEFAULT_WORKLOAD); |
- |
-whit the button 'q','w','e' you can respectively |
-negotiate contract for a server |
- |
-[err = fsf_negotiate_contract(&contractX,&serverY);] |
- |
-'q' -> negotiate contract1 for server1 |
-'w' -> negotiate contract2 for server2 |
-'e' -> negotiate contract1 for server3 |
- |
-now with button '1','2','3','4' you can bind the thread to a server |
- |
-[err = fsf_bind_thread_to_server(serverY,jZ);] |
- |
-'1' -> bind thread1 to server1 |
-'2' -> bind thread2 to server2 |
-'3' -> bind thread3 to server3 |
-'4' -> bind thread4 to server2 |
- |
-threads will start to respect the assigned budget. It's possible |
-to bind more threads to one server. The local scheduler specified in the |
-contract define how the threads will get the server resources. |
- |
-With '5','6','7','8' the thread is unbind from the server |
- |
-[err = fsf_unbind_thread_from_server(jZ);] |
- |
-With 'r','t','y' a server is removed |
- |
-[err = fsf_cancel_contract(&server2);] |
- |
- |
Index: tags/rel_1_22/fsf/mpeg2/verify.c |
=================================================================== |
--- tags/rel_1_22/fsf/mpeg2/verify.c (revision 1310) |
+++ tags/rel_1_22/fsf/mpeg2/verify.c (nonexistent) |
@@ -1,300 +0,0 @@ |
-/* verify.c |
- * |
- * Bitstream verification routines |
- * |
- * |
- */ |
-#ifdef VERIFY |
- |
-#include <stdlib.h> |
-#include <math.h> /* needed for ceil() */ |
- |
-#include "config.h" |
-#include "global.h" |
- |
-/* #define DEBUG */ |
-#ifdef DEBUG |
-#define PC |
-#endif |
- |
-#ifdef PC |
-#include <conio.h> /* needed for getch() */ |
-#endif /* PC */ |
- |
-/* |
- Check picture headers: due to the VBV definition of picture data, |
- this routine must be called immediately before any picture data |
- is parsed. (before the first slice start code, including any slice |
- start code stuffing). |
-*/ |
- |
- |
-static void Check_VBV_Delay _ANSI_ARGS_((int Bitstream_Framenum, int Sequence_Framenum)); |
- |
- |
-void Check_Headers(Bitstream_Framenum, Sequence_Framenum) |
-int Bitstream_Framenum; |
-int Sequence_Framenum; |
-{ |
- |
- |
- if((!low_delay)&&(vbv_delay!=0)&&(vbv_delay!=0xFFFF)) |
- Check_VBV_Delay(Bitstream_Framenum, Sequence_Framenum); |
- |
- /* clear out the header tracking variables so we have an accurate |
- count next time */ |
- Clear_Verify_Headers(); |
-} |
- |
- |
- |
-/* |
- * Verify vbv_delay value in picture header |
- * (low_delay==1 checks not implemented. this does not exhaustively test all |
- * possibilities suggested in ISO/IEC 13818-2 Annex C. It only checks |
- * for constant rate streams) |
- * |
- * Q:how do we tell a variable rate stream from a constant rate stream anyway? |
- * it's not as simple as vbv_delay==0xFFFF, since we need meaningful |
- * vbv_delay values to calculate the piecewise rate in the first place! |
- * |
- * Also: no special provisions at the beginning or end of a sequence |
- */ |
- |
-static void Check_VBV_Delay(Bitstream_Framenum, Sequence_Framenum) |
-int Bitstream_Framenum; |
-int Sequence_Framenum; |
-{ |
- double B; /* buffer size */ |
- double Bn; /* buffer fullness for picture n */ |
- double R; /* bitrate */ |
- double I; /* time interval (t[n+1] - t[n]) */ |
- double T; /* inverse of the frame rate (frame period) */ |
- |
- int d; |
- int internal_vbv_delay; |
- |
- static int previous_IorP_picture_structure; |
- static int previous_IorP_repeat_first_field; |
- static int previous_IorP_top_field_first; |
- static int previous_vbv_delay; |
- static int previous_bitstream_position; |
- |
- static double previous_Bn; |
- static double E; /* maximum quantization error or mismatch */ |
- |
- |
- |
- if((Sequence_Framenum==0)&&(!Second_Field)) |
- { /* first coded picture of sequence */ |
- |
- R = bit_rate; |
- |
- /* the initial buffer occupancy is taken on faith |
- that is, we believe what is transmitted in the first coded picture header |
- to be the true/actual buffer occupancy */ |
- |
- Bn = (R * (double) vbv_delay) / 90000.0; |
- B = 16 * 1024 * vbv_buffer_size; |
- |
- |
- /* maximum quantization error in bitrate (bit_rate_value is quantized/ |
- rounded-up to units of 400 bits/sec as per ISO/IEC 13818-2 |
- section 6.3.3 */ |
- |
- E = (400.0/frame_rate) + 400; |
- |
-#ifdef DEBUG |
- cprintf("vbv_buffer_size (B) = %.0f, Bn=%f, E=%f, \nbitrate=%f, vbv_delay=%d frame_rate=%f\n", |
- B, Bn, E, bit_rate, vbv_delay, frame_rate); |
-#endif |
- |
- } |
- else /* not the first coded picture of sequence */ |
- { |
- |
- /* derive the interval (I). The interval tells us how many constant rate bits |
- * will have been downloaded to the buffer during the current picture period |
- * |
- * interval assumes that: |
- * 1. whilst we are decoding the current I or P picture, we are displaying |
- * the previous I or P picture which was stored in the reorder |
- * buffer (pointed to by forward_reference_frame in this implementation) |
- * |
- * 2. B pictures are output ("displayed") at the time when they are decoded |
- * |
- */ |
- |
- if(progressive_sequence) /* Annex C.9 (progressive_sequence==1, low_delay==0) */ |
- { |
- |
- T = 1/frame_rate; /* inverse of the frame rate (frame period) */ |
- |
- if(picture_coding_type==B_TYPE) |
- { |
- if(repeat_first_field==1) |
- { |
- if(top_field_first==1) |
- I = T*3; /* three frame periods */ |
- else |
- I = T*2; /* two frame periods */ |
- } |
- else |
- I = T; /* one frame period */ |
- } |
- else /* P or I frame */ |
- { |
- if(previous_IorP_repeat_first_field==1) |
- { |
- if(previous_IorP_top_field_first==1) |
- I = 3*T; |
- else |
- I = 2*T; |
- } |
- else |
- I = T; |
- } |
- } |
- else /* Annex C.11 (progressive_sequence==0, low_delay==0) */ |
- { |
- |
- T = 1/(2*frame_rate); /* inverse of two times the frame rate (field period) */ |
- |
- if(picture_coding_type==B_TYPE) |
- { |
- if(picture_structure==FRAME_PICTURE) |
- { |
- if(repeat_first_field==0) |
- I = 2*T; /* two field periods */ |
- else |
- I = 3*T; /* three field periods */ |
- } |
- else /* B field */ |
- { |
- I = T; /* one field period */ |
- } |
- } |
- else /* I or P picture */ |
- { |
- if(picture_structure==FRAME_PICTURE) |
- { |
- if(previous_IorP_repeat_first_field==0) |
- I = 2*T; |
- else |
- I = 3*T; |
- } |
- else |
- { |
- if(Second_Field==0) /* first field of current frame */ |
- I = T; |
- else /* second field of current frame */ |
- { |
- /* formula: previous I or P display period (2*T or 3*T) minus the |
- very recent decode period (T) of the first field of the current |
- frame */ |
- |
- if(previous_IorP_picture_structure!=FRAME_PICTURE |
- || previous_IorP_repeat_first_field==0) |
- I = 2*T - T; /* a net of one field period */ |
- else if(previous_IorP_picture_structure==FRAME_PICTURE |
- && previous_IorP_repeat_first_field==1) |
- I = 3*T - T; /* a net of two field periods */ |
- } |
- } |
- } |
- } |
- |
- /* derive coded size of previous picture */ |
- d = ld->Bitcnt - previous_bitstream_position; |
- |
- /* Rate = Distance/Time */ |
- |
- /* piecewise constant rate (variable rate stream) calculation |
- * R = ((double) d /((previous_vbv_delay - vbv_delay)/90000 + I)); |
- */ |
- |
- R = bit_rate; |
- |
- /* compute buffer fullness just before removing picture n |
- * |
- * Bn = previous_Bn + (I*R) - d; (recursive formula) |
- * |
- * where: |
- * |
- * n is the current picture |
- * |
- * Bn is the buffer fullness for the current picture |
- * |
- * previous_Bn is the buffer fullness of the previous picture |
- * |
- * (I*R ) is the bits accumulated during the current picture |
- * period |
- * |
- * d is the number of bits removed during the decoding of the |
- * previous picture |
- */ |
- |
- Bn = previous_Bn + (I*R) - d; |
- |
- /* compute internally derived vbv_delay (rouding up with ceil()) */ |
- internal_vbv_delay = (int) ceil((90000 * Bn / bit_rate)); |
- |
-#ifdef DEBUG |
- cprintf("\nvbv_delay: internal=%d, bitstream=%d\n", internal_vbv_delay, vbv_delay); |
- |
- cprintf("Bn=%f, prevBn=%f, I=%f, R=%f, d=%d\n", Bn, previous_Bn, I, R, d); |
- cprintf("frame(%d), pictstruct(%d), picttype(%d)\n", Sequence_Framenum, |
- picture_structure, picture_coding_type); |
- |
- /* report error */ |
- if(internal_vbv_delay != vbv_delay) |
- { |
- cprintf("WARNING: internal_vbv_delay(%d) != vbv_delay(%d)\n", |
- internal_vbv_delay, vbv_delay); |
- } |
-#endif |
- |
- } /* not the first coded picture of sequence */ |
- |
- |
-#ifdef PC |
- getch(); |
-#endif /* PC */ |
- |
- /* update generic tracking variables */ |
- previous_bitstream_position = ld->Bitcnt ; |
- previous_vbv_delay = vbv_delay; |
- previous_Bn = Bn; |
- |
- /* reference picture: reordered/delayed output picture */ |
- if(picture_coding_type!=B_TYPE) |
- { |
- previous_IorP_repeat_first_field = repeat_first_field; |
- previous_IorP_top_field_first = top_field_first; |
- previous_IorP_picture_structure = picture_structure; |
- } |
- |
-} |
- |
- |
- |
-/* variables to keep track of the occurance of redundant headers between pictures */ |
-void Clear_Verify_Headers() |
-{ |
- verify_sequence_header = 0; |
- verify_group_of_pictures_header = 0; |
- verify_picture_header = 0; |
- verify_slice_header = 0; |
- verify_sequence_extension = 0; |
- verify_sequence_display_extension = 0; |
- verify_quant_matrix_extension = 0; |
- verify_sequence_scalable_extension = 0; |
- verify_picture_display_extension = 0; |
- verify_picture_coding_extension = 0; |
- verify_picture_spatial_scalable_extension = 0; |
- verify_picture_temporal_scalable_extension = 0; |
- verify_copyright_extension = 0; |
-} |
- |
-#endif /* VERIFY */ |
- |
Index: tags/rel_1_22/fsf/mpeg2/global.h |
=================================================================== |
--- tags/rel_1_22/fsf/mpeg2/global.h (revision 1310) |
+++ tags/rel_1_22/fsf/mpeg2/global.h (nonexistent) |
@@ -1,497 +0,0 @@ |
-/* global.h, global variables */ |
- |
-/* Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved. */ |
- |
-/* |
- * Disclaimer of Warranty |
- * |
- * These software programs are available to the user without any license fee or |
- * royalty on an "as is" basis. The MPEG Software Simulation Group disclaims |
- * any and all warranties, whether express, implied, or statuary, including any |
- * implied warranties or merchantability or of fitness for a particular |
- * purpose. In no event shall the copyright-holder be liable for any |
- * incidental, punitive, or consequential damages of any kind whatsoever |
- * arising from the use of these programs. |
- * |
- * This disclaimer of warranty extends to the user of these programs and user's |
- * customers, employees, agents, transferees, successors, and assigns. |
- * |
- * The MPEG Software Simulation Group does not represent or warrant that the |
- * programs furnished hereunder are free of infringement of any third-party |
- * patents. |
- * |
- * Commercial implementations of MPEG-1 and MPEG-2 video, including shareware, |
- * are subject to royalty fees to patent holders. Many of these patents are |
- * general enough such that they are unavoidable regardless of implementation |
- * design. |
- * |
- */ |
- |
-#include "ll/sys/types.h" |
-#include "kernel/kern.h" |
-#include "mpeg2dec.h" |
- |
-/* choose between declaration (GLOBAL undefined) |
- * and definition (GLOBAL defined) |
- * GLOBAL is defined in exactly one file mpeg2dec.c) |
- */ |
- |
-#ifndef GLOBAL |
-#define EXTERN extern |
-#else |
-#define EXTERN |
-#endif |
- |
-/* prototypes of global functions */ |
-/* readpic.c */ |
-void Substitute_Frame_Buffer _ANSI_ARGS_ ((int bitstream_framenum, |
- int sequence_framenum)); |
- |
-/* Get_Bits.c */ |
-void Initialize_Buffer _ANSI_ARGS_((void)); |
-void Fill_Buffer _ANSI_ARGS_((void)); |
-unsigned int Show_Bits _ANSI_ARGS_((int n)); |
-unsigned int Get_Bits1 _ANSI_ARGS_((void)); |
-void Flush_Buffer _ANSI_ARGS_((int n)); |
-unsigned int Get_Bits _ANSI_ARGS_((int n)); |
-int Get_Byte _ANSI_ARGS_((void)); |
-int Get_Word _ANSI_ARGS_((void)); |
- |
-/* systems.c */ |
-void Next_Packet _ANSI_ARGS_((void)); |
-int Get_Long _ANSI_ARGS_((void)); |
-void Flush_Buffer32 _ANSI_ARGS_((void)); |
-unsigned int Get_Bits32 _ANSI_ARGS_((void)); |
- |
- |
-/* getblk.c */ |
-void Decode_MPEG1_Intra_Block _ANSI_ARGS_((int comp, int dc_dct_pred[])); |
-void Decode_MPEG1_Non_Intra_Block _ANSI_ARGS_((int comp)); |
-void Decode_MPEG2_Intra_Block _ANSI_ARGS_((int comp, int dc_dct_pred[])); |
-void Decode_MPEG2_Non_Intra_Block _ANSI_ARGS_((int comp)); |
- |
-/* gethdr.c */ |
-int Get_Hdr _ANSI_ARGS_((void)); |
-void next_start_code _ANSI_ARGS_((void)); |
-int slice_header _ANSI_ARGS_((void)); |
-void marker_bit _ANSI_ARGS_((char *text)); |
- |
-/* getpic.c */ |
-void Decode_Picture _ANSI_ARGS_((int bitstream_framenum, |
- int sequence_framenum)); |
-void Output_Last_Frame_of_Sequence _ANSI_ARGS_((int framenum)); |
- |
-/* getvlc.c */ |
-int Get_macroblock_type _ANSI_ARGS_((void)); |
-int Get_motion_code _ANSI_ARGS_((void)); |
-int Get_dmvector _ANSI_ARGS_((void)); |
-int Get_coded_block_pattern _ANSI_ARGS_((void)); |
-int Get_macroblock_address_increment _ANSI_ARGS_((void)); |
-int Get_Luma_DC_dct_diff _ANSI_ARGS_((void)); |
-int Get_Chroma_DC_dct_diff _ANSI_ARGS_((void)); |
- |
-/* idct.c */ |
-void Fast_IDCT _ANSI_ARGS_((short *block)); |
-void Initialize_Fast_IDCT _ANSI_ARGS_((void)); |
- |
-/* Reference_IDCT.c */ |
-void Initialize_Reference_IDCT _ANSI_ARGS_((void)); |
-void Reference_IDCT _ANSI_ARGS_((short *block)); |
- |
-/* motion.c */ |
-void motion_vectors _ANSI_ARGS_((int PMV[2][2][2], int dmvector[2], |
- int motion_vertical_field_select[2][2], int s, int motion_vector_count, |
- int mv_format, int h_r_size, int v_r_size, int dmv, int mvscale)); |
-void motion_vector _ANSI_ARGS_((int *PMV, int *dmvector, |
- int h_r_size, int v_r_size, int dmv, int mvscale, int full_pel_vector)); |
-void Dual_Prime_Arithmetic _ANSI_ARGS_((int DMV[][2], int *dmvector, int mvx, int mvy)); |
- |
-/* mpeg2dec.c */ |
-void Error _ANSI_ARGS_((char *text)); |
-void Warning _ANSI_ARGS_((char *text)); |
-void Print_Bits _ANSI_ARGS_((int code, int bits, int len)); |
- |
-/* recon.c */ |
-void form_predictions _ANSI_ARGS_((int bx, int by, int macroblock_type, |
- int motion_type, int PMV[2][2][2], int motion_vertical_field_select[2][2], |
- int dmvector[2], int stwtype)); |
- |
-/* spatscal.c */ |
-void Spatial_Prediction _ANSI_ARGS_((void)); |
- |
-/* store.c */ |
-void Write_Frame _ANSI_ARGS_((unsigned char *src[], int frame)); |
- |
-#ifdef DISPLAY |
-/* display.c */ |
-void Initialize_Display_Process _ANSI_ARGS_((char *name)); |
-void Terminate_Display_Process _ANSI_ARGS_((void)); |
-void Display_Second_Field _ANSI_ARGS_((void)); |
-void dither _ANSI_ARGS_((unsigned char *src[])); |
-void Initialize_Dither_Matrix _ANSI_ARGS_((void)); |
-#endif |
- |
-/* global variables */ |
- |
-EXTERN char Version[] |
-#ifdef GLOBAL |
- ="mpeg2decode V1.2a, 96/07/19" |
-#endif |
-; |
- |
-EXTERN char Author[] |
-#ifdef GLOBAL |
- ="(C) 1996, MPEG Software Simulation Group" |
-#endif |
-; |
- |
- |
-/* zig-zag and alternate scan patterns */ |
-EXTERN unsigned char scan[2][64] |
-#ifdef GLOBAL |
-= |
-{ |
- { /* Zig-Zag scan pattern */ |
- 0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5, |
- 12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28, |
- 35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51, |
- 58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63 |
- }, |
- { /* Alternate scan pattern */ |
- 0,8,16,24,1,9,2,10,17,25,32,40,48,56,57,49, |
- 41,33,26,18,3,11,4,12,19,27,34,42,50,58,35,43, |
- 51,59,20,28,5,13,6,14,21,29,36,44,52,60,37,45, |
- 53,61,22,30,7,15,23,31,38,46,54,62,39,47,55,63 |
- } |
-} |
-#endif |
-; |
- |
-/* default intra quantization matrix */ |
-EXTERN unsigned char default_intra_quantizer_matrix[64] |
-#ifdef GLOBAL |
-= |
-{ |
- 8, 16, 19, 22, 26, 27, 29, 34, |
- 16, 16, 22, 24, 27, 29, 34, 37, |
- 19, 22, 26, 27, 29, 34, 34, 38, |
- 22, 22, 26, 27, 29, 34, 37, 40, |
- 22, 26, 27, 29, 32, 35, 40, 48, |
- 26, 27, 29, 32, 35, 40, 48, 58, |
- 26, 27, 29, 34, 38, 46, 56, 69, |
- 27, 29, 35, 38, 46, 56, 69, 83 |
-} |
-#endif |
-; |
- |
-/* non-linear quantization coefficient table */ |
-EXTERN unsigned char Non_Linear_quantizer_scale[32] |
-#ifdef GLOBAL |
-= |
-{ |
- 0, 1, 2, 3, 4, 5, 6, 7, |
- 8,10,12,14,16,18,20,22, |
- 24,28,32,36,40,44,48,52, |
- 56,64,72,80,88,96,104,112 |
-} |
-#endif |
-; |
- |
-/* color space conversion coefficients |
- * for YCbCr -> RGB mapping |
- * |
- * entries are {crv,cbu,cgu,cgv} |
- * |
- * crv=(255/224)*65536*(1-cr)/0.5 |
- * cbu=(255/224)*65536*(1-cb)/0.5 |
- * cgu=(255/224)*65536*(cb/cg)*(1-cb)/0.5 |
- * cgv=(255/224)*65536*(cr/cg)*(1-cr)/0.5 |
- * |
- * where Y=cr*R+cg*G+cb*B (cr+cg+cb=1) |
- */ |
- |
-/* ISO/IEC 13818-2 section 6.3.6 sequence_display_extension() */ |
- |
-EXTERN int Inverse_Table_6_9[8][4] |
-#ifdef GLOBAL |
-= |
-{ |
- {117504, 138453, 13954, 34903}, /* no sequence_display_extension */ |
- {117504, 138453, 13954, 34903}, /* ITU-R Rec. 709 (1990) */ |
- {104597, 132201, 25675, 53279}, /* unspecified */ |
- {104597, 132201, 25675, 53279}, /* reserved */ |
- {104448, 132798, 24759, 53109}, /* FCC */ |
- {104597, 132201, 25675, 53279}, /* ITU-R Rec. 624-4 System B, G */ |
- {104597, 132201, 25675, 53279}, /* SMPTE 170M */ |
- {117579, 136230, 16907, 35559} /* SMPTE 240M (1987) */ |
-} |
-#endif |
-; |
- |
- |
- |
- |
- |
-/* output types (Output_Type) */ |
-#define T_YUV 0 |
-#define T_SIF 1 |
-#define T_TGA 2 |
-#define T_PPM 3 |
-#define T_X11 4 |
-#define T_X11HIQ 5 |
- |
-/* decoder operation control variables */ |
-EXTERN int Output_Type; |
-EXTERN int hiQdither; |
- |
-/* decoder operation control flags */ |
-EXTERN int Quiet_Flag; |
-EXTERN int Trace_Flag; |
-EXTERN int Fault_Flag; |
-EXTERN int Verbose_Flag; |
-EXTERN int Two_Streams; |
-EXTERN int Spatial_Flag; |
-EXTERN int Reference_IDCT_Flag; |
-EXTERN int Frame_Store_Flag; |
-EXTERN int System_Stream_Flag; |
-EXTERN int Display_Progressive_Flag; |
-EXTERN int Ersatz_Flag; |
-EXTERN int Big_Picture_Flag; |
-EXTERN int Verify_Flag; |
-EXTERN int Stats_Flag; |
-EXTERN int User_Data_Flag; |
-EXTERN int Main_Bitstream_Flag; |
- |
- |
-/* filenames */ |
-EXTERN char *Output_Picture_Filename; |
-EXTERN char *Substitute_Picture_Filename; |
-EXTERN char *Main_Bitstream_Filename; |
-EXTERN char *Enhancement_Layer_Bitstream_Filename; |
- |
- |
-/* buffers for multiuse purposes */ |
-EXTERN char Error_Text[256]; |
-EXTERN unsigned char *Clip; |
- |
-/* pointers to generic picture buffers */ |
-EXTERN unsigned char *backward_reference_frame[3]; |
-EXTERN unsigned char *forward_reference_frame[3]; |
- |
-EXTERN unsigned char *auxframe[3]; |
-EXTERN unsigned char *current_frame[3]; |
-EXTERN unsigned char *substitute_frame[3]; |
- |
- |
-/* pointers to scalability picture buffers */ |
-EXTERN unsigned char *llframe0[3]; |
-EXTERN unsigned char *llframe1[3]; |
- |
-EXTERN short *lltmp; |
-EXTERN char *Lower_Layer_Picture_Filename; |
- |
- |
- |
- |
-/* non-normative variables derived from normative elements */ |
-EXTERN int Coded_Picture_Width; |
-EXTERN int Coded_Picture_Height; |
-EXTERN int Chroma_Width; |
-EXTERN int Chroma_Height; |
-EXTERN int block_count; |
-EXTERN int Second_Field; |
-EXTERN int profile, level; |
- |
-/* normative derived variables (as per ISO/IEC 13818-2) */ |
-EXTERN int horizontal_size; |
-EXTERN int vertical_size; |
-EXTERN int mb_width; |
-EXTERN int mb_height; |
-EXTERN double bit_rate; |
-EXTERN double frame_rate; |
- |
- |
- |
-/* headers */ |
- |
-/* ISO/IEC 13818-2 section 6.2.2.1: sequence_header() */ |
-EXTERN int aspect_ratio_information; |
-EXTERN int frame_rate_code; |
-EXTERN int bit_rate_value; |
-EXTERN int vbv_buffer_size; |
-EXTERN int constrained_parameters_flag; |
- |
-/* ISO/IEC 13818-2 section 6.2.2.3: sequence_extension() */ |
-EXTERN int profile_and_level_indication; |
-EXTERN int progressive_sequence; |
-EXTERN int chroma_format; |
-EXTERN int low_delay; |
-EXTERN int frame_rate_extension_n; |
-EXTERN int frame_rate_extension_d; |
- |
-/* ISO/IEC 13818-2 section 6.2.2.4: sequence_display_extension() */ |
-EXTERN int video_format; |
-EXTERN int color_description; |
-EXTERN int color_primaries; |
-EXTERN int transfer_characteristics; |
-EXTERN int matrix_coefficients; |
-EXTERN int display_horizontal_size; |
-EXTERN int display_vertical_size; |
- |
-/* ISO/IEC 13818-2 section 6.2.3: picture_header() */ |
-EXTERN int temporal_reference; |
-EXTERN int picture_coding_type; |
-EXTERN int vbv_delay; |
-EXTERN int full_pel_forward_vector; |
-EXTERN int forward_f_code; |
-EXTERN int full_pel_backward_vector; |
-EXTERN int backward_f_code; |
- |
- |
-/* ISO/IEC 13818-2 section 6.2.3.1: picture_coding_extension() header */ |
-EXTERN int f_code[2][2]; |
-EXTERN int intra_dc_precision; |
-EXTERN int picture_structure; |
-EXTERN int top_field_first; |
-EXTERN int frame_pred_frame_dct; |
-EXTERN int concealment_motion_vectors; |
- |
-EXTERN int intra_vlc_format; |
- |
-EXTERN int repeat_first_field; |
- |
-EXTERN int chroma_420_type; |
-EXTERN int progressive_frame; |
-EXTERN int composite_display_flag; |
-EXTERN int v_axis; |
-EXTERN int field_sequence; |
-EXTERN int sub_carrier; |
-EXTERN int burst_amplitude; |
-EXTERN int sub_carrier_phase; |
- |
- |
- |
-/* ISO/IEC 13818-2 section 6.2.3.3: picture_display_extension() header */ |
-EXTERN int frame_center_horizontal_offset[3]; |
-EXTERN int frame_center_vertical_offset[3]; |
- |
- |
- |
-/* ISO/IEC 13818-2 section 6.2.2.5: sequence_scalable_extension() header */ |
-EXTERN int layer_id; |
-EXTERN int lower_layer_prediction_horizontal_size; |
-EXTERN int lower_layer_prediction_vertical_size; |
-EXTERN int horizontal_subsampling_factor_m; |
-EXTERN int horizontal_subsampling_factor_n; |
-EXTERN int vertical_subsampling_factor_m; |
-EXTERN int vertical_subsampling_factor_n; |
- |
- |
-/* ISO/IEC 13818-2 section 6.2.3.5: picture_spatial_scalable_extension() header */ |
-EXTERN int lower_layer_temporal_reference; |
-EXTERN int lower_layer_horizontal_offset; |
-EXTERN int lower_layer_vertical_offset; |
-EXTERN int spatial_temporal_weight_code_table_index; |
-EXTERN int lower_layer_progressive_frame; |
-EXTERN int lower_layer_deinterlaced_field_select; |
- |
- |
- |
- |
- |
- |
-/* ISO/IEC 13818-2 section 6.2.3.6: copyright_extension() header */ |
-EXTERN int copyright_flag; |
-EXTERN int copyright_identifier; |
-EXTERN int original_or_copy; |
-EXTERN int copyright_number_1; |
-EXTERN int copyright_number_2; |
-EXTERN int copyright_number_3; |
- |
-/* ISO/IEC 13818-2 section 6.2.2.6: group_of_pictures_header() */ |
-EXTERN int drop_flag; |
-EXTERN int hour; |
-EXTERN int minute; |
-EXTERN int sec; |
-EXTERN int frame; |
-EXTERN int closed_gop; |
-EXTERN int broken_link; |
- |
- |
- |
-/* layer specific variables (needed for SNR and DP scalability) */ |
-EXTERN struct layer_data { |
- /* bit input */ |
- int Infile; |
- |
- void *start_file_ptr; |
- void *actual_file_ptr; |
- void *end_file_ptr; |
- |
- int px; |
- int py; |
- |
- unsigned char Rdbfr[2048]; |
- unsigned char *Rdptr; |
- unsigned char Inbfr[16]; |
- /* from mpeg2play */ |
- unsigned int Bfr; |
- unsigned char *Rdmax; |
- int Incnt; |
- int Bitcnt; |
- /* sequence header and quant_matrix_extension() */ |
- int intra_quantizer_matrix[64]; |
- int non_intra_quantizer_matrix[64]; |
- int chroma_intra_quantizer_matrix[64]; |
- int chroma_non_intra_quantizer_matrix[64]; |
- |
- int load_intra_quantizer_matrix; |
- int load_non_intra_quantizer_matrix; |
- int load_chroma_intra_quantizer_matrix; |
- int load_chroma_non_intra_quantizer_matrix; |
- |
- int MPEG2_Flag; |
- /* sequence scalable extension */ |
- int scalable_mode; |
- /* picture coding extension */ |
- int q_scale_type; |
- int alternate_scan; |
- /* picture spatial scalable extension */ |
- int pict_scal; |
- /* slice/macroblock */ |
- int priority_breakpoint; |
- int quantizer_scale; |
- int intra_slice; |
- short block[12][64]; |
-} base, enhan, *ld; |
- |
-#ifdef VERIFY |
-EXTERN int verify_sequence_header; |
-EXTERN int verify_group_of_pictures_header; |
-EXTERN int verify_picture_header; |
-EXTERN int verify_slice_header; |
-EXTERN int verify_sequence_extension; |
-EXTERN int verify_sequence_display_extension; |
-EXTERN int verify_quant_matrix_extension; |
-EXTERN int verify_sequence_scalable_extension; |
-EXTERN int verify_picture_display_extension; |
-EXTERN int verify_picture_coding_extension; |
-EXTERN int verify_picture_spatial_scalable_extension; |
-EXTERN int verify_picture_temporal_scalable_extension; |
-EXTERN int verify_copyright_extension; |
-#endif /* VERIFY */ |
- |
- |
-EXTERN int Decode_Layer; |
- |
-/* verify.c */ |
-#ifdef VERIFY |
-void Check_Headers _ANSI_ARGS_((int Bitstream_Framenum, int Sequence_Framenum)); |
-void Clear_Verify_Headers _ANSI_ARGS_((void)); |
-#endif /* VERIFY */ |
- |
- |
-EXTERN int global_MBA; |
-EXTERN int global_pic; |
-EXTERN int True_Framenum; |
- |
Index: tags/rel_1_22/fsf/mpeg2/motion.c |
=================================================================== |
--- tags/rel_1_22/fsf/mpeg2/motion.c (revision 1310) |
+++ tags/rel_1_22/fsf/mpeg2/motion.c (nonexistent) |
@@ -1,234 +0,0 @@ |
-/* motion.c, motion vector decoding */ |
- |
-/* Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved. */ |
- |
-/* |
- * Disclaimer of Warranty |
- * |
- * These software programs are available to the user without any license fee or |
- * royalty on an "as is" basis. The MPEG Software Simulation Group disclaims |
- * any and all warranties, whether express, implied, or statuary, including any |
- * implied warranties or merchantability or of fitness for a particular |
- * purpose. In no event shall the copyright-holder be liable for any |
- * incidental, punitive, or consequential damages of any kind whatsoever |
- * arising from the use of these programs. |
- * |
- * This disclaimer of warranty extends to the user of these programs and user's |
- * customers, employees, agents, transferees, successors, and assigns. |
- * |
- * The MPEG Software Simulation Group does not represent or warrant that the |
- * programs furnished hereunder are free of infringement of any third-party |
- * patents. |
- * |
- * Commercial implementations of MPEG-1 and MPEG-2 video, including shareware, |
- * are subject to royalty fees to patent holders. Many of these patents are |
- * general enough such that they are unavoidable regardless of implementation |
- * design. |
- * |
- */ |
- |
-#include "config.h" |
-#include "global.h" |
- |
-/* private prototypes */ |
-static void decode_motion_vector _ANSI_ARGS_((int *pred, int r_size, int motion_code, |
- int motion_residualesidual, int full_pel_vector)); |
- |
-/* ISO/IEC 13818-2 sections 6.2.5.2, 6.3.17.2, and 7.6.3: Motion vectors */ |
-void motion_vectors(PMV,dmvector, |
- motion_vertical_field_select,s,motion_vector_count,mv_format,h_r_size,v_r_size,dmv,mvscale) |
-int PMV[2][2][2]; |
-int dmvector[2]; |
-int motion_vertical_field_select[2][2]; |
-int s, motion_vector_count, mv_format, h_r_size, v_r_size, dmv, mvscale; |
-{ |
- if (motion_vector_count==1) |
- { |
- if (mv_format==MV_FIELD && !dmv) |
- { |
- motion_vertical_field_select[1][s] = motion_vertical_field_select[0][s] = Get_Bits(1); |
-#ifdef TRACE |
- if (Trace_Flag) |
- { |
- cprintf("motion_vertical_field_select[][%d] (%d): %d\n",s, |
- motion_vertical_field_select[0][s],motion_vertical_field_select[0][s]); |
- } |
-#endif /* TRACE */ |
- } |
- |
- motion_vector(PMV[0][s],dmvector,h_r_size,v_r_size,dmv,mvscale,0); |
- |
- /* update other motion vector predictors */ |
- PMV[1][s][0] = PMV[0][s][0]; |
- PMV[1][s][1] = PMV[0][s][1]; |
- } |
- else |
- { |
- motion_vertical_field_select[0][s] = Get_Bits(1); |
-#ifdef TRACE |
- if (Trace_Flag) |
- { |
- cprintf("motion_vertical_field_select[0][%d] (%d): %d\n",s, |
- motion_vertical_field_select[0][s],motion_vertical_field_select[0][s]); |
- } |
-#endif /* TRACE */ |
- motion_vector(PMV[0][s],dmvector,h_r_size,v_r_size,dmv,mvscale,0); |
- |
- motion_vertical_field_select[1][s] = Get_Bits(1); |
-#ifdef TRACE |
- if (Trace_Flag) |
- { |
- cprintf("motion_vertical_field_select[1][%d] (%d): %d\n",s, |
- motion_vertical_field_select[1][s],motion_vertical_field_select[1][s]); |
- } |
-#endif /* TRACE */ |
- motion_vector(PMV[1][s],dmvector,h_r_size,v_r_size,dmv,mvscale,0); |
- } |
-} |
- |
-/* get and decode motion vector and differential motion vector |
- for one prediction */ |
-void motion_vector(PMV,dmvector, |
- h_r_size,v_r_size,dmv,mvscale,full_pel_vector) |
-int *PMV; |
-int *dmvector; |
-int h_r_size; |
-int v_r_size; |
-int dmv; /* MPEG-2 only: get differential motion vectors */ |
-int mvscale; /* MPEG-2 only: field vector in frame pic */ |
-int full_pel_vector; /* MPEG-1 only */ |
-{ |
- int motion_code, motion_residual; |
- |
- /* horizontal component */ |
- /* ISO/IEC 13818-2 Table B-10 */ |
- motion_code = Get_motion_code(); |
- |
- motion_residual = (h_r_size!=0 && motion_code!=0) ? Get_Bits(h_r_size) : 0; |
- |
-#ifdef TRACE |
- if (Trace_Flag) |
- { |
- if (h_r_size!=0 && motion_code!=0) |
- { |
- cprintf("motion_residual ("); |
- Print_Bits(motion_residual,h_r_size,h_r_size); |
- cprintf("): %d\n",motion_residual); |
- } |
- } |
-#endif /* TRACE */ |
- |
- |
- decode_motion_vector(&PMV[0],h_r_size,motion_code,motion_residual,full_pel_vector); |
- |
- if (dmv) |
- dmvector[0] = Get_dmvector(); |
- |
- |
- /* vertical component */ |
- motion_code = Get_motion_code(); |
- motion_residual = (v_r_size!=0 && motion_code!=0) ? Get_Bits(v_r_size) : 0; |
- |
-#ifdef TRACE |
- if (Trace_Flag) |
- { |
- if (v_r_size!=0 && motion_code!=0) |
- { |
- cprintf("motion_residual ("); |
- Print_Bits(motion_residual,v_r_size,v_r_size); |
- cprintf("): %d\n",motion_residual); |
- } |
- } |
-#endif /* TRACE */ |
- |
- if (mvscale) |
- PMV[1] >>= 1; /* DIV 2 */ |
- |
- decode_motion_vector(&PMV[1],v_r_size,motion_code,motion_residual,full_pel_vector); |
- |
- if (mvscale) |
- PMV[1] <<= 1; |
- |
- if (dmv) |
- dmvector[1] = Get_dmvector(); |
- |
-#ifdef TRACE |
- if (Trace_Flag) |
- cprintf("PMV = %d,%d\n",PMV[0],PMV[1]); |
-#endif /* TRACE */ |
-} |
- |
-/* calculate motion vector component */ |
-/* ISO/IEC 13818-2 section 7.6.3.1: Decoding the motion vectors */ |
-/* Note: the arithmetic here is more elegant than that which is shown |
- in 7.6.3.1. The end results (PMV[][][]) should, however, be the same. */ |
- |
-static void decode_motion_vector(pred,r_size,motion_code,motion_residual,full_pel_vector) |
-int *pred; |
-int r_size, motion_code, motion_residual; |
-int full_pel_vector; /* MPEG-1 (ISO/IEC 11172-1) support */ |
-{ |
- int lim, vec; |
- |
- lim = 16<<r_size; |
- vec = full_pel_vector ? (*pred >> 1) : (*pred); |
- |
- if (motion_code>0) |
- { |
- vec+= ((motion_code-1)<<r_size) + motion_residual + 1; |
- if (vec>=lim) |
- vec-= lim + lim; |
- } |
- else if (motion_code<0) |
- { |
- vec-= ((-motion_code-1)<<r_size) + motion_residual + 1; |
- if (vec<-lim) |
- vec+= lim + lim; |
- } |
- *pred = full_pel_vector ? (vec<<1) : vec; |
-} |
- |
- |
-/* ISO/IEC 13818-2 section 7.6.3.6: Dual prime additional arithmetic */ |
-void Dual_Prime_Arithmetic(DMV,dmvector,mvx,mvy) |
-int DMV[][2]; |
-int *dmvector; /* differential motion vector */ |
-int mvx, mvy; /* decoded mv components (always in field format) */ |
-{ |
- if (picture_structure==FRAME_PICTURE) |
- { |
- if (top_field_first) |
- { |
- /* vector for prediction of top field from bottom field */ |
- DMV[0][0] = ((mvx +(mvx>0))>>1) + dmvector[0]; |
- DMV[0][1] = ((mvy +(mvy>0))>>1) + dmvector[1] - 1; |
- |
- /* vector for prediction of bottom field from top field */ |
- DMV[1][0] = ((3*mvx+(mvx>0))>>1) + dmvector[0]; |
- DMV[1][1] = ((3*mvy+(mvy>0))>>1) + dmvector[1] + 1; |
- } |
- else |
- { |
- /* vector for prediction of top field from bottom field */ |
- DMV[0][0] = ((3*mvx+(mvx>0))>>1) + dmvector[0]; |
- DMV[0][1] = ((3*mvy+(mvy>0))>>1) + dmvector[1] - 1; |
- |
- /* vector for prediction of bottom field from top field */ |
- DMV[1][0] = ((mvx +(mvx>0))>>1) + dmvector[0]; |
- DMV[1][1] = ((mvy +(mvy>0))>>1) + dmvector[1] + 1; |
- } |
- } |
- else |
- { |
- /* vector for prediction from field of opposite 'parity' */ |
- DMV[0][0] = ((mvx+(mvx>0))>>1) + dmvector[0]; |
- DMV[0][1] = ((mvy+(mvy>0))>>1) + dmvector[1]; |
- |
- /* correct for vertical field shift */ |
- if (picture_structure==TOP_FIELD) |
- DMV[0][1]--; |
- else |
- DMV[0][1]++; |
- } |
-} |
- |
Index: tags/rel_1_22/fsf/mpeg2/recon.c |
=================================================================== |
--- tags/rel_1_22/fsf/mpeg2/recon.c (revision 1310) |
+++ tags/rel_1_22/fsf/mpeg2/recon.c (nonexistent) |
@@ -1,465 +0,0 @@ |
-/* Predict.c, motion compensation routines */ |
- |
-/* Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved. */ |
- |
-/* |
- * Disclaimer of Warranty |
- * |
- * These software programs are available to the user without any license fee or |
- * royalty on an "as is" basis. The MPEG Software Simulation Group disclaims |
- * any and all warranties, whether express, implied, or statuary, including any |
- * implied warranties or merchantability or of fitness for a particular |
- * purpose. In no event shall the copyright-holder be liable for any |
- * incidental, punitive, or consequential damages of any kind whatsoever |
- * arising from the use of these programs. |
- * |
- * This disclaimer of warranty extends to the user of these programs and user's |
- * customers, employees, agents, transferees, successors, and assigns. |
- * |
- * The MPEG Software Simulation Group does not represent or warrant that the |
- * programs furnished hereunder are free of infringement of any third-party |
- * patents. |
- * |
- * Commercial implementations of MPEG-1 and MPEG-2 video, including shareware, |
- * are subject to royalty fees to patent holders. Many of these patents are |
- * general enough such that they are unavoidable regardless of implementation |
- * design. |
- * |
- */ |
- |
-#include "config.h" |
-#include "global.h" |
- |
-/* private prototypes */ |
-static void form_prediction _ANSI_ARGS_((unsigned char *src[], int sfield, |
- unsigned char *dst[], int dfield, |
- int lx, int lx2, int w, int h, int x, int y, int dx, int dy, |
- int average_flag)); |
- |
-static void form_component_prediction _ANSI_ARGS_((unsigned char *src, unsigned char *dst, |
- int lx, int lx2, int w, int h, int x, int y, int dx, int dy, int average_flag)); |
- |
-void form_predictions(bx,by,macroblock_type,motion_type,PMV,motion_vertical_field_select,dmvector,stwtype) |
-int bx, by; |
-int macroblock_type; |
-int motion_type; |
-int PMV[2][2][2], motion_vertical_field_select[2][2], dmvector[2]; |
-int stwtype; |
-{ |
- int currentfield; |
- unsigned char **predframe; |
- int DMV[2][2]; |
- int stwtop, stwbot; |
- |
- stwtop = stwtype%3; /* 0:temporal, 1:(spat+temp)/2, 2:spatial */ |
- stwbot = stwtype/3; |
- |
- if ((macroblock_type & MACROBLOCK_MOTION_FORWARD) |
- || (picture_coding_type==P_TYPE)) |
- { |
- if (picture_structure==FRAME_PICTURE) |
- { |
- if ((motion_type==MC_FRAME) |
- || !(macroblock_type & MACROBLOCK_MOTION_FORWARD)) |
- { |
- /* frame-based prediction (broken into top and bottom halves |
- for spatial scalability prediction purposes) */ |
- if (stwtop<2) |
- form_prediction(forward_reference_frame,0,current_frame,0, |
- Coded_Picture_Width,Coded_Picture_Width<<1,16,8,bx,by, |
- PMV[0][0][0],PMV[0][0][1],stwtop); |
- |
- if (stwbot<2) |
- form_prediction(forward_reference_frame,1,current_frame,1, |
- Coded_Picture_Width,Coded_Picture_Width<<1,16,8,bx,by, |
- PMV[0][0][0],PMV[0][0][1],stwbot); |
- } |
- else if (motion_type==MC_FIELD) /* field-based prediction */ |
- { |
- /* top field prediction */ |
- if (stwtop<2) |
- form_prediction(forward_reference_frame,motion_vertical_field_select[0][0], |
- current_frame,0,Coded_Picture_Width<<1,Coded_Picture_Width<<1,16,8, |
- bx,by>>1,PMV[0][0][0],PMV[0][0][1]>>1,stwtop); |
- |
- /* bottom field prediction */ |
- if (stwbot<2) |
- form_prediction(forward_reference_frame,motion_vertical_field_select[1][0], |
- current_frame,1,Coded_Picture_Width<<1,Coded_Picture_Width<<1,16,8, |
- bx,by>>1,PMV[1][0][0],PMV[1][0][1]>>1,stwbot); |
- } |
- else if (motion_type==MC_DMV) /* dual prime prediction */ |
- { |
- /* calculate derived motion vectors */ |
- Dual_Prime_Arithmetic(DMV,dmvector,PMV[0][0][0],PMV[0][0][1]>>1); |
- |
- if (stwtop<2) |
- { |
- /* predict top field from top field */ |
- form_prediction(forward_reference_frame,0,current_frame,0, |
- Coded_Picture_Width<<1,Coded_Picture_Width<<1,16,8,bx,by>>1, |
- PMV[0][0][0],PMV[0][0][1]>>1,0); |
- |
- /* predict and add to top field from bottom field */ |
- form_prediction(forward_reference_frame,1,current_frame,0, |
- Coded_Picture_Width<<1,Coded_Picture_Width<<1,16,8,bx,by>>1, |
- DMV[0][0],DMV[0][1],1); |
- } |
- |
- if (stwbot<2) |
- { |
- /* predict bottom field from bottom field */ |
- form_prediction(forward_reference_frame,1,current_frame,1, |
- Coded_Picture_Width<<1,Coded_Picture_Width<<1,16,8,bx,by>>1, |
- PMV[0][0][0],PMV[0][0][1]>>1,0); |
- |
- /* predict and add to bottom field from top field */ |
- form_prediction(forward_reference_frame,0,current_frame,1, |
- Coded_Picture_Width<<1,Coded_Picture_Width<<1,16,8,bx,by>>1, |
- DMV[1][0],DMV[1][1],1); |
- } |
- } |
- else |
- /* invalid motion_type */ |
- cprintf("invalid motion_type\n"); |
- } |
- else /* TOP_FIELD or BOTTOM_FIELD */ |
- { |
- /* field picture */ |
- currentfield = (picture_structure==BOTTOM_FIELD); |
- |
- /* determine which frame to use for prediction */ |
- if ((picture_coding_type==P_TYPE) && Second_Field |
- && (currentfield!=motion_vertical_field_select[0][0])) |
- predframe = backward_reference_frame; /* same frame */ |
- else |
- predframe = forward_reference_frame; /* previous frame */ |
- |
- if ((motion_type==MC_FIELD) |
- || !(macroblock_type & MACROBLOCK_MOTION_FORWARD)) |
- { |
- /* field-based prediction */ |
- if (stwtop<2) |
- form_prediction(predframe,motion_vertical_field_select[0][0],current_frame,0, |
- Coded_Picture_Width<<1,Coded_Picture_Width<<1,16,16,bx,by, |
- PMV[0][0][0],PMV[0][0][1],stwtop); |
- } |
- else if (motion_type==MC_16X8) |
- { |
- if (stwtop<2) |
- { |
- form_prediction(predframe,motion_vertical_field_select[0][0],current_frame,0, |
- Coded_Picture_Width<<1,Coded_Picture_Width<<1,16,8,bx,by, |
- PMV[0][0][0],PMV[0][0][1],stwtop); |
- |
- /* determine which frame to use for lower half prediction */ |
- if ((picture_coding_type==P_TYPE) && Second_Field |
- && (currentfield!=motion_vertical_field_select[1][0])) |
- predframe = backward_reference_frame; /* same frame */ |
- else |
- predframe = forward_reference_frame; /* previous frame */ |
- |
- form_prediction(predframe,motion_vertical_field_select[1][0],current_frame,0, |
- Coded_Picture_Width<<1,Coded_Picture_Width<<1,16,8,bx,by+8, |
- PMV[1][0][0],PMV[1][0][1],stwtop); |
- } |
- } |
- else if (motion_type==MC_DMV) /* dual prime prediction */ |
- { |
- if (Second_Field) |
- predframe = backward_reference_frame; /* same frame */ |
- else |
- predframe = forward_reference_frame; /* previous frame */ |
- |
- /* calculate derived motion vectors */ |
- Dual_Prime_Arithmetic(DMV,dmvector,PMV[0][0][0],PMV[0][0][1]); |
- |
- /* predict from field of same parity */ |
- form_prediction(forward_reference_frame,currentfield,current_frame,0, |
- Coded_Picture_Width<<1,Coded_Picture_Width<<1,16,16,bx,by, |
- PMV[0][0][0],PMV[0][0][1],0); |
- |
- /* predict from field of opposite parity */ |
- form_prediction(predframe,!currentfield,current_frame,0, |
- Coded_Picture_Width<<1,Coded_Picture_Width<<1,16,16,bx,by, |
- DMV[0][0],DMV[0][1],1); |
- } |
- else |
- /* invalid motion_type */ |
- cprintf("invalid motion_type\n"); |
- } |
- stwtop = stwbot = 1; |
- } |
- |
- if (macroblock_type & MACROBLOCK_MOTION_BACKWARD) |
- { |
- if (picture_structure==FRAME_PICTURE) |
- { |
- if (motion_type==MC_FRAME) |
- { |
- /* frame-based prediction */ |
- if (stwtop<2) |
- form_prediction(backward_reference_frame,0,current_frame,0, |
- Coded_Picture_Width,Coded_Picture_Width<<1,16,8,bx,by, |
- PMV[0][1][0],PMV[0][1][1],stwtop); |
- |
- if (stwbot<2) |
- form_prediction(backward_reference_frame,1,current_frame,1, |
- Coded_Picture_Width,Coded_Picture_Width<<1,16,8,bx,by, |
- PMV[0][1][0],PMV[0][1][1],stwbot); |
- } |
- else /* field-based prediction */ |
- { |
- /* top field prediction */ |
- if (stwtop<2) |
- form_prediction(backward_reference_frame,motion_vertical_field_select[0][1], |
- current_frame,0,Coded_Picture_Width<<1,Coded_Picture_Width<<1,16,8, |
- bx,by>>1,PMV[0][1][0],PMV[0][1][1]>>1,stwtop); |
- |
- /* bottom field prediction */ |
- if (stwbot<2) |
- form_prediction(backward_reference_frame,motion_vertical_field_select[1][1], |
- current_frame,1,Coded_Picture_Width<<1,Coded_Picture_Width<<1,16,8, |
- bx,by>>1,PMV[1][1][0],PMV[1][1][1]>>1,stwbot); |
- } |
- } |
- else /* TOP_FIELD or BOTTOM_FIELD */ |
- { |
- /* field picture */ |
- if (motion_type==MC_FIELD) |
- { |
- /* field-based prediction */ |
- form_prediction(backward_reference_frame,motion_vertical_field_select[0][1], |
- current_frame,0,Coded_Picture_Width<<1,Coded_Picture_Width<<1,16,16, |
- bx,by,PMV[0][1][0],PMV[0][1][1],stwtop); |
- } |
- else if (motion_type==MC_16X8) |
- { |
- form_prediction(backward_reference_frame,motion_vertical_field_select[0][1], |
- current_frame,0,Coded_Picture_Width<<1,Coded_Picture_Width<<1,16,8, |
- bx,by,PMV[0][1][0],PMV[0][1][1],stwtop); |
- |
- form_prediction(backward_reference_frame,motion_vertical_field_select[1][1], |
- current_frame,0,Coded_Picture_Width<<1,Coded_Picture_Width<<1,16,8, |
- bx,by+8,PMV[1][1][0],PMV[1][1][1],stwtop); |
- } |
- else |
- /* invalid motion_type */ |
- cprintf("invalid motion_type\n"); |
- } |
- } |
-} |
- |
-static void form_prediction(src,sfield,dst,dfield,lx,lx2,w,h,x,y,dx,dy,average_flag) |
-unsigned char *src[]; /* prediction source buffer */ |
-int sfield; /* prediction source field number (0 or 1) */ |
-unsigned char *dst[]; /* prediction destination buffer */ |
-int dfield; /* prediction destination field number (0 or 1)*/ |
-int lx,lx2; /* line strides */ |
-int w,h; /* prediction block/sub-block width, height */ |
-int x,y; /* pixel co-ordinates of top-left sample in current MB */ |
-int dx,dy; /* horizontal, vertical prediction address */ |
-int average_flag; /* add prediction error to prediction ? */ |
-{ |
- /* Y */ |
- form_component_prediction(src[0]+(sfield?lx2>>1:0),dst[0]+(dfield?lx2>>1:0), |
- lx,lx2,w,h,x,y,dx,dy,average_flag); |
- |
- if (chroma_format!=CHROMA444) |
- { |
- lx>>=1; lx2>>=1; w>>=1; x>>=1; dx/=2; |
- } |
- |
- if (chroma_format==CHROMA420) |
- { |
- h>>=1; y>>=1; dy/=2; |
- } |
- |
- /* Cb */ |
- form_component_prediction(src[1]+(sfield?lx2>>1:0),dst[1]+(dfield?lx2>>1:0), |
- lx,lx2,w,h,x,y,dx,dy,average_flag); |
- |
- /* Cr */ |
- form_component_prediction(src[2]+(sfield?lx2>>1:0),dst[2]+(dfield?lx2>>1:0), |
- lx,lx2,w,h,x,y,dx,dy,average_flag); |
-} |
- |
-/* ISO/IEC 13818-2 section 7.6.4: Forming predictions */ |
-/* NOTE: the arithmetic below produces numerically equivalent results |
- * to 7.6.4, yet is more elegant. It differs in the following ways: |
- * |
- * 1. the vectors (dx, dy) are based on cartesian frame |
- * coordiantes along a half-pel grid (always positive numbers) |
- * In contrast, vector[r][s][t] are differential (with positive and |
- * negative values). As a result, deriving the integer vectors |
- * (int_vec[t]) from dx, dy is accomplished by a simple right shift. |
- * |
- * 2. Half pel flags (xh, yh) are equivalent to the LSB (Least |
- * Significant Bit) of the half-pel coordinates (dx,dy). |
- * |
- * |
- * NOTE: the work of combining predictions (ISO/IEC 13818-2 section 7.6.7) |
- * is distributed among several other stages. This is accomplished by |
- * folding line offsets into the source and destination (src,dst) |
- * addresses (note the call arguments to form_prediction() in Predict()), |
- * line stride variables lx and lx2, the block dimension variables (w,h), |
- * average_flag, and by the very order in which Predict() is called. |
- * This implementation design (implicitly different than the spec) |
- * was chosen for its elegance. |
-*/ |
- |
-static void form_component_prediction(src,dst,lx,lx2,w,h,x,y,dx,dy,average_flag) |
-unsigned char *src; |
-unsigned char *dst; |
-int lx; /* raster line increment */ |
-int lx2; |
-int w,h; |
-int x,y; |
-int dx,dy; |
-int average_flag; /* flag that signals bi-directional or Dual-Prime |
- averaging (7.6.7.1 and 7.6.7.4). if average_flag==1, |
- a previously formed prediction has been stored in |
- pel_pred[] */ |
-{ |
- int xint; /* horizontal integer sample vector: analogous to int_vec[0] */ |
- int yint; /* vertical integer sample vectors: analogous to int_vec[1] */ |
- int xh; /* horizontal half sample flag: analogous to half_flag[0] */ |
- int yh; /* vertical half sample flag: analogous to half_flag[1] */ |
- int i, j, v; |
- unsigned char *s; /* source pointer: analogous to pel_ref[][] */ |
- unsigned char *d; /* destination pointer: analogous to pel_pred[][] */ |
- |
- /* half pel scaling for integer vectors */ |
- xint = dx>>1; |
- yint = dy>>1; |
- |
- /* derive half pel flags */ |
- xh = dx & 1; |
- yh = dy & 1; |
- |
- /* compute the linear address of pel_ref[][] and pel_pred[][] |
- based on cartesian/raster cordinates provided */ |
- s = src + lx*(y+yint) + x + xint; |
- d = dst + lx*y + x; |
- |
- if (!xh && !yh) /* no horizontal nor vertical half-pel */ |
- { |
- if (average_flag) |
- { |
- for (j=0; j<h; j++) |
- { |
- for (i=0; i<w; i++) |
- { |
- v = d[i]+s[i]; |
- d[i] = (v+(v>=0?1:0))>>1; |
- } |
- |
- s+= lx2; |
- d+= lx2; |
- } |
- } |
- else |
- { |
- for (j=0; j<h; j++) |
- { |
- for (i=0; i<w; i++) |
- { |
- d[i] = s[i]; |
- } |
- |
- s+= lx2; |
- d+= lx2; |
- } |
- } |
- } |
- else if (!xh && yh) /* no horizontal but vertical half-pel */ |
- { |
- if (average_flag) |
- { |
- for (j=0; j<h; j++) |
- { |
- for (i=0; i<w; i++) |
- { |
- v = d[i] + ((unsigned int)(s[i]+s[i+lx]+1)>>1); |
- d[i]=(v+(v>=0?1:0))>>1; |
- } |
- |
- s+= lx2; |
- d+= lx2; |
- } |
- } |
- else |
- { |
- for (j=0; j<h; j++) |
- { |
- for (i=0; i<w; i++) |
- { |
- d[i] = (unsigned int)(s[i]+s[i+lx]+1)>>1; |
- } |
- |
- s+= lx2; |
- d+= lx2; |
- } |
- } |
- } |
- else if (xh && !yh) /* horizontal but no vertical half-pel */ |
- { |
- if (average_flag) |
- { |
- for (j=0; j<h; j++) |
- { |
- for (i=0; i<w; i++) |
- { |
- v = d[i] + ((unsigned int)(s[i]+s[i+1]+1)>>1); |
- d[i] = (v+(v>=0?1:0))>>1; |
- } |
- |
- s+= lx2; |
- d+= lx2; |
- } |
- } |
- else |
- { |
- for (j=0; j<h; j++) |
- { |
- for (i=0; i<w; i++) |
- { |
- d[i] = (unsigned int)(s[i]+s[i+1]+1)>>1; |
- } |
- |
- s+= lx2; |
- d+= lx2; |
- } |
- } |
- } |
- else /* if (xh && yh) horizontal and vertical half-pel */ |
- { |
- if (average_flag) |
- { |
- for (j=0; j<h; j++) |
- { |
- for (i=0; i<w; i++) |
- { |
- v = d[i] + ((unsigned int)(s[i]+s[i+1]+s[i+lx]+s[i+lx+1]+2)>>2); |
- d[i] = (v+(v>=0?1:0))>>1; |
- } |
- |
- s+= lx2; |
- d+= lx2; |
- } |
- } |
- else |
- { |
- for (j=0; j<h; j++) |
- { |
- for (i=0; i<w; i++) |
- { |
- d[i] = (unsigned int)(s[i]+s[i+1]+s[i+lx]+s[i+lx+1]+2)>>2; |
- } |
- |
- s+= lx2; |
- d+= lx2; |
- } |
- } |
- } |
-} |
Index: tags/rel_1_22/fsf/mpeg2/systems.c |
=================================================================== |
--- tags/rel_1_22/fsf/mpeg2/systems.c (revision 1310) |
+++ tags/rel_1_22/fsf/mpeg2/systems.c (nonexistent) |
@@ -1,195 +0,0 @@ |
-/* systems.c, systems-specific routines */ |
- |
-/* Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved. */ |
- |
-/* |
- * Disclaimer of Warranty |
- * |
- * These software programs are available to the user without any license fee or |
- * royalty on an "as is" basis. The MPEG Software Simulation Group disclaims |
- * any and all warranties, whether express, implied, or statuary, including any |
- * implied warranties or merchantability or of fitness for a particular |
- * purpose. In no event shall the copyright-holder be liable for any |
- * incidental, punitive, or consequential damages of any kind whatsoever |
- * arising from the use of these programs. |
- * |
- * This disclaimer of warranty extends to the user of these programs and user's |
- * customers, employees, agents, transferees, successors, and assigns. |
- * |
- * The MPEG Software Simulation Group does not represent or warrant that the |
- * programs furnished hereunder are free of infringement of any third-party |
- * patents. |
- * |
- * Commercial implementations of MPEG-1 and MPEG-2 video, including shareware, |
- * are subject to royalty fees to patent holders. Many of these patents are |
- * general enough such that they are unavoidable regardless of implementation |
- * design. |
- * |
- */ |
- |
-#include <stdlib.h> |
- |
-#include "config.h" |
-#include "global.h" |
- |
-/* initialize buffer, call once before first getbits or showbits */ |
- |
-/* parse system layer, ignore everything we don't need */ |
-void Next_Packet() |
-{ |
- unsigned int code; |
- int l; |
- |
- for(;;) |
- { |
- code = Get_Long(); |
- |
- /* remove system layer byte stuffing */ |
- while ((code & 0xffffff00) != 0x100) |
- code = (code<<8) | Get_Byte(); |
- |
- switch(code) |
- { |
- case PACK_START_CODE: /* pack header */ |
- /* skip pack header (system_clock_reference and mux_rate) */ |
- ld->Rdptr += 8; |
- break; |
- case VIDEO_ELEMENTARY_STREAM: |
- code = Get_Word(); /* packet_length */ |
- ld->Rdmax = ld->Rdptr + code; |
- |
- code = Get_Byte(); |
- |
- if((code>>6)==0x02) |
- { |
- ld->Rdptr++; |
- code=Get_Byte(); /* parse PES_header_data_length */ |
- ld->Rdptr+=code; /* advance pointer by PES_header_data_length */ |
- cprintf("MPEG-2 PES packet\n"); |
- return; |
- } |
- else if(code==0xff) |
- { |
- /* parse MPEG-1 packet header */ |
- while((code=Get_Byte())== 0xFF); |
- } |
- |
- /* stuffing bytes */ |
- if(code>=0x40) |
- { |
- if(code>=0x80) |
- { |
- cprintf("Error in packet header\n"); |
- } |
- /* skip STD_buffer_scale */ |
- ld->Rdptr++; |
- code = Get_Byte(); |
- } |
- |
- if(code>=0x30) |
- { |
- if(code>=0x40) |
- { |
- cprintf("Error in packet header\n"); |
- } |
- /* skip presentation and decoding time stamps */ |
- ld->Rdptr += 9; |
- } |
- else if(code>=0x20) |
- { |
- /* skip presentation time stamps */ |
- ld->Rdptr += 4; |
- } |
- else if(code!=0x0f) |
- { |
- cprintf("Error in packet header\n"); |
- } |
- return; |
- case ISO_END_CODE: /* end */ |
- /* simulate a buffer full of sequence end codes */ |
- l = 0; |
- while (l<2048) |
- { |
- ld->Rdbfr[l++] = SEQUENCE_END_CODE>>24; |
- ld->Rdbfr[l++] = SEQUENCE_END_CODE>>16; |
- ld->Rdbfr[l++] = SEQUENCE_END_CODE>>8; |
- ld->Rdbfr[l++] = SEQUENCE_END_CODE&0xff; |
- } |
- ld->Rdptr = ld->Rdbfr; |
- ld->Rdmax = ld->Rdbfr + 2048; |
- return; |
- default: |
- if(code>=SYSTEM_START_CODE) |
- { |
- /* skip system headers and non-video packets*/ |
- code = Get_Word(); |
- ld->Rdptr += code; |
- } |
- else |
- { |
- cprintf("Unexpected startcode %08x in system layer\n",code); |
- } |
- break; |
- } |
- } |
-} |
- |
- |
- |
-void Flush_Buffer32() |
-{ |
- int Incnt; |
- |
- ld->Bfr = 0; |
- |
- Incnt = ld->Incnt; |
- Incnt -= 32; |
- |
- if (System_Stream_Flag && (ld->Rdptr >= ld->Rdmax-4)) |
- { |
- while (Incnt <= 24) |
- { |
- if (ld->Rdptr >= ld->Rdmax) |
- Next_Packet(); |
- ld->Bfr |= Get_Byte() << (24 - Incnt); |
- Incnt += 8; |
- } |
- } |
- else |
- { |
- while (Incnt <= 24) |
- { |
- if (ld->Rdptr >= ld->Rdbfr+2048) |
- Fill_Buffer(); |
- ld->Bfr |= *ld->Rdptr++ << (24 - Incnt); |
- Incnt += 8; |
- } |
- } |
- ld->Incnt = Incnt; |
- |
-#ifdef VERIFY |
- ld->Bitcnt += 32; |
-#endif /* VERIFY */ |
-} |
- |
- |
-unsigned int Get_Bits32() |
-{ |
- unsigned int l; |
- |
- l = Show_Bits(32); |
- Flush_Buffer32(); |
- |
- return l; |
-} |
- |
- |
-int Get_Long() |
-{ |
- int i; |
- |
- i = Get_Word(); |
- return (i<<16) | Get_Word(); |
-} |
- |
- |
Index: tags/rel_1_22/fsf/mpeg2/subspic.c |
=================================================================== |
--- tags/rel_1_22/fsf/mpeg2/subspic.c (revision 1310) |
+++ tags/rel_1_22/fsf/mpeg2/subspic.c (nonexistent) |
@@ -1,384 +0,0 @@ |
-/* #define DEBUG */ |
-/* subspic.c, Frame buffer substitution routines */ |
- |
-/* Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved. */ |
- |
-/* |
- * Disclaimer of Warranty |
- * |
- * These software programs are available to the user without any license fee or |
- * royalty on an "as is" basis. The MPEG Software Simulation Group disclaims |
- * any and all warranties, whether express, implied, or statuary, including any |
- * implied warranties or merchantability or of fitness for a particular |
- * purpose. In no event shall the copyright-holder be liable for any |
- * incidental, punitive, or consequential damages of any kind whatsoever |
- * arising from the use of these programs. |
- * |
- * This disclaimer of warranty extends to the user of these programs and user's |
- * customers, employees, agents, transferees, successors, and assigns. |
- * |
- * The MPEG Software Simulation Group does not represent or warrant that the |
- * programs furnished hereunder are free of infringement of any third-party |
- * patents. |
- * |
- * Commercial implementations of MPEG-1 and MPEG-2 video, including shareware, |
- * are subject to royalty fees to patent holders. Many of these patents are |
- * general enough such that they are unavoidable regardless of implementation |
- * design. |
- * |
- */ |
- |
-#include <stdlib.h> |
- |
-#include "config.h" |
-#include "global.h" |
- |
-/* private prototypes*/ |
-static void Read_Frame _ANSI_ARGS_((char *filename, |
- unsigned char *frame_buffer[], int framenum)); |
-static void Copy_Frame _ANSI_ARGS_((unsigned char *src, unsigned char *dst, |
- int width, int height, int parity, int incr)); |
-static int Read_Components _ANSI_ARGS_ ((char *filename, |
- unsigned char *frame[3], int framenum)); |
-static int Read_Component _ANSI_ARGS_ ((char *fname, unsigned char *frame, |
- int width, int height)); |
-static int Extract_Components _ANSI_ARGS_ ((char *filename, |
- unsigned char *frame[3], int framenum)); |
- |
-extern int read(int Infile, void *Rdbfr, int rdsize); |
- |
-/* substitute frame buffer routine */ |
-void Substitute_Frame_Buffer (bitstream_framenum, sequence_framenum) |
-int bitstream_framenum; |
-int sequence_framenum; |
-{ |
- /* static tracking variables */ |
- static int previous_temporal_reference; |
- static int previous_bitstream_framenum; |
- static int previous_anchor_temporal_reference; |
- static int previous_anchor_bitstream_framenum; |
- static int previous_picture_coding_type; |
- static int bgate; |
- |
- /* local temporary variables */ |
- int substitute_display_framenum; |
- |
- |
-#ifdef DEBUG |
- cprintf("SUB: seq fn(%d) bitfn(%d) tempref(%d) picstr(%d) type(%d)\n", |
- sequence_framenum, bitstream_framenum, temporal_reference, |
- picture_structure, picture_coding_type); |
-#endif |
- |
- /* we don't substitute at the first picture of a sequence */ |
- if((sequence_framenum!=0)||(Second_Field)) |
- { |
- /* only at the start of the frame */ |
- if ((picture_structure==FRAME_PICTURE)||(!Second_Field)) |
- { |
- if(picture_coding_type==P_TYPE) |
- { |
- /* the most recently decoded reference frame needs substituting */ |
- substitute_display_framenum = bitstream_framenum - 1; |
- |
- Read_Frame(Substitute_Picture_Filename, forward_reference_frame, |
- substitute_display_framenum); |
- } |
- /* only the first B frame in a consequitve set of B pictures |
- loads a substitute backward_reference_frame since all subsequent |
- B frames predict from the same reference pictures */ |
- else if((picture_coding_type==B_TYPE)&&(bgate!=1)) |
- { |
- substitute_display_framenum = |
- (previous_temporal_reference - temporal_reference) |
- + bitstream_framenum - 1; |
- |
- Read_Frame(Substitute_Picture_Filename, backward_reference_frame, |
- substitute_display_framenum); |
- } |
- } /* P fields can predict from the two most recently decoded fields, even |
- from the first field of the same frame being decoded */ |
- else if(Second_Field && (picture_coding_type==P_TYPE)) |
- { |
- /* our favourite case: the IP field picture pair */ |
- if((previous_picture_coding_type==I_TYPE)&&(picture_coding_type==P_TYPE)) |
- { |
- substitute_display_framenum = bitstream_framenum; |
- } |
- else /* our more generic P field picture pair */ |
- { |
- substitute_display_framenum = |
- (temporal_reference - previous_anchor_temporal_reference) |
- + bitstream_framenum - 1; |
- } |
- |
- Read_Frame(Substitute_Picture_Filename, current_frame, substitute_display_framenum); |
- } |
-#ifdef DEBUG |
- else if((picture_coding_type!=B_TYPE)||(picture_coding_type!=D_TYPE)) |
- { |
- cprintf("NO SUBS FOR THIS PICTURE\n"); |
- } |
-#endif |
- } |
- |
- |
- /* set b gate so we don't redundantly load next time around */ |
- if(picture_coding_type==B_TYPE) |
- bgate = 1; |
- else |
- bgate = 0; |
- |
- /* update general tracking variables */ |
- if((picture_structure==FRAME_PICTURE)||(!Second_Field)) |
- { |
- previous_temporal_reference = temporal_reference; |
- previous_bitstream_framenum = bitstream_framenum; |
- } |
- |
- /* update reference frame tracking variables */ |
- if((picture_coding_type!=B_TYPE) && |
- ((picture_structure==FRAME_PICTURE)||Second_Field)) |
- { |
- previous_anchor_temporal_reference = temporal_reference; |
- previous_anchor_bitstream_framenum = bitstream_framenum; |
- } |
- |
- previous_picture_coding_type = picture_coding_type; |
- |
-} |
- |
- |
-/* Note: fields are only read to serve as the same-frame reference for |
- a second field */ |
-static void Read_Frame(fname,frame,framenum) |
-char *fname; |
-unsigned char *frame[]; |
-int framenum; |
-{ |
- int parity; |
- int rerr = 0; |
- int field_mode; |
- |
- if(framenum<0) |
- cprintf("ERROR: framenum (%d) is less than zero\n", framenum); |
- |
- |
- if(Big_Picture_Flag) |
- rerr = Extract_Components(fname, substitute_frame, framenum); |
- else |
- rerr = Read_Components(fname, substitute_frame, framenum); |
- |
- if(rerr!=0) |
- { |
- cprintf("was unable to substitute frame\n"); |
- } |
- |
- /* now copy to the appropriate buffer */ |
- /* first field (which we are attempting to substitute) must be |
- of opposite field parity to the current one */ |
- if((Second_Field)&&(picture_coding_type==P_TYPE)) |
- { |
- parity = (picture_structure==TOP_FIELD ? 1:0); |
- field_mode = (picture_structure==FRAME_PICTURE ? 0:1); |
- } |
- else |
- { |
- /* Like frame structued pictures, B pictures only substitute an entire frame |
- since both fields always predict from the same frame (with respect |
- to forward/backwards directions) */ |
- parity = 0; |
- field_mode = 0; |
- } |
- |
- |
- Copy_Frame(substitute_frame[0], frame[0], Coded_Picture_Width, |
- Coded_Picture_Height, parity, field_mode); |
- |
- Copy_Frame(substitute_frame[1], frame[1], Chroma_Width, Chroma_Height, |
- parity, field_mode); |
- |
- Copy_Frame(substitute_frame[2], frame[2], Chroma_Width, Chroma_Height, |
- parity, field_mode); |
- |
-#ifdef VERBOSE |
- if(Verbose_Flag > NO_LAYER) |
- cprintf("substituted %s %d\n", |
- (field_mode ? (parity?"bottom field":"bottom field"):"frame"), framenum); |
-#endif |
-} |
- |
- |
- |
- |
-static int Read_Components(filename, frame, framenum) |
-char *filename; |
-unsigned char *frame[3]; |
-int framenum; |
-{ |
- int err = 0; |
- char outname[FILENAME_LENGTH]; |
- char name[FILENAME_LENGTH]; |
- |
- sprintf(outname,filename,framenum); |
- |
- |
- sprintf(name,"%s.Y",outname); |
- err += Read_Component(name, frame[0], Coded_Picture_Width, |
- Coded_Picture_Height); |
- |
- sprintf(name,"%s.U",outname); |
- err += Read_Component(name, frame[1], Chroma_Width, Chroma_Height); |
- |
- sprintf(name,"%s.V",outname); |
- err += Read_Component(name, frame[2], Chroma_Width, Chroma_Height); |
- |
- return(err); |
-} |
- |
- |
-static int Read_Component(Filename, Frame, Width, Height) |
-char *Filename; |
-unsigned char *Frame; |
-int Width; |
-int Height; |
-{ |
- int Size; |
- int Bytes_Read; |
- int Infile; |
- |
- Size = Width*Height; |
- |
-#ifdef DEBUG |
- cprintf("SUBS: reading %s\n", filename); |
-#endif |
- |
- if(!(Infile=1)<0) |
- { |
- cprintf("ERROR: unable to open reference filename (%s)\n", Filename); |
- return(-1); |
- } |
- |
- Bytes_Read = read(Infile, Frame, Size); |
- |
- if(Bytes_Read!=Size) |
- { |
- cprintf("was able to read only %d bytes of %d of file %s\n", |
- Bytes_Read, Size, Filename); |
- } |
- |
- return(0); |
-} |
- |
- |
-/* optimization: do not open the big file each time. Open once at start |
- of decoder, and close at the very last frame */ |
- |
-/* Note: "big" files were used in E-mail exchanges almost exclusively by the |
- MPEG Committee's syntax validation and conformance ad-hoc groups from |
- the year 1993 until 1995 */ |
-static int Extract_Components(filename, frame, framenum) |
-char *filename; |
-unsigned char *frame[3]; |
-int framenum; |
-{ |
-/* int err = 0; */ |
- int line; |
- int size, offset; |
- |
- cprintf("Extract_Components\n"); |
- |
- /* compute size of each frame (in bytes) */ |
- size = (Coded_Picture_Width*Coded_Picture_Height); |
- |
- if(chroma_format==CHROMA444) |
- size = (size * 3); |
- else if(chroma_format==CHROMA422) |
- size = (size * 2); |
- else if(chroma_format==CHROMA420) |
- size = ((size*3)>>1); |
- else |
- cprintf("ERROR: chroma_format (%d) not recognized\n", chroma_format); |
- |
- |
- /* compute distance into "big" file */ |
- offset = size*framenum; |
- |
-#ifdef DEBUG |
- printf("EXTRACTING: frame(%d) offset(%d), size (%d) from %s\n", |
- framenum, offset, size, filename); |
-#endif |
- |
- /* seek to location in big file where desired frame begins */ |
- /* note: this offset cannot exceed a few billion bytes due to the */ |
- /* obvious limitations of 32-bit integers */ |
- //fseek(fd, offset, 0); |
- |
- /* Y */ |
- for (line=0; line<Coded_Picture_Height; line++) |
- { |
- //fread(frame[0]+(line*Coded_Picture_Width),1,Coded_Picture_Width,fd); |
- } |
- |
- /* Cb */ |
- for (line=0; line<Chroma_Height; line++) |
- { |
- //fread(frame[1]+(line*Chroma_Width),1,Chroma_Width,fd); |
- } |
- |
- /* Cr */ |
- for (line=0; line<Chroma_Height; line++) |
- { |
- //fread(frame[2]+(line*Chroma_Width),1,Chroma_Width,fd); |
- } |
- |
- |
- //fclose(fd); |
- return(0); |
-} |
- |
- |
-static void Copy_Frame(src, dst, width, height, parity, field_mode) |
-unsigned char *src; |
-unsigned char *dst; |
-int width; |
-int height; |
-int parity; /* field parity (top or bottom) to overwrite */ |
-int field_mode; /* 0 = frame, 1 = field */ |
-{ |
- int row, col; |
- int s, d; |
- int incr; |
- |
- s = d = 0; |
- |
-#ifdef DEBUG |
- cprintf("COPYING (w=%d, h=%d, parity=%d, field_mode=%d)\n", |
- width,height,parity,field_mode); |
-#endif /* DEBUG */ |
- |
- if(field_mode) |
- { |
- incr = 2; |
- |
- if(parity==0) |
- s += width; |
- } |
- else |
- { |
- incr = 1; |
- } |
- |
- for(row=0; row<height; row+=incr) |
- { |
- for(col=0; col<width; col++) |
- { |
- dst[d+col] = src[s+col]; |
- } |
- |
- d += (width*incr); |
- s += (width*incr); |
- } |
- |
-} |
- |
Index: tags/rel_1_22/fsf/mpeg2/getblk.c |
=================================================================== |
--- tags/rel_1_22/fsf/mpeg2/getblk.c (revision 1310) |
+++ tags/rel_1_22/fsf/mpeg2/getblk.c (nonexistent) |
@@ -1,571 +0,0 @@ |
-/* getblk.c, DCT block decoding */ |
- |
-/* Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved. */ |
- |
-/* |
- * Disclaimer of Warranty |
- * |
- * These software programs are available to the user without any license fee or |
- * royalty on an "as is" basis. The MPEG Software Simulation Group disclaims |
- * any and all warranties, whether express, implied, or statuary, including any |
- * implied warranties or merchantability or of fitness for a particular |
- * purpose. In no event shall the copyright-holder be liable for any |
- * incidental, punitive, or consequential damages of any kind whatsoever |
- * arising from the use of these programs. |
- * |
- * This disclaimer of warranty extends to the user of these programs and user's |
- * customers, employees, agents, transferees, successors, and assigns. |
- * |
- * The MPEG Software Simulation Group does not represent or warrant that the |
- * programs furnished hereunder are free of infringement of any third-party |
- * patents. |
- * |
- * Commercial implementations of MPEG-1 and MPEG-2 video, including shareware, |
- * are subject to royalty fees to patent holders. Many of these patents are |
- * general enough such that they are unavoidable regardless of implementation |
- * design. |
- * |
- */ |
- |
-#include "config.h" |
-#include "global.h" |
- |
- |
-/* defined in getvlc.h */ |
-typedef struct { |
- char run, level, len; |
-} DCTtab; |
- |
-extern DCTtab DCTtabfirst[],DCTtabnext[],DCTtab0[],DCTtab1[]; |
-extern DCTtab DCTtab2[],DCTtab3[],DCTtab4[],DCTtab5[],DCTtab6[]; |
-extern DCTtab DCTtab0a[],DCTtab1a[]; |
- |
- |
-/* decode one intra coded MPEG-1 block */ |
- |
-void Decode_MPEG1_Intra_Block(comp,dc_dct_pred) |
-int comp; |
-int dc_dct_pred[]; |
-{ |
- int val, i, j, sign; |
- unsigned int code; |
- DCTtab *tab; |
- short *bp; |
- |
- bp = ld->block[comp]; |
- |
- /* ISO/IEC 11172-2 section 2.4.3.7: Block layer. */ |
- /* decode DC coefficients */ |
- if (comp<4) |
- bp[0] = (dc_dct_pred[0]+=Get_Luma_DC_dct_diff()) << 3; |
- else if (comp==4) |
- bp[0] = (dc_dct_pred[1]+=Get_Chroma_DC_dct_diff()) << 3; |
- else |
- bp[0] = (dc_dct_pred[2]+=Get_Chroma_DC_dct_diff()) << 3; |
- |
- if (Fault_Flag) return; |
- |
- /* D-pictures do not contain AC coefficients */ |
- if(picture_coding_type == D_TYPE) |
- return; |
- |
- /* decode AC coefficients */ |
- for (i=1; ; i++) |
- { |
- code = Show_Bits(16); |
- if (code>=16384) |
- tab = &DCTtabnext[(code>>12)-4]; |
- else if (code>=1024) |
- tab = &DCTtab0[(code>>8)-4]; |
- else if (code>=512) |
- tab = &DCTtab1[(code>>6)-8]; |
- else if (code>=256) |
- tab = &DCTtab2[(code>>4)-16]; |
- else if (code>=128) |
- tab = &DCTtab3[(code>>3)-16]; |
- else if (code>=64) |
- tab = &DCTtab4[(code>>2)-16]; |
- else if (code>=32) |
- tab = &DCTtab5[(code>>1)-16]; |
- else if (code>=16) |
- tab = &DCTtab6[code-16]; |
- else |
- { |
- if (!Quiet_Flag) |
- cprintf("invalid Huffman code in Decode_MPEG1_Intra_Block()\n"); |
- Fault_Flag = 1; |
- return; |
- } |
- |
- Flush_Buffer(tab->len); |
- |
- if (tab->run==64) /* end_of_block */ |
- return; |
- |
- if (tab->run==65) /* escape */ |
- { |
- i+= Get_Bits(6); |
- |
- val = Get_Bits(8); |
- if (val==0) |
- val = Get_Bits(8); |
- else if (val==128) |
- val = Get_Bits(8) - 256; |
- else if (val>128) |
- val -= 256; |
- |
- if((sign = (val<0))) |
- val = -val; |
- } |
- else |
- { |
- i+= tab->run; |
- val = tab->level; |
- sign = Get_Bits(1); |
- } |
- |
- if (i>=64) |
- { |
- if (!Quiet_Flag) |
- cprintf("DCT coeff index (i) out of bounds (intra)\n"); |
- Fault_Flag = 1; |
- return; |
- } |
- |
- j = scan[ZIG_ZAG][i]; |
- val = (val*ld->quantizer_scale*ld->intra_quantizer_matrix[j]) >> 3; |
- |
- /* mismatch control ('oddification') */ |
- if (val!=0) /* should always be true, but it's not guaranteed */ |
- val = (val-1) | 1; /* equivalent to: if ((val&1)==0) val = val - 1; */ |
- |
- /* saturation */ |
- if (!sign) |
- bp[j] = (val>2047) ? 2047 : val; /* positive */ |
- else |
- bp[j] = (val>2048) ? -2048 : -val; /* negative */ |
- } |
-} |
- |
- |
-/* decode one non-intra coded MPEG-1 block */ |
- |
-void Decode_MPEG1_Non_Intra_Block(comp) |
-int comp; |
-{ |
- int val, i, j, sign; |
- unsigned int code; |
- DCTtab *tab; |
- short *bp; |
- |
- bp = ld->block[comp]; |
- |
- /* decode AC coefficients */ |
- for (i=0; ; i++) |
- { |
- code = Show_Bits(16); |
- if (code>=16384) |
- { |
- if (i==0) |
- tab = &DCTtabfirst[(code>>12)-4]; |
- else |
- tab = &DCTtabnext[(code>>12)-4]; |
- } |
- else if (code>=1024) |
- tab = &DCTtab0[(code>>8)-4]; |
- else if (code>=512) |
- tab = &DCTtab1[(code>>6)-8]; |
- else if (code>=256) |
- tab = &DCTtab2[(code>>4)-16]; |
- else if (code>=128) |
- tab = &DCTtab3[(code>>3)-16]; |
- else if (code>=64) |
- tab = &DCTtab4[(code>>2)-16]; |
- else if (code>=32) |
- tab = &DCTtab5[(code>>1)-16]; |
- else if (code>=16) |
- tab = &DCTtab6[code-16]; |
- else |
- { |
- if (!Quiet_Flag) |
- cprintf("invalid Huffman code in Decode_MPEG1_Non_Intra_Block()\n"); |
- Fault_Flag = 1; |
- return; |
- } |
- |
- Flush_Buffer(tab->len); |
- |
- if (tab->run==64) /* end_of_block */ |
- return; |
- |
- if (tab->run==65) /* escape */ |
- { |
- i+= Get_Bits(6); |
- |
- val = Get_Bits(8); |
- if (val==0) |
- val = Get_Bits(8); |
- else if (val==128) |
- val = Get_Bits(8) - 256; |
- else if (val>128) |
- val -= 256; |
- |
- if((sign = (val<0))) |
- val = -val; |
- } |
- else |
- { |
- i+= tab->run; |
- val = tab->level; |
- sign = Get_Bits(1); |
- } |
- |
- if (i>=64) |
- { |
- if (!Quiet_Flag) |
- cprintf("DCT coeff index (i) out of bounds (inter)\n"); |
- Fault_Flag = 1; |
- return; |
- } |
- |
- j = scan[ZIG_ZAG][i]; |
- val = (((val<<1)+1)*ld->quantizer_scale*ld->non_intra_quantizer_matrix[j]) >> 4; |
- |
- /* mismatch control ('oddification') */ |
- if (val!=0) /* should always be true, but it's not guaranteed */ |
- val = (val-1) | 1; /* equivalent to: if ((val&1)==0) val = val - 1; */ |
- |
- /* saturation */ |
- if (!sign) |
- bp[j] = (val>2047) ? 2047 : val; /* positive */ |
- else |
- bp[j] = (val>2048) ? -2048 : -val; /* negative */ |
- } |
-} |
- |
- |
-/* decode one intra coded MPEG-2 block */ |
- |
-void Decode_MPEG2_Intra_Block(comp,dc_dct_pred) |
-int comp; |
-int dc_dct_pred[]; |
-{ |
- int val, i, j, sign, nc, cc, run; |
- unsigned int code; |
- DCTtab *tab; |
- short *bp; |
- int *qmat; |
- struct layer_data *ld1; |
- |
- /* with data partitioning, data always goes to base layer */ |
- ld1 = (ld->scalable_mode==SC_DP) ? &base : ld; |
- bp = ld1->block[comp]; |
- |
- if (base.scalable_mode==SC_DP) { |
- if (base.priority_breakpoint<64) |
- ld = &enhan; |
- else |
- ld = &base; |
- } |
- |
- cc = (comp<4) ? 0 : (comp&1)+1; |
- |
- qmat = (comp<4 || chroma_format==CHROMA420) |
- ? ld1->intra_quantizer_matrix |
- : ld1->chroma_intra_quantizer_matrix; |
- |
- /* ISO/IEC 13818-2 section 7.2.1: decode DC coefficients */ |
- if (cc==0) |
- val = (dc_dct_pred[0]+= Get_Luma_DC_dct_diff()); |
- else if (cc==1) |
- val = (dc_dct_pred[1]+= Get_Chroma_DC_dct_diff()); |
- else |
- val = (dc_dct_pred[2]+= Get_Chroma_DC_dct_diff()); |
- |
- if (Fault_Flag) return; |
- |
- bp[0] = val << (3-intra_dc_precision); |
- |
- nc=0; |
- |
-#ifdef TRACE |
- if (Trace_Flag) |
- cprintf("DCT(%d)i:",comp); |
-#endif /* TRACE */ |
- |
- /* decode AC coefficients */ |
- for (i=1; ; i++) |
- { |
- code = Show_Bits(16); |
- if (code>=16384 && !intra_vlc_format) |
- tab = &DCTtabnext[(code>>12)-4]; |
- else if (code>=1024) |
- { |
- if (intra_vlc_format) |
- tab = &DCTtab0a[(code>>8)-4]; |
- else |
- tab = &DCTtab0[(code>>8)-4]; |
- } |
- else if (code>=512) |
- { |
- if (intra_vlc_format) |
- tab = &DCTtab1a[(code>>6)-8]; |
- else |
- tab = &DCTtab1[(code>>6)-8]; |
- } |
- else if (code>=256) |
- tab = &DCTtab2[(code>>4)-16]; |
- else if (code>=128) |
- tab = &DCTtab3[(code>>3)-16]; |
- else if (code>=64) |
- tab = &DCTtab4[(code>>2)-16]; |
- else if (code>=32) |
- tab = &DCTtab5[(code>>1)-16]; |
- else if (code>=16) |
- tab = &DCTtab6[code-16]; |
- else |
- { |
- if (!Quiet_Flag) |
- cprintf("invalid Huffman code in Decode_MPEG2_Intra_Block()\n"); |
- Fault_Flag = 1; |
- return; |
- } |
- |
- Flush_Buffer(tab->len); |
- |
-#ifdef TRACE |
- if (Trace_Flag) |
- { |
- printf(" ("); |
- Print_Bits(code,16,tab->len); |
- } |
-#endif /* TRACE */ |
- |
- if (tab->run==64) /* end_of_block */ |
- { |
-#ifdef TRACE |
- if (Trace_Flag) |
- printf("): EOB\n"); |
-#endif /* TRACE */ |
- return; |
- } |
- |
- if (tab->run==65) /* escape */ |
- { |
-#ifdef TRACE |
- if (Trace_Flag) |
- { |
- putchar(' '); |
- Print_Bits(Show_Bits(6),6,6); |
- } |
-#endif /* TRACE */ |
- |
- i+= run = Get_Bits(6); |
- |
-#ifdef TRACE |
- if (Trace_Flag) |
- { |
- putchar(' '); |
- Print_Bits(Show_Bits(12),12,12); |
- } |
-#endif /* TRACE */ |
- |
- val = Get_Bits(12); |
- if ((val&2047)==0) |
- { |
- if (!Quiet_Flag) |
- cprintf("invalid escape in Decode_MPEG2_Intra_Block()\n"); |
- Fault_Flag = 1; |
- return; |
- } |
- if((sign = (val>=2048))) |
- val = 4096 - val; |
- } |
- else |
- { |
- i+= run = tab->run; |
- val = tab->level; |
- sign = Get_Bits(1); |
- |
-#ifdef TRACE |
- if (Trace_Flag) |
- cprintf("%d",sign); |
-#endif /* TRACE */ |
- } |
- |
- if (i>=64) |
- { |
- if (!Quiet_Flag) |
- cprintf("DCT coeff index (i) out of bounds (intra2)\n"); |
- Fault_Flag = 1; |
- return; |
- } |
- |
-#ifdef TRACE |
- if (Trace_Flag) |
- cprintf("): %d/%d",run,sign ? -val : val); |
-#endif /* TRACE */ |
- |
- j = scan[ld1->alternate_scan][i]; |
- val = (val * ld1->quantizer_scale * qmat[j]) >> 4; |
- bp[j] = sign ? -val : val; |
- nc++; |
- |
- if (base.scalable_mode==SC_DP && nc==base.priority_breakpoint-63) |
- ld = &enhan; |
- } |
-} |
- |
- |
-/* decode one non-intra coded MPEG-2 block */ |
- |
-void Decode_MPEG2_Non_Intra_Block(comp) |
-int comp; |
-{ |
- int val, i, j, sign, nc, run; |
- unsigned int code; |
- DCTtab *tab; |
- short *bp; |
- int *qmat; |
- struct layer_data *ld1; |
- |
- /* with data partitioning, data always goes to base layer */ |
- ld1 = (ld->scalable_mode==SC_DP) ? &base : ld; |
- bp = ld1->block[comp]; |
- |
- if (base.scalable_mode==SC_DP) { |
- if (base.priority_breakpoint<64) |
- ld = &enhan; |
- else |
- ld = &base; |
- } |
- |
- qmat = (comp<4 || chroma_format==CHROMA420) |
- ? ld1->non_intra_quantizer_matrix |
- : ld1->chroma_non_intra_quantizer_matrix; |
- |
- nc = 0; |
- |
-#ifdef TRACE |
- if (Trace_Flag) |
- cprintf("DCT(%d)n:",comp); |
-#endif /* TRACE */ |
- |
- /* decode AC coefficients */ |
- for (i=0; ; i++) |
- { |
- code = Show_Bits(16); |
- if (code>=16384) |
- { |
- if (i==0) |
- tab = &DCTtabfirst[(code>>12)-4]; |
- else |
- tab = &DCTtabnext[(code>>12)-4]; |
- } |
- else if (code>=1024) |
- tab = &DCTtab0[(code>>8)-4]; |
- else if (code>=512) |
- tab = &DCTtab1[(code>>6)-8]; |
- else if (code>=256) |
- tab = &DCTtab2[(code>>4)-16]; |
- else if (code>=128) |
- tab = &DCTtab3[(code>>3)-16]; |
- else if (code>=64) |
- tab = &DCTtab4[(code>>2)-16]; |
- else if (code>=32) |
- tab = &DCTtab5[(code>>1)-16]; |
- else if (code>=16) |
- tab = &DCTtab6[code-16]; |
- else |
- { |
- if (!Quiet_Flag) |
- cprintf("invalid Huffman code in Decode_MPEG2_Non_Intra_Block()\n"); |
- Fault_Flag = 1; |
- return; |
- } |
- |
- Flush_Buffer(tab->len); |
- |
-#ifdef TRACE |
- if (Trace_Flag) |
- { |
- cprintf(" ("); |
- Print_Bits(code,16,tab->len); |
- } |
-#endif /* TRACE */ |
- |
- if (tab->run==64) /* end_of_block */ |
- { |
-#ifdef TRACE |
- if (Trace_Flag) |
- cprintf("): EOB\n"); |
-#endif /* TRACE */ |
- return; |
- } |
- |
- if (tab->run==65) /* escape */ |
- { |
-#ifdef TRACE |
- if (Trace_Flag) |
- { |
- cprintf(" "); |
- Print_Bits(Show_Bits(6),6,6); |
- } |
-#endif /* TRACE */ |
- |
- i+= run = Get_Bits(6); |
- |
-#ifdef TRACE |
- if (Trace_Flag) |
- { |
- cprintf(" "); |
- Print_Bits(Show_Bits(12),12,12); |
- } |
-#endif /* TRACE */ |
- |
- val = Get_Bits(12); |
- if ((val&2047)==0) |
- { |
- if (!Quiet_Flag) |
- cprintf("invalid escape in Decode_MPEG2_Intra_Block()\n"); |
- Fault_Flag = 1; |
- return; |
- } |
- if((sign = (val>=2048))) |
- val = 4096 - val; |
- } |
- else |
- { |
- i+= run = tab->run; |
- val = tab->level; |
- sign = Get_Bits(1); |
- |
-#ifdef TRACE |
- if (Trace_Flag) |
- cprintf("%d",sign); |
-#endif /* TRACE */ |
- } |
- |
- if (i>=64) |
- { |
- if (!Quiet_Flag) |
- cprintf("DCT coeff index (i) out of bounds (inter2)\n"); |
- Fault_Flag = 1; |
- return; |
- } |
- |
-#ifdef TRACE |
- if (Trace_Flag) |
- cprintf("): %d/%d",run,sign?-val:val); |
-#endif /* TRACE */ |
- |
- j = scan[ld1->alternate_scan][i]; |
- val = (((val<<1)+1) * ld1->quantizer_scale * qmat[j]) >> 5; |
- bp[j] = sign ? -val : val; |
- nc++; |
- |
- if (base.scalable_mode==SC_DP && nc==base.priority_breakpoint-63) |
- ld = &enhan; |
- } |
-} |
- |
Index: tags/rel_1_22/fsf/mpeg2/spatscal.c |
=================================================================== |
--- tags/rel_1_22/fsf/mpeg2/spatscal.c (revision 1310) |
+++ tags/rel_1_22/fsf/mpeg2/spatscal.c (nonexistent) |
@@ -1,275 +0,0 @@ |
- |
-#include "config.h" |
-#include "global.h" |
- |
-/* private prototypes */ |
-static void Read_Lower_Layer_Component_Framewise _ANSI_ARGS_((int comp, int lw, int lh)); |
-static void Read_Lower_Layer_Component_Fieldwise _ANSI_ARGS_((int comp, int lw, int lh)); |
-static void Make_Spatial_Prediction_Frame _ANSI_ARGS_((int progressive_frame, |
- int llprogressive_frame, unsigned char *fld0, unsigned char *fld1, |
- short *tmp, unsigned char *dst, int llx0, int lly0, int llw, int llh, |
- int horizontal_size, int vertical_size, int vm, int vn, int hm, int hn, |
- int aperture)); |
-static void Deinterlace _ANSI_ARGS_((unsigned char *fld0, unsigned char *fld1, |
- int j0, int lx, int ly, int aperture)); |
-static void Subsample_Vertical _ANSI_ARGS_((unsigned char *s, short *d, |
- int lx, int lys, int lyd, int m, int n, int j0, int dj)); |
-static void Subsample_Horizontal _ANSI_ARGS_((short *s, unsigned char *d, |
- int x0, int lx, int lxs, int lxd, int ly, int m, int n)); |
- |
- |
- |
-/* get reference frame */ |
-void Spatial_Prediction() |
-{ |
- |
- if(Frame_Store_Flag) |
- { |
- Read_Lower_Layer_Component_Framewise(0,lower_layer_prediction_horizontal_size, |
- lower_layer_prediction_vertical_size); /* Y */ |
- Read_Lower_Layer_Component_Framewise(1,lower_layer_prediction_horizontal_size>>1, |
- lower_layer_prediction_vertical_size>>1); /* Cb ("U") */ |
- Read_Lower_Layer_Component_Framewise(2,lower_layer_prediction_horizontal_size>>1, |
- lower_layer_prediction_vertical_size>>1); /* Cr ("V") */ |
- } |
- else |
- { |
- Read_Lower_Layer_Component_Fieldwise(0,lower_layer_prediction_horizontal_size, |
- lower_layer_prediction_vertical_size); /* Y */ |
- Read_Lower_Layer_Component_Fieldwise(1,lower_layer_prediction_horizontal_size>>1, |
- lower_layer_prediction_vertical_size>>1); /* Cb ("U") */ |
- Read_Lower_Layer_Component_Fieldwise(2,lower_layer_prediction_horizontal_size>>1, |
- lower_layer_prediction_vertical_size>>1); /* Cr ("V") */ |
- } |
- |
- |
- Make_Spatial_Prediction_Frame /* Y */ |
- (progressive_frame,lower_layer_progressive_frame,llframe0[0],llframe1[0], |
- lltmp,current_frame[0],lower_layer_horizontal_offset, |
- lower_layer_vertical_offset, |
- lower_layer_prediction_horizontal_size, |
- lower_layer_prediction_vertical_size, |
- horizontal_size,vertical_size,vertical_subsampling_factor_m, |
- vertical_subsampling_factor_n,horizontal_subsampling_factor_m, |
- horizontal_subsampling_factor_n, |
- picture_structure!=FRAME_PICTURE); /* this changed from CD to DIS */ |
- |
- Make_Spatial_Prediction_Frame /* Cb */ |
- (progressive_frame,lower_layer_progressive_frame,llframe0[1],llframe1[1], |
- lltmp,current_frame[1],lower_layer_horizontal_offset/2, |
- lower_layer_vertical_offset/2, |
- lower_layer_prediction_horizontal_size>>1, |
- lower_layer_prediction_vertical_size>>1, |
- horizontal_size>>1,vertical_size>>1,vertical_subsampling_factor_m, |
- vertical_subsampling_factor_n,horizontal_subsampling_factor_m, |
- horizontal_subsampling_factor_n,1); |
- |
- Make_Spatial_Prediction_Frame /* Cr */ |
- (progressive_frame,lower_layer_progressive_frame,llframe0[2],llframe1[2], |
- lltmp,current_frame[2],lower_layer_horizontal_offset/2, |
- lower_layer_vertical_offset/2, |
- lower_layer_prediction_horizontal_size>>1, |
- lower_layer_prediction_vertical_size>>1, |
- horizontal_size>>1,vertical_size>>1,vertical_subsampling_factor_m, |
- vertical_subsampling_factor_n,horizontal_subsampling_factor_m, |
- horizontal_subsampling_factor_n,1); |
- |
-} |
- |
-static void Read_Lower_Layer_Component_Framewise(comp,lw,lh) |
- int comp; |
- int lw, lh; |
-{ |
- cprintf("Read_Lower_Layer_Component_Framewise\n"); |
-} |
- |
- |
-static void Read_Lower_Layer_Component_Fieldwise(comp,lw,lh) |
- int comp; |
- int lw, lh; |
-{ |
- cprintf("Read_Lower_Layer_Component_Fieldwise\n"); |
-} |
- |
- |
-/* form spatial prediction */ |
-static void Make_Spatial_Prediction_Frame(progressive_frame, |
- llprogressive_frame,fld0,fld1,tmp,dst,llx0,lly0,llw,llh,horizontal_size, |
- vertical_size,vm,vn,hm,hn,aperture) |
-int progressive_frame,llprogressive_frame; |
-unsigned char *fld0,*fld1; |
-short *tmp; |
-unsigned char *dst; |
-int llx0,lly0,llw,llh,horizontal_size,vertical_size,vm,vn,hm,hn,aperture; |
-{ |
- int w, h, x0, llw2, llh2; |
- |
- llw2 = (llw*hn)/hm; |
- llh2 = (llh*vn)/vm; |
- |
- if (llprogressive_frame) |
- { |
- /* progressive -> progressive / interlaced */ |
- Subsample_Vertical(fld0,tmp,llw,llh,llh2,vm,vn,0,1); |
- } |
- else if (progressive_frame) |
- { |
- /* interlaced -> progressive */ |
- if (lower_layer_deinterlaced_field_select) |
- { |
- Deinterlace(fld1,fld0,0,llw,llh,aperture); |
- Subsample_Vertical(fld1,tmp,llw,llh,llh2,vm,vn,0,1); |
- } |
- else |
- { |
- Deinterlace(fld0,fld1,1,llw,llh,aperture); |
- Subsample_Vertical(fld0,tmp,llw,llh,llh2,vm,vn,0,1); |
- } |
- } |
- else |
- { |
- /* interlaced -> interlaced */ |
- Deinterlace(fld0,fld1,1,llw,llh,aperture); |
- Deinterlace(fld1,fld0,0,llw,llh,aperture); |
- Subsample_Vertical(fld0,tmp,llw,llh,llh2,vm,vn,0,2); |
- Subsample_Vertical(fld1,tmp,llw,llh,llh2,vm,vn,1,2); |
- } |
- |
- /* vertical limits */ |
- if (lly0<0) |
- { |
- tmp-= llw*lly0; |
- llh2+= lly0; |
- if (llh2<0) |
- llh2 = 0; |
- h = (vertical_size<llh2) ? vertical_size : llh2; |
- } |
- else |
- { |
- dst+= horizontal_size*lly0; |
- h= vertical_size - lly0; |
- if (h>llh2) |
- h = llh2; |
- } |
- |
- /* horizontal limits */ |
- if (llx0<0) |
- { |
- x0 = -llx0; |
- llw2+= llx0; |
- if (llw2<0) |
- llw2 = 0; |
- w = (horizontal_size<llw2) ? horizontal_size : llw2; |
- } |
- else |
- { |
- dst+= llx0; |
- x0 = 0; |
- w = horizontal_size - llx0; |
- if (w>llw2) |
- w = llw2; |
- } |
- |
- Subsample_Horizontal(tmp,dst,x0,w,llw,horizontal_size,h,hm,hn); |
-} |
- |
-/* deinterlace one field (interpolate opposite parity samples) |
- * |
- * deinterlacing is done in-place: if j0=1, fld0 contains the input field in |
- * its even lines and the odd lines are interpolated by this routine |
- * if j0=0, the input field is in the odd lines and the even lines are |
- * interpolated |
- * |
- * fld0: field to be deinterlaced |
- * fld1: other field (referenced by the two field aperture filter) |
- * j0: 0: interpolate even (top) lines, 1: interpolate odd (bottom) lines |
- * lx: width of fld0 and fld1 |
- * ly: height of the deinterlaced field (has to be even) |
- * aperture: 1: use one field aperture filter (two field otherwise) |
- */ |
-static void Deinterlace(fld0,fld1,j0,lx,ly,aperture) |
-unsigned char *fld0,*fld1; |
-int j0,lx,ly; /* ly has to be even */ |
-int aperture; |
-{ |
- int i,j,v; |
- unsigned char *p0, *p0m1, *p0p1, *p1, *p1m2, *p1p2; |
- |
- /* deinterlace one field */ |
- for (j=j0; j<ly; j+=2) |
- { |
- p0 = fld0+lx*j; |
- p0m1 = (j==0) ? p0+lx : p0-lx; |
- p0p1 = (j==ly-1) ? p0-lx : p0+lx; |
- |
- if (aperture) |
- for (i=0; i<lx; i++) |
- p0[i] = (unsigned int)(p0m1[i] + p0p1[i] + 1)>>1; |
- else |
- { |
- p1 = fld1 + lx*j; |
- p1m2 = (j<2) ? p1 : p1-2*lx; |
- p1p2 = (j>=ly-2) ? p1 : p1+2*lx; |
- for (i=0; i<lx; i++) |
- { |
- v = 8*(p0m1[i]+p0p1[i]) + 2*p1[i] - p1m2[i] - p1p2[i]; |
- p0[i] = Clip[(v + ((v>=0) ? 8 : 7))>>4]; |
- } |
- } |
- } |
-} |
- |
-/* vertical resampling */ |
-static void Subsample_Vertical(s,d,lx,lys,lyd,m,n,j0,dj) |
-unsigned char *s; |
-short *d; |
-int lx, lys, lyd, m, n, j0, dj; |
-{ |
- int i, j, c1, c2, jd; |
- unsigned char *s1, *s2; |
- short *d1; |
- |
- for (j=j0; j<lyd; j+=dj) |
- { |
- d1 = d + lx*j; |
- jd = (j*m)/n; |
- s1 = s + lx*jd; |
- s2 = (jd<lys-1)? s1+lx : s1; |
- c2 = (16*((j*m)%n) + (n>>1))/n; |
- c1 = 16 - c2; |
- for (i=0; i<lx; i++) |
- d1[i] = c1*s1[i] + c2*s2[i]; |
- } |
-} |
- |
-/* horizontal resampling */ |
-static void Subsample_Horizontal(s,d,x0,lx,lxs,lxd,ly,m,n) |
-short *s; |
-unsigned char *d; |
-int x0, lx, lxs, lxd, ly, m, n; |
-{ |
- int i, i1, j, id, c1, c2, v; |
- short *s1, *s2; |
- unsigned char *d1; |
- |
- for (i1=0; i1<lx; i1++) |
- { |
- d1 = d + i1; |
- i = x0 + i1; |
- id = (i*m)/n; |
- s1 = s+id; |
- s2 = (id<lxs-1) ? s1+1 : s1; |
- c2 = (16*((i*m)%n) + (n>>1))/n; |
- c1 = 16 - c2; |
- for (j=0; j<ly; j++) |
- { |
- v = c1*(*s1) + c2*(*s2); |
- *d1 = (v + ((v>=0) ? 128 : 127))>>8; |
- d1+= lxd; |
- s1+= lxs; |
- s2+= lxs; |
- } |
- } |
-} |
- |
- |
Index: tags/rel_1_22/fsf/mpeg2/config.h |
=================================================================== |
--- tags/rel_1_22/fsf/mpeg2/config.h (revision 1310) |
+++ tags/rel_1_22/fsf/mpeg2/config.h (nonexistent) |
@@ -1,45 +0,0 @@ |
-/* config.h, configuration defines */ |
- |
-/* Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved. */ |
- |
-/* |
- * Disclaimer of Warranty |
- * |
- * These software programs are available to the user without any license fee or |
- * royalty on an "as is" basis. The MPEG Software Simulation Group disclaims |
- * any and all warranties, whether express, implied, or statuary, including any |
- * implied warranties or merchantability or of fitness for a particular |
- * purpose. In no event shall the copyright-holder be liable for any |
- * incidental, punitive, or consequential damages of any kind whatsoever |
- * arising from the use of these programs. |
- * |
- * This disclaimer of warranty extends to the user of these programs and user's |
- * customers, employees, agents, transferees, successors, and assigns. |
- * |
- * The MPEG Software Simulation Group does not represent or warrant that the |
- * programs furnished hereunder are free of infringement of any third-party |
- * patents. |
- * |
- * Commercial implementations of MPEG-1 and MPEG-2 video, including shareware, |
- * are subject to royalty fees to patent holders. Many of these patents are |
- * general enough such that they are unavoidable regardless of implementation |
- * design. |
- * |
- */ |
- |
-/* define NON_ANSI_COMPILER for compilers without function prototyping */ |
-/* #define NON_ANSI_COMPILER */ |
- |
-#ifdef NON_ANSI_COMPILER |
-#define _ANSI_ARGS_(x) () |
-#else |
-#define _ANSI_ARGS_(x) x |
-#endif |
- |
-#define RB "rb" |
-#define WB "wb" |
- |
-#ifndef O_BINARY |
-#define O_BINARY 0 |
- |
-#endif |
Index: tags/rel_1_22/fsf/mpeg2/getpic.c |
=================================================================== |
--- tags/rel_1_22/fsf/mpeg2/getpic.c (revision 1310) |
+++ tags/rel_1_22/fsf/mpeg2/getpic.c (nonexistent) |
@@ -1,1223 +0,0 @@ |
-/* getpic.c, picture decoding */ |
- |
-/* Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved. */ |
- |
-/* |
- * Disclaimer of Warranty |
- * |
- * These software programs are available to the user without any license fee or |
- * royalty on an "as is" basis. The MPEG Software Simulation Group disclaims |
- * any and all warranties, whether express, implied, or statuary, including any |
- * implied warranties or merchantability or of fitness for a particular |
- * purpose. In no event shall the copyright-holder be liable for any |
- * incidental, punitive, or consequential damages of any kind whatsoever |
- * arising from the use of these programs. |
- * |
- * This disclaimer of warranty extends to the user of these programs and user's |
- * customers, employees, agents, transferees, successors, and assigns. |
- * |
- * The MPEG Software Simulation Group does not represent or warrant that the |
- * programs furnished hereunder are free of infringement of any third-party |
- * patents. |
- * |
- * Commercial implementations of MPEG-1 and MPEG-2 video, including shareware, |
- * are subject to royalty fees to patent holders. Many of these patents are |
- * general enough such that they are unavoidable regardless of implementation |
- * design. |
- * |
- */ |
- |
-#include "config.h" |
-#include "global.h" |
- |
-/* private prototypes*/ |
-static void picture_data _ANSI_ARGS_((int framenum)); |
-static void macroblock_modes _ANSI_ARGS_((int *pmacroblock_type, int *pstwtype, |
- int *pstwclass, int *pmotion_type, int *pmotion_vector_count, int *pmv_format, int *pdmv, |
- int *pmvscale, int *pdct_type)); |
-static void Clear_Block _ANSI_ARGS_((int comp)); |
-static void Sum_Block _ANSI_ARGS_((int comp)); |
-static void Saturate _ANSI_ARGS_((short *bp)); |
-static void Add_Block _ANSI_ARGS_((int comp, int bx, int by, |
- int dct_type, int addflag)); |
-static void Update_Picture_Buffers _ANSI_ARGS_((void)); |
-static void frame_reorder _ANSI_ARGS_((int bitstream_framenum, |
- int sequence_framenum)); |
-static void Decode_SNR_Macroblock _ANSI_ARGS_((int *SNRMBA, int *SNRMBAinc, |
- int MBA, int MBAmax, int *dct_type)); |
- |
-static void motion_compensation _ANSI_ARGS_((int MBA, int macroblock_type, |
- int motion_type, int PMV[2][2][2], int motion_vertical_field_select[2][2], |
- int dmvector[2], int stwtype, int dct_type)); |
- |
-static void skipped_macroblock _ANSI_ARGS_((int dc_dct_pred[3], |
- int PMV[2][2][2], int *motion_type, int motion_vertical_field_select[2][2], |
- int *stwtype, int *macroblock_type)); |
- |
-static int slice _ANSI_ARGS_((int framenum, int MBAmax)); |
- |
-static int start_of_slice _ANSI_ARGS_ ((int MBAmax, int *MBA, |
- int *MBAinc, int dc_dct_pred[3], int PMV[2][2][2])); |
- |
-static int decode_macroblock _ANSI_ARGS_((int *macroblock_type, |
- int *stwtype, int *stwclass, int *motion_type, int *dct_type, |
- int PMV[2][2][2], int dc_dct_pred[3], |
- int motion_vertical_field_select[2][2], int dmvector[2])); |
- |
- |
-/* decode one frame or field picture */ |
-void Decode_Picture(bitstream_framenum, sequence_framenum) |
-int bitstream_framenum, sequence_framenum; |
-{ |
- |
- if (picture_structure==FRAME_PICTURE && Second_Field) |
- { |
- /* recover from illegal number of field pictures */ |
- cprintf("odd number of field pictures\n"); |
- Second_Field = 0; |
- } |
- |
- /* IMPLEMENTATION: update picture buffer pointers */ |
- Update_Picture_Buffers(); |
- |
-#ifdef VERIFY |
- Check_Headers(bitstream_framenum, sequence_framenum); |
-#endif /* VERIFY */ |
- |
- /* ISO/IEC 13818-4 section 2.4.5.4 "frame buffer intercept method" */ |
- /* (section number based on November 1995 (Dallas) draft of the |
- conformance document) */ |
- if(Ersatz_Flag) |
- Substitute_Frame_Buffer(bitstream_framenum, sequence_framenum); |
- |
- /* form spatial scalable picture */ |
- |
- /* form spatial scalable picture */ |
- /* ISO/IEC 13818-2 section 7.7: Spatial scalability */ |
- if (base.pict_scal && !Second_Field) |
- { |
- Spatial_Prediction(); |
- } |
- |
- /* decode picture data ISO/IEC 13818-2 section 6.2.3.7 */ |
- picture_data(bitstream_framenum); |
- |
- /* write or display current or previously decoded reference frame */ |
- /* ISO/IEC 13818-2 section 6.1.1.11: Frame reordering */ |
- frame_reorder(bitstream_framenum, sequence_framenum); |
- |
- if (picture_structure!=FRAME_PICTURE) |
- Second_Field = !Second_Field; |
-} |
- |
- |
-/* decode all macroblocks of the current picture */ |
-/* stages described in ISO/IEC 13818-2 section 7 */ |
-static void picture_data(framenum) |
-int framenum; |
-{ |
- int MBAmax; |
- int ret; |
- |
- /* number of macroblocks per picture */ |
- MBAmax = mb_width*mb_height; |
- |
- if (picture_structure!=FRAME_PICTURE) |
- MBAmax>>=1; /* field picture has half as mnay macroblocks as frame */ |
- |
- for(;;) |
- { |
- if((ret=slice(framenum, MBAmax))<0) |
- return; |
- } |
- |
-} |
- |
- |
- |
-/* decode all macroblocks of the current picture */ |
-/* ISO/IEC 13818-2 section 6.3.16 */ |
-static int slice(framenum, MBAmax) |
-int framenum, MBAmax; |
-{ |
- int MBA; |
- int MBAinc, macroblock_type, motion_type, dct_type; |
- int dc_dct_pred[3]; |
- int PMV[2][2][2], motion_vertical_field_select[2][2]; |
- int dmvector[2]; |
- int stwtype, stwclass; |
- int SNRMBA, SNRMBAinc; |
- int ret; |
- |
- MBA = 0; /* macroblock address */ |
- MBAinc = 0; |
- |
- if((ret=start_of_slice(MBAmax, &MBA, &MBAinc, dc_dct_pred, PMV))!=1) |
- return(ret); |
- |
- if (Two_Streams && enhan.scalable_mode==SC_SNR) |
- { |
- SNRMBA=0; |
- SNRMBAinc=0; |
- } |
- |
- Fault_Flag=0; |
- |
- for (;;) |
- { |
- |
- /* this is how we properly exit out of picture */ |
- if (MBA>=MBAmax) |
- return(-1); /* all macroblocks decoded */ |
- |
-#ifdef TRACE |
- if (Trace_Flag) |
- cprintf("frame %d, MB %d\n",framenum,MBA); |
-#endif /* TRACE */ |
- |
-#ifdef DISPLAY |
- if (!progressive_frame && picture_structure==FRAME_PICTURE |
- && MBA==(MBAmax>>1) && framenum!=0 && Output_Type==T_X11 |
- && !Display_Progressive_Flag) |
- { |
- Display_Second_Field(); |
- } |
-#endif |
- |
- ld = &base; |
- |
- if (MBAinc==0) |
- { |
- if (base.scalable_mode==SC_DP && base.priority_breakpoint==1) |
- ld = &enhan; |
- |
- if (!Show_Bits(23) || Fault_Flag) /* next_start_code or fault */ |
- { |
-resync: /* if Fault_Flag: resynchronize to next next_start_code */ |
- Fault_Flag = 0; |
- return(0); /* trigger: go to next slice */ |
- } |
- else /* neither next_start_code nor Fault_Flag */ |
- { |
- if (base.scalable_mode==SC_DP && base.priority_breakpoint==1) |
- ld = &enhan; |
- |
- /* decode macroblock address increment */ |
- MBAinc = Get_macroblock_address_increment(); |
- |
- if (Fault_Flag) goto resync; |
- } |
- } |
- |
- if (MBA>=MBAmax) |
- { |
- /* MBAinc points beyond picture dimensions */ |
- if (!Quiet_Flag) |
- cprintf("Too many macroblocks in picture\n"); |
- return(-1); |
- } |
- |
- if (MBAinc==1) /* not skipped */ |
- { |
- ret = decode_macroblock(¯oblock_type, &stwtype, &stwclass, |
- &motion_type, &dct_type, PMV, dc_dct_pred, |
- motion_vertical_field_select, dmvector); |
- |
- if(ret==-1) |
- return(-1); |
- |
- if(ret==0) |
- goto resync; |
- |
- } |
- else /* MBAinc!=1: skipped macroblock */ |
- { |
- /* ISO/IEC 13818-2 section 7.6.6 */ |
- skipped_macroblock(dc_dct_pred, PMV, &motion_type, |
- motion_vertical_field_select, &stwtype, ¯oblock_type); |
- } |
- |
- /* SCALABILITY: SNR */ |
- /* ISO/IEC 13818-2 section 7.8 */ |
- /* NOTE: we currently ignore faults encountered in this routine */ |
- if (Two_Streams && enhan.scalable_mode==SC_SNR) |
- Decode_SNR_Macroblock(&SNRMBA, &SNRMBAinc, MBA, MBAmax, &dct_type); |
- |
- /* ISO/IEC 13818-2 section 7.6 */ |
- motion_compensation(MBA, macroblock_type, motion_type, PMV, |
- motion_vertical_field_select, dmvector, stwtype, dct_type); |
- |
- |
- /* advance to next macroblock */ |
- MBA++; |
- MBAinc--; |
- |
- /* SCALABILITY: SNR */ |
- if (Two_Streams && enhan.scalable_mode==SC_SNR) |
- { |
- SNRMBA++; |
- SNRMBAinc--; |
- } |
- |
- if (MBA>=MBAmax) |
- return(-1); /* all macroblocks decoded */ |
- } |
-} |
- |
- |
-/* ISO/IEC 13818-2 section 6.3.17.1: Macroblock modes */ |
-static void macroblock_modes(pmacroblock_type,pstwtype,pstwclass, |
- pmotion_type,pmotion_vector_count,pmv_format,pdmv,pmvscale,pdct_type) |
- int *pmacroblock_type, *pstwtype, *pstwclass; |
- int *pmotion_type, *pmotion_vector_count, *pmv_format, *pdmv, *pmvscale; |
- int *pdct_type; |
-{ |
- int macroblock_type; |
- int stwtype, stwcode, stwclass; |
- int motion_type = 0; |
- int motion_vector_count, mv_format, dmv, mvscale; |
- int dct_type; |
- static unsigned char stwc_table[3][4] |
- = { {6,3,7,4}, {2,1,5,4}, {2,5,7,4} }; |
- static unsigned char stwclass_table[9] |
- = {0, 1, 2, 1, 1, 2, 3, 3, 4}; |
- |
- /* get macroblock_type */ |
- macroblock_type = Get_macroblock_type(); |
- |
- if (Fault_Flag) return; |
- |
- /* get spatial_temporal_weight_code */ |
- if (macroblock_type & MB_WEIGHT) |
- { |
- if (spatial_temporal_weight_code_table_index==0) |
- stwtype = 4; |
- else |
- { |
- stwcode = Get_Bits(2); |
-#ifdef TRACE |
- if (Trace_Flag) |
- { |
- cprintf("spatial_temporal_weight_code ("); |
- Print_Bits(stwcode,2,2); |
- cprintf("): %d\n",stwcode); |
- } |
-#endif /* TRACE */ |
- stwtype = stwc_table[spatial_temporal_weight_code_table_index-1][stwcode]; |
- } |
- } |
- else |
- stwtype = (macroblock_type & MB_CLASS4) ? 8 : 0; |
- |
- /* SCALABILITY: derive spatial_temporal_weight_class (Table 7-18) */ |
- stwclass = stwclass_table[stwtype]; |
- |
- /* get frame/field motion type */ |
- if (macroblock_type & (MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD)) |
- { |
- if (picture_structure==FRAME_PICTURE) /* frame_motion_type */ |
- { |
- motion_type = frame_pred_frame_dct ? MC_FRAME : Get_Bits(2); |
-#ifdef TRACE |
- if (!frame_pred_frame_dct && Trace_Flag) |
- { |
- cprintf("frame_motion_type ("); |
- Print_Bits(motion_type,2,2); |
- cprintf("): %s\n",motion_type==MC_FIELD?"Field": |
- motion_type==MC_FRAME?"Frame": |
- motion_type==MC_DMV?"Dual_Prime":"Invalid"); |
- } |
-#endif /* TRACE */ |
- } |
- else /* field_motion_type */ |
- { |
- motion_type = Get_Bits(2); |
-#ifdef TRACE |
- if (Trace_Flag) |
- { |
- cprintf("field_motion_type ("); |
- Print_Bits(motion_type,2,2); |
- cprintf("): %s\n",motion_type==MC_FIELD?"Field": |
- motion_type==MC_16X8?"16x8 MC": |
- motion_type==MC_DMV?"Dual_Prime":"Invalid"); |
- } |
-#endif /* TRACE */ |
- } |
- } |
- else if ((macroblock_type & MACROBLOCK_INTRA) && concealment_motion_vectors) |
- { |
- /* concealment motion vectors */ |
- motion_type = (picture_structure==FRAME_PICTURE) ? MC_FRAME : MC_FIELD; |
- } |
-#if 0 |
- else |
- { |
- printf("maroblock_modes(): unknown macroblock type\n"); |
- motion_type = -1; |
- } |
-#endif |
- |
- /* derive motion_vector_count, mv_format and dmv, (table 6-17, 6-18) */ |
- if (picture_structure==FRAME_PICTURE) |
- { |
- motion_vector_count = (motion_type==MC_FIELD && stwclass<2) ? 2 : 1; |
- mv_format = (motion_type==MC_FRAME) ? MV_FRAME : MV_FIELD; |
- } |
- else |
- { |
- motion_vector_count = (motion_type==MC_16X8) ? 2 : 1; |
- mv_format = MV_FIELD; |
- } |
- |
- dmv = (motion_type==MC_DMV); /* dual prime */ |
- |
- /* field mv predictions in frame pictures have to be scaled |
- * ISO/IEC 13818-2 section 7.6.3.1 Decoding the motion vectors |
- * IMPLEMENTATION: mvscale is derived for later use in motion_vectors() |
- * it displaces the stage: |
- * |
- * if((mv_format=="field")&&(t==1)&&(picture_structure=="Frame picture")) |
- * prediction = PMV[r][s][t] DIV 2; |
- */ |
- |
- mvscale = ((mv_format==MV_FIELD) && (picture_structure==FRAME_PICTURE)); |
- |
- /* get dct_type (frame DCT / field DCT) */ |
- dct_type = (picture_structure==FRAME_PICTURE) |
- && (!frame_pred_frame_dct) |
- && (macroblock_type & (MACROBLOCK_PATTERN|MACROBLOCK_INTRA)) |
- ? Get_Bits(1) |
- : 0; |
- |
-#ifdef TRACE |
- if (Trace_Flag && (picture_structure==FRAME_PICTURE) |
- && (!frame_pred_frame_dct) |
- && (macroblock_type & (MACROBLOCK_PATTERN|MACROBLOCK_INTRA))) |
- cprintf("dct_type (%d): %s\n",dct_type,dct_type?"Field":"Frame"); |
-#endif /* TRACE */ |
- |
- /* return values */ |
- *pmacroblock_type = macroblock_type; |
- *pstwtype = stwtype; |
- *pstwclass = stwclass; |
- *pmotion_type = motion_type; |
- *pmotion_vector_count = motion_vector_count; |
- *pmv_format = mv_format; |
- *pdmv = dmv; |
- *pmvscale = mvscale; |
- *pdct_type = dct_type; |
-} |
- |
- |
-/* move/add 8x8-Block from block[comp] to backward_reference_frame */ |
-/* copy reconstructed 8x8 block from block[comp] to current_frame[] |
- * ISO/IEC 13818-2 section 7.6.8: Adding prediction and coefficient data |
- * This stage also embodies some of the operations implied by: |
- * - ISO/IEC 13818-2 section 7.6.7: Combining predictions |
- * - ISO/IEC 13818-2 section 6.1.3: Macroblock |
-*/ |
-static void Add_Block(comp,bx,by,dct_type,addflag) |
-int comp,bx,by,dct_type,addflag; |
-{ |
- int cc,i, j, iincr; |
- unsigned char *rfp; |
- short *bp; |
- |
- |
- /* derive color component index */ |
- /* equivalent to ISO/IEC 13818-2 Table 7-1 */ |
- cc = (comp<4) ? 0 : (comp&1)+1; /* color component index */ |
- |
- if (cc==0) |
- { |
- /* luminance */ |
- |
- if (picture_structure==FRAME_PICTURE) |
- if (dct_type) |
- { |
- /* field DCT coding */ |
- rfp = current_frame[0] |
- + Coded_Picture_Width*(by+((comp&2)>>1)) + bx + ((comp&1)<<3); |
- iincr = (Coded_Picture_Width<<1) - 8; |
- } |
- else |
- { |
- /* frame DCT coding */ |
- rfp = current_frame[0] |
- + Coded_Picture_Width*(by+((comp&2)<<2)) + bx + ((comp&1)<<3); |
- iincr = Coded_Picture_Width - 8; |
- } |
- else |
- { |
- /* field picture */ |
- rfp = current_frame[0] |
- + (Coded_Picture_Width<<1)*(by+((comp&2)<<2)) + bx + ((comp&1)<<3); |
- iincr = (Coded_Picture_Width<<1) - 8; |
- } |
- } |
- else |
- { |
- /* chrominance */ |
- |
- /* scale coordinates */ |
- if (chroma_format!=CHROMA444) |
- bx >>= 1; |
- if (chroma_format==CHROMA420) |
- by >>= 1; |
- if (picture_structure==FRAME_PICTURE) |
- { |
- if (dct_type && (chroma_format!=CHROMA420)) |
- { |
- /* field DCT coding */ |
- rfp = current_frame[cc] |
- + Chroma_Width*(by+((comp&2)>>1)) + bx + (comp&8); |
- iincr = (Chroma_Width<<1) - 8; |
- } |
- else |
- { |
- /* frame DCT coding */ |
- rfp = current_frame[cc] |
- + Chroma_Width*(by+((comp&2)<<2)) + bx + (comp&8); |
- iincr = Chroma_Width - 8; |
- } |
- } |
- else |
- { |
- /* field picture */ |
- rfp = current_frame[cc] |
- + (Chroma_Width<<1)*(by+((comp&2)<<2)) + bx + (comp&8); |
- iincr = (Chroma_Width<<1) - 8; |
- } |
- } |
- |
- bp = ld->block[comp]; |
- |
- if (addflag) |
- { |
- for (i=0; i<8; i++) |
- { |
- for (j=0; j<8; j++) |
- { |
- *rfp = Clip[*bp++ + *rfp]; |
- rfp++; |
- } |
- |
- rfp+= iincr; |
- } |
- } |
- else |
- { |
- for (i=0; i<8; i++) |
- { |
- for (j=0; j<8; j++) |
- *rfp++ = Clip[*bp++ + 128]; |
- |
- rfp+= iincr; |
- } |
- } |
-} |
- |
- |
-/* ISO/IEC 13818-2 section 7.8 */ |
-static void Decode_SNR_Macroblock(SNRMBA, SNRMBAinc, MBA, MBAmax, dct_type) |
- int *SNRMBA, *SNRMBAinc; |
- int MBA, MBAmax; |
- int *dct_type; |
-{ |
- int SNRmacroblock_type, SNRcoded_block_pattern, SNRdct_type, dummy; |
- int slice_vert_pos_ext, quantizer_scale_code, comp, code; |
- |
- ld = &enhan; |
- |
- if (*SNRMBAinc==0) |
- { |
- if (!Show_Bits(23)) /* next_start_code */ |
- { |
- next_start_code(); |
- code = Show_Bits(32); |
- |
- if (code<SLICE_START_CODE_MIN || code>SLICE_START_CODE_MAX) |
- { |
- /* only slice headers are allowed in picture_data */ |
- if (!Quiet_Flag) |
- cprintf("SNR: Premature end of picture\n"); |
- return; |
- } |
- |
- Flush_Buffer32(); |
- |
- /* decode slice header (may change quantizer_scale) */ |
- slice_vert_pos_ext = slice_header(); |
- |
- /* decode macroblock address increment */ |
- *SNRMBAinc = Get_macroblock_address_increment(); |
- |
- /* set current location */ |
- *SNRMBA = |
- ((slice_vert_pos_ext<<7) + (code&255) - 1)*mb_width + *SNRMBAinc - 1; |
- |
- *SNRMBAinc = 1; /* first macroblock in slice: not skipped */ |
- } |
- else /* not next_start_code */ |
- { |
- if (*SNRMBA>=MBAmax) |
- { |
- if (!Quiet_Flag) |
- cprintf("Too many macroblocks in picture\n"); |
- return; |
- } |
- |
- /* decode macroblock address increment */ |
- *SNRMBAinc = Get_macroblock_address_increment(); |
- } |
- } |
- |
- if (*SNRMBA!=MBA) |
- { |
- /* streams out of sync */ |
- if (!Quiet_Flag) |
- cprintf("Cant't synchronize streams\n"); |
- return; |
- } |
- |
- if (*SNRMBAinc==1) /* not skipped */ |
- { |
- macroblock_modes(&SNRmacroblock_type, &dummy, &dummy, |
- &dummy, &dummy, &dummy, &dummy, &dummy, |
- &SNRdct_type); |
- |
- if (SNRmacroblock_type & MACROBLOCK_PATTERN) |
- *dct_type = SNRdct_type; |
- |
- if (SNRmacroblock_type & MACROBLOCK_QUANT) |
- { |
- quantizer_scale_code = Get_Bits(5); |
- ld->quantizer_scale = |
- ld->q_scale_type ? Non_Linear_quantizer_scale[quantizer_scale_code] : quantizer_scale_code<<1; |
- } |
- |
- /* macroblock_pattern */ |
- if (SNRmacroblock_type & MACROBLOCK_PATTERN) |
- { |
- SNRcoded_block_pattern = Get_coded_block_pattern(); |
- |
- if (chroma_format==CHROMA422) |
- SNRcoded_block_pattern = (SNRcoded_block_pattern<<2) | Get_Bits(2); /* coded_block_pattern_1 */ |
- else if (chroma_format==CHROMA444) |
- SNRcoded_block_pattern = (SNRcoded_block_pattern<<6) | Get_Bits(6); /* coded_block_pattern_2 */ |
- } |
- else |
- SNRcoded_block_pattern = 0; |
- |
- /* decode blocks */ |
- for (comp=0; comp<block_count; comp++) |
- { |
- Clear_Block(comp); |
- |
- if (SNRcoded_block_pattern & (1<<(block_count-1-comp))) |
- Decode_MPEG2_Non_Intra_Block(comp); |
- } |
- } |
- else /* SNRMBAinc!=1: skipped macroblock */ |
- { |
- for (comp=0; comp<block_count; comp++) |
- Clear_Block(comp); |
- } |
- |
- ld = &base; |
-} |
- |
- |
- |
-/* IMPLEMENTATION: set scratch pad macroblock to zero */ |
-static void Clear_Block(comp) |
-int comp; |
-{ |
- short *Block_Ptr; |
- int i; |
- |
- Block_Ptr = ld->block[comp]; |
- |
- for (i=0; i<64; i++) |
- *Block_Ptr++ = 0; |
-} |
- |
- |
-/* SCALABILITY: add SNR enhancement layer block data to base layer */ |
-/* ISO/IEC 13818-2 section 7.8.3.4: Addition of coefficients from the two layes */ |
-static void Sum_Block(comp) |
-int comp; |
-{ |
- short *Block_Ptr1, *Block_Ptr2; |
- int i; |
- |
- Block_Ptr1 = base.block[comp]; |
- Block_Ptr2 = enhan.block[comp]; |
- |
- for (i=0; i<64; i++) |
- *Block_Ptr1++ += *Block_Ptr2++; |
-} |
- |
- |
-/* limit coefficients to -2048..2047 */ |
-/* ISO/IEC 13818-2 section 7.4.3 and 7.4.4: Saturation and Mismatch control */ |
-static void Saturate(Block_Ptr) |
-short *Block_Ptr; |
-{ |
- int i, sum, val; |
- |
- sum = 0; |
- |
- /* ISO/IEC 13818-2 section 7.4.3: Saturation */ |
- for (i=0; i<64; i++) |
- { |
- val = Block_Ptr[i]; |
- |
- if (val>2047) |
- val = 2047; |
- else if (val<-2048) |
- val = -2048; |
- |
- Block_Ptr[i] = val; |
- sum+= val; |
- } |
- |
- /* ISO/IEC 13818-2 section 7.4.4: Mismatch control */ |
- if ((sum&1)==0) |
- Block_Ptr[63]^= 1; |
- |
-} |
- |
- |
-/* reuse old picture buffers as soon as they are no longer needed |
- based on life-time axioms of MPEG */ |
-static void Update_Picture_Buffers() |
-{ |
- int cc; /* color component index */ |
- unsigned char *tmp; /* temporary swap pointer */ |
- |
- for (cc=0; cc<3; cc++) |
- { |
- /* B pictures do not need to be save for future reference */ |
- if (picture_coding_type==B_TYPE) |
- { |
- current_frame[cc] = auxframe[cc]; |
- } |
- else |
- { |
- /* only update at the beginning of the coded frame */ |
- if (!Second_Field) |
- { |
- tmp = forward_reference_frame[cc]; |
- |
- /* the previously decoded reference frame is stored |
- coincident with the location where the backward |
- reference frame is stored (backwards prediction is not |
- needed in P pictures) */ |
- forward_reference_frame[cc] = backward_reference_frame[cc]; |
- |
- /* update pointer for potential future B pictures */ |
- backward_reference_frame[cc] = tmp; |
- } |
- |
- /* can erase over old backward reference frame since it is not used |
- in a P picture, and since any subsequent B pictures will use the |
- previously decoded I or P frame as the backward_reference_frame */ |
- current_frame[cc] = backward_reference_frame[cc]; |
- } |
- |
- /* IMPLEMENTATION: |
- one-time folding of a line offset into the pointer which stores the |
- memory address of the current frame saves offsets and conditional |
- branches throughout the remainder of the picture processing loop */ |
- if (picture_structure==BOTTOM_FIELD) |
- current_frame[cc]+= (cc==0) ? Coded_Picture_Width : Chroma_Width; |
- } |
-} |
- |
- |
-/* store last frame */ |
- |
-void Output_Last_Frame_of_Sequence(Framenum) |
-int Framenum; |
-{ |
- if (Second_Field) |
- cprintf("last frame incomplete, not stored\n"); |
- else |
- Write_Frame(backward_reference_frame,Framenum-1); |
-} |
- |
- |
- |
-static void frame_reorder(Bitstream_Framenum, Sequence_Framenum) |
-int Bitstream_Framenum, Sequence_Framenum; |
-{ |
- /* tracking variables to insure proper output in spatial scalability */ |
- static int Oldref_progressive_frame, Newref_progressive_frame; |
- |
- if (Sequence_Framenum!=0) |
- { |
- if (picture_structure==FRAME_PICTURE || Second_Field) |
- { |
- if (picture_coding_type==B_TYPE) |
- Write_Frame(auxframe,Bitstream_Framenum-1); |
- else |
- { |
- Newref_progressive_frame = progressive_frame; |
- progressive_frame = Oldref_progressive_frame; |
- |
- Write_Frame(forward_reference_frame,Bitstream_Framenum-1); |
- |
- Oldref_progressive_frame = progressive_frame = Newref_progressive_frame; |
- } |
- } |
-#ifdef DISPLAY |
- else if (Output_Type==T_X11) |
- { |
- if(!Display_Progressive_Flag) |
- Display_Second_Field(); |
- } |
-#endif |
- } |
- else |
- Oldref_progressive_frame = progressive_frame; |
- |
-} |
- |
- |
-/* ISO/IEC 13818-2 section 7.6 */ |
-static void motion_compensation(MBA, macroblock_type, motion_type, PMV, |
- motion_vertical_field_select, dmvector, stwtype, dct_type) |
-int MBA; |
-int macroblock_type; |
-int motion_type; |
-int PMV[2][2][2]; |
-int motion_vertical_field_select[2][2]; |
-int dmvector[2]; |
-int stwtype; |
-int dct_type; |
-{ |
- int bx, by; |
- int comp; |
- |
- /* derive current macroblock position within picture */ |
- /* ISO/IEC 13818-2 section 6.3.1.6 and 6.3.1.7 */ |
- bx = 16*(MBA%mb_width); |
- by = 16*(MBA/mb_width); |
- |
- /* motion compensation */ |
- if (!(macroblock_type & MACROBLOCK_INTRA)) |
- form_predictions(bx,by,macroblock_type,motion_type,PMV, |
- motion_vertical_field_select,dmvector,stwtype); |
- |
- /* SCALABILITY: Data Partitioning */ |
- if (base.scalable_mode==SC_DP) |
- ld = &base; |
- |
- /* copy or add block data into picture */ |
- for (comp=0; comp<block_count; comp++) |
- { |
- /* SCALABILITY: SNR */ |
- /* ISO/IEC 13818-2 section 7.8.3.4: Addition of coefficients from |
- the two a layers */ |
- if (Two_Streams && enhan.scalable_mode==SC_SNR) |
- Sum_Block(comp); /* add SNR enhancement layer data to base layer */ |
- |
- /* MPEG-2 saturation and mismatch control */ |
- /* base layer could be MPEG-1 stream, enhancement MPEG-2 SNR */ |
- /* ISO/IEC 13818-2 section 7.4.3 and 7.4.4: Saturation and Mismatch control */ |
- if ((Two_Streams && enhan.scalable_mode==SC_SNR) || ld->MPEG2_Flag) |
- Saturate(ld->block[comp]); |
- |
- /* ISO/IEC 13818-2 section Annex A: inverse DCT */ |
- if (Reference_IDCT_Flag) |
- Reference_IDCT(ld->block[comp]); |
- else |
- Fast_IDCT(ld->block[comp]); |
- |
- /* ISO/IEC 13818-2 section 7.6.8: Adding prediction and coefficient data */ |
- Add_Block(comp,bx,by,dct_type,(macroblock_type & MACROBLOCK_INTRA)==0); |
- } |
- |
-} |
- |
- |
- |
-/* ISO/IEC 13818-2 section 7.6.6 */ |
-static void skipped_macroblock(dc_dct_pred, PMV, motion_type, |
- motion_vertical_field_select, stwtype, macroblock_type) |
-int dc_dct_pred[3]; |
-int PMV[2][2][2]; |
-int *motion_type; |
-int motion_vertical_field_select[2][2]; |
-int *stwtype; |
-int *macroblock_type; |
-{ |
- int comp; |
- |
- /* SCALABILITY: Data Paritioning */ |
- if (base.scalable_mode==SC_DP) |
- ld = &base; |
- |
- for (comp=0; comp<block_count; comp++) |
- Clear_Block(comp); |
- |
- /* reset intra_dc predictors */ |
- /* ISO/IEC 13818-2 section 7.2.1: DC coefficients in intra blocks */ |
- dc_dct_pred[0]=dc_dct_pred[1]=dc_dct_pred[2]=0; |
- |
- /* reset motion vector predictors */ |
- /* ISO/IEC 13818-2 section 7.6.3.4: Resetting motion vector predictors */ |
- if (picture_coding_type==P_TYPE) |
- PMV[0][0][0]=PMV[0][0][1]=PMV[1][0][0]=PMV[1][0][1]=0; |
- |
- /* derive motion_type */ |
- if (picture_structure==FRAME_PICTURE) |
- *motion_type = MC_FRAME; |
- else |
- { |
- *motion_type = MC_FIELD; |
- |
- /* predict from field of same parity */ |
- /* ISO/IEC 13818-2 section 7.6.6.1 and 7.6.6.3: P field picture and B field |
- picture */ |
- motion_vertical_field_select[0][0]=motion_vertical_field_select[0][1] = |
- (picture_structure==BOTTOM_FIELD); |
- } |
- |
- /* skipped I are spatial-only predicted, */ |
- /* skipped P and B are temporal-only predicted */ |
- /* ISO/IEC 13818-2 section 7.7.6: Skipped macroblocks */ |
- *stwtype = (picture_coding_type==I_TYPE) ? 8 : 0; |
- |
- /* IMPLEMENTATION: clear MACROBLOCK_INTRA */ |
- *macroblock_type&= ~MACROBLOCK_INTRA; |
- |
-} |
- |
- |
-/* return==-1 means go to next picture */ |
-/* the expression "start of slice" is used throughout the normative |
- body of the MPEG specification */ |
-static int start_of_slice(MBAmax, MBA, MBAinc, |
- dc_dct_pred, PMV) |
-int MBAmax; |
-int *MBA; |
-int *MBAinc; |
-int dc_dct_pred[3]; |
-int PMV[2][2][2]; |
-{ |
- unsigned int code; |
- int slice_vert_pos_ext; |
- |
- ld = &base; |
- |
- Fault_Flag = 0; |
- |
- next_start_code(); |
- code = Show_Bits(32); |
- |
- if (code<SLICE_START_CODE_MIN || code>SLICE_START_CODE_MAX) |
- { |
- /* only slice headers are allowed in picture_data */ |
- if (!Quiet_Flag) |
- cprintf("start_of_slice(): Premature end of picture\n"); |
- |
- return(-1); /* trigger: go to next picture */ |
- } |
- |
- Flush_Buffer32(); |
- |
- /* decode slice header (may change quantizer_scale) */ |
- slice_vert_pos_ext = slice_header(); |
- |
- |
- /* SCALABILITY: Data Partitioning */ |
- if (base.scalable_mode==SC_DP) |
- { |
- ld = &enhan; |
- next_start_code(); |
- code = Show_Bits(32); |
- |
- if (code<SLICE_START_CODE_MIN || code>SLICE_START_CODE_MAX) |
- { |
- /* only slice headers are allowed in picture_data */ |
- if (!Quiet_Flag) |
- cprintf("DP: Premature end of picture\n"); |
- return(-1); /* trigger: go to next picture */ |
- } |
- |
- Flush_Buffer32(); |
- |
- /* decode slice header (may change quantizer_scale) */ |
- slice_vert_pos_ext = slice_header(); |
- |
- if (base.priority_breakpoint!=1) |
- ld = &base; |
- } |
- |
- /* decode macroblock address increment */ |
- *MBAinc = Get_macroblock_address_increment(); |
- |
- if (Fault_Flag) |
- { |
- cprintf("start_of_slice(): MBAinc unsuccessful\n"); |
- return(0); /* trigger: go to next slice */ |
- } |
- |
- /* set current location */ |
- /* NOTE: the arithmetic used to derive macroblock_address below is |
- * equivalent to ISO/IEC 13818-2 section 6.3.17: Macroblock |
- */ |
- *MBA = ((slice_vert_pos_ext<<7) + (code&255) - 1)*mb_width + *MBAinc - 1; |
- *MBAinc = 1; /* first macroblock in slice: not skipped */ |
- |
- /* reset all DC coefficient and motion vector predictors */ |
- /* reset all DC coefficient and motion vector predictors */ |
- /* ISO/IEC 13818-2 section 7.2.1: DC coefficients in intra blocks */ |
- dc_dct_pred[0]=dc_dct_pred[1]=dc_dct_pred[2]=0; |
- |
- /* ISO/IEC 13818-2 section 7.6.3.4: Resetting motion vector predictors */ |
- PMV[0][0][0]=PMV[0][0][1]=PMV[1][0][0]=PMV[1][0][1]=0; |
- PMV[0][1][0]=PMV[0][1][1]=PMV[1][1][0]=PMV[1][1][1]=0; |
- |
- /* successfull: trigger decode macroblocks in slice */ |
- return(1); |
-} |
- |
- |
-/* ISO/IEC 13818-2 sections 7.2 through 7.5 */ |
-static int decode_macroblock(macroblock_type, stwtype, stwclass, |
- motion_type, dct_type, PMV, dc_dct_pred, |
- motion_vertical_field_select, dmvector) |
-int *macroblock_type; |
-int *stwtype; |
-int *stwclass; |
-int *motion_type; |
-int *dct_type; |
-int PMV[2][2][2]; |
-int dc_dct_pred[3]; |
-int motion_vertical_field_select[2][2]; |
-int dmvector[2]; |
-{ |
- /* locals */ |
- int quantizer_scale_code; |
- int comp; |
- |
- int motion_vector_count; |
- int mv_format; |
- int dmv; |
- int mvscale; |
- int coded_block_pattern; |
- |
- /* SCALABILITY: Data Patitioning */ |
- if (base.scalable_mode==SC_DP) |
- { |
- if (base.priority_breakpoint<=2) |
- ld = &enhan; |
- else |
- ld = &base; |
- } |
- |
- /* ISO/IEC 13818-2 section 6.3.17.1: Macroblock modes */ |
- macroblock_modes(macroblock_type, stwtype, stwclass, |
- motion_type, &motion_vector_count, &mv_format, &dmv, &mvscale, |
- dct_type); |
- |
- if (Fault_Flag) return(0); /* trigger: go to next slice */ |
- |
- if (*macroblock_type & MACROBLOCK_QUANT) |
- { |
- quantizer_scale_code = Get_Bits(5); |
- |
-#ifdef TRACE |
- if (Trace_Flag) |
- { |
- cprintf("quantiser_scale_code ("); |
- Print_Bits(quantizer_scale_code,5,5); |
- cprintf("): %d\n",quantizer_scale_code); |
- } |
-#endif /* TRACE */ |
- |
- /* ISO/IEC 13818-2 section 7.4.2.2: Quantizer scale factor */ |
- if (ld->MPEG2_Flag) |
- ld->quantizer_scale = |
- ld->q_scale_type ? Non_Linear_quantizer_scale[quantizer_scale_code] |
- : (quantizer_scale_code << 1); |
- else |
- ld->quantizer_scale = quantizer_scale_code; |
- |
- /* SCALABILITY: Data Partitioning */ |
- if (base.scalable_mode==SC_DP) |
- /* make sure base.quantizer_scale is valid */ |
- base.quantizer_scale = ld->quantizer_scale; |
- } |
- |
- /* motion vectors */ |
- |
- |
- /* ISO/IEC 13818-2 section 6.3.17.2: Motion vectors */ |
- |
- /* decode forward motion vectors */ |
- if ((*macroblock_type & MACROBLOCK_MOTION_FORWARD) |
- || ((*macroblock_type & MACROBLOCK_INTRA) |
- && concealment_motion_vectors)) |
- { |
- if (ld->MPEG2_Flag) |
- motion_vectors(PMV,dmvector,motion_vertical_field_select, |
- 0,motion_vector_count,mv_format,f_code[0][0]-1,f_code[0][1]-1, |
- dmv,mvscale); |
- else |
- motion_vector(PMV[0][0],dmvector, |
- forward_f_code-1,forward_f_code-1,0,0,full_pel_forward_vector); |
- } |
- |
- if (Fault_Flag) return(0); /* trigger: go to next slice */ |
- |
- /* decode backward motion vectors */ |
- if (*macroblock_type & MACROBLOCK_MOTION_BACKWARD) |
- { |
- if (ld->MPEG2_Flag) |
- motion_vectors(PMV,dmvector,motion_vertical_field_select, |
- 1,motion_vector_count,mv_format,f_code[1][0]-1,f_code[1][1]-1,0, |
- mvscale); |
- else |
- motion_vector(PMV[0][1],dmvector, |
- backward_f_code-1,backward_f_code-1,0,0,full_pel_backward_vector); |
- } |
- |
- if (Fault_Flag) return(0); /* trigger: go to next slice */ |
- |
- if ((*macroblock_type & MACROBLOCK_INTRA) && concealment_motion_vectors) |
- Flush_Buffer(1); /* remove marker_bit */ |
- |
- if (base.scalable_mode==SC_DP && base.priority_breakpoint==3) |
- ld = &enhan; |
- |
- /* macroblock_pattern */ |
- /* ISO/IEC 13818-2 section 6.3.17.4: Coded block pattern */ |
- if (*macroblock_type & MACROBLOCK_PATTERN) |
- { |
- coded_block_pattern = Get_coded_block_pattern(); |
- |
- if (chroma_format==CHROMA422) |
- { |
- /* coded_block_pattern_1 */ |
- coded_block_pattern = (coded_block_pattern<<2) | Get_Bits(2); |
- |
-#ifdef TRACE |
- if (Trace_Flag) |
- { |
- cprintf("coded_block_pattern_1: "); |
- Print_Bits(coded_block_pattern,2,2); |
- cprintf(" (%d)\n",coded_block_pattern&3); |
- } |
-#endif /* TRACE */ |
- } |
- else if (chroma_format==CHROMA444) |
- { |
- /* coded_block_pattern_2 */ |
- coded_block_pattern = (coded_block_pattern<<6) | Get_Bits(6); |
- |
-#ifdef TRACE |
- if (Trace_Flag) |
- { |
- cprintf("coded_block_pattern_2: "); |
- Print_Bits(coded_block_pattern,6,6); |
- cprintf(" (%d)\n",coded_block_pattern&63); |
- } |
-#endif /* TRACE */ |
- } |
- } |
- else |
- coded_block_pattern = (*macroblock_type & MACROBLOCK_INTRA) ? |
- (1<<block_count)-1 : 0; |
- |
- if (Fault_Flag) return(0); /* trigger: go to next slice */ |
- |
- /* decode blocks */ |
- for (comp=0; comp<block_count; comp++) |
- { |
- /* SCALABILITY: Data Partitioning */ |
- if (base.scalable_mode==SC_DP) |
- ld = &base; |
- |
- Clear_Block(comp); |
- |
- if (coded_block_pattern & (1<<(block_count-1-comp))) |
- { |
- if (*macroblock_type & MACROBLOCK_INTRA) |
- { |
- if (ld->MPEG2_Flag) |
- Decode_MPEG2_Intra_Block(comp,dc_dct_pred); |
- else |
- Decode_MPEG1_Intra_Block(comp,dc_dct_pred); |
- } |
- else |
- { |
- if (ld->MPEG2_Flag) |
- Decode_MPEG2_Non_Intra_Block(comp); |
- else |
- Decode_MPEG1_Non_Intra_Block(comp); |
- } |
- |
- if (Fault_Flag) return(0); /* trigger: go to next slice */ |
- } |
- } |
- |
- if(picture_coding_type==D_TYPE) |
- { |
- /* remove end_of_macroblock (always 1, prevents startcode emulation) */ |
- /* ISO/IEC 11172-2 section 2.4.2.7 and 2.4.3.6 */ |
- marker_bit("D picture end_of_macroblock bit"); |
- } |
- |
- /* reset intra_dc predictors */ |
- /* ISO/IEC 13818-2 section 7.2.1: DC coefficients in intra blocks */ |
- if (!(*macroblock_type & MACROBLOCK_INTRA)) |
- dc_dct_pred[0]=dc_dct_pred[1]=dc_dct_pred[2]=0; |
- |
- /* reset motion vector predictors */ |
- if ((*macroblock_type & MACROBLOCK_INTRA) && !concealment_motion_vectors) |
- { |
- /* intra mb without concealment motion vectors */ |
- /* ISO/IEC 13818-2 section 7.6.3.4: Resetting motion vector predictors */ |
- PMV[0][0][0]=PMV[0][0][1]=PMV[1][0][0]=PMV[1][0][1]=0; |
- PMV[0][1][0]=PMV[0][1][1]=PMV[1][1][0]=PMV[1][1][1]=0; |
- } |
- |
- /* special "No_MC" macroblock_type case */ |
- /* ISO/IEC 13818-2 section 7.6.3.5: Prediction in P pictures */ |
- if ((picture_coding_type==P_TYPE) |
- && !(*macroblock_type & (MACROBLOCK_MOTION_FORWARD|MACROBLOCK_INTRA))) |
- { |
- /* non-intra mb without forward mv in a P picture */ |
- /* ISO/IEC 13818-2 section 7.6.3.4: Resetting motion vector predictors */ |
- PMV[0][0][0]=PMV[0][0][1]=PMV[1][0][0]=PMV[1][0][1]=0; |
- |
- /* derive motion_type */ |
- /* ISO/IEC 13818-2 section 6.3.17.1: Macroblock modes, frame_motion_type */ |
- if (picture_structure==FRAME_PICTURE) |
- *motion_type = MC_FRAME; |
- else |
- { |
- *motion_type = MC_FIELD; |
- /* predict from field of same parity */ |
- motion_vertical_field_select[0][0] = (picture_structure==BOTTOM_FIELD); |
- } |
- } |
- |
- if (*stwclass==4) |
- { |
- /* purely spatially predicted macroblock */ |
- /* ISO/IEC 13818-2 section 7.7.5.1: Resetting motion vector predictions */ |
- PMV[0][0][0]=PMV[0][0][1]=PMV[1][0][0]=PMV[1][0][1]=0; |
- PMV[0][1][0]=PMV[0][1][1]=PMV[1][1][0]=PMV[1][1][1]=0; |
- } |
- |
- /* successfully decoded macroblock */ |
- return(1); |
- |
-} /* decode_macroblock */ |
- |
- |
Index: tags/rel_1_22/fsf/mpeg2/gvideo.c |
=================================================================== |
--- tags/rel_1_22/fsf/mpeg2/gvideo.c (revision 1310) |
+++ tags/rel_1_22/fsf/mpeg2/gvideo.c (nonexistent) |
@@ -1,51 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-#include "drivers/glib.h" |
- |
-#include "fsf_contract.h" |
- |
-#include "config.h" |
-#include "global.h" |
- |
-extern void *start_file; |
-extern void *end_file; |
- |
-int Init_Mpeg_Decoder(void *start,void *end); |
-int Decode_Bitstream(); |
- |
-void *mpeg2decoder(void *arg) |
-{ |
- |
- int init = 1; |
- |
- Init_Mpeg_Decoder(start_file,end_file); |
- |
- while(1) { |
- |
- if (init == 1) { |
- Decode_Bitstream(); |
- } |
- |
- } |
- |
- return 0; |
- |
-} |
- |
- |
Index: tags/rel_1_22/fsf/mpeg2/gethdr.c |
=================================================================== |
--- tags/rel_1_22/fsf/mpeg2/gethdr.c (revision 1310) |
+++ tags/rel_1_22/fsf/mpeg2/gethdr.c (nonexistent) |
@@ -1,1074 +0,0 @@ |
-/* gethdr.c, header decoding */ |
- |
-/* Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved. */ |
- |
-/* |
- * Disclaimer of Warranty |
- * |
- * These software programs are available to the user without any license fee or |
- * royalty on an "as is" basis. The MPEG Software Simulation Group disclaims |
- * any and all warranties, whether express, implied, or statuary, including any |
- * implied warranties or merchantability or of fitness for a particular |
- * purpose. In no event shall the copyright-holder be liable for any |
- * incidental, punitive, or consequential damages of any kind whatsoever |
- * arising from the use of these programs. |
- * |
- * This disclaimer of warranty extends to the user of these programs and user's |
- * customers, employees, agents, transferees, successors, and assigns. |
- * |
- * The MPEG Software Simulation Group does not represent or warrant that the |
- * programs furnished hereunder are free of infringement of any third-party |
- * patents. |
- * |
- * Commercial implementations of MPEG-1 and MPEG-2 video, including shareware, |
- * are subject to royalty fees to patent holders. Many of these patents are |
- * general enough such that they are unavoidable regardless of implementation |
- * design. |
- * |
- */ |
- |
-#include "config.h" |
-#include "global.h" |
- |
- |
-/* private prototypes */ |
-static void sequence_header _ANSI_ARGS_((void)); |
-static void group_of_pictures_header _ANSI_ARGS_((void)); |
-static void picture_header _ANSI_ARGS_((void)); |
-static void extension_and_user_data _ANSI_ARGS_((void)); |
-static void sequence_extension _ANSI_ARGS_((void)); |
-static void sequence_display_extension _ANSI_ARGS_((void)); |
-static void quant_matrix_extension _ANSI_ARGS_((void)); |
-static void sequence_scalable_extension _ANSI_ARGS_((void)); |
-static void picture_display_extension _ANSI_ARGS_((void)); |
-static void picture_coding_extension _ANSI_ARGS_((void)); |
-static void picture_spatial_scalable_extension _ANSI_ARGS_((void)); |
-static void picture_temporal_scalable_extension _ANSI_ARGS_((void)); |
-static int extra_bit_information _ANSI_ARGS_((void)); |
-static void copyright_extension _ANSI_ARGS_((void)); |
-static void user_data _ANSI_ARGS_((void)); |
-static void user_data _ANSI_ARGS_((void)); |
- |
- |
- |
- |
-/* introduced in September 1995 to assist spatial scalable decoding */ |
-static void Update_Temporal_Reference_Tacking_Data _ANSI_ARGS_((void)); |
-/* private variables */ |
-static int Temporal_Reference_Base = 0; |
-static int True_Framenum_max = -1; |
-static int Temporal_Reference_GOP_Reset = 0; |
- |
-#define RESERVED -1 |
-static double frame_rate_Table[16] = |
-{ |
- 0.0, |
- ((23.0*1000.0)/1001.0), |
- 24.0, |
- 25.0, |
- ((30.0*1000.0)/1001.0), |
- 30.0, |
- 50.0, |
- ((60.0*1000.0)/1001.0), |
- 60.0, |
- |
- RESERVED, |
- RESERVED, |
- RESERVED, |
- RESERVED, |
- RESERVED, |
- RESERVED, |
- RESERVED |
-}; |
- |
-/* |
- * decode headers from one input stream |
- * until an End of Sequence or picture start code |
- * is found |
- */ |
-int Get_Hdr() |
-{ |
- unsigned int code; |
- |
- for (;;) |
- { |
- /* look for next_start_code */ |
- next_start_code(); |
- code = Get_Bits32(); |
- |
- switch (code) |
- { |
- case SEQUENCE_HEADER_CODE: |
- sequence_header(); |
- break; |
- case GROUP_START_CODE: |
- group_of_pictures_header(); |
- break; |
- case PICTURE_START_CODE: |
- picture_header(); |
- return 1; |
- break; |
- case SEQUENCE_END_CODE: |
- return 0; |
- break; |
- default: |
- if (!Quiet_Flag) |
- cprintf("Unexpected next_start_code %08x (ignored)\n",code); |
- break; |
- } |
- } |
-} |
- |
- |
-/* align to start of next next_start_code */ |
- |
-void next_start_code() |
-{ |
- /* byte align */ |
- Flush_Buffer(ld->Incnt&7); |
- while (Show_Bits(24)!=0x01L) |
- Flush_Buffer(8); |
-} |
- |
- |
-/* decode sequence header */ |
- |
-static void sequence_header() |
-{ |
- int i; |
- int pos; |
- |
- pos = ld->Bitcnt; |
- horizontal_size = Get_Bits(12); |
- vertical_size = Get_Bits(12); |
- aspect_ratio_information = Get_Bits(4); |
- frame_rate_code = Get_Bits(4); |
- bit_rate_value = Get_Bits(18); |
- marker_bit("sequence_header()"); |
- vbv_buffer_size = Get_Bits(10); |
- constrained_parameters_flag = Get_Bits(1); |
- |
- if((ld->load_intra_quantizer_matrix = Get_Bits(1))) |
- { |
- for (i=0; i<64; i++) |
- ld->intra_quantizer_matrix[scan[ZIG_ZAG][i]] = Get_Bits(8); |
- } |
- else |
- { |
- for (i=0; i<64; i++) |
- ld->intra_quantizer_matrix[i] = default_intra_quantizer_matrix[i]; |
- } |
- |
- if((ld->load_non_intra_quantizer_matrix = Get_Bits(1))) |
- { |
- for (i=0; i<64; i++) |
- ld->non_intra_quantizer_matrix[scan[ZIG_ZAG][i]] = Get_Bits(8); |
- } |
- else |
- { |
- for (i=0; i<64; i++) |
- ld->non_intra_quantizer_matrix[i] = 16; |
- } |
- |
- /* copy luminance to chrominance matrices */ |
- for (i=0; i<64; i++) |
- { |
- ld->chroma_intra_quantizer_matrix[i] = |
- ld->intra_quantizer_matrix[i]; |
- |
- ld->chroma_non_intra_quantizer_matrix[i] = |
- ld->non_intra_quantizer_matrix[i]; |
- } |
- |
-#ifdef VERBOSE |
- if (Verbose_Flag > NO_LAYER) |
- { |
- cprintf("sequence header (byte %d)\n",(pos>>3)-4); |
- if (Verbose_Flag > SEQUENCE_LAYER) |
- { |
- cprintf(" horizontal_size=%d\n",horizontal_size); |
- cprintf(" vertical_size=%d\n",vertical_size); |
- cprintf(" aspect_ratio_information=%d\n",aspect_ratio_information); |
- cprintf(" frame_rate_code=%d",frame_rate_code); |
- cprintf(" bit_rate_value=%d\n",bit_rate_value); |
- cprintf(" vbv_buffer_size=%d\n",vbv_buffer_size); |
- cprintf(" constrained_parameters_flag=%d\n",constrained_parameters_flag); |
- cprintf(" load_intra_quantizer_matrix=%d\n",ld->load_intra_quantizer_matrix); |
- cprintf(" load_non_intra_quantizer_matrix=%d\n",ld->load_non_intra_quantizer_matrix); |
- } |
- } |
-#endif /* VERBOSE */ |
- |
-#ifdef VERIFY |
- verify_sequence_header++; |
-#endif /* VERIFY */ |
- |
- extension_and_user_data(); |
-} |
- |
- |
- |
-/* decode group of pictures header */ |
-/* ISO/IEC 13818-2 section 6.2.2.6 */ |
-static void group_of_pictures_header() |
-{ |
- int pos; |
- |
- if (ld == &base) |
- { |
- Temporal_Reference_Base = True_Framenum_max + 1; /* *CH* */ |
- Temporal_Reference_GOP_Reset = 1; |
- } |
- pos = ld->Bitcnt; |
- drop_flag = Get_Bits(1); |
- hour = Get_Bits(5); |
- minute = Get_Bits(6); |
- marker_bit("group_of_pictures_header()"); |
- sec = Get_Bits(6); |
- frame = Get_Bits(6); |
- closed_gop = Get_Bits(1); |
- broken_link = Get_Bits(1); |
- |
-#ifdef VERBOSE |
- if (Verbose_Flag > NO_LAYER) |
- { |
- cprintf("group of pictures (byte %d)\n",(pos>>3)-4); |
- if (Verbose_Flag > SEQUENCE_LAYER) |
- { |
- cprintf(" drop_flag=%d\n",drop_flag); |
- cprintf(" timecode %d:%02d:%02d:%02d\n",hour,minute,sec,frame); |
- cprintf(" closed_gop=%d\n",closed_gop); |
- cprintf(" broken_link=%d\n",broken_link); |
- } |
- } |
-#endif /* VERBOSE */ |
- |
-#ifdef VERIFY |
- verify_group_of_pictures_header++; |
-#endif /* VERIFY */ |
- |
- extension_and_user_data(); |
- |
-} |
- |
- |
-/* decode picture header */ |
- |
-/* ISO/IEC 13818-2 section 6.2.3 */ |
-static void picture_header() |
-{ |
- int pos; |
- int Extra_Information_Byte_Count; |
- |
- /* unless later overwritten by picture_spatial_scalable_extension() */ |
- ld->pict_scal = 0; |
- |
- pos = ld->Bitcnt; |
- temporal_reference = Get_Bits(10); |
- picture_coding_type = Get_Bits(3); |
- vbv_delay = Get_Bits(16); |
- |
- if (picture_coding_type==P_TYPE || picture_coding_type==B_TYPE) |
- { |
- full_pel_forward_vector = Get_Bits(1); |
- forward_f_code = Get_Bits(3); |
- } |
- if (picture_coding_type==B_TYPE) |
- { |
- full_pel_backward_vector = Get_Bits(1); |
- backward_f_code = Get_Bits(3); |
- } |
- |
-#ifdef VERBOSE |
- if (Verbose_Flag>NO_LAYER) |
- { |
- cprintf("picture header (byte %d)\n",(pos>>3)-4); |
- if (Verbose_Flag>SEQUENCE_LAYER) |
- { |
- cprintf(" temporal_reference=%d\n",temporal_reference); |
- cprintf(" picture_coding_type=%d\n",picture_coding_type); |
- cprintf(" vbv_delay=%d\n",vbv_delay); |
- if (picture_coding_type==P_TYPE || picture_coding_type==B_TYPE) |
- { |
- cprintf(" full_pel_forward_vector=%d\n",full_pel_forward_vector); |
- cprintf(" forward_f_code =%d\n",forward_f_code); |
- } |
- if (picture_coding_type==B_TYPE) |
- { |
- cprintf(" full_pel_backward_vector=%d\n",full_pel_backward_vector); |
- cprintf(" backward_f_code =%d\n",backward_f_code); |
- } |
- } |
- } |
-#endif /* VERBOSE */ |
- |
-#ifdef VERIFY |
- verify_picture_header++; |
-#endif /* VERIFY */ |
- |
- Extra_Information_Byte_Count = |
- extra_bit_information(); |
- |
- extension_and_user_data(); |
- |
- /* update tracking information used to assist spatial scalability */ |
- Update_Temporal_Reference_Tacking_Data(); |
-} |
- |
-/* decode slice header */ |
- |
-/* ISO/IEC 13818-2 section 6.2.4 */ |
-int slice_header() |
-{ |
- int slice_vertical_position_extension; |
- int quantizer_scale_code; |
- int pos; |
- int slice_picture_id_enable = 0; |
- int slice_picture_id = 0; |
- int extra_information_slice = 0; |
- |
- pos = ld->Bitcnt; |
- |
- slice_vertical_position_extension = |
- (ld->MPEG2_Flag && vertical_size>2800) ? Get_Bits(3) : 0; |
- |
- if (ld->scalable_mode==SC_DP) |
- ld->priority_breakpoint = Get_Bits(7); |
- |
- quantizer_scale_code = Get_Bits(5); |
- ld->quantizer_scale = |
- ld->MPEG2_Flag ? (ld->q_scale_type ? Non_Linear_quantizer_scale[quantizer_scale_code] : quantizer_scale_code<<1) : quantizer_scale_code; |
- |
- /* slice_id introduced in March 1995 as part of the video corridendum |
- (after the IS was drafted in November 1994) */ |
- if (Get_Bits(1)) |
- { |
- ld->intra_slice = Get_Bits(1); |
- |
- slice_picture_id_enable = Get_Bits(1); |
- slice_picture_id = Get_Bits(6); |
- |
- extra_information_slice = extra_bit_information(); |
- } |
- else |
- ld->intra_slice = 0; |
- |
-#ifdef VERBOSE |
- if (Verbose_Flag>PICTURE_LAYER) |
- { |
- cprintf("slice header (byte %d)\n",(pos>>3)-4); |
- if (Verbose_Flag>SLICE_LAYER) |
- { |
- if (ld->MPEG2_Flag && vertical_size>2800) |
- cprintf(" slice_vertical_position_extension=%d\n",slice_vertical_position_extension); |
- |
- if (ld->scalable_mode==SC_DP) |
- cprintf(" priority_breakpoint=%d\n",ld->priority_breakpoint); |
- |
- cprintf(" quantizer_scale_code=%d\n",quantizer_scale_code); |
- |
- cprintf(" slice_picture_id_enable = %d\n", slice_picture_id_enable); |
- |
- if(slice_picture_id_enable) |
- cprintf(" slice_picture_id = %d\n", slice_picture_id); |
- |
- } |
- } |
-#endif /* VERBOSE */ |
- |
-#ifdef VERIFY |
- verify_slice_header++; |
-#endif /* VERIFY */ |
- |
- |
- return slice_vertical_position_extension; |
-} |
- |
- |
-/* decode extension and user data */ |
-/* ISO/IEC 13818-2 section 6.2.2.2 */ |
-static void extension_and_user_data() |
-{ |
- int code,ext_ID; |
- |
- next_start_code(); |
- |
- while ((code = Show_Bits(32))==EXTENSION_START_CODE || code==USER_DATA_START_CODE) |
- { |
- if (code==EXTENSION_START_CODE) |
- { |
- Flush_Buffer32(); |
- ext_ID = Get_Bits(4); |
- switch (ext_ID) |
- { |
- case SEQUENCE_EXTENSION_ID: |
- sequence_extension(); |
- break; |
- case SEQUENCE_DISPLAY_EXTENSION_ID: |
- sequence_display_extension(); |
- break; |
- case QUANT_MATRIX_EXTENSION_ID: |
- quant_matrix_extension(); |
- break; |
- case SEQUENCE_SCALABLE_EXTENSION_ID: |
- sequence_scalable_extension(); |
- break; |
- case PICTURE_DISPLAY_EXTENSION_ID: |
- picture_display_extension(); |
- break; |
- case PICTURE_CODING_EXTENSION_ID: |
- picture_coding_extension(); |
- break; |
- case PICTURE_SPATIAL_SCALABLE_EXTENSION_ID: |
- picture_spatial_scalable_extension(); |
- break; |
- case PICTURE_TEMPORAL_SCALABLE_EXTENSION_ID: |
- picture_temporal_scalable_extension(); |
- break; |
- case COPYRIGHT_EXTENSION_ID: |
- copyright_extension(); |
- break; |
- default: |
- cprintf("reserved extension start code ID %d\n",ext_ID); |
- break; |
- } |
- next_start_code(); |
- } |
- else |
- { |
-#ifdef VERBOSE |
- if (Verbose_Flag>NO_LAYER) |
- cprintf("user data\n"); |
-#endif /* VERBOSE */ |
- Flush_Buffer32(); |
- user_data(); |
- } |
- } |
-} |
- |
- |
-/* decode sequence extension */ |
- |
-/* ISO/IEC 13818-2 section 6.2.2.3 */ |
-static void sequence_extension() |
-{ |
- int horizontal_size_extension; |
- int vertical_size_extension; |
- int bit_rate_extension; |
- int vbv_buffer_size_extension; |
- |
- /* derive bit position for trace */ |
-#ifdef VERBOSE |
- pos = ld->Bitcnt; |
-#endif |
- |
- ld->MPEG2_Flag = 1; |
- |
- ld->scalable_mode = SC_NONE; /* unless overwritten by sequence_scalable_extension() */ |
- layer_id = 0; /* unless overwritten by sequence_scalable_extension() */ |
- |
- profile_and_level_indication = Get_Bits(8); |
- progressive_sequence = Get_Bits(1); |
- chroma_format = Get_Bits(2); |
- horizontal_size_extension = Get_Bits(2); |
- vertical_size_extension = Get_Bits(2); |
- bit_rate_extension = Get_Bits(12); |
- marker_bit("sequence_extension"); |
- vbv_buffer_size_extension = Get_Bits(8); |
- low_delay = Get_Bits(1); |
- frame_rate_extension_n = Get_Bits(2); |
- frame_rate_extension_d = Get_Bits(5); |
- |
- frame_rate = frame_rate_Table[frame_rate_code] * |
- ((frame_rate_extension_n+1)/(frame_rate_extension_d+1)); |
- |
- /* special case for 422 profile & level must be made */ |
- if((profile_and_level_indication>>7) & 1) |
- { /* escape bit of profile_and_level_indication set */ |
- |
- /* 4:2:2 Profile @ Main Level */ |
- if((profile_and_level_indication&15)==5) |
- { |
- profile = PROFILE_422; |
- level = MAIN_LEVEL; |
- } |
- } |
- else |
- { |
- profile = profile_and_level_indication >> 4; /* Profile is upper nibble */ |
- level = profile_and_level_indication & 0xF; /* Level is lower nibble */ |
- } |
- |
- |
- horizontal_size = (horizontal_size_extension<<12) | (horizontal_size&0x0fff); |
- vertical_size = (vertical_size_extension<<12) | (vertical_size&0x0fff); |
- |
- |
- /* ISO/IEC 13818-2 does not define bit_rate_value to be composed of |
- * both the original bit_rate_value parsed in sequence_header() and |
- * the optional bit_rate_extension in sequence_extension_header(). |
- * However, we use it for bitstream verification purposes. |
- */ |
- |
- bit_rate_value += (bit_rate_extension << 18); |
- bit_rate = ((double) bit_rate_value) * 400.0; |
- vbv_buffer_size += (vbv_buffer_size_extension << 10); |
- |
-#ifdef VERBOSE |
- if (Verbose_Flag>NO_LAYER) |
- { |
- cprintf("sequence extension (byte %d)\n",(pos>>3)-4); |
- |
- if (Verbose_Flag>SEQUENCE_LAYER) |
- { |
- cprintf(" profile_and_level_indication=%d\n",profile_and_level_indication); |
- |
- if (profile_and_level_indication<128) |
- { |
- cprintf(" profile=%d, level=%d\n",profile,level); |
- } |
- |
- cprintf(" progressive_sequence=%d\n",progressive_sequence); |
- cprintf(" chroma_format=%d\n",chroma_format); |
- cprintf(" horizontal_size_extension=%d\n",horizontal_size_extension); |
- cprintf(" vertical_size_extension=%d\n",vertical_size_extension); |
- cprintf(" bit_rate_extension=%d\n",bit_rate_extension); |
- cprintf(" vbv_buffer_size_extension=%d\n",vbv_buffer_size_extension); |
- cprintf(" low_delay=%d\n",low_delay); |
- cprintf(" frame_rate_extension_n=%d\n",frame_rate_extension_n); |
- cprintf(" frame_rate_extension_d=%d\n",frame_rate_extension_d); |
- } |
- } |
-#endif /* VERBOSE */ |
- |
-#ifdef VERIFY |
- verify_sequence_extension++; |
-#endif /* VERIFY */ |
- |
- |
-} |
- |
- |
-/* decode sequence display extension */ |
- |
-static void sequence_display_extension() |
-{ |
- int pos; |
- |
- pos = ld->Bitcnt; |
- video_format = Get_Bits(3); |
- color_description = Get_Bits(1); |
- |
- if (color_description) |
- { |
- color_primaries = Get_Bits(8); |
- transfer_characteristics = Get_Bits(8); |
- matrix_coefficients = Get_Bits(8); |
- } |
- |
- display_horizontal_size = Get_Bits(14); |
- marker_bit("sequence_display_extension"); |
- display_vertical_size = Get_Bits(14); |
- |
-#ifdef VERBOSE |
- if (Verbose_Flag>NO_LAYER) |
- { |
- cprintf("sequence display extension (byte %d)\n",(pos>>3)-4); |
- if (Verbose_Flag>SEQUENCE_LAYER) |
- { |
- |
- cprintf(" video_format=%d\n",video_format); |
- cprintf(" color_description=%d\n",color_description); |
- |
- if (color_description) |
- { |
- cprintf(" color_primaries=%d\n",color_primaries); |
- cprintf(" transfer_characteristics=%d\n",transfer_characteristics); |
- cprintf(" matrix_coefficients=%d\n",matrix_coefficients); |
- } |
- cprintf(" display_horizontal_size=%d\n",display_horizontal_size); |
- cprintf(" display_vertical_size=%d\n",display_vertical_size); |
- } |
- } |
-#endif /* VERBOSE */ |
- |
-#ifdef VERIFY |
- verify_sequence_display_extension++; |
-#endif /* VERIFY */ |
- |
-} |
- |
- |
-/* decode quant matrix entension */ |
-/* ISO/IEC 13818-2 section 6.2.3.2 */ |
-static void quant_matrix_extension() |
-{ |
- int i; |
- int pos; |
- |
- pos = ld->Bitcnt; |
- |
- if((ld->load_intra_quantizer_matrix = Get_Bits(1))) |
- { |
- for (i=0; i<64; i++) |
- { |
- ld->chroma_intra_quantizer_matrix[scan[ZIG_ZAG][i]] |
- = ld->intra_quantizer_matrix[scan[ZIG_ZAG][i]] |
- = Get_Bits(8); |
- } |
- } |
- |
- if((ld->load_non_intra_quantizer_matrix = Get_Bits(1))) |
- { |
- for (i=0; i<64; i++) |
- { |
- ld->chroma_non_intra_quantizer_matrix[scan[ZIG_ZAG][i]] |
- = ld->non_intra_quantizer_matrix[scan[ZIG_ZAG][i]] |
- = Get_Bits(8); |
- } |
- } |
- |
- if((ld->load_chroma_intra_quantizer_matrix = Get_Bits(1))) |
- { |
- for (i=0; i<64; i++) |
- ld->chroma_intra_quantizer_matrix[scan[ZIG_ZAG][i]] = Get_Bits(8); |
- } |
- |
- if((ld->load_chroma_non_intra_quantizer_matrix = Get_Bits(1))) |
- { |
- for (i=0; i<64; i++) |
- ld->chroma_non_intra_quantizer_matrix[scan[ZIG_ZAG][i]] = Get_Bits(8); |
- } |
- |
-#ifdef VERBOSE |
- if (Verbose_Flag>NO_LAYER) |
- { |
- cprintf("quant matrix extension (byte %d)\n",(pos>>3)-4); |
- cprintf(" load_intra_quantizer_matrix=%d\n", |
- ld->load_intra_quantizer_matrix); |
- cprintf(" load_non_intra_quantizer_matrix=%d\n", |
- ld->load_non_intra_quantizer_matrix); |
- cprintf(" load_chroma_intra_quantizer_matrix=%d\n", |
- ld->load_chroma_intra_quantizer_matrix); |
- cprintf(" load_chroma_non_intra_quantizer_matrix=%d\n", |
- ld->load_chroma_non_intra_quantizer_matrix); |
- } |
-#endif /* VERBOSE */ |
- |
-#ifdef VERIFY |
- verify_quant_matrix_extension++; |
-#endif /* VERIFY */ |
- |
-} |
- |
- |
-/* decode sequence scalable extension */ |
-/* ISO/IEC 13818-2 section 6.2.2.5 */ |
-static void sequence_scalable_extension() |
-{ |
- int pos; |
- |
- pos = ld->Bitcnt; |
- |
- /* values (without the +1 offset) of scalable_mode are defined in |
- Table 6-10 of ISO/IEC 13818-2 */ |
- ld->scalable_mode = Get_Bits(2) + 1; /* add 1 to make SC_DP != SC_NONE */ |
- |
- layer_id = Get_Bits(4); |
- |
- if (ld->scalable_mode==SC_SPAT) |
- { |
- lower_layer_prediction_horizontal_size = Get_Bits(14); |
- marker_bit("sequence_scalable_extension()"); |
- lower_layer_prediction_vertical_size = Get_Bits(14); |
- horizontal_subsampling_factor_m = Get_Bits(5); |
- horizontal_subsampling_factor_n = Get_Bits(5); |
- vertical_subsampling_factor_m = Get_Bits(5); |
- vertical_subsampling_factor_n = Get_Bits(5); |
- } |
- |
- if (ld->scalable_mode==SC_TEMP) |
- Error("temporal scalability not implemented\n"); |
- |
-#ifdef VERBOSE |
- if (Verbose_Flag>NO_LAYER) |
- { |
- cprintf("sequence scalable extension (byte %d)\n",(pos>>3)-4); |
- if (Verbose_Flag>SEQUENCE_LAYER) |
- { |
- cprintf(" scalable_mode=%d\n",ld->scalable_mode-1); |
- cprintf(" layer_id=%d\n",layer_id); |
- if (ld->scalable_mode==SC_SPAT) |
- { |
- cprintf(" lower_layer_prediction_horiontal_size=%d\n", |
- lower_layer_prediction_horizontal_size); |
- cprintf(" lower_layer_prediction_vertical_size=%d\n", |
- lower_layer_prediction_vertical_size); |
- cprintf(" horizontal_subsampling_factor_m=%d\n", |
- horizontal_subsampling_factor_m); |
- cprintf(" horizontal_subsampling_factor_n=%d\n", |
- horizontal_subsampling_factor_n); |
- cprintf(" vertical_subsampling_factor_m=%d\n", |
- vertical_subsampling_factor_m); |
- cprintf(" vertical_subsampling_factor_n=%d\n", |
- vertical_subsampling_factor_n); |
- } |
- } |
- } |
-#endif /* VERBOSE */ |
- |
-#ifdef VERIFY |
- verify_sequence_scalable_extension++; |
-#endif /* VERIFY */ |
- |
-} |
- |
- |
-/* decode picture display extension */ |
-/* ISO/IEC 13818-2 section 6.2.3.3. */ |
-static void picture_display_extension() |
-{ |
- int i; |
- int number_of_frame_center_offsets; |
- int pos; |
- |
- pos = ld->Bitcnt; |
- /* based on ISO/IEC 13818-2 section 6.3.12 |
- (November 1994) Picture display extensions */ |
- |
- /* derive number_of_frame_center_offsets */ |
- if(progressive_sequence) |
- { |
- if(repeat_first_field) |
- { |
- if(top_field_first) |
- number_of_frame_center_offsets = 3; |
- else |
- number_of_frame_center_offsets = 2; |
- } |
- else |
- { |
- number_of_frame_center_offsets = 1; |
- } |
- } |
- else |
- { |
- if(picture_structure!=FRAME_PICTURE) |
- { |
- number_of_frame_center_offsets = 1; |
- } |
- else |
- { |
- if(repeat_first_field) |
- number_of_frame_center_offsets = 3; |
- else |
- number_of_frame_center_offsets = 2; |
- } |
- } |
- |
- |
- /* now parse */ |
- for (i=0; i<number_of_frame_center_offsets; i++) |
- { |
- frame_center_horizontal_offset[i] = Get_Bits(16); |
- marker_bit("picture_display_extension, first marker bit"); |
- |
- frame_center_vertical_offset[i] = Get_Bits(16); |
- marker_bit("picture_display_extension, second marker bit"); |
- } |
- |
-#ifdef VERBOSE |
- if (Verbose_Flag>NO_LAYER) |
- { |
- cprintf("picture display extension (byte %d)\n",(pos>>3)-4); |
- if (Verbose_Flag>SEQUENCE_LAYER) |
- { |
- |
- for (i=0; i<number_of_frame_center_offsets; i++) |
- { |
- cprintf(" frame_center_horizontal_offset[%d]=%d\n",i, |
- frame_center_horizontal_offset[i]); |
- cprintf(" frame_center_vertical_offset[%d]=%d\n",i, |
- frame_center_vertical_offset[i]); |
- } |
- } |
- } |
-#endif /* VERBOSE */ |
- |
-#ifdef VERIFY |
- verify_picture_display_extension++; |
-#endif /* VERIFY */ |
- |
-} |
- |
- |
-/* decode picture coding extension */ |
-static void picture_coding_extension() |
-{ |
- int pos; |
- |
- pos = ld->Bitcnt; |
- |
- f_code[0][0] = Get_Bits(4); |
- f_code[0][1] = Get_Bits(4); |
- f_code[1][0] = Get_Bits(4); |
- f_code[1][1] = Get_Bits(4); |
- |
- intra_dc_precision = Get_Bits(2); |
- picture_structure = Get_Bits(2); |
- top_field_first = Get_Bits(1); |
- frame_pred_frame_dct = Get_Bits(1); |
- concealment_motion_vectors = Get_Bits(1); |
- ld->q_scale_type = Get_Bits(1); |
- intra_vlc_format = Get_Bits(1); |
- ld->alternate_scan = Get_Bits(1); |
- repeat_first_field = Get_Bits(1); |
- chroma_420_type = Get_Bits(1); |
- progressive_frame = Get_Bits(1); |
- composite_display_flag = Get_Bits(1); |
- |
- if (composite_display_flag) |
- { |
- v_axis = Get_Bits(1); |
- field_sequence = Get_Bits(3); |
- sub_carrier = Get_Bits(1); |
- burst_amplitude = Get_Bits(7); |
- sub_carrier_phase = Get_Bits(8); |
- } |
- |
-#ifdef VERBOSE |
- if (Verbose_Flag>NO_LAYER) |
- { |
- cprintf("picture coding extension (byte %d)\n",(pos>>3)-4); |
- if (Verbose_Flag>SEQUENCE_LAYER) |
- { |
- cprintf(" forward horizontal f_code=%d\n", f_code[0][0]); |
- cprintf(" forward vertical f_code=%d\n", f_code[0][1]); |
- cprintf(" backward horizontal f_code=%d\n", f_code[1][0]); |
- cprintf(" backward_vertical f_code=%d\n", f_code[1][1]); |
- cprintf(" intra_dc_precision=%d\n",intra_dc_precision); |
- cprintf(" picture_structure=%d\n",picture_structure); |
- cprintf(" top_field_first=%d\n",top_field_first); |
- cprintf(" frame_pred_frame_dct=%d\n",frame_pred_frame_dct); |
- cprintf(" concealment_motion_vectors=%d\n",concealment_motion_vectors); |
- cprintf(" q_scale_type=%d\n",ld->q_scale_type); |
- cprintf(" intra_vlc_format=%d\n",intra_vlc_format); |
- cprintf(" alternate_scan=%d\n",ld->alternate_scan); |
- cprintf(" repeat_first_field=%d\n",repeat_first_field); |
- cprintf(" chroma_420_type=%d\n",chroma_420_type); |
- cprintf(" progressive_frame=%d\n",progressive_frame); |
- cprintf(" composite_display_flag=%d\n",composite_display_flag); |
- |
- if (composite_display_flag) |
- { |
- cprintf(" v_axis=%d\n",v_axis); |
- cprintf(" field_sequence=%d\n",field_sequence); |
- cprintf(" sub_carrier=%d\n",sub_carrier); |
- cprintf(" burst_amplitude=%d\n",burst_amplitude); |
- cprintf(" sub_carrier_phase=%d\n",sub_carrier_phase); |
- } |
- } |
- } |
-#endif /* VERBOSE */ |
- |
-#ifdef VERIFY |
- verify_picture_coding_extension++; |
-#endif /* VERIFY */ |
-} |
- |
- |
-/* decode picture spatial scalable extension */ |
-/* ISO/IEC 13818-2 section 6.2.3.5. */ |
-static void picture_spatial_scalable_extension() |
-{ |
- int pos; |
- |
- pos = ld->Bitcnt; |
- |
- ld->pict_scal = 1; /* use spatial scalability in this picture */ |
- |
- lower_layer_temporal_reference = Get_Bits(10); |
- marker_bit("picture_spatial_scalable_extension(), first marker bit"); |
- lower_layer_horizontal_offset = Get_Bits(15); |
- if (lower_layer_horizontal_offset>=16384) |
- lower_layer_horizontal_offset-= 32768; |
- marker_bit("picture_spatial_scalable_extension(), second marker bit"); |
- lower_layer_vertical_offset = Get_Bits(15); |
- if (lower_layer_vertical_offset>=16384) |
- lower_layer_vertical_offset-= 32768; |
- spatial_temporal_weight_code_table_index = Get_Bits(2); |
- lower_layer_progressive_frame = Get_Bits(1); |
- lower_layer_deinterlaced_field_select = Get_Bits(1); |
- |
-#ifdef VERBOSE |
- if (Verbose_Flag>NO_LAYER) |
- { |
- cprintf("picture spatial scalable extension (byte %d)\n",(pos>>3)-4); |
- if (Verbose_Flag>SEQUENCE_LAYER) |
- { |
- cprintf(" lower_layer_temporal_reference=%d\n",lower_layer_temporal_reference); |
- cprintf(" lower_layer_horizontal_offset=%d\n",lower_layer_horizontal_offset); |
- cprintf(" lower_layer_vertical_offset=%d\n",lower_layer_vertical_offset); |
- cprintf(" spatial_temporal_weight_code_table_index=%d\n", |
- spatial_temporal_weight_code_table_index); |
- cprintf(" lower_layer_progressive_frame=%d\n",lower_layer_progressive_frame); |
- cprintf(" lower_layer_deinterlaced_field_select=%d\n",lower_layer_deinterlaced_field_select); |
- } |
- } |
-#endif /* VERBOSE */ |
- |
-#ifdef VERIFY |
- verify_picture_spatial_scalable_extension++; |
-#endif /* VERIFY */ |
- |
-} |
- |
- |
-/* decode picture temporal scalable extension |
- * |
- * not implemented |
- */ |
-/* ISO/IEC 13818-2 section 6.2.3.4. */ |
-static void picture_temporal_scalable_extension() |
-{ |
- Error("temporal scalability not supported\n"); |
- |
-#ifdef VERIFY |
- verify_picture_temporal_scalable_extension++; |
-#endif /* VERIFY */ |
-} |
- |
- |
-/* decode extra bit information */ |
-/* ISO/IEC 13818-2 section 6.2.3.4. */ |
-static int extra_bit_information() |
-{ |
- int Byte_Count = 0; |
- |
- while (Get_Bits1()) |
- { |
- Flush_Buffer(8); |
- Byte_Count++; |
- } |
- |
- return(Byte_Count); |
-} |
- |
- |
- |
-/* ISO/IEC 13818-2 section 5.3 */ |
-/* Purpose: this function is mainly designed to aid in bitstream conformance |
- testing. A simple Flush_Buffer(1) would do */ |
-void marker_bit(text) |
-char *text; |
-{ |
- int marker; |
- |
- marker = Get_Bits(1); |
- |
-#ifdef VERIFY |
- if(!marker) |
- cprintf("ERROR: %s--marker_bit set to 0",text); |
-#endif |
-} |
- |
- |
-/* ISO/IEC 13818-2 sections 6.3.4.1 and 6.2.2.2.2 */ |
-static void user_data() |
-{ |
- /* skip ahead to the next start code */ |
- next_start_code(); |
-} |
- |
- |
- |
-/* Copyright extension */ |
-/* ISO/IEC 13818-2 section 6.2.3.6. */ |
-/* (header added in November, 1994 to the IS document) */ |
- |
- |
-static void copyright_extension() |
-{ |
- int pos; |
- int reserved_data; |
- |
- pos = ld->Bitcnt; |
- |
- |
- copyright_flag = Get_Bits(1); |
- copyright_identifier = Get_Bits(8); |
- original_or_copy = Get_Bits(1); |
- |
- /* reserved */ |
- reserved_data = Get_Bits(7); |
- |
- marker_bit("copyright_extension(), first marker bit"); |
- copyright_number_1 = Get_Bits(20); |
- marker_bit("copyright_extension(), second marker bit"); |
- copyright_number_2 = Get_Bits(22); |
- marker_bit("copyright_extension(), third marker bit"); |
- copyright_number_3 = Get_Bits(22); |
- |
- if(Verbose_Flag>NO_LAYER) |
- { |
- cprintf("copyright_extension (byte %d)\n",(pos>>3)-4); |
- if (Verbose_Flag>SEQUENCE_LAYER) |
- { |
- cprintf(" copyright_flag =%d\n",copyright_flag); |
- |
- cprintf(" copyright_identifier=%d\n",copyright_identifier); |
- |
- cprintf(" original_or_copy = %d (original=1, copy=0)\n", |
- original_or_copy); |
- |
- cprintf(" copyright_number_1=%d\n",copyright_number_1); |
- cprintf(" copyright_number_2=%d\n",copyright_number_2); |
- cprintf(" copyright_number_3=%d\n",copyright_number_3); |
- } |
- } |
- |
-#ifdef VERIFY |
- verify_copyright_extension++; |
-#endif /* VERIFY */ |
-} |
- |
- |
- |
-/* introduced in September 1995 to assist Spatial Scalability */ |
-static void Update_Temporal_Reference_Tacking_Data() |
-{ |
- static int temporal_reference_wrap = 0; |
- static int temporal_reference_old = 0; |
- |
- if (ld == &base) /* *CH* */ |
- { |
- if (picture_coding_type!=B_TYPE && temporal_reference!=temporal_reference_old) |
- /* check first field of */ |
- { |
- /* non-B-frame */ |
- if (temporal_reference_wrap) |
- {/* wrap occured at previous I- or P-frame */ |
- /* now all intervening B-frames which could |
- still have high temporal_reference values are done */ |
- Temporal_Reference_Base += 1024; |
- temporal_reference_wrap = 0; |
- } |
- |
- /* distinguish from a reset */ |
- if (temporal_reference<temporal_reference_old && !Temporal_Reference_GOP_Reset) |
- temporal_reference_wrap = 1; /* we must have just passed a GOP-Header! */ |
- |
- temporal_reference_old = temporal_reference; |
- Temporal_Reference_GOP_Reset = 0; |
- } |
- |
- True_Framenum = Temporal_Reference_Base + temporal_reference; |
- |
- /* temporary wrap of TR at 1024 for M frames */ |
- if (temporal_reference_wrap && temporal_reference <= temporal_reference_old) |
- True_Framenum += 1024; |
- |
- True_Framenum_max = (True_Framenum > True_Framenum_max) ? |
- True_Framenum : True_Framenum_max; |
- } |
-} |
Index: tags/rel_1_22/fsf/mpeg2/idctref.c |
=================================================================== |
--- tags/rel_1_22/fsf/mpeg2/idctref.c (revision 1310) |
+++ tags/rel_1_22/fsf/mpeg2/idctref.c (nonexistent) |
@@ -1,108 +0,0 @@ |
-/* Reference_IDCT.c, Inverse Discrete Fourier Transform, double precision */ |
- |
-/* Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved. */ |
- |
-/* |
- * Disclaimer of Warranty |
- * |
- * These software programs are available to the user without any license fee or |
- * royalty on an "as is" basis. The MPEG Software Simulation Group disclaims |
- * any and all warranties, whether express, implied, or statuary, including any |
- * implied warranties or merchantability or of fitness for a particular |
- * purpose. In no event shall the copyright-holder be liable for any |
- * incidental, punitive, or consequential damages of any kind whatsoever |
- * arising from the use of these programs. |
- * |
- * This disclaimer of warranty extends to the user of these programs and user's |
- * customers, employees, agents, transferees, successors, and assigns. |
- * |
- * The MPEG Software Simulation Group does not represent or warrant that the |
- * programs furnished hereunder are free of infringement of any third-party |
- * patents. |
- * |
- * Commercial implementations of MPEG-1 and MPEG-2 video, including shareware, |
- * are subject to royalty fees to patent holders. Many of these patents are |
- * general enough such that they are unavoidable regardless of implementation |
- * design. |
- * |
- */ |
- |
-/* Perform IEEE 1180 reference (64-bit floating point, separable 8x1 |
- * direct matrix multiply) Inverse Discrete Cosine Transform |
-*/ |
- |
- |
-/* Here we use math.h to generate constants. Compiler results may |
- vary a little */ |
- |
-#include <math.h> |
- |
-#include "config.h" |
- |
-#ifndef PI |
-# ifdef M_PI |
-# define PI M_PI |
-# else |
-# define PI 3.14159265358979323846 |
-# endif |
-#endif |
- |
-/* global declarations */ |
-void Initialize_Fast_IDCTref _ANSI_ARGS_((void)); |
-void Reference_IDCT _ANSI_ARGS_((short *block)); |
- |
-/* private data */ |
- |
-/* cosine transform matrix for 8x1 IDCT */ |
-static double c[8][8]; |
- |
-/* initialize DCT coefficient matrix */ |
- |
-void Initialize_Reference_IDCT() |
-{ |
- int freq, time; |
- double scale; |
- |
- for (freq=0; freq < 8; freq++) |
- { |
- scale = (freq == 0) ? sqrt(0.125) : 0.5; |
- for (time=0; time<8; time++) |
- c[freq][time] = scale*cos((PI/8.0)*freq*(time + 0.5)); |
- } |
-} |
- |
-/* perform IDCT matrix multiply for 8x8 coefficient block */ |
- |
-void Reference_IDCT(block) |
-short *block; |
-{ |
- int i, j, k, v; |
- double partial_product; |
- double tmp[64]; |
- |
- for (i=0; i<8; i++) |
- for (j=0; j<8; j++) |
- { |
- partial_product = 0.0; |
- |
- for (k=0; k<8; k++) |
- partial_product+= c[k][j]*block[8*i+k]; |
- |
- tmp[8*i+j] = partial_product; |
- } |
- |
- /* Transpose operation is integrated into address mapping by switching |
- loop order of i and j */ |
- |
- for (j=0; j<8; j++) |
- for (i=0; i<8; i++) |
- { |
- partial_product = 0.0; |
- |
- for (k=0; k<8; k++) |
- partial_product+= c[k][i]*tmp[8*k+j]; |
- |
- v = (int) floor(partial_product+0.5); |
- block[8*i+j] = (v<-256) ? -256 : ((v>255) ? 255 : v); |
- } |
-} |
Index: tags/rel_1_22/fsf/mpeg2/idct.c |
=================================================================== |
--- tags/rel_1_22/fsf/mpeg2/idct.c (revision 1310) |
+++ tags/rel_1_22/fsf/mpeg2/idct.c (nonexistent) |
@@ -1,211 +0,0 @@ |
-/* idct.c, inverse fast discrete cosine transform */ |
- |
-/* Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved. */ |
- |
-/* |
- * Disclaimer of Warranty |
- * |
- * These software programs are available to the user without any license fee or |
- * royalty on an "as is" basis. The MPEG Software Simulation Group disclaims |
- * any and all warranties, whether express, implied, or statuary, including any |
- * implied warranties or merchantability or of fitness for a particular |
- * purpose. In no event shall the copyright-holder be liable for any |
- * incidental, punitive, or consequential damages of any kind whatsoever |
- * arising from the use of these programs. |
- * |
- * This disclaimer of warranty extends to the user of these programs and user's |
- * customers, employees, agents, transferees, successors, and assigns. |
- * |
- * The MPEG Software Simulation Group does not represent or warrant that the |
- * programs furnished hereunder are free of infringement of any third-party |
- * patents. |
- * |
- * Commercial implementations of MPEG-1 and MPEG-2 video, including shareware, |
- * are subject to royalty fees to patent holders. Many of these patents are |
- * general enough such that they are unavoidable regardless of implementation |
- * design. |
- * |
- */ |
- |
-/**********************************************************/ |
-/* inverse two dimensional DCT, Chen-Wang algorithm */ |
-/* (cf. IEEE ASSP-32, pp. 803-816, Aug. 1984) */ |
-/* 32-bit integer arithmetic (8 bit coefficients) */ |
-/* 11 mults, 29 adds per DCT */ |
-/* sE, 18.8.91 */ |
-/**********************************************************/ |
-/* coefficients extended to 12 bit for IEEE1180-1990 */ |
-/* compliance sE, 2.1.94 */ |
-/**********************************************************/ |
- |
-/* this code assumes >> to be a two's-complement arithmetic */ |
-/* right shift: (-2)>>1 == -1 , (-3)>>1 == -2 */ |
- |
-#include "config.h" |
- |
-#define W1 2841 /* 2048*sqrt(2)*cos(1*pi/16) */ |
-#define W2 2676 /* 2048*sqrt(2)*cos(2*pi/16) */ |
-#define W3 2408 /* 2048*sqrt(2)*cos(3*pi/16) */ |
-#define W5 1609 /* 2048*sqrt(2)*cos(5*pi/16) */ |
-#define W6 1108 /* 2048*sqrt(2)*cos(6*pi/16) */ |
-#define W7 565 /* 2048*sqrt(2)*cos(7*pi/16) */ |
- |
-/* global declarations */ |
-void Initialize_Fast_IDCT _ANSI_ARGS_((void)); |
-void Fast_IDCT _ANSI_ARGS_((short *block)); |
- |
-/* private data */ |
-static short iclip[1024]; /* clipping table */ |
-static short *iclp; |
- |
-/* private prototypes */ |
-static void idctrow _ANSI_ARGS_((short *blk)); |
-static void idctcol _ANSI_ARGS_((short *blk)); |
- |
-/* row (horizontal) IDCT |
- * |
- * 7 pi 1 |
- * dst[k] = sum c[l] * src[l] * cos( -- * ( k + - ) * l ) |
- * l=0 8 2 |
- * |
- * where: c[0] = 128 |
- * c[1..7] = 128*sqrt(2) |
- */ |
- |
-static void idctrow(blk) |
-short *blk; |
-{ |
- int x0, x1, x2, x3, x4, x5, x6, x7, x8; |
- |
- /* shortcut */ |
- if (!((x1 = blk[4]<<11) | (x2 = blk[6]) | (x3 = blk[2]) | |
- (x4 = blk[1]) | (x5 = blk[7]) | (x6 = blk[5]) | (x7 = blk[3]))) |
- { |
- blk[0]=blk[1]=blk[2]=blk[3]=blk[4]=blk[5]=blk[6]=blk[7]=blk[0]<<3; |
- return; |
- } |
- |
- x0 = (blk[0]<<11) + 128; /* for proper rounding in the fourth stage */ |
- |
- /* first stage */ |
- x8 = W7*(x4+x5); |
- x4 = x8 + (W1-W7)*x4; |
- x5 = x8 - (W1+W7)*x5; |
- x8 = W3*(x6+x7); |
- x6 = x8 - (W3-W5)*x6; |
- x7 = x8 - (W3+W5)*x7; |
- |
- /* second stage */ |
- x8 = x0 + x1; |
- x0 -= x1; |
- x1 = W6*(x3+x2); |
- x2 = x1 - (W2+W6)*x2; |
- x3 = x1 + (W2-W6)*x3; |
- x1 = x4 + x6; |
- x4 -= x6; |
- x6 = x5 + x7; |
- x5 -= x7; |
- |
- /* third stage */ |
- x7 = x8 + x3; |
- x8 -= x3; |
- x3 = x0 + x2; |
- x0 -= x2; |
- x2 = (181*(x4+x5)+128)>>8; |
- x4 = (181*(x4-x5)+128)>>8; |
- |
- /* fourth stage */ |
- blk[0] = (x7+x1)>>8; |
- blk[1] = (x3+x2)>>8; |
- blk[2] = (x0+x4)>>8; |
- blk[3] = (x8+x6)>>8; |
- blk[4] = (x8-x6)>>8; |
- blk[5] = (x0-x4)>>8; |
- blk[6] = (x3-x2)>>8; |
- blk[7] = (x7-x1)>>8; |
-} |
- |
-/* column (vertical) IDCT |
- * |
- * 7 pi 1 |
- * dst[8*k] = sum c[l] * src[8*l] * cos( -- * ( k + - ) * l ) |
- * l=0 8 2 |
- * |
- * where: c[0] = 1/1024 |
- * c[1..7] = (1/1024)*sqrt(2) |
- */ |
-static void idctcol(blk) |
-short *blk; |
-{ |
- int x0, x1, x2, x3, x4, x5, x6, x7, x8; |
- |
- /* shortcut */ |
- if (!((x1 = (blk[8*4]<<8)) | (x2 = blk[8*6]) | (x3 = blk[8*2]) | |
- (x4 = blk[8*1]) | (x5 = blk[8*7]) | (x6 = blk[8*5]) | (x7 = blk[8*3]))) |
- { |
- blk[8*0]=blk[8*1]=blk[8*2]=blk[8*3]=blk[8*4]=blk[8*5]=blk[8*6]=blk[8*7]= |
- iclp[(blk[8*0]+32)>>6]; |
- return; |
- } |
- |
- x0 = (blk[8*0]<<8) + 8192; |
- |
- /* first stage */ |
- x8 = W7*(x4+x5) + 4; |
- x4 = (x8+(W1-W7)*x4)>>3; |
- x5 = (x8-(W1+W7)*x5)>>3; |
- x8 = W3*(x6+x7) + 4; |
- x6 = (x8-(W3-W5)*x6)>>3; |
- x7 = (x8-(W3+W5)*x7)>>3; |
- |
- /* second stage */ |
- x8 = x0 + x1; |
- x0 -= x1; |
- x1 = W6*(x3+x2) + 4; |
- x2 = (x1-(W2+W6)*x2)>>3; |
- x3 = (x1+(W2-W6)*x3)>>3; |
- x1 = x4 + x6; |
- x4 -= x6; |
- x6 = x5 + x7; |
- x5 -= x7; |
- |
- /* third stage */ |
- x7 = x8 + x3; |
- x8 -= x3; |
- x3 = x0 + x2; |
- x0 -= x2; |
- x2 = (181*(x4+x5)+128)>>8; |
- x4 = (181*(x4-x5)+128)>>8; |
- |
- /* fourth stage */ |
- blk[8*0] = iclp[(x7+x1)>>14]; |
- blk[8*1] = iclp[(x3+x2)>>14]; |
- blk[8*2] = iclp[(x0+x4)>>14]; |
- blk[8*3] = iclp[(x8+x6)>>14]; |
- blk[8*4] = iclp[(x8-x6)>>14]; |
- blk[8*5] = iclp[(x0-x4)>>14]; |
- blk[8*6] = iclp[(x3-x2)>>14]; |
- blk[8*7] = iclp[(x7-x1)>>14]; |
-} |
- |
-/* two dimensional inverse discrete cosine transform */ |
-void Fast_IDCT(block) |
-short *block; |
-{ |
- int i; |
- |
- for (i=0; i<8; i++) |
- idctrow(block+8*i); |
- |
- for (i=0; i<8; i++) |
- idctcol(block+i); |
-} |
- |
-void Initialize_Fast_IDCT() |
-{ |
- int i; |
- |
- iclp = iclip+512; |
- for (i= -512; i<512; i++) |
- iclp[i] = (i<-256) ? -256 : ((i>255) ? 255 : i); |
-} |
Index: tags/rel_1_22/fsf/mpeg2/getvlc.c |
=================================================================== |
--- tags/rel_1_22/fsf/mpeg2/getvlc.c (revision 1310) |
+++ tags/rel_1_22/fsf/mpeg2/getvlc.c (nonexistent) |
@@ -1,797 +0,0 @@ |
-/* getvlc.c, variable length decoding */ |
- |
-/* Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved. */ |
- |
-/* |
- * Disclaimer of Warranty |
- * |
- * These software programs are available to the user without any license fee or |
- * royalty on an "as is" basis. The MPEG Software Simulation Group disclaims |
- * any and all warranties, whether express, implied, or statuary, including any |
- * implied warranties or merchantability or of fitness for a particular |
- * purpose. In no event shall the copyright-holder be liable for any |
- * incidental, punitive, or consequential damages of any kind whatsoever |
- * arising from the use of these programs. |
- * |
- * This disclaimer of warranty extends to the user of these programs and user's |
- * customers, employees, agents, transferees, successors, and assigns. |
- * |
- * The MPEG Software Simulation Group does not represent or warrant that the |
- * programs furnished hereunder are free of infringement of any third-party |
- * patents. |
- * |
- * Commercial implementations of MPEG-1 and MPEG-2 video, including shareware, |
- * are subject to royalty fees to patent holders. Many of these patents are |
- * general enough such that they are unavoidable regardless of implementation |
- * design. |
- * |
- */ |
- |
-#include "config.h" |
-#include "global.h" |
-#include "getvlc.h" |
- |
-/* private prototypes */ |
-/* generic picture macroblock type processing functions */ |
-static int Get_I_macroblock_type _ANSI_ARGS_((void)); |
-static int Get_P_macroblock_type _ANSI_ARGS_((void)); |
-static int Get_B_macroblock_type _ANSI_ARGS_((void)); |
-static int Get_D_macroblock_type _ANSI_ARGS_((void)); |
- |
-/* spatial picture macroblock type processing functions */ |
-static int Get_I_Spatial_macroblock_type _ANSI_ARGS_((void)); |
-static int Get_P_Spatial_macroblock_type _ANSI_ARGS_((void)); |
-static int Get_B_Spatial_macroblock_type _ANSI_ARGS_((void)); |
-static int Get_SNR_macroblock_type _ANSI_ARGS_((void)); |
- |
-int Get_macroblock_type() |
-{ |
- int macroblock_type = 0; |
- |
- if (ld->scalable_mode==SC_SNR) |
- macroblock_type = Get_SNR_macroblock_type(); |
- else |
- { |
- switch (picture_coding_type) |
- { |
- case I_TYPE: |
- macroblock_type = ld->pict_scal ? Get_I_Spatial_macroblock_type() : Get_I_macroblock_type(); |
- break; |
- case P_TYPE: |
- macroblock_type = ld->pict_scal ? Get_P_Spatial_macroblock_type() : Get_P_macroblock_type(); |
- break; |
- case B_TYPE: |
- macroblock_type = ld->pict_scal ? Get_B_Spatial_macroblock_type() : Get_B_macroblock_type(); |
- break; |
- case D_TYPE: |
- macroblock_type = Get_D_macroblock_type(); |
- break; |
- default: |
- cprintf("Get_macroblock_type(): unrecognized picture coding type\n"); |
- break; |
- } |
- } |
- |
- return macroblock_type; |
-} |
- |
-static int Get_I_macroblock_type() |
-{ |
-#ifdef TRACE |
- if (Trace_Flag) |
- cprintf("macroblock_type(I) "); |
-#endif /* TRACE */ |
- |
- if (Get_Bits1()) |
- { |
-#ifdef TRACE |
- if (Trace_Flag) |
- cprintf("(1): Intra (1)\n"); |
-#endif /* TRACE */ |
- return 1; |
- } |
- |
- if (!Get_Bits1()) |
- { |
- if (!Quiet_Flag) |
- cprintf("Invalid macroblock_type code\n"); |
- Fault_Flag = 1; |
- } |
- |
-#ifdef TRACE |
- if (Trace_Flag) |
- cprintf("(01): Intra, Quant (17)\n"); |
-#endif /* TRACE */ |
- |
- return 17; |
-} |
- |
-static char *MBdescr[]={ |
- "", "Intra", "No MC, Coded", "", |
- "Bwd, Not Coded", "", "Bwd, Coded", "", |
- "Fwd, Not Coded", "", "Fwd, Coded", "", |
- "Interp, Not Coded", "", "Interp, Coded", "", |
- "", "Intra, Quant", "No MC, Coded, Quant", "", |
- "", "", "Bwd, Coded, Quant", "", |
- "", "", "Fwd, Coded, Quant", "", |
- "", "", "Interp, Coded, Quant", "" |
-}; |
- |
-static int Get_P_macroblock_type() |
-{ |
- int code; |
- |
-#ifdef TRACE |
- if (Trace_Flag) |
- cprintf("macroblock_type(P) ("); |
-#endif /* TRACE */ |
- |
- if ((code = Show_Bits(6))>=8) |
- { |
- code >>= 3; |
- Flush_Buffer(PMBtab0[code].len); |
-#ifdef TRACE |
- if (Trace_Flag) |
- { |
- Print_Bits(code,3,PMBtab0[code].len); |
- cprintf("): %s (%d)\n",MBdescr[(int)PMBtab0[code].val],PMBtab0[code].val); |
- } |
-#endif /* TRACE */ |
- return PMBtab0[code].val; |
- } |
- |
- if (code==0) |
- { |
- if (!Quiet_Flag) |
- cprintf("Invalid macroblock_type code\n"); |
- Fault_Flag = 1; |
- return 0; |
- } |
- |
- Flush_Buffer(PMBtab1[code].len); |
- |
-#ifdef TRACE |
- if (Trace_Flag) |
- { |
- Print_Bits(code,6,PMBtab1[code].len); |
- cprintf("): %s (%d)\n",MBdescr[(int)PMBtab1[code].val],PMBtab1[code].val); |
- } |
-#endif /* TRACE */ |
- |
- return PMBtab1[code].val; |
-} |
- |
-static int Get_B_macroblock_type() |
-{ |
- int code; |
- |
-#ifdef TRACE |
- if (Trace_Flag) |
- cprintf("macroblock_type(B) ("); |
-#endif /* TRACE */ |
- |
- if ((code = Show_Bits(6))>=8) |
- { |
- code >>= 2; |
- Flush_Buffer(BMBtab0[code].len); |
- |
-#ifdef TRACE |
- if (Trace_Flag) |
- { |
- Print_Bits(code,4,BMBtab0[code].len); |
- cprintf("): %s (%d)\n",MBdescr[(int)BMBtab0[code].val],BMBtab0[code].val); |
- } |
-#endif /* TRACE */ |
- |
- return BMBtab0[code].val; |
- } |
- |
- if (code==0) |
- { |
- if (!Quiet_Flag) |
- cprintf("Invalid macroblock_type code\n"); |
- Fault_Flag = 1; |
- return 0; |
- } |
- |
- Flush_Buffer(BMBtab1[code].len); |
- |
-#ifdef TRACE |
- if (Trace_Flag) |
- { |
- Print_Bits(code,6,BMBtab1[code].len); |
- cprintf("): %s (%d)\n",MBdescr[(int)BMBtab1[code].val],BMBtab1[code].val); |
- } |
-#endif /* TRACE */ |
- |
- return BMBtab1[code].val; |
-} |
- |
-static int Get_D_macroblock_type() |
-{ |
- if (!Get_Bits1()) |
- { |
- if (!Quiet_Flag) |
- cprintf("Invalid macroblock_type code\n"); |
- Fault_Flag=1; |
- } |
- |
- return 1; |
-} |
- |
-/* macroblock_type for pictures with spatial scalability */ |
-static int Get_I_Spatial_macroblock_type() |
-{ |
- int code; |
- |
-#ifdef TRACE |
- if (Trace_Flag) |
- cprintf("macroblock_type(I,spat) ("); |
-#endif /* TRACE */ |
- |
- code = Show_Bits(4); |
- |
- if (code==0) |
- { |
- if (!Quiet_Flag) |
- cprintf("Invalid macroblock_type code\n"); |
- Fault_Flag = 1; |
- return 0; |
- } |
- |
-#ifdef TRACE |
- if (Trace_Flag) |
- { |
- Print_Bits(code,4,spIMBtab[code].len); |
- cprintf("): %02x\n",spIMBtab[code].val); |
- } |
-#endif /* TRACE */ |
- |
- Flush_Buffer(spIMBtab[code].len); |
- return spIMBtab[code].val; |
-} |
- |
-static int Get_P_Spatial_macroblock_type() |
-{ |
- int code; |
- |
-#ifdef TRACE |
- if (Trace_Flag) |
- cprintf("macroblock_type(P,spat) ("); |
-#endif /* TRACE */ |
- |
- code = Show_Bits(7); |
- |
- if (code<2) |
- { |
- if (!Quiet_Flag) |
- cprintf("Invalid macroblock_type code\n"); |
- Fault_Flag = 1; |
- return 0; |
- } |
- |
- if (code>=16) |
- { |
- code >>= 3; |
- Flush_Buffer(spPMBtab0[code].len); |
- |
-#ifdef TRACE |
- if (Trace_Flag) |
- { |
- Print_Bits(code,4,spPMBtab0[code].len); |
- cprintf("): %02x\n",spPMBtab0[code].val); |
- } |
-#endif /* TRACE */ |
- |
- return spPMBtab0[code].val; |
- } |
- |
- Flush_Buffer(spPMBtab1[code].len); |
- |
-#ifdef TRACE |
- if (Trace_Flag) |
- { |
- Print_Bits(code,7,spPMBtab1[code].len); |
- cprintf("): %02x\n",spPMBtab1[code].val); |
- } |
-#endif /* TRACE */ |
- |
- return spPMBtab1[code].val; |
-} |
- |
-static int Get_B_Spatial_macroblock_type() |
-{ |
- int code; |
- VLCtab *p; |
- |
-#ifdef TRACE |
- if (Trace_Flag) |
- cprintf("macroblock_type(B,spat) ("); |
-#endif /* TRACE */ |
- |
- code = Show_Bits(9); |
- |
- if (code>=64) |
- p = &spBMBtab0[(code>>5)-2]; |
- else if (code>=16) |
- p = &spBMBtab1[(code>>2)-4]; |
- else if (code>=8) |
- p = &spBMBtab2[code-8]; |
- else |
- { |
- if (!Quiet_Flag) |
- cprintf("Invalid macroblock_type code\n"); |
- Fault_Flag = 1; |
- return 0; |
- } |
- |
- Flush_Buffer(p->len); |
- |
-#ifdef TRACE |
- if (Trace_Flag) |
- { |
- Print_Bits(code,9,p->len); |
- printf("): %02x\n",p->val); |
- } |
-#endif /* TRACE */ |
- |
- return p->val; |
-} |
- |
-static int Get_SNR_macroblock_type() |
-{ |
- int code; |
- |
-#ifdef TRACE /* *CH* */ |
- if (Trace_Flag) |
- cprintf("macroblock_type(SNR) ("); |
-#endif |
- |
- code = Show_Bits(3); |
- |
- if (code==0) |
- { |
- if (!Quiet_Flag) |
- cprintf("Invalid macroblock_type code\n"); |
- Fault_Flag = 1; |
- return 0; |
- } |
- |
- Flush_Buffer(SNRMBtab[code].len); |
- |
-#ifdef TRACE /* *CH* */ |
- if (Trace_Flag) |
- { |
- Print_Bits(code,3,SNRMBtab[code].len); |
- cprintf("): %s (%d)\n",MBdescr[(int)SNRMBtab[code].val],SNRMBtab[code].val); |
- } |
-#endif |
- |
- |
- return SNRMBtab[code].val; |
-} |
- |
-int Get_motion_code() |
-{ |
- int code; |
- |
-#ifdef TRACE |
- if (Trace_Flag) |
- cprintf("motion_code ("); |
-#endif /* TRACE */ |
- |
- if (Get_Bits1()) |
- { |
-#ifdef TRACE |
- if (Trace_Flag) |
- cprintf("0): 0\n"); |
-#endif /* TRACE */ |
- return 0; |
- } |
- |
- if ((code = Show_Bits(9))>=64) |
- { |
- code >>= 6; |
- Flush_Buffer(MVtab0[code].len); |
- |
-#ifdef TRACE |
- if (Trace_Flag) |
- { |
- Print_Bits(code,3,MVtab0[code].len); |
- cprintf("%d): %d\n", |
- Show_Bits(1),Show_Bits(1)?-MVtab0[code].val:MVtab0[code].val); |
- } |
-#endif /* TRACE */ |
- |
- return Get_Bits1()?-MVtab0[code].val:MVtab0[code].val; |
- } |
- |
- if (code>=24) |
- { |
- code >>= 3; |
- Flush_Buffer(MVtab1[code].len); |
- |
-#ifdef TRACE |
- if (Trace_Flag) |
- { |
- Print_Bits(code,6,MVtab1[code].len); |
- cprintf("%d): %d\n", |
- Show_Bits(1),Show_Bits(1)?-MVtab1[code].val:MVtab1[code].val); |
- } |
-#endif /* TRACE */ |
- |
- return Get_Bits1()?-MVtab1[code].val:MVtab1[code].val; |
- } |
- |
- if ((code-=12)<0) |
- { |
- if (!Quiet_Flag) |
-/* HACK */ |
- cprintf("Invalid motion_vector code (MBA %d, pic %d)\n", global_MBA, global_pic); |
- Fault_Flag=1; |
- return 0; |
- } |
- |
- Flush_Buffer(MVtab2[code].len); |
- |
-#ifdef TRACE |
- if (Trace_Flag) |
- { |
- Print_Bits(code+12,9,MVtab2[code].len); |
- cprintf("%d): %d\n", |
- Show_Bits(1),Show_Bits(1)?-MVtab2[code].val:MVtab2[code].val); |
- } |
-#endif /* TRACE */ |
- |
- return Get_Bits1() ? -MVtab2[code].val : MVtab2[code].val; |
-} |
- |
-/* get differential motion vector (for dual prime prediction) */ |
-int Get_dmvector() |
-{ |
-#ifdef TRACE |
- if (Trace_Flag) |
- cprintf("dmvector ("); |
-#endif /* TRACE */ |
- |
- if (Get_Bits(1)) |
- { |
-#ifdef TRACE |
- if (Trace_Flag) |
- cprintf(Show_Bits(1) ? "11): -1\n" : "10): 1\n"); |
-#endif /* TRACE */ |
- return Get_Bits(1) ? -1 : 1; |
- } |
- else |
- { |
-#ifdef TRACE |
- if (Trace_Flag) |
- cprintf("0): 0\n"); |
-#endif /* TRACE */ |
- return 0; |
- } |
-} |
- |
-int Get_coded_block_pattern() |
-{ |
- int code; |
- |
-#ifdef TRACE |
- if (Trace_Flag) |
- cprintf("coded_block_pattern_420 ("); |
-#endif /* TRACE */ |
- |
- if ((code = Show_Bits(9))>=128) |
- { |
- code >>= 4; |
- Flush_Buffer(CBPtab0[code].len); |
- |
-#ifdef TRACE |
- if (Trace_Flag) |
- { |
- Print_Bits(code,5,CBPtab0[code].len); |
- cprintf("): "); |
- Print_Bits(CBPtab0[code].val,6,6); |
- cprintf(" (%d)\n",CBPtab0[code].val); |
- } |
-#endif /* TRACE */ |
- |
- return CBPtab0[code].val; |
- } |
- |
- if (code>=8) |
- { |
- code >>= 1; |
- Flush_Buffer(CBPtab1[code].len); |
- |
-#ifdef TRACE |
- if (Trace_Flag) |
- { |
- Print_Bits(code,8,CBPtab1[code].len); |
- cprintf("): "); |
- Print_Bits(CBPtab1[code].val,6,6); |
- cprintf(" (%d)\n",CBPtab1[code].val); |
- } |
-#endif /* TRACE */ |
- |
- return CBPtab1[code].val; |
- } |
- |
- if (code<1) |
- { |
- if (!Quiet_Flag) |
- cprintf("Invalid coded_block_pattern code\n"); |
- Fault_Flag = 1; |
- return 0; |
- } |
- |
- Flush_Buffer(CBPtab2[code].len); |
- |
-#ifdef TRACE |
- if (Trace_Flag) |
- { |
- Print_Bits(code,9,CBPtab2[code].len); |
- cprintf("): "); |
- Print_Bits(CBPtab2[code].val,6,6); |
- cprintf(" (%d)\n",CBPtab2[code].val); |
- } |
-#endif /* TRACE */ |
- |
- return CBPtab2[code].val; |
-} |
- |
-int Get_macroblock_address_increment() |
-{ |
- int code, val; |
- |
-#ifdef TRACE |
- if (Trace_Flag) |
- cprintf("macroblock_address_increment ("); |
-#endif /* TRACE */ |
- |
- val = 0; |
- |
- while ((code = Show_Bits(11))<24) |
- { |
- if (code!=15) /* if not macroblock_stuffing */ |
- { |
- if (code==8) /* if macroblock_escape */ |
- { |
-#ifdef TRACE |
- if (Trace_Flag) |
- cprintf("00000001000 "); |
-#endif /* TRACE */ |
- |
- val+= 33; |
- } |
- else |
- { |
- if (!Quiet_Flag) |
- cprintf("Invalid macroblock_address_increment code\n"); |
- |
- Fault_Flag = 1; |
- return 1; |
- } |
- } |
- else /* macroblock suffing */ |
- { |
-#ifdef TRACE |
- if (Trace_Flag) |
- cprintf("00000001111 "); |
-#endif /* TRACE */ |
- } |
- |
- Flush_Buffer(11); |
- } |
- |
- /* macroblock_address_increment == 1 */ |
- /* ('1' is in the MSB position of the lookahead) */ |
- if (code>=1024) |
- { |
- Flush_Buffer(1); |
-#ifdef TRACE |
- if (Trace_Flag) |
- cprintf("1): %d\n",val+1); |
-#endif /* TRACE */ |
- return val + 1; |
- } |
- |
- /* codes 00010 ... 011xx */ |
- if (code>=128) |
- { |
- /* remove leading zeros */ |
- code >>= 6; |
- Flush_Buffer(MBAtab1[code].len); |
- |
-#ifdef TRACE |
- if (Trace_Flag) |
- { |
- Print_Bits(code,5,MBAtab1[code].len); |
- printf("): %d\n",val+MBAtab1[code].val); |
- } |
-#endif /* TRACE */ |
- |
- |
- return val + MBAtab1[code].val; |
- } |
- |
- /* codes 00000011000 ... 0000111xxxx */ |
- code-= 24; /* remove common base */ |
- Flush_Buffer(MBAtab2[code].len); |
- |
-#ifdef TRACE |
- if (Trace_Flag) |
- { |
- Print_Bits(code+24,11,MBAtab2[code].len); |
- cprintf("): %d\n",val+MBAtab2[code].val); |
- } |
-#endif /* TRACE */ |
- |
- return val + MBAtab2[code].val; |
-} |
- |
-/* combined MPEG-1 and MPEG-2 stage. parse VLC and |
- perform dct_diff arithmetic. |
- |
- MPEG-1: ISO/IEC 11172-2 section |
- MPEG-2: ISO/IEC 13818-2 section 7.2.1 |
- |
- Note: the arithmetic here is presented more elegantly than |
- the spec, yet the results, dct_diff, are the same. |
-*/ |
- |
-int Get_Luma_DC_dct_diff() |
-{ |
- int code, size, dct_diff; |
- |
-#ifdef TRACE |
-/* |
- if (Trace_Flag) |
- printf("dct_dc_size_luminance: ("); |
-*/ |
-#endif /* TRACE */ |
- |
- /* decode length */ |
- code = Show_Bits(5); |
- |
- if (code<31) |
- { |
- size = DClumtab0[code].val; |
- Flush_Buffer(DClumtab0[code].len); |
-#ifdef TRACE |
-/* |
- if (Trace_Flag) |
- { |
- Print_Bits(code,5,DClumtab0[code].len); |
- printf("): %d",size); |
- } |
-*/ |
-#endif /* TRACE */ |
- } |
- else |
- { |
- code = Show_Bits(9) - 0x1f0; |
- size = DClumtab1[code].val; |
- Flush_Buffer(DClumtab1[code].len); |
- |
-#ifdef TRACE |
-/* |
- if (Trace_Flag) |
- { |
- Print_Bits(code+0x1f0,9,DClumtab1[code].len); |
- printf("): %d",size); |
- } |
-*/ |
-#endif /* TRACE */ |
- } |
- |
-#ifdef TRACE |
-/* |
- if (Trace_Flag) |
- printf(", dct_dc_differential ("); |
-*/ |
-#endif /* TRACE */ |
- |
- if (size==0) |
- dct_diff = 0; |
- else |
- { |
- dct_diff = Get_Bits(size); |
-#ifdef TRACE |
-/* |
- if (Trace_Flag) |
- Print_Bits(dct_diff,size,size); |
-*/ |
-#endif /* TRACE */ |
- if ((dct_diff & (1<<(size-1)))==0) |
- dct_diff-= (1<<size) - 1; |
- } |
- |
-#ifdef TRACE |
-/* |
- if (Trace_Flag) |
- printf("): %d\n",dct_diff); |
-*/ |
-#endif /* TRACE */ |
- |
- return dct_diff; |
-} |
- |
- |
-int Get_Chroma_DC_dct_diff() |
-{ |
- int code, size, dct_diff; |
- |
-#ifdef TRACE |
-/* |
- if (Trace_Flag) |
- printf("dct_dc_size_chrominance: ("); |
-*/ |
-#endif /* TRACE */ |
- |
- /* decode length */ |
- code = Show_Bits(5); |
- |
- if (code<31) |
- { |
- size = DCchromtab0[code].val; |
- Flush_Buffer(DCchromtab0[code].len); |
- |
-#ifdef TRACE |
-/* |
- if (Trace_Flag) |
- { |
- Print_Bits(code,5,DCchromtab0[code].len); |
- printf("): %d",size); |
- } |
-*/ |
-#endif /* TRACE */ |
- } |
- else |
- { |
- code = Show_Bits(10) - 0x3e0; |
- size = DCchromtab1[code].val; |
- Flush_Buffer(DCchromtab1[code].len); |
- |
-#ifdef TRACE |
-/* |
- if (Trace_Flag) |
- { |
- Print_Bits(code+0x3e0,10,DCchromtab1[code].len); |
- printf("): %d",size); |
- } |
-*/ |
-#endif /* TRACE */ |
- } |
- |
-#ifdef TRACE |
-/* |
- if (Trace_Flag) |
- printf(", dct_dc_differential ("); |
-*/ |
-#endif /* TRACE */ |
- |
- if (size==0) |
- dct_diff = 0; |
- else |
- { |
- dct_diff = Get_Bits(size); |
-#ifdef TRACE |
-/* |
- if (Trace_Flag) |
- Print_Bits(dct_diff,size,size); |
-*/ |
-#endif /* TRACE */ |
- if ((dct_diff & (1<<(size-1)))==0) |
- dct_diff-= (1<<size) - 1; |
- } |
- |
-#ifdef TRACE |
-/* |
- if (Trace_Flag) |
- printf("): %d\n",dct_diff); |
-*/ |
-#endif /* TRACE */ |
- |
- return dct_diff; |
-} |
Index: tags/rel_1_22/fsf/mpeg2/mpeg2dec.c |
=================================================================== |
--- tags/rel_1_22/fsf/mpeg2/mpeg2dec.c (revision 1310) |
+++ tags/rel_1_22/fsf/mpeg2/mpeg2dec.c (nonexistent) |
@@ -1,495 +0,0 @@ |
- |
-/* mpeg2dec.c, main(), initialization, option processing */ |
- |
-/* Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved. */ |
- |
-/* |
- * Disclaimer of Warranty |
- * |
- * These software programs are available to the user without any license fee or |
- * royalty on an "as is" basis. The MPEG Software Simulation Group disclaims |
- * any and all warranties, whether express, implied, or statuary, including any |
- * implied warranties or merchantability or of fitness for a particular |
- * purpose. In no event shall the copyright-holder be liable for any |
- * incidental, punitive, or consequential damages of any kind whatsoever |
- * arising from the use of these programs. |
- * |
- * This disclaimer of warranty extends to the user of these programs and user's |
- * customers, employees, agents, transferees, successors, and assigns. |
- * |
- * The MPEG Software Simulation Group does not represent or warrant that the |
- * programs furnished hereunder are free of infringement of any third-party |
- * patents. |
- * |
- * Commercial implementations of MPEG-1 and MPEG-2 video, including shareware, |
- * are subject to royalty fees to patent holders. Many of these patents are |
- * general enough such that they are unavoidable regardless of implementation |
- * design. |
- * |
- */ |
- |
-#include "stdlib.h" |
-#include "drivers/glib.h" |
- |
-#include "fsf_contract.h" |
- |
-#define GLOBAL |
-#include "config.h" |
-#include "global.h" |
- |
-/* private prototypes */ |
-static int video_sequence _ANSI_ARGS_((int *framenum)); |
-static int Headers _ANSI_ARGS_((void)); |
-static void Initialize_Sequence _ANSI_ARGS_((void)); |
-static void Initialize_Decoder _ANSI_ARGS_((void)); |
-static void Deinitialize_Sequence _ANSI_ARGS_((void)); |
- |
-/* #define DEBUG */ |
- |
-static void Clear_Options(); |
-#ifdef DEBUG |
-static void Print_Options(); |
-#endif |
- |
-#define MAX_M_QOS 0 |
-#define MIN_M_QOS 0 |
- |
-int dos_video_preload(char *file_name, long max_size, void **start, void **end) |
-{ |
- DOS_FILE* file; |
- void *buf; |
- long rd; |
- |
- |
- file = DOS_fopen(file_name,"r"); |
- if (file == NULL) return -1; |
- |
- buf = malloc(max_size); |
- *start = buf; |
- |
- while(((rd = DOS_fread(buf, sizeof(BYTE), 2048, file)) == 2048) && |
- ((buf - *start + rd) < (max_size-2048))) { |
- buf += rd; |
- } |
- |
- *end = buf + rd; |
- |
- DOS_fclose(file); |
- return(0); |
- |
-} |
- |
-int Init_Mpeg_Decoder(void *start, void *end) |
-{ |
- int code; |
- |
- Clear_Options(); |
- |
-#ifdef DEBUG |
- Print_Options(); |
-#endif |
- |
- ld = &base; /* select base layer context */ |
- ld->start_file_ptr = start; |
- ld->end_file_ptr = end; |
- ld->actual_file_ptr = ld->start_file_ptr; |
- |
- /* open MPEG base layer bitstream file(s) */ |
- /* NOTE: this is either a base layer stream or a spatial enhancement stream */ |
- if ((base.Infile=1)<0) |
- { |
- cprintf("Base layer input file %s not found\n", Main_Bitstream_Filename); |
- } |
- |
- |
- if(base.Infile != 0) |
- { |
- Initialize_Buffer(); |
- |
- if(Show_Bits(8)==0x47) |
- { |
- sprintf(Error_Text,"Decoder currently does not parse transport streams\n"); |
- Error(Error_Text); |
- } |
- |
- next_start_code(); |
- code = Show_Bits(32); |
- |
- switch(code) |
- { |
- case SEQUENCE_HEADER_CODE: |
- break; |
- case PACK_START_CODE: |
- System_Stream_Flag = 1; |
- case VIDEO_ELEMENTARY_STREAM: |
- System_Stream_Flag = 1; |
- break; |
- default: |
- sprintf(Error_Text,"Unable to recognize stream type\n"); |
- Error(Error_Text); |
- break; |
- } |
- |
- ld->actual_file_ptr = ld->start_file_ptr; |
- Initialize_Buffer(); |
- } |
- |
- if(base.Infile!=0) |
- { |
- ld->actual_file_ptr = ld->start_file_ptr; |
- } |
- |
- Initialize_Buffer(); |
- |
- if(Two_Streams) |
- { |
- ld = &enhan; /* select enhancement layer context */ |
- |
- if ((enhan.Infile = 1)<0) |
- { |
- sprintf(Error_Text,"enhancment layer bitstream file %s not found\n", |
- Enhancement_Layer_Bitstream_Filename); |
- |
- Error(Error_Text); |
- } |
- |
- Initialize_Buffer(); |
- ld = &base; |
- } |
- |
- Initialize_Decoder(); |
- |
- //Decode_Bitstream(); |
- |
- return 0; |
-} |
- |
-/* IMPLEMENTAION specific rouintes */ |
-static void Initialize_Decoder() |
-{ |
- int i; |
- |
- /* Clip table */ |
- if (!(Clip=(unsigned char *)malloc(1024))) |
- Error("Clip[] malloc failed\n"); |
- |
- Clip += 384; |
- |
- for (i=-384; i<640; i++) |
- Clip[i] = (i<0) ? 0 : ((i>255) ? 255 : i); |
- |
- /* IDCT */ |
- if (Reference_IDCT_Flag) |
- Initialize_Reference_IDCT(); |
- else |
- Initialize_Fast_IDCT(); |
- |
-} |
- |
-/* mostly IMPLEMENTAION specific rouintes */ |
-static void Initialize_Sequence() |
-{ |
- int cc, size; |
- static int Table_6_20[3] = {6,8,12}; |
- |
- /* check scalability mode of enhancement layer */ |
- if (Two_Streams && (enhan.scalable_mode!=SC_SNR) && (base.scalable_mode!=SC_DP)) |
- Error("unsupported scalability mode\n"); |
- |
- /* force MPEG-1 parameters for proper decoder behavior */ |
- /* see ISO/IEC 13818-2 section D.9.14 */ |
- if (!base.MPEG2_Flag) |
- { |
- progressive_sequence = 1; |
- progressive_frame = 1; |
- picture_structure = FRAME_PICTURE; |
- frame_pred_frame_dct = 1; |
- chroma_format = CHROMA420; |
- matrix_coefficients = 5; |
- } |
- |
- /* round to nearest multiple of coded macroblocks */ |
- /* ISO/IEC 13818-2 section 6.3.3 sequence_header() */ |
- mb_width = (horizontal_size+15)/16; |
- mb_height = (base.MPEG2_Flag && !progressive_sequence) ? 2*((vertical_size+31)/32) |
- : (vertical_size+15)/16; |
- |
- Coded_Picture_Width = 16*mb_width; |
- Coded_Picture_Height = 16*mb_height; |
- |
- /* ISO/IEC 13818-2 sections 6.1.1.8, 6.1.1.9, and 6.1.1.10 */ |
- Chroma_Width = (chroma_format==CHROMA444) ? Coded_Picture_Width |
- : Coded_Picture_Width>>1; |
- Chroma_Height = (chroma_format!=CHROMA420) ? Coded_Picture_Height |
- : Coded_Picture_Height>>1; |
- |
- /* derived based on Table 6-20 in ISO/IEC 13818-2 section 6.3.17 */ |
- block_count = Table_6_20[chroma_format-1]; |
- |
- for (cc=0; cc<3; cc++) |
- { |
- if (cc==0) |
- size = Coded_Picture_Width*Coded_Picture_Height; |
- else |
- size = Chroma_Width*Chroma_Height; |
- |
- if (!(backward_reference_frame[cc] = (unsigned char *)malloc(size))) |
- Error("backward_reference_frame[] malloc failed\n"); |
- |
- if (!(forward_reference_frame[cc] = (unsigned char *)malloc(size))) |
- Error("forward_reference_frame[] malloc failed\n"); |
- |
- if (!(auxframe[cc] = (unsigned char *)malloc(size))) |
- Error("auxframe[] malloc failed\n"); |
- |
- if(Ersatz_Flag) |
- if (!(substitute_frame[cc] = (unsigned char *)malloc(size))) |
- Error("substitute_frame[] malloc failed\n"); |
- |
- |
- if (base.scalable_mode==SC_SPAT) |
- { |
- /* this assumes lower layer is 4:2:0 */ |
- if (!(llframe0[cc] = (unsigned char *)malloc((lower_layer_prediction_horizontal_size*lower_layer_prediction_vertical_size)/(cc?4:1)))) |
- Error("llframe0 malloc failed\n"); |
- if (!(llframe1[cc] = (unsigned char *)malloc((lower_layer_prediction_horizontal_size*lower_layer_prediction_vertical_size)/(cc?4:1)))) |
- Error("llframe1 malloc failed\n"); |
- } |
- } |
- |
- /* SCALABILITY: Spatial */ |
- if (base.scalable_mode==SC_SPAT) |
- { |
- if (!(lltmp = (short *)malloc(lower_layer_prediction_horizontal_size*((lower_layer_prediction_vertical_size*vertical_subsampling_factor_n)/vertical_subsampling_factor_m)*sizeof(short)))) |
- Error("lltmp malloc failed\n"); |
- } |
- |
-#ifdef DISPLAY |
- if (Output_Type==T_X11) |
- { |
- Initialize_Display_Process(""); |
- Initialize_Dither_Matrix(); |
- } |
-#endif /* DISPLAY */ |
- |
-} |
- |
-void Error(text) |
-char *text; |
-{ |
- cprintf(text); |
-} |
- |
-/* Trace_Flag output */ |
-void Print_Bits(code,bits,len) |
-int code,bits,len; |
-{ |
- int i; |
- for (i=0; i<len; i++) |
- cprintf("%d",(code>>(bits-1-i))&1); |
-} |
- |
-static int Headers() |
-{ |
- int ret; |
- |
- ld = &base; |
- |
- |
- /* return when end of sequence (0) or picture |
- header has been parsed (1) */ |
- |
- ret = Get_Hdr(); |
- |
- |
- if (Two_Streams) |
- { |
- ld = &enhan; |
- if (Get_Hdr()!=ret && !Quiet_Flag) |
- cprintf("streams out of sync\n"); |
- ld = &base; |
- } |
- |
- return ret; |
-} |
- |
-int Decode_Bitstream() |
-{ |
- int ret; |
- int Bitstream_Framenum; |
- |
- Bitstream_Framenum = 0; |
- |
- for(;;) |
- { |
- |
-#ifdef VERIFY |
- Clear_Verify_Headers(); |
-#endif /* VERIFY */ |
- |
- ld->actual_file_ptr = ld->start_file_ptr; |
- |
- ret = Headers(); |
- |
- if(ret==1) |
- { |
- ret = video_sequence(&Bitstream_Framenum); |
- } |
- else |
- return(ret); |
- } |
- |
-} |
- |
- |
-static void Deinitialize_Sequence() |
-{ |
- int i; |
- |
- /* clear flags */ |
- base.MPEG2_Flag=0; |
- |
- for(i=0;i<3;i++) |
- { |
- free(backward_reference_frame[i]); |
- free(forward_reference_frame[i]); |
- free(auxframe[i]); |
- |
- if (base.scalable_mode==SC_SPAT) |
- { |
- free(llframe0[i]); |
- free(llframe1[i]); |
- } |
- } |
- |
- if (base.scalable_mode==SC_SPAT) |
- free(lltmp); |
- |
-#ifdef DISPLAY |
- if (Output_Type==T_X11) |
- Terminate_Display_Process(); |
-#endif |
-} |
- |
- |
-static int video_sequence(Bitstream_Framenumber) |
-int *Bitstream_Framenumber; |
-{ |
- int Bitstream_Framenum; |
- int Sequence_Framenum; |
- int Return_Value; |
- |
- char tmp[100]; |
- |
- Bitstream_Framenum = *Bitstream_Framenumber; |
- Sequence_Framenum=0; |
- |
- Initialize_Sequence(); |
- |
- /* decode picture whose header has already been parsed in |
- Decode_Bitstream() */ |
- |
- ld->px = 310+(rand()%(500-Coded_Picture_Width)); |
- ld->py = 100+(rand()%(400-Coded_Picture_Height)); |
- |
- sprintf(tmp,"Wx = %3d Wy = %3d",Coded_Picture_Width,Coded_Picture_Height); |
- grx_text(tmp,ld->px,ld->py-10,rgb16(255,255,255),0); |
- |
- Decode_Picture(Bitstream_Framenum, Sequence_Framenum); |
- |
- /* update picture numbers */ |
- if (!Second_Field) |
- { |
- Bitstream_Framenum++; |
- Sequence_Framenum++; |
- } |
- |
- fsf_schedule_next_timed_job(NULL, NULL, NULL, NULL, NULL); |
- |
- /* loop through the rest of the pictures in the sequence */ |
- while ((Return_Value=Headers())) |
- { |
- Decode_Picture(Bitstream_Framenum, Sequence_Framenum); |
- |
- if (!Second_Field) |
- { |
- Bitstream_Framenum++; |
- Sequence_Framenum++; |
- } |
- |
- fsf_schedule_next_timed_job(NULL, NULL, NULL, NULL, NULL); |
- |
- } |
- |
- /* put last frame */ |
- if (Sequence_Framenum!=0) |
- { |
- Output_Last_Frame_of_Sequence(Bitstream_Framenum); |
- } |
- |
- Deinitialize_Sequence(); |
- |
-#ifdef VERIFY |
- Clear_Verify_Headers(); |
-#endif /* VERIFY */ |
- |
- *Bitstream_Framenumber = Bitstream_Framenum; |
- return(Return_Value); |
-} |
- |
- |
- |
-static void Clear_Options() |
-{ |
- Verbose_Flag = 0; |
- Output_Type = 0; |
- Output_Picture_Filename = " "; |
- hiQdither = 0; |
- Output_Type = 0; |
- Frame_Store_Flag = 0; |
- Spatial_Flag = 0; |
- Lower_Layer_Picture_Filename = " "; |
- Reference_IDCT_Flag = 0; |
- Trace_Flag = 0; |
- Quiet_Flag = 0; |
- Ersatz_Flag = 0; |
- Substitute_Picture_Filename = " "; |
- Two_Streams = 0; |
- Enhancement_Layer_Bitstream_Filename = " "; |
- Big_Picture_Flag = 0; |
- Main_Bitstream_Flag = 0; |
- Main_Bitstream_Filename = " "; |
- Verify_Flag = 0; |
- Stats_Flag = 0; |
- User_Data_Flag = 0; |
-} |
- |
- |
-#ifdef DEBUG |
-static void Print_Options() |
-{ |
- |
- printf("Verbose_Flag = %d\n", Verbose_Flag); |
- printf("Output_Type = %d\n", Output_Type); |
- printf("Output_Picture_Filename = %s\n", Output_Picture_Filename); |
- printf("hiQdither = %d\n", hiQdither); |
- printf("Output_Type = %d\n", Output_Type); |
- printf("Frame_Store_Flag = %d\n", Frame_Store_Flag); |
- printf("Spatial_Flag = %d\n", Spatial_Flag); |
- printf("Lower_Layer_Picture_Filename = %s\n", Lower_Layer_Picture_Filename); |
- printf("Reference_IDCT_Flag = %d\n", Reference_IDCT_Flag); |
- printf("Trace_Flag = %d\n", Trace_Flag); |
- printf("Quiet_Flag = %d\n", Quiet_Flag); |
- printf("Ersatz_Flag = %d\n", Ersatz_Flag); |
- printf("Substitute_Picture_Filename = %s\n", Substitute_Picture_Filename); |
- printf("Two_Streams = %d\n", Two_Streams); |
- printf("Enhancement_Layer_Bitstream_Filename = %s\n", Enhancement_Layer_Bitstream_Filename); |
- printf("Big_Picture_Flag = %d\n", Big_Picture_Flag); |
- printf("Main_Bitstream_Flag = %d\n", Main_Bitstream_Flag); |
- printf("Main_Bitstream_Filename = %s\n", Main_Bitstream_Filename); |
- printf("Verify_Flag = %d\n", Verify_Flag); |
- printf("Stats_Flag = %d\n", Stats_Flag); |
- printf("User_Data_Flag = %d\n", User_Data_Flag); |
- |
-} |
-#endif |
Index: tags/rel_1_22/fsf/mpeg2/getvlc.h |
=================================================================== |
--- tags/rel_1_22/fsf/mpeg2/getvlc.h (revision 1310) |
+++ tags/rel_1_22/fsf/mpeg2/getvlc.h (nonexistent) |
@@ -1,491 +0,0 @@ |
-/* getvlc.h, variable length code tables */ |
- |
-/* Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved. */ |
- |
-/* |
- * Disclaimer of Warranty |
- * |
- * These software programs are available to the user without any license fee or |
- * royalty on an "as is" basis. The MPEG Software Simulation Group disclaims |
- * any and all warranties, whether express, implied, or statuary, including any |
- * implied warranties or merchantability or of fitness for a particular |
- * purpose. In no event shall the copyright-holder be liable for any |
- * incidental, punitive, or consequential damages of any kind whatsoever |
- * arising from the use of these programs. |
- * |
- * This disclaimer of warranty extends to the user of these programs and user's |
- * customers, employees, agents, transferees, successors, and assigns. |
- * |
- * The MPEG Software Simulation Group does not represent or warrant that the |
- * programs furnished hereunder are free of infringement of any third-party |
- * patents. |
- * |
- * Commercial implementations of MPEG-1 and MPEG-2 video, including shareware, |
- * are subject to royalty fees to patent holders. Many of these patents are |
- * general enough such that they are unavoidable regardless of implementation |
- * design. |
- * |
- */ |
- |
-/* NOTE: #define constants such as MACROBLOCK_QUANT are upper case |
- as per C programming convention. However, the MPEG document |
- (ISO/IEC 13818-2) lists them in all lower case (e.g. Annex B) */ |
- |
-/* NOTE: the VLC tables are in a flash format---a transformation |
- of the tables in Annex B to a form more convenient towards |
- parallel (more than one-bit-at-a-time) decoding */ |
- |
-typedef struct { |
- char val, len; |
-} VLCtab; |
- |
-typedef struct { |
- char run, level, len; |
-} DCTtab; |
- |
-/* Table B-3, macroblock_type in P-pictures, codes 001..1xx */ |
-static VLCtab PMBtab0[8] = { |
- {ERROR,0}, |
- {MACROBLOCK_MOTION_FORWARD,3}, |
- {MACROBLOCK_PATTERN,2}, {MACROBLOCK_PATTERN,2}, |
- {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,1}, |
- {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,1}, |
- {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,1}, |
- {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,1} |
-}; |
- |
-/* Table B-3, macroblock_type in P-pictures, codes 000001..00011x */ |
-static VLCtab PMBtab1[8] = { |
- {ERROR,0}, |
- {MACROBLOCK_QUANT|MACROBLOCK_INTRA,6}, |
- {MACROBLOCK_QUANT|MACROBLOCK_PATTERN,5}, {MACROBLOCK_QUANT|MACROBLOCK_PATTERN,5}, |
- {MACROBLOCK_QUANT|MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,5}, {MACROBLOCK_QUANT|MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,5}, |
- {MACROBLOCK_INTRA,5}, {MACROBLOCK_INTRA,5} |
-}; |
- |
-/* Table B-4, macroblock_type in B-pictures, codes 0010..11xx */ |
-static VLCtab BMBtab0[16] = { |
- {ERROR,0}, |
- {ERROR,0}, |
- {MACROBLOCK_MOTION_FORWARD,4}, |
- {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,4}, |
- {MACROBLOCK_MOTION_BACKWARD,3}, |
- {MACROBLOCK_MOTION_BACKWARD,3}, |
- {MACROBLOCK_MOTION_BACKWARD|MACROBLOCK_PATTERN,3}, |
- {MACROBLOCK_MOTION_BACKWARD|MACROBLOCK_PATTERN,3}, |
- {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD,2}, |
- {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD,2}, |
- {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD,2}, |
- {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD,2}, |
- {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD|MACROBLOCK_PATTERN,2}, |
- {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD|MACROBLOCK_PATTERN,2}, |
- {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD|MACROBLOCK_PATTERN,2}, |
- {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD|MACROBLOCK_PATTERN,2} |
-}; |
- |
-/* Table B-4, macroblock_type in B-pictures, codes 000001..00011x */ |
-static VLCtab BMBtab1[8] = { |
- {ERROR,0}, |
- {MACROBLOCK_QUANT|MACROBLOCK_INTRA,6}, |
- {MACROBLOCK_QUANT|MACROBLOCK_MOTION_BACKWARD|MACROBLOCK_PATTERN,6}, |
- {MACROBLOCK_QUANT|MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,6}, |
- {MACROBLOCK_QUANT|MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD|MACROBLOCK_PATTERN,5}, |
- {MACROBLOCK_QUANT|MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD|MACROBLOCK_PATTERN,5}, |
- {MACROBLOCK_INTRA,5}, |
- {MACROBLOCK_INTRA,5} |
-}; |
- |
-/* Table B-5, macroblock_type in spat. scal. I-pictures, codes 0001..1xxx */ |
-static VLCtab spIMBtab[16] = { |
- {ERROR,0}, |
- {PERMITTED_SPATIAL_TEMPORAL_WEIGHT_CLASS,4}, |
- {MACROBLOCK_QUANT|MACROBLOCK_INTRA,4}, |
- {MACROBLOCK_INTRA,4}, |
- {PERMITTED_SPATIAL_TEMPORAL_WEIGHT_CLASS|MACROBLOCK_QUANT|MACROBLOCK_PATTERN,2}, {PERMITTED_SPATIAL_TEMPORAL_WEIGHT_CLASS|MACROBLOCK_QUANT|MACROBLOCK_PATTERN,2}, |
- {PERMITTED_SPATIAL_TEMPORAL_WEIGHT_CLASS|MACROBLOCK_QUANT|MACROBLOCK_PATTERN,2}, {PERMITTED_SPATIAL_TEMPORAL_WEIGHT_CLASS|MACROBLOCK_QUANT|MACROBLOCK_PATTERN,2}, |
- {PERMITTED_SPATIAL_TEMPORAL_WEIGHT_CLASS|MACROBLOCK_PATTERN,1}, {PERMITTED_SPATIAL_TEMPORAL_WEIGHT_CLASS|MACROBLOCK_PATTERN,1}, |
- {PERMITTED_SPATIAL_TEMPORAL_WEIGHT_CLASS|MACROBLOCK_PATTERN,1}, {PERMITTED_SPATIAL_TEMPORAL_WEIGHT_CLASS|MACROBLOCK_PATTERN,1}, |
- {PERMITTED_SPATIAL_TEMPORAL_WEIGHT_CLASS|MACROBLOCK_PATTERN,1}, {PERMITTED_SPATIAL_TEMPORAL_WEIGHT_CLASS|MACROBLOCK_PATTERN,1}, |
- {PERMITTED_SPATIAL_TEMPORAL_WEIGHT_CLASS|MACROBLOCK_PATTERN,1}, {PERMITTED_SPATIAL_TEMPORAL_WEIGHT_CLASS|MACROBLOCK_PATTERN,1} |
-}; |
- |
-/* Table B-6, macroblock_type in spat. scal. P-pictures, codes 0010..11xx */ |
-static VLCtab spPMBtab0[16] = |
-{ |
- {ERROR,0}, |
- {ERROR,0}, |
- {MACROBLOCK_MOTION_FORWARD,4}, |
- {SPATIAL_TEMPORAL_WEIGHT_CODE_FLAG|MACROBLOCK_MOTION_FORWARD,4}, |
- {MACROBLOCK_QUANT|MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,3}, {MACROBLOCK_QUANT|MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,3}, |
- {SPATIAL_TEMPORAL_WEIGHT_CODE_FLAG|MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,3}, {SPATIAL_TEMPORAL_WEIGHT_CODE_FLAG|MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,3}, |
- {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,2}, |
- {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,2}, |
- {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,2}, |
- {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,2}, |
- {SPATIAL_TEMPORAL_WEIGHT_CODE_FLAG|MACROBLOCK_QUANT|MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,2}, |
- {SPATIAL_TEMPORAL_WEIGHT_CODE_FLAG|MACROBLOCK_QUANT|MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,2}, |
- {SPATIAL_TEMPORAL_WEIGHT_CODE_FLAG|MACROBLOCK_QUANT|MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,2}, |
- {SPATIAL_TEMPORAL_WEIGHT_CODE_FLAG|MACROBLOCK_QUANT|MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,2} |
-}; |
- |
-/* Table B-6, macroblock_type in spat. scal. P-pictures, codes 0000010..000111x */ |
-static VLCtab spPMBtab1[16] = { |
- {ERROR,0}, |
- {ERROR,0}, |
- {PERMITTED_SPATIAL_TEMPORAL_WEIGHT_CLASS|MACROBLOCK_QUANT|MACROBLOCK_PATTERN,7}, |
- {PERMITTED_SPATIAL_TEMPORAL_WEIGHT_CLASS,7}, |
- {MACROBLOCK_PATTERN,7}, |
- {PERMITTED_SPATIAL_TEMPORAL_WEIGHT_CLASS|MACROBLOCK_PATTERN,7}, |
- {MACROBLOCK_QUANT|MACROBLOCK_INTRA,7}, |
- {MACROBLOCK_INTRA,7}, |
- {MACROBLOCK_QUANT|MACROBLOCK_PATTERN,6}, |
- {MACROBLOCK_QUANT|MACROBLOCK_PATTERN,6}, |
- {SPATIAL_TEMPORAL_WEIGHT_CODE_FLAG|MACROBLOCK_QUANT|MACROBLOCK_PATTERN,6}, |
- {SPATIAL_TEMPORAL_WEIGHT_CODE_FLAG|MACROBLOCK_QUANT|MACROBLOCK_PATTERN,6}, |
- {SPATIAL_TEMPORAL_WEIGHT_CODE_FLAG,6}, |
- {SPATIAL_TEMPORAL_WEIGHT_CODE_FLAG,6}, |
- {SPATIAL_TEMPORAL_WEIGHT_CODE_FLAG|MACROBLOCK_PATTERN,6}, |
- {SPATIAL_TEMPORAL_WEIGHT_CODE_FLAG|MACROBLOCK_PATTERN,6} |
-}; |
- |
-/* Table B-7, macroblock_type in spat. scal. B-pictures, codes 0010..11xx */ |
-static VLCtab spBMBtab0[14] = { |
- {MACROBLOCK_MOTION_FORWARD,4}, |
- {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,4}, |
- {MACROBLOCK_MOTION_BACKWARD,3}, |
- {MACROBLOCK_MOTION_BACKWARD,3}, |
- {MACROBLOCK_MOTION_BACKWARD|MACROBLOCK_PATTERN,3}, |
- {MACROBLOCK_MOTION_BACKWARD|MACROBLOCK_PATTERN,3}, |
- {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD,2}, |
- {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD,2}, |
- {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD,2}, |
- {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD,2}, |
- {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD|MACROBLOCK_PATTERN,2}, |
- {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD|MACROBLOCK_PATTERN,2}, |
- {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD|MACROBLOCK_PATTERN,2}, |
- {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD|MACROBLOCK_PATTERN,2} |
-}; |
- |
-/* Table B-7, macroblock_type in spat. scal. B-pictures, codes 0000100..000111x */ |
-static VLCtab spBMBtab1[12] = { |
- {MACROBLOCK_QUANT|MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,7}, |
- {MACROBLOCK_QUANT|MACROBLOCK_MOTION_BACKWARD|MACROBLOCK_PATTERN,7}, |
- {MACROBLOCK_INTRA,7}, |
- {MACROBLOCK_QUANT|MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD|MACROBLOCK_PATTERN,7}, |
- {SPATIAL_TEMPORAL_WEIGHT_CODE_FLAG|MACROBLOCK_MOTION_FORWARD,6}, |
- {SPATIAL_TEMPORAL_WEIGHT_CODE_FLAG|MACROBLOCK_MOTION_FORWARD,6}, |
- {SPATIAL_TEMPORAL_WEIGHT_CODE_FLAG|MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,6}, |
- {SPATIAL_TEMPORAL_WEIGHT_CODE_FLAG|MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,6}, |
- {SPATIAL_TEMPORAL_WEIGHT_CODE_FLAG|MACROBLOCK_MOTION_BACKWARD,6}, |
- {SPATIAL_TEMPORAL_WEIGHT_CODE_FLAG|MACROBLOCK_MOTION_BACKWARD,6}, |
- {SPATIAL_TEMPORAL_WEIGHT_CODE_FLAG|MACROBLOCK_MOTION_BACKWARD|MACROBLOCK_PATTERN,6}, |
- {SPATIAL_TEMPORAL_WEIGHT_CODE_FLAG|MACROBLOCK_MOTION_BACKWARD|MACROBLOCK_PATTERN,6} |
-}; |
- |
-/* Table B-7, macroblock_type in spat. scal. B-pictures, codes 00000100x..000001111 */ |
-static VLCtab spBMBtab2[8] = { |
- {MACROBLOCK_QUANT|MACROBLOCK_INTRA,8}, |
- {MACROBLOCK_QUANT|MACROBLOCK_INTRA,8}, |
- {SPATIAL_TEMPORAL_WEIGHT_CODE_FLAG|MACROBLOCK_QUANT|MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,8}, |
- {SPATIAL_TEMPORAL_WEIGHT_CODE_FLAG|MACROBLOCK_QUANT|MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,8}, |
- {SPATIAL_TEMPORAL_WEIGHT_CODE_FLAG|MACROBLOCK_QUANT|MACROBLOCK_MOTION_BACKWARD|MACROBLOCK_PATTERN,9}, |
- {PERMITTED_SPATIAL_TEMPORAL_WEIGHT_CLASS|MACROBLOCK_QUANT|MACROBLOCK_PATTERN,9}, |
- {PERMITTED_SPATIAL_TEMPORAL_WEIGHT_CLASS,9}, |
- {PERMITTED_SPATIAL_TEMPORAL_WEIGHT_CLASS|MACROBLOCK_PATTERN,9} |
-}; |
- |
-/* Table B-8, macroblock_type in spat. scal. B-pictures, codes 001..1xx */ |
-static VLCtab SNRMBtab[8] = { |
- {ERROR,0}, |
- {0,3}, |
- {MACROBLOCK_QUANT|MACROBLOCK_PATTERN,2}, |
- {MACROBLOCK_QUANT|MACROBLOCK_PATTERN,2}, |
- {MACROBLOCK_PATTERN,1}, |
- {MACROBLOCK_PATTERN,1}, |
- {MACROBLOCK_PATTERN,1}, |
- {MACROBLOCK_PATTERN,1} |
-}; |
- |
-/* Table B-10, motion_code, codes 0001 ... 01xx */ |
-static VLCtab MVtab0[8] = |
-{ {ERROR,0}, {3,3}, {2,2}, {2,2}, {1,1}, {1,1}, {1,1}, {1,1} |
-}; |
- |
-/* Table B-10, motion_code, codes 0000011 ... 000011x */ |
-static VLCtab MVtab1[8] = |
-{ {ERROR,0}, {ERROR,0}, {ERROR,0}, {7,6}, {6,6}, {5,6}, {4,5}, {4,5} |
-}; |
- |
-/* Table B-10, motion_code, codes 0000001100 ... 000001011x */ |
-static VLCtab MVtab2[12] = |
-{ {16,9}, {15,9}, {14,9}, {13,9}, |
- {12,9}, {11,9}, {10,8}, {10,8}, |
- {9,8}, {9,8}, {8,8}, {8,8} |
-}; |
- |
-/* Table B-9, coded_block_pattern, codes 01000 ... 111xx */ |
-static VLCtab CBPtab0[32] = |
-{ {ERROR,0}, {ERROR,0}, {ERROR,0}, {ERROR,0}, |
- {ERROR,0}, {ERROR,0}, {ERROR,0}, {ERROR,0}, |
- {62,5}, {2,5}, {61,5}, {1,5}, {56,5}, {52,5}, {44,5}, {28,5}, |
- {40,5}, {20,5}, {48,5}, {12,5}, {32,4}, {32,4}, {16,4}, {16,4}, |
- {8,4}, {8,4}, {4,4}, {4,4}, {60,3}, {60,3}, {60,3}, {60,3} |
-}; |
- |
-/* Table B-9, coded_block_pattern, codes 00000100 ... 001111xx */ |
-static VLCtab CBPtab1[64] = |
-{ {ERROR,0}, {ERROR,0}, {ERROR,0}, {ERROR,0}, |
- {58,8}, {54,8}, {46,8}, {30,8}, |
- {57,8}, {53,8}, {45,8}, {29,8}, {38,8}, {26,8}, {37,8}, {25,8}, |
- {43,8}, {23,8}, {51,8}, {15,8}, {42,8}, {22,8}, {50,8}, {14,8}, |
- {41,8}, {21,8}, {49,8}, {13,8}, {35,8}, {19,8}, {11,8}, {7,8}, |
- {34,7}, {34,7}, {18,7}, {18,7}, {10,7}, {10,7}, {6,7}, {6,7}, |
- {33,7}, {33,7}, {17,7}, {17,7}, {9,7}, {9,7}, {5,7}, {5,7}, |
- {63,6}, {63,6}, {63,6}, {63,6}, {3,6}, {3,6}, {3,6}, {3,6}, |
- {36,6}, {36,6}, {36,6}, {36,6}, {24,6}, {24,6}, {24,6}, {24,6} |
-}; |
- |
-/* Table B-9, coded_block_pattern, codes 000000001 ... 000000111 */ |
-static VLCtab CBPtab2[8] = |
-{ {ERROR,0}, {0,9}, {39,9}, {27,9}, {59,9}, {55,9}, {47,9}, {31,9} |
-}; |
- |
-/* Table B-1, macroblock_address_increment, codes 00010 ... 011xx */ |
-static VLCtab MBAtab1[16] = |
-{ {ERROR,0}, {ERROR,0}, {7,5}, {6,5}, {5,4}, {5,4}, {4,4}, {4,4}, |
- {3,3}, {3,3}, {3,3}, {3,3}, {2,3}, {2,3}, {2,3}, {2,3} |
-}; |
- |
-/* Table B-1, macroblock_address_increment, codes 00000011000 ... 0000111xxxx */ |
-static VLCtab MBAtab2[104] = |
-{ |
- {33,11}, {32,11}, {31,11}, {30,11}, {29,11}, {28,11}, {27,11}, {26,11}, |
- {25,11}, {24,11}, {23,11}, {22,11}, {21,10}, {21,10}, {20,10}, {20,10}, |
- {19,10}, {19,10}, {18,10}, {18,10}, {17,10}, {17,10}, {16,10}, {16,10}, |
- {15,8}, {15,8}, {15,8}, {15,8}, {15,8}, {15,8}, {15,8}, {15,8}, |
- {14,8}, {14,8}, {14,8}, {14,8}, {14,8}, {14,8}, {14,8}, {14,8}, |
- {13,8}, {13,8}, {13,8}, {13,8}, {13,8}, {13,8}, {13,8}, {13,8}, |
- {12,8}, {12,8}, {12,8}, {12,8}, {12,8}, {12,8}, {12,8}, {12,8}, |
- {11,8}, {11,8}, {11,8}, {11,8}, {11,8}, {11,8}, {11,8}, {11,8}, |
- {10,8}, {10,8}, {10,8}, {10,8}, {10,8}, {10,8}, {10,8}, {10,8}, |
- {9,7}, {9,7}, {9,7}, {9,7}, {9,7}, {9,7}, {9,7}, {9,7}, |
- {9,7}, {9,7}, {9,7}, {9,7}, {9,7}, {9,7}, {9,7}, {9,7}, |
- {8,7}, {8,7}, {8,7}, {8,7}, {8,7}, {8,7}, {8,7}, {8,7}, |
- {8,7}, {8,7}, {8,7}, {8,7}, {8,7}, {8,7}, {8,7}, {8,7} |
-}; |
- |
-/* Table B-12, dct_dc_size_luminance, codes 00xxx ... 11110 */ |
-static VLCtab DClumtab0[32] = |
-{ {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, |
- {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, |
- {0, 3}, {0, 3}, {0, 3}, {0, 3}, {3, 3}, {3, 3}, {3, 3}, {3, 3}, |
- {4, 3}, {4, 3}, {4, 3}, {4, 3}, {5, 4}, {5, 4}, {6, 5}, {ERROR, 0} |
-}; |
- |
-/* Table B-12, dct_dc_size_luminance, codes 111110xxx ... 111111111 */ |
-static VLCtab DClumtab1[16] = |
-{ {7, 6}, {7, 6}, {7, 6}, {7, 6}, {7, 6}, {7, 6}, {7, 6}, {7, 6}, |
- {8, 7}, {8, 7}, {8, 7}, {8, 7}, {9, 8}, {9, 8}, {10,9}, {11,9} |
-}; |
- |
-/* Table B-13, dct_dc_size_chrominance, codes 00xxx ... 11110 */ |
-static VLCtab DCchromtab0[32] = |
-{ {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, |
- {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, |
- {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, |
- {3, 3}, {3, 3}, {3, 3}, {3, 3}, {4, 4}, {4, 4}, {5, 5}, {ERROR, 0} |
-}; |
- |
-/* Table B-13, dct_dc_size_chrominance, codes 111110xxxx ... 1111111111 */ |
-static VLCtab DCchromtab1[32] = |
-{ {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, |
- {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, |
- {7, 7}, {7, 7}, {7, 7}, {7, 7}, {7, 7}, {7, 7}, {7, 7}, {7, 7}, |
- {8, 8}, {8, 8}, {8, 8}, {8, 8}, {9, 9}, {9, 9}, {10,10}, {11,10} |
-}; |
- |
-/* Table B-14, DCT coefficients table zero, |
- * codes 0100 ... 1xxx (used for first (DC) coefficient) |
- */ |
-DCTtab DCTtabfirst[12] = |
-{ |
- {0,2,4}, {2,1,4}, {1,1,3}, {1,1,3}, |
- {0,1,1}, {0,1,1}, {0,1,1}, {0,1,1}, |
- {0,1,1}, {0,1,1}, {0,1,1}, {0,1,1} |
-}; |
- |
-/* Table B-14, DCT coefficients table zero, |
- * codes 0100 ... 1xxx (used for all other coefficients) |
- */ |
-DCTtab DCTtabnext[12] = |
-{ |
- {0,2,4}, {2,1,4}, {1,1,3}, {1,1,3}, |
- {64,0,2}, {64,0,2}, {64,0,2}, {64,0,2}, /* EOB */ |
- {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2} |
-}; |
- |
-/* Table B-14, DCT coefficients table zero, |
- * codes 000001xx ... 00111xxx |
- */ |
-DCTtab DCTtab0[60] = |
-{ |
- {65,0,6}, {65,0,6}, {65,0,6}, {65,0,6}, /* Escape */ |
- {2,2,7}, {2,2,7}, {9,1,7}, {9,1,7}, |
- {0,4,7}, {0,4,7}, {8,1,7}, {8,1,7}, |
- {7,1,6}, {7,1,6}, {7,1,6}, {7,1,6}, |
- {6,1,6}, {6,1,6}, {6,1,6}, {6,1,6}, |
- {1,2,6}, {1,2,6}, {1,2,6}, {1,2,6}, |
- {5,1,6}, {5,1,6}, {5,1,6}, {5,1,6}, |
- {13,1,8}, {0,6,8}, {12,1,8}, {11,1,8}, |
- {3,2,8}, {1,3,8}, {0,5,8}, {10,1,8}, |
- {0,3,5}, {0,3,5}, {0,3,5}, {0,3,5}, |
- {0,3,5}, {0,3,5}, {0,3,5}, {0,3,5}, |
- {4,1,5}, {4,1,5}, {4,1,5}, {4,1,5}, |
- {4,1,5}, {4,1,5}, {4,1,5}, {4,1,5}, |
- {3,1,5}, {3,1,5}, {3,1,5}, {3,1,5}, |
- {3,1,5}, {3,1,5}, {3,1,5}, {3,1,5} |
-}; |
- |
-/* Table B-15, DCT coefficients table one, |
- * codes 000001xx ... 11111111 |
-*/ |
-DCTtab DCTtab0a[252] = |
-{ |
- {65,0,6}, {65,0,6}, {65,0,6}, {65,0,6}, /* Escape */ |
- {7,1,7}, {7,1,7}, {8,1,7}, {8,1,7}, |
- {6,1,7}, {6,1,7}, {2,2,7}, {2,2,7}, |
- {0,7,6}, {0,7,6}, {0,7,6}, {0,7,6}, |
- {0,6,6}, {0,6,6}, {0,6,6}, {0,6,6}, |
- {4,1,6}, {4,1,6}, {4,1,6}, {4,1,6}, |
- {5,1,6}, {5,1,6}, {5,1,6}, {5,1,6}, |
- {1,5,8}, {11,1,8}, {0,11,8}, {0,10,8}, |
- {13,1,8}, {12,1,8}, {3,2,8}, {1,4,8}, |
- {2,1,5}, {2,1,5}, {2,1,5}, {2,1,5}, |
- {2,1,5}, {2,1,5}, {2,1,5}, {2,1,5}, |
- {1,2,5}, {1,2,5}, {1,2,5}, {1,2,5}, |
- {1,2,5}, {1,2,5}, {1,2,5}, {1,2,5}, |
- {3,1,5}, {3,1,5}, {3,1,5}, {3,1,5}, |
- {3,1,5}, {3,1,5}, {3,1,5}, {3,1,5}, |
- {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3}, |
- {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3}, |
- {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3}, |
- {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3}, |
- {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3}, |
- {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3}, |
- {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3}, |
- {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3}, |
- {64,0,4}, {64,0,4}, {64,0,4}, {64,0,4}, /* EOB */ |
- {64,0,4}, {64,0,4}, {64,0,4}, {64,0,4}, |
- {64,0,4}, {64,0,4}, {64,0,4}, {64,0,4}, |
- {64,0,4}, {64,0,4}, {64,0,4}, {64,0,4}, |
- {0,3,4}, {0,3,4}, {0,3,4}, {0,3,4}, |
- {0,3,4}, {0,3,4}, {0,3,4}, {0,3,4}, |
- {0,3,4}, {0,3,4}, {0,3,4}, {0,3,4}, |
- {0,3,4}, {0,3,4}, {0,3,4}, {0,3,4}, |
- {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, |
- {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, |
- {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, |
- {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, |
- {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, |
- {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, |
- {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, |
- {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, |
- {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, |
- {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, |
- {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, |
- {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, |
- {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, |
- {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, |
- {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, |
- {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, |
- {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3}, |
- {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3}, |
- {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3}, |
- {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3}, |
- {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3}, |
- {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3}, |
- {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3}, |
- {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3}, |
- {0,4,5}, {0,4,5}, {0,4,5}, {0,4,5}, |
- {0,4,5}, {0,4,5}, {0,4,5}, {0,4,5}, |
- {0,5,5}, {0,5,5}, {0,5,5}, {0,5,5}, |
- {0,5,5}, {0,5,5}, {0,5,5}, {0,5,5}, |
- {9,1,7}, {9,1,7}, {1,3,7}, {1,3,7}, |
- {10,1,7}, {10,1,7}, {0,8,7}, {0,8,7}, |
- {0,9,7}, {0,9,7}, {0,12,8}, {0,13,8}, |
- {2,3,8}, {4,2,8}, {0,14,8}, {0,15,8} |
-}; |
- |
-/* Table B-14, DCT coefficients table zero, |
- * codes 0000001000 ... 0000001111 |
- */ |
-DCTtab DCTtab1[8] = |
-{ |
- {16,1,10}, {5,2,10}, {0,7,10}, {2,3,10}, |
- {1,4,10}, {15,1,10}, {14,1,10}, {4,2,10} |
-}; |
- |
-/* Table B-15, DCT coefficients table one, |
- * codes 000000100x ... 000000111x |
- */ |
-DCTtab DCTtab1a[8] = |
-{ |
- {5,2,9}, {5,2,9}, {14,1,9}, {14,1,9}, |
- {2,4,10}, {16,1,10}, {15,1,9}, {15,1,9} |
-}; |
- |
-/* Table B-14/15, DCT coefficients table zero / one, |
- * codes 000000010000 ... 000000011111 |
- */ |
-DCTtab DCTtab2[16] = |
-{ |
- {0,11,12}, {8,2,12}, {4,3,12}, {0,10,12}, |
- {2,4,12}, {7,2,12}, {21,1,12}, {20,1,12}, |
- {0,9,12}, {19,1,12}, {18,1,12}, {1,5,12}, |
- {3,3,12}, {0,8,12}, {6,2,12}, {17,1,12} |
-}; |
- |
-/* Table B-14/15, DCT coefficients table zero / one, |
- * codes 0000000010000 ... 0000000011111 |
- */ |
-DCTtab DCTtab3[16] = |
-{ |
- {10,2,13}, {9,2,13}, {5,3,13}, {3,4,13}, |
- {2,5,13}, {1,7,13}, {1,6,13}, {0,15,13}, |
- {0,14,13}, {0,13,13}, {0,12,13}, {26,1,13}, |
- {25,1,13}, {24,1,13}, {23,1,13}, {22,1,13} |
-}; |
- |
-/* Table B-14/15, DCT coefficients table zero / one, |
- * codes 00000000010000 ... 00000000011111 |
- */ |
-DCTtab DCTtab4[16] = |
-{ |
- {0,31,14}, {0,30,14}, {0,29,14}, {0,28,14}, |
- {0,27,14}, {0,26,14}, {0,25,14}, {0,24,14}, |
- {0,23,14}, {0,22,14}, {0,21,14}, {0,20,14}, |
- {0,19,14}, {0,18,14}, {0,17,14}, {0,16,14} |
-}; |
- |
-/* Table B-14/15, DCT coefficients table zero / one, |
- * codes 000000000010000 ... 000000000011111 |
- */ |
-DCTtab DCTtab5[16] = |
-{ |
- {0,40,15}, {0,39,15}, {0,38,15}, {0,37,15}, |
- {0,36,15}, {0,35,15}, {0,34,15}, {0,33,15}, |
- {0,32,15}, {1,14,15}, {1,13,15}, {1,12,15}, |
- {1,11,15}, {1,10,15}, {1,9,15}, {1,8,15} |
-}; |
- |
-/* Table B-14/15, DCT coefficients table zero / one, |
- * codes 0000000000010000 ... 0000000000011111 |
- */ |
-DCTtab DCTtab6[16] = |
-{ |
- {1,18,16}, {1,17,16}, {1,16,16}, {1,15,16}, |
- {6,3,16}, {16,2,16}, {15,2,16}, {14,2,16}, |
- {13,2,16}, {12,2,16}, {11,2,16}, {31,1,16}, |
- {30,1,16}, {29,1,16}, {28,1,16}, {27,1,16} |
-}; |
- |
Index: tags/rel_1_22/fsf/mpeg2/const.h |
=================================================================== |
--- tags/rel_1_22/fsf/mpeg2/const.h (revision 1310) |
+++ tags/rel_1_22/fsf/mpeg2/const.h (nonexistent) |
@@ -1,141 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * Massimiliano Giorgi <massy@gandalf.sssup.it> |
- * Luca Abeni <luca@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
- |
-/** |
- ------------ |
- CVS : $Id: const.h,v 1.1 2003-09-11 13:55:59 giacomo Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1 $ |
- Last update: $Date: 2003-09-11 13:55:59 $ |
- ------------ |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Marco Dallera and Marco Fiocca |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-/* |
- * AUTO |
- * |
- * Another Unuseful Track simulatOr |
- * |
- * Authors: Marco Dallera |
- * Marco Fiocca |
- * |
- */ |
- |
-/* ------------------ */ |
-/* Useful constants */ |
-/* ------------------ */ |
- |
-#ifndef __CONST_H_ |
- |
-#define __CONST_H_ |
- |
-/* Screen dimensions */ |
-#define SCREEN_WIDTH 800 |
-#define SCREEN_HEIGHT 600 |
-#define SCREEN_BIT_COLORS 8 |
- |
-/* Visible area */ |
-#define TEL_WIDTH 50 |
-#define TEL_HEIGHT 50 |
- |
-/* Car dimensions */ |
-#define CAR_WIDTH 12 |
-#define CAR_HEIGHT 12 |
-#define CAR_W 8 |
-#define CAR_H 10 |
- |
-/* Track dimensions */ |
-#define TRACK_WIDTH 500 |
-#define TRACK_HEIGHT 500 |
- |
-/* Track position */ |
-#define TRACK_X1 0 |
-#define TRACK_Y1 0 |
-#define TRACK_X2 TRACK_X1+TRACK_WIDTH-1 |
-#define TRACK_Y2 TRACK_Y1+TRACK_HEIGHT-1 |
- |
-/* Max number of car on track */ |
-#define MAX_CAR_NUMBER 10 |
-#define DRIVERS_NUMBER 20 |
-#define MAX_DRIVER_NAME_LENGTH 20 |
-#define MAX_TRACK_NAME_LENGTH 20 |
-#define TRACK_NUMBER 4 |
- |
-/* Lap direction */ |
-#define CLOCK 0 |
-#define ANTICLOCK 1 |
- |
-/* Information display coords */ |
-#define CMD_WIDTH TRACK_WIDTH |
-#define CMD_HEIGHT (SCREEN_HEIGHT-TRACK_HEIGHT-3) |
- |
-/* Car position limits */ |
-#define MIN_CAR_X (TRACK_X1 + CAR_WIDTH/2 + 4) |
-#define MIN_CAR_Y (TRACK_Y1 + CAR_HEIGHT/2 + 4) |
-#define MAX_CAR_X (TRACK_X2 - CAR_WIDTH/2 - 4) |
-#define MAX_CAR_Y (TRACK_Y2 - CAR_HEIGHT/2 - 4) |
- |
-/* Road constants */ |
-#define LEFT_ONLY 10 |
-#define RIGHT_ONLY 11 |
-#define ROAD_OK 12 |
-#define NO_ROAD 13 |
- |
-/* Collision constants */ |
-#define COLLISION_LEFT 20 |
-#define COLLISION_RIGHT 21 |
-#define COLLISION_BACK 22 |
-#define NO_COLL 0 |
- |
-/* CAB constants */ |
-#define ROAD_MSG_DIM sizeof(road_info) |
-#define ROAD_MSG_READER 4 |
- |
-#define CAR_MSG_DIM sizeof(car_status) |
-#define CAR_MSG_READER 5 |
- |
-/* Tasks parameters */ |
-#define SENSOR_WCET 3000 |
-#define SENSOR_PERIOD 40000 |
-#define CONTROL_WCET 1000 |
-#define CONTROL_PERIOD 40000 |
- |
-#endif |
- |
Index: tags/rel_1_22/fsf/mpeg2/mpeg2dec.h |
=================================================================== |
--- tags/rel_1_22/fsf/mpeg2/mpeg2dec.h (revision 1310) |
+++ tags/rel_1_22/fsf/mpeg2/mpeg2dec.h (nonexistent) |
@@ -1,129 +0,0 @@ |
-/* mpeg2dec.h, MPEG specific defines */ |
- |
-/* Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved. */ |
- |
-/* |
- * Disclaimer of Warranty |
- * |
- * These software programs are available to the user without any license fee or |
- * royalty on an "as is" basis. The MPEG Software Simulation Group disclaims |
- * any and all warranties, whether express, implied, or statuary, including any |
- * implied warranties or merchantability or of fitness for a particular |
- * purpose. In no event shall the copyright-holder be liable for any |
- * incidental, punitive, or consequential damages of any kind whatsoever |
- * arising from the use of these programs. |
- * |
- * This disclaimer of warranty extends to the user of these programs and user's |
- * customers, employees, agents, transferees, successors, and assigns. |
- * |
- * The MPEG Software Simulation Group does not represent or warrant that the |
- * programs furnished hereunder are free of infringement of any third-party |
- * patents. |
- * |
- * Commercial implementations of MPEG-1 and MPEG-2 video, including shareware, |
- * are subject to royalty fees to patent holders. Many of these patents are |
- * general enough such that they are unavoidable regardless of implementation |
- * design. |
- * |
- */ |
- |
-#define ERROR (-1) |
- |
-#define PICTURE_START_CODE 0x100 |
-#define SLICE_START_CODE_MIN 0x101 |
-#define SLICE_START_CODE_MAX 0x1AF |
-#define USER_DATA_START_CODE 0x1B2 |
-#define SEQUENCE_HEADER_CODE 0x1B3 |
-#define SEQUENCE_ERROR_CODE 0x1B4 |
-#define EXTENSION_START_CODE 0x1B5 |
-#define SEQUENCE_END_CODE 0x1B7 |
-#define GROUP_START_CODE 0x1B8 |
-#define SYSTEM_START_CODE_MIN 0x1B9 |
-#define SYSTEM_START_CODE_MAX 0x1FF |
- |
-#define ISO_END_CODE 0x1B9 |
-#define PACK_START_CODE 0x1BA |
-#define SYSTEM_START_CODE 0x1BB |
- |
-#define VIDEO_ELEMENTARY_STREAM 0x1e0 |
- |
-/* scalable_mode */ |
-#define SC_NONE 0 |
-#define SC_DP 1 |
-#define SC_SPAT 2 |
-#define SC_SNR 3 |
-#define SC_TEMP 4 |
- |
-/* picture coding type */ |
-#define I_TYPE 1 |
-#define P_TYPE 2 |
-#define B_TYPE 3 |
-#define D_TYPE 4 |
- |
-/* picture structure */ |
-#define TOP_FIELD 1 |
-#define BOTTOM_FIELD 2 |
-#define FRAME_PICTURE 3 |
- |
-/* macroblock type */ |
-#define MACROBLOCK_INTRA 1 |
-#define MACROBLOCK_PATTERN 2 |
-#define MACROBLOCK_MOTION_BACKWARD 4 |
-#define MACROBLOCK_MOTION_FORWARD 8 |
-#define MACROBLOCK_QUANT 16 |
-#define SPATIAL_TEMPORAL_WEIGHT_CODE_FLAG 32 |
-#define PERMITTED_SPATIAL_TEMPORAL_WEIGHT_CLASS 64 |
- |
- |
-/* motion_type */ |
-#define MC_FIELD 1 |
-#define MC_FRAME 2 |
-#define MC_16X8 2 |
-#define MC_DMV 3 |
- |
-/* mv_format */ |
-#define MV_FIELD 0 |
-#define MV_FRAME 1 |
- |
-/* chroma_format */ |
-#define CHROMA420 1 |
-#define CHROMA422 2 |
-#define CHROMA444 3 |
- |
-/* extension start code IDs */ |
- |
-#define SEQUENCE_EXTENSION_ID 1 |
-#define SEQUENCE_DISPLAY_EXTENSION_ID 2 |
-#define QUANT_MATRIX_EXTENSION_ID 3 |
-#define COPYRIGHT_EXTENSION_ID 4 |
-#define SEQUENCE_SCALABLE_EXTENSION_ID 5 |
-#define PICTURE_DISPLAY_EXTENSION_ID 7 |
-#define PICTURE_CODING_EXTENSION_ID 8 |
-#define PICTURE_SPATIAL_SCALABLE_EXTENSION_ID 9 |
-#define PICTURE_TEMPORAL_SCALABLE_EXTENSION_ID 10 |
- |
-#define ZIG_ZAG 0 |
- |
-#define PROFILE_422 (128+5) |
-#define MAIN_LEVEL 8 |
- |
-/* Layers: used by Verbose_Flag, Verifier_Flag, Stats_Flag, and Trace_Flag */ |
-#define NO_LAYER 0 |
-#define SEQUENCE_LAYER 1 |
-#define PICTURE_LAYER 2 |
-#define SLICE_LAYER 3 |
-#define MACROBLOCK_LAYER 4 |
-#define BLOCK_LAYER 5 |
-#define EVENT_LAYER 6 |
-#define ALL_LAYERS 7 |
- |
- |
- |
-#define FILENAME_LENGTH 256 |
- |
- |
- |
- |
-#define MB_WEIGHT 32 |
-#define MB_CLASS4 64 |
- |
Index: tags/rel_1_22/fsf/mpeg2/store.c |
=================================================================== |
--- tags/rel_1_22/fsf/mpeg2/store.c (revision 1310) |
+++ tags/rel_1_22/fsf/mpeg2/store.c (nonexistent) |
@@ -1,319 +0,0 @@ |
-/* store.c, picture output routines */ |
- |
-/* Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved. */ |
- |
-/* |
- * Disclaimer of Warranty |
- * |
- * These software programs are available to the user without any license fee or |
- * royalty on an "as is" basis. The MPEG Software Simulation Group disclaims |
- * any and all warranties, whether express, implied, or statuary, including any |
- * implied warranties or merchantability or of fitness for a particular |
- * purpose. In no event shall the copyright-holder be liable for any |
- * incidental, punitive, or consequential damages of any kind whatsoever |
- * arising from the use of these programs. |
- * |
- * This disclaimer of warranty extends to the user of these programs and user's |
- * customers, employees, agents, transferees, successors, and assigns. |
- * |
- * The MPEG Software Simulation Group does not represent or warrant that the |
- * programs furnished hereunder are free of infringement of any third-party |
- * patents. |
- * |
- * Commercial implementations of MPEG-1 and MPEG-2 video, including shareware, |
- * are subject to royalty fees to patent holders. Many of these patents are |
- * general enough such that they are unavoidable regardless of implementation |
- * design. |
- * |
- */ |
- |
-#include <stdlib.h> |
- |
-#include "drivers/glib.h" |
- |
-#include "config.h" |
-#include "global.h" |
- |
-extern DWORD flbaddr; |
- |
-static void conv422to444 _ANSI_ARGS_((unsigned char *src, unsigned char *dst)); |
-static void conv420to422 _ANSI_ARGS_((unsigned char *src, unsigned char *dst)); |
- |
-__inline__ WORD down32to16(unsigned char r, unsigned char g, unsigned char b) |
-{ |
- return ((b&0xf8)>>3)|((g&0xfc)<<3)|((r&0xf8)<<8); |
-} |
- |
-void Write_Frame _ANSI_ARGS_((unsigned char *src[], int frame)) |
-{ |
- int i, j; |
- int y, u, v, r, g, b; |
-// int rm=0,gm=0,bm=0; |
- int crv, cbu, cgu, cgv; |
- unsigned char *py, *pu, *pv; |
- int height, width, incr; |
- static unsigned char *u422, *v422, *u444, *v444; |
- |
- incr = width = Coded_Picture_Width ; |
- height = Coded_Picture_Height; |
- |
- if (chroma_format==CHROMA444) |
- { |
- u444 = src[1]; |
- v444 = src[2]; |
- } |
- else |
- { |
- if (!u444) |
- { |
- if (chroma_format==CHROMA420) |
- { |
- if (!(u422 = (unsigned char *)malloc((Coded_Picture_Width>>1) |
- *Coded_Picture_Height))) |
- Error("malloc failed"); |
- if (!(v422 = (unsigned char *)malloc((Coded_Picture_Width>>1) |
- *Coded_Picture_Height))) |
- Error("malloc failed"); |
- } |
- |
- if (!(u444 = (unsigned char *)malloc(Coded_Picture_Width |
- *Coded_Picture_Height))) |
- Error("malloc failed"); |
- |
- if (!(v444 = (unsigned char *)malloc(Coded_Picture_Width |
- *Coded_Picture_Height))) |
- Error("malloc failed"); |
- } |
- |
- if (chroma_format==CHROMA420) |
- { |
- conv420to422(src[1],u422); |
- conv420to422(src[2],v422); |
- conv422to444(u422,u444); |
- conv422to444(v422,v444); |
- } |
- else |
- { |
- conv422to444(src[1],u444); |
- conv422to444(src[2],v444); |
- } |
- } |
- |
- /* matrix coefficients */ |
- crv = Inverse_Table_6_9[matrix_coefficients][0]; |
- cbu = Inverse_Table_6_9[matrix_coefficients][1]; |
- cgu = Inverse_Table_6_9[matrix_coefficients][2]; |
- cgv = Inverse_Table_6_9[matrix_coefficients][3]; |
- |
- for (i=0; i<height; i++) |
- { |
- py = src[0] + incr*i; |
- pu = u444 + incr*i; |
- pv = v444 + incr*i; |
- |
- for (j=0; j<width; j++) |
- { |
- u = *pu++ - 128; |
- v = *pv++ - 128; |
- y = 76309 * (*py++ - 16); /* (255/219)*65536 */ |
- |
- r = Clip[(y + crv*v + 32768)>>16]; |
- g = Clip[(y - cgu*u - cgv*v + 32768)>>16]; |
- b = Clip[(y + cbu*u + 32786)>>16]; |
- |
- *(WORD *)(flbaddr+((i+ld->py)*800+(j+ld->px))*2) = down32to16(r,g,b); |
- |
- } |
- } |
- |
-} |
- |
-/* |
-void Display_Image(Dithered_Image) |
-unsigned char *Dithered_Image; |
-{ |
- / * display dithered image */ |
-//} |
- |
- |
-/* horizontal 1:2 interpolation filter */ |
-static void conv422to444(src,dst) |
-unsigned char *src,*dst; |
-{ |
- int i, i2, w, j, im3, im2, im1, ip1, ip2, ip3; |
- |
- w = Coded_Picture_Width>>1; |
- |
- if (base.MPEG2_Flag) |
- { |
- for (j=0; j<Coded_Picture_Height; j++) |
- { |
- for (i=0; i<w; i++) |
- { |
- i2 = i<<1; |
- im2 = (i<2) ? 0 : i-2; |
- im1 = (i<1) ? 0 : i-1; |
- ip1 = (i<w-1) ? i+1 : w-1; |
- ip2 = (i<w-2) ? i+2 : w-1; |
- ip3 = (i<w-3) ? i+3 : w-1; |
- |
- /* FIR filter coefficients (*256): 21 0 -52 0 159 256 159 0 -52 0 21 */ |
- /* even samples (0 0 256 0 0) */ |
- dst[i2] = src[i]; |
- |
- /* odd samples (21 -52 159 159 -52 21) */ |
- dst[i2+1] = Clip[(int)(21*(src[im2]+src[ip3]) |
- -52*(src[im1]+src[ip2]) |
- +159*(src[i]+src[ip1])+128)>>8]; |
- } |
- src+= w; |
- dst+= Coded_Picture_Width; |
- } |
- } |
- else |
- { |
- for (j=0; j<Coded_Picture_Height; j++) |
- { |
- for (i=0; i<w; i++) |
- { |
- |
- i2 = i<<1; |
- im3 = (i<3) ? 0 : i-3; |
- im2 = (i<2) ? 0 : i-2; |
- im1 = (i<1) ? 0 : i-1; |
- ip1 = (i<w-1) ? i+1 : w-1; |
- ip2 = (i<w-2) ? i+2 : w-1; |
- ip3 = (i<w-3) ? i+3 : w-1; |
- |
- /* FIR filter coefficients (*256): 5 -21 70 228 -37 11 */ |
- dst[i2] = Clip[(int)( 5*src[im3] |
- -21*src[im2] |
- +70*src[im1] |
- +228*src[i] |
- -37*src[ip1] |
- +11*src[ip2]+128)>>8]; |
- |
- dst[i2+1] = Clip[(int)( 5*src[ip3] |
- -21*src[ip2] |
- +70*src[ip1] |
- +228*src[i] |
- -37*src[im1] |
- +11*src[im2]+128)>>8]; |
- } |
- src+= w; |
- dst+= Coded_Picture_Width; |
- } |
- } |
-} |
- |
-/* vertical 1:2 interpolation filter */ |
-static void conv420to422(src,dst) |
-unsigned char *src,*dst; |
-{ |
- int w, h, i, j, j2; |
- int jm6, jm5, jm4, jm3, jm2, jm1, jp1, jp2, jp3, jp4, jp5, jp6, jp7; |
- |
- w = Coded_Picture_Width>>1; |
- h = Coded_Picture_Height>>1; |
- |
- if (progressive_frame) |
- { |
- /* intra frame */ |
- for (i=0; i<w; i++) |
- { |
- for (j=0; j<h; j++) |
- { |
- j2 = j<<1; |
- jm3 = (j<3) ? 0 : j-3; |
- jm2 = (j<2) ? 0 : j-2; |
- jm1 = (j<1) ? 0 : j-1; |
- jp1 = (j<h-1) ? j+1 : h-1; |
- jp2 = (j<h-2) ? j+2 : h-1; |
- jp3 = (j<h-3) ? j+3 : h-1; |
- |
- /* FIR filter coefficients (*256): 5 -21 70 228 -37 11 */ |
- /* New FIR filter coefficients (*256): 3 -16 67 227 -32 7 */ |
- dst[w*j2] = Clip[(int)( 3*src[w*jm3] |
- -16*src[w*jm2] |
- +67*src[w*jm1] |
- +227*src[w*j] |
- -32*src[w*jp1] |
- +7*src[w*jp2]+128)>>8]; |
- |
- dst[w*(j2+1)] = Clip[(int)( 3*src[w*jp3] |
- -16*src[w*jp2] |
- +67*src[w*jp1] |
- +227*src[w*j] |
- -32*src[w*jm1] |
- +7*src[w*jm2]+128)>>8]; |
- } |
- src++; |
- dst++; |
- } |
- } |
- else |
- { |
- /* intra field */ |
- for (i=0; i<w; i++) |
- { |
- for (j=0; j<h; j+=2) |
- { |
- j2 = j<<1; |
- |
- /* top field */ |
- jm6 = (j<6) ? 0 : j-6; |
- jm4 = (j<4) ? 0 : j-4; |
- jm2 = (j<2) ? 0 : j-2; |
- jp2 = (j<h-2) ? j+2 : h-2; |
- jp4 = (j<h-4) ? j+4 : h-2; |
- jp6 = (j<h-6) ? j+6 : h-2; |
- |
- /* Polyphase FIR filter coefficients (*256): 2 -10 35 242 -18 5 */ |
- /* New polyphase FIR filter coefficients (*256): 1 -7 30 248 -21 5 */ |
- dst[w*j2] = Clip[(int)( 1*src[w*jm6] |
- -7*src[w*jm4] |
- +30*src[w*jm2] |
- +248*src[w*j] |
- -21*src[w*jp2] |
- +5*src[w*jp4]+128)>>8]; |
- |
- /* Polyphase FIR filter coefficients (*256): 11 -38 192 113 -30 8 */ |
- /* New polyphase FIR filter coefficients (*256):7 -35 194 110 -24 4 */ |
- dst[w*(j2+2)] = Clip[(int)( 7*src[w*jm4] |
- -35*src[w*jm2] |
- +194*src[w*j] |
- +110*src[w*jp2] |
- -24*src[w*jp4] |
- +4*src[w*jp6]+128)>>8]; |
- |
- /* bottom field */ |
- jm5 = (j<5) ? 1 : j-5; |
- jm3 = (j<3) ? 1 : j-3; |
- jm1 = (j<1) ? 1 : j-1; |
- jp1 = (j<h-1) ? j+1 : h-1; |
- jp3 = (j<h-3) ? j+3 : h-1; |
- jp5 = (j<h-5) ? j+5 : h-1; |
- jp7 = (j<h-7) ? j+7 : h-1; |
- |
- /* Polyphase FIR filter coefficients (*256): 11 -38 192 113 -30 8 */ |
- /* New polyphase FIR filter coefficients (*256):7 -35 194 110 -24 4 */ |
- dst[w*(j2+1)] = Clip[(int)( 7*src[w*jp5] |
- -35*src[w*jp3] |
- +194*src[w*jp1] |
- +110*src[w*jm1] |
- -24*src[w*jm3] |
- +4*src[w*jm5]+128)>>8]; |
- |
- dst[w*(j2+3)] = Clip[(int)( 1*src[w*jp7] |
- -7*src[w*jp5] |
- +30*src[w*jp3] |
- +248*src[w*jp1] |
- -21*src[w*jm1] |
- +5*src[w*jm3]+128)>>8]; |
- } |
- src++; |
- dst++; |
- } |
- } |
-} |
- |
Index: tags/rel_1_22/fsf/mpeg2/getbits.c |
=================================================================== |
--- tags/rel_1_22/fsf/mpeg2/getbits.c (revision 1310) |
+++ tags/rel_1_22/fsf/mpeg2/getbits.c (nonexistent) |
@@ -1,217 +0,0 @@ |
-/* getbits.c, bit level routines */ |
- |
-/* |
- * All modifications (mpeg2decode -> mpeg2play) are |
- * Copyright (C) 1996, Stefan Eckart. All Rights Reserved. |
- */ |
- |
-/* Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved. */ |
- |
-/* |
- * Disclaimer of Warranty |
- * |
- * These software programs are available to the user without any license fee or |
- * royalty on an "as is" basis. The MPEG Software Simulation Group disclaims |
- * any and all warranties, whether express, implied, or statuary, including any |
- * implied warranties or merchantability or of fitness for a particular |
- * purpose. In no event shall the copyright-holder be liable for any |
- * incidental, punitive, or consequential damages of any kind whatsoever |
- * arising from the use of these programs. |
- * |
- * This disclaimer of warranty extends to the user of these programs and user's |
- * customers, employees, agents, transferees, successors, and assigns. |
- * |
- * The MPEG Software Simulation Group does not represent or warrant that the |
- * programs furnished hereunder are free of infringement of any third-party |
- * patents. |
- * |
- * Commercial implementations of MPEG-1 and MPEG-2 video, including shareware, |
- * are subject to royalty fees to patent holders. Many of these patents are |
- * general enough such that they are unavoidable regardless of implementation |
- * design. |
- * |
- */ |
- |
-#include <stdlib.h> |
- |
-#include "drivers/glib.h" |
- |
-#include "config.h" |
-#include "global.h" |
- |
-/* initialize buffer, call once before first getbits or showbits */ |
- |
-void Initialize_Buffer() |
-{ |
- ld->Incnt = 0; |
- ld->Rdptr = ld->Rdbfr + 2048; |
- ld->Rdmax = ld->Rdptr; |
- |
-#ifdef VERIFY |
- /* only the verifier uses this particular bit counter |
- * Bitcnt keeps track of the current parser position with respect |
- * to the video elementary stream being decoded, regardless |
- * of whether or not it is wrapped within a systems layer stream |
- */ |
- ld->Bitcnt = 0; |
-#endif |
- |
- ld->Bfr = 0; |
- Flush_Buffer(0); /* fills valid data into bfr */ |
-} |
- |
-int read(int Infile, void *Rdbfr, int rdsize) { |
- |
- if (ld->actual_file_ptr + 2048 > ld->end_file_ptr) |
- rdsize = (int)(ld->end_file_ptr - ld->actual_file_ptr); |
- |
- if (rdsize < 0) return 0; |
- |
- memcpy(Rdbfr,ld->actual_file_ptr,rdsize); |
- ld->actual_file_ptr += rdsize; |
- |
- return rdsize; |
- |
-} |
- |
-void Fill_Buffer() |
-{ |
- int Buffer_Level; |
- |
- Buffer_Level = read(ld->Infile,ld->Rdbfr,2048); |
- ld->Rdptr = ld->Rdbfr; |
- |
- if (System_Stream_Flag) |
- ld->Rdmax -= 2048; |
- |
- |
- /* end of the bitstream file */ |
- if (Buffer_Level < 2048) |
- { |
- /* just to be safe */ |
- if (Buffer_Level < 0) |
- Buffer_Level = 0; |
- |
- /* pad until the next to the next 32-bit word boundary */ |
- while (Buffer_Level & 3) |
- ld->Rdbfr[Buffer_Level++] = 0; |
- |
- /* pad the buffer with sequence end codes */ |
- while (Buffer_Level < 2048) |
- { |
- ld->Rdbfr[Buffer_Level++] = SEQUENCE_END_CODE>>24; |
- ld->Rdbfr[Buffer_Level++] = SEQUENCE_END_CODE>>16; |
- ld->Rdbfr[Buffer_Level++] = SEQUENCE_END_CODE>>8; |
- ld->Rdbfr[Buffer_Level++] = SEQUENCE_END_CODE&0xff; |
- } |
- } |
-} |
- |
- |
-/* MPEG-1 system layer demultiplexer */ |
- |
-int Get_Byte() |
-{ |
- while(ld->Rdptr >= ld->Rdbfr+2048) |
- { |
- read(ld->Infile,ld->Rdbfr,2048); |
- ld->Rdptr -= 2048; |
- ld->Rdmax -= 2048; |
- } |
- return *ld->Rdptr++; |
-} |
- |
-/* extract a 16-bit word from the bitstream buffer */ |
-int Get_Word() |
-{ |
- int Val; |
- |
- Val = Get_Byte(); |
- return (Val<<8) | Get_Byte(); |
-} |
- |
- |
-/* return next n bits (right adjusted) without advancing */ |
- |
-unsigned int Show_Bits(N) |
-int N; |
-{ |
- return ld->Bfr >> (32-N); |
-} |
- |
- |
-/* return next bit (could be made faster than Get_Bits(1)) */ |
- |
-unsigned int Get_Bits1() |
-{ |
- return Get_Bits(1); |
-} |
- |
- |
-/* advance by n bits */ |
- |
-void Flush_Buffer(N) |
-int N; |
-{ |
- int Incnt; |
- |
- ld->Bfr <<= N; |
- |
- Incnt = ld->Incnt -= N; |
- |
- if (Incnt <= 24) |
- { |
- if (System_Stream_Flag && (ld->Rdptr >= ld->Rdmax-4)) |
- { |
- do |
- { |
- if (ld->Rdptr >= ld->Rdmax) |
- Next_Packet(); |
- ld->Bfr |= Get_Byte() << (24 - Incnt); |
- Incnt += 8; |
- } |
- while (Incnt <= 24); |
- } |
- else if (ld->Rdptr < ld->Rdbfr+2044) |
- { |
- do |
- { |
- ld->Bfr |= *ld->Rdptr++ << (24 - Incnt); |
- Incnt += 8; |
- } |
- while (Incnt <= 24); |
- } |
- else |
- { |
- do |
- { |
- if (ld->Rdptr >= ld->Rdbfr+2048) |
- Fill_Buffer(); |
- ld->Bfr |= *ld->Rdptr++ << (24 - Incnt); |
- Incnt += 8; |
- } |
- while (Incnt <= 24); |
- } |
- ld->Incnt = Incnt; |
- } |
- |
-#ifdef VERIFY |
- ld->Bitcnt += N; |
-#endif /* VERIFY */ |
- |
-} |
- |
- |
-/* return next n bits (right adjusted) */ |
- |
-unsigned int Get_Bits(N) |
-int N; |
-{ |
- unsigned int Val; |
- |
- Val = Show_Bits(N); |
- Flush_Buffer(N); |
- |
- return Val; |
-} |
- |
Index: tags/rel_1_22/fsf/makefile |
=================================================================== |
--- tags/rel_1_22/fsf/makefile (revision 1310) |
+++ tags/rel_1_22/fsf/makefile (nonexistent) |
@@ -1,23 +0,0 @@ |
-# |
-# |
- |
-BASE=../.. |
-include $(BASE)/config/config.mk |
- |
-PROGS= test1 test2 test3 |
- |
-MPEG2 = ./mpeg2/getbits.o ./mpeg2/getblk.o ./mpeg2/gethdr.o ./mpeg2/getpic.o\ |
- ./mpeg2/getvlc.o ./mpeg2/idct.o ./mpeg2/idctref.o ./mpeg2/motion.o\ |
- ./mpeg2/mpeg2dec.o ./mpeg2/recon.o ./mpeg2/spatscal.o ./mpeg2/store.o\ |
- ./mpeg2/subspic.o ./mpeg2/systems.o ./mpeg2/verify.o ./mpeg2/gvideo.o |
- |
-include $(BASE)/config/example.mk |
- |
-test1: |
- make -f $(SUBMAKE) APP=test1 INIT= OTHEROBJS= OTHERINCL= SHARKOPT="__OLDCHAR__ __FIRST__" |
- |
-test2: |
- make -f $(SUBMAKE) APP=test2 INIT= OTHEROBJS="initfile.o $(MPEG2)" OTHERINCL= SHARKOPT="__OLDCHAR__ __GRX__ __FIRST__" |
-test3: |
- make -f $(SUBMAKE) APP=test3 INIT= OTHEROBJS= OTHERINCL= SHARKOPT="__OLDCHAR__ __FIRST__" |
- |
Index: tags/rel_1_22/fsf/test1.c |
=================================================================== |
--- tags/rel_1_22/fsf/test1.c (revision 1310) |
+++ tags/rel_1_22/fsf/test1.c (nonexistent) |
@@ -1,352 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Giacomo Guidi <giacomo@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2002 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include "kernel/kern.h" |
- |
-#include "modules/edf.h" |
-#include "modules/cbs.h" |
- |
-#include "pthread.h" |
-#include "modules/posix.h" |
- |
-#include "fsf_contract.h" |
-#include "fsf_server.h" |
- |
-#include "modules/dummy.h" |
- |
-#include "modules/sem.h" |
-#include "modules/pi.h" |
-#include "modules/pc.h" |
- |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
- |
-#include "drivers/keyb.h" |
-#include <stdlib.h> |
- |
-// -------------------------------------------------- |
-// -------------------------------------------------- |
-// Init Part |
-// -------------------------------------------------- |
-// -------------------------------------------------- |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 0 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 10000 |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- int grubstar_level; |
- |
- EDF_register_level(EDF_ENABLE_ALL); |
- POSIX_register_level(RRTICK, 1, mb, 32); |
- grubstar_level = GRUBSTAR_register_level(4, 0); |
- FSF_register_module(grubstar_level); |
- dummy_register_level(); |
- |
- // for the keyboard... |
- CBS_register_level(CBS_ENABLE_ALL, 0); |
- |
- PI_register_module(); |
- PC_register_module(); |
- |
- SEM_register_module(); |
- |
- PTHREAD_register_module(1, 0, 1); |
- |
- return TICK; |
-} |
- |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- HARTPORT_init(); |
- |
- KEYB_init(NULL); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
- |
-} |
- |
-// -------------------------------------------------- |
-// -------------------------------------------------- |
-// The Test |
-// -------------------------------------------------- |
-// -------------------------------------------------- |
- |
-pthread_t j1 = -1; |
-pthread_t j2 = -1; |
-pthread_t j3 = -1; |
-pthread_t j4 = -1; |
-fsf_server_id_t server1 = -1; |
-fsf_server_id_t server2 = -1; |
-fsf_server_id_t server3 = -1; |
-fsf_server_id_t server4 = -1; |
-fsf_contract_parameters_t contract1, contract2; |
- |
-pthread_mutex_t mux; |
- |
-#define TASK_PERIOD 1000000 |
- |
-void *periodic_star(void *arg) |
-{ |
- struct timespec actual,end,next_time; |
- int actpersecond,act,cycle; |
- int mean,nmean; |
- bool was_deadline_missed, was_budget_overran; |
- |
- act = 0; |
- actpersecond = 0; |
- mean = 0; |
- nmean = 0; |
- cycle = 0; |
- for (;;) { |
- |
- kern_gettime(&actual); |
- cycle++; |
- |
- if (act == 0) { |
- TIMESPEC_ASSIGN(&end,&actual); |
- end.tv_sec++; |
- } |
- |
- if (TIMESPEC_A_LT_B(&actual,&end)) { |
- act++; |
- } else { |
- actpersecond = act; |
- act = 0; |
- mean = (mean * nmean + actpersecond) / (nmean+1); |
- nmean++; |
- } |
- |
- //pthread_mutex_lock(&mux); |
- printf_xy(0,exec_shadow,WHITE,"Thread %3d Act_per_Second = %8d Mean = %8d Cycle = %8d", |
- exec_shadow,actpersecond,mean,cycle); |
- //pthread_mutex_unlock(&mux); |
- |
- kern_gettime(&next_time); |
- ADDUSEC2TIMESPEC(TASK_PERIOD, &next_time); |
- fsf_schedule_next_timed_job(NULL, NULL, NULL, &was_deadline_missed, &was_budget_overran); |
- |
- } |
- |
- return NULL; |
- |
-} |
- |
-void *star(void *arg) |
-{ |
- struct timespec actual,end; |
- int actpersecond,act; |
- int mean,nmean,cycle; |
- |
- act = 0; |
- actpersecond = 0; |
- mean = 0; |
- nmean = 0; |
- cycle = 0; |
- for (;;) { |
- |
- cycle++; |
- kern_gettime(&actual); |
- |
- if (act == 0) { |
- TIMESPEC_ASSIGN(&end,&actual); |
- end.tv_sec++; |
- } |
- |
- if (TIMESPEC_A_LT_B(&actual,&end)) { |
- act++; |
- } else { |
- actpersecond = act; |
- act = 0; |
- mean = (mean * nmean + actpersecond) / (nmean+1); |
- nmean++; |
- } |
- |
- //pthread_mutex_lock(&mux); |
- printf_xy(0,exec_shadow,WHITE,"Thread %3d Act_per_Second = %8d Mean = %8d Cycle = %8d", |
- exec_shadow,actpersecond,mean,cycle); |
- //pthread_mutex_unlock(&mux); |
- |
- } |
- |
- return NULL; |
- |
-} |
- |
-void *edftask(void *arg) |
-{ |
- int i,j; |
- while(1) { |
- for (i=0;i<5; i++) { |
- for (j=0; j<10; j++); |
- //cputc('#'); |
- //cputs((char *)(arg)); |
- } |
- |
- task_endcycle(); |
- } |
- |
- return NULL; |
-} |
- |
- |
-void create() |
-{ |
- HARD_TASK_MODEL mhard; |
- |
- struct timespec period1 = {0,100000000}; |
- struct timespec period2 = {0,100000000}; |
- struct timespec budget1 = {0,30000000}; |
- struct timespec budget2 = {0,30000000}; |
- |
- PID t1, t2; |
- |
- kern_printf("(Start Create)"); |
- |
- hard_task_default_model(mhard); |
- hard_task_def_ctrl_jet(mhard); |
- hard_task_def_mit(mhard,32000); |
- hard_task_def_wcet(mhard,3000); |
- hard_task_def_arg(mhard,(void *)"X"); |
- hard_task_def_group(mhard,1); |
- hard_task_def_periodic(mhard); |
- |
- t1 = task_create("X", edftask, &mhard, NULL); |
- if (t1 == NIL) { |
- perror("Could not create task X ..."); |
- sys_end(); |
- } |
- |
- hard_task_def_mit(mhard,32000); |
- hard_task_def_wcet(mhard,3000); |
- hard_task_def_arg(mhard,(void *)"Y"); |
- t2 = task_create("Y", edftask, &mhard, NULL); |
- if (t2 == NIL) { |
- perror("Could not create task Y ..."); |
- sys_end(); |
- } |
- |
- group_activate(1); |
- |
- fsf_initialize_contract(&contract1); |
- fsf_set_contract_basic_parameters(&contract1,&budget1,&period1,NULL,NULL,FSF_DEFAULT_WORKLOAD); |
- fsf_initialize_contract(&contract2); |
- fsf_set_contract_basic_parameters(&contract2,&budget2,&period2,NULL,NULL,FSF_DEFAULT_WORKLOAD); |
- |
- kern_printf("(End Create)"); |
- |
-} |
- |
-int main(int argc, char **argv) |
-{ |
- |
- NRT_TASK_MODEL nrt; |
- char ch = 0; |
- int err; |
- |
- pthread_mutex_init(&mux,NULL); |
- |
- create(); |
- |
- nrt_task_default_model(nrt); |
- nrt_task_def_save_arrivals(nrt); |
- nrt_task_def_ctrl_jet(nrt); |
- |
- do { |
- ch = keyb_getch(BLOCK); |
- |
- switch(ch) { |
- case '1': |
- err = fsf_create_thread(server1,&j1,NULL,star,NULL,&nrt); |
- kern_printf("(%d)",err); |
- break; |
- case '2': |
- err = fsf_create_thread(server2,&j2,NULL,star,NULL,&nrt); |
- kern_printf("(%d)",err); |
- break; |
- case '3': |
- err = fsf_create_thread(server1,&j3,NULL,star,NULL,&nrt); |
- kern_printf("(%d)",err); |
- break; |
- case '4': |
- err = fsf_create_thread(server2,&j4,NULL,star,NULL,&nrt); |
- kern_printf("(%d)",err); |
- break; |
- case 'q': |
- err = fsf_negotiate_contract(&contract1,&server1); |
- cprintf("(%d)",err); |
- break; |
- case 'w': |
- err = fsf_negotiate_contract(&contract2,&server2); |
- kern_printf("(%d)",err); |
- break; |
- case 'e': |
- err = fsf_negotiate_contract(&contract1,&server3); |
- kern_printf("(%d)",err); |
- break; |
- case 'r': |
- err = fsf_cancel_contract(&server1); |
- kern_printf("(%d)",err); |
- break; |
- case 't': |
- err = fsf_cancel_contract(&server2); |
- kern_printf("(%d)",err); |
- break; |
- case 'y': |
- err = fsf_cancel_contract(&server3); |
- kern_printf("(%d)",err); |
- break; |
- |
- } |
- |
- } while(ch != ESC); |
- |
- sys_end(); |
- |
- return 0; |
- |
-} |
- |
Index: tags/rel_1_22/fsf/test2.c |
=================================================================== |
--- tags/rel_1_22/fsf/test2.c (revision 1310) |
+++ tags/rel_1_22/fsf/test2.c (nonexistent) |
@@ -1,302 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Giacomo Guidi <giacomo@gandalf.sssup.it> |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- */ |
- |
-#include "kernel/kern.h" |
- |
-#include "fsf_contract.h" |
- |
-#include "stdlib.h" |
-#include "unistd.h" |
-#include "string.h" |
- |
-#include "pthread.h" |
- |
-#include "drivers/keyb.h" |
-#include "drivers/glib.h" |
- |
-#define TEST_PERIOD 50000 |
- |
-mutex_t mux; |
- |
-void program_key_end(KEY_EVT *k) |
-{ |
- |
- sys_end(); |
- |
-} |
- |
-void print_timer(int x, int y) |
-{ |
- |
- long nsec,sec,min,hrs,day; |
- struct timespec actual_timer; |
- char tmp[100]; |
- |
- sys_gettime(&actual_timer); |
- |
- nsec = actual_timer.tv_nsec; |
- sec = actual_timer.tv_sec; |
- min = sec / 60; |
- sec %= 60; |
- hrs = min / 60; |
- min %= 60; |
- day = hrs / 24; |
- hrs %= 24; |
- |
- sprintf(tmp,"Time: %2ld d %2ld h %2ld m %2ld s %12ld ns",day,hrs,min,sec,(long)nsec); |
- //mutex_lock(&mux); |
- grx_text(tmp,x,y,rgb16(255,255,255),0); |
- //mutex_unlock(&mux); |
- |
-} |
- |
-#define LOAD_VARIATION 10 |
- |
-#define MAX_V_QOS 30 |
-#define MIN_V_QOS 2 |
- |
-void *test_task_variable(void *arg) { |
- |
- char tmp[100]; |
- |
- long long i; |
- int task_qos; |
- int var_load, rd_per; |
- |
- TIME exectime; |
- |
- task_qos = 7; |
- var_load = 5; |
- rd_per = 0; |
- |
- while(1) { |
- |
- print_timer(307,10+30*exec_shadow); |
- sprintf(tmp,"Test Thread V QOS = %5d PID = %3d VLOAD = %3d",task_qos,exec_shadow,var_load); |
- |
- //mutex_lock(&mux); |
- grx_text(tmp,307,20+30*exec_shadow,rgb16(255,255,255),0); |
- //mutex_unlock(&mux); |
- |
- jet_gettable(exec_shadow, &exectime, 1); |
- sprintf(tmp,"Thread Exec Timer = %10d us",(int)exectime); |
- grx_text(tmp,307,30+30*exec_shadow,rgb16(255,255,255),0); |
- |
- if (rd_per > LOAD_VARIATION) { |
- var_load += rand()%3-1; |
- if (var_load > 20) var_load = 20; |
- if (var_load < 0) var_load = 0; |
- rd_per = 0; |
- } else { |
- rd_per++; |
- } |
- |
- for(i = 0; i < 10000*(task_qos+var_load); i++); |
- |
- } |
- |
- return NULL; |
- |
-} |
- |
-#define MAX_C_QOS 30 |
-#define MIN_C_QOS 2 |
- |
-void *test_task_constant(void *arg) { |
- |
- char tmp[100]; |
- |
- long long i; |
- int task_qos; |
- |
- task_qos = 7; |
- |
- while(1) { |
- |
- print_timer(307,10+20*exec_shadow); |
- sprintf(tmp,"Test Task C QOS = %5d PID = %3d",task_qos,exec_shadow); |
- //mutex_lock(&mux); |
- grx_text(tmp,307,20+20*exec_shadow,rgb16(255,255,255),0); |
- //mutex_unlock(&mux); |
- |
- for(i = 0; i < 10000*task_qos; i++); |
- |
- } |
- |
- return NULL; |
- |
-} |
- |
-void draw_box(int x1, int y1, int x2, int y2) |
-{ |
- |
- grx_rect(x1,y1,x2,y2,rgb16(160,160,160)); |
- grx_rect(x1+2,y1+2,x2-2,y2-2,rgb16(210,210,210)); |
- |
-} |
- |
-void layout_screen() |
-{ |
- |
- draw_box(0,0,300,500); |
- grx_text("Application Task List",5,5,rgb16(255,255,255),0); |
- |
- draw_box(303,0,799,500); |
- grx_text("Task Output",305,5,rgb16(255,255,255),0); |
- |
- draw_box(0,503,799,599); |
- grx_line(140,505,140,597,rgb16(255,255,255)); |
- grx_line(140,583,797,583,rgb16(255,255,255)); |
- |
- grx_text("Application Statistics",142,507,rgb16(255,255,255),0); |
- |
-} |
- |
-void program_end() |
-{ |
- |
- grx_close(); |
- |
-} |
- |
-void *mpeg2decoder(void *arg); |
- |
-void add_posixstar_thread(fsf_server_id_t server) |
-{ |
- NRT_TASK_MODEL nrt; |
- pthread_t j = -1; |
- |
- nrt_task_default_model(nrt); |
- fsf_create_thread(server, &j, NULL, test_task_variable, NULL, &nrt); |
- |
-} |
- |
-void add_edfstar_thread(fsf_server_id_t server) |
-{ |
- |
- pthread_t j = -1; |
- HARD_TASK_MODEL ht; |
- |
- hard_task_default_model(ht); |
- hard_task_def_mit(ht,100000); |
- hard_task_def_wcet(ht,90000); |
- |
- fsf_create_thread(server, &j, NULL, mpeg2decoder, NULL, &ht); |
- |
-} |
- |
-int main(int argc, char **argv) |
-{ |
- |
- char ch; |
- int err; |
- |
- KEY_EVT k; |
- |
- PI_mutexattr_t a; |
- |
- struct timespec period1 = {0,10000000}; |
- struct timespec period2 = {0,10000000}; |
- struct timespec budget1 = {0,4000000}; |
- struct timespec budget2 = {0,4000000}; |
- |
- fsf_server_id_t server1, server2; |
- fsf_contract_parameters_t contract1, contract2; |
- |
- sys_atrunlevel(program_end, NULL, RUNLEVEL_BEFORE_EXIT); |
- |
- k.flag = ALTL_BIT; |
- k.scan = KEY_C; |
- k.ascii = 'c'; |
- keyb_hook(k,program_key_end); |
- |
- srand(sys_gettime(NULL)); |
- |
- // graphic card Initialization |
- if (grx_init() < 1) { |
- sys_end(); |
- } |
- |
- if (grx_open(800, 600, 16) < 0) { |
- cprintf("GRX Err\n"); |
- sys_end(); |
- } |
- |
- layout_screen(); |
- |
- PI_mutexattr_default(a); |
- |
- mutex_init(&mux,&a); |
- |
- fsf_initialize_contract(&contract1); |
- fsf_set_contract_basic_parameters(&contract1,&budget1,&period1,NULL,NULL,FSF_DEFAULT_WORKLOAD); |
- fsf_initialize_contract(&contract2); |
- fsf_set_contract_basic_parameters(&contract2,&budget2,&period2,NULL,NULL,FSF_DEFAULT_WORKLOAD); |
- fsf_set_local_scheduler_parameter(&contract2, FSF_SCHEDULER_EDF); |
- |
- err = fsf_negotiate_contract(&contract1,&server1); |
- if (err) cprintf("(FSF ERROR %d)",err); |
- err = fsf_negotiate_contract(&contract2,&server2); |
- if (err) cprintf("(FSF ERROR %d)",err); |
- |
- ch = keyb_getch(BLOCK); |
- |
- while(ch != ESC) { |
- |
- switch (ch) { |
- |
- case '1': |
- add_posixstar_thread(server1); |
- break; |
- case '2': |
- add_edfstar_thread(server2); |
- break; |
- case '3': |
- break; |
- case '4': |
- break; |
- case '5': |
- break; |
- } |
- |
- ch = keyb_getch(BLOCK); |
- |
- } |
- |
- sys_end(); |
- |
- return 0; |
- |
-} |
Index: tags/rel_1_22/fsf/test3.c |
=================================================================== |
--- tags/rel_1_22/fsf/test3.c (revision 1310) |
+++ tags/rel_1_22/fsf/test3.c (nonexistent) |
@@ -1,379 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Giacomo Guidi <giacomo@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2002 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include "kernel/kern.h" |
- |
-#include "modules/edf.h" |
-#include "modules/cbs.h" |
- |
-#include "pthread.h" |
-#include "modules/posix.h" |
- |
-#include "fsf_contract.h" |
-#include "fsf_server.h" |
- |
-#include "modules/dummy.h" |
- |
-#include "modules/sem.h" |
-#include "modules/pi.h" |
-#include "modules/pc.h" |
- |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
- |
-#include "drivers/keyb.h" |
-#include <stdlib.h> |
- |
-// -------------------------------------------------- |
-// -------------------------------------------------- |
-// Init Part |
-// -------------------------------------------------- |
-// -------------------------------------------------- |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 0 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 10000 |
- |
-int grubstar_level; |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- EDF_register_level(EDF_ENABLE_ALL); |
- POSIX_register_level(RRTICK, 1, mb, 32); |
- grubstar_level = GRUBSTAR_register_level(5, 0); |
- FSF_register_module(grubstar_level); |
- dummy_register_level(); |
- |
- // for the keyboard... |
- CBS_register_level(CBS_ENABLE_ALL, 0); |
- |
- PI_register_module(); |
- PC_register_module(); |
- |
- SEM_register_module(); |
- |
- PTHREAD_register_module(1, 0, 1); |
- |
- return TICK; |
-} |
- |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- HARTPORT_init(); |
- |
- KEYB_init(NULL); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
- |
-} |
- |
-// -------------------------------------------------- |
-// -------------------------------------------------- |
-// The Test |
-// -------------------------------------------------- |
-// -------------------------------------------------- |
- |
-pthread_t jposix = -1; |
-pthread_t j1 = -1; |
-pthread_t j2 = -1; |
-pthread_t j3 = -1; |
-pthread_t j4 = -1; |
-fsf_server_id_t server1 = -1; |
-fsf_server_id_t server2 = -1; |
-fsf_server_id_t server3 = -1; |
-fsf_server_id_t server4 = -1; |
-fsf_contract_parameters_t contract; |
- |
-pthread_mutex_t mux; |
- |
-void *posix(void *arg) |
-{ |
- struct timespec actual,end; |
- int actpersecond,act; |
- int cycle; |
- |
- act = 0; |
- actpersecond = 0; |
- cycle = 0; |
- for (;;) { |
- |
- cycle++; |
- kern_gettime(&actual); |
- |
- if (act == 0) { |
- TIMESPEC_ASSIGN(&end,&actual); |
- end.tv_sec++; |
- } |
- |
- if (TIMESPEC_A_LT_B(&actual,&end)) { |
- act++; |
- } else { |
- actpersecond = act; |
- act = 0; |
- } |
- |
- pthread_mutex_lock(&mux); |
- printf_xy(0,exec_shadow,GREEN,"Thread %3d Act_per_Second = %8d cycle = %8d", |
- exec_shadow,actpersecond,cycle); |
- pthread_mutex_unlock(&mux); |
- |
- } |
- |
- return NULL; |
- |
-} |
- |
-void *star(void *arg) |
-{ |
- struct timespec actual,end; |
- int actpersecond,act; |
- int cycle,rec; |
- |
- act = 0; |
- actpersecond = 0; |
- cycle = 0; |
- rec = 0; |
- for (;;) { |
- |
- cycle++; |
- kern_gettime(&actual); |
- rec = SERVER_get_last_reclaiming(grubstar_level,exec_shadow); |
- |
- if (act == 0) { |
- TIMESPEC_ASSIGN(&end,&actual); |
- end.tv_sec++; |
- } |
- |
- if (TIMESPEC_A_LT_B(&actual,&end)) { |
- act++; |
- } else { |
- actpersecond = act; |
- act = 0; |
- } |
- |
- pthread_mutex_lock(&mux); |
- printf_xy(0,exec_shadow,WHITE,"Thread %3d Act_per_Second = %8d cycle = %8d rec = %8d", |
- exec_shadow,actpersecond,cycle,rec); |
- pthread_mutex_unlock(&mux); |
- |
- } |
- |
- return NULL; |
- |
-} |
- |
-void *periodic_star(void *arg) |
-{ |
- struct timespec actual,end; |
- int actpersecond,act; |
- int cycle,rec; |
- |
- act = 0; |
- actpersecond = 0; |
- cycle = 0; |
- rec = 0; |
- for (;;) { |
- |
- cycle++; |
- kern_gettime(&actual); |
- rec = SERVER_get_last_reclaiming(grubstar_level,exec_shadow); |
- |
- if (act == 0) { |
- TIMESPEC_ASSIGN(&end,&actual); |
- end.tv_sec++; |
- } |
- |
- if (TIMESPEC_A_LT_B(&actual,&end)) { |
- act++; |
- } else { |
- actpersecond = act; |
- act = 0; |
- } |
- |
- pthread_mutex_lock(&mux); |
- printf_xy(0,exec_shadow,RED,"Thread %3d Act_per_Second = %8d cycle = %8d rec = %8d", |
- exec_shadow,actpersecond,cycle,rec); |
- pthread_mutex_unlock(&mux); |
- |
- task_endcycle(); |
- |
- } |
- |
- return NULL; |
- |
-} |
- |
-int keyinc = 5; |
- |
-void *edftask(void *arg) |
-{ |
- long long j; |
- while(1) { |
- for (j=0; j<10000*keyinc; j++); |
- task_endcycle(); |
- } |
- |
- return NULL; |
-} |
- |
- |
-void create() |
-{ |
- HARD_TASK_MODEL mhard; |
- int err; |
- |
- struct timespec period1 = {0,90000000}; //30% |
- struct timespec period2 = {0,300000000}; //20% |
- struct timespec period3 = {0,300000000}; //10% |
- struct timespec budget1 = {0,30000000}; |
- struct timespec budget2 = {0,60000000}; |
- struct timespec budget3 = {0,30000000}; |
- |
- PID t1, t2; |
- |
- kern_printf("(Start Create)"); |
- |
- hard_task_default_model(mhard); |
- hard_task_def_ctrl_jet(mhard); |
- hard_task_def_mit(mhard,30000); //5% |
- hard_task_def_wcet(mhard,1500); |
- hard_task_def_arg(mhard,(void *)"X"); |
- hard_task_def_group(mhard,1); |
- hard_task_def_periodic(mhard); |
- hard_task_def_level(mhard,0); |
- |
- t1 = task_create("X", edftask, &mhard, NULL); |
- if (t1 == NIL) { |
- perror("Could not create task X ..."); |
- sys_end(); |
- } |
- |
- hard_task_def_mit(mhard,30000); //5% |
- hard_task_def_wcet(mhard,1500); |
- hard_task_def_arg(mhard,(void *)"Y"); |
- t2 = task_create("Y", edftask, &mhard, NULL); |
- if (t2 == NIL) { |
- perror("Could not create task Y ..."); |
- sys_end(); |
- } |
- |
- group_activate(1); |
- |
- fsf_initialize_contract(&contract); |
- |
- fsf_set_contract_basic_parameters(&contract,&budget1,&period1,NULL,NULL,FSF_DEFAULT_WORKLOAD); |
- fsf_negotiate_contract(&contract,&server1); |
- |
- fsf_set_contract_basic_parameters(&contract,&budget2,&period2,NULL,NULL,FSF_DEFAULT_WORKLOAD); |
- fsf_negotiate_contract(&contract,&server2); |
- |
- fsf_set_contract_basic_parameters(&contract,&budget3,&period3,NULL,NULL,FSF_DEFAULT_WORKLOAD); |
- fsf_negotiate_contract(&contract,&server3); |
- |
- fsf_set_contract_basic_parameters(&contract,&budget2,&period2,NULL,NULL,FSF_DEFAULT_WORKLOAD); |
- fsf_set_local_scheduler_parameter(&contract, FSF_SCHEDULER_EDF); |
- fsf_negotiate_contract(&contract,&server4); |
- |
- err = pthread_create(&jposix, NULL, posix, NULL); |
- if (err) kern_printf("(Error creating posix task)"); |
- |
- kern_printf("(End Create)"); |
- |
-} |
- |
-int main(int argc, char **argv) |
-{ |
- |
- int err; |
- HARD_TASK_MODEL ht; |
- NRT_TASK_MODEL nrt; |
- struct timespec endtimer; |
- |
- pthread_mutex_init(&mux,NULL); |
- |
- srand(kern_gettime(NULL)); |
- create(); |
- |
- nrt_task_default_model(nrt); |
- |
- kern_gettime(&endtimer); |
- endtimer.tv_sec += 20; |
- kern_event_post(&endtimer, (void (*)(void *))(sys_end), NULL); |
- |
- err = fsf_create_thread(server1,&j1,NULL,star,NULL,&nrt); |
- kern_printf("(%d)",err); |
- |
- err = fsf_create_thread(server2,&j2,NULL,star,NULL,&nrt); |
- kern_printf("(%d)",err); |
- |
- err = fsf_create_thread(server3,&j3,NULL,star,NULL,&nrt); |
- kern_printf("(%d)",err); |
- |
- hard_task_default_model(ht); |
- hard_task_def_mit(ht,200000); |
- hard_task_def_wcet(ht,50000); |
- err = fsf_create_thread(server4,&j4,NULL,periodic_star,NULL,&ht); |
- kern_printf("(%d)",err); |
- |
-/* hard_task_default_model(ht); |
- hard_task_def_mit(ht,159000); |
- hard_task_def_wcet(ht,50000); |
- err = fsf_create_thread(server4,&j4,NULL,periodic_star,NULL,&ht); |
- kern_printf("(%d)",err); |
-*/ |
- err = fsf_create_thread(server1,&j1,NULL,star,NULL,&nrt); |
- kern_printf("(%d)",err); |
- |
- err = fsf_create_thread(server2,&j2,NULL,star,NULL,&nrt); |
- kern_printf("(%d)",err); |
- |
- err = fsf_create_thread(server3,&j3,NULL,star,NULL,&nrt); |
- kern_printf("(%d)",err); |
- |
- return 0; |
- |
-} |
- |
Index: tags/rel_1_22/tracer/utils/types.h |
=================================================================== |
--- tags/rel_1_22/tracer/utils/types.h (revision 1310) |
+++ tags/rel_1_22/tracer/utils/types.h (nonexistent) |
@@ -1,55 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * Massimiliano Giorgi <massy@gandalf.sssup.it> |
- * Luca Abeni <luca@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Massimiliano Giorgi |
- * Copyright (C) 2002 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * CVS : $Id: types.h,v 1.2 2002-10-28 08:07:32 pj Exp $ |
- */ |
- |
-#ifndef __TYPES_H__ |
-#define __TYPES_H__ |
- |
-#include <sys/types.h> |
- |
-/* when compiling under MSDOS, uncomment this three typedefs!!! */ |
- |
-//typedef unsigned char u_int8_t; |
-//typedef unsigned short u_int16_t; |
-//typedef unsigned long u_int32_t; |
- |
-#include <types.h> |
-#endif |
- |
Index: tags/rel_1_22/tracer/utils/tdump.c |
=================================================================== |
--- tags/rel_1_22/tracer/utils/tdump.c (revision 1310) |
+++ tags/rel_1_22/tracer/utils/tdump.c (nonexistent) |
@@ -1,115 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * Massimiliano Giorgi <massy@gandalf.sssup.it> |
- * Luca Abeni <luca@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Massimiliano Giorgi |
- * Copyright (C) 2002 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * CVS : $Id: tdump.c,v 1.2 2002-10-28 08:07:32 pj Exp $ |
- */ |
- |
-/* this example simply prints a Shark trace file */ |
- |
-#include <netinet/in.h> |
- |
-#include <stdio.h> |
-#include "types.h" |
-#include <trace.h> |
-#include "util.h" |
- |
-int dumpsys(trc_system_event_t *sys) |
-{ |
- /* |
- if (sys->event==TRC_SCHEDULE) { |
- //if (sys->prev!=65535) |
- // printf("%02i->%02i\n",sys->prev,sys->task); |
- //else |
- printf("??->%02i\n",sys->task); |
- return 0; |
- } |
- */ |
- printf("%02i\n",sys->task); |
- return 0; |
-} |
- |
-int dumpusr(trc_user_event_t *usr) |
-{ |
- printf("%8li ",usr->n); |
- printf("\n"); |
- return 0; |
-} |
- |
-int dumpsem(trc_sem_event_t *sem) |
-{ |
- printf("on [%i]\n",sem->id); |
- return 0; |
-} |
- |
-int dumpfunc(trc_event_t *ev) |
-{ |
- static int counter=0; |
- |
- printf("%4i ",counter); |
- counter++; |
- printf("%12s ",format_time(ev->time)); |
- printf("%-10s ",event_name(ev->event)); |
- |
- //printf("%08x\n",(unsigned)ev->sys.event); |
- //return 0; |
- |
- switch(event_class(ev->event)) { |
- case TRC_CLASS_SYSTEM: return dumpsys(&ev->x.sys); |
- case TRC_CLASS_USER: return dumpusr(&ev->x.usr); |
- case TRC_CLASS_SEM: return dumpsem(&ev->x.sem); |
- } |
- printf("\nEVENT %i... CLASS %i UNKNOWN!\n",ev->event,event_class(ev->event)); |
- return -1; |
-} |
- |
-int main(int argc, char *argv[]) |
-{ |
- int res; |
- |
- if (argc!=2) { |
- fprintf(stderr,"missing filename!\n"); |
- return -1; |
- } |
- |
- res=read_trace(argv[1],dumpfunc); |
- |
- //fprintf(stderr,"result=%i\n",res); |
- //fprintf(stderr,"size=%li\n",sizeof(trc_event_t)); |
- |
- return 0; |
-} |
Index: tags/rel_1_22/tracer/utils/readme |
=================================================================== |
--- tags/rel_1_22/tracer/utils/readme (revision 1310) |
+++ tags/rel_1_22/tracer/utils/readme (nonexistent) |
@@ -1,13 +0,0 @@ |
-This directory contains a set of utilities that can be used to interpret |
-the tracer output: |
- |
-- tdump this example simply prints a Shark trace file |
-- jdump converts trace file formats from SHARK to JTRACER |
-- sa prints the distribution of (schedule_time - arrival_time) |
-- road prints the distribution of the HD seeks |
-- wait computes the distribution of the wait times on disk requests |
- |
-Under Linux: to compile, type "make util_linux" |
-Under MSDOS: uncomment the three lines into types.h, then type "make util_dos" |
- |
-PJ |
Index: tags/rel_1_22/tracer/utils/makefile |
=================================================================== |
--- tags/rel_1_22/tracer/utils/makefile (revision 1310) |
+++ tags/rel_1_22/tracer/utils/makefile (nonexistent) |
@@ -1,70 +0,0 @@ |
-# |
-# util -> compiles the tracer utilities under MSDOS/DJGPP |
-# util_linux -> compiles the tracer utilities under Linux |
-# |
- |
-ifndef BASE |
-BASE=../../.. |
-endif |
- |
-.PHONY: util_dos util_linux clean |
- |
-all: |
- @echo Targets: util_dos util_linux clean |
- @echo Note: udpdump is available only under linux |
- |
-util_dos: tdump.exe jdump.exe sa.exe road.exe wait.exe |
- |
-tdump.exe: tdump.c util.c |
- gcc -s -Wimplicit-function-declaration -Wall \ |
- -I$(BASE)/include/trace tdump.c util.c -o tdump.exe |
- |
-jdump.exe: jdump.c util.c |
- gcc -s -Wimplicit-function-declaration -Wall \ |
- -I$(BASE)/include/trace jdump.c util.c -o jdump.exe |
- |
-sa.exe: sa.c util.c distr.c |
- gcc -s -Wimplicit-function-declaration -Wall \ |
- -I$(BASE)/include/trace sa.c util.c -o sa.exe |
- |
-road.exe: road.c util.c distr.c |
- gcc -s -Wimplicit-function-declaration -Wall \ |
- -I$(BASE)/include/trace road.c util.c -o road.exe |
- |
-wait.exe: wait.c util.c distr.c |
- gcc -s -Wimplicit-function-declaration -Wall \ |
- -I$(BASE)/include/trace wait.c util.c -o wait.exe |
- |
- |
-util_linux: jdump tdump sa road wait udpdump |
- |
-jdump: jdump.c util.c |
- gcc -s -Wimplicit-function-declaration -Wall \ |
- -I$(BASE)/include/trace -I$(BASE)/oslib jdump.c util.c -o jdump |
- |
-tdump: tdump.c util.c |
- gcc -s -Wimplicit-function-declaration -Wall \ |
- -I$(BASE)/include/trace -I$(BASE)/oslib tdump.c util.c -o tdump |
- |
-sa: sa.c util.c distr.c |
- gcc -s -Wimplicit-function-declaration -Wall \ |
- -I$(BASE)/include/trace -I$(BASE)/oslib sa.c util.c -o sa |
- |
-road: road.c util.c distr.c |
- gcc -s -Wimplicit-function-declaration -Wall \ |
- -I$(BASE)/include/trace -I$(BASE)/oslib road.c util.c -o road |
- |
-wait: wait.c util.c distr.c |
- gcc -s -Wimplicit-function-declaration -Wall \ |
- -I$(BASE)/include/trace -I$(BASE)/oslib wait.c util.c -o wait |
- |
-udpdump: udpdump.c util.c |
- gcc -Wimplicit-function-declaration -Wall -ggdb\ |
- -I$(BASE)/include/trace -I$(BASE)/oslib udpdump.c util.c -o udpdump |
- |
- |
- |
-clean: |
- rm -rf *.o jdump tdump sa road wait tdump.exe jdump.exe sa.exe road.exe wait.exe |
- |
- |
Index: tags/rel_1_22/tracer/utils/util.c |
=================================================================== |
--- tags/rel_1_22/tracer/utils/util.c (revision 1310) |
+++ tags/rel_1_22/tracer/utils/util.c (nonexistent) |
@@ -1,203 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * Massimiliano Giorgi <massy@gandalf.sssup.it> |
- * Luca Abeni <luca@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Massimiliano Giorgi |
- * Copyright (C) 2002 Paolo Gai |
- * Copyright (C) 2002 Tomas Lenvall |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * CVS : $Id: util.c,v 1.3 2003-07-24 12:22:11 giacomo Exp $ |
- */ |
- |
-#include <stdio.h> |
-#include <string.h> |
-#include <fcntl.h> |
-#include <unistd.h> |
-#include <stdlib.h> |
- |
-#include "types.h" |
-#include <trace.h> |
-#include <types.h> |
- |
-static char *names[]={ |
- "reserved", |
- "hoops", |
- /*--*/ |
- "create", |
- "activate", |
- "schedule", |
- "delay", |
- "sleep", |
- "endcycle", |
- "destroy", |
- "intactiv", |
- "disable", |
- /*--*/ |
- "user0", |
- "user1", |
- "user2", |
- "user3", |
- "user4", |
- "user5", |
- "user6", |
- "user7", |
- /*--*/ |
- "wait", |
- "waitnb", |
- "signal" |
-}; |
- |
-int classtable[TRC_NUMCLASSES+1]={ |
- TRC_F_TRACER, |
- TRC_F_SYSTEM, |
- TRC_F_USER, |
- TRC_F_SEM, |
- TRC_F_LAST |
-}; |
- |
-int event_class(int ev) |
-{ |
- int i; |
- |
- if (ev < 0 || ev >= TRC_NUMEVENTS) |
- return -1; |
- |
- for (i = 0; i < TRC_NUMCLASSES; i++) |
- if (ev >= classtable[i] && ev < classtable[i+1]) |
- return i; |
- |
- return -1; |
-} |
- |
-char *event_name(int ev) |
-{ |
- if (ev<0||ev>=TRC_NUMEVENTS) return "unknown"; |
- return names[ev]; |
-} |
- |
-char *event_hexdump(u_int8_t *ptr,int maxsize) |
-{ |
- static char buffer[256]; |
- int i; |
- for (i=0;i<maxsize;i++) sprintf(buffer+i*2,"%02x",*(ptr+i)); |
- buffer[maxsize*2]='\0'; |
- return buffer; |
-} |
- |
-char *event_strdump(u_int8_t *ptr, int maxsize) |
-{ |
- static char buffer[256]; |
- memcpy(buffer,ptr,maxsize); |
- buffer[maxsize]='\0'; |
- return buffer; |
-} |
- |
- |
-char *format_time(long time) |
-{ |
- static char buffer[256]; |
- |
- if (time<1000l) { |
- sprintf(buffer,"%li",time); |
- return buffer; |
- } |
- if (time<1000000l) { |
- sprintf(buffer,"%li,%03li",time/1000l,time%1000l); |
- return buffer; |
- } |
- sprintf(buffer,"%li,%03li,%03li", |
- (time/1000000l), |
- (time%1000000l)/1000l, |
- time%1000l); |
- return buffer; |
-} |
- |
-#ifndef O_BINARY |
-#define O_BINARY 0 |
-#endif |
- |
-int read_trace(char *filename,int (*func)(trc_event_t *)) |
-{ |
- trc_event_t buffer; |
- int fin; |
- int res; |
- |
- fin=open(filename,O_RDONLY|O_BINARY); |
- if (fin==-1) return -1; |
- for (;;) { |
- res=read(fin,&buffer,sizeof(trc_event_t)); |
- if (res!=sizeof(trc_event_t)) { |
- close(fin); |
- return res==0?0:-2; |
- } |
- res=(*func)(&buffer); |
- if (res!=0) { |
- close(fin); |
- return res; |
- } |
- } |
- close(fin); |
- return 0; |
-} |
- |
- |
-/* reads trace events from a udp message */ |
-int read_udp_trace(char *msg, int (*func)(trc_event_t *)) |
-{ |
- short int events; // temporary storage of nr of events |
- int res; |
- |
- /* message: |
- |2 bytes=nr of events|12 bytes=event 0|12 bytes=event 1|... |
- |
- Note: the size of an event depends on the extra informations that |
- are put on the trc_event_t data structures. That size is |
- currently 12 bytes, but it can change if additional fields are |
- added to the trc_event_t structure. Including the |
- include/trace/types.h header ensures that the size used in this |
- application is coherent with the size of the compiled Shark |
- applications... |
- */ |
- events = *((short int *)msg); |
- |
- msg += 2; // skip the 2 first bytes |
- |
- for (; |
- events > 0; |
- events--, msg += sizeof(trc_event_t)) |
- res = (*func)((trc_event_t *)msg); |
- |
- return 1; |
-} |
- |
Index: tags/rel_1_22/tracer/utils/udpdump.c |
=================================================================== |
--- tags/rel_1_22/tracer/utils/udpdump.c (revision 1310) |
+++ tags/rel_1_22/tracer/utils/udpdump.c (nonexistent) |
@@ -1,216 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * Massimiliano Giorgi <massy@gandalf.sssup.it> |
- * Luca Abeni <luca@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Massimiliano Giorgi |
- * Copyright (C) 2002 Paolo Gai |
- * Copyright (C) 2002 Tomas Lenvall |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * CVS : $Id: udpdump.c,v 1.1 2002-10-28 08:07:32 pj Exp $ |
- */ |
- |
-/* this example simply prints a Shark trace file */ |
- |
-// INCLUDES |
-#include <netinet/in.h> |
- |
-#include "types.h" |
-#include "trace.h" |
-#include "util.h" |
- |
-#include <sys/socket.h> |
-#include <netinet/in.h> |
-#include <arpa/inet.h> |
-#include <netdb.h> |
-#include <stdio.h> |
-#include <unistd.h>/* close() */ |
-#include <string.h> /* memset() */ |
-#include <stdlib.h> |
- |
- |
-// GLOBALS |
-char server_ipaddr[20]; // Store the IP adress of the server |
- |
-// DEFINES |
-#define LOCAL_SERVER_PORT 20000 |
-#define MAX_MSG 10000 |
- |
-// FUNCTIONS |
-/* */ |
-int dumpsys(trc_system_event_t *sys) |
-{ |
- printf("%02i\n",sys->task); |
- return 0; |
-} |
- |
-/* */ |
-int dumpusr(trc_user_event_t *usr) |
-{ |
- printf("%8li ",usr->n); |
- printf("\n"); |
- return 0; |
-} |
- |
-/* */ |
-int dumpsem(trc_sem_event_t *sem) |
-{ |
- printf("on [%i]\n",sem->id); |
- return 0; |
-} |
- |
-/* */ |
-int dumpfunc(trc_event_t *ev) |
-{ |
- static int counter=0; |
- |
- printf("\t%4i ",counter); |
- counter++; |
- printf("%12s ",format_time(ev->time)); |
- printf("%-10s ",event_name(ev->event)); |
- |
- //printf("%08x\n",(unsigned)ev->sys.event); |
- //return 0; |
- |
- switch(event_class(ev->event)) { |
- case TRC_CLASS_SYSTEM: return dumpsys(&ev->x.sys); |
- case TRC_CLASS_USER: return dumpusr(&ev->x.usr); |
- case TRC_CLASS_SEM: return dumpsem(&ev->x.sem); |
- } |
- printf("\nEVENT %i... CLASS %i UNKNOWN!\n",ev->event,event_class(ev->event)); |
- return -1; |
-} |
- |
- |
-/* Use UDP/IP to receive the events from the client computer */ |
-int main(int argc, char *argv[]) |
-{ |
- int sd, rc, n, cliLen; |
- struct sockaddr_in cliAddr, servAddr; |
- char msg[MAX_MSG]; |
- |
- // socket creation |
- sd = socket(AF_INET, SOCK_DGRAM, 0); |
- if(sd < 0) { |
- printf("%s: cannot open socket \n",argv[0]); |
- exit(1); |
- } |
- |
- // bind local server port |
- servAddr.sin_family = AF_INET; |
- |
- servAddr.sin_addr.s_addr = htonl(INADDR_ANY); |
- servAddr.sin_port = htons(LOCAL_SERVER_PORT); |
- |
- rc = bind (sd, (struct sockaddr *)&servAddr,sizeof(servAddr)); |
- if(rc < 0) { |
- printf("%s: cannot bind port number %d \n", |
- argv[0], LOCAL_SERVER_PORT); |
- exit(1); |
- } |
- |
- while(1){ |
- |
- // init buffer |
- memset(msg, 0x0, MAX_MSG); |
- |
- // receive message |
- cliLen = sizeof(cliAddr); |
- n = recvfrom(sd, msg, MAX_MSG, 0,(struct sockaddr *)&cliAddr, &cliLen); |
- |
- printf("Packet received, length %d, %d tracer events.\n", n, |
- *((short int *)msg)); |
- |
- if(n < 0) { |
- printf("%s: cannot receive data \n",argv[0]); |
- continue; |
- } |
- |
- // Read the trace we got from the network |
- read_udp_trace(msg, dumpfunc); |
- } |
- |
- return 0; |
-} |
- |
- |
-// test main: testing this program from a file (simulating a network package) |
-// ONLY USED FOR TESTING!!! |
- |
-/*int main(int argc, char *argv[]) |
-{ |
- FILE* fin; |
- int nr_of_events = 0; |
- trc_event_t buffer; |
- char all_events[1000]; |
- char tmpbuf[2]; |
- |
- if(argc != 2) { |
- printf("Missing filename!\n"); |
- return -1; |
- } |
- |
- // open the file and send event by event |
- fin = fopen(argv[1], "r"); |
- if (fin == NULL) { |
- printf("Cannot open file\n"); |
- return -1; |
- } |
- |
- // check how many events |
- while (!feof(fin)) { |
- fread(&buffer, sizeof(trc_event_t), 1, fin); |
- nr_of_events++; |
- } |
- |
- //printf("Nr of events: %d\n", nr_of_events); |
- |
- rewind(fin); // start from the beginning again... |
- //strncpy(tmpbuf, itoa(nr_of_events), 2); |
- sprintf(tmpbuf, "%d", nr_of_events); |
- //printf("tmpbuf: %s\n", tmpbuf); |
- |
- memset(all_events, 0, 1000); |
- memcpy(all_events, tmpbuf, 2); |
- printf("all_events(1): %s\n", all_events); |
- // read all tracer events and store them in an array |
- fread(all_events + 2, sizeof(trc_event_t), nr_of_events, fin); |
- fclose(fin); |
- |
- printf("all_events(2): %s\n", all_events); |
- // send it to the event reader |
- read_trace(all_events, dumpfunc); |
- |
- return 1; |
-} |
-*/ |
Index: tags/rel_1_22/tracer/utils/jdump.c |
=================================================================== |
--- tags/rel_1_22/tracer/utils/jdump.c (revision 1310) |
+++ tags/rel_1_22/tracer/utils/jdump.c (nonexistent) |
@@ -1,470 +0,0 @@ |
-/* |
- * Project: HARTIK (HA-rd R-eal TI-me K-ernel) |
- * |
- * Coordinators: Giorgio Buttazzo <giorgio@sssup.it> |
- * Gerardo Lamastra <gerardo@sssup.it> |
- * |
- * Authors : Massimiliano Giorgi <massy@hartik.sssup.it> |
- * (see authors.txt for full list of hartik's authors) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://hartik.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 1999 Massimiliano Giorgi |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-/* |
- * CVS : $Id: jdump.c,v 1.3 2003-07-24 12:22:11 giacomo Exp $ |
- * |
- * File: $File$ |
- * Revision: $Revision: 1.3 $ |
- * Last update: $Date: 2003-07-24 12:22:11 $ |
- */ |
- |
-#include <netinet/in.h> |
-#include <stdio.h> |
-#include <string.h> |
-#include <unistd.h> |
-#include <fcntl.h> |
- |
-#include "types.h" |
-#include <trace.h> |
-#include "util.h" |
- |
-/* |
- * |
- * This filter converts trace file formats from SHARK to JTRACER |
- * |
- */ |
- |
-/* All times are dived by this costant. */ |
-#define TIMESCALE 1 |
- |
-/* If defined dump on stdout the packets (in ascii) that will be written |
- * on the output file (the file of the tracer). |
- */ |
- |
-#define DUMPOUT |
- |
-/* |
- * |
- * |
- * |
- */ |
- |
-int pippo=0; |
- |
-int writeInt(int h, int x) |
-{ |
- int y,res; |
- y=htonl(x); |
- res=write(h,&y,sizeof(int)); |
- return res!=sizeof(int); |
-} |
- |
- |
-int writeStr(int h, char *s) |
-{ |
- int res,size; |
- size=strlen(s); |
- writeInt(h,size); |
- res=write(h,s,size); |
- return res!=size; |
-} |
- |
-/* |
- * |
- */ |
- |
-#define TASK_ARRIVAL 0 |
-#define TASK_SCHEDULE 1 |
-#define TASK_DESCHEDULE 2 |
-#define TASK_END 3 |
-#define TASK_DLINEPOST 4 |
-#define TASK_DLINESET 5 |
-#define TASK_WAIT 6 |
-#define TASK_SIGNAL 7 |
-#define TASK_IDLE 8 |
-#define TASK_NAME 9 |
- |
-#define EVT_NUMBER 10 |
- |
-char *eventsname[]={ |
- "task_arrival", |
- "task_schedule", |
- "task_deschedule", |
- "task_end", |
- "task_dlinepost", |
- "task_dlineset", |
- "task_wait", |
- "task_signal", |
- "task_idle", |
- "task_name" |
-}; |
- |
-struct j_evt_prolog { |
- int type; |
- int time; |
-}; |
- |
-struct j_evt_task { |
- struct j_evt_prolog p; |
- int task; |
-}; |
- |
-struct j_evt_dlinepost { |
- struct j_evt_task t; |
- int taskD; |
- int taskD2; |
-}; |
- |
-struct j_evt_dlineset { |
- struct j_evt_task t; |
- int taskD; |
-}; |
- |
-struct j_evt_semaph { |
- struct j_evt_task t; |
- int res; |
- char *name; |
-}; |
- |
-struct j_evt_name { |
- struct j_evt_task t; |
- char *name; |
-}; |
- |
-/* |
- * |
- */ |
- |
-int j_write_prolog(int h, void *ptr) |
-{ |
-#ifdef DUMPOUT |
- printf("%10i ",((struct j_evt_prolog *)ptr)->time); |
- printf("%-18s ",eventsname[((struct j_evt_prolog *)ptr)->type]); |
-#endif |
- if (writeInt(h,((struct j_evt_prolog *)ptr)->type)) return -2; |
- if (writeInt(h,((struct j_evt_prolog *)ptr)->time)) return -3; |
- return 0; |
-} |
- |
-int j_write_task(int h, void *ptr) |
-{ |
- int res; |
- res=j_write_prolog(h,ptr); |
-#ifdef DUMPOUT |
- printf("tsk=%i ",((struct j_evt_task *)ptr)->task); |
-#endif |
- if (res) return res; |
- if (writeInt(h,((struct j_evt_task *)ptr)->task)) return -4; |
- return 0; |
-} |
- |
-int j_write_dlinepost(int h, void *ptr) |
-{ |
- int res; |
- res=j_write_task(h,ptr); |
- if (res) return res; |
- if (writeInt(h,((struct j_evt_dlinepost *)ptr)->taskD)) return -5; |
- if (writeInt(h,((struct j_evt_dlinepost *)ptr)->taskD2)) return -6; |
- return 0; |
-} |
- |
-int j_write_dlineset(int h, void *ptr) |
-{ |
- int res; |
- res=j_write_task(h,ptr); |
- if (res) return res; |
- if (writeInt(h,((struct j_evt_dlineset *)ptr)->taskD)) return -7; |
- return 0; |
-} |
- |
-int j_write_semaph(int h, void *ptr) |
-{ |
- int res; |
- res=j_write_task(h,ptr); |
- if (res) return res; |
- if (writeInt(h,((struct j_evt_semaph *)ptr)->res)) return -8; |
- if (writeStr(h,((struct j_evt_semaph *)ptr)->name)) return -9; |
- return 0; |
-} |
- |
-int j_write_name(int h, void *ptr) |
-{ |
- int res; |
- res=j_write_task(h,ptr); |
-#ifdef DUMPOUT |
- printf("name='%s' ",((struct j_evt_name *)ptr)->name); |
-#endif |
- if (res) return res; |
- if (writeStr(h,((struct j_evt_name *)ptr)->name)) return -10; |
- return 0; |
-} |
- |
-int writeEvent(int h, void *ptr) |
-{ |
- int res; |
- |
- //printf("<%i>",((struct j_evt_prolog*)ptr)->type); |
- |
- ((struct j_evt_prolog*)ptr)->time/=TIMESCALE; |
- |
- switch(((struct j_evt_prolog*)ptr)->type) { |
- case TASK_ARRIVAL: |
- case TASK_SCHEDULE: |
- case TASK_DESCHEDULE: |
- case TASK_END: |
- case TASK_IDLE: |
- res=j_write_task(h,ptr); |
- break; |
- case TASK_DLINEPOST: |
- res=j_write_dlinepost(h,ptr); |
- break; |
- case TASK_DLINESET: |
- res=j_write_dlineset(h,ptr); |
- break; |
- case TASK_WAIT: |
- case TASK_SIGNAL: |
- res=j_write_semaph(h,ptr); |
- break; |
- case TASK_NAME: |
- res=j_write_name(h,ptr); |
- break; |
- default: |
- return -1; |
- |
- } |
- |
-#ifdef DUMPOUT |
- printf(" \n"); |
-#endif |
- |
- return res; |
-} |
- |
-/* |
- * |
- * |
- * |
- */ |
- |
-#define MAX_PROC 150 |
- |
-//int activated[MAX_PROC]; |
- |
-int cxx=0; |
-/* write MAXC-1 events */ |
-#define MAXC 10000 |
- |
-long lasttime; |
- |
-int sys_event(int h, void *param) |
-{ |
- static int prevtask=-1; |
- trc_event_t *ptr=(trc_event_t *)param; |
- struct j_evt_task evt; |
- |
- evt.p.time=ptr->time; |
- evt.task=ptr->x.sys.task; |
- |
- lasttime=ptr->time; |
- switch(ptr->event) { |
- |
- case TRC_CREATE: |
- return 0; |
- |
- case TRC_ACTIVATE: |
- case TRC_INTACTIVATION: |
- |
- |
- //activated[ptr->x.sys.task]=1; |
- |
- |
- evt.p.type=TASK_ARRIVAL; |
- break; |
- |
- case TRC_DESTROY: |
- |
- |
- //activated[ptr->x.sys.task]=0; |
- |
- |
- |
- return 0; |
- |
- case TRC_DISABLE: |
- |
- return 0; |
- |
- case TRC_DELAY: |
- prevtask=-1; |
- evt.p.type=TASK_DESCHEDULE; |
- break; |
- |
- case TRC_SLEEP: |
- prevtask=-1; |
- evt.p.type=TASK_DESCHEDULE; |
- break; |
- |
- case TRC_ENDCYCLE: |
- prevtask=-1; |
- evt.p.type=TASK_END; |
- break; |
- |
- case TRC_SCHEDULE: |
- if (prevtask!=-1) { |
- struct j_evt_task evt2; |
- int res; |
- evt2.p.time=ptr->time; |
- evt2.p.type=TASK_DESCHEDULE; |
- evt2.task=prevtask; |
- res=writeEvent(h,&evt2); |
- if (res!=0) return -1; |
- } |
- |
- /* |
- if (!activated[ptr->x.sys.task]) { |
- struct j_evt_task evt2; |
- |
- evt2.p.time=ptr->time-1; |
- evt2.task=ptr->x.sys.task; |
- evt2.p.type=TASK_ARRIVAL; |
- |
- writeEvent(h,&evt2); |
- |
- activated[ptr->x.sys.task]=1; |
- } |
- */ |
- |
- evt.p.type=TASK_SCHEDULE; |
- prevtask=ptr->x.sys.task; |
- break; |
- |
- default: |
- return 0; |
- } |
- |
- cxx++; |
- if (cxx==MAXC) return -1; |
- |
- return writeEvent(h,&evt); |
-} |
- |
- |
-int sem_event(int h,void *param) |
-{ |
- //trc_event_t *ptr=(trc_event_t *)param; |
- //struct j_evt_semaph evt; |
- |
- return 0; |
- /* |
- evt.t.p.time=ptr->x.norm.when; |
- evt.t.task=ptr->x.norm.who; |
- switch(ptr->what) { |
- case TRC_SEM_WAIT: evt.t.p.type=TASK_WAIT; break; |
- case TRC_SEM_SIGNAL: evt.t.p.type=TASK_SIGNAL; break; |
- case TRC_SEM_WAITNB: return 0; |
- default: return 0; |
- } |
- evt.res=1; |
- evt.name="NoName"; |
- return j_write_semaph(h,&evt); |
- */ |
-} |
- |
-/* -- */ |
- |
-#define MAX_PROC 150 |
-int names[MAX_PROC]; |
- |
-int outfile; |
- |
-int dumpfunc(trc_event_t *ptr) |
-{ |
- //printf("{%i}",ptr->event); |
- |
- if (!names[ptr->x.sys.task]) { |
- struct j_evt_name evtname; |
- static char name[24]; |
- |
- cxx++; |
- if (cxx==MAXC) return -1; |
- |
- evtname.t.p.time=lasttime; |
- evtname.t.task=ptr->x.sys.task; |
- evtname.t.p.type=TASK_NAME; |
- sprintf(name,"task%03i",ptr->x.sys.task); |
- evtname.name=name; |
- writeEvent(outfile,&evtname); |
- names[ptr->x.sys.task]=1; |
- |
- } |
- |
- switch(event_class(ptr->event)) { |
- case TRC_CLASS_SYSTEM: |
- return sys_event(outfile,ptr); |
- case TRC_CLASS_SEM: |
- return 0; |
- return sem_event(outfile,ptr); |
- case TRC_CLASS_USER: |
- return 0; |
- } |
- return 0; |
-} |
- |
-/* |
- * |
- */ |
- |
-#ifndef O_BINARY |
-#define O_BINARY 0 |
-#endif |
- |
-int main(int argc, char *argv[]) |
-{ |
- int res; |
- int i; |
- |
- if (argc!=3) { |
- fprintf(stderr,"missing filenames\n"); |
- fprintf(stderr,"usage: jdump SHARKtracefilename JTRACERtracefilename\n"); |
- return -1; |
- } |
- |
- for (i=0;i<MAX_PROC;i++) { |
- names[i]=0; |
- //activated[i]=0; |
- } |
- |
- outfile=open(argv[2],O_WRONLY|O_CREAT|O_TRUNC|O_BINARY,0777); |
- if (outfile==-1) { |
- perror("can't open outfile"); |
- return -1; |
- } |
- res=read_trace(argv[1],dumpfunc); |
- close(outfile); |
- |
- //fprintf(stderr,"result=%i",res); |
- return 0; |
-} |
Index: tags/rel_1_22/tracer/utils/util.h |
=================================================================== |
--- tags/rel_1_22/tracer/utils/util.h (revision 1310) |
+++ tags/rel_1_22/tracer/utils/util.h (nonexistent) |
@@ -1,58 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * Massimiliano Giorgi <massy@gandalf.sssup.it> |
- * Luca Abeni <luca@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Massimiliano Giorgi |
- * Copyright (C) 2002 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * CVS : $Id: util.h,v 1.2 2002-10-28 08:07:32 pj Exp $ |
- */ |
- |
-#ifndef __UTIL_H |
-#define __UTIL_H |
- |
-#include "types.h" |
- |
-char *event_name(int evt); |
-char *event_hexdump(u_int8_t *ptr, int maxsize); |
-char *event_strdump(u_int8_t *ptr, int maxsize); |
-int event_class(int evt); |
- |
-int read_trace(char *filename,int (*func)(trc_event_t *)); |
-int read_udp_trace(void *msg, int (*func)(trc_event_t *)); |
- |
-char *format_time(long time); |
- |
-#endif |
- |
Index: tags/rel_1_22/tracer/utils/sa.c |
=================================================================== |
--- tags/rel_1_22/tracer/utils/sa.c (revision 1310) |
+++ tags/rel_1_22/tracer/utils/sa.c (nonexistent) |
@@ -1,120 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * Massimiliano Giorgi <massy@gandalf.sssup.it> |
- * Luca Abeni <luca@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Massimiliano Giorgi |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * CVS : $Id: sa.c,v 1.2 2002-10-28 08:07:32 pj Exp $ |
- */ |
- |
-#include <netinet/in.h> |
- |
-#include <stdlib.h> |
-#include <stdio.h> |
-#include "types.h" |
-#include <trace.h> |
-#include "util.h" |
- |
-/* this file prints the distribution of (schedule_time - arrival_time) */ |
- |
-#define MAXX 50 |
-#define PREC 100 |
-#define DELTA ((double)MAXX/(double)PREC) |
- |
-#include "distr.c" |
- |
-int task; |
-long a=-1; |
-long s; |
- |
-int safunc(trc_event_t *ev) |
-{ |
- if (event_class(ev->event)!=TRC_CLASS_SYSTEM) return 0; |
- |
- if (ev->x.sys.task!=task) return 0; |
- |
- if (a==-1) { |
- if (ev->event==TRC_ACTIVATE||ev->event==TRC_INTACTIVATION) |
- a=ev->time; |
- } else { |
- if (ev->event==TRC_SCHEDULE) { |
- s=ev->time; |
- d_insert(s-a); |
- a=-1; |
- } |
- } |
- return 0; |
-} |
- |
-/* -- */ |
- |
-int main(int argc, char *argv[]) |
-{ |
- int res; |
- |
- if (argc!=4) { |
- fprintf(stderr,"usage: sa [tracefile] [pid] [outputfile]\n"); |
- return -1; |
- } |
- |
- d_init(); |
- |
- task=atoi(argv[2]); |
- res=read_trace(argv[1],safunc); |
- |
- if (res==0) { |
- FILE *fout; |
- fout=fopen(argv[3],"wt"); |
- if (fout==NULL) { |
- fprintf(stderr,"error writing output file!\n"); |
- return 0; |
- } |
- d_dump(fout); |
- fclose(fout); |
- } |
- |
- if (res!=0) { |
- fprintf(stderr,"error=%i\n",res); |
- perror("ERROR"); |
- } |
- |
- return 0; |
-} |
- |
- |
- |
- |
- |
- |
- |
Index: tags/rel_1_22/tracer/utils/wait.c |
=================================================================== |
--- tags/rel_1_22/tracer/utils/wait.c (revision 1310) |
+++ tags/rel_1_22/tracer/utils/wait.c (nonexistent) |
@@ -1,95 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * Massimiliano Giorgi <massy@gandalf.sssup.it> |
- * Luca Abeni <luca@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Massimiliano Giorgi |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * CVS : $Id: wait.c,v 1.2 2002-10-28 08:07:32 pj Exp $ |
- */ |
- |
-#include <stdio.h> |
-#include <stdlib.h> |
-#include "types.h" |
-#include <trace.h> |
-#include "util.h" |
- |
-/* This demo computes the distribution of the wait times on disk requests */ |
- |
-#define MAXX 37000 |
-#define PREC 37000 |
-#define DELTA ((double)MAXX/(double)PREC) |
- |
-#include "distr.c" |
- |
-int task; |
-long a=-1; |
- |
-int waitfunc(trc_event_t *ev) |
-{ |
- if (event_class(ev->event)!=TRC_CLASS_USER) return 0; |
- if (ev->x.usr.n!=task) return 0; |
- if (ev->event==TRC_USER1) { |
- a=ev->time; |
- return 0; |
- } |
- if (ev->event==TRC_USER2) { |
- if (a!=-1) d_insert(ev->time-a); |
- a=-1; |
- } |
- return 0; |
-} |
- |
-int main(int argc, char *argv[]) |
-{ |
- FILE *fout; |
- int res; |
- if (argc!=4) { |
- fprintf(stderr,"missing filename!\n"); |
- return -1; |
- } |
- d_init(); |
- task=atoi(argv[2]); |
- res=read_trace(argv[1],waitfunc); |
- if (res==0) { |
- fout=fopen(argv[3],"wt"); |
- if (fout!=NULL) { |
- d_dump(fout); |
- fclose(fout); |
- } else |
- fprintf(stderr,"can't create output file!\n"); |
- } else |
- fprintf(stderr,"read_trace error\n"); |
- |
- return 0; |
-} |
Index: tags/rel_1_22/tracer/utils/distr.c |
=================================================================== |
--- tags/rel_1_22/tracer/utils/distr.c (revision 1310) |
+++ tags/rel_1_22/tracer/utils/distr.c (nonexistent) |
@@ -1,83 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * Massimiliano Giorgi <massy@gandalf.sssup.it> |
- * Luca Abeni <luca@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Massimiliano Giorgi |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * CVS : $Id: distr.c,v 1.2 2002-10-28 08:07:32 pj Exp $ |
- */ |
- |
-long t[PREC]; |
-long counter; |
-long hoops; |
-long maxv=0; |
- |
-void d_init(void) |
-{ |
- int i; |
- hoops=counter=0; |
- for (i=0;i<PREC;i++) t[i]=0; |
-} |
- |
-void d_insert(long d) |
-{ |
- if (d>=MAXX) { |
- hoops++; |
- if (d>maxv) maxv=d; |
- return; |
- } |
- |
- counter++; |
- t[(int)(d/DELTA)]++; |
-} |
- |
-void d_dump(FILE *fout) |
-{ |
- int i; |
- |
- if (counter==0) { |
- fprintf(stderr,"nothing to write to the output file\n"); |
- return; |
- } |
- |
- if (hoops) { |
- fprintf(stderr,"%li values to big (max=%li)\n",hoops,maxv); |
- } |
- |
- for (i=0;i<PREC;i++) |
- fprintf(fout,"%f %f\n", |
- DELTA/2.0+DELTA*i, |
- (double)t[i]/(double)counter |
- ); |
-} |
Index: tags/rel_1_22/tracer/utils/road.c |
=================================================================== |
--- tags/rel_1_22/tracer/utils/road.c (revision 1310) |
+++ tags/rel_1_22/tracer/utils/road.c (nonexistent) |
@@ -1,96 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * Massimiliano Giorgi <massy@gandalf.sssup.it> |
- * Luca Abeni <luca@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Massimiliano Giorgi |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * CVS : $Id: road.c,v 1.2 2002-10-28 08:07:32 pj Exp $ |
- */ |
- |
-#include <stdio.h> |
-#include <stdlib.h> |
-#include "types.h" |
-#include <trace.h> |
-#include "util.h" |
- |
- |
-/* this test prints the distribution of the HD seeks */ |
- |
-#define MAXX 1000 |
-#define PREC 1000 |
-#define DELTA ((double)MAXX/(double)PREC) |
- |
-#include "distr.c" |
- |
-int dumpusr(int event, trc_user_event_t *usr) |
-{ |
- static long last=-1; |
- long d; |
- if (event!=TRC_USER0) return 0; |
- if (last!=-1) { |
- d=abs(last-usr->n); |
- d_insert(d); |
- } |
- last=usr->n; |
- return 0; |
-} |
- |
-int dumpfunc(trc_event_t *ev) |
-{ |
- if (event_class(ev->event)==TRC_CLASS_USER) dumpusr(ev->event,&ev->x.usr); |
- return 0; |
-} |
- |
-int main(int argc, char *argv[]) |
-{ |
- FILE *fout; |
- int res; |
- if (argc!=3) { |
- fprintf(stderr,"missing filename!\n"); |
- return -1; |
- } |
- d_init(); |
- res=read_trace(argv[1],dumpfunc); |
- if (res==0) { |
- fout=fopen(argv[2],"wt"); |
- if (fout!=NULL) { |
- d_dump(fout); |
- fclose(fout); |
- } else |
- fprintf(stderr,"can't create output file!\n"); |
- } else |
- fprintf(stderr,"read_trace error\n"); |
- |
- return 0; |
-} |
Index: tags/rel_1_22/tracer/dfixed/dfixed.c |
=================================================================== |
--- tags/rel_1_22/tracer/dfixed/dfixed.c (revision 1310) |
+++ tags/rel_1_22/tracer/dfixed/dfixed.c (nonexistent) |
@@ -1,133 +0,0 @@ |
-/* |
- * Project: HARTIK (HA-rd R-eal TI-me K-ernel) |
- * |
- * Coordinators: Giorgio Buttazzo <giorgio@sssup.it> |
- * Gerardo Lamastra <gerardo@sssup.it> |
- * |
- * Authors : Massimiliano Giorgi <massy@hartik.sssup.it> |
- * (see authors.txt for full list of hartik's authors) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://hartik.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Massimiliano Giorgi |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-/* |
- * CVS : $Id: dfixed.c,v 1.2 2003-12-17 14:15:45 giacomo Exp $ |
- * |
- * File: $File$ |
- * Revision: $Revision: 1.2 $ |
- * Last update: $Date: 2003-12-17 14:15:45 $ |
- */ |
- |
-/* |
- * Example of tracer initialization. |
- */ |
- |
-#include <ll/i386/cons.h> |
- |
-#include <kernel/func.h> |
-#include <tracer.h> |
- |
-#include <fs/bdevinit.h> |
-#include <fs/fsinit.h> |
-#include <fs/bdev.h> |
- |
-#include <drivers/keyb.h> |
- |
-#include <trace.h> |
-#include <queues.h> |
- |
-#include <sys/mount.h> |
-#include <stddef.h> |
- |
- |
-void mytracer_prologue(void) |
-{ |
- int myqueue; |
- TRC_PARMS p; |
- TRC_FIXED_PARMS f; |
- |
- trc_default_parms(p); |
- trc_def_path(p,""); |
- |
- trc_fixed_default_parms(f); |
- trc_fixed_def_filename(f,"fixed"); |
- |
- /* Tracer Initialization */ |
- /* the first functions to call... parameters can be passed */ |
- TRC_init_phase1(&p); |
- |
- /* all the tracer queue types must be registered */ |
- trc_register_dosfs_fixed_queue(); |
- |
- /* then, we create all the queues we need */ |
- myqueue = trc_create_queue(TRC_DOSFS_FIXED_QUEUE,&f); |
- |
- /* Then, we say that events must be sent to a particular queue */ |
- trc_trace_class(TRC_CLASS_SYSTEM); |
- trc_assign_class_to_queue(TRC_CLASS_SYSTEM, myqueue); |
-} |
- |
-void mytracer_epilogue(void) |
-{ |
- TRC_init_phase2(); |
-} |
- |
-void ctrlc_exit(KEY_EVT *k) |
-{ |
- sys_end(); |
-} |
- |
-void *mytask(void *arg) |
-{ |
- int i; |
- |
- for(i=0; i<10; i++) { |
- cprintf("%d ", i); |
- task_endcycle(); |
- } |
- |
- return 0; |
-} |
- |
-int main(int argc,char *argv[]) |
-{ |
- SOFT_TASK_MODEL mp; |
- |
- PID pid; |
- |
- soft_task_default_model(mp); |
- soft_task_def_met(mp, 10000); |
- soft_task_def_period(mp,50000); |
- soft_task_def_usemath(mp); |
- |
- cprintf("\nHello, world!\n"); |
- |
- pid = task_create("mytask", mytask, &mp, NULL); |
- |
- if (pid != NIL) task_activate(pid); |
- |
- return 0; |
-} |
Index: tags/rel_1_22/tracer/dfixed/initfile.c |
=================================================================== |
--- tags/rel_1_22/tracer/dfixed/initfile.c (revision 1310) |
+++ tags/rel_1_22/tracer/dfixed/initfile.c (nonexistent) |
@@ -1,115 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-/* |
- * CVS : $Id: initfile.c,v 1.1 2002-10-21 09:12:35 pj Exp $ |
- * |
- * File: $File$ |
- * Revision: $Revision: 1.1 $ |
- * Last update: $Date: 2002-10-21 09:12:35 $ |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/rr.h" |
-#include "modules/cbs.h" |
-#include "modules/dummy.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
-#include "modules/pi.h" |
-#include "modules/pc.h" |
-#include "modules/srp.h" |
-#include "modules/npp.h" |
-#include "modules/nop.h" |
-#include "modules/nopm.h" |
- |
-#include "drivers/keyb.h" |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 1000 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 10000 |
- |
-void mytracer_prologue(void); |
-void mytracer_epilogue(void); |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- mytracer_prologue(); |
- |
- EDF_register_level(EDF_ENABLE_ALL); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- CBS_register_level(CBS_ENABLE_ALL, 0); |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- |
- CABS_register_module(); |
- |
- PI_register_module(); |
- PC_register_module(); |
- NPP_register_module(); |
- SRP_register_module(); |
- NOP_register_module(); |
- NOPM_register_module(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- KEYB_PARMS keyb = BASE_KEYB; |
- extern void ctrlc_exit(KEY_EVT *k); |
- |
- HARTPORT_init(); |
- |
- keyb_def_ctrlC(keyb, ctrlc_exit); |
- KEYB_init(&keyb); |
- |
- mytracer_epilogue(); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
Index: tags/rel_1_22/tracer/dfixed/readme |
=================================================================== |
--- tags/rel_1_22/tracer/dfixed/readme (revision 1310) |
+++ tags/rel_1_22/tracer/dfixed/readme (nonexistent) |
@@ -1,8 +0,0 @@ |
-This is a simple test that uses the tracer. |
- |
-The example simply creates a soft task that does 10 instances and then dies. |
-It uses a DOSFS Fixed queue to write the output on a file. |
- |
-Enjoy, |
- |
-PJ |
Index: tags/rel_1_22/tracer/dfixed/makefile |
=================================================================== |
--- tags/rel_1_22/tracer/dfixed/makefile (revision 1310) |
+++ tags/rel_1_22/tracer/dfixed/makefile (nonexistent) |
@@ -1,21 +0,0 @@ |
-# |
-# |
-# |
- |
-ifndef BASE |
-BASE=../../.. |
-endif |
- |
-include $(BASE)/config/config.mk |
- |
-PROGS= dfixed |
- |
-include $(BASE)/config/example.mk |
- |
-dfixed: |
- make -f $(SUBMAKE) BASE=$(BASE) APP=dfixed INIT= OTHEROBJS=initfile.o SHARKOPT=__OLDCHAR__ |
- |
- |
- |
- |
- |
Index: tags/rel_1_22/tracer/udp/initfile.c |
=================================================================== |
--- tags/rel_1_22/tracer/udp/initfile.c (revision 1310) |
+++ tags/rel_1_22/tracer/udp/initfile.c (nonexistent) |
@@ -1,115 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-/* |
- * CVS : $Id: initfile.c,v 1.2 2003-12-10 16:58:32 giacomo Exp $ |
- * |
- * File: $File$ |
- * Revision: $Revision: 1.2 $ |
- * Last update: $Date: 2003-12-10 16:58:32 $ |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/rr.h" |
-#include "modules/cbs.h" |
-#include "modules/dummy.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
-#include "modules/pi.h" |
-#include "modules/pc.h" |
-#include "modules/srp.h" |
-#include "modules/npp.h" |
-#include "modules/nop.h" |
-#include "modules/nopm.h" |
- |
-#include "drivers/keyb.h" |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 0 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 10000 |
- |
-void mytracer_prologue(void); |
-void mytracer_epilogue(void); |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- mytracer_prologue(); |
- |
- EDF_register_level(EDF_ENABLE_ALL); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- CBS_register_level(CBS_ENABLE_ALL, 0); |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- |
- CABS_register_module(); |
- |
- PI_register_module(); |
- PC_register_module(); |
- NPP_register_module(); |
- SRP_register_module(); |
- NOP_register_module(); |
- NOPM_register_module(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- KEYB_PARMS keyb = BASE_KEYB; |
- extern void ctrlc_exit(KEY_EVT *k); |
- |
- HARTPORT_init(); |
- |
- keyb_def_ctrlC(keyb, ctrlc_exit); |
- KEYB_init(&keyb); |
- |
- mytracer_epilogue(); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
Index: tags/rel_1_22/tracer/udp/udptrace.c |
=================================================================== |
--- tags/rel_1_22/tracer/udp/udptrace.c (revision 1310) |
+++ tags/rel_1_22/tracer/udp/udptrace.c (nonexistent) |
@@ -1,159 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * Massimiliano Giorgi <massy@gandalf.sssup.it> |
- * Luca Abeni <luca@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Massimiliano Giorgi |
- * Copyright (C) 2002 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * CVS : $Id: udptrace.c,v 1.4 2003-12-10 16:58:32 giacomo Exp $ |
- */ |
- |
-/* |
- * Example of tracer initialization. |
- */ |
- |
-#include <ll/i386/cons.h> |
- |
-#include <kernel/func.h> |
- |
-#include <fs/bdevinit.h> |
-#include <fs/fsinit.h> |
-#include <fs/bdev.h> |
- |
-#include <drivers/keyb.h> |
-#include <drivers/udpip.h> |
- |
-#include <tracer.h> |
-#include <queues.h> |
- |
-#include <sys/mount.h> |
-#include <stddef.h> |
-#include <string.h> |
- |
-char myipaddr[15], toipaddr[15]; |
- |
-void mytracer_prologue(void) |
-{ |
- int myqueue; |
- TRC_PARMS p; |
- TRC_UDP_PARMS u; |
- UDP_ADDR local, remote; |
- |
- /* these are the IP numbers of my home PCs ;-) */ |
- strcpy(myipaddr, "192.168.82.120"); |
- strcpy(toipaddr, "192.168.82.20"); |
- |
- clear(); |
- |
- ip_str2addr(toipaddr,&(remote.s_addr)); |
- remote.s_port = 20000; // htons is done automatically; |
- ip_str2addr(myipaddr,&(local.s_addr)); |
- local.s_port = 20000; // htons is done automatically; |
- |
- trc_default_parms(p); |
- trc_def_path(p,""); |
- |
- trc_udp_default_parms(u,local,remote); |
- |
- /* Tracer Initialization */ |
- /* the first functions to call... parameters can be passed */ |
- TRC_init_phase1(&p); |
- |
- /* all the tracer queue types must be registered */ |
- trc_register_udp_queue(); |
- |
- /* then, we create all the queues we need */ |
- myqueue = trc_create_queue(TRC_UDP_QUEUE,&u); |
- |
- /* Then, we say that events must be sent to a particular queue */ |
- trc_trace_class(TRC_CLASS_SYSTEM); |
- trc_assign_class_to_queue(TRC_CLASS_SYSTEM, myqueue); |
-} |
- |
-void mytracer_epilogue(void) |
-{ |
- struct net_model m = net_base; |
- |
- |
- /* We want a task for TX mutual exclusion */ |
- net_setmode(m, TXTASK); |
- /* We use UDP/IP stack */ |
- net_setudpip(m, myipaddr, "255.255.255.255"); |
- /* OK: let's start the NetLib! */ |
- if (net_init(&m) == 1) { |
- cprintf("udptrace: Net Init OK...\n"); |
- } else { |
- cprintf("udptrace: Net Init Failed...\n"); |
- sys_abort(300); |
- } |
- |
- TRC_init_phase2(); |
-} |
- |
-void ctrlc_exit(KEY_EVT *k) |
-{ |
- sys_end(); |
-} |
- |
-void *mytask(void *arg) |
-{ |
- int i; |
- |
- for(i=0; i<10; i++) { |
- cprintf("%d\n", i); |
- task_endcycle(); |
- } |
- |
- return 0; |
-} |
- |
-int main(int argc,char *argv[]) |
-{ |
- SOFT_TASK_MODEL mp; |
- |
- PID pid; |
- |
- soft_task_default_model(mp); |
- soft_task_def_met(mp, 10000); |
- soft_task_def_period(mp,50000); |
- soft_task_def_usemath(mp); |
- |
- cprintf("\nHello, world!\n"); |
- |
- pid = task_create("mytask", mytask, &mp, NULL); |
- |
- if (pid != NIL) task_activate(pid); |
- |
- return 0; |
-} |
Index: tags/rel_1_22/tracer/udp/readme |
=================================================================== |
--- tags/rel_1_22/tracer/udp/readme (revision 1310) |
+++ tags/rel_1_22/tracer/udp/readme (nonexistent) |
@@ -1,10 +0,0 @@ |
-This is a simple test that uses the tracer. |
- |
-The example assigns the IP address 192.168.1.2 to the machine, and |
-sends the tracer data to 192.168.1.1 using UDp, port 20000. |
- |
-You can use demos/tracer/utils/udpdump to get the informations. |
- |
-Enjoy, |
- |
-PJ |
Index: tags/rel_1_22/tracer/udp/makefile |
=================================================================== |
--- tags/rel_1_22/tracer/udp/makefile (revision 1310) |
+++ tags/rel_1_22/tracer/udp/makefile (nonexistent) |
@@ -1,21 +0,0 @@ |
-# |
-# |
-# |
- |
-ifndef BASE |
-BASE=../../.. |
-endif |
- |
-include $(BASE)/config/config.mk |
- |
-PROGS= udptrace |
- |
-include $(BASE)/config/example.mk |
- |
-udptrace: |
- make -f $(SUBMAKE) BASE=$(BASE) APP=udptrace INIT= OTHEROBJS=initfile.o OTHERINCL="-I$(BASE)/tracer/include" SHARKOPT=__OLDCHAR__ |
- |
- |
- |
- |
- |
Index: tags/rel_1_22/tracer/small/simple.c |
=================================================================== |
--- tags/rel_1_22/tracer/small/simple.c (revision 1310) |
+++ tags/rel_1_22/tracer/small/simple.c (nonexistent) |
@@ -1,132 +0,0 @@ |
-/* |
- * Project: HARTIK (HA-rd R-eal TI-me K-ernel) |
- * |
- * Coordinators: Giorgio Buttazzo <giorgio@sssup.it> |
- * Gerardo Lamastra <gerardo@sssup.it> |
- * |
- * Authors : Massimiliano Giorgi <massy@hartik.sssup.it> |
- * (see authors.txt for full list of hartik's authors) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://hartik.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Massimiliano Giorgi |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-/* |
- * CVS : $Id: simple.c,v 1.2 2003-12-17 14:15:45 giacomo Exp $ |
- * |
- * File: $File$ |
- * Revision: $Revision: 1.2 $ |
- * Last update: $Date: 2003-12-17 14:15:45 $ |
- */ |
- |
-/* |
- * Example of simple tracer initialization. |
- */ |
- |
-#include <ll/i386/cons.h> |
- |
-#include <kernel/func.h> |
-#include <trace.h> |
- |
-#include <fs/bdevinit.h> |
-#include <fs/fsinit.h> |
-#include <fs/bdev.h> |
- |
-#include <drivers/keyb.h> |
- |
-#include <trace.h> |
- |
-#include <sys/mount.h> |
-#include <stddef.h> |
- |
-#define ROOTDEVICE "ide/hda2" |
- |
-int __register_sub_init_prologue(void) |
-{ |
- int res; |
- |
- /* tracer initialization phase 1 */ |
- res=TRC_init_phase1_standard(); |
- if (res!=0) { |
- cprintf("tracer initialization error (%i)!!!\n",res); |
- sys_end(); |
- return -1; |
- } |
- |
- return 0; |
-} |
- |
-int __register_sub_init(void) |
-{ |
- return 0; |
-} |
- |
-__dev_t root_device; |
- |
-int __bdev_sub_init(void) |
-{ |
- /* block device initialization */ |
- bdev_init(NULL); |
- |
- /* choose root device */ |
- root_device=bdev_find_byname(ROOTDEVICE); |
- if (root_device<0) { |
- cprintf("can't find root device to mount on /!!!\n"); |
- sys_end(); |
- return -1; |
- } |
- |
- return 0; |
-} |
- |
-int __fs_sub_init(void) |
-{ |
- FILESYSTEM_PARMS fs=BASE_FILESYSTEM; |
- extern int libc_initialize(void); |
- |
- /* filesystems initialization */ |
- filesystem_def_rootdevice(fs,root_device); |
- filesystem_def_fs(fs,FS_MSDOS); |
- filesystem_def_showinfo(fs,FALSE); |
- filesystem_init(&fs); |
- |
- /* libC initialization */ |
- libc_initialize(); |
- |
- /* tracer initialization phase 2 */ |
- TRC_init_phase2_standard(); |
- return 0; |
-} |
- |
-void ctrlc_exit(KEY_EVT *k) |
-{ |
- sys_end(); |
-} |
- |
-int main(int argc,char *argv[]) |
-{ |
- cprintf("\nSimple hello world (with tracer)!\n\n"); |
- return 0; |
-} |
Index: tags/rel_1_22/tracer/small/readme |
=================================================================== |
--- tags/rel_1_22/tracer/small/readme (revision 1310) |
+++ tags/rel_1_22/tracer/small/readme (nonexistent) |
@@ -1,27 +0,0 @@ |
-This directory contains a set of tests that uses the Shark Filesystem and the tracer |
- |
-treef1 - the test shows all filenames of a directory of an hardisk |
- recursively using a soft task for every directory. |
- The tracer with a circular queue is activated. |
- |
-treec2 - the test shows all filenames of a directory of an hardisk |
- recursively using a soft task for every directory. |
- The tracer with a circular queue is activated that write |
- on hardisk online (while the system is running). |
- |
-treec1 - This test show all filenames of a directory of an hardisk |
- recursively using a soft task for every directory. |
- The tracer with a circular queue is activated. |
- |
-test0 - A file is opened for reading while the tracerwith a fixed |
- queue is runnig. |
- |
-simple - Simple hello world (with tracer)! |
- |
-hello - another hello world... |
- |
-hello1 - another hello world with a dummy queue... |
- |
-hello2 - another hello world with a fixed queue... |
- |
-PJ |
Index: tags/rel_1_22/tracer/small/initfs.c |
=================================================================== |
--- tags/rel_1_22/tracer/small/initfs.c (revision 1310) |
+++ tags/rel_1_22/tracer/small/initfs.c (nonexistent) |
@@ -1,119 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-/* |
- * CVS : $Id: initfs.c,v 1.1 2002-11-11 07:45:05 pj Exp $ |
- * |
- * File: $File$ |
- * Revision: $Revision: 1.1 $ |
- * Last update: $Date: 2002-11-11 07:45:05 $ |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/rr.h" |
-#include "modules/cbs.h" |
-#include "modules/dummy.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
-#include "modules/pi.h" |
-#include "modules/pc.h" |
-#include "modules/srp.h" |
-#include "modules/npp.h" |
-#include "modules/nop.h" |
-#include "modules/nopm.h" |
- |
-#include "drivers/keyb.h" |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 1000 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 10000 |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- extern int __register_sub_init_prologue(void); |
- extern int __register_sub_init(void); |
- |
- __register_sub_init_prologue(); |
- |
- EDF_register_level(EDF_ENABLE_ALL); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- CBS_register_level(CBS_ENABLE_ALL, 0); |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- |
- CABS_register_module(); |
- |
- PI_register_module(); |
- PC_register_module(); |
- NPP_register_module(); |
- SRP_register_module(); |
- NOP_register_module(); |
- NOPM_register_module(); |
- |
- __register_sub_init(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- KEYB_PARMS keyb = BASE_KEYB; |
- extern int __bdev_sub_init(void); |
- extern int __fs_sub_init(void); |
- extern void ctrlc_exit(KEY_EVT *k); |
- |
- HARTPORT_init(); |
- |
- keyb_def_ctrlC(keyb, ctrlc_exit); |
- KEYB_init(&keyb); |
- |
- __bdev_sub_init(); |
- __fs_sub_init(); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
Index: tags/rel_1_22/tracer/small/makefile |
=================================================================== |
--- tags/rel_1_22/tracer/small/makefile (revision 1310) |
+++ tags/rel_1_22/tracer/small/makefile (nonexistent) |
@@ -1,29 +0,0 @@ |
-# |
-# |
-# |
- |
-ifndef BASE |
-BASE=../../.. |
-endif |
-include $(BASE)/config/config.mk |
- |
-PROGS= simple hello hello1 hello2 test0 treef1 treec1 treec2 |
- |
-include $(BASE)/config/example.mk |
- |
-simple: |
- make -f $(SUBMAKE) BASE=$(BASE) APP=simple OTHEROBJS=initfs.o SHARKOPT=__OLDCHAR__ |
-hello: |
- make -f $(SUBMAKE) BASE=$(BASE) APP=hello OTHEROBJS=initfs.o SHARKOPT=__OLDCHAR__ |
-hello1: |
- make -f $(SUBMAKE) BASE=$(BASE) APP=hello1 OTHEROBJS="initfs.o common.o" SHARKOPT=__OLDCHAR__ |
-hello2: |
- make -f $(SUBMAKE) BASE=$(BASE) APP=hello2 OTHEROBJS="initfs.o common.o" SHARKOPT=__OLDCHAR__ |
-test0: |
- make -f $(SUBMAKE) BASE=$(BASE) APP=test0 OTHEROBJS="initfs.o common.o" SHARKOPT=__OLDCHAR__ |
-treef1: |
- make -f $(SUBMAKE) BASE=$(BASE) APP=treef1 OTHEROBJS="initfs.o common.o" SHARKOPT=__OLDCHAR__ |
-treec1: |
- make -f $(SUBMAKE) BASE=$(BASE) APP=treec1 OTHEROBJS="initfs.o common.o" SHARKOPT=__OLDCHAR__ |
-treec2: |
- make -f $(SUBMAKE) BASE=$(BASE) APP=treec2 OTHEROBJS="initfs.o common.o" SHARKOPT=__OLDCHAR__ |
Index: tags/rel_1_22/tracer/small/common.h |
=================================================================== |
--- tags/rel_1_22/tracer/small/common.h (revision 1310) |
+++ tags/rel_1_22/tracer/small/common.h (nonexistent) |
@@ -1,28 +0,0 @@ |
- |
-#ifndef _COMMON_H |
-#define _COMMON_H |
- |
-#include <sys/types.h> |
- |
-/* |
-#include <kernel/int_sem.h> |
-#define SEM internal_sem_t |
-#define sem_init internal_sem_init |
-#define sem_signal internal_sem_post |
-#define sem_wait internal_sem_wait |
-*/ |
- |
-#define SEM sem_t |
-#define sem_signal sem_post |
- |
-extern __dev_t root_device; |
-extern __dev_t temp_device; |
- |
-int choose_temp_callback(__dev_t dev,__uint8_t fs); |
- |
-void showmessage(char *s); |
-void waitend(void); |
- |
-#define FROMDIR "/TEMP" |
- |
-#endif |
Index: tags/rel_1_22/tracer/small/test0.c |
=================================================================== |
--- tags/rel_1_22/tracer/small/test0.c (revision 1310) |
+++ tags/rel_1_22/tracer/small/test0.c (nonexistent) |
@@ -1,71 +0,0 @@ |
-/* |
- * |
- * |
- * |
- */ |
- |
-#include <kernel/func.h> |
- |
-#include <fs/bdevinit.h> |
-#include <fs/fsinit.h> |
-#include <fs/bdev.h> |
- |
-#include <drivers/keyb.h> |
- |
-#include <sys/mount.h> |
- |
-#include <fcntl.h> |
-#include <unistd.h> |
-#include <errno.h> |
-#include <string.h> |
- |
-#include "common.h" |
- |
-#define FILENAME "/TEMP/ALFA1.TXT" |
- |
-#include <trace/trace.h> |
-#include <trace/queues.h> |
- |
-int __register_sub_init_prologue(void) |
-{ |
- TRC_init_phase1(NULL); |
- trc_register_fixed_queue(); |
- trc_create_queue(TRC_FIXED_QUEUE,NULL); |
- return 0; |
-} |
- |
-int main(int argc,char *argv[]) |
-{ |
- int h; |
- |
- showmessage("A file is opened for reading while the tracer\n" |
- "with a fixed queue is runnig\n"); |
- |
- cprintf("OPENING %s\n",FILENAME); |
- h=open(FILENAME,O_RDONLY); |
- if (h>=0) { |
- char buffer[128]; |
- int len; |
- cprintf("OPENED!\n"); |
- |
- cprintf("READING...\n"); |
- len=read(h,buffer,sizeof(buffer)); |
- cprintf("READ %i bytes\n",len); |
- memset(buffer,'\0',sizeof(buffer)); |
- cprintf("buffer='%s'\n",buffer); |
- |
- cprintf("READING...\n"); |
- len=read(h,buffer,sizeof(buffer)); |
- cprintf("READ %i bytes\n",len); |
- memset(buffer,'\0',sizeof(buffer)); |
- cprintf("buffer='%s'\n",buffer); |
- |
- close(h); |
- |
- } else |
- cprintf("FAILED!\n"); |
- |
- waitend(); |
- |
- return 0; |
-} |
Index: tags/rel_1_22/tracer/small/treec1.c |
=================================================================== |
--- tags/rel_1_22/tracer/small/treec1.c (revision 1310) |
+++ tags/rel_1_22/tracer/small/treec1.c (nonexistent) |
@@ -1,220 +0,0 @@ |
-/* |
- * |
- * |
- * |
- */ |
- |
-#include <kernel/func.h> |
-#include <kernel/model.h> |
- |
-#include <sys/types.h> |
-#include <sys/stat.h> |
-#include <sys/mount.h> |
-#include <dirent.h> |
-#include <fcntl.h> |
-#include <unistd.h> |
-#include <errno.h> |
-#include <string.h> |
-#include <stdlib.h> |
-#include <semaphore.h> |
-#include <stdio.h> |
-#include <time.h> |
- |
-#include "common.h" |
- |
-#include <trace/trace.h> |
-#include <trace/queues.h> |
- |
- |
-int noscroll=0; |
-SEM console; |
- |
-#define MPROC ((50<(MAX_PROC-10))?50:MAX_PROC-10) |
- |
-TASK viewdir(void *prof); |
-sem_t actmutex,actsync; |
-char *globpathname; |
-PID globpid; |
-int counter=0,actcounter=0; |
- |
-void activate_task(int prof, char *pathname) |
-{ |
- char tname[32]; |
- NRT_TASK_MODEL m; |
- PID pid; |
- |
-REPEAT: |
- sem_wait(&actmutex); |
- |
- if (actcounter>=MPROC) { |
- struct timespec delay; |
- delay.tv_sec = 0; |
- delay.tv_nsec = 10000000; |
- sem_signal(&actmutex); |
- nanosleep(&delay, NULL); |
- goto REPEAT; |
- } |
- |
- globpathname=pathname; |
- counter++; |
- sprintf(tname,"tsk%i",counter); |
- |
- nrt_task_default_model(m); |
- nrt_task_def_arg(m,(void*)counter); |
- |
- globpid=pid=task_create(tname,viewdir,&m,NULL); |
- if (pid==-1) { |
- sem_wait(&console); |
- cprintf("can't create '%s'\n",tname); |
- perror("can't create task"); |
- sem_signal(&console); |
- sys_end(); |
- return; |
- } |
- task_activate(pid); |
- sem_wait(&actsync); |
- actcounter++; |
- |
- sem_signal(&actmutex); |
-} |
- |
-/* |
- * |
- */ |
- |
-int filecounter=0; |
- |
-TASK viewdir(void *pointer) |
-{ |
- struct dirent *den; |
- struct stat st; |
- char *str; |
- DIR *d; |
- int res; |
- int x; |
- char pathname[1024]; |
- PID mypid; |
- int prof=(int)pointer; |
- |
- strcpy(pathname,globpathname); |
- mypid=globpid; |
- sem_signal(&actsync); |
- |
- str=pathname+(x=strlen(pathname)); |
- d=opendir(pathname); |
- |
- if (d==NULL) { |
- sem_wait(&console); |
- cprintf("%03i ERR: can't open dir %s\n",prof,pathname); |
- cprintf("errno: %i '%s'\n",errno,strerror(errno)); |
- sem_signal(&console); |
- |
- sys_end(); |
- l1_exit(0); |
- |
- goto END; |
- } |
- |
- while ((den=readdir(d))!=NULL) { |
- |
- if (x==1&&*pathname=='/') |
- strcat(pathname,den->d_name); |
- else |
- strcat(strcat(pathname,"/"),den->d_name); |
- |
- sem_wait(&console); |
- if (noscroll) { |
- place(0,10); |
- cprintf(" "); |
- place(0,10); |
- } |
- cprintf("t%03i %s\n",prof,pathname); |
- filecounter++; |
- sem_signal(&console); |
- |
- if (!strcmp(den->d_name,".")) goto SKIP; |
- if (!strcmp(den->d_name,"..")) goto SKIP; |
- |
- res=stat(pathname,&st); |
- if (res!=0) { |
- sem_wait(&console); |
- cprintf("t%03i can't stat %s\n",prof,pathname); |
- cprintf("errno: %i '%s'\n",errno,strerror(errno)); |
- sem_signal(&console); |
- |
- sys_end(); |
- l1_exit(0); |
- |
- closedir(d); |
- goto END; |
- } else { |
- if (S_ISDIR(st.st_mode)) { |
- sem_wait(&console); |
- sem_signal(&console); |
- activate_task(prof,pathname); |
- } |
- |
- } |
- |
- SKIP: |
- *str='\0'; |
- } |
- |
- closedir(d); |
- |
-END: |
- sem_wait(&actmutex); |
- actcounter--; |
- sem_signal(&actmutex); |
- |
- return 0; |
-} |
- |
-/* |
- * |
- */ |
- |
-int __register_sub_init_prologue(void) |
-{ |
- TRC_init_phase1(NULL); |
- trc_register_circular_queue(); |
- trc_create_queue(TRC_CIRCULAR_QUEUE,NULL); |
- return 0; |
-} |
- |
-/* |
- * |
- */ |
- |
-int main(int argc,char *argv[]) |
-{ |
- // int res; |
- |
- showmessage("This test show all filenames of a directory of an hardisk\n" |
- "recursively using a soft task for every directory.\n" |
- "The tracer with a circular queue is activated.\n"); |
- |
- sem_init(&console,0,1); |
- sem_init(&actmutex,0,1); |
- sem_init(&actsync,0,0); |
- |
- activate_task(-1,FROMDIR); |
- |
- { |
- struct timespec delay; |
- delay.tv_sec = 0; |
- delay.tv_nsec = 500000000; |
- for(;;) { |
- sem_wait(&actmutex); |
- if (actcounter==0) break; |
- sem_signal(&actmutex); |
- nanosleep(&delay, NULL); |
- } |
- } |
- |
- cprintf("\nfiles: %i\n",filecounter); |
- |
- waitend(); |
- |
- return 0; |
-} |
Index: tags/rel_1_22/tracer/small/hello.c |
=================================================================== |
--- tags/rel_1_22/tracer/small/hello.c (revision 1310) |
+++ tags/rel_1_22/tracer/small/hello.c (nonexistent) |
@@ -1,209 +0,0 @@ |
-/* |
- * Project: HARTIK (HA-rd R-eal TI-me K-ernel) |
- * |
- * Coordinators: Giorgio Buttazzo <giorgio@sssup.it> |
- * Gerardo Lamastra <gerardo@sssup.it> |
- * |
- * Authors : Massimiliano Giorgi <massy@hartik.sssup.it> |
- * (see authors.txt for full list of hartik's authors) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://hartik.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Massimiliano Giorgi |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-/* |
- * CVS : $Id: hello.c,v 1.2 2003-12-17 14:15:45 giacomo Exp $ |
- * |
- * File: $File$ |
- * Revision: $Revision: 1.2 $ |
- * Last update: $Date: 2003-12-17 14:15:45 $ |
- */ |
- |
-/* |
- * Example of tracer initialization. |
- */ |
- |
-#include <ll/i386/cons.h> |
- |
-#include <kernel/func.h> |
-#include <tracer.h> |
- |
-#include <fs/bdevinit.h> |
-#include <fs/fsinit.h> |
-#include <fs/bdev.h> |
- |
-#include <drivers/keyb.h> |
- |
-#include <trace.h> |
-#include <queues.h> |
- |
-#include <sys/mount.h> |
-#include <stddef.h> |
- |
-/* |
- this example use initfs.c to initialize the system; this file define |
- the following two function. |
- |
- __kernel_register_levels__(), must initialize all kernel modules, |
- it has this structure: |
- |
- { |
- __register_sub_init_prologue(); |
- |
- ... modules initialization.... |
- |
- __register_sub_init(); |
- } |
- |
- __init__(void *arg) is called when the first task is created |
- and must call the main(): |
- |
- { |
- |
- ... drivers initialization .... |
- |
- __bdev_sub_init(); |
- __fs_sub_init(); |
- |
- call_main() |
- |
- } |
- |
- */ |
- |
-/* |
- * This function is called before all other modules initialization because |
- * all modules that need the tracer must follow tracer initialization. |
- */ |
-int __register_sub_init_prologue(void) |
-{ |
- /* the first functions to call... parameters can be passed */ |
- TRC_init_phase1(NULL); |
- /* all the tracer queues must be registrated (in this case only */ |
- /* a dummy queue is initialized) */ |
- trc_register_dummy_queue(); |
- /* the queues must be created (only one in this example) */ |
- trc_create_queue(TRC_DUMMY_QUEUE,NULL); |
- /* events can be dispatch to a queue (nothing in this case) */ |
- return 0; |
-} |
- |
-/* |
- * This function is called after all other modules initialization |
- * functions... notjing to do. |
- */ |
-int __register_sub_init(void) |
-{ |
- return 0; |
-} |
- |
-__dev_t root_device; |
-__dev_t temp_device; |
- |
-/* |
- * Now the system is running... we have to initialize the block device |
- * drivers |
- */ |
-int __bdev_sub_init(void) |
-{ |
- BDEV_PARMS bdev=BASE_BDEV; |
- |
- /* This to initialize the block device drivers... a NULL can be passed */ |
- /* to the bdev_init() functions */ |
- bdev_def_showinfo(bdev,FALSE); |
- bdev_init(&bdev); |
- |
- /* The following phase ca be made in several way: we must decide the */ |
- /* device that we want mount as root... we use the bdev_find_byname() */ |
- /* functions to find a specific device */ |
- root_device=bdev_find_byname("ide/hda1"); |
- if (root_device<0) { |
- cprintf("can't find root device to mount on /!!!\n"); |
- sys_end(); |
- return -1; |
- } |
- |
- /* Well, we want a device to mount into /TEMP */ |
- temp_device=bdev_find_byname("ide/hdb3"); |
- if (temp_device<0) { |
- cprintf("can't find a filesystem to mount on /TEMP!!!\n"); |
- sys_end(); |
- return -1; |
- } |
- |
- return 0; |
-} |
- |
- |
-/* |
- * This is the real filesystem initialization! |
- */ |
-int __fs_sub_init(void) |
-{ |
- FILESYSTEM_PARMS fs=BASE_FILESYSTEM; |
- extern int libc_initialize(void); |
- int res; |
- struct mount_opts opts; |
- |
- /* We set the root device and call the filesystem_init() function */ |
- filesystem_def_rootdevice(fs,root_device); |
- filesystem_def_fs(fs,FS_MSDOS); |
- filesystem_def_showinfo(fs,FALSE); |
- filesystem_init(&fs); |
- |
- /* We must initialize the libC if we use it */ |
- libc_initialize(); |
- |
- /* We have choose to mount the second partiotion into the /TEMP */ |
- /* directory with read/write privilegies (this step is not required) */ |
- if (temp_device>=0) { |
- memset(&opts,0,sizeof(struct mount_opts)); |
- opts.flags=MOUNT_FLAG_RW; |
- res=mount(temp_device,FS_MSDOS,"/TEMP",&opts); |
- if (res!=0) { |
- cprintf("can't mount XXX on /TEMP (errno: %i)\n",errno); |
- } |
- } |
- |
- /* NOW we call the tracer initialization phase 2!!! */ |
- /* It must FOLLOW the filesystem initialization... (this function */ |
- /* can be called after the call to filesystem_init() functions but */ |
- /* we do it here because we want be able to write into the /TEMP */ |
- /* directory! */ |
- TRC_init_phase2(); |
- |
- return 0; |
-} |
- |
-void ctrlc_exit(KEY_EVT *k) |
-{ |
- sys_end(); |
-} |
- |
-int main(int argc,char *argv[]) |
-{ |
- cprintf("\nHello, world!\n"); |
- return 0; |
-} |
Index: tags/rel_1_22/tracer/small/treec2.c |
=================================================================== |
--- tags/rel_1_22/tracer/small/treec2.c (revision 1310) |
+++ tags/rel_1_22/tracer/small/treec2.c (nonexistent) |
@@ -1,233 +0,0 @@ |
-/* |
- * |
- * |
- * |
- */ |
- |
-#include <kernel/func.h> |
-#include <kernel/model.h> |
- |
-#include <sys/types.h> |
-#include <sys/stat.h> |
-#include <sys/mount.h> |
-#include <dirent.h> |
-#include <fcntl.h> |
-#include <unistd.h> |
-#include <errno.h> |
-#include <string.h> |
-#include <stdlib.h> |
-#include <semaphore.h> |
-#include <stdio.h> |
-#include <time.h> |
- |
-#include "common.h" |
- |
-#include <trace/trace.h> |
-#include <trace/queues.h> |
- |
-#define sem_signal sem_post |
- |
-int noscroll=0; |
-SEM console; |
- |
-#define MPROC ((50<(MAX_PROC-10))?50:MAX_PROC-10) |
- |
-TASK viewdir(void *prof); |
-sem_t actmutex,actsync; |
-char *globpathname; |
-PID globpid; |
-int counter=0,actcounter=0; |
- |
-void activate_task(int prof, char *pathname) |
-{ |
- char tname[32]; |
- NRT_TASK_MODEL m; |
- PID pid; |
- |
-REPEAT: |
- sem_wait(&actmutex); |
- |
- if (actcounter>=MPROC) { |
- struct timespec delay; |
- delay.tv_sec = 0; |
- delay.tv_nsec = 10000000; |
- sem_signal(&actmutex); |
- nanosleep(&delay, NULL); |
- goto REPEAT; |
- } |
- |
- globpathname=pathname; |
- counter++; |
- sprintf(tname,"tsk%i",counter); |
- |
- nrt_task_default_model(m); |
- nrt_task_def_arg(m,(void*)counter); |
- |
- globpid=pid=task_create(tname,viewdir,&m,NULL); |
- if (pid==-1) { |
- sem_wait(&console); |
- cprintf("can't create '%s'\n",tname); |
- perror("can't create task"); |
- sem_signal(&console); |
- sys_end(); |
- return; |
- } |
- task_activate(pid); |
- sem_wait(&actsync); |
- actcounter++; |
- |
- sem_signal(&actmutex); |
-} |
- |
-/* |
- * |
- */ |
- |
-int filecounter=0; |
- |
-TASK viewdir(void *pointer) |
-{ |
- struct dirent *den; |
- struct stat st; |
- char *str; |
- DIR *d; |
- int res; |
- int x; |
- char pathname[1024]; |
- PID mypid; |
- int prof=(int)pointer; |
- |
- strcpy(pathname,globpathname); |
- mypid=globpid; |
- sem_signal(&actsync); |
- |
- str=pathname+(x=strlen(pathname)); |
- d=opendir(pathname); |
- |
- if (d==NULL) { |
- sem_wait(&console); |
- cprintf("%03i ERR: can't open dir %s\n",prof,pathname); |
- cprintf("errno: %i '%s'\n",errno,strerror(errno)); |
- sem_signal(&console); |
- |
- sys_end(); |
- l1_exit(0); |
- |
- goto END; |
- } |
- |
- while ((den=readdir(d))!=NULL) { |
- |
- if (x==1&&*pathname=='/') |
- strcat(pathname,den->d_name); |
- else |
- strcat(strcat(pathname,"/"),den->d_name); |
- |
- sem_wait(&console); |
- if (noscroll) { |
- place(0,10); |
- cprintf(" "); |
- place(0,10); |
- } |
- cprintf("t%03i %s\n",prof,pathname); |
- filecounter++; |
- sem_signal(&console); |
- |
- if (!strcmp(den->d_name,".")) goto SKIP; |
- if (!strcmp(den->d_name,"..")) goto SKIP; |
- |
- res=stat(pathname,&st); |
- if (res!=0) { |
- sem_wait(&console); |
- cprintf("t%03i can't stat %s\n",prof,pathname); |
- cprintf("errno: %i '%s'\n",errno,strerror(errno)); |
- sem_signal(&console); |
- |
- sys_end(); |
- l1_exit(0); |
- |
- closedir(d); |
- goto END; |
- } else { |
- if (S_ISDIR(st.st_mode)) { |
- sem_wait(&console); |
- sem_signal(&console); |
- activate_task(prof,pathname); |
- } |
- |
- } |
- |
- SKIP: |
- *str='\0'; |
- } |
- |
- closedir(d); |
- |
-END: |
- sem_wait(&actmutex); |
- actcounter--; |
- sem_signal(&actmutex); |
- |
- return 0; |
-} |
- |
-/* |
- * |
- */ |
- |
-int __register_sub_init_prologue(void) |
-{ |
- TRC_CIRCULAR_PARMS args; |
- int q; |
- |
- TRC_init_phase1(NULL); |
- trc_register_circular_queue(); |
- |
- trc_circular_default_parms(args); |
- trc_circular_def_onlinetask(args); |
- q=trc_create_queue(TRC_CIRCULAR_QUEUE,&args); |
- |
- trc_assign_class_to_queue(TRC_CLASS_SYSTEM,q); |
- trc_trace_class(TRC_CLASS_SYSTEM); |
- |
- return 0; |
-} |
- |
-/* |
- * |
- */ |
- |
-int main(int argc,char *argv[]) |
-{ |
- // int res; |
- |
- showmessage("This test show all filenames of a directory of an hardisk\n" |
- "recursively using a soft task for every directory.\n" |
- "The tracer with a circular queue is activated that write\n" |
- "on hardisk online (while the system is running)\n"); |
- |
- sem_init(&console,0,1); |
- sem_init(&actmutex,0,1); |
- sem_init(&actsync,0,0); |
- |
- activate_task(-1,FROMDIR); |
- //activate_task(-1,"/"); |
- |
- { |
- struct timespec delay; |
- delay.tv_sec = 0; |
- delay.tv_nsec = 500000000; |
- for(;;) { |
- sem_wait(&actmutex); |
- if (actcounter==0) break; |
- sem_signal(&actmutex); |
- nanosleep(&delay, NULL); |
- } |
- } |
- |
- cprintf("\nfiles: %i\n",filecounter); |
- |
- waitend(); |
- |
- return 0; |
-} |
Index: tags/rel_1_22/tracer/small/hello1.c |
=================================================================== |
--- tags/rel_1_22/tracer/small/hello1.c (revision 1310) |
+++ tags/rel_1_22/tracer/small/hello1.c (nonexistent) |
@@ -1,27 +0,0 @@ |
-/* |
- * |
- * |
- * |
- */ |
- |
-#include <ll/i386/cons.h> |
-#include <stddef.h> |
- |
-#include <trace/trace.h> |
-#include <trace/queues.h> |
- |
-int __register_sub_init_prologue(void) |
-{ |
- TRC_init_phase1(NULL); |
- trc_register_dummy_queue(); |
- trc_create_queue(TRC_DUMMY_QUEUE,NULL); |
- return 0; |
-} |
- |
-int main(int argc,char *argv[]) |
-{ |
- cprintf("\nHello, world!\n"); |
- cprintf("The tracer has been activated!\n"); |
- cprintf("(No result are produced)\n\n"); |
- return 0; |
-} |
Index: tags/rel_1_22/tracer/small/hello2.c |
=================================================================== |
--- tags/rel_1_22/tracer/small/hello2.c (revision 1310) |
+++ tags/rel_1_22/tracer/small/hello2.c (nonexistent) |
@@ -1,30 +0,0 @@ |
-/* |
- * |
- * |
- * |
- */ |
- |
-#include <ll/i386/cons.h> |
-#include <stddef.h> |
- |
-#include <trace/trace.h> |
-#include <trace/queues.h> |
- |
-int __register_sub_init_prologue(void) |
-{ |
- int q; |
- TRC_init_phase1(NULL); |
- trc_register_fixed_queue(); |
- q=trc_create_queue(TRC_FIXED_QUEUE,NULL); |
- trc_assign_class_to_queue(TRC_CLASS_SYSTEM,q); |
- trc_trace_class(TRC_CLASS_SYSTEM); |
- return 0; |
-} |
- |
-int main(int argc,char *argv[]) |
-{ |
- cprintf("\nHello, world!\n"); |
- cprintf("The tracer has been activated! Look at the results.\n"); |
- cprintf("(A fixed queue has been created)\n\n"); |
- return 0; |
-} |
Index: tags/rel_1_22/tracer/small/treef1.c |
=================================================================== |
--- tags/rel_1_22/tracer/small/treef1.c (revision 1310) |
+++ tags/rel_1_22/tracer/small/treef1.c (nonexistent) |
@@ -1,224 +0,0 @@ |
-/* |
- * |
- * |
- * |
- */ |
- |
-#include <kernel/func.h> |
-#include <kernel/model.h> |
- |
-#include <sys/types.h> |
-#include <sys/stat.h> |
-#include <sys/mount.h> |
-#include <dirent.h> |
-#include <fcntl.h> |
-#include <unistd.h> |
-#include <errno.h> |
-#include <string.h> |
-#include <stdlib.h> |
-#include <semaphore.h> |
-#include <stdio.h> |
-#include <time.h> |
- |
-#include "common.h" |
- |
-#include <trace/trace.h> |
-#include <trace/queues.h> |
- |
-#define sem_signal sem_post |
- |
-int noscroll=0; |
-SEM console; |
- |
-#define MPROC ((50<(MAX_PROC-10))?50:MAX_PROC-10) |
- |
-TASK viewdir(void *prof); |
-sem_t actmutex,actsync; |
-char *globpathname; |
-PID globpid; |
-int counter=0,actcounter=0; |
- |
-void activate_task(int prof, char *pathname) |
-{ |
- char tname[32]; |
- NRT_TASK_MODEL m; |
- PID pid; |
- |
-REPEAT: |
- sem_wait(&actmutex); |
- |
- if (actcounter>=MPROC) { |
- struct timespec delay; |
- delay.tv_sec = 0; |
- delay.tv_nsec = 10000000; |
- sem_signal(&actmutex); |
- nanosleep(&delay, NULL); |
- goto REPEAT; |
- } |
- |
- globpathname=pathname; |
- counter++; |
- sprintf(tname,"tsk%i",counter); |
- |
- nrt_task_default_model(m); |
- nrt_task_def_arg(m,(void*)counter); |
- |
- globpid=pid=task_create(tname,viewdir,&m,NULL); |
- if (pid==-1) { |
- sem_wait(&console); |
- cprintf("can't create '%s'\n",tname); |
- perror("can't create task"); |
- sem_signal(&console); |
- sys_end(); |
- return; |
- } |
- task_activate(pid); |
- sem_wait(&actsync); |
- actcounter++; |
- |
- sem_signal(&actmutex); |
-} |
- |
-/* |
- * |
- */ |
- |
-int filecounter=0; |
- |
-TASK viewdir(void *pointer) |
-{ |
- struct dirent *den; |
- struct stat st; |
- char *str; |
- DIR *d; |
- int res; |
- int x; |
- char pathname[1024]; |
- PID mypid; |
- int prof=(int)pointer; |
- |
- strcpy(pathname,globpathname); |
- mypid=globpid; |
- sem_signal(&actsync); |
- |
- str=pathname+(x=strlen(pathname)); |
- d=opendir(pathname); |
- |
- if (d==NULL) { |
- sem_wait(&console); |
- cprintf("%03i ERR: can't open dir %s\n",prof,pathname); |
- cprintf("errno: %i '%s'\n",errno,strerror(errno)); |
- sem_signal(&console); |
- |
- sys_end(); |
- l1_exit(0); |
- |
- goto END; |
- } |
- |
- while ((den=readdir(d))!=NULL) { |
- |
- if (x==1&&*pathname=='/') |
- strcat(pathname,den->d_name); |
- else |
- strcat(strcat(pathname,"/"),den->d_name); |
- |
- sem_wait(&console); |
- if (noscroll) { |
- place(0,10); |
- cprintf(" "); |
- place(0,10); |
- } |
- cprintf("t%03i %s\n",prof,pathname); |
- filecounter++; |
- sem_signal(&console); |
- |
- if (!strcmp(den->d_name,".")) goto SKIP; |
- if (!strcmp(den->d_name,"..")) goto SKIP; |
- |
- res=stat(pathname,&st); |
- if (res!=0) { |
- sem_wait(&console); |
- cprintf("t%03i can't stat %s\n",prof,pathname); |
- cprintf("errno: %i '%s'\n",errno,strerror(errno)); |
- sem_signal(&console); |
- |
- sys_end(); |
- l1_exit(0); |
- |
- closedir(d); |
- goto END; |
- } else { |
- if (S_ISDIR(st.st_mode)) { |
- sem_wait(&console); |
- sem_signal(&console); |
- activate_task(prof,pathname); |
- } |
- |
- } |
- |
- SKIP: |
- *str='\0'; |
- } |
- |
- closedir(d); |
- |
-END: |
- sem_wait(&actmutex); |
- actcounter--; |
- sem_signal(&actmutex); |
- |
- return 0; |
-} |
- |
-/* |
- * |
- */ |
- |
-int __register_sub_init_prologue(void) |
-{ |
- int q; |
- TRC_init_phase1(NULL); |
- trc_register_fixed_queue(); |
- q=trc_create_queue(TRC_FIXED_QUEUE,NULL); |
- trc_assign_class_to_queue(TRC_CLASS_SYSTEM,q); |
- trc_trace_class(TRC_CLASS_SYSTEM); |
- return 0; |
-} |
- |
-/* |
- * |
- */ |
- |
-int main(int argc,char *argv[]) |
-{ |
- // int res; |
- |
- showmessage("This test show all filenames of a directory of an hardisk\n" |
- "recursively using a soft task for every directory.\n" |
- "The tracer with a circular queue is activated.\n"); |
- |
- sem_init(&console,0,1); |
- sem_init(&actmutex,0,1); |
- sem_init(&actsync,0,0); |
- |
- activate_task(-1,FROMDIR); |
- |
- { |
- struct timespec delay; |
- delay.tv_sec = 0; |
- delay.tv_nsec = 500000000; |
- for(;;) { |
- sem_wait(&actmutex); |
- if (actcounter==0) break; |
- sem_signal(&actmutex); |
- nanosleep(&delay, NULL); |
- } |
- } |
- |
- cprintf("\nfiles: %i\n",filecounter); |
- |
- waitend(); |
- |
- return 0; |
-} |
Index: tags/rel_1_22/tracer/small/common.c |
=================================================================== |
--- tags/rel_1_22/tracer/small/common.c (revision 1310) |
+++ tags/rel_1_22/tracer/small/common.c (nonexistent) |
@@ -1,133 +0,0 @@ |
- |
-#include <kernel/func.h> |
-#include <tracer.h> |
- |
-#include <fs/bdevinit.h> |
-#include <fs/fsinit.h> |
-#include <fs/bdev.h> |
- |
-#include <drivers/keyb.h> |
- |
-#include <trace.h> |
-#include <queues.h> |
- |
-#include <sys/mount.h> |
- |
-#include <fcntl.h> |
-#include <unistd.h> |
-#include <errno.h> |
- |
-int __register_sub_init(void) |
-{ |
- return 0; |
-} |
- |
-/* -- */ |
- |
-__dev_t root_device; |
-__dev_t temp_device; |
- |
-int choose_root_callback(__dev_t dev,__uint8_t fs) |
-{ |
- if (fs==FS_MSDOS) return dev; |
- return -1; |
-} |
- |
-int choose_temp_callback(__dev_t dev,__uint8_t fs) |
-{ |
- static int flag=0; |
- if (fs==FS_MSDOS) { |
- if (flag) return dev; |
- flag=1; |
- } |
- return -1; |
-} |
- |
-/* -- */ |
- |
-extern int bdev_scan_devices(int(*callback)(__dev_t,__uint8_t)); |
- |
-int __bdev_sub_init(void) |
-{ |
- BDEV_PARMS bdev=BASE_BDEV; |
- |
- bdev_def_showinfo(bdev,FALSE); |
- bdev_init(&bdev); |
- |
- root_device=bdev_scan_devices(choose_root_callback); |
- if (root_device<0) { |
- cprintf("can't find root device to mount on /!!!\n"); |
- sys_end(); |
- return -1; |
- } |
- |
- temp_device=bdev_scan_devices(choose_temp_callback); |
- if (temp_device<0) { |
- cprintf("can't find a filesystem to mount on /TEMP!!!\n"); |
- } |
- |
- return 0; |
-} |
- |
-/* -- */ |
- |
-extern int libc_initialize(void); |
- |
-int __fs_sub_init(void) |
-{ |
- FILESYSTEM_PARMS fs=BASE_FILESYSTEM; |
- struct mount_opts opts; |
- int res; |
- |
- filesystem_def_rootdevice(fs,root_device); |
- filesystem_def_fs(fs,FS_MSDOS); |
- filesystem_def_showinfo(fs,FALSE); |
- |
- |
- //filesystem_init_prologue(); |
- filesystem_init(&fs); |
- |
- libc_initialize(); |
- |
- if (temp_device>=0) { |
- memset(&opts,0,sizeof(struct mount_opts)); |
- opts.flags=MOUNT_FLAG_RW; |
- res=mount(temp_device,FS_MSDOS,"/TEMP",&opts); |
- if (res!=0) { |
- cprintf("can't mount XXX on /TEMP (errno: %i)\n",errno); |
- } |
- } |
- |
- TRC_init_phase2(); |
- |
- return 0; |
-} |
- |
-/* -- */ |
- |
-void ctrlc_exit(KEY_EVT *k) |
-{ |
- extern void dump_sem_table(void); |
- extern void dump_nop_table(void); |
- //dump_sem_table(); |
- //dump_nop_table(); |
- sys_end(); |
-} |
- |
-/* -- */ |
- |
-void showmessage(char *s) |
-{ |
- cputs(s); |
- cprintf("Press [x] to begin..."); |
- while (keyb_getchar()!='x'); |
- cprintf("\n"); |
-} |
- |
-void waitend(void) |
-{ |
- int c; |
- cprintf("Press [x] to exit..."); |
- while ((c=keyb_getchar())!='x'); |
- cprintf("\n"); |
-} |
Index: tags/rel_1_22/tracer/readme |
=================================================================== |
--- tags/rel_1_22/tracer/readme (revision 1310) |
+++ tags/rel_1_22/tracer/readme (nonexistent) |
@@ -1,14 +0,0 @@ |
-This directory contains a set of sub directories containing all the tracer |
-examples and utilities. |
- |
-Here a short description of the contents |
- |
-utils - some small utilities that can read tracer files |
-dfixed - a small applications that defines a tracer queue. |
- At the end a file is written (using DOSFS). |
-small - a set of small examples of tracer usage (using the Shark Filesystem) |
-udp - a small application that sends its trace data through the network |
- |
-Enjoy |
- |
-PJ |
Index: tags/rel_1_22/tracer/makefile |
=================================================================== |
--- tags/rel_1_22/tracer/makefile (revision 1310) |
+++ tags/rel_1_22/tracer/makefile (nonexistent) |
@@ -1,11 +0,0 @@ |
-.PHONY: all clean |
- |
-all: |
- make -C dfixed |
- make -C small |
- make -C udp |
- |
-clean: |
- make -C dfixed clean |
- make -C small clean |
- make -C udp clean |
Index: tags/rel_1_22/oscilloscopio/adc.c |
=================================================================== |
--- tags/rel_1_22/oscilloscopio/adc.c (revision 1310) |
+++ tags/rel_1_22/oscilloscopio/adc.c (nonexistent) |
@@ -1,400 +0,0 @@ |
-/***************************************************************************** |
-* Filename: ADC.C * |
-* Author: Ghiro Andrea,Franchino Gianluca * |
-* Date: 06/06/2001 * |
-* Description: Analog 2 digital conversion functions * |
-*----------------------------------------------------------------------------* |
-* Notes: Funcion for one sample from Ch0 * |
-*****************************************************************************/ |
- |
-/* This file is part of the S.Ha.R.K. Project - http://shark.sssup.it |
- * |
- * Copyright (C) 2003 Ghiro Andrea,Franchino Gianluca |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include "adc.h" |
- |
-/* |
-* Call this function to configure board options. |
-*/ |
- |
-void Configure_Board(BYTE numch) |
-{ |
-WORD memhi; |
- /* |
- * Writing to register Write_Strobe_0_Register with address 82. |
- * Write_Strobe_0 <= 1 |
- * New pattern = 0x0001 |
- */ |
- DAQ_STC_Windowed_Mode_Write(WRITE_STROBE_0,0x0001); |
- |
- /* |
- * Writing to register Write_Strobe_1_Register with address 83. |
- * Write_Strobe_1 <= 1 |
- * New pattern = 0x0001 |
- */ |
- DAQ_STC_Windowed_Mode_Write(WRITE_STROBE_1,0x0001); |
- |
- /* |
- * Writing to register Config_Memory_High_Register with address 18. |
- * CM_Channel_Number <= channel_number (0) |
- * CM_Channel_Bank <= channel_bank (0) |
- * CM_Channel_Type <= channel_type_for_rev_b (3) |
- * New pattern = 0x3000 |
- */ |
- memhi = 0x3000 | numch; |
- Immediate_Writew(ADC_CONFIG_HI,memhi); |
- |
- /* |
- * Writing to register Config_Memory_Low_Register with address 16. |
- * CM_Last_Channel <= last_channel (1) |
- * CM_Trigger <= trigger (0) |
- * CM_AI_Gain <= ai_gain (1) |
- * CM_AI_Polarity <= ai_polarity (0) |
- * CM_AI_Dither_Enable <= ai_dither_enable (0) |
- * New pattern = 0x8001 |
- */ |
- Immediate_Writew(ADC_CONFIG_LO,0x8100); |
- return; |
- } |
- |
-/* |
-* program the ADC_STC |
-*/ |
- |
-void ADC_Init() |
-{ |
-/* |
-* configure the timebase options. |
-*/ |
- /* |
- * Writing to register Clock_and_FOUT_Register with address 56. |
- * Slow_Internal_Timebase <= p->msc_slow_int_tb_enable (1) |
- * Slow_Internal_Time_Divide_By_2 <= p->msc_slow_int_tb_divide_by_2 (1) |
- * Clock_To_Board <= p->msc_clock_to_board_enable (1) |
- * Clock_To_Board_Divide_By_2 <= p->msc_clock_to_board_divide_by_2 (1) |
- * New pattern = 0x1B00 |
- */ |
- DAQ_STC_Windowed_Mode_Write(CLOCK_AND_FOUT,0x1B00); |
- |
-/* |
-* clear the AI FIFO. |
-*/ |
- /* |
- * Writing to register Write_Strobe_1_Register with address 83. |
- * Write_Strobe_1 <= 1 |
- * New pattern = 0x0001 |
- */ |
- DAQ_STC_Windowed_Mode_Write(WRITE_STROBE_1,0x0001); |
- |
-/* |
-* stop any activities in progress. |
-*/ |
- /* |
- * Writing to register Joint_Reset_Register with address 72. |
- * AI_Reset <= 1 |
- * New pattern = 0x0001 |
- */ |
- DAQ_STC_Windowed_Mode_Write(JOINT_RESET,0x0001); |
- |
- /* |
- * Writing to register Joint_Reset_Register with address 72. |
- * AI_Configuration_Start <= 1 |
- * New pattern = 0x0010 |
- */ |
- DAQ_STC_Windowed_Mode_Write(JOINT_RESET,0x0010); |
- |
- /* |
- * Writing to register Interrupt_A_Ack_Register with address 2. |
- * AI_SC_TC_Error_Confirm <= 1 |
- * AI_SC_TC_Interrupt_Ack <= 1 |
- * AI_START1_Interrupt_Ack <= 1 |
- * AI_START2_Interrupt_Ack <= 1 |
- * AI_START_Interrupt_Ack <= 1 |
- * AI_STOP_Interrupt_Ack <= 1 |
- * AI_Error_Interrupt_Ack <= 1 |
- * New pattern = 0x3F80 |
- */ |
- DAQ_STC_Windowed_Mode_Write(INTERRUPT_A_ACK,0x3F80); |
- |
- /* |
- * Writing to register AI_Command_1_Register with address 8. |
- * AI_Command_1_Register <= 0 |
- * New pattern = 0x0000 |
- */ |
- DAQ_STC_Windowed_Mode_Write(AI_COMMAND_1,0x0000); |
- |
- /* |
- * Writing to register AI_Mode_1_Register with address 12. |
- * Reserved_One <= 1 |
- * AI_Start_Stop <= 1 |
- * New pattern = 0x000C |
- */ |
- DAQ_STC_Windowed_Mode_Write(AI_MODE_1,0x000C); |
- |
- /* |
- * Writing to register Joint_Reset_Register with address 72. |
- * AI_Configuration_Start <= 0 |
- * AI_Configuration_End <= 1 |
- * New pattern = 0x0100 |
- */ |
- DAQ_STC_Windowed_Mode_Write(JOINT_RESET,0x0100); |
- |
-/* |
-* setup the board. |
-*/ |
- /* |
- * Writing to register Joint_Reset_Register with address 72. |
- * AI_Configuration_Start <= 1 |
- * New pattern = 0x0010 |
- */ |
- DAQ_STC_Windowed_Mode_Write(JOINT_RESET,0x0010); |
- |
- /* |
- * Writing to register Clock_and_FOUT_Register with address 56. |
- * AI_Source_Divide_By_2 <= p->ai_source_divide_by_2 (0) |
- * AI_Output_Divide_By_2 <= p->ai_output_divide_by_2 (1) |
- * New pattern = 0x1B80 |
- */ |
- DAQ_STC_Windowed_Mode_Write(CLOCK_AND_FOUT,0x1B80); |
- |
- /* |
- * Writing to register AI_Personal_Register with address 77. |
- * AI_CONVERT_Pulse_Timebase <= p->ai_convert_pulse_timebase (0) |
- * AI_CONVERT_Pulse_Width <= p->ai_convert_pulse_width (1) |
- * AI_FIFO_Flags_Polarity <= p->ai_fifo_flags_polarity (0) |
- * AI_LOCALMUX_CLK_Pulse_Width <= p->ai_localmux_clk_pulse_width (1) |
- * AI_AIFREQ_Polarity <= p->ai_aifreq_polarity (0) |
- * AI_SHIFTIN_Polarity <= p->ai_shiftin_polarity (0) |
- * AI_SHIFTIN_Pulse_Width <= p->ai_shiftin_pulse_width (1) |
- * AI_EOC_Polarity <= p->ai_eoc_polarity (0) |
- * AI_SOC_Polarity <= p->ai_soc_polarity (1) |
- * AI_Overrun_Mode <= p->ai_overrun_mode (1) |
- * New pattern = 0xA4A0 |
- */ |
- DAQ_STC_Windowed_Mode_Write(AI_PERSONAL,0xA4A0); |
- |
- /* |
- * Writing to register AI_Output_Control_Register with address 60. |
- * AI_CONVERT_Output_Select <= p->ai_convert_output_select (2) |
- * AI_SC_TC_Output_Select <= p->ai_sc_tc_output_select (3) |
- * AI_SCAN_IN_PROG_Output_Select <= p->ai_scan_in_prog_output_select (3) |
- * AI_LOCALMUX_CLK_Output_Select <= p->ai_localmux_clk_output_select (2) |
- * New pattern = 0x032E |
- */ |
- DAQ_STC_Windowed_Mode_Write(AI_OUTPUT_CONTROL,0x032E); |
- |
- /* |
- * Writing to register Joint_Reset_Register with address 72. |
- * AI_Configuration_Start <= 0 |
- * AI_Configuration_End <= 1 |
- * New pattern = 0x0100 |
- */ |
- DAQ_STC_Windowed_Mode_Write(JOINT_RESET,0x0100); |
- |
-/* |
-* access the first value in the configuration |
-* FIFO. |
-*/ |
- /* |
- * Writing to register AI_Command_1_Register with address 8. |
- * AI_CONVERT_Pulse <= 1 |
- * New pattern = 0x0001 |
- */ |
- DAQ_STC_Windowed_Mode_Write(AI_COMMAND_1,0x0001); |
- |
-/* |
-* setup for external hardware. |
-*/ |
- /* |
- * Writing to register Joint_Reset_Register with address 72. |
- * AI_Configuration_Start <= 1 |
- * New pattern = 0x0010 |
- */ |
- DAQ_STC_Windowed_Mode_Write(JOINT_RESET,0x0010); |
- |
- /* |
- * Writing to register AI_Mode_2_Register with address 13. |
- * AI_External_MUX_Present <= 0 |
- * New pattern = 0x0000 |
- */ |
- DAQ_STC_Windowed_Mode_Write(AI_MODE_2,0x0000); |
- |
- /* |
- * Writing to register AI_Output_Control_Register with address 60. |
- * AI_EXTMUX_CLK_Output_Select <= p->ai_extmux_clk_output_select (0) |
- * New pattern = 0x032E |
- */ |
- DAQ_STC_Windowed_Mode_Write(AI_OUTPUT_CONTROL,0x032E); |
- |
- /* |
- * Writing to register Joint_Reset_Register with address 72. |
- * AI_Configuration_Start <= 0 |
- * AI_Configuration_End <= 1 |
- * New pattern = 0x0100 |
- */ |
- DAQ_STC_Windowed_Mode_Write(JOINT_RESET,0x0100); |
- |
-/* |
-* enable or disable retriggering. |
-*/ |
- /* |
- * Writing to register Joint_Reset_Register with address 72. |
- * AI_Configuration_Start <= 1 |
- * New pattern = 0x0010 |
- */ |
- DAQ_STC_Windowed_Mode_Write(JOINT_RESET,0x0010); |
- |
- /* |
- * Writing to register AI_Mode_1_Register with address 12. |
- * AI_Trigger_Once <= 1 |
- * New pattern = 0x000D |
- */ |
- DAQ_STC_Windowed_Mode_Write(AI_MODE_1,0x000D); |
- |
- /* |
- * Writing to register AI_Trigger_Select_Register with address 63. |
- * AI_START1_Select <= 0 |
- * AI_START1_Polarity <= 0 |
- * AI_START1_Edge <= 1 |
- * AI_START1_Sync <= 1 |
- * New pattern = 0x0060 |
- */ |
- DAQ_STC_Windowed_Mode_Write(AI_TRIGGER_SELECT,0x0060); |
- |
- /* |
- * Writing to register Joint_Reset_Register with address 72. |
- * AI_Configuration_Start <= 0 |
- * AI_Configuration_End <= 1 |
- * New pattern = 0x0100 |
- */ |
- DAQ_STC_Windowed_Mode_Write(JOINT_RESET,0x0100); |
- |
-/* |
-* select the number of scans. |
-*/ |
-/* |
- * Writing to register Joint_Reset_Register with address 72. |
- * AI_Configuration_Start <= 1 |
- * New pattern = 0x0010 |
- */ |
- DAQ_STC_Windowed_Mode_Write(JOINT_RESET,0x0010); |
- |
- DAQ_STC_Windowed_Mode_Write(AI_MODE_1,0x000F); |
- |
- /* |
- * Writing to register Joint_Reset_Register with address 72. |
- * AI_Configuration_Start <= 0 |
- * AI_Configuration_End <= 1 |
- * New pattern = 0x0100 |
- */ |
- DAQ_STC_Windowed_Mode_Write(JOINT_RESET,0x0100); |
- |
-/* |
-* select the scan start event. |
-*/ |
- /* |
- * Writing to register Joint_Reset_Register with address 72. |
- * AI_Configuration_Start <= 1 |
- * New pattern = 0x0010 |
- */ |
- DAQ_STC_Windowed_Mode_Write(JOINT_RESET,0x0010); |
- |
- /* |
- * Writing to register AI_START_STOP_Select_Register with address 62. |
- * AI_START_Select <= 0 |
- * AI_START_Edge <= 1 |
- * AI_START_Sync <= 1 |
- * AI_START_Polarity <= 0 |
- * New pattern = 0x0060 |
- */ |
- DAQ_STC_Windowed_Mode_Write(AI_START_STOP_SELECT,0x0060); |
- |
- |
- /* |
- * Writing to register Joint_Reset_Register with address 72. |
- * AI_Configuration_Start <= 0 |
- * AI_Configuration_End <= 1 |
- * New pattern = 0x0100 |
- */ |
- DAQ_STC_Windowed_Mode_Write(JOINT_RESET,0x0100); |
- |
-/* |
-* select the end of scan event. |
-*/ |
- /* |
- * Writing to register Joint_Reset_Register with address 72. |
- * AI_Configuration_Start <= 1 |
- * New pattern = 0x0010 |
- */ |
- DAQ_STC_Windowed_Mode_Write(JOINT_RESET,0x0010); |
- |
- /* |
- * Writing to register AI_START_STOP_Select_Register with address 62. |
- * AI_STOP_Select <= p->ai_stop_select (19) |
- * AI_STOP_Edge <= 0 |
- * AI_STOP_Polarity <= p->ai_stop_polarity (0) |
- * AI_STOP_Sync <= 1 |
- * New pattern = 0x29E0 |
- */ |
- DAQ_STC_Windowed_Mode_Write(AI_START_STOP_SELECT,0x29E0); |
- |
- /* |
- * Writing to register Joint_Reset_Register with address 72. |
- * AI_Configuration_Start <= 0 |
- * AI_Configuration_End <= 1 |
- * New pattern = 0x0100 |
- */ |
- DAQ_STC_Windowed_Mode_Write(JOINT_RESET,0x0100); |
- |
-/* |
-* clear the AI FIFO. |
-*/ |
- /* |
- * Writing to register Write_Strobe_1_Register with address 83. |
- * Write_Strobe_1 <= 1 |
- * New pattern = 0x0001 |
- */ |
- DAQ_STC_Windowed_Mode_Write(WRITE_STROBE_1,0x0001); |
-return; |
-} |
- |
-/* |
-* Call this function to start the acquistion. |
-*/ |
- |
-void AI_Start_The_Acquisition() |
-{ |
- /* |
- * Writing to register AI_Command_1_Register with address 8. |
- * AI_CONVERT_Pulse <= 1 |
- * New pattern = 0x0001 |
- */ |
- DAQ_STC_Windowed_Mode_Write(AI_COMMAND_1,0x0001); |
- return; |
- } |
- |
-/*End of file: adc.c*/ |
- |
- |
- |
- |
- |
- |
- |
- |
Index: tags/rel_1_22/oscilloscopio/initosc.c |
=================================================================== |
--- tags/rel_1_22/oscilloscopio/initosc.c (revision 1310) |
+++ tags/rel_1_22/oscilloscopio/initosc.c (nonexistent) |
@@ -1,69 +0,0 @@ |
-/* |
-* Filename: Initosc.c |
-* Author: Ghiro Andrea, Franchino Gianluca |
-* Date: 09/03 |
-* Description: this file is for osc |
-*/ |
- |
-/* This file is part of the S.Ha.R.K. Project - http://shark.sssup.it |
- * |
- * Copyright (C) 2003 Ghiro Andrea Franchino Gianluca |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include <kernel/kern.h> |
-#include <modules/edf.h> |
-#include <modules/cbs.h> |
-#include <modules/rr.h> |
-#include <modules/hartport.h> |
-#include <modules/dummy.h> |
-#include <modules/sem.h> |
-#include <modules/srp.h> |
- |
-#include <drivers/keyb.h> |
- |
-#define TICK 1000 |
-#define RRTICK 5000 |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- EDF_register_level(EDF_ENABLE_ALL); |
- CBS_register_level(CBS_ENABLE_ALL, 0); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- |
- SRP_register_module(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- HARTPORT_init(); |
- KEYB_init(NULL); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
Index: tags/rel_1_22/oscilloscopio/readme.txt |
=================================================================== |
--- tags/rel_1_22/oscilloscopio/readme.txt (revision 1310) |
+++ tags/rel_1_22/oscilloscopio/readme.txt (nonexistent) |
@@ -1 +0,0 @@ |
-Verione con tutti i task periodici Hard |
Index: tags/rel_1_22/oscilloscopio/adc.h |
=================================================================== |
--- tags/rel_1_22/oscilloscopio/adc.h (revision 1310) |
+++ tags/rel_1_22/oscilloscopio/adc.h (nonexistent) |
@@ -1,48 +0,0 @@ |
-/***************************************************************************** |
-* Filename: ADC.H * |
-* Author: Ghiro Andrea,Franchino Gianluca * |
-* Date: 09/2003 * |
-* Description: Analog 2 digital conversion package header file * |
-*----------------------------------------------------------------------------* |
-* Notes: * |
-*****************************************************************************/ |
- |
-/* This file is part of the S.Ha.R.K. Project - http://shark.sssup.it |
- * |
- * Copyright (C) 2003 Ghiro Andrea,Franchino Gianluca |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
- |
-#ifndef _MY_ADC_H_ |
-#define _MY_ADC_H_ |
- |
-#include <drivers/pci6025e/pci6025e.h> |
-#include <drivers/pci6025e/regconst.h> |
-#include "ll/sys/cdefs.h" |
- |
-__BEGIN_DECLS |
- |
-//Analog input releted functions |
-void Configure_Board(BYTE); |
-void ADC_Init(void); |
-void AI_Start_The_Acquisition(void); |
- |
-__END_DECLS |
-#endif |
-/*End of file: adc.h*/ |
- |
Index: tags/rel_1_22/oscilloscopio/makefile |
=================================================================== |
--- tags/rel_1_22/oscilloscopio/makefile (revision 1310) |
+++ tags/rel_1_22/oscilloscopio/makefile (nonexistent) |
@@ -1,18 +0,0 @@ |
-# |
-# |
-# PCI6025E Examples and Test programs |
-# |
-# |
- |
-ifndef BASE |
-BASE=../.. |
-endif |
-include $(BASE)/config/config.mk |
- |
-PROGS= osc |
- |
-include $(BASE)/config/example.mk |
- |
-osc: |
- make -f $(SUBMAKE) APP=osc OTHEROBJS="initosc.o adc.o" SHARKOPT="__6025E__ __OLDCHAR__ __GRX__" |
- |
Index: tags/rel_1_22/oscilloscopio/osc.c |
=================================================================== |
--- tags/rel_1_22/oscilloscopio/osc.c (revision 1310) |
+++ tags/rel_1_22/oscilloscopio/osc.c (nonexistent) |
@@ -1,871 +0,0 @@ |
-/***************************************************************************** |
-* Filename: osc.c * |
-* Author: Ghiro Andrea,Franchino Gianluca * |
-* Date: 09/2003 * |
-* Description: Oscilloscope and function generator for PCI6025E * |
-*----------------------------------------------------------------------------* |
-* Notes: Connect DAC output pin (21) to ADC input pins (3-18) and * |
-* watch the waveforms. * |
-*****************************************************************************/ |
- |
-/* This file is part of the S.Ha.R.K. Project - http://shark.sssup.it |
- * |
- * Copyright (C) 2003 Ghiro Andrea,Franchino Gianluca |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
- |
-#include <drivers/glib.h> |
-#include <drivers/keyb.h> |
-#include <math.h> |
-#include <drivers/pci6025e/dac.h> |
-#include <modules/hartport.h> |
-#include <modules/srp.h> |
-#include "adc.h" |
- |
-#define MAX_VAL 500 |
-#define NUM_POINT 20 |
-#define GRAPH_PERIOD 50000 |
-#define GRAPH_WCET 2000 |
-#define WAVE_WCET 200 |
-#define OSC_WCET 200 |
-#define TASK_GROUP 1 |
-#define CHFREQ_PERIOD 5000 |
-#define CHFREQ_WCET 200 |
- |
-void drawInterface(void); |
-void endfun(KEY_EVT *); |
-void close_event(void *); |
-void createWaves(void); |
-void change_disp(KEY_EVT *); |
-void change_mode(KEY_EVT *); |
-void change_wave(KEY_EVT *); |
-void change_passo(KEY_EVT *); |
-void change_channel(KEY_EVT *); |
-void inc(KEY_EVT *); |
-void dec(KEY_EVT *); |
- |
-TASK video_body(int); |
-TASK wave_body(int); |
-TASK osc_body(int); |
-TASK chfreq_body(int); |
- |
-HARD_TASK_MODEL wave0; |
-HARD_TASK_MODEL chfreq; |
-HARD_TASK_MODEL osc; |
-SRP_RES_MODEL r; |
-SRP_mutexattr_t a; |
- |
-PID wave0_pid; |
-PID chfreq_pid; |
-PID osc_pid; |
- |
-mutex_t m1 ; |
- |
-int black = rgb16(0,0,0), |
- white = rgb16(255, 255, 255); |
- |
-int wave = 3, |
- varfun = 0, |
- varosc = 0, |
- flagch = 0, |
- channel = 0; |
- |
-float vfun = 0, |
- vosc = 2.5, |
- ffun = 1, |
- tbase = 75, |
- yr[MAX_VAL], |
- yrdac[NUM_POINT], |
- ys[MAX_VAL], |
- ysdac[NUM_POINT], |
- yq[MAX_VAL], |
- yqdac[NUM_POINT]; |
- |
-BYTE disp = 0, |
- modefun= 0, |
- modeosc= 0, |
- lib = 0, |
- sys = 0; |
- |
-short yoscold[MAX_VAL]; |
- |
-unsigned int period= 1e6/NUM_POINT; |
-unsigned int oscperiod = 1500; |
- |
-int main(int argc, char **argv) |
-{ |
- KEY_EVT k; |
- |
- HARD_TASK_MODEL video; |
- PID video_pid; |
- |
- int modenum; |
- |
- k.flag = CNTR_BIT; |
- k.scan = KEY_X; |
- k.ascii = 'x'; |
- keyb_hook(k, endfun); |
- |
- k.flag = CNTL_BIT; |
- keyb_hook(k, endfun); |
- |
- k.flag = 0; |
- k.scan = KEY_A; |
- k.ascii = 'a'; |
- keyb_hook(k, change_disp); |
- |
- k.flag = 0; |
- k.scan = KEY_S; |
- k.ascii = 's'; |
- keyb_hook(k, change_mode); |
- |
- k.flag = 0; |
- k.scan = KEY_F; |
- k.ascii = 'f'; |
- keyb_hook(k, change_wave); |
- |
- k.flag = 0; |
- k.scan = KEY_G; |
- k.ascii = 'g'; |
- keyb_hook(k, change_wave); |
- |
- k.flag = 0; |
- k.scan = KEY_H; |
- k.ascii = 'H'; |
- keyb_hook(k, change_wave); |
- |
- k.flag = 0; |
- k.scan = KEY_D; |
- k.ascii = 'd'; |
- keyb_hook(k, change_passo); |
- |
- k.flag = 0; |
- k.scan = KEY_J; |
- k.ascii = 'j'; |
- keyb_hook(k, change_channel); |
- |
- k.flag = 0; |
- k.scan = 78; |
- k.ascii = 43; |
- keyb_hook(k, inc); |
- |
- k.flag = 0; |
- k.scan = 74; |
- k.ascii = 45; |
- keyb_hook(k, dec); |
- |
- sys_atrunlevel(close_event, NULL, RUNLEVEL_BEFORE_EXIT); |
- |
- /*initialize the srp mutex*/ |
- SRP_mutexattr_default(a); |
- mutex_init(&m1,&a); |
- |
- hard_task_default_model(wave0); |
- hard_task_def_wcet(wave0, WAVE_WCET); |
- hard_task_def_mit(wave0, period); |
- hard_task_def_group(wave0, TASK_GROUP); |
- if( (wave0_pid = task_create("Wave 0", wave_body, &wave0, NULL)) == NIL ) |
- { |
- sys = 10; |
- sys_end(); |
- } |
- |
- hard_task_default_model(video); |
- hard_task_def_wcet(video, GRAPH_WCET); |
- hard_task_def_mit(video, GRAPH_PERIOD); |
- hard_task_def_group(video, TASK_GROUP); |
- SRP_res_default_model(r,2); |
- if( (video_pid = task_createn("Video task", video_body, &video, &r, |
- SRP_usemutex(&m1), NULL))== NIL ) |
- { |
- sys = 12; |
- sys_end(); |
- } |
- |
- hard_task_default_model(osc); |
- hard_task_def_wcet(osc, OSC_WCET); |
- hard_task_def_mit(osc, oscperiod); |
- hard_task_def_group(osc, TASK_GROUP); |
- SRP_res_default_model(r,1); |
- if((osc_pid = task_createn("osc task", osc_body, &osc, &r, |
- SRP_usemutex(&m1), NULL))== NIL ) |
- { |
- sys = 11; |
- sys_end(); |
- } |
- |
- hard_task_default_model(chfreq); |
- hard_task_def_wcet(chfreq, CHFREQ_WCET); |
- hard_task_def_mit(chfreq, CHFREQ_PERIOD); |
- hard_task_def_group(chfreq, TASK_GROUP); |
- if( (chfreq_pid = task_create("chfreq", chfreq_body, &chfreq, NULL)) == NIL ) |
- { |
- sys = 13; |
- sys_end(); |
- } |
- |
- if(grx_init() == -1) |
- { |
- sys = 30; |
- sys_end(); |
- } |
- |
- if((modenum = grx_getmode(800, 600, 16)) == -1) |
- { |
- sys = 31; |
- sys_end(); |
- } |
- |
- if(pci_init() == -1) |
- { |
- sys = 20; |
- sys_end(); |
- } |
- |
- if(!reMap()) |
- { |
- sys = 21; |
- sys_end(); |
- } |
- |
- grx_setmode(modenum); |
- |
- createWaves(); |
- drawInterface(); |
- |
- DAC_Init(); //Program the DAQ-STC AOTM |
- Configure_Board(channel); //Configure the board with the channel settings. |
- ADC_Init(); //Program the DAQ-STC AITM |
- |
- group_activate(TASK_GROUP); |
- |
- return 0; |
-} |
- |
-void endfun(KEY_EVT *k) |
-{ |
- sys_end(); |
-} |
- |
-void close_event(void *arg) |
-{ |
- grx_close(); |
- switch(sys) |
- { |
- case 0: cprintf("Regular End!\n"); break; |
- case 10: cprintf("Cannot create <wave 0> task!\n"); break; |
- case 11: cprintf("Cannot create <osc> task!\n"); break; |
- case 12: cprintf("Cannot create <video> task!\n"); break; |
- case 13: cprintf("Cannot create <chfreq> task!\n"); break; |
- case 14: cprintf("Cannot kill <wave 0> task!\n"); break; |
- case 15: cprintf("Cannot kill <osc> task\n");break; |
- case 20: cprintf("No PCI bus found!\n"); break; |
- case 21: cprintf("No NATIONAL PCI E-Series board found on PCI bus!\n");break; |
- case 30: cprintf("Cannot start graphic envirorment!\n"); break; |
- case 31: cprintf("800x600x16 video mode not supported!\n");break; |
- default: cprintf("Unknown exit event!\n"); break; |
- } |
-} |
- |
-/* |
-* kill wave0 or osc when frequency change |
-*/ |
- |
-TASK chfreq_body(int w) |
-{ |
- PORT p; |
- char msg[1]; |
- p = port_create("activation",1,1,STREAM,WRITE); |
- |
- while(1) |
- { |
- if(flagch == 1) |
- { |
- if(task_kill(wave0_pid)!=0) |
- { |
- sys=14; |
- sys_end(); |
- } |
- hard_task_def_mit(wave0, period); |
- if( (wave0_pid = task_create("wave 0", wave_body, &wave0, NULL))== NIL ) |
- { |
- sys = 10; |
- sys_end(); |
- } |
- flagch = 0; |
- task_activate(wave0_pid); |
- } |
- |
- if(flagch == 2) |
- { |
- if(task_kill(osc_pid)!=0) |
- { |
- sys=15; |
- sys_end(); |
- } |
- hard_task_def_mit(osc, oscperiod); |
- if( (osc_pid = task_createn("osc", osc_body, &osc, &r, |
- SRP_usemutex(&m1), NULL))== NIL ) |
- { |
- sys = 11; |
- sys_end(); |
- } |
- flagch = 0; |
- msg[0]=1; |
- port_send(p,msg,NON_BLOCK); |
- } |
- task_endcycle(); |
- } |
-} |
- |
-/* |
-* acquisition of input samples |
-*/ |
- |
-TASK osc_body(int wv) |
-{ |
- int i = 0 ; |
- short y = 0; |
- WORD Status = 0; |
- |
- while(1) |
- { |
- mutex_lock(&m1); |
- if(lib) |
- { |
- mutex_unlock(&m1); |
- AI_Start_The_Acquisition(); |
- do { |
- Status = DAQ_STC_Windowed_Mode_Read(AI_STATUS_1); |
- if (!( (Status & 0x1000) == 0x1000 ) ) |
- y = Immediate_Readw(ADC_DATA_READ); |
- } while(((Status & 0x1000) == 0x1000)); |
- y = (2.5/vosc)*(y-40)/20; |
- if(abs(y)<=100) |
- { |
- grx_plot(19+i,483-y,rgb16(255,255,0)); |
- } |
- yoscold[i]=y; |
- i=(i+1)%500; |
- if(i==0) |
- { |
- mutex_lock(&m1); |
- lib=0; |
- mutex_unlock(&m1); |
- task_testcancel(); |
- } |
- } |
- else mutex_unlock(&m1); |
- task_endcycle(); |
- } |
-} |
- |
-/* |
-* Sends out waves' samples |
-*/ |
- |
-TASK wave_body(int wv) |
-{ |
- int i = 0; |
- int y = 0; |
- while(1) |
- { |
- if(wave==0) |
- { |
- y=vfun*(yrdac[i]*20); |
- y=(y & 0x0FFF); |
- } |
- if(wave==1) |
- { |
- y=vfun*(ysdac[i]*20); |
- y=(y & 0x0FFF); |
- } |
- if(wave==2) |
- { |
- y=vfun*(yqdac[i]*20); |
- y=(y & 0x0FFF); |
- } |
- DAC_output(DAC1,y); |
- i = (i + 1) % NUM_POINT; |
- task_testcancel(); |
- task_endcycle(); |
- } |
-} |
- |
-/* |
-* Shows setting,wave,grid and clear display |
-*/ |
- |
-TASK video_body(int dummy) |
-{ |
- BYTE dispold = 1, |
- modefunold = 1, |
- modeoscold = 1, |
- new = 0; |
- |
- int waveold = 3, |
- varfunold = 2, |
- i = 0, |
- y = 0, |
- channelold = 16, |
- yold[MAX_VAL]; |
- |
- |
- float vfunold = 1, |
- voscold = 1, |
- ffunold = 0, |
- tbaseold = 1; |
- |
- char st[20]; |
- |
- PORT p; |
- char msg[1]; |
- p=port_connect("activation",1,STREAM,READ); |
- |
- while(1) |
- { |
- mutex_lock(&m1); |
- if(!lib) |
- { |
- mutex_unlock(&m1); |
- for(i=0;i<MAX_VAL;i++) |
- { |
- if(abs(yoscold[i])<=100) |
- { |
- grx_plot(19+i,483-yoscold[i],rgb16(0,0,0)); |
- } |
- } |
- //OSCILLOSCOPE GRID |
- grx_line(19, 385, 519, 385, rgb16(150,150,150)); |
- grx_line(19, 410, 519, 410, rgb16(150,150,150)); |
- grx_line(19, 435, 519, 435, rgb16(150,150,150)); |
- grx_line(19, 460, 519, 460, rgb16(150,150,150)); |
- grx_line(19, 485, 519, 485, rgb16(150,150,150)); |
- grx_line(19, 510, 519, 510, rgb16(150,150,150)); |
- grx_line(19, 535, 519, 535, rgb16(150,150,150)); |
- grx_line(19, 560, 519, 560, rgb16(150,150,150)); |
- grx_line(19, 585, 519, 585, rgb16(150,150,150)); |
- grx_line(19, 385, 19, 585, rgb16(150,150,150)); |
- grx_line(69, 385, 69, 585, rgb16(150,150,150)); |
- grx_line(119, 385, 119, 585, rgb16(150,150,150)); |
- grx_line(169, 385, 169, 585, rgb16(150,150,150)); |
- grx_line(219, 385, 219, 585, rgb16(150,150,150)); |
- grx_line(269, 385, 269, 585, rgb16(150,150,150)); |
- grx_line(319, 385, 319, 585, rgb16(150,150,150)); |
- grx_line(369, 385, 369, 585, rgb16(150,150,150)); |
- grx_line(419, 385, 419, 585, rgb16(150,150,150)); |
- grx_line(469, 385, 469, 585, rgb16(150,150,150)); |
- grx_line(519, 385, 519, 585, rgb16(150,150,150)); |
- mutex_lock(&m1); |
- lib=1; |
- mutex_unlock(&m1); |
- port_receive(p,msg,NON_BLOCK); |
- if(msg[0]==1) |
- { |
- task_activate(osc_pid); |
- } |
- } |
- else mutex_unlock(&m1); |
- if(disp != dispold) |
- { |
- dispold = disp; |
- grx_disc(780,120,10,rgb16(255*(1-disp),0,0)); |
- grx_disc(780,390,10,rgb16(0,255*disp,0)); |
- } |
- |
- if(modefun != modefunold) |
- { |
- modefunold = modefun; |
- grx_disc(780,237,5,rgb16(255*(1-modefun),0,0)); |
- grx_disc(780,267,5,rgb16(255*(modefun),0,0)); |
- } |
- |
- if(modeosc != modeoscold) |
- { |
- modeoscold = modeosc; |
- grx_disc(780,502,5,rgb16(0,255*(1-modeosc),0)); |
- grx_disc(780,532,5,rgb16(0,255*(modeosc),0)); |
- } |
- |
- if(wave != waveold) |
- { |
- waveold = wave; |
- grx_disc(730,127,3,rgb16(127*(1-wave)*(2-wave),0,0)); |
- grx_disc(730,142,3,rgb16(254*wave*(2-wave),0,0)); |
- grx_disc(730,157,3,rgb16(254*wave*(wave-1),0,0)); |
- new=1; |
- } |
- |
- if(varfun != varfunold) |
- { |
- varfunold = varfun; |
- grx_disc(675,292,3,rgb16(42*(1-varfun)*(2-varfun)*(3-varfun),0,0)); |
- grx_disc(775,292,3,rgb16(126*varfun*(2-varfun)*(3-varfun),0,0)); |
- grx_disc(675,307,3,rgb16(252*varfun*(varfun-1)*(3-varfun),0,0)); |
- grx_disc(775,307,3,rgb16(42*varfun*(varfun-1)*(varfun-2),0,0)); |
- } |
- |
- |
- if(channel != channelold) |
- { |
- sprintf(st,"%2d",channel); |
- grx_text(" ",660,470,black,white); |
- grx_text(st,660,470,black,white); |
- } |
- |
- if(ffun != ffunold) |
- { |
- ffunold = ffun; |
- sprintf(st,"%10f",ffun); |
- grx_text(" ",660,265,black,white); |
- grx_text(st,660,265,black,white); |
- } |
- |
- if(tbase != tbaseold) |
- { |
- tbaseold = tbase; |
- sprintf(st,"%10f",tbase); |
- grx_text(" ",660,530,black,white); |
- grx_text(st,660,530,black,white); |
- } |
- |
- if(vfun != vfunold) |
- { |
- vfunold = vfun; |
- sprintf(st,"%3.1f",vfun); |
- grx_text(" ",660,235,black,white); |
- grx_text(st,660,235,black,white); |
- new=1; |
- } |
- |
- if(vosc != voscold) |
- { |
- voscold = vosc; |
- sprintf(st,"%3.1f",vosc); |
- grx_text(" ",660,500,black,white); |
- grx_text(st,660,500,black,white); |
- } |
- |
- if(new) |
- { |
- for(i=0; i<MAX_VAL; i++) |
- { |
- grx_plot(19+i, 215-yold[i],rgb16(0, 0, 0)); |
- } |
- |
- //FUNCTION GENERATOR GRID |
- grx_line(22, 115, 525, 115, rgb16(150,150,150)); |
- grx_line(22, 165, 525, 165, rgb16(150,150,150)); |
- grx_line(22, 265, 525, 265, rgb16(150,150,150)); |
- grx_line(22, 315, 525, 315, rgb16(150,150,150)); |
- grx_line(19, 110, 19, 320, rgb16(150,150,150)); |
- grx_line(14, 215, 525, 215, rgb16(150,150,150)); |
- |
- if(wave==0) |
- { |
- for(i=0;i<MAX_VAL;i++) |
- { |
- y=(vfun)*yr[i]; |
- grx_plot(19+i,215-y,rgb16(255,255,0)); |
- yold[i]=y; |
- } |
- } |
- |
- if(wave==1) |
- { |
- for(i=0;i<MAX_VAL;i++) |
- { |
- y=(vfun)*ys[i]; |
- grx_plot(19+i,215-y,rgb16(255,255,0)); |
- yold[i]=y; |
- } |
- } |
- |
- if(wave==2) |
- { |
- for(i=0;i<MAX_VAL;i++) |
- { |
- y=(vfun)*yq[i]; |
- grx_plot(19+i,215-y,rgb16(255,255,0)); |
- yold[i]=y; |
- } |
- } |
- |
- new=0; |
- } |
- task_endcycle(); |
- } |
-} |
- |
-/* |
-* create wave triangular,sinusoidal and square |
-*/ |
- |
-void createWaves(void) |
-{ |
- float u=0, |
- qdac= 2*PI/NUM_POINT, |
- q = 2*PI/(MAX_VAL/2); |
- |
- register int i; |
- |
- BYTE direction=0; |
-/*create the vectors for the video task*/ |
- for(i=0;i<MAX_VAL/2;i++) |
- { |
- yr[i]=yr[i+MAX_VAL/2]=u/10; |
- if(!direction) u += 1.613; |
- else u -= 1.613; |
- if(u >= 100) direction = 1; |
- if(u <= -101) direction = 0; |
- |
- ys[i]=ys[i+MAX_VAL/2] = (sin(i*q)*10); |
- |
- if((i>=(MAX_VAL/4) && i< (MAX_VAL/2))) yq[i]=yq[i+MAX_VAL/2]=0; |
- else yq[i]=yq[i+MAX_VAL/2]=10; |
- } |
-/*create the vectors for the wave_body task*/ |
- direction=0; |
- u = 0; |
- for(i=0;i<NUM_POINT;i++) |
- { |
- yrdac[i]=u/10; |
- if(!direction) u += (400/NUM_POINT); |
- else u -= (400/NUM_POINT); |
- if(u >= 100) direction = 1; |
- if(u <= -100) direction = 0; |
- |
- ysdac[i]=(sin(i*qdac)*10); |
- |
- if((i>=(NUM_POINT/2) && i<NUM_POINT)) yqdac[i]=0; |
- else yqdac[i]=10; |
- } |
-} |
- |
-/* |
-* select device (0 function generator,1 oscilloscope) |
-*/ |
- |
-void change_disp(KEY_EVT *k) |
-{ |
- if(disp) disp = 0; |
- else disp = 1; |
-} |
- |
-/* |
-* select volt or frequency |
-*/ |
- |
-void change_mode(KEY_EVT *k) |
-{ |
- if(disp && modeosc) modeosc = 0; |
- else |
- if(disp && !modeosc) modeosc = 1; |
- else |
- if(!disp && modefun) modefun = 0; |
- else |
- if(!disp && !modefun) modefun =1; |
-} |
- |
-/* |
-* select wave (0 triangular,1 sinusoindal,2 square |
-*/ |
- |
-void change_wave(KEY_EVT *k) |
-{ |
- if(!disp && k->ascii =='f') |
- { |
- wave=0; |
- } |
- else |
- if(!disp && k->ascii =='g') |
- { |
- wave=1; |
- } |
- else |
- if(!disp && k->ascii =='h') |
- { |
- wave=2; |
- } |
-} |
- |
-/* |
-* select increase or decrease step |
-*/ |
- |
-void change_passo(KEY_EVT *k) |
-{ |
- if(!disp && modefun) |
- { |
- varfun=(varfun+1)%2; |
- } |
-} |
- |
-/* |
-* select input channel |
-*/ |
- |
-void change_channel(KEY_EVT *k) |
-{ |
- if(disp) |
- { |
- channel=(channel+1)%16; |
- Configure_Board(channel); |
- } |
-} |
- |
-/* |
-* increase selected variable |
-*/ |
- |
-void inc(KEY_EVT *k) |
-{ |
- if(disp && modeosc && tbase<300) |
- { |
- flagch=2; |
- switch(varosc) |
- { |
- case(0): tbase = tbase*2; |
- oscperiod=(tbase/50)*1000; |
- break; |
- } |
- } |
- else |
- if(disp && !modeosc && vosc<10) vosc += 0.1; |
- else |
- if(!disp && modefun && ffun<(1e6/(1020*NUM_POINT))-1) |
- { |
- flagch=1; |
- switch(varfun) |
- { |
- case(0): ffun += 1; |
- period = 1e6/(NUM_POINT*ffun); |
- break; |
- case(1): ffun += 10; |
- period = 1e6/(NUM_POINT*ffun); |
- break; |
- } |
- } |
- else |
- if(!disp && !modefun && vfun<10) vfun += 0.1; |
-} |
- |
-/* |
-* decrease selected variable |
-*/ |
- |
-void dec(KEY_EVT *k) |
-{ |
- if(disp && modeosc && tbase> 75) |
- { |
- flagch=2; |
- switch(varosc) |
- { |
- case(0): tbase = tbase/2; |
- oscperiod=(tbase/50)*1000; |
- break; |
- } |
- } |
- else |
- if(disp && !modeosc && vosc> 0.2) vosc -= 0.1; |
- else |
- if(!disp && modefun && ffun> 0) |
- { |
- flagch = 1; |
- switch(varfun) |
- { |
- case(0): ffun -= 1; |
- if(ffun == 0) period =1e6; |
- else |
- period = 1e6/(NUM_POINT*ffun); |
- break; |
- case(1): ffun -= 10; |
- if(ffun == 0) period =1e6; |
- else |
- period = 1e6/(NUM_POINT*ffun); |
- break; |
- } |
- } |
- else |
- if(!disp && !modefun && vfun> -10) vfun -= 0.1; |
-} |
- |
-/* |
-* draw interface |
-*/ |
- |
-void drawInterface(void) |
-{ |
- //TITLE |
- grx_rect(1, 1, 799, 69, rgb16(105, 0, 105)); |
- grx_rect(2, 2, 798, 68, rgb16(155, 0, 155)); |
- grx_rect(3, 3, 797, 67, rgb16(205, 0, 205)); |
- grx_rect(4, 4, 796, 66, rgb16(255, 0, 255)); |
- grx_text("Oscilloscope and function generator for PCI6025E",7, 10, rgb16(50, 255, 50), black); |
- grx_text("Pin ADC 3-18, DAC 21",7, 25, rgb16(0, 255, 255), black); |
- grx_text("A for select Oscilloscope or Function generator",7, 40, rgb16(0, 255, 255), black); |
- grx_text("CTRL-X for Exit", 7, 55, rgb16(200, 200, 0), black); |
- |
- //FUNCTION GENERATOR |
- grx_text("FUNCTION GENERATOR", 100, 92, rgb16(200, 200, 0), black); |
- grx_rect(1, 100, 549, 325, rgb16(0, 105, 0)); |
- grx_rect(2, 101, 548, 324, rgb16(0, 155, 0)); |
- grx_rect(3, 102, 547, 323, rgb16(0, 205, 0)); |
- grx_rect(4, 103, 546, 322, rgb16(0, 255, 0)); |
- grx_rect(579, 100, 799, 325, rgb16(0, 105, 0)); |
- grx_rect(580, 101, 798, 324, rgb16(0, 155, 0)); |
- grx_rect(581, 102, 797, 323, rgb16(0, 205, 0)); |
- grx_rect(582, 103, 796, 322, rgb16(0, 255, 0)); |
- grx_text("Wave selection",589,110,rgb16(0, 255, 0), black); |
- grx_text("f -->triangular",589,125,rgb16(200, 200, 0), black); |
- grx_text("g -->sin",589,140,rgb16(200, 200, 0), black); |
- grx_text("h -->square",589,155,rgb16(200, 200, 0), black); |
- grx_text("s -->select volt/freq",589,180,rgb16(200, 200, 0), black); |
- grx_text("+/- -->set volt/freq",589,195,rgb16(200, 200, 0), black); |
- grx_text("d -->frequency increase",589,210,rgb16(200, 200, 0),black); |
- grx_text("Vpicco V",589,235,rgb16(0, 255, 0),black); |
- grx_text("Freq Hz",589,265,rgb16(0, 255, 0),black); |
- grx_text("+/- 1 Hz",589,290,rgb16(0, 255, 0),black); |
- grx_text("+/- 10 HZ",689,290,rgb16(0, 255, 0),black); |
- |
- //OSCILLOSCOPE |
- grx_text("OSCILLOSCOPE", 100, 362, rgb16(200, 200, 0), black); |
- grx_rect(1, 370, 549, 595, rgb16(105, 0, 0)); |
- grx_rect(2, 371, 548, 594, rgb16(155, 0, 0)); |
- grx_rect(3, 372, 547, 593, rgb16(205, 0, 0)); |
- grx_rect(4, 373, 546, 592, rgb16(255, 0, 0)); |
- grx_rect(579, 370, 799, 595, rgb16(105, 0, 0)); |
- grx_rect(580, 371, 798, 594, rgb16(155, 0, 0)); |
- grx_rect(581, 372, 797, 593, rgb16(205, 0, 0)); |
- grx_rect(582, 373, 796, 592, rgb16(255, 0, 0)); |
- grx_text("Scale selection",589,380,rgb16(255, 0, 0), black); |
- grx_text("s -->select volt/freq",589,400,rgb16(200, 200, 0), black); |
- grx_text("+/- -->set volt/freq",589,415,rgb16(200, 200, 0), black); |
- grx_text("j -->change channel",589,430,rgb16(200, 200, 0),black); |
- grx_text("Channel",589,470,rgb16(255, 0, 0),black); |
- grx_text("Volt/div V",589,500,rgb16(255, 0, 0),black); |
- grx_text("Time/div ms",589,530,rgb16(255, 0, 0),black); |
- |
- //LABEL |
- grx_text("0 V", 555, 211, rgb16(0, 255, 0), black); |
- grx_text("+10", 555, 111, rgb16(0, 255, 0), black); |
- grx_text("+5", 555, 161, rgb16(0, 255, 0), black); |
- grx_text("-5", 555, 261, rgb16(0, 255, 0), black); |
- grx_text("-10", 555, 311, rgb16(0, 255 , 0), black); |
- grx_text("0 V", 555, 481, rgb16(255, 0, 0), black); |
-} |
Index: tags/rel_1_22/bttvdemo/makefile |
=================================================================== |
--- tags/rel_1_22/bttvdemo/makefile (revision 1310) |
+++ tags/rel_1_22/bttvdemo/makefile (nonexistent) |
@@ -1,16 +0,0 @@ |
-# |
-# |
-# |
- |
-ifndef BASE |
-BASE=../.. |
-endif |
-include $(BASE)/config/config.mk |
- |
-PROGS = bttv |
- |
-include $(BASE)/config/example.mk |
- |
-bttv: |
- make -f $(SUBMAKE) APP=bttv INIT= OTHEROBJS="initfile.o" OTHERINCL= SHARKOPT="__OLDCHAR__ __GRX__ __BTTV__" |
- |
Index: tags/rel_1_22/bttvdemo/bttv.c |
=================================================================== |
--- tags/rel_1_22/bttvdemo/bttv.c (revision 1310) |
+++ tags/rel_1_22/bttvdemo/bttv.c (nonexistent) |
@@ -1,153 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Giacomo Guidi <giacomo@gandalf.sssup.it> |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2003 Giacomo Guidi |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- */ |
- |
-#include "kernel/kern.h" |
-#include <drivers/fg.h> |
-#include <drivers/glib.h> |
-#include <drivers/keyb.h> |
-#include <unistd.h> |
-#include <stdlib.h> |
- |
-#define WIDTH 640 |
-#define HEIGHT 480 |
-#define BYTES_PP 2 |
- |
-unsigned char *video_buf = NULL; //Video Buffer |
-unsigned long int VMEMLONG = WIDTH * HEIGHT * BYTES_PP / 4; // Used by copy_videomem_16to16 |
-unsigned long int RGB565MEM = WIDTH * HEIGHT * BYTES_PP; // Total video mem |
- |
-#define FG_PERIOD 40000 |
-#define FG_WCET 30000 |
-#define FG_W 320 |
-#define FG_H 200 |
- |
-unsigned int color = FG_MONO; |
- |
-extern DWORD flbaddr; |
- |
-static void screen() |
-{ |
- |
- /* graphic card Initialization */ |
- if (grx_init() < 1) { |
- sys_abort(1); |
- } |
- |
- if (grx_open(640, 480, 16) < 0) { |
- cprintf("GRX Err\n"); |
- sys_abort(1); |
- } |
- |
- video_buf = (unsigned char *)flbaddr; |
- |
-} |
- |
-void program_end(void *arg) |
-{ |
- |
- grx_close(); |
- |
- sys_end(); |
- |
-} |
- |
-void elaborate_image(void *imageptr) |
-{ |
- |
- WORD x,y; |
- BYTE *col; |
- |
- if (color == FG_MONO) { |
- |
- for(y = 0; y < FG_H; y++) |
- for(x = 0; x < FG_W; x++) { |
- |
- col = (BYTE *)(imageptr + y*FG_W + x); |
- *(WORD *)(video_buf + y*(WIDTH*2) + (x*2)) = (WORD)rgb16(*(BYTE *)(col),*(BYTE *)(col),*(BYTE *)(col)); |
- |
- } |
- |
- } |
- |
- if (color == FG_RGB24) { |
- |
- for(y = 0; y < FG_H; y++) |
- for(x = 0; x < FG_W; x++) { |
- |
- col = (BYTE *)(imageptr + y*(FG_W*3) + (x*3)); |
- *(WORD *)(video_buf + y*(WIDTH*2) + (x*2)) = (WORD)rgb16(*(BYTE *)(col),*(BYTE *)(col+1),*(BYTE *)(col+2)); |
- |
- } |
- |
- } |
- |
- //printf_xy(0,0,WHITE,"Grabbed = %08lx",*(DWORD *)(imageptr + 50*FG_W + 50)); |
- //printf_xy(0,1,WHITE,"Grabbed = %08lx",*(DWORD *)(imageptr + 51*FG_W + 50)); |
- |
-} |
- |
-int main(int argc, char **argv) |
-{ |
- |
- int channel = 0; |
- |
- if (argc < 2) { |
- channel = 0; |
- } else { |
- channel = atoi(argv[1]); |
- } |
- |
- sys_atrunlevel(program_end,NULL, RUNLEVEL_BEFORE_EXIT); |
- |
- screen(); |
- //video_buf = malloc(RGB565MEM); |
- |
- sleep(1); |
- |
- FG_init(FG_PERIOD, FG_WCET, FG_W, FG_H, color, channel); |
- |
- FG_set_hook(elaborate_image); |
- |
- FG_start_grabbing(); |
- |
- while(keyb_getch(BLOCK) != ESC); |
- |
- FG_close(); |
- |
- sys_end(); |
- |
- return 0; |
- |
-} |
Index: tags/rel_1_22/bttvdemo/initfile.c |
=================================================================== |
--- tags/rel_1_22/bttvdemo/initfile.c (revision 1310) |
+++ tags/rel_1_22/bttvdemo/initfile.c (nonexistent) |
@@ -1,120 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- ------------ |
- CVS : $Id: initfile.c,v 1.1 2003-05-22 14:12:29 giacomo Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1 $ |
- Last update: $Date: 2003-05-22 14:12:29 $ |
- ------------ |
- |
- System initialization file |
- |
- This file contains the 2 functions needed to initialize the system. |
- |
- These functions register the following levels: |
- |
- an EDF (Earliest Deadline First) level |
- a RR (Round Robin) level |
- a CBS (Costant Bandwidth Server) level |
- a Dummy level |
- |
- It can accept these task models: |
- |
- HARD_TASK_MODEL (wcet+mit) at level 0 |
- SOFT_TASK_MODEL (met, period) at level 1 |
- NRT_TASK_MODEL at level 2 |
- |
- This file is similar to the configuration of kernel/init/hartik3.c |
- |
- TICK is set to 0 (one-shot timer is used) |
-*/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/cbs.h" |
-#include "modules/rr.h" |
-#include "modules/dummy.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
- |
-#include "drivers/keyb.h" |
- |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 1000 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 10000 |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- EDF_register_level(EDF_ENABLE_ALL); |
- CBS_register_level(CBS_ENABLE_ALL, 0); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- |
- CABS_register_module(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- KEYB_PARMS kparms = BASE_KEYB; |
- |
- HARTPORT_init(); |
- |
- keyb_def_ctrlC(kparms, NULL); |
- keyb_def_map(kparms,itaMap); |
- KEYB_init(&kparms); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
Index: tags/rel_1_22/bttvdemo/readme.txt |
=================================================================== |
--- tags/rel_1_22/bttvdemo/readme.txt (revision 1310) |
+++ tags/rel_1_22/bttvdemo/readme.txt (nonexistent) |
@@ -1,38 +0,0 @@ |
--------------------------------------- |
-BTTV Frame Grabber Demo |
- |
-by |
- |
-Giacomo Guidi <giacomo@gandalf.sssup.it> |
- |
-Last update 27/05/2003 |
--------------------------------------- |
-Ex: |
- |
-x bttv [channel number] |
- |
-if the channel is not specified 0 is taken. |
-If you don't see a grabbed image, you |
-can try to set a channel number from 1 to 4. |
- |
-This is a simple demo for the BTTV driver. |
-It starts the frame grabber at 25 fps 320x200. |
-The GRX driver is used to |
-visualize the grabbed images. |
- |
-See also drivers/bttv/readme |
- |
-drivers/bttv/fgman-it.txt is the |
-italian manual |
- |
--------------------------------------- |
- |
-The demo is composed by: |
- |
-MAKEFILE The makefile used to compile the application |
-README.TXT This file |
-INITFILE.C The init file |
-BTTV.C The BTTV Demo |
- |
--------------------------------------- |
- |
Index: tags/rel_1_22/parport/readme.txt |
=================================================================== |
--- tags/rel_1_22/parport/readme.txt (revision 1310) |
+++ tags/rel_1_22/parport/readme.txt (nonexistent) |
@@ -1,27 +0,0 @@ |
-Hi, |
- |
-This directory contains a small demo that uses the Shark Parallel Port driver. |
- |
-Full documentation is available on the Shark Web Page. |
- |
-PJ |
- |
-PS: The following text is the original text made by the authors. |
------------------------------------------------------------------------------- |
- |
-Universita' degli Studi di Pavia |
-Facoltà di Ingegneria |
-Dipartimento di Informatica e Sistemistica |
- |
-------------------------------------------------------------- |
- PARALLEL PORT SHARK PROJECT |
- COMUNICAZIONE TRA PERSONAL COMPUTER TRAMITE PORTA PARALLELA |
-------------------------------------------------------------- |
-Corso: Informatica Industriale - A.A. 2001/2002 |
-Docente: Prof. Giorgio Buttazzo |
-Responsabili: Prof. Giorgio Buttazzo - Ing. Paolo Gai |
- |
-Progetto: Parallel Port Shark Project |
-Autori: Andrea Battistotti, Armando Leggio |
- |
-(C) Copyright 2002 Andrea Battistotti & Armando Leggio |
Index: tags/rel_1_22/parport/makefile |
=================================================================== |
--- tags/rel_1_22/parport/makefile (revision 1310) |
+++ tags/rel_1_22/parport/makefile (nonexistent) |
@@ -1,16 +0,0 @@ |
-# |
-# |
-# |
- |
-ifndef BASE |
-BASE=../.. |
-endif |
-include $(BASE)/config/config.mk |
- |
-PROGS= ppdemo |
- |
-include $(BASE)/config/example.mk |
- |
-ppdemo: |
- make -f $(SUBMAKE) APP=ppdemo INIT= OTHEROBJS="initfile.o" OTHERINCL= SHARKOPT="__OLDCHAR__ __PPORT__ __GRX__" |
- |
Index: tags/rel_1_22/parport/initfile.c |
=================================================================== |
--- tags/rel_1_22/parport/initfile.c (revision 1310) |
+++ tags/rel_1_22/parport/initfile.c (nonexistent) |
@@ -1,120 +0,0 @@ |
-/* |
- * |
- * Project: |
- * Parallel Port S.Ha.R.K. Project |
- * |
- * Module: |
- * Initfile.c |
- * |
- * Description: |
- * System initialization file |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors: |
- * Andrea Battistotti <btandrea@libero.it> |
- * Armando Leggio <a_leggio@hotmail.com> |
- * |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- * |
- |
- |
- System initialization file |
- |
- This file contains the 2 functions needed to initialize the system. |
- |
- These functions register the following levels: |
- |
- an EDF (Earliest Deadline First) level |
- a RR (Round Robin) level |
- a CBS (Costant Bandwidth Server) level |
- a Dummy level |
- |
- It can accept these task models: |
- |
- HARD_TASK_MODEL (wcet+mit) at level 0 |
- SOFT_TASK_MODEL (met, period) at level 1 |
- NRT_TASK_MODEL at level 2 |
- |
- This file is similar to the configuration of kernel/init/hartik3.c |
- |
- TICK is set to 0 (one-shot timer is used) |
-*/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/cbs.h" |
-#include "modules/rr.h" |
-#include "modules/dummy.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
- |
-#include "drivers/keyb.h" |
- |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 0 |
-/* #define TICK 100 */ |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 10000 |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- EDF_register_level(EDF_ENABLE_ALL); |
- CBS_register_level(CBS_ENABLE_ALL, 0); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- |
- CABS_register_module(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- KEYB_PARMS kparms = BASE_KEYB; |
- |
- HARTPORT_init(); |
- |
- keyb_def_ctrlC(kparms, NULL); |
- keyb_def_map(kparms,itaMap); |
- KEYB_init(&kparms); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
Index: tags/rel_1_22/parport/ppdemo.c |
=================================================================== |
--- tags/rel_1_22/parport/ppdemo.c (revision 1310) |
+++ tags/rel_1_22/parport/ppdemo.c (nonexistent) |
@@ -1,495 +0,0 @@ |
-/* |
- * |
- * Project: |
- * Parallel Port S.Ha.R.K. Project |
- * |
- * Module: |
- * ppDemo.c |
- * |
- * Description: |
- * file contents description |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors: |
- * Andrea Battistotti <btandrea@libero.it> |
- * Armando Leggio <a_leggio@hotmail.com> |
- * |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- * |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: ppdemo.c,v 1.3 2003-03-24 11:18:19 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.3 $ |
- Last update: $Date: 2003-03-24 11:18:19 $ |
- ------------ |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai and Giorgio Buttazzo |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-/****************************************************************/ |
-/* PERIODIC PROCESS TEST */ |
-/****************************************************************/ |
- |
- |
-#include <drivers/parport.h> |
-#include <drivers/keyb.h> |
-#include <drivers/glib.h> |
- |
-#define TSK_PERIOD 250000 /*400000 ok for debug...*/ |
-#define TSK_WCET 70000 |
- |
- |
-#define YMENU 10 /* menu level */ |
-#define XMIN 10 |
-#define XMAX 630 |
-#define YMIN 10 |
-#define YMAX 470 |
-#define ESC 27 /* ASCII code of ESCAPE key */ |
-#define X0 |
-#define GRXWND_COLS 33 |
-#define GRXWND_LINS 15 |
- |
- |
- |
-void ppInitGrxWnd(void) |
-{ |
- /* graphic preparation */ |
- /* graphic card Initialization */ |
- if (grx_init() < 1) { |
- sys_abort(1); |
- } |
- |
- if (grx_open(640, 480, 8) < 0) { |
- kern_printf("GRX Err\n"); |
- sys_abort(1); |
- } |
- kern_printf("Video card ok!\n"); |
- /* The scenario */ |
- |
- // Background |
- grx_clear(6); |
- |
- // Frame |
- grx_rect(XMIN-1, YMIN-1, XMAX+1, YMAX+1, 0); |
- |
- // Window 1 |
- grx_box(XMIN+14,YMIN+14,XMAX-317,YMAX-235,7); //window |
- grx_box(XMIN+17,YMIN+17,XMAX-320,YMAX-427,1); //bar |
- grx_box(XMIN+17,YMIN+42,XMAX- 320,YMAX-238,0); //workspace |
- grx_box(XMIN+286,YMIN+19,XMAX-322,YMAX-429,7);//button |
- grx_text("PPDemo", XMIN+30, YMIN+21, 15, 1); //title |
- grx_text("**********************************", XMIN+25, YMIN+55, 10, 0); |
- grx_text("* PARALLEL PORT DEMONSTRATION *", XMIN+25, YMIN+70, 10, 0); |
- grx_text("**********************************", XMIN+25, YMIN+85, 10, 0); |
- grx_text("Press ALT X to exit", XMIN+25, YMIN+115, 10, 0); |
- grx_text("other keys to communicate with", XMIN+25, YMIN+130, 10, 0); |
- grx_text("remote terminal", XMIN+25, YMIN+145, 10, 0); |
- grx_text("(c) Copyright 2002", XMIN+25, YMIN+190, 10, 0); |
- grx_text("Andrea Battistotti, Armando Leggio", XMIN+25, YMIN+205, 10, 0); |
- |
- // Window 2 |
- grx_box(XMIN+317,YMIN+14,XMAX-14,YMAX-235,7); |
- grx_box(XMIN+320,YMIN+17,XMAX-17,YMAX-427,1); |
- grx_box(XMIN+320,YMIN+42,XMAX-17,YMAX-238,0); |
- grx_box(XMIN+589,YMIN+19,XMAX-19,YMAX-429,7); |
- grx_text("Statistics", XMIN+333, YMIN+21, 15, 1); |
- |
-} |
- |
- |
-void ppInitGrxWnd_b(void) |
-{ |
- // Window 3 |
- grx_box(XMIN+14,YMIN+243,XMAX-317,YMAX-6,7); |
- grx_box(XMIN+17,YMIN+246,XMAX-320,YMAX-198,1); |
- grx_box(XMIN+17,YMIN+271,XMAX-320,YMAX-9,0); |
- grx_box(XMIN+286,YMIN+248,XMAX-322,YMAX-200,7); |
- grx_text("Local Terminal", XMIN+30, YMIN+250, 15, 1); |
- |
- // Window 4 |
- grx_box(XMIN+317,YMIN+243,XMAX-14,YMAX-6,7); |
- grx_box(XMIN+320,YMIN+246,XMAX-17,YMAX-198,1); |
- grx_box(XMIN+320,YMIN+271,XMAX-17,YMAX-9,0); |
- grx_box(XMIN+589,YMIN+248,XMAX-19,YMAX-200,7); |
- grx_text("Remote Terminal", XMIN+333, YMIN+250, 15, 1); |
- |
-} |
- |
- |
-void ppGrxWnd2(char *c) /* sys msg wind */ |
-{ |
- static int i,j; |
- static char sysmsg[GRXWND_LINS+1][GRXWND_COLS+1]; |
- char s[2]; |
- |
- s[1]='\0'; |
- |
- |
- while ((s[0]=*c++)) // *c != 0 |
- { |
- sysmsg[i][j]=s[0] ; |
- switch (s[0]) |
- { |
- case '\r': case '\n': |
- j=0;i++; |
- break; |
- |
- case '\b': |
- if (j>0) |
- { |
- j--;s[0]=' '; |
- grx_text(s, XMIN+330+8*j, YMIN+49+10*i,10,0); |
- //statistics grx_text(s, XMIN+330+8*j, YMIN+49+10*i,10,0); |
- //statistics |
- } |
- break; |
- |
- default: |
- grx_text(s, XMIN+330+8*j, YMIN+49+10*i,10,0); //statistics |
- j++; |
- break; |
- |
- } |
- if (j>=GRXWND_COLS) |
- {i++; |
- j=0;} |
- if (i>=GRXWND_LINS) { |
- s[0]=' '; |
- for (i=0;i<GRXWND_LINS;i++){ |
- for (j=0;j<GRXWND_COLS;j++){ |
- grx_text(s, XMIN+330+8*j, YMIN+49+10*i,10,0); //statistics |
- }; |
- }; |
- i=0; j=0; |
- }; |
- } // end while |
-} |
- |
- |
-void ppGrxWnd3(char c) |
-{ |
- static int i,j; |
- char talk[GRXWND_LINS+1][GRXWND_COLS+1]; |
- char s[2]; |
- s[1]='\0'; |
- |
- talk[i][j]=c; |
- s[0] = c; |
- switch (c) |
- { |
- case '\r': case '\n': |
- j=0;i++; |
- break; |
- |
- |
- case '\b': |
- if (j>0) |
- { |
- j--;s[0]=' '; |
- grx_text(s, XMIN+27+8*j, YMIN+278+10*i,10,0); //local term |
- |
- } |
- break; |
- |
- default: |
- grx_text(s, XMIN+27+8*j, YMIN+278+10*i,10,0); //local term |
- j++; |
- break; |
- |
- } |
- if(j==GRXWND_COLS) {i++; j=0;}; |
- if(i==GRXWND_LINS) { |
- s[0]=' '; |
- for (i=0;i<GRXWND_LINS;i++){ |
- for (j=0;j<GRXWND_COLS;j++){ |
- grx_text(s, XMIN+27+8*j, YMIN+278+10*i,10,0); //local term |
- }; |
- }; |
- i=0; j=0; |
- } |
-} |
- |
- |
-void ppGrxWnd4(char c) |
-{ |
- static int i,j; |
- char talk[GRXWND_LINS][GRXWND_COLS]; |
- char s[2]; |
- s[1]='\0'; |
- |
- talk[i][j]=c; |
- s[0] = c; |
- switch (c) |
- { |
- case '\r': case '\n': |
- j=0;i++;break; |
- |
- case '\b': |
- if (j>0) |
- { |
- j--;s[0]=' '; |
- grx_text(s, XMIN+330+8*j, YMIN+278+10*i,10,0); //remote term |
- } |
- break; |
- default: |
- grx_text(s, XMIN+330+8*j, YMIN+278+10*i,10,0); //remote term |
- j++; |
- break; |
- } |
- |
- if(j==GRXWND_COLS) {i++; j=0;} |
- if(i==GRXWND_LINS) { |
- s[0]=' '; |
- for (i=0;i<GRXWND_LINS;i++){ |
- for (j=0;j<GRXWND_COLS;j++){ |
- grx_text(s, XMIN+330+8*j, YMIN+278+10*i,10,0); //remote term |
- }; |
- }; |
- i=0; j=0; |
- } |
-} |
- |
- |
-/***************************************************************/ |
- |
-TASK ppChat(void *arg) |
-{ |
- char sysmsg[SYS_MSG_COLS+1]; |
- long xposTx; |
- KEY_EVT k; |
- BYTE b; |
- |
- |
- k.ascii = 0; |
- xposTx=9430 ; // any 16 bit test value... |
- |
- task_endcycle(); |
- |
- while (1) { |
-#if PP_DEBUG == 1 |
- //kern_printf("ppchat \n"); |
-#endif |
- /* read char buffer */ |
- if (keyb_getcode(&k,NON_BLOCK)) |
- { |
- /* if any send it to ppDrv ...*/ |
- b=k.ascii; |
-#if PP_DEBUG == 1 |
- kern_printf("Send char: %i , %c \n",b,b); |
-#endif |
- //kern_printf("--- Transmit value for xposTx: %d \n",xposTx); |
- //ppTxBytes( (BYTE *) &xposTx, sizeof(xposTx) ); |
- ppGrxWnd3(b); |
- ppTxOneByte(b); |
- } |
- |
- if (ppRxOneByte(&b)==PP_COMM_OK) |
- //if (ppRxBytes((BYTE *) &xposRx, sizeof(xposRx))==PP_COMM_OK) |
- { |
- ppGrxWnd4(b); |
- //kern_printf("%c",b); |
- //kern_printf("--- Received value for xposRx: %d \n", xposRx); |
- } |
- |
- if (ppReadSysMsg(sysmsg)==PP_SYSMSG_OK) ppGrxWnd2(sysmsg); |
- |
- |
- /* ..and show it in upper screen..*/ |
- |
- task_endcycle(); |
- } |
-} |
- |
- |
-/****************************************************************/ |
- |
-/* This function is called when Alt-X is pressed. |
- It simply shutdown the system using sys_end. |
- Note that the byebye() function is called only if we exit from |
- the system using sys_end()!!!! |
-*/ |
-void my_end(KEY_EVT* e) |
-{ |
- |
- sys_end(); |
-} |
- |
-/******************************************************************/ |
- |
-/* This function is called when the system exit correctly after Alt-X. |
- It exits from the graphic mode and then it prints a small greeting. |
- Note that: |
- - The function calls grx_exit, so it must be registered using |
- RUNLEVEL_BEFORE_EXIT (RUNLEVEL_AFTER_EXIT does not work because |
- at that point the kernel is already returned in real mode!!!) |
- - When an exception is raised, the exception handler is called. |
- Since the exception handler already exits from the graphic mode, |
- this funcion has not to be called. For this reason: |
- . we registered byebye using the flag NO_AT_ABORT |
- . the exception handler exits using sys_abort; in that way byebye is |
- NOT called |
-*/ |
- |
-void byebye(void *arg) |
-{ |
- grx_close(); |
- kern_printf("Bye Bye!\n"); |
-} |
- |
-/****************************** MAIN ******************************/ |
- |
-int main(int argc, char **argv) |
-{ |
- PID pid2, pid; |
- KEY_EVT emerg; |
- |
- HARD_TASK_MODEL m2; |
- SOFT_TASK_MODEL mp; |
- |
- /* Set the closing function */ |
- sys_atrunlevel(byebye, NULL, RUNLEVEL_BEFORE_EXIT); |
- |
- |
- |
- |
- keyb_set_map(itaMap); |
- /* set the keyboard handler to exit correctly */ |
- emerg.ascii = 'x'; |
- emerg.scan = KEY_X; |
- emerg.flag = ALTL_BIT; |
- keyb_hook(emerg,my_end); |
- |
- emerg.ascii = 'x'; |
- emerg.scan = KEY_X; |
- emerg.flag = ALTR_BIT; |
- keyb_hook(emerg,my_end); |
- |
- /* a small banner */ |
- kern_printf("ppChat Demo\n"); |
- kern_printf("Press Alt-X to exit\n"); |
- |
- /* graphics */ |
- ppInitGrxWnd(); |
- |
- |
- /* graphic card Initialization */ |
- //kern_printf("Video card ok!\n"); |
- |
- |
- |
- /* ppDrv creation */ |
- ppGrxWnd2("Initing Drv...\n"); |
- ppInitDrv(ppGrxWnd2); /* pass output fnc for init debug...*/ |
- |
- ppInitGrxWnd_b(); |
- |
- |
- /* MODEL TASK EXAMPLES */ |
- soft_task_default_model(mp); |
- soft_task_def_level(mp,1); |
- soft_task_def_ctrl_jet(mp); |
- soft_task_def_arg(mp, (void *)0); |
- soft_task_def_group(mp, 1); |
- soft_task_def_met(mp, PPDRV_WCET); |
- soft_task_def_period(mp,PPDRV_PERIOD); |
- soft_task_def_usemath(mp); |
- pid = task_create("ppDrv", ppPollingSvr, &mp, NULL); |
- if (pid != NIL) task_activate(pid); |
- /**/ |
- |
- //hard_task_default_model(m1); |
- //hard_task_def_ctrl_jet (m1); |
- //hard_task_def_arg (m1, (void *)0); |
- //hard_task_def_wcet (m1, PPDRV_WCET); |
- //hard_task_def_mit (m1, PPDRV_PERIOD); |
- //hard_task_def_group (m1,1); |
- //pid1 = task_create("ppDrv", ppPollingSvr, &m1, NULL); |
- //if (pid1 == NIL) {/*grx_close();*/ perror("Could not create task <ppDrv>");sys_abort(1);} |
- //if(task_activate(pid1)==-1) {/*grx_close();*/ perror("Could not create task <ppDrv>");sys_abort(1);}; |
- |
- //(" Task ppDrv Activate...PID: %i\n",pid1); |
- // kern_printf("---------------------\n"); |
- |
- |
- /* ppChat creation */ |
- hard_task_default_model(m2); |
- hard_task_def_ctrl_jet (m2); |
- hard_task_def_arg (m2, (void *)1); |
- hard_task_def_wcet (m2, TSK_WCET); |
- hard_task_def_mit (m2, TSK_PERIOD); |
- hard_task_def_group (m2,2); |
- pid2 = task_create("ppChat", ppChat, &m2, NULL); |
- if (pid2 == NIL) {/*grx_close();*/ perror("Could not create task <ppChat>");sys_abort(1);} |
- task_activate(pid2); |
- //kern_printf("Task Chat Activate...PID: %i\n",pid2); |
- |
- //kern_printf("---------------------\n"); |
- |
- |
- /* |
- now the task main ends, but the system does not shutdown because |
- there are the three task ego1, ego2, and ego3 running. |
- The demo will finish if a Alt-X key is pressed. |
- */ |
- |
- return 0; |
-} |
- |
-/* MODEL TASK EXAMPLES (from jumpball demo) |
- |
- SOFT_TASK_MODEL mp; |
- |
- soft_task_default_model(mp); |
- soft_task_def_level(mp,1); |
- soft_task_def_ctrl_jet(mp); |
- soft_task_def_arg(mp, (void *)rgb16(r,g,b)); |
- soft_task_def_group(mp, BALL_GROUP); |
- soft_task_def_met(mp, WCET_BALL); |
- soft_task_def_period(mp,PERIOD_BALL); |
- soft_task_def_usemath(mp); |
- pid = task_create(palla_str, palla, &mp, NULL); |
- |
- if (pid != NIL) task_activate(pid); |
- |
- |
- HARD TASK EXAMPLES |
- |
- HARD_TASK_MODEL mp; |
- |
- hard_task_default_model(mp); |
- hard_task_def_ctrl_jet(mp); |
- hard_task_def_arg(mp, (void *)rgb16(r,g,b)); |
- hard_task_def_wcet(mp, 380); |
- hard_task_def_mit(mp,PERIOD_BALL); |
- hard_task_def_usemath(mp); |
- pid = task_create("pallaEDF", palla, &mp, NULL); |
- |
- if (pid != NIL) task_activate(pid); |
-*/ |
Index: tags/rel_1_22/first/rmstar.c |
=================================================================== |
--- tags/rel_1_22/first/rmstar.c (revision 1310) |
+++ tags/rel_1_22/first/rmstar.c (nonexistent) |
@@ -1,640 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: rmstar.c,v 1.5 2003-12-17 13:52:46 giacomo Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.5 $ |
- Last update: $Date: 2003-12-17 13:52:46 $ |
- ------------ |
-**/ |
- |
-/* |
- * Copyright (C) 2001 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include "rmstar.h" |
-#include <ll/stdio.h> |
-#include <ll/string.h> |
-#include <kernel/model.h> |
-#include <kernel/descr.h> |
-#include <kernel/var.h> |
-#include <kernel/func.h> |
- |
-/* for iqueues */ |
-/* #include "iqueue.h" Now iqueues are the only queue type into the kernel */ |
- |
-/* for BUDGET_TASK_MODEL */ |
-#include "cbsstar.h" |
- |
-/* |
- * DEBUG stuffs begin |
- */ |
- |
-//#define RMSTAR_DEBUG |
- |
-#ifdef RMSTAR_DEBUG |
- |
-static __inline__ fake_printf(char *fmt, ...) {} |
- |
-#define rmstar_printf fake_printf |
-#define rmstar_printf2 fake_printf |
-#define rmstar_printf3 fake_printf |
- |
-//#define rmstar_printf kern_printf |
-//#define rmstar_printf2 kern_printf |
-//#define rmstar_printf3 kern_printf |
-#endif |
- |
-/* |
- * DEBUG stuffs end |
- */ |
- |
-/* Status used in the level */ |
-#define RMSTAR_READY MODULE_STATUS_BASE /* - Ready status */ |
-#define RMSTAR_IDLE MODULE_STATUS_BASE+4 /* to wait the deadline */ |
- |
-/* flags */ |
-#define RMSTAR_FLAG_NORAISEEXC 2 |
- |
-/* the level redefinition for the Earliest Deadline First level */ |
-typedef struct { |
- level_des l; /* the standard level descriptor */ |
- |
- TIME period[MAX_PROC]; /* The task periods; the deadlines are |
- stored in the priority field */ |
- int deadline_timer[MAX_PROC]; |
- /* The task deadline timers */ |
- |
- struct timespec deadline_timespec[MAX_PROC]; |
- |
- int dline_miss[MAX_PROC]; /* Deadline miss counter */ |
- int wcet_miss[MAX_PROC]; /* Wcet miss counter */ |
- |
- int nact[MAX_PROC]; /* Wcet miss counter */ |
- |
- int flag[MAX_PROC]; |
- /* used to manage the JOB_TASK_MODEL and the |
- periodicity */ |
- |
- IQUEUE ready; /* the ready queue */ |
- |
- PID activated; /* the task that has been inserted into the |
- master module */ |
- |
- int budget; |
- |
- int scheduling_level; |
-} RMSTAR_level_des; |
- |
-static void RMSTAR_check_preemption(RMSTAR_level_des *lev) |
-{ |
- PID first; |
- |
-#ifdef RMSTAR_DEBUG |
- rmstar_printf("(E:chk)"); |
-#endif |
- |
- if ((first = iq_query_first(&lev->ready)) != lev->activated) { |
- if (lev->activated != NIL) |
- level_table[ lev->scheduling_level ]-> |
- private_extract(lev->scheduling_level, lev->activated); |
- |
- lev->activated = first; |
- |
- if (first != NIL) { |
- BUDGET_TASK_MODEL b; |
- budget_task_default_model(b, lev->budget); |
- |
- level_table[ lev->scheduling_level ]-> |
- private_insert(lev->scheduling_level, first, (TASK_MODEL *)&b); |
- } |
- } |
-} |
- |
-static void RMSTAR_timer_deadline(void *par); |
- |
-static void RMSTAR_internal_activate(RMSTAR_level_des *lev, PID p, |
- struct timespec *t) |
-{ |
-#ifdef RMSTAR_DEBUG |
- rmstar_printf("(E:iact)"); |
-#endif |
- |
- ADDUSEC2TIMESPEC(lev->period[p], t); |
- |
- *iq_query_timespec(p, &lev->ready) = *t; |
- lev->deadline_timespec[p] = *t; |
- |
- /* Insert task in the correct position */ |
- proc_table[p].status = RMSTAR_READY; |
- iq_priority_insert(p,&lev->ready); |
- |
- /* needed because when there is a wcet miss I disable CONTROL_CAP */ |
- proc_table[p].control |= CONTROL_CAP; |
- |
- /* check for preemption */ |
- RMSTAR_check_preemption(lev); |
-} |
- |
-static void RMSTAR_timer_deadline(void *par) |
-{ |
- PID p = (PID) par; |
- RMSTAR_level_des *lev; |
- |
-#ifdef RMSTAR_DEBUG |
-// rmstar_printf("(E:tdl "); |
-#endif |
- |
- lev = (RMSTAR_level_des *)level_table[proc_table[p].task_level]; |
- |
- switch (proc_table[p].status) { |
- case RMSTAR_IDLE: |
-#ifdef RMSTAR_DEBUG |
-// rmstar_printf2("I%d",p); |
-#endif |
- /* set the request time */ |
- RMSTAR_internal_activate(lev,p,iq_query_timespec(p, &lev->ready)); |
- |
- event_need_reschedule(); |
- break; |
- |
- default: |
-#ifdef RMSTAR_DEBUG |
-// rmstar_printf2("D%d",p); |
-#endif |
- /* else, a deadline miss occurred!!! */ |
- lev->dline_miss[p]++; |
- |
- /* the task is into another state */ |
- lev->nact[p]++; |
- |
- /* Set the deadline timer */ |
- ADDUSEC2TIMESPEC(lev->period[p], &lev->deadline_timespec[p]); |
- } |
- |
- /* Set the deadline timer */ |
- lev->deadline_timer[p] = kern_event_post(&lev->deadline_timespec[p], |
- RMSTAR_timer_deadline, |
- (void *)p); |
- |
-#ifdef RMSTAR_DEBUG |
-// rmstar_printf(")"); |
-#endif |
-} |
- |
-static void RMSTAR_timer_guest_deadline(void *par) |
-{ |
- PID p = (PID) par; |
- |
-#ifdef RMSTAR_DEBUG |
- rmstar_printf("(E:gdl)"); |
-#endif |
- |
- kern_raise(XDEADLINE_MISS,p); |
-} |
- |
-static int RMSTAR_public_create(LEVEL l, PID p, TASK_MODEL *m) |
-{ |
- RMSTAR_level_des *lev = (RMSTAR_level_des *)(level_table[l]); |
- |
- /* if the RMSTAR_task_create is called, then the pclass must be a |
- valid pclass. */ |
- HARD_TASK_MODEL *h; |
- |
- if (m->pclass != HARD_PCLASS) return -1; |
- if (m->level != 0 && m->level != l) return -1; |
- h = (HARD_TASK_MODEL *)m; |
- if (!h->wcet || !h->mit || h->periodicity != PERIODIC) return -1; |
- /* now we know that m is a valid model */ |
- |
-#ifdef RMSTAR_DEBUG |
- rmstar_printf("(E:tcr)"); |
-#endif |
- |
- lev->period[p] = h->mit; |
- *iq_query_priority(p, &lev->ready) = h->mit; |
- |
- lev->flag[p] = 0; |
- lev->deadline_timer[p] = -1; |
- lev->dline_miss[p] = 0; |
- lev->wcet_miss[p] = 0; |
- lev->nact[p] = 0; |
- |
- /* Enable wcet check */ |
- proc_table[p].avail_time = h->wcet; |
- proc_table[p].wcet = h->wcet; |
- proc_table[p].control |= CONTROL_CAP; |
- |
- return 0; /* OK, also if the task cannot be guaranteed... */ |
-} |
- |
-static void RMSTAR_public_dispatch(LEVEL l, PID p, int nostop) |
-{ |
- RMSTAR_level_des *lev = (RMSTAR_level_des *)(level_table[l]); |
- |
-#ifdef RMSTAR_DEBUG |
- rmstar_printf("(E:dis)"); |
- |
- rmstar_printf3("(%d %d)", |
- iq_query_timespec(p, &lev->ready)->tv_nsec/1000000, |
- schedule_time.tv_nsec/1000000); |
-#endif |
- |
- level_table[ lev->scheduling_level ]-> |
- private_dispatch(lev->scheduling_level,p,nostop); |
-} |
- |
-static void RMSTAR_public_epilogue(LEVEL l, PID p) |
-{ |
- RMSTAR_level_des *lev = (RMSTAR_level_des *)(level_table[l]); |
- |
-#ifdef RMSTAR_DEBUG |
- rmstar_printf("(E:epi "); |
-#endif |
- |
- /* check if the wcet is finished... */ |
- if (proc_table[p].avail_time <= 0 && proc_table[p].control&CONTROL_CAP) { |
- /* wcet finished: disable wcet event and count wcet miss */ |
-#ifdef RMSTAR_DEBUG |
- rmstar_printf2("W%d",p); |
-#endif |
- proc_table[p].control &= ~CONTROL_CAP; |
- lev->wcet_miss[p]++; |
- } |
-#ifdef RMSTAR_DEBUG |
- rmstar_printf(")"); |
-#endif |
- |
- level_table[ lev->scheduling_level ]-> |
- private_epilogue(lev->scheduling_level,p); |
- |
- proc_table[p].status = RMSTAR_READY; |
-} |
- |
-static void RMSTAR_public_activate(LEVEL l, PID p) |
-{ |
- RMSTAR_level_des *lev = (RMSTAR_level_des *)(level_table[l]); |
- struct timespec t; |
- |
-#ifdef RMSTAR_DEBUG |
- rmstar_printf("(E:act)"); |
-#endif |
- |
- /* Test if we are trying to activate a non sleeping task */ |
- /* save activation (only if needed... */ |
- if (proc_table[p].status != SLEEP) { |
- /* a periodic task cannot be activated when it is already active */ |
- kern_raise(XACTIVATION,p); |
- return; |
- } |
- |
- kern_gettime(&t); |
- |
- RMSTAR_internal_activate(lev,p, &t); |
- |
- /* Set the deadline timer */ |
- lev->deadline_timer[p] = kern_event_post(&lev->deadline_timespec[p], |
- RMSTAR_timer_deadline, |
- (void *)p); |
- |
-} |
- |
-static void RMSTAR_public_unblock(LEVEL l, PID p) |
-{ |
- RMSTAR_level_des *lev = (RMSTAR_level_des *)(level_table[l]); |
- |
-#ifdef RMSTAR_DEBUG |
- rmstar_printf("(E:ins)"); |
-#endif |
- |
- /* Insert task in the correct position */ |
- proc_table[p].status = RMSTAR_READY; |
- iq_priority_insert(p,&lev->ready); |
- |
- /* and check for preemption! */ |
- RMSTAR_check_preemption(lev); |
-} |
- |
-static void RMSTAR_public_block(LEVEL l, PID p) |
-{ |
- RMSTAR_level_des *lev = (RMSTAR_level_des *)(level_table[l]); |
- |
-#ifdef RMSTAR_DEBUG |
- rmstar_printf("(E:ext)"); |
-#endif |
- |
- /* the task is blocked on a synchronization primitive. we have to |
- remove it from the master module -and- from the local queue! */ |
- iq_extract(p,&lev->ready); |
- |
- /* and finally, a preemption check! (it will also call guest_end) */ |
- RMSTAR_check_preemption(lev); |
-} |
- |
-static int RMSTAR_public_message(LEVEL l, PID p, void *m) |
-{ |
- RMSTAR_level_des *lev = (RMSTAR_level_des *)(level_table[l]); |
- struct timespec temp; |
- |
-#ifdef RMSTAR_DEBUG |
- rmstar_printf("(E:ecy "); |
-#endif |
- |
- /* we call guest_end directly here because the same task may |
- be reinserted in the queue before calling the preemption check! */ |
- level_table[ lev->scheduling_level ]-> |
- private_extract(lev->scheduling_level,p); lev->activated = NIL; |
- |
- iq_extract(p,&lev->ready); |
- |
- /* we reset the capacity counters... */ |
- proc_table[p].avail_time = proc_table[p].wcet; |
- |
- if (lev->nact[p] > 0) { |
-#ifdef RMSTAR_DEBUG |
- rmstar_printf2("E%d",p); |
-#endif |
- |
- /* Pending activation: reactivate the thread!!! */ |
- lev->nact[p]--; |
- |
- /* see also RMSTAR_timer_deadline */ |
- kern_gettime(&temp); |
- |
- RMSTAR_internal_activate(lev,p,&temp); |
- |
- /* check if the deadline has already expired */ |
- temp = *iq_query_timespec(p, &lev->ready); |
- if (TIMESPEC_A_LT_B(&temp, &schedule_time)) { |
- /* count the deadline miss */ |
- lev->dline_miss[p]++; |
- kern_event_delete(lev->deadline_timer[p]); |
- } |
- |
- } |
- else { |
-#ifdef RMSTAR_DEBUG |
- rmstar_printf("e%d",p); |
-#endif |
- |
- /* the task has terminated his job before it consume the wcet. All OK! */ |
- proc_table[p].status = RMSTAR_IDLE; |
- |
- /* and finally, a preemption check! */ |
- RMSTAR_check_preemption(lev); |
- |
- /* when the deadline timer fire, it recognize the situation and set |
- correctly all the stuffs (like reactivation, etc... ) */ |
- } |
-#ifdef RMSTAR_DEBUG |
- rmstar_printf(")"); |
-#endif |
- |
- jet_update_endcycle(); /* Update the Jet data... */ |
- |
- return 0; |
-} |
- |
-static void RMSTAR_public_end(LEVEL l, PID p) |
-{ |
- RMSTAR_level_des *lev = (RMSTAR_level_des *)(level_table[l]); |
- |
-#ifdef RMSTAR_DEBUG |
- rmstar_printf("(E:end)"); |
-#endif |
- |
- iq_extract(p,&lev->ready); |
- |
- /* we finally put the task in the ready queue */ |
- proc_table[p].status = FREE; |
- |
- iq_insertfirst(p,&freedesc); |
- |
- if (lev->deadline_timer[p] != -1) { |
- kern_event_delete(lev->deadline_timer[p]); |
- } |
- |
- /* and finally, a preemption check! (it will also call guest_end) */ |
- RMSTAR_check_preemption(lev); |
-} |
- |
- |
-/* Guest Functions |
- These functions manages a JOB_TASK_MODEL, that is used to put |
- a guest task in the RMSTAR ready queue. */ |
- |
-static void RMSTAR_private_insert(LEVEL l, PID p, TASK_MODEL *m) |
-{ |
- RMSTAR_level_des *lev = (RMSTAR_level_des *)(level_table[l]); |
- JOB_TASK_MODEL *job; |
- |
- if (m->pclass != JOB_PCLASS || (m->level != 0 && m->level != l) ) { |
- kern_raise(XINVALID_TASK, p); |
- return; |
- } |
- |
- job = (JOB_TASK_MODEL *)m; |
- |
- *iq_query_timespec(p, &lev->ready) = job->deadline; |
- |
- lev->deadline_timer[p] = -1; |
- lev->dline_miss[p] = 0; |
- lev->wcet_miss[p] = 0; |
- lev->nact[p] = 0; |
- |
- if (job->noraiseexc) |
- lev->flag[p] = RMSTAR_FLAG_NORAISEEXC; |
- else { |
- lev->flag[p] = 0; |
- lev->deadline_timer[p] = kern_event_post(iq_query_timespec(p, &lev->ready), |
- RMSTAR_timer_guest_deadline, |
- (void *)p); |
- } |
- |
- lev->period[p] = job->period; |
- *iq_query_priority(p, &lev->ready) = job->period; |
- |
- /* there is no bandwidth guarantee at this level, it is performed |
- by the level that inserts guest tasks... */ |
- |
- /* Insert task in the correct position */ |
- iq_priority_insert(p,&lev->ready); |
- proc_table[p].status = RMSTAR_READY; |
- |
- /* check for preemption */ |
- RMSTAR_check_preemption(lev); |
-} |
- |
-static void RMSTAR_private_dispatch(LEVEL l, PID p, int nostop) |
-{ |
- RMSTAR_level_des *lev = (RMSTAR_level_des *)(level_table[l]); |
- |
- level_table[ lev->scheduling_level ]-> |
- private_dispatch(lev->scheduling_level,p,nostop); |
-} |
- |
-static void RMSTAR_private_epilogue(LEVEL l, PID p) |
-{ |
- RMSTAR_level_des *lev = (RMSTAR_level_des *)(level_table[l]); |
- |
- /* the task has been preempted. it returns into the ready queue... */ |
- level_table[ lev->scheduling_level ]-> |
- private_epilogue(lev->scheduling_level,p); |
- |
- proc_table[p].status = RMSTAR_READY; |
-} |
- |
-static void RMSTAR_private_extract(LEVEL l, PID p) |
-{ |
- RMSTAR_level_des *lev = (RMSTAR_level_des *)(level_table[l]); |
- |
-#ifdef RMSTAR_DEBUG |
- //kern_printf("RMSTAR_guest_end: dline timer %d\n",lev->deadline_timer[p]); |
-#endif |
- |
- iq_extract(p, &lev->ready); |
- |
- /* we remove the deadline timer, because the slice is finished */ |
- if (lev->deadline_timer[p] != NIL) { |
-#ifdef RMSTAR_DEBUG |
-// kern_printf("RMSTAR_guest_end: dline timer %d\n",lev->deadline_timer[p]); |
-#endif |
- kern_event_delete(lev->deadline_timer[p]); |
- lev->deadline_timer[p] = NIL; |
- } |
- |
- /* and finally, a preemption check! (it will also call guest_end() */ |
- RMSTAR_check_preemption(lev); |
-} |
- |
-/* Registration functions */ |
- |
-/* Registration function: |
- int flags the init flags ... see RMSTAR.h */ |
-LEVEL RMSTAR_register_level(int budget, int master) |
-{ |
- LEVEL l; /* the level that we register */ |
- RMSTAR_level_des *lev; /* for readableness only */ |
- PID i; /* a counter */ |
- |
-#ifdef RMSTAR_DEBUG |
- printk("RMSTAR_register_level\n"); |
-#endif |
- |
- /* request an entry in the level_table */ |
- l = level_alloc_descriptor(sizeof(RMSTAR_level_des)); |
- |
- lev = (RMSTAR_level_des *)level_table[l]; |
- |
- printk(" lev=%d\n",(int)lev); |
- |
- /* fill the standard descriptor */ |
- lev->l.private_insert = RMSTAR_private_insert; |
- lev->l.private_extract = RMSTAR_private_extract; |
- lev->l.private_dispatch = RMSTAR_private_dispatch; |
- lev->l.private_epilogue = RMSTAR_private_epilogue; |
- |
- lev->l.public_guarantee = NULL; |
- lev->l.public_create = RMSTAR_public_create; |
- lev->l.public_end = RMSTAR_public_end; |
- lev->l.public_dispatch = RMSTAR_public_dispatch; |
- lev->l.public_epilogue = RMSTAR_public_epilogue; |
- lev->l.public_activate = RMSTAR_public_activate; |
- lev->l.public_unblock = RMSTAR_public_unblock; |
- lev->l.public_block = RMSTAR_public_block; |
- lev->l.public_message = RMSTAR_public_message; |
- |
- /* fill the RMSTAR descriptor part */ |
- for(i=0; i<MAX_PROC; i++) { |
- lev->period[i] = 0; |
- lev->deadline_timer[i] = -1; |
- lev->flag[i] = 0; |
- lev->dline_miss[i] = 0; |
- lev->wcet_miss[i] = 0; |
- lev->nact[i] = 0; |
- } |
- |
- iq_init(&lev->ready, NULL, 0); |
- lev->activated = NIL; |
- |
- lev->budget = budget; |
- lev->scheduling_level = master; |
- |
- return l; |
-} |
- |
-int RMSTAR_get_dline_miss(PID p) |
-{ |
- LEVEL l = proc_table[p].task_level; |
- RMSTAR_level_des *lev = (RMSTAR_level_des *)(level_table[l]); |
- |
- return lev->dline_miss[p]; |
-} |
- |
-int RMSTAR_get_wcet_miss(PID p) |
-{ |
- LEVEL l = proc_table[p].task_level; |
- RMSTAR_level_des *lev = (RMSTAR_level_des *)(level_table[l]); |
- |
- return lev->wcet_miss[p]; |
-} |
- |
-int RMSTAR_get_nact(PID p) |
-{ |
- LEVEL l = proc_table[p].task_level; |
- RMSTAR_level_des *lev = (RMSTAR_level_des *)(level_table[l]); |
- |
- return lev->nact[p]; |
-} |
- |
-int RMSTAR_reset_dline_miss(PID p) |
-{ |
- LEVEL l = proc_table[p].task_level; |
- RMSTAR_level_des *lev = (RMSTAR_level_des *)(level_table[l]); |
- |
- lev->dline_miss[p] = 0; |
- return 0; |
-} |
- |
-int RMSTAR_reset_wcet_miss(PID p) |
-{ |
- LEVEL l = proc_table[p].task_level; |
- RMSTAR_level_des *lev = (RMSTAR_level_des *)(level_table[l]); |
- |
- lev->wcet_miss[p] = 0; |
- return 0; |
-} |
- |
Index: tags/rel_1_22/first/testiq.c |
=================================================================== |
--- tags/rel_1_22/first/testiq.c (revision 1310) |
+++ tags/rel_1_22/first/testiq.c (nonexistent) |
@@ -1,260 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- ------------ |
- CVS : $Id: testiq.c,v 1.3 2003-01-07 17:10:17 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.3 $ |
- Last update: $Date: 2003-01-07 17:10:17 $ |
- ------------ |
- |
- The purpose of this test is to show that two budgets with different |
- period and budgets schedules correctly. |
- |
- 2 never ending tasks are involved |
- |
- This test cannot compile because of the fact that QUEUE and QQUEUE |
- types does not exist anymore! |
-*/ |
- |
-/* |
- * Copyright (C) 2002 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/cbs.h" |
-#include "cbsstar.h" |
-#include "edfstar.h" |
-#include "modules/rr.h" |
-#include "modules/dummy.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
- |
-#include "drivers/keyb.h" |
- |
-// -------------------------------------------------- |
-// -------------------------------------------------- |
-// Init Part |
-// -------------------------------------------------- |
-// -------------------------------------------------- |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 0 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 10000 |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- clear(); |
- |
- EDF_register_level(EDF_ENABLE_ALL); |
- |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- // for the keyboard... |
- CBS_register_level(CBS_ENABLE_ALL, 0); |
- |
- SEM_register_module(); |
- |
- CABS_register_module(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- KEYB_PARMS kparms = BASE_KEYB; |
- |
- HARTPORT_init(); |
- |
- //keyb_def_ctrlC(kparms, NULL); |
- //keyb_def_map(kparms,itaMap); |
- KEYB_init(&kparms); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
-// -------------------------------------------------- |
-// -------------------------------------------------- |
-// The Test |
-// -------------------------------------------------- |
-// -------------------------------------------------- |
- |
- |
-#include <kernel/kern.h> |
-#include <drivers/keyb.h> |
-#include "iqueue.h" |
- |
-sem_t s; |
- |
-PID p2,p3,p4; |
- |
-void *star(void *arg) |
-{ |
- int j; |
- TIME last[5]; |
- |
- QUEUE i = NIL; |
- IQUEUE ii; |
- |
- q_timespec_insert(p2,&i); |
- q_timespec_insert(p3,&i); |
- |
- iq_init(&ii,NULL,0); |
- *iq_query_timespec(p2,&ii) = proc_table[p2].timespec_priority; |
- *iq_query_timespec(p3,&ii) = proc_table[p3].timespec_priority; |
- *iq_query_timespec(p4,&ii) = proc_table[p4].timespec_priority; |
- iq_timespec_insert(p2,&ii); |
- iq_timespec_insert(p3,&ii); |
- |
- cprintf("p2=%ld.%ld\n",proc_table[p2].timespec_priority.tv_sec,proc_table[p2].timespec_priority.tv_nsec/1000); |
- cprintf("p3=%ld.%ld\n",proc_table[p3].timespec_priority.tv_sec,proc_table[p3].timespec_priority.tv_nsec/1000); |
- cprintf("p4=%ld.%ld\n",proc_table[p4].timespec_priority.tv_sec,proc_table[p4].timespec_priority.tv_nsec/1000); |
- |
- task_endcycle(); |
- |
- for (j=0; j<200000; j++) { |
- q_timespec_insert(p4,&i); |
- q_extract(p4,&i); |
- } |
- |
- |
- task_endcycle(); |
- |
- for (j=0; j<200000; j++) { |
- iq_timespec_insert(p4,&ii); |
- iq_extract(p4,&ii); |
- } |
- |
- task_endcycle(); |
- |
- jet_gettable(exec_shadow, &last[0], 3); |
- |
- cprintf("\ninit=%d queue=%d iqueue=%d\n", |
- (int)last[0], (int)last[1], (int)last[2]); |
- |
- sys_end(); |
- return NULL; |
-} |
- |
-void *fake(void *arg) |
-{ |
- cputs("#"); |
- task_endcycle(); |
- |
- return NULL; |
-} |
- |
- |
-void create1() |
-{ |
- HARD_TASK_MODEL m1; |
- PID p1a; |
- |
- hard_task_default_model(m1); |
- hard_task_def_wcet(m1, 500000); |
- hard_task_def_group(m1,1); |
- hard_task_def_periodic(m1); |
- hard_task_def_mit(m1,1000000); |
- hard_task_def_ctrl_jet(m1); |
- p1a = task_create("a", star, &m1, NULL); |
- if (p1a == -1) { |
- perror("Could not create task a ..."); |
- sys_end(); |
- } |
- |
- hard_task_default_model(m1); |
- hard_task_def_wcet(m1, 5000); |
- hard_task_def_aperiodic(m1); |
- hard_task_def_group(m1,1); |
- |
- hard_task_def_mit(m1,100000); |
- p2 = task_create("a", fake, &m1, NULL); |
- if (p1a == -1) { |
- perror("Could not create task a ..."); |
- sys_end(); |
- } |
- |
- hard_task_def_mit(m1,100001); |
- p3 = task_create("a", fake, &m1, NULL); |
- if (p1a == -1) { |
- perror("Could not create task a ..."); |
- sys_end(); |
- } |
- |
- hard_task_def_mit(m1,100002); |
- p4 = task_create("a", fake, &m1, NULL); |
- if (p1a == -1) { |
- perror("Could not create task a ..."); |
- sys_end(); |
- } |
- |
- group_activate(1); |
-} |
- |
-void endfun(KEY_EVT *k) |
-{ |
- cprintf("ESC pressed!"); |
- |
- sys_end(); |
-} |
- |
-int main(int argc, char **argv) |
-{ |
- KEY_EVT k; |
- |
- sem_init(&s,0,1); |
- |
- k.flag = 0; |
- k.scan = KEY_ESC; |
- k.ascii = 27; |
- keyb_hook(k,endfun); |
- |
- create1(); |
- |
- return 0; |
-} |
- |
Index: tags/rel_1_22/first/rmstar.h |
=================================================================== |
--- tags/rel_1_22/first/rmstar.h (revision 1310) |
+++ tags/rel_1_22/first/rmstar.h (nonexistent) |
@@ -1,128 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * Massimiliano Giorgi <massy@gandalf.sssup.it> |
- * Luca Abeni <luca@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: rmstar.h,v 1.2 2003-01-07 17:10:17 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.2 $ |
- Last update: $Date: 2003-01-07 17:10:17 $ |
- ------------ |
- |
- Title: |
- RMSTAR |
- |
- Task Models Accepted: |
- HARD_TASK_MODEL - Hard Tasks (only Periodic) |
- wcet field and mit field must be != 0. They are used to set the wcet |
- and period of the tasks. |
- periodicity field can be only PERIODIC |
- drel field is ignored |
- |
- Guest Models Accepted: |
- JOB_TASK_MODEL - a single guest task activation |
- Identified by an absolute deadline and a period. |
- period field is ignored |
- |
- Description: |
- |
- This module schedule his tasks following the classic RM |
- scheme. |
- |
- Note: This module is derived from the EDFSTAR Scheduling Module. I |
- have just changed RM in EDF and iq_timespec_insert with |
- iq_priority_insert... |
- |
- Exceptions raised: |
- XUNVALID_GUEST XUNVALID_TASK |
- some primitives are not implemented: |
- task_sleep, task_delay, guest_endcycle, guest_sleep, guest_delay |
- |
- XACTIVATION |
- If a task is actiated through task_activate or guest_activate more than |
- one time |
- |
- Restrictions & special features: |
- see edfstar.h |
- |
-**/ |
- |
-/* |
- * Copyright (C) 2001 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
- |
-#ifndef __RMSTAR_H__ |
-#define __RMSTAR_H__ |
- |
-#include <ll/ll.h> |
-#include <kernel/config.h> |
-#include <sys/types.h> |
-#include <kernel/types.h> |
- |
- |
- |
-/* flags... */ |
-#define RMSTAR_ENABLE_GUARANTEE 1 /* Task Guarantee enabled */ |
-#define RMSTAR_ENABLE_ALL 1 |
- |
-#define RMSTAR_FAILED_GUARANTEE 8 /* used in the module, unsettabl |
- in RM_register_level... */ |
- |
- |
- |
-#define RMSTAR_LEVELNAME "RMSTAR base" |
-#define RMSTAR_LEVEL_CODE 166 |
-#define RMSTAR_LEVEL_VERSION 1 |
- |
- |
-/* Registration function: |
- int budget The budget used by this module (see CBSSTAR.h) |
- int master The master module used by RMSTAR |
-*/ |
-LEVEL RMSTAR_register_level(int budget, int master); |
- |
-/* returns respectively the number of dline, wcet or nact; -1 if error */ |
-int RMSTAR_get_dline_miss(PID p); |
-int RMSTAR_get_wcet_miss(PID p); |
-int RMSTAR_get_nact(PID p); |
- |
-/* resets respectively the number of dline, wcet miss; -1 if error */ |
-int RMSTAR_reset_dline_miss(PID p); |
-int RMSTAR_reset_wcet_miss(PID p); |
- |
-#endif |
- |
Index: tags/rel_1_22/first/edfstar.c |
=================================================================== |
--- tags/rel_1_22/first/edfstar.c (revision 1310) |
+++ tags/rel_1_22/first/edfstar.c (nonexistent) |
@@ -1,657 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: edfstar.c,v 1.6 2003-12-17 13:52:46 giacomo Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.6 $ |
- Last update: $Date: 2003-12-17 13:52:46 $ |
- ------------ |
-**/ |
- |
-/* |
- * Copyright (C) 2001 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include "edfstar.h" |
-#include <ll/stdio.h> |
-#include <ll/string.h> |
-#include <kernel/model.h> |
-#include <kernel/descr.h> |
-#include <kernel/var.h> |
-#include <kernel/func.h> |
- |
-/* for iqueues */ |
-/* #include "iqueue.h" Now iqueues are the only queue type available |
- into the kernel */ |
-#include <kernel/iqueue.h> |
- |
-/* for BUDGET_TASK_MODEL */ |
-#include "cbsstar.h" |
- |
-/* |
- * DEBUG stuffs begin |
- */ |
- |
-//#define EDFSTAR_DEBUG |
- |
-#ifdef EDFSTAR_DEBUF |
- |
-static __inline__ fake_printf(char *fmt, ...) {} |
- |
-#define edfstar_printf fake_printf |
-#define edfstar_printf2 fake_printf |
-#define edfstar_printf3 fake_printf |
- |
-//#define edfstar_printf kern_printf |
-//#define edfstar_printf2 kern_printf |
-//#define edfstar_printf3 kern_printf |
-#endif |
- |
-/* |
- * DEBUG stuffs end |
- */ |
- |
-/* Status used in the level */ |
-#define EDFSTAR_READY MODULE_STATUS_BASE /* - Ready status */ |
-#define EDFSTAR_IDLE MODULE_STATUS_BASE+4 /* to wait the deadline */ |
- |
-/* flags */ |
-#define EDFSTAR_FLAG_NORAISEEXC 2 |
- |
-/* the level redefinition for the Earliest Deadline First level */ |
-typedef struct { |
- level_des l; /* the standard level descriptor */ |
- |
- TIME period[MAX_PROC]; /* The task periods; the deadlines are |
- stored in the priority field */ |
- int deadline_timer[MAX_PROC]; |
- /* The task deadline timers */ |
- |
- struct timespec deadline_timespec[MAX_PROC]; |
- |
- int dline_miss[MAX_PROC]; /* Deadline miss counter */ |
- int wcet_miss[MAX_PROC]; /* Wcet miss counter */ |
- |
- int nact[MAX_PROC]; /* Wcet miss counter */ |
- |
- int flag[MAX_PROC]; |
- /* used to manage the JOB_TASK_MODEL and the |
- periodicity */ |
- |
- IQUEUE ready; /* the ready queue */ |
- |
- PID activated; /* the task that has been inserted into the |
- master module */ |
- |
- int budget; |
- |
- int scheduling_level; |
-} EDFSTAR_level_des; |
- |
-static void EDFSTAR_check_preemption(EDFSTAR_level_des *lev) |
-{ |
- PID first; |
- |
-#ifdef EDFSTAR_DEBUG |
- edfstar_printf("(E:chk)"); |
-#endif |
- |
- if ((first = iq_query_first(&lev->ready)) != lev->activated) { |
- if (lev->activated != NIL) |
- level_table[ lev->scheduling_level ]-> |
- private_extract(lev->scheduling_level, lev->activated); |
- |
- lev->activated = first; |
- |
- if (first != NIL) { |
- BUDGET_TASK_MODEL b; |
- budget_task_default_model(b, lev->budget); |
- |
- level_table[ lev->scheduling_level ]-> |
- private_insert(lev->scheduling_level, first, (TASK_MODEL *)&b); |
- } |
- } |
-} |
- |
-static void EDFSTAR_timer_deadline(void *par); |
- |
-static void EDFSTAR_internal_activate(EDFSTAR_level_des *lev, PID p, |
- struct timespec *t) |
-{ |
-#ifdef EDFSTAR_DEBUG |
- edfstar_printf("(E:iact)"); |
-#endif |
- |
- ADDUSEC2TIMESPEC(lev->period[p], t); |
- |
- *iq_query_timespec(p, &lev->ready) = *t; |
- lev->deadline_timespec[p] = *t; |
- |
- /* Insert task in the correct position */ |
- proc_table[p].status = EDFSTAR_READY; |
- iq_timespec_insert(p,&lev->ready); |
- |
- /* needed because when there is a wcet miss I disable CONTROL_CAP */ |
- proc_table[p].control |= CONTROL_CAP; |
- |
- /* check for preemption */ |
- EDFSTAR_check_preemption(lev); |
-} |
- |
-static void EDFSTAR_timer_deadline(void *par) |
-{ |
- PID p = (PID) par; |
- EDFSTAR_level_des *lev; |
- |
-#ifdef EDFSTAR_DEBUG |
-// edfstar_printf("(E:tdl "); |
-#endif |
- |
- lev = (EDFSTAR_level_des *)level_table[proc_table[p].task_level]; |
- |
- switch (proc_table[p].status) { |
- case EDFSTAR_IDLE: |
-#ifdef EDFSTAR_DEBUG |
-// edfstar_printf2("I%d",p); |
-#endif |
- /* set the request time */ |
- EDFSTAR_internal_activate(lev,p,iq_query_timespec(p, &lev->ready)); |
- |
- event_need_reschedule(); |
- break; |
- |
- default: |
-#ifdef EDFSTAR_DEBUG |
-// edfstar_printf2("D%d",p); |
-#endif |
- /* else, a deadline miss occurred!!! */ |
- lev->dline_miss[p]++; |
- |
- /* the task is into another state */ |
- lev->nact[p]++; |
- |
- /* Set the deadline timer */ |
- ADDUSEC2TIMESPEC(lev->period[p], &lev->deadline_timespec[p]); |
- } |
- |
- /* Set the deadline timer */ |
- lev->deadline_timer[p] = kern_event_post(&lev->deadline_timespec[p], |
- EDFSTAR_timer_deadline, |
- (void *)p); |
- |
-#ifdef EDFSTAR_DEBUG |
-// edfstar_printf(")"); |
-#endif |
-} |
- |
-static void EDFSTAR_timer_guest_deadline(void *par) |
-{ |
- PID p = (PID) par; |
- |
-#ifdef EDFSTAR_DEBUG |
- edfstar_printf("(E:gdl)"); |
-#endif |
- |
- kern_raise(XDEADLINE_MISS,p); |
-} |
- |
-static int EDFSTAR_public_create(LEVEL l, PID p, TASK_MODEL *m) |
-{ |
- EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]); |
- |
- /* if the EDFSTAR_task_create is called, then the pclass must be a |
- valid pclass. */ |
- HARD_TASK_MODEL *h; |
- |
- if (m->pclass != HARD_PCLASS) return -1; |
- if (m->level != 0 && m->level != l) return -1; |
- h = (HARD_TASK_MODEL *)m; |
- if (!h->wcet || !h->mit || h->periodicity != PERIODIC) return -1; |
- /* now we know that m is a valid model */ |
- |
- |
-#ifdef EDFSTAR_DEBUG |
- edfstar_printf("(E:tcr)"); |
-#endif |
- |
- lev->period[p] = h->mit; |
- |
- lev->flag[p] = 0; |
- lev->deadline_timer[p] = -1; |
- lev->dline_miss[p] = 0; |
- lev->wcet_miss[p] = 0; |
- lev->nact[p] = 0; |
- |
- /* Enable wcet check */ |
- proc_table[p].avail_time = h->wcet; |
- proc_table[p].wcet = h->wcet; |
- proc_table[p].control |= CONTROL_CAP; |
- |
- return 0; /* OK, also if the task cannot be guaranteed... */ |
-} |
- |
-static int EDFSTAR_public_eligible(LEVEL l, PID p) |
-{ |
- EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]); |
- |
-#ifdef EDFSTAR_DEBUG |
- edfstar_printf2("(E:eli)"); |
-#endif |
- |
- return level_table[ lev->scheduling_level ]-> |
- private_eligible(lev->scheduling_level,p); |
-} |
- |
-static void EDFSTAR_public_dispatch(LEVEL l, PID p, int nostop) |
-{ |
- EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]); |
- |
-#ifdef EDFSTAR_DEBUG |
- edfstar_printf("(E:dis)"); |
- |
- edfstar_printf3("(%d %d)", |
- iq_query_timespec(p, &lev->ready)->tv_nsec/1000000, |
- schedule_time.tv_nsec/1000000); |
-#endif |
- |
- level_table[ lev->scheduling_level ]-> |
- private_dispatch(lev->scheduling_level,p,nostop); |
-} |
- |
-static void EDFSTAR_public_epilogue(LEVEL l, PID p) |
-{ |
- EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]); |
- |
-#ifdef EDFSTAR_DEBUG |
- edfstar_printf("(E:epi "); |
-#endif |
- |
- /* check if the wcet is finished... */ |
- if (proc_table[p].avail_time <= 0 && proc_table[p].control&CONTROL_CAP) { |
- /* wcet finished: disable wcet event and count wcet miss */ |
-#ifdef EDFSTAR_DEBUG |
- edfstar_printf2("W%d",p); |
-#endif |
- proc_table[p].control &= ~CONTROL_CAP; |
- lev->wcet_miss[p]++; |
- } |
-#ifdef EDFSTAR_DEBUG |
- edfstar_printf(")"); |
-#endif |
- |
- level_table[ lev->scheduling_level ]-> |
- private_epilogue(lev->scheduling_level,p); |
- |
- proc_table[p].status = EDFSTAR_READY; |
-} |
- |
-static void EDFSTAR_public_activate(LEVEL l, PID p) |
-{ |
- EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]); |
- struct timespec t; |
- |
-#ifdef EDFSTAR_DEBUG |
- edfstar_printf("(E:act)"); |
-#endif |
- |
- /* Test if we are trying to activate a non sleeping task */ |
- /* save activation (only if needed... */ |
- if (proc_table[p].status != SLEEP) { |
- /* a periodic task cannot be activated when it is already active */ |
- kern_raise(XACTIVATION,p); |
- return; |
- } |
- |
- kern_gettime(&t); |
- |
- EDFSTAR_internal_activate(lev,p, &t); |
- |
- /* Set the deadline timer */ |
- lev->deadline_timer[p] = kern_event_post(&lev->deadline_timespec[p], |
- EDFSTAR_timer_deadline, |
- (void *)p); |
- |
-} |
- |
-static void EDFSTAR_public_unblock(LEVEL l, PID p) |
-{ |
- EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]); |
- |
-#ifdef EDFSTAR_DEBUG |
- edfstar_printf("(E:ins)"); |
-#endif |
- |
- /* Insert task in the correct position */ |
- proc_table[p].status = EDFSTAR_READY; |
- iq_timespec_insert(p,&lev->ready); |
- |
- /* and check for preemption! */ |
- EDFSTAR_check_preemption(lev); |
-} |
- |
-static void EDFSTAR_public_block(LEVEL l, PID p) |
-{ |
- EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]); |
- |
-#ifdef EDFSTAR_DEBUG |
- edfstar_printf("(E:ext)"); |
-#endif |
- |
- /* the task is blocked on a synchronization primitive. we have to |
- remove it from the master module -and- from the local queue! */ |
- iq_extract(p,&lev->ready); |
- |
- /* and finally, a preemption check! (it will also call guest_end) */ |
- EDFSTAR_check_preemption(lev); |
-} |
- |
-static int EDFSTAR_public_message(LEVEL l, PID p, void *m) |
-{ |
- EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]); |
- struct timespec temp; |
- |
-#ifdef EDFSTAR_DEBUG |
- edfstar_printf("(E:ecy "); |
-#endif |
- |
- /* we call guest_end directly here because the same task may |
- be reinserted in the queue before calling the preemption check! */ |
- level_table[ lev->scheduling_level ]-> |
- private_extract(lev->scheduling_level,p); |
- lev->activated = NIL; |
- |
- iq_extract(p,&lev->ready); |
- |
- /* we reset the capacity counters... */ |
- proc_table[p].avail_time = proc_table[p].wcet; |
- |
- if (lev->nact[p] > 0) { |
-#ifdef EDFSTAR_DEBUG |
- edfstar_printf2("E%d",p); |
-#endif |
- |
- /* Pending activation: reactivate the thread!!! */ |
- lev->nact[p]--; |
- |
- /* see also EDFSTAR_timer_deadline */ |
- kern_gettime(&temp); |
- |
- EDFSTAR_internal_activate(lev,p, &temp); |
- |
- /* check if the deadline has already expired */ |
- temp = *iq_query_timespec(p, &lev->ready); |
- if (TIMESPEC_A_LT_B(&temp, &schedule_time)) { |
- /* count the deadline miss */ |
- lev->dline_miss[p]++; |
- kern_event_delete(lev->deadline_timer[p]); |
- } |
- |
- } |
- else { |
-#ifdef EDFSTAR_DEBUG |
- edfstar_printf("e%d",p); |
-#endif |
- |
- /* the task has terminated his job before it consume the wcet. All OK! */ |
- proc_table[p].status = EDFSTAR_IDLE; |
- |
- /* and finally, a preemption check! */ |
- EDFSTAR_check_preemption(lev); |
- |
- /* when the deadline timer fire, it recognize the situation and set |
- correctly all the stuffs (like reactivation, etc... ) */ |
- } |
-#ifdef EDFSTAR_DEBUG |
- edfstar_printf(")"); |
-#endif |
- |
- jet_update_endcycle(); /* Update the Jet data... */ |
- |
- return 0; |
-} |
- |
-static void EDFSTAR_public_end(LEVEL l, PID p) |
-{ |
- EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]); |
- |
-#ifdef EDFSTAR_DEBUG |
- edfstar_printf("(E:end)"); |
-#endif |
- |
- iq_extract(p,&lev->ready); |
- |
- /* we finally put the task in the ready queue */ |
- proc_table[p].status = FREE; |
- |
- iq_insertfirst(p,&freedesc); |
- |
- if (lev->deadline_timer[p] != -1) { |
- kern_event_delete(lev->deadline_timer[p]); |
- } |
- |
- /* and finally, a preemption check! (it will also call guest_end) */ |
- EDFSTAR_check_preemption(lev); |
-} |
- |
-/* Guest Functions |
- These functions manages a JOB_TASK_MODEL, that is used to put |
- a guest task in the EDFSTAR ready queue. */ |
- |
-static void EDFSTAR_private_insert(LEVEL l, PID p, TASK_MODEL *m) |
-{ |
- EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]); |
- JOB_TASK_MODEL *job; |
- |
- if (m->pclass != JOB_PCLASS || (m->level != 0 && m->level != l) ) { |
- kern_raise(XINVALID_TASK, p); |
- return; |
- } |
- |
- job = (JOB_TASK_MODEL *)m; |
- |
- /* if the EDFSTAR_guest_create is called, then the pclass must be a |
- valid pclass. */ |
- |
- *iq_query_timespec(p, &lev->ready) = job->deadline; |
- |
- lev->deadline_timer[p] = -1; |
- lev->dline_miss[p] = 0; |
- lev->wcet_miss[p] = 0; |
- lev->nact[p] = 0; |
- |
- if (job->noraiseexc) |
- lev->flag[p] = EDFSTAR_FLAG_NORAISEEXC; |
- else { |
- lev->flag[p] = 0; |
- lev->deadline_timer[p] = kern_event_post(iq_query_timespec(p, &lev->ready), |
- EDFSTAR_timer_guest_deadline, |
- (void *)p); |
- } |
- |
- lev->period[p] = job->period; |
- |
- /* Insert task in the correct position */ |
- iq_timespec_insert(p,&lev->ready); |
- proc_table[p].status = EDFSTAR_READY; |
- |
- /* check for preemption */ |
- EDFSTAR_check_preemption(lev); |
- |
- /* there is no bandwidth guarantee at this level, it is performed |
- by the level that inserts guest tasks... */ |
-} |
- |
-static void EDFSTAR_private_dispatch(LEVEL l, PID p, int nostop) |
-{ |
- EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]); |
- |
- level_table[ lev->scheduling_level ]-> |
- private_dispatch(lev->scheduling_level,p,nostop); |
-} |
- |
-static void EDFSTAR_private_epilogue(LEVEL l, PID p) |
-{ |
- EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]); |
- |
- /* the task has been preempted. it returns into the ready queue... */ |
- level_table[ lev->scheduling_level ]-> |
- private_epilogue(lev->scheduling_level,p); |
- |
- proc_table[p].status = EDFSTAR_READY; |
-} |
- |
-static void EDFSTAR_private_extract(LEVEL l, PID p) |
-{ |
- EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]); |
- |
-#ifdef EDFSTAR_DEBUG |
- //kern_printf("EDFSTAR_guest_end: dline timer %d\n",lev->deadline_timer[p]); |
-#endif |
- |
- iq_extract(p, &lev->ready); |
- |
- /* we remove the deadline timer, because the slice is finished */ |
- if (lev->deadline_timer[p] != NIL) { |
-#ifdef EDFSTAR_DEBUG |
-// kern_printf("EDFSTAR_guest_end: dline timer %d\n",lev->deadline_timer[p]); |
-#endif |
- kern_event_delete(lev->deadline_timer[p]); |
- lev->deadline_timer[p] = NIL; |
- } |
- |
- /* and finally, a preemption check! (it will also call guest_end() */ |
- EDFSTAR_check_preemption(lev); |
-} |
- |
-/* Registration functions */ |
- |
-/* Registration function: |
- int flags the init flags ... see EDFSTAR.h */ |
-LEVEL EDFSTAR_register_level(int budget, int master) |
-{ |
- LEVEL l; /* the level that we register */ |
- EDFSTAR_level_des *lev; /* for readableness only */ |
- PID i; /* a counter */ |
- |
-#ifdef EDFSTAR_DEBUG |
- printk("EDFSTAR_register_level\n"); |
-#endif |
- |
- /* request an entry in the level_table */ |
- l = level_alloc_descriptor(sizeof(EDFSTAR_level_des)); |
- |
- lev = (EDFSTAR_level_des *)level_table[l]; |
- |
- printk(" lev=%d\n",(int)lev); |
- |
- /* fill the standard descriptor */ |
- lev->l.private_insert = EDFSTAR_private_insert; |
- lev->l.private_extract = EDFSTAR_private_extract; |
- lev->l.private_dispatch = EDFSTAR_private_dispatch; |
- lev->l.private_epilogue = EDFSTAR_private_epilogue; |
- |
- lev->l.public_guarantee = NULL; |
- lev->l.public_eligible = EDFSTAR_public_eligible; |
- lev->l.public_create = EDFSTAR_public_create; |
- lev->l.public_end = EDFSTAR_public_end; |
- lev->l.public_dispatch = EDFSTAR_public_dispatch; |
- lev->l.public_epilogue = EDFSTAR_public_epilogue; |
- lev->l.public_activate = EDFSTAR_public_activate; |
- lev->l.public_unblock = EDFSTAR_public_unblock; |
- lev->l.public_block = EDFSTAR_public_block; |
- lev->l.public_message = EDFSTAR_public_message; |
- |
- /* fill the EDFSTAR descriptor part */ |
- for(i=0; i<MAX_PROC; i++) { |
- lev->period[i] = 0; |
- lev->deadline_timer[i] = -1; |
- lev->flag[i] = 0; |
- lev->dline_miss[i] = 0; |
- lev->wcet_miss[i] = 0; |
- lev->nact[i] = 0; |
- } |
- |
- iq_init(&lev->ready, NULL, IQUEUE_NO_PRIORITY); |
- lev->activated = NIL; |
- |
- lev->budget = budget; |
- lev->scheduling_level = master; |
- |
- return l; |
-} |
- |
-int EDFSTAR_get_dline_miss(PID p) |
-{ |
- LEVEL l = proc_table[p].task_level; |
- EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]); |
- |
- return lev->dline_miss[p]; |
-} |
- |
-int EDFSTAR_get_wcet_miss(PID p) |
-{ |
- LEVEL l = proc_table[p].task_level; |
- EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]); |
- |
- return lev->wcet_miss[p]; |
-} |
- |
-int EDFSTAR_get_nact(PID p) |
-{ |
- LEVEL l = proc_table[p].task_level; |
- EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]); |
- |
- return lev->nact[p]; |
-} |
- |
-int EDFSTAR_reset_dline_miss(PID p) |
-{ |
- LEVEL l = proc_table[p].task_level; |
- EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]); |
- |
- lev->dline_miss[p] = 0; |
- return 0; |
-} |
- |
-int EDFSTAR_reset_wcet_miss(PID p) |
-{ |
- LEVEL l = proc_table[p].task_level; |
- EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]); |
- |
- lev->wcet_miss[p] = 0; |
- return 0; |
-} |
- |
Index: tags/rel_1_22/first/posixstar.c |
=================================================================== |
--- tags/rel_1_22/first/posixstar.c (revision 1310) |
+++ tags/rel_1_22/first/posixstar.c (nonexistent) |
@@ -1,541 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Trimarchi Michael <trimarchi@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: posixstar.c,v 1.3 2003-12-17 13:52:46 giacomo Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.3 $ |
- Last update: $Date: 2003-12-17 13:52:46 $ |
- ------------ |
- |
- This file contains the scheduling module compatible with POSIX |
- specifications |
- |
- Read posixstar.h for further details. |
- |
- RR tasks have the CONTROL_CAP bit set |
- |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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 WARR2ANTY; without even the implied waRR2anty 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
- |
-#include <ll/stdio.h> |
-#include <ll/string.h> |
-#include <kernel/model.h> |
-#include <kernel/descr.h> |
-#include <kernel/var.h> |
-#include <kernel/func.h> |
-#include "posixstar.h" |
-#include "cbsstar.h" |
-//#define POSIXSTAR_DEBUG |
-/*+ Status used in the level +*/ |
-#define POSIXSTAR_READY MODULE_STATUS_BASE |
- |
-/*+ the level redefinition for the Round Robin level +*/ |
-typedef struct { |
- level_des l; /*+ the standard level descriptor +*/ |
- |
- int nact[MAX_PROC]; /*+ number of pending activations +*/ |
- |
- int priority[MAX_PROC]; /*+ priority of each task +*/ |
- |
- IQUEUE *ready; /*+ the ready queue array +*/ |
- |
- int slice; /*+ the level's time slice +*/ |
- |
-// the multiboot is not usefull for this module |
-// struct multiboot_info *multiboot; /*+ used if the level have to insert |
- // the main task +*/ |
- int maxpriority; /*+ the priority are from 0 to maxpriority |
- (i.e 0 to 31) +*/ |
- |
- int yielding; /*+ equal to 1 when a sched_yield is called +*/ |
- |
- int budget; |
- |
- PID activated; |
- int scheduling_level; |
- |
-} POSIXSTAR_level_des; |
- |
-/* the private scheduler choice a task and insert in cbsstar module */ |
-/* This is not efficient but very fair :-) |
- The need of all this stuff is because if a task execute a long time |
- due to (shadow!) priority inheritance, then the task shall go to the |
- tail of the queue many times... */ |
- |
-static void POSIXSTAR_private_scheduler(POSIXSTAR_level_des * lev) |
-{ |
- /* the old posix scheduler select the private job for CBS */ |
- PID p=NIL; |
- |
- int prio; |
- |
- prio = lev->maxpriority; |
- |
- for (;;) { |
- p = iq_query_first(&lev->ready[prio]); |
- if (p == NIL) { |
- if (prio) { |
- prio--; |
- continue; |
- } |
- else { |
- p=NIL; |
- break; |
- } |
- } |
- //if (p != NIL && (proc_table[p].control & CONTROL_CAP)) |
- // kern_printf("CC SET %d",p); |
- |
- //kern_printf("task %d", p); |
- |
- if ((proc_table[p].control & CONTROL_CAP) && |
- (proc_table[p].avail_time <= 0)) { |
- if (proc_table[p].avail_time<=0) |
- proc_table[p].avail_time += proc_table[p].wcet; |
- //kern_printf("RR policy"); |
- iq_extract(p,&lev->ready[prio]); |
- iq_insertlast(p,&lev->ready[prio]); |
- } |
- else { |
- break; |
- } |
- } |
- |
- if (p!=lev->activated) { |
- if (lev->activated != NIL ) { |
- level_table[ lev->scheduling_level ]-> |
- private_extract(lev->scheduling_level, lev->activated); |
- //kern_printf("CBS ext %d",p); |
- } |
- lev->activated = p; |
- |
- if (p != NIL) { |
- BUDGET_TASK_MODEL b; |
- budget_task_default_model(b, lev->budget); |
- //kern_printf("(Act %d",p); |
- level_table[ lev->scheduling_level ]-> |
- private_insert(lev->scheduling_level, p, (TASK_MODEL *)&b); |
- } |
- } |
-} |
- |
-static int POSIXSTAR_public_eligible(LEVEL l, PID p) |
-{ |
- POSIXSTAR_level_des *lev = (POSIXSTAR_level_des *)(level_table[l]); |
- if (p==lev->activated) { |
- //kern_printf("eli %d", p); |
- |
- return level_table[ lev->scheduling_level ]-> |
- private_eligible(lev->scheduling_level,p); |
- } |
- return 0; |
-} |
- |
- |
-static int POSIXSTAR_public_create(LEVEL l, PID p, TASK_MODEL *m) |
-{ |
- POSIXSTAR_level_des *lev = (POSIXSTAR_level_des *)(level_table[l]); |
- NRT_TASK_MODEL *nrt; |
- |
- if (m->pclass != NRT_PCLASS) return -1; |
- if (m->level != 0 && m->level != l) return -1; |
- |
- nrt = (NRT_TASK_MODEL *)m; |
- |
- /* the task state is set at SLEEP by the general task_create */ |
- |
- /* I used the wcet field because using wcet can account if a task |
- consume more than the timeslice... */ |
- |
- if (nrt->inherit == NRT_INHERIT_SCHED && |
- proc_table[exec_shadow].task_level == l) { |
- /* We inherit the scheduling properties if the scheduling level |
- *is* the same */ |
- lev->priority[p] = lev->priority[exec_shadow]; |
- |
- proc_table[p].avail_time = proc_table[exec_shadow].avail_time; |
- proc_table[p].wcet = proc_table[exec_shadow].wcet; |
- |
- proc_table[p].control = (proc_table[p].control & ~CONTROL_CAP) | |
- (proc_table[exec_shadow].control & CONTROL_CAP); |
- |
- lev->nact[p] = (lev->nact[exec_shadow] == -1) ? -1 : 0; |
- } |
- else { |
- if (nrt->weight<=lev->maxpriority) |
- lev->priority[p] = nrt->weight; |
- else lev->priority[p]=lev->maxpriority; |
- |
- if (nrt->slice) { |
- proc_table[p].avail_time = nrt->slice; |
- proc_table[p].wcet = nrt->slice; |
- } |
- else { |
- proc_table[p].avail_time = lev->slice; |
- proc_table[p].wcet = lev->slice; |
- } |
- |
- if (nrt->policy == NRT_RR_POLICY) { |
- proc_table[p].control |= CONTROL_CAP; |
- //kern_printf("CCAP set:%d",p); |
- |
- } |
- if (nrt->arrivals == SAVE_ARRIVALS) |
- lev->nact[p] = 0; |
- else |
- lev->nact[p] = -1; |
- } |
- |
- return 0; /* OK */ |
-} |
- |
-static void POSIXSTAR_public_dispatch(LEVEL l, PID p, int nostop) |
-{ |
- POSIXSTAR_level_des *lev = (POSIXSTAR_level_des *)(level_table[l]); |
- |
- //#ifdef POSIXSTAR_DEBUG |
- |
- //#endif |
- |
- /* the task state is set EXE by the scheduler() |
- we extract the task from the ready queue |
- NB: we can't assume that p is the first task in the queue!!! */ |
- //iq_extract(p, &lev->ready[lev->priority[p]]); |
- //if (!nostop) { |
- //kern_printf("PDisp:%d(%d)",p, lev->activated); |
- if (p==lev->activated) |
- level_table[lev->scheduling_level]->private_dispatch(lev->scheduling_level, p, nostop); |
- //} else |
- // kern_printf("PDisp:%d(%d)",p, lev->activated); |
-} |
- |
-static void POSIXSTAR_public_epilogue(LEVEL l, PID p) |
-{ |
- POSIXSTAR_level_des *lev = (POSIXSTAR_level_des *)(level_table[l]); |
- //#ifdef POSIXSTAR_DEBUG |
- //kern_printf("PEpic:%d",p); |
- //#endif |
- if (p==lev->activated) { |
- if (lev->yielding) { |
- lev->yielding = 0; |
- iq_extract(p,&lev->ready[lev->priority[p]]); |
- iq_insertlast(p,&lev->ready[lev->priority[p]]); |
- } |
- /* check if the slice is finished and insert the task in the coPOSIXect |
- qqueue position */ |
- else if (proc_table[p].control & CONTROL_CAP && |
- proc_table[p].avail_time <= 0) { |
- |
- //proc_table[p].avail_time += proc_table[p].wcet; |
- //kern_printf("avail_time %d", proc_table[p].avail_time); |
- iq_extract(p,&lev->ready[lev->priority[p]]); |
- iq_insertlast(p,&lev->ready[lev->priority[p]]); |
- //level_table[lev->scheduling_level]->private_extract(lev->scheduling_level,p); |
- //lev->activated=NIL; |
- |
- POSIXSTAR_private_scheduler(lev); |
- if (p==lev->activated) |
- level_table[lev->scheduling_level]->private_epilogue(lev->scheduling_level,p); |
- |
- } |
- else { |
- //iq_insertfirst(p,&lev->ready[lev->priority[p]]); |
- level_table[lev->scheduling_level]->private_epilogue(lev->scheduling_level,p); |
- |
- } |
- |
- proc_table[p].status = POSIXSTAR_READY; |
- |
- } |
- |
- |
-} |
- |
-static void POSIXSTAR_internal_activate(POSIXSTAR_level_des *lev, PID p) |
-{ |
- |
- /* Insert task in the correct position */ |
- proc_table[p].status = POSIXSTAR_READY; |
- iq_insertlast(p,&lev->ready[lev->priority[p]]); |
- |
-} |
- |
- |
-static void POSIXSTAR_public_activate(LEVEL l, PID p) |
-{ |
- POSIXSTAR_level_des *lev = (POSIXSTAR_level_des *)(level_table[l]); |
- |
- /* Test if we are trying to activate a non sleeping task */ |
- /* save activation (only if needed...) */ |
- if (proc_table[p].status != SLEEP) { |
- if (lev->nact[p] != -1) |
- lev->nact[p]++; |
- return; |
- } |
-#ifdef POSIXSTAR_DEBUG |
- kern_printf("PA:%d",p); |
-#endif |
- POSIXSTAR_internal_activate(lev, p); |
- POSIXSTAR_private_scheduler(lev); |
- |
-} |
- |
- |
-static void POSIXSTAR_public_unblock(LEVEL l, PID p) |
-{ |
- POSIXSTAR_level_des *lev = (POSIXSTAR_level_des *)(level_table[l]); |
- |
- /* Similar to POSIX_task_activate, but we don't check in what state |
- the task is */ |
- |
- /* Insert task in the coPOSIXect position */ |
- //kern_printf("PU:%d", p); |
- proc_table[p].status = POSIXSTAR_READY; |
- iq_insertlast(p,&lev->ready[lev->priority[p]]); |
- POSIXSTAR_private_scheduler(lev); |
-} |
- |
-static void POSIXSTAR_public_block(LEVEL l, PID p) |
-{ |
- POSIXSTAR_level_des *lev = (POSIXSTAR_level_des *)(level_table[l]); |
- |
- /* Extract the running task from the level |
- . we have already extract it from the ready queue at the dispatch time. |
- . the capacity event have to be removed by the generic kernel |
- . the wcet don't need modification... |
- . the state of the task is set by the calling function |
- |
- So, we do nothing!!! |
- */ |
- |
-//#ifdef POSIXSTAR_DEBUG |
-//kern_printf("PB:%d", p); |
-//#endif |
- iq_extract(p,&lev->ready[lev->priority[p]]); |
- POSIXSTAR_private_scheduler(lev); |
- |
-} |
- |
-static int POSIXSTAR_public_message(LEVEL l, PID p, void *m) |
-{ |
- POSIXSTAR_level_des *lev = (POSIXSTAR_level_des *)(level_table[l]); |
- |
- if (lev->nact[p] > 0) { |
- /* continue!!!! */ |
- lev->nact[p]--; |
- iq_extract(p,&lev->ready[lev->priority[p]]); |
- iq_insertfirst(p,&lev->ready[lev->priority[p]]); |
- proc_table[p].status = POSIXSTAR_READY; |
- } |
- else { |
- proc_table[p].status = SLEEP; |
- |
- } |
- //#ifdef POSIXSTAR_DEBUG |
- kern_printf("PM:%d",p); |
- //#endif |
- POSIXSTAR_private_scheduler(lev); |
- return 0; |
-} |
- |
-static void POSIXSTAR_public_end(LEVEL l, PID p) |
-{ |
- POSIXSTAR_level_des *lev = (POSIXSTAR_level_des *)(level_table[l]); |
-#ifdef POSIXSTAR_DEBUG |
- kern_printf("PEnd:%d", p); |
-#endif |
- lev->nact[p] = -1; |
- |
- /* then, we insert the task in the free queue */ |
- proc_table[p].status = FREE; |
- iq_priority_insert(p,NULL); |
- POSIXSTAR_private_scheduler(lev); |
-} |
- |
-/* Registration functions */ |
- |
-/*+ Registration function: |
- TIME slice the slice for the Round Robin queue |
- struct multiboot_info *mb used if createmain specified +*/ |
-LEVEL POSIXSTAR_register_level(int budget, int master, TIME slice, |
- int prioritylevels) |
-{ |
- LEVEL l; /* the level that we register */ |
- POSIXSTAR_level_des *lev; /* for readableness only */ |
- PID i; /* a counter */ |
- int x; /* a counter */ |
- |
- printk("POSIXSTAR_register_level\n"); |
- |
- l = level_alloc_descriptor(sizeof(POSIXSTAR_level_des)); |
- |
- lev = (POSIXSTAR_level_des *)level_table[l]; |
- |
- printk(" lev=%d\n",(int)lev); |
- |
- /* fill the standard descriptor */ |
- /* |
- lev->l.private_insert = NULL; |
- lev->l.private_extract = NULL; |
- lev->l.private_dispatch = NULL; |
- lev->l.private_epilogue = NULL; |
- */ |
- |
- //lev->l.public_scheduler = NULL; |
- lev->l.public_create = POSIXSTAR_public_create; |
- lev->l.public_end = POSIXSTAR_public_end; |
- lev->l.public_dispatch = POSIXSTAR_public_dispatch; |
- lev->l.public_epilogue = POSIXSTAR_public_epilogue; |
- lev->l.public_activate = POSIXSTAR_public_activate; |
- lev->l.public_unblock = POSIXSTAR_public_unblock; |
- lev->l.public_block = POSIXSTAR_public_block; |
- lev->l.public_message = POSIXSTAR_public_message; |
- lev->l.public_eligible = POSIXSTAR_public_eligible; |
- |
- /* fill the POSIX descriptor part */ |
- for (i = 0; i < MAX_PROC; i++) |
- lev->nact[i] = -1; |
- |
- lev->maxpriority = prioritylevels -1; |
- |
- lev->ready = (IQUEUE *)kern_alloc(sizeof(IQUEUE) * prioritylevels); |
- |
- for (x = 0; x < prioritylevels; x++) |
- iq_init(&lev->ready[x], NULL, 0); |
- |
- if (slice < POSIXSTAR_MINIMUM_SLICE) slice = POSIXSTAR_MINIMUM_SLICE; |
- if (slice > POSIXSTAR_MAXIMUM_SLICE) slice = POSIXSTAR_MAXIMUM_SLICE; |
- lev->slice = slice; |
- lev->activated=NIL; |
- lev->budget = budget; |
- lev->scheduling_level = master; |
- //lev->multiboot = mb; |
- |
- //if (createmain) |
- // sys_atrunlevel(POSIXSTAR_call_main,(void *) l, RUNLEVEL_INIT); |
- |
- return l; |
-} |
- |
-/*+ this function forces the running task to go to his queue tail; |
- (it works only on the POSIX level) +*/ |
-int POSIXSTAR_sched_yield(LEVEL l) |
-{ |
- POSIXSTAR_level_des *lev = (POSIXSTAR_level_des *)(level_table[l]); |
- |
- if (proc_table[exec_shadow].task_level != l) |
- return -1; |
- |
- proc_table[exec_shadow].context = kern_context_save(); |
- lev->yielding = 1; |
- scheduler(); |
- kern_context_load(proc_table[exec_shadow].context); |
- return 0; |
-} |
- |
-/*+ this function returns the maximum level allowed for the POSIX level +*/ |
-int POSIXSTAR_get_priority_max(LEVEL l) |
-{ |
- POSIXSTAR_level_des *lev = (POSIXSTAR_level_des *)(level_table[l]); |
- return lev->maxpriority; |
-} |
- |
-/*+ this function returns the default timeslice for the POSIX level +*/ |
-int POSIXSTAR_rr_get_interval(LEVEL l) |
-{ |
- POSIXSTAR_level_des *lev = (POSIXSTAR_level_des *)(level_table[l]); |
- return lev->slice; |
-} |
- |
-/*+ this functions returns some paramaters of a task; |
- policy must be NRT_RR_POLICY or NRT_FIFO_POLICY; |
- priority must be in the range [0..prioritylevels] |
- returns ENOSYS or ESRCH if there are problems +*/ |
-int POSIXSTAR_getschedparam(LEVEL l, PID p, int *policy, int *priority) |
-{ |
- if (p<0 || p>= MAX_PROC || proc_table[p].status == FREE) |
- return ESRCH; |
- |
- if (proc_table[p].task_level != l) |
- return ENOSYS; |
- |
- if (proc_table[p].control & CONTROL_CAP) |
- *policy = NRT_RR_POLICY; |
- else |
- *policy = NRT_FIFO_POLICY; |
- |
- *priority = ((POSIXSTAR_level_des *)(level_table[l]))->priority[p]; |
- |
- return 0; |
-} |
- |
-/*+ this functions sets paramaters of a task +*/ |
-int POSIXSTAR_setschedparam(LEVEL l, PID p, int policy, int priority) |
-{ |
- POSIXSTAR_level_des *lev = (POSIXSTAR_level_des *)(level_table[l]); |
- |
- if (p<0 || p>= MAX_PROC || proc_table[p].status == FREE) |
- return ESRCH; |
- |
- if (proc_table[p].task_level != l) |
- return ENOSYS; |
- |
- if (policy == SCHED_RR) |
- proc_table[p].control |= CONTROL_CAP; |
- else if (policy == SCHED_FIFO) |
- proc_table[p].control &= ~CONTROL_CAP; |
- else |
- return EINVAL; |
- |
- if (lev->priority[p] != priority) { |
- if (proc_table[p].status == POSIXSTAR_READY) { |
- iq_extract(p,&lev->ready[lev->priority[p]]); |
- lev->priority[p] = priority; |
- iq_insertlast(p,&lev->ready[priority]); |
- } |
- else |
- lev->priority[p] = priority; |
- } |
- |
- return 0; |
-} |
- |
- |
- |
Index: tags/rel_1_22/first/makefile |
=================================================================== |
--- tags/rel_1_22/first/makefile (revision 1310) |
+++ tags/rel_1_22/first/makefile (nonexistent) |
@@ -1,35 +0,0 @@ |
-# |
-# |
- |
-ifndef BASE |
-BASE=../.. |
-endif |
-include $(BASE)/config/config.mk |
- |
-PROGS= test1 test2 test3 test4 test5 test6 test7 testiq |
- |
-include $(BASE)/config/example.mk |
- |
-test1: |
- make -f $(SUBMAKE) APP=test1 INIT= OTHEROBJS="edfstar.o cbsstar.o" OTHERINCL= SHARKOPT=__OLDCHAR__ |
- |
-test2: |
- make -f $(SUBMAKE) APP=test2 INIT= OTHEROBJS="edfstar.o cbsstar.o" OTHERINCL= SHARKOPT=__OLDCHAR__ |
- |
-test3: |
- make -f $(SUBMAKE) APP=test3 INIT= OTHEROBJS="edfstar.o cbsstar.o" OTHERINCL= SHARKOPT=__OLDCHAR__ |
- |
-test4: |
- make -f $(SUBMAKE) APP=test4 INIT= OTHEROBJS="edfstar.o cbsstar.o" OTHERINCL= SHARKOPT=__OLDCHAR__ |
- |
-test5: |
- make -f $(SUBMAKE) APP=test5 INIT= OTHEROBJS="edfstar.o cbsstar.o" OTHERINCL= SHARKOPT=__OLDCHAR__ |
- |
-test6: |
- make -f $(SUBMAKE) APP=test6 INIT= OTHEROBJS="rmstar.o cbsstar.o" OTHERINCL= SHARKOPT=__OLDCHAR__ |
- |
-test7: |
- make -f $(SUBMAKE) APP=test7 INIT= OTHEROBJS="posixstar.o cbsstar.o" OTHERINCL= SHARKOPT=__OLDCHAR__ |
- |
-#testiq: |
-# make -f $(SUBMAKE) APP=testiq INIT= OTHEROBJS="iqueue.o " OTHERINCL= |
Index: tags/rel_1_22/first/iqueue.c |
=================================================================== |
--- tags/rel_1_22/first/iqueue.c (revision 1310) |
+++ tags/rel_1_22/first/iqueue.c (nonexistent) |
@@ -1,221 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- ------------ |
- CVS : $Id: iqueue.c,v 1.1 2002-09-02 10:29:30 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1 $ |
- Last update: $Date: 2002-09-02 10:29:30 $ |
- ------------ |
- |
-*/ |
- |
-/* |
- * Copyright (C) 2002 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include "iqueue.h" |
-#include <kernel/mem.h> |
- |
-void iq_init (IQUEUE *q, IQUEUE *share, int flags) |
-{ |
- q->first = NIL; |
- q->last = NIL; |
- |
- if (share) |
- q->s = share->s; |
- else { |
- q->s = (struct IQUEUE_shared *)kern_alloc(sizeof(struct IQUEUE_shared)); |
- |
- if (!(flags & IQUEUE_NO_PRIORITY)) |
- q->s->priority = (DWORD *)kern_alloc(sizeof(DWORD) * MAX_PROC); |
- if (!(flags & IQUEUE_NO_TIMESPEC)) |
- q->s->timespec_priority = (struct timespec *) |
- kern_alloc(sizeof(struct timespec) * MAX_PROC); |
- } |
-} |
- |
-/*+ |
- This function insert the task with PID i in the queue que. |
- The insertion is made respecting the priority field. |
- (the first item in the queue have the less priority) |
-+*/ |
-void iq_priority_insert (PID i, IQUEUE *que) |
-{ |
- DWORD prio; |
- PID p,q; |
- |
- p = NIL; |
- q = que->first; |
- prio = que->s->priority[i]; |
- |
- while ((q != NIL) && (prio >= que->s->priority[q])) { |
- p = q; |
- q = que->s->next[q]; |
- } |
- |
- if (p != NIL) |
- que->s->next[p] = i; |
- else |
- que->first = i; |
- |
- if (q != NIL) |
- que->s->prev[q] = i; |
- else |
- que->last = i; |
- |
- que->s->next[i] = q; |
- que->s->prev[i] = p; |
-} |
- |
- |
-/* |
- This function insert the task with PID i in the queue que. |
- The insertion is made respecting the timespec priority field. |
- (the first item in the queue have the less priority) |
-*/ |
-void iq_timespec_insert(PID i, IQUEUE *que) |
-{ |
- struct timespec prio; |
- PID p,q; |
- |
- p = NIL; |
- q = que->first; |
- |
- TIMESPEC_ASSIGN(&prio, &que->s->timespec_priority[i]); |
- |
- while ((q != NIL) && |
- !TIMESPEC_A_LT_B(&prio, &que->s->timespec_priority[q])) { |
- p = q; |
- q = que->s->next[q]; |
- } |
- |
- if (p != NIL) |
- que->s->next[p] = i; |
- else |
- que->first = i; |
- |
- if (q != NIL) |
- que->s->prev[q] = i; |
- else |
- que->last = i; |
- |
- que->s->next[i] = q; |
- que->s->prev[i] = p; |
-} |
- |
- |
- |
-void iq_insertfirst(PID p, IQUEUE *q) |
-{ |
- if (q->first != NIL) { |
- q->s->next[p] = q->first; |
- q->s->prev[q->first] = p; |
- } |
- else { |
- q->last = p; |
- q->s->next[p] = NIL; |
- } |
- q->s->prev[p] = NIL; |
- q->first = p; |
-} |
- |
- |
-void iq_insertlast(PID p, IQUEUE *q) |
-{ |
- if (q->last != NIL) { |
- q->s->prev[p] = q->last; |
- q->s->next[q->last] = p; |
- } |
- else { |
- q->first = p; |
- q->s->prev[p] = NIL; |
- } |
- q->s->next[p] = NIL; |
- q->last = p; |
-} |
- |
- |
-void iq_extract(PID i, IQUEUE *que) |
-{ |
- PID p,q; |
- |
- p = que->s->prev[i]; |
- q = que->s->next[i]; |
- |
- if (p != NIL) |
- que->s->next[p] = que->s->next[i]; |
- else |
- que->first = q; |
- |
- if (q != NIL) |
- que->s->prev[q] = que->s->prev[i]; |
- else |
- que->last = p; |
-} |
- |
-PID iq_getfirst(IQUEUE *q) |
-{ |
- PID p = q->first; |
- |
- if (p == NIL) |
- return NIL; |
- |
- q->first = q->s->next[q->first]; |
- |
- if (q->first != NIL) |
- q->s->prev[q->first] = NIL; |
- else |
- q->last = NIL; |
- |
- return p; |
-} |
- |
-PID iq_getlast(IQUEUE *q) |
-{ |
- PID p = q->last; |
- |
- if (p == NIL) |
- return NIL; |
- |
- q->last = q->s->prev[q->last]; |
- |
- if (q->last != NIL) |
- q->s->next[q->last] = NIL; |
- else |
- q->first = NIL; |
- |
- return p; |
-} |
Index: tags/rel_1_22/first/edfstar.h |
=================================================================== |
--- tags/rel_1_22/first/edfstar.h (revision 1310) |
+++ tags/rel_1_22/first/edfstar.h (nonexistent) |
@@ -1,138 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * Massimiliano Giorgi <massy@gandalf.sssup.it> |
- * Luca Abeni <luca@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: edfstar.h,v 1.2 2003-01-07 17:10:17 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.2 $ |
- Last update: $Date: 2003-01-07 17:10:17 $ |
- ------------ |
- |
- Title: |
- EDFSTAR |
- |
- Task Models Accepted: |
- HARD_TASK_MODEL - Hard Tasks (only Periodic) |
- wcet field and mit field must be != 0. They are used to set the wcet |
- and period of the tasks. |
- periodicity field can be only PERIODIC |
- drel field is ignored |
- |
- Guest Models Accepted: |
- JOB_TASK_MODEL - a single guest task activation |
- Identified by an absolute deadline and a period. |
- period field is ignored |
- |
- Description: |
- |
- This module schedule his tasks following the classic EDF |
- scheme. This module is derived from the EDFACT Scheduling Module. |
- |
- This module can not stay alone: when it have to schedule a task, it |
- simply inserts it into another master module using a |
- BUDGET_TASK_MODEL. |
- |
- No Task guarantee is performed at all. |
- The tasks scheduled are only periodic. |
- All the task are put in a queue and the scheduling is based on the |
- deadline value. |
- If a task miss a deadline a counter is incremented. |
- If a task exausts the wcet a counter is incremented |
- No ZOMBIE support!!!!!! |
- |
- Exceptions raised: |
- XUNVALID_GUEST XUNVALID_TASK |
- some primitives are not implemented: |
- task_sleep, task_delay, guest_endcycle, guest_sleep, guest_delay |
- |
- XACTIVATION |
- If a task is actiated through task_activate or guest_activate more than |
- one time |
- |
- Restrictions & special features: |
- - This level doesn't manage the main task. |
- - Functions to return and reset the nact, wcet and dline miss |
- counters are provided |
- |
-**/ |
- |
-/* |
- * Copyright (C) 2001 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
- |
-#ifndef __EDFSTAR_H__ |
-#define __EDFSTAR_H__ |
- |
-#include <ll/ll.h> |
-#include <kernel/config.h> |
-#include <sys/types.h> |
-#include <kernel/types.h> |
- |
- |
- |
-/* flags... */ |
-#define EDFSTAR_ENABLE_GUARANTEE 1 /* Task Guarantee enabled */ |
-#define EDFSTAR_ENABLE_ALL 1 |
- |
-#define EDFSTAR_FAILED_GUARANTEE 8 /* used in the module, unsettabl |
- in EDF_register_level... */ |
- |
- |
- |
-#define EDFSTAR_LEVELNAME "EDFSTAR base" |
-#define EDFSTAR_LEVEL_CODE 166 |
-#define EDFSTAR_LEVEL_VERSION 1 |
- |
- |
-/* Registration function: |
- int budget The budget used by this module (see CBSSTAR.h) |
- int master The master module used by EDFSTAR |
-*/ |
-LEVEL EDFSTAR_register_level(int budget, int master); |
- |
-/* returns respectively the number of dline, wcet or nact; -1 if error */ |
-int EDFSTAR_get_dline_miss(PID p); |
-int EDFSTAR_get_wcet_miss(PID p); |
-int EDFSTAR_get_nact(PID p); |
- |
-/* resets respectively the number of dline, wcet miss; -1 if error */ |
-int EDFSTAR_reset_dline_miss(PID p); |
-int EDFSTAR_reset_wcet_miss(PID p); |
- |
-#endif |
- |
Index: tags/rel_1_22/first/test1.c |
=================================================================== |
--- tags/rel_1_22/first/test1.c (revision 1310) |
+++ tags/rel_1_22/first/test1.c (nonexistent) |
@@ -1,247 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- ------------ |
- CVS : $Id: test1.c,v 1.2 2003-01-07 17:10:17 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.2 $ |
- Last update: $Date: 2003-01-07 17:10:17 $ |
- ------------ |
- |
- this test shows a set of 5 tasks (+main+dummy+keyboard driver). |
- |
- The first 4 tasks are scheduled by a EDFSTAR Module, whereas the |
- fifth one is a standard traditional EDF task. The 4 tasks uses a |
- budget of 10000/100000. |
- |
- if edfstar.c is compiled with edfstar_printf3 active, a couple |
- (dline, curtime) is showed (in ms). |
- |
- if cbsstar.c is compiled with cbsstar_printf3 active, the budget |
- replenishments are showed. |
-*/ |
- |
-/* |
- * Copyright (C) 2002 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/cbs.h" |
-#include "cbsstar.h" |
-#include "edfstar.h" |
-#include "modules/rr.h" |
-#include "modules/dummy.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
- |
-#include "drivers/keyb.h" |
- |
- |
-// -------------------------------------------------- |
-// -------------------------------------------------- |
-// Init Part |
-// -------------------------------------------------- |
-// -------------------------------------------------- |
- |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 0 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 10000 |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- int cbsstar_level, edfstar_level, mybudget; |
- |
- EDF_register_level(EDF_ENABLE_ALL); |
- |
- cbsstar_level = CBSSTAR_register_level(3, 0); |
- mybudget = CBSSTAR_setbudget(cbsstar_level, 10000, 100000); |
- edfstar_level = EDFSTAR_register_level(mybudget, cbsstar_level); |
- |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- // for the keyboard... |
- CBS_register_level(CBS_ENABLE_ALL, 0); |
- |
- SEM_register_module(); |
- |
- CABS_register_module(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- KEYB_PARMS kparms = BASE_KEYB; |
- |
- HARTPORT_init(); |
- |
- //keyb_def_ctrlC(kparms, NULL); |
- //keyb_def_map(kparms,itaMap); |
- KEYB_init(&kparms); |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
-// -------------------------------------------------- |
-// -------------------------------------------------- |
-// The Test |
-// -------------------------------------------------- |
-// -------------------------------------------------- |
- |
- |
-#include <kernel/kern.h> |
-#include <drivers/keyb.h> |
- |
-void *star(void *arg) |
-{ |
- int i,j; |
- |
- for (i=0; i<5; i++) { |
- for (j=0; j<100000; j++); |
- cputc('°'); |
- cputs((char *)arg); |
- task_endcycle(); |
- } |
- |
- return NULL; |
-} |
- |
-void *edftask(void *arg) |
-{ |
- int i,j; |
- |
- for (i=0; i<5; i++) { |
- for (j=0; j<100000; j++); |
- cputc('°'); |
- cputs((char *)arg); |
- task_endcycle(); |
- } |
- |
- return NULL; |
-} |
- |
-void create1() |
-{ |
- HARD_TASK_MODEL m1, m2; |
- PID p1a, p1b, p1c, p1d, p2; |
- |
- hard_task_default_model(m1); |
- hard_task_def_wcet(m1, 5000); |
- hard_task_def_level(m1,2); |
- hard_task_def_group(m1,1); |
- hard_task_def_periodic(m1); |
- |
- hard_task_def_arg(m1,(void *)"a"); |
- hard_task_def_mit(m1,10000); |
- p1a = task_create("a", star, &m1, NULL); |
- if (p1a == -1) { |
- perror("Could not create task a ..."); |
- sys_end(); |
- } |
- |
- hard_task_def_arg(m1,(void *)"b"); |
- hard_task_def_mit(m1,15000); |
- p1b = task_create("b", star, &m1, NULL); |
- if (p1b == -1) { |
- perror("Could not create task b ..."); |
- sys_end(); |
- } |
- |
- hard_task_def_arg(m1,(void *)"c"); |
- hard_task_def_mit(m1,20000); |
- p1c = task_create("c", star, &m1, NULL); |
- if (p1c == -1) { |
- perror("Could not create task c ..."); |
- sys_end(); |
- } |
- |
- hard_task_def_arg(m1,(void *)"d"); |
- hard_task_def_mit(m1,30000); |
- p1d = task_create("d", star, &m1, NULL); |
- if (p1d == -1) { |
- perror("Could not create task d ..."); |
- sys_end(); |
- } |
- |
- hard_task_default_model(m2); |
- hard_task_def_mit(m2,50000); // the budget has dline 100,000! |
- hard_task_def_wcet(m2, 5000); |
- hard_task_def_arg(m2,(void *)"Û"); |
- hard_task_def_group(m2,1); |
- hard_task_def_periodic(m2); |
- |
- p2 = task_create("2", edftask, &m2, NULL); |
- if (p2 == -1) { |
- perror("Could not create task edf ..."); |
- sys_end(); |
- } |
- |
- cprintf("stars=%d %d %d %d, star2=%d\n", p1a, p1b, p1c, p1d, p2); |
- |
- group_activate(1); |
-} |
- |
-int main(int argc, char **argv) |
-{ |
- char c; |
- |
- clear(); |
- |
- cprintf("Hello, world!\nPress ESC to end the demo...\n"); |
- |
- create1(); |
- |
- do { |
- c =keyb_getch(BLOCK); |
- } while (c != ESC); |
- |
- cprintf("ESC pressed!"); |
- |
- sys_end(); |
- |
- return 0; |
-} |
- |
Index: tags/rel_1_22/first/test2.c |
=================================================================== |
--- tags/rel_1_22/first/test2.c (revision 1310) |
+++ tags/rel_1_22/first/test2.c (nonexistent) |
@@ -1,241 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- ------------ |
- CVS : $Id: test2.c,v 1.2 2003-01-07 17:10:17 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.2 $ |
- Last update: $Date: 2003-01-07 17:10:17 $ |
- ------------ |
- |
- The purpose of this test is to show that two budgets with different |
- period and capacity schedules correctly. |
- |
- 4 periodic tasks are involved |
-*/ |
- |
-/* |
- * Copyright (C) 2002 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/cbs.h" |
-#include "cbsstar.h" |
-#include "edfstar.h" |
-#include "modules/rr.h" |
-#include "modules/dummy.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
- |
-#include "drivers/keyb.h" |
- |
- |
-// -------------------------------------------------- |
-// -------------------------------------------------- |
-// Init Part |
-// -------------------------------------------------- |
-// -------------------------------------------------- |
- |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 0 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 10000 |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- int cbsstar_level, edfstar_level, edfstar_level2, mybudget, mybudget2; |
- clear(); |
- EDF_register_level(EDF_ENABLE_ALL); |
- |
- cbsstar_level = CBSSTAR_register_level(3, 0); |
- |
- mybudget = CBSSTAR_setbudget(cbsstar_level, 1000, 50000); |
- edfstar_level = EDFSTAR_register_level(mybudget, cbsstar_level); |
- |
- mybudget2 = CBSSTAR_setbudget(cbsstar_level, 10000, 25000); |
- edfstar_level2 = EDFSTAR_register_level(mybudget2, cbsstar_level); |
- |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- cprintf("edfstar_level=%d, edfstar_level2=%d\n", |
- edfstar_level,edfstar_level2); |
- |
- // for the keyboard... |
- CBS_register_level(CBS_ENABLE_ALL, 0); |
- |
- SEM_register_module(); |
- |
- CABS_register_module(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- KEYB_PARMS kparms = BASE_KEYB; |
- |
- HARTPORT_init(); |
- |
- KEYB_init(&kparms); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
-// -------------------------------------------------- |
-// -------------------------------------------------- |
-// The Test |
-// -------------------------------------------------- |
-// -------------------------------------------------- |
- |
- |
-#include <kernel/kern.h> |
-#include <drivers/keyb.h> |
- |
-void *star(void *arg) |
-{ |
- int i,j,z; |
- |
- for (i=0; i<100; i++) { |
- for (z=0; z<5; z++) { |
- for (j=0; j<60000; j++); |
- cputs((char *)arg); |
- } |
- task_endcycle(); |
- } |
- |
- return NULL; |
-} |
- |
-// version for the "slow" budget |
-void *slow(void *arg) |
-{ |
- int i,j,z; |
- |
- for (i=0; i<15; i++) { |
- for (z=0; z<5; z++) { |
- for (j=0; j<200000; j++); |
- cputs((char *)arg); |
- } |
- task_endcycle(); |
- } |
- |
- return NULL; |
-} |
- |
-void create1() |
-{ |
- HARD_TASK_MODEL m1; |
- PID p1a, p1b, p1c, p1d; |
- |
- hard_task_default_model(m1); |
- hard_task_def_wcet(m1, 5000); |
- hard_task_def_group(m1,1); |
- hard_task_def_periodic(m1); |
- |
- |
- |
- |
- hard_task_def_level(m1,2); |
- |
- hard_task_def_arg(m1,(void *)"."); |
- hard_task_def_mit(m1,5000); |
- p1a = task_create("a", slow, &m1, NULL); |
- if (p1a == -1) { |
- perror("Could not create task a ..."); |
- sys_end(); |
- } |
- |
- hard_task_def_arg(m1,(void *)","); |
- hard_task_def_mit(m1,5000); |
- p1b = task_create("b", slow, &m1, NULL); |
- if (p1b == -1) { |
- perror("Could not create task b ..."); |
- sys_end(); |
- } |
- |
- |
- |
- |
- hard_task_def_level(m1,3); |
- |
- hard_task_def_arg(m1,(void *)"o"); |
- hard_task_def_mit(m1,5000); |
- p1c = task_create("c", star, &m1, NULL); |
- if (p1c == -1) { |
- perror("Could not create task c ..."); |
- sys_end(); |
- } |
- |
- hard_task_def_arg(m1,(void *)"O"); |
- hard_task_def_mit(m1,5000); |
- p1d = task_create("d", star, &m1, NULL); |
- if (p1d == -1) { |
- perror("Could not create task d ..."); |
- sys_end(); |
- } |
- |
- group_activate(1); |
-} |
- |
-int main(int argc, char **argv) |
-{ |
- char c; |
- |
- cprintf("Hello, world!"); |
- |
- create1(); |
- |
- do { |
- c =keyb_getch(BLOCK); |
- } while (c != ESC); |
- |
- cprintf("ESC pressed!"); |
- |
- sys_end(); |
- |
- return 0; |
-} |
- |
Index: tags/rel_1_22/first/cbsstar.c |
=================================================================== |
--- tags/rel_1_22/first/cbsstar.c (revision 1310) |
+++ tags/rel_1_22/first/cbsstar.c (nonexistent) |
@@ -1,674 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * Massimiliano Giorgi <massy@gandalf.sssup.it> |
- * Luca Abeni <luca@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- ------------ |
- CVS : $Id: cbsstar.c,v 1.6 2003-08-01 13:20:38 trimarchi Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.6 $ |
- Last update: $Date: 2003-08-01 13:20:38 $ |
- ------------ |
- |
- Read CBSSTAR.h for general details. |
- |
- Basically, a budget can be in 2 states: |
- - Active -> the budget queue is not empty |
- - Idle -> the budget queue is empty |
- |
- The fact that a task into a budget is inserted into the master module depends |
- on the value of the remaining time the tasks can spend in the period. |
- |
- The module does handle only one oslib event, used to enforce the |
- temporal isolation between buffers. Note that all is implemented |
- without using the CONTROL_CAP field. |
- |
- Basically, for each budget there can be at most one task inserted |
- into the master level. Its deadline is modified according to the |
- usage of its capacity, that is, when a budget is exausted its |
- deadline is postponed. |
- |
-*/ |
- |
-/* |
- * Copyright (C) 2002 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
- |
-#include "cbsstar.h" |
-#include <ll/string.h> |
- |
-#define ACTIVE 1 |
-#define NOACTIVE 0 |
-#define INIT 2 |
- |
-#define CBSSTAR_IDLE APER_STATUS_BASE |
-/* |
- * DEBUG stuffs begin |
- */ |
- |
-//#define CBSSTAR_DEBUG |
-int event_monitor; |
-#ifdef CBSSTAR_DEBUG |
- |
- |
-static __inline__ void fake_printf(char *fmt, ...) {} |
- |
-//#define cbsstar_printf kern_printf |
-//#define cbsstar_printf2 kern_printf |
-//#define cbsstar_printf3 kern_printf |
- |
-#define cbsstar_printf fake_printf |
-#define cbsstar_printf2 fake_printf |
-#define cbsstar_printf3 fake_printf |
- |
-#if 0 |
-void cbsstar_printq(QQUEUE *q) |
-{ |
- PID p; |
- kern_printf("["); |
- p = q->first; |
- kern_printf("->%d",p); |
- while (p != NIL) { |
- p = proc_table[p].next; |
- kern_printf("->%d",p); |
- } |
- kern_printf("]"); |
-} |
-#else |
-static __inline__ void cbsstar_printq(QQUEUE *q) {} |
-#endif |
- |
-#if 0 |
-static __inline__ void cbsstar_printblob(int x) { if (x) cputc('±'); else cputc('Û'); } |
-#else |
-static __inline__ void cbsstar_printblob(int x) {} |
-#endif |
- |
-#endif |
- |
-/* |
- * DEBUG stuffs end |
- */ |
-/*+ Status used in the level +*/ |
-#define CBSSTAR_WAIT APER_STATUS_BASE /*+ waiting the service +*/ |
- |
-/* this structure contains the status for a single budget */ |
-struct budget_struct { |
- TIME Q; /* budget */ |
- TIME T; /* period */ |
- |
- struct timespec dline; /* deadline */ |
- int dline_timer; /* oslib event for budget reactivation*/ |
- int avail; /* current budget */ |
- |
- PID current; /* the task currently put in execution */ |
- |
- int flags; |
- |
- IQUEUE tasks; /* a FIFO queue for the tasks handled |
- using the budget */ |
-}; |
- |
-typedef struct { |
- level_des l; /* the standard level descriptor */ |
- |
- struct budget_struct *b; /* the budgets! */ |
- int n; /* the maximum index for the budgets */ |
- int freebudgets; /* number of free budgets; starts from n */ |
- |
- int tb[MAX_PROC]; /* link task->budget (used in guest_end) */ |
- |
- bandwidth_t U; /*+ the used bandwidth by the server +*/ |
- |
- int cap_lev; |
- |
- PID on_shadow; |
- |
- LEVEL scheduling_level; |
- |
-} CBSSTAR_level_des; |
- |
- |
-static void CBSSTAR_deadline_timer_hardreservation(void *a) |
-{ |
- struct budget_struct *b = a; |
- struct timespec t; |
- |
- //kern_printf("*********** %d", b->dline_timer); |
- b->dline_timer=NIL; |
- /* we modify the deadline according to rule 4 ... */ |
- /* there is a while because if the wcet is << than the system tick |
- we need to postpone the deadline many times */ |
- if (b->avail<=0) { |
- b->avail += b->Q; |
- if (b->avail>b->Q) b->avail=b->Q; |
- |
- //kern_printf("budget recharge %d", b); |
- } |
- |
- if (b->avail>0) b->flags=ACTIVE; |
- |
- /* avail may be <0 because a task executed via a shadow fo many time |
- b->current == NIL only if the prec task was finished and there |
- was not any other task to be put in the ready queue |
- ... we are now activating the next task */ |
- if (b->current == NIL && b->flags) { |
- if (iq_query_first(&(b->tasks)) != NIL) { |
- //struct timespec t; |
- CBSSTAR_level_des *lev; |
- PID p; |
- JOB_TASK_MODEL job; |
- //kern_gettime(&t); |
- //TIMESPEC_ASSIGN(&b->dline, &schedule_time); |
- //ADDUSEC2TIMESPEC(b->T, &b->dline); |
- kern_gettime(&t); |
- TIMESPEC_ASSIGN(&b->dline, &t); |
- ADDUSEC2TIMESPEC(b->T, &b->dline); |
- |
- p = iq_getfirst(&(b->tasks)); |
- b->current=p; |
- lev = (CBSSTAR_level_des *)(level_table[proc_table[p].task_level]); |
- //kern_printf("reinsert task p = %d lev = %d ",p,proc_table[p].task_level); |
- /* and, finally, we reinsert the task in the master level */ |
- job_task_default_model(job, b->dline); |
- job_task_def_noexc(job); |
- //kern_printf("(CR:iact p%d %ld.%ld av=%d)",p,b->dline.tv_sec,b->dline.tv_nsec/1000, b->avail); |
- //kern_printf("**"); |
- level_table[ lev->scheduling_level ]-> |
- private_insert(lev->scheduling_level, p, (TASK_MODEL *)&job); |
- |
- event_need_reschedule(); |
- } |
- } else |
- if (b->current !=NIL && b->avail>0) { |
- kern_printf("(cap&nil "); |
- } |
- if (b->flags==NOACTIVE && b->dline_timer!=NIL){ |
- kern_gettime(&t); |
- TIMESPEC_ASSIGN(&b->dline, &t); |
- ADDUSEC2TIMESPEC(b->T, &b->dline); |
- |
- b->dline_timer=kern_event_post(&b->dline, CBSSTAR_deadline_timer_hardreservation, b); |
- event_monitor=b->dline_timer; |
- //kern_printf("(dline hard %ld.%ld ev %d)",b->dline.tv_sec,b->dline.tv_nsec/1000, b->dline_timer); |
- } |
-} |
-static void CBSSTAR_activation(CBSSTAR_level_des *lev, |
- PID p, |
- struct timespec *acttime) |
-{ |
- JOB_TASK_MODEL job; |
- struct budget_struct *b = &lev->b[lev->tb[p]]; |
- /* we have to check if the deadline and the wcet are correct before |
- activating a new task or an old task... */ |
- |
- /* check 1: if the deadline is before than the actual scheduling time */ |
- |
- /* check 2: if ( avail_time >= (cbs_dline - acttime)* (wcet/period) ) |
- (rule 7 in the CBS article!) */ |
- TIME t; |
- struct timespec t2,t3; |
- |
- t = (b->T * b->avail) / b->Q; |
- t3.tv_sec = t / 1000000; |
- t3.tv_nsec = (t % 1000000) * 1000; |
- |
- SUBTIMESPEC(&b->dline, acttime, &t2); |
- if (/* 1 */ TIMESPEC_A_LT_B(&b->dline, acttime) || |
- /* 2 */ TIMESPEC_A_GT_B(&t3, &t2) ) { |
- TIMESPEC_ASSIGN(&b->dline, acttime); |
- ADDUSEC2TIMESPEC(b->T, &b->dline); |
- } |
- |
- /* and the capacity */ |
- if (b->flags==INIT) { |
- b->avail = b->Q; |
- b->flags=ACTIVE; |
- } |
- |
- |
-#ifdef CBSSTAR_DEBUG |
- cbsstar_printf3("±%d±",lev->tb[p]); |
- cbsstar_printblob(lev->tb[p]); |
-#endif |
- //} |
- //#endif |
- |
- /* record the current task inserted in the master module */ |
- b->current = p; |
- |
- //#ifdef CBSSTAR_DEBUG |
- //kern_printf("(CA:iact p%d %ld.%ld av=%d at=%ld.%ld)",p,b->dline.tv_sec,b->dline.tv_nsec/1000, b->avail, acttime->tv_sec, acttime->tv_nsec/1000); |
- //#endif |
- /* and, finally, we reinsert the task in the master level */ |
- job_task_default_model(job, b->dline); |
- job_task_def_noexc(job); |
- level_table[ lev->scheduling_level ]-> |
- private_insert(lev->scheduling_level, p, (TASK_MODEL *)&job); |
- //b->dline_timer=kern_event_post(&b->dline, CBSSTAR_deadline_timer_hardreservation, b); |
-} |
- |
-static void CBSSTAR_account_capacity(CBSSTAR_level_des *lev, PID p) |
-{ |
- struct timespec ty; |
- TIME tx; |
- struct budget_struct *b = &lev->b[lev->tb[p]]; |
- TIME t; |
- struct timespec t2,t3, acttime; |
- |
- if (lev->cap_lev!=NIL && b->current==p) { |
- kern_event_delete(lev->cap_lev); |
- lev->cap_lev=NIL; |
- } |
- |
- kern_gettime(&acttime); |
- t = (b->T * b->avail) / b->Q; |
- t3.tv_sec = t / 1000000; |
- t3.tv_nsec = (t % 1000000) * 1000; |
- |
- SUBTIMESPEC(&b->dline, &acttime, &t2); |
- |
- SUBTIMESPEC(&schedule_time, &cap_lasttime, &ty); |
- tx = TIMESPEC2USEC(&ty); |
- lev->b[lev->tb[p]].avail -= tx; |
- |
-#ifdef CBSSTAR_DEBUG |
- cbsstar_printf2("(C:cap p%d av=%d)", p, lev->b[lev->tb[p]].avail); |
-#endif |
- if (lev->b[lev->tb[p]].avail<=0 || TIMESPEC_A_GT_B(&t3, &t2)) lev->b[lev->tb[p]].flags=NOACTIVE; |
- |
- if ( TIMESPEC_A_LT_B(&b->dline, &schedule_time) ) { |
- |
- /* we modify the deadline ... */ |
- TIMESPEC_ASSIGN(&b->dline, &schedule_time); |
- ADDUSEC2TIMESPEC(b->T, &b->dline); |
- } |
- |
- //if (b->flags==NOACTIVE && b->dline_timer!=NIL) |
- // kern_printf("flags %d, dline_timer %d", b->flags, b->dline_timer); |
- |
- if (b->flags==NOACTIVE && b->dline_timer==NIL) { |
- b->dline_timer=kern_event_post(&b->dline, CBSSTAR_deadline_timer_hardreservation, b); |
- event_monitor=b->dline_timer; |
- //kern_printf("(dline %ld.%ld ev %d)",b->dline.tv_sec,b->dline.tv_nsec/1000, b->dline_timer); |
- } |
- |
- |
-} |
- |
- |
-/* The on-line guarantee is enabled only if the appropriate flag is set... */ |
-static int CBSSTAR_public_guarantee(LEVEL l, bandwidth_t *freebandwidth) |
-{ |
- CBSSTAR_level_des *lev = (CBSSTAR_level_des *)(level_table[l]); |
- |
-#ifdef CBSSTAR_DEBUG |
- cbsstar_printf("(C:gua)"); |
-#endif |
- |
- if (*freebandwidth >= lev->U) { |
- *freebandwidth -= lev->U; |
- return 1; |
- } |
- else |
- return 0; |
-} |
- |
-static void capacity_handler(void *l) |
-{ |
- //kern_printf("!"); |
- CBSSTAR_level_des *lev =l; |
- lev->cap_lev=NIL; |
- event_need_reschedule(); |
- |
-} |
- |
-static int CBSSTAR_private_eligible(LEVEL l, PID p) |
-{ |
- CBSSTAR_level_des *lev = (CBSSTAR_level_des *)(level_table[l]); |
- struct budget_struct *b = &lev->b[lev->tb[p]]; |
- JOB_TASK_MODEL job; |
- |
-#ifdef CBSSTAR_DEBUG |
- //kern_printf("(C:eli %d",p); |
-#endif |
- |
- /* we have to check if the deadline and the wcet are correct... |
- if the CBSSTAR level schedules in background with respect to others |
- levels, there can be the case in witch a task is scheduled by |
- schedule_time > CBSSTAR_deadline; in this case (not covered in the |
- article because if there is only the standard scheduling policy |
- this never apply) we reassign the deadline */ |
- if (b->current==p) { |
- if ( TIMESPEC_A_LT_B(&b->dline, &schedule_time)) { |
- if (lev->cap_lev!=NIL) { |
- kern_event_delete(lev->cap_lev); |
- lev->cap_lev=NIL; |
- } |
- |
- /* we kill the current activation */ |
- level_table[ lev->scheduling_level ]-> |
- private_extract(lev->scheduling_level, p); |
- /* we modify the deadline ... */ |
- TIMESPEC_ASSIGN(&b->dline, &schedule_time); |
- ADDUSEC2TIMESPEC(b->T, &b->dline); |
- |
- /* and the capacity */ |
- b->avail = b->Q; |
- b->flags=ACTIVE; |
- |
- if (b->dline_timer!=NIL) { |
- kern_event_delete(b->dline_timer); |
- b->dline_timer=NIL; |
- } |
- |
- //#ifdef CBSSTAR_DEBUG |
- //kern_printf(" %ld.%ld av=%d)",b->dline.tv_sec,b->dline.tv_nsec/1000, b->Q); |
- //cbsstar_printf3("±%d±",lev->tb[p]); |
- //cbsstar_printblob(lev->tb[p]); |
- //#endif |
- |
- /* and, finally, we reinsert the task in the master level */ |
- job_task_default_model(job, b->dline); |
- job_task_def_noexc(job); |
- //kern_printf("(CE:iact p%d %ld.%ld av=%d)",p,b->dline.tv_sec,b->dline.tv_nsec/1000, b->avail); |
- level_table[ lev->scheduling_level ]-> |
- private_insert(lev->scheduling_level, p, (TASK_MODEL *)&job); |
- //kern_printf("task %d, avail %d", p, b->avail); |
- return -1; |
- } |
-} |
-#ifdef CBSSTAR_DEBUG |
- cbsstar_printf(")"); |
-#endif |
- |
- return 0; |
-} |
- |
-static void CBSSTAR_private_insert(LEVEL l, PID p, TASK_MODEL *m) |
-{ |
- /* A task has been activated for some reason. Basically, the task is |
- inserted in the queue if the queue is empty, otherwise the task is |
- inserted into the master module, and an oslib event is posted. */ |
- |
- CBSSTAR_level_des *lev = (CBSSTAR_level_des *)(level_table[l]); |
- BUDGET_TASK_MODEL *budget; |
- |
- if (m->pclass != BUDGET_PCLASS || |
- (m->level != 0 && m->level != l)) { |
- kern_raise(XINVALID_TASK, p); |
- return; |
- } |
- budget = (BUDGET_TASK_MODEL *)m; |
- |
-#ifdef CBSSTAR_DEBUG |
- cbsstar_printf("(C:gcr %d b%d", p, budget->b); |
-#endif |
- |
- lev->tb[p] = budget->b; |
- |
- if (lev->b[budget->b].current == NIL && lev->b[budget->b].flags ) { |
- /* This is the first task in the budget, |
- the task have to be inserted into the master module */ |
- struct timespec t; |
- kern_gettime(&t); |
- CBSSTAR_activation(lev,p,&t); |
- } else { |
- /* The budget is not empty, another task is already into the |
- master module, so the task is inserted at the end of the budget |
- queue */ |
- iq_insertlast(p,&lev->b[budget->b].tasks); |
-//#ifdef CBSSTAR_DEBUG |
- //kern_printf(" ilast flag %d task %d",lev->b[budget->b].flags,lev->b[budget->b].current); |
- // cbsstar_printq(&lev->b[budget->b].tasks); |
-//#endif |
- } |
-#ifdef CBSSTAR_DEBUG |
- cbsstar_printf(")"); |
-#endif |
-} |
- |
-static void CBSSTAR_private_extract(LEVEL l, PID p) |
-{ |
- CBSSTAR_level_des *lev = (CBSSTAR_level_des *)(level_table[l]); |
- |
-//#ifdef CBSSTAR_DEBUG |
- //kern_printf("(C:gend p%d c%d av=%d)", p, lev->b[lev->tb[p]].current, lev->b[lev->tb[p]].avail); |
- //cbsstar_printq(&lev->b[lev->tb[p]].tasks); |
-//#endif |
- |
- /* a task is removed from execution for some reasons. It must be |
- that it is the first in its budget queue (only the first task in |
- a budget queue is put into execution!) */ |
- |
- /* remove the task from execution (or from the ready queue) */ |
- if (lev->b[lev->tb[p]].current == p) { |
- |
- CBSSTAR_account_capacity(lev,p); |
- /* remove the task from the master module */ |
- level_table[ lev->scheduling_level ]-> |
- private_extract(lev->scheduling_level, p); |
- |
-#ifdef CBSSTAR_DEBUG |
- cbsstar_printq(&lev->b[lev->tb[p]].tasks); |
-#endif |
- |
- /* check if the buffer has someone else to schedule */ |
- if (iq_query_first(&lev->b[lev->tb[p]].tasks) == NIL) { |
- /* the buffer has no tasks! */ |
- lev->b[lev->tb[p]].current = NIL; |
- } |
- else if (lev->b[lev->tb[p]].flags) { |
- /* if so, insert the new task into the master module */ |
- PID n; |
- struct timespec t; |
- |
- kern_gettime(&t); |
- n = iq_getfirst(&lev->b[lev->tb[p]].tasks); |
-//#ifdef CBSSTAR_DEBUG |
- //kern_printf("{p%d n%d}",p,n); |
-//#endif |
- CBSSTAR_activation(lev,n,&t); // it modifies b[lev->tb[p]].current |
- } |
- else |
- lev->b[lev->tb[p]].current=NIL; |
- |
- } |
- else { |
- iq_extract(p, &lev->b[lev->tb[p]].tasks); |
- } |
-} |
- |
-static void CBSSTAR_private_dispatch(LEVEL l, PID p, int nostop) |
-{ |
- CBSSTAR_level_des *lev = (CBSSTAR_level_des *)(level_table[l]); |
- struct timespec ty; |
- |
-//#ifdef CBSSTAR_DEBUG |
- //kern_printf("(C:gdisp p%d c%d av=%d)", p, lev->b[lev->tb[p]].current, lev->b[lev->tb[p]].avail); |
-// cbsstar_printq(&lev->b[lev->tb[p]].tasks); |
-//#endif |
- |
- /* the current task (that is the only one inserted in the master module |
- for the corresponding budget) is dispatched. Note that the current |
- task is not inserted in any FIFO queue, so the task does not have to |
- be extracted! */ |
- |
- /* ... then, we dispatch it to the master level */ |
- level_table[ lev->scheduling_level ]-> |
- private_dispatch(lev->scheduling_level,p,nostop); |
- |
- /* ...and finally, we have to post a capacity event */ |
- if (!nostop) { |
- TIMESPEC_ASSIGN(&ty, &schedule_time); |
- ADDUSEC2TIMESPEC(lev->b[lev->tb[p]].avail,&ty); |
- lev->cap_lev = kern_event_post(&ty,capacity_handler, lev); |
- } |
- |
-} |
- |
-static void CBSSTAR_private_epilogue(LEVEL l, PID p) |
-{ |
- CBSSTAR_level_des *lev = (CBSSTAR_level_des *)(level_table[l]); |
- struct budget_struct *b = &lev->b[lev->tb[p]]; |
- |
- |
- //#ifdef CBSSTAR_DEBUG |
- //kern_printf("(C:gepi %d %d",p, b->current); |
- //#endif |
- |
- if (p==b->current) { |
- |
- CBSSTAR_account_capacity(lev,p); |
- |
- // L'evento di capacità va cancellato perchè sarà ripristinato nella successiva dispatch |
- /* we have to check if the capacity is still available */ |
- if (b->flags) { |
- /* there is capacity available, maybe it is simply a preemption; |
- the task have to return to the ready queue */ |
- level_table[ lev->scheduling_level ]-> |
- private_epilogue(lev->scheduling_level,p); |
-#ifdef CBSSTAR_DEBUG |
- //kern_printf("(ep *av=%d", b->avail); |
-#endif |
- |
- |
- } else { |
- /* we kill the current activation */ |
- level_table[ lev->scheduling_level ]-> |
- private_extract(lev->scheduling_level, p); |
- //kern_printf("extract"); |
- iq_insertfirst(p, &b->tasks); |
- proc_table[p].status = CBSSTAR_IDLE; |
- b->current = NIL; |
- |
- //kern_printf("budget finish %d", b); |
- } |
-#ifdef CBSSTAR_DEBUG |
- cbsstar_printf(")"); |
-#endif |
- } |
- |
-} |
- |
-/* Registration functions }*/ |
- |
-/*+ Registration function: |
- int flags the init flags ... see CBSSTAR.h +*/ |
-LEVEL CBSSTAR_register_level(int n, LEVEL master) |
-{ |
- LEVEL l; /* the level that we register */ |
- CBSSTAR_level_des *lev; /* for readableness only */ |
- PID i; /* a counter */ |
- |
-#ifdef CBSSTAR_DEBUG |
- cbsstar_printf("CBSSTAR_register_level\n"); |
-#endif |
- |
- /* request an entry in the level_table */ |
- l = level_alloc_descriptor(sizeof(CBSSTAR_level_des)); |
- |
- lev = (CBSSTAR_level_des *)level_table[l]; |
- |
- printk(" lev=%d\n",(int)lev); |
- |
- /* fill the standard descriptor */ |
- lev->l.private_insert = CBSSTAR_private_insert; |
- lev->l.private_extract = CBSSTAR_private_extract; |
- lev->l.private_eligible = CBSSTAR_private_eligible; |
- lev->l.private_dispatch = CBSSTAR_private_dispatch; |
- lev->l.private_epilogue = CBSSTAR_private_epilogue; |
- |
- lev->l.public_guarantee = CBSSTAR_public_guarantee; |
- |
- /* fill the CBSSTAR descriptor part */ |
- lev->b = (struct budget_struct *)kern_alloc(sizeof(struct budget_struct)*n); |
- |
- for (i=0; i<n; i++) { |
- lev->b[i].Q = 0; |
- lev->b[i].T = 0; |
- NULL_TIMESPEC(&lev->b[i].dline); |
- lev->b[i].dline_timer = NIL; |
- lev->b[i].avail = 0; |
- lev->b[i].current = -1; |
- lev->b[i].flags=INIT; |
- iq_init(&lev->b[i].tasks, &freedesc, 0); |
- } |
- |
- lev->n = n; |
- lev->freebudgets = 0; |
- |
- for (i=0; i<MAX_PROC; i++) |
- lev->tb[i] = NIL; |
- |
- lev->U = 0; |
- lev->cap_lev=NIL; |
- lev->scheduling_level = master; |
- lev->on_shadow=NIL; |
- |
- return l; |
-} |
- |
-int CBSSTAR_setbudget(LEVEL l, TIME Q, TIME T) |
-{ |
- CBSSTAR_level_des *lev = (CBSSTAR_level_des *)(level_table[l]); |
- |
-#ifdef CBSSTAR_DEBUG |
- cbsstar_printf("(C:sbud)"); |
-#endif |
- |
- if (lev->freebudgets != lev->n) { |
- bandwidth_t b; |
- b = (MAX_BANDWIDTH / T) * Q; |
- |
- /* really update lev->U, checking an overflow... */ |
- if (Q< T && MAX_BANDWIDTH - lev->U > b) { |
- int r = lev->freebudgets; // the return value |
- |
- lev->U += b; |
- lev->freebudgets++; |
- |
- lev->b[r].Q = Q; |
- lev->b[r].T = T; |
- |
- return r; |
- } |
- else |
- return -2; |
- } |
- else |
- return -1; |
-} |
Index: tags/rel_1_22/first/posixstar.h |
=================================================================== |
--- tags/rel_1_22/first/posixstar.h (revision 1310) |
+++ tags/rel_1_22/first/posixstar.h (nonexistent) |
@@ -1,142 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * Massimiliano Giorgi <massy@gandalf.sssup.it> |
- * Luca Abeni <luca@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
- |
-/** |
- ------------ |
- CVS : $Id: posixstar.h,v 1.1 2003-06-18 08:13:53 trimarchi Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1 $ |
- Last update: $Date: 2003-06-18 08:13:53 $ |
- ------------ |
- |
- This file contains the scheduling module compatible with POSIX |
- specifications |
- |
- Title: |
- POSIX version 1 |
- |
- Task Models Accepted: |
- NRT_TASK_MODEL - Non-Realtime Tasks |
- weight field is ignored |
- slice field is used to set the slice of a task, if it is !=0 |
- policy field is ignored |
- inherit field is ignored |
- |
- Description: |
- This module schedule his tasks following the POSIX specifications... |
- |
- A task can be scheduled in a Round Robin way or in a FIFO way. |
- The tasks have also a priority field. |
- |
- The slices can be different one task from one another. |
- |
- The module can SAVE or SKIP activations |
- |
- Exceptions raised: |
- XUNVALID_GUEST |
- This level doesn't support guests. When a guest operation |
- is called, the exception is raised. |
- |
- Restrictions & special features: |
- - if specified, it creates at init time a task, |
- called "Main", attached to the function __init__(). |
- - There must be only one module in the system that creates a task |
- attached to the function __init__(). |
- - The level tries to guarantee that a RR task uses a "full" timeslice |
- before going to the queue tail. "full" means that a task can execute |
- a maximum time of slice+sys_tick due to the approx. done by |
- the Virtual Machine. If a task execute more time than the slice, |
- the next time it execute less... |
- |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
- |
-#ifndef __POSIXSTAR_H__ |
-#define __POSIXSTAR_H__ |
- |
-#include <ll/ll.h> |
-#include <kernel/config.h> |
-#include <sys/types.h> |
-#include <kernel/types.h> |
-//#define POSIXSTAR_DEBUG |
- |
-/*+ Const: +*/ |
-#define POSIXSTAR_MINIMUM_SLICE 1000 /*+ Minimum Timeslice +*/ |
-#define POSIXSTAR_MAXIMUM_SLICE 500000 /*+ Maximum Timeslice +*/ |
- |
-/*+ Registration function: |
- TIME slice the slice for the Round Robin queue |
- int createmain 1 if the level creates the main task 0 otherwise |
- struct multiboot_info *mb used if createmain specified |
- |
- returns the level number at which the module has been registered. |
-+*/ |
-LEVEL POSIXSTAR_register_level(int budget, int master, TIME slice, |
- int prioritylevels); |
- |
-/*+ this function forces the running task to go to his queue tail, |
- then calls the scheduler and changes the context |
- (it works only on the POSIX level) +*/ |
-int POSIXSTAR_sched_yield(LEVEL l); |
- |
-/* the following functions have to be called with interruptions DISABLED! */ |
- |
-/*+ this function returns the maximum level allowed for the POSIX level +*/ |
-int POSIXSTAR_get_priority_max(LEVEL l); |
- |
-/*+ this function returns the default timeslice for the POSIX level +*/ |
-int POSIXSTAR_rr_get_interval(LEVEL l); |
- |
-/*+ this functions returns some paramaters of a task; |
- policy must be NRT_RR_POLICY or NRT_FIFO_POLICY; |
- priority must be in the range [0..prioritylevels] |
- returns ENOSYS or ESRCH if there are problems +*/ |
-int POSIXSTAR_getschedparam(LEVEL l, PID p, int *policy, int *priority); |
- |
-/*+ this functions sets paramaters of a task +*/ |
-int POSIXSTAR_setschedparam(LEVEL l, PID p, int policy, int priority); |
- |
-#endif |
- |
-/* |
-MANCANO |
-13.3.6 GETPRIORITYMin da mettere a 0 |
-*/ |
Index: tags/rel_1_22/first/test3.c |
=================================================================== |
--- tags/rel_1_22/first/test3.c (revision 1310) |
+++ tags/rel_1_22/first/test3.c (nonexistent) |
@@ -1,213 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- ------------ |
- CVS : $Id: test3.c,v 1.2 2003-01-07 17:10:17 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.2 $ |
- Last update: $Date: 2003-01-07 17:10:17 $ |
- ------------ |
- |
- The purpose of this test is to show that two budgets with different |
- period and budgets schedules correctly. |
- |
- 2 never ending tasks are involved |
-*/ |
- |
-/* |
- * Copyright (C) 2002 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/cbs.h" |
-#include "cbsstar.h" |
-#include "edfstar.h" |
-#include "modules/rr.h" |
-#include "modules/dummy.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
- |
-#include "drivers/keyb.h" |
- |
-// -------------------------------------------------- |
-// -------------------------------------------------- |
-// Init Part |
-// -------------------------------------------------- |
-// -------------------------------------------------- |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 0 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 10000 |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- int cbsstar_level, edfstar_level, edfstar_level2, mybudget, mybudget2; |
- clear(); |
- EDF_register_level(EDF_ENABLE_ALL); |
- |
- cbsstar_level = CBSSTAR_register_level(3, 0); |
- |
- mybudget = CBSSTAR_setbudget(cbsstar_level, 2000, 50000); |
- edfstar_level = EDFSTAR_register_level(mybudget, cbsstar_level); |
- |
- mybudget2 = CBSSTAR_setbudget(cbsstar_level, 10000, 25000); |
- edfstar_level2 = EDFSTAR_register_level(mybudget2, cbsstar_level); |
- |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- cprintf("edfstar_level=%d, edfstar_level2=%d\n", |
- edfstar_level,edfstar_level2); |
- |
- // for the keyboard... |
- CBS_register_level(CBS_ENABLE_ALL, 0); |
- |
- SEM_register_module(); |
- |
- CABS_register_module(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- KEYB_PARMS kparms = BASE_KEYB; |
- |
- HARTPORT_init(); |
- |
- KEYB_init(&kparms); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
-// -------------------------------------------------- |
-// -------------------------------------------------- |
-// The Test |
-// -------------------------------------------------- |
-// -------------------------------------------------- |
- |
-#include <kernel/kern.h> |
-#include <drivers/keyb.h> |
-#include <semaphore.h> |
- |
-sem_t s; |
- |
-void *star(void *arg) |
-{ |
- int j,z; |
- |
- for (;;) { |
- for (z=0; z<5; z++) { |
- for (j=0; j<60000; j++); |
- sem_wait(&s); |
- cputs((char *)arg); |
- sem_post(&s); |
- } |
- } |
- |
- return NULL; |
-} |
- |
- |
-void create1() |
-{ |
- HARD_TASK_MODEL m1; |
- PID p1a, p1c; |
- |
- hard_task_default_model(m1); |
- hard_task_def_wcet(m1, 5000); |
- hard_task_def_group(m1,1); |
- hard_task_def_periodic(m1); |
- |
- |
- |
- |
- hard_task_def_level(m1,2); |
- |
- hard_task_def_arg(m1,(void *)"O"); |
- hard_task_def_mit(m1,5000); |
- p1a = task_create("a", star, &m1, NULL); |
- if (p1a == -1) { |
- perror("Could not create task a ..."); |
- sys_end(); |
- } |
- |
- |
- hard_task_def_level(m1,3); |
- |
- hard_task_def_arg(m1,(void *)"."); |
- hard_task_def_mit(m1,5000); |
- p1c = task_create("c", star, &m1, NULL); |
- if (p1c == -1) { |
- perror("Could not create task c ..."); |
- sys_end(); |
- } |
- |
- group_activate(1); |
-} |
- |
-void endfun(KEY_EVT *k) |
-{ |
- cprintf("ESC pressed!"); |
- |
- sys_end(); |
-} |
- |
-int main(int argc, char **argv) |
-{ |
- KEY_EVT k; |
- |
- sem_init(&s,0,1); |
- |
- k.flag = 0; |
- k.scan = KEY_ESC; |
- k.ascii = 27; |
- keyb_hook(k,endfun); |
- |
- create1(); |
- |
- return 0; |
-} |
- |
Index: tags/rel_1_22/first/iqueue.h |
=================================================================== |
--- tags/rel_1_22/first/iqueue.h (revision 1310) |
+++ tags/rel_1_22/first/iqueue.h (nonexistent) |
@@ -1,172 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- ------------ |
- CVS : $Id: iqueue.h,v 1.1 2002-09-02 10:29:30 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1 $ |
- Last update: $Date: 2002-09-02 10:29:30 $ |
- ------------ |
- |
-*/ |
- |
-/* |
- * Copyright (C) 2002 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
- |
-/* |
- IQUEUEs |
- |
- This file contains functions that helps to manage task queues. |
- |
- These functions are different from the functions that manages the |
- QUEUE and QQUEUE types. In particular, these functions no more relies |
- on the prev & next fields of the task descriptor. In that way, tasks |
- can be inserted in more than one queue at a time. |
- |
- Basically, an IQUEUE has an "I"nternal prev/next structure, that may |
- be shared between one or more queue. Of course, the user MUST |
- guarantee that the same task will not be inserted in two IQUEUEs that |
- share the same prev/next buffer. |
- |
- The queue insertion is made by the following functions: |
- iq_insert -> insertion based on the priority field. |
- iq_timespec_insert -> same as above but use the timespec_priority field |
- iq_insertfirst -> insert in the first position of the queue |
-*/ |
- |
-#include <kernel/const.h> |
-#include <kernel/types.h> |
-#include <sys/types.h> |
- |
-#define IQUEUE_NO_PRIORITY 1 |
-#define IQUEUE_NO_TIMESPEC 2 |
- |
-struct IQUEUE_shared { |
- PID prev[MAX_PROC]; |
- PID next[MAX_PROC]; |
- struct timespec *timespec_priority; |
- DWORD *priority; |
-}; |
- |
-typedef struct { |
- PID first; |
- PID last; |
- struct IQUEUE_shared *s; |
-} IQUEUE; |
- |
- |
- |
-/* Internal queue initialization: |
- |
- share = &x -> the internal data structure of the IQUEUE x is used |
- to enqueue the tasks. |
- |
- share = NULL -> an internal data structure to handle prev/next |
- pairs is dynamically allocated (The amount of |
- memory that is allocated can be reduced using the |
- flags). |
- |
- flags can be used to reduce the memory usage of an IQUEUE when share=NULL: |
- IQUEUE_NO_PRIORITY -> the iqueue do not provide internally a priority field |
- IQUEUE_NO_TIMESPEC -> the iqueue do not provide internally a timespec field |
- |
- - note that, if these flags are used, the corresponding insert |
- functions will not work! |
- - the default value for the flags is, of course, 0 |
-*/ |
-void iq_init (IQUEUE *q, IQUEUE *share, int flags); |
- |
-/* Queue insert functions: |
- |
- - inserts a p into the q. p must not be already inserted into q. |
- - four versions of the function; |
- - iq_priority_insert -> ordered insertion using the priority field |
- - iq_timespec_insert -> ordered insertion using the timespec field |
- - iq_insertfirst -> insert at the first position of the queue |
- - iq_insertlast -> insert at the last position of the queue |
-*/ |
-void iq_priority_insert (PID p, IQUEUE *q); |
-void iq_timespec_insert (PID p, IQUEUE *q); |
-void iq_insertfirst (PID p, IQUEUE *q); |
-void iq_insertlast (PID p, IQUEUE *q); |
- |
-/* Queue extract functions: |
- |
- - extracts a task p from the queue q. |
- - three versions of the function; |
- - iq_extract -> extracts given a task p |
- (that must be inserted in the queue) |
- |
- - iq_getfirst -> extracts the first task in the queue, |
- NIL if the queue is empty |
- |
- - iq_getlast -> extracts the last task in the queue, |
- NIL if the queue is empty |
- |
-*/ |
-void iq_extract (PID p, IQUEUE *q); |
-PID iq_getfirst ( IQUEUE *q); |
-PID iq_getlast ( IQUEUE *q); |
- |
- |
-/* Queue query functions: |
- |
- The first two functions return the first and the last task in the queue, |
- NIL if the queue is empty. |
- |
- The second two functions can be used to get/set the priority or the |
- timespec field used when queuing. |
-*/ |
-static __inline__ PID iq_queryfirst(IQUEUE *q) |
-{ |
- return q->first; |
-} |
- |
-static __inline__ PID iq_querylast(IQUEUE *q) |
-{ |
- return q->last; |
-} |
- |
-static __inline__ struct timespec *iq_query_timespec(PID p, IQUEUE *q) |
-{ |
- return &q->s->timespec_priority[p]; |
-} |
- |
-static __inline__ DWORD *iq_query_priority (PID p, IQUEUE *q) |
-{ |
- return &q->s->priority[p]; |
-} |
Index: tags/rel_1_22/first/test4.c |
=================================================================== |
--- tags/rel_1_22/first/test4.c (revision 1310) |
+++ tags/rel_1_22/first/test4.c (nonexistent) |
@@ -1,231 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- ------------ |
- CVS : $Id: test4.c,v 1.2 2003-01-07 17:10:17 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.2 $ |
- Last update: $Date: 2003-01-07 17:10:17 $ |
- ------------ |
- |
- The purpose of this test is to show that two budgets with different |
- period and budgets schedules correctly. |
- |
- 2 never ending tasks are involved |
-*/ |
- |
-/* |
- * Copyright (C) 2002 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/cbs.h" |
-#include "cbsstar.h" |
-#include "edfstar.h" |
-#include "modules/rr.h" |
-#include "modules/dummy.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
- |
-#include "drivers/keyb.h" |
- |
-// -------------------------------------------------- |
-// -------------------------------------------------- |
-// Init Part |
-// -------------------------------------------------- |
-// -------------------------------------------------- |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 0 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 10000 |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- int cbsstar_level; |
- int edfstar_level, edfstar_level2, edfstar_level3; |
- int mybudget, mybudget2; |
- |
- clear(); |
- |
- EDF_register_level(EDF_ENABLE_ALL); |
- |
- cbsstar_level = CBSSTAR_register_level(3, 0); |
- |
- mybudget = CBSSTAR_setbudget(cbsstar_level, 2000, 50000); |
- edfstar_level = EDFSTAR_register_level(mybudget, cbsstar_level); |
- |
- mybudget2 = CBSSTAR_setbudget(cbsstar_level, 10000, 25000); |
- edfstar_level2 = EDFSTAR_register_level(mybudget2, cbsstar_level); |
- edfstar_level3 = EDFSTAR_register_level(mybudget2, cbsstar_level); |
- |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- cprintf("edfstar_level=%d, edfstar_level2=%d\n", |
- edfstar_level,edfstar_level2); |
- |
- // for the keyboard... |
- CBS_register_level(CBS_ENABLE_ALL, 0); |
- |
- SEM_register_module(); |
- |
- CABS_register_module(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- KEYB_PARMS kparms = BASE_KEYB; |
- |
- HARTPORT_init(); |
- |
- //keyb_def_ctrlC(kparms, NULL); |
- //keyb_def_map(kparms,itaMap); |
- KEYB_init(&kparms); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
-// -------------------------------------------------- |
-// -------------------------------------------------- |
-// The Test |
-// -------------------------------------------------- |
-// -------------------------------------------------- |
- |
-#include <kernel/kern.h> |
-#include <drivers/keyb.h> |
-#include <semaphore.h> |
- |
-sem_t s; |
- |
-void *star(void *arg) |
-{ |
- int j,z; |
- |
- for (;;) { |
- for (z=0; z<50; z++) { |
- for (j=0; j<60000; j++); |
-// sem_wait(&s); |
- cputs((char *)arg); |
-// sem_post(&s); |
- } |
- task_endcycle(); |
- } |
- |
- return NULL; |
-} |
- |
- |
-void create1() |
-{ |
- HARD_TASK_MODEL m1; |
- PID p1a, p1b, p1c; |
- |
- hard_task_default_model(m1); |
- hard_task_def_wcet(m1, 5000); |
- hard_task_def_group(m1,1); |
- hard_task_def_periodic(m1); |
- |
- |
- |
- |
- hard_task_def_level(m1,2); |
- |
- hard_task_def_arg(m1,(void *)"O"); |
- hard_task_def_mit(m1,5000); |
- p1a = task_create("a", star, &m1, NULL); |
- if (p1a == -1) { |
- perror("Could not create task a ..."); |
- sys_end(); |
- } |
- |
- |
- hard_task_def_level(m1,3); |
- |
- hard_task_def_arg(m1,(void *)"."); |
- hard_task_def_mit(m1,5000); |
- p1b = task_create("b", star, &m1, NULL); |
- if (p1b == -1) { |
- perror("Could not create task c ..."); |
- sys_end(); |
- } |
- |
- hard_task_def_level(m1,4); |
- |
- hard_task_def_arg(m1,(void *)","); |
- hard_task_def_mit(m1,5000); |
- p1c = task_create("c", star, &m1, NULL); |
- if (p1c == -1) { |
- perror("Could not create task c ..."); |
- sys_end(); |
- } |
- |
- group_activate(1); |
-} |
- |
-void endfun(KEY_EVT *k) |
-{ |
- cprintf("ESC pressed!"); |
- |
- sys_end(); |
-} |
- |
-int main(int argc, char **argv) |
-{ |
- KEY_EVT k; |
- |
- sem_init(&s,0,1); |
- |
- k.flag = 0; |
- k.scan = KEY_ESC; |
- k.ascii = 27; |
- keyb_hook(k,endfun); |
- |
- create1(); |
- |
- return 0; |
-} |
- |
Index: tags/rel_1_22/first/test5.c |
=================================================================== |
--- tags/rel_1_22/first/test5.c (revision 1310) |
+++ tags/rel_1_22/first/test5.c (nonexistent) |
@@ -1,248 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- ------------ |
- CVS : $Id: test5.c,v 1.2 2003-01-07 17:10:17 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.2 $ |
- Last update: $Date: 2003-01-07 17:10:17 $ |
- ------------ |
- |
- The purpose of this test is to show that two budgets with different |
- period and budgets schedules correctly. |
- |
- 2 never ending tasks are involved |
-*/ |
- |
-/* |
- * Copyright (C) 2002 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/cbs.h" |
-#include "cbsstar.h" |
-#include "edfstar.h" |
-#include "modules/rr.h" |
-#include "modules/dummy.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
- |
-#include "drivers/keyb.h" |
- |
-// -------------------------------------------------- |
-// -------------------------------------------------- |
-// Init Part |
-// -------------------------------------------------- |
-// -------------------------------------------------- |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 0 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 10000 |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- int cbsstar_level; |
- int edfstar_level, edfstar_level2, edfstar_level3; |
- int mybudget, mybudget2; |
- |
- clear(); |
- |
- EDF_register_level(EDF_ENABLE_ALL); |
- |
- cbsstar_level = CBSSTAR_register_level(3, 0); |
- |
- mybudget = CBSSTAR_setbudget(cbsstar_level, 2000, 50000); |
- edfstar_level = EDFSTAR_register_level(mybudget, cbsstar_level); |
- |
- mybudget2 = CBSSTAR_setbudget(cbsstar_level, 10000, 25000); |
- edfstar_level2 = EDFSTAR_register_level(mybudget2, cbsstar_level); |
- edfstar_level3 = EDFSTAR_register_level(mybudget2, cbsstar_level); |
- |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- cprintf("edfstar_level=%d, edfstar_level2=%d\n", |
- edfstar_level,edfstar_level2); |
- |
- // for the keyboard... |
- CBS_register_level(CBS_ENABLE_ALL, 0); |
- |
- CBS_register_level(CBS_ENABLE_ALL, edfstar_level3); |
- |
- SEM_register_module(); |
- |
- CABS_register_module(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- KEYB_PARMS kparms = BASE_KEYB; |
- |
- HARTPORT_init(); |
- |
- //keyb_def_ctrlC(kparms, NULL); |
- //keyb_def_map(kparms,itaMap); |
- KEYB_init(&kparms); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
-// -------------------------------------------------- |
-// -------------------------------------------------- |
-// The Test |
-// -------------------------------------------------- |
-// -------------------------------------------------- |
- |
- |
-#include <kernel/kern.h> |
-#include <drivers/keyb.h> |
-#include <semaphore.h> |
- |
-sem_t s; |
- |
-void *star(void *arg) |
-{ |
- int j,z; |
- |
- for (;;) { |
- for (z=0; z<50; z++) { |
- for (j=0; j<60000; j++); |
-// sem_wait(&s); |
- cputs((char *)arg); |
-// sem_post(&s); |
- } |
- task_endcycle(); |
- } |
- |
- return NULL; |
-} |
- |
- |
-void create1() |
-{ |
- HARD_TASK_MODEL m1; |
- SOFT_TASK_MODEL ms; |
- PID p1a, p1b, p1c, p2; |
- |
- hard_task_default_model(m1); |
- hard_task_def_wcet(m1, 5000); |
- hard_task_def_group(m1,1); |
- hard_task_def_periodic(m1); |
- |
- |
- |
- |
- hard_task_def_level(m1,2); |
- |
- hard_task_def_arg(m1,(void *)"O"); |
- hard_task_def_mit(m1,5000); |
- p1a = task_create("a", star, &m1, NULL); |
- if (p1a == -1) { |
- perror("Could not create task a ..."); |
- sys_end(); |
- } |
- |
- |
- hard_task_def_level(m1,3); |
- |
- hard_task_def_arg(m1,(void *)"."); |
- hard_task_def_mit(m1,50000); |
- p1b = task_create("b", star, &m1, NULL); |
- if (p1b == -1) { |
- perror("Could not create task c ..."); |
- sys_end(); |
- } |
- |
- hard_task_def_level(m1,4); |
- |
- hard_task_def_arg(m1,(void *)","); |
- hard_task_def_mit(m1,50000); |
- p1c = task_create("c", star, &m1, NULL); |
- if (p1c == -1) { |
- perror("Could not create task c ..."); |
- sys_end(); |
- } |
- |
- soft_task_default_model(ms); |
- soft_task_def_met(ms, 5000); |
- soft_task_def_period(ms, 30000); |
- soft_task_def_group(ms,1); |
- soft_task_def_periodic(ms); |
- soft_task_def_level(ms,8); |
- soft_task_def_arg(ms,(void *)"X"); |
- p2 = task_create("S", star, &ms, NULL); |
- if (p2 == -1) { |
- perror("Could not create task S ..."); |
- sys_end(); |
- } |
- |
- group_activate(1); |
-} |
- |
-void endfun(KEY_EVT *k) |
-{ |
- cprintf("ESC pressed!"); |
- |
- sys_end(); |
-} |
- |
-int main(int argc, char **argv) |
-{ |
- KEY_EVT k; |
- |
- sem_init(&s,0,1); |
- |
- k.flag = 0; |
- k.scan = KEY_ESC; |
- k.ascii = 27; |
- keyb_hook(k,endfun); |
- |
- create1(); |
- |
- return 0; |
-} |
- |
Index: tags/rel_1_22/first/test6.c |
=================================================================== |
--- tags/rel_1_22/first/test6.c (revision 1310) |
+++ tags/rel_1_22/first/test6.c (nonexistent) |
@@ -1,248 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- ------------ |
- CVS : $Id: test6.c,v 1.2 2003-01-07 17:10:17 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.2 $ |
- Last update: $Date: 2003-01-07 17:10:17 $ |
- ------------ |
- |
- this test shows a set of 5 tasks (+main+dummy+keyboard driver). |
- |
- The first 4 tasks are scheduled by a RMSTAR Module, whereas the |
- fifth one is a standard traditional EDF task. The 4 tasks uses a |
- budget of 10000/100000. |
- |
- if edfstar.c is compiled with edfstar_printf3 active, a couple |
- (dline, curtime) is showed (in ms). |
- |
- if cbsstar.c is compiled with cbsstar_printf3 active, the budget |
- replenishments are showed. |
-*/ |
- |
-/* |
- * Copyright (C) 2002 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/cbs.h" |
-#include "cbsstar.h" |
-#include "rmstar.h" |
-#include "modules/rr.h" |
-#include "modules/dummy.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
- |
-#include "drivers/keyb.h" |
- |
- |
-// -------------------------------------------------- |
-// -------------------------------------------------- |
-// Init Part |
-// -------------------------------------------------- |
-// -------------------------------------------------- |
- |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 0 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 10000 |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- int cbsstar_level, rmstar_level, mybudget; |
- |
- EDF_register_level(EDF_ENABLE_ALL); |
- |
- cbsstar_level = CBSSTAR_register_level(3, 0); |
- mybudget = CBSSTAR_setbudget(cbsstar_level, 10000, 100000); |
- rmstar_level = RMSTAR_register_level(mybudget, cbsstar_level); |
- |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- // for the keyboard... |
- CBS_register_level(CBS_ENABLE_ALL, 0); |
- |
- SEM_register_module(); |
- |
- CABS_register_module(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- KEYB_PARMS kparms = BASE_KEYB; |
- |
- HARTPORT_init(); |
- |
- //keyb_def_ctrlC(kparms, NULL); |
- //keyb_def_map(kparms,itaMap); |
- KEYB_init(&kparms); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
-// -------------------------------------------------- |
-// -------------------------------------------------- |
-// The Test |
-// -------------------------------------------------- |
-// -------------------------------------------------- |
- |
- |
-#include <kernel/kern.h> |
-#include <drivers/keyb.h> |
- |
-void *star(void *arg) |
-{ |
- int i,j; |
- |
- for (i=0; i<5; i++) { |
- for (j=0; j<100000; j++); |
- cputc('°'); |
- cputs((char *)arg); |
- task_endcycle(); |
- } |
- |
- return NULL; |
-} |
- |
-void *edftask(void *arg) |
-{ |
- int i,j; |
- |
- for (i=0; i<5; i++) { |
- for (j=0; j<100000; j++); |
- cputc('°'); |
- cputs((char *)arg); |
- task_endcycle(); |
- } |
- |
- return NULL; |
-} |
- |
-void create1() |
-{ |
- HARD_TASK_MODEL m1, m2; |
- PID p1a, p1b, p1c, p1d, p2; |
- |
- hard_task_default_model(m1); |
- hard_task_def_wcet(m1, 5000); |
- hard_task_def_level(m1,2); |
- hard_task_def_group(m1,1); |
- hard_task_def_periodic(m1); |
- |
- hard_task_def_arg(m1,(void *)"a"); |
- hard_task_def_mit(m1,10000); |
- p1a = task_create("a", star, &m1, NULL); |
- if (p1a == -1) { |
- perror("Could not create task a ..."); |
- sys_end(); |
- } |
- |
- hard_task_def_arg(m1,(void *)"b"); |
- hard_task_def_mit(m1,15000); |
- p1b = task_create("b", star, &m1, NULL); |
- if (p1b == -1) { |
- perror("Could not create task b ..."); |
- sys_end(); |
- } |
- |
- hard_task_def_arg(m1,(void *)"c"); |
- hard_task_def_mit(m1,20000); |
- p1c = task_create("c", star, &m1, NULL); |
- if (p1c == -1) { |
- perror("Could not create task c ..."); |
- sys_end(); |
- } |
- |
- hard_task_def_arg(m1,(void *)"d"); |
- hard_task_def_mit(m1,30000); |
- p1d = task_create("d", star, &m1, NULL); |
- if (p1d == -1) { |
- perror("Could not create task d ..."); |
- sys_end(); |
- } |
- |
- hard_task_default_model(m2); |
- hard_task_def_mit(m2,50000); // the budget has dline 100,000! |
- hard_task_def_wcet(m2, 5000); |
- hard_task_def_arg(m2,(void *)"Û"); |
- hard_task_def_group(m2,1); |
- hard_task_def_periodic(m2); |
- |
- p2 = task_create("2", edftask, &m2, NULL); |
- if (p2 == -1) { |
- perror("Could not create task edf ..."); |
- sys_end(); |
- } |
- |
- cprintf("stars=%d %d %d %d, star2=%d\n", p1a, p1b, p1c, p1d, p2); |
- |
- group_activate(1); |
-} |
- |
-int main(int argc, char **argv) |
-{ |
- char c; |
- |
- clear(); |
- |
- cprintf("Hello, world!"); |
- |
- create1(); |
- |
- do { |
- c =keyb_getch(BLOCK); |
- } while (c != ESC); |
- |
- cprintf("ESC pressed!"); |
- |
- sys_end(); |
- |
- return 0; |
-} |
- |
Index: tags/rel_1_22/first/cbsstar.h |
=================================================================== |
--- tags/rel_1_22/first/cbsstar.h (revision 1310) |
+++ tags/rel_1_22/first/cbsstar.h (nonexistent) |
@@ -1,157 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * Massimiliano Giorgi <massy@gandalf.sssup.it> |
- * Luca Abeni <luca@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
- |
-/* |
- ------------ |
- CVS : $Id: cbsstar.h,v 1.1 2002-09-02 10:29:30 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1 $ |
- Last update: $Date: 2002-09-02 10:29:30 $ |
- ------------ |
- |
- This file contains the budget support for the multiapplication |
- scheduling algorithm proposed in the framework of the FIRST Project |
- |
- Title: |
- CBSSTAR |
- |
- Task Models Accepted: |
- None! |
- |
- Guest Models Accepted: |
- BUDGET_TASK_MODEL - A task that is attached to a budget |
- int b; --> the number of the budget which the task is attached to |
- |
- Description: |
- This module schedule its tasks following the CBS scheme. |
- Every task is inserted using the guest calls. |
- |
- The module defines a limited set of budgets that the application |
- can use. Every guest task will use a particular budget; FIFO |
- scheduling is used inside a budget to schedule more than one ready |
- task attached to the same budget. |
- |
- The tasks are inserted in an EDF level (or similar) with a JOB_TASK_MODEL, |
- and the CBS level expects that the task is scheduled with the absolute |
- deadline passed in the model. |
- |
- This module tries to implement a simplified version of the guest |
- task interface: |
- - To insert a guest task, use guest_create |
- - When a task is dispatched, use guest_dispatch |
- - When a task have to be suspended, you have to use: |
- -> preemption: use guest_epilogue |
- -> synchronization, end: use guest_end |
- Remember: no check is done on the budget number passed with the model!!! |
- |
- Exceptions raised: |
- XUNVALID_TASK |
- This level doesn't support normal tasks, but just guest tasks. |
- When a task operation is called, an exception is raised. |
- |
- Restrictions & special features: |
- - This level doesn't manage the main task. |
- - At init time we have to specify: |
- . guarantee check |
- (when all task are created the system will check that the task_set |
- will not use more than the available bandwidth) |
- - A function to return the used bandwidth of the level is provided. |
- |
- - A function is provided to allocate a buffer. |
-*/ |
- |
-/* |
- * Copyright (C) 2002 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
- |
-#ifndef __CBSSTAR_H__ |
-#define __CBSSTAR_H__ |
- |
-#include <kernel/kern.h> |
- |
-//#include <ll/ll.h> |
-//#include <kernel/config.h> |
-//#include <sys/types.h> |
-//#include <kernel/types.h> |
-//#include <modules/codes.h> |
- |
-/* ----------------------------------------------------------------------- |
- BUDGET_TASK_MODEL: a model for guest tasks |
- ----------------------------------------------------------------------- */ |
- |
-#define BUDGET_PCLASS 0x0600 |
- |
-typedef struct { |
- TASK_MODEL t; |
- int b; |
-} BUDGET_TASK_MODEL; |
- |
-#define budget_task_default_model(m,buf) \ |
- task_default_model((m).t, BUDGET_PCLASS), \ |
- (m).b = (buf); |
- |
- |
- |
-/* some constants for registering the Module in the right place */ |
-#define CBSSTAR_LEVELNAME "CBSSTAR" |
-#define CBSSTAR_LEVEL_CODE 106 |
-#define CBSSTAR_LEVEL_VERSION 1 |
- |
- |
- |
- |
-/* Registration function: |
- int N Maximum number of budgets allocated for the applications |
- LEVEL master the level that must be used as master level for the |
- CBS tasks |
-*/ |
-LEVEL CBSSTAR_register_level(int n, LEVEL master); |
- |
-/* Allocates a budget to be used for an application. |
- Input parameters: |
- Q The budget |
- T The period of the budget |
- Return value: |
- 0..N The ID of the budget |
- -1 no more free budgets |
- -2 The budgets allocated locally to this module have bandwidth > 1 |
- -3 wrong LEVEL id |
-*/ |
-int CBSSTAR_setbudget(LEVEL l, TIME Q, TIME T); |
- |
-#endif |
Index: tags/rel_1_22/first/test7.c |
=================================================================== |
--- tags/rel_1_22/first/test7.c (revision 1310) |
+++ tags/rel_1_22/first/test7.c (nonexistent) |
@@ -1,338 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- ------------ |
- CVS : $Id: test7.c,v 1.2 2003-08-01 13:20:38 trimarchi Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.2 $ |
- Last update: $Date: 2003-08-01 13:20:38 $ |
- ------------ |
- |
- this test shows a set of 5 tasks (+main+dummy+keyboard driver). |
- |
- The first 4 tasks are scheduled by a EDFSTAR Module, whereas the |
- fifth one is a standard traditional EDF task. The 4 tasks uses a |
- budget of 10000/100000. |
- |
- if edfstar.c is compiled with edfstar_printf3 active, a couple |
- (dline, curtime) is showed (in ms). |
- |
- if cbsstar.c is compiled with cbsstar_printf3 active, the budget |
- replenishments are showed. |
-*/ |
- |
-/* |
- * Copyright (C) 2002 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/cbs.h" |
-#include "cbsstar.h" |
-#include "posixstar.h" |
-#include "modules/rr.h" |
-#include "modules/dummy.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
- |
-#include "modules/pi.h" |
-#include "modules/nop.h" |
- |
-// -------------------------------------------------- |
-// -------------------------------------------------- |
-// Init Part |
-// -------------------------------------------------- |
-// -------------------------------------------------- |
- |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 0 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 10000 |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- int cbsstar_level, posixstar_level, mybudget, mybudget1, posixstar_level1; |
- |
- EDF_register_level(EDF_ENABLE_ALL); |
- |
- cbsstar_level = CBSSTAR_register_level(3, 0); |
- mybudget = CBSSTAR_setbudget(cbsstar_level, 15000, 30000); |
- mybudget1 = CBSSTAR_setbudget(cbsstar_level, 14000, 56000); |
- posixstar_level = POSIXSTAR_register_level(mybudget, cbsstar_level, 3000,1); |
- posixstar_level1 = POSIXSTAR_register_level(mybudget1, cbsstar_level, 5000,1); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- // for the keyboard... |
- //CBS_register_level(CBS_ENABLE_ALL, 0); |
- |
- //SEM_register_module(); |
- PI_register_module(); |
- NOP_register_module(); |
- return TICK; |
-} |
- |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- //CABS_register_module(); |
- //keyb_def_map(kparms,itaMap); |
- //KEYB_init(&kparms); |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
-// -------------------------------------------------- |
-// -------------------------------------------------- |
-// The Test |
-// -------------------------------------------------- |
-// -------------------------------------------------- |
- |
- |
-#include <kernel/kern.h> |
-#include <drivers/keyb.h> |
-#include <semaphore.h> |
- |
-mutex_t s; |
- |
-void *star(void *arg) |
-{ |
- int j; |
- for (;;) { |
- for (j=0; j<5000; j++); |
- //sem_wait(&s); |
- mutex_lock(&s); |
- cputc('°'); |
- cputs((char *)arg); |
- mutex_unlock(&s); |
- //kern_printf("ril"); |
- //sem_post(&s); |
- //task_endcycle(); |
- } |
- |
- return NULL; |
-} |
- |
-void *edftask(void *arg) |
-{ |
- int i,j; |
- while(1) { |
- for (i=0;i<5; i++) { |
- for (j=0; j<10; j++); |
- //sem_wait(&s); |
- //mutex_lock(&s); |
- cputc('°'); |
- cputs((char *)arg); |
- //mutex_unlock(&s); |
- //sem_post(&s); |
- } |
- |
- task_endcycle(); |
- } |
- |
- return NULL; |
-} |
- |
- |
-void create1() |
-{ |
- int i; |
- NRT_TASK_MODEL m1; |
- HARD_TASK_MODEL m2; |
- PID p1a, p1b, p1c[20],p2,p3; |
- struct timespec fineprg; |
- nrt_task_default_model(m1); |
- nrt_task_def_group(m1, 1); |
- nrt_task_def_level(m1,2); |
- nrt_task_def_arg(m1,(void *)"A"); |
- nrt_task_def_weight(m1,0); |
- p1a = task_create("a",star,&m1,NULL); |
- if (p1a == -1) { |
- perror("Could not create task <Write>"); |
- sys_abort(-1); |
- } |
- |
- nrt_task_def_arg(m1,(void *)"B"); |
- nrt_task_def_group(m1, 1); |
- nrt_task_def_level(m1,2); |
- p1b = task_create("b", star, &m1, NULL); |
- if (p1b == -1) { |
- perror("Could not create task b ..."); |
- sys_end(); |
- } |
- |
- nrt_task_def_arg(m1,(void *)"1"); |
- nrt_task_def_group(m1, 1); |
- nrt_task_def_level(m1,2); |
- |
- p1c[5] = task_create("1", star, &m1, NULL); |
- if (p1c[5] == -1) { |
- perror("Could not create task b ..."); |
- sys_end(); |
- } |
- |
- |
- nrt_task_def_arg(m1,(void *)"C"); |
- nrt_task_def_group(m1, 1); |
- nrt_task_def_level(m1,2); |
- |
- p1c[4] = task_create("c", star, &m1, NULL); |
- if (p1c[4] == -1) { |
- perror("Could not create task b ..."); |
- sys_end(); |
- } |
- |
- nrt_task_def_arg(m1,(void *)"D"); |
- nrt_task_def_group(m1, 1); |
- nrt_task_def_level(m1,2); |
- |
- p1c[5] = task_create("d", star, &m1, NULL); |
- if (p1c[5] == -1) { |
- perror("Could not create task b ..."); |
- sys_end(); |
- } |
- |
- nrt_task_def_arg(m1,(void *)"E"); |
- nrt_task_def_group(m1, 1); |
- nrt_task_def_level(m1,2); |
- |
- p1c[0] = task_create("e", star, &m1, NULL); |
- if (p1c[0] == -1) { |
- perror("Could not create task b ..."); |
- sys_end(); |
- } |
- |
- nrt_task_def_arg(m1,(void *)"F"); |
- p1c[1] = task_create("f", star, &m1, NULL); |
- if (p1c[1] == -1) { |
- perror("Could not create task b ..."); |
- sys_end(); |
- } |
- |
- |
- nrt_task_def_arg(m1,(void *)"G"); |
- nrt_task_def_group(m1, 1); |
- nrt_task_def_level(m1,2); |
- |
- p1c[2] = task_create("g", star, &m1, NULL); |
- if (p1c[2] == -1) { |
- perror("Could not create task b ..."); |
- sys_end(); |
- } |
- |
- nrt_task_def_arg(m1,(void *)"H"); |
- p1c[3] = task_create("h", star, &m1, NULL); |
- if (p1c[3] == -1) { |
- perror("Could not create task b ..."); |
- sys_end(); |
- } |
- |
- nrt_task_def_arg(m1,(void *)"I"); |
- p1c[4] = task_create("h", star, &m1, NULL); |
- if (p1c[4] == -1) { |
- perror("Could not create task b ..."); |
- sys_end(); |
- } |
- |
- |
- |
- hard_task_default_model(m2); |
- hard_task_def_ctrl_jet(m2); |
- hard_task_def_mit(m2,32000); // the budget has dline 100,000! |
- hard_task_def_wcet(m2, 3000); |
- hard_task_def_arg(m2,(void *)"X"); |
- hard_task_def_group(m2,1); |
- hard_task_def_periodic(m2); |
- |
- p2 = task_create("2", edftask, &m2, NULL); |
- if (p2 == -1) { |
- perror("Could not create task edf ..."); |
- sys_end(); |
- } |
- |
- hard_task_def_mit(m2,32000); // the budget has dline 100,000! |
- hard_task_def_wcet(m2, 3000); |
- hard_task_def_arg(m2,(void *)"K"); |
- p3 = task_create("3", edftask, &m2, NULL); |
- if (p3 == -1) { |
- perror("Could not create task edf ..."); |
- sys_end(); |
- } |
- |
- cprintf("stars=%d", p2); |
- fineprg.tv_sec=140; |
- fineprg.tv_nsec=0; |
- kern_event_post(&fineprg,(void(*)(void *))sys_end, NULL); |
- group_activate(1); |
-} |
- |
-int main(int argc, char **argv) |
-{ |
- char c='t'; |
- PI_mutexattr_t a; |
- PI_mutexattr_default(a); |
- |
- //NOP_mutexattr_t a; |
- //NOP_mutexattr_default(a); |
- |
- |
- mutex_init(&s,&a); |
- |
- clear(); |
- |
- |
- cprintf("Hello, world!\nPress ESC to end the demo...\n"); |
- |
- create1(); |
- |
- do { |
- //c =keyb_getch(BLOCK); |
- // cprintf("[]"); |
- } while (c != ESC); |
- |
- cprintf("ESC pressed!"); |
- |
- sys_end(); |
- |
- return 0; |
-} |
- |
Index: tags/rel_1_22/block/readme |
=================================================================== |
--- tags/rel_1_22/block/readme (revision 1310) |
+++ tags/rel_1_22/block/readme (nonexistent) |
@@ -1,33 +0,0 @@ |
-Hi, |
- |
-These are the block devices demos. |
- |
-- THEY DO NOT WRITE ON YOUR HD, so they are not dangerous. |
- |
-- They do not require a FAT16 Filesystem. |
- |
- |
-idetest0: |
-The demo identifies your Hard Disk characteristics and prints it on |
-the screen. |
- |
-idetest1: |
-The demo identifies all the partitions of your HD. |
- |
-idetest2: |
-The demo allows you to select a sector on the HD and to read it. |
- |
-idetest3: |
-The demo reads a random sector and then it writes it in the same position. |
- |
-idelin: |
-The demo reads 16Mb of data from the HD. The data is read block by |
-block, linearly. |
- |
-idernd: |
-The demo reads 512Kb of data from the HD. The data is read block by |
-block, randomly. |
- |
-Enjoy, |
- |
-PJ |
Index: tags/rel_1_22/block/initblk.c |
=================================================================== |
--- tags/rel_1_22/block/initblk.c (revision 1310) |
+++ tags/rel_1_22/block/initblk.c (nonexistent) |
@@ -1,113 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-/* |
- * CVS : $Id: initblk.c,v 1.1 2002-11-11 08:24:49 pj Exp $ |
- * |
- * File: $File$ |
- * Revision: $Revision: 1.1 $ |
- * Last update: $Date: 2002-11-11 08:24:49 $ |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/rr.h" |
-#include "modules/cbs.h" |
-#include "modules/dummy.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
-#include "modules/pi.h" |
-#include "modules/pc.h" |
-#include "modules/srp.h" |
-#include "modules/npp.h" |
-#include "modules/nop.h" |
-#include "modules/nopm.h" |
- |
-#include "drivers/keyb.h" |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 1000 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 10000 |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- extern int __register_sub_init(void); |
- |
- EDF_register_level(EDF_ENABLE_ALL); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- CBS_register_level(CBS_ENABLE_ALL, 0); |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- |
- CABS_register_module(); |
- |
- PI_register_module(); |
- PC_register_module(); |
- NPP_register_module(); |
- SRP_register_module(); |
- NOP_register_module(); |
- NOPM_register_module(); |
- |
- __register_sub_init(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- KEYB_PARMS keyb = BASE_KEYB; |
- extern int __bdev_sub_init(void); |
- extern void ctrlc_exit(KEY_EVT *k); |
- |
- HARTPORT_init(); |
- |
- keyb_def_ctrlC(keyb, ctrlc_exit); |
- KEYB_init(&keyb); |
- |
- __bdev_sub_init(); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
Index: tags/rel_1_22/block/makefile |
=================================================================== |
--- tags/rel_1_22/block/makefile (revision 1310) |
+++ tags/rel_1_22/block/makefile (nonexistent) |
@@ -1,34 +0,0 @@ |
-# |
-# |
-# |
- |
-ifndef BASE |
-BASE=../.. |
-endif |
-include $(BASE)/config/config.mk |
- |
-PROGS=idetest0 idetest1 idetest2 idetest3 idelin idernd idetx430 |
- |
-include $(BASE)/config/example.mk |
- |
-# |
-# |
-# |
- |
-idetest0: |
- make -f $(SUBMAKE) BASE=$(BASE) APP=idetest0 OTHEROBJS="common.o initblk.o" SHARKOPT=__OLDCHAR__ |
- |
-idetest1: |
- make -f $(SUBMAKE) BASE=$(BASE) APP=idetest1 OTHEROBJS="common.o initblk.o" SHARKOPT=__OLDCHAR__ |
- |
-idetest2: |
- make -f $(SUBMAKE) BASE=$(BASE) APP=idetest2 OTHEROBJS="common.o initblk.o" SHARKOPT=__OLDCHAR__ |
- |
-idetest3: |
- make -f $(SUBMAKE) BASE=$(BASE) APP=idetest3 OTHEROBJS="common.o initblk.o" SHARKOPT=__OLDCHAR__ |
- |
-idelin: |
- make -f $(SUBMAKE) BASE=$(BASE) APP=idelin OTHEROBJS="common.o initblk.o" SHARKOPT=__OLDCHAR__ |
- |
-idernd: |
- make -f $(SUBMAKE) BASE=$(BASE) APP=idernd OTHEROBJS="common.o initblk.o" SHARKOPT=__OLDCHAR__ |
Index: tags/rel_1_22/block/common.h |
=================================================================== |
--- tags/rel_1_22/block/common.h (revision 1310) |
+++ tags/rel_1_22/block/common.h (nonexistent) |
@@ -1,11 +0,0 @@ |
- |
-#ifndef __COMMON_H |
-#define __COMMON_H |
- |
-void showmessage(char *s); |
-void waitend(void); |
- |
-void debug_dump_buffer(char *buf, int size); |
- |
-#endif |
- |
Index: tags/rel_1_22/block/idetest0.c |
=================================================================== |
--- tags/rel_1_22/block/idetest0.c (revision 1310) |
+++ tags/rel_1_22/block/idetest0.c (nonexistent) |
@@ -1,15 +0,0 @@ |
-/* |
- * |
- * |
- * |
- */ |
- |
-#include <fs/bdev.h> |
- |
-#include "common.h" |
- |
-int main(int argc,char *argv[]) |
-{ |
- showmessage("Have ide devices been found?\n"); |
- return 0; |
-} |
Index: tags/rel_1_22/block/idetest1.c |
=================================================================== |
--- tags/rel_1_22/block/idetest1.c (revision 1310) |
+++ tags/rel_1_22/block/idetest1.c (nonexistent) |
@@ -1,20 +0,0 @@ |
-/* |
- * |
- * |
- * |
- */ |
- |
-#include <fs/bdev.h> |
- |
-#include "common.h" |
- |
-int main(int argc,char *argv[]) |
-{ |
- |
- showmessage("This test try to identify the partions of all hard disks\n"); |
- |
- bdev_dump_names(); |
- |
- waitend(); |
- return 0; |
-} |
Index: tags/rel_1_22/block/idetest2.c |
=================================================================== |
--- tags/rel_1_22/block/idetest2.c (revision 1310) |
+++ tags/rel_1_22/block/idetest2.c (nonexistent) |
@@ -1,77 +0,0 @@ |
-/* |
- * |
- * |
- * |
- */ |
- |
-#include <ll/i386/cons.h> |
-#include <drivers/keyb.h> |
- |
-#include <fs/bdevinit.h> |
-#include <fs/bdev.h> |
- |
-#include <string.h> |
- |
-#include "common.h" |
- |
-#define DISKDEVICE "ide/hda1" |
- |
-__uint8_t buffer[2048] __attribute__ ((aligned (4))); |
-__dev_t dev; |
- |
-extern char *ide_error_msg[]; |
- |
-int main(int argc,char *argv[]) |
-{ |
- __blkcnt_t blk; |
- int res; |
- int c; |
- |
- showmessage("This test try to read some blocks from first hard disk\n"); |
- |
- dev=bdev_find_byname(DISKDEVICE); |
- if (dev<0) { |
- cprintf("Can't find device to operate with\n"); |
- return -1; |
- } |
- cprintf("Using device %s (dev=%04x)\n",DISKDEVICE,dev); |
- |
- blk=0; |
- for (;;) { |
- cprintf("Commands: x-exit r-read n-next block p-prev block\n"); |
- c = keyb_getchar(); |
- switch(c) { |
- case 'x': |
- return 0; |
- |
- case 'n': |
- blk++; |
- cprintf("Block %li\n",(long)blk); |
- break; |
- |
- case 'p': |
- if (blk>=0) blk--; |
- cprintf("Block %li\n",(long)blk); |
- break; |
- |
- case 'r': |
- cprintf("Reading block %li...\n",(long)blk); |
- memset(buffer,0xff,sizeof(buffer)); |
- res=bdev_read(dev,blk,buffer); |
- cprintf("Result %i\n",res); |
- //cprintf("Soft reset done %i\n",ide[0].errors); |
- if (res!=0) { |
- cprintf(" %s\n",(char*)ide_error_msg[-res]); |
- } |
- debug_dump_buffer(buffer,64); |
- break; |
- |
- default: |
- cprintf("Invalid command!\n"); |
- break; |
- } |
- cprintf("\n"); |
- } |
- |
- return 0; |
-} |
Index: tags/rel_1_22/block/idelin.c |
=================================================================== |
--- tags/rel_1_22/block/idelin.c (revision 1310) |
+++ tags/rel_1_22/block/idelin.c (nonexistent) |
@@ -1,71 +0,0 @@ |
-/* |
- * |
- * |
- * |
- */ |
- |
-#include <ll/i386/cons.h> |
-#include <kernel/func.h> |
- |
-#include <fs/bdevinit.h> |
-#include <fs/bdev.h> |
- |
-#include <stdlib.h> |
-#include <string.h> |
- |
-#include "common.h" |
- |
-#define DISKDEVICE "ide/hda" |
- |
-#define TEST_MB 16 |
- |
-#define NUMBLOCK (TEST_MB*1024l*1024l/512l) |
- |
-__dev_t dev; |
- |
-__uint8_t buffer[2048]; |
- |
-int main(int argc,char *argv[]) |
-{ |
- __blkcnt_t blk; |
- int res; |
- int errors; |
- TIME sttime,etime; |
- |
- showmessage("\n" |
- "This test read data from first hard disk to test\n" |
- "disk throughtput.\n" |
- "Remeber that the reads are made block by block so\n" |
- "don't worry if you see a low throughtput.\n" |
- ); |
- |
- dev=bdev_find_byname(DISKDEVICE); |
- if (dev<0) { |
- cprintf("\nCan't find device to operate with\n"); |
- return -1; |
- } |
- cprintf("\nUsing device %s (dev=%04x)\n",DISKDEVICE,dev); |
- |
- cprintf("Please wait (reading %i MB linearly?!?)...",TEST_MB); |
- |
- sttime=sys_gettime(NULL); |
- errors=0; |
- for (blk=0;blk<NUMBLOCK;blk++) { |
- res=bdev_read(dev,blk,buffer); |
- //res=bdev_seek(dev,blk); |
- if (res!=0) errors++; |
- } |
- etime=sys_gettime(NULL)-sttime; |
- |
- cprintf("\nDone\n\n"); |
- cprintf("elapse time : %li sec %li msec\n", |
- etime/1000000l, |
- (etime/1000l)%1000l); |
- cprintf("throughtput : %6.3f MB/s\n", |
- NUMBLOCK*512.0/1024.0/1024.0/etime*1000000.0); |
- //cprintf("soft reset made: %i\n",ide[0].errors); |
- cprintf("errors : %i\n",errors); |
- cprintf("\n"); |
- |
- return 0; |
-} |
Index: tags/rel_1_22/block/idetest3.c |
=================================================================== |
--- tags/rel_1_22/block/idetest3.c (revision 1310) |
+++ tags/rel_1_22/block/idetest3.c (nonexistent) |
@@ -1,66 +0,0 @@ |
-/* |
- * |
- * |
- * |
- */ |
- |
-#include <ll/i386/cons.h> |
-#include <drivers/keyb.h> |
- |
-#include <fs/bdevinit.h> |
-#include <fs/bdev.h> |
- |
-#include <string.h> |
- |
-#include "common.h" |
- |
-#define DISKDEVICE "ide/hda1" |
-#define BLOCKNUMBER 58549 |
- |
-__uint8_t buffer[2048] __attribute__ ((aligned (4))); |
- |
-extern char *ide_error_msg[]; |
- |
-int main(int argc,char *argv[]) |
-{ |
- __dev_t dev; |
- __blkcnt_t blk; |
- int res; |
- // int c; |
- |
- showmessage("This test tries to read a block from the first hard disk\n" |
- "and then it tries to write it to disk\n" |
- "Press [CTRL-C] to abort..."); |
- |
- dev=bdev_find_byname(DISKDEVICE); |
- if ((int)dev<0) { |
- cprintf("Can't find device to operate with\n"); |
- cprintf("%s not present!\n",DISKDEVICE); |
- return -1; |
- } |
- cprintf("Using device %s (dev=%04x)\n",DISKDEVICE,dev); |
- |
- blk=BLOCKNUMBER; |
- |
- cprintf("Reading block %li...\n",(long)blk); |
- memset(buffer,0xff,sizeof(buffer)); |
- res=bdev_read(dev,blk,buffer); |
- cprintf("Result %i\n",res); |
- //cprintf("Soft reset done %i\n",ide[0].errors); |
- if (res!=0) { |
- cprintf(" %s\n",(char*)ide_error_msg[-res]); |
- return -1; |
- } |
- debug_dump_buffer(buffer,64); |
- |
- cprintf("Writing block %li...\n",(long)blk); |
- res=bdev_write(dev,blk,buffer); |
- cprintf("Result %i\n",res); |
- //cprintf("Soft reset done %i\n",ide[0].errors); |
- if (res!=0) { |
- cprintf(" %s\n",(char*)ide_error_msg[-res]); |
- } |
- |
- waitend(); |
- return 0; |
-} |
Index: tags/rel_1_22/block/idernd.c |
=================================================================== |
--- tags/rel_1_22/block/idernd.c (revision 1310) |
+++ tags/rel_1_22/block/idernd.c (nonexistent) |
@@ -1,68 +0,0 @@ |
-/* |
- * |
- * |
- * |
- */ |
- |
-#include <ll/i386/cons.h> |
-#include <kernel/func.h> |
- |
-#include <fs/bdevinit.h> |
-#include <fs/bdev.h> |
- |
-#include <stdlib.h> |
-#include <string.h> |
- |
-#include "common.h" |
- |
-#define DISKDEVICE "ide/hda1" |
- |
-#define NUMBLOCK 1000 |
- |
-__dev_t dev; |
-__uint8_t buffer[2048]; |
- |
-int main(int argc,char *argv[]) |
-{ |
- __blkcnt_t blk; |
- int res; |
- int errors; |
- TIME sttime,etime; |
- |
- showmessage("\n" |
- "This test read RAMDOMLY data from first hard disk to test\n" |
- "disk throughtput.\n" |
- "Remeber that the reads are made RANDOMLY block by block so\n" |
- "don't worry if you see a VERY low throughtput.\n" |
- ); |
- srand(7); |
- |
- dev=bdev_find_byname(DISKDEVICE); |
- if (dev<0) { |
- cprintf("\nCan't find device to operate with\n"); |
- return -1; |
- } |
- cprintf("\nUsing device %s (dev=%04x)\n",DISKDEVICE,dev); |
- |
- cprintf("Please wait (reading %i KB ramdomly)...",NUMBLOCK/2); |
- |
- sttime=sys_gettime(NULL); |
- errors=0; |
- for (blk=0;blk<NUMBLOCK;blk++) { |
- res=bdev_read(dev,rand()%5000,buffer); |
- if (res!=0) errors++; |
- } |
- etime=sys_gettime(NULL)-sttime; |
- |
- cprintf("\nDone\n\n"); |
- cprintf("elapse time : %li sec %li msec\n", |
- etime/1000000l, |
- (etime/1000l)%1000l); |
- cprintf("throughtput : %6.3f KB/s\n", |
- NUMBLOCK*512.0/1024.0/etime*1000000.0); |
- //cprintf("soft reset made: %i\n",ide[0].errors); |
- cprintf("errors : %i\n",errors); |
- cprintf("\n"); |
- |
- return 0; |
-} |
Index: tags/rel_1_22/block/common.c |
=================================================================== |
--- tags/rel_1_22/block/common.c (revision 1310) |
+++ tags/rel_1_22/block/common.c (nonexistent) |
@@ -1,74 +0,0 @@ |
- |
-#include <kernel/func.h> |
- |
-#include <fs/bdevinit.h> |
-#include <fs/fsinit.h> |
-#include <fs/bdev.h> |
- |
-#include <drivers/keyb.h> |
- |
-#include <sys/mount.h> |
- |
-#include <fcntl.h> |
-#include <unistd.h> |
-#include <errno.h> |
- |
-/* -- */ |
- |
-int __register_sub_init(void) |
-{ |
- return 0; |
-} |
- |
-/* -- */ |
- |
-int __bdev_sub_init(void) |
-{ |
- BDEV_PARMS bdev=BASE_BDEV; |
- |
- bdev_def_showinfo(bdev,TRUE); |
- bdev_init(&bdev); |
- |
- return 0; |
-} |
- |
-/* -- */ |
- |
-void ctrlc_exit(KEY_EVT *k) |
-{ |
- cprintf("CTRL-C pressed!\n"); |
- sys_end(); |
-} |
- |
-/* -- */ |
- |
-void showmessage(char *s) |
-{ |
- cputs(s); |
- cprintf("Press [x] to begin..."); |
- while (keyb_getchar()!='x'); |
- cprintf("\n"); |
-} |
- |
-void waitend(void) |
-{ |
- int c; |
- cprintf("Press [x] to exit..."); |
- while ((c=keyb_getchar())!='x'); |
- cprintf("\n"); |
-} |
- |
-/* -- */ |
- |
-void debug_dump_buffer(char *buf, int size) |
-{ |
- int i; |
- for (i=0;i<size;i++) { |
- if (i%16==0) { |
- if (i!=0) cprintf("\n"); |
- cprintf("%04x: ",i); |
- } |
- cprintf("%02x ",(unsigned char)*(buf+i)); |
- } |
- cprintf("\n"); |
-} |
Index: tags/rel_1_22/pse51/ptest5.c |
=================================================================== |
--- tags/rel_1_22/pse51/ptest5.c (revision 1310) |
+++ tags/rel_1_22/pse51/ptest5.c (nonexistent) |
@@ -1,109 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: ptest5.c,v 1.1.1.1 2002-09-02 09:37:47 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1.1.1 $ |
- Last update: $Date: 2002-09-02 09:37:47 $ |
- ------------ |
- |
- Posix test 5: |
- an alarm test |
- |
- non standard function used: |
- cprintf |
- sys_gettime |
- keyboard stuffs |
- sys_end |
- |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include <sys/types.h> |
-#include <pthread.h> |
-#include <signal.h> |
-#include <unistd.h> |
- |
-#include <kernel/kern.h> |
-#include <drivers/keyb.h> |
- |
- |
- |
-void signal_handler(int signo, siginfo_t *info, void *extra) |
-{ |
- cprintf("SIGNAL HANDLER: pid=%d\n",exec_shadow); |
-} |
- |
-void fine(KEY_EVT *e) |
-{ |
- sys_end(); |
-} |
- |
- |
-int main(int argc, char **argv) |
-{ |
- struct sigaction sig_act; |
- |
- KEY_EVT emerg; |
- //keyb_set_map(itaMap); |
- emerg.ascii = 'x'; |
- emerg.scan = KEY_X; |
- emerg.flag = ALTL_BIT; |
- keyb_hook(emerg,fine); |
- |
- sig_act.sa_sigaction = (void *) signal_handler; |
- sig_act.sa_flags = SA_SIGINFO; |
- sigemptyset(&sig_act.sa_mask); |
- |
- sigaction(SIGALRM, &sig_act, NULL); |
- |
- cprintf("main: alarm(5), waiting t=2 sec\n"); |
- alarm(5); |
- |
- while (sys_gettime(NULL) < 2000000); |
- |
- cprintf("main: alarm(3) return %d, waiting t=6 sec\n",alarm(3)); |
- |
- pause(); |
-// while (sys_gettime(NULL) < 6000000); |
- |
- cprintf("main: ending...\n"); |
- |
- return 0; |
-} |
Index: tags/rel_1_22/pse51/ptest6.c |
=================================================================== |
--- tags/rel_1_22/pse51/ptest6.c (revision 1310) |
+++ tags/rel_1_22/pse51/ptest6.c (nonexistent) |
@@ -1,300 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: ptest6.c,v 1.1.1.1 2002-09-02 09:37:47 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1.1.1 $ |
- Last update: $Date: 2002-09-02 09:37:47 $ |
- ------------ |
- |
- Posix test 6: |
- |
- message queues |
- |
- main thread: |
- set a sigevent to sigev_thread on a mailbox (that creates thread 2) |
- creates thread 1 |
- waits t=3.5 sec. |
- pthread_cancel(T4) |
- |
- thread 1: |
- send a msg to the mailbox (the event fires and thread 2 is created) |
- |
- thread 2: |
- receive the msg sent by thread 1 |
- set the event to a signal |
- creates thread 3 and 4 |
- waits t = 1 sec |
- send another msg |
- |
- thread 3: |
- receive the msg sent by 2 (it blocks!) |
- waits t = 2 sec |
- send 5 msgs (with different priorities!!! |
- |
- thread 4: |
- receives 5 msgs every 0.5 sec. |
- then receive another message that never will arrive... |
- |
- non standard function used: |
- cprintf |
- sys_gettime |
- keyboard stuffs |
- sys_end |
- |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include <sys/types.h> |
-#include <pthread.h> |
-#include <mqueue.h> |
- |
-#include <kernel/kern.h> |
-#include <drivers/keyb.h> |
- |
-struct sigevent ev25, evtask; |
-pthread_attr_t task_attr; |
-struct sched_param task_param; |
-mqd_t mq; |
-pthread_t T1,T2,T3,T4,T5; |
- |
-#define MESSAGE_LENGTH 100 |
- |
-void *t1(void *arg) |
-{ |
- cprintf("T1: started, sending a message\n"); |
- if (mq_send(mq,"Donald Duck",12,1)) |
- { cprintf("T1: mq_send returns errno %d\n",errno); return 0; } |
- |
- cprintf("T1: ending...\n"); |
- return 0; |
-} |
- |
-void *t4(void *arg); |
-void *t3(void *arg); |
- |
-void t2(union sigval value) |
-{ |
- ssize_t x; |
- char buf[MESSAGE_LENGTH]; |
- int prio; |
- |
- cprintf("T2: value = %d, receiving a message\n", value.sival_int); |
- |
- x = mq_receive(mq,buf,MESSAGE_LENGTH,&prio); |
- |
- cprintf("T2: received message: length=%ld, prio=%d, text=°%s°, notify...\n", |
- x,prio,buf); |
- |
- if (mq_notify(mq, &ev25)) |
- { cprintf("T2: mq_notify returns errno %d\n",errno); sys_end(); } |
- |
- cprintf("T2: waiting t = 1 sec.\n"); |
- while (sys_gettime(NULL)<1000000); |
- cprintf("T2: 1 sec. reached, sending another message and creating T3 and T4, \n"); |
- |
- if (mq_send(mq,"Mickey Mouse",13,1)) |
- { cprintf("T2: mq_send returns errno %d\n",errno); sys_end(); } |
- |
- pthread_create(&T3, NULL, t3, NULL); |
- pthread_create(&T4, NULL, t4, NULL); |
- |
- cprintf("T2: ending...\n"); |
-} |
- |
-void *t3(void *arg) |
-{ |
- ssize_t x; |
- char buf[MESSAGE_LENGTH]; |
- int prio; |
- |
- cprintf("T3: waiting a message...\n"); |
- |
- x = mq_receive(mq,buf,MESSAGE_LENGTH,&prio); |
- |
- // mickey mouse |
- cprintf("T3: received message: length=%ld, prio=%d, text=°%s°\n", |
- x,prio,buf); |
- |
- cprintf("T3: waiting t = 1.5 sec.\n"); |
- while (sys_gettime(NULL)<1500000); |
- cprintf("T3: 2 sec. reached, sending 5 messages\n"); |
- |
- if (mq_send(mq,"Goofy",6,1)) |
- { cprintf("T3: mq_send1 returns errno %d\n",errno); sys_end(); } |
- cprintf("Û"); |
- |
- if (mq_send(mq,"Minnie",7,1)) |
- { cprintf("T3: mq_send2 returns errno %d\n",errno); sys_end(); } |
- cprintf("Û"); |
- |
- if (mq_send(mq,"Pluto",6,2)) // NB: different priority!!! |
- { cprintf("T3: mq_send3 returns errno %d\n",errno); sys_end(); } |
- cprintf("Û"); |
- |
- if (mq_send(mq,"Rocker Duck",12,2)) // NB: different priority!!! |
- { cprintf("T3: mq_send4 returns errno %d\n",errno); sys_end(); } |
- cprintf("Û"); |
- |
- if (mq_send(mq,"Oncle Scroodge",15,2)) // NB: different priority!!! |
- { cprintf("T3: mq_send5 returns errno %d\n",errno); sys_end(); } |
- cprintf("Û"); |
- |
- cprintf("T3: ending...\n"); |
- |
- return 0; |
-} |
- |
-void t4exit(void *arg) |
-{ |
- cprintf("T4: AAAARRRRGGGHHH!!! killed by someone...\n"); |
-} |
- |
-void *t4(void *arg) |
-{ |
- ssize_t x; |
- char buf[MESSAGE_LENGTH]; |
- int prio; |
- |
- cprintf("T4: waiting t = 2.2 sec.\n"); |
- |
- while (sys_gettime(NULL)<2200000); |
- x = mq_receive(mq,buf,MESSAGE_LENGTH,&prio); |
- cprintf("T4: received message: length=%ld, prio=%d, text=°%s°\n",x,prio,buf); |
- |
- while (sys_gettime(NULL)<2400000); |
- x = mq_receive(mq,buf,MESSAGE_LENGTH,&prio); |
- cprintf("T4: received message: length=%ld, prio=%d, text=°%s°\n",x,prio,buf); |
- while (sys_gettime(NULL)<2600000); |
- |
- x = mq_receive(mq,buf,MESSAGE_LENGTH,&prio); |
- cprintf("T4: received message: length=%ld, prio=%d, text=°%s°\n",x,prio,buf); |
- while (sys_gettime(NULL)<2800000); |
- |
- x = mq_receive(mq,buf,MESSAGE_LENGTH,&prio); |
- cprintf("T4: received message: length=%ld, prio=%d, text=°%s°\n",x,prio,buf); |
- while (sys_gettime(NULL)<3000000); |
- |
- x = mq_receive(mq,buf,MESSAGE_LENGTH,&prio); |
- cprintf("T4: received message: length=%ld, prio=%d, text=°%s°\n",x,prio,buf); |
- |
- pthread_cleanup_push(t4exit,NULL); |
- x = mq_receive(mq,buf,MESSAGE_LENGTH,&prio); |
- cprintf("T4: received message: length=%ld, prio=%d, text=°%s°\n",x,prio,buf); |
- pthread_cleanup_pop(0); |
- |
- return 0; |
-} |
- |
-void signal_handler(int signo, siginfo_t *info, void *extra) |
-{ |
- cprintf("Signal %d code=%s value=%d task=%d time=%ldusec\n", |
- info->si_signo, |
- (info->si_code == SI_TIMER) ? "Timer" : "Other", |
- info->si_value.sival_int, |
- info->si_task, |
- sys_gettime(NULL)); |
-} |
- |
-void fine(KEY_EVT *e) |
-{ |
- sys_end(); |
-} |
- |
-int main(int argc, char **argv) |
-{ |
-// int err; |
- struct sigaction sig_act; |
- struct mq_attr attr; |
- |
- KEY_EVT emerg; |
- //keyb_set_map(itaMap); |
- emerg.ascii = 'x'; |
- emerg.scan = KEY_X; |
- emerg.flag = ALTL_BIT; |
- keyb_hook(emerg,fine); |
- |
- sig_act.sa_sigaction = (void *) signal_handler; |
- sig_act.sa_flags = SA_SIGINFO; |
- sigemptyset(&sig_act.sa_mask); |
- sigaction(25, &sig_act, NULL); |
- |
- // set ev25, evtask |
- ev25.sigev_notify = SIGEV_SIGNAL; |
- ev25.sigev_signo = 25; |
- ev25.sigev_value.sival_int = 555; |
- |
- evtask.sigev_notify = SIGEV_THREAD; |
- evtask.sigev_value.sival_int = 777; |
- evtask.sigev_notify_function = t2; |
- evtask.sigev_notify_attributes = &task_attr; |
- |
- // set pthread attributes |
- pthread_attr_init(&task_attr); |
- pthread_attr_setdetachstate(&task_attr, PTHREAD_CREATE_DETACHED); |
- pthread_attr_setschedpolicy(&task_attr, SCHED_FIFO); |
- task_param.sched_priority = 10; |
- pthread_attr_setschedparam(&task_attr, &task_param); |
- |
- // set mqueue attributes |
- attr.mq_flags = 0; |
- attr.mq_maxmsg = 3; |
- attr.mq_msgsize = MESSAGE_LENGTH; |
- |
- // create the message queue |
- if ((mq = mq_open("mq", O_CREAT|O_RDWR, 0, &attr)) == -1) |
- { cprintf("main: mq_open returns errno %d\n",errno); return 0; } |
- |
- if (mq_notify(mq, &evtask)) |
- { cprintf("main: mq_notify returns errno %d\n",errno); return 0; } |
- |
- cprintf("main: created mq, creating T1...\n"); |
- |
- pthread_create(&T1, NULL, t1, NULL); |
- |
- cprintf("main: waiting t= 3.5 sec., then kill T4...\n"); |
- |
- while (sys_gettime(NULL)<3500000); |
- |
- pthread_cancel(T4); |
- |
- cprintf("main: ending...\n"); |
- |
- return 0; |
-} |
Index: tags/rel_1_22/pse51/makefile |
=================================================================== |
--- tags/rel_1_22/pse51/makefile (revision 1310) |
+++ tags/rel_1_22/pse51/makefile (nonexistent) |
@@ -1,25 +0,0 @@ |
-# |
-# |
-# |
- |
-ifndef BASE |
-BASE=../.. |
-endif |
-include $(BASE)/config/config.mk |
- |
-PROGS+= ptest1 ptest2 ptest3 ptest4 ptest5 ptest6 |
- |
-include $(BASE)/config/example.mk |
- |
-ptest1: |
- make -f $(SUBMAKE) APP=ptest1 INIT= OTHEROBJS="pinit.o" SHARKOPT=__OLDCHAR__ |
-ptest2: |
- make -f $(SUBMAKE) APP=ptest2 INIT= OTHEROBJS="pinit.o" SHARKOPT=__OLDCHAR__ |
-ptest3: |
- make -f $(SUBMAKE) APP=ptest3 INIT= OTHEROBJS="pinit.o" SHARKOPT=__OLDCHAR__ |
-ptest4: |
- make -f $(SUBMAKE) APP=ptest4 INIT= OTHEROBJS="pinit.o" SHARKOPT=__OLDCHAR__ |
-ptest5: |
- make -f $(SUBMAKE) APP=ptest5 INIT= OTHEROBJS="pinit.o" SHARKOPT=__OLDCHAR__ |
-ptest6: |
- make -f $(SUBMAKE) APP=ptest6 INIT= OTHEROBJS="pinit.o" SHARKOPT=__OLDCHAR__ |
Index: tags/rel_1_22/pse51/ptest1.c |
=================================================================== |
--- tags/rel_1_22/pse51/ptest1.c (revision 1310) |
+++ tags/rel_1_22/pse51/ptest1.c (nonexistent) |
@@ -1,221 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: ptest1.c,v 1.1.1.1 2002-09-02 09:37:47 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1.1.1 $ |
- Last update: $Date: 2002-09-02 09:37:47 $ |
- ------------ |
- |
- Posix test 1: |
- |
- the main task create 4 tasks, J1, J2, J3, J4 |
- at t = 0.2 sec. it raise a signal to J1 |
- at t = 0.4 sec. it raise a signal to J2 |
- at t = 0.8 sec. it kill J4 |
- |
- J1: it simply calls sigwait |
- |
- J2: it simply calls sigwaitinfo |
- |
- J3: it simply calls sigtimedwait with a timeout of 0.5 sec. |
- |
- J4: it simply calls sigtimedwait with a -long- timeout |
- (J4 will be killed by main) |
- |
- non standard function used: |
- cprintf |
- sys_gettime |
- keyboard stuffs |
- sys_end |
- |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include <sys/types.h> |
-#include <pthread.h> |
-#include <signal.h> |
- |
-#include <kernel/kern.h> |
-#include <drivers/keyb.h> |
- |
-void *J1(void *arg) |
-{ |
- int sig, err; |
- sigset_t mask; |
- |
- cprintf("J1 starts and call sigwait(31)\n"); |
- |
- sigemptyset(&mask); |
- sigaddset(&mask,31); |
- err = sigwait(&mask,&sig); |
- |
- cprintf("J1 exit from sigwait(), err=%d, sig=%d\n", err, sig); |
- |
- return 0; |
-} |
- |
-void *J2(void *arg) |
-{ |
- int err; |
- siginfo_t info; |
- sigset_t mask; |
- |
- cprintf("J2 starts and call sigwaitinfo(30)\n"); |
- |
- sigemptyset(&mask); |
- sigaddset(&mask,30); |
- err = sigwaitinfo(&mask,&info); |
- |
- cprintf("J2 exit from sigwaitinfo(), err=%d, signo=%d code=%d value=%d\n", |
- err, info.si_signo, info.si_code, info.si_value.sival_int); |
- |
- return 0; |
-} |
- |
-void *J3(void *arg) |
-{ |
- int err; |
- siginfo_t info; |
- sigset_t mask; |
- struct timespec t; |
- |
- cprintf("J3 starts and call sigtimedwait(29)\n"); |
- |
- sigemptyset(&mask); |
- sigaddset(&mask,29); |
- t.tv_sec = 0; |
- t.tv_nsec = 300000000; |
- err = sigtimedwait(&mask,&info,&t); |
- |
- cprintf("J3 exit from sigtimedwait(), err=%d, signo=%d code=%d value=%d\n", |
- err, info.si_signo, info.si_code, info.si_value.sival_int); |
- |
- return 0; |
-} |
- |
-void uscitaJ4(void *arg) |
-{ |
- cprintf("J4: AAAARRRRGGGHHH!!! killed by someone...\n"); |
-} |
- |
-void *J4(void *arg) |
-{ |
- int err; |
- siginfo_t info; |
- sigset_t mask; |
- struct timespec t; |
- |
- cprintf("J4 starts and call sigtimedwait(28)\n"); |
- |
- sigemptyset(&mask); |
- sigaddset(&mask,28); |
- t.tv_sec = 10; |
- t.tv_nsec = 0; |
- |
- pthread_cleanup_push(uscitaJ4,NULL); |
- err = sigtimedwait(&mask,&info,&t); |
- pthread_cleanup_pop(0); |
- |
- cprintf("J4 exit from sigtimedwait(), err=%d, signo=%d code=%d value=%d\n", |
- err, info.si_signo, info.si_code, info.si_value.sival_int); |
- |
- return 0; |
-} |
- |
-void fine(KEY_EVT *e) |
-{ |
- sys_end(); |
-} |
- |
- |
-int main(int argc, char **argv) |
-{ |
- int err; |
- sigset_t mask; |
- pthread_t j1, j2, j3, j4; |
- union sigval value; |
- |
- KEY_EVT emerg; |
- //keyb_set_map(itaMap); |
- emerg.ascii = 'x'; |
- emerg.scan = KEY_X; |
- emerg.flag = ALTL_BIT; |
- keyb_hook(emerg,fine); |
- |
- |
- /* main blocks signals for all the tasks */ |
- sigfillset(&mask); |
- pthread_sigmask(SIG_BLOCK, &mask, NULL); |
- |
- cprintf("main: creating J1\n"); |
- err = pthread_create(&j1, NULL, J1, NULL); |
- if (err) cprintf("Error creating J1\n"); |
- |
- cprintf("main: creating J2\n"); |
- err = pthread_create(&j2, NULL, J2, NULL); |
- if (err) cprintf("Error creating J2\n"); |
- |
- cprintf("main: creating J3\n"); |
- err = pthread_create(&j3, NULL, J3, NULL); |
- if (err) cprintf("Error creating J3\n"); |
- |
- cprintf("main: creating J4\n"); |
- err = pthread_create(&j4, NULL, J4, NULL); |
- if (err) cprintf("Error creating J4\n"); |
- |
- cprintf("main: waiting 0.2 sec\n"); |
- while (sys_gettime(NULL) < 200000); |
- |
- cprintf("main: kill(31), then wait until t=0.4 sec \n"); |
- kill(0, 31); |
- |
- while (sys_gettime(NULL) < 400000); |
- cprintf("main: sigqueue(30), then wait until t=0.8 sec \n"); |
- value.sival_int = 300; |
- sigqueue(0, 30, value); |
- |
- while (sys_gettime(NULL) < 800000); |
- cprintf("main: kill(J4)\n"); |
- pthread_cancel(j4); |
- |
- cprintf("main: ending...\n"); |
- |
- return 0; |
-} |
Index: tags/rel_1_22/pse51/ptest2.c |
=================================================================== |
--- tags/rel_1_22/pse51/ptest2.c (revision 1310) |
+++ tags/rel_1_22/pse51/ptest2.c (nonexistent) |
@@ -1,152 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: ptest2.c,v 1.1.1.1 2002-09-02 09:37:47 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1.1.1 $ |
- Last update: $Date: 2002-09-02 09:37:47 $ |
- ------------ |
- |
- Posix test 2: |
- |
- pthread_once + thread_specific_data |
- |
- the main task: |
- creates a key |
- creates 2 tasks, J1, J2 |
- at t = 0.4 sec. it kills J1 and J2 |
- |
- J1 and J2 will set and check the thread specific data |
- and when the die, a destructor is called (twice, because the value |
- is not set to null...) |
- |
- non standard function used: |
- cprintf |
- sys_gettime |
- keyboard stuffs |
- sys_end |
- |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include <sys/types.h> |
-#include <pthread.h> |
- |
-#include <kernel/kern.h> |
-#include <drivers/keyb.h> |
- |
-pthread_key_t prova_key; |
- |
-pthread_once_t once = PTHREAD_ONCE_INIT; |
- |
-void once_init() |
-{ |
- cprintf("ONCE: (pid=%d)\n", exec_shadow); |
-} |
- |
-void destr_key(void *arg) |
-{ |
- cprintf("J (pid=%d) destructor called with value %d\n", exec_shadow,(int)arg); |
- pthread_setspecific(prova_key,(void *)((int)arg/100)); |
-} |
- |
-void print_test() |
-{ |
- int val; |
- |
- val = (int)pthread_getspecific(prova_key); |
- cprintf("J (pid=%d) printtest value=%d\n", exec_shadow, val); |
-} |
- |
-void *J(void *arg) |
-{ |
- pthread_once(&once, once_init); |
- cprintf("J (pid=%d) starts and call setspecific\n", exec_shadow); |
- pthread_setspecific(prova_key,arg); |
- print_test(); |
- cprintf("J (pid=%d) exits\n", exec_shadow); |
- |
- return 0; |
-} |
- |
-void fine(KEY_EVT *e) |
-{ |
- sys_end(); |
-} |
- |
- |
-int main(int argc, char **argv) |
-{ |
- int err; |
- pthread_t j1, j2; |
- |
- KEY_EVT emerg; |
- //keyb_set_map(itaMap); |
- emerg.ascii = 'x'; |
- emerg.scan = KEY_X; |
- emerg.flag = ALTL_BIT; |
- keyb_hook(emerg,fine); |
- |
- |
- cprintf("main: creating prova_key\n"); |
- pthread_key_create(&prova_key, destr_key); |
- |
- cprintf("main: provakey =%d\n", prova_key); |
- |
- cprintf("main: creating J1\n"); |
- err = pthread_create(&j1, NULL, J, (void *)1414); |
- if (err) cprintf("Error creating J1\n"); |
- cprintf("main: J1 has PID %d\n",j1); |
- |
- cprintf("main: creating J2\n"); |
- err = pthread_create(&j2, NULL, J, (void *)3141); |
- if (err) cprintf("Error creating J2\n"); |
- cprintf("main: J2 has PID %d\n",j2); |
- |
- cprintf("main: waiting 0.4 sec\n"); |
- while (sys_gettime(NULL) < 400000); |
- |
- cprintf("main: kill J1 and J2\n"); |
- pthread_cancel(j1); |
- pthread_cancel(j2); |
- |
- cprintf("main: ending...\n"); |
- |
- return 0; |
-} |
Index: tags/rel_1_22/pse51/ptest3.c |
=================================================================== |
--- tags/rel_1_22/pse51/ptest3.c (revision 1310) |
+++ tags/rel_1_22/pse51/ptest3.c (nonexistent) |
@@ -1,229 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: ptest3.c,v 1.1.1.1 2002-09-02 09:37:47 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1.1.1 $ |
- Last update: $Date: 2002-09-02 09:37:47 $ |
- ------------ |
- |
- Posix test 3: |
- |
- timers... |
- it creates two periodic timers that queues signals, a periodic timer |
- that create tasks and an one-shot timer. |
- |
- non standard function used: |
- cprintf |
- sys_gettime |
- keyboard stuffs |
- sys_end |
- |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include <sys/types.h> |
-#include <pthread.h> |
-#include <time.h> |
- |
-#include <kernel/kern.h> |
-#include <drivers/keyb.h> |
- |
-int count25 = 0, count26 = 0; |
- |
-void signal_handler(int signo, siginfo_t *info, void *extra) |
-{ |
- switch (signo) { |
- case 25: |
- count25++; |
- break; |
- case 26: |
- count26++; |
- break; |
- } |
- |
- cprintf("Signal %d code=%s value=%d task=%d count25=%d count26=%d time=%ldusec\n", |
- info->si_signo, |
- (info->si_code == SI_TIMER) ? "Timer" : "Other", |
- info->si_value.sival_int, |
- info->si_task, |
- count25, |
- count26, |
- sys_gettime(NULL)); |
-} |
- |
-void fine(KEY_EVT *e) |
-{ |
- sys_end(); |
-} |
- |
-void task_timer(union sigval value) |
-{ |
- cprintf("task_timer: value = %d, time = %ldusec\n", |
- value.sival_int, sys_gettime(NULL)); |
-} |
- |
-int main(int argc, char **argv) |
-{ |
- int err; |
- timer_t timer1, timer2, timer3; |
- struct itimerspec timeout1, timeout2, timeout3, nulltimeout; |
- struct sigaction sig_act; |
- struct sigevent ev25, ev26, evtask; |
- pthread_attr_t task_attr; |
- struct sched_param task_param; |
- |
- KEY_EVT emerg; |
- //keyb_set_map(itaMap); |
- emerg.ascii = 'x'; |
- emerg.scan = KEY_X; |
- emerg.flag = ALTL_BIT; |
- keyb_hook(emerg,fine); |
- |
- sig_act.sa_sigaction = (void *) signal_handler; |
- sig_act.sa_flags = SA_SIGINFO; |
- sigemptyset(&sig_act.sa_mask); |
- |
- sigaction(25, &sig_act, NULL); |
- sigaction(26, &sig_act, NULL); |
- |
- // set ev25, ev26, evtask |
- ev25.sigev_notify = SIGEV_SIGNAL; |
- ev25.sigev_signo = 25; |
- ev25.sigev_value.sival_int = 555; |
- |
- ev26.sigev_notify = SIGEV_SIGNAL; |
- ev26.sigev_signo = 26; |
- ev26.sigev_value.sival_int = 666; |
- |
- evtask.sigev_notify = SIGEV_THREAD; |
- evtask.sigev_value.sival_int = 777; |
- evtask.sigev_notify_function = task_timer; |
- evtask.sigev_notify_attributes = &task_attr; |
- |
- pthread_attr_init(&task_attr); |
- pthread_attr_setdetachstate(&task_attr, PTHREAD_CREATE_DETACHED); |
- pthread_attr_setschedpolicy(&task_attr, SCHED_FIFO); |
- task_param.sched_priority = 10; |
- pthread_attr_setschedparam(&task_attr, &task_param); |
- |
- // set timeout1, timeout2, nulltimeout |
- timeout1.it_interval.tv_sec = 0; |
- timeout1.it_interval.tv_nsec = 500000000; |
- timeout1.it_value.tv_sec = 3; |
- timeout1.it_value.tv_nsec = 0; |
- |
- timeout2.it_interval.tv_sec = 0; |
- timeout2.it_interval.tv_nsec = 200000000; |
- timeout2.it_value.tv_sec = 7; |
- timeout2.it_value.tv_nsec = 0; |
- |
- timeout3.it_interval.tv_sec = 0; |
- timeout3.it_interval.tv_nsec = 300000000; |
- timeout3.it_value.tv_sec = 5; |
- timeout3.it_value.tv_nsec = 0; |
- |
- NULL_TIMESPEC(&nulltimeout.it_value); |
- NULL_TIMESPEC(&nulltimeout.it_interval); |
- |
- // create the timers |
- err = timer_create(CLOCK_REALTIME, &ev25, &timer1); |
- if (err == -1) { cprintf("main: unable to create timer 1\n"); } |
- |
- err = timer_create(CLOCK_REALTIME, &ev26, &timer2); |
- if (err == -1) { cprintf("main: unable to create timer 2\n"); } |
- |
- err = timer_create(CLOCK_REALTIME, &evtask, &timer3); |
- if (err == -1) { cprintf("main: unable to create timer 3\n"); } |
- |
- // arm the timers |
- err = timer_settime(timer1, TIMER_ABSTIME, &timeout1, NULL); |
- if (err == -1) { cprintf("main: unable to set timer 1\n"); } |
- |
- err = timer_settime(timer2, 0, &timeout2, NULL); |
- if (err == -1) { cprintf("main: unable to set timer 2\n"); } |
- |
- err = timer_settime(timer3, TIMER_ABSTIME, &timeout3, NULL); |
- if (err == -1) { cprintf("main: unable to set timer 3\n"); } |
- |
- cprintf("main: waiting signals...\n"); |
- while (sys_gettime(NULL) < 8500000) { |
- //kern_deliver_pending_signals(); |
- } |
- |
- cprintf("main: disarm the timer2\n"); |
- err = timer_settime(timer2, 0, &nulltimeout, &timeout2); |
- if (err == -1) { cprintf("main: unable to disarm timer 2\n"); } |
- |
- cprintf("main: timer2 disarmed, itvalue=%ld.%ld\n", |
- timeout2.it_value.tv_sec,timeout2.it_value.tv_nsec/1000); |
- |
- while (sys_gettime(NULL) < 10000000) { |
- //kern_deliver_pending_signals(); |
- } |
- |
- cprintf("main: disarm the timer1\n"); |
- err = timer_settime(timer1, TIMER_ABSTIME, &nulltimeout, &timeout1); |
- if (err == -1) { cprintf("main: unable to disarm timer 1\n"); } |
- |
- cprintf("main: timer1 disarmed, itvalue=%ld.%ld\n", |
- timeout1.it_value.tv_sec,timeout1.it_value.tv_nsec/1000); |
- |
- while (sys_gettime(NULL) < 12000000) { |
- //kern_deliver_pending_signals(); |
- } |
- |
- cprintf("main: arm timer1\n"); |
- timeout1.it_interval.tv_sec = 0; |
- timeout1.it_interval.tv_nsec = 0; |
- timeout1.it_value.tv_sec = 13; |
- timeout1.it_value.tv_nsec = 0; |
- err = timer_settime(timer1, TIMER_ABSTIME, &timeout1, NULL); |
- if (err == -1) { cprintf("main: unable to arm timer 1\n"); } |
- |
- while (sys_gettime(NULL) < 14000000) { |
- //kern_deliver_pending_signals(); |
- } |
- |
- |
- |
- cprintf("main: ending...\n"); |
- |
- return 0; |
-} |
Index: tags/rel_1_22/pse51/pinit.c |
=================================================================== |
--- tags/rel_1_22/pse51/pinit.c (revision 1310) |
+++ tags/rel_1_22/pse51/pinit.c (nonexistent) |
@@ -1,126 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: pinit.c,v 1.2 2003-10-07 09:30:18 giacomo Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.2 $ |
- Last update: $Date: 2003-10-07 09:30:18 $ |
- ------------ |
- |
- This is a minimal initialization file for the PSE51 profile. |
- |
- It initializes the POSIX scheduler, the Hartik Ports and the Keyboard driver. |
- |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
- |
- |
-#include "kernel/kern.h" |
-#include "modules/posix.h" |
-#include "modules/dummy.h" |
- |
-#include "modules/pi.h" |
-#include "modules/pc.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
- |
-#include "drivers/keyb.h" |
- |
-#include "pthread.h" |
-#include "time.h" |
- |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 1000 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 10000 |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- POSIX_register_level(RRTICK, POSIX_MAIN_YES, mb, 32); |
- dummy_register_level(); |
- |
- PI_register_module(); |
- PC_register_module(); |
- |
- SEM_register_module(); |
- |
- /* for the Pthread library */ |
- PTHREAD_register_module(0, 0, 1); |
- |
- /* for the real time clock extensions */ |
- TIMER_register_module(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- NRT_TASK_MODEL m; // the scheduling model for the Keyboard |
- |
- KEYB_PARMS k = BASE_KEYB; |
- keyb_def_task(k, &m); |
- |
- nrt_task_default_model(m); |
- nrt_task_def_arg(m,arg); |
- nrt_task_def_usemath(m); |
- nrt_task_def_ctrl_jet(m); |
- nrt_task_def_save_arrivals(m); |
- nrt_task_def_unjoinable(m); |
- nrt_task_def_weight(m, sched_get_priority_max(SCHED_RR)); |
- nrt_task_def_policy(m,SCHED_RR); |
- nrt_task_def_inherit(m,PTHREAD_EXPLICIT_SCHED); |
- nrt_task_def_nokill(m); |
- nrt_task_def_system(m); |
- |
- HARTPORT_init(); |
- |
- if (KEYB_init(&k) < 0) |
- kern_printf("Error during Keyboard Initialization!!!"); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
Index: tags/rel_1_22/pse51/ptest4.c |
=================================================================== |
--- tags/rel_1_22/pse51/ptest4.c (revision 1310) |
+++ tags/rel_1_22/pse51/ptest4.c (nonexistent) |
@@ -1,151 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: ptest4.c,v 1.1.1.1 2002-09-02 09:37:47 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1.1.1 $ |
- Last update: $Date: 2002-09-02 09:37:47 $ |
- ------------ |
- |
- Posix test 4: |
- |
- the main task create 3 tasks, J1, J2, J3 |
- at t = 1 sec. it raise a signal to J1 |
- at t = 2 sec. it kills J2 |
- |
- J1,J2,J3: it simply calls nanosleep |
- |
- non standard function used: |
- cprintf |
- sys_gettime |
- keyboard stuffs |
- sys_end |
- |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include <sys/types.h> |
-#include <pthread.h> |
-#include <signal.h> |
-#include <time.h> |
- |
-#include <kernel/kern.h> |
-#include <drivers/keyb.h> |
- |
-void uscitaJ(void *arg) |
-{ |
- cprintf("J: (pid=%d) AAAARRRRGGGHHH!!! killed by someone...\n", exec_shadow); |
-} |
- |
-void *J(void *arg) |
-{ |
- struct timespec t1, t2; |
- int err; |
- |
- cprintf("J (pid=%d) starts and call nanosleep\n",exec_shadow); |
- |
- t1.tv_sec = 3; |
- t1.tv_nsec = 0; |
- NULL_TIMESPEC(&t2); |
- pthread_cleanup_push(uscitaJ,NULL); |
- err = nanosleep(&t1, &t2); |
- pthread_cleanup_pop(0); |
- |
- cprintf("J (pid=%d) ending, nanosleep returns errno=%d, t2=%ld.%ld\n", |
- exec_shadow, err, t2.tv_sec, t2.tv_nsec/1000); |
- |
- return 0; |
-} |
- |
-void signal_handler(int signo, siginfo_t *info, void *extra) |
-{ |
- cprintf("SIGNAL HANDLER: pid=%d\n",exec_shadow); |
-} |
- |
-void fine(KEY_EVT *e) |
-{ |
- sys_end(); |
-} |
- |
- |
-int main(int argc, char **argv) |
-{ |
- int err; |
- pthread_t j1, j2, j3; |
- struct sigaction sig_act; |
- |
- KEY_EVT emerg; |
- //keyb_set_map(itaMap); |
- emerg.ascii = 'x'; |
- emerg.scan = KEY_X; |
- emerg.flag = ALTL_BIT; |
- keyb_hook(emerg,fine); |
- |
- sig_act.sa_sigaction = (void *) signal_handler; |
- sig_act.sa_flags = SA_SIGINFO; |
- sigemptyset(&sig_act.sa_mask); |
- |
- sigaction(31, &sig_act, NULL); |
- |
- cprintf("main: creating J1\n"); |
- err = pthread_create(&j1, NULL, J, NULL); |
- if (err) cprintf("Error creating J1\n"); |
- |
- cprintf("main: creating J2\n"); |
- err = pthread_create(&j2, NULL, J, NULL); |
- if (err) cprintf("Error creating J2\n"); |
- |
- cprintf("main: creating J3\n"); |
- err = pthread_create(&j3, NULL, J, NULL); |
- if (err) cprintf("Error creating J3\n"); |
- |
- cprintf("main: waiting 1 sec\n"); |
- while (sys_gettime(NULL) < 1000000); |
- |
- cprintf("main: pthread_kill on j1, then wait until t=2 sec \n"); |
- pthread_kill(j1, 31); |
- |
- while (sys_gettime(NULL) < 2000000); |
- cprintf("main: pthread_cancel(J2)\n"); |
- pthread_cancel(j2); |
- |
- cprintf("main: ending...\n"); |
- |
- return 0; |
-} |
Index: tags/rel_1_22/mix/mix.dat |
=================================================================== |
--- tags/rel_1_22/mix/mix.dat (revision 1310) |
+++ tags/rel_1_22/mix/mix.dat (nonexistent) |
@@ -1,12 +0,0 @@ |
-TASK NAME PERIOD WCET |
------------------------------------------- |
-task1 watch: 1000000 200 |
-task2 tasto: 2000 200 |
-task3 palla: 2000 200 |
-task4 mosca: 20000 200 |
-task5 infor: 20000 300 |
-task6 ruota: 5000 400 |
-task7 color: 2000 200 |
-task8 pendo: 5000 400 |
------------------------------------------- |
- |
Index: tags/rel_1_22/mix/initfile.c |
=================================================================== |
--- tags/rel_1_22/mix/initfile.c (revision 1310) |
+++ tags/rel_1_22/mix/initfile.c (nonexistent) |
@@ -1,124 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- ------------ |
- CVS : $Id: initfile.c,v 1.1.1.1 2002-09-02 09:37:45 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1.1.1 $ |
- Last update: $Date: 2002-09-02 09:37:45 $ |
- ------------ |
- |
- System initialization file |
- |
- This file contains the 2 functions needed to initialize the system. |
- |
- These functions register the following levels: |
- |
- an EDF (Earliest Deadline First) level |
- a RR (Round Robin) level |
- a CBS (Costant Bandwidth Server) level |
- a Dummy level |
- |
- It can accept these task models: |
- |
- HARD_TASK_MODEL (wcet+mit) at level 0 |
- SOFT_TASK_MODEL (met, period) at level 1 |
- NRT_TASK_MODEL at level 2 |
- |
- This file is similar to the configuration of kernel/init/hartik3.c |
- |
- TICK is set to 0 (one-shot timer is used) |
-*/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/cbs.h" |
-#include "modules/rr.h" |
-#include "modules/dummy.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
- |
-#include "drivers/keyb.h" |
- |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 0 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 10000 |
- |
-void read_file(); |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- EDF_register_level(0); |
- CBS_register_level(0, 0); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- |
- CABS_register_module(); |
- |
- read_file(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- KEYB_PARMS kparms = BASE_KEYB; |
- |
- HARTPORT_init(); |
- |
- keyb_def_ctrlC(kparms, NULL); |
- keyb_def_map(kparms,itaMap); |
- KEYB_init(&kparms); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
Index: tags/rel_1_22/mix/readme |
=================================================================== |
--- tags/rel_1_22/mix/readme (revision 1310) |
+++ tags/rel_1_22/mix/readme (nonexistent) |
@@ -1,7 +0,0 @@ |
-MIX |
---- |
- |
-This simple applications is a pout-pourri of simple graphic tasks |
-that does different things with different timing constraints... |
- |
-Paolo |
\ No newline at end of file |
Index: tags/rel_1_22/mix/makefile |
=================================================================== |
--- tags/rel_1_22/mix/makefile (revision 1310) |
+++ tags/rel_1_22/mix/makefile (nonexistent) |
@@ -1,16 +0,0 @@ |
-# |
-# |
-# |
- |
-ifndef BASE |
-BASE=../.. |
-endif |
-include $(BASE)/config/config.mk |
- |
-PROGS= mix |
- |
-include $(BASE)/config/example.mk |
- |
-mix: |
- make -f $(SUBMAKE) APP=mix INIT= OTHEROBJS="initfile.o" OTHERINCL= SHARKOPT="__OLDCHAR__ __GRX__" |
- |
Index: tags/rel_1_22/mix/mix.c |
=================================================================== |
--- tags/rel_1_22/mix/mix.c (revision 1310) |
+++ tags/rel_1_22/mix/mix.c (nonexistent) |
@@ -1,761 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- ------------ |
- CVS : $Id: mix.c,v 1.4 2003-03-24 11:18:19 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.4 $ |
- Last update: $Date: 2003-03-24 11:18:19 $ |
- ------------ |
-*/ |
- |
-/* |
- * Copyright (C) 2000 Giorgio Buttazzo and Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-/*--------------------------------------------------------------*/ |
-/* DEMO with 9 INDEPENDENT TASKS */ |
-/*--------------------------------------------------------------*/ |
- |
-#include <kernel/kern.h> |
-#include <drivers/glib.h> |
-#include <drivers/keyb.h> |
-#include <semaphore.h> |
-#include <stdlib.h> |
-#include <math.h> |
- |
-#define PIG 3.1415 |
-#define ESC 27 /* ASCII code for ESCAPE */ |
-#define DURATA 10000 /* counter duration in tick */ |
- |
-#define LW 200 /* window length */ |
-#define HW 150 /* window height */ |
-#define HLOAD 30 /* Y level for the max load */ |
-#define LLOAD (HW-HLOAD-5) /* length for the max load */ |
- |
-#define XWL 10 /* left X of LEFT window */ |
-#define XWM 220 /* left X of MIDDLE window */ |
-#define XWR 430 /* left X RIGHT window */ |
- |
-#define YWH 5 /* top Y of HIGH window */ |
-#define YWM 165 /* top Y of MIDDLE window */ |
-#define YWL 325 /* top Y of LOW window */ |
- |
-char fbuf[1000]; /* buffer for reading a file */ |
-int flen; /* file length */ |
-int fine = 0; /* ending flag */ |
- |
-sem_t mx_mat, mx_grf; /* mutex semaphores */ |
- |
-int wcet[10]; /* array of task wcets */ |
-int period[10]; /* array of task periods */ |
-double load(long); /* load evaluation function */ |
- |
-PID ptas; |
-char talk[5][25] = {" SHARK Demonstration ", |
- " RETIS Lab -- Scuola ", |
- " Superiore S. Anna ", |
- " HARD REAL-TIME DEMO ", |
- " June 5, 2001 "}; |
- |
-/*------------------------------------------------------*/ |
-/* file reading */ |
-/*------------------------------------------------------*/ |
- |
-void read_file(void) |
-{ |
- int err; |
- DOS_FILE *fp; |
- |
- fp = DOS_fopen("mix.dat","r"); |
- |
- if (!fp) { |
- err = DOS_error(); |
- cprintf("Error %d opening myfile.txt...\n", err); |
- flen = 0; |
- return; |
- } |
- |
- flen = DOS_fread(&fbuf, 1, 1000, fp); |
- cprintf("Read %d bytes from file\n", flen); |
- DOS_fclose(fp); |
-} |
- |
-/*------------------------------------------------------*/ |
-/* get data from buffer */ |
-/*------------------------------------------------------*/ |
- |
-void get_par(void) |
-{ |
- int x = 0; |
- int i; |
- |
- for (i=1; i<=8; i++) { |
- while ((fbuf[x] != ':') && (x < flen)) x++; |
- x++; |
- sscanf(&fbuf[x], "%d %d", &period[i], &wcet[i]); |
- cprintf("per[%d] = %d, wcet[%d] = %d\n", |
- i, period[i], i, wcet[i]); |
- } |
-} |
- |
-/*--------------------------------------------------------------*/ |
- |
-void byebye() |
-{ |
- grx_close(); |
- kern_printf("Bye Bye!\n"); |
-} |
- |
-/*--------------------------------------------------------------*/ |
- |
-void finish1() |
-{ |
- sys_end(); |
-} |
- |
-/*--------------------------------------------------------------*/ |
- |
-void finish2() |
-{ |
- fine = 1; |
-} |
- |
-/****************************************************************/ |
-/* PROCESSO OROLOGIO */ |
-/****************************************************************/ |
- |
-#define LLAN 40 /* length of watch stick */ |
- |
-TASK watch() |
-{ |
- int x0 = XWL + LW/2; |
- int y0 = YWH + HW/2; |
- int grad; |
- int xg, yg; |
- int xt, yt, d; |
- int sec, min; |
- char s[5]; |
- double rad, x, y; |
- |
- xg = x0; |
- yg = y0 - LLAN; |
- xt = XWL + 78; |
- yt = YWH + 12; |
- sec = min = 0; |
- |
- while (1) { |
- sec = (sec + 1) % 60; |
- if (sec == 0) min++; |
- grad = 90 - sec * 6; |
- rad = (double)grad * PIG / 180.; |
- |
- sem_wait(&mx_mat); |
- x = (double)x0 + (double)LLAN * cos(rad); |
- y = (double)y0 - (double)LLAN * sin(rad); |
- sem_post(&mx_mat); |
- |
- sem_wait(&mx_grf); |
- grx_line(x0, y0, xg, yg, 0); |
- sem_post(&mx_grf); |
- |
- xg = x; |
- yg = y; |
- |
- sem_wait(&mx_grf); |
- grx_line(x0, y0, xg, yg, 14); |
- sem_post(&mx_grf); |
- |
- sem_wait(&mx_grf); |
- grx_text("0 :0 ", xt, yt, 14, 0); |
- sprintf(s, "%d", min); |
- grx_text(s, xt+8, yt, 14, 0); |
- sprintf(s, "%d", sec); |
- if (sec > 9) d = 24; else d = 32; |
- grx_text(s, xt+d, yt, 14, 0); |
- sem_post(&mx_grf); |
- |
- task_endcycle(); |
- } |
-} |
- |
-/****************************************************************/ |
-/* PROCESSO DI RIEMPIMENTO */ |
-/****************************************************************/ |
- |
-#define CIMA (YWH+5) /* fondo del recipiente */ |
-#define FONDO (YWH+HW-5) /* cima del recipiente */ |
-#define LREC (XWM+75) /* lato sinistro recipiente */ |
-#define DREC 50 /* diametro del recipiente */ |
- |
-TASK tasto() |
-{ |
- int x, y; |
- int x0; /* coord. sinistra recipiente */ |
- int col, cliq, bkg; |
- int i; |
- int liv; /* livello del liquido */ |
- |
- cliq = 9; |
- bkg = 14; |
- x0 = LREC; |
- x = x0 + DREC/2; |
- y = CIMA; |
- liv = FONDO; |
- |
- while (1) { |
- |
- col = cliq; |
- for (i=0; i<2; i++) { /* disegna goccia */ |
- while (y < liv) { |
- sem_wait(&mx_grf); |
- grx_plot(x,y,col); |
- sem_post(&mx_grf); |
- y++; |
- } |
- y = CIMA; |
- col = bkg; |
- } |
- |
- liv--; |
- sem_wait(&mx_grf); |
- grx_line(x0+1, liv, x0+DREC-1, liv, cliq); |
- sem_post(&mx_grf); |
- |
- if (liv <= CIMA+1) { /* swap colors */ |
- i = bkg; bkg = cliq; cliq = i; |
- liv = FONDO; |
- } |
- |
- task_endcycle(); |
- } |
-} |
- |
-/****************************************************************/ |
- |
-void kboar() |
-{ |
- task_activate(ptas); |
-} |
- |
-/****************************************************************/ |
-/* PROCESSO PALLA */ |
-/****************************************************************/ |
- |
-#define VMIN 11. /* velocitÂ… minima per suono */ |
-#define LP 3 /* lato della pallina */ |
- |
-TASK palla() |
-{ |
- int ox, oy; /* vecchia posizione pallina */ |
- int x0; /* posizione iniziale pallina */ |
- int xmin, xmax; |
- int base, top; |
- int xg, yg; /* coordinate grafiche pallina */ |
- double x, y; /* coordinate pallina */ |
- double G = 9.8; |
- double vx, vy, v0; /* velocitÂ… della pallina */ |
- double t, tx; /* variabile temporale */ |
- double dt; /* incremento temporale */ |
- double arg; /* variabile di appoggio */ |
- |
- xmin = XWR+LP+1; |
- xmax = XWR+LW-LP-1; |
- base = YWH+HW-LP-1; |
- top = HW-10-LP; |
- x = ox = x0 = xmin; |
- y = oy = top; |
- arg = 2.*G*(double)top; |
- vy = v0 = sqrt(arg); |
- vx = 15.; |
- tx = 0.0; |
- t = vy / G; |
- dt = .02; |
- |
- while (1) { |
- x = x0 + vx*tx; |
- y = base - vy*t + .5*G*t*t; |
- if (y >= base) { |
- t = 0.0; |
- vy = v0; |
- y = base - vy*t + .5*G*t*t; |
- } |
- if (x >= xmax) { |
- tx = 0.0; |
- x0 = xmax; |
- vx = -vx; |
- x = x0 + vx*tx; |
- } |
- if (x <= xmin) { |
- tx = 0.0; |
- x0 = xmin; |
- vx = -vx; |
- x = x0 + vx*tx; |
- } |
- xg = x; yg = y; |
- sem_wait(&mx_grf); |
- grx_disc(ox,oy,LP,0); |
- grx_disc(xg,yg,LP,10); |
- sem_post(&mx_grf); |
- oy = yg; ox = xg; |
- t += dt; |
- tx += dt; |
- task_endcycle(); |
- } |
-} |
- |
-/****************************************************************/ |
-/* PROCESSO MOSCA */ |
-/****************************************************************/ |
- |
-TASK mosca() |
-{ |
- int x, y, Ax, Ay, h; |
- int x0, y0, tet; |
- int xmax,ymax; |
- double A, B; |
- double r; |
- double rnd; |
- |
- xmax = LW/2-1; ymax = HW/2-1; |
- x = 0; y = 0; tet = 0; |
- x0 = XWL+LW/2; y0 = YWM+HW/2; |
- A = 5.; B = 30.; |
- |
- while (1) { |
- |
- rnd = (rand()%100)/100.; /* rnd = [0,1] */ |
- h = (2. * B * rnd) - B; /* h = [-B,B] */ |
- tet = tet + h; |
- |
- if (tet > 360) tet = tet - 360; |
- if (tet < 0) tet = tet + 360; |
- r = tet * PIG / 180.; |
- |
- sem_wait(&mx_mat); |
- Ax = (double)(A * cos(r)); |
- Ay = (double)(A * sin(r)); |
- sem_post(&mx_mat); |
- x = x + Ax; |
- y = y + Ay; |
- |
- if ((x >= xmax) || (x <= -xmax) || |
- (y >= ymax) || (y <= -ymax)) { |
- x = x - Ax; |
- y = y - Ay; |
- tet = tet - 180; |
- if (tet > 360) tet = tet - 360; |
- if (tet < 0) tet = tet + 360; |
- r = tet * PIG / 180.; |
- sem_wait(&mx_mat); |
- Ax = (double)(A * cos(r)); |
- Ay = (double)(A * sin(r)); |
- sem_post(&mx_mat); |
- x = x + Ax; |
- y = y + Ay; |
- } |
- sem_wait(&mx_grf); |
- grx_plot(x+x0, y+y0, 10); |
- sem_post(&mx_grf); |
- task_endcycle(); |
- } |
-} |
- |
-/****************************************************************/ |
-/* PROCESSO INFORMAZIONI */ |
-/****************************************************************/ |
- |
-TASK infor() |
-{ |
- char s[2]; |
- int x, y; |
- int r; |
- int i = 0; |
- int leng; |
- int col = 0; |
- |
- r = 0; |
- x = XWM + 16; |
- y = YWM + 40; |
- s[1] = 0; |
- |
- leng = 0; |
- while (talk[0][leng] != 0) leng++; |
- |
- while (1) { |
- s[0] = talk[r][i]; |
- sem_wait(&mx_grf); |
- grx_text(s,x+i*8,y+r*8,col+10,1); |
- sem_post(&mx_grf); |
- i++; |
- if (i == leng) { |
- i = 0; |
- r = (r + 1) % 5; |
- if (r == 0) col = (col + 1) % 6; |
- } |
- task_endcycle(); |
- } |
-} |
- |
-/****************************************************************/ |
-/* PROCESSO RUOTA */ |
-/****************************************************************/ |
- |
-TASK ruota() |
-{ |
- int x0 = XWR + LW/2; |
- int y0 = YWM + HW/2; |
- int grad = 90; |
- int xg, yg; |
- double rad, x, y; |
- |
- xg = x0; |
- yg = y0 + LLAN; |
- |
- while (1) { |
- |
- rad = (double)grad * PIG / 180.; |
- |
- sem_wait(&mx_mat); |
- x = (double)x0 + (double)LLAN * cos(rad); |
- y = (double)y0 + (double)LLAN * sin(rad); |
- sem_post(&mx_mat); |
- |
- sem_wait(&mx_grf); |
- grx_disc(xg, yg, 4, 0); |
- sem_post(&mx_grf); |
- |
- xg = x; yg = y; |
- |
- sem_wait(&mx_grf); |
- grx_disc(xg, yg, 4, 13); |
- sem_post(&mx_grf); |
- |
- grad = (grad + 1) % 360; |
- |
- task_endcycle(); |
- } |
-} |
- |
-/****************************************************************/ |
-/* PROCESSO COLORI */ |
-/****************************************************************/ |
- |
-TASK color() |
-{ |
- int xx0 = XWL+5; |
- int yy0 = YWL+5; |
- int n, col; |
- int x, y; |
- |
- x = 0; y = 0; |
- |
- while (1) { |
- n = 19. * ((rand()%100)/100.); |
- x = xx0 + n * 10; |
- n = 14. * ((rand()%100)/100.); |
- y = yy0 + n * 10; |
- col = 16. * ((rand()%100)/100.); |
- |
- /* xg = xx0 + x; |
- yg = yy0 + y; |
- x = (x + 10)%(LW-10); |
- y = (y + 10)%(HW-10); |
- */ |
- sem_wait(&mx_grf); |
- grx_box(x, y, x+9, y+9, col); |
- sem_post(&mx_grf); |
- |
- task_endcycle(); |
- } |
-} |
- |
-/****************************************************************/ |
-/* PROCESSO PENDOLO */ |
-/****************************************************************/ |
- |
-TASK pendo() |
-{ |
- int x0 = XWM+LW/2; |
- int y0 = YWL+10; |
- int xg, yg; |
- int col = 11; |
- double x, y, teta; |
- double v, a, dt; |
- double g, l; |
- |
- g = 9.8; |
- l = 80.; |
- dt = 0.1; |
- teta = 40. * PIG / 180.; |
- v = 0.; |
- sem_wait(&mx_mat); |
- x = l * sin((double)teta); |
- y = l * cos((double)teta); |
- a = -(g/l) * sin((double)teta); |
- sem_post(&mx_mat); |
- xg = x0 + x; |
- yg = y0 + y; |
- |
- while (1) { |
- |
- v += a * dt; |
- teta += v * dt; |
- sem_wait(&mx_mat); |
- x = l * sin((double)teta); |
- y = l * cos((double)teta); |
- a = -(g/l) * sin((double)teta); |
- sem_post(&mx_mat); |
- |
- sem_wait(&mx_grf); |
- grx_line(x0, y0, xg, yg, 0); |
- grx_circle(xg, yg, 5, 0); |
- grx_disc(xg, yg, 4, 0); |
- sem_post(&mx_grf); |
- |
- xg = x0+x; yg = y0+y; |
- |
- sem_wait(&mx_grf); |
- grx_line(x0, y0, xg, yg, col); |
- grx_circle(xg, yg, 5, col+2); |
- grx_disc(xg, yg, 4, col+1); |
- sem_post(&mx_grf); |
- |
- task_endcycle(); |
- } |
-} |
- |
-/****************************** gener ******************************/ |
- |
-TASK gener() |
-{ |
- HARD_TASK_MODEL m; |
- SOFT_TASK_MODEL am; |
- PID pid; |
- |
- //--------------------------------------------- |
- hard_task_default_model(m); |
- hard_task_def_wcet (m, wcet[1]); |
- hard_task_def_mit (m, period[1]); |
- hard_task_def_usemath (m); |
- pid = task_create("watch", watch, &m, NULL); |
- task_activate(pid); |
- keyb_getch(BLOCK); |
- //--------------------------------------------- |
- soft_task_default_model(am); |
- soft_task_def_met (am, wcet[2]); |
- soft_task_def_period (am, period[2]); |
- soft_task_def_aperiodic(am); |
- soft_task_def_usemath (am); |
- ptas = task_create("tasto", tasto, &am, NULL); |
- task_activate(ptas); |
- keyb_getch(BLOCK); |
- //--------------------------------------------- |
- hard_task_default_model(m); |
- hard_task_def_wcet (m, wcet[3]); |
- hard_task_def_mit (m, period[3]); |
- hard_task_def_usemath (m); |
- pid = task_create("palla", palla, &m, NULL); |
- task_activate(pid); |
- keyb_getch(BLOCK); |
- //--------------------------------------------- |
- hard_task_default_model(m); |
- hard_task_def_wcet (m, wcet[4]); |
- hard_task_def_mit (m, period[4]); |
- hard_task_def_usemath (m); |
- pid = task_create("mosca", mosca, &m, NULL); |
- task_activate(pid); |
- keyb_getch(BLOCK); |
- //--------------------------------------------- |
- hard_task_default_model(m); |
- hard_task_def_wcet (m, wcet[5]); |
- hard_task_def_mit (m, period[5]); |
- hard_task_def_usemath (m); |
- pid = task_create("infor", infor, &m, NULL); |
- task_activate(pid); |
- keyb_getch(BLOCK); |
- //--------------------------------------------- |
- hard_task_default_model(m); |
- hard_task_def_wcet (m, wcet[6]); |
- hard_task_def_mit (m, period[6]); |
- hard_task_def_usemath (m); |
- pid = task_create("ruota", ruota, &m, NULL); |
- task_activate(pid); |
- keyb_getch(BLOCK); |
- //--------------------------------------------- |
- hard_task_default_model(m); |
- hard_task_def_wcet (m, wcet[7]); |
- hard_task_def_mit (m, period[7]); |
- hard_task_def_usemath (m); |
- pid = task_create("color", color, &m, NULL); |
- task_activate(pid); |
- keyb_getch(BLOCK); |
- //--------------------------------------------- |
- hard_task_default_model(m); |
- hard_task_def_wcet (m, wcet[8]); |
- hard_task_def_mit (m, period[8]); |
- hard_task_def_usemath (m); |
- pid = task_create("pendo", pendo, &m, NULL); |
- task_activate(pid); |
- //--------------------------------------------- |
- |
- return NULL; |
-} |
- |
-/****************************** MAIN ******************************/ |
- |
-int main() |
-{ |
- char s[20]; /* carattere letto da tastiera */ |
- int x0, y0; |
- int x, y; |
- TIME t1, count; /* contatori valutazione carico */ |
- double car; /* valore del carico corrente */ |
- TIME seme; |
- PID pid; |
- NRT_TASK_MODEL m2; |
- KEY_EVT eva, evx, evs; |
- |
- sys_atrunlevel(byebye, NULL, RUNLEVEL_BEFORE_EXIT); |
- |
- /* set the keyboard handler */ |
- eva.ascii = 'a'; |
- eva.scan = KEY_A; |
- eva.flag = 0; |
- keyb_hook(eva,kboar); |
- |
- evx.ascii = 'x'; |
- evx.scan = KEY_X; |
- evx.flag = ALTL_BIT; |
- keyb_hook(evx,finish1); |
- |
- evs.ascii = ESC; |
- evs.scan = KEY_ESC; |
- evs.flag = 0; |
- keyb_hook(evs,finish2); |
- |
- sem_init(&mx_mat,0,1); |
- sem_init(&mx_grf,0,1); |
- |
- seme = sys_gettime(NULL); |
- srand(seme); |
- |
- get_par(); |
- keyb_getch(BLOCK); |
- |
- grx_init(); |
- grx_open(640, 480, 8); |
- |
- grx_rect(XWL,YWH,XWL+LW,YWH+HW,14); |
- grx_rect(XWM,YWH,XWM+LW,YWH+HW,14); |
- grx_rect(XWR,YWH,XWR+LW,YWH+HW,14); |
- |
- grx_rect(XWL,YWM,XWL+LW,YWM+HW,14); |
- grx_rect(XWM,YWM,XWM+LW,YWM+HW,14); |
- grx_rect(XWR,YWM,XWR+LW,YWM+HW,14); |
- |
- grx_rect(XWL,YWL,XWL+LW,YWL+HW,14); |
- grx_rect(XWM,YWL,XWM+LW,YWL+HW,14); |
- grx_rect(XWR,YWL,XWR+LW,YWL+HW,14); |
- |
- x0 = XWL + LW/2; |
- y0 = YWH + HW/2; |
- grx_circle(x0, y0, LLAN+3, 12); |
- grx_rect(XWL+74, YWH+7, XWL+120, YWH+22, 12); |
- |
- x0 = LREC; |
- grx_line(x0, CIMA, x0, FONDO, 15); |
- grx_line(x0+DREC, CIMA, x0+DREC, FONDO, 15); |
- grx_line(x0, FONDO, x0+DREC, FONDO, 15); |
- grx_box(x0+1, CIMA, x0+DREC-1, FONDO-1, 14); |
- grx_text("Press A", XWM+16, YWH+48, 10, 0); |
- grx_text("to fill", XWM+16, YWH+64, 10, 0); |
- |
- grx_text("Press:", XWM+18, YWM+HW-50, 10, 0); |
- grx_text("ESC to exit", XWM+18, YWM+HW-40, 10, 0); |
- grx_text("SPACE to create", XWM+18, YWM+HW-30, 10, 0); |
- |
- x0 = XWR + LW/2; |
- y0 = YWM + HW/2; |
- grx_circle(x0, y0, LLAN/3, 14); |
- grx_disc(x0, y0, LLAN/3-1, 12); |
- |
- x0 = XWR+5; |
- y0 = YWL+HW-5; |
- grx_line(x0, YWL+HLOAD, x0+LW-10, YWL+HLOAD, 12); |
- grx_text("SYSTEM WORKLOAD:", x0+5, YWL+HLOAD-10, 10, 0); |
- |
- count = 0; |
- t1 = sys_gettime(NULL); |
- do count++; while (sys_gettime(NULL) < (t1 + DURATA)); |
- |
- nrt_task_default_model(m2); |
- pid = task_create("gener", gener, &m2, NULL); |
- task_activate(pid); |
- |
- x = 0; |
- while (!fine) { |
- car = load(count); |
- y = (double)LLOAD*car; |
- sem_wait(&mx_grf); |
- grx_line(x0+x, y0-LLOAD+1, x0+x, y0, 0); |
- grx_line(x0+x, y0-y, x0+x, y0, 15); |
- grx_text(" ", x0+LW-60, YWL+HLOAD-10, 0, 0); |
- sprintf(s, "%.3f", car); |
- grx_text(s, x0+LW-50, YWL+HLOAD-10, 15, 0); |
- sem_post(&mx_grf); |
- x = (x + 1) % (LW-10); |
- } |
- |
- sys_end(); |
- |
- return 0; |
-} |
- |
-/****************************************************************/ |
- |
-double load(long n) |
-{ |
- TIME i, t1; |
- double carico; |
- |
- i = 0; |
- t1 = sys_gettime(NULL); |
- do i++; while (sys_gettime(NULL) < (t1 + DURATA)); |
- carico = 1. - (double)i / (double)n; |
- return(carico); |
-} |
- |
-/****************************************************************/ |
Index: tags/rel_1_22/joy/joy_grx.c |
=================================================================== |
--- tags/rel_1_22/joy/joy_grx.c (revision 1310) |
+++ tags/rel_1_22/joy/joy_grx.c (nonexistent) |
@@ -1,177 +0,0 @@ |
- |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: Giorgio Buttazzo <giorgio@sssup.it> |
- * |
- * Authors : Paolo Gai <pj@hartik.sssup.it> |
- * (see authors.txt for full list of hartik's authors) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include <kernel/kern.h> |
-#include <kernel/func.h> |
-#include <stdlib.h> |
-#include <drivers/keyb.h> |
-#include <drivers/glib.h> |
-#include <semaphore.h> |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
- |
-#include <math.h> |
- |
-#include "joy.h" |
- |
-#define RGB_BLACK rgb16( 0, 0, 0) |
-#define RGB_GRAY rgb16(127,127,127) |
-#define RGB_WHITE rgb16(255,255,255) |
-#define RGB_RED rgb16(255, 0, 0) |
-#define RGB_GREEN rgb16( 0,255, 0) |
-#define RGB_BLUE rgb16( 0, 0,255) |
-#define RGB_YELLOW rgb16(255,255, 0) |
-#define RGB_MAGENTA rgb16(255, 0,255) |
-#define RGB_CYAN rgb16( 0,255,255) |
-#define RGB_D_RED rgb16(127, 0, 0) |
-#define RGB_D_GREEN rgb16( 0,127, 0) |
-#define RGB_D_BLUE rgb16( 0, 0,127) |
-#define RGB_D_YELLOW rgb16(127,127, 0) |
-#define RGB_D_MAGENTA rgb16(127, 0,127) |
-#define RGB_D_CYAN rgb16( 0,127,127) |
- |
-sem_t mx_mat, mx_grf; /* mutex semaphores */ |
-PID pid; |
-JOY_BOUND jb; |
- |
- |
-TASK write() |
-{ |
- int x = 319, y = 239; |
- float dx, dy; |
- JOY_STATE jsa; |
- |
- clear(); |
- |
- dx = 640 / (jb.x_max - jb.x_min); |
- dy = 480 / (jb.y_max - jb.y_min); |
- |
- while (1) { |
- sem_wait(&mx_grf); |
- grx_circle(10 + x, 10 + y, 9, RGB_BLACK); |
- sem_post(&mx_grf); |
- |
- get_joystick_A(&jsa); |
- |
- x = (jsa.x - jb.x_min) * dx; |
- y = (jsa.y - jb.y_min) * dy; |
- |
- sem_wait(&mx_grf); |
- if (jsa.b1==1) |
- grx_circle(10 + dx * x, 10 + dy * y, 9, RGB_RED); |
- else |
- grx_circle(10 + dx * x, 10 + dy * y, 9, RGB_YELLOW); |
- sem_post(&mx_grf); |
- |
- task_endcycle(); |
- } |
- return 0; |
-} |
- |
-void endfun(KEY_EVT *k) |
-{ |
- cprintf("Ctrl-Brk pressed! Ending...\n"); |
- sys_end(); |
-} |
- |
-void my_close(void *arg) |
-{ |
- int i; |
- TIME tmp; |
- |
- grx_close(); |
- kern_printf("Taskset Execution Time\n\n"); |
- for (i=3; i<MAX_PROC; i++){ |
- if (!jet_getstat(i, NULL, &tmp, NULL, NULL)) |
- kern_printf("Task Name : %s - Max Time : %d\n", proc_table[i].name, (int)tmp); |
- } |
-} |
- |
-void init_graph() { |
- grx_box( 0, 0,639,479,RGB_BLACK); |
-} |
- |
-int main(int argc, char **argv) |
-{ |
- SOFT_TASK_MODEL ms; |
- KEY_EVT k; |
- TIME seme; |
- int modenum; |
- |
- k.flag = CNTR_BIT; |
- k.scan = KEY_C; |
- k.ascii = 'c'; |
- keyb_hook(k,endfun); |
- |
- k.flag = CNTL_BIT; |
- k.scan = KEY_C; |
- k.ascii = 'c'; |
- keyb_hook(k,endfun); |
- |
- sem_init(&mx_mat,0,1); |
- sem_init(&mx_grf,0,1); |
- |
- seme = sys_gettime(NULL); |
- srand(seme); |
- |
- sys_atrunlevel(my_close, NULL, RUNLEVEL_BEFORE_EXIT); |
- |
- if (get_joystick_bound_A(&jb)) { |
- perror("Could not find Joystick."); |
- sys_end(); |
- } |
- |
- grx_init(); |
- modenum = grx_getmode(640, 480, 16); |
- grx_setmode(modenum); |
- init_graph(); |
- |
- soft_task_default_model(ms); |
- soft_task_def_level(ms,1); |
- soft_task_def_ctrl_jet(ms); |
- soft_task_def_met(ms,100); |
- soft_task_def_period(ms,10000); |
- soft_task_def_usemath(ms); |
- pid = task_create("Write", write, &ms, NULL); |
- if (pid == NIL) { |
- grx_close(); |
- perror("Could not create task <Write>"); |
- sys_end(); |
- } else { |
- task_activate(pid); |
- } |
- |
- return 0; |
-} |
/tags/rel_1_22/joy/joy_grx.c |
Property changes: |
Deleted: svn:executable |
## -1 +0,0 ## |
-* |
\ No newline at end of property |
Index: tags/rel_1_22/joy/initfile.c |
=================================================================== |
--- tags/rel_1_22/joy/initfile.c (revision 1310) |
+++ tags/rel_1_22/joy/initfile.c (nonexistent) |
@@ -1,84 +0,0 @@ |
-/* |
- * Project: HARTIK (HA-rd R-eal TI-me K-ernel) |
- * |
- * Coordinators: Giorgio Buttazzo <giorgio@sssup.it> |
- * Gerardo Lamastra <gerardo@sssup.it> |
- * |
- * Authors : Paolo Gai <pj@hartik.sssup.it> |
- * (see authors.txt for full list of hartik's authors) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://hartik.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include <kernel/kern.h> |
-#include <kernel/func.h> |
-#include <stdlib.h> |
-#include <drivers/keyb.h> |
-#include <semaphore.h> |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
- |
-#include "modules/edf.h" |
-#include "modules/cbs.h" |
-#include "modules/rr.h" |
-#include "modules/dummy.h" |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 0 //300 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 300 |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- EDF_register_level(EDF_ENABLE_ALL); |
- CBS_register_level(CBS_ENABLE_ALL, 0); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- KEYB_PARMS kparms = BASE_KEYB; |
- |
- HARTPORT_init(); |
- |
- //keyb_set_map(itaMap); |
- keyb_def_ctrlC(kparms, NULL); |
- KEYB_init(&kparms); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
/tags/rel_1_22/joy/initfile.c |
Property changes: |
Deleted: svn:executable |
## -1 +0,0 ## |
-* |
\ No newline at end of property |
Index: tags/rel_1_22/joy/README |
=================================================================== |
--- tags/rel_1_22/joy/README (revision 1310) |
+++ tags/rel_1_22/joy/README (nonexistent) |
@@ -1,2 +0,0 @@ |
-TODO |
- |
Index: tags/rel_1_22/joy/makefile |
=================================================================== |
--- tags/rel_1_22/joy/makefile (revision 1310) |
+++ tags/rel_1_22/joy/makefile (nonexistent) |
@@ -1,18 +0,0 @@ |
-# |
-# |
-# |
- |
-ifndef BASE |
-BASE=../.. |
-endif |
-include $(BASE)/config/config.mk |
- |
-PROGS= joy_hex joy_test joy_grx |
- |
-include $(BASE)/config/example.mk |
- |
-joy_grx: |
- make -f $(SUBMAKE) APP=joy_grx INIT= OTHEROBJS="initfile.o" SHARKOPT="__OLDCHAR__ __GRX__ __JOY__" |
- |
-joy_test: |
- make -f $(SUBMAKE) APP=joy_test INIT= OTHEROBJS="initfile.o" SHARKOPT="__OLDCHAR__ __JOY__" |
/tags/rel_1_22/joy/makefile |
Property changes: |
Deleted: svn:executable |
## -1 +0,0 ## |
-* |
\ No newline at end of property |
Index: tags/rel_1_22/joy/joy_test.c |
=================================================================== |
--- tags/rel_1_22/joy/joy_test.c (revision 1310) |
+++ tags/rel_1_22/joy/joy_test.c (nonexistent) |
@@ -1,131 +0,0 @@ |
- |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: Giorgio Buttazzo <giorgio@sssup.it> |
- * |
- * Authors : Paolo Gai <pj@hartik.sssup.it> |
- * (see authors.txt for full list of hartik's authors) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * 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 2 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, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include <kernel/kern.h> |
-#include <kernel/func.h> |
-#include <stdlib.h> |
-#include <drivers/keyb.h> |
-#include <math.h> |
- |
-#include "joy.h" |
- |
-PID pid; |
- |
-void endfun(KEY_EVT *k) |
-{ |
- cprintf("Ctrl-Brk pressed! Ending...\n"); |
- sys_end(); |
-} |
- |
-void my_close(void *arg) |
-{ |
- int i; |
- TIME tmp; |
- |
- kern_printf("Taskset Execution Time\n\n"); |
- for (i=3; i<MAX_PROC; i++){ |
- if (!jet_getstat(i, NULL, &tmp, NULL, NULL)) |
- kern_printf("Task Name : %s - Max Time : %d\n", proc_table[i].name, (int)tmp); |
- } |
-} |
- |
- |
-TASK write() |
-{ |
- JOY_STATE jsa; |
- |
- while (1) { |
- get_joystick_A(&jsa); |
- place(2,4); |
- cprintf("The X coord. is: %3d and the Y coord. is: %3d of the joystick1\n", jsa.x, jsa.y); |
- place(2,12); |
- cprintf("The button 1, joystick 1 is: %3d\n", jsa.b1); |
- place(2,14); |
- cprintf("The button 2, joystick 1 is: %3d\n", jsa.b2); |
- |
- task_endcycle(); |
- } |
- return 0; |
-} |
- |
-int main(int argc, char **argv) |
-{ |
- SOFT_TASK_MODEL ms; |
- KEY_EVT k; |
- TIME seme; |
- |
- JOY_BOUND jb; |
- |
- k.flag = CNTR_BIT; |
- k.scan = KEY_C; |
- k.ascii = 'c'; |
- keyb_hook(k,endfun); |
- |
- k.flag = CNTL_BIT; |
- k.scan = KEY_C; |
- k.ascii = 'c'; |
- keyb_hook(k,endfun); |
- |
- seme = sys_gettime(NULL); |
- srand(seme); |
- |
- sys_atrunlevel(my_close, NULL, RUNLEVEL_BEFORE_EXIT); |
- |
- clear(); |
- |
- if (get_joystick_bound_A(&jb)) { |
- perror("Could not find Joystick."); |
- sys_end(); |
- } |
- |
- place(2,2); |
- cprintf("The X bounds are: [ %3d - %3d ] and the Y bounds are: [ %3d - %3d ]\n", jb.x_min,jb.x_max,jb.y_min,jb.y_max); |
- |
- soft_task_default_model(ms); |
- soft_task_def_level(ms,1); |
- soft_task_def_ctrl_jet(ms); |
- soft_task_def_met(ms,100); |
- soft_task_def_period(ms,10000); |
- soft_task_def_usemath(ms); |
- pid = task_create("Write", write, &ms, NULL); |
- if (pid == NIL) { |
- perror("Could not create task <Write>"); |
- sys_end(); |
- } else { |
- task_activate(pid); |
- } |
- |
- return 0; |
-} |