dde_linux: promote PC specific additions

Issue #4861.
This commit is contained in:
Josef Söntgen 2023-05-03 13:50:16 +02:00 committed by Christian Helmuth
parent aeb65d6b1b
commit 6727b5ea49
10 changed files with 87 additions and 144 deletions

View File

@ -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;
}

View File

@ -279,3 +279,6 @@ int idle_cpu(int cpu)
{
return 1;
}
void sched_set_fifo(struct task_struct * p) { }

View File

@ -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);
}

View File

@ -24,12 +24,15 @@ SRC_CC += lx_emul/io_mem.cc
SRC_CC += lx_emul/io_port.cc
SRC_CC += lx_emul/irq.cc
SRC_CC += lx_emul/random.cc
SRC_C += lx_emul/shadow/fs/libfs.c
SRC_C += lx_emul/shadow/kernel/dma/mapping.c
SRC_C += lx_emul/shadow/kernel/irq/spurious.c
SRC_C += lx_emul/shadow/lib/devres.c
SRC_C += lx_emul/shadow/lib/smp_processor_id.c
SRC_C += lx_emul/shadow/mm/dmapool.c
SRC_C += lx_emul/shadow/mm/memblock.c
SRC_C += lx_emul/shadow/mm/page_alloc.c
SRC_C += lx_emul/shadow/mm/vmalloc.c
SRC_C += lx_emul/shadow/drivers/char/random.c
SRC_C += lx_emul/shadow/drivers/pci/host-bridge.c
SRC_C += lx_emul/shadow/drivers/pci/pci.c
@ -50,12 +53,6 @@ SRC_C += lx_emul/shadow/fs/sysfs/symlink.c
#
# Replacing implementations that could be merged into DDE Linux.
#
SRC_C += lx_emul/mapping.c
SRC_C += lx_emul/page_alloc.c
SRC_C += lx_emul/sched_core.c
SRC_C += lx_emul/vmalloc.c
SRC_C += lx_emul/shadow/fs/libfs.c
SRC_C += lx_emul/shadow/lib/logic_iomem.c
SRC_C += lx_emul/shadow/drivers/acpi/bus.c
@ -64,6 +61,3 @@ SRC_C += lx_emul/shadow/drivers/acpi/glue.c
SRC_C += lx_emul/shadow/drivers/acpi/property.c
SRC_C += lx_emul/shadow/drivers/acpi/scan.c
SRC_C += lx_emul/shadow/drivers/acpi/utils.c
# not needed by intel fb
SRC_C += lx_emul/shadow/mm/dmapool.c

View File

@ -1,78 +0,0 @@
/*
* \brief Supplement for emulation of kernel/dma/mapping.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 <lx_emul/alloc.h>
#include <linux/dma-mapping.h>
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)
{
lx_emul_trace(__func__);
return 1;
}

View File

@ -1,34 +0,0 @@
/*
* \brief Supplement for emulation of mm/page_alloc.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/gfp.h>
#include <linux/mm.h>
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 = alloc_pages(gfp_mask & ~__GFP_HIGHMEM, order);
if (!page)
return 0;
return (unsigned long)page_address(page);
}

View File

@ -1,23 +0,0 @@
/*
* \brief Supplement for emulation of kernel/sched/core.c
* \author Josef Soentgen
* \date 2022-05-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/sched.h>
void sched_set_fifo(struct task_struct * p)
{
lx_emul_trace(__func__);
}