void Debugger(const char * reason);
This function freezes the kernel and enters the builtin debugger. It may not be possible to exit the debugger without a second machine.
Name Description reason A C-string to describe why the debugger is being entered.
IOThread IOCreateThread(IOThreadFunc function, void *argument);
This function creates a kernel thread, and passes the caller supplied argument to the new thread.
Result: An IOThread identifier for the new thread, equivalent to an osfmk thread_t.
Name Description function A C-function pointer where the thread will begin execution. argument Caller specified data to be passed to the new thread.
void IODelay(unsigned microseconds);
This function spins to delay for at least the number of specified microseconds. Since the CPU is busy spinning no time is made available to other processes; this method of delay should be used only for short periods. Also, the AbsoluteTime based APIs of kern/clock.h provide finer grained and lower cost delays.
Name Description microseconds The integer number of microseconds to spin wait.
volatile void IOExitThread();
This function destroys the currently running thread, and does not return.
IOReturn IOFlushProcessorCache( task_t task, IOVirtualAddress address, IOByteCount length );
This function flushes the processor cache of an already mapped memory range. Note in most cases it is preferable to use IOMemoryDescriptor::prepare and complete to manage cache coherency since they are aware of the architecture's requirements. Flushing the processor cache is not required for coherency in most situations.
Result: An IOReturn code.
Name Description task Task the memory is mapped into. address Virtual address of the memory. length Length of the range to set.
void IOFree(void * address, vm_size_t size);
This function frees memory allocated with IOMalloc, it may block and so should not be called from interrupt level or while a simple lock is held.
Name Description address Pointer to the allocated memory. size Size of the memory allocated.
void IOFreeAligned(void * address, vm_size_t size);
This function frees memory allocated with IOMallocAligned, it may block and so should not be called from interrupt level or while a simple lock is held.
Name Description address Pointer to the allocated memory. size Size of the memory allocated.
void IOFreeContiguous(void * address, vm_size_t size);
This function frees memory allocated with IOMallocContiguous, it may block and so should not be called from interrupt level or while a simple lock is held.
Name Description address Virtual address of the allocated memory. size Size of the memory allocated.
void IOLog(const char *format, ...) __attribute__((format(printf, 1, 2)));
This function allows a driver to log diagnostic information to the screen during verbose boots, and to a log file found at /var/log/system.log. IOLog should not be called from interrupt context.
Name Description format A printf() style format string (see printf() documentation). other arguments described by the format string.
void * IOMalloc(vm_size_t size);
This is a general purpose utility to allocate memory in the kernel. There are no alignment guarantees given on the returned memory, and alignment may vary depending on the kernel configuration. This function may block and so should not be called from interrupt level or while a simple lock is held.
Result: Pointer to the allocated memory, or zero on failure.
Name Description size Size of the memory requested.
void * IOMallocAligned(vm_size_t size, vm_offset_t alignment);
This is a utility to allocate memory in the kernel, with an alignment restriction which is specified as a byte count. This function may block and so should not be called from interrupt level or while a simple lock is held.
Result: Pointer to the allocated memory, or zero on failure.
Name Description size Size of the memory requested. alignment Byte count of the alignment for the memory. For example, pass 256 to get memory allocated at an address with bit 0-7 zero.
void * IOMallocContiguous(vm_size_t size, vm_size_t alignment, IOPhysicalAddress * physicalAddress);
This is a utility to allocate memory in the kernel, with an alignment restriction which is specified as a byte count, and will allocate only physically contiguous memory. The request may fail if memory is fragmented, and may cause large amounts of paging activity. This function may block and so should not be called from interrupt level or while a simple lock is held.
Result: Virtual address of the allocated memory, or zero on failure.
Name Description size Size of the memory requested. alignment Byte count of the alignment for the memory. For example, pass 256 to get memory allocated at an address with bits 0-7 zero. physicalAddress IOMallocContiguous returns the physical address of the allocated memory here, if physicalAddress is a non-zero pointer.
IOReturn IOSetProcessorCacheMode( task_t task, IOVirtualAddress address, IOByteCount length, IOOptionBits cacheMode );
This function sets the cache mode of an already mapped & wired memory range. Note this may not be supported on I/O mappings or shared memory - it is far preferable to set the cache mode as mappings are created with the IOMemoryDescriptor::map method.
Result: An IOReturn code.
Name Description task Task the memory is mapped into. address Virtual address of the memory. length Length of the range to set. cacheMode A constant from IOTypes.h,
kIOMapDefaultCache to inhibit the cache in I/O areas, kIOMapCopybackCache in general purpose RAM.
kIOMapInhibitCache, kIOMapWriteThruCache, kIOMapCopybackCache to set the appropriate caching.
void IOSleep(unsigned milliseconds);
This function blocks the calling thread for at least the number of specified milliseconds, giving time to other processes.
Name Description milliseconds The integer number of milliseconds to wait.
This function returns the current thread (a pointer to the currently active osfmk thread_shuttle).
© 2000 Apple Computer, Inc. (Last Updated 2/23/2000)