diff options
Diffstat (limited to 'sys/include/vm')
-rw-r--r-- | sys/include/vm/dynalloc.h | 44 | ||||
-rw-r--r-- | sys/include/vm/fault.h | 38 | ||||
-rw-r--r-- | sys/include/vm/map.h | 84 | ||||
-rw-r--r-- | sys/include/vm/obj.h | 61 | ||||
-rw-r--r-- | sys/include/vm/page.h | 41 | ||||
-rw-r--r-- | sys/include/vm/pager.h | 51 | ||||
-rw-r--r-- | sys/include/vm/physseg.h | 48 | ||||
-rw-r--r-- | sys/include/vm/pmap.h | 117 | ||||
-rw-r--r-- | sys/include/vm/tlsf.h | 90 | ||||
-rw-r--r-- | sys/include/vm/vm.h | 78 |
10 files changed, 0 insertions, 652 deletions
diff --git a/sys/include/vm/dynalloc.h b/sys/include/vm/dynalloc.h deleted file mode 100644 index 44d2f5a..0000000 --- a/sys/include/vm/dynalloc.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra 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. - */ - -/* - * For documentation: See dynalloc(9) - */ - -#ifndef _VM_DYNALLOC_H_ -#define _VM_DYNALLOC_H_ - -#include <sys/types.h> - -void *dynalloc(size_t sz); -void *dynalloc_memalign(size_t sz, size_t align); -void *dynrealloc(void *old_ptr, size_t newsize); -void dynfree(void *ptr); - -#endif /* !_VM_DYNALLOC_H_ */ diff --git a/sys/include/vm/fault.h b/sys/include/vm/fault.h deleted file mode 100644 index f0e308c..0000000 --- a/sys/include/vm/fault.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra 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. - */ - -#ifndef _VM_FAULT_H_ -#define _VM_FAULT_H_ - -#include <sys/types.h> -#include <vm/pmap.h> - -int vm_fault(vaddr_t va, vm_prot_t access_type); - -#endif /* !_VM_FAULT_H_ */ diff --git a/sys/include/vm/map.h b/sys/include/vm/map.h deleted file mode 100644 index a1e74d9..0000000 --- a/sys/include/vm/map.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra 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. - */ - -#ifndef _VM_MMAP_H_ -#define _VM_MMAP_H_ - -#include <sys/types.h> -#include <sys/cdefs.h> -#include <sys/queue.h> -#include <sys/syscall.h> -#include <sys/spinlock.h> -#include <vm/pmap.h> -#include <vm/vm.h> - -#define MAP_SHARED 0x0001 -#define MAP_PRIVATE 0x0002 -#define MAP_ANONYMOUS 0x0010 -#define MAP_FAILED ((void *)-1) - -/* Memory map table entry count */ -#define MTAB_ENTRIES 32 - -struct vm_object; - -struct vm_mapping { - TAILQ_ENTRY(vm_mapping) link; - struct vm_range range; - struct vm_object *vmobj; - paddr_t physmem_base; - vm_prot_t prot; - - /* Private */ - size_t vhash; /* Virtual address hash */ -}; - -typedef TAILQ_HEAD(, vm_mapping) vm_mapq_t; - -struct vm_mapspace { - vm_mapq_t mtab[MTAB_ENTRIES]; /* Map table */ - size_t map_count; -}; - -/* Mapping operations */ -int vm_map_destroy(struct vas vas, vaddr_t va, size_t bytes); -int vm_map_create(struct vas vas, vaddr_t va, paddr_t pa, vm_prot_t prot, - size_t bytes); - -/* Syscalls */ -uint64_t sys_mmap(struct syscall_args *args); -uint64_t sys_munmap(struct syscall_args *args); - -/* Mapespace operations */ -void vm_mapspace_insert(struct vm_mapspace *ms, struct vm_mapping *mapping); -void vm_mapspace_remove(struct vm_mapspace *ms, struct vm_mapping *mapping); -struct vm_mapping *vm_mapping_fetch(struct vm_mapspace *ms, vaddr_t va); -void vm_free_mapq(vm_mapq_t *mapq); - -#endif /* !_VM_MMAP_H_ */ diff --git a/sys/include/vm/obj.h b/sys/include/vm/obj.h deleted file mode 100644 index 6e24516..0000000 --- a/sys/include/vm/obj.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra 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. - */ - -#ifndef _VM_OBJ_H_ -#define _VM_OBJ_H_ - -#include <sys/spinlock.h> -#include <sys/types.h> -#include <sys/vnode.h> -#include <vm/map.h> -#include <vm/pager.h> - -struct vm_object { - struct spinlock lock; /* Protects this object */ - struct vm_mapspace mapspace; /* Mapspace this object points to */ - struct vm_pagerops *pgops; /* Pager operations */ - - uint8_t is_anon : 1; /* Is an anonymous mapping */ - uint8_t demand : 1; /* Only mapped upon access */ - int ref; /* Ref count */ - struct vnode *vnode; /* Only used if `is_anon` is 0 */ -}; - -#define vm_object_ref(OBJPTR) (++(OBJPTR)->ref) -#define vm_object_unref(OBJPTR) do { \ - if ((OBJPTR)->ref > 0) { \ - --(OBJPTR)->ref; \ - } \ - } while (0); - -size_t vm_obj_count(void); -int vm_obj_init(struct vm_object **res, struct vnode *vnode); -int vm_obj_destroy(struct vm_object *obj); - -#endif /* !_VM_OBJ_H_ */ diff --git a/sys/include/vm/page.h b/sys/include/vm/page.h deleted file mode 100644 index 80fa74f..0000000 --- a/sys/include/vm/page.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra 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. - */ - -#ifndef _VM_PAGE_H_ -#define _VM_PAGE_H_ - -#include <sys/types.h> - -struct vm_page { - paddr_t physaddr; -}; - -void vm_zero_page(void *page, size_t page_count); - -#endif /* !_VM_PAGE_H_ */ diff --git a/sys/include/vm/pager.h b/sys/include/vm/pager.h deleted file mode 100644 index e57afe1..0000000 --- a/sys/include/vm/pager.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra 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. - */ - -#ifndef _VM_PAGER_H_ -#define _VM_PAGER_H_ - -#include <sys/types.h> -#include <vm/page.h> - -struct vm_object; - -struct vm_pagerops { - int(*get)(struct vm_object *obj, off_t off, size_t len, struct vm_page *pg); - int(*store)(struct vm_object *obj, off_t off, size_t len, struct vm_page *pg); - /* TODO: Remove this and add demand paging */ - int(*get_paddr)(struct vm_object *obj, paddr_t *paddr, vm_prot_t prot); -}; - -extern struct vm_pagerops g_vnode_pagerops; -extern struct vm_pagerops g_dev_pagerops; - -int vm_pager_get(struct vm_object *obj, off_t off, size_t len, struct vm_page *pg); -int vm_pager_paddr(struct vm_object *obj, paddr_t *paddr, vm_prot_t prot); - -#endif /* !_VM_PAGER_H_ */ diff --git a/sys/include/vm/physseg.h b/sys/include/vm/physseg.h deleted file mode 100644 index 956f82f..0000000 --- a/sys/include/vm/physseg.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra 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. - */ - -#ifndef _VM_VM_PHYSSEG_H_ -#define _VM_VM_PHYSSEG_H_ - -#include <sys/types.h> - -struct physmem_stat { - size_t reserved_kib; /* Reserved memory */ - size_t total_kib; /* Total memory */ - size_t avl_kib; /* Available memory */ - size_t alloc_kib; /* Allocated physical memory */ -}; - -void vm_physseg_init(void); -uintptr_t vm_alloc_pageframe(size_t count); - -void vm_free_pageframe(uintptr_t base, size_t count); -struct physmem_stat vm_phys_memstat(void); - -#endif /* !_VM_VM_PHYSSEG_H_ */ diff --git a/sys/include/vm/pmap.h b/sys/include/vm/pmap.h deleted file mode 100644 index cb18885..0000000 --- a/sys/include/vm/pmap.h +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra 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. - */ - -#ifndef _VM_PMAP_H_ -#define _VM_PMAP_H_ - -/* - * Each architecture is expected to implement - * this header. It should contain a `struct vas' - * which will contain information about a VAS - * (virtual address space) - * - * On AMD64 this struct contains: PML4, etc - * - * XXX: Compiler errors pointing to this include means you - * forgot to implement it!!! - * - * `struct vas' MUST have a `struct spinlock lock' field!!! - */ -#include <machine/vas.h> - -#include <vm/tlsf.h> -#include <sys/types.h> -#include <sys/spinlock.h> - -/* prot flags for mappings */ -#define PROT_WRITE __BIT(0) /* Writable */ -#define PROT_EXEC __BIT(1) /* Executable */ -#define PROT_USER __BIT(2) /* User accessible */ - -/* Caching types */ -#define VM_CACHE_UC 0x00000U /* Uncachable */ -#define VM_CACHE_WT 0x00001U /* Write-through */ - -#define is_vas_valid(vas) (vas.top_level != 0) - -/* - * vm_ctx - Per core virtual memory context - */ -struct vm_ctx { - uintptr_t dynalloc_pool_phys; - size_t dynalloc_pool_sz; /* In bytes */ - tlsf_t tlsf_ctx; - struct spinlock dynalloc_lock; -}; - -/* - * Mark a virtual address with a specific caching - * type. - */ -int pmap_set_cache(struct vm_ctx *, struct vas, vaddr_t, int); - -/* - * Create a virtual address space - * and return the descriptor. - */ -int pmap_create_vas(struct vm_ctx *, struct vas *); - -/* - * Switch the current virtual address space - * to another. - */ -void pmap_switch_vas(struct vm_ctx *, struct vas); - -/* - * Read virtual address space descriptor - * and return it. - */ -struct vas pmap_read_vas(void); - -/* - * Map a physical address to a virtual address. - */ -int pmap_map(struct vm_ctx *, struct vas, vaddr_t, paddr_t, vm_prot_t); - -/* - * Get rid of a virtual address space and free - * resources. - */ -int pmap_free_vas(struct vm_ctx *, struct vas); - -/* - * Unmap a page. - */ -int pmap_unmap(struct vm_ctx *, struct vas, vaddr_t); - -/* - * Architecture specific init code for pmap - */ -int pmap_init(struct vm_ctx *); -#endif /* _VM_PMAP_H_ */ diff --git a/sys/include/vm/tlsf.h b/sys/include/vm/tlsf.h deleted file mode 100644 index e9b5a91..0000000 --- a/sys/include/vm/tlsf.h +++ /dev/null @@ -1,90 +0,0 @@ -#ifndef INCLUDED_tlsf
-#define INCLUDED_tlsf
-
-/*
-** Two Level Segregated Fit memory allocator, version 3.1.
-** Written by Matthew Conte
-** http://tlsf.baisoku.org
-**
-** Based on the original documentation by Miguel Masmano:
-** http://www.gii.upv.es/tlsf/main/docs
-**
-** This implementation was written to the specification
-** of the document, therefore no GPL restrictions apply.
-**
-** Copyright (c) 2006-2016, Matthew Conte
-** 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 and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in the
-** documentation and/or other materials provided with the distribution.
-** * Neither the name of the copyright holder 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 MATTHEW CONTE 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.
-*/
-
-#include <stddef.h>
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-/* tlsf_t: a TLSF structure. Can contain 1 to N pools. */
-/* pool_t: a block of memory that TLSF can manage. */
-typedef void* tlsf_t;
-typedef void* pool_t;
-
-/* Create/destroy a memory pool. */
-tlsf_t tlsf_create(void* mem);
-tlsf_t tlsf_create_with_pool(void* mem, size_t bytes);
-void tlsf_destroy(tlsf_t tlsf);
-pool_t tlsf_get_pool(tlsf_t tlsf);
-
-/* Add/remove memory pools. */
-pool_t tlsf_add_pool(tlsf_t tlsf, void* mem, size_t bytes);
-void tlsf_remove_pool(tlsf_t tlsf, pool_t pool);
-
-/* malloc/memalign/realloc/free replacements. */
-void* tlsf_malloc(tlsf_t tlsf, size_t bytes);
-void* tlsf_memalign(tlsf_t tlsf, size_t align, size_t bytes);
-void* tlsf_realloc(tlsf_t tlsf, void* ptr, size_t size);
-void tlsf_free(tlsf_t tlsf, void* ptr);
-
-/* Returns internal block size, not original request size */
-size_t tlsf_block_size(void* ptr);
-
-/* Overheads/limits of internal structures. */
-size_t tlsf_size(void);
-size_t tlsf_align_size(void);
-size_t tlsf_block_size_min(void);
-size_t tlsf_block_size_max(void);
-size_t tlsf_pool_overhead(void);
-size_t tlsf_alloc_overhead(void);
-
-/* Debugging. */
-typedef void (*tlsf_walker)(void* ptr, size_t size, int used, void* user);
-void tlsf_walk_pool(pool_t pool, tlsf_walker walker, void* user);
-/* Returns nonzero if any internal consistency check fails. */
-int tlsf_check(tlsf_t tlsf);
-int tlsf_check_pool(pool_t pool);
-
-#if defined(__cplusplus)
-};
-#endif
-
-#endif
diff --git a/sys/include/vm/vm.h b/sys/include/vm/vm.h deleted file mode 100644 index 1c23b8a..0000000 --- a/sys/include/vm/vm.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hyra 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. - */ - -/* - * For documentation: See vm(9) - */ - -#ifndef _VM_H_ -#define _VM_H_ - -#include <sys/types.h> -#include <sys/limine.h> -#include <sys/cdefs.h> -#include <vm/page.h> -#include <vm/pmap.h> -#include <vm/physseg.h> - -extern volatile struct limine_hhdm_request g_hhdm_request; - -#define VM_HIGHER_HALF (g_hhdm_request.response->offset) - -#define PHYS_TO_VIRT(phys) (void *)((uintptr_t)phys + VM_HIGHER_HALF) -#define VIRT_TO_PHYS(virt) ((uintptr_t)virt - VM_HIGHER_HALF) - -struct vm_range { - uintptr_t start; - uintptr_t end; -}; - -struct vm_memstat { - struct physmem_stat pmem_stat; - size_t vmobj_cnt; -}; - -/* - * Returns the machine's pagesize: - * - * XXX TODO: This needs to be moved to vmm_init.c - * while returning a non-constant value. - */ -static inline size_t -vm_get_page_size(void) -{ - return 4096; -} - -void vm_init(void); -struct vm_ctx *vm_get_ctx(void); -struct vas vm_get_kvas(void); -struct vm_memstat vm_memstat(void); - -#endif /* !_VM_H_ */ |