GadgetSeed  0.9.6
device.c ファイル

デバイスドライバAPI [詳解]

#include "sysconfig.h"
#include "interrupt.h"
#include "device.h"
#include "task/syscall.h"
#include "str.h"
#include "tkprintf.h"
#include "dkprintf.h"
#include "datetime.h"
device.c の依存先関係図:

[ソースコード]

マクロ定義

#define GSC_KERNEL_MAX_DEVICE_NUM   16
 $gsc カーネル最大デバイスドライバ数
 

関数

void init_device_list (void)
 デバイスドライバリストを初期化する
 
int device_num (void)
 登録されているデバイス数を取得する [詳解]
 
const char * device_name (int num)
 デバイス名を取得する [詳解]
 
const char * device_explan (int num)
 デバイス説明を取得する [詳解]
 
int register_device (const struct st_device *dev, char *param)
 
int unregister_device (const struct st_device *dev)
 デバイスを削除する [詳解]
 
struct st_deviceopen_device (char *name)
 デバイスをオープンする [詳解]
 
int close_device (struct st_device *dev)
 デバイスをクローズする [詳解]
 
int lock_device (struct st_device *dev, unsigned int timeout)
 デバイスをロックする [詳解]
 
int unlock_device (struct st_device *dev)
 デバイスをアンロックする [詳解]
 
int read_device (struct st_device *dev, void *buf, unsigned int count)
 デバイスよりデータを読み出す [詳解]
 
int block_read_device (struct st_device *dev, void *buf, unsigned int sector, unsigned int blkcount)
 デバイスよりブロックデータを読み出す [詳解]
 
int getc_device (struct st_device *dev, unsigned char *data)
 デバイスよりデータを1バイト読み出す [詳解]
 
int write_device (struct st_device *dev, const void *buf, unsigned int count)
 デバイスにデータを書き込む [詳解]
 
int block_write_device (struct st_device *dev, const void *buf, unsigned int sector, unsigned int blkcount)
 デバイスにブロックデータを書き込む [詳解]
 
int putc_device (struct st_device *dev, unsigned char data)
 デバイスにデータを1バイト書き込む [詳解]
 
int ioctl_device (struct st_device *dev, unsigned int com, unsigned int arg, void *param)
 デバイスを制御する [詳解]
 
int seek_device (struct st_device *dev, int offset, int whence)
 デバイスのアクセスポイントを設定する [詳解]
 
int sync_device (struct st_device *dev)
 デバイスの書き込みデータの同期をとる [詳解]
 
int select_device (struct st_device *dev, unsigned int timeout)
 デバイスのアクセス準備完了を待つ [詳解]
 
int suspend_device (struct st_device *dev)
 デバイスを休止状態にする [詳解]
 
int resume_device (struct st_device *dev)
 デバイスを活性化する [詳解]
 
int suspend (void)
 全デバイスを休止状態にする [詳解]
 
int resume (void)
 全デバイスを活性化する [詳解]
 

変数

static struct st_devicedevice_list [GSC_KERNEL_MAX_DEVICE_NUM]
 登録デバイスリスト
 
int flg_init_task_run
 デバイスを登録する [詳解]
 

詳解

デバイスドライバAPI

GadgetSeed は標準化されたデバイスアクセスのための API を提供します。

GadgetSeed のデバイスドライバは struct st_device 構造体で定義されています。

日付
2007.03.18
著者
Takashi SHUDO

device.c に定義があります。

関数詳解

◆ block_read_device()

int block_read_device ( struct st_device dev,
void *  buf,
unsigned int  sector,
unsigned int  blkcount 
)

デバイスよりブロックデータを読み出す

引数
[in]devデバイスドライバ
[out]buf読み出しデータポインタ
[in]sector読み出しデータセクター
[in]blkcount読み出しデータブロック数
戻り値
読み出しデータバイト数,<0:エラー

device.c410 行目に定義があります。

◆ block_write_device()

int block_write_device ( struct st_device dev,
const void *  buf,
unsigned int  sector,
unsigned int  blkcount 
)

デバイスにブロックデータを書き込む

引数
[in]devデバイスドライバ
[in]buf書き込みデータポインタ
[in]sector書き込みデータセクター
[in]blkcount書き込みデータブロック数
戻り値
書き込みデータバイト数,<0:エラー

device.c483 行目に定義があります。

◆ close_device()

int close_device ( struct st_device dev)

デバイスをクローズする

引数
[in]devデバイスドライバ
戻り値
!=0:エラー

device.c291 行目に定義があります。

◆ device_explan()

const char* device_explan ( int  num)

デバイス説明を取得する

引数
[in]numデバイス番号
戻り値
デバイス説明

device.c154 行目に定義があります。

参照先 st_device::explan, flg_init_task_run, GSC_KERNEL_MAX_DEVICE_NUM.

◆ device_name()

const char* device_name ( int  num)

デバイス名を取得する

引数
[in]numデバイス名
戻り値
デバイス名

device.c132 行目に定義があります。

参照先 GSC_KERNEL_MAX_DEVICE_NUM, st_device::name.

◆ device_num()

int device_num ( void  )

登録されているデバイス数を取得する

戻り値
デバイス数

device.c113 行目に定義があります。

参照先 GSC_KERNEL_MAX_DEVICE_NUM.

