annotate TaskManager/kernel/main.cc @ 1479:163220e54cc0 draft

remove hard code for TaskLog
author Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
date Tue, 24 Jul 2012 17:15:15 +0900
parents af2adce9752e
children 0ad321ee074d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
1 #include <stdlib.h>
275
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 273
diff changeset
2 #include <string.h>
1216
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1215
diff changeset
3 #include <SDL.h>
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
4 #include "TaskManager.h"
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
5
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
6 /*!
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
7 User が書いた TMmain() (*名前は固定) を実行する
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
8 */
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
9
216
e9a52d68db42 rename cerium_main to TMmain, add TMend()
gongo@localhost.localdomain
parents: 109
diff changeset
10 /* User main function */
397
ce86b0186a4a delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
11 extern int TMmain(TaskManager* manager, int argc, char *argv[]);
216
e9a52d68db42 rename cerium_main to TMmain, add TMend()
gongo@localhost.localdomain
parents: 109
diff changeset
12
674
07351a5a51c9 fix many task example (sort).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 673
diff changeset
13 static int profile = 0;
1428
af2adce9752e add to export TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1413
diff changeset
14 static int export_task_log = 0;
674
07351a5a51c9 fix many task example (sort).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 673
diff changeset
15
216
e9a52d68db42 rename cerium_main to TMmain, add TMend()
gongo@localhost.localdomain
parents: 109
diff changeset
16 /* Default TMend function */
e9a52d68db42 rename cerium_main to TMmain, add TMend()
gongo@localhost.localdomain
parents: 109
diff changeset
17 static void
674
07351a5a51c9 fix many task example (sort).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 673
diff changeset
18 defaultTMend(TaskManager *manager) {
07351a5a51c9 fix many task example (sort).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 673
diff changeset
19 }
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
20
397
ce86b0186a4a delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
21 //TaskManager *manager;
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
22
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
23 /*!
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
24 const char *usr_help_str を User 側で指定する必要がある
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
25 -help で出力される文字列
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
26 */
253
0c9c9906d777 usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents: 242
diff changeset
27 const char *help_str = "\n\
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
28 * Cerium program option *\n\
253
0c9c9906d777 usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents: 242
diff changeset
29 -help Print this message \n\
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
30 -cpu Number of CPU (default 1) \n";
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
31
253
0c9c9906d777 usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents: 242
diff changeset
32 extern const char *usr_help_str;
0c9c9906d777 usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents: 242
diff changeset
33
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
34 int
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
35 main(int argc, char *argv[])
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
36 {
1147
279b41354753 add check code.
Yutaka_Kinjyo
parents: 1123
diff changeset
37 int machineNum = 0;
1066
04a42a788fa2 speidle init fix.
tkaito@henri
parents: 1061
diff changeset
38 int speIdle = 0;
1413
5b024efa2429 fix free on non copy DMA
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1288
diff changeset
39 int useRefDma = 0;
1105
f80524d00a2c bug fix.
tkaito
parents: 1104
diff changeset
40
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
41 for (int i = 1; argv[i]; ++i) {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
42 if (strcmp(argv[i], "-cpu") == 0) {
1413
5b024efa2429 fix free on non copy DMA
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1288
diff changeset
43 machineNum = atoi(argv[++i]);
674
07351a5a51c9 fix many task example (sort).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 673
diff changeset
44 } else if (strcmp(argv[i], "-p") == 0) {
1413
5b024efa2429 fix free on non copy DMA
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1288
diff changeset
45 profile = 1;
1428
af2adce9752e add to export TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1413
diff changeset
46 } else if (strcmp(argv[i], "-export") == 0) {
af2adce9752e add to export TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1413
diff changeset
47 export_task_log = 1;
1413
5b024efa2429 fix free on non copy DMA
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1288
diff changeset
48 } else if (strcmp(argv[i], "-speidle") == 0) { // これなんだよ?
5b024efa2429 fix free on non copy DMA
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1288
diff changeset
49 speIdle = atoi(argv[++i]);
5b024efa2429 fix free on non copy DMA
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1288
diff changeset
50 } else if (strcmp(argv[i], "-copy") == 0) { // force copy DMA in FifoManager
5b024efa2429 fix free on non copy DMA
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1288
diff changeset
51 useRefDma |= 0x01;
5b024efa2429 fix free on non copy DMA
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1288
diff changeset
52 } else if (strcmp(argv[i], "-pre") == 0) { // deplicated
5b024efa2429 fix free on non copy DMA
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1288
diff changeset
53 useRefDma |= 0x10;
5b024efa2429 fix free on non copy DMA
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1288
diff changeset
54 }
5b024efa2429 fix free on non copy DMA
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1288
diff changeset
55 }
1104
3e7cb5546075 option fix.
tkaito
parents: 1066
diff changeset
56
1113
d2d44bc55fa1 changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.
tkaito
parents: 1105
diff changeset
57 TaskManager *manager = new TaskManager(machineNum);
1479
163220e54cc0 remove hard code for TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1428
diff changeset
58 manager->init(speIdle,export_task_log, useRefDma);
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
59
1113
d2d44bc55fa1 changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.
tkaito
parents: 1105
diff changeset
60 manager->set_TMend(defaultTMend);
d2d44bc55fa1 changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.
tkaito
parents: 1105
diff changeset
61
1105
f80524d00a2c bug fix.
tkaito
parents: 1104
diff changeset
62 for (int i = 1; argv[i]; ++i) {
f80524d00a2c bug fix.
tkaito
parents: 1104
diff changeset
63 if (strcmp(argv[i], "-help") == 0) {
f80524d00a2c bug fix.
tkaito
parents: 1104
diff changeset
64 if (usr_help_str) {
f80524d00a2c bug fix.
tkaito
parents: 1104
diff changeset
65 manager->get_scheduler()->printf("%s", usr_help_str);
f80524d00a2c bug fix.
tkaito
parents: 1104
diff changeset
66 }
f80524d00a2c bug fix.
tkaito
parents: 1104
diff changeset
67 manager->get_scheduler()->printf("%s", help_str);
f80524d00a2c bug fix.
tkaito
parents: 1104
diff changeset
68 return EXIT_SUCCESS;
f80524d00a2c bug fix.
tkaito
parents: 1104
diff changeset
69 }
f80524d00a2c bug fix.
tkaito
parents: 1104
diff changeset
70 }
f80524d00a2c bug fix.
tkaito
parents: 1104
diff changeset
71
674
07351a5a51c9 fix many task example (sort).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 673
diff changeset
72 if (profile)
07351a5a51c9 fix many task example (sort).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 673
diff changeset
73 manager->start_profile();
397
ce86b0186a4a delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
74 if (TMmain(manager, argc, argv) < 0) {
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
75 goto FINISH;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
76 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
77
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
78 manager->run();
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
79
397
ce86b0186a4a delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
80 (manager->tm_end)(manager);
674
07351a5a51c9 fix many task example (sort).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 673
diff changeset
81 if (profile)
07351a5a51c9 fix many task example (sort).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 673
diff changeset
82 manager->show_profile();
1428
af2adce9752e add to export TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1413
diff changeset
83 if (export_task_log)
af2adce9752e add to export TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1413
diff changeset
84 manager->export_task_log();
af2adce9752e add to export TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1413
diff changeset
85
674
07351a5a51c9 fix many task example (sort).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 673
diff changeset
86 manager->run(); // tm_end/show_profile may create a Task..
216
e9a52d68db42 rename cerium_main to TMmain, add TMend()
gongo@localhost.localdomain
parents: 109
diff changeset
87
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
88 FINISH:
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
89 delete manager;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
90
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
91 return EXIT_SUCCESS;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
92 }
674
07351a5a51c9 fix many task example (sort).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 673
diff changeset
93
07351a5a51c9 fix many task example (sort).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 673
diff changeset
94 /* end */