diff --git a/src/sys/include/sys/device.h b/src/sys/include/sys/device.h index 08938bd..3c88a8f 100644 --- a/src/sys/include/sys/device.h +++ b/src/sys/include/sys/device.h @@ -1,25 +1,31 @@ -/************************************************************************************** - 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 _DEVICE_H #define _DEVICE_H @@ -27,12 +33,16 @@ #include struct deviceNode { - struct deviceNode *prev; - struct deviceNode *next; - char type; - int major; - int minor; - uInt32 size; + struct deviceNode *prev; + struct deviceNode *next; + struct deviceInterface *devInfo; + char type;; + int minor; + uInt32 size; + }; + +struct deviceInterface { + int major; void *info; void (*read)(void *,void *,uInt32,uInt32); void (*write)(void *,void *,uInt32,uInt32); @@ -45,7 +55,7 @@ }; -void deviceAdd(int major,int minor,char type,void *read,void *write,void *reset,void *init,void *ioctl,void *stop,void *start,void *standby,void *info); +int deviceAdd(int,struct deviceInterface *); struct deviceNode *deviceFind(int major,int minor); #endif diff --git a/src/sys/sys/device.c b/src/sys/sys/device.c index 8311534..3b91985 100644 --- a/src/sys/sys/device.c +++ b/src/sys/sys/device.c @@ -1,36 +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.2 2004/04/27 12:05:12 reddawg - Updates To Driver Subsystem - - Revision 1.1 2004/04/27 03:49:41 reddawg - Start of new driver system - - + 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$ @@ -39,38 +30,63 @@ #include #include +/* Linked list of drivers loaded in the system accessable by the subsystem only */ static struct deviceNode *devices = 0x0; -void deviceAdd(int major,int minor,char type,void *read,void *write,void *reset,void *init,void *ioctl,void *stop,void *start,void *standby,void *info) { +/***************************************************************************************** + + Function: int deviceAdd(int minor,struct deviceInterface *devInfo); + + Description: This will add a device to the system + + Notes: + + 05/19/2004 - Improving Upon the spec + +*****************************************************************************************/ +int deviceAdd(int minor,struct deviceInterface *devInfo) { struct deviceNode *tmpDev = kmalloc(sizeof(struct deviceNode)); tmpDev->prev = 0x0; - tmpDev->major = major; tmpDev->minor = minor; tmpDev->type = type; - tmpDev->read = read; - tmpDev->write = write; - tmpDev->reset = reset; - tmpDev->init = init; - tmpDev->ioctl = ioctl; - tmpDev->stop = stop; - tmpDev->start = start; - tmpDev->standby = standby; - tmpDev->info = info; + tmpDev->devInfo = devInfo; tmpDev->next = devices; devices = tmpDev; tmpDev->init(tmpDev); } +/***************************************************************************************** + + Function: struct deviceNode *deviceFind(int major,int minor); + + Description: This will find a device based on major minor + + Notes: + + 05/19/2004 - Improving Upon the spec + +*****************************************************************************************/ struct deviceNode *deviceFind(int major,int minor) { struct deviceNode *tmp = devices; for (;tmp;tmp=tmp->next) { - if ((tmp->major == major) && (tmp->minor == minor)) + if ((tmp->devInfo->major == major) && (tmp->minor == minor)) return(tmp); } return(0x0); } /*** + + $Log$ + 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/27 12:05:12 reddawg + Updates To Driver Subsystem + + Revision 1.1 2004/04/27 03:49:41 reddawg + Start of new driver system + END ***/