00001 // See the end of this file for license information. 00002 00003 #ifndef TORSION_SEGMENT_H 00004 #define TORSION_SEGMENT_H 00005 00006 #include "addrmap.h" 00007 #include "array.h" 00008 #include "blockmap.h" 00009 00016 00017 class Segment_map : public Address_map { 00018 public: 00020 void 00021 set_pages_count(unsigned segment, Size pages_count); 00022 00024 Size 00025 get_pages_count(unsigned segment); 00026 00028 bool 00029 is_segment_free(unsigned segment); 00030 }; 00031 00034 00035 class Segment_header { 00036 public: 00040 inline void* 00041 get_page_address(unsigned page_index) { 00042 return (void*)((unsigned*)this)[page_index]; 00043 } 00044 00046 inline void 00047 set_page_address(unsigned page_index, void* page_address) { 00048 ((unsigned*)this)[page_index] = (unsigned)page_address; 00049 } 00050 }; 00051 00059 00060 class Segment { 00061 public: 00062 Segment_header* header; 00063 void* buffer; 00064 unsigned first_block; 00065 unsigned curr_page_block; 00066 Size pages_count; 00067 unsigned index; 00068 00070 void 00071 init(unsigned first_block, unsigned index); 00072 00074 void 00075 alloc_buffers(Size segment_size_without_header); 00076 00078 void 00079 free_buffers(); 00080 00082 void 00083 print(); 00084 }; 00085 00086 #endif 00087 00088 /* Torsion Operating System, Copyright (C) 2000-2004 Dan Helfman 00089 * 00090 * This program is free software; you can redistribute it and/or modify it 00091 * under the terms of the GNU General Public License as published by the 00092 * Free Software Foundation; either version 2 of the License, or (at your 00093 * option) any later version. 00094 * 00095 * This program is distributed in the hope that it will be useful, but 00096 * WITHOUT ANY WARRANTY; without even the implied warranty of 00097 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00098 * General Public License for more details (in the COPYING file). 00099 * 00100 * You should have received a copy of the GNU General Public License along 00101 * with this program; if not, write to the Free Software Foundation, Inc., 00102 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00103 */
Torsion Operating System, Copyright (C) 2000-2004 Dan Helfman