ADC Home > Reference Library > Reference > Darwin > Kernel Framework Reference
|
IOLib.h |
Includes: |
<sys/cdefs.h> <sys/appleapiopts.h> <IOKit/system.h> <IOKit/IOReturn.h> <IOKit/IOTypes.h> <IOKit/IOLocks.h> <libkern/OSAtomic.h> <kern/thread_call.h> <kern/clock.h> |
Enter the kernel debugger.
Create a kernel thread.
Spin delay for a number of microseconds.
Terminate exceution of current thread.
Flushes the processor cache for mapped memory.
Frees memory allocated with IOMalloc.
Frees memory allocated with IOMallocAligned.
Frees memory allocated with IOMallocContiguous.
Frees memory allocated with IOMallocPageable.
Log a message to console in text mode, and /var/log/system.log.
Allocates general purpose, wired memory in the kernel map.
Allocates wired memory in the kernel map, with an alignment restriction.
Allocates wired memory in the kernel map, with an alignment restriction and physically contiguous.
Allocates pageable memory in the kernel map.
Read two bytes from the desired "Physical" IOSpace address.
Read four bytes from the desired "Physical" IOSpace address.
Read eight bytes from the desired "Physical" IOSpace address.
Read one byte from the desired "Physical" IOSpace address.
Write two bytes to the desired "Physical" IOSpace address.
Write four bytes to the desired "Physical" IOSpace address.
Write eight bytes to the desired "Physical" IOSpace address.
Write one byte to the desired "Physical" IOSpace address.
Spin delay for a number of nanoseconds.
Sets the processor cache mode for mapped memory.
Sleep the calling thread for a number of milliseconds.
Debugger |
Enter the kernel debugger.
void Debugger( const char * reason);
reason
A C-string to describe why the debugger is being entered.
This function freezes the kernel and enters the builtin debugger. It may not be possible to exit the debugger without a second machine.
IOCreateThread |
Create a kernel thread.
IOThread IOCreateThread( IOThreadFunc function, void *argument);
function
A C-function pointer where the thread will begin execution.
argument
Caller specified data to be passed to the new thread.
An IOThread identifier for the new thread, equivalent to an osfmk thread_t.
This function creates a kernel thread, and passes the caller supplied argument to the new thread. Warning: the value returned by this function is not 100% reliable. There is a race condition where it is possible that the new thread has already terminated before this call returns. Under that circumstance the IOThread returned will be invalid. In general there is little that can be done with this value except compare it against 0. The thread itself can call IOThreadSelf() 100% reliably and that is the prefered mechanism to manipulate the IOThreads state.
IODelay |
Spin delay for a number of microseconds.
void IODelay( unsigned microseconds);
microseconds
The integer number of microseconds to spin wait.
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.
IOExitThread |
Terminate exceution of current thread.
void IOExitThread( void) __dead2;
This function destroys the currently running thread, and does not return.
IOFlushProcessorCache |
Flushes the processor cache for mapped memory.
IOReturn IOFlushProcessorCache( task_t task, IOVirtualAddress address, IOByteCount length );
task
Task the memory is mapped into.
address
Virtual address of the memory.
length
Length of the range to set.
An IOReturn code.
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.
IOFree |
Frees memory allocated with IOMalloc.
void IOFree( void *address, vm_size_t size);
address
Pointer to the allocated memory.
size
Size of the memory allocated.
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.
IOFreeAligned |
Frees memory allocated with IOMallocAligned.
void IOFreeAligned( void *address, vm_size_t size);
address
Pointer to the allocated memory.
size
Size of the memory allocated.
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.
IOFreeContiguous |
Frees memory allocated with IOMallocContiguous.
void IOFreeContiguous( void *address, vm_size_t size);
address
Virtual address of the allocated memory.
size
Size of the memory allocated.
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.
IOFreePageable |
Frees memory allocated with IOMallocPageable.
void IOFreePageable( void *address, vm_size_t size);
address
Virtual address of the allocated memory.
size
Size of the memory allocated.
This function frees memory allocated with IOMallocPageable, it may block and so should not be called from interrupt level or while a simple lock is held.
IOLog |
Log a message to console in text mode, and /var/log/system.log.
void IOLog( const char *format, ...) __attribute__((format(printf, 1, 2)));
format
A printf() style format string (see printf() documentation).
other
arguments described by the format string.
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.
IOMalloc |
Allocates general purpose, wired memory in the kernel map.
void * IOMalloc( vm_size_t size);
size
Size of the memory requested.
Pointer to the allocated memory, or zero on failure.
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.
IOMallocAligned |
Allocates wired memory in the kernel map, with an alignment restriction.
void * IOMallocAligned( vm_size_t size, vm_offset_t alignment);
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.
Pointer to the allocated memory, or zero on failure.
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.
IOMallocContiguous |
Allocates wired memory in the kernel map, with an alignment restriction and physically contiguous.
void * IOMallocContiguous( vm_size_t size, vm_size_t alignment, IOPhysicalAddress *physicalAddress);
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.
Virtual address of the allocated memory, or zero on failure.
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.
IOMallocPageable |
Allocates pageable memory in the kernel map.
void * IOMallocPageable( vm_size_t size, vm_size_t alignment);
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.
Pointer to the allocated memory, or zero on failure.
This is a utility to allocate pageable memory in the kernel. This function may block and so should not be called from interrupt level or while a simple lock is held.
IOMappedRead16 |
Read two bytes from the desired "Physical" IOSpace address.
UInt16 IOMappedRead16( IOPhysicalAddress address);
address
The desired address, as returned by IOMemoryDescriptor::getPhysicalSegment.
Data contained at that location
Read two bytes from the desired "Physical" IOSpace address. This function allows the developer to read an address returned from any memory descriptor's getPhysicalSegment routine. It can then be used by segmenting a physical page slightly to tag the physical page with its kernel space virtual address.
IOMappedRead32 |
Read four bytes from the desired "Physical" IOSpace address.
UInt32 IOMappedRead32( IOPhysicalAddress address);
address
The desired address, as returned by IOMemoryDescriptor::getPhysicalSegment.
Data contained at that location
Read four bytes from the desired "Physical" IOSpace address. This function allows the developer to read an address returned from any memory descriptor's getPhysicalSegment routine. It can then be used by segmenting a physical page slightly to tag the physical page with its kernel space virtual address.
IOMappedRead64 |
Read eight bytes from the desired "Physical" IOSpace address.
UInt64 IOMappedRead64( IOPhysicalAddress address);
address
The desired address, as returned by IOMemoryDescriptor::getPhysicalSegment.
Data contained at that location
Read eight bytes from the desired "Physical" IOSpace address. This function allows the developer to read an address returned from any memory descriptor's getPhysicalSegment routine. It can then be used by segmenting a physical page slightly to tag the physical page with its kernel space virtual address.
IOMappedRead8 |
Read one byte from the desired "Physical" IOSpace address.
UInt8 IOMappedRead8( IOPhysicalAddress address);
address
The desired address, as returned by IOMemoryDescriptor::getPhysicalSegment.
Data contained at that location
Read one byte from the desired "Physical" IOSpace address. This function allows the developer to read an address returned from any memory descriptor's getPhysicalSegment routine. It can then be used by segmenting a physical page slightly to tag the physical page with its kernel space virtual address.
IOMappedWrite16 |
Write two bytes to the desired "Physical" IOSpace address.
void IOMappedWrite16( IOPhysicalAddress address, UInt16 value);
address
The desired address, as returned by IOMemoryDescriptor::getPhysicalSegment.
value
Data to be writen to the desired location
Write two bytes to the desired "Physical" IOSpace address. This function allows the developer to write to an address returned from any memory descriptor's getPhysicalSegment routine.
IOMappedWrite32 |
Write four bytes to the desired "Physical" IOSpace address.
void IOMappedWrite32( IOPhysicalAddress address, UInt32 value);
address
The desired address, as returned by IOMemoryDescriptor::getPhysicalSegment.
value
Data to be writen to the desired location
Write four bytes to the desired "Physical" IOSpace address. This function allows the developer to write to an address returned from any memory descriptor's getPhysicalSegment routine.
IOMappedWrite64 |
Write eight bytes to the desired "Physical" IOSpace address.
void IOMappedWrite64( IOPhysicalAddress address, UInt64 value);
address
The desired address, as returned by IOMemoryDescriptor::getPhysicalSegment.
value
Data to be writen to the desired location
Write eight bytes to the desired "Physical" IOSpace address. This function allows the developer to write to an address returned from any memory descriptor's getPhysicalSegment routine.
IOMappedWrite8 |
Write one byte to the desired "Physical" IOSpace address.
void IOMappedWrite8( IOPhysicalAddress address, UInt8 value);
address
The desired address, as returned by IOMemoryDescriptor::getPhysicalSegment.
value
Data to be writen to the desired location
Write one byte to the desired "Physical" IOSpace address. This function allows the developer to write to an address returned from any memory descriptor's getPhysicalSegment routine.
IOPause |
Spin delay for a number of nanoseconds.
void IOPause( unsigned nanoseconds);
microseconds
The integer number of nanoseconds to spin wait.
This function spins to delay for at least the number of specified nanoseconds. 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.
IOSetProcessorCacheMode |
Sets the processor cache mode for mapped memory.
IOReturn IOSetProcessorCacheMode( task_t task, IOVirtualAddress address, IOByteCount length, IOOptionBits cacheMode );
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.
An IOReturn code.
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.
IOSleep |
Sleep the calling thread for a number of milliseconds.
void IOSleep( unsigned milliseconds);
milliseconds
The integer number of milliseconds to wait.
This function blocks the calling thread for at least the number of specified milliseconds, giving time to other processes.
IOThreadSelf |
Returns the osfmk identifier for the currently running thread.
#define IOThreadSelf()
This function returns the current thread (a pointer to the currently active osfmk thread_shuttle).
|
Last Updated: 2008-12-19