2 * Copyright (C) 2001-2003 Hewlett-Packard Co.
3 * Contributed by Stephane Eranian <eranian@hpl.hp.com>
5 * This file is part of the ELILO, the EFI Linux boot loader.
7 * ELILO is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
12 * ELILO is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with ELILO; see the file COPYING. If not, write to the Free
19 * Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 * Please check out the elilo.txt for complete documentation on how
23 * to use this program.
32 * Initialize the generic part of the boot parameters and call the architecture specific
35 * cookie: the memory map cookie to use with ExitBootServices()
37 * NULL: if an error occured
38 * bp : the address of the bootparams otherwise (opaque type)
41 create_boot_params(CHAR16 *args, memdesc_t *initrd, memdesc_t *vmcode, UINTN *cookie)
45 * See ia32 code for explanation on why it is so big.
47 #define BOOT_PARAM_MEMSIZE 16384
48 UINTN bpsize, cmdline_size;
54 * Allocate runtime services memory to hold memory descriptor table and
55 * command line arguments and fetch memory map:
57 * arg_size = number of character in ASCII form
59 cmdline_size = StrLen(args) + 1;
60 bpsize = sizeof(boot_params_t) + cmdline_size;
62 if (bpsize > BOOT_PARAM_MEMSIZE) {
63 ERR_PRT((L"BOOT_PARAM_MEMSIZE too small, need at least %d bytes", bpsize));
69 * Allocate memory for boot parameters.
70 * This CANNOT be EfiLoaderData or EfiLoaderCode as the kernel
71 * frees this region when initializing.
72 * FIXME: Is this a bug? (since the memory type *is* EfiLoaderData)
75 bp = (boot_params_t *)alloc(BOOT_PARAM_MEMSIZE, EfiLoaderData);
77 ERR_PRT((L"can't allocate boot params"));
81 VERB_PRT(3, Print(L"boot params @ 0x%lx\n", bp));
83 /* XXX: need to fix this for 3.5 */
85 cp = ((CHAR8 *)bp) + BOOT_PARAM_MEMSIZE - cmdline_size;
86 #elif defined CONFIG_ia32
87 cp = ((CHAR8 *)bp) + BOOT_PARAM_MEMSIZE - 2048;
91 * clear entire buffer. The boot param structure is bigger than
92 * needs be but this allows the kernel bootparam structure to grow
93 * (up to BOOT_PARAM_MEMSIZE) without having to worry about fixing the bootloader.
94 * By convention between the laoder and the kernel, the value 0 means
95 * don't care or not set.
97 Memset(bp, 0, BOOT_PARAM_MEMSIZE);
99 if (sysdeps_create_boot_params(bp, cp, initrd, vmcode, cookie) == -1) return 0;
102 * Convert kernel command line args from UNICODE to ASCII and put them where
103 * the kernel expects them:
116 free_boot_params(VOID *bp)
118 boot_params_t *real_bp = (boot_params_t *)bp;
120 sysdeps_free_boot_params(real_bp);