[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Lost] [Patch] get_phys_addr()



Ich wünsche mir einen neuen Syscall. Ich hab die Funktionalität nämlich erst in CDI eingebaut und in sis900 verwendet und anschließend festgestellt, daß ich das mit LOST bisher gar nicht umsetzen kann. ;-)
Index: src/modules/lib/syscalls/get_phys_addr.c
===================================================================
--- src/modules/lib/syscalls/get_phys_addr.c	(Revision 0)
+++ src/modules/lib/syscalls/get_phys_addr.c	(Revision 0)
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2007 The LOST Project. All rights reserved.
+ *
+ * This code is derived from software contributed to the LOST Project
+ * by Kevin Wolf.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the LOST Project
+ *     and its contributors.
+ * 4. Neither the name of the LOST Project nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <syscall.h>
+
+void* get_phys_addr(void* address)
+{
+    void* ptr;
+
+    asm(
+        "pushl %2;"
+        "mov %1, %%eax;"
+        "int $0x30;"
+        "add $0x8, %%esp;"
+    : "=a" (ptr) : "i" (SYSCALL_MEM_RESOLVE_VADDR), "r" (address));
+
+    return ptr;
+}

Eigenschaftsänderungen: src/modules/lib/syscalls/get_phys_addr.c
___________________________________________________________________
Name: svn:eol-style
   + native

Index: src/modules/include/syscall.h
===================================================================
--- src/modules/include/syscall.h	(Revision 650)
+++ src/modules/include/syscall.h	(Arbeitskopie)
@@ -26,6 +26,7 @@
 bool mem_free(void* address, dword size);
 void mem_free_physical(void* address, dword size);
 memory_info_t memory_info();
+void* get_phys_addr(void* address);
 
 dword create_shared_memory(dword size);
 void *open_shared_memory(dword id);
Index: src/include/syscallno.h
===================================================================
--- src/include/syscallno.h	(Revision 650)
+++ src/include/syscallno.h	(Arbeitskopie)
@@ -8,6 +8,7 @@
 #define SYSCALL_MEM_INFO 60
 #define SYSCALL_MEM_ALLOCATE_PHYSICAL 61
 #define SYSCALL_MEM_FREE_PHYSICAL 62
+#define SYSCALL_MEM_RESOLVE_VADDR 66
 
 #define SYSCALL_SHM_CREATE 63
 #define SYSCALL_SHM_ATTACH 64
Index: src/kernel/src/syscall.c
===================================================================
--- src/kernel/src/syscall.c	(Revision 650)
+++ src/kernel/src/syscall.c	(Arbeitskopie)
@@ -278,7 +278,19 @@
 
             break;
         }
+        
+        case SYSCALL_MEM_RESOLVE_VADDR:
+        {
+            vaddr_t address = *((vaddr_t*) isf->esp);
+            if (is_userspace(address, 1)) {
+                isf->eax = resolve_vaddr(current_task->cr3, address);
+            } else {
+                isf->eax = 0;
+            }
 
+            break;
+        }
+
         
         case SYSCALL_MEM_INFO:
         {