add memory routines
This commit is contained in:
parent
d5b44e501d
commit
0f355bc6b3
6 changed files with 164 additions and 19 deletions
|
@ -26,6 +26,10 @@
|
|||
#include <grub/machine/loader.h>
|
||||
#include <grub/command.h>
|
||||
#include <grub/mips/relocator.h>
|
||||
#include <grub/machine/memory.h>
|
||||
|
||||
/* For frequencies. */
|
||||
#include <grub/pci.h>
|
||||
|
||||
#define ELF32_LOADMASK (0x00000000UL)
|
||||
#define ELF64_LOADMASK (0x0000000000000000ULL)
|
||||
|
@ -176,7 +180,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
|||
int size;
|
||||
void *extra = NULL;
|
||||
grub_uint32_t *linux_argv, *linux_envp;
|
||||
char *linux_args;
|
||||
char *linux_args, *linux_envs;
|
||||
grub_err_t err;
|
||||
|
||||
if (argc == 0)
|
||||
|
@ -218,7 +222,12 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
|||
size += ALIGN_UP (sizeof ("rd_size=0xXXXXXXXXXXXXXXXX"), 4);
|
||||
|
||||
/* For the environment. */
|
||||
size += sizeof (grub_uint32_t);
|
||||
size += sizeof (grub_uint32_t);
|
||||
size += 4 * sizeof (grub_uint32_t);
|
||||
size += ALIGN_UP (sizeof ("memsize=XXXXXXXXXXXXXXXXXXXX"), 4)
|
||||
+ ALIGN_UP (sizeof ("highmemsize=XXXXXXXXXXXXXXXXXXXX"), 4)
|
||||
+ ALIGN_UP (sizeof ("busclock=XXXXXXXXXX"), 4)
|
||||
+ ALIGN_UP (sizeof ("cpuclock=XXXXXXXXXX"), 4);
|
||||
|
||||
if (grub_elf_is_elf32 (elf))
|
||||
err = grub_linux_load32 (elf, &extra, size);
|
||||
|
@ -276,7 +285,27 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
|||
|
||||
linux_envp = extra;
|
||||
envp_off = (grub_uint8_t *) linux_envp - (grub_uint8_t *) playground;
|
||||
linux_envp[0] = 0;
|
||||
linux_envs = (char *) (linux_envp + 5);
|
||||
grub_sprintf (linux_envs, "memsize=%lld", (unsigned long long) grub_mmap_get_lower () >> 20);
|
||||
linux_envp[0] = (grub_uint8_t *) linux_envs - (grub_uint8_t *) playground
|
||||
+ target_addr;
|
||||
linux_envs += ALIGN_UP (grub_strlen (linux_envs) + 1, 4);
|
||||
grub_sprintf (linux_envs, "highmemsize=%lld", (unsigned long long) grub_mmap_get_upper () >> 20);
|
||||
linux_envp[1] = (grub_uint8_t *) linux_envs - (grub_uint8_t *) playground
|
||||
+ target_addr;
|
||||
linux_envs += ALIGN_UP (grub_strlen (linux_envs) + 1, 4);
|
||||
|
||||
grub_sprintf (linux_envs, "busclock=%d", grub_arch_busclock);
|
||||
linux_envp[2] = (grub_uint8_t *) linux_envs - (grub_uint8_t *) playground
|
||||
+ target_addr;
|
||||
linux_envs += ALIGN_UP (grub_strlen (linux_envs) + 1, 4);
|
||||
grub_sprintf (linux_envs, "cpuclock=%d", grub_arch_cpuclock);
|
||||
linux_envp[3] = (grub_uint8_t *) linux_envs - (grub_uint8_t *) playground
|
||||
+ target_addr;
|
||||
linux_envs += ALIGN_UP (grub_strlen (linux_envs) + 1, 4);
|
||||
|
||||
|
||||
linux_envp[4] = 0;
|
||||
|
||||
grub_loader_set (grub_linux_boot, grub_linux_unload, 1);
|
||||
initrd_loaded = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue