mirror of
https://github.com/drasko/codezero.git
synced 2026-01-12 10:53:16 +01:00
This implements the infrastructure for read/write system calls where file content is first searched in mm0's page cache and then read-in or written via the vfs read/write functions. modified: tasks/fs0/src/syscalls.c modified: tasks/mm0/include/lib/bit.h modified: tasks/mm0/include/lib/idpool.h modified: tasks/mm0/include/task.h modified: tasks/mm0/include/vm_area.h modified: tasks/mm0/main.c modified: tasks/mm0/src/devzero.c modified: tasks/mm0/src/fault.c new file: tasks/mm0/src/file.c modified: tasks/mm0/src/init.c modified: tasks/mm0/src/lib/bit.c modified: tasks/mm0/src/lib/idpool.c modified: tasks/mm0/src/task.c
66 lines
1.1 KiB
C
66 lines
1.1 KiB
C
/*
|
|
* Handling of the special zero page.
|
|
*
|
|
* Copyright (C) 2007 Bahadir Balban
|
|
*/
|
|
#include <memory.h>
|
|
#include <mm/alloc_page.h>
|
|
#include <l4lib/arch/syscalls.h>
|
|
#include <l4lib/arch/syslib.h>
|
|
#include <string.h>
|
|
#include INC_GLUE(memory.h)
|
|
#include INC_SUBARCH(mm.h)
|
|
#include <l4/generic/space.h>
|
|
#include <arch/mm.h>
|
|
|
|
static void *zpage_p;
|
|
static struct page *zpage;
|
|
static struct vm_file devzero;
|
|
|
|
void init_zero_page(void)
|
|
{
|
|
void *zpage_v;
|
|
zpage_p = alloc_page(1);
|
|
zpage = phys_to_page(zpage_p);
|
|
|
|
/* Map it to self */
|
|
zpage_v = l4_map_helper(zpage_p, 1);
|
|
|
|
/* Zero it */
|
|
memset(zpage_v, 0, PAGE_SIZE);
|
|
|
|
/* Unmap it */
|
|
l4_unmap_helper(zpage_v, 1);
|
|
|
|
/* Update page struct. All other fields are zero */
|
|
zpage->count++;
|
|
}
|
|
|
|
void init_devzero(void)
|
|
{
|
|
init_zero_page();
|
|
|
|
INIT_LIST_HEAD(&devzero.list);
|
|
INIT_LIST_HEAD(&devzero.page_cache_list);
|
|
devzero.length = (unsigned int)-1;
|
|
devzero.vnum = -1;
|
|
}
|
|
|
|
struct vm_file *get_devzero(void)
|
|
{
|
|
return &devzero;
|
|
}
|
|
|
|
void *get_zero_page(void)
|
|
{
|
|
zpage->count++;
|
|
return zpage_p;
|
|
}
|
|
|
|
void put_zero_page(void)
|
|
{
|
|
zpage->count--;
|
|
BUG_ON(zpage->count < 0);
|
|
}
|
|
|