GadgetSeed  0.9.6
initsystem.c
[詳解]
1 /** @file
2  @brief 仮想 GadgetSeed システム初期化
3 
4  @date 2009.11.06
5  @author Takashi SHUDO
6 */
7 
8 #include "sysconfig.h"
9 #include "system.h"
10 #include "device.h"
11 #include "random.h"
12 #include "datetime.h"
13 #include "graphics.h"
14 #include "console.h"
15 #include "device/rtc_ioctl.h"
16 #include "device/sd_ioctl.h"
17 #include "device/video_ioctl.h"
18 
19 #ifdef GSC_COMP_ENABLE_FATFS
20 #include "storage.h"
21 #include "file.h"
22 #endif
23 
24 extern int open_lcdwindow(int *argc, char ***argv);
25 
26 extern const struct st_device GSC_KERNEL_ERROUT_DEVICE;
27 extern const struct st_device vconsole_device;
28 extern const struct st_device rtc_device;
29 extern const struct st_device vlcd_device;
30 extern const struct st_device framebuf_device;
31 //extern const struct st_device fbconsole_device;
32 extern const struct st_device grconsole_device;
33 extern const struct st_device eventcon_device;
34 extern const struct st_device sound_device;
35 extern const struct st_device veeprom_device;
36 extern const struct st_device vmmc_device;
37 extern const struct st_device vaudio_device;
38 extern const struct st_device vether_device;
39 
40 extern const struct st_device powerkey_device;
41 extern const struct st_device gbkey_device;
42 extern const struct st_device led_device;
43 
44 // デバイスドライバリスト
45 static const struct st_device * const dev_list[] = {
46  &vconsole_device,
47 #ifdef GSC_DEV_ENABLE_RTC
48  &rtc_device,
49 #endif
50 #ifdef GSC_COMP_ENABLE_GRAPHICS
51  &vlcd_device,
52 #endif
53 #ifdef GSC_DEV_ENABLE_I2CEEPROM
54  &veeprom_device,
55 #endif
56 #ifdef GSC_DEV_ENABLE_STORAGE
57  &vmmc_device,
58 #endif
59 #ifdef GSC_DEV_ENABLE_AUDIO // $gsc オーディオデバイスを有効にする
60  &vaudio_device,
61 #endif
62 #ifdef GSC_DEV_ENABLE_ETHER // $gsc Etherデバイスを有効にする
63  &vether_device,
64 #endif
65  0
66 };
67 
68 #ifdef GSC_COMP_ENABLE_FATFS
69 // ドライブリスト
70 static const char * const storade_devices[] = {
72  0
73 };
74 #endif
75 
76 void init_system(int *argc, char ***argv)
77 {
78 #ifdef GSC_COMP_ENABLE_GRAPHICS
79  open_lcdwindow(argc, argv);
80 #endif
81 }
82 
83 static void register_devices(const struct st_device * const list[])
84 {
85  struct st_device **dev = (struct st_device **)list;
86 
87  while(*dev) {
88  register_device(*dev, 0);
89  dev ++;
90  }
91 }
92 
94 {
95  // デバイスドライバ初期化
96  register_devices(dev_list);
98  register_console_out_dev(&vconsole_device);
99  register_console_in_dev(&vconsole_device);
100 
101  // RTC初期化
102 #ifdef GSC_DEV_ENABLE_RTC
104 #else
105  init_time(0);
106 #endif
107 
108  // グラフィックドライバ初期化
109 #ifdef GSC_COMP_ENABLE_GRAPHICS // $gsc グラフィック描画を有効にする
111  extern struct st_bitmap gs_logo;
112  draw_enlarged_bitmap(0, 0, &gs_logo, 4);
113 #ifdef GSC_DEV_ENABLE_GRCONSOLE // $gsc グラフィックデバイス用コンソール出力を有効にする
114  register_device(&grconsole_device, 0);
115 #endif
116 #endif
117 
118  // 乱数初期化
119 #ifdef GSC_LIB_ENABLE_RANDOM
120  init_genrand(get_systime_sec());
121 #endif
122 
123 #ifdef GSC_DEV_ENABLE_NULL
124  // NULLデバイス初期化
125  register_device(&null_device, 0);
126 #endif
127 }
128 
130 {
131 #ifdef GSC_COMP_ENABLE_FATFS // $gsc FATFSを有効にする
132  // ファイルシステム初期化
133  init_storage();
134  register_storage_device(storade_devices);
135  init_file();
136 #endif
137 }
138 
139 void init_syscalltbl(void)
140 {
141 }
142 
143 void reset_system(void)
144 {
145  // 未実装
146 }
RTCドライバ ioctl 用マクロ定義
int register_storage_device(const char *const device_name[])
ストレージデバイスをリストでマウントする
Definition: storage.c:160
画像表示デバイスドライバ ioctl 用マクロ定義
ビットマップグラフィックデータ
Definition: graphics.h:86
ファイル
void init_system_process(void)
タスク起動後の初期化処理
Definition: initsystem.c:129
void init_system_drivers(void)
基本ドライバ初期化後に登録するユーザドライバ登録処理
Definition: initsystem.c:93
#define DEF_DEV_NAME_SD
標準ストレージデバイス名(MMC,SD等)
Definition: sd_ioctl.h:15
日付時刻
int init_time(char *devname)
時計を初期する
Definition: datetime.c:517
void init_system(int *argc, char ***argv)
ドライバ初期化以前に行う初期化処理
Definition: initsystem.c:76
void register_console_in_dev(const struct st_device *in_dev)
システム標準のコンソール入力デバイスを登録する
Definition: console.c:100
const struct st_device led_device
LEDドライバ
外部記憶装置管理
void init_file(void)
全てのファイルディスクリプタを初期化する
Definition: file.c:84
void register_console_out_dev(const struct st_device *out_dev)
システム標準のコンソール出力デバイスを登録する
Definition: console.c:110
struct st_device GSC_KERNEL_ERROUT_DEVICE
$gsc エラーメッセージ出力デバイス
ストレージデバイスドライバ ioctl 用マクロ定義
void register_error_out_dev(const struct st_device *err_dev)
システム標準のエラー出力デバイスを登録する
Definition: console.c:255
#define DEF_DEV_NAME_RTC
標準リアルタイムクロックデバイス名
Definition: rtc_ioctl.h:15
システム固有初期化関連
コンソールI/O
void init_storage(void)
外部記憶装置管理初期化
Definition: storage.c:44
#define DEF_DEV_NAME_VIDEO
標準ビデオデバイス名
Definition: video_ioctl.h:16
デバイスドライバAPI
デバイスドライバ構造体
Definition: device.h:25
疑似乱数発生
void draw_enlarged_bitmap(short px, short py, struct st_bitmap *bitmap, int rate)
拡大したビットマップデータを描画する
Definition: graphics.c:1160
int init_graphics(char *devname)
グラフィックスライブラリを初期化する
Definition: graphics.c:305
グラフィックライブラリ
t_time get_systime_sec(void)
システム時間(秒)を取得する
Definition: datetime.c:765