--- linux/kernel/chr_drv/mem.c 2018/04/24 18:10:17 1.1.1.2 +++ linux/kernel/chr_drv/mem.c 2018/04/24 18:13:48 1.1.1.4 @@ -1,15 +1,15 @@ /* * linux/kernel/chr_drv/mem.c * - * (C) 1991 Linus Torvalds + * Copyright (C) 1991, 1992 Linus Torvalds */ -#include -#include - +#include +#include #include #include #include +#include #include #include @@ -36,17 +36,17 @@ static int read_mem(struct inode * inode addr = file->f_pos; tmp = buf; while (count > 0) { + if (current->signal & ~current->blocked) + break; pde = (unsigned long) pg_dir + (addr >> 20 & 0xffc); - if (!((pte = *((unsigned long *) pde)) & 1)) + pte = *(unsigned long *) pde; + if (!(pte & PAGE_PRESENT)) break; pte &= 0xfffff000; pte += (addr >> 10) & 0xffc; - if (((page = *((unsigned long *) pte)) & 1) == 0) + page = *(unsigned long *) pte; + if (!(page & 1)) break; -/* - if ((page & 2) == 0) - un_wp_page((unsigned long *) pte); -*/ page &= 0xfffff000; page += addr & 0xfff; i = 4096-(addr & 0xfff); @@ -73,15 +73,21 @@ static int write_mem(struct inode * inod addr = file->f_pos; tmp = buf; while (count > 0) { + if (current->signal & ~current->blocked) + break; pde = (unsigned long) pg_dir + (addr >> 20 & 0xffc); - if (!((pte = *((unsigned long *) pde)) & 1)) + pte = *(unsigned long *) pde; + if (!(pte & PAGE_PRESENT)) break; pte &= 0xfffff000; pte += (addr >> 10) & 0xffc; - if (((page = *((unsigned long *) pte)) & 1) == 0) + page = *(unsigned long *) pte; + if (!(page & PAGE_PRESENT)) break; - if ((page & 2) == 0) - un_wp_page((unsigned long *) pte); + if (!(page & 2)) { + do_wp_page(0,addr,current,0); + continue; + } page &= 0xfffff000; page += addr & 0xfff; i = 4096-(addr & 0xfff); @@ -93,7 +99,11 @@ static int write_mem(struct inode * inod count -= i; } file->f_pos = addr; - return tmp-buf; + if (tmp != buf) + return tmp-buf; + if (current->signal & ~current->blocked) + return -ERESTARTSYS; + return 0; } static int read_kmem(struct inode * inode, struct file * file,char * buf, int count) @@ -102,10 +112,10 @@ static int read_kmem(struct inode * inod if (count < 0) return -EINVAL; - if (p >= HIGH_MEMORY) + if (p >= high_memory) return 0; - if (count > HIGH_MEMORY - p) - count = HIGH_MEMORY - p; + if (count > high_memory - p) + count = high_memory - p; memcpy_tofs(buf,(void *) p,count); file->f_pos += count; return count; @@ -117,10 +127,10 @@ static int write_kmem(struct inode * ino if (count < 0) return -EINVAL; - if (p >= HIGH_MEMORY) + if (p >= high_memory) return 0; - if (count > HIGH_MEMORY - p) - count = HIGH_MEMORY - p; + if (count > high_memory - p) + count = high_memory - p; memcpy_fromfs((void *) p,buf,count); file->f_pos += count; return count; @@ -241,10 +251,11 @@ static struct file_operations mem_fops = NULL /* no special release code */ }; -long chr_dev_init(long kmem_start) +long chr_dev_init(long mem_start, long mem_end) { chrdev_fops[1] = &mem_fops; - kmem_start = tty_init(kmem_start); - kmem_start = lp_init(kmem_start); - return kmem_start; + mem_start = tty_init(mem_start); + mem_start = lp_init(mem_start); + mem_start = mouse_init(mem_start); + return mem_start; }