--- /dev/null
+/**
+ * $PROJECT_NAME$
+ *
+ * @file xxxxdrv.h
+ * @brief %jp{$OBJNAME_JP$ 公開ヘッダファイル}%en{$OBJNAME_EN$ public header file}
+ *
+ * $COPYRIGHT$
+ */
+
+
+#ifndef __ZZZZ__xxxxdrv_h__
+#define __ZZZZ__xxxxdrv_h__
+
+
+#include "hosaplfw.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+HANDLE XxxxDrv_Create(void *pRegBase, int iIntNum); /**< %jp{生成}%en{create} */
+void XxxxDrv_Delete(HANDLE hDriver); /**< %jp{削除}%en{delete} */
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* __ZZZZ__xxxxdrv_h__ */
+
+
+/* end of file */
--- /dev/null
+/**
+ * $PROJECT_NAME$
+ *
+ * @file xxxxdrv_close.c
+ * @brief %jp{$OBJNAME_JP$ クローズ}%en{$OBJNAME_EN$ close}
+ *
+ * $COPYRIGHT$
+ */
+
+
+#include "xxxxdrv_local.h"
+
+
+/** クローズ */
+void XxxxDrv_Close(C_DRVOBJ *pDrvObj, C_FILEOBJ *pFileObj)
+{
+ C_XXXXDRV *self;
+ C_XXXXFILE *pFile;
+
+ /* upper cast */
+ self = (C_XXXXDRV *)pDrvObj;
+ pFile = (C_XXXXFILE *)pFileObj;
+
+ /* クローズ処理 */
+ if ( --self->iOpenCount == 0 )
+ {
+ SysInt_Disable(self->iIntNum);
+ }
+
+ /* ディスクリプタ削除 */
+ SyncFile_Delete((HANDLE)pFile);
+}
+
+
+/* end of file */
--- /dev/null
+/**
+ * $PROJECT_NAME$
+ *
+ * @file xxxxdrv_constructor.c
+ * @brief %jp{$OBJNAME_JP$ オブジェクト削除}%en{$OBJNAME_EN$ delete object}
+ *
+ * $COPYRIGHT$
+ */
+
+
+#include "xxxxdrv_local.h"
+
+
+
+/** %jp{仮想関数テーブル}%en{virtual functions table} */
+const T_DRVOBJ_METHODS XxxxDrv_Methods =
+ {
+ { XxxxDrv_Delete },
+ XxxxDrv_Open,
+ XxxxDrv_Close,
+ XxxxDrv_IoControl,
+ XxxxDrv_Seek,
+ XxxxDrv_Read,
+ XxxxDrv_Write,
+ XxxxDrv_Flush,
+ };
+
+
+
+/** コンストラクタ */
+FILE_ERR XxxxDrv_Constructor(C_XXXXDRV *self, const T_DRVOBJ_METHODS *pMethods, void *pRegBase, int iIntNum)
+{
+ FILE_ERR ErrCode;
+
+ /* 仮想関数テーブル */
+ if ( pMethods == NULL )
+ {
+ pMethods = &XxxxDrv_Methods;
+ }
+
+ /* 親クラスコンストラクタ呼び出し */
+ if ( (ErrCode = SyncDrv_Constructor(&self->SyncDrv, pMethods, SYNCDRV_FACTOR_NUM)) != FILE_ERR_OK )
+ {
+ return ErrCode;
+ }
+
+ /* メンバ変数初期化 */
+ self->pRegBase = pRegBase;
+ self->iIntNum = iIntNum;
+ self->iOpenCount = 0;
+
+
+ /* 割込み処理登録 */
+ self->hIsr = SysIsr_Create(self->iIntNum, XxxxDrv_Isr, (VPARAM)self);
+ if ( self->hIsr == SYSISR_HANDLE_NULL )
+ {
+ SyncDrv_Destructor(&self->SyncDrv);
+ return FILE_ERR_NG;
+ }
+
+ return FILE_ERR_OK;
+}
+
+
+/* end of file */
--- /dev/null
+/**
+ * $PROJECT_NAME$
+ *
+ * @file xxxxdrv_create.c
+ * @brief %jp{$OBJNAME_JP$ オブジェクト生成}%en{$OBJNAME_EN$ create object}
+ *
+ * $COPYRIGHT$
+ */
+
+
+#include "xxxxdrv_local.h"
+
+
+/** %jp{オブジェクト生成}%en{create object} */
+HANDLE XxxxDrv_Create(void *pRegBase, int iIntNum)
+{
+ C_XXXXDRV *self;
+
+ /* %jp{メモリ確保}%en{Memory allocate} */
+ if ( (self = (C_XXXXDRV *)SysMem_Alloc(sizeof(C_XXXXDRV))) == NULL )
+ {
+ return HANDLE_NULL;
+ }
+
+ /* %jp{コンストラクタ呼び出し}%en{constructor} */
+ if ( XxxxDrv_Constructor(self, NULL, pRegBase, iIntNum) != FILE_ERR_OK )
+ {
+ SysMem_Free(self);
+ return HANDLE_NULL;
+ }
+
+ return (HANDLE)self;
+}
+
+
+/* end of file */
--- /dev/null
+/**
+ * $PROJECT_NAME$
+ *
+ * @file xxxxdrv_delete.c
+ * @brief %jp{$OBJNAME_JP$ オブジェクト削除}%en{$OBJNAME_EN$ delete object}
+ *
+ * $COPYRIGHT$
+ */
+
+
+
+#include "xxxxdrv_local.h"
+
+
+/** 削除 */
+void XxxxDrv_Delete(HANDLE hDriver)
+{
+ C_XXXXDRV *self;
+
+ /* upper cast */
+ self = (C_XXXXDRV *)hDriver;
+
+ /* %jp{デストラクタ呼び出し}%en{destructor} */
+ XxxxDrv_Destructor(self);
+
+ /* %jp{メモリ開放}%en{free memory} */
+ SysMem_Free(self);
+}
+
+
+/* end of file */
--- /dev/null
+/**
+ * $PROJECT_NAME$
+ *
+ * @file xxxxdrv_destructor.c
+ * @brief %jp{$OBJNAME_JP$ デストラクタ}%en{$OBJNAME_EN$ destructor}
+ *
+ * $COPYRIGHT$
+ */
+
+
+#include "xxxxdrv_local.h"
+
+
+/** デストラクタ */
+void XxxxDrv_Destructor(C_XXXXDRV *self)
+{
+ /* 割込みサービスルーチン削除 */
+ SysIsr_Delete(self->hIsr);
+
+ /* 親クラスデストラクタ */
+ SyncDrv_Destructor(&self->SyncDrv);
+}
+
+
+/* end of file */
--- /dev/null
+/**
+ * $PROJECT_NAME$
+ *
+ * @file xxxxdrv_flush.c
+ * @brief %jp{$OBJNAME_JP$ フラッシュ}%en{$OBJNAME_EN$ flush}
+ *
+ * $COPYRIGHT$
+ */
+
+
+#include "xxxxdrv_local.h"
+
+
+FILE_ERR XxxxDrv_Flush(C_DRVOBJ *pDrvObj, C_FILEOBJ *pFileObj)
+{
+ return FILE_ERR_OK;
+}
+
+
+/* end of file */
--- /dev/null
+/**
+ * $PROJECT_NAME$
+ *
+ * @file xxxxdrv_iocontrol.c
+ * @brief %jp{$OBJNAME_JP$ I/O制御}%en{$OBJNAME_EN$ I/O control}
+ *
+ * $COPYRIGHT$
+ */
+
+
+#include "xxxxdrv_local.h"
+
+
+FILE_ERR XxxxDrv_IoControl(C_DRVOBJ *pDrvObj, C_FILEOBJ *pFileObj, int iFunc, void *pInBuf, FILE_SIZE InSize, const void *pOutBuf, FILE_SIZE OutSize)
+{
+ C_XXXXDRV *self;
+ C_XXXXFILE *pFile;
+ FILE_ERR ErrCode;
+
+ /* upper cast */
+ self = (C_XXXXDRV *)pDrvObj;
+ pFile = (C_XXXXFILE *)pFileObj;
+
+ switch ( iFunc )
+ {
+ case 1:
+ {
+ /* I/O処理開始 */
+ if ( (ErrCode = SyncDrv_StartProcess(&self->SyncDrv, &pFile->SyncFile, SYNCDRV_FACTOR_IOCTL)) != FILE_ERR_OK )
+ {
+ return (FILE_SIZE)ErrCode;
+ }
+
+ /* シグナルを一旦クリア */
+ SyncFile_ClearSignal(&pFile->SyncFile, SYNCDRV_FACTOR_IOCTL);
+
+ /* 開始処理を書く */
+
+
+ /* ブロッキングモードでなければ抜ける */
+ if ( SyncFile_GetSyncMode(&pFile->SyncFile, SYNCDRV_FACTOR_IOCTL) != FILE_SYNCMODE_BLOCKING )
+ {
+ return FILE_ERR_BACKGROUND; /* バックグラウンド継続 */
+ }
+
+ /* 完了シグナルを待つ */
+ SyncFile_WaitSignal(&pFile->SyncFile, SYNCDRV_FACTOR_IOCTL);
+
+ return SyncFile_GetErrCode(&pFile->SyncFile, SYNCDRV_FACTOR_IOCTL);
+ }
+ }
+
+
+ return SyncDrv_IoControl(pDrvObj, pFileObj, iFunc, pInBuf, InSize, pOutBuf, OutSize);
+}
+
+
+/* end of file */
--- /dev/null
+/**
+ * $PROJECT_NAME$
+ *
+ * @file xxxxdrv_isr.c
+ * @brief %jp{$OBJNAME_JP$ 割込みサービスルーチン}%en{$OBJNAME_EN$ interrupt service routine}
+ *
+ * $COPYRIGHT$
+ */
+
+
+#include "xxxxdrv_local.h"
+
+
+/* 割込み処理 */
+void XxxxDrv_Isr(VPARAM Param)
+{
+ C_XXXXDRV *self;
+ int c;
+
+ self = (C_XXXXDRV *)Param;
+
+
+ /* I/O処理完了 */
+ SyncDrv_EndProcess(&self->SyncDrv, SYNCDRV_FACTOR_IOCTL, (VPARAM)FILE_ERR_OK);
+
+
+ /* 割込み要因クリア */
+ SysInt_Clear(self->iIntNum);
+}
+
+
+/* end of file */
--- /dev/null
+/**
+ * $PROJECT_NAME$
+ *
+ * @file xxxxdrv_local.h
+ * @brief %jp{$OBJNAME_JP$ ローカルヘッダファイル}%en{$OBJNAME_EN$ private header file}
+ *
+ * $COPYRIGHT$
+ */
+
+
+#ifndef __ZZZZ__xxxxdrv_local_h__
+#define __ZZZZ__xxxxdrv_local_h__
+
+
+#include "xxxxdrv.h"
+#include "system/file/syncdrv_local.h"
+#include "system/sysapi/sysapi.h"
+
+
+/** %jp{ドライバクラス}%en{Device driver class} */
+typedef struct c_xxxxdrv
+{
+ C_SYNCDRV SyncDrv; /**< %jp{同期機能付きデバイスドライバを継承} */
+
+ void *pRegBase; /**< %jp{レジスタベースアドレス} */
+ int iIntNum; /**< %jp{割込み番号} */
+
+ SYSISR_HANDLE hIsr; /**< %jp{割込みサービスルーチンハンドル} */
+
+ int iOpenCount; /**< %jp{オープンカウンタ} */
+} C_XXXXDRV;
+
+
+#include "xxxxfile_local.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+FILE_ERR XxxxDrv_Constructor(C_XXXXDRV *self, const T_DRVOBJ_METHODS *pMethods, void *pRegBase, int iIntNum); /**< コンストラクタ */
+void XxxxDrv_Destructor(C_XXXXDRV *self); /**< デストラクタ */
+
+HANDLE XxxxDrv_Open(C_DRVOBJ *pDrvObj, const char *pszPath, int iMode);
+void XxxxDrv_Close(C_DRVOBJ *pDrvObj, C_FILEOBJ *pFileObj);
+FILE_ERR XxxxDrv_IoControl(C_DRVOBJ *pDrvObj, C_FILEOBJ *pFileObj, int iFunc, void *pInBuf, FILE_SIZE InSize, const void *pOutBuf, FILE_SIZE OutSize);
+FILE_POS XxxxDrv_Seek(C_DRVOBJ *pDrvObj, C_FILEOBJ *pFileObj, FILE_POS Offset, int iOrign);
+FILE_SIZE XxxxDrv_Read(C_DRVOBJ *pDrvObj, C_FILEOBJ *pFileObj, void *pBuf, FILE_SIZE Size);
+FILE_SIZE XxxxDrv_Write(C_DRVOBJ *pDrvObj, C_FILEOBJ *pFileObj, const void *pData, FILE_SIZE Size);
+FILE_ERR XxxxDrv_Flush(C_DRVOBJ *pDrvObj, C_FILEOBJ *pFileObj);
+
+void XxxxDrv_Isr(VPARAM Param); /**< %jp{割込み処理} */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* __ZZZZ__xxxxdrv_local_h__ */
+
+
+/* end of file */
--- /dev/null
+/**
+ * $PROJECT_NAME$
+ *
+ * @file xxxxdrv_close.c
+ * @brief %jp{$OBJNAME_JP$ クローズ}%en{$OBJNAME_EN$ close}
+ *
+ * $COPYRIGHT$
+ */
+
+
+#include "xxxxdrv_local.h"
+
+
+/** オープン */
+HANDLE XxxxDrv_Open(C_DRVOBJ *pDrvObj, const char *pszPath, int iMode)
+{
+ C_XXXXDRV *self;
+ HANDLE hFile;
+
+ /* upper cast */
+ self = (C_XXXXDRV *)pDrvObj;
+
+ /* create file descriptor */
+ if ( (hFile = XxxxFile_Create(self, iMode)) == HANDLE_NULL )
+ {
+ return HANDLE_NULL;
+ }
+
+ /* オープン処理 */
+ if ( self->iOpenCount++ == 0 )
+ {
+ /* ここでデバイスを初期化 */
+
+ /* 割り込みを許可 */
+ SysInt_Enable(self->iIntNum);
+ }
+
+ return hFile;
+}
+
+
+/* end of file */
--- /dev/null
+/**
+ * $PROJECT_NAME$
+ *
+ * @file xxxxdrv_read.c
+ * @brief %jp{$OBJNAME_JP$ 読込み}%en{$OBJNAME_EN$ read}
+ *
+ * $COPYRIGHT$
+ */
+
+
+#include "xxxxdrv_local.h"
+
+
+/** %jp{読込み} */
+FILE_SIZE XxxxDrv_Read(C_DRVOBJ *pDrvObj, C_FILEOBJ *pFileObj, void *pBuf, FILE_SIZE Size)
+{
+ C_XXXXDRV *self;
+ C_XXXXFILE *pFile;
+
+ /* upper cast */
+ self = (C_XXXXDRV *)pDrvObj;
+ pFile = (C_XXXXFILE *)pFileObj;
+
+ return 0;
+}
+
+
+/* end of file */
--- /dev/null
+/**
+ * $PROJECT_NAME$
+ *
+ * @file xxxxdrv_seek.c
+ * @brief %jp{$OBJNAME_JP$ シーク}%en{$OBJNAME_EN$ seek}
+ *
+ * $COPYRIGHT$
+ */
+
+
+#include "xxxxdrv_local.h"
+
+
+FILE_POS XxxxDrv_Seek(C_DRVOBJ *pDrvObj, C_FILEOBJ *pFileObj, FILE_POS Offset, int iOrign)
+{
+ return FILE_ERR_NG;
+}
+
+
+/* end of file */
--- /dev/null
+/**
+ * $PROJECT_NAME$
+ *
+ * @file xxxxdrv_write.c
+ * @brief %jp{$OBJNAME_JP$ 書込み}%en{$OBJNAME_EN$ write}
+ *
+ * $COPYRIGHT$
+ */
+
+
+#include "xxxxdrv_local.h"
+
+
+/** %jp{送信} */
+FILE_SIZE XxxxDrv_Write(C_DRVOBJ *pDrvObj, C_FILEOBJ *pFileObj, const void *pData, FILE_SIZE Size)
+{
+ C_XXXXDRV *self;
+ C_XXXXFILE *pFile;
+
+ /* upper cast */
+ self = (C_XXXXDRV *)pDrvObj;
+ pFile = (C_XXXXFILE *)pFileObj;
+
+ return 0;
+}
+
+
+/* end of file */
--- /dev/null
+/**
+ * $PROJECT_NAME$
+ *
+ * @file xxxxfile.h
+ * @brief %jp{$OBJNAME_JP$ 公開ヘッダファイル}%en{$OBJNAME_EN$ public header file}
+ *
+ * $COPYRIGHT$
+ */
+
+
+#ifndef __ZZZZ__xxxxfile_h__
+#define __ZZZZ__xxxxfile_h__
+
+
+#include "xxxxdrv_local.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+HANDLE XxxxFile_Create(C_XXXXDRV *pXxxxDrv, int iMode);
+void XxxxFile_Delete(HANDLE hFile);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* __ZZZZ__xxxxfile_h__ */
+
+
+/* end of file */
--- /dev/null
+/**
+ * $PROJECT_NAME$
+ *
+ * @file xxxxfile_constructor.c
+ * @brief %jp{$OBJNAME_JP$ コンストラクタ}%en{$OBJNAME_EN$ constructor}
+ *
+ * $COPYRIGHT$
+ */
+
+
+#include "xxxxfile_local.h"
+
+
+void XxxxFile_Constructor(C_XXXXFILE *self, const T_FILEOBJ_METHODS *pMethods, C_XXXXDRV *pXxxxDrv, int iMode)
+{
+ /* 親クラスコンストラクタ */
+ SyncFile_Constructor(&self->SyncFile, pMethods, &pXxxxDrv->SyncDrv, iMode);
+
+ /* メンバ変数初期化 */
+}
+
+
+/* end of file */
--- /dev/null
+/**
+ * $PROJECT_NAME$
+ *
+ * @file xxxxfile.h
+ * @brief %jp{$OBJNAME_JP$ 公開ヘッダファイル}%en{$OBJNAME_EN$ public header file}
+ *
+ * $COPYRIGHT$
+ */
+
+
+#include "xxxxfile_local.h"
+
+
+static const T_FILEOBJ_METHODS XxxxFile_FileObjMethods =
+ {
+ {File_Close}, /* デストラクタ */
+ };
+
+
+HANDLE XxxxFile_Create(C_XXXXDRV *pXxxxVol, int iMode)
+{
+ C_XXXXFILE *self;
+
+ /* create file descriptor */
+ if ( (self = (C_XXXXFILE *)SysMem_Alloc(sizeof(C_XXXXFILE))) == NULL )
+ {
+ return HANDLE_NULL;
+ }
+
+ /* コンストラクタ呼び出し */
+ XxxxFile_Constructor(self, &XxxxFile_FileObjMethods, pXxxxVol, iMode);
+
+ return (HANDLE)self;
+}
+
+
+/* end of file */
--- /dev/null
+/**
+ * $PROJECT_NAME$
+ *
+ * @file xxxxfile.h
+ * @brief %jp{$OBJNAME_JP$ オブジェクト削除}%en{$OBJNAME_EN$ delete}
+ *
+ * $COPYRIGHT$
+ */
+
+
+#include "xxxxfile_local.h"
+
+
+void XxxxFile_Delete(HANDLE hFile)
+{
+ C_XXXXFILE *self;
+
+ self = (C_XXXXFILE *)hFile;
+
+ /* デストラクタ */
+ XxxxFile_Destructor(self);
+
+ /* メモリ削除 */
+ SysMem_Free(self);
+}
+
+
+/* end of file */
--- /dev/null
+/**
+ * $PROJECT_NAME$
+ *
+ * @file xxxxfile_destructor.c
+ * @brief %jp{$OBJNAME_JP$ デストラクタ}%en{$OBJNAME_EN$ destructor}
+ *
+ * $COPYRIGHT$
+ */
+
+
+#include "xxxxfile_local.h"
+
+
+void XxxxFile_Destructor(C_XXXXFILE *self)
+{
+ /* 親クラスデストラクタ */
+ SyncFile_Destructor(&self->SyncFile);
+}
+
+
+/* end of file */
--- /dev/null
+/**
+ * $PROJECT_NAME$
+ *
+ * @file xxxxfile.h
+ * @brief %jp{$OBJNAME_JP$ ローカルヘッダファイル}%en{$OBJNAME_EN$ private header file}
+ *
+ * $COPYRIGHT$
+ */
+
+
+#ifndef __ZZZZ__xxxxfile_local_h__
+#define __ZZZZ__xxxxfile_local_h__
+
+
+#include "xxxxfile.h"
+#include "system/file/syncfile_local.h"
+#include "system/sysapi/sysapi.h"
+
+
+/* ファイルディスクリプタ */
+typedef struct c_xxxxfile
+{
+ C_SYNCFILE SyncFile; /* 継承 */
+
+ /* ここに必要なメンバを追加 */
+} C_XXXXFILE;
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void XxxxFile_Constructor(C_XXXXFILE *self, const T_FILEOBJ_METHODS *pMethods, C_XXXXDRV *pXxxxDrv, int iMode);
+void XxxxFile_Destructor(C_XXXXFILE *self);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+
+#endif /* __ZZZZ__xxxxfile_local_h__ */
+
+
+/* end of file */