mirror of
https://github.com/drasko/codezero.git
synced 2026-04-03 02:29:06 +02:00
Clean up to kernel code, Added `used' field to capabilities
With the addition of used field, capability structure can be used for resource accounting over the capability.
This commit is contained in:
@@ -59,6 +59,9 @@ struct capability {
|
|||||||
unsigned long start; /* Resource start value */
|
unsigned long start; /* Resource start value */
|
||||||
unsigned long end; /* Resource end value */
|
unsigned long end; /* Resource end value */
|
||||||
unsigned long size; /* Resource size */
|
unsigned long size; /* Resource size */
|
||||||
|
|
||||||
|
/* Used amount on resource */
|
||||||
|
unsigned long used;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct cap_list {
|
struct cap_list {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
#include INC_API(syscall.h)
|
#include INC_API(syscall.h)
|
||||||
|
|
||||||
|
|
||||||
int task_read_capabilities(void *userbuf)
|
int read_task_capabilities(void *userbuf)
|
||||||
{
|
{
|
||||||
int copy_size, copy_offset = 0;
|
int copy_size, copy_offset = 0;
|
||||||
struct capability *cap;
|
struct capability *cap;
|
||||||
@@ -69,7 +69,7 @@ int sys_capability_control(unsigned int req, unsigned int flags, void *userbuf)
|
|||||||
|
|
||||||
/* Return all capabilities as an array of capabilities */
|
/* Return all capabilities as an array of capabilities */
|
||||||
case CAP_CONTROL_READ_CAPS:
|
case CAP_CONTROL_READ_CAPS:
|
||||||
err = task_read_capabilities(userbuf);
|
err = read_task_capabilities(userbuf);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -9,13 +9,6 @@
|
|||||||
#include <l4/api/errno.h>
|
#include <l4/api/errno.h>
|
||||||
#include <l4/api/space.h>
|
#include <l4/api/space.h>
|
||||||
|
|
||||||
/* NOTE:
|
|
||||||
* For lazy mm switching, a list of newly created mappings that are common to
|
|
||||||
* all tasks (e.g. any mapping done in the kernel) can be kept here so that when
|
|
||||||
* a new task is scheduled, the same mappings are copied to its page tables as
|
|
||||||
* well. struct link new_mappings;
|
|
||||||
*/
|
|
||||||
|
|
||||||
int sys_map(unsigned long phys, unsigned long virt, unsigned long npages,
|
int sys_map(unsigned long phys, unsigned long virt, unsigned long npages,
|
||||||
unsigned long flags, unsigned int tid)
|
unsigned long flags, unsigned int tid)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -313,6 +313,7 @@ void init_kernel_container(struct kernel_container *kcont)
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copies cinfo structures to real capabilities for each pager.
|
* Copies cinfo structures to real capabilities for each pager.
|
||||||
*
|
*
|
||||||
@@ -341,6 +342,33 @@ int copy_pager_info(struct pager *pager, struct pager_info *pinfo)
|
|||||||
|
|
||||||
cap_list_insert(cap, &pager->cap_list);
|
cap_list_insert(cap, &pager->cap_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Find pager's capability capability, check its
|
||||||
|
* current use count and initialize it
|
||||||
|
*
|
||||||
|
* FIXME: We may want to do this capability checking
|
||||||
|
* in a more generic and straightforward place.
|
||||||
|
*/
|
||||||
|
|
||||||
|
list_foreach_struct(cap, &pager->cap_list.caps, list) {
|
||||||
|
/* Find capability pool capability */
|
||||||
|
if ((cap->type & CAP_RTYPE_MASK) == CAP_RTYPE_CAPPOOL) {
|
||||||
|
/* Verify that we did not excess allocated */
|
||||||
|
if (cap->size < pinfo->ncaps) {
|
||||||
|
printk("FATAL: Pager needs more capabilities "
|
||||||
|
"than allocated for initialization.\n");
|
||||||
|
BUG();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Initialize used count. The rest of the checking
|
||||||
|
* of spending on this cap will be done in the
|
||||||
|
* cap syscall
|
||||||
|
*/
|
||||||
|
cap->used = pinfo->ncaps;
|
||||||
|
}
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,16 +44,6 @@ void task_init_registers(struct ktcb *task, unsigned long pc)
|
|||||||
task->context.spsr = ARM_MODE_USR;
|
task->context.spsr = ARM_MODE_USR;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
/* Sets up struct page array and the physical memory descriptor. */
|
|
||||||
void paging_init(void)
|
|
||||||
{
|
|
||||||
read_bootdesc();
|
|
||||||
physmem_init();
|
|
||||||
memory_init();
|
|
||||||
copy_bootdesc();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copies global kernel entries into another pgd. Even for sub-pmd ranges
|
* Copies global kernel entries into another pgd. Even for sub-pmd ranges
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ struct capability {
|
|||||||
unsigned long start; /* Resource start value */
|
unsigned long start; /* Resource start value */
|
||||||
unsigned long end; /* Resource end value */
|
unsigned long end; /* Resource end value */
|
||||||
unsigned long size; /* Resource size */
|
unsigned long size; /* Resource size */
|
||||||
|
|
||||||
|
unsigned long used; /* Resource used size */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user