mirror of
https://github.com/drasko/codezero.git
synced 2026-01-12 10:53:16 +01:00
Added freeing of pager init memory, but this memory is currently not utilized.
This commit is contained in:
@@ -6,6 +6,12 @@
|
||||
#include <l4/generic/resource.h>
|
||||
#include <l4/generic/capability.h>
|
||||
|
||||
void capability_init(struct capability *cap)
|
||||
{
|
||||
cap->capid = id_new(&kernel_container.capability_ids);
|
||||
link_init(&cap->list);
|
||||
}
|
||||
|
||||
struct capability *capability_create(void)
|
||||
{
|
||||
struct capability *cap = alloc_capability();
|
||||
@@ -15,9 +21,3 @@ struct capability *capability_create(void)
|
||||
return cap;
|
||||
}
|
||||
|
||||
void capability_init(struct capability *cap)
|
||||
{
|
||||
cap->capid = id_new(&kernel_container.capability_ids);
|
||||
link_init(&cap->list);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,5 +37,6 @@ extern struct cap_list capability_list;
|
||||
|
||||
struct initdata;
|
||||
int read_kernel_capabilities(struct initdata *);
|
||||
void copy_boot_capabilities(struct initdata *initdata);
|
||||
|
||||
#endif /* __MM0_CAPABILITY_H__ */
|
||||
|
||||
@@ -36,16 +36,20 @@ SECTIONS
|
||||
.bss : AT (ADDR(.bss) - pager_offset) { *(.bss) }
|
||||
. = ALIGN(4K);
|
||||
. += 0x2000; /* BSS doesnt increment link counter??? */
|
||||
.stack : AT (ADDR(.stack) - pager_offset)
|
||||
{
|
||||
*(.stack)
|
||||
}
|
||||
. = ALIGN(4K);
|
||||
__stack = .; /* This is the preallocated boot stack */
|
||||
|
||||
/* Below part is to be discarded after boot */
|
||||
_start_init = .;
|
||||
.init : AT (ADDR(.init) - pager_offset)
|
||||
{
|
||||
*(.init.data)
|
||||
*(.init.bootmem)
|
||||
*(.init.stack)
|
||||
}
|
||||
_end_init = .;
|
||||
__stack = .; /* This is the preallocated boot stack */
|
||||
_end_init = .;
|
||||
_end = .;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#define BOOTMEM_SIZE SZ_32K
|
||||
|
||||
SECTION(".init.bootmem") char bootmem[BOOTMEM_SIZE];
|
||||
SECTION(".init.stack") char stack[4096];
|
||||
SECTION(".stack") char stack[4096];
|
||||
// SECTION("init.data")
|
||||
|
||||
extern unsigned long __stack[]; /* Linker defined */
|
||||
|
||||
@@ -5,14 +5,36 @@
|
||||
*/
|
||||
#include <bootm.h>
|
||||
#include <init.h>
|
||||
#include <l4/lib/list.h>
|
||||
#include <capability.h>
|
||||
#include <l4/api/capability.h>
|
||||
#include <l4lib/arch/syscalls.h>
|
||||
#include <l4/generic/cap-types.h> /* TODO: Move this to API */
|
||||
#include <lib/malloc.h>
|
||||
|
||||
extern struct cap_list capability_list;
|
||||
struct cap_list capability_list;
|
||||
|
||||
__initdata static struct capability *caparray;
|
||||
__initdata static int total_caps = 0;
|
||||
|
||||
/* Copy all init-memory allocated capabilities */
|
||||
void copy_boot_capabilities(struct initdata *initdata)
|
||||
{
|
||||
struct capability *cap;
|
||||
|
||||
for (int i = 0; i < total_caps; i++) {
|
||||
cap = kzalloc(sizeof(struct capability));
|
||||
|
||||
/* This copies kernel-allocated unique cap id as well */
|
||||
memcpy(cap, &caparray[i], sizeof(struct capability));
|
||||
|
||||
/* Initialize capability list */
|
||||
link_init(&cap->list);
|
||||
|
||||
/* Add capability to global cap list */
|
||||
list_insert(&capability_list.caps, &cap->list);
|
||||
}
|
||||
}
|
||||
|
||||
int read_kernel_capabilities(struct initdata *initdata)
|
||||
{
|
||||
@@ -25,6 +47,7 @@ int read_kernel_capabilities(struct initdata *initdata)
|
||||
"Could not complete CAP_CONTROL_NCAPS request.\n");
|
||||
goto error;
|
||||
}
|
||||
total_caps = ncaps;
|
||||
|
||||
/* Allocate array of caps from boot memory */
|
||||
caparray = alloc_bootmem(sizeof(struct capability) * ncaps, 0);
|
||||
|
||||
@@ -207,6 +207,33 @@ int start_boot_tasks(struct initdata *initdata)
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern unsigned long _start_init[];
|
||||
extern unsigned long _end_init[];
|
||||
|
||||
/*
|
||||
* Copy all necessary data from initmem to real memory,
|
||||
* release initdata and any init memory used
|
||||
*/
|
||||
void copy_release_initdata(struct initdata *initdata)
|
||||
{
|
||||
/*
|
||||
* Copy boot capabilities to a list of
|
||||
* real capabilities
|
||||
*/
|
||||
copy_boot_capabilities(initdata);
|
||||
|
||||
/* Free and unmap init memory:
|
||||
*
|
||||
* FIXME: We can and do safely unmap the boot
|
||||
* memory here, but because we don't utilize it yet,
|
||||
* it remains as if it is a used block
|
||||
*/
|
||||
|
||||
l4_unmap(_start_init,
|
||||
__pfn(page_align_up(_end_init - _start_init)),
|
||||
self_tid());
|
||||
}
|
||||
|
||||
|
||||
void init_mm(struct initdata *initdata)
|
||||
{
|
||||
@@ -257,6 +284,9 @@ void init_pager(void)
|
||||
|
||||
start_boot_tasks(&initdata);
|
||||
|
||||
/* Copy necessary initdata info */
|
||||
copy_release_initdata(&initdata);
|
||||
|
||||
mm0_test_global_vm_integrity();
|
||||
}
|
||||
|
||||
|
||||
@@ -304,7 +304,11 @@ int init_boot_files(struct initdata *initdata)
|
||||
for (int i = 0; i < bd->total_images; i++) {
|
||||
img = &bd->images[i];
|
||||
boot_file = vm_file_create();
|
||||
boot_file->priv_data = img;
|
||||
|
||||
/* Allocate private data */
|
||||
boot_file->priv_data = kzalloc(sizeof(*img));
|
||||
memcpy(boot_file->priv_data, img, sizeof(*img));
|
||||
|
||||
boot_file->length = img->phys_end - img->phys_start;
|
||||
boot_file->type = VM_FILE_BOOTFILE;
|
||||
boot_file->destroy_priv_data =
|
||||
|
||||
Reference in New Issue
Block a user