#include <lunaix/ds/btrie.h>
#include <lunaix/fs.h>
#include <lunaix/mm/page.h>
-#include <lunaix/mm/pmm.h>
#include <lunaix/mm/valloc.h>
-#include <lunaix/mm/vmm.h>
#include <lunaix/spike.h>
#define PCACHE_DIRTY 0x1
static void
pcache_free_page(void* va)
{
- ptr_t pa = vmm_del_mapping(VMS_SELF, (ptr_t)va);
- pmm_free_page(pa);
+ pte_t* ptep = mkptep_va(VMS_SELF, (ptr_t)va);
+ pte_t pte = pte_at(ptep);
+ leaflet_return(pte_leaflet(pte));
}
static void*
pcache_alloc_page()
{
int i = 0;
- ptr_t pp = pmm_alloc_page(0), va = 0;
+ ptr_t va = 0;
+ struct leaflet* leaflet = alloc_leaflet(0);
- if (!pp) {
+ if (!leaflet) {
return NULL;
}
- if (!(va = (ptr_t)vmap(pp, PG_SIZE, PG_PREM_RW, 0))) {
- pmm_free_page(pp);
+ if (!(va = (ptr_t)vmap(leaflet, KERNEL_DATA))) {
+ leaflet_return(leaflet);
return NULL;
}
void
pcache_init(struct pcache* pcache)
{
- btrie_init(&pcache->tree, PG_SIZE_BITS);
+ btrie_init(&pcache->tree, PAGE_SHIFT);
llist_init_head(&pcache->dirty);
llist_init_head(&pcache->pages);
struct pcache_pg* pg;
while (buf_off < len && errno >= 0) {
- u32_t wr_bytes = MIN(PG_SIZE - pg_off, len - buf_off);
+ u32_t wr_bytes = MIN(PAGE_SIZE - pg_off, len - buf_off);
int new_page = pcache_get_page(pcache, fpos, &pg_off, &pg);
if (errno < 0) {
break;
}
- if (errno < PG_SIZE) {
+ if (errno < (int)PAGE_SIZE) {
// EOF
len = MIN(len, buf_off + errno);
}
if (errno < 0) {
break;
}
- if (errno < PG_SIZE) {
+ if (errno < (int)PAGE_SIZE) {
// EOF
len = MIN(len, buf_off + errno);
}