diff --git a/include/device.h b/include/device.h index f97d06f..8e3fa6a 100644 --- a/include/device.h +++ b/include/device.h @@ -32,12 +32,11 @@ #include - typedef struct dev_t { - int major; - void *info; - int (*read)(dev_t *,void *,uInt32,uInt32); - void (*write)(void *,void *,uInt32,uInt32); + int major; + void *info; + int (*read)(dev_t *,void *,uInt32,uInt32); + int (*write)(dev_t *,void *,uInt32,uInt32); void (*reset)(void *); int (*init)(void *); void (*ioctl)(void *); @@ -46,12 +45,13 @@ void (*standby)(void *); }; -dev_t *dev_ramDrive(); - #endif /*** $Log$ + Revision 1.2 2004/08/13 16:54:14 reddawg + fixed + Revision 1.1 2004/08/13 16:51:55 reddawg Start of ubixfs shell diff --git a/include/fs.h b/include/fs.h deleted file mode 100644 index efeb44b..0000000 --- a/include/fs.h +++ /dev/null @@ -1,57 +0,0 @@ -/***************************************************************************************** - Copyright (c) 2002-2004 The UbixOS Project - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, are - permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, this list of - conditions, the following disclaimer and the list of authors. Redistributions in binary - form must reproduce the above copyright notice, this list of conditions, the following - disclaimer and the list of authors in the documentation and/or other materials provided - with the distribution. Neither the name of the UbixOS Project 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 COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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. - - $Id$ - -*****************************************************************************************/ - -#ifndef __XFS_H_ -#define __FS_H_ - -#include - -class fsAbstract { - public: - int init(dev_t *); - int read(dev_t *,void *,uInt32,uInt32); - char name[128]; - }; - -#endif - -/*** - $Log$ - Revision 1.4 2004/08/13 17:07:32 reddawg - Works - - Revision 1.3 2004/08/13 16:58:57 reddawg - test - - Revision 1.2 2004/08/13 16:51:55 reddawg - Start of ubixfs shell - - END - ***/ - diff --git a/include/ramdrive.h b/include/ramdrive.h new file mode 100644 index 0000000..e7465f5 --- /dev/null +++ b/include/ramdrive.h @@ -0,0 +1,45 @@ +/***************************************************************************************** + Copyright (c) 2002-2004 The UbixOS Project + All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, are + permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this list of + conditions, the following disclaimer and the list of authors. Redistributions in binary + form must reproduce the above copyright notice, this list of conditions, the following + disclaimer and the list of authors in the documentation and/or other materials provided + with the distribution. Neither the name of the UbixOS Project 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 COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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. + + $Id$ + +*****************************************************************************************/ + +#ifndef __RAMDRIVE_H_ +#define __RAMDRIVE_H_ + +#include +#include + +int dev_ramDestroy(); +dev_t *dev_ramDrive(); + +#endif + +/*** + $Log$ + END + ***/ + diff --git a/include/ubixfs.h b/include/ubixfs.h index bb4944b..e2d1315 100644 --- a/include/ubixfs.h +++ b/include/ubixfs.h @@ -30,12 +30,17 @@ #ifndef __UBIXFS_H_ #define __UBIXFS_H_ -#include +#include +#include + +#define UBIXFS_READ 0x1 class UbixFS : public fsAbstract { public: - int init(dev_t *); - int read(dev_t *,void *,uInt32,uInt32); + virtual int init(dev_t *); + virtual int open(Ubix_FD *,const char *,int); + virtual int read(dev_t *,Ubix_FD *,void *,uInt32,uInt32); + virtual int write(dev_t *,Ubix_FD *,void *,uInt32,uInt32); }; UbixFS *ubixfs_fn(); @@ -44,6 +49,9 @@ /*** $Log$ + Revision 1.5 2004/08/13 17:25:06 reddawg + Testing better + Revision 1.4 2004/08/13 17:07:32 reddawg Works diff --git a/include/vfs.h b/include/vfs.h index df3b7c5..8c9e760 100644 --- a/include/vfs.h +++ b/include/vfs.h @@ -30,31 +30,47 @@ #ifndef __VFS_H_ #define __VFS_H_ +#include #include -#include + +typedef struct Ubix_FD_NODE { + uInt32 length; + } Ubix_FD; + +class fsAbstract { + public: + virtual int init(dev_t *); + virtual int open(Ubix_FD *,const char *,int); + virtual int read(dev_t *,Ubix_FD *,void *,uInt32,uInt32); + virtual int write(dev_t *,Ubix_FD *,void *,uInt32,uInt32); + char name[128]; + }; class vfs { protected: vfs *prev; vfs *next; public: - dev_t *dev; - UbixFS *fs; - int vfs_initFS(); - int vfs_read(void *,uInt32,uInt32); - int vfs_Write(char *,long,long); - int vfs_OpenFile(void *,void *); - int vfs_Unlink(char *,void *); - int vfs_MakeDir(char *,void *); - int vfs_RemDir(char *); - int vfs_Sync(void); - int vfs_Type; + dev_t *dev; + fsAbstract *fs; + int vfs_initFS(); + int vfs_read(Ubix_FD *,void *,uInt32,uInt32); + int vfs_write(Ubix_FD *,void *,uInt32,uInt32); + int vfs_openFile(Ubix_FD *,const char *,int); + int vfs_unlink(char *,void *); + int vfs_makeDir(char *,void *); + int vfs_remDir(char *); + int vfs_sync(void); + int vfs_type; }; #endif /*** $Log$ + Revision 1.3 2004/08/13 17:07:32 reddawg + Works + Revision 1.2 2004/08/13 16:58:57 reddawg test diff --git a/main.cc b/main.cc index cafb33a..8c08b88 100644 --- a/main.cc +++ b/main.cc @@ -27,15 +27,22 @@ *****************************************************************************************/ +#include #include #include #include +#include int main(int argc,char **argv) { char data[512]; + Ubix_FD *test_file = 0x0; + vfs *ubixfs_VFS = new(vfs); + /* make fake data */ + sprintf(data,"blah"); + /* this would really be vfs_find(fs type) */ ubixfs_VFS->fs = ubixfs_fn(); /* this would really be dev_findDev(major,minor); */ @@ -43,12 +50,20 @@ /* this is what is done when we mount */ ubixfs_VFS->vfs_initFS(); + ubixfs_VFS->vfs_openFile(test_file,"fake_file",UBIXFS_READ); + ubixfs_VFS->vfs_write(test_file,data,5,0); + + /* Save our ram disk */ + dev_ramDestroy(); return(0x0); } /*** $Log$ + Revision 1.5 2004/08/13 17:27:08 reddawg + Ok everything is here needed to test + Revision 1.4 2004/08/13 17:25:06 reddawg Testing better diff --git a/ramdrive.cc b/ramdrive.cc index f999307..051f1e8 100644 --- a/ramdrive.cc +++ b/ramdrive.cc @@ -34,7 +34,7 @@ #include -char *ram_data = 0x0; +static char *ram_data = 0x0; static int ramDrive_read(dev_t *dev,void *ptr,uInt32 length,uInt32 offset) { @@ -45,27 +45,64 @@ return(length); } +static int ramDrive_write(dev_t *dev,void *ptr,uInt32 length,uInt32 offset) { + char *data = ram_data + offset; + + memcpy(data,ptr,length); + + return(length); + } + dev_t *dev_ramDrive() { dev_t *ramDrive = 0x0; + + FILE *ramDisk; + + ramDisk = fopen("./ram.dsk","rb"); ramDrive = (dev_t *)malloc(sizeof(dev_t)); ram_data = (char *)malloc(1024 * 1024 * 40); - ram_data[0] = '1'; - ram_data[1] = '2'; - ram_data[2] = '3'; - ram_data[3] = '\0'; + if (ramDisk != 0x0) { + printf("Loaded Ram Disk\n"); + fread(ram_data,1024 * 1024 * 40,1,ramDisk); + fclose(ramDisk); + } + else { + ram_data[0] = '1'; + ram_data[1] = '2'; + ram_data[2] = '3'; + ram_data[3] = '\0'; + } ramDrive->major = 0x1; ramDrive->read = ramDrive_read; + ramDrive->write = ramDrive_write; return(ramDrive); } + +int dev_ramDestroy() { + FILE *ramDisk; + + ramDisk = fopen("./ram.dsk","wb"); + + fwrite(ram_data,1024 * 1024 * 40,1,ramDisk); + + fclose(ramDisk); + + printf("Saved Ram Disk\n"); + + return(0x0); + } /*** $Log$ + Revision 1.5 2004/08/13 17:25:06 reddawg + Testing better + Revision 1.4 2004/08/13 17:07:32 reddawg Works diff --git a/ubixfs.cc b/ubixfs.cc index f141299..f9fcfd7 100644 --- a/ubixfs.cc +++ b/ubixfs.cc @@ -43,12 +43,24 @@ return(0x0); } -int UbixFS::read(dev_t *dev,void *ptr,uInt32 length,uInt32 offset) { +int UbixFS::read(dev_t *dev,Ubix_FD *fd,void *ptr,uInt32 length,uInt32 offset) { printf("UbixFS::read\n"); dev->read(dev,ptr,length,offset); return(length); } +int UbixFS::open(Ubix_FD *fd,const char *name,int mode) { + printf("UbixFS::open\n"); + printf("File: [%s:%i]\n",name,mode); + return(0x0); + } + +int UbixFS::write(dev_t *dev,Ubix_FD *fd,void *ptr,uInt32 length,uInt32 offset) { + printf("UbixFS::write\n"); + dev->write(dev,ptr,length,offset); + return(length); + } + /* This would be like the very top level of the ubixfs driver it sets it up into memory */ UbixFS *ubixfs_fn() { UbixFS *tmpFS = new(UbixFS); @@ -60,6 +72,9 @@ /*** $Log$ + Revision 1.3 2004/08/13 17:25:06 reddawg + Testing better + Revision 1.2 2004/08/13 17:07:32 reddawg Works diff --git a/vfs.cc b/vfs.cc index 32e6fb1..66c8617 100644 --- a/vfs.cc +++ b/vfs.cc @@ -37,12 +37,23 @@ return(0x0); } -int vfs::vfs_read(void *ptr,uInt32 length,uInt32 offset) { - return(fs->read(dev,ptr,length,offset)); +int vfs::vfs_read(Ubix_FD *fd,void *ptr,uInt32 length,uInt32 offset) { + return(fs->read(dev,fd,ptr,length,offset)); } +int vfs::vfs_write(Ubix_FD *fd,void *ptr,uInt32 length,uInt32 offset) { + return(fs->write(dev,fd,ptr,length,offset)); + } + +int vfs::vfs_openFile(Ubix_FD *fd,const char *file,int mode) { + return(fs->open(fd,file,mode)); + } + /*** $Log$ + Revision 1.4 2004/08/13 17:07:32 reddawg + Works + Revision 1.3 2004/08/13 16:58:57 reddawg test