X-Git-Url: http://git.buserror.net/cgi-bin/gitweb.cgi?p=polintos%2Fscott%2Fpriv.git;a=blobdiff_plain;f=kernel%2Fmem%2Faddrspace.cc;h=20a46fb04d09c6997e87ee2669e94cabefb494b6;hp=f014c5458c621d97b08a5efe3787d342852dd533;hb=b4bfc871337ca32ce83407916a87db2524729ca9;hpb=166dbb2f95c17d80568102b9f063c472e30d706b diff --git a/kernel/mem/addrspace.cc b/kernel/mem/addrspace.cc index f014c54..20a46fb 100644 --- a/kernel/mem/addrspace.cc +++ b/kernel/mem/addrspace.cc @@ -9,34 +9,19 @@ // // This software is copyright (c) 2006 Scott Wood . // -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal with -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to do -// so, subject to the following conditions: +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors or contributors be held liable for any damages +// arising from the use of this software. // -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimers. -// -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimers in the -// documentation and/or other materials provided with the distribution. -// -// * The names of the Software's authors and/or contributors -// may not be used to endorse or promote products derived from -// this Software without specific prior written permission. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE -// SOFTWARE. +// Permission is hereby granted to everyone, free of charge, to use, copy, +// modify, prepare derivative works of, publish, distribute, perform, +// sublicense, and/or sell copies of the Software, provided that the above +// copyright notice and disclaimer of warranty be included in all copies or +// substantial portions of this software. #include #include +#include #include #include #include @@ -59,7 +44,7 @@ namespace Mem { void create(Object *obj) { - *obj = static_cast(*(new AddrSpace(false))); + *obj = static_cast(*(new AddrSpace)); } }; @@ -74,7 +59,7 @@ namespace Mem { void create(Object *obj) { - AddrSpace *as = new AddrSpace(true); + AddrSpace *as = new ProcAddrSpace; Region region; MapFlags mf = 0; u64 vstart; @@ -104,7 +89,7 @@ namespace Mem { printf("vstart %llx\n", vstart); as->map(anonmem, region, &vstart, mf); - *obj = static_cast(*(as)); + *obj = static_cast(*as); } }; @@ -114,34 +99,32 @@ namespace Mem { AddrSpaceFactory real_addrspace_factory; Factory addr_space_factory = real_addrspace_factory; - AddrSpace::AddrSpace(bool process) : mappable(this) + AddrSpace::AddrSpace(PageTable *ptbl) : mappable(this) { init_iface(); - is_process = process; - - // OPT: Allow optional use of the native PTE for stacked aspaces, - // either because the native PTE is 64-bit, or because it's an - // embedded system which does not need 64-bit storage. + is_process = false; + page_table = ptbl; - if (process) - page_table = new PageTableImpl(true); - else + if (!ptbl) page_table = new PageTableImpl(false); cached_free_region = Arch::user_start + Arch::page_size; } + ProcAddrSpace::ProcAddrSpace() : + AddrSpace(new PageTableImpl(true)) + { + is_process = true; + } + // This should only be used once during bootup to initialize the // kernel's address space with a static initial page table. - AddrSpace::AddrSpace(void *ptbl_toplevel) : mappable(this) + ProcAddrSpace::ProcAddrSpace(void *ptbl_toplevel) : + AddrSpace(new PageTableImpl(ptbl_toplevel)) { - init_iface(); + // FIXME: set cached_free_region to kernel virtual space is_process = true; - page_table = new PageTableImpl(ptbl_toplevel); - - // FIXME: should be kernel virtual space - cached_free_region = Arch::user_start + Arch::page_size; } void AddrSpace::get_mappable(IMappable *ma) @@ -765,6 +748,11 @@ namespace Mem { { *min_align = Arch::page_mapping_min_align; } + + void AddrSpace::get_size(u64 *size) + { + page_table->get_size(size); + } void Mappable::map(VirtualArea *varea) { @@ -818,8 +806,6 @@ namespace Mem { void pagein(u64 vaddr, PTEFlags reqflags) { - // Doesn't need to do anything yet, though it may later - // once high memory support is added. } void get_mapping(u64 addr, u64 *phys, PTEFlags *flags) @@ -849,8 +835,6 @@ namespace Mem { void pagein(u64 vaddr, PTEFlags reqflags) { - // Doesn't need to do anything yet, though it may later - // once high memory support is added. } void get_mapping(u64 addr, u64 *phys, PTEFlags *flags)