projects
/
debian
/
elilo
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Imported Debian patch 3.12-4.1
[debian/elilo]
/
alloc.c
diff --git
a/alloc.c
b/alloc.c
index 349da9f24e6dbc85101f99fcc3645ff8077f1c51..6f463e4324e4e03199672ecaa6d321ef39f0ec25 100644
(file)
--- a/
alloc.c
+++ b/
alloc.c
@@
-1,6
+1,9
@@
/*
* Copyright (C) 2001-2003 Hewlett-Packard Co.
* Contributed by Stephane Eranian <eranian@hpl.hp.com>
/*
* Copyright (C) 2001-2003 Hewlett-Packard Co.
* Contributed by Stephane Eranian <eranian@hpl.hp.com>
+ * Contributed by Fenghua Yu <Fenghua.Yu@intel.com>
+ * Contributed by Bibo Mao <bibo.mao@intel.com>
+ * Contributed by Chandramouli Narayanan <mouli@linux.intel.com>
*
* This file is part of the ELILO, the EFI Linux boot loader.
*
*
* This file is part of the ELILO, the EFI Linux boot loader.
*
@@
-100,15
+103,15
@@
alloc(UINTN size, EFI_MEMORY_TYPE type)
if (type == 0) type = EfiLoaderData;
if (type == 0) type = EfiLoaderData;
- status =
BS->AllocatePool (
type, size, &tmp);
+ status =
uefi_call_wrapper(BS->AllocatePool, 3,
type, size, &tmp);
if (EFI_ERROR(status)) {
if (EFI_ERROR(status)) {
- ERR_PRT((L"allocator: AllocatePool(%d, %d
, 0x%x
) failed (%r)\n", type, size, status));
+ ERR_PRT((L"allocator: AllocatePool(%d, %d) failed (%r)\n", type, size, status));
return NULL;
}
alloc_add(tmp, size, ALLOC_POOL);
return NULL;
}
alloc_add(tmp, size, ALLOC_POOL);
-
- DBG_PRT((L"alloc: allocated %d bytes @[
0x%lx-0x%lx
]\n", size, tmp, tmp+size));
-
+#ifdef DEBUG_MEM
+ DBG_PRT((L"alloc: allocated %d bytes @[
" PTR_FMT "-" PTR_FMT "
]\n", size, tmp, tmp+size));
+#endif
return tmp;
}
return tmp;
}
@@
-127,9
+130,9
@@
alloc_pages(UINTN pgcnt, EFI_MEMORY_TYPE type, EFI_ALLOCATE_TYPE where, VOID *ad
return NULL;
}
return NULL;
}
- status =
BS->AllocatePages(
where, type , pgcnt, &tmp);
+ status =
uefi_call_wrapper(BS->AllocatePages, 4,
where, type , pgcnt, &tmp);
if (EFI_ERROR(status)) {
if (EFI_ERROR(status)) {
- VERB_PRT(1, (L"allocator: AllocatePages(%d, %d, %d, 0x%lx) failed (%r)\n", where, type, pgcnt, tmp, status));
+ VERB_PRT(1,
Print
(L"allocator: AllocatePages(%d, %d, %d, 0x%lx) failed (%r)\n", where, type, pgcnt, tmp, status));
return NULL;
}
/* XXX: will cause warning on IA-32 */
return NULL;
}
/* XXX: will cause warning on IA-32 */
@@
-155,17
+158,18
@@
free(VOID *addr)
if (p->addr == addr) goto found;
}
/* not found */
if (p->addr == addr) goto found;
}
/* not found */
- VERB_PRT(1,
(L"allocator: invalid free @ 0x%lx
\n", addr));
+ VERB_PRT(1,
Print(L"allocator: invalid free @ " PTR_FMT "
\n", addr));
return;
found:
return;
found:
- DBG_PRT((L"free: %s @0x%lx size=%ld\n",
+#ifdef DEBUG_MEM
+ DBG_PRT((L"free: %s @" PTR_FMT " size=%d\n",
p->type == ALLOC_POOL ? L"Pool": L"Page",
addr, p->size));
p->type == ALLOC_POOL ? L"Pool": L"Page",
addr, p->size));
-
+#endif
if (p->type == ALLOC_POOL)
if (p->type == ALLOC_POOL)
-
BS->FreePool(
addr);
+
uefi_call_wrapper(BS->FreePool, 1,
addr);
else
else
-
BS->FreePages(
(EFI_PHYSICAL_ADDRESS)addr, p->size);
+
uefi_call_wrapper(BS->FreePages, 2,
(EFI_PHYSICAL_ADDRESS)addr, p->size);
/* remove from used list */
if (p->next)
/* remove from used list */
if (p->next)
@@
-191,13
+195,13
@@
free_all(VOID)
alloc_entry_t *tmp;
while(used_allocs) {
alloc_entry_t *tmp;
while(used_allocs) {
-
- DBG_PRT((L"free_all %a @
0x%lx
\n", used_allocs->type == ALLOC_POOL ? "pool" : "pages", used_allocs->addr));
-
+#ifdef DEBUG_MEM
+ DBG_PRT((L"free_all %a @
" PTR_FMT "
\n", used_allocs->type == ALLOC_POOL ? "pool" : "pages", used_allocs->addr));
+#endif
if (used_allocs->type == ALLOC_POOL)
if (used_allocs->type == ALLOC_POOL)
-
BS->FreePool(
used_allocs->addr);
+
uefi_call_wrapper(BS->FreePool, 1,
used_allocs->addr);
else
else
-
BS->FreePages(
(EFI_PHYSICAL_ADDRESS)used_allocs->addr, used_allocs->size);
+
uefi_call_wrapper(BS->FreePages, 2,
(EFI_PHYSICAL_ADDRESS)used_allocs->addr, used_allocs->size);
tmp = used_allocs->next;
tmp = used_allocs->next;
@@
-209,6
+213,19
@@
free_all(VOID)
}
}
}
}
+INTN
+alloc_kmem_anywhere(VOID **start_addr, UINTN pgcnt)
+{
+ void * tmp;
+ if ((tmp = alloc_pages(pgcnt, EfiLoaderData, AllocateAnyPages, *start_addr)) == 0) return -1;
+
+ kmem_addr = tmp;
+ kmem_pgcnt = pgcnt;
+ *start_addr = tmp;
+
+ return 0;
+}
+
INTN
alloc_kmem(VOID *start_addr, UINTN pgcnt)
{
INTN
alloc_kmem(VOID *start_addr, UINTN pgcnt)
{
@@
-223,13
+240,17
@@
alloc_kmem(VOID *start_addr, UINTN pgcnt)
VOID
free_kmem(VOID)
{
VOID
free_kmem(VOID)
{
- DBG_PRT((L"free_kmem before (%lx, %ld)\n", kmem_addr, kmem_pgcnt));
+#ifdef DEBUG_MEM
+ DBG_PRT((L"free_kmem before (" PTR_FMT ", %d)\n", kmem_addr, kmem_pgcnt));
+#endif
if (kmem_addr && kmem_pgcnt != 0) {
free(kmem_addr);
kmem_addr = NULL;
kmem_pgcnt = 0;
}
if (kmem_addr && kmem_pgcnt != 0) {
free(kmem_addr);
kmem_addr = NULL;
kmem_pgcnt = 0;
}
- DBG_PRT((L"free_kmem after (%lx, %ld)\n", kmem_addr, kmem_pgcnt));
+#ifdef DEBUG_MEM
+ DBG_PRT((L"free_kmem after (" PTR_FMT ", %d)\n", kmem_addr, kmem_pgcnt));
+#endif
}
VOID
}
VOID