mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-23 17:17:38 +00:00
committed by
Christian Helmuth
parent
aeb65d6b1b
commit
6727b5ea49
47
repos/dde_linux/src/lib/lx_emul/shadow/fs/libfs.c
Normal file
47
repos/dde_linux/src/lib/lx_emul/shadow/fs/libfs.c
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* \brief Dummy definitions of Linux Kernel functions
|
||||
* \author Josef Soentgen
|
||||
* \date 2022-04-05
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2022 Genode Labs GmbH
|
||||
*
|
||||
* This file is distributed under the terms of the GNU General Public License
|
||||
* version 2.
|
||||
*/
|
||||
|
||||
#include <lx_emul.h>
|
||||
|
||||
#include <linux/fs.h>
|
||||
#include <linux/mount.h>
|
||||
#include <linux/slab.h>
|
||||
|
||||
int simple_pin_fs(struct file_system_type * type, struct vfsmount ** mount, int * count)
|
||||
{
|
||||
if (!mount)
|
||||
return -EFAULT;
|
||||
|
||||
if (!*mount)
|
||||
*mount = kzalloc(sizeof(struct vfsmount), GFP_KERNEL);
|
||||
|
||||
if (!*mount)
|
||||
return -ENOMEM;
|
||||
|
||||
if (count)
|
||||
++*count;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void simple_release_fs(struct vfsmount ** mount,int * count)
|
||||
{
|
||||
kfree(*mount);
|
||||
}
|
||||
|
||||
|
||||
struct inode * alloc_anon_inode(struct super_block * s)
|
||||
{
|
||||
return kzalloc(sizeof(struct inode), GFP_KERNEL);
|
||||
}
|
@ -125,3 +125,65 @@ void dma_unmap_sg_attrs(struct device * dev,
|
||||
sg->dma_address = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
dma_addr_t dma_map_page_attrs(struct device * dev,
|
||||
struct page * page,
|
||||
size_t offset,
|
||||
size_t size,
|
||||
enum dma_data_direction dir,
|
||||
unsigned long attrs)
|
||||
{
|
||||
dma_addr_t const dma_addr = page_to_phys(page);
|
||||
unsigned long const virt_addr = (unsigned long)page_to_virt(page);
|
||||
|
||||
lx_emul_mem_cache_clean_invalidate((void *)(virt_addr + offset), size);
|
||||
return dma_addr + offset;
|
||||
}
|
||||
|
||||
|
||||
void dma_unmap_page_attrs(struct device * dev,
|
||||
dma_addr_t addr,
|
||||
size_t size,
|
||||
enum dma_data_direction dir,
|
||||
unsigned long attrs)
|
||||
{
|
||||
unsigned long const virt_addr = lx_emul_mem_virt_addr((void*)addr);
|
||||
|
||||
if (!virt_addr)
|
||||
return;
|
||||
|
||||
if (dir == DMA_FROM_DEVICE)
|
||||
lx_emul_mem_cache_invalidate((void *)virt_addr, size);
|
||||
}
|
||||
|
||||
|
||||
void dma_sync_single_for_cpu(struct device *dev, dma_addr_t addr,
|
||||
size_t size, enum dma_data_direction dir)
|
||||
{
|
||||
unsigned long const virt_addr = lx_emul_mem_virt_addr((void*)addr);
|
||||
|
||||
if (!virt_addr)
|
||||
return;
|
||||
|
||||
lx_emul_mem_cache_invalidate((void *)virt_addr, size);
|
||||
}
|
||||
|
||||
|
||||
void dma_sync_single_for_device(struct device *dev, dma_addr_t addr,
|
||||
size_t size, enum dma_data_direction dir)
|
||||
{
|
||||
unsigned long const virt_addr = lx_emul_mem_virt_addr((void*)addr);
|
||||
|
||||
if (!virt_addr)
|
||||
return;
|
||||
|
||||
lx_emul_mem_cache_clean_invalidate((void *)virt_addr, size);
|
||||
}
|
||||
|
||||
|
||||
int dma_supported(struct device * dev,u64 mask)
|
||||
{
|
||||
/* do we need to evaluate the mask? */
|
||||
return 1;
|
||||
}
|
||||
|
@ -279,3 +279,6 @@ int idle_cpu(int cpu)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void sched_set_fifo(struct task_struct * p) { }
|
||||
|
77
repos/dde_linux/src/lib/lx_emul/shadow/mm/dmapool.c
Normal file
77
repos/dde_linux/src/lib/lx_emul/shadow/mm/dmapool.c
Normal file
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* \brief Replaces mm/dmapool.c
|
||||
* \author josef soentgen
|
||||
* \date 2022-04-05
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Copyright (C) 2022 Genode Labs GmbH
|
||||
*
|
||||
* This file is distributed under the terms of the GNU General Public License
|
||||
* version 2.
|
||||
*/
|
||||
|
||||
|
||||
#include <linux/slab.h>
|
||||
#include <linux/dmapool.h>
|
||||
|
||||
struct dma_pool
|
||||
{
|
||||
size_t size;
|
||||
size_t align;
|
||||
};
|
||||
|
||||
void * dma_pool_alloc(struct dma_pool * pool, gfp_t mem_flags, dma_addr_t * handle)
|
||||
{
|
||||
void * ret =
|
||||
lx_emul_mem_alloc_aligned_uncached(pool->size, pool->align);
|
||||
*handle = lx_emul_mem_dma_addr(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
struct dma_pool * dma_pool_create(const char * name,
|
||||
struct device * dev,
|
||||
size_t size,
|
||||
size_t align,
|
||||
size_t boundary)
|
||||
{
|
||||
struct dma_pool * pool = kzalloc(sizeof(struct dma_pool), GFP_KERNEL);
|
||||
if (!pool)
|
||||
return NULL;
|
||||
|
||||
/* TODO check if it makes sense to add min(align, PAGE_SIZE) check */
|
||||
|
||||
pool->size = size;
|
||||
pool->align = align;
|
||||
return pool;
|
||||
}
|
||||
|
||||
|
||||
struct dma_pool *dmam_pool_create(const char *name,
|
||||
struct device *dev,
|
||||
size_t size,
|
||||
size_t align,
|
||||
size_t allocation)
|
||||
{
|
||||
/*
|
||||
* Only take care of allocating the pool because
|
||||
* we do not detach the driver anyway.
|
||||
*/
|
||||
return dma_pool_create(name, dev, size, align, 0);
|
||||
}
|
||||
|
||||
|
||||
void dma_pool_destroy(struct dma_pool * pool)
|
||||
{
|
||||
kfree(pool);
|
||||
}
|
||||
|
||||
|
||||
void dma_pool_free(struct dma_pool * pool,void * vaddr,dma_addr_t dma)
|
||||
{
|
||||
lx_emul_mem_free(vaddr);
|
||||
}
|
||||
|
||||
|
@ -80,6 +80,7 @@ static struct page * lx_alloc_pages(unsigned const nr_pages)
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* In earlier kernel versions, '__alloc_pages' was an inline function.
|
||||
*/
|
||||
@ -96,3 +97,21 @@ void *alloc_pages_exact(size_t size, gfp_t gfp_mask)
|
||||
{
|
||||
return lx_alloc_pages(PAGE_ALIGN(size) / PAGE_SIZE)->virtual;
|
||||
}
|
||||
|
||||
|
||||
void free_pages(unsigned long addr,unsigned int order)
|
||||
{
|
||||
if (addr != 0ul)
|
||||
__free_pages(virt_to_page((void *)addr), order);
|
||||
}
|
||||
|
||||
|
||||
unsigned long __get_free_pages(gfp_t gfp_mask, unsigned int order)
|
||||
{
|
||||
struct page *page = lx_alloc_pages(1u << order);
|
||||
|
||||
if (!page)
|
||||
return 0;
|
||||
|
||||
return (unsigned long)page_address(page);
|
||||
}
|
||||
|
39
repos/dde_linux/src/lib/lx_emul/shadow/mm/vmalloc.c
Normal file
39
repos/dde_linux/src/lib/lx_emul/shadow/mm/vmalloc.c
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* \brief Supplement for emulation of mm/vmalloc.c
|
||||
* \author Josef Soentgen
|
||||
* \date 2022-04-05
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2022 Genode Labs GmbH
|
||||
*
|
||||
* This file is distributed under the terms of the GNU General Public License
|
||||
* version 2.
|
||||
*/
|
||||
|
||||
|
||||
#include <linux/slab.h>
|
||||
#include <linux/vmalloc.h>
|
||||
|
||||
void vfree(const void * addr)
|
||||
{
|
||||
kfree(addr);
|
||||
}
|
||||
|
||||
|
||||
void * vmalloc(unsigned long size)
|
||||
{
|
||||
return kmalloc(size, GFP_KERNEL);
|
||||
}
|
||||
|
||||
|
||||
void * vzalloc(unsigned long size)
|
||||
{
|
||||
return kzalloc(size, GFP_KERNEL);
|
||||
}
|
||||
|
||||
|
||||
bool is_vmalloc_addr(const void * x)
|
||||
{
|
||||
return false;
|
||||
}
|
Reference in New Issue
Block a user