X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fmem.c;fp=src%2Fmem.c;h=1d5db9e87b6efd653980188b2a68a810ff26dac8;hb=79be435fcf61613617025a2c4ef5fddf00a09178;hp=0000000000000000000000000000000000000000;hpb=5a961b914da78d534e8e2dc6bfb5103114dbff54;p=bootcensus diff --git a/src/mem.c b/src/mem.c new file mode 100644 index 0000000..1d5db9e --- /dev/null +++ b/src/mem.c @@ -0,0 +1,44 @@ +/* +pcboot - bootable PC demo/game kernel +Copyright (C) 2018 John Tsiombikas + +This program 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. + +This program 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 this program. If not, see . +*/ +#include +#include "panic.h" +#include "mem.h" + +struct mem_range { + uint32_t start; + uint32_t size; +}; + +#define MAX_MAP_SIZE 16 +extern struct mem_range boot_mem_map[MAX_MAP_SIZE]; +extern int boot_mem_map_size; + +void init_mem(void) +{ + int i; + + if(boot_mem_map_size <= 0 || boot_mem_map_size > MAX_MAP_SIZE) { + panic("invalid memory map size reported by the boot loader: %d\n", boot_mem_map_size); + } + + printf("Memory map:\n"); + for(i=0; i