POK(kernelpart)
/home/jaouen/pok_official/pok/trunk/kernel/arch/x86/x86-qemu/pm.c
Go to the documentation of this file.
00001 /*
00002  *                               POK header
00003  * 
00004  * The following file is a part of the POK project. Any modification should
00005  * made according to the POK licence. You CANNOT use this file or a part of
00006  * this file is this part of a file for your own project
00007  *
00008  * For more information on the POK licence, please see our LICENCE FILE
00009  *
00010  * Please follow the coding guidelines described in doc/CODING_GUIDELINES
00011  *
00012  *                                      Copyright (c) 2007-2009 POK team 
00013  *
00014  * Created by julien on Thu Jan 15 23:34:13 2009 
00015  */
00016 
00024 #include <errno.h>
00025 #include <arch/x86/multiboot.h>
00026 #include <types.h>
00027 
00028 #include "pm.h"
00029 
00030 #define ALIGN_UP(boundary, val) \
00031         (val + (boundary - 1)) & (~(boundary - 1))
00032 
00033 extern void *__pok_begin;
00034 extern void *__pok_end;
00035 
00036 extern uint32_t pok_multiboot_magic;
00037 extern uint32_t pok_multiboot_info;
00038 
00039 uint32_t pok_x86_pm_heap_start;
00040 uint32_t pok_x86_pm_brk;
00041 uint32_t pok_x86_pm_heap_end;
00042 
00043 
00044 int pok_pm_init ()
00045 {
00046   pok_multiboot_info_t* mbi;
00047   uint32_t              free_mem;
00048 
00049   mbi = (pok_multiboot_info_t*) pok_multiboot_info;
00050 
00051 #ifdef POK_NEEDS_DMA
00052   free_mem = MEM_16MB;
00053 #else
00054   free_mem = ALIGN_UP (4096, (uint32_t)(&__pok_end));
00055 #endif
00056 
00057   pok_x86_pm_heap_start = pok_x86_pm_brk = free_mem;
00058 
00059   pok_x86_pm_heap_end = (uint32_t)(mbi->mem_upper * 1024);
00060 
00061   return (POK_ERRNO_OK);
00062 }
00063 
00068 uint32_t pok_pm_sbrk (uint32_t increment)
00069 {
00070   uint32_t addr;
00071   
00072   addr = pok_x86_pm_brk;
00073 
00074   pok_x86_pm_brk += increment;
00075 
00076   return (addr);
00077 }
00078