00001
00002
00011
00012
00013
00014
00015
00043
00044 #include <l4/env/errno.h>
00045
00046 #include <l4/dde_linux/dde.h>
00047
00048
00049 #include "__config.h"
00050 #include "internal.h"
00051
00055 static struct dde_region *conv = NULL;
00056
00064 void l4dde_add_region(l4_addr_t va, l4_addr_t pa, l4_size_t size)
00065 {
00066 dde_add_region(&conv, va, pa, size);
00067 }
00068
00074 void l4dde_remove_region(l4_addr_t va, l4_size_t size)
00075 {
00076 dde_remove_region(&conv, va, 0, size);
00077 }
00078
00086 void *__va(volatile unsigned long paddr)
00087 {
00088 struct dde_region *p;
00089 void *pp;
00090
00091
00092 p = conv;
00093 while (p)
00094 {
00095 if ((p->pa <= paddr) && (p->pa + p->size > paddr))
00096 {
00097 pp = (void *) (p->va + (paddr - p->pa));
00098 #if DEBUG_ADDRESS
00099 LOG("__va(0x%lx) => %p\n", paddr, pp);
00100 #endif
00101 return pp;
00102 }
00103 p = p->next;
00104 }
00105
00106 Panic("no virtual address found for 0x%lx", paddr);
00107 return NULL;
00108 }
00109
00117 unsigned long __pa(volatile void *vaddr)
00118 {
00119 struct dde_region *p;
00120 unsigned long pp;
00121 unsigned long addr = (unsigned long) vaddr;
00122
00123
00124 p = conv;
00125 while (p)
00126 {
00127 if ((p->va <= addr) && (p->va + p->size > addr))
00128 {
00129 pp = p->pa + (addr - p->va);
00130 #if DEBUG_ADDRESS
00131 LOG("__pa(0x%lx) => 0x%lx\n", addr, pp);
00132 #endif
00133 return pp;
00134 }
00135 p = p->next;
00136 }
00137
00138 Panic("no physical address found for %p", vaddr);
00139 return 0;
00140 }