1 | /*
|
---|
2 | * TOPPERS/ASP Kernel
|
---|
3 | * Toyohashi Open Platform for Embedded Real-Time Systems/
|
---|
4 | * Advanced Standard Profile Kernel
|
---|
5 | *
|
---|
6 | * Copyright (C) 2008-2011 by Embedded and Real-Time Systems Laboratory
|
---|
7 | * Graduate School of Information Science, Nagoya Univ., JAPAN
|
---|
8 | * Copyright (C) 2015-2016 by TOPPERS PROJECT Educational Working Group.
|
---|
9 | *
|
---|
10 | * 上記著作権者は,以下の (1)~(4) の条件か,Free Software Foundation
|
---|
11 | * によって公表されている GNU General Public License の Version 2 に記
|
---|
12 | * 述されている条件を満たす場合に限り,本ソフトウェア(本ソフトウェア
|
---|
13 | * を改変したものを含む.以下同じ)を使用・複製・改変・再配布(以下,
|
---|
14 | * 利用と呼ぶ)することを無償で許諾する.
|
---|
15 | * (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
|
---|
16 | * 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
|
---|
17 | * スコード中に含まれていること.
|
---|
18 | * (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
|
---|
19 | * 用できる形で再配布する場合には,再配布に伴うドキュメント(利用
|
---|
20 | * 者マニュアルなど)に,上記の著作権表示,この利用条件および下記
|
---|
21 | * の無保証規定を掲載すること.
|
---|
22 | * (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
|
---|
23 | * 用できない形で再配布する場合には,次のいずれかの条件を満たすこ
|
---|
24 | * と.
|
---|
25 | * (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著
|
---|
26 | * 作権表示,この利用条件および下記の無保証規定を掲載すること.
|
---|
27 | * (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに
|
---|
28 | * 報告すること.
|
---|
29 | * (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
|
---|
30 | * 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること.
|
---|
31 | *
|
---|
32 | * 本ソフトウェアは,無保証で提供されているものである.上記著作権者お
|
---|
33 | * よびTOPPERSプロジェクトは,本ソフトウェアに関して,その適用可能性も
|
---|
34 | * 含めて,いかなる保証も行わない.また,本ソフトウェアの利用により直
|
---|
35 | * 接的または間接的に生じたいかなる損害に関しても,その責任を負わない.
|
---|
36 | *
|
---|
37 | * @(#) $Id$
|
---|
38 | */
|
---|
39 |
|
---|
40 | #ifndef _STORAGEDEVICE_H_
|
---|
41 | #define _STORAGEDEVICE_H_
|
---|
42 |
|
---|
43 | #include <kernel.h>
|
---|
44 | #include <stdlib.h>
|
---|
45 | #include <string.h>
|
---|
46 | #include <t_syslog.h>
|
---|
47 | #include <t_stdlib.h>
|
---|
48 | #ifndef TOPPERS_MACRO_ONLY
|
---|
49 | #include <fcntl.h>
|
---|
50 | #endif /* TOPPERS_MACRO_ONLY */
|
---|
51 |
|
---|
52 | /*
|
---|
53 | * This file includes the definitions for open and fcntl
|
---|
54 | * described by POSIX for <fcntl.h>; it also includes
|
---|
55 | * related kernel definitions.
|
---|
56 | */
|
---|
57 | #ifndef TOPPERS_MACRO_ONLY
|
---|
58 | #include <sys/types.h>
|
---|
59 | #endif /* TOPPERS_MACRO_ONLY */
|
---|
60 |
|
---|
61 | #ifdef __cplusplus
|
---|
62 | extern "C" {
|
---|
63 | #endif
|
---|
64 |
|
---|
65 | /*
|
---|
66 | * ストレージデバイスの基本設定
|
---|
67 | */
|
---|
68 | #ifndef NUM_STORAGEDEVICE
|
---|
69 | #define NUM_STORAGEDEVICE 4 /* デフォルトのストレージデバイス数 */
|
---|
70 | #endif
|
---|
71 | #define MINIMUM_DEVNO 0
|
---|
72 | #define MAXIMUM_DEVNO 9
|
---|
73 | #ifndef DEFAULT_DEVNO
|
---|
74 | #define DEFAULT_DEVNO MINIMUM_DEVNO
|
---|
75 | #endif
|
---|
76 |
|
---|
77 | #define SDEV_ACTIVE (1<<15) /* アクティブなデバイス */
|
---|
78 | #define SDEV_INSERTCHK (1<<14) /* 挿入・排出の設定あり */
|
---|
79 | #define SDEV_CHKREMOVE (1<<13) /* 排出検査する */
|
---|
80 | #define SDEV_ONEEXIT (1<<12) /* 一度排出あり */
|
---|
81 | #define SDEV_EMPLOY (1<<8) /* 使用可能 */
|
---|
82 | #define SDEV_DEVERROR (1<<7) /* DEVICE ERROR */
|
---|
83 | #define SDEV_DEVNOTUSE (1<<0) /* DEVICE 使用不可 */
|
---|
84 | #define SDEV_NOTUSE 255
|
---|
85 |
|
---|
86 |
|
---|
87 | /* File attribute bits for directory entry */
|
---|
88 |
|
---|
89 | #define AM_RDO 0x01 /* Read only */
|
---|
90 | #define AM_HID 0x02 /* Hidden */
|
---|
91 | #define AM_SYS 0x04 /* System */
|
---|
92 | #define AM_VOL 0x08 /* Volume label */
|
---|
93 | #define AM_LFN 0x0F /* LFN entry */
|
---|
94 | #define AM_DIR 0x10 /* Directory */
|
---|
95 | #define AM_ARC 0x20 /* Archive */
|
---|
96 | #define AM_MASK 0x3F /* Mask of defined bits */
|
---|
97 |
|
---|
98 | /*
|
---|
99 | * chmod value
|
---|
100 | */
|
---|
101 | #define FF_READ 0x0000444
|
---|
102 | #define FF_WRITE 0x0000222
|
---|
103 | #define FF_EXEC 0x0000111
|
---|
104 |
|
---|
105 | #define SENSE_TIME (500)
|
---|
106 |
|
---|
107 | #ifndef TOPPERS_MACRO_ONLY
|
---|
108 |
|
---|
109 | struct dirent2
|
---|
110 | {
|
---|
111 | /* NOTE: This is OUR VERSION of this structure. It contains all the fields currently used by IPS code.
|
---|
112 | If you add fields here, you will also have to modify vcwrapnt.c::*dir() to fill those fields! */
|
---|
113 | unsigned long d_fsize;
|
---|
114 | unsigned short d_date;
|
---|
115 | unsigned short d_time;
|
---|
116 | unsigned short d_reclen;
|
---|
117 | unsigned char d_type;
|
---|
118 | unsigned char d_dummy;
|
---|
119 | char d_name[256]; /* FIXME: use NAME_MAX? */
|
---|
120 | };
|
---|
121 |
|
---|
122 | /*
|
---|
123 | * file system statistics
|
---|
124 | */
|
---|
125 | struct statfs2 {
|
---|
126 | long f_type; /* type of file system (unused; zero) */
|
---|
127 | long f_bsize; /* fundamental file system block size */
|
---|
128 | long f_blocks; /* total data blocks in file system */
|
---|
129 | long f_bfree; /* free blocks in fs */
|
---|
130 | long f_bavail; /* free blocks avail to non-superuser */
|
---|
131 | };
|
---|
132 |
|
---|
133 | /*
|
---|
134 | * デバイスドライバー用関数テーブル定義
|
---|
135 | */
|
---|
136 | typedef struct StorageDeviceFunc {
|
---|
137 | int (*_sdevf_sense)(void *psdev, bool_t on);
|
---|
138 | int (*_sdevf_diskinit)();
|
---|
139 | int (*_sdevf_diskstatus)();
|
---|
140 | int (*_sdevf_diskread)();
|
---|
141 | int (*_sdevf_diskwrite)();
|
---|
142 | int (*_sdevf_diskioctl)();
|
---|
143 | } StorageDeviceFunc_t;
|
---|
144 |
|
---|
145 | /*
|
---|
146 | * POSIXファイルインターフェイス用関数テーブル定義
|
---|
147 | */
|
---|
148 | typedef struct StorageDeviceFileFunc {
|
---|
149 | void *(*_sdevff_opendir)(const char *name);
|
---|
150 | int (*_sdevff_closedir)(void *dir);
|
---|
151 | int (*_sdevff_readdir)(void *dir, void *dirent2);
|
---|
152 | int (*_sdevff_mkdir)(const char *name);
|
---|
153 | int (*_sdevff_rmdir)(const char *name);
|
---|
154 | int (*_sdevff_unlink)(const char *name);
|
---|
155 | int (*_sdevff_rename)(const char *oname, const char *nname);
|
---|
156 | int (*_sdevff_chmod)(const char *name, int mode);
|
---|
157 | int (*_sdevff_stat)(const char *name, struct stat *buf);
|
---|
158 | int (*_sdevff_statfs)(const char *name, void *status);
|
---|
159 | int (*_sdevff_open)(int devno, const char *name, int flags);
|
---|
160 | int (*_sdevff_close)(int fd);
|
---|
161 | int (*_sdevff_fstat)(int fd, struct stat *buf);
|
---|
162 | off_t (*_sdevff_lseek)(int fd, off_t offset, int whence, int *res);
|
---|
163 | long (*_sdevff_read)(int fd, void *buf, long count, int *res);
|
---|
164 | long (*_sdevff_write)(int fd, const void *buf, long count, int *res);
|
---|
165 | void *(*_sdevff_mmap)(void *start, size_t length, int prot, int flags, int fd, off_t offset);
|
---|
166 | } StorageDeviceFileFunc_t;
|
---|
167 |
|
---|
168 | /*
|
---|
169 | * ストレージデバイス型定義
|
---|
170 | */
|
---|
171 | typedef struct StorageDevice {
|
---|
172 | uint16_t _sdev_attribute;
|
---|
173 | uint8_t _sdev_devno;
|
---|
174 | uint8_t _sdev_port;
|
---|
175 | uint32_t _sdev_maxsec;
|
---|
176 | uint32_t _sdev_secsize;
|
---|
177 | uint16_t _sdev_instimer;
|
---|
178 | uint16_t _sdev_inswait;
|
---|
179 | void (*_sdev_notice)(void *psdev, bool_t sw);
|
---|
180 | void *_sdev_local[4];
|
---|
181 | StorageDeviceFunc_t *pdevf;
|
---|
182 | StorageDeviceFileFunc_t *pdevff;
|
---|
183 | } StorageDevice_t;
|
---|
184 |
|
---|
185 | /*
|
---|
186 | * ストレージデバイスヘッダー型定義
|
---|
187 | */
|
---|
188 | typedef struct StorageDeviceHead {
|
---|
189 | int16_t _num_activedev;
|
---|
190 | int8_t _sdev_active;
|
---|
191 | int8_t _default_device;
|
---|
192 | uint32_t (*_get_datetime)(void);
|
---|
193 | StorageDevice_t *_psd;
|
---|
194 | } StorageDeviceHead_t;
|
---|
195 |
|
---|
196 | /*
|
---|
197 | * SDMの全体定義
|
---|
198 | */
|
---|
199 | extern StorageDeviceHead_t SDeviceHead;
|
---|
200 |
|
---|
201 | /*
|
---|
202 | * 各サービスのプロトタイプ宣言
|
---|
203 | */
|
---|
204 | extern void sdev_init(intptr_t exinf);
|
---|
205 | extern void sdev_terminate(void);
|
---|
206 | extern ER SDMSetupDevice(int16_t devno, StorageDevice_t **ppsdev);
|
---|
207 | extern ER_ID SDMGetDeviceNo(const char **ppathname);
|
---|
208 | extern StorageDevice_t *SDMGetStorageDevice(int devno);
|
---|
209 | extern ER SDMEmploy(StorageDevice_t *psdev, bool_t sw);
|
---|
210 | extern void SDMSence_task(intptr_t exinf);
|
---|
211 |
|
---|
212 | extern void stdfile_init(intptr_t exinf);
|
---|
213 | extern void volume_info_init(intptr_t exinf);
|
---|
214 |
|
---|
215 | #endif /* TOPPERS_MACRO_ONLY */
|
---|
216 |
|
---|
217 | #ifdef __cplusplus
|
---|
218 | }
|
---|
219 | #endif
|
---|
220 |
|
---|
221 | #endif /* _STORAGEDEVICE_H_ */
|
---|
222 | /* end of file */
|
---|