home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.1 (Developer) [x86] / NeXT Step 3.1 Intel dev.cdr.dmg / NextDeveloper / Headers / driverkit / generalFuncs.h < prev    next >
Encoding:
Text File  |  1993-02-17  |  2.3 KB  |  108 lines

  1. /*     Copyright (c) 1991 NeXT Computer, Inc.  All rights reserved. 
  2.  *
  3.  * generalFuncs.h - General purpose driverkit functions.
  4.  *
  5.  * HISTORY
  6.  * 18-Apr-91    Doug Mitchell at NeXT
  7.  *      Created. 
  8.  */
  9.  
  10. #import <mach/mach_types.h>
  11. #import <driverkit/return.h>
  12. #import <kernserv/clock_timer.h>
  13. #import <driverkit/driverTypes.h>
  14.  
  15. /*
  16.  * These are opaque to the user.
  17.  */
  18. typedef void  *IOThread;
  19. typedef void (*IOThreadFunc)(void *arg);
  20.  
  21. /*
  22.  * Memory allocation functions. Both may block.
  23.  */
  24. void *IOMalloc(int size);
  25. void IOFree(void *p, int size);
  26.  
  27. /*
  28.  * Thread and task functions.
  29.  */
  30. /*
  31.  * Start a new thread starting execution at fcn with argument arg.
  32.  */
  33. IOThread IOForkThread(IOThreadFunc fcn, void *arg);
  34.  
  35. /*
  36.  * Suspend a thread started with IOThreadFork().
  37.  */
  38. void IOSuspendThread(IOThread thread);
  39.  
  40. /*
  41.  * Resume a thread started by IOThreadFork().
  42.  */
  43. void IOResumeThread(IOThread thread);
  44.  
  45. /*
  46.  * Terminate exceution of current thread. Does not return.
  47.  */
  48. volatile void IOExitThread();
  49.  
  50. /*
  51.  * Sleep for indicated number of milliseconds.
  52.  */
  53. void IOSleep(unsigned milliseconds);
  54.  
  55. /*
  56.  * Spin for indicated number of microseconds.
  57.  */
  58. void IODelay(unsigned microseconds);
  59.  
  60. /*
  61.  * Call function fcn with argument arg in specified number of seconds.
  62.  * WARNING: The kernel version of this function does the callback in
  63.  *         the kernel task's context, not the IOTask context.
  64.  */
  65. void IOScheduleFunc(IOThreadFunc fcn, void *arg, int seconds);
  66.  
  67. /*
  68.  * Cancel callout requested in IOScheduleFunc().
  69.  */
  70. void IOUnscheduleFunc(IOThreadFunc fcn, void *arg);
  71.  
  72. /*
  73.  * Obtain current time in ns.
  74.  */
  75. void IOGetTimestamp(ns_time_t *nsp);
  76.  
  77. /*
  78.  * Log a printf-style string to console.
  79.  */
  80. void IOLog(const char *format, ...);
  81.  
  82. /*
  83.  * Panic (if in the kernel) or dump core (if user space).
  84.  * FIXME - this should be a volatile, but panic() isn't...
  85.  */
  86. void IOPanic(const char *reason);
  87.  
  88. /*
  89.  * Convert a integer constant (typically a #define or enum) to a string
  90.  * via an array of IONamedValue.
  91.  */
  92. const char *IOFindNameForValue(int value, 
  93.     const IONamedValue *namedValueArray);
  94.  
  95. /*
  96.  * Convert a string to an int via an array of IONamedValue. Returns
  97.  * IO_R_SUCCESS of string found, else returns IO_R_INVALIDARG.
  98.  */
  99. IOReturn IOFindValueForName(const char *string, 
  100.     const IONamedValue *regValueArray,
  101.     int *value);                /* RETURNED */
  102.  
  103. /*
  104.  * One-time only init for this module.
  105.  */
  106. void IOInitGeneralFuncs();
  107.  
  108.