Unnamed: 0
int64 0
0
| repo_id
stringlengths 5
186
| file_path
stringlengths 15
223
| content
stringlengths 1
32.8M
⌀ |
---|---|---|---|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/arm/machine_cpuid.h | /*
* Copyright (c) 2017 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _ARM_MACHINE_CPUID_H_
#define _ARM_MACHINE_CPUID_H_
/* CPU feature identification */
typedef struct {
uint32_t arm_32bit_isa : 4,
arm_thumb_ver : 4,
arm_jazelle : 4,
arm_thumb2 : 4,
reserved : 16;
} arm_feature_bits_t;
typedef union {
arm_feature_bits_t field;
uint32_t value;
} arm_feature0_reg_t;
// Register 0, subtype 21: Instruction Set Features #1
typedef struct{
uint32_t endianness_support : 4;
uint32_t exception_1_support : 4;
uint32_t exception_2_support : 4;
uint32_t sign_zero_ext_support : 4;
uint32_t if_then_support : 4;
uint32_t immediate_support : 4;
uint32_t interworking_support : 4;
uint32_t jazelle_support : 4;
}
syscp_ID_instructions_feat_1_reg;
typedef union {
uint32_t value;
syscp_ID_instructions_feat_1_reg field;
} arm_isa_feat1_reg;
arm_isa_feat1_reg machine_read_isa_feat1(void);
/* Debug identification */
/* ID_DFR0 */
typedef union {
struct {
uint32_t coprocessor_core_debug : 4,
coprocessor_secure_debug : 4,
memory_mapped_core_debug : 4,
coprocessor_trace_debug : 4,
memory_mapped_trace_debug : 4,
microcontroller_debug : 4;
} debug_feature;
uint32_t value;
} arm_cpuid_id_dfr0;
/* DBGDIDR */
typedef union {
struct {
uint32_t revision : 4,
variant : 4,
: 4,
se_imp : 1,
pcsr_imp : 1,
nsuhd_imp : 1,
: 1,
version : 4,
ctx_cmps : 4,
brps : 4,
wrps : 4;
} debug_id;
uint32_t value;
} arm_debug_dbgdidr;
typedef struct {
boolean_t memory_mapped_core_debug;
boolean_t coprocessor_core_debug;
uint32_t num_watchpoint_pairs;
uint32_t num_breakpoint_pairs;
} arm_debug_info_t;
#endif /* _ARM_MACHINE_CPUID_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/device/device_types.h | /*
* Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
/*
* Mach Operating System
* Copyright (c) 1991,1990,1989 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or [email protected]
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
/*
*/
/*
* Author: David B. Golub, Carnegie Mellon University
* Date: 3/89
*/
#ifndef DEVICE_TYPES_H
#define DEVICE_TYPES_H
/*
* Types for device interface.
*/
#include <mach/std_types.h>
#include <mach/mach_types.h>
#include <mach/message.h>
#include <mach/port.h>
#include <stdint.h>
/*
* IO buffer - out-of-line array of characters.
*/
typedef char * io_buf_ptr_t;
/*
* Some types for IOKit.
*/
#ifdef IOKIT
/* must match device_types.defs */
typedef char io_name_t[128];
typedef char io_string_t[512];
typedef char io_string_inband_t[4096];
typedef char io_struct_inband_t[4096];
typedef uint64_t io_user_scalar_t;
typedef uint64_t io_user_reference_t __kernel_ptr_semantics;
typedef int io_scalar_inband_t[16];
// must be the same type as OSAsyncReference
typedef natural_t io_async_ref_t[8] __kernel_ptr_semantics;
typedef io_user_scalar_t io_scalar_inband64_t[16];
typedef io_user_reference_t io_async_ref64_t[8];
#ifndef __IOKIT_PORTS_DEFINED__
#define __IOKIT_PORTS_DEFINED__
typedef mach_port_t io_object_t;
#endif /* __IOKIT_PORTS_DEFINED__ */
#endif /* IOKIT */
#endif /* DEVICE_TYPES_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/device/device_port.h | /*
* Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
/*
* Mach Operating System
* Copyright (c) 1991,1990,1989 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or [email protected]
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
/*
*/
/*
* Author: David B. Golub, Carnegie Mellon University
* Date: 8/89
*/
#ifndef _DEVICE_DEVICE_PORT_H_
#define _DEVICE_DEVICE_PORT_H_
#include <device/device_types.h>
/*
* Master privileged I/O object for this host
*/
extern mach_port_t master_device_port;
#define DEVICE_PAGER_GUARDED 0x1
#define DEVICE_PAGER_COHERENT 0x2
#define DEVICE_PAGER_CACHE_INHIB 0x4
#define DEVICE_PAGER_WRITE_THROUGH 0x8
#define DEVICE_PAGER_CONTIGUOUS 0x100
#define DEVICE_PAGER_NOPHYSCACHE 0x200
#endif /* _DEVICE_DEVICE_PORT_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IODataQueueShared.h | /*
* Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _IOKIT_IODATAQUEUESHARED_H
#define _IOKIT_IODATAQUEUESHARED_H
#include <libkern/OSTypes.h>
#include <mach/port.h>
#include <mach/message.h>
/*!
* @typedef IODataQueueEntry
* @abstract Represents an entry within the data queue
* @discussion This is a variable sized struct. The data field simply represents the start of the data region. The size of the data region is stored in the size field. The whole size of the specific entry is the size of a UInt32 plus the size of the data region.
* @field size The size of the following data region.
* @field data Represents the beginning of the data region. The address of the data field is a pointer to the start of the data region.
*/
typedef struct _IODataQueueEntry {
UInt32 size;
UInt8 data[4];
} IODataQueueEntry;
/*!
* @typedef IODataQueueMemory
* @abstract A struct mapping to the header region of a data queue.
* @discussion This struct is variable sized. The struct represents the data queue header information plus a pointer to the actual data queue itself. The size of the struct is the combined size of the header fields (3 * sizeof(UInt32)) plus the actual size of the queue region. This size is stored in the queueSize field.
* @field queueSize The size of the queue region pointed to by the queue field.
* @field head The location of the queue head. This field is represented as a byte offset from the beginning of the queue memory region.
* @field tail The location of the queue tail. This field is represented as a byte offset from the beginning of the queue memory region.
* @field queue Represents the beginning of the queue memory region. The size of the region pointed to by queue is stored in the queueSize field.
*/
typedef struct _IODataQueueMemory {
UInt32 queueSize;
volatile UInt32 head;
volatile UInt32 tail;
IODataQueueEntry queue[1];
} IODataQueueMemory;
/*!
* @typedef IODataQueueAppendix
* @abstract A struct mapping to the appendix region of a data queue.
* @discussion This struct is variable sized dependent on the version. The struct represents the data queue appendix information.
* @field version The version of the queue appendix.
* @field msgh Mach message header containing the notification mach port associated with this queue.
*/
typedef struct _IODataQueueAppendix {
UInt32 version;
mach_msg_header_t msgh;
} IODataQueueAppendix;
/*!
* @defined DATA_QUEUE_ENTRY_HEADER_SIZE Represents the size of the data queue entry header independent of the actual size of the data in the entry. This is the overhead of each entry in the queue. The total size of an entry is equal to this value plus the size stored in the entry's size field (in IODataQueueEntry).
*/
#define DATA_QUEUE_ENTRY_HEADER_SIZE (sizeof(IODataQueueEntry) - 4)
/*!
* @defined DATA_QUEUE_MEMORY_HEADER_SIZE Represents the size of the data queue memory header independent of the actual size of the queue data itself. The total size of the queue memory is equal to this value plus the size of the queue appendix and the size of the queue data region which is stored in the queueSize field of IODataQueueMeory.
*/
#define DATA_QUEUE_MEMORY_HEADER_SIZE (sizeof(IODataQueueMemory) - sizeof(IODataQueueEntry))
/*!
* @defined DATA_QUEUE_MEMORY_APPENDIX_SIZE Represents the size of the data queue memory appendix independent of the actual size of the queue data itself. The total size of the queue memory is equal to this value plus the size of queue header and size of the queue data region which is stored in the queueSize field of IODataQueueMeory.
*/
#define DATA_QUEUE_MEMORY_APPENDIX_SIZE (sizeof(IODataQueueAppendix))
#endif /* _IOKIT_IODATAQUEUESHARED_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOTimeStamp.h | /*
* Copyright (c) 1998-2010 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef IOKIT_IOTIMESTAMP_H
#define IOKIT_IOTIMESTAMP_H
#include <sys/kdebug.h>
static inline void
IOTimeStampStartConstant(unsigned int csc,
uintptr_t a = 0, uintptr_t b = 0,
uintptr_t c = 0, uintptr_t d = 0)
{
(void)csc;
(void)a;
(void)b;
(void)c;
(void)d;
KERNEL_DEBUG_CONSTANT(((uint32_t)csc) | DBG_FUNC_START, a, b, c, d, 0);
}
static inline void
IOTimeStampEndConstant(uintptr_t csc,
uintptr_t a = 0, uintptr_t b = 0,
uintptr_t c = 0, uintptr_t d = 0)
{
(void)csc;
(void)a;
(void)b;
(void)c;
(void)d;
KERNEL_DEBUG_CONSTANT(((uint32_t)csc) | DBG_FUNC_END, a, b, c, d, 0);
}
static inline void
IOTimeStampConstant(uintptr_t csc,
uintptr_t a = 0, uintptr_t b = 0,
uintptr_t c = 0, uintptr_t d = 0)
{
(void)csc;
(void)a;
(void)b;
(void)c;
(void)d;
KERNEL_DEBUG_CONSTANT(((uint32_t)csc) | DBG_FUNC_NONE, a, b, c, d, 0);
}
static inline void
IOTimeStampConstantFiltered(uintptr_t csc,
uintptr_t a = 0, uintptr_t b = 0,
uintptr_t c = 0, uintptr_t d = 0)
{
(void)csc;
(void)a;
(void)b;
(void)c;
(void)d;
KERNEL_DEBUG_CONSTANT_FILTERED(((uint32_t)csc) | DBG_FUNC_NONE, a, b, c, d, 0);
}
/*
* Objects of this class will trace a filtered interval for their lifetime.
* The constructor takes in the start tracepoint's arguments.
* By default, the end tracepoint emits no additional arguments,
* but you can set them with setEndCodes.
* Alternatively, you can set them individually with setA...setD
*/
class IOTimeStampIntervalConstantFiltered
{
public:
IOTimeStampIntervalConstantFiltered(unsigned int csc,
uintptr_t arg1 = 0, uintptr_t arg2 = 0,
uintptr_t arg3 = 0, uintptr_t arg4 = 0)
: _csc(csc), _endArg1(0), _endArg2(0), _endArg3(0), _endArg4(0)
{
(void)csc;
(void)arg1;
(void)arg2;
(void)arg3;
(void)arg4;
KDBG_FILTERED(((uint32_t)csc) | DBG_FUNC_START, arg1, arg2, arg3, arg4);
}
// Setters for the end debug codes
void
setEndCodes(uintptr_t arg1 = 0, uintptr_t arg2 = 0,
uintptr_t arg3 = 0, uintptr_t arg4 = 0)
{
_endArg1 = arg1;
_endArg2 = arg2;
_endArg3 = arg3;
_endArg4 = arg4;
}
void
setEndArg1(uintptr_t arg)
{
_endArg1 = arg;
}
void
setEndArg2(uintptr_t arg)
{
_endArg2 = arg;
}
void
setEndArg3(uintptr_t arg)
{
_endArg3 = arg;
}
void
setEndArg4(uintptr_t arg)
{
_endArg4 = arg;
}
~IOTimeStampIntervalConstantFiltered()
{
KDBG_FILTERED(((uint32_t)_csc) | DBG_FUNC_END, _endArg1, _endArg2, _endArg3, _endArg4);
}
private:
#if (KDEBUG_LEVEL < KDEBUG_LEVEL_STANDARD)
__unused
#endif /* KDEBUG_LEVEL < KDEBUG_LEVEL_STANDARD */
unsigned int _csc;
// End debug codes
#if (KDEBUG_LEVEL < KDEBUG_LEVEL_STANDARD)
__unused
#endif /* KDEBUG_LEVEL < KDEBUG_LEVEL_STANDARD */
uintptr_t _endArg1, _endArg2, _endArg3, _endArg4;
};
#if KDEBUG
static inline void
IOTimeStampStart(uintptr_t csc,
uintptr_t a = 0, uintptr_t b = 0,
uintptr_t c = 0, uintptr_t d = 0)
{
(void)csc;
(void)a;
(void)b;
(void)c;
(void)d;
KERNEL_DEBUG(((uint32_t)csc) | DBG_FUNC_START, a, b, c, d, 0);
}
static inline void
IOTimeStampEnd(uintptr_t csc,
uintptr_t a = 0, uintptr_t b = 0,
uintptr_t c = 0, uintptr_t d = 0)
{
(void)csc;
(void)a;
(void)b;
(void)c;
(void)d;
KERNEL_DEBUG(((uint32_t)csc) | DBG_FUNC_END, a, b, c, d, 0);
}
static inline void
IOTimeStamp(uintptr_t csc,
uintptr_t a = 0, uintptr_t b = 0,
uintptr_t c = 0, uintptr_t d = 0)
{
(void)csc;
(void)a;
(void)b;
(void)c;
(void)d;
KERNEL_DEBUG(((uint32_t)csc) | DBG_FUNC_NONE, a, b, c, d, 0);
}
#endif /* KDEBUG */
#define IODBG_STORAGE(code) (KDBG_CODE(DBG_IOKIT, DBG_IOSTORAGE, code))
#define IODBG_NETWORK(code) (KDBG_CODE(DBG_IOKIT, DBG_IONETWORK, code))
#define IODBG_KEYBOARD(code) (KDBG_CODE(DBG_IOKIT, DBG_IOKEYBOARD, code))
#define IODBG_HID(code) (KDBG_CODE(DBG_IOKIT, DBG_IOHID, code))
#define IODBG_AUDIO(code) (KDBG_CODE(DBG_IOKIT, DBG_IOAUDIO, code))
#define IODBG_SERIAL(code) (KDBG_CODE(DBG_IOKIT, DBG_IOSERIAL, code))
#define IODBG_TTY(code) (KDBG_CODE(DBG_IOKIT, DBG_IOTTY, code))
#define IODBG_SAM(code) (KDBG_CODE(DBG_IOKIT, DBG_IOSAM, code))
#define IODBG_PARALLELATA(code) (KDBG_CODE(DBG_IOKIT, DBG_IOPARALLELATA, code))
#define IODBG_PARALLELSCSI(code) (KDBG_CODE(DBG_IOKIT, DBG_IOPARALLELSCSI, code))
#define IODBG_SATA(code) (KDBG_CODE(DBG_IOKIT, DBG_IOSATA, code))
#define IODBG_SAS(code) (KDBG_CODE(DBG_IOKIT, DBG_IOSAS, code))
#define IODBG_FIBRECHANNEL(code) (KDBG_CODE(DBG_IOKIT, DBG_IOFIBRECHANNEL, code))
#define IODBG_USB(code) (KDBG_CODE(DBG_IOKIT, DBG_IOUSB, code))
#define IODBG_BLUETOOTH(code) (KDBG_CODE(DBG_IOKIT, DBG_IOBLUETOOTH, code))
#define IODBG_FIREWIRE(code) (KDBG_CODE(DBG_IOKIT, DBG_IOFIREWIRE, code))
#define IODBG_INFINIBAND(code) (KDBG_CODE(DBG_IOKIT, DBG_IOINFINIBAND, code))
/* Backwards compatibility */
#define IODBG_DISK(code) IODBG_STORAGE(code)
#define IODBG_POINTING(code) IODBG_HID(code)
/* IOKit infrastructure subclasses */
#define IODBG_INTC(code) (KDBG_CODE(DBG_IOKIT, DBG_IOINTC, code))
#define IODBG_WORKLOOP(code) (KDBG_CODE(DBG_IOKIT, DBG_IOWORKLOOP, code))
#define IODBG_INTES(code) (KDBG_CODE(DBG_IOKIT, DBG_IOINTES, code))
#define IODBG_TIMES(code) (KDBG_CODE(DBG_IOKIT, DBG_IOCLKES, code))
#define IODBG_CMDQ(code) (KDBG_CODE(DBG_IOKIT, DBG_IOCMDQ, code))
#define IODBG_MCURS(code) (KDBG_CODE(DBG_IOKIT, DBG_IOMCURS, code))
#define IODBG_MDESC(code) (KDBG_CODE(DBG_IOKIT, DBG_IOMDESC, code))
#define IODBG_POWER(code) (KDBG_CODE(DBG_IOKIT, DBG_IOPOWER, code))
#define IODBG_IOSERVICE(code) (KDBG_CODE(DBG_IOKIT, DBG_IOSERVICE, code))
#define IODBG_IOREGISTRY(code) (KDBG_CODE(DBG_IOKIT, DBG_IOREGISTRY, code))
#define IODBG_IOMDPA(code) (KDBG_CODE(DBG_IOKIT, DBG_IOMDPA, code))
/* IOKit specific codes - within each subclass */
/* DBG_IOKIT/DBG_IODISK codes */
/* DBG_IOKIT/DBG_IONETWORK codes */
/* DBG_IOKIT/DBG_IOKEYBOARD codes */
/* DBG_IOKIT/DBG_IOHID codes */
/* DBG_IOKIT/DBG_IOAUDIO codes */
/* DBG_IOKIT/DBG_IOSERIAL codes */
/* DBG_IOKIT/DBG_IOTTY codes */
/* DBG_IOKIT/DBG_IOINTC codes */
#define IOINTC_HANDLER 1 /* 0x05000004 */
#define IOINTC_SPURIOUS 2 /* 0x05000008 */
/* DBG_IOKIT/DBG_IOWORKLOOP codes */
#define IOWL_CLIENT 1 /* 0x05010004 */
#define IOWL_WORK 2 /* 0x05010008 */
/* DBG_IOKIT/DBG_IOINTES codes */
#define IOINTES_CLIENT 1 /* 0x05020004 */
#define IOINTES_LAT 2 /* 0x05020008 */
#define IOINTES_SEMA 3 /* 0x0502000c */
#define IOINTES_INTCTXT 4 /* 0x05020010 */
#define IOINTES_INTFLTR 5 /* 0x05020014 */
#define IOINTES_ACTION 6 /* 0x05020018 */
#define IOINTES_FILTER 7 /* 0x0502001c */
/* DBG_IOKIT/DBG_IOTIMES codes */
#define IOTIMES_CLIENT 1 /* 0x05030004 */
#define IOTIMES_LAT 2 /* 0x05030008 */
#define IOTIMES_SEMA 3 /* 0x0503000c */
#define IOTIMES_ACTION 4 /* 0x05030010 */
/* DBG_IOKIT/DBG_IOCMDQ codes */
#define IOCMDQ_CLIENT 1 /* 0x05040004 */
#define IOCMDQ_LAT 2 /* 0x05040008 */
#define IOCMDQ_SEMA 3 /* 0x0504000c */
#define IOCMDQ_PSEMA 4 /* 0x05040010 */
#define IOCMDQ_PLOCK 5 /* 0x05040014 */
#define IOCMDQ_ACTION 6 /* 0x05040018 */
/* DBG_IOKIT/DBG_IOMCURS codes */
/* DBG_IOKIT/DBG_IOMDESC codes */
#define IOMDESC_WIRE 1 /* 0x05060004 */
#define IOMDESC_PREPARE 2 /* 0x05060008 */
#define IOMDESC_MAP 3 /* 0x0506000C */
#define IOMDESC_UNMAP 4 /* 0x05060010 */
#define IOMDESC_DMA_MAP 5 /* 0x05060014 */
#define IOMDESC_DMA_UNMAP 6 /* 0x05060018 */
#define IOMDESC_COMPLETE 7 /* 0x0506001C */
/* DBG_IOKIT/DBG_IOMDPA */
#define IOMDPA_MAPPED 1 /* 0x05410004 */
#define IOMDPA_UNMAPPED 2 /* 0x05410008 */
#define IOMDPA_SEGMENTS_PAGE 3 /* 0x0541000C */
#define IOMDPA_SEGMENTS_LONG 4 /* 0x05410010 */
/* DBG_IOKIT/DBG_IOPOWER codes */
// See IOKit/pwr_mgt/IOPMlog.h for the power management codes
/* DBG_IOKIT/DBG_IOSERVICE codes */
#define IOSERVICE_BUSY 1 /* 0x05080004 */
#define IOSERVICE_NONBUSY 2 /* 0x05080008 */
#define IOSERVICE_MODULESTALL 3 /* 0x0508000C */
#define IOSERVICE_MODULEUNSTALL 4 /* 0x05080010 */
#define IOSERVICE_TERMINATE_PHASE1 5 /* 0x05080014 */
#define IOSERVICE_TERMINATE_REQUEST_OK 6 /* 0x05080018 */
#define IOSERVICE_TERMINATE_REQUEST_FAIL 7 /* 0x0508001C */
#define IOSERVICE_TERMINATE_SCHEDULE_STOP 8 /* 0x05080020 */
#define IOSERVICE_TERMINATE_SCHEDULE_FINALIZE 9 /* 0x05080024 */
#define IOSERVICE_TERMINATE_WILL 10 /* 0x05080028 */
#define IOSERVICE_TERMINATE_DID 11 /* 0x0508002C */
#define IOSERVICE_TERMINATE_DID_DEFER 12 /* 0x05080030 */
#define IOSERVICE_TERMINATE_FINALIZE 13 /* 0x05080034 */
#define IOSERVICE_TERMINATE_STOP 14 /* 0x05080038 */
#define IOSERVICE_TERMINATE_STOP_NOP 15 /* 0x0508003C */
#define IOSERVICE_TERMINATE_STOP_DEFER 16 /* 0x05080040 */
#define IOSERVICE_TERMINATE_DONE 17 /* 0x05080044 */
#define IOSERVICE_KEXTD_ALIVE 18 /* 0x05080048 */
#define IOSERVICE_KEXTD_READY 19 /* 0x0508004C */
#define IOSERVICE_REGISTRY_QUIET 20 /* 0x05080050 */
#define IOSERVICE_TERM_SET_INACTIVE 21 /* 0x05080054 */
#define IOSERVICE_TERM_SCHED_PHASE2 22 /* 0x05080058 */
#define IOSERVICE_TERM_START_PHASE2 23 /* 0x0508005C */
#define IOSERVICE_TERM_TRY_PHASE2 24 /* 0x05080060 */
#define IOSERVICE_TERM_UC_DEFER 25 /* 0x05080064 */
#define IOSERVICE_DETACH 26 /* 0x05080068 */
/* DBG_IOKIT/DBG_IOREGISTRY codes */
#define IOREGISTRYENTRY_NAME_STRING 1 /* 0x05090004 */
#define IOREGISTRYENTRY_NAME 2 /* 0x05090008 */
#endif /* ! IOKIT_IOTIMESTAMP_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOPlatformExpert.h | /*
* Copyright (c) 1998-2019 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* Copyright (c) 1998 Apple Computer, Inc. All rights reserved.
*
* HISTORY
*
*/
#ifndef _IOKIT_IOPLATFORMEXPERT_H
#define _IOKIT_IOPLATFORMEXPERT_H
#ifdef __cplusplus
#include <IOKit/IOLib.h>
#include <IOKit/IOService.h>
#include <IOKit/IOInterrupts.h>
#include <IOKit/IOInterruptController.h>
#include <libkern/c++/OSPtr.h>
extern "C" {
#else
#include <kern/clock.h>
#endif
#include <libkern/OSTypes.h>
typedef enum {
kCoprocessorVersionNone = 0x00000000,
kCoprocessorVersion1 = 0x00010000,
kCoprocessorVersion2 = 0x00020000,
} coprocessor_type_t;
/*
* PEGetMachineName() and PEGetModelName() are inconsistent across
* architectures, and considered deprecated.
* PEGetTargetName() and PEGetProductName() instead.
*/
extern boolean_t PEGetMachineName( char * name, int maxLength );
extern boolean_t PEGetModelName( char * name, int maxLength );
extern boolean_t PEGetTargetName( char * name, int maxLength );
extern boolean_t PEGetProductName( char * name, int maxLength );
extern int PEGetPlatformEpoch( void );
enum {
kPEHaltCPU,
kPERestartCPU,
kPEHangCPU,
kPEUPSDelayHaltCPU,
kPEPanicRestartCPU,
kPEPanicSync,
kPEPagingOff,
kPEPanicBegin,
kPEPanicEnd,
kPEPanicRestartCPUNoCallouts,
kPEPanicDiagnosticsDone,
kPEPanicDiagnosticsInProgress,
};
/* Bitmask of details related to panic callouts */
#define kPanicDetailsForcePowerOff 0x1
extern int (*PE_halt_restart)(unsigned int type);
extern int PEHaltRestart(unsigned int type);
// Save the Panic Info. Returns the number of bytes saved.
extern UInt32 PESavePanicInfo(UInt8 *buffer, UInt32 length);
extern void PESavePanicInfoAction(void *buffer, UInt32 offset, UInt32 length);
/*
* SMC requires that all data is flushed in multiples of 16 bytes at 16 byte
* boundaries.
*/
#define PANIC_FLUSH_BOUNDARY 16
extern long PEGetGMTTimeOfDay( void );
extern void PESetGMTTimeOfDay( long secs );
extern void PEGetUTCTimeOfDay( clock_sec_t * secs, clock_usec_t * usecs );
extern void PESetUTCTimeOfDay( clock_sec_t secs, clock_usec_t usecs );
/* unless it's a "well-known" property, these will read/write out the value as raw data */
extern boolean_t PEWriteNVRAMBooleanProperty(const char *symbol, boolean_t value);
extern boolean_t PEWriteNVRAMProperty(const char *symbol, const void *value, const unsigned int len);
extern boolean_t PEWriteNVRAMPropertyWithCopy(const char *symbol, const void *value, const unsigned int len);
extern boolean_t PEReadNVRAMProperty(const char *symbol, void *value, unsigned int *len);
extern boolean_t PERemoveNVRAMProperty(const char *symbol);
extern coprocessor_type_t PEGetCoprocessorVersion( void );
#ifdef __cplusplus
} /* extern "C" */
#define kIOPlatformMapperPresentKey "IOPlatformMapperPresent"
extern OSSymbol * gPlatformInterruptControllerName;
/*
* IOPlatformSleepAction
*
* Sleep is called after power management has finished all of the power plane
* driver power management notifications and state transitions and has
* committed to sleep, but before the other CPUs are powered off.
* The scheduler is still active.
*/
extern const OSSymbol *gIOPlatformSleepActionKey;
/*
* IOPlatformWakeAction
*
* Wake is called with the scheduler enabled, but before
* powering on other CPUs, so try to minimize work done in this path to speed
* up wake time.
*/
extern const OSSymbol *gIOPlatformWakeActionKey;
/*
* IOPlatformQuiesceAction
*
* Quiesce is called after all CPUs are off, scheduling is disabled,
* and the boot CPU is about to pull the plug.
* Mutexes and blocking are disallowed in this context and will panic.
* Do not pass this action to super() (incl. IOService, IOPlatformExpert)
*/
extern const OSSymbol *gIOPlatformQuiesceActionKey;
/*
* IOPlatformActiveAction
*
* Active is called very early in the wake path before enabling the scheduler
* on the boot CPU.
* Mutexes and blocking are disallowed in this context and will panic.
* Do not pass this action to super() (incl. IOService, IOPlatformExpert)
*/
extern const OSSymbol *gIOPlatformActiveActionKey;
/*
* IOPlatformHaltRestartAction
*
* Halt/Restart is called after the kernel finishes shutting down the
* system and is ready to power off or reboot.
*
* It is not guaranteed to be called in non-graceful shutdown scenarios.
*/
extern const OSSymbol *gIOPlatformHaltRestartActionKey;
/*
* IOPlatformPanicAction
*
* Panic is called when the system is panicking before it records a core file
* (if it is configured to do so)
*
* It can be called at any time, in any context, in any state. Don't depend
* on anything being powered on in a useful state.
*
* Mutexes and blocking are disallowed in this context and will fail.
*
* If you hang or panic again in this callout, the panic log may not be recorded,
* leading to the loss of field reports about customer issues.
*/
extern const OSSymbol *gIOPlatformPanicActionKey;
class IORangeAllocator;
class IONVRAMController;
class IOPMrootDomain;
class IOPlatformExpert : public IOService
{
OSDeclareDefaultStructors(IOPlatformExpert);
private:
long _peBootROMType;
long _peChipSetType;
long _peMachineType;
protected:
IOPMrootDomain * root;
int _pePMFeatures;
int _pePrivPMFeatures;
int _peNumBatteriesSupported;
OSArray * thePowerTree;
bool searchingForAdditionalParents;
OSNumber * multipleParentKeyValue;
int numInstancesRegistered;
struct ExpansionData { };
ExpansionData *iope_reserved __unused;
virtual void setBootROMType(long peBootROMType);
virtual void setChipSetType(long peChipSetType);
virtual void setMachineType(long peMachineType);
virtual bool CheckSubTree(OSArray * inSubTree, IOService * theNub, IOService * theDevice, OSDictionary * theParent);
virtual bool RegisterServiceInTree(IOService * theService, OSDictionary * theTreeNode, OSDictionary * theTreeParentNode, IOService * theProvider);
virtual void PMInstantiatePowerDomains( void );
public:
virtual bool attach( IOService * provider ) APPLE_KEXT_OVERRIDE;
virtual bool start( IOService * provider ) APPLE_KEXT_OVERRIDE;
virtual bool configure( IOService * provider );
virtual IOService * createNub( OSDictionary * from );
virtual bool compareNubName( const IOService * nub, OSString * name,
OSString ** matched = NULL ) const;
bool compareNubName( const IOService * nub, OSString * name,
OSSharedPtr<OSString>& matched ) const;
virtual IOReturn getNubResources( IOService * nub );
virtual long getBootROMType(void);
virtual long getChipSetType(void);
virtual long getMachineType(void);
/*
* getModelName() and getMachineName() are deprecated for direct
* use. Use getTargetName() and getProductName() instead.
*/
virtual bool getModelName( char * name, int maxLength );
virtual bool getMachineName( char * name, int maxLength );
virtual int haltRestart(unsigned int type);
virtual void sleepKernel(void);
virtual long getGMTTimeOfDay( void );
virtual void setGMTTimeOfDay( long secs );
virtual IOReturn getConsoleInfo( PE_Video * consoleInfo );
virtual IOReturn setConsoleInfo( PE_Video * consoleInfo, unsigned int op );
virtual void registerNVRAMController( IONVRAMController * nvram );
virtual IOReturn registerInterruptController(OSSymbol *name, IOInterruptController *interruptController);
virtual LIBKERN_RETURNS_NOT_RETAINED IOInterruptController *
lookUpInterruptController(OSSymbol *name);
virtual void setCPUInterruptProperties(IOService *service);
virtual bool atInterruptLevel(void);
virtual IOReturn callPlatformFunction(const OSSymbol *functionName,
bool waitForFunction,
void *param1, void *param2,
void *param3, void *param4) APPLE_KEXT_OVERRIDE;
virtual IORangeAllocator * getPhysicalRangeAllocator(void);
virtual bool platformAdjustService(IOService *service);
virtual void PMRegisterDevice(IOService * theNub, IOService * theDevice);
virtual void PMLog( const char *, unsigned long, unsigned long, unsigned long );
virtual bool hasPMFeature(unsigned long featureMask);
virtual bool hasPrivPMFeature(unsigned long privFeatureMask);
virtual int numBatteriesSupported(void);
virtual IOByteCount savePanicInfo(UInt8 *buffer, IOByteCount length);
virtual OSString* createSystemSerialNumberString(OSData* myProperty);
virtual IOReturn deregisterInterruptController(OSSymbol *name);
virtual void getUTCTimeOfDay( clock_sec_t * secs, clock_nsec_t * nsecs );
virtual void setUTCTimeOfDay( clock_sec_t secs, clock_nsec_t nsecs );
void publishPlatformUUIDAndSerial( void );
void publishNVRAM( void );
virtual bool getTargetName( char * name, int maxLength );
virtual bool getProductName( char * name, int maxLength );
OSMetaClassDeclareReservedUsedX86(IOPlatformExpert, 0);
OSMetaClassDeclareReservedUsedX86(IOPlatformExpert, 1);
OSMetaClassDeclareReservedUsedX86(IOPlatformExpert, 2);
OSMetaClassDeclareReservedUsedX86(IOPlatformExpert, 3);
OSMetaClassDeclareReservedUsedX86(IOPlatformExpert, 4);
OSMetaClassDeclareReservedUsedX86(IOPlatformExpert, 5);
OSMetaClassDeclareReservedUsedX86(IOPlatformExpert, 6);
OSMetaClassDeclareReservedUnused(IOPlatformExpert, 7);
OSMetaClassDeclareReservedUnused(IOPlatformExpert, 8);
OSMetaClassDeclareReservedUnused(IOPlatformExpert, 9);
OSMetaClassDeclareReservedUnused(IOPlatformExpert, 10);
OSMetaClassDeclareReservedUnused(IOPlatformExpert, 11);
};
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
class IODTNVRAM;
class IODTPlatformExpert : public IOPlatformExpert
{
OSDeclareAbstractStructors(IODTPlatformExpert);
private:
IODTNVRAM *dtNVRAM;
struct ExpansionData { };
ExpansionData *iodtpe_reserved;
public:
virtual IOService * probe( IOService * provider,
SInt32 * score ) APPLE_KEXT_OVERRIDE;
virtual bool configure( IOService * provider ) APPLE_KEXT_OVERRIDE;
virtual void processTopLevel( IORegistryEntry * root );
virtual const char * deleteList( void ) = 0;
virtual const char * excludeList( void ) = 0;
virtual IOService * createNub( IORegistryEntry * from );
virtual bool createNubs( IOService * parent, LIBKERN_CONSUMED OSIterator * iter );
virtual bool compareNubName( const IOService * nub, OSString * name,
OSString ** matched = NULL ) const APPLE_KEXT_OVERRIDE;
virtual IOReturn getNubResources( IOService * nub ) APPLE_KEXT_OVERRIDE;
/*
* getModelName() and getMachineName() are deprecated. Use
* getTargetName() and getProductName() instead.
*/
virtual bool getModelName( char * name, int maxLength ) APPLE_KEXT_OVERRIDE;
virtual bool getMachineName( char * name, int maxLength ) APPLE_KEXT_OVERRIDE;
virtual bool getTargetName( char * name, int maxLength ) APPLE_KEXT_OVERRIDE;
virtual bool getProductName( char * name, int maxLength ) APPLE_KEXT_OVERRIDE;
virtual void registerNVRAMController( IONVRAMController * nvram ) APPLE_KEXT_OVERRIDE;
virtual int haltRestart(unsigned int type) APPLE_KEXT_OVERRIDE;
/* virtual */ IOReturn readXPRAM(IOByteCount offset, UInt8 * buffer,
IOByteCount length);
/* virtual */ IOReturn writeXPRAM(IOByteCount offset, UInt8 * buffer,
IOByteCount length);
virtual IOReturn readNVRAMProperty(
IORegistryEntry * entry,
const OSSymbol ** name, OSData ** value );
IOReturn readNVRAMProperty(
IORegistryEntry * entry,
OSSharedPtr<const OSSymbol>& name, OSSharedPtr<OSData>& value );
virtual IOReturn writeNVRAMProperty(
IORegistryEntry * entry,
const OSSymbol * name, OSData * value );
// This returns a dictionary describing all the NVRAM partitions.
// The keys will be the partitionIDs of the form "0x52,nvram".
// The values will be OSNumbers of the partition's byte count.
/* virtual */ OSDictionary *getNVRAMPartitions(void);
/* virtual */ IOReturn readNVRAMPartition(const OSSymbol * partitionID,
IOByteCount offset, UInt8 * buffer,
IOByteCount length);
/* virtual */ IOReturn writeNVRAMPartition(const OSSymbol * partitionID,
IOByteCount offset, UInt8 * buffer,
IOByteCount length);
virtual IOByteCount savePanicInfo(UInt8 *buffer, IOByteCount length) APPLE_KEXT_OVERRIDE;
virtual OSString* createSystemSerialNumberString(OSData* myProperty) APPLE_KEXT_OVERRIDE;
OSMetaClassDeclareReservedUnused(IODTPlatformExpert, 0);
OSMetaClassDeclareReservedUnused(IODTPlatformExpert, 1);
OSMetaClassDeclareReservedUnused(IODTPlatformExpert, 2);
OSMetaClassDeclareReservedUnused(IODTPlatformExpert, 3);
OSMetaClassDeclareReservedUnused(IODTPlatformExpert, 4);
OSMetaClassDeclareReservedUnused(IODTPlatformExpert, 5);
OSMetaClassDeclareReservedUnused(IODTPlatformExpert, 6);
OSMetaClassDeclareReservedUnused(IODTPlatformExpert, 7);
};
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* generic root nub of service tree */
class IOPlatformExpertDevice : public IOService
{
OSDeclareDefaultStructors(IOPlatformExpertDevice);
private:
IOWorkLoop *workLoop;
struct ExpansionData { };
ExpansionData *ioped_reserved __unused;
public:
virtual bool init(void *dtRoot);
virtual bool compareName( OSString * name, OSString ** matched = NULL ) const APPLE_KEXT_OVERRIDE;
virtual IOWorkLoop *getWorkLoop() const APPLE_KEXT_OVERRIDE;
virtual IOReturn setProperties( OSObject * properties ) APPLE_KEXT_OVERRIDE;
virtual void free() APPLE_KEXT_OVERRIDE;
virtual IOReturn newUserClient( task_t owningTask, void * securityID,
UInt32 type, OSDictionary * properties,
IOUserClient ** handler) APPLE_KEXT_OVERRIDE;
bool startIOServiceMatching(void);
void createNVRAM(void);
void generatePlatformUUID(void);
void configureDefaults(void);
OSMetaClassDeclareReservedUnused(IOPlatformExpertDevice, 0);
OSMetaClassDeclareReservedUnused(IOPlatformExpertDevice, 1);
OSMetaClassDeclareReservedUnused(IOPlatformExpertDevice, 2);
OSMetaClassDeclareReservedUnused(IOPlatformExpertDevice, 3);
};
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* generic nub for motherboard devices */
class IOPlatformDevice : public IOService
{
OSDeclareDefaultStructors(IOPlatformDevice);
struct ExpansionData { };
ExpansionData *iopd_reserved;
public:
virtual bool compareName( OSString * name, OSString ** matched = NULL ) const APPLE_KEXT_OVERRIDE;
virtual IOService * matchLocation( IOService * client ) APPLE_KEXT_OVERRIDE;
virtual IOReturn getResources( void ) APPLE_KEXT_OVERRIDE;
OSMetaClassDeclareReservedUnused(IOPlatformDevice, 0);
OSMetaClassDeclareReservedUnused(IOPlatformDevice, 1);
OSMetaClassDeclareReservedUnused(IOPlatformDevice, 2);
OSMetaClassDeclareReservedUnused(IOPlatformDevice, 3);
};
#endif /* __cplusplus */
#endif /* ! _IOKIT_IOPLATFORMEXPERT_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOSharedLock.h | /*
* Copyright (c) 1998-2010 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _IOKIT_IOSHAREDLOCK_H
#define _IOKIT_IOSHAREDLOCK_H
#include <libkern/OSAtomic.h>
#define IOSharedLockData OSSpinLock
#define ev_lock_data_t OSSpinLock
#define ev_unlock(l) OSSpinLockUnlock(l)
#define ev_try_lock(l) OSSpinLockTry(l)
#endif /* ! _IOKIT_IOSHAREDLOCK_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOKitKeys.h | /*
* Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
*
* Common symbol definitions for IOKit.
*
* HISTORY
*
*/
#ifndef _IOKIT_IOKITKEYS_H
#define _IOKIT_IOKITKEYS_H
// properties found in the registry root
#define kIOKitBuildVersionKey "IOKitBuildVersion"
#define kIOKitDiagnosticsKey "IOKitDiagnostics"
// a dictionary keyed by plane name
#define kIORegistryPlanesKey "IORegistryPlanes"
#define kIOCatalogueKey "IOCatalogue"
// registry plane names
#define kIOServicePlane "IOService"
#define kIOPowerPlane "IOPower"
#define kIODeviceTreePlane "IODeviceTree"
#define kIOAudioPlane "IOAudio"
#define kIOFireWirePlane "IOFireWire"
#define kIOUSBPlane "IOUSB"
// registry ID number
#define kIORegistryEntryIDKey "IORegistryEntryID"
// property name to get array of property names
#define kIORegistryEntryPropertyKeysKey "IORegistryEntryPropertyKeys"
// IOService class name
#define kIOServiceClass "IOService"
// IOResources class name
#define kIOResourcesClass "IOResources"
// IOService driver probing property names
#define kIOClassKey "IOClass"
#define kIOProbeScoreKey "IOProbeScore"
#define kIOKitDebugKey "IOKitDebug"
// Properties to be supported as API
#define kIOSupportedPropertiesKey "IOSupportedProperties"
// Properties writable by dexts
#define kIOUserServicePropertiesKey "IOUserServiceProperties"
// IOService matching property names
#define kIOProviderClassKey "IOProviderClass"
#define kIONameMatchKey "IONameMatch"
#define kIOPropertyMatchKey "IOPropertyMatch"
#define kIOPropertyExistsMatchKey "IOPropertyExistsMatch"
#define kIOPathMatchKey "IOPathMatch"
#define kIOLocationMatchKey "IOLocationMatch"
#define kIOParentMatchKey "IOParentMatch"
#define kIOResourceMatchKey "IOResourceMatch"
#define kIOResourceMatchedKey "IOResourceMatched"
#define kIOMatchedServiceCountKey "IOMatchedServiceCountMatch"
#define kIONameMatchedKey "IONameMatched"
#define kIOMatchCategoryKey "IOMatchCategory"
#define kIODefaultMatchCategoryKey "IODefaultMatchCategory"
#define kIOMatchedPersonalityKey "IOMatchedPersonality"
#define kIORematchPersonalityKey "IORematchPersonality"
#define kIORematchCountKey "IORematchCount"
#define kIODEXTMatchCountKey "IODEXTMatchCount"
// Entitlements to check against dext process
// Property is an array, one or more of which may match, of:
// an array of entitlement strings, all must be present
// Any array can be a single string.
#define kIOServiceDEXTEntitlementsKey "IOServiceDEXTEntitlements"
// Entitlement required to open dext connection
#define kIODriverKitEntitlementKey "com.apple.developer.driverkit"
// Entitlements required to open dext IOUserClient
// Property is an array of strings containing CFBundleIdentifiers of service being opened
#define kIODriverKitUserClientEntitlementsKey "com.apple.developer.driverkit.userclient-access"
// Allows the entitled process to open a user client connection to any dext that has specific entitlements
// Property is an array of strings containing entitlements, one of which needs to be present
// in the dext providing the user client being opened
#define kIODriverKitRequiredEntitlementsKey "com.apple.private.driverkit.driver-access"
// Entitlement of a dext that allows any task to open one of its IOUserClients
#define kIODriverKitUserClientEntitlementAllowAnyKey "com.apple.developer.driverkit.allow-any-userclient-access"
#define kIODriverKitUserClientEntitlementAdministratorKey "com.apple.developer.driverkit.administrator"
// Other DriverKit entitlements
#define kIODriverKitUSBTransportEntitlementKey "com.apple.developer.driverkit.transport.usb"
#define kIODriverKitHIDTransportEntitlementKey "com.apple.developer.driverkit.transport.hid"
#define kIODriverKitHIDFamilyDeviceEntitlementKey "com.apple.developer.driverkit.family.hid.device"
#define kIODriverKitHIDFamilyEventServiceEntitlementKey "com.apple.developer.driverkit.family.hid.eventservice"
#define kIODriverKitTransportBuiltinEntitlementKey "com.apple.developer.driverkit.builtin"
// Entitlement required to read nvram root-only properties as non-root user
#define kIONVRAMReadAccessKey "com.apple.private.iokit.nvram-read-access"
// Entitlement required to write nvram properties as non-root user
#define kIONVRAMWriteAccessKey "com.apple.private.iokit.nvram-write-access"
// Entitlement required to set properties on the IOResources object as non-root user
#define kIOResourcesSetPropertyKey "com.apple.private.iokit.ioresources.setproperty"
// Entitlement required to read/write to the system nvram region
#define kIONVRAMSystemAllowKey "com.apple.private.iokit.system-nvram-allow"
// When possible, defer matching of this driver until kextd has started.
#define kIOMatchDeferKey "IOMatchDefer"
// Published after processor_start() has been called on all CPUs at boot time.
#define kIOAllCPUInitializedKey "IOAllCPUInitialized"
// IOService default user client class, for loadable user clients
#define kIOUserClientClassKey "IOUserClientClass"
// key to find IOMappers
#define kIOMapperIDKey "IOMapperID"
#define kIOUserClientCrossEndianKey "IOUserClientCrossEndian"
#define kIOUserClientCrossEndianCompatibleKey "IOUserClientCrossEndianCompatible"
#define kIOUserClientSharedInstanceKey "IOUserClientSharedInstance"
#define kIOUserClientDefaultLockingKey "IOUserClientDefaultLocking"
// diagnostic string describing the creating task
#define kIOUserClientCreatorKey "IOUserClientCreator"
// the expected cdhash value of the userspace driver executable
#define kIOUserServerCDHashKey "IOUserServerCDHash"
#define kIOUserUserClientKey "IOUserUserClient"
#define kIOUserServerOneProcessKey "IOUserServerOneProcess"
// IOService notification types
#define kIOPublishNotification "IOServicePublish"
#define kIOFirstPublishNotification "IOServiceFirstPublish"
#define kIOMatchedNotification "IOServiceMatched"
#define kIOFirstMatchNotification "IOServiceFirstMatch"
#define kIOTerminatedNotification "IOServiceTerminate"
#define kIOWillTerminateNotification "IOServiceWillTerminate"
// IOService interest notification types
#define kIOGeneralInterest "IOGeneralInterest"
#define kIOBusyInterest "IOBusyInterest"
#define kIOAppPowerStateInterest "IOAppPowerStateInterest"
#define kIOPriorityPowerStateInterest "IOPriorityPowerStateInterest"
#define kIOPlatformDeviceMessageKey "IOPlatformDeviceMessage"
// IOService interest notification types
#define kIOCFPlugInTypesKey "IOCFPlugInTypes"
#define kIOCompatibilityMatchKey "IOCompatibilityMatch"
#define kIOCompatibilityPropertiesKey "IOCompatibilityProperties"
#define kIOPathKey "IOPath"
// properties found in services that implement command pooling
#define kIOCommandPoolSizeKey "IOCommandPoolSize" // (OSNumber)
// properties found in services that implement priority
#define kIOMaximumPriorityCountKey "IOMaximumPriorityCount" // (OSNumber)
// properties found in services that have transfer constraints
#define kIOMaximumBlockCountReadKey "IOMaximumBlockCountRead" // (OSNumber)
#define kIOMaximumBlockCountWriteKey "IOMaximumBlockCountWrite" // (OSNumber)
#define kIOMaximumByteCountReadKey "IOMaximumByteCountRead" // (OSNumber)
#define kIOMaximumByteCountWriteKey "IOMaximumByteCountWrite" // (OSNumber)
#define kIOMaximumSegmentCountReadKey "IOMaximumSegmentCountRead" // (OSNumber)
#define kIOMaximumSegmentCountWriteKey "IOMaximumSegmentCountWrite" // (OSNumber)
#define kIOMaximumSegmentByteCountReadKey "IOMaximumSegmentByteCountRead" // (OSNumber)
#define kIOMaximumSegmentByteCountWriteKey "IOMaximumSegmentByteCountWrite" // (OSNumber)
#define kIOMinimumSegmentAlignmentByteCountKey "IOMinimumSegmentAlignmentByteCount" // (OSNumber)
#define kIOMaximumSegmentAddressableBitCountKey "IOMaximumSegmentAddressableBitCount" // (OSNumber)
#define kIOMinimumSaturationByteCountKey "IOMinimumSaturationByteCount" // (OSNumber)
#define kIOMaximumSwapWriteKey "IOMaximumSwapWrite" // (OSNumber)
// properties found in services that wish to describe an icon
//
// IOIcon =
// {
// CFBundleIdentifier = "com.example.driver.example";
// IOBundleResourceFile = "example.icns";
// };
//
// where IOBundleResourceFile is the filename of the resource
#define kIOIconKey "IOIcon" // (OSDictionary)
#define kIOBundleResourceFileKey "IOBundleResourceFile" // (OSString)
#define kIOBusBadgeKey "IOBusBadge" // (OSDictionary)
#define kIODeviceIconKey "IODeviceIcon" // (OSDictionary)
// property of root that describes the machine's serial number as a string
#define kIOPlatformSerialNumberKey "IOPlatformSerialNumber" // (OSString)
// property of root that describes the machine's UUID as a string
#define kIOPlatformUUIDKey "IOPlatformUUID" // (OSString)
// IODTNVRAM property keys
#define kIONVRAMBootArgsKey "boot-args"
#define kIONVRAMDeletePropertyKey "IONVRAM-DELETE-PROPERTY"
#define kIONVRAMSyncNowPropertyKey "IONVRAM-SYNCNOW-PROPERTY"
#define kIONVRAMActivateCSRConfigPropertyKey "IONVRAM-ARMCSR-PROPERTY"
#define kIODTNVRAMPanicInfoKey "aapl,panic-info"
// keys for complex boot information
#define kIOBootDeviceKey "IOBootDevice" // dict | array of dicts
#define kIOBootDevicePathKey "IOBootDevicePath" // arch-neutral OSString
#define kIOBootDeviceSizeKey "IOBootDeviceSize" // OSNumber of bytes
// keys for OS Version information
#define kOSBuildVersionKey "OS Build Version"
//
#define kIOStateNotificationItemCreateKey "com.apple.iokit.statenotification.create"
#define kIOStateNotificationItemSetKey "com.apple.iokit.statenotification.set"
#define kIOStateNotificationItemCopyKey "com.apple.iokit.statenotification.copy"
#define kIOStateNotificationNameKey "com.apple.iokit.statenotification.name"
#define kIOStateNotificationEntitlementSetKey "com.apple.iokit.statenotification.entitlement-set"
#define kIOStateNotificationEntitlementGetKey "com.apple.iokit.statenotification.entitlement-get"
//
#define kIOSystemStateClamshellKey "com.apple.iokit.pm.clamshell"
#define kIOSystemStateSleepDescriptionKey "com.apple.iokit.pm.sleepdescription"
#define kIOSystemStateSleepDescriptionReasonKey "com.apple.iokit.pm.sleepreason"
#define kIOSystemStateSleepDescriptionHibernateStateKey "com.apple.iokit.pm.hibernatestate"
#define kIOSystemStateHaltDescriptionKey "com.apple.iokit.pm.haltdescription"
#define kIOSystemStateHaltDescriptionHaltStateKey "com.apple.iokit.pm.haltstate"
#define kIOSystemStatePowerSourceDescriptionKey "com.apple.iokit.pm.powersourcedescription"
#define kIOSystemStatePowerSourceDescriptionACAttachedKey "com.apple.iokit.pm.acattached"
#endif /* ! _IOKIT_IOKITKEYS_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOKitDiagnosticsUserClient.h | /* * Copyright (c) 2019 Apple Inc. All rights reserved. */
#include <IOKit/IOService.h>
#include <IOKit/IOUserClient.h>
class IOKitDiagnosticsClient : public IOUserClient
{
OSDeclareDefaultStructors(IOKitDiagnosticsClient);
public:
static IOUserClient * withTask(task_t owningTask);
virtual IOReturn clientClose(void) APPLE_KEXT_OVERRIDE;
virtual IOReturn setProperties(OSObject * properties) APPLE_KEXT_OVERRIDE;
virtual IOReturn externalMethod(uint32_t selector, IOExternalMethodArguments * args,
IOExternalMethodDispatch * dispatch, OSObject * target, void * reference) APPLE_KEXT_OVERRIDE;
};
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOWorkLoop.h | /*
* Copyright (c) 1998-2019 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef __IOKIT_IOWORKLOOP_H
#define __IOKIT_IOWORKLOOP_H
#include <libkern/c++/OSObject.h>
#include <IOKit/IOReturn.h>
#include <IOKit/IOLib.h>
#include <IOKit/IOLocks.h>
#include <libkern/c++/OSPtr.h>
#include <IOKit/system.h>
#if IOKITSTATS
#include <IOKit/IOStatisticsPrivate.h>
#endif
class IOEventSource;
class IOTimerEventSource;
class IOCommandGate;
/*! @class IOWorkLoop
* @discussion An IOWorkLoop is a thread of control that is intended to be used to provide single threaded access to hardware. This class has no knowledge of the nature and type of the events that it marshals and forwards. When a device driver successfully starts (see IOService::start), it is expected to create the event sources it will need to receive events. Then a work loop is initialized and the events are added to the work loop for monitoring. In general this set up will be automated by the family superclass of the specific device.
* <br><br>
* The thread main method walks the event source linked list and messages each one requesting a work check. At this point each event source is expected to notify its registered owner that the event has occurred. After each event has been walked and each indicates that another loop isn't required (by setting the 'more' flag to false) the thread will go to sleep on a signaling semaphore.
* <br><br>
* When an event source is registered with a work loop it is informed of the semaphore to use to wake up the loop.
*/
class IOWorkLoop : public OSObject
{
OSDeclareDefaultStructors(IOWorkLoop);
public:
/*!
* @typedef Action
* @discussion Type and arguments of callout C function that is used when
* a runCommand is executed by a client. Cast to this type when you want a C++
* member function to be used. Note the arg1 - arg3 parameters are straight pass
* through from the runCommand to the action callout.
* @param target
* Target of the function, can be used as a refcon. Note if a C++ function
* was specified, this parameter is implicitly the first parameter in the target
* member function's parameter list.
* @param arg0 Argument to action from run operation.
* @param arg1 Argument to action from run operation.
* @param arg2 Argument to action from run operation.
* @param arg3 Argument to action from run operation.
*/
typedef IOReturn (*Action)(OSObject *target,
void *arg0, void *arg1,
void *arg2, void *arg3);
#ifdef __BLOCKS__
typedef IOReturn (^ActionBlock)();
#endif /* __BLOCKS__ */
enum {
kPreciousStack = 0x00000001,
kTimeLockPanics = 0x00000002,
};
private:
/*! @function threadMainContinuation
* @abstract Static function that calls the threadMain function.
*/
static void threadMainContinuation(IOWorkLoop *self);
/*! @function eventSourcePerformsWork
* @abstract Checks if the event source passed in overrides checkForWork() to perform any work.
* IOWorkLoop uses this to determine if the event source should be polled in runEventSources() or not.
* @param inEventSource The event source to check.
*/
bool eventSourcePerformsWork(IOEventSource *inEventSource);
/*! @function releaseEventChain
* @abstract Static function that releases the events in a chain and sets
* their work loops to NULL.
*/
static void releaseEventChain(LIBKERN_CONSUMED IOEventSource *eventChain);
protected:
/*! @typedef maintCommandEnum
* @discussion Enumeration of commands that _maintCommand can deal with.
* @constant mAddEvent Used to tag a Remove event source command.
* @constant mRemoveEvent Used to tag a Remove event source command.
*/
typedef enum { mAddEvent, mRemoveEvent } maintCommandEnum;
/*! @var gateLock
* Mutual exclusion lock that is used by close and open Gate functions.
* This is a recursive lock, which allows multiple layers of code to share a single IOWorkLoop without deadlock. This is common in IOKit since threads of execution tend to follow the service plane in the IORegistry, and multiple objects along the call path may acquire the gate for the same (shared) workloop.
*/
IORecursiveLock *gateLock;
/*! @var eventChain
* Pointer to first event source in linked list.
*/
IOEventSource *eventChain;
/*! @var controlG
* Internal control gate to maintain event system.
*/
IOCommandGate *controlG;
/*! @var workToDoLock
* The spin lock that is used to guard the 'workToDo' variable.
*/
IOSimpleLock *workToDoLock;
/*! @var workThread
* Work loop thread.
*/
IOThread workThread;
/*! @var workToDo
* Used to to indicate that an interrupt has fired and needs to be processed.
*/
volatile bool workToDo;
/*! @var loopRestart
* Set if an event chain has been changed and the system has to be rechecked from start. (Internal use only)
*/
bool loopRestart;
/*! @struct ExpansionData
* @discussion This structure will be used to expand the capablilties of the IOWorkLoop in the future.
*/
struct ExpansionData {
IOOptionBits options;
IOEventSource *passiveEventChain;
#if IOKITSTATS
struct IOWorkLoopCounter *counter;
#else
void *iokitstatsReserved;
#endif
uint64_t lockInterval;
uint64_t lockTime;
};
/*! @var reserved
* Reserved for future use. (Internal use only)
*/
ExpansionData *reserved;
/*! @function _maintRequest
* @abstract Synchronous implementation of addEventSource and removeEventSource functions.
* @discussion This function implements the commands as defined in the maintCommandEnum. It can be subclassed but it isn't an external API in the usual sense. A subclass implementation of _maintRequest would be called synchronously with respect to the work loop and it should be implemented in the usual way that an ioctl would be.
* @return kIOReturnUnsupported if the command given is not implemented, kIOReturnSuccess otherwise.
*/
virtual IOReturn _maintRequest(void *command, void *data, void *, void *);
/*! @function free
* @discussion Mandatory free of the object independent of the current retain count. If the work loop is running, this method will not return until the thread has successfully terminated. Each event source in the chain will be released and the working semaphore will be destroyed.
* <br><br>
* If the client has some outstanding requests on an event they will never be informed of completion. If an external thread is blocked on any of the event sources they will be awakened with a KERN_INTERUPTED status.
*/
virtual void free() APPLE_KEXT_OVERRIDE;
/*! @function threadMain
* @discussion Work loop threads main function. This function consists of 3
* loops: the outermost loop is the semaphore clear and wait loop, the middle
* loop terminates when there is no more work, and the inside loop walks the
* event list calling the checkForWork method in each event source. If an
* event source has more work to do, it can set the more flag and the middle
* loop will repeat. When no more work is outstanding the outermost will
* sleep until an event is signalled.
*/
virtual void threadMain();
public:
/*! @function workLoop
* @abstract Factory member function to construct and intialize a work loop.
* @result Returns a workLoop instance if constructed successfully, 0 otherwise.
*/
static OSPtr<IOWorkLoop> workLoop();
/*! @function workLoopWithOptions(IOOptionBits options)
* @abstract Factory member function to constuct and intialize a work loop.
* @param options Options - kPreciousStack to avoid stack deallocation on paging path.
* @result Returns a workLoop instance if constructed successfully, 0 otherwise.
*/
static OSPtr<IOWorkLoop> workLoopWithOptions(IOOptionBits options);
/*! @function init
* @discussion Initializes an instance of the workloop. This method creates and initializes the signaling semaphore, the controller gate lock, and spawns the thread that will continue executing.
* @result Returns true if initialized successfully, false otherwise.
*/
virtual bool init() APPLE_KEXT_OVERRIDE;
/*! @function getThread
* @abstract Gets the workThread.
* @result Returns workThread.
*/
virtual IOThread getThread() const;
/*! @function onThread
* @abstract Is the current execution context on the work thread?
* @result Returns true if IOThreadSelf() == workThread.
*/
virtual bool onThread() const;
/*! @function inGate
* @abstract Is the current execution context holding the work-loop's gate?
* @result Returns true if IOThreadSelf() is gate holder.
*/
virtual bool inGate() const;
/*! @function addEventSource
* @discussion Add an event source to be monitored by the work loop. This function does not return until the work loop has acknowledged the arrival of the new event source. When a new event has been added the threadMain will always restart its loop and check all outstanding events. The event source is retained by the work loop.
* @param newEvent Pointer to IOEventSource subclass to add.
* @result Always returns kIOReturnSuccess.
*/
virtual IOReturn addEventSource(IOEventSource *newEvent);
/*! @function removeEventSource
* @discussion Remove an event source from the work loop. This function does not return until the work loop has acknowledged the removal of the event source. When an event has been removed the threadMain will always restart its loop and check all outstanding events. The event source will be released before return.
* @param toRemove Pointer to IOEventSource subclass to remove.
* @result Returns kIOReturnSuccess if successful, kIOReturnBadArgument if toRemove couldn't be found.
*/
virtual IOReturn removeEventSource(IOEventSource *toRemove);
/*! @function enableAllEventSources
* @abstract Calls enable() in all event sources.
* @discussion For all event sources in eventChain, call enable() function. See IOEventSource::enable().
*/
virtual void enableAllEventSources() const;
/*! @function disableAllEventSources
* @abstract Calls disable() in all event sources.
* @discussion For all event sources in eventChain, call disable() function. See IOEventSource::disable().
*/
virtual void disableAllEventSources() const;
/*! @function enableAllInterrupts
* @abstract Calls enable() in all interrupt event sources.
* @discussion For all event sources (ES) for which OSDynamicCast(IOInterruptEventSource, ES) is valid, in eventChain call enable() function. See IOEventSource::enable().
*/
virtual void enableAllInterrupts() const;
/*! @function disableAllInterrupts
* @abstract Calls disable() in all interrupt event sources.
* @discussion For all event sources (ES) for which OSDynamicCast(IOInterruptEventSource, ES) is valid, in eventChain call disable() function. See IOEventSource::disable().
*/
virtual void disableAllInterrupts() const;
protected:
// Internal APIs used by event sources to control the thread
friend class IOEventSource;
friend class IOTimerEventSource;
friend class IOCommandGate;
#if IOKITSTATS
friend class IOStatistics;
#endif
virtual void signalWorkAvailable();
virtual void openGate();
virtual void closeGate();
virtual bool tryCloseGate();
virtual int sleepGate(void *event, UInt32 interuptibleType);
virtual void wakeupGate(void *event, bool oneThread);
public:
/* methods available in Mac OS X 10.1 or later */
/*! @function runAction
* @abstract Single thread a call to an action with the work-loop.
* @discussion Client function that causes the given action to be called in a single threaded manner. Beware: the work-loop's gate is recursive and runAction can cause direct or indirect re-entrancy. When executing on a client's thread, runAction will sleep until the work-loop's gate opens for execution of client actions, the action is single threaded against all other work-loop event sources.
* @param action Pointer to function to be executed in work-loop context.
* @param arg0 Parameter for action parameter, defaults to 0.
* @param arg1 Parameter for action parameter, defaults to 0.
* @param arg2 Parameter for action parameter, defaults to 0.
* @param arg3 Parameter for action parameter, defaults to 0.
* @result Returns the value of the Action callout.
*/
virtual IOReturn runAction(Action action, OSObject *target,
void *arg0 = NULL, void *arg1 = NULL,
void *arg2 = NULL, void *arg3 = NULL);
#ifdef __BLOCKS__
/*! @function runAction
* @abstract Single thread a call to an action with the work-loop.
* @discussion Client function that causes the given action to be called in a single threaded manner. Beware: the work-loop's gate is recursive and runAction can cause direct or indirect re-entrancy. When executing on a client's thread, runAction will sleep until the work-loop's gate opens for execution of client actions, the action is single threaded against all other work-loop event sources.
* @param action Block to be executed in work-loop context.
* @result Returns the result of the action block.
*/
IOReturn runActionBlock(ActionBlock action);
#endif /* __BLOCKS__ */
/*! @function runEventSources
* @discussion Consists of the inner 2 loops of the threadMain function(qv).
* The outer loop terminates when there is no more work, and the inside loop
* walks the event list calling the checkForWork method in each event source.
* If an event source has more work to do, it can set the more flag and the
* outer loop will repeat.
* <br><br>
* This function can be used to clear a priority inversion between the normal
* workloop thread and multimedia's real time threads. The problem is that
* the interrupt action routine is often held off by high priority threads.
* So if they want to get their data now they will have to call us and ask if
* any data is available. The multi-media user client will arrange for this
* function to be called, which causes any pending interrupts to be processed
* and the completion routines called. By the time the function returns all
* outstanding work will have been completed at the real time threads
* priority.
*
* @result Return false if the work loop is shutting down, true otherwise.
*/
virtual bool runEventSources();
/*! @function setMaximumLockTime
* @discussion For diagnostics use in DEVELOPMENT kernels, set a time interval which if the work loop lock is held for this time or greater, IOWorkLoop will panic or log a backtrace.
* @param interval An absolute time interval, eg. created with clock_interval_to_absolutetime_interval().
* @param options Pass IOWorkLoop::kTimeLockPanics to panic when the time is exceeded, otherwise a log will be generated with OSReportWithBacktrace().
*/
void setMaximumLockTime(uint64_t interval, uint32_t options);
protected:
// Internal APIs used by event sources to control the thread
virtual int sleepGate(void *event, AbsoluteTime deadline, UInt32 interuptibleType);
protected:
#if __LP64__
OSMetaClassDeclareReservedUnused(IOWorkLoop, 0);
OSMetaClassDeclareReservedUnused(IOWorkLoop, 1);
OSMetaClassDeclareReservedUnused(IOWorkLoop, 2);
#else
OSMetaClassDeclareReservedUsedX86(IOWorkLoop, 0);
OSMetaClassDeclareReservedUsedX86(IOWorkLoop, 1);
OSMetaClassDeclareReservedUsedX86(IOWorkLoop, 2);
#endif
OSMetaClassDeclareReservedUnused(IOWorkLoop, 3);
OSMetaClassDeclareReservedUnused(IOWorkLoop, 4);
OSMetaClassDeclareReservedUnused(IOWorkLoop, 5);
OSMetaClassDeclareReservedUnused(IOWorkLoop, 6);
OSMetaClassDeclareReservedUnused(IOWorkLoop, 7);
};
#endif /* !__IOKIT_IOWORKLOOP_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOGuardPageMemoryDescriptor.h | /*
* Copyright (c) 1998-2020 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _IOGUARDPAGEMEMORYDESCRIPTOR_H
#define _IOGUARDPAGEMEMORYDESCRIPTOR_H
#include <IOKit/IOMemoryDescriptor.h>
#include <libkern/c++/OSPtr.h>
/*!
* @class IOGuardPageMemoryDescriptor
* @abstract Provides a memory descriptor that allows for variable size guard regions. Use with
* IOMultiMemoryDescriptor to surround other memory descriptors with guard pages.
*/
class IOGuardPageMemoryDescriptor : public IOGeneralMemoryDescriptor
{
OSDeclareDefaultStructors(IOGuardPageMemoryDescriptor);
protected:
virtual void free() APPLE_KEXT_OVERRIDE;
vm_offset_t _buffer;
vm_size_t _size;
public:
/* @function withSize
* @discussion Create a IOGuardPageMemoryDescriptor with the specified size.
* @param Size of the guard region. This will be rounded up to the nearest multiple of page size.
* @return IOGuardPageMemoryDescriptor instance to be released by the caller, which will free the allocated
* virtual memory region.
*/
static OSPtr<IOGuardPageMemoryDescriptor> withSize(vm_size_t size);
virtual bool initWithSize(vm_size_t size);
private:
virtual IOReturn doMap(vm_map_t addressMap,
IOVirtualAddress * atAddress,
IOOptionBits options,
IOByteCount sourceOffset = 0,
IOByteCount length = 0 ) APPLE_KEXT_OVERRIDE;
};
#endif /* !_IOGUARDPAGEMEMORYDESCRIPTOR_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOSharedDataQueue.h | /*
* Copyright (c) 1998-2019 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _IOKIT_IOSHAREDDATAQUEUE_H
#define _IOKIT_IOSHAREDDATAQUEUE_H
#define DISABLE_DATAQUEUE_WARNING /* IODataQueue is deprecated, please use IOSharedDataQueue instead */
#include <IOKit/IODataQueue.h>
#include <libkern/c++/OSPtr.h>
#undef DISABLE_DATAQUEUE_WARNING
typedef struct _IODataQueueEntry IODataQueueEntry;
/*!
* @class IOSharedDataQueue : public IODataQueue
* @abstract A generic queue designed to pass data both from the kernel to a user process and from a user process to the kernel.
* @discussion The IOSharedDataQueue class is designed to also allow a user process to queue data to kernel code. IOSharedDataQueue objects are designed to be used in a single producer / single consumer situation. As such, there are no locks on the data itself. Because the kernel enqueue and user-space dequeue methods follow a strict set of guidelines, no locks are necessary to maintain the integrity of the data struct.
*
* <br>Each data entry can be variable sized, but the entire size of the queue data region (including overhead for each entry) must be specified up front.
*
* <br>In order for the IODataQueue instance to notify the user process that data is available, a notification mach port must be set. When the queue is empty and a new entry is added, a message is sent to the specified port.
*
* <br>In order to make the data queue memory available to a user process, the method getMemoryDescriptor() must be used to get an IOMemoryDescriptor instance that can be mapped into a user process. Typically, the clientMemoryForType() method on an IOUserClient instance will be used to request the IOMemoryDescriptor and then return it to be mapped into the user process.
*/
class IOSharedDataQueue : public IODataQueue
{
OSDeclareDefaultStructors(IOSharedDataQueue);
struct ExpansionData {
UInt32 queueSize;
};
/*! @var reserved
* Reserved for future use. (Internal use only) */
ExpansionData * _reserved;
protected:
virtual void free() APPLE_KEXT_OVERRIDE;
/*!
* @function getQueueSize
* @abstract Returns the size of the data queue.
* @discussion Use this method to access the size of the data queue. Do not access the value of size directly, as it can get modified from userspace and is not reliable.
* @result Returns the size of the data queue, or zero in case of failure.
*/
UInt32 getQueueSize();
/*!
* @function setQueueSize
* @abstract Stores the value of the size of the data queue.
* @discussion Use this method to store the value of the size of the data queue. Do not access the value of size directly, as it can get modified from userspace and is not reliable.
* @param size The size of the data queue.
* @result Returns true in case of success, false otherwise.
*/
Boolean setQueueSize(UInt32 size);
public:
/*!
* @function withCapacity
* @abstract Static method that creates a new IOSharedDataQueue instance with the capacity specified in the size parameter.
* @discussion The actual size of the entire data queue memory region (to be shared into a user process) is equal to the capacity plus the IODataQueueMemory overhead. This overhead value can be determined from the DATA_QUEUE_MEMORY_HEADER_SIZE macro in <IOKit/IODataQueueShared.h>. The size of the data queue memory region must include space for the overhead of each IODataQueueEntry. This entry overhead can be determined from the DATA_QUEUE_ENTRY_HEADER_SIZE macro in <IOKit/IODataQueueShared.h>.<br> This method allocates a new IODataQueue instance and then calls initWithCapacity() with the given size parameter. If the initWithCapacity() fails, the new instance is released and zero is returned.
* @param size The size of the data queue memory region.
* @result Returns the newly allocated IOSharedDataQueue instance. Zero is returned on failure.
*/
static OSPtr<IOSharedDataQueue> withCapacity(UInt32 size);
/*!
* @function withEntries
* @abstract Static method that creates a new IOSharedDataQueue instance with the specified number of entries of the given size.
* @discussion This method will create a new IOSharedDataQueue instance with enough capacity for numEntries of entrySize. It does account for the IODataQueueEntry overhead for each entry. Note that the numEntries and entrySize are simply used to determine the data region size. They do not actually restrict the size of number of entries that can be added to the queue.<br> This method allocates a new IODataQueue instance and then calls initWithEntries() with the given numEntries and entrySize parameters. If the initWithEntries() fails, the new instance is released and zero is returned.
* @param numEntries Number of entries to allocate space for.
* @param entrySize Size of each entry.
* @result Reeturns the newly allocated IOSharedDataQueue instance. Zero is returned on failure.
*/
static OSPtr<IOSharedDataQueue> withEntries(UInt32 numEntries, UInt32 entrySize);
/*!
* @function initWithCapacity
* @abstract Initializes an IOSharedDataQueue instance with the capacity specified in the size parameter.
* @discussion The actual size of the entire data queue memory region (to be shared into a user process) is equal to the capacity plus the IODataQueueMemory overhead. This overhead value can be determined from the DATA_QUEUE_MEMORY_HEADER_SIZE and DATA_QUEUE_MEMORY_APPENDIX_SIZE macro in <IOKit/IODataQueueShared.h>. The size of the data queue memory region must include space for the overhead of each IODataQueueEntry. This entry overhead can be determined from the DATA_QUEUE_ENTRY_HEADER_SIZE macro in <IOKit/IODataQueueShared.h>.
* @param size The size of the data queue memory region.
* @result Returns true on success and false on failure.
*/
virtual Boolean initWithCapacity(UInt32 size) APPLE_KEXT_OVERRIDE;
/*!
* @function getMemoryDescriptor
* @abstract Returns a memory descriptor covering the IODataQueueMemory region.
* @discussion The IOMemoryDescriptor instance returned by this method is intended to be mapped into a user process. This is the memory region that the IODataQueueClient code operates on.
* @result Returns a newly allocated IOMemoryDescriptor for the IODataQueueMemory region. Returns zero on failure.
*/
virtual OSPtr<IOMemoryDescriptor> getMemoryDescriptor() APPLE_KEXT_OVERRIDE;
/*!
* @function peek
* @abstract Used to peek at the next entry on the queue.
* @discussion This function can be used to look at the next entry which allows the entry to be received without having to copy it with dequeue. In order to do this, call peek to get the entry. Then call dequeue with a NULL data pointer. That will cause the head to be moved to the next entry, but no memory to be copied.
* @result Returns a pointer to the next IODataQueueEntry if one is available. 0 (NULL) is returned if the queue is empty.
*/
virtual IODataQueueEntry * peek();
/*!
* @function dequeue
* @abstract Dequeues the next available entry on the queue and copies it into the given data pointer.
* @discussion This function will dequeue the next available entry on the queue. If a data pointer is provided, it will copy the data into the memory region if there is enough space available as specified in the dataSize parameter. If no data pointer is provided, it will simply move the head value past the current entry.
* @param data A pointer to the data memory region in which to copy the next entry data on the queue. If this parameter is 0 (NULL), it will simply move to the next entry.
* @param dataSize A pointer to the size of the data parameter. On return, this contains the size of the actual entry data - even if the original size was not large enough.
* @result Returns true on success and false on failure. Typically failure means that the queue is empty.
*/
virtual Boolean dequeue(void *data, UInt32 *dataSize);
/*!
* @function enqueue
* @abstract Enqueues a new entry on the queue.
* @discussion This method adds a new data entry of dataSize to the queue. It sets the size parameter of the entry pointed to by the tail value and copies the memory pointed to by the data parameter in place in the queue. Once that is done, it moves the tail to the next available location. When attempting to add a new entry towards the end of the queue and there isn't enough space at the end, it wraps back to the beginning.<br> If the queue is empty when a new entry is added, sendDataAvailableNotification() is called to send a message to the user process that data is now available.
* @param data Pointer to the data to be added to the queue.
* @param dataSize Size of the data pointed to by data.
* @result Returns true on success and false on failure. Typically failure means that the queue is full.
*/
virtual Boolean enqueue(void *data, UInt32 dataSize) APPLE_KEXT_OVERRIDE;
#if APPLE_KEXT_VTABLE_PADDING
OSMetaClassDeclareReservedUnused(IOSharedDataQueue, 0);
OSMetaClassDeclareReservedUnused(IOSharedDataQueue, 1);
OSMetaClassDeclareReservedUnused(IOSharedDataQueue, 2);
OSMetaClassDeclareReservedUnused(IOSharedDataQueue, 3);
OSMetaClassDeclareReservedUnused(IOSharedDataQueue, 4);
OSMetaClassDeclareReservedUnused(IOSharedDataQueue, 5);
OSMetaClassDeclareReservedUnused(IOSharedDataQueue, 6);
OSMetaClassDeclareReservedUnused(IOSharedDataQueue, 7);
#endif
};
#endif /* _IOKIT_IOSHAREDDATAQUEUE_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IODMAController.h | /*
* Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _IOKIT_IODMACONTROLLER_H
#define _IOKIT_IODMACONTROLLER_H
#include <IOKit/IODMACommand.h>
#include <IOKit/IODMAEventSource.h>
#include <IOKit/IOService.h>
#include <libkern/c++/OSPtr.h>
class IODMAEventSource;
class IODMAController : public IOService
{
OSDeclareAbstractStructors(IODMAController);
friend class IODMAEventSource;
private:
IOService *_provider;
OSPtr<const OSSymbol> _dmaControllerName;
protected:
virtual void registerDMAController(IOOptionBits options = 0);
virtual IOReturn initDMAChannel(IOService *provider, IODMAEventSource *dmaES, UInt32 *dmaIndex, UInt32 reqIndex) = 0;
virtual IOReturn startDMACommand(UInt32 dmaIndex, IODMACommand *dmaCommand, IODirection direction,
IOByteCount byteCount = 0, IOByteCount byteOffset = 0) = 0;
virtual IOReturn stopDMACommand(UInt32 dmaIndex, bool flush = false, uint64_t timeout = UINT64_MAX) = 0;
virtual void completeDMACommand(IODMAEventSource *dmaES, IODMACommand *dmaCommand);
virtual void notifyDMACommand(IODMAEventSource *dmaES, IODMACommand *dmaCommand, IOReturn status, IOByteCount actualByteCount, AbsoluteTime timeStamp);
virtual IOReturn queryDMACommand(UInt32 dmaIndex, IODMACommand **dmaCommand, IOByteCount *transferCount, bool waitForIdle = false) = 0;
virtual IOByteCount getFIFODepth(UInt32 dmaIndex, IODirection direction) = 0;
virtual IOReturn setFIFODepth(UInt32 dmaIndex, IOByteCount depth) = 0;
virtual IOByteCount validFIFODepth(UInt32 dmaIndex, IOByteCount depth, IODirection direction) = 0;
virtual IOReturn setFrameSize(UInt32 dmaIndex, UInt8 byteCount) = 0;
virtual IOReturn setDMAConfig(UInt32 dmaIndex, IOService *provider, UInt32 reqIndex) = 0;
virtual bool validDMAConfig(UInt32 dmaIndex, IOService *provider, UInt32 reqIndex) = 0;
public:
static OSPtr<const OSSymbol> createControllerName(UInt32 phandle);
static IODMAController *getController(IOService *provider, UInt32 dmaIndex);
virtual bool start(IOService *provider) APPLE_KEXT_OVERRIDE;
};
#endif /* _IOKIT_IODMACONTROLLER_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOServiceStateNotificationEventSource.h | /*
* Copyright (c) 1998-2019 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _IOKIT_IOSERVICESTATENOTIFICATIONEVENTSOURCE_H
#define _IOKIT_IOSERVICESTATENOTIFICATIONEVENTSOURCE_H
#include <libkern/c++/OSPtr.h>
#include <IOKit/IOEventSource.h>
class IOService;
/*! @class IOServiceStateNotificationEventSource : public IOEventSource
* @abstract Event source for IOService state notification delivery to work-loop based drivers.
* @discussion For use with the IOService.iig IOService::StateNotification* APIs.
*/
class IOServiceStateNotificationEventSource : public IOEventSource
{
OSDeclareDefaultStructors(IOServiceStateNotificationEventSource);
public:
typedef void (^ActionBlock)();
protected:
IOService * fStateNotification;
IOStateNotificationListenerRef fListener;
bool fEnable;
bool fArmed;
/*! @struct ExpansionData
* @discussion This structure will be used to expand the capablilties of the IOWorkLoop in the future.
*/
/*! @var reserved
* Reserved for future use. (Internal use only) */
APPLE_KEXT_WSHADOW_PUSH;
ExpansionData *reserved;
APPLE_KEXT_WSHADOW_POP;
/*! @function free
* @abstract Sub-class implementation of free method, disconnects from the interrupt source. */
virtual void free() APPLE_KEXT_OVERRIDE;
/*! @function checkForWork
* @abstract Pure Virtual member function used by IOWorkLoop for issueing a client calls.
* @discussion This function called when the work-loop is ready to check for any work to do and then to call out the owner/action.
* @result Return true if this function needs to be called again before all its outstanding events have been processed. */
virtual bool checkForWork() APPLE_KEXT_OVERRIDE;
/*! @function setWorkLoop
* @abstract Sub-class implementation of setWorkLoop method. */
virtual void setWorkLoop(IOWorkLoop *inWorkLoop) APPLE_KEXT_OVERRIDE;
public:
/*!
* @brief Create an IOServiceStateNotificationEventSource for notification of IOService state events sent by the StateNotificationSet() api.
* @param service The object hosting state, typically returned by IOService::CopySystemStateNotificationService().
* @param items Array of state item names to be notified about.
* @param action Handler block to be invoked on the event source workloop when the notification fires.
* @return IOServiceStateNotificationEventSource with +1 retain, or NULL on failure.
*/
static OSPtr<IOServiceStateNotificationEventSource>
serviceStateNotificationEventSource(IOService *service,
OSArray * items,
ActionBlock action);
/*! @function enable
* @abstract Enable event source.
* @discussion A subclass implementation is expected to respect the enabled
* state when checkForWork is called. Calling this function will cause the
* work-loop to be signalled so that a checkForWork is performed. */
virtual void enable() APPLE_KEXT_OVERRIDE;
/*! @function disable
* @abstract Disable event source.
* @discussion A subclass implementation is expected to respect the enabled
* state when checkForWork is called. */
virtual void disable() APPLE_KEXT_OVERRIDE;
private:
OSMetaClassDeclareReservedUnused(IOServiceStateNotificationEventSource, 0);
OSMetaClassDeclareReservedUnused(IOServiceStateNotificationEventSource, 1);
OSMetaClassDeclareReservedUnused(IOServiceStateNotificationEventSource, 2);
OSMetaClassDeclareReservedUnused(IOServiceStateNotificationEventSource, 3);
OSMetaClassDeclareReservedUnused(IOServiceStateNotificationEventSource, 4);
OSMetaClassDeclareReservedUnused(IOServiceStateNotificationEventSource, 5);
OSMetaClassDeclareReservedUnused(IOServiceStateNotificationEventSource, 6);
OSMetaClassDeclareReservedUnused(IOServiceStateNotificationEventSource, 7);
};
#endif /* !_IOKIT_IOSERVICESTATENOTIFICATIONEVENTSOURCE_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/PassthruInterruptController.h | /*
* Copyright (c) 2019 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#pragma once
extern "C" {
#include <mach/semaphore.h>
};
#include <IOKit/IOInterruptController.h>
/*!
* @class PassthruInterruptController
* @abstract Trivial IOInterruptController class that passes all IRQs through to a
* "child" driver.
* @discussion Waits for a "child" driver (typically loaded in a kext) to register itself,
* then passes the child driver's IOService pointer back via
* waitForChildController() so that XNU can operate on it directly.
*/
class PassthruInterruptController : public IOInterruptController
{
OSDeclareDefaultStructors(PassthruInterruptController);
public:
virtual bool init(void) APPLE_KEXT_OVERRIDE;
virtual void *waitForChildController(void);
virtual void setCPUInterruptProperties(IOService *service) APPLE_KEXT_OVERRIDE;
virtual IOReturn registerInterrupt(IOService *nub, int source,
void *target,
IOInterruptHandler handler,
void *refCon) APPLE_KEXT_OVERRIDE;
virtual IOReturn getInterruptType(IOService *nub, int source,
int *interruptType) APPLE_KEXT_OVERRIDE;
virtual IOReturn enableInterrupt(IOService *nub, int source) APPLE_KEXT_OVERRIDE;
virtual IOReturn disableInterrupt(IOService *nub, int source) APPLE_KEXT_OVERRIDE;
virtual IOReturn causeInterrupt(IOService *nub, int source) APPLE_KEXT_OVERRIDE;
virtual IOReturn handleInterrupt(void *refCon, IOService *nub,
int source) APPLE_KEXT_OVERRIDE;
virtual void externalInterrupt(void);
protected:
IOInterruptHandler child_handler;
void *child_target;
void *child_refCon;
IOService *child_nub;
semaphore_t child_sentinel;
};
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOMapTypes.h | /*
* Copyright (c) 1998-2021 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef __IOKIT_IOMAPTYPES_H
#define __IOKIT_IOMAPTYPES_H
// IOConnectMapMemory memoryTypes
enum {
kIODefaultMemoryType = 0
};
enum {
kIODefaultCache = 0,
kIOInhibitCache = 1,
kIOWriteThruCache = 2,
kIOCopybackCache = 3,
kIOWriteCombineCache = 4,
kIOCopybackInnerCache = 5,
kIOPostedWrite = 6,
kIORealTimeCache = 7,
kIOPostedReordered = 8,
kIOPostedCombinedReordered = 9,
};
// IOMemory mapping options
enum {
kIOMapAnywhere = 0x00000001,
kIOMapCacheMask = 0x00000f00,
kIOMapCacheShift = 8,
kIOMapDefaultCache = kIODefaultCache << kIOMapCacheShift,
kIOMapInhibitCache = kIOInhibitCache << kIOMapCacheShift,
kIOMapWriteThruCache = kIOWriteThruCache << kIOMapCacheShift,
kIOMapCopybackCache = kIOCopybackCache << kIOMapCacheShift,
kIOMapWriteCombineCache = kIOWriteCombineCache << kIOMapCacheShift,
kIOMapCopybackInnerCache = kIOCopybackInnerCache << kIOMapCacheShift,
kIOMapPostedWrite = kIOPostedWrite << kIOMapCacheShift,
kIOMapRealTimeCache = kIORealTimeCache << kIOMapCacheShift,
kIOMapPostedReordered = kIOPostedReordered << kIOMapCacheShift,
kIOMapPostedCombinedReordered = kIOPostedCombinedReordered << kIOMapCacheShift,
kIOMapUserOptionsMask = 0x00000fff,
kIOMapReadOnly = 0x00001000,
kIOMapStatic = 0x01000000,
kIOMapReference = 0x02000000,
kIOMapUnique = 0x04000000,
kIOMapPrefault = 0x10000000,
kIOMapOverwrite = 0x20000000,
kIOMapGuardedMask = 0xC0000000,
kIOMapGuardedSmall = 0x40000000,
kIOMapGuardedLarge = 0x80000000
};
#endif /* ! __IOKIT_IOMAPTYPES_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOInterleavedMemoryDescriptor.h | /*
* Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _IOINTERLEAVEDMEMORYDESCRIPTOR_H
#define _IOINTERLEAVEDMEMORYDESCRIPTOR_H
#include <IOKit/IOMemoryDescriptor.h>
#include <libkern/c++/OSPtr.h>
/*! @class IOInterleavedMemoryDescriptor : public IOMemoryDescriptor
* @abstract The IOInterleavedMemoryDescriptor object describes a memory area made up of portions of several other IOMemoryDescriptors.
* @discussion The IOInterleavedMemoryDescriptor object represents interleaved ranges of memory, specified as an ordered list of portions of individual IOMemoryDescriptors. The portions are chained end-to-end to make up a single contiguous buffer. */
class IOInterleavedMemoryDescriptor : public IOMemoryDescriptor
{
OSDeclareDefaultStructors(IOInterleavedMemoryDescriptor);
protected:
IOByteCount _descriptorCapacity;
UInt32 _descriptorCount;
IOMemoryDescriptor ** _descriptors;
IOByteCount * _descriptorOffsets;
IOByteCount * _descriptorLengths;
bool _descriptorPrepared;
virtual void free() APPLE_KEXT_OVERRIDE;
public:
/*! @function withCapacity
* @abstract Create an IOInterleavedMemoryDescriptor to describe a memory area made up of several other IOMemoryDescriptors.
* @discussion This method creates and initializes an IOInterleavedMemoryDescriptor for memory consisting of portions of a number of other IOMemoryDescriptors, chained end-to-end (in the order they appear in the array) to represent a single contiguous memory buffer.
* @param capacity The maximum number of IOMemoryDescriptors that may be subsequently added to this IOInterleavedMemoryDescriptor.
* @param direction An I/O direction to be associated with the descriptor, which may affect the operation of the prepare and complete methods on some architectures.
* @result The created IOInterleavedMemoryDescriptor on success, to be released by the caller, or zero on failure. */
static OSPtr<IOInterleavedMemoryDescriptor> withCapacity( IOByteCount capacity,
IODirection direction);
/*! @function initWithCapacity
* @abstract Initialize an IOInterleavedMemoryDescriptor to describe a memory area made up of several other IOMemoryDescriptors.
* @discussion This method initializes an IOInterleavedMemoryDescriptor for memory consisting of portions of a number of other IOMemoryDescriptors, chained end-to-end (in the order they appear in the array) to represent a single contiguous memory buffer.
* @param capacity The maximum number of IOMemoryDescriptors that may be subsequently added to this IOInterleavedMemoryDescriptor.
* @param direction An I/O direction to be associated with the descriptor, which may affect the operation of the prepare and complete methods on some architectures.
* @result The created IOInterleavedMemoryDescriptor on success, to be released by the caller, or zero on failure. */
virtual bool initWithCapacity( IOByteCount capacity,
IODirection direction );
/*! @function clearMemoryDescriptors
* @abstract Clear all of the IOMemoryDescriptors currently contained in and reset the IOInterleavedMemoryDescriptor.
* @discussion Clears each IOMemoryDescriptor by completing (if needed) and releasing. The IOInterleavedMemoryDescriptor is then reset and may accept new descriptors up to the capacity specified when it was created.
* @param direction An I/O direction to be associated with the descriptor, which may affect the operation of the prepare and complete methods on some architectures. */
virtual void clearMemoryDescriptors( IODirection direction = kIODirectionNone );
/*! @function setMemoryDescriptor
* @abstract Add a portion of an IOMemoryDescriptor to the IOInterleavedMemoryDescriptor.
* @discussion This method adds the portion of an IOMemoryDescriptor described by the offset and length parameters to the end of the IOInterleavedMemoryDescriptor. A single IOMemoryDescriptor may be added as many times as there is room for it. The offset and length must describe a portion entirely within the IOMemoryDescriptor.
* @param descriptor An IOMemoryDescriptor to be added to the IOInterleavedMemoryDescriptor. Its direction must be compatible with that of the IOInterleavedMemoryDescriptor.
* @param offset The offset into the IOMemoryDescriptor of the portion that will be added to the virtualized buffer.
* @param length The length of the portion of the IOMemoryDescriptor to be added to the virtualized buffer.
* @result Returns true the portion was successfully added. */
virtual bool setMemoryDescriptor( IOMemoryDescriptor * descriptor,
IOByteCount offset,
IOByteCount length );
/*! @function getPhysicalSegment
* @abstract Break a memory descriptor into its physically contiguous segments.
* @discussion This method returns the physical address of the byte at the given offset into the memory, and optionally the length of the physically contiguous segment from that offset.
* @param offset A byte offset into the memory whose physical address to return.
* @param length If non-zero, getPhysicalSegment will store here the length of the physically contiguous segement at the given offset.
* @result A physical address, or zero if the offset is beyond the length of the memory. */
virtual addr64_t getPhysicalSegment( IOByteCount offset,
IOByteCount * length,
IOOptionBits options = 0 ) APPLE_KEXT_OVERRIDE;
/*! @function prepare
* @abstract Prepare the memory for an I/O transfer.
* @discussion This involves paging in the memory, if necessary, and wiring it down for the duration of the transfer. The complete() method completes the processing of the memory after the I/O transfer finishes. This method need not called for non-pageable memory.
* @param forDirection The direction of the I/O to be performed, or kIODirectionNone for the direction specified by the memory descriptor.
* @result An IOReturn code. */
virtual IOReturn prepare(IODirection forDirection = kIODirectionNone) APPLE_KEXT_OVERRIDE;
/*! @function complete
* @abstract Complete processing of the memory after an I/O transfer finishes.
* @discussion This method should not be called unless a prepare was previously issued; the prepare() and complete() must occur in pairs, before and after an I/O transfer involving pageable memory.
* @param forDirection The direction of the I/O just completed, or kIODirectionNone for the direction specified by the memory descriptor.
* @result An IOReturn code. */
virtual IOReturn complete(IODirection forDirection = kIODirectionNone) APPLE_KEXT_OVERRIDE;
};
#endif /* !_IOINTERLEAVEDMEMORYDESCRIPTOR_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IODeviceTreeSupport.h | /*
* Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* Copyright (c) 1998 Apple Computer, Inc. All rights reserved.
*
* HISTORY
*
*/
#ifndef _IOKIT_IODEVICETREE_H
#define _IOKIT_IODEVICETREE_H
#include <IOKit/IORegistryEntry.h>
#include <libkern/c++/OSData.h>
#include <libkern/c++/OSPtr.h>
class IODeviceMemory;
class IOService;
extern const IORegistryPlane * gIODTPlane;
extern const OSSymbol * gIODTPHandleKey;
extern const OSSymbol * gIODTCompatibleKey;
extern const OSSymbol * gIODTTypeKey;
extern const OSSymbol * gIODTModelKey;
extern const OSSymbol * gIODTBridgeModelKey;
extern const OSSymbol * gIODTTargetTypeKey;
extern const OSSymbol * gIODTAAPLInterruptsKey;
extern const OSSymbol * gIODTDefaultInterruptController;
extern const OSSymbol * gIODTNWInterruptMappingKey;
LIBKERN_RETURNS_NOT_RETAINED IORegistryEntry * IODeviceTreeAlloc( void * dtTop );
bool IODTMatchNubWithKeys( IORegistryEntry * nub,
const char * keys );
bool IODTCompareNubName( const IORegistryEntry * regEntry,
OSString * name,
LIBKERN_RETURNS_RETAINED_ON_NONZERO OSString ** matchingName );
bool IODTCompareNubName( const IORegistryEntry * regEntry,
OSString * name,
OSSharedPtr<OSString>& matchingName );
enum {
kIODTRecursive = 0x00000001,
kIODTExclusive = 0x00000002
};
OSCollectionIterator * IODTFindMatchingEntries( IORegistryEntry * from,
IOOptionBits options, const char * keys );
#if !defined(__arm64__)
typedef SInt32 (*IODTCompareAddressCellFunc)
(UInt32 cellCount, UInt32 left[], UInt32 right[]);
#else
typedef SInt64 (*IODTCompareAddressCellFunc)
(UInt32 cellCount, UInt32 left[], UInt32 right[]);
#endif
typedef void (*IODTNVLocationFunc)
(IORegistryEntry * entry,
UInt8 * busNum, UInt8 * deviceNum, UInt8 * functionNum );
void IODTSetResolving( IORegistryEntry * regEntry,
IODTCompareAddressCellFunc compareFunc,
IODTNVLocationFunc locationFunc );
void IODTGetCellCounts( IORegistryEntry * regEntry,
UInt32 * sizeCount, UInt32 * addressCount);
bool IODTResolveAddressCell( IORegistryEntry * regEntry,
UInt32 cellsIn[],
IOPhysicalAddress * phys, IOPhysicalLength * len );
LIBKERN_RETURNS_NOT_RETAINED OSArray *
IODTResolveAddressing( IORegistryEntry * regEntry,
const char * addressPropertyName,
IODeviceMemory * parent );
struct IONVRAMDescriptor {
unsigned int format:4;
unsigned int marker:1;
unsigned int bridgeCount:3;
unsigned int busNum:2;
unsigned int bridgeDevices:6 * 5;
unsigned int functionNum:3;
unsigned int deviceNum:5;
} __attribute__((aligned(2), packed));
IOReturn IODTMakeNVDescriptor( IORegistryEntry * regEntry,
IONVRAMDescriptor * hdr );
LIBKERN_RETURNS_NOT_RETAINED OSData *
IODTFindSlotName( IORegistryEntry * regEntry, UInt32 deviceNumber );
const OSSymbol * IODTInterruptControllerName(
IORegistryEntry * regEntry );
bool IODTMapInterrupts( IORegistryEntry * regEntry );
enum {
kIODTInterruptShared = 0x00000001
};
IOReturn IODTGetInterruptOptions( IORegistryEntry * regEntry, int source, IOOptionBits * options );
#ifdef __cplusplus
extern "C" {
#endif
IOReturn IONDRVLibrariesInitialize( IOService * provider );
#ifdef __cplusplus
}
#endif
#endif /* _IOKIT_IODEVICETREE_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOTimerEventSource.h | /*
* Copyright (c) 1998-2019 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
*
* IOTimerEventSource.h
*
* HISTORY
* 2-Feb-1999 Joe Liu (jliu) created.
*
*/
#ifndef _IOTIMEREVENTSOURCE
#define _IOTIMEREVENTSOURCE
#include <sys/cdefs.h>
__BEGIN_DECLS
#include <kern/clock.h>
__END_DECLS
#include <libkern/c++/OSPtr.h>
#include <IOKit/IOEventSource.h>
#include <IOKit/IOTypes.h>
/*!
* @enum IOTimerEventSource constructor options
* @abstract Constants defining behavior of the IOTimerEventSource.
* @constant kIOTimerEventSourceOptionsPriorityHigh Importance above everything but realtime.
* Thread calls allocated with this priority execute at extremely high priority,
* above everything but realtime threads. They are generally executed in serial.
* Though they may execute concurrently under some circumstances, no fan-out is implied.
* These work items should do very small amounts of work or risk disrupting system
* responsiveness.
* @constant kIOTimerEventSourceOptionsPriorityKernelHigh Importance higher than most kernel
* threads.
* @constant kIOTimerEventSourceOptionsPriorityKernel Importance similar to that of normal kernel
* threads.
* @constant kIOTimerEventSourceOptionsPriorityUser Importance similar to that of normal user threads.
* @constant kIOTimerEventSourceOptionsPriorityLow Very low importance.
* @constant kIOTimerEventSourceOptionsPriorityWorkLoop Run the callout on the thread of the IOWorkLoop
* the event source has been added to.
* @constant kIOTimerEventSourceOptionsAllowReenter Allow the callout to be rescheduled and potentially
* re-entered, if the IOWorkLoop lock has been released (eg. with commandSleep) during its invocation.
* @constant kIOTimerEventSourceOptionsDefault Recommended default options.
*/
enum{
kIOTimerEventSourceOptionsPriorityMask = 0x000000ff,
kIOTimerEventSourceOptionsPriorityHigh = 0x00000000,
kIOTimerEventSourceOptionsPriorityKernelHigh = 0x00000001,
kIOTimerEventSourceOptionsPriorityKernel = 0x00000002,
kIOTimerEventSourceOptionsPriorityUser = 0x00000003,
kIOTimerEventSourceOptionsPriorityLow = 0x00000004,
kIOTimerEventSourceOptionsPriorityWorkLoop = 0x000000ff,
kIOTimerEventSourceOptionsAllowReenter = 0x00000100,
kIOTimerEventSourceOptionsDefault = kIOTimerEventSourceOptionsPriorityKernelHigh
};
#define IOTIMEREVENTSOURCEOPTIONS_DEFINED 1
/*!
* @enum IOTimerEventSource setTimeout/wakeAtTime options
* @abstract Constants defining behavior of a scheduled call from IOTimerEventSource.
* @constant kIOTimeOptionsWithLeeway Use the leeway parameter to the call.
* @constant kIOTimeOptionsContinuous Use mach_continuous_time() to generate the callback.
*/
enum{
kIOTimeOptionsWithLeeway = 0x00000020,
kIOTimeOptionsContinuous = 0x00000100,
};
/*!
* @class IOTimerEventSource : public IOEventSource
* @abstract Time based event source mechanism.
* @discussion An event source that implements a simple timer. A timeout handler is called once the timeout period expires. This timeout handler will be called by the work-loop that this event source is attached to.
* <br><br>
* Usually a timer event source will be used to implement a timeout. In general when a driver makes a request it will need to setup a call to keep track of when the I/O doesn't complete. This class is designed to make that somewhat easier.
* <br><br>
* Remember the system doesn't guarantee the accuracy of the callout. It is possible that a higher priority thread is running which will delay the execution of the action routine. In fact the thread will be made runable at the exact requested time, within the accuracy of the CPU's decrementer based interrupt, but the scheduler will then control execution.
*/
class IOTimerEventSource : public IOEventSource
{
OSDeclareDefaultStructors(IOTimerEventSource);
protected:
/*! @var calloutEntry thread_call entry for preregistered thread callouts */
void *calloutEntry;
/*! @var abstime time to wake up next, see enable. */
AbsoluteTime abstime;
/*! @struct ExpansionData
* @discussion This structure is private to the IOTimerEventSource implementation.
*/
struct ExpansionData {
SInt32 calloutGeneration;
SInt32 calloutGenerationSignaled;
IOWorkLoop * workLoop;
};
/*! @var reserved
* Reserved for future use. (Internal use only) */
APPLE_KEXT_WSHADOW_PUSH;
ExpansionData *reserved;
APPLE_KEXT_WSHADOW_POP;
/*! @function timeout
* @abstract Function that routes the call from the OS' timeout mechanism into a work-loop context.
* @discussion timeout will normally not be called nor overridden by a subclass. If the event source is enabled then close the work-loop's gate and call the action routine.
* @param self This argument will be cast to an IOTimerEventSource. */
static void timeout(void *self);
/*! @function setTimeoutFunc
* @abstract Set's timeout as the function of calloutEntry.
* @discussion IOTimerEventSource is based upon the kern/thread_call.h APIs currently. This function allocates the calloutEntry member variable by using thread_call_allocate(timeout, this). If you need to write your own subclass of IOTimerEventSource you probably should override this method to allocate an entry that points to your own timeout routine. */
virtual void setTimeoutFunc();
/*! @function free
* @abstract Sub-class implementation of free method, frees calloutEntry */
virtual void free() APPLE_KEXT_OVERRIDE;
virtual void setWorkLoop(IOWorkLoop *workLoop) APPLE_KEXT_OVERRIDE;
public:
/*! @typedef Action
* @discussion 'C' Function pointer defining the callout routine of this event source.
* @param owner Owning target object. Note by a startling coincidence the first parameter in a C callout is currently used to define the target of a C++ member function.
* @param sender The object that timed out. */
typedef void (*Action)(OSObject *owner, IOTimerEventSource *sender);
#ifdef __BLOCKS__
typedef void (^ActionBlock)(IOTimerEventSource *sender);
#endif /* __BLOCKS__ */
static OSPtr<IOTimerEventSource>
timerEventSource(OSObject *owner, Action action = NULL);
/*! @function timerEventSource
* @abstract Allocates and returns an initialized timer instance.
* @param options Mask of kIOTimerEventSourceOptions* options.
* @param owner The object that that will be passed to the Action callback.
* @param action 'C' Function pointer for the callout routine of this event source.
*/
static OSPtr<IOTimerEventSource>
timerEventSource(uint32_t options, OSObject *owner, Action action = NULL);
#ifdef __BLOCKS__
/*! @function timerEventSource
* @abstract Allocates and returns an initialized timer instance.
* @param options Mask of kIOTimerEventSourceOptions* options.
* @param inOwner The object that that will be passed to the Action callback.
* @param action Block for the callout routine of this event source.
*/
static OSPtr<IOTimerEventSource>
timerEventSource(uint32_t options, OSObject *inOwner, ActionBlock action);
#endif /* __BLOCKS__ */
/*! @function init
* @abstract Initializes the timer with an owner, and a handler to call when the timeout expires.
*/
virtual bool init(OSObject *owner, Action action = NULL);
/*! @function enable
* @abstract Enables a call to the action.
* @discussion Allows the action function to be called. If the timer event source was disabled while a call was outstanding and the call wasn't cancelled then it will be rescheduled. So a disable/enable pair will disable calls from this event source. */
virtual void enable() APPLE_KEXT_OVERRIDE;
/*! @function disable
* @abstract Disable a timed callout.
* @discussion When disable returns the action will not be called until the next time enable(qv) is called. */
virtual void disable() APPLE_KEXT_OVERRIDE;
/*! @function checkForWork
* @abstract Pure Virtual member function used by IOWorkLoop for issuing a client calls.
* @discussion This function called when the work-loop is ready to check for any work to do and then to call out the owner/action.
* @result Return true if this function needs to be called again before all its outstanding events have been processed. */
virtual bool checkForWork() APPLE_KEXT_OVERRIDE;
/*! @function setTimeoutTicks
* @abstract Setup a callback at after the delay in scheduler ticks. See wakeAtTime(AbsoluteTime).
* @param ticks Delay from now to wake up, in scheduler ticks, whatever that may be.
* @result kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared. */
virtual IOReturn setTimeoutTicks(UInt32 ticks);
/*! @function setTimeoutMS
* @abstract Setup a callback at after the delay in milliseconds. See wakeAtTime(AbsoluteTime).
* @param ms Delay from now to wake up, time in milliseconds.
* @result kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared. */
virtual IOReturn setTimeoutMS(UInt32 ms);
/*! @function setTimeoutUS
* @abstract Setup a callback at after the delay in microseconds. See wakeAtTime(AbsoluteTime).
* @param us Delay from now to wake up, time in microseconds.
* @result kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared. */
virtual IOReturn setTimeoutUS(UInt32 us);
/*! @function setTimeout
* @abstract Setup a callback at after the delay in some unit. See wakeAtTime(AbsoluteTime).
* @param interval Delay from now to wake up in some defined unit.
* @param scale_factor Define the unit of interval, default to nanoseconds.
* @result kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared. */
virtual IOReturn setTimeout(UInt32 interval,
UInt32 scale_factor = kNanosecondScale);
#if !defined(__LP64__)
virtual IOReturn setTimeout(mach_timespec_t interval)
APPLE_KEXT_DEPRECATED;
#endif
/*! @function setTimeout
* @abstract Setup a callback at after the delay in decrementer ticks. See wakeAtTime(AbsoluteTime).
* @param interval Delay from now to wake up in decrementer ticks.
* @result kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared. */
virtual IOReturn setTimeout(AbsoluteTime interval);
/*! @function wakeAtTimeTicks
* @abstract Setup a callback at this absolute time. See wakeAtTime(AbsoluteTime).
* @param ticks Time to wake up in scheduler quantums, whatever that is?
* @result kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared. */
virtual IOReturn wakeAtTimeTicks(UInt32 ticks);
/*! @function wakeAtTimeMS
* @abstract Setup a callback at this absolute time. See wakeAtTime(AbsoluteTime).
* @param ms Time to wake up in milliseconds.
* @result kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared. */
virtual IOReturn wakeAtTimeMS(UInt32 ms);
/*! @function wakeAtTimeUS
* @abstract Setup a callback at this absolute time. See wakeAtTime(AbsoluteTime).
* @param us Time to wake up in microseconds.
* @result kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared. */
virtual IOReturn wakeAtTimeUS(UInt32 us);
/*! @function wakeAtTime
* @abstract Setup a callback at this absolute time. See wakeAtTime(AbsoluteTime).
* @param abstime Time to wake up in some unit.
* @param scale_factor Define the unit of abstime, default to nanoseconds.
* @result kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared. */
virtual IOReturn wakeAtTime(UInt32 abstime,
UInt32 scale_factor = kNanosecondScale);
#if !defined(__LP64__)
virtual IOReturn wakeAtTime(mach_timespec_t abstime)
APPLE_KEXT_DEPRECATED;
#endif
/*! @function wakeAtTime
* @abstract Setup a callback at this absolute time.
* @discussion Starts the timer, which will expire at abstime. After it expires, the timer will call the 'action' registered in the init() function. This timer is not periodic, a further call is needed to reset and restart the timer after it expires.
* @param abstime Absolute Time when to wake up, counted in 'decrementer' units and starts at zero when system boots.
* @result kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared by init or IOEventSource::setAction (qqv). */
virtual IOReturn wakeAtTime(AbsoluteTime abstime);
/*! @function cancelTimeout
* @abstract Disable any outstanding calls to this event source.
* @discussion Clear down any oustanding calls. By the time this function completes it is guaranteed that the action will not be called again. */
virtual void cancelTimeout();
/*! @function init
* @abstract Initializes the timer with an owner, and a handler to call when the timeout expires.
*/
virtual bool init(uint32_t options, OSObject *inOwner, Action inAction);
/*! @function setTimeout
* @abstract Setup a callback at after the delay in decrementer ticks. See wakeAtTime(AbsoluteTime).
* @param options see kIOTimeOptionsWithLeeway and kIOTimeOptionsContinuous
* @param interval Delay from now to wake up in decrementer ticks.
* @param leeway Allowable leeway to wake time, if the kIOTimeOptionsWithLeeway option is set
* @result kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared. */
virtual IOReturn setTimeout(uint32_t options, AbsoluteTime interval, AbsoluteTime leeway);
/*! @function wakeAtTime
* @abstract Setup a callback at this absolute time.
* @discussion Starts the timer, which will expire at abstime. After it expires, the timer will call the 'action' registered in the init() function. This timer is not periodic, a further call is needed to reset and restart the timer after it expires.
* @param options see kIOTimeOptionsWithLeeway and kIOTimeOptionsContinuous
* @param abstime Absolute Time when to wake up, counted in 'decrementer' units and starts at zero when system boots.
* @param leeway Allowable leeway to wake time, if the kIOTimeOptionsWithLeeway option is set
* @result kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared by init or IOEventSource::setAction (qqv). */
virtual IOReturn wakeAtTime(uint32_t options, AbsoluteTime abstime, AbsoluteTime leeway);
private:
static void timeoutAndRelease(void *self, void *c);
static void timeoutSignaled(void *self, void *c);
private:
OSMetaClassDeclareReservedUsedX86(IOTimerEventSource, 0);
OSMetaClassDeclareReservedUsedX86(IOTimerEventSource, 1);
OSMetaClassDeclareReservedUsedX86(IOTimerEventSource, 2);
OSMetaClassDeclareReservedUnused(IOTimerEventSource, 3);
OSMetaClassDeclareReservedUnused(IOTimerEventSource, 4);
OSMetaClassDeclareReservedUnused(IOTimerEventSource, 5);
OSMetaClassDeclareReservedUnused(IOTimerEventSource, 6);
OSMetaClassDeclareReservedUnused(IOTimerEventSource, 7);
};
#endif /* !_IOTIMEREVENTSOURCE */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOMemoryDescriptor.h | /*
* Copyright (c) 1998-2020 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _IOMEMORYDESCRIPTOR_H
#define _IOMEMORYDESCRIPTOR_H
#include <sys/cdefs.h>
#include <IOKit/IOTypes.h>
#include <IOKit/IOLocks.h>
#include <libkern/c++/OSPtr.h>
#include <libkern/c++/OSContainers.h>
#include <DriverKit/IOMemoryDescriptor.h>
#include <DriverKit/IOMemoryMap.h>
#include <mach/memory_object_types.h>
class IOMemoryDescriptor;
class IOMemoryMap;
class IOMapper;
class IOService;
class IODMACommand;
class _IOMemoryDescriptorMixedData;
/*
* Direction of transfer, with respect to the described memory.
*/
#ifdef __LP64__
enum
#else /* !__LP64__ */
enum IODirection
#endif /* !__LP64__ */
{
kIODirectionNone = 0x0,// same as VM_PROT_NONE
kIODirectionIn = 0x1,// User land 'read', same as VM_PROT_READ
kIODirectionOut = 0x2,// User land 'write', same as VM_PROT_WRITE
kIODirectionOutIn = kIODirectionOut | kIODirectionIn,
kIODirectionInOut = kIODirectionIn | kIODirectionOut,
// these flags are valid for the prepare() method only
kIODirectionPrepareToPhys32 = 0x00000004,
kIODirectionPrepareNoFault = 0x00000008,
kIODirectionPrepareReserved1 = 0x00000010,
#define IODIRECTIONPREPARENONCOHERENTDEFINED 1
kIODirectionPrepareNonCoherent = 0x00000020,
// these flags are valid for the complete() method only
#define IODIRECTIONCOMPLETEWITHERRORDEFINED 1
kIODirectionCompleteWithError = 0x00000040,
#define IODIRECTIONCOMPLETEWITHDATAVALIDDEFINED 1
kIODirectionCompleteWithDataValid = 0x00000080,
};
#ifdef __LP64__
typedef IOOptionBits IODirection;
#endif /* __LP64__ */
/*
* IOOptionBits used in the withOptions variant
*/
enum {
kIOMemoryDirectionMask = 0x00000007,
kIOMemoryTypeVirtual = 0x00000010,
kIOMemoryTypePhysical = 0x00000020,
kIOMemoryTypeUPL = 0x00000030,
kIOMemoryTypePersistentMD = 0x00000040,// Persistent Memory Descriptor
kIOMemoryTypeUIO = 0x00000050,
#ifdef __LP64__
kIOMemoryTypeVirtual64 = kIOMemoryTypeVirtual,
kIOMemoryTypePhysical64 = kIOMemoryTypePhysical,
#else /* !__LP64__ */
kIOMemoryTypeVirtual64 = 0x00000060,
kIOMemoryTypePhysical64 = 0x00000070,
#endif /* !__LP64__ */
kIOMemoryTypeMask = 0x000000f0,
kIOMemoryAsReference = 0x00000100,
kIOMemoryBufferPageable = 0x00000400,
kIOMemoryMapperNone = 0x00000800,// Shared with Buffer MD
kIOMemoryHostOnly = 0x00001000,// Never DMA accessible
kIOMemoryPersistent = 0x00010000,
kIOMemoryMapCopyOnWrite = 0x00020000,
kIOMemoryRemote = 0x00040000,
kIOMemoryThreadSafe = 0x00100000,// Shared with Buffer MD
kIOMemoryClearEncrypt = 0x00200000,// Shared with Buffer MD
kIOMemoryUseReserve = 0x00800000,// Shared with Buffer MD
#define IOMEMORYUSERESERVEDEFINED 1
};
#define kIOMapperSystem ((IOMapper *) NULL)
enum{
kIOMemoryLedgerTagDefault = VM_LEDGER_TAG_DEFAULT,
kIOmemoryLedgerTagNetwork = VM_LEDGER_TAG_NETWORK,
kIOMemoryLedgerTagMedia = VM_LEDGER_TAG_MEDIA,
kIOMemoryLedgerTagGraphics = VM_LEDGER_TAG_GRAPHICS,
kIOMemoryLedgerTagNeural = VM_LEDGER_TAG_NEURAL,
};
enum{
kIOMemoryLedgerFlagNoFootprint = VM_LEDGER_FLAG_NO_FOOTPRINT,
};
enum{
kIOMemoryPurgeableKeepCurrent = 1,
kIOMemoryPurgeableNonVolatile = 2,
kIOMemoryPurgeableVolatile = 3,
kIOMemoryPurgeableEmpty = 4,
// modifiers for kIOMemoryPurgeableVolatile behavior
kIOMemoryPurgeableVolatileGroup0 = VM_VOLATILE_GROUP_0,
kIOMemoryPurgeableVolatileGroup1 = VM_VOLATILE_GROUP_1,
kIOMemoryPurgeableVolatileGroup2 = VM_VOLATILE_GROUP_2,
kIOMemoryPurgeableVolatileGroup3 = VM_VOLATILE_GROUP_3,
kIOMemoryPurgeableVolatileGroup4 = VM_VOLATILE_GROUP_4,
kIOMemoryPurgeableVolatileGroup5 = VM_VOLATILE_GROUP_5,
kIOMemoryPurgeableVolatileGroup6 = VM_VOLATILE_GROUP_6,
kIOMemoryPurgeableVolatileGroup7 = VM_VOLATILE_GROUP_7,
kIOMemoryPurgeableVolatileBehaviorFifo = VM_PURGABLE_BEHAVIOR_FIFO,
kIOMemoryPurgeableVolatileBehaviorLifo = VM_PURGABLE_BEHAVIOR_LIFO,
kIOMemoryPurgeableVolatileOrderingObsolete = VM_PURGABLE_ORDERING_OBSOLETE,
kIOMemoryPurgeableVolatileOrderingNormal = VM_PURGABLE_ORDERING_NORMAL,
kIOMemoryPurgeableFaultOnAccess = VM_PURGABLE_DEBUG_FAULT,
};
enum{
kIOMemoryIncoherentIOFlush = 1,
kIOMemoryIncoherentIOStore = 2,
kIOMemoryClearEncrypted = 50,
kIOMemorySetEncrypted = 51,
};
#define IOMEMORYDESCRIPTOR_SUPPORTS_DMACOMMAND 1
struct IODMAMapSpecification {
uint64_t alignment;
IOService * device;
uint32_t options;
uint8_t numAddressBits;
uint8_t resvA[3];
uint32_t resvB[4];
};
struct IODMAMapPageList {
uint32_t pageOffset;
uint32_t pageListCount;
const upl_page_info_t * pageList;
};
// mapOptions for iovmMapMemory
enum{
kIODMAMapReadAccess = 0x00000001,
kIODMAMapWriteAccess = 0x00000002,
kIODMAMapPhysicallyContiguous = 0x00000010,
kIODMAMapDeviceMemory = 0x00000020,
kIODMAMapPagingPath = 0x00000040,
kIODMAMapIdentityMap = 0x00000080,
kIODMAMapPageListFullyOccupied = 0x00000100,
kIODMAMapFixedAddress = 0x00000200,
};
enum{
kIOPreparationIDUnprepared = 0,
kIOPreparationIDUnsupported = 1,
kIOPreparationIDAlwaysPrepared = 2,
};
/*! @class IOMemoryDescriptor : public OSObject
* @abstract An abstract base class defining common methods for describing physical or virtual memory.
* @discussion The IOMemoryDescriptor object represents a buffer or range of memory, specified as one or more physical or virtual address ranges. It contains methods to return the memory's physically contiguous segments (fragments), for use with the IOMemoryCursor, and methods to map the memory into any address space with caching and placed mapping options. */
class IOMemoryDescriptor : public OSObject
{
friend class IOMemoryMap;
friend class IOMultiMemoryDescriptor;
OSDeclareDefaultStructorsWithDispatch(IOMemoryDescriptor);
protected:
/*! @var reserved
* Reserved for future use. (Internal use only) */
struct IOMemoryDescriptorReserved * reserved;
protected:
OSPtr<OSSet> _mappings;
IOOptionBits _flags;
void * __iomd_reserved5;
uint16_t __iomd_reserved1[4];
uintptr_t __iomd_reserved2;
uintptr_t __iomd_reserved3;
uintptr_t __iomd_reserved4;
#ifndef __LP64__
IODirection _direction; /* use _flags instead */
#endif /* !__LP64__ */
IOByteCount _length; /* length of all ranges */
IOOptionBits _tag;
public:
typedef IOOptionBits DMACommandOps;
#ifndef __LP64__
virtual IOPhysicalAddress getSourceSegment( IOByteCount offset,
IOByteCount * length ) APPLE_KEXT_DEPRECATED;
#endif /* !__LP64__ */
/*! @function initWithOptions
* @abstract Master initialiser for all variants of memory descriptors. For a more complete description see IOMemoryDescriptor::withOptions.
* @discussion Note this function can be used to re-init a previously created memory descriptor.
* @result true on success, false on failure. */
virtual bool initWithOptions(void * buffers,
UInt32 count,
UInt32 offset,
task_t task,
IOOptionBits options,
IOMapper * mapper = kIOMapperSystem);
#ifndef __LP64__
virtual addr64_t getPhysicalSegment64( IOByteCount offset,
IOByteCount * length ) APPLE_KEXT_DEPRECATED; /* use getPhysicalSegment() and kIOMemoryMapperNone instead */
#endif /* !__LP64__ */
/*! @function setPurgeable
* @abstract Control the purgeable status of a memory descriptors memory.
* @discussion Buffers may be allocated with the ability to have their purgeable status changed - IOBufferMemoryDescriptor with the kIOMemoryPurgeable option, VM_FLAGS_PURGEABLE may be passed to vm_allocate() in user space to allocate such buffers. The purgeable status of such a buffer may be controlled with setPurgeable(). The process of making a purgeable memory descriptor non-volatile and determining its previous state is atomic - if a purgeable memory descriptor is made nonvolatile and the old state is returned as kIOMemoryPurgeableVolatile, then the memory's previous contents are completely intact and will remain so until the memory is made volatile again. If the old state is returned as kIOMemoryPurgeableEmpty then the memory was reclaimed while it was in a volatile state and its previous contents have been lost.
* @param newState - the desired new purgeable state of the memory:<br>
* kIOMemoryPurgeableKeepCurrent - make no changes to the memory's purgeable state.<br>
* kIOMemoryPurgeableVolatile - make the memory volatile - the memory may be reclaimed by the VM system without saving its contents to backing store.<br>
* kIOMemoryPurgeableNonVolatile - make the memory nonvolatile - the memory is treated as with usual allocations and must be saved to backing store if paged.<br>
* kIOMemoryPurgeableEmpty - make the memory volatile, and discard any pages allocated to it.
* @param oldState - if non-NULL, the previous purgeable state of the memory is returned here:<br>
* kIOMemoryPurgeableNonVolatile - the memory was nonvolatile.<br>
* kIOMemoryPurgeableVolatile - the memory was volatile but its content has not been discarded by the VM system.<br>
* kIOMemoryPurgeableEmpty - the memory was volatile and has been discarded by the VM system.<br>
* @result An IOReturn code. */
virtual IOReturn setPurgeable( IOOptionBits newState,
IOOptionBits * oldState );
/*! @function setOwnership
* @abstract Control the ownership of a memory descriptors memory.
* @discussion IOBufferMemoryDescriptor are owned by a specific task. The ownership of such a buffer may be controlled with setOwnership().
* @param newOwner - the task to be the new owner of the memory.
* @param newLedgerTag - the ledger this memory should be accounted in.
* @param newLedgerOptions - accounting options
* @result An IOReturn code. */
IOReturn setOwnership( task_t newOwner,
int newLedgerTag,
IOOptionBits newLedgerOptions );
/*! @function getPageCounts
* @abstract Retrieve the number of resident and/or dirty pages encompassed by an IOMemoryDescriptor.
* @discussion This method returns the number of resident and/or dirty pages encompassed by an IOMemoryDescriptor.
* @param residentPageCount - If non-null, a pointer to a byte count that will return the number of resident pages encompassed by this IOMemoryDescriptor.
* @param dirtyPageCount - If non-null, a pointer to a byte count that will return the number of dirty pages encompassed by this IOMemoryDescriptor.
* @result An IOReturn code. */
IOReturn getPageCounts( IOByteCount * residentPageCount,
IOByteCount * dirtyPageCount);
/*! @function performOperation
* @abstract Perform an operation on the memory descriptor's memory.
* @discussion This method performs some operation on a range of the memory descriptor's memory. When a memory descriptor's memory is not mapped, it should be more efficient to use this method than mapping the memory to perform the operation virtually.
* @param options The operation to perform on the memory:<br>
* kIOMemoryIncoherentIOFlush - pass this option to store to memory and flush any data in the processor cache for the memory range, with synchronization to ensure the data has passed through all levels of processor cache. It may not be supported on all architectures. This type of flush may be used for non-coherent I/O such as AGP - it is NOT required for PCI coherent operations. The memory descriptor must have been previously prepared.<br>
* kIOMemoryIncoherentIOStore - pass this option to store to memory any data in the processor cache for the memory range, with synchronization to ensure the data has passed through all levels of processor cache. It may not be supported on all architectures. This type of flush may be used for non-coherent I/O such as AGP - it is NOT required for PCI coherent operations. The memory descriptor must have been previously prepared.
* @param offset A byte offset into the memory descriptor's memory.
* @param length The length of the data range.
* @result An IOReturn code. */
virtual IOReturn performOperation( IOOptionBits options,
IOByteCount offset, IOByteCount length );
// Used for dedicated communications for IODMACommand
virtual IOReturn dmaCommandOperation(DMACommandOps op, void *vData, UInt dataSize) const;
/*! @function getPhysicalSegment
* @abstract Break a memory descriptor into its physically contiguous segments.
* @discussion This method returns the physical address of the byte at the given offset into the memory, and optionally the length of the physically contiguous segment from that offset.
* @param offset A byte offset into the memory whose physical address to return.
* @param length If non-zero, getPhysicalSegment will store here the length of the physically contiguous segement at the given offset.
* @result A physical address, or zero if the offset is beyond the length of the memory. */
#ifdef __LP64__
virtual addr64_t getPhysicalSegment( IOByteCount offset,
IOByteCount * length,
IOOptionBits options = 0 ) = 0;
#else /* !__LP64__ */
virtual addr64_t getPhysicalSegment( IOByteCount offset,
IOByteCount * length,
IOOptionBits options );
#endif /* !__LP64__ */
virtual uint64_t getPreparationID( void );
void setPreparationID( void );
void setVMTags(uint32_t kernelTag, uint32_t userTag);
uint32_t getVMTag(vm_map_t map);
private:
OSMetaClassDeclareReservedUsedX86(IOMemoryDescriptor, 0);
#ifdef __LP64__
OSMetaClassDeclareReservedUnused(IOMemoryDescriptor, 1);
OSMetaClassDeclareReservedUnused(IOMemoryDescriptor, 2);
OSMetaClassDeclareReservedUnused(IOMemoryDescriptor, 3);
OSMetaClassDeclareReservedUnused(IOMemoryDescriptor, 4);
OSMetaClassDeclareReservedUnused(IOMemoryDescriptor, 5);
OSMetaClassDeclareReservedUnused(IOMemoryDescriptor, 6);
OSMetaClassDeclareReservedUnused(IOMemoryDescriptor, 7);
#else /* !__LP64__ */
OSMetaClassDeclareReservedUsedX86(IOMemoryDescriptor, 1);
OSMetaClassDeclareReservedUsedX86(IOMemoryDescriptor, 2);
OSMetaClassDeclareReservedUsedX86(IOMemoryDescriptor, 3);
OSMetaClassDeclareReservedUsedX86(IOMemoryDescriptor, 4);
OSMetaClassDeclareReservedUsedX86(IOMemoryDescriptor, 5);
OSMetaClassDeclareReservedUsedX86(IOMemoryDescriptor, 6);
OSMetaClassDeclareReservedUsedX86(IOMemoryDescriptor, 7);
#endif /* !__LP64__ */
OSMetaClassDeclareReservedUnused(IOMemoryDescriptor, 8);
OSMetaClassDeclareReservedUnused(IOMemoryDescriptor, 9);
OSMetaClassDeclareReservedUnused(IOMemoryDescriptor, 10);
OSMetaClassDeclareReservedUnused(IOMemoryDescriptor, 11);
OSMetaClassDeclareReservedUnused(IOMemoryDescriptor, 12);
OSMetaClassDeclareReservedUnused(IOMemoryDescriptor, 13);
OSMetaClassDeclareReservedUnused(IOMemoryDescriptor, 14);
OSMetaClassDeclareReservedUnused(IOMemoryDescriptor, 15);
protected:
virtual void free(void) APPLE_KEXT_OVERRIDE;
public:
static void initialize( void );
public:
/*! @function withAddress
* @abstract Create an IOMemoryDescriptor to describe one virtual range of the kernel task.
* @discussion This method creates and initializes an IOMemoryDescriptor for memory consisting of a single virtual memory range mapped into the kernel map. This memory descriptor needs to be prepared before it can be used to extract data from the memory described.
* @param address The virtual address of the first byte in the memory.
* @param withLength The length of memory.
* @param withDirection An I/O direction to be associated with the descriptor, which may affect the operation of the prepare and complete methods on some architectures.
* @result The created IOMemoryDescriptor on success, to be released by the caller, or zero on failure. */
static OSPtr<IOMemoryDescriptor> withAddress(void * address,
IOByteCount withLength,
IODirection withDirection);
#ifndef __LP64__
static OSPtr<IOMemoryDescriptor> withAddress(IOVirtualAddress address,
IOByteCount withLength,
IODirection withDirection,
task_t withTask) APPLE_KEXT_DEPRECATED; /* use withAddressRange() and prepare() instead */
#endif /* !__LP64__ */
/*! @function withPhysicalAddress
* @abstract Create an IOMemoryDescriptor to describe one physical range.
* @discussion This method creates and initializes an IOMemoryDescriptor for memory consisting of a single physical memory range.
* @param address The physical address of the first byte in the memory.
* @param withLength The length of memory.
* @param withDirection An I/O direction to be associated with the descriptor, which may affect the operation of the prepare and complete methods on some architectures.
* @result The created IOMemoryDescriptor on success, to be released by the caller, or zero on failure. */
static OSPtr<IOMemoryDescriptor> withPhysicalAddress(
IOPhysicalAddress address,
IOByteCount withLength,
IODirection withDirection );
#ifndef __LP64__
static OSPtr<IOMemoryDescriptor> withRanges(IOVirtualRange * ranges,
UInt32 withCount,
IODirection withDirection,
task_t withTask,
bool asReference = false) APPLE_KEXT_DEPRECATED; /* use withAddressRanges() instead */
#endif /* !__LP64__ */
/*! @function withAddressRange
* @abstract Create an IOMemoryDescriptor to describe one virtual range of the specified map.
* @discussion This method creates and initializes an IOMemoryDescriptor for memory consisting of a single virtual memory range mapped into the specified map. This memory descriptor needs to be prepared before it can be used to extract data from the memory described.
* @param address The virtual address of the first byte in the memory.
* @param length The length of memory.
* @param options
* kIOMemoryDirectionMask (options:direction) This nibble indicates the I/O direction to be associated with the descriptor, which may affect the operation of the prepare and complete methods on some architectures.
* @param task The task the virtual ranges are mapped into. Note that unlike IOMemoryDescriptor::withAddress(), kernel_task memory must be explicitly prepared when passed to this api. The task argument may be NULL to specify memory by physical address.
* @result The created IOMemoryDescriptor on success, to be released by the caller, or zero on failure. */
static OSPtr<IOMemoryDescriptor> withAddressRange(
mach_vm_address_t address,
mach_vm_size_t length,
IOOptionBits options,
task_t task);
/*! @function withAddressRanges
* @abstract Create an IOMemoryDescriptor to describe one or more virtual ranges.
* @discussion This method creates and initializes an IOMemoryDescriptor for memory consisting of an array of virtual memory ranges each mapped into a specified source task. This memory descriptor needs to be prepared before it can be used to extract data from the memory described.
* @param ranges An array of IOAddressRange structures which specify the virtual ranges in the specified map which make up the memory to be described. IOAddressRange is the 64bit version of IOVirtualRange.
* @param rangeCount The member count of the ranges array.
* @param options
* kIOMemoryDirectionMask (options:direction) This nibble indicates the I/O direction to be associated with the descriptor, which may affect the operation of the prepare and complete methods on some architectures.
* kIOMemoryAsReference For options:type = Virtual or Physical this indicate that the memory descriptor need not copy the ranges array into local memory. This is an optimisation to try to minimise unnecessary allocations.
* @param task The task each of the virtual ranges are mapped into. Note that unlike IOMemoryDescriptor::withAddress(), kernel_task memory must be explicitly prepared when passed to this api. The task argument may be NULL to specify memory by physical address.
* @result The created IOMemoryDescriptor on success, to be released by the caller, or zero on failure. */
static OSPtr<IOMemoryDescriptor> withAddressRanges(
IOAddressRange * ranges,
UInt32 rangeCount,
IOOptionBits options,
task_t task);
/*! @function withOptions
* @abstract Master initialiser for all variants of memory descriptors.
* @discussion This method creates and initializes an IOMemoryDescriptor for memory it has three main variants: Virtual, Physical & mach UPL. These variants are selected with the options parameter, see below. This memory descriptor needs to be prepared before it can be used to extract data from the memory described.
*
*
* @param buffers A pointer to an array of IOAddressRange when options:type is kIOMemoryTypeVirtual64 or kIOMemoryTypePhysical64 or a 64bit kernel. For type UPL it is a upl_t returned by the mach/memory_object_types.h apis, primarily used internally by the UBC. IOVirtualRanges or IOPhysicalRanges are 32 bit only types for use when options:type is kIOMemoryTypeVirtual or kIOMemoryTypePhysical on 32bit kernels.
*
* @param count options:type = Virtual or Physical count contains a count of the number of entires in the buffers array. For options:type = UPL this field contains a total length.
*
* @param offset Only used when options:type = UPL, in which case this field contains an offset for the memory within the buffers upl.
*
* @param task Only used options:type = Virtual, The task each of the virtual ranges are mapped into.
*
* @param options
* kIOMemoryDirectionMask (options:direction) This nibble indicates the I/O direction to be associated with the descriptor, which may affect the operation of the prepare and complete methods on some architectures.
* kIOMemoryTypeMask (options:type) kIOMemoryTypeVirtual64, kIOMemoryTypeVirtual, kIOMemoryTypePhysical64, kIOMemoryTypePhysical, kIOMemoryTypeUPL Indicates that what type of memory basic memory descriptor to use. This sub-field also controls the interpretation of the buffers, count, offset & task parameters.
* kIOMemoryAsReference For options:type = Virtual or Physical this indicate that the memory descriptor need not copy the ranges array into local memory. This is an optimisation to try to minimise unnecessary allocations.
* kIOMemoryBufferPageable Only used by the IOBufferMemoryDescriptor as an indication that the kernel virtual memory is in fact pageable and we need to use the kernel pageable submap rather than the default map.
*
* @param mapper Which IOMapper should be used to map the in-memory physical addresses into I/O space addresses. Defaults to 0 which indicates that the system mapper is to be used, if present.
*
* @result The created IOMemoryDescriptor on success, to be released by the caller, or zero on failure. */
static OSPtr<IOMemoryDescriptor> withOptions(void * buffers,
UInt32 count,
UInt32 offset,
task_t task,
IOOptionBits options,
IOMapper * mapper = kIOMapperSystem);
#ifndef __LP64__
static OSPtr<IOMemoryDescriptor> withPhysicalRanges(
IOPhysicalRange * ranges,
UInt32 withCount,
IODirection withDirection,
bool asReference = false) APPLE_KEXT_DEPRECATED; /* use withOptions() and kIOMemoryTypePhysical instead */
#endif /* !__LP64__ */
#ifndef __LP64__
static OSPtr<IOMemoryDescriptor> withSubRange(IOMemoryDescriptor *of,
IOByteCount offset,
IOByteCount length,
IODirection withDirection) APPLE_KEXT_DEPRECATED; /* use IOSubMemoryDescriptor::withSubRange() and kIOMemoryThreadSafe instead */
#endif /* !__LP64__ */
/*! @function withPersistentMemoryDescriptor
* @abstract Copy constructor that generates a new memory descriptor if the backing memory for the same task's virtual address and length has changed.
* @discussion If the original memory descriptor's address and length is still backed by the same real memory, i.e. the user hasn't deallocated and the reallocated memory at the same address then the original memory descriptor is returned with a additional reference. Otherwise we build a totally new memory descriptor with the same characteristics as the previous one but with a new view of the vm. Note not legal to call this function with anything except an IOGeneralMemoryDescriptor that was created with the kIOMemoryPersistent option.
* @param originalMD The memory descriptor to be duplicated.
* @result Either the original memory descriptor with an additional retain or a new memory descriptor, 0 for a bad original memory descriptor or some other resource shortage. */
static OSPtr<IOMemoryDescriptor>
withPersistentMemoryDescriptor(IOMemoryDescriptor *originalMD);
#ifndef __LP64__
// obsolete initializers
// - initWithOptions is the designated initializer
virtual bool initWithAddress(void * address,
IOByteCount withLength,
IODirection withDirection) APPLE_KEXT_DEPRECATED; /* use initWithOptions() instead */
virtual bool initWithAddress(IOVirtualAddress address,
IOByteCount withLength,
IODirection withDirection,
task_t withTask) APPLE_KEXT_DEPRECATED; /* use initWithOptions() instead */
virtual bool initWithPhysicalAddress(
IOPhysicalAddress address,
IOByteCount withLength,
IODirection withDirection ) APPLE_KEXT_DEPRECATED; /* use initWithOptions() instead */
virtual bool initWithRanges(IOVirtualRange * ranges,
UInt32 withCount,
IODirection withDirection,
task_t withTask,
bool asReference = false) APPLE_KEXT_DEPRECATED; /* use initWithOptions() instead */
virtual bool initWithPhysicalRanges(IOPhysicalRange * ranges,
UInt32 withCount,
IODirection withDirection,
bool asReference = false) APPLE_KEXT_DEPRECATED; /* use initWithOptions() instead */
#endif /* __LP64__ */
/*! @function getDirection
* @abstract Accessor to get the direction the memory descriptor was created with.
* @discussion This method returns the direction the memory descriptor was created with.
* @result The direction. */
virtual IODirection getDirection() const;
/*! @function getLength
* @abstract Accessor to get the length of the memory descriptor (over all its ranges).
* @discussion This method returns the total length of the memory described by the descriptor, ie. the sum of its ranges' lengths.
* @result The byte count. */
virtual IOByteCount getLength() const;
#define IOMEMORYDESCRIPTOR_SUPPORTS_GETDMAMAPLENGTH
uint64_t getDMAMapLength(uint64_t * offset = NULL);
/*! @function setTag
* @abstract Set the tag for the memory descriptor.
* @discussion This method sets the tag for the memory descriptor. Tag bits are not interpreted by IOMemoryDescriptor.
* @param tag The tag. */
virtual void setTag( IOOptionBits tag );
/*! @function getTag
* @abstract Accessor to the retrieve the tag for the memory descriptor.
* @discussion This method returns the tag for the memory descriptor. Tag bits are not interpreted by IOMemoryDescriptor.
* @result The tag. */
virtual IOOptionBits getTag( void );
/*! @function getFlags
* @abstract Accessor to the retrieve the options the memory descriptor was created with.
* @discussion Accessor to the retrieve the options the memory descriptor was created with, and flags with its state. These bits are defined by the kIOMemory* enum.
* @result The flags bitfield. */
uint64_t getFlags(void);
/*! @function readBytes
* @abstract Copy data from the memory descriptor's buffer to the specified buffer.
* @discussion This method copies data from the memory descriptor's memory at the given offset, to the caller's buffer. The memory descriptor MUST have the kIODirectionOut direcction bit set and be prepared. kIODirectionOut means that this memory descriptor will be output to an external device, so readBytes is used to get memory into a local buffer for a PIO transfer to the device.
* @param offset A byte offset into the memory descriptor's memory.
* @param bytes The caller supplied buffer to copy the data to.
* @param withLength The length of the data to copy.
* @result The number of bytes copied, zero will be returned if the specified offset is beyond the length of the descriptor. Development/debug kernel builds will assert if the offset is beyond the length of the descriptor. */
virtual IOByteCount readBytes(IOByteCount offset,
void * bytes, IOByteCount withLength);
/*! @function writeBytes
* @abstract Copy data to the memory descriptor's buffer from the specified buffer.
* @discussion This method copies data to the memory descriptor's memory at the given offset, from the caller's buffer. The memory descriptor MUST have the kIODirectionIn direcction bit set and be prepared. kIODirectionIn means that this memory descriptor will be input from an external device, so writeBytes is used to write memory into the descriptor for PIO drivers.
* @param offset A byte offset into the memory descriptor's memory.
* @param bytes The caller supplied buffer to copy the data from.
* @param withLength The length of the data to copy.
* @result The number of bytes copied, zero will be returned if the specified offset is beyond the length of the descriptor. Development/debug kernel builds will assert if the offset is beyond the length of the descriptor. */
virtual IOByteCount writeBytes(IOByteCount offset,
const void * bytes, IOByteCount withLength);
#ifndef __LP64__
virtual IOPhysicalAddress getPhysicalSegment(IOByteCount offset,
IOByteCount * length);
#endif /* !__LP64__ */
/*! @function getPhysicalAddress
* @abstract Return the physical address of the first byte in the memory.
* @discussion This method returns the physical address of the first byte in the memory. It is most useful on memory known to be physically contiguous.
* @result A physical address. */
IOPhysicalAddress getPhysicalAddress();
#ifndef __LP64__
virtual void * getVirtualSegment(IOByteCount offset,
IOByteCount * length) APPLE_KEXT_DEPRECATED; /* use map() and getVirtualAddress() instead */
#endif /* !__LP64__ */
/*! @function prepare
* @abstract Prepare the memory for an I/O transfer.
* @discussion This involves paging in the memory, if necessary, and wiring it down for the duration of the transfer. The complete() method completes the processing of the memory after the I/O transfer finishes. Note that the prepare call is not thread safe and it is expected that the client will more easily be able to guarantee single threading a particular memory descriptor.
* @param forDirection The direction of the I/O just completed, or kIODirectionNone for the direction specified by the memory descriptor.
* @result An IOReturn code. */
virtual IOReturn prepare(IODirection forDirection = kIODirectionNone) = 0;
/*! @function complete
* @abstract Complete processing of the memory after an I/O transfer finishes.
* @discussion This method should not be called unless a prepare was previously issued; the prepare() and complete() must occur in pairs, before and after an I/O transfer involving pageable memory. In 10.3 or greater systems the direction argument to complete is not longer respected. The direction is totally determined at prepare() time.
* @param forDirection DEPRECATED The direction of the I/O just completed, or kIODirectionNone for the direction specified by the memory descriptor.
* @result An IOReturn code. */
virtual IOReturn complete(IODirection forDirection = kIODirectionNone) = 0;
/*
* Mapping functions.
*/
/*! @function createMappingInTask
* @abstract Maps a IOMemoryDescriptor into a task.
* @discussion This is the general purpose method to map all or part of the memory described by a memory descriptor into a task at any available address, or at a fixed address if possible. Caching & read-only options may be set for the mapping. The mapping is represented as a returned reference to a IOMemoryMap object, which may be shared if the mapping is compatible with an existing mapping of the IOMemoryDescriptor. The IOMemoryMap object returned should be released only when the caller has finished accessing the mapping, as freeing the object destroys the mapping.
* @param intoTask Sets the target task for the mapping. Pass kernel_task for the kernel address space.
* @param atAddress If a placed mapping is requested, atAddress specifies its address, and the kIOMapAnywhere should not be set. Otherwise, atAddress is ignored.
* @param options Mapping options are defined in IOTypes.h,<br>
* kIOMapAnywhere should be passed if the mapping can be created anywhere. If not set, the atAddress parameter sets the location of the mapping, if it is available in the target map.<br>
* kIOMapDefaultCache to inhibit the cache in I/O areas, kIOMapCopybackCache in general purpose RAM.<br>
* kIOMapInhibitCache, kIOMapWriteThruCache, kIOMapCopybackCache to set the appropriate caching.<br>
* kIOMapReadOnly to allow only read only accesses to the memory - writes will cause and access fault.<br>
* kIOMapReference will only succeed if the mapping already exists, and the IOMemoryMap object is just an extra reference, ie. no new mapping will be created.<br>
* kIOMapUnique allows a special kind of mapping to be created that may be used with the IOMemoryMap::redirect() API. These mappings will not be shared as is the default - there will always be a unique mapping created for the caller, not an existing mapping with an extra reference.<br>
* kIOMapPrefault will try to prefault the pages corresponding to the mapping. This must not be done on the kernel task, and the memory must have been wired via prepare(). Otherwise, the function will fail.<br>
* @param offset Is a beginning offset into the IOMemoryDescriptor's memory where the mapping starts. Zero is the default to map all the memory.
* @param length Is the length of the mapping requested for a subset of the IOMemoryDescriptor. Zero is the default to map all the memory.
* @result A reference to an IOMemoryMap object representing the mapping, which can supply the virtual address of the mapping and other information. The mapping may be shared with multiple callers - multiple maps are avoided if a compatible one exists. The IOMemoryMap object returned should be released only when the caller has finished accessing the mapping, as freeing the object destroys the mapping. The IOMemoryMap instance also retains the IOMemoryDescriptor it maps while it exists. */
OSPtr<IOMemoryMap> createMappingInTask(
task_t intoTask,
mach_vm_address_t atAddress,
IOOptionBits options,
mach_vm_size_t offset = 0,
mach_vm_size_t length = 0 );
#ifndef __LP64__
virtual OSPtr<IOMemoryMap> map(
task_t intoTask,
IOVirtualAddress atAddress,
IOOptionBits options,
IOByteCount offset = 0,
IOByteCount length = 0 ) APPLE_KEXT_DEPRECATED;/* use createMappingInTask() instead */
#endif /* !__LP64__ */
/*! @function map
* @abstract Maps a IOMemoryDescriptor into the kernel map.
* @discussion This is a shortcut method to map all the memory described by a memory descriptor into the kernel map at any available address. See the full version of the createMappingInTask method for further details.
* @param options Mapping options as in the full version of the createMappingInTask method, with kIOMapAnywhere assumed.
* @result See the full version of the createMappingInTask method. */
virtual OSPtr<IOMemoryMap> map(
IOOptionBits options = 0 );
/*! @function setMapping
* @abstract Establishes an already existing mapping.
* @discussion This method tells the IOMemoryDescriptor about a mapping that exists, but was created elsewhere. It allows later callers of the map method to share this externally created mapping. The IOMemoryMap object returned is created to represent it. This method is not commonly needed.
* @param task Address space in which the mapping exists.
* @param mapAddress Virtual address of the mapping.
* @param options Caching and read-only attributes of the mapping.
* @result A IOMemoryMap object created to represent the mapping. */
virtual OSPtr<IOMemoryMap> setMapping(
task_t task,
IOVirtualAddress mapAddress,
IOOptionBits options = 0 );
// Following methods are private implementation
#ifdef __LP64__
virtual
#endif /* __LP64__ */
IOReturn redirect( task_t safeTask, bool redirect );
IOReturn handleFault(
void * _pager,
mach_vm_size_t sourceOffset,
mach_vm_size_t length);
IOReturn populateDevicePager(
void * pager,
vm_map_t addressMap,
mach_vm_address_t address,
mach_vm_size_t sourceOffset,
mach_vm_size_t length,
IOOptionBits options );
virtual LIBKERN_RETURNS_NOT_RETAINED IOMemoryMap * makeMapping(
IOMemoryDescriptor * owner,
task_t intoTask,
IOVirtualAddress atAddress,
IOOptionBits options,
IOByteCount offset,
IOByteCount length );
protected:
virtual void addMapping(
IOMemoryMap * mapping );
virtual void removeMapping(
IOMemoryMap * mapping );
virtual IOReturn doMap(
vm_map_t addressMap,
IOVirtualAddress * atAddress,
IOOptionBits options,
IOByteCount sourceOffset = 0,
IOByteCount length = 0 );
virtual IOReturn doUnmap(
vm_map_t addressMap,
IOVirtualAddress logical,
IOByteCount length );
};
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*! @class IOMemoryMap : public OSObject
* @abstract A class defining common methods for describing a memory mapping.
* @discussion The IOMemoryMap object represents a mapped range of memory, described by a IOMemoryDescriptor. The mapping may be in the kernel or a non-kernel task and has processor cache mode attributes. IOMemoryMap instances are created by IOMemoryDescriptor when it creates mappings in its map method, and returned to the caller. */
class IOMemoryMap : public OSObject
{
OSDeclareDefaultStructorsWithDispatch(IOMemoryMap);
protected:
virtual void taggedRelease(const void *tag = NULL) const APPLE_KEXT_OVERRIDE;
virtual void free(void) APPLE_KEXT_OVERRIDE;
public:
/*! @function getVirtualAddress
* @abstract Accessor to the virtual address of the first byte in the mapping.
* @discussion This method returns the virtual address of the first byte in the mapping. Since the IOVirtualAddress is only 32bit in 32bit kernels, the getAddress() method should be used for compatibility with 64bit task mappings.
* @result A virtual address. */
virtual IOVirtualAddress getVirtualAddress(void);
/*! @function getPhysicalSegment
* @abstract Break a mapping into its physically contiguous segments.
* @discussion This method returns the physical address of the byte at the given offset into the mapping, and optionally the length of the physically contiguous segment from that offset. It functions similarly to IOMemoryDescriptor::getPhysicalSegment.
* @param offset A byte offset into the mapping whose physical address to return.
* @param length If non-zero, getPhysicalSegment will store here the length of the physically contiguous segement at the given offset.
* @result A physical address, or zero if the offset is beyond the length of the mapping. */
#ifdef __LP64__
virtual IOPhysicalAddress getPhysicalSegment(IOByteCount offset,
IOByteCount * length,
IOOptionBits options = 0);
#else /* !__LP64__ */
virtual IOPhysicalAddress getPhysicalSegment(IOByteCount offset,
IOByteCount * length);
#endif /* !__LP64__ */
/*! @function getPhysicalAddress
* @abstract Return the physical address of the first byte in the mapping.
* @discussion This method returns the physical address of the first byte in the mapping. It is most useful on mappings known to be physically contiguous.
* @result A physical address. */
IOPhysicalAddress getPhysicalAddress(void);
/*! @function getLength
* @abstract Accessor to the length of the mapping.
* @discussion This method returns the length of the mapping.
* @result A byte count. */
virtual IOByteCount getLength(void);
/*! @function getAddressTask
* @abstract Accessor to the task of the mapping.
* @discussion This method returns the mach task the mapping exists in.
* @result A mach task_t. */
virtual task_t getAddressTask();
/*! @function getMemoryDescriptor
* @abstract Accessor to the IOMemoryDescriptor the mapping was created from.
* @discussion This method returns the IOMemoryDescriptor the mapping was created from.
* @result An IOMemoryDescriptor reference, which is valid while the IOMemoryMap object is retained. It should not be released by the caller. */
virtual IOMemoryDescriptor * getMemoryDescriptor();
/*! @function getMapOptions
* @abstract Accessor to the options the mapping was created with.
* @discussion This method returns the options to IOMemoryDescriptor::map the mapping was created with.
* @result Options for the mapping, including cache settings. */
virtual IOOptionBits getMapOptions();
/*! @function unmap
* @abstract Force the IOMemoryMap to unmap, without destroying the object.
* @discussion IOMemoryMap instances will unmap themselves upon free, ie. when the last client with a reference calls release. This method forces the IOMemoryMap to destroy the mapping it represents, regardless of the number of clients. It is not generally used.
* @result An IOReturn code. */
virtual IOReturn unmap();
virtual void taskDied();
/*! @function redirect
* @abstract Replace the memory mapped in a process with new backing memory.
* @discussion An IOMemoryMap created with the kIOMapUnique option to IOMemoryDescriptor::map() can remapped to a new IOMemoryDescriptor backing object. If the new IOMemoryDescriptor is specified as NULL, client access to the memory map is blocked until a new backing object has been set. By blocking access and copying data, the caller can create atomic copies of the memory while the client is potentially reading or writing the memory.
* @param newBackingMemory The IOMemoryDescriptor that represents the physical memory that is to be now mapped in the virtual range the IOMemoryMap represents. If newBackingMemory is NULL, any access to the mapping will hang (in vm_fault()) until access has been restored by a new call to redirect() with non-NULL newBackingMemory argument.
* @param options Mapping options are defined in IOTypes.h, and are documented in IOMemoryDescriptor::map()
* @param offset As with IOMemoryDescriptor::map(), a beginning offset into the IOMemoryDescriptor's memory where the mapping starts. Zero is the default.
* @result An IOReturn code. */
#ifndef __LP64__
// For 32 bit XNU, there is a 32 bit (IOByteCount) and a 64 bit (mach_vm_size_t) interface;
// for 64 bit, these fall together on the 64 bit one.
virtual IOReturn redirect(IOMemoryDescriptor * newBackingMemory,
IOOptionBits options,
IOByteCount offset = 0);
#endif
virtual IOReturn redirect(IOMemoryDescriptor * newBackingMemory,
IOOptionBits options,
mach_vm_size_t offset = 0);
#ifdef __LP64__
/*! @function getAddress
* @abstract Accessor to the virtual address of the first byte in the mapping.
* @discussion This method returns the virtual address of the first byte in the mapping.
* @result A virtual address. */
inline mach_vm_address_t getAddress() __attribute__((always_inline));
/*! @function getSize
* @abstract Accessor to the length of the mapping.
* @discussion This method returns the length of the mapping.
* @result A byte count. */
inline mach_vm_size_t getSize() __attribute__((always_inline));
#else /* !__LP64__ */
/*! @function getAddress
* @abstract Accessor to the virtual address of the first byte in the mapping.
* @discussion This method returns the virtual address of the first byte in the mapping.
* @result A virtual address. */
virtual mach_vm_address_t getAddress();
/*! @function getSize
* @abstract Accessor to the length of the mapping.
* @discussion This method returns the length of the mapping.
* @result A byte count. */
virtual mach_vm_size_t getSize();
#endif /* !__LP64__ */
IOReturn wireRange(
uint32_t options,
mach_vm_size_t offset,
mach_vm_size_t length);
OSMetaClassDeclareReservedUnused(IOMemoryMap, 0);
OSMetaClassDeclareReservedUnused(IOMemoryMap, 1);
OSMetaClassDeclareReservedUnused(IOMemoryMap, 2);
OSMetaClassDeclareReservedUnused(IOMemoryMap, 3);
OSMetaClassDeclareReservedUnused(IOMemoryMap, 4);
OSMetaClassDeclareReservedUnused(IOMemoryMap, 5);
OSMetaClassDeclareReservedUnused(IOMemoryMap, 6);
OSMetaClassDeclareReservedUnused(IOMemoryMap, 7);
};
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
// The following classes are private implementation of IOMemoryDescriptor - they
// should not be referenced directly, just through the public API's in the
// IOMemoryDescriptor class. For example, an IOGeneralMemoryDescriptor instance
// might be created by IOMemoryDescriptor::withAddressRange(), but there should be
// no need to reference as anything but a generic IOMemoryDescriptor *.
class IOGeneralMemoryDescriptor : public IOMemoryDescriptor
{
OSDeclareDefaultStructors(IOGeneralMemoryDescriptor);
public:
union Ranges {
IOVirtualRange *v;
IOAddressRange *v64;
IOPhysicalRange *p;
void *uio;
};
protected:
Ranges _ranges;
unsigned _rangesCount; /* number of address ranges in list */
#ifndef __LP64__
bool _rangesIsAllocated;/* is list allocated by us? */
#endif /* !__LP64__ */
task_t _task; /* task where all ranges are mapped to */
union {
IOVirtualRange v;
IOPhysicalRange p;
} _singleRange; /* storage space for a single range */
unsigned _wireCount; /* number of outstanding wires */
#ifndef __LP64__
uintptr_t _cachedVirtualAddress;
IOPhysicalAddress _cachedPhysicalAddress;
#endif /* !__LP64__ */
bool _initialized; /* has superclass been initialized? */
public:
virtual void free() APPLE_KEXT_OVERRIDE;
virtual IOReturn dmaCommandOperation(DMACommandOps op, void *vData, UInt dataSize) const APPLE_KEXT_OVERRIDE;
virtual uint64_t getPreparationID( void ) APPLE_KEXT_OVERRIDE;
private:
#ifndef __LP64__
virtual void setPosition(IOByteCount position);
virtual void mapIntoKernel(unsigned rangeIndex);
virtual void unmapFromKernel();
#endif /* !__LP64__ */
// Internal
OSPtr<_IOMemoryDescriptorMixedData> _memoryEntries;
unsigned int _pages;
ppnum_t _highestPage;
uint32_t __iomd_reservedA;
uint32_t __iomd_reservedB;
IOLock * _prepareLock;
public:
/*
* IOMemoryDescriptor required methods
*/
// Master initaliser
virtual bool initWithOptions(void * buffers,
UInt32 count,
UInt32 offset,
task_t task,
IOOptionBits options,
IOMapper * mapper = kIOMapperSystem) APPLE_KEXT_OVERRIDE;
#ifndef __LP64__
// Secondary initialisers
virtual bool initWithAddress(void * address,
IOByteCount withLength,
IODirection withDirection) APPLE_KEXT_OVERRIDE APPLE_KEXT_DEPRECATED;
virtual bool initWithAddress(IOVirtualAddress address,
IOByteCount withLength,
IODirection withDirection,
task_t withTask) APPLE_KEXT_OVERRIDE APPLE_KEXT_DEPRECATED;
virtual bool initWithPhysicalAddress(
IOPhysicalAddress address,
IOByteCount withLength,
IODirection withDirection ) APPLE_KEXT_OVERRIDE APPLE_KEXT_DEPRECATED;
virtual bool initWithRanges( IOVirtualRange * ranges,
UInt32 withCount,
IODirection withDirection,
task_t withTask,
bool asReference = false) APPLE_KEXT_OVERRIDE APPLE_KEXT_DEPRECATED;
virtual bool initWithPhysicalRanges(IOPhysicalRange * ranges,
UInt32 withCount,
IODirection withDirection,
bool asReference = false) APPLE_KEXT_OVERRIDE APPLE_KEXT_DEPRECATED;
virtual addr64_t getPhysicalSegment64( IOByteCount offset,
IOByteCount * length ) APPLE_KEXT_OVERRIDE APPLE_KEXT_DEPRECATED;
virtual IOPhysicalAddress getPhysicalSegment(IOByteCount offset,
IOByteCount * length) APPLE_KEXT_OVERRIDE;
virtual IOPhysicalAddress getSourceSegment(IOByteCount offset,
IOByteCount * length) APPLE_KEXT_OVERRIDE APPLE_KEXT_DEPRECATED;
virtual void * getVirtualSegment(IOByteCount offset,
IOByteCount * length) APPLE_KEXT_OVERRIDE APPLE_KEXT_DEPRECATED;
#endif /* !__LP64__ */
virtual IOReturn setPurgeable( IOOptionBits newState,
IOOptionBits * oldState ) APPLE_KEXT_OVERRIDE;
IOReturn setOwnership( task_t newOwner,
int newLedgerTag,
IOOptionBits newLedgerOptions );
virtual addr64_t getPhysicalSegment( IOByteCount offset,
IOByteCount * length,
#ifdef __LP64__
IOOptionBits options = 0 ) APPLE_KEXT_OVERRIDE;
#else /* !__LP64__ */
IOOptionBits options)APPLE_KEXT_OVERRIDE;
#endif /* !__LP64__ */
virtual IOReturn prepare(IODirection forDirection = kIODirectionNone) APPLE_KEXT_OVERRIDE;
virtual IOReturn complete(IODirection forDirection = kIODirectionNone) APPLE_KEXT_OVERRIDE;
virtual IOReturn doMap(
vm_map_t addressMap,
IOVirtualAddress * atAddress,
IOOptionBits options,
IOByteCount sourceOffset = 0,
IOByteCount length = 0 ) APPLE_KEXT_OVERRIDE;
virtual IOReturn doUnmap(
vm_map_t addressMap,
IOVirtualAddress logical,
IOByteCount length ) APPLE_KEXT_OVERRIDE;
virtual bool serialize(OSSerialize *s) const APPLE_KEXT_OVERRIDE;
// Factory method for cloning a persistent IOMD, see IOMemoryDescriptor
static OSPtr<IOMemoryDescriptor>
withPersistentMemoryDescriptor(IOGeneralMemoryDescriptor *originalMD);
};
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifdef __LP64__
mach_vm_address_t
IOMemoryMap::getAddress()
{
return getVirtualAddress();
}
mach_vm_size_t
IOMemoryMap::getSize()
{
return getLength();
}
#else /* !__LP64__ */
#include <IOKit/IOSubMemoryDescriptor.h>
#endif /* !__LP64__ */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
extern bool iokit_iomd_setownership_enabled;
#endif /* !_IOMEMORYDESCRIPTOR_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOInterrupts.h | /*
* Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
*
* DRI: Josh de Cesare
*
*/
#ifndef _IOKIT_IOINTERRUPTS_H
#define _IOKIT_IOINTERRUPTS_H
#define kIOInterruptTypeEdge (0)
#define kIOInterruptTypeLevel (1)
#ifdef __cplusplus
class OSData;
class IOInterruptController;
struct IOInterruptSource {
IOInterruptController *interruptController;
OSData *vectorData;
};
typedef struct IOInterruptSource IOInterruptSource;
#endif /* __cplusplus */
typedef void (*IOInterruptHandler)(void *target, void *refCon,
void *nub, int source);
#endif /* ! _IOKIT_IOINTERRUPTS_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOCatalogue.h | /*
* Copyright (c) 1998-2019 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* Copyright (c) 1998 Apple Inc. All rights reserved.
*
* HISTORY
*
*/
#ifndef _IOKIT_IOCATALOGUE_H
#define _IOKIT_IOCATALOGUE_H
#include <libkern/c++/OSPtr.h>
#include <libkern/c++/OSObject.h>
#include <libkern/c++/OSCollectionIterator.h>
#include <libkern/c++/OSArray.h>
#include <libkern/c++/OSDictionary.h>
#include <IOKit/IOLocks.h>
#include <sys/cdefs.h>
#include <IOKit/IOKitServer.h>
class IOService;
extern OSPtr<const OSSymbol> gIOModuleIdentifierKey;
extern OSPtr<const OSSymbol> gIOModuleIdentifierKernelKey;
/*!
* @class IOCatalogue
* @abstract In-kernel database for IOKit driver personalities.
* @discussion The IOCatalogue is a database which contains all IOKit driver personalities. IOService uses this resource when matching devices to their associated drivers.
*/
class IOCatalogue : public OSObject
{
OSDeclareDefaultStructors(IOCatalogue);
private:
IORWLock * lock;
SInt32 generation;
OSPtr<OSDictionary> personalities;
OSArray * arrayForPersonality(OSDictionary * dict);
void addPersonality(OSDictionary * dict);
public:
/*!
* @function initialize
* @abstract Creates and initializes the database object and poputates it with in-kernel driver personalities.
*/
static void initialize( void );
/*!
* @function init
* @abstract Initializes the database object.
* @param initArray The initial array of driver personalities to populate the database.
*/
bool init( OSArray * initArray );
/*!
* @function free
* @abstract Cleans up the database and deallocates memory allocated at initialization. This is never called in normal operation of the system.
*/
void free( void ) APPLE_KEXT_OVERRIDE;
/*!
* @function findDrivers
* @abstract This is the primary entry point for IOService.
* @param service The service
* @param generationCount Returns a reference to the generation count of the database. The generation count increases only when personalities are added to the database *and* IOService matching has been initiated.
* @result Returns an ordered set of driver personalities ranked on probe-scores. The ordered set must be released by the receiver.
*/
OSPtr<OSOrderedSet> findDrivers( IOService * service, SInt32 * generationCount );
/*!
* @function findDrivers
* @abstract A more general purpose interface which allows one to retreive driver personalities based the intersection of the 'matching' dictionary and the personality's own property list.
* @param matching A dictionary containing only keys and values which are to be used for matching. For example, a matching dictionary containing 'IOProviderClass'='IOPCIDevice' will return all personalities with an IOProviderClass key and a value of IOPCIDevice.
* @param generationCount Returns a reference to the current generation of the database. The generation count increases only when personalities are added to the database *and* IOService matching has been initiated.
* @result Returns an ordered set of driver personalities ranked on probe-scores. The ordered set must be released by the receiver.
*/
OSPtr<OSOrderedSet> findDrivers( OSDictionary * matching, SInt32 * generationCount );
/*!
* @function addDrivers
* @abstract Adds an array of driver personalities to the database.
* @param array Array of driver personalities to be added to the database.
* @param doNubMatching Start matching process after personalities have been added.
* @result Returns true if driver personality was added to the database successfully. Failure is due to a memory allocation failure.
*/
bool addDrivers( OSArray * array, bool doNubMatching = true );
/*!
* @function removeDrivers
* @abstract Remove driver personalities from the database based on matching information provided.
* @param matching A dictionary whose keys and values are used for matching personalities in the database. For example, a matching dictionary containing a 'IOProviderClass' key with the value 'IOPCIDevice' will remove all personalities which have the key 'IOProviderClass' equal to 'IOPCIDevice'.
* @param doNubMatching Start matching process after personalities have been removed. Matching criteria is based on IOProviderClass of those personalities which were removed. This is to allow drivers which haven't been matched to match against NUB's which were blocked by the previous personalities.
* @result Returns true if personality was removed successfully. Failure is due to a memory allocation failure.
*/
bool removeDrivers( OSDictionary * matching, bool doNubMatching = true );
/*!
* @function getGenerationCount
* @abstract Get the current generation count of the database.
*/
SInt32 getGenerationCount( void ) const;
/*!
* @function isModuleLoaded
* @abstract Reports if a kernel module has been loaded for a particular personality.
* @param driver A driver personality's property list.
* @param kextRef A reference to the kext getting loaded.
* @result Returns true if the associated kernel module has been loaded into the kernel for a particular driver personality on which it depends.
*/
bool isModuleLoaded( OSDictionary * driver, OSObject ** kextRef ) const;
bool isModuleLoaded( OSDictionary * driver, OSSharedPtr<OSObject>& kextRef ) const;
/*!
* @function moduleHasLoaded
* @abstract Callback function called after a IOKit dependent kernel module is loaded.
* @param name Name of the kernel module.
*/
void moduleHasLoaded( const OSSymbol * name );
/*!
* @function moduleHasLoaded
* @abstract Callback function called after a IOKit dependent kernel module is loaded.
* @param name Name of the kernel module.
*/
void moduleHasLoaded( const char * name );
/*!
* @function personalityIsBoot
*/
bool personalityIsBoot(OSDictionary * match);
/*!
* @function terminateDrivers
* @abstract Terminates all instances of a driver which match the contents of the matching dictionary. Does not unload module.
* @param matching A dictionary whose keys and values are used for matching personalities in the database. For example, a matching dictionary containing a 'IOProviderClass' key with the value 'IOPCIDevice' will cause termination for all instances whose personalities have the key 'IOProviderClass' equal to 'IOPCIDevice'.
*/
IOReturn terminateDrivers( OSDictionary * matching );
/*!
* @function terminateDriversForModule
* @abstract Terminates all instances of a driver which depends on a particular module and unloads the module.
* @param moduleName Name of the module which is used to determine which driver instances to terminate and unload.
* @param unload Flag to cause the actual unloading of the module.
*/
IOReturn terminateDriversForModule( OSString * moduleName, bool unload = true);
/*!
* @function terminateDriversForModule
* @abstract Terminates all instances of a driver which depends on a particular module and unloads the module.
* @param moduleName Name of the module which is used to determine which driver instances to terminate and unload.
* @param unload Flag to cause the actual unloading of the module.
*/
IOReturn terminateDriversForModule( const char * moduleName, bool unload = true);
/*!
* @function startMatching
* @abstract Restarts IOService matching.
* @param identifier All IOService objects with this bundle indentifier are rematched.
*/
bool startMatching( const OSSymbol * identifier );
// deprecated, for bin compat
#if defined(__i386__) || defined(__x86_64__)
bool startMatching( OSDictionary * matching );
#endif
/*!
* @function reset
* @abstract Return the Catalogue to its initial state.
* @discussion
* Should only be used by kextd just before it sends all kext personalities down during a rescan.
*/
void reset(void);
/*!
* @function resetAndAddDrivers
* @abstract Replace personalities in IOCatalog with those provided.
* @discussion
* Resets the catalogue with a new set of drivers, preserving matching originals to keep wired memory usage down.
*/
bool resetAndAddDrivers(OSArray * drivers, bool doNubMatching = true);
/*!
* @function serialize
* @abstract Serializes the catalog for transport to the user.
* @param s The serializer object.
* @result Returns false if unable to serialize database, most likely due to memory shortage.
*/
virtual bool serialize(OSSerialize * s) const APPLE_KEXT_OVERRIDE;
bool serializeData(IOOptionBits kind, OSSerialize * s) const;
/* This stuff is no longer used at all we keep it around for i386
* binary compatibility only. Symbols are no longer exported.
*/
private:
/*!
* @function unloadModule
* @abstract Unloads the reqested module if no driver instances are currently depending on it.
* @param moduleName An OSString containing the name of the module to unload.
*/
IOReturn unloadModule( OSString * moduleName ) const;
IOReturn _removeDrivers(OSDictionary * matching);
};
extern OSPtr<const OSSymbol> gIOClassKey;
extern OSPtr<const OSSymbol> gIOProbeScoreKey;
extern OSPtr<IOCatalogue> gIOCatalogue;
#endif /* ! _IOKIT_IOCATALOGUE_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOFilterInterruptEventSource.h | /*
* Copyright (c) 1998-2019 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
*
* HISTORY
* 1999-4-15 Godfrey van der Linden(gvdl)
* Created.
*/
#ifndef _IOKIT_IOFILTERINTERRUPTEVENTSOURCE_H
#define _IOKIT_IOFILTERINTERRUPTEVENTSOURCE_H
#include <libkern/c++/OSPtr.h>
#include <IOKit/IOInterruptEventSource.h>
#include <libkern/c++/OSPtr.h>
class IOService;
/*! @class IOFilterInterruptEventSource : public IOInterruptEventSource
* @abstract Filtering varient of the $link IOInterruptEventSource.
* @discussion An interrupt event source that calls the client to determine if a interrupt event needs to be scheduled on the work loop. A filter interrupt event source call's the client in the primary interrupt context, the client can then interrogate its hardware and determine if the interrupt needs to be processed yet.
* <br><br>
* As the routine is called in the primary interrupt context great care must be taken in the writing of this routine. In general none of the generic IOKit environment is safe to call in this context. We intend this routine to be used by hardware that can interrogate its registers without destroying state. Primarily this variant of event sources will be used by drivers that share interrupts. The filter routine will determine if the interrupt is a real interrupt or a ghost and thus optimise the work thread context switch away.
* <br><br>
* If you are implementing 'SoftDMA' (or pseudo-DMA), you may not want the I/O Kit to automatically start your interrupt handler routine on your work loop when your filter routine returns true. In this case, you may choose to have your filter routine schedule the work on the work loop itself and then return false. If you do this, the interrupt will not be disabled in hardware and you could receive additional primary interrupts before your work loop–level service routine completes. Because this scheme has implications for synchronization between your filter routine and your interrupt service routine, you should avoid doing this unless your driver requires SoftDMA.
* <br><br>
* CAUTION: Called in primary interrupt context, if you need to disable interrupt to guard you registers against an unexpected call then it is better to use a straight IOInterruptEventSource and its secondary interrupt delivery mechanism.
*/
class IOFilterInterruptEventSource : public IOInterruptEventSource
{
OSDeclareDefaultStructors(IOFilterInterruptEventSource);
public:
/*!
* @typedef Filter
* @discussion C Function pointer to a routine to call when an interrupt occurs.
* @param owner Pointer to the owning/client instance.
* @param sender Where is the interrupt comming from.
* @result false if this interrupt can be ignored. */
typedef bool (*Filter)(OSObject *owner, IOFilterInterruptEventSource *sender);
/*! @defined IOFilterInterruptAction
* @discussion Backward compatibilty define for the old non-class scoped type definition. See $link IOFilterInterruptSource::Filter */
#define IOFilterInterruptAction IOFilterInterruptEventSource::Filter
#ifdef __BLOCKS__
typedef bool (^FilterBlock)(IOFilterInterruptEventSource *sender);
#endif /* __BLOCKS__ */
private:
// Hide the superclass initializers
virtual bool init(OSObject *inOwner,
IOInterruptEventSource::Action inAction = NULL,
IOService *inProvider = NULL,
int inIntIndex = 0) APPLE_KEXT_OVERRIDE;
static OSPtr<IOInterruptEventSource>
interruptEventSource(OSObject *inOwner,
IOInterruptEventSource::Action inAction = NULL,
IOService *inProvider = NULL,
int inIntIndex = 0);
protected:
/*! @var filterAction Filter callout */
Filter filterAction;
/*! @struct ExpansionData
* @discussion This structure will be used to expand the capablilties of the IOWorkLoop in the future.
*/
struct ExpansionData { };
/*! @var reserved
* Reserved for future use. (Internal use only) */
APPLE_KEXT_WSHADOW_PUSH;
ExpansionData *reserved;
APPLE_KEXT_WSHADOW_POP;
public:
/*! @function filterInterruptEventSource
* @abstract Factor method to create and initialise an IOFilterInterruptEventSource. See $link init.
* @param owner Owner/client of this event source.
* @param action 'C' Function to call when something happens.
* @param filter 'C' Function to call when interrupt occurs.
* @param provider Service that provides interrupts.
* @param intIndex Defaults to 0.
* @result a new event source if succesful, 0 otherwise. */
static OSPtr<IOFilterInterruptEventSource>
filterInterruptEventSource(OSObject *owner,
IOInterruptEventSource::Action action,
Filter filter,
IOService *provider,
int intIndex = 0);
#ifdef __BLOCKS__
/*! @function filterInterruptEventSource
* @abstract Factor method to create and initialise an IOFilterInterruptEventSource. See $link init.
* @param owner Owner/client of this event source.
* @param provider Service that provides interrupts.
* @param intIndex The index of the interrupt within the provider's interrupt sources.
* @param action Block for the callout routine of this event source.
* @param filter Block to invoke when HW interrupt occurs.
* @result a new event source if succesful, 0 otherwise. */
static OSPtr<IOFilterInterruptEventSource>
filterInterruptEventSource(OSObject *owner,
IOService *provider,
int intIndex,
IOInterruptEventSource::ActionBlock action,
FilterBlock filter);
#endif /* __BLOCKS__ */
/*! @function init
* @abstract Primary initialiser for the IOFilterInterruptEventSource class.
* @param owner Owner/client of this event source.
* @param action 'C' Function to call when something happens.
* @param filter 'C' Function to call in primary interrupt context.
* @param provider Service that provides interrupts.
* @param intIndex Interrupt source within provider. Defaults to 0.
* @result true if the inherited classes and this instance initialise
* successfully. */
virtual bool init(OSObject *owner,
IOInterruptEventSource::Action action,
Filter filter,
IOService *provider,
int intIndex = 0);
virtual void free( void ) APPLE_KEXT_OVERRIDE;
/*! @function signalInterrupt
* @abstract Cause the work loop to schedule the action.
* @discussion Cause the work loop to schedule the interrupt action even if the filter routine returns 'false'. Note well the interrupting condition MUST be cleared from the hardware otherwise an infinite process interrupt loop will occur. Use this function when SoftDMA is desired. See $link IOFilterInterruptSource::Filter */
virtual void signalInterrupt();
/*! @function getFilterAction
* @abstract Get'ter for filterAction variable.
* @result value of filterAction. */
virtual Filter getFilterAction() const;
#ifdef __BLOCKS__
/*! @function getFilterActionBlock
* @abstract Get'ter for filterAction variable.
* @result value of filterAction. */
FilterBlock getFilterActionBlock() const;
#endif /* __BLOCKS__ */
/*! @function normalInterruptOccurred
* @abstract Override $link IOInterruptEventSource::normalInterruptOccured to make a filter callout. */
virtual void normalInterruptOccurred(void *self, IOService *prov, int ind) APPLE_KEXT_OVERRIDE;
/*! @function disableInterruptOccurred
* @abstract Override $link IOInterruptEventSource::disableInterruptOccurred to make a filter callout. */
virtual void disableInterruptOccurred(void *self, IOService *prov, int ind) APPLE_KEXT_OVERRIDE;
private:
OSMetaClassDeclareReservedUnused(IOFilterInterruptEventSource, 0);
OSMetaClassDeclareReservedUnused(IOFilterInterruptEventSource, 1);
OSMetaClassDeclareReservedUnused(IOFilterInterruptEventSource, 2);
OSMetaClassDeclareReservedUnused(IOFilterInterruptEventSource, 3);
OSMetaClassDeclareReservedUnused(IOFilterInterruptEventSource, 4);
OSMetaClassDeclareReservedUnused(IOFilterInterruptEventSource, 5);
OSMetaClassDeclareReservedUnused(IOFilterInterruptEventSource, 6);
OSMetaClassDeclareReservedUnused(IOFilterInterruptEventSource, 7);
};
#endif /* !_IOKIT_IOFILTERINTERRUPTEVENTSOURCE_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/assert.h | /*
* Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _IO_ASSERT_H_
#define _IO_ASSERT_H_
#include <sys/cdefs.h>
#ifdef __cplusplus
extern "C" {
#endif
#if IOASSERT
#undef MACH_ASSERT
#define MACH_ASSERT 1
#endif
#include <kern/assert.h>
#ifdef __cplusplus
}
#endif
#if(!defined(OSCompileAssert))
# define OSCompileAssert( TEST ) \
extern int OSCompileAssertFailed[ ( TEST ) ? 1 : -1 ] __unused;
#endif
#endif /* _IO_ASSERT_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IODeviceMemory.h | /*
* Copyright (c) 1998-2019 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* Copyright (c) 1998 Apple Computer, Inc. All rights reserved.
*
* HISTORY
*
*/
#ifndef _IOKIT_IODEVICEMEMORY_H
#define _IOKIT_IODEVICEMEMORY_H
#include <IOKit/IOMemoryDescriptor.h>
#include <libkern/c++/OSPtr.h>
/*! @class IODeviceMemory
* @abstract An IOMemoryDescriptor used for device physical memory ranges.
* @discussion The IODeviceMemory class is a simple subclass of IOMemoryDescriptor that uses its methods to describe a single range of physical memory on a device. IODeviceMemory objects are usually looked up with IOService or IOPCIDevice accessors, and are created by memory-mapped bus families. IODeviceMemory implements only some factory methods in addition to the methods of IOMemoryDescriptor.
*/
class IODeviceMemory : public IOMemoryDescriptor
{
OSDeclareDefaultStructors(IODeviceMemory);
public:
/*! @struct InitElement
* @field start First physical address in the range.
* @field length Length of the range.
* @field tag 32-bit value not interpreted by IODeviceMemory or IOMemoryDescriptor, for use by the bus family. */
struct InitElement {
IOPhysicalAddress start;
IOPhysicalLength length;
IOOptionBits tag;
};
/*! @function arrayFromList
* @abstract Constructs an OSArray of IODeviceMemory instances, each describing one physical range, and a tag value.
* @discussion This method creates IODeviceMemory instances for each physical range passed in an IODeviceMemory::InitElement array. Each element consists of a physical address, length and tag value for the IODeviceMemory. The instances are returned as a created OSArray.
* @param list An array of IODeviceMemory::InitElement structures.
* @param count The number of elements in the list.
* @result Returns a created OSArray of IODeviceMemory objects, to be released by the caller, or zero on failure. */
static OSPtr<OSArray> arrayFromList(
InitElement list[],
IOItemCount count );
/*! @function withRange
* @abstract Constructs an IODeviceMemory instance, describing one physical range.
* @discussion This method creates an IODeviceMemory instance for one physical range passed as a physical address and length. It just calls IOMemoryDescriptor::withPhysicalAddress.
* @param start The physical address of the first byte in the memory.
* @param length The length of memory.
* @result Returns the created IODeviceMemory on success, to be released by the caller, or zero on failure. */
static OSPtr<IODeviceMemory> withRange(
IOPhysicalAddress start,
IOPhysicalLength length );
/*! @function withSubRange
* @abstract Constructs an IODeviceMemory instance, describing a subset of an existing IODeviceMemory range.
* @discussion This method creates an IODeviceMemory instance for a subset of an existing IODeviceMemory range, passed as a physical address offset and length. It just calls IOMemoryDescriptor::withSubRange.
* @param of The parent IODeviceMemory of which a subrange is to be used for the new descriptor, which will be retained by the subrange IODeviceMemory.
* @param offset A byte offset into the parent's memory.
* @param length The length of the subrange.
* @result Returns the created IODeviceMemory on success, to be released by the caller, or zero on failure. */
static OSPtr<IODeviceMemory> withSubRange(
IODeviceMemory * of,
IOPhysicalAddress offset,
IOPhysicalLength length );
};
#endif /* ! _IOKIT_IODEVICEMEMORY_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IORangeAllocator.h | /*
* Copyright (c) 1998-2019 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* Copyright (c) 1999 Apple Computer, Inc.
*
*
* HISTORY
*
* sdouglas 05 Nov 99 - created.
*/
#ifndef _IOKIT_IORANGEALLOCATOR_H
#define _IOKIT_IORANGEALLOCATOR_H
#include <libkern/c++/OSPtr.h>
#include <libkern/c++/OSObject.h>
#include <IOKit/IOTypes.h>
typedef IOByteCount IORangeScalar;
/*! @class IORangeAllocator
* @abstract A utility class to manage allocations from a range.
* @discussion The IORangeAllocator class provides functions for allocating ranges, at a fixed or any offset, and freeing them back to a free list. It is useful for describing ranges of memory or address space without requiring storage in the memory - information describing the free elements is kept elsewhere. Ranges are described by a start offset and a size. IORangeAllocator is optionally protected against multithreaded access.
*/
class IORangeAllocator : public OSObject {
OSDeclareDefaultStructors(IORangeAllocator);
protected:
UInt32 numElements;
UInt32 capacity;
UInt32 capacityIncrement;
IORangeScalar defaultAlignmentMask;
IOOptionBits options;
struct IORangeAllocatorElement * elements;
private:
virtual bool allocElement( UInt32 index );
virtual void deallocElement( UInt32 index );
public:
enum {
kLocking = 0x00000001
};
/*! @function init
* @abstract Standard initializer for IORangeAllocator.
* @discussion This method initializes an IORangeAllocator and optionally sets the free list to contain one fragment, from zero to an endOfRange parameter. The capacity in terms of free fragments and locking options are set for the instance.
* @param endOfRange If the free list is to contain an initial fragment, set endOfRange to the last offset in the range, ie. size - 1, to create a free fragment for the range zero to endOfRange inclusive. If zero is passed, the free list will be initialized empty, and can be populated with calls to the deallocate method.
* @param defaultAlignment If this parameter is non-zero it specifies a required alignment for all allocations, for example pass 256 to align allocations on 256 byte boundaries. Zero or one specify unaligned allocations.
* @param capacity Sets the initial size of the free list in number of noncontiguous fragments. This value is also used for the capacityIncrement.
* @param options Pass kLocking if the instance can be used by multiple threads.
* @result Returns true if the instance is successfully initialized, false on failure. */
virtual bool init( IORangeScalar endOfRange,
IORangeScalar defaultAlignment,
UInt32 capacity,
IOOptionBits options );
/*! @function withRange
* @abstract Standard factory method for IORangeAllocator.
* @discussion This method allocates and initializes an IORangeAllocator and optionally sets the free list to contain one fragment, from zero to an endOfRange parameter. The capacity in terms of free fragments and locking options are set for the instance.
* @param endOfRange If the free list is to contain an initial fragment, set endOfRange to the last offset in the range, ie. size - 1, to create a free fragment for the range zero to endOfRange inclusive. If zero is passed the free list will be initialized empty, and can be populated with calls to the deallocate method.
* @param defaultAlignment If this parameter is non-zero it specifies a required alignment for all allocations, for example pass 256 to align allocations on 256 byte boundaries. Zero or one specify unaligned allocations.
* @param capacity Sets the initial size of the free list in number of non-contiguous fragments. This value is also used for the capacityIncrement.
* @param options Pass kLocking if the instance can be used by multiple threads.
* @result Returns the new IORangeAllocator instance, to be released by the caller, or zero on failure. */
static OSPtr<IORangeAllocator> withRange( IORangeScalar endOfRange,
IORangeScalar defaultAlignment = 0,
UInt32 capacity = 0,
IOOptionBits options = 0 );
virtual void free() APPLE_KEXT_OVERRIDE;
virtual bool serialize(OSSerialize *s) const APPLE_KEXT_OVERRIDE;
/*! @function getFragmentCount
* @abstract Accessor to return the number of free fragments in the range.
* @discussion This method returns a count of free fragments. Each fragment describes a non-contiguous free range - deallocations will merge contiguous fragments together.
* @result Returns the count of free fragments.
*/
virtual UInt32 getFragmentCount( void );
/*! @function getFragmentCapacity
* @abstract Accessor to return the number of free fragments in the range.
* @discussion This method returns the current capacity of the free fragment list.
* @result Returns the current capacity of free fragment list.
*/
virtual UInt32 getFragmentCapacity( void );
/*! @function setFragmentCapacityIncrement
* @abstract Sets the count of fragments the free list will increase by when full.
* @discussion This method sets the number of extra fragments the free list will expand to when full. It defaults to the initial capacity.
* @param count The number of fragments to increment the capacity by when the free list is full.
*/
virtual void setFragmentCapacityIncrement( UInt32 count );
/*! @function getFreeCount
* @abstract Totals the sizes of the free fragments.
* @discussion This method returns the total of the sizes of the fragments on the free list.
* @result Returns the total of the free fragments sizes.
*/
virtual IORangeScalar getFreeCount( void );
/*! @function allocate
* @abstract Allocates from the free list, at any offset.
* @discussion This method allocates a range from the free list. The alignment will default to the alignment set when the allocator was created or may be set here.
* @param size The size of the range requested.
* @param result The beginning of the range allocated is returned here on success.
* @param alignment If zero is passed, default to the allocators alignment, otherwise pass an alignment required for the allocation, for example 4096 to page align.
* @result Returns true if the allocation was successful, else false.
*/
virtual bool allocate( IORangeScalar size,
IORangeScalar * result,
IORangeScalar alignment = 0 );
/*! @function allocateRange
* @abstract Allocates from the free list, at a set offset.
* @discussion This method allocates a range from the free list, given a set offset passed in.
* @param start The beginning of the range requested.
* @param size The size of the range requested.
* @result Returns true if the allocation was successful, else false.
*/
virtual bool allocateRange( IORangeScalar start,
IORangeScalar size );
/*! @function deallocate
* @abstract Deallocates a range to the free list.
* @discussion This method deallocates a range to the free list, given a the start offset and length passed in.
* @param start The beginning of the range requested.
* @param size Returns the size of the range requested.
*/
virtual void deallocate( IORangeScalar start,
IORangeScalar size );
};
#endif /* _IOKIT_IORANGEALLOCATOR_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOConditionLock.h | /*
* Copyright (c) 1998-2019 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/* Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
* Copyright (c) 1994-1996 NeXT Software, Inc. All rights reserved.
*/
#ifndef _IOKIT_IOCONDITIONLOCK_H
#define _IOKIT_IOCONDITIONLOCK_H
#include <libkern/c++/OSPtr.h>
#include <libkern/c++/OSObject.h>
#include <IOKit/IOLib.h>
#include <IOKit/system.h>
#include <IOKit/IOLocks.h>
class IOConditionLock : public OSObject
{
OSDeclareDefaultStructors(IOConditionLock);
private:
IOLock * cond_interlock; // condition var Simple lock
volatile int condition;
IOLock * sleep_interlock; // sleep lock Simple lock
unsigned char interruptible;
volatile bool want_lock;
volatile bool waiting;
public:
static OSPtr<IOConditionLock> withCondition(int condition, bool inIntr = true);
virtual bool initWithCondition(int condition, bool inIntr = true);
virtual void free() APPLE_KEXT_OVERRIDE;
virtual bool tryLock(); // acquire lock, no waiting
virtual int lock(); // acquire lock (enter critical section)
virtual void unlock(); // release lock (leave critical section)
virtual bool getInterruptible() const;
virtual int getCondition() const;
virtual int setCondition(int condition);
virtual int lockWhen(int condition);// acquire lock when condition
virtual void unlockWith(int condition); // set condition & release lock
};
#endif /* _IOKIT_IOCONDITIONLOCK_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOKitServer.h | /*
* Copyright (c) 1998-2011 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* Copyright (c) 1998 Apple Computer, Inc. All rights reserved.
*
* HISTORY
*
*/
/*
* Internal definitions used between the iokit user library and
* server routines.
*/
#ifndef _IOKIT_IOKITSERVER_H
#define _IOKIT_IOKITSERVER_H
#include <IOKit/IOTypes.h>
#include <IOKit/IOKitKeys.h>
#include <IOKit/OSMessageNotification.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <mach/kmod.h>
#ifdef __cplusplus
}
#endif
// IOCatalogueSendData
/*!
* @enum IOCatalogueSendData user-client flags.
* @constant kIOCatalogAddDrivers Signals a call to the addDrivers function in IOCatalogue.
* @constant kIOCatalogAddDriversNoMatch Signals a call to the addDrivers function in IOCatalogue but does not start a matching thread.
* @constant kIOCatalogRemoveDrivers Signals a call to the removeDrivers function in IOCatalogue.
* @constant kIOCatalogRemoveDriversNoMatch Signals a call to the removedrivers function in IOCatalogue but does not start a matching thread.
* @constant kIOCatalogStartMatching Signals the IOCatalogue to start an IOService matching thread.
* @constant kIOCatalogRemoveKernelLinker Deprecated; does nothing.
* @constant kIOCatalogKextdActive Signals the kernel that kextd is running.
* @constant kIOCatalogKextdFinishedLaunching Signals the IOCatalogue that kextd has finished sending it information at startup.
* @constant kIOCatalogResetDrivers Resets the IOCatalogue with a new set of personalities.
* @constant kIOCatalogResetDriversNoMatch Resets the IOCatalogue with a new set of personalities but does not start a matching thread.
*/
enum {
kIOCatalogAddDrivers = 1,
kIOCatalogAddDriversNoMatch,
kIOCatalogRemoveDrivers,
kIOCatalogRemoveDriversNoMatch,
kIOCatalogStartMatching__Removed,
kIOCatalogRemoveKernelLinker__Removed,
kIOCatalogKextdActive,
kIOCatalogKextdFinishedLaunching,
kIOCatalogResetDrivers,
kIOCatalogResetDriversNoMatch
};
// IOCatalogueGetData
/*!
* @enum IOCatalogueGetData user-client flags
* @constant kIOCatalogGetContents Returns a snapshot of the database to the caller.
*/
enum {
kIOCatalogGetContents = 1,
kIOCatalogGetModuleDemandList = 2,
kIOCatalogGetCacheMissList = 3,
kIOCatalogGetROMMkextList = 4
};
// IOCatalogueReset
/*!
* @enum IOCatalogueReset user-client flag
* @constant kIOCatalogResetDefault Removes all entries from IOCatalogue except those used for booting the system.
*/
enum {
kIOCatalogResetDefault = 1
};
// IOCatalogueTerminate
/*!
* @enum IOCatalogueTerminate user-client flags.
* @constant kIOCatalogModuleUnload Terminates all services which depend on a particular module and unloads the module.
* @constant kIOCatalogModuleTerminate Terminates all services which depend on a particular module but does not unload the module.
* @constant kIOCatalogServiceTerminate Terminates a particular service by name.
*/
enum {
kIOCatalogModuleUnload = 1,
kIOCatalogModuleTerminate,
kIOCatalogServiceTerminate
};
#endif /* ! _IOKIT_IOKITSERVER_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IODMACommand.h | /*
* Copyright (c) 2005-2016 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _IODMACOMMAND_H
#define _IODMACOMMAND_H
#include <IOKit/IOCommand.h>
#include <IOKit/IOMemoryDescriptor.h>
#include <DriverKit/IODMACommand.h>
class IOMapper;
class IOBufferMemoryDescriptor;
enum{
kIODMAMapOptionMapped = 0x00000000,
kIODMAMapOptionBypassed = 0x00000001,
kIODMAMapOptionNonCoherent = 0x00000002,
kIODMAMapOptionUnmapped = 0x00000003,
kIODMAMapOptionTypeMask = 0x0000000f,
kIODMAMapOptionNoCacheStore = 0x00000010, // Memory in descriptor
kIODMAMapOptionOnChip = 0x00000020,// Indicates DMA is on South Bridge
kIODMAMapOptionIterateOnly = 0x00000040// DMACommand will be used as a cursor only
};
/**************************** class IODMACommand ***************************/
/*!
* @class IODMACommand
* @abstract A mechanism to convert memory references to I/O bus addresses.
* @discussion The IODMACommand is supersedes the IOMemoryCursor and greatly enhances the functionality and power of it. The command can be specified to output 64 bit physical addresses and also allows driver writers bypass mapping hardware or get addresses suitable for non-snooped DMA.
* <br><br>
* The command is designed to be very easily subclassable. Most driver writers need to associate some DMA operations with their memory descriptor and usually use a C structure for that purpose. This structure is often kept in a linked list. This IODMACommand has built it <kern/queue.h> linkage and can be derived and 'public:' variables added, giving the developer a structure that can associate a memory descriptor with a particular dma command but will also allow the developer to generate that command and keep the state necessary for tracking it.
* <br><br>
* It is envisaged that a pool of IODMACommands will be created at driver initialisation and each command will be kept in an IOCommandPool while not in use. However if developers wishes to maintain their own free lists that is certainly possible. See the <kern/queue.h> and <xnu/iokit/Kernel/IOCommandPool> for sample code on manipulating the command's doubly linked list entries.
* <br><br>
* The IODMACommand can be used in a 'weak-linked' manner. To do this you must avoid using any static member functions. Use the, much slower but safe, weakWithSpecification function. On success a dma command instance will be returned. This instance can then be used to clone as many commands as is needed. Remember deriving from this class can not be done weakly, that is no weak subclassing!
*/
class IODMACommand : public IOCommand
{
OSDeclareDefaultStructorsWithDispatch(IODMACommand);
friend class IODMAEventSource;
public:
/*!
* @typedef Segment32
* @discussion A 32 bit I/O bus address/length pair
*/
struct Segment32 {
UInt32 fIOVMAddr, fLength;
};
/*!
* @typedef Segment64
* @discussion A 64 bit I/O bus address/length pair
*/
struct Segment64 {
UInt64 fIOVMAddr, fLength;
};
/*! @enum MappingOptions
* @abstract Mapping types to indicate the desired mapper type for translating memory descriptors into I/O DMA Bus addresses.
* @constant kNonCoherent Used by drivers for non-coherent transfers, implies unmapped memmory
* @constant kMapped Allow a driver to define addressing size
* @constant kBypassed Allow drivers to bypass any mapper
* @constant kMaxMappingOptions Internal use only
*/
enum MappingOptions {
kMapped = kIODMAMapOptionMapped,
kBypassed = kIODMAMapOptionBypassed,
kNonCoherent = kIODMAMapOptionNonCoherent,
kUnmapped = kIODMAMapOptionUnmapped,
kTypeMask = kIODMAMapOptionTypeMask,
kNoCacheStore = kIODMAMapOptionNoCacheStore, // Memory in descriptor
kOnChip = kIODMAMapOptionOnChip, // Indicates DMA is on South Bridge
kIterateOnly = kIODMAMapOptionIterateOnly// DMACommand will be used as a cursor only
};
struct SegmentOptions {
uint8_t fStructSize;
uint8_t fNumAddressBits;
uint64_t fMaxSegmentSize;
uint64_t fMaxTransferSize;
uint32_t fAlignment;
uint32_t fAlignmentLength;
uint32_t fAlignmentInternalSegments;
};
/*! @enum SynchronizeOptions
* @abstract Options for the synchronize method.
* @constant kForceDoubleBuffer Copy the entire prepared range to a new page aligned buffer.
*/
enum SynchronizeOptions {
kForceDoubleBuffer = 0x01000000
};
/*!
* @typedef SegmentFunction
* @discussion Pointer to a C function that translates a 64 segment and outputs a single desired segment to the array at the requested index. There are a group of pre-implemented SegmentFunctions that may be usefull to the developer below.
* @param segment The 64Bit I/O bus address and length.
* @param segments Base of the output vector of DMA address length pairs.
* @param segmentIndex Index to output 'segment' in the 'segments' array.
* @result Returns true if segment encoding succeeded. false may be returned if the current segment does not fit in an output segment, i.e. a 38bit address wont fit into a 32 encoding.
*/
typedef bool (*SegmentFunction)(IODMACommand *target,
Segment64 segment,
void *segments,
UInt32 segmentIndex);
// -------------- Preimplemented output functions ----------------
/*! @function OutputHost32
* @abstract Output host natural Segment32 output segment function.
*/
static bool OutputHost32(IODMACommand *target,
Segment64 seg, void *segs, UInt32 ind);
/*! @defined kIODMACommandOutputHost32
* @abstract Output host natural Segment32 output segment function.
*/
#define kIODMACommandOutputHost32 (IODMACommand::OutputHost32)
/*! @function OutputBig32
* @abstract Output big-endian Segment32 output segment function.
*/
static bool OutputBig32(IODMACommand *target,
Segment64 seg, void *segs, UInt32 ind);
/*! @defined kIODMACommandOutputBig32
* @abstract Output big-endian Segment32 output segment function.
*/
#define kIODMACommandOutputBig32 (IODMACommand::OutputBig32)
/*! @function OutputLittle32
* @abstract Output little-endian Segment32 output segment function.
*/
static bool OutputLittle32(IODMACommand *target,
Segment64 seg, void *segs, UInt32 ind);
/*! @defined kIODMACommandOutputLittle32
* @abstract Output little-endian Segment32 output segment function.
*/
#define kIODMACommandOutputLittle32 (IODMACommand::OutputLittle32)
/*! @function OutputHost64
* @abstract Output host natural Segment64 output segment function.
*/
static bool OutputHost64(IODMACommand *target,
Segment64 seg, void *segs, UInt32 ind);
/*! @defined kIODMACommandOutputHost64
* @abstract Output host natural Segment64 output segment function.
*/
#define kIODMACommandOutputHost64 (IODMACommand::OutputHost64)
/*! @function OutputBig64
* @abstract Output big-endian Segment64 output segment function.
*/
static bool OutputBig64(IODMACommand *target,
Segment64 seg, void *segs, UInt32 ind);
/*! @defined kIODMACommandOutputBig64
* @abstract Output big-endian Segment64 output segment function.
*/
#define kIODMACommandOutputBig64 (IODMACommand::OutputBig64)
/*! @function OutputLittle64
* @abstract Output little-endian Segment64 output segment function.
*/
static bool OutputLittle64(IODMACommand *target,
Segment64 seg, void *segs, UInt32 ind);
/*! @defined kIODMACommandOutputLittle64
* @abstract Output little-endian Segment64 output segment function.
*/
#define kIODMACommandOutputLittle64 (IODMACommand::OutputLittle64)
/*! @function withSpecification
* @abstract Creates and initializes an IODMACommand in one operation.
* @discussion Factory function to create and initialize an IODMACommand in one operation.
* @param outSegFunc SegmentFunction to call to output one physical segment. A set of nine commonly required segment functions are provided.
* @param numAddressBits Number of bits that the hardware uses on its internal address bus. Typically 32 but may be more on modern hardware. A 0 implies no-restriction other than that implied by the output segment function.
* @param maxSegmentSize Maximum allowable size for one segment. If 0 is passed the maximum segment size is unlimited.
* @param mappingOptions is the type of mapping that is required to translate an IOMemoryDescriptor into the desired number of bits. For instance if your hardware only supports 32 bits but must run on machines with > 4G of RAM some mapping will be required. Number of bits will be specified in numAddressBits, see below.This parameter can take 3 values:- kNonCoherent - used for non-coherent hardware transfers, Mapped - Validate that all I/O bus generated addresses are within the number of addressing bits specified, Bypassed indicates that bypassed addressing is required, this is used when the hardware transferes are into coherent memory but no mapping is required. See also prepare() for failure cases.
* @param maxTransferSize Maximum size of an entire transfer. Defaults to 0 indicating no maximum.
* @param alignment Alignment restriction, in bytes, on I/O bus addresses. Defaults to single byte alignment.
* @param mapper For mapping types kMapped & kBypassed mapper is used to define the hardware that will perform the mapping, defaults to the system mapper.
* @param refCon Reference Constant
* @result Returns a new IODMACommand if successfully created and initialized, 0 otherwise.
*/
static OSPtr<IODMACommand>
withSpecification(SegmentFunction outSegFunc,
UInt8 numAddressBits,
UInt64 maxSegmentSize,
MappingOptions mappingOptions = kMapped,
UInt64 maxTransferSize = 0,
UInt32 alignment = 1,
IOMapper *mapper = NULL,
void *refCon = NULL);
/*! @function weakWithSpecification
* @abstract Creates and initialises an IODMACommand in one operation if this version of the operating system supports it.
* @discussion Factory function to create and initialise an IODMACommand in one operation. The function allows a developer to 'weak' link with IODMACommand. This function will return kIOReturnUnsupported if the IODMACommand is unavailable. This function is actually fairly slow so it will be better to call it once then clone the successfully create command using cloneCommand (q.v.).
* @param newCommand Output reference variable of the newly created IODMACommand.
* @param outSegFunc SegmentFunction to call to output one physical segment. A set of nine commonly required segment functions are provided.
* @param numAddressBits Number of bits that the hardware uses on its internal address bus. Typically 32 but may be more on modern hardware. A 0 implies no-restriction other than that implied by the output segment function.
* @param maxSegmentSize Maximum allowable size for one segment. Zero is treated as an unlimited segment size.
* @param mapType is the type of mapping that is required to translate an IOMemoryDescriptor into the desired number of bits. For instance if your hardware only supports 32 bits but must run on machines with > 4G of RAM some mapping will be required. Number of bits will be specified in numAddressBits, see below. This parameter can take 3 values:- kNonCoherent - used for non-coherent hardware transfers, Mapped - Validate that all I/O bus generated addresses are within the number of addressing bits specified, Bypassed indicates that bypassed addressing is required, this is used when the hardware transfers are into coherent memory but no mapping is required. See also prepare() for failure cases.
* @param maxTransferSize Maximum size of an entire transfer. Defaults to 0 indicating no maximum.
* @param alignment Alignment restriction, in bytes, on I/O bus addresses. Defaults to single byte alignment.
* @param mapper For mapping types kMapped & kBypassed mapper is used to define the hardware that will perform the mapping, defaults to the system mapper.
* @param refCon Reference Constant
* @result kIOReturnSuccess if everything is OK, otherwise kIOReturnBadArgument if newCommand is NULL, kIOReturnUnsupported if the kernel doesn't export IODMACommand or IOReturnError if the new command fails to init, q.v. initWithSpecification.
*/
// Note that the function has the attribute always_inline.
// The point of this function is to make a call into the kernel
// without generating an undefined symbol. If the client could call
// the code as a function then the goal of no undefined symbols
// would be lost thus defeating the purpose.
static inline IOReturn weakWithSpecification
(IODMACommand **newCommand,
SegmentFunction outSegFunc,
UInt8 numAddressBits,
UInt64 maxSegmentSize,
MappingOptions mapType = kMapped,
UInt64 maxTransferSize = 0,
UInt32 alignment = 1,
IOMapper *mapper = NULL,
void *refCon = NULL) __attribute__((always_inline));
static OSPtr<IODMACommand>
withSpecification(SegmentFunction outSegFunc,
const SegmentOptions * segmentOptions,
uint32_t mappingOptions,
IOMapper * mapper,
void * refCon);
/*! @function withRefCon
* @abstract Creates and initializes an unspecified IODMACommand.
* @discussion Factory function to create and initialize an unspecified IODMACommand. prepareWithSpecification() must be used to prepare the IODMACommand before use.
* @param refCon Reference Constant
* @result Returns a new IODMACommand if successfully created and initialized, 0 otherwise.
*/
static OSPtr<IODMACommand> withRefCon(void * refCon);
/*!
* @function cloneCommand
* @abstract Creates a new command based on the specification of the current one.
* @discussion Factory function to create and initialise an IODMACommand in one operation. The current command's specification will be duplicated in the new object, but however none of its state will be duplicated. This means that it is safe to clone a command even if it is currently active and running, however you must be certain that the command to be duplicated does have a valid reference for the duration.
* @result Returns a new IODMACommand if successfully created and initialised, 0 otherwise.
*/
virtual OSPtr<IODMACommand> cloneCommand(void *refCon = NULL);
/*! @function initWithSpecification
* @abstract Primary initializer for the IODMACommand class.
* @param outSegFunc SegmentFunction to call to output one physical segment. A set of nine commonly required segment functions are provided.
* @param numAddressBits Number of bits that the hardware uses on its internal address bus. Typically 32 but may be more on modern hardware. A 0 implies no-restriction other than that implied by the output segment function.
* @param maxSegmentSize Maximum allowable size for one segment. Defaults to 0 which means any size.
* @param mappingOptions is the type of mapping that is required to translate an IOMemoryDescriptor into the desired number of bits. For instance if your hardware only supports 32 bits but must run on machines with > 4G of RAM some mapping will be required. Number of bits will be specified in numAddressBits, see below.This parameter can take 3 values:- kNonCoherent - used for non-coherent hardware transfers, Mapped - Validate that all I/O bus generated addresses are within the number of addressing bits specified, Bypassed indicates that bypassed addressing is required, this is used when the hardware transferes are into coherent memory but no mapping is required. See also prepare() for failure cases.
* @param maxTransferSize Maximum size of an entire transfer. Defaults to 0 indicating no maximum.
* @param alignment Alignment restriction, in bytes, on I/O bus addresses. Defaults to single byte alignment.
* @param mapper For mapping types kMapped & kBypassed mapper is used to define the hardware that will perform the mapping, defaults to the system mapper.
* @param refCon Reference Constant
* @result Can fail if the mapping type is not recognised, if one of the 3 mandatory parameters are set to 0, if a 32 bit output function is selected when more than 32 bits of address is required or, if kBypassed is requested on a machine that doesn't support bypassing. Returns true otherwise.
*/
virtual bool initWithSpecification( SegmentFunction outSegFunc,
UInt8 numAddressBits,
UInt64 maxSegmentSize,
MappingOptions mappingOptions = kMapped,
UInt64 maxTransferSize = 0,
UInt32 alignment = 1,
IOMapper *mapper = NULL,
void *refCon = NULL);
/*! @function setMemoryDescriptor
* @abstract Sets and resets the DMACommand's current memory descriptor
* @discussion The DMA command will configure itself based on the information that it finds in the memory descriptor. It looks for things like the direction of the memory descriptor and whether the current memory descriptor is already mapped into some IOMMU. As a programmer convenience it can also prepare the DMA command immediately. See prepare(). Note the IODMACommand is designed to used multiple times with a succession of memory descriptors, making the pooling of commands possible. It is an error though to attempt to reset a currently prepared() DMA command. Warning: This routine may block so never try to autoprepare an IODMACommand while in a gated context, i.e. one of the WorkLoops action call outs.
* @param mem A pointer to the current I/Os memory descriptor.
* @param autoPrepare An optional boolean variable that will call the prepare() function automatically after the memory descriptor is processed. Defaults to true.
* @result Returns kIOReturnSuccess, kIOReturnBusy if currently prepared, kIOReturnNoSpace if the length(mem) >= Maximum Transfer Size, kIOReturnCannotLock if called from the interrupt context or with a spinlock held, or the error codes returned by prepare() (qv).
*/
virtual IOReturn setMemoryDescriptor(const IOMemoryDescriptor *mem,
bool autoPrepare = true);
/*! @function clearMemoryDescriptor
* @abstract Clears the DMACommand's current memory descriptor
* @discussion completes and invalidates the cache if the DMA command is currently active, copies all data from bounce buffers if necessary and releases all resources acquired during setMemoryDescriptor.
* @param autoComplete An optional boolean variable that will call the complete() function automatically before the memory descriptor is processed. Defaults to true.
*/
virtual IOReturn clearMemoryDescriptor(bool autoComplete = true);
/*! @function getMemoryDescriptor
* @abstract Get the current memory descriptor
*/
virtual const IOMemoryDescriptor * getMemoryDescriptor() const;
/*! @function getIOMemoryDescriptor
* @abstract Get the memory descriptor to be used for DMA
*/
IOMemoryDescriptor * getIOMemoryDescriptor() const;
/*! @function prepare
* @abstract Prepare the memory for an I/O transfer.
* @discussion Allocate the mapping resources neccessary for this transfer, specifying a sub range of the IOMemoryDescriptor that will be the target of the I/O. The complete() method frees these resources. Data may be copied to buffers for kIODirectionOut memory descriptors, depending on hardware mapping resource availabilty or alignment restrictions. It should be noted that the this function may block and should only be called on the clients context, i.e never call this routine while gated; also the call itself is not thread safe though this should be an issue as each IODMACommand is independant.
* @param offset defines the starting offset in the memory descriptor the DMA command will operate on. genIOVMSegments will produce its results based on the offset and length passed to the prepare method.
* @param length defines the ending position in the memory descriptor the DMA command will operate on. genIOVMSegments will produce its results based on the offset and length passed to the prepare method.
* @param flushCache Flush the caches for the memory descriptor and make certain that the memory cycles are complete. Defaults to true for kNonCoherent and is ignored by the other types.
* @param synchronize Copy any buffered data back from the target IOMemoryDescriptor. Defaults to true, if synchronize() is being used to explicitly copy data, passing false may avoid an unneeded copy.
* @result An IOReturn code. */
virtual IOReturn prepare(UInt64 offset = 0, UInt64 length = 0, bool flushCache = true, bool synchronize = true);
/*! @function complete
* @abstract Complete processing of DMA mappings after an I/O transfer is finished.
* @discussion This method should not be called unless a prepare was previously issued; the prepare() and complete() must occur in pairs, before and after an I/O transfer
* @param invalidateCache Invalidate the caches for the memory descriptor. Defaults to true for kNonCoherent and is ignored by the other types.
* @param synchronize Copy any buffered data back to the target IOMemoryDescriptor. Defaults to true, if synchronize() is being used to explicitly copy data, passing false may avoid an unneeded copy.
* @result kIOReturnNotReady if not prepared, kIOReturnSuccess otherwise. */
virtual IOReturn complete(bool invalidateCache = true, bool synchronize = true);
/*! @function synchronize
* @abstract Bring IOMemoryDescriptor and IODMACommand buffers into sync.
* @discussion This method should not be called unless a prepare was previously issued. If needed a caller may synchronize any IODMACommand buffers with the original IOMemoryDescriptor buffers.
* @param options Specifies the direction of the copy:
* kIODirectionOut copy IOMemoryDesciptor memory to any IODMACommand buffers. By default this action takes place automatically at prepare().
* kIODirectionIn copy any IODMACommand buffers back to the IOMemoryDescriptor. By default this action takes place automatically at complete().
* kForceDoubleBuffer copy the entire prepared range to a new page aligned buffer.
* @result kIOReturnNotReady if not prepared, kIOReturnBadArgument if invalid options are passed, kIOReturnSuccess otherwise. */
virtual IOReturn synchronize(IOOptionBits options);
/*! @function genIOVMSegments
* @abstract Generates a physical scatter/gather for the current DMA command
* @discussion Generates a list of physical segments from the given memory descriptor, relative to the current position of the descriptor. The constraints that are set during initialisation will be respected. This function maintains the state across multiple calls for efficiency. However the state is discarded if the new offset is not the expected one.
* @param offset input/output parameter, defines the starting and ending offset in the memory descriptor, relative to any offset passed to the prepare() method.
* @param segments Void pointer to base of output physical scatter/gather list. Always passed directly onto the SegmentFunction.
* @param numSegments Input/output parameter Number of segments that can fit in the segment array and returns number of segments generated.
* @result kIOReturnSuccess on success, kIOReturnOverrun if the memory descriptor is exhausted, kIOReturnMessageTooLarge if the output segment function's address bits has insufficient resolution for a segment, kIOReturnNotReady if the DMA command has not be prepared, kIOReturnBadArgument if the DMA command doesn't have a memory descriptor yet or some of the parameters are NULL and kIOReturnNotReady if the DMA command is not prepared.
*/
virtual IOReturn genIOVMSegments(UInt64 *offset,
void *segments,
UInt32 *numSegments);
private:
virtual UInt64 transfer( IOOptionBits transferOp, UInt64 offset, void * buffer, UInt64 length );
public:
/*! @function writeBytes
* @abstract Copy data to the IODMACommand's buffer from the specified buffer.
* @discussion This method copies data to the IODMACommand's memory at the given offset, from the caller's buffer. The IODMACommand must be prepared, and the offset is relative to the prepared offset.
* @param offset A byte offset into the IODMACommand's memory, relative to the prepared offset.
* @param bytes The caller supplied buffer to copy the data from.
* @param length The length of the data to copy.
* @result The number of bytes copied, zero will be returned if the specified offset is beyond the prepared length of the IODMACommand. */
UInt64 writeBytes(UInt64 offset, const void *bytes, UInt64 length);
/*! @function readBytes
* @abstract Copy data from the IODMACommand's buffer to the specified buffer.
* @discussion This method copies data from the IODMACommand's memory at the given offset, to the caller's buffer. The IODMACommand must be prepared, and the offset is relative to the prepared offset.
* @param offset A byte offset into the IODMACommand's memory, relative to the prepared offset.
* @param bytes The caller supplied buffer to copy the data to.
* @param length The length of the data to copy.
* @result The number of bytes copied, zero will be returned if the specified offset is beyond the prepared length of the IODMACommand. */
UInt64 readBytes(UInt64 offset, void *bytes, UInt64 length);
/*! @function gen32IOVMSegments
* @abstract Helper function for a type checked call to genIOVMSegments(qv), for use with an IODMACommand set up with the output function kIODMACommandOutputHost32, kIODMACommandOutputBig32, or kIODMACommandOutputLittle32. If the output function of the IODMACommand is not a 32 bit function, results will be incorrect.
*/
inline IOReturn
gen32IOVMSegments(UInt64 *offset,
Segment32 *segments,
UInt32 *numSegments)
{
return genIOVMSegments(offset, segments, numSegments);
}
/*! @function gen64IOVMSegments
* @abstract Helper function for a type checked call to genIOVMSegments(qv), for use with an IODMACommand set up with the output function kIODMACommandOutputHost64, kIODMACommandOutputBig64, or kIODMACommandOutputLittle64. If the output function of the IODMACommand is not a 64 bit function, results will be incorrect.
*/
inline IOReturn
gen64IOVMSegments(UInt64 *offset,
Segment64 *segments,
UInt32 *numSegments)
{
return genIOVMSegments(offset, segments, numSegments);
}
IOReturn
genIOVMSegments(SegmentFunction segmentFunction,
UInt64 *offsetP,
void *segmentsP,
UInt32 *numSegmentsP);
virtual void free() APPLE_KEXT_OVERRIDE;
private:
IOReturn setSpecification(SegmentFunction outSegFunc,
const SegmentOptions * segmentOptions,
uint32_t mappingOptions,
IOMapper * mapper);
typedef IOReturn (*InternalSegmentFunction)(
void *reference,
IODMACommand *target,
Segment64 segment,
void *segments,
UInt32 segmentIndex);
IOReturn genIOVMSegments(uint32_t op,
InternalSegmentFunction outSegFunc,
void *reference,
UInt64 *offsetP,
void *segmentsP,
UInt32 *numSegmentsP);
static IOReturn clientOutputSegment(
void *reference, IODMACommand *target,
Segment64 segment, void *vSegList, UInt32 outSegIndex);
static IOReturn segmentOp(
void *reference,
IODMACommand *target,
Segment64 segment,
void *segments,
UInt32 segmentIndex);
IOReturn walkAll(uint32_t op);
public:
/*! @function prepareWithSpecification
* @abstract Prepare the memory for an I/O transfer with a new specification.
* @discussion Allocate the mapping resources neccessary for this transfer, specifying a sub range of the IOMemoryDescriptor that will be the target of the I/O. The complete() method frees these resources. Data may be copied to buffers for kIODirectionOut memory descriptors, depending on hardware mapping resource availabilty or alignment restrictions. It should be noted that the this function may block and should only be called on the clients context, i.e never call this routine while gated; also the call itself is not thread safe though this should be an issue as each IODMACommand is independant.
* @param outSegFunc SegmentFunction to call to output one physical segment. A set of nine commonly required segment functions are provided.
* @param numAddressBits Number of bits that the hardware uses on its internal address bus. Typically 32 but may be more on modern hardware. A 0 implies no-restriction other than that implied by the output segment function.
* @param maxSegmentSize Maximum allowable size for one segment. Defaults to 0 which means any size.
* @param mappingOptions is the type of mapping that is required to translate an IOMemoryDescriptor into the desired number of bits. For instance if your hardware only supports 32 bits but must run on machines with > 4G of RAM some mapping will be required. Number of bits will be specified in numAddressBits, see below.This parameter can take 3 values:- kNonCoherent - used for non-coherent hardware transfers, Mapped - Validate that all I/O bus generated addresses are within the number of addressing bits specified, Bypassed indicates that bypassed addressing is required, this is used when the hardware transferes are into coherent memory but no mapping is required. See also prepare() for failure cases.
* @param maxTransferSize Maximum size of an entire transfer. Defaults to 0 indicating no maximum.
* @param alignment Alignment restriction, in bytes, on I/O bus addresses. Defaults to single byte alignment.
* @param mapper For mapping types kMapped & kBypassed mapper is used to define the hardware that will perform the mapping, defaults to the system mapper.
* @param offset defines the starting offset in the memory descriptor the DMA command will operate on. genIOVMSegments will produce its results based on the offset and length passed to the prepare method.
* @param length defines the ending position in the memory descriptor the DMA command will operate on. genIOVMSegments will produce its results based on the offset and length passed to the prepare method.
* @param flushCache Flush the caches for the memory descriptor and make certain that the memory cycles are complete. Defaults to true for kNonCoherent and is ignored by the other types.
* @param synchronize Copy any buffered data back from the target IOMemoryDescriptor. Defaults to true, if synchronize() is being used to explicitly copy data, passing false may avoid an unneeded copy.
* @result An IOReturn code. Can fail if the mapping type is not recognised, if one of the 3 mandatory parameters are set to 0, if a 32 bit output function is selected when more than 32 bits of address is required or, if kBypassed is requested on a machine that doesn't support bypassing.
*/
virtual IOReturn prepareWithSpecification(SegmentFunction outSegFunc,
UInt8 numAddressBits,
UInt64 maxSegmentSize,
MappingOptions mappingOptions = kMapped,
UInt64 maxTransferSize = 0,
UInt32 alignment = 1,
IOMapper *mapper = NULL,
UInt64 offset = 0,
UInt64 length = 0,
bool flushCache = true,
bool synchronize = true);
static IOReturn transferSegment(void *reference,
IODMACommand *target,
Segment64 segment,
void *segments,
UInt32 segmentIndex);
/*! @function getPreparedOffsetAndLength
* @abstract Returns the offset and length into the target IOMemoryDescriptor of a prepared IODDMACommand.
* @discussion If successfully prepared, returns the offset and length into the IOMemoryDescriptor. Will fail for an unprepared IODMACommand.
* @param offset returns the starting offset in the memory descriptor the DMA command was prepared with. Pass NULL for don't care.
* @param length returns the length in the memory descriptor the DMA command was prepared with. Pass NULL for don't care.
* @result An IOReturn code. kIOReturnNotReady if the IODMACommand is not prepared. */
virtual IOReturn getPreparedOffsetAndLength(UInt64 * offset, UInt64 * length);
UInt8 getNumAddressBits(void);
UInt32 getAlignment(void);
uint32_t getAlignmentLength(void);
uint32_t getAlignmentInternalSegments(void);
/*! @function initWithRefCon
* @abstract Secondary initializer for the IODMACommand class.
* @param refCon Reference Constant
* @result Can fail if super init fails. Returns true otherwise.
*/
virtual
bool initWithRefCon(void * refCon = NULL);
virtual
bool initWithSpecification(SegmentFunction outSegFunc,
const SegmentOptions * segmentOptions,
uint32_t mappingOptions,
IOMapper * mapper,
void * refCon);
virtual
IOReturn prepareWithSpecification(SegmentFunction outSegFunc,
const SegmentOptions * segmentOptions,
uint32_t mappingOptions,
IOMapper * mapper,
uint64_t offset,
uint64_t length,
bool flushCache = true,
bool synchronize = true);
virtual
OSPtr<IOBufferMemoryDescriptor> createCopyBuffer(IODirection direction, UInt64 length);
private:
OSMetaClassDeclareReservedUsedX86(IODMACommand, 0);
OSMetaClassDeclareReservedUsedX86(IODMACommand, 1);
OSMetaClassDeclareReservedUsedX86(IODMACommand, 2);
OSMetaClassDeclareReservedUsedX86(IODMACommand, 3);
OSMetaClassDeclareReservedUsedX86(IODMACommand, 4);
OSMetaClassDeclareReservedUsedX86(IODMACommand, 5);
OSMetaClassDeclareReservedUsedX86(IODMACommand, 6);
OSMetaClassDeclareReservedUnused(IODMACommand, 7);
OSMetaClassDeclareReservedUnused(IODMACommand, 8);
OSMetaClassDeclareReservedUnused(IODMACommand, 9);
OSMetaClassDeclareReservedUnused(IODMACommand, 10);
OSMetaClassDeclareReservedUnused(IODMACommand, 11);
OSMetaClassDeclareReservedUnused(IODMACommand, 12);
OSMetaClassDeclareReservedUnused(IODMACommand, 13);
OSMetaClassDeclareReservedUnused(IODMACommand, 14);
OSMetaClassDeclareReservedUnused(IODMACommand, 15);
public:
/*! @var fRefCon Reference Constant, client defined publicly avialable */
void *fRefCon;
protected:
/*! @var fMaxSegmentSize Maximum size of one segment in a scatter/gather list */
UInt64 fMaxSegmentSize;
/*! @var fMaxTransferSize
* Maximum size of a transfer that this memory cursor is allowed to generate */
UInt64 fMaxTransferSize;
UInt32 fAlignMaskLength;
UInt32 fAlignMaskInternalSegments;
/*! @var fMapper
* Client defined mapper. */
OSPtr<IOMapper> fMapper;
/*! @var fMemory
* memory descriptor for current I/O. */
OSPtr<IOMemoryDescriptor> fMemory;
/*! @var fOutSeg The action method called when an event has been delivered */
SegmentFunction fOutSeg;
/*! @var fAlignMask
* Alignment restriction mask. */
UInt32 fAlignMask;
/*! @var fNumAddressBits
* Number of bits that the hardware can address */
UInt32 fNumAddressBits;
/*! @var fNumSegments
* Number of contiguous segments required for the current memory descriptor and desired mapping */
UInt32 fNumSegments;
/*! @var fMappingOptions
* What type of I/O virtual address mapping is required for this command */
uint32_t fMappingOptions;
/*! @var fActive
* fActive indicates that this DMA command is currently prepared and ready to go */
UInt32 fActive;
/*! @var reserved
* Reserved for future use. (Internal use only) */
struct IODMACommandInternal *reserved;
};
IOReturn
IODMACommand::
weakWithSpecification(IODMACommand **newCommand,
SegmentFunction outSegFunc,
UInt8 numAddressBits,
UInt64 maxSegmentSize,
MappingOptions mapType,
UInt64 maxTransferSize,
UInt32 alignment,
IOMapper *mapper,
void *refCon)
{
if (!newCommand) {
return kIOReturnBadArgument;
}
IODMACommand *self = (IODMACommand *)
OSMetaClass::allocClassWithName("IODMACommand");
if (!self) {
return kIOReturnUnsupported;
}
IOReturn ret;
bool inited = self->
initWithSpecification(outSegFunc,
numAddressBits, maxSegmentSize, mapType,
maxTransferSize, alignment, mapper, refCon);
if (inited) {
ret = kIOReturnSuccess;
} else {
self->release();
self = NULL;
ret = kIOReturnError;
}
*newCommand = self;
return ret;
};
#endif /* !_IODMACOMMAND_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOCommand.h | /*
* Copyright (c) 2019 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
*
* Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
*
* HISTORY
*
* 2001-01-18 gvdl Made the primary queue pointer public, to be used when
* Ownership is clear.
* 11/13/2000 CJS Created IOCommand class and implementation
*
*/
/*!
* @header IOCommand
* @abstract
* This header contains the IOCommand class definition.
*/
#ifndef _IOKIT_IO_COMMAND_H_
#define _IOKIT_IO_COMMAND_H_
/*
* Kernel
*/
#if defined(KERNEL) && defined(__cplusplus)
#include <kern/queue.h>
#include <libkern/c++/OSObject.h>
/*!
* @class IOCommand
* @abstract
* This class is an abstract class which represents an I/O command.
* @discussion
* This class is an abstract class which represents an I/O command passed
* from a device driver to a controller. All controller commands (e.g. IOATACommand)
* should inherit from this class.
*/
class IOCommand : public OSObject
{
OSDeclareDefaultStructors(IOCommand);
public:
virtual bool init(void) APPLE_KEXT_OVERRIDE;
/*! @var fCommandChain
* This variable is used by the current 'owner' to queue the command. During the life cycle of a command it moves through a series of queues. This is the queue pointer for it. Only valid while 'ownership' is clear. For instance a IOCommandPool uses this pointer to maintain its list of free commands. May be manipulated using the kern/queue.h macros */
queue_chain_t fCommandChain; /* used to queue commands */
};
#endif /* defined(KERNEL) && defined(__cplusplus) */
#endif /* _IOKIT_IO_COMMAND_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOBufferMemoryDescriptor.h | /*
* Copyright (c) 1998-2016 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _IOBUFFERMEMORYDESCRIPTOR_H
#define _IOBUFFERMEMORYDESCRIPTOR_H
#include <libkern/c++/OSPtr.h>
#include <IOKit/IOMemoryDescriptor.h>
#include <DriverKit/IOBufferMemoryDescriptor.h>
enum {
kIOMemoryPhysicallyContiguous = 0x00000010,
kIOMemoryPageable = 0x00000020,
kIOMemoryPurgeable = 0x00000040,
kIOMemoryHostPhysicallyContiguous = 0x00000080,
kIOMemorySharingTypeMask = 0x000f0000,
kIOMemoryUnshared = 0x00000000,
kIOMemoryKernelUserShared = 0x00010000,
// shared IOMemoryDescriptor options for IOBufferMemoryDescriptor:
kIOBufferDescriptorMemoryFlags = kIOMemoryDirectionMask
| kIOMemoryThreadSafe
| kIOMemoryClearEncrypt
| kIOMemoryMapperNone
| kIOMemoryUseReserve
};
#define _IOBUFFERMEMORYDESCRIPTOR_INTASKWITHOPTIONS_ 1
#define _IOBUFFERMEMORYDESCRIPTOR_HOSTPHYSICALLYCONTIGUOUS_ 1
#define IOBUFFERMEMORYDESCRIPTOR_SUPPORTS_INTASKWITHOPTIONS_TAGS 1
/*!
* @class IOBufferMemoryDescriptor
* @abstract Provides a simple memory descriptor that allocates its own buffer memory.
*/
class IOBufferMemoryDescriptor : public IOGeneralMemoryDescriptor
{
OSDeclareDefaultStructorsWithDispatch(IOBufferMemoryDescriptor);
private:
/*! @struct ExpansionData
* @discussion This structure will be used to expand the capablilties of this class in the future.
*/
struct ExpansionData {
IOMemoryMap * map;
};
/*! @var reserved
* Reserved for future use. (Internal use only) */
APPLE_KEXT_WSHADOW_PUSH;
ExpansionData * reserved;
protected:
void * _buffer;
vm_size_t _capacity;
vm_offset_t _alignment;
IOOptionBits _options;
private:
uintptr_t _internalReserved;
unsigned _internalFlags;
APPLE_KEXT_WSHADOW_POP;
private:
#ifndef __LP64__
virtual bool initWithOptions(
IOOptionBits options,
vm_size_t capacity,
vm_offset_t alignment,
task_t inTask) APPLE_KEXT_DEPRECATED; /* use withOptions() instead */
#endif /* !__LP64__ */
public:
virtual bool initWithPhysicalMask(
task_t inTask,
IOOptionBits options,
mach_vm_size_t capacity,
mach_vm_address_t alignment,
mach_vm_address_t physicalMask);
#ifdef __LP64__
OSMetaClassDeclareReservedUnused(IOBufferMemoryDescriptor, 0);
OSMetaClassDeclareReservedUnused(IOBufferMemoryDescriptor, 1);
#else /* !__LP64__ */
OSMetaClassDeclareReservedUsedX86(IOBufferMemoryDescriptor, 0);
OSMetaClassDeclareReservedUsedX86(IOBufferMemoryDescriptor, 1);
#endif /* !__LP64__ */
OSMetaClassDeclareReservedUnused(IOBufferMemoryDescriptor, 2);
OSMetaClassDeclareReservedUnused(IOBufferMemoryDescriptor, 3);
OSMetaClassDeclareReservedUnused(IOBufferMemoryDescriptor, 4);
OSMetaClassDeclareReservedUnused(IOBufferMemoryDescriptor, 5);
OSMetaClassDeclareReservedUnused(IOBufferMemoryDescriptor, 6);
OSMetaClassDeclareReservedUnused(IOBufferMemoryDescriptor, 7);
OSMetaClassDeclareReservedUnused(IOBufferMemoryDescriptor, 8);
OSMetaClassDeclareReservedUnused(IOBufferMemoryDescriptor, 9);
OSMetaClassDeclareReservedUnused(IOBufferMemoryDescriptor, 10);
OSMetaClassDeclareReservedUnused(IOBufferMemoryDescriptor, 11);
OSMetaClassDeclareReservedUnused(IOBufferMemoryDescriptor, 12);
OSMetaClassDeclareReservedUnused(IOBufferMemoryDescriptor, 13);
OSMetaClassDeclareReservedUnused(IOBufferMemoryDescriptor, 14);
OSMetaClassDeclareReservedUnused(IOBufferMemoryDescriptor, 15);
protected:
virtual void free() APPLE_KEXT_OVERRIDE;
public:
/*
* withOptions:
*
* Returns a new IOBufferMemoryDescriptor with a buffer large enough to
* hold capacity bytes. The descriptor's length is initially set to the
* capacity.
*/
#ifndef __LP64__
virtual bool initWithOptions( IOOptionBits options,
vm_size_t capacity,
vm_offset_t alignment) APPLE_KEXT_DEPRECATED; /* use withOptions() instead */
#endif /* !__LP64__ */
static OSPtr<IOBufferMemoryDescriptor> withCopy(
task_t inTask,
IOOptionBits options,
vm_map_t sourceMap,
mach_vm_address_t source,
mach_vm_size_t size);
static OSPtr<IOBufferMemoryDescriptor> withOptions( IOOptionBits options,
vm_size_t capacity,
vm_offset_t alignment = 1);
/*! @function inTaskWithOptions
* @abstract Creates a memory buffer with memory descriptor for that buffer.
* @discussion Added in Mac OS X 10.2, this method allocates a memory buffer with a given size and alignment in the task's address space specified, and returns a memory descriptor instance representing the memory. It is recommended that memory allocated for I/O or sharing via mapping be created via IOBufferMemoryDescriptor. Options passed with the request specify the kind of memory to be allocated - pageablity and sharing are specified with option bits. This function may block and so should not be called from interrupt level or while a simple lock is held.
* @param inTask The task the buffer will be allocated in.
* @param options Options for the allocation:<br>
* kIODirectionOut, kIODirectionIn - set the direction of the I/O transfer.<br>
* kIOMemoryPhysicallyContiguous - pass to request memory be physically contiguous. This option is heavily discouraged. The request may fail if memory is fragmented, may cause large amounts of paging activity, and may take a very long time to execute.<br>
* kIOMemoryPageable - pass to request memory be non-wired - the default for kernel allocated memory is wired.<br>
* kIOMemoryPurgeable - pass to request memory that may later have its purgeable state set with IOMemoryDescriptor::setPurgeable. Only supported for kIOMemoryPageable allocations.<br>
* kIOMemoryKernelUserShared - pass to request memory that will be mapped into both the kernel and client applications.<br>
* kIOMapInhibitCache - allocate memory with inhibited cache setting. <br>
* kIOMapWriteThruCache - allocate memory with writethru cache setting. <br>
* kIOMapCopybackCache - allocate memory with copyback cache setting. <br>
* kIOMapWriteCombineCache - allocate memory with writecombined cache setting.
* @param capacity The number of bytes to allocate.
* @param alignment The minimum required alignment of the buffer in bytes - 1 is the default for no required alignment. For example, pass 256 to get memory allocated at an address with bits 0-7 zero.
* @result Returns an instance of class IOBufferMemoryDescriptor to be released by the caller, which will free the memory desriptor and associated buffer. */
static OSPtr<IOBufferMemoryDescriptor> inTaskWithOptions(
task_t inTask,
IOOptionBits options,
vm_size_t capacity,
vm_offset_t alignment = 1);
/*! @function inTaskWithOptions
* @abstract Creates a memory buffer with memory descriptor for that buffer.
* @discussion Added in Mac OS X 10.2, this method allocates a memory buffer with a given size and alignment in the task's address space specified, and returns a memory descriptor instance representing the memory. It is recommended that memory allocated for I/O or sharing via mapping be created via IOBufferMemoryDescriptor. Options passed with the request specify the kind of memory to be allocated - pageablity and sharing are specified with option bits. This function may block and so should not be called from interrupt level or while a simple lock is held.
* @param inTask The task the buffer will be allocated in.
* @param options Options for the allocation:<br>
* kIODirectionOut, kIODirectionIn - set the direction of the I/O transfer.<br>
* kIOMemoryPhysicallyContiguous - pass to request memory be physically contiguous. This option is heavily discouraged. The request may fail if memory is fragmented, may cause large amounts of paging activity, and may take a very long time to execute.<br>
* kIOMemoryPageable - pass to request memory be non-wired - the default for kernel allocated memory is wired.<br>
* kIOMemoryPurgeable - pass to request memory that may later have its purgeable state set with IOMemoryDescriptor::setPurgeable. Only supported for kIOMemoryPageable allocations.<br>
* kIOMemoryKernelUserShared - pass to request memory that will be mapped into both the kernel and client applications.<br>
* kIOMapInhibitCache - allocate memory with inhibited cache setting. <br>
* kIOMapWriteThruCache - allocate memory with writethru cache setting. <br>
* kIOMapCopybackCache - allocate memory with copyback cache setting. <br>
* kIOMapWriteCombineCache - allocate memory with writecombined cache setting.
* @param capacity The number of bytes to allocate.
* @param alignment The minimum required alignment of the buffer in bytes - 1 is the default for no required alignment. For example, pass 256 to get memory allocated at an address with bits 0-7 zero.
* @param kernTag The kernel memory tag
* @param userTag The user memory tag
* @result Returns an instance of class IOBufferMemoryDescriptor to be released by the caller, which will free the memory desriptor and associated buffer. */
static OSPtr<IOBufferMemoryDescriptor> inTaskWithOptions(
task_t inTask,
IOOptionBits options,
vm_size_t capacity,
vm_offset_t alignment,
uint32_t kernTag,
uint32_t userTag);
/*! @function inTaskWithPhysicalMask
* @abstract Creates a memory buffer with memory descriptor for that buffer.
* @discussion Added in Mac OS X 10.5, this method allocates a memory buffer with a given size and alignment in the task's address space specified, and returns a memory descriptor instance representing the memory. It is recommended that memory allocated for I/O or sharing via mapping be created via IOBufferMemoryDescriptor. Options passed with the request specify the kind of memory to be allocated - pageablity and sharing are specified with option bits. This function may block and so should not be called from interrupt level or while a simple lock is held.
* @param inTask The task the buffer will be mapped in. Pass NULL to create memory unmapped in any task (eg. for use as a DMA buffer).
* @param options Options for the allocation:<br>
* kIODirectionOut, kIODirectionIn - set the direction of the I/O transfer.<br>
* kIOMemoryPhysicallyContiguous - pass to request memory be physically contiguous. This option is heavily discouraged. The request may fail if memory is fragmented, may cause large amounts of paging activity, and may take a very long time to execute.<br>
* kIOMemoryKernelUserShared - pass to request memory that will be mapped into both the kernel and client applications.<br>
* kIOMapInhibitCache - allocate memory with inhibited cache setting. <br>
* kIOMapWriteThruCache - allocate memory with writethru cache setting. <br>
* kIOMapCopybackCache - allocate memory with copyback cache setting. <br>
* kIOMapWriteCombineCache - allocate memory with writecombined cache setting.
* @param capacity The number of bytes to allocate.
* @param physicalMask The buffer will be allocated with pages such that physical addresses will only have bits set present in physicalMask. For example, pass 0x00000000FFFFFFFFULL for a buffer to be accessed by hardware that has 32 address bits.
* @result Returns an instance of class IOBufferMemoryDescriptor to be released by the caller, which will free the memory desriptor and associated buffer. */
static OSPtr<IOBufferMemoryDescriptor> inTaskWithPhysicalMask(
task_t inTask,
IOOptionBits options,
mach_vm_size_t capacity,
mach_vm_address_t physicalMask);
/*
* withCapacity:
*
* Returns a new IOBufferMemoryDescriptor with a buffer large enough to
* hold capacity bytes. The descriptor's length is initially set to the
* capacity.
*/
static OSPtr<IOBufferMemoryDescriptor> withCapacity(
vm_size_t capacity,
IODirection withDirection,
bool withContiguousMemory = false);
#ifndef __LP64__
virtual bool initWithBytes(const void * bytes,
vm_size_t withLength,
IODirection withDirection,
bool withContiguousMemory = false) APPLE_KEXT_DEPRECATED; /* use withBytes() instead */
#endif /* !__LP64__ */
/*
* withBytes:
*
* Returns a new IOBufferMemoryDescriptor preloaded with bytes (copied).
* The descriptor's length and capacity are set to the input buffer's size.
*/
static OSPtr<IOBufferMemoryDescriptor> withBytes(
const void * bytes,
vm_size_t withLength,
IODirection withDirection,
bool withContiguousMemory = false);
/*
* setLength:
*
* Change the buffer length of the memory descriptor. When a new buffer
* is created, the initial length of the buffer is set to be the same as
* the capacity. The length can be adjusted via setLength for a shorter
* transfer (there is no need to create more buffer descriptors when you
* can reuse an existing one, even for different transfer sizes). Note
* that the specified length must not exceed the capacity of the buffer.
*/
virtual void setLength(vm_size_t length);
/*
* setDirection:
*
* Change the direction of the transfer. This method allows one to redirect
* the descriptor's transfer direction. This eliminates the need to destroy
* and create new buffers when different transfer directions are needed.
*/
virtual void setDirection(IODirection direction);
/*
* getCapacity:
*
* Get the buffer capacity
*/
virtual vm_size_t getCapacity() const;
/*
* getBytesNoCopy:
*
* Return the virtual address of the beginning of the buffer
*/
virtual void *getBytesNoCopy();
/*
* getBytesNoCopy:
*
* Return the virtual address of an offset from the beginning of the buffer
*/
virtual void *getBytesNoCopy(vm_size_t start, vm_size_t withLength);
/*
* appendBytes:
*
* Add some data to the end of the buffer. This method automatically
* maintains the memory descriptor buffer length. Note that appendBytes
* will not copy past the end of the memory descriptor's current capacity.
*/
virtual bool appendBytes(const void *bytes, vm_size_t withLength);
#ifndef __LP64__
virtual void * getVirtualSegment(IOByteCount offset,
IOByteCount * length) APPLE_KEXT_OVERRIDE APPLE_KEXT_DEPRECATED; /* use getBytesNoCopy() instead */
#endif /* !__LP64__ */
};
#endif /* !_IOBUFFERMEMORYDESCRIPTOR_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IONVRAM.h | /*
* Copyright (c) 1998-2006 Apple Computer, Inc. All rights reserved.
* Copyright (c) 2007-2012 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _IOKIT_IONVRAM_H
#define _IOKIT_IONVRAM_H
#ifdef __cplusplus
#include <libkern/c++/OSPtr.h>
#include <IOKit/IOKitKeys.h>
#include <IOKit/IOService.h>
#include <IOKit/IODeviceTreeSupport.h>
#include <IOKit/nvram/IONVRAMController.h>
#endif /* __cplusplus */
#include <uuid/uuid.h>
enum NVRAMPartitionType {
kIONVRAMPartitionTypeUnknown,
kIONVRAMPartitionSystem,
kIONVRAMPartitionCommon
};
enum IONVRAMVariableType {
kOFVariableTypeBoolean = 1,
kOFVariableTypeNumber,
kOFVariableTypeString,
kOFVariableTypeData
};
enum IONVRAMOperation {
kIONVRAMOperationInit,
kIONVRAMOperationRead,
kIONVRAMOperationWrite,
kIONVRAMOperationDelete,
kIONVRAMOperationObliterate,
kIONVRAMOperationReset
};
enum {
// Deprecated but still used in AppleEFIRuntime for now
kOFVariablePermRootOnly = 0,
kOFVariablePermUserRead,
kOFVariablePermUserWrite,
kOFVariablePermKernelOnly
};
#ifdef __cplusplus
class IODTNVRAMVariables;
class IODTNVRAMDiags;
class IODTNVRAM : public IOService
{
OSDeclareDefaultStructors(IODTNVRAM);
private:
friend class IODTNVRAMVariables;
IONVRAMController *_nvramController;
OSPtr<const OSSymbol> _registryPropertiesKey;
UInt8 *_nvramImage;
UInt32 _nvramSize;
int _nvramVersion;
UInt32 _nvramGeneration;
UInt32 _commonPartitionOffset;
UInt32 _commonPartitionSize;
UInt32 _systemPartitionOffset;
UInt32 _systemPartitionSize;
IODTNVRAMDiags *_diags;
IORWLock *_variableLock;
IOLock *_controllerLock;
IODTNVRAMVariables *_commonService;
IODTNVRAMVariables *_systemService;
OSPtr<OSDictionary> _commonDict;
OSPtr<OSDictionary> _systemDict;
OSPtr<OSDictionary> _nvramPartitionOffsets;
OSPtr<OSDictionary> _nvramPartitionLengths;
bool _systemPanicked;
SInt32 _lastDeviceSync;
bool _freshInterval;
bool _isProxied;
void initNVRAMImage(void);
IOReturn initVariables(void);
void initProxyData(void);
UInt32 getNVRAMSize(void);
IOReturn serializeVariables(void);
NVRAMPartitionType getDictionaryType(const OSDictionary *dict) const;
IOReturn chooseDictionary(IONVRAMOperation operation, const uuid_t *varGuid,
const char *variableName, OSDictionary **dict) const;
IOReturn flushDict(const uuid_t *guid, IONVRAMOperation op);
bool handleSpecialVariables(const char *name, const uuid_t *guid, const OSObject *obj, IOReturn *error);
IOReturn setPropertyInternal(const OSSymbol *aKey, OSObject *anObject);
IOReturn removePropertyInternal(const OSSymbol *aKey);
OSSharedPtr<OSObject> copyPropertyWithGUIDAndName(const uuid_t *guid, const char *name) const;
IOReturn removePropertyWithGUIDAndName(const uuid_t *guid, const char *name);
IOReturn setPropertyWithGUIDAndName(const uuid_t *guid, const char *name, OSObject *anObject);
bool convertPropToObject(const UInt8 *propName, UInt32 propNameLength,
const UInt8 *propData, UInt32 propDataLength,
LIBKERN_RETURNS_RETAINED const OSSymbol **propSymbol,
LIBKERN_RETURNS_RETAINED OSObject **propObject);
bool convertPropToObject(const UInt8 *propName, UInt32 propNameLength,
const UInt8 *propData, UInt32 propDataLength,
OSSharedPtr<const OSSymbol>& propSymbol,
OSSharedPtr<OSObject>& propObject);
bool convertObjectToProp(UInt8 *buffer, UInt32 *length,
const OSSymbol *propSymbol, OSObject *propObject);
bool convertObjectToProp(UInt8 *buffer, UInt32 *length,
const char *propSymbol, OSObject *propObject);
OSPtr<OSData> unescapeBytesToData(const UInt8 *bytes, UInt32 length);
OSPtr<OSData> escapeDataToData(OSData * value);
IOReturn readNVRAMPropertyType1(IORegistryEntry *entry,
const OSSymbol **name,
OSData **value);
IOReturn writeNVRAMPropertyType1(IORegistryEntry *entry,
const OSSymbol *name,
OSData *value);
void syncInternal(bool rateLimit);
bool safeToSync(void);
public:
virtual bool init(IORegistryEntry *old, const IORegistryPlane *plane) APPLE_KEXT_OVERRIDE;
virtual bool start(IOService * provider) APPLE_KEXT_OVERRIDE;
virtual void registerNVRAMController(IONVRAMController *nvram);
virtual void sync(void);
virtual bool serializeProperties(OSSerialize *s) const APPLE_KEXT_OVERRIDE;
virtual OSPtr<OSObject> copyProperty(const OSSymbol *aKey) const APPLE_KEXT_OVERRIDE;
virtual OSPtr<OSObject> copyProperty(const char *aKey) const APPLE_KEXT_OVERRIDE;
virtual OSObject *getProperty(const OSSymbol *aKey) const APPLE_KEXT_OVERRIDE;
virtual OSObject *getProperty(const char *aKey) const APPLE_KEXT_OVERRIDE;
virtual bool setProperty(const OSSymbol *aKey, OSObject *anObject) APPLE_KEXT_OVERRIDE;
virtual void removeProperty(const OSSymbol *aKey) APPLE_KEXT_OVERRIDE;
virtual IOReturn setProperties(OSObject *properties) APPLE_KEXT_OVERRIDE;
virtual IOReturn readXPRAM(IOByteCount offset, UInt8 *buffer,
IOByteCount length);
virtual IOReturn writeXPRAM(IOByteCount offset, UInt8 *buffer,
IOByteCount length);
virtual IOReturn readNVRAMProperty(IORegistryEntry *entry,
const OSSymbol **name,
OSData **value);
virtual IOReturn writeNVRAMProperty(IORegistryEntry *entry,
const OSSymbol *name,
OSData *value);
virtual OSDictionary *getNVRAMPartitions(void);
virtual IOReturn readNVRAMPartition(const OSSymbol *partitionID,
IOByteCount offset, UInt8 *buffer,
IOByteCount length);
virtual IOReturn writeNVRAMPartition(const OSSymbol *partitionID,
IOByteCount offset, UInt8 *buffer,
IOByteCount length);
virtual IOByteCount savePanicInfo(UInt8 *buffer, IOByteCount length);
};
#endif /* __cplusplus */
#endif /* !_IOKIT_IONVRAM_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOCommandPool.h | /*
* Copyright (c) 2000-2019 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
*
* Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
*
* HISTORY
*
* 2001-01-17 gvdl Re-implement on IOCommandGate::commandSleep
* 11/13/2000 CJS Created IOCommandPool class and implementation
*
*/
/*!
* @header IOCommandPool
* @abstract
* This header contains the IOCommandPool class definition.
*/
#ifndef _IOKIT_IO_COMMAND_POOL_H_
#define _IOKIT_IO_COMMAND_POOL_H_
/*
* Kernel
*/
#if defined(KERNEL) && defined(__cplusplus)
#include <kern/kern_types.h>
#include <kern/queue.h>
#include <IOKit/IOCommand.h>
#include <IOKit/IOCommandGate.h>
#include <IOKit/IOService.h>
#include <IOKit/IOWorkLoop.h>
#include <libkern/c++/OSPtr.h>
/*!
* @class IOCommandPool
* @abstract Manipulates a pool of commands which inherit from IOCommand.
* @discussion
* The IOCommandPool class is used to manipulate a pool of commands which
* inherit from IOCommand. It includes a factory method to create a pool
* of a certain size. Once the factory method is invoked, the semaphore
* is set to zero. The caller must then put commands in the pool by creating
* the command (via the controller's factory method or a memory allocation)
* and calling the returnCommand method with the newly created command as its
* argument.
*/
class IOCommandPool : public OSObject
{
OSDeclareDefaultStructors(IOCommandPool);
protected:
queue_head_t fQueueHead; /* head of the queue of elements available */
UInt32 fSleepers; /* Count of threads sleeping on this pool */
OSPtr<IOCommandGate> fSerializer; /* command gate used for serializing pool access */
/*! @struct ExpansionData
* @discussion This structure will be used to expand the capablilties of the IOEventSource in the future.
*/
struct ExpansionData { };
/*! @var reserved
* Reserved for future use. (Internal use only) */
ExpansionData *reserved;
/*!
* @const kIOCommandPoolDefaultSize
* @abstract The default size of any command pool.
* @discussion
* kIOCommandPoolDefaultSize is the default size of any command pool.
* The default size was determined to be the smallest size for which
* a pool makes sense.
*/
static const UInt32 kIOCommandPoolDefaultSize = 2;
/*
* Free all of this object's outstanding resources.
*/
virtual void free(void) APPLE_KEXT_OVERRIDE;
public:
/*!
* @function initWithWorkLoop
* @abstract Primary initializer for an IOCommandPool object.
* @discussion Primary initializer for an IOCommandPool.
* Should probably use IOCommandPool::withWorkLoop() as it is easier to use.
* @param workLoop
* The workloop that this command pool should synchronize with.
* @result Returns true if command pool was successfully initialized.
*/
virtual bool initWithWorkLoop(IOWorkLoop *workLoop);
/*!
* @function withWorkLoop
* @abstract Primary factory method for the IOCommandPool class
* @discussion
* The withWorkLoop method is what is known as a factory method. It creates
* a new instance of an IOCommandPool and returns a pointer to that object.
* @param inWorkLoop
* The workloop that this command pool should synchronize with.
* @result
* Returns a pointer to an instance of IOCommandPool if successful,
* otherwise NULL.
*/
static OSPtr<IOCommandPool> withWorkLoop(IOWorkLoop *inWorkLoop);
/*!
* @function init
* @abstract Should never be used, obsolete. See initWithWorkLoop.
*/
virtual bool init(IOService *inOwner,
IOWorkLoop *inWorkLoop,
UInt32 inSize = kIOCommandPoolDefaultSize);
/*!
* @function withWorkLoop
* @abstract Should never be used, obsolete. See IOCommandPool::withWorkLoop.
*/
static OSPtr<IOCommandPool> commandPool(IOService *inOwner,
IOWorkLoop *inWorkLoop,
UInt32 inSize = kIOCommandPoolDefaultSize);
/*!
* @function getCommand
* @discussion The getCommand method is used to get a pointer to an object of type IOCommand from the pool.
* @param blockForCommand
* If the caller would like to have its thread slept until a command is
* available, it should pass true, else false.
* @result
* If the caller passes true in blockForCommand, getCommand guarantees that
* the result will be a pointer to an IOCommand object from the pool. If
* the caller passes false, s/he is responsible for checking whether a non-NULL
* pointer was returned.
*/
virtual OSPtr<IOCommand> getCommand(
bool blockForCommand = true);
/*!
* @function returnCommand
* @discussion
* The returnCommand method is used to place an object of type IOCommand
* into the pool, whether it be the first time, or the 1000th time.
* @param command
* The command to place in the pool.
*/
virtual void returnCommand(LIBKERN_CONSUMED IOCommand *command);
protected:
/*!
* @function gatedGetCommand
* @discussion
* The gatedGetCommand method is used to serialize the extraction of a
* command from the pool behind a command gate, runAction-ed by getCommand.
* @param command
* A pointer to a pointer to an IOCommand object where the returned
* command will be stored.
* @param blockForCommand
* A bool that indicates whether to block the request until a command
* becomes available.
* @result
* Returns kIOReturnNoResources if no command is available and the client
* doesn't wish to block until one does become available.
* kIOReturnSuccess if the vCommand argument is valid.
*/
virtual IOReturn gatedGetCommand(
LIBKERN_RETURNS_NOT_RETAINED IOCommand **command, bool blockForCommand);
/*!
* @function gatedReturnCommand
* @discussion
* The gatedReturnCommand method is used to serialize the return of a
* command to the pool behind a command gate, runAction-ed by returnCommand.
* @param command
* A pointer to the IOCommand object to be returned to the pool.
* @result
* Always returns kIOReturnSuccess if the vCommand argument is valid.
*/
virtual IOReturn gatedReturnCommand(IOCommand *command);
private:
OSMetaClassDeclareReservedUnused(IOCommandPool, 0);
OSMetaClassDeclareReservedUnused(IOCommandPool, 1);
OSMetaClassDeclareReservedUnused(IOCommandPool, 2);
OSMetaClassDeclareReservedUnused(IOCommandPool, 3);
OSMetaClassDeclareReservedUnused(IOCommandPool, 4);
OSMetaClassDeclareReservedUnused(IOCommandPool, 5);
OSMetaClassDeclareReservedUnused(IOCommandPool, 6);
OSMetaClassDeclareReservedUnused(IOCommandPool, 7);
};
#endif /* defined(KERNEL) && defined(__cplusplus) */
#endif /* _IOKIT_IO_COMMAND_POOL_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOInterruptController.h | /*
* Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
*
* DRI: Josh de Cesare
*
*/
#ifndef _IOKIT_IOINTERRUPTCONTROLLER_H
#define _IOKIT_IOINTERRUPTCONTROLLER_H
#include <IOKit/IOLocks.h>
#include <IOKit/IOService.h>
#include <IOKit/IOInterrupts.h>
class IOSharedInterruptController;
struct IOInterruptVector {
volatile char interruptActive;
volatile char interruptDisabledSoft;
volatile char interruptDisabledHard;
volatile char interruptRegistered;
IOLock * interruptLock;
IOService * nub;
int source;
void * target;
IOInterruptHandler handler;
void * refCon;
IOSharedInterruptController *sharedController;
};
typedef struct IOInterruptVector IOInterruptVector;
#if __LP64__
typedef int32_t IOInterruptVectorNumber;
#else
typedef long IOInterruptVectorNumber;
#endif
class IOInterruptController : public IOService
{
OSDeclareAbstractStructors(IOInterruptController);
protected:
IOInterruptVector *vectors;
IOSimpleLock *controllerLock;
struct ExpansionData { };
ExpansionData *ioic_reserved;
public:
virtual IOReturn registerInterrupt(IOService *nub, int source,
void *target,
IOInterruptHandler handler,
void *refCon);
virtual IOReturn unregisterInterrupt(IOService *nub, int source);
virtual IOReturn getInterruptType(IOService *nub, int source,
int *interruptType);
virtual IOReturn enableInterrupt(IOService *nub, int source);
virtual IOReturn disableInterrupt(IOService *nub, int source);
virtual IOReturn causeInterrupt(IOService *nub, int source);
virtual IOInterruptAction getInterruptHandlerAddress(void);
virtual IOReturn handleInterrupt(void *refCon, IOService *nub,
int source);
// Methods to be overridden for simplifed interrupt controller subclasses.
virtual bool vectorCanBeShared(IOInterruptVectorNumber vectorNumber, IOInterruptVector *vector);
virtual void initVector(IOInterruptVectorNumber vectorNumber, IOInterruptVector *vector);
virtual int getVectorType(IOInterruptVectorNumber vectorNumber, IOInterruptVector *vector);
virtual void disableVectorHard(IOInterruptVectorNumber vectorNumber, IOInterruptVector *vector);
virtual void enableVector(IOInterruptVectorNumber vectorNumber, IOInterruptVector *vector);
virtual void causeVector(IOInterruptVectorNumber vectorNumber, IOInterruptVector *vector);
virtual void setCPUInterruptProperties(IOService *service);
virtual void sendIPI(unsigned int cpu_id, bool deferred);
virtual void cancelDeferredIPI(unsigned int cpu_id);
OSMetaClassDeclareReservedUsedX86(IOInterruptController, 0);
OSMetaClassDeclareReservedUsedX86(IOInterruptController, 1);
OSMetaClassDeclareReservedUsedX86(IOInterruptController, 2);
OSMetaClassDeclareReservedUnused(IOInterruptController, 3);
OSMetaClassDeclareReservedUnused(IOInterruptController, 4);
OSMetaClassDeclareReservedUnused(IOInterruptController, 5);
public:
// Generic methods (not to be overriden).
void timeStampSpuriousInterrupt(void);
void timeStampInterruptHandlerStart(IOInterruptVectorNumber vectorNumber, IOInterruptVector *vector);
void timeStampInterruptHandlerEnd(IOInterruptVectorNumber vectorNumber, IOInterruptVector *vector);
private:
void timeStampInterruptHandlerInternal(bool isStart, IOInterruptVectorNumber vectorNumber, IOInterruptVector *vector);
};
class IOSharedInterruptController : public IOInterruptController
{
OSDeclareDefaultStructors(IOSharedInterruptController);
private:
IOService *provider;
int numVectors;
int vectorsRegistered;
int vectorsEnabled;
volatile int controllerDisabled;
bool sourceIsLevel;
struct ExpansionData { };
ExpansionData *iosic_reserved __unused;
public:
virtual IOReturn initInterruptController(IOInterruptController *parentController, OSData *parentSource);
virtual IOReturn registerInterrupt(IOService *nub, int source,
void *target,
IOInterruptHandler handler,
void *refCon) APPLE_KEXT_OVERRIDE;
virtual IOReturn unregisterInterrupt(IOService *nub, int source) APPLE_KEXT_OVERRIDE;
virtual IOReturn getInterruptType(IOService *nub, int source,
int *interruptType) APPLE_KEXT_OVERRIDE;
virtual IOReturn enableInterrupt(IOService *nub, int source) APPLE_KEXT_OVERRIDE;
virtual IOReturn disableInterrupt(IOService *nub, int source) APPLE_KEXT_OVERRIDE;
virtual IOInterruptAction getInterruptHandlerAddress(void) APPLE_KEXT_OVERRIDE;
virtual IOReturn handleInterrupt(void *refCon, IOService *nub, int source) APPLE_KEXT_OVERRIDE;
OSMetaClassDeclareReservedUnused(IOSharedInterruptController, 0);
OSMetaClassDeclareReservedUnused(IOSharedInterruptController, 1);
OSMetaClassDeclareReservedUnused(IOSharedInterruptController, 2);
OSMetaClassDeclareReservedUnused(IOSharedInterruptController, 3);
};
#endif /* ! _IOKIT_IOINTERRUPTCONTROLLER_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IORegistryEntry.h | /*
* Copyright (c) 1998-2019 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* Copyright (c) 1998 Apple Computer, Inc. All rights reserved.
*
* HISTORY
*
*/
#ifndef _IOKIT_IOREGISTRYENTRY_H
#define _IOKIT_IOREGISTRYENTRY_H
#include <IOKit/IOTypes.h>
#include <libkern/c++/OSContainers.h>
#include <libkern/c++/OSPtr.h>
#if defined(IOKIT_ENABLE_SHARED_PTR)
/*! @parseOnly */
#define APPLE_KEXT_DEPRECATED_WITH_SHARED_PTR __attribute__((deprecated))
#else
/*! @parseOnly */
#define APPLE_KEXT_DEPRECATED_WITH_SHARED_PTR
#endif /* IOKIT_ENABLE_SHARED_PTR */
extern const OSSymbol * gIONameKey;
extern const OSSymbol * gIOLocationKey;
extern const OSSymbol * gIORegistryEntryIDKey;
extern const OSSymbol * gIORegistryEntryPropertyKeysKey;
class IORegistryEntry;
class IORegistryPlane;
class IORegistryIterator;
typedef void (*IORegistryEntryApplierFunction)(IORegistryEntry * entry,
void * context);
enum {
kIORegistryIterateRecursively = 0x00000001,
kIORegistryIterateParents = 0x00000002,
};
/*! @class IORegistryEntry : public OSObject
* @abstract The base class for all objects in the registry.
* @discussion The IORegistryEntry base class provides functions for describing graphs of connected registry entries, each with a dictionary-based property table. Entries may be connected in different planes, with differing topologies. Access to the registry is protected against multiple threads. Inside the kernel planes are specified with plane objects and are published by the creator - IOService exports the gIOServicePlane plane object for example. Non kernel clients specify planes by their name.
*/
class IORegistryEntry : public OSObject
{
friend class IORegistryIterator;
OSDeclareDefaultStructors(IORegistryEntry);
protected:
/*! @struct ExpansionData
* @discussion This structure will be used to expand the capablilties of this class in the future.
*/
struct ExpansionData;
/*! @var reserved
* Reserved for future use. (Internal use only) */
ExpansionData * reserved;
private:
OSDictionary * fRegistryTable;
OSDictionary * fPropertyTable;
public:
/* methods available in Mac OS X 10.1 or later */
/*! @function copyProperty
* @abstract Synchronized method to obtain a property from a registry entry or one of its parents (or children) in the hierarchy. Available in Mac OS X 10.1 or later.
* @discussion This method will search for a property, starting first with this registry entry's property table, then iterating recusively through either the parent registry entries or the child registry entries of this entry. Once the first occurrence is found, it will lookup and return the value of the property, using the OSDictionary::getObject semantics. The iteration keeps track of entries that have been recursed into previously to avoid loops. This method is synchronized with other IORegistryEntry accesses to the property table(s).
* @param aKey The property's name as a C-string.
* @param plane The plane to iterate over, eg. gIOServicePlane.
* @param options kIORegistryIterateRecursively may be set to recurse automatically into the registry hierarchy. Without this option, this method degenerates into the standard getProperty() call. kIORegistryIterateParents may be set to iterate the parents of the entry, in place of the children.
* @result The property value found, or zero. A reference on any found property is returned to caller, which should be released. */
virtual OSPtr<OSObject> copyProperty( const char * aKey,
const IORegistryPlane * plane,
IOOptionBits options =
kIORegistryIterateRecursively |
kIORegistryIterateParents) const;
/*! @function copyProperty
* @abstract Synchronized method to obtain a property from a registry entry or one of its parents (or children) in the hierarchy. Available in Mac OS X 10.1 or later.
* @discussion This method will search for a property, starting first with this registry entry's property table, then iterating recusively through either the parent registry entries or the child registry entries of this entry. Once the first occurrence is found, it will lookup and return the value of the property, using the OSDictionary::getObject semantics. The iteration keeps track of entries that have been recursed into previously to avoid loops. This method is synchronized with other IORegistryEntry accesses to the property table(s).
* @param aKey The property's name as an OSString.
* @param plane The plane to iterate over, eg. gIOServicePlane.
* @param options kIORegistryIterateRecursively may be set to recurse automatically into the registry hierarchy. Without this option, this method degenerates into the standard getProperty() call. kIORegistryIterateParents may be set to iterate the parents of the entry, in place of the children.
* @result The property value found, or zero. A reference on any found property is returned to caller, which should be released. */
virtual OSPtr<OSObject> copyProperty( const OSString * aKey,
const IORegistryPlane * plane,
IOOptionBits options =
kIORegistryIterateRecursively |
kIORegistryIterateParents) const;
/*! @function copyProperty
* @abstract Synchronized method to obtain a property from a registry entry or one of its parents (or children) in the hierarchy. Available in Mac OS X 10.1 or later.
* @discussion This method will search for a property, starting first with this registry entry's property table, then iterating recusively through either the parent registry entries or the child registry entries of this entry. Once the first occurrence is found, it will lookup and return the value of the property, using the OSDictionary::getObject semantics. The iteration keeps track of entries that have been recursed into previously to avoid loops. This method is synchronized with other IORegistryEntry accesses to the property table(s).
* @param aKey The property's name as an OSSymbol.
* @param plane The plane to iterate over, eg. gIOServicePlane.
* @param options kIORegistryIterateRecursively may be set to recurse automatically into the registry hierarchy. Without this option, this method degenerates into the standard getProperty() call. kIORegistryIterateParents may be set to iterate the parents of the entry, in place of the children.
* @result The property value found, or zero. A reference on any found property is returned to caller, which should be released. */
virtual OSPtr<OSObject> copyProperty( const OSSymbol * aKey,
const IORegistryPlane * plane,
IOOptionBits options =
kIORegistryIterateRecursively |
kIORegistryIterateParents) const;
/*! @function copyParentEntry
* @abstract Returns an registry entry's first parent entry in a plane. Available in Mac OS X 10.1 or later.
* @discussion This function will return the parent to which a registry entry was first attached. Since the majority of registry entrys have only one provider, this is a useful simplification.
* @param plane The plane object.
* @result Returns the first parent of the registry entry, or zero if the entry is not attached into the registry in that plane. A reference on the entry is returned to caller, which should be released. */
virtual OSPtr<IORegistryEntry> copyParentEntry( const IORegistryPlane * plane ) const;
/*! @function copyChildEntry
* @abstract Returns an registry entry's first child entry in a plane. Available in Mac OS X 10.1 or later.
* @discussion This function will return the child which first attached to a registry entry.
* @param plane The plane object.
* @result Returns the first child of the registry entry, or zero if the entry is not attached into the registry in that plane. A reference on the entry is returned to caller, which should be released. */
virtual OSPtr<IORegistryEntry> copyChildEntry( const IORegistryPlane * plane ) const;
/* method available in Mac OS X 10.4 or later */
/*!
* @typedef Action
* @discussion Type and arguments of callout C function that is used when
* a runCommand is executed by a client. Cast to this type when you want a C++
* member function to be used. Note the arg1 - arg3 parameters are passed straight pass through to the action callout.
* @param target
* Target of the function, can be used as a refcon. Note if a C++ function
* was specified, this parameter is implicitly the first parameter in the target
* member function's parameter list.
* @param arg0 Argument to action from run operation.
* @param arg1 Argument to action from run operation.
* @param arg2 Argument to action from run operation.
* @param arg3 Argument to action from run operation.
*/
typedef IOReturn (*Action)(OSObject *target,
void *arg0, void *arg1,
void *arg2, void *arg3);
/*! @function runPropertyAction
* @abstract Single thread a call to an action w.r.t. the property lock
* @discussion Client function that causes the given action to be called in a manner that syncrhonises with the registry iterators and serialisers. This functin can be used to synchronously manipulate the property table of this nub
* @param action Pointer to function to be executed in work-loop context.
* @param arg0 Parameter for action parameter, defaults to 0.
* @param arg1 Parameter for action parameter, defaults to 0.
* @param arg2 Parameter for action parameter, defaults to 0.
* @param arg3 Parameter for action parameter, defaults to 0.
* @result Returns the value of the Action callout.
*/
virtual IOReturn runPropertyAction(Action action, OSObject *target,
void *arg0 = NULL, void *arg1 = NULL,
void *arg2 = NULL, void *arg3 = NULL);
#ifdef __BLOCKS__
typedef IOReturn (^ActionBlock)(void);
IOReturn runPropertyActionBlock(ActionBlock block);
#endif /* __BLOCKS__ */
private:
#if __LP64__
OSMetaClassDeclareReservedUnused(IORegistryEntry, 0);
OSMetaClassDeclareReservedUnused(IORegistryEntry, 1);
OSMetaClassDeclareReservedUnused(IORegistryEntry, 2);
OSMetaClassDeclareReservedUnused(IORegistryEntry, 3);
OSMetaClassDeclareReservedUnused(IORegistryEntry, 4);
OSMetaClassDeclareReservedUnused(IORegistryEntry, 5);
#else
OSMetaClassDeclareReservedUsedX86(IORegistryEntry, 0);
OSMetaClassDeclareReservedUsedX86(IORegistryEntry, 1);
OSMetaClassDeclareReservedUsedX86(IORegistryEntry, 2);
OSMetaClassDeclareReservedUsedX86(IORegistryEntry, 3);
OSMetaClassDeclareReservedUsedX86(IORegistryEntry, 4);
OSMetaClassDeclareReservedUsedX86(IORegistryEntry, 5);
#endif
OSMetaClassDeclareReservedUnused(IORegistryEntry, 6);
OSMetaClassDeclareReservedUnused(IORegistryEntry, 7);
OSMetaClassDeclareReservedUnused(IORegistryEntry, 8);
OSMetaClassDeclareReservedUnused(IORegistryEntry, 9);
OSMetaClassDeclareReservedUnused(IORegistryEntry, 10);
OSMetaClassDeclareReservedUnused(IORegistryEntry, 11);
OSMetaClassDeclareReservedUnused(IORegistryEntry, 12);
OSMetaClassDeclareReservedUnused(IORegistryEntry, 13);
OSMetaClassDeclareReservedUnused(IORegistryEntry, 14);
OSMetaClassDeclareReservedUnused(IORegistryEntry, 15);
OSMetaClassDeclareReservedUnused(IORegistryEntry, 16);
OSMetaClassDeclareReservedUnused(IORegistryEntry, 17);
OSMetaClassDeclareReservedUnused(IORegistryEntry, 18);
OSMetaClassDeclareReservedUnused(IORegistryEntry, 19);
OSMetaClassDeclareReservedUnused(IORegistryEntry, 20);
OSMetaClassDeclareReservedUnused(IORegistryEntry, 21);
OSMetaClassDeclareReservedUnused(IORegistryEntry, 22);
OSMetaClassDeclareReservedUnused(IORegistryEntry, 23);
OSMetaClassDeclareReservedUnused(IORegistryEntry, 24);
OSMetaClassDeclareReservedUnused(IORegistryEntry, 25);
OSMetaClassDeclareReservedUnused(IORegistryEntry, 26);
OSMetaClassDeclareReservedUnused(IORegistryEntry, 27);
OSMetaClassDeclareReservedUnused(IORegistryEntry, 28);
OSMetaClassDeclareReservedUnused(IORegistryEntry, 29);
OSMetaClassDeclareReservedUnused(IORegistryEntry, 30);
OSMetaClassDeclareReservedUnused(IORegistryEntry, 31);
public:
/* Registry accessors */
/*! @function getRegistryRoot
* @abstract Returns a pointer to the root instance of the registry.
* @discussion This method provides an accessor to the root of the registry for the machine. The root may be passed to a registry iterator when iterating a plane, and contains properties that describe the available planes, and diagnostic information for IOKit. Keys for these properties are in IOKitKeys.h.
* @result A pointer to the IORegistryEntry root instance. It should not be released by the caller. */
static IORegistryEntry * getRegistryRoot( void );
/*! @function getGenerationCount
* @abstract Returns an generation count for all registry changing operations.
* @discussion This method provides an accessor to the current generation count (or seed) of the registry which changes when any topology change occurs in the registry - this does not include property table changes. It may be used to invalidate any caching of the results from IORegistryEntry methods.
* @result An integer generation count. */
static SInt32 getGenerationCount( void );
/*! @function getPlane
* @abstract Looks up the plane object by a C-string name.
* @discussion Planes are usually provided as globals by the creator, eg. gIOServicePlane, gIODeviceTreePlane, or gIOAudioPlane, however they may also be looked up by name with this method.
* @result A pointer to the plane object, or zero if no such plane exists. The returned plane should not be released. */
static const IORegistryPlane * getPlane( const char * name );
/* Registry Entry allocation & init */
/*! @function init
* @abstract Standard init method for all IORegistryEntry subclasses.
* @discussion A registry entry must be initialized with this method before it can be used. A property dictionary may passed and will be retained by this method for use as the registry entry's property table, or an empty one will be created.
* @param dictionary A dictionary that will become the registry entry's property table (retaining it), or zero which will cause an empty property table to be created.
* @result true on success, or false on a resource failure. */
virtual bool init( OSDictionary * dictionary = NULL );
/*! @function free
* @abstract Standard free method for all IORegistryEntry subclasses.
* @discussion This method will release any resources of the entry, in particular its property table. Note that the registry entry must always be detached from the registry before free may be called, and subclasses (namely IOService) will have additional protocols for removing registry entries. free should never need be called directly. */
virtual void free( void ) APPLE_KEXT_OVERRIDE;
/*! @function setPropertyTable
* @abstract Replace a registry entry's property table.
* @discussion This method will release the current property table of a the entry and replace it with another, retaining the new property table.
* @param dict The new dictionary to be used as the entry's property table. */
virtual void setPropertyTable( OSDictionary * dict );
/* Synchronized property accessors; wrappers to OSDictionary
* plus property creation helpers */
/*! @function setProperty
* @abstract Synchronized method to add a property to a registry entry's property table.
* @discussion This method will add or replace a property in a registry entry's property table, using the OSDictionary::setObject semantics. This method is synchronized with other IORegistryEntry accesses to the property table.
* @param aKey The properties name as an OSSymbol.
* @param anObject The property value.
* @result true on success or false on a resource failure. */
virtual bool setProperty(const OSSymbol * aKey,
OSObject * anObject);
/*! @function setProperty
* @abstract Synchronized method to add a property to a registry entry's property table.
* @discussion This method will add or replace a property in a registry entry's property table, using the OSDictionary::setObject semantics. This method is synchronized with other IORegistryEntry accesses to the property table.
* @param aKey The property's name as an OSString.
* @param anObject The property value.
* @result true on success or false on a resource failure. */
virtual bool setProperty(const OSString * aKey, OSObject * anObject);
/*! @function setProperty
* @abstract Synchronized method to add a property to a registry entry's property table.
* @discussion This method will add or replace a property in a registry entry's property table, using the OSDictionary::setObject semantics. This method is synchronized with other IORegistryEntry accesses to the property table.
* @param aKey The property's name as a C-string.
* @param anObject The property value.
* @result true on success or false on a resource failure. */
virtual bool setProperty(const char * aKey, OSObject * anObject);
/*! @function setProperty
* @abstract Synchronized method to construct and add a OSString property to a registry entry's property table.
* @discussion This method will add or replace a property in a registry entry's property table, using the OSDictionary::setObject semantics. This method is synchronized with other IORegistryEntry accesses to the property table. The property is created as an OSString from the supplied C-string, set in the property table with the given name, and released.
* @param aKey The property's name as a C-string.
* @param aString The property value as a C-string.
* @result true on success or false on a resource failure. */
virtual bool setProperty(const char * aKey, const char * aString);
/*! @function setProperty
* @abstract Synchronized method to construct and add an OSBoolean property to a registry entry's property table.
* @discussion This method will add or replace a property in a registry entry's property table, using the OSDictionary::setObject semantics. This method is synchronized with other IORegistryEntry accesses to the property table. The property is created as an OSBoolean from the supplied value, set in the property table with the given name, and released.
* @param aKey The property's name as a C-string.
* @param aBoolean The property's boolean value.
* @result true on success or false on a resource failure. */
virtual bool setProperty(const char * aKey, bool aBoolean);
/*! @function setProperty
* @abstract Synchronized method to construct and add an OSNumber property to a registry entry's property table.
* @discussion This method will add or replace a property in a registry entry's property table, using the OSDictionary::setObject semantics. This method is synchronized with other IORegistryEntry accesses to the property table. The property is created as an OSNumber from the supplied value and size, set in the property table with the given name, and released.
* @param aKey The property's name as a C-string.
* @param aValue The property's numeric value.
* @param aNumberOfBits The property's size in bits, for OSNumber.
* @result true on success or false on a resource failure. */
virtual bool setProperty( const char * aKey,
unsigned long long aValue,
unsigned int aNumberOfBits);
/*! @function setProperty
* @abstract Synchronized method to construct and add an OSData property to a registry entry's property table.
* @discussion This method will add or replace a property in a registry entry's property table, using the OSDictionary::setObject semantics. This method is synchronized with other IORegistryEntry accesses to the property table. The property is created as an OSData copied from the supplied data and length, set in the property table with the given name, and released.
* @param aKey The property's name as a C-string.
* @param bytes The property's value as a pointer. OSData will copy this data.
* @param length The property's size in bytes, for OSData.
* @result true on success or false on a resource failure. */
virtual bool setProperty( const char * aKey,
void * bytes,
unsigned int length);
/*! @function removeProperty
* @abstract Synchronized method to remove a property from a registry entry's property table.
* @discussion This method will remove a property from a registry entry's property table, using the OSDictionary::removeObject semantics. This method is synchronized with other IORegistryEntry accesses to the property table.
* @param aKey The property's name as an OSSymbol. */
virtual void removeProperty( const OSSymbol * aKey);
/*! @function removeProperty
* @abstract Synchronized method to remove a property from a registry entry's property table.
* @discussion This method will remove a property from a registry entry's property table, using the OSDictionary::removeObject semantics. This method is synchronized with other IORegistryEntry accesses to the property table.
* @param aKey The property's name as an OSString. */
virtual void removeProperty( const OSString * aKey);
/*! @function removeProperty
* @abstract Synchronized method to remove a property from a registry entry's property table.
* @discussion This method will remove a property from a registry entry's property table, using the OSDictionary::removeObject semantics. This method is synchronized with other IORegistryEntry accesses to the property table.
* @param aKey The property's name as a C-string. */
virtual void removeProperty( const char * aKey);
/*! @function getProperty
* @abstract Synchronized method to obtain a property from a registry entry's property table.
* @discussion This method will lookup a property in a registry entry's property table, using the OSDictionary::getObject semantics. This method is synchronized with other IORegistryEntry accesses to the property table.
* @param aKey The property's name as an OSSymbol.
* @result The property value found, or zero. */
virtual OSObject * getProperty( const OSSymbol * aKey) const APPLE_KEXT_DEPRECATED_WITH_SHARED_PTR;
/*! @function getProperty
* @abstract Synchronized method to obtain a property from a registry entry's property table.
* @discussion This method will lookup a property in a registry entry's property table, using the OSDictionary::getObject semantics. This method is synchronized with other IORegistryEntry accesses to the property table.
* @param aKey The property's name as an OSString.
* @result The property value found, or zero. */
virtual OSObject * getProperty( const OSString * aKey) const APPLE_KEXT_DEPRECATED_WITH_SHARED_PTR;
/*! @function getProperty
* @abstract Synchronized method to obtain a property from a registry entry's property table.
* @discussion This method will lookup a property in a registry entry's property table, using the OSDictionary::getObject semantics. This method is synchronized with other IORegistryEntry accesses to the property table.
* @param aKey The property's name as a C-string.
* @result The property value found, or zero. */
virtual OSObject * getProperty( const char * aKey) const APPLE_KEXT_DEPRECATED_WITH_SHARED_PTR;
/*! @function propertyExists
* @abstract Synchronized method to check if a property exists in a registry entry's property table.
* @discussion This method will check if a property exists in a registry entry's property table. This method is synchronized with other IORegistryEntry accesses to the property table.
* @param aKey The property's name as an OSSymbol.
* @result True if the property value found. */
bool propertyExists(const OSSymbol * aKey);
/*! @function propertyExists
* @abstract Synchronized method to check if a property exists in a registry entry's property table.
* @discussion This method will check if a property exists in a registry entry's property table. This method is synchronized with other IORegistryEntry accesses to the property table.
* @param aKey The property's name as an OSString.
* @result True if the property value found. */
bool propertyExists(const OSString * aKey);
/*! @function propertyExists
* @abstract Synchronized method to check if a property exists in a registry entry's property table.
* @discussion This method will check if a property exists in a registry entry's property table. This method is synchronized with other IORegistryEntry accesses to the property table.
* @param aKey The property's name as a C-string.
* @result True if the property value found. */
bool propertyExists(const char * aKey);
/*! @function propertyHasValue
* @abstract Synchronized method to check if a property in a registry entry's property table has a given value.
* @discussion This method will check if a property exists in a registry entry's property table and compares with isEqualTo() the supplied value. This method is synchronized with other IORegistryEntry accesses to the property table.
* @param aKey The property's name as an OSSymbol.
* @param value The property's value to be compared.
* @result True if the property value was found and isEqualTo() the supplied value. */
bool propertyHasValue(const OSSymbol * aKey,
const OSObject * value);
/*! @function propertyHasValue
* @abstract Synchronized method to check if a property in a registry entry's property table has a given value.
* @discussion This method will check if a property exists in a registry entry's property table and compares with isEqualTo() the supplied value. This method is synchronized with other IORegistryEntry accesses to the property table.
* @param aKey The property's name as an OSString.
* @param value The property's value to be compared.
* @result True if the property value was found and isEqualTo() the supplied value. */
bool propertyHasValue(const OSString * aKey,
const OSObject * value);
/*! @function propertyHasValue
* @abstract Synchronized method to check if a property in a registry entry's property table has a given value.
* @discussion This method will check if a property exists in a registry entry's property table and compares with isEqualTo() the supplied value. This method is synchronized with other IORegistryEntry accesses to the property table.
* @param aKey The property's name as a C-string.
* @param value The property's value to be compared.
* @result True if the property value was found and isEqualTo() the supplied value. */
bool propertyHasValue(const char * aKey,
const OSObject * value);
/*! @function getProperty
* @abstract Synchronized method to obtain a property from a registry entry or one of its parents (or children) in the hierarchy.
* @discussion This method will search for a property, starting first with this registry entry's property table, then iterating recusively through either the parent registry entries or the child registry entries of this entry. Once the first occurrence is found, it will lookup and return the value of the property, using the OSDictionary::getObject semantics. The iteration keeps track of entries that have been recursed into previously to avoid loops. This method is synchronized with other IORegistryEntry accesses to the property table(s).
* @param aKey The property's name as an OSSymbol.
* @param plane The plane to iterate over, eg. gIOServicePlane.
* @param options kIORegistryIterateRecursively may be set to recurse automatically into the registry hierarchy. Without this option, this method degenerates into the standard getProperty() call. kIORegistryIterateParents may be set to iterate the parents of the entry, in place of the children.
* @result The property value found, or zero. */
virtual OSObject * getProperty( const OSSymbol * aKey,
const IORegistryPlane * plane,
IOOptionBits options =
kIORegistryIterateRecursively |
kIORegistryIterateParents) const APPLE_KEXT_DEPRECATED_WITH_SHARED_PTR;
/*! @function getProperty
* @abstract Synchronized method to obtain a property from a registry entry or one of its parents (or children) in the hierarchy.
* @discussion This method will search for a property, starting first with this registry entry's property table, then iterating recusively through either the parent registry entries or the child registry entries of this entry. Once the first occurrence is found, it will lookup and return the value of the property, using the OSDictionary::getObject semantics. The iteration keeps track of entries that have been recursed into previously to avoid loops. This method is synchronized with other IORegistryEntry accesses to the property table(s).
* @param aKey The property's name as an OSString.
* @param plane The plane to iterate over, eg. gIOServicePlane.
* @param options kIORegistryIterateRecursively may be set to recurse automatically into the registry hierarchy. Without this option, this method degenerates into the standard getProperty() call. kIORegistryIterateParents may be set to iterate the parents of the entry, in place of the children.
* @result The property value found, or zero. */
virtual OSObject * getProperty( const OSString * aKey,
const IORegistryPlane * plane,
IOOptionBits options =
kIORegistryIterateRecursively |
kIORegistryIterateParents) const APPLE_KEXT_DEPRECATED_WITH_SHARED_PTR;
/*! @function getProperty
* @abstract Synchronized method to obtain a property from a registry entry or one of its parents (or children) in the hierarchy.
* @discussion This method will search for a property, starting first with this registry entry's property table, then iterating recusively through either the parent registry entries or the child registry entries of this entry. Once the first occurrence is found, it will lookup and return the value of the property, using the OSDictionary::getObject semantics. The iteration keeps track of entries that have been recursed into previously to avoid loops. This method is synchronized with other IORegistryEntry accesses to the property table(s).
* @param aKey The property's name as a C-string.
* @param plane The plane to iterate over, eg. gIOServicePlane.
* @param options kIORegistryIterateRecursively may be set to recurse automatically into the registry hierarchy. Without this option, this method degenerates into the standard getProperty() call. kIORegistryIterateParents may be set to iterate the parents of the entry, in place of the children.
* @result The property value found, or zero. */
virtual OSObject * getProperty( const char * aKey,
const IORegistryPlane * plane,
IOOptionBits options =
kIORegistryIterateRecursively |
kIORegistryIterateParents) const APPLE_KEXT_DEPRECATED_WITH_SHARED_PTR;
/*! @function propertyExists
* @abstract Synchronized method to check if a property exists from a registry entry or one of its parents (or children) in the hierarchy.
* @discussion This method will search for a property, starting first with this registry entry's property table, then iterating recusively through either the parent registry entries or the child registry entries of this entry. Once the first occurrence is found, it will return true. The iteration keeps track of entries that have been recursed into previously to avoid loops. This method is synchronized with other IORegistryEntry accesses to the property table(s).
* @param aKey The property's name as an OSSymbol.
* @param plane The plane to iterate over, eg. gIOServicePlane.
* @param options kIORegistryIterateRecursively may be set to recurse automatically into the registry hierarchy. Without this option, this method degenerates into the standard propertyExists() call. kIORegistryIterateParents may be set to iterate the parents of the entry, in place of the children.
* @result True if the property was found. */
bool propertyExists( const OSSymbol * aKey,
const IORegistryPlane * plane,
uint32_t options =
kIORegistryIterateRecursively |
kIORegistryIterateParents) const;
/*! @function propertyExists
* @abstract Synchronized method to check if a property exists from a registry entry or one of its parents (or children) in the hierarchy.
* @discussion This method will search for a property, starting first with this registry entry's property table, then iterating recusively through either the parent registry entries or the child registry entries of this entry. Once the first occurrence is found, it will return true. The iteration keeps track of entries that have been recursed into previously to avoid loops. This method is synchronized with other IORegistryEntry accesses to the property table(s).
* @param aKey The property's name as an OSString.
* @param plane The plane to iterate over, eg. gIOServicePlane.
* @param options kIORegistryIterateRecursively may be set to recurse automatically into the registry hierarchy. Without this option, this method degenerates into the standard propertyExists() call. kIORegistryIterateParents may be set to iterate the parents of the entry, in place of the children.
* @result True if the property was found. */
bool propertyExists( const OSString * aKey,
const IORegistryPlane * plane,
uint32_t options =
kIORegistryIterateRecursively |
kIORegistryIterateParents) const;
/*! @function propertyExists
* @abstract Synchronized method to check if a property exists from a registry entry or one of its parents (or children) in the hierarchy.
* @discussion This method will search for a property, starting first with this registry entry's property table, then iterating recusively through either the parent registry entries or the child registry entries of this entry. Once the first occurrence is found, it will return true. The iteration keeps track of entries that have been recursed into previously to avoid loops. This method is synchronized with other IORegistryEntry accesses to the property table(s).
* @param aKey The property's name as a C-string.
* @param plane The plane to iterate over, eg. gIOServicePlane.
* @param options kIORegistryIterateRecursively may be set to recurse automatically into the registry hierarchy. Without this option, this method degenerates into the standard propertyExists() call. kIORegistryIterateParents may be set to iterate the parents of the entry, in place of the children.
* @result True if the property was found. */
bool propertyExists( const char * aKey,
const IORegistryPlane * plane,
uint32_t options =
kIORegistryIterateRecursively |
kIORegistryIterateParents) const;
/*! @function propertyHasValue
* @abstract Synchronized method to check if a property has a given value from a registry entry or one of its parents (or children) in the hierarchy.
* @discussion This method will search for a property, starting first with this registry entry's property table, then iterating recusively through either the parent registry entries or the child registry entries of this entry. Once the first occurrence is found, it will return true if the property isEqualTo() the supplied value. The iteration keeps track of entries that have been recursed into previously to avoid loops. This method is synchronized with other IORegistryEntry accesses to the property table(s).
* @param aKey The property's name as an OSSymbol.
* @param value The property value to be compared.
* @param plane The plane to iterate over, eg. gIOServicePlane.
* @param options kIORegistryIterateRecursively may be set to recurse automatically into the registry hierarchy. Without this option, this method degenerates into the standard propertyExists() call. kIORegistryIterateParents may be set to iterate the parents of the entry, in place of the children.
* @result True if the property was found and isEqualTo() the supplied value. */
bool propertyHasValue( const OSSymbol * aKey,
const OSObject * value,
const IORegistryPlane * plane,
uint32_t options =
kIORegistryIterateRecursively |
kIORegistryIterateParents) const;
/*! @function propertyHasValue
* @abstract Synchronized method to check if a property has a given value from a registry entry or one of its parents (or children) in the hierarchy.
* @discussion This method will search for a property, starting first with this registry entry's property table, then iterating recusively through either the parent registry entries or the child registry entries of this entry. Once the first occurrence is found, it will return true if the property isEqualTo() the supplied value. The iteration keeps track of entries that have been recursed into previously to avoid loops. This method is synchronized with other IORegistryEntry accesses to the property table(s).
* @param aKey The property's name as an OSString.
* @param value The property value to be compared.
* @param plane The plane to iterate over, eg. gIOServicePlane.
* @param options kIORegistryIterateRecursively may be set to recurse automatically into the registry hierarchy. Without this option, this method degenerates into the standard propertyExists() call. kIORegistryIterateParents may be set to iterate the parents of the entry, in place of the children.
* @result True if the property was found and isEqualTo() the supplied value. */
bool propertyHasValue( const OSString * aKey,
const OSObject * value,
const IORegistryPlane * plane,
uint32_t options =
kIORegistryIterateRecursively |
kIORegistryIterateParents) const;
/*! @function propertyHasValue
* @abstract Synchronized method to check if a property has a given value from a registry entry or one of its parents (or children) in the hierarchy.
* @discussion This method will search for a property, starting first with this registry entry's property table, then iterating recusively through either the parent registry entries or the child registry entries of this entry. Once the first occurrence is found, it will return true if the property isEqualTo() the supplied value. The iteration keeps track of entries that have been recursed into previously to avoid loops. This method is synchronized with other IORegistryEntry accesses to the property table(s).
* @param aKey The property's name as a C-string.
* @param value The property value to be compared.
* @param plane The plane to iterate over, eg. gIOServicePlane.
* @param options kIORegistryIterateRecursively may be set to recurse automatically into the registry hierarchy. Without this option, this method degenerates into the standard propertyExists() call. kIORegistryIterateParents may be set to iterate the parents of the entry, in place of the children.
* @result True if the property was found and isEqualTo() the supplied value. */
bool propertyHasValue( const char * aKey,
const OSObject * value,
const IORegistryPlane * plane,
uint32_t options =
kIORegistryIterateRecursively |
kIORegistryIterateParents) const;
/*! @function copyProperty
* @abstract Synchronized method to obtain a property from a registry entry's property table.
* @discussion This method will lookup a property in a registry entry's property table, using the OSDictionary::getObject semantics, and return a reference to the caller. This method is synchronized with other IORegistryEntry accesses to the property table.
* @param aKey The property's name as an OSSymbol.
* @result The property value found, or zero. It should be released by the caller. */
virtual OSPtr<OSObject> copyProperty( const OSSymbol * aKey) const;
/*! @function copyProperty
* @abstract Synchronized method to obtain a property from a registry entry's property table.
* @discussion This method will lookup a property in a registry entry's property table, using the OSDictionary::getObject semantics, and return a reference to the caller. This method is synchronized with other IORegistryEntry accesses to the property table.
* @param aKey The property's name as an OSString.
* @result The property value found, or zero. It should be released by the caller. */
virtual OSPtr<OSObject> copyProperty( const OSString * aKey) const;
/*! @function copyProperty
* @abstract Synchronized method to obtain a property from a registry entry's property table.
* @discussion This method will lookup a property in a registry entry's property table, using the OSDictionary::getObject semantics, and return a reference to the caller. This method is synchronized with other IORegistryEntry accesses to the property table.
* @param aKey The property's name as a C-string.
* @result The property value found, or zero. It should be released by the caller. */
virtual OSPtr<OSObject> copyProperty( const char * aKey) const;
/*! @function dictionaryWithProperties
* @abstract Synchronized method to obtain copy a registry entry's property table.
* @discussion This method will copy a registry entry's property table, using the OSDictionary::withDictionary semantics. This method is synchronized with other IORegistryEntry accesses to the property table. Since OSDictionary will only copy property values by reference, synchronization is not guaranteed to any collection values.
* @result The created dictionary, or zero on a resource value. It should be released by the caller. */
virtual OSPtr<OSDictionary> dictionaryWithProperties( void ) const;
/*! @function serializeProperties
* @abstract Synchronized method to serialize a registry entry's property table.
* @discussion This method will serialize a registry entry's property table, using the OSDictionary::serialize semantics. This method is synchronized with other IORegistryEntry accesses to the property table. Many non-kernel clients of IOKit read information from the registry via properties, and will invoke this method in a registry entry to create a serialization of all the entry's properties, which is then reconstructed in the client's task as a CFDictionary. This method may be intercepted by subclasses to update their properties or implement a different serialization method, though it is usually better to implement such functionality by creating objects in the property table and implementing their serialize methods, avoiding any need to implement serializeProperties.
* @param serialize The OSSerialize instance representing the serialization request.
* @result True on success, false otherwise. */
virtual bool serializeProperties( OSSerialize * serialize ) const;
/* Unsynchronized(!) property table access */
/*! @function getPropertyTable
* @abstract Unsynchronized accessor to a registry entry's property table.
* @discussion This method will return a pointer to the live property table as an OSDictionery. Its use is not recommended in most cases, instead use the synchronized accessors and helper functions of IORegistryEntry to access properties. It can only safely be used by one thread, which usually means it can only be used before a registry entry is entered into the registry.
* @result A pointer to the property table as an OSDictionary. The pointer is valid while the registry entry is retained, and should not be released by the caller. */
/* inline */ OSDictionary * getPropertyTable( void ) const;
/* { return(fPropertyTable); } */
/* Set properties from user level, to be overridden if supported */
/*! @function setProperties
* @abstract Optionally supported external method to set properties in a registry entry.
* @discussion This method is not implemented by IORegistryEntry, but is available to kernel and non-kernel clients to set properties in a registry entry. IOUserClient provides connection based, more controlled access to this functionality and may be more appropriate for many uses, since there is no differentiation between clients available to this method.
* @param properties Any OSObject subclass, to be interpreted by the implementing method - for example an OSDictionary, OSData etc. may all be appropriate.
* @result An IOReturn code to be returned to the caller. */
virtual IOReturn setProperties( OSObject * properties );
/* Topology */
/*! @function getParentIterator
* @abstract Returns an iterator over an registry entry's parent entries in a specified plane.
* @param plane The plane object.
* @result Returns an iterator over the parents of the registry entry, or zero if there is a resource failure. The iterator must be released when the iteration is finished. All objects returned by the iteration are retained while the iterator is valid, though they may no longer be attached during the iteration. */
virtual OSPtr<OSIterator> getParentIterator( const IORegistryPlane * plane )
const;
virtual void applyToParents( IORegistryEntryApplierFunction applier,
void * context,
const IORegistryPlane * plane ) const;
/*! @function getParentEntry
* @abstract Returns an registry entry's first parent entry in a plane.
* @discussion This function will return the parent to which a registry entry was first attached. Since the majority of registry entrys have only one provider, this is a useful simplification.
* @param plane The plane object.
* @result Returns the first parent of the registry entry, or zero if the entry is not attached into the registry in that plane. The parent is retained while the entry is attached, and should not be released by the caller. */
virtual IORegistryEntry * getParentEntry( const IORegistryPlane * plane ) const;
/*! @function getChildIterator
* @abstract Returns an iterator over an registry entry's child entries in a plane.
* @discussion This method creates an iterator which will return each of a registry entry's child entries in a specified plane.
* @param plane The plane object.
* @result Returns an iterator over the children of the entry, or zero if there is a resource failure. The iterator must be released when the iteration is finished. All objects returned by the iteration are retained while the iterator is valid, though they may no longer be attached during the iteration. */
virtual OSPtr<OSIterator> getChildIterator( const IORegistryPlane * plane )
const;
virtual void applyToChildren( IORegistryEntryApplierFunction applier,
void * context,
const IORegistryPlane * plane ) const;
/*! @function getChildEntry
* @abstract Returns an registry entry's first child entry in a plane.
* @discussion This function will return the child which first attached to a registry entry.
* @param plane The plane object.
* @result Returns the first child of the registry entry, or zero if the entry is not attached into the registry in that plane. The child is retained while the entry is attached, and should not be released by the caller. */
virtual IORegistryEntry * getChildEntry( const IORegistryPlane * plane ) const;
/*! @function isChild
* @abstract Determines whether a registry entry is the child of another in a plane.
* @discussion This method called in the parent entry determines if the specified entry is a child, in a plane. Additionally, it can check if the child is the only child of the parent entry.
* @param child The possible child registry entry.
* @param plane The plane object.
* @param onlyChild If true, check also if the child is the only child.
* @result If the child argument is not a child of the registry entry, false is returned. If onlyChild is true and the child is not the only child of the entry, false is returned, otherwise true is returned. */
virtual bool isChild( IORegistryEntry * child,
const IORegistryPlane * plane,
bool onlyChild = false ) const;
/*! @function isParent
* @abstract Determines whether a registry entry is the parent of another in a plane.
* @discussion This method called in the child entry determines if the specified entry is a parent, in a plane. Additionally, it can check if the parent is the only parent of the child entry.
* @param parent The possible parent registry entry.
* @param plane The plane object.
* @param onlyParent If true, check also if the parent is the only parent.
* @result If the parent argument is not a parent of the registry entry, false is returned. If onlyParent is true and the parent is not the only parent of the entry, false is returned, otherwise true is returned. */
virtual bool isParent( IORegistryEntry * parent,
const IORegistryPlane * plane,
bool onlyParent = false ) const;
/*! @function inPlane
* @abstract Determines whether a registry entry is attached in a plane.
* @discussion This method determines if the entry is attached in a plane to any other entry. It can also be used to determine if the entry is a member of any plane.
* @param plane The plane object, 0 indicates any plane.
* @result If the entry has a parent in the given plane or if plane = 0 then if entry has any parent; return true, otherwise false. */
virtual bool inPlane( const IORegistryPlane * plane = NULL) const;
/*! @function getDepth
* @abstract Counts the maximum number of entries between an entry and the registry root, in a plane.
* @discussion This method counts the number of entries between and entry and the registry root, in a plane, for each parent of the entry and returns the maximum value.
* @param plane The plane object.
* @result The maximum number of entries between the entry and the root. Zero is returned if the entry is not attached in the plane. */
virtual unsigned int getDepth( const IORegistryPlane * plane ) const;
/* Attach / detach */
/*! @function attachToParent
* @abstract Attaches a entry to a parent entry in a plane.
* @discussion This is the usual method of entering an entry into the registry. It is a no-op and success if the entry is already attached to the parent. Attaching the entry into the registry retains both the child and parent while they are attached. This method will call attachToChild in the parent entry if it is not being called from attachToChild.
* @param parent The registry entry to attach to.
* @param plane The plane object.
* @result true on success, or false on a resource failure, or if the parent is the same as the child. */
virtual bool attachToParent( IORegistryEntry * parent,
const IORegistryPlane * plane );
/*! @function detachFromParent
* @abstract Detaches an entry from a parent entry in a plane.
* @discussion This is the usual method of removing an entry from the registry. It is a no-op if the entry is not attached to the parent. Detaching the entry will release both the child and parent. This method will call detachFromChild in the parent entry if it is not being called from detachFromChild.
* @param parent The registry entry to detach from.
* @param plane The plane object. */
virtual void detachFromParent( IORegistryEntry * parent,
const IORegistryPlane * plane );
/*! @function attachToChild
* @abstract Method called in the parent entry when a child attaches.
* @discussion This method is called in the parent entry when a child attaches, to make overrides possible. This method will also call attachToParent in the child entry if it is not being called from attachToParent. It is a no-op and success if the entry is already a child. Attaching the entry into the registry retains both the child and parent while they are attached.
* @param child The registry entry being attached.
* @param plane The plane object.
* @result true on success, or false on a resource failure, or if the parent is the same as the child. */
virtual bool attachToChild( IORegistryEntry * child,
const IORegistryPlane * plane );
/*! @function detachFromChild
* @abstract Detaches a child entry from its parent in a plane.
* @discussion This method is called in the parent entry when a child detaches, to make overrides possible. It is a no-op if the entry is not a child of the parent. Detaching the entry will release both the child and parent. This method will call detachFromParent in the child entry if it is not being called from detachFromParent.
* @param child The registry entry to detach.
* @param plane The plane object. */
virtual void detachFromChild( IORegistryEntry * child,
const IORegistryPlane * plane );
/*! @function detachAbove
* @abstract Detaches an entry from all its parent entries in a plane.
* @discussion This method calls detachFromParent in the entry for each of its parent entries in the plane.
* @param plane The plane object. */
virtual void detachAbove( const IORegistryPlane * plane );
/*! @function detachAll
* @abstract Detaches an entry and all its children recursively in a plane.
* @discussion This method breaks the registry connections for a subtree. detachAbove is called in the entry, and all child entries and their children in the plane.
* @param plane The plane object. */
virtual void detachAll( const IORegistryPlane * plane );
/* Name, location and path accessors */
/*! @function getName
* @abstract Returns the name assigned to the registry entry as a C-string.
* @discussion Entries can be named in a particular plane, or globally. If the entry is named in plane and the plane is specified that name will be returned, otherwise the global name is returned. The global name defaults to the entry's meta class name if it has not been named.
* @param plane The plane object, or zero for the global name.
* @result A C-string name, valid while the entry is retained. */
virtual const char * getName( const IORegistryPlane * plane = NULL ) const;
/*! @function copyName
* @abstract Returns the name assigned to the registry entry as an OSSymbol.
* @discussion Entries can be named in a particular plane, or globally. If the entry is named in plane and the plane is specified that name will be returned, otherwise the global name is returned. The global name defaults to the entry's meta class name if it has not been named.
* @param plane The plane object, or zero for the global name.
* @result A reference to an OSSymbol for the name, which should be released by the caller. */
virtual OSPtr<const OSSymbol> copyName(
const IORegistryPlane * plane = NULL ) const;
/*! @function compareNames
* @abstract Compares the name of the entry with one or more names, and optionally returns the matching name.
* @discussion This method is called during IOService name matching and elsewhere to compare the entry's global name with a list of names, or a single name. A list of names may be passed as any OSCollection of OSStrings, while a single name may be passed an OSString, in the name parameter. compareNames will call the compareName method for each name, for overrides.
* @param name The name or names to compare with as any OSCollection (eg. OSArray, OSSet, OSDictionary) of OSStrings, or a single name may be passed an OSString.
* @param matched If the caller wants the successfully matched name returned, pass a non-zero pointer for the matched parameter and an OSString will be returned here. It should be released by the caller.
* @result True if one of the names compared true with the entry's global name. */
virtual bool compareNames( OSObject * name, OSString ** matched = NULL ) const;
bool compareNames( OSObject * name, OSSharedPtr<OSString>& matched) const;
/*! @function compareName
* @abstract Compares the name of the entry with one name, and optionally returns the matching name.
* @discussion This method is called during IOService name matching and elsewhere from the compareNames method. It should be overridden to provide non-standard name matching.
* @param name The name to compare with as an OSString.
* @param matched If the caller wants the successfully matched name returned, pass a non-zero pointer for the matched parameter and an OSString will be returned here. It should be released by the caller. Generally, this will be the same as the name parameter, but may not be if wildcards are used.
* @result True if the name compared true with the entry's global name. */
virtual bool compareName( OSString * name, OSString ** matched = NULL ) const;
bool compareName( OSString * name, OSSharedPtr<OSString>& matched) const;
/*! @function setName
* @abstract Sets a name for the registry entry, in a particular plane, or globally.
* @discussion Entries can be named in a particular plane, or globally. If the plane is specified the name applies only to that plane, otherwise the global name is set. The global name defaults to the entry's meta class name if it has not been named.
* @param name An OSSymbol which will be retained.
* @param plane The plane object, or zero to set the global name. */
virtual void setName( const OSSymbol * name,
const IORegistryPlane * plane = NULL );
/*! @function setName
* @abstract Sets a name for the registry entry, in a particular plane, or globally.
* @discussion Entries can be named in a particular plane, or globally. If the plane is specified the name applies only to that plane, otherwise the global name is set. The global name defaults to the entry's meta class name if it has not been named.
* @param name A const C-string name which will be copied.
* @param plane The plane object, or zero to set the global name. */
virtual void setName( const char * name,
const IORegistryPlane * plane = NULL );
/*! @function getLocation
* @abstract Returns the location string assigned to the registry entry as a C-string.
* @discussion Entries can given a location string in a particular plane, or globally. If the entry has had a location set in a plane and the plane is specified that location string will be returned, otherwise the global location string is returned. If no global location string has been set, zero is returned.
* @param plane The plane object, or zero for the global name.
* @result A C-string location string, valid while the entry is retained, or zero. */
virtual const char * getLocation( const IORegistryPlane * plane = NULL ) const;
/*! @function copyLocation
* @abstract Returns the location string assigned to the registry entry as an OSSymbol.
* @discussion Entries can given a location string in a particular plane, or globally. If the entry has had a location set in a plane and the plane is specified that location string will be returned, otherwise the global location string is returned. If no global location string has been set, zero is returned.
* @param plane The plane object, or zero for the global name.
* @result A reference to an OSSymbol for the location if one exists, which should be released by the caller, or zero. */
virtual OSPtr<const OSSymbol> copyLocation(
const IORegistryPlane * plane = NULL ) const;
/*! @function setLocation
* @abstract Sets a location string for the registry entry, in a particular plane, or globally.
* @discussion Entries can be given a location string in a particular plane, or globally. If the plane is specified the location applies only to that plane, otherwise the global location is set. The location string may be used during path lookups of registry entries, to distinguish between sibling entries with the same name. The default IORegistryEntry parsing of location strings expects a list of hex numbers separated by commas, though subclasses of IORegistryEntry might do their own parsing.
* @param location A C-string location string which will be copied, or an OSSymbol which will be retained.
* @param plane The plane object, or zero to set the global location string. */
virtual void setLocation( const OSSymbol * location,
const IORegistryPlane * plane = NULL );
virtual void setLocation( const char * location,
const IORegistryPlane * plane = NULL );
/*! @function getPath
* @abstract Create a path for a registry entry.
* @discussion The path for a registry entry is copied to the caller's buffer. The path describes the entry's attachment in a particular plane, which must be specified. The path begins with the plane name followed by a colon, and then followed by '/' separated path components for each of the entries between the root and the registry entry. Each component is constructed with the getPathComponent method called in each entry. An alias may also exist for the entry, which are described as properties in a registry entry found at /aliases in the plane. If a property value interpreted as a path in a call to IORegistryEntry::fromPath yields the entry, then the property name is used as the entry's path.
* @param path A char buffer allocated by the caller.
* @param length An in/out parameter - the caller sets the length of the buffer available, and getPath returns the total length of the path copied to the buffer.
* @param plane The plane object.
* @result getPath will fail if the entry is not attached in the plane, or if the buffer is not large enough to contain the path. */
virtual bool getPath( char * path, int * length,
const IORegistryPlane * plane) const;
/*! @function getPathComponent
* @abstract Create a path component for a registry entry.
* @discussion Each component of a path created with getPath is created with getPathComponent. The default implementation concatenates the entry's name in the the plane, with the "at" symbol and the location string of the entry in the plane if it has been set.
* @param path A char buffer allocated by the caller.
* @param length An in/out parameter - the caller sets the length of the buffer available, and getPathComponent returns the total length of the path component copied to the buffer.
* @param plane The plane object.
* @result true if the path fits into the supplied buffer or false on a overflow. */
virtual bool getPathComponent( char * path, int * length,
const IORegistryPlane * plane ) const;
/*! @function fromPath
* @abstract Looks up a registry entry by path.
* @discussion This function parses paths to lookup registry entries. The path may begin with the <plane name>: created by getPath, or the plane may be set by the caller. If there are characters remaining unparsed after an entry has been looked up, this may be considered an invalid lookup, or those characters may be passed back to the caller and the lookup successful.
* @param path A C-string path.
* @param plane The plane to lookup up the path, or zero, in which case the path must begin with the plane name.
* @param residualPath If the path may contain residual characters after the last path component, the residual will be copied back to the caller's residualPath buffer. If there are residual characters and no residual buffer is specified, fromPath will fail.
* @param residualLength An in/out parameter - the caller sets the length of the residual buffer available, and fromPath returns the total length of the residual path copied to the buffer. If there is no residualBuffer (residualPath = 0) then residualLength may be zero also.
* @param fromEntry The lookup will proceed rooted at this entry if non-zero, otherwise it proceeds from the root of the plane.
* @result A retained registry entry is returned on success, or zero on failure. The caller should release the entry. */
static OSPtr<IORegistryEntry> fromPath( const char * path,
const IORegistryPlane * plane = NULL,
char * residualPath = NULL,
int * residualLength = NULL,
IORegistryEntry * fromEntry = NULL );
/*! @function fromPath
* @abstract Looks up a registry entry by relative path.
* @discussion This function looks up a entry below the called entry by a relative path. It is just a convenience that calls IORegistryEntry::fromPath with this as the fromEntry parameter.
* @param path See IORegistryEntry::fromPath.
* @param plane See IORegistryEntry::fromPath.
* @param residualPath See IORegistryEntry::fromPath.
* @param residualLength See IORegistryEntry::fromPath.
* @result See IORegistryEntry::fromPath. */
virtual OSPtr<IORegistryEntry> childFromPath( const char * path,
const IORegistryPlane * plane = NULL,
char * residualPath = NULL,
int * residualLength = NULL );
/*! @function dealiasPath
* @abstract Strips any aliases from the head of path and returns the full path.
* @discussion If the path specified begins with an alias found in the /aliases entry, the value of the alias is returned, and a pointer into the passed in path after the alias is passed back to the caller. If an alias is not found, zero is returned and the path parameter is unchanged.
* @param opath An in/out paramter - the caller passes in a pointer to a C-string pointer to a path. If an alias is found, dealiasPath returns a pointer into the path just beyond the end of the alias.
* @param plane A plane object must be specified.
* @result A C-string pointer to the value of the alias if one is found, or zero if not. */
static const char * dealiasPath( const char ** opath,
const IORegistryPlane * plane );
/*! @function makePlane
* @abstract Constructs an IORegistryPlane object.
* @discussion Most planes in IOKit are created by the OS, although other planes may be created.
* @param name A C-string name for the new plane, to be copied.
* @result A new instance of an IORegistryPlane, or zero on failure. */
static OSPtr<const IORegistryPlane> makePlane( const char * name );
/*! @abstract Returns an ID for the registry entry that is global to all tasks.
* @discussion The entry ID returned by getRegistryEntryID can be used to identify a registry entry across all tasks. A registry entry may be looked up by its entry ID by creating a matching dictionary with IORegistryEntryIDMatching() in user space, or <code>IOService::registryEntryIDMatching()</code> in the kernel, to be used with the IOKit matching functions. The ID is valid only until the machine reboots.
* @result An ID for the registry entry, assigned when the entry is first attached in the registry. */
uint64_t getRegistryEntryID( void );
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* * * * * * * * * * * * internals * * * * * * * * * * * */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * */
virtual bool init( IORegistryEntry * from,
const IORegistryPlane * inPlane );
private:
static LIBKERN_RETURNS_NOT_RETAINED IORegistryEntry * initialize( void );
private:
inline bool arrayMember( OSArray * set,
const IORegistryEntry * member,
unsigned int * index = NULL ) const;
bool makeLink( IORegistryEntry * to,
unsigned int relation,
const IORegistryPlane * plane ) const;
void breakLink( IORegistryEntry * to,
unsigned int relation,
const IORegistryPlane * plane ) const;
APPLE_KEXT_COMPATIBILITY_VIRTUAL
OSArray * getParentSetReference( const IORegistryPlane * plane )
const;
APPLE_KEXT_COMPATIBILITY_VIRTUAL
OSArray * getChildSetReference( const IORegistryPlane * plane )
const;
APPLE_KEXT_COMPATIBILITY_VIRTUAL
IORegistryEntry * getChildFromComponent( const char ** path,
const IORegistryPlane * plane );
APPLE_KEXT_COMPATIBILITY_VIRTUAL
LIBKERN_RETURNS_NOT_RETAINED const OSSymbol * hasAlias(
const IORegistryPlane * plane,
char * opath = NULL, int * length = NULL ) const;
APPLE_KEXT_COMPATIBILITY_VIRTUAL
const char * matchPathLocation( const char * cmp,
const IORegistryPlane * plane );
};
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*! @class IORegistryIterator : public OSIterator
* @abstract An iterator over the registry.
* @discussion An iterator that can traverse the children or parents of a registry entry in a plane, and recurse. Access to the registry is protected against multiple threads, but an IORegistryIterator instance is for use by one thread only. */
class IORegistryIterator : public OSIterator
{
OSDeclareAbstractStructors(IORegistryIterator);
private:
struct IORegCursor {
IORegCursor * next;
IORegistryEntry * current;
OSIterator * iter;
};
IORegCursor start;
IORegCursor * where;
IORegistryEntry * root;
OSOrderedSet * done;
const IORegistryPlane * plane;
IOOptionBits options;
virtual void free( void ) APPLE_KEXT_OVERRIDE;
public:
/*! @function iterateOver
* @abstract Create an iterator rooted at a given registry entry.
* @discussion This method creates an IORegistryIterator that is set up with options to iterate children or parents of a root entry, and to recurse automatically into entries as they are returned, or only when instructed. The iterator object keeps track of entries that have been recursed into previously to avoid loops.
* @param start The root entry to begin the iteration at.
* @param plane A plane object must be specified.
* @param options kIORegistryIterateRecursively may be set to recurse automatically into each entry as it is returned. This option affects the behaviour of the getNextObject method, which is defined in the OSIterator superclass. Other methods will override this behaviour. kIORegistryIterateParents may be set to iterate the parents of each entry, by default the children are iterated.
* @result A created IORegistryIterator instance, to be released by the caller when it has finished with it. */
static OSPtr<IORegistryIterator> iterateOver( IORegistryEntry * start,
const IORegistryPlane * plane,
IOOptionBits options = 0 );
/*! @function iterateOver
* @abstract Create an iterator rooted at the registry root.
* @discussion This method creates an IORegistryIterator that is set up with options to iterate children of the registry root entry, and to recurse automatically into entries as they are returned, or only when instructed. The iterator object keeps track of entries that have been recursed into previously to avoid loops.
* @param plane A plane object must be specified.
* @param options kIORegistryIterateRecursively may be set to recurse automatically into each entry as it is returned. This option affects the behaviour of the getNextObject method, which is defined in the OSIterator superclass. Other methods will override this behaviour. kIORegistryIterateParents may be set to iterate the parents of each entry, by default the children are iterated.
* @result A created IORegistryIterator instance, to be released by the caller when it has finished with it. */
static OSPtr<IORegistryIterator> iterateOver( const IORegistryPlane * plane,
IOOptionBits options = 0 );
/*! @function getNextObject
* @abstract Return the next object in the registry iteration.
* @discussion This method calls either getNextObjectFlat or getNextObjectRecursive depending on the options the iterator was created with. This implements the OSIterator defined getNextObject method. The object returned is retained while the iterator is pointing at it (its the current entry), or recursing into it. The caller should not release it.
* @result The next registry entry in the iteration (the current entry), or zero if the iteration has finished at this level of recursion. The entry returned is retained while the iterator is pointing at it (its the current entry), or recursing into it. The caller should not release it. */
virtual IORegistryEntry * getNextObject( void ) APPLE_KEXT_OVERRIDE;
/*! @function getNextObjectFlat
* @abstract Return the next object in the registry iteration, ignoring the kIORegistryIterateRecursively option.
* @discussion This method returns the next child, or parent if the kIORegistryIterateParents option was used to create the iterator, of the current root entry. The object returned is retained while the iterator is pointing at it (its the current entry), or recursing into it. The caller should not release it.
* @result The next registry entry in the iteration (the current entry), or zero if the iteration has finished at this level of recursion, or the iteration is invalid (see isValid). The entry returned is retained while the iterator is pointing at it (its the current entry), or recursing into it. The caller should not release it. */
virtual IORegistryEntry * getNextObjectFlat( void );
/*! @function getNextObjectRecursive
* @abstract Return the next object in the registry iteration, and enter it.
* @discussion If the iterator has a current entry, and the iterator has not already entered previously, enterEntry is called to recurse into it, ie. make it the new root, and the next child, or parent if the kIORegistryIterateParents option was used to create the iterator, at this new level of recursion is returned. If there is no current entry at this level of recursion, exitEntry is called and the process repeats, until the iteration returns to the entry the iterator was created with and zero is returned. The object returned is retained while the iterator is pointing at it (its the current entry), or recursing into it. The caller should not release it.
* @result The next registry entry in the iteration (the current entry), or zero if its finished, or the iteration is invalid (see isValid). The entry returned is retained while the iterator is pointing at it (its the current entry), or recursing into it. The caller should not release it. */
virtual IORegistryEntry * getNextObjectRecursive( void );
/*! @function getCurrentEntry
* @abstract Return the current entry in the registry iteration.
* @discussion This method returns the current entry, last returned by getNextObject et al. The object returned is retained while the iterator is pointing at it (its the current entry), or recursing into it. The caller should not release it. If the iteration is no longer valid (see isValid), the current entry is zero.
* @result The current registry entry in the iteration, or zero if the last iteration returned zero, or the iteration is invalid (see isValid). The entry returned is retained while the iterator is pointing at it (its the current entry), or recursing into it. The caller should not release it. */
virtual IORegistryEntry * getCurrentEntry( void );
/*! @function enterEntry
* @abstract Recurse into the current entry in the registry iteration.
* @discussion This method makes the current entry, ie. the last entry returned by getNextObject et al., the root in a new level of recursion. */
virtual void enterEntry( void );
/*! @function enterEntry
* @abstract Recurse into the current entry in the registry iteration.
* @discussion This method recurses into an entry as with enterEntry, but also switches from the current plane to a new one set by the caller.
* @param plane The new plane to switch into. */
virtual void enterEntry( const IORegistryPlane * plane );
/*! @function exitEntry
* @abstract Exits a level of recursion, restoring the current entry.
* @discussion This method undoes an enterEntry, restoring the current entry. If there are no more levels of recursion to exit false is returned, otherwise true is returned.
* @result true if a level of recursion was undone, false if no recursive levels are left in the iteration. */
virtual bool exitEntry( void );
/*! @function reset
* @abstract Exits all levels of recursion, restoring the iterator to its state at creation.
* @discussion This method exits all levels of recursion, and restores the iterator to its state at creation. */
virtual void reset( void ) APPLE_KEXT_OVERRIDE;
/*! @function isValid
* @abstract Checks that no registry changes have invalidated the iteration.
* @discussion If a registry iteration is invalidated by changes to the registry, it will be made invalid, the currentEntry will be considered zero, and further calls to getNextObject et al. will return zero. The iterator should be reset to restart the iteration when this happens.
* @result false if the iterator has been invalidated by changes to the registry, true otherwise. */
virtual bool isValid( void ) APPLE_KEXT_OVERRIDE;
/*! @function iterateAll
* @abstract Iterates all entries (with getNextObject) and returns a set of all returned entries.
* @discussion This method will reset, then iterate all entries in the iteration (with getNextObject).
* @result A set of entries returned by the iteration. The caller should release the set when it has finished with it. Zero is returned on a resource failure. */
virtual OSPtr<OSOrderedSet> iterateAll( void );
};
#endif /* _IOKIT_IOREGISTRYENTRY_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOTypes.h | /*
* Copyright (c) 1998-2012 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef __IOKIT_IOTYPES_H
#define __IOKIT_IOTYPES_H
#ifndef IOKIT
#define IOKIT 1
#endif /* !IOKIT */
#include <sys/cdefs.h>
#include <IOKit/system.h>
#include <IOKit/IOReturn.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef NULL
#if defined (__cplusplus)
#if __cplusplus >= 201103L && (defined(__arm__) || defined(__arm64__))
#define NULL nullptr
#else
#define NULL 0
#endif
#else
#define NULL ((void *)0)
#endif
#endif
/*
* Simple data types.
*/
#include <stdbool.h>
#include <libkern/OSTypes.h>
#include <libkern/OSBase.h>
typedef UInt32 IOOptionBits;
typedef SInt32 IOFixed;
typedef UInt32 IOVersion;
typedef UInt32 IOItemCount;
typedef UInt32 IOCacheMode;
typedef UInt32 IOByteCount32;
typedef UInt64 IOByteCount64;
typedef UInt32 IOPhysicalAddress32;
typedef UInt64 IOPhysicalAddress64;
typedef UInt32 IOPhysicalLength32;
typedef UInt64 IOPhysicalLength64;
#if !defined(__arm__) && !defined(__i386__)
typedef mach_vm_address_t IOVirtualAddress __kernel_ptr_semantics;
#else
typedef vm_address_t IOVirtualAddress __kernel_ptr_semantics;
#endif
#if !defined(__arm__) && !defined(__i386__) && !(defined(__x86_64__) && !defined(KERNEL)) && !(defined(__arm64__) && !defined(__LP64__))
typedef IOByteCount64 IOByteCount;
#define PRIIOByteCount PRIu64
#else
typedef IOByteCount32 IOByteCount;
#define PRIIOByteCount PRIu32
#endif
typedef IOVirtualAddress IOLogicalAddress;
#if !defined(__arm__) && !defined(__i386__) && !(defined(__x86_64__) && !defined(KERNEL))
typedef IOPhysicalAddress64 IOPhysicalAddress;
typedef IOPhysicalLength64 IOPhysicalLength;
#define IOPhysical32( hi, lo ) ((UInt64) lo + ((UInt64)(hi) << 32))
#define IOPhysSize 64
#else
typedef IOPhysicalAddress32 IOPhysicalAddress;
typedef IOPhysicalLength32 IOPhysicalLength;
#define IOPhysical32( hi, lo ) (lo)
#define IOPhysSize 32
#endif
typedef struct{
IOPhysicalAddress address;
IOByteCount length;
} IOPhysicalRange;
typedef struct{
IOVirtualAddress address;
IOByteCount length;
} IOVirtualRange;
#if !defined(__arm__) && !defined(__i386__)
typedef IOVirtualRange IOAddressRange;
#else
typedef struct{
mach_vm_address_t address;
mach_vm_size_t length;
} IOAddressRange;
#endif
/*
* Map between #defined or enum'd constants and text description.
*/
typedef struct {
int value;
const char *name;
} IONamedValue;
/*
* Memory alignment -- specified as a power of two.
*/
typedef unsigned int IOAlignment;
#define IO_NULL_VM_TASK ((vm_task_t)0)
/*
* Pull in machine specific stuff.
*/
//#include <IOKit/machine/IOTypes.h>
#ifndef MACH_KERNEL
#ifndef __IOKIT_PORTS_DEFINED__
#define __IOKIT_PORTS_DEFINED__
#ifdef __cplusplus
class OSObject;
typedef OSObject * io_object_t;
#else
typedef struct OSObject * io_object_t;
#endif
#endif /* __IOKIT_PORTS_DEFINED__ */
#include <device/device_types.h>
typedef io_object_t io_connect_t;
typedef io_object_t io_enumerator_t;
typedef io_object_t io_ident_t;
typedef io_object_t io_iterator_t;
typedef io_object_t io_registry_entry_t;
typedef io_object_t io_service_t;
typedef io_object_t uext_object_t;
#define IO_OBJECT_NULL ((io_object_t) 0)
#endif /* MACH_KERNEL */
#include <IOKit/IOMapTypes.h>
/*! @enum Scale Factors
* @discussion Used when a scale_factor parameter is required to define a unit of time.
* @constant kNanosecondScale Scale factor for nanosecond based times.
* @constant kMicrosecondScale Scale factor for microsecond based times.
* @constant kMillisecondScale Scale factor for millisecond based times.
* @constant kTickScale Scale factor for the standard (100Hz) tick.
* @constant kSecondScale Scale factor for second based times. */
enum {
kNanosecondScale = 1,
kMicrosecondScale = 1000,
kMillisecondScale = 1000 * 1000,
kSecondScale = 1000 * 1000 * 1000,
kTickScale = (kSecondScale / 100)
};
enum {
kIOConnectMethodVarOutputSize = -3
};
/* compatibility types */
#ifdef __cplusplus
}
#endif
enum {
kIOMaxBusStall40usec = 40000,
kIOMaxBusStall30usec = 30000,
kIOMaxBusStall25usec = 25000,
kIOMaxBusStall20usec = 20000,
kIOMaxBusStall10usec = 10000,
kIOMaxBusStall5usec = 5000,
kIOMaxBusStallNone = 0,
};
#endif /* ! __IOKIT_IOTYPES_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOServicePM.h | /*
* Copyright (c) 1998-2019 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _IOKIT_IOSERVICEPM_H
#define _IOKIT_IOSERVICEPM_H
#include <IOKit/pwr_mgt/IOPM.h>
class IOService;
class IOServicePM;
class IOPowerConnection;
class IOWorkLoop;
class IOCommandGate;
class IOTimerEventSource;
class IOPlatformExpert;
#endif /* !_IOKIT_IOSERVICEPM_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOMapper.h | /*
* Copyright (c) 1998-2016 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef __IOKIT_IOMAPPER_H
#define __IOKIT_IOMAPPER_H
#include <sys/cdefs.h>
__BEGIN_DECLS
#include <IOKit/IOTypes.h>
#include <mach/vm_types.h>
// These are C accessors to the system mapper for non-IOKit clients
ppnum_t IOMapperIOVMAlloc(unsigned pages);
void IOMapperIOVMFree(ppnum_t addr, unsigned pages);
ppnum_t IOMapperInsertPage(ppnum_t addr, unsigned offset, ppnum_t page);
__END_DECLS
#if __cplusplus
#include <IOKit/IOService.h>
#include <IOKit/IOMemoryDescriptor.h>
#include <IOKit/IODMACommand.h>
#include <libkern/c++/OSPtr.h>
class OSData;
extern const OSSymbol * gIOMapperIDKey;
class IOMapper : public IOService
{
OSDeclareAbstractStructors(IOMapper);
// Give the platform expert access to setMapperRequired();
friend class IOPlatformExpert;
friend class IOMemoryDescriptor;
friend class IOGeneralMemoryDescriptor;
private:
enum SystemMapperState {
kNoMapper = 0,
kUnknown = 1,
kHasMapper = 2, // Any other value is pointer to a live mapper
kWaitMask = 3,
};
protected:
uint64_t __reserved[8];
bool fIsSystem;
static void setMapperRequired(bool hasMapper);
static void waitForSystemMapper();
virtual bool initHardware(IOService *provider) = 0;
public:
virtual bool start(IOService *provider) APPLE_KEXT_OVERRIDE;
virtual void free() APPLE_KEXT_OVERRIDE;
// To get access to the system mapper IOMapper::gSystem
static IOMapper *gSystem;
static void
checkForSystemMapper()
{
if ((uintptr_t) gSystem & kWaitMask) {
waitForSystemMapper();
}
}
static OSPtr<IOMapper> copyMapperForDevice(IOService * device);
static OSPtr<IOMapper> copyMapperForDeviceWithIndex(IOService * device, unsigned int index);
// { subclasses
virtual uint64_t getPageSize(void) const = 0;
virtual IOReturn iovmMapMemory(IOMemoryDescriptor * memory,
uint64_t descriptorOffset,
uint64_t length,
uint32_t mapOptions,
const IODMAMapSpecification * mapSpecification,
IODMACommand * dmaCommand,
const IODMAMapPageList * pageList,
uint64_t * mapAddress,
uint64_t * mapLength) = 0;
virtual IOReturn iovmUnmapMemory(IOMemoryDescriptor * memory,
IODMACommand * dmaCommand,
uint64_t mapAddress,
uint64_t mapLength) = 0;
virtual IOReturn iovmInsert(uint32_t options,
uint64_t mapAddress,
uint64_t offset,
uint64_t physicalAddress,
uint64_t length) = 0;
virtual uint64_t mapToPhysicalAddress(uint64_t mappedAddress) = 0;
// }
private:
OSMetaClassDeclareReservedUnused(IOMapper, 0);
OSMetaClassDeclareReservedUnused(IOMapper, 1);
OSMetaClassDeclareReservedUnused(IOMapper, 2);
OSMetaClassDeclareReservedUnused(IOMapper, 3);
OSMetaClassDeclareReservedUnused(IOMapper, 4);
OSMetaClassDeclareReservedUnused(IOMapper, 5);
OSMetaClassDeclareReservedUnused(IOMapper, 6);
OSMetaClassDeclareReservedUnused(IOMapper, 7);
OSMetaClassDeclareReservedUnused(IOMapper, 8);
OSMetaClassDeclareReservedUnused(IOMapper, 9);
OSMetaClassDeclareReservedUnused(IOMapper, 10);
OSMetaClassDeclareReservedUnused(IOMapper, 11);
OSMetaClassDeclareReservedUnused(IOMapper, 12);
OSMetaClassDeclareReservedUnused(IOMapper, 13);
OSMetaClassDeclareReservedUnused(IOMapper, 14);
OSMetaClassDeclareReservedUnused(IOMapper, 15);
};
#endif /* __cplusplus */
#endif /* !__IOKIT_IOMAPPER_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOCommandGate.h | /*
* Copyright (c) 1998-2019 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*[
* 1999-8-10 Godfrey van der Linden(gvdl)
* Created.
* ]*/
/*! @language embedded-c++ */
#ifndef _IOKIT_IOCOMMANDGATE_H
#define _IOKIT_IOCOMMANDGATE_H
#include <IOKit/IOEventSource.h>
#include <libkern/c++/OSPtr.h>
/*!
* @class IOCommandGate : public IOEventSource
* @abstract Single-threaded work loop client request mechanism.
* @discussion An IOCommandGate instance is an extremely lightweight mechanism
* that executes an action on the driver's work loop. Although the code does not
* technically execute on the work loop itself, a single-threaded work loop semantic
* is maintained for this event source using the work loop gate. The command gate
* tests for a potential self dead lock by checking if the runCommand request is
* made from the work loop's thread, it doesn't check for a mutual dead lock though
* where a pair of work loop's dead lock each other.
* <br><br>
* The IOCommandGate is a lighter weight version of the IOCommandQueue and
* should be used in preference. Generally use a command queue whenever you need a
* client to submit a request to a work loop. A typical command gate action would
* check if the hardware is active, if so it will add the request to a pending
* queue internal to the device or the device's family. Otherwise if the hardware
* is inactive then this request can be acted upon immediately.
* <br><br>
* CAUTION: The runAction, runCommand, and attemptCommand functions cannot be called from an interrupt context.
*
*/
class IOCommandGate : public IOEventSource
{
OSDeclareDefaultStructors(IOCommandGate);
public:
/*!
* @typedef Action
* @discussion Type and arguments of callout C function that is used when
* a runCommand is executed by a client. Cast to this type when you want a C++
* member function to be used. Note the arg1 - arg3 parameters are straight pass
* through from the runCommand to the action callout.
* @param owner
* Target of the function, can be used as a refcon. The owner is set
* during initialisation of the IOCommandGate instance. Note if a C++ function
* was specified this parameter is implicitly the first paramter in the target
* member function's parameter list.
* @param arg0 Argument to action from run operation.
* @param arg1 Argument to action from run operation.
* @param arg2 Argument to action from run operation.
* @param arg3 Argument to action from run operation.
*/
typedef IOReturn (*Action)(OSObject *owner,
void *arg0, void *arg1,
void *arg2, void *arg3);
protected:
/*! @struct ExpansionData
* @discussion This structure will be used to expand the capablilties of the IOWorkLoop in the future.
*/
struct ExpansionData { };
/*! @var reserved
* Reserved for future use. (Internal use only) */
APPLE_KEXT_WSHADOW_PUSH;
ExpansionData *reserved;
APPLE_KEXT_WSHADOW_POP;
public:
/*! @function commandGate
* @abstract Factory method to create and initialise an IOCommandGate, See $link init.
* @result Returns a pointer to the new command gate if sucessful, 0 otherwise. */
static OSPtr<IOCommandGate> commandGate(OSObject *owner, Action action = NULL);
/*! @function init
* @abstract Class initialiser.
* @discussion Initialiser for IOCommandGate operates only on newly 'newed'
* objects. Shouldn't be used to re-init an existing instance.
* @param owner Owner of this, newly created, instance of the IOCommandGate. This argument will be used as the first parameter in the action callout.
* @param action
* Pointer to a C function that is called whenever a client of the
* IOCommandGate calls runCommand. NB Can be a C++ member function but caller
* must cast the member function to $link IOCommandGate::Action and they will get a
* compiler warning. Defaults to zero, see $link IOEventSource::setAction.
* @result True if inherited classes initialise successfully. */
virtual bool init(OSObject *owner, Action action = NULL);
// Superclass overrides
virtual void free() APPLE_KEXT_OVERRIDE;
virtual void setWorkLoop(IOWorkLoop *inWorkLoop) APPLE_KEXT_OVERRIDE;
/*! @function runCommand
* @abstract Single thread a command with the target work loop.
* @discussion Client function that causes the current action to be called in
* a single threaded manner. Beware the work loop's gate is recursive and command
* gates can cause direct or indirect re-entrancy. When the executing on a
* client's thread runCommand will sleep until the work loop's gate opens for
* execution of client actions, the action is single threaded against all other
* work loop event sources. If the command is disabled the attempt to run a command will be stalled until enable is called.
* @param arg0 Parameter for action of command gate, defaults to 0.
* @param arg1 Parameter for action of command gate, defaults to 0.
* @param arg2 Parameter for action of command gate, defaults to 0.
* @param arg3 Parameter for action of command gate, defaults to 0.
* @result kIOReturnSuccess if successful. kIOReturnAborted if a disabled command gate is free()ed before being reenabled, kIOReturnNoResources if no action available.
*/
virtual IOReturn runCommand(void *arg0 = NULL, void *arg1 = NULL,
void *arg2 = NULL, void *arg3 = NULL);
/*! @function runAction
* @abstract Single thread a call to an action with the target work loop.
* @discussion Client function that causes the given action to be called in
* a single threaded manner. Beware the work loop's gate is recursive and command
* gates can cause direct or indirect re-entrancy. When the executing on a
* client's thread runAction will sleep until the work loop's gate opens for
* execution of client actions, the action is single threaded against all other
* work loop event sources. If the command is disabled the attempt to run a command will be stalled until enable is called.
* @param action Pointer to function to be executed in the context of the work loop.
* @param arg0 Parameter for action parameter, defaults to 0.
* @param arg1 Parameter for action parameter, defaults to 0.
* @param arg2 Parameter for action parameter, defaults to 0.
* @param arg3 Parameter for action parameter, defaults to 0.
* @result The return value of action if it was called, kIOReturnBadArgument if action is not defined, kIOReturnAborted if a disabled command gate is free()ed before being reenabled.
*/
virtual IOReturn runAction(Action action,
void *arg0 = NULL, void *arg1 = NULL,
void *arg2 = NULL, void *arg3 = NULL);
#ifdef __BLOCKS__
/*! @function runActionBlock
* @abstract Single thread a call to an action with the target work loop.
* @discussion Client function that causes the given action to be called in
* a single threaded manner. Beware the work loop's gate is recursive and command
* gates can cause direct or indirect re-entrancy. When the executing on a
* client's thread runAction will sleep until the work loop's gate opens for
* execution of client actions, the action is single threaded against all other
* work loop event sources. If the command is disabled the attempt to run a command will be stalled until enable is called.
* @param action Block to be executed in the context of the work loop.
* @result The return value of action if it was called, kIOReturnBadArgument if action is not defined, kIOReturnAborted if a disabled command gate is free()ed before being reenabled.
*/
IOReturn runActionBlock(ActionBlock action);
#endif /* __BLOCKS__ */
/*! @function attemptCommand
* @abstract Single thread a command with the target work loop.
* @discussion Client function that causes the current action to be called in
* a single threaded manner. When the executing on a client's thread attemptCommand will fail if the work loop's gate is closed.
* @param arg0 Parameter for action of command gate, defaults to 0.
* @param arg1 Parameter for action of command gate, defaults to 0.
* @param arg2 Parameter for action of command gate, defaults to 0.
* @param arg3 Parameter for action of command gate, defaults to 0.
* @result kIOReturnSuccess if successful. kIOReturnNotPermitted if this event source is currently disabled, kIOReturnNoResources if no action available, kIOReturnCannotLock if lock attempt fails.
*/
virtual IOReturn attemptCommand(void *arg0 = NULL, void *arg1 = NULL,
void *arg2 = NULL, void *arg3 = NULL);
/*! @function attemptAction
* @abstract Single thread a call to an action with the target work loop.
* @discussion Client function that causes the given action to be called in
* a single threaded manner. Beware the work loop's gate is recursive and command
* gates can cause direct or indirect re-entrancy. When the executing on a
* client's thread attemptCommand will fail if the work loop's gate is closed.
* @param action Pointer to function to be executed in context of the work loop.
* @param arg0 Parameter for action parameter, defaults to 0.
* @param arg1 Parameter for action parameter, defaults to 0.
* @param arg2 Parameter for action parameter, defaults to 0.
* @param arg3 Parameter for action parameter, defaults to 0.
* @result kIOReturnSuccess if successful. kIOReturnBadArgument if action is not defined, kIOReturnNotPermitted if this event source is currently disabled, kIOReturnCannotLock if lock attempt fails.
*
*/
virtual IOReturn attemptAction(Action action,
void *arg0 = NULL, void *arg1 = NULL,
void *arg2 = NULL, void *arg3 = NULL);
/*! @function commandSleep
* @abstract Put a thread that is currently holding the command gate to sleep.
* @discussion Put a thread to sleep waiting for an event but release the gate first. If the event occurs then the commandGate is closed before the function returns. If the thread does not hold the gate, panic.
* @param event Pointer to an address.
* @param interruptible THREAD_UNINT, THREAD_INTERRUPTIBLE or THREAD_ABORTSAFE. THREAD_UNINT specifies that the sleep cannot be interrupted by a signal. THREAD_INTERRUPTIBLE specifies that the sleep may be interrupted by a "kill -9" signal. THREAD_ABORTSAFE (the default value) specifies that the sleep may be interrupted by any user signal.
* @result THREAD_AWAKENED - normal wakeup, THREAD_TIMED_OUT - timeout expired, THREAD_INTERRUPTED - interrupted, THREAD_RESTART - restart operation entirely. */
virtual IOReturn commandSleep(void *event,
UInt32 interruptible = THREAD_ABORTSAFE);
/*! @function commandWakeup
* @abstract Wakeup one or more threads that are asleep on an event.
* @param event Pointer to an address.
* @param oneThread true to only wake up at most one thread, false otherwise. */
virtual void commandWakeup(void *event, bool oneThread = false);
/*! @function disable
* @abstract Disable the command gate
* @discussion When a command gate is disabled all future calls to runAction and runCommand will stall until the gate is enable()d later. This can be used to block client threads when a system sleep is requested. The IOWorkLoop thread itself will never stall, even when making runAction/runCommand calls. This call must be made from a gated context, to clear potential race conditions. */
virtual void disable() APPLE_KEXT_OVERRIDE;
/*! @function enable
* @abstract Enable command gate, this will unblock any blocked Commands and Actions.
* @discussion Enable the command gate. The attemptAction/attemptCommand calls will now be enabled and can succeeed. Stalled runCommand/runAction calls will be woken up. */
virtual void enable() APPLE_KEXT_OVERRIDE;
/*! @function commandSleep
* @abstract Put a thread that is currently holding the command gate to sleep.
* @discussion Put a thread to sleep waiting for an event but release the gate first. If the event occurs or timeout occurs then the commandGate is closed before the function returns. If the thread does not hold the gate, panic.
* @param event Pointer to an address.
* @param deadline Clock deadline to timeout the sleep.
* @param interruptible THREAD_UNINT, THREAD_INTERRUPTIBLE or THREAD_ABORTSAFE. THREAD_UNINT specifies that the sleep cannot be interrupted by a signal. THREAD_INTERRUPTIBLE specifies that the sleep may be interrupted by a "kill -9" signal. THREAD_ABORTSAFE specifies that the sleep may be interrupted by any user signal.
* @result THREAD_AWAKENED - normal wakeup, THREAD_TIMED_OUT - timeout expired, THREAD_INTERRUPTED - interrupted, THREAD_RESTART - restart operation entirely. */
virtual IOReturn commandSleep(void *event,
AbsoluteTime deadline,
UInt32 interruptible);
private:
#if __LP64__
OSMetaClassDeclareReservedUnused(IOCommandGate, 0);
#else
OSMetaClassDeclareReservedUsedX86(IOCommandGate, 0);
#endif
OSMetaClassDeclareReservedUnused(IOCommandGate, 1);
OSMetaClassDeclareReservedUnused(IOCommandGate, 2);
OSMetaClassDeclareReservedUnused(IOCommandGate, 3);
OSMetaClassDeclareReservedUnused(IOCommandGate, 4);
OSMetaClassDeclareReservedUnused(IOCommandGate, 5);
OSMetaClassDeclareReservedUnused(IOCommandGate, 6);
OSMetaClassDeclareReservedUnused(IOCommandGate, 7);
};
#endif /* !_IOKIT_IOCOMMANDGATE_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOLocks.h | /*
* Copyright (c) 1998-2012 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
*
*/
#ifndef __IOKIT_IOLOCKS_H
#define __IOKIT_IOLOCKS_H
#include <sys/appleapiopts.h>
#include <sys/cdefs.h>
#include <IOKit/system.h>
#include <IOKit/IOReturn.h>
#include <IOKit/IOTypes.h>
#include <machine/machine_routines.h>
#include <libkern/locks.h>
#ifdef __cplusplus
extern "C" {
#endif
/*! @var IOLockGroup
* Global lock group used by all IOKit locks. To simplify kext debugging and lock-heat analysis, consider using lck_* locks with a per-driver lock group, as defined in kern/locks.h.
*/
extern lck_grp_t *IOLockGroup;
/*
* Mutex lock operations
*/
#ifdef IOLOCKS_INLINE
typedef lck_mtx_t IOLock;
#else
typedef struct _IOLock IOLock;
#endif /* IOLOCKS_INLINE */
/*! @function IOLockAlloc
* @abstract Allocates and initializes a mutex.
* @discussion Allocates a mutex in general purpose memory, and initializes it. Mutexes are general purpose blocking mutual exclusion locks, supplied by libkern/locks.h. This function may block and so should not be called from interrupt level or while a spin lock is held. IOLocks use the global IOKit lock group, IOLockGroup. To simplify kext debugging and lock-heat analysis, consider using lck_* locks with a per-driver lock group, as defined in kern/locks.h.
* @result Pointer to the allocated lock, or zero on failure. */
IOLock * IOLockAlloc( void );
/*! @function IOLockFree
* @abstract Frees a mutex.
* @discussion Frees a lock allocated with IOLockAlloc. Mutex should be unlocked with no waiters.
* @param lock Pointer to the allocated lock. */
void IOLockFree( IOLock * lock);
/*! @function IOLockGetMachLock
* @abstract Accessor to a Mach mutex.
* @discussion Accessor to the Mach mutex.
* @param lock Pointer to the allocated lock. */
lck_mtx_t * IOLockGetMachLock( IOLock * lock);
/*! @function IOLockLock
* @abstract Lock a mutex.
* @discussion Lock the mutex. If the lock is held by any thread, block waiting for its unlock. This function may block and so should not be called from interrupt level or while a spin lock is held. Locking the mutex recursively from one thread will result in deadlock.
* @param lock Pointer to the allocated lock. */
#ifdef IOLOCKS_INLINE
#define IOLockLock(l) lck_mtx_lock(l)
#else
void IOLockLock( IOLock * lock);
#endif /* !IOLOCKS_INLINE */
/*! @function IOLockTryLock
* @abstract Attempt to lock a mutex.
* @discussion Lock the mutex if it is currently unlocked, and return true. If the lock is held by any thread, return false.
* @param lock Pointer to the allocated lock.
* @result True if the mutex was unlocked and is now locked by the caller, otherwise false. */
#ifdef IOLOCKS_INLINE
#define IOLockTryLock(l) lck_mtx_try_lock(l)
#else
boolean_t IOLockTryLock( IOLock * lock);
#endif /* !IOLOCKS_INLINE */
/*! @function IOLockUnlock
* @abstract Unlock a mutex.
* @discussion Unlock the mutex and wake any blocked waiters. Results are undefined if the caller has not locked the mutex. This function may block and so should not be called from interrupt level or while a spin lock is held.
* @param lock Pointer to the allocated lock. */
#ifdef IOLOCKS_INLINE
#define IOLockUnlock(l) lck_mtx_unlock(l)
#else
void IOLockUnlock( IOLock * lock);
#endif /* !IOLOCKS_INLINE */
/*! @function IOLockSleep
* @abstract Sleep with mutex unlock and relock
* @discussion Prepare to sleep,unlock the mutex, and re-acquire it on wakeup. Results are undefined if the caller has not locked the mutex. This function may block and so should not be called from interrupt level or while a spin lock is held.
* @param lock Pointer to the locked lock.
* @param event The event to sleep on. Must be non-NULL.
* @param interType How can the sleep be interrupted.
* @result The wait-result value indicating how the thread was awakened.*/
int IOLockSleep( IOLock * lock, void *event, UInt32 interType) __DARWIN14_ALIAS(IOLockSleep);
int IOLockSleepDeadline( IOLock * lock, void *event,
AbsoluteTime deadline, UInt32 interType) __DARWIN14_ALIAS(IOLockSleepDeadline);
void IOLockWakeup(IOLock * lock, void *event, bool oneThread) __DARWIN14_ALIAS(IOLockWakeup);
#ifdef __APPLE_API_OBSOLETE
/* The following API is deprecated */
typedef enum {
kIOLockStateUnlocked = 0,
kIOLockStateLocked = 1
} IOLockState;
void IOLockInitWithState( IOLock * lock, IOLockState state);
#define IOLockInit( l ) IOLockInitWithState( l, kIOLockStateUnlocked);
static __inline__ void
IOTakeLock( IOLock * lock)
{
IOLockLock(lock);
}
static __inline__ boolean_t
IOTryLock( IOLock * lock)
{
return IOLockTryLock(lock);
}
static __inline__ void
IOUnlock( IOLock * lock)
{
IOLockUnlock(lock);
}
#endif /* __APPLE_API_OBSOLETE */
/*
* Recursive lock operations
*/
typedef struct _IORecursiveLock IORecursiveLock;
/*! @function IORecursiveLockAlloc
* @abstract Allocates and initializes an recursive lock.
* @discussion Allocates a recursive lock in general purpose memory, and initializes it. Recursive locks function identically to mutexes but allow one thread to lock more than once, with balanced unlocks. IORecursiveLocks use the global IOKit lock group, IOLockGroup. To simplify kext debugging and lock-heat analysis, consider using lck_* locks with a per-driver lock group, as defined in kern/locks.h.
* @result Pointer to the allocated lock, or zero on failure. */
IORecursiveLock * IORecursiveLockAlloc( void );
/*! @function IORecursiveLockFree
* @abstract Frees a recursive lock.
* @discussion Frees a lock allocated with IORecursiveLockAlloc. Lock should be unlocked with no waiters.
* @param lock Pointer to the allocated lock. */
void IORecursiveLockFree( IORecursiveLock * lock);
/*! @function IORecursiveLockGetMachLock
* @abstract Accessor to a Mach mutex.
* @discussion Accessor to the Mach mutex.
* @param lock Pointer to the allocated lock. */
lck_mtx_t * IORecursiveLockGetMachLock( IORecursiveLock * lock);
/*! @function IORecursiveLockLock
* @abstract Lock a recursive lock.
* @discussion Lock the recursive lock. If the lock is held by another thread, block waiting for its unlock. This function may block and so should not be called from interrupt level or while a spin lock is held. The lock may be taken recursively by the same thread, with a balanced number of calls to IORecursiveLockUnlock.
* @param lock Pointer to the allocated lock. */
void IORecursiveLockLock( IORecursiveLock * lock);
/*! @function IORecursiveLockTryLock
* @abstract Attempt to lock a recursive lock.
* @discussion Lock the lock if it is currently unlocked, or held by the calling thread, and return true. If the lock is held by another thread, return false. Successful calls to IORecursiveLockTryLock should be balanced with calls to IORecursiveLockUnlock.
* @param lock Pointer to the allocated lock.
* @result True if the lock is now locked by the caller, otherwise false. */
boolean_t IORecursiveLockTryLock( IORecursiveLock * lock);
/*! @function IORecursiveLockUnlock
* @abstract Unlock a recursive lock.
* @discussion Undo one call to IORecursiveLockLock, if the lock is now unlocked wake any blocked waiters. Results are undefined if the caller does not balance calls to IORecursiveLockLock with IORecursiveLockUnlock. This function may block and so should not be called from interrupt level or while a spin lock is held.
* @param lock Pointer to the allocated lock. */
void IORecursiveLockUnlock( IORecursiveLock * lock);
/*! @function IORecursiveLockHaveLock
* @abstract Check if a recursive lock is held by the calling thread.
* @discussion If the lock is held by the calling thread, return true, otherwise the lock is unlocked, or held by another thread and false is returned.
* @param lock Pointer to the allocated lock.
* @result True if the calling thread holds the lock otherwise false. */
boolean_t IORecursiveLockHaveLock( const IORecursiveLock * lock);
extern int IORecursiveLockSleep( IORecursiveLock *_lock,
void *event, UInt32 interType);
extern int IORecursiveLockSleepDeadline( IORecursiveLock * _lock, void *event,
AbsoluteTime deadline, UInt32 interType);
extern void IORecursiveLockWakeup( IORecursiveLock *_lock,
void *event, bool oneThread);
/*
* Complex (read/write) lock operations
*/
#ifdef IOLOCKS_INLINE
typedef lck_rw_t IORWLock;
#else
typedef struct _IORWLock IORWLock;
#endif /* IOLOCKS_INLINE */
/*! @function IORWLockAlloc
* @abstract Allocates and initializes a read/write lock.
* @discussion Allocates and initializes a read/write lock in general purpose memory. Read/write locks provide for multiple readers, one exclusive writer, and are supplied by libkern/locks.h. This function may block and so should not be called from interrupt level or while a spin lock is held. IORWLocks use the global IOKit lock group, IOLockGroup. To simplify kext debugging and lock-heat analysis, consider using lck_* locks with a per-driver lock group, as defined in kern/locks.h.
* @result Pointer to the allocated lock, or zero on failure. */
IORWLock * IORWLockAlloc( void );
/*! @function IORWLockFree
* @abstract Frees a read/write lock.
* @discussion Frees a lock allocated with IORWLockAlloc. Lock should be unlocked with no waiters.
* @param lock Pointer to the allocated lock. */
void IORWLockFree( IORWLock * lock);
/*! @function IORWLockGetMachLock
* @abstract Accessor to a Mach read/write lock.
* @discussion Accessor to the Mach read/write lock.
* @param lock Pointer to the allocated lock. */
lck_rw_t * IORWLockGetMachLock( IORWLock * lock);
/*! @function IORWLockRead
* @abstract Lock a read/write lock for read.
* @discussion Lock the lock for read, allowing multiple readers when there are no writers. If the lock is held for write, block waiting for its unlock. This function may block and so should not be called from interrupt level or while a spin lock is held. Locking the lock recursively from one thread, for read or write, can result in deadlock.
* @param lock Pointer to the allocated lock. */
#ifdef IOLOCKS_INLINE
#define IORWLockRead(l) lck_rw_lock_shared(l)
#else
void IORWLockRead(IORWLock * lock);
#endif /* !IOLOCKS_INLINE */
/*! @function IORWLockTryRead
* @abstract Attempt to lock a read/write lock for read.
* @discussion Lock the lock for read, allowing multiple readers when there are no writers. If the lock is held for write, return false. Return true otherwise.
* @param lock Pointer to the allocated lock. */
#ifdef IOLOCKS_INLINE
#define IORWLockTryRead(l) lck_rw_try_lock_shared(l)
#else
void IORWLockTryRead( IORWLock * lock);
#endif /* !IOLOCKS_INLINE */
/*! @function IORWLockWrite
* @abstract Lock a read/write lock for write.
* @discussion Lock the lock for write, allowing one writer exlusive access. If the lock is held for read or write, block waiting for its unlock. This function may block and so should not be called from interrupt level or while a spin lock is held. Locking the lock recursively from one thread, for read or write, can result in deadlock.
* @param lock Pointer to the allocated lock. */
#ifdef IOLOCKS_INLINE
#define IORWLockWrite(l) lck_rw_lock_exclusive(l)
#else
void IORWLockWrite( IORWLock * lock);
#endif /* !IOLOCKS_INLINE */
/*! @function IORWLockTryWrite
* @abstract Attempt to lock a read/write lock for write.
* @discussion Lock the lock for write, allowing one writer exlusive access. If the lock is held for read or write, return false. Return true otherwise.
* @param lock Pointer to the allocated lock. */
#ifdef IOLOCKS_INLINE
#define IORWLockTryWrite(l) lck_rw_try_lock_exclusive(l)
#else
void IORWLockTryWrite( IORWLock * lock);
#endif /* !IOLOCKS_INLINE */
/*! @function IORWLockUnlock
* @abstract Unlock a read/write lock.
* @discussion Undo one call to IORWLockRead or IORWLockWrite. Results are undefined if the caller has not locked the lock. This function may block and so should not be called from interrupt level or while a spin lock is held.
* @param lock Pointer to the allocated lock. */
#ifdef IOLOCKS_INLINE
#define IORWLockUnlock(l) lck_rw_done(l)
#else
void IORWLockUnlock( IORWLock * lock);
#endif /* !IOLOCKS_INLINE */
#ifdef __APPLE_API_OBSOLETE
/* The following API is deprecated */
static __inline__ void
IOReadLock( IORWLock * lock)
{
IORWLockRead(lock);
}
static __inline__ void
IOWriteLock( IORWLock * lock)
{
IORWLockWrite(lock);
}
static __inline__ void
IORWUnlock( IORWLock * lock)
{
IORWLockUnlock(lock);
}
#endif /* __APPLE_API_OBSOLETE */
/*
* Simple locks. Cannot block while holding a simple lock.
*/
#ifdef IOLOCKS_INLINE
typedef lck_spin_t IOSimpleLock;
#else
typedef struct _IOSimpleLock IOSimpleLock;
#endif /* IOLOCKS_INLINE */
/*! @function IOSimpleLockAlloc
* @abstract Allocates and initializes a spin lock.
* @discussion Allocates and initializes a spin lock in general purpose memory. Spin locks provide non-blocking mutual exclusion for synchronization between thread context and interrupt context, or for multiprocessor synchronization, and are supplied by libkern/locks.h. This function may block and so should not be called from interrupt level or while a spin lock is held. IOSimpleLocks use the global IOKit lock group, IOLockGroup. To simplify kext debugging and lock-heat analysis, consider using lck_* locks with a per-driver lock group, as defined in kern/locks.h.
* @result Pointer to the allocated lock, or zero on failure. */
IOSimpleLock * IOSimpleLockAlloc( void );
/*! @function IOSimpleLockFree
* @abstract Frees a spin lock.
* @discussion Frees a lock allocated with IOSimpleLockAlloc.
* @param lock Pointer to the lock. */
void IOSimpleLockFree( IOSimpleLock * lock );
/*! @function IOSimpleLockGetMachLock
* @abstract Accessor to a Mach spin lock.
* @discussion Accessor to the Mach spin lock.
* @param lock Pointer to the allocated lock. */
lck_spin_t * IOSimpleLockGetMachLock( IOSimpleLock * lock);
/*! @function IOSimpleLockInit
* @abstract Initialize a spin lock.
* @discussion Initialize a non heap allocated spin lock to the unlocked state. Use this function when your lock is, for example, a member variable. You will need to call IOSimpleLockDestroy when you are finished with the lock to avoid lock group refcount leaks.
* @param lock Pointer to the lock. */
void IOSimpleLockInit( IOSimpleLock * lock );
/*! @function IOSimpleLockDestroy
* @abstract De-initializes (destroys) a spin lock initialized with IOSimpleLockInit
* @discussion Destroy / De-initialize a non heap allocated spin lock, releasing any system resources such as lock group refcounts.
* @param lock Pointer to the lock. */
void IOSimpleLockDestroy( IOSimpleLock * lock );
/*! @function IOSimpleLockLock
* @abstract Lock a spin lock.
* @discussion Lock the spin lock. If the lock is held, spin waiting for its unlock. Spin locks disable preemption, cannot be held across any blocking operation, and should be held for very short periods. When used to synchronize between interrupt context and thread context they should be locked with interrupts disabled - IOSimpleLockLockDisableInterrupt() will do both. Locking the lock recursively from one thread will result in deadlock.
* @param lock Pointer to the lock. */
#ifdef IOLOCKS_INLINE
#define IOSimpleLockLock(l) lck_spin_lock(l)
#else
void IOSimpleLockLock( IOSimpleLock * lock );
#endif /* !IOLOCKS_INLINE */
/*! @function IOSimpleLockTryLock
* @abstract Attempt to lock a spin lock.
* @discussion Lock the spin lock if it is currently unlocked, and return true. If the lock is held, return false. Successful calls to IOSimpleLockTryLock should be balanced with calls to IOSimpleLockUnlock.
* @param lock Pointer to the lock.
* @result True if the lock was unlocked and is now locked by the caller, otherwise false. */
#ifdef IOLOCKS_INLINE
#define IOSimpleLockTryLock(l) lck_spin_try_lock(l)
#else
boolean_t IOSimpleLockTryLock( IOSimpleLock * lock );
#endif /* !IOLOCKS_INLINE */
/*! @function IOSimpleLockUnlock
* @abstract Unlock a spin lock.
* @discussion Unlock the lock, and restore preemption. Results are undefined if the caller has not locked the lock.
* @param lock Pointer to the lock. */
#ifdef IOLOCKS_INLINE
#define IOSimpleLockUnlock(l) lck_spin_unlock(l)
#else
void IOSimpleLockUnlock( IOSimpleLock * lock );
#endif /* !IOLOCKS_INLINE */
#if __LP64__
typedef boolean_t IOInterruptState;
#else
typedef long int IOInterruptState;
#endif
/*! @function IOSimpleLockLockDisableInterrupt
* @abstract Lock a spin lock.
* @discussion Lock the spin lock. If the lock is held, spin waiting for its unlock. Simple locks disable preemption, cannot be held across any blocking operation, and should be held for very short periods. When used to synchronize between interrupt context and thread context they should be locked with interrupts disabled - IOSimpleLockLockDisableInterrupt() will do both. Locking the lock recursively from one thread will result in deadlock.
* @param lock Pointer to the lock. */
static __inline__
IOInterruptState
IOSimpleLockLockDisableInterrupt( IOSimpleLock * lock )
{
IOInterruptState state = ml_set_interrupts_enabled( false );
IOSimpleLockLock( lock );
return state;
}
/*! @function IOSimpleLockUnlockEnableInterrupt
* @abstract Unlock a spin lock, and restore interrupt state.
* @discussion Unlock the lock, and restore preemption and interrupts to the state as they were when the lock was taken. Results are undefined if the caller has not locked the lock.
* @param lock Pointer to the lock.
* @param state The interrupt state returned by IOSimpleLockLockDisableInterrupt() */
static __inline__
void
IOSimpleLockUnlockEnableInterrupt( IOSimpleLock * lock,
IOInterruptState state )
{
IOSimpleLockUnlock( lock );
ml_set_interrupts_enabled( state );
}
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* !__IOKIT_IOLOCKS_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOUserServer.h | /*
* Copyright (c) 2019 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _IOUSERSERVER_H
#define _IOUSERSERVER_H
#include <IOKit/IORPC.h>
#define kIOUserClassKey "IOUserClass"
#define kIOUserServerClassKey "IOUserServer"
#define kIOUserServerNameKey "IOUserServerName"
#define kIOUserServerTagKey "IOUserServerTag"
// the expected cdhash value of the userspace driver executable
#define kIOUserServerCDHashKey "IOUserServerCDHash"
#if DRIVERKIT_PRIVATE
enum{
kIOKitUserServerClientType = 0x99000003,
};
enum{
kIOUserServerMethodRegisterClass = 0x0001000,
kIOUserServerMethodStart = 0x0001001,
kIOUserServerMethodRegister = 0x0001002,
};
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#define OSObject_Instantiate_ID 0x0000000100000001ULL
enum {
kOSObjectRPCRemote = 0x00000001,
kOSObjectRPCKernel = 0x00000002,
};
struct OSObject_Instantiate_Msg_Content {
IORPCMessage __hdr;
OSObjectRef __object;
};
struct OSObject_Instantiate_Rpl_Content {
IORPCMessage __hdr;
kern_return_t __result;
uint32_t __pad;
uint64_t flags;
char classname[128];
uint64_t methods[0];
};
#pragma pack(4)
struct OSObject_Instantiate_Msg {
IORPCMessageMach mach;
mach_msg_port_descriptor_t __object__descriptor;
OSObject_Instantiate_Msg_Content content;
};
struct OSObject_Instantiate_Rpl {
IORPCMessageMach mach;
OSObject_Instantiate_Rpl_Content content;
};
#pragma pack()
typedef uint64_t IOTrapMessageBuffer[256];
#endif /* DRIVERKIT_PRIVATE */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#endif /* _IOUSERSERVER_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOInterruptEventSource.h | /*
* Copyright (c) 1998-2019 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* Copyright (c) 1998 Apple Computer, Inc. All rights reserved.
*
* HISTORY
* 1998-7-13 Godfrey van der Linden(gvdl)
* Created.
* 1998-10-30 Godfrey van der Linden(gvdl)
* Converted to C++
*/
#ifndef _IOKIT_IOINTERRUPTEVENTSOURCE_H
#define _IOKIT_IOINTERRUPTEVENTSOURCE_H
#include <libkern/c++/OSPtr.h>
#include <IOKit/IOEventSource.h>
class IOService;
struct IOInterruptAccountingData;
/*! @class IOInterruptEventSource : public IOEventSource
* @abstract Event source for interrupt delivery to work-loop based drivers.
* @discussion The IOInterruptEventSource is a generic object that delivers calls interrupt routines in it's client in a guaranteed single-threaded manner. IOInterruptEventSource is part of the IOKit $link IOWorkLoop infrastructure where the semantic that one and only one action method is executing within a work-loops event chain.
* <br><br>
* When the action method is called in the client member function will receive 2 arguments, (IOEventSource *) sender and (int) count, See $link IOInterruptEventSource::Action. Where sender will be reference to the interrupt that occurred and the count will be computed by the difference between the $link producerCount and $link consumerCount. This number may not be reliable as no attempt is made to adjust for around the world type problems but is provided for general information and statistic gathering.
* <br><br>
* In general a client will use the factory member function to create and initialise the event source and then add it to their work-loop. It is the work loop's responsiblity to maintain the new event source in it's event chain. See $link IOWorkLoop.
* <br><br>
* An interrupt event source attaches itself to the given provider's interrupt source at initialisation time. At this time it determines if it is connected to a level or edge triggered interrupt. If the interrupt is an level triggered interrupt the event source automatically disables the interrupt source at primary interrupt time and after it call's the client it automatically reenables the interrupt. This action is fairly expensive but it is 100% safe and defaults sensibly so that the driver writer does not have to implement type dependant interrupt routines. So to repeat, the driver writer does not have to be concerned by the actual underlying interrupt mechanism as the event source hides the complexity.
* <br><br>
* Saying this if the hardware is a multi-device card, for instance a 4 port NIC, where all of the devices are sharing one level triggered interrupt AND it is possible to determine each port's interrupt state non-destructively then the $link IOFilterInterruptEventSource would be a better choice.
* <br><br>
* Warning: All IOInterruptEventSources are created in the disabled state. If you want to actually schedule interrupt delivery do not forget to enable the source.
*/
class IOInterruptEventSource : public IOEventSource
{
OSDeclareDefaultStructors(IOInterruptEventSource);
public:
/*! @typedef Action
* @discussion 'C' pointer prototype of functions that are called in a single threaded context when an interrupt occurs.
* @param owner Pointer to client instance.
* @param sender Pointer to generation interrupt event source.
* @param count Number of interrupts seen before delivery. */
typedef void (*Action)(OSObject *owner, IOInterruptEventSource *sender, int count);
#ifdef __BLOCKS__
typedef void (^ActionBlock)(IOInterruptEventSource *sender, int count);
#endif /* __BLOCKS__ */
/*! @defined IOInterruptEventAction
* @discussion Backward compatibilty define for the old non-class scoped type definition. See $link IOInterruptEventSource::Action */
#define IOInterruptEventAction IOInterruptEventSource::Action
protected:
/*! @var provider IOService that provides interrupts for delivery. */
IOService *provider;
/*! @var intIndex */
int intIndex;
/*! @var producerCount
* Current count of produced interrupts that have been received. */
volatile unsigned int producerCount;
/*! @var consumerCount
* Current count of produced interrupts that the owner has been informed of. */
unsigned int consumerCount;
/*! @var autoDisable Do we need to automatically disable the interrupt source when we take an interrupt, i.e. we are level triggered. */
bool autoDisable;
/*! @var explicitDisable Has the user expicitly disabled this event source, if so then do not overide their request when returning from the callout */
bool explicitDisable;
/*! @struct ExpansionData
* @discussion This structure will be used to expand the capablilties of the IOWorkLoop in the future.
*/
struct ExpansionData {
IOInterruptAccountingData * statistics;
};
/*! @var reserved
* Reserved for future use. (Internal use only) */
APPLE_KEXT_WSHADOW_PUSH;
ExpansionData *reserved;
APPLE_KEXT_WSHADOW_POP;
/*! @function free
* @abstract Sub-class implementation of free method, disconnects from the interrupt source. */
virtual void free() APPLE_KEXT_OVERRIDE;
/*! @function checkForWork
* @abstract Pure Virtual member function used by IOWorkLoop for issueing a client calls.
* @discussion This function called when the work-loop is ready to check for any work to do and then to call out the owner/action.
* @result Return true if this function needs to be called again before all its outstanding events have been processed. */
virtual bool checkForWork() APPLE_KEXT_OVERRIDE;
/*! @function setWorkLoop
* @abstract Sub-class implementation of setWorkLoop method. */
virtual void setWorkLoop(IOWorkLoop *inWorkLoop) APPLE_KEXT_OVERRIDE;
public:
/*! @function interruptEventSource
* @abstract Factory function for IOInterruptEventSources creation and initialisation.
* @param owner Owning client of the new event source.
* @param action 'C' Function to call when something happens.
* @param provider IOService that represents the interrupt source. Defaults to 0. When no provider is defined the event source assumes that the client will in some manner call the interruptOccured method explicitly. This will start the ball rolling for safe delivery of asynchronous event's into the driver.
* @param intIndex The index of the interrupt within the provider's interrupt sources. Defaults to 0, i.e. the first interrupt in the provider.
* @result A new interrupt event source if successfully created and initialised, 0 otherwise. */
static OSPtr<IOInterruptEventSource>
interruptEventSource(OSObject *owner,
Action action,
IOService *provider = NULL,
int intIndex = 0);
#ifdef __BLOCKS__
/*! @function interruptEventSource
* @abstract Factory function for IOInterruptEventSources creation and initialisation.
* @param owner Owning client of the new event source.
* @param provider IOService that represents the interrupt source. When no provider is defined the event source assumes that the client will in some manner call the interruptOccured method explicitly. This will start the ball rolling for safe delivery of asynchronous event's into the driver.
* @param intIndex The index of the interrupt within the provider's interrupt sources.
* @param action Block for the callout routine of this event source..
* @result A new interrupt event source if successfully created and initialised, 0 otherwise. */
static OSPtr<IOInterruptEventSource>
interruptEventSource(OSObject *owner,
IOService *provider,
int intIndex,
ActionBlock action);
#endif /* __BLOCKS__ */
/*! @function init
* @abstract Primary initialiser for the IOInterruptEventSource class.
* @param owner Owning client of the new event source.
* @param action 'C' Function to call when something happens.
* @param provider IOService that represents the interrupt source. Defaults to 0. When no provider is defined the event source assumes that the client will in some manner call the interruptOccured method explicitly. This will start the ball rolling for safe delivery of asynchronous event's into the driver.
* @param intIndex The index of the interrupt within the provider's interrupt sources. Defaults to 0, i.e. the first interrupt in the provider.
* @result true if the inherited classes and this instance initialise
* successfully. */
virtual bool init(OSObject *owner,
Action action,
IOService *provider = NULL,
int intIndex = 0);
/*! @function enable
* @abstract Enable event source.
* @discussion A subclass implementation is expected to respect the enabled
* state when checkForWork is called. Calling this function will cause the
* work-loop to be signalled so that a checkForWork is performed. */
virtual void enable() APPLE_KEXT_OVERRIDE;
/*! @function disable
* @abstract Disable event source.
* @discussion A subclass implementation is expected to respect the enabled
* state when checkForWork is called. */
virtual void disable() APPLE_KEXT_OVERRIDE;
/*! @function getProvider
* @abstract Get'ter for $link provider variable.
* @result value of provider. */
virtual const IOService *getProvider() const;
/*! @function getIntIndex
* @abstract Get'ter for $link intIndex interrupt index variable.
* @result value of intIndex. */
virtual int getIntIndex() const;
/*! @function getAutoDisable
* @abstract Get'ter for $link autoDisable variable.
* @result value of autoDisable. */
virtual bool getAutoDisable() const;
/*! @function interruptOccurred
* @abstract Functions that get called by the interrupt controller. See $link IOService::registerInterrupt
* @param nub Where did the interrupt originate from
* @param ind What is this interrupts index within 'nub'. */
virtual void interruptOccurred(void *, IOService *nub, int ind);
/*! @function normalInterruptOccurred
* @abstract Functions that get called by the interrupt controller.See $link IOService::registerInterrupt
* @param nub Where did the interrupt originate from
* @param ind What is this interrupts index within 'nub'. */
virtual void normalInterruptOccurred(void *, IOService *nub, int ind);
/*! @function disableInterruptOccurred
* @abstract Functions that get called by the interrupt controller.See $link IOService::registerInterrupt
* @param nub Where did the interrupt originate from
* @param ind What is this interrupts index within 'nub'. */
virtual void disableInterruptOccurred(void *, IOService *nub, int ind);
/*! @function warmCPU
* @abstract Tries to reduce latency for an interrupt which will be received near a specified time.
* @discussion Warms up a CPU in advance of an interrupt so that the interrupt may be serviced with predictable latency.
* The warm-up is not periodic; callers should call warmCPU once in advance of each interrupt. It is recommended that
* requests be issues in serial (i.e. each after the target for the previous call has elapsed), as there is a systemwide
* cap on the number of outstanding requests. This routine may be disruptive to the system if used with very small intervals
* between requests; it should be used only in cases where interrupt latency is absolutely critical, and tens or hundreds of
* milliseconds between targets is the expected time scale. NOTE: it is not safe to call this method with interrupts disabled.
* @param abstime Time at which interrupt is expected. */
IOReturn warmCPU(uint64_t abstime);
/*! @function enablePrimaryInterruptTimestamp
* @abstract Enables collection of mach_absolute_time at primary interrupt.
* @discussion Enables collection of mach_absolute_time at primary interrupt.
* @param enable True to enable timestamp. */
void enablePrimaryInterruptTimestamp(bool enable);
/*! @function getPrimaryInterruptTimestamp
* @abstract Returns mach_absolute_time timestamp of primary interrupt.
* @discussion Returns mach_absolute_time timestamp of primary interrupt.
* @result Value of the timestamp. Zero if never interrupted, or -1ULL if timestamp collection has not been enabled. */
uint64_t getPrimaryInterruptTimestamp();
private:
IOReturn registerInterruptHandler(IOService *inProvider, int inIntIndex);
void unregisterInterruptHandler(IOService *inProvider, int inIntIndex);
private:
OSMetaClassDeclareReservedUnused(IOInterruptEventSource, 0);
OSMetaClassDeclareReservedUnused(IOInterruptEventSource, 1);
OSMetaClassDeclareReservedUnused(IOInterruptEventSource, 2);
OSMetaClassDeclareReservedUnused(IOInterruptEventSource, 3);
OSMetaClassDeclareReservedUnused(IOInterruptEventSource, 4);
OSMetaClassDeclareReservedUnused(IOInterruptEventSource, 5);
OSMetaClassDeclareReservedUnused(IOInterruptEventSource, 6);
OSMetaClassDeclareReservedUnused(IOInterruptEventSource, 7);
};
#endif /* !_IOKIT_IOINTERRUPTEVENTSOURCE_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOService.h | /*
* Copyright (c) 1998-2020 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* Copyright (c) 1998,1999 Apple Computer, Inc. All rights reserved.
*
* HISTORY
*
*/
/*!
* @header
* This header contains the definition of the IOService class. IOService is the sole direct subclass of IORegistryEntry and is the base class of almost all I/O Kit family superclasses. IOService defines methods that support the life cycle of I/O Kit drivers. For more information on IOService, see {@linkdoc //apple_ref/doc/uid/TP0000011 I/O Kit Fundamentals}.
*
* @seealso //apple_ref/doc/header/IORegistryEntry.h IORegistryEntry
*/
#ifndef _IOKIT_IOSERVICE_H
#define _IOKIT_IOSERVICE_H
#include <IOKit/IORegistryEntry.h>
#include <IOKit/IOReturn.h>
#include <IOKit/IODeviceMemory.h>
#include <IOKit/IONotifier.h>
#include <IOKit/IOLocks.h>
#include <IOKit/IOKitDebug.h>
#include <IOKit/IOInterrupts.h>
#include <IOKit/pwr_mgt/IOPMpowerState.h>
#include <IOKit/IOServicePM.h>
#include <IOKit/IOReportTypes.h>
#include <DriverKit/IOService.h>
#include <libkern/c++/OSPtr.h>
#if __cplusplus >= 201703L
extern "C++" {
#include <libkern/c++/OSSharedPtr.h>
}
#endif
extern "C" {
#include <kern/thread_call.h>
}
#ifndef UINT64_MAX
#define UINT64_MAX 18446744073709551615ULL
#endif
enum {
kIODefaultProbeScore = 0
};
// masks for getState()
enum {
kIOServiceInactiveState = 0x00000001,
kIOServiceRegisteredState = 0x00000002,
kIOServiceMatchedState = 0x00000004,
kIOServiceFirstPublishState = 0x00000008,
kIOServiceFirstMatchState = 0x00000010,
kIOServiceReservedMatchState = 0x80000000,
};
enum {
// options for registerService()
kIOServiceExclusive = 0x00000001,
// options for terminate()
kIOServiceRequired = 0x00000001,
kIOServiceTerminate = 0x00000004,
kIOServiceTerminateWithRematch = 0x00000010,
kIOServiceTerminateWithRematchCurrentDext = 0x00000020,
// options for registerService() & terminate()
kIOServiceSynchronous = 0x00000002,
// options for registerService()
kIOServiceAsynchronous = 0x00000008
};
// options for open()
enum {
kIOServiceSeize = 0x00000001,
kIOServiceFamilyOpenOptions = 0xffff0000
};
// options for close()
enum {
kIOServiceFamilyCloseOptions = 0xffff0000
};
typedef void * IONotificationRef;
extern const IORegistryPlane * gIOServicePlane;
extern const IORegistryPlane * gIOPowerPlane;
extern const OSSymbol * gIOResourcesKey;
extern const OSSymbol * gIOResourceMatchKey;
extern const OSSymbol * gIOResourceMatchedKey;
extern const OSSymbol * gIOResourceIOKitKey;
extern const OSSymbol * gIOProviderClassKey;
extern const OSSymbol * gIONameMatchKey;
extern const OSSymbol * gIONameMatchedKey;
extern const OSSymbol * gIOPropertyMatchKey;
extern const OSSymbol * gIOPropertyExistsMatchKey;
extern const OSSymbol * gIOLocationMatchKey;
extern const OSSymbol * gIOParentMatchKey;
extern const OSSymbol * gIOPathMatchKey;
extern const OSSymbol * gIOMatchCategoryKey;
extern const OSSymbol * gIODefaultMatchCategoryKey;
extern const OSSymbol * gIOMatchedServiceCountKey;
extern const OSSymbol * gIOMatchedPersonalityKey;
extern const OSSymbol * gIORematchPersonalityKey;
extern const OSSymbol * gIORematchCountKey;
extern const OSSymbol * gIODEXTMatchCountKey;
extern const OSSymbol * gIOUserClientClassKey;
extern const OSSymbol * gIOUserClassKey;
extern const OSSymbol * gIOUserServerClassKey;
extern const OSSymbol * gIOUserServerNameKey;
extern const OSSymbol * gIOUserServerTagKey;
extern const OSSymbol * gIOUserUserClientKey;
extern const OSSymbol * gIOAssociatedServicesKey;
extern const OSSymbol * gIOKitDebugKey;
extern const OSSymbol * gIOServiceKey;
extern const OSSymbol * gIOCommandPoolSizeKey;
extern const OSSymbol * gIOPublishNotification;
extern const OSSymbol * gIOFirstPublishNotification;
extern const OSSymbol * gIOMatchedNotification;
extern const OSSymbol * gIOFirstMatchNotification;
extern const OSSymbol * gIOTerminatedNotification;
extern const OSSymbol * gIOWillTerminateNotification;
extern const OSSymbol * gIOGeneralInterest;
extern const OSSymbol * gIOBusyInterest;
extern const OSSymbol * gIOOpenInterest;
extern const OSSymbol * gIOAppPowerStateInterest;
extern const OSSymbol * gIOPriorityPowerStateInterest;
extern const OSSymbol * gIOConsoleSecurityInterest;
extern const OSSymbol * gIODeviceMemoryKey;
extern const OSSymbol * gIOInterruptControllersKey;
extern const OSSymbol * gIOInterruptSpecifiersKey;
extern const OSSymbol * gIOSupportedPropertiesKey;
extern const OSSymbol * gIOUserServicePropertiesKey;
extern const OSSymbol * gIOCompatibilityMatchKey;
extern const OSSymbol * gIOCompatibilityPropertiesKey;
extern const OSSymbol * gIOPathKey;
extern const OSSymbol * gIOBSDKey;
extern const OSSymbol * gIOBSDNameKey;
extern const OSSymbol * gIOBSDMajorKey;
extern const OSSymbol * gIOBSDMinorKey;
extern const OSSymbol * gIOBSDUnitKey;
extern const OSSymbol * gIODriverKitEntitlementKey;
extern const OSSymbol * gIOServiceDEXTEntitlementsKey;
extern const OSSymbol * gIODriverKitUserClientEntitlementsKey;
extern const OSSymbol * gIODriverKitUserClientEntitlementAllowAnyKey;
extern const OSSymbol * gIODriverKitRequiredEntitlementsKey;
extern const OSSymbol * gIOMatchDeferKey;
extern const OSSymbol * gIOAllCPUInitializedKey;
extern SInt32 IOServiceOrdering( const OSMetaClassBase * inObj1, const OSMetaClassBase * inObj2, void * ref );
typedef void (*IOInterruptAction)( OSObject * target, void * refCon,
IOService * nub, int source );
#ifdef __BLOCKS__
typedef void (^IOInterruptActionBlock)(IOService * nub, int source);
typedef kern_return_t (^IOStateNotificationHandler)(void);
#endif /* __BLOCKS__ */
typedef void * IOStateNotificationListenerRef;
class IOStateNotificationItem;
/*! @typedef IOServiceNotificationHandler
* @param target Reference supplied when the notification was registered.
* @param refCon Reference constant supplied when the notification was registered.
* @param newService The IOService object the notification is delivering. It is retained for the duration of the handler's invocation and doesn't need to be released by the handler. */
typedef bool (*IOServiceNotificationHandler)( void * target, void * refCon,
IOService * newService );
typedef bool (*IOServiceMatchingNotificationHandler)( void * target, void * refCon,
IOService * newService,
IONotifier * notifier );
#ifdef __BLOCKS__
typedef bool (^IOServiceMatchingNotificationHandlerBlock)(IOService * newService,
IONotifier * notifier );
#endif /* __BLOCKS__ */
/*! @typedef IOServiceInterestHandler
* @param target Reference supplied when the notification was registered.
* @param refCon Reference constant supplied when the notification was registered.
* @param messageType Type of the message - IOKit defined in IOKit/IOMessage.h or family specific.
* @param provider The IOService object who is delivering the notification. It is retained for the duration of the handler's invocation and doesn't need to be released by the handler.
* @param messageArgument An argument for message, dependent on its type.
* @param argSize Non zero if the argument represents a struct of that size, used when delivering messages outside the kernel. */
typedef IOReturn (*IOServiceInterestHandler)( void * target, void * refCon,
UInt32 messageType, IOService * provider,
void * messageArgument, vm_size_t argSize );
#ifdef __BLOCKS__
typedef IOReturn (^IOServiceInterestHandlerBlock)( uint32_t messageType, IOService * provider,
void * messageArgument, size_t argSize );
#endif /* __BLOCKS__ */
typedef void (*IOServiceApplierFunction)(IOService * service, void * context);
typedef void (*OSObjectApplierFunction)(OSObject * object, void * context);
#ifdef __BLOCKS__
typedef void (^IOServiceApplierBlock)(IOService * service);
typedef void (^OSObjectApplierBlock)(OSObject * object);
#endif /* __BLOCKS__ */
class IOUserClient;
class IOPlatformExpert;
class IOUserServerCheckInToken;
/*! @class IOService
* @abstract The base class for most I/O Kit families, devices, and drivers.
* @discussion The IOService base class defines APIs used to publish services, instantiate other services based on the existance of a providing service (ie. driver stacking), destroy a service and its dependent stack, notify interested parties of service state changes, and general utility functions useful across all families.
*
* Types of service are specified with a matching dictionary that describes properties of the service. For example, a matching dictionary might describe any IOUSBDevice (or subclass), an IOUSBDevice with a certain class code, or a IOPCIDevice with a set of matching names or device & vendor IDs. Since the matching dictionary is interpreted by the family which created the service, as well as generically by IOService, the list of properties considered for matching depends on the familiy.
*
* Matching dictionaries are associated with IOService classes by the catalogue, as driver property tables, and also supplied by clients of the notification APIs.
*
* IOService provides matching based on C++ class (via OSMetaClass dynamic casting), registry entry name, a registry path to the service (which includes device tree paths), a name assigned by BSD, or by its location (its point of attachment).
*
* <br><br>Driver Instantiation by IOService<br><br>
*
* Drivers are subclasses of IOService, and their availability is managed through the catalogue. They are instantiated based on the publication of an IOService they use (for example, an IOPCIDevice or IOUSBDevice), or when they are added to the catalogue and the IOService(s) they use are already available.
*
* When an IOService (the "provider") is published with the @link registerService registerService@/link method, the matching and probing process begins, which is always single threaded per provider. A list of matching dictionaries from the catalog and installed publish notification requests, that successfully match the IOService, is constructed, with ordering supplied by <code>kIOProbeScoreKey</code> ("IOProbeScore") property in the dictionary, or supplied with the notification.
*
* Each entry in the list is then processed in order - for notifications, the notification is delivered, for driver property tables a lot more happens.
*
* The driver class is instantiated and <code>init()</code> called with its property table. The new driver instance is then attached to the provider, and has its @link probe probe@/link method called with the provider as an argument. The default <code>probe</code> method does nothing but return success, but a driver may implement this method to interrogate the provider to make sure it can work with it. It may also modify its probe score at this time. After probe, the driver is detached and the next in the list is considered (ie. attached, probed, and detached).
*
* When the probing phase is complete, the list consists of successfully probed drivers, in order of their probe score (after adjustment during the @link probe probe@/link call). The list is then divided into categories based on the <code>kIOMatchCategoryKey</code> property ("IOMatchCategory"); drivers without a match category are all considered in one default category. Match categories allow multiple clients of a provider to be attached and started, though the provider may also enforce open/close semantics to gain active access to it.
*
* For each category, the highest scoring driver in that category is attached to the provider, and its @link start start@/link method called. If <code>start</code> is successful, the rest of the drivers in the same match category are discarded, otherwise the next highest scoring driver is started, and so on.
*
* The driver should only consider itself in action when the start method is called, meaning it has been selected for use on the provider, and consuming that particular match category. It should also be prepared to be allocated, probed and freed even if the probe was successful.
*
* After the drivers have all synchronously been started, the installed "matched" notifications that match the registered IOService are delivered.
*
* <br><br>Properties used by IOService<br><br>
*
* <code>kIOClassKey, extern const OSSymbol * gIOClassKey, "IOClass"</code>
* <br>
* <br>
* Class of the driver to instantiate on matching providers.
* <br>
* <br>
* <code>kIOProviderClassKey, extern const OSSymbol * gIOProviderClassKey, "IOProviderClass"</code>
* <br>
* <br>
* Class of the provider(s) to be considered for matching, checked with OSDynamicCast so subclasses will also match.
* <br>
* <br>
* <code>kIOProbeScoreKey, extern const OSSymbol * gIOProbeScoreKey, "IOProbeScore"</code>
* <br>
* <br>
* The probe score initially used to order multiple matching drivers.
* <br>
* <br>
* <code>kIOMatchCategoryKey, extern const OSSymbol * gIOMatchCategoryKey, "IOMatchCategory"</code>
* <br>
* <br>
* A string defining the driver category for matching purposes. All drivers with no <code>IOMatchCategory</code> property are considered to be in the same default category. Only one driver in a category can be started on each provider.
* <br>
* <br>
* <code>kIONameMatchKey, extern const OSSymbol * gIONameMatchKey, "IONameMatch"</code>
* <br>
* A string or collection of strings that match the provider's name. The comparison is implemented with the @link //apple_ref/cpp/instm/IORegistryEntry/compareNames/virtualbool/(OSObject*,OSString**) IORegistryEntry::compareNames@/link method, which supports a single string, or any collection (OSArray, OSSet, OSDictionary etc.) of strings. IOService objects with device tree properties (eg. IOPCIDevice) will also be matched based on that standard's "compatible", "name", "device_type" properties. The matching name will be left in the driver's property table in the <code>kIONameMatchedKey</code> property.
* <br>
* Examples
* <pre>
* @textblock
* <key>IONameMatch</key>
* <string>pci106b,7</string>
* @/textblock
* </pre>
*
* For a list of possible matching names, a serialized array of strings should used, eg.
* <pre>
* @textblock
* <key>IONameMatch</key>
* <array>
* <string>APPL,happy16</string>
* <string>pci106b,7</string>
* </array>
* @/textblock
* </pre>
*
* <br>
* <code>kIONameMatchedKey, extern const OSSymbol * gIONameMatchedKey, "IONameMatched"</code>
* <br>
* The name successfully matched name from the <code>kIONameMatchKey</code> property will be left in the driver's property table as the <code>kIONameMatchedKey</code> property.
* <br>
* <br>
* <code>kIOPropertyMatchKey, extern const OSSymbol * gIOPropertyMatchKey, "IOPropertyMatch"</code>
* <br>
* A dictionary of properties that each must exist in the matching IOService and compare successfully with the <code>isEqualTo</code> method.
*
* <pre>
* @textblock
* <key>IOPropertyMatch</key>
* <dictionary>
* <key>APPL,happy16</key>
* <string>APPL,meek8</string>
* </dictionary>
* @/textblock
* </pre>
*
* <br>
* <code>kIOUserClientClassKey, extern const OSSymbol * gIOUserClientClassKey, "IOUserClientClass"</code>
* <br>
* The class name that the service will attempt to allocate when a user client connection is requested. First the device nub is queried, then the nub's provider is queried by default.
* <br>
* <br>
* <code>kIOKitDebugKey, extern const OSSymbol * gIOKitDebugKey, "IOKitDebug"</code>
* <br>
* Set some debug flags for logging the driver loading process. Flags are defined in <code>IOKit/IOKitDebug.h</code>, but <code>65535</code> works well.*/
struct IOInterruptAccountingData;
struct IOInterruptAccountingReporter;
struct OSObjectUserVars;
struct IOServiceStateChangeVars;
struct IOInterruptSourcePrivate;
class IOService : public IORegistryEntry
{
OSDeclareDefaultStructorsWithDispatch(IOService);
protected:
/*! @struct ExpansionData
* @discussion This structure will be used to expand the capablilties of this class in the future.
*/
struct ExpansionData {
uint64_t authorizationID;
/*
* Variables associated with interrupt accounting. Consists of an array
* (that pairs reporters with opaque "statistics" objects), the count for
* the array, and a lock to guard both of the former variables. The lock
* is necessary as IOReporting will not update reports in a manner that is
* synchonized with the service (i.e, on a workloop).
*/
IOLock * interruptStatisticsLock;
IOInterruptAccountingReporter * interruptStatisticsArray;
int interruptStatisticsArrayCount;
OSObjectUserVars * uvars;
IOServiceStateChangeVars * svars;
IOInterruptSourcePrivate * interruptSourcesPrivate;
};
/*! @var reserved
* Reserved for future use. (Internal use only) */
APPLE_KEXT_WSHADOW_PUSH;
ExpansionData * reserved;
APPLE_KEXT_WSHADOW_POP;
private:
IOService * __provider;
SInt32 __providerGeneration;
IOService * __owner;
IOOptionBits __state[2];
uint64_t __timeBusy;
uint64_t __accumBusy;
IOServicePM * pwrMgt;
protected:
// TRUE once PMinit has been called
bool initialized;
public:
// DEPRECATED
void * pm_vars;
public:
/* methods available in Mac OS X 10.1 or later */
/*! @function requestTerminate
* @abstract Passes a termination up the stack.
* @discussion When an IOService is made inactive the default behavior is to also make any of its clients that have it as their only provider also inactive, in this way recursing the termination up the driver stack. This method allows an IOService object to override this behavior. Returning <code>true</code> from this method when passed a just terminated provider will cause the client to also be terminated.
* @param provider The terminated provider of this object.
* @param options Options originally passed to terminate, plus <code>kIOServiceRecursing</code>.
* @result <code>true</code> if this object should be terminated now that its provider has been. */
virtual bool requestTerminate( IOService * provider, IOOptionBits options );
/*! @function willTerminate
* @abstract Passes a termination up the stack.
* @discussion Notification that a provider has been terminated, sent before recursing up the stack, in root-to-leaf order.
* @param provider The terminated provider of this object.
* @param options Options originally passed to terminate.
* @result <code>true</code>. */
virtual bool willTerminate( IOService * provider, IOOptionBits options );
/*! @function didTerminate
* @abstract Passes a termination up the stack.
* @discussion Notification that a provider has been terminated, sent after recursing up the stack, in leaf-to-root order.
* @param provider The terminated provider of this object.
* @param options Options originally passed to terminate.
* @param defer If there is pending I/O that requires this object to persist, and the provider is not opened by this object set <code>defer</code> to <code>true</code> and call the <code>IOService::didTerminate()</code> implementation when the I/O completes. Otherwise, leave <code>defer</code> set to its default value of <code>false</code>.
* @result <code>true</code>. */
virtual bool didTerminate( IOService * provider, IOOptionBits options, bool * defer );
/*! @function nextIdleTimeout
* @availability Mac OS X v10.4 and later
* @abstract Allows subclasses to customize idle power management behavior.
* @discussion Returns the next time that the device should idle into its next lower power state. Subclasses may override for custom idle behavior.
*
* A power managed driver might override this method to provide a more sophisticated idle power off algorithm than the one defined by power management.
* @param currentTime The current time
* @param lastActivity The time of last activity on this device
* @param powerState The device's current power state.
* @result Returns the next time the device should idle off (in seconds, relative to the current time). */
virtual SInt32 nextIdleTimeout(AbsoluteTime currentTime,
AbsoluteTime lastActivity, unsigned int powerState);
/*! @function systemWillShutdown
* @availability Mac OS X v10.5 and later
* @abstract Notifies members of the power plane of system shutdown and restart.
* @discussion This function is called for all members of the power plane in leaf-to-root order. If a subclass needs to wait for a pending I/O, then the call to <code>systemWillShutdown</code> should be postponed until the I/O completes.
*
* Any power managed driver (which has called @link joinPMtree joinPMtree@/link to join the power plane) interested in taking action at system shutdown or restart should override this method.
* @param specifier <code>kIOMessageSystemWillPowerOff</code> or <code>kIOMessageSystemWillRestart</code>. */
virtual void systemWillShutdown( IOOptionBits specifier );
/*! @function copyClientWithCategory
* @availability Mac OS X v10.6 and later
* @param category An OSSymbol corresponding to an IOMatchCategory matching property.
* @result Returns a reference to the IOService child with the given category. The result should be released by the caller.
*/
virtual IOService * copyClientWithCategory( const OSSymbol * category );
public:
/*! @function configureReport
* @abstract configure IOReporting channels
* @availability SPI on OS X v10.9 / iOS 7 and later
*
* @param channels - channels to configure
* @param action - enable/disable/size, etc
* @param result - action-specific returned value
* @param destination - action-specific default destination
*/
virtual IOReturn configureReport(IOReportChannelList *channels,
IOReportConfigureAction action,
void *result,
void *destination);
/*! @function updateReport
* @abstract request current data for the specified channels
* @availability SPI on OS X 10.9 / iOS 7 and later
*
* @param channels - channels to be updated
* @param action - type/style of update
* @param result - returned details about what was updated
* @param destination - destination for this update (action-specific)
*/
virtual IOReturn updateReport(IOReportChannelList *channels,
IOReportUpdateAction action,
void *result,
void *destination);
protected:
/* these are helper methods for DriverKit */
IOReturn _ConfigureReport(IOReportChannelList *channels,
IOReportConfigureAction action,
void *result,
void *destination);
IOReturn _UpdateReport(IOReportChannelList *channels,
IOReportUpdateAction action,
void *result,
void *destination);
private:
#if __LP64__
OSMetaClassDeclareReservedUsedX86(IOService, 0);
OSMetaClassDeclareReservedUsedX86(IOService, 1);
OSMetaClassDeclareReservedUnused(IOService, 2);
OSMetaClassDeclareReservedUnused(IOService, 3);
OSMetaClassDeclareReservedUnused(IOService, 4);
OSMetaClassDeclareReservedUnused(IOService, 5);
OSMetaClassDeclareReservedUnused(IOService, 6);
OSMetaClassDeclareReservedUnused(IOService, 7);
#else
OSMetaClassDeclareReservedUsedX86(IOService, 0);
OSMetaClassDeclareReservedUsedX86(IOService, 1);
OSMetaClassDeclareReservedUsedX86(IOService, 2);
OSMetaClassDeclareReservedUsedX86(IOService, 3);
OSMetaClassDeclareReservedUsedX86(IOService, 4);
OSMetaClassDeclareReservedUsedX86(IOService, 5);
OSMetaClassDeclareReservedUsedX86(IOService, 6);
OSMetaClassDeclareReservedUsedX86(IOService, 7);
#endif
OSMetaClassDeclareReservedUnused(IOService, 8);
OSMetaClassDeclareReservedUnused(IOService, 9);
OSMetaClassDeclareReservedUnused(IOService, 10);
OSMetaClassDeclareReservedUnused(IOService, 11);
OSMetaClassDeclareReservedUnused(IOService, 12);
OSMetaClassDeclareReservedUnused(IOService, 13);
OSMetaClassDeclareReservedUnused(IOService, 14);
OSMetaClassDeclareReservedUnused(IOService, 15);
OSMetaClassDeclareReservedUnused(IOService, 16);
OSMetaClassDeclareReservedUnused(IOService, 17);
OSMetaClassDeclareReservedUnused(IOService, 18);
OSMetaClassDeclareReservedUnused(IOService, 19);
OSMetaClassDeclareReservedUnused(IOService, 20);
OSMetaClassDeclareReservedUnused(IOService, 21);
OSMetaClassDeclareReservedUnused(IOService, 22);
OSMetaClassDeclareReservedUnused(IOService, 23);
OSMetaClassDeclareReservedUnused(IOService, 24);
OSMetaClassDeclareReservedUnused(IOService, 25);
OSMetaClassDeclareReservedUnused(IOService, 26);
OSMetaClassDeclareReservedUnused(IOService, 27);
OSMetaClassDeclareReservedUnused(IOService, 28);
OSMetaClassDeclareReservedUnused(IOService, 29);
OSMetaClassDeclareReservedUnused(IOService, 30);
OSMetaClassDeclareReservedUnused(IOService, 31);
OSMetaClassDeclareReservedUnused(IOService, 32);
OSMetaClassDeclareReservedUnused(IOService, 33);
OSMetaClassDeclareReservedUnused(IOService, 34);
OSMetaClassDeclareReservedUnused(IOService, 35);
OSMetaClassDeclareReservedUnused(IOService, 36);
OSMetaClassDeclareReservedUnused(IOService, 37);
OSMetaClassDeclareReservedUnused(IOService, 38);
OSMetaClassDeclareReservedUnused(IOService, 39);
OSMetaClassDeclareReservedUnused(IOService, 40);
OSMetaClassDeclareReservedUnused(IOService, 41);
OSMetaClassDeclareReservedUnused(IOService, 42);
OSMetaClassDeclareReservedUnused(IOService, 43);
OSMetaClassDeclareReservedUnused(IOService, 44);
OSMetaClassDeclareReservedUnused(IOService, 45);
OSMetaClassDeclareReservedUnused(IOService, 46);
OSMetaClassDeclareReservedUnused(IOService, 47);
public:
/*! @function getState
* @abstract Accessor for IOService state bits, not normally needed or used outside IOService.
* @result State bits for the IOService, eg. <code>kIOServiceInactiveState</code>, <code>kIOServiceRegisteredState</code>. */
virtual IOOptionBits getState( void ) const;
/*! @function isInactive
* @abstract Checks if the IOService object has been terminated, and is in the process of being destroyed.
* @discussion When an IOService object is successfully terminated, it is immediately made inactive, which blocks further attach()es, matching or notifications occuring on the object. It remains inactive until the last client closes, and is then finalized and destroyed.
* @result <code>true</code> if the IOService object has been terminated. */
bool isInactive( void ) const;
/* Stack creation */
/*! @function registerService
* @abstract Starts the registration process for a newly discovered IOService object.
* @discussion This function allows an IOService subclass to be published and made available to possible clients, by starting the registration process and delivering notifications to registered clients. The object should be completely setup and ready to field requests from clients before <code>registerService</code> is called.
* @param options The default zero options mask is recommended and should be used in most cases. The registration process is usually asynchronous, with possible driver probing and notification occurring some time later. <code>kIOServiceSynchronous</code> may be passed to carry out the matching and notification process for currently registered clients before returning to the caller. */
virtual void registerService( IOOptionBits options = 0 );
/*! @function probe
* @abstract During an IOService object's instantiation, probes a matched service to see if it can be used.
* @discussion The registration process for an IOService object (the provider) includes instantiating possible driver clients. The <code>probe</code> method is called in the client instance to check the matched service can be used before the driver is considered to be started. Since matching screens many possible providers, in many cases the <code>probe</code> method can be left unimplemented by IOService subclasses. The client is already attached to the provider when <code>probe</code> is called.
* @param provider The registered IOService object that matches a driver personality's matching dictionary.
* @param score Pointer to the current driver's probe score, which is used to order multiple matching drivers in the same match category. It defaults to the value of the <code>IOProbeScore</code> property in the drivers property table, or <code>kIODefaultProbeScore</code> if none is specified. The <code>probe</code> method may alter the score to affect start order.
* @result An IOService instance or zero when the probe is unsuccessful. In almost all cases the value of <code>this</code> is returned on success. If another IOService object is returned, the probed instance is detached and freed, and the returned instance is used in its stead for <code>start</code>. */
virtual LIBKERN_RETURNS_NOT_RETAINED IOService * probe( IOService * provider,
SInt32 * score );
/*! @function start
* @abstract During an IOService object's instantiation, starts the IOService object that has been selected to run on the provider.
* @discussion The <code>start</code> method of an IOService instance is called by its provider when it has been selected (due to its probe score and match category) as the winning client. The client is already attached to the provider when <code>start</code> is called.<br>Implementations of <code>start</code> must call <code>start</code> on their superclass at an appropriate point. If an implementation of <code>start</code> has already called <code>super::start</code> but subsequently determines that it will fail, it must call <code>super::stop</code> to balance the prior call to <code>super::start</code> and prevent reference leaks.
* @result <code>true</code> if the start was successful; <code>false</code> otherwise (which will cause the instance to be detached and usually freed). */
virtual bool start( IOService * provider );
/*! @function stop
* @abstract During an IOService termination, the stop method is called in its clients before they are detached & it is destroyed.
* @discussion The termination process for an IOService (the provider) will call stop in each of its clients, after they have closed the provider if they had it open, or immediately on termination. */
virtual void stop( IOService * provider );
/* Open / Close */
/*! @function open
* @abstract Requests active access to a provider.
* @discussion IOService provides generic open and close semantics to track clients of a provider that have established an active datapath. The use of <code>open</code> and @link close close@/link, and rules regarding ownership are family defined, and defined by the @link handleOpen handleOpen@/link and @link handleClose handleClose@/link methods in the provider. Some families will limit access to a provider based on its open state.
* @param forClient Designates the client of the provider requesting the open.
* @param options Options for the open. The provider family may implement options for open; IOService defines only <code>kIOServiceSeize</code> to request the device be withdrawn from its current owner.
* @param arg Family specific arguments which are ignored by IOService.
* @result <code>true</code> if the open was successful; <code>false</code> otherwise. */
virtual bool open( IOService * forClient,
IOOptionBits options = 0,
void * arg = NULL );
/*! @function close
* @abstract Releases active access to a provider.
* @discussion IOService provides generic open and close semantics to track clients of a provider that have established an active datapath. The use of @link open open@/link and <code>close</code>, and rules regarding ownership are family defined, and defined by the @link handleOpen handleOpen@/link and @link handleClose handleClose@/link methods in the provider.
* @param forClient Designates the client of the provider requesting the close.
* @param options Options available for the close. The provider family may implement options for close; IOService defines none. */
virtual void close( IOService * forClient,
IOOptionBits options = 0 );
/*! @function isOpen
* @abstract Determines whether a specific, or any, client has an IOService object open.
* @discussion Returns the open state of an IOService object with respect to the specified client, or when it is open by any client.
* @param forClient If non-zero, <code>isOpen</code> returns the open state for that client. If zero is passed, <code>isOpen</code> returns the open state for all clients.
* @result <code>true</code> if the specific, or any, client has the IOService object open. */
virtual bool isOpen( const IOService * forClient = NULL ) const;
/*! @function handleOpen
* @abstract Controls the open / close behavior of an IOService object (overrideable by subclasses).
* @discussion IOService calls this method in its subclasses in response to the @link open open@/link method, so the subclass may implement the request. The default implementation provides single owner access to an IOService object via <code>open</code>. The object is locked via @link lockForArbitration lockForArbitration@/link before <code>handleOpen</code> is called.
* @param forClient Designates the client of the provider requesting the open.
* @param options Options for the open, may be interpreted by the implementor of <code>handleOpen</code>.
* @result <code>true</code>if the open was successful; <code>false</code> otherwise. */
virtual bool handleOpen( IOService * forClient,
IOOptionBits options,
void * arg );
/*! @function handleClose
* @abstract Controls the open / close behavior of an IOService object (overrideable by subclasses).
* @discussion IOService calls this method in its subclasses in response to the @link close close@/link method, so the subclass may implement the request. The default implementation provides single owner access to an IOService object via @link open open@/link. The object is locked via @link lockForArbitration lockForArbitration@/link before <code>handleClose</code> is called.
* @param forClient Designates the client of the provider requesting the close.
* @param options Options for the close, may be interpreted by the implementor of @link handleOpen handleOpen@/link. */
virtual void handleClose( IOService * forClient,
IOOptionBits options );
/*! @function handleIsOpen
* @abstract Controls the open / close behavior of an IOService object (overrideable by subclasses).
* @discussion IOService calls this method in its subclasses in response to the @link open open@/link method, so the subclass may implement the request. The default implementation provides single owner access to an IOService object via @link open open@/link. The object is locked via @link lockForArbitration lockForArbitration@/link before <code>handleIsOpen</code> is called.
* @param forClient If non-zero, <code>isOpen</code> returns the open state for that client. If zero is passed, <code>isOpen</code> returns the open state for all clients.
* @result <code>true</code> if the specific, or any, client has the IOService object open. */
virtual bool handleIsOpen( const IOService * forClient ) const;
/* Stacking change */
/*! @function terminate
* @abstract Makes an IOService object inactive and begins its destruction.
* @discussion Registering an IOService object informs possible clients of its existance and instantiates drivers that may be used with it; <code>terminate</code> involves the opposite process of informing clients that an IOService object is no longer able to be used and will be destroyed. By default, if any client has the service open, <code>terminate</code> fails. If the <code>kIOServiceRequired</code> flag is passed however, <code>terminate</code> will be successful though further progress in the destruction of the IOService object will not proceed until the last client has closed it. The service will be made inactive immediately upon successful termination, and all its clients will be notified via their @link message message@/link method with a message of type <code>kIOMessageServiceIsTerminated</code>. Both these actions take place on the caller's thread. After the IOService object is made inactive, further matching or attach calls will fail on it. Each client has its @link stop stop@/link method called upon their close of an inactive IOService object , or on its termination if they do not have it open. After <code>stop</code>, @link detach detach@/link is called in each client. When all clients have been detached, the @link finalize finalize@/link method is called in the inactive service. The termination process is inherently asynchronous because it will be deferred until all clients have chosen to close.
* @param options In most cases no options are needed. <code>kIOServiceSynchronous</code> may be passed to cause <code>terminate</code> to not return until the service is finalized. */
virtual bool terminate( IOOptionBits options = 0 );
/*! @function finalize
* @abstract Finalizes the destruction of an IOService object.
* @discussion The <code>finalize</code> method is called in an inactive (ie. terminated) IOService object after the last client has detached. IOService's implementation will call @link stop stop@/link, @link close close@/link, and @link detach detach@/link on each provider. When <code>finalize</code> returns, the object's retain count will have no references generated by IOService's registration process.
* @param options The options passed to the @link terminate terminate@/link method of the IOService object are passed on to <code>finalize</code>.
* @result <code>true</code>. */
virtual bool finalize( IOOptionBits options );
/*! @function init
* @abstract Initializes generic IOService data structures (expansion data, etc). */
virtual bool init( OSDictionary * dictionary = NULL ) APPLE_KEXT_OVERRIDE;
/*! @function init
* @abstract Initializes generic IOService data structures (expansion data, etc). */
virtual bool init( IORegistryEntry * from,
const IORegistryPlane * inPlane ) APPLE_KEXT_OVERRIDE;
/*! @function free
* @abstract Frees data structures that were allocated when power management was initialized on this service. */
virtual void free( void ) APPLE_KEXT_OVERRIDE;
/*! @function lockForArbitration
* @abstract Locks an IOService object against changes in state or ownership.
* @discussion The registration, termination and open / close functions of IOService use <code>lockForArbtration</code> to single-thread access to an IOService object. <code>lockForArbitration</code> grants recursive access to the same thread.
* @param isSuccessRequired If a request for access to an IOService object should be denied if it is terminated, pass <code>false</code>, otherwise pass <code>true</code>. */
virtual bool lockForArbitration( bool isSuccessRequired = true );
/*! @function unlockForArbitration
* @abstract Unlocks an IOService obkect after a successful @link lockForArbitration lockForArbitration@/link.
* @discussion A thread granted exclusive access to an IOService object should release it with <code>unlockForArbitration</code>. */
virtual void unlockForArbitration( void );
/*! @function terminateClient
* @abstract Passes a termination up the stack.
* @discussion When an IOService object is made inactive the default behavior is to also make any of its clients that have it as their only provider inactive, in this way recursing the termination up the driver stack. This method allows a terminated IOService object to override this behavior. Note the client may also override this behavior by overriding its @link terminate terminate@/link method.
* @param client The client of the terminated provider.
* @param options Options originally passed to @link terminate terminate@/link, plus <code>kIOServiceRecursing</code>.
* @result result of the terminate request on the client. */
virtual bool terminateClient( IOService * client, IOOptionBits options );
/* Busy state indicates discovery, matching or termination is in progress */
/*! @function getBusyState
* @abstract Returns the <code>busyState</code> of an IOService object.
* @discussion Many activities in IOService are asynchronous. When registration, matching, or termination is in progress on an IOService object, its <code>busyState</code> is increased by one. Change in <code>busyState</code> to or from zero also changes the IOService object's provider's <code>busyState</code> by one, which means that an IOService object is marked busy when any of the above activities is ocurring on it or any of its clients.
* @result The <code>busyState</code> value. */
virtual UInt32 getBusyState( void );
/*! @function adjustBusy
* @abstract Adjusts the <code>busyState</code> of an IOService object.
* @discussion Applies a delta to an IOService object's <code>busyState</code>. A change in the <code>busyState</code> to or from zero will change the IOService object's provider's <code>busyState</code> by one (in the same direction).
* @param delta The delta to be applied to the IOService object's <code>busyState</code>. */
virtual void adjustBusy( SInt32 delta );
APPLE_KEXT_COMPATIBILITY_VIRTUAL
IOReturn waitQuiet(mach_timespec_t * timeout)
APPLE_KEXT_DEPRECATED;
/*! @function waitQuiet
* @abstract Waits for an IOService object's <code>busyState</code> to be zero.
* @discussion Blocks the caller until an IOService object is non busy.
* @param timeout The maximum time to wait in nanoseconds. Default is to wait forever.
* @result Returns an error code if Mach synchronization primitives fail, <code>kIOReturnTimeout</code>, or <code>kIOReturnSuccess</code>. */
IOReturn waitQuiet(uint64_t timeout = UINT64_MAX);
/* Matching */
/*! @function matchPropertyTable
* @abstract Allows a registered IOService object to implement family specific matching.
* @discussion All matching on an IOService object will call this method to allow a family writer to implement matching in addition to the generic methods provided by IOService. The implementer should examine the matching dictionary passed to see if it contains properties the family understands for matching, and use them to match with the IOService object if so. Note that since matching is also carried out by other parts of the I/O Kit, the matching dictionary may contain properties the family does not understand - these should not be considered matching failures.
* @param table The dictionary of properties to be matched against.
* @param score Pointer to the current driver's probe score, which is used to order multiple matching drivers in the same match category. It defaults to the value of the <code>IOProbeScore</code> property in the drivers property table, or <code>kIODefaultProbeScore</code> if none is specified.
* @result <code>false</code> if the family considers the matching dictionary does not match in properties it understands; <code>true</code> otherwise. */
virtual bool matchPropertyTable( OSDictionary * table,
SInt32 * score );
virtual bool matchPropertyTable( OSDictionary * table );
/*! @function matchLocation
* @abstract Allows a registered IOService object to direct location matching.
* @discussion By default, a location matching property will be applied to an IOService object's provider. This method allows that behavior to be overridden by families.
* @param client The IOService object at which matching is taking place.
* @result Returns the IOService instance to be used for location matching. */
virtual LIBKERN_RETURNS_NOT_RETAINED IOService * matchLocation( IOService * client );
/* Resource service */
/*! @function publishResource
* @abstract Uses the resource service to publish a property.
* @discussion The resource service uses IOService's matching and notification to allow objects to be published and found by any I/O Kit client by a global name. <code>publishResource</code> makes an object available to anyone waiting for it or looking for it in the future.
* @param key An OSSymbol key that globally identifies the object.
* @param value The object to be published. */
static void publishResource( const OSSymbol * key, OSObject * value = NULL );
static void publishUserResource( const OSSymbol * key, OSObject * value = NULL );
/*! @function publishResource
* @abstract Uses the resource service to publish a property.
* @discussion The resource service uses IOService object's matching and notification to allow objects to be published and found by any I/O Kit client by a global name. <code>publishResource</code> makes an object available to anyone waiting for it or looking for it in the future.
* @param key A C string key that globally identifies the object.
* @param value The object to be published. */
static void publishResource( const char * key, OSObject * value = NULL );
virtual bool addNeededResource( const char * key );
/* Notifications */
/*! @function addNotification
* @abstract Deprecated use addMatchingNotification(). Adds a persistant notification handler to be notified of IOService events.
* @discussion IOService will deliver notifications of changes in state of an IOService object to registered clients. The type of notification is specified by a symbol, for example <code>gIOMatchedNotification</code> or <code>gIOTerminatedNotification</code>, and notifications will only include IOService objects that match the supplied matching dictionary. Notifications are ordered by a priority set with <code>addNotification</code>. When the notification is installed, its handler will be called with each of any currently existing IOService objects that are in the correct state (eg. registered) and match the supplied matching dictionary, avoiding races between finding preexisting and new IOService events. The notification request is identified by an instance of an IONotifier object, through which it can be enabled, disabled, or removed. <code>addNotification</code> consumes a retain count on the matching dictionary when the notification is removed.
* @param type An OSSymbol identifying the type of notification and IOService state:
* <br> <code>gIOPublishNotification</code> Delivered when an IOService object is registered.
* <br> <code>gIOFirstPublishNotification</code> Delivered when an IOService object is registered, but only once per IOService instance. Some IOService objects may be reregistered when their state is changed.
* <br> <code>gIOMatchedNotification</code> Delivered when an IOService object has been matched with all client drivers, and they have been probed and started.
* <br> <code>gIOFirstMatchNotification</code> Delivered when an IOService object has been matched with all client drivers, but only once per IOService instance. Some IOService objects may be reregistered when their state is changed.
* <br> <code>gIOWillTerminateNotification</code> Delivered after an IOService object has been terminated, during its finalize stage. Delivered after any matching on the service has finished.
* <br> <code>gIOTerminatedNotification</code> Delivered immediately when an IOService object has been terminated, making it inactive.
* @param matching A matching dictionary to restrict notifications to only matching IOService objects. The dictionary will be released when the notification is removed, consuming the passed-in reference.
* @param handler A C function callback to deliver notifications.
* @param target An instance reference for the callback's use.
* @param ref A reference constant for the callback's use.
* @param priority A constant ordering all notifications of a each type.
* @result An instance of an IONotifier object that can be used to control or destroy the notification request. */
static OSPtr<IONotifier> addNotification(
const OSSymbol * type, OSDictionary * matching,
IOServiceNotificationHandler handler,
void * target, void * ref = NULL,
SInt32 priority = 0 )
APPLE_KEXT_DEPRECATED;
/*! @function addMatchingNotification
* @abstract Adds a persistant notification handler to be notified of IOService events.
* @discussion IOService will deliver notifications of changes in state of an IOService object to registered clients. The type of notification is specified by a symbol, for example <code>gIOMatchedNotification</code> or <code>gIOTerminatedNotification</code>, and notifications will only include IOService objects that match the supplied matching dictionary. Notifications are ordered by a priority set with <code>addNotification</code>. When the notification is installed, its handler will be called with each of any currently existing IOService objects that are in the correct state (eg. registered) and match the supplied matching dictionary, avoiding races between finding preexisting and new IOService events. The notification request is identified by an instance of an IONotifier object, through which it can be enabled, disabled, or removed. <code>addMatchingNotification</code> does not consume a reference on the matching dictionary when the notification is removed, unlike addNotification.
* @param type An OSSymbol identifying the type of notification and IOService state:
* <br> <code>gIOPublishNotification</code> Delivered when an IOService object is registered.
* <br> <code>gIOFirstPublishNotification</code> Delivered when an IOService object is registered, but only once per IOService instance. Some IOService objects may be reregistered when their state is changed.
* <br> <code>gIOMatchedNotification</code> Delivered when an IOService object has been matched with all client drivers, and they have been probed and started.
* <br> <code>gIOFirstMatchNotification</code> Delivered when an IOService object has been matched with all client drivers, but only once per IOService instance. Some IOService objects may be reregistered when their state is changed.
* <br> <code>gIOWillTerminateNotification</code> Delivered after an IOService object has been terminated, during its finalize stage. Delivered after any matching on the service has finished.
* <br> <code>gIOTerminatedNotification</code> Delivered immediately when an IOService object has been terminated, making it inactive.
* @param matching A matching dictionary to restrict notifications to only matching IOService objects. The dictionary is retained while the notification is installed. (Differs from addNotification).
* @param handler A C function callback to deliver notifications.
* @param target An instance reference for the callback's use.
* @param ref A reference constant for the callback's use.
* @param priority A constant ordering all notifications of a each type.
* @result An instance of an IONotifier object that can be used to control or destroy the notification request. */
static IONotifier * addMatchingNotification(
const OSSymbol * type, OSDictionary * matching,
IOServiceMatchingNotificationHandler handler,
void * target, void * ref = NULL,
SInt32 priority = 0 );
#ifdef __BLOCKS__
static IONotifier * addMatchingNotification(
const OSSymbol * type, OSDictionary * matching,
SInt32 priority,
IOServiceMatchingNotificationHandlerBlock handler);
#endif /* __BLOCKS__ */
/*! @function waitForService
* @abstract Deprecated use waitForMatchingService(). Waits for a matching to service to be published.
* @discussion Provides a method of waiting for an IOService object matching the supplied matching dictionary to be registered and fully matched.
* @param matching The matching dictionary describing the desired IOService object. <code>waitForService</code> consumes one reference of the matching dictionary.
* @param timeout The maximum time to wait.
* @result A published IOService object matching the supplied dictionary. */
static LIBKERN_RETURNS_NOT_RETAINED IOService * waitForService(
LIBKERN_CONSUMED OSDictionary * matching,
mach_timespec_t * timeout = NULL);
/*! @function waitForMatchingService
* @abstract Waits for a matching to service to be published.
* @discussion Provides a method of waiting for an IOService object matching the supplied matching dictionary to be registered and fully matched.
* @param matching The matching dictionary describing the desired IOService object. (Does not consume a reference of the matching dictionary - differs from waitForService() which does consume a reference on the matching dictionary.)
* @param timeout The maximum time to wait in nanoseconds. Default is to wait forever.
* @result A published IOService object matching the supplied dictionary. waitForMatchingService returns a reference to the IOService which should be released by the caller. (Differs from waitForService() which does not retain the returned object.) */
static OSPtr<IOService> waitForMatchingService( OSDictionary * matching,
uint64_t timeout = UINT64_MAX);
/*! @function getMatchingServices
* @abstract Finds the set of current published IOService objects matching a matching dictionary.
* @discussion Provides a method of finding the current set of published IOService objects matching the supplied matching dictionary.
* @param matching The matching dictionary describing the desired IOService objects.
* @result An instance of an iterator over a set of IOService objects. To be released by the caller. */
static OSPtr<OSIterator> getMatchingServices( OSDictionary * matching );
/*! @function copyMatchingService
* @abstract Finds one of the current published IOService objects matching a matching dictionary.
* @discussion Provides a method to find one member of the set of published IOService objects matching the supplied matching dictionary.
* @param matching The matching dictionary describing the desired IOService object.
* @result The IOService object or NULL. To be released by the caller. */
static OSPtr<IOService> copyMatchingService( OSDictionary * matching );
public:
/* Helpers to make matching dictionaries for simple cases,
* they add keys to an existing dictionary, or create one. */
/*! @function serviceMatching
* @abstract Creates a matching dictionary, or adds matching properties to an existing dictionary, that specify an IOService class match.
* @discussion A very common matching criteria for IOService object is based on its class. <code>serviceMatching</code> creates a matching dictionary that specifies any IOService object of a class, or its subclasses. The class is specified by name, and an existing dictionary may be passed in, in which case the matching properties will be added to that dictionary rather than creating a new one.
* @param className The class name, as a const C string. Class matching is successful on IOService objects of this class or any subclass.
* @param table If zero, <code>serviceMatching</code> creates a matching dictionary and returns a reference to it, otherwise the matching properties are added to the specified dictionary.
* @result The matching dictionary created, or passed in, is returned on success, or zero on failure. */
static OSPtr<OSDictionary> serviceMatching( const char * className,
OSDictionary * table = NULL );
#if __cplusplus >= 201703L
/*! @function serviceMatching
* @abstract Creates a matching dictionary, or adds matching properties to an existing dictionary, that specify an IOService class match.
* @discussion A very common matching criteria for IOService object is based on its class. <code>serviceMatching</code> creates a matching dictionary that specifies any IOService object of a class, or its subclasses. The class is specified by name, and an existing dictionary may be passed in, in which case the matching properties will be added to that dictionary rather than creating a new one.
* @param className The class name, as a const C string. Class matching is successful on IOService objects of this class or any subclass.
* @param table If zero, <code>serviceMatching</code> creates a matching dictionary and returns a reference to it, otherwise the matching properties are added to the specified dictionary.
* @result The matching dictionary created, or passed in, is returned on success, or zero on failure. */
static OSSharedPtr<OSDictionary> serviceMatching( const char * className,
OSSharedPtr<OSDictionary> table);
#endif
/*! @function serviceMatching
* @abstract Creates a matching dictionary, or adds matching properties to an existing dictionary, that specify an IOService class match.
* @discussion A very common matching criteria for IOService object is based on its class. <code>serviceMatching</code> creates a matching dictionary that specifies any IOService of a class, or its subclasses. The class is specified by name, and an existing dictionary may be passed in, in which case the matching properties will be added to that dictionary rather than creating a new one.
* @param className The class name, as an OSString (which includes OSSymbol). Class matching is successful on IOService objects of this class or any subclass.
* @param table If zero, <code>serviceMatching</code> creates a matching dictionary and returns a reference to it, otherwise the matching properties are added to the specified dictionary.
* @result The matching dictionary created, or passed in, is returned on success, or zero on failure. */
static OSPtr<OSDictionary> serviceMatching( const OSString * className,
OSDictionary * table = NULL );
#if __cplusplus >= 201703L
/*! @function serviceMatching
* @abstract Creates a matching dictionary, or adds matching properties to an existing dictionary, that specify an IOService class match.
* @discussion A very common matching criteria for IOService object is based on its class. <code>serviceMatching</code> creates a matching dictionary that specifies any IOService of a class, or its subclasses. The class is specified by name, and an existing dictionary may be passed in, in which case the matching properties will be added to that dictionary rather than creating a new one.
* @param className The class name, as an OSString (which includes OSSymbol). Class matching is successful on IOService objects of this class or any subclass.
* @param table If zero, <code>serviceMatching</code> creates a matching dictionary and returns a reference to it, otherwise the matching properties are added to the specified dictionary.
* @result The matching dictionary created, or passed in, is returned on success, or zero on failure. */
static OSSharedPtr<OSDictionary> serviceMatching( const OSString * className,
OSSharedPtr<OSDictionary> table);
#endif
/*! @function nameMatching
* @abstract Creates a matching dictionary, or adds matching properties to an existing dictionary, that specify an IOService name match.
* @discussion A very common matching criteria for IOService object is based on its name. <code>nameMatching</code> creates a matching dictionary that specifies any IOService object which responds successfully to the @link //apple_ref/cpp/instm/IORegistryEntry/compareName/virtualbool/(OSString*,OSString**) IORegistryEntry::compareName@/link method. An existing dictionary may be passed in, in which case the matching properties will be added to that dictionary rather than creating a new one.
* @param name The service's name, as a const C string. Name matching is successful on IOService objects that respond successfully to the <code>IORegistryEntry::compareName</code> method.
* @param table If zero, <code>nameMatching</code> creates a matching dictionary and returns a reference to it, otherwise the matching properties are added to the specified dictionary.
* @result The matching dictionary created, or passed in, is returned on success, or zero on failure. */
static OSPtr<OSDictionary> nameMatching( const char * name,
OSDictionary * table = NULL );
#if __cplusplus >= 201703L
/*! @function nameMatching
* @abstract Creates a matching dictionary, or adds matching properties to an existing dictionary, that specify an IOService name match.
* @discussion A very common matching criteria for IOService object is based on its name. <code>nameMatching</code> creates a matching dictionary that specifies any IOService object which responds successfully to the @link //apple_ref/cpp/instm/IORegistryEntry/compareName/virtualbool/(OSString*,OSString**) IORegistryEntry::compareName@/link method. An existing dictionary may be passed in, in which case the matching properties will be added to that dictionary rather than creating a new one.
* @param name The service's name, as a const C string. Name matching is successful on IOService objects that respond successfully to the <code>IORegistryEntry::compareName</code> method.
* @param table If zero, <code>nameMatching</code> creates a matching dictionary and returns a reference to it, otherwise the matching properties are added to the specified dictionary.
* @result The matching dictionary created, or passed in, is returned on success, or zero on failure. */
static OSSharedPtr<OSDictionary> nameMatching( const char * name,
OSSharedPtr<OSDictionary> table);
#endif
/*! @function nameMatching
* @abstract Creates a matching dictionary, or adds matching properties to an existing dictionary, that specify an IOService name match.
* @discussion A very common matching criteria for IOService object is based on its name. <code>nameMatching</code> creates a matching dictionary that specifies any IOService object which responds successfully to the @link //apple_ref/cpp/instm/IORegistryEntry/compareName/virtualbool/(OSString*,OSString**) IORegistryEntry::compareName@/link method. An existing dictionary may be passed in, in which case the matching properties will be added to that dictionary rather than creating a new one.
* @param name The service's name, as an OSString (which includes OSSymbol). Name matching is successful on IOService objects that respond successfully to the <code>IORegistryEntry::compareName</code> method.
* @param table If zero, <code>nameMatching</code> creates a matching dictionary and returns a reference to it, otherwise the matching properties are added to the specified dictionary.
* @result The matching dictionary created, or passed in, is returned on success, or zero on failure. */
static OSPtr<OSDictionary> nameMatching( const OSString* name,
OSDictionary * table = NULL );
#if __cplusplus >= 201703L
/*! @function nameMatching
* @abstract Creates a matching dictionary, or adds matching properties to an existing dictionary, that specify an IOService name match.
* @discussion A very common matching criteria for IOService object is based on its name. <code>nameMatching</code> creates a matching dictionary that specifies any IOService object which responds successfully to the @link //apple_ref/cpp/instm/IORegistryEntry/compareName/virtualbool/(OSString*,OSString**) IORegistryEntry::compareName@/link method. An existing dictionary may be passed in, in which case the matching properties will be added to that dictionary rather than creating a new one.
* @param name The service's name, as an OSString (which includes OSSymbol). Name matching is successful on IOService objects that respond successfully to the <code>IORegistryEntry::compareName</code> method.
* @param table If zero, <code>nameMatching</code> creates a matching dictionary and returns a reference to it, otherwise the matching properties are added to the specified dictionary.
* @result The matching dictionary created, or passed in, is returned on success, or zero on failure. */
static OSSharedPtr<OSDictionary> nameMatching( const OSString* name,
OSSharedPtr<OSDictionary> table);
#endif
/*! @function resourceMatching
* @abstract Creates a matching dictionary, or adds matching properties to an existing dictionary, that specify a resource service match.
* @discussion IOService maintains a resource service IOResources that allows objects to be published and found globally in the I/O Kit based on a name, using the standard IOService matching and notification calls.
* @param name The resource name, as a const C string. Resource matching is successful when an object by that name has been published with the <code>publishResource</code> method.
* @param table If zero, <code>resourceMatching</code> creates a matching dictionary and returns a reference to it, otherwise the matching properties are added to the specified dictionary.
* @result The matching dictionary created, or passed in, is returned on success, or zero on failure. */
static OSPtr<OSDictionary> resourceMatching( const char * name,
OSDictionary * table = NULL );
#if __cplusplus >= 201703L
/*! @function resourceMatching
* @abstract Creates a matching dictionary, or adds matching properties to an existing dictionary, that specify a resource service match.
* @discussion IOService maintains a resource service IOResources that allows objects to be published and found globally in the I/O Kit based on a name, using the standard IOService matching and notification calls.
* @param name The resource name, as a const C string. Resource matching is successful when an object by that name has been published with the <code>publishResource</code> method.
* @param table If zero, <code>resourceMatching</code> creates a matching dictionary and returns a reference to it, otherwise the matching properties are added to the specified dictionary.
* @result The matching dictionary created, or passed in, is returned on success, or zero on failure. */
static OSSharedPtr<OSDictionary> resourceMatching( const char * name,
OSSharedPtr<OSDictionary> table);
#endif
/*! @function resourceMatching
* @abstract Creates a matching dictionary, or adds matching properties to an existing dictionary, that specify a resource service match.
* @discussion IOService maintains a resource service IOResources that allows objects to be published and found globally in the I/O Kit based on a name, using the standard IOService matching and notification calls.
* @param name The resource name, as an OSString (which includes OSSymbol). Resource matching is successful when an object by that name has been published with the <code>publishResource</code> method.
* @param table If zero, <code>resourceMatching</code> creates a matching dictionary and returns a reference to it, otherwise the matching properties are added to the specified dictionary.
* @result The matching dictionary created, or passed in, is returned on success, or zero on failure. */
static OSPtr<OSDictionary> resourceMatching( const OSString * name,
OSDictionary * table = NULL );
#if __cplusplus >= 201703L
/*! @function resourceMatching
* @abstract Creates a matching dictionary, or adds matching properties to an existing dictionary, that specify a resource service match.
* @discussion IOService maintains a resource service IOResources that allows objects to be published and found globally in the I/O Kit based on a name, using the standard IOService matching and notification calls.
* @param name The resource name, as an OSString (which includes OSSymbol). Resource matching is successful when an object by that name has been published with the <code>publishResource</code> method.
* @param table If zero, <code>resourceMatching</code> creates a matching dictionary and returns a reference to it, otherwise the matching properties are added to the specified dictionary.
* @result The matching dictionary created, or passed in, is returned on success, or zero on failure. */
static OSSharedPtr<OSDictionary> resourceMatching( const OSString * name,
OSSharedPtr<OSDictionary> table);
#endif
/*! @function propertyMatching
* @abstract Creates a matching dictionary, or adds matching properties to an existing dictionary, that specify an IOService phandle match.
* @discussion TODO A very common matching criteria for IOService is based on its name. nameMatching will create a matching dictionary that specifies any IOService which respond successfully to the IORegistryEntry method compareName. An existing dictionary may be passed in, in which case the matching properties will be added to that dictionary rather than creating a new one.
* @param key The service's phandle, as a const UInt32. PHandle matching is successful on IOService objects that respond successfully to the IORegistryEntry method compareName.
* @param value The service's phandle, as a const UInt32. PHandle matching is successful on IOService's which respond successfully to the IORegistryEntry method compareName.
* @param table If zero, nameMatching will create a matching dictionary and return a reference to it, otherwise the matching properties are added to the specified dictionary.
* @result The matching dictionary created, or passed in, is returned on success, or zero on failure. */
static OSPtr<OSDictionary> propertyMatching( const OSSymbol * key, const OSObject * value,
OSDictionary * table = NULL );
#if __cplusplus >= 201703L
/*! @function propertyMatching
* @abstract Creates a matching dictionary, or adds matching properties to an existing dictionary, that specify an IOService phandle match.
* @discussion TODO A very common matching criteria for IOService is based on its name. nameMatching will create a matching dictionary that specifies any IOService which respond successfully to the IORegistryEntry method compareName. An existing dictionary may be passed in, in which case the matching properties will be added to that dictionary rather than creating a new one.
* @param key The service's phandle, as a const UInt32. PHandle matching is successful on IOService objects that respond successfully to the IORegistryEntry method compareName.
* @param value The service's phandle, as a const UInt32. PHandle matching is successful on IOService's which respond successfully to the IORegistryEntry method compareName.
* @param table If zero, nameMatching will create a matching dictionary and return a reference to it, otherwise the matching properties are added to the specified dictionary.
* @result The matching dictionary created, or passed in, is returned on success, or zero on failure. */
static OSSharedPtr<OSDictionary> propertyMatching( const OSSymbol * key, const OSObject * value,
OSSharedPtr<OSDictionary> table);
#endif
/*! @function registryEntryIDMatching
* @abstract Creates a matching dictionary, or adds matching properties to an existing dictionary, that specify a IORegistryEntryID match.
* @discussion <code>registryEntryIDMatching</code> creates a matching dictionary that specifies the IOService object with the assigned registry entry ID (returned by <code>IORegistryEntry::getRegistryEntryID()</code>). An existing dictionary may be passed in, in which case the matching properties will be added to that dictionary rather than creating a new one.
* @param entryID The service's ID. Matching is successful on the IOService object that return that ID from the <code>IORegistryEntry::getRegistryEntryID()</code> method.
* @param table If zero, <code>registryEntryIDMatching</code> creates a matching dictionary and returns a reference to it, otherwise the matching properties are added to the specified dictionary.
* @result The matching dictionary created, or passed in, is returned on success, or zero on failure. */
static OSDictionary * registryEntryIDMatching( uint64_t entryID,
OSDictionary * table = NULL );
#if __cplusplus >= 201703L
/*! @function registryEntryIDMatching
* @abstract Creates a matching dictionary, or adds matching properties to an existing dictionary, that specify a IORegistryEntryID match.
* @discussion <code>registryEntryIDMatching</code> creates a matching dictionary that specifies the IOService object with the assigned registry entry ID (returned by <code>IORegistryEntry::getRegistryEntryID()</code>). An existing dictionary may be passed in, in which case the matching properties will be added to that dictionary rather than creating a new one.
* @param entryID The service's ID. Matching is successful on the IOService object that return that ID from the <code>IORegistryEntry::getRegistryEntryID()</code> method.
* @param table If zero, <code>registryEntryIDMatching</code> creates a matching dictionary and returns a reference to it, otherwise the matching properties are added to the specified dictionary.
* @result The matching dictionary created, or passed in, is returned on success, or zero on failure. */
static OSSharedPtr<OSDictionary> registryEntryIDMatching( uint64_t entryID,
OSSharedPtr<OSDictionary> table);
#endif
/*! @function addLocation
* @abstract Adds a location matching property to an existing dictionary.
* @discussion This function creates matching properties that specify the location of a IOService object, as an embedded matching dictionary. This matching will be successful on an IOService object that attached to an IOService object which matches this location matching dictionary.
* @param table The matching properties are added to the specified dictionary, which must be non-zero.
* @result The location matching dictionary created is returned on success, or zero on failure. */
static OSPtr<OSDictionary> addLocation( OSDictionary * table );
/* Helpers for matching dictionaries. */
/*! @function compareProperty
* @abstract Compares a property in a matching dictionary with an IOService object's property table.
* @discussion This is a helper function to aid in implementing @link matchPropertyTable matchPropertyTable@/link. If the property specified by <code>key</code> exists in the matching dictionary, it is compared with a property of the same name in the IOService object's property table. The comparison is performed with the <code>isEqualTo</code> method. If the property does not exist in the matching table, success is returned. If the property exists in the matching dictionary but not the IOService property table, failure is returned.
* @param matching The matching dictionary, which must be non-zero.
* @param key The dictionary key specifying the property to be compared, as a C string.
* @result <code>true</code> if the property does not exist in the matching table. If the property exists in the matching dictionary but not the IOService property table, failure is returned. Otherwise the result of calling the property from the matching dictionary's <code>isEqualTo</code> method with the IOService property as an argument is returned. */
virtual bool compareProperty( OSDictionary * matching,
const char * key );
/*! @function compareProperty
* @abstract Compares a property in a matching dictionary with an IOService object's property table.
* @discussion This is a helper function to aid in implementing @link matchPropertyTable matchPropertyTable@/link. If the property specified by <code>key</code> exists in the matching dictionary, it is compared with a property of the same name in the IOService object's property table. The comparison is performed with the <code>isEqualTo</code> method. If the property does not exist in the matching table, success is returned. If the property exists in the matching dictionary but not the IOService property table, failure is returned.
* @param matching The matching dictionary, which must be non-zero.
* @param key The dictionary key specifying the property to be compared, as an OSString (which includes OSSymbol).
* @result <code>true</code> if the property does not exist in the matching table. If the property exists in the matching dictionary but not the IOService property table, failure is returned. Otherwise the result of calling the property from the matching dictionary's <code>isEqualTo</code> method with the IOService property as an argument is returned. */
virtual bool compareProperty( OSDictionary * matching,
const OSString * key );
/*! @function compareProperties
* @abstract Compares a set of properties in a matching dictionary with an IOService object's property table.
* @discussion This is a helper function to aid in implementing @link matchPropertyTable matchPropertyTable@/link. A collection of dictionary keys specifies properties in a matching dictionary to be compared, with <code>compareProperty</code>, with an IOService object's property table, if <code>compareProperty</code> returns <code>true</code> for each key, success is returned; otherwise failure.
* @param matching The matching dictionary, which must be non-zero.
* @param keys A collection (eg. OSSet, OSArray, OSDictionary) which should contain OSStrings (or OSSymbols) that specify the property keys to be compared.
* @result Success if <code>compareProperty</code> returns <code>true</code> for each key in the collection; otherwise failure. */
virtual bool compareProperties( OSDictionary * matching,
OSCollection * keys );
/* Client / provider accessors */
/*! @function attach
* @abstract Attaches an IOService client to a provider in the I/O Registry.
* @discussion This function called in an IOService client enters the client into the I/O Registry as a child of the provider in the service plane. The provider must be active or the attach will fail. Multiple attach calls to the same provider are no-ops and return success. A client may be attached to multiple providers. Entering an object into the I/O Registry retains both the client and provider until they are detached.
* @param provider The IOService object which will serve as this object's provider.
* @result <code>false</code> if the provider is inactive or on a resource failure; otherwise <code>true</code>. */
virtual bool attach( IOService * provider );
/*! @function detach
* @abstract Detaches an IOService client from a provider in the I/O Registry.
* @discussion This function called in an IOService client removes the client as a child of the provider in the service plane of the I/O Registry. If the provider is not a parent of the client this is a no-op, otherwise the I/O Registry releases both the client and provider.
* @param provider The IOService object to detach from. */
virtual void detach( IOService * provider );
/*! @function getProvider
* @abstract Returns an IOService object's primary provider.
* @discussion This function called in an IOService client will return the provider to which it was first attached. Because the majority of IOService objects have only one provider, this is a useful simplification and also supports caching of the provider when the I/O Registry is unchanged.
* @result The first provider of the client, or zero if the IOService object is not attached into the I/O Registry. The provider is retained while the client is attached, and should not be released by the caller. */
virtual IOService * getProvider( void ) const;
/*! @function getWorkLoop
* @abstract Returns the current work loop or <code>provider->getWorkLoop</code>.
* @discussion This function returns a valid work loop that a client can use to add an IOCommandGate to. The intention is that an IOService client has data that needs to be protected but doesn't want to pay the cost of a dedicated thread. This data has to be accessed from a provider's call-out context as well. So to achieve both of these goals the client creates an IOCommandGate to lock access to his data but he registers it with the provider's work loop, i.e. the work loop which will make the completion call-outs. This avoids a potential deadlock because the work loop gate uses a recursive lock, which allows the same lock to be held multiple times by a single thread.
* @result A work loop, either the current work loop or it walks up the @link getProvider getProvider@/link chain calling <code>getWorkLoop</code>. Eventually it will reach a valid work loop-based driver or the root of the I/O tree, where it will return a system-wide work loop. Returns 0 if it fails to find (or create) a work loop.*/
virtual IOWorkLoop * getWorkLoop() const;
/*! @function getProviderIterator
* @abstract Returns an iterator over an IOService object's providers.
* @discussion For those few IOService objects that obtain service from multiple providers, this method supplies an iterator over a client's providers.
* @result An iterator over the providers of the client, or zero if there is a resource failure. The iterator must be released when the iteration is finished. All objects returned by the iteration are retained while the iterator is valid, though they may no longer be attached during the iteration. */
virtual OSPtr<OSIterator> getProviderIterator( void ) const;
/*! @function getOpenProviderIterator
* @abstract Returns an iterator over an client's providers that are currently opened by the client.
* @discussion For those few IOService objects that obtain service from multiple providers, this method supplies an iterator over a client's providers, locking each in turn with @link lockForArbitration lockForArbitration@/link and returning those that have been opened by the client.
* @result An iterator over the providers the client has open, or zero if there is a resource failure. The iterator must be released when the iteration is finished. All objects returned by the iteration are retained while the iterator is valid, and the current entry in the iteration is locked with <code>lockForArbitration</code>, protecting it from state changes. */
virtual OSPtr<OSIterator> getOpenProviderIterator( void ) const;
/*! @function getClient
* @abstract Returns an IOService object's primary client.
* @discussion This function called in an IOService provider will return the first client to attach to it. For IOService objects which have only only one client, this may be a useful simplification.
* @result The first client of the provider, or zero if the IOService object is not attached into the I/O Registry. The client is retained while it is attached, and should not be released by the caller. */
virtual IOService * getClient( void ) const;
/*! @function getClientIterator
* @abstract Returns an iterator over an IOService object's clients.
* @discussion For IOService objects that may have multiple clients, this method supplies an iterator over a provider's clients.
* @result An iterator over the clients of the provider, or zero if there is a resource failure. The iterator must be released when the iteration is finished. All objects returned by the iteration are retained while the iterator is valid, though they may no longer be attached during the iteration. */
virtual OSPtr<OSIterator> getClientIterator( void ) const;
/*! @function getOpenClientIterator
* @abstract Returns an iterator over a provider's clients that currently have opened the provider.
* @discussion For IOService objects that may have multiple clients, this method supplies an iterator over a provider's clients, locking each in turn with @link lockForArbitration lockForArbitration@/link and returning those that have opened the provider.
* @result An iterator over the clients that have opened the provider, or zero if there is a resource failure. The iterator must be released when the iteration is finished. All objects returned by the iteration are retained while the iterator is valid, and the current entry in the iteration is locked with <code>lockForArbitration</code>, protecting it from state changes. */
virtual OSPtr<OSIterator> getOpenClientIterator( void ) const;
/*! @function callPlatformFunction
* @abstract Calls the platform function with the given name.
* @discussion The platform expert or other drivers may implement various functions to control hardware features. <code>callPlatformFunction</code> allows any IOService object to access these functions. Normally <code>callPlatformFunction</code> is called on a service's provider. The provider services the request or passes it to its provider. The system's IOPlatformExpert subclass catches functions it knows about and redirects them into other parts of the service plane. If the IOPlatformExpert subclass cannot execute the function, the base class is called. The IOPlatformExpert base class attempts to find a service to execute the function by looking up the function name in an IOResources name space. A service may publish a service using <code>publishResource(functionName, this)</code>. If no service can be found to execute the function an error is returned.
* @param functionName Name of the function to be called. When <code>functionName</code> is a C string, <code>callPlatformFunction</code> converts the C string to an OSSymbol and calls the OSSymbol version of <code>callPlatformFunction</code>. This process can block and should not be used from an interrupt context.
* @param waitForFunction If <code>true</code>, <code>callPlatformFunction</code> will not return until the function has been called.
* @result An IOReturn code; <code>kIOReturnSuccess</code> if the function was successfully executed, <code>kIOReturnUnsupported</code> if a service to execute the function could not be found. Other return codes may be returned by the function.*/
virtual IOReturn callPlatformFunction( const OSSymbol * functionName,
bool waitForFunction,
void *param1, void *param2,
void *param3, void *param4 );
virtual IOReturn callPlatformFunction( const char * functionName,
bool waitForFunction,
void *param1, void *param2,
void *param3, void *param4 );
/* Some accessors */
/*! @function getPlatform
* @abstract Returns a pointer to the platform expert instance for the computer.
* @discussion This method provides an accessor to the platform expert instance for the computer.
* @result A pointer to the IOPlatformExpert instance. It should not be released by the caller. */
static IOPlatformExpert * getPlatform( void );
/*! @function getPMRootDomain
* @abstract Returns a pointer to the power management root domain instance for the computer.
* @discussion This method provides an accessor to the power management root domain instance for the computer.
* @result A pointer to the power management root domain instance. It should not be released by the caller. */
static class IOPMrootDomain * getPMRootDomain( void );
/*! @function getServiceRoot
* @abstract Returns a pointer to the root of the service plane.
* @discussion This method provides an accessor to the root of the service plane for the computer.
* @result A pointer to the IOService instance at the root of the service plane. It should not be released by the caller. */
static IOService * getServiceRoot( void );
/*! @function getResourceService
* @abstract Returns a pointer to the IOResources service.
* @discussion IOService maintains a resource service IOResources that allows objects to be published and found globally in the I/O Kit based on a name, using the standard IOService matching and notification calls.
* @result A pointer to the IOResources instance. It should not be released by the caller. */
static IOService * getResourceService( void );
static IOService * getSystemStateNotificationService(void);
/* Allocate resources for a matched service */
/*! @function getResources
* @abstract Allocates any needed resources for a published IOService object before clients attach.
* @discussion This method is called during the registration process for an IOService object if there are successful driver matches, before any clients attach. It allows for lazy allocation of resources to an IOService object when a matching driver is found.
* @result An IOReturn code; <code>kIOReturnSuccess</code> is necessary for the IOService object to be successfully used, otherwise the registration process for the object is halted. */
virtual IOReturn getResources( void );
/* Device memory accessors */
/*! @function getDeviceMemoryCount
* @abstract Returns a count of the physical memory ranges available for a device.
* @discussion This method returns the count of physical memory ranges, each represented by an IODeviceMemory instance, that have been allocated for a memory mapped device.
* @result An integer count of the number of ranges available. */
virtual IOItemCount getDeviceMemoryCount( void );
/*! @function getDeviceMemoryWithIndex
* @abstract Returns an instance of IODeviceMemory representing one of a device's memory mapped ranges.
* @discussion This method returns a pointer to an instance of IODeviceMemory for the physical memory range at the given index for a memory mapped device.
* @param index An index into the array of ranges assigned to the device.
* @result A pointer to an instance of IODeviceMemory, or zero if the index is beyond the count available. The IODeviceMemory is retained by the provider, so is valid while attached, or while any mappings to it exist. It should not be released by the caller. See also @link mapDeviceMemoryWithIndex mapDeviceMemoryWithIndex@/link, which creates a device memory mapping. */
virtual IODeviceMemory * getDeviceMemoryWithIndex( unsigned int index );
/*! @function mapDeviceMemoryWithIndex
* @abstract Maps a physical range of a device.
* @discussion This method creates a mapping for the IODeviceMemory at the given index, with <code>IODeviceMemory::map(options)</code>. The mapping is represented by the returned instance of IOMemoryMap, which should not be released until the mapping is no longer required.
* @param index An index into the array of ranges assigned to the device.
* @result An instance of IOMemoryMap, or zero if the index is beyond the count available. The mapping should be released only when access to it is no longer required. */
virtual IOMemoryMap * mapDeviceMemoryWithIndex( unsigned int index,
IOOptionBits options = 0 );
/*! @function getDeviceMemory
* @abstract Returns the array of IODeviceMemory objects representing a device's memory mapped ranges.
* @discussion This method returns an array of IODeviceMemory objects representing the physical memory ranges allocated to a memory mapped device.
* @result An OSArray of IODeviceMemory objects, or zero if none are available. The array is retained by the provider, so is valid while attached. */
virtual OSArray * getDeviceMemory( void );
/*! @function setDeviceMemory
* @abstract Sets the array of IODeviceMemory objects representing a device's memory mapped ranges.
* @discussion This method sets an array of IODeviceMemory objects representing the physical memory ranges allocated to a memory mapped device.
* @param array An OSArray of IODeviceMemory objects, or zero if none are available. The array will be retained by the object. */
virtual void setDeviceMemory( OSArray * array );
/* Interrupt accessors */
/*! @function registerInterrupt
* @abstract Registers a C function interrupt handler for a device supplying interrupts.
* @discussion This method installs a C function interrupt handler to be called at primary interrupt time for a device's interrupt. Only one handler may be installed per interrupt source. IOInterruptEventSource provides a work loop based abstraction for interrupt delivery that may be more appropriate for work loop based drivers.
* @param source The index of the interrupt source in the device.
* @param target An object instance to be passed to the interrupt handler.
* @param handler The C function to be called at primary interrupt time when the interrupt occurs. The handler should process the interrupt by clearing the interrupt, or by disabling the source.
* @param refCon A reference constant for the handler's use.
* @result An IOReturn code.<br><code>kIOReturnNoInterrupt</code> is returned if the source is not valid; <code>kIOReturnNoResources</code> is returned if the interrupt already has an installed handler. */
virtual IOReturn registerInterrupt(int source, OSObject *target,
IOInterruptAction handler,
void *refCon = NULL);
#ifdef __BLOCKS__
/*! @function registerInterrupt
* @abstract Registers a block handler for a device supplying interrupts.
* @discussion This method installs a C function interrupt handler to be called at primary interrupt time for a device's interrupt. Only one handler may be installed per interrupt source. IOInterruptEventSource provides a work loop based abstraction for interrupt delivery that may be more appropriate for work loop based drivers.
* @param source The index of the interrupt source in the device.
* @param target An object instance to be passed to the interrupt handler.
* @param handler The block to be invoked at primary interrupt time when the interrupt occurs. The handler should process the interrupt by clearing the interrupt, or by disabling the source.
* @result An IOReturn code.<br><code>kIOReturnNoInterrupt</code> is returned if the source is not valid; <code>kIOReturnNoResources</code> is returned if the interrupt already has an installed handler. */
IOReturn registerInterruptBlock(int source, OSObject *target,
IOInterruptActionBlock handler);
#endif /* __BLOCKS__ */
/*! @function unregisterInterrupt
* @abstract Removes a C function interrupt handler for a device supplying hardware interrupts.
* @discussion This method removes a C function interrupt handler previously installed with @link registerInterrupt registerInterrupt@/link.
* @param source The index of the interrupt source in the device.
* @result An IOReturn code (<code>kIOReturnNoInterrupt</code> is returned if the source is not valid). */
virtual IOReturn unregisterInterrupt(int source);
/*! @function addInterruptStatistics
* @abstract Adds a statistics object to the IOService for the given interrupt.
* @discussion This method associates a set of statistics and a reporter for those statistics with an interrupt for this IOService, so that we can interrogate the IOService for statistics pertaining to that interrupt.
* @param statistics The IOInterruptAccountingData container we wish to associate the IOService with.
* @param source The index of the interrupt source in the device. */
IOReturn addInterruptStatistics(IOInterruptAccountingData * statistics, int source);
/*! @function removeInterruptStatistics
* @abstract Removes any statistics from the IOService for the given interrupt.
* @discussion This method disassociates any IOInterruptAccountingData container we may have for the given interrupt from the IOService; this indicates that the the interrupt target (at the moment, likely an IOInterruptEventSource) is being destroyed.
* @param source The index of the interrupt source in the device. */
IOReturn removeInterruptStatistics(int source);
/*! @function getInterruptType
* @abstract Returns the type of interrupt used for a device supplying hardware interrupts.
* @param source The index of the interrupt source in the device.
* @param interruptType The interrupt type for the interrupt source will be stored here by <code>getInterruptType</code>.<br> <code>kIOInterruptTypeEdge</code> will be returned for edge-trigggered sources.<br><code>kIOInterruptTypeLevel</code> will be returned for level-trigggered sources.
* @result An IOReturn code (<code>kIOReturnNoInterrupt</code> is returned if the source is not valid). */
virtual IOReturn getInterruptType(int source, int *interruptType);
/*! @function enableInterrupt
* @abstract Enables a device interrupt.
* @discussion It is the caller's responsiblity to keep track of the enable state of the interrupt source.
* @param source The index of the interrupt source in the device.
* @result An IOReturn code (<code>kIOReturnNoInterrupt</code> is returned if the source is not valid). */
virtual IOReturn enableInterrupt(int source);
/*! @function disableInterrupt
* @abstract Synchronously disables a device interrupt.
* @discussion If the interrupt routine is running, the call will block until the routine completes. It is the caller's responsiblity to keep track of the enable state of the interrupt source.
* @param source The index of the interrupt source in the device.
* @result An IOReturn code (<code>kIOReturnNoInterrupt</code> is returned if the source is not valid). */
virtual IOReturn disableInterrupt(int source);
/*! @function causeInterrupt
* @abstract Causes a device interrupt to occur.
* @discussion Emulates a hardware interrupt, to be called from task level.
* @param source The index of the interrupt source in the device.
* @result An IOReturn code (<code>kIOReturnNoInterrupt</code> is returned if the source is not valid). */
virtual IOReturn causeInterrupt(int source);
/*! @function requestProbe
* @abstract Requests that hardware be re-scanned for devices.
* @discussion For bus families that do not usually detect device addition or removal, this method represents an external request (eg. from a utility application) to rescan and publish or remove found devices.
* @param options Family defined options, not interpreted by IOService.
* @result An IOReturn code. */
virtual IOReturn requestProbe( IOOptionBits options );
/* Generic API for non-data-path upstream calls */
/*! @function message
* @abstract Receives a generic message delivered from an attached provider.
* @discussion A provider may deliver messages via the <code>message</code> method to its clients informing them of state changes, such as <code>kIOMessageServiceIsTerminated</code> or <code>kIOMessageServiceIsSuspended</code>. Certain messages are defined by the I/O Kit in <code>IOMessage.h</code> while others may be family dependent. This method is implemented in the client to receive messages.
* @param type A type defined in <code>IOMessage.h</code> or defined by the provider family.
* @param provider The provider from which the message originates.
* @param argument An argument defined by the provider family, not used by IOService.
* @result An IOReturn code defined by the message type. */
virtual IOReturn message( UInt32 type, IOService * provider,
void * argument = NULL );
/*! @function messageClient
* @abstract Sends a generic message to an attached client.
* @discussion A provider may deliver messages via the @link message message@/link method to its clients informing them of state changes, such as <code>kIOMessageServiceIsTerminated</code> or <code>kIOMessageServiceIsSuspended</code>. Certain messages are defined by the I/O Kit in <code>IOMessage.h</code> while others may be family dependent. This method may be called in the provider to send a message to the specified client, which may be useful for overrides.
* @param messageType A type defined in <code>IOMessage.h</code> or defined by the provider family.
* @param client A client of the IOService to send the message.
* @param messageArgument An argument defined by the provider family, not used by IOService.
* @param argSize Specifies the size of messageArgument, in bytes. If argSize is non-zero, messageArgument is treated as a pointer to argSize bytes of data. If argSize is 0 (the default), messageArgument is treated as an ordinal and passed by value.
* @result The return code from the client message call. */
virtual IOReturn messageClient( UInt32 messageType, OSObject * client,
void * messageArgument = NULL, vm_size_t argSize = 0 );
/*! @function messageClients
* @abstract Sends a generic message to all attached clients.
* @discussion A provider may deliver messages via the @link message message@/link method to its clients informing them of state changes, such as <code>kIOMessageServiceIsTerminated</code> or <code>kIOMessageServiceIsSuspended</code>. Certain messages are defined by the I/O Kit in <code>IOMessage.h</code> while others may be family dependent. This method may be called in the provider to send a message to all the attached clients, via the @link messageClient messageClient@/link method.
* @param type A type defined in <code>IOMessage.h</code> or defined by the provider family.
* @param argument An argument defined by the provider family, not used by IOService.
* @param argSize Specifies the size of argument, in bytes. If argSize is non-zero, argument is treated as a pointer to argSize bytes of data. If argSize is 0 (the default), argument is treated as an ordinal and passed by value.
* @result Any non-<code>kIOReturnSuccess</code> return codes returned by the clients, or <code>kIOReturnSuccess</code> if all return <code>kIOReturnSuccess</code>. */
virtual IOReturn messageClients( UInt32 type,
void * argument = NULL, vm_size_t argSize = 0 );
virtual OSPtr<IONotifier> registerInterest( const OSSymbol * typeOfInterest,
IOServiceInterestHandler handler,
void * target, void * ref = NULL );
#ifdef __BLOCKS__
OSPtr<IONotifier> registerInterest(const OSSymbol * typeOfInterest,
IOServiceInterestHandlerBlock handler);
#endif /* __BLOCKS__ */
virtual void applyToProviders( IOServiceApplierFunction applier,
void * context );
virtual void applyToClients( IOServiceApplierFunction applier,
void * context );
#ifdef __BLOCKS__
void applyToProviders(IOServiceApplierBlock applier);
void applyToClients(IOServiceApplierBlock applier);
#endif /* __BLOCKS__ */
virtual void applyToInterested( const OSSymbol * typeOfInterest,
OSObjectApplierFunction applier,
void * context );
virtual IOReturn acknowledgeNotification( IONotificationRef notification,
IOOptionBits response );
/* User client create */
/*! @function newUserClient
* @abstract Creates a connection for a non kernel client.
* @discussion A non kernel client may request a connection be opened via the @link //apple_ref/c/func/IOServiceOpen IOServiceOpen@/link library function, which will call this method in an IOService object. The rules and capabilities of user level clients are family dependent, and use the functions of the IOUserClient class for support. IOService's implementation returns <code>kIOReturnUnsupported</code>, so any family supporting user clients must implement this method.
* @param owningTask The Mach task of the client thread in the process of opening the user client. Note that in Mac OS X, each process is based on a Mach task and one or more Mach threads. For more information on the composition of a Mach task and its relationship with Mach threads, see {@linkdoc //apple_ref/doc/uid/TP30000905-CH209-TPXREF103 "Tasks and Threads"}.
* @param securityID A token representing the access level for the task.
* @param type A constant specifying the type of connection to be created, specified by the caller of @link //apple_ref/c/func/IOServiceOpen IOServiceOpen@/link and interpreted only by the family.
* @param handler An instance of an IOUserClient object to represent the connection, which will be released when the connection is closed, or zero if the connection was not opened.
* @param properties A dictionary of additional properties for the connection.
* @result A return code to be passed back to the caller of <code>IOServiceOpen</code>. */
virtual IOReturn newUserClient( task_t owningTask, void * securityID,
UInt32 type, OSDictionary * properties,
LIBKERN_RETURNS_RETAINED IOUserClient ** handler );
virtual IOReturn newUserClient( task_t owningTask, void * securityID,
UInt32 type,
LIBKERN_RETURNS_RETAINED IOUserClient ** handler );
IOReturn newUserClient( task_t owningTask, void * securityID,
UInt32 type, OSDictionary * properties,
OSSharedPtr<IOUserClient>& handler );
IOReturn newUserClient( task_t owningTask, void * securityID,
UInt32 type,
OSSharedPtr<IOUserClient>& handler );
/* Return code utilities */
/*! @function stringFromReturn
* @abstract Supplies a programmer-friendly string from an IOReturn code.
* @discussion Strings are available for the standard return codes in <code>IOReturn.h</code> in IOService, while subclasses may implement this method to interpret family dependent return codes.
* @param rtn The IOReturn code.
* @result A pointer to a constant string, or zero if the return code is unknown. */
virtual const char * stringFromReturn( IOReturn rtn );
/*! @function errnoFromReturn
* @abstract Translates an IOReturn code to a BSD <code>errno</code>.
* @discussion BSD defines its own return codes for its functions in <code>sys/errno.h</code>, and I/O Kit families may need to supply compliant results in BSD shims. Results are available for the standard return codes in <code>IOReturn.h</code> in IOService, while subclasses may implement this method to interpret family dependent return codes.
* @param rtn The IOReturn code.
* @result The BSD <code>errno</code> or <code>EIO</code> if unknown. */
virtual int errnoFromReturn( IOReturn rtn );
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* * * * * * * * * * end of IOService API * * * * * * * */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* for IOInterruptController implementors */
int _numInterruptSources;
IOInterruptSource *_interruptSources;
/* overrides */
virtual bool serializeProperties( OSSerialize * s ) const APPLE_KEXT_OVERRIDE;
IOReturn requireMaxBusStall(UInt32 ns);
IOReturn requireMaxInterruptDelay(uint32_t ns);
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* * * * * * * * * * * * Internals * * * * * * * * * * * */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * */
private:
APPLE_KEXT_COMPATIBILITY_VIRTUAL
bool checkResources( void );
APPLE_KEXT_COMPATIBILITY_VIRTUAL
bool checkResource( OSObject * matching );
APPLE_KEXT_COMPATIBILITY_VIRTUAL
void probeCandidates( LIBKERN_CONSUMED OSOrderedSet * matches );
APPLE_KEXT_COMPATIBILITY_VIRTUAL
bool startCandidate( IOService * candidate );
public:
APPLE_KEXT_COMPATIBILITY_VIRTUAL
IOService * getClientWithCategory( const OSSymbol * category )
APPLE_KEXT_DEPRECATED;
// copyClientWithCategory is the public replacement
private:
APPLE_KEXT_COMPATIBILITY_VIRTUAL
bool passiveMatch( OSDictionary * matching, bool changesOK = false);
APPLE_KEXT_COMPATIBILITY_VIRTUAL
void startMatching( IOOptionBits options = 0 );
APPLE_KEXT_COMPATIBILITY_VIRTUAL
void doServiceMatch( IOOptionBits options );
APPLE_KEXT_COMPATIBILITY_VIRTUAL
void doServiceTerminate( IOOptionBits options );
bool hasParent(IOService * root);
static void setRootMedia(IOService * root);
static void publishHiddenMedia(IOService * parent);
static bool publishHiddenMediaApplier(const OSObject * entry, void * context);
bool canTerminateForReplacement(IOService * client);
private:
bool matchPassive(OSDictionary * table, uint32_t options);
bool matchInternal(OSDictionary * table, uint32_t options, unsigned int * did);
static bool instanceMatch(const OSObject * entry, void * context);
static OSPtr<OSObject> copyExistingServices( OSDictionary * matching,
IOOptionBits inState, IOOptionBits options = 0 );
static OSPtr<IONotifier> setNotification(
const OSSymbol * type, OSDictionary * matching,
IOServiceMatchingNotificationHandler handler,
void * target, void * ref,
SInt32 priority = 0 );
static OSPtr<IONotifier> doInstallNotification(
const OSSymbol * type, OSDictionary * matching,
IOServiceMatchingNotificationHandler handler,
void * target, void * ref,
SInt32 priority, OSIterator ** existing );
static bool syncNotificationHandler( void * target, void * ref,
IOService * newService, IONotifier * notifier );
static void userServerCheckInTokenCancellationHandler(
IOUserServerCheckInToken * token,
void * ref);
APPLE_KEXT_COMPATIBILITY_VIRTUAL
void deliverNotification( const OSSymbol * type,
IOOptionBits orNewState, IOOptionBits andNewState );
OSPtr<OSArray> copyNotifiers(const OSSymbol * type,
IOOptionBits orNewState, IOOptionBits andNewState);
bool invokeNotifiers(OSArray * willSend[]);
bool invokeNotifier( class _IOServiceNotifier * notify );
APPLE_KEXT_COMPATIBILITY_VIRTUAL
void unregisterAllInterest( void );
APPLE_KEXT_COMPATIBILITY_VIRTUAL
IOReturn waitForState( UInt32 mask, UInt32 value,
mach_timespec_t * timeout = NULL );
IOReturn waitForState( UInt32 mask, UInt32 value, uint64_t timeout );
UInt32 _adjustBusy( SInt32 delta );
bool terminatePhase1( IOOptionBits options = 0 );
void scheduleTerminatePhase2( IOOptionBits options = 0 );
void scheduleStop( IOService * provider );
static void waitToBecomeTerminateThread( void );
static void __attribute__((__noreturn__)) terminateThread( void * arg, wait_result_t unused );
static void terminateWorker( IOOptionBits options );
static void actionWillTerminate( IOService * victim, IOOptionBits options,
OSArray * doPhase2List, bool, void * );
static void actionDidTerminate( IOService * victim, IOOptionBits options,
void *, void *, void *);
static void actionWillStop( IOService * victim, IOOptionBits options,
void *, void *, void *);
static void actionDidStop( IOService * victim, IOOptionBits options,
void *, void *, void *);
static void actionFinalize( IOService * victim, IOOptionBits options,
void *, void *, void *);
static void actionStop( IOService * client, IOService * provider,
void *, void *, void *);
APPLE_KEXT_COMPATIBILITY_VIRTUAL
IOReturn resolveInterrupt(IOService *nub, int source);
APPLE_KEXT_COMPATIBILITY_VIRTUAL
IOReturn lookupInterrupt(
int source, bool resolve,
LIBKERN_RETURNS_NOT_RETAINED IOInterruptController *
*interruptController);
/* power management */
public:
/*! @function PMinit
* @abstract Initializes power management for a driver.
* @discussion <code>PMinit</code> allocates and initializes the power management instance variables, and it should be called before accessing those variables or calling the power management methods. This method should be called inside the driver's <code>start</code> routine and must be paired with a call to @link PMstop PMstop@/link.
* Most calls to <code>PMinit</code> are followed by calls to @link joinPMtree joinPMtree@/link and @link registerPowerDriver registerPowerDriver@/link. */
virtual void PMinit( void );
/*! @function PMstop
* @abstract Stop power managing the driver.
* @discussion Removes the driver from the power plane and stop its power management. This method is synchronous against any power management method invocations (e.g. <code>setPowerState</code> or <code>setAggressiveness</code>), so when this method returns it is guaranteed those power management methods will not be entered. Driver should not call any power management methods after this call.
* Calling <code>PMstop</code> cleans up for the three power management initialization calls: @link PMinit PMinit@/link, @link joinPMtree joinPMtree@/link, and @link registerPowerDriver registerPowerDriver@/link. */
virtual void PMstop( void );
/*! @function joinPMtree
* @abstract Joins the driver into the power plane of the I/O Registry.
* @discussion A driver uses this method to call its nub when initializing (usually in its <code>start</code> routine after calling @link PMinit PMinit@/link), to be attached into the power management hierarchy (i.e., the power plane). A driver usually calls this method on the driver for the device that provides it power (this is frequently the nub).
* Before this call returns, the caller will probably be called at @link setPowerParent setPowerParent@/link and @link setAggressiveness setAggressiveness@/link and possibly at @link addPowerChild addPowerChild@/link as it is added to the hierarchy. This method may be overridden by a nub subclass.
* @param driver The driver to be added to the power plane, usually <code>this</code>. */
virtual void joinPMtree( IOService * driver );
/*! @function registerPowerDriver
* @abstract Registers a set of power states that the driver supports.
* @discussion A driver defines its array of supported power states with power management in its power management initialization (its <code>start</code> routine). If successful, power management will call the driver to instruct it to change its power state through @link setPowerState setPowerState@/link.
* Most drivers do not need to override <code>registerPowerDriver</code>. A nub may override <code>registerPowerDriver</code> if it needs to arrange its children in the power plane differently than the default placement, but this is uncommon.
* @param controllingDriver A pointer to the calling driver, usually <code>this</code>.
* @param powerStates A driver-defined array of power states that the driver and device support. Power states are defined in <code>pwr_mgt/IOPMpowerState.h</code>.
* @param numberOfStates The number of power states in the array.
* @result <code>IOPMNoErr</code>. All errors are logged via <code>kprintf</code>. */
virtual IOReturn registerPowerDriver(
IOService * controllingDriver,
IOPMPowerState * powerStates,
unsigned long numberOfStates );
/*! @function registerInterestedDriver
* @abstract Allows an IOService object to register interest in the changing power state of a power-managed IOService object.
* @discussion Call <code>registerInterestedDriver</code> on the IOService object you are interested in receiving power state messages from, and pass a pointer to the interested driver (<code>this</code>) as an argument.
* The interested driver is retained until the power interest is removed by calling <code>deRegisterInterestedDriver</code>.
* The interested driver should override @link powerStateWillChangeTo powerStateWillChangeTo@/link and @link powerStateDidChangeTo powerStateDidChangeTo@/link to receive these power change messages.
* Interested drivers must acknowledge power changes in <code>powerStateWillChangeTo</code> or <code>powerStateDidChangeTo</code>, either via return value or later calls to @link acknowledgePowerChange acknowledgePowerChange@/link.
* @param theDriver The driver of interest adds this pointer to the list of interested drivers. It informs drivers on this list before and after the power change.
* @result Flags describing the capability of the device in its current power state. If the current power state is not yet defined, zero is returned (this is the case when the driver is not yet in the power domain hierarchy or hasn't fully registered with power management yet). */
APPLE_KEXT_COMPATIBILITY_VIRTUAL
IOPMPowerFlags registerInterestedDriver( IOService * theDriver );
/*! @function deRegisterInterestedDriver
* @abstract De-registers power state interest from a previous call to <code>registerInterestedDriver</code>.
* @discussion The retain from <code>registerInterestedDriver</code> is released. This method is synchronous against any <code>powerStateWillChangeTo</code> or <code>powerStateDidChangeTo</code> call targeting the interested driver, so when this method returns it is guaranteed those interest handlers will not be entered.
* Most drivers do not need to override <code>deRegisterInterestedDriver</code>.
* @param theDriver The interested driver previously passed into @link registerInterestedDriver registerInterestedDriver@/link.
* @result A return code that can be ignored by the caller. */
APPLE_KEXT_COMPATIBILITY_VIRTUAL
IOReturn deRegisterInterestedDriver( IOService * theDriver );
/*! @function acknowledgePowerChange
* @abstract Acknowledges an in-progress power state change.
* @discussion When power management informs an interested object (via @link powerStateWillChangeTo powerStateWillChangeTo@/link or @link powerStateDidChangeTo powerStateDidChangeTo@/link), the object can return an immediate acknowledgement via a return code, or it may return an indication that it will acknowledge later by calling <code>acknowledgePowerChange</code>.
* Interested objects are those that have registered as interested drivers, as well as power plane children of the power changing driver. A driver that calls @link registerInterestedDriver registerInterestedDriver@/link must call <code>acknowledgePowerChange</code>, or use an immediate acknowledgement return from <code>powerStateWillChangeTo</code> or <code>powerStateDidChangeTo</code>.
* @param whichDriver A pointer to the calling driver. The called object tracks all interested parties to ensure that all have acknowledged the power state change.
* @result <code>IOPMNoErr</code>. */
APPLE_KEXT_COMPATIBILITY_VIRTUAL
IOReturn acknowledgePowerChange( IOService * whichDriver );
/*! @function acknowledgeSetPowerState
* @abstract Acknowledges the belated completion of a driver's <code>setPowerState</code> power state change.
* @discussion After power management instructs a driver to change its state via @link setPowerState setPowerState@/link, that driver must acknowledge the change when its device has completed its transition. The acknowledgement may be immediate, via a return code from <code>setPowerState</code>, or delayed, via this call to <code>acknowledgeSetPowerState</code>.
* Any driver that does not return <code>kIOPMAckImplied</code> from its <code>setPowerState</code> implementation must later call <code>acknowledgeSetPowerState</code>.
* @result <code>IOPMNoErr</code>. */
APPLE_KEXT_COMPATIBILITY_VIRTUAL
IOReturn acknowledgeSetPowerState( void );
/*! @function requestPowerDomainState
* @abstract Tells a driver to adjust its power state.
* @discussion This call is handled internally by power management. It is not intended to be overridden or called by drivers. */
virtual IOReturn requestPowerDomainState(
IOPMPowerFlags desiredState,
IOPowerConnection * whichChild,
unsigned long specificationFlags );
/*! @function makeUsable
* @abstract Requests that a device become usable.
* @discussion This method is called when some client of a device (or the device's own driver) is asking for the device to become usable. Power management responds by telling the object upon which this method is called to change to its highest power state.
* <code>makeUsable</code> is implemented using @link changePowerStateToPriv changePowerStateToPriv@/link. Subsequent requests for lower power, such as from <code>changePowerStateToPriv</code>, will pre-empt this request.
* @result A return code that can be ignored by the caller. */
APPLE_KEXT_COMPATIBILITY_VIRTUAL
IOReturn makeUsable( void );
/*! @function temporaryPowerClampOn
* @abstract A driver calls this method to hold itself in the highest power state until it has children.
* @discussion Use <code>temporaryPowerClampOn</code> to hold your driver in its highest power state while waiting for child devices to attach. After children have attached, the clamp is released and the device's power state is controlled by the children's requirements.
* @result A return code that can be ignored by the caller. */
APPLE_KEXT_COMPATIBILITY_VIRTUAL
IOReturn temporaryPowerClampOn( void );
/*! @function changePowerStateTo
* @abstract Sets a driver's power state.
* @discussion This function is one of several that are used to set a driver's power state. In most circumstances, however, you should call @link changePowerStateToPriv changePowerStateToPriv@/link instead.
* Calls to <code>changePowerStateTo</code>, <code>changePowerStateToPriv</code>, and a driver's power children all affect the power state of a driver. For legacy design reasons, they have overlapping functionality. Although you should call <code>changePowerStateToPriv</code> to change your device's power state, you might need to call <code>changePowerStateTo</code> in the following circumstances:
* <ul><li>If a driver will be using <code>changePowerStateToPriv</code> to change its power state, it should call <code>changePowerStateTo(0)</code> in its <code>start</code> routine to eliminate the influence <code>changePowerStateTo</code> has on power state calculations.
* <li>Call <code>changePowerStateTo</code> in conjunction with @link setIdleTimerPeriod setIdleTimerPeriod@/link and @link activityTickle activityTickle@/link to idle a driver into a low power state. For a driver with 3 power states, for example, <code>changePowerStateTo(1)</code> sets a minimum level of power state 1, such that the idle timer period may not set your device's power any lower than state 1.</ul>
* @param ordinal The number of the desired power state in the power state array.
* @result A return code that can be ignored by the caller. */
APPLE_KEXT_COMPATIBILITY_VIRTUAL
IOReturn changePowerStateTo( unsigned long ordinal );
/*! @function currentCapability
* @abstract Finds out the capability of a device's current power state.
* @result A copy of the <code>capabilityFlags</code> field for the current power state in the power state array. */
APPLE_KEXT_COMPATIBILITY_VIRTUAL
IOPMPowerFlags currentCapability( void );
/*! @function currentPowerConsumption
* @abstract Finds out the current power consumption of a device.
* @discussion Most Mac OS X power managed drivers do not report their power consumption via the <code>staticPower</code> field. Thus this call will not accurately reflect power consumption for most drivers.
* @result A copy of the <code>staticPower</code> field for the current power state in the power state array. */
APPLE_KEXT_COMPATIBILITY_VIRTUAL
unsigned long currentPowerConsumption( void );
/*! @function activityTickle
* @abstract Informs power management when a power-managed device is in use, so that power management can track when it is idle and adjust its power state accordingly.
* @discussion The <code>activityTickle</code> method is provided for objects in the system (or for the driver itself) to tell a driver that its device is being used.
* The IOService superclass can manage idleness determination with a simple idle timer mechanism and this <code>activityTickle</code> call. To start this up, the driver calls its superclass's <code>setIdleTimerPeriod</code>. This starts a timer for the time interval specified in the call. When the timer expires, the superclass checks to see if there has been any activity since the last timer expiration. (It checks to see if <code>activityTickle</code> has been called). If there has been activity, it restarts the timer, and this process continues. When the timer expires, and there has been no device activity, the superclass lowers the device power state to the next lower state. This can continue until the device is in state zero.
* After the device has been powered down by at least one power state, a subsequent call to <code>activityTickle</code> causes the device to be switched to a higher state required for the activity.
* If the driver is managing the idleness determination totally on its own, the value of the <code>type</code> parameter should be <code>kIOPMSubclassPolicy</code>, and the driver should override the <code>activityTickle</code> method. The superclass IOService implementation of <code>activityTickle</code> does nothing with the <code>kIOPMSubclassPolicy</code> argument.
* @param type When <code>type</code> is <code>kIOPMSubclassPolicy</code>, <code>activityTickle</code> is not handled in IOService and should be intercepted by the subclass. When <code>type</code> is <code>kIOPMSuperclassPolicy1</code>, an activity flag is set and the device state is checked. If the device has been powered down, it is powered up again.
* @param stateNumber When <code>type</code> is <code>kIOPMSuperclassPolicy1</code>, <code>stateNumber</code> contains the desired power state ordinal for the activity. If the device is in a lower state, the superclass will switch it to this state. This is for devices that can handle some accesses in lower power states; the device is powered up only as far as it needs to be for the activity.
* @result When <code>type</code> is <code>kIOPMSuperclassPolicy1</code>, the superclass returns <code>true</code> if the device is currently in the state specified by <code>stateNumber</code>. If the device is in a lower state and must be powered up, the superclass returns <code>false</code>; in this case the superclass will initiate a power change to power the device up. */
virtual bool activityTickle(
unsigned long type,
unsigned long stateNumber = 0 );
/*! @function setAggressiveness
* @abstract Broadcasts an aggressiveness factor from the parent of a driver to the driver.
* @discussion Implement <code>setAggressiveness</code> to receive a notification when an "aggressiveness Aggressiveness factors are a loose set of power management variables that contain values for system sleep timeout, display sleep timeout, whether the system is on battery or AC, and other power management features. There are several aggressiveness factors that can be broadcast and a driver may take action on whichever factors apply to it.
* A driver that has joined the power plane via @link joinPMtree joinPMtree@/link will receive <code>setAgressiveness</code> calls when aggressiveness factors change.
* A driver may override this call if it needs to do something with the new factor (such as change its idle timeout). If overridden, the driver must call its superclass's <code>setAgressiveness</code> method in its own <code>setAgressiveness</code> implementation.
* Most drivers do not need to implement <code>setAgressiveness</code>.
* @param type The aggressiveness factor type, such as <code>kPMMinutesToDim</code>, <code>kPMMinutesToSpinDown</code>, <code>kPMMinutesToSleep</code>, and <code>kPMPowerSource</code>. (Aggressiveness factors are defined in <code>pwr_mgt/IOPM.h</code>.)
* @param newLevel The aggressiveness factor's new value.
* @result <code>IOPMNoErr</code>. */
virtual IOReturn setAggressiveness(
unsigned long type,
unsigned long newLevel );
/*! @function getAggressiveness
* @abstract Returns the current aggressiveness value for the given type.
* @param type The aggressiveness factor to query.
* @param currentLevel Upon successful return, contains the value of aggressiveness factor <code>type</code>.
* @result <code>kIOReturnSuccess</code> upon success; an I/O Kit error code otherwise. */
virtual IOReturn getAggressiveness(
unsigned long type,
unsigned long * currentLevel );
#ifndef __LP64__
/*! @function systemWake
* @abstract Tells every driver in the power plane that the system is waking up.
* @discussion This call is handled internally by power management. It is not intended to be overridden or called by drivers. */
virtual IOReturn systemWake( void )
APPLE_KEXT_DEPRECATED;
/*! @function temperatureCriticalForZone
* @abstract Alerts a driver to a critical temperature in some thermal zone.
* @discussion This call is unused by power management. It is not intended to be called or overridden. */
virtual IOReturn temperatureCriticalForZone( IOService * whichZone )
APPLE_KEXT_DEPRECATED;
/*! @function youAreRoot
* @abstract Informs power management which IOService object is the power plane root.
* @discussion This call is handled internally by power management. It is not intended to be overridden or called by drivers. */
virtual IOReturn youAreRoot( void )
APPLE_KEXT_DEPRECATED;
/*! @function setPowerParent
* @abstract This call is handled internally by power management. It is not intended to be overridden or called by drivers. */
virtual IOReturn setPowerParent(
IOPowerConnection * parent,
bool stateKnown,
IOPMPowerFlags currentState )
APPLE_KEXT_DEPRECATED;
#endif /* !__LP64__ */
/*! @function addPowerChild
* @abstract Informs a driver that it has a new child.
* @discussion The Platform Expert uses this method to call a driver and introduce it to a new child. This call is handled internally by power management. It is not intended to be overridden or called by drivers.
* @param theChild A pointer to the child IOService object. */
virtual IOReturn addPowerChild( IOService * theChild );
/*! @function removePowerChild
* @abstract Informs a power managed driver that one of its power plane childen is disappearing.
* @discussion This call is handled internally by power management. It is not intended to be overridden or called by drivers. */
virtual IOReturn removePowerChild( IOPowerConnection * theChild );
#ifndef __LP64__
/*! @function command_received
* @discussion This call is handled internally by power management. It is not intended to be overridden or called by drivers. */
virtual void command_received( void *, void *, void *, void * );
#endif
/*! @function start_PM_idle_timer
* @discussion This call is handled internally by power management. It is not intended to be overridden or called by drivers. */
APPLE_KEXT_COMPATIBILITY_VIRTUAL
void start_PM_idle_timer( void );
#ifndef __LP64__
/*! @function PM_idle_timer_expiration
* @discussion This call is handled internally by power management. It is not intended to be overridden or called by drivers. */
virtual void PM_idle_timer_expiration( void )
APPLE_KEXT_DEPRECATED;
/*! @function PM_Clamp_Timer_Expired
* @discussion This call is handled internally by power management. It is not intended to be overridden or called by drivers. */
virtual void PM_Clamp_Timer_Expired( void )
APPLE_KEXT_DEPRECATED;
#endif
/*! @function setIdleTimerPeriod
* @abstract Sets or changes the idle timer period.
* @discussion A driver using the idleness determination provided by IOService calls its superclass with this method to set or change the idle timer period. See @link activityTickle activityTickle@/link for a description of this type of idleness determination.
* @param period The desired idle timer period in seconds.
* @result <code>kIOReturnSuccess</code> upon success; an I/O Kit error code otherwise. */
virtual IOReturn setIdleTimerPeriod( unsigned long period );
#ifndef __LP64__
/*! @function getPMworkloop
* @abstract Returns a pointer to the system-wide power management work loop.
* @availability Deprecated in Mac OS X version 10.6.
* @discussion Most drivers should create their own work loops to synchronize their code; drivers should not run arbitrary code on the power management work loop. */
virtual IOWorkLoop * getPMworkloop( void )
APPLE_KEXT_DEPRECATED;
#endif
/*! @function getPowerState
* @abstract Determines a device's power state.
* @discussion A device's "current power state" is updated at the end of each power state transition (e.g. transition from state 1 to state 0, or state 0 to state 2). This transition includes the time spent powering on or off any power plane children. Thus, if a child calls <code>getPowerState</code> on its power parent during system wake from sleep, the call will return the index to the device's off state rather than its on state.
* @result The current power state's index into the device's power state array. */
UInt32 getPowerState( void );
/*! @function setPowerState
* @abstract Requests a power managed driver to change the power state of its device.
* @discussion A power managed driver must override <code>setPowerState</code> to take part in system power management. After a driver is registered with power management, the system uses <code>setPowerState</code> to power the device off and on for system sleep and wake.
* Calls to @link PMinit PMinit@/link and @link registerPowerDriver registerPowerDriver@/link enable power management to change a device's power state using <code>setPowerState</code>. <code>setPowerState</code> is called in a clean and separate thread context.
* @param powerStateOrdinal The number in the power state array of the state the driver is being instructed to switch to.
* @param whatDevice A pointer to the power management object which registered to manage power for this device. In most cases, <code>whatDevice</code> will be equal to your driver's own <code>this</code> pointer.
* @result The driver must return <code>IOPMAckImplied</code> if it has complied with the request when it returns. Otherwise if it has started the process of changing power state but not finished it, the driver should return a number of microseconds which is an upper limit of the time it will need to finish. Then, when it has completed the power switch, it should call @link acknowledgeSetPowerState acknowledgeSetPowerState@/link. */
virtual IOReturn setPowerState(
unsigned long powerStateOrdinal,
IOService * whatDevice );
#ifndef __LP64__
/*! @function clampPowerOn
* @abstract Deprecated. Do not use. */
virtual void clampPowerOn( unsigned long duration );
#endif
/*! @function maxCapabilityForDomainState
* @abstract Determines a driver's highest power state possible for a given power domain state.
* @discussion This happens when the power domain is changing state and power management needs to determine which state the device is capable of in the new domain state.
* Most drivers do not need to implement this method, and can rely upon the default IOService implementation. The IOService implementation scans the power state array looking for the highest state whose <code>inputPowerRequirement</code> field exactly matches the value of the <code>domainState</code> parameter. If more intelligent determination is required, the driver itself should implement the method and override the superclass's implementation.
* @param domainState Flags that describe the character of "domain power"; they represent the <code>outputPowerCharacter</code> field of a state in the power domain's power state array.
* @result A state number. */
virtual unsigned long maxCapabilityForDomainState( IOPMPowerFlags domainState );
/*! @function initialPowerStateForDomainState
* @abstract Determines which power state a device is in, given the current power domain state.
* @discussion Power management calls this method once, when the driver is initializing power management.
* Most drivers do not need to implement this method, and can rely upon the default IOService implementation. The IOService implementation scans the power state array looking for the highest state whose <code>inputPowerRequirement</code> field exactly matches the value of the <code>domainState</code> parameter. If more intelligent determination is required, the power managed driver should implement the method and override the superclass's implementation.
* @param domainState Flags that describe the character of "domain power"; they represent the <code>outputPowerCharacter</code> field of a state in the power domain's power state array.
* @result A state number. */
virtual unsigned long initialPowerStateForDomainState( IOPMPowerFlags domainState );
/*! @function powerStateForDomainState
* @abstract Determines what power state the device would be in for a given power domain state.
* @discussion This call is unused by power management. Drivers should override <code>initialPowerStateForDomainState</code> and/or <code>maxCapabilityForDomainState</code> instead to change the default mapping of domain state to driver power state.
* @param domainState Flags that describe the character of "domain power"; they represent the <code>outputPowerCharacter</code> field of a state in the power domain's power state array.
* @result A state number. */
virtual unsigned long powerStateForDomainState( IOPMPowerFlags domainState );
/*! @function powerStateWillChangeTo
* @abstract Informs interested parties that a device is about to change its power state.
* @discussion Power management informs interested parties that a device is about to change to a different power state. Interested parties are those that have registered for this notification via @link registerInterestedDriver registerInterestedDriver@/link. If you have called <code>registerInterestedDriver</code> on a power managed driver, you must implement <code>powerStateWillChangeTo</code> and @link powerStateDidChangeTo powerStateDidChangeTo@/link to receive the notifications.
* <code>powerStateWillChangeTo</code> is called in a clean and separate thread context. <code>powerStateWillChangeTo</code> is called before a power state transition takes place; <code>powerStateDidChangeTo</code> is called after the transition has completed.
* @param capabilities Flags that describe the capability of the device in the new power state (they come from the <code>capabilityFlags</code> field of the new state in the power state array).
* @param stateNumber The number of the state in the state array that the device is switching to.
* @param whatDevice A pointer to the driver that is changing. It can be used by a driver that is receiving power state change notifications for multiple devices to distinguish between them.
* @result The driver returns <code>IOPMAckImplied</code> if it has prepared for the power change when it returns. If it has started preparing but not finished, it should return a number of microseconds which is an upper limit of the time it will need to finish preparing. Then, when it has completed its preparations, it should call @link acknowledgePowerChange acknowledgePowerChange@/link. */
virtual IOReturn powerStateWillChangeTo(
IOPMPowerFlags capabilities,
unsigned long stateNumber,
IOService * whatDevice );
/*! @function powerStateDidChangeTo
* @abstract Informs interested parties that a device has changed to a different power state.
* @discussion Power management informs interested parties that a device has changed to a different power state. Interested parties are those that have registered for this notification via @link registerInterestedDriver registerInterestedDriver@/link. If you have called <code>registerInterestedDriver</code> on a power managed driver, you must implemnt @link powerStateWillChangeTo powerStateWillChangeTo@/link and <code>powerStateDidChangeTo</code> to receive the notifications.
* <code>powerStateDidChangeTo</code> is called in a clean and separate thread context. <code>powerStateWillChangeTo</code> is called before a power state transition takes place; <code>powerStateDidChangeTo</code> is called after the transition has completed.
* @param capabilities Flags that describe the capability of the device in the new power state (they come from the <code>capabilityFlags</code> field of the new state in the power state array).
* @param stateNumber The number of the state in the state array that the device is switching to.
* @param whatDevice A pointer to the driver that is changing. It can be used by a driver that is receiving power state change notifications for multiple devices to distinguish between them.
* @result The driver returns <code>IOPMAckImplied</code> if it has prepared for the power change when it returns. If it has started preparing but not finished, it should return a number of microseconds which is an upper limit of the time it will need to finish preparing. Then, when it has completed its preparations, it should call @link acknowledgePowerChange acknowledgePowerChange@/link. */
virtual IOReturn powerStateDidChangeTo(
IOPMPowerFlags capabilities,
unsigned long stateNumber,
IOService * whatDevice );
#ifndef __LP64__
/*! @function didYouWakeSystem
* @abstract Asks a driver if its device is the one that just woke the system from sleep.
* @availability Deprecated in Mac OS X version 10.6.
* @discussion Power management calls a power managed driver with this method to ask if its device is the one that just woke the system from sleep. If a device is capable of waking the system from sleep, its driver should implement <code>didYouWakeSystem</code> and return <code>true</code> if its device was responsible for waking the system.
* @result <code>true</code> if the driver's device woke the system and <code>false</code> otherwise. */
virtual bool didYouWakeSystem( void )
APPLE_KEXT_DEPRECATED;
/*! @function newTemperature
* @abstract Tells a power managed driver that the temperature in the thermal zone has changed.
* @discussion This call is unused by power management. It is not intended to be called or overridden. */
virtual IOReturn newTemperature( long currentTemp, IOService * whichZone )
APPLE_KEXT_DEPRECATED;
#endif
virtual bool askChangeDown( unsigned long );
virtual bool tellChangeDown( unsigned long );
virtual void tellNoChangeDown( unsigned long );
virtual void tellChangeUp( unsigned long );
virtual IOReturn allowPowerChange( unsigned long refcon );
virtual IOReturn cancelPowerChange( unsigned long refcon );
protected:
/*! @function changePowerStateToPriv
* @abstract Tells a driver's superclass to change the power state of its device.
* @discussion A driver uses this method to tell its superclass to change the power state of the device. This is the recommended way to change the power state of a device.
* Three things affect driver power state: @link changePowerStateTo changePowerStateTo@/link, <code>changePowerStateToPriv</code>, and the desires of the driver's power plane children. Power management puts the device into the maximum state governed by those three entities.
* Drivers may eliminate the influence of the <code>changePowerStateTo</code> method on power state one of two ways. See @link powerOverrideOnPriv powerOverrideOnPriv@/link to ignore the method's influence, or call <code>changePowerStateTo(0)</code> in the driver's <code>start</code> routine to remove the <code>changePowerStateTo</code> method's power request.
* @param ordinal The number of the desired power state in the power state array.
* @result A return code that can be ignored by the caller. */
public:
IOReturn changePowerStateToPriv( unsigned long ordinal );
/*! @function powerOverrideOnPriv
* @abstract Allows a driver to ignore its children's power management requests and only use changePowerStateToPriv to define its own power state.
* @discussion Power management normally keeps a device at the highest state required by its requests via @link changePowerStateTo changePowerStateTo@/link, @link changePowerStateToPriv changePowerStateToPriv@/link, and its children. However, a driver may ensure a lower power state than otherwise required by itself and its children using <code>powerOverrideOnPriv</code>. When the override is on, power management keeps the device's power state in the state specified by <code>changePowerStateToPriv</code>. Turning on the override will initiate a power change if the driver's <code>changePowerStateToPriv</code> desired power state is different from the maximum of the <code>changePowerStateTo</code> desired power state and the children's desires.
* @result A return code that can be ignored by the caller. */
IOReturn powerOverrideOnPriv( void );
/*! @function powerOverrideOffPriv
* @abstract Allows a driver to disable a power override.
* @discussion When a driver has enabled an override via @link powerOverrideOnPriv powerOverrideOnPriv@/link, it can disable it again by calling this method in its superclass. Disabling the override reverts to the default algorithm for determining a device's power state. The superclass will now keep the device at the highest state required by <code>changePowerStateTo</code>, <code>changePowerStateToPriv</code>, and its children. Turning off the override will initiate a power change if the driver's desired power state is different from the maximum of the power managed driver's desire and the children's desires.
* @result A return code that can be ignored by the caller. */
IOReturn powerOverrideOffPriv( void );
/*! @function powerChangeDone
* @abstract Tells a driver when a power state change is complete.
* @discussion Power management uses this method to inform a driver when a power change is completely done, when all interested parties have acknowledged the @link powerStateDidChangeTo powerStateDidChangeTo@/link call. The default implementation of this method is null; the method is meant to be overridden by subclassed power managed drivers. A driver should use this method to find out if a power change it initiated is complete.
* @param stateNumber The number of the state in the state array that the device has switched from. */
virtual void powerChangeDone( unsigned long stateNumber );
};
#endif /* ! _IOKIT_IOSERVICE_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOKernelReportStructs.h | /*
* Copyright (c) 2012-2014 Apple Computer, Inc. All Rights Reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
// Internal data structures to be used by IOReporters and User Space Observers
#ifndef _IOKERNELREPORTSTRUCTS_H_
#define _IOKERNELREPORTSTRUCTS_H_
#include <stdint.h>
#include <IOKit/IOReportTypes.h>
#ifdef __cplusplus
extern "C" {
#endif
// Drivers participating in IOReporting can advertise channels by
// publishing properties in the I/O Kit registry. Various helper
// mechanisms exist to produce correctly-formatted legends.
// 12836893 tracks advertising channels in user space.
#define kIOReportLegendPublicKey "IOReportLegendPublic" // bool
#define kIOReportLegendKey "IOReportLegend" // arr
#define kIOReportLegendChannelsKey "IOReportChannels" // arr
#define kIOReportLegendGroupNameKey "IOReportGroupName" // str
#define kIOReportLegendSubGroupNameKey "IOReportSubGroupName" // str
#define kIOReportLegendInfoKey "IOReportChannelInfo" // dict
#define kIOReportLegendUnitKey "IOReportChannelUnit" // num
#define kIOReportLegendConfigKey "IOReportChannelConfig" // data
#define kIOReportLegendStateNamesKey "IOReportChannelStateNames" // str[]
// in an I/O Kit registry legend, a small "array struct" represents a channel
#define kIOReportChannelIDIdx 0 // required
#define kIOReportChannelTypeIdx 1 // required
#define kIOReportChannelNameIdx 2 // optional
/* Histogram Segment Configuration
* Currently supports 2 types of scaling to compute bucket upper bounds,
* linear or exponential.
* scale_flag = 0 -> linear scale
* 1 -> exponential scale
* upper_bound[n] = (scale_flag) ? pow(base,(n+1)) : base * (n+1);
*/
#define kIOHistogramScaleLinear 0
#define kIOHistogramScaleExponential 1
typedef struct {
uint32_t base_bucket_width;// segment[0].bucket[0] = [0, base_width]
uint32_t scale_flag; // bit 0 only in current use (see #defs)
uint32_t segment_idx; // for multiple segments histograms
uint32_t segment_bucket_count;// number of buckets in this segment
} __attribute((packed)) IOHistogramSegmentConfig;
// "normalized distribution"(FIXME?) internal format (unused?)
typedef struct {
uint64_t samples;
uint64_t mean;
uint64_t variance;
uint64_t reserved;
} __attribute((packed)) IONormDistReportValues;
#ifdef __cplusplus
}
#endif
#endif // _IOKERNELREPORTSTRUCTS_H_
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOBSD.h | /*
* Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _IOBSD_H
#define _IOBSD_H
/*
* bsd-related registry properties
*/
#define kIOBSDKey "IOBSD" // (BSD subsystem resource)
#define kIOBSDNameKey "BSD Name" // (an OSString)
#define kIOBSDNamesKey "BSD Names" // (an OSDictionary of OSString's, for links)
#define kIOBSDMajorKey "BSD Major" // (an OSNumber)
#define kIOBSDMinorKey "BSD Minor" // (an OSNumber)
#define kIOBSDUnitKey "BSD Unit" // (an OSNumber)
#endif /* !_IOBSD_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IODMAEventSource.h | /*
* Copyright (c) 2005 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _IOKIT_IODMAEVENTSOURCE_H
#define _IOKIT_IODMAEVENTSOURCE_H
#include <libkern/c++/OSPtr.h>
#include <IOKit/IOService.h>
#include <IOKit/IODMACommand.h>
#include <IOKit/IODMAController.h>
#include <IOKit/IOEventSource.h>
class IODMAController;
class IODMAEventSource : public IOEventSource
{
OSDeclareDefaultStructors(IODMAEventSource);
friend class IODMAController;
public:
typedef void (*Action)(OSObject *owner, IODMAEventSource *dmaES, IODMACommand *dmaCommand, IOReturn status, IOByteCount actualByteCount, AbsoluteTime timeStamp);
#define IODMAEventAction IODMAEventSource::Action
protected:
virtual void completeDMACommand(IODMACommand *dmaCommand);
virtual void notifyDMACommand(IODMACommand *dmaCommand, IOReturn status, IOByteCount actualByteCount, AbsoluteTime timeStamp);
public:
static OSPtr<IODMAEventSource> dmaEventSource(OSObject *owner,
IOService *provider,
Action completion = NULL,
Action notification = NULL,
UInt32 dmaIndex = 0);
virtual IOReturn startDMACommand(IODMACommand *dmaCommand, IODirection direction, IOByteCount byteCount = 0, IOByteCount byteOffset = 0);
virtual IOReturn stopDMACommand(bool flush = false, uint64_t timeout = UINT64_MAX);
virtual IOReturn queryDMACommand(IODMACommand **dmaCommand, IOByteCount *transferCount, bool waitForIdle = false);
virtual IOByteCount getFIFODepth(IODirection direction = kIODirectionNone);
virtual IOReturn setFIFODepth(IOByteCount depth);
virtual IOByteCount validFIFODepth(IOByteCount depth, IODirection direction);
virtual IOReturn setFrameSize(UInt8 byteCount);
virtual IOReturn setDMAConfig(UInt32 dmaIndex);
virtual bool validDMAConfig(UInt32 dmaIndex);
private:
IOService *dmaProvider;
OSPtr<IODMAController> dmaController;
UInt32 dmaIndex;
queue_head_t dmaCommandsCompleted;
IOSimpleLock *dmaCommandsCompletedLock;
Action dmaCompletionAction;
Action dmaNotificationAction;
bool dmaSynchBusy;
virtual bool init(OSObject *owner,
IOService *provider,
Action completion = NULL,
Action notification = NULL,
UInt32 dmaIndex = 0);
virtual bool checkForWork(void) APPLE_KEXT_OVERRIDE;
virtual void free(void) APPLE_KEXT_OVERRIDE;
};
#endif /* _IOKIT_IODMAEVENTSOURCE_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOKitDebug.h | /*
* Copyright (c) 1998-2019 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _IOKIT_IOKITDEBUG_H
#define _IOKIT_IOKITDEBUG_H
#include <IOKit/IOTypes.h>
#ifdef __cplusplus
#include <libkern/c++/OSObject.h>
#include <libkern/c++/OSDictionary.h>
#include <libkern/c++/OSSerialize.h>
class IOKitDiagnostics : public OSObject
{
OSDeclareDefaultStructors(IOKitDiagnostics);
public:
static OSObject * diagnostics( void );
virtual bool serialize(OSSerialize *s) const APPLE_KEXT_OVERRIDE;
private:
static void updateOffset( OSDictionary * dict,
UInt64 value, const char * name );
};
#endif /* __cplusplus */
enum {
// loggage
kIOLogAttach = 0x00000001ULL,
kIOLogProbe = 0x00000002ULL,
kIOLogStart = 0x00000004ULL,
kIOLogRegister = 0x00000008ULL,
kIOLogMatch = 0x00000010ULL,
kIOLogConfig = 0x00000020ULL,
kIOLogYield = 0x00000040ULL,
kIOLogPower = 0x00000080ULL,
kIOLogMapping = 0x00000100ULL,
kIOLogCatalogue = 0x00000200ULL,
kIOLogTracePower = 0x00000400ULL, // Obsolete: Use iotrace=0x00000400ULL to enable now
kIOLogDebugPower = 0x00000800ULL,
kIOLogServiceTree = 0x00001000ULL,
kIOLogDTree = 0x00002000ULL,
kIOLogMemory = 0x00004000ULL,
kIOLogKextMemory = 0x00008000ULL,
kOSLogRegistryMods = 0x00010000ULL,// Log attempts to modify registry collections
kIOLogPMRootDomain = 0x00020000ULL,
kOSRegistryModsMode = 0x00040000ULL,// Change default registry modification handling - panic vs. log
// kIOTraceIOService = 0x00080000ULL, // Obsolete: Use iotrace=0x00080000ULL to enable now
kIOLogHibernate = 0x00100000ULL,
kIOStatistics = 0x04000000ULL,
kIOSleepWakeWdogOff = 0x40000000ULL,
kIOKextSpinDump = 0x80000000ULL,
// debug aids - change behaviour
kIONoFreeObjects = 0x00100000ULL,
// kIOLogSynchronous = 0x00200000ULL, // IOLog completes synchronously -- obsolete
kIOTracking = 0x00400000ULL,
kIOWaitQuietPanics = 0x00800000ULL,
kIOWaitQuietBeforeRoot = 0x01000000ULL,
kIOTrackingBoot = 0x02000000ULL,
_kIODebugTopFlag = 0x8000000000000000ULL// force enum to be 64 bits
};
enum {
kIOKitDebugUserOptions = 0
| kIOLogAttach
| kIOLogProbe
| kIOLogStart
| kIOLogRegister
| kIOLogMatch
| kIOLogConfig
| kIOLogYield
| kIOLogPower
| kIOLogMapping
| kIOLogCatalogue
| kIOLogTracePower
| kIOLogDebugPower
| kOSLogRegistryMods
| kIOLogPMRootDomain
| kOSRegistryModsMode
| kIOLogHibernate
| kIOSleepWakeWdogOff
| kIOKextSpinDump
| kIOWaitQuietPanics
};
enum {
kIOTraceInterrupts = 0x00000001ULL, // Trace primary interrupts
kIOTraceWorkLoops = 0x00000002ULL, // Trace workloop activity
kIOTraceEventSources = 0x00000004ULL, // Trace non-passive event sources
kIOTraceIntEventSource = 0x00000008ULL, // Trace IOIES and IOFIES sources
kIOTraceCommandGates = 0x00000010ULL, // Trace command gate activity
kIOTraceTimers = 0x00000020ULL, // Trace timer event source activity
kIOTracePowerMgmt = 0x00000400ULL, // Trace power management changes
kIOTraceIOService = 0x00080000ULL, // registerService/termination
kIOTraceCompatBootArgs = kIOTraceIOService | kIOTracePowerMgmt
};
enum {
kIODKEnable = 0x00000001ULL,
kIODKLogSetup = 0x00000002ULL,
kIODKLogIPC = 0x00000004ULL,
kIODKLogPM = 0x00000008ULL,
kIODKLogMessages = 0x00000010ULL,
kIODKDisablePM = 0x000000100ULL,
kIODKDisableDextLaunch = 0x00001000ULL,
kIODKDisableDextTag = 0x00002000ULL,
kIODKDisableCDHashChecking = 0x00004000ULL,
kIODKDisableEntitlementChecking = 0x00008000ULL,
kIODKDisableCheckInTokenVerification = 0x00010000ULL,
};
extern SInt64 gIOKitDebug;
extern SInt64 gIOKitTrace;
extern SInt64 gIODKDebug;
#ifdef __cplusplus
typedef kern_return_t (*IOCoreAnalyticsSendEventProc)(
uint64_t options,
OSString * eventName,
OSDictionary * eventPayload);
#endif /* __cplusplus */
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
class IORegistryPlane;
#endif
extern void IOPrintPlane(
#ifdef __cplusplus
const IORegistryPlane * plane
#else
const struct IORegistryPlane * plane
#endif
);
#ifndef _OSCPPDEBUG_H
extern void OSPrintMemory( void );
#endif
#define IOPrintMemory OSPrintMemory
#if defined(KERNEL) && defined(__cplusplus)
kern_return_t
IOSetCoreAnalyticsSendEventProc(IOCoreAnalyticsSendEventProc proc);
#endif /* defined(KERNEL) && defined(__cplusplus) */
#define kIOKitDiagnosticsClientClassName "IOKitDiagnosticsClient"
enum{
kIOKitDiagnosticsClientType = 0x99000002
};
struct IOKitDiagnosticsParameters {
size_t size;
uint64_t value;
uint32_t options;
uint32_t tag;
uint32_t zsize;
uint32_t reserved[8];
};
typedef struct IOKitDiagnosticsParameters IOKitDiagnosticsParameters;
enum{
kIOTrackingCallSiteBTs = 16,
};
struct IOTrackingCallSiteInfo {
uint32_t count;
pid_t addressPID;
mach_vm_address_t address;
mach_vm_size_t size[2];
pid_t btPID;
mach_vm_address_t bt[2][kIOTrackingCallSiteBTs];
};
#define kIOMallocTrackingName "IOMalloc"
#define kIOWireTrackingName "IOWire"
#define kIOMapTrackingName "IOMap"
enum{
kIOTrackingExcludeNames = 0x00000001,
};
enum{
kIOTrackingGetTracking = 0x00000001,
kIOTrackingGetMappings = 0x00000002,
kIOTrackingResetTracking = 0x00000003,
kIOTrackingStartCapture = 0x00000004,
kIOTrackingStopCapture = 0x00000005,
kIOTrackingSetMinCaptureSize = 0x00000006,
kIOTrackingLeaks = 0x00000007,
kIOTrackingInvalid = 0xFFFFFFFE,
};
#ifdef __cplusplus
} /* extern "C" */
#endif /* __cplusplus */
#endif /* ! _IOKIT_IOKITDEBUG_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IODataQueue.h | /*
* Copyright (c) 1998-2019 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _IOKIT_IODATAQUEUE_H
#define _IOKIT_IODATAQUEUE_H
#ifndef DISABLE_DATAQUEUE_WARNING
#warning "IODataQueue is deprecated due to security issues in its interfaces, please use IOSharedDataQueue instead"
#endif
#include <libkern/c++/OSPtr.h>
#include <libkern/c++/OSObject.h>
#include <libkern/OSTypes.h>
#include <mach/port.h>
#include <mach/message.h>
typedef struct _IODataQueueMemory IODataQueueMemory;
class IOMemoryDescriptor;
struct _notifyMsg {
mach_msg_header_t h;
};
#ifdef dequeue
#undef dequeue
#endif
#ifdef enqueue
#undef enqueue
#endif
/*!
* @class IODataQueue : public OSObject
* @abstract A generic queue designed to pass data from the kernel to a user process.
* @discussion The IODataQueue class is designed to allow kernel code to queue data to a user process. IODataQueue objects are designed to be used in a single producer / single consumer situation. As such, there are no locks on the data itself. Because the kernel enqueue and user-space dequeue methods follow a strict set of guidelines, no locks are necessary to maintain the integrity of the data struct.
*
* <br>Each data entry can be variable sized, but the entire size of the queue data region (including overhead for each entry) must be specified up front.
*
* <br>In order for the IODataQueue instance to notify the user process that data is available, a notification mach port must be set. When the queue is empty and a new entry is added, a message is sent to the specified port.
*
* <br>User client code exists in the IOKit framework that facilitates the creation of the receive notification port as well as the listen process for new data available notifications.
*
* <br>In order to make the data queue memory available to a user process, the method getMemoryDescriptor() must be used to get an IOMemoryDescriptor instance that can be mapped into a user process. Typically, the clientMemoryForType() method on an IOUserClient instance will be used to request the IOMemoryDescriptor and then return it to be mapped into the user process.
*/
#ifndef DISABLE_DATAQUEUE_WARNING
class __attribute__((deprecated)) IODataQueue: public OSObject
#else
class IODataQueue : public OSObject
#endif
{
OSDeclareDefaultStructors(IODataQueue);
protected:
IODataQueueMemory * dataQueue;
void * notifyMsg;
virtual void free() APPLE_KEXT_OVERRIDE;
/*!
* @function sendDataAvailableNotification
* @abstract Sends a dataAvailableNotification message to the specified mach port.
* @discussion This method sends a message to the mach port passed to setNotificationPort(). It is used to indicate that data is available in the queue.
*/
virtual void sendDataAvailableNotification();
public:
/*!
* @function withCapacity
* @abstract Static method that creates a new IODataQueue instance with the capacity specified in the size parameter.
* @discussion The actual size of the entire data queue memory region (to be shared into a user process) is equal to the capacity plus the IODataQueueMemory overhead. This overhead value can be determined from the DATA_QUEUE_MEMORY_HEADER_SIZE macro in <IOKit/IODataQueueShared.h>. The size of the data queue memory region must include space for the overhead of each IODataQueueEntry. This entry overhead can be determined from the DATA_QUEUE_ENTRY_HEADER_SIZE macro in <IOKit/IODataQueueShared.h>.<br> This method allocates a new IODataQueue instance and then calls initWithCapacity() with the given size parameter. If the initWithCapacity() fails, the new instance is released and zero is returned.
* @param size The size of the data queue memory region.
* @result Returns the newly allocated IODataQueue instance. Zero is returned on failure.
*/
static OSPtr<IODataQueue> withCapacity(UInt32 size);
/*!
* @function withEntries
* @abstract Static method that creates a new IODataQueue instance with the specified number of entries of the given size.
* @discussion This method will create a new IODataQueue instance with enough capacity for numEntries of entrySize. It does account for the IODataQueueEntry overhead for each entry. Note that the numEntries and entrySize are simply used to determine the data region size. They do not actually restrict the size of number of entries that can be added to the queue.<br> This method allocates a new IODataQueue instance and then calls initWithEntries() with the given numEntries and entrySize parameters. If the initWithEntries() fails, the new instance is released and zero is returned.
* @param numEntries Number of entries to allocate space for.
* @param entrySize Size of each entry.
* @result Returns the newly allocated IODataQueue instance. Zero is returned on failure.
*/
static OSPtr<IODataQueue> withEntries(UInt32 numEntries, UInt32 entrySize);
/*!
* @function initWithCapacity
* @abstract Initializes an IODataQueue instance with the capacity specified in the size parameter.
* @discussion The actual size of the entire data queue memory region (to be shared into a user process) is equal to the capacity plus the IODataQueueMemory overhead. This overhead value can be determined from the DATA_QUEUE_MEMORY_HEADER_SIZE macro in <IOKit/IODataQueueShared.h>. The size of the data queue memory region must include space for the overhead of each IODataQueueEntry. This entry overhead can be determined from the DATA_QUEUE_ENTRY_HEADER_SIZE macro in <IOKit/IODataQueueShared.h>.
* @param size The size of the data queue memory region.
* @result Returns true on success and false on failure.
*/
virtual Boolean initWithCapacity(UInt32 size);
/*!
* @function initWithEntries
* @abstract Initializes an IODataQueue instance with the specified number of entries of the given size.
* @discussion This method will initialize an IODataQueue instance with enough capacity for numEntries of entrySize. It does account for the IODataQueueEntry overhead for each entry. Note that the numEntries and entrySize are simply used to determine the data region size. They do not actually restrict the size of number of entries that can be added to the queue.<br> This method allocates a new IODataQueue instance and then calls initWithEntries() with the given numEntries and entrySize parameters.
* @param numEntries Number of entries to allocate space for.
* @param entrySize Size of each entry.
* @result Returns true on success and false on failure.
*/
virtual Boolean initWithEntries(UInt32 numEntries, UInt32 entrySize);
/*!
* @function enqueue
* @abstract Enqueues a new entry on the queue.
* @discussion This method adds a new data entry of dataSize to the queue. It sets the size parameter of the entry pointed to by the tail value and copies the memory pointed to by the data parameter in place in the queue. Once that is done, it moves the tail to the next available location. When attempting to add a new entry towards the end of the queue and there isn't enough space at the end, it wraps back to the beginning.<br> If the queue is empty when a new entry is added, sendDataAvailableNotification() is called to send a message to the user process that data is now available.
* @param data Pointer to the data to be added to the queue.
* @param dataSize Size of the data pointed to by data.
* @result Returns true on success and false on failure. Typically failure means that the queue is full.
*/
virtual Boolean enqueue(void *data, UInt32 dataSize);
/*!
* @function setNotificationPort
* @abstract Creates a simple mach message targeting the mach port specified in port.
* @discussion This message is sent when data is added to an empty queue. It is to notify a user process that new data has become available.
* @param port The mach port to target with the notification message.
*/
virtual void setNotificationPort(mach_port_t port);
/*!
* @function getMemoryDescriptor
* @abstract Returns a memory descriptor covering the IODataQueueMemory region.
* @discussion The IOMemoryDescriptor instance returned by this method is intended to be mapped into a user process. This is the memory region that the IODataQueueClient code operates on.
* @result Returns a newly allocated IOMemoryDescriptor for the IODataQueueMemory region. Returns zero on failure.
*/
virtual OSPtr<IOMemoryDescriptor> getMemoryDescriptor();
};
#endif /* _IOKIT_IODATAQUEUE_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOSubMemoryDescriptor.h | /*
* Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _IOSUBMEMORYDESCRIPTOR_H
#define _IOSUBMEMORYDESCRIPTOR_H
#include <IOKit/IOMemoryDescriptor.h>
#include <libkern/c++/OSPtr.h>
/*! @class IOSubMemoryDescriptor : public IOMemoryDescriptor
* @abstract The IOSubMemoryDescriptor object describes a memory area made up of a portion of another IOMemoryDescriptor.
* @discussion The IOSubMemoryDescriptor object represents a subrange of memory, specified as a portion of another IOMemoryDescriptor. */
class IOSubMemoryDescriptor : public IOMemoryDescriptor
{
OSDeclareDefaultStructors(IOSubMemoryDescriptor);
protected:
IOMemoryDescriptor * _parent;
IOByteCount _start;
virtual void free() APPLE_KEXT_OVERRIDE;
public:
/*! @function withSubRange
* @abstract Create an IOMemoryDescriptor to describe a subrange of an existing descriptor.
* @discussion This method creates and initializes an IOMemoryDescriptor for memory consisting of a subrange of the specified memory descriptor. The parent memory descriptor is retained by the new descriptor.
* @param of The parent IOMemoryDescriptor of which a subrange is to be used for the new descriptor, which will be retained by the subrange IOMemoryDescriptor.
* @param offset A byte offset into the parent memory descriptor's memory.
* @param length The length of the subrange.
* @param options
* kIOMemoryDirectionMask (options:direction) This nibble indicates the I/O direction to be associated with the descriptor, which may affect the operation of the prepare and complete methods on some architectures.
* @result The created IOMemoryDescriptor on success, to be released by the caller, or zero on failure. */
static OSPtr<IOSubMemoryDescriptor> withSubRange(IOMemoryDescriptor *of,
IOByteCount offset,
IOByteCount length,
IOOptionBits options);
/*
* Initialize or reinitialize an IOSubMemoryDescriptor to describe
* a subrange of an existing descriptor.
*
* An IOSubMemoryDescriptor can be re-used by calling initSubRange
* again on an existing instance -- note that this behavior is not
* commonly supported in other IOKit classes, although it is here.
*/
virtual bool initSubRange( IOMemoryDescriptor * parent,
IOByteCount offset, IOByteCount length,
IODirection withDirection );
/*
* IOMemoryDescriptor required methods
*/
virtual addr64_t getPhysicalSegment( IOByteCount offset,
IOByteCount * length,
IOOptionBits options = 0 ) APPLE_KEXT_OVERRIDE;
virtual IOReturn prepare(IODirection forDirection = kIODirectionNone) APPLE_KEXT_OVERRIDE;
virtual IOReturn complete(IODirection forDirection = kIODirectionNone) APPLE_KEXT_OVERRIDE;
#ifdef __LP64__
virtual IOReturn redirect( task_t safeTask, bool redirect ) APPLE_KEXT_OVERRIDE;
#else
IOReturn redirect( task_t safeTask, bool redirect );
#endif /* __LP64__ */
virtual IOReturn setPurgeable( IOOptionBits newState,
IOOptionBits * oldState ) APPLE_KEXT_OVERRIDE;
IOReturn setOwnership( task_t newOwner,
int newLedgerTag,
IOOptionBits newLedgerOptions );
// support map() on kIOMemoryTypeVirtual without prepare()
virtual IOMemoryMap * makeMapping(
IOMemoryDescriptor * owner,
task_t intoTask,
IOVirtualAddress atAddress,
IOOptionBits options,
IOByteCount offset,
IOByteCount length ) APPLE_KEXT_OVERRIDE;
virtual uint64_t getPreparationID( void ) APPLE_KEXT_OVERRIDE;
/*! @function getPageCounts
* @abstract Retrieve the number of resident and/or dirty pages encompassed by an IOMemoryDescriptor.
* @discussion This method returns the number of resident and/or dirty pages encompassed by an IOMemoryDescriptor.
* @param residentPageCount - If non-null, a pointer to a byte count that will return the number of resident pages encompassed by this IOMemoryDescriptor.
* @param dirtyPageCount - If non-null, a pointer to a byte count that will return the number of dirty pages encompassed by this IOMemoryDescriptor.
* @result An IOReturn code. */
IOReturn getPageCounts(IOByteCount * residentPageCount,
IOByteCount * dirtyPageCount);
};
#endif /* !_IOSUBMEMORYDESCRIPTOR_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOMemoryCursor.h | /*
* Copyright (c) 1998-2019 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _IOMEMORYCURSOR_H
#define _IOMEMORYCURSOR_H
#include <libkern/c++/OSObject.h>
#include <libkern/c++/OSPtr.h>
#include <IOKit/IOTypes.h>
class IOMemoryDescriptor;
/**************************** class IOMemoryCursor ***************************/
/*!
* @class IOMemoryCursor
* @abstract A mechanism to convert memory references to physical addresses.
* @discussion The IOMemoryCursor declares the super class that all
* specific memory cursors must inherit from, but a memory cursor can be created without a specific format subclass by just providing a segment function to the initializers. This class does the difficult stuff of dividing a memory descriptor into a physical scatter/gather list appropriate for the target hardware.
* <br><br>
* A driver is expected to create a memory cursor and configure it to the limitations of its DMA hardware; for instance the memory cursor used by the FireWire SBP-2 protocol has a maximum physical segment size of 2^16 - 1 but the actual transfer size is unlimited. Thus it would create a cursor with a maxSegmentSize of 65535 and a maxTransfer size of UINT_MAX. It would also provide a SegmentFunction that can output a pagelist entry.
* <br><br>
* Below is the simplest example of a SegmentFunction:<br>
* void IONaturalMemoryCursor::outputSegment(PhysicalSegment segment,<br>
* void * outSegments,<br>
* UInt32 outSegmentIndex)<br>
* {<br>
* ((PhysicalSegment *) outSegments)[outSegmentIndex] = segment;<br>
* }
*
*/
class IOMemoryCursor : public OSObject
{
OSDeclareDefaultStructors(IOMemoryCursor);
public:
/*!
* @typedef PhysicalSegment
* @discussion A physical address/length pair.
*/
struct PhysicalSegment {
IOPhysicalAddress location;
IOPhysicalLength length;
};
/*! @defined IOPhysicalSegment
* @discussion Backward compatibility define for the old non-class scoped type definition. See IOMemoryCursor::PhysicalSegment
*/
#define IOPhysicalSegment IOMemoryCursor::PhysicalSegment
/*!
* @typedef SegmentFunction
* @discussion Pointer to a C function that outputs a single physical segment to an element in the array as defined by the segments and segmentIndex parameters.
* @param segment The physical address and length that is next to be output.
* @param segments Base of the output vector of DMA address length pairs.
* @param segmentIndex Index to output 'segment' in the 'segments' array.
*/
typedef void (*SegmentFunction)(PhysicalSegment segment,
void * segments,
UInt32 segmentIndex);
/*! @defined OutputSegmentFunc
* @discussion Backward compatibility define for the old non-class scoped type definition. See IOMemoryCursor::SegmentFunction */
#define OutputSegmentFunc IOMemoryCursor::SegmentFunction
protected:
/*! @var outSeg The action method called when an event has been delivered */
SegmentFunction outSeg;
/*! @var maxSegmentSize Maximum size of one segment in a scatter/gather list */
IOPhysicalLength maxSegmentSize;
/*! @var maxTransferSize
* Maximum size of a transfer that this memory cursor is allowed to generate */
IOPhysicalLength maxTransferSize;
/*! @var alignMask
* Currently unused. Reserved for automated aligment restriction code. */
IOPhysicalLength alignMask;
public:
/*! @function withSpecification
* @abstract Creates and initializes an IOMemoryCursor in one operation.
* @discussion Factory function to create and initialize an IOMemoryCursor in one operation. For more information, see IOMemoryCursor::initWithSpecification.
* @param outSegFunc SegmentFunction to call to output one physical segment.
* @param maxSegmentSize Maximum allowable size for one segment. Defaults to 0.
* @param maxTransferSize Maximum size of an entire transfer. Defaults to 0 indicating no maximum.
* @param alignment Alignment restrictions on output physical addresses. Not currently implemented. Defaults to single byte alignment.
* @result Returns a new memory cursor if successfully created and initialized, 0 otherwise.
*/
static OSPtr<IOMemoryCursor>
withSpecification(SegmentFunction outSegFunc,
IOPhysicalLength maxSegmentSize = 0,
IOPhysicalLength maxTransferSize = 0,
IOPhysicalLength alignment = 1);
/*! @function initWithSpecification
* @abstract Primary initializer for the IOMemoryCursor class.
* @param outSegFunc SegmentFunction to call to output one physical segment.
* @param maxSegmentSize Maximum allowable size for one segment. Defaults to 0.
* @param maxTransferSize Maximum size of an entire transfer. Defaults to 0 indicating no maximum.
* @param alignment Alignment restrictions on output physical addresses. Not currently implemented. Defaults to single byte alignment.
* @result Returns true if the inherited classes and this instance initialize
* successfully.
*/
virtual bool initWithSpecification(SegmentFunction outSegFunc,
IOPhysicalLength maxSegmentSize = 0,
IOPhysicalLength maxTransferSize = 0,
IOPhysicalLength alignment = 1);
/*! @function genPhysicalSegments
* @abstract Generates a physical scatter/gather list given a memory descriptor.
* @discussion Generates a list of physical segments from the given memory descriptor, relative to the current position of the descriptor.
* @param descriptor IOMemoryDescriptor that describes the data associated with an I/O request.
* @param fromPosition Starting location of the I/O within a memory descriptor.
* @param segments Void pointer to base of output physical scatter/gather list. Always passed directly onto the SegmentFunction without interpretation by the cursor.
* @param maxSegments Maximum number of segments that can be written to segments array.
* @param maxTransferSize Maximum transfer size is limited to that many bytes, otherwise it defaults to the maximum transfer size specified when the memory cursor was initialized.
* @param transferSize Pointer to an IOByteCount variable that can contain the total size of the transfer being described. Defaults to 0 indicating that no transfer size need be returned.
* @result If the descriptor is exhausted of memory, a zero is returned, otherwise the number of segments that were filled in is returned.
*/
virtual UInt32 genPhysicalSegments(
IOMemoryDescriptor *descriptor,
IOByteCount fromPosition,
void * segments,
UInt32 maxSegments,
UInt32 maxTransferSize = 0,
IOByteCount *transferSize = NULL);
};
/************************ class IONaturalMemoryCursor ************************/
/*!
* @class IONaturalMemoryCursor
* @abstract An IOMemoryCursor subclass that outputs a vector of PhysicalSegments in the natural byte orientation for the CPU.
* @discussion The IONaturalMemoryCursor would be used when it is too difficult to safely describe a SegmentFunction that is more appropriate for your hardware. This cursor just outputs an array of PhysicalSegments.
*/
class IONaturalMemoryCursor : public IOMemoryCursor
{
OSDeclareDefaultStructors(IONaturalMemoryCursor);
public:
/*! @function outputSegment
* @abstract Outputs the given segment into the output segments array in natural byte order.
* @param segment The physical address and length that is next to be output.
* @param segments Base of the output vector of DMA address length pairs.
* @param segmentIndex Index to output 'segment' in the 'segments' array.
*/
static void outputSegment(PhysicalSegment segment,
void * segments,
UInt32 segmentIndex);
/*! @defined naturalOutputSegment
* @discussion Backward compatibility define for the old global function definition. See IONaturalMemoryCursor::outputSegment.
*/
#define naturalOutputSegment IONaturalMemoryCursor::outputSegment
/*! @function withSpecification
* @abstract Creates and initializes an IONaturalMemoryCursor in one operation.
* @discussion Factory function to create and initialize an IONaturalMemoryCursor in one operation. For more information, see IONaturalMemoryCursor::initWithSpecification.
* @param maxSegmentSize Maximum allowable size for one segment. Defaults to 0.
* @param maxTransferSize Maximum size of an entire transfer. Defaults to 0 indicating no maximum.
* @param alignment Alignment restrictions on output physical addresses. Not currently implemented. Defaults to single byte alignment.
* @result Returns a new memory cursor if successfully created and initialized, 0 otherwise.
*/
static OSPtr<IONaturalMemoryCursor>
withSpecification(IOPhysicalLength maxSegmentSize,
IOPhysicalLength maxTransferSize,
IOPhysicalLength alignment = 1);
/*! @function initWithSpecification
* @abstract Primary initializer for the IONaturalMemoryCursor class.
* @param maxSegmentSize Maximum allowable size for one segment. Defaults to 0.
* @param maxTransferSize Maximum size of an entire transfer. Defaults to 0 indicating no maximum.
* @param alignment Alignment restrictions on output physical addresses. Not currently implemented. Defaults to single byte alignment.
* @result Returns true if the inherited classes and this instance initialize successfully.
*/
virtual bool initWithSpecification(IOPhysicalLength maxSegmentSize,
IOPhysicalLength maxTransferSize,
IOPhysicalLength alignment = 1);
/*! @function getPhysicalSegments
* @abstract Generates a CPU natural physical scatter/gather list given a memory descriptor.
* @discussion Generates a list of physical segments from the given memory descriptor, relative to the current position of the descriptor. Wraps IOMemoryCursor::genPhysicalSegments.
* @param descriptor IOMemoryDescriptor that describes the data associated with an I/O request.
* @param fromPosition Starting location of the I/O within a memory descriptor.
* @param segments Pointer to an array of IOMemoryCursor::PhysicalSegments for the output physical scatter/gather list.
* @param maxSegments Maximum number of segments that can be written to segments array.
* @param inMaxTransferSize Maximum transfer size is limited to that many bytes, otherwise it defaults to the maximum transfer size specified when the memory cursor was initialized.
* @param transferSize Pointer to an IOByteCount variable that can contain the total size of the transfer being described. Defaults to 0 indicating that no transfer size need be returned.
* @result If the descriptor is exhausted of memory, a zero is returned, otherwise the number of segments that were filled in is returned.
*/
virtual UInt32
getPhysicalSegments(IOMemoryDescriptor *descriptor,
IOByteCount fromPosition,
PhysicalSegment *segments,
UInt32 maxSegments,
UInt32 inMaxTransferSize = 0,
IOByteCount *transferSize = NULL)
{
return genPhysicalSegments(descriptor, fromPosition, segments,
maxSegments, inMaxTransferSize, transferSize);
}
};
/************************** class IOBigMemoryCursor **************************/
/*!
* @class IOBigMemoryCursor
* @abstract An IOMemoryCursor subclass that outputs a vector of PhysicalSegments in the big endian byte order.
* @discussion The IOBigMemoryCursor would be used when the DMA hardware requires a big endian address and length pair. This cursor outputs an array of PhysicalSegments that are encoded in big-endian format.
*/
class IOBigMemoryCursor : public IOMemoryCursor
{
OSDeclareDefaultStructors(IOBigMemoryCursor);
public:
/*! @function outputSegment
* @abstract Outputs the given segment into the output segments array in big endian byte order.
* @param segment The physical address and length that is next to be output.
* @param segments Base of the output vector of DMA address length pairs.
* @param segmentIndex Index to output 'segment' in the 'segments' array.
*/
static void outputSegment(PhysicalSegment segment,
void * segments,
UInt32 segmentIndex);
/*! @defined bigOutputSegment
* @discussion Backward compatibility define for the old global function definition. See IOBigMemoryCursor::outputSegment
*/
#define bigOutputSegment IOBigMemoryCursor::outputSegment
/*! @function withSpecification
* @abstract Creates and initializes an IOBigMemoryCursor in one operation.
* @discussion Factory function to create and initialize an IOBigMemoryCursor in one operation. See also IOBigMemoryCursor::initWithSpecification.
* @param maxSegmentSize Maximum allowable size for one segment. Defaults to 0.
* @param maxTransferSize Maximum size of an entire transfer. Defaults to 0 indicating no maximum.
* @param alignment Alignment restrictions on output physical addresses. Not currently implemented. Defaults to single byte alignment.
* @result Returns a new memory cursor if successfully created and initialized, 0 otherwise.
*/
static OSPtr<IOBigMemoryCursor>
withSpecification(IOPhysicalLength maxSegmentSize,
IOPhysicalLength maxTransferSize,
IOPhysicalLength alignment = 1);
/*! @function initWithSpecification
* @abstract Primary initializer for the IOBigMemoryCursor class.
* @param maxSegmentSize Maximum allowable size for one segment. Defaults to 0.
* @param maxTransferSize Maximum size of an entire transfer. Defaults to 0 indicating no maximum.
* @param alignment Alignment restrictions on output physical addresses. Not currently implemented. Defaults to single byte alignment.
* @result Returns true if the inherited classes and this instance initialize
* successfully.
*/
virtual bool initWithSpecification(IOPhysicalLength maxSegmentSize,
IOPhysicalLength maxTransferSize,
IOPhysicalLength alignment = 1);
/*! @function getPhysicalSegments
* @abstract Generates a big endian physical scatter/gather list given a memory descriptor.
* @discussion Generates a list of physical segments from the given memory descriptor, relative to the current position of the descriptor. Wraps IOMemoryCursor::genPhysicalSegments.
* @param descriptor IOMemoryDescriptor that describes the data associated with an I/O request.
* @param fromPosition Starting location of the I/O within a memory descriptor.
* @param segments Pointer to an array of IOMemoryCursor::PhysicalSegments for the output physical scatter/gather list.
* @param maxSegments Maximum number of segments that can be written to segments array.
* @param inMaxTransferSize Maximum transfer size is limited to that many bytes, otherwise it defaults to the maximum transfer size specified when the memory cursor was initialized.
* @param transferSize Pointer to an IOByteCount variable that can contain the total size of the transfer being described. Defaults to 0 indicating that no transfer size need be returned.
* @result If the descriptor is exhausted of memory, a zero is returned, otherwise the number of segments that were filled in is returned.
*/
virtual UInt32
getPhysicalSegments(IOMemoryDescriptor * descriptor,
IOByteCount fromPosition,
PhysicalSegment * segments,
UInt32 maxSegments,
UInt32 inMaxTransferSize = 0,
IOByteCount * transferSize = NULL)
{
return genPhysicalSegments(descriptor, fromPosition, segments,
maxSegments, inMaxTransferSize, transferSize);
}
};
/************************* class IOLittleMemoryCursor ************************/
/*!
* @class IOLittleMemoryCursor
* @abstract An IOMemoryCursor subclass that outputs a vector of PhysicalSegments in the little endian byte order.
* @discussion The IOLittleMemoryCursor would be used when the DMA hardware requires a little endian address and length pair. This cursor outputs an array of PhysicalSegments that are encoded in little endian format.
*/
class IOLittleMemoryCursor : public IOMemoryCursor
{
OSDeclareDefaultStructors(IOLittleMemoryCursor);
public:
/*! @function outputSegment
* @abstract Outputs the given segment into the output segments array in little endian byte order.
* @param segment The physical address and length that is next to be output.
* @param segments Base of the output vector of DMA address length pairs.
* @param segmentIndex Index to output 'segment' in the 'segments' array.
*/
static void outputSegment(PhysicalSegment segment,
void * segments,
UInt32 segmentIndex);
/*! @defined littleOutputSegment
* @discussion Backward compatibility define for the old global function definition. See also IOLittleMemoryCursor::outputSegment. */
#define littleOutputSegment IOLittleMemoryCursor::outputSegment
/*! @function withSpecification
* @abstract Creates and initializes an IOLittleMemoryCursor in one operation.
* @discussion Factory function to create and initialize an IOLittleMemoryCursor in one operation. See also IOLittleMemoryCursor::initWithSpecification.
* @param maxSegmentSize Maximum allowable size for one segment. Defaults to 0.
* @param maxTransferSize Maximum size of an entire transfer. Defaults to 0 indicating no maximum.
* @param alignment Alignment restrictions on output physical addresses. Not currently implemented. Defaults to single byte alignment.
* @result Returns a new memory cursor if successfully created and initialized, 0 otherwise.
*/
static OSPtr<IOLittleMemoryCursor>
withSpecification(IOPhysicalLength maxSegmentSize,
IOPhysicalLength maxTransferSize,
IOPhysicalLength alignment = 1);
/*! @function initWithSpecification
* @abstract Primary initializer for the IOLittleMemoryCursor class.
* @param maxSegmentSize Maximum allowable size for one segment. Defaults to 0.
* @param maxTransferSize Maximum size of an entire transfer. Defaults to 0 indicating no maximum.
* @param alignment Alignment restrictions on output physical addresses. Not currently implemented. Defaults to single byte alignment.
* @result Returns true if the inherited classes and this instance initialize successfully.
*/
virtual bool initWithSpecification(IOPhysicalLength maxSegmentSize,
IOPhysicalLength maxTransferSize,
IOPhysicalLength alignment = 1);
/*! @function getPhysicalSegments
* @abstract Generates a little endian physical scatter/gather list given a memory descriptor.
* @discussion Generates a list of physical segments from the given memory descriptor, relative to the current position of the descriptor. Wraps IOMemoryCursor::genPhysicalSegments.
* @param descriptor IOMemoryDescriptor that describes the data associated with an I/O request.
* @param fromPosition Starting location of the I/O within a memory descriptor.
* @param segments Pointer to an array of IOMemoryCursor::PhysicalSegments for the output physical scatter/gather list.
* @param maxSegments Maximum number of segments that can be written to segments array.
* @param inMaxTransferSize Maximum transfer size is limited to that many bytes, otherwise it defaults to the maximum transfer size specified when the memory cursor was initialized.
* @param transferSize Pointer to an IOByteCount variable that can contain the total size of the transfer being described. Defaults to 0 indicating that no transfer size need be returned.
* @result If the descriptor is exhausted of memory, a zero is returned, otherwise the number of segments that were filled in is returned.
*/
virtual UInt32
getPhysicalSegments(IOMemoryDescriptor * descriptor,
IOByteCount fromPosition,
PhysicalSegment * segments,
UInt32 maxSegments,
UInt32 inMaxTransferSize = 0,
IOByteCount * transferSize = NULL)
{
return genPhysicalSegments(descriptor, fromPosition, segments,
maxSegments, inMaxTransferSize, transferSize);
}
};
#endif /* !_IOMEMORYCURSOR_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOUserClient.h | /*
* Copyright (c) 1998-2019 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* Changes to this API are expected.
*/
#ifndef _IOKIT_IOUSERCLIENT_H
#define _IOKIT_IOUSERCLIENT_H
#include <IOKit/IOTypes.h>
#include <IOKit/IOService.h>
#include <IOKit/OSMessageNotification.h>
#include <DriverKit/IOUserClient.h>
#include <libkern/c++/OSPtr.h>
#if IOKITSTATS
#include <IOKit/IOStatisticsPrivate.h>
#endif
#define _IOUSERCLIENT_SENDASYNCRESULT64WITHOPTIONS_ 1
enum {
kIOUCTypeMask = 0x0000000f,
kIOUCScalarIScalarO = 0,
kIOUCScalarIStructO = 2,
kIOUCStructIStructO = 3,
kIOUCScalarIStructI = 4,
kIOUCForegroundOnly = 0x00000010,
};
/*! @enum
* @abstract Constant to denote a variable length structure argument to IOUserClient.
* @constant kIOUCVariableStructureSize Use in the structures IOExternalMethod, IOExternalAsyncMethod, IOExternalMethodDispatch to specify the size of the structure is variable.
*/
enum {
kIOUCVariableStructureSize = 0xffffffff
};
typedef IOReturn (IOService::*IOMethod)(void * p1, void * p2, void * p3,
void * p4, void * p5, void * p6 );
typedef IOReturn (IOService::*IOAsyncMethod)(OSAsyncReference asyncRef,
void * p1, void * p2, void * p3,
void * p4, void * p5, void * p6 );
typedef IOReturn (IOService::*IOTrap)(void * p1, void * p2, void * p3,
void * p4, void * p5, void * p6 );
struct IOExternalMethod {
IOService * object;
IOMethod func;
IOOptionBits flags;
IOByteCount count0;
IOByteCount count1;
};
struct IOExternalAsyncMethod {
IOService * object;
IOAsyncMethod func;
IOOptionBits flags;
IOByteCount count0;
IOByteCount count1;
};
struct IOExternalTrap {
IOService * object;
IOTrap func;
};
enum {
kIOUserNotifyMaxMessageSize = 64
};
enum {
kIOUserNotifyOptionCanDrop = 0x1 /* Fail if queue is full, rather than infinitely queuing. */
};
// keys for clientHasPrivilege
#define kIOClientPrivilegeAdministrator "root"
#define kIOClientPrivilegeLocalUser "local"
#define kIOClientPrivilegeForeground "foreground"
/*! @enum
* @abstract Constants to specify the maximum number of scalar arguments in the IOExternalMethodArguments structure. These constants are documentary since the scalarInputCount, scalarOutputCount fields reflect the actual number passed.
* @constant kIOExternalMethodScalarInputCountMax The maximum number of scalars able to passed on input.
* @constant kIOExternalMethodScalarOutputCountMax The maximum number of scalars able to passed on output.
*/
enum {
kIOExternalMethodScalarInputCountMax = 16,
kIOExternalMethodScalarOutputCountMax = 16,
};
struct IOExternalMethodArguments {
uint32_t version;
uint32_t selector;
mach_port_t asyncWakePort;
io_user_reference_t * asyncReference;
uint32_t asyncReferenceCount;
const uint64_t * scalarInput;
uint32_t scalarInputCount;
const void * structureInput;
uint32_t structureInputSize;
IOMemoryDescriptor * structureInputDescriptor;
uint64_t * scalarOutput;
uint32_t scalarOutputCount;
void * structureOutput;
uint32_t structureOutputSize;
IOMemoryDescriptor * structureOutputDescriptor;
uint32_t structureOutputDescriptorSize;
uint32_t __reservedA;
OSObject ** structureVariableOutputData;
uint32_t __reserved[30];
};
typedef IOReturn (*IOExternalMethodAction)(OSObject * target, void * reference,
IOExternalMethodArguments * arguments);
struct IOExternalMethodDispatch {
IOExternalMethodAction function;
uint32_t checkScalarInputCount;
uint32_t checkStructureInputSize;
uint32_t checkScalarOutputCount;
uint32_t checkStructureOutputSize;
};
enum {
#define IO_EXTERNAL_METHOD_ARGUMENTS_CURRENT_VERSION 2
kIOExternalMethodArgumentsCurrentVersion = IO_EXTERNAL_METHOD_ARGUMENTS_CURRENT_VERSION
};
/*!
* @class IOUserClient
* @abstract Provides a basis for communication between client applications and I/O Kit objects.
*/
class IOUserClient : public IOService
{
OSDeclareAbstractStructorsWithDispatch(IOUserClient);
#if IOKITSTATS
friend class IOStatistics;
#endif
protected:
/*! @struct ExpansionData
* @discussion This structure will be used to expand the capablilties of this class in the future.
*/
struct ExpansionData {
#if IOKITSTATS
IOUserClientCounter *counter;
#else
void *iokitstatsReserved;
#endif
void *iokitFilterReserved;
};
/*! @var reserved
* Reserved for future use. (Internal use only)
*/
APPLE_KEXT_WSHADOW_PUSH;
ExpansionData * reserved;
APPLE_KEXT_WSHADOW_POP;
bool reserve();
private:
void * __reserved[9];
public:
MIG_SERVER_ROUTINE virtual IOReturn
externalMethod(uint32_t selector, IOExternalMethodArguments *arguments,
IOExternalMethodDispatch *dispatch = NULL,
OSObject *target = NULL, void *reference = NULL);
MIG_SERVER_ROUTINE virtual IOReturn registerNotificationPort(
mach_port_t port, UInt32 type, io_user_reference_t refCon);
private:
#if __LP64__
OSMetaClassDeclareReservedUnused(IOUserClient, 0);
OSMetaClassDeclareReservedUnused(IOUserClient, 1);
#else
OSMetaClassDeclareReservedUsedX86(IOUserClient, 0);
OSMetaClassDeclareReservedUsedX86(IOUserClient, 1);
#endif
OSMetaClassDeclareReservedUnused(IOUserClient, 2);
OSMetaClassDeclareReservedUnused(IOUserClient, 3);
OSMetaClassDeclareReservedUnused(IOUserClient, 4);
OSMetaClassDeclareReservedUnused(IOUserClient, 5);
OSMetaClassDeclareReservedUnused(IOUserClient, 6);
OSMetaClassDeclareReservedUnused(IOUserClient, 7);
OSMetaClassDeclareReservedUnused(IOUserClient, 8);
OSMetaClassDeclareReservedUnused(IOUserClient, 9);
OSMetaClassDeclareReservedUnused(IOUserClient, 10);
OSMetaClassDeclareReservedUnused(IOUserClient, 11);
OSMetaClassDeclareReservedUnused(IOUserClient, 12);
OSMetaClassDeclareReservedUnused(IOUserClient, 13);
OSMetaClassDeclareReservedUnused(IOUserClient, 14);
OSMetaClassDeclareReservedUnused(IOUserClient, 15);
protected:
static IOReturn sendAsyncResult(OSAsyncReference reference,
IOReturn result, void *args[], UInt32 numArgs);
static void setAsyncReference(OSAsyncReference asyncRef,
mach_port_t wakePort,
void *callback, void *refcon);
static IOReturn sendAsyncResult64(OSAsyncReference64 reference,
IOReturn result, io_user_reference_t args[], UInt32 numArgs);
/*!
* @function sendAsyncResult64WithOptions
* @abstract Send a notification as with sendAsyncResult, but with finite queueing.
* @discussion IOUserClient::sendAsyncResult64() will infitely queue messages if the client
* is not processing them in a timely fashion. This variant will not, for simple
* handling of situations where clients may be expected to stop processing messages.
*/
static IOReturn sendAsyncResult64WithOptions(OSAsyncReference64 reference,
IOReturn result, io_user_reference_t args[], UInt32 numArgs,
IOOptionBits options);
static void setAsyncReference64(OSAsyncReference64 asyncRef,
mach_port_t wakePort,
mach_vm_address_t callback, io_user_reference_t refcon);
static void setAsyncReference64(OSAsyncReference64 asyncRef,
mach_port_t wakePort,
mach_vm_address_t callback, io_user_reference_t refcon,
task_t task);
public:
static IOReturn clientHasAuthorization( task_t task,
IOService * service );
static IOReturn clientHasPrivilege( void * securityToken,
const char * privilegeName );
static OSPtr<OSObject> copyClientEntitlement(task_t task, const char *entitlement);
static OSPtr<OSObject> copyClientEntitlementVnode(struct vnode *vnode, off_t offset, const char *entitlement);
static OSPtr<OSDictionary> copyClientEntitlements(task_t task);
static OSPtr<OSDictionary> copyClientEntitlementsVnode(struct vnode *vnode, off_t offset);
/*!
* @function releaseAsyncReference64
* @abstract Release the mach_port_t reference held within the OSAsyncReference64 structure.
* @discussion The OSAsyncReference64 structure passed to async methods holds a reference to the wakeup mach port, which should be released to balance each async method call. Behavior is undefined if these calls are not correctly balanced.
* @param reference The reference passed to the subclass IOAsyncMethod, or externalMethod() in the IOExternalMethodArguments.asyncReference field.
* @result A return code.
*/
static IOReturn releaseAsyncReference64(OSAsyncReference64 reference);
/*!
* @function releaseNotificationPort
* @abstract Release the mach_port_t passed to registerNotificationPort().
* @discussion The mach_port_t passed to the registerNotificationPort() methods should be released to balance each call to registerNotificationPort(). Behavior is undefined if these calls are not correctly balanced.
* @param port The mach_port_t argument previously passed to the subclass implementation of registerNotificationPort().
* @result A return code.
*/
static IOReturn releaseNotificationPort(mach_port_t port);
virtual bool init() APPLE_KEXT_OVERRIDE;
virtual bool init( OSDictionary * dictionary ) APPLE_KEXT_OVERRIDE;
// Currently ignores the all args, just passes up to IOService::init()
virtual bool initWithTask(
task_t owningTask, void * securityToken, UInt32 type,
OSDictionary * properties);
virtual bool initWithTask(
task_t owningTask, void * securityToken, UInt32 type);
virtual void free() APPLE_KEXT_OVERRIDE;
virtual IOReturn clientClose( void );
virtual IOReturn clientDied( void );
virtual IOService * getService( void );
MIG_SERVER_ROUTINE virtual IOReturn registerNotificationPort(
mach_port_t port, UInt32 type, UInt32 refCon );
MIG_SERVER_ROUTINE virtual IOReturn getNotificationSemaphore( UInt32 notification_type,
semaphore_t * semaphore );
virtual IOReturn connectClient( IOUserClient * client );
// memory will be released by user client when last map is destroyed
virtual IOReturn clientMemoryForType( UInt32 type,
IOOptionBits * options,
IOMemoryDescriptor ** memory );
IOReturn clientMemoryForType( UInt32 type,
IOOptionBits * options,
OSSharedPtr<IOMemoryDescriptor>& memory );
#if !__LP64__
private:
APPLE_KEXT_COMPATIBILITY_VIRTUAL
OSPtr<IOMemoryMap> mapClientMemory( IOOptionBits type,
task_t task,
IOOptionBits mapFlags = kIOMapAnywhere,
IOVirtualAddress atAddress = 0 );
#endif
static IOReturn _sendAsyncResult64(OSAsyncReference64 reference,
IOReturn result, io_user_reference_t args[], UInt32 numArgs, IOOptionBits options);
public:
/*!
* @function removeMappingForDescriptor
* Remove the first mapping created from the memory descriptor returned by clientMemoryForType() from IOUserClient's list of mappings. If such a mapping exists, it is retained and the reference currently held by IOUserClient is returned to the caller.
* @param memory The memory descriptor instance previously returned by the implementation of clientMemoryForType().
* @result A reference to the first IOMemoryMap instance found in the list of mappings created by IOUserClient from that passed memory descriptor is returned, or zero if none exist. The caller should release this reference.
*/
OSPtr<IOMemoryMap> removeMappingForDescriptor(IOMemoryDescriptor * memory);
/*!
* @function exportObjectToClient
* Make an arbitrary OSObject available to the client task.
* @param task The task.
* @param obj The object we want to export to the client.
* @param clientObj Returned value is the client's port name.
*/
virtual IOReturn exportObjectToClient(task_t task,
LIBKERN_CONSUMED OSObject *obj, io_object_t *clientObj);
// Old methods for accessing method vector backward compatiblility only
virtual IOExternalMethod *
getExternalMethodForIndex( UInt32 index )
APPLE_KEXT_DEPRECATED;
virtual IOExternalAsyncMethod *
getExternalAsyncMethodForIndex( UInt32 index )
APPLE_KEXT_DEPRECATED;
// Methods for accessing method vector.
virtual IOExternalMethod *
getTargetAndMethodForIndex(
LIBKERN_RETURNS_NOT_RETAINED IOService ** targetP, UInt32 index );
virtual IOExternalAsyncMethod *
getAsyncTargetAndMethodForIndex(
LIBKERN_RETURNS_NOT_RETAINED IOService ** targetP, UInt32 index );
IOExternalMethod *
getTargetAndMethodForIndex(
OSSharedPtr<IOService>& targetP, UInt32 index );
IOExternalAsyncMethod *
getAsyncTargetAndMethodForIndex(
OSSharedPtr<IOService>& targetP, UInt32 index );
// Methods for accessing trap vector - old and new style
virtual IOExternalTrap *
getExternalTrapForIndex( UInt32 index )
APPLE_KEXT_DEPRECATED;
virtual IOExternalTrap *
getTargetAndTrapForIndex(
LIBKERN_RETURNS_NOT_RETAINED IOService **targetP, UInt32 index );
};
#endif /* ! _IOKIT_IOUSERCLIENT_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IONotifier.h | /*
* Copyright (c) 1998-2019 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
*
* HISTORY
*
*/
#ifndef _IOKIT_IONOTIFIER_H
#define _IOKIT_IONOTIFIER_H
#include <libkern/c++/OSObject.h>
/*! @class IONotifier : public OSObject
* @abstract An abstract base class defining common methods for controlling a notification request.
* @discussion IOService notification requests are represented as implementations of the IONotifier object. It defines methods to enable, disable and remove notification requests. These actions are synchronized with invocations of the notification handler, so removing a notification request will guarantee the handler is not being executed. */
class IONotifier : public OSObject
{
OSDeclareAbstractStructors(IONotifier);
public:
/*! @function remove
* @abstract Removes the notification request and releases it.
* @discussion Removes the notification request and release it. Since creating an IONotifier instance will leave it with a retain count of one, creating an IONotifier and then removing it will destroy it. This method is synchronous with any handler invocations, so when this method returns its guaranteed the handler will not be in entered. */
virtual void remove() = 0;
/*! @function disable
* @abstract Disables the notification request.
* @discussion Disables the notification request. This method is synchronous with any handler invocations, so when this method returns its guaranteed the handler will not be in entered.
* @result Returns the previous enable state of the IONotifier. */
virtual bool disable() = 0;
/*! @function enable
* @abstract Sets the enable state of the notification request.
* @discussion Restores the enable state of the notification request, given the previous state passed in.
* @param was The enable state of the notifier to restore. */
virtual void enable( bool was ) = 0;
};
#endif /* ! _IOKIT_IONOTIFIER_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOReportTypes.h | /*
* Copyright (c) 2012-2014 Apple Computer, Inc. All Rights Reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _IOREPORT_TYPES_H_
#define _IOREPORT_TYPES_H_
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
#define IOR_VALUES_PER_ELEMENT 4
/*! @const kIOReportInvalidValue
* @const kIOReportInvalidIntValue
* @abstract cardinal value used to indicate data errors
*
* @discussion
* kIOReportInvalidValue and kIOReportInvalidIntValue have the
* same bit pattern so that clients checking for one or the other
* don't have to worry about getting the signedness right.
*/
#define kIOReportInvalidIntValue INT64_MIN
#define kIOReportInvalidValue (uint64_t)kIOReportInvalidIntValue
/*! @typedef IOReportCategories
* @abstract encapsulate important, multi-purpose "tags" for channels
*
* @discussion
* IOReportCategories is the type for the .categories field of
* IOReportChanelType. These categories are inteded to empower a
* limited number of clients to retrieve a broad range of channels
* without knowing much about them. They can be OR'd together as
* needed. Groups and subgroups are a more extensible mechanism
* for aggregating channels produced by different drivers.
*/
typedef uint16_t IOReportCategories;
#define kIOReportCategoryPower (1 << 1) // and energy
#define kIOReportCategoryTraffic (1 << 2) // I/O at any level
#define kIOReportCategoryPerformance (1 << 3) // e.g. cycles/byte
#define kIOReportCategoryPeripheral (1 << 4) // not built-in
#define kIOReportCategoryField (1 << 8) // consider logging
// future categories TBD
#define kIOReportCategoryDebug (1 << 15)
#define kIOReportInvalidCategory UINT16_MAX
// IOReportChannelType.report_format
typedef uint8_t IOReportFormat;
enum {
kIOReportInvalidFormat = 0,
kIOReportFormatSimple = 1,
kIOReportFormatState = 2,
kIOReportFormatHistogram = 3,
kIOReportFormatSimpleArray = 4
};
// simple report values
typedef struct {
int64_t simple_value;
uint64_t reserved1;
uint64_t reserved2;
uint64_t reserved3;
} __attribute((packed)) IOSimpleReportValues;
// simple value array
typedef struct {
int64_t simple_values[IOR_VALUES_PER_ELEMENT];
} __attribute((packed)) IOSimpleArrayReportValues;
// state report values
typedef struct {
uint64_t state_id; // 0..N-1 or 8-char code (see MAKEID())
uint64_t intransitions; // number of transitions into this state
uint64_t upticks; // ticks spent in state (local timebase)
uint64_t last_intransition;// ticks at last in-transition
} __attribute((packed)) IOStateReportValues;
// histogram report values
typedef struct {
uint64_t bucket_hits;
int64_t bucket_min;
int64_t bucket_max;
int64_t bucket_sum;
} __attribute((packed)) IOHistogramReportValues;
// configuration actions generally change future behavior
typedef uint32_t IOReportConfigureAction;
enum {
// basics (in common operational order)
kIOReportEnable = 0x01,
kIOReportGetDimensions = 0x02,
kIOReportDisable = 0x00,
// Enable/disable modifiers
kIOReportNotifyHubOnChange = 0x10, // triggered polling
kIOReportTraceOnChange = 0x20 // kdebug.h tracing
};
// update actions should not have observable side effects
typedef uint32_t IOReportUpdateAction;
enum {
kIOReportCopyChannelData = 1,
kIOReportTraceChannelData = 2
};
typedef struct {
uint8_t report_format; // Histogram, StateResidency, etc.
uint8_t reserved; // must be zero
uint16_t categories; // power, traffic, etc (omnibus obs.)
uint16_t nelements; // internal size of channel
// only meaningful in the data pipeline
int16_t element_idx; // 0..nelements-1
// -1..-(nelements) = invalid (13127884)
} __attribute((packed)) IOReportChannelType;
/*!
* @define IOREPORT_MAKECHID
* @abstract convert up to 8 printable characters into a 64-bit channel ID
* @param <char0..char7> - printable chars to be packed into a channel ID
* @result a 64-bit channel ID with an implicit ASCII name
* @discussion A simple example:
* IOREPORT_MAKECHID('H', 'i', ' ', 'w', 'o', 'r', 'l', 'd');
* will evaluate to 0x686920776f726c64. Any NUL bytes are
* ignored (by libIOReport) for naming purposes, but will
* appear in the channel ID. Using a non-NUL non-printable
* character will disable the implicit name. Putting NUL
* bytes first eliminates trailing zeros when the channel
* ID is printed as hex. For example:
* IORERPORT_MAKECHID('\0','\0','n','x','f','e','r','s');
* To see the text, use xxd -r -p # not -rp; see 12976241
*/
#define __IOR_lshiftchr(c, chshift) ((uint64_t)(c) << (8*(chshift)))
#define IOREPORT_MAKEID(A, B, C, D, E, F, G, H) \
(__IOR_lshiftchr(A, 7) | __IOR_lshiftchr(B, 6) | __IOR_lshiftchr(C, 5) \
| __IOR_lshiftchr(D, 4) | __IOR_lshiftchr(E, 3) | __IOR_lshiftchr(F, 2) \
| __IOR_lshiftchr(G, 1) | __IOR_lshiftchr(H, 0))
typedef struct {
uint64_t channel_id;
IOReportChannelType channel_type;
} IOReportChannel;
typedef struct {
uint32_t nchannels;
IOReportChannel channels[];
} IOReportChannelList;
typedef struct {
uint64_t provider_id;
IOReportChannel channel;
} IOReportInterest;
typedef struct {
uint32_t ninterests;
IOReportInterest interests[];
} IOReportInterestList;
typedef struct {
uint64_t v[IOR_VALUES_PER_ELEMENT];
} __attribute((packed)) IOReportElementValues;
typedef struct {
uint64_t provider_id;
uint64_t channel_id;
IOReportChannelType channel_type;
uint64_t timestamp;// mach_absolute_time()
IOReportElementValues values;
} __attribute((packed)) IOReportElement;
/*
* IOReporting unit type and constants
*/
// 1. Mechanism
// Assume encoded units could be stored in binary format: don't
// change existing values.
typedef uint64_t IOReportUnit;
typedef uint64_t IOReportUnits; // deprecated typo, please switch
#define __IOR_MAKEUNIT(quantity, scale) \
(((IOReportUnit)quantity << 56) | (uint64_t)scale)
#define IOREPORT_GETUNIT_QUANTITY(unit) \
((IOReportQuantity)((uint64_t)unit >> 56) & 0xff)
#define IOREPORT_GETUNIT_SCALE(unit) \
((IOReportScaleFactor)unit & 0x00ffffffffffffff)
// 8b quantity ID | 32b const val + 8b*2^10 + 8b*2^n | 8b cardinal | 8b unused
typedef uint8_t IOReportQuantity; // SI "quantity" is what's measured
typedef uint64_t IOReportScaleFactor;
// See <http://en.wikipedia.org/wiki/SI_base_unit> for a list
// of quantities and their symbols.
enum {
// used by state reports, etc
kIOReportQuantityUndefined = 0,
kIOReportQuantityTime = 1,// Seconds
kIOReportQuantityPower = 2,// Watts
kIOReportQuantityEnergy = 3,// Joules
kIOReportQuantityCurrent = 4,// Amperes
kIOReportQuantityVoltage = 5,// Volts
kIOReportQuantityCapacitance = 6,// Farad
kIOReportQuantityInductance = 7,// Henry
kIOReportQuantityFrequency = 8,// Hertz
kIOReportQuantityData = 9,// bits/bytes (see scale)
kIOReportQuantityTemperature = 10,// Celsius (not Kelvin :)
kIOReportQuantityEventCount = 100,
kIOReportQuantityPacketCount = 101,
kIOReportQuantityCPUInstrs = 102
};
/* A number of units end up with both IEC (2^n) and SI (10^n) scale factors.
* For example, the "MB" of a 1.44 MB floppy or a 1024MHz clock. We
* thus support separate 2^n and 10^n factors. The exponent encoding
* scheme is modeled loosely on single-precision IEEE 754.
*/
#define kIOReportScaleConstMask 0x000000007fffffff // constant ("uint31")
#define kIOReportScaleOneOver (1LL << 31) // 1/constant
#define kIOReportExpBase (-127) // support base^(-n)
#define kIOReportExpZeroOffset -(kIOReportExpBase) // max exponent = 128
#define kIOReportScaleSIShift 32 // * 10^n
#define kIOReportScaleSIMask 0x000000ff00000000
#define kIOReportScaleIECShift 40 // * 2^n
#define kIOReportScaleIECMask 0x0000ff0000000000
#define kIOReportCardinalShift 48 // placeholders
#define kIOReportCardinalMask 0x00ff000000000000
/*
* Scales are described as a factor times unity:
* 1ms = kIOReportScaleMilli * s
*
* A value expressed in a scaled unit can be scaled to unity via
* multiplication by the constant:
* 100ms * kIOReportScaleMilli [1e-3] = 0.1s.
*/
// SI / decimal
#define kIOReportScalePico ((-12LL + kIOReportExpZeroOffset) \
<< kIOReportScaleSIShift)
#define kIOReportScaleNano ((-9LL + kIOReportExpZeroOffset) \
<< kIOReportScaleSIShift)
#define kIOReportScaleMicro ((-6LL + kIOReportExpZeroOffset) \
<< kIOReportScaleSIShift)
#define kIOReportScaleMilli ((-3LL + kIOReportExpZeroOffset) \
<< kIOReportScaleSIShift)
#define kIOReportScaleUnity 0 // 10^0 = 2^0 = 1
// unity = 0 is a special case for which we give up exp = -127
#define kIOReportScaleKilo ((3LL + kIOReportExpZeroOffset) \
<< kIOReportScaleSIShift)
#define kIOReportScaleMega ((6LL + kIOReportExpZeroOffset) \
<< kIOReportScaleSIShift)
#define kIOReportScaleGiga ((9LL + kIOReportExpZeroOffset) \
<< kIOReportScaleSIShift)
#define kIOReportScaleTera ((12LL + kIOReportExpZeroOffset) \
<< kIOReportScaleSIShift)
// IEC / computer / binary
// It's not clear we'll ever use 2^(-n), but 1..2^~120 should suffice.
#define kIOReportScaleBits kIOReportScaleUnity
#define kIOReportScaleBytes ((3LL + kIOReportExpZeroOffset) \
<< kIOReportScaleIECShift)
// (bytes have to be added to the exponents up front, can't just OR in)
#define kIOReportScaleKibi ((10LL + kIOReportExpZeroOffset) \
<< kIOReportScaleIECShift)
#define kIOReportScaleKiBytes ((13LL + kIOReportExpZeroOffset) \
<< kIOReportScaleIECShift)
#define kIOReportScaleMebi ((20LL + kIOReportExpZeroOffset) \
<< kIOReportScaleIECShift)
#define kIOReportScaleMiBytes ((23LL + kIOReportExpZeroOffset) \
<< kIOReportScaleIECShift)
#define kIOReportScaleGibi ((30LL + kIOReportExpZeroOffset) \
<< kIOReportScaleIECShift)
#define kIOReportScaleGiBytes ((33LL + kIOReportExpZeroOffset) \
<< kIOReportScaleIECShift)
#define kIOReportScaleTebi ((40LL + kIOReportExpZeroOffset) \
<< kIOReportScaleIECShift)
#define kIOReportScaleTiBytes ((43LL + kIOReportExpZeroOffset) \
<< kIOReportScaleIECShift)
// can't encode more than 2^125 (keeping bits & bytes inside -126..128)
// Also, IOReportScaleValue() is currently limited internally by uint64_t.
// Cardinal values, to be filled in appropriately.
// Add values in increasing order.
#define kIOReportScaleMachHWTicks (1LL << kIOReportCardinalShift)
#define kIOReportScaleHWPageSize (2LL << kIOReportCardinalShift)
// page scales: 2 pages * 4ikB/page = 8096 bytes
#define kIOReportScale4KiB (4 | kIOReportScaleKiBytes)
#define kIOReportScale8KiB (8 | kIOReportScaleKiBytes)
#define kIOReportScale16KiB (16 | kIOReportScaleKiBytes)
// Clock frequency scales (units add seconds).
// 1 GHz ticks are 1 ns: 1000 ticks * 1e-6 = 1e-3s
// This '1' is a no-op for scaling, but allows a custom label.
#define kIOReportScale1GHz (1 | kIOReportScaleNano)
// 24MHz ticks are 1/24 of a microsecond: (1/24 * kIOReportScaleMicro [1e-6])s
// So for example, 240 24Mticks * 1/24 * 1e-6 = .00001s [1e-5]s
#define kIOReportScale24MHz (kIOReportScaleOneOver|24 |kIOReportScaleMicro)
// --- END: units mechanism
// 2. Unit constants
#define kIOReportUnitNone __IOR_MAKEUNIT(kIOReportQuantityUndefined, \
kIOReportScaleUnity)
#define kIOReportUnit_s __IOR_MAKEUNIT(kIOReportQuantityTime, \
kIOReportScaleUnity)
#define kIOReportUnit_ms __IOR_MAKEUNIT(kIOReportQuantityTime, \
kIOReportScaleMilli)
#define kIOReportUnit_us __IOR_MAKEUNIT(kIOReportQuantityTime, \
kIOReportScaleMicro)
#define kIOReportUnit_ns __IOR_MAKEUNIT(kIOReportQuantityTime, \
kIOReportScaleNano)
#define kIOReportUnit_J __IOR_MAKEUNIT(kIOReportQuantityEnergy, \
kIOReportScaleUnity)
#define kIOReportUnit_mJ __IOR_MAKEUNIT(kIOReportQuantityEnergy, \
kIOReportScaleMilli)
#define kIOReportUnit_uJ __IOR_MAKEUNIT(kIOReportQuantityEnergy, \
kIOReportScaleMicro)
#define kIOReportUnit_nJ __IOR_MAKEUNIT(kIOReportQuantityEnergy, \
kIOReportScaleNano)
#define kIOReportUnit_pJ __IOR_MAKEUNIT(kIOReportQuantityEnergy, \
kIOReportScalePico)
#define kIOReportUnitHWTicks __IOR_MAKEUNIT(kIOReportQuantityTime, \
kIOReportScaleMachHWTicks)
#define kIOReportUnit24MHzTicks __IOR_MAKEUNIT(kIOReportQuantityTime, \
kIOReportScale24MHz)
#define kIOReportUnit1GHzTicks __IOR_MAKEUNIT(kIOReportQuantityTime, \
kIOReportScale1GHz)
#define kIOReportUnitBits __IOR_MAKEUNIT(kIOReportQuantityData, \
kIOReportScaleBits)
#define kIOReportUnitBytes __IOR_MAKEUNIT(kIOReportQuantityData, \
kIOReportScaleBytes)
#define kIOReportUnit_KiB __IOR_MAKEUNIT(kIOReportQuantityData, \
kIOReportScaleKiBytes)
#define kIOReportUnit_MiB __IOR_MAKEUNIT(kIOReportQuantityData, \
kIOReportScaleMiBytes)
#define kIOReportUnit_GiB __IOR_MAKEUNIT(kIOReportQuantityData, \
kIOReportScaleGiBytes)
#define kIOReportUnit_TiB __IOR_MAKEUNIT(kIOReportQuantityData, \
kIOReportScaleTiBytes)
#define kIOReportUnitEvents __IOR_MAKEUNIT(kIOReportQuantityEventCount, \
kIOReportScaleUnity)
#define kIOReportUnitPackets __IOR_MAKEUNIT(kIOReportQuantityPacketCount, \
kIOReportScaleUnity)
#define kIOReportUnitInstrs __IOR_MAKEUNIT(kIOReportQuantityCPUInstrs, \
kIOReportScaleUnity)
#define kIOReportUnit_KI __IOR_MAKEUNIT(kIOReportQuantityCPUInstrs, \
kIOReportScaleKilo)
#define kIOReportUnit_MI __IOR_MAKEUNIT(kIOReportQuantityCPUInstrs, \
kIOReportScaleMega)
#define kIOReportUnit_GI __IOR_MAKEUNIT(kIOReportQuantityCPUInstrs, \
kIOReportScaleGiga)
// Please file bugs (xnu | IOReporting) for additional units.
// --- END: unit constants
#ifdef __cplusplus
}
#endif
#endif // _IOREPORT_TYPES_H_
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IORPC.h | /*
* Copyright (c) 2018 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _IORPC_H
#define _IORPC_H
#include <stdint.h>
#include <mach/message.h>
class IOUserServer;
typedef uint64_t OSObjectRef;
enum {
kIORPCVersion190615 = (mach_msg_id_t) 0x4da2b68c,
kIORPCVersion190615Reply = (mach_msg_id_t) 0x4da2b68d,
#if DRIVERKIT_PRIVATE
kIORPCVersion190501 = (mach_msg_id_t) 0xfe316a7a,
kIORPCVersion190501Reply = (mach_msg_id_t) 0xfe316a7b,
kIORPCVersionCurrent = kIORPCVersion190615,
kIORPCVersionCurrentReply = kIORPCVersion190615Reply
#endif /* DRIVERKIT_PRIVATE */
};
enum{
kIORPCMessageRemote = 0x00000001,
kIORPCMessageLocalHost = 0x00000002,
kIORPCMessageKernel = 0x00000004,
kIORPCMessageOneway = 0x00000008,
kIORPCMessageObjectRefs = 0x00000010,
kIORPCMessageOnqueue = 0x00000020,
kIORPCMessageError = 0x00000040,
kIORPCMessageSimpleReply = 0x00000080,
};
enum{
kIORPCMessageIDKernel = (1ULL << 63),
};
struct IORPCMessageMach {
mach_msg_header_t msgh;
mach_msg_body_t msgh_body;
mach_msg_port_descriptor_t objects[0];
};
typedef struct IORPCMessageMach IORPCMessageMach;
struct IORPCMessage {
uint64_t msgid;
uint64_t flags;
uint64_t objectRefs;
OSObjectRef objects[0];
};
typedef struct IORPCMessage IORPCMessage;
#if defined(__cplusplus)
extern "C"
#else
extern
#endif
IORPCMessage *
IORPCMessageFromMach(IORPCMessageMach * msg, bool reply);
struct IORPCMessageErrorReturnContent {
IORPCMessage hdr;
kern_return_t result;
uint32_t pad;
};
typedef struct IORPCMessageErrorReturnContent IORPCMessageErrorReturnContent;
#pragma pack(4)
struct IORPCMessageErrorReturn {
IORPCMessageMach mach;
IORPCMessageErrorReturnContent content;
};
#pragma pack()
#if defined(__cplusplus)
class OSMetaClassBase;
struct IORPC;
typedef kern_return_t (*OSDispatchMethod)(OSMetaClassBase * self, const IORPC rpc);
#endif
struct IORPC {
IORPCMessageMach * message;
IORPCMessageMach * reply;
uint32_t sendSize;
uint32_t replySize;
};
typedef struct IORPC IORPC;
enum {
kOSClassCanRemote = 0x00000001,
};
struct OSClassDescription {
uint32_t descriptionSize;
char name[96];
char superName[96];
uint32_t methodOptionsSize;
uint32_t methodOptionsOffset;
uint32_t metaMethodOptionsSize;
uint32_t metaMethodOptionsOffset;
uint32_t queueNamesSize;
uint32_t queueNamesOffset;
uint32_t methodNamesSize;
uint32_t methodNamesOffset;
uint32_t metaMethodNamesSize;
uint32_t metaMethodNamesOffset;
uint64_t flags;
uint64_t resv1[8];
uint64_t methodOptions[0];
uint64_t metaMethodOptions[0];
char dispatchNames[0];
char methodNames[0];
char metaMethodNames[0];
};
#endif /* _IORPC_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/system.h | /*
* Copyright (c) 1998-2004 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef __IOKIT_SYSTEM_H
#define __IOKIT_SYSTEM_H
#ifndef __STDC_LIMIT_MACROS
#define __STDC_LIMIT_MACROS
#endif
#include <sys/cdefs.h>
#include <kern/thread.h>
__BEGIN_DECLS
#include <mach/mach_types.h>
#include <mach/mach_interface.h>
#include <mach/memory_object_types.h>
#include <stdarg.h>
#include <stdint.h>
#include <string.h>
#include <IOKit/assert.h> /* Must be before other includes of kern/assert.h */
#include <kern/kern_types.h>
#include <kern/debug.h>
#include <kern/task.h>
#include <kern/sched_prim.h>
#include <kern/locks.h>
#include <kern/queue.h>
#include <kern/ipc_mig.h>
#include <libkern/libkern.h>
#ifndef _MISC_PROTOS_H_
extern void _doprnt( const char *format, va_list *arg,
void (*lputc)(char), int radix );
#endif
__END_DECLS
#endif /* !__IOKIT_SYSTEM_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOReturn.h | /*
* Copyright (c) 1998-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* HISTORY
*/
/*
* Core IOReturn values. Others may be family defined.
*/
#ifndef __IOKIT_IORETURN_H
#define __IOKIT_IORETURN_H
#ifdef __cplusplus
extern "C" {
#endif
#include <mach/error.h>
typedef kern_return_t IOReturn;
#ifndef sys_iokit
#define sys_iokit err_system(0x38)
#endif /* sys_iokit */
#define sub_iokit_common err_sub(0)
#define sub_iokit_usb err_sub(1)
#define sub_iokit_firewire err_sub(2)
#define sub_iokit_block_storage err_sub(4)
#define sub_iokit_graphics err_sub(5)
#define sub_iokit_networking err_sub(6)
#define sub_iokit_bluetooth err_sub(8)
#define sub_iokit_pmu err_sub(9)
#define sub_iokit_acpi err_sub(10)
#define sub_iokit_smbus err_sub(11)
#define sub_iokit_ahci err_sub(12)
#define sub_iokit_powermanagement err_sub(13)
#define sub_iokit_hidsystem err_sub(14)
#define sub_iokit_scsi err_sub(16)
#define sub_iokit_usbaudio err_sub(17)
#define sub_iokit_wirelesscharging err_sub(18)
//#define sub_iokit_pccard err_sub(21)
#define sub_iokit_thunderbolt err_sub(29)
#define sub_iokit_graphics_acceleration err_sub(30)
#define sub_iokit_keystore err_sub(31)
#define sub_iokit_apfs err_sub(33)
#define sub_iokit_acpiec err_sub(34)
#define sub_iokit_timesync_avb err_sub(35)
#define sub_iokit_platform err_sub(0x2A)
#define sub_iokit_audio_video err_sub(0x45)
#define sub_iokit_cec err_sub(0x46)
#define sub_iokit_baseband err_sub(0x80)
#define sub_iokit_HDA err_sub(0xFE)
#define sub_iokit_hsic err_sub(0x147)
#define sub_iokit_sdio err_sub(0x174)
#define sub_iokit_wlan err_sub(0x208)
#define sub_iokit_appleembeddedsleepwakehandler err_sub(0x209)
#define sub_iokit_appleppm err_sub(0x20A)
#define sub_iokit_vendor_specific err_sub(-2)
#define sub_iokit_reserved err_sub(-1)
#define iokit_common_err(return ) (sys_iokit|sub_iokit_common|return)
#define iokit_family_err(sub, return ) (sys_iokit|sub|return)
#define iokit_vendor_specific_err(return ) (sys_iokit|sub_iokit_vendor_specific|return)
#define kIOReturnSuccess KERN_SUCCESS // OK
#define kIOReturnError iokit_common_err(0x2bc) // general error
#define kIOReturnNoMemory iokit_common_err(0x2bd) // can't allocate memory
#define kIOReturnNoResources iokit_common_err(0x2be) // resource shortage
#define kIOReturnIPCError iokit_common_err(0x2bf) // error during IPC
#define kIOReturnNoDevice iokit_common_err(0x2c0) // no such device
#define kIOReturnNotPrivileged iokit_common_err(0x2c1) // privilege violation
#define kIOReturnBadArgument iokit_common_err(0x2c2) // invalid argument
#define kIOReturnLockedRead iokit_common_err(0x2c3) // device read locked
#define kIOReturnLockedWrite iokit_common_err(0x2c4) // device write locked
#define kIOReturnExclusiveAccess iokit_common_err(0x2c5) // exclusive access and
// device already open
#define kIOReturnBadMessageID iokit_common_err(0x2c6) // sent/received messages
// had different msg_id
#define kIOReturnUnsupported iokit_common_err(0x2c7) // unsupported function
#define kIOReturnVMError iokit_common_err(0x2c8) // misc. VM failure
#define kIOReturnInternalError iokit_common_err(0x2c9) // internal error
#define kIOReturnIOError iokit_common_err(0x2ca) // General I/O error
//#define kIOReturn???Error iokit_common_err(0x2cb) // ???
#define kIOReturnCannotLock iokit_common_err(0x2cc) // can't acquire lock
#define kIOReturnNotOpen iokit_common_err(0x2cd) // device not open
#define kIOReturnNotReadable iokit_common_err(0x2ce) // read not supported
#define kIOReturnNotWritable iokit_common_err(0x2cf) // write not supported
#define kIOReturnNotAligned iokit_common_err(0x2d0) // alignment error
#define kIOReturnBadMedia iokit_common_err(0x2d1) // Media Error
#define kIOReturnStillOpen iokit_common_err(0x2d2) // device(s) still open
#define kIOReturnRLDError iokit_common_err(0x2d3) // rld failure
#define kIOReturnDMAError iokit_common_err(0x2d4) // DMA failure
#define kIOReturnBusy iokit_common_err(0x2d5) // Device Busy
#define kIOReturnTimeout iokit_common_err(0x2d6) // I/O Timeout
#define kIOReturnOffline iokit_common_err(0x2d7) // device offline
#define kIOReturnNotReady iokit_common_err(0x2d8) // not ready
#define kIOReturnNotAttached iokit_common_err(0x2d9) // device not attached
#define kIOReturnNoChannels iokit_common_err(0x2da) // no DMA channels left
#define kIOReturnNoSpace iokit_common_err(0x2db) // no space for data
//#define kIOReturn???Error iokit_common_err(0x2dc) // ???
#define kIOReturnPortExists iokit_common_err(0x2dd) // port already exists
#define kIOReturnCannotWire iokit_common_err(0x2de) // can't wire down
// physical memory
#define kIOReturnNoInterrupt iokit_common_err(0x2df) // no interrupt attached
#define kIOReturnNoFrames iokit_common_err(0x2e0) // no DMA frames enqueued
#define kIOReturnMessageTooLarge iokit_common_err(0x2e1) // oversized msg received
// on interrupt port
#define kIOReturnNotPermitted iokit_common_err(0x2e2) // not permitted
#define kIOReturnNoPower iokit_common_err(0x2e3) // no power to device
#define kIOReturnNoMedia iokit_common_err(0x2e4) // media not present
#define kIOReturnUnformattedMedia iokit_common_err(0x2e5)// media not formatted
#define kIOReturnUnsupportedMode iokit_common_err(0x2e6) // no such mode
#define kIOReturnUnderrun iokit_common_err(0x2e7) // data underrun
#define kIOReturnOverrun iokit_common_err(0x2e8) // data overrun
#define kIOReturnDeviceError iokit_common_err(0x2e9) // the device is not working properly!
#define kIOReturnNoCompletion iokit_common_err(0x2ea) // a completion routine is required
#define kIOReturnAborted iokit_common_err(0x2eb) // operation aborted
#define kIOReturnNoBandwidth iokit_common_err(0x2ec) // bus bandwidth would be exceeded
#define kIOReturnNotResponding iokit_common_err(0x2ed) // device not responding
#define kIOReturnIsoTooOld iokit_common_err(0x2ee) // isochronous I/O request for distant past!
#define kIOReturnIsoTooNew iokit_common_err(0x2ef) // isochronous I/O request for distant future
#define kIOReturnNotFound iokit_common_err(0x2f0) // data was not found
#define kIOReturnInvalid iokit_common_err(0x1) // should never be seen
#ifdef __cplusplus
}
#endif
#endif /* ! __IOKIT_IORETURN_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOReportMacros.h | /*
* Copyright (c) 2012-2020 Apple Computer, Inc. All Rights Reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _IOREPORT_MACROS_H_
#define _IOREPORT_MACROS_H_
#include "IOReportTypes.h"
#include <string.h>
#include <os/overflow.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef IOREPORT_ABORT
#define IOREPORT_ABORT panic
#endif
/*
* Background
*
* These macros allow non-I/O Kit software to generate IOReporting
* reports. Clients must prevent concurrent access to any given
* report buffer from multiple threads.
*
* While these macros allow non-I/O Kit software to participate
* in IOReporting, an IOService instance must lend its driver ID,
* respond to the appropriate IOService overrides, and shuttle
* data back and forth. In some cases, it may be useful to have
* the I/O Kit driver initialize the report buffer with the
* appropriate macro.
*/
/* ----- Reporting Single Integers (SimpleReport) ----- */
/*
* The buffer size required for a SimpleReport.
*/
#define SIMPLEREPORT_BUFSIZE (sizeof(IOReportElement))
/*
* Initialize a buffer to hold a SimpleReport.
*
* void* buffer - ptr to SIMPLEREPORT_BUFSIZE bytes
* size_t bufSize - sanity check of buffer's size
* uint64_t providerID - registry Entry ID of the reporting service
* uint64_t channelID - the report's channel ID
* IOReportCategories categories - categories of this channel
*
* If the buffer is not of sufficient size, the macro calls IOREPORT_ABORT().
* If that returns, the buffer is left full of '&'.
*/
#define SIMPLEREPORT_INIT(buf, bufSize, providerID, channelID, cats) \
do { \
memset((buf), '&', (bufSize)); \
IOReportElement *__elem = (IOReportElement *)(buf); \
IOSimpleReportValues *__vals; \
if ((bufSize) >= SIMPLEREPORT_BUFSIZE) { \
__elem->provider_id = (providerID); \
__elem->channel_id = (channelID); \
__elem->channel_type.report_format = kIOReportFormatSimple; \
__elem->channel_type.reserved = 0; \
__elem->channel_type.categories = (cats); \
__elem->channel_type.nelements = 1; \
__elem->channel_type.element_idx = 0; \
__elem->timestamp = 0; \
__vals = (IOSimpleReportValues*)&__elem->values; \
__vals->simple_value = kIOReportInvalidIntValue; \
} \
else { \
IOREPORT_ABORT("bufSize is smaller than the required size\n"); \
} \
} while(0)
/*
* Set a SimpleReport to a new value.
*
* void* simp_buf - ptr to memory initialized by SIMPLEREPORT_INIT()
* int64_t new_value - new value for the report
*/
#define SIMPLEREPORT_SETVALUE(simp_buf, new_value) \
do { \
IOReportElement *__elem = (IOReportElement *)(simp_buf); \
IOSimpleReportValues *__vals; \
__vals = (IOSimpleReportValues*)&__elem->values; \
__vals->simple_value = (new_value); \
} while(0)
/*
* Increment the value of a SimpleReport.
*
* void* simp_buf - ptr to memory initialized by SIMPLEREPORT_INIT()
* int64_t increment - amount by which to increment the value
*/
#define SIMPLEREPORT_INCREMENTVALUE(simp_buf, increment_by) \
do { \
IOReportElement *__elem = (IOReportElement *)(simp_buf); \
IOSimpleReportValues *__vals; \
__vals = (IOSimpleReportValues*)&__elem->values; \
int64_t __simple_value = INT64_MAX; \
if (os_add_overflow(__vals->simple_value, (increment_by), &__simple_value)) { \
__vals->simple_value = INT64_MAX; \
} else { \
__vals->simple_value = __simple_value; \
} \
} while(0)
/*
* Prepare a SimpleReport for
* IOService::updateReport(kIOReportCopyChannelData...)
*
* void* simp_buf - Ptr to memory updated by SIMPLEREPORT_SETVALUE()
* void* ptr2cpy - On return, 'ptr2cpy' points to the memory that needs to be
* copied for kIOReportCopyChannelData.
* size_t size2cpy - On return, 'size2cpy' is set to the size of the report
* data that needs to be copied for kIOReportCopyChannelData.
*/
#define SIMPLEREPORT_UPDATEPREP(simp_buf, ptr2cpy, size2cpy) \
do { \
(ptr2cpy) = (simp_buf); \
(size2cpy) = sizeof(IOReportElement); \
} while(0)
/*
* Update the result field received as a parameter for
* kIOReportGetDimensions & kIOReportCopyChannelData actions.
*
* IOReportConfigureAction action - configure/updateReport() 'action' param
* void* result - configure/updateReport() 'result' param
*/
#define SIMPLEREPORT_UPDATERES(action, result) \
do { \
if (((action) == kIOReportGetDimensions) || ((action) == kIOReportCopyChannelData)) { \
int *__nElements = (int *)(result); \
*__nElements += 1; \
} \
} while (0)
/*
* Get the 64-bit channel ID of a SimpleReport.
*
* void* simp_buf - ptr to memory initialized by SIMPLEREPORT_INIT()
*/
#define SIMPLEREPORT_GETCHID(simp_buf) \
(((IOReportElement *)(simp_buf))->channel_id)
/*
* Get the IOReportChannelType of a SimpleReport.
*
* void* simp_buf - ptr to memory initialized by SIMPLEREPORT_INIT()
*/
#define SIMPLEREPORT_GETCHTYPE(simp_buf) \
(*(uint64_t*)&(((IOReportElement *)(simp_buf))->channel_type))
/*
* Get the integer value of a SimpleReport.
*
* void* simp_buf - memory initialized by SIMPLEREPORT_INIT()
*/
#define SIMPLEREPORT_GETVALUE(simp_buf) \
(((IOSimpleReportValues*)&(((IOReportElement*)(simp_buf))->values)) \
->simple_value)
/* ----- State Machine Reporting (StateReport) ----- */
// Internal struct for StateReport
typedef struct {
uint16_t curr_state;
uint64_t update_ts;
IOReportElement elem[]; // Array of elements
} IOStateReportInfo;
/*
* Determine the size required for a StateReport buffer.
*
* int nstates - number of states to be reported
*/
#define STATEREPORT_BUFSIZE(nstates) \
(sizeof(IOStateReportInfo) + (nstates) * sizeof(IOReportElement))
/*
* Initialize a StateReport buffer.
*
* uint16_t nstates - number of states to be reported
* void* buffer - ptr to STATEREPORT_BUFSIZE(nstates) bytes
* size_t bufSize - sanity check of buffer's size
* uint64_t providerID - registry Entry ID of the reporting service
* uint64_t channelID - ID of this channel, see IOREPORT_MAKEID()
* IOReportCategories categories - categories of this channel
*
* If the buffer is not of sufficient size, the macro invokes IOREPORT_ABORT.
* If that returns, the buffer is left full of '&'.
*/
#define STATEREPORT_INIT(nstates, buf, bufSize, providerID, channelID, cats) \
do { \
memset((buf), '&', (bufSize)); \
IOStateReportInfo *__info = (IOStateReportInfo *)(buf); \
IOStateReportValues *__rep; \
IOReportElement *__elem; \
if ((bufSize) >= STATEREPORT_BUFSIZE(nstates)) { \
for (uint16_t __no = 0; __no < (nstates); __no++) { \
__elem = &(__info->elem[__no]); \
__rep = (IOStateReportValues *) &(__elem->values); \
__elem->provider_id = (providerID); \
__elem->channel_id = (channelID); \
__elem->channel_type.report_format = kIOReportFormatState; \
__elem->channel_type.reserved = 0; \
__elem->channel_type.categories = (cats); \
__elem->channel_type.nelements = (nstates); \
__elem->channel_type.element_idx = __no; \
__elem->timestamp = 0; \
__rep->state_id = __no; \
__rep->intransitions = 0; \
__rep->upticks = 0; \
__rep->last_intransition = 0; \
} \
__info->curr_state = 0; \
__info->update_ts = 0; \
} \
else { \
IOREPORT_ABORT("bufSize is smaller than the required size\n"); \
} \
} while(0)
/*
* Initialize the state id field of a state with the specified value. By
* default, STATEREPORT_INIT() initializes the state IDs with the index of
* that state. This macro can be used to provide a more descriptive state id.
*
* void* state_buf - ptr to memory initialized by STATEREPORT_INIT()
* unsigned stateIdx - index of the state, out of bounds -> no-op
* uint64_t stateID - new state id, see IOREPORT_MAKEID()
*/
#define STATEREPORT_SETSTATEID(state_buf, stateIdx, stateID) \
do { \
IOStateReportInfo *__info = (IOStateReportInfo *)(state_buf); \
IOStateReportValues *__rep; \
if ((stateIdx) < __info->elem[0].channel_type.nelements) { \
__rep = (IOStateReportValues*) &(__info->elem[(stateIdx)].values); \
__rep->state_id = (stateID); \
} \
} while (0)
/*
* Set the state of a StateReport.
*
* void* state_buf - pointer to memory initialized by STATEREPORT_INIT()
* unsigned newStateIdx - index of new state, out of bounds -> no-op
* uint64_t changeTime - time at which the transition occurred
*/
#define STATEREPORT_SETSTATE(state_buf, newStateIdx, changeTime) \
do { \
IOStateReportInfo *__info = (IOStateReportInfo *)(state_buf); \
IOStateReportValues *__rep; \
if ((newStateIdx) < __info->elem[0].channel_type.nelements ) { \
__rep = (IOStateReportValues*) &(__info->elem[__info->curr_state].values); \
if (__info->update_ts) \
__rep->upticks += (changeTime) - __info->update_ts; \
__info->elem[(newStateIdx)].timestamp = (changeTime); \
__rep = (IOStateReportValues*) &(__info->elem[(newStateIdx)].values); \
__rep->intransitions++; \
__info->curr_state = (newStateIdx); \
__info->update_ts = (changeTime); \
} \
} while(0)
/*
* Prepare a StateReport for
* IOService::updateReport(kIOReportCopyChannelData...)
*
* void* state_buf - ptr to memory initialized by STATEREPORT_INIT()
* uint64_t currentTime - current timestamp
* void* ptr2cpy - filled in with pointer to buffer to be copied out
* size_t size2cpy - filled in with the size of the buffer to copy out
*/
#define STATEREPORT_UPDATEPREP(state_buf, currentTime, ptr2cpy, size2cpy) \
do { \
IOStateReportInfo *__info = (IOStateReportInfo *)(state_buf); \
IOReportElement *__elem; \
IOStateReportValues *__state; \
(size2cpy) = __info->elem[0].channel_type.nelements * sizeof(IOReportElement); \
(ptr2cpy) = (void *) &__info->elem[0]; \
if (__info->update_ts) { \
__elem = &__info->elem[__info->curr_state]; \
__state = (IOStateReportValues *)&__elem->values; \
__elem->timestamp = (currentTime); \
__state->upticks += (currentTime) - __info->update_ts; \
__info->update_ts = (currentTime); \
} \
} while(0)
/*
* Update the result field received as a parameter for kIOReportGetDimensions &
* kIOReportCopyChannelData actions.
*
* void* state_buf - memory initialized by STATEREPORT_INIT()
* IOReportConfigureAction action - configure/updateReport() 'action'
* void* result - configure/updateReport() 'result'
*/
#define STATEREPORT_UPDATERES(state_buf, action, result) \
do { \
IOStateReportInfo *__info = (IOStateReportInfo *)(state_buf); \
IOReportElement *__elem; \
int *__nElements = (int *)(result); \
if (((action) == kIOReportGetDimensions) || ((action) == kIOReportCopyChannelData)) { \
__elem = &(__info->elem[0]); \
if (os_add_overflow(*__nElements, __elem->channel_type.nelements, __nElements)) { \
*__nElements = INT_MAX; \
} \
} \
} while (0)
/*
* Get the 64-bit channel ID of a StateReport.
*
* void* state_buf - ptr to memory initialized by STATEREPORT_INIT()
*/
#define STATEREPORT_GETCHID(state_buf) \
(((IOStateReportInfo *)(state_buf))->elem[0].channel_id)
/*
* Get the IOReportChannelType of a StateReport.
*
* void* state_buf - ptr to memory initialized by STATEREPORT_INIT()
*/
#define STATEREPORT_GETCHTYPE(state_buf) \
(*(uint64_t*)&(((IOStateReportInfo *)(state_buf))->elem[0].channel_type))
/*
* Get the number of transitions into a given state.
*
* void* state_buf - ptr to memory initialized by STATEREPORT_INIT()
* unsigned stateIdx - index of state, out of bounds -> kIOReportInvalidValue
*
*/
#define STATEREPORT_GETTRANSITIONS(state_buf, stateIdx) \
(((stateIdx) < ((IOStateReportInfo *)(state_buf))->elem[0].channel_type.nelements) \
? ((IOStateReportValues*)&(((IOStateReportInfo*)(state_buf))->elem[(stateIdx)].values))->intransitions \
: kIOReportInvalidValue)
/*
* Get the total number of ticks spent in a given state.
*
* void* state_buf - ptr to memory initialized by STATEREPORT_INIT()
* unsigned stateIdx - index of state, out of bounds -> kIOReportInvalidValue
*/
#define STATEREPORT_GETTICKS(state_buf, stateIdx) \
(((stateIdx) < ((IOStateReportInfo*)(state_buf))->elem[0].channel_type.nelements) \
? ((IOStateReportValues*)&(((IOStateReportInfo*)(state_buf))->elem[(stateIdx)].values))->upticks \
: kIOReportInvalidValue)
/* ----- Reporting an Array of Integers (SimpleArrayReport) ----- */
/*
* Determine the buffer size for a SimpleArrayReport.
*
* int nValues - number of values to be reported
*/
#define SIMPLEARRAY_BUFSIZE(nValues) \
((((nValues)/IOR_VALUES_PER_ELEMENT) + (((nValues) % IOR_VALUES_PER_ELEMENT) ? 1:0)) \
* sizeof(IOReportElement))
/*
* Initialize a buffer for use as a SimpleArrayReport.
*
* int nValues - number of elements to be reported
* void* buf - ptr to SIMPLEARRAY_BUFSIZE(nValues) bytes
* size_t bufSize - sanity check of buffer's size
* uint64_t providerID - registry Entry ID of the reporting service
* uint64_t channelID - ID of this channel, see IOREPORT_MAKEID()
* IOReportCategories categories - categories of this channel
*
* If the buffer is not of sufficient size, the macro invokes IOREPORT_ABORT().
* If that returns, the buffer is left full of '&'.
*/
#define SIMPLEARRAY_INIT(nValues, buf, bufSize, providerID, channelID, cats) \
do { \
memset((buf), '&', (bufSize)); \
IOSimpleArrayReportValues *__rep; \
IOReportElement *__elem; \
uint32_t __nElems = (((nValues) / IOR_VALUES_PER_ELEMENT) + \
(((nValues) % IOR_VALUES_PER_ELEMENT) ? 1 : 0)); \
if ((bufSize) >= SIMPLEARRAY_BUFSIZE(nValues)) { \
for (unsigned __no = 0; __no < __nElems; __no++) { \
__elem = &(((IOReportElement *)(buf))[__no]); \
__rep = (IOSimpleArrayReportValues *) &(__elem->values); \
__elem->provider_id = (providerID); \
__elem->channel_id = (channelID); \
__elem->channel_type.report_format = kIOReportFormatSimpleArray; \
__elem->channel_type.reserved = 0; \
__elem->channel_type.categories = (cats); \
__elem->channel_type.nelements = (__nElems); \
__elem->channel_type.element_idx = __no; \
__elem->timestamp = 0; \
__rep->simple_values[0] = kIOReportInvalidIntValue; \
__rep->simple_values[1] = kIOReportInvalidIntValue; \
__rep->simple_values[2] = kIOReportInvalidIntValue; \
__rep->simple_values[3] = kIOReportInvalidIntValue; \
} \
} \
else { \
IOREPORT_ABORT("bufSize is smaller than the required size\n"); \
} \
} while(0)
/* SimpleArrayReport helpers */
#define __SA_FINDREP(array_buf, idx) \
IOSimpleArrayReportValues *__rep; \
IOReportElement *__elem; \
unsigned __elemIdx = (idx) / IOR_VALUES_PER_ELEMENT; \
unsigned __valueIdx = (idx) % IOR_VALUES_PER_ELEMENT; \
__elem = &(((IOReportElement *)(array_buf))[0]); \
if (__elemIdx < __elem->channel_type.nelements) { \
__elem = &(((IOReportElement *)(array_buf))[__elemIdx]); \
__rep = (IOSimpleArrayReportValues *) &(__elem->values); \
#define __SA_MAXINDEX(array_buf) \
((((IOReportElement*)(array_buf))->channel_type.nelements) \
* IOR_VALUES_PER_ELEMENT) - 1
/*
* Set a value at a specified index in a SimpleArrayReport.
*
* void* array_bufbuf - ptr to memory initialized by SIMPLEARRAY_INIT()
* unsigned idx - array index, out of bounds -> no-op
* uint64_t newValue - new value to be stored at array[idx]
*/
#define SIMPLEARRAY_SETVALUE(array_buf, idx, newValue) \
do { \
__SA_FINDREP((array_buf), (idx)) \
__rep->simple_values[__valueIdx] = (newValue); \
} \
} while(0)
/*
* Increment an array value within a SimpleArrayReport.
*
* void* array_buf - ptr to memory initialized by SIMPLEARRAY_INIT()
* unsigned idx - array index to increment, out of bounds -> no-op
* int64_t value - amount by which to increment array[idx]
*/
#define SIMPLEARRAY_INCREMENTVALUE(array_buf, idx, value) \
do { \
__SA_FINDREP((array_buf), (idx)) \
if (os_add_overflow(__rep->simple_values[__valueIdx], (value), &__rep->simple_values[__valueIdx])) { \
__rep->simple_values[__valueIdx] = INT64_MAX; \
} \
} \
} while(0)
/*
* Prepare a SimpleArrayReport for
* IOService::updateReport(kIOReportCopyChannelData...)
*
* void* array_buf - ptr to memory initialized by SIMPLEARRAY_INIT()
* void* ptr2cpy - filled in with pointer to buffer to be copied out
* size_t size2cpy - filled in with the size of the buffer to copy out
*/
#define SIMPLEARRAY_UPDATEPREP(array_buf, ptr2cpy, size2cpy) \
do { \
IOReportElement *__elem; \
__elem = &(((IOReportElement *)(array_buf))[0]); \
(ptr2cpy) = (void *) (array_buf); \
(size2cpy) = __elem->channel_type.nelements * sizeof(IOReportElement); \
} while(0)
/*
* Update the result field received as a parameter for kIOReportGetDimensions &
* kIOReportCopyChannelData actions.
*
* void* array_buf - memory initialized by SIMPLEARRAY_INIT()
* IOReportConfigureAction action - configure/updateReport() 'action'
* void* result - configure/updateReport() 'result'
*/
#define SIMPLEARRAY_UPDATERES(array_buf, action, result) \
do { \
IOReportElement *__elem; \
int *__nElements = (int *)(result); \
__elem = &(((IOReportElement *)(array_buf))[0]); \
if (((action) == kIOReportGetDimensions) || ((action) == kIOReportCopyChannelData)) { \
if (os_add_overflow(*__nElements, __elem->channel_type.nelements, __nElements)) { \
*__nElements = INT_MAX; \
} \
} \
} while (0)
/*
* Get the 64-bit channel ID of a SimpleArrayReport.
*
* void* array_buf - ptr to memory initialized by SIMPLEARRAY_INIT()
*/
#define SIMPLEARRAY_GETCHID(array_buf) \
(((IOReportElement *)(array_buf))->channel_id)
/*
* Get the IOReportChannelType of a SimpleArrayReport.
*
* void* simp_buf - ptr to memory initialized by SIMPLEREPORT_INIT()
*/
#define SIMPLEARRAY_GETCHTYPE(array_buf) \
(*(uint64_t*)&(((IOReportElement *)(array_buf))->channel_type))
/*
* Get a value from a SimpleArrayReport.
*
* void* array_buf - ptr to memory initialized by SIMPLEARRAY_INIT()
* unsigned idx - index of the value, out of bounds -> kIOReportInvalidValue
*/
#define SIMPLEARRAY_GETVALUE(array_buf, idx) \
(((idx) > __SA_MAXINDEX(array_buf) || (idx) < 0) ? kIOReportInvalidIntValue : \
((IOSimpleArrayReportValues*)&( \
((IOReportElement*)(array_buf))[(idx) / IOR_VALUES_PER_ELEMENT].values)) \
->simple_values[(idx) % IOR_VALUES_PER_ELEMENT])
/* ----- Histogram Reporting (HistogramReport) ----- */
// Internal struct for HistogramReport
typedef struct {
int bucketWidth;
IOReportElement elem[]; // Array of elements
} IOHistReportInfo;
/*
* Determine the size required for a HistogramReport buffer.
*
* int nbuckets - number of buckets in the histogram
*/
#define HISTREPORT_BUFSIZE(nbuckets) \
(sizeof(IOHistReportInfo) + ((nbuckets) * sizeof(IOReportElement)))
/*
* Initialize a HistogramReport buffer. Supports only linear scale histogram.
*
* uint16_t nbuckets - number of buckets data is combined into
* uint32_t bucketWidth - size of each bucket
* void* buffer - ptr to HISTREPORT_BUFSIZE(nbuckets) bytes
* size_t bufSize - sanity check of buffer's size
* uint64_t providerID - registry Entry ID of the reporting service
* uint64_t channelID - ID of this channel, see IOREPORT_MAKEID()
* IOReportCategories categories - categories of this channel
*
* If the buffer is not of sufficient size, the macro invokes IOREPORT_ABORT.
* If that returns, the buffer is left full of '&'.
*/
#define HISTREPORT_INIT(nbuckets, bktSize, buf, bufSize, providerID, channelID, cats) \
do { \
memset((buf), '&', (bufSize)); \
IOHistReportInfo *__info = (IOHistReportInfo *)(buf); \
IOReportElement *__elem; \
IOHistogramReportValues *__rep; \
if ((bufSize) >= HISTREPORT_BUFSIZE(nbuckets)) { \
__info->bucketWidth = (bktSize); \
for (uint16_t __no = 0; __no < (nbuckets); __no++) { \
__elem = &(__info->elem[__no]); \
__rep = (IOHistogramReportValues *) &(__elem->values); \
__elem->provider_id = (providerID); \
__elem->channel_id = (channelID); \
__elem->channel_type.report_format = kIOReportFormatHistogram; \
__elem->channel_type.reserved = 0; \
__elem->channel_type.categories = (cats); \
__elem->channel_type.nelements = (nbuckets); \
__elem->channel_type.element_idx = __no; \
__elem->timestamp = 0; \
memset(__rep, '\0', sizeof(IOHistogramReportValues)); \
} \
} \
else { \
IOREPORT_ABORT("bufSize is smaller than the required size\n"); \
} \
} while (0)
/*
* Update histogram with a new value.
*
*
* void* hist_buf - pointer to memory initialized by HISTREPORT_INIT()
* int64_t value - new value to add to the histogram
*/
#define HISTREPORT_TALLYVALUE(hist_buf, value) \
do { \
IOHistReportInfo *__info = (IOHistReportInfo *)(hist_buf); \
IOReportElement *__elem; \
IOHistogramReportValues *__rep; \
for (unsigned __no = 0; __no < __info->elem[0].channel_type.nelements; __no++) { \
if ((value) <= __info->bucketWidth * (__no+1)) { \
__elem = &(__info->elem[__no]); \
__rep = (IOHistogramReportValues *) &(__elem->values); \
if (__rep->bucket_hits == 0) { \
__rep->bucket_min = __rep->bucket_max = (value); \
} \
else if ((value) < __rep->bucket_min) { \
__rep->bucket_min = (value); \
} \
else if ((value) > __rep->bucket_max) { \
__rep->bucket_max = (value); \
} \
int64_t __sum = 0; \
if (os_add_overflow(__rep->bucket_sum, (value), &__sum)) { \
__rep->bucket_sum = INT64_MAX; \
} else { \
__rep->bucket_sum = __sum; \
} \
__rep->bucket_hits++; \
break; \
} \
} \
} while (0)
/*
* Prepare a HistogramReport for
* IOService::updateReport(kIOReportCopyChannelData...)
*
* void* array_buf - ptr to memory initialized by HISTREPORT_INIT()
* void* ptr2cpy - filled in with pointer to buffer to be copied out
* size_t size2cpy - filled in with the size of the buffer to copy out
*/
#define HISTREPORT_UPDATEPREP(hist_buf, ptr2cpy, size2cpy) \
do { \
IOHistReportInfo *__info = (IOHistReportInfo *)(hist_buf); \
(size2cpy) = __info->elem[0].channel_type.nelements * sizeof(IOReportElement); \
(ptr2cpy) = (void *) &__info->elem[0]; \
} while(0)
/*
* Update the result field received as a parameter for kIOReportGetDimensions &
* kIOReportCopyChannelData actions.
*
* void* array_buf - memory initialized by HISTREPORT_INIT()
* IOReportConfigureAction action - configure/updateReport() 'action'
* void* result - configure/updateReport() 'result'
*/
#define HISTREPORT_UPDATERES(hist_buf, action, result) \
do { \
IOHistReportInfo *__info = (IOHistReportInfo *)(hist_buf); \
int *__nElements = (int *)(result); \
if (((action) == kIOReportGetDimensions) || ((action) == kIOReportCopyChannelData)) { \
if (os_add_overflow(*__nElements, __info->elem[0].channel_type.nelements, __nElements)) { \
*__nElements = INT_MAX; \
} \
} \
} while (0)
/*
* Get the 64-bit channel ID of a HistogramReport.
*
* void* hist_buf - ptr to memory initialized by HISTREPORT_INIT()
*/
#define HISTREPORT_GETCHID(hist_buf) \
(((IOHistReportInfo *)(hist_buf))->elem[0].channel_id)
/*
* Get the IOReportChannelType of a HistogramReport.
*
* void* hist_buf - ptr to memory initialized by HISTREPORT_INIT()
*/
#define HISTREPORT_GETCHTYPE(hist_buf) \
(*(uint64_t*)&(((IOHistReportInfo *)(hist_buf))->elem[0].channel_type))
#ifdef __cplusplus
}
#endif
#endif // _IOREPORT_MACROS_H_
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOEventSource.h | /*
* Copyright (c) 1998-2019 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* Copyright (c) 1998 Apple Computer, Inc. All rights reserved.
* HISTORY
* 1998-7-13 Godfrey van der Linden(gvdl)
* Created.
* 1998-10-30 Godfrey van der Linden(gvdl)
* Converted to C++
*/
#ifndef _IOKIT_IOEVENTSOURCE_H
#define _IOKIT_IOEVENTSOURCE_H
#include <sys/cdefs.h>
#include <libkern/c++/OSObject.h>
#include <IOKit/IOLib.h>
#include <IOKit/system.h>
#include <IOKit/IOWorkLoop.h>
#if IOKITSTATS
#include <IOKit/IOStatisticsPrivate.h>
#endif
__BEGIN_DECLS
#include <mach/clock_types.h>
#include <kern/clock.h>
__END_DECLS
/*!
* @class IOEventSource : public OSObject
* @abstract Abstract class for all work-loop event sources.
* @discussion The IOEventSource declares the abstract super class that all
* event sources must inherit from if an IOWorkLoop is to receive events from them.
* <br><br>
* An event source can represent any event that should cause the work-loop of a
* device to wake up and perform work. Two examples of event sources are the
* IOInterruptEventSource which delivers interrupt notifications and IOCommandGate
* which delivers command requests.
* <br><br>
* A kernel module can always use the work-loop model for serialising access to
* anything at all. The IOEventSource is used for communicating events to the
* work-loop, and the chain of event sources should be used to walk the possible
* event sources and demultipex them. Note a particular instance of an event
* source may only be a member of 1 linked list chain. If you need to move it
* between chains than make sure it is removed from the original chain before
* attempting to move it.
* <br><br>
* The IOEventSource makes no attempt to maintain the consistency of its internal data across multi-threading. It is assumed that the user of these basic tools will protect the data that these objects represent in some sort of device wide instance lock. For example the IOWorkLoop maintains the event chain by using an IOCommandGate and thus single threading access to its state.
* <br><br>
* All subclasses of IOEventSource that wish to perform work on the work-loop thread are expected to implement the checkForWork() member function. As of Mac OS X, 10.7 (Darwin 11), checkForWork is no longer pure virtual, and should not be overridden if there is no work to be done.
*
* <br><br>
* checkForWork() is the key method in this class. It is called by some work-loop when convienient and is expected to evaluate its internal state and determine if an event has occurred since the last call. In the case of an event having occurred then the instance defined target(owner)/action will be called. The action is stored as an ordinary C function pointer but the first parameter is always the owner. This means that a C++ member function can be used as an action function though this depends on the ABI.
* <br><br>
* Although the eventChainNext variable contains a reference to the next event source in the chain this reference is not retained. The list 'owner' i.e. the client that creates the event, not the work-loop, is expected to retain the source.
*/
class IOEventSource : public OSObject
{
OSDeclareAbstractStructors(IOEventSource);
friend class IOWorkLoop;
#if IOKITSTATS
friend class IOStatistics;
#endif
public:
/*!
* @typedef Action
* @discussion Placeholder type for C++ function overloading discrimination.
* As the all event sources require an action and it has to be stored somewhere
* and be of some type, this is that type.
* @param owner
* Target of the function, can be used as a refcon. The owner is set
* during initialisation. Note if a C++ function was specified this parameter
* is implicitly the first paramter in the target member function's parameter list.
*/
typedef void (*Action)(OSObject *owner, ...);
/*! @defined IOEventSourceAction
* @discussion Backward compatibilty define for the old non-class scoped type definition. See $link IOEventSource::Action */
#define IOEventSourceAction IOEventSource::Action
#ifdef __BLOCKS__
typedef IOReturn (^ActionBlock)();
#endif /* __BLOCKS__ */
protected:
/*! @var eventChainNext
* The next event source in the event chain. nil at end of chain. */
IOEventSource *eventChainNext;
/*! @var owner The owner object called when an event has been delivered. */
OSObject *owner;
/*! @var action
* The action method called when an event has been delivered */
Action action;
/*! @var enabled
* Is this event source enabled to deliver requests to the work-loop. */
bool enabled;
/*! @var workLoop What is the work-loop for this event source. */
IOWorkLoop *workLoop;
/*! @var refcon What ever the client wants to do, see $link setRefcon. */
void *refcon;
/*! @struct ExpansionData
* @discussion This structure will be used to expand the capablilties of the IOEventSource in the future.
*/
struct ExpansionData {
#if IOKITSTATS
struct IOEventSourceCounter *counter;
#else
void *iokitstatsReserved;
#endif
};
/*! @var reserved
* Reserved for future use. (Internal use only) */
ExpansionData *reserved;
/*! @function init
* @abstract Primary initialiser for the IOEventSource class.
* @param owner
* Owner of this instance of an event source. Used as the first parameter
* of the action callout. Owner must be an OSObject.
* @param action
* Pointer to C call out function. Action is a pointer to a C function
* that gets called when this event source has outstanding work. It will usually
* be called by the checkForWork member function. The first parameter of the
* action call out will always be the owner, this allows C++ member functions to
* be used as actions. Defaults to 0.
* @result true if the inherited classes and this instance initialise
* successfully.
*/
virtual bool init(OSObject *owner, IOEventSource::Action action = NULL);
virtual void free( void ) APPLE_KEXT_OVERRIDE;
/*! @function checkForWork
* @abstract Virtual member function used by IOWorkLoop for work
* scheduling.
* @discussion This function will be called to request a subclass to check
* its internal state for any work to do and then to call out the owner/action.
* If this event source never performs any work (e.g. IOCommandGate), this
* method should not be overridden. NOTE: This method is no longer declared pure
* virtual. A default implementation is provided in IOEventSource.
* @result Return true if this function needs to be called again before all its outstanding events have been processed.
*/
virtual bool checkForWork();
/*! @function setWorkLoop
* @abstract Set'ter for $link workLoop variable.
* @param workLoop
* Target work-loop of this event source instance. A subclass of
* IOWorkLoop that at least reacts to signalWorkAvailable() and onThread functions.
*/
virtual void setWorkLoop(IOWorkLoop *workLoop);
/*! @function setNext
* @abstract Set'ter for $link eventChainNext variable.
* @param next
* Pointer to another IOEventSource instance.
*/
virtual void setNext(IOEventSource *next);
/*! @function getNext
* @abstract Get'ter for $link eventChainNext variable.
* @result value of eventChainNext.
*/
virtual IOEventSource *getNext() const;
protected:
// Methods to access the IOWorkLoop exported fields
void signalWorkAvailable();
void openGate();
void closeGate();
bool tryCloseGate();
int sleepGate(void *event, UInt32 type);
int sleepGate(void *event, AbsoluteTime deadline, UInt32 type);
void wakeupGate(void *event, bool oneThread);
public:
/*! @function setAction
* @abstract Set'ter for $link action variable.
* @param action Pointer to a C function of type IOEventSource::Action. */
virtual void setAction(IOEventSource::Action action);
/*! @function getAction
* @abstract Get'ter for $link action variable.
* @result value of action. */
virtual IOEventSource::Action getAction() const;
#ifdef __BLOCKS__
/*! @function setActionBlock
* @abstract Setter for action ivar. The current block is released, & the new block is retained.
* @param block Block pointer of type IOEventSource::ActionBlock. */
void setActionBlock(ActionBlock block);
/*! @function getActionBlock
* @abstract Getter for action ivar.
* @result Block pointer of type IOEventSource::ActionBlock, if set, or NULL. */
ActionBlock getActionBlock(ActionBlock) const;
#endif /* __BLOCKS__ */
/*! @function setRefcon
* @abstract Setter for refcon ivar. This function will assert if a block action has been set.
* @param refcon Refcon. */
void setRefcon(void *refcon);
/*! @function getRefcon
* @abstract Getter for refcon ivar.
* @result The refcon. This function will assert if a block action has been set. */
void * getRefcon() const;
/*! @function enable
* @abstract Enable event source.
* @discussion A subclass implementation is expected to respect the enabled
* state when checkForWork is called. Calling this function will cause the
* work-loop to be signalled so that a checkForWork is performed. */
virtual void enable();
/*! @function disable
* @abstract Disable event source.
* @discussion A subclass implementation is expected to respect the enabled
* state when checkForWork is called. */
virtual void disable();
/*! @function isEnabled
* @abstract Get'ter for $link enable variable.
* @result true if enabled. */
virtual bool isEnabled() const;
/*! @function getWorkLoop
* @abstract Get'ter for $link workLoop variable.
* @result value of workLoop. */
virtual IOWorkLoop *getWorkLoop() const;
/*! @function onThread
* @abstract Convenience function for workLoop->onThread.
* @result true if called on the work-loop thread.
*/
virtual bool onThread() const;
private:
OSMetaClassDeclareReservedUnused(IOEventSource, 0);
OSMetaClassDeclareReservedUnused(IOEventSource, 1);
OSMetaClassDeclareReservedUnused(IOEventSource, 2);
OSMetaClassDeclareReservedUnused(IOEventSource, 3);
OSMetaClassDeclareReservedUnused(IOEventSource, 4);
OSMetaClassDeclareReservedUnused(IOEventSource, 5);
OSMetaClassDeclareReservedUnused(IOEventSource, 6);
OSMetaClassDeclareReservedUnused(IOEventSource, 7);
};
#endif /* !_IOKIT_IOEVENTSOURCE_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOMultiMemoryDescriptor.h | /*
* Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _IOMULTIMEMORYDESCRIPTOR_H
#define _IOMULTIMEMORYDESCRIPTOR_H
#include <IOKit/IOMemoryDescriptor.h>
#include <libkern/c++/OSPtr.h>
/*! @class IOMultiMemoryDescriptor : public IOMemoryDescriptor
* @abstract The IOMultiMemoryDescriptor object describes a memory area made up of several other IOMemoryDescriptors.
* @discussion The IOMultiMemoryDescriptor object represents multiple ranges of memory, specified as an ordered list of IOMemoryDescriptors. The descriptors are chained end-to-end to make up a single contiguous buffer. */
class IOMultiMemoryDescriptor : public IOMemoryDescriptor
{
OSDeclareDefaultStructors(IOMultiMemoryDescriptor);
protected:
IOMemoryDescriptor ** _descriptors;
UInt32 _descriptorsCount;
bool _descriptorsIsAllocated;
virtual void free() APPLE_KEXT_OVERRIDE;
public:
/*! @function withDescriptors
* @abstract Create an IOMultiMemoryDescriptor to describe a memory area made up of several other IOMemoryDescriptors.
* @discussion This method creates and initializes an IOMultiMemoryDescriptor for memory consisting of a number of other IOMemoryDescriptors, chained end-to-end (in the order they appear in the array) to represent a single contiguous memory buffer. Passing the descriptor array as a reference will avoid an extra allocation.
* @param descriptors An array of IOMemoryDescriptors which make up the memory to be described.
* @param withCount The object count for the descriptors array.
* @param withDirection An I/O direction to be associated with the descriptor, which may affect the operation of the prepare and complete methods on some architectures.
* @param asReference If false, the IOMultiMemoryDescriptor object will make a copy of the descriptors array, otherwise, the array will be used in situ, avoiding an extra allocation.
* @result The created IOMultiMemoryDescriptor on success, to be released by the caller, or zero on failure. */
static OSPtr<IOMultiMemoryDescriptor> withDescriptors(
IOMemoryDescriptor ** descriptors,
UInt32 withCount,
IODirection withDirection,
bool asReference = false );
/*! @function withDescriptors
* @abstract Initialize an IOMultiMemoryDescriptor to describe a memory area made up of several other IOMemoryDescriptors.
* @discussion This method initializes an IOMultiMemoryDescriptor for memory consisting of a number of other IOMemoryDescriptors, chained end-to-end (in the order they appear in the array) to represent a single contiguous memory buffer. Passing the descriptor array as a reference will avoid an extra allocation.
* @param descriptors An array of IOMemoryDescriptors which make up the memory to be described.
* @param withCount The object count for the descriptors array.
* @param withDirection An I/O direction to be associated with the descriptor, which may affect the operation of the prepare and complete methods on some architectures.
* @param asReference If false, the IOMultiMemoryDescriptor object will make a copy of the descriptors array, otherwise, the array will be used in situ, avoiding an extra allocation.
* @result The created IOMultiMemoryDescriptor on success, to be released by the caller, or zero on failure. */
virtual bool initWithDescriptors(
IOMemoryDescriptor ** descriptors,
UInt32 withCount,
IODirection withDirection,
bool asReference = false );
/*! @function getPhysicalSegment
* @abstract Break a memory descriptor into its physically contiguous segments.
* @discussion This method returns the physical address of the byte at the given offset into the memory, and optionally the length of the physically contiguous segment from that offset.
* @param offset A byte offset into the memory whose physical address to return.
* @param length If non-zero, getPhysicalSegment will store here the length of the physically contiguous segement at the given offset.
* @result A physical address, or zero if the offset is beyond the length of the memory. */
virtual addr64_t getPhysicalSegment( IOByteCount offset,
IOByteCount * length,
IOOptionBits options = 0 ) APPLE_KEXT_OVERRIDE;
/*! @function prepare
* @abstract Prepare the memory for an I/O transfer.
* @discussion This involves paging in the memory, if necessary, and wiring it down for the duration of the transfer. The complete() method completes the processing of the memory after the I/O transfer finishes. This method needn't called for non-pageable memory.
* @param forDirection The direction of the I/O just completed, or kIODirectionNone for the direction specified by the memory descriptor.
* @result An IOReturn code. */
virtual IOReturn prepare(IODirection forDirection = kIODirectionNone) APPLE_KEXT_OVERRIDE;
/*! @function complete
* @abstract Complete processing of the memory after an I/O transfer finishes.
* @discussion This method should not be called unless a prepare was previously issued; the prepare() and complete() must occur in pairs, before and after an I/O transfer involving pageable memory.
* @param forDirection The direction of the I/O just completed, or kIODirectionNone for the direction specified by the memory descriptor.
* @result An IOReturn code. */
virtual IOReturn complete(IODirection forDirection = kIODirectionNone) APPLE_KEXT_OVERRIDE;
virtual IOReturn setPurgeable(IOOptionBits newState, IOOptionBits * oldState) APPLE_KEXT_OVERRIDE;
IOReturn setOwnership(task_t newOwner, int newLedgerTag, IOOptionBits newOptions);
/*! @function getPageCounts
* @abstract Retrieve the number of resident and/or dirty pages encompassed by an IOMemoryDescriptor.
* @discussion This method returns the number of resident and/or dirty pages encompassed by an IOMemoryDescriptor.
* @param residentPageCount - If non-null, a pointer to a byte count that will return the number of resident pages encompassed by this IOMemoryDescriptor.
* @param dirtyPageCount - If non-null, a pointer to a byte count that will return the number of dirty pages encompassed by this IOMemoryDescriptor.
* @result An IOReturn code. */
IOReturn getPageCounts(IOByteCount * residentPageCount,
IOByteCount * dirtyPageCount);
virtual uint64_t getPreparationID( void ) APPLE_KEXT_OVERRIDE;
#define IOMULTIMEMORYDESCRIPTOR_SUPPORTS_GETPAGECOUNTS 1
private:
virtual IOReturn doMap(vm_map_t addressMap,
IOVirtualAddress * atAddress,
IOOptionBits options,
IOByteCount sourceOffset = 0,
IOByteCount length = 0 ) APPLE_KEXT_OVERRIDE;
};
#endif /* !_IOMULTIMEMORYDESCRIPTOR_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOMessage.h | /*
* Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef __IOKIT_IOMESSAGE_H
#define __IOKIT_IOMESSAGE_H
#include <IOKit/IOReturn.h>
#include <IOKit/IOTypes.h>
/*!
* @header IOMessage.h
*
* Defines message type constants for several IOKit messaging API's.
*
*/
typedef UInt32 IOMessage;
#define iokit_common_msg(message) (UInt32)(sys_iokit|sub_iokit_common|message)
#define iokit_family_msg(sub, message) (UInt32)(sys_iokit|sub|message)
/*!
* @defined iokit_vendor_specific_msg
* @discussion iokit_vendor_specific_msg passes messages in the sub_iokit_vendor_specific
* subsystem. It can be used to generate messages that are used for private
* communication between vendor specific code with the IOService::message() etc. APIs.
*/
#define iokit_vendor_specific_msg(message) (UInt32)(sys_iokit|sub_iokit_vendor_specific|message)
#define kIOMessageServiceIsTerminated iokit_common_msg(0x010)
#define kIOMessageServiceIsSuspended iokit_common_msg(0x020)
#define kIOMessageServiceIsResumed iokit_common_msg(0x030)
#define kIOMessageServiceIsRequestingClose iokit_common_msg(0x100)
#define kIOMessageServiceIsAttemptingOpen iokit_common_msg(0x101)
#define kIOMessageServiceWasClosed iokit_common_msg(0x110)
#define kIOMessageServiceBusyStateChange iokit_common_msg(0x120)
#define kIOMessageConsoleSecurityChange iokit_common_msg(0x128)
#define kIOMessageServicePropertyChange iokit_common_msg(0x130)
#define kIOMessageCopyClientID iokit_common_msg(0x330)
#define kIOMessageSystemCapabilityChange iokit_common_msg(0x340)
#define kIOMessageDeviceSignaledWakeup iokit_common_msg(0x350)
/*!
* @defined kIOMessageDeviceWillPowerOff
* @discussion Indicates the device is about to move to a lower power state.
* Sent to IOKit interest notification clients of type <code>kIOAppPowerStateInterest</code>
* and <code>kIOGeneralInterest</code>.
*/
#define kIOMessageDeviceWillPowerOff iokit_common_msg(0x210)
/*!
* @defined kIOMessageDeviceHasPoweredOn
* @discussion Indicates the device has just moved to a higher power state.
* Sent to IOKit interest notification clients of type <code>kIOAppPowerStateInterest</code>
* and <code>kIOGeneralInterest</code>.
*/
#define kIOMessageDeviceHasPoweredOn iokit_common_msg(0x230)
/*! @group In-kernel system shutdown and restart notifications
*/
/*!
* @defined kIOMessageSystemWillPowerOff
* @discussion Indicates an imminent system shutdown. Recipients have a limited
* amount of time to respond, otherwise the system will timeout and
* shutdown even without a response.
* Delivered to in-kernel IOKit drivers via <code>IOService::systemWillShutdown()</code>,
* and to clients of <code>registerPrioritySleepWakeInterest()</code>.
* Never delivered to user space notification clients.
*/
#define kIOMessageSystemWillPowerOff iokit_common_msg(0x250)
/*!
* @defined kIOMessageSystemWillRestart
* @discussion Indicates an imminent system restart. Recipients have a limited
* amount of time to respond, otherwise the system will timeout and
* restart even without a response.
* Delivered to in-kernel IOKit drivers via <code>IOService::systemWillShutdown()</code>,
* and to clients of <code>registerPrioritySleepWakeInterest()</code>.
* Never delivered to user space notification clients.
*/
#define kIOMessageSystemWillRestart iokit_common_msg(0x310)
/*!
* @defined kIOMessageSystemPagingOff
* @discussion Indicates an imminent system shutdown, paging device now unavailable.
* Recipients have a limited amount of time to respond, otherwise the
* system will timeout and shutdown even without a response.
* Delivered to clients of <code>registerPrioritySleepWakeInterest()</code>.
* Never delivered to user space notification clients.
*/
#define kIOMessageSystemPagingOff iokit_common_msg(0x255)
/*! @group System sleep and wake notifications
*/
/*!
* @defined kIOMessageCanSystemSleep
* @discussion Announces/Requests permission to proceed to system sleep.
* Delivered to in-kernel IOKit drivers via <code>kIOGeneralInterest</code>
* and <code>kIOPriorityPowerStateInterest</code>.
* Delivered to user clients of <code>IORegisterForSystemPower</code>.
*/
#define kIOMessageCanSystemSleep iokit_common_msg(0x270)
/*!
* @defined kIOMessageSystemWillNotSleep
* @discussion Announces that the system has retracted a previous attempt to sleep;
* it follows <code>kIOMessageCanSystemSleep</code>.
* Delivered to in-kernel IOKit drivers via <code>kIOGeneralInterest</code>
* and <code>kIOPriorityPowerStateInterest</code>.
* Delivered to user clients of <code>IORegisterForSystemPower</code>.
*/
#define kIOMessageSystemWillNotSleep iokit_common_msg(0x290)
/*!
* @defined kIOMessageSystemWillSleep
* @discussion Announces that sleep is beginning.
* Delivered to in-kernel IOKit drivers via <code>kIOGeneralInterest</code>
* and <code>kIOPriorityPowerStateInterest</code>.
* Delivered to user clients of <code>IORegisterForSystemPower</code>.
*/
#define kIOMessageSystemWillSleep iokit_common_msg(0x280)
/*!
* @defined kIOMessageSystemWillPowerOn
* @discussion Announces that the system is beginning to power the device tree; most
* devices are unavailable at this point..
* Delivered to in-kernel IOKit drivers via <code>kIOGeneralInterest</code>
* and <code>kIOPriorityPowerStateInterest</code>.
* Delivered to user clients of <code>IORegisterForSystemPower</code>.
*/
#define kIOMessageSystemWillPowerOn iokit_common_msg(0x320)
/*!
* @defined kIOMessageSystemHasPoweredOn
* @discussion Announces that the system and its devices have woken up.
* Delivered to in-kernel IOKit drivers via <code>kIOGeneralInterest</code>
* and <code>kIOPriorityPowerStateInterest</code>.
* Delivered to user clients of <code>IORegisterForSystemPower</code>.
*/
#define kIOMessageSystemHasPoweredOn iokit_common_msg(0x300)
/*! @group Unused and deprecated notifications
*/
/*!
* @defined kIOMessageCanDevicePowerOff
* @discussion Delivered to <code>kIOAppPowerStateInterest</code> clients of
* devices that implement their own idle timeouts.
* This message type is almost never used.
*/
#define kIOMessageCanDevicePowerOff iokit_common_msg(0x200)
/*!
* @defined kIOMessageDeviceWillNotPowerOff
* @discussion This IOKit interest notification is largely unused;
* it's not very interesting.
*/
#define kIOMessageDeviceWillNotPowerOff iokit_common_msg(0x220)
/*!
* @defined kIOMessageSystemWillNotPowerOff
* @deprecated This IOKit message is unused.
*/
#define kIOMessageSystemWillNotPowerOff iokit_common_msg(0x260)
/*!
* @defined kIOMessageCanSystemPowerOff
* @deprecated This IOKit message is unused.
*/
#define kIOMessageCanSystemPowerOff iokit_common_msg(0x240)
/*!
* @defined kIOMessageDeviceWillPowerOn
* @discussion IOService power mgt does not send kIOMessageDeviceWillPowerOn.
*/
#define kIOMessageDeviceWillPowerOn iokit_common_msg(0x215)
/*!
* @defined kIOMessageDeviceHasPoweredOff
* @discussion IOService power mgt does not send kIOMessageDeviceHasPoweredOff.
*/
#define kIOMessageDeviceHasPoweredOff iokit_common_msg(0x225)
#endif /* ! __IOKIT_IOMESSAGE_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/OSMessageNotification.h | /*
* Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
*
* HISTORY
*
*/
#ifndef __OS_OSMESSAGENOTIFICATION_H
#define __OS_OSMESSAGENOTIFICATION_H
#ifdef __cplusplus
extern "C" {
#endif
#include <mach/mach_types.h>
#include <device/device_types.h>
#include <IOKit/IOReturn.h>
enum {
kFirstIOKitNotificationType = 100,
kIOServicePublishNotificationType = 100,
kIOServiceMatchedNotificationType = 101,
kIOServiceTerminatedNotificationType = 102,
kIOAsyncCompletionNotificationType = 150,
kIOServiceMessageNotificationType = 160,
kLastIOKitNotificationType = 199,
// reserved bits
kIOKitNoticationTypeMask = 0x00000FFF,
kIOKitNoticationTypeSizeAdjShift = 30,
kIOKitNoticationMsgSizeMask = 3,
};
enum {
kOSNotificationMessageID = 53,
kOSAsyncCompleteMessageID = 57,
kMaxAsyncArgs = 16
};
enum {
kIOAsyncReservedIndex = 0,
kIOAsyncReservedCount,
kIOAsyncCalloutFuncIndex = kIOAsyncReservedCount,
kIOAsyncCalloutRefconIndex,
kIOAsyncCalloutCount,
kIOMatchingCalloutFuncIndex = kIOAsyncReservedCount,
kIOMatchingCalloutRefconIndex,
kIOMatchingCalloutCount,
kIOInterestCalloutFuncIndex = kIOAsyncReservedCount,
kIOInterestCalloutRefconIndex,
kIOInterestCalloutServiceIndex,
kIOInterestCalloutCount
};
// --------------
enum {
kOSAsyncRef64Count = 8,
kOSAsyncRef64Size = kOSAsyncRef64Count * ((int) sizeof(io_user_reference_t))
};
typedef io_user_reference_t OSAsyncReference64[kOSAsyncRef64Count];
struct OSNotificationHeader64 {
mach_msg_size_t size; /* content size */
natural_t type;
OSAsyncReference64 reference;
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
unsigned char content[];
#else
unsigned char content[0];
#endif
};
#pragma pack(4)
struct IOServiceInterestContent64 {
natural_t messageType;
io_user_reference_t messageArgument[1];
};
#pragma pack()
// --------------
#if !KERNEL_USER32
enum {
kOSAsyncRefCount = 8,
kOSAsyncRefSize = 32
};
typedef natural_t OSAsyncReference[kOSAsyncRefCount] __kernel_ptr_semantics;
struct OSNotificationHeader {
mach_msg_size_t size; /* content size */
natural_t type;
OSAsyncReference reference;
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
unsigned char content[];
#else
unsigned char content[0];
#endif
};
#pragma pack(4)
struct IOServiceInterestContent {
natural_t messageType;
void * messageArgument[1];
};
#pragma pack()
#endif /* KERNEL_USER32 */
struct IOAsyncCompletionContent {
IOReturn result;
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
void * args[] __attribute__ ((packed));
#else
void * args[0] __attribute__ ((packed));
#endif
};
#ifndef __cplusplus
typedef struct OSNotificationHeader OSNotificationHeader;
typedef struct IOServiceInterestContent IOServiceInterestContent;
typedef struct IOAsyncCompletionContent IOAsyncCompletionContent;
#endif
#ifdef __cplusplus
}
#endif
#endif /* __OS_OSMESSAGENOTIFICATION_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOLib.h | /*
* Copyright (c) 1998-2016 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* Copyright (c) 1998 Apple Computer, Inc. All rights reserved.
*
* HISTORY
*
*/
#ifndef __IOKIT_IOLIB_H
#define __IOKIT_IOLIB_H
#include <stdarg.h>
#include <sys/cdefs.h>
#include <os/overflow.h>
#include <sys/appleapiopts.h>
#include <IOKit/system.h>
#include <IOKit/IOReturn.h>
#include <IOKit/IOTypes.h>
#include <IOKit/IOLocks.h>
#include <libkern/OSAtomic.h>
__BEGIN_DECLS
#include <kern/thread_call.h>
#include <kern/clock.h>
/*
* min/max macros.
*/
#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))
/*
* Safe functions to compute array sizes (saturate to a size that can't be
* allocated ever and will cause the allocation to return NULL always).
*/
static inline vm_size_t
IOMallocArraySize(vm_size_t hdr_size, vm_size_t elem_size, vm_size_t elem_count)
{
/* IOMalloc() will reject this size before even asking the VM */
const vm_size_t limit = 1ull << (8 * sizeof(vm_size_t) - 1);
vm_size_t s = hdr_size;
if (os_mul_and_add_overflow(elem_size, elem_count, s, &s) || (s & limit)) {
return limit;
}
return s;
}
/*
* These are opaque to the user.
*/
typedef thread_t IOThread;
typedef void (*IOThreadFunc)(void *argument);
/*
* Memory allocation functions.
*/
/*! @function IOMalloc
* @abstract Allocates general purpose, wired memory in the kernel map.
* @discussion 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.
* @param size Size of the memory requested.
* @result Pointer to the allocated memory, or zero on failure. */
void * IOMalloc(vm_size_t size) __attribute__((alloc_size(1)));
void * IOMallocZero(vm_size_t size) __attribute__((alloc_size(1)));
/*! @function IOFree
* @abstract Frees memory allocated with IOMalloc.
* @discussion 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.
* @param address Pointer to the allocated memory. Must be identical to result
* @of a prior IOMalloc.
* @param size Size of the memory allocated. Must be identical to size of
* @the corresponding IOMalloc */
void IOFree(void * address, vm_size_t size);
/*! @function IOMallocAligned
* @abstract Allocates wired memory in the kernel map, with an alignment restriction.
* @discussion 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.
* @param size Size of the memory requested.
* @param 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.
* @result Pointer to the allocated memory, or zero on failure. */
void * IOMallocAligned(vm_size_t size, vm_offset_t alignment) __attribute__((alloc_size(1)));
/*! @function IOFreeAligned
* @abstract Frees memory allocated with IOMallocAligned.
* @discussion 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.
* @param address Pointer to the allocated memory.
* @param size Size of the memory allocated. */
void IOFreeAligned(void * address, vm_size_t size);
/*! @function IOMallocContiguous
* @abstract Deprecated - use IOBufferMemoryDescriptor. Allocates wired memory in the kernel map, with an alignment restriction and physically contiguous.
* @discussion 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.
* @param size Size of the memory requested.
* @param 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.
* @param physicalAddress IOMallocContiguous returns the physical address of the allocated memory here, if physicalAddress is a non-zero pointer. The physicalAddress argument is deprecated and should be passed as NULL. To obtain the physical address for a memory buffer, use the IODMACommand class in conjunction with the IOMemoryDescriptor or IOBufferMemoryDescriptor classes.
* @result Virtual address of the allocated memory, or zero on failure. */
void * IOMallocContiguous(vm_size_t size, vm_size_t alignment,
IOPhysicalAddress * physicalAddress) __attribute__((deprecated)) __attribute__((alloc_size(1)));
/*! @function IOFreeContiguous
* @abstract Deprecated - use IOBufferMemoryDescriptor. Frees memory allocated with IOMallocContiguous.
* @discussion 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.
* @param address Virtual address of the allocated memory.
* @param size Size of the memory allocated. */
void IOFreeContiguous(void * address, vm_size_t size) __attribute__((deprecated));
/*! @function IOMallocPageable
* @abstract Allocates pageable memory in the kernel map.
* @discussion 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.
* @param size Size of the memory requested.
* @param 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.
* @result Pointer to the allocated memory, or zero on failure. */
void * IOMallocPageable(vm_size_t size, vm_size_t alignment) __attribute__((alloc_size(1)));
/*! @function IOMallocPageableZero
* @abstract Allocates pageable, zeroed memory in the kernel map.
* @discussion Same as IOMallocPageable but guarantees the returned memory will be zeroed.
* @param size Size of the memory requested.
* @param 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.
* @result Pointer to the allocated memory, or zero on failure. */
void * IOMallocPageableZero(vm_size_t size, vm_size_t alignment) __attribute__((alloc_size(1)));
/*! @function IOFreePageable
* @abstract Frees memory allocated with IOMallocPageable.
* @discussion 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.
* @param address Virtual address of the allocated memory.
* @param size Size of the memory allocated. */
void IOFreePageable(void * address, vm_size_t size);
/*
* IONew/IONewZero/IODelete/IOSafeDeleteNULL
*
* Those functions come in 2 variants:
*
* 1. IONew(element_type, count)
* IONewZero(element_type, count)
* IODelete(ptr, element_type, count)
* IOSafeDeleteNULL(ptr, element_type, count)
*
* Those allocate/free arrays of `count` elements of type `element_type`.
*
* 2. IONew(hdr_type, element_type, count)
* IONewZero(hdr_type, element_type, count)
* IODelete(ptr, hdr_type, element_type, count)
* IOSafeDeleteNULL(ptr, hdr_type, element_type, count)
*
* Those allocate/free arrays with `count` elements of type `element_type`,
* prefixed with a header of type `hdr_type`, like this:
*
* Those perform safe math with the sizes, checking for overflow.
* An overflow in the sizes will cause the allocation to return NULL.
*/
#define IONew(...) __IOKIT_DISPATCH(IONew, ##__VA_ARGS__)
#define IONewZero(...) __IOKIT_DISPATCH(IONewZero, ##__VA_ARGS__)
#define IODelete(...) __IOKIT_DISPATCH(IODelete, ##__VA_ARGS__)
#define IOSafeDeleteNULL(...) __IOKIT_DISPATCH(IOSafeDeleteNULL, ##__VA_ARGS__)
#define IONew_2(e_ty, count) \
((e_ty *)IOMalloc(IOMallocArraySize(0, sizeof(e_ty), count)))
#define IONew_3(h_ty, e_ty, count) \
((h_ty *)IOMalloc(IOMallocArraySize(sizeof(h_ty), sizeof(e_ty), count)))
#define IONewZero_2(e_ty, count) \
((e_ty *)IOMallocZero(IOMallocArraySize(0, sizeof(e_ty), count)))
#define IONewZero_3(h_ty, e_ty, count) \
((h_ty *)IOMallocZero(IOMallocArraySize(sizeof(h_ty), sizeof(e_ty), count)))
#define IODelete_3(ptr, e_ty, count) \
IOFree(ptr, IOMallocArraySize(0, sizeof(e_ty), count))
#define IODelete_4(ptr, h_ty, e_ty, count) \
IOFree(ptr, IOMallocArraySize(sizeof(h_ty), sizeof(e_ty), count))
#define IOSafeDeleteNULL_3(ptr, e_ty, count) ({ \
vm_size_t __s = IOMallocArraySize(0, sizeof(e_ty), count); \
IOFree(__iokit_ptr_load_and_erase(ptr), __s); \
})
#define IOSafeDeleteNULL_4(ptr, h_ty, e_ty, count) ({ \
vm_size_t __s = IOMallocArraySize(sizeof(h_ty), sizeof(e_ty), count)); \
IOFree(__iokit_ptr_load_and_erase(ptr), __s); \
})
/////////////////////////////////////////////////////////////////////////////
//
//
// These functions are now implemented in IOMapper.cpp
//
//
/////////////////////////////////////////////////////////////////////////////
/*! @function IOMappedRead8
* @abstract Read one byte from the desired "Physical" IOSpace address.
* @discussion 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.
* @param address The desired address, as returned by IOMemoryDescriptor::getPhysicalSegment.
* @result Data contained at that location */
UInt8 IOMappedRead8(IOPhysicalAddress address);
/*! @function IOMappedRead16
* @abstract Read two bytes from the desired "Physical" IOSpace address.
* @discussion 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.
* @param address The desired address, as returned by IOMemoryDescriptor::getPhysicalSegment.
* @result Data contained at that location */
UInt16 IOMappedRead16(IOPhysicalAddress address);
/*! @function IOMappedRead32
* @abstract Read four bytes from the desired "Physical" IOSpace address.
* @discussion 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.
* @param address The desired address, as returned by IOMemoryDescriptor::getPhysicalSegment.
* @result Data contained at that location */
UInt32 IOMappedRead32(IOPhysicalAddress address);
/*! @function IOMappedRead64
* @abstract Read eight bytes from the desired "Physical" IOSpace address.
* @discussion 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.
* @param address The desired address, as returned by IOMemoryDescriptor::getPhysicalSegment.
* @result Data contained at that location */
UInt64 IOMappedRead64(IOPhysicalAddress address);
/*! @function IOMappedWrite8
* @abstract Write one byte to the desired "Physical" IOSpace address.
* @discussion 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.
* @param address The desired address, as returned by IOMemoryDescriptor::getPhysicalSegment.
* @param value Data to be writen to the desired location */
void IOMappedWrite8(IOPhysicalAddress address, UInt8 value);
/*! @function IOMappedWrite16
* @abstract Write two bytes to the desired "Physical" IOSpace address.
* @discussion 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.
* @param address The desired address, as returned by IOMemoryDescriptor::getPhysicalSegment.
* @param value Data to be writen to the desired location */
void IOMappedWrite16(IOPhysicalAddress address, UInt16 value);
/*! @function IOMappedWrite32
* @abstract Write four bytes to the desired "Physical" IOSpace address.
* @discussion 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.
* @param address The desired address, as returned by IOMemoryDescriptor::getPhysicalSegment.
* @param value Data to be writen to the desired location */
void IOMappedWrite32(IOPhysicalAddress address, UInt32 value);
/*! @function IOMappedWrite64
* @abstract Write eight bytes to the desired "Physical" IOSpace address.
* @discussion 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.
* @param address The desired address, as returned by IOMemoryDescriptor::getPhysicalSegment.
* @param value Data to be writen to the desired location */
void IOMappedWrite64(IOPhysicalAddress address, UInt64 value);
/* This function is deprecated. Cache settings may be set for allocated memory with the IOBufferMemoryDescriptor api. */
IOReturn IOSetProcessorCacheMode( task_t task, IOVirtualAddress address,
IOByteCount length, IOOptionBits cacheMode ) __attribute__((deprecated));
/*! @function IOFlushProcessorCache
* @abstract Flushes the processor cache for mapped memory.
* @discussion 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.
* @param task Task the memory is mapped into.
* @param address Virtual address of the memory.
* @param length Length of the range to set.
* @result An IOReturn code. */
IOReturn IOFlushProcessorCache( task_t task, IOVirtualAddress address,
IOByteCount length );
/*! @function IOThreadSelf
* @abstract Returns the osfmk identifier for the currently running thread.
* @discussion This function returns the current thread (a pointer to the currently active osfmk thread_shuttle). */
#define IOThreadSelf() (current_thread())
/*! @function IOCreateThread
* @abstract Deprecated function - use kernel_thread_start(). Create a kernel thread.
* @discussion 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.
* @param function A C-function pointer where the thread will begin execution.
* @param argument Caller specified data to be passed to the new thread.
* @result An IOThread identifier for the new thread, equivalent to an osfmk thread_t. */
IOThread IOCreateThread(IOThreadFunc function, void *argument) __attribute__((deprecated));
/*! @function IOExitThread
* @abstract Deprecated function - use thread_terminate(). Terminate execution of current thread.
* @discussion This function destroys the currently running thread, and does not return. */
void IOExitThread(void) __attribute__((deprecated));
/*! @function IOSleep
* @abstract Sleep the calling thread for a number of milliseconds.
* @discussion This function blocks the calling thread for at least the number of specified milliseconds, giving time to other processes.
* @param milliseconds The integer number of milliseconds to wait. */
void IOSleep(unsigned milliseconds);
/*! @function IOSleepWithLeeway
* @abstract Sleep the calling thread for a number of milliseconds, with a specified leeway the kernel may use for timer coalescing.
* @discussion This function blocks the calling thread for at least the number of specified milliseconds, giving time to other processes. The kernel may also coalesce any timers involved in the delay, using the leeway given as a guideline.
* @param intervalMilliseconds The integer number of milliseconds to wait.
* @param leewayMilliseconds The integer number of milliseconds to use as a timer coalescing guideline. */
void IOSleepWithLeeway(unsigned intervalMilliseconds, unsigned leewayMilliseconds);
/*! @function IODelay
* @abstract Spin delay for a number of microseconds.
* @discussion 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.
* @param microseconds The integer number of microseconds to spin wait. */
void IODelay(unsigned microseconds);
/*! @function IOPause
* @abstract Spin delay for a number of nanoseconds.
* @discussion 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.
* @param nanoseconds The integer number of nanoseconds to spin wait. */
void IOPause(unsigned nanoseconds);
/*! @function IOLog
* @abstract Log a message to console in text mode, and /var/log/system.log.
* @discussion 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.
* @param format A printf() style format string (see printf(3) documentation).
*/
void IOLog(const char *format, ...)
__attribute__((format(printf, 1, 2)));
/*! @function IOLogv
* @abstract Log a message to console in text mode, and /var/log/system.log.
* @discussion 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. IOLogv should not be called from interrupt context.
* @param format A printf() style format string (see printf(3) documentation).
* @param ap stdarg(3) style variable arguments. */
void IOLogv(const char *format, va_list ap)
__attribute__((format(printf, 1, 0)));
#ifndef _FN_KPRINTF
#define _FN_KPRINTF
void kprintf(const char *format, ...) __printflike(1, 2);
#endif
#ifndef _FN_KPRINTF_DECLARED
#define _FN_KPRINTF_DECLARED
#endif
/*
* Convert a integer constant (typically a #define or enum) to a string
* via an array of IONamedValue.
*/
const char *IOFindNameForValue(int value,
const IONamedValue *namedValueArray);
/*
* Convert a string to an int via an array of IONamedValue. Returns
* kIOReturnSuccess of string found, else returns kIOReturnBadArgument.
*/
IOReturn IOFindValueForName(const char *string,
const IONamedValue *regValueArray,
int *value); /* RETURNED */
/*! @function Debugger
* @abstract Enter the kernel debugger.
* @discussion This function freezes the kernel and enters the builtin debugger. It may not be possible to exit the debugger without a second machine.
* @param reason A C-string to describe why the debugger is being entered. */
void Debugger(const char * reason);
#if __LP64__
#define IOPanic(reason) panic("%s", reason)
#else
void IOPanic(const char *reason) __attribute__((deprecated)) __abortlike;
#endif
#ifdef __cplusplus
class OSDictionary;
#endif
#ifdef __cplusplus
OSDictionary *
#else
struct OSDictionary *
#endif
IOBSDNameMatching( const char * name );
#ifdef __cplusplus
OSDictionary *
#else
struct OSDictionary *
#endif
IOOFPathMatching( const char * path, char * buf, int maxLen ) __attribute__((deprecated));
/*
* Convert between size and a power-of-two alignment.
*/
IOAlignment IOSizeToAlignment(unsigned int size);
unsigned int IOAlignmentToSize(IOAlignment align);
/*
* Multiply and divide routines for IOFixed datatype.
*/
static inline IOFixed
IOFixedMultiply(IOFixed a, IOFixed b)
{
return (IOFixed)((((SInt64) a) * ((SInt64) b)) >> 16);
}
static inline IOFixed
IOFixedDivide(IOFixed a, IOFixed b)
{
return (IOFixed)((((SInt64) a) << 16) / ((SInt64) b));
}
/*
* IORound and IOTrunc convenience functions, in the spirit
* of vm's round_page() and trunc_page().
*/
#define IORound(value, multiple) \
((((value) + (multiple) - 1) / (multiple)) * (multiple))
#define IOTrunc(value, multiple) \
(((value) / (multiple)) * (multiple));
#if defined(__APPLE_API_OBSOLETE)
/* The following API is deprecated */
/* The API exported by kern/clock.h
* should be used for high resolution timing. */
void IOGetTime( mach_timespec_t * clock_time) __attribute__((deprecated));
#if !defined(__LP64__)
#undef eieio
#define eieio() \
OSSynchronizeIO()
extern mach_timespec_t IOZeroTvalspec;
#endif /* !defined(__LP64__) */
#endif /* __APPLE_API_OBSOLETE */
/*
* Implementation details
*/
#define __IOKIT_COUNT_ARGS1(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, N, ...) N
#define __IOKIT_COUNT_ARGS(...) \
__IOKIT_COUNT_ARGS1(, ##__VA_ARGS__, _9, _8, _7, _6, _5, _4, _3, _2, _1, _0)
#define __IOKIT_DISPATCH1(base, N, ...) __CONCAT(base, N)(__VA_ARGS__)
#define __IOKIT_DISPATCH(base, ...) \
__IOKIT_DISPATCH1(base, __IOKIT_COUNT_ARGS(__VA_ARGS__), ##__VA_ARGS__)
#define __iokit_ptr_load_and_erase(elem) ({ \
_Static_assert(sizeof(elem) == sizeof(void *), \
"elem isn't pointer sized"); \
__auto_type __eptr = &(elem); \
__auto_type __elem = *__eptr; \
*__eptr = (__typeof__(__elem))NULL; \
__elem; \
})
__END_DECLS
#endif /* !__IOKIT_IOLIB_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/hidevent/IOHIDEventService.h | /*
*
* @APPLE_LICENSE_HEADER_START@
*
* Copyright (c) 1999-2009 Apple Computer, Inc. All Rights Reserved.
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _IOKIT_HID_IOHIDEVENTSERVICE_H
#define _IOKIT_HID_IOHIDEVENTSERVICE_H
#include <TargetConditionals.h>
#include <IOKit/IOService.h>
#include <IOKit/IOWorkLoop.h>
#include <IOKit/IOTimerEventSource.h>
#include <IOKit/hidsystem/IOHIDTypes.h>
#include <IOKit/hid/IOHIDInterface.h>
#include <IOKit/hid/IOHIDElement.h>
#include <IOKit/hid/IOHIDKeys.h>
#if KERNEL_PRIVATE
#include <IOKit/hid/IOHIDEvent.h>
#endif
#include "IOHIDUtility.h"
#include <HIDDriverKit/IOHIDEventService.h>
enum
{
kHIDDispatchOptionPointerNoAcceleration = 0x01,
kHIDDispatchOptionPointerDisplayIntegrated = 0x02,
kHIDDispatchOptionPointerAffixToScreen = kHIDDispatchOptionPointerDisplayIntegrated,
kHIDDispatchOptionPointerAbsolutToRelative = 0x04
};
enum
{
kHIDDispatchOptionScrollNoAcceleration = (1<<0),
kHIDDispatchOptionScrollMomentumAny = 0x00e,
kHIDDispatchOptionScrollMomentumContinue = (1<<1),
kHIDDispatchOptionScrollMomentumStart = (1<<2),
kHIDDispatchOptionScrollMomentumEnd = (1<<3),
kHIDDispatchOptionPhaseAny = 0xff0,
kHIDDispatchOptionPhaseBegan = (1<<4),
kHIDDispatchOptionPhaseChanged = (1<<5),
kHIDDispatchOptionPhaseEnded = (1<<6),
kHIDDispatchOptionPhaseCanceled = (1<<7),
kHIDDispatchOptionPhaseMayBegin = (1<<11),
kHIDDispatchOptionDeliveryNotificationForce = (1<<12),
kHIDDispatchOptionDeliveryNotificationSuppress = (1<<13)
};
enum
{
kHIDDispatchOptionKeyboardNoRepeat = (1<<0)
};
class IOHIDEventService;
class IOHIDPointing;
class IOHIDKeyboard;
class IOHIDConsumer;
struct TransducerData;
class IOHIDEvent;
class IOBufferMemoryDescriptor;
#ifndef _IOKIT_HID_IOHIDEVENTTYPES_H
typedef uint32_t IOHIDEventType;
typedef uint32_t IOHIDBiometricEventType;
#endif
struct KeyValueMask {
Key key;
uint32_t mask;
};
typedef void (*DebugKeyActionProc) (IOHIDEventService *self, void * parameter);
struct DebugKeyAction {
bool debugArgRequired;
uint32_t mask;
DebugKeyActionProc action;
void* parameter;
};
/*! @class IOHIDEventService : public IOService
@abstract
@discussion
*/
#if defined(KERNEL) && !defined(KERNEL_PRIVATE)
class __deprecated_msg("Use DriverKit") IOHIDEventService : public IOService
#else
class IOHIDEventService : public IOService
#endif
{
OSDeclareDefaultStructorsWithDispatch( IOHIDEventService )
friend class IOHIDPointing;
friend class IOHIDKeyboard;
friend class IOHIDConsumer;
friend class AppleEmbeddedKeyboard;
friend class IOHIDEventServiceUserClient;
friend class IOHIDEventServiceFastPathUserClient;
private:
IOHIDKeyboard * _keyboardNub;
IOHIDPointing * _pointingNub; //unused, keep to maintain layout
IOHIDConsumer * _consumerNub;
IOLock * _clientDictLock;
IORecursiveLock * _nubLock;
void * _reserved0;
bool _readyForInputReports;
struct ExpansionData {
IOService * provider;
IOWorkLoop * workLoop;
OSArray * deviceUsagePairs;
IOCommandGate * commandGate;
OSDictionary * clientDict;
IOBufferMemoryDescriptor *eventMemory;
IOLock *eventMemLock;
OSSet *outstandingActions;
struct {
UInt32 deviceID;
bool range;
bool touch;
SInt32 x;
SInt32 y;
SInt32 z;
} digitizer;
struct {
#if TARGET_OS_IPHONE
struct {
UInt32 startMask;
UInt32 mask;
UInt32 nmiHoldMask;
UInt32 nmiDelay;
UInt32 nmiTriplePressMask;
UInt32 nmiPressCount;
UInt64 nmiStartTime;
IOTimerEventSource * nmiTimer;
UInt32 stackshotHeld;
IOTimerEventSource * stackshotTimer;
} debug;
bool swapISO;
#endif
Key pressedKeys[10];
UInt32 pressedKeysMask;
bool appleVendorSupported;
} keyboard;
struct {
IOFixed x;
IOFixed y;
IOFixed z;
IOFixed rX;
IOFixed rY;
IOFixed rZ;
UInt32 buttonState;
IOOptionBits options;
IOTimerEventSource * timer;
} multiAxis;
struct {
UInt32 buttonState;
} relativePointer;
#if TARGET_OS_OSX
struct {
UInt32 buttonState;
} absolutePointer;
#ifdef POINTING_SHIM_SUPPORT
int pointingShim;
#endif
int keyboardShim;
#endif
UInt32 debugMask;
bool powerButtonNmi;
bool disableAcceleration;
};
static KeyValueMask keyMonitorTable[];
static DebugKeyAction debugKeyActionTable[];
ExpansionData * _reserved;
#ifdef POINTING_SHIM_SUPPORT
IOHIDPointing * newPointingShim (
UInt32 buttonCount = 1,
IOFixed pointerResolution = (400 << 16),
IOFixed scrollResolution = 0,
IOOptionBits options = 0 );
#endif
IOHIDKeyboard * newKeyboardShim (
UInt32 supportedModifiers = 0,
IOOptionBits options = 0 );
IOHIDConsumer * newConsumerShim ( IOOptionBits options = 0 );
void parseSupportedElements (
OSArray * elementArray,
UInt32 bootProtocol );
void processTabletElement ( IOHIDElement * element );
IOFixed determineResolution ( IOHIDElement * element );
#if TARGET_OS_IPHONE
void debuggerTimerCallback(IOTimerEventSource *sender);
void triggerDebugger();
void stackshotTimerCallback(IOTimerEventSource *sender);
#endif
bool isPowerButtonNmiEnabled() const;
void multiAxisTimerCallback(IOTimerEventSource *sender);
void calculateStandardType();
bool supportsHeadset(OSArray *elements);
protected:
virtual void free(void) APPLE_KEXT_OVERRIDE;
/*! @function handleOpen
@abstract Handle a client open on the interface.
@discussion This method is called by IOService::open() with the
arbitration lock held, and must return true to accept the client open.
This method will in turn call handleClientOpen() to qualify the client
requesting the open.
@param client The client object that requested the open.
@param options Options passed to IOService::open().
@param argument Argument passed to IOService::open().
@result true to accept the client open, false otherwise. */
virtual bool handleOpen(IOService * client,
IOOptionBits options,
void * argument) APPLE_KEXT_OVERRIDE;
/*! @function handleClose
@abstract Handle a client close on the interface.
@discussion This method is called by IOService::close() with the
arbitration lock held. This method will in turn call handleClientClose()
to notify interested subclasses about the client close. If this represents
the last close, then the interface will also close the controller before
this method returns. The controllerWillClose() method will be called before
closing the controller. Subclasses should not override this method.
@param client The client object that requested the close.
@param options Options passed to IOService::close(). */
virtual void handleClose(IOService * client, IOOptionBits options) APPLE_KEXT_OVERRIDE;
/*! @function handleIsOpen
@abstract Query whether a client has an open on the interface.
@discussion This method is always called by IOService with the
arbitration lock held. Subclasses should not override this method.
@result true if the specified client, or any client if none (0) is
specified, presently has an open on this object. */
virtual bool handleIsOpen(const IOService * client) const APPLE_KEXT_OVERRIDE;
/*! @function handleStart
@abstract Prepare the hardware and driver to support I/O operations.
@discussion IOHIDEventService will call this method from start() before
any I/O operations are issued to the concrete subclass. Methods
such as getReportElements() are only called after handleStart()
has returned true. A subclass that overrides this method should
begin its implementation by calling the version in super, and
then check the return value.
@param provider The provider argument passed to start().
@result True on success, or false otherwise. Returning false will
cause start() to fail and return false. */
virtual bool handleStart( IOService * provider );
/*! @function handleStop
@abstract Quiesce the hardware and stop the driver.
@discussion IOHIDEventService will call this method from stop() to
signal that the hardware should be quiesced and the driver stopped.
A subclass that overrides this method should end its implementation
by calling the version in super.
@param provider The provider argument passed to stop(). */
virtual void handleStop( IOService * provider );
virtual OSString * getTransport ();
virtual UInt32 getLocationID ();
virtual UInt32 getVendorID ();
virtual UInt32 getVendorIDSource ();
virtual UInt32 getProductID ();
virtual UInt32 getVersion ();
virtual UInt32 getCountryCode ();
virtual OSString * getManufacturer ();
virtual OSString * getProduct ();
virtual OSString * getSerialNumber ();
virtual OSArray * getReportElements();
virtual IOReturn setElementValue (
UInt32 usagePage,
UInt32 usage,
UInt32 value );
virtual UInt32 getElementValue (
UInt32 usagePage,
UInt32 usage );
virtual void dispatchKeyboardEvent(
AbsoluteTime timeStamp,
UInt32 usagePage,
UInt32 usage,
UInt32 value,
IOOptionBits options = 0 );
virtual void dispatchRelativePointerEvent(
AbsoluteTime timeStamp,
SInt32 dx,
SInt32 dy,
UInt32 buttonState,
IOOptionBits options = 0 );
void dispatchRelativePointerEventWithFixed(
AbsoluteTime timeStamp,
IOFixed dx,
IOFixed dy,
UInt32 buttonState,
IOOptionBits options = 0 );
virtual void dispatchAbsolutePointerEvent(
AbsoluteTime timeStamp,
SInt32 x,
SInt32 y,
IOGBounds * bounds,
UInt32 buttonState,
bool inRange,
SInt32 tipPressure,
SInt32 tipPressureMin,
SInt32 tipPressureMax,
IOOptionBits options = 0 );
virtual void dispatchScrollWheelEvent(
AbsoluteTime timeStamp,
SInt32 deltaAxis1,
SInt32 deltaAxis2,
SInt32 deltaAxis3,
IOOptionBits options = 0 );
virtual void dispatchTabletPointerEvent(
AbsoluteTime timeStamp,
UInt32 transducerID,
SInt32 x,
SInt32 y,
SInt32 z,
IOGBounds * bounds,
UInt32 buttonState,
SInt32 tipPressure,
SInt32 tipPressureMin,
SInt32 tipPressureMax,
SInt32 barrelPressure,
SInt32 barrelPressureMin,
SInt32 barrelPressureMax,
SInt32 tiltX,
SInt32 tiltY,
UInt32 twist,
IOOptionBits options = 0 );
virtual void dispatchTabletProximityEvent(
AbsoluteTime timeStamp,
UInt32 transducerID,
bool inRange,
bool invert,
UInt32 vendorTransducerUniqueID = 0,
UInt32 vendorTransducerSerialNumber = 0,
IOOptionBits options = 0 );
public:
bool readyForReports();
virtual bool init(OSDictionary * properties = 0) APPLE_KEXT_OVERRIDE;
virtual bool start( IOService * provider ) APPLE_KEXT_OVERRIDE;
virtual void stop( IOService * provider ) APPLE_KEXT_OVERRIDE;
virtual bool matchPropertyTable(OSDictionary * table, SInt32 * score) APPLE_KEXT_OVERRIDE;
virtual IOReturn setSystemProperties( OSDictionary * properties );
virtual IOReturn setProperties( OSObject * properties ) APPLE_KEXT_OVERRIDE;
virtual IOReturn newUserClient(
task_t owningTask,
void * securityID,
UInt32 type,
OSDictionary * properties,
IOUserClient ** handler ) APPLE_KEXT_OVERRIDE;
protected:
OSMetaClassDeclareReservedUsed(IOHIDEventService, 0);
virtual OSArray * getDeviceUsagePairs();
OSMetaClassDeclareReservedUsed(IOHIDEventService, 1);
virtual UInt32 getReportInterval();
OSMetaClassDeclareReservedUsed(IOHIDEventService, 2);
enum {
kMultiAxisOptionRotationForTranslation = (1<<0),
kMultiAxisOptionZForScroll = (1<<1)
};
/*!
@function dispatchMultiAxisPointerEvent
@abstract Dispatch multi-axis pointer event
@discussion This is meant to be used with joysticks or multi-axis pointer devices such as those with
with 6 degrees of freedom. This function will generate related relative pointer and scroll
event associated with movement.
@param timeStamp AbsoluteTime representing origination of event
@param buttonState Button mask where bit0 is the primary button, bit1 secondary and so forth
@param x Absolute location of pointer along the x-axis from -1.0 to 1.0 in 16:16 fixed point.
@param y Absolute location of pointer along the y-axis from -1.0 to 1.0 in 16:16 fixed point.
@param z Absolute location of pointer along the z-axis from -1.0 to 1.0 in 16:16 fixed point.
@param rX Absolute rotation of pointer around the x-axis from -1.0 to 1.0 in 16:16 fixed point.
@param rY Absolute rotation of pointer around the y-axis from -1.0 to 1.0 in 16:16 fixed point.
@param rZ Absolute rotation of pointer around the z-axis from -1.0 to 1.0 in 16:16 fixed point.
@param options Additional options to be used when dispatching event such as leveraging rotational
axis for translation or using the z axis for vertical scrolling.
*/
virtual void dispatchMultiAxisPointerEvent(
AbsoluteTime timeStamp,
UInt32 buttonState,
IOFixed x,
IOFixed y,
IOFixed z,
IOFixed rX = 0,
IOFixed rY = 0,
IOFixed rZ = 0,
IOOptionBits options = 0 );
enum {
kDigitizerInvert = (1<<0),
kDigitizerCapabilityButtons = (1<<16),
kDigitizerCapabilityPressure = (1<<16),
kDigitizerCapabilityTangentialPressure = (1<<16),
kDigitizerCapabilityZ = (1<<16),
kDigitizerCapabilityTiltX = (1<<16),
kDigitizerCapabilityTiltY = (1<<16),
kDigitizerCapabilityTwist = (1<<16),
};
enum {
kDigitizerTransducerTypeStylus = 0,
kDigitizerTransducerTypePuck,
kDigitizerTransducerTypeFinger,
kDigitizerTransducerTypeHand
};
typedef UInt32 DigitizerTransducerType;
/*!
@function dispatchDigitizerEvent
@abstract Dispatch tablet events without orientation
@discussion This is meant to be used with transducers without any orientation.
@param timeStamp AbsoluteTime representing origination of event
@param ID ID of the transducer generating the event
@param type Type of the transducer generating the event
@param inRange Details whether the transducer is in promitity to digitizer surface
@param buttonState Button mask where bit0 is the primary button, bit1 secondary and so forth
@param x Absolute location of transducer along the x-axis from 0.0 to 1.0 in
16:16 fixed point.
@param y Absolute location of transducer along the y-axis from 0.0 to 1.0 in
16:16 fixed point.
@param z Absolute location of transducer along the z-axis from 0.0 to 1.0 in
16:16 fixed point. This is typically used to determine the distance
between the transducer and surface
@param tipPressure Absolute pressure exerted on surface by tip from 0.0 to 1.0 in 16:16
fixed point.
@param auxPressure Absolute pressure exerted on transducer from 0.0 to 1.0 in 16:16 fixed point.
@param options Additional options to be used when dispatching event.
*/
OSMetaClassDeclareReservedUsed(IOHIDEventService, 3);
virtual void dispatchDigitizerEvent(
AbsoluteTime timeStamp,
UInt32 transducerID,
DigitizerTransducerType type,
bool inRange,
UInt32 buttonState,
IOFixed x,
IOFixed y,
IOFixed z = 0,
IOFixed tipPressure = 0,
IOFixed auxPressure = 0,
IOFixed twist = 0,
IOOptionBits options = 0 );
/*!
@function dispatchDigitizerEventWithTiltOrientation
@abstract Dispatch tablet events with tilt orientation
@discussion This is meant to be used with transducers that leverage tilt orientation
@param timeStamp AbsoluteTime representing origination of event
@param ID ID of the transducer generating the event
@param type Type of the transducer generating the event
@param inRange Details whether the transducer is in promitity to digitizer surface
@param buttonState Button mask where bit0 is the primary button, bit1 secondary and so forth
@param x Absolute location of transducer along the x-axis from 0.0 to 1.0 in
16:16 fixed point.
@param y Absolute location of transducer along the y-axis from 0.0 to 1.0 in
16:16 fixed point.
@param z Absolute location of transducer along the z-axis from 0.0 to 1.0 in
16:16 fixed point. This is typically used to determine the distance
between the transducer and surface
@param tipPressure Absolute pressure exerted on surface by tip from 0.0 to 1.0 in 16:16
fixed point.
@param auxPressure Absolute pressure exerted on transducer from 0.0 to 1.0 in 16:16 fixed point.
@param twist Absolute clockwise rotation along the transducer's major axis from 0.0 to
360.0 degrees in 16:16 fixed point.
@param tiltX Absolute plane angle between the Y-Z plane and the plane containing the
transducer axis and the Y axis. A positive X tilt is to the right. Value is
represented in degrees from -90.0 to 90.0 in 16:16 fixed point.
@param tiltY Absolute plane angle between the X-Z plane and the plane containing the
transducer axis and the X axis. A positive Y tilt is towards the user. Value
is represented in degrees from -90.0 to 90.0 in 16:16 fixed point.
@param options Additional options to be used when dispatching event.
*/
OSMetaClassDeclareReservedUsed(IOHIDEventService, 4);
virtual void dispatchDigitizerEventWithTiltOrientation(
AbsoluteTime timeStamp,
UInt32 ID,
DigitizerTransducerType type,
bool inRange,
UInt32 buttonState,
IOFixed x,
IOFixed y,
IOFixed z = 0,
IOFixed tipPressure = 0, // 0.0-1.0 in 16:16 fixed
IOFixed auxPressure = 0, // 0.0-1.0 in 16:16 fixed
IOFixed twist = 0,
IOFixed tiltX = 0,
IOFixed tiltY = 0,
IOOptionBits options = 0 );
/*!
@function dispatchDigitizerEventWithPolarOrientation
@abstract Dispatch tablet events with polar orientation
@discussion This is meant to be used with transducers that leverage polar orientation
@param timeStamp AbsoluteTime representing origination of event
@param ID ID of the transducer generating the event
@param type Type of the transducer generating the event
@param inRange Details whether the transducer is in promitity to digitizer surface
@param buttonState Button mask where bit0 is the primary button, bit1 secondary and so forth
@param x Absolute location of transducer along the x-axis from 0.0 to 1.0 in
16:16 fixed point.
@param y Absolute location of transducer along the y-axis from 0.0 to 1.0 in
16:16 fixed point.
@param z Absolute location of transducer along the z-axis from 0.0 to 1.0 in
16:16 fixed point. This is typically used to determine the distance
between the transducer and surface
@param tipPressure Absolute pressure exerted on surface by tip from 0.0 to 1.0 in 16:16
fixed point.
@param auxPressure Absolute pressure exerted on transducer from 0.0 to 1.0 in 16:16 fixed point.
@param twist Absolute clockwise rotation along the transducer's major axis from 0.0 to
360.0 degrees in 16:16 fixed point.
@param altitude Specifies angle with the X-Y plane thorugh a signed, semicircular range.
Positive values specify an angle downward and toward the positive Z axis.
Value is represented in degrees from -180.0 to 180.0 in 16:16 fixed point.
@param azimuth Counter clockwise rotation of the cursor around the Z-axis through a full
circular range. Value is represented in degrees from 0.0 to 360.0 in 16:16
fixed point.
@param options Additional options to be used when dispatching event.
*/
OSMetaClassDeclareReservedUsed(IOHIDEventService, 5);
virtual void dispatchDigitizerEventWithPolarOrientation(
AbsoluteTime timeStamp,
UInt32 transducerID,
DigitizerTransducerType type,
bool inRange,
UInt32 buttonState,
IOFixed x,
IOFixed y,
IOFixed z = 0,
IOFixed tipPressure = 0, // 0.0-1.0 in 16:16 fixed
IOFixed tanPressure = 0, // 0.0-1.0 in 16:16 fixed
IOFixed twist = 0,
IOFixed altitude = 0,
IOFixed azimuth = 0,
IOOptionBits options = 0 );
/*!
@function dispatchUnicodeEvent
@abstract Dispatch unicode events
@discussion The HID specification provides a means to dispatch unicode characters from HID
compliant devices. The original method was to leverage the unicode page to deliver UTF-16 LE
characters by way of a usage page selector.
@param timeStamp AbsoluteTime representing origination of event
@param length Length of unicode payload
@param payload character payload
@param quality A fixed point value from 0.0 to 1.0 that represents that quality/confidence of the event.
@param options Additional options to be used when dispatching event.
*/
OSMetaClassDeclareReservedUsed(IOHIDEventService, 6);
enum {
kUnicodeEncodingTypeUTF8 = 0,
kUnicodeEncodingTypeUTF16LE,
kUnicodeEncodingTypeUTF16BE,
kUnicodeEncodingTypeUTF32LE,
kUnicodeEncodingTypeUTF32BE,
};
typedef UInt32 UnicodeEncodingType;
virtual void dispatchUnicodeEvent(
AbsoluteTime timeStamp,
UInt8 * payload,
UInt32 length,
UnicodeEncodingType encoding = kUnicodeEncodingTypeUTF16LE,
IOFixed quality = (1<<16),
IOOptionBits options = 0);
private:
enum {
kDigitizerOrientationTypeTilt = 0,
kDigitizerOrientationTypePolar,
kDigitizerOrientationTypeQuality
};
typedef UInt32 DigitizerOrientationType;
void dispatchDigitizerEventWithOrientation(
AbsoluteTime timeStamp,
UInt32 transducerID,
DigitizerTransducerType type,
bool inRange,
UInt32 buttonState,
IOFixed x,
IOFixed y,
IOFixed z = 0,
IOFixed tipPressure = 0,
IOFixed auxPressure = 0,
IOFixed twist = 0,
DigitizerOrientationType orientationType = kDigitizerOrientationTypeTilt,
IOFixed * orientationParams = NULL,
UInt32 orientationParamCount = 0,
IOOptionBits options = 0 );
public:
typedef void (*Action)(OSObject *target, OSObject * sender, void *context, OSObject *event, IOOptionBits options);
OSMetaClassDeclareReservedUsed(IOHIDEventService, 7);
virtual bool open(
IOService * client,
IOOptionBits options,
void * context,
Action action);
protected:
OSMetaClassDeclareReservedUsed(IOHIDEventService, 8);
virtual void dispatchEvent(IOHIDEvent * event, IOOptionBits options=0);
OSMetaClassDeclareReservedUsed(IOHIDEventService, 9);
virtual UInt32 getPrimaryUsagePage();
OSMetaClassDeclareReservedUsed(IOHIDEventService, 10);
virtual UInt32 getPrimaryUsage();
static void debugActionSysdiagnose(IOHIDEventService* self, void *parameter);
static void debugActionNMI(IOHIDEventService* self, void *parameter);
static void powerButtonNMI(IOHIDEventService* self, void *parameter);
public:
OSMetaClassDeclareReservedUsed(IOHIDEventService, 11);
virtual IOHIDEvent * copyEvent(
IOHIDEventType type,
IOHIDEvent * matching = 0,
IOOptionBits options = 0);
protected:
/*!
@function dispatchStandardGameControllerEvent
@abstract Dispatch standard game controller event
@discussion This is meant to dispatch a conforming standard game controller event that includes the
following: Direction Pad, Face Buttons, and Left and Right Shoulder Buttons.
@param timeStamp AbsoluteTime representing origination of event
@param dpadUp Direction pad up with a fixed value between 0.0 and 1.0
@param dpadDown Direction pad down with a fixed value between 0.0 and 1.0
@param dpadLeft Direction pad left with a fixed value between 0.0 and 1.0
@param dpadRight Direction pad right with a fixed value between 0.0 and 1.0
@param faceX Face button X with a fixed value between 0.0 and 1.0
@param faceY Face button Y with a fixed value between 0.0 and 1.0
@param faceA Face button A with a fixed value between 0.0 and 1.0
@param faceB Face button B with a fixed value between 0.0 and 1.0
@param shoulderL Left shoulder button with a fixed value between 0.0 and 1.0
@param shoulderR Right shoulder button with a fixed value between 0.0 and 1.0
@param options Additional options to be defined.
*/
OSMetaClassDeclareReservedUsed(IOHIDEventService, 12);
virtual void dispatchStandardGameControllerEvent(
AbsoluteTime timeStamp,
IOFixed dpadUp,
IOFixed dpadDown,
IOFixed dpadLeft,
IOFixed dpadRight,
IOFixed faceX,
IOFixed faceY,
IOFixed faceA,
IOFixed faceB,
IOFixed shoulderL,
IOFixed shoulderR,
IOOptionBits options = 0 );
/*!
@function dispatchExtendedGameControllerEvent
@abstract Dispatch extended game controller event
@discussion This is meant to dispatch a conforming extended game controller event that includes the
following: Direction Pad, Face Buttons, Left and Right Joysticks and 2 Left and 2 Right Shoulder Buttons.
@param timeStamp AbsoluteTime representing origination of event
@param dpadUp Direction pad up with a fixed value between 0.0 and 1.0
@param dpadDown Direction pad down with a fixed value between 0.0 and 1.0
@param dpadLeft Direction pad left with a fixed value between 0.0 and 1.0
@param dpadRight Direction pad right with a fixed value between 0.0 and 1.0
@param faceX Face button X with a fixed value between 0.0 and 1.0
@param faceY Face button Y with a fixed value between 0.0 and 1.0
@param faceA Face button A with a fixed value between 0.0 and 1.0
@param faceB Face button B with a fixed value between 0.0 and 1.0
@param shoulderL1 Top left shoulder button with a fixed value between 0.0 and 1.0
@param shoulderR1 Top right shoulder button with a fixed value between 0.0 and 1.0
@param shoulderL2 Bottom left shoulder button with a fixed value between 0.0 and 1.0
@param shoulderR2 Bottom right shoulder button with a fixed value between 0.0 and 1.0
@param joystickX Joystick X axis with a fixed value between -1.0 and 1.0
@param joystickY Joystick Y axis with a fixed value between -1.0 and 1.0
@param joystickZ Joystick Z axis with a fixed value between -1.0 and 1.0
@param joystickRz Joystick Rz axis with a fixed value between -1.0 and 1.0
@param options Additional options to be defined.
*/
OSMetaClassDeclareReservedUsed(IOHIDEventService, 13);
virtual void dispatchExtendedGameControllerEvent(
AbsoluteTime timeStamp,
IOFixed dpadUp,
IOFixed dpadDown,
IOFixed dpadLeft,
IOFixed dpadRight,
IOFixed faceX,
IOFixed faceY,
IOFixed faceA,
IOFixed faceB,
IOFixed shoulderL1,
IOFixed shoulderR1,
IOFixed shoulderL2,
IOFixed shoulderR2,
IOFixed joystickX,
IOFixed joystickY,
IOFixed joystickZ,
IOFixed joystickRz,
IOOptionBits options = 0 );
/*!
@function dispatchBiometricEvent
@abstract Dispatch biometric event
@param timeStamp AbsoluteTime representing origination of event.
@param level Float value from 0 - 1.0 detailing the current level.
@param eventType The type of biometric event.
@param options Additional options to be defined.
*/
OSMetaClassDeclareReservedUsed(IOHIDEventService, 14);
virtual void dispatchBiometricEvent(
AbsoluteTime timeStamp,
IOFixed level,
IOHIDBiometricEventType eventType,
IOOptionBits options = 0);
/*!
@function copyEventForClient
@abstract Copy event/events for client
@dicussion function called NOT on service workloop. It is guaranteed that function call will not occur once service closed by this client
@param copySpec Event copy spec (If copySpec is an OSData object, physical copy needs to be made if callee intends to retain data)
@param options options
@param clientContext client identifier
*/
OSMetaClassDeclareReservedUsed(IOHIDEventService, 15);
virtual IOHIDEvent * copyEventForClient (OSObject * copySpec, IOOptionBits options, void * clientContext);
/*!
@function copyPropertyForClient
@abstract Copy property for client
@dicussion function called on service workloop
@param aKey property key
@param clientContext client identifier
*/
OSMetaClassDeclareReservedUsed(IOHIDEventService, 16);
virtual OSObject * copyPropertyForClient (const char * aKey, void * clientContext) const;
/*!
@function setPropertiesForClient
@abstract Set properties for client
@dicussion function called on service workloop
@param properties properties object
@param clientContext client identifier
*/
OSMetaClassDeclareReservedUsed(IOHIDEventService, 17);
virtual IOReturn setPropertiesForClient (OSObject * properties, void * clientContext);
/*!
@function openForClient
@abstract open service for client
@dicussion function called on service workloop
@param client client service
@param options options
@param property client property
@param clientContext client identifier should be provided by callee, will be used for all subsequent ...Client calls. It is safe to release memory associated with parameter at close
*/
OSMetaClassDeclareReservedUsed(IOHIDEventService, 18);
virtual bool openForClient (IOService * client, IOOptionBits options, OSDictionary *property, void ** clientContext);
/*!
@function closeForClient
@abstract close service for client
@param clientContext client identifier
@param options options
*/
OSMetaClassDeclareReservedUsed(IOHIDEventService, 19);
virtual void closeForClient(IOService *client, void *context, IOOptionBits options = 0);
/*!
@function dispatchExtendedGameControllerEvent
@abstract Dispatch extended game controller event
@discussion This is meant to dispatch a conforming extended game controller event that includes the
following: Direction Pad, Face Buttons, Left and Right Joysticks and 2 Left and 2 Right Shoulder Buttons.
@param timeStamp AbsoluteTime representing origination of event
@param dpadUp Direction pad up with a fixed value between 0.0 and 1.0
@param dpadDown Direction pad down with a fixed value between 0.0 and 1.0
@param dpadLeft Direction pad left with a fixed value between 0.0 and 1.0
@param dpadRight Direction pad right with a fixed value between 0.0 and 1.0
@param faceX Face button X with a fixed value between 0.0 and 1.0
@param faceY Face button Y with a fixed value between 0.0 and 1.0
@param faceA Face button A with a fixed value between 0.0 and 1.0
@param faceB Face button B with a fixed value between 0.0 and 1.0
@param shoulderL1 Top left shoulder button with a fixed value between 0.0 and 1.0
@param shoulderR1 Top right shoulder button with a fixed value between 0.0 and 1.0
@param shoulderL2 Bottom left shoulder button with a fixed value between 0.0 and 1.0
@param shoulderR2 Bottom right shoulder button with a fixed value between 0.0 and 1.0
@param joystickX Joystick X axis with a fixed value between -1.0 and 1.0
@param joystickY Joystick Y axis with a fixed value between -1.0 and 1.0
@param joystickZ Joystick Z axis with a fixed value between -1.0 and 1.0
@param joystickRz Joystick Rz axis with a fixed value between -1.0 and 1.0
@param thumbstickButtonLeft Joystick left thumbstick button with boolean value true/false for button down/up
@param thumbstickButtonRight Joystick right thumbstick button with boolean value true/false for button down/up
@param options Additional options to be defined.
*/
OSMetaClassDeclareReservedUsed(IOHIDEventService, 20);
virtual void dispatchExtendedGameControllerEventWithThumbstickButtons(
AbsoluteTime timeStamp,
IOFixed dpadUp,
IOFixed dpadDown,
IOFixed dpadLeft,
IOFixed dpadRight,
IOFixed faceX,
IOFixed faceY,
IOFixed faceA,
IOFixed faceB,
IOFixed shoulderL1,
IOFixed shoulderR1,
IOFixed shoulderL2,
IOFixed shoulderR2,
IOFixed joystickX,
IOFixed joystickY,
IOFixed joystickZ,
IOFixed joystickRz,
boolean_t thumbstickButtonLeft,
boolean_t thumbstickButtonRight,
IOOptionBits options = 0 );
OSMetaClassDeclareReservedUsed(IOHIDEventService, 21);
virtual IOHIDEvent *copyMatchingEvent(OSDictionary *matching);
OSMetaClassDeclareReservedUsed(IOHIDEventService, 22);
virtual void dispatchScrollWheelEventWithFixed(AbsoluteTime timeStamp,
IOFixed deltaAxis1,
IOFixed deltaAxis2,
IOFixed deltaAxis3,
IOOptionBits options = 0);
OSMetaClassDeclareReservedUsed(IOHIDEventService, 23);
virtual void dispatchKeyboardEvent(AbsoluteTime timeStamp,
UInt32 usagePage,
UInt32 usage,
UInt32 value,
UInt8 pressCount,
UInt8 longPress,
UInt8 clickSpeed,
IOOptionBits options = 0 );
/*!
@function completeCopyEvent
@abstract Completion of call to DriverKit to copy matching event
@discussion Called by DriverKit to complete copy matching event requets
@param action Action
@param event Copied event or NULL
@param context Context associated with request
*/
OSMetaClassDeclareReservedUsed(IOHIDEventService, 24);
virtual void completeCopyEvent (OSAction * action, IOHIDEvent * event, uint64_t context);
/*!
@function completeSetProperties
@abstract Completion of call to DriverKit to set properties call
@discussion Called by DriverKit to complete set properties requests
@param action Action
@param status Return status of the set properties call
@param context Context associated with request
*/
OSMetaClassDeclareReservedUsed(IOHIDEventService, 25);
virtual void completeSetProperties(OSAction * action, IOReturn status, uint64_t context);
/*!
@function completeSetLED
@abstract Completion of call to DriverKit to set LED call
@discussion Called by DriverKit to complete set LED requests
@param action Action
@param status Return status of the set LED call
@param context Context associated with request
*/
OSMetaClassDeclareReservedUsed(IOHIDEventService, 26);
virtual void completeSetLED(OSAction * action, IOReturn status, uint64_t context);
OSMetaClassDeclareReservedUnused(IOHIDEventService, 27);
OSMetaClassDeclareReservedUnused(IOHIDEventService, 28);
OSMetaClassDeclareReservedUnused(IOHIDEventService, 29);
OSMetaClassDeclareReservedUnused(IOHIDEventService, 30);
OSMetaClassDeclareReservedUnused(IOHIDEventService, 31);
public:
virtual void close( IOService * forClient, IOOptionBits options = 0 ) APPLE_KEXT_OVERRIDE;
/*! @function message
@abstract Receives messages delivered from an attached provider.
@discussion Handles the <code>kIOMessageDeviceSignaledWakeup</code> message
from a provider identifying the IOHIDDevice as the wakeup source.
@param type A type defined in <code>IOMessage.h</code>.
@param provider The provider from which the message originates.
@param argument An argument defined by the message type.
@result An IOReturn code defined by the message type.
*/
virtual IOReturn message(UInt32 type, IOService * provider, void * argument) APPLE_KEXT_OVERRIDE;
protected:
};
#endif /* !_IOKIT_HID_IOHIDEVENTSERVICE_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/hidevent/IOHIDUtility.h | /*
*
* @APPLE_LICENSE_HEADER_START@
*
* Copyright (c) 2016 Apple Computer, Inc. All Rights Reserved.
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef IOHIDUtility_h
#define IOHIDUtility_h
#include <IOKit/IOTypes.h>
#include <IOKit/hid/IOHIDUsageTables.h>
enum {
kKeyMaskCtrl = 0x0001,
kKeyMaskShift = 0x0002,
kKeyMaskAlt = 0x0004,
kKeyMaskLeftCommand = 0x0008,
kKeyMaskRightCommand = 0x0010,
kKeyMaskPeriod = 0x0020,
kKeyMaskComma = 0x0040,
kKeyMaskSlash = 0x0080,
kKeyMaskEsc = 0x0100,
kKeyMaskFn = 0x0200,
kKeyMaskDelete = 0x0400,
kKeyMaskPower = 0x0800,
kKeyMaskUnknown = 0x80000000
};
struct Key {
uint64_t _value;
bool _modified;
Key ():_value(0), _modified(false){}
Key (uint32_t usagePage, uint32_t usage):_value(((uint64_t)usagePage << 32) | usage), _modified(false) {}
Key (uint32_t usagePage, uint32_t usage, bool modified):_value(((uint64_t)usagePage << 32) | usage), _modified(modified) {}
Key (uint64_t usageAndUsagePage): _value (usageAndUsagePage), _modified(false) {}
friend bool operator==(const Key &lhs, const Key &rhs) {
return (lhs._value == rhs._value);
}
friend bool operator<(const Key &lhs, const Key &rhs) {
return (lhs._value < rhs._value);
}
uint32_t usage () const {return ((uint32_t*)&_value)[0];}
uint32_t usagePage () const {return((uint32_t*)&_value)[1];}
bool isValid () const {return _value != 0;}
bool isModifier () const;
bool isTopRow () const {
bool result = false;
if ((usagePage() == kHIDPage_KeyboardOrKeypad) &&
(((usage() >= kHIDUsage_Keyboard1) && (usage() <= kHIDUsage_Keyboard0)) ||
(usage() == kHIDUsage_KeyboardHyphen) ||
(usage() == kHIDUsage_KeyboardEqualSign) ||
(usage() == kHIDUsage_KeyboardGraveAccentAndTilde) ||
(usage() == kHIDUsage_KeyboardDeleteOrBackspace))) {
result = true;
}
return result;
}
uint32_t modifierMask () const;
};
struct KeyAttribute {
uint32_t _flags;
KeyAttribute (uint32_t flags = 0):_flags(flags) {};
};
#endif /* IOHIDUtility_h */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/hidevent/IOHIDEventDriver.h | /*
*
* @APPLE_LICENSE_HEADER_START@
*
* Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _IOKIT_HID_IOHIDEVENTDRIVER_H
#define _IOKIT_HID_IOHIDEVENTDRIVER_H
#include <IOKit/IOService.h>
#include <IOKit/hidsystem/IOHIDTypes.h>
#include <IOKit/hid/IOHIDInterface.h>
#include <IOKit/hidevent/IOHIDEventService.h>
#include <IOKit/IOWorkLoop.h>
#include <IOKit/IOCommandGate.h>
class DigitizerTransducer;
class EventElementCollection;
class IOHIDEvent;
/*! @class IOHIDEventDriver : public IOHIDEventService
@abstract
@discussion
*/
#if defined(KERNEL) && !defined(KERNEL_PRIVATE)
class __deprecated_msg("Use DriverKit") IOHIDEventDriver : public IOHIDEventService
#else
class IOHIDEventDriver : public IOHIDEventService
#endif
{
OSDeclareDefaultStructors( IOHIDEventDriver )
private:
IOHIDInterface * _interface;
void * _reservedVoid[3] __unused;
OSArray * _supportedElements;
UInt32 _bootSupport;
bool _multipleReports;
bool _authenticatedDevice;
bool _reservedBool __unused;
UInt32 _reservedUInt32 __unused;
bool _reservedBool1 __unused;
struct ExpansionData {
SInt32 absoluteAxisRemovalPercentage;
SInt32 preferredAxisRemovalPercentage;
struct {
OSArray * elements;
} led;
struct {
OSArray * elements;
} scroll;
struct {
OSArray * elements;
bool disabled;
} relative;
struct {
OSArray * elements;
OSArray * blessedUsagePairs;
UInt8 bootMouseData[4];
bool appleVendorSupported;
IOHIDElement * keyboardPower;
} keyboard;
struct {
IOHIDElement * deviceModeElement;
OSArray * transducers;
OSArray * transducerStates;
IOHIDElement * touchCancelElement;
bool native;
bool collectionDispatch;
IOFixed centroidX;
IOFixed centroidY;
IOHIDElement * relativeScanTime;
IOHIDElement * surfaceSwitch;
IOHIDElement * reportRate;
OSArray * buttons;
} digitizer;
struct {
OSArray * elements;
UInt32 capable;
UInt32 sendingReportID;
IOFixed axis[6];
UInt32 buttonState;
IOOptionBits options;
bool disabled;
} multiAxis;
struct {
IOHIDElement * gestureStateElement;
OSArray * legacyElements;
OSArray * gesturesCandidates;
} unicode;
struct {
bool extended;
bool formFitting;
OSArray * elements;
UInt32 capable;
UInt32 sendingReportID;
struct {
IOFixed up;
IOFixed down;
IOFixed left;
IOFixed right;
} dpad;
struct {
IOFixed x;
IOFixed y;
IOFixed a;
IOFixed b;
}face;
struct {
IOFixed x;
IOFixed y;
IOFixed z;
IOFixed rz;
} joystick;
struct {
IOFixed l1;
IOFixed l2;
IOFixed r1;
IOFixed r2;
} shoulder;
struct {
unsigned int left;
unsigned int right;
} thumbstick;
} gameController;
struct {
OSArray * childElements;
OSArray * primaryElements;
OSArray * pendingEvents;
} vendorMessage;
struct {
OSArray * elements;
} biometric;
struct {
OSArray * elements;
} accel;
struct {
OSArray * elements;
} gyro;
struct {
OSArray * elements;
} compass;
struct {
OSArray * elements;
} temperature;
struct {
IOHIDElement * reportInterval;
IOHIDElement * maxFIFOEvents;
IOHIDElement * reportLatency;
IOHIDElement * sniffControl;
} sensorProperty;
struct {
OSArray * cmElements;
OSArray * tiltElements;
} orientation;
struct {
OSArray * phaseElements;
IOHIDElement * longPress;
IOOptionBits phaseFlags;
IOOptionBits prevPhaseFlags;
} phase;
struct {
OSArray * elements;
} proximity;
UInt64 lastReportTime;
IOWorkLoop * workLoop;
IOCommandGate * commandGate;
};
ExpansionData * _reserved;
bool getBlessedUsagePairs();
bool parseElements(OSArray * elementArray, UInt32 bootProtocol);
bool parseRelativeElement(IOHIDElement * element);
bool parseMultiAxisElement(IOHIDElement * element);
bool parseGameControllerElement(IOHIDElement * element);
bool parseDigitizerElement(IOHIDElement * element);
bool parseDigitizerTransducerElement(IOHIDElement * element, IOHIDElement * parent=NULL);
bool parseScrollElement(IOHIDElement * element);
bool parseLEDElement(IOHIDElement * element);
bool parseKeyboardElement(IOHIDElement * element);
bool parseUnicodeElement(IOHIDElement * element);
bool parseLegacyUnicodeElement(IOHIDElement * element);
bool parseGestureUnicodeElement(IOHIDElement * element);
bool parseVendorMessageElement(IOHIDElement * element);
bool parseBiometricElement(IOHIDElement * element);
bool parseAccelElement(IOHIDElement * element);
bool parseGyroElement(IOHIDElement * element);
bool parseCompassElement(IOHIDElement * element);
bool parseTemperatureElement(IOHIDElement * element);
bool parseSensorPropertyElement(IOHIDElement * element);
bool parseDeviceOrientationElement(IOHIDElement * element);
bool parsePhaseElement(IOHIDElement * element);
bool parseProximityElement(IOHIDElement * element);
void processLEDElements();
void processDigitizerElements();
void processMultiAxisElements();
void processGameControllerElements();
void processUnicodeElements();
void setRelativeProperties();
void setDigitizerProperties();
void setGameControllerProperties();
void setMultiAxisProperties();
void setScrollProperties();
void setLEDProperties();
void setKeyboardProperties();
void setUnicodeProperties();
void setAccelerationProperties();
void setVendorMessageProperties();
void setBiometricProperties();
void setAccelProperties();
void setGyroProperties();
void setCompassProperties();
void setTemperatureProperties();
void setSensorProperties();
void setDeviceOrientationProperties();
void setSurfaceDimensions();
UInt32 checkGameControllerElement(IOHIDElement * element);
UInt32 checkMultiAxisElement(IOHIDElement * element);
static void calibrateJustifiedPreferredStateElement(IOHIDElement * element, SInt32 removalPercentage);
static void calibrateCenteredPreferredStateElement(IOHIDElement * element, SInt32 removalPercentage);
void handleBootPointingReport(AbsoluteTime timeStamp, IOMemoryDescriptor * report, UInt32 reportID);
void handleRelativeReport(AbsoluteTime timeStamp, UInt32 reportID);
void handleGameControllerReport(AbsoluteTime timeStamp, UInt32 reportID);
void handleMultiAxisPointerReport(AbsoluteTime timeStamp, UInt32 reportID);
void handleDigitizerCollectionReport(AbsoluteTime timeStamp, UInt32 reportID);
void handleDigitizerReport(AbsoluteTime timeStamp, UInt32 reportID);
IOHIDEvent* handleDigitizerTransducerReport(DigitizerTransducer * transducer, AbsoluteTime timeStamp, UInt32 reportID);
void handleScrollReport(AbsoluteTime timeStamp, UInt32 reportID);
void handleKeboardReport(AbsoluteTime timeStamp, UInt32 reportID);
void handleUnicodeReport(AbsoluteTime timeStamp, UInt32 reportID);
void handleUnicodeLegacyReport(AbsoluteTime timeStamp, UInt32 reportID);
void handleUnicodeGestureReport(AbsoluteTime timeStamp, UInt32 reportID);
IOHIDEvent * handleUnicodeGestureCandidateReport(EventElementCollection * candidate, AbsoluteTime timeStamp, UInt32 reportID);
void handleVendorMessageReport(AbsoluteTime timeStamp, IOMemoryDescriptor * report, UInt32 reportID, int phase);
void handleBiometricReport(AbsoluteTime timeStamp, UInt32 reportID);
void handleAccelReport(AbsoluteTime timeStamp, UInt32 reportID);
void handleGyroReport(AbsoluteTime timeStamp, UInt32 reportID);
void handleCompassReport(AbsoluteTime timeStamp, UInt32 reportID);
void handleTemperatureReport(AbsoluteTime timeStamp, UInt32 reportID);
void handleDeviceOrientationReport(AbsoluteTime timeStamp, UInt32 reportID);
void handlePhaseReport(AbsoluteTime timeStamp, UInt32 reportID);
void handleProximityReport(AbsoluteTime, UInt32 reportID);
bool serializeCharacterGestureState(void * ref, OSSerialize * serializer);
bool conformTo (UInt32 usagePage, UInt32 usage);
IOHIDEvent* createDigitizerTransducerEventForReport(DigitizerTransducer * transducer, AbsoluteTime timeStamp, UInt32 reportID);
bool serializeDebugState(void * ref, OSSerialize * serializer);
UInt32 getButtonStateFromElements(OSArray * elements);
protected:
virtual void free(void) APPLE_KEXT_OVERRIDE;
virtual OSArray * getReportElements(void) APPLE_KEXT_OVERRIDE;
virtual bool handleStart( IOService * provider ) APPLE_KEXT_OVERRIDE;
virtual void handleStop( IOService * provider ) APPLE_KEXT_OVERRIDE;
virtual void handleInterruptReport (
AbsoluteTime timeStamp,
IOMemoryDescriptor * report,
IOHIDReportType reportType,
UInt32 reportID);
virtual OSString * getTransport (void) APPLE_KEXT_OVERRIDE;
virtual UInt32 getLocationID (void) APPLE_KEXT_OVERRIDE;
virtual UInt32 getVendorID (void) APPLE_KEXT_OVERRIDE;
virtual UInt32 getVendorIDSource (void) APPLE_KEXT_OVERRIDE;
virtual UInt32 getProductID (void) APPLE_KEXT_OVERRIDE;
virtual UInt32 getVersion (void) APPLE_KEXT_OVERRIDE;
virtual UInt32 getCountryCode (void) APPLE_KEXT_OVERRIDE;
virtual OSString * getManufacturer (void) APPLE_KEXT_OVERRIDE;
virtual OSString * getProduct (void) APPLE_KEXT_OVERRIDE;
virtual OSString * getSerialNumber (void) APPLE_KEXT_OVERRIDE;
virtual IOReturn setElementValue (
UInt32 usagePage,
UInt32 usage,
UInt32 value ) APPLE_KEXT_OVERRIDE;
virtual UInt32 getElementValue (
UInt32 usagePage,
UInt32 usage ) APPLE_KEXT_OVERRIDE;
virtual void dispatchEvent(IOHIDEvent * event, IOOptionBits options=0) APPLE_KEXT_OVERRIDE;
public:
virtual bool init( OSDictionary * dictionary = 0 ) APPLE_KEXT_OVERRIDE;
virtual bool didTerminate(
IOService * provider,
IOOptionBits options,
bool * defer ) APPLE_KEXT_OVERRIDE;
virtual IOReturn setProperties( OSObject * properties ) APPLE_KEXT_OVERRIDE;
virtual IOHIDEvent * copyEvent(
IOHIDEventType type,
IOHIDEvent * matching = 0,
IOOptionBits options = 0) APPLE_KEXT_OVERRIDE;
virtual IOHIDEvent *copyMatchingEvent(OSDictionary *matching) APPLE_KEXT_OVERRIDE;
OSMetaClassDeclareReservedUnused(IOHIDEventDriver, 0);
OSMetaClassDeclareReservedUnused(IOHIDEventDriver, 1);
OSMetaClassDeclareReservedUnused(IOHIDEventDriver, 2);
OSMetaClassDeclareReservedUnused(IOHIDEventDriver, 3);
OSMetaClassDeclareReservedUnused(IOHIDEventDriver, 4);
OSMetaClassDeclareReservedUnused(IOHIDEventDriver, 5);
OSMetaClassDeclareReservedUnused(IOHIDEventDriver, 6);
OSMetaClassDeclareReservedUnused(IOHIDEventDriver, 7);
OSMetaClassDeclareReservedUnused(IOHIDEventDriver, 8);
OSMetaClassDeclareReservedUnused(IOHIDEventDriver, 9);
OSMetaClassDeclareReservedUnused(IOHIDEventDriver, 10);
OSMetaClassDeclareReservedUnused(IOHIDEventDriver, 11);
OSMetaClassDeclareReservedUnused(IOHIDEventDriver, 12);
OSMetaClassDeclareReservedUnused(IOHIDEventDriver, 13);
OSMetaClassDeclareReservedUnused(IOHIDEventDriver, 14);
OSMetaClassDeclareReservedUnused(IOHIDEventDriver, 15);
OSMetaClassDeclareReservedUnused(IOHIDEventDriver, 16);
OSMetaClassDeclareReservedUnused(IOHIDEventDriver, 17);
OSMetaClassDeclareReservedUnused(IOHIDEventDriver, 18);
OSMetaClassDeclareReservedUnused(IOHIDEventDriver, 19);
OSMetaClassDeclareReservedUnused(IOHIDEventDriver, 20);
OSMetaClassDeclareReservedUnused(IOHIDEventDriver, 21);
OSMetaClassDeclareReservedUnused(IOHIDEventDriver, 22);
OSMetaClassDeclareReservedUnused(IOHIDEventDriver, 23);
OSMetaClassDeclareReservedUnused(IOHIDEventDriver, 24);
OSMetaClassDeclareReservedUnused(IOHIDEventDriver, 25);
OSMetaClassDeclareReservedUnused(IOHIDEventDriver, 26);
OSMetaClassDeclareReservedUnused(IOHIDEventDriver, 27);
OSMetaClassDeclareReservedUnused(IOHIDEventDriver, 28);
OSMetaClassDeclareReservedUnused(IOHIDEventDriver, 29);
OSMetaClassDeclareReservedUnused(IOHIDEventDriver, 30);
OSMetaClassDeclareReservedUnused(IOHIDEventDriver, 31);
};
#endif /* !_IOKIT_HID_IOHIDEVENTDRIVER_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/sbp2/IOFireWireSBP2ManagementORB.h | /*
* Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* The contents of this file constitute Original Code as defined in and
* are subject to the Apple Public Source License Version 1.1 (the
* "License"). You may not use this file except in compliance with the
* License. Please obtain a copy of the License at
* http://www.apple.com/publicsource and read it before using this file.
*
* This Original Code and all software distributed under the License are
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/*!
@header IOFireWireSBP2ManagementORB
Contains the class definition for IOFireWireSBP2ManagementORB.
*/
#ifndef _IOKIT_IOFIREWIRESBP2MANAGEMENTORB_H
#define _IOKIT_IOFIREWIRESBP2MANAGEMENTORB_H
#include <IOKit/firewire/IOFWCommand.h>
#include <IOKit/firewire/IOFireWireUnit.h>
#include <IOKit/IOUserClient.h>
class IOFireWireSBP2LUN;
class IOFireWireSBP2ManagementORB;
class IOFireWireSBP2ORB;
enum
{
kFWSBP2QueryLogins = 1,
kFWSBP2AbortTask = 0xb,
kFWSBP2AbortTaskSet = 0xc,
kFWSBP2LogicalUnitReset = 0xe,
kFWSBP2TargetReset = 0xf
};
// Callback when management command completes asynchronously
/*!
@typedef FWSBP2ManagementCallback
@param refCon Reference constant supplied when the notification was registered.
@param status Indicates success or failure of operation.
@param orb Indicates current orb status is for.
*/
typedef void (*FWSBP2ManagementCallback)(void * refCon, IOReturn status, IOFireWireSBP2ManagementORB * orb);
/*!
@class IOFireWireSBP2ManagementORB
@abstract Supplies non login related management ORBs. Management ORBs can be executed independent
of a login, if necessary. Management ORBs are created using the IOFireWireSBP2LUN interface.
*/
class IOFireWireSBP2ManagementORB : public IOFWCommand
{
OSDeclareDefaultStructors( IOFireWireSBP2ManagementORB )
friend class IOFireWireSBP2LUN;
friend class IOFireWireSBP2UserClient;
protected:
////////////////////////////////////////
// rom keys
enum
{
kUnitCharacteristicsKey = 0x3A,
kManagementAgentOffsetKey = 0x54
};
////////////////////////////////////////
// structs
typedef struct
{
UInt32 orbOffsetHi;
UInt32 orbOffsetLo;
UInt32 reserved1[2];
UInt16 options;
UInt16 loginID;
UInt32 reserved2;
UInt32 statusFIFOAddressHi;
UInt32 statusFIFOAddressLo;
} FWSBP2TaskManagementORB;
typedef struct
{
UInt32 reserved1[2];
UInt32 queryResponseAddressHi;
UInt32 queryResponseAddressLo;
UInt16 options;
UInt16 lun;
UInt16 reserved2;
UInt16 queryResponseLength;
UInt32 statusFIFOAddressHi;
UInt32 statusFIFOAddressLo;
} FWSBP2QueryLoginsORB;
typedef struct
{
UInt8 details;
UInt8 sbpStatus;
UInt16 orbOffsetHi;
UInt32 orbOffsetLo;
UInt32 status[6];
} FWSBP2StatusBlock;
protected:
////////////////////////////////////////
// friend methods
// IOFireWireSBP2LUN methods
virtual bool initWithLUN( IOFireWireSBP2LUN * lun,
void * refCon,
FWSBP2ManagementCallback completion );
// IOFireWireSBP2UserClient methods
virtual void setAsyncCallbackReference( void * asyncRef );
virtual void getAsyncCallbackReference( void * asyncRef );
protected:
// reserved for future use
struct ExpansionData
{
bool fInCriticalSection;
};
ExpansionData * fExpansionData;
IOFireWireSBP2LUN * fLUN;
IOFireWireUnit * fUnit;
UInt32 fManagementOffset;
UInt32 fManagementTimeout;
UInt32 fFunction;
OSObject * fManageeCommand;
// our orb
FWSBP2TaskManagementORB fManagementORB;
IOFWAddressSpace * fManagementORBAddressSpace;
FWAddress fManagementORBAddress;
// command to write management agent
IOFWWriteCommand * fWriteCommand;
IOMemoryDescriptor * fWriteCommandMemory;
// timeout
IOFWCommand * fTimeoutCommand;
bool fTimeoutTimerSet;
// status block
FWSBP2StatusBlock fStatusBlock;
IOFWAddressSpace * fStatusBlockAddressSpace;
FWAddress fStatusBlockAddress;
// response buffer
void * fResponseBuf;
UInt32 fResponseLen;
IOFWAddressSpace * fResponseAddressSpace;
FWAddress fResponseAddress;
// competion routine
FWSBP2ManagementCallback fCompletionCallback;
void * fCompletionRefCon;
// for user client
OSAsyncReference64 fCallbackAsyncRef;
IOMemoryMap * fResponseMap;
bool fCompleting;
////////////////////////////////////////
// init / destroy
virtual IOReturn getUnitInformation( void );
virtual IOReturn allocateResources( void );
virtual void free( void ) APPLE_KEXT_OVERRIDE;
// command execution
virtual IOReturn execute( void ) APPLE_KEXT_OVERRIDE;
virtual IOReturn complete( IOReturn state ) APPLE_KEXT_OVERRIDE;
// write complete handler
static void writeCompleteStatic( void *refcon,
IOReturn status,
IOFireWireNub *device,
IOFWCommand *fwCmd );
virtual void writeComplete( IOReturn status,
IOFireWireNub *device,
IOFWCommand *fwCmd );
// timeout handler
static void handleTimeoutStatic( void *refcon,
IOReturn status,
IOFireWireBus *bus,
IOFWBusCommand *fwCmd );
virtual void handleTimeout( IOReturn status, IOFireWireBus *bus, IOFWBusCommand *fwCmd );
// status block write handler
static UInt32 statusBlockWriteStatic( void *refcon,
UInt16 nodeID,
IOFWSpeed &speed,
FWAddress addr,
UInt32 len,
const void *buf,
IOFWRequestRefCon lockRead );
virtual UInt32 statusBlockWrite( UInt16 nodeID,
FWAddress addr,
UInt32 len,
const void *buf,
IOFWRequestRefCon lockRead );
// IOFireWireSBP2LUN friend class wrappers
virtual void clearAllTasksInSet( void );
virtual void removeManagementORB( IOFireWireSBP2ManagementORB * orb );
public:
////////////////////////////////////////
// client methods
/*!
@function setCommandFunction
@abstract Sets the function of the management ORB.
@discussion Sets the the function of the management ORB. Legal values are kFWSBP2QueryLogins,
kFWSBP2AbortTask, kFWSBP2AbortTaskSet, kFWSBP2LogicalUnitReset, and kFWSBP2TargetReset.
@param function a value indicating the desired management function.
@result Returns kIOReturnSuccess if function was a legal function.
*/
virtual IOReturn setCommandFunction( UInt32 function );
/*!
@function getCommandFunction
@abstract Returns the current function of the management ORB.
@discussion Returns the function of the management ORB. This is the same value that was
set with setCommandFunction.
@result Returns the function of the management ORB.
*/
virtual UInt32 getCommandFunction( void );
/*!
@function setManageeCommand
@abstract Sets the command to be managed by the management ORB.
@discussion All management functions except kFWSBP2QueryLogins require a reference to an ORB of
some sort. kFWSBP2AbortTaskSet, kFWSBP2LogicalUnitReset, and kFWSBP2TargetReset require a
reference to the login ORB. kFWSBP2AbortTask requires a reference to the ORB to be aborted.
This method allows you to set the ORB to be managed.
@param command a reference to an IOFireWireSBP2Login or an IOFireWireSBP2ORB.
*/
virtual void setManageeCommand( OSObject * command );
/*!
@function getCommandFunction
@abstract Returns the current managee command of the management ORB.
@discussion Returns the current managee command of the management ORB. This is the same value that was
set with setManageeCommand.
@result Returns the current managee command of the management ORB.
*/
virtual OSObject* getManageeCommand( void );
/*!
@function setResponseBuffer
@abstract Sets the response buffer for the management ORB.
@discussion Sets the response buffer for the management ORB. kFWSBP2QueryLogins returns
a response to its query and needs to write it somewhere. This routine allows you to
specify the location.
@param desc memory descriptor for buffer.
@result Returns kIOReturnSuccess on a success.
*/
virtual IOReturn setResponseBuffer( IOMemoryDescriptor * desc );
/*!
@function setResponseBuffer
@abstract Sets the response buffer for the management ORB.
@discussion Sets the response buffer for the management ORB. kFWSBP2QueryLogins returns
a response to its query and needs to write it somewhere. This routine allows you to
specify the location.
@param buf backing store for buffer
@param len length of buffer.
@result Returns kIOReturnSuccess on a success.
*/
virtual IOReturn setResponseBuffer( void * buf, UInt32 len );
/*!
@function getResponseBuffer
@abstract Returns the response buffer for the management ORB.
@discussion Returns the response buffer set in setResponseBuffer above
@param desc memory descriptor for buffer.
@param buf output parameter for backing store for buffer
@param len output parameter for length of buffer.
*/
virtual void getResponseBuffer( void ** buf, UInt32 * len );
/*!
@function release
@abstract Primary implementation of the release mechanism.
@discussion See OSObject.h for more information.
@param when When retainCount == when then call free().
*/
virtual void release() const APPLE_KEXT_OVERRIDE;
protected:
virtual void setORBToDummy( IOFireWireSBP2ORB * orb );
virtual void suspendedNotify();
private:
OSMetaClassDeclareReservedUsed(IOFireWireSBP2ManagementORB, 0);
OSMetaClassDeclareReservedUnused(IOFireWireSBP2ManagementORB, 1);
OSMetaClassDeclareReservedUnused(IOFireWireSBP2ManagementORB, 2);
OSMetaClassDeclareReservedUnused(IOFireWireSBP2ManagementORB, 3);
OSMetaClassDeclareReservedUnused(IOFireWireSBP2ManagementORB, 4);
OSMetaClassDeclareReservedUnused(IOFireWireSBP2ManagementORB, 5);
OSMetaClassDeclareReservedUnused(IOFireWireSBP2ManagementORB, 6);
OSMetaClassDeclareReservedUnused(IOFireWireSBP2ManagementORB, 7);
OSMetaClassDeclareReservedUnused(IOFireWireSBP2ManagementORB, 8);
};
#endif
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/sbp2/IOFireWireSerialBusProtocolTransport.h | /*
* Copyright (c) 1998-2009 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/*!
@header IOFireWireSerialBusProtocolTransport
Contains the class definition for IOFireWireSerialBusProtocolTransport.
*/
#ifndef _IOKIT_IO_FIREWIRE_SERIAL_BUS_PROTOCOL_TRANSPORT_H_
#define _IOKIT_IO_FIREWIRE_SERIAL_BUS_PROTOCOL_TRANSPORT_H_
#include <IOKit/IOBufferMemoryDescriptor.h>
#include <IOKit/IOLib.h>
#include <IOKit/IOMessage.h>
#include <IOKit/IOService.h>
#include <IOKit/IOCommandPool.h>
#include <IOKit/firewire/IOFireWireUnit.h>
#include <IOKit/sbp2/IOFireWireSBP2LUN.h>
#include <IOKit/scsi/IOSCSIProtocolServices.h>
/*!
@class IOFireWireSerialBusProtocolTransport
@abstract SCSI Protocol Driver Family for FireWire SBP2 Devices.
@discussion IOFireWireSerialBusProtocolTransport contains all the bus specific support for FireWire
SBP2 compliant devices. To add vendor specific features or workarounds you will sub-class the appropriate
methods of this family.
*/
class __exported IOFireWireSerialBusProtocolTransport : public IOSCSIProtocolServices
{
OSDeclareDefaultStructors ( IOFireWireSerialBusProtocolTransport )
private:
IOFireWireUnit * fUnit;
IOFireWireSBP2LUN * fSBPTarget;
IOFireWireSBP2Login * fLogin;
IOFireWireSBP2ORB * fORB;
IOFireWireSBP2ManagementORB * fLUNResetORB;
// /!\ WARNING! NOT USED left behind for legacy binary reasons
__unused IOSimpleLock * fQueueLock;
UInt32 fLoginRetryCount;
bool fDeferRegisterService;
bool fNeedLogin;
// /!\ WARNING! NOT USED left behind for legacy binary reasons
__unused bool fPhysicallyConnected;
static void
StatusNotifyStatic ( void * refCon, FWSBP2NotifyParamsPtr params );
static void
UnsolicitedStatusNotifyStatic ( void * refCon,
FWSBP2NotifyParamsPtr params );
static void
LunResetCompleteStatic ( void * refCon,
IOReturn status,
IOFireWireSBP2ManagementORB * orb );
static void
FetchAgentResetCompleteStatic ( void * refcon,
IOReturn status );
static IOReturn
ConnectToDeviceStatic ( OSObject * refCon, void *, void *, void *, void * );
virtual void
FetchAgentResetComplete ( IOReturn status );
static void LoginCompletionStatic ( void * refCon, FWSBP2LoginCompleteParams * params );
static void
LogoutCompletionStatic ( void * refCon, FWSBP2LogoutCompleteParams * params );
/*!
@function CoalesceSenseData
@abstract CoalesceSenseData convert a SBP-2 status block into a SPC-2 sense block.
@discussion CoalesceSenseData pulls the appropriate bits out of the SBP2 sense block
as defined in SBP-2 Annex B section B.2 and dynamically builds a sense data block as
defined in SPC-2 section 7.23.2.
*/
SCSITaskStatus
CoalesceSenseData ( FWSBP2StatusBlock * sourceData,
UInt8 quadletCount,
SCSI_Sense_Data * targetData );
virtual void ConnectToDevice ( void );
virtual void DisconnectFromDevice ( void );
virtual bool IsDeviceCPUInDiskMode ( void );
protected:
/*!
@function AllocateResources
@abstract Allocate Resources.
@discussion Called from start method to allocate needed resources.
*/
virtual IOReturn AllocateResources ( void );
/*!
@function DeallocateResources
@abstract Deallocate Resources.
@discussion Called from cleanUp method to deallocate resources.
*/
virtual void DeallocateResources ( void );
enum SBP2LoginState
{
kFirstTimeLoggingInState,
kLogginSucceededState,
kLogginFailedState
};
/*!
@typedef SBP2ClientOrbData
@param orb IOFireWireSBP2ORB for request.
@param scsiTask SCSITaskIdentifier of request.
@param serviceResponse SCSIServiceResponse of request.
@param taskStatus SCSITaskStatus of request.
@discussion This structure is stuffed into the refcon so we can associate which
IOFireWireSBP2ORB and SCSITaskIdentifier is completing.
*/
typedef struct {
IOFireWireSBP2ORB * orb;
SCSITaskIdentifier scsiTask;
SCSIServiceResponse serviceResponse;
SCSITaskStatus taskStatus;
IOBufferMemoryDescriptor * quadletAlignedBuffer;
} SBP2ClientOrbData;
static const UInt32 kDefaultBusyTimeoutValue = 0x0000000F;
static const UInt64 kMaxFireWireLUN = 0xFFFF;
static const UInt32 kMaxFireWirePayload = 4096;
static const UInt32 kMaxLoginRetryCount = 8;
static const UInt32 kMaxReconnectCount = 128;
static const UInt32 kCSRModelInfoKey = 0x17;
UInt32 fReconnectCount;
bool fLoggedIn;
// binary compatibility instance variable expansion
struct ExpansionData
{
IOCommandPool * fCommandPool;
IOCommandPool * fSubmitQueue;
SBP2LoginState fLoginState;
bool fLUNResetPathFlag;
int fLUNResetCount;
bool fAlwaysSetSenseData;
bool fAutonomousSpinDownWorkAround;
};
ExpansionData * reserved;
bool fObjectIsOpen;
/*!
@function CommandORBAccessor
@abstract accessor function for fORB.
@discussion xxx.
*/
IOFireWireSBP2ORB * CommandORBAccessor ( void );
/*!
@function SBP2LoginAccessor
@abstract accessor function for fLogin.
@discussion xxx.
*/
IOFireWireSBP2Login * SBP2LoginAccessor ( void );
virtual IOReturn
message ( UInt32 type, IOService * provider, void * argument = 0 ) APPLE_KEXT_OVERRIDE;
/*!
@function SendSCSICommand
@abstract Prepare and send a SCSI command to the device.
@discussion The incoming SCSITaskIdentifier gets turned into a IOFireWireSBP2ORB
and is submitted to the SBP2 layer. See IOSCSIProtocolServices.h for more details
regarding SendSCSICommand. Also see IOFireWireSBP2Lib.h for details regarding the
IOFireWireSBP2ORB structure and the submitORB method.
@result If the command was sent to the device and is pending completion, the
subclass should return true and return back the kSCSIServiceResponse_Request_In_Process response.
If the command completes immediately with an error, the subclass will return true
and return back the appropriate status. If the subclass is currently processing all the
commands it can, the subclass will return false and the command will be resent next time
CommandCompleted is called.
*/
virtual bool
SendSCSICommand ( SCSITaskIdentifier request,
SCSIServiceResponse * serviceResponse,
SCSITaskStatus * taskStatus ) APPLE_KEXT_OVERRIDE;
/*!
@function SetCommandBuffers
@abstract Method to set orb's buffers.
@discussion This method was added so that subclasses can override and massage buffers as
needed. The default simply calls setCommandBuffers. See IOFireWireSBP2Lib.h for details
regarding the setCommandBuffers method.
@result xxx.
*/
virtual IOReturn
SetCommandBuffers ( IOFireWireSBP2ORB * orb, SCSITaskIdentifier request );
/*!
@function CompleteSCSITask
@abstract This qualifies and sets appropriate data then calls CommandCompleted.
@discussion See IOSCSIProtocolServices.h for more details
regarding CommandCompleted.
*/
virtual void
CompleteSCSITask ( IOFireWireSBP2ORB * orb );
/*!
@function AbortSCSICommand
@abstract This method is intended to abort an in progress SCSI Task.
@discussion Currently not implemented in super class. This is a stub method for adding
the abort command in the near future.
@result See SCSITask.h for SCSIServiceResponse codes.
*/
virtual SCSIServiceResponse
AbortSCSICommand ( SCSITaskIdentifier request ) APPLE_KEXT_OVERRIDE;
/*!
@function StatusNotify
@abstract This is our handler for status.
@discussion See IOFireWireSBP2Lib.h for details regarding the FWSBP2NotifyParams
structure that is passed in to the completion..
*/
virtual void
StatusNotify ( FWSBP2NotifyParams * params );
/*!
@function SetValidAutoSenseData
@abstract Set the auto sense data that was returned for a given SCSI Task.
@discussion SetValidAutoSenseData is called to qualify sense data that is copied to the
client via the SetAutoSenseData method. See IOSCSIProtocolServices.h for more details
regarding SetAutoSenseData.
*/
void
SetValidAutoSenseData ( SBP2ClientOrbData * clientData,
FWSBP2StatusBlock * statusBlock,
SCSI_Sense_Data * targetData );
/*!
@function UnsolicitedStatusNotify
@abstract This is our handler for unsolicited status.
@discussion After we have parsed and handled the unsolicited status we call
enableUnsolicitedStatus. See IOFireWireSBP2Lib.h for details regarding the
enableUnsolicitedStatus method.
*/
virtual void
UnsolicitedStatusNotify ( FWSBP2NotifyParamsPtr params );
/*!
@function LoginCompletion
@abstract Completion routine for login complete.
@discussion See IOFireWireSBP2Lib.h for details regarding the FWSBP2LogoutCompleteParams
structure that is passed in to the completion.
*/
virtual void
LoginCompletion ( FWSBP2LoginCompleteParams * params );
/*!
@function LogoutCompletion
@abstract Completion routine for logout complete.
@discussion See IOFireWireSBP2Lib.h for details regarding the FWSBP2LogoutCompleteParams
structure that is passed in to the completion.
*/
virtual void
LogoutCompletion ( FWSBP2LogoutCompleteParams * params );
/*!
@function IsProtocolServiceSupported
@abstract Determine is specified feature is supported by the protocol layer.
@discussion If the service has a value that must be returned, it will be returned in the
serviceValue output parameter. See IOSCSIProtocolServices.h for more details regarding
IsProtocolServiceSupported.
@result Will return true if the specified feature is supported by the protocol layer.
*/
virtual bool
IsProtocolServiceSupported ( SCSIProtocolFeature feature, void * serviceValue ) APPLE_KEXT_OVERRIDE;
/*!
@function HandleProtocolServiceFeature
@abstract Handle specified feature supported by the protocol layer.
@discussion See IOSCSIProtocolServices.h for more details regarding HandleProtocolServiceFeature.
@result Will return true if the specified feature is supported by the protocol layer.
*/
virtual bool
HandleProtocolServiceFeature ( SCSIProtocolFeature feature, void * serviceValue ) APPLE_KEXT_OVERRIDE;
/*!
@function LunResetComplete
@abstract Callback to submit Fetch Agent Reset.
@discussion See IOFireWireSBP2Lib.h for details regarding the submitFetchAgentReset
method.
*/
virtual void
LunResetComplete ( IOReturn status, IOFireWireSBP2ManagementORB * orb );
public:
/*!
@function init
@abstract See IOService for discussion.
@discussion Setup and prime class into known state.
*/
bool init ( OSDictionary * propTable ) APPLE_KEXT_OVERRIDE;
/*!
@function start
@discussion See IOService for discussion.
@result Return true if the start was successful, false otherwise ( which will
cause the instance to be detached and usually freed ).
*/
virtual bool start ( IOService * provider ) APPLE_KEXT_OVERRIDE;
/*!
@function cleanUp
@abstract cleanUp is called to tear down IOFireWireSerialBusProtocolTransport.
@discussion cleanUp is called when we receive a kIOFWMessageServiceIsRequestingClose
message or if we fail our initialization.
*/
virtual void cleanUp ( void );
/*!
@function finalize
@abstract See IOService for discussion.
@result Returns true.
*/
virtual bool finalize ( IOOptionBits options ) APPLE_KEXT_OVERRIDE;
/*!
@function free
@discussion See IOService for discussion.
@result none.
*/
virtual void free ( void ) APPLE_KEXT_OVERRIDE;
protected:
virtual IOReturn login ( void );
OSMetaClassDeclareReservedUsed ( IOFireWireSerialBusProtocolTransport, 1 );
virtual IOReturn submitLogin ( void );
OSMetaClassDeclareReservedUsed ( IOFireWireSerialBusProtocolTransport, 2 );
virtual void loginLost ( void );
OSMetaClassDeclareReservedUsed ( IOFireWireSerialBusProtocolTransport, 3 );
void loginSuspended ( void );
OSMetaClassDeclareReservedUsed ( IOFireWireSerialBusProtocolTransport, 4 );
virtual void loginResumed ( void );
OSMetaClassDeclareReservedUsed ( IOFireWireSerialBusProtocolTransport, 5 );
static IOReturn CriticalOrbSubmissionStatic (
OSObject * refCon,
void * val1,
void * val2,
void * val3,
void * val4 );
/*!
@function CriticalOrbSubmission
@abstract xxx.
@discussion xxx.
@result none.
*/
void
CriticalOrbSubmission (
IOFireWireSBP2ORB * orb,
SCSITaskIdentifier request );
virtual void submitOrbFromQueue ( void );
OSMetaClassDeclareReservedUsed ( IOFireWireSerialBusProtocolTransport, 6 );
private:
// binary compatibility reserved method space
OSMetaClassDeclareReservedUnused ( IOFireWireSerialBusProtocolTransport, 7 );
OSMetaClassDeclareReservedUnused ( IOFireWireSerialBusProtocolTransport, 8 );
OSMetaClassDeclareReservedUnused ( IOFireWireSerialBusProtocolTransport, 9 );
OSMetaClassDeclareReservedUnused ( IOFireWireSerialBusProtocolTransport, 10 );
OSMetaClassDeclareReservedUnused ( IOFireWireSerialBusProtocolTransport, 11 );
OSMetaClassDeclareReservedUnused ( IOFireWireSerialBusProtocolTransport, 12 );
OSMetaClassDeclareReservedUnused ( IOFireWireSerialBusProtocolTransport, 13 );
OSMetaClassDeclareReservedUnused ( IOFireWireSerialBusProtocolTransport, 14 );
OSMetaClassDeclareReservedUnused ( IOFireWireSerialBusProtocolTransport, 15 );
OSMetaClassDeclareReservedUnused ( IOFireWireSerialBusProtocolTransport, 16 );
};
#endif /* _IOKIT_IO_FIREWIRE_SERIAL_BUS_PROTOCOL_TRANSPORT_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/sbp2/IOFireWireSBP2LUN.h | /*
* Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* The contents of this file constitute Original Code as defined in and
* are subject to the Apple Public Source License Version 1.1 (the
* "License"). You may not use this file except in compliance with the
* License. Please obtain a copy of the License at
* http://www.apple.com/publicsource and read it before using this file.
*
* This Original Code and all software distributed under the License are
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/*!
@header IOFireWireSBP2LUN
Contains the class definition for IOFireWireSBP2LUN.
*/
#ifndef _IOKIT_IOFIREWIRESBP2LUN_H
#define _IOKIT_IOFIREWIRESBP2LUN_H
#include <IOKit/IOService.h>
#include <IOKit/IOCommandGate.h>
#include <IOKit/firewire/IOFireWireUnit.h>
#include <IOKit/sbp2/IOFireWireSBP2Login.h>
#include <IOKit/sbp2/IOFireWireSBP2ManagementORB.h>
class IOFireWireSBP2Target;
/*!
@class IOFireWireSBP2LUN
@abstract Provider for most drivers.
@discussion IOFireWireSBP2LUN objects are created by IOFireWireSBP2Target objects. Each target may have zero or more IOFireWireSBP2LUN children. The LUN object serves as the matching nub for most drivers and therefore will be the provider for most drivers. It supplies the methods that control the operation of the LUN as a whole. Methods that control the behavior and execution of an SBP2 login session are supplied in a separate IOFireWireSBP2Login object. The LUN can be used to create one of these login objects.
The LUN can also create IOFireWireSBP2ManagementORBs for configuring and appending non-login related management functions. Login related management functions (ie. Login, Logout, Reconnect) are supplied by the IOFireWireSBP2Login.
Finally the LUN can supply a reference to the IOFireWireUnit. This can be useful if a driver wishes to access the standard FireWire APIs.
*/
class IOFireWireSBP2LUN : public IOService
{
OSDeclareDefaultStructors( IOFireWireSBP2LUN );
friend class IOFireWireSBP2ManagementORB;
friend class IOFireWireSBP2Login;
friend class IOFireWireSBP2UserClient;
protected:
// reserved for future use
struct ExpansionData { };
ExpansionData *reserved;
////////////////////////////////////////////
// methods called by friend classes
// IOFireWireSBP2Login methods
virtual void removeLogin( IOFireWireSBP2Login * login );
virtual IOFireWireSBP2Target * getTarget( void );
// IOFireWireSBP2ManagementORB methods
virtual void clearAllTasksInSet( void ); // assumes caller is on workloop
virtual void removeManagementORB( IOFireWireSBP2ManagementORB * orb );
// IOFireWireSBP2UserClient methods
virtual void flushAllManagementORBs( void );
public:
////////////////////////////////////////////
// IOService overrides
/*! @function attach
@abstract Attaches an IOService client to a provider in the registry.
@discussion See IOService for discussion.
@param provider The IOService object which will serve as this objects provider.
@result false if the provider is inactive or on a resource failure, otherwise true.
*/
virtual bool attach( IOService *provider ) APPLE_KEXT_OVERRIDE;
/*! @function handleOpen
@abstract Overrideable method to control the open / close behaviour of an IOService.
@discussion See IOService for discussion.
@param forClient Designates the client of the provider requesting the open.
@param options Options for the open, may be interpreted by the implementor of handleOpen.
@result Return true if the open was successful, false otherwise. */
virtual bool handleOpen( IOService * forClient,
IOOptionBits options,
void * arg ) APPLE_KEXT_OVERRIDE;
/*!
@function handleClose
@abstract Overrideable method to control the open / close behaviour of an IOService.
@discussion See IOService for discussion.
@param forClient Designates the client of the provider requesting the close.
@param options Options for the close, may be interpreted by the implementor of handleOpen.
*/
virtual void handleClose( IOService * forClient,
IOOptionBits options ) APPLE_KEXT_OVERRIDE;
/*!
@function matchPropertyTable
@abstract Implements SBP2 specific matching.
@discussion See IOService for discussion.
@param table The dictionary of properties to be matched against.
@result Returns false if the family considers the matching dictionary does not match in properties it understands, true otherwise.
*/
virtual bool matchPropertyTable(OSDictionary * table) APPLE_KEXT_OVERRIDE;
protected:
////////////////////////////////////////////
// private fields
IOFireWireSBP2Target * fProviderTarget;
UInt32 fLUNumber;
OSSet * fLoginSet;
OSIterator * fLoginSetIterator;
IOCommandGate * fGate;
OSSet * fORBSet;
OSIterator * fORBSetIterator;
OSObject * fDiagnostics;
////////////////////////////////////////////
// private methods
// IOService methods
virtual void free( void ) APPLE_KEXT_OVERRIDE;
virtual IOReturn message( UInt32 type, IOService * provider, void * argument = 0 ) APPLE_KEXT_OVERRIDE;
// create management orb internals
static IOReturn staticCreateManagementORBAction( OSObject *self,
void * refCon,
void * completion,
void * orb,
void * );
virtual IOReturn createManagementORBAction( void * refCon,
FWSBP2ManagementCallback completion,
IOFireWireSBP2ManagementORB ** orb );
// remove management orb internals
static IOReturn staticRemoveManagementORBAction( OSObject * self, void * orb,
void *, void *, void * );
virtual IOReturn removeManagementORBAction( IOFireWireSBP2ManagementORB * orb );
// flush all management orb internals
static IOReturn staticExecuteFlushAllMgmtORBs( OSObject * self, void *,
void *, void *, void * );
virtual IOReturn executeFlushAllMgmtORBs( void );
// IOFireWireSBP2ManagementORB friend class wrappers
virtual bool initMgmtORBWithLUN( IOFireWireSBP2ManagementORB * orb, IOFireWireSBP2LUN * lun,
void * refCon,
FWSBP2ManagementCallback completion );
// IOFireWireSBP2Login friend class wrappers
virtual bool initLoginWithLUN( IOFireWireSBP2Login * login, IOFireWireSBP2LUN * lun );
virtual void suspendedNotify( void );
virtual void resumeNotify( void );
private:
OSMetaClassDeclareReservedUnused(IOFireWireSBP2LUN, 0);
public:
////////////////////////////////////////////
// client methods
// getters
/*!
@function getFireWireUnit
@abstract Returns an IOFireWireUnit object.
@discussion An IOFireWireUnit is the provider of an IOFireWireSBP2Target. In order to
use the base FireWire services you will need a reference to the unit. This method
returns that reference.
@result Returns a pointer to an IOFireWireUnit.
*/
virtual IOFireWireUnit * getFireWireUnit( void );
/*!
@function getLUNumber
@abstract Returns the LUNs number.
@discussion Each LUN has a number to uniquely identify it on a device. This method returns
this value in a UInt32.
@result Returns a UInt32 containing the Logical Unit Number.
*/
virtual UInt32 getLUNumber( void );
// factory methods
/*!
@function createLogin
@abstract Creates a new IOFireWireSBP2Login object.
@discussion Creates a new IOFireWireSBP2Login object for the LUN. Login objects supply most
of the SBP2 APIs related to login maintenance and Normal Command ORB execution.
@result Returns a pointer to a new IOFireWireSBP2Login.
*/
virtual IOFireWireSBP2Login *createLogin( void );
/*!
@function createManagementORB
@abstract Creates a new IOFireWireSBP2ManagementORB object.
@discussion Creates a new IOFireWireSBP2ManagementORB object. Management objects let you
execute commands like QueryLogins, LogicalUnitReset, and AbortTask. These commands are
configured after they are created here. When they are done executing (after a call to submit)
the supplied completion routine will be called with the supplied refcon. Usually this refCon
is the "this" pointer of completion method's object.
@param refCon The refcon passed to the completion routine.
@param completion The completion routine. Called when the ORB finishes execution.
@result Returns a pointer to a new IOFireWireSBP2Login.
*/
virtual IOFireWireSBP2ManagementORB * createManagementORB( void * refCon, FWSBP2ManagementCallback completion );
protected:
static IOReturn staticCreateLogin( OSObject *self, void * login, void *, void *, void * );
virtual IOReturn createLoginAction( IOFireWireSBP2Login ** login );
static IOReturn staticRemoveLoginAction( OSObject *self, void * login, void *, void *, void * );
virtual IOReturn removeLoginAction( IOFireWireSBP2Login * login );
public:
/*!
@function getDiagnostics
@abstract Debug-only method.
@discussion Returns a reference to the internal diagnostics object when the services are built
in debug mode. Should be a no-op in release builds.
@result Returns a pointer to the diagnostics object (if any).
*/
virtual OSObject * getDiagnostics( void );
virtual bool finalize( IOOptionBits options ) APPLE_KEXT_OVERRIDE;
protected:
void terminateNotify( void );
private:
OSMetaClassDeclareReservedUnused(IOFireWireSBP2LUN, 1);
OSMetaClassDeclareReservedUnused(IOFireWireSBP2LUN, 2);
OSMetaClassDeclareReservedUnused(IOFireWireSBP2LUN, 3);
OSMetaClassDeclareReservedUnused(IOFireWireSBP2LUN, 4);
OSMetaClassDeclareReservedUnused(IOFireWireSBP2LUN, 5);
OSMetaClassDeclareReservedUnused(IOFireWireSBP2LUN, 6);
OSMetaClassDeclareReservedUnused(IOFireWireSBP2LUN, 7);
OSMetaClassDeclareReservedUnused(IOFireWireSBP2LUN, 8);
};
#endif
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/sbp2/IOFireWireSBP2LSIWorkaroundDescriptor.h | /*
* Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* The contents of this file constitute Original Code as defined in and
* are subject to the Apple Public Source License Version 1.1 (the
* "License"). You may not use this file except in compliance with the
* License. Please obtain a copy of the License at
* http://www.apple.com/publicsource and read it before using this file.
*
* This Original Code and all software distributed under the License are
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#if __ppc__
/*!
@header IOFireWireSBP2LSIWorkaroundDescriptor
Contains the class definition for IOFireWireSBP2LSIWorkaroundDescriptor.
*/
#ifndef _IOKIT_IOFIREWIRESBP2LSIWORKAROUNDDESCRIPTOR_H
#define _IOKIT_IOFIREWIRESBP2LSIWORKAROUNDDESCRIPTOR_H
#include <IOKit/IOMemoryDescriptor.h>
class IOFireWireSBP2LSIRange;
/*!
@class IOFireWireSBP2LSIWorkaroundDescriptor
@abstract This is a subclass of IOGeneralMemoryDescriptor. It is designed to work around
a hardware problem in a common SBP2 target. It takes a memory descriptor as
an argument. It retains this descriptor and returns a new one with resegmented
physical segments and potentially some "unfixable" segments double buffered.
If the transfer will cause data to be sent from the Mac, syncBuffersForOutput
must be called before the transfer.
If the transfer will cause data to be recieve by the Mac, syncBuffersForInput
must be called after the transfer.
This class calculates the new segmentation only once when it is created.
Any changes to the structure of the original memory descriptor will render
this one useless. It must be released and a new IOFireWireSBP2LSIWorkaroundDescriptor
can be created.
LSI Bridge Workaround Algorithm Details
Goals:
1. Avoid LSI Logic "< 16 byte" bug - prevent any data packet smaller than 16 bytes
2. Minimize double-buffering
3. Support non-multiple-of-512-byte devices, e.g. CD Audio
Solution:
Write a page table such that the bridge will nor use packets smaller than 16 bytes.
In other words, rearrange the memory descriptor to avoid the bug, and do it such
that the SBP-2 layer will not break up a segment (du ro the 64k-1 limit) and
re-introduces the problem
SBP-2 defines the kFWSBP2MaxPageClusterSize constant. We simply make sure
none of our segments are larger than this size and SBP-2 will not break them
up when it writes the SBP-2 page table.
Notes:
- Some double buffering is unavoidable. Discontiguous pages may yield page
fragments at the start or end of the buffer (or both, with non-512x buffers).
solution uses less than 33 bytes of double-buffer per segment in original
memory descriptor.
- If driver must break up IO to meet ATA limit of 255 (250?) blocks, assume
the driver does this at a higher level (before applying workaround).
- It is expected that the original memory descriptor has been prepared (wired)
*/
class IOFireWireSBP2LSIWorkaroundDescriptor : public IOGeneralMemoryDescriptor
{
OSDeclareDefaultStructors(IOFireWireSBP2LSIWorkaroundDescriptor)
friend class IOFireWireSBP2LSIRange;
protected:
// reserved for future use
struct ExpansionData { };
ExpansionData *reserved;
bool fFixedCapacity; // for both allocators
//////////////////////////////////////
// for range allocator
OSArray * fPermanentRanges;
UInt32 fAllocatedRangesCount;
virtual IOReturn rangeAllocatorInitialize( UInt32 rangeCount );
virtual void rangeAllocatorDeallocateAllRanges( void );
virtual IOFireWireSBP2LSIRange * rangeAllocatorNewRange( void );
virtual void rangeAllocatorFree( void );
//////////////////////////////////////
// for buffer allocator
OSArray * fBufferDescriptors;
UInt32 fPermanentPages;
IOByteCount fAllocatedBytesCount;
virtual IOReturn bufferAllocatorInitialize( IOByteCount requestedBufferSize );
virtual void bufferAllocatorDeallocateAllBuffers( void );
virtual void * bufferAllocatorNewBuffer( IOPhysicalAddress * address );
virtual void bufferAllocatorFree( void );
//////////////////////////////////////
// for range table allocator
IOPhysicalRange * fRangeTable;
IOByteCount fRangeTableSize;
virtual IOReturn rangeTableAllocatorInitialize( UInt32 requestedBufferSize );
virtual IOPhysicalRange * rangeTableAllocatorNewTable( UInt32 entries );
virtual void rangeTableAllocatorFree( void );
//////////////////////////////////////
// for workaround
IOMemoryDescriptor * fOriginalDesc;
OSArray * fRanges;
IOByteCount fOffset;
IOByteCount fLength;
IODirection fDirection;
virtual bool initWithCapacity
( UInt32 permanentRanges, IOByteCount permanentBufferSpace, bool fixedCapacity );
virtual void free();
virtual IOReturn resetToInitialCapacity( void );
virtual IOReturn initializeRangesArray( void );
virtual IOReturn recalculateSmallSegments( void );
virtual IOReturn splitLargeSegments( void );
virtual IOReturn resegmentOddLengthSegments( void );
virtual IOReturn initializeBuffers( void );
virtual bool initWithAddress( void * address, /* not supported */
IOByteCount withLength,
IODirection withDirection );
virtual bool initWithAddress( vm_address_t address, /* not supported */
IOByteCount withLength,
IODirection withDirection,
task_t withTask );
virtual bool initWithPhysicalAddress(
IOPhysicalAddress address, /* not supported */
IOByteCount withLength,
IODirection withDirection );
virtual bool initWithPhysicalRanges(
IOPhysicalRange * ranges, /* not supported */
UInt32 withCount,
IODirection withDirection,
bool asReference = false );
virtual bool initWithRanges( IOVirtualRange * ranges, /* not supported */
UInt32 withCount,
IODirection withDirection,
task_t withTask,
bool asReference = false );
public:
// static factory methods and intializers
//
// create a new instance
//
/*!
@function withDescriptor
@abstract Creates a new IOFireWireSBP2LSIWorkaroundDescriptor.
@discussion Create a IOFireWireSBP2LSIWorkaroundDescriptor with no permanent capacity then
inits it the given descriptor. This is basicly a short cut for calling
withCapacity( 0, 0, false) and the initWithDescriptor()
@param desc Original memory descriptor.
@param offset Offset of data to "fix" in bytes from beginning of descriptor.
@param len Length of data in bytes to "fix"
@param direction IODirection of data transfer.
@result Returns a new IOFireWireSBP2LSIWorkaroundDescriptor if successful.
*/
static IOFireWireSBP2LSIWorkaroundDescriptor * withDescriptor
( IOMemoryDescriptor * desc, IOByteCount offset = 0,
IOByteCount len = 0, IODirection direction = kIODirectionInOut );
// initialize with descriptor
/*!
@function initWithDescriptor
@abstract Initialize an IOFireWireSBP2LSIWorkaroundDescriptor with the given descriptor.
@discussion Initialize the workaround descriptor with the given descriptor.
@param desc Original memory descriptor.
@param offset Offset of data to "fix" in bytes from beginning of descriptor.
@param len Length of data in bytes to "fix"
@param direction IODirection of data transfer.
@result Returns true if the initialization was successful.
*/
virtual bool initWithDescriptor( IOMemoryDescriptor * desc, IOByteCount offset = 0,
IOByteCount len = 0, IODirection direction = kIODirectionInOut );
///////////////////////////////////
/*!
@function withCapacity
@abstract Create a new descriptor with possibly a permanent capacity.
@discussion Create and IOFireWireSBP2LSIWorkaroundDescriptor with a permanent fixed capacity.
You should call initWithDescriptor afterward. permanentRanges is number of ranges to keep
permanently allocated for use by the algorithm. If fixedCapacity is false additional ranges
may be allocated and deallocated dyanmicly if needed. The algorithm may require more or less
ranges than either the original descriptor or the final fixed may decriptor contain.
permanentBufferSpace is the number of bytes of permanent buffer to keep arround. If fixedCapacity
is false additional buffer space may be allocated and deallocated dynamically. permanentBufferSpace
should generally be set to 32 * maximum number of ranges. fixedCapacity is a flag indicating
whether dynamic allocations are allowed. When making decisions about the maximum amount of
buffer space to keep around, it should be noted tha the maximum number of ranges maybe different
from permanentRanges if fixedCapcity is false.
@param permanentRanges Count of permanent ranges.
@param permanentBufferSpace Byte count of permanent buffers.
@param fixedCapacity bool indicating if dynamic allocations can be made.
@result Returns true if the initialization was successful.
*/
static IOFireWireSBP2LSIWorkaroundDescriptor * withCapacity
( UInt32 permanentRanges, IOByteCount permanentBufferSpace, bool fixedCapacity );
///////////////////////////////////
//
// manipulate buffers for IO
//
/*!
@function syncBuffersForOutput
@abstract Synchronize the buffers for output.
@discussion Since double buffering may be invovled in the workaround. The driver needs to
indicate when these buffers should be syncronized with the original descriptor. For data
that will be output syncBuffersForOutput should be called before submiting the ORB.
@result Returns kIOReturnSuccess if sync was successful.
*/
virtual IOReturn syncBuffersForOutput( void ); // call before output
/*!
@function syncBuffersForInput
@abstract Synchronize the buffers for input.
@discussion Since double buffering may be invovled in the workaround. The driver needs to
indicate when these buffers should be syncronized with the original descriptor. For data
that will be input syncBuffersForOutput should be called after receiving completion status
for the ORB.
@result Returns kIOReturnSuccess if sync was successful.
*/
virtual IOReturn syncBuffersForInput( void ); // call after input
private:
OSMetaClassDeclareReservedUnused(IOFireWireSBP2LSIWorkaroundDescriptor, 0);
OSMetaClassDeclareReservedUnused(IOFireWireSBP2LSIWorkaroundDescriptor, 1);
OSMetaClassDeclareReservedUnused(IOFireWireSBP2LSIWorkaroundDescriptor, 2);
OSMetaClassDeclareReservedUnused(IOFireWireSBP2LSIWorkaroundDescriptor, 3);
OSMetaClassDeclareReservedUnused(IOFireWireSBP2LSIWorkaroundDescriptor, 4);
OSMetaClassDeclareReservedUnused(IOFireWireSBP2LSIWorkaroundDescriptor, 5);
OSMetaClassDeclareReservedUnused(IOFireWireSBP2LSIWorkaroundDescriptor, 6);
OSMetaClassDeclareReservedUnused(IOFireWireSBP2LSIWorkaroundDescriptor, 7);
OSMetaClassDeclareReservedUnused(IOFireWireSBP2LSIWorkaroundDescriptor, 8);
};
#endif
#endif
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/sbp2/IOFireWireSBP2Login.h | /*
* Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* The contents of this file constitute Original Code as defined in and
* are subject to the Apple Public Source License Version 1.1 (the
* "License"). You may not use this file except in compliance with the
* License. Please obtain a copy of the License at
* http://www.apple.com/publicsource and read it before using this file.
*
* This Original Code and all software distributed under the License are
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/*!
@header IOFireWireSBP2Login
Contains the class definition for IOFireWireSBP2Login.
*/
#ifndef _IOKIT_IOFIREWIRESBP2LOGIN_H
#define _IOKIT_IOFIREWIRESBP2LOGIN_H
#include <IOKit/IOCommandGate.h>
#include <IOKit/firewire/IOFireWireUnit.h>
#include <IOKit/sbp2/IOFireWireSBP2ORB.h>
#include <IOKit/sbp2/IOFireWireSBP2Target.h>
// login option flags
enum
{
kFWSBP2DontSynchronizeMgmtAgent = (1 << 0),
kFWSBP2ExclusiveLogin = (1 << 5)
};
// notification events
enum
{
kFWSBP2NormalCommandStatus = 6,
kFWSBP2NormalCommandTimeout = 7,
kFWSBP2UnsolicitedStatus = 8,
kFWSBP2NormalCommandReset = 9
};
#define kIOMessageFWSBP2ReconnectComplete iokit_fw_err(0x3E8)
#define kIOMessageFWSBP2ReconnectFailed iokit_fw_err(0x3E9)
/*!
@typedef FWSBP2LoginResponse
@param length Length of login response.
@param loginID Unique id representing this login.
@param commandBlockAgentAddressHi High 32 bits of command block agent address.
@param commandBlockAgentAddressLo Low 32 bits of command block agent address.
@param reserved Reserved.
@param reconnectHold Reconnect timeout encoded as 2^reconnectHold seconds.
*/
typedef struct
{
UInt16 length;
UInt16 loginID;
UInt32 commandBlockAgentAddressHi;
UInt32 commandBlockAgentAddressLo;
UInt16 reserved;
UInt16 reconnectHold;
} FWSBP2LoginResponse, *FWSBP2LoginResponsePtr;
/*!
@typedef FWSBP2StatusBlock
@param details Src, Resp, D, Len fields of status block format
@param sbpStatus SBP2 specific status
@param orbOffsetHi High 32 bits of address of orb status is for.
@param orbOffsetLo Low 32 bits of address of orb status is for.
@param status[6] Up to 48 bytes of additional data. Length is determined by len field.
*/
typedef struct
{
UInt8 details;
UInt8 sbpStatus;
UInt16 orbOffsetHi;
UInt32 orbOffsetLo;
UInt32 status[6];
} FWSBP2StatusBlock;
class IOFireWireSBP2LUN;
class IOFireWireSBP2Login;
// struct sent to login complete handler
/*!
@typedef FWSBP2LoginCompleteParams
@param login Pointer to IOFireWireSBP2Login object.
@param generation FireWire generation value.
@param status Status of login attempt.
@param loginResponse Pointer to login response struct.
@param statusBlock Pointer to status block buffer.
@param statusBlockLength Length of entire status block.
*/
typedef struct
{
IOFireWireSBP2Login * login; // login object this param is sent from
UInt32 generation; // generation this login was attempted in
IOReturn status; // status of login attempt
FWSBP2LoginResponsePtr loginResponse; // pointer to loginResponse buffer
FWSBP2StatusBlock * statusBlock; // pointer to statusBlock buffer
UInt32 statusBlockLength; // size of statusBlock buffer
} FWSBP2LoginCompleteParams, *FWSBP2LoginCompleteParamsPtr;
// struct sent to logout complete handler
/*!
@typedef FWSBP2LogoutCompleteParams
@param login Pointer to IOFireWireSBP2Login object.
@param generation FireWire generation value.
@param status Status of login attempt.
@param statusBlock Pointer to status block buffer.
@param statusBlockLength Length of entire status block.
*/
typedef struct
{
IOFireWireSBP2Login * login; // login object this param is sent from
UInt32 generation; // generation this login was attempted in
IOReturn status; // status of login attempt
FWSBP2StatusBlock * statusBlock; // pointer to statusBlock buffer
UInt32 statusBlockLength; // size of statusBlock buffer
} FWSBP2LogoutCompleteParams, *FWSBP2LogoutCompleteParamsPtr;
// struct sent with reconnect notification
/*!
@typedef FWSBP2LogoutCompleteParams
@param login Pointer to IOFireWireSBP2Login object.
@param generation FireWire generation value.
@param status Status of login attempt.
@param reconnectStatusBlock Pointer to status block buffer.
@param reconnectStatusBlockLength Length of entire status block.
*/
typedef struct
{
IOFireWireSBP2Login * login; // login object this param is sent from
UInt32 generation; // generation this login was attempted in
IOReturn status; // status of reconnect attempt
void * reconnectStatusBlock; // pointer to statusBlock buffer
UInt32 reconnectStatusBlockLength; // size of statusBlock buffer
} FWSBP2ReconnectParams, *FWSBP2ReconnectParamsPtr;
// Callback when login and logout commands complete asynchronously
/*!
@typedef FWSBP2LoginCallback
@param refCon Reference constant supplied when the notification was registered.
@param params Structure containing additional information about the status of the login.
*/
typedef void (*FWSBP2LoginCallback)(void * refCon, FWSBP2LoginCompleteParamsPtr params);
/*!
@typedef FWSBP2LogoutCallback
@param refCon Reference constant supplied when the notification was registered.
@param params Structure containing additional information about the status of the logout.
*/
typedef void (*FWSBP2LogoutCallback)(void * refCon, FWSBP2LogoutCompleteParamsPtr params);
/*!
@typedef FWSBP2StatusCallback
@param refCon Reference constant supplied when the notification was registered.
@param status Indicates success or failure of operation.
*/
typedef void (*FWSBP2StatusCallback)(void * refCon, IOReturn status);
/*!
@typedef FWSBP2FetchAgentWriteCallback
@param refCon Reference constant supplied when the notification was registered.
@param status Indicates success or failure of operation.
@param orb Indicates current last orb in chain.
*/
typedef void (*FWSBP2FetchAgentWriteCallback)(void * refCon, IOReturn status, IOFireWireSBP2ORB * orb);
/*!
@typedef FWSBP2NotifyParams
@param notificationEvent Type of event we are being notified of.
@param message buffer containing message.
@param length length of message field.
@param generation FireWire generation value.
*/
typedef struct
{
void * commandObject;
UInt32 notificationEvent;
const void * message;
UInt32 length;
UInt32 generation;
} FWSBP2NotifyParams, *FWSBP2NotifyParamsPtr;
/*!
@typedef FWSBP2NotifyCallback
@param refCon Reference constant supplied when the notification was registered.
@param params FWSBP2NotifyParams containing notification information.
*/
typedef void (*FWSBP2NotifyCallback)(void * refCon, FWSBP2NotifyParamsPtr params);
/*!
@class IOFireWireSBP2Login
@abstract Supplies the login maintenance and Normal Command ORB execution portions of the API.
@discussion Supplies APIs for login maintenance and command execution. Drivers can use this
object to create IOFireWireSBP2ORB objects and execute them. Solicited and unsolicited status
callback routines can be registered and the SBP2 services will notify the driver when the
appropriate status arrives.
This class also handles login maintenance. Supplies APIs for logging in and logging out and
attempts to reconnect to the LUN after bus resets. The base FireWire services deliver bus
reset notification via the IOKit message routine. The SBP2 services build on this behavior
and deliver reconnectFailed and reconnectComplete through the message routine as well.
*/
class IOFireWireSBP2Login : public OSObject
{
OSDeclareDefaultStructors( IOFireWireSBP2Login )
friend class IOFireWireSBP2ORB;
friend class IOFireWireSBP2LUN;
friend class IOFireWireSBP2UserClient;
protected:
// command selectors
enum
{
kLoginCommandIdle = 0,
kLoginCommandDoLogin = 1,
kLoginCommandDoLogout = 2,
kLoginAddORB = 3,
kLoginRemoveORB = 4,
kLoginFetchAgentReset = 5
};
// internal login states
enum
{
kLoginStateIdle = 0,
kLoginStateLoggingIn = 1,
kLoginStateConnected = 2,
kLoginStateReconnect = 3,
kLoginStateLoggingOut = 4,
kLoginStateTerminated = 5
};
// rom keys
enum
{
kUnitCharacteristicsKey = 0x3A,
kManagementAgentOffsetKey = 0x54
};
// sbp2 defs
enum
{
kFWSBP2RequestComplete = 0,
kFWSBP2TransportFailure = 1,
kFWSBP2IllegalRequest = 2,
kFWSBP2VendorDependent = 3
};
enum
{
kFWSBP2NoSense = 0,
kFWSBP2RequestTypeNotSupported = 1,
kFWSBP2SpeedNotSupported = 2,
kFWSBP2PageSizeNotSupported = 3,
kFWSBP2AccessDenied = 4,
kFWSBP2LogicalUnitNotSupported = 5,
kFWSBP2MaxPayloadTooSmall = 6,
kFWSBP2FunctionRejected = 9,
kFWSBP2LoginIDNotRecognized = 10,
kFWSBP2DummyORBCompleted = 11,
kFWSBP2RequestAborted = 12,
kFWSBP2UnspecifiedError = 0xFF
};
typedef struct
{
UInt32 password[2];
UInt32 loginResponseAddressHi;
UInt32 loginResponseAddressLo;
UInt16 options;
UInt16 lun;
UInt16 passwordLength;
UInt16 loginResponseLength;
UInt32 statusFIFOAddressHi;
UInt32 statusFIFOAddressLo;
} FWSBP2LoginORB;
typedef struct
{
UInt32 reserved1[4];
UInt16 options;
UInt16 loginID;
UInt32 reserved2;
UInt32 statusFIFOAddressHi;
UInt32 statusFIFOAddressLo;
} FWSBP2ReconnectORB;
typedef struct
{
UInt32 reserved1[4];
UInt16 options;
UInt16 loginID;
UInt32 reserved2;
UInt32 statusFIFOAddressHi;
UInt32 statusFIFOAddressLo;
} FWSBP2LogoutORB;
protected:
///////////////////////////////////////////////////////////////////
// private interface methods
// IOFireWireSBP2LUN methods
virtual void clearAllTasksInSet( void );
virtual bool initWithLUN( IOFireWireSBP2LUN * lun );
virtual void suspendedNotify( void );
virtual void resumeNotify( void );
// IOFireWireSBP2ORB methods
virtual IOFireWireUnit * getFireWireUnit( void );
virtual IOFireWireSBP2LUN * getFireWireLUN( void );
virtual bool isFetchAgentWriteInProgress( void );
virtual bool isConnected( void );
virtual IOReturn removeORB( IOFireWireSBP2ORB * orb );
virtual IOReturn appendORBImmediate( IOFireWireSBP2ORB * orb );
virtual IOReturn appendORB( IOFireWireSBP2ORB * orb );
virtual void sendTimeoutNotification( IOFireWireSBP2ORB * orb );
protected:
// reserved for future use
struct ExpansionData { };
ExpansionData *reserved;
IOFireWireSBP2LUN * fLUN;
IOFireWireUnit * fUnit;
IOFireWireController * fControl;
IOCommandGate * fGate;
FWSBP2LoginCallback fLoginCompletionCallback;
void * fLoginCompletionRefCon;
FWSBP2LogoutCallback fLogoutCompletionCallback;
void * fLogoutCompletionRefCon;
FWSBP2NotifyCallback fStatusNotifyCallback;
void * fStatusNotifyRefCon;
FWSBP2NotifyCallback fUnsolicitedStatusNotifyCallback;
void * fUnsolicitedStatusNotifyRefCon;
UInt32 fLoginFlags;
UInt32 fReconnectTime;
UInt32 fLoginState;
UInt32 fManagementOffset;
UInt32 fManagementTimeout;
UInt32 fMaxORBSize;
UInt32 fMaxCommandBlockSize;
UInt16 fLoginNodeID;
UInt32 fLoginGeneration;
UInt32 fLoginID;
UInt32 fReconnectHold;
UInt32 fMaxPayloadSize;
void * fRefCon;
// resources
FWSBP2LoginORB fLoginORB;
IOFWAddressSpace * fLoginORBAddressSpace;
FWAddress fLoginORBAddress;
FWSBP2LoginResponse fLoginResponse;
IOFWAddressSpace * fLoginResponseAddressSpace;
FWAddress fLoginResponseAddress;
FWSBP2ReconnectORB fReconnectORB;
IOFWAddressSpace * fReconnectORBAddressSpace;
FWAddress fReconnectORBAddress;
FWSBP2StatusBlock fStatusBlock;
IOFWAddressSpace * fStatusBlockAddressSpace;
FWAddress fStatusBlockAddress;
FWSBP2StatusBlock fReconnectStatusBlock;
IOFWAddressSpace * fReconnectStatusBlockAddressSpace;
FWAddress fReconnectStatusBlockAddress;
FWSBP2LogoutORB fLogoutORB;
IOFWAddressSpace * fLogoutORBAddressSpace;
FWAddress fLogoutORBAddress;
bool fLogoutPending;
IOFWWriteCommand * fLoginWriteCommand;
IOMemoryDescriptor * fLoginWriteCommandMemory;
bool fLoginWriteInProgress;
IOFWWriteCommand * fReconnectWriteCommand;
IOMemoryDescriptor * fReconnectWriteCommandMemory;
bool fReconnectWriteInProgress;
bool fReconnectWriteInterrupted;
IOFWWriteCommand * fLogoutWriteCommand;
IOMemoryDescriptor * fLogoutWriteCommandMemory;
bool fLogoutWriteInProgress;
IOFWCommand * fLoginTimeoutCommand;
bool fLoginTimeoutTimerSet;
IOFWDelayCommand * fReconnectTimeoutCommand;
bool fReconnectTimeoutTimerSet;
IOFWCommand * fLogoutTimeoutCommand;
bool fLogoutTimeoutTimerSet;
FWAddress fFetchAgentAddress;
IOMemoryDescriptor * fFetchAgentWriteCommandMemory;
FWAddress fLastORBAddress;
IOFireWireSBP2ORB * fLastORB;
IOFWWriteCommand * fFetchAgentWriteCommand;
bool fFetchAgentWriteCommandInUse;
FWSBP2FetchAgentWriteCallback fFetchAgentWriteCompletion;
void * fFetchAgentWriteRefCon;
IOFireWireSBP2ORB * fORBToWrite;
OSSet * fORBSet;
OSIterator * fORBSetIterator;
void * fPasswordBuf;
UInt32 fPasswordLen;
IOFWAddressSpace * fPasswordAddressSpace;
FWAddress fPasswordAddress;
IOMemoryDescriptor * fPasswordDescriptor;
bool fSuspended;
UInt32 fLoginRetryDelay;
UInt32 fLoginRetryCount;
UInt32 fLoginRetryMax;
IOFWDelayCommand * fLoginRetryTimeoutCommand;
bool fLoginRetryTimeoutTimerSet;
IOFireWireSBP2Target * fTarget;
bool fUnsolicitedStatusEnableRequested;
IOFWDelayCommand * fReconnectRetryTimeoutCommand;
bool fReconnectRetryTimeoutTimerSet;
int fCriticalSectionCount;
// init / destroy
virtual IOReturn getUnitInformation( void );
virtual IOReturn allocateResources( void );
virtual void free( void ) APPLE_KEXT_OVERRIDE;
// orb add / remove
virtual IOReturn addORB( IOFireWireSBP2ORB * orb );
static IOReturn staticExecuteAddORB( OSObject *self, void * orb, void *, void *, void * );
virtual IOReturn executeAddORB( IOFireWireSBP2ORB * orb );
static IOReturn staticExecuteRemoveORB( OSObject *self, void * orb, void *, void *, void * );
virtual IOReturn executeRemoveORB( IOFireWireSBP2ORB * orb );
//
// login
//
static IOReturn staticExecuteLogin( OSObject *self, void *, void *, void *, void * );
virtual IOReturn executeLogin( void );
virtual void abortLogin( void );
// login write complete handler
static void loginWriteCompleteStatic( void *refcon, IOReturn status, IOFireWireNub *device, IOFWCommand *fwCmd );
virtual void loginWriteComplete( IOReturn status, IOFireWireNub *device, IOFWCommand *fwCmd );
// login timeout handler
static void loginTimeoutStatic( void *refcon, IOReturn status, IOFireWireBus *bus, IOFWBusCommand *fwCmd );
virtual void loginTimeout( IOReturn status, IOFireWireBus *bus, IOFWBusCommand *fwCmd );
// status block write handler
static UInt32 statusBlockWriteStatic(void *refcon, UInt16 nodeID, IOFWSpeed &speed, FWAddress addr, UInt32 len,
const void *buf, IOFWRequestRefCon lockRead);
virtual UInt32 statusBlockWrite( UInt16 nodeID, IOFWSpeed &speed, FWAddress addr, UInt32 len, const void *buf, IOFWRequestRefCon lockRead);
virtual void completeLogin( IOReturn state, const void *buf = NULL, UInt32 len = 0, void * buf2 = NULL );
//
// reconnect
//
virtual void doReconnect( void );
virtual void restartReconnect( void );
virtual void startReconnectTimer( void );
// reconnect write complete handler
static void reconnectWriteCompleteStatic( void *refcon, IOReturn status, IOFireWireNub *device, IOFWCommand *fwCmd );
virtual void reconnectWriteComplete( IOReturn status, IOFireWireNub *device, IOFWCommand *fwCmd );
// reconnect timeout handler
static void reconnectTimeoutStatic( void *refcon, IOReturn status, IOFireWireBus *bus, IOFWBusCommand *fwCmd );
virtual void reconnectTimeout( IOReturn status, IOFireWireBus *bus, IOFWBusCommand *fwCmd );
// reconnect status block
static UInt32 reconnectStatusBlockWriteStatic(void *refcon, UInt16 nodeID, IOFWSpeed &speed, FWAddress addr,
UInt32 len, const void *buf, IOFWRequestRefCon lockRead);
virtual UInt32 reconnectStatusBlockWrite( UInt16 nodeID, IOFWSpeed &speed, FWAddress addr, UInt32 len,
const void *buf, IOFWRequestRefCon lockRead);
virtual void sendReconnectNotification( UInt32 event );
virtual void sendReconnectNotificationWithStatusBlock( UInt32 event );
//
// logout
//
static IOReturn staticExecuteLogout( OSObject *self, void *, void *, void *, void * );
virtual IOReturn executeLogout( void );
// logout write complete handler
static void logoutWriteCompleteStatic( void *refcon, IOReturn status, IOFireWireNub *device, IOFWCommand *fwCmd );
virtual void logoutWriteComplete( IOReturn status, IOFireWireNub *device, IOFWCommand *fwCmd );
// logout timeout handler
static void logoutTimeoutStatic( void *refcon, IOReturn status, IOFireWireBus *bus, IOFWBusCommand *fwCmd );
virtual void logoutTimeout( IOReturn status, IOFireWireBus *bus, IOFWBusCommand *fwCmd );
virtual void completeLogout( IOReturn state, const void *buf = NULL, UInt32 len = 0);
// fetch agent write complete handler
static void fetchAgentWriteCompleteStatic( void *refcon, IOReturn status, IOFireWireNub *device, IOFWCommand *fwCmd );
virtual void fetchAgentWriteComplete( IOReturn status, IOFireWireNub *device, IOFWCommand *fwCmd );
//
// fetch agent
//
bool fFetchAgentResetInProgress;
UInt32 fFetchAgentResetBuffer;
FWAddress fFetchAgentResetAddress;
IOFWWriteQuadCommand * fFetchAgentResetCommand;
void * fFetchAgentResetRefCon;
FWSBP2StatusCallback fFetchAgentResetCompletion;
static IOReturn staticExecuteFetchAgentReset( OSObject *self, void *, void *, void *, void * );
virtual IOReturn executeFetchAgentReset( void );
static void fetchAgentResetCompleteStatic( void *refcon, IOReturn status, IOFireWireNub *device, IOFWCommand *fwCmd );
virtual void fetchAgentResetComplete( IOReturn status, IOFireWireNub *device, IOFWCommand *fwCmd );
//
// doorbell
//
bool fDoorbellInProgress;
bool fDoorbellRingAgain;
UInt32 fDoorbellBuffer;
FWAddress fDoorbellAddress;
IOFWWriteQuadCommand * fDoorbellCommand;
static IOReturn staticExecuteDoorbell( OSObject *self, void *, void *, void *, void * );
virtual IOReturn executeDoorbell( void );
static void doorbellCompleteStatic( void *refcon, IOReturn status, IOFireWireNub *device, IOFWCommand *fwCmd );
virtual void doorbellComplete( IOReturn status, IOFireWireNub *device, IOFWCommand *fwCmd );
//
// enable unsolicited satus
//
bool fUnsolicitedStatusEnableInProgress;
UInt32 fUnsolicitedStatusEnableBuffer;
FWAddress fUnsolicitedStatusEnableAddress;
IOFWWriteQuadCommand * fUnsolicitedStatusEnableCommand;
static IOReturn staticExecuteUnsolicitedStatusEnable( OSObject *self, void *, void *, void *, void * );
virtual IOReturn executeUnsolicitedStatusEnable( void );
static void unsolicitedStatusEnableCompleteStatic( void *refcon, IOReturn status, IOFireWireNub *device, IOFWCommand *fwCmd );
virtual void unsolicitedStatusEnableComplete( IOReturn status, IOFireWireNub *device, IOFWCommand *fwCmd );
//
// busy timeout stuff
//
bool fSetBusyTimeoutInProgress;
UInt32 fSetBusyTimeoutBuffer;
FWAddress fSetBusyTimeoutAddress;
IOFWWriteQuadCommand * fSetBusyTimeoutCommand;
bool fInCriticalSection;
UInt16 fLocalNodeID;
bool fFastStartSupported;
UInt32 fFastStartOffset;
UInt32 fFastStartMaxPayload;
UInt32 fUserLoginGeneration;
bool fUserLoginGenerationSet;
IOFWDelayCommand * fFetchAgentRetryTimerCommand;
bool fFetchAgentRetryTimerSet;
virtual IOReturn executeSetBusyTimeout( void );
static void setBusyTimeoutCompleteStatic( void *refcon, IOReturn status, IOFireWireNub *device, IOFWCommand *fwCmd );
virtual void setBusyTimeoutComplete( IOReturn status, IOFireWireNub *device, IOFWCommand *fwCmd );
private:
// IOFireWireSBP2ORB friend class wrappers
OSMetaClassDeclareReservedUnused(IOFireWireSBP2Login, 0);
protected:
virtual bool initORBWithLogin( IOFireWireSBP2ORB * orb, IOFireWireSBP2Login * login );
virtual void setNextORBAddress( IOFireWireSBP2ORB * orb, FWAddress address );
virtual void fetchAgentWriteComplete( IOFireWireSBP2ORB * orb, IOReturn status );
virtual bool isORBTimerSet( IOFireWireSBP2ORB * orb );
virtual void cancelORBTimer( IOFireWireSBP2ORB * orb );
// IOFireWireSBP2LUN friend class wrappers
virtual void removeLogin( void );
virtual IOFireWireSBP2Target * getTarget( void );
UInt32 fARDMAMax;
bool fPhysicalAccessEnabled;
bool fLoginStatusReceived;
FWSBP2StatusBlock fLoginStatusBlock;
UInt32 fLoginStatusBlockLen;
private:
OSMetaClassDeclareReservedUnused(IOFireWireSBP2Login, 1);
OSMetaClassDeclareReservedUnused(IOFireWireSBP2Login, 2);
OSMetaClassDeclareReservedUnused(IOFireWireSBP2Login, 3);
OSMetaClassDeclareReservedUnused(IOFireWireSBP2Login, 4);
OSMetaClassDeclareReservedUnused(IOFireWireSBP2Login, 5);
public:
//////////////////////////////
/*!
@function createORB
@abstract Creates a new IOFireWireSBP2ORB for this login.
@discussion Create a new IOFireWireSBP2ORB for this login. It can be configured
with it's accessors and executed with submitORB below.
@result Returns a pointer to the new ORB object.
*/
virtual IOFireWireSBP2ORB * createORB( void );
/*!
@function submitORB
@abstract Submits the given orb
@discussion Starts execution of the given ORB. If the ORB is an immediate ORB it's
addresss is written to the fetch agent. If it is a non immediate orb its address
is appended to the last orb of the currently processing chain. The doorbell is not
rung automatically it must be run manually with the ringDoorbell command described below.
@param orb The orb to be executed.
@result Returns kIOReturnSuccess if the ORB has been started successfully.
*/
virtual IOReturn submitORB( IOFireWireSBP2ORB * orb );
// set callbacks
/*!
@function setStatusNotifyProc
@abstract Sets the callback to be called on normal command status.
@discussion The supplied callback is called when normal command status is recieved, when
a normal command times out, or when a normal command is aborted.
"notificationEvent" in the callback's params will indicate what happened.
It will be set to one of the following values: kFWSBP2NormalCommandReset, kFWSBP2NormalCommandStatus,
or kFWSBP2NormalCommandTimeout. If the event type is kFWSBP2NormalCommandTimeout and "len" is
non-zero then "message" contains the data written to the status block.
@param refCon refCon passed to callback.
@param callback address of callback method of type FWSBP2NotifyCallback.
*/
virtual void setStatusNotifyProc( void * refCon, FWSBP2NotifyCallback callback );
/*!
@function getStatusNotifyProc
@abstract Returns the callback to be called on normal command status.
@discussion Returns the refCon and callback address of the status notify callback.
@param refCon output parameter returning the refCon to be passed to the callback.
@param callback output parameter returning the address of the callback.
*/
virtual void getStatusNotifyProc( void ** refCon, FWSBP2NotifyCallback * callback );
/*!
@function setUnsolicitedStatusNotifyProc
@abstract Sets the callback to be called on normal command status.
@discussion The supplied callback is called when unsolicited status is recieved.
"notificationEvent" in the callback's params will indicate what happened. In this
case it will be set to kFWSBP2UnsolicitedStatus. If "len" is
non-zero then "message" contains the data written to the status block. Note: any buffers
returned by callbacks are only valid for the duration of the login and should not have
their contents modified.
@param refCon refCon passed to callback.
@param callback address of callback method of type FWSBP2NotifyCallback.
*/
virtual void setUnsolicitedStatusNotifyProc( void * refCon, FWSBP2NotifyCallback callback );
/*!
@function getUnsolicitedStatusNotifyProc
@abstract Returns the callback to be called on unsolicited status.
@discussion Returns the refCon and callback address of the unsolicited status notify callback.
@param refCon output parameter returning the refCon to be passed to the callback.
@param callback output parameter returning the address of the callback.
*/
virtual void getUnsolicitedStatusNotifyProc( void ** refCon, FWSBP2NotifyCallback * callback );
// command handling
/*!
@function setLoginCompletion
@abstract Sets the callback to be called when a login attempt is complete.
@discussion The supplied callback is called when a login attempt has completed. "status" in the
callback's params should be checked to determine the success or failure of the login attempt.
If "statusBlock" is non-null then login status was written and it has been supplied here. If
the login attempt was successful then the login response will be supplied in the "loginResponse"
buffer. Note: all buffers supplied to callbacks are only valid for the duration of the callback.
Also, you are not to modify the contents of any supplied buffer.
@param refCon refCon passed to callback.
@param callback address of callback method of type FWSBP2LoginCallback.
*/
virtual void setLoginCompletion( void * refCon, FWSBP2LoginCallback completion );
/*!
@function submitLogin
@abstract Attempts to login to the LUN.
@discussion This call begins the login process. The login object should be configured prior
to this call. If kIOReturnSuccess is returned from this call then the loginCompletion routine
will be called when the login completes (successfully or unsuccesfully).
@result Returns kIOReturnSuccess login has successlly begun.
*/
virtual IOReturn submitLogin( void );
/*!
@function submitLogout
@abstract Attempts to logout of the LUN.
@discussion This call begins the logout process. If kIOReturnSuccess is returned from this call then
the logoutCompletion routine will be called when the logout completes (successfully or unsuccesfully).
@result Returns kIOReturnSuccess if logout has successfully begun.
*/
virtual IOReturn submitLogout( void );
/*!
@function setLogoutCompletion
@abstract Sets the callback to be called when a logout attempt is complete.
@discussion The supplied callback is called when a logout attempt has completed. "status" in the
callback's params should be checked to determine the success or failure of the logout attempt.
If "statusBlock" is non-null then logout status was written and it has been supplied here.
Note: all buffers supplied to callbacks are only valid for the duration of the callback.
Also, you are not to modify the contents of any supplied buffer.
@param refCon refCon passed to callback.
@param callback address of callback method of type FWSBP2LogoutCallback.
*/
virtual void setLogoutCompletion( void * refCon, FWSBP2LogoutCallback completion );
/*!
@function setFetchAgentWriteCompletion
@abstract Sets the callback to be called when the fetch agent write completes.
@discussion When an immediate orb is executed with submitORB, it's address is written to a
specific address on the device. This address is called the fetch agent. The device the
reads that orb from the Mac's memory and executes it. With this call you can register to
be called back when this write to the fetch agent completes. The SBP2 services guarantee
that the fetch agent write will be complete before status is reported for an ORB, so for
most drivers this notification is not required.
@param refCon refCon passed to callback.
@param callback address of callback method of type FWSBP2FetchAgentWriteCallback.
*/
virtual void setFetchAgentWriteCompletion( void * refCon, FWSBP2FetchAgentWriteCallback completion );
/*!
@function setFetchAgentResetCompletion
@abstract Sets the callback to be called when a fetch agent reset completes.
@discussion The fetch agent state machine on the device can be reset by a write to a specific
register. The SBP2 services offer a utility method to reset the fetch agent. You can register
a callback routine here to be notified when this rest write completes.
@param refCon refCon passed to callback.
@param callback address of callback method of type FWSBP2FetchAgentWriteCallback.
*/
virtual void setFetchAgentResetCompletion( void * refCon, FWSBP2StatusCallback completion );
/*!
@function submitFetchAgentReset
@abstract Resets the LUN's fetch agent.
@discussion The fetch agent state machine on the device can be reset by a write to a specific
register. This reset can be intiated by a call to this method. Notification of the completion
of this write can be had by registering a callback with the setFetchAgentResetCompletion method.
@result Returns kIOReturnSuccess if the reset started successfully.
*/
virtual IOReturn submitFetchAgentReset( void );
/*!
@function ringDoorbell
@abstract Rings the doorbell on the LUN.
@discussion Non-immediate appends to the ORB chain may require the fetch agent state machine
to be notified of the new ORB's presence. This is accomplished by writing to the so called
doorbell register. This method begins one of those writes.
@result Returns kIOReturnSuccess if the ring started successfully.
*/
virtual IOReturn ringDoorbell( void );
/*!
@function enableUnsolicitedStatus
@abstract Enables unsolicited status.
@discussion After unsolicited is sent the device will not send any additional unsolicited status
until a specific register is written. This serves as a sort of flow-control for unsolicited status.
After unsolicited status is recieved and processed drivers will want to reenable the delivery
of unsolicted status by a call to this method.
@result Returns kIOReturnSuccess if the status enable write started successfully.
*/
virtual IOReturn enableUnsolicitedStatus( void );
// accessors
/*!
@function getMaxCommandBlockSize
@abstract Returns the maximum command block size.
@discussion The device publishes an upper limit on the size of command block that it can
accept. That value can be accessed via this method.
@result Returns a UInt32 containing the maximum command block size.
*/
virtual UInt32 getMaxCommandBlockSize( void );
/*!
@function getLoginID
@abstract Returns the current login ID.
@discussion When we successfully login to a device. The device gives us a unique login id.
This is used internally for reconnecting to the device after bus resets and for certain other
management ORBs. Most drivers are probably not interested in this value.
@result Returns a UInt32 containing the current login ID.
*/
virtual UInt32 getLoginID( void );
/*!
@function setLoginFlags
@abstract Sets login configuration flags.
@discussion Configures the login behavior according to the provided flags. Currently two
flags are defined for this API. kFWSBP2ExclusiveLogin sets the exclusive login bit in the
login ORB. kFWSBP2DontSynchronizeMgmtAgent allows simultaneous logins or reconnects to LUNs
with a common management agent (ie LUNs in the same unit directory).
@param loginFlags the login configuration flags.
*/
virtual void setLoginFlags( UInt32 loginFlags );
/*!
@function getLoginFlags
@abstract Returns the currently set login flags.
@discussion Returns the current state of the login flags. Currently there is only one
flag defined for this API. kFWSBP2ExclusiveLogin indicates that the exclusive login bit
should be set in the login ORB.
@result Returns a UInt32 containing the currently set login flags.
*/
virtual UInt32 getLoginFlags( void );
/*!
@function setReconnectTime
@abstract Sets the desired reconnect duration.
@discussion The target and initiator arbitrate the duration of the reconnect timeout. Here
the initiator specifies its desired timeout time in 2^reconnectTime seconds. After a
successful login the device returns the actual timeout value it wishes to use. This value
may be less than the reconnect timeout that the intiator specified if this is all that the
device can support.
@param reconnectTime The desired reconnect timeout encoded as 2^reconnectTime seconds.
*/
virtual void setReconnectTime( UInt32 reconnectTime );
/*!
@function getReconnectTime
@abstract Returns the currently set reconnect time.
@discussion Returns the currently desired initiator reconnect time encoded as 2^time seconds.
@result Returns a UInt32 containing the currently set reconnect time.
*/
virtual UInt32 getReconnectTime( void );
/*!
@function setMaxPayloadSize
@abstract Sets the maximum data transfer length for a normal command ORB.
@discussion Sets the maximum data transfer length for a normal command ORB. This value is
the maximum for all ORBs sent to this LUN. This can be trimmed further on an ORB by ORB basis,
by a similar call in the IOFireWireSBP2ORB itself.
@param reconnectTime The desired maximum payload size in bytes.
*/
virtual void setMaxPayloadSize( UInt32 maxPayloadSize );
/*!
@function getMaxPayloadSize
@abstract Returns the currently set maximum payload size.
@discussion Returns the currently global maximum payload size in bytes.
@result Returns a UInt32 containing the currently set maximum payload size.
*/
virtual UInt32 getMaxPayloadSize( void );
/*!
@function setPassword
@abstract Sets the login password.
@discussion Sets the login password using a buffer and a length. An alternate version exists
that accepts an IOMemoryDescriptor. If the password length is 8 or less the password is copied
directly into the login orb. If the length is greater than 8 the buffer is referenced by address
in the login ORB. In this case the buffer is not copied and should remain allocated for the
duration of the login attempt.
@param buf a pointer to the password buffer.
@param len the length in bytes of the password buffer.
@result Returns kIOReturnSuccess on success.
*/
virtual IOReturn setPassword( void * buf, UInt32 len );
/*!
@function setPassword
@abstract Sets the login password.
@discussion Sets the login password using an IOMemoryDescriptor. An alternate version exists
that accepts a buffer and a length. If the password length is 8 or less the password is copied
directly into the login orb. If the length is greater than 8 the buffer is referenced by address
in the login ORB.
@param memory an IOMemoryDescriptor referencing the password.
@result Returns kIOReturnSuccess on success.
*/
virtual IOReturn setPassword( IOMemoryDescriptor * memory );
/*!
@function setRefCon
@abstract Sets the login refCon.
@discussion Sets a user defined value on the login that can be retrieved later with the
method getRefCon.
@param refCon a user defined value.
*/
virtual void setRefCon( void * refCon );
/*!
@function getRefCon
@abstract Returns the refCon set with setRefCon.
@discussion Returns the user defined value previously stored in the login with setRefCon.
@result Returns the previously stored user defined value.
*/
virtual void * getRefCon( void );
/*!
@function setBusyTimeoutRegisterValue
@abstract Sets the value to be written to the BUSY_TIMEOUT register.
@discussion 1394-1995 defines a register known as the BUSY_TIMEOUT register. This register
controls the busy retry behavior of your device. The initial value for this register is
0x00000000. Which means busied transactions will not be retried. Since most devices want
their transactions retired on busy acks, the SBP2 service automatically updates the
BUSY_TIMEOUT register with the value specified here whenever necessary. Most drivers should
set this value to 0x0000000f.
@param timeout desired value of the BUSY_TIMEOUT register.
*/
virtual void setBusyTimeoutRegisterValue( UInt32 timeout );
protected:
virtual void startORBTimer( IOFireWireSBP2ORB * orb );
virtual void prepareORBForExecution( IOFireWireSBP2ORB * orb );
static IOReturn staticExecuteORB( OSObject *self, void * orb, void *, void *, void * );
virtual IOReturn executeORB( IOFireWireSBP2ORB * orb );
public:
/*!
@function release
@abstract Primary implementation of the release mechanism.
@discussion See OSObject.h for more information. When retainCount == when then call free().
*/
virtual void release() const APPLE_KEXT_OVERRIDE;
/*!
@function setLoginRetryCountAndDelayTime
@abstract Sets login retry behavior.
@discussion Sets login retry behavior.
@param retryCount number of times to retry logins
@param uSecs delay time in microseconds between login retries
*/
virtual void setLoginRetryCountAndDelayTime( UInt32 retryCount, UInt32 uSecs );
protected:
virtual IOReturn initialExecuteLogin( void );
virtual void startLoginRetryTimer( void );
virtual void stopLoginRetryTimer( void );
static void loginRetryTimeoutStatic( void *refcon, IOReturn status,
IOFireWireBus *bus, IOFWBusCommand *fwCmd );
virtual void loginRetryTimeout( IOReturn status, IOFireWireBus *bus, IOFWBusCommand *fwCmd);
virtual void startReconnectRetryTimer( void );
virtual void stopReconnectRetryTimer( void );
static void reconnectRetryTimeoutStatic( void *refcon, IOReturn status, IOFireWireBus *bus, IOFWBusCommand *fwCmd );
virtual void reconnectRetryTimeout( IOReturn status, IOFireWireBus *bus, IOFWBusCommand *fwCmd );
virtual bool isORBAppended( IOFireWireSBP2ORB * orb );
virtual void setORBIsAppended( IOFireWireSBP2ORB * orb, bool state );
public:
virtual void setAddressLoForLoginORBAndResponse( UInt32 addressLoORB, UInt32 addresLoResponse );
virtual void setLoginGeneration( UInt32 generation );
virtual void clearLoginGeneration( void );
protected:
void startFetchAgentRetryTimer( UInt32 duration );
void stopFetchAgentRetryTimer( void );
static void fetchAgentRetryTimerStatic( void *refcon, IOReturn status, IOFireWireBus *bus, IOFWBusCommand *fwCmd );
void fetchAgentRetryTimer( IOReturn status, IOFireWireBus *bus, IOFWBusCommand *fwCmd );
void terminateNotify( void );
void processLoginWrite( void );
public:
bool isPhysicalAccessEnabled( void );
UInt32 getARDMMax( void );
private:
OSMetaClassDeclareReservedUnused(IOFireWireSBP2Login, 6);
OSMetaClassDeclareReservedUnused(IOFireWireSBP2Login, 7);
OSMetaClassDeclareReservedUnused(IOFireWireSBP2Login, 8);
};
#endif
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/sbp2/IOFireWireSBP2UserClient.h | /*
* Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* The contents of this file constitute Original Code as defined in and
* are subject to the Apple Public Source License Version 1.1 (the
* "License"). You may not use this file except in compliance with the
* License. Please obtain a copy of the License at
* http://www.apple.com/publicsource and read it before using this file.
*
* This Original Code and all software distributed under the License are
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _IOKIT_IOFIREWIRESBP2USERCLIENT_H
#define _IOKIT_IOFIREWIRESBP2USERCLIENT_H
#include <IOKit/IOUserClient.h>
#define FIREWIREPRIVATE
#include <IOKit/firewire/IOFireWireController.h>
#undef FIREWIREPRIVATE
#include <IOKit/firewire/IOFWUserObjectExporter.h>
#include <IOKit/sbp2/IOFireWireSBP2UserClientCommon.h>
#include <IOKit/sbp2/IOFireWireSBP2LUN.h>
class IOFireWireSBP2UserClient : public IOUserClient
{
OSDeclareDefaultStructors(IOFireWireSBP2UserClient)
protected:
bool fOpened;
bool fStarted;
IOFireWireSBP2Login * fLogin;
task_t fTask;
IOFireWireSBP2LUN * fProviderLUN;
OSAsyncReference64 fMessageCallbackAsyncRef;
OSAsyncReference64 fLoginCallbackAsyncRef;
OSAsyncReference64 fLogoutCallbackAsyncRef;
OSAsyncReference64 fUnsolicitedStatusNotifyAsyncRef;
OSAsyncReference64 fStatusNotifyAsyncRef;
OSAsyncReference64 fFetchAgentResetAsyncRef;
OSAsyncReference64 fFetchAgentWriteAsyncRef;
IOFWUserObjectExporter * fExporter;
IOFireWireLib::UserObjectHandle fSessionRef;
IOLock * fUserClientLock;
virtual IOReturn externalMethod( uint32_t selector,
IOExternalMethodArguments * args,
IOExternalMethodDispatch * dispatch,
OSObject * target,
void * reference ) APPLE_KEXT_OVERRIDE;
public:
virtual bool initWithTask( task_t owningTask, void * securityToken, UInt32 type, OSDictionary * properties ) APPLE_KEXT_OVERRIDE;
virtual void free () APPLE_KEXT_OVERRIDE;
virtual bool start( IOService * provider ) APPLE_KEXT_OVERRIDE;
virtual IOReturn clientClose( void ) APPLE_KEXT_OVERRIDE;
virtual IOReturn clientDied( void ) APPLE_KEXT_OVERRIDE;
// IOFireWireSBP2ManagementORB friend class wrappers
virtual void flushAllManagementORBs( void );
/////////////////////////////////////////////////
// IOFireWireSBP2LUN
IOReturn open( IOExternalMethodArguments * arguments );
IOReturn openWithSessionRef( IOExternalMethodArguments * arguments );
IOReturn getSessionRef( IOExternalMethodArguments * arguments );
IOReturn close( IOExternalMethodArguments * arguments );
// callbacks
IOReturn setMessageCallback( IOExternalMethodArguments * arguments );
virtual IOReturn message( UInt32 type, IOService * provider, void * arg ) APPLE_KEXT_OVERRIDE;
/////////////////////////////////////////////////
// IOFireWireSBP2Login
IOReturn setLoginCallback( IOExternalMethodArguments * arguments );
IOReturn setLogoutCallback( IOExternalMethodArguments * arguments );
IOReturn setUnsolicitedStatusNotify( IOExternalMethodArguments * arguments );
IOReturn setStatusNotify( IOExternalMethodArguments * arguments );
IOReturn createLogin( IOExternalMethodArguments * arguments );
IOReturn releaseLogin( IOExternalMethodArguments * arguments );
IOReturn submitLogin( IOExternalMethodArguments * arguments );
IOReturn submitLogout( IOExternalMethodArguments * arguments );
IOReturn setLoginFlags( IOExternalMethodArguments * arguments );
IOReturn getMaxCommandBlockSize( IOExternalMethodArguments * arguments );
IOReturn getLoginID( IOExternalMethodArguments * arguments );
IOReturn setReconnectTime( IOExternalMethodArguments * arguments );
IOReturn setMaxPayloadSize( IOExternalMethodArguments * arguments );
IOReturn submitFetchAgentReset( IOExternalMethodArguments * arguments );
IOReturn setFetchAgentWriteCompletion( IOExternalMethodArguments * arguments );
IOReturn ringDoorbell( IOExternalMethodArguments * arguments );
IOReturn enableUnsolicitedStatus( IOExternalMethodArguments * arguments );
IOReturn setBusyTimeoutRegisterValue( IOExternalMethodArguments * arguments );
IOReturn setPassword( IOExternalMethodArguments * arguments );
// callbacks
static void staticLoginCallback( void * refCon, FWSBP2LoginCompleteParamsPtr params );
virtual void loginCallback( FWSBP2LoginCompleteParamsPtr params );
static void staticLogoutCallback( void * refCon, FWSBP2LogoutCompleteParamsPtr params );
virtual void logoutCallback( FWSBP2LogoutCompleteParamsPtr params );
static void staticStatusNotify( void * refCon, FWSBP2NotifyParams * params );
virtual void statusNotify( FWSBP2NotifyParams * params );
static void staticUnsolicitedNotify( void * refCon, FWSBP2NotifyParams * params );
virtual void unsolicitedNotify( FWSBP2NotifyParams * params );
static void staticFetchAgentWriteComplete( void * refCon, IOReturn status, IOFireWireSBP2ORB * orb );
virtual void fetchAgentWriteComplete( IOReturn status, IOFireWireSBP2ORB * orb );
static void staticFetchAgentResetComplete( void * refCon, IOReturn status );
virtual void fetchAgentResetComplete( IOReturn status );
/////////////////////////////////////////////////
// IOFireWireSBP2ORB
IOReturn createORB( IOExternalMethodArguments * arguments );
IOReturn releaseORB( IOExternalMethodArguments * arguments );
IOReturn submitORB( IOExternalMethodArguments * arguments );
IOReturn setCommandFlags( IOExternalMethodArguments * arguments );
IOReturn setORBRefCon( IOExternalMethodArguments * arguments );
IOReturn setMaxORBPayloadSize( IOExternalMethodArguments * arguments );
IOReturn setCommandTimeout( IOExternalMethodArguments * arguments );
IOReturn setCommandGeneration( IOExternalMethodArguments * arguments );
IOReturn setToDummy( IOExternalMethodArguments * arguments );
IOReturn setCommandBuffersAsRanges( IOExternalMethodArguments * arguments );
IOReturn releaseCommandBuffers( IOExternalMethodArguments * arguments );
IOReturn setCommandBlock( IOExternalMethodArguments * arguments );
// LSI workaround
IOReturn LSIWorkaroundSetCommandBuffersAsRanges( IOExternalMethodArguments * arguments );
IOReturn LSIWorkaroundSyncBuffersForOutput( IOExternalMethodArguments * arguments );
IOReturn LSIWorkaroundSyncBuffersForInput( IOExternalMethodArguments * arguments );
/////////////////////////////////////////////////
// IOFireWireSBP2MgmtORB
IOReturn createMgmtORB( IOExternalMethodArguments * arguments );
IOReturn releaseMgmtORB( IOExternalMethodArguments * arguments );
IOReturn setMgmtORBCallback( IOExternalMethodArguments * arguments );
IOReturn submitMgmtORB( IOExternalMethodArguments * arguments );
IOReturn setMgmtORBCommandFunction( IOExternalMethodArguments * arguments );
IOReturn setMgmtORBManageeORB( IOExternalMethodArguments * arguments );
IOReturn setMgmtORBManageeLogin( IOExternalMethodArguments * arguments );
IOReturn setMgmtORBResponseBuffer( IOExternalMethodArguments * arguments );
// callbacks
static void staticMgmtORBCallback( void * refCon, IOReturn status, IOFireWireSBP2ManagementORB * orb );
virtual void mgmtORBCallback( IOReturn status, IOFireWireSBP2ManagementORB * orb );
// IOFireWireSBP2MgmtORB friend class wrappers
virtual void setMgmtORBAsyncCallbackReference( IOFireWireSBP2ManagementORB * orb, void * asyncRef );
virtual void getMgmtORBAsyncCallbackReference( IOFireWireSBP2ManagementORB * orb, void * asyncRef );
uint32_t checkScalarInputCount;
uint32_t checkStructureInputSize;
uint32_t checkScalarOutputCount;
uint32_t checkStructureOutputSize;
IOReturn checkArguments( IOExternalMethodArguments * args, uint32_t scalarInCount, uint32_t structInCount,
uint32_t scalarOutCount, uint32_t structOutCount );
};
#endif
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/sbp2/IOFireWireSBP2UserClientCommon.h | /*
* Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* The contents of this file constitute Original Code as defined in and
* are subject to the Apple Public Source License Version 1.1 (the
* "License"). You may not use this file except in compliance with the
* License. Please obtain a copy of the License at
* http://www.apple.com/publicsource and read it before using this file.
*
* This Original Code and all software distributed under the License are
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _IOKIT_IOFIREWIRESBP2USERCLIENTCOMMON_H_
#define _IOKIT_IOFIREWIRESBP2USERCLIENTCOMMON_H_
#define kIOFireWireSBP2LibConnection 12
enum IOFWSBP2UserClientCommandCodes {
kIOFWSBP2UserClientOpen, // kIOUCScalarIScalarO 0,0
kIOFWSBP2UserClientClose, // kIOUCScalarIScalarO 0,0
kIOFWSBP2UserClientCreateLogin, // kIOUCScalarIScalarO 0,1
kIOFWSBP2UserClientReleaseLogin, // kIOUCScalarIScalarO 1,0
kIOFWSBP2UserClientSubmitLogin, // kIOUCScalarIScalarO 1,0
kIOFWSBP2UserClientSubmitLogout, // kIOUCScalarIScalarO 1,0
kIOFWSBP2UserClientSetLoginFlags, // kIOUCScalarIScalarO 2,0
kIOFWSBP2UserClientGetMaxCommandBlockSize, // kIOUCScalarIScalarO 1,1
kIOFWSBP2UserClientGetLoginID, // kIOUCScalarIScalarO 1,1
kIOFWSBP2UserClientSetReconnectTime, // kIOUCScalarIScalarO 1,0
kIOFWSBP2UserClientSetMaxPayloadSize, // kIOUCScalarIScalarO 1,0
kIOFWSBP2UserClientCreateORB, // kIOUCScalarIScalarO 0,1
kIOFWSBP2UserClientReleaseORB, // kIOUCScalarIScalarO 1,0
kIOFWSBP2UserClientSubmitORB, // kIOUCScalarIScalarO 1,0
kIOFWSBP2UserClientSetCommandFlags, // kIOUCScalarIScalarO 2,0
kIOFWSBP2UserClientSetMaxORBPayloadSize, // kIOUCScalarIScalarO 2,0
kIOFWSBP2UserClientSetCommandTimeout, // kIOUCScalarIScalarO 2,0
kIOFWSBP2UserClientSetCommandGeneration, // kIOUCScalarIScalarO 2,0
kIOFWSBP2UserClientSetToDummy, // kIOUCScalarIScalarO 1,0
kIOFWSBP2UserClientSetCommandBuffersAsRanges, // kIOUCScalarIScalarO 6,0
kIOFWSBP2UserClientReleaseCommandBuffers, // kIOUCScalarIScalarO 1,0
kIOFWSBP2UserClientSetCommandBlock, // kIOUCScalarIScalarO 3,0
kIOFWSBP2UserClientCreateMgmtORB, // kIOUCScalarIScalarO 0,1
kIOFWSBP2UserClientReleaseMgmtORB, // kIOUCScalarIScalarO 1,0
kIOFWSBP2UserClientSubmitMgmtORB, // kIOUCScalarIScalarO 1,0
kIOFWSBP2UserClientMgmtORBSetCommandFunction, // kIOUCScalarIScalarO 2,0
kIOFWSBP2UserClientMgmtORBSetManageeORB, // kIOUCScalarIScalarO 2,0
kIOFWSBP2UserClientMgmtORBSetManageeLogin, // kIOUCScalarIScalarO 2,0
kIOFWSBP2UserClientMgmtORBSetResponseBuffer, // kIOUCScalarIScalarO 3,0
kIOFWSBP2UserClientLSIWorkaroundSetCommandBuffersAsRanges, // kIOUCScalarIScalarO 6,0
kIOFWSBP2UserClientMgmtORBLSIWorkaroundSyncBuffersForOutput, // kIOUCScalarIScalarO 1,0
kIOFWSBP2UserClientMgmtORBLSIWorkaroundSyncBuffersForInput, // kIOUCScalarIScalarO 1,0
kIOFWSBP2UserClientOpenWithSessionRef, // kIOUCScalarIScalarO 1,0
kIOFWSBP2UserClientGetSessionRef, // kIOUCScalarIScalarO 0,1
kIOFWSBP2UserClientRingDoorbell, // kIOUCScalarIScalarO 1, 0
kIOFWSBP2UserClientEnableUnsolicitedStatus, // kIOUCScalarIScalarO 1, 0
kIOFWSBP2UserClientSetBusyTimeoutRegisterValue, // kIOUCScalarIScalarO 2, 0
kIOFWSBP2UserClientSetORBRefCon, // kIOUCScalarIScalarO 2, 0
kIOFWSBP2UserClientSetPassword, // kIOUCScalarIScalarO 3, 0
kIOFWSBP2UserClientSetMessageCallback, // kIOUCScalarIScalarO 2, 0
kIOFWSBP2UserClientSetLoginCallback, // kIOUCScalarIScalarO 2, 0
kIOFWSBP2UserClientSetLogoutCallback, // kIOUCScalarIScalarO 2, 0
kIOFWSBP2UserClientSetUnsolicitedStatusNotify, // kIOUCScalarIScalarO 2, 0
kIOFWSBP2UserClientSetStatusNotify, // kIOUCScalarIScalarO 2, 0
kIOFWSBP2UserClientSetMgmtORBCallback, // kIOUCScalarIScalarO 3, 0
kIOFWSBP2UserClientSubmitFetchAgentReset, // kIOUCScalarIScalarO 3, 0
kIOFWSBP2UserClientSetFetchAgentWriteCompletion, // kIOUCScalarIScalaO 2, 0
kIOFWSBP2UserClientNumCommands
};
#endif |
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/sbp2/IOFireWireSBP2Target.h | /*
* Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* The contents of this file constitute Original Code as defined in and
* are subject to the Apple Public Source License Version 1.1 (the
* "License"). You may not use this file except in compliance with the
* License. Please obtain a copy of the License at
* http://www.apple.com/publicsource and read it before using this file.
*
* This Original Code and all software distributed under the License are
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/*!
@header IOFireWireSBP2Target
Contains the class definition for IOFireWireSBP2Target.
*/
#ifndef _IOKIT_IOFIREWIRESBP2TARGET_H
#define _IOKIT_IOFIREWIRESBP2TARGET_H
#include <IOKit/firewire/IOFireWireUnit.h>
#include <IOKit/IOService.h>
enum
{
kIOFWSBP2FailsOnAckBusy = (1 << 0),
kIOFWSBP2FailsOnBusResetsDuringIO = (1 << 1),
kIOFWSBP2DontUsePTPacketLimit = (1 << 2)
};
/*!
@class IOFireWireSBP2Target
@abstract Serves as bridge between IOFireWireUnit and IOFireWireLUN.
@discussion Matches against IOFireWireUnits supporting the SBP2 protocol. Creates IOFireWireSBP2LUN nubs for matching. Most drivers will match against an IOFireWireSBP2LUN, but matching against an IOFireWireSBP2Target is also supported. This can be useful in cases where a single driver wishes to
control all LUNs on a device. Support for this technique is minimal, however, and the driver will be
required to discover it's LUNs through the registry.
*/
class IOFireWireSBP2Target : public IOService
{
OSDeclareDefaultStructors(IOFireWireSBP2Target);
protected:
/////////////////////////////////////////
// rom keys
enum
{
kCmdSpecIDKey = 0x38,
kCmdSetKey = 0x39,
kSoftwareRevKey = 0x3b,
kFirmwareRevKey = 0x3c,
kLUNKey = 0x14,
kLUNDirectoryKey = 0xd4,
kManagementAgentOffsetKey = 0x54,
kUnitCharacteristicsKey = 0x3A,
kRevisionKey = 0x21,
kFastStartKey = 0x3E
};
typedef struct
{
UInt32 cmdSpecID;
UInt32 cmdSet;
UInt32 vendorID;
UInt32 softwareRev;
UInt32 firmwareRev;
UInt32 lun;
UInt32 devType;
UInt32 unitCharacteristics;
UInt32 managementOffset;
UInt32 revision;
bool fastStartSupported;
UInt32 fastStart;
} LUNInfo;
// reserved for future use
struct ExpansionData
{
bool fStarted;
OSArray * fPendingMgtAgentCommands ;
UInt32 fNumberPendingMgtAgentOrbs;
UInt32 fNumLUNs;
};
ExpansionData * fExpansionData;
/////////////////////////////////////////
// private fields
bool fOpenFromTarget;
UInt32 fOpenFromLUNCount;
IOFireWireUnit * fProviderUnit;
UInt32 fFlags;
IOFireWireController * fControl;
UInt32 fIOCriticalSectionCount;
/////////////////////////////////////////
// private internals
virtual void free( void ) APPLE_KEXT_OVERRIDE;
virtual IOReturn message( UInt32 type,
IOService * provider,
void * argument = 0) APPLE_KEXT_OVERRIDE;
virtual void scanForLUNs( void );
IOReturn createLUN( LUNInfo * info );
public:
/////////////////////////////////////////
// public methods
/*! @function handleOpen
@abstract Overrideable method to control the open / close behaviour of an IOService.
@discussion See IOService for discussion.
@param forClient Designates the client of the provider requesting the open.
@param options Options for the open, may be interpreted by the implementor of handleOpen.
@result Return true if the open was successful, false otherwise. */
virtual bool handleOpen( IOService * forClient, IOOptionBits options, void * arg ) APPLE_KEXT_OVERRIDE;
/*!
@function handleClose
@abstract Overrideable method to control the open / close behaviour of an IOService.
@discussion See IOService for discussion.
@param forClient Designates the client of the provider requesting the close.
@param options Options for the close, may be interpreted by the implementor of handleOpen.
*/
virtual void handleClose( IOService * forClient, IOOptionBits options ) APPLE_KEXT_OVERRIDE;
/*!
@function handleIsOpen
@abstract Overrideable method to control the open / close behaviour of an IOService.
@discussion See IOService for discussion.
@param forClient If non-zero, isOpen returns the open state for that client. If zero is passed, isOpen returns the open state for all clients.
@result Returns true if the specific, or any, client has the IOService open.
*/
virtual bool handleIsOpen( const IOService * forClient ) const APPLE_KEXT_OVERRIDE;
/*!
@function start
@abstract During an IOService instantiation, the start method is called when the IOService has been selected to run on the provider.
@discussion See IOService for discussion.
@result Return true if the start was successful, false otherwise (which will cause the instance to be detached and usually freed).
*/
virtual bool start( IOService *provider ) APPLE_KEXT_OVERRIDE;
/*!
@function stop
@abstract During an IOService termination, the stop method is called in its clients before they are detached & it is destroyed.
@discussion See IOService for discussion.
*/
virtual void stop( IOService *provider ) APPLE_KEXT_OVERRIDE;
/*!
@function getFireWireUnit
@abstract Returns an IOFireWireUnit object.
@discussion An IOFireWireUnit is the provider of an IOFireWireSBP2Target. In order to use the base FireWire services
you will need a reference to the unit. This method returns that reference.
@result Returns a pointer to an IOFireWireUnit.
*/
virtual IOFireWireUnit * getFireWireUnit( void );
/*!
@function matchPropertyTable
@abstract Implements SBP2 specific matching.
@discussion See IOService for discussion.
@param table The dictionary of properties to be matched against.
@result Returns false if the family considers the matching dictionary does not match in properties it understands, true otherwise.
*/
virtual bool matchPropertyTable( OSDictionary * table ) APPLE_KEXT_OVERRIDE;
virtual void setTargetFlags( UInt32 flags );
virtual UInt32 getTargetFlags( void );
protected:
virtual void configurePhysicalFilter( void );
public:
virtual void clearTargetFlags( UInt32 flags );
virtual IOReturn beginIOCriticalSection( void );
virtual void endIOCriticalSection( void );
virtual bool finalize( IOOptionBits options ) APPLE_KEXT_OVERRIDE;
IOReturn synchMgmtAgentAccess( IOFWCommand * mgmtOrbCommand );
void completeMgmtAgentAccess( );
void clearMgmtAgentAccess( );
void cancelMgmtAgentAccess( IOFWCommand * mgmtOrbCommand );
protected:
OSMetaClassDeclareReservedUnused(IOFireWireSBP2Target, 0);
OSMetaClassDeclareReservedUnused(IOFireWireSBP2Target, 1);
OSMetaClassDeclareReservedUnused(IOFireWireSBP2Target, 2);
OSMetaClassDeclareReservedUnused(IOFireWireSBP2Target, 3);
OSMetaClassDeclareReservedUnused(IOFireWireSBP2Target, 4);
OSMetaClassDeclareReservedUnused(IOFireWireSBP2Target, 5);
OSMetaClassDeclareReservedUnused(IOFireWireSBP2Target, 6);
OSMetaClassDeclareReservedUnused(IOFireWireSBP2Target, 7);
OSMetaClassDeclareReservedUnused(IOFireWireSBP2Target, 8);
};
#endif
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/sbp2/IOFireWireSBP2ORB.h | /*
* Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* The contents of this file constitute Original Code as defined in and
* are subject to the Apple Public Source License Version 1.1 (the
* "License"). You may not use this file except in compliance with the
* License. Please obtain a copy of the License at
* http://www.apple.com/publicsource and read it before using this file.
*
* This Original Code and all software distributed under the License are
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/*!
@header IOFireWireSBP2ORB
Contains the class definition for IOFireWireSBP2ORB.
*/
#ifndef _IOKIT_IOFIREWIRESBP2ORB_H
#define _IOKIT_IOFIREWIRESBP2ORB_H
#include <IOKit/firewire/IOFireWireUnit.h>
#include <IOKit/IOBufferMemoryDescriptor.h>
#include <IOKit/IOUserClient.h>
#include <IOKit/IODMACommand.h>
enum
{
kFWSBP2ConstraintForceDoubleBuffer = (1 << 0)
};
// login option flags
enum
{
kFWSBP2CommandCompleteNotify = (1 << 0),
kFWSBP2CommandTransferDataFromTarget = (1 << 1),
kFWSBP2CommandImmediate = (1 << 2),
kFWSBP2CommandNormalORB = (1 << 5),
kFWSBP2CommandReservedORB = (1 << 6),
kFWSBP2CommandVendorORB = (1 << 7),
kFWSBP2CommandDummyORB = (1 << 8),
kFWSBP2CommandCheckGeneration = (1 << 9),
kFWSBP2CommandFixedSize = (1 << 10),
kFWSBP2CommandVirtualORBs = (1 << 11) // handy for debugging
};
enum
{
kFWSBP2MaxPageClusterSize = 0xf000
};
class IOFireWireSBP2ORB;
class IOFireWireSBP2LUN;
class IOFireWireSBP2Login;
/*!
@class IOFireWireSBP2ORB
@abstract Represents an SBP2 normal command ORB. Supplies the APIs for configuring normal
command ORBs. This includes setting the command block and writing the page tables for I/O.
The ORBs are executed using the submitORB method in IOFireWireSBP2Login.
*/
class IOFireWireSBP2ORB : public IOCommand
{
OSDeclareDefaultStructors( IOFireWireSBP2ORB )
friend class IOFireWireSBP2Login;
friend class IOFireWireSBP2ManagementORB;
protected:
typedef struct
{
UInt32 nextORBAddressHi;
UInt32 nextORBAddressLo;
UInt32 dataDescriptorHi;
UInt32 dataDescriptorLo;
UInt16 options;
UInt16 dataSize;
UInt32 commandBlock[1]; // will be variable sized
} FWSBP2ORB;
typedef struct
{
UInt16 segmentLength;
UInt16 segmentBaseAddressHi;
UInt32 segmentBaseAddressLo;
} FWSBP2PTE;
private:
OSMetaClassDeclareReservedUnused(IOFireWireSBP2ORB, 0);
OSMetaClassDeclareReservedUnused(IOFireWireSBP2ORB, 1);
OSMetaClassDeclareReservedUnused(IOFireWireSBP2ORB, 2);
OSMetaClassDeclareReservedUnused(IOFireWireSBP2ORB, 3);
OSMetaClassDeclareReservedUnused(IOFireWireSBP2ORB, 4);
OSMetaClassDeclareReservedUnused(IOFireWireSBP2ORB, 5);
OSMetaClassDeclareReservedUnused(IOFireWireSBP2ORB, 6);
OSMetaClassDeclareReservedUnused(IOFireWireSBP2ORB, 7);
OSMetaClassDeclareReservedUnused(IOFireWireSBP2ORB, 8);
protected:
virtual void deallocateBufferAddressSpace( void );
virtual IOReturn allocateTimer( void );
virtual void deallocateTimer( void );
/*!
@function deallocatePageTable
@abstract Frees up memory allocated for the page table.
@discussion Frees all memory associated with the page table. Undoes what allocatePageTable does.
Calling allocatePageTable again will automatically deallocate the existing page table before
allocating a new one, so this method is not used in most cases.
*/
virtual void deallocatePageTable( void );
protected:
// IOFireWireSBP2Login methods
virtual bool initWithLogin( IOFireWireSBP2Login * login );
virtual void setNextORBAddress( FWAddress address );
public:
/*!
@function allocatePageTable
@abstract Allocates memory for the page table.
@discussion Page table allocation is handle automatically by the ORB, except if the
kFWSBP2CommandFixedSize flags is set. In this case we will fail to write a page table if we
need more page table space than we have already. This method is exposed so these drivers
can preallocate as much page table as they need. This is useful if your driver is part of
the paging path and cannot allow allocations to occur.
@param entryCount number of entries of page table to be allocated.
*/
virtual IOReturn allocatePageTable( UInt32 entryCount );
protected:
virtual bool isTimerSet( void );
virtual void cancelTimer( void );
protected:
// reserved for future use
struct ExpansionData { };
ExpansionData *reserved;
IOFireWireSBP2Login * fLogin;
IOFireWireSBP2LUN * fLUN;
IOFireWireUnit * fUnit;
IOFireWireController * fControl;
IODMACommand * fDMACommand;
void * fUnused2;
UInt32 fCommandFlags;
UInt32 fMaxPayloadSize;
UInt32 fTimeoutDuration;
UInt32 fGeneration;
UInt64 fRefCon;
//
// orb
//
IOMemoryDescriptor * fORBDescriptor;
FWSBP2ORB * fORBBuffer;
FWAddress fORBPseudoAddress;
IOFWAddressSpace * fORBPseudoAddressSpace;
IOFWAddressSpace * fORBPhysicalAddressSpace;
FWAddress fORBPhysicalAddress;
//
// page table
//
UInt32 fPageTableSize;
IOBufferMemoryDescriptor * fPageTableDescriptor;
IOFWAddressSpace * fPageTablePhysicalAddressSpace;
FWAddress fPageTablePhysicalAddress;
UInt32 fPageTablePhysicalLength;
IOFWAddressSpace * fPageTablePseudoAddressSpace;
FWAddress fPageTablePseudoAddress;
//
// buffers
//
IOFWAddressSpace * fBufferAddressSpace;
bool fBufferAddressSpaceAllocated;
IOMemoryDescriptor * fBufferDescriptor;
//
// timer
//
IOFWDelayCommand * fTimeoutCommand;
bool fTimeoutTimerSet;
bool fInProgress;
bool fIsAppended;
UInt32 fFetchAgentWriteRetries;
UInt32 fPTECount;
UInt32 fFetchAgentWriteRetryInterval;
UInt32 fConstraintOptions;
virtual IOReturn allocateResources( void );
virtual void free( void ) APPLE_KEXT_OVERRIDE;
// orb timeout handler
static void orbTimeoutStatic( void *refcon, IOReturn status, IOFireWireBus *bus, IOFWBusCommand *fwCmd );
virtual void orbTimeout( IOReturn status, IOFireWireBus *bus, IOFWBusCommand *fwCmd );
// login friend class wrappers
virtual IOFireWireUnit * getFireWireUnit( void );
virtual IOFireWireSBP2LUN * getFireWireLUN( void );
virtual void deallocateORB( void );
virtual IOReturn allocateORB( UInt32 orbSize );
virtual IOReturn removeORB( IOFireWireSBP2ORB * orb );
virtual void prepareORBForExecution( void );
virtual void startTimer( void );
virtual void sendTimeoutNotification( IOFireWireSBP2ORB * orb );
public:
/*!
@function release
@abstract Primary implementation of the release mechanism.
@discussion See OSObject.h for more information.
@param when When retainCount == when then call free().
*/
virtual void release() const APPLE_KEXT_OVERRIDE;
/*!
@function getLogin
@abstract Gets the login associated with this ORB.
@discussion Returns the IOFireWireSBP2Login object associated with this ORB.
@result Returns a pointer to an IOFireWireSBP2Login.
*/
virtual IOFireWireSBP2Login * getLogin( void );
/*!
@function setCommandBuffersAsRanges
@abstract Creates a page table from a list of ranges.
@discussion Creates a page table with the given parameters. Any addresses mapped by this method
must remain valid until setCommandBuffers is called again or releaseCommandBuffers is called.
The SBP2 services do not release references to the command buffers just because the command
has completed.
@param ranges An array of ranges representing the data to be transfered.
@param withCount The number of ranges in the ranges array.
@param withDirection An IODirection indicating the direction of data transfer.
@param withTask The task that these adressses reside in.
@param offset Offset in bytes into data to begin writing table at.
@param length Number of bytes of data to map from offset.
@result Returns KIOReturnSuccess if the page table was written successfully.
*/
virtual IOReturn setCommandBuffersAsRanges( IOVirtualRange * ranges,
UInt32 withCount,
IODirection withDirection,
task_t withTask,
UInt32 offset = 0,
UInt32 length = 0 );
/*!
@function setCommandBuffersAsRanges
@abstract Creates a page table from a list of ranges.
@discussion Creates a page table with the given parameters. Any addresses mapped by this method
must remain valid until setCommandBuffers is called again or releaseCommandBuffers is called.
The SBP2 services do not release references to the command buffers just because the command
has completed.
@param memoryDescriptor IOMemoryDescriptor describe ranges to be written to a page table.
@param offset Offset in bytes into data to begin writing table at.
@param length Number of bytes of data to map from offset.
@result Returns KIOReturnSuccess if the page table was written successfully.
*/
virtual IOReturn setCommandBuffers( IOMemoryDescriptor * memoryDescriptor, UInt32 offset = 0,
UInt32 length = 0 );
/*!
@function releaseCommandBuffers
@abstract Releases SBP2's reference to the command buffers.
@discussion When you create a page table with one of the variants of setCommandBuffers.
SBP2 holds on to a reference to the buffers until this method is called. This means that
if a command completed and you manipulated the memory descriptor or released the buffers
without calling this method you could leave FW in an inconsistent state.
@result Returns KIOReturnSuccess if the page table was cleared successfully.
*/
virtual IOReturn releaseCommandBuffers( void );
/*!
@function setCommandBlock
@abstract Sets the command block portion of the ORB.
@discussion Copys the data provided in the buffer to the command block portion of the ORB.
@param buffer Pointer to buffer to copy command block from.
@param length Number of bytes of data to copy.
@result Returns KIOReturnSuccess if the command block was updated successfully.
*/
virtual IOReturn setCommandBlock( void * buffer, UInt32 length );
/*!
@function setCommandBlock
@abstract Sets the command block portion of the ORB.
@discussion Copys the data provided in the buffer to the command block portion of the ORB.
@param memory IOMemoryDescriptor representing the command block buffer.
@result Returns KIOReturnSuccess if the command block was updated successfully.
*/
virtual IOReturn setCommandBlock( IOMemoryDescriptor * memory );
/*!
@function getCommandBufferDescriptor
@abstract Returns the memory descriptor representing the command buffer.
@discussion Returns the IOMemoryDescriptor for the data mapped by setCommandBuffer variants.
Works for setCommandBuffersAsRanges too.
@result Returns memory descriptor representing mapped data buffers.
*/
virtual IOMemoryDescriptor * getCommandBufferDescriptor( void );
// accessors
/*!
@function setCommandFlags
@abstract Sets configuration flags for the ORB.
@discussion Sets the configuration flags for the ORB. These can be any of the following:
<p>kFWSBP2CommandCompleteNotify - Set the notify bit as specified in SBP2 standard. Set to receive completion/timeout notification on this ORB. You almost always want to set this.</p>
<p>kFWSBP2CommandTransferDataFromTarget - Transfer direction as specified in SBP2 standard. Set if data is to be written by the device into the host's memory.</p>
<p>kFWSBP2CommandImmediate - Immediate Append. ORB address will be written to fetch agent and not chained. It is only legal to have one immediate ORB in progress at a time.</p>
<p>kFWSBP2CommandNormalORB - ORB format 0 - Format specified by SBP2 standard. Set this for most ORBs.</p>
<p>kFWSBP2CommandReservedORB - ORB format 1 - Format reserved by SBP2 standard for future standardization.</p>
<p>kFWSBP2CommandVendorORB - ORB format 2 - Format specified by SBP2 standard for vendor dependent ORBs.</p>
<p>kFWSBP2CommandDummyORB - ORB format 3 - Format specified by SBP2 standard for dummy ORBs.</p>
<p>kFWSBP2CommandCheckGeneration - If set upon submitORB, the ORB will only be appended if generation set with setCommandGeneration() matches the current generation. Pretty much all SBP2 drivers need sophisticated logic to track login state, so this is generally not used. </p>
<p>kFWSBP2CommandFixedSize - Do not allocate more memory for page table if needed. If there is not enough space in the currently allocated page table, the setCommandBuffers call will fail. This is important to set if your device is the backing store, as we don't want to cause memory allocations on the paging path. </p>
<p>kFWSBP2CommandVirtualORBs - Normally ORBs are backed by physical address spaces. Setting this flag makes this ORB backed by a pseudo address space. This can make ORBs easier to see in a bus trace. Virtual ORBs will have an address in the form of ffcX.XXXX.0000.0000. Pseudo address space backed ORBs are slower, so you won't want to set for deployment builds.</p>
@param flags The flags to be set.
*/
virtual void setCommandFlags( UInt32 flags );
/*!
@function getCommandFlags
@abstract Sets configuration flags for the ORB.
@discussion Returns the current configuration flags set on this ORB.
@result Return The current ORB flags.
*/
virtual UInt32 getCommandFlags( void );
/*!
@function setMaxPayloadSize
@abstract Sets max payload size for the ORB.
@discussion This sets the maximum payload size for this ORB only. This size is clipped by
the global max payload size set in the login object.
@param maxPayloadSize The maximum payload size in bytes.
*/
virtual void setMaxPayloadSize( UInt32 maxPayloadSize );
/*!
@function getMaxPayloadSize
@abstract Gets max payload size for the ORB.
@discussion This gets the maximum payload size for this ORB only.
@result Returns the maximum payload size in bytes.
*/
virtual UInt32 getMaxPayloadSize( void );
/*!
@function setCommandTimeout
@abstract Sets the timeout of the ORB.
@discussion This sets the timeout for the ORB in milliseconds. Note that ORBs without timeouts
can be "lost." You will obviously not recieve timeout notification for timeouts of zero. But
perhaps less obviously you will not recieve orb reset notification, which is really a sort of
accelerated timeout notification for bus reset situations.
@param timeout The timeout duration in milliseconds.
*/
virtual void setCommandTimeout( UInt32 timeout );
/*!
@function getCommandTimeout
@abstract Gets the timeout of the ORB.
@discussion This method gets the timeout for this ORB in milliseconds.
@result Returns the timeout for the orb in milliseconds.
*/
virtual UInt32 getCommandTimeout( void );
/*!
@function setCommandGeneration
@abstract Sets the command generation.
@discussion This sets the bus generation this ORB should be appended in. It is only meaningful
when combined with the kFWSBP2CommandCheckGeneration flags above.
@param gen The bus generation for command execution.
*/
virtual void setCommandGeneration( UInt32 gen );
/*!
@function getCommandGeneration
@abstract Gets the command generation.
@discussion This gets the bus generation this ORB should be appended in.
@result Returns the bus generation for command execution.
*/
virtual UInt32 getCommandGeneration( void );
/*!
@function setRefCon
@abstract Sets the ORB refCon.
@discussion Sets a user defined value on the ORB that can be retrieved later with the
method getRefCon.
@param refCon a user defined value.
*/
virtual void setRefCon( void * refCon );
/*!
@function getRefCon
@abstract Returns the refCon set with setRefCon.
@discussion Returns the user defined value previously stored in the ORB with setRefCon.
@result Returns the previously stored user defined value.
*/
virtual void * getRefCon( void );
protected:
virtual void setToDummy( void );
public:
/*!
@function getORBAddress
@abstract Returns the FireWire address of this ORB.
@discussion Returns the FireWire bus address of this ORB. This is not the same as the Macintosh
address for the IOFireWireSBP2ORB.
@result Returns the FireWire address of this ORB.
*/
virtual void getORBAddress( FWAddress * address );
protected:
virtual bool isAppended( void );
virtual void setIsAppended( bool state );
virtual UInt32 getFetchAgentWriteRetries( void );
virtual void setFetchAgentWriteRetries( UInt32 retries );
virtual void prepareFastStartPacket( IOBufferMemoryDescriptor * descriptor );
UInt32 getFetchAgentWriteRetryInterval( void );
void setFetchAgentWriteRetryInterval( UInt32 interval );
IOReturn completeBufferAddressSpace( void );
IOReturn prepareBufferAddressSpace( IOMemoryDescriptor * memoryDescriptor );
public:
/*!
@function setBufferConstraints
@abstract Configures page table generation parameters
@discussion Sets the maximums size of any page table segment and the required alignemnt. Double buffering
may be used to satisfy these constraints. The only supported option is kFWSBP2ConstraintForceDoubleBuffer which
forces a page aligned double buffering of the entire descriptor.
@result May return an error if there is a problem allocating the underlying resources or if buffers are currently attached.
*/
IOReturn setBufferConstraints( UInt64 maxSegmentSize, UInt32 alignment, UInt32 options = 0);
/*!
@function setCommandBuffersAsRanges64
@abstract Creates a page table from a list of 64 bit ranges.
@discussion Creates a page table with the given parameters. Any addresses mapped by this method
must remain valid until setCommandBuffers is called again or releaseCommandBuffers is called.
The SBP2 services do not release references to the command buffers just because the command
has completed. This is a 64 bit compatible version of setCommandBuffersAsRanges.
@param ranges An array of ranges representing the data to be transfered.
@param withCount The number of ranges in the ranges array.
@param withDirection An IODirection indicating the direction of data transfer.
@param withTask The task that these adressses reside in.
@param offset Offset in bytes into data to begin writing table at.
@param length Number of bytes of data to map from offset.
@result Returns KIOReturnSuccess if the page table was written successfully.
*/
IOReturn setCommandBuffersAsRanges64( IOAddressRange * ranges,
uint64_t withCount,
IODirection withDirection,
task_t withTask,
uint64_t offset = 0,
uint64_t length = 0);
/*!
@function setRefCon64
@abstract Sets the ORB refCon as a 64 bit value.
@discussion Sets a user defined value on the ORB that can be retrieved later with the
method getRefCon.
@param refCon a user defined value.
*/
virtual void setRefCon64( UInt64 refCon );
/*!
@function getRefCon64
@abstract Returns the 64 bit refCon set with setRefCon64.
@discussion Returns the user defined value previously stored in the ORB with setRefCon.
@result Returns the previously stored user defined value.
*/
virtual UInt64 getRefCon64( void );
protected:
UInt32 calculateTransferSizeLog( bool * clipping );
};
#endif
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/rtc/IORTCController.h | /*
* Copyright (c) 1998-2019 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* 24 Nov 1998 suurballe Created.
*/
#ifndef _IORTCCONTROLLER_H
#define _IORTCCONTROLLER_H
#include <IOKit/IOService.h>
typedef void (*RTC_tick_handler)( IOService * );
class IORTCController : public IOService
{
OSDeclareAbstractStructors(IORTCController);
public:
virtual IOReturn getRealTimeClock( UInt8 * currentTime, IOByteCount * length ) = 0;
virtual IOReturn setRealTimeClock( UInt8 * newTime ) = 0;
};
class IORTC : public IOService
{
OSDeclareAbstractStructors(IORTC);
protected:
/*! @var reserved
* Reserved for future use. (Internal use only) */
struct ExpansionData { };
ExpansionData *iortc_reserved __unused;
public:
virtual long getGMTTimeOfDay( void ) = 0;
virtual void setGMTTimeOfDay( long secs ) = 0;
virtual void getUTCTimeOfDay( clock_sec_t * secs, clock_nsec_t * nsecs );
virtual void setUTCTimeOfDay( clock_sec_t secs, clock_nsec_t nsecs );
virtual void setAlarmEnable( IOOptionBits message ) = 0;
virtual IOReturn getMonotonicClockOffset( int64_t * usecs );
virtual IOReturn setMonotonicClockOffset( int64_t usecs );
virtual IOReturn getMonotonicClockAndTimestamp( uint64_t * usecs, uint64_t *mach_absolute_time );
OSMetaClassDeclareReservedUnused(IORTC, 0);
OSMetaClassDeclareReservedUnused(IORTC, 1);
OSMetaClassDeclareReservedUnused(IORTC, 2);
OSMetaClassDeclareReservedUnused(IORTC, 3);
OSMetaClassDeclareReservedUnused(IORTC, 4);
OSMetaClassDeclareReservedUnused(IORTC, 5);
OSMetaClassDeclareReservedUnused(IORTC, 6);
OSMetaClassDeclareReservedUnused(IORTC, 7);
};
#endif /* !_IORTCCONTROLLER_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/stream/IOStream.h | /*
* Copyright 2006 Apple Computer, Inc. All rights reserved.
*
*/
#if !defined(__IOKIT_IOSTREAM_H)
#define __IOKIT_IOSTREAM_H
#include <IOKit/IOService.h>
#include <IOKit/IOMemoryDescriptor.h>
#include <IOKit/IOBufferMemoryDescriptor.h>
#include <IOKit/IOUserClient.h>
#include <sys/cdefs.h>
#include <IOKit/stream/IOStreamShared.h>
/*!
@header IOStream.h
Definitions for IOStream family.
*/
class __exported IOStreamBuffer;
/*!
@class IOStream
@abstract
A class representing a stream of data buffers passed from kernel to
user space and back again.
@discussion
The IOStream class defines a mechanism for moving buffers of data from
kernel space to user space or vice-versa. The policy for which direction
the data flows and the nature of the data is left up the the implementer
of the driver which uses IOStream.
Although it is expected that the client of an IOStream will be in user space,
this is not required.
References to "output" mean "from the IOStream to the user client", and
"input" means "from the user client to the IOStream."
*/
class __exported IOStream : public IOService
{
OSDeclareDefaultStructors(IOStream);
protected:
OSArray * _buffers; // IOStreamBuffer objects in this stream
IOItemCount _queueCount; // Number of entries for the queues
IOMemoryDescriptor * _inputQueueDescriptor;
IOMemoryMap * _inputQueueMap;
IOMemoryDescriptor * _outputQueueDescriptor;
IOMemoryMap * _outputQueueMap;
IOStreamBufferQueue * _outputQueue; // Shared memory for buffers out to user space
IOStreamBufferQueue * _inputQueue; // Shared memory for buffers in from user space
mach_port_t _outputPort;
mach_port_t _inputPort;
OSArray * _memoryMaps; // Maps for data queues
IOStreamMode _streamMode;
public:
/*!
@functiongroup Creating IOStream objects
*/
/*!
@function withBuffers
@param mode The initial mode of the stream, either output, input, or input/output.
@param queueLength The nuber of queue entries to reserve in the input and output queue.
Zero means to make the queues big enough to accommodate all the buffers at once.
@param properties
A dictionary of properties which will be set on the stream.
@param buffers
An array of IOStreamBuffer objects which will be the buffers for this stream.
*/
static IOStream *withBuffers(OSArray *buffers, IOStreamMode mode = kIOStreamModeOutput, IOItemCount queueLength = 0, OSDictionary *properties = 0);
virtual bool init(OSDictionary *properties = 0);
/*!
@function initWithBuffers
@param mode The initial mode of the stream, either output, input, or input/output.
@param queueLength The nuber of queue entries to reserve in the input and output queue.
Zero means to make the queues big enough to accommodate all the buffers at once.
@param properties
A dictionary of properties which will be set on the stream.
@param buffers
An array of IOStreamBuffer objects which will be the buffers for this stream.
*/
virtual bool initWithBuffers(OSArray *buffers, IOStreamMode mode = kIOStreamModeOutput, IOItemCount queueLength = 0, OSDictionary *properties = 0);
/*!
@function free
*/
virtual void free(void);
/*!
@functiongroup Opening and closing streams
*/
/*!
@function handleOpen
@abstract The handleOpen() method relies on the default IOService behavior
to ensure that
only one client has the stream open at a time.
The shared input and output queues are created at open time.
@param options
@param arg
*/
virtual bool handleOpen( IOService * forClient,
IOOptionBits options,
void * arg );
/*!
@function handleClose
@abstract The handleClose method destroys the shared input and output
queues.
@param options
*/
virtual void handleClose( IOService * forClient,
IOOptionBits options );
/*!
@functiongroup Managing shared queues
*/
/*!
@function createQueues
@abstract Creates the shared input and output queues, without regard
to whether the stream is open or not.
Normally this is called by handleOpen().
@param queueLength
@param options
@result Returns kIOReturnSuccess if the queues were successfully created.
*/
virtual IOReturn createQueues( IOItemCount queueLength = 0, IOOptionBits options = 0 );
/*!
@function destroyQueues
@abstract Releases the shared input and output queues.
@result Returns kIOReturnSuccess if the queues were successfully destroyed.
The queues cannot be destroyed while the stream is open by a client.
*/
virtual IOReturn destroyQueues( void );
/*!
@function getOutputQueue
@result A pointer to the output IOStreamBufferQueue structure for the stream,
or NULL if the stream is not open and the queue has not been created yet.
*/
virtual IOStreamBufferQueue *getOutputQueue(void); // get shared-memory output queue
/*!
@function getOutputQueueMemoryDescriptor
@result An IOMemoryDescriptor object repesenting the shared memory
output queue buffer.
*/
virtual IOMemoryDescriptor *getOutputQueueMemoryDescriptor(void);
/*!
@function getInputQueue
@result A pointer to the input IOStreamBufferQueue structure for the stream,
or NULL if the stream is not open and the queue has not been created yet.
*/
virtual IOStreamBufferQueue *getInputQueue(void); // get shared-memory input queue
/*!
@function getInputQueueMemoryDescriptor
@result An IOMemoryDescriptor object repesenting the shared memory
input queue buffer.
*/
virtual IOMemoryDescriptor *getInputQueueMemoryDescriptor(void);
/*!
@functiongroup Managing buffers in an IOStream
*/
/*!
@function addBuffer
@abstract Add a buffer to an IOStream.
@param buffer
@discussion
Adds an IOStreamBuffer to an IOStream. It will be added to the end
of the buffer array, so the buffer ID of existing buffers will not change.
*/
virtual IOReturn addBuffer(IOStreamBuffer *buffer); // add a new buffer to the stream
/*!
@function addBuffers
@param buffers
@result
*/
virtual IOReturn addBuffers(OSArray *buffers);
/*!
@function removeBuffer
@param buffer A pointer to an IOStreamBuffer object in the stream.
@result Returns kIOReturnSuccess if the buffer was removed, or kIOReturnNotFound
if the buffer was not in this stream.
@abstract
Removes a buffer from the stream. Buffers cannot be removed
while the stream is open, as this will change the buffer IDs of existing
buffers.
*/
virtual IOReturn removeBuffer(IOStreamBuffer *buffer);
/*!
@function removeBuffer
@param bufferID The ID of the buffer to remove.
@result Returns kIOReturnSuccess if the buffer was removed.
@abstract
Removes a buffer from the stream. Buffers cannot be removed
while the stream is open, as this will change the buffer IDs of existing
buffers.
*/
virtual IOReturn removeBuffer(IOStreamBufferID bufferID);
/*!
@function removeAllBuffers
@result
*/
virtual IOReturn removeAllBuffers( void );
/*!
@function removeAllBuffers
@result Returns kIOReturnSuccess if all the buffers were successfully
removed. Buffers cannot be removed
while the stream is open, as this will change the buffer IDs of existing
buffers.
*/
virtual IOItemCount getBufferCount( void );
/*!
@function getBuffers
@abstract Get an array containing all the buffers in the stream.
@discussion
Returns an OSArray containing all the buffers in the stream in order of their buffer ID.
*/
virtual OSArray *getBuffers( void );
/*!
@function getBufferWithID
@param bufferID
The ID of the buffer to get.
@result
A pointer to an IOStreamBuffer object, or NULL if the
buffer ID was invalid for this stream.
*/
virtual IOStreamBuffer *getBufferWithID(IOStreamBufferID bufferID);
/*!
@functiongroup Managing notification ports
*/
/*!
@function getInputPort
@abstract Get the Mach port used to receive notifications
from user space that a buffer has been added to the input queue.
*/
virtual mach_port_t getInputPort(void);
/*!
@function setInputPort
@abstract Set the Mach port used to receive notifications from
user space that a buffer has been added to the input queue.
@param port
*/
virtual IOReturn setInputPort(mach_port_t port);
/*!
@function getOutputPort
@abstract Get the Mach port used to send notifications to user space
that a buffer has been added to the output queue.
*/
virtual mach_port_t getOutputPort(void);
/*!
@function setOutputPort
@abstract Set the Mach port used to send notifications to user space
that a buffer has been added to the output queue.
@param port
*/
virtual IOReturn setOutputPort(mach_port_t port);
/*!
@function sendOutputNotification
@abstract Send a notification to the user client that data is available
for reading on the output queue. This will result in the user's output
handler being called, if they registered one.
@result Returns kIOReturnSuccess if the notification was successfully sent.
*/
virtual IOReturn sendOutputNotification(void);
/*!
@functiongroup Queueing and dequeueing buffers
*/
/*!
@function enqueueOutputBuffer
@abstract A convenience method for enqueueing a buffer.
@param buffer
@param dataOffset
@param dataLength
@param controlOffset
@param controlLength
@result
*/
virtual IOReturn enqueueOutputBuffer(IOStreamBuffer *buffer,
IOByteCount dataOffset = 0,
IOByteCount dataLength = 0,
IOByteCount controlOffset = 0,
IOByteCount controlLength = 0);
/*!
@function enqueueOutputEntry
@param entry
@result
*/
virtual IOReturn enqueueOutputEntry( IOStreamBufferQueueEntry *entry );
/*!
@function dequeueInputEntry
@param entry
@result
*/
virtual IOReturn dequeueInputEntry( IOStreamBufferQueueEntry *entry );
/*!
@functiongroup Managing notifications
*/
/*!
@function inputCallback
@abstract Input callback function to be implemented by a subclass;
@param token
A 32-bit token value that can be used by convention to communicate
from user space to the stream. The semantics of this value are
defined by the IOStream subclass.
@discussion
The inputCallback() method is called as a result of a fast trap
from user space. It is called on the same thread as the user request,
but the subclass should implement this call as a notification sent
to a workloop so that the request is asynchronous.
*/
virtual void inputCallback( UInt32 token );
/*!
@function inputSyncCallback
@abstract Input callback function to be implemented by a subclass.
@param token
A 32-bit token value that can be used by convention to communicate
from user space to the stream. The semantics of this value are
defined by the IOStream subclass.
@discussion
The inputSyncCallback() method is called as a result of a fast trap
from user space. It is called on the same thread as the user request,
so no context switch is necessary.
*/
virtual void inputSyncCallback( UInt32 token );
/*!
@functiongroup Stream control
*/
/*!
@function getStreamMode
@abstract Returns the mode of the stream, either input or output.
@result The mode of the stream, either kIOStreamModeInput
(from user space to kernel space) or the default
kIOStreamModeOutput (from kernel space to user space).
*/
virtual IOStreamMode getStreamMode(void);
/*!
@function setStreamMode
@abstract Sets the mode of the stream, either input or output.
@discussion Subclasses may define whether it is possible
to change the mode of a stream.
*/
virtual IOReturn setStreamMode(IOStreamMode mode);
/*!
@function startStream
@abstract Start sending data on a stream.
@result Returns kIOReturnSuccess if the stream was successfully started.
@discussion This must be implemented by a subclass.
*/
virtual IOReturn startStream(void);
/*!
@function stopStream
@abstract Stop sending data on a stream.
@result Returns kIOReturnSuccess if the stream was successfully stopped.
@discussion This must be implemented by a subclass.
*/
virtual IOReturn stopStream(void);
/*!
@function suspendStream
@abstract Temporarily suspend data flow on the stream.
@result Returns kIOReturnSuccess if the stream was successfully suspended.
@discussion This must be implemented by a subclass.
*/
virtual IOReturn suspendStream(void);
/*!
@functiongroup Managing user clients
*/
/*!
@function newUserClient
@abstract See the documentation for the IOService method newUserClient.
*/
virtual IOReturn newUserClient( task_t owningTask, void * securityID,
UInt32 type, OSDictionary * properties,
IOUserClient ** handler );
/* Reserved slots */
OSMetaClassDeclareReservedUnused(IOStream, 0);
OSMetaClassDeclareReservedUnused(IOStream, 1);
OSMetaClassDeclareReservedUnused(IOStream, 2);
OSMetaClassDeclareReservedUnused(IOStream, 3);
OSMetaClassDeclareReservedUnused(IOStream, 4);
OSMetaClassDeclareReservedUnused(IOStream, 5);
OSMetaClassDeclareReservedUnused(IOStream, 6);
OSMetaClassDeclareReservedUnused(IOStream, 7);
OSMetaClassDeclareReservedUnused(IOStream, 8);
OSMetaClassDeclareReservedUnused(IOStream, 9);
OSMetaClassDeclareReservedUnused(IOStream, 10);
OSMetaClassDeclareReservedUnused(IOStream, 11);
OSMetaClassDeclareReservedUnused(IOStream, 12);
OSMetaClassDeclareReservedUnused(IOStream, 13);
OSMetaClassDeclareReservedUnused(IOStream, 14);
OSMetaClassDeclareReservedUnused(IOStream, 15);
OSMetaClassDeclareReservedUnused(IOStream, 16);
OSMetaClassDeclareReservedUnused(IOStream, 17);
OSMetaClassDeclareReservedUnused(IOStream, 18);
OSMetaClassDeclareReservedUnused(IOStream, 19);
OSMetaClassDeclareReservedUnused(IOStream, 20);
OSMetaClassDeclareReservedUnused(IOStream, 21);
OSMetaClassDeclareReservedUnused(IOStream, 22);
OSMetaClassDeclareReservedUnused(IOStream, 23);
OSMetaClassDeclareReservedUnused(IOStream, 24);
OSMetaClassDeclareReservedUnused(IOStream, 25);
OSMetaClassDeclareReservedUnused(IOStream, 26);
OSMetaClassDeclareReservedUnused(IOStream, 27);
OSMetaClassDeclareReservedUnused(IOStream, 28);
OSMetaClassDeclareReservedUnused(IOStream, 29);
OSMetaClassDeclareReservedUnused(IOStream, 30);
OSMetaClassDeclareReservedUnused(IOStream, 31);
};
/*!
@class IOStreamBuffer
A class representing a data buffer that is part of an IOStream.
*/
class __exported IOStreamBuffer : public OSObject
{
OSDeclareDefaultStructors(IOStreamBuffer);
protected:
IOMemoryDescriptor * _dataBuffer; // The data buffer is expected to be filled by hardware.
IOMemoryDescriptor * _controlBuffer; // The control buffer is expected to be defined by the hardware driver.
IOStreamBufferID _bufferID; // Client handle for this buffer.
OSArray * _clientMemoryMaps; // Maps for clients who are sharing these buffers.
SInt32 _clientReferenceCount; // Count of client uses of this buffer. May be negative.
public:
/*!
@function initWithMemoryDescriptors
*/
virtual bool initWithMemoryDescriptors(IOMemoryDescriptor *dataBuffer,
IOMemoryDescriptor *controlBuffer,
IOStreamBufferID bufferID = 0);
/*!
@function withMemoryDescriptors
*/
static IOStreamBuffer *withMemoryDescriptors(IOMemoryDescriptor *dataBuffer,
IOMemoryDescriptor *controlBuffer,
IOStreamBufferID bufferID = 0);
virtual void free(void);
/*!
@function getBufferID
@abstract Gets the buffer identifier for the IOStreamBuffer object.
@discussion The buffer identifier is unique across all buffers in a stream.
*/
virtual IOStreamBufferID getBufferID(void);
/*!
@function setBufferID
@abstract Sets the buffer identifier for the IOStreamBuffer object.
*/
virtual void setBufferID( IOStreamBufferID bufferID );
/*!
@function setDataBuffer
@abstract Sets the data buffer for the IOStreamBuffer object.
*/
virtual void setDataBuffer(IOMemoryDescriptor *dataBuffer);
/*!
@function setControlBuffer
@abstract Sets the control buffer for the IOStreamBuffer object.
*/
virtual void setControlBuffer(IOMemoryDescriptor *controlBuffer);
/*!
@function getDataBuffer
@result A pointer to the IOMemoryDescriptor for the data buffer.
*/
virtual IOMemoryDescriptor *getDataBuffer(void);
/*!
@function getControlBuffer
@result A pointer to the IOMemoryDescriptor for the control buffer.
*/
virtual IOMemoryDescriptor *getControlBuffer(void);
/*!
@function getClientReferenceCount
@result The count of client references to this buffer. It may be positive
or negative, depending on whether the client is sending data into the kernel,
or the kernel is sending data out to the client.
*/
virtual SInt32 getClientReferenceCount( void );
/*!
@function sendClientReference
@param offset The offset in the buffer of the data sent to the client.
@param length The length of the data sent to the client.
@result The new client reference count.
@abstract
*/
virtual SInt32 sendClientReference( IOByteCount offset = 0, IOByteCount length = 0 );
/*!
@function receiveClientReference
@param offset The offset in the buffer of the data from the client.
@param length The length of the data from the client.
@abstract
*/
virtual SInt32 receiveClientReference( IOByteCount offset = 0, IOByteCount length = 0 );
/* Reserved slots */
OSMetaClassDeclareReservedUnused(IOStreamBuffer, 0);
OSMetaClassDeclareReservedUnused(IOStreamBuffer, 1);
OSMetaClassDeclareReservedUnused(IOStreamBuffer, 2);
OSMetaClassDeclareReservedUnused(IOStreamBuffer, 3);
OSMetaClassDeclareReservedUnused(IOStreamBuffer, 4);
OSMetaClassDeclareReservedUnused(IOStreamBuffer, 5);
OSMetaClassDeclareReservedUnused(IOStreamBuffer, 6);
OSMetaClassDeclareReservedUnused(IOStreamBuffer, 7);
OSMetaClassDeclareReservedUnused(IOStreamBuffer, 8);
OSMetaClassDeclareReservedUnused(IOStreamBuffer, 9);
OSMetaClassDeclareReservedUnused(IOStreamBuffer, 10);
OSMetaClassDeclareReservedUnused(IOStreamBuffer, 11);
OSMetaClassDeclareReservedUnused(IOStreamBuffer, 12);
OSMetaClassDeclareReservedUnused(IOStreamBuffer, 13);
OSMetaClassDeclareReservedUnused(IOStreamBuffer, 14);
OSMetaClassDeclareReservedUnused(IOStreamBuffer, 15);
OSMetaClassDeclareReservedUnused(IOStreamBuffer, 16);
OSMetaClassDeclareReservedUnused(IOStreamBuffer, 17);
OSMetaClassDeclareReservedUnused(IOStreamBuffer, 18);
OSMetaClassDeclareReservedUnused(IOStreamBuffer, 19);
OSMetaClassDeclareReservedUnused(IOStreamBuffer, 20);
OSMetaClassDeclareReservedUnused(IOStreamBuffer, 21);
OSMetaClassDeclareReservedUnused(IOStreamBuffer, 22);
OSMetaClassDeclareReservedUnused(IOStreamBuffer, 23);
OSMetaClassDeclareReservedUnused(IOStreamBuffer, 24);
OSMetaClassDeclareReservedUnused(IOStreamBuffer, 25);
OSMetaClassDeclareReservedUnused(IOStreamBuffer, 26);
OSMetaClassDeclareReservedUnused(IOStreamBuffer, 27);
OSMetaClassDeclareReservedUnused(IOStreamBuffer, 28);
OSMetaClassDeclareReservedUnused(IOStreamBuffer, 29);
OSMetaClassDeclareReservedUnused(IOStreamBuffer, 30);
OSMetaClassDeclareReservedUnused(IOStreamBuffer, 31);
};
#endif /* ! __IOKIT_IOSTREAM_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/stream/IOStreamUserClient.h | /*
* IOStreamUserClient.h
* IOStreamFamily
*
* Copyright 2006 Apple Computer, Inc. All rights reserved.
*
*/
#if !defined( __IOKIT_IOSTREAMUSERCLIENT_H )
#define __IOKIT_IOSTREAMUSERCLIENT_H
#include <IOKit/IOUserClient.h>
#include <IOKit/stream/IOStreamShared.h>
#include <IOKit/stream/IOStream.h>
#include <sys/cdefs.h>
class __exported IOStreamUserClient : public IOUserClient
{
OSDeclareDefaultStructors( IOStreamUserClient )
protected:
IOStream * _owner;
task_t _task;
IOWorkLoop * fWL;
IOCommandGate * fGate;
public:
virtual bool initWithTask(
task_t owningTask, void * securityToken, UInt32 type,
OSDictionary * properties);
virtual bool initWithTask(
task_t owningTask, void * securityToken, UInt32 type);
virtual IOReturn clientClose( void );
virtual IOReturn clientDied( void );
virtual IOService * getService( void );
virtual IOReturn registerNotificationPort(
mach_port_t port, UInt32 type, UInt32 refCon );
virtual IOReturn connectClient( IOUserClient * client );
virtual IOExternalMethod * getTargetAndMethodForIndex(
IOService ** targetP, UInt32 index );
virtual IOExternalTrap *
getTargetAndTrapForIndex( IOService **targetP, UInt32 index );
virtual IOReturn clientMemoryForType( UInt32 type,
IOOptionBits * options,
IOMemoryDescriptor ** memory );
virtual bool start( IOService * provider ) APPLE_KEXT_OVERRIDE;
virtual void stop(IOService *provider) APPLE_KEXT_OVERRIDE;
virtual void free(void) APPLE_KEXT_OVERRIDE;
protected:
virtual IOReturn openMethod( char * dataIn, char * dataOut,
IOByteCount inputSize, IOByteCount * outputSize );
virtual IOReturn closeMethod( void );
virtual IOReturn startMethod( void );
virtual IOReturn stopMethod( void );
virtual IOReturn suspendMethod( void );
virtual IOReturn getModeMethod( char * dataOut,
IOByteCount * outputSize );
virtual IOReturn setModeMethod( char * dataIn,
IOByteCount inputSize );
virtual IOReturn getBufferCountMethod( char * dataOut,
IOByteCount * outputSize );
virtual IOReturn inputTrap( UInt32 token );
virtual IOReturn inputSyncTrap( UInt32 token );
IOReturn clientMemoryForTypeGated( UInt32 memoryType, IOOptionBits * flags, IOMemoryDescriptor ** memory );
IOReturn getTargetAndMethodForIndexGated(IOService ** targetP, UInt32 index , IOExternalMethod ** method);
};
#endif /* ! __IOKIT_IOSTREAMUSERCLIENT_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/stream/IOStreamShared.h | /*
* IOStreamShared.h
* IOStreamFamily
*
* Copyright 2006 Apple Computer, Inc. All rights reserved.
*
*/
#if !defined(__IOKIT_IOSTREAMSHARED_H)
#define __IOKIT_IOSTREAMSHARED_H
#include <sys/cdefs.h>
#include <IOKit/IOTypes.h>
/*!
@header IOStreamShared.h
IOStream definitions shared between kernel and user space.
*/
__BEGIN_DECLS
// Buffer numbers are guaranteed to go from 0 to bufferCount - 1.
/*!
@typedef IOStreamBufferID
*/
typedef UInt32 IOStreamBufferID;
#define kIOStreamBufferIDInvalid (~0)
// This is the header for the shared-memory queue used to send buffer notifications
// from kernel to user space or vice versa.
// Queue entry in input or output queue
#ifdef __cplusplus
/*!
@struct IOStreamBufferQueueEntry
@field bufferID The ID of the buffer passed in this queue entry.
@field dataLength The length of the valid data in the buffer.
@field reserved Reserved for future use.
*/
struct IOStreamBufferQueueEntry {
IOStreamBufferID bufferID;
UInt32 dataOffset;
UInt32 dataLength;
UInt32 controlOffset;
UInt32 controlLength;
UInt32 reserved[3];
};
/*!
@struct IOStreamBufferQueue
@field entryCount The number of queue entries in the queue.
@field headIndex The index of the next queue slot that will be filled in by the queue writer.
@field tailIndex The index of the next queue slot that can be read by the queue reader.
@field reserved Reserved for future use.
@field queue The array of queue entries.
*/
struct IOStreamBufferQueue {
UInt32 entryCount;
volatile UInt32 headIndex;
volatile UInt32 tailIndex;
UInt32 reserved;
IOStreamBufferQueueEntry queue[0];
};
#else
typedef struct __IOStreamBufferQueueEntry {
IOStreamBufferID bufferID;
UInt32 dataOffset;
UInt32 dataLength;
UInt32 controlOffset;
UInt32 controlLength;
UInt32 reserved[3];
} IOStreamBufferQueueEntry;
typedef struct __IOStreamBufferQueue {
UInt32 entryCount;
volatile UInt32 headIndex;
volatile UInt32 tailIndex;
UInt32 reserved;
IOStreamBufferQueueEntry queue[0];
} IOStreamBufferQueue;
#endif
/*!
@enum Memory mapping types
@constant kIOStreamMemoryTypeOutputQueue
@constant kIOStreamMemoryTypeInputQueue
@constant kIOStreamMemoryTypeBufferData
@constant kIOStreamMemoryTypeBufferControl
@constant kIOStreamBufferIDMask
@constant kIOStreamMemoryTypeMask
@abstract Memory types used with IOConnectMapMemory().
@discussion
*/
enum {
kIOStreamMemoryTypeOutputQueue = 0x10000000,
kIOStreamMemoryTypeInputQueue = 0x20000000,
kIOStreamMemoryTypeBufferData = 0x30000000,
kIOStreamMemoryTypeBufferControl = 0x40000000,
kIOStreamBufferIDMask = 0x0FFFFFFF,
kIOStreamMemoryTypeMask = 0xF0000000
};
/*!
@enum Mach port types
@constant kIOStreamPortTypeOutput
@constant kIOStreamPortTypeInput
@abstract Port types used with IOConnectSetNotificationPort().
@discussion
*/
enum {
kIOStreamPortTypeOutput,
kIOStreamPortTypeInput
};
/*!
@enum IOStream open options
@discussion
*/
enum {
kIOStreamOptionOpenExclusive = 0x00010000,
kIOStreamOptionOpenShared = 0x00020000
};
/*!
@enum User client methods
@constant kIOStreamMethodOpen
@constant kIOStreamMethodClose
@constant kIOStreamMethodStart
@constant kIOStreamMethodStop
@constant kIOStreamMethodSuspend
@constant kIOStreamMethodGetMode
@constant kIOStreamMethodSetMode
@abstract Client method numbers used with IOConnectMethod...() functions.
@discussion
*/
enum {
kIOStreamMethodOpen,
kIOStreamMethodClose,
kIOStreamMethodStart,
kIOStreamMethodStop,
kIOStreamMethodSuspend,
kIOStreamMethodGetMode,
kIOStreamMethodSetMode,
kIOStreamMethodGetBufferCount
};
/*!
@enum User client traps
@constant kIOStreamEnqueueInputTrap
@constant kIOStreamEnqueueInputSyncTrap
@abstract Client trap numbers used with IOConnectTrap..() functions.
@discussion
*/
enum {
kIOStreamEnqueueInputTrap,
kIOStreamEnqueueInputSyncTrap
};
typedef enum {
kIOStreamModeInput, // From user to kernel space
kIOStreamModeOutput, // From kernel to user space
kIOStreamModeInputOutput // bidirectional
} IOStreamMode;
__END_DECLS
#endif /* ! __IOKIT_IOSTREAMSHARED_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/stream/IOStreamFamily.h | /*
* Copyright 2006 Apple Computer, Inc. All rights reserved.
*
*/
#ifndef __IOKIT_IOSTREAMFAMILY_H
#define __IOKIT_IOSTREAMFAMILY_H
#include <IOKit/stream/IOStream.h>
#include <IOKit/stream/IOStreamShared.h>
#endif /* !__IOKIT_IOSTREAMFAMILY_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/network/IOKernelDebugger.h | /*
* Copyright (c) 1998-2008 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* The contents of this file constitute Original Code as defined in and
* are subject to the Apple Public Source License Version 1.1 (the
* "License"). You may not use this file except in compliance with the
* License. Please obtain a copy of the License at
* http://www.apple.com/publicsource and read it before using this file.
*
* This Original Code and all software distributed under the License are
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _IOKERNELDEBUGGER_H
#define _IOKERNELDEBUGGER_H
#include <IOKit/IOService.h>
/*! @typedef IODebuggerRxHandler
@discussion Defines the receive handler that must be implemented
by the target to service KDP receive requests. This handler is called
by kdpReceiveDispatcher().
@param target The target object.
@param buffer KDP receive buffer. The buffer allocated has room for
1518 bytes. The receive handler must not overflow this buffer.
@param length The amount of data received and placed into the buffer.
Set to 0 if no frame was received during the poll interval.
@param timeout The amount of time to poll in milliseconds while waiting
for a frame to arrive. */
typedef void (*IODebuggerRxHandler)( IOService * target,
void * buffer,
UInt32 * length,
UInt32 timeout );
/*! @typedef IODebuggerTxHandler
@discussion Defines the transmit handler that must be implemented
by the target to service KDP transmit requests. This handler is called
by kdpTransmitDispatcher().
@param target The target object.
@param buffer KDP transmit buffer. This buffer contains a KDP frame
to be sent on the network.
@param length The number of bytes in the transmit buffer. */
typedef void (*IODebuggerTxHandler)( IOService * target,
void * buffer,
UInt32 length );
/*! @typedef IODebuggerLinkStatusHandler
@discussion Defines the link up handler that must be implemented
by the target to service KDP link status requests. This handler is called
by kdpLinkStatusDispatcher().
@param target The target object.
@result Return link status.
*/
typedef UInt32 (*IODebuggerLinkStatusHandler)( IOService * target);
/*! @typedef IODebuggerSetModeHandler
@discussion Defines the mode handler that must be implemented
by the target to service KDP link status requests. This handler is called
by kdpSetModeDispatcher().
@param target The target object.
@param active True if entering KDP and false if exiting KDP.
@result Return true on success and false on failure.
*/
typedef bool (*IODebuggerSetModeHandler)( IOService * target, bool active);
/*! @typedef IODebuggerLockState
@discussion Defines flags returned by IOKernelDebugger::lock().
@constant kIODebuggerLockTaken Set if the debugger lock was taken. */
typedef enum {
kIODebuggerLockTaken = 0x1
} IODebuggerLockState;
/*! @class IOKernelDebugger
@abstract Kernel debugger nub.
@discussion This object interfaces with the KDP
(kernel debugger protocol) module and dispatches KDP requests to its
target (provider). The target, designated as the debugger device, must
implement a pair of handler functions that are called to handle KDP
transmit and receive requests during a debugging session. Only a single
IOKernelDebugger in the system can be active at a given time. The
active IOKernelDebugger is the one that has an IOKDP object attached
as a client.
The debugger device is usually a subclass of IOEthernetController.
However, any IOService can service an IOKernelDebugger client,
implement the two polled mode handlers, and transport the KDP
packets through a data channel. However, KDP assumes that the
debugger device is an Ethernet interface and therefore it will
always send, and expect to receive, an Ethernet frame. */
class __exported IOKernelDebugger : public IOService
{
OSDeclareDefaultStructors( IOKernelDebugger )
protected:
IOService * _target; // target (provider)
IODebuggerTxHandler _txHandler; // target's transmit handler.
IODebuggerRxHandler _rxHandler; // target's receive handler.
IOService * _client; // client that has opened us.
bool _pmDisabled; // true if disabled by PM.
struct ExpansionData {
thread_call_t activationChangeThreadCall;
UInt32 stateVars[2];
IONotifier * interfaceNotifier;
IODebuggerLinkStatusHandler linkStatusHandler; // target's link status handler.
IODebuggerSetModeHandler setModeHandler; // target's KDP mode handler.
};
/*! @var reserved
Reserved for future use. (Internal use only) */
ExpansionData * _reserved;
/*! @function kdpReceiveDispatcher
@abstract The KDP receive dispatch function.
@discussion Field KDP receives requests, then dispatches the call to the
registered receiver handler.
@param buffer KDP receive buffer. The buffer allocated by KDP has room
for 1518 bytes. The receive handler must not overflow this buffer.
@param length The amount of data received and placed into the buffer.
Set to 0 if a frame was not received during the poll interval.
@param timeout The amount of time to poll in milliseconds while waiting
for a frame to arrive.
*/
static void kdpReceiveDispatcher(void * buffer,
UInt32 * length,
UInt32 timeout);
/*! @function kdpTransmitDispatcher
@abstract The KDP transmit dispatch function.
@discussion Field KDP transmit requests, then dispatches the call to the
registered transmit handler.
@param buffer KDP transmit buffer. This buffer contains a KDP frame to
be sent on the network.
@param length The number of bytes in the transmit buffer.
*/
static void kdpTransmitDispatcher(void * buffer, UInt32 length);
/*! @function kdpLinkStatusDispatcher
@abstract The KDP link status dispatch function.
@discussion Field KDP link status requests, then dispatches the call to the
registered link up handler.
@result Return link status.
*/
static UInt32 kdpLinkStatusDispatcher(void);
/*! @function kdpSetModeDispatcher
@abstract The KDP set mode dispatch function.
@discussion Field KDP set mode requests, then dispatches the call to the
registered set mode handler.
@param active TRUE if entering KDP. FALSE if leaving KDP.
@result Return TRUE if the link is up and data can be sent/received. Otherwise,
return FALSE.
*/
static boolean_t kdpSetModeDispatcher(boolean_t active);
/*! @function free
@abstract Frees the IOKernelDebugger instance. */
virtual void free() APPLE_KEXT_OVERRIDE;
/*! @function nullTxHandler
@abstract Null transmit handler.
@discussion This function is registered as the transmit handler when an
IOKernelDebugger object surrenders its status as the active debugger nub.
Until another IOKernelDebugger object gets promoted, this function will
handle polled transmit requests from KDP. This function does nothing
useful.
*/
static void nullTxHandler( IOService * target,
void * buffer,
UInt32 length );
/*! @function nullRxHandler
@abstract Null receive handler.
@discussion This function is registered as the receive handler when an
IOKernelDebugger object surrenders its status as the active debugger nub.
Until another IOKernelDebugger object gets promoted, this function will
handle polled receive requests from KDP. This function does nothing
except to log a warning message.
*/
static void nullRxHandler( IOService * target,
void * buffer,
UInt32 * length,
UInt32 timeout );
/*! @function nullLinkStatusHandler
@abstract Null link status handler.
@discussion This function is registered as the link status handler when an
IOKernelDebugger object surrenders its status as the active debugger nub.
Until another IOKernelDebugger object gets promoted, this function will
handle polled link status requests from KDP.
@result This function will always report link up.
*/
static UInt32 nullLinkStatusHandler( IOService * target);
/*! @function nullSetModeHandler
@abstract Null set mode handler.
@discussion This function is registered as the set mode handler when an
IOKernelDebugger object surrenders its status as the active debugger nub.
Until another IOKernelDebugger object gets promoted, this function will
handle set mode requests from KDP.
@result This function will always return true.
*/
static bool nullSetModeHandler( IOService * target, bool active);
/*! @function registerHandler
@abstract Registers the target and the handler functions.
@discussion This method is called by handleOpen() and handleClose()
to register or unregister the target and its handler functions.
@param target The target object.
@param txHandler The transmit handler function. The null handler is
registered if the argument is zero.
@param rxHandler The receive handler function. The null handler is
@param linkUpHandler The linkup handler function. The null handler is
registered if the argument is zero.
*/
static void registerHandler( IOService * target,
IODebuggerTxHandler txHandler = 0,
IODebuggerRxHandler rxHandler = 0,
IODebuggerLinkStatusHandler linkUpHandler = 0,
IODebuggerSetModeHandler setModeHandler = 0);
/*! @function powerStateWillChangeTo
@abstract Handles notification that the network controller will change
power state.
@discussion If the controller is about to become unusable, then the
controller's handlers are unregistered, and the controller is disabled.
@param flags Describe the capability of the controller in the new power
state.
@param stateNumber The number of the state in the state array that the
controller is switching to.
@param policyMaker The policy maker that manages the controller's
power state.
@result Returns the constant 3000000, to indicate a maximum of 3 seconds for the
preparation to complete, and an acknowledgement delivered to the
policy maker.
*/
virtual IOReturn powerStateWillChangeTo( IOPMPowerFlags flags,
unsigned long stateNumber,
IOService * policyMaker ) APPLE_KEXT_OVERRIDE;
/*! @function powerStateDidChangeTo
@abstract Handles notification that the network controller did change
power state.
@discussion If the controller became usable, then the controller is
re-enabled, and the controller's handlers are re-registered.
@param flags Description of the capability of the controller in the new power
state.
@param stateNumber The number of the state in the state array that the
controller is switching to.
@param policyMaker The policy maker that manages the controller's
power state.
@result Returns the constant 3000000, to indicate a maximum of 3 seconds for the
preparation to complete, and an acknowledgement delivered to the
policy maker.
*/
virtual IOReturn powerStateDidChangeTo( IOPMPowerFlags flags,
unsigned long stateNumber,
IOService * policyMaker ) APPLE_KEXT_OVERRIDE;
/*! @function handleOpen
@abstract Handles a client open.
@discussion This method is called by IOService::open() to handle an
open from a client (IOKDP) with the arbitration lock held.
@param forClient The client (IOKDP) requesting the open.
@param options Options passed to the open() call. Not used.
@param arg A family defined argument passed to the open() call. Not used.
@result Returns true on success, false otherwise.
*/
virtual bool handleOpen( IOService * forClient,
IOOptionBits options,
void * arg ) APPLE_KEXT_OVERRIDE;
/*! @function handleClose
@abstract Handles a client close.
@discussion This method is called by IOService::close() to handle a
close from a client with the arbitration lock held.
@param forClient The client (IOKDP) requesting the close.
@param options Options passed to the close() call. Not used.
*/
virtual void handleClose( IOService * forClient,
IOOptionBits options ) APPLE_KEXT_OVERRIDE;
/*! @function handleIsOpen
@abstract Queries whether a client has an open on this object.
@discussion This method is called by IOService::isOpen() with the
arbitration lock held.
@result Returns true if the specified client, or any client if none (0) is
specified, presently has an open on this object.
*/
virtual bool handleIsOpen( const IOService * forClient ) const APPLE_KEXT_OVERRIDE;
static bool interfacePublished(
void *target, void *param, IOService *service, IONotifier *notifier );
public:
/*! @function lock
@abstract Takes the debugger lock conditionally.
@discussion This method takes the debugger lock if the object given matches the
target registered by registerHandler().
@param target The target or provider of an IOKernelDebugger object.
@result Returns kIODebuggerLockTaken if the lock was taken, or 0 otherwise.
*/
static IODebuggerLockState lock( IOService * target );
/*! @function unlock
@abstract Releases the debugger lock.
@discussion This method releases the debugger lock if the kIODebuggerLockTaken flag is
set in the argument.
*/
static void unlock( IODebuggerLockState state );
/*! @function init
@abstract Initializes an IOKernelDebugger instance.
@param target The target object that implements the debugger handlers.
@param txHandler The target's transmit handler. A pointer to a 'C' function.
@param rxHandler The target's receive handler. A pointer to a 'C' function.
@param linkStatusHandler The target's link status handler. A pointer to a 'C' function.
@param setModeHandler The target's set mode handler. A pointer to a 'C' function.
@result Returns true if the instance initialized successfully, false otherwise.
*/
virtual bool init( IOService * target,
IODebuggerTxHandler txHandler,
IODebuggerRxHandler rxHandler,
IODebuggerLinkStatusHandler linkUpHandler,
IODebuggerSetModeHandler setModeHandler);
/*! @function debugger
@abstract Factory method that performs allocation and initialization
of an IOKernelDebugger object.
@param target The target object that implements the debugger handlers.
@param txHandler The target's transmit handler. A pointer to a 'C' function.
@param rxHandler The target's receive handler. A pointer to a 'C' function.
@param linkStatusHandler The target's link status handler. A pointer to a 'C' function.
@param setModeHandler The target's set mode handler. A pointer to a 'C' function.
@result Returns an IOKernelDebugger instance on success, 0 otherwise.
*/
static IOKernelDebugger * debugger( IOService * target,
IODebuggerTxHandler txHandler,
IODebuggerRxHandler rxHandler,
IODebuggerLinkStatusHandler linkStatusHandler,
IODebuggerSetModeHandler setModeHandler);
/*
* Entry point for generic messages delivered from the provider.
*/
virtual IOReturn message( UInt32 type, IOService * provider, void * arg ) APPLE_KEXT_OVERRIDE;
/*! @function signalDebugger
@abstract Signal the kernel to enter the debugger when safe.
*/
static void signalDebugger(void);
// Virtual function padding
OSMetaClassDeclareReservedUnused( IOKernelDebugger, 0);
OSMetaClassDeclareReservedUnused( IOKernelDebugger, 1);
OSMetaClassDeclareReservedUnused( IOKernelDebugger, 2);
OSMetaClassDeclareReservedUnused( IOKernelDebugger, 3);
};
// Concise form of the lock()/unlock() static member functions.
//
#define IODebuggerLock IOKernelDebugger::lock
#define IODebuggerUnlock IOKernelDebugger::unlock
#endif /* !_IOKERNELDEBUGGER_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/network/IOBasicOutputQueue.h | /*
* Copyright (c) 1998-2008 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* The contents of this file constitute Original Code as defined in and
* are subject to the Apple Public Source License Version 1.1 (the
* "License"). You may not use this file except in compliance with the
* License. Please obtain a copy of the License at
* http://www.apple.com/publicsource and read it before using this file.
*
* This Original Code and all software distributed under the License are
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _IOBASICOUTPUTQUEUE_H
#define _IOBASICOUTPUTQUEUE_H
#include <IOKit/IOLocks.h>
#include <IOKit/network/IOOutputQueue.h>
#include <IOKit/network/IOPacketQueue.h>
struct IOMbufQueue;
/*! @class IOBasicOutputQueue
@abstract A concrete implementation of an IOOutputQueue.
@discussion This object uses a mutex to protect the packet queue from
multiple producers.
A single producer is promoted to become a consumer when the queue is
not active. Otherwise, the producer will simply queue the packet and
return without blocking.
The flow of packets from the queue to its target can be controlled
by calling methods such as start(), stop(), or service(). The target
is expected to call those methods from a single threaded context,
i.e. the work loop context in a network driver. In addition, the
target must also return a status for every packet delivered by the
consumer thread. This return value is the only mechanism that the
target can use to manage the queue when it is running on the
consumer thread.
*/
class __exported IOBasicOutputQueue : public IOOutputQueue
{
OSDeclareDefaultStructors( IOBasicOutputQueue )
private:
static IOReturn dispatchNetworkDataNotification(void * target,
void * param,
IONetworkData * data,
UInt32 type);
void dequeue();
protected:
OSObject * _target;
IOOutputAction _action;
UInt32 _priorities;
IOOutputQueueStats * _stats;
IONetworkData * _statsData;
IOLock * _queueLock;
IOMbufQueue * _inQueues;
IOMbufQueue * _primaryQueues;
IOMbufQueue * _shadowQueues;
volatile bool _waitDequeueDone;
volatile UInt32 _state;
volatile UInt32 _serviceCount;
/*! @function serviceThread
@abstract Provides an implementation for the serviceThread() method
defined in IOOutputQueue.
@discussion This method is called by the scheduled service thread when it
starts to run. The service thread is scheduled by service()
to restart a stalled queue when the kServiceAsync option is given.
@param param A parameter that was given to scheduleServiceThread().
This parameter is not used.
*/
virtual void serviceThread(void * param) APPLE_KEXT_OVERRIDE;
/*! @function output
@abstract Transfers all packets in the mbuf queue to the target.
@param queue A queue of output packets.
@param state Returns a state bit defined by IOBasicOutputQueue that
declares the new state of the queue following this method call.
A kStateStalled is returned if the queue should stall, otherwise 0
is returned.
*/
virtual void output(IOMbufQueue * queue, UInt32 * state);
/*! @function free
@abstract Frees the IOBasicOutputQueue object.
@discussion This function releases allocated resources, then call super::free().
*/
virtual void free() APPLE_KEXT_OVERRIDE;
/*! @function handleNetworkDataAccess
@abstract Handles an external access to the IONetworkData object
returned by getStatisticsData().
@param data The IONetworkData object being accessed.
@param type Description of the type of access being performed.
@param param An optional parameter for the handler.
@result Returns kIOReturnSuccess on success, or an error code otherwise.
*/
virtual IOReturn handleNetworkDataAccess(IONetworkData * data,
UInt32 type,
void * param);
public:
/*! @function init
@abstract Initializes an IOBasicOutputQueue object.
@param target The object that will handle packets removed from the
queue, which is usually a subclass of IONetworkController.
@param action The function that will handle packets removed from the
queue.
@param capacity The initial capacity of the output queue.
@result Returns true if initialized successfully, false otherwise.
*/
virtual bool init(OSObject * target,
IOOutputAction action,
UInt32 capacity = 0,
UInt32 priorities = 1);
/*! @function withTarget
@abstract Factory method that constructs and initializes an
IOBasicOutputQueue object.
@param target An IONetworkController object that will handle packets
removed from the queue.
@param capacity The initial capacity of the output queue.
@result Returns an IOBasicOutputQueue object on success, or 0 otherwise.
*/
static IOBasicOutputQueue * withTarget(IONetworkController * target,
UInt32 capacity = 0);
/*! @function withTarget
@abstract Factory method that constructs and initializes an
IOBasicOutputQueue object.
@param target An IONetworkController object that will handle packets
removed from the queue.
@param capacity The initial capacity of the output queue.
@param priorities The number of traffic priorities supported
@result Returns an IOBasicOutputQueue object on success, or 0 otherwise.
*/
static IOBasicOutputQueue * withTarget(IONetworkController * target,
UInt32 capacity,
UInt32 priorities);
/*! @function withTarget
@abstract Factory method that constructs and initializes an
IOBasicOutputQueue object.
@param target The object that will handle packets removed from the
queue.
@param action The function that will handle packets removed from the
queue.
@param capacity The initial capacity of the output queue.
@result Returns an IOBasicOutputQueue object on success, or 0 otherwise.
*/
static IOBasicOutputQueue * withTarget(OSObject * target,
IOOutputAction action,
UInt32 capacity = 0);
/*! @function withTarget
@abstract Factory method that constructs and initializes an
IOBasicOutputQueue object.
@param target The object that will handle packets removed from the
queue.
@param action The function that will handle packets removed from the
queue.
@param capacity The initial capacity of the output queue.
@param priorities The number of traffic priorities supported
@result Returns an IOBasicOutputQueue object on success, or 0 otherwise.
*/
static IOBasicOutputQueue * withTarget(OSObject * target,
IOOutputAction action,
UInt32 capacity,
UInt32 priorities);
/*! @function enqueue
@abstract Adds a packet, or a chain of packets,
to the queue.
@discussion This method is called by a client to add a packet, or a chain of packets,
to the queue. A packet is described by an mbuf chain, while a chain
of packets is constructed by linking multiple mbuf chains via the
m_nextpkt field. This method can be called by multiple client
threads.
@param m A single packet, or a chain of packets.
@param param A parameter provided by the caller.
@result Always returns 0.
*/
virtual UInt32 enqueue(mbuf_t m, void * param) APPLE_KEXT_OVERRIDE;
/*! @function start
@abstract Starts up the packet flow between the queue and its target.
@discussion Called by the target to start the queue. This will allow
packets to be removed from the queue, and then delivered to the target.
@result Returns true if the queue was started successfully, false otherwise. */
virtual bool start() APPLE_KEXT_OVERRIDE;
/*! @function stop
@abstract Stops the packet flow between the queue and its target.
@discussion This method stops the queue and prevents it from sending packets to its
target. This call is synchronous and it may block. After this method
returns, the queue will no longer call the registered target/action,
even as new packets are added to the queue. The queue will continue to
absorb new packets until the size of the queue reaches its capacity.
The registered action must never call stop(), or a deadlock will occur.
@result Returns the previous running state of the queue,
true if the queue was running, false if the queue was already stopped.
*/
virtual bool stop() APPLE_KEXT_OVERRIDE;
/*! @enum ServiceAsync
@abstract The option bits recognized by service().
@constant kServiceAsync Set this option to service the queue in
an asynchronous manner. The service() call will not block, but a
scheduling latency will be introduced before the queue is serviced.
*/
enum {
kServiceAsync = 0x1
};
/*! @function service
@abstract Services a queue that was stalled by the target.
@discussion A target that stalls the queue must call service() when
it becomes ready to accept more packets. Calling this method when the
queue is not stalled is harmless.
@result Returns true if the queue was stalled and there were packets sitting in
the queue awaiting delivery, false otherwise.
*/
virtual bool service(IOOptionBits options = 0) APPLE_KEXT_OVERRIDE;
/*! @function flush
@abstract Drops and frees all packets currently held by the queue.
@discussion To ensure that all packets are removed from the queue,
stop() should be called prior to flush(), to make sure there are
no packets in-flight and being delivered to the target.
@result Returns the number of packets that were dropped and freed.
*/
virtual UInt32 flush() APPLE_KEXT_OVERRIDE;
/*! @function setCapacity
@abstract Changes the number of packets that the queue can hold
before it begins to drop excess packets.
@param capacity The new desired capacity.
@result Returns true if the new capacity was accepted, false otherwise.
*/
virtual bool setCapacity(UInt32 capacity) APPLE_KEXT_OVERRIDE;
/*! @function getCapacity
@abstract Gets the number of packets that the queue can hold.
@discussion The queue will begin to drop incoming packets when the
size of the queue reaches its capacity.
@result Returns the current queue capacity.
*/
virtual UInt32 getCapacity() const APPLE_KEXT_OVERRIDE;
/*! @function getSize
@abstract Gets the number of packets currently held in the queue.
@result Returns the size of the queue.
*/
virtual UInt32 getSize() const APPLE_KEXT_OVERRIDE;
/*! @function getDropCount
@abstract Gets the number of packets dropped by the queue.
@result Returns the number of packets dropped due to over-capacity, or by
external calls to the flush() method.
*/
virtual UInt32 getDropCount();
/*! @function getOutputCount
@abstract Gets the number of packets accepted by the target.
@result Returns the number of times that kIOOutputStatusAccepted is returned by
the target.
*/
virtual UInt32 getOutputCount();
/*! @function getRetryCount
@abstract Gets the number of instances when the target has refused to
accept the packet provided.
@result Returns the number of times that kIOOutputStatusRetry is returned by the
target.
*/
virtual UInt32 getRetryCount();
/*! @function getStallCount
@abstract Gets the number of instances when the target has stalled the
queue.
@result Returns the number of times that kIOOutputCommandStall is returned by the
target.
*/
virtual UInt32 getStallCount();
/*! @enum GetStateBits
@abstract The bits in the value returned by getState().
@constant kStateRunning Set when the queue is running. Calling start()
and stop() will set or clear this bit.
@constant kStateStalled Set when the queue is stalled by the target.
@constant kStateActive Set when a consumer thread is actively removing
packets from the queue and passing them to the target.
*/
enum {
kStateRunning = 0x1,
kStateOutputStalled = 0x2,
kStateOutputActive = 0x4,
kStateOutputServiceMask = 0xff00
};
/*! @function getState
@abstract Gets the state of the queue object.
@result Returns the current state of the queue object.
*/
virtual UInt32 getState() const;
/*! @function getStatisticsData
@abstract Returns an IONetworkData object containing statistics counters
updated by the queue.
@result Returns an IONetworkData object.
*/
virtual IONetworkData * getStatisticsData() const APPLE_KEXT_OVERRIDE;
};
#endif /* !_IOBASICOUTPUTQUEUE_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/network/IOEthernetController.h | /*
* Copyright (c) 1998-2008 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* The contents of this file constitute Original Code as defined in and
* are subject to the Apple Public Source License Version 1.1 (the
* "License"). You may not use this file except in compliance with the
* License. Please obtain a copy of the License at
* http://www.apple.com/publicsource and read it before using this file.
*
* This Original Code and all software distributed under the License are
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _IOETHERNETCONTROLLER_H
#define _IOETHERNETCONTROLLER_H
#include <IOKit/network/IONetworkController.h>
#define APPLE_KEXT_DEPRECATE __kpi_deprecated("DriverKit/NetworkingDriverKit is the new Networking Driver Development framework, please transition your Networking Driver to that Framework")
/*! @defined kIOEthernetControllerClass
@abstract kIOEthernetControllerClass is the name of the
IOEthernetController class. */
#define kIOEthernetControllerClass "IOEthernetController"
/*! @defined kIOEthernetAddressSize
@abstract The number of bytes in an Ethernet hardware address. */
#define kIOEthernetAddressSize 6
/*! @defined kIOEthernetMaxPacketSize
@abstract The maximum size of an Ethernet packet, including
the FCS bytes. */
#define kIOEthernetMaxPacketSize 1518
/*! @defined kIOEthernetMinPacketSize
@abstract The minimum size of an Ethernet packet, including
the FCS bytes. */
#define kIOEthernetMinPacketSize 64
/*! @defined kIOEthernetCRCSize
@abstract The size in bytes of the 32-bit CRC value appended
to the end of each Ethernet frame. */
#define kIOEthernetCRCSize 4
/*! @defined kIOEthernetWakeOnLANFilterGroup
@abstract kIOEthernetWakeOnLANFilterGroup describes the name assigned
to the Ethernet Wake-On-LAN filter group. This group represents
wake filters that are supported by the controller. */
#define kIOEthernetWakeOnLANFilterGroup "IOEthernetWakeOnLANFilterGroup"
/*! @defined kIOEthernetDisabledWakeOnLANFilterGroup
@abstract kIOEthernetDisabledWakeOnLANFilterGroup describes the name
assigned to the disabled Ethernet Wake-On-LAN filter group. This
group represents wake filters that are currently disabled.
Membership in this group is dynamic. */
#define kIOEthernetDisabledWakeOnLANFilterGroup \
"IOEthernetDisabledWakeOnLANFilterGroup"
/*! @enum Wake On LAN Filters
@abstract All filters in the Wake-on-LAN filter group.
@discussion Each filter listed will respond to a network event that
will trigger a system wake-up.
@constant kIOEthernetWakeOnMagicPacket Reception of a Magic Packet.
@constant kIOEthernetWakeOnPacketAddressMatch Reception of a packet
which passes through any of the address filtering mechanisms based
on its destination Ethernet address. This may include unicast,
broadcast, or multicast addresses depending on the current state
and setting of the corresponding packet filters. */
enum {
kIOEthernetWakeOnMagicPacket = 0x00000001,
kIOEthernetWakeOnPacketAddressMatch = 0x00000002
};
#ifdef KERNEL
#ifdef __cplusplus
struct IOEthernetAddress {
UInt8 bytes[kIOEthernetAddressSize];
};
/*! @const gIOEthernetWakeOnLANFilterGroup
@discussion gIOEthernetWakeOnLANFilterGroup is an OSSymbol object
that contains the name of the Ethernet Wake-on-LAN filter group
defined by kIOEthernetWakeOnLANFilterGroup. */
extern const OSSymbol * gIOEthernetWakeOnLANFilterGroup;
/*! @const gIOEthernetDisabledWakeOnLANFilterGroup
@discussion gIOEthernetDisabledWakeOnLANFilterGroup is an OSSymbol object
that contains the name of the disabled Ethernet Wake-on-LAN filter group
defined by kIOEthernetDisabledWakeOnLANFilterGroup. */
extern const OSSymbol * gIOEthernetDisabledWakeOnLANFilterGroup;
/*! @enum AVB Time Sync Support
@abstract The support that the controller has for Time Sync timestamping.
@discussion A controller can support ingress and egress timestamping of time sync packets
in a number of ways.
@const kIOEthernetControllerAVBTimeSyncSupportNone Controller does not support sending or
receiving packets with ingress and egress timestamping
@const kIOEthernetControllerAVBTimeSyncSupportHardware Controller supports sending and
receiving packets with ingress and egress timestamping and the timestamping is done in hardware
@const kIOEthernetControllerAVBTimeSyncSupportInterrupt Controller supports sending and receiving
packets with ingress and egress timestamping and the timestamping is done in the primary interrupt handler
@const kIOEthernetControllerAVBTimeSyncSupportSoftware Controller supports sending and receiving
packets with ingress and egress timestamping and the timestamping is done in software stack
(secondary interrupt handler or higher)
*/
typedef enum
{
kIOEthernetControllerAVBTimeSyncSupportNone,
kIOEthernetControllerAVBTimeSyncSupportHardware,
kIOEthernetControllerAVBTimeSyncSupportInterrupt,
kIOEthernetControllerAVBTimeSyncSupportSoftware,
} IOEthernetControllerAVBTimeSyncSupport;
/*! @enum Controller AVB States
@abstract The state the AVB support is in.
@discussion A controller can be in one of 4 states depending on the capabilities required by the AVB stack.
@const kIOEthernetControllerAVBStateDisabled No AVB streaming services or gPTP can run
@const kIOEthernetControllerAVBStateActivated No AVB streaming services and no gPTP but they can be
enabled, no media restrictions
@const kIOEthernetControllerAVBStateTimeSyncEnabled No AVB streaming services, time sync hardware
enabled so that gPTP can run, no media restrictions
@const kIOEthernetControllerAVBStateAVBEnabled AVB streams can run, media restrictions are in place
*/
typedef enum
{
kIOEthernetControllerAVBStateDisabled,
kIOEthernetControllerAVBStateActivated,
kIOEthernetControllerAVBStateTimeSyncEnabled,
kIOEthernetControllerAVBStateAVBEnabled,
} IOEthernetControllerAVBState;
///Events to trigger changes of state
/*! @enum Controller AVB State Events
@abstract Events to trigger the change in AVB state of the controller.
@const kIOEthernetControllerAVBStateEventDisable Disable AVB support
@const kIOEthernetControllerAVBStateEventEnable Enable AVB support
@const kIOEthernetControllerAVBStateEventStartTimeSync Start using Time Sync services.
@const kIOEthernetControllerAVBStateEventStopTimeSync Stop using Time Sync services.
@const kIOEthernetControllerAVBStateEventStartStreaming Start using realtime streaming services.
@const kIOEthernetControllerAVBStateEventStopStreaming Stop using realtime streaming services.
*/
typedef enum
{
kIOEthernetControllerAVBStateEventDisable,
kIOEthernetControllerAVBStateEventEnable,
kIOEthernetControllerAVBStateEventStartTimeSync,
kIOEthernetControllerAVBStateEventStopTimeSync,
kIOEthernetControllerAVBStateEventStartStreaming,
kIOEthernetControllerAVBStateEventStopStreaming,
} IOEthernetControllerAVBStateEvent;
class IOTimeSyncEthernetInterfaceAdapter;
/*! @class IOEthernetController
@abstract Abstract superclass for Ethernet controllers.
@discussion Ethernet controller drivers should subclass IOEthernetController, and implement
or override the hardware specific methods to create an Ethernet driver.
An interface object (an IOEthernetInterface instance) must be
instantiated by the driver, through attachInterface(), to connect
the controller driver to the data link layer.
*/
class __exported APPLE_KEXT_DEPRECATE IOEthernetController : public IONetworkController
{
OSDeclareAbstractStructors( IOEthernetController )
protected:
struct IOECTSCallbackEntry;
struct ExpansionData {
IOEthernetControllerAVBTimeSyncSupport fTimeSyncSupport;
bool fRealtimeMulticastAllowed;
IOMapper *fAVBPacketMapper;
uint32_t fNumberOfRealtimeTransmitQueues;
uint64_t *fTransmitQueuePacketLatency;
uint64_t *fTransmitQueuePrefetchDelay;
uint32_t fNumberOfRealtimeReceiveQueues;
IOEthernetControllerAVBState fAVBControllerState;
int32_t fTimeSyncEnabled;
int32_t fAVBEnabled;
IOLock *fStateLock;
OSArray *fStateChangeNotifiers;
IOLock *fStateChangeNotifiersLock;
OSArray *fTimeSyncReceiveHandlers;
IOLock *fTimeSyncReceiveHandlersLock;
OSArray *fTimeSyncTransmitHandlers;
IOLock *fTimeSyncTransmitHandlersLock;
uint32_t fNextTimeSyncTransmitCallbackID;
bool fHasTimeSyncTransmitCallbackIDAvailable;
struct IOECTSCallbackEntry *fTimeSyncTransmitCallbackQueue;
IOLock *fTimeSyncTransmitCallbackQueueLock;
struct IOECTSCallbackEntry *fTimeSyncReceiveCallbackQueue;
IOLock *fTimeSyncReceiveCallbackQueueLock;
bool fTimeSyncCallbackThreadShouldKeepRunning;
bool fTimeSyncCallbackThreadIsRunning;
thread_t fTimeSyncCallbackThread;
semaphore_t fTimeSyncCallbackStartSemaphore;
semaphore_t fTimeSyncCallbackStopSemaphore;
semaphore_t fTimeSyncCallbackQueueSemaphore;
uint64_t fTimeSyncCallbackTimeoutTime;
bool fgPTPPresent;
};
/*! @var reserved
Reserved for future use. (Internal use only) */
ExpansionData * _reserved;
public:
/*! @function initialize
@abstract IOEthernetController class initializer.
@discussion Creates global OSSymbol objects that are used as keys. */
static void initialize();
/*! @function init
@abstract Initializes an IOEthernetController object.
@param properties A dictionary object containing a property table
associated with this instance.
@result Returns true on success, false otherwise.
*/
virtual bool init(OSDictionary * properties) APPLE_KEXT_OVERRIDE;
/*! @function getPacketFilters
@abstract Gets the set of packet filters supported by the Ethernet
controller in the given filter group.
@discussion The default implementation of the abstract method inherited
from IONetworkController. When the filter group specified is
gIONetworkFilterGroup, then this method will return a value formed by
a bitwise OR of kIOPacketFilterUnicast, kIOPacketFilterBroadcast,
kIOPacketFilterMulticast, kIOPacketFilterPromiscuous. Otherwise, the
return value will be set to zero (0). Subclasses must override this
method if their filtering capability differs from what is reported by
this default implementation. This method is called from the workloop
context, and the result is published to the I/O Kit Registry.
@param group The name of the filter group.
@param filters Pointer to the mask of supported filters returned by
this method.
@result Returns kIOReturnSuccess. Drivers that override this
method must return kIOReturnSuccess to indicate success, or an error
return code otherwise.
*/
virtual IOReturn getPacketFilters(const OSSymbol * group,
UInt32 * filters) const APPLE_KEXT_OVERRIDE;
/*! @function enablePacketFilter
@abstract Enables one of the supported packet filters from the
given filter group.
@discussion The default implementation of the abstract method inherited
from IONetworkController. This method will call setMulticastMode() or
setPromiscuousMode() when the multicast or the promiscuous filter is to be
enabled. Requests to disable the Unicast or Broadcast filters are handled
silently, without informing the subclass. Subclasses can override this
method to change this default behavior, or to extend it to handle
additional filter types or filter groups. This method call is synchronized
by the workloop's gate.
@param group The name of the filter group containing the filter to be
enabled.
@param aFilter The filter to enable.
@param enabledFilters All filters currently enabled by the client.
@param options Optional flags for the enable request.
@result Returns the value returned by setMulticastMode() or setPromiscuousMode() if
either of those two methods are called. Returns kIOReturnSuccess if the filter
specified is kIOPacketFilterUnicast or kIOPacketFilterBroadcast.
Returns kIOReturnUnsupported if the filter group specified is not
gIONetworkFilterGroup.
*/
virtual IOReturn enablePacketFilter(const OSSymbol * group,
UInt32 aFilter,
UInt32 enabledFilters,
IOOptionBits options = 0) APPLE_KEXT_OVERRIDE;
/*! @function disablePacketFilter
@abstract Disables a packet filter that is currently enabled from the
given filter group.
@discussion The default implementation of the abstract method inherited
from IONetworkController. This method will call setMulticastMode() or
setPromiscuousMode() when the multicast or the promiscuous filter is to be
disabled. Requests to disable the Unicast or Broadcast filters are handled
silently, without informing the subclass. Subclasses can override this
method to change this default behavior, or to extend it to handle
additional filter types or filter groups. This method call is synchronized
by the workloop's gate.
@param group The name of the filter group containing the filter to be
disabled.
@param aFilter The filter to disable.
@param enabledFilters All filters currently enabled by the client.
@param options Optional flags for the disable request.
@result Returns the value returned by setMulticastMode() or setPromiscuousMode() if
either of those two methods are called. Returns kIOReturnSuccess if the filter
specified is kIOPacketFilterUnicast or kIOPacketFilterBroadcast.
Returns kIOReturnUnsupported if the filter group specified is not
gIONetworkFilterGroup.
*/
virtual IOReturn disablePacketFilter(const OSSymbol * group,
UInt32 aFilter,
UInt32 enabledFilters,
IOOptionBits options = 0) APPLE_KEXT_OVERRIDE;
/*! @function getHardwareAddress
@abstract Gets the Ethernet controller's station address.
@discussion The default implementation of the abstract method inherited
from IONetworkController. This method will call the overloaded form
IOEthernetController::getHardwareAddress() that subclasses are expected
to override.
@param addr The buffer where the controller's hardware address should
be written.
@param inOutAddrBytes The size of the address buffer provided by the
client, and replaced by this method with the actual size of
the hardware address in bytes.
@result Returns kIOReturnSuccess on success, or an error otherwise.
*/
virtual IOReturn getHardwareAddress(void * addr,
UInt32 * inOutAddrBytes) APPLE_KEXT_OVERRIDE;
/*! @function setHardwareAddress
@abstract Sets or changes the station address used by the Ethernet
controller.
@discussion The default implementation of the abstract method inherited
from IONetworkController. This method will call the overloaded form
IOEthernetController::setHardwareAddress() that subclasses are expected
to override.
@param addr The buffer containing the hardware address provided by
the client.
@param addrBytes The size of the address buffer provided by the
client in bytes.
@result Returns kIOReturnSuccess on success, or an error otherwise.
*/
virtual IOReturn setHardwareAddress(const void * addr,
UInt32 addrBytes) APPLE_KEXT_OVERRIDE;
/*! @function getMaxPacketSize
@abstract Gets the maximum packet size supported by the Ethernet
controller, including the frame header and FCS.
@param maxSize Pointer to the return value.
@result Returns kIOReturnSuccess on success, or an error code otherwise.
*/
virtual IOReturn getMaxPacketSize(UInt32 * maxSize) const APPLE_KEXT_OVERRIDE;
/*! @function getMinPacketSize
@abstract Gets the minimum packet size supported by the Ethernet
controller, including the frame header and FCS.
@param minSize Pointer to the return value.
@result Returns kIOReturnSuccess on success, or an error code otherwise.
*/
virtual IOReturn getMinPacketSize(UInt32 * minSize) const APPLE_KEXT_OVERRIDE;
/*! @function getPacketFilters
@abstract Gets the set of packet filters supported by the Ethernet
controller in the network filter group.
@param filters Pointer to the return value containing a mask of
supported filters.
@result Returns kIOReturnSuccess. Drivers that override this
method must return kIOReturnSuccess to indicate success, or an error
return code otherwise.
*/
virtual IOReturn getPacketFilters(UInt32 * filters) const;
/*! @function getHardwareAddress
@abstract Gets the Ethernet controller's permanent station address.
@discussion Ethernet drivers must implement this method, by reading the
address from hardware and writing it to the buffer provided. This method
is called from the workloop context.
@param addrP Pointer to an IOEthernetAddress where the hardware address
should be returned.
@result Returns kIOReturnSuccess on success, or an error return code otherwise.
*/
virtual IOReturn getHardwareAddress(IOEthernetAddress * addrP) = 0;
/*! @function setHardwareAddress
@abstract Sets or changes the station address used by the Ethernet
controller.
@discussion This method is called in response to a client command to
change the station address used by the Ethernet controller. Implementation
of this method is optional. This method is called from the workloop context.
@param addrP Pointer to an IOEthernetAddress containing the new station
address.
@result The default implementation will always return kIOReturnUnsupported.
If overridden, drivers must return kIOReturnSuccess on success, or an error
return code otherwise.
*/
virtual IOReturn setHardwareAddress(const IOEthernetAddress * addrP);
/*! @function setMulticastMode
@abstract Enables or disables multicast mode.
@discussion Called by enablePacketFilter() or disablePacketFilter()
when there is a change in the activation state of the multicast filter
identified by kIOPacketFilterMulticast. This method is called from the
workloop context.
@param active True to enable multicast mode, false to disable it.
@result Returns kIOReturnUnsupported. If overridden, drivers must return
kIOReturnSuccess on success, or an error return code otherwise.
*/
virtual IOReturn setMulticastMode(bool active);
/*! @function setMulticastList
@abstract Sets the list of multicast addresses a multicast filter
should use to match against the destination address of an incoming frame.
@discussion This method sets the list of multicast addresses that the multicast filter
should use to match against the destination address of an incoming frame.
The frame should be accepted when a match occurs. Called when the multicast group membership of an interface
object is changed. Drivers that support kIOPacketFilterMulticast should
override this method and update the hardware multicast filter using the
list of Ethernet addresses provided. Perfect multicast filtering is
preferred if supported by the hardware, in order to reduce the number of
unwanted packets received. If the number of multicast addresses in the
list exceeds what the hardware is capable of supporting, or if perfect
filtering is not supported, then ideally the hardware should be programmed
to perform imperfect filtering, through some form of hash filtering
mechanism. Only as a last resort should the driver enable reception of
all multicast packets to satisfy this request. This method is called
from the workloop context, and only if the driver reports
kIOPacketFilterMulticast support in getPacketFilters().
@param addrs An array of Ethernet addresses. This argument must be
ignored if the count argument is 0.
@param count The number of Ethernet addresses in the list. This value
will be zero when the list becomes empty.
@result Returns kIOReturnUnsupported. Drivers must return kIOReturnSuccess to
indicate success, or an error return code otherwise.
*/
virtual IOReturn setMulticastList(IOEthernetAddress * addrs,
UInt32 count);
/*! @function setPromiscuousMode
@abstract Enables or disables promiscuous mode.
@discussion Called by enablePacketFilter() or disablePacketFilter()
when there is a change in the activation state of the promiscuous
filter identified by kIOPacketFilterPromiscuous. This method is
called from the workloop context.
@param active True to enable promiscuous mode, false to disable it.
@result Returns kIOReturnUnsupported. If overridden, drivers must return
kIOReturnSuccess on success, or an error return code otherwise.
*/
virtual IOReturn setPromiscuousMode(bool active);
/*! @function setWakeOnMagicPacket
@abstract Enables or disables the wake on Magic Packet support.
@discussion Called by enablePacketFilter() or disablePacketFilter()
when there is a change in the activation state of the Wake-on-LAN
filter identified by kIOEthernetWakeOnMagicPacket. This method is
called from the workloop context.
@param active True to enable support for system wake on reception
of a Magic Packet, false to disable it.
@result Returns kIOReturnUnsupported. If overridden, drivers must return
kIOReturnSuccess on success, or an error return code otherwise.
*/
virtual IOReturn setWakeOnMagicPacket(bool active);
protected:
/*! @function createInterface
@abstract Creates an IOEthernetInterface object.
@discussion This method allocates and returns a new IOEthernetInterface instance.
A subclass of IONetworkController must implement this method and return
a matching interface object. The implementation in IOEthernetController
will return an IOEthernetInterface object. Subclasses of
IOEthernetController, such as Ethernet controller drivers, will have
little reason to override this implementation.
@result Returns a newly allocated and initialized IOEthernetInterface object.
*/
virtual IONetworkInterface * createInterface() APPLE_KEXT_OVERRIDE;
/*! @function free
@abstract Frees the IOEthernetController instance.
@discussion This method releases resources, and is
then followed by a call to super::free(). */
virtual void free() APPLE_KEXT_OVERRIDE;
/*! @function publishProperties
@abstract Publishes Ethernet controller properties and capabilities.
@discussion This method publishes Ethernet controller properties to the property
table. For instance, getHardwareAddress() is called to fetch the
hardware address, and the address is then published to the property
table. This method call is synchronized by the workloop's gate,
and must never be called directly by subclasses.
@result Returns true if all properties and capabilities were discovered,
and published successfully, false otherwise. Returning false will
prevent client objects from attaching to the Ethernet controller
since a property that a client relies upon may be missing.
*/
virtual bool publishProperties() APPLE_KEXT_OVERRIDE;
OSMetaClassDeclareReservedUsed( IOEthernetController, 0);
/*! @function getVlanTagDemand
@abstract Fetch the demand for hardware vlan tag stuffing
for the given packet before it is transmitted on the network.
@discussion A network controller that can insert 802.1Q vlan tags for output
packets must call this method to obtain vlan tag information that it must
insert into the given output packet.
@param m A mbuf containing a packet that may require vlan tag stuffing.
@param vlanTag After calling, the low order 16 bits contain the 802.1Q priority and
vlan ID tag in host order. The hi-order 16 bits are currently unused and should be ignored.
@result true if vlanTag has been set and should be used.
false if no vlan tag stuffing is required for this packet. */
virtual bool getVlanTagDemand(mbuf_t m, UInt32 *vlanTag);
OSMetaClassDeclareReservedUsed( IOEthernetController, 1);
/*! @function setVlanTag
@abstract Encode a received packet with the vlan tag result reported
by the hardware.
@discussion A network controller that can strip 802.1Q vlan tag information for a
received packet should call this method to encode the result on the
packet, before passing it up towards the protocol stacks.
@param m A mbuf containing a packet that has had its 802.1q vlan tag stripped by
the hardware.
@param vlanTag A value in host order that contains the 802.1q vlan tag and priority
in the low order 16 bits. The hi order word is currently unused and should be set to 0. */
virtual void setVlanTag(mbuf_t m, UInt32 vlanTag);
public:
/*! @struct IOEthernetControllerAVBSupport
@abstract Group of capabilities for the AVB/TSN support of the driver and hardware.
@discussion Structure containing the AVB/TSN capabilities of the controller.
@field timeSyncSupport The type of time sync timestamping support the driver provides.
@field numberOfRealtimeTransmitQueues The number of hardware queues available for AVB
traffic transmission. These are queues which support launch timestamps.
@field numberOfRealtimeReceiveQueues The number of hardware queues available for AVB
traffic reception. These are dedicated hardware queues with filtering that send
packets into a provided callback rather than the regular network stack
@field realtimeMulticastIsAllowed The transport layer allows for realtime traffic
to be sent multicast. Ethernet networks typically respond as true, WiFi networks as false.
@field packetMapper The IOMapper to be used for mapping the virtual memory used for packets to
the physical address addresses used by the controller. May be NULL to indicate that it can use
physical addresses from anywhere in the address space.
*/
typedef struct
{
IOEthernetControllerAVBTimeSyncSupport timeSyncSupport;
uint32_t numberOfRealtimeTransmitQueues;
uint32_t numberOfRealtimeReceiveQueues;
bool realtimeMulticastIsAllowed;
IOMapper *packetMapper;
} IOEthernetControllerAVBSupport;
/*! @function getAVBSupport
@abstract Indicates that AVB streaming is supported and what capabilities it has.
@discussion
@param avbSupport A pointer to an IOEthernetControllerAVBSupport struct to return the capabilities.
@return True if this controller has at least 1 real time transmit queues or at least 1 realtime receive queues
*/
bool getAVBSupport(IOEthernetControllerAVBSupport *avbSupport) const;
protected:
/*! @function setRealtimeMulticastIsAllowed
@abstract Sets up the realtime multicast allowed in the AVB support information.
@discussion Used by subclasses to set the value returned in the realtimeMulticastIsAllowed
field of the AVB support capabilities. This indicates if the transport allows the realtime
AVB transmit queues to use multicast destination addresses. A transport such as WiFi where
multicast drops to a low transfer rate would typically set this to false. Wired Ethernet
would typically set this to true. The default value of a newly initialized object is true.
@param realtimeMulticastAllowed bool indicating if the transport allows realtime streams to use multicast destination addresses.
*/
void setRealtimeMulticastIsAllowed(bool realtimeMulticastAllowed);
/*! @function setAVBPacketMapper
@abstract Sets up the packet mapper in the AVB support information.
@discussion Used by subclasses to set the value returned in the packetMapper field of the AVB
support capabilities. This is used by the AVB stack to create the memory descriptors used
for transmitting packets by the controller. The packet mapper is retained.
@param packetMapper the IOMapper to be used.
*/
void setAVBPacketMapper(IOMapper *packetMaper);
#pragma mark Interface State
friend IOTimeSyncEthernetInterfaceAdapter;
public:
/*! @function getControllerAVBState
@abstract Get the current AVB state of the controller.
@discussion The controller transitions through a number of AVB states depending on the
services required by the AVB stack. The state transitions are triggered by a call to
changeAVBControllerState() as the AVB stack transitions into and out of using TimeSync
and/or streaming services
@return The AVB state of the controller.
*/
IOEthernetControllerAVBState getControllerAVBState(void) const;
/*! @function changeAVBControllerState
@abstract Change the AVB state of the AVB state of the controller.
@discussion Called by the AVB stack to trigger changing of the controller AVB state machine
based on what services the AVB stack requires.
@param event The event to trigger the state machine change.
@return IOReturn code indicating either success or reason for failure.
*/
IOReturn changeAVBControllerState(IOEthernetControllerAVBStateEvent event);
/*! @typedef avb_state_callback_t
@abstract Callback function for notifying of AVB state changes
@discussion Prototype for the callback function provided to the registerForAVBStateChangeNotifications()
function for calling back to the requestor.
@param context The context pointer that was provided in the call the registerForAVBStateChangeNotifications()
@param newState The new state that the controller is now in.
*/
typedef void (* avb_state_callback_t)(void *context, IOEthernetControllerAVBState oldState, IOEthernetControllerAVBState newState);
//Allow the AVB stack or other interested drivers to register for notifications in the change of AVB state
/*! @function registerForAVBStateChangeNotifications
@abstract Function to register to receive callbacks whenever the AVB state changes.
@discussion This function registers the callback function and context provided by the caller so that
it can be called when the AVB state of the controller changes.
@param callback A pointer to a callback function
@param context A caller specified pointer sized value that is passed back in the callback function.
@return IOReturn code indicating success or a reason for failure.
*/
IOReturn registerForAVBStateChangeNotifications(avb_state_callback_t callback, void *context);
/*! @function deregisterForAVBStateChangeNotifications
@abstract Function to deregister from receiving callbacks whenever the AVB state changes.
@discussion This function deregisters the callback function and context provided by the caller so that
it will stop being called when the AVB state of the controller changes. The provided values must
match what was previously registered with registerForAVBStateChangeNotifications().
@param callback A pointer to a callback function.
@param context A caller specified pointer sized value that is passed back in the callback function.
@return IOReturn code indicating success or a reason for failure.
*/
IOReturn deregisterForAVBStateChangeNotifications(avb_state_callback_t callback, void *context);
protected:
/*! @function setAVBControllerState
@abstract Set the controller to the new AVB state.
@discussion This function is called as part of the changeAVBControllerState() processing and performs
the change to the new state. This function is overriden by subclasses to perform any driver specific
actions (such as enabling or disabling hardware features). Subclasses must call the base implementation
and should be called last.
@param newState The state to which the controller's AVB state machine will be set.
@return IOReturn code indicating success or a reason for failure.
*/
virtual IOReturn setAVBControllerState(IOEthernetControllerAVBState newState);
OSMetaClassDeclareReservedUsed( IOEthernetController, 2);
#pragma mark AVB Packets and Callbacks
public:
#define kMaxIOEthernetReltimeEntries 4
struct IOEthernetAVBPacket;
/*! @typedef avb_packet_callback_t
@abstract Callback function for handling received realtime or TimeSync packets
@discussion Prototype for the callback function provided to the setRealtimeReceiveQueuePacketHandler(),
addTimeSyncReceivePacketHandler() and addTimeSyncTransmitPacketHandler() functions for calling back to the requestor.
@param context The context pointer that was provided in the call the registerForAVBStateChangeNotifications()
@param packet The packet being received or transmitted.
*/
typedef void (* avb_packet_callback_t)(void *context, struct IOEthernetAVBPacket *packet);
/*! @struct IOEthernetAVBPacket
@abstract Structure containing an AVB or TimeSync packet.
@discussion Structure containing the metadata for an AVB or TimeSync packet.
@field structVersion The version of the packet structure. The only defined version is version 0 and this field shall be set to 0.
@field numberOfEntries The number of entries in the virtualRanges and physicalRanges fields that contain
valid addresses and lengths.
@field virtualRanges The kernel virtual addresses of the buffer segments that make up the packet.
@field physicalRanges The physical addresses of the mapped buffer segments that make up the packet.
@field packetTimestamp The timestamp of the packet in mach_absolute_time() based time. For AVB realtime
transmit packets this is the launch time of the packet, for AVB realtime receive packets this is
optionally the ingress time of the packet. For TimeSync packets this is the egress time of transmitted
packets or the ingress time of received packets.
@field timestampValid Indicates if the packetTimestamp field contains a valid value.
@field transmittedTimeSyncCallbackRef For transmited egress time stamped packets the callback reference
returned by calling addTimeSyncTransmitPacketHandler(). This is required when calling transmitTimeSyncPacket().
@field vlanTag The VLAN tag associated with the packet (includes the VLAN ID, Priority Code Point and Drop Eligable Indicator).
This is typically used on receive paths to carry the VLAN tag that was stripped during reception.
@field desc_buffer A field for the allocator to keep track of the buffer for memory management purposes. Use is allocator defined.
@field desc_dma A field for the allocator to keep track of the DMA. Use is allocator defined.
@field completion_context A pointer value for use in the completion callback
@field completion_callback A callback function called by completeAVBPacket() to return the packet to the allocator when use is completed.
*/
typedef struct IOEthernetAVBPacket
{
int structVersion;
int numberOfEntries;
IOVirtualRange virtualRanges[kMaxIOEthernetReltimeEntries];
IOPhysicalRange physicalRanges[kMaxIOEthernetReltimeEntries];
uint64_t packetTimestamp;
bool timestampValid;
uint32_t transmittedTimeSyncCallbackRef;
uint16_t vlanTag;
void *desc_buffer;
void *desc_dma;
void *completion_context;
avb_packet_callback_t completion_callback;
void *reservedAVBStack;
void *reservedFamily;
} IOEthernetAVBPacket;
/*! @function completeAVBPacket
@abstract Call the packet's completion callback to hand the packet back to the allocator of the packet for reuse or destruction.
@discussion The completeAVBPacket function is called to provide the packet back to the allocator (or its delegate function).
This is called by the owner of the IOEthernetAVBPacket when they have finished using it.
@param packet The packet to be returned.
*/
void completeAVBPacket(IOEthernetAVBPacket *packet);
/*! @function allocateAVBPacket
@abstract Allocate a packet from the AVB packet pool.
@discussion Provide a packet from the AVB packet pool. The packet must eventually be returned by a call to completeAVBPacket().
Packets allocated by this call will have one segment (numberOfEntries = 1) with a 2000 byte length. The caller must set the
virtual and physical range lengths to the amount of data actually used for the packet.
@param fromRealtimePool If true pull the packet from the pre-allocated realtime pool, if false then allocate a new packet.
@result The allocated packet. May return NULL if the pool is out of packets.
*/
IOEthernetAVBPacket *allocateAVBPacket(bool fromRealtimePool);
private:
static void allocatedAVBPacketCompletion(void *context, IOEthernetAVBPacket *packet);
void realtimePoolAVBPacketCompletion(IOEthernetAVBPacket *packet);
#pragma mark Realtime Transmit
public:
/*! @function getTransmitQueuePacketLatency
@abstract Get the minimum amount of time required between when transmitRealtimePacket() is called and the launch timestamp.
@discussion Get the packet latency, the minimum amount of time needed between when a packet is given to
transmitRealtimePacket() and the launchTime when it is sent. This includes any prefetch delay (where the NIC fetches
the data at most that amount of time before the launch time) and any descriptor setup time.
@param queueIndex index of the realtime transmit queue.
@return The number of mach_absolute_time ticks.
*/
uint64_t getTransmitQueuePacketLatency(uint32_t queueIndex) const;
/*! @function getTransmitQueuePrefetchDelay
@abstract Get the maximum amount of time required between when NIC will DMA the packet contents and the launch timestamp.
@discussion Get the prefetch delay, the maximum amount of time between when the NIC will DMA the packet contents and
the launchTime when it is sent.
@param queueIndex index of the realtime transmit queue.
@return The number of mach_absolute_time ticks.
*/
uint64_t getTransmitQueuePrefetchDelay(uint32_t queueIndex) const;
/*! @function transmitRealtimePacket
@abstract Transmit an AVB packet on a realtime transmit queue.
@discussion Queues an AVB packet onto one of the controllers realtime transmit queues.
@param queueIndex index of the realtime transmit queue.
@param packets Array of the AVB packets to transmit.
@param packetCount The number of AVB packets in the packets array.
@param commonTimestamp All of the packets in the packets array share the same timestamp and the timestamp from the first packet
should be used for scheduling all of the packets if needed by the hardware.
@param successfulPacketCount The number of packets that were sucessfully added to the transmit queue.
@return IOReturn indicating success or reason for failure.
*/
virtual IOReturn transmitRealtimePackets(uint32_t queueIndex, IOEthernetAVBPacket **packets, uint32_t packetCount, bool commonTimestamp, uint32_t *successfulPacketCount);
OSMetaClassDeclareReservedUsed( IOEthernetController, 3);
//Clean up the realtime transmit queue (free up anything that has already been processed by the NIC)
/*! @function cleanupTransmitQueue
@abstract Cleanup the realtime transmit queue synchronously with AVB adding frames.
@discussion This function performs necessary cleanup of the realtime transmit queue (cleaning through transmit
descriptors) to free up space in the queue without needing to handle an interrupt. This is called from a
realtime (priority 97) thread and care should be taken about use of locks and memory allocation/deallocation.
@param queueIndex index of the realtime transmit queue.
@return IOReturn indicating success or reason for failure.
*/
virtual IOReturn cleanupTransmitQueue(uint32_t queueIndex);
OSMetaClassDeclareReservedUsed( IOEthernetController, 4);
protected:
/*! @function setNumberOfRealtimeTransmitQueues
@abstract Sets up the realtime transmit queue count in the AVB support information.
@discussion Used by subclasses to set the value returned in the numberOfRealtimeTransmitQueues field of the AVB
support capabilities. It also initializes internal data structures to contain enough space for keeping track
of realtime transmit queue information (such as the packet latency).
@param numberOfTransmitQueues The number of transmit queues.
*/
void setNumberOfRealtimeTransmitQueues(uint32_t numberOfTransmitQueues);
/*! @function setTransmitQueuePacketLatency
@abstract Set the value returned by getTransmitQueuePacketLatency() for a given queue.
@discussion Stores the value of the minimum packet latency for a given queue. See getTransmitQueuePacketLatency for more details.
@param queueIndex index of the realtime transmit queue.
@param packetLatency The packet latency for the queue.
*/
void setTransmitQueuePacketLatency(uint32_t queueIndex, uint64_t packetLatency);
/*! @function setTransmitQueuePrefetchDelay
@abstract Set the value returned by getTransmitQueuePrefetchDelay() for a given queue.
@discussion Stores the value of the maximum prefetch delay for a given queue. See getTransmitQueuePrefetchDelay for more details.
@param queueIndex index of the realtime transmit queue.
@param PrefetchDelay The prefetch delay for the queue.
*/
void setTransmitQueuePrefetchDelay(uint32_t queueIndex, uint64_t prefetchDelay);
#pragma mark Realtime Receive
public:
/*! @enum Filter element types
@abstract The type of the filter element described in an IOEthernetAVBIngressFilterElement struct.
@const IOEthernetAVBIngressFilterTypeDestinationMAC Match a specific destination MAC address. Uses the destinationMAC field of the filter union.
@const IOEthernetAVBIngressFilterTypeEtherTypeVLANTag Match a specific EtherType and VLAN Tag (Priority Code Point + VLAN ID). Uses the etherTypeVLANTag field of the filter union.
@const IOEthernetAVBIngressFilterTypeUDPv4Port Match a specific UDPv4 source and/or destination port. Uses the udpPort field of the filter union.
@const IOEthernetAVBIngressFilterTypeUDPv6Port Match a specific UDPv6 source and/or destination port. Uses the udpPort field of the filter union.
@const IOEthernetAVBIngressFilterTypeIPv4Tuple Match a specific IPv4 tuple (source address, destination address, source port, destination port and protocol). Uses the ipv4Tuple field of the filter union.
@const IOEthernetAVBIngressFilterTypeIPv6Tuple Match a specific IPv6 tuple (source address, destination address, source port, destination port and protocol). Uses the ipv6Tuple field of the filter union.
@const IOEthernetAVBIngressFilterTypeMPLSLabel Match a specific MPLS Label. Uses the mplsLabel field of the filter union.
@const IOEthernetAVBIngressFilterTypeByteMatch Match an aribitrary byte range up to 128 bytes long. Uses the byteMatch field of the filter union.
@const IOEthernetAVBIngressFilterTypeCompound Provide an AND of more filter terms (takes each of the sub filters and ANDs together the results). Uses the compound field of the filter union.
*/
typedef enum
{
IOEthernetAVBIngressFilterTypeDestinationMAC,
IOEthernetAVBIngressFilterTypeEtherTypeVLANTag,
IOEthernetAVBIngressFilterTypeUDPv4Port,
IOEthernetAVBIngressFilterTypeUDPv6Port,
IOEthernetAVBIngressFilterTypeIPv4Tuple,
IOEthernetAVBIngressFilterTypeIPv6Tuple,
IOEthernetAVBIngressFilterTypeMPLSLabel,
IOEthernetAVBIngressFilterTypeByteMatch,
IOEthernetAVBIngressFilterTypeCompound,
} IOEthernetAVBIngressFilterType;
/*! @enum Filter IP tuple protocol types
@abstract The protocl that the IPv4 or IPv6 tuple match applies to.
@const IOEthernetAVBIngressFilterProtocolTCP A TCP packet.
@const IOEthernetAVBIngressFilterProtocolUDP A UDP packet.
@const IOEthernetAVBIngressFilterProtocolSCTP An SCTP packet.
@const IOEthernetAVBIngressFilterProtocolICMP An ICMP packet.
*/
typedef enum
{
IOEthernetAVBIngressFilterProtocolTCP,
IOEthernetAVBIngressFilterProtocolUDP,
IOEthernetAVBIngressFilterProtocolSCTP,
IOEthernetAVBIngressFilterProtocolICMP
} IOEthernetAVBIngressFilterProtocol;
/*! @struct IOEthernetAVBRealtimeIngressFilterElement
@abstract One element in realtime receive queue ingress filter used to configure the hardware
to send the packet to the specified receive queue.
@discussion One element in realtime receive queue ingress filter used to configure the hardware
to send the packet to the specified receive queue.
For IOEthernetAVBRealtimeIngressFilterTypeEtherTypeVLANTag the element is applied as
(etherTypeVLANTag.etherType == (packet.etherType & etherTypeVLANTag.etherTypeMask)) && (etherTypeVLANTag.vlanTag == (packet.vlanTag & etherTypeVLANTag.vlanTagMask))
For IOEthernetAVBRealtimeIngressFilterTypeUDPv4Port or IOEthernetAVBRealtimeIngressFilterTypeUDPv6Port the element is applied as
(udpPort.sourcePort == (packet.sourcePort & udpPort.sourcePortMask)) && (udpPort.destinationPort == (packet.destinationPort & udpPort.destinationPortMask))
@field filterType The type of filter being added, defines which member of the union (filter) is used
@field filter The union of all possible filter type fields.
@field destinationMAC The struct containing matching parameters for an IOEthernetAVBIngressFilterTypeDestinationMAC filter element.
@field etherTypeVLANTag The struct containing matching parameters for an IOEthernetAVBIngressFilterTypeEtherTypeVLANTag fiter element.
@field udpPort The struct containing matching parameters for an IOEthernetAVBIngressFilterTypeUDPv4Port or IOEthernetAVBIngressFilterTypeUDPv6Port filter element.
@field ipv4Tuple The struct containing matching parameters for an IOEthernetAVBIngressFilterTypeIPv4Tuple filter element.
@field ipv6Tuple The struct containing matching parameters for an IOEthernetAVBIngressFilterTypeIPv6Tuple filter element.
@field mplsLabel The struct containing matching parameters for an IOEthernetAVBIngressFilterTypeMPLSLabel filter element.
@field byteMatch The struct containing matching parameters for an IOEthernetAVBIngressFilterTypeByteMatch filter element.
@field compound The struct containing matching parameters for an IOEthernetAVBIngressFilterTypeCompound filter element.
@field macAddress The MAC address to match.
@field macAddressMask The mask to apply to the destination MAC address of the packet to compare to the macAddress field.
@field etherType The EtherType to match to send to the queue.
@field etherTypeMask The mask to apply to the EtherType of the packet to compare to the etherType field.
@field vlanTag The VLAN Tag (PCP and VID) to match to send to the queue.
@field vlanTagMask The mask to apply to the VLAN tag of the packet to compare to the vlanTag field.
@field sourcePort The source port to match.
@field sourcePortMask The mask to apply to the source port of the packet to compare to the sourcePort field.
@field destinationPort The destination port to match.
@field destinationPortMask The mask to apply to the destination port of the packet to compare to the destinationPort field.
@field sourceAddress The source address to match.
@field sourceAddressMask The mask to apply to the source address of the packet to compare to the sourceAddress field.
@field destinationAddress The destination address to match.
@field destinationAddressMask The mask to apply to the destination address of the packet to compare to the destinationAddress field.
@field protocol The protocol that the match applies to. See IOEthernetAVBIngressFilterProtocol.
@field label The MPLS label to match
@field labelMask The mask to apply to the MPLS label in the packet to compare to the label field.
@field patternOffset The offset into the packet that the pattern match begins at.
@field patternLength The number of bytes of pattern and pattern mask used in the match (maximum 128).
@field pattern The pattern to match.
@field patternMask The mask to apply to the bytes in the packet to compare to the pattern.
@field elementCount The number of entries in the elements field.
@field elements An array of IOEthernetAVBIngressFilterElement structs for sub filters to be ANDed together to make this filter element. These elements should not have sub elements.
*/
typedef struct IOEthernetAVBIngressFilterElement
{
IOEthernetAVBIngressFilterType filterType;
union
{
struct
{
uint8_t macAddress[kIOEthernetAddressSize];
uint8_t macAddressMask[kIOEthernetAddressSize];
} destinationMAC;
struct
{
uint16_t etherType;
uint16_t etherTypeMask;
uint16_t vlanTag;
uint16_t vlanTagMask;
} etherTypeVLANTag;
struct
{
uint16_t sourcePort;
uint16_t sourcePortMask;
uint16_t destinationPort;
uint16_t destinationPortMask;
} udpPort;
struct
{
uint32_t sourceAddress;
uint32_t sourceAddressMask;
uint32_t destinationAddress;
uint32_t destinationAddressMask;
uint16_t sourcePort;
uint16_t sourcePortMask;
uint16_t destinationPort;
uint16_t destinationPortMask;
uint8_t protocol;
} ipv4Tuple;
struct
{
uint8_t sourceAddress[16];
uint8_t sourceAddressMask[16];
uint8_t destinationAddress[16];
uint8_t destinationAddressMask[16];
uint16_t sourcePort;
uint16_t sourcePortMask;
uint16_t destinationPort;
uint16_t destinationPortMask;
uint8_t protocol;
} ipv6Tuple;
struct
{
uint32_t label;
uint32_t labelMask;
} mplsLabel;
struct
{
uint8_t patternOffset;
uint8_t patternLength;
uint8_t pattern[128];
uint8_t patternMask[128];
} byteMatch;
struct
{
uint32_t elementCount;
struct IOEthernetAVBIngressFilterElement *elements;
} compound;
} filter;
} IOEthernetAVBIngressFilterElement;
//Set the VLAN ID and PCP being used for a receive queue
/*! @function setRealtimeReceiveQueueFilter
@abstract Set the ingress filter being used for a receive queue.
@discussion Sets the ingress filter hardware for directing the appropriate media streaming packets into the receive queue.
Passing an empty array removes any added filters and either resets the queue to a default value or disables the queue.
@param queueIndex index of the realtime receive queue.
@param filterElements the array of IOEthernetAVBIngressFilterElement elements to apply as the ingress filter,
@param filterElementCount the number of elements in the filterElements array.
@return IOReturn indicating success or reason for failure.
*/
virtual IOReturn setRealtimeReceiveQueueFilter(uint32_t queueIndex, IOEthernetAVBIngressFilterElement *filterElements, uint32_t filterElementCount);
OSMetaClassDeclareReservedUsed( IOEthernetInterface, 5);
//Get the VLAN ID and PCP being used for a receive queue
/*! @function getRealtimeReceiveQueueFilter
@abstract Get the ingress filter being used for a receive queue.
@discussion Gets the ingress filter hardware for directing the appropriate media streaming packets into the receive queue.
The caller should call IOFree on any elements array within an IOEthernetAVBIngressFilterTypeCompound element.
@param queueIndex index of the realtime receive queue.
@param filterElements the array of IOEthernetAVBIngressFilterElement elements to apply as the ingress filter,
@param filterElementCount the number of elements in the filterElements array. On entry this is the maximum size of the array.
@return IOReturn indicating success or reason for failure.
*/
virtual IOReturn getRealtimeReceiveQueueFilter(uint32_t queueIndex, IOEthernetAVBIngressFilterElement *filterElements, uint32_t *filterElementCount);
OSMetaClassDeclareReservedUsed( IOEthernetInterface, 6);
/*! @function setRealtimeReceiveQueuePacketHandler
@abstract Set the packet handler callback function for a realtime receive queue.
@discussion Sets the callback function and context to be used to process all of the packets for a realtime receive queue.
Ownership of the packets is handed from the driver to the callback function. The callback function must call completeAVBPacket()
before returning.
@param queueIndex index of the realtime receive queue.
@param callback The callback function pointer.
@param context A caller specified pointer sized value that is passed back in the callback function.
@return IOReturn indicating success or reason for failure.
*/
virtual IOReturn setRealtimeReceiveQueuePacketHandler(uint32_t queueIndex, avb_packet_callback_t callback, void *context);
OSMetaClassDeclareReservedUsed( IOEthernetController, 7);
/*! @function setRealtimeReceiveDestinationMACList
@abstract Set the list of destination MAC addreses used for a realtime receive queue.
@discussion Set the list of destination MAC addresses that are being received on a realtime receive queue. These multicast
addresses are *not* included in the list supplied to the setMulticastList call.
@param queueIndex index of the realtime receive queue.
@param addresses An array of ethernet destination MAC addresses. This shall be ignored if addressCount is 0.
@param addressCount The number of elements in the addresses array.
@return IOReturn indicating success or reason for failure.
*/
virtual IOReturn setRealtimeReceiveDestinationMACList(uint32_t queueIndex, IOEthernetAddress *addresses, int addressCount);
OSMetaClassDeclareReservedUsed( IOEthernetController, 8);
protected:
/*! @function setNumberOfRealtimeReceiveQueues
@abstract Sets up the realtime receive queue count in the AVB support information.
@discussion Used by subclasses to set the value returned in the numberOfRealtimeReceiveQueues field of the AVB
support capabilities. It also initializes internal data structures to contain enough space for keeping track
of realtime receive queue information (such as the callbacks).
@param numberOfReceiveQueues The number of receive queues.
*/
void setNumberOfRealtimeReceiveQueues(uint32_t numberOfReceiveQueues);
#pragma mark Time Sync
public:
/*! @function addTimeSyncReceivePacketHandler
@abstract Add a callback function to the list of Time Sync receive callbacks.
@discussion Add a callback function to the set of callbacks that are called for every received time sync packet.
Ownership of the packet is not handed to the callback function. The callback function must not call completeAVBPacket().
@param callback The function to be called upon receiving a Time Sync packet in the dedicated time sync receive queue.
@param context A caller specified pointer sized value that is passed back in the callback function.
@return IOReturn indicating success or reason for failure.
*/
IOReturn addTimeSyncReceivePacketHandler(avb_packet_callback_t callback, void *context);
/*! @function removeTimeSyncReceivePacketHandler
@abstract Remove a previously added callback.
@discussion Remove a callback function that was previously added with addTimeSyncReceivePacketHandler().
@param callback The function previously added.
@param context A caller specified pointer sized value that is passed back in the callback function.
@return IOReturn indicating success or reason for failure.
*/
IOReturn removeTimeSyncReceivePacketHandler(avb_packet_callback_t callback, void *context);
//Set the callback for transmitted time sync packets (those that require egress timestamping)
/*! @function addTimeSyncTransmitPacketHandler
@abstract Add a callback function to be called after transmitting an egress timestamped Time Sync packet.
@discussion Add a callback function to the list and assigns a reference to it for tracking the callback to be used
for returning the egress timestamp to the caller. Ownership of the packet is not handed to the callback function.
The callback function must not call completeAVBPacket().
@param callback The function to be called upon transmitting a Time Sync packet and obtaining it's egress timestamp.
@param context A caller specified pointer sized value that is passed back in the callback function.
@param callbackRef A pointer to a uint32_t that is allocated to the callback for use in the packets passed
to the transmitTimeSyncPacket so that the callback will be called.
@return IOReturn indicating success or reason for failure.
*/
IOReturn addTimeSyncTransmitPacketHandler(avb_packet_callback_t callback, void *context, uint32_t *callbackRef);
/*! @function removeTimeSyncTransmitPacketHandler
@abstract Remove a callback function previously added with addTimeSyncTransmitPacketHandler()
@discussion Remove a transmit packet handler previously added with addTimeSyncTransmitPacketHandler().
@param callbackRef The callback reference returned by the call to addTimeSyncTransmitPacketHandler().
@return IOReturn indicating success or reason for failure.
*/
IOReturn removeTimeSyncTransmitPacketHandler(uint32_t callbackRef);
/*! @function transmitTimeSyncPacket
@abstract Transmit a time sync packet and capture it's egress timestamp.
@discussion Transmit a time sync packet which requires egress timestamping, after the egress timestamp is available
the transmit packet handler is called, passing this packet. If expiryTime (in mach_absolute_time) is reached
before the packet is transmitted it is aborted the packet callback called with the packet containing no valid timestamp.
@param packet The packet to be transmitted.
@param expiryTime The time at which the packet no longer needs to be transmitted if it hasn't already been transmitted.
@return IOReturn indicating success or reason for failure.
*/
virtual IOReturn transmitTimeSyncPacket(IOEthernetAVBPacket * packet, uint64_t expiryTime);
OSMetaClassDeclareReservedUsed( IOEthernetController, 9);
protected:
/*! @function setGPTPPresent
@abstract Set the gPTP present flag on the controller and trigger the AVB stack loading.
@discussion Sets the gPTPPresent property on the controller and interface. If setting gPTPPresent to true it calls
registerService() to trigger matching and loading of the AVB stack on demand, otherwise it calls messageClients
to trigger the stack to unload.
@param gPTPPresent
@return IOReturn indicating success or reason for failure.
*/
IOReturn setGPTPPresent(bool gPTPPresent);
protected:
/*! @function receivedTimeSyncPacket
@abstract Send the received time sync packet to the callback functions.
@discussion This function is called by subclasses when they have received a Time Sync packet to send it to all of the
registered callback functions.
@param packet The received time sync packet.
*/
void receivedTimeSyncPacket(IOEthernetAVBPacket *packet);
/*! @function transmittedTimeSyncPacket
@abstract Send the transmitted time sync packet to the transmit callback.
@discussion This function is called by subclasses when they have transmitted an egress timestamped packet and have the
egress timestamp or when they have expired the packet.
@param packet The transmitted time sync packet
@param expired A bool indicating if the call is due to the packet being expired.
*/
void transmittedTimeSyncPacket(IOEthernetAVBPacket *packet, bool expired);
/*! @function setTimeSyncPacketSupport
@abstract Sets up the time sync support in the AVB support information
@discussion Used by subclasses to set the value returned in the timeSyncSupport field of the AVB support caoabilities.
@param timeSyncPacketSupport The support that the controller has for timestamping.
*/
void setTimeSyncPacketSupport(IOEthernetControllerAVBTimeSyncSupport timeSyncPacketSupport);
private:
static void timeSyncCallbackThreadEntry(void *param, wait_result_t waitResult);
void timeSyncCallbackThread(void);
// Virtual function padding
OSMetaClassDeclareReservedUnused( IOEthernetController, 10);
OSMetaClassDeclareReservedUnused( IOEthernetController, 11);
OSMetaClassDeclareReservedUnused( IOEthernetController, 12);
OSMetaClassDeclareReservedUnused( IOEthernetController, 13);
OSMetaClassDeclareReservedUnused( IOEthernetController, 14);
OSMetaClassDeclareReservedUnused( IOEthernetController, 15);
OSMetaClassDeclareReservedUnused( IOEthernetController, 16);
OSMetaClassDeclareReservedUnused( IOEthernetController, 17);
OSMetaClassDeclareReservedUnused( IOEthernetController, 18);
OSMetaClassDeclareReservedUnused( IOEthernetController, 19);
OSMetaClassDeclareReservedUnused( IOEthernetController, 20);
OSMetaClassDeclareReservedUnused( IOEthernetController, 21);
OSMetaClassDeclareReservedUnused( IOEthernetController, 22);
OSMetaClassDeclareReservedUnused( IOEthernetController, 23);
OSMetaClassDeclareReservedUnused( IOEthernetController, 24);
OSMetaClassDeclareReservedUnused( IOEthernetController, 25);
OSMetaClassDeclareReservedUnused( IOEthernetController, 26);
OSMetaClassDeclareReservedUnused( IOEthernetController, 27);
OSMetaClassDeclareReservedUnused( IOEthernetController, 28);
OSMetaClassDeclareReservedUnused( IOEthernetController, 29);
OSMetaClassDeclareReservedUnused( IOEthernetController, 30);
OSMetaClassDeclareReservedUnused( IOEthernetController, 31);
};
/*
* FIXME: remove this.
*/
enum {
kIOEnetPromiscuousModeOff = false,
kIOEnetPromiscuousModeOn = true,
kIOEnetPromiscuousModeAll = true,
kIOEnetMulticastModeOff = false,
kIOEnetMulticastModeFilter = true
};
typedef bool IOEnetPromiscuousMode;
typedef bool IOEnetMulticastMode;
#endif /* __cplusplus */
#endif /* KERNEL */
#endif /* !_IOETHERNETCONTROLLER_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/network/IOOutputQueue.h | /*
* Copyright (c) 1998-2008 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* The contents of this file constitute Original Code as defined in and
* are subject to the Apple Public Source License Version 1.1 (the
* "License"). You may not use this file except in compliance with the
* License. Please obtain a copy of the License at
* http://www.apple.com/publicsource and read it before using this file.
*
* This Original Code and all software distributed under the License are
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _IOOUTPUTQUEUE_H
#define _IOOUTPUTQUEUE_H
#include <IOKit/network/IONetworkInterface.h>
// Forward declarations.
//
struct mbuf;
class IONetworkData;
// FIXME - We do not want the enqueue/dequeue macros defined in queue.h.
//
#undef enqueue
#undef dequeue
// FIXME - Belongs in IOBasicOutputQueue.h
//
/*! @enum OutputPacketStatus
@abstract The status of the packet sent to the target.
@constant kIOOutputStatusMask Define the status field in the return code.
@constant kIOOutputStatusAccept Packet was accepted by the target.
@constant kIOOutputStatusDropped Packet accepted, but was also dropped.
@constant kIOOutputStatusRetry Target ran out of resources, and is unable
to accept the packet. The ownership of the packet reverts back to the
queue.
*/
enum {
kIOOutputStatusMask = 0x00ff,
kIOOutputStatusAccepted = 0x0000,
kIOOutputStatusDropped = 0x0001,
kIOOutputStatusRetry = 0x0002
};
/*! @enum OutputCommands
@abstract A command requested by the target.
@constant kIOOutputCommandMask Define the command field in the return code.
@constant kIOOutputCommandNone No command.
@constant kIOOutputCommandStall A command to stall the queue.
*/
enum {
kIOOutputCommandMask = 0xff00,
kIOOutputCommandNone = 0x0000,
kIOOutputCommandStall = 0x0100
};
/*! @enum OutputHandlerReturnCodes
@abstract Common return codes returned by the target's output handler.
@constant kIOReturnOutputSuccess Packet was accepted.
@constant kIOReturnOutputDropped Packet was dropped.
@constant kIOReturnOutputStall Stall the queue and retry the same packet
when the queue is restarted.
*/
enum {
kIOReturnOutputSuccess = (kIOOutputStatusAccepted | kIOOutputCommandNone),
kIOReturnOutputDropped = (kIOOutputStatusDropped | kIOOutputCommandNone),
kIOReturnOutputStall = (kIOOutputStatusRetry | kIOOutputCommandStall)
};
/*! @class IOOutputQueue
@abstract A packet queue that supports multiple producers and a single
consumer.
@discussion Each producer, or a client thread, will deliver a chain of packets
to the queue. A single consumer will remove packets from the queue one at a
time and forward it to the registered target/action. This object may be used
by an IONetworkController on the output (transmit) side to handle the output
packet flow downstream from an IONetworkInterface, and then call the driver's
output function. IOOutputQueue is an abstract class that provides an interface
for its subclasses. Concrete subclasses will complete the implementation, and
specify the context that the target is called for packets removed from
the queue.
*/
class __exported IOOutputQueue : public OSObject
{
OSDeclareAbstractStructors( IOOutputQueue )
private:
static void runServiceThread(thread_call_param_t, thread_call_param_t);
protected:
thread_call_t _callEntry; // callout entry structure.
struct ExpansionData { };
/*! @var reserved
Reserved for future use. (Internal use only) */
ExpansionData *_reserved;
/*! @function init
@abstract Initializes an IOOutputQueue object.
@result Returns true if initialized successfully, false otherwise.
*/
virtual bool init() APPLE_KEXT_OVERRIDE;
/*! @function free
@abstract Frees the IOOutputQueue object.
@discussion Release allocated resources, then call super::free().
*/
virtual void free() APPLE_KEXT_OVERRIDE;
/*! @function scheduleServiceThread
@abstract Schedules a service thread callout.
@discussion This method can be called by service() to schedule
a thread that will call serviceThread() when it starts running.
@param param A parameter to pass to the serviceThread() method.
@result Returns true if a thread callout was scheduled, false otherwise.
*/
virtual bool scheduleServiceThread(void * param = 0);
/*! @function cancelServiceThread
@abstract Cancels any pending service thread callout.
@result Returns true if a previously scheduled thread callout was canceled,
false otherwise.
*/
virtual bool cancelServiceThread();
/*! @function serviceThread
@abstract Method called by the scheduled service thread when it
starts to run.
@discussion Must be implemented by a subclass that calls
scheduleServiceThread(). The default implementation does nothing.
@param param A parameter that was given to scheduleServiceThread()
when the service thread was scheduled.
*/
virtual void serviceThread(void * param);
public:
/*! @function start
@abstract Starts up the queue.
@discussion This method is called by the target to start the queue. This will allow
packets to be removed from the queue, then delivered to the target.
@result Returns true if the queue was started successfully, false otherwise.
*/
virtual bool start() = 0;
/*! @function stop
@abstract Stops the queue.
@discussion Stop the queue and prevent it from sending packets to its
target.
@result Returns the previous running state of the queue,
true if the queue was running, false if the queue was already stopped.
*/
virtual bool stop() = 0;
/*! @function service
@abstract Services the queue.
@discussion Manage the queue after it has been started.
@param options Options for the service request.
@result Returns a return value to indicate the service result.
*/
virtual bool service(IOOptionBits options = 0) = 0;
/*! @function flush
@abstract Drops and frees all packets currently held by the queue.
@result Returns the number of packets that were dropped and freed.
*/
virtual UInt32 flush() = 0;
/*! @function setCapacity
@abstract Changes the number of packets that the queue can hold
before it begins to drop excess packets.
@param capacity The new desired capacity.
@result Returns true if the new capacity was accepted, false otherwise.
*/
virtual bool setCapacity(UInt32 capacity) = 0;
/*! @function getCapacity
@abstract Gets the number of packets that the queue can hold.
@discussion The queue will begin to drop incoming packets when the
size of queue reaches its capacity.
@result Returns the current queue capacity.
*/
virtual UInt32 getCapacity() const = 0;
/*! @function getSize
@abstract Gets the number of packets currently held in the queue.
@result Returns the size of the queue.
*/
virtual UInt32 getSize() const = 0;
/*! @function enqueue
@abstract Adds a packet, or a chain of packets, to the queue.
@discussion This method is called by a client to add a packet, or a chain of packets,
to the queue. A packet is described by an mbuf chain, while a chain
of packets is constructed by linking multiple mbuf chains via the
m_nextpkt field.
@param m A single packet, or a chain of packets.
@param param A parameter provided by the caller.
@result Returns a return code.
*/
virtual UInt32 enqueue(mbuf_t m, void * param) = 0;
/*! @function getOutputHandler
@abstract Returns the address of a function that is designated to handle
incoming packets sent to the queue object.
@result Returns the address of the enqueue() method.
*/
virtual IOOutputAction getOutputHandler() const;
/*! @function getStatisticsData
@abstract Returns an IONetworkData object containing statistics counters
updated by the queue.
@result Returns an IONetworkData object. This implementation will always return
0.
*/
virtual IONetworkData * getStatisticsData() const;
/*! @function getMbufPriority
@abstract Determines an mbuf's traffic priority. The highest priority is 0.
@discussion A queue can prioritize certain classes of traffic. This method
facilitates that by evaluating an mbuf and returning its priority.
@param m An mbuf to analyze.
@result Returns a UInt32 representing the priority of the packet. 0 is the highest priority.
*/
OSMetaClassDeclareReservedUsed( IOOutputQueue, 0);
virtual UInt32 getMbufPriority(mbuf_t m);
// Virtual function padding
OSMetaClassDeclareReservedUnused( IOOutputQueue, 1);
OSMetaClassDeclareReservedUnused( IOOutputQueue, 2);
OSMetaClassDeclareReservedUnused( IOOutputQueue, 3);
OSMetaClassDeclareReservedUnused( IOOutputQueue, 4);
OSMetaClassDeclareReservedUnused( IOOutputQueue, 5);
OSMetaClassDeclareReservedUnused( IOOutputQueue, 6);
OSMetaClassDeclareReservedUnused( IOOutputQueue, 7);
OSMetaClassDeclareReservedUnused( IOOutputQueue, 8);
OSMetaClassDeclareReservedUnused( IOOutputQueue, 9);
OSMetaClassDeclareReservedUnused( IOOutputQueue, 10);
OSMetaClassDeclareReservedUnused( IOOutputQueue, 11);
OSMetaClassDeclareReservedUnused( IOOutputQueue, 12);
OSMetaClassDeclareReservedUnused( IOOutputQueue, 13);
OSMetaClassDeclareReservedUnused( IOOutputQueue, 14);
OSMetaClassDeclareReservedUnused( IOOutputQueue, 15);
};
#endif /* !_IOOUTPUTQUEUE_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/network/IONetworkInterface.h | /*
* Copyright (c) 1998-2008 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* The contents of this file constitute Original Code as defined in and
* are subject to the Apple Public Source License Version 1.1 (the
* "License"). You may not use this file except in compliance with the
* License. Please obtain a copy of the License at
* http://www.apple.com/publicsource and read it before using this file.
*
* This Original Code and all software distributed under the License are
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _IONETWORKINTERFACE_H
#define _IONETWORKINTERFACE_H
/*! @defined kIONetworkInterfaceClass
@abstract The name of the IONetworkInterface class.
*/
#define kIONetworkInterfaceClass "IONetworkInterface"
/*! @defined kIONetworkData
@abstract A property of IONetworkInterface objects.
@discussion The kIONetworkData property has an OSDictionary value and is a
container for the set of IONetworkData objects managed by the interface.
Each entry in the dictionary is a key/value pair consisting of
the network data name, and an OSDictionary describing the
contents of the network data.
*/
#define kIONetworkData "IONetworkData"
/*! @defined kIOInterfaceType
@abstract A property of IONetworkInterface objects.
@discussion The kIOInterfaceType property has an OSNumber value that
specifies the type of network interface that this interface represents.
The type constants are defined in bsd/net/if_types.h.
*/
#define kIOInterfaceType "IOInterfaceType"
/*! @defined kIOMaxTransferUnit
@abstract A property of IONetworkInterface objects.
@discussion The kIOMaxTransferUnit property has an OSNumber value that
specifies the maximum transfer unit for the interface in bytes.
*/
#define kIOMaxTransferUnit "IOMaxTransferUnit"
/*! @defined kIOMediaAddressLength
@abstract A property of IONetworkInterface objects.
@discussion The kIOMediaAddressLength property has an OSNumber value that
specifies the size of the media address in bytes.
*/
#define kIOMediaAddressLength "IOMediaAddressLength"
/*! @defined kIOMediaHeaderLength
@abstract A property of IONetworkInterface objects.
@discussion The kIOMediaHeaderLength property has an OSNumber value that
specifies the size of the media header in bytes.
*/
#define kIOMediaHeaderLength "IOMediaHeaderLength"
/*! @defined kIOInterfaceFlags
@abstract A property of IONetworkInterface objects.
@discussion The kIOInterfaceFlags property has an OSNumber value that
specifies the current value of the interface flags. The flag constants
are defined in bsd/net/if.h.
*/
#define kIOInterfaceFlags "IOInterfaceFlags"
/*! @defined kIOInterfaceExtraFlags
@abstract A property of IONetworkInterface objects.
@discussion The kIOInterfaceExtraFlags property has an OSNumber value that
specifies the current value of the interface eflags. The eflag constants
are defined in bsd/net/if.h.
*/
#define kIOInterfaceExtraFlags "IOInterfaceExtraFlags"
/*! @defined kIOInterfaceUnit
@abstract A property of IONetworkInterface objects.
@discussion The kIOInterfaceUnit property has an OSNumber value that
describes the unit number assigned to the interface object.
*/
#define kIOInterfaceUnit "IOInterfaceUnit"
/*! @defined kIOInterfaceState
@abstract A property of IONetworkInterface objects.
@discussion The kIOInterfaceState property has an OSNumber value that
describes the current state of the interface object. This property is
not exported to BSD via the ifnet structure.
*/
#define kIOInterfaceState "IOInterfaceState"
/*! @defined kIOInterfaceNamePrefix
@abstract A property of IONetworkInterface objects.
@discussion The kIOInterfaceNamePrefix property has an OSString value that
describes the string prefix for the BSD name assigned to the interface.
*/
#define kIOInterfaceNamePrefix "IOInterfaceNamePrefix"
/*! @defined kIOPrimaryInterface
@abstract A property of IONetworkInterface objects.
@discussion The kIOInterfaceNamePrefix property has an OSBoolean value that
describes whether the interface is the primary or the built-in network
interface.
*/
#define kIOPrimaryInterface "IOPrimaryInterface"
/*! @defined kIOBuiltin
@abstract kIOBuiltin is a property of IONetworkInterface
objects. It has an OSBoolean value.
@discussion The kIOBuiltin property describes whether the
interface is built-in.
*/
#define kIOBuiltin "IOBuiltin"
/*! @defined kIOLocation
@abstract kIOLocation is a property of IONetworkInterface
objects. It has an OSString value.
@discussion The kIOLocation property describes the physical
location of built-in interfaces.
*/
#define kIOLocation "IOLocation"
/*! @defined kIONetworkNoBSDAttachKey
@abstract kIONetworkNoBSDAttachKey is a property of IONetworkInterface
objects. It has an OSBoolean value.
@discussion Adding a property with this key and the value kOSBooleanTrue
before the interface is published will hold off the BSD attach.
When the interface is ready to attach to BSD, remove the property
and then re-publish the interface by calling registerService().
*/
#define kIONetworkNoBSDAttachKey "IONetworkNoBSDAttach"
/*! @enum InterfaceObjectStates
@discussion Constants used to encode the state of the interface object.
@constant kIONetworkInterfaceRegisteredState The interface object has
registered with the data link layer.
@constant kIONetworkInterfaceOpenedState One or more clients have an
open on the interface object.
@constant kIONetworkInterfaceDisabledState The interface is temporarily
unable to service its clients. This will occur when the network
controller that is servicing the interface has entered a low power
state that renders it unusable.
*/
enum {
kIONetworkInterfaceRegisteredState = 0x1,
kIONetworkInterfaceOpenedState = 0x2,
kIONetworkInterfaceDisabledState = 0x4
};
#ifdef KERNEL
#ifdef __cplusplus
#include <IOKit/IOService.h>
#include <IOKit/network/IONetworkData.h>
#include <IOKit/network/IONetworkStats.h>
#include <IOKit/network/IONetworkMedium.h>
#include <net/kpi_interface.h>
class IONetworkController;
class IONetworkStack;
class IOCommandGate;
struct IOMbufQueue;
/*! @typedef IOOutputAction
@discussion Prototype for an output packet handler that will process
all outbound packets sent to the interface from the data link layer.
An output handler is registered with the interface by calling
registerOutputHandler().
@param mbuf_t A packet mbuf.
@param param A parameter for the output request. */
typedef UInt32 (OSObject::*IOOutputAction)(mbuf_t, void * param);
/*! @typedef BPF_FUNC
@discussion Prototype for the BPF tap handler. This will disappear
when the correct DLIL header file is included. */
typedef int (*BPF_FUNC)(struct ifnet *, struct mbuf *);
// Network event types recognized by inputEvent().
//
enum {
/* DLIL defined event, argument must be a pointer to a
kern_event_msg structure. */
kIONetworkEventTypeDLIL = 0xff000001,
/* Link up event, no argument */
kIONetworkEventTypeLinkUp = 0xff000002,
/* Link down event, no argument */
kIONetworkEventTypeLinkDown = 0xff000003,
/* Wake on LAN support changed, no argument */
kIONetworkEventWakeOnLANSupportChanged = 0xff000004,
/* Link speed changed */
kIONetworkEventTypeLinkSpeedChange = 0xff000005
};
/*! @class IONetworkInterface
@abstract Abstract class that manages the connection between an
IONetworkController and the data link interface layer.
@discussion An IONetworkInterface object manages the connection between
an IONetworkController and the data link interface layer (DLIL).
All interactions between the controller and DLIL must go through an
interface object. Any data structures that are required by DLIL for a
particular interface type shall be allocated and mantained by the
interface object. IONetworkInterface is an abstract class that must be
extended by a concrete subclass to specialize for a particular network
type.
Although most drivers will allocate a single interface object,
it is possible for multiple interfaces to be attached to a single
controller. This controller driver will be responsible for arbitrating
access among its multiple interface clients.
IONetworkInterface also maintains a dictionary of IONetworkData
objects containing statistics structures. Controller drivers can
ask for a particular data object by name and update the
statistics counters within directly. This dictionary is added to
the interface's property table and is visible outside of the kernel.
*/
class __exported IONetworkInterface : public IOService
{
OSDeclareAbstractStructors( IONetworkInterface )
friend class IONetworkStack;
private:
IONetworkController * _driver;
ifnet_t _backingIfnet;
IOLock * _privateLock;
OSSet * _clientSet;
OSNumber * _stateBits;
bpf_packet_func _inputFilterFunc;
bpf_packet_func _outputFilterFunc;
OSObject * _outTarget;
IOOutputAction _outAction;
UInt32 _clientVar[4];
OSDictionary * _dataDict;
IOMbufQueue * _inputPushQueue;
void * _unused1;
UInt32 _unused2;
struct ExpansionData {
int unit;
int type;
int mtu;
int flags;
int eflags;
int addrlen;
int hdrlen;
int32_t loggingLevel;
uint32_t outputQueueModel;
IONetworkStats driverStats;
IONetworkStats lastDriverStats;
ifnet_stat_increment_param inputDeltas;
IORecursiveLock * publicLock;
char * remote_NMI_pattern;
unsigned int remote_NMI_len;
IONetworkController * controller;
uint32_t configFlags;
uint32_t txRingSize;
uint32_t txPullOptions;
uint32_t txQueueSize;
uint32_t txSchedulingModel;
uint32_t txTargetQdelay;
uint32_t txThreadState;
volatile UInt32 txThreadFlags;
uint32_t txThreadSignal;
uint32_t txThreadSignalLast;
thread_t txStartThread;
void * txStartAction;
IOWorkLoop * txWorkLoop;
uint32_t rxRingSize;
uint32_t rxPollOptions;
uint32_t rxPollModel;
void * rxPollAction;
void * rxCtlAction;
uint64_t rxPollEmpty;
uint64_t rxPollTotal;
uint16_t txStartDelayQueueLength; /* optional */
uint16_t txStartDelayTimeout; /* optional */
IOOptionBits clientBehavior;
thread_call_t inputEventThreadCall; // inputEvent() thread call
};
ExpansionData * _reserved;
bool _syncNetworkDataDict();
SInt32 syncSIOCSIFMEDIA(IONetworkController * ctr, struct ifreq * ifr);
SInt32 syncSIOCGIFMEDIA(IONetworkController * ctr, struct ifreq * ifr,
unsigned long cmd);
SInt32 syncSIOCSIFMTU(IONetworkController * ctr, struct ifreq * ifr);
void drainOutputQueue(ifnet_t ifp, IONetworkController * driver);
IOReturn haltOutputThread(uint32_t stateBit);
void pushInputQueue( IOMbufQueue * queue );
void pushInputPacket( mbuf_t packet, uint32_t length );
int if_start_precheck( ifnet_t ifp );
static int performGatedCommand(void *, void *, void *, void *, void *);
static void powerChangeHandler(void *, void *, void *);
static errno_t if_ioctl(ifnet_t ifp, unsigned long cmd, void * data);
static int if_output(ifnet_t ifp, mbuf_t);
static errno_t if_set_bpf_tap(ifnet_t ifp, bpf_tap_mode, bpf_packet_func);
static void if_detach(ifnet_t ifp);
static void if_start(ifnet_t ifp);
static void if_start_gated(ifnet_t ifp);
static void if_input_poll(ifnet_t ifp, uint32_t flags,
uint32_t max_count,
mbuf_t * first_packet, mbuf_t * last_packet,
uint32_t * cnt, uint32_t * len);
static void if_input_poll_gated(ifnet_t ifp, uint32_t flags,
uint32_t max_count,
mbuf_t * first_packet, mbuf_t * last_packet,
uint32_t * cnt, uint32_t * len);
void notifyDriver( uint32_t type, void * data );
static void handleNetworkInputEvent(thread_call_param_t param0, thread_call_param_t param1);
public:
/*! @function isPrimaryInterface
@abstract Queries whether the interface is the primary network interface
on the system.
@discussion The definition of a primary interface and its discovery is
platform specific.
@result Returns true if the interface is the primary interface,
false otherwise.
*/
virtual bool isPrimaryInterface( void ) const;
/*! @function init
@abstract Initializes the <code>IONetworkInterface</code> object.
@discussion Resources are allocated, but an <code>ifnet_t</code> will not
be allocated until the interface is assigned a BSD name and attached to the
network stack.
@param controller A network controller object that will service the
the interface.
@result Returns true on success, false otherwise.
*/
virtual bool init( IONetworkController * controller );
/*! @function isRegistered
@abstract Queries if the interface has attached to the BSD network stack.
@discussion Once attached a <code>kIOBSDNameKey</code> property is added
to the interface object with the assigned BSD name.
@result Returns true if interface is registered and attached to the network
stack, false otherwise.
*/
virtual bool isRegistered( void ) const;
/*! @function getInterfaceState
@abstract Reports the current state of the interface object.
@result Returns the current interface state flags.
*/
virtual UInt32 getInterfaceState( void ) const;
/*! @function getController
@abstract Gets the <code>IONetworkController</code> object that created
this interface.
@discussion The controller object passed to init() will be retained until
the interface closes the controller. Subclasses can safely call this method
before the controller is closed.
@result Returns the parent <code>IONetworkController</code> object.
*/
virtual IONetworkController * getController( void ) const;
/*! @function inputPacket
@abstract For drivers to submit a received packet to the network stack.
@discussion The packet provided to this method may be added to an input
queue managed by the interface object, which the driver can use to postpone
the packet handoff to the network stack, until all received packets have been
added to the input queue. A subsequent call to <code>flushInputQueue()</code>,
will transfer the entire contents of the input queue to the network stack.
This input queue is not protected by a lock. Drivers that leverage this
input queue must either access the queue from a single thread, or enforce
serialized access.
@param mbuf_t The mbuf containing the received packet.
@param length Specify the size of the received packet in the mbuf.
The mbuf length fields are updated with this value. If zero, then the mbuf
length fields are not updated.
@param options Pass <code>kInputOptionQueuePacket</code> to enqueue the
input packet. Pass zero to bypass the input queue, and immediately submit
the packet to the network stack.
@param param A parameter provided by the driver. Not used.
@result Returns the number of packets that were submitted to the network
stack, or zero if the packet was enqueued.
*/
virtual UInt32 inputPacket(
mbuf_t packet,
UInt32 length = 0,
IOOptionBits options = 0,
void * param = 0 );
/*! @enum InputOptionQueuePacket
@discussion Options for <code>inputPacket()</code>.
@constant kInputOptionQueuePacket Enqueue the input packet provided to the
input packet queue. Calls to <code>inputPacket()</code> must be serialized.
*/
enum {
kInputOptionQueuePacket = 0x1
};
/*! @function flushInputQueue
@abstract Submit all packets held in the input queue to the network stack.
@discussion Allow drivers to remove all packets from the input queue and
submit them to the network stack. This method should be used in concert
with the <code>inputPacket()</code> method, to flush the input queue after
queueing a number of received packets.
@result Returns the number of packets that were submitted to the network
stack. Returns zero if the queue was empty.
*/
virtual UInt32 flushInputQueue( void );
/*! @function clearInputQueue
@abstract Discards all packets in the input queue.
@discussion This method removes all packets from the input queue and
releases them back to the free mbuf pool. It is unusual for a driver to
call this method.
@result Returns the number of packets freed.
*/
virtual UInt32 clearInputQueue( void );
/*! @function inputEvent
@abstract Sends an event to the network stack.
@discussion This method can be used by the driver to send an event to the
network stack.
@param type A constant describing the event type.
@param data An optional data associated with the event.
@result Returns true if the event was delivered, false if the event type
specified is invalid, or if the event delivery failed.
*/
virtual bool inputEvent( UInt32 type, void * data );
/*! @function registerOutputHandler
@abstract Registers a target/action to handle outbound packets.
@discussion The interface object will forward all output packets sent from
the network stack to the target and action registered using this method.
The registration must occur before the interface is registered and opened
by <code>IONetworkStack</code>, otherwise the default handler will be used.
The default target and action is set by <code>init()</code> as the
controller, and the handler returned by the controller's
<code>getOutputHandler()</code> method.
@param target Object that implements the output handler.
@param action The function that will handle output packets.
@result Returns true if the target/action provided was accepted,
false otherwise.
*/
virtual bool registerOutputHandler(
OSObject * target,
IOOutputAction action );
/*! @function getNamePrefix
@abstract Returns the BSD name prefix as a C-string.
@discussion The BSD name for each interface object is generated by
concatenating the string returned by this method, along with an unit number
assigned by <code>IONetworkStack</code>. A concrete interface subclass must
implement this method and return a distinct name prefix for its instances.
@result Returns a pointer to a constant C-string.
*/
virtual const char * getNamePrefix() const = 0;
/*! @function getInterfaceType
@abstract Gets the interface type.
@discussion This method returns the interface type previously set by
<code>setInterfaceType</code>.
@result Returns a constant defined in <code>bsd/net/if_types.h</code>
that describes the interface type.
*/
virtual UInt8 getInterfaceType( void ) const;
/*! @function getMaxTransferUnit
@abstract Gets the maximum transfer unit for this interface.
@discussion This method calls <code>ifnet_mtu</code> and returns the
maximum transfer unit.
@result Returns the interface MTU size in bytes.
*/
virtual UInt32 getMaxTransferUnit( void ) const;
/*! @function getFlags
@abstract Gets the current interface flags.
@discussion This method calls <code>ifnet_flags</code> and returns the
current interface flags.
@result Returns the interface flags.
*/
virtual UInt16 getFlags( void ) const;
/*! @function getExtraFlags
@abstract Gets the current interface eflags.
@discussion This method calls <code>ifnet_eflags</code> and returns the
current interface eflags.
@result Returns the value of the interface eflags.
*/
virtual UInt32 getExtraFlags( void ) const;
/*! @function getMediaAddressLength
@abstract Gets the size of the media (MAC-layer) address.
@discussion This method calls <code>ifnet_addrlen</code> and returns the
media address length.
@result Returns the size of the media address in bytes.
*/
virtual UInt8 getMediaAddressLength( void ) const;
/*! @function getMediaHeaderLength
@abstract Gets the size of the media header.
@discussion This method calls <code>ifnet_hdrlen</code> and returns the
media header length.
@result Returns the size of the media header in bytes.
*/
virtual UInt8 getMediaHeaderLength( void ) const;
/*! @function getUnitNumber
@abstract Gets the unit number assigned to this interface object.
@discussion This method calls <code>ifnet_unit</code> and returns the
unit number assigned by <code>IONetworkStack</code>.
@result Returns the assigned interface unit number.
*/
virtual UInt16 getUnitNumber( void ) const;
/*! @function addNetworkData
@abstract Adds an <code>IONetworkData</code> object to the interface.
@discussion The <code>IONetworkData</code> object is added to a
collection using the key from <code>IONetworkData::getKey()<code>.
The object provided is retained.
@param aData The <code>IONetworkData</code> object.
@result Returns true if the object was added, false otherwise.
*/
virtual bool addNetworkData( IONetworkData * aData );
/*! @function removeNetworkData
@abstract Removes an <code>IONetworkData</code> object from the interface.
@discussion This method removes an <code>IONetworkData</code> object from
the collection managed by the interface. The object removed is released.
@param aKey An OSSymbol identifying the object to be removed.
@result Returns true if the object was found and removed, false otherwise.
*/
virtual bool removeNetworkData( const OSSymbol * aKey );
/*! @function removeNetworkData
@abstract Removes an <code>IONetworkData</code> object from the interface.
@discussion This method removes an <code>IONetworkData</code> object from
the collection managed by the interface. The object removed is released.
@param aKey A C-string identifying the object to be removed.
@result Returns true if the object was found and removed, false otherwise.
*/
virtual bool removeNetworkData( const char * aKey );
/*! @function getNetworkData
@abstract Gets an <code>IONetworkData</code> object from the interface.
@discussion Returns a reference to an <code>IONetworkData</code> object
that was previously added to the interface, and is associated with the
provided key.
@param aKey A C-string identifying the object.
@result Returns a reference to the matching <code>IONetworkData</code>
object, or NULL if no match was found.
*/
virtual IONetworkData * getNetworkData( const char * aKey ) const;
/*! @function getNetworkData
@abstract Gets an <code>IONetworkData</code> object from the interface.
@discussion Returns a reference to an <code>IONetworkData</code> object
that was previously added to the interface, and is associated with the
provided key.
@param aKey An OSSymbol identifying the object.
@result Returns a reference to the matching <code>IONetworkData</code>
object, or NULL if no match was found.
*/
virtual IONetworkData * getNetworkData(const OSSymbol * aKey) const;
/* Compatibility methods */
IONetworkData * getParameter(const char * aKey) const;
bool setExtendedFlags(UInt32 flags, UInt32 clear = 0);
/* Override IOService::message() */
virtual IOReturn message( UInt32 type, IOService * provider, void * argument ) APPLE_KEXT_OVERRIDE;
/*! @function debuggerRegistered
@abstract Tells the <code>IONetworkData</code> that this interface will be
used by the debugger.
*/
void debuggerRegistered( void );
protected:
/*! @function setInterfaceType
@abstract Sets the interface type.
@discussion Sets the interface type before the interface is attached to
the network stack. See <code>bsd/net/if_types.h</code> for defined types.
The <code>kIOInterfaceType</code> is also updated using the provided type.
@param type A constant defined in <code>bsd/net/if_types.h</code> that
describes the interface type.
@result Returns true to indicate success if the interface has not yet
attached to the network stack, otherwise returns false.
*/
virtual bool setInterfaceType( UInt8 type );
/*! @function setMaxTransferUnit
@abstract Sets the maximum transfer unit for this interface.
@discussion Calls <code>ifnet_set_mtu</code> if the interface is attached
to the network stack, and updates the <code>kIOMaxTransferUnit</code>
property using the provided value.
@param mtu The interface MTU size in bytes.
@result Always returns true.
*/
virtual bool setMaxTransferUnit( UInt32 mtu );
/*! @function setFlags
@abstract Performs a read-modify-write operation on the current
interface flags value.
@discussion Calls <code>ifnet_set_flags</code> if the interface is attached
to the network stack, and updates the <code>kIOInterfaceFlags</code>
property using the provided value. See <code>bsd/net/if.h</code> header
file for the flag constants.
@param flags The bits that should be set.
@param clear The bits that should be cleared. If zero, then non
of the flags are cleared and the result is formed by OR'ing the
original flags value with the new flags.
@result Always returns true.
*/
virtual bool setFlags( UInt16 flags, UInt16 clear = 0 );
/* Deprecated. No replacement. */
virtual bool setExtraFlags( UInt32 flags, UInt32 clear = 0 );
/*! @function setMediaAddressLength
@abstract Sets the size of the media (MAC-layer) address.
@discussion Calls <code>ifnet_set_addrlen</code> if interface is attached
to the network stack, and updates the <code>kIOMediaAddressLength</code>
property using the provided value.
@param length The size of the media address in bytes.
@result Always returns true.
*/
virtual bool setMediaAddressLength( UInt8 length );
/*! @function setMediaHeaderLength
@abstract Sets the size of the media header.
@discussion Calls <code>ifnet_set_hdrlen</code> if interface is attached
to the network stack, and updates the <code>kIOMediaHeaderLength</code>
property using the provided value.
@param length The size of the media header in bytes.
@result Always returns true.
*/
virtual bool setMediaHeaderLength( UInt8 length );
/*! @function setUnitNumber
@abstract Assigns an unique unit number to this interface.
@discussion This method is called internally before the interface is
attached to the network stack, to assign an unique unit number to the
interface object. The <code>kIOInterfaceUnit</code> property is also
updated using the provided value.
@param unit The unit number assigned to this interface object.
@result Returns true to indicate success if the interface has not yet
attached to the network stack, otherwise returns false.
*/
virtual bool setUnitNumber( UInt16 unit );
/*! @function free
@abstract Frees the <code>IONetworkInterface</code> object.
@discussion Resource allocated by init() are released, and
clearInputQueue() is called to ensure that the input queue is empty.
The interface should have already detached from the network stack.
*/
virtual void free( void ) APPLE_KEXT_OVERRIDE;
/* Override IOService::handleOpen() */
virtual bool handleOpen( IOService * client,
IOOptionBits options,
void * argument ) APPLE_KEXT_OVERRIDE;
/* Override IOService::handleClose() */
virtual void handleClose( IOService * client, IOOptionBits options ) APPLE_KEXT_OVERRIDE;
/* Override IOService::handleIsOpen() */
virtual bool handleIsOpen( const IOService * client ) const APPLE_KEXT_OVERRIDE;
/*! @function lock
@abstract Acquires a recursive lock owned by the interface.
@discussion A recursive lock is allocated and initialized in
<code>init()</code>. This lock is otherwise not used by the
<code>IONetworkInterface</code> class. This method call acquires
the lock and must be balanced with an <code>unlock()</code>.
*/
virtual void lock( void );
/*! @function unlock
@abstract Releases the recursive lock owned by the interface.
@discussion A recursive lock is allocated and initialized in
<code>init()</code>. This lock is otherwise not used by the
<code>IONetworkInterface</code> class. This method call releases
the lock to balance a prior <code>lock()</code>.
*/
virtual void unlock( void );
/*! @function controllerDidOpen
@abstract Sends a notification that the interface has opened the network
controller.
@discussion This method is called by <code>handleOpen()</code> to notify
subclasses that the controller was opened. The open on the controller
occurs when the interface receives the initial open request from a client.
Subclasses can override this method and inspect the controller before
allowing the client open. This method is called with the arbitration lock
held, hence issuing I/O to the controller must be avoided to eliminate the
possibility of a deadlock.
@param controller The controller that was opened.
@result Must return true in order for handleOpen() to accept the client
open. If the return is false, then the controller will be closed and the
client open will fail.
*/
virtual bool controllerDidOpen( IONetworkController * controller );
/*! @function controllerWillClose
@abstract Sends a notification that the interface will close the network
controller.
@discussion This method is called by <code>handleClose()</code> after
receiving a close from the last interface client, and just before the
controller is closed. Subclasses can override this method to perform any
cleanup action before the controller is closed. This method is called with
the arbitration lock held, hence issuing I/O to the controller should be
avoided to eliminate the possibility of a deadlock.
@param controller The controller that is about to be closed.
*/
virtual void controllerWillClose( IONetworkController * controller );
/*! @function performCommand
@abstract Handles an ioctl command sent to the network interface.
@discussion This method handles socket ioctl commands sent to the
network interface from DLIL.
IONetworkInterface handles commands that are common for all network
interface types. A subclass of IONetworkInterface may override this
method to override the command handling in IONetworkInterface, or
to extend the command processing to handle additional commands.
The ioctl commands handled by IONetworkInterface are
<code>SIOCGIFMTU</code> (Get interface MTU size),
<code>SIOCSIFMTU</code> (Set interface MTU size),
<code>SIOCSIFMEDIA</code> (Set media), and
<code>SIOCGIFMEDIA</code> (Get media and link status).
@param controller The controller object.
@param cmd The ioctl command code.
@param arg0 Command argument 0. Generally a pointer to an ifnet structure
associated with the interface.
@param arg1 Command argument 1.
@result Returns a BSD return value defined in <code>bsd/sys/errno.h</code>.
*/
virtual SInt32 performCommand(
IONetworkController * controller,
unsigned long cmd,
void * arg0,
void * arg1 );
public:
/*! @function getIfnet
@abstract Returns the <code>ifnet_t</code> allocated by the interface object.
@discussion Gets the interface's <code>ifnet_t</code>, which is managed
primarily by <code>IONetworkInterface</code>, however subclasses or drivers
can use this method to obtain a reference to the <code>ifnet_t</code> for
interface KPI calls.
@result Returns the <code>ifnet_t</code> after the interface has attached
to the network stack and before the interface is detached, otherwise returns
NULL.
*/
virtual ifnet_t getIfnet( void ) const;
protected:
/* Deprecated. Use <code>initIfnetParams</code> instead. */
virtual bool initIfnet( struct ifnet * ifp );
/*! @function handleClientOpen
@abstract Handles a client open on the interface.
@discussion This method is called by <code>handleOpen()</code> to allow a
subclass to handle a client close. The arbitration lock is held.
@param client The client object requesting the open.
@param options Options passed to <code>handleOpen()</code>.
@param argument Argument passed to <code>handleOpen()</code>.
@result Returns true to accept the client open, false to reject the open.
*/
virtual bool handleClientOpen( IOService * client,
IOOptionBits options,
void * argument );
/*! @function handleClientClose
@abstract Handles a client close on the interface.
@discussion This method is called by <code>handleClose()</code> to allow a
subclass to handle a client close. The arbitration lock is held.
@param client The client object requesting the close.
@param options Options same options passed to <code>handleClose()</code>.
*/
virtual void handleClientClose( IOService * client,
IOOptionBits options );
/* Override IOService::newUserClient() */
virtual IOReturn newUserClient( task_t owningTask,
void * security_id,
UInt32 type,
IOUserClient ** handler ) APPLE_KEXT_OVERRIDE;
/*! @function setInterfaceState
@abstract Updates the interface object state flags.
@discussion The flags reflect the current state of the interface, and is
also published through the <code>kIOInterfaceState</code> property.
@param set The flags that should be set.
@param clear The flags that should be cleared.
@result Returns the new interface state flags.
*/
virtual UInt32 setInterfaceState( UInt32 set, UInt32 clear = 0 );
/*! @function powerStateWillChangeTo
@abstract Handles a pre-change power interest notification from the
network controller.
@discussion The <code>controllerWillChangePowerState()</code> method is
called by this handler. Subclasses are not expected to override this method.
@param flags Flags that describe the capability of the controller in the
new power state.
@param stateNumber An index to a state in the network controller's
power state array that the controller is switching to.
@param policyMaker A reference to the network controller's policy-maker,
and is also the originator of this notification.
@result Returns <code>IOPMAckImplied</code> to indicate synchronous completion.
*/
virtual IOReturn powerStateWillChangeTo(
IOPMPowerFlags flags,
unsigned long stateNumber,
IOService * policyMaker ) APPLE_KEXT_OVERRIDE;
/*! @function powerStateDidChangeTo
@abstract Handles a post-change power interest notification from the
network controller.
@discussion The <code>controllerDidChangePowerState()</code> method is
called by this handler. Subclasses are not expected to override this method.
@param flags Flags that describe the capability of the controller in the
new power state.
@param stateNumber An index to a state in the network controller's
power state array that the controller has switched to.
@param policyMaker A reference to the network controller's policy-maker,
and is also the originator of this notification.
@result Returns <code>IOPMAckImplied</code> to indicate synchronous completion.
*/
virtual IOReturn powerStateDidChangeTo(
IOPMPowerFlags flags,
unsigned long stateNumber,
IOService * policyMaker ) APPLE_KEXT_OVERRIDE;
/*! @function controllerWillChangePowerState
@abstract Handles a notification that the network controller servicing
this interface object will transition to a new power state.
@param controller The network controller object.
@param flags Flags that describe the capability of the controller in the
new power state.
@param stateNumber An index to a state in the network controller's
power state array that the controller is switching to.
@param policyMaker A reference to the network controller's policy-maker,
and is also the originator of this notification.
@result The return value is always <code>kIOReturnSuccess</code>.
*/
virtual IOReturn controllerWillChangePowerState(
IONetworkController * controller,
IOPMPowerFlags flags,
UInt32 stateNumber,
IOService * policyMaker );
/*! @function controllerDidChangePowerState
@abstract Handles a notification that the network controller servicing
this interface object has transitioned to a new power state.
@param controller The network controller object.
@param flags Flags that describe the capability of the controller in the
new power state.
@param stateNumber An index to a state in the network controller's
power state array that the controller has switched to.
@param policyMaker A reference to the network controller's policy-maker,
and is also the originator of this notification.
@result The return value is always <code>kIOReturnSuccess</code>.
*/
virtual IOReturn controllerDidChangePowerState(
IONetworkController * controller,
IOPMPowerFlags flags,
UInt32 stateNumber,
IOService * policyMaker );
public:
/* Override IOService::willTerminate() */
virtual bool willTerminate(
IOService * provider,
IOOptionBits options ) APPLE_KEXT_OVERRIDE;
/* Override IOService::requestTerminate() */
virtual bool requestTerminate(
IOService * provider, IOOptionBits options ) APPLE_KEXT_OVERRIDE;
/* Override IOService::serializeProperties() */
virtual bool serializeProperties( OSSerialize * s ) const APPLE_KEXT_OVERRIDE;
/*! @function attachToDataLinkLayer
@abstract Attach the network interface to the BSD data link layer.
@discussion This method is called internally to attach the network
interface to the BSD data link layer, after an unit number has been
assigned. The calling context is not synchronized against the driver's
work loop. Subclasses may override this method to perform additional
setup before the network stack attach. The <code>getIfnet()</code> method
will return the BSD interface being attached.
@param options Options for the attach call. None are currently defined.
@param parameter Parameter for the attach call. Not currently used.
@result Returns <code>kIOReturnSuccess</code> on success.
*/
virtual IOReturn attachToDataLinkLayer( IOOptionBits options,
void * parameter );
OSMetaClassDeclareReservedUsed(IONetworkInterface, 0);
/*! @function detachFromDataLinkLayer
@abstract Detach the network interface from the BSD data link layer.
@discussion This method is called internally to detach the network
interface from the BSD data link layer, after the interface has been
terminated and before the last client close. This method will block until
the detach operation is complete. The calling context is not synchronized
against the driver's work loop. Subclasses may override this method to
perform additional cleanup before or after detaching from the network
stack. The <code>getIfnet()</code> method will return NULL after detach.
@param options Options for the detach call. None are currently defined.
@param parameter Parameter for the detach call. Not currently used.
*/
virtual void detachFromDataLinkLayer( IOOptionBits options,
void * parameter );
OSMetaClassDeclareReservedUsed(IONetworkInterface, 1);
protected:
/*! @function feedPacketInputTap
@abstract Feed received packets to the BPF
@discussion This function is called internally to send input packets to
the BPF input tap when it is enabled. Subclasses are not expected to
override this method.
@param mbuf_t Pointer to the input packet.
*/
virtual void feedPacketInputTap( mbuf_t );
OSMetaClassDeclareReservedUsed(IONetworkInterface, 2);
/*! @function feedPacketOutputTap
@abstract Feed output packets to the BPF
@discussion This function is called internally to send output packets to
the BPF output tap when it is enabled. Subclasses are not expected to
override this method.
@param mbuf_t Pointer to the output packet.
*/
virtual void feedPacketOutputTap( mbuf_t );
OSMetaClassDeclareReservedUsed(IONetworkInterface, 3);
/*! @function initIfnetParams
@abstract Allows a subclass to provide ifnet initialization parameters
specific to an interface type.
@discussion This method initializes the parameters that are common to all
network interfaces. An interface subclass is expected to override this
method, call the superclass implementation first, then initialize the
parameters specific to that interface type. This method is called after
an unit number has been assigned to the interface, and just before the
interface is attached to BSD.
@param params Pointer to an <code>ifnet_init_params</code> allocated by
the caller.
@result Returns <code>true</code> on success, <code>false</code> otherwise.
*/
virtual bool initIfnetParams( struct ifnet_init_params * params );
OSMetaClassDeclareReservedUsed(IONetworkInterface, 4);
/*! @function configureOutputStartDelay
@abstract Configure the output start delay
@discussion This optional routine, if used, needs to be called after
IONetworkInterface::init() and before IONetworkInterface::attachToDataLinkLayer().
This allows for over-riding ifnet_init_eparams.start_delay_qlen and
ifnet_init_eparams.start_delay_timeout.
@param outputStartDelayQueueLength, maps to ifnet_init_eparams.start_delay_qlen
@param outputStartDelayTimeout, maps to ifnet_init_eparams.start_delay_timeout
@result <code>kIOReturnSuccess</code> if interface was successfully
configured.
*/
IOReturn configureOutputStartDelay( uint16_t outputStartDelayQueueLength,
uint16_t outputStartDelayTimeout );
public:
OSMetaClassDeclareReservedUnused( IONetworkInterface, 5);
OSMetaClassDeclareReservedUnused( IONetworkInterface, 6);
OSMetaClassDeclareReservedUnused( IONetworkInterface, 7);
OSMetaClassDeclareReservedUnused( IONetworkInterface, 8);
OSMetaClassDeclareReservedUnused( IONetworkInterface, 9);
OSMetaClassDeclareReservedUnused( IONetworkInterface, 10);
OSMetaClassDeclareReservedUnused( IONetworkInterface, 11);
OSMetaClassDeclareReservedUnused( IONetworkInterface, 12);
OSMetaClassDeclareReservedUnused( IONetworkInterface, 13);
OSMetaClassDeclareReservedUnused( IONetworkInterface, 14);
OSMetaClassDeclareReservedUnused( IONetworkInterface, 15);
};
#endif /* __cplusplus */
#endif /* KERNEL */
#endif /* !_IONETWORKINTERFACE_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/network/IOEthernetStats.h | /*
* Copyright (c) 1998-2008 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* The contents of this file constitute Original Code as defined in and
* are subject to the Apple Public Source License Version 1.1 (the
* "License"). You may not use this file except in compliance with the
* License. Please obtain a copy of the License at
* http://www.apple.com/publicsource and read it before using this file.
*
* This Original Code and all software distributed under the License are
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/*
* IOEthernetStats.h - Ethernet MIB statistics definitions.
*
* HISTORY
*/
#ifndef _IOETHERNETSTATS_H
#define _IOETHERNETSTATS_H
/*! @header IOEthernetStats.h
@discussion Ethernet statistics. */
//---------------------------------------------------------------------------
// Ethernet-like statistics group.
/*! @typedef IODot3StatsEntry
@discussion Ethernet MIB statistics structure.
@field alignmentErrors dot3StatsAlignmentErrors.
@field fcsErrors dot3StatsFCSErrors.
@field singleCollisionFrames dot3StatsSingleCollisionFrames.
@field multipleCollisionFrames dot3StatsMultipleCollisionFrames.
@field sqeTestErrors dot3StatsSQETestErrors.
@field deferredTransmissions dot3StatsDeferredTransmissions.
@field lateCollisions dot3StatsLateCollisions.
@field excessiveCollisions dot3StatsExcessiveCollisions.
@field internalMacTransmitErrors dot3StatsInternalMacTransmitErrors.
@field carrierSenseErrors dot3StatsCarrierSenseErrors.
@field frameTooLongs dot3StatsFrameTooLongs.
@field internalMacReceiveErrors dot3StatsInternalMacReceiveErrors.
@field etherChipSet dot3StatsEtherChipSet.
@field missedFrames dot3StatsMissedFrames (not in RFC1650).
*/
typedef struct {
UInt32 alignmentErrors;
UInt32 fcsErrors;
UInt32 singleCollisionFrames;
UInt32 multipleCollisionFrames;
UInt32 sqeTestErrors;
UInt32 deferredTransmissions;
UInt32 lateCollisions;
UInt32 excessiveCollisions;
UInt32 internalMacTransmitErrors;
UInt32 carrierSenseErrors;
UInt32 frameTooLongs;
UInt32 internalMacReceiveErrors;
UInt32 etherChipSet;
UInt32 missedFrames;
} IODot3StatsEntry;
//---------------------------------------------------------------------------
// Ethernet-like collision statistics group (optional).
/*! @typedef IODot3CollEntry
@discussion Collision statistics structure.
@field collFrequencies dot3StatsCollFrequencies. */
typedef struct {
UInt32 collFrequencies[16];
} IODot3CollEntry;
//---------------------------------------------------------------------------
// Receiver extra statistics group (not defined by RFC 1650).
/*! @typedef IODot3RxExtraEntry
@discussion Extra receiver statistics not defined by RFC1650.
@field overruns receiver overruns.
@field watchdogTimeouts watchdog timer expirations.
@field frameTooShorts runt frames.
@field collisionErrors frames damages by late collision.
@field phyErrors PHY receive errors.
@field timeouts receiver timeouts.
@field interrupts receiver interrupts.
@field resets receiver resets.
@field resourceErrors receiver resource shortages.
*/
typedef struct {
UInt32 overruns;
UInt32 watchdogTimeouts;
UInt32 frameTooShorts;
UInt32 collisionErrors;
UInt32 phyErrors;
UInt32 timeouts;
UInt32 interrupts;
UInt32 resets;
UInt32 resourceErrors;
UInt32 reserved[4];
} IODot3RxExtraEntry;
//---------------------------------------------------------------------------
// Transmitter extra statistics group (not defined by RFC 1650).
/*! @typedef IODot3TxExtraEntry
@discussion Extra transmitter statistics not defined by RFC1650.
@field underruns transmit underruns.
@field jabbers jabber events.
@field phyErrors PHY transmit errors.
@field timeouts transmitter timeouts.
@field interrupts transmitter interrupts.
@field resets transmitter resets.
@field resourceErrors transmitter resource shortages.
*/
typedef struct {
UInt32 underruns;
UInt32 jabbers;
UInt32 phyErrors;
UInt32 timeouts;
UInt32 interrupts;
UInt32 resets;
UInt32 resourceErrors;
UInt32 reserved[4];
} IODot3TxExtraEntry;
//---------------------------------------------------------------------------
// Aggregate Ethernet statistics.
/*! @typedef IOEthernetStats
@discussion Aggregate Ethernet statistics structure.
@field dot3StatsEntry IODot3StatsEntry statistics group.
@field dot3CollEntry IODot3CollEntry statistics group.
@field dot3RxExtraEntry IODot3RxExtraEntry statistics group.
@field dot3TxExtraEntry IODot3TxExtraEntry statistics group.
*/
typedef struct {
IODot3StatsEntry dot3StatsEntry;
IODot3CollEntry dot3CollEntry;
IODot3RxExtraEntry dot3RxExtraEntry;
IODot3TxExtraEntry dot3TxExtraEntry;
} IOEthernetStats;
/*! @defined kIOEthernetStatsKey
@discussion Defines the name of an IONetworkData that contains
an IOEthernetStats. */
#define kIOEthernetStatsKey "IOEthernetStatsKey"
#endif /* !_IOETHERNETSTATS_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/network/IOPacketQueue.h | /*
* Copyright (c) 1998-2008 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* The contents of this file constitute Original Code as defined in and
* are subject to the Apple Public Source License Version 1.1 (the
* "License"). You may not use this file except in compliance with the
* License. Please obtain a copy of the License at
* http://www.apple.com/publicsource and read it before using this file.
*
* This Original Code and all software distributed under the License are
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _IOPACKETQUEUE_H
#define _IOPACKETQUEUE_H
#include <libkern/c++/OSObject.h>
#include <IOKit/IOLocks.h>
extern "C" {
#include <sys/kpi_mbuf.h>
}
// Forward declarations.
//
struct mbuf;
struct IOMbufQueue;
// We do not want the enqueue/dequeue macros defined in queue.h.
//
// #warning queue.h should not be included
#undef enqueue
#undef dequeue
/*! @class IOPacketQueue
@abstract Implements a bounded FIFO queue of mbuf packets.
@discussion Packets are
removed from the head of the queue (dequeue), and new packets are added
to the tail of the queue (enqueue). A spinlock is used to synchronize
access to the queue between methods that have a "lock" prefix.
*/
class __exported IOPacketQueue : public OSObject
{
OSDeclareDefaultStructors( IOPacketQueue )
protected:
IOMbufQueue * _queue; // mbuf queue
IOSimpleLock * _lock; // spinlock for synchronized methods
struct ExpansionData { };
/*! @var reserved
Reserved for future use. (Internal use only) */
ExpansionData *_reserved;
/*! @function free
@abstract Frees the IOPacketQueue object.
@discussion All packets held by the queue are released back to the free
pool, resource are deallocated, then super::free() is called.
*/
virtual void free() APPLE_KEXT_OVERRIDE;
/*! @var IOPacketQueueDefaultCapacity
@abstract Describes the default capacity of the
queue object.
@discussion The capacity is only observed by the enqueue() method.
Therefore, it is possible for the size of the queue to exceed its
capacity when other methods, such as prepend(), are used to add packets
to the queue.
*/
static const UInt32 IOPacketQueueDefaultCapacity = 100;
public:
/*! @function withCapacity
@abstract Factory method that constructs and initializes an
IOPacketQueue object.
@param capacity The initial capacity of the queue object. Can be
later changed by calling the setCapacity() method.
@result Returns an IOPacketQueue instance on success, or 0 otherwise.
*/
static IOPacketQueue * withCapacity(UInt32 capacity =
IOPacketQueueDefaultCapacity);
/*! @function initWithCapacity
@abstract Initializes an IOPacketQueue object.
@discussion This method initializes an IOPacketQueue object with the given capacity.
@param capacity The initial capacity of the queue. Can be later changed
by calling the setCapacity() method.
@result Returns true if initialized successfully, false otherwise.
*/
virtual bool initWithCapacity(UInt32 capacity =
IOPacketQueueDefaultCapacity);
/*! @function getSize
@abstract Gets the size of the queue.
@result Returns the number of packets currently held by the queue.
*/
virtual UInt32 getSize() const;
/*! @function setCapacity
@abstract Changes the capacity of the queue.
@param capacity The new capacity.
@result Returns true if the new capacity was accepted, false otherwise.
*/
virtual bool setCapacity(UInt32 capacity);
/*! @function getCapacity
@abstract Gets the current capacity of the queue.
@result Returns the current queue capacity.
*/
virtual UInt32 getCapacity() const;
/*! @function peek
@abstract Examines the packet at the head of the queue without
removing it from the queue.
@discussion A following call to peek() or dequeue() will return
the same packet. The caller must never modify the mbuf packet returned.
@result Returns the packet at the head of the queue.
*/
virtual mbuf_t peek() const;
/*! @function prepend
@abstract Adds a chain of packets to the head of the queue.
@param m A chain of packets to add to the head of the queue.
*/
virtual void prepend(mbuf_t m);
/*! @function prepend
@abstract Removes all packets from the specified queue, and adds them
to the head of this queue.
@param queue The source IOPacketQueue object containing the packets to
be transferred.
*/
virtual void prepend(IOPacketQueue * queue);
/*! @function lockPrepend
@abstract Adds a chain of packets to the head of a synchronized queue.
@discussion A spinlock is used to synchronize access to the queue.
@param m A chain of packets to add to the head of the queue.
@result Always returns true.
*/
virtual void lockPrepend(mbuf_t m);
/*! @function enqueue
@abstract Adds a chain of packets to the tail of the queue.
@discussion Packets are not added if the size of the queue has reached
its capacity.
@param m A chain of packets to add to the tail of the queue.
@result Returns true on success, or false to indicate over-capacity and refusal
to accept the packet chain provided.
*/
virtual bool enqueue(mbuf_t m);
/*! @function enqueue
@abstract Removes all packets from the specified queue, and adds them
to the tail of this queue.
@param queue The source IOPacketQueue object containing the packets to
be transferred.
@result Always returns true.
*/
virtual bool enqueue(IOPacketQueue * queue);
/*! @function enqueueWithDrop
@abstract Adds a chain of packets to the tail of the queue.
@discussion Packets are
dropped if the size of the queue has reached its capacity.
@param m A chain of packets to add to the tail of the queue.
@result Returns the number of packets dropped and freed by the queue.
*/
virtual UInt32 enqueueWithDrop(mbuf_t m);
/*! @function lockEnqueue
@abstract Adds a chain of packets to the tail of a synchronized queue.
@discussion Packets are not added if the size of the queue has reached
its capacity. A spinlock is used to synchronize access to the queue.
@param m A chain of packets to add to the tail of the queue.
@result Returns true on success, or false to indicate over-capacity and refusal
to accept the packet chain provided.
*/
virtual bool lockEnqueue(mbuf_t m);
/*! @function lockEnqueueWithDrop
@abstract Adds a chain of packets to the tail of a synchronized queue.
@discussion Packets are dropped if the size of the queue has reached its capacity. A spinlock is used to synchronize access to the queue.
@param m A chain of packets to add to the tail of the queue.
@result Returns the number of packets dropped and freed by the queue.
*/
virtual UInt32 lockEnqueueWithDrop(mbuf_t m);
/*! @function dequeue
@abstract Removes a single packet from the head of the queue.
@result Returns a packet removed from the head of the queue, or NULL if the
queue was empty.
*/
virtual mbuf_t dequeue();
/*! @function lockDequeue
@abstract Removes a single packet from the head of a synchronized queue.
@discussion A spinlock is used to synchronize access to the queue.
@result Returns a packet removed from the head of the queue, or NULL if the
queue was empty.
*/
virtual mbuf_t lockDequeue();
/*! @function dequeueAll
@abstract Removes all packets from the queue and returns the head of the
packet chain.
@discussion The size of the queue is cleared to zero.
@result Returns the head of a packet chain linking all packets that were held
in the queue, or NULL if the queue was empty.
*/
virtual mbuf_t dequeueAll();
/*! @function lockDequeueAll
@abstract Removes all packets from a synchronized queue and returns the
head of the packet chain.
@discussion The size of the queue is cleared to zero. A spinlock is used
to synchronize access to the queue.
@result Returns the head of a packet chain linking all packets that were held
in the queue, or NULL if the queue was empty.
*/
virtual mbuf_t lockDequeueAll();
/*! @function flush
@abstract Frees all packets currently held in the queue and releases them
back to the free mbuf pool.
@discussion The size of the queue is cleared to zero.
@result Returns the number of packets freed.
*/
virtual UInt32 flush();
/*! @function lockFlush
@abstract Frees all packets currently held in a synchronized queue and
releases them back to the free mbuf pool.
@discussion The size of the queue is cleared to zero. A spinlock is used
to synchronize access to the queue.
@result Returns the number of packets freed.
*/
virtual UInt32 lockFlush();
// Virtual Pad functions
OSMetaClassDeclareReservedUnused( IOPacketQueue, 0);
OSMetaClassDeclareReservedUnused( IOPacketQueue, 1);
OSMetaClassDeclareReservedUnused( IOPacketQueue, 2);
OSMetaClassDeclareReservedUnused( IOPacketQueue, 3);
OSMetaClassDeclareReservedUnused( IOPacketQueue, 4);
OSMetaClassDeclareReservedUnused( IOPacketQueue, 5);
OSMetaClassDeclareReservedUnused( IOPacketQueue, 6);
OSMetaClassDeclareReservedUnused( IOPacketQueue, 7);
OSMetaClassDeclareReservedUnused( IOPacketQueue, 8);
OSMetaClassDeclareReservedUnused( IOPacketQueue, 9);
OSMetaClassDeclareReservedUnused( IOPacketQueue, 10);
OSMetaClassDeclareReservedUnused( IOPacketQueue, 11);
OSMetaClassDeclareReservedUnused( IOPacketQueue, 12);
OSMetaClassDeclareReservedUnused( IOPacketQueue, 13);
OSMetaClassDeclareReservedUnused( IOPacketQueue, 14);
OSMetaClassDeclareReservedUnused( IOPacketQueue, 15);
};
#endif /* !_IOPACKETQUEUE_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/network/IONetworkMedium.h | /*
* Copyright (c) 1998-2008, 2021 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* The contents of this file constitute Original Code as defined in and
* are subject to the Apple Public Source License Version 1.1 (the
* "License"). You may not use this file except in compliance with the
* License. Please obtain a copy of the License at
* http://www.apple.com/publicsource and read it before using this file.
*
* This Original Code and all software distributed under the License are
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _IONETWORKMEDIUM_H
#define _IONETWORKMEDIUM_H
__BEGIN_DECLS
#include <net/if_media.h>
/*! @typedef IOMediumType
@discussion A 32-bit value divided into fields which describes
a single medium type. */
typedef UInt32 IOMediumType;
/*! @defined kIOMediumType
@abstract A property of IONetworkMedium objects.
@discussion The kIOMediumType property is an OSNumber object that describes the type of
medium that this object represents.
*/
#define kIOMediumType "Type"
/*! @defined kIOMediumFlags
@abstract A property of IONetworkMedium objects.
@discussion The kIOMediumFlags property is an OSNumber object that describes a set of
attributes assigned to the medium.
*/
#define kIOMediumFlags "Flags"
/*! @defined kIOMediumSpeed
@abstract A property of IONetworkMedium objects.
@discussion The kIOMediumSpeed property is an OSNumber object that describes the maximum link
speed supported by the medium in bits per second.
*/
#define kIOMediumSpeed "Speed"
/*! @defined kIOMediumIndex
@abstract A property of IONetworkMedium objects.
@discussion The kIOMediumIndex property is an OSNumber object that describes an index assigned
by the owner of the medium object. Its interpretation is driver
specific.
*/
#define kIOMediumIndex "Index"
//===========================================================================
// Medium Type (IOMediumType).
//
// The medium type is encoded by a 32-bit value. The definitions of
// the fields and the encoding for each field is adapted from FreeBSD.
//
// Bits Definition
// -------------------
// 4-0 medium subtype
// 7-5 network type
// 15-8 network specific options
// 19-16 reserved
// 27-20 common options
// 31-28 instance number
// Ethernet.
//
// Important Note:
//
// The kIOMediumEthernet* definitions are aliases for the IFM_* definitions
// in <net/if_media.h>. The kIOMediumEthernet* list defined here is no longer
// complete and will not be extended beyond its current set of definitions.
// Use the IFM_* definitions from <net/if_media.h> directly to make use
// of media types not defined here. For example to specify an IOMediumType
// corresponding to 25G_T, use (IFM_25G_T | IFM_ETHER).
//
enum {
kIOMediumEthernet = IFM_ETHER,
kIOMediumEthernetAuto = ( IFM_AUTO | IFM_ETHER ),
kIOMediumEthernetManual = ( IFM_MANUAL | IFM_ETHER ),
kIOMediumEthernetNone = ( IFM_NONE | IFM_ETHER ),
kIOMediumEthernet10BaseT = ( IFM_10_T | IFM_ETHER ),
kIOMediumEthernet10Base2 = ( IFM_10_2 | IFM_ETHER ),
kIOMediumEthernet10Base5 = ( IFM_10_5 | IFM_ETHER ),
kIOMediumEthernet100BaseTX = ( IFM_100_TX | IFM_ETHER ),
kIOMediumEthernet100BaseFX = ( IFM_100_FX | IFM_ETHER ),
kIOMediumEthernet100BaseT4 = ( IFM_100_T4 | IFM_ETHER ),
kIOMediumEthernet100BaseVG = ( IFM_100_VG | IFM_ETHER ),
kIOMediumEthernet100BaseT2 = ( IFM_100_T2 | IFM_ETHER ),
kIOMediumEthernet1000BaseSX = ( IFM_1000_SX | IFM_ETHER ),
kIOMediumEthernet10BaseSTP = ( IFM_10_STP | IFM_ETHER ),
kIOMediumEthernet10BaseFL = ( IFM_10_FL | IFM_ETHER ),
kIOMediumEthernet1000BaseLX = ( IFM_1000_LX | IFM_ETHER ),
kIOMediumEthernet1000BaseCX = ( IFM_1000_CX | IFM_ETHER ),
kIOMediumEthernet1000BaseTX = ( IFM_1000_T | IFM_ETHER ), //deprecated- use kIOMediumEthernet1000BaseT instead
kIOMediumEthernet1000BaseT = ( IFM_1000_T | IFM_ETHER ),
kIOMediumEthernetHomePNA1 = ( IFM_HPNA_1 | IFM_ETHER ),
kIOMediumEthernet10GBaseSR = ( IFM_10G_SR | IFM_ETHER ),
kIOMediumEthernet10GBaseLR = ( IFM_10G_LR | IFM_ETHER ),
kIOMediumEthernet10GBaseCX4 = ( IFM_10G_CX4 | IFM_ETHER ),
kIOMediumEthernet10GBaseT = ( IFM_10G_T | IFM_ETHER ),
kIOMediumEthernet2500BaseT = ( IFM_2500_T | IFM_ETHER ),
kIOMediumEthernet5000BaseT = ( IFM_5000_T | IFM_ETHER )
};
// IEEE 802.11 Wireless.
//
enum {
kIOMediumIEEE80211 = IFM_IEEE80211,
kIOMediumIEEE80211Auto = ( IFM_AUTO | IFM_IEEE80211 ),
kIOMediumIEEE80211Manual = ( IFM_MANUAL | IFM_IEEE80211 ),
kIOMediumIEEE80211None = ( IFM_NONE | IFM_IEEE80211 ),
kIOMediumIEEE80211FH1 = ( IFM_IEEE80211_FH1 | IFM_IEEE80211 ),
kIOMediumIEEE80211FH2 = ( IFM_IEEE80211_FH2 | IFM_IEEE80211 ),
kIOMediumIEEE80211DS2 = ( IFM_IEEE80211_DS2 | IFM_IEEE80211 ),
kIOMediumIEEE80211DS5 = ( IFM_IEEE80211_DS5 | IFM_IEEE80211 ),
kIOMediumIEEE80211DS11 = ( IFM_IEEE80211_DS11 | IFM_IEEE80211 ),
kIOMediumIEEE80211DS1 = ( IFM_IEEE80211_DS1 | IFM_IEEE80211 ),
kIOMediumIEEE80211OptionAdhoc = IFM_IEEE80211_ADHOC
};
// Common options.
//
enum {
kIOMediumOptionFullDuplex = IFM_FDX,
kIOMediumOptionHalfDuplex = IFM_HDX,
kIOMediumOptionFlowControl = IFM_FLOW,
kIOMediumOptionEEE = IFM_EEE,
kIOMediumOptionFlag0 = IFM_FLAG0,
kIOMediumOptionFlag1 = IFM_FLAG1,
kIOMediumOptionFlag2 = IFM_FLAG2,
kIOMediumOptionLoopback = IFM_LOOP
};
// Medium type masks.
//
#define kIOMediumSubTypeMask IFM_TMASK
#define kIOMediumNetworkTypeMask IFM_NMASK
#define kIOMediumOptionsMask IFM_OMASK
#define kIOMediumCommonOptionsMask IFM_GMASK
#define kIOMediumInstanceShift IFM_ISHIFT
#define kIOMediumInstanceMask IFM_IMASK
// Medium type field accessors.
//
#define IOMediumGetSubType(x) ((x) & kIOMediumSubTypeMask)
#define IOMediumGetNetworkType(x) ((x) & kIOMediumNetworkTypeMask)
#define IOMediumGetInstance(x) (((x) & kIOMediumInstanceMask) >> \
kIOMediumInstanceShift)
//===========================================================================
// Medium flags.
//===========================================================================
// Link status bits.
//
enum {
kIONetworkLinkValid = IFM_AVALID, // link status is valid
kIONetworkLinkActive = IFM_ACTIVE, // link is up/active.
kIONetworkLinkNoNetworkChange = IFM_WAKESAMENET
};
__END_DECLS
#ifdef KERNEL
//===========================================================================
// IONetworkMedium class.
#include <libkern/c++/OSObject.h>
#include <libkern/c++/OSSymbol.h>
/*! @class IONetworkMedium
@abstract An object that encapsulates information about a network
medium (i.e. 10Base-T, or 100Base-T Full Duplex).
@discussion The main purpose of
this object is for a network driver to advertise its media capability,
through a collection of IONetworkMedium objects stored in a dictionary
in its property table. IONetworkMedium supports serialization, and will
encode its properties in the form of a dictionary to the serialization
stream when instructed. This will allow a user-space application to
browse the set of media types supported by the controller.
*/
class __exported IONetworkMedium : public OSObject
{
OSDeclareDefaultStructors( IONetworkMedium )
protected:
IOMediumType _type;
UInt32 _flags;
UInt64 _speed;
UInt32 _index;
const OSSymbol * _name;
struct ExpansionData { };
/*! @var reserved
Reserved for future use. (Internal use only) */
ExpansionData *_reserved;
/*! @function free
@abstract Frees the IONetworkMedium object.
*/
virtual void free() APPLE_KEXT_OVERRIDE;
public:
/*! @function nameForType
@abstract Creates a name that describes a medium type.
@discussion Given a medium type, creates an OSymbol object that
describes the medium type. There is a 1-to-1 mapping between the
medium type, and the medium name created by this method. The caller
is responsible for releasing the OSSymbol object returned.
@param type A medium type. See IONetworkMedium.h for type encoding.
@result Returns an OSSymbol object is created based on the type provided.
*/
static const OSSymbol * nameForType(IOMediumType type);
/*! @function addMedium
@abstract Adds an IONetworkMedium object to a dictionary.
@discussion A helper function to add an IONetworkMedium object to a
given dictionary. The name of the medium is used as the key for the
new dictionary entry.
@param dict An OSDictionary object where the medium object should be
added as a new entry.
@param medium The IONetworkMedium object to add to the dictionary.
@result Returns true on success, false otherwise.
*/
static bool addMedium(OSDictionary * dict,
const IONetworkMedium * medium);
/*! @function removeMedium
@abstract Removes an IONetworkMedium object from a dictionary.
@discussion A helper function to remove an entry in a dictionary.
@param dict The OSDictionary object where the medium object should be
removed from.
@param medium The name of this medium object is used as the key.
*/
static void removeMedium(OSDictionary * dict,
const IONetworkMedium * medium);
/*! @function getMediumWithType
@abstract Finds a medium object from a dictionary with a given type.
@discussion This method iterates through a dictionary and returns an IONetworkMedium
entry with the given type. An optional mask supplies the don't care bits.
@param dict The dictionary to look for a matching entry.
@param type Search for an entry with this type.
@param mask The don't care bits in IOMediumType. Defaults to 0, which
implies that a perfect match is desired.
@result Returns the first matching IONetworkMedium entry found,
or 0 if no match was found.
*/
static IONetworkMedium * getMediumWithType(const OSDictionary * dict,
IOMediumType type,
IOMediumType mask = 0);
/*! @function getMediumWithIndex
@abstract Finds a medium object from a dictionary with a given index.
@discussion This method iterates through a dictionary and returns an IONetworkMedium
entry with the given index. An optional mask supplies the don't care bits.
@param dict The dictionary to look for a matching entry.
@param index Search for an entry with the given index.
@param mask The don't care bits in index. Defaults to 0, which
implies that a perfect match is desired.
@result Returns the first matching IONetworkMedium entry found,
or 0 if no match was found.
*/
static IONetworkMedium * getMediumWithIndex(const OSDictionary * dict,
UInt32 index,
UInt32 mask = 0);
/*! @function init
@abstract Initializes an IONetworkMedium object.
@param type The medium type, this value is encoded with bits defined in
IONetworkMedium.h.
@param speed The maximum (or the only) link speed supported over this
medium in units of bits per second.
@param flags An optional flag for the medium object.
See IONetworkMedium.h for defined flags.
@param index An optional index number assigned by the owner.
Drivers can use this to store an index to a media table in
the driver, or it may map to a driver-defined media type.
@param name An optional name assigned to this medium object. If 0,
then a name will be created based on the medium type by
calling IONetworkMedium::nameForType(). Since the name of
the medium is used as a key when inserted into a dictionary,
the name chosen must be unique within the scope of the owner.
@result Returns true on success, false otherwise.
*/
virtual bool init(IOMediumType type,
UInt64 speed,
UInt32 flags = 0,
UInt32 index = 0,
const char * name = 0);
/*! @function medium
@abstract Factory method that allocates and initializes an IONetworkMedium object.
@param type The medium type, this value is encoded with bits defined in
IONetworkMedium.h.
@param speed The maximum (or the only) link speed supported over this
medium in units of bits per second.
@param flags An optional flag for the medium object.
See IONetworkMedium.h for defined flags.
@param index An optional index number assigned by the owner.
Drivers can use this to store an index to a media table in
the driver, or it may map to a driver-defined media type.
@param name An optional name assigned to this medium object. If 0,
then a name will be created based on the medium type by
calling IONetworkMedium::nameForType(). Since the name of
the medium is used as a key when inserted into a dictionary,
the name chosen must be unique within the scope of the owner.
@result Returns an IONetworkMedium instance on success, or 0 otherwise.
*/
static IONetworkMedium * medium(IOMediumType type,
UInt64 speed,
UInt32 flags = 0,
UInt32 index = 0,
const char * name = 0);
/*! @function getType
@result Returns the medium type assigned to this medium object.
*/
virtual IOMediumType getType() const;
/*! @function getSpeed
@result Returns the maximum link speed supported by this medium.
*/
virtual UInt64 getSpeed() const;
/*! @function getFlags
@result Returns the medium flags.
*/
virtual UInt32 getFlags() const;
/*! @function getIndex
@result Returns the assigned medium index.
*/
virtual UInt32 getIndex() const;
/*! @function getName
@result Returns the name assigned to this medium object.
*/
virtual const OSSymbol * getName() const;
/*! @function getKey
@result Returns the key to use for this medium object. This key should be
used when this object is added to a dictionary. Same as getName().
*/
virtual const OSSymbol * getKey() const;
/*! @function isEqualTo
@abstract Tests for equality between two IONetworkMedium objects.
@discussion Two IONetworkMedium objects are considered equal if
they have similar properties assigned to them during initialization.
@param medium An IONetworkMedium to test against the IONetworkMedium
object being called.
@result Returns true if equal, false otherwise.
*/
virtual bool isEqualTo(const IONetworkMedium * medium) const;
/*! @function isEqualTo
@abstract Tests for equality between a IONetworkMedium object and an
OSObject.
@discussion The OSObject is considered equal to the IONetworkMedium
object if the OSObject is an IONetworkMedium, and they have
similar properties assigned to them during initialization.
@param obj An OSObject to test against an IONetworkMedium object.
@result Returns true if equal, false otherwise.
*/
virtual bool isEqualTo(const OSMetaClassBase * obj) const APPLE_KEXT_OVERRIDE;
/*! @function serialize
@abstract Serializes the IONetworkMedium object.
@discussion A dictionary is created containing the properties
assigned to this medium object, and this dictionary is then
serialized using the OSSerialize object provided.
@param s An OSSerialize object.
@result Returns true on success, false otherwise.
*/
virtual bool serialize(OSSerialize * s) const APPLE_KEXT_OVERRIDE;
// Virtual function padding
OSMetaClassDeclareReservedUnused( IONetworkMedium, 0);
OSMetaClassDeclareReservedUnused( IONetworkMedium, 1);
OSMetaClassDeclareReservedUnused( IONetworkMedium, 2);
OSMetaClassDeclareReservedUnused( IONetworkMedium, 3);
};
// Translate getKey() to getName().
//
inline const OSSymbol * IONetworkMedium::getKey() const
{
return getName();
}
#endif /* KERNEL */
#endif /* !_IONETWORKMEDIUM_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/network/IOEthernetInterface.h | /*
* Copyright (c) 1998-2008 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* The contents of this file constitute Original Code as defined in and
* are subject to the Apple Public Source License Version 1.1 (the
* "License"). You may not use this file except in compliance with the
* License. Please obtain a copy of the License at
* http://www.apple.com/publicsource and read it before using this file.
*
* This Original Code and all software distributed under the License are
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _IOETHERNETINTERFACE_H
#define _IOETHERNETINTERFACE_H
/*! @defined kIOEthernetInterfaceClass
@abstract The name of the
IOEthernetInterface class.
*/
#define kIOEthernetInterfaceClass "IOEthernetInterface"
/*! @defined kIOActivePacketFilters
@abstract A property of IOEthernetInterface objects.
@discussion The kIOActivePacketFilters property has an OSDictionary value that describes the current
set of packet filters that have been successfully activated. Each
entry in the dictionary is a key/value pair consisting of the filter
group name, and an OSNumber describing the set of active filters for
that group. Entries in this dictionary will mirror those in
kIORequiredPacketFilters if the controller has reported success for
all filter change requests from the IOEthernetInterface object.
*/
#define kIOActivePacketFilters "IOActivePacketFilters"
/*! @defined kIORequiredPacketFilters
@abstract A property of IOEthernetInterface objects.
@discussion The kIORequiredPacketFilters property has an OSDictionary value that describes the current
set of required packet filters. Each entry in the dictionary is a
key/value pair consisting of the filter group name, and an OSNumber
describing the set of required filters for that group.
*/
#define kIORequiredPacketFilters "IORequiredPacketFilters"
/*! @defined kIOMulticastAddressList
@abstract A property of IOEthernetInterface objects.
@discussion The kIOMulticastAddressList property is an OSData object that describes the
list of multicast addresses that are being used by the
controller to match against the destination address of an
incoming frame.
*/
#define kIOMulticastAddressList "IOMulticastAddressList"
#define kIOMulticastFilterData kIOMulticastAddressList
#ifdef KERNEL
#ifdef __cplusplus
#include <IOKit/network/IONetworkInterface.h>
#include <IOKit/network/IOEthernetController.h>
#include <IOKit/network/IOEthernetStats.h>
/*! @class IOEthernetInterface
@abstract The Ethernet interface object.
@discussion An Ethernet controller driver,
that is a subclass of IOEthernetController, will instantiate an object
of this class when the driver calls the attachInterface() method.
This interface object will then vend an Ethernet interface to DLIL,
and manage the connection between the controller driver and the upper
networking layers. Drivers will seldom need to subclass
IOEthernetInterface.
*/
class __exported APPLE_KEXT_DEPRECATE IOEthernetInterface : public IONetworkInterface
{
OSDeclareDefaultStructors( IOEthernetInterface )
private:
thread_call_t _inputEventThreadCall; // inputEvent() thread call
UInt32 _mcAddrCount; // # of multicast addresses
bool _ctrEnabled; // Is controller enabled?
OSDictionary * _supportedFilters; // Controller's supported filters
OSDictionary * _requiredFilters; // The required filters
OSDictionary * _activeFilters; // Currently active filters
bool _controllerLostPower; // true if controller is unusable
struct ExpansionData {
UInt32 altMTU; // track the physical mtu of controller
UInt32 publishedFeatureID; // id for published wake packet
uint32_t supportedWakeFilters; // bitmask of supported wake filters
OSNumber * disabledWakeFilters; // OSNumber of disabled wake filters
uint64_t wompEnabledAssertionID;
};
/*! @var reserved
Reserved for future use. (Internal use only) */
ExpansionData * _reserved;
IOReturn enableController(IONetworkController * ctr);
IOReturn setupMulticastFilter(IONetworkController * ctr);
UInt32 getFilters(const OSDictionary * dict,
const OSSymbol * group);
bool setFilters(OSDictionary * dict,
const OSSymbol * group,
UInt32 filters);
IOReturn disableFilter(IONetworkController * ctr,
const OSSymbol * group,
UInt32 filter,
IOOptionBits options = 0);
IOReturn enableFilter(IONetworkController * ctr,
const OSSymbol * group,
UInt32 filter,
IOOptionBits options = 0);
int syncSIOCSIFFLAGS(IONetworkController * ctr);
int syncSIOCSIFADDR(IONetworkController * ctr);
int syncSIOCADDMULTI(IONetworkController * ctr);
int syncSIOCDELMULTI(IONetworkController * ctr);
int syncSIOCSIFMTU(IONetworkController * ctr, struct ifreq * ifr, bool);
int syncSIOCGIFDEVMTU(IONetworkController * ctr, struct ifreq * ifr);
int syncSIOCSIFLLADDR(IONetworkController * ctr, const char * lladdr, int len);
int syncSIOCSIFCAP(IONetworkController * ctr, struct ifreq * ifr);
void _fixupVlanPacket(mbuf_t, u_int16_t, int);
void reportInterfaceWakeFlags(IONetworkController * ctr);
static void handleEthernetInputEvent(thread_call_param_t param0, thread_call_param_t param1);
static int performGatedCommand(void *, void *, void *, void *, void *);
static IOReturn enableFilter_Wrapper(
IOEthernetInterface *, IONetworkController *, const OSSymbol *, UInt32 , IOOptionBits);
public:
/*! @function init
@abstract Initializes an IOEthernetInterface instance.
@discussion Instance variables are initialized, and an arpcom
structure is allocated.
@param controller A network controller object that will service
the interface object being initialized.
@result Returns true on success, false otherwise.
*/
virtual bool init( IONetworkController * controller ) APPLE_KEXT_OVERRIDE;
/*! @function getNamePrefix
@abstract Returns a string containing the prefix to use when
creating a BSD name for this interface.
@discussion The BSD name for each interface object is created by
concatenating a string returned by this method, with an unique
unit number assigned by IONetworkStack.
@result Returns a pointer to a constant C string "en". Therefore, Ethernet
interfaces will be registered with BSD as en0, en1, etc.
*/
virtual const char * getNamePrefix() const APPLE_KEXT_OVERRIDE;
protected:
/*! @function free
@abstract Frees the IOEthernetInterface instance.
@discussion The memory allocated for the arpcom structure is released,
followed by a call to super::free().
*/
virtual void free() APPLE_KEXT_OVERRIDE;
/*! @function performCommand
@abstract Handles an ioctl command sent to the Ethernet interface.
@discussion This method handles socket ioctl commands sent to the Ethernet
interface from DLIL. Commands recognized and processed by this method are
SIOCSIFADDR, SIOCSIFFLAGS, SIOCADDMULTI, and SIOCDELMULTI. Other commands
are passed to the superclass.
@param controller The controller object.
@param cmd The ioctl command code.
@param arg0 Command argument 0. Generally a pointer to an ifnet structure
associated with the interface.
@param arg1 Command argument 1.
@result Returns a BSD return value defined in bsd/sys/errno.h.
*/
virtual SInt32 performCommand(IONetworkController * controller,
unsigned long cmd,
void * arg0,
void * arg1) APPLE_KEXT_OVERRIDE;
/*! @function controllerDidOpen
@abstract A notification that the interface has opened the network
controller.
@discussion This method will be called by IONetworkInterface after a
network controller has accepted an open from this interface object.
IOEthernetInterface will first call the implementation in its
superclass, then inspect the controller through properties published
in the registry. This method is called with the arbitration lock held.
@param controller The controller object that was opened.
@result Returns true on success, false otherwise. Returning false will
cause the controller to be closed, and any pending client opens to be
rejected.
*/
virtual bool controllerDidOpen(IONetworkController * controller) APPLE_KEXT_OVERRIDE;
/*! @function controllerWillClose
@abstract A notification that the interface will close the network
controller.
@discussion This method will simply call super to propagate the method
call. This method is called with the arbitration lock held.
@param controller The controller that is about to be closed.
*/
virtual void controllerWillClose(IONetworkController * controller) APPLE_KEXT_OVERRIDE;
/*! @function controllerWillChangePowerState
@abstract Handles a notification that the network controller
servicing this interface object is about to transition to a new power state.
@discussion If the controller is about to transition to an unusable state,
and it is currently enabled, then the disable() method on the controller is
called.
@param controller The network controller object.
@param flags Flags that describe the capability of the controller in the new
power state.
@param stateNumber An index to a state in the network controller's
power state array that the controller is switching to.
@param policyMaker A reference to the network controller's policy-maker,
and is also the originator of this notification.
@result Always returns kIOReturnSuccess.
*/
virtual IOReturn controllerWillChangePowerState(
IONetworkController * controller,
IOPMPowerFlags flags,
UInt32 stateNumber,
IOService * policyMaker) APPLE_KEXT_OVERRIDE;
/*! @function controllerDidChangePowerState
@abstract Handles a notification that the network controller servicing
this interface object has transitioned to a new power state.
@discussion If the controller did transition to a usable state, and it was
previously disabled due to a previous power change, then it is re-enabled.
@param controller The network controller object.
@param flags Flags that describe the capability of the controller in the new
power state.
@param stateNumber An index to a state in the network controller's
power state array that the controller has switched to.
@param policyMaker A reference to the network controller's policy-maker,
and is also the originator of this notification.
@result Always returns kIOReturnSuccess.
*/
virtual IOReturn controllerDidChangePowerState(
IONetworkController * controller,
IOPMPowerFlags flags,
UInt32 stateNumber,
IOService * policyMaker) APPLE_KEXT_OVERRIDE;
public:
/* Override IONetworkInterface::willTerminate() */
virtual bool willTerminate( IOService * provider,
IOOptionBits options ) APPLE_KEXT_OVERRIDE;
/* Override IONetworkInterface::attachToDataLinkLayer() */
virtual IOReturn attachToDataLinkLayer( IOOptionBits options,
void * parameter) APPLE_KEXT_OVERRIDE;
/* Override IONetworkInterface::inputEvent() */
virtual bool inputEvent( UInt32 type, void * data) APPLE_KEXT_OVERRIDE;
protected:
virtual void feedPacketInputTap(mbuf_t) APPLE_KEXT_OVERRIDE;
virtual void feedPacketOutputTap(mbuf_t) APPLE_KEXT_OVERRIDE;
virtual bool initIfnetParams(struct ifnet_init_params *params) APPLE_KEXT_OVERRIDE;
public:
// Virtual function padding
OSMetaClassDeclareReservedUnused( IOEthernetInterface, 0);
OSMetaClassDeclareReservedUnused( IOEthernetInterface, 1);
OSMetaClassDeclareReservedUnused( IOEthernetInterface, 2);
OSMetaClassDeclareReservedUnused( IOEthernetInterface, 3);
OSMetaClassDeclareReservedUnused( IOEthernetInterface, 4);
OSMetaClassDeclareReservedUnused( IOEthernetInterface, 5);
OSMetaClassDeclareReservedUnused( IOEthernetInterface, 6);
OSMetaClassDeclareReservedUnused( IOEthernetInterface, 7);
OSMetaClassDeclareReservedUnused( IOEthernetInterface, 8);
OSMetaClassDeclareReservedUnused( IOEthernetInterface, 9);
OSMetaClassDeclareReservedUnused( IOEthernetInterface, 10);
OSMetaClassDeclareReservedUnused( IOEthernetInterface, 11);
OSMetaClassDeclareReservedUnused( IOEthernetInterface, 12);
OSMetaClassDeclareReservedUnused( IOEthernetInterface, 13);
OSMetaClassDeclareReservedUnused( IOEthernetInterface, 14);
OSMetaClassDeclareReservedUnused( IOEthernetInterface, 15);
};
#endif /* __cplusplus */
#endif /* KERNEL */
#endif /* !_IOETHERNETINTERFACE_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/network/IONetworkData.h | /*
* Copyright (c) 1998-2008 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* The contents of this file constitute Original Code as defined in and
* are subject to the Apple Public Source License Version 1.1 (the
* "License"). You may not use this file except in compliance with the
* License. Please obtain a copy of the License at
* http://www.apple.com/publicsource and read it before using this file.
*
* This Original Code and all software distributed under the License are
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _IONETWORKDATA_H
#define _IONETWORKDATA_H
#define IONetworkParameter IONetworkData // FIXME
/*! @enum NetworkDataAccessTypes
@abstract Constants that describe access types.
@constant kIONetworkDataAccessTypeRead Read access.
@constant kIONetworkDataAccessTypeWrite Write access (deprecated).
@constant kIONetworkDataAccessTypeReset Reset access (deprecated).
@constant kIONetworkDataAccessTypeSerialize Serialization access.
*/
enum {
kIONetworkDataAccessTypeRead = 0x01,
kIONetworkDataAccessTypeWrite = 0x02,
kIONetworkDataAccessTypeReset = 0x04,
kIONetworkDataAccessTypeSerialize = 0x08,
kIONetworkDataAccessTypeMask = 0xff
};
/*! @define kIONetworkDataBasicAccessTypes
@discussion The default access types supported by an IONetworkData
object. Allow read() and serialize(). */
#define kIONetworkDataBasicAccessTypes \
(kIONetworkDataAccessTypeRead | kIONetworkDataAccessTypeSerialize)
/*! @enum NetworkDataBufferTypes
@abstract The types of data buffers that can be managed by an IONetworkData object.
@constant kIONetworkDataBufferTypeInternal An internal data buffer
allocated by the init() method.
@constant kIONetworkDataBufferTypeExternal An external (persistent) data
buffer.
@constant kIONetworkDataBufferTypeNone No data buffer. The only useful
action perfomed by an IONetworkData object with this buffer type
is to call the access notification handler.
*/
enum {
kIONetworkDataBufferTypeInternal = 0,
kIONetworkDataBufferTypeExternal,
kIONetworkDataBufferTypeNone
};
/*! @defined kIONetworkDataBytes
@abstract A property of IONetworkData objects.
@discussion The kIONetworkDataBytes property is an OSData that describes
the data buffer of an IONetworkData object. This property is present
only if kIONetworkDataAccessTypeSerialize access is supported.
*/
#define kIONetworkDataBytes "Data"
/*! @defined kIONetworkDataAccessTypes
@abstract A property of IONetworkData objects.
@discussion The kIONetworkDataAccessTypes property is an OSNumber that
describes the supported access types of an IONetworkData object.
*/
#define kIONetworkDataAccessTypes "Access Types"
/*! @defined kIONetworkDataSize
@abstract A property of IONetworkData objects.
@discussion The kIONetworkDataSize property is an OSNumber that
describes the size of the data buffer of an IONetworkData object.
*/
#define kIONetworkDataSize "Size"
#ifdef KERNEL
#include <libkern/c++/OSSymbol.h>
#include <libkern/c++/OSSerialize.h>
/*! @class IONetworkData
@abstract An object that manages a fixed-size named buffer.
@discussion An IONetworkData object manages a fixed-size named buffer.
This object provides external access methods that can be used to
access the contents of the data buffer. In addition, serialization
is supported, and therefore this object can be added to a property
table to publish the data object. An unique name must be assigned to
the object during initialization. An OSSymbol key will be created
based on the assigned name, and this key can be used when the object
is added to a dictionary.
The level of access granted to the access methods can be restricted,
by specifying a set of supported access types when the object is
initialized, or modified later by calling setAccessTypes(). By default,
each IONetworkData object created will support serialization, and will
also allow its data buffer to be read through the read() access method.
An access notification handler, in the form of a 'C' function, can
be registered to receive a call each time the data buffer is accessed
through an access method. Arguments provided to the handler will identify
the data object and the type of access that triggered the notification.
The handler can therefore perform lazy update of the data buffer until
an interested party tries to read or serialize the data. The notification
handler can also take over the default action performed by the access
methods when the buffer type is set to kIONetworkDataBufferTypeNone.
This will prevent the access methods from accessing the data buffer,
and allow the handler to override the access protocol.
This object is primarily used by IONetworkInterface to export interface
properties to user space.
*/
class __exported IONetworkData : public OSObject
{
OSDeclareDefaultStructors( IONetworkData )
public:
/*! @typedef Action
@abstract Defines a C function that may be called by an IONetworkData object
when one of its access methods is called.
@param target The target of the notification.
@param param A parameter that was provided when the notification
handler was registered.
@param data The IONetworkData object being accessed, and the
sender of the notification.
@param accessType A bit will be set indicating the type of access
which triggered the notification.
@param buffer Pointer to the accessor's buffer. Only valid for
read() and write() accesses.
@param bufferSize Pointer to the size of the accessor's buffer.
@param offset An offset from the start of the data buffer to begin
reading or writing.
*/
typedef IOReturn (*Action)(void * target,
void * param,
IONetworkData * data,
UInt32 accessType,
void * buffer,
UInt32 * bufferSize,
UInt32 offset);
protected:
const OSSymbol * _key; // key associated with this object.
UInt32 _access; // supported access types.
void * _buffer; // Data buffer.
UInt32 _bufType; // buffer type
UInt32 _size; // data buffer size.
void * _tapTarget; // target for access notification.
Action _tapAction; // the function to call.
void * _tapParam; // arbitrary notification param.
struct ExpansionData { };
/*! @var reserved
Reserved for future use. (Internal use only) */
ExpansionData * _reserved;
/*! @function free
@abstract Frees the IONetworkData object.
*/
virtual void free() APPLE_KEXT_OVERRIDE;
/*! @function writeBytes
@abstract Writes to the data buffer with data from a source buffer
provided by the caller.
@param srcBuffer Pointer to a source buffer provided by the caller.
@param srcBufferSize The size of the source buffer.
@param writeOffset A byte offset from the start of the data buffer
to begin writting.
@result Returns true if the operation was successful, false otherwise.
*/
virtual bool writeBytes(const void * srcBuffer,
UInt32 srcBufferSize,
UInt32 writeOffset = 0);
/*! @function readBytes
@abstract Reads from the data buffer and copies the data to a destination
buffer provided by the caller.
@param dstBuffer Pointer to the destination buffer.
@param dstBufferSize Pointer to an integer containing the size of the
destination buffer. And is overwritten by this method with the actual
number of bytes copied to the destination buffer.
@param readOffset A byte offset from the start of the data buffer
to begin reading.
@result Returns true if the operation was successful, false otherwise.
*/
virtual bool readBytes(void * dstBuffer,
UInt32 * dstBufferSize,
UInt32 readOffset = 0) const;
/*! @function clearBuffer
@abstract Clears the data buffer by filling it with zeroes.
@result Returns true if the operation was successful, false otherwise.
*/
virtual bool clearBuffer();
public:
/*! @function withInternalBuffer
@abstract Factory method that constructs and initializes an
IONetworkData object with an internal data buffer.
@param name A name to assign to this object.
@param bufferSize The number of bytes to allocate for the internal data
buffer.
@param accessTypes The initial supported access types.
@param target The notification target.
@param action The notification action.
@param param A parameter to pass to the notification action.
@result Returns an IONetworkData object on success, or 0 otherwise.
*/
static IONetworkData *
withInternalBuffer(const char * name,
UInt32 bufferSize,
UInt32 accessTypes =
kIONetworkDataBasicAccessTypes,
void * target = 0,
Action action = 0,
void * param = 0);
/*! @function withExternalBuffer
@abstract Factory method that constructs and initializes an
IONetworkData object with an external data buffer.
@param name A name to assign to this object.
@param bufferSize The size of the external data buffer.
@param externalBuffer Pointer to the external data buffer.
@param accessTypes The initial supported access types.
@param target The notification target.
@param action The notification action.
@param param A parameter to pass to the notification action.
@result Returns an IONetworkData object on success, or 0 otherwise.
*/
static IONetworkData *
withExternalBuffer(const char * name,
UInt32 bufferSize,
void * externalBuffer,
UInt32 accessTypes =
kIONetworkDataBasicAccessTypes,
void * target = 0,
Action action = 0,
void * param = 0);
/*! @function withNoBuffer
@abstract Factory method that constructs and initializes an
IONetworkData object without a data buffer.
@discussion The notification handler
must intervene when the IONetworkData is accessed.
@param name A name to assign to this object.
@param bufferSize The size of the phantom data buffer.
@param accessTypes The initial supported access types.
@param target The notification target.
@param action The notification action.
@param param A parameter to pass to the notification action.
@result Returns an IONetworkData object on success, or 0 otherwise.
*/
static IONetworkData * withNoBuffer(const char * name,
UInt32 bufferSize,
UInt32 accessTypes,
void * target,
Action action,
void * param = 0);
/*! @function init
@abstract Initializes an IONetworkData object.
@param name A name to assign to this object.
@param bufferType The type of buffer associated with this object.
@param bufferSize The size of the data buffer.
@param externalBuffer Pointer to an external data buffer.
@param accessTypes The initial supported access types.
Can be later modified by calling setAccessTypes().
@param target The notification target.
@param action The notification action.
@param param A parameter to pass to the notification action.
@result Returns true if initialized successfully, false otherwise.
*/
virtual bool init(const char * name,
UInt32 bufferType,
UInt32 bufferSize,
void * externalBuffer = 0,
UInt32 accessTypes =
kIONetworkDataBasicAccessTypes,
void * target = 0,
Action action = 0,
void * param = 0);
/*! @function setAccessTypes
@abstract Sets the types of access that are permitted on the data buffer.
@param types A mask of access types indicating the supported access
types.
*/
virtual void setAccessTypes(UInt32 types);
/*! @function setNotificationTarget
@abstract Registers a C function to handle access notifications sent
from this object.
@discussion A notification is sent by an IONetworkData object to the
registered notification handler, when an access method is called to
modify the contents of the data buffer.
@param target The first parameter passed to the notification handler.
@param action A pointer to a C function that will handle the notification.
If 0, then notification is disabled.
@param param An optional parameter passed to the notification handler.
*/
virtual void setNotificationTarget(void * target,
Action action,
void * param = 0);
/*! @function getBuffer
@abstract Gets a pointer to the data buffer.
@result Returns a pointer to the data buffer. Returns 0 if the buffer type is
kIONetworkDataBufferTypeNone.
*/
virtual const void * getBuffer() const;
/*! @function getBufferType
@abstract Gets the type of data buffer managed by this object.
@result Returns a constant that describes the type of the data buffer.
*/
virtual UInt32 getBufferType() const;
/*! @function getAccessTypes
@abstract Gets the types of data access supported by this object.
@result Returns a mask of supported access types.
*/
virtual UInt32 getAccessTypes() const;
/*! @function getNotificationTarget
@abstract Gets the first parameter that will be passed to the access
notification handler.
@result Returns the first parameter that will be passed to the access notification
handler.
*/
virtual void * getNotificationTarget() const;
/*! @function getNotificationAction
@abstract Gets the C function that was registered to handle access
notifications sent from this object.
@result Returns a pointer to a C function, or 0 if notification is disabled.
*/
virtual Action getNotificationAction() const;
/*! @function getNotificationParameter
@abstract Gets the parameter that will be passed to the access
notification handler.
@result Returns the parameter that will be passed to the access notification
handler.
*/
virtual void * getNotificationParameter() const;
/*! @function getKey
@abstract Gets a unique OSSymbol key associated with this object.
@discussion During initialization, IONetworkData will create an
OSSymbol key based on its assigned name.
@result Returns an OSSymbol key that was generated from the name assigned to
this object.
*/
virtual const OSSymbol * getKey() const;
/*! @function getSize
@abstract Gets the size of the data buffer.
@result Returns the size of the data buffer managed by this object in bytes.
*/
virtual UInt32 getSize() const;
/*! @function reset
@abstract An access method that resets the data buffer.
@discussion This method handles an external request to reset the data buffer.
If notification is enabled, then the notification handler is called
after the data buffer has been cleared.
@result Returns kIOReturnSuccess on success,
kIOReturnNotWritable if reset access is not permitted,
or an error from the notification handler.
*/
virtual IOReturn reset();
/*! @function read
@abstract An access method that reads from the data buffer.
@discussion This method handles an external request to read from the data buffer
and copy it to the destination buffer provided by the accessor.
If notification is enabled, then the notification handler is called
before the data buffer is copied to the destination buffer. The
notification handler may use this opportunity to intervene and
to update the contents of the data buffer.
@param dstBuffer Pointer to the destination buffer.
@param dstBufferSize Pointer to an integer containing the size of the
destination buffer. And is overwritten by this method to the actual number
of bytes copied to the destination buffer.
@param readOffset An offset from the start of the source data buffer to
begin reading.
@result Returns kIOReturnSuccess on success,
kIOReturnBadArgument if any of the arguments provided is invalid,
kIOReturnNotReadable if read access is not permitted,
or an error from the notification handler.
*/
virtual IOReturn read(void * dstBuffer,
UInt32 * dstBufferSize,
UInt32 readOffset = 0);
/*! @function write
@abstract An access method that writes to the data buffer.
@discussion This method handles an external request to write to the data buffer
from a source buffer provided by the accessor. After checking that
the data object supports write accesses, the data buffer is updated
if it exists. Then the registered notification handler is called.
@param srcBuffer Pointer to the source buffer.
@param srcBufferSize The number of bytes to write to the data buffer.
@param writeOffset An offset from the start of the destination data buffer
to begin writing.
@result Returns kIOReturnSuccess on success,
kIOReturnBadArgument if any of the arguments provided is invalid,
kIOReturnNotWritable if write access is not permitted,
or an error from the notification handler.
*/
virtual IOReturn write(void * srcBuffer,
UInt32 srcBufferSize,
UInt32 writeOffset = 0);
/*! @function serialize
@abstract Serializes the IONetworkData object.
@discussion If notification is enabled, then the notification
handler is called just before the data buffer is serialized.
@param s An OSSerialize object.
@result Returns true on success, false otherwise.
*/
virtual bool serialize(OSSerialize * s) const APPLE_KEXT_OVERRIDE;
// Virtual function padding
OSMetaClassDeclareReservedUnused( IONetworkData, 0);
OSMetaClassDeclareReservedUnused( IONetworkData, 1);
OSMetaClassDeclareReservedUnused( IONetworkData, 2);
OSMetaClassDeclareReservedUnused( IONetworkData, 3);
};
#endif /* KERNEL */
#endif /* !_IONETWORKDATA_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/network/IOMbufMemoryCursor.h | /*
* Copyright (c) 1998-2008 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* The contents of this file constitute Original Code as defined in and
* are subject to the Apple Public Source License Version 1.1 (the
* "License"). You may not use this file except in compliance with the
* License. Please obtain a copy of the License at
* http://www.apple.com/publicsource and read it before using this file.
*
* This Original Code and all software distributed under the License are
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _IOKIT_NETWORK_IOMBUFMEMORYCURSOR_H
#define _IOKIT_NETWORK_IOMBUFMEMORYCURSOR_H
#include <IOKit/IOMemoryCursor.h>
/*! @class IOMbufMemoryCursor
@abstract A mechanism to convert mbuf chains to physical addresses.
@discussion The IOMbufMemoryCursor defines the super class that all
specific mbuf cursors must inherit from, but a mbuf cursor can be created
without a specific formal subclass by just providing a segment function to
the initializers. This class performs the task of walking a given
mbuf chain and creating a physical scatter/gather list appropriate for
the target hardware. When necessary, this class may also coalesce
mbuf chains when the generated scatter/gather list exceeds the specified
hardware limit. However, this should be avoided since it exacts a
performance cost.
<br><br>
A driver is expected to create a mbuf cursor and configure it to match the
limitations of it's DMA hardware; for instance the mbuf cursor used by
an Ethernet controller driver may have a maximum physical segment size
of 1520, and allow for up to 6 physical segments. Thus it would create a
mbuf cursor with a maxSegmentSize of 1520 and a maxNumSegments of 6.
The driver may choose to supply an OutputSegmentFunc function to
format the output of each scatter/gather segment to match the
hardware descriptor format, or it may use a subclass of
IOMbufMemoryCursor to generate IOPhysicalSegment segments with
various byte orders.
<br><br>
A driver may also create more than one mbuf cursor, perhaps one
dedicated for the transmit thread, and the other for the receive thread.
This becomes a requirement when the driver is multi-threaded, since the
mbuf cursor maintains state and does not support reentrancy. */
class __exported IOMbufMemoryCursor : public IOMemoryCursor
{
OSDeclareDefaultStructors(IOMbufMemoryCursor)
protected:
UInt32 maxNumSegments;
UInt32 coalesceCount;
UInt32 packetTooBigErrors;
struct ExpansionData { };
/*! @var reserved
Reserved for future use. (Internal use only) */
ExpansionData *reserved;
virtual bool initWithSpecification(OutputSegmentFunc outSeg,
UInt32 maxSegmentSize,
UInt32 maxTransferSize,
UInt32 align);
public:
/*! @function initWithSpecification
@abstract Primary initializer for the IOMbufMemoryCursor class.
@param outSeg Function to call to output one physical segment.
@param maxSegmentSize Maximum allowable size for one segment.
@param maxNumSegments Maximum number of segments.
@result Returns true if the inherited classes and this instance initialized
successfully.
*/
virtual bool initWithSpecification(OutputSegmentFunc outSeg,
UInt32 maxSegmentSize,
UInt32 maxNumSegments);
/*! @function genPhysicalSegments
@abstract Generates a physical scatter/gather list given a mbuf packet.
@discussion Generates a list of physical segments from the given mbuf.
@param packet The mbuf packet.
@param vector Void pointer to base of output physical scatter/gather list.
Always passed directly onto the OutputSegmentFunc without interpretation
by the cursor.
@param maxSegs Maximum number of segments that can be written to segments
array.
@param doCoalesce Set to true to perform coalescing when the required
number of segments exceeds the specified limit, otherwise abort and
return 0.
@result Returns the number of segments that were filled in, or
0 if an error occurred.
*/
virtual UInt32 genPhysicalSegments(mbuf_t packet, void * vector,
UInt32 maxSegs, bool doCoalesce);
/*! @function getAndResetCoalesceCount
@abstract Returns a count of the total number of mbuf chains coalesced
by genPhysicalSegments().
@discussion This method returns a count of the total number of mbuf chains coalesced
by genPhysicalSegments(). The counter is then reset to 0.
@result Returns the coalesce count.
*/
UInt32 getAndResetCoalesceCount();
// Virtual function padding
OSMetaClassDeclareReservedUnused( IOMbufMemoryCursor, 0);
OSMetaClassDeclareReservedUnused( IOMbufMemoryCursor, 1);
OSMetaClassDeclareReservedUnused( IOMbufMemoryCursor, 2);
OSMetaClassDeclareReservedUnused( IOMbufMemoryCursor, 3);
};
/*! @class IOMbufNaturalMemoryCursor
@abstract An IOMbufMemoryCursor subclass that outputs a vector of
IOPhysicalSegments in the natural byte orientation for the cpu.
@discussion The IOMbufNaturalMemoryCursor would be used when it is too
difficult to implement an OutputSegmentFunc that is more appropriate for
your hardware. This cursor just outputs an array of IOPhysicalSegments.
*/
class __exported IOMbufNaturalMemoryCursor : public IOMbufMemoryCursor
{
OSDeclareDefaultStructors(IOMbufNaturalMemoryCursor)
public:
/*! @function withSpecification
@abstract Factory function that creates and initializes an
IOMbufNaturalMemoryCursor in one operation.
@discussion See also IOMbufMemoryCursor::initWithSpecification.
@param maxSegmentSize Maximum allowable size for one segment.
@param maxNumSegments Maximum number of segments.
@result Returns a new mbuf cursor if successfully created and initialized,
0 otherwise.
*/
static IOMbufNaturalMemoryCursor * withSpecification(UInt32 maxSegmentSize,
UInt32 maxNumSegments);
/*! @function getPhysicalSegments
@abstract Generates a cpu natural physical scatter/gather list from a given
mbuf.
@param packet The mbuf packet.
@param vector Pointer to an array of IOPhysicalSegments for the output
physical scatter/gather list.
@param numVectorSegments Maximum number of IOPhysicalSegments accepted.
@result Returns the number of segments that were filled in, or
0 if an error occurred.
*/
UInt32 getPhysicalSegments(mbuf_t packet,
struct IOPhysicalSegment * vector,
UInt32 numVectorSegments = 0);
/*! @function getPhysicalSegmentsWithCoalesce
@abstract Generates a cpu natural physical scatter/gather list from a given
mbuf.
@discussion Generate a cpu natural physical scatter/gather list from a
given mbuf. Coalesce mbuf chain when the number of segments in the
scatter/gather list exceeds numVectorSegments.
@param packet The mbuf packet.
@param vector Pointer to an array of IOPhysicalSegments for the output
physical scatter/gather list.
@param numVectorSegments Maximum number of IOPhysicalSegments accepted.
@result Returns the number of segments that were filled in, or
0 if an error occurred.
*/
UInt32 getPhysicalSegmentsWithCoalesce(mbuf_t packet,
struct IOPhysicalSegment * vector,
UInt32 numVectorSegments = 0);
};
//===========================================================================
//===========================================================================
/*! @class IOMbufBigMemoryCursor
@abstract An IOMbufMemoryCursor subclass that outputs a vector of
IOPhysicalSegments in the big endian byte order.
@discussion The IOMbufBigMemoryCursor would be used when the DMA hardware
requires a big endian address and length pair. This cursor outputs an
array of IOPhysicalSegments that are encoded in big-endian format.
*/
class __exported IOMbufBigMemoryCursor : public IOMbufMemoryCursor
{
OSDeclareDefaultStructors(IOMbufBigMemoryCursor)
public:
/*! @function withSpecification
@abstract Factory function that creates and initializes an
IOMbufBigMemoryCursor in one operation.
@discussion See also IOMbufMemoryCursor::initWithSpecification.
@param maxSegmentSize Maximum allowable size for one segment.
@param maxNumSegments Maximum number of segments.
@result Returns a new mbuf cursor if successfully created and initialized,
0 otherwise.
*/
static IOMbufBigMemoryCursor * withSpecification(UInt32 maxSegmentSize,
UInt32 maxNumSegments);
/*! @function getPhysicalSegments
@abstract Generates a big endian physical scatter/gather list from a given
mbuf.
@param packet The mbuf packet.
@param vector Pointer to an array of IOPhysicalSegments for the output
physical scatter/gather list.
@param numVectorSegments Maximum number of IOPhysicalSegments accepted.
@result Returns the number of segments that were filled in, or
0 if an error occurred.
*/
UInt32 getPhysicalSegments(mbuf_t packet,
struct IOPhysicalSegment * vector,
UInt32 numVectorSegments = 0);
/*! @function getPhysicalSegmentsWithCoalesce
@abstract Generates a big endian physical scatter/gather list from a given
mbuf.
@discussion Generate a big endian physical scatter/gather list from a
given mbuf. Coalesce mbuf chain when the number of segments in the
scatter/gather list exceeds numVectorSegments.
@param packet The mbuf packet.
@param vector Pointer to an array of IOPhysicalSegments for the output
physical scatter/gather list.
@param numVectorSegments Maximum number of IOPhysicalSegments accepted.
@result Returns the number of segments that were filled in, or
0 if an error occurred.
*/
UInt32 getPhysicalSegmentsWithCoalesce(mbuf_t packet,
struct IOPhysicalSegment * vector,
UInt32 numVectorSegments = 0);
};
//===========================================================================
//===========================================================================
/*! @class IOMbufLittleMemoryCursor
@abstract An IOMbufMemoryCursor subclass that outputs a vector of
IOPhysicalSegments in the little endian byte order.
@discussion The IOMbufLittleMemoryCursor would be used when the DMA
hardware requires a little endian address and length pair. This cursor
outputs an array of IOPhysicalSegments that are encoded in little endian
format.
*/
class __exported IOMbufLittleMemoryCursor : public IOMbufMemoryCursor
{
OSDeclareDefaultStructors(IOMbufLittleMemoryCursor)
public:
/*! @function withSpecification
@abstract Factory function that creates and initializes an
IOMbufLittleMemoryCursor in one operation.
@discussion See also IOMbufMemoryCursor::initWithSpecification.
@param maxSegmentSize Maximum allowable size for one segment.
@param maxNumSegments Maximum number of segments.
@result Returns a new mbuf cursor if successfully created and initialized,
0 otherwise.
*/
static IOMbufLittleMemoryCursor * withSpecification(UInt32 maxSegmentSize,
UInt32 maxNumSegments);
/*! @function getPhysicalSegments
@abstract Generates a little endian physical scatter/gather list from a
given mbuf.
@param packet The mbuf packet.
@param vector Pointer to an array of IOPhysicalSegments for the output
physical scatter/gather list.
@param numVectorSegments Maximum number of IOPhysicalSegments accepted.
@result Returns the number of segments that were filled in, or
0 if an error occurred.
*/
UInt32 getPhysicalSegments(mbuf_t packet,
struct IOPhysicalSegment * vector,
UInt32 numVectorSegments = 0);
/*! @function getPhysicalSegmentsWithCoalesce
@abstract Generates a little endian physical scatter/gather list from a
given mbuf.
@discussion Generate a little endian physical scatter/gather list from a
given mbuf. Coalesce mbuf chain when the number of segments in the
scatter/gather list exceeds numVectorSegments.
@param packet The mbuf packet.
@param vector Pointer to an array of IOPhysicalSegments for the output
physical scatter/gather list.
@param numVectorSegments Maximum number of IOPhysicalSegments accepted.
@result Returns the number of segments that were filled in, or
0 if an error occurred.
*/
UInt32 getPhysicalSegmentsWithCoalesce(mbuf_t packet,
struct IOPhysicalSegment * vector,
UInt32 numVectorSegments = 0);
};
#ifdef __ppc__
struct IODBDMADescriptor;
//===========================================================================
//===========================================================================
/*! @class IOMbufDBDMAMemoryCursor
@abstract An IOMbufMemoryCursor subclass that outputs a vector of
IODBDMADescriptors.
*/
class IOMbufDBDMAMemoryCursor : public IOMbufMemoryCursor
{
OSDeclareDefaultStructors(IOMbufDBDMAMemoryCursor)
public:
/*! @function withSpecification
@abstract Factory function that creates and initializes an
IOMbufDBDMAMemoryCursor in one operation.
@discussion See also IOMbufMemoryCursor::initWithSpecification.
@param maxSegmentSize Maximum allowable size for one segment.
@param maxNumSegments Maximum number of segments.
@result Returns a new mbuf cursor if successfully created and initialized,
0 otherwise.
*/
static IOMbufDBDMAMemoryCursor * withSpecification(UInt32 maxSegmentSize,
UInt32 maxNumSegments);
/*! @function getPhysicalSegments
@abstract Generates a DBDMA descriptor list from a given mbuf.
@param packet The mbuf packet.
@param vector Pointer to an array of IODBDMADescriptor for the output list.
@param numVectorSegments Maximum number of IODBDMADescriptors accepted.
@result Returns the number of segments that were filled in, or
0 if an error occurred.
*/
UInt32 getPhysicalSegments(mbuf_t packet,
struct IODBDMADescriptor *vector,
UInt32 numVectorSegments = 0);
/*! @function getPhysicalSegmentsWithCoalesce
@abstract Generates a DBDMA descriptor list from a given mbuf.
@discussion Generate a DBDMA descriptor list from a given mbuf.
Coalesce mbuf chain when the number of elements in the list exceeds
numVectorSegments.
@param packet The mbuf packet.
@param vector Pointer to an array of IODBDMADescriptor for the output list.
@param numVectorSegments Maximum number of IODBDMADescriptors accepted.
@result Returns the number of segments that were filled in, or
0 if an error occurred.
*/
UInt32 getPhysicalSegmentsWithCoalesce(mbuf_t packet,
struct IODBDMADescriptor * vector,
UInt32 numVectorSegments = 0);
};
#endif /* __ppc__ */
#endif /* !_IOKIT_NETWORK_IOMBUFMEMORYCURSOR_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/network/IONetworkController.h | /*
* Copyright (c) 1998-2008 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* The contents of this file constitute Original Code as defined in and
* are subject to the Apple Public Source License Version 1.1 (the
* "License"). You may not use this file except in compliance with the
* License. Please obtain a copy of the License at
* http://www.apple.com/publicsource and read it before using this file.
*
* This Original Code and all software distributed under the License are
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _IONETWORKCONTROLLER_H
#define _IONETWORKCONTROLLER_H
/*! @defined kIONetworkControllerClass
@abstract The name of the IONetworkController class. */
#define kIONetworkControllerClass "IONetworkController"
/*! @defined kIOVendor
@abstract A property of IONetworkController objects.
@discussion The kIOVendor property is a property of IONetworkController objects. It has an OSString value that describes the vendor of the network controller. */
#define kIOVendor "IOVendor"
/*! @defined kIOModel
@abstract A property of IONetworkController objects.
@discussion The kIOModel property is a property of IONetworkController objects. It has an OSString value that describes the model of the network controller. */
#define kIOModel "IOModel"
/*! @defined kIORevision
@abstract A property of IONetworkController objects.
@discussion The kIORevision property is a property of IONetworkController objects. It has an OSString value that describes the revision level of the network controller. */
#define kIORevision "IORevision"
/*! @defined kIOFeatures
@abstract A property of IONetworkController objects.
@discussion The kIOFeatures property is a property of IONetworkController objects. It has an OSNumber value that describes generic features defined by IONetworkController that are supported by the
network controller. */
#define kIOFeatures "IOFeatures"
/*! @defined kIOMediumDictionary
@abstract A property of IONetworkController objects.
@discussion The kIOMediumDictionary property is a property of IONetworkController
objects. It has an OSDictionary value that is a container for the
collection of IONetworkMedium objects that represent the media
types supported by the network controller.
Each entry in the dictionary is a key/value pair consisting of
the medium name, and a dictionary value that contains the
properties for that medium entry. */
#define kIOMediumDictionary "IOMediumDictionary"
/*! @defined kIODefaultMedium
@abstract A property of IONetworkController objects.
@discussion The kIODefaultMedium property is a property of IONetworkController
objects. It has an OSString value that describes the name of the
default medium. This definition may change or disappear in the
future. */
#define kIODefaultMedium "IODefaultMedium"
/*! @defined kIOSelectedMedium
@abstract A property of IONetworkController objects.
@discussion The kIOSelectedMedium property is a property of IONetworkController
objects. It has an OSSymbol value that describes the name of the
current selected medium. This name can be used as a key into the
medium dictionary to gather additional information about the
selected medium. */
#define kIOSelectedMedium "IOSelectedMedium"
/*! @defined kIOActiveMedium
@abstract A property of IONetworkController objects.
@discussion The kIOActiveMedium property is a property of IONetworkController
objects. It has an OSSymbol value that describes the name of the
active medium. This is the name of the medium where an active
link has been established. This name can be used as a key into
the medium dictionary to gather additional information about the
active medium. */
#define kIOActiveMedium "IOActiveMedium"
/*! @defined kIOLinkSpeed
@abstract A property of IONetworkController objects.
@discussion The kIOLinkSpeed property is a property of IONetworkController
objects. It has an OSNumber value that describes the speed of the
link established over the active medium in bits per second. */
#define kIOLinkSpeed "IOLinkSpeed"
/*! @defined kIOLinkStatus
@abstract A property of IONetworkController objects.
@discussion The kIOLinkStatus property is a property of IONetworkController
objects. It has an OSNumber value that describes the current network
link status. See IONetworkMedium for the definition of the link
status bits. */
#define kIOLinkStatus "IOLinkStatus"
/*! @defined kIOLinkData
@abstract A property of IONetworkController objects.
@discussion The kIOLinkData property is a property of IONetworkController
objects. It has an OSData value that contains additional information
describing the active link that was established.
Its interpretation is not defined. */
#define kIOLinkData "IOLinkData"
/*! @defined kIOPacketFilters
@abstract A property of IONetworkController objects.
@discussion The kIOPacketFilters property is a property of IONetworkController
objects. It has an OSDictionary value that describes the entire
set of packet filters supported by the controller. Each entry
in the dictionary is a key/value pair consisting of the filter
group name, and an OSNumber describing the set of supported
filters for that group. */
#define kIOPacketFilters "IOPacketFilters"
/*! @defined kIOMACAddress
@abstract A property of IONetworkController objects.
@discussion The kIOMACAddress property is a property of IONetworkController
objects. It has an OSData value that describes the hardware
MAC (media access controller) address, or station address,
of the network controller. */
#define kIOMACAddress "IOMACAddress"
/*! @defined kIOMaxPacketSize
@abstract A property of IONetworkController objects.
@discussion The kIOMaxPacketSize property is a property of IONetworkController
objects. It has an OSNumber value that describes the maximum
packet size supported by the controller. */
#define kIOMaxPacketSize "IOMaxPacketSize"
/*! @defined kIOMinPacketSize
@abstract A property of IONetworkController objects.
@discussion The kIOMinPacketSize property is a property of IONetworkController
objects. It has an OSNumber value that describes the minimum
packet size supported by the controller. */
#define kIOMinPacketSize "IOMinPacketSize"
/*! @defined kIONetworkFilterGroup
@abstract The name assigned to the standard network filter group. */
#define kIONetworkFilterGroup "IONetworkFilterGroup"
/*! @enum StandardPacketFilters
@abstract All standard packet filters.
@discussion Each filter will allow the reception of certain class of packets
depending on its destination MAC address.
@constant kIOPacketFilterUnicast Reception of unicast packets.
@constant kIOPacketFilterBroadcast Reception of broadcast packets.
@constant kIOPacketFilterMulticast Reception of multicast packets
addressed to a set of multicast addresses.
@constant kIOPacketFilterMulticastAll Reception of all multicast
packets.
@constant kIOPacketFilterPromiscuous Reception of all packets.
@constant kIOPacketFilterPromiscuousAll Reception of all packets,
including bad packets. */
enum {
kIOPacketFilterUnicast = 0x1,
kIOPacketFilterBroadcast = 0x2,
kIOPacketFilterMulticast = 0x10,
kIOPacketFilterMulticastAll = 0x20,
kIOPacketFilterPromiscuous = 0x100,
kIOPacketFilterPromiscuousAll = 0x200
};
/*! @enum Network Feature Flags
@abstract Feature flags returned by the getFeatures() method.
@constant kIONetworkFeatureNoBSDWait Set this bit in the value
returned by getFeatures() to disable the automatic wait for
"IOBSD" resource by the IONetworkController::start() method.
@constant kIONetworkFeatureHardwareVlan Set this bit in the value
returned by getFeatures() to indicate the controller supports hardware
stripping and stuffing of 802.1q vlan tags. If the controller supports
this feature it must enable it when initializing so that all received
packets delivered to higher layers have the tag stripped. The controller
should use setVlanTag() to provide the tag information out of band.
@constant kIONetworkFeatureSoftwareVlan Set this bit in the value
returned by getFeatures() to indicate that the controller can support software
based vlan by transmitting and receiving packets 4 bytes longer that normal.
@constant kIONetworkFeatureMultiPages Set this bit if the driver is
capable of handling packets coming down from the network stack that
reside in virtually, but not in physically contiguous span of the
external mbuf clusters. In this case, the data area of a packet in
the external mbuf cluster might cross one or more physical pages that
are disjoint, depending on the interface MTU and the packet size.
Such a use of larger than system page size clusters by the network
stack is done for better system efficiency. Drivers that utilize the
IOMbufNaturalMemoryCursor with the getPhysicalSegmentsWithCoalesce
interfaces and enumerate the list of vectors should set this flag
for possible gain in performance during bulk data transfer.
@constant kIONetworkFeatureTSOIPv4 Set this bit to advertise support
for TCP/IPv4 segmentation offload.
@constant kIONetworkFeatureTSOIPv6 Set this bit to advertise support
for TCP/IPv6 segmentation offload.
@constant kIONetworkFeatureTransmitCompletionStatus Set this bit to
advertise the capability to report per-packet transmit completion status.
See <code>IONetworkInterface::reportTransmitCompletionStatus</code>.
@constant kIONetworkFeatureHWTimeStamp Set this bit to advertise
the capability to compute per-packet timestamp in hardware.
@constant kIONetworkFeatureHWTimeStamp Set this bit to advertise
the capability to compute per-packet timestamp in software.
*/
enum {
kIONetworkFeatureNoBSDWait = 0x001,
kIONetworkFeatureHardwareVlan = 0x002,
kIONetworkFeatureSoftwareVlan = 0x004,
kIONetworkFeatureMultiPages = 0x008,
kIONetworkFeatureTSOIPv4 = 0x010,
kIONetworkFeatureTSOIPv6 = 0x020,
kIONetworkFeatureTransmitCompletionStatus = 0x040,
kIONetworkFeatureHWTimeStamp = 0x080,
kIONetworkFeatureSWTimeStamp = 0x100
};
#ifdef KERNEL
#ifdef __cplusplus
#include <IOKit/IOService.h>
#include <IOKit/IOWorkLoop.h>
#include <IOKit/network/IONetworkInterface.h>
#include <IOKit/network/IOKernelDebugger.h>
class IOCommandGate;
class IOOutputQueue;
class IONetworkMedium;
/*! @typedef IOPacketBufferConstraints
@discussion Constraint parameters, specified by a driver,
for the data buffer in a packet mbuf. This is observed by
allocatePacket() to satisfy the stated requirements.
@field alignStart Starting address byte alignment.
@field alignLength Buffer length byte alignment. */
typedef struct {
UInt32 alignStart;
UInt32 alignLength;
UInt32 reserved[6];
} IOPacketBufferConstraints;
// Some frequently used alignment constants.
//
enum {
kIOPacketBufferAlign1 = 1,
kIOPacketBufferAlign2 = 2,
kIOPacketBufferAlign4 = 4,
kIOPacketBufferAlign8 = 8,
kIOPacketBufferAlign16 = 16,
kIOPacketBufferAlign32 = 32
};
/*! @const gIONetworkFilterGroup
@discussion gIONetworkFilterGroup is an OSSymbol object that contains
the name of the standard network filter group as defined by
kIONetworkFilterGroup. */
extern const OSSymbol * gIONetworkFilterGroup;
/*! @class IONetworkController
@abstract Implements the framework for a generic
network controller.
@discussion A subclass of IONetworkController must provide
additional functionality specific for a particular networking type.
In addition, the driver must implement (override) a basic set of
hardware dependent methods to create a working driver.
IONetworkController attaches itself to the data link layer (DLIL) via
an IONetworkInterface object. A controller object without a companion
interface is not accessible to the networking system. The controller
interacts with DLIL by calling methods defined by the interface object.
And conversely, DLIL will issue commands and packets to the controller
through the interface object.
IONetworkController will create an IOCommandGate and attach this
event source to an IOWorkLoop object. All commands sent from the
interface object are handled through the IOCommandGate object,
which will serialize access to the controller. Outbound packets sent
from the interface to the controller have no implicit serialization.
Drivers must implement an output function that is thread safe, or use
an IOOutputQueue object which will provide a serialization model.
Note: IONetworkController internally uses some private messaging constants
in the sys_iokit | sub_iokit_networking range defined in
"IONetworkControllerPrivate.h". If you create a client for your controller
(for example an IOUserClient), and it overrides the IOService::message
method, your client may receive these messages. It should ignore these
messages and pass them to super::message()
*/
class __exported IONetworkController : public IOService
{
OSDeclareAbstractStructors( IONetworkController )
private:
IOWorkLoop * _workLoop;
IOCommandGate * _cmdGate;
IOOutputQueue * _outputQueue;
OSSet * _clientSet;
OSCollectionIterator * _clientSetIter;
OSObject * _cmdClient;
UInt32 _alignStart;
UInt32 _alignLength;
UInt32 _alignPadding;
bool _propertiesPublished;
IOLock * _mediumLock;
IODebuggerLockState _debugLockState;
SInt32 _debugLockCount;
OSNumber * _linkStatus;
OSNumber * _linkSpeed;
const OSData * _lastLinkData;
const OSSymbol * _lastActiveMediumName;
const OSSymbol * _lastCurrentMediumName;
mbuf_t _freeList;
struct ExpansionData { };
/*! @var reserved
Reserved for future use. (Internal use only) */
ExpansionData * _reserved;
bool _broadcastEvent(UInt32 type, void * data = 0);
static void debugRxHandler(IOService * handler,
void * buffer,
UInt32 * length,
UInt32 timeout);
static void debugTxHandler(IOService * handler,
void * buffer,
UInt32 length);
static UInt32 debugLinkStatusHandler(IOService * handler);
static bool debugSetModeHandler(IOService * handler, bool active);
static IOReturn executeCommandAction(OSObject * owner,
void * arg0,
void * arg1,
void * arg2,
void * arg3);
static IOReturn handleCommand(void * target,
void * param0,
void * param1,
void * param2,
void * param3);
public:
/*! @function init
@abstract Initializes the IONetworkController object.
@discussion Instance variables are initialized, then super::init()
is called.
@param properties A dictionary object containing a property table
associated with this instance.
@result Returns true on success, false otherwise.
*/
virtual bool init(OSDictionary * properties) APPLE_KEXT_OVERRIDE;
/*! @function start
@abstract Starts the network controller.
@discussion After the controller driver has successfully matched
to a provider, this method is called to start the network controller.
IONetworkController will allocate resources and gather controller
properties in its implementation. No I/O will be performed until
the subclass tries to attach a client object. A driver must override
this method, and call super::start() at the beginning of its own
implementation. Then check the return value to make sure that its
superclass was started successfully before proceeding. Tasks that
are usually performed by a driver's start method are: resource
allocation, hardware initialization, allocation of IOEventSources
and attaching them to a workloop, publishing a medium dictionary,
and finally, attaching an interface object when it is ready to
handle client requests.
@param provider The provider that the controller was matched
(and attached) to.
@result Returns true on success, false otherwise.
*/
virtual bool start(IOService * provider) APPLE_KEXT_OVERRIDE;
/*! @function stop
@abstract Stops the network controller.
@discussion The counterpart of start(). The controller has been
instructed to stop running. The stop() method should release
resources and undo actions performed by the start() method.
Subclasses must override this method and call super::stop()
at the end of its implementation.
@param provider The provider that the controller was matched
(and attached) to. */
virtual void stop(IOService * provider) APPLE_KEXT_OVERRIDE;
/*! @function message
@abstract Receives messages delivered from an attached provider.
@discussion Handles the <code>kIOMessageDeviceSignaledWakeup</code> message
from a provider identifying the IONetworkController as the wakeup source.
@param type A type defined in <code>IOMessage.h</code>.
@param provider The provider from which the message originates.
@param argument An argument defined by the message type.
@result An IOReturn code defined by the message type.
*/
virtual IOReturn message(
UInt32 type, IOService * provider, void * argument ) APPLE_KEXT_OVERRIDE;
/*! @typedef IONetworkController::Action
@discussion Definition of a C function that can be called
through executeCommand().
@param target The first argument passed to action.
@param param0 Action parameter 0.
@param param1 Action parameter 1.
@param param2 Action parameter 2.
@param param3 Action parameter 3. */
typedef IOReturn (*Action)(void * target, void * param0,
void * param1,
void * param2,
void * param3);
/*! @function executeCommand
@abstract Makes a C function call through the command gate.
@discussion This method makes a call to a C function that will be synchronized
with the workloop thread, and any other threads that are called
with the workloop's gate closed.
@param client The client requesting the action. This parameter is not
passed to the function.
@param action Pointer to a C function to be executed.
@param target The first parameter in the action callout.
@param param0 Action parameter 0.
@param param1 Action parameter 1.
@param param2 Action parameter 2.
@param param3 Action parameter 3.
@result Returns the value returned by the action.
*/
virtual IOReturn executeCommand(OSObject * client,
Action action,
void * target,
void * param0 = 0,
void * param1 = 0,
void * param2 = 0,
void * param3 = 0);
/*! @function outputPacket
@abstract Transmits an output packet.
@discussion If an IOOutputQueue was created by createOutputQueue(),
then this method will be called by the output queue object.
Otherwise, an interface object will call this method directly when
it receives an output packet from the data link layer.
There is no upper limit on the number of mbufs, hence the number of
memory fragments, in the mbuf chain provided. Drivers must be able to
handle cases when the mbuf count might exceed the limit supported by their
DMA engines, and perform coalescing to copy the various memory fragments
into a lesser number of fragments. This complexity can be hidden from
the driver when an IOMbufMemoryCursor is used, which is able to convert
an mbuf chain into a physical address scatter-gather list that will not
exceed a specified number of physically contiguous memory segments.
See IOMbufMemoryCursor.
The implementation in IONetworkController performs no useful action
and will drop all packets. A driver must override this method and
process the output packet provided. The implementation in the driver
must not block, since this may cause the network stack to be reentered
from an unsafe point.
@param mbuf_t An mbuf chain containing the output packet to be sent on
the network.
@param param A parameter provided by the caller.
@result Returns a return code defined by the caller.
*/
virtual UInt32 outputPacket(mbuf_t m, void * param);
/*! @function getFeatures
@abstract Reports generic features supported by the controller and/or
the driver.
@result This method will always return 0. Subclasses may override
this method and return a bit mask of all supported features. */
virtual UInt32 getFeatures() const;
/*! @function newVendorString
@result Returns a string describing the vendor of the network controller.
The caller is responsible for releasing the string object returned. */
virtual const OSString * newVendorString() const;
/*! @function newModelString
@result Returns a string describing the model of the network controller.
The caller is responsible for releasing the string object returned. */
virtual const OSString * newModelString() const;
/*! @function newRevisionString
@result Returns a string describing the hardware revision of the
network controller. The caller is responsible for releasing the
string object returned. */
virtual const OSString * newRevisionString() const;
/*! @function getSelectedMedium
@abstract Gets the current selected medium.
@discussion If the driver has previously called setSelectedMedium()
to indicate its current media selection, then this method will return
that medium object. Otherwise, the driver's property table is
consulted and a default medium property is examined, and the
corresponding entry in the medium dictionary is returned.
@result Returns the current selected medium, the default medium, or 0.
*/
virtual const IONetworkMedium * getSelectedMedium() const;
const IONetworkMedium * getCurrentMedium() const;
/*! @function getMediumDictionary
@abstract Returns the medium dictionary published by the driver.
@discussion Returns the medium dictionary published by the driver
through publishMediumDictionary(). Use copyMediumDictionary() to
create and get a copy of the medium dictionary.
@result Returns the published medium dictionary, or 0 if the driver has not
yet published a medium dictionary through publishMediumDictionary().
*/
virtual const OSDictionary * getMediumDictionary() const;
/*! @function copyMediumDictionary
@abstract Returns a copy of the medium dictionary published by the
driver.
@discussion The caller is responsible for releasing the dictionary
object returned. Use getMediumDictionary() to get a reference to the
published medium dictionary instead of creating a copy.
@result Returns a copy of the medium dictionary, or 0 if the driver has not
published a medium dictionary through publishMediumDictionary().
*/
virtual OSDictionary * copyMediumDictionary() const;
/*! @function getOutputHandler
@abstract Gets the address of the method designated to handle output
packets for the network controller.
@result Returns a pointer to the outputPacket() method.
*/
virtual IOOutputAction getOutputHandler() const;
/*! @function doEnable
@abstract Makes a synchronized call to enable() through executeCommand().
@discussion Do not use this method, it may be removed in the future.
See enable().
*/
virtual IOReturn doEnable(IOService * client);
/*! @function doDisable
@abstract Makes a synchronized call to disable() through executeCommand().
@discussion Do not use this method, it may be removed in the future.
See disable().
*/
virtual IOReturn doDisable(IOService * client);
/*! @function getCommandGate
@abstract Gets the IOCommandGate object created by IONetworkController.
@discussion When IONetworkController is started, an IOCommandGate object
is instantiated and attached to the workloop returned by getWorkLoop().
This IOCommandGate object is used internally to synchronize client
commands handled through executeCommand(). Subclasses that need an
IOCommandGate should try to reuse the object returned by this method,
rather than creating a new instance. See IOCommandGate documentation.
@result Returns the IOCommandGate object created by IONetworkController.
*/
virtual IOCommandGate * getCommandGate() const;
/*! @function getHardwareAddress
@abstract Gets the network controller's permanent hardware/station
address.
@discussion This method call is synchronized by the workloop's gate.
@param addr The buffer where the controller's hardware address should
be stored.
@param inOutAddrBytes The size of the address buffer provided by the
client, and replaced by this method with the actual size of
the hardware address in bytes.
@result Returns kIOReturnSuccess on success, or an error otherwise.
*/
virtual IOReturn getHardwareAddress(void * addr,
UInt32 * inOutAddrBytes) = 0;
/*! @function setHardwareAddress
@abstract Sets or changes the station address used by the network
controller.
@discussion This method call is synchronized by the workloop's gate.
@param addr The buffer containing the hardware address provided by
the client.
@param addrBytes The size of the address buffer provided by the
client in bytes.
@result Returns kIOReturnSuccess on success, or an error otherwise.
*/
virtual IOReturn setHardwareAddress(const void * addr,
UInt32 addrBytes) = 0;
/*! @function enable
@abstract Handles an enable request from a client.
@discussion This method handles an enable request from a client. A client will call
enable after it has opened the controller, and before it starts to use
the controller to send and to receive packets over the network. The
client object provided is typecasted using OSDynamicCast, and depending
on whether the client is an IOKernelDebugger or an IONetworkInterface,
then an overloaded enable method that takes a more specific argument
type is called. If the client matches neither type, then
kIOReturnBadArgument is returned. A driver has the option of overriding
this base enable method, or the overloaded form. This method call is
synchronized by the workloop's gate.
@param client The client object requesting the enable.
@result Returns the return value from the overloaded enable() method, or
kIOReturnBadArgument if the client type is unknown.
*/
virtual IOReturn enable(IOService * client);
/*! @function disable
@abstract Handles a disable request from a client.
@discussion This method handles a disable request from a client. A client will call
disable if it has previously enabled the controller, and it no longer
needs to transport packets or perform I/O using the controller.
The client object is typecasted using OSDynamicCast, and depending on
whether the client is an IOKernelDebugger or an IONetworkInterface,
then an overloaded disable method that takes a more specific argument
type is called. If the client matches neither type, then
kIOReturnBadArgument is returned. A driver has the option of overriding
this base disable method, or the overloaded form. This method call is
synchronized by the workloop's gate.
@param client The client object requesting the disable.
@result Returns the return from the overloaded disable() method, or
kIOReturnBadArgument if the client type is unknown.
*/
virtual IOReturn disable(IOService * client);
/*! @function setMaxPacketSize
@abstract A client request to change the maximum packet size.
@discussion This method call is synchronized by the workloop's gate.
@param maxSize The new maximum packet size.
@result Returns kIOReturnUnsupported. Drivers may override this method
and return either kIOReturnSuccess to indicate that the new size
was accepted and is in effect, or an error code to indicate failure.
*/
virtual IOReturn setMaxPacketSize(UInt32 maxSize);
/*! @function getMaxPacketSize
@abstract Gets the maximum packet size supported by the controller.
@param maxSize Pointer to the return value.
@result Returns kIOReturnSuccess on success, or an error code otherwise.
*/
virtual IOReturn getMaxPacketSize(UInt32 * maxSize) const = 0;
/*! @function getMinPacketSize
@abstract Gets the minimum packet size supported by the controller.
@param minSize Pointer to the return value.
@result Returns kIOReturnSuccess on success, or an error code otherwise.
*/
virtual IOReturn getMinPacketSize(UInt32 * minSize) const = 0;
/*! @function selectMedium
@abstract A client request to change the medium selection.
@discussion This method is called when a client issues a command
for the controller to change its current medium selection.
The implementation must call setSelectedMedium() after the change
has occurred. This method call is synchronized by the workloop's
gate.
@param medium An entry from the published medium dictionary that
represents the selection chosen by the client.
@result Returns kIOReturnUnsupported. Drivers may override this method and
return kIOReturnSuccess if the selection was successful,
or an error code otherwise.
*/
virtual IOReturn selectMedium(const IONetworkMedium * medium);
/*! @function selectMediumWithName
@abstract A client request to change the medium selection.
@discussion This method is called when a client issues a command
for the controller to change its current medium selection.
This implementation will look for an entry in the medium
dictionary published by the driver that is associated with the
key given. If a match is found, then selectMedium() is called to
perform the selection, otherwise an error is reported back to the
client. Subclasses should override selectMedium() and not this
method. This method call is synchronized by the workloop's gate.
@param mediumName An OSSymbol object that describes the name of the
new medium selected by the client.
@result Returns the return from selectMedium() if a matching entry was found
from the medium dictionary. Returns kIOReturnUnsupported if a medium
dictionary does not exist, or kIOReturnBadArgument if the name given
does not match any entry in the medium dictionary.
*/
virtual IOReturn selectMediumWithName(const OSSymbol * mediumName);
/*! @function getPacketFilters
@abstract Gets the set of packet filters supported by the network
controller for the given filter group.
@discussion A subclass must implement this method and report the
set of filters that are supported for the given filter group.
This method call is synchronized by the workloop's gate.
@param group The name of the filter group.
@param filters Pointer to the mask of supported filters returned by
this method.
@result Returns kIOReturnSuccess on success, or an error to indicate a
failure to discover the set of supported filters.
*/
virtual IOReturn getPacketFilters(const OSSymbol * group,
UInt32 * filters) const = 0;
/*! @function enablePacketFilter
@abstract Enables one of the supported packet filters from the
given filter group.
@discussion A client will call this method to enable a supported filter
from the filter group specified. If the client wishes to enable more
than one filter, it must call this method multiple times to enable the
desired set of filters. This method call is synchronized by the
workloop's gate.
@param group The name of the filter group containing the filter to be
enabled.
@param aFilter The filter to enable.
@param enabledFilters All filters currently enabled by the client.
@param options Optional flags for the enable request.
@result Returns kIOReturnSuccess on success, or an error otherwise.
*/
virtual IOReturn enablePacketFilter(const OSSymbol * group,
UInt32 aFilter,
UInt32 enabledFilters,
IOOptionBits options = 0) = 0;
/*! @function disablePacketFilter
@abstract Disables a packet filter that is currently enabled from the
given filter group.
@discussion After a supported filter has been successfully enabled,
a client can call this method to disable that filter. This method call
is synchronized by the workloop's gate.
@param group The name of the filter group containing the filter to be
disabled.
@param aFilter The filter to disable.
@param enabledFilters All filters currently enabled by the client.
@param options Optional flags for the disable request.
@result Returns kIOReturnSuccess on success, or an error otherwise.
*/
virtual IOReturn disablePacketFilter(const OSSymbol * group,
UInt32 aFilter,
UInt32 enabledFilters,
IOOptionBits options = 0) = 0;
/*! @function getOutputQueue
@abstract Gets the IOOutputQueue object created by createOutputQueue().
@result Returns a reference to the output queue object created by
createOutputQueue().
*/
virtual IOOutputQueue * getOutputQueue() const;
/*! @function getPacketBufferConstraints
@abstract Gets the controller's packet buffer constraints.
@discussion Called by start() to obtain the constraints on the
memory buffer for each mbuf packet allocated through allocatePacket().
Drivers can override this method to specify the buffer constraints
imposed by their bus master hardware. Note that outbound packets,
those that originate from the network stack, are not currently
subject to the constraints reported here.
@param constraints A pointer to an IOPacketBufferConstraints
structure that this method is expected to initialize.
See IOPacketBufferConstraints structure definition.
*/
virtual void getPacketBufferConstraints(
IOPacketBufferConstraints * constraints) const;
/*! @function allocatePacket
@abstract Allocates a packet with a data buffer that is larger than
or equal to the size specified.
@discussion This method will always return a single mbuf unless the
size requested (plus the alignment padding) is greater than MCLBYTES.
The data buffer for the mbuf (or an mbuf chain) returned is aligned
according to the constraints reported by getPacketBufferConstraints().
The length fields in each mbuf returned are set by this method, thus
allowing the mbuf to be passed directly to an IOMbufMemoryCursor object
in order to convert the mbuf to a physical address scatter-gather list.
@param size The minimum size of the data buffer for the mbuf
packet allocated.
@result Returns an mbuf packet, or 0 if allocation failed.
*/
virtual mbuf_t allocatePacket(UInt32 size);
/*! @function copyPacket
@abstract Allocates a new packet, containing data copied from an
existing source packet.
@discussion The source packet is not modified by this method.
@param m The source packet.
@param size The number of bytes to copy. If set to 0, then the
entire data buffer from the source packet is copied.
@result Returns a new packet containing the same data as the source packet.
*/
virtual mbuf_t copyPacket(const mbuf_t m, UInt32 size = 0);
/*! @function replacePacket
@abstract Allocates a new packet to replace an existing packet, the
existing packet is then returned.
@param mp A handle to the existing packet.
@param size If size is 0, then the new packet shall have the same buffer
size as the original packet that is being replaced. Otherwise, the new
packet shall have the buffer size specified by this value.
@result If packet allocation was successful, then a replacement will
take place and the original packet will be returned. Otherwise, 0
is returned, and the original packet will be left untouched.
*/
virtual mbuf_t replacePacket(mbuf_t * mp, UInt32 size = 0);
/*! @function replaceOrCopyPacket
@abstract A helper method that combines the functionality of
copyPacket() and replacePacket() to process a packet containing
a received frame.
@discussion This method will either make a copy or replace the existing
packet, whichever is more time efficient. Packets containing small frames
are copied, otherwise they are replaced. If replaced, then the existing
packet is returned, and a new packet with the same buffer size is created
to take its place. If copied, the existing packet is left intact, while a
copy is returned that will hold a copy of the data from the source packet.
@param mp A handle to the existing packet that may be replaced.
@param length The number of bytes received held in the packet.
Must be greater than zero.
@param replaced Pointer to a return value that is set to true to indicate
that the existing packet was replaced, or false to indicate that the
existing packet was not replaced, and a copy was created.
@result Returns a replacement or a copy of the existing packet, or 0 if packet
allocation failed.
*/
virtual mbuf_t replaceOrCopyPacket(mbuf_t * mp,
UInt32 length,
bool * replaced);
enum {
kDelayFree = 0x01
};
/*! @function freePacket
@abstract Releases the packet given back to the free pool.
@param mbuf_t The packet to be freed.
@param options When kDelayFree option is set, then the packet
provided to this function will be queued on the free packet queue.
A subsequent call to releaseFreePackets() will release all queued
packets by making a single BSD function call. Without the kDelayFree
option, the packet provided will be released immediately.
*/
virtual void freePacket(mbuf_t, IOOptionBits options = 0);
/*! @function releaseFreePackets
@abstract Releases all packets held in the free packet queue.
@discussion The free packet queue is not protected by a lock. This
function must be called in a single-threaded manner with respect to
all calls to freePacket() with the kDelayFree option set.
@result Returns the number of packets queued and released.
*/
virtual UInt32 releaseFreePackets();
/*! @enum TCP/IP Checksums
@abstract TCP/IP checksums that may be supported by the
hardware.
@constant kChecksumFamilyTCPIP A value that describes the collection
of TCP/IP checksums.
@constant kChecksumIP An IP header checksum.
@constant kChecksumTCP A TCP checksum that covers the TCP header and TCP
data.
@constant kChecksumUDP A UDP checksum that covers the UDP header and UDP
data.
@constant kChecksumTCPIPv6 A TCP checksum that covers the IPv6 pseudo header,
TCP header and TCP data.
@constant kChecksumUDPIPv6 A UDP checksum that covers the IPv6 pseudo header,
UDP header and UDP data.
@constant kChecksumTCPNoPseudoHeader A TCP checksum that covers the TCP
header and the TCP data, but the pseudo header is not included in the
checksum computation. A partial 16-bit checksum value must be provided
to allow the protocol stacks to calculate and verify the final checksum.
This type of checksum is not currently supported on the output path.
@constant kChecksumUDPNoPseudoHeader A UDP checksum that covers the UDP
header and the UDP data, but the pseudo header is not included in the
checksum computation. A partial 16-bit checksum value must be provided
to allow the protocol stacks to calculate and verify the final checksum.
This type of checksum is not currently supported on the output path.
@constant kChecksumTCPSum16 The hardware has a simple checksum engine
that can perform a TCP style ones complement sum of 16-bit words over
a certain range of bytes in a packet. The hardware does not have the
ability to scan for IP or TCP headers, and the driver must pass/get
additional parameter(s) to or from the protocol stack to coordinate
the checksumming effort.
*/
enum {
kChecksumFamilyTCPIP = 0x00000001,
kChecksumIP = 0x0001,
kChecksumTCP = 0x0002,
kChecksumUDP = 0x0004,
kChecksumTCPIPv6 = 0x0020,
kChecksumUDPIPv6 = 0x0040,
kChecksumTCPNoPseudoHeader = 0x0100,
kChecksumUDPNoPseudoHeader = 0x0200,
kChecksumTCPSum16 = 0x1000
};
/*! @function getChecksumSupport
@abstract Gets checksums that are supported by the network controller for
the given checksum family.
@discussion A network controller that is capable of inserting and verifying
checksums on output and input packets, should override this method and
advertise its capability in order to assist or offload the software checksum
calculations performed by the protocol stacks.
@param checksumMask A pointer to the mask of supported checksums returned
by this method.
@param checksumFamily A value that specifies the checksum family.
@param isOutput Set to true to query the support for checksum insertion on
output packets, or false to query the support for checksum verification
on input packets. Controllers that have symmetric hardware checksum support
can return a fixed checksum mask value, and ignore this argument.
@result Default return is kIOReturnUnsupported. Controllers that override
this method must return kIOReturnSuccess. Any other return value will be
interpretated as a lack of checksum support, regardless of the value
returned through the first argument.
*/
virtual IOReturn getChecksumSupport( UInt32 * checksumMask,
UInt32 checksumFamily,
bool isOutput );
/*! @function setChecksumResult
@abstract Encodes a received packet with the checksum result reported
by the hardware.
@discussion A network controller that can verify the checksum(s) for a
received packet, should call this method to encode the result on the
packet, before passing it up towards the protocol stacks.
@param packet An mbuf containing a packet that has been checksummed by
the hardware.
@param checksumFamily A value that specifies the checksum family.
@param resultMask A mask of all checksums that were checked or computed.
Setting a bit implies that the driver is able to report the result of
the checksum computation, by asserting the validity of the checksum,
or by returning a partial checksum value.
@param validMask A mask of all checksums are were computed and verified
by the hardware as valid. Certain types of checksum performed by the
hardware are inheritely incomplete, and therefore should never be marked
as valid. A checksum cannot be marked valid unless it has also been
checked.
@param param0 Optional parameter 0, defaults to 0.
@param param1 Optional parameter 1, defaults to 0.
@result Returns true if the checksum family is valid and the packet has been
encoded with the checksum result provided, false otherwise.
*/
virtual bool setChecksumResult( mbuf_t packet,
UInt32 checksumFamily,
UInt32 resultMask,
UInt32 validMask,
UInt32 param0 = 0,
UInt32 param1 = 0 );
/*! @function getChecksumDemand
@abstract Fetches the demand for hardware checksum computation and insertion
for the given packet before it is transmitted on the network.
@discussion A network controller that can insert a checksum for output
packets must call this method to obtain the set of checksums that it must
compute, and insert into the appropriate fields in the given output packet.
@param packet An mbuf containing a packet that may be missing one or more
checksums in the specified checksum family.
@param checksumFamily A value that specifies the checksum family.
@param demandMask A mask of all checksums that the hardware must compute
and insert into the appropriate checksum fields in the packet.
@param param0 Optional parameter 0, defaults to 0.
@param param1 Optional parameter 1, defaults to 0.
*/
virtual void getChecksumDemand( const mbuf_t packet,
UInt32 checksumFamily,
UInt32 * demandMask,
void * param0 = 0,
void * param1 = 0 );
/*! @function publishMediumDictionary
@abstract Publishes a dictionary of IONetworkMedium objects to
advertise the media selection supported by the network controller.
@discussion Called by drivers to publish their medium dictionary.
Each entry in the dictionary is an IONetworkMedium object that
represents a single medium that is supported by the controller.
This method will make a copy of the dictionary provided, then add
the copy to the driver's property table. The dictionary provided
can be released by the caller upon returning from this method.
It is permissible to call this method multiple times, which may be
necessary if the hardware's media capability changes dynamically.
However, if the capability is static, which is often the case,
then a driver will typically call this method only once from
its start() method.
Several methods depend on the presence of a medium dictionary.
They should be called after the medium dictionary has been
published. Those methods are:
setSelectedMedium()
getSelectedMedium()
getMediumDictionary()
copyMediumDictionary()
@param mediumDict A dictionary of IONetworkMedium objects.
@result Returns true if the dictionary is valid, and was successfully
exported to the property table, false otherwise.
*/
virtual bool publishMediumDictionary(const OSDictionary * mediumDict);
/*! @function setSelectedMedium
@abstract Designates an entry in the published medium dictionary as
the current selected medium.
@discussion After the driver has configured the hardware to select
one of its supported media types, it must call this method to inform
its parent about the change that has occurred. IONetworkController
will update a property in the registry to reflect the current selection.
@param medium A medium object representing the current selection.
@result Returns true if the property table update was successful,
false if the update failed, or if the medium provided does not match
any entry from the published medium dictionary.
*/
virtual bool setSelectedMedium(const IONetworkMedium * medium);
bool setCurrentMedium(const IONetworkMedium * medium);
/*! @function setLinkStatus
@abstract Reports the link status and the active medium.
@discussion Drivers must call this method when a link change is
detected. IONetworkController will update the link status properties
in the registry, and generate an event to inform the upper layers
about the change.
@param status Link status bits.
See IONetworkMedium for the definition of the link status bits.
@param activeMedium An object in the published medium dictionary
that represents the active medium. This may not be the same as
the selected medium. Set this to 0 if the link is inactive.
@param speed Link speed in units of bits per second. If zero, then
the link speed is taken from the medium object provided.
@param data An OSData containing any additional link parameter that
the driver wishes to publish to the registry.
@result Returns true if all link properties were successfully updated,
false otherwise.
*/
virtual bool setLinkStatus(
UInt32 status,
const IONetworkMedium * activeMedium = 0,
UInt64 speed = 0,
OSData * data = 0);
/*! @function systemWillShutdown
@abstract Handles system shutdown and restart notifications.
@discussion Overrides <code>IOService::systemWillShutdown</code> in order
to notify network clients that the power-managed controller should be disabled.
As a result, drivers can expect their <code>disable</code> method to be called
before system shutdown or restart. This implementation is synchronous and can
block before calling <code>IOService::systemWillShutdown</code> and return.
@param specifier
<code>kIOMessageSystemWillPowerOff</code> or <code>kIOMessageSystemWillRestart</code>.
@see //apple_ref/cpp/instm/IOService/systemWillShutdown/void/(IOOptionBits) IOService::systemWillShutdown
*/
virtual void systemWillShutdown( IOOptionBits specifier ) APPLE_KEXT_OVERRIDE;
/* Override IOService::setAggressiveness() */
virtual IOReturn setAggressiveness(
unsigned long type, unsigned long newLevel ) APPLE_KEXT_OVERRIDE;
protected:
/*! @function free
@abstract Frees the IONetworkController object.
@discussion Frees the IONetworkController object by releasing all
allocated resources, followed by a call to super::free().
*/
virtual void free() APPLE_KEXT_OVERRIDE;
/*! @function registerWithPolicyMaker
@abstract Implemented by controller drivers to register with
the power management policy-maker.
@discussion Drivers that are able to power manage their hardware
should override this method and register with the policy-maker
provided by calling IOService::registerPowerDriver().
IONetworkController will call this method before the initial
attempt is made to attach a client.
@param policyMaker The policy-maker chosen to manage power for
this network controller.
@result Returns kIOReturnSuccess on success, kIOReturnUnsupported if the
driver does not support power management, or an appropriate error
return code. The default return is kIOReturnUnsupported. */
virtual IOReturn registerWithPolicyMaker(IOService * policyMaker);
/*! @function createWorkLoop
@abstract Method called by IONetworkController prior to the initial
getWorkLoop() call.
@discussion Before IONetworkController calls getWorkLoop() in its
start() method, it will call createWorkLoop() to make sure that a
subclass that wants to create a workloop, will do so before its
first use.
@result Returns true to indicate success, false otherwise. Returning false
will fail IONetworkController::start().
*/
virtual bool createWorkLoop();
/*! @function prepare
@abstract Prepares the controller before an IOService is created and
attached as a client.
@discussion This method is called by attachInterface() or
attachDebuggerClient() to prepare the controller before the new client
object is attached. This method will call publishProperties() to publish
controller capabilities and properties that may be used by client objects.
However, publishProperties() will be called only once, even if prepare()
is called multiple times. This method call is synchronized by the
workloop's gate.
@result Returns kIOReturnSuccess on success, or an error code otherwise.
Returning an error will fail the client attach.
*/
virtual IOReturn prepare();
/*! @function publishProperties
@abstract Publishes controller properties and capabilities.
@discussion Called by IONetworkController to discover controller
properties, and publish them to the property table in the I/O Kit
Registry. This method is called once by prepare().
@result Returns true if all properties were discovered and published
successfully, false otherwise. Returning false will prevent client
objects from attaching to the controller, since a property that
a client relies upon may be missing. */
virtual bool publishProperties();
/*! @function getCommandClient
@abstract Gets the command client object.
@discussion Methods called on the workloop context to service a
client request can call this method to get the client object that
initiated the command.
@result Returns the command client. If the caller is not running on the
workloop thread, or if the thread does not have the workloop's gate
closed, then 0 is returned.
*/
virtual OSObject * getCommandClient() const;
/*! @function handleOpen
@abstract Handles a client open.
@discussion This method handles a client open on the controller object. IOService
calls this method with the arbitration lock held. Subclasses
should not override this method.
@param client The client that is attempting to open the controller.
@param options Not used. See IOService.
@param argument Not used. See IOService.
@result Returns true to accept the client open, false to refuse it.
*/
virtual bool handleOpen(IOService * client,
IOOptionBits options,
void * argument) APPLE_KEXT_OVERRIDE;
/*! @function handleClose
@abstract Handles a client close.
@discussion This method handles a close from one of the client objects. IOService
calls this method with the arbitration lock held. Subclasses
should not override this method.
@param client The client that is closing the controller.
@param options Not used. See IOService.
*/
virtual void handleClose(IOService * client, IOOptionBits options) APPLE_KEXT_OVERRIDE;
/*! @function handleIsOpen
@abstract Queries whether a client has an open on the controller.
@discussion This method is always called by IOService with the
arbitration lock held. Subclasses should not override this method.
@result Returns true if the specified client, or any client if none (0) is
specified, presently has an open on this object.
*/
virtual bool handleIsOpen(const IOService * client) const APPLE_KEXT_OVERRIDE;
/*! @function enable
@abstract A request from an interface client to enable the controller.
@discussion This method is called by an interface client to enable the controller.
Upon receiving this command, the controller driver must bring up the
hardware and become ready to transmit and receive packets. A driver
should also delay the allocation of most runtime resources until this
method is called in order to conserve system resources. This method call
is synchronized by the workloop's gate.
@param interface The interface client object that requested the enable.
@result Returns kIOReturnUnsupported. Drivers that override this method must
return kIOReturnSuccess on success, or an error code otherwise.
*/
virtual IOReturn enable(IONetworkInterface * interface);
/*! @function disable
@abstract A request from an interface client to disable the controller.
@discussion This method is called by an interface client to disable the controller.
This method should stop the hardware and disable hardware interrupt
sources. Any resources allocated by enable() should also be deallocated.
This method call is synchronized by the workloop's gate.
@param interface The interface object that requested the disable.
@result kIOReturnUnsupported. Drivers that override this method must
return Returns kIOReturnSuccess on success, or an error code otherwise.
*/
virtual IOReturn disable(IONetworkInterface * interface);
/*! @function attachInterface
@abstract Attaches a new network interface client object.
@discussion This method creates a new network interface object and attaches
it as a client of the controller. The <code>createInterface()</code> method
is used to allocate and to initialize the interface, followed by a call to
<code>configureInterface()</code> to configure the interface. Subclasses
may override those two methods to customize the new interface object.
Before this method returns, <code>registerService()</code> is called on the
interface to start matching, which will ultimately attach the interface
to the networking stack.
Drivers will typically call this method from their <code>start()</code>
method after they are ready to process interface requests. This has the
desirable effect of preventing the <code>busyState</code> at the IOService
root from becoming zero before the interface object has completed matching,
which then holds off the user process that is waiting for I/O Kit to become
quiet before assigning BSD names to all interfaces. Drivers that are unable
to trigger interface matching synchronously from their <code>start()</code>
method should instead call <code>adjustBusy</code> to manually increment
the <code>busyState</code>, then followed by a <code>busyState</code>
decrement after attaching and registering the interface, or after a
reasonable timeout.
@param interface Upon success (return value is <code>true</code>), the
pointer to the interface object will be written to the argument provided.
@param doRegister If true, start interface matching before returning.
Drivers can pass <code>false</code> to postpone interface matching, then
register the interface when ready.
@result Returns <code>true</code> on success, <code>false</code> otherwise.
*/
virtual bool attachInterface(IONetworkInterface ** interface,
bool doRegister = true);
/*! @function detachInterface
@abstract Detaches an interface client object.
@discussion This method will verify that the object provided is indeed
an IONetworkInterface instance, and then call its terminate() method.
Note that an interface object will close and detach from its
controller after the data link layer has removed all references to
all data structures exposed by the interface. The interface object
should be released following this call.
@param interface An interface object to be detached and terminated.
@param sync If true, the interface is terminated synchronously.
This may cause this method to block for an indeterminate
amount of time. */
virtual void detachInterface(IONetworkInterface * interface,
bool sync = false);
/*! @function createInterface
@abstract Creates a new network interface object.
@discussion This method is called by attachInterface() to perform
allocation and initialization of a new interface object. A subclass of
IONetworkController must implement this method and return a matching
interface object. For example, IOEthernetController's implementation
will return an IOEthernetInterface object when createInterface() is
called.
@result Returns a newly allocated and initialized interface object.
*/
virtual IONetworkInterface * createInterface() = 0;
/*! @function configureInterface
@abstract Configures a newly created network interface object.
@discussion This method configures an interface object that was created by
createInterface(). Subclasses can override this method to customize
and examine the interface object that will be attached to the
controller as a client.
@param interface The interface object to be configured.
@result Returns true if the operation was successful, false otherwise
(this will cause attachInterface() to fail and return 0).
*/
virtual bool configureInterface(IONetworkInterface * interface);
/*! @function createOutputQueue
@abstract Creates an IOOutputQueue to handle output packet queueing,
and also to resolve contention for the controller's transmitter from
multiple client threads.
@discussion This method is called by start() to create an IOOutputQueue object to
handle output packet queueing. The default implementation will always
return 0, hence no output queue will be created. A driver may override
this method and return a subclass of IOOutputQueue. IONetworkController
will keep a reference to the queue created, and will release this
object when IONetworkController is freed. Also see getOutputQueue().
@result Returns a newly allocated and initialized IOOutputQueue object.
*/
virtual IOOutputQueue * createOutputQueue();
/*! @function enable
@abstract An enable request from an IOKernelDebugger client.
@discussion Drivers that provide debugging support may either override
this method and set up the hardware to support the polled-mode send and
receive methods, receivePacket() and sendPacket(), or override the base
enable() and disable() methods that take an IOService argument.
@param debugger The IOKernelDebugger client requesting the enable.
@result Returns kIOReturnSuccess. Drivers must return kIOReturnSuccess
on success, or an error otherwise.
*/
virtual IOReturn enable(IOKernelDebugger * debugger);
/*! @function disable
@abstract A disable request from an IOKernelDebugger client.
@discussion Drivers that provide debugging support may either override
this method to disable support for the polled-mode send and receive
methods, or override the base enable() and disable() methods that
take an IOService argument.
@param debugger The IOKernelDebugger client requesting the disable.
@result Returns kIOReturnSuccess. Drivers must return kIOReturnSuccess
on success, or an error otherwise.
*/
virtual IOReturn disable(IOKernelDebugger * debugger);
/*! @function attachDebuggerClient
@abstract Attaches a new IOKernelDebugger client object.
@discussion This method allocates an IOKernelDebugger object and attaches it as
a client. Having a debugger client implies that the controller
supports kernel debugging, and therefore must implement the two
polled-mode methods that are called by the debugger client. See
sendPacket() and receivePacket(). Only a single debugger client
should be attached to each controller.
@param debuggerP A handle that will return the new
IOKernelDebugger object created.
@result Returns true on success, false otherwise.
*/
virtual bool attachDebuggerClient(IOKernelDebugger ** debuggerP);
/*! @function detachDebuggerClient
@abstract Detaches an IOKernelDebugger client object.
@discussion This method detaches and terminates the IOKernelDebugger client object
provided. A synchronous termination is issued, and this method will
return after the debugger client has been terminated. The debugger
client should be released following this call.
@param debugger The IOKernelDebugger object to be detached and
terminated. If the argument provided is NULL or is not an
IOKernelDebugger, this method will return immediately.
*/
virtual void detachDebuggerClient(IOKernelDebugger * debugger);
/*! @function reserveDebuggerLock
@abstract Takes the global debugger lock.
@discussion This method should not be used. Instead, call the
lock() method provided by IOKernelDebugger.
*/
void reserveDebuggerLock();
/*! @function releaseDebuggerLock
@abstract Releases the global debugger lock.
@discussion This method should not be used. Instead, call the
unlock() method provided by IOKernelDebugger.
*/
void releaseDebuggerLock();
/*! @function receivePacket
@abstract Debugger polled-mode receive handler.
@discussion This method must be implemented by a driver that supports
kernel debugging. After a debugger client has been attached through
attachDebuggerClient(), this method will be called by the debugger
client to poll for an incoming packet when the kernel debugger is active.
This method may be called from the primary interrupt context, and the
implementation must avoid any memory allocation, and must never block.
The receivePacket() method in IONetworkController is used as a placeholder,
it performs no useful action, and should not be called. A driver that
attaches a debugger client must override this method.
@param pkt Address of a receive buffer where the received packet should
be stored. This buffer has room for 1518 bytes.
@param pktSize Address where the number of bytes received must be
recorded. Set this to zero if no packets were received during
the timeout interval.
@param timeout The maximum amount of time in milliseconds to poll for
a packet to arrive before this method must return.
*/
virtual void receivePacket(void * pkt, UInt32 * pktSize, UInt32 timeout);
/*! @function sendPacket
@abstract Debugger polled-mode transmit handler.
@discussion This method must be implemented by a driver that supports
kernel debugging. After a debugger client has been attached through
attachDebuggerClient(), this method will be called by the debugger
to send an outbound packet only when the kernel debugger is active.
This method may be called from the primary interrupt context, and the
implementation must avoid any memory allocation, and must never block.
The sendPacket() method in IONetworkController is used as a placeholder,
it performs no useful action, and should not be called. A driver that
attaches a debugger client must override this method.
@param pkt Pointer to a transmit buffer containing the packet to be
sent on the network.
@param pktSize The size of the transmit buffer in bytes.
*/
virtual void sendPacket(void * pkt, UInt32 pktSize);
/*! @function getDebuggerLinkStatus
@abstract Debugger polled-mode link status handler.
@discussion This method should be implemented by a driver that wishes to support
early availability kernel debugging. After a debugger client has been attached through
attachDebuggerClient(), this method will be called by the debugger
to poll for link status availability only when the kernel debugger is active.
This method may be called from the primary interrupt context. As a result, the
implementation must avoid any memory allocation, not use spinlocks, and
never block.
The getDebuggerLinkStatus() method in IONetworkController is used as a placeholder
and always reports that the link is up. A driver that attaches a debugger client
should override this method. The driver should do any setup required to make
sure the link is available for use. Prior to sending or receiving data, KDP will call this
function repeatedly until it indicates that the link is both valid and active
(kIONetworkLinkValid | kIONetworkLinkActive).
@result Link status bits. See IONetworkMedium for the definition of the link status bits.
*/
virtual UInt32 getDebuggerLinkStatus(void);
/*! @function setDebuggerMode
@abstract Set debugger mode for network drivers.
@discussion This method should be implemented by a driver that wishes to be notified when
entering or leaving KDP. After a debugger client has been attached through
attachDebuggerClient(), this method will be called by the debugger
to inform the driver that the kernel debugger is going active or inactive.
This method may be called from the primary interrupt context. As a result, the
implementation must avoid any memory allocation, not use spinlocks, and
never block.
The setDebuggerMode() method in IONetworkController is used as a placeholder
and doesn't do anything. If a driver wishes to perform specific actions based upon whether
or not the debugger is active or not, it should override this method. For example, drivers
may wish to alter power management settings or perform other chipset reconfigurations based
upon the active debugger state.
@param active Set to true if entering KDP and false if leaving KDP.
@result Returns true on success and false otherwise.
*/
virtual bool setDebuggerMode(bool active);
// Virtual function padding
OSMetaClassDeclareReservedUsed( IONetworkController, 0); // getDebuggerLinkStatus
OSMetaClassDeclareReservedUsed( IONetworkController, 1); // setDebuggerMode
OSMetaClassDeclareReservedUnused( IONetworkController, 2);
OSMetaClassDeclareReservedUnused( IONetworkController, 3);
OSMetaClassDeclareReservedUnused( IONetworkController, 4);
OSMetaClassDeclareReservedUnused( IONetworkController, 5);
OSMetaClassDeclareReservedUnused( IONetworkController, 6);
OSMetaClassDeclareReservedUnused( IONetworkController, 7);
OSMetaClassDeclareReservedUnused( IONetworkController, 8);
OSMetaClassDeclareReservedUnused( IONetworkController, 9);
OSMetaClassDeclareReservedUnused( IONetworkController, 10);
OSMetaClassDeclareReservedUnused( IONetworkController, 11);
OSMetaClassDeclareReservedUnused( IONetworkController, 12);
OSMetaClassDeclareReservedUnused( IONetworkController, 13);
OSMetaClassDeclareReservedUnused( IONetworkController, 14);
OSMetaClassDeclareReservedUnused( IONetworkController, 15);
OSMetaClassDeclareReservedUnused( IONetworkController, 16);
OSMetaClassDeclareReservedUnused( IONetworkController, 17);
OSMetaClassDeclareReservedUnused( IONetworkController, 18);
OSMetaClassDeclareReservedUnused( IONetworkController, 19);
OSMetaClassDeclareReservedUnused( IONetworkController, 20);
OSMetaClassDeclareReservedUnused( IONetworkController, 21);
OSMetaClassDeclareReservedUnused( IONetworkController, 22);
OSMetaClassDeclareReservedUnused( IONetworkController, 23);
OSMetaClassDeclareReservedUnused( IONetworkController, 24);
OSMetaClassDeclareReservedUnused( IONetworkController, 25);
OSMetaClassDeclareReservedUnused( IONetworkController, 26);
OSMetaClassDeclareReservedUnused( IONetworkController, 27);
OSMetaClassDeclareReservedUnused( IONetworkController, 28);
OSMetaClassDeclareReservedUnused( IONetworkController, 29);
OSMetaClassDeclareReservedUnused( IONetworkController, 30);
OSMetaClassDeclareReservedUnused( IONetworkController, 31);
};
#endif /* __cplusplus */
#endif /* KERNEL */
#endif /* !_IONETWORKCONTROLLER_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/network/IONetworkStats.h | /*
* Copyright (c) 1998-2008 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* The contents of this file constitute Original Code as defined in and
* are subject to the Apple Public Source License Version 1.1 (the
* "License"). You may not use this file except in compliance with the
* License. Please obtain a copy of the License at
* http://www.apple.com/publicsource and read it before using this file.
*
* This Original Code and all software distributed under the License are
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _IONETWORKSTATS_H
#define _IONETWORKSTATS_H
#include <libkern/OSTypes.h>
/*! @header IONetworkStats.h
@discussion Generic network statistics. */
//------------------------------------------------------------------------
// Generic network statistics. Common to all network interfaces.
//
// WARNING: This structure must match the statistics field in
// ifnet->if_data. This structure will overlay a portion of ifnet.
/*! @typedef IONetworkStats
@discussion Generic network statistics structure.
@field inputPackets count input packets.
@field inputErrors count input errors.
@field outputPackets count output packets.
@field outputErrors count output errors.
@field collisions count collisions on CDMA networks. */
typedef struct {
UInt32 inputPackets;
UInt32 inputErrors;
UInt32 outputPackets;
UInt32 outputErrors;
UInt32 collisions;
} IONetworkStats;
/*! @defined kIONetworkStatsKey
@discussion Defines the name of an IONetworkData that contains
an IONetworkStats. */
#define kIONetworkStatsKey "IONetworkStatsKey"
//------------------------------------------------------------------------
// Output queue statistics.
/*! @typedef IOOutputQueueStats
@discussion Statistics recorded by IOOutputQueue objects.
@field capacity queue capacity.
@field size current size of the queue.
@field peakSize peak size of the queue.
@field dropCount number of packets dropped.
@field outputCount number of output packets.
@field retryCount number of retries.
@field stallCount number of queue stalls. */
typedef struct {
UInt32 capacity;
UInt32 size;
UInt32 peakSize;
UInt32 dropCount;
UInt32 outputCount;
UInt32 retryCount;
UInt32 stallCount;
UInt32 reserved[4];
} IOOutputQueueStats;
/*! @defined kIOOutputQueueStatsKey
@discussion Defines the name of an IONetworkData that contains
an IOOutputQueueStats. */
#define kIOOutputQueueStatsKey "IOOutputQueueStatsKey"
#endif /* !_IONETWORKSTATS_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/network/IOGatedOutputQueue.h | /*
* Copyright (c) 1998-2008 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* The contents of this file constitute Original Code as defined in and
* are subject to the Apple Public Source License Version 1.1 (the
* "License"). You may not use this file except in compliance with the
* License. Please obtain a copy of the License at
* http://www.apple.com/publicsource and read it before using this file.
*
* This Original Code and all software distributed under the License are
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _IOGATEDOUTPUTQUEUE_H
#define _IOGATEDOUTPUTQUEUE_H
#include <IOKit/IOWorkLoop.h>
#include <IOKit/IOCommandGate.h>
#include <IOKit/IOInterruptEventSource.h>
#include <IOKit/network/IOBasicOutputQueue.h>
/*! @class IOGatedOutputQueue
@abstract An extension of an IOBasicOutputQueue.
@discussion An IOCommandGate
object is created by this queue and added to a work loop as an
event source. All calls to the target by the consumer thread must
occur with the gate closed. Therefore, all calls to the target of
this type of queue will be serialized with any other thread that
runs on the same work loop context. This is useful for network
drivers that have a tight hardware coupling between the transmit
and receive engines, and a single-threaded hardware access model
is desirable.
*/
class __exported IOGatedOutputQueue : public IOBasicOutputQueue
{
OSDeclareDefaultStructors( IOGatedOutputQueue )
private:
static void gatedOutput(OSObject * owner,
IOGatedOutputQueue * self,
IOMbufQueue * queue,
UInt32 * state);
static void restartDeferredOutput(OSObject * owner,
IOInterruptEventSource * sender,
int count);
protected:
IOCommandGate * _gate;
IOInterruptEventSource * _interruptSrc;
/*! @function output
@abstract Transfers all packets in the mbuf queue to the target.
@param queue A queue of output packets.
@param state Return a state bit defined by IOBasicOutputQueue that
declares the new state of the queue following this method call.
A kStateStalled is returned if the queue should stall, otherwise 0
is returned.
*/
virtual void output(IOMbufQueue * queue, UInt32 * state) APPLE_KEXT_OVERRIDE;
/*! @function free
@abstract Frees the IOGatedOutputQueue object.
@discussion Release allocated resources, then call super::free(). */
virtual void free() APPLE_KEXT_OVERRIDE;
/*! @function output
@abstract Overrides the method inherited from IOOutputQueue.
@result Returns true if a thread was successfully scheduled to service
the queue.
*/
virtual bool scheduleServiceThread(void * param) APPLE_KEXT_OVERRIDE;
public:
/*! @function init
@abstract Initializes an IOGatedOutputQueue object.
@param target The object that will handle packets removed from the
queue, and is usually a subclass of IONetworkController.
@param action The function that will handle packets removed from the
queue.
@param workloop A workloop object. An IOCommandGate object is created
and added to this workloop as an event source.
@param capacity The initial capacity of the output queue.
@result Returns true if initialized successfully, false otherwise.
*/
virtual bool init(OSObject * target,
IOOutputAction action,
IOWorkLoop * workloop,
UInt32 capacity = 0,
UInt32 priorities = 1);
/*! @function withTarget
@abstract Factory method that constructs and initializes an
IOGatedOutputQueue object.
@param target An IONetworkController object that will handle packets
removed from the queue.
@param workloop A workloop object. An IOCommandGate object is created
and added to this workloop as an event source.
@param capacity The initial capacity of the output queue.
@result Returns an IOGatedOutputQueue object on success, or 0 otherwise.
*/
static IOGatedOutputQueue * withTarget(IONetworkController * target,
IOWorkLoop * workloop,
UInt32 capacity = 0);
/*! @function withTarget
@abstract Factory method that constructs and initializes an
IOGatedOutputQueue object.
@param target An IONetworkController object that will handle packets
removed from the queue.
@param workloop A workloop object. An IOCommandGate object is created
and added to this workloop as an event source.
@param capacity The initial capacity of the output queue.
@param priorities The number of traffic priorities supported
@result Returns an IOGatedOutputQueue object on success, or 0 otherwise.
*/
static IOGatedOutputQueue * withTarget(IONetworkController * target,
IOWorkLoop * workloop,
UInt32 capacity,
UInt32 priorities);
/*! @function withTarget
@abstract Factory method that constructs and initializes an
IOGatedOutputQueue object.
@param target The object that will handle packets removed from the
queue.
@param action The function that will handle packets removed from the
queue.
@param workloop A workloop object. An IOCommandGate object is created
and added to this workloop as an event source.
@param capacity The initial capacity of the output queue.
@result Returns an IOGatedOutputQueue object on success, or 0 otherwise.
*/
static IOGatedOutputQueue * withTarget(OSObject * target,
IOOutputAction action,
IOWorkLoop * workloop,
UInt32 capacity = 0);
/*! @function withTarget
@abstract Factory method that constructs and initializes an
IOGatedOutputQueue object.
@param target The object that will handle packets removed from the
queue.
@param action The function that will handle packets removed from the
queue.
@param workloop A workloop object. An IOCommandGate object is created
and added to this workloop as an event source.
@param capacity The initial capacity of the output queue.
@param priorities The number of traffic priorities supported
@result Returns an IOGatedOutputQueue object on success, or 0 otherwise.
*/
static IOGatedOutputQueue * withTarget(OSObject * target,
IOOutputAction action,
IOWorkLoop * workloop,
UInt32 capacity,
UInt32 priorities);
};
#endif /* !_IOGATEDOUTPUTQUEUE_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/storage/IOStorageControllerCharacteristics.h | /*
* Copyright (c) 1998-2014 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _IOKIT_IO_STORAGE_CONTROLLER_CHARACTERISTICS_H_
#define _IOKIT_IO_STORAGE_CONTROLLER_CHARACTERISTICS_H_
#include <TargetConditionals.h>
/*
* Controller Characteristics - Characteristics defined for controllers.
*/
/*!
@defined kIOPropertyControllerCharacteristicsKey
@discussion This key is used to define Controller Characteristics for a particular
device and it has an associated dictionary which lists the
controller characteristics.
Requirement: Mandatory
Example:
<pre>
@textblock
<dict>
<key>Controller Characteristics</key>
<dict>
<key>Port Speed</key>
<string>Automatic</string>
</dict>
</dict>
@/textblock
</pre>
*/
#define kIOPropertyControllerCharacteristicsKey "Controller Characteristics"
/*!
@defined kIOPropertySASAddressKey
@discussion This key is the unique 64-bit SAS Address for the device server
node located at this port, or for the initiating host port.
Requirement: Mandatory for SAS.
Example:
<pre>
@textblock
<dict>
<key>Controller Characteristics</key>
<dict>
<key>SAS Address</key>
<data>0011223344556677</data>
</dict>
</dict>
@/textblock
</pre>
*/
#define kIOPropertySASAddressKey "SAS Address"
/*!
@defined kIOPropertySCSIPortIdentifierKey
@discussion This key is the unique port identifier for the device server
node located at this port, or for the initiating host port. The format for
this data is allowed to be vendor-specific, as long as it is guaranteed to
be unique. Length is arbitrary, to allow for itnerfaces with non-standard
identifier rules. It is recommended to have this be a copy of an existing
standard unique identifier for this port, should one already exist for your
interface type
Requirement: Mandatory.
Example:
<pre>
@textblock
<dict>
<key>Controller Characteristics</key>
<dict>
<key>Unique SCSI Port Identifier</key>
<data>0011223344556677</data>
</dict>
</dict>
@/textblock
</pre>
*/
#define kIOPropertySCSIPortIdentifierKey "Unique SCSI Port Identifier"
/*!
@defined kIOPropertyFibreChannelNodeWorldWideNameKey
@discussion This key is the unique 64-bit World Wide Name for the device server
node located at this port, or for the initiating host port.
Requirement: Mandatory for Fibre Channel Interface.
Example:
<pre>
@textblock
<dict>
<key>Controller Characteristics</key>
<dict>
<key>Node World Wide Name</key>
<data>0011223344556677</data>
</dict>
</dict>
@/textblock
</pre>
*/
#define kIOPropertyFibreChannelNodeWorldWideNameKey "Node World Wide Name"
/*!
@defined kIOPropertyFibreChannelPortWorldWideNameKey
@discussion This key is the unique 64-bit World Wide Name for the port.
Requirement: Mandatory for Fibre Channel Interface.
Example:
<pre>
@textblock
<dict>
<key>Controller Characteristics</key>
<dict>
<key>Port World Wide Name</key>
<data>0011223344556677</data>
</dict>
</dict>
@/textblock
</pre>
*/
#define kIOPropertyFibreChannelPortWorldWideNameKey "Port World Wide Name"
/*!
@defined kIOPropertyFibreChannelAddressIdentifierKey
@discussion This key is the 24-bit Address Identifier (S_ID or D_ID) as
defined in the FC-FS specification. It contains the address identifier
of the source or destination Nx_Port.
Note: This value can change. It is not a static value.
Requirement: Optional (only necessary for Fibre Channel Interface).
Example:
<pre>
@textblock
<dict>
<key>Controller Characteristics</key>
<dict>
<key>Address Identifier</key>
<data>001122</data>
</dict>
</dict>
@/textblock
</pre>
*/
#define kIOPropertyFibreChannelAddressIdentifierKey "Address Identifier"
/*!
@defined kIOPropertyFibreChannelALPAKey
@discussion This key is the 8-bit Arbitrated Loop Physical Address
(AL_PA) value as defined in the FC-AL-2 specification.
Note: This value can change. It is not a static value.
Requirement: Optional (only necessary for Fibre Channel Interface).
Example:
<pre>
@textblock
<dict>
<key>Controller Characteristics</key>
<dict>
<key>AL_PA</key>
<data>04</data>
</dict>
</dict>
@/textblock
</pre>
*/
#define kIOPropertyFibreChannelALPAKey "AL_PA"
/*!
@defined kIOPropertyPortStatusKey
@discussion This key is associated with the current port
status of the physical link. The port status is either
"Link Established", "No Link Established", or "Link Failed".
Note: This value can change when the port status changes. It
is not a static value.
Requirement: Optional for any interconnect.
Example:
<pre>
@textblock
<dict>
<key>Controller Characteristics</key>
<dict>
<key>Port Status</key>
<string>Link Established</string>
</dict>
</dict>
@/textblock
</pre>
*/
#define kIOPropertyPortStatusKey "Port Status"
/*!
@defined kIOPropertyPortSpeedKey
@discussion This key is associated with the current port
speed. The port speed can be any valid speed for the interconnect.
Note: This value can change. It is not a static value.
Requirement: Optional for any interconnect.
Example:
<pre>
@textblock
<dict>
<key>Controller Characteristics</key>
<dict>
<key>Port Speed</key>
<string>Automatic (1 Gigabit)</string>
</dict>
</dict>
@/textblock
</pre>
*/
#define kIOPropertyPortSpeedKey "Port Speed"
/*!
@defined kIOPropertyPortTopologyKey
@discussion This key is associated with the current port
topology. The port topology can be any valid topology for the interconnect.
Note: This value can change. It is not a static value.
Requirement: Optional for any interconnect.
Example:
<pre>
@textblock
<dict>
<key>Controller Characteristics</key>
<dict>
<key>Port Topology</key>
<string>Automatic (N_Port)</string>
</dict>
</dict>
@/textblock
</pre>
*/
#define kIOPropertyPortTopologyKey "Port Topology"
/*!
@defined kIOPropertyPortDescriptionKey
@discussion This key is associated with an human
readable port description. Examples include
"Channel A", "Port 1", etc.
Requirement: Optional for all interconnects.
Example:
<pre>
@textblock
<dict>
<key>Controller Characteristics</key>
<dict>
<key>Port Description</key>
<string>Channel A</string>
</dict>
</dict>
@/textblock
</pre>
*/
#define kIOPropertyPortDescriptionKey "Port Description"
/*!
@defined kIOPropertySCSIParallelSignalingTypeKey
@discussion This key is associated with the signaling type
used for this SCSI Parallel bus. Valid values include
"High Voltage Differential", "Low Voltage Differential",
and "Single Ended".
Requirement: Optional for SCSI Parallel Interface. Not
defined for any other physical interconnect.
Example:
<pre>
@textblock
<dict>
<key>Controller Characteristics</key>
<dict>
<key>SCSI Parallel Signaling Type</key>
<string>High Voltage Differential</string>
</dict>
</dict>
@/textblock
</pre>
*/
#define kIOPropertySCSIParallelSignalingTypeKey "SCSI Parallel Signaling Type"
/*!
@defined kIOPropertyFibreChannelCableDescriptionKey
@discussion This key is associated with the cabling type
used for this Fibre Channel port. Valid values include
"Copper" and "Fiber Optic".
Requirement: Optional for Fibre Channel Interface. Not
defined for any other physical interconnect.
Example:
<pre>
@textblock
<dict>
<key>Controller Characteristics</key>
<dict>
<key>Fibre Channel Cabling Type</key>
<string>Copper</string>
</dict>
</dict>
@/textblock
</pre>
*/
#define kIOPropertyFibreChannelCableDescriptionKey "Fibre Channel Cabling Type"
/*!
@defined kIOPropertyEncryptionTypeKey
@discussion This key is associated with the encryption type
used for this storage controller. Valid values currently include
"AES-XTS", "AES-XEX" and "AES-CBC".
Requirement: Optional for all storage controllers.
Example:
<pre>
@textblock
<dict>
<key>Controller Characteristics</key>
<dict>
<key>Encryption Type</key>
<string>AES-XTS</string>
</dict>
</dict>
@/textblock
</pre>
*/
#define kIOPropertyEncryptionTypeKey "Encryption Type"
/*!
@defined kIOPropertyLowPowerModeKey
@discussion This key is associated with whether the storage
device has low-power mode enabled. If enabled, it will set this
key to true.
Requirement: Optional for any interconnect.
Example:
<pre>
@textblock
<dict>
<key>Controller Characteristics</key>
<dict>
<key>Low Power Mode</key>
<true/>
</dict>
</dict>
@/textblock
</pre>
*/
#define kIOPropertyLowPowerModeKey "Low Power Mode"
/*
* Values - Values for the characteristics defined above.
*/
/*!
@defined kIOPropertyPortStatusLinkEstablishedKey
@discussion This key defines the value of Link Established for the key
kIOPropertyPortStatusKey.
Example:
<pre>
@textblock
<dict>
<key>Controller Characteristics</key>
<dict>
<key>Port Status</key>
<string>Link Established</string>
</dict>
</dict>
@/textblock
</pre>
*/
#define kIOPropertyPortStatusLinkEstablishedKey "Link Established"
/*!
@defined kIOPropertyPortStatusNoLinkEstablishedKey
@discussion This key defines the value of No Link Established for the key
kIOPropertyPortStatusKey.
Example:
<pre>
@textblock
<dict>
<key>Controller Characteristics</key>
<dict>
<key>Port Status</key>
<string>No Link Established</string>
</dict>
</dict>
@/textblock
</pre>
*/
#define kIOPropertyPortStatusNoLinkEstablishedKey "No Link Established"
/*!
@defined kIOPropertyPortStatusLinkFailedKey
@discussion This key defines the value of Link Failed for the key
kIOPropertyPortStatusKey.
Example:
<pre>
@textblock
<dict>
<key>Controller Characteristics</key>
<dict>
<key>Port Status</key>
<string>Link Failed</string>
</dict>
</dict>
@/textblock
</pre>
*/
#define kIOPropertyPortStatusLinkFailedKey "Link Failed"
/*!
@defined kIOPropertyPortSpeedAutomaticKey
@discussion This key defines the value of Automatic for the key
kIOPropertyPortSpeedKey. If the speed of the port is automatically
adjusted by the host/device and a definitive speed is not known,
this key should be used.
Note: This value can change. It is not a static value.
Requirement: Optional for any interconnect.
Example:
<pre>
@textblock
<dict>
<key>Controller Characteristics</key>
<dict>
<key>Port Speed</key>
<string>Automatic</string>
</dict>
</dict>
@/textblock
</pre>
*/
#define kIOPropertyPortSpeedAutomaticKey "Automatic"
/*!
@defined kIOPropertyPortSpeed1GigabitKey
@discussion This key defines the value of 1 Gigabit for the key
kIOPropertyPortSpeedKey. If the speed of the port is 1 Gigabit
per second and is not automatically determined (i.e. the user
configured the port to be exactly this speed),
this key should be used.
Note: This value can change. It is not a static value.
Requirement: Optional for any interconnect.
Example:
<pre>
@textblock
<dict>
<key>Controller Characteristics</key>
<dict>
<key>Port Speed</key>
<string>1 Gigabit</string>
</dict>
</dict>
@/textblock
</pre>
*/
#define kIOPropertyPortSpeed1GigabitKey "1 Gigabit"
/*!
@defined kIOPropertyPortSpeed1_5GigabitKey
@discussion This key defines the value of 1.5 Gigabit for the key
kIOPropertyPortSpeedKey. If the speed of the port is 1.5 Gigabits
per second and is not automatically determined (i.e. the user
configured the port to be exactly this speed),
this key should be used.
Note: This value can change. It is not a static value.
Requirement: Optional for any interconnect.
Example:
<pre>
@textblock
<dict>
<key>Controller Characteristics</key>
<dict>
<key>Port Speed</key>
<string>1.5 Gigabit</string>
</dict>
</dict>
@/textblock
</pre>
*/
#define kIOPropertyPortSpeed1_5GigabitKey "1.5 Gigabit"
/*!
@defined kIOPropertyPortSpeed2GigabitKey
@discussion This key defines the value of 2 Gigabit for the key
kIOPropertyPortSpeedKey. If the speed of the port is 2 Gigabits
per second and is not automatically determined (i.e. the user
configured the port to be exactly this speed),
this key should be used.
Note: This value can change. It is not a static value.
Requirement: Optional for any interconnect.
Example:
<pre>
@textblock
<dict>
<key>Controller Characteristics</key>
<dict>
<key>Port Speed</key>
<string>2 Gigabit</string>
</dict>
</dict>
@/textblock
</pre>
*/
#define kIOPropertyPortSpeed2GigabitKey "2 Gigabit"
/*!
@defined kIOPropertyPortSpeed3GigabitKey
@discussion This key defines the value of 3 Gigabit for the key
kIOPropertyPortSpeedKey. If the speed of the port is 3 Gigabits
per second and is not automatically determined (i.e. the user
configured the port to be exactly this speed),
this key should be used.
Note: This value can change. It is not a static value.
Requirement: Optional for any interconnect.
Example:
<pre>
@textblock
<dict>
<key>Controller Characteristics</key>
<dict>
<key>Port Speed</key>
<string>3 Gigabit</string>
</dict>
</dict>
@/textblock
</pre>
*/
#define kIOPropertyPortSpeed3GigabitKey "3 Gigabit"
/*!
@defined kIOPropertyPortSpeed4GigabitKey
@discussion This key defines the value of 4 Gigabit for the key
kIOPropertyPortSpeedKey. If the speed of the port is 4 Gigabits
per second and is not automatically determined (i.e. the user
configured the port to be exactly this speed),
this key should be used.
Note: This value can change. It is not a static value.
Requirement: Optional for any interconnect.
Example:
<pre>
@textblock
<dict>
<key>Controller Characteristics</key>
<dict>
<key>Port Speed</key>
<string>4 Gigabit</string>
</dict>
</dict>
@/textblock
</pre>
*/
#define kIOPropertyPortSpeed4GigabitKey "4 Gigabit"
/*!
@defined kIOPropertyPortSpeed6GigabitKey
@discussion This key defines the value of 6 Gigabit for the key
kIOPropertyPortSpeedKey. If the speed of the port is 6 Gigabits
per second and is not automatically determined (i.e. the user
configured the port to be exactly this speed),
this key should be used.
Note: This value can change. It is not a static value.
Requirement: Optional for any interconnect.
Example:
<pre>
@textblock
<dict>
<key>Controller Characteristics</key>
<dict>
<key>Port Speed</key>
<string>6 Gigabit</string>
</dict>
</dict>
@/textblock
</pre>
*/
#define kIOPropertyPortSpeed6GigabitKey "6 Gigabit"
/*!
@defined kIOPropertyPortSpeed8GigabitKey
@discussion This key defines the value of 8 Gigabit for the key
kIOPropertyPortSpeedKey. If the speed of the port is 8 Gigabits
per second and is not automatically determined (i.e. the user
configured the port to be exactly this speed),
this key should be used.
Note: This value can change. It is not a static value.
Requirement: Optional for any interconnect.
Example:
<pre>
@textblock
<dict>
<key>Controller Characteristics</key>
<dict>
<key>Port Speed</key>
<string>8 Gigabit</string>
</dict>
</dict>
@/textblock
</pre>
*/
#define kIOPropertyPortSpeed8GigabitKey "8 Gigabit"
/*!
@defined kIOPropertyPortSpeed10GigabitKey
@discussion This key defines the value of 10 Gigabit for the key
kIOPropertyPortSpeedKey. If the speed of the port is 10 Gigabits
per second and is not automatically determined (i.e. the user
configured the port to be exactly this speed),
this key should be used.
Note: This value can change. It is not a static value.
Requirement: Optional for any interconnect.
Example:
<pre>
@textblock
<dict>
<key>Controller Characteristics</key>
<dict>
<key>Port Speed</key>
<string>10 Gigabit</string>
</dict>
</dict>
@/textblock
</pre>
*/
#define kIOPropertyPortSpeed10GigabitKey "10 Gigabit"
/*!
@defined kIOPropertyPortSpeed12GigabitKey
@discussion This key defines the value of 12 Gigabit for the key
kIOPropertyPortSpeedKey. If the speed of the port is 12 Gigabits
per second and is not automatically determined (i.e. the user
configured the port to be exactly this speed),
this key should be used.
Note: This value can change. It is not a static value.
Requirement: Optional for any interconnect.
Example:
<pre>
@textblock
<dict>
<key>Controller Characteristics</key>
<dict>
<key>Port Speed</key>
<string>12 Gigabit</string>
</dict>
</dict>
@/textblock
</pre>
*/
#define kIOPropertyPortSpeed12GigabitKey "12 Gigabit"
/*!
@defined kIOPropertyPortSpeed16GigabitKey
@discussion This key defines the value of 16 Gigabit for the key
kIOPropertyPortSpeedKey. If the speed of the port is 16 Gigabits
per second and is not automatically determined (i.e. the user
configured the port to be exactly this speed),
this key should be used.
Note: This value can change. It is not a static value.
Requirement: Optional for any interconnect.
Example:
<pre>
@textblock
<dict>
<key>Controller Characteristics</key>
<dict>
<key>Port Speed</key>
<string>16 Gigabit</string>
</dict>
</dict>
@/textblock
</pre>
*/
#define kIOPropertyPortSpeed16GigabitKey "16 Gigabit"
/*!
@defined kIOPropertyPortSpeed40GigabitKey
@discussion This key defines the value of 40 Gigabit for the key
kIOPropertyPortSpeedKey. If the speed of the port is 40 Gigabits
per second and is not automatically determined (i.e. the user
configured the port to be exactly this speed),
this key should be used.
Note: This value can change. It is not a static value.
Requirement: Optional for any interconnect.
Example:
<pre>
@textblock
<dict>
<key>Controller Characteristics</key>
<dict>
<key>Port Speed</key>
<string>40 Gigabit</string>
</dict>
</dict>
@/textblock
</pre>
*/
#define kIOPropertyPortSpeed40GigabitKey "40 Gigabit"
/*!
@defined kIOPropertyPortSpeedAutomatic1GigabitKey
@discussion This key defines the value of Automatic (1 Gigabit)
for the key kIOPropertyPortSpeedKey. If the speed of the port is
1 Gigabit per second and is automatically determined by host
software, this key should be used.
Note: This value can change. It is not a static value.
Requirement: Optional for any interconnect.
Example:
<pre>
@textblock
<dict>
<key>Controller Characteristics</key>
<dict>
<key>Port Speed</key>
<string>Automatic (1 Gigabit)</string>
</dict>
</dict>
@/textblock
</pre>
*/
#define kIOPropertyPortSpeedAutomatic1GigabitKey "Automatic (1 Gigabit)"
/*!
@defined kIOPropertyPortSpeedAutomatic1_5GigabitKey
@discussion This key defines the value of Automatic (1.5 Gigabit) for the key
kIOPropertyPortSpeedKey. If the speed of the port is
1.5 Gigabits per second and is automatically determined by host
software, this key should be used.
Note: This value can change. It is not a static value.
Requirement: Optional for any interconnect.
Example:
<pre>
@textblock
<dict>
<key>Controller Characteristics</key>
<dict>
<key>Port Speed</key>
<string>Automatic (1.5 Gigabit)</string>
</dict>
</dict>
@/textblock
</pre>
*/
#define kIOPropertyPortSpeedAutomatic1_5GigabitKey "Automatic (1.5 Gigabit)"
/*!
@defined kIOPropertyPortSpeedAutomatic2GigabitKey
@discussion This key defines the value of Automatic (2 Gigabit)
for the key kIOPropertyPortSpeedKey. If the speed of the port is
2 Gigabits per second and is automatically determined by host
software, this key should be used.
Note: This value can change. It is not a static value.
Requirement: Optional for any interconnect.
Example:
<pre>
@textblock
<dict>
<key>Controller Characteristics</key>
<dict>
<key>Port Speed</key>
<string>Automatic (2 Gigabit)</string>
</dict>
</dict>
@/textblock
</pre>
*/
#define kIOPropertyPortSpeedAutomatic2GigabitKey "Automatic (2 Gigabit)"
/*!
@defined kIOPropertyPortSpeedAutomatic3GigabitKey
@discussion This key defines the value of Automatic (3 Gigabit)
for the key kIOPropertyPortSpeedKey. If the speed of the port is
3 Gigabits per second and is automatically determined by host
software, this key should be used.
Note: This value can change. It is not a static value.
Requirement: Optional for any interconnect.
Example:
<pre>
@textblock
<dict>
<key>Controller Characteristics</key>
<dict>
<key>Port Speed</key>
<string>Automatic (3 Gigabit)</string>
</dict>
</dict>
@/textblock
</pre>
*/
#define kIOPropertyPortSpeedAutomatic3GigabitKey "Automatic (3 Gigabit)"
/*!
@defined kIOPropertyPortSpeedAutomatic4GigabitKey
@discussion This key defines the value of Automatic (4 Gigabit)
for the key kIOPropertyPortSpeedKey. If the speed of the port is
4 Gigabits per second and is automatically determined by host
software, this key should be used.
Note: This value can change. It is not a static value.
Requirement: Optional for any interconnect.
Example:
<pre>
@textblock
<dict>
<key>Controller Characteristics</key>
<dict>
<key>Port Speed</key>
<string>Automatic (4 Gigabit)</string>
</dict>
</dict>
@/textblock
</pre>
*/
#define kIOPropertyPortSpeedAutomatic4GigabitKey "Automatic (4 Gigabit)"
/*!
@defined kIOPropertyPortSpeedAutomatic6GigabitKey
@discussion This key defines the value of Automatic (6 Gigabit)
for the key kIOPropertyPortSpeedKey. If the speed of the port is
6 Gigabits per second and is automatically determined by host
software, this key should be used.
Note: This value can change. It is not a static value.
Requirement: Optional for any interconnect.
Example:
<pre>
@textblock
<dict>
<key>Controller Characteristics</key>
<dict>
<key>Port Speed</key>
<string>Automatic (6 Gigabit)</string>
</dict>
</dict>
@/textblock
</pre>
*/
#define kIOPropertyPortSpeedAutomatic6GigabitKey "Automatic (6 Gigabit)"
/*!
@defined kIOPropertyPortSpeedAutomatic8GigabitKey
@discussion This key defines the value of Automatic (8 Gigabit)
for the key kIOPropertyPortSpeedKey. If the speed of the port is
8 Gigabits per second and is automatically determined by host
software, this key should be used.
Note: This value can change. It is not a static value.
Requirement: Optional for any interconnect.
Example:
<pre>
@textblock
<dict>
<key>Controller Characteristics</key>
<dict>
<key>Port Speed</key>
<string>Automatic (8 Gigabit)</string>
</dict>
</dict>
@/textblock
</pre>
*/
#define kIOPropertyPortSpeedAutomatic8GigabitKey "Automatic (8 Gigabit)"
/*!
@defined kIOPropertyPortSpeedAutomatic10GigabitKey
@discussion This key defines the value of Automatic (10 Gigabit)
for the key kIOPropertyPortSpeedKey. If the speed of the port is
10 Gigabits per second and is automatically determined by host
software, this key should be used.
Note: This value can change. It is not a static value.
Requirement: Optional for any interconnect.
Example:
<pre>
@textblock
<dict>
<key>Controller Characteristics</key>
<dict>
<key>Port Speed</key>
<string>Automatic (10 Gigabit)</string>
</dict>
</dict>
@/textblock
</pre>
*/
#define kIOPropertyPortSpeedAutomatic10GigabitKey "Automatic (10 Gigabit)"
/*!
@defined kIOPropertyPortTopologyAutomaticKey
@discussion This key defines the value of Automatic for the key
kIOPropertyPortTopologyKey. If the topology of the port is automatically
adjusted by the host/device and a definitive topology is not known,
this key should be used.
Note: This value can change. It is not a static value.
Requirement: Optional for any interconnect.
Example:
<pre>
@textblock
<dict>
<key>Controller Characteristics</key>
<dict>
<key>Port Topology</key>
<string>Automatic</string>
</dict>
</dict>
@/textblock
</pre>
*/
#define kIOPropertyPortTopologyAutomaticKey "Automatic"
/*!
@defined kIOPropertyPortTopologyNPortKey
@discussion This key defines the value of N_Port for the key
kIOPropertyPortTopologyKey. If the topology of the port is an N_Port,
this key should be used.
Note: This value can change. It is not a static value.
Requirement: Optional for any interconnect.
Example:
<pre>
@textblock
<dict>
<key>Controller Characteristics</key>
<dict>
<key>Port Topology</key>
<string>N_Port</string>
</dict>
</dict>
@/textblock
</pre>
*/
#define kIOPropertyPortTopologyNPortKey "N_Port"
/*!
@defined kIOPropertyPortTopologyNLPortKey
@discussion This key defines the value of NL_Port for the key
kIOPropertyPortTopologyKey. If the topology of the port is an NL_Port,
this key should be used.
Note: This value can change. It is not a static value.
Requirement: Optional for any interconnect.
Example:
<pre>
@textblock
<dict>
<key>Controller Characteristics</key>
<dict>
<key>Port Topology</key>
<string>NL_Port</string>
</dict>
</dict>
@/textblock
</pre>
*/
#define kIOPropertyPortTopologyNLPortKey "NL_Port"
/*!
@defined kIOPropertyPortTopologyAutomaticNPortKey
@discussion This key defines the value of Automatic (N_Port) for the key
kIOPropertyPortTopologyKey. If the topology of the port is
N_Port and is automatically determined by host software, this
key should be used.
Note: This value can change. It is not a static value.
Requirement: Optional for any interconnect.
Example:
<pre>
@textblock
<dict>
<key>Controller Characteristics</key>
<dict>
<key>Port Topology</key>
<string>Automatic (N_Port)</string>
</dict>
</dict>
@/textblock
</pre>
*/
#define kIOPropertyPortTopologyAutomaticNPortKey "Automatic (N_Port)"
/*!
@defined kIOPropertyPortTopologyAutomaticNLPortKey
@discussion This key defines the value of Automatic (NL_Port) for the key
kIOPropertyPortTopologyKey. If the topology of the port is
NL_Port and is automatically determined by host software, this
key should be used.
Note: This value can change. It is not a static value.
Requirement: Optional for any interconnect.
Example:
<pre>
@textblock
<dict>
<key>Controller Characteristics</key>
<dict>
<key>Port Topology</key>
<string>Automatic (NL_Port)</string>
</dict>
</dict>
@/textblock
</pre>
*/
#define kIOPropertyPortTopologyAutomaticNLPortKey "Automatic (NL_Port)"
/*!
@defined kIOPropertySCSIParallelSignalingTypeHVDKey
@discussion This key defines the value of High Voltage Differential for the key
kIOPropertySCSIParallelSignalingTypeKey. If the signaling type of the port is
High Voltage Differential, this key should be used.
Requirement: Optional for SCSI Parallel Interface interconnect.
Example:
<pre>
@textblock
<dict>
<key>Controller Characteristics</key>
<dict>
<key>SCSI Parallel Signaling Type</key>
<string>High Voltage Differential</string>
</dict>
</dict>
@/textblock
</pre>
*/
#define kIOPropertySCSIParallelSignalingTypeHVDKey "High Voltage Differential"
/*!
@defined kIOPropertySCSIParallelSignalingTypeLVDKey
@discussion This key defines the value of Low Voltage Differential for the key
kIOPropertySCSIParallelSignalingTypeKey. If the signaling type of the port is
Low Voltage Differential, this key should be used.
Requirement: Optional for SCSI Parallel Interface interconnect.
Example:
<pre>
@textblock
<dict>
<key>Controller Characteristics</key>
<dict>
<key>SCSI Parallel Signaling Type</key>
<string>Low Voltage Differential</string>
</dict>
</dict>
@/textblock
</pre>
*/
#define kIOPropertySCSIParallelSignalingTypeLVDKey "Low Voltage Differential"
/*!
@defined kIOPropertySCSIParallelSignalingTypeSEKey
@discussion This key defines the value of Single Ended for the key
kIOPropertySCSIParallelSignalingTypeKey. If the signaling type of the port is
Single Ended, this key should be used.
Requirement: Optional for SCSI Parallel Interface interconnect.
Example:
<pre>
@textblock
<dict>
<key>Controller Characteristics</key>
<dict>
<key>SCSI Parallel Signaling Type</key>
<string>Single Ended</string>
</dict>
</dict>
@/textblock
</pre>
*/
#define kIOPropertySCSIParallelSignalingTypeSEKey "Single Ended"
/*!
@defined kIOPropertyFibreChannelCableDescriptionCopperKey
@discussion This key defines the value of Copper for the key
kIOPropertyFibreChannelCableDescriptionKey. If the cabling is
Copper, this key should be used.
Requirement: Optional for Fibre Channel Interface interconnect.
Example:
<pre>
@textblock
<dict>
<key>Controller Characteristics</key>
<dict>
<key>Fibre Channel Cabling Type</key>
<string>Copper</string>
</dict>
</dict>
@/textblock
</pre>
*/
#define kIOPropertyFibreChannelCableDescriptionCopperKey "Copper"
/*!
@defined kIOPropertyFibreChannelCableDescriptionFiberOpticKey
@discussion This key defines the value of Fiber Optic for the key
kIOPropertyFibreChannelCableDescriptionKey. If the cabling is
Fiber Optic, this key should be used.
Requirement: Optional for Fibre Channel Interface interconnect.
Example:
<pre>
@textblock
<dict>
<key>Controller Characteristics</key>
<dict>
<key>Fibre Channel Cabling Type</key>
<string>Fiber Optic</string>
</dict>
</dict>
@/textblock
</pre>
*/
#define kIOPropertyFibreChannelCableDescriptionFiberOpticKey "Fiber Optic"
/*!
@defined kIOPropertyAESCBCKey
@discussion This key defines the value of AES-CBC for the key
kIOPropertyEncryptionTypeKey. If the encryption used is
AES-CBC, this key should be used.
Requirement: Optional for all storage controllers.
Example:
<pre>
@textblock
<dict>
<key>Controller Characteristics</key>
<dict>
<key>Encryption Type</key>
<string>AES-CBC</string>
</dict>
</dict>
@/textblock
</pre>
*/
#define kIOPropertyAESCBCKey "AES-CBC"
/*!
@defined kIOPropertyAESXTSKey
@discussion This key defines the value of AES-XTS for the key
kIOPropertyEncryptionTypeKey. If the encryption used is
AES-XTS, this key should be used.
Requirement: Optional for all storage controllers.
Example:
<pre>
@textblock
<dict>
<key>Controller Characteristics</key>
<dict>
<key>Encryption Type</key>
<string>AES-XTS</string>
</dict>
</dict>
@/textblock
</pre>
*/
#define kIOPropertyAESXTSKey "AES-XTS"
/*!
@defined kIOPropertyAESXEXKey
@discussion This key defines the value of AES-XEX for the key
kIOPropertyEncryptionTypeKey. If the encryption used is
AES-XEX, this key should be used.
Requirement: Optional for all storage controllers.
Example:
<pre>
@textblock
<dict>
<key>Controller Characteristics</key>
<dict>
<key>Encryption Type</key>
<string>AES-XEX</string>
</dict>
</dict>
@/textblock
</pre>
*/
#define kIOPropertyAESXEXKey "AES-XEX"
#endif /* _IOKIT_IO_STORAGE_CONTROLLER_CHARACTERISTICS_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/storage/IOBlockStoragePerfControlExports.h | /*
* Copyright (c) 1998-2019 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef IOBlockStoragePerfControlExports_h
#define IOBlockStoragePerfControlExports_h
#include <IOKit/perfcontrol/IOPerfControl.h>
struct IOBlockStorageWorkFlags
{
/* isRead is True for read op */
bool isRead{};
/* isLowPriority is True for low priority IOs */
bool isLowPriority{};
/* Size of the I/O in bytes */
uint64_t ioSize{};
};
#endif /* IOBlockStoragePerfControlExports_h */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/storage/IOBDMediaBSDClient.h | /*
* Copyright (c) 2006-2014 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _IOBDMEDIABSDCLIENT_H
#define _IOBDMEDIABSDCLIENT_H
#include <sys/ioctl.h>
#include <sys/types.h>
#include <IOKit/storage/IOBDTypes.h>
/*
* Definitions
*
* ioctl description
* ---------------------------- ------------------------------------------------
* DKIOCBDREADSTRUCTURE see IOBDMedia::readStructure() in IOBDMedia.h
*
* DKIOCBDREADDISCINFO see IOBDMedia::readDiscInfo() in IOBDMedia.h
* DKIOCBDREADTRACKINFO see IOBDMedia::readTrackInfo() in IOBDMedia.h
*
* DKIOCBDREPORTKEY see IOBDMedia::reportKey() in IOBDMedia.h
* DKIOCBDSENDKEY see IOBDMedia::sendKey() in IOBDMedia.h
*
* DKIOCBDGETSPEED see IOBDMedia::getSpeed() in IOBDMedia.h
* DKIOCBDSETSPEED see IOBDMedia::setSpeed() in IOBDMedia.h
*
* in /System/Library/Frameworks/Kernel.framework/Headers/IOKit/storage/
*/
__exported_push
typedef struct
{
uint8_t format;
uint8_t reserved0008[3]; /* reserved, clear to zero */
uint32_t address;
uint8_t grantID;
uint8_t layer;
uint8_t reserved0080[4]; /* reserved, clear to zero */
uint16_t bufferLength;
void * buffer;
} dk_bd_read_structure_t;
typedef struct
{
uint8_t format;
uint8_t keyClass;
uint8_t blockCount;
uint8_t reserved0024[1]; /* reserved, clear to zero */
uint32_t address;
uint8_t grantID;
uint8_t reserved0072[5]; /* reserved, clear to zero */
uint16_t bufferLength;
void * buffer;
} dk_bd_report_key_t;
typedef struct
{
uint8_t format;
uint8_t keyClass;
uint8_t reserved0016[6]; /* reserved, clear to zero */
uint8_t grantID;
uint8_t reserved0072[5]; /* reserved, clear to zero */
uint16_t bufferLength;
void * buffer;
} dk_bd_send_key_t;
typedef struct
{
uint8_t reserved0000[14]; /* reserved, clear to zero */
uint16_t bufferLength; /* actual length on return */
void * buffer;
} dk_bd_read_disc_info_t;
typedef struct
{
uint8_t reserved0000[4]; /* reserved, clear to zero */
uint32_t address;
uint8_t addressType;
uint8_t reserved0072[5]; /* reserved, clear to zero */
uint16_t bufferLength; /* actual length on return */
void * buffer;
} dk_bd_read_track_info_t;
__exported_pop
#define DKIOCBDREADSTRUCTURE _IOW('d', 160, dk_bd_read_structure_t)
#define DKIOCBDREPORTKEY _IOW('d', 161, dk_bd_report_key_t)
#define DKIOCBDSENDKEY _IOW('d', 162, dk_bd_send_key_t)
#define DKIOCBDGETSPEED _IOR('d', 163, uint16_t)
#define DKIOCBDSETSPEED _IOW('d', 163, uint16_t)
#define DKIOCBDREADDISCINFO _IOWR('d', 164, dk_bd_read_disc_info_t)
#define DKIOCBDREADTRACKINFO _IOWR('d', 165, dk_bd_read_track_info_t)
#define DKIOCBDSPLITTRACK _IOW('d', 166, uint32_t)
#ifdef KERNEL
#ifdef __cplusplus
/*
* Kernel
*/
#include <IOKit/storage/IOBDMedia.h>
#include <IOKit/storage/IOMediaBSDClient.h>
/*
* Class
*/
class __exported IOBDMediaBSDClient : public IOMediaBSDClient
{
OSDeclareDefaultStructors(IOBDMediaBSDClient)
protected:
struct ExpansionData { /* */ };
ExpansionData * _expansionData;
public:
/*
* Obtain this object's provider. We override the superclass's method
* to return a more specific subclass of IOService -- IOBDMedia. This
* method serves simply as a convenience to subclass developers.
*/
virtual IOBDMedia * getProvider() const;
/*
* Process a BD-specific ioctl.
*/
virtual int ioctl(dev_t dev, u_long cmd, caddr_t data, int flags, proc_t proc);
OSMetaClassDeclareReservedUnused(IOBDMediaBSDClient, 0);
OSMetaClassDeclareReservedUnused(IOBDMediaBSDClient, 1);
OSMetaClassDeclareReservedUnused(IOBDMediaBSDClient, 2);
OSMetaClassDeclareReservedUnused(IOBDMediaBSDClient, 3);
OSMetaClassDeclareReservedUnused(IOBDMediaBSDClient, 4);
OSMetaClassDeclareReservedUnused(IOBDMediaBSDClient, 5);
OSMetaClassDeclareReservedUnused(IOBDMediaBSDClient, 6);
OSMetaClassDeclareReservedUnused(IOBDMediaBSDClient, 7);
};
#endif /* __cplusplus */
#endif /* KERNEL */
#endif /* !_IOBDMEDIABSDCLIENT_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/storage/IOFireWireStorageCharacteristics.h | /*
* Copyright (c) 1998-2009 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _IOKIT_IO_FIREWIRE_STORAGE_DEVICE_CHARACTERISTICS_H_
#define _IOKIT_IO_FIREWIRE_STORAGE_DEVICE_CHARACTERISTICS_H_
//
// Bridge Characteristics - Characteristics defined for FireWire bridges.
//
/*!
@defined kIOPropertyBridgeCharacteristicsKey
@discussion This key is used to define Bridge Characteristics for a particular
devices's bridge chipset. It has an associated dictionary which lists the
bridge characteristics.
Requirement: Optional
Example:
<pre>
@textblock
<dict>
<key>Bridge Characteristics</key>
<dict>
<key>Bridge Vendor Name</key>
<string>Oxford Semiconductor</string>
<key>Bridge Model Name</key>
<string>FW911</string>
<key>Bridge Revision Level</key>
<string>3.7</string>
</dict>
</dict>
@/textblock
</pre>
*/
#define kIOPropertyBridgeCharacteristicsKey "Bridge Characteristics"
#define kIOPropertyBridgeVendorNameKey "Bridge Vendor Name"
#define kIOPropertyBridgeModelNameKey "Bridge Model Name"
#define kIOPropertyBridgeRevisionLevelKey "Bridge Revision Level"
#endif /* _IOKIT_IO_FIREWIRE_STORAGE_DEVICE_CHARACTERISTICS_H_ */ |
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/storage/IODVDBlockStorageDevice.h | /*
* Copyright (c) 1998-2014 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/*!
* @header IODVDBlockStorageDevice
* @abstract
* This header contains the IODVDBlockStorageDevice class definition.
*/
#ifndef _IODVDBLOCKSTORAGEDEVICE_H
#define _IODVDBLOCKSTORAGEDEVICE_H
#include <IOKit/storage/IODVDTypes.h>
/*!
* @defined kIODVDBlockStorageDeviceClass
* @abstract
* kIODVDBlockStorageDeviceClass is the name of the IODVDBlockStorageDevice class.
* @discussion
* kIODVDBlockStorageDeviceClass is the name of the IODVDBlockStorageDevice class.
*/
#define kIODVDBlockStorageDeviceClass "IODVDBlockStorageDevice"
#ifdef KERNEL
#ifdef __cplusplus
/*
* Kernel
*/
#include <IOKit/storage/IOCDBlockStorageDevice.h>
/* Property used for matching, so the generic driver gets the nub it wants. */
#define kIOBlockStorageDeviceTypeDVD "DVD"
/*!
* @class
* IODVDBlockStorageDevice : public IOCDBlockStorageDevice
* @abstract
* The IODVDBlockStorageDevice class is a generic DVD block storage device
* abstraction.
* @discussion
* This class is the protocol for generic DVD functionality, independent of
* the physical connection protocol (e.g. SCSI, ATA, USB).
*
* The APIs are the union of CD APIs and all
* necessary new low-level DVD APIs.
*
* A subclass implements relay methods that translate our requests into
* calls to a protocol- and device-specific provider.
*/
class IODVDBlockStorageDevice : public IOCDBlockStorageDevice {
OSDeclareAbstractStructors(IODVDBlockStorageDevice)
protected:
struct ExpansionData { /* */ };
ExpansionData * _expansionData;
public:
/* Overrides from IORegistryEntry */
virtual bool init(OSDictionary * properties);
/* New APIs for DVD */
virtual IOReturn reportKey(IOMemoryDescriptor *buffer,const DVDKeyClass keyClass,
const UInt32 lba,const UInt8 agid,const DVDKeyFormat keyFormat) __attribute__ ((deprecated));
virtual IOReturn sendKey(IOMemoryDescriptor *buffer,const DVDKeyClass keyClass,
const UInt8 agid,const DVDKeyFormat keyFormat) = 0;
virtual IOReturn readDVDStructure(IOMemoryDescriptor *buffer,const DVDStructureFormat format,
const UInt32 address,const UInt8 layer,const UInt8 agid) = 0;
virtual IOReturn reportKey(IOMemoryDescriptor *buffer,const DVDKeyClass keyClass,
const UInt32 lba,const UInt8 blockCount,
const UInt8 agid,const DVDKeyFormat keyFormat); /* 10.12.0 */
OSMetaClassDeclareReservedUsed(IODVDBlockStorageDevice, 0); /* reportKey */
OSMetaClassDeclareReservedUnused(IODVDBlockStorageDevice, 1);
OSMetaClassDeclareReservedUnused(IODVDBlockStorageDevice, 2);
OSMetaClassDeclareReservedUnused(IODVDBlockStorageDevice, 3);
OSMetaClassDeclareReservedUnused(IODVDBlockStorageDevice, 4);
OSMetaClassDeclareReservedUnused(IODVDBlockStorageDevice, 5);
OSMetaClassDeclareReservedUnused(IODVDBlockStorageDevice, 6);
OSMetaClassDeclareReservedUnused(IODVDBlockStorageDevice, 7);
OSMetaClassDeclareReservedUnused(IODVDBlockStorageDevice, 8);
OSMetaClassDeclareReservedUnused(IODVDBlockStorageDevice, 9);
OSMetaClassDeclareReservedUnused(IODVDBlockStorageDevice, 10);
OSMetaClassDeclareReservedUnused(IODVDBlockStorageDevice, 11);
OSMetaClassDeclareReservedUnused(IODVDBlockStorageDevice, 12);
OSMetaClassDeclareReservedUnused(IODVDBlockStorageDevice, 13);
OSMetaClassDeclareReservedUnused(IODVDBlockStorageDevice, 14);
OSMetaClassDeclareReservedUnused(IODVDBlockStorageDevice, 15);
OSMetaClassDeclareReservedUnused(IODVDBlockStorageDevice, 16);
OSMetaClassDeclareReservedUnused(IODVDBlockStorageDevice, 17);
OSMetaClassDeclareReservedUnused(IODVDBlockStorageDevice, 18);
OSMetaClassDeclareReservedUnused(IODVDBlockStorageDevice, 19);
OSMetaClassDeclareReservedUnused(IODVDBlockStorageDevice, 20);
OSMetaClassDeclareReservedUnused(IODVDBlockStorageDevice, 21);
OSMetaClassDeclareReservedUnused(IODVDBlockStorageDevice, 22);
OSMetaClassDeclareReservedUnused(IODVDBlockStorageDevice, 23);
OSMetaClassDeclareReservedUnused(IODVDBlockStorageDevice, 24);
OSMetaClassDeclareReservedUnused(IODVDBlockStorageDevice, 25);
OSMetaClassDeclareReservedUnused(IODVDBlockStorageDevice, 26);
OSMetaClassDeclareReservedUnused(IODVDBlockStorageDevice, 27);
OSMetaClassDeclareReservedUnused(IODVDBlockStorageDevice, 28);
OSMetaClassDeclareReservedUnused(IODVDBlockStorageDevice, 29);
OSMetaClassDeclareReservedUnused(IODVDBlockStorageDevice, 30);
OSMetaClassDeclareReservedUnused(IODVDBlockStorageDevice, 31);
};
#endif /* __cplusplus */
#endif /* KERNEL */
#endif /* !_IODVDBLOCKSTORAGEDEVICE_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/storage/IOCDBlockStorageDriver.h | /*
* Copyright (c) 1998-2014 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/*
* IOCDBlockStorageDriver.h
*
* This class implements CD functionality, independent of
* the physical connection protocol (e.g. SCSI, ATA, USB).
*
* A protocol-specific provider implements the functionality using an appropriate
* protocol and commands.
*/
#ifndef _IOCDBLOCKSTORAGEDRIVER_H
#define _IOCDBLOCKSTORAGEDRIVER_H
#include <IOKit/IOTypes.h>
#include <IOKit/storage/IOCDBlockStorageDevice.h>
#include <IOKit/storage/IOCDTypes.h>
#include <IOKit/storage/IOBlockStorageDriver.h>
/*
* @defined kIOCDBlockStorageDriverClass
* @abstract
* kIOCDBlockStorageDriverClass is the name of the IOCDBlockStorageDriver class.
* @discussion
* kIOCDBlockStorageDriverClass is the name of the IOCDBlockStorageDriver class.
*/
#define kIOCDBlockStorageDriverClass "IOCDBlockStorageDriver"
class IOCDBlockStorageDriver : public IOBlockStorageDriver {
OSDeclareDefaultStructors(IOCDBlockStorageDriver)
public:
static const UInt64 kBlockSizeCD = 2352;
static const UInt8 kBlockTypeCD = 0x01;
/* Overrides of IORegistryEntry */
virtual bool init(OSDictionary * properties);
virtual void free(void);
/* Overrides of IOBlockStorageDriver: */
virtual IOReturn ejectMedia(void);
virtual void executeRequest(UInt64 byteStart,
IOMemoryDescriptor *buffer,
IOStorageAttributes *attributes,
IOStorageCompletion *completion,
Context *context);
virtual const char * getDeviceTypeName(void);
virtual IOMedia * instantiateDesiredMediaObject(void);
virtual IOMedia * instantiateMediaObject(UInt64 base,UInt64 byteSize,
UInt32 blockSize,char *mediaName);
virtual IOReturn recordMediaParameters(void);
/* End of IOBlockStorageDriver overrides. */
/*
* @function getMediaType
* @abstract
* Get the current type of media inserted in the CD drive.
* @discussion
* Certain I/O operations may not be allowed depending on the type of
* media currently inserted. For example, one cannot issue write operations
* if CD-ROM media is inserted.
* @result
* See the kCDMediaType constants in IOCDTypes.h.
*/
virtual UInt32 getMediaType(void);
/* -------------------------------------------------*/
/* APIs implemented here, exported by IOCDMedia: */
/* -------------------------------------------------*/
virtual CDTOC * getTOC(void);
virtual void readCD(IOService *client,
UInt64 byteStart,
IOMemoryDescriptor *buffer,
CDSectorArea sectorArea,
CDSectorType sectorType,
IOStorageAttributes *attributes,
IOStorageCompletion *completion);
virtual IOReturn readISRC(UInt8 track,CDISRC isrc);
virtual IOReturn readMCN(CDMCN mcn);
/* end of IOCDMedia APIs */
/*
* Obtain this object's provider. We override the superclass's method to
* return a more specific subclass of IOService -- IOCDBlockStorageDevice.
* This method serves simply as a convenience to subclass developers.
*/
virtual IOCDBlockStorageDevice * getProvider() const;
protected:
/* Overrides of IOBlockStorageDriver behavior. */
/* When CD media is inserted, we want to create multiple nubs for the data and
* audio tracks, for sessions, and the entire media. We override the methods
* that manage nubs.
*/
virtual IOReturn acceptNewMedia(void);
virtual IOReturn decommissionMedia(bool forcible);
/* End of IOBlockStorageDriver overrides. */
/* Internally used methods: */
using IOBlockStorageDriver::getMediaBlockSize;
virtual IOReturn cacheTocInfo(void);
virtual UInt64 getMediaBlockSize(CDSectorArea area,CDSectorType type);
virtual void prepareRequest(UInt64 byteStart,
IOMemoryDescriptor *buffer,
CDSectorArea sectorArea,
CDSectorType sectorType,
IOStorageAttributes *attributes,
IOStorageCompletion *completion);
/* ------- */
struct ExpansionData
{
UInt32 minBlockNumberAudio;
UInt32 maxBlockNumberAudio;
};
ExpansionData * _expansionData;
#define _minBlockNumberAudio \
IOCDBlockStorageDriver::_expansionData->minBlockNumberAudio
#define _maxBlockNumberAudio \
IOCDBlockStorageDriver::_expansionData->maxBlockNumberAudio
UInt32 _reserved0032;
/* We keep the TOC here because we'll always need it, so what the heck.
*
* There are possible "point" track entries for 0xa0..a2, 0xb0..b4, and 0xc0..0xc1.
* Tracks need not start at 1, as long as they're between 1 and 99, and have contiguous
* numbers.
*/
CDTOC * _toc;
UInt32 _tocSize;
/* ------- */
IOReturn reportDiscInfo(CDDiscInfo *discInfo);
IOReturn reportTrackInfo(UInt16 track,CDTrackInfo *trackInfo);
public:
virtual IOReturn getSpeed(UInt16 * kilobytesPerSecond);
virtual IOReturn setSpeed(UInt16 kilobytesPerSecond);
virtual IOReturn readTOC(IOMemoryDescriptor *buffer,CDTOCFormat format,
UInt8 formatAsTime,UInt8 trackOrSessionNumber,
UInt16 *actualByteCount);
virtual IOReturn readDiscInfo(IOMemoryDescriptor *buffer,
UInt16 *actualByteCount);
virtual IOReturn readTrackInfo(IOMemoryDescriptor *buffer,UInt32 address,
CDTrackInfoAddressType addressType,
UInt16 *actualByteCount);
virtual void writeCD(IOService *client,
UInt64 byteStart,
IOMemoryDescriptor *buffer,
CDSectorArea sectorArea,
CDSectorType sectorType,
IOStorageAttributes *attributes,
IOStorageCompletion *completion);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver, 0);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver, 1);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver, 2);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver, 3);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver, 4);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver, 5);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver, 6);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver, 7);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver, 8);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver, 9);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver, 10);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver, 11);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver, 12);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver, 13);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver, 14);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver, 15);
};
#endif
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/IOKit/storage/IOCDBlockStorageDevice.h | /*
* Copyright (c) 1998-2014 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/*!
* @header IOCDBlockStorageDevice
* @abstract
* This header contains the IOCDBlockStorageDevice class definition.
*/
#ifndef _IOCDBLOCKSTORAGEDEVICE_H
#define _IOCDBLOCKSTORAGEDEVICE_H
#include <IOKit/storage/IOCDTypes.h>
/*!
* @defined kIOCDBlockStorageDeviceClass
* @abstract
* kIOCDBlockStorageDeviceClass is the name of the IOCDBlockStorageDevice class.
* @discussion
* kIOCDBlockStorageDeviceClass is the name of the IOCDBlockStorageDevice class.
*/
#define kIOCDBlockStorageDeviceClass "IOCDBlockStorageDevice"
#ifdef KERNEL
#ifdef __cplusplus
/*
* Kernel
*/
#include <IOKit/storage/IOBlockStorageDevice.h>
/* Property used for matching, so the generic driver gets the nub it wants. */
#define kIOBlockStorageDeviceTypeCDROM "CDROM"
/*!
* @class
* IOCDBlockStorageDevice : public IOBlockStorageDevice
* @abstract
* The IOCDBlockStorageDevice class is a generic CD block storage device
* abstraction.
* @discussion
* This class is the protocol for generic CD functionality, independent of
* the physical connection protocol (e.g. SCSI, ATA, USB).
*
* The APIs are the union of CD (block storage) data APIs and all
* necessary low-level CD APIs.
*
* A subclass implements relay methods that translate our requests into
* calls to a protocol- and device-specific provider.
*/
class IOCDBlockStorageDevice : public IOBlockStorageDevice {
OSDeclareAbstractStructors(IOCDBlockStorageDevice)
protected:
struct ExpansionData { /* */ };
ExpansionData * _expansionData;
public:
/* Overrides from IORegistryEntry */
virtual bool init(OSDictionary * properties);
/*-----------------------------------------*/
/* CD APIs */
/*-----------------------------------------*/
virtual IOReturn doAsyncReadCD(IOMemoryDescriptor *buffer,
UInt32 block,UInt32 nblks,
CDSectorArea sectorArea,
CDSectorType sectorType,
IOStorageCompletion completion) = 0;
virtual UInt32 getMediaType(void) = 0;
virtual IOReturn readISRC(UInt8 track,CDISRC isrc) = 0;
virtual IOReturn readMCN(CDMCN mcn) = 0;
virtual IOReturn readTOC(IOMemoryDescriptor *buffer) = 0;
/*-----------------------------------------*/
/* CD APIs */
/*-----------------------------------------*/
virtual IOReturn getSpeed(UInt16 * kilobytesPerSecond) = 0;
virtual IOReturn setSpeed(UInt16 kilobytesPerSecond) = 0;
virtual IOReturn readTOC(IOMemoryDescriptor *buffer,CDTOCFormat format,
UInt8 msf,UInt8 trackSessionNumber,
UInt16 *actualByteCount) = 0;
virtual IOReturn readDiscInfo(IOMemoryDescriptor *buffer,
UInt16 *actualByteCount) = 0;
virtual IOReturn readTrackInfo(IOMemoryDescriptor *buffer,UInt32 address,
CDTrackInfoAddressType addressType,
UInt16 *actualByteCount) = 0;
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDevice, 0);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDevice, 1);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDevice, 2);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDevice, 3);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDevice, 4);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDevice, 5);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDevice, 6);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDevice, 7);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDevice, 8);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDevice, 9);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDevice, 10);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDevice, 11);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDevice, 12);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDevice, 13);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDevice, 14);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDevice, 15);
};
#endif /* __cplusplus */
#endif /* KERNEL */
#endif /* !_IOCDBLOCKSTORAGEDEVICE_H */
|
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.