mirror of
https://github.com/drasko/codezero.git
synced 2026-01-14 03:43:15 +01:00
Wiring between mm0 page cache and vfs almost what it should look like.
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
This commit is contained in:
@@ -9,6 +9,7 @@ int find_and_set_first_free_contig_bits(u32 *word, unsigned int limit,
|
||||
int nbits);
|
||||
int check_and_clear_bit(u32 *word, int bit);
|
||||
int check_and_clear_contig_bits(u32 *word, int first, int nbits);
|
||||
int check_and_set_bit(u32 *word, int bit);
|
||||
|
||||
|
||||
/* Set */
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
#define __MM0_IDPOOL_H__
|
||||
|
||||
#include <lib/bit.h>
|
||||
#include <lib/spinlock.h>
|
||||
|
||||
struct id_pool {
|
||||
struct spinlock lock;
|
||||
int nwords;
|
||||
u32 bitmap[];
|
||||
};
|
||||
@@ -11,6 +13,7 @@ struct id_pool {
|
||||
struct id_pool *id_pool_new_init(int mapsize);
|
||||
int id_new(struct id_pool *pool);
|
||||
int id_del(struct id_pool *pool, int id);
|
||||
int id_get(struct id_pool *pool, int id);
|
||||
int ids_new_contiguous(struct id_pool *pool, int numids);
|
||||
int ids_del_contiguous(struct id_pool *pool, int first, int numids);
|
||||
|
||||
|
||||
@@ -13,13 +13,21 @@
|
||||
#include <l4lib/types.h>
|
||||
#include <l4lib/utcb.h>
|
||||
|
||||
#define __TASKNAME__ "mm0"
|
||||
#define __TASKNAME__ __PAGERNAME__
|
||||
|
||||
#define TASK_OFILES_MAX 32
|
||||
|
||||
/* Allow per-task anonymous memory to grow as much as 1 MB for now. */
|
||||
#define TASK_SWAPFILE_MAXSIZE SZ_1MB
|
||||
|
||||
struct vm_file;
|
||||
|
||||
struct file_descriptor {
|
||||
unsigned long vnum;
|
||||
unsigned long cursor;
|
||||
struct vm_file *vmfile;
|
||||
};
|
||||
|
||||
/* Stores all task information that can be kept in userspace. */
|
||||
struct tcb {
|
||||
/* Task list */
|
||||
@@ -53,6 +61,9 @@ struct tcb {
|
||||
/* Per-task swap file for now */
|
||||
struct vm_file *swap_file;
|
||||
|
||||
/* File descriptors for this task */
|
||||
struct file_descriptor fd[TASK_OFILES_MAX];
|
||||
|
||||
/* Pool to generate swap file offsets for fileless anonymous regions */
|
||||
struct id_pool *swap_file_offset_pool;
|
||||
};
|
||||
|
||||
@@ -59,8 +59,8 @@ struct fault_data {
|
||||
};
|
||||
|
||||
struct vm_pager_ops {
|
||||
void (*read_page)(struct fault_data *f, void *);
|
||||
void (*write_page)(struct fault_data *f, void *);
|
||||
int (*read_page)(struct vm_file *f, unsigned long f_offset, void *pagebuf);
|
||||
int (*write_page)(struct vm_file *f, unsigned long f_offset, void *pagebuf);
|
||||
};
|
||||
|
||||
/* Describes the pager task that handles a vm_area. */
|
||||
@@ -68,27 +68,22 @@ struct vm_pager {
|
||||
struct vm_pager_ops ops; /* The ops the pager does on area */
|
||||
};
|
||||
|
||||
/*
|
||||
* TODO: Since there's no vfs yet, an inode's i_addr field is the
|
||||
* virtual memory address of a file which uniquely identifies that file.
|
||||
*/
|
||||
struct inode {
|
||||
unsigned long i_addr; /* The unique, global resource id. */
|
||||
};
|
||||
|
||||
/*
|
||||
* Describes the in-memory representation of a file. This could
|
||||
* point at a file or another resource, e.g. a device area or swapper space.
|
||||
*/
|
||||
struct vm_file {
|
||||
struct inode inode;
|
||||
int refcnt;
|
||||
unsigned long vnum; /* Vnode number */
|
||||
unsigned long length;
|
||||
struct list_head list; /* List of all vm files in memory */
|
||||
|
||||
/* This is the cache of physical pages that this file has in memory. */
|
||||
struct list_head page_cache_list;
|
||||
struct vm_pager *pager;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Describes a virtually contiguous chunk of memory region in a task. It covers
|
||||
* a unique virtual address area within its task, meaning that it does not
|
||||
@@ -119,6 +114,7 @@ static inline struct vm_area *find_vma(unsigned long addr,
|
||||
|
||||
/* Pagers */
|
||||
extern struct vm_pager default_file_pager;
|
||||
extern struct vm_pager boot_file_pager;
|
||||
extern struct vm_pager swap_pager;
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user