Main Page   Compound List   File List   Compound Members   File Members  

system.c File Reference

#include "copyright.h"
#include <stdio.h>
#include <syscall.h>
#include "int.h"

Go to the source code of this file.

Defines

#define IOCPARM_MASK   0x7f

Functions

char * u_to_int_addr ()
 system_break ()
 system_trap ()
char * u_to_int_addr (ptr) int ptr

Variables

int Reg []
char mem []
int Traptrace


Define Documentation

#define IOCPARM_MASK   0x7f
 


Function Documentation

system_break  
 

Definition at line 19 of file system.c.

References system_trap.

00020 {
00021         if  ( Traptrace )
00022                 printf("**breakpoint ");
00023         system_trap();
00024 }

system_trap  
 

Definition at line 26 of file system.c.

References lseek, and Reg.

Referenced by system_break.

00027 {
00028         int o0, o1, o2;         /* user out register values */
00029         int syscallno;
00030         extern long lseek();
00031 
00032         if  ( Traptrace )
00033         {
00034                 printf("**System call %d\n", Reg[2]);
00035                 dump_reg();
00036         }
00037 
00038 /*      if (Reg[1] == 0)
00039 /*      {                       /* SYS_indir */
00040 /*              syscallno = Reg[8];     /* out reg 0 */
00041 /*              o0 = Reg[9];
00042 /*              o1 = Reg[10];
00043 /*              o2 = Reg[11];
00044 /*      }
00045 /*      else    /* */
00046         {
00047                 syscallno = Reg[2];
00048                 o0 = Reg[4];
00049                 o1 = Reg[5];
00050                 o2 = Reg[6];
00051         }
00052 
00053         switch (syscallno)
00054         {
00055                 case SYS_exit:  /*1*/
00056                         printstatistics();
00057                         fflush(stdout);
00058                         exit(0);
00059                         break;
00060                 case SYS_read:  /*3*/
00061                         Reg[1] = 
00062                                 read(u_to_int_fd(o0), u_to_int_addr(o1), o2);
00063                         break;
00064                 case SYS_write: /*4*/
00065                         Reg[1] = 
00066                                 write(u_to_int_fd(o0), u_to_int_addr(o1), o2);
00067                         break;
00068 
00069                 case SYS_open:  /*5*/
00070                         Reg[1] = open(u_to_int_addr(o0), o1, o2); /* */
00071                         break;
00072 
00073                 case SYS_close: /*6*/
00074                         Reg[1] = 0;     /* hack */
00075                         break;
00076 
00077                 case 17:        /* 17 */
00078                         /* old sbreak. where did it go? */
00079                         Reg[1] = ((o0 / 8192) + 1) * 8192;
00080                         break;
00081 
00082                 case SYS_lseek: /*19*/
00083                         Reg[1] = (int) lseek(u_to_int_fd(o0), (long) o1, o2);
00084                         break;
00085 
00086                 case SYS_ioctl:/* 54 */
00087                         {       /* copied from sas -- I don't understand yet. */
00088                                 /* see dave weaver */
00089 #define IOCPARM_MASK    0x7f    /* parameters must be < 128 bytes */
00090                                 int size = (o1 >> 16) & IOCPARM_MASK;
00091                                 char ioctl_group = (o1 >> 8) & 0x00ff;
00092                                 if ((ioctl_group == 't') && (size == 8))
00093                                 {
00094                                         size = 6;
00095                                         o1 = (o1 & ~((IOCPARM_MASK << 16))) 
00096                                            | (size << 16);
00097                                 }
00098                         }
00099                         Reg[1] = ioctl(u_to_int_fd(o0),o1,u_to_int_addr(o2));
00100                         Reg[1] = 0;     /* hack */
00101                         break;
00102 
00103                 case SYS_fstat:         /* 62 */
00104                         Reg[1] = fstat(o1, o2);
00105                         break;
00106 
00107                 case SYS_getpagesize:   /* 64 */
00108                         Reg[1] = getpagesize();
00109                         break;
00110 
00111                 default:
00112                         printf("Unknown System call %d\n", syscallno);
00113                         if  ( ! Traptrace )
00114                                 dump_reg();
00115                         exit(2);
00116                         break;
00117         }
00118         if  ( Traptrace )
00119         {
00120                 printf("**Afterwards:\n");
00121                 dump_reg();
00122         }
00123 }

char* u_to_int_addr ptr   
 

char* u_to_int_addr  
 


Variable Documentation

char mem[]
 

Definition at line 13 of file system.c.

int Reg[]
 

Definition at line 12 of file system.c.

Referenced by system_trap.

int Traptrace
 

Definition at line 14 of file system.c.


Generated on Mon Feb 10 09:54:52 2003 for nachos by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002
The University of Southern California does not screen or control the content on this website and thus does not guarantee the accuracy, integrity, or quality of such content. All content on this website is provided by and is the sole responsibility of the person from which such content originated, and such content does not necessarily reflect the opinions of the University administration or the Board of Trustees