Main Page   Compound List   File List   Compound Members   File Members  

syscall.h

Go to the documentation of this file.
00001 /* syscalls.h 
00002  *      Nachos system call interface.  These are Nachos kernel operations
00003  *      that can be invoked from user programs, by trapping to the kernel
00004  *      via the "syscall" instruction.
00005  *
00006  *      This file is included by user programs and by the Nachos kernel. 
00007  *
00008  * Copyright (c) 1992-1993 The Regents of the University of California.
00009  * All rights reserved.  See copyright.h for copyright notice and limitation 
00010  * of liability and disclaimer of warranty provisions.
00011  */
00012 
00013 #ifndef SYSCALLS_H
00014 #define SYSCALLS_H
00015 
00016 #include "copyright.h"
00017 
00018 /* system call codes -- used by the stubs to tell the kernel which system call
00019  * is being asked for
00020  */
00021 #define SC_Halt         0
00022 #define SC_Exit         1
00023 #define SC_Exec         2
00024 #define SC_Join         3
00025 #define SC_Create       4
00026 #define SC_Open         5
00027 #define SC_Read         6
00028 #define SC_Write        7
00029 #define SC_Close        8
00030 #define SC_Fork         9
00031 #define SC_Yield        10
00032 
00033 #ifndef IN_ASM
00034 
00035 /* The system call interface.  These are the operations the Nachos
00036  * kernel needs to support, to be able to run user programs.
00037  *
00038  * Each of these is invoked by a user program by simply calling the 
00039  * procedure; an assembly language stub stuffs the system call code
00040  * into a register, and traps to the kernel.  The kernel procedures
00041  * are then invoked in the Nachos kernel, after appropriate error checking, 
00042  * from the system call entry point in exception.cc.
00043  */
00044 
00045 /* Stop Nachos, and print out performance stats */
00046 void Halt();            
00047  
00048 
00049 /* Address space control operations: Exit, Exec, and Join */
00050 
00051 /* This user program is done (status = 0 means exited normally). */
00052 void Exit(int status);  
00053 
00054 /* A unique identifier for an executing user program (address space) */
00055 typedef int SpaceId;    
00056  
00057 /* Run the executable, stored in the Nachos file "name", and return the 
00058  * address space identifier
00059  */
00060 SpaceId Exec(char *name);
00061  
00062 /* Only return once the the user program "id" has finished.  
00063  * Return the exit status.
00064  */
00065 int Join(SpaceId id);   
00066  
00067 
00068 /* File system operations: Create, Open, Read, Write, Close
00069  * These functions are patterned after UNIX -- files represent
00070  * both files *and* hardware I/O devices.
00071  *
00072  * If this assignment is done before doing the file system assignment,
00073  * note that the Nachos file system has a stub implementation, which
00074  * will work for the purposes of testing out these routines.
00075  */
00076  
00077 /* A unique identifier for an open Nachos file. */
00078 typedef int OpenFileId; 
00079 
00080 /* when an address space starts up, it has two open files, representing 
00081  * keyboard input and display output (in UNIX terms, stdin and stdout).
00082  * Read and Write can be used directly on these, without first opening
00083  * the console device.
00084  */
00085 
00086 #define ConsoleInput    0  
00087 #define ConsoleOutput   1  
00088  
00089 /* Create a Nachos file, with "name" */
00090 void Create(char *name);
00091 
00092 /* Open the Nachos file "name", and return an "OpenFileId" that can 
00093  * be used to read and write to the file.
00094  */
00095 OpenFileId Open(char *name);
00096 
00097 /* Write "size" bytes from "buffer" to the open file. */
00098 void Write(char *buffer, int size, OpenFileId id);
00099 
00100 /* Read "size" bytes from the open file into "buffer".  
00101  * Return the number of bytes actually read -- if the open file isn't
00102  * long enough, or if it is an I/O device, and there aren't enough 
00103  * characters to read, return whatever is available (for I/O devices, 
00104  * you should always wait until you can return at least one character).
00105  */
00106 int Read(char *buffer, int size, OpenFileId id);
00107 
00108 /* Close the file, we're done reading and writing to it. */
00109 void Close(OpenFileId id);
00110 
00111 
00112 
00113 /* User-level thread operations: Fork and Yield.  To allow multiple
00114  * threads to run within a user program. 
00115  */
00116 
00117 /* Fork a thread to run a procedure ("func") in the *same* address space 
00118  * as the current thread.
00119  */
00120 void Fork(void (*func)());
00121 
00122 /* Yield the CPU to another runnable thread, whether in this address space 
00123  * or not. 
00124  */
00125 void Yield();           
00126 
00127 #endif /* IN_ASM */
00128 
00129 #endif /* SYSCALL_H */

Generated on Mon Feb 10 09:54:47 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