Subversion Repositories HelenOS

Compare Revisions

Regard whitespace Rev 3383 → Rev 3384

/trunk/kernel/generic/src/mm/as.c
111,11 → 111,10
/** Kernel address space. */
as_t *AS_KERNEL = NULL;
 
static int area_flags_to_page_flags(int aflags);
static as_area_t *find_area_and_lock(as_t *as, uintptr_t va);
static bool check_area_conflicts(as_t *as, uintptr_t va, size_t size,
as_area_t *avoid_area);
static void sh_info_remove_reference(share_info_t *sh_info);
static int area_flags_to_page_flags(int);
static as_area_t *find_area_and_lock(as_t *, uintptr_t);
static bool check_area_conflicts(as_t *, uintptr_t, size_t, as_area_t *);
static void sh_info_remove_reference(share_info_t *);
 
static int as_constructor(void *obj, int flags)
{
153,7 → 152,8
 
/** Create address space.
*
* @param flags Flags that influence way in wich the address space is created.
* @param flags Flags that influence the way in wich the address space
* is created.
*/
as_t *as_create(int flags)
{
186,6 → 186,8
* zero), the address space can be destroyed.
*
* We know that we don't hold any spinlock.
*
* @param as Address space to be destroyed.
*/
void as_destroy(as_t *as)
{
322,9 → 324,10
/** Find address space area and change it.
*
* @param as Address space.
* @param address Virtual address belonging to the area to be changed. Must be
* page-aligned.
* @param size New size of the virtual memory block starting at address.
* @param address Virtual address belonging to the area to be changed.
* Must be page-aligned.
* @param size New size of the virtual memory block starting at
* address.
* @param flags Flags influencing the remap operation. Currently unused.
*
* @return Zero on success or a value from @ref errno.h otherwise.
435,8 → 438,10
cond = false; /* we are almost done */
i = (start_free - b) >> PAGE_WIDTH;
if (!used_space_remove(area, start_free, c - i))
panic("Could not remove used space.\n");
if (!used_space_remove(area, start_free,
c - i))
panic("Could not remove used "
"space.\n");
} else {
/*
* The interval of used space can be
443,7 → 448,8
* completely removed.
*/
if (!used_space_remove(area, b, c))
panic("Could not remove used space.\n");
panic("Could not remove used "
"space.\n");
}
for (; i < c; i++) {
506,7 → 512,7
/** Destroy address space area.
*
* @param as Address space.
* @param address Address withing the area to be deleted.
* @param address Address within the area to be deleted.
*
* @return Zero on success or a value from @ref errno.h on failure.
*/
612,11 → 618,12
* @param dst_base Target base address.
* @param dst_flags_mask Destination address space area flags mask.
*
* @return Zero on success or ENOENT if there is no such task or if there is no
* such address space area, EPERM if there was a problem in accepting the area
* or ENOMEM if there was a problem in allocating destination address space
* area. ENOTSUP is returned if the address space area backend does not support
* sharing.
* @return Zero on success or ENOENT if there is no such task or if
* there is no such address space area, EPERM if there was
* a problem in accepting the area or ENOMEM if there was a
* problem in allocating destination address space area.
* ENOTSUP is returned if the address space area backend
* does not support sharing.
*/
int as_area_share(as_t *src_as, uintptr_t src_base, size_t acc_size,
as_t *dst_as, uintptr_t dst_base, int dst_flags_mask)
738,7 → 745,8
* @param area Address space area.
* @param access Access mode.
*
* @return False if access violates area's permissions, true otherwise.
* @return False if access violates area's permissions, true
* otherwise.
*/
bool as_area_check_access(as_area_t *area, pf_access_t access)
{
754,7 → 762,7
return true;
}
 
/** Change adress area flags.
/** Change adress space area flags.
*
* The idea is to have the same data, but with a different access mode.
* This is needed e.g. for writing code into memory and then executing it.
876,8 → 884,8
 
/*
* Map pages back in with new flags. This step is kept separate
* so that there's no instant when the memory area could be
* accesed with both the old and the new flags at once.
* so that the memory area could not be accesed with both the old and
* the new flags at once.
*/
frame_idx = 0;
 
915,19 → 923,20
 
/** Handle page fault within the current address space.
*
* This is the high-level page fault handler. It decides
* whether the page fault can be resolved by any backend
* and if so, it invokes the backend to resolve the page
* fault.
* This is the high-level page fault handler. It decides whether the page fault
* can be resolved by any backend and if so, it invokes the backend to resolve
* the page fault.
*
* Interrupts are assumed disabled.
*
* @param page Faulting page.
* @param access Access mode that caused the fault (i.e. read/write/exec).
* @param istate Pointer to interrupted state.
* @param access Access mode that caused the page fault (i.e.
* read/write/exec).
* @param istate Pointer to the interrupted state.
*
* @return AS_PF_FAULT on page fault, AS_PF_OK on success or AS_PF_DEFER if the
* fault was caused by copy_to_uspace() or copy_from_uspace().
* @return AS_PF_FAULT on page fault, AS_PF_OK on success or
* AS_PF_DEFER if the fault was caused by copy_to_uspace()
* or copy_from_uspace().
*/
int as_page_fault(uintptr_t page, pf_access_t access, istate_t *istate)
{
973,9 → 982,8
page_table_lock(AS, false);
/*
* To avoid race condition between two page faults
* on the same address, we need to make sure
* the mapping has not been already inserted.
* To avoid race condition between two page faults on the same address,
* we need to make sure the mapping has not been already inserted.
*/
if ((pte = page_mapping_find(AS, page))) {
if (PTE_PRESENT(pte)) {
1142,10 → 1150,11
 
/** Create page table.
*
* Depending on architecture, create either address space
* private or global page table.
* Depending on architecture, create either address space private or global page
* table.
*
* @param flags Flags saying whether the page table is for kernel address space.
* @param flags Flags saying whether the page table is for the kernel
* address space.
*
* @return First entry of the page table.
*/
1212,8 → 1221,8
* @param as Address space.
* @param va Virtual address.
*
* @return Locked address space area containing va on success or NULL on
* failure.
* @return Locked address space area containing va on success or
* NULL on failure.
*/
as_area_t *find_area_and_lock(as_t *as, uintptr_t va)
{
1272,8 → 1281,8
*
* @return True if there is no conflict, false otherwise.
*/
bool check_area_conflicts(as_t *as, uintptr_t va, size_t size,
as_area_t *avoid_area)
bool
check_area_conflicts(as_t *as, uintptr_t va, size_t size, as_area_t *avoid_area)
{
as_area_t *a;
btree_node_t *leaf, *node;
1380,7 → 1389,7
* @param page First page to be marked.
* @param count Number of page to be marked.
*
* @return 0 on failure and 1 on success.
* @return Zero on failure and non-zero on success.
*/
int used_space_insert(as_area_t *a, uintptr_t page, count_t count)
{
1650,8 → 1659,8
}
}
 
panic("Inconsistency detected while adding %" PRIc " pages of used space at "
"%p.\n", count, page);
panic("Inconsistency detected while adding %" PRIc " pages of used "
"space at %p.\n", count, page);
}
 
/** Mark portion of address space area as unused.
1662,7 → 1671,7
* @param page First page to be marked.
* @param count Number of page to be marked.
*
* @return 0 on failure and 1 on success.
* @return Zero on failure and non-zero on success.
*/
int used_space_remove(as_area_t *a, uintptr_t page, count_t count)
{
1829,8 → 1838,8
}
 
error:
panic("Inconsistency detected while removing %" PRIc " pages of used space "
"from %p.\n", count, page);
panic("Inconsistency detected while removing %" PRIc " pages of used "
"space from %p.\n", count, page);
}
 
/** Remove reference to address space area share info.
1928,9 → 1937,9
as_area_t *area = node->value[i];
mutex_lock(&area->lock);
printf("as_area: %p, base=%p, pages=%" PRIc " (%p - %p)\n",
area, area->base, area->pages, area->base,
area->base + FRAMES2SIZE(area->pages));
printf("as_area: %p, base=%p, pages=%" PRIc
" (%p - %p)\n", area, area->base, area->pages,
area->base, area->base + FRAMES2SIZE(area->pages));
mutex_unlock(&area->lock);
}
}