From 9d7bf73ada00a5c568b04fd96d5f7a8e2ae0a8fc Mon Sep 17 00:00:00 2001 From: bluecode Date: Sat, 7 Mar 2009 14:48:48 +0000 Subject: [PATCH] Minor cleanups git-svn-id: https://svn.bountysource.com/lightos@477 fe0da31e-fa12-0410-8c14-cf7afecde7d9 --- trunk/Doxyfile | 6 +- trunk/Makefile | 6 + trunk/kernel/include/kernel/page_allocator.hpp | 173 ++++++++++++------------- trunk/kernel/page_allocator.cpp | 8 +- trunk/lib/libc/include/time.h | 2 +- trunk/lib/libc/include/wchar.h | 78 +++++++++++ trunk/lib/libc/time.c | 14 +- 7 files changed, 178 insertions(+), 109 deletions(-) rewrite trunk/kernel/include/kernel/page_allocator.hpp (67%) create mode 100644 trunk/lib/libc/include/wchar.h diff --git a/trunk/Doxyfile b/trunk/Doxyfile index 8e890c2..7ec870f 100644 --- a/trunk/Doxyfile +++ b/trunk/Doxyfile @@ -461,7 +461,7 @@ RECURSIVE = YES # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. -EXCLUDE = libarch/include/libarch/arch libkernel/include/libkernel/arch +EXCLUDE = libarch/include/libarch/arch libkernel/include/libkernel/arch lib/libc/libOS # The EXCLUDE_SYMLINKS tag can be used select whether or not files or # directories that are symbolic links (a Unix filesystem feature) are excluded @@ -1070,7 +1070,7 @@ HIDE_UNDOC_RELATIONS = YES # toolkit from AT&T and Lucent Bell Labs. The other options in this section # have no effect if this option is set to NO (the default) -HAVE_DOT = NO +HAVE_DOT = YES # If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and @@ -1122,7 +1122,7 @@ INCLUDED_BY_GRAPH = YES # So in most cases it will be better to enable call graphs for selected # functions only using the \callgraph command. -CALL_GRAPH = NO +CALL_GRAPH = YES # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen # will graphical hierarchy of all classes instead of a textual one. diff --git a/trunk/Makefile b/trunk/Makefile index 43bbc4d..961f274 100644 --- a/trunk/Makefile +++ b/trunk/Makefile @@ -6,6 +6,12 @@ default: dep all -include Makefile.config -include Makefile.rules +.PHONY : doc + +doc: + @doxygen Doxyfile + @doxygen Doxyfile.kernel + dep: @make -C server dep @make -C lib/lightOS++ dep diff --git a/trunk/kernel/include/kernel/page_allocator.hpp b/trunk/kernel/include/kernel/page_allocator.hpp dissimilarity index 67% index b4a1949..e4acd71 100644 --- a/trunk/kernel/include/kernel/page_allocator.hpp +++ b/trunk/kernel/include/kernel/page_allocator.hpp @@ -1,93 +1,80 @@ -/* -lightOS kernel -Copyright (C) 2006-2009 Jörg Pfähler - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ -#ifndef LIGHTOS_KERNEL_PAGEALLOCATOR_HPP -#define LIGHTOS_KERNEL_PAGEALLOCATOR_HPP - -/*! \addtogroup kernel kernel */ -/*@{*/ - -#include -#include -#include - -namespace kernel -{ - /*! page_allocator class for the management of pages above the 16mb barrier - *\note Not neccessarily every page above the 16mb barrier is manged by this allocator. The amount is calculated - * based on the total amount of RAM (see x86-shared/multiboot.cpp) */ - class page_allocator - { - public: - /*! Get the page_allocator instance */ - inline static page_allocator &instance(){return mInst;} - - /*! Allocate a new page - *\return physical address of the page */ - void *allocate(); - /*! Free a previously allocated page - *\param[in] physical address of the page */ - void free(void *page); - - /*! Get the page size - *\return the page size in byte */ - inline static size_t page_size(){return mPageSize;} - /*! Number of free pages - *\return the number of free pages */ - inline size_t size(){return mSize;} - /*! Total number of pages (userfriendly version) - *\return the total number of pages (userfriendly version) */ - inline size_t capacity(){return mPageCount;} - /*! Set the total number of pages (userfriendly version) - *\param[in] the number of pages (userfriendly version) */ - inline void capacity(size_t i){mPageCount = i;} - private: - /*! The constructor */ - page_allocator(); - /*! The copy-constructor - *\note NO implementation provided */ - page_allocator(const page_allocator &); - /*! The = operator - *\note NO implementation provided */ - page_allocator &operator = (const page_allocator &); - /*! The destructor */ - inline ~page_allocator(){} - - /*! The instance */ - static page_allocator mInst; - - /*! Size of one page */ - static size_t mPageSize; - /*! The number of pages */ - size_t mCapacity; - /*! The number of free pages */ - size_t mSize; - /*! The number of total pages (userfriendly version) */ - size_t mPageCount; - /*! Pointer to the stack */ - uintptr_t *mStack; - #ifdef _LIGHTOS_SMP - /*! Spinlock to protect the page_allocator in a multiprocessor environment */ - lightOS::spinlock mLock; - #endif - }; -} - -/*@}*/ - -#endif +/* +lightOS kernel +Copyright (C) 2006-2009 Jörg Pfähler + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +*/ +#ifndef LIGHTOS_KERNEL_PAGEALLOCATOR_HPP +#define LIGHTOS_KERNEL_PAGEALLOCATOR_HPP + +/*! \addtogroup kernel kernel */ +/*@{*/ + +#include +#include +#include +#include + +namespace kernel +{ + /*! page_allocator class for the management of pages above the 16mb barrier + *\note Not neccessarily every page above the 16mb barrier is manged by this allocator. The amount is calculated + * based on the total amount of RAM (see x86-shared/multiboot.cpp) */ + class page_allocator + { + SINGLETON(page_allocator); + + public: + /*! Allocate a new page + *\return physical address of the page */ + void *allocate(); + /*! Free a previously allocated page + *\param[in] physical address of the page */ + void free(void *page); + + /*! Get the page size + *\return the page size in byte */ + inline static size_t page_size(){return mPageSize;} + /*! Number of free pages + *\return the number of free pages */ + inline size_t size(){return mSize;} + /*! Total number of pages (userfriendly version) + *\return the total number of pages (userfriendly version) */ + inline size_t capacity(){return mPageCount;} + /*! Set the total number of pages (userfriendly version) + *\param[in] the number of pages (userfriendly version) */ + inline void capacity(size_t i){mPageCount = i;} + + private: + /*! Size of one page */ + static size_t mPageSize; + /*! The number of pages */ + size_t mCapacity; + /*! The number of free pages */ + size_t mSize; + /*! The number of total pages (userfriendly version) */ + size_t mPageCount; + /*! Pointer to the stack */ + uintptr_t *mStack; + #ifdef _LIGHTOS_SMP + /*! Spinlock to protect the page_allocator in a multiprocessor environment */ + lightOS::spinlock mLock; + #endif + }; +} + +/*@}*/ + +#endif diff --git a/trunk/kernel/page_allocator.cpp b/trunk/kernel/page_allocator.cpp index 5fd71c0..574ce6d 100644 --- a/trunk/kernel/page_allocator.cpp +++ b/trunk/kernel/page_allocator.cpp @@ -26,12 +26,17 @@ using namespace std; using namespace kernel; size_t page_allocator::mPageSize = PAGE_SIZE; -page_allocator page_allocator::mInst = page_allocator(); +page_allocator page_allocator::m_instance = page_allocator(); page_allocator::page_allocator() : mCapacity(0), mSize(0), mStack(reinterpret_cast(KERNEL_MEMORY_PAGE_ALLOCATOR_START)) { } + +page_allocator::~page_allocator() +{ +} + void *page_allocator::allocate() { if (mSize == 0) @@ -49,6 +54,7 @@ void *page_allocator::allocate() return Page; } + void page_allocator::free(void *page) { LOCK(mLock); diff --git a/trunk/lib/libc/include/time.h b/trunk/lib/libc/include/time.h index cf927f0..8917e3b 100644 --- a/trunk/lib/libc/include/time.h +++ b/trunk/lib/libc/include/time.h @@ -34,7 +34,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA /*! \addtogroup libc libc */ /*@{*/ /*! \addtogroup libc_time ISO/IEC 9899:1999 - 7.23 - time.h - * ISO/IEC 9899:1999 7.23 Date and time */ + * ISO/IEC 9899:1999 7.23 Date and time */ /*@{*/ diff --git a/trunk/lib/libc/include/wchar.h b/trunk/lib/libc/include/wchar.h new file mode 100644 index 0000000..635a9cf --- /dev/null +++ b/trunk/lib/libc/include/wchar.h @@ -0,0 +1,78 @@ +/* +lightOS libc +Copyright (C) 2006-2008 Jörg Pfähler + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +*/ +#ifndef LIGHTOS_LIBC_WCHAR_H +#define LIGHTOS_LIBC_WCHAR_H + + +/* + * Standard includes + */ +#include +#include + + +/*! \addtogroup libc libc */ +/*@{*/ +/*! \addtogroup libc_wchar ISO/IEC 9899:1999 - 7.24 - wchar.h + * ISO/IEC 9899:1999 7.24 Extended multibyte and wide character utilities */ +/*@{*/ + + +/* + * Types + * ISO/IEC 9899:1999 7.24.1 + */ +#define WEOF (wint_t)-1 + + +/* + * Types + * ISO/IEC 9899:1999 7.24.1 + */ + +// TODO: mbstate_t +// TODO: wint_t + +/** Forward declaration of struct tm, see time.h */ +struct tm; + +#ifdef __cplusplus + extern "C" + { + + #define restrict +#endif + + + /* + * ISO/IEC 9899:1999 7.24.2 Formatted wide character input/output functions + */ + // TODO + +#ifdef __cplusplus + } + + #undef restrict +#endif + + +/*@}*/ +/*@}*/ + +#endif diff --git a/trunk/lib/libc/time.c b/trunk/lib/libc/time.c index 817c2a7..14ddd28 100644 --- a/trunk/lib/libc/time.c +++ b/trunk/lib/libc/time.c @@ -45,8 +45,9 @@ size_t _LIBC_calc_day_of_year(size_t year, size_t month) if (_LIBC_is_leap_year(year) == true && month > 1)++yday; return yday; } -void _LIBC_calc_month(size_t *days, - size_t *month) + +static void _LIBC_calc_month(size_t *days, + size_t *month) { *month = 1; while (*days >= _LIBC_month[*month - 1]) @@ -56,15 +57,6 @@ void _LIBC_calc_month(size_t *days, } } -size_t _LIBC_calc_date_from_day_of_year(size_t year, size_t days, int *mday, int *month) -{ - *mday = 0; - *month = 0; - // TODO - _LIBOS_WARNING("libc", "not implemented"); - return 0; -} - /* * libc functions */ -- 2.11.4.GIT