copy.c revision 199767f8919635c4928607450d9e0abb932109ce
/*-
* Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
* Copyright (c) 2007 Semihalf, Rafal Jaworowski <raj@semihalf.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
__FBSDID("$FreeBSD$");
#include <stand.h>
#include <stdint.h>
#include "api_public.h"
#include "glue.h"
#include "libuboot.h"
/*
* MD primitives supporting placement of module data
*/
#ifdef __arm__
#else
#define KERN_ALIGN PAGE_SIZE
#endif
/*
* Avoid low memory, u-boot puts things like args and dtb blobs there.
*/
extern void _start(void); /* ubldr entry point address. */
/*
* This is called for every object loaded (kernel, module, dtb file, etc). The
* expected return value is the next address at or after the given addr which is
* appropriate for loading the given object described by type and data. On each
* call the addr is the next address following the previously loaded object.
*
* The first call is for loading the kernel, and the addr argument will be zero,
* and we search for a big block of ram to load the kernel and modules.
*
* On subsequent calls the addr will be non-zero, and we just round it up so
* that each object begins on a page boundary.
*/
{
int i;
char *envstr;
if (addr == 0) {
/*
* If the loader_kernaddr environment variable is set, blindly
* honor it. It had better be right. We force interpretation
* of the value in base-16 regardless of any leading 0x prefix,
* because that's the U-Boot convention.
*/
/*
* range out of the block, because loading the kernel over the
* top ourself is a poor memory-conservation strategy. Avoid
* memory at beginning of the first block of physical ram,
* since u-boot likes to pass args and data there. Assume that
* u-boot has moved itself to the very top of ram and
* optimistically assume that we won't run into it up there.
*/
panic("could not retrieve system info");
biggest_block = 0;
biggest_size = 0;
continue;
if (biggest_size == 0)
sblock += KERN_MINADDR;
this_block = sblock;
} else {
this_block = eubldr;
}
/* Loader is below or engulfs the sblock */
} else {
this_block = 0;
this_size = 0;
}
if (biggest_size < this_size) {
}
}
if (biggest_size == 0)
panic("Not enough DRAM to load kernel\n");
#if 0
printf("Loading kernel into region 0x%08jx-0x%08jx (%ju MiB)\n",
#endif
return (biggest_block);
}
}
{
return (len);
}
{
return (len);
}
{
}