| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- /* include/kernel/mm.h
- *
- * This file is part of evx.
- *
- * evx 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 3 of the License, or
- * (at your option) any later version.
- *
- * evx 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 evx. If not, see <https://www.gnu.org/licenses/>
- */
- #ifndef __MM_H
- #define __MM_H
- #ifndef __ASSEMBLER__
- #include <sys/types.h>
- #include <arch/archinfo.h>
- /* a descriptor for each page to describe a page, hopely be smallest
- * and this is create only for the buddy memory management system. we
- * can't implement that without this, because we need more memory when
- * inserting.
- *
- * we should initiallize this as late as we can, after maps okay.
- * */
- struct page {
- /* for cow, the reference count. we won't free if count-- */
- __uint32_t count;
- struct page *next;
- };
- /* okay, that's may only in the x86, but... */
- struct zone {
- __uint32_t total_pages;
- #define ZONETYPE_RAM 1
- #define ZONETYPE_OTHER 0
- __uint32_t type;
- void *start_addr;
-
- struct page *pages;
- };
- /* sets by arch_mm_init */
- extern struct page *first_usable_ram;
- #define kmem_zones ((struct zone *) kernel_end)
- #define kmem_pages ((struct page *) (kmem_zones + 2))
- /* they're really early but fast. actually, most free() did nothing
- *
- * WARNING that you should't use align, because we didn't save old
- * freeptr and it will be cracked by it: not freeable */
- void *early_kmalloc(int nbytes, int align);
- int early_free(void *p, int nbytes);
- #endif
- #endif
|