/* 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 */ #ifndef __MM_H #define __MM_H #ifndef __ASSEMBLER__ #include #include /* 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 { /* number of this page */ __archptr_t pnr; /* 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; }; #define kmem_zones ((struct zone *) &_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