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 / p8 / System.h < prev    next >
Text File  |  2007-09-19  |  4KB  |  79 lines

  1. header System
  2.  
  3.   -- The following routines print data directly and immediately to the output.
  4.   -- They are intended only for use in debugging kernel code; as such they
  5.   -- bypass the serial I/O device entirely and use the debug2 "back-door" to
  6.   -- the virtual machine.  They may be called from any code, including
  7.   -- from within an interrupt handler.  NOTE: A process switch may occur at
  8.   -- any time, but each of these routines will print atomically.  In
  9.   -- other words, each will either print all of its output before the switch
  10.   -- or all of its output when the process resumes.  However, if several calls
  11.   -- are made in sequence, the output may be intermixed with the output from
  12.   -- another thread.  To avoid this and ensure all output from several calls
  13.   -- is printed together, you may wish to create and use a "lock" and
  14.   -- force all threads to acquire the lock before printing.  Another approach
  15.   -- is to explicitly disable interrupts before making a series of printing
  16.   -- calls and then restore the interrupt status after printing is complete.
  17.   functions
  18.     external print (s: ptr to array of char)
  19.     external printInt (i: int)
  20.     external printHex (i: int)           -- prints, e.g., 0x0012ABCD
  21.     external printChar (c: char)         -- prints non-printables as, e.g., \x05
  22.     external printBool (b: bool)         -- prints "TRUE" or "FALSE"
  23.  
  24.  
  25.   -- Misc. useful stuff.
  26.   type String = ptr to array of char
  27.   functions
  28.     MemoryEqual (s1, s2: ptr to char, len: int) returns bool
  29.     StrEqual (s1, s2: String) returns bool
  30.     StrCopy (s1, s2: String)               -- Copy s2 into s1; move min(s1,s2) chars
  31.     StrCmp (s1, s2: String) returns int    -- return -1 if <, 0 if =, +1 if >
  32.     Min (i, j: int) returns int
  33.     Max (i, j: int) returns int
  34.     printIntVar (s: String, i: int)        -- prints "s = " int \n
  35.     printHexVar (s: String, i: int)        -- prints "s = " 0x00000000 \n
  36.     printBoolVar (s: String, b: bool)      -- prints "s = " bool \n
  37.     printCharVar (s: String, c: char)      -- prints "s = " ch \n
  38.     printPtr (s: String, p: ptr to void)   -- prints "s = " 0x00000000 \n
  39.     nl ()                                  -- Short for printChar ('\n')
  40.     PrintMemory (startingAddr, numBytes: int)
  41.  
  42.  
  43.   -- The following routines are implemented in assembly in the Runtime.s file.
  44.   functions
  45.     external Cleari ()                -- Execute "cleari" instruction and return
  46.     external Seti ()                  -- Execute "seti" instruction and return
  47.     external Wait ()                  -- Execute "wait" instruction and return
  48.     external RuntimeExit ()           -- Terminate all execution and do not return
  49.     external getCatchStack () returns int  -- Actually returns ptr to a CATCH_RECORD
  50.     external MemoryZero (destAddr, byteCount: int)  -- Set block of mem to zeros
  51.     external MemoryCopy (destAddr: int,             -- Copy bytes from one memory area
  52.                          srcAddr: int,              -- to another memory area.  Need not
  53.                          byteCount: int)            -- be aligned, but must not overlap!
  54.  
  55.   -- The following function is called to shutdown the entire system when a
  56.   -- major error occurs.  We use a variable since the appropriate function
  57.   -- to invoked will be changed after thread scheduling begins.
  58.   var
  59.     FatalError: ptr to function (ptr to array of char)
  60.  
  61.   -- The following functions are part of the KPL language support.
  62.   functions
  63.     KPLSystemInitialize ()
  64.     KPLMemoryAlloc (byteCount: int) returns ptr to char
  65.     KPLMemoryFree (p: ptr to char)
  66.     KPLUncaughtThrow (errorID: ptr to char, line: int, rPtr: int)
  67.     KPLIsKindOf (objPtr: ptr to Object, typeDesc: ptr to int) returns int
  68.     KPLSystemError (message: ptr to array of char)
  69.   errors
  70.     UncaughtThrowError (errorID: ptr to char, line: int, routineDescPtr: int)
  71.  
  72.  
  73.   -- The class "Object" is the root of the superclass/subclass tree.  It has no
  74.   -- fields and no methods.
  75.   class Object
  76.   endClass
  77.  
  78. endHeader
  79.