merge mainline into newreloc
This commit is contained in:
commit
6a82c1b2db
26 changed files with 429 additions and 97 deletions
|
@ -26,6 +26,7 @@
|
|||
#include <grub/file.h>
|
||||
#include <grub/device.h>
|
||||
#include <grub/command.h>
|
||||
#include <grub/i18n.h>
|
||||
|
||||
/* set ENVVAR=VALUE */
|
||||
static grub_err_t
|
||||
|
@ -178,11 +179,13 @@ void
|
|||
grub_register_core_commands (void)
|
||||
{
|
||||
grub_register_command ("set", grub_core_cmd_set,
|
||||
"[ENVVAR=VALUE]", "Set an environment variable.");
|
||||
N_("[ENVVAR=VALUE]"),
|
||||
N_("Set an environment variable."));
|
||||
grub_register_command ("unset", grub_core_cmd_unset,
|
||||
"ENVVAR", "Remove an environment variable.");
|
||||
N_("ENVVAR"),
|
||||
N_("Remove an environment variable."));
|
||||
grub_register_command ("ls", grub_core_cmd_ls,
|
||||
"[ARG]", "List devices or files.");
|
||||
N_("[ARG]"), N_("List devices or files."));
|
||||
grub_register_command ("insmod", grub_core_cmd_insmod,
|
||||
"MODULE", "Insert a module.");
|
||||
N_("MODULE"), N_("Insert a module."));
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ grub_load_config (void)
|
|||
auto int hook (struct grub_module_header *);
|
||||
int hook (struct grub_module_header *header)
|
||||
{
|
||||
/* Not an ELF module, skip. */
|
||||
/* Not an embedded config, skip. */
|
||||
if (header->type != OBJ_TYPE_CONFIG)
|
||||
return 0;
|
||||
|
||||
|
|
35
kern/mm.c
35
kern/mm.c
|
@ -113,14 +113,14 @@ grub_mm_init_region (void *addr, grub_size_t size)
|
|||
grub_printf ("Using memory for heap: start=%p, end=%p\n", addr, addr + (unsigned int) size);
|
||||
#endif
|
||||
|
||||
/* If this region is too small, ignore it. */
|
||||
if (size < GRUB_MM_ALIGN * 2)
|
||||
return;
|
||||
|
||||
/* Allocate a region from the head. */
|
||||
r = (grub_mm_region_t) ALIGN_UP ((grub_addr_t) addr, GRUB_MM_ALIGN);
|
||||
size -= (char *) r - (char *) addr + sizeof (*r);
|
||||
|
||||
/* If this region is too small, ignore it. */
|
||||
if (size < GRUB_MM_ALIGN)
|
||||
return;
|
||||
|
||||
h = (grub_mm_header_t) (r + 1);
|
||||
h->next = h;
|
||||
h->magic = GRUB_MM_FREE_MAGIC;
|
||||
|
@ -185,9 +185,8 @@ grub_real_malloc (grub_mm_header_t *first, grub_size_t n, grub_size_t align)
|
|||
+---------------+ v
|
||||
*/
|
||||
q->next = p->next;
|
||||
p->magic = GRUB_MM_ALLOC_MAGIC;
|
||||
}
|
||||
else if (extra == 0 || p->size == n + extra)
|
||||
else if (align == 1 || p->size == n + extra)
|
||||
{
|
||||
/* There might be alignment requirement, when taking it into
|
||||
account memory block fits in.
|
||||
|
@ -204,10 +203,25 @@ grub_real_malloc (grub_mm_header_t *first, grub_size_t n, grub_size_t align)
|
|||
| alloc, size=n | |
|
||||
+---------------+ v
|
||||
*/
|
||||
|
||||
p->size -= n;
|
||||
p += p->size;
|
||||
p->size = n;
|
||||
p->magic = GRUB_MM_ALLOC_MAGIC;
|
||||
}
|
||||
else if (extra == 0)
|
||||
{
|
||||
grub_mm_header_t r;
|
||||
|
||||
r = p + extra + n;
|
||||
r->magic = GRUB_MM_FREE_MAGIC;
|
||||
r->size = p->size - extra - n;
|
||||
r->next = p->next;
|
||||
q->next = r;
|
||||
|
||||
if (q == p)
|
||||
{
|
||||
q = r;
|
||||
r->next = r;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -241,10 +255,11 @@ grub_real_malloc (grub_mm_header_t *first, grub_size_t n, grub_size_t align)
|
|||
p->size = extra;
|
||||
q->next = r;
|
||||
p += extra;
|
||||
p->size = n;
|
||||
p->magic = GRUB_MM_ALLOC_MAGIC;
|
||||
}
|
||||
|
||||
p->magic = GRUB_MM_ALLOC_MAGIC;
|
||||
p->size = n;
|
||||
|
||||
/* Mark find as a start marker for next allocation to fasten it.
|
||||
This will have side effect of fragmenting memory as small
|
||||
pieces before this will be un-used. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue