OSDN Git Service

(none)
authorryuz <ryuz>
Tue, 23 Oct 2007 15:07:58 +0000 (15:07 +0000)
committerryuz <ryuz>
Tue, 23 Oct 2007 15:07:58 +0000 (15:07 +0000)
94 files changed:
aplfw/application/filecmd/filecat/filecat.h [new file with mode: 0755]
aplfw/application/filecmd/filecat/filecat_main.c [new file with mode: 0755]
aplfw/application/filecmd/filecopy/filecopy.h [new file with mode: 0755]
aplfw/application/filecmd/filecopy/filecopy_main.c [new file with mode: 0755]
aplfw/application/filecmd/filedump/filedump.h [new file with mode: 0755]
aplfw/application/filecmd/filedump/filedump_main.c [new file with mode: 0755]
aplfw/application/filecmd/filelist/filelist.h
aplfw/build/common/gmake/aplfwsrc.inc
aplfw/driver/serial/at91/at91usartdrv_local.h
aplfw/driver/serial/pc16550/pc16550drv.h
aplfw/driver/serial/pc16550/pc16550drv_close.c
aplfw/driver/serial/pc16550/pc16550drv_flush.c
aplfw/driver/serial/pc16550/pc16550drv_iocontrol.c
aplfw/driver/serial/pc16550/pc16550drv_open.c
aplfw/driver/serial/pc16550/pc16550drv_read.c
aplfw/driver/serial/pc16550/pc16550drv_seek.c
aplfw/driver/serial/pc16550/pc16550drv_write.c
aplfw/driver/serial/renesas/scidrv.h
aplfw/driver/serial/renesas/scidrv_flush.c
aplfw/driver/serial/renesas/scidrv_iocontrol.c
aplfw/driver/serial/renesas/scidrv_open.c
aplfw/driver/serial/renesas/scidrv_read.c
aplfw/driver/serial/renesas/scidrv_seek.c
aplfw/driver/serial/renesas/scidrv_write.c
aplfw/driver/tcpip/tcpip/tcpip_clese.c [new file with mode: 0755]
aplfw/driver/tcpip/tcpip/tcpip_delete.c [new file with mode: 0755]
aplfw/driver/tcpip/tcpip/tcpip_flush.c [new file with mode: 0755]
aplfw/driver/tcpip/tcpip/tcpip_iocontrol.c [new file with mode: 0755]
aplfw/driver/tcpip/tcpip/tcpip_local.h
aplfw/driver/tcpip/tcpip/tcpip_open.c [new file with mode: 0755]
aplfw/driver/tcpip/tcpip/tcpip_read.c [new file with mode: 0755]
aplfw/driver/tcpip/tcpip/tcpip_seek.c [new file with mode: 0755]
aplfw/driver/tcpip/tcpip/tcpip_write.c [new file with mode: 0755]
aplfw/driver/volume/fat/fatvol.h
aplfw/driver/volume/fat/fatvol_close.c
aplfw/driver/volume/fat/fatvol_create.c
aplfw/driver/volume/fat/fatvol_flush.c
aplfw/driver/volume/fat/fatvol_flushclusterbuf.c [new file with mode: 0755]
aplfw/driver/volume/fat/fatvol_flushfat.c
aplfw/driver/volume/fat/fatvol_getclusterbuf.c
aplfw/driver/volume/fat/fatvol_getfilesize.c [deleted file]
aplfw/driver/volume/fat/fatvol_getnewcluster.c [new file with mode: 0755]
aplfw/driver/volume/fat/fatvol_getnextcluster.c
aplfw/driver/volume/fat/fatvol_local.h
aplfw/driver/volume/fat/fatvol_open.c
aplfw/driver/volume/fat/fatvol_read.c
aplfw/driver/volume/fat/fatvol_setnextcluster.c
aplfw/driver/volume/fat/fatvol_syncfilesize.c [new file with mode: 0755]
aplfw/driver/volume/fat/fatvol_write.c
aplfw/hosaplfw.h
aplfw/library/container/packetbuf/packetbuf.h [new file with mode: 0755]
aplfw/library/container/packetbuf/packetbuf_clear.c [new file with mode: 0755]
aplfw/library/container/packetbuf/packetbuf_create.c [new file with mode: 0755]
aplfw/library/container/packetbuf/packetbuf_getbuf.c [new file with mode: 0755]
aplfw/library/container/packetbuf/packetbuf_local.h [new file with mode: 0755]
aplfw/library/container/packetbuf/packetbuf_recvbuf.c [new file with mode: 0755]
aplfw/library/container/packetbuf/packetbuf_recvdata.c [new file with mode: 0755]
aplfw/library/container/packetbuf/packetbuf_relbuf.c [new file with mode: 0755]
aplfw/library/container/packetbuf/packetbuf_sendbuf.c [new file with mode: 0755]
aplfw/library/container/packetbuf/packetbuf_senddata.c [new file with mode: 0755]
aplfw/library/container/stmbuf/stmbuf.c [deleted file]
aplfw/library/container/stmbuf/stmbuf.h [deleted file]
aplfw/library/container/streambuf/streambuf.h [new file with mode: 0755]
aplfw/library/container/streambuf/streambuf_clear.c [new file with mode: 0755]
aplfw/library/container/streambuf/streambuf_create.c [new file with mode: 0755]
aplfw/library/container/streambuf/streambuf_getbuf.c [new file with mode: 0755]
aplfw/library/container/streambuf/streambuf_local.h [new file with mode: 0755]
aplfw/library/container/streambuf/streambuf_recvbuf.c [new file with mode: 0755]
aplfw/library/container/streambuf/streambuf_recvchar.c [new file with mode: 0755]
aplfw/library/container/streambuf/streambuf_recvdata.c [new file with mode: 0755]
aplfw/library/container/streambuf/streambuf_refdatasize.c [new file with mode: 0755]
aplfw/library/container/streambuf/streambuf_reffreesize.c [new file with mode: 0755]
aplfw/library/container/streambuf/streambuf_relbuf.c [new file with mode: 0755]
aplfw/library/container/streambuf/streambuf_sendbuf.c [new file with mode: 0755]
aplfw/library/container/streambuf/streambuf_sendchar.c [new file with mode: 0755]
aplfw/library/container/streambuf/streambuf_senddata.c [new file with mode: 0755]
aplfw/sample/arm/utb_arm7at91/boot_task.c
aplfw/system/file/stdfile.h
aplfw/system/file/sysvol_open.c
aplfw/system/sysapi/systim_getsystemtime.c
aplfw/system/time/time.h
aplfw/system/time/time_getsystemtime.c
aplfw/system/time/time_wait.c
cfgrtr/build/vc60/h4acfg.dsp
cfgrtr/build/vc60/h4acfg.dsw
kernel/build/win/win32/vc60/hosv4a.dsp
kernel/build/win/win32/vc60/hosv4a.dsw
kernel/include/arch/proc/mn103/mn1030/proc.h
sample/win/win32/vc60/sample.dsp
sample/win/win32/vc60/sample.dsw
test/que/test_que.dsp
test/que/test_que.dsw
tools/cmtcnv/cmtcnv.dsp
tools/cmtcnv/cmtcnv.dsw

diff --git a/aplfw/application/filecmd/filecat/filecat.h b/aplfw/application/filecmd/filecat/filecat.h
new file mode 100755 (executable)
index 0000000..1243124
--- /dev/null
@@ -0,0 +1,30 @@
+/** 
+ *  Hyper Operating System  Application Framework
+ *
+ * @file  filecat.h
+ * @brief %jp{ファイル結合コマンド}
+ *
+ * Copyright (C) 2006-2007 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+
+#ifndef __HOS__filecat_h__
+#define __HOS__filecat_h__
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int FileCat_Main(int argc, char *argv[]);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* __HOS__filecat_h__ */
+
+
+/* end of file */
diff --git a/aplfw/application/filecmd/filecat/filecat_main.c b/aplfw/application/filecmd/filecat/filecat_main.c
new file mode 100755 (executable)
index 0000000..29dcf9c
--- /dev/null
@@ -0,0 +1,62 @@
+/** 
+ *  Hyper Operating System  Application Framework
+ *
+ * @file  filecat_main.c
+ * @brief %jp{ファイル結合コマンド}
+ *
+ * Copyright (C) 2006-2007 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include "hosaplfw.h"
+#include "filecat.h"
+
+
+#define FILECAT_BUFSIZE        4096
+
+
+/* ファイル結合コマンド */
+int FileCat_Main(int argc, char *argv[])
+{
+       HANDLE          hFile;
+       int                     i;
+       FILE_SIZE       Size;
+       void            *pBuf;
+
+       /* バッファ確保 */
+       pBuf = Memory_Alloc(FILECAT_BUFSIZE);
+       if ( pBuf == NULL )
+       {
+               return 1;
+       }
+       
+       /* 結合 */
+       for ( i = 1; i < argc; i++ )
+       {
+               /* Open */
+               if ( (hFile = File_Open(argv[i], FILE_OPEN_READ | FILE_OPEN_EXIST)) == HANDLE_NULL )
+               {
+                       continue;
+               }
+               
+               /* 読み出し */
+               while ( (Size = File_Read(hFile, pBuf, FILECAT_BUFSIZE)) > 0 )
+               {
+                       StdIo_Write(pBuf, Size);
+               }
+               
+               /* Close */
+               File_Close(hFile);              
+       }
+
+       /* バッファ開放 */
+       Memory_Free(pBuf);
+
+
+       return 0;
+}
+
+
+/* end of file */
diff --git a/aplfw/application/filecmd/filecopy/filecopy.h b/aplfw/application/filecmd/filecopy/filecopy.h
new file mode 100755 (executable)
index 0000000..e3fc11f
--- /dev/null
@@ -0,0 +1,30 @@
+/** 
+ *  Hyper Operating System  Application Framework
+ *
+ * @file  filelist.h
+ * @brief %jp{ファイルコピーコマンド}
+ *
+ * Copyright (C) 2006-2007 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+
+#ifndef __HOS__filecopy_h__
+#define __HOS__filecopy_h__
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int FileCopy_Main(int argc, char *argv[]);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* __HOS__filecopy_h__ */
+
+
+/* end of file */
diff --git a/aplfw/application/filecmd/filecopy/filecopy_main.c b/aplfw/application/filecmd/filecopy/filecopy_main.c
new file mode 100755 (executable)
index 0000000..fc605a1
--- /dev/null
@@ -0,0 +1,69 @@
+/** 
+ *  Hyper Operating System  Application Framework
+ *
+ * @file  filecopy_main.c
+ * @brief %jp{ファイルコピーコマンド}
+ *
+ * Copyright (C) 2006-2007 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include "hosaplfw.h"
+#include "filecopy.h"
+
+
+#define FILECOPY_BUFSIZE       (4 * 1024)
+
+
+int FileCopy_Main(int argc, char *argv[])
+{
+       HANDLE          hFileSrc;
+       HANDLE          hFileDst;
+       void            *pBuf;
+       FILE_SIZE       Size;
+       
+       /* 引数チェック */
+       if ( argc < 3 )
+       {
+               return 1;
+       }
+
+       /* バッファ確保 */
+       pBuf = Memory_Alloc(FILECOPY_BUFSIZE);
+       if ( pBuf == NULL )
+       {
+               return 1;
+       }
+       
+       /* Open */
+       if ( (hFileSrc = File_Open(argv[1], FILE_OPEN_READ | FILE_OPEN_EXIST)) == HANDLE_NULL )
+       {
+               return 1;
+       }
+       if ( (hFileDst = File_Open(argv[2], FILE_OPEN_WRITE | FILE_OPEN_CREATE)) == HANDLE_NULL )
+       {
+               File_Close(hFileSrc);
+               return 1;
+       }
+       
+       
+       /* コピー */
+       while ( (Size = File_Read(hFileSrc, pBuf, FILECOPY_BUFSIZE)) > 0 )
+       {
+               File_Write(hFileDst, pBuf, Size);
+       }
+               
+       /* Close */
+       File_Close(hFileSrc);
+       File_Close(hFileDst);
+
+       /* バッファ開放 */
+       Memory_Free(pBuf);
+
+       return 0;
+}
+
+
+/* end of file */
diff --git a/aplfw/application/filecmd/filedump/filedump.h b/aplfw/application/filecmd/filedump/filedump.h
new file mode 100755 (executable)
index 0000000..09a2110
--- /dev/null
@@ -0,0 +1,30 @@
+/** 
+ *  Hyper Operating System  Application Framework
+ *
+ * @file  filedump.h
+ * @brief %jp{ファイルダンプコマンド}
+ *
+ * Copyright (C) 2006-2007 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+
+#ifndef __HOS__filedump_h__
+#define __HOS__filedump_h__
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int FileDump_Main(int argc, char *argv[]);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* __HOS__filedump_h__ */
+
+
+/* end of file */
diff --git a/aplfw/application/filecmd/filedump/filedump_main.c b/aplfw/application/filecmd/filedump/filedump_main.c
new file mode 100755 (executable)
index 0000000..1c1407a
--- /dev/null
@@ -0,0 +1,113 @@
+/** 
+ *  Hyper Operating System  Application Framework
+ *
+ * @file  filedump_main.c
+ * @brief %jp{ファイルダンプコマンド}
+ *
+ * Copyright (C) 2006-2007 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+
+#include <stdlib.h>
+#include <string.h>
+#include "hosaplfw.h"
+#include "filedump.h"
+
+#define FILEDUMP_BUFSIZE       4096
+
+
+int FileDump_Main(int argc, char *argv[])
+{
+       HANDLE                  hFile;
+       unsigned char   *pubBuf;
+       unsigned long   ulSize = 0x7fffffff;
+       unsigned long   ulPos  = 0;
+       int                             iReadSize;
+       int                             i;
+
+       /* 引数チェック */
+       if ( argc < 2 )
+       {
+               StdIo_PrintFormat(
+                               "<usage>\n"
+                               " %s filename [size] [offest]\n\n",
+                               argv[0]
+                       );
+               return 1;
+       }
+
+       /* コマンドライン解析 */
+       if ( argc >= 3 )
+       {
+               ulSize = (int)strtoul(argv[2], 0, 0);
+       }
+       if ( argc >= 4 )
+       {
+               ulPos = (int)strtoul(argv[3], 0, 0);
+       }
+
+       
+       /* ファイルをを開く */  
+       if ( (hFile = File_Open(argv[1], FILE_OPEN_READ)) == HANDLE_NULL )
+       {
+               return 1;
+       }
+       ulPos = File_Seek(hFile, ulPos, FILE_SEEK_SET);
+
+       
+       /* バッファ確保 */
+       pubBuf = (unsigned char *)Memory_Alloc(FILEDUMP_BUFSIZE);
+       if ( pubBuf == NULL )
+       {
+               File_Close(hFile);
+               return 1;
+       }
+       
+       
+       while ( ulSize > 0 )
+       {
+               if ( ulSize > FILEDUMP_BUFSIZE )
+               {
+                       iReadSize = FILEDUMP_BUFSIZE;
+               }
+               else
+               {
+                       iReadSize = (int)ulSize;
+               }
+               
+               iReadSize = File_Read(hFile, pubBuf, iReadSize);
+               if ( iReadSize <= 0 )
+               {
+                       break;
+               }
+               ulSize -= iReadSize;
+               
+               for ( i = 0; i < iReadSize; i++ )
+               {
+                       if ( i % 16 == 0 )
+                       {
+                               StdIo_PrintFormat("%08lx: ", ulPos);
+                       }
+                       StdIo_PrintFormat("%02x ",  pubBuf[i]);
+                       ulPos++;
+                       if ( i % 16 == 15 )
+                       {
+                               StdIo_PrintFormat("\n");
+                       }
+               }
+       }
+       StdIo_PrintFormat("\n");
+       
+       
+       /* メモリ開放 */
+       Memory_Free(pubBuf);
+
+       /* ファイルを閉じる */  
+       File_Close(hFile);
+
+       return 0;
+}
+
+
+/* end of file */
index 4e91294..5be95d6 100755 (executable)
@@ -24,8 +24,7 @@ int FileList_Main(int argc, char *argv[]);
 #endif
 
 
-#endif /* __HOS__filelist_h__
- */
+#endif /* __HOS__filelist_h__ */
 
 
 /* end of file */
index 02aeaa9..9b0cd9a 100755 (executable)
@@ -52,6 +52,7 @@ CSRCS         += $(SYSAPI_DIR)/sysapi_initialize.c                                    \
                  $(SYSAPI_DIR)/sysprc_exit.c                                           \
                  $(SYSAPI_DIR)/sysprc_getcurrenthandle.c                       \
                  $(SYSAPI_DIR)/sysprc_start.c                                          \
+                 $(SYSAPI_DIR)/systim_getsystemtime.c                          \
                  $(SYSAPI_DIR)/systim_wait.c
 
 
@@ -69,6 +70,13 @@ SRC_DIRS      += $(MEMORY_DIR)
 CSRCS         += $(MEMORY_DIR)/memory.c
 
 
+# Time
+TIME_DIR       = $(APLFW_DIR)/system/time
+SRC_DIRS      += $(TIME_DIR)
+CSRCS         += $(TIME_DIR)/time_getsystemtime.c                                      \
+                 $(TIME_DIR)/time_wait.c
+
+
 # Process
 PROCESS_DIR    = $(APLFW_DIR)/system/process
 SRC_DIRS      += $(PROCESS_DIR)
@@ -145,17 +153,12 @@ SRC_DIRS      += $(MEMPOL_DIR)
 CSRCS         += $(MEMPOL_DIR)/mempol.c        
 
 
-# Stream Buffer
-STMBUF_DIR     = $(APLFW_DIR)/library/container/stmbuf
-SRC_DIRS      += $(STMBUF_DIR)
-CSRCS         += $(STMBUF_DIR)/stmbuf.c
-
-
 # Association Array
 ASSOC_DIR      = $(APLFW_DIR)/library/container/assoc
 SRC_DIRS      += $(ASSOC_DIR)
 CSRCS         += $(ASSOC_DIR)/assoc.c
 
+
 # List
 LIST_DIR       = $(APLFW_DIR)/library/container/list
 SRC_DIRS      += $(LIST_DIR)
@@ -170,6 +173,36 @@ CSRCS         += $(LIST_DIR)/list_create.c                                                 \
                  $(LIST_DIR)/list_remove.c
 
 
+# Stream Buffer
+STREAMBUF_DIR  = $(APLFW_DIR)/library/container/streambuf
+SRC_DIRS      += $(STREAMBUF_DIR)
+CSRCS         += $(STREAMBUF_DIR)/streambuf_create.c                           \
+                 $(STREAMBUF_DIR)/streambuf_getbuf.c                           \
+                 $(STREAMBUF_DIR)/streambuf_sendbuf.c                          \
+                 $(STREAMBUF_DIR)/streambuf_senddata.c                         \
+                 $(STREAMBUF_DIR)/streambuf_sendchar.c                         \
+                 $(STREAMBUF_DIR)/streambuf_recvbuf.c                          \
+                 $(STREAMBUF_DIR)/streambuf_relbuf.c                           \
+                 $(STREAMBUF_DIR)/streambuf_recvdata.c                         \
+                 $(STREAMBUF_DIR)/streambuf_recvchar.c                         \
+                 $(STREAMBUF_DIR)/streambuf_clear.c                                    \
+                 $(STREAMBUF_DIR)/streambuf_refdatasize.c                      \
+                 $(STREAMBUF_DIR)/streambuf_reffreesize.c
+
+
+# Packet Buffer
+PACKETBUF_DIR  = $(APLFW_DIR)/library/container/packetbuf
+SRC_DIRS      += $(PACKETBUF_DIR)
+CSRCS         += $(PACKETBUF_DIR)/packetbuf_create.c                           \
+                 $(PACKETBUF_DIR)/packetbuf_getbuf.c                           \
+                 $(PACKETBUF_DIR)/packetbuf_sendbuf.c                          \
+                 $(PACKETBUF_DIR)/packetbuf_senddata.c                         \
+                 $(PACKETBUF_DIR)/packetbuf_recvbuf.c                          \
+                 $(PACKETBUF_DIR)/packetbuf_relbuf.c                           \
+                 $(PACKETBUF_DIR)/packetbuf_recvdata.c                         \
+                 $(PACKETBUF_DIR)/packetbuf_clear.c
+
+
 
 # --------------------------------------------------
 #  Device Drivers
