diff --git a/Makefile.include b/Makefile.include index 8bad9e2e5..01378f115 100644 --- a/Makefile.include +++ b/Makefile.include @@ -37,7 +37,6 @@ include $(CONTIKI)/core/net/mac/Makefile.mac SYSTEM = process.c procinit.c service.c autostart.c elfloader.c THREADS = mt.c LIBS = memb.c timer.c list.c etimer.c energest.c rtimer.c -CFS = cfs.c cfs-ram.c CTK = ctk.c UIP = uip.c uiplib.c resolv.c tcpip.c psock.c hc.c uip-split.c \ uip-fw.c uip-fw-service.c uipbuf.c uip_arp.c uiplib.c tcpdump.c \ @@ -49,7 +48,7 @@ CTKVNC = $(CTK) ctk-vncserver.c libconio.c vnc-server.c vnc-out.c \ CTKTERM = $(CTK) libconio.c ctk-term.c ctk-term-in.c ctk-term-out.c \ ctk-termtelnet.c -CONTIKIFILES = $(SYSTEM) $(CFS) $(LIBS) $(NET) $(DHCP) $(THREADS) +CONTIKIFILES = $(SYSTEM) $(LIBS) $(NET) $(DHCP) $(THREADS) CONTIKI_SOURCEFILES += $(CONTIKIFILES) diff --git a/core/cfs/cfs-eeprom.c b/core/cfs/cfs-eeprom.c index e686b4af1..b75b15fda 100644 --- a/core/cfs/cfs-eeprom.c +++ b/core/cfs/cfs-eeprom.c @@ -30,12 +30,11 @@ * * Author: Adam Dunkels * - * $Id: cfs-eeprom.c,v 1.1 2006/06/17 22:41:15 adamdunkels Exp $ + * $Id: cfs-eeprom.c,v 1.2 2007/05/19 21:05:48 oliverschmidt Exp $ */ #include "contiki.h" #include "cfs/cfs.h" -#include "cfs/cfs-service.h" #include "dev/eeprom.h" struct filestate { @@ -54,8 +53,8 @@ static struct filestate file; #endif /*---------------------------------------------------------------------------*/ -static int -s_open(const char *n, int f) +int +cfs_open(const char *n, int f) { if(file.flag == FLAG_FILE_CLOSED) { file.flag = FLAG_FILE_OPEN; @@ -66,14 +65,14 @@ s_open(const char *n, int f) } } /*---------------------------------------------------------------------------*/ -static void -s_close(int f) +void +cfs_close(int f) { file.flag = FLAG_FILE_CLOSED; } /*---------------------------------------------------------------------------*/ -static int -s_read(int f, char *buf, unsigned int len) +int +cfs_read(int f, char *buf, unsigned int len) { if(f == 1) { eeprom_read(CFS_EEPROM_OFFSET + file.fileptr, buf, len); @@ -84,8 +83,8 @@ s_read(int f, char *buf, unsigned int len) } } /*---------------------------------------------------------------------------*/ -static int -s_write(int f, char *buf, unsigned int len) +int +cfs_write(int f, char *buf, unsigned int len) { if(f == 1) { eeprom_write(CFS_EEPROM_OFFSET + file.fileptr, buf, len); @@ -96,8 +95,8 @@ s_write(int f, char *buf, unsigned int len) } } /*---------------------------------------------------------------------------*/ -static int -s_seek(int f, unsigned int o) +int +cfs_seek(int f, unsigned int o) { if(f == 1) { file.fileptr = o; @@ -107,44 +106,21 @@ s_seek(int f, unsigned int o) } } /*---------------------------------------------------------------------------*/ -static int -s_opendir(struct cfs_dir *p, const char *n) +int +cfs_opendir(struct cfs_dir *p, const char *n) { return 1; } /*---------------------------------------------------------------------------*/ -static int -s_readdir(struct cfs_dir *p, struct cfs_dirent *e) +int +cfs_readdir(struct cfs_dir *p, struct cfs_dirent *e) { return 1; } /*---------------------------------------------------------------------------*/ -static int -s_closedir(struct cfs_dir *p) +int +cfs_closedir(struct cfs_dir *p) { return 1; } /*---------------------------------------------------------------------------*/ -/* - * Service registration code follows. - */ -SERVICE(cfs_eeprom_service, cfs_service, -{ s_open, s_close, s_read, s_write, s_seek, - s_opendir, s_readdir, s_closedir }); - -PROCESS(cfs_eeprom_process, "CFS EEPROM service"); - -PROCESS_THREAD(cfs_eeprom_process, ev, data) -{ - PROCESS_BEGIN(); - - SERVICE_REGISTER(cfs_eeprom_service); - - PROCESS_WAIT_EVENT_UNTIL(ev == PROCESS_EVENT_SERVICE_REMOVED || - ev == PROCESS_EVENT_EXIT); - - SERVICE_REMOVE(cfs_eeprom_service); - - PROCESS_END(); -} -/*---------------------------------------------------------------------------*/ diff --git a/core/cfs/cfs-eeprom.h b/core/cfs/cfs-eeprom.h deleted file mode 100644 index e6746001e..000000000 --- a/core/cfs/cfs-eeprom.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2004, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - * Author: Adam Dunkels - * - * $Id: cfs-eeprom.h,v 1.1 2006/06/17 22:41:15 adamdunkels Exp $ - */ -#ifndef __CFS_EEPROM_H__ -#define __CFS_EEPROM_H__ - -#include "contiki.h" -#include "cfs/cfs.h" - -PROCESS_NAME(cfs_eeprom_process); - -#endif /* __CFS_EEPROM_H__ */ diff --git a/core/cfs/cfs-posix.c b/core/cfs/cfs-posix.c index c20d2f9be..7dfa5a2c6 100644 --- a/core/cfs/cfs-posix.c +++ b/core/cfs/cfs-posix.c @@ -30,12 +30,11 @@ * * Author: Adam Dunkels * - * $Id: cfs-posix.c,v 1.2 2006/08/13 14:05:20 oliverschmidt Exp $ + * $Id: cfs-posix.c,v 1.3 2007/05/19 21:05:49 oliverschmidt Exp $ */ #include "contiki.h" #include "cfs/cfs.h" -#include "cfs/cfs-service.h" #undef LITTLE_ENDIAN #undef BIG_ENDIAN @@ -51,41 +50,13 @@ #include #include -static int s_open(const char *n, int f); -static void s_close(int f); -static int s_read(int f, char *b, unsigned int l); -static int s_write(int f, char *b, unsigned int l); -static int s_seek(int f, unsigned int offset); -static int s_opendir(struct cfs_dir *p, const char *n); -static int s_readdir(struct cfs_dir *p, struct cfs_dirent *e); -static int s_closedir(struct cfs_dir *p); - -SERVICE(cfs_posix_service, cfs_service, -{ s_open, s_close, s_read, s_write, s_seek, - s_opendir, s_readdir, s_closedir }); - struct cfs_posix_dir { DIR *dirp; }; -PROCESS(cfs_posix_process, "CFS POSIX service"); - -PROCESS_THREAD(cfs_posix_process, ev, data) -{ - PROCESS_BEGIN(); - - SERVICE_REGISTER(cfs_posix_service); - - PROCESS_WAIT_EVENT_UNTIL(ev == PROCESS_EVENT_SERVICE_REMOVED || - ev == PROCESS_EVENT_EXIT); - - SERVICE_REMOVE(cfs_posix_service); - - PROCESS_END(); -} /*---------------------------------------------------------------------------*/ -static int -s_open(const char *n, int f) +int +cfs_open(const char *n, int f) { char filename[255]; @@ -98,32 +69,32 @@ s_open(const char *n, int f) } } /*---------------------------------------------------------------------------*/ -static void -s_close(int f) +void +cfs_close(int f) { close(f); } /*---------------------------------------------------------------------------*/ -static int -s_read(int f, char *b, unsigned int l) +int +cfs_read(int f, char *b, unsigned int l) { return read(f, b, l); } /*---------------------------------------------------------------------------*/ -static int -s_write(int f, char *b, unsigned int l) +int +cfs_write(int f, char *b, unsigned int l) { return write(f, b, l); } /*---------------------------------------------------------------------------*/ -static int -s_seek(int f, unsigned int o) +int +cfs_seek(int f, unsigned int o) { return lseek(f, o, SEEK_SET); } /*---------------------------------------------------------------------------*/ -static int -s_opendir(struct cfs_dir *p, const char *n) +int +cfs_opendir(struct cfs_dir *p, const char *n) { struct cfs_posix_dir *dir = (struct cfs_posix_dir *)p; char dirname[255]; @@ -141,8 +112,8 @@ s_opendir(struct cfs_dir *p, const char *n) return dir->dirp == NULL; } /*---------------------------------------------------------------------------*/ -static int -s_readdir(struct cfs_dir *p, struct cfs_dirent *e) +int +cfs_readdir(struct cfs_dir *p, struct cfs_dirent *e) { struct cfs_posix_dir *dir = (struct cfs_posix_dir *)p; struct dirent *res; @@ -160,8 +131,8 @@ s_readdir(struct cfs_dir *p, struct cfs_dirent *e) return 0; } /*---------------------------------------------------------------------------*/ -static int -s_closedir(struct cfs_dir *p) +int +cfs_closedir(struct cfs_dir *p) { struct cfs_posix_dir *dir = (struct cfs_posix_dir *)p; if(dir->dirp != NULL) { diff --git a/core/cfs/cfs-posix.h b/core/cfs/cfs-posix.h deleted file mode 100644 index a7b665d72..000000000 --- a/core/cfs/cfs-posix.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2004, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - * Author: Adam Dunkels - * - * $Id: cfs-posix.h,v 1.1 2006/06/17 22:41:15 adamdunkels Exp $ - */ -#ifndef __CFS_POSIX_H__ -#define __CFS_POSIX_H__ - -#include "contiki.h" - -PROCESS_NAME(cfs_posix_process); - -#endif /* __CFS_POSIX_H__ */ diff --git a/core/cfs/cfs-ram.c b/core/cfs/cfs-ram.c index 21435d7d9..ce2a092a6 100644 --- a/core/cfs/cfs-ram.c +++ b/core/cfs/cfs-ram.c @@ -30,12 +30,11 @@ * * Author: Adam Dunkels * - * $Id: cfs-ram.c,v 1.2 2007/03/22 23:55:03 adamdunkels Exp $ + * $Id: cfs-ram.c,v 1.3 2007/05/19 21:05:49 oliverschmidt Exp $ */ #include "contiki.h" #include "cfs/cfs.h" -#include "cfs/cfs-service.h" #include struct filestate { @@ -56,8 +55,8 @@ static struct filestate file; static char filemem[CFS_RAM_SIZE]; /*---------------------------------------------------------------------------*/ -static int -s_open(const char *n, int f) +int +cfs_open(const char *n, int f) { if(file.flag == FLAG_FILE_CLOSED) { file.flag = FLAG_FILE_OPEN; @@ -71,14 +70,14 @@ s_open(const char *n, int f) } } /*---------------------------------------------------------------------------*/ -static void -s_close(int f) +void +cfs_close(int f) { file.flag = FLAG_FILE_CLOSED; } /*---------------------------------------------------------------------------*/ -static int -s_read(int f, char *buf, unsigned int len) +int +cfs_read(int f, char *buf, unsigned int len) { if(file.fileptr + len > sizeof(filemem)) { len = sizeof(filemem) - file.fileptr; @@ -97,8 +96,8 @@ s_read(int f, char *buf, unsigned int len) } } /*---------------------------------------------------------------------------*/ -static int -s_write(int f, char *buf, unsigned int len) +int +cfs_write(int f, char *buf, unsigned int len) { if(file.fileptr >= sizeof(filemem)) { return 0; @@ -121,8 +120,8 @@ s_write(int f, char *buf, unsigned int len) } } /*---------------------------------------------------------------------------*/ -static int -s_seek(int f, unsigned int o) +int +cfs_seek(int f, unsigned int o) { if(f == 1) { if(o > file.filesize) { @@ -135,50 +134,21 @@ s_seek(int f, unsigned int o) } } /*---------------------------------------------------------------------------*/ -static int -s_opendir(struct cfs_dir *p, const char *n) +int +cfs_opendir(struct cfs_dir *p, const char *n) { return 1; } /*---------------------------------------------------------------------------*/ -static int -s_readdir(struct cfs_dir *p, struct cfs_dirent *e) +int +cfs_readdir(struct cfs_dir *p, struct cfs_dirent *e) { return 1; } /*---------------------------------------------------------------------------*/ -static int -s_closedir(struct cfs_dir *p) +int +cfs_closedir(struct cfs_dir *p) { return 1; } /*---------------------------------------------------------------------------*/ -/* - * Service registration code follows. - */ -SERVICE(cfs_ram_service, cfs_service, -{ s_open, s_close, s_read, s_write, s_seek, - s_opendir, s_readdir, s_closedir }); - -PROCESS(cfs_ram_process, "CFS RAM service"); - -PROCESS_THREAD(cfs_ram_process, ev, data) -{ - PROCESS_BEGIN(); - - SERVICE_REGISTER(cfs_ram_service); - - PROCESS_WAIT_EVENT_UNTIL(ev == PROCESS_EVENT_SERVICE_REMOVED || - ev == PROCESS_EVENT_EXIT); - - SERVICE_REMOVE(cfs_ram_service); - - PROCESS_END(); -} -/*---------------------------------------------------------------------------*/ -void -cfs_ram_init(void) -{ - process_start(&cfs_ram_process, NULL); -} -/*---------------------------------------------------------------------------*/ diff --git a/core/cfs/cfs-ram.h b/core/cfs/cfs-ram.h deleted file mode 100644 index 140ee41ae..000000000 --- a/core/cfs/cfs-ram.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2004, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - * Author: Adam Dunkels - * - * $Id: cfs-ram.h,v 1.1 2006/06/17 22:41:15 adamdunkels Exp $ - */ -#ifndef __CFS_RAM_H__ -#define __CFS_RAM_H__ - -#include "contiki.h" -#include "cfs/cfs.h" - -PROCESS_NAME(cfs_ram_process); - -#endif /* __CFS_RAM_H__ */ diff --git a/core/cfs/cfs-service.h b/core/cfs/cfs-service.h deleted file mode 100644 index 374eba53d..000000000 --- a/core/cfs/cfs-service.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2004, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - * Author: Adam Dunkels - * - * $Id: cfs-service.h,v 1.1 2006/06/17 22:41:15 adamdunkels Exp $ - */ -#ifndef __CFS_SERVICE_H__ -#define __CFS_SERVICE_H__ - -#include "contiki.h" -#include "cfs/cfs.h" - -struct cfs_dir { - unsigned char dummy_space[32]; -}; - -struct cfs_dirent { - unsigned char name[32]; - unsigned int size; -}; - -struct cfs_service_interface { - int (* open)(const char *name, int flags); - void (* close)(int fd); - int (* read)(int fd, char *buf, unsigned int len); - int (* write)(int fd, char *buf, unsigned int len); - int (* seek)(int fd, unsigned int offset); - - int (* opendir)(struct cfs_dir *dir, const char *name); - int (* readdir)(struct cfs_dir *dir, struct cfs_dirent *dirent); - int (* closedir)(struct cfs_dir *dir); -}; - -#define cfs_service_name "Filesystem" -SERVICE_INTERFACE(cfs_service, -{ - int (* open)(const char *name, int flags); - void (* close)(int fd); - int (* read)(int fd, char *buf, unsigned int len); - int (* write)(int fd, char *buf, unsigned int len); - int (* seek)(int fd, unsigned int offset); - - int (* opendir)(struct cfs_dir *dir, const char *name); - int (* readdir)(struct cfs_dir *dir, struct cfs_dirent *dirent); - int (* closedir)(struct cfs_dir *dir); -}); - -#endif /* __CFS_SERVICE_H__ */ diff --git a/core/cfs/cfs-xmem.c b/core/cfs/cfs-xmem.c index 98581fa87..fc3e2bc0b 100644 --- a/core/cfs/cfs-xmem.c +++ b/core/cfs/cfs-xmem.c @@ -30,12 +30,11 @@ * * Author: Adam Dunkels * - * $Id: cfs-xmem.c,v 1.3 2007/03/23 15:52:13 nifi Exp $ + * $Id: cfs-xmem.c,v 1.4 2007/05/19 21:05:49 oliverschmidt Exp $ */ #include "contiki.h" #include "cfs/cfs.h" -#include "cfs/cfs-service.h" #include "dev/xmem.h" struct filestate { @@ -61,10 +60,9 @@ struct filestate { static struct filestate file; - /*---------------------------------------------------------------------------*/ -static int -s_open(const char *n, int f) +int +cfs_open(const char *n, int f) { if(file.flag == FLAG_FILE_CLOSED) { file.flag = FLAG_FILE_OPEN; @@ -79,14 +77,14 @@ s_open(const char *n, int f) } } /*---------------------------------------------------------------------------*/ -static void -s_close(int f) +void +cfs_close(int f) { file.flag = FLAG_FILE_CLOSED; } /*---------------------------------------------------------------------------*/ -static int -s_read(int f, char *buf, unsigned int len) +int +cfs_read(int f, char *buf, unsigned int len) { if(file.fileptr + len > CFS_XMEM_SIZE) { len = CFS_XMEM_SIZE - file.fileptr; @@ -105,8 +103,8 @@ s_read(int f, char *buf, unsigned int len) } } /*---------------------------------------------------------------------------*/ -static int -s_write(int f, char *buf, unsigned int len) +int +cfs_write(int f, char *buf, unsigned int len) { if(file.fileptr >= CFS_XMEM_SIZE) { return 0; @@ -129,8 +127,8 @@ s_write(int f, char *buf, unsigned int len) } } /*---------------------------------------------------------------------------*/ -static int -s_seek(int f, unsigned int o) +int +cfs_seek(int f, unsigned int o) { if(f == 1) { if(o > file.filesize) { @@ -143,52 +141,22 @@ s_seek(int f, unsigned int o) } } /*---------------------------------------------------------------------------*/ -static int -s_opendir(struct cfs_dir *p, const char *n) +int +cfs_opendir(struct cfs_dir *p, const char *n) { return 1; } /*---------------------------------------------------------------------------*/ -static int -s_readdir(struct cfs_dir *p, struct cfs_dirent *e) +int +cfs_readdir(struct cfs_dir *p, struct cfs_dirent *e) { return 1; } /*---------------------------------------------------------------------------*/ -static int -s_closedir(struct cfs_dir *p) +int +cfs_closedir(struct cfs_dir *p) { return 1; } /*---------------------------------------------------------------------------*/ -/* - * Service registration code follows. - */ -SERVICE(cfs_xmem_service, cfs_service, -{ s_open, s_close, s_read, s_write, s_seek, - s_opendir, s_readdir, s_closedir }); -PROCESS(cfs_xmem_process, "CFS XMEM service"); - -PROCESS_THREAD(cfs_xmem_process, ev, data) -{ - PROCESS_BEGIN(); - - file.fileptr = file.filesize = 0; - - SERVICE_REGISTER(cfs_xmem_service); - - PROCESS_WAIT_EVENT_UNTIL(ev == PROCESS_EVENT_SERVICE_REMOVED || - ev == PROCESS_EVENT_EXIT); - - SERVICE_REMOVE(cfs_xmem_service); - - PROCESS_END(); -} -/*---------------------------------------------------------------------------*/ -void -cfs_xmem_init(void) -{ - process_start(&cfs_xmem_process, NULL); -} -/*---------------------------------------------------------------------------*/ diff --git a/core/cfs/cfs-xmem.h b/core/cfs/cfs-xmem.h deleted file mode 100644 index f9309f19a..000000000 --- a/core/cfs/cfs-xmem.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2004, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - * Author: Adam Dunkels - * - * $Id: cfs-xmem.h,v 1.1 2007/03/21 23:15:31 adamdunkels Exp $ - */ -#ifndef __CFS_XMEM_H__ -#define __CFS_XMEM_H__ - -#include "contiki.h" -#include "cfs/cfs.h" - -PROCESS_NAME(cfs_xmem_process); - -void cfs_xmem_init(void); - -#endif /* __CFS_XMEM_H__ */ diff --git a/core/cfs/cfs.c b/core/cfs/cfs.c deleted file mode 100644 index 9adae853c..000000000 --- a/core/cfs/cfs.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2004, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - * Author: Adam Dunkels - * - * $Id: cfs.c,v 1.2 2006/08/13 14:06:24 oliverschmidt Exp $ - */ -#include "contiki.h" - -#include "cfs/cfs.h" -#include "cfs/cfs-service.h" - - -static int null_open(const char *n, int f) {return -1;} -static void null_close(int f) {return;} -static int null_read(int f, char *b, unsigned int l) {return -1;} -static int null_write(int f, char *b, unsigned int l) {return -1;} -static int null_seek(int fd, unsigned int l) {return -1;} -static int null_opendir(struct cfs_dir *p, const char *n) {return -1;} -static int null_readdir(struct cfs_dir *p, struct cfs_dirent *e) {return -1;} -static int null_closedir(struct cfs_dir *p) {return -1;} - -SERVICE(cfs_nullservice, cfs_service, - { - null_open, - null_close, - null_read, - null_write, - null_seek, - null_opendir, - null_readdir, - null_closedir - }); - -/*---------------------------------------------------------------------------*/ -const struct cfs_service_interface * -cfs_find_service(void) -{ - struct service *s; - - s = service_find(cfs_service_name); - - if(s != NULL) { - return s->interface; - } else { - return cfs_nullservice.interface; - } -} -/*---------------------------------------------------------------------------*/ diff --git a/core/cfs/cfs.h b/core/cfs/cfs.h index b5960e425..eaa9a111c 100644 --- a/core/cfs/cfs.h +++ b/core/cfs/cfs.h @@ -54,12 +54,21 @@ * * Author: Adam Dunkels * - * $Id: cfs.h,v 1.4 2007/03/22 23:55:32 adamdunkels Exp $ + * $Id: cfs.h,v 1.5 2007/05/19 21:05:49 oliverschmidt Exp $ */ #ifndef __CFS_H__ #define __CFS_H__ -#include "cfs/cfs-service.h" +#include "contiki.h" + +struct cfs_dir { + unsigned char dummy_space[32]; +}; + +struct cfs_dirent { + unsigned char name[32]; + unsigned int size; +}; /** * Specify that cfs_open() should open a file for reading. @@ -115,7 +124,7 @@ * \sa CFS_WRITE * \sa cfs_close() */ -int cfs_open(const char *name, int flags); +CCIF int cfs_open(const char *name, int flags); /** * \brief Close an open file. @@ -124,7 +133,7 @@ int cfs_open(const char *name, int flags); * This function closes a file that has previously been * opened with cfs_open(). */ -void cfs_close(int fd); +CCIF void cfs_close(int fd); /** * \brief Read data from an open file. @@ -137,7 +146,7 @@ void cfs_close(int fd); * buffer. The file must have first been opened with * cfs_open() and the CFS_READ flag. */ -int cfs_read(int fd, char *buf, unsigned int len); +CCIF int cfs_read(int fd, char *buf, unsigned int len); /** * \brief Write data to an open file. @@ -150,7 +159,7 @@ int cfs_read(int fd, char *buf, unsigned int len); * an open file. The file must have been opened with * cfs_open() and the CFS_WRITE flag. */ -int cfs_write(int fd, char *buf, unsigned int len); +CCIF int cfs_write(int fd, char *buf, unsigned int len); /** * \brief Seek to a specified position in an open file. @@ -163,7 +172,7 @@ int cfs_write(int fd, char *buf, unsigned int len); * or written to the file will be at the position given by * the offset parameter. */ -int cfs_seek(int fd, unsigned int offset); +CCIF int cfs_seek(int fd, unsigned int offset); /** * \brief Open a directory for reading directory entries. @@ -174,7 +183,7 @@ int cfs_seek(int fd, unsigned int offset); * \sa cfs_readdir() * \sa cfs_closedir() */ -int cfs_opendir(struct cfs_dir *dirp, const char *name); +CCIF int cfs_opendir(struct cfs_dir *dirp, const char *name); /** * \brief Read a directory entry @@ -186,7 +195,7 @@ int cfs_opendir(struct cfs_dir *dirp, const char *name); * \sa cfs_opendir() * \sa cfs_closedir() */ -int cfs_readdir(struct cfs_dir *dirp, struct cfs_dirent *dirent); +CCIF int cfs_readdir(struct cfs_dir *dirp, struct cfs_dirent *dirent); /** * \brief Close a directory opened with cfs_opendir(). @@ -195,20 +204,7 @@ int cfs_readdir(struct cfs_dir *dirp, struct cfs_dirent *dirent); * \sa cfs_opendir() * \sa cfs_readdir() */ -int cfs_closedir(struct cfs_dir *dirp); - -CCIF const struct cfs_service_interface *cfs_find_service(void); - -#define cfs_open(name, flags) (cfs_find_service()->open(name, flags)) -#define cfs_close(fd) (cfs_find_service()->close(fd)) -#define cfs_read(fd, buf, len) (cfs_find_service()->read(fd, buf, len)) -#define cfs_write(fd, buf, len) (cfs_find_service()->write(fd, buf, len)) -#define cfs_seek(fd, off) (cfs_find_service()->seek(fd, off)) - -#define cfs_opendir(dirp, name) (cfs_find_service()->opendir(dirp, name)) -#define cfs_readdir(dirp, ent) (cfs_find_service()->readdir(dirp, ent)) -#define cfs_closedir(dirp) (cfs_find_service()->closedir(dirp)) - +CCIF int cfs_closedir(struct cfs_dir *dirp); #endif /* __CFS_H__ */ diff --git a/examples/sky/test-cfs.c b/examples/sky/test-cfs.c index b20ffef72..d1688d8d6 100644 --- a/examples/sky/test-cfs.c +++ b/examples/sky/test-cfs.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: test-cfs.c,v 1.1 2007/03/23 12:17:28 adamdunkels Exp $ + * $Id: test-cfs.c,v 1.2 2007/05/19 21:07:07 oliverschmidt Exp $ */ /** @@ -40,15 +40,12 @@ #include "contiki.h" #include "cfs/cfs.h" -/*---------------------------------------------------------------------------*/ -PROCESS(cfs_process, "xmem cfs"); -AUTOSTART_PROCESSES(&cfs_process); + /*---------------------------------------------------------------------------*/ PROCESS_THREAD(cfs_process, ev, data) { PROCESS_BEGIN(); - { int i, j, fd; int errors = 0; @@ -84,7 +81,7 @@ PROCESS_THREAD(cfs_process, ev, data) } printf("CFS xmem test 1 completed with %d errors\n", errors); - fd = cfs_open("hej", CFS_WRITE); + fd = cfs_open("hej", CFS_WRITE); if(fd < 0) { printf("could not open file for writing, aborting\n"); } else { @@ -112,7 +109,7 @@ PROCESS_THREAD(cfs_process, ev, data) } } printf("CFS xmem test 2 completed with %d errors\n", errors); -} + } PROCESS_END(); } diff --git a/platform/esb/contiki-esb-main.c b/platform/esb/contiki-esb-main.c index d860a2485..5ff94da61 100644 --- a/platform/esb/contiki-esb-main.c +++ b/platform/esb/contiki-esb-main.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * @(#)$Id: contiki-esb-main.c,v 1.9 2007/05/15 08:11:33 adamdunkels Exp $ + * @(#)$Id: contiki-esb-main.c,v 1.10 2007/05/19 21:08:43 oliverschmidt Exp $ */ #include @@ -40,15 +40,12 @@ #include "sys/autostart.h" #include "contiki-esb.h" -#include "cfs/cfs-eeprom.h" - SENSORS(&button_sensor, &sound_sensor, &vib_sensor, &pir_sensor, &radio_sensor, &battery_sensor, &ctsrts_sensor, &temperature_sensor); PROCINIT(&sensors_process, /*&ir_process,*/ - &etimer_process, - &cfs_eeprom_process); + &etimer_process); PROCESS(contiki_esb_main_init_process, "Contiki ESB init process");