diff --git a/src/sys/devfs/devfs.c b/src/sys/devfs/devfs.c index 85ae750..ea3eefd 100644 --- a/src/sys/devfs/devfs.c +++ b/src/sys/devfs/devfs.c @@ -29,7 +29,6 @@ #include #include -#include #include #include #include @@ -41,7 +40,7 @@ /* Spinlock for devfs we should start converting to sem/mutex */ static spinLock_t devfsSpinLock = SPIN_LOCK_INITIALIZER; -static void devfs_initialize(struct mountPoints *mp) { +static void devfs_initialize(vfs_mountPoint_t *mp) { struct devfs_info *fsInfo = 0x0; /* Allocate memory for the fsInfo */ @@ -149,13 +148,13 @@ int devfs_makeNode(char *name,uInt8 type,uInt16 major,uInt16 minor) { - struct mountPoints *mp = 0x0; + vfs_mountPoint_t *mp = 0x0; struct devfs_info *fsInfo = 0x0; struct devfs_devices *tmpDev = 0x0; spinLock(&devfsSpinLock); - mp = findMount("devfs"); + mp = vfs_findMount("devfs"); if (mp == 0x0) { kprintf("Error: Can't Find Mount Point\n"); @@ -205,7 +204,7 @@ return(0x1); } /* Mount our devfs this will build the devfs container node */ - mount(0x0,0x0,0x0,0x1,"devfs","rw"); // Mount Device File System + vfs_mount(0x0,0x0,0x0,0x1,"devfs","rw"); // Mount Device File System /* Return */ return(0x0); @@ -213,6 +212,18 @@ /*** $Log$ + Revision 1.14 2004/07/21 10:02:09 reddawg + devfs: renamed functions + device system: renamed functions + fdc: fixed a few potential bugs and cleaned up some unused variables + strol: fixed definition + endtask: made it print out freepage debug info + kmalloc: fixed a huge memory leak we had some unhandled descriptor insertion so some descriptors were lost + ld: fixed a pointer conversion + file: cleaned up a few unused variables + sched: broke task deletion + kprintf: fixed ogPrintf definition + Revision 1.13 2004/07/20 22:42:34 reddawg Fixed up any bugs I could find now to move onto bigger things diff --git a/src/sys/include/ubixfs/ubixfs.h b/src/sys/include/ubixfs/ubixfs.h index df8588a..f68e28c 100644 --- a/src/sys/include/ubixfs/ubixfs.h +++ b/src/sys/include/ubixfs/ubixfs.h @@ -31,18 +31,19 @@ #define _UBIXFS_H #include -#include +#include #include #include #include -#define UBIXFS_ALIGN_SIZE 0x1000 -#define UBIXFS_ALIGN(size) (size + ((((size) % UBIXFS_ALIGN_SIZE) == 0)? 0 : (UBIXFS_ALIGN_SIZE - ((size) % UBIXFS_ALIGN_SIZE)))) + +#define UBIXFS_BLOCKSIZE_BYTES blockSize*512 +#define UBIXFS_ALIGN(size) (size + ((((size) % UBIXFS_BLOCKSIZE_BYTES) == 0)? 0 : (UBIXFS_BLOCKSIZE_BYTES - ((size) % UBIXFS_BLOCKSIZE_BYTES)))) #define UBIXDISKMAGIC ((uInt32)0x45) /* The disk magic number */ #define MAXUBIXPARTITIONS 16 #define blockSize 8 -#define blockByteSize blockSize*512 + #define EOBC -1 @@ -137,27 +138,33 @@ int readFile(char *file); int writeFileByte(int ch,fileDescriptor *fd,long offset); -int openFileUbixFS(char *file,fileDescriptor *fd); +//int openFileUbixFS(char *file,fileDescriptor *fd); int getFreeBlocks(int count,fileDescriptor *fd); //extern struct ubixDiskLabel *diskLabel; //Good Functions -void initUbixFS(struct mountPoints *mp); -int ubixfs_init(); +//void initUbixFS(struct mountPoints *mp); + int readUbixFS(fileDescriptor *fd,char *data,long offset,long size); int writeUbixFS(fileDescriptor *fd,char *data,long offset,long size); -void syncBat(struct mountPoints *mp); +void syncBat(vfs_mountPoint_t *mp); int freeBlocks(int block,fileDescriptor *fd); int addDirEntry(struct directoryEntry *dir,fileDescriptor *fd); -void ubixFSUnlink(char *path,struct mountPoints *mp); +void ubixFSUnlink(char *path,vfs_mountPoint_t *mp); int ubixFSmkDir(char *dir,fileDescriptor *fd); -void ubixFS_Thread(); +int ubixfs_init(); +int ubixfs_initialize(); +void ubixfs_thread(); + #endif /*** $Log$ + Revision 1.17 2004/07/22 22:37:03 reddawg + Caching is working now the FS is extremely fast but needs to be optimized to do 32bit copies over 8bit + Revision 1.16 2004/07/20 21:28:16 flameshadow oops diff --git a/src/sys/include/ubixos/vitals.h b/src/sys/include/ubixos/vitals.h index d3ca05a..12eaf8f 100644 --- a/src/sys/include/ubixos/vitals.h +++ b/src/sys/include/ubixos/vitals.h @@ -43,7 +43,7 @@ uInt32 dQuantum; uInt32 freePages; struct fileSystem *fileSystems; - struct mountPoints *mountPoints; + vfs_mountPoint_t *mountPoints; uInt32 timeStart; void *screen; void *font; @@ -59,6 +59,10 @@ /*** $Log$ + Revision 1.5 2004/07/09 13:03:50 reddawg + vitals: named vitalsInit to vitals_init + Adjusted Startup Routines + Revision 1.4 2004/06/18 13:01:47 solar Added nice and timeSlice members to the kTask_t type diff --git a/src/sys/include/vfs/file.h b/src/sys/include/vfs/file.h index 32ba8c4..0fb7c8b 100644 --- a/src/sys/include/vfs/file.h +++ b/src/sys/include/vfs/file.h @@ -25,7 +25,7 @@ #define _FILE_H #include -#include +#include #define SEEK_SET 0x0 @@ -33,6 +33,22 @@ char *cwd; }; +typedef struct fileDescriptorStruct { + struct fileDescriptorStruct *prev; + struct fileDescriptorStruct *next; + vfs_mountPoint_t *mp; + uInt16 status; + uInt16 mode; + uInt32 offset; + uInt32 size; + uInt16 length; + uInt32 start; + uInt8 fileName[512]; + char *buffer; + uInt32 dirBlock; + uInt32 perms; + } fileDescriptor; + typedef struct userFileDescriptorStruct { struct fileDescriptorStruct *fd; uInt32 fdSize; diff --git a/src/sys/include/vfs/mount.h b/src/sys/include/vfs/mount.h index 05dc3e7..f047c88 100644 --- a/src/sys/include/vfs/mount.h +++ b/src/sys/include/vfs/mount.h @@ -32,21 +32,21 @@ #include -struct mountPoints { - struct mountPoints *prev; - struct mountPoints *next; - struct fileSystem *fs; +typedef struct vfs_mountPoint { + struct vfs_mountPoint *prev; + struct vfs_mountPoint *next; + struct fileSystem *fs; struct device_node *device; struct ubixDiskLabel *diskLabel; void *fsInfo; int partition; char mountPoint[1024]; char perms; - }; + } vfs_mountPoint_t; -int mount(int major,int minor,int partition,int fsType,char *mountPoint,char *perms); -int addMount(struct mountPoints *mp); -struct mountPoints *findMount(char *mountPoint); +int vfs_mount(int major,int minor,int partition,int fsType,char *mountPoint,char *perms); +int vfs_addMount(vfs_mountPoint_t *mp); +vfs_mountPoint_t *vfs_findMount(char *mountPoint); #endif diff --git a/src/sys/include/vfs/vfs.h b/src/sys/include/vfs/vfs.h index 8ba5778..2a58ecc 100644 --- a/src/sys/include/vfs/vfs.h +++ b/src/sys/include/vfs/vfs.h @@ -1,30 +1,38 @@ -/************************************************************************************** - Copyright (c) 2002 The UbixOS Project +/***************************************************************************************** + 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: + 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. + 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. + 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 _VFS_H #define _VFS_H #include +#include +#include #define maxFd 32 #define fdAvail 1 @@ -38,22 +46,6 @@ #define fileBinary 0x0004 #define fileAppend 0x0008 -typedef struct fileDescriptorStruct { - struct fileDescriptorStruct *prev; - struct fileDescriptorStruct *next; - struct mountPoints *mp; - uInt16 status; - uInt16 mode; - uInt32 offset; - uInt32 size; - uInt16 length; - uInt32 start; - uInt8 fileName[512]; - char *buffer; - uInt32 dirBlock; - uInt32 perms; - } fileDescriptor; - struct fileSystem { struct fileSystem *prev; struct fileSystem *next; @@ -86,3 +78,8 @@ #endif +/*** + $Log$ + END + ***/ + diff --git a/src/sys/init/main.c b/src/sys/init/main.c index 34b03d4..e1b7f99 100644 --- a/src/sys/init/main.c +++ b/src/sys/init/main.c @@ -89,14 +89,14 @@ } } - if (mount(0x0,0x0,0x0,0x0,"sys","rw") != 0x0) { + if (vfs_mount(0x0,0x0,0x0,0x0,"sys","rw") != 0x0) { kprintf("Problem Mounting sys Mount Point\n"); } - if (mount(0x0,0x0,0x1,0x0,"tmp","rw") != 0x0) { + if (vfs_mount(0x0,0x0,0x1,0x0,"tmp","rw") != 0x0) { kprintf("Problem Mounting tmp Mount Point\n"); } /* - if (mount(0x1,0x1,0x0,0x0,"hd","rw") != 0x0) { + if (vfs_mount(0x1,0x1,0x0,0x0,"hd","rw") != 0x0) { kprintf("Problem Mounting HD Mount Point\n"); } */ @@ -113,6 +113,12 @@ /*** $Log$ + Revision 1.61 2004/07/21 23:05:05 reddawg + last round of fixed + main.c: removed kernel stack + start.S: added kernel stack thanks to tip off from BJ about .comm + init.h: re-enabled ipStack + Revision 1.60 2004/07/21 22:01:24 reddawg Fixed diff --git a/src/sys/isa/atkbd.c b/src/sys/isa/atkbd.c index d75bf3a..d0c81f2 100644 --- a/src/sys/isa/atkbd.c +++ b/src/sys/isa/atkbd.c @@ -29,6 +29,7 @@ #include #include +#include #include #include #include @@ -181,6 +182,8 @@ void keyboardHandler() { unsigned int key = inportByte(0x60); + if (key > 255) + return; /* Control Key */ if (key == 0x1D && !(controlKeys & controlKey)) { @@ -280,6 +283,9 @@ /*** $Log$ + Revision 1.7 2004/07/22 20:53:07 reddawg + atkbd: fixed problem + Revision 1.6 2004/07/09 13:34:51 reddawg keyboard: keyboardInit to atkbd_init Adjusted initialization routines diff --git a/src/sys/ubixfs/block.c b/src/sys/ubixfs/block.c index 14e474b..edb467c 100644 --- a/src/sys/ubixfs/block.c +++ b/src/sys/ubixfs/block.c @@ -24,6 +24,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. $Log$ + Revision 1.4 2004/06/04 10:19:42 reddawg + notes: we compile again, thank g-d anyways i was about to cry + Revision 1.3 2004/05/19 15:20:06 reddawg Fixed reference problems due to changes in drive subsystem @@ -48,7 +51,7 @@ #include -void syncBat(struct mountPoints *mp) { +void syncBat(vfs_mountPoint_t *mp) { struct ubixFSInfo *fsInfo = mp->fsInfo; mp->device->devInfo->write(mp->device->devInfo->info,fsInfo->blockAllocationTable,mp->diskLabel->partitions[mp->partition].pOffset,mp->diskLabel->partitions[mp->partition].pBatSize); } diff --git a/src/sys/ubixfs/directory.c b/src/sys/ubixfs/directory.c index 7d5843b..87d5e61 100644 --- a/src/sys/ubixfs/directory.c +++ b/src/sys/ubixfs/directory.c @@ -1,58 +1,27 @@ /***************************************************************************************** - Copyright (c) 2002 The UbixOS Project + 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: + 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. + 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. - - $Log$ - Revision 1.8 2004/06/29 03:59:47 reddawg - Fixed a few issues with subdirectories they are working much better now - - Revision 1.7 2004/06/28 23:12:58 reddawg - file format now container:/path/to/file - - Revision 1.6 2004/06/04 13:20:22 reddawg - ubixFSmkDir(): played with it a bit to see if it still worked - - Revision 1.5 2004/06/04 10:19:42 reddawg - notes: we compile again, thank g-d anyways i was about to cry - - Revision 1.4 2004/05/19 15:20:06 reddawg - Fixed reference problems due to changes in drive subsystem - - Revision 1.3 2004/05/19 04:07:43 reddawg - kmalloc(size,pid) no more it is no kmalloc(size); the way it should of been - - Revision 1.2 2004/04/28 02:22:55 reddawg - This is a fiarly large commit but we are starting to use new driver model - all around - - Revision 1.1.1.1 2004/04/15 12:07:07 reddawg - UbixOS v1.0 - - Revision 1.6 2004/04/13 16:36:34 reddawg - Changed our copyright, it is all now under a BSD-Style license - - + 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$ @@ -133,11 +102,11 @@ block = getFreeBlocks(1,fd); if (block != 0x0) { - dir = (struct directoryEntry *)kmalloc(blockByteSize); + dir = (struct directoryEntry *)kmalloc(UBIXFS_BLOCKSIZE_BYTES); entry = (struct directoryEntry *)kmalloc(sizeof(struct directoryEntry)); entry->startCluster = block; - entry->size = blockByteSize; + entry->size = UBIXFS_BLOCKSIZE_BYTES; entry->attributes = typeDirectory; entry->permissions = 0xEAA; sprintf(entry->fileName,directory); @@ -155,5 +124,39 @@ } /*** + $Log$ + Revision 1.9 2004/07/16 20:17:29 flameshadow + chg: broke the ufs stuff + chg: changed vfsRegisterFS() to accept a fileSystem struct + chg: modified calls to vfsRegisterFS() to pass fileSystem struct + + Revision 1.8 2004/06/29 03:59:47 reddawg + Fixed a few issues with subdirectories they are working much better now + + Revision 1.7 2004/06/28 23:12:58 reddawg + file format now container:/path/to/file + + Revision 1.6 2004/06/04 13:20:22 reddawg + ubixFSmkDir(): played with it a bit to see if it still worked + + Revision 1.5 2004/06/04 10:19:42 reddawg + notes: we compile again, thank g-d anyways i was about to cry + + Revision 1.4 2004/05/19 15:20:06 reddawg + Fixed reference problems due to changes in drive subsystem + + Revision 1.3 2004/05/19 04:07:43 reddawg + kmalloc(size,pid) no more it is no kmalloc(size); the way it should of been + + Revision 1.2 2004/04/28 02:22:55 reddawg + This is a fiarly large commit but we are starting to use new driver model + all around + + Revision 1.1.1.1 2004/04/15 12:07:07 reddawg + UbixOS v1.0 + + Revision 1.6 2004/04/13 16:36:34 reddawg + Changed our copyright, it is all now under a BSD-Style license + END ***/ diff --git a/src/sys/ubixfs/thread.c b/src/sys/ubixfs/thread.c index 20a7cf1..25723f0 100755 --- a/src/sys/ubixfs/thread.c +++ b/src/sys/ubixfs/thread.c @@ -1,27 +1,27 @@ /***************************************************************************************** - Copyright (c) 2002 The UbixOS Project + 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: + 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. + 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. + 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$ @@ -29,13 +29,14 @@ #include #include +#include #include static struct { int mounts; } ubixFS_Info; -void ubixFS_Thread() { +void ubixfs_thread(vfs_mountPoint_t *mp) { mpiMessage_t myMsg; ubixFS_Info.mounts = 0; @@ -56,5 +57,8 @@ /*** $Log$ + Revision 1.1 2004/06/28 18:12:44 reddawg + We need these files + END ***/ diff --git a/src/sys/ubixfs/ubixfs.c b/src/sys/ubixfs/ubixfs.c index ed280b6..1d854cd 100644 --- a/src/sys/ubixfs/ubixfs.c +++ b/src/sys/ubixfs/ubixfs.c @@ -29,10 +29,7 @@ #include #include -#include -#include -#include -#include +#include #include #include #include @@ -41,140 +38,16 @@ #include #include #include -#include -int -ubixfs_init() { +/* Static defines */ +static int ubixfs_loadData(fileDescriptor *fd,char *data,uInt32 size,uInt32 batIndex); - struct fileSystem ubixFileSystem = - {NULL, /* prev */ - NULL, /* next */ - (void *)initUbixFS, /* vfsInitFS */ - (void *)readUbixFS, /* vfsRead */ - (void *)writeUbixFS, /* vfsWrite */ - (void *)openFileUbixFS, /* vfsOpenFile */ - (void *)ubixFSUnlink, /* vfsUnlink */ - (void *)ubixFSmkDir, /* vfsMakeDir */ - NULL, /* vfsRemDir */ - NULL, /* vfsSync */ - 0 /* vfsType */ - }; /* ubixFileSystem */ - - /* Add UbixFS */ -/* mji - * if (vfsRegisterFS(0, initUbixFS, readUbixFS, writeUbixFS, openFileUbixFS, - * ubixFSUnlink, ubixFSmkDir, 0x0, 0x0) != 0x0) { - */ - if (vfsRegisterFS(ubixFileSystem) != 0x0) { - kpanic("Unable To Enable UbixFS"); - return(0x1); - } - - /* Start Up The UbixFS Thread Which Will Manage All The Mounted - * UbixFS Partitions - */ - execThread(ubixFS_Thread,(uInt32)(kmalloc(0x2000)+0x2000),0x0); - /* Return */ - return(0x0); - } -void -initUbixFS(struct mountPoints *mp) { - struct ubixFSInfo *fsInfo = 0x0; - int size; - - assert(mp); - assert(mp->diskLabel); - assert(mp->diskLabel->partitions); - - mp->fsInfo = (struct ubixFSInfo *)kmalloc(sizeof(struct ubixFSInfo)); - - fsInfo = mp->fsInfo; - fsInfo->rootDir = 0x0; - //mp->diskLabel->partitions[mp->partition].pOffset -= 63; - if ((mp->diskLabel->magicNum == UBIXDISKMAGIC) && - (mp->diskLabel->magicNum2 == UBIXDISKMAGIC)) { - size = mp->diskLabel->partitions[mp->partition].pBatSize * 512; - fsInfo->blockAllocationTable = (struct blockAllocationTableEntry *)kmalloc(size); - - /* fsInfo->blockAllocationTable[0].nextBlock = 100; */ - size = (mp->diskLabel->partitions[mp->partition].pBatSize*512) / sizeof(struct blockAllocationTableEntry); - fsInfo->batEntries = size; - - assert(mp->device->devInfo->read); - - mp->device->devInfo->read(mp->device->devInfo->info, - fsInfo->blockAllocationTable, - mp->diskLabel->partitions[mp->partition].pOffset, - mp->diskLabel->partitions[mp->partition].pBatSize); - -/* mji */ - fsInfo->dirCache = ubixfs_cacheNew("/"); - assert(fsInfo->dirCache); - fsInfo->dirCache->present = 1; - fsInfo->dirCache->size = 0x4000; - fsInfo->dirCache->startCluster = fsInfo->rootDir; - -/* mji */ - fsInfo->dirCache->info = (struct directoryEntry *)kmalloc(0x4000); /* allocate root dir */ -kprintf("\ncaching root dir [%i]\n",fsInfo->rootDir); - mp->device->devInfo->read(mp->device->devInfo->info, - fsInfo->dirCache->info, - (mp->diskLabel->partitions[mp->partition].pOffset+fsInfo->blockAllocationTable[fsInfo->rootDir].realSector), - 0x4000 / 512); - -/* mji */ - //UBU dircache the ubixfs fs info struct fsInfo ->(pointer to) your rootdir thing like fsInfo->rootDirCache=ubixfs_cacheNode(blah); - kprintf(" Offset: [%i], Partition: [%i]\n", - mp->diskLabel->partitions[mp->partition].pOffset,mp->partition); - kprintf("UbixFS Initialized\n"); - } - else { - kprintf("Insert System Disk!\n"); - while (1); - initUbixFS(mp); - } - /* Return */ - return; - } - -/*UBU*/ -static int ubixfs_loadData(fileDescriptor *fd,char *data,uInt32 size,uInt32 batIndex) { - long i = 0x0; - - struct ubixFSInfo *fsInfo = NULL; - - assert(fd); - assert(fd->mp); - assert(fd->mp->fsInfo); - - fsInfo = fd->mp->fsInfo; - - /* If The File Size Is Greater Then The Offset Lets Goto Work */ - - size += 4095; - for (i=0x0; i fd->size) { - /* Set File EOF If There Is Nothing To Do */ - fd->status = fdEof; - return(size); - } - if (i != 0x0) - batIndex = fsInfo->blockAllocationTable[batIndex].nextBlock;; - - fd->mp->device->devInfo->read(fd->mp->device->devInfo->info,data+i,fd->mp->diskLabel->partitions[fd->mp->partition].pOffset+fsInfo->blockAllocationTable[batIndex].realSector,blockSize); - } - /* Return */ - return(size); - } - -int -openFileUbixFS(char *file, fileDescriptor *fd) { - int x = 0; +static int openFileUbixFS(char *file, fileDescriptor *fd) { + //int x = 0; /* mji struct directoryEntry *dirEntry = (struct directoryEntry *)kmalloc(0x4000); */ struct cacheNode * cacheNode = NULL; - struct directoryEntry * dirEntry = NULL; + //struct directoryEntry * dirEntry = NULL; struct ubixFSInfo *fsInfo = fd->mp->fsInfo; //kprintf("openFileUbixFS(%s), cwd: %s\n", file, _current->oInfo.cwd); @@ -187,20 +60,40 @@ assert(fd->mp->device->devInfo->read); assert(fsInfo); assert(fsInfo->dirCache); + + /* + UBU + + I did not like the order in which things happened here so let me fix it :) + + */ + + /* + UBU do { + */ cacheNode = ubixfs_cacheFind(fsInfo->dirCache, file); if (cacheNode == NULL) return 0; + /* + UBU if (cacheNode->present == 1) break; + */ /* one level of the cache wasn't loaded */ + /* + UBU if (cacheNode->size != 0 && cacheNode->info == NULL) { kprintf("allocating space for %s\n", cacheNode->name); cacheNode->info = kmalloc(UBIXFS_ALIGN(cacheNode->size)); - fd->size = cacheNode->size; //UBU do we need this anymopre or can we change things + fd->size = cacheNode->size; */ /* UBU what is the best way to keep these in sync? */ + /* + UBU ubixfs_loadData(fd,cacheNode->info,cacheNode->size,cacheNode->startCluster); cacheNode->present = 1; - } /* if */ + } */ /* if */ + /* + UBU } while (1); - + */ assert(cacheNode); if (cacheNode == NULL) return 0; @@ -209,7 +102,12 @@ fd->size = cacheNode->size; fd->perms = cacheNode->permissions; fd->dirBlock = 0x0; /* Directory Start Sector */ - return 1; + if (cacheNode->size != 0x0 && cacheNode->info == NULL) { + cacheNode->info = kmalloc(UBIXFS_ALIGN(cacheNode->size)); + ubixfs_loadData(fd,cacheNode->info,cacheNode->size,cacheNode->startCluster); + cacheNode->present = 0x1; + } + return(0x1); } else if ((fd->mode & fileWrite) == fileWrite) { @@ -275,8 +173,7 @@ #endif } -int -writeFileByte(int ch, fileDescriptor *fd, long offset) { +int writeFileByte(int ch, fileDescriptor *fd, long offset) { int blockCount = 0x0,batIndex = 0x0,batIndexPrev = 0x0,i = 0x0; struct directoryEntry *dirEntry = 0x0; @@ -386,7 +283,7 @@ Notes: ************************************************************************/ -int readUbixFS_old(fileDescriptor *fd,char *data,long offset,long size) { +static int readUbixFS_old(fileDescriptor *fd,char *data,long offset,long size) { int blockCount = 0x0; int batIndex; long i = 0x0; @@ -512,8 +409,7 @@ return(size); } -void -ubixFSUnlink(char *path,struct mountPoints *mp) { +void ubixFSUnlink(char *path,vfs_mountPoint_t *mp) { int x=0; struct directoryEntry *dirEntry = (struct directoryEntry *)kmalloc(0x1000); struct ubixFSInfo *fsInfo = mp->fsInfo; @@ -531,9 +427,160 @@ kprintf("File Not Found\n"); return; } + + +/***************************************************************************************** + +Function: static + int ubixfs_loadData(fileDescriptor *fd,char *data,uInt32 size,uInt32 batIndex) + +Description: This will load the node data in from the disk + +Notes: + 07/23/2004 - This loads complete blocks from disk so it is aligned to 0x1000 not the + actual file size + +*****************************************************************************************/ +static int ubixfs_loadData(fileDescriptor *fd,char *data,uInt32 size,uInt32 batIndex) { + int i = 0x0; + + struct ubixFSInfo *fsInfo = NULL; + + assert(fd); + assert(fd->mp); + assert(fd->mp->fsInfo); + + fsInfo = fd->mp->fsInfo; + + size = UBIXFS_ALIGN(size); + /* Loop by block size */ + + for (i=0x0; iblockAllocationTable[batIndex].nextBlock; + /* Read data in from media */ + fd->mp->device->devInfo->read(fd->mp->device->devInfo->info,data+i,fd->mp->diskLabel->partitions[fd->mp->partition].pOffset+fsInfo->blockAllocationTable[batIndex].realSector,blockSize); + } + /* Return */ + return(0x0); + } + + +/***************************************************************************************** + +Function: int ubixfs_initialize() + +Description: This will initialize a mount point it loads the BAT and Caches the rootDir + +Notes: + +*****************************************************************************************/ +int ubixfs_initialize(vfs_mountPoint_t *mp) { + struct ubixFSInfo *fsInfo = 0x0; + + assert(mp); + assert(mp->diskLabel); + assert(mp->diskLabel->partitions); + + mp->fsInfo = (struct ubixFSInfo *)kmalloc(sizeof(struct ubixFSInfo)); + assert(mp->fsInfo); + + fsInfo = mp->fsInfo; + fsInfo->rootDir = 0x0; /* Root directory is always 0x0 on the UbixFS */ + + /* + Check the disk label to ensure this is an UbixFS partition + */ + if ((mp->diskLabel->magicNum == UBIXDISKMAGIC) && (mp->diskLabel->magicNum2 == UBIXDISKMAGIC)) { + + /* Allocate memory for BAT */ + fsInfo->blockAllocationTable = (struct blockAllocationTableEntry *)kmalloc(mp->diskLabel->partitions[mp->partition].pBatSize * 512); + assert(fsInfo->blockAllocationTable); + + /* Set up the amount of BAT entries */ + fsInfo->batEntries = (mp->diskLabel->partitions[mp->partition].pBatSize*512) / sizeof(struct blockAllocationTableEntry); + + /* Read the BAT to memory */ + assert(mp->device->devInfo->read); + mp->device->devInfo->read(mp->device->devInfo->info, + fsInfo->blockAllocationTable, + mp->diskLabel->partitions[mp->partition].pOffset, + mp->diskLabel->partitions[mp->partition].pBatSize); + + /* Set up root directory cache */ + fsInfo->dirCache = ubixfs_cacheNew("/"); + assert(fsInfo->dirCache); + fsInfo->dirCache->present = 1; + fsInfo->dirCache->size = 0x4000; + fsInfo->dirCache->startCluster = fsInfo->rootDir; + fsInfo->dirCache->info = (struct directoryEntry *)kmalloc(0x4000); /* allocate root dir */ + assert(fsInfo->dirCache->info); + /* Read root dir in from disk it is always 0x4000 bytes long */ + mp->device->devInfo->read(mp->device->devInfo->info, + fsInfo->dirCache->info, + (mp->diskLabel->partitions[mp->partition].pOffset+fsInfo->blockAllocationTable[fsInfo->rootDir].realSector), + 0x4000 / 512); + + /* Start our ubixfs_thread to manage the mount point */ + /* + UBU disable for now + execThread(ubixfs_Thread,(uInt32)(kmalloc(0x2000)+0x2000),0x0); + */ + kprintf(" Offset: [%i], Partition: [%i]\n", + mp->diskLabel->partitions[mp->partition].pOffset,mp->partition); + kprintf("UbixFS Initialized\n"); + return(0x1); + } + + kprintf("Not a valid UbixFS disk.\n"); + /* Return */ + return(0x0); + } + +/***************************************************************************************** + +Function: int ubixfs_init() + +Description: This is the master initialization for the Ubix File System it will make the + OS UbixFS aware. + It does not in any way shape or form connect a mount point an medium that is + upto the ubixfs_initialize() function + +Notes: + +*****************************************************************************************/ +int ubixfs_init() { + /* Set up our file system structure */ + struct fileSystem ubixFileSystem = + {NULL, /* prev */ + NULL, /* next */ + (void *)ubixfs_initialize, /* vfsInitFS */ + (void *)readUbixFS, /* vfsRead */ + (void *)writeUbixFS, /* vfsWrite */ + (void *)openFileUbixFS, /* vfsOpenFile */ + (void *)ubixFSUnlink, /* vfsUnlink */ + (void *)ubixFSmkDir, /* vfsMakeDir */ + NULL, /* vfsRemDir */ + NULL, /* vfsSync */ + 0 /* vfsType */ + }; /* ubixFileSystem */ + + /* Add UbixFS */ + if (vfsRegisterFS(ubixFileSystem) != 0x0) { + kpanic("Unable To Enable UbixFS"); + return(0x1); + } + + /* Return */ + return(0x0); + } /*** $Log$ + Revision 1.32 2004/07/22 23:01:51 reddawg + Ok checking in before I sleep + Revision 1.31 2004/07/22 22:37:03 reddawg Caching is working now the FS is extremely fast but needs to be optimized to do 32bit copies over 8bit diff --git a/src/sys/vfs/file.c b/src/sys/vfs/file.c index 207555e..2832d14 100644 --- a/src/sys/vfs/file.c +++ b/src/sys/vfs/file.c @@ -130,15 +130,15 @@ int unlink(const char *node) { char *path = 0x0,*mountPoint = 0x0; - struct mountPoints *mp = 0x0; + vfs_mountPoint_t *mp = 0x0; path = (char *)strtok((char *)node,"@"); mountPoint = strtok(NULL,"\n"); if (mountPoint == 0x0) { - mp = findMount("sys"); /* _current->oInfo.container; */ + mp = vfs_findMount("sys"); /* _current->oInfo.container; */ } else { - mp = findMount(mountPoint); + mp = vfs_findMount(mountPoint); } if (mp == 0x0) { //kpanic("Mount Point Bad"); @@ -166,7 +166,7 @@ /* Allocate Memory For File Descriptor */ tmpFd = (fileDescriptor *)kmalloc(sizeof(fileDescriptor)); - path = &tmpFd->fileName; + path = tmpFd->fileName; if (strstr(file,":")) { mountPoint = (char *)strtok((char *)file,":"); sprintf(path,strtok(NULL,"\n")); @@ -186,10 +186,10 @@ i = 0; if (mountPoint == 0x0) { - tmpFd->mp = findMount("sys"); /* _current->oInfo.container; */ + tmpFd->mp = vfs_findMount("sys"); /* _current->oInfo.container; */ } else { - tmpFd->mp = findMount(mountPoint); + tmpFd->mp = vfs_findMount(mountPoint); } if (tmpFd->mp == 0x0) { //kpanic("Mount Point Bad"); @@ -261,6 +261,9 @@ /*** $Log$ + Revision 1.12 2004/07/22 22:37:03 reddawg + Caching is working now the FS is extremely fast but needs to be optimized to do 32bit copies over 8bit + Revision 1.11 2004/07/22 19:43:36 reddawg ok we are absolute now...... ? diff --git a/src/sys/vfs/mount.c b/src/sys/vfs/mount.c index 3284946..4294d11 100644 --- a/src/sys/vfs/mount.c +++ b/src/sys/vfs/mount.c @@ -43,12 +43,12 @@ Notes: ************************************************************************/ -int mount(int major,int minor,int partition,int vfsType,char *mountPoint,char *perms) { - struct mountPoints *mp = 0x0; +int vfs_mount(int major,int minor,int partition,int vfsType,char *mountPoint,char *perms) { + vfs_mountPoint_t *mp = 0x0; struct device_node *device = 0x0; /* Allocate Memory For Mount Point */ - mp = (struct mountPoints *)kmalloc(sizeof(struct mountPoints)); + mp = (vfs_mountPoint_t *)kmalloc(sizeof(vfs_mountPoint_t)); /* Copy Mount Point Into Buffer */ sprintf(mp->mountPoint,mountPoint); @@ -73,7 +73,7 @@ return(0x1); } /* Add Mountpoint If It Fails Free And Return */ - if (addMount(mp) != 0x0) { + if (vfs_addMount(mp) != 0x0) { kfree(mp); return(0x1); } @@ -88,14 +88,14 @@ /************************************************************************ -Function: addMount(struct mountPoints *mp) +Function: vfs_addMount(vfs_mountPoint_t *mp) Description: This function adds a mount point to the system Notes: ************************************************************************/ -int addMount(struct mountPoints *mp) { +int vfs_addMount(vfs_mountPoint_t *mp) { /* If There Are No Existing Mounts Make It The First */ if (systemVitals->mountPoints == 0x0) { @@ -115,15 +115,15 @@ /************************************************************************ -Function: findMount(char *mountPoint) +Function: vfs_findMount(char *mountPoint) Description: This function finds a particular mount point Notes: ************************************************************************/ -struct mountPoints *findMount(char *mountPoint) { - struct mountPoints *tmpMp = 0x0; +vfs_mountPoint_t *vfs_findMount(char *mountPoint) { + vfs_mountPoint_t *tmpMp = 0x0; for (tmpMp=systemVitals->mountPoints;tmpMp;tmpMp=tmpMp->next) { if (strcmp(tmpMp->mountPoint,mountPoint) == 0x0) { @@ -136,6 +136,18 @@ /*** $Log$ + Revision 1.8 2004/07/21 10:02:09 reddawg + devfs: renamed functions + device system: renamed functions + fdc: fixed a few potential bugs and cleaned up some unused variables + strol: fixed definition + endtask: made it print out freepage debug info + kmalloc: fixed a huge memory leak we had some unhandled descriptor insertion so some descriptors were lost + ld: fixed a pointer conversion + file: cleaned up a few unused variables + sched: broke task deletion + kprintf: fixed ogPrintf definition + Revision 1.7 2004/06/28 23:12:58 reddawg file format now container:/path/to/file