Index: uKadecot/trunk/uip/apps/webserver/httpd-fs.c
===================================================================
--- uKadecot/trunk/uip/apps/webserver/httpd-fs.c	(revision 152)
+++ uKadecot/trunk/uip/apps/webserver/httpd-fs.c	(revision 154)
@@ -38,8 +38,9 @@
 #include "pff.h"
 #include "diskio.h"
+#include "mmc_rspi.h"
+#include <string.h>
 
 //#define FILE_DUMP
 #ifdef FILE_DUMP
-#include <string.h>
 char path[256] = "";
 FATFS fs;
@@ -98,5 +99,6 @@
 	FRESULT res;
 #endif
-	disk_initialize();
+	ramdisk_initialize();
+	mmc_rspi_initialize();
 #ifdef FILE_DUMP
 	if((res = pf_mount(&fs)) != FR_OK){
@@ -112,8 +114,25 @@
 /*-----------------------------------------------------------------------------------*/
 int
-httpd_fs_open(const char *name, struct httpd_fs_file *file)
+httpd_fs_open(int drv, const char *name, struct httpd_fs_file *file)
 {
 	FRESULT res;
-	FATFS *fs = (FATFS *)&file->fs;
+	FATFS *fs = (FATFS *)file->fs;
+
+	file->pos = 0;
+	file->len = 0;
+	file->drv = drv;
+	file->name = name;
+	memset(fs, 0, sizeof(FATFS));
+
+	if (drv == 0) {
+		fs->disk_get_status = ramdisk_get_status;
+		fs->disk_readp = ramdisk_readp;
+		fs->disk_writep = ramdisk_writep;
+	}
+	else {
+		fs->disk_get_status = mmc_rspi_get_status;
+		fs->disk_readp = mmc_rspi_readp;
+		fs->disk_writep = mmc_rspi_writep;
+	}
 
 	if (fs->fs_type == 0){
@@ -125,13 +144,11 @@
 
 	if((res = pf_open(fs, name)) != FR_OK){
-		printf("pf_open(%s) => %d\n", name, res);
+		printf("pf_open(%d:%s) => %d\n", drv, name, res);
 		return 0;
 	}
 
-	file->pos = 0;
 	file->len = fs->fsize;
-	file->name = name;
 
-	//printf("httpd_fs_open(%s) %d\n", name, file->len);
+	//printf("httpd_fs_open(%d:%s) %d\n", drv, name, file->len);
 
 	return 1;
@@ -143,21 +160,21 @@
 	FRESULT ret;
 	UINT rlen;
-	FATFS *fs = (FATFS *)&file->fs;
+	FATFS *fs = (FATFS *)file->fs;
 
 	if((ret = pf_lseek(fs, file->pos)) != FR_OK){
-		printf("pf_lseek(%d) => %d\n", file->pos, ret);
+		printf("pf_lseek(%d:%s, %d) => %d\n", file->drv, file->name, file->pos, ret);
 		return 0;
 	}
 
 	if(file->pos != fs->fptr){
-		printf("pf_lseek(%d) != %d\n", file->pos, fs->fptr);
+		printf("pf_lseek(%d:%s, %d) != %d\n", file->drv, file->name, file->pos, fs->fptr);
 	}
 
 	if((ret = pf_read(fs, dst, len, &rlen)) != FR_OK){
-		printf("pf_read(%x, %d) => %d\n", dst, len, ret);
+		printf("pf_read(%d:%s, 0x%p, %d) => %d\n", file->drv, file->name, dst, len, ret);
 		return 0;
 	}
 
-	//printf("httpd_fs_read(%s, %d, %d) => %d\n", file->name, file->pos, len, rlen);
+	//printf("httpd_fs_read(%d:%s, %d, %d) => %d\n", file->drv, file->name, file->pos, len, rlen);
 
 	return rlen;
Index: uKadecot/trunk/uip/apps/webserver/httpd-fs.h
===================================================================
--- uKadecot/trunk/uip/apps/webserver/httpd-fs.h	(revision 152)
+++ uKadecot/trunk/uip/apps/webserver/httpd-fs.h	(revision 154)
@@ -41,11 +41,12 @@
   int pos;
   int len;
+  int drv;
   const char *name;
-  char fs[64/*>sizeof(FATFS)*/];
+  void *fs;
 };
 
 /* file must be allocated by caller and will be filled in
    by the function. */
-int httpd_fs_open(const char *name, struct httpd_fs_file *file);
+int httpd_fs_open(int drv, const char *name, struct httpd_fs_file *file);
 int httpd_fs_read(struct httpd_fs_file *file, void *dst, int len);
 
Index: uKadecot/trunk/uip/apps/webserver/httpd.c
===================================================================
--- uKadecot/trunk/uip/apps/webserver/httpd.c	(revision 152)
+++ uKadecot/trunk/uip/apps/webserver/httpd.c	(revision 154)
@@ -198,6 +198,8 @@
   memcpy(pos, statushdr, len); pos += len;
 
-  len = strlen(http_content_encoding_gzip);
-  memcpy(pos, http_content_encoding_gzip, len); pos += len;
+  if (s->drv == 0) {
+    len = strlen(http_content_encoding_gzip);
+    memcpy(pos, http_content_encoding_gzip, len); pos += len;
+  }
 
   ptr = strrchr(s->message.request_url, ISO_period);
@@ -244,10 +246,11 @@
 PT_THREAD(handle_output(struct httpd_state *s))
 {
-  char *ptr;
-
   PT_BEGIN(&s->outputpt);
 
-  if (!httpd_fs_open(s->message.request_url, &s->file)) {
-    httpd_fs_open(http_404_html, &s->file);
+  s->file.fs = ((char *)&s[1]) - 64 - 512;
+
+  if (!httpd_fs_open(s->drv, s->filename, &s->file)) {
+    s->drv = 0;
+    httpd_fs_open(s->drv, http_404_html, &s->file);
     strcpy_s(s->message.request_url, sizeof(s->message.request_url), http_404_html);
     PT_WAIT_THREAD(&s->outputpt,
@@ -259,5 +262,4 @@
       send_headers(s,
       http_header_200));
-    ptr = strchr(s->message.request_url, ISO_period);
     PT_WAIT_THREAD(&s->outputpt, send_file(s));
   }
@@ -406,4 +408,14 @@
   if ((s->message.request_url[0] == '\0') || ((s->message.request_url[0] == '/') && (s->message.request_url[1] == '\0'))) {
     strncpy_s(s->message.request_url, sizeof(s->message.request_url), http_index_html, sizeof(s->message.request_url));
+    s->filename = s->message.request_url;
+  }
+  /* "/~/"ならSDカードから読み込み */
+  else if ((s->message.request_url[0] == '/') && (s->message.request_url[1] == '~') && (s->message.request_url[2] == '/')) {
+    s->drv = 1;
+    s->filename = &s->message.request_url[2];
+  }
+  else {
+    s->drv = 0;
+    s->filename = s->message.request_url;
   }
 
Index: uKadecot/trunk/uip/apps/webserver/httpd.h
===================================================================
--- uKadecot/trunk/uip/apps/webserver/httpd.h	(revision 152)
+++ uKadecot/trunk/uip/apps/webserver/httpd.h	(revision 154)
@@ -47,7 +47,8 @@
   char inputbuf[50];
   char state;
+  int drv;
+  char *filename;
+  int len;
   struct httpd_fs_file file;
-  int len;
-  unsigned short count;
   int parse_pos;
   int parse_len;
