OSDN Git Service

(none)
[hos/hos-v4a.git] / cfgrtr / source / intstk.cpp
1 // ---------------------------------------------------------------------------
2 //  Hyper Operating System V4  コンフィギュレーター                           
3 //    HOS_INT_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 "intstk.h"
15 #include "analyze.h"
16 #include "readcfg.h"
17
18
19 #define INTSTK_STKSZ            0
20 #define INTSTK_STK                      1
21
22
23 // コンストラクタ
24 CApiIntStack::CApiIntStack()
25 {
26         // パラメーター構文設定
27         m_iParamSyntax[0] = 0;          // 単独パラメーター
28         m_iParams = 2;
29
30         // スタックポインタ
31         m_szStackPointer[0] = '\0';
32 }
33
34
35 // デストラクタ
36 CApiIntStack::~CApiIntStack()
37 {
38 }
39
40
41 // 自動ID番号割り当て
42 int CApiIntStack::AutoId(void)
43 {
44         return CFG_ERR_OK;
45 }
46
47
48 // APIの解析
49 int CApiIntStack::AnalyzeApi(const char* pszApiName, const char* pszParams)
50 {
51         if ( strcmp(pszApiName, "KERNEL_INT_STK") == 0 )
52         {
53                 if ( m_iObjs > 0 )
54                 {
55                         return CFG_ERR_MULTIDEF;
56                 }
57
58                 if ( m_szStackPointer[0] != '\0' )
59                 {
60                         return CFG_ERR_DEF_CONFLICT;
61                 }
62
63                 return AddParams(pszParams);
64         }
65
66         return CFG_ERR_NOPROC;
67 }
68
69
70 // cfgファイル定義部書き出し
71 void  CApiIntStack::WriteCfgDef(FILE* fp)
72 {
73         const char* pszSize;
74         const char* pszStack;
75
76         // パラメータ読み出し
77         if ( m_iObjs <= 0 )
78         {
79                 pszSize  = "256";
80                 pszStack = "NULL";
81         }
82         else
83         {
84                 pszSize  = m_pParamPacks[0]->GetParam(INTSTK_STKSZ);
85                 pszStack = m_pParamPacks[0]->GetParam(INTSTK_STK);
86         }
87
88
89         // コメント出力
90         fputs(
91                 "\n\n\n"
92                 "/* ------------------------------------------ */\n"
93                 "/*             interrupt stack                */\n"
94                 "/* ------------------------------------------ */\n\n"
95                 , fp);
96
97         if ( strcmp(pszStack, "NULL") == 0 )
98         {
99                 fprintf(
100                                 fp,
101                                 "VP       _kernel_int_stkblk[((%s) + sizeof(VP) - 1) / sizeof(VP)];\n"
102                                 "const VP _kernel_int_isp = &_kernel_int_stkblk[((%s) + sizeof(VP) - 1) / sizeof(VP)];\n",
103                                 pszSize, pszSize);
104         }
105         else
106         {
107                 fprintf(
108                                 fp,
109                                 "const VP _kernel_int_isp = (VP)((VB *)(%s) + (SIZE)(%s));\n",
110                                 pszStack, pszSize);
111         }
112
113 }
114
115
116 // cfgファイル起動部書き出し
117 void CApiIntStack::WriteCfgIni(FILE* fp)
118 {
119         const char* pszSize;
120         const char* pszStack;
121
122         // パラメータ読み出し
123         if ( m_iObjs <= 0 )
124         {
125                 pszSize  = "256";
126                 pszStack = "NULL";
127         }
128         else
129         {
130                 pszSize  = m_pParamPacks[0]->GetParam(INTSTK_STKSZ);
131                 pszStack = m_pParamPacks[0]->GetParam(INTSTK_STK);
132         }
133         
134                 
135         if ( strcmp(pszStack, "NULL") == 0 )
136         {
137                 fprintf(
138                         fp,
139                         "\t_KERNEL_SYS_INI_INTSTK((SIZE)sizeof(_kernel_int_stkblk), (VP)(_kernel_int_stkblk));\n");
140         }
141         else
142         {
143                 fprintf(
144                         fp,
145                         "\t_KERNEL_SYS_INI_SYSSTK((SIZE)(%s), (VP)(%s));\n",
146                         pszSize, pszStack);
147         }
148 }
149
150
151
152 // ---------------------------------------------------------------------------
153 //  Copyright (C) 1998-2006 by Project HOS                                    
154 // ---------------------------------------------------------------------------