diff --git a/src/sys/include/sys/kern_sysctl.h b/src/sys/include/sys/kern_sysctl.h new file mode 100644 index 0000000..e4559c7 --- /dev/null +++ b/src/sys/include/sys/kern_sysctl.h @@ -0,0 +1,73 @@ +/***************************************************************************************** + 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 _KERNSYSCTL_H +#define _KERNSYSCTL_H + +#include +#include + +#define CTL_MAXNAME 24 /* largest number of components supported */ + +/* + * Top-level identifiers + */ +#define CTL_UNSPEC 0 /* unused */ +#define CTL_KERN 1 /* "high kernel": proc, limits */ +#define CTL_VM 2 /* virtual memory */ +#define CTL_VFS 3 /* filesystem, mount type is next */ +#define CTL_NET 4 /* network, see socket.h */ +#define CTL_DEBUG 5 /* debugging parameters */ +#define CTL_HW 6 /* generic cpu/io */ +#define CTL_MACHDEP 7 /* machine dependent */ +#define CTL_USER 8 /* user-level */ +#define CTL_P1003_1B 9 /* POSIX 1003.1B */ +#define CTL_UBIX 10 /* ubixos */ + + +int __sysctl(struct thread *, struct sysctl_args *); +int sysctl_add(int *,int,char *,void *,int); +int sysctl_init(); + +struct sysctl_entry { + struct sysctl_entry *prev; + struct sysctl_entry *next; + struct sysctl_entry *children; + char name[32]; + int id; + void *value; + int val_len; + }; + +#endif + +/*** + END + ***/ + diff --git a/src/sys/include/sys/kernsysctl.h b/src/sys/include/sys/kernsysctl.h deleted file mode 100644 index d434106..0000000 --- a/src/sys/include/sys/kernsysctl.h +++ /dev/null @@ -1,55 +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 _KERNSYSCTL_H -#define _KERNSYSCTL_H - -#include -#include - -int __sysctl(struct thread *, struct sysctl_args *); -int sysctl_add(int *,int,char *,void *,int); -int sysctl_init(); - -struct sysctl_entry { - struct sysctl_entry *prev; - struct sysctl_entry *next; - struct sysctl_entry *children; - char name[32]; - int id; - void *value; - int val_len; - }; - -#endif - -/*** - END - ***/ - diff --git a/src/sys/include/ubixos/init.h b/src/sys/include/ubixos/init.h index 8c3596a..70da17f 100644 --- a/src/sys/include/ubixos/init.h +++ b/src/sys/include/ubixos/init.h @@ -49,6 +49,7 @@ #include #include #include +#include typedef int (*intFunctionPTR)(void); @@ -58,6 +59,7 @@ i8259_init, idt_init, vitals_init, + sysctl_init, vfs_init, sched_init, pit_init, diff --git a/src/sys/kernel/kern_descrip.c b/src/sys/kernel/kern_descrip.c index f4be4ac..89f443a 100644 --- a/src/sys/kernel/kern_descrip.c +++ b/src/sys/kernel/kern_descrip.c @@ -38,7 +38,6 @@ int fcntl(struct thread *td, struct fcntl_args *uap) { struct file *fp = 0x0; - //kprintf("fcntl: [%i:%i:0x%X]",uap->cmd,uap->fd,uap->arg); if (td->o_files[uap->fd] == 0x0) { kprintf("ERROR!!!\n"); @@ -81,21 +80,20 @@ } int close(struct thread *td,struct close_args *uap) { - //kprintf("fd: [%i]\n",uap->fd); kfree((void *)td->o_files[uap->fd]); td->o_files[uap->fd] = 0x0; td->td_retval[0] = 0x0; return(0x0); } - -int getdtablesize(struct thread *td, struct getdtablesize_args *uap) { /* HACK */ +int getdtablesize(struct thread *td, struct getdtablesize_args *uap) { td->td_retval[0] = 20; return (0); } -int fstat(struct thread *td, struct fstat_args *uap) { +/* HACK */ +int fstat(struct thread *td,struct fstat_args *uap) { struct file *fp = 0x0; kprintf("fd: %i",uap->fd); fp = _current->td.o_files[uap->fd]; diff --git a/src/sys/kernel/kern_sysctl.c b/src/sys/kernel/kern_sysctl.c index 33b468b..430d7cb 100644 --- a/src/sys/kernel/kern_sysctl.c +++ b/src/sys/kernel/kern_sysctl.c @@ -30,98 +30,18 @@ #include #include #include -#include +#include #include #include #include #include #include -#define CTL_MAXNAME 24 - static struct sysctl_entry *ctls = 0x0; static struct sysctl_entry *sysctl_find(int *,int); -int sysctl_init() { - struct sysctl_entry *tmpCtl = 0x0; - if (ctls != 0x0) { - kprintf("sysctl already Initialized\n"); - while (1); - } - - ctls = (struct sysctl_entry *)kmalloc(sizeof(struct sysctl_entry)); - ctls->prev = 0x0; - ctls->id = 0x0; - ctls->children = 0x0; - sprintf(ctls->name,"CTL_UNSPEC"); - - tmpCtl = (struct sysctl_entry *)kmalloc(sizeof(struct sysctl_entry)); - tmpCtl->prev = ctls; - tmpCtl->id = 1; - tmpCtl->children = 0x0; - sprintf(tmpCtl->name,"CTL_KERN"); - ctls->next = tmpCtl; - - tmpCtl->next = (struct sysctl_entry *)kmalloc(sizeof(struct sysctl_entry)); - tmpCtl->next->prev = tmpCtl; - tmpCtl = tmpCtl->next; - tmpCtl->id = 2; - tmpCtl->children = 0x0; - sprintf(tmpCtl->name,"CTL_VM"); - - tmpCtl->next = (struct sysctl_entry *)kmalloc(sizeof(struct sysctl_entry)); - tmpCtl->next->prev = tmpCtl; - tmpCtl = tmpCtl->next; - tmpCtl->id = 3; - tmpCtl->children = 0x0; - sprintf(tmpCtl->name,"CTL_VFS"); - - tmpCtl->next = (struct sysctl_entry *)kmalloc(sizeof(struct sysctl_entry)); - tmpCtl->next->prev = tmpCtl; - tmpCtl = tmpCtl->next; - tmpCtl->id = 4; - tmpCtl->children = 0x0; - sprintf(tmpCtl->name,"CTL_NET"); - - tmpCtl->next = (struct sysctl_entry *)kmalloc(sizeof(struct sysctl_entry)); - tmpCtl->next->prev = tmpCtl; - tmpCtl = tmpCtl->next; - tmpCtl->id = 5; - tmpCtl->children = 0x0; - sprintf(tmpCtl->name,"CTL_DEBUG"); - - tmpCtl->next = (struct sysctl_entry *)kmalloc(sizeof(struct sysctl_entry)); - tmpCtl->next->prev = tmpCtl; - tmpCtl = tmpCtl->next; - tmpCtl->id = 6; - tmpCtl->children = 0x0; - sprintf(tmpCtl->name,"CTL_HW"); - - tmpCtl->next = (struct sysctl_entry *)kmalloc(sizeof(struct sysctl_entry)); - tmpCtl->next->prev = tmpCtl; - tmpCtl = tmpCtl->next; - tmpCtl->id = 7; - tmpCtl->children = 0x0; - sprintf(tmpCtl->name,"CTL_MACHDEP"); - - tmpCtl->next = (struct sysctl_entry *)kmalloc(sizeof(struct sysctl_entry)); - tmpCtl->next->prev = tmpCtl; - tmpCtl = tmpCtl->next; - tmpCtl->id = 8; - tmpCtl->children = 0x0; - sprintf(tmpCtl->name,"CTL_USER"); - - tmpCtl->next = (struct sysctl_entry *)kmalloc(sizeof(struct sysctl_entry)); - tmpCtl->next->prev = tmpCtl; - tmpCtl = tmpCtl->next; - tmpCtl->id = 9; - tmpCtl->children = 0x0; - sprintf(tmpCtl->name,"CTL_P1003_1B"); - - return(0x0); - } - +/* This is a cheat for now */ static void def_ctls() { int name[CTL_MAXNAME], name_len; uInt32 page_val = 0x1000; @@ -141,12 +61,98 @@ sysctl_add(name,name_len,"page_size",&page_val,sizeof(uInt32)); } +int sysctl_init() { + struct sysctl_entry *tmpCtl = 0x0; + if (ctls != 0x0) { + kprintf("sysctl already Initialized\n"); + while (1); + } + + ctls = (struct sysctl_entry *)kmalloc(sizeof(struct sysctl_entry)); + ctls->prev = 0x0; + ctls->id = CTL_UNSPEC; + ctls->children = 0x0; + sprintf(ctls->name,"unspec"); + + tmpCtl = (struct sysctl_entry *)kmalloc(sizeof(struct sysctl_entry)); + tmpCtl->prev = ctls; + tmpCtl->id = CTL_KERN; + tmpCtl->children = 0x0; + sprintf(tmpCtl->name,"kern"); + ctls->next = tmpCtl; + + tmpCtl->next = (struct sysctl_entry *)kmalloc(sizeof(struct sysctl_entry)); + tmpCtl->next->prev = tmpCtl; + tmpCtl = tmpCtl->next; + tmpCtl->id = CTL_VM; + tmpCtl->children = 0x0; + sprintf(tmpCtl->name,"vm"); + + tmpCtl->next = (struct sysctl_entry *)kmalloc(sizeof(struct sysctl_entry)); + tmpCtl->next->prev = tmpCtl; + tmpCtl = tmpCtl->next; + tmpCtl->id = CTL_VFS; + tmpCtl->children = 0x0; + sprintf(tmpCtl->name,"vfs"); + + tmpCtl->next = (struct sysctl_entry *)kmalloc(sizeof(struct sysctl_entry)); + tmpCtl->next->prev = tmpCtl; + tmpCtl = tmpCtl->next; + tmpCtl->id = CTL_NET; + tmpCtl->children = 0x0; + sprintf(tmpCtl->name,"net"); + + tmpCtl->next = (struct sysctl_entry *)kmalloc(sizeof(struct sysctl_entry)); + tmpCtl->next->prev = tmpCtl; + tmpCtl = tmpCtl->next; + tmpCtl->id = CTL_DEBUG; + tmpCtl->children = 0x0; + sprintf(tmpCtl->name,"debug"); + + tmpCtl->next = (struct sysctl_entry *)kmalloc(sizeof(struct sysctl_entry)); + tmpCtl->next->prev = tmpCtl; + tmpCtl = tmpCtl->next; + tmpCtl->id = CTL_HW; + tmpCtl->children = 0x0; + sprintf(tmpCtl->name,"hw"); + + tmpCtl->next = (struct sysctl_entry *)kmalloc(sizeof(struct sysctl_entry)); + tmpCtl->next->prev = tmpCtl; + tmpCtl = tmpCtl->next; + tmpCtl->id = CTL_MACHDEP; + tmpCtl->children = 0x0; + sprintf(tmpCtl->name,"machdep"); + + tmpCtl->next = (struct sysctl_entry *)kmalloc(sizeof(struct sysctl_entry)); + tmpCtl->next->prev = tmpCtl; + tmpCtl = tmpCtl->next; + tmpCtl->id = CTL_USER; + tmpCtl->children = 0x0; + sprintf(tmpCtl->name,"user"); + + tmpCtl->next = (struct sysctl_entry *)kmalloc(sizeof(struct sysctl_entry)); + tmpCtl->next->prev = tmpCtl; + tmpCtl = tmpCtl->next; + tmpCtl->id = CTL_P1003_1B; + tmpCtl->children = 0x0; + sprintf(tmpCtl->name,"p1003_1b"); + + tmpCtl->next = (struct sysctl_enctry *)kmalloc(sizeof(struct sysctl_entry)); + tmpCtl->next->prev = tmpCtl; + tmpCtl = tmpCtl->next; + tmpCtl->id = CTL_UBIX; + tmpCtl->children = 0x0; + sprintf(tmpCtl->name,"ubix"); + + def_ctls(); + + return(0x0); + } + int __sysctl(struct thread *td, struct sysctl_args *uap) { struct sysctl_entry *tmpCtl = 0x0; int i = 0; - if (ctls == 0x0) { - def_ctls(); - } + if (uap->newlen < 0) { kprintf("Changing Not supported yet.\n"); endTask(_current->id); @@ -196,10 +202,6 @@ struct sysctl_entry *tmpCtl = 0x0; struct sysctl_entry *newCtl = 0x0; - if (ctls == 0x0) { - sysctl_init(); - } - /* Check if it exists */ tmpCtl = sysctl_find(name,namelen); if (tmpCtl != 0x0) { @@ -236,8 +238,7 @@ newCtl->val_len = buf_size; tmpCtl->children->prev = newCtl; tmpCtl->children = newCtl; - - } + } return(0x0); } @@ -246,4 +247,3 @@ /*** END ***/ - diff --git a/ubix2.kdevelop b/ubix2.kdevelop index 2afe967..fe42a8a 100644 --- a/ubix2.kdevelop +++ b/ubix2.kdevelop @@ -15,7 +15,7 @@ kdevcvsservice . false - + @@ -34,27 +34,27 @@ make - + true 1 false - + 0 - - + + default executable / - - + + false true @@ -112,7 +112,7 @@ Doxygen Documentation Collection ubix2.tag - + @@ -144,10 +144,10 @@ false 3 - + - + set m_,_ theValue @@ -187,12 +187,12 @@ - - - - - - + + + + + + true false false