|
|
@ -625,7 +625,7 @@ long sys_mmap(void * start,size_t len,...)// int prot,int flags,int fd,off_t off
|
|
|
|
*(unsigned long *)from_page= tpage | 7;
|
|
|
|
*(unsigned long *)from_page= tpage | 7;
|
|
|
|
mem_map[(tpage-LOW_MEM)>>12]++;
|
|
|
|
mem_map[(tpage-LOW_MEM)>>12]++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*(unsigned long *)from_page &= (prot&PROT_WRITE); //分配读写权限
|
|
|
|
*(unsigned long *)from_page &= (prot&PROT_WRITE)?0xffffffff:0xfffffffd; //分配读写权限
|
|
|
|
|
|
|
|
|
|
|
|
if(flags & MAP_SHARED)
|
|
|
|
if(flags & MAP_SHARED)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -709,9 +709,9 @@ int sys_munmap(void * start ,size_t size)
|
|
|
|
if(!pre)
|
|
|
|
if(!pre)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(current->mmap_tail==current->mmap)current->mmap_tail=NULL;
|
|
|
|
if(current->mmap_tail==current->mmap)current->mmap_tail=NULL;
|
|
|
|
current->mmap==current->mmap->next;
|
|
|
|
current->mmap=current->mmap->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(temp->next=NULL)
|
|
|
|
else if(temp->next=NULL)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
current->mmap_tail=pre;
|
|
|
|
current->mmap_tail=pre;
|
|
|
|
pre->next=NULL;
|
|
|
|
pre->next=NULL;
|
|
|
@ -726,12 +726,13 @@ int sys_munmap(void * start ,size_t size)
|
|
|
|
unsigned long phys_addr;
|
|
|
|
unsigned long phys_addr;
|
|
|
|
unsigned long tpage;
|
|
|
|
unsigned long tpage;
|
|
|
|
unsigned long address=temp->address;
|
|
|
|
unsigned long address=temp->address;
|
|
|
|
|
|
|
|
printk("%lx\n",address);
|
|
|
|
if(!(temp->ps & MAP_SHARED))
|
|
|
|
if(!(temp->ps & MAP_SHARED))
|
|
|
|
goto mytag;
|
|
|
|
goto mytag;
|
|
|
|
//若为共享,执行下面的代码
|
|
|
|
//若为共享,执行下面的代码
|
|
|
|
while (address < temp ->endaddr)
|
|
|
|
while (address < temp ->endaddr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
printk("addr: %lx\n",address);
|
|
|
|
//printk("addr: %lx\n",address);
|
|
|
|
from_page = ((address>>20) & 0xffc);
|
|
|
|
from_page = ((address>>20) & 0xffc);
|
|
|
|
from_page += ((current->start_code>>20) & 0xffc);//页目录
|
|
|
|
from_page += ((current->start_code>>20) & 0xffc);//页目录
|
|
|
|
from=*(unsigned long *)from_page; //页表项
|
|
|
|
from=*(unsigned long *)from_page; //页表项
|
|
|
@ -741,7 +742,8 @@ int sys_munmap(void * start ,size_t size)
|
|
|
|
//printk("addr: %lx",*(unsigned long *)from_page);
|
|
|
|
//printk("addr: %lx",*(unsigned long *)from_page);
|
|
|
|
if(!(*(unsigned long *)from_page & 1))
|
|
|
|
if(!(*(unsigned long *)from_page & 1))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
printk("error of deleting page.");
|
|
|
|
printk("error of deleting page at %x.\n",*(unsigned long *)from_page);
|
|
|
|
|
|
|
|
printk("current address:%x\n",address);
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(temp->ps & MAP_SHARED)
|
|
|
|
if(temp->ps & MAP_SHARED)
|
|
|
@ -778,8 +780,10 @@ int sys_munmap(void * start ,size_t size)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mytag:
|
|
|
|
mytag:
|
|
|
|
//取消物理页写权限
|
|
|
|
//取消物理页写权限
|
|
|
|
|
|
|
|
address=temp->address;
|
|
|
|
while (address < temp ->endaddr)
|
|
|
|
while (address < temp ->endaddr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
//printk("%lx\n",address);
|
|
|
|
from_page = ((address>>20) & 0xffc);
|
|
|
|
from_page = ((address>>20) & 0xffc);
|
|
|
|
from_page += ((current->start_code>>20) & 0xffc);//页目录
|
|
|
|
from_page += ((current->start_code>>20) & 0xffc);//页目录
|
|
|
|
from=*(unsigned long *)from_page; //页表项
|
|
|
|
from=*(unsigned long *)from_page; //页表项
|
|
|
@ -789,7 +793,8 @@ mytag:
|
|
|
|
//printk("addr: %lx",*(unsigned long *)from_page);
|
|
|
|
//printk("addr: %lx",*(unsigned long *)from_page);
|
|
|
|
if(!(*(unsigned long *)from_page & 1))
|
|
|
|
if(!(*(unsigned long *)from_page & 1))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
printk("error of deleting page.");
|
|
|
|
printk("error of deleting page at %x.\n",*(unsigned long *)from_page);
|
|
|
|
|
|
|
|
printk("current address:%x\n",address);
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
else{
|
|
|
|