home *** CD-ROM | disk | FTP | other *** search
/ ftp.ee.pdx.edu / 2014.02.ftp.ee.pdx.edu.tar / ftp.ee.pdx.edu / pub / users / Harry / Blitz / OSProject / p5 / UserSystem.h < prev   
Text File  |  2007-09-19  |  4KB  |  106 lines

  1. header UserSystem
  2.  
  3.   -- Syscall code numbers for kernel interface routines.
  4.   -- NOTE: These codes must exactly match an identical enum in Kernel.h.
  5.   enum SYSCALL_EXIT = 1,
  6.        SYSCALL_SHUTDOWN,
  7.        SYSCALL_YIELD,
  8.        SYSCALL_FORK,
  9.        SYSCALL_JOIN,
  10.        SYSCALL_EXEC,
  11.        SYSCALL_CREATE,
  12.        SYSCALL_OPEN,
  13.        SYSCALL_READ,
  14.        SYSCALL_WRITE,
  15.        SYSCALL_SEEK,
  16.        SYSCALL_CLOSE
  17.  
  18.   --
  19.   -- The following routines comprise the syscall interface to the kernel.  They
  20.   -- are wrapper functions, which do nothing more than a syscall to the kernel.
  21.   --
  22.   functions
  23.     Sys_Exit (returnStatus: int)
  24.     Sys_Shutdown ()
  25.     Sys_Yield ()
  26.     Sys_Fork () returns int
  27.     Sys_Join (processID: int) returns int
  28.     Sys_Exec (filename: String) returns int
  29.     Sys_Create (filename: String) returns int
  30.     Sys_Open (filename: String) returns int
  31.     Sys_Read (fileDesc: int, buffer: ptr to char, sizeInBytes: int) returns int
  32.     Sys_Write (fileDesc: int, buffer: ptr to char, sizeInBytes: int) returns int
  33.     Sys_Seek (fileDesc: int, newCurrentPos: int) returns int
  34.     Sys_Close (fileDesc: int)
  35.  
  36.   --
  37.   -- The following routines are implemented in UserRuntime.s:
  38.   --
  39.   functions
  40.     external DoSyscall (funCode, arg1, arg2, arg3, arg4: int) returns int
  41.     external TerminateWithError ()
  42.  
  43.   --
  44.   -- The following routines print data directly and immediately to the output.
  45.   -- They bypass the serial I/O device and use the debug2 "back-door" to
  46.   -- the virtual machine.  NOTE: These routines are for use in debugging the
  47.   -- kernel; normally a user process will use the "write" syscall to do all
  48.   -- output.
  49.   --
  50.   functions
  51.     external print (s: String)
  52.     external printInt (i: int)
  53.     external printHex (i: int)           -- prints, e.g., 0x0012ABCD
  54.     external printChar (c: char)         -- prints non-printables as, e.g., \x05
  55.     external printBool (b: bool)         -- prints "TRUE" or "FALSE"
  56.     external printDouble (d: double)
  57.  
  58.   --
  59.   -- Misc. useful stuff.
  60.   --
  61.   type String = ptr to array of char
  62.   functions
  63.     StrEqual (s1, s2: String) returns bool
  64.     StrCopy (s1, s2: String)               -- Copy s2 into s1; move min(s1,s2) chars
  65.     StrCmp (s1, s2: String) returns int    -- return -1 if <, 0 if =, +1 if >
  66.     Min (i, j: int) returns int
  67.     Max (i, j: int) returns int
  68.     printIntVar (s: String, i: int)        -- prints "s = " int \n
  69.     printHexVar (s: String, i: int)        -- prints "s = " 0x00000000 \n
  70.     printBoolVar (s: String, b: bool)      -- prints "s = " bool \n
  71.     printCharVar (s: String, c: char)      -- prints "s = " ch \n
  72.     printPtr (s: String, p: ptr to void)   -- prints "s = " 0x00000000 \n
  73.     nl ()                                  -- Short for printChar ('\n')
  74.     MemoryEqual (s1, s2: ptr to char, len: int) returns bool
  75.  
  76.   --
  77.   -- The following routines are implemented in assembly in the Runtime.s file.
  78.   --
  79.   functions
  80.     external getCatchStack () returns int  -- Actually returns ptr to a CATCH_RECORD
  81.     external MemoryZero (destAddr, byteCount: int)  -- Set block of mem to zeros
  82.     external MemoryCopy (destAddr: int,             -- Copy bytes from one memory area
  83.                          srcAddr: int,              -- to another memory area.  Need not
  84.                          byteCount: int)            -- be aligned, but must not overlap!
  85.   --
  86.   -- The following functions are part of the KPL language support.
  87.   --
  88.   functions
  89.     KPLSystemInitialize ()
  90.     KPLMemoryAlloc (byteCount: int) returns ptr to char
  91.     KPLMemoryFree (p: ptr to char)
  92.     KPLUncaughtThrow (errorID: ptr to char, line: int, rPtr: int)
  93.     KPLIsKindOf (objPtr: ptr to Object, typeDesc: ptr to int) returns int
  94.     KPLSystemError (message: String)
  95.   errors
  96.     UncaughtThrowError (errorID: ptr to char, line: int, routineDescPtr: int)
  97.  
  98.   --
  99.   -- The class "Object" is the root of the superclass/subclass tree.  It has no
  100.   -- fields and no methods.
  101.   --
  102.   class Object
  103.   endClass
  104.  
  105. endHeader
  106.