@@ -248,6 +281,21 @@ FILELIST_DIR   = $(APLFW_DIR)/application/filecmd/filelist
 SRC_DIRS      += $(FILELIST_DIR)
 CSRCS         += $(FILELIST_DIR)/filelist_main.c
 
+# File Cat
+FILECAT_DIR    = $(APLFW_DIR)/application/filecmd/filecat
+SRC_DIRS      += $(FILECAT_DIR)
+CSRCS         += $(FILECAT_DIR)/filecat_main.c
+
+# File Copy
+FILECOPY_DIR   = $(APLFW_DIR)/application/filecmd/filecopy
+SRC_DIRS      += $(FILECOPY_DIR)
+CSRCS         += $(FILECOPY_DIR)/filecopy_main.c
+
+# File Dump
+FILEDUMP_DIR   = $(APLFW_DIR)/application/filecmd/filedump
+SRC_DIRS      += $(FILEDUMP_DIR)
+CSRCS         += $(FILEDUMP_DIR)/filedump_main.c
+
 
 # Memory Dump
 MEMDUMP_DIR    = $(APLFW_DIR)/application/utility/memdump
@@ -269,6 +317,11 @@ KEYTEST_DIR    = $(APLFW_DIR)/application/utility/keytest
 SRC_DIRS      += $(KEYTEST_DIR)
 CSRCS         += $(KEYTEST_DIR)/keytest_main.c
 
+# Time Command
+TIMECMD_DIR    = $(APLFW_DIR)/application/utility/timecmd
+SRC_DIRS      += $(TIMECMD_DIR)
+CSRCS         += $(TIMECMD_DIR)/timecmd_main.c
+
 
 # Ether Snoopt
 ETHERSNOOP_DIR = $(APLFW_DIR)/application/netcmd/ethersnoop
index 111b887..b14bd03 100755 (executable)
 
 #define AT91USART_US_CR                        0x00            /* Control Register */
 #define AT91USART_US_MR                        0x04            /* Mode Register */
-#define AT91USART_US_IER               0x08            /* Interrupt Enable Register */
-#define AT91USART_US_IDR               0x0c            /* Interrupt Disable Register */
-#define AT91USART_US_IMR               0x10            /* Interrupt Mask Register */
-#define AT91USART_US_CSR               0x14            /* Channel Status Register */
-#define AT91USART_US_RHR               0x18            /* Receiver Holding Register */
-#define AT91USART_US_THR               0x1c            /* Transmitter Holding Register */
+#define AT91USART_US_IER                       0x08            /* Interrupt Enable Register */
+#define AT91USART_US_IDR                       0x0c            /* Interrupt Disable Register */
+#define AT91USART_US_IMR                       0x10            /* Interrupt Mask Register */
+#define AT91USART_US_CSR                       0x14            /* Channel Status Register */
+#define AT91USART_US_RHR                       0x18            /* Receiver Holding Register */
+#define AT91USART_US_THR                       0x1c            /* Transmitter Holding Register */
 #define AT91USART_US_BRGR              0x20            /* Baud Rate Generator Register */
 #define AT91USART_US_RTOR              0x24            /* Receiver Time-out Register */
 #define AT91USART_US_TTGR              0x28            /* Transmitter Time-guard Register */
-#define AT91USART_US_RPR               0x30            /* Receive Pointer Register */
-#define AT91USART_US_RCR               0x34            /* Receive Counter Register */
-#define AT91USART_US_TPR               0x38            /* Transmit Pointer Register */
-#define AT91USART_US_TCR               0x3c            /* Transmit Counter Register */
+#define AT91USART_US_RPR                       0x30            /* Receive Pointer Register */
+#define AT91USART_US_RCR                       0x34            /* Receive Counter Register */
+#define AT91USART_US_TPR                       0x38            /* Transmit Pointer Register */
+#define AT91USART_US_TCR                       0x3c            /* Transmit Counter Register */
 
 #define AT91USART_REG_WRITE(self, offset, val) do { *(unsigned long *)((char *)(self)->pRegBase + (offset)) = (val); } while(0)
 #define AT91USART_REG_READ(self, offset)                       (*((unsigned long *)((char *)(self)->pRegBase + (offset))))
index 96ee187..6456bde 100755 (executable)
@@ -16,7 +16,7 @@
 #include "system/sysapi/sysapi.h"
 #include "system/file/chrdrv.h"
 #include "pc16550hal.h"
-#include "library/container/stmbuf/stmbuf.h"
+#include "library/container/streambuf/streambuf.h"
 
 
 /* PC16550用ドライバ制御部 */
index e24cac2..ac0f93f 100755 (executable)
 void Pc16550Drv_Close(C_DRVOBJ *pDrvObj, C_FILEOBJ *pFileObj)
 {
        C_PC16550DRV    *self;
-       C_CHRFILE               *pChrFile;
+       C_CHRFILE               *pFile;
        
        /* upper cast */
-       self     = (C_PC16550DRV *)pDrvObj;
-       pChrFile = (C_CHRFILE *)pFileObj;
+       self  = (C_PC16550DRV *)pDrvObj;
+       pFile = (C_CHRFILE *)pFileObj;
 
        /* クローズ処理 */
        if ( --self->iOpenCount == 0 )
@@ -32,7 +32,7 @@ void Pc16550Drv_Close(C_DRVOBJ *pDrvObj, C_FILEOBJ *pFileObj)
        }
        
        /* ディスクリプタ削除 */
-       ChrFile_Delete(pChrFile);       
+       ChrFile_Delete(pFile);  
        SysMem_Free(pFileObj);
 }
 
index 9f16072..476771f 100755 (executable)
 FILE_ERR Pc16550Drv_Flush(C_DRVOBJ *pDrvObj, C_FILEOBJ *pFileObj)
 {
        C_PC16550DRV    *self;
-       C_CHRFILE               *pChrFile;
+       C_CHRFILE               *pFile;
        
        /* upper cast */
-       self     = (C_PC16550DRV *)pDrvObj;
-       pChrFile = (C_CHRFILE *)pFileObj;
+       self  = (C_PC16550DRV *)pDrvObj;
+       pFile = (C_CHRFILE *)pFileObj;
 
        return FILE_ERR_OK;
 }
index 8f80496..12ca75f 100755 (executable)
 FILE_ERR  Pc16550Drv_IoControl(C_DRVOBJ *pDrvObj, C_FILEOBJ *pFileObj, int iFunc, void *pInBuf, FILE_SIZE InSize, const void *pOutBuf, FILE_SIZE OutSize)
 {
        C_PC16550DRV    *self;
-       C_CHRFILE               *pChrFile;
+       C_CHRFILE               *pFile;
        
        /* upper cast */
-       self     = (C_PC16550DRV *)pDrvObj;
-       pChrFile = (C_CHRFILE *)pFileObj;
+       self  = (C_PC16550DRV *)pDrvObj;
+       pFile = (C_CHRFILE *)pFileObj;
 
        return FILE_ERR_NG;
 }
index ff02b33..b153d39 100755 (executable)
 HANDLE Pc16550Drv_Open(C_DRVOBJ *pDrvObj, const char *pszPath, int iMode)
 {
        C_PC16550DRV    *self;
-       C_CHRFILE               *pChrFile;
+       C_CHRFILE               *pFile;
        
        /* upper cast */
        self = (C_PC16550DRV *)pDrvObj;
 
        /* create file descriptor */
-       if ( (pChrFile = SysMem_Alloc(sizeof(*pChrFile))) == NULL )
+       if ( (pFile = SysMem_Alloc(sizeof(*pFile))) == NULL )
        {
                return HANDLE_NULL;
        }
-       ChrFile_Create(pChrFile, pDrvObj, NULL);
+       ChrFile_Create(pFile, pDrvObj, NULL);
 
        
        /* オープン処理 */
@@ -38,7 +38,7 @@ HANDLE Pc16550Drv_Open(C_DRVOBJ *pDrvObj, const char *pszPath, int iMode)
                SysInt_Enable(self->iIntNum);
        }
 
-       return (HANDLE)pChrFile;
+       return (HANDLE)pFile;
 }
 
 
