1223695Sdfr/*- 2223695Sdfr * Copyright (c) 1998 Michael Smith <msmith@freebsd.org> 3223695Sdfr * All rights reserved. 4223695Sdfr * 5223695Sdfr * Redistribution and use in source and binary forms, with or without 6223695Sdfr * modification, are permitted provided that the following conditions 7223695Sdfr * are met: 8223695Sdfr * 1. Redistributions of source code must retain the above copyright 9223695Sdfr * notice, this list of conditions and the following disclaimer. 10223695Sdfr * 2. Redistributions in binary form must reproduce the above copyright 11223695Sdfr * notice, this list of conditions and the following disclaimer in the 12223695Sdfr * documentation and/or other materials provided with the distribution. 13223695Sdfr * 14223695Sdfr * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15223695Sdfr * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16223695Sdfr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17223695Sdfr * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18223695Sdfr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19223695Sdfr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20223695Sdfr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21223695Sdfr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22223695Sdfr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23223695Sdfr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24223695Sdfr * SUCH DAMAGE. 25223695Sdfr */ 26223695Sdfr 27223695Sdfr#include <sys/cdefs.h> 28223695Sdfr__FBSDID("$FreeBSD$"); 29223695Sdfr 30223695Sdfr#include <stand.h> 31223695Sdfr#include <sys/param.h> 32223695Sdfr#include <sys/reboot.h> 33223695Sdfr#include <sys/linker.h> 34261504Sjhb#include <machine/pc/bios.h> 35261504Sjhb#include <machine/metadata.h> 36223695Sdfr 37223695Sdfr#include "bootstrap.h" 38223695Sdfr#include "libuserboot.h" 39223695Sdfr 40223695Sdfr#define GB (1024UL * 1024 * 1024) 41223695Sdfr 42261504Sjhbvoid 43223695Sdfrbios_addsmapdata(struct preloaded_file *kfp) 44223695Sdfr{ 45223695Sdfr uint64_t lowmem, highmem; 46223695Sdfr int smapnum, len; 47261504Sjhb struct bios_smap smap[3], *sm; 48223695Sdfr 49223695Sdfr CALLBACK(getmem, &lowmem, &highmem); 50223695Sdfr 51223695Sdfr sm = &smap[0]; 52223695Sdfr 53223695Sdfr sm->base = 0; /* base memory */ 54223695Sdfr sm->length = 640 * 1024; 55223695Sdfr sm->type = SMAP_TYPE_MEMORY; 56223695Sdfr sm++; 57223695Sdfr 58223695Sdfr sm->base = 0x100000; /* extended memory */ 59223695Sdfr sm->length = lowmem - 0x100000; 60223695Sdfr sm->type = SMAP_TYPE_MEMORY; 61223695Sdfr sm++; 62223695Sdfr 63223695Sdfr smapnum = 2; 64223695Sdfr 65223695Sdfr if (highmem != 0) { 66223695Sdfr sm->base = 4 * GB; 67223695Sdfr sm->length = highmem; 68223695Sdfr sm->type = SMAP_TYPE_MEMORY; 69223695Sdfr smapnum++; 70223695Sdfr } 71223695Sdfr 72261504Sjhb len = smapnum * sizeof(struct bios_smap); 73223695Sdfr file_addmetadata(kfp, MODINFOMD_SMAP, len, &smap[0]); 74223695Sdfr} 75