[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Lost] [PATCH] kernel2: mem_allocate fuer DMA
+ kernel2: mem_allocate beruecksichtigt das DMA-Flag
! kernel2: mem_allocate setzt den phys-Parameter
---
src/kernel2/include/syscall.h | 2 +-
src/kernel2/src/syscalls/mem.c | 17 ++++++++++++++---
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/src/kernel2/include/syscall.h b/src/kernel2/include/syscall.h
index 960f671..ff4fe29 100644
--- a/src/kernel2/include/syscall.h
+++ b/src/kernel2/include/syscall.h
@@ -75,7 +75,7 @@ void syscall_init();
// Speicherverwaltung
/// Einen Speicherblock allokieren.
-vaddr_t syscall_mem_allocate(size_t bytes, syscall_arg_t flags, paddr_t phys);
+vaddr_t syscall_mem_allocate(size_t bytes, syscall_arg_t flags, paddr_t* phys);
/// Einen Speicherblock freigeben
void syscall_mem_free(vaddr_t start, size_t bytes);
diff --git a/src/kernel2/src/syscalls/mem.c b/src/kernel2/src/syscalls/mem.c
index 5247355..ac174d0 100644
--- a/src/kernel2/src/syscalls/mem.c
+++ b/src/kernel2/src/syscalls/mem.c
@@ -49,16 +49,27 @@
*
* @return Virtuelle Adresse des Blocks
*/
-vaddr_t syscall_mem_allocate(size_t bytes, syscall_arg_t flags, paddr_t phys)
+vaddr_t syscall_mem_allocate(size_t bytes, syscall_arg_t flags, paddr_t* phys)
{
vaddr_t address = NULL;
size_t page_count = NUM_PAGES(PAGE_ALIGN_ROUND_UP(bytes));
// Der Speicher muss nicht physisch zusamenhaengend sein.
- paddr_t physical_address = pmm_alloc(page_count);
- address = mmc_automap(&mmc_current_context(), physical_address, page_count,
+ if (flags & 0x80) {
+ *phys = pmm_alloc_limits((paddr_t) 0, (paddr_t) (16 * 1024 * 1024),
+ page_count);
+ } else {
+ *phys = pmm_alloc(page_count);
+ }
+
+ address = mmc_automap(&mmc_current_context(), *phys, page_count,
USER_MEM_START, USER_MEM_END, MM_FLAGS_USER_DATA);
+ // Die physische Adresse gibt es nur fuer DMA
+ if ((flags & 0x80) == 0) {
+ *phys = 0;
+ }
+
return address;
}
--
1.5.4.5