index 74c1d5d..8333c1f 100755 (executable)
 FILE_SIZE Pc16550Drv_Read(C_DRVOBJ *pDrvObj, C_FILEOBJ *pFileObj, void *pBuf, FILE_SIZE Size)
 {
        C_PC16550DRV    *self;
-       C_CHRFILE               *pChrFile;
+       C_CHRFILE               *pFile;
        unsigned char   *pubBuf;
        FILE_SIZE               i;
        int                             c;
        
        /* upper cast */
-       self     = (C_PC16550DRV *)pDrvObj;
-       pChrFile = (C_CHRFILE *)pFileObj;
+       self  = (C_PC16550DRV *)pDrvObj;
+       pFile = (C_CHRFILE *)pFileObj;
 
        pubBuf = (unsigned char *)pBuf;
 
@@ -34,7 +34,7 @@ FILE_SIZE Pc16550Drv_Read(C_DRVOBJ *pDrvObj, C_FILEOBJ *pFileObj, void *pBuf, FI
        {
                while ( (c = StreamBuf_RecvChar(&self->StmBufRecv)) < 0 )
                {
-                       if ( pChrFile->cReadMode == FILE_RMODE_BLOCKING )
+                       if ( pFile->cReadMode == FILE_RMODE_BLOCKING )
                        {
                                /* ブロッキングなら受信イベントを待つ */
                                SysEvt_Wait(self->hEvtRecv);
index c392983..3d9b6ab 100755 (executable)
 FILE_POS Pc16550Drv_Seek(C_DRVOBJ *pDrvObj, C_FILEOBJ *pFileObj, FILE_POS Offset, int iOrign)
 {
        C_PC16550DRV    *self;
-       C_CHRFILE               *pChrFile;
+       C_CHRFILE               *pFile;
        
        /* upper cast */
-       self     = (C_PC16550DRV *)pDrvObj;
-       pChrFile = (C_CHRFILE *)pFileObj;
+       self  = (C_PC16550DRV *)pDrvObj;
+       pFile = (C_CHRFILE *)pFileObj;
 
        return FILE_ERR_NG;
 }
index 7303683..495cef3 100755 (executable)
 FILE_SIZE Pc16550Drv_Write(C_DRVOBJ *pDrvObj, C_FILEOBJ *pFileObj, const void *pData, FILE_SIZE Size)
 {
        C_PC16550DRV            *self;
-       C_CHRFILE                       *pChrFile;
+       C_CHRFILE                       *pFile;
        const unsigned char     *pubBuf;
        FILE_SIZE                       i;
        int                                     c;
        
        /* upper cast */
-       self     = (C_PC16550DRV *)pDrvObj;
-       pChrFile = (C_CHRFILE *)pFileObj;
+       self  = (C_PC16550DRV *)pDrvObj;
+       pFile = (C_CHRFILE *)pFileObj;
 
        pubBuf = (const unsigned char *)pData;
 
@@ -35,7 +35,7 @@ FILE_SIZE Pc16550Drv_Write(C_DRVOBJ *pDrvObj, C_FILEOBJ *pFileObj, const void *p
                c = *pubBuf++;
                while ( Pc16550Hal_SendChar(&self->Pc16550Hal, c) < 0 )
                {
-                       if ( pChrFile->cWriteMode == FILE_WMODE_BLOCKING )
+                       if ( pFile->cWriteMode == FILE_WMODE_BLOCKING )
                        {
                                /* ブロッキングなら送信割り込みを待つ */
                                Pc16550Hal_EnableInterrupt(&self->Pc16550Hal, PC16550HAL_IER_ERBFI | PC16550HAL_IER_ETBEI);
index d56e517..fbff6df 100755 (executable)
@@ -16,7 +16,7 @@
 #include "system/sysapi/sysapi.h"
 #include "system/file/chrdrv.h"
 #include "scihal.h"
-#include "library/container/stmbuf/stmbuf.h"
+#include "library/container/streambuf/streambuf.h"
 
 
 /* SCI用ドライバ制御部 */
index d603887..c4112e7 100755 (executable)
 FILE_ERR SciDrv_Flush(C_DRVOBJ *pDrvObj, C_FILEOBJ *pFileObj)
 {
        C_SCIDRV        *self;
-       C_CHRFILE               *pChrFile;
+       C_CHRFILE       *pFile;
        
        /* upper cast */
-       self     = (C_SCIDRV *)pDrvObj;
-       pChrFile = (C_CHRFILE *)pFileObj;
+       self  = (C_SCIDRV *)pDrvObj;
+       pFile = (C_CHRFILE *)pFileObj;
 
        return FILE_ERR_OK;
 }
index a5f3085..fd50599 100755 (executable)
 FILE_ERR  SciDrv_IoControl(C_DRVOBJ *pDrvObj, C_FILEOBJ *pFileObj, int iFunc, void *pInBuf, FILE_SIZE InSize, const void *pOutBuf, FILE_SIZE OutSize)
 {
        C_SCIDRV        *self;
-       C_CHRFILE               *pChrFile;
+       C_CHRFILE       *pFile;
        
        /* upper cast */
-       self     = (C_SCIDRV *)pDrvObj;
-       pChrFile = (C_CHRFILE *)pFileObj;
+       self  = (C_SCIDRV *)pDrvObj;
+       pFile = (C_CHRFILE *)pFileObj;
 
        return FILE_ERR_NG;
 }
index b3a53cb..d455a11 100755 (executable)
 HANDLE SciDrv_Open(C_DRVOBJ *pDrvObj, const char *pszPath, int iMode)
 {
        C_SCIDRV        *self;
-       C_CHRFILE               *pChrFile;
+       C_CHRFILE       *pFile;
        
        /* upper cast */
        self = (C_SCIDRV *)pDrvObj;
 
        /* create file descriptor */
-       if ( (pChrFile = SysMem_Alloc(sizeof(*pChrFile))) == NULL )
+       if ( (pFile = SysMem_Alloc(sizeof(*pFile))) == NULL )
        {
                return HANDLE_NULL;
        }
-       ChrFile_Create(pChrFile, pDrvObj, NULL);
+       ChrFile_Create(pFile, pDrvObj, NULL);
        
        /* オープン処理 */
        if ( self->iOpenCount++ == 0 )
@@ -36,7 +36,7 @@ HANDLE SciDrv_Open(C_DRVOBJ *pDrvObj, const char *pszPath, int iMode)
                SciHal_EnableInterrupt(&self->SciHal, SCIHAL_INT_RIE);
        }
 
-       return (HANDLE)pChrFile;
+       return (HANDLE)pFile;
 }
 
 
index b83e4a3..2ed7888 100755 (executable)
 /** %jp{受信} */
 FILE_SIZE SciDrv_Read(C_DRVOBJ *pDrvObj, C_FILEOBJ *pFileObj, void *pBuf, FILE_SIZE Size)
 {
-       C_SCIDRV        *self;
-       C_CHRFILE               *pChrFile;
+       C_SCIDRV                *self;
+       C_CHRFILE               *pFile;
        unsigned char   *pubBuf;
        FILE_SIZE               i;
        int                             c;
        
        /* upper cast */
-       self     = (C_SCIDRV *)pDrvObj;
-       pChrFile = (C_CHRFILE *)pFileObj;
+       self  = (C_SCIDRV *)pDrvObj;
+       pFile = (C_CHRFILE *)pFileObj;
 
        pubBuf = (unsigned char *)pBuf;
 
@@ -34,7 +34,7 @@ FILE_SIZE SciDrv_Read(C_DRVOBJ *pDrvObj, C_FILEOBJ *pFileObj, void *pBuf, FILE_S
        {
                while ( (c = StreamBuf_RecvChar(&self->StmBufRecv)) < 0 )
                {
-                       if ( pChrFile->cReadMode == FILE_RMODE_BLOCKING )
+                       if ( pFile->cReadMode == FILE_RMODE_BLOCKING )
                        {
                                /* ブロッキングなら受信イベントを待つ */
                                SysEvt_Wait(self->hEvtRecv);
index 0e73e7b..9b423a7 100755 (executable)
 FILE_POS SciDrv_Seek(C_DRVOBJ *pDrvObj, C_FILEOBJ *pFileObj, FILE_POS Offset, int iOrign)
 {
        C_SCIDRV        *self;
-       C_CHRFILE               *pChrFile;
+       C_CHRFILE       *pFile;
        
        /* upper cast */
-       self     = (C_SCIDRV *)pDrvObj;
-       pChrFile = (C_CHRFILE *)pFileObj;
+       self  = (C_SCIDRV *)pDrvObj;
+       pFile = (C_CHRFILE *)pFileObj;
 
        return FILE_ERR_NG;
 }
index 031f724..23b0f7d 100755 (executable)
 /** %jp{送信} */
 FILE_SIZE SciDrv_Write(C_DRVOBJ *pDrvObj, C_FILEOBJ *pFileObj, const void *pData, FILE_SIZE Size)
 {
-       C_SCIDRV                *self;
-       C_CHRFILE                       *pChrFile;
+       C_SCIDRV                        *self;
+       C_CHRFILE                       *pFile;
        const unsigned char     *pubBuf;
        FILE_SIZE                       i;
        int                                     c;
        
        /* upper cast */
-       self     = (C_SCIDRV *)pDrvObj;
-       pChrFile = (C_CHRFILE *)pFileObj;
+       self  = (C_SCIDRV *)pDrvObj;
+       pFile = (C_CHRFILE *)pFileObj;
 
        pubBuf = (const unsigned char *)pData;
 
@@ -35,7 +35,7 @@ FILE_SIZE SciDrv_Write(C_DRVOBJ *pDrvObj, C_FILEOBJ *pFileObj, const void *pData
                c = *pubBuf++;
                while ( SciHal_SendChar(&self->SciHal, c) < 0 )
                {
-                       if ( pChrFile->cWriteMode == FILE_WMODE_BLOCKING )
+                       if ( pFile->cWriteMode == FILE_WMODE_BLOCKING )
                        {
                                /* ブロッキングなら送信割り込みを待つ */
                                SciHal_EnableInterrupt(&self->SciHal, SCIHAL_INT_TIE | SCIHAL_INT_RIE);
diff --git a/aplfw/driver/tcpip/tcpip/tcpip_clese.c b/aplfw/driver/tcpip/tcpip/tcpip_clese.c
new file mode 100755 (executable)
index 0000000..d6f8d2d
--- /dev/null
@@ -0,0 +1,24 @@
+/** 
+ *  Hyper Operating System  Application Framework
+ *
+ * @file  tcpip.h
+ * @brief %jp{TCP/IP プロトコル}
+ *
+ * Copyright (C) 2006-2007 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+
+#include "tcpip_local.h"
+
+
+void TcpIp_Close(C_DRVOBJ *pDrvObj, C_FILEOBJ *pFileObj)
+{
+       C_TCPIP         *self;
+       
+       /* upper cast */
+       self = (C_TCPIP *)pDrvObj;
+}
+
+
+/* endof file */
diff --git a/aplfw/driver/tcpip/tcpip/tcpip_delete.c b/aplfw/driver/tcpip/tcpip/tcpip_delete.c
new file mode 100755 (executable)
index 0000000..ada9a52
--- /dev/null
@@ -0,0 +1,31 @@
+/** 
+ *  Hyper Operating System  Application Framework
+ *
+ * @file  tcpip.h
+ * @brief %jp{TCP/IP プロトコル}
+ *
+ * Copyright (C) 2006-2007 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+
+#include "tcpip_local.h"
+
+
+void TcpIp_Delete(C_DRVOBJ *pDrvObj)
+{
+       C_TCPIP *self;
+       
+       /* upper cast */
+       self = (C_TCPIP *)pDrvObj;
+
+       SysMtx_Delete(self->hMtxLock);
+       SysMtx_Delete(self->hMtxSend);
+
+
+       /* 親クラスデストラクタ呼び出し */
+       ChrDrv_Delete(&self->ChrDrv);
+}
+
+
+/* endof file */
diff --git a/aplfw/driver/tcpip/tcpip/tcpip_flush.c b/aplfw/driver/tcpip/tcpip/tcpip_flush.c
new file mode 100755 (executable)
index 0000000..048695d
--- /dev/null
@@ -0,0 +1,22 @@
+/** 
+ *  Hyper Operating System  Application Framework
+ *
+ * @file  tcpip.h
+ * @brief %jp{TCP/IP プロトコル}
+ *
+ * Copyright (C) 2006-2007 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+
+#include "tcpip_local.h"
+
+
+FILE_ERR TcpIp_Flush(C_DRVOBJ *pDrvObj, C_FILEOBJ *pFileObj)
+{
+       return FILE_ERR_NG;
+}
+
+
+
+/* endof file */
diff --git a/aplfw/driver/tcpip/tcpip/tcpip_iocontrol.c b/aplfw/driver/tcpip/tcpip/tcpip_iocontrol.c
new file mode 100755 (executable)
index 0000000..67bfc67
--- /dev/null
@@ -0,0 +1,26 @@
+/** 
+ *  Hyper Operating System  Application Framework
+ *
+ * @file  tcpip.h
+ * @brief %jp{TCP/IP プロトコル}
+ *
+ * Copyright (C) 2006-2007 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+
+#include "tcpip_local.h"
+
+
+FILE_ERR TcpIp_IoControl(C_DRVOBJ *pDrvObj, C_FILEOBJ *pFileObj, int iFunc, void *pInBuf, FILE_SIZE InSize, const void *pOutBuf, FILE_SIZE OutSize)
+{
+       C_TCPIP *self;
+       
+       /* upper cast */
+       self = (C_TCPIP *)pDrvObj;
+       
+       return FILE_ERR_NG;
+}
+
+
+/* endof file */
index b4d23de..b6ba232 100755 (executable)
@@ -15,7 +15,7 @@
 
 #include "tcpip.h"
 #include "system/file/chrfile.h"
-#include "library/container/stmbuf/stmbuf.h"
+#include "library/container/streambuf/streambuf.h"
 
 
 #define TCP_FLAG_FIN                   0x01
diff --git a/aplfw/driver/tcpip/tcpip/tcpip_open.c b/aplfw/driver/tcpip/tcpip/tcpip_open.c
new file mode 100755 (executable)
index 0000000..f9eac81
--- /dev/null
@@ -0,0 +1,66 @@
+/** 
+ *  Hyper Operating System  Application Framework
+ *
+ * @file  ipether.h
+ * @brief %jp{Ether上にIPプロトコルを実装(つまりMAC層近辺)}
+ *
+ * Copyright (C) 2006-2007 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+
+#include <stdlib.h>
+#include <string.h>
+#include "tcpip_local.h"
+
+
+HANDLE TcpIp_Open(C_DRVOBJ *pDrvObj, const char *pszPath, int iMode)
+{
+       C_TCPIP         *self;
+       C_TCPIPFILE     *pFile;
+       
+       /* upper cast */
+       self = (C_TCPIP *)pDrvObj;
+
+       /* create file descriptor */
+       if ( (pFile = SysMem_Alloc(sizeof(C_TCPIPFILE))) == NULL )
+       {
+               return HANDLE_NULL;
+       }
+       ChrFile_Create(&pFile->ChrFile, pDrvObj, NULL);
+       StreamBuf_Create(&pFile->RecvBuf, TCPIPFILE_RECV_BUFSIZE, pFile->ubRecvBuf);
+       pFile->hEvtRecv = SysEvt_Create();
+       
+       /* デバイスオープン処理 */
+       if ( self->iOpenCount++ == 0 )
+       {
+       }
+       
+       /* オープン処理 */
+       if ( strncmp(pszPath, "udp:", 4) == 0 )
+       {
+               /* UDPポートオープン */
+               pFile->iType     = TCPIPFILE_TYPE_UDP;
+               pFile->uhPortNum = (unsigned short)atoi(&pszPath[4]);
+               
+               /* リストに登録 */
+               if ( self->pUdpHead == NULL )
+               {
+                       pFile->pNext   = pFile;
+                       pFile->pPrev   = pFile;
+                       self->pUdpHead = pFile;
+               }
+               else
+               {
+                       pFile->pNext = self->pUdpHead;
+                       pFile->pPrev = pFile->pPrev;
+                       pFile->pNext->pPrev = pFile;
+                       pFile->pPrev->pNext = pFile;                    
+               }
+       }
+       
+       return (HANDLE)pFile;
+}
+
+
+/* end of file */
diff --git a/aplfw/driver/tcpip/tcpip/tcpip_read.c b/aplfw/driver/tcpip/tcpip/tcpip_read.c
new file mode 100755 (executable)
index 0000000..e8be2ef
--- /dev/null
@@ -0,0 +1,46 @@
+/** 
+ *  Hyper Operating System  Application Framework
+ *
+ * @file  tcpip.h
+ * @brief %jp{TCP/IP プロトコル}
+ *
+ * Copyright (C) 2006-2007 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+
+#include "tcpip_local.h"
+
+
+/* IPパケット受信 */
+FILE_SIZE TcpIp_Read(C_DRVOBJ *pDrvObj, C_FILEOBJ *pFileObj, void *pBuf, FILE_SIZE Size)
+{
+       C_TCPIP         *self;
+       C_TCPIPFILE     *pFile;
+       int                     iRecvSize;
+       
+       /* upper cast */
+       self  = (C_TCPIP *)pDrvObj;
+       pFile = (C_TCPIPFILE *)pFileObj;
+       
+       
+       if ( pFile->iType == TCPIPFILE_TYPE_UDP )
+       {
+               unsigned short uhUdpSize;
+               
+               while ( StreamBuf_RefDataSize(&pFile->RecvBuf) < sizeof(uhUdpSize) + sizeof(T_TCPIP_ADDRESS) )
+               {
+                       SysEvt_Wait(pFile->hEvtRecv);
+               }
+               
+               StreamBuf_RecvData(&pFile->RecvBuf, &uhUdpSize, sizeof(uhUdpSize));
+               StreamBuf_RecvData(&pFile->RecvBuf, pBuf, sizeof(T_TCPIP_ADDRESS) + (uhUdpSize - 8));
+               
+               iRecvSize = sizeof(T_TCPIP_ADDRESS) + (uhUdpSize - 8);
+       }
+       
+       return iRecvSize;
+}
+
+
+/* endof file */
diff --git a/aplfw/driver/tcpip/tcpip/tcpip_seek.c b/aplfw/driver/tcpip/tcpip/tcpip_seek.c
new file mode 100755 (executable)
index 0000000..6583ee5
--- /dev/null
@@ -0,0 +1,22 @@
+/** 
+ *  Hyper Operating System  Application Framework
+ *
+ * @file  tcpip.h
+ * @brief %jp{TCP/IP プロトコル}
+ *
+ * Copyright (C) 2006-2007 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+
+#include "tcpip_local.h"
+
+
+FILE_POS TcpIp_Seek(C_DRVOBJ *pDrvObj, C_FILEOBJ *pFileObj, FILE_POS Offset, int iOrign)
+{
+       return (-1);
+}
+
+
+
+/* endof file */
diff --git a/aplfw/driver/tcpip/tcpip/tcpip_write.c b/aplfw/driver/tcpip/tcpip/tcpip_write.c
new file mode 100755 (executable)
index 0000000..82dceaf
--- /dev/null
@@ -0,0 +1,106 @@
+/** 
+ *  Hyper Operating System  Application Framework
+ *
+ * @file  tcpip.h
+ * @brief %jp{TCP/IP プロトコル}
+ *
+ * Copyright (C) 2006-2007 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+
+#include "hosaplfw.h"
+#include "tcpip_local.h"
+#include "library/algorithm/ipchecksum/ipchecksum.h"
+
+
+FILE_SIZE TcpIp_Write(C_DRVOBJ *pDrvObj, C_FILEOBJ *pFileObj, const void *pData, FILE_SIZE Size)
+{
+       C_TCPIP                 *self;
+       C_TCPIPFILE             *pFile;
+       C_IPCHECKSUM    ics;
+       unsigned short  uhSum;
+       unsigned char   *pubSendBuf;
+       int                             iSendSize;
+       
+       /* upper cast */
+       self  = (C_TCPIP *)pDrvObj;
+       pFile = (C_TCPIPFILE *)pFileObj;
+       
+       
+       if ( pFile->iType == TCPIPFILE_TYPE_UDP )
+       {
+               const T_TCPIP_ADDRESS   *pAddr;
+               const unsigned char             *pubData;
+               
+               pAddr   = (const T_TCPIP_ADDRESS *)pData;
+               pubData = (const unsigned char *)pData + sizeof(T_TCPIP_ADDRESS);
+               
+       //      iSendSize = 
+               
+               SysMtx_Lock(self->hMtxSend);
+               
+               pubSendBuf = self->ubSendBuf;
+               
+               /******** IPヘッダ ********/
+       
+               /* バージョン4, ヘッダ長 0x14 */
+               pubSendBuf[0] = 0x45;
+               
+               /* 優先度, サービスタイプ */  
+               pubSendBuf[1] = 0x00;
+               
+               /* データ長 */
+               pubSendBuf[2] = iSendSize / 256;        
+               pubSendBuf[3] = iSendSize % 256;
+               
+               /* ID */
+               pubSendBuf[4] = self->uhPacketId / 256;
+               pubSendBuf[5] = self->uhPacketId % 256;
+               self->uhPacketId++;
+               
+               /* フラグメント */
+               pubSendBuf[6] = 0x00;
+               pubSendBuf[7] = 0x00;
+               
+               /* TTL */
+               pubSendBuf[8] = 0xff;
+               
+               /* プロトコル */
+               pubSendBuf[9] = 0x17;   /* UDP */
+               
+               /* チェックサム */
+               pubSendBuf[10] = 0;
+               pubSendBuf[11] = 0;
+               
+               /* 送信元IPアドレス */
+//             memcpy(&pubSendBuf[12],  self->ubMyIpAddr, 4);
+               
+               /* 送信先IPアドレス */
+               memcpy(&pubSendBuf[16],  &pAddr->ubAddress, 4);
+               
+               
+               /******** IPヘッダ ********/
+               
+               /* 発信元ポート番号 */
+               IP_SET_HALFWORD(&pubSendBuf[20], pFile->uhPortNum);
+               
+               /* 発信先ポート番号 */
+               IP_SET_HALFWORD(&pubSendBuf[22], pFile->uhPortNum);
+               
+               /* データ長 */
+               IP_SET_HALFWORD(&pubSendBuf[24], Size - sizeof(T_TCPIP_ADDRESS) + 8);
+               
+               /* チェックサム */
+               IP_SET_HALFWORD(&pubSendBuf[26], 0);
+               
+               /* データ */
+               memcpy(&pubSendBuf[28], pubData, Size - sizeof(T_TCPIP_ADDRESS));
+               
+       }
+       
+       return Size;
+}
+
+
+/* endof file */
index 88c1f02..1ccb30b 100755 (executable)
@@ -45,12 +45,13 @@ typedef struct c_fatvol
        FATVOL_UINT                     SectorsPerCluster;                      /**< クラスタあたりのセクタ数 */
        FATVOL_UINT                     BytesPerCluster;                        /**< クラスタサイズ */
        FATVOL_UINT                     FatStartSector;                         /**< FATの開始セクタ番号 */
+       FATVOL_UINT                     SectorNum;                                      /**< 総セクタ数 */
        FATVOL_UINT                     SectorPerFat;                           /**< FATあたりのセクタ数 */
        FATVOL_UINT                     FatNum;                                         /**< FATの個数 */
        FATVOL_UINT                     RootDirEntryNum;                        /**< ルートディレクトリのエントリ数 */
        FATVOL_UINT                     RootDirSector;                          /**< ルートディレクトリのセクタ */
        FATVOL_UINT                     Cluster0Sector;                         /**< クラスタ0のセクタ番号 */
-       FATVOL_UINT                     MaxClusterNum;                          /**< 最大クラスタ番号 */
+       FATVOL_UINT                     ClusterNum;                                     /**< 総クラスタ数 */
        FATVOL_UINT                     RootDirCluster;                         /**< ルートディレクトリのクラスタ番号 */
        
        unsigned char           *pubFatBuf;                                     /**< FATのバッファリングメモリ */
index acf9b6a..9f6a43c 100755 (executable)
@@ -17,18 +17,22 @@ void FatVol_Close(C_DRVOBJ *pDrvObj, C_FILEOBJ *pFileObj)
 {
        C_FATVOL        *self;
        C_FATFILE       *pFile;
+
+       /* フラッシュしておく */
+       FatVol_Flush(pDrvObj, pFileObj);
        
        /* upper cast */
        self  = (C_FATVOL *)pDrvObj;
        pFile = (C_FATFILE *)pFileObj;
-
+       
+       
        /* クローズ処理 */
        if ( --self->iOpenCount == 0 )
        {
        }
        
        /* ディスクリプタ削除 */
-       SysMem_Free(pFile);
+       FatVol_FileDelete(self, pFile);
 }
 
 
index 6a21c69..75bbac4 100755 (executable)
@@ -99,20 +99,22 @@ int FatVol_Create(C_FATVOL *self, const char *pszPath)
        {
        case FATVOL_TYPE_FAT12:
        case FATVOL_TYPE_FAT16:
-               self->BytesPerSector    = ubBuf[0x0b] + ubBuf[0x0c] * 256;                      /**< セクタサイズ */
-               self->SectorsPerCluster = ubBuf[0x0d];                                                          /**< 1クラスタのセクタ数 */
-               self->BytesPerCluster   = self->BytesPerSector * self->SectorsPerCluster;
-                                                                                                                                                       /**< 1クラスタサイズ */
-               self->RootDirEntryNum   = ubBuf[0x11] + ubBuf[0x12] * 256;                      /**< ルートディレクトリ最大エントリ数 */
-               self->FatStartSector    = ubBuf[0x0e] + ubBuf[0x0f] * 256;                      /**< FATの開始セクタ番号 */
-               self->SectorPerFat      = ubBuf[0x16] + ubBuf[0x17] * 256;                      /**< FATあたりのセクタ数 */
-               self->FatNum            = ubBuf[0x10];                                                          /**< FAT個数 */
+               self->BytesPerSector    = ubBuf[0x0b] + (ubBuf[0x0c] << 8);                                     /**< セクタサイズ */
+               self->SectorsPerCluster = ubBuf[0x0d];                                                                          /**< 1クラスタのセクタ数 */
+               self->FatStartSector    = ubBuf[0x0e] + (ubBuf[0x0f] << 8);                                     /**< FATの開始セクタ番号 */
+               self->RootDirEntryNum   = ubBuf[0x11] + (ubBuf[0x12] << 8);                                     /**< ルートディレクトリ最大エントリ数 */
+               self->SectorNum         = ubBuf[0x13] + (ubBuf[0x14] << 8);                                     /**< 総セクタ数 */
+               self->SectorPerFat      = ubBuf[0x16] + (ubBuf[0x17] << 8);                                     /**< FATあたりのセクタ数 */
+               self->FatNum            = ubBuf[0x10];                                                                          /**< FAT個数 */
                self->RootDirSector     = self->FatStartSector + (self->SectorPerFat * self->FatNum);
-                                                                                                                                                       /**< ルートディレクトリ開始位置 */
+                                                                                                                                                                       /**< ルートディレクトリ開始位置 */
+
+               self->BytesPerCluster   = self->BytesPerSector * self->SectorsPerCluster;       /**< 1クラスタサイズ */
                self->Cluster0Sector    = self->RootDirSector
                                                                                + (((self->RootDirEntryNum * 32) + self->BytesPerSector - 1) / self->BytesPerSector)
-                                                                               - (2 * self->SectorsPerCluster);        /**< クラスタ0の開始セクタ */
-               
+                                                                               - (2 * self->SectorsPerCluster);                        /**< クラスタ0の開始セクタ */
+               self->ClusterNum        = (self->SectorNum - self->Cluster0Sector) / self->SectorsPerCluster;
+                                                                                                                                                                       /**< 総クラスタ数 */
                self->RootDirCluster    = 0xf0000000;
                
                /* FATバッファ準備 */
@@ -133,30 +135,6 @@ int FatVol_Create(C_FATVOL *self, const char *pszPath)
                return FATVOL_ERR_NG;
        }
        
-       /* 最大クラスタ番号算出 */
-       switch ( self->iFatType )
-       {
-       case FATVOL_TYPE_FAT12:
-               self->MaxClusterNum = (self->SectorPerFat * self->BytesPerSector) / 3 * 2;
-               if ( self->MaxClusterNum >= 0x0ff7 )
-               {
-                       self->MaxClusterNum = 0x0ff6;
-               }
-               break;
-
-       case FATVOL_TYPE_FAT16:
-               self->MaxClusterNum = (self->SectorPerFat * self->BytesPerSector) / 2;
-               if ( self->MaxClusterNum >= 0xfff7 )
-               {
-                       self->MaxClusterNum = 0xfff6;
-               }
-               break;
-
-       case FATVOL_TYPE_FAT32:
-               self->MaxClusterNum = (self->SectorPerFat * self->BytesPerSector) / 4;
-               break;
-       }
-       
        /* クラスタバッファ取得 */
        self->iClusterBufNum   = 8;
        self->pClusterBuf = (T_FATVOL_CLUSTERBUF *)SysMem_Alloc(sizeof(T_FATVOL_CLUSTERBUF) * self->iClusterBufNum);
index beb522b..16fd419 100755 (executable)
@@ -21,6 +21,19 @@ FILE_ERR FatVol_Flush(C_DRVOBJ *pDrvObj, C_FILEOBJ *pFileObj)
        self  = (C_FATVOL *)pDrvObj;
        pFile = (C_FATFILE *)pFileObj;
 
+       /* クリティカルセクションに入る */
+       SysMtx_Lock(self->hMtx);
+       
+       /* FATの書き出し */
+       FatVol_FlushFat(self);
+       
+       /* バッファのフラッシュ */
+       FatVol_FlushClusterBuf(self);
+       
+       
+       /* クリティカルセクションを出る */
+       SysMtx_Unlock(self->hMtx);
+
        return FILE_ERR_OK;
 }
 
diff --git a/aplfw/driver/volume/fat/fatvol_flushclusterbuf.c b/aplfw/driver/volume/fat/fatvol_flushclusterbuf.c
new file mode 100755 (executable)
index 0000000..616874a
--- /dev/null
@@ -0,0 +1,31 @@
+/** 
+ *  Hyper Operating System  Application Framework
+ *
+ * @file  fatvol.c
+ * @brief %jp{FATボリューム用デバイスドライバ}
+ *
+ * Copyright (C) 2006-2007 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+
+#include <string.h>
+#include "fatvol_local.h"
+
+
+void FatVol_FlushClusterBuf(C_FATVOL *self)
+{
+       int i;
+       
+       for ( i = 0; i < self->iClusterBufNum; i++ )
+       {
+               if ( self->pClusterBuf[i].uiClusterNum != FATVOL_CLUSTER_ENDMARKER && self->pClusterBuf[i].iDirty )
+               {
+                       FatVol_ClusterWrite(self, self->pClusterBuf[i].uiClusterNum, self->pClusterBuf[i].pubBuf);
+                       self->pClusterBuf[i].iDirty = 0;
+               }
+       }
+}
+
+
+/* end of file */
index 957b067..eeb4390 100755 (executable)
@@ -37,7 +37,7 @@ void FatVol_FlushFat(C_FATVOL *self)
                        }
                }
        }
-
+       
        /* 更新フラグクリア */
        memset(self->pubFatDirty, 0, self->SectorPerFat);
 }
index 55928ab..4baca9f 100755 (executable)
@@ -44,6 +44,11 @@ int FatVol_AlloctClusterBuf(C_FATVOL *self, FATVOL_UINT uiCluster, int iRead)
 {
        int iIndex;
        
+       if ( uiCluster < 2 || uiCluster >= 0xfffffff7 )
+       {
+               return -1;
+       }
+       
        /* 既にバッファに居ないか探索 */
        for ( iIndex = 0; iIndex < self->iClusterBufNum; iIndex++ )
        {
diff --git a/aplfw/driver/volume/fat/fatvol_getfilesize.c b/aplfw/driver/volume/fat/fatvol_getfilesize.c
deleted file mode 100755 (executable)
index 335e8fd..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/** 
- *  Hyper Operating System  Application Framework
- *
- * @file  fatvol.c
- * @brief %jp{FATボリューム用デバイスドライバ}
- *
- * Copyright (C) 2006-2007 by Project HOS
- * http://sourceforge.jp/projects/hos/
- */
-
-
-
-#include <stdio.h>
-#include "fatvol_local.h"
-
-
-FILE_POS FatVol_GetFileSize(HANDLE hDir, int iDirEntry)
-{
-       unsigned char ubBuf[4];
-
-       File_Seek(hDir, 32*iDirEntry+28, FILE_SEEK_SET);
-       File_Read(hDir, ubBuf, 4);
-
-       return ubBuf[0] + (ubBuf[1] << 8) + (ubBuf[2] << 16) + (ubBuf[3] << 24);
-}
-
-
-/* end of file */
diff --git a/aplfw/driver/volume/fat/fatvol_getnewcluster.c b/aplfw/driver/volume/fat/fatvol_getnewcluster.c
new file mode 100755 (executable)
index 0000000..e7ee9b9
--- /dev/null
@@ -0,0 +1,35 @@
+/** 
+ *  Hyper Operating System  Application Framework
+ *
+ * @file  fatvol.c
+ * @brief %jp{FATボリューム用デバイスドライバ}
+ *
+ * Copyright (C) 2006-2007 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+
+#include "fatvol_local.h"
+
+
+/* 空きクラスタの獲得 */
+FATVOL_UINT  FatVol_GetNewCluster(C_FATVOL *self)
+{
+       FATVOL_UINT     uiCluster;
+       
+       /* 空きクラスタ検索 */
+       for ( uiCluster = 2; uiCluster < self->ClusterNum; uiCluster++ )
+       {
+               if ( FatVol_GetNextCluster(self, uiCluster) == FATVOL_CLUSTER_FREE )
+               {
+                       FatVol_SetNextCluster(self, uiCluster, FATVOL_CLUSTER_ENDMARKER);
+                       return uiCluster;
+               }
+       }
+       
+       /* 空き無し */
+       return FATVOL_CLUSTER_ENDMARKER;
+}
+
+
+/* end of file */
index 0a78269..628d9d0 100755 (executable)
@@ -27,6 +27,10 @@ FATVOL_UINT FatVol_GetNextCluster(C_FATVOL *self, FATVOL_UINT uiCluster)
                /* 0xf0000000 からルートディレクトリをマップ */
                if ( uiCluster >= 0xf0000000 )
                {
+                       if ( uiCluster >= 0xf000001f )
+                       {
+                               return FATVOL_CLUSTER_ENDMARKER;
+                       }
                        return uiCluster + 1;
                }
                
@@ -52,6 +56,10 @@ FATVOL_UINT FatVol_GetNextCluster(C_FATVOL *self, FATVOL_UINT uiCluster)
                /* 0xf0000000 からルートディレクトリをマップ */
                if ( uiCluster >= 0xf0000000 )
                {
+                       if ( uiCluster >= 0xf000001f )
+                       {
+                               return FATVOL_CLUSTER_ENDMARKER;
+                       }
                        return uiCluster + 1;
                }
                
@@ -68,6 +76,12 @@ FATVOL_UINT FatVol_GetNextCluster(C_FATVOL *self, FATVOL_UINT uiCluster)
                                + (self->pubFatBuf[uiCluster * 4 + 1] << 8)
                                + (self->pubFatBuf[uiCluster * 4 + 2] << 16)
                                + (self->pubFatBuf[uiCluster * 4 + 3] << 24);
+               
+               if ( uiCluster >= 0xfffffff7 )
+               {
+                       return FATVOL_CLUSTER_ENDMARKER;
+               }
+
                break;
        }
        
index dd03e20..b5a56d1 100755 (executable)
@@ -71,18 +71,21 @@ FILE_ERR    FatVol_Remove(C_VOLUMEOBJ *pVolObj, const char *pszPath);                                                                       /*
 HANDLE      FatVol_FileCreate(C_FATVOL *self, FATVOL_UINT uiStartCluster, FATVOL_UINT uiDirCluster, FATVOL_UINT uiDirEntryPos, FILE_POS FileSize, int iMode);
 void        FatVol_FileDelete(C_FATVOL *self, HANDLE hFile);
 
-FILE_POS    FatVol_GetFileSize(HANDLE hDir, int iDirEntry);
-void        FatVol_SetFileSize(HANDLE hDir, int iDirEntry, FILE_POS Size);
+void        FatVol_SyncFileSize(C_FATVOL *self, C_FATFILE *pFile);                                                                             /* サイズ同期 */
 
 int         FatVol_ClusterWrite(C_FATVOL *self, FATVOL_UINT uiCluster, const void *pBuf);                              /**< クラスタ書き込み */
 int         FatVol_ClusterRead(C_FATVOL *self, FATVOL_UINT uiCluster, void *pBuf);                                             /**< クラスタ読み込み */
 
 T_FATVOL_CLUSTERBUF *FatVol_GetClusterBuf(C_FATVOL *self, FATVOL_UINT uiCluster, int iRead);
 void                FatVol_RelClusterBuf(C_FATVOL *self, T_FATVOL_CLUSTERBUF *pClusterBuf, int iDirty);                                                        
+void                FatVol_FlushClusterBuf(C_FATVOL *self);
 
+FATVOL_UINT FatVol_GetNewCluster(C_FATVOL *self);
 FATVOL_UINT FatVol_GetNextCluster(C_FATVOL *self, FATVOL_UINT uiCluster);
 void        FatVol_SetNextCluster(C_FATVOL *self, FATVOL_UINT uiCluster, FATVOL_UINT uiNextCluster);
 
+void        FatVol_FlushFat(C_FATVOL *self);
+
 
 #ifdef __cplusplus
 }
index db205cd..73874c2 100755 (executable)
 #include "fatvol_local.h"
 
 
+/* ファイルオープン */
 HANDLE FatVol_Open(C_DRVOBJ *pDrvObj, const char *pszPath, int iMode)
 {
        C_FATVOL                        *self;
-       FATVOL_UINT                     uiCluster;
+
        HANDLE                          hFile;
-       char                            szEntryName[8+1+3+1];
-       int                             iEntryNameLen;
-       char                            szName[8+1+3+1];
+
+
+       FATVOL_UINT                     uiDirStartCluster;      
+       FATVOL_UINT                     uiDirCluster;   
+       FATVOL_UINT                     uiDirEntryPos;
+
+       char                            szName[8+3];
        int                             iNameLen;
-       unsigned char           ubAttr;
+
+       FATVOL_UINT                     uiFileCluster;
+       unsigned char           ubFileAttr;
        FILE_POS                        FileSize;
        T_FATVOL_CLUSTERBUF *pClusterBuf;
        unsigned char           *pubBuf;
-       FATVOL_UINT                     uiDirCluster;   
-       FATVOL_UINT                     uiDirEntryPos;
        int                                     iEntryHit;
-       int                             i;
+       int                             i, j;
+       
        
        /* upper cast */
        self = (C_FATVOL *)pDrvObj;
@@ -38,102 +44,140 @@ HANDLE FatVol_Open(C_DRVOBJ *pDrvObj, const char *pszPath, int iMode)
        /* クリティカルセクションに入る */
        SysMtx_Lock(self->hMtx);
        
+       
        /* ルートディレクトリを設定 */
-       uiDirCluster  = self->RootDirCluster;
-       uiDirEntryPos = 0;
-       if ( (pClusterBuf = FatVol_GetClusterBuf(self, uiDirCluster, 1)) == NULL )
-       {
-               SysMtx_Unlock(self->hMtx);
-               return HANDLE_NULL;
-       }
+       uiDirStartCluster = FATVOL_CLUSTER_ENDMARKER;
+       uiDirCluster      = FATVOL_CLUSTER_ENDMARKER;
+       uiDirEntryPos     = 0;
+       uiFileCluster     = self->RootDirCluster;
+       ubFileAttr        = 0x10;
+       FileSize          = 0;
        
        /* パス探索 */
        for ( ; ; )
        {
-               /* 名前の部分を切り出し */
-               for ( iNameLen = 0; iNameLen < sizeof(szName) && *pszPath != '\0'; pszPath++, iNameLen++ )
+               /* 区切りを読み飛ばす */
+               while ( pszPath[0] == '/' )
+               {
+                       pszPath++;
+               }
+
+               /* 名前の部分を探索 */
+               for ( i = 0; pszPath[i] != '\0'; i++ )
                {
                        /* パス区切りなら抜ける */
-                       if ( *pszPath == '/' )
+                       if ( pszPath[i] == '/' )
                        {
-                               pszPath++;
                                break;
                        }
-                       szName[iNameLen] = *pszPath;
-                       
-                       /* 大文字に変換 */
-                       if ( szName[iNameLen] >= 'a' && szName[iNameLen] <= 'z' )
+               }
+               iNameLen = i;
+
+               /* ディレクトリ自身を指す場合 */
+               if ( iNameLen == 0 )
+               {
+                       iEntryHit = 1;
+                       break;
+               }
+               
+               /* ディレクトリエントリ名を作成 */
+               for ( i = 0, j = 0; i < iNameLen && j < 8; i++, j++ )
+               {
+                       if ( pszPath[i] == '.' )
                        {
-                               szName[iNameLen] -= ('a' - 'A');
+                               break;
                        }
+                       szName[j] = pszPath[i];
+               }
+               for ( ; j < 8; j++ )
+               {
+                       szName[j] = 0x20;
+               }
+               if ( pszPath[i] != '.' && i < iNameLen )        /* ファイル名長すぎ */
+               {
+                       SysMtx_Unlock(self->hMtx);
+                       return HANDLE_NULL;
                }
-               szName[iNameLen] = '\0';
                
-                               
-               /* ディレクトリ自身を指す場合 */
-               if ( iNameLen == 0 )
+               /* 拡張子 */
+               if ( pszPath[i] == '.' )
                {
-                       /* ディレクトリを閉じる */
-                       FatVol_RelClusterBuf(self, pClusterBuf, 0);
+                       i++;
+               }
+               for ( j = 0; i < iNameLen && j < 3; i++, j++ )
+               {
+                       szName[8+j] = pszPath[i];
+               }
+               for ( ; j < 3; j++ )
+               {
+                       szName[8+j] = 0x20;
+               }
+               if ( i < iNameLen )             /* 拡張子長すぎ */
+               {
+                       SysMtx_Unlock(self->hMtx);
+                       return HANDLE_NULL;
+               }
+               
+
+               /* ポインタを進める */
+               pszPath += iNameLen;
 
-                       /* ディレクトリ指定があれば開く */
-                       if ( iMode & FILE_OPEN_DIR )
+               
+               /* 文字変換 */
+               for ( i = 0; i < 8+3; i++ )
+               {
+                       /* 大文字化 */
+                       if ( szName[i] >= 'a' && szName[i] <= 'z')
                        {
-                               if ( (hFile = FatVol_FileCreate(self, uiDirCluster, FATVOL_CLUSTER_ENDMARKER, 0, 0, iMode)) != HANDLE_NULL )
-                               {
-                                       self->iOpenCount++;
-                                       SysMtx_Unlock(self->hMtx);
-                                       return hFile;
-                               }
+                               szName[i] -= ('a' - 'A');
                        }
-                       
-                       /* エラー終了 */
-                       SysMtx_Unlock(self->hMtx);
-                       return HANDLE_NULL;                             
                }
+               if ( szName[0] == 0xe5 )
+               {
+                       szName[0] = 0x05;
+               } 
+                               
                
                
+               /* ディレクトリを開く */
+               uiDirStartCluster = uiFileCluster;
+               uiDirCluster      = uiDirStartCluster;
+               uiDirEntryPos     = 0;
+               if ( (pClusterBuf = FatVol_GetClusterBuf(self, uiDirCluster, 1)) == NULL )
+               {
+                       SysMtx_Unlock(self->hMtx);
+                       return HANDLE_NULL;
+               }
+               
                /* ディレクトリエントリを検索 */
                iEntryHit = 0;
                for ( ; ; )
                {
                        /* ディレクトリエントリ位置 */
                        pubBuf = &pClusterBuf->pubBuf[uiDirEntryPos];
-               
+                       
                        /* 0なら打ち切り */
                        if ( pubBuf[0] == 0x00 )
                        {
                                break;
                        }
                        
-                       /* 名前部分取り出し */
-                       iEntryNameLen = 0;
-                       for ( i = 0; i < 8; i++ )
-                       {
-                               if ( pubBuf[0+i] == ' ' || pubBuf[0+i] == '\0' )
-                               {
-                                       break;
-                               }
-                               szEntryName[iEntryNameLen++] = (char)pubBuf[0+i];
-                       }
-                       szEntryName[iEntryNameLen++] = '.';
-                       for ( i = 0; i < 3; i++ )
+                       /* 名前比較 */
+                       if ( memcmp(pubBuf, szName, 8+3) == 0 )
                        {
-                               if ( pubBuf[8+i] == ' ' || pubBuf[8+i] == '\0' )
+                               /* 開始クラスタ取得 */
+                               uiFileCluster = pubBuf[26] + (pubBuf[27] << 8);
+                               if ( self->iFatType == FATVOL_TYPE_FAT32 )
                                {
-                                       break;
+                                       uiFileCluster += (pubBuf[20] << 16) + (pubBuf[21] << 24);
                                }
-                               szEntryName[iEntryNameLen++] = (char)pubBuf[8+i];
-                       }
-                       szEntryName[iEntryNameLen] = '\0';
-                       if ( iEntryNameLen > 2 && szEntryName[iEntryNameLen-1] == '.' )
-                       {
-                               szEntryName[--iEntryNameLen] = '\0';
-                       }
-                       
-                       /* 名前比較 */
-                       if ( strcmp(szEntryName, szName) == 0 )
-                       {
+                               
+                               /* 属性取得 */ 
+                               ubFileAttr = pubBuf[11];
+                               
+                               /* サイズ取得 */
+                               FileSize = pubBuf[28] + (pubBuf[29] << 8) + (pubBuf[30] << 16) + (pubBuf[31] << 24);
+                               
                                iEntryHit = 1;
                                break;
                        }
@@ -154,63 +198,122 @@ HANDLE FatVol_Open(C_DRVOBJ *pDrvObj, const char *pszPath, int iMode)
                        }
                }
                
-               /* 見つからなければエラー */
-               if ( !iEntryHit )
-               {
-                       FatVol_RelClusterBuf(self, pClusterBuf, 0);
-                       SysMtx_Unlock(self->hMtx);
-                       return HANDLE_NULL;
-               }
-               
-               /* 開始クラスタ取得 */
-               uiCluster = pubBuf[26] + (pubBuf[27] << 8);
-               if ( self->iFatType == FATVOL_TYPE_FAT32 )
-               {
-                       uiCluster += (pubBuf[20] << 16) + (pubBuf[21] << 24);
-               }
-
-               /* 属性取得 */ 
-               ubAttr = pubBuf[11];
-               
-               /* サイズ取得 */
-               FileSize = pubBuf[28] + (pubBuf[29] << 8) + (pubBuf[30] << 16) + (pubBuf[31] << 24);
-
-               /* 親ディレクトリを閉じる */
+               /* ディレクトリを閉じる */
                FatVol_RelClusterBuf(self, pClusterBuf, 0);
-
                
-               /* パス部分の解析が終わっていればここで抜ける */
-               if ( *pszPath == '\0' )
+               
+               /* これ以上開くサブディレクトリがなければ抜ける */
+               if ( !(iEntryHit && (ubFileAttr & 0x10)) )
                {
                        break;
                }
-               
-               /* サブディレクトリでなければエラー */
-               if ( !(ubAttr & 0x10) )
+       }
+       
+       
+       /* パスをすべて探索できていなければNG */
+       if ( *pszPath != '\0' )
+       {
+               SysMtx_Unlock(self->hMtx);
+               return HANDLE_NULL;
+       }
+       
+       
+       /* ディレクトリに存在しない場合 */
+       if ( !iEntryHit )
+       {
+               /* 新規作成でなければエラー */
+               if ( !(iMode & FILE_OPEN_CREATE) )
                {
                        SysMtx_Unlock(self->hMtx);
-                       return HANDLE_NULL;
+                       return HANDLE_NULL;                     
                }
                
-               /* サブディレクトリを開く */
-               uiDirCluster = uiCluster;
+               
+               /* ディレクトリを開く */
+               uiDirCluster  = uiDirStartCluster;
                uiDirEntryPos = 0;
                if ( (pClusterBuf = FatVol_GetClusterBuf(self, uiDirCluster, 1)) == NULL )
                {
                        SysMtx_Unlock(self->hMtx);
                        return HANDLE_NULL;
                }
+               
+               /* 空き探索 */
+               for ( ; ; )
+               {
+                       /* ディレクトリエントリ位置 */
+                       pubBuf = &pClusterBuf->pubBuf[uiDirEntryPos];
+                       
+                       /* 空き発見 */
+                       if ( pubBuf[0] == 0xe5 || pubBuf[0] == 0x00 )
+                       {
+                               break;
+                       }
+                       
+                       /* シーク */
+                       uiDirEntryPos += 32;
+                       if ( uiDirEntryPos >= self->BytesPerCluster )   /* クラスタ越えなら */
+                       {
+                               FatVol_RelClusterBuf(self, pClusterBuf, 0);
+                               uiDirCluster = FatVol_GetNextCluster(self, uiDirCluster);
+                               if ( uiDirCluster == FATVOL_CLUSTER_ENDMARKER )
+                               {
+                                       /* FAT32以外のルートディレクトリなら拡張不能 */
+                                       if ( self->iFatType != FATVOL_TYPE_FAT32 && uiDirCluster >= 0xf0000000 )
+                                       {
+                                               SysMtx_Unlock(self->hMtx);
+                                               return HANDLE_NULL;                                             
+                                       }
+                                       if ( (uiFileCluster = FatVol_GetNewCluster(self)) == FATVOL_CLUSTER_ENDMARKER )
+                                       {
+                                               SysMtx_Unlock(self->hMtx);
+                                               return HANDLE_NULL;                                             
+                                       }
+                                       FatVol_SetNextCluster(self, uiDirCluster, uiFileCluster);
+                                       uiDirCluster = uiFileCluster;
+                               }
+                               if ( (pClusterBuf = FatVol_GetClusterBuf(self, uiDirCluster, 1)) == NULL )
+                               {
+                                       SysMtx_Unlock(self->hMtx);
+                                       return HANDLE_NULL;
+                               }
+                               uiDirEntryPos = 0;
+                       }
+               }
+               
+               /* 新規クラスタ作成 */
+               if ( (uiFileCluster = FatVol_GetNewCluster(self)) == FATVOL_CLUSTER_ENDMARKER )
+               {
+                       FatVol_RelClusterBuf(self, pClusterBuf, 0);
+                       SysMtx_Unlock(self->hMtx);
+                       return HANDLE_NULL;                     
+               }
+               FatVol_SetNextCluster(self, uiFileCluster, FATVOL_CLUSTER_ENDMARKER);
+               
+               memset(&pubBuf[0], 0, 32);                                                              /* 初期化 */
+               memcpy(&pubBuf[0], szName, 8+3);                                                /* ファイル名 */
+               pubBuf[11] = (iMode & FILE_OPEN_DIR) ? 0x10 : 0x20;             /* 属性 */
+               pubBuf[26] = ((uiFileCluster >>  0) & 0xff);                                    /* 開始クラスタ */
+               pubBuf[27] = ((uiFileCluster >>  8) & 0xff);
+               pubBuf[20] = ((uiFileCluster >> 16) & 0xff);
+               pubBuf[21] = ((uiFileCluster >> 24) & 0xff);
+               FileSize   = 0;
+               ubFileAttr = pubBuf[11];
+
+               /* ディレクトリを閉じる */
+               FatVol_RelClusterBuf(self, pClusterBuf, 1);
        }
        
        /* モードチェック */
-       if ( iMode & FILE_OPEN_DIR )
+       if ( ((ubFileAttr & 0x10) && !(iMode & FILE_OPEN_DIR))
+               || (!(ubFileAttr & 0x10) && (iMode & FILE_OPEN_DIR)) )
        {
                SysMtx_Unlock(self->hMtx);
                return HANDLE_NULL;             
        }
        
        /* ファイルディスクリプタを作成 */
-       hFile = FatVol_FileCreate(self, uiCluster, uiDirCluster, uiDirEntryPos, FileSize, iMode);
+       hFile = FatVol_FileCreate(self, uiFileCluster, uiDirCluster, uiDirEntryPos, FileSize, iMode);
        if ( hFile != HANDLE_NULL )
        {
                self->iOpenCount++;
index a6bcda6..035bca1 100755 (executable)
@@ -80,7 +80,6 @@ FILE_SIZE FatVol_Read(C_DRVOBJ *pDrvObj, C_FILEOBJ *pFileObj, void *pBuf, FILE_S
                /* バッファ取得 */
                if ( (pClusterBuf = FatVol_GetClusterBuf(self, uiCluster, 1)) == NULL )
                {
-                       SysMtx_Unlock(self->hMtx);
                        break;
                }
 
@@ -102,7 +101,7 @@ FILE_SIZE FatVol_Read(C_DRVOBJ *pDrvObj, C_FILEOBJ *pFileObj, void *pBuf, FILE_S
                SysMtx_Unlock(self->hMtx);
                SysMtx_Lock(self->hMtx);
        }
-
+       
        /* クリティカルセクションを出る */
        SysMtx_Unlock(self->hMtx);
        
index bdf7659..4db9bca 100755 (executable)
@@ -36,8 +36,8 @@ void FatVol_SetNextCluster(C_FATVOL *self, FATVOL_UINT uiCluster, FATVOL_UINT ui
                
        case FATVOL_TYPE_FAT16:
                /* FAT更新 */
-               self->pubFatBuf[uiCluster * 2 + 0] = uiNextCluster % 256;
-               self->pubFatBuf[uiCluster * 2 + 1] = uiNextCluster / 256;
+               self->pubFatBuf[uiCluster * 2 + 0] = ((uiNextCluster >> 0) & 0xff);
+               self->pubFatBuf[uiCluster * 2 + 1] = ((uiNextCluster >> 8) & 0xff);
 
                /* 更新フラグ設定 */
                self->pubFatDirty[(uiCluster * 2) / self->BytesPerSector] = 1;
@@ -45,10 +45,10 @@ void FatVol_SetNextCluster(C_FATVOL *self, FATVOL_UINT uiCluster, FATVOL_UINT ui
 
        case FATVOL_TYPE_FAT32:
                /* FAT更新 */
-               self->pubFatBuf[uiCluster * 2 + 0] = uiNextCluster % 256;
-               self->pubFatBuf[uiCluster * 2 + 1] = (uiNextCluster / 256) % 256;
-               self->pubFatBuf[uiCluster * 2 + 2] = (uiNextCluster / 256 / 256) % 256;
-               self->pubFatBuf[uiCluster * 2 + 3] = (uiNextCluster / 256 / 256 / 256) % 256;
+               self->pubFatBuf[uiCluster * 2 + 0] = ((uiNextCluster >>  0) & 0xff);
+               self->pubFatBuf[uiCluster * 2 + 1] = ((uiNextCluster >>  8) & 0xff);
+               self->pubFatBuf[uiCluster * 2 + 2] = ((uiNextCluster >> 16) & 0xff);
+               self->pubFatBuf[uiCluster * 2 + 3] = ((uiNextCluster >> 24) & 0xff);
 
                /* 更新フラグ設定 */
                self->pubFatDirty[(uiCluster * 4) / self->BytesPerSector] = 1;
diff --git a/aplfw/driver/volume/fat/fatvol_syncfilesize.c b/aplfw/driver/volume/fat/fatvol_syncfilesize.c
new file mode 100755 (executable)
index 0000000..f536385
--- /dev/null
@@ -0,0 +1,56 @@
+/** 
+ *  Hyper Operating System  Application Framework
+ *
+ * @file  fatvol.c
+ * @brief %jp{FATボリューム用デバイスドライバ}
+ *
+ * Copyright (C) 2006-2007 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+
+
+#include <stdio.h>
+#include "fatvol_local.h"
+
+
+/* サイズ同期 */
+void FatVol_SyncFileSize(C_FATVOL *self, C_FATFILE *pFile)
+{
+       T_FATVOL_CLUSTERBUF *pClusterBuf;
+       FILE_POS                        Size;
+
+       /* バッファ取得 */
+       if ( (pClusterBuf = FatVol_GetClusterBuf(self, pFile->uiDirCluster, 1)) == NULL )
+       {
+               return;
+       }
+       
+       /* サイズ取得 */
+       Size = pClusterBuf->pubBuf[pFile->uiDirEntryPos + 28]
+                               + (pClusterBuf->pubBuf[pFile->uiDirEntryPos + 29] << 8)
+                               + (pClusterBuf->pubBuf[pFile->uiDirEntryPos + 30] << 16)
+                               + (pClusterBuf->pubBuf[pFile->uiDirEntryPos + 31] << 24);
+       
+       /* サイズ拡張 */
+       if ( pFile->FileSize > Size )
+       {
+               pClusterBuf->pubBuf[pFile->uiDirEntryPos + 28] = (pFile->FileSize >>  0) & 0xff;
+               pClusterBuf->pubBuf[pFile->uiDirEntryPos + 29] = (pFile->FileSize >>  8) & 0xff;
+               pClusterBuf->pubBuf[pFile->uiDirEntryPos + 30] = (pFile->FileSize >> 16) & 0xff;
+               pClusterBuf->pubBuf[pFile->uiDirEntryPos + 31] = (pFile->FileSize >> 24) & 0xff;
+
+               /* バッファ開放 */
+               FatVol_RelClusterBuf(self, pClusterBuf, 1);
+       }
+       else
+       {
+               pFile->FileSize = Size;
+       
+               /* バッファ開放 */
+               FatVol_RelClusterBuf(self, pClusterBuf, 0);
+       }
+}
+
+
+/* end of file */
index 67d6a6a..22d9dbd 100755 (executable)
  */
 
 
-
+#include <string.h>
 #include "fatvol_local.h"
 
 
 /** %jp{書き込み} */
 FILE_SIZE FatVol_Write(C_DRVOBJ *pDrvObj, C_FILEOBJ *pFileObj, const void *pData, FILE_SIZE Size)
 {
-       C_FATVOL        *self;
-       C_FATFILE       *pFile;
+       C_FATVOL                        *self;
+       C_FATFILE                       *pFile;
+
+       FILE_SIZE                       ReqSize;
+       const unsigned char     *pubData;
+       FATVOL_UINT                     uiNextCluster;
+       FATVOL_UINT                     uiCluster;
+       FATVOL_UINT                     i;
+       int                 iResizeFlag = 0;
+
        
        /* upper cast */
        self  = (C_FATVOL *)pDrvObj;
        pFile = (C_FATFILE *)pFileObj;
+
+       /* キャスト */
+       pubData = (const unsigned char *)pData;
+
+       /* サイズ0なら即時成功 */
+       if ( Size <= 0 )
+       {
+               return 0;
+       }
+
+       /* クリティカルセクションに入る */
+       SysMtx_Lock(self->hMtx);
        
        /* モードチェック */
-       if ( !(pFile->iMode & FILE_OPEN_WRITE) )
+       if ( !(pFile->iMode & FILE_OPEN_WRITE) || (pFile->iMode & FILE_OPEN_DIR) )
        {
+               SysMtx_Unlock(self->hMtx);
                return 0;
        }
+               
+       /* 書き込み要求量保存 */
+       ReqSize = Size;
+       
+       /* ファイルポインタ位置のクラスタを検索 */
+       uiCluster = pFile->uiStartCluster;
+       for ( i = 0; pFile->FilePos >= (i + 1) * self->BytesPerCluster; i++ )
+       {
+               /* 次のクラスタを探す */
+               uiNextCluster = FatVol_GetNextCluster(self, uiCluster);
+               if ( uiNextCluster == FATVOL_CLUSTER_ENDMARKER )
+               {
+                       /* 次クラスタが無ければ作る */
+                       uiNextCluster = FatVol_GetNewCluster(self);
+                       if ( uiNextCluster == FATVOL_CLUSTER_ENDMARKER )
+                       {
+                               return 0;       /* ディスクフル */
+                       }
+                       FatVol_SetNextCluster(self, uiCluster, uiNextCluster);
+               }
+               uiCluster = uiNextCluster;
+       }
+       
        
+       /* 書き出し */
+       while ( Size > 0 )
+       {
+               FILE_POS                        WriteStart;
+               FILE_SIZE                       WriteSize;
+               T_FATVOL_CLUSTERBUF     *pClusterBuf;
+                               
+               /* 転送位置計算 */
+               WriteStart = (pFile->FilePos & (self->BytesPerCluster - 1));
+               WriteSize  = self->BytesPerCluster - WriteStart;
+               if ( WriteSize > Size )
+               {
+                       WriteSize = Size;
+               }
+
+               /* バッファ取得 */
+               if ( WriteStart == 0 && pFile->FilePos == pFile->FileSize )
+               {
+                       pClusterBuf = FatVol_GetClusterBuf(self, uiCluster, 1);         /* 完全新規の場合 */
+               }
+               else
+               {
+                       pClusterBuf = FatVol_GetClusterBuf(self, uiCluster, 0);         /* 部分更新の場合 */
+               }
+               if ( pClusterBuf == NULL )
+               {
+                       break;
+               }
+
+               /* 転送 */
+               memcpy(&pClusterBuf->pubBuf[WriteStart], pubData, WriteSize);
        
+               /* バッファ開放 */
+               FatVol_RelClusterBuf(self, pClusterBuf, 1);
+               
+               
+               /* サイズ更新 */
+               pFile->FilePos += WriteSize;
+               pubData        += WriteSize;
+               Size           -= WriteSize;
+               
+               /* ファイルサイズ更新 */
+               if ( pFile->FileSize < pFile->FilePos )
+               {
+                       pFile->FileSize = pFile->FilePos;
+                       iResizeFlag     = 1;
+               }
+               
+               /* 完了チェック */
+               if ( Size <= 0 )
+               {
+                       break;
+               }
+               
+               /* 次のクラスタを探す */
+               uiNextCluster = FatVol_GetNextCluster(self, uiCluster);
+               if ( uiNextCluster == FATVOL_CLUSTER_ENDMARKER )
+               {
+                       /* 次クラスタが無ければ作る */
+                       uiNextCluster = FatVol_GetNewCluster(self);
+                       if ( uiNextCluster == FATVOL_CLUSTER_ENDMARKER )
+                       {
+                               break;  /* ディスクフル */
+                       }
+                       FatVol_SetNextCluster(self, uiCluster, uiNextCluster);
+               }
+               uiCluster = uiNextCluster;
+               
+               /* 一旦ロックを放す */
+               SysMtx_Unlock(self->hMtx);
+               SysMtx_Lock(self->hMtx);                
+       }
        
+       /* ディレクトリテーブルのサイズ更新 */
+       if ( iResizeFlag &&     !(pFile->iMode & FILE_OPEN_DIR) )
+       {
+               FatVol_SyncFileSize(self, pFile);
+       }
+
+       /* クリティカルセクションを出る */
+       SysMtx_Unlock(self->hMtx);
        
-       return 0;
+       return ReqSize - Size;  
 }
 
 
index 0bcdd1d..aa0b825 100755 (executable)
@@ -7,6 +7,7 @@
 
 #include "system/handle/handle.h"
 #include "system/memory/memory.h"
+#include "system/time/time.h"
 #include "system/process/process.h"
 #include "system/command/command.h"
 #include "system/file/file.h"
diff --git a/aplfw/library/container/packetbuf/packetbuf.h b/aplfw/library/container/packetbuf/packetbuf.h
new file mode 100755 (executable)
index 0000000..6a9930b
--- /dev/null
@@ -0,0 +1,60 @@
+/** 
+ *  Hyper Operating System  Application Framework
+ *
+ * @file  packetbuf.h
+ * @brief %jp{パケットデータ用バッファクラス}
+ *
+ * Copyright (C) 2002-2007 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+
+#ifndef __HOS__packetbuf_h__
+#define __HOS__packetbuf_h__
+
+
+
+/* パケットバッファクラス構造体 */
+typedef struct c_packetbuf
+{
+       unsigned char                   *pubBuf;                        /**< バッファ領域の先頭アドレス */
+       unsigned int                    uiBufSize;                      /**< バッファ領域のサイズ */
+       volatile unsigned int   uiReturnPoint;          /**< バッファ折り返し位置 */
+       volatile unsigned int   uiHead;                         /**< データの先頭 */
+       volatile unsigned int   uiTail;                         /**< データの末尾 */
+} C_PACKETBUF;
+
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* 生成/削除 */
+void         PacketBuf_Create(C_PACKETBUF *self, unsigned int uiBufSize, void *pBuf);          /**< コンストラクタ */
+#define      PacketBuf_Delete(self)            do {} while(0)                                                                          /**< デストラクタ */
+
+/* パケット送信 */
+unsigned int PacketBuf_SendData(C_PACKETBUF *self, const void *pData, unsigned int uiSize);    /**< データの送信 */
+unsigned int PacketBuf_GetBuf(C_PACKETBUF *self, void **ppBuf, unsigned int uiSize);           /**< 送信用バッファの取得(省コピー) */
+void         PacketBuf_SendBuf(C_PACKETBUF *self, unsigned int uiSize);                                                /**< バッファ内のデータの送信(省コピー) */
+
+/* パケット受信 */
+unsigned int PacketBuf_RecvData(C_PACKETBUF *self, void *pBuf, unsigned int uiSize);           /**< データの受信 */
+unsigned int PacketBuf_RecvBuf(C_PACKETBUF *self, void **ppBuf);                                                       /**< 受信したデータの入ったバッファの取得(省コピー) */
+void         PacketBuf_RelBuf(C_PACKETBUF *self);                                                                                      /**< 受信用バッファの解放(省コピー) */
+
+/* 制御 */
+void         PacketBuf_Clear(C_PACKETBUF *self);                                                                                       /**< バッファのクリア */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+
+#endif /* __HOS__packetbuf_local_h__ */
+
+
+/* end of file */
diff --git a/aplfw/library/container/packetbuf/packetbuf_clear.c b/aplfw/library/container/packetbuf/packetbuf_clear.c
new file mode 100755 (executable)
index 0000000..17f6345
--- /dev/null
@@ -0,0 +1,24 @@
+/** 
+ *  Hyper Operating System  Application Framework
+ *
+ * @file  packetbuf.h
+ * @brief %jp{パケットデータ用バッファクラス}
+ *
+ * Copyright (C) 2002-2007 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+
+
+#include "packetbuf_local.h"
+
+
+/** バッファのクリア */
+void PacketBuf_Clear(C_PACKETBUF *self)
+{
+       self->uiHead =  self->uiTail;
+}
+
+
+
+/* end of file */
diff --git a/aplfw/library/container/packetbuf/packetbuf_create.c b/aplfw/library/container/packetbuf/packetbuf_create.c
new file mode 100755 (executable)
index 0000000..94f8cdf
--- /dev/null
@@ -0,0 +1,28 @@
+/** 
+ *  Hyper Operating System  Application Framework
+ *
+ * @file  packetbuf.h
+ * @brief %jp{パケットデータ用バッファクラス}
+ *
+ * Copyright (C) 2002-2007 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+
+#include "packetbuf_local.h"
+
+
+
+/** コンストラクタ */
+void PacketBuf_Create(C_PACKETBUF *self, unsigned int uiBufSize, void *pBuf)
+{
+       /* メンバ変数の初期化 */
+       self->pubBuf        = (unsigned char *)pBuf;
+       self->uiBufSize     = uiBufSize;
+       self->uiReturnPoint = uiBufSize;
+       self->uiHead        = 0;
+       self->uiTail        = 0;
+}
+
+
+/* end of file */
diff --git a/aplfw/library/container/packetbuf/packetbuf_getbuf.c b/aplfw/library/container/packetbuf/packetbuf_getbuf.c
new file mode 100755 (executable)
index 0000000..2a86980
--- /dev/null
@@ -0,0 +1,55 @@
+/** 
+ *  Hyper Operating System  Application Framework
+ *
+ * @file  packetbuf.h
+ * @brief %jp{パケットデータ用バッファクラス}
+ *
+ * Copyright (C) 2002-2007 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+
+#include "packetbuf_local.h"
+
+
+
+/** 送信用バッファの取得(省コピー) */
+unsigned int PacketBuf_GetBuf(C_PACKETBUF *self, void **ppBuf, unsigned int uiSize)
+{
+       unsigned int uiAllocSize;
+       
+       /* 割り当てサイズ計算 */
+       uiAllocSize = PACKETBUF_DATASIZE(uiSize) + sizeof(unsigned int);
+       
+       /* 割り当て可能性チェック */
+       if ( self->uiTail >= self->uiHead )
+       {
+               if ( self->uiTail > self->uiBufSize - uiAllocSize )
+               {
+                       /* 折り返し可能かチェック */
+                       if ( self->uiHead <= uiAllocSize )
+                       {
+                               return 0;       /* 割り当て不可 */
+                       }
+                       
+                       /* 折り返し */
+                       self->uiReturnPoint = self->uiTail;
+                       self->uiTail        = 0;
+               }
+       }
+       else
+       {
+               if ( self->uiHead - self->uiTail <= uiAllocSize )
+               {
+                       return 0;       /* 割り当て不可 */
+               }
+       }
+       
+       /* 割り当てたバッファを返す */
+       *ppBuf = (void *)(self->pubBuf + self->uiTail + sizeof(unsigned int));
+       
+       return uiSize;  /* 割り当てたサイズを返す */
+}
+
+
+/* end of file */
diff --git a/aplfw/library/container/packetbuf/packetbuf_local.h b/aplfw/library/container/packetbuf/packetbuf_local.h
new file mode 100755 (executable)
index 0000000..8570b80
--- /dev/null
@@ -0,0 +1,27 @@
+/** 
+ *  Hyper Operating System  Application Framework
+ *
+ * @file  packetbuf.h
+ * @brief %jp{パケットデータ用バッファクラス}
+ *
+ * Copyright (C) 2002-2007 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+
+
+#ifndef __HOS__packetbuf_local_h__
+#define __HOS__packetbuf_local_h__
+
+
+#include "packetbuf.h"
+
+
+#define PACKETBUF_DATASIZE(len)                ((len + sizeof(int) - 1) & (~sizeof(int) - 1))                          /**< データの利用メモリ範囲設定 */
+
+
+
+#endif /* __HOS__packetbuf_local_h__ */
+
+
+/* end of file */
diff --git a/aplfw/library/container/packetbuf/packetbuf_recvbuf.c b/aplfw/library/container/packetbuf/packetbuf_recvbuf.c
new file mode 100755 (executable)
index 0000000..8d3a468
--- /dev/null
@@ -0,0 +1,37 @@
+/** 
+ *  Hyper Operating System  Application Framework
+ *
+ * @file  packetbuf.h
+ * @brief %jp{パケットデータ用バッファクラス}
+ *
+ * Copyright (C) 2002-2007 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+
+
+#include "packetbuf_local.h"
+
+
+
+/** 受信したデータの入ったバッファの取得(省コピー) */
+unsigned int PacketBuf_RecvBuf(C_PACKETBUF *self, void **ppBuf)
+{
+       unsigned int uiSize;
+       
+       if ( self->uiHead == self->uiTail )
+       {
+               return 0;       /* データなし */
+       }
+
+       /* データサイズ取得 */
+       uiSize = *(unsigned int *)(self->pubBuf + self->uiHead);
+       
+       /* バッファ位置設定 */
+       *ppBuf = (void *)(self->pubBuf + self->uiHead + sizeof(unsigned int));
+
+       return uiSize;
+}
+
+
+/* end of file */
diff --git a/aplfw/library/container/packetbuf/packetbuf_recvdata.c b/aplfw/library/container/packetbuf/packetbuf_recvdata.c
new file mode 100755 (executable)
index 0000000..0b48ee2
--- /dev/null
@@ -0,0 +1,46 @@
+/** 
+ *  Hyper Operating System  Application Framework
+ *
+ * @file  packetbuf.h
+ * @brief %jp{パケットデータ用バッファクラス}
+ *
+ * Copyright (C) 2002-2007 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+
+
+#include <string.h>
+#include "packetbuf_local.h"
+
+
+
+/** データの受信 */
+unsigned int PacketBuf_RecvData(C_PACKETBUF *self, void *pBuf, unsigned int uiSize)
+{
+       void                    *pDataBuf;
+       unsigned int    uiDataSize;
+       
+       /* 受信バッファ取得 */
+       if ( (uiDataSize = PacketBuf_RecvBuf(self, &pDataBuf)) == 0)
+       {
+               return 0;
+       }
+       
+       /* サイズチェック */
+       if ( uiDataSize > uiSize)
+       {
+               return 0;
+       }
+       
+       /* バッファからデータ読み込み */
+       memcpy(pBuf, pDataBuf, uiDataSize);
+
+       /* バッファ解放 */
+       PacketBuf_RelBuf(self);
+
+       return uiDataSize;
+}
+
+
+/* end of file */
diff --git a/aplfw/library/container/packetbuf/packetbuf_relbuf.c b/aplfw/library/container/packetbuf/packetbuf_relbuf.c
new file mode 100755 (executable)
index 0000000..9018ef5
--- /dev/null
@@ -0,0 +1,36 @@
+/** 
+ *  Hyper Operating System  Application Framework
+ *
+ * @file  packetbuf.h
+ * @brief %jp{パケットデータ用バッファクラス}
+ *
+ * Copyright (C) 2002-2007 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+
+
+#include "packetbuf_local.h"
+
+
+/* 受信用バッファの解放(省コピー) */
+void PacketBuf_RelBuf(C_PACKETBUF *self)
+{
+       unsigned int uiSize;
+       unsigned int uiNextHead;
+       
+       /* データサイズ取得 */
+       uiSize = *(unsigned int *)(self->pubBuf + self->uiHead);
+       uiSize = PACKETBUF_DATASIZE(uiSize) + sizeof(unsigned int);
+       
+       /* 先頭位置更新 */
+       uiNextHead = self->uiHead + uiSize;
+       if ( self->uiTail < self->uiHead && uiNextHead >= self->uiReturnPoint )
+       {
+               uiNextHead = 0;
+       }
+       self->uiHead = uiNextHead;
+}
+
+
+/* end of file */
diff --git a/aplfw/library/container/packetbuf/packetbuf_sendbuf.c b/aplfw/library/container/packetbuf/packetbuf_sendbuf.c
new file mode 100755 (executable)
index 0000000..69aa799
--- /dev/null
@@ -0,0 +1,27 @@
+/** 
+ *  Hyper Operating System  Application Framework
+ *
+ * @file  packetbuf.h
+ * @brief %jp{パケットデータ用バッファクラス}
+ *
+ * Copyright (C) 2002-2007 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+
+#include "packetbuf_local.h"
+
+
+
+/** バッファ内のデータの送信(省コピー) */
+void PacketBuf_SendBuf(C_PACKETBUF *self, unsigned int uiSize)
+{
+       /* サイズの格納 */
+       *(unsigned int *)(self->pubBuf + self->uiTail) = uiSize;
+       
+       /* 末尾位置の更新 */
+       self->uiTail += PACKETBUF_DATASIZE(uiSize);
+}
+
+
+/* end of file */
diff --git a/aplfw/library/container/packetbuf/packetbuf_senddata.c b/aplfw/library/container/packetbuf/packetbuf_senddata.c
new file mode 100755 (executable)
index 0000000..7da8f9c
--- /dev/null
@@ -0,0 +1,39 @@
+/** 
+ *  Hyper Operating System  Application Framework
+ *
+ * @file  packetbuf.h
+ * @brief %jp{パケットデータ用バッファクラス}
+ *
+ * Copyright (C) 2002-2007 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+
+
+#include <string.h>
+#include "packetbuf_local.h"
+
+
+
+/** データの送信 */
+unsigned int PacketBuf_SendData(C_PACKETBUF *self, const void *pData, unsigned int uiSize)
+{
+       void *pBuf;
+       
+       /* 送信バッファ取得 */
+       if ( PacketBuf_GetBuf(self, &pBuf, uiSize) < uiSize )
+       {
+               return 0;
+       }
+
+       /* バッファにデータ書き込み */
+       memcpy(pBuf, pData, uiSize);
+
+       /* バッファ送信 */
+       PacketBuf_SendBuf(self, uiSize);
+
+       return uiSize;
+}
+
+
+/* end of file */
diff --git a/aplfw/library/container/stmbuf/stmbuf.c b/aplfw/library/container/stmbuf/stmbuf.c
deleted file mode 100755 (executable)
index 78a4be0..0000000
+++ /dev/null
@@ -1,270 +0,0 @@
-#include <string.h>
-#include "stmbuf.h"
-
-
-/* バッファの生成 */
-void StreamBuf_Create(
-               C_STREAMBUF *self,              /* クラスポインタ */
-               int         bufsz,              /* バッファに割り当てる領域の先頭番地 */
-               void        *buf)               /* バッファに割り当てる領域のサイズ(バイト数) */
-{
-       /* クラスメンバの初期化 */
-       self->bufsz = bufsz;
-       self->buf   = buf;
-       self->head  = 0;
-       self->tail  = 0;
-}
-
-
-/* データの送信 */
-int StreamBuf_SendData(
-               C_STREAMBUF *self,              /* クラスポインタ */
-               const void  *data,              /* 送信データ */
-               int         len)                /* 送信データサイズ */
-{
-       void *buf;                      /* バッファアドレス */
-       int  buf_len;           /* バッファサイズ */
-       int  snd_len = 0;       /* 送信サイズ */
-
-       do
-       {
-               /* 送信バッファ取得 */
-               if ( (buf_len = StreamBuf_GetBuf(self, &buf)) <= 0 )
-               {
-                       break;
-               }
-               
-               /* サイズ計算 */
-               if ( buf_len > len )
-               {
-                       buf_len = len;
-               }
-
-               /* 送信 */
-               memcpy(buf, data, buf_len);
-               StreamBuf_SendBuf(self, buf_len);
-               len     -= buf_len;
-               snd_len += buf_len;
-               data     = (void *)((char *)data + buf_len);
-       } while ( len > 0 );
-       
-       return snd_len;         /* 送信サイズを返す */
-}
-
-
-/* 送信用バッファの取得(省コピー) */
-int StreamBuf_GetBuf(
-               C_STREAMBUF *self,              /* クラスポインタ */
-               void        **p_buf)    /* 送信バッファ先頭番地の格納先 */
-{
-       int head;
-
-       *p_buf = (void *)(self->buf + self->tail);      /* 送信バッファ先頭番地の格納 */
-
-       head = self->head;
-       if ( head > self->tail )        /* データがバッファ末尾で折り返されているか */
-       {
-               return head - self->tail - 1;
-       }
-       else
-       {
-               if ( head == 0 )        /* バッファ先頭にデータがあるか */
-               {
-                       return self->bufsz - self->tail - 1;            /* 先頭にデータがあるなら1バイト開ける */
-               }
-               else
-               {
-                       return self->bufsz - self->tail;
-               }
-       }
-}
-
-
-/* バッファ内のデータの送信(省コピー) */
-void StreamBuf_SendBuf(
-               C_STREAMBUF *self,              /* クラスポインタ */
-               int         len)                /* 送信サイズ */
-{
-       int next_tail;
-
-       /* サイズチェック */
-       if ( len <= 0 )
-       {
-               return;
-       }
-
-       /* 次のポインタ位置計算 */
-       next_tail = self->tail + len;
-       if ( next_tail >= self->bufsz )
-       {
-               next_tail = 0;
-       }
-       self->tail = next_tail;
-}
-
-
-/* 1キャラクタの送信 */
-int StreamBuf_SendChar(
-               C_STREAMBUF *self,              /* クラスポインタ */
-               int         chr)                /* 送信キャラクタ */
-{
-       int next_tail;
-
-       /* 次の位置を計算 */
-       next_tail = self->tail + 1;
-       if ( next_tail >= self->bufsz )
-       {
-               next_tail = 0;
-       }
-
-       /* バッファフルチェック */
-       if ( next_tail == self->head )
-       {
-               return -1;      /* 失敗 */
-       }
-
-       /* 1キャラクタ送信 */
-       chr = (*(self->buf + self->tail) = (unsigned char)chr);
-       self->tail = next_tail;
-
-       return chr;             /* 成功 */
-}
-
-
-/* データの受信 */
-int StreamBuf_RecvData(
-               C_STREAMBUF *self,              /* クラスポインタ */
-               void        *data,              /* 受信データの格納先 */
-               int         len)                /* 受信データの格納先のサイズ */
-{
-       void *buf;                      /* バッファアドレス */
-       int  buf_len;           /* バッファサイズ */
-       int  rcv_len = 0;       /* 受信サイズ */
-
-       do
-       {
-               /* 受信バッファ取得 */
-               if ( (buf_len = StreamBuf_RecvBuf(self, &buf)) <= 0 )
-               {
-                       break;
-               }
-
-               /* 受信サイズ計算 */
-               if ( buf_len > len )
-               {
-                       buf_len = len;
-               }
-
-               /* 受信 */
-               memcpy(data, buf, buf_len);
-               StreamBuf_RelBuf(self, buf_len);
-               len     -= buf_len;
-               rcv_len += buf_len;
-               data     = (void *)((char *)data + buf_len);
-       } while ( len > 0 );
-
-       return rcv_len;
-}
-
-
-/* 受信用バッファの取得(省コピー) */
-int StreamBuf_RecvBuf(
-               C_STREAMBUF *self,              /* クラスポインタ */
-               void        **p_buf)    /* 受信バッファ先頭番地の格納先 */
-{
-       int tail;
-
-       *p_buf = (void *)(self->buf + self->head);      /* 受信バッファ先頭番地の格納 */
-
-       tail = self->tail;
-       if ( tail < self->head )        /* データがバッファ末尾で折り返されているか */
-       {
-               return self->bufsz - self->head;        /* 折り返されていたらバッファ末尾まで */
-       }
-       else
-       {
-               return tail - self->head;                       /* 折り返されていなければデータ末尾まで */
-       }
-}
-
-
-
-
-/* 受信用バッファの解放(省コピー) */
-void StreamBuf_RelBuf(
-               C_STREAMBUF *self,              /* クラスポインタ */
-               int         len)                /* 解放するデータサイズ */
-{
-       int next_head;
-
-       /* データ先頭位置更新 */
-       next_head = self->head + len;
-       if ( next_head >= self->bufsz )
-       {
-               next_head = 0;
-       }
-       self->head = next_head;
-}
-
-
-
-/* 1キャラクタの受信 */
-int StreamBuf_RecvChar(
-               C_STREAMBUF *self)              /* クラスポインタ */
-{
-       int next_head;
-       int chr;
-
-       /* バッファエンプティ−チェック */
-       if ( self->head == self->tail )
-       {
-               return -1;      /* 失敗 */
-       }
-
-       /* 1キャラクタ受信 */
-       chr = *(self->buf + self->head);
-
-       /* 次の位置を計算 */
-       next_head = self->head + 1;
-       if ( next_head >= self->bufsz )
-       {
-               next_head = 0;
-       }
-       self->head = next_head;
-
-       return chr;     /* 成功 */
-}
-
-
-/* バッファのクリア */
-void StreamBuf_ClearBuf(
-               C_STREAMBUF *self)              /* クラスポインタ */
-{
-       self->head = self->tail;
-}
-
-
-int StreamBuf_RefDataSize(C_STREAMBUF *self)
-{
-       int head;
-       int tail;
-       
-       head = self->head;
-       tail = self->tail;
-       
-       if ( head <= tail )
-       {
-               return tail - head;
-       }
-       else
-       {
-               return self->bufsz + tail - head;
-       }
-}
-
-
-int StreamBuf_RefFreeSize(C_STREAMBUF *self)
-{
-       return StreamBuf_RefMaxSize(self) - StreamBuf_RefDataSize(self);
-}
-
diff --git a/aplfw/library/container/stmbuf/stmbuf.h b/aplfw/library/container/stmbuf/stmbuf.h
deleted file mode 100755 (executable)
index 6390e3f..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-
-
-#ifndef __HOS__stmbuf_h__
-#define __HOS__stmbuf_h__
-
-
-/* ストリームバッファクラス */
-typedef struct c_streambuf
-{
-       unsigned char *buf;             /* バッファ領域の先頭アドレス */
-       int           bufsz;    /* バッファ領域のサイズ */
-       volatile int  head;             /* データの先頭 */
-       volatile int  tail;             /* データの末尾 */
-} C_STREAMBUF;
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* 生成/削除 */
-void    StreamBuf_Create(C_STREAMBUF *self, int bufsz, void *buf);                     /* バッファの生成 */
-#define StreamBuf_Delete(self) do {} while(0)                                                          /* バッファの削除 */
-
-/* データ送信 */
-int     StreamBuf_SendData(C_STREAMBUF *self, const void *data, int len);      /* データの送信 */
-int     StreamBuf_GetBuf(C_STREAMBUF *self, void **p_buf);                                     /* 送信用バッファの取得(省コピー) */
-void    StreamBuf_SendBuf(C_STREAMBUF *self, int len);                                         /* バッファ内のデータの送信(省コピー) */
-int     StreamBuf_SendChar(C_STREAMBUF *self, int chr);                                                /* 1キャラクタの送信 */
-
-/* データ受信 */
-int     StreamBuf_RecvData(C_STREAMBUF *self, void *data, int len);                    /* データの受信 */
-int     StreamBuf_RecvBuf(C_STREAMBUF *self, void **p_buf);                                    /* 受信したデータの入ったバッファの取得(省コピー) */
-void    StreamBuf_RelBuf(C_STREAMBUF *self, int len);                                          /* 受信用バッファの解放(省コピー) */
-int     StreamBuf_RecvChar(C_STREAMBUF *self);                                                         /* 1キャラクタの受信 */
-
-/* 制御 */
-void    StreamBuf_ClearBuf(C_STREAMBUF *self);                                                         /* バッファのクリア */
-#define StreamBuf_RefMaxSize(self)             ((self)->bufsz - 1)                                     /* 最大格納可能サイズ参照 */
-#define StreamBuf_RefBufAddr(self)             ((self)->buf)
-#define StreamBuf_RefBufSize(self)             ((self)->bufsz)
-int            StreamBuf_RefDataSize(C_STREAMBUF *self);
-int            StreamBuf_RefFreeSize(C_STREAMBUF *self);
-
-#ifdef __cplusplus
-}
-#endif
-
-
-
-#endif /* __HOS__stmbuf_h__ */
-
diff --git a/aplfw/library/container/streambuf/streambuf.h b/aplfw/library/container/streambuf/streambuf.h
new file mode 100755 (executable)
index 0000000..063c8e3
--- /dev/null
@@ -0,0 +1,64 @@
+/** 
+ *  Hyper Operating System  Application Framework
+ *
+ * @file  streambuf.h
+ * @brief %jp{ストリームデータ用バッファクラス}
+ *
+ * Copyright (C) 2002-2007 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+
+#ifndef __HOS__streambuf_h__
+#define __HOS__streambuf_h__
+
+
+/* ストリームバッファクラス */
+typedef struct c_streambuf
+{
+       unsigned char                   *pubBuf;        /**< バッファ領域の先頭アドレス */
+       unsigned int                    uiBufSize;      /**< バッファ領域のサイズ */
+       volatile unsigned int   uiHead;         /**< データの先頭 */
+       volatile unsigned int   uiTail;         /**< データの末尾 */
+} C_STREAMBUF;
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* 生成/削除 */
+void         StreamBuf_Create(C_STREAMBUF *self, unsigned int uiBufSize, void *pBuf);          /**< コンストラクタ */
+#define      StreamBuf_Delete(self)    do {} while(0)                                                                                  /**< デストラクタ */
+
+/* データ送信 */
+unsigned int StreamBuf_SendData(C_STREAMBUF *self, const void *pData, unsigned int uiSize);    /**< データの送信 */
+unsigned int StreamBuf_GetBuf(C_STREAMBUF *self, void **ppBuf);                                                                /**< 送信用バッファの取得(省コピー) */
+void         StreamBuf_SendBuf(C_STREAMBUF *self, unsigned int uiSize);                                                /**< バッファ内のデータの送信(省コピー) */
+int          StreamBuf_SendChar(C_STREAMBUF *self, int c);                                                                     /**< 1キャラクタの送信 */
+
+/* データ受信 */
+unsigned int StreamBuf_RecvData(C_STREAMBUF *self, void *pBuf, unsigned int uiSize);           /**< データの受信 */
+unsigned int StreamBuf_RecvBuf(C_STREAMBUF *self, void **ppBuf);                                                       /**< 受信したデータの入ったバッファの取得(省コピー) */
+void         StreamBuf_RelBuf(C_STREAMBUF *self, unsigned int uiSize);                                         /**< 受信用バッファの解放(省コピー) */
+int          StreamBuf_RecvChar(C_STREAMBUF *self);                                                                                    /**< 1キャラクタの受信 */
+
+/* 制御 */
+void         StreamBuf_Clear(C_STREAMBUF *self);                                                                                       /**< バッファのクリア */
+unsigned int StreamBuf_RefDataSize(C_STREAMBUF *self);                                                                         /**< バッファ空き容量の参照 */
+unsigned int StreamBuf_RefFreeSize(C_STREAMBUF *self);
+
+#define      StreamBuf_RefMaxSize(self)                ((self)->uiBufSize - 1)                                                 /**< 最大格納可能サイズ参照 */
+#define      StreamBuf_RefBufAddr(self)                ((void *)(self)->pubBuf)                                                /**< バッファアドレスの参照 */
+#define      StreamBuf_RefBufSize(self)                ((self)->uiBufSize)                                                             /**< バッファ内データ量の参照 */
+
+#ifdef __cplusplus
+}
+#endif
+
+
+
+#endif /* __HOS__streambuf_h__ */
+
+
+/* end of file */
diff --git a/aplfw/library/container/streambuf/streambuf_clear.c b/aplfw/library/container/streambuf/streambuf_clear.c
new file mode 100755 (executable)
index 0000000..544302d
--- /dev/null
@@ -0,0 +1,22 @@
+/** 
+ *  Hyper Operating System  Application Framework
+ *
+ * @file  streambuf.h
+ * @brief %jp{ストリームデータ用バッファクラス}
+ *
+ * Copyright (C) 2002-2007 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+
+#include "streambuf_local.h"
+
+
+/** バッファのクリア */
+void StreamBuf_Clear(C_STREAMBUF *self)
+{
+       self->uiHead = self->uiTail;
+}
+
+
+/* end of file */
diff --git a/aplfw/library/container/streambuf/streambuf_create.c b/aplfw/library/container/streambuf/streambuf_create.c
new file mode 100755 (executable)
index 0000000..69d22eb
--- /dev/null
@@ -0,0 +1,26 @@
+/** 
+ *  Hyper Operating System  Application Framework
+ *
+ * @file  streambuf.h
+ * @brief %jp{ストリームデータ用バッファクラス}
+ *
+ * Copyright (C) 2002-2007 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+
+#include "streambuf_local.h"
+
+
+/** コンストラクタ */
+void StreamBuf_Create(C_STREAMBUF *self, unsigned int uiBufSize, void *pBuf)
+{
+       /* クラスメンバの初期化 */
+       self->uiBufSize = uiBufSize;
+       self->pubBuf    = (unsigned char *)pBuf;
+       self->uiHead    = 0;
+       self->uiTail    = 0;
+}
+
+
+/* end of file */
diff --git a/aplfw/library/container/streambuf/streambuf_getbuf.c b/aplfw/library/container/streambuf/streambuf_getbuf.c
new file mode 100755 (executable)
index 0000000..bc2ffd5
--- /dev/null
@@ -0,0 +1,43 @@
+/** 
+ *  Hyper Operating System  Application Framework
+ *
+ * @file  streambuf.h
+ * @brief %jp{ストリームデータ用バッファクラス}
+ *
+ * Copyright (C) 2002-2007 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+
+#include "streambuf_local.h"
+
+
+
+/** 送信用バッファの取得(省コピー) */
+unsigned int StreamBuf_GetBuf(C_STREAMBUF *self, void **ppBuf)
+{
+       unsigned int uiHead;
+
+       *ppBuf = (void *)(self->pubBuf + self->uiTail); /* 送信バッファ先頭番地の格納 */
+
+       uiHead = self->uiHead;
+       if ( uiHead > self->uiTail )    /* データがバッファ末尾で折り返されているか */
+       {
+               return uiHead - self->uiTail - 1;
+       }
+       else
+       {
+               if ( uiHead == 0 )      /* バッファ先頭にデータがあるか */
+               {
+                       return self->uiBufSize - self->uiTail - 1;              /* 先頭にデータがあるなら1バイト開ける */
+               }
+               else
+               {
+                       return self->uiBufSize - self->uiTail;
+               }
+       }
+}
+
+
+
+/* end of file */
diff --git a/aplfw/library/container/streambuf/streambuf_local.h b/aplfw/library/container/streambuf/streambuf_local.h
new file mode 100755 (executable)
index 0000000..ab128b8
--- /dev/null
@@ -0,0 +1,22 @@
+/** 
+ *  Hyper Operating System  Application Framework
+ *
+ * @file  streambuf.h
+ * @brief %jp{ストリームデータ用バッファクラス}
+ *
+ * Copyright (C) 2002-2007 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+
+#ifndef __HOS__streambuf_local_h__
+#define __HOS__streambuf_local_h__
+
+
+#include "streambuf.h"
+
+
+#endif /* __HOS__streambuf_local_h__ */
+
+
+/* end of file */
diff --git a/aplfw/library/container/streambuf/streambuf_recvbuf.c b/aplfw/library/container/streambuf/streambuf_recvbuf.c
new file mode 100755 (executable)
index 0000000..627be4a
--- /dev/null
@@ -0,0 +1,34 @@
+/** 
+ *  Hyper Operating System  Application Framework
+ *
+ * @file  streambuf.h
+ * @brief %jp{ストリームデータ用バッファクラス}
+ *
+ * Copyright (C) 2002-2007 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+
+#include "streambuf_local.h"
+
+
+/** 受信したデータの入ったバッファの取得(省コピー) */
+unsigned int StreamBuf_RecvBuf(C_STREAMBUF *self, void **ppBuf)
+{
+       unsigned int uiTail;
+       
+       *ppBuf = (void *)(self->pubBuf + self->uiHead); /* 受信バッファ先頭番地の格納 */
+       
+       uiTail = self->uiTail;
+       if ( uiTail < self->uiHead )    /* データがバッファ末尾で折り返されているか */
+       {
+               return self->uiBufSize - self->uiHead;          /* 折り返されていたらバッファ末尾まで */
+       }
+       else
+       {
+               return uiTail - self->uiHead;                           /* 折り返されていなければデータ末尾まで */
+       }
+}
+
+
+/* end of file */
diff --git a/aplfw/library/container/streambuf/streambuf_recvchar.c b/aplfw/library/container/streambuf/streambuf_recvchar.c
new file mode 100755 (executable)
index 0000000..6c71493
--- /dev/null
@@ -0,0 +1,42 @@
+/** 
+ *  Hyper Operating System  Application Framework
+ *
+ * @file  streambuf.h
+ * @brief %jp{ストリームデータ用バッファクラス}
+ *
+ * Copyright (C) 2002-2007 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+
+#include "streambuf_local.h"
+
+
+/** 1キャラクタの受信 */
+int StreamBuf_RecvChar(C_STREAMBUF *self)
+{
+       unsigned int    uiNextHead;
+       int                             c;
+
+       /* バッファエンプティ−チェック */
+       if ( self->uiHead == self->uiTail )
+       {
+               return -1;      /* 失敗 */
+       }
+
+       /* 1キャラクタ受信 */
+       c = *(self->pubBuf + self->uiHead);
+
+       /* 次の位置を計算 */
+       uiNextHead = self->uiHead + 1;
+       if ( uiNextHead >= self->uiBufSize )
+       {
+               uiNextHead = 0;
+       }
+       self->uiHead = uiNextHead;
+
+       return c;       /* 成功 */
+}
+
+
+/* end of file */
diff --git a/aplfw/library/container/streambuf/streambuf_recvdata.c b/aplfw/library/container/streambuf/streambuf_recvdata.c
new file mode 100755 (executable)
index 0000000..9e43f39
--- /dev/null
@@ -0,0 +1,50 @@
+/** 
+ *  Hyper Operating System  Application Framework
+ *
+ * @file  streambuf.h
+ * @brief %jp{ストリームデータ用バッファクラス}
+ *
+ * Copyright (C) 2002-2007 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+
+#include <string.h>
+#include "streambuf_local.h"
+
+
+
+/** データの受信 */
+unsigned int StreamBuf_RecvData(C_STREAMBUF *self, void *pBuf, unsigned int uiSize)
+{
+       void                    *pRecvBuf;                      /* バッファアドレス */
+       unsigned int    uiBufSize;                      /* バッファサイズ */
+       unsigned int    uiRecvSize = 0; /* 受信サイズ */
+
+       do
+       {
+               /* 受信バッファ取得 */
+               if ( (uiBufSize = StreamBuf_RecvBuf(self, &pRecvBuf)) <= 0 )
+               {
+                       break;
+               }
+
+               /* 受信サイズ計算 */
+               if ( uiBufSize > uiSize )
+               {
+                       uiBufSize = uiSize;
+               }
+
+               /* 受信 */
+               memcpy(pBuf, pRecvBuf, uiBufSize);
+               StreamBuf_RelBuf(self, uiBufSize);
+               uiSize     -= uiBufSize;
+               uiRecvSize += uiBufSize;
+               pBuf        = (void *)((char *)pBuf + uiBufSize);
+       } while ( uiSize > 0 );
+
+       return uiRecvSize;
+}
+
+
+/* end of file */
diff --git a/aplfw/library/container/streambuf/streambuf_refdatasize.c b/aplfw/library/container/streambuf/streambuf_refdatasize.c
new file mode 100755 (executable)
index 0000000..593ae34
--- /dev/null
@@ -0,0 +1,37 @@
+/** 
+ *  Hyper Operating System  Application Framework
+ *
+ * @file  streambuf.h
+ * @brief %jp{ストリームデータ用バッファクラス}
+ *
+ * Copyright (C) 2002-2007 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+
+#include "streambuf_local.h"
+
+
+
+/** バッファ内データ量の参照 */
+unsigned int StreamBuf_RefDataSize(C_STREAMBUF *self)
+{
+       unsigned int uiHead;
+       unsigned int uiTail;
+       
+       uiHead = self->uiHead;
+       uiTail = self->uiTail;
+       
+       if ( uiHead <= uiTail )
+       {
+               return uiTail - uiHead;
+       }
+       else
+       {
+               return self->uiBufSize + uiTail - uiHead;
+       }
+}
+
+
+
+/* end of file */
diff --git a/aplfw/library/container/streambuf/streambuf_reffreesize.c b/aplfw/library/container/streambuf/streambuf_reffreesize.c
new file mode 100755 (executable)
index 0000000..6132e1f
--- /dev/null
@@ -0,0 +1,22 @@
+/** 
+ *  Hyper Operating System  Application Framework
+ *
+ * @file  streambuf.h
+ * @brief %jp{ストリームデータ用バッファクラス}
+ *
+ * Copyright (C) 2002-2007 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+
+#include "streambuf_local.h"
+
+
+/** バッファ空き容量の参照 */
+unsigned int StreamBuf_RefFreeSize(C_STREAMBUF *self)
+{
+       return StreamBuf_RefMaxSize(self) - StreamBuf_RefDataSize(self);
+}
+
+
+/* end of file */
diff --git a/aplfw/library/container/streambuf/streambuf_relbuf.c b/aplfw/library/container/streambuf/streambuf_relbuf.c
new file mode 100755 (executable)
index 0000000..4ba7fd8
--- /dev/null
@@ -0,0 +1,30 @@
+/** 
+ *  Hyper Operating System  Application Framework
+ *
+ * @file  streambuf.h
+ * @brief %jp{ストリームデータ用バッファクラス}
+ *
+ * Copyright (C) 2002-2007 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+
+#include "streambuf_local.h"
+
+
+/** 受信用バッファの解放(省コピー) */
+void StreamBuf_RelBuf(C_STREAMBUF *self, unsigned int uiSize)
+{
+       unsigned int uiNextHead;
+
+       /* データ先頭位置更新 */
+       uiNextHead = self->uiHead + uiSize;
+       if ( uiNextHead >= self->uiBufSize )
+       {
+               uiNextHead = 0;
+       }
+       self->uiHead = uiNextHead;
+}
+
+
+/* end of file */
diff --git a/aplfw/library/container/streambuf/streambuf_sendbuf.c b/aplfw/library/container/streambuf/streambuf_sendbuf.c
new file mode 100755 (executable)
index 0000000..f757c0c
--- /dev/null
@@ -0,0 +1,36 @@
+/** 
+ *  Hyper Operating System  Application Framework
+ *
+ * @file  streambuf.h
+ * @brief %jp{ストリームデータ用バッファクラス}
+ *
+ * Copyright (C) 2002-2007 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+
+#include "streambuf_local.h"
+
+
+/** バッファ内のデータの送信(省コピー) */
+void StreamBuf_SendBuf(C_STREAMBUF *self, unsigned int uiSize)
+{
+       unsigned int uiNextTail;
+       
+       /* サイズチェック */
+       if ( uiSize == 0 )
+       {
+               return;
+       }
+
+       /* 次のポインタ位置計算 */
+       uiNextTail = self->uiTail + uiSize;
+       if ( uiNextTail >= self->uiBufSize )
+       {
+               uiNextTail = 0;
+       }
+       self->uiTail = uiNextTail;
+}
+
+
+/* end of file */
diff --git a/aplfw/library/container/streambuf/streambuf_sendchar.c b/aplfw/library/container/streambuf/streambuf_sendchar.c
new file mode 100755 (executable)
index 0000000..142d9a1
--- /dev/null
@@ -0,0 +1,41 @@
+/** 
+ *  Hyper Operating System  Application Framework
+ *
+ * @file  streambuf.h
+ * @brief %jp{ストリームデータ用バッファクラス}
+ *
+ * Copyright (C) 2002-2007 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+
+#include "streambuf_local.h"
+
+
+/* 1キャラクタの送信 */
+int StreamBuf_SendChar(C_STREAMBUF *self, int c)
+{
+       unsigned int uiNextTail;
+
+       /* 次の位置を計算 */
+       uiNextTail = self->uiTail + 1;
+       if ( uiNextTail >= self->uiBufSize )
+       {
+               uiNextTail = 0;
+       }
+
+       /* バッファフルチェック */
+       if ( uiNextTail == self->uiHead )
+       {
+               return -1;      /* 失敗 */
+       }
+       
+       /* 1キャラクタ送信 */
+       c = (*(self->pubBuf + self->uiTail) = (unsigned char)c);
+       self->uiTail = uiNextTail;
+
+       return c;               /* 成功 */
+}
+
+
+/* end of file */
diff --git a/aplfw/library/container/streambuf/streambuf_senddata.c b/aplfw/library/container/streambuf/streambuf_senddata.c
new file mode 100755 (executable)
index 0000000..d98d7e4
--- /dev/null
@@ -0,0 +1,54 @@
+/** 
+ *  Hyper Operating System  Application Framework
+ *
+ * @file  streambuf.h
+ * @brief %jp{ストリームデータ用バッファクラス}
+ *
+ * Copyright (C) 2002-2007 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+
+#include <string.h>
+#include "streambuf_local.h"
+
+
+/** データの送信 */
+unsigned int StreamBuf_SendData(C_STREAMBUF *self, const void *pData, unsigned int uiSize)
+{
+       void                    *pBuf;                          /* バッファアドレス */
+       unsigned int    uiBufSize;                      /* バッファサイズ */
+       unsigned int    uiSendSize = 0;         /* 送信サイズ */
+
+       do
+       {
+               /* 送信バッファ取得 */
+               if ( (uiBufSize = StreamBuf_GetBuf(self, &pBuf)) <= 0 )
+               {
+                       break;
+               }
+               
+               /* サイズ計算 */
+               if ( uiBufSize > uiSize )
+               {
+                       uiBufSize = uiSize;
+               }
+               
+               /* データコピー */
+               memcpy(pBuf, pData, uiBufSize);
+               
+               /* 送信 */
+               StreamBuf_SendBuf(self, uiBufSize);
+               
+               /* ポインタ更新 */
+               pData       = (void *)((char *)pData + uiBufSize);
+               uiSize     -= uiBufSize;
+               uiSendSize += uiBufSize;
+       } while ( uiSize > 0 );
+       
+       
+       return uiSendSize;              /* 送信サイズを返す */
+}
+
+
+/* end of file */
index 3cea098..44f50f8 100755 (executable)
@@ -117,9 +117,11 @@ void Boot_Task(VP_INT exinf)
        hCon = File_Open("/dev/con0", FILE_OPEN_READ | FILE_OPEN_WRITE);
        
        
+       
        /*************************/
        /*     コマンド登録      */
        /*************************/
+       
        Command_AddCommand("hsh",      Shell_Main);
        Command_AddCommand("hello",    Hello_Main);
        Command_AddCommand("memdump",  MemDump_Main);
@@ -129,9 +131,12 @@ void Boot_Task(VP_INT exinf)
        Command_AddCommand("time",     TimeCmd_Main);
        Command_AddCommand("ethsnoop", EtherSnoop_Main);
        
+       
+       
        /*************************/
        /*  システムプロセス起動 */
        /*************************/
+       
        System_Boot(hTty, hCon, "hsh", 4096);
 }
 
index 733b8c2..5a22377 100755 (executable)
 extern "C" {
 #endif
 
+#define StdIo_Read(buf, len)   File_Read(Process_GetStdIn(), (buf), (len));
 #define StdIo_GetChar()                        File_GetChar(Process_GetStdIn());
 #define StdIo_GetString(str)   File_GetString(Process_GetStdIn(), (str));
 
+#define StdIo_Write(buf, len)  File_Write(Process_GetStdIn(), (buf), (len));
 #define StdIo_PutChar(c)               File_PutChar(Process_GetStdOut(), (c));
 #define StdIo_PutString(str)   File_PutString(Process_GetStdOut(), (str));
 int     StdIo_PrintFormat(const char *pszFormat, ...);
index 64e2eac..b5d58dd 100755 (executable)
@@ -55,7 +55,7 @@ HANDLE SysVol_Open(C_DRVOBJ *pDrvObj, const char *pszPath, int iMode)
                for ( iLen =0; pszPath[iLen] != '\0' && pszPath[iLen] != '/'; iLen++ )
                        ;
                
-               if ( strncmp(pszPath, self->DevTable[i].szName, iLen) == 0 )
+               if ( strncmp(pszPath, self->DevTable[i].szName, iLen) == 0 && self->DevTable[i].szName[iLen] == '\0' )
                {
                        break;
                }
index 54d4676..f10ea05 100755 (executable)
@@ -2,7 +2,7 @@
  *  Hyper Operating System  Application Framework
  *
  * @file  system.h
- * @brief %jp{ã\82·ã\82¹ã\83\86ã\83 ç\94¨APIå®\9a義}
+ * @brief %jp{ã\83»ã\82­ã\83»ã\82±ã\83»ã\83\8bã\83»ç\8c©ã\83 APIã\83\88ã\83\81}
  *
  * Copyright (C) 2006 by Project HOS
  * http://sourceforge.jp/projects/hos/
@@ -12,7 +12,7 @@
 #include "sysapi_local.h"
 
 
-/* ã\82·ã\82¹ã\83\86ã\83 æ\99\82å\88»å\8f\96å¾\97 */
+/* ã\83»ã\82­ã\83»ã\82±ã\83»ã\83\8bã\83»ç\8b\83è¾¼æ\83\85*/
 TIME SysTim_GetSystemTime(void)
 {
        SYSTIM tim;
index f32b290..e7a3d2b 100755 (executable)
@@ -2,7 +2,7 @@
  *  Hyper Operating System  Application Framework
  *
  * @file  time.h
- * @brief %jp{時刻管理API定義}
+ * @brief %jp{サ込理APIトチ}
  *
  * Copyright (C) 2006-2007 by Project HOS
  * http://sourceforge.jp/projects/hos/
@@ -13,7 +13,7 @@
 #define __HOS__time_h__
 
 
-/* ã\82·ã\82¹ã\83\86ã\83 æ\99\82å\88»å\9e\8b */
+/* ã\83»ã\82­ã\83»ã\82±ã\83»ã\83\8bã\83»ç\8b\83è¾¼*/
 typedef long           TIME_SYSTEM;
 
 #ifdef __cplusplus
index b888a81..109c3f2 100755 (executable)
@@ -2,7 +2,7 @@
  *  Hyper Operating System  Application Framework
  *
  * @file  time.h
- * @brief %jp{時刻管理API定義}
+ * @brief %jp{サ込理APIトチ}
  *
  * Copyright (C) 2006-2007 by Project HOS
  * http://sourceforge.jp/projects/hos/
@@ -13,7 +13,7 @@
 #include "system/sysapi/sysapi.h"
 
 
-/* ã\82·ã\82¹ã\83\86ã\83 æ\99\82å\88»(èµ·å\8b\95ã\81\8bã\82\89ã\81®ã\83\9fã\83ªç§\92\82\92å¾\97る */
+/* ã\83»ã\82­ã\83»ã\82±ã\83»ã\83\8bã\83»ç\8b\83å\88»(ã\82ªã\83\83ã\83\8bã\83¼ã\80\81ã\82©ã\80\81鬢ã\83\9bã\83»ã\82\9cã\83»ã\83\86\80\81る */
 TIME_SYSTEM Time_GetSystemTime(void)
 {
        return SysTim_GetSystemTime();
index e623909..d3da055 100755 (executable)
@@ -2,7 +2,7 @@
  *  Hyper Operating System  Application Framework
  *
  * @file  time.h
- * @brief %jp{時刻管理API定義}
+ * @brief %jp{サ込理APIトチ}
  *
  * Copyright (C) 2006-2007 by Project HOS
  * http://sourceforge.jp/projects/hos/
@@ -13,7 +13,7 @@
 #include "system/sysapi/sysapi.h"
 
 
-/* 一定時刻待つ */
+/* ー込*/
 void Time_Wait(TIME_SYSTEM Millisecond)
 {
        SysTim_Wait(Millisecond);
index 83c1eb6..ea622c4 100755 (executable)
@@ -1,21 +1,19 @@
 # Microsoft Developer Studio Project File - Name="h4acfg" - Package Owner=<4>\r
 # Microsoft Developer Studio Generated Build File, Format Version 6.00\r
-# ** \95Ò\8fW\82µ\82È\82¢\82Å\82­\82¾\82³\82¢ **\r
+# ** \95ÿÿW\82ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ**\r
 \r
 # TARGTYPE "Win32 (x86) Console Application" 0x0103\r
 \r
 CFG=h4acfg - Win32 Debug\r
-!MESSAGE \82±\82ê\82Í\97L\8cø\82ÈÒ²¸Ì§²Ù\82Å\82Í\82 \82è\82Ü\82¹\82ñ\81\82±\82ÌÌßÛ¼Þª¸Ä\82ðËÞÙÄÞ\82·\82é\82½\82ß\82É\82Í NMAKE \82ð\8eg\97p\82µ\82Ä\82­\82¾\82³\82¢\81B\r
-!MESSAGE [Ò²¸Ì§²Ù\82Ì´¸½Îß°Ä] ºÏÝÄÞ\82ð\8eg\97p\82µ\82Ä\8eÀ\8ds\82µ\82Ä\82­\82¾\82³\82¢\r
-!MESSAGE \r
+!MESSAGE \82ÿÿÿÿÿÿL\8cÿÿ\94Ð\89\96¥\89×\82ÿÿÿÿ \82ÿÿÿÿÿÿÿÿB \82ÿÿ\96Êàz\8eÜ\85¶ÿÿèÉ\9f×\92Ü\82ÿÿÿÿÿÿÿÿÿÿÿÿNMAKE \82ð\8eg\97p\82ÿÿÿÿÿÿÿÿÿÿÿÿB\r
+!MESSAGE [\99°\8cÊ\84Qÿÿ\96²\8c»\97Ý\88Â] \8dÍ\9fcÿÿð\8eg\97p\82ÿÿÄ\8eÿÿs\82ÿÿÿÿÿÿÿÿÿÿÿÿ!MESSAGE \r
 !MESSAGE NMAKE /f "h4acfg.mak".\r
 !MESSAGE \r
-!MESSAGE NMAKE \82Ì\8eÀ\8ds\8e\9e\82É\8d\\90¬\82ð\8ew\92è\82Å\82«\82Ü\82·\r
-!MESSAGE ºÏÝÄޠײÝ\8fã\82ÅϸÛ\82Ì\90Ý\92è\82ð\92è\8b`\82µ\82Ü\82·\81B\97á:\r
+!MESSAGE NMAKE \82Ì\8eÿÿs\8e\9e\82ÿÿ\\90ÿÿð\8ew\92ÿÿÿÿÿÿÿÿÿÿ!MESSAGE \8dÍ\9fcÿÿ\9cQÿÿÿÿ\93n\8cÙ\82ÿÿÿÿÿÿÿÿÿÿ`\82ÿÿÿÿÿÿB\97ÿÿ\r
 !MESSAGE \r
 !MESSAGE NMAKE /f "h4acfg.mak" CFG="h4acfg - Win32 Debug"\r
 !MESSAGE \r
-!MESSAGE \91I\91ð\89Â\94\\82ÈËÞÙÄÞ Ó°ÄÞ:\r
+!MESSAGE \91I\91ÿÿÿÿ\\82\94É\9f×\92Ü \9aO\92Ü:\r
 !MESSAGE \r
 !MESSAGE "h4acfg - Win32 Release" ("Win32 (x86) Console Application" \97p)\r
 !MESSAGE "h4acfg - Win32 Debug" ("Win32 (x86) Console Application" \97p)\r
index 8b20e73..d21714b 100755 (executable)
@@ -1,5 +1,5 @@
 Microsoft Developer Studio Workspace File, Format Version 6.00\r
-# \8cx\8d\90\82±\82ÌÜ°¸½Íß°½ Ì§²Ù \82ð\95Ò\8fW\82Ü\82½\82Í\8dí\8f\9c\82µ\82È\82¢\82Å\82­\82¾\82³\82¢!\r
+# \8cx\8d\90\82ÿÿ\96Ú\88\8flàOÿÿ\96¥\89× \82ÿÿÿÿW\82ÿÿÿÿÿÿÿÿ\9c\82ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ\r
 \r
 ###############################################################################\r
 \r
index a1f7354..f2a2f55 100755 (executable)
@@ -1,21 +1,19 @@
 # Microsoft Developer Studio Project File - Name="hosv4a" - Package Owner=<4>\r
 # Microsoft Developer Studio Generated Build File, Format Version 6.00\r
-# ** \95Ò\8fW\82µ\82È\82¢\82Å\82­\82¾\82³\82¢ **\r
+# ** \95ÿÿW\82ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ**\r
 \r
 # TARGTYPE "Win32 (x86) Static Library" 0x0104\r
 \r
 CFG=hosv4a - Win32 Debug\r
-!MESSAGE \82±\82ê\82Í\97L\8cø\82ÈÒ²¸Ì§²Ù\82Å\82Í\82 \82è\82Ü\82¹\82ñ\81\82±\82ÌÌßÛ¼Þª¸Ä\82ðËÞÙÄÞ\82·\82é\82½\82ß\82É\82Í NMAKE \82ð\8eg\97p\82µ\82Ä\82­\82¾\82³\82¢\81B\r
-!MESSAGE [Ò²¸Ì§²Ù\82Ì´¸½Îß°Ä] ºÏÝÄÞ\82ð\8eg\97p\82µ\82Ä\8eÀ\8ds\82µ\82Ä\82­\82¾\82³\82¢\r
-!MESSAGE \r
+!MESSAGE \82ÿÿÿÿÿÿL\8cÿÿ\94Ð\89\96¥\89×\82ÿÿÿÿ \82ÿÿÿÿÿÿÿÿB \82ÿÿ\96Êàz\8eÜ\85¶ÿÿèÉ\9f×\92Ü\82ÿÿÿÿÿÿÿÿÿÿÿÿNMAKE \82ð\8eg\97p\82ÿÿÿÿÿÿÿÿÿÿÿÿB\r
+!MESSAGE [\99°\8cÊ\84Qÿÿ\96²\8c»\97Ý\88Â] \8dÍ\9fcÿÿð\8eg\97p\82ÿÿÄ\8eÿÿs\82ÿÿÿÿÿÿÿÿÿÿÿÿ!MESSAGE \r
 !MESSAGE NMAKE /f "hosv4a.mak".\r
 !MESSAGE \r
-!MESSAGE NMAKE \82Ì\8eÀ\8ds\8e\9e\82É\8d\\90¬\82ð\8ew\92è\82Å\82«\82Ü\82·\r
-!MESSAGE ºÏÝÄޠײÝ\8fã\82ÅϸÛ\82Ì\90Ý\92è\82ð\92è\8b`\82µ\82Ü\82·\81B\97á:\r
+!MESSAGE NMAKE \82Ì\8eÿÿs\8e\9e\82ÿÿ\\90ÿÿð\8ew\92ÿÿÿÿÿÿÿÿÿÿ!MESSAGE \8dÍ\9fcÿÿ\9cQÿÿÿÿ\93n\8cÙ\82ÿÿÿÿÿÿÿÿÿÿ`\82ÿÿÿÿÿÿB\97ÿÿ\r
 !MESSAGE \r
 !MESSAGE NMAKE /f "hosv4a.mak" CFG="hosv4a - Win32 Debug"\r
 !MESSAGE \r
-!MESSAGE \91I\91ð\89Â\94\\82ÈËÞÙÄÞ Ó°ÄÞ:\r
+!MESSAGE \91I\91ÿÿÿÿ\\82\94É\9f×\92Ü \9aO\92Ü:\r
 !MESSAGE \r
 !MESSAGE "hosv4a - Win32 Release" ("Win32 (x86) Static Library" \97p)\r
 !MESSAGE "hosv4a - Win32 Debug" ("Win32 (x86) Static Library" \97p)\r
index 45b7d32..a7b747e 100755 (executable)
@@ -1,5 +1,5 @@
 Microsoft Developer Studio Workspace File, Format Version 6.00\r
-# \8cx\8d\90\82±\82ÌÜ°¸½Íß°½ Ì§²Ù \82ð\95Ò\8fW\82Ü\82½\82Í\8dí\8f\9c\82µ\82È\82¢\82Å\82­\82¾\82³\82¢!\r
+# \8cx\8d\90\82ÿÿ\96Ú\88\8flàOÿÿ\96¥\89× \82ÿÿÿÿW\82ÿÿÿÿÿÿÿÿ\9c\82ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ\r
 \r
 ###############################################################################\r
 \r
index 1a514d2..c2070c0 100755 (executable)
@@ -21,6 +21,17 @@ typedef struct _kernel_t_ctxcb
 } _KERNEL_T_CTXCB;
 
 
+/** %jp{割込みコンテキスト制御ブロック} */
+typedef struct _kernel_t_ictxcb
+{
+       VP      isp;
+       UB      intcnt;
+} _KERNEL_T_ICTXCB;
+
+
+extern _KERNEL_T_ICTXCB _kernel_ictxcb;                /**< %jp{割込みコンテキスト制御ブロック} */
+
+
 
 #ifdef __cplusplus
 extern "C" {
@@ -43,11 +54,12 @@ void    _kernel_swi_ctx(_KERNEL_T_CTXCB *pk_ctxinf_nxt, _KERNEL_T_CTXCB *pk_ctxc
 #endif
 
 
-#define _KERNEL_INI_PRC()      _kernel_ini_prc()                                                                                                               /**< %jp{プロセッサ固有の初期化} */
+#define _KERNEL_INI_PRC()                      _kernel_ini_prc()                                                                                               /**< %jp{プロセッサ固有の初期化} */
 
-#define _KERNEL_ENA_INT()      _kernel_ena_int()                                                                                                               /**< %jp{割り込み許可} */
-#define _KERNEL_DIS_INT()      _kernel_dis_int()                                                                                                               /**< %jp{割り込み禁止} */
-#define _KERNEL_WAI_INT()      _kernel_wai_int()                                                                                                               /**< %jp{割り込み待ち(アイドル時の処理)} */
+#define _KERNEL_INI_INT(stksz, stk)    do { _kernel_ictxcb.isp = (VB *)(stk) + (stksz); } while (0)    /**< %jp{割込み初期化} */
+#define _KERNEL_ENA_INT()                      _kernel_ena_int()                                                                                               /**< %jp{割り込み許可} */
+#define _KERNEL_DIS_INT()                      _kernel_dis_int()                                                                                               /**< %jp{割り込み禁止} */
+#define _KERNEL_WAI_INT()                      _kernel_wai_int()                                                                                               /**< %jp{割り込み待ち(アイドル時の処理)} */
 
 #define _KERNEL_CRE_CTX(pk_ctxcb, stksz, stk, isp, entry, par1, par2)                  \
                                                                        _kernel_cre_ctx((UW)(par1), (UW)(par2), (pk_ctxcb), (isp), (entry))
index 32e4d09..30efba5 100755 (executable)
@@ -1,21 +1,19 @@
 # Microsoft Developer Studio Project File - Name="sample" - Package Owner=<4>\r
 # Microsoft Developer Studio Generated Build File, Format Version 6.00\r
-# ** \95Ò\8fW\82µ\82È\82¢\82Å\82­\82¾\82³\82¢ **\r
+# ** \95ÿÿW\82ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ**\r
 \r
 # TARGTYPE "Win32 (x86) Console Application" 0x0103\r
 \r
 CFG=sample - Win32 Debug\r
-!MESSAGE \82±\82ê\82Í\97L\8cø\82ÈÒ²¸Ì§²Ù\82Å\82Í\82 \82è\82Ü\82¹\82ñ\81\82±\82ÌÌßÛ¼Þª¸Ä\82ðËÞÙÄÞ\82·\82é\82½\82ß\82É\82Í NMAKE \82ð\8eg\97p\82µ\82Ä\82­\82¾\82³\82¢\81B\r
-!MESSAGE [Ò²¸Ì§²Ù\82Ì´¸½Îß°Ä] ºÏÝÄÞ\82ð\8eg\97p\82µ\82Ä\8eÀ\8ds\82µ\82Ä\82­\82¾\82³\82¢\r
-!MESSAGE \r
+!MESSAGE \82ÿÿÿÿÿÿL\8cÿÿ\94Ð\89\96¥\89×\82ÿÿÿÿ \82ÿÿÿÿÿÿÿÿB \82ÿÿ\96Êàz\8eÜ\85¶ÿÿèÉ\9f×\92Ü\82ÿÿÿÿÿÿÿÿÿÿÿÿNMAKE \82ð\8eg\97p\82ÿÿÿÿÿÿÿÿÿÿÿÿB\r
+!MESSAGE [\99°\8cÊ\84Qÿÿ\96²\8c»\97Ý\88Â] \8dÍ\9fcÿÿð\8eg\97p\82ÿÿÄ\8eÿÿs\82ÿÿÿÿÿÿÿÿÿÿÿÿ!MESSAGE \r
 !MESSAGE NMAKE /f "sample.mak".\r
 !MESSAGE \r
-!MESSAGE NMAKE \82Ì\8eÀ\8ds\8e\9e\82É\8d\\90¬\82ð\8ew\92è\82Å\82«\82Ü\82·\r
-!MESSAGE ºÏÝÄޠײÝ\8fã\82ÅϸÛ\82Ì\90Ý\92è\82ð\92è\8b`\82µ\82Ü\82·\81B\97á:\r
+!MESSAGE NMAKE \82Ì\8eÿÿs\8e\9e\82ÿÿ\\90ÿÿð\8ew\92ÿÿÿÿÿÿÿÿÿÿ!MESSAGE \8dÍ\9fcÿÿ\9cQÿÿÿÿ\93n\8cÙ\82ÿÿÿÿÿÿÿÿÿÿ`\82ÿÿÿÿÿÿB\97ÿÿ\r
 !MESSAGE \r
 !MESSAGE NMAKE /f "sample.mak" CFG="sample - Win32 Debug"\r
 !MESSAGE \r
-!MESSAGE \91I\91ð\89Â\94\\82ÈËÞÙÄÞ Ó°ÄÞ:\r
+!MESSAGE \91I\91ÿÿÿÿ\\82\94É\9f×\92Ü \9aO\92Ü:\r
 !MESSAGE \r
 !MESSAGE "sample - Win32 Release" ("Win32 (x86) Console Application" \97p)\r
 !MESSAGE "sample - Win32 Debug" ("Win32 (x86) Console Application" \97p)\r
index 6e8d891..aa625a5 100755 (executable)
@@ -1,5 +1,5 @@
 Microsoft Developer Studio Workspace File, Format Version 6.00\r
-# \8cx\8d\90\82±\82ÌÜ°¸½Íß°½ Ì§²Ù \82ð\95Ò\8fW\82Ü\82½\82Í\8dí\8f\9c\82µ\82È\82¢\82Å\82­\82¾\82³\82¢!\r
+# \8cx\8d\90\82ÿÿ\96Ú\88\8flàOÿÿ\96¥\89× \82ÿÿÿÿW\82ÿÿÿÿÿÿÿÿ\9c\82ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ\r
 \r
 ###############################################################################\r
 \r
index 0cc40a3..5a12702 100755 (executable)
@@ -5,15 +5,15 @@
 # TARGTYPE "Win32 (x86) Console Application" 0x0103\r
 \r
 CFG=test_que - Win32 Debug\r
-!MESSAGE \82ÿÿÿÿÿÿL\8cÿÿ\94Ð\89\96¥\89×\82ÿÿÿÿ \82ÿÿÿÿÿÿÿÿB \82ÿÿ\96Êàz\8eÜ\85¶ÿÿèÉ\9f×\92Ü\82ÿÿÿÿÿÿÿÿÿÿÿÿNMAKE \82ð\8eg\97p\82ÿÿÿÿÿÿÿÿÿÿÿÿB\r
-!MESSAGE [\99°\8cÊ\84Qÿÿ\96²\8c»\97Ý\88Â] \8dÍ\9fcÿÿð\8eg\97p\82ÿÿÄ\8eÿÿs\82ÿÿÿÿÿÿÿÿÿÿÿÿ!MESSAGE \r
+!MESSAGE \82ÿÿÿÿÿÿL\8cÿÿ\94ÿÿÿÿÿÿÿÿÿÿÿÿ \82ÿÿÿÿÿÿÿÿB \82ÿÿ\96\95ÞzÜ\85ÿÿÿäÇ\9fÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNMAKE \82ð\8eg\97p\82ÿÿÿÿÿÿÿÿÿÿÿÿB\r
+!MESSAGE [\99ÿÿÿÿQÿÿ\96ÿÿÿÿÿÿÿÿ \8dÿÿcÿÿð\8eg\97p\82ÿÿÄ\8eÿÿs\82ÿÿÿÿÿÿÿÿÿÿÿÿ!MESSAGE \r
 !MESSAGE NMAKE /f "test_que.mak".\r
 !MESSAGE \r
-!MESSAGE NMAKE \82Ì\8eÿÿs\8e\9e\82ÿÿ\\90ÿÿð\8ew\92ÿÿÿÿÿÿÿÿÿÿ!MESSAGE \8dÍ\9fcÿÿ\9cQÿÿÿÿ\93n\8cÙ\82ÿÿÿÿÿÿÿÿÿÿ`\82ÿÿÿÿÿÿB\97ÿÿ\r
+!MESSAGE NMAKE \82Ì\8eÿÿs\8e\9e\82ÿÿ\\90ÿÿð\8ew\92ÿÿÿÿÿÿÿÿÿÿ!MESSAGE \8dÿÿcÿÿ\9cQÿÿÿÿ\93n\8cÿÿÿÿÿÿÿÿÿÿÿÿ`\82ÿÿÿÿÿÿB\97ÿÿ\r
 !MESSAGE \r
 !MESSAGE NMAKE /f "test_que.mak" CFG="test_que - Win32 Debug"\r
 !MESSAGE \r
-!MESSAGE \91I\91ÿÿÿÿ\\82\94É\9f×\92Ü \9aO\92Ü:\r
+!MESSAGE \91I\91ÿÿÿÿ\\82\94ÿÿÿÿÿÿ\9aO\92ÿÿ\r
 !MESSAGE \r
 !MESSAGE "test_que - Win32 Release" ("Win32 (x86) Console Application" \97p)\r
 !MESSAGE "test_que - Win32 Debug" ("Win32 (x86) Console Application" \97p)\r
index 422b6d8..ce59f33 100755 (executable)
@@ -1,5 +1,5 @@
 Microsoft Developer Studio Workspace File, Format Version 6.00\r
-# \8cx\8d\90\82ÿÿ\96Ú\88\8flàOÿÿ\96¥\89× \82ÿÿÿÿW\82ÿÿÿÿÿÿÿÿ\9c\82ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ\r
+# \8cx\8d\90\82ÿÿ\96ÿÿÿÿlÿÿÿÿ\96ÿÿÿÿ\82ÿÿÿÿW\82ÿÿÿÿÿÿÿÿ\9c\82ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ\r
 \r
 ###############################################################################\r
 \r
index 565ddff..63d0205 100755 (executable)
@@ -5,15 +5,15 @@
 # TARGTYPE "Win32 (x86) Console Application" 0x0103\r
 \r
 CFG=cmtcnv - Win32 Debug\r
-!MESSAGE \82ÿÿÿÿÿÿL\8cÿÿ\94Ð\89\96¥\89×\82ÿÿÿÿ \82ÿÿÿÿÿÿÿÿB \82ÿÿ\96Êàz\8eÜ\85¶ÿÿèÉ\9f×\92Ü\82ÿÿÿÿÿÿÿÿÿÿÿÿNMAKE \82ð\8eg\97p\82ÿÿÿÿÿÿÿÿÿÿÿÿB\r
-!MESSAGE [\99°\8cÊ\84Qÿÿ\96²\8c»\97Ý\88Â] \8dÍ\9fcÿÿð\8eg\97p\82ÿÿÄ\8eÿÿs\82ÿÿÿÿÿÿÿÿÿÿÿÿ!MESSAGE \r
+!MESSAGE \82ÿÿÿÿÿÿL\8cÿÿ\94ÿÿÿÿÿÿÿÿÿÿÿÿ \82ÿÿÿÿÿÿÿÿB \82ÿÿ\96\95ÞzÜ\85ÿÿÿäÇ\9fÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNMAKE \82ð\8eg\97p\82ÿÿÿÿÿÿÿÿÿÿÿÿB\r
+!MESSAGE [\99ÿÿÿÿQÿÿ\96ÿÿÿÿÿÿÿÿ \8dÿÿcÿÿð\8eg\97p\82ÿÿÄ\8eÿÿs\82ÿÿÿÿÿÿÿÿÿÿÿÿ!MESSAGE \r
 !MESSAGE NMAKE /f "cmtcnv.mak".\r
 !MESSAGE \r
-!MESSAGE NMAKE \82Ì\8eÿÿs\8e\9e\82ÿÿ\\90ÿÿð\8ew\92ÿÿÿÿÿÿÿÿÿÿ!MESSAGE \8dÍ\9fcÿÿ\9cQÿÿÿÿ\93n\8cÙ\82ÿÿÿÿÿÿÿÿÿÿ`\82ÿÿÿÿÿÿB\97ÿÿ\r
+!MESSAGE NMAKE \82Ì\8eÿÿs\8e\9e\82ÿÿ\\90ÿÿð\8ew\92ÿÿÿÿÿÿÿÿÿÿ!MESSAGE \8dÿÿcÿÿ\9cQÿÿÿÿ\93n\8cÿÿÿÿÿÿÿÿÿÿÿÿ`\82ÿÿÿÿÿÿB\97ÿÿ\r
 !MESSAGE \r
 !MESSAGE NMAKE /f "cmtcnv.mak" CFG="cmtcnv - Win32 Debug"\r
 !MESSAGE \r
-!MESSAGE \91I\91ÿÿÿÿ\\82\94É\9f×\92Ü \9aO\92Ü:\r
+!MESSAGE \91I\91ÿÿÿÿ\\82\94ÿÿÿÿÿÿ\9aO\92ÿÿ\r
 !MESSAGE \r
 !MESSAGE "cmtcnv - Win32 Release" ("Win32 (x86) Console Application" \97p)\r
 !MESSAGE "cmtcnv - Win32 Debug" ("Win32 (x86) Console Application" \97p)\r
index c2a0f06..78d0334 100755 (executable)
@@ -1,5 +1,5 @@
 Microsoft Developer Studio Workspace File, Format Version 6.00\r
-# \8cx\8d\90\82ÿÿ\96Ú\88\8flàOÿÿ\96¥\89× \82ÿÿÿÿW\82ÿÿÿÿÿÿÿÿ\9c\82ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ\r
+# \8cx\8d\90\82ÿÿ\96ÿÿÿÿlÿÿÿÿ\96ÿÿÿÿ\82ÿÿÿÿW\82ÿÿÿÿÿÿÿÿ\9c\82ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ\r
 \r
 ###############################################################################\r
 \r