openblt

a hobby OS from the late 90s
git clone http://frotz.net/git/openblt.git
Log | Files | Refs | LICENSE

memory.h (1223B)


      1 /* Copyright 1998-1999, Brian J. Swetland. All rights reserved.
      2 ** Distributed under the terms of the OpenBLT License
      3 */
      4 
      5 #ifndef _MEMORY_H_
      6 #define _MEMORY_H_
      7 
      8 #include "types.h"
      9 
     10 #define KM16   0
     11 #define KM32   1
     12 #define KM64   2
     13 #define KM96   3
     14 #define KM128  4
     15 #define KM192  5
     16 #define KM256  6
     17 #define KMMAX  7
     18 
     19 uint32 getpage(void);                 /* allocate a single physical page */
     20 void putpage(uint32);                 /* release a single physical page */
     21 
     22 void *kgetpage(uint32 *phys);         /* allocate one page (and return phys addr) */
     23 void *kgetpages(int count);           /* allocate count pages */
     24 void kfreepage(void *vaddr);
     25 void *kmallocP(int pool);             /* allocate from pool (eg KM16, KM128, ...)*/
     26 void kfreeP(int pool, void *block);   /* release back to pool */
     27 
     28 void *kmallocB(int size);             /* allocate from appropriate pool for size */
     29 void kfreeB(int size, void *block);   /* release back to appropriate pool */
     30 #define kmalloc(type) kmallocB(sizeof(type))
     31 #define kfree(type,ptr) kfreeB(sizeof(type),ptr)
     32 
     33 void memory_init(uint32 bottom, uint32 top); /* only call once - on kernel launch */
     34 void memory_status(void);             /* dump memory usage information */
     35 
     36 #endif
     37