◆ getc_device()

int getc_device ( struct st_device dev,
unsigned char *  data 
)

デバイスよりデータを1バイト読み出す

引数
[in]devデバイスドライバ
[out]data読み出しデータポインタ
戻り値
<0:エラー

device.c429 行目に定義があります。

参照元 cgetc(), cgetcnw().

被呼び出し関係図:

◆ ioctl_device()

int ioctl_device ( struct st_device dev,
unsigned int  com,
unsigned int  arg,
void *  param 
)

デバイスを制御する

引数
[in]devデバイスドライバ
[in]comコマンド
[in]argコマンド引数
戻り値
<0:エラー

device.c525 行目に定義があります。

参照元 clear_screen(), draw_fill_ellipse(), get_display_frame(), get_draw_frame(), get_kernel_time(), get_system_utime(), set_display_frame(), set_draw_frame(), start_timer(), stop_timer().

被呼び出し関係図:

◆ lock_device()

int lock_device ( struct st_device dev,
unsigned int  timeout 
)

デバイスをロックする

引数
[in]devデバイスドライバ
[in]timeoutタイムアウト時間(msec)
戻り値
!=0:エラー

device.c310 行目に定義があります。

◆ open_device()

struct st_device* open_device ( char *  name)

デバイスをオープンする

引数
[in]nameデバイス名
戻り値
0:エラー,!=0:デバイスポインタ

device.c262 行目に定義があります。

参照先 GSC_KERNEL_MAX_DEVICE_NUM, strcomp().

参照元 init_graphics().

呼び出し関係図:
被呼び出し関係図:

◆ putc_device()

int putc_device ( struct st_device dev,
unsigned char  data 
)

デバイスにデータを1バイト書き込む

引数
[in]devデバイスドライバ
[out]data読み出しデータ
戻り値
<0:エラー

device.c502 行目に定義があります。

参照元 cputc().

被呼び出し関係図:

◆ read_device()

int read_device ( struct st_device dev,
void *  buf,
unsigned int  count 
)

デバイスよりデータを読み出す

引数
[in]devデバイスドライバ
[out]buf読み出しデータポインタ
[in]count読み出しデータバイト数
戻り値
読み出しデータバイト数,<0:エラー

device.c378 行目に定義があります。

◆ resume()

int resume ( void  )

全デバイスを活性化する

戻り値
<0:エラー

device.c655 行目に定義があります。

参照先 GSC_KERNEL_MAX_DEVICE_NUM.

◆ resume_device()

int resume_device ( struct st_device dev)

デバイスを活性化する

引数
[in]devデバイスドライバ
戻り値
<0:エラー

device.c618 行目に定義があります。

◆ seek_device()

int seek_device ( struct st_device dev,
int  offset,
int  whence 
)

デバイスのアクセスポイントを設定する

引数
[in]devデバイスドライバ
[in]offsetオフセット
[in]whenceオフセット開始位置
戻り値
<0:エラー

device.c545 行目に定義があります。

◆ select_device()

int select_device ( struct st_device dev,
unsigned int  timeout 
)

デバイスのアクセス準備完了を待つ

引数
[in]devデバイスドライバ
[in]timeoutタイムアウト時間
戻り値
<0:エラー

device.c582 行目に定義があります。

参照元 cgetc(), cwait().

被呼び出し関係図:

◆ suspend()

int suspend ( void  )

全デバイスを休止状態にする

戻り値
<0:エラー

device.c634 行目に定義があります。

参照先 GSC_KERNEL_MAX_DEVICE_NUM.

◆ suspend_device()

int suspend_device ( struct st_device dev)

デバイスを休止状態にする

引数
[in]devデバイスドライバ
戻り値
<0:エラー

device.c600 行目に定義があります。

◆ sync_device()

int sync_device ( struct st_device dev)

デバイスの書き込みデータの同期をとる

引数
[in]devデバイスドライバ
戻り値
<0:エラー

device.c563 行目に定義があります。

◆ unlock_device()

int unlock_device ( struct st_device dev)

デバイスをアンロックする

引数
[in]devデバイスドライバ
戻り値
!=0:エラー

device.c343 行目に定義があります。

◆ unregister_device()

int unregister_device ( const struct st_device dev)

デバイスを削除する

引数
[in]devデバイスドライバ
戻り値
!=0:エラー

device.c225 行目に定義があります。

参照先 flg_init_task_run, GSC_KERNEL_MAX_DEVICE_NUM, st_device::mutex, mutex_unregister(), mutex_unregister_ISR().

呼び出し関係図:

◆ write_device()

int write_device ( struct st_device dev,
const void *  buf,
unsigned int  count 
)

デバイスにデータを書き込む

引数
[in]devデバイスドライバ
[in]buf書き込みデータポインタ
[in]count書き込みデータバイト数
戻り値
書き込みデータバイト数,<0:エラー

device.c451 行目に定義があります。

変数詳解

◆ flg_init_task_run

int flg_init_task_run

デバイスを登録する

引数
[in]devデバイスドライバ
[in]contextデバイスコンテキストデータポインタ(プライベートデータ)
[in]paramドライバパラメタ
戻り値
!=0:エラー

init.c81 行目に定義があります。

参照元 device_explan(), unregister_device().