OSDN Git Service

(none)
[hos/hos-v4a.git] / cfgrtr / source / idlstk.cpp
1 // ---------------------------------------------------------------------------
2 //  Hyper Operating System V4  コンフィギュレーター                           
3 //    HOS_IDL_STK API の処理                                                  
4 //                                                                            
5 //                                    Copyright (C) 1998-2003 by Project HOS  
6 //                                    http://sourceforge.jp/projects/hos/     
7 // ---------------------------------------------------------------------------
8
9
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include <string.h>
13 #include "defercd.h"
14 #include "idlstk.h"
15 #include "analyze.h"
16 #include "readcfg.h"
17
18
19 #define IDLSTK_STKSZ            0
20 #define IDLSTK_STK                      1
21
22
23 // コンストラクタ
24 CApiIdleStack::CApiIdleStack()
25 {
26         // パラメーター構文設定
27         m_iParamSyntax[0] = 0;          // 単独パラメーター
28         m_iParams = 2;
29 }
30
31
32 // デストラクタ
33 CApiIdleStack::~CApiIdleStack()
34 {
35 }
36
37
38 // 自動ID番号割り当て
39 int CApiIdleStack::AutoId(void)
40 {
41         return CFG_ERR_OK;
42 }
43
44
45 // APIの解析
46 int CApiIdleStack::AnalyzeApi(const char* pszApiName, const char* pszParams)
47 {
48         if ( strcmp(pszApiName, "KERNEL_IDL_STK") == 0 )
49         {
50                 if ( m_iObjs > 0 )
51                 {
52                         return CFG_ERR_MULTIDEF;
53                 }
54
55                 return AddParams(pszParams);
56         }
57
58         return CFG_ERR_NOPROC;
59 }
60
61
62 // cfgファイル定義部書き出し
63 void  CApiIdleStack::WriteCfgDef(FILE* fp)
64 {
65         const char* pszSize;
66         const char* pszStack;
67
68         // コメント出力
69         fputs(
70                 "\n\n\n"
71                 "/* ------------------------------------------ */\n"
72                 "/*                 idle stack                 */\n"
73                 "/* ------------------------------------------ */\n\n"
74                 , fp);
75
76         // パラメータ読み出し
77         if ( m_iObjs > 0 )
78         {
79                 pszSize  = m_pParamPacks[0]->GetParam(IDLSTK_STKSZ);
80                 pszStack = m_pParamPacks[0]->GetParam(IDLSTK_STK);
81         }
82         else
83         {
84                 pszSize  = "128";               // 指定が無ければデフォルトサイズ
85                 pszStack = "NULL";              // 指定が無ければNULL(自動生成)
86         }
87
88         // アイドルループ用スタック出力
89         if ( strcmp(pszStack, "NULL") == 0 )
90         {
91                 fprintf(
92                         fp,
93                         "VP         _kernel_idl_stkblk[((%s) + sizeof(VP) - 1) / sizeof(VP)];\t/* idle stack block*/\n"
94                         "const VP   _kernel_idl_stk   = (VP)(_kernel_idl_stkblk);\t/* idle stack */\n"
95                         "const SIZE _kernel_idl_stksz = (SIZE)sizeof(_kernel_idl_stkblk);\t/* idle stack size */\n",
96                         pszSize);
97         }
98         else
99         {
100                 fprintf(
101                         fp,
102                         "const VP   _kernel_idl_stk   = (VP)(%s);\t/* idle stack */\n"
103                         "const SIZE _kernel_idl_stksz = (SIZE)(%s);\t/* idle stack */\n",
104                         pszStack,pszSize);
105         }
106 }
107
108
109 // ---------------------------------------------------------------------------
110 //  Copyright (C) 1998-2003 by Project HOS                                    
111 // ---------------------------------------------------------------------------