Results 1 to 2 of 2
hye fellas
------------------------------------------------------
#include <linux/linkage.h>
#include<linux/sched.h>
#include<linux/kernel.h>
#include<linux/module.h>
#include<linux/init.h>
#include<linux/mm.h>
#include<asm/pgtable.h>
#include<linux/hardirq.h>
pgd_t *pgd;
pud_t *pud;
pmd_t *pmd;
pte_t *pte;
int N_VMA = 0;
unsigned long int addr;
struct page ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 03-28-2010 #1Just Joined!
- Join Date
- Mar 2010
- Posts
- 4
[SOLVED] Pte problem
hye fellas
------------------------------------------------------
#include <linux/linkage.h>
#include<linux/sched.h>
#include<linux/kernel.h>
#include<linux/module.h>
#include<linux/init.h>
#include<linux/mm.h>
#include<asm/pgtable.h>
#include<linux/hardirq.h>
pgd_t *pgd;
pud_t *pud;
pmd_t *pmd;
pte_t *pte;
int N_VMA = 0;
unsigned long int addr;
struct page *page = NULL;
unsigned long phys_addr;
//static void *print_mem(struct task_struct *task);
static void *print_mem(struct task_struct *task)
{ struct mm_struct *mm1;
struct vm_area_struct *vma;
mm1 = task->mm;
vma = mm1->mmap;
addr = vma->vm_start;
while(vma && (mm1->map_count > N_VMA)){
while(addr <= vma->vm_end)
{
pgd = pgd_offset(mm1, addr);
if ( pgd_bad(*pgd) || (!pgd_present(*pgd)))
printk("Page does not exit or swapped out\n");
pud = pud_offset(pgd, addr);
if ( pud_bad(*pud) || (!pud_present(*pud)))
printk("ERROR\n");
pmd = pmd_offset(pud, addr);
if (pmd_bad(*pmd) || (!pmd_present(*pmd)))
printk("ERROR\n");
pte = pte_offset_map(pmd, addr);
if (pte_present(*pte))
//page = pte_page(*pte);
phys_addr = pte_pfn(*pte);
printk(KERN_DEBUG "|\t%p\t|\t%p\t|\n",(void*)addr, (void*)phys_addr);
addr += 4096;
}
vma = vma->vm_next;
N_VMA++;
}
}
asmlinkage long sys_getpgmap(int i){
struct task_struct *task1;
printk("Get the process ID %d\n", i);
for_each_process(task1)
{ if(task1->pid == i)
{ printk("%d\n",task1->pid);
print_mem(task1);}
}
return 0;
}
-------------------------------------------------------------
when I enter a process ID, it retreives the physical adresses but then it froze the whole Operating system Linux Ubuntu.
Can someone help me with this code?
Thanks
- 04-06-2010 #2Just Joined!
- Join Date
- Mar 2010
- Posts
- 4
I fixed the problem. I had to create user code that received the output of Kernel terminal. Now, it workd well and niw I could map any Process id and get all its physical adresses that reside in the main memory.



