SimpleOS

LXR

Navigation



Site hébergé par : enix

The LXR Cross Referencer for SOS

source navigation ]
diff markup ]
identifier search ]
general search ]
 
 
Article:1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 6.5 ] [ 7 ] [ 7.5 ] [ 8 ] [ 9 ] [ 9.5 ]

001 /* Copyright (C) 2005 David Decotigny
002 
003    This program is free software; you can redistribute it and/or
004    modify it under the terms of the GNU General Public License
005    as published by the Free Software Foundation; either version 2
006    of the License, or (at your option) any later version.
007    
008    This program is distributed in the hope that it will be useful,
009    but WITHOUT ANY WARRANTY; without even the implied warranty of
010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
011    GNU General Public License for more details.
012    
013    You should have received a copy of the GNU General Public License
014    along with this program; if not, write to the Free Software
015    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
016    USA. 
017 */
018 
019 #include <crt.h>
020 #include <libc.h>
021 #include <stdarg.h>
022 #include <debug.h>
023 
024 
025 /**
026  * @file myprog11.c
027  *
028  * mresize tests
029  *
030  * We use the temporary syscall 4004 to dump the list of VRs in the
031  * thread's address space
032  */
033 
034 
035 int main()
036 {
037   void * moved;
038   char * zoup;
039 
040   zoup = fakemmap((void*)4096, 8*1024*1024,
041                   PROT_READ | PROT_WRITE,
042                   MAP_SHARED,
043                   "/dev/zero", 34);
044   bochs_printf("mapped @%x\n", (unsigned)zoup);
045 
046   /* Do some forks to complicate things */
047   fork();
048   fork();
049 
050   /* First, split the region in slices using a sequence of
051      mprotects */
052   _sos_syscall1(4004, (unsigned)"Initial");
053   mprotect(zoup, 10*4096, PROT_READ);
054   zoup += 10*4096;
055   _sos_syscall1(4004, (unsigned)"After mprotect Low");
056 
057   mprotect(zoup-4096, 2*4096, PROT_READ);
058   zoup += 4096;
059   _sos_syscall1(4004, (unsigned)"After mprotect Before Low");
060 
061   mprotect(zoup-4096, 4096, PROT_READ);
062   _sos_syscall1(4004, (unsigned)"After mprotect Before low (bis)");
063 
064   mprotect(zoup + 1024*1024, 4096, PROT_READ);
065   _sos_syscall1(4004, (unsigned)"After mprotect Middle");
066 
067   mprotect(zoup + 1024*1024, 4096, PROT_READ);
068   _sos_syscall1(4004, (unsigned)"After mprotect Middle (bis)");
069 
070   mprotect(zoup + 8*1024*1024 - 11*4096 - 4096, 4096, PROT_READ);
071   _sos_syscall1(4004, (unsigned)"After mprotect High");
072 
073   mprotect(zoup + 8*1024*1024 - 11*4096 - 2*4096, 3*4096, PROT_READ);
074   _sos_syscall1(4004, (unsigned)"After mprotect Past High");
075 
076   mprotect((void*)0x40000000, 0x10000000, PROT_READ);
077   _sos_syscall1(4004, (unsigned)"After mprotect Complete VR");
078 
079   mprotect((void*)0x40000000, 0x10000000, PROT_READ);
080   _sos_syscall1(4004, (unsigned)"After mprotect Complete VR (bis)");
081 
082   /* Now try to resize one of the VR */
083   moved = zoup + 8*1024*1024 - 11*4096 - 10*4096;
084   _sos_mresize(zoup + 8*1024*1024 - 11*4096 - 2*4096, 3*4096,
085                & moved, 40*4096, 0);
086   _sos_syscall1(4004, (unsigned)"After mremap (not allowed)");
087   bochs_printf("moved=%x\n", (unsigned)moved);
088 
089   _sos_mresize(zoup + 8*1024*1024 - 11*4096 - 2*4096, 4096,
090                & moved, 40*4096, 0);
091   _sos_syscall1(4004, (unsigned)"After mremap (not allowed - bis)");
092   bochs_printf("moved=%x\n", (unsigned)moved);
093 
094   _sos_mresize(zoup + 8*1024*1024 - 11*4096 - 2*4096, 4096,
095                & moved, 40*4096, MREMAP_MAYMOVE);
096   _sos_syscall1(4004, (unsigned)"After mremap (DO move)");
097   bochs_printf("moved=%x\n", (unsigned)moved);
098 
099   _sos_mresize(moved, 4096,
100                & moved, 100*4096, MREMAP_MAYMOVE);
101   _sos_syscall1(4004, (unsigned)"After mremap (DO move)");
102   bochs_printf("moved=%x\n", (unsigned)moved);
103 
104   return 0;
105 }

source navigation ] diff markup ] identifier search ] general search ]