OSDN Git Service

projects clean up 1
[pinoc/pinoc.git] / pinoc_gcc / kernel / pinoc.h
1 /*
2  * pinoc.h
3  *
4  *  Created on: 2011/05/07
5  *      Author: mizu
6  */
7
8 #ifndef PINOC_H_
9 #define PINOC_H_
10
11 #include "dbg.hpp"
12 #include "interrupt.h"
13
14 typedef int (*pinoc_func_t)(void);
15 typedef void (*pinoc_handler_t)(void);
16
17 // システムコールタイプ
18 typedef enum
19 {
20         PINOC_SYSCALL_RUN = 0,
21         PINOC_SYSCALL_EXIT
22 }pinoc_syacall_t;
23
24 // システムコールパラメータ
25 typedef struct
26 {
27         union
28         {
29                 struct
30                 {
31                         pinoc_func_t func;
32                         char* name;
33                         int stacksize;
34                         int argc;
35                         char** argv;
36 //                      pinoc_thread_id_t ret;
37                 }run;
38                 struct
39                 {
40                         int dummy;
41                 }exit;
42
43         }un;
44 }pinoc_syscall_param_t;
45
46 /********************************************************************************
47  *              カーネル構造体定義
48  ********************************************************************************/
49 #define THREAD_NUM 6
50 #define THREAD_NAME_SIZE 15
51
52 // ユーザー毎のコンテキストが保存されたスタックポインタ
53 typedef struct _pinoc_context
54 {
55         long int sp;
56 }pinoc_context;
57
58 /*
59  * スレッドの型
60  */
61 typedef struct _pinoc_thread
62 {
63         struct _pinoc_thread* next;                     // レディーキュー
64         char name[THREAD_NAME_SIZE + 1];        // スレッド名
65         char* stack;                                            //
66
67         struct
68         {
69                 pinoc_func_t func;                              // 関数名
70                 int argc;                                               // 引数1
71                 char** argv;                                    // 引数2
72         }init;
73
74         struct
75         {
76                 pinoc_syacall_t type;                   // システムコールの種類
77                 pinoc_syscall_param_t param;    // システみコールの引数
78         }syscall;
79
80         pinoc_context context;                          // このスレッドのコンテキスト情報
81
82 }pinoc_thread;
83
84 // レディースキュー
85 static struct
86 {
87         pinoc_thread* head;
88         pinoc_thread* tail;
89 }readyque;
90
91
92
93
94 /********************************************************************************
95  *              プロトタイプ宣言
96 ********************************************************************************/
97 // システム・コール
98 //void pinoc_run(pinoc_func_t func, char *name, int stack_size, int argc, char* argv[]);
99 //void pinoc_exit();
100
101 // ライブラリ関数
102 void pinoc_start(pinoc_func_t func, char *name, int stack_size, int argc, char* argv[]);
103 //void pinoc_syserr();
104 //void pinoc_syscall(pinoc_syscall_type_t type, pinoc_syscall_param_t* param);
105
106 // ユーザー・スレッド
107 int test08_1_main(int argc, char* argv[]);
108
109 //static pinoc_handler_t handlers[softvec];
110
111 /*
112  * ディスパッチの内容は外部ファイルにアセンブラで記述してある
113  */
114 void dispatch(pinoc_context* context);
115
116
117 #endif /* PINOC_H_ */