Index: branches/azimutz/Cleancut/i386/libsaio/Makefile =================================================================== --- branches/azimutz/Cleancut/i386/libsaio/Makefile (revision 884) +++ branches/azimutz/Cleancut/i386/libsaio/Makefile (revision 885) @@ -1,38 +1,33 @@ +SRCROOT = $(shell pwd)/../../ +OBJROOT = $(SRCROOT)/obj/i386/libsaio +SYMROOT = $(SRCROOT)/sym/i386 +DSTROOT = $(SRCROOT)/dst/i386 +DOCROOT = $(SRCROOT)/doc +IMGROOT = $(SRCROOT)/sym/cache +IMGSKELROOT = $(SRCROOT)/imgskel +CDBOOT = ${IMGROOT}/usr/standalone/i386/cdboot DIR = libsaio -include ../MakePaths.dir +include ${SRCROOT}/Make.rules UTILDIR = ../util LIBSADIR = ../libsa BOOT2DIR = ../boot2 -INSTALLDIR = $(DSTROOT)/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders/standalone -#SYMROOT= -OPTIM = -Os -Oz -DEBUG = -DNOTHING -#DEBUG = -DDEBUG_CPU=1 -DDEBUG_MEM=1 -DDEBUG_SPD=1 -DDEBUG_PCI=1 -DDEBUG_SMBIOS=1 -CFLAGS = $(RC_CFLAGS) $(OPTIM) $(MORECPP) -arch i386 -g -Wmost \ +DEFINES = -DNOTHING +#DEFINES = -DDEBUG_CPU=1 -DDEBUG_MEM=1 -DDEBUG_SPD=1 -DDEBUG_PCI=1 -DDEBUG_SMBIOS=1 + +CFLAGS := $(CFLAGS) $(RC_CFLAGS) $(MORECPP) -arch i386 \ -D__ARCHITECTURE__=\"i386\" -DSAIO_INTERNAL_USER \ - -DRCZ_COMPRESSED_FILE_SUPPORT $(DEBUG) \ + -DRCZ_COMPRESSED_FILE_SUPPORT \ -fno-builtin -static $(OMIT_FRAME_POINTER_CFLAG) \ -mpreferred-stack-boundary=2 -fno-align-functions -fno-stack-protector \ - -march=pentium4 -msse2 -mfpmath=sse -msoft-float + -march=pentium4 -msse2 -mfpmath=sse -msoft-float -nostdinc -include $(SRCROOT)/autoconf.h + +CPPFLAGS := $(CPPFLAGS) -nostdinc++ -DEFINES= -CONFIG = hd -INC = -I. -I$(SYMROOT) -I$(UTILDIR) -I$(LIBSADIR) -I$(BOOT2DIR) -ifneq "" "$(wildcard /bin/mkdirs)" - MKDIRS = /bin/mkdirs -else - MKDIRS = /bin/mkdir -p -endif -AS = as -LD = ld -# LIBS= -lc_static -LIBS= +INC = -I. -I$(SYMROOT) -I$(LIBSADIR) -I$(BOOT2DIR) -I${SRCROOT}/i386/include -VPATH = $(OBJROOT):$(SYMROOT) - SAIO_OBJS = table.o asm.o bios.o biosfn.o \ disk.o sys.o cache.o bootstruct.o \ stringTable.o load.o pci.o allocate.o misc.o \ @@ -44,53 +39,24 @@ fake_efi.o ext2fs.o \ hpet.o dram_controllers.o spd.o usb.o pci_setup.o \ device_inject.o pci_root.o \ - convert.o aml_generator.o + convert.o aml_generator.o console.o +LIBS = libsaio.a +LIBS := $(addprefix $(SYMROOT)/, $(LIBS)) -SAIO_EXTERN_OBJS = console.o - -SFILES = -CFILES = -HFILES = -EXPORTED_HFILES = -INSTALLED_HFILES = -OTHERFILES = Makefile -ALLSRC = $(SFILES) $(CFILES) \ - $(HFILES) $(OTHERFILES) -LIBS = libsaio.a DIRS_NEEDED = $(OBJROOT) $(SYMROOT) -#GENFILES = $(SYMROOT)/saio_internal.h \ -# $(SYMROOT)/saio_external.h \ -# $(SYMROOT)/saio_defs.h \ -# $(SYMROOT)/saio_table.c -#SIG = $(SYMROOT)/sig -all embedtheme: $(DIRS_NEEDED) libsaio.h $(LIBS) +all: $(DIRS_NEEDED) $(LIBS) -#libsaio_static.a: $(SAIO_OBJS) -# rm -f $(SYMROOT)/$@ -# ar q $(SYMROOT)/$@ $(SAIO_OBJS) -# ranlib $(SYMROOT)/$@ - -libsaio.a: $(SAIO_EXTERN_OBJS) $(SAIO_OBJS) - @echo "\t[RM] $(SYMROOT)/$(@F)" - @rm -f $(SYMROOT)/$(@F) - @echo "\t[AR] $@" - @ar q $(SYMROOT)/$(@F) $^ &> /dev/null - @echo "\t[RANLIB] $@" +$(LIBS): $(addprefix $(OBJROOT)/, $(SAIO_OBJS)) + @echo "\t[RM] $@" + @rm -f $@ + @echo "\t[AR] $(@F)" + @ar q $@ $^ &> /dev/null + @echo "\t[RANLIB] $(@F)" @ranlib $(SYMROOT)/$(@F) -#saio_internal.h: saio_external.h -#saio_table.c: saio_external.h -#saio_defs.h: saio_external.h -#saio_external.h: saio.def -# $(SIG) -d $(SYMROOT) -n saio saio.def -#installhdrs:: $(INSTALLDIR) -# cp $(INSTALLED_HFILES) $(INSTALLDIR) - -include ../MakeInc.dir - # dependencies -include $(OBJROOT)/Makedep Index: branches/azimutz/Cleancut/i386/libsaio/ufs.c =================================================================== --- branches/azimutz/Cleancut/i386/libsaio/ufs.c (revision 884) +++ branches/azimutz/Cleancut/i386/libsaio/ufs.c (revision 885) @@ -26,7 +26,7 @@ * * DRI: Josh de Cesare */ - +#if 0 #include #include "ufs.h" @@ -533,3 +533,4 @@ return bytesLeft; } +#endif \ No newline at end of file Index: branches/azimutz/Cleancut/i386/libsaio/Cconfig =================================================================== Index: branches/azimutz/Cleancut/i386/libsaio/ufs_byteorder.c =================================================================== --- branches/azimutz/Cleancut/i386/libsaio/ufs_byteorder.c (revision 884) +++ branches/azimutz/Cleancut/i386/libsaio/ufs_byteorder.c (revision 885) @@ -25,10 +25,10 @@ * Copyright 1993 NeXT, Inc. * All rights reserved. */ - +#if 0 #include #include -#include +//#include #include #include #include "ufs_byteorder.h" @@ -169,3 +169,5 @@ break; } } + +#endif Index: branches/azimutz/Cleancut/i386/libsaio/sys.c =================================================================== --- branches/azimutz/Cleancut/i386/libsaio/sys.c (revision 884) +++ branches/azimutz/Cleancut/i386/libsaio/sys.c (revision 885) @@ -58,7 +58,6 @@ "Preboot" ramdisk support added by David Elliott */ -#include #include "libsaio.h" #include "boot.h" @@ -66,17 +65,15 @@ #include "disk.h" #include "ramdisk.h" #include "xml.h" -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 -# include -#else -# include -#endif -#include + +#include +//#include + #if 0 /* No OS X release has ever included this. */ #include #else -/* copied from uuid/namespace.h, just like BootX's fs.c does. */ -UUID_DEFINE( kFSUUIDNamespaceSHA1, 0xB3, 0xE2, 0x0F, 0x39, 0xF2, 0x92, 0x11, 0xD6, 0x97, 0xA4, 0x00, 0x30, 0x65, 0x43, 0xEC, 0xAC ); +// from our uuid/namespace.h (UFS and HFS uuids can live in the same space?) +static unsigned char kFSUUIDNamespaceSHA1[] = {0xB3,0xE2,0x0F,0x39,0xF2,0x92,0x11,0xD6,0x97,0xA4,0x00,0x30,0x65,0x43,0xEC,0xAC}; #endif extern int multiboot_partition; Index: branches/azimutz/Cleancut/i386/libsaio/load.c =================================================================== --- branches/azimutz/Cleancut/i386/libsaio/load.c (revision 884) +++ branches/azimutz/Cleancut/i386/libsaio/load.c (revision 885) @@ -277,11 +277,7 @@ i386ThreadState = (i386_thread_state_t *) (cmdBase + sizeof(struct thread_command) + 8); - #if defined(__DARWIN_UNIX03) && __DARWIN_UNIX03 - *entry = i386ThreadState->__eip; - #else *entry = i386ThreadState->eip; - #endif return 0; } @@ -292,11 +288,7 @@ x86_64ThreadState = (x86_thread_state64_t *) (cmdBase + sizeof(struct thread_command) + 8); - #if defined(__DARWIN_UNIX03) && __DARWIN_UNIX03 - *entry = x86_64ThreadState->__rip; - #else *entry = x86_64ThreadState->rip; - #endif return 0; } Index: branches/azimutz/Cleancut/i386/libsaio/ufs_byteorder.h =================================================================== --- branches/azimutz/Cleancut/i386/libsaio/ufs_byteorder.h (revision 884) +++ branches/azimutz/Cleancut/i386/libsaio/ufs_byteorder.h (revision 885) @@ -36,13 +36,12 @@ #ifndef __LIBSAIO_UFS_BYTEORDER_H #define __LIBSAIO_UFS_BYTEORDER_H -#include +//#include +#include #include #include -#include #include #include -#include void byte_swap_ints(unsigned int *array, int count); void byte_swap_shorts(unsigned short *array, int count); Index: branches/azimutz/Cleancut/i386/libsaio/sl.h =================================================================== --- branches/azimutz/Cleancut/i386/libsaio/sl.h (revision 884) +++ branches/azimutz/Cleancut/i386/libsaio/sl.h (revision 885) @@ -27,7 +27,7 @@ #include #include -#include +#include #include "libsaio.h" #define SWAP_BE16(x) OSSwapBigToHostInt16(x) Index: branches/azimutz/Cleancut/i386/libsaio/platform.h =================================================================== --- branches/azimutz/Cleancut/i386/libsaio/platform.h (revision 884) +++ branches/azimutz/Cleancut/i386/libsaio/platform.h (revision 885) @@ -7,7 +7,7 @@ #ifndef __LIBSAIO_PLATFORM_H #define __LIBSAIO_PLATFORM_H -#include "libsaio.h" +//#include "libsaio.h" extern bool platformCPUFeature(uint32_t); extern void scan_platform(void); Index: branches/azimutz/Cleancut/i386/libsaio/pci_setup.c =================================================================== --- branches/azimutz/Cleancut/i386/libsaio/pci_setup.c (revision 884) +++ branches/azimutz/Cleancut/i386/libsaio/pci_setup.c (revision 885) @@ -3,6 +3,7 @@ #include "bootstruct.h" #include "pci.h" #include "modules.h" +#include "modules.h" extern void set_eth_builtin(pci_dt_t *eth_dev); @@ -47,6 +48,8 @@ break; } + execute_hook("PCIDevice", current, NULL, NULL, NULL); + setup_pci_devs(current->children); current = current->next; } Index: branches/azimutz/Cleancut/i386/libsaio/smbios.c =================================================================== --- branches/azimutz/Cleancut/i386/libsaio/smbios.c (revision 884) +++ branches/azimutz/Cleancut/i386/libsaio/smbios.c (revision 885) @@ -606,6 +606,8 @@ for (i = 0; i < numOfSetters; i++) if ((structPtr->orig->type == SMBSetters[i].type) && (SMBSetters[i].fieldOffset < structPtr->orig->length)) { + if (SMBSetters[i].fieldOffset > structPtr->orig->length) + continue; setterFound = true; setSMBValue(structPtr, i, (returnType *)((uint8_t *)structPtr->new + SMBSetters[i].fieldOffset)); } Property changes on: branches/azimutz/Cleancut/i386/libsaio/smbios.h ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk/i386/libsaio/smbios.h:r827-884 Index: branches/azimutz/Cleancut/i386/libsaio/msdos.c =================================================================== --- branches/azimutz/Cleancut/i386/libsaio/msdos.c (revision 884) +++ branches/azimutz/Cleancut/i386/libsaio/msdos.c (revision 885) @@ -45,7 +45,6 @@ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - #define tolower(c) (((c)>='A' && c<='Z')?((c) | 0x20):(c)) #include "libsaio.h" #include "sl.h" @@ -61,10 +60,6 @@ #define CLUST_RSRVD16 0xfff8 /* reserved cluster range */ #define CLUST_RSRVD12 0xff8 /* reserved cluster range */ - -#define false 0 -#define true 1 - static int msdosressector=0; static int msdosnfats = 0; static int msdosfatsecs = 0; Index: branches/azimutz/Cleancut/i386/libsaio/md5c.c =================================================================== --- branches/azimutz/Cleancut/i386/libsaio/md5c.c (revision 884) +++ branches/azimutz/Cleancut/i386/libsaio/md5c.c (revision 885) @@ -29,14 +29,9 @@ */ #include "libsaio.h" +#include -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 -# include -#else -# include -#endif - #define Encode memcpy #define Decode memcpy Index: branches/azimutz/Cleancut/i386/boot0/chain0.s =================================================================== --- branches/azimutz/Cleancut/i386/boot0/chain0.s (revision 884) +++ branches/azimutz/Cleancut/i386/boot0/chain0.s (revision 885) @@ -43,7 +43,7 @@ ; ; Set to 1 to enable obscure debug messages. ; -DEBUG EQU 0 +DEBUG EQU CONFIG_BOOT0_DEBUG ; ; Set to 1 to support loading the partition booter (boot1) from a Index: branches/azimutz/Cleancut/i386/boot0/boot0.s =================================================================== --- branches/azimutz/Cleancut/i386/boot0/boot0.s (revision 884) +++ branches/azimutz/Cleancut/i386/boot0/boot0.s (revision 885) @@ -52,12 +52,12 @@ ; ; Set to 1 to enable obscure debug messages. ; -DEBUG EQU 0 +DEBUG EQU CONFIG_BOOT0_DEBUG ; ; Set to 1 to enable verbose mode ; -VERBOSE EQU 1 +VERBOSE EQU CONFIG_BOOT0_VERBOSE ; ; Various constants. @@ -315,7 +315,7 @@ jne .Pass2 .Pass1: -%ifdef HFSFIRST +%if CONFIG_BOOT0_HFSFIRST cmp BYTE [si + part.type], kPartTypeHFS ; In pass 1 we're going to find a HFS+ partition ; equipped with boot1h in its boot record ; regardless if it's active or not. @@ -332,7 +332,7 @@ jmp .tryToBoot .Pass2: -%ifdef HFSFIRST +%if CONFIG_BOOT0_HFSFIRST cmp BYTE [si + part.bootid], kPartActive ; In pass 2 we are walking on the standard path ; by trying to hop on the active partition. jne .continue Index: branches/azimutz/Cleancut/i386/boot0/Cconfig =================================================================== --- branches/azimutz/Cleancut/i386/boot0/Cconfig (revision 0) +++ branches/azimutz/Cleancut/i386/boot0/Cconfig (revision 885) @@ -0,0 +1,30 @@ +config BOOT0_HFSFIRST + bool "boot0 HFS prefered" + default y + help + Say Y here if you want boot0 to attempt to boot the first + hfs partition found, instead of the active partition. + +config BOOT0_DEBUG + bool "boot0 debug support" + default n + help + Say Y here if you want to compile in boot0 + debug messages. On an error, boot0 will print + one of thefollowing: + > start_reloc was called + * Boot partition found + J Jumping to partition booter + < read_lba + R INT13/F42 error + + + +config BOOT0_VERBOSE + bool "boot0 verbose support" + default y + help + Say Y here if you want to enable boot0 verbose messages. + boot0 will pronto out status updates as it executes to + notify the user of progress in the initial boot sequence. + When in doubt, say "Y". Index: branches/azimutz/Cleancut/i386/boot0/Makefile =================================================================== --- branches/azimutz/Cleancut/i386/boot0/Makefile (revision 884) +++ branches/azimutz/Cleancut/i386/boot0/Makefile (revision 885) @@ -1,31 +1,26 @@ +SRCROOT = $(shell pwd)/../../ +OBJROOT = $(SRCROOT)/obj/i386/boot0 +SYMROOT = $(SRCROOT)/sym/i386 +DSTROOT = $(SRCROOT)/dst/i386 +DOCROOT = $(SRCROOT)/doc +IMGROOT = $(SRCROOT)/sym/cache +IMGSKELROOT = $(SRCROOT)/imgskel +CDBOOT = ${IMGROOT}/usr/standalone/i386/cdboot DIR = boot0 -include ../MakePaths.dir +include ${SRCROOT}/Make.rules -#NASM = /Developer/usr/bin/nasm -NASM = $(shell which nasm) -INSTALLDIR = $(DSTROOT)/usr/standalone/i386 DIRS_NEEDED = $(SYMROOT) -all embedtheme: $(DIRS_NEEDED) boot0 boot0hfs chain0 -boot0: boot0.s - @echo "\t[NASM] $@" - @$(NASM) boot0.s -o $(SYMROOT)/$@ +OBJECTS = boot0 chain0 +OBJECTS := $(addprefix $(SYMROOT)/, $(OBJECTS)) -boot0hfs: boot0.s Makefile $(NASM) - @echo "\t[NASM] $@" - @$(NASM) boot0.s -DHFSFIRST -o $(SYMROOT)/$@ +all: $(DIRS_NEEDED) $(OBJECTS) -chain0: chain0.s Makefile $(NASM) - @echo "\t[NASM] $@" - @$(NASM) chain0.s -o $(SYMROOT)/$@ +$(OBJECTS): $(SRCROOT)/autoconf.inc + @echo "\t[NASM] $(@F)" + @$(NASM) $(@F).s -o $@ -install_i386:: all $(INSTALLDIR) - cp $(SYMROOT)/boot0 $(SYMROOT)/chain0 $(INSTALLDIR) - cd $(INSTALLDIR); chmod u+w boot0 - -include ../MakeInc.dir - #dependencies Index: branches/azimutz/Cleancut/i386/include/IOKit/serial/IORS232SerialStreamSync.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/serial/IORS232SerialStreamSync.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/serial/IORS232SerialStreamSync.h (revision 885) @@ -0,0 +1,172 @@ +/* + * Copyright (c) 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@ + */ + +/* + * IORS232SerialStreamSync.h + * This file contains RS232 specific extensions to the IOSerialStreamSync class. + * + * 2000-10-21 gvdl Initial real change to IOKit serial family. + */ + +#ifndef _SERIAL_IORS232SERIALSTREAMSYNC_H +#define _SERIAL_IORS232SERIALSTREAMSYNC_H + +#include +#include + +/* + * Extra events for RS232 based PortDevices + */ + +#define PD_RS232_E_RX_LINE_BREAK (PD_DATA_VOID|PD_OP(63)) // line break was received +#define PD_RS232_E_LINE_BREAK (PD_DATA_BYTE|PD_OP(62)) // BOOL set/clear line break + +#define PD_RS232_E_RX_STOP_BITS (PD_DATA_LONG|PD_OP(61)) // half stop bits +#define PD_RS232_E_STOP_BITS (PD_DATA_LONG|PD_OP(60)) // half stop bits + +#define PD_RS232_E_XON_BYTE (PD_DATA_BYTE|PD_OP(59)) // The XON char for TX&RX +#define PD_RS232_E_XOFF_BYTE (PD_DATA_BYTE|PD_OP(58)) // The XOFF char for TX&RX + +#define PD_RS232_E_MIN_LATENCY (PD_DATA_BYTE|PD_OP(57)) // BOOL true if low latency req + +/* + * RS232 Parity stuff, used with the DATA_INTEGRITY event + */ +#define PD_RS232_PARITY_DEFAULT 0 // Valid only for RX, means follow TX +#define PD_RS232_PARITY_NONE 1 // No Parity bit inserted or expected +#define PD_RS232_PARITY_ODD 2 // Odd Parity bit inserted or expected +#define PD_RS232_PARITY_EVEN 3 // Even Parity bit inserted or expected +#define PD_RS232_PARITY_MARK 4 // Mark inserted or expected +#define PD_RS232_PARITY_SPACE 5 // Space inserted or expected +#define PD_RS232_PARITY_ANY 6 // Valid only for RX, means discard parity + +/* + * RS232 Flow Control specifiers, used with the FLOW_CONTROL event + * NB. The XON character is set with FLOW_START_DATA + * and the XOFF character is set with FLOW_STOP_DATA. + * + * Signal Name Direction + * RFR Ready For Receive Output generated by UART + * RTS Ready To Send (alias of RFR) Output generated by UART + * CTS Clear To Send Input sensed by UART + * DTR Data Terminal Ready Output generated by UART + * DSR Data Set Ready Input sensed by UART + * TXO XON/XOFF/XANY protocol Characters received by UART + * RXO XON/XOFF protocol Characters transmitted by UART + * DCD Data Carrier Detect Input sensed by UART + */ + +/* + * RS232 State Word extensions, based on + * Also the 'current state' bits for enq/deq of Flow Control event + */ +#define PD_RS232_S_MASK 0x0000ffffUL +#define PD_RS232_S_SHIFT 0 // to align State bits for enq/deq event +#define PD_RS232_D_MASK 0xffff0000UL +#define PD_RS232_D_SHIFT 16 // to align Delta bits for enq/deq event +#define PD_RS232_A_MASK 0x0000ffffUL +#define PD_RS232_A_SHIFT 0 // to align Auto bits for req/exec event +#define PD_RS232_N_MASK 0xffff0000UL +#define PD_RS232_N_SHIFT 16 // to align Notify bits for req/exec event + +#define PD_RS232_S_LE TIOCM_LE // line enable +#define PD_RS232_S_DTR TIOCM_DTR // data terminal ready +#define PD_RS232_S_RTS TIOCM_RTS // request to send +#define PD_RS232_S_RFR PD_RS232_S_RTS // ready for receive +#define PD_RS232_S_TXO TIOCM_ST // TX XON/XOFF +#define PD_RS232_S_RXO TIOCM_SR // RX XON/XOFF +#define PD_RS232_S_CTS TIOCM_CTS // clear to send +#define PD_RS232_S_CAR TIOCM_CAR // carrier detect +#define PD_RS232_S_DCD PD_RS232_S_CAR +#define PD_RS232_S_RNG TIOCM_RNG // ring +#define PD_RS232_S_RI PD_RS232_S_RNG +#define PD_RS232_S_DSR TIOCM_DSR // data set ready + +#define PD_RS232_S_BRK 0x00000800UL // break active Extension to TIOCM +#define PD_RS232_S_LOOP 0x00001000UL // LOOP back Extension to TIOCM +#define PD_RS232_S_TXQ 0x00002000UL // User flowcontrol bit +#define PD_RS232_S_RXQ 0x00004000UL // User flowcontrol bit + +// The 'delta' bits for enq/deq of Flow Control event +#define PD_RS232_D_LE (PD_RS232_S_LE << PD_RS232_D_SHIFT) +#define PD_RS232_D_DTR (PD_RS232_S_DTR << PD_RS232_D_SHIFT) +#define PD_RS232_D_RTS (PD_RS232_S_RTS << PD_RS232_D_SHIFT) +#define PD_RS232_D_RFR (PD_RS232_S_RFR << PD_RS232_D_SHIFT) +#define PD_RS232_D_TXO (PD_RS232_S_TXO << PD_RS232_D_SHIFT) +#define PD_RS232_D_RXO (PD_RS232_S_RXO << PD_RS232_D_SHIFT) +#define PD_RS232_D_CTS (PD_RS232_S_CTS << PD_RS232_D_SHIFT) +#define PD_RS232_D_CAR (PD_RS232_S_CAR << PD_RS232_D_SHIFT) +#define PD_RS232_D_DCD (PD_RS232_S_DCD << PD_RS232_D_SHIFT) +#define PD_RS232_D_RNG (PD_RS232_S_RNG << PD_RS232_D_SHIFT) +#define PD_RS232_D_RI (PD_RS232_S_RI << PD_RS232_D_SHIFT) +#define PD_RS232_D_DSR (PD_RS232_S_DSR << PD_RS232_D_SHIFT) + +#define PD_RS232_D_BRK (PD_RS232_S_BRK << PD_RS232_D_SHIFT) +#define PD_RS232_D_LOOP (PD_RS232_S_LOOP << PD_RS232_D_SHIFT) +#define PD_RS232_D_TXQ (PD_RS232_S_TXQ << PD_RS232_D_SHIFT) +#define PD_RS232_D_RXQ (PD_RS232_S_RXQ << PD_RS232_D_SHIFT) + +// The 'auto' bits for exec/req of Flow Control event +#define PD_RS232_A_LE PD_RS232_S_LE +#define PD_RS232_A_DTR PD_RS232_S_DTR +#define PD_RS232_A_RTS PD_RS232_S_RTS +#define PD_RS232_A_RFR PD_RS232_S_RFR +#define PD_RS232_A_TXO PD_RS232_S_TXO +#define PD_RS232_A_RXO PD_RS232_S_RXO +#define PD_RS232_A_CTS PD_RS232_S_CTS +#define PD_RS232_A_CAR PD_RS232_S_CAR +#define PD_RS232_A_DCD PD_RS232_S_DCD +#define PD_RS232_A_RNG PD_RS232_S_RNG +#define PD_RS232_A_RI PD_RS232_S_RI +#define PD_RS232_A_DSR PD_RS232_S_DSR +#define PD_RS232_A_XANY 0x00000400 // changes _A_TXO from XON/XOFF to XANY/XOFF +#define PD_RS232_A_BRK PD_RS232_S_BRK +#define PD_RS232_A_LOOP PD_RS232_S_LOOP +#define PD_RS232_A_TXQ PD_RS232_S_TXQ +#define PD_RS232_A_RXQ PD_RS232_S_RXQ + +// The 'notify' bits for exec/req of Flow Control event +#define PD_RS232_N_LE (PD_RS232_S_LE << PD_RS232_N_SHIFT) +#define PD_RS232_N_DTR (PD_RS232_S_DTR << PD_RS232_N_SHIFT) +#define PD_RS232_N_RTS (PD_RS232_S_RTS << PD_RS232_N_SHIFT) +#define PD_RS232_N_RFR (PD_RS232_S_RFR << PD_RS232_N_SHIFT) +#define PD_RS232_N_TXO (PD_RS232_S_TXO << PD_RS232_N_SHIFT) +#define PD_RS232_N_RXO (PD_RS232_S_RXO << PD_RS232_N_SHIFT) +#define PD_RS232_N_CTS (PD_RS232_S_CTS << PD_RS232_N_SHIFT) +#define PD_RS232_N_CAR (PD_RS232_S_CAR << PD_RS232_N_SHIFT) +#define PD_RS232_N_DCD (PD_RS232_S_DCD << PD_RS232_N_SHIFT) +#define PD_RS232_N_RNG (PD_RS232_S_RNG << PD_RS232_N_SHIFT) +#define PD_RS232_N_RI (PD_RS232_S_RI << PD_RS232_N_SHIFT) +#define PD_RS232_N_DSR (PD_RS232_S_DSR << PD_RS232_N_SHIFT) + +#define PD_RS232_N_BRK (PD_RS232_S_BRK << PD_RS232_N_SHIFT) +#define PD_RS232_N_LOOP (PD_RS232_S_LOOP << PD_RS232_N_SHIFT) +#define PD_RS232_N_TXQ (PD_RS232_S_TXQ << PD_RS232_N_SHIFT) +#define PD_RS232_N_RXQ (PD_RS232_S_RXQ << PD_RS232_N_SHIFT) + +class IORS232SerialStreamSync : public IOSerialStreamSync +{ + OSDeclareDefaultStructors(IORS232SerialStreamSync) +}; + +#endif /* !_SERIAL_IORS232SERIALSTREAMSYNC_H */ + Index: branches/azimutz/Cleancut/i386/include/IOKit/serial/IOSerialDriverSync.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/serial/IOSerialDriverSync.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/serial/IOSerialDriverSync.h (revision 885) @@ -0,0 +1,91 @@ +/* + *Copyright (c) 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@ + */ + +/* + * IOSerialDriverSync.h + * This file contains the abstract parent class for any IOSerialDriver + * interface, which is a generic serial interface, designed for devices + * that do character oriented transfers (async) rather than block or + * packet transfers. Most notably RS-232, Printer, Mouse, and Keyboard + * type devices. + * + * 2000-10-21 gvdl Initial real change to IOKit serial family. + */ + +#ifndef _SERIAL_IOSERIALDRIVERSYNC_H +#define _SERIAL_IOSERIALDRIVERSYNC_H + +#include + +class IOSerialDriverSync : public IOService +{ + OSDeclareAbstractStructors(IOSerialDriverSync); + +public: + virtual IOReturn acquirePort(bool sleep, void *refCon) = 0; + + virtual IOReturn releasePort(void *refCon) = 0; + + virtual IOReturn setState(UInt32 state, UInt32 mask, void *refCon) = 0; + + virtual UInt32 getState(void *refCon) = 0; + + virtual IOReturn watchState(UInt32 *state, UInt32 mask, void *refCon) = 0; + + virtual UInt32 nextEvent(void *refCon) = 0; + + virtual IOReturn executeEvent(UInt32 event, UInt32 data, void *refCon) = 0; + + virtual IOReturn requestEvent(UInt32 event, UInt32 *data, void *refCon) = 0; + + virtual IOReturn enqueueEvent(UInt32 event, UInt32 data, + bool sleep, void *refCon) = 0; + + virtual IOReturn dequeueEvent(UInt32 *event, UInt32 *data, + bool sleep, void *refCon) = 0; + + virtual IOReturn enqueueData(UInt8 *buffer, UInt32 size, UInt32 *count, + bool sleep, void *refCon) = 0; + + virtual IOReturn dequeueData(UInt8 *buffer, UInt32 size, UInt32 *count, + UInt32 min, void *refCon) = 0; + +OSMetaClassDeclareReservedUnused(IOSerialDriverSync, 0); +OSMetaClassDeclareReservedUnused(IOSerialDriverSync, 1); +OSMetaClassDeclareReservedUnused(IOSerialDriverSync, 2); +OSMetaClassDeclareReservedUnused(IOSerialDriverSync, 3); +OSMetaClassDeclareReservedUnused(IOSerialDriverSync, 4); +OSMetaClassDeclareReservedUnused(IOSerialDriverSync, 5); +OSMetaClassDeclareReservedUnused(IOSerialDriverSync, 6); +OSMetaClassDeclareReservedUnused(IOSerialDriverSync, 7); +OSMetaClassDeclareReservedUnused(IOSerialDriverSync, 8); +OSMetaClassDeclareReservedUnused(IOSerialDriverSync, 9); +OSMetaClassDeclareReservedUnused(IOSerialDriverSync, 10); +OSMetaClassDeclareReservedUnused(IOSerialDriverSync, 11); +OSMetaClassDeclareReservedUnused(IOSerialDriverSync, 12); +OSMetaClassDeclareReservedUnused(IOSerialDriverSync, 13); +OSMetaClassDeclareReservedUnused(IOSerialDriverSync, 14); +OSMetaClassDeclareReservedUnused(IOSerialDriverSync, 15); + +}; + +#endif /* !_SERIAL_IOSERIALDRIVERSYNC_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/serial/IOSerialStreamSync.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/serial/IOSerialStreamSync.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/serial/IOSerialStreamSync.h (revision 885) @@ -0,0 +1,275 @@ +/* + *Copyright (c) 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@ + */ +/* + * IOSerialStreamSync.h + * + * 2000-10-21 gvdl Initial real change to IOKit serial family. + * + */ + +#ifndef _SERIAL_IOSERIALSTREAMSYNC_H +#define _SERIAL_IOSERIALSTREAMSYNC_H + +#include + +#ifdef __LP64__ + +#define PD_DATA_MASK 0x03U +#define PD_DATA_VOID 0x00U +#define PD_DATA_BYTE 0x01U +#define PD_DATA_WORD 0x02U +#define PD_DATA_LONG 0x03U + +#else + +#define PD_DATA_MASK 0x03UL +#define PD_DATA_VOID 0x00UL +#define PD_DATA_BYTE 0x01UL +#define PD_DATA_WORD 0x02UL +#define PD_DATA_LONG 0x03UL + +#endif + +#define PD_OP(x) ((x) << 2) +#define PD_E_MASK (~PD_DATA_MASK) + +/* General Command & Status events */ +#define PD_E_EOQ (PD_DATA_VOID|PD_OP( 0)) // Always nextEvent on empty queue +#define PD_E_ACTIVE (PD_DATA_BYTE|PD_OP( 1)) // BOOL start/shutdown chip + +/* Queue management events - all units are multiples of characters + *based on the current character size + */ +#define PD_E_TXQ_SIZE (PD_DATA_LONG|PD_OP( 2)) +#define PD_E_RXQ_SIZE (PD_DATA_LONG|PD_OP( 3)) +#define PD_E_TXQ_LOW_WATER (PD_DATA_LONG|PD_OP( 4)) +#define PD_E_RXQ_LOW_WATER (PD_DATA_LONG|PD_OP( 5)) +#define PD_E_TXQ_HIGH_WATER (PD_DATA_LONG|PD_OP( 6)) +#define PD_E_RXQ_HIGH_WATER (PD_DATA_LONG|PD_OP( 7)) +#define PD_E_TXQ_AVAILABLE (PD_DATA_LONG|PD_OP( 8)) +#define PD_E_RXQ_AVAILABLE (PD_DATA_LONG|PD_OP( 9)) +#define PD_E_TXQ_FLUSH (PD_DATA_VOID|PD_OP(10)) +#define PD_E_RXQ_FLUSH (PD_DATA_LONG|PD_OP(11)) + +/* port & link characteristics - units are half bits */ +#define PD_E_DATA_RATE (PD_DATA_LONG|PD_OP(12)) // raw bits of symbols per second +#define PD_E_RX_DATA_RATE (PD_DATA_LONG|PD_OP(13)) +#define PD_E_DATA_SIZE (PD_DATA_LONG|PD_OP(14)) // raw bits per symbol +#define PD_E_RX_DATA_SIZE (PD_DATA_LONG|PD_OP(15)) +#define PD_E_DATA_INTEGRITY (PD_DATA_LONG|PD_OP(16)) // parity or ECC method +#define PD_E_RX_DATA_INTEGRITY (PD_DATA_LONG|PD_OP(17)) +#define PD_E_EXTERNAL_CLOCK_MODE (PD_DATA_LONG|PD_OP(28)) // multiplier between clock and data rates + +/* timeout events */ +#define PD_E_DELAY (PD_DATA_LONG|PD_OP(18)) // inter-character delay (us) +#define PD_E_DATA_LATENCY (PD_DATA_LONG|PD_OP(19)) // A dequeueData Latency timeout + // rcs Secondary Timer mainly to fix performance + // problems with MIDI and IRDA drivers. + // Midi and Irda drivers will issue an IOCTL + // call with this as the selector and + // the Data as the value they want the rate set + // to (Typically 1 for IrDA devices) +#define PD_E_FLOW_CONTROL (PD_DATA_LONG|PD_OP(20)) // enable/disable each flow mechanism + +/* I/O events */ +#define PD_E_VALID_DATA (PD_DATA_VOID|PD_OP(21)) // A valid frame was received +#define PD_E_VALID_DATA_BYTE (PD_DATA_BYTE|PD_E_VALID_DATA) +#define PD_E_VALID_DATA_WORD (PD_DATA_WORD|PD_E_VALID_DATA) +#define PD_E_VALID_DATA_LONG (PD_DATA_LONG|PD_E_VALID_DATA) + +#define PD_E_SPECIAL (PD_DATA_VOID|PD_OP(22)) // valid data received with 'special' value +#define PD_E_SPECIAL_BYTE (PD_DATA_BYTE|PD_E_SPECIAL) +#define PD_E_SPECIAL_WORD (PD_DATA_WORD|PD_E_SPECIAL) +#define PD_E_SPECIAL_LONG (PD_DATA_LONG|PD_E_SPECIAL) + +#define PD_E_FRAMING_ERROR (PD_DATA_VOID|PD_OP(23)) // Failure occured assembling frame +#define PD_E_FRAMING_BYTE (PD_DATA_BYTE|PD_E_FRAMING_ERROR) +#define PD_E_FRAMING_WORD (PD_DATA_WORD|PD_E_FRAMING_ERROR) +#define PD_E_FRAMING_LONG (PD_DATA_LONG|PD_E_FRAMING_ERROR) + +#define PD_E_INTEGRITY_ERROR (PD_DATA_VOID|PD_OP(24)) // An uncorrectable frame was received +#define PD_E_INTEGRITY_BYTE (PD_DATA_BYTE|PD_E_INTEGRITY_ERROR) +#define PD_E_INTEGRITY_WORD (PD_DATA_WORD|PD_E_INTEGRITY_ERROR) +#define PD_E_INTEGRITY_LONG (PD_DATA_LONG|PD_E_INTEGRITY_ERROR) + +#define PD_E_INTEGRITY_WARNING (PD_DATA_VOID|PD_OP(25)) // A correctable frame was received +#define PD_E_HW_OVERRUN_ERROR (PD_DATA_VOID|PD_OP(26)) // Hardware's buffer overflowed, data lost +#define PD_E_SW_OVERRUN_ERROR (PD_DATA_VOID|PD_OP(27)) // Driver's buffer overflowed, data lost + +/* + *The variables below make up the bits returned + *by the State methods:- getState, setState, watchState + */ +#define PD_S_MASK 0xffff0000UL +#define PD_S_RX_OFFSET 7 + +#define PD_S_ACQUIRED 0x80000000UL +#define PD_S_ACTIVE 0x40000000UL + +#define PD_S_TX_ENABLE 0x20000000UL +#define PD_S_TX_BUSY 0x10000000UL +#define PD_S_TX_EVENT 0x08000000UL +#define PD_S_TXQ_EMPTY 0x04000000UL +#define PD_S_TXQ_LOW_WATER 0x02000000UL +#define PD_S_TXQ_HIGH_WATER 0x01000000UL +#define PD_S_TXQ_FULL 0x00800000UL +#define PD_S_TXQ_MASK ( PD_S_TXQ_EMPTY | PD_S_TXQ_LOW_WATER \ + | PD_S_TXQ_FULL | PD_S_TXQ_HIGH_WATER ) + +#define PD_S_RX_ENABLE (PD_S_TX_ENABLE >> PD_S_RX_OFFSET) +#define PD_S_RX_BUSY (PD_S_TX_BUSY >> PD_S_RX_OFFSET) +#define PD_S_RX_EVENT (PD_S_TX_EVENT >> PD_S_RX_OFFSET) +#define PD_S_RXQ_EMPTY (PD_S_TXQ_EMPTY >> PD_S_RX_OFFSET) +#define PD_S_RXQ_LOW_WATER (PD_S_TXQ_LOW_WATER >> PD_S_RX_OFFSET) +#define PD_S_RXQ_HIGH_WATER (PD_S_TXQ_HIGH_WATER >> PD_S_RX_OFFSET) +#define PD_S_RXQ_FULL (PD_S_TXQ_FULL >> PD_S_RX_OFFSET) +#define PD_S_RXQ_MASK (PD_S_TXQ_MASK >> PD_S_RX_OFFSET) + +class IOSerialDriverSync; +class IOSerialStreamSync : public IOService +{ + OSDeclareDefaultStructors(IOSerialStreamSync); + +protected: + IOSerialDriverSync *fProvider; + void *fRefCon; + +public: + /* acquire tests and sets the state of the port object. If the port was + *available, then the state is set to busy, and kIOReturnSuccess is returned. + *If the port was already busy and sleep is YES, then the thread will sleep + *until the port is freed, then re-attempts the acquire. If the port was + *already busy and sleep in NO, then kIOReturnExclusiveAccess is returned. + */ + virtual IOReturn acquirePort(bool sleep); + + /* release sets the state of the port object to available and wakes up any + *threads sleeping for access to this port. It will return kIOReturnSuccess + *if the port was in a busy state, and kIOReturnNotOpen if it was available. + */ + virtual IOReturn releasePort(); + + /* + *Set the state for the port device. + */ + virtual IOReturn setState(UInt32 state, UInt32 mask); + + /* + *Get the state for the port device. + */ + virtual UInt32 getState(); + + /* + *Wait for the at least one of the state bits defined in mask to be equal + *to the value defined in state. + *Check on entry then sleep until necessary. + */ + virtual IOReturn watchState(UInt32 *state, UInt32 mask); + + /* nextEvent returns the type of the next event on the RX queue. If no + *events are present on the RX queue, then EOQ is returned. + */ + virtual UInt32 nextEvent(); + + /* executeEvent causes the specified event to be processed immediately. + *This is primarily used for channel control commands like START & STOP + */ + virtual IOReturn executeEvent(UInt32 event, UInt32 data); + + /* requestEvent processes the specified event as an immediate request and + *returns the results in data. This is primarily used for getting link + *status information and verifying baud rate and such. + */ + virtual IOReturn requestEvent(UInt32 event, UInt32 *data); + + /* enqueueEvent will place the specified event into the TX queue. The + *sleep argument allows the caller to specify the enqueueEvent's + *behaviour when the TX queue is full. If sleep is true, then this + *method will sleep until the event is enqueued. If sleep is false, + *then enqueueEvent will immediatly return kIOReturnNoResources. + */ + virtual IOReturn enqueueEvent(UInt32 event, UInt32 data, bool sleep); + + /* dequeueEvent will remove the oldest event from the RX queue and return + *it in event & data. The sleep argument defines the behaviour if the RX + *queue is empty. If sleep is true, then this method will sleep until an + *event is available. If sleep is false, then an EOQ event will be + *returned. In either case kIOReturnSuccess is returned. + */ + virtual IOReturn dequeueEvent(UInt32 *event, UInt32 *data, bool sleep); + + /* enqueueData will attempt to copy data from the specified buffer to the + *TX queue as a sequence of VALID_DATA events. The argument bufferSize + *specifies the number of bytes to be sent. The actual number of bytes + *transferred is returned in transferCount. If sleep is true, then this + *method will sleep until all bytes can be transferred. If sleep is + *false, then as many bytes as possible will be copied to the TX queue. + */ + virtual IOReturn enqueueData(UInt8 *buffer, UInt32 size, UInt32 *count, bool sleep ); + + /* dequeueData will attempt to copy data from the RX queue to the specified + *buffer. No more than bufferSize VALID_DATA events will be transferred. + *In other words, copying will continue until either a non-data event is + *encountered or the transfer buffer is full. The actual number of bytes + *transferred is returned in transferCount. + * + *The sleep semantics of this method are slightly more complicated than + *other methods in this API: Basically, this method will continue to + *sleep until either minCount characters have been received or a non + *data event is next in the RX queue. If minCount is zero, then this + *method never sleeps and will return immediatly if the queue is empty. + * + *The latency parameter specifies the maximum amount of time that should + *pass after the first character is available before the routine returns. + *This allows the caller to specify a 'packet' timeout. The unit of the + *latency parameter is microseconds, though the exact delay may vary + *depending on the granularity of the timeout services available to the + *driver. + */ + virtual IOReturn dequeueData(UInt8 *buffer, UInt32 size, UInt32 *count, UInt32 min); + + /* Internal for IOSerialDriver only */ + virtual bool init(OSDictionary *dictionary = 0, void *refCon = 0); + virtual bool attach(IOService *provider); + void *getRefCon() const { return fRefCon; } + +OSMetaClassDeclareReservedUnused(IOSerialStreamSync, 0); +OSMetaClassDeclareReservedUnused(IOSerialStreamSync, 1); +OSMetaClassDeclareReservedUnused(IOSerialStreamSync, 2); +OSMetaClassDeclareReservedUnused(IOSerialStreamSync, 3); +OSMetaClassDeclareReservedUnused(IOSerialStreamSync, 4); +OSMetaClassDeclareReservedUnused(IOSerialStreamSync, 5); +OSMetaClassDeclareReservedUnused(IOSerialStreamSync, 6); +OSMetaClassDeclareReservedUnused(IOSerialStreamSync, 7); +OSMetaClassDeclareReservedUnused(IOSerialStreamSync, 8); +OSMetaClassDeclareReservedUnused(IOSerialStreamSync, 9); +OSMetaClassDeclareReservedUnused(IOSerialStreamSync, 10); +OSMetaClassDeclareReservedUnused(IOSerialStreamSync, 11); +OSMetaClassDeclareReservedUnused(IOSerialStreamSync, 12); +OSMetaClassDeclareReservedUnused(IOSerialStreamSync, 13); +OSMetaClassDeclareReservedUnused(IOSerialStreamSync, 14); +OSMetaClassDeclareReservedUnused(IOSerialStreamSync, 15); +}; + +#endif /* !_SERIAL_IOSERIALSTREAMSYNC_H */ + + Index: branches/azimutz/Cleancut/i386/include/IOKit/serial/IOModemSerialStreamSync.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/serial/IOModemSerialStreamSync.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/serial/IOModemSerialStreamSync.h (revision 885) @@ -0,0 +1,42 @@ +/* + * Copyright (c) 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@ + */ +/* + * + * IOModemSerialStreamSync.h + * This file contains Modem specific extensions to the IOSerialStreamSync class. + * + * 2000-10-21 gvdl Initial real change to IOKit serial family. + * + */ + +#ifndef _SERIAL_IOMODEMSERIALSTREAMSYNC_H +#define _SERIAL_IOMODEMSERIALSTREAMSYNC_H + +#include + +class IOModemSerialStreamSync : public IOSerialStreamSync +{ + OSDeclareDefaultStructors(IOModemSerialStreamSync) +}; + +#endif /* !_SERIAL_IOMODEMSERIALSTREAMSYNC_H */ + Index: branches/azimutz/Cleancut/i386/include/IOKit/serial/IOSerialKeys.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/serial/IOSerialKeys.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/serial/IOSerialKeys.h (revision 885) @@ -0,0 +1,80 @@ +/* + * Copyright (c) 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@ + */ +/* + * IOSerialKeys.h + * + * 2000-10-21 gvdl Initial real change to IOKit serial family. + * + */ + +/* +Sample Matching dictionary +{ + IOProviderClass = kIOSerialBSDServiceValue; + kIOSerialBSDTypeKey = kIOSerialBSDAllTypes + | kIOSerialBSDModemType + | kIOSerialBSDRS232Type; + kIOTTYDeviceKey = ; + kIOTTYBaseNameKey = ; + kIOTTYSuffixKey = ; + kIOCalloutDeviceKey = ; + kIODialinDeviceKey = ; +} + +Note only the IOProviderClass is mandatory. The other keys allow the searcher to reduce the size of the set of matching devices. +*/ + +/* Service Matching That is the 'IOProviderClass' */ +#define kIOSerialBSDServiceValue "IOSerialBSDClient" + +/* Matching keys */ +#define kIOSerialBSDTypeKey "IOSerialBSDClientType" + +/* Currently possible kIOSerialBSDTypeKey values. */ +#define kIOSerialBSDAllTypes "IOSerialStream" +#define kIOSerialBSDModemType "IOModemSerialStream" +#define kIOSerialBSDRS232Type "IORS232SerialStream" + +// Properties that resolve to a /dev device node to open for +// a particular service +#define kIOTTYDeviceKey "IOTTYDevice" +#define kIOTTYBaseNameKey "IOTTYBaseName" +#define kIOTTYSuffixKey "IOTTYSuffix" + +#define kIOCalloutDeviceKey "IOCalloutDevice" +#define kIODialinDeviceKey "IODialinDevice" + +// Property 'ioctl' wait for the tty device to go idle. +#define kIOTTYWaitForIdleKey "IOTTYWaitForIdle" + +#if KERNEL +extern const OSSymbol *gIOSerialBSDServiceValue; +extern const OSSymbol *gIOSerialBSDTypeKey; +extern const OSSymbol *gIOSerialBSDAllTypes; +extern const OSSymbol *gIOSerialBSDModemType; +extern const OSSymbol *gIOSerialBSDRS232Type; +extern const OSSymbol *gIOTTYDeviceKey; +extern const OSSymbol *gIOTTYBaseNameKey; +extern const OSSymbol *gIOTTYSuffixKey; +extern const OSSymbol *gIOCalloutDeviceKey; +extern const OSSymbol *gIODialinDeviceKey; +#endif /* KERNEL */ Index: branches/azimutz/Cleancut/i386/include/IOKit/IOSyncer.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/IOSyncer.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/IOSyncer.h (revision 885) @@ -0,0 +1,64 @@ +/* + * 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 _IOSYNCER_H +#define _IOSYNCER_H + +#include +#include +#include + +class IOSyncer : public OSObject +{ + OSDeclareDefaultStructors(IOSyncer) + +private: + // The spin lock that is used to guard the 'threadMustStop' variable. + IOSimpleLock *guardLock; + volatile bool threadMustStop; + IOReturn fResult; + virtual void free(); + virtual void privateSignal(); + +public: + + static IOSyncer * create(bool twoRetains = true) + APPLE_KEXT_DEPRECATED; + + virtual bool init(bool twoRetains) + APPLE_KEXT_DEPRECATED; + virtual void reinit() + APPLE_KEXT_DEPRECATED; + virtual IOReturn wait(bool autoRelease = true) + APPLE_KEXT_DEPRECATED; + virtual void signal(IOReturn res = kIOReturnSuccess, + bool autoRelease = true) + APPLE_KEXT_DEPRECATED; +}; + +#endif /* !_IOSYNCER */ + Index: branches/azimutz/Cleancut/i386/include/IOKit/IOTimerEventSource.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/IOTimerEventSource.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/IOTimerEventSource.h (revision 885) @@ -0,0 +1,230 @@ +/* + * 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. + * + * IOTimerEventSource.h + * + * HISTORY + * 2-Feb-1999 Joe Liu (jliu) created. + * + */ + +#ifndef _IOTIMEREVENTSOURCE +#define _IOTIMEREVENTSOURCE + +#include + +__BEGIN_DECLS +#include +__END_DECLS + +#include +#include + +/*! + @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. +

+ 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. +

+ 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; + IOWorkLoop * workLoop; + }; + +/*! @var reserved + Reserved for future use. (Internal use only) */ + ExpansionData *reserved; + +/*! @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(); + +/*! @function checkForWork + @abstract Have to implement it is mandatory in $link IOEventSource, but IOTimerEventSources don't actually use this work-loop mechanism. */ + virtual bool checkForWork(); + + virtual void setWorkLoop(IOWorkLoop *workLoop); + +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); + +/*! @function timerEventSource + @abstract Allocates and returns an initialized timer instance. + @param owner + @param action */ + static IOTimerEventSource * + timerEventSource(OSObject *owner, Action action = 0); + +/*! @function init + @abstract Initializes the timer with an owner, and a handler to call when the timeout expires. + @param owner + @param action */ + virtual bool init(OSObject *owner, Action action = 0); + +/*! @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(); + +/*! @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(); + + +/*! @function setTimeoutTicks + @abstract Setup a callback at after the delay in scheduler ticks. See wakeAtTime(AbsoluteTime). + @param interval 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 interval 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 interval 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 abstime 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 abstime 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 abstime 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(); + +private: + static void timeoutAndRelease(void *self, void *wl); + +private: + OSMetaClassDeclareReservedUnused(IOTimerEventSource, 0); + OSMetaClassDeclareReservedUnused(IOTimerEventSource, 1); + OSMetaClassDeclareReservedUnused(IOTimerEventSource, 2); + OSMetaClassDeclareReservedUnused(IOTimerEventSource, 3); + OSMetaClassDeclareReservedUnused(IOTimerEventSource, 4); + OSMetaClassDeclareReservedUnused(IOTimerEventSource, 5); + OSMetaClassDeclareReservedUnused(IOTimerEventSource, 6); + OSMetaClassDeclareReservedUnused(IOTimerEventSource, 7); +}; + +#endif /* !_IOTIMEREVENTSOURCE */ Index: branches/azimutz/Cleancut/i386/include/IOKit/nvram/IONVRAMController.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/nvram/IONVRAMController.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/nvram/IONVRAMController.h (revision 885) @@ -0,0 +1,49 @@ +/* + * 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_IONVRAMCONTROLLER_H +#define _IOKIT_IONVRAMCONTROLLER_H + +#include + +class IONVRAMController: public IOService +{ + OSDeclareAbstractStructors(IONVRAMController); + +public: + virtual bool start(IOService *provider); + + virtual void sync(void); + + virtual IOReturn read(IOByteCount offset, UInt8 *buffer, + IOByteCount length) = 0; + virtual IOReturn write(IOByteCount offset, UInt8 *buffer, + IOByteCount length) = 0; +}; + +#endif /* !_IOKIT_IONVRAMCONTROLLER_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/IOLib.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/IOLib.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/IOLib.h (revision 885) @@ -0,0 +1,398 @@ +/* + * 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_IOLIB_H +#define __IOKIT_IOLIB_H + + +#include +#include + +#include + +#include + +#include +#include +#include + +#include + +__BEGIN_DECLS + +#include +#include + +/* + * min/max macros. + */ + +#define min(a,b) ((a) < (b) ? (a) : (b)) +#define max(a,b) ((a) > (b) ? (a) : (b)) + +/* + * 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); + +/*! @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. + @param size Size of the memory allocated. */ + +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); + +/*! @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)); + +/*! @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); + +/*! @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); + +/* + * Typed memory allocation macros. Both may block. + */ +#define IONew(type,number) (type*)IOMalloc(sizeof(type) * (number) ) +#define IODelete(ptr,type,number) IOFree( (ptr) , sizeof(type) * (number) ) + +///////////////////////////////////////////////////////////////////////////// +// +// +// 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); + +/*! @function IOSetProcessorCacheMode + @abstract Sets the processor cache mode for mapped memory. + @discussion This function sets the cache mode of an already mapped & wired memory range. Note this may not be supported on I/O mappings or shared memory - it is far preferable to set the cache mode as mappings are created with the IOMemoryDescriptor::map method. + @param task Task the memory is mapped into. + @param address Virtual address of the memory. + @param length Length of the range to set. + @param cacheMode A constant from IOTypes.h,
+ kIOMapDefaultCache to inhibit the cache in I/O areas, kIOMapCopybackCache in general purpose RAM.
+ kIOMapInhibitCache, kIOMapWriteThruCache, kIOMapCopybackCache to set the appropriate caching.
+ @result An IOReturn code.*/ + +IOReturn IOSetProcessorCacheMode( task_t task, IOVirtualAddress address, + IOByteCount length, IOOptionBits cacheMode ); + +/*! @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 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 microseconds 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). + @param other arguments described by the format string. */ + +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); + +#ifndef _FN_KPRINTF +#define _FN_KPRINTF +void kprintf(const char *format, ...); +#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)); +#endif + +struct OSDictionary * IOBSDNameMatching( const char * name ); +struct OSDictionary * IOOFPathMatching( const char * path, char * buf, int maxLen ); + +/* + * 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 */ + +__END_DECLS + +#endif /* !__IOKIT_IOLIB_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/IOBSD.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/IOBSD.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/IOBSD.h (revision 885) @@ -0,0 +1,41 @@ +/* + * 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 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 */ Index: branches/azimutz/Cleancut/i386/include/IOKit/IODeviceTreeSupport.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/IODeviceTreeSupport.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/IODeviceTreeSupport.h (revision 885) @@ -0,0 +1,127 @@ +/* + * 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 +#include + +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 * gIODTAAPLInterruptsKey; +extern const OSSymbol * gIODTDefaultInterruptController; +extern const OSSymbol * gIODTNWInterruptMappingKey; + +IORegistryEntry * IODeviceTreeAlloc( void * dtTop ); + + +bool IODTMatchNubWithKeys( IORegistryEntry * nub, + const char * keys ); + +bool IODTCompareNubName( const IORegistryEntry * regEntry, + OSString * name, OSString ** matchingName ); + +enum { + kIODTRecursive = 0x00000001, + kIODTExclusive = 0x00000002 +}; + +OSCollectionIterator * IODTFindMatchingEntries( IORegistryEntry * from, + IOOptionBits options, const char * keys ); + +typedef SInt32 (*IODTCompareAddressCellFunc) + (UInt32 cellCount, UInt32 left[], UInt32 right[]); +typedef void (*IODTNVLocationFunc) + (IORegistryEntry * entry, + UInt8 * busNum, UInt8 * deviceNum, UInt8 * functionNum ); + +void IODTSetResolving( IORegistryEntry * regEntry, + IODTCompareAddressCellFunc compareFunc, + IODTNVLocationFunc locationFunc ); + +bool IODTResolveAddressCell( IORegistryEntry * regEntry, + UInt32 cellsIn[], + IOPhysicalAddress * phys, IOPhysicalLength * len ); + +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 ); + +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 */ + Index: branches/azimutz/Cleancut/i386/include/IOKit/stream/IOStreamShared.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/stream/IOStreamShared.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/stream/IOStreamShared.h (revision 885) @@ -0,0 +1,175 @@ +/* + * IOStreamShared.h + * IOStreamFamily + * + * Copyright 2006 Apple Computer, Inc. All rights reserved. + * + */ + +#if !defined(__IOKIT_IOSTREAMSHARED_H) +#define __IOKIT_IOSTREAMSHARED_H + +#include + +#include + +/*! + @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(). + */ +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(). + */ +enum { + kIOStreamPortTypeOutput, + kIOStreamPortTypeInput +}; + +/*! + @enum IOStream open options + */ + +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. + */ +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. + */ +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 */ + Index: branches/azimutz/Cleancut/i386/include/IOKit/stream/IOStreamUserClient.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/stream/IOStreamUserClient.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/stream/IOStreamUserClient.h (revision 885) @@ -0,0 +1,76 @@ +/* + * IOStreamUserClient.h + * IOStreamFamily + * + * Copyright 2006 Apple Computer, Inc. All rights reserved. + * + */ + +#if !defined( __IOKIT_IOSTREAMUSERCLIENT_H ) +#define __IOKIT_IOSTREAMUSERCLIENT_H + + +#include + +#include +#include + +class IOStreamUserClient : public IOUserClient +{ + OSDeclareDefaultStructors( IOStreamUserClient ) + +protected: + IOStream * _owner; + task_t _task; + +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 ); + + +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 ); + +}; + +#endif /* ! __IOKIT_IOSTREAMUSERCLIENT_H */ + Index: branches/azimutz/Cleancut/i386/include/IOKit/stream/IOStream.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/stream/IOStream.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/stream/IOStream.h (revision 885) @@ -0,0 +1,609 @@ +/* + * Copyright 2006 Apple Computer, Inc. All rights reserved. + * + */ + +#if !defined(__IOKIT_IOSTREAM_H) +#define __IOKIT_IOSTREAM_H + +#include +#include +#include +#include + +#include + +/*! + @header IOStream.h + Definitions for IOStream family. + */ + +class 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 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 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 */ + Index: branches/azimutz/Cleancut/i386/include/IOKit/stream/IOStreamFamily.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/stream/IOStreamFamily.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/stream/IOStreamFamily.h (revision 885) @@ -0,0 +1,13 @@ +/* + * Copyright 2006 Apple Computer, Inc. All rights reserved. + * + */ + +#ifndef __IOKIT_IOSTREAMFAMILY_H +#define __IOKIT_IOSTREAMFAMILY_H + +#include +#include + + +#endif /* !__IOKIT_IOSTREAMFAMILY_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/IOKitServer.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/IOKitServer.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/IOKitServer.h (revision 885) @@ -0,0 +1,123 @@ +/* + * 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 + * + */ + +/* + * Internal definitions used between the iokit user library and + * server routines. + */ + +#ifndef _IOKIT_IOKITSERVER_H +#define _IOKIT_IOKITSERVER_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif +#include +#ifdef __cplusplus +} +#endif + +// IOMakeMatching +/*! + @enum IOMakeMatching + @constant kIOServiceMatching + @constant kIOBSDNameMatching + @constant kIOOFPathMatching +*/ +enum { + kIOServiceMatching = 100, + kIOBSDNameMatching = 101, + kIOOFPathMatching = 102 +}; + +// 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. +*/ +enum { + kIOCatalogAddDrivers = 1, + kIOCatalogAddDriversNoMatch, + kIOCatalogRemoveDrivers, + kIOCatalogRemoveDriversNoMatch, + kIOCatalogStartMatching, + kIOCatalogRemoveKernelLinker, + kIOCatalogKextdActive, + kIOCatalogKextdFinishedLaunching +}; + +// 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 */ + Index: branches/azimutz/Cleancut/i386/include/IOKit/IOCommand.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/IOCommand.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/IOCommand.h (revision 885) @@ -0,0 +1,83 @@ +/* + * Copyright (c) 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) 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 +#include + +/*! + * @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); + +/*! @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_ */ Index: branches/azimutz/Cleancut/i386/include/IOKit/IODataQueue.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/IODataQueue.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/IODataQueue.h (revision 885) @@ -0,0 +1,141 @@ +/* + * 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_IODATAQUEUE_H +#define _IOKIT_IODATAQUEUE_H + +#include +#include +#include +#include + +typedef struct _IODataQueueMemory IODataQueueMemory; +class IOMemoryDescriptor; + +struct _notifyMsg { + mach_msg_header_t h; +}; + +/*! + * @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. + * + *
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. + * + *
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. + * + *
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. + * + *
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 IODataQueue : public OSObject +{ + OSDeclareDefaultStructors(IODataQueue) + +protected: + IODataQueueMemory * dataQueue; + + void * notifyMsg; + + virtual void free(); + + /*! + * @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 . 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 .
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 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.
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 IODataQueue instance. Zero is returned on failure. + */ + static 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 . 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 . + * @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.
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 Reeturns 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.
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 IOMemoryDescriptor *getMemoryDescriptor(); +}; + +#endif /* _IOKIT_IODATAQUEUE_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/IOMultiMemoryDescriptor.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/IOMultiMemoryDescriptor.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/IOMultiMemoryDescriptor.h (revision 885) @@ -0,0 +1,110 @@ +/* + * 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 + +/*! @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(); + +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 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 ); + +/*! @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); + +/*! @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); +}; + +#endif /* !_IOMULTIMEMORYDESCRIPTOR_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/audio/IOAudioDevice.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/audio/IOAudioDevice.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/audio/IOAudioDevice.h (revision 885) @@ -0,0 +1,749 @@ +/* + * Copyright (c) 1998-2010 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 IOAudioDevice + */ + +#ifndef _IOKIT_IOAUDIODEVICE_H +#define _IOKIT_IOAUDIODEVICE_H + +#include + +#ifndef IOAUDIOFAMILY_SELF_BUILD +#include +#include +#else +#include "IOAudioTypes.h" +#include "IOAudioStream.h" +#endif + +class IOAudioEngine; +class IOAudioStream; +class IOAudioPort; +class IOAudioControl; +class OSDictionary; +class OSSet; +class OSArray; +class IOTimerEventSource; +class IOCommandGate; + +/*! + * enum IOAudioDevicePowerState + * @abstract Identifies the power state of the audio device + * @discussion A newly created IOAudioDevices defaults to the idle state. + * @constant kIOAudioDeviceSleep State set when the system is going to sleep + * @constant kIOAudioDeviceIdle State when the system is awake but none of the IOAudioEngines are in use + * @constant kIOAudioDeviceActive State when one ore more IOAudioEngines are in use. This state transition must complete before the system will begin playing audio. + */ +typedef enum _IOAudioDevicePowerState { + kIOAudioDeviceSleep = 0, // When sleeping + kIOAudioDeviceIdle = 1, // When no audio engines running + kIOAudioDeviceActive = 2 // audio engines running +} IOAudioDevicePowerState; + +/*! + * @class IOAudioDevice + * @abstract Abstract base class for a single piece of audio hardware. The IOAudioDevice provides + * the central coordination point for an audio driver. + * @discussion An audio driver is required to subclass IOAudioDevice in order to provide + * working audio to the system. A single driver instance will contain a single instance of the + * driver's IOAudioDevice subclass. The subclass is responsible for mapping all hardware device + * resources from the service provider nub. It must control access to the hardware so that the + * hardware doesn't get into an inconsistent state. It is possible that different threads may make + * requests of the hardware at the same time. The IOAudioDevice superclass provides an IOWorkLoop + * and IOCommandGate on the IOWorkLoop through which all hardware accesses may be synchronized. + * All entry points to all parts of the driver controlled by the IOAudioFamily will be synchronized + * through this one IOWorkLoop. + * + * The IOAudioDevice subclass is responsible for creating the rest of the pieces of the driver. + * It must identify and create all IOAudioEngines that are not automatically created by the system + * (i.e. those that are not matched and instantiated by IOKit directly). + * + * The IOAudioDevice subclass must enumerate and create all IOAudioControls to match + * the device capabilities. + * + * It must also execute control value chages when requested by the system (i.e. volume adjustments). + * + * In order to allow sleep and wake to work on the system, the IOAudioDevice subclass is responsible + * for performing the necessary actions to sleep and wake its hardware (and restore necessary state + * on wake). + * + * The IOAudioDevice class provides timer services that allow different elements in the audio driver + * to receive timer notifications as needed. These services were designed with the idea that most + * timed events in a typical audio driver need to be done at least as often as a certain interval. + * Further, it is designed with the idea that being called more often than the specified interval + * doesn't hurt anything - and in fact may help. With this in mind, the timer services provided + * by the IOAudioDevice class allow different targets to register for timer callbacks at least as + * often as the specified interval. The actual interval will be the smallest of the intervals of + * all of the callbacks. This way, we avoid the overhead of having many timers in a single audio + * device. As an example, each output IOAudioEngine has a timer to run the erase head. It doesn't hurt + * to have the erase head run more often. Also, a typical IOAudioDevice subclass may need to run a timer + * to check for device state changes (e.g. jack insertions). + * + * There are a number of strings passed from the driver to the CoreAudio.framework and then into + * applications. All of those strings should be localized by the driver. In order to do that + * the kext bundle should have localized string files following the Mac OS X localization + * instructions. The IOAudioDevice should contain a property with the name of the bundle/kext + * that contains the localized string resources. To do that, the driver's personality in + * the bundle resources could have a property named 'IOAudioDeviceLocalizedBundle' with the path + * of the bundle/kext relative to '/System/Library/Extensions'. It could also be set by the + * IOAudioDevice subclass in its initHardware() function. To do so, call + * setProperty(kIOAudioDeviceLocalizedBundleKey, "Driver.kext"). + * + * In a typical driver, the IOAudioDevice subclass will implement initHardware() to perform the + * hardware initialization and driver construction. Within that initialization it must create at + * least one IOAudioEngine instance and activate it. In order to activate a new IOAudioEngine + * activateAudioEngine() should be called for each one. It must create the IOAudioControls + * matching the hardware capabilities to allow the system to set volume, mute and input selection. + * To add those controls to the driver, each control should be attached to the IOAudioEngine to + * which it applies by calling addDefaultAudioControl() on the IOAudioEngine. + * During initialization it should also call setDeviceName(), setDeviceShortName() and + * setManufacturerName() with localized strings representing each of the attributes. + * + * If the driver is to work properly after sleep/wake, it must implement performPowerStateChange() + * and deal with the sleep and wake transitions. It may also deal with the idle state transitions + * to turn off device power when it isn't in use (especially useful for devices attached to a + * portable running on battery power). + */ + +class IOAudioDevice : public IOService +{ + friend class IOAudioEngine; + + OSDeclareDefaultStructors(IOAudioDevice) + +protected: + /*! @var workLoop The IOWorkLoop for the driver - this is shared with the other objects in the driver */ + IOWorkLoop *workLoop; + /*! @var commandGate The IOCommandGate for this IOAudioDevice. It is attached to workLoop */ + IOCommandGate *commandGate; + /*! @var timerEventSource An IOTimerEventSource attached to workLoop used for the timer services */ + IOTimerEventSource *timerEventSource; + + /*! @var duringStartup State variable set to true while the driver is starting up and false all other times */ + bool duringStartup; + /*! @var familyManagePower Set to true if the family is supposed to manage power - this is the default state. It can be changed early in the initialization process with a call to setFamilyManagePower(). */ + bool familyManagePower; + /*! @var asyncPowerStateChangeInProgress Set to true while an asynchronous power change is pending and false all other times. */ + bool asyncPowerStateChangeInProgress; + + /*! @var numRunningAudioEngines The number of running IOAudioEngines. This is used to maintain idle vs active power state. */ + UInt32 numRunningAudioEngines; + + /*! @var currentPowerState Used to track the existing power state - can be fetched by calling getPowerState() */ + IOAudioDevicePowerState currentPowerState; + /*! @var pendingPowerState If a power state change is in progress, this represents the pending power state. All other times this is the same as the currentPowerState. */ + IOAudioDevicePowerState pendingPowerState; + + /*! @var audioEngines The set of IOAudioEngine objects vended by the IOAudioDevice. */ + OSArray * audioEngines; + /*! @var timerEvents The set of timer events in use by the device. + * @discussion The key for the dictionary is the target of the event. This means that a single target may + * have only a single event associated with it. + */ + OSDictionary * timerEvents; + /*! @var audioPorts The set of IOAudioPort objects associated with the IOAudioDevice */ + OSSet * audioPorts; + + /*! @var minimumInterval The smallest timer interval requested by all timer event targets. */ + AbsoluteTime minimumInterval; + /*! @var previousTimerFire The time of the last timer event. + * @discussion This is used to schedule the next timer event. + */ + AbsoluteTime previousTimerFire; + +public: + /*! @var gIOAudioPlane A static IORegistryPlane representing the new IOAudioPlane that the IOAudioFamily uses + * to represent the signal chain of the device. + */ + static const IORegistryPlane *gIOAudioPlane; + +protected: + struct ExpansionData { + unsigned long long idleSleepDelayTime; + IOTimerEventSource * idleTimer; + }; + + ExpansionData *reserved; + +public: + static void idleAudioSleepHandlerTimer(OSObject *owner, IOTimerEventSource *sender); + virtual IOReturn setAggressiveness(unsigned long type, unsigned long newLevel); + + // OSMetaClassDeclareReservedUsed(IOAudioDevice, 0); + virtual void setDeviceTransportType(const UInt32 transportType); + + // OSMetaClassDeclareReservedUsed(IOAudioDevice, 1); + /*! + * @function setIdleAudioSleepTime + * @abstract This function is to be called by a driver that doesn't want to be told about the audio + * going idle immediately, but at some point in the future. + * @discussion This is useful if the device will want to power down its hardware into an idle sleep + * state, but doesn't want to do that unless audio hasn't been used for a while. Calling this function + * immediately changes the idle sleep timer and queues it up if the idle is different from the previous + * idle time. The idle time defaults to 0, which means be called immediately (backwards compatible with + * previous versions of IOAudioFamily). A value of 0xffffffffffffffffULL means don't ever tell the + * driver about going idle. + * @param sleepDelay The amount of time, in nanoseconds, before the hardware should be told to go idle. + */ + virtual void setIdleAudioSleepTime(unsigned long long sleepDelay); + + // OSMetaClassDeclareReservedUsed(IOAudioDevice, 2); + virtual void scheduleIdleAudioSleep(void); + + // OSMetaClassDeclareReservedUsed(IOAudioDevice, 3); + /*! + * @function setConfigurationApplicationBundle + * @abstract This function is to be called if an external configuration application is available to set + * which application to launch. + * @discussion This is useful for device drivers that are too complex to be represented by the Sound Preferences + * panel. The bundle ID is a more flexible way of specifying where the application is than a hard coded path. + * @param bundleID The bundle ID of the application to be launched by the HAL for configuration of the device and its engine(s). + */ + virtual void setConfigurationApplicationBundle(const char *bundleID); + + // OSMetaClassDeclareReservedUsed(IOAudioDevice, 4); + /*! + * @function setDeviceCanBeDefault + * @abstract This function is to be called to tell CoreAudio if this device shouldn't be a default device. + * @discussion This is useful for device drivers that don't want to be a default device. Can be called with + * kIOAudioDeviceCanBeDefaultNothing to prevent CoreAudio from allowing this device to be any default device, or it + * can be called with any combination of kIOAudioDeviceCanBeDefaultInput, kIOAudioDeviceCanBeDefaultOutput, or + * kIOAudioDeviceCanBeSystemOutput. The default is + * (kIOAudioDeviceCanBeDefaultInput | kIOAudioDeviceCanBeDefaultOutput | kIOAudioDeviceCanBeSystemOutput). + * @param defaultsFlags The flags to instruct CoreAudio to allow this device to be only the indicated default devices. + */ + virtual void setDeviceCanBeDefault(UInt32 defaultsFlags); + + // OSMetaClassDeclareReservedUsed(IOAudioDevice, 5); + virtual void setDeviceModelName(const char * modelName); + +private: + OSMetaClassDeclareReservedUsed(IOAudioDevice, 0); + OSMetaClassDeclareReservedUsed(IOAudioDevice, 1); + OSMetaClassDeclareReservedUsed(IOAudioDevice, 2); + OSMetaClassDeclareReservedUsed(IOAudioDevice, 3); + OSMetaClassDeclareReservedUsed(IOAudioDevice, 4); + OSMetaClassDeclareReservedUsed(IOAudioDevice, 5); + + OSMetaClassDeclareReservedUnused(IOAudioDevice, 6); + OSMetaClassDeclareReservedUnused(IOAudioDevice, 7); + OSMetaClassDeclareReservedUnused(IOAudioDevice, 8); + OSMetaClassDeclareReservedUnused(IOAudioDevice, 9); + OSMetaClassDeclareReservedUnused(IOAudioDevice, 10); + OSMetaClassDeclareReservedUnused(IOAudioDevice, 11); + OSMetaClassDeclareReservedUnused(IOAudioDevice, 12); + OSMetaClassDeclareReservedUnused(IOAudioDevice, 13); + OSMetaClassDeclareReservedUnused(IOAudioDevice, 14); + OSMetaClassDeclareReservedUnused(IOAudioDevice, 15); + OSMetaClassDeclareReservedUnused(IOAudioDevice, 16); + OSMetaClassDeclareReservedUnused(IOAudioDevice, 17); + OSMetaClassDeclareReservedUnused(IOAudioDevice, 18); + OSMetaClassDeclareReservedUnused(IOAudioDevice, 19); + OSMetaClassDeclareReservedUnused(IOAudioDevice, 20); + OSMetaClassDeclareReservedUnused(IOAudioDevice, 21); + OSMetaClassDeclareReservedUnused(IOAudioDevice, 22); + OSMetaClassDeclareReservedUnused(IOAudioDevice, 23); + OSMetaClassDeclareReservedUnused(IOAudioDevice, 24); + OSMetaClassDeclareReservedUnused(IOAudioDevice, 25); + OSMetaClassDeclareReservedUnused(IOAudioDevice, 26); + OSMetaClassDeclareReservedUnused(IOAudioDevice, 27); + OSMetaClassDeclareReservedUnused(IOAudioDevice, 28); + OSMetaClassDeclareReservedUnused(IOAudioDevice, 29); + OSMetaClassDeclareReservedUnused(IOAudioDevice, 30); + OSMetaClassDeclareReservedUnused(IOAudioDevice, 31); + + +public: + // Initialization + + /*! + * @function init + * @abstract Initialize a newly created instance of IOAudioDevice. + * @discussion This implementation initializes all of the data structures and variables used by the + * IOAudioDevice. The currentPowerState and pendingPowerState variables are set to kIOAudioDeviceIdle. + * A subclass that overrides this method must call the superclass' implementation. + * @param properties An OSDictionary of the device properties that gets passed to super::init and set + * in the IORegistry. + * @result true if initialization was successful + */ + virtual bool init(OSDictionary *properties); + + /*! + * @function free + * @abstract Frees resources used by the IOAudioDevice instance + * @discussion This method will deactivate all audio audio engines and release the audioEngines OSSet. + * It will also deactivate all of the audio ports and release the audioPorts OSSet. It will release + * the timerEvents OSDictionary as well as cancel any outstanding timer callbacks. It will clean up + * all of the event sources and the workLoop. + * + * Do not call this directly. This is called automatically by the system when the instance's + * refcount goes to 0. To decrement the refcount, call release() on the object. + */ + + virtual void free(); + + /*! + * @function start + * @abstract This function is called automatically by the system to tell the driver to start vending + * services to the rest of the system. + * @discussion The start() implementation in IOAudioDevice starts by calling start() on its superclass. + * It then calls initHardware() which the subclass should override to properly initialize itself and + * the hardware. If that call succeeds, it sets up power management if the family is supposed to + * manage power (checking the familyManagePower variable). Then finally it calls registerService() + * to make the IOAudioDevice visible in the IORegistry. + * @param provider This is the service provider nub that provides access to the hardware resources. + * @result Returns true on success + */ + virtual bool start(IOService *provider); + + /*! + * @function stop + * @abstract This is responsible for stopping the device after the system is done with it (or + * if the device is removed from the system). + * @discussion The IOAudioDevice implentation of stop() disables the timer services, deactivates + * all of the audio audio engines and audio ports and stops power management of the device. + * The audio engine and port deactivation causes all of the audio engines to get stopped and + * all of the audio engine and port resources and objects to be released. A subclass' implementation + * may could shut down hardware here if necessary. If this function is overridden by a subclass, + * the superclass' implementation must be called. + * @param The service provider nub for the device. + */ + virtual void stop(IOService *provider); + virtual bool willTerminate(IOService *provider, IOOptionBits options); + + /*! + * @function initHardware + * @abstract This function is called by start() to provide a convenient place for the subclass to + * perform its initialization. + * @discussion In a typical implementation, a driver would implementation this function and perform + * a number of tasks. Those include mapping hardware resources, initializing the hardware to a known + * state, creating the IOAudioEngines, IOAudioControls and IOAudioStreams. Additionally it + * should also call setDeviceName(), setDeviceShortName(), setManufacturerName(). Upon return of + * this function, the device should be ready to begin vending services to the system. + * @param provider The service provider nub for the device. + * @result This function should return true on a successful initialization. + */ + virtual bool initHardware(IOService *provider); + + /*! + * @function setDeviceName + * @abstract Sets the name of the device + * @discussion This method should be called during initialization or startup. It should + * be set by the time initHardware() completes. The device name is used by the + * CoreAudio.framework to identify the particular piece of hardware. This string should + * should be localized by the driver. + */ + virtual void setDeviceName(const char *deviceName); + + /*! + * @function setDeviceShortName + * @abstract Sets the short name of the device + * @discussion The short name is a shorter representation of the device name. It may be used + * by applications when the device name is too long. It should be set by the time initHardware() + * completes. The string should be localized by the driver. + */ + virtual void setDeviceShortName(const char *shortName); + + /*! + * @function setManufacturerName + * @abstract Sets the manufacturer name of the device + * @discussion This method should be called during initialization or startup. This should be + * called by the time initHardware() completes. The string should be localized by the driver. + */ + virtual void setManufacturerName(const char *manufacturerName); + + + // IOWorkLoop, IOCommandGate management + + /*! + * @function getWorkLoop + * @abstract Returns the IOWorkLoop for the driver + * @discussion The IOWorkLoop is used to synchronized all critical aspects of the driver. This + * includes all entry points to the driver as well as power management. + */ + virtual IOWorkLoop *getWorkLoop() const; + + /*! + * @function getCommandGate + * @abstract Returns the IOCommandGate for this IOAudioDevice + * @discussion This IOCommandGate allows calls into this IOAudioDevice to be synchronized on + * the IOWorkLoop. + */ + virtual IOCommandGate *getCommandGate() const; + + + // IOAudioEngine management + + /*! + * @function activateAudioEngine + * @abstract This simply calls activateAudioEngine(IOAudioEngine *audioEngine, + * bool shouldStartAudioEngine) with a value of true for shouldStartAudioEngine. + * @param audioEngine The IOAudioEngine instance to be activated. It is treated as a newly + * allocated instance. + * @result Returns true if the audio engine was successfully activated. + */ + virtual IOReturn activateAudioEngine(IOAudioEngine *audioEngine); + + /*! + * @function activateAudioEngine + * @abstract This is called to add a new IOAudioEngine object to the IOAudioDevice. + * @discussion Once the IOAudioEngine has been activated by this function, it is ready + * to begin moving audio data. This should be called either during the subclass' initHardware() + * implementation for each IOAudioEngine the device creates. Or it should be called by + * the IOAudioEngine itself if the audio engine was automatically created by IOKit's matching + * process. The system won't be able to properly track and control IOAudioEngines if + * they are not activated though this function. + * This implementation will retain the IOAudioEngine while it maintains control of it. + * When the audio engine is deactivated, the IOAudioEngine will be released. If the + * IOAudioDevice subclass is passing a newly instantiated IOAudioEngine, it will need to release + * the audio engine after it has been activated. This will insure that the refCount on the audio engine + * is correct when it gets deactivated when the driver is stopped. That allows the audio engine to be + * freed when it is no longer needed. + * @param audioEngine The IOAudioEngine instance to be activated. + * @param shouldStartAudioEngine If true, the audio engine is treated as a newly allocated IOAudioEngine + * instance and is appropriately attached and started according to IOKit convention. If it is false + * it is assumed that some other process (possibly the IOKit matching process) has started the + * IOAudioEngine and will skip that step. + * @result Returns true if the audio engine was successfully activated. + */ + virtual IOReturn activateAudioEngine(IOAudioEngine *audioEngine, bool shouldStartAudioEngine); + + /*! + * @function deactivateAllAudioEngines + * @abstract Deactivates all of the audio engines in the device. + * @discussion This is called by the stop() and free() methods in IOAudioDevice to completely + * shut down all audio engines as the driver is being shut down. + */ + virtual void deactivateAllAudioEngines(); + + + // Power management + + /*! + * @function setFamilyManagePower + * @abstract Called set whether or not the family should manage the device power throught the + * IOService power management APIs. + * @discussion The default behavior is for the family to manage power. It is only necessary to + * call this function if the driver does not want the family to manage power. It is not + * recommended that this function be called because it makes power management much more + * difficult for the driver. If this function is to be called, it must be called before + * initHardware() completes. Immediately after initHardware() is called by start(), + * the power management system is initialized if the family is to manage power. + * @param manage Set to false if it is not desired that the family does the power management + */ + virtual void setFamilyManagePower(bool manage); + + /*! + * @function setPowerState + * @abstract Called by the power management system in IOService when the power state of this + * service needs to change. + * @discussion The default implementation of IOAudioDevice sets up two power states for IOService + * to use. State 0 is sleep and state 1 is wake. This function should not be called directly. + * It is only supposed to be used by the IOService power management services. + * @param powerStateOrdinal The number of the power state as defined by the IOAudioDevice - + * 0 for sleep, 1 for wake. + * @param device The power management policy maker. + * @result Returns kIOPMAckImplied (0) when the power state change is complete. Otherwise the an + * upper bound on the number of microseconds until the state change is complete is returned. + */ + virtual IOReturn setPowerState(unsigned long powerStateOrdinal, IOService *device); + + /*! + * @function setPowerStateAction + * @abstract IOCommandGate Action which calls protectedSetPowerState() while holding the IOCommandGate + * @discussion This is needed to allow protectedSetPowerState() to be called on the IOWorkLoop + * @param owner The owner of the IOCommandGate (the IOAudioDevice in this case) + * @param arg1 The powerStateOrdinal to be passed to protectedSetPowerState() + * @param arg2 The device to be passed to protectedSetPowerState() + * @result Returns the result of protectedSetPowerState() + */ + static IOReturn setPowerStateAction(OSObject *owner, void *arg1, void *arg2, void *arg3, void *arg4); + + /*! + * @function protectedSetPowerState + * @abstract Called by setPowerStateAction() to deal with a power state change from the IOService + * power management facility. + * @discussion This function is responsible for performing the necessary sleep and wake tasks + * when the system is sleeping or waking. If an outstanding power state change is in progress, + * it will wait until the state changes has completed. While sleeping, all audio engines are + * stopped before calling initiatePowerStateChange() to call performPowerStateChange() to let + * the driver deal with the sleep request. When waking, it determines if the device should be + * idle or active and continues to call initiatePowerStateChange(). If initiatePowerStateChange() + * indicates that the power state change is occuring asynchronously, it returns the number of + * microseconds. This function must be called on the IOWorkLoop, but should not be called + * directly. + * @param powerStateOrdinal Param passed to setPowerState() - 0 for sleep, 1 for wake + * @param device Param passed to setPowerState - the device initiating the power state change + * @result Returns 0 if the power state change is complete - the number of microseconds until + * complete if its asynchronous. + */ + virtual IOReturn protectedSetPowerState(unsigned long powerStateOrdinal, IOService *device); + + /*! + * @function performPowerStateChange + * @abstract This function is called by the IOAudioDevice when a power state change is needed. + * @discussion In order to deal with power state changes, a subclass must override this function. + * Any combination of old and new power states may be passed to this function. If work is to + * be performed while transitioning to sleep, check for a newPowerState of kIOAudioDeviceSleep. + * If work is to be performed while transitioning from sleep, check for an oldPowerState of + * kIOAudioDeviceSleep. A power state of kIOAudioDeviceIdle means the system is awake, but + * no clients are currently playing or recording audio (i.e. no IOAudioEngines are active). + * A power state of kIOAudioDeviceActive means that at least one IOAudioEngine is active. + * It is possible for a power state change to be performed synchronously or asynchronously. + * In the case of a synchronous power state change, simple leave microsecondsUntilComplete + * alone and return kIOReturnSuccess. If an asynchronous power state change is needed the + * driver should do whatever needed to schedule another thread to finish the state change + * and set the microsecondsUntilComplete to an upper bound on the amount of time it will + * take to complete the power state change. Then when the power state change is complete, + * a call must be made to completePowerStateChange(). During an asynchronous power state + * change, the current power state will remain the same as before the transition began, + * and the pendingPowerState is set to the new power state that will be set when the + * change is complete. + * @param oldPowerState The power state before the power state change + * @param newPowerState The power state being transitioned to + * @param microsecondsUntilComplete A pointer to a value representing an upper bound on + * the number of microseconds to complete an asynchronous power state change. It points + * to a value of zero at the start and if it remains zero, the state change is complete + * upon a successful return from the function. + * @result Returns kIOReturnSuccess on a successful completion + */ + virtual IOReturn performPowerStateChange(IOAudioDevicePowerState oldPowerState, + IOAudioDevicePowerState newPowerState, + UInt32 *microsecondsUntilComplete); + + /*! + * @function completePowerStateChange + * @abstract Called when a power state change is complete + * @discussion In the case of an asynchronous power state change, a subclass is responsible + * for calling this function. It is safe to call this function if not on the IOWorkLoop. + * This function calls protectedCompletePowerStateChange() through the IOCommandGate and + * completePowerStateChangeAction(). If the call is already on the IOWorkLoop, it is safe + * to call protectedCompletePowerStateChange() directly. + * @result Returns kIOReturnSuccess on a successful completion + */ + virtual IOReturn completePowerStateChange(); + + /*! + * @function completePowerStateChangeAction + * @abstract IOCommandGate Action which calls protectedCompletePowerStateChange() while holding the + * IOCommandGate. + * @discussion This is needed to allow protectedCompletePowerStateChange() to be called on the IOWorkLoop. + * @param owner The owner of the IOCommandGate (the IOAudioDevice in this case) + * @result Returns the result of protectedCompletePowerStateChange() + */ + static IOReturn completePowerStateChangeAction(OSObject *owner, void *arg1, void *arg2, void *arg3, void *arg4); + + /*! + * @function protectedCompletePowerStateChange() + * @abstract Called on the IOWorkLoop when a power state change is complete. + * @discussion This function does the work to complete a power state change (both synchronous and + * asynchronous). If the system is waking from sleep, the timer system is restarted and the + * audio engines are resumed. If this was called as a result of an asynchronous power state changed + * it makes the IOService power management call acknowledgePowerChange() and resets the + * asyncPowerStateChangeInProgress variable. Finally it sets the currentPowerState to the + * pendingPowerState. This function must be called on the IOWorkLoop. If a subclass is not + * on the IOWorkLoop (e.g. holding the IOCommandGate), call completePowerStateChange() instead. + * @result Returns kIOReturnSuccess on success + */ + virtual IOReturn protectedCompletePowerStateChange(); + + /*! + * @function getPowerState + * @abstract Returns the current power state (the old power state if a change is in progress). + * @result The current power state + */ + virtual IOAudioDevicePowerState getPowerState(); + + /*! + * @function getPendingPowerState + * @abstract Returns the pending power state if a state change is in progress. Otherwise it + * returns the current power state change. + * @result The pending power state + */ + virtual IOAudioDevicePowerState getPendingPowerState(); + + /*! + * @function waitForPendingPowerStateChange + * @abstract Called internally to wait until a pending power state change is complete. + * @discussion This is only used by internal functions to wait during pending power + * state changes. It is used to prevent multiple power state changes at the same time. + * This function must be called while holding the IOCommandGate. If an asynchronous + * power state change is in progress this function will block until the state change + * if complete. Once complete, it will return while still holding the IOCommandGate. + */ + virtual void waitForPendingPowerStateChange(); + + /*! + * @function initiatePowerStateChange + * @abstract Called internally to execute a power state change + * @discussion This function must be called on the IOWorkLoop. It calls performPowerStateChange() + * to let the driver process the state change. If the state change is completed synchronously + * by the driver (subclass) it calls protectedCompletePowerStateChange(). If done asynchronously + * it returns the microsecondsUntilComplete that was set by performPowerStateChange(). This + * function should not be called directly. + * @param microsecondsUntilComplete Pointer to the microsecondsUntilComplete that should be set + * by performPowerStateChange if an asynchronous power state change was started. + * @result Returns kIOReturnSuccess on success + */ + virtual IOReturn initiatePowerStateChange(UInt32 *microsecondsUntilComplete = NULL); + + + // IOAudioControl management + + /*! + * @function flushAudioControls + * @abstract Forces each IOAudioControl in the driver to have its value flushed out to the hardware. + * That will cause either the IOAudioControl's ValueChangeHandler to be called. + * @discussion This can be used to force the hardware to get updated with the current value + * of each control. It may be useful during wake for example. + */ + virtual void flushAudioControls(); + + + // Timer services + + /*! + * @typedef TimerEvent + * @abstract Generic timer event callback for IOAudioDevice timer targets + * @discussion TimerEvent callback function takes two arguments; the target of + * the timer event and the IOAudioDevice sending the event. + * @param target The target of the timer event - passed in when the timer event was registered + * @param audioDevice The IOAudioDevice sending the event + */ + typedef void (*TimerEvent)(OSObject *target, IOAudioDevice *audioDevice); + + /*! + * @function addTimerEvent + * @abstract Adds a TimerEvent callback for the given target called at least as often + * as specified in interval. + * @discussion The frequency of the timer event callbacks will be the smallest interval + * specified by all targets. Only one interval and callback may be specified per target. + * If a addTimerEvent is called twice with the same target, the second one overrides the + * first. There is currently a bug triggered if the first call had the smallest interval. + * In that case, that smallest interval would still be used. + * @param target This parameter is the target object of the TimerEvent. + * @param event The callback function called each time the timer fires. + * @param interval The callback will be called at least this often. + * @result Returns kIOReturnSuccess if the timer event was successfully added. + */ + virtual IOReturn addTimerEvent(OSObject *target, TimerEvent event, AbsoluteTime interval); + + /*! + * @function removeTimerEvent + * @abstract Removes the timer event for the given target. + * @discussion If the interval for the target to be removed is the smallest interval, + * the timer interval is recalculated based on the remaining targets. The next fire + * time is readjusted based on the new interval compared to the last fire time. + * @param target The target whose timer event will be removed. + */ + virtual void removeTimerEvent(OSObject *target); + + /*! + * @function removeAllTimerEvents + * @abstract Removes all timer events and stops the timer + * @discussion Called during teardown of the driver + */ + virtual void removeAllTimerEvents(); + + + // IOAudioPort management + + /*! + * @function attachAudioPort + * @abstract Adds the port to the IOAudioDevice's list of ports and attaches the port to its parent + * and attaches the child to the port. + * @discussion This function provides the functionality to represent the device's signal chain in the + * IOAudioPlane in the IORegistry. An IOAudioPort's parent(s) are before it in the signal chain + * and its children are after it. This method may be called multiple times for a single IOAudioPort. + * This is necessary when there are many children or parents. Once a relationship is made, it is not + * necessary to make the reverse relationship. A NULL value may be passed in for either the parent + * or child or both. + * The IOAudioPort passed in should be a newly allocated IOAudioPort instance. This function will + * appropriately attach and start the port object. NOTE: It is not necessary to use IOAudioPorts + * in a fully functional audio driver. + * @param port The newly created IOAudioPort instance to be activated. + * @param parent A parent IOAudioPort or IOAudioEngine of the given port. + * @param child A child IOAudioPort or IOAudioEngine of the given port. + * @result Returns true when the port has been successfully added and attached. + */ + virtual IOReturn attachAudioPort(IOAudioPort *port, IORegistryEntry *parent, IORegistryEntry *child); + + /*! + * @function detachAllAudioPorts + * @abstract Deactivates all of the ports in the device. + * @discussion This is called by the stop() and free() methods in IOAudioDevice to completely + * shut down all ports as the driver is being shut down. + */ + virtual void detachAllAudioPorts(); + +protected: + /*! + * @function timerFired + * @abstract Internal static function called when the timer fires. + * @discussion This function simply calls dispatchTimerEvents() on the IOAudioDevice to do just that. + * @param target The IOAudioDevice instance that initiated the timer callback. + * @param sender The IOTimerEventSources calling this callback + */ + static void timerFired(OSObject *target, IOTimerEventSource *sender); + + /*! + * @function dispatchTimerEvents + * @abstract Called by timerFired() to cause the timer event callbacks to be called. + * @discussion This method iterates through all of the timer event targets and calls + * the callback on each. Unless the force flag is set to true, the timer events will + * only be dispatched if the power state is not kIOAudioDeviceSleep. This prevents + * unexpected timer firings while making wake->sleep->wake transitions. This function must + * be called on the IOWorkLoop. + * @function force A bool param to allow the timer events to be dispatched even if the + * device is in the kIOAudioDeviceSleep power state. + */ + virtual void dispatchTimerEvents(bool force); + + /*! + * @function audioEngineStarting + * @abstract Called by IOAudioEngine when it is starting up + * @discussion This should only be called while on the IOWorkLoop. It is not intended to be called + * directly. It is called when an IOAudioEngine is starting up to allow the IOAudioDevice + * to keep track of running audio engines and change the power state from kIOAudioDeviceIdle to + * kIOAudioDeviceActive when the first audio engine starts up. If the state change is done + * asynchronously, it waits for the state change to complete. This is to ensure that the + * system doesn't start playing audio until the IOAudioDevice has completed its transition + * to kIOAudioDeviceActive. + */ + virtual void audioEngineStarting(); + + /*! + * @function audioEngineStopped + * @abstract Called by IOAudioEngine when it has stopped + * @discussion This should only be called while on the IOWorkLoop. It is not intended to be called + * directly. It is called when an IOAudioEngine has stopped to allow the IOAudioDevice + * to keep track of running audio engines and change the power state from kIOAudioDeviceActive + * to kIOAudioDeviceIdle when the last audio engine stops. If the state change is done + * asynchronously, it waits for the state change to complete. + */ + virtual void audioEngineStopped(); + +}; + +#endif /* _IOKIT_IOAUDIODEVICE_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/audio/IOAudioControl.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/audio/IOAudioControl.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/audio/IOAudioControl.h (revision 885) @@ -0,0 +1,595 @@ +/* + * Copyright (c) 1998-2010 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_IOAUDIOCONTROL_H +#define _IOKIT_IOAUDIOCONTROL_H + +#include +#ifndef IOAUDIOFAMILY_SELF_BUILD +#include +#else +#include "IOAudioEngine.h" +#endif + +class IOAudioPort; +class OSDictionary; +class OSSet; +class IOAudioUserClient; +class IOAudioControlUserClient; +class IOWorkLoop; +class IOCommandGate; + +/*! + * @class IOAudioControl + * @abstract Represents any controllable attribute of an IOAudioDevice. + * @discussion An IOAudioControl instance may belong to one IOAudioPort. Additionally, it may associated + * with an IOAudioEngine as a default control for that IOAudioEngine. + * + * When its value changes, it sends a notification to the CoreAudio.framework (HAL). It also makes a call + * to the ValueChangeHandler. + * + * The base IOAudioControl class contains a type, a value and a channel ID representing the channel(s) which + * the control acts on. It may also contain a readable format for the name of the channel as well as a + * control ID that can be used to identify unique controls. Additionally it may contain a subType and a usage. + * Each type has its own set of possible subTypes. There currently four different control types defined: + * kIOAudioControlTypeLevel, kIOAudioControlTypeToggle, kIOAudioControlTypeSelector. + * Each one is represented by a subclass of IOAudioControl: IOAudioLevelControl, IOAudioToggleControl, + * IOAudioSelectorControl. The level control defines a range of allowed values and has + * a defined subtype of kIOAudioLevelControlSubTypeVolume used to define a volume control. The toggle control + * allows for a boolean value and has a defined subtype kIOAudioToggleControlSubTypeMute for a mute control. The + * selector control has a list of allowed selections with a value and description for each allowed selection and + * has the following sub types: kIOAudioSelectorControlSubTypeOutput for an output selector and + * kIOAudioSelectorControlSubTypeInput for an input selector. See the subclass documentation for a more + * complete description of each + * + * There are enums for default channel ID values and common channel names in IOAudioTypes.h. The channel ID + * values are prefixed with 'kIOAudioControlChannelID' and the common channel names are prefixed with + * 'kIOAudioControlChannelName'. All of the attributes of the IOAudioControl are stored in the registry. + * The key used for each attribute is defined in IOAudioTypes.h with the define matching the following + * pattern: 'kIOAudioControlKey'. For example: kIOAudioControlChannelIDKey. + * + * In addition to the existing defined control types, drivers can define their own as well for other purposes. + * + * Changes to the IOAudioControl's value made by the CoreAudio.framework are done through the IORegistry. + * When the CoreAudio.framework initiates a value change, the control receives a setProperties() message. + * The setProperties() implementation looks for the property 'IOAudioControlValue' and if present, calls + * setValue() on the driver's IOWorkLoop with the new value. The setValue() function first checks to see + * if the new value is different. If so, it calls performValueChange() to call through to the driver + * to make the change in the hardware. If that call succeeds the value is changed and the new value is set + * in the registry. Additionally notifications are sent to all clients that have registered for them. + */ +class IOAudioControl : public IOService +{ + friend class IOAudioPort; + friend class IOAudioDevice; + friend class IOAudioEngine; + + OSDeclareDefaultStructors(IOAudioControl) + +public: + + /*! + * @typedef IntValueChangeHandler + * @abstract Handler function used to make a notification when a value is to be changed. + * @param target Reference supplied when the handler was registered. + * @param audioControl The IOAudioControl that is changing. + * @param oldValue The old value of the control. + * @param newValue The new value the control is being changed to. + * @result Must return kIOReturnSuccess when the hardware is successfully updated. + */ + typedef IOReturn (*IntValueChangeHandler)(OSObject *target, IOAudioControl *audioControl, SInt32 oldValue, SInt32 newValue); + typedef IOReturn (*DataValueChangeHandler)(OSObject *target, IOAudioControl *audioControl, const void *oldData, UInt32 oldDataSize, const void *newData, UInt32 newDataSize); + typedef IOReturn (*ObjectValueChangeHandler)(OSObject *target, IOAudioControl *audioControl, OSObject *oldValue, OSObject *newValue); + +protected: + /*! @var workLoop + The IOWorkLoop for the audio driver - shared from the IOAudioDevice. + */ + IOWorkLoop *workLoop; + /*! @var commandGate + The IOCommandGate for this control - attached to the driver's IOWorkLoop. + */ + IOCommandGate *commandGate; + + /*! @var isStarted + Internal state keeping track of when the IOAudioControl has been started. + */ + bool isStarted; + + /*! @var controlID + An optional identifier that can be used to identify the control. + */ + UInt32 controlID; + /*! @var channelID + The ID of the channel this control affects - may be kIOAudioControlChannelIDAll if it represents all channels. + */ + UInt32 channelID; + + UInt32 type; + UInt32 subType; + UInt32 usage; + + OSObject *value; + + typedef enum { + kIntValueChangeHandler, + kDataValueChangeHandler, + kObjectValueChangeHandler + } ValueChangeHandlerType; + + ValueChangeHandlerType valueChangeHandlerType; + + union { + IntValueChangeHandler intHandler; + DataValueChangeHandler dataHandler; + ObjectValueChangeHandler objectHandler; + } valueChangeHandler; + + OSObject *valueChangeTarget; + + /*! @var clients + A list of user clients that have requested value change notifications. + */ + OSSet *userClients; + +protected: + struct ExpansionData { + IOAudioEngine * providerEngine; + OSArray * notificationQueue; + }; + + ExpansionData *reserved; + +public: + // OSMetaClassDeclareReservedUsed(IOAudioControl, 0); + virtual void sendChangeNotification(UInt32 notificationType); + + // OSMetaClassDeclareReservedUsed(IOAudioControl, 1); + /*! + * @function setReadOnlyFlag + * @abstract Call this function to say that a control is read only. + * This call cannot be undone, so if a control is only temporarily unsetable, + * do not use this call but instead return an error from the control handler. + */ + virtual void setReadOnlyFlag(); + + // OSMetaClassDeclareReservedUsed(IOAudioControl, 2); + virtual void sendQueuedNotifications(void); + + // OSMetaClassDeclareReservedUsed(IOAudioControl, 3); + /*! + * @function createUserClient + * @abstract Creates a new IOAudioControlUserClient instance. + * @discussion This function is called by newUserClient() to create a new IOAudioControlUserClient instance. This function may be overridden by subclasses that need to add functionality + * to the IOAudioControlUserClient. In that case, they must subclass IOAudioControlUserClient + * and return a new, initialized instance of that subclass. + * A derived class that requires overriding of createUserClient should override the version with the properties + * parameter for Intel targets, and without the properties parameter for PPC targets. The #if __i386__ directive + * can be used to select between the two behaviors. + * @param task The task requesting the new user client. + * @param securityID Optional security paramater passed in by the client - ignored. + * @param type Optional user client type passed in by the client. + * @param newUserClient The IOAudioControlUserClient * must be stored in this param on a successful + * completion. + * @param properties A dictionary of additional properties for the connection. + * @result Returns kIOReturnSuccess on success. + */ + virtual IOReturn createUserClient(task_t task, void *securityID, UInt32 type, IOAudioControlUserClient **newUserClient, OSDictionary *properties); + +private: + OSMetaClassDeclareReservedUsed(IOAudioControl, 0); + OSMetaClassDeclareReservedUsed(IOAudioControl, 1); + OSMetaClassDeclareReservedUsed(IOAudioControl, 2); + OSMetaClassDeclareReservedUsed(IOAudioControl, 3); + + OSMetaClassDeclareReservedUnused(IOAudioControl, 4); + OSMetaClassDeclareReservedUnused(IOAudioControl, 5); + OSMetaClassDeclareReservedUnused(IOAudioControl, 6); + OSMetaClassDeclareReservedUnused(IOAudioControl, 7); + OSMetaClassDeclareReservedUnused(IOAudioControl, 8); + OSMetaClassDeclareReservedUnused(IOAudioControl, 9); + OSMetaClassDeclareReservedUnused(IOAudioControl, 10); + OSMetaClassDeclareReservedUnused(IOAudioControl, 11); + OSMetaClassDeclareReservedUnused(IOAudioControl, 12); + OSMetaClassDeclareReservedUnused(IOAudioControl, 13); + OSMetaClassDeclareReservedUnused(IOAudioControl, 14); + OSMetaClassDeclareReservedUnused(IOAudioControl, 15); + OSMetaClassDeclareReservedUnused(IOAudioControl, 16); + OSMetaClassDeclareReservedUnused(IOAudioControl, 17); + OSMetaClassDeclareReservedUnused(IOAudioControl, 18); + OSMetaClassDeclareReservedUnused(IOAudioControl, 19); + OSMetaClassDeclareReservedUnused(IOAudioControl, 20); + OSMetaClassDeclareReservedUnused(IOAudioControl, 21); + OSMetaClassDeclareReservedUnused(IOAudioControl, 22); + OSMetaClassDeclareReservedUnused(IOAudioControl, 23); + +public: + + /*! + * @function withAttributes + * @abstract Static function that allocates a new IOAudioControl with the given attributes. + * @param type The type of the control. Common, known types are defined in IOAudioTypes.h. They currently + * consist of kIOAudioControlTypeLevel, kIOAudioControlTypeToggle, kIOAudioControlTypeSelector. + * @param channelID The ID of the channel(s) that the control acts on. Common IDs are located in IOAudioTypes.h. + * @param channelName An optional name for the channel. Common names are located in IOAudioDefines.h. Any name not + * defined in IOAudioDefines.h must be localized in order to be properly displayed in multiple languages. + * @param cntrlID An optional ID for the control that can be used to uniquely identify controls + * @param subType An optional subType specific to the given type + * @param usage An optional value specifying how the control will be used. Currently defined usages are kIOAudioControlUsageInput, + * kIOAudioControlUsageOutput and kIOAudioControlUsagePassThru. This value is used when a control is set as a default control + * on an IOAudioEngine. + * @result Returns a newly allocated and initialized IOAudioControl. + */ + static IOAudioControl *withAttributes(UInt32 type, + OSObject *initialValue, + UInt32 channelID, + const char *channelName = 0, + UInt32 cntrlID = 0, + UInt32 subType = 0, + UInt32 usage = 0); + + /*! + * @function init + * @abstract Initializes a newly allocated IOAudioControl with the given attributes. + * @param type The type of the control. Common, known types are defined in IOAudioTypes.h. They currently + * consist of kIOAudioControlTypeLevel, kIOAudioControlTypeToggle, kIOAudioControlTypeSelector. + * @param channelID The ID of the channel(s) that the control acts on. Common IDs are located in IOAudioTypes.h. + * @param channelName An optional name for the channel. Common names are located in IOAudioDefines.h. Any name not + * defined in IOAudioDefines.h must be localized in order to be properly displayed in multiple languages. + * @param cntrlID An optional ID for the control that can be used to uniquely identify controls + * @param subType An optional subType specific to the given type + * @param usage An optional value specifying how the control will be used. Currently defined usages are kIOAudioControlUsageInput, + * kIOAudioControlUsageOutput and kIOAudioControlUsagePassThru. This value is used when a control is set as a default control + * on an IOAudioEngine. + * @param properties Standard property list passed to the init() function of any new IOService. This dictionary + * gets stored in the registry entry for this instance. + * @result Returns true on success. + */ + virtual bool init(UInt32 type, + OSObject *initialValue, + UInt32 channelID, + const char *channelName = 0, + UInt32 cntrlID = 0, + UInt32 subType = 0, + UInt32 usage = 0, + OSDictionary *properties = 0); + + /*! + * @function free + * @abstract Frees all of the resources allocated by the IOAudioControl. + * @discussion Do not call this directly. This is called automatically by the system when the instance's + * refcount goes to 0. To decrement the refcount, call release() on the object. + */ + virtual void free(); + + /*! + * @function start + * @abstract Starts a newly created IOAudioControl. + * @discussion This is called automatically by IOAudioPort when addAudioControl() is called or by IOAudioEngine + * when addDefaultAudioControl() is called. It will only be called by the first call to either addAudioControl() or + * addDefaultAudioControl(). + * @param provider The IOAudioPort or IOAudioEngine that owns this control. + * @result Returns true on success. + */ + virtual bool start(IOService *provider); + + virtual bool attachAndStart(IOService *provider); + + /*! + * @function getIsStarted + * @abstract Returns true after start() has been called. + * @discussion Used by IOAudioPort and IOAudioEngine to decide if the control needs to be started. + */ + virtual bool getIsStarted(); + + /*! + * @function stop + * @abstract Stops the control when the provider is going away. + * @param provider The IOAudioPort or IOAudioEngine that owns this control. + */ + virtual void stop(IOService *provider); + + /*! + * @function getWorkLoop + * @abstract Returns the IOWorkLoop for the whole audio driver. + */ + virtual IOWorkLoop *getWorkLoop(); + + /*! + * @function getCommandGate + * @abstract Returns the IOCommandGate for this IOAudioControl. + */ + virtual IOCommandGate *getCommandGate(); + + /*! + * @function newUserClient + * @abstract Creates a new user client object for this IOAudioControl instance. + * @discussion This is called automatically by I/O Kit when a user process opens a connection to this + * IOAudioControl. This is typically done when the user process needs to register for value change + * notifications. This implementation allocates a new IOAudioControlUserClient object. There is no + * need to call this directly. + * A derived class that requires overriding of newUserClient should override the version with the properties + * parameter for Intel targets, and without the properties parameter for PPC targets. The #if __i386__ directive + * can be used to select between the two behaviors. + * @param task The task requesting the new user client. + * @param securityID Optional security paramater passed in by the client - ignored. + * @param type Optional user client type passed in by the client - 0 for the default user client type. + * @param handler The new IOUserClient * must be stored in this param on a successful completion. + * @param properties A dictionary of additional properties for the connection. + * @result Returns kIOReturnSuccess on success. May also result kIOReturnError or kIOReturnNoMemory. + */ + virtual IOReturn newUserClient(task_t task, void *securityID, UInt32 type, IOUserClient **handler); + virtual IOReturn newUserClient(task_t task, void *securityID, UInt32 type, OSDictionary *properties, IOUserClient **handler); + + /*! + * @function createUserClient + * @abstract Creates a new IOAudioControlUserClient instance. + * @discussion This function is called by newUserClient() to create a new IOAudioControlUserClient instance. This function may be overridden by subclasses that need to add functionality + * to the IOAudioControlUserClient. In that case, they must subclass IOAudioControlUserClient + * and return a new, initialized instance of that subclass. + * A derived class that requires overriding of createUserClient should override the version with the properties + * parameter for Intel targets, and without the properties parameter for PPC targets. The #if __i386__ directive + * can be used to select between the two behaviors. + * @param task The task requesting the new user client. + * @param securityID Optional security paramater passed in by the client - ignored. + * @param type Optional user client type passed in by the client. + * @param newUserClient The IOAudioControlUserClient * must be stored in this param on a successful + * completion. + * @result Returns kIOReturnSuccess on success. + */ + virtual IOReturn createUserClient(task_t task, void *securityID, UInt32 type, IOAudioControlUserClient **newUserClient); + + /*! + * @function clientClosed + * @abstract Called automatically by the IOAudioControlUserClient when a user client closes its + * connection to the control. + * @param client The user client object that has disconnected. + */ + virtual void clientClosed(IOAudioControlUserClient *client); + + /*! + * @function setProperties + * @abstract Changes a property of this IOService. + * @discussion This is called when the user client changes a property of this + * IOAudioControl. In this case it is used to change the value. This function + * looks for that property and then calls setValue() through the IOCommandGate and + * setValueAction(). + * @param properties An OSDictionary containing the properties to change. + * @result Returns kIOReturnSuccess on success. + */ + virtual IOReturn setProperties(OSObject *properties); + + virtual void setValueChangeHandler(IntValueChangeHandler intValueChangeHandler, OSObject *target); + virtual void setValueChangeHandler(DataValueChangeHandler dataValueChangeHandler, OSObject *target); + virtual void setValueChangeHandler(ObjectValueChangeHandler objectValueChangeHandler, OSObject *target); + + virtual void setValueChangeTarget(OSObject *target); + + /*! + * @function flushValue + * @abstract Forces the control to be flushed out to the hardware. + * @discussion This function calls performValueChange() directly with the current value of the IOAudioControl. + * @result Returns the result of performValueChange() - kIOReturnSuccess on success. + */ + virtual IOReturn flushValue(); + + /*! + * @function setValueAction + * @abstract IOCommandGate Action which calls setValue() while holding the IOCommandGate. + * @discussion This is needed to allow setValue() to be called on the IOWorkLoop. + * @param owner The owner of the IOCommandGate (the IOAudioControl in this case). + * @param arg1 The new value for the IOAudioControl. + * @result Returns the result of setValue() - kIOReturnSuccess on success. + */ + static IOReturn setValueAction(OSObject *owner, void *arg1, void *arg2, void *arg3, void *arg4); + + static IOReturn _setValueAction(OSObject *target, void *arg0, void *arg1, void *arg2, void *arg3); // + + /*! + * @function setValue + * @abstract Sets the value for this control. + * @discussion When the control's value is changed, a call is made to performValueChange(). If that call + * succeeds, the value is set and sendValueChangeNotification() is called to send a notification to the + * user clients. This function must be called on the IOWorkLoop. + * @param newValue The new value for this control. + * @result Returns kIOReturnSuccess if the value is successfully set. + */ + virtual IOReturn setValue(OSObject *newValue); + + virtual IOReturn setValue(SInt32 intValue); + + /*! + * @function hardwareValueChanged + * @abstract Updates the value for this control and sends out the value changed notification. + * @discussion This is designed to be called by the driver when it detects that the hardware's value has + * changed without driver intervention (e.g. when an external event causes the change). The difference between + * hardwareValueChanged() and setValue() is that hardwareValueChanged() doesn't call performValueChange() which + * sends a message back to the driver to cause it to change the hardware with the new value. This function must + * be called on the IOWorkLoop. + * @param newValue The new value for this control. + * @result Returns kIOReturnSuccess if the value is successfully updated. + */ + virtual IOReturn hardwareValueChanged(OSObject *newValue); + + /*! + * @function getValue + * @abstract Returns the current value of the control. + */ + virtual OSObject *getValue(); + virtual SInt32 getIntValue(); + virtual const void *getDataBytes(); + virtual UInt32 getDataLength(); + + /*! + * @function getControlID + * @abstract Returns the control ID for the control. + */ + virtual UInt32 getControlID(); + + /*! + * @function getChannelID + * @abstract Returns the channel ID for the control. + */ + virtual UInt32 getChannelID(); + + virtual UInt32 getType(); + virtual UInt32 getSubType(); + virtual UInt32 getUsage(); + + virtual void setCoreAudioPropertyID(UInt32 propertyID); + + void setWorkLoop(IOWorkLoop *wl); + +protected: + /*! + * @function sendValueChangeNotification + * @abstract Called when the value has changed for the control. + * @discussion This function sends out the value change notification to the user clients. + */ + virtual void sendValueChangeNotification(); + + /*! + * @function setChannelName + * @abstract Called at init time to set the channel name for this IOAudioControl. + */ + virtual void setChannelName(const char *channelName); + + /*! + * @function setChannelID + * @abstract Called at init time to set the channel ID for this IOAudioControl. + */ + virtual void setChannelID(UInt32 newChannelID); + virtual void setChannelNumber(SInt32 channelNumber); + + /*! + * @function setSubType + * @abstract Called at init time to set the control subType. + */ + virtual void setType(UInt32 type); + + /*! + * @function setType + * @abstract Called at init time to set the control type. + */ + virtual void setSubType(UInt32 subType); + + /*! + * @function setUsage + * @abstract Called at init time to set the control usage. + */ + virtual void setUsage(UInt32 usage); + + /*! + * @function setControlID + * @abstract Sets the controlID for this control. + * @discussion The control ID is an optional attribute that can be used to track IOAudioControls. A typical + * use is for the IOAudioDevice to assign a unique controlID to each control that it creates and then + * do a switch statement on the id of the control when it gets an audioControlValueChanged() notification. + * Typically the control ID is set when the object is created and doesn't need to be called again. + * @param cntrlID The control ID for the control. + */ + virtual void setControlID(UInt32 cntrlID); + + /*! + * @function validateValue + * @abstract Called by setValue() to verify that the value is valid. + * @param newValue The new value to be verified. + * @result Returns kIOReturnSuccess if the value is valid. + */ + virtual IOReturn validateValue(OSObject *newValue); + + /*! + * @function updateValue + * @abstract Called by setValue() in order to update the value and the registry. + * @discussion It also calls + * sendValueChangedNotification() to send notifications to the user clients. + * @param newValue The new value to b updated. + * @result Returns kIOReturnSuccess if the value is successfully updated. + */ + virtual IOReturn updateValue(OSObject *newValue); + + virtual IOReturn _setValue(OSObject *newValue); + + /*! + * @function performValueChange + * @abstract Called by setValue() to make the call to the valueChangeHandler + * to update the hardware. + * @result Returns the result of the handler call (or kIOReturnError on an error). + */ + virtual IOReturn performValueChange(OSObject *newValue); + + /*! + * @function addUserClientAction + * @abstract IOCommandGate Action which calls addUserClient() while holding the IOCommandGate. + * @discussion This is needed to allow addUserClient() to be called on the IOWorkLoop. + * @param owner The owner of the IOCommandGate (the IOAudioControl in this case). + * @param arg1 The IOAudioControlUserClient to be added. + * @result Returns the result of addUserClient() - kIOReturnSuccess on success. + */ + static IOReturn addUserClientAction(OSObject *owner, void *arg1, void *arg2, void *arg3, void *arg4); + + static IOReturn _addUserClientAction(OSObject *target, void *arg0, void *arg1, void *arg2, void *arg3); // + + /*! + * @function removeUserClientAction + * @abstract IOCommandGate Action which calls removeUserClient() while holding the IOCommandGate. + * @discussion This is needed to allow removeUserClient() to be called on the IOWorkLoop. + * @param owner The owner of the IOCommandGate (the IOAudioControl in this case). + * @param arg1 The IOAudioControlUserClient to be removed. + * @result Returns the result of removeUserClient() - kIOReturnSuccess on success. + */ + static IOReturn removeUserClientAction(OSObject *owner, void *arg1, void *arg2, void *arg3, void *arg4); + + static IOReturn _removeUserClientAction(OSObject *target, void *arg0, void *arg1, void *arg2, void *arg3); // + + /*! + * @function detachUserClientsAction + */ + static IOReturn detachUserClientsAction(OSObject *owner, void *arg1, void *arg2, void *arg3, void *arg4); + + /*! + * @function addUserClient + * @abstract Called on the IOWorkLoop to add a new IOAudioControlUserClient. + * @discussion There is no need to call this directly. It is called on the workLoop + * by newUserClient() through addUserClientAction(). + * @param newUserClient The IOAudioControlUserClientto be added. + * @result Returns kIOReturnSuccess on success. + */ + virtual IOReturn addUserClient(IOAudioControlUserClient *newUserClient); + + /*! + * @function removeUserClient + * @abstract Called on the IOWorkLoop to remove an IOAudioControlUserClient. + * @discussion This is called on the IOWorkLoop by clientClosed() through + * removeUserClientAction() when the user client is going away. It should + * not be called directly. + * @param userClient The IOAudioControlUserClient to be removed. + * @result Returns kIOReturnSuccess on success. + */ + virtual IOReturn removeUserClient(IOAudioControlUserClient *userClient); + + virtual IOReturn detachUserClients(); + +}; + +#endif /* _IOKIT_IOAUDIOCONTROL_H */ + Index: branches/azimutz/Cleancut/i386/include/IOKit/audio/IOAudioSelectorControl.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/audio/IOAudioSelectorControl.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/audio/IOAudioSelectorControl.h (revision 885) @@ -0,0 +1,122 @@ +/* + * Copyright (c) 1998-2010 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_IOAUDIOSELECTORCONTROL_H +#define _IOKIT_IOAUDIOSELECTORCONTROL_H + +#ifndef IOAUDIOFAMILY_SELF_BUILD +#include +#else +#include "IOAudioControl.h" +#endif + +class OSString; +class OSArray; + +class IOAudioSelectorControl : public IOAudioControl +{ + OSDeclareDefaultStructors(IOAudioSelectorControl) + +protected: + + OSArray *availableSelections; + +protected: + struct ExpansionData { }; + + ExpansionData *reserved; + +public: + static IOAudioSelectorControl *createOutputSelector(SInt32 initialValue, + UInt32 channelID, + const char *channelName = 0, + UInt32 cntrlID = 0); + static IOAudioSelectorControl *createOutputClockSelector(SInt32 initialValue, + UInt32 channelID, + UInt32 clockSource, + const char *channelName = 0, + UInt32 cntrlID = 0); + static IOAudioSelectorControl *createInputClockSelector(SInt32 initialValue, + UInt32 channelID, + UInt32 clockSource, + const char *channelName = 0, + UInt32 cntrlID = 0); + + // OSMetaClassDeclareReservedUsed(IOAudioSelectorControl, 0); + virtual IOReturn removeAvailableSelection(SInt32 selectionValue); + // OSMetaClassDeclareReservedUsed(IOAudioSelectorControl, 1); + virtual IOReturn replaceAvailableSelection(SInt32 selectionValue, const char *selectionDescription); + // OSMetaClassDeclareReservedUsed(IOAudioSelectorControl, 2); + virtual IOReturn replaceAvailableSelection(SInt32 selectionValue, OSString *selectionDescription); + +private: + OSMetaClassDeclareReservedUsed(IOAudioSelectorControl, 0); + OSMetaClassDeclareReservedUsed(IOAudioSelectorControl, 1); + OSMetaClassDeclareReservedUsed(IOAudioSelectorControl, 2); + + OSMetaClassDeclareReservedUnused(IOAudioSelectorControl, 3); + OSMetaClassDeclareReservedUnused(IOAudioSelectorControl, 4); + OSMetaClassDeclareReservedUnused(IOAudioSelectorControl, 5); + OSMetaClassDeclareReservedUnused(IOAudioSelectorControl, 6); + OSMetaClassDeclareReservedUnused(IOAudioSelectorControl, 7); + OSMetaClassDeclareReservedUnused(IOAudioSelectorControl, 8); + OSMetaClassDeclareReservedUnused(IOAudioSelectorControl, 9); + OSMetaClassDeclareReservedUnused(IOAudioSelectorControl, 10); + OSMetaClassDeclareReservedUnused(IOAudioSelectorControl, 11); + OSMetaClassDeclareReservedUnused(IOAudioSelectorControl, 12); + OSMetaClassDeclareReservedUnused(IOAudioSelectorControl, 13); + OSMetaClassDeclareReservedUnused(IOAudioSelectorControl, 14); + OSMetaClassDeclareReservedUnused(IOAudioSelectorControl, 15); + +public: + static IOAudioSelectorControl *create(SInt32 initialValue, + UInt32 channelID, + const char *channelName = 0, + UInt32 cntrlID = 0, + UInt32 subType = 0, + UInt32 usage = 0); + + static IOAudioSelectorControl *createInputSelector(SInt32 initialValue, + UInt32 channelID, + const char *channelName = 0, + UInt32 cntrlID = 0); + + virtual bool init(SInt32 initialValue, + UInt32 channelID, + const char *channelName = 0, + UInt32 cntrlID = 0, + UInt32 subType = 0, + UInt32 usage = 0, + OSDictionary *properties = 0); + + virtual void free(); + + virtual IOReturn addAvailableSelection(SInt32 selectionValue, const char *selectionDescription); + virtual IOReturn addAvailableSelection(SInt32 selectionValue, OSString *selectionDescription); + + virtual bool valueExists(SInt32 selectorValue); + + virtual IOReturn validateValue(OSObject *newValue); + +}; + +#endif /* _IOKIT_IOAUDIOSELECTORCONTROL_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/audio/IOAudioToggleControl.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/audio/IOAudioToggleControl.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/audio/IOAudioToggleControl.h (revision 885) @@ -0,0 +1,121 @@ +/* + * Copyright (c) 1998-2010 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_IOAUDIOTOGGLECONTROL_H +#define _IOKIT_IOAUDIOTOGGLECONTROL_H + +#ifndef IOAUDIOFAMILY_SELF_BUILD +#include +#else +#include "IOAudioControl.h" +#endif + +/*! + * @class IOAudioToggleControl + */ + +class IOAudioToggleControl : public IOAudioControl +{ + OSDeclareDefaultStructors(IOAudioToggleControl) + +protected: + struct ExpansionData { }; + + ExpansionData *reserved; + +// New code added here +public: + /*! + * @function createPassThruMuteControl + * @abstract Allocates a new pass through mute control with the given attributes + * @param initialValue The initial value of the control + * @param channelID The ID of the channel(s) that the control acts on. Common IDs are located in IOAudioTypes.h. + * @param channelName An optional name for the channel. Common names are located in IOAudioPort.h. + * @param cntrlID An optional ID for the control that can be used to uniquely identify controls + * @result Returns a newly allocated and initialized mute IOAudioControl + */ + static IOAudioToggleControl *createPassThruMuteControl (bool initialValue, + UInt32 channelID, + const char *channelName, + UInt32 cntrlID); + +private: + OSMetaClassDeclareReservedUnused(IOAudioToggleControl, 0); + OSMetaClassDeclareReservedUnused(IOAudioToggleControl, 1); + OSMetaClassDeclareReservedUnused(IOAudioToggleControl, 2); + OSMetaClassDeclareReservedUnused(IOAudioToggleControl, 3); + OSMetaClassDeclareReservedUnused(IOAudioToggleControl, 4); + OSMetaClassDeclareReservedUnused(IOAudioToggleControl, 5); + OSMetaClassDeclareReservedUnused(IOAudioToggleControl, 6); + OSMetaClassDeclareReservedUnused(IOAudioToggleControl, 7); + OSMetaClassDeclareReservedUnused(IOAudioToggleControl, 8); + OSMetaClassDeclareReservedUnused(IOAudioToggleControl, 9); + OSMetaClassDeclareReservedUnused(IOAudioToggleControl, 10); + OSMetaClassDeclareReservedUnused(IOAudioToggleControl, 11); + OSMetaClassDeclareReservedUnused(IOAudioToggleControl, 12); + OSMetaClassDeclareReservedUnused(IOAudioToggleControl, 13); + OSMetaClassDeclareReservedUnused(IOAudioToggleControl, 14); + OSMetaClassDeclareReservedUnused(IOAudioToggleControl, 15); + +public: + /*! + * @function create + * @abstract Allocates a new mute control with the given attributes + * @param initialValue The initial value of the control + * @param channelID The ID of the channel(s) that the control acts on. Common IDs are located in IOAudioTypes.h. + * @param channelName An optional name for the channel. Common names are located in IOAudioPort.h. + * @param cntrlID An optional ID for the control that can be used to uniquely identify controls + * @result Returns a newly allocated and initialized mute IOAudioControl + */ + static IOAudioToggleControl *create(bool initialValue, + UInt32 channelID, + const char *channelName = 0, + UInt32 cntrlID = 0, + UInt32 subType = 0, + UInt32 usage = 0); + + static IOAudioToggleControl *createMuteControl(bool initialValue, + UInt32 channelID, + const char *channelName = 0, + UInt32 cntrlID = 0, + UInt32 usage = 0); + + /*! + * @function init + * @abstract Initializes a newly allocated IOAudioToggleControl with the given attributes + * @param initialValue The initial value of the control + * @param channelID The ID of the channel(s) that the control acts on. Common IDs are located in IOAudioTypes.h. + * @param channelName An optional name for the channel. Common names are located in IOAudioPort.h. + * @param cntrlID An optional ID for the control that can be used to uniquely identify controls + * @result Returns truen on success + */ + virtual bool init(bool initialValue, + UInt32 channelID, + const char *channelName = 0, + UInt32 cntrlID = 0, + UInt32 subType = 0, + UInt32 usage = 0, + OSDictionary *properties = 0); + +}; + +#endif /* _IOKIT_IOAUDIOTOGGLECONTROL_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/audio/IOAudioEngineUserClient.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/audio/IOAudioEngineUserClient.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/audio/IOAudioEngineUserClient.h (revision 885) @@ -0,0 +1,270 @@ +/* + * Copyright (c) 1998-2010 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_IOAUDIOENGINEUSERCLIENT_H +#define _IOKIT_IOAUDIOENGINEUSERCLIENT_H + +#include +#ifndef IOAUDIOFAMILY_SELF_BUILD +#include +#include +#else +#include "IOAudioEngine.h" +#include "IOAudioTypes.h" +#endif +#include + +class IOAudioEngine; +class IOAudioStream; +class IOMemoryDescriptor; +class IOCommandGate; +class IOWorkLoop; + +class IOAudioEngineUserClient; +class IOAudioClientBufferSet; +typedef struct IOAudioFormatNotification; +typedef struct IOAudioClientBuffer { + IOAudioEngineUserClient *userClient; + IOAudioStream *audioStream; + void *sourceBuffer; + IOMemoryDescriptor *sourceBufferDescriptor; + IOMemoryMap *sourceBufferMap; + void *unmappedSourceBuffer; + UInt32 numSampleFrames; + UInt32 numChannels; + IOAudioEnginePosition mixedPosition; + struct IOAudioClientBuffer *mNextBuffer32; + struct IOAudioClientBuffer *nextClip; + struct IOAudioClientBuffer *previousClip; + struct IOAudioClientBuffer *nextClient; + IOAudioBufferDataDescriptor *bufferDataDescriptor; +} IOAudioClientBuffer; + +/* IOAudioClientBuffer64 added for binary compatibility with old PPC drivers covered by */ +typedef struct IOAudioClientBuffer64 +{ + IOAudioClientBuffer mAudioClientBuffer32; + mach_vm_address_t mUnmappedSourceBuffer64; + struct IOAudioClientBuffer64 *mNextBuffer64; +} IOAudioClientBuffer64; + +typedef struct IOAudioClientBufferExtendedInfo { + // Added stuff for registerClientParameterBuffer + UInt32 bufferSetID; + void *paramBuffer; + IOMemoryDescriptor *paramBufferDescriptor; + IOMemoryMap *paramBufferMap; + void *unmappedParamBuffer; + struct IOAudioClientBufferExtendedInfo *mNextExtended; +} IOAudioClientBufferExtendedInfo; +/* IOAudioClientBufferExtendedInfo64 added for binary compatibility with old PPC drivers covered by */ +typedef struct IOAudioClientBufferExtendedInfo64 +{ + IOAudioClientBufferExtendedInfo mAudioClientBufferExtended32; + mach_vm_address_t mUnmappedParamBuffer64; + struct IOAudioClientBufferExtendedInfo64 *mNextExtended64; +} IOAudioClientBufferExtendedInfo64; + + +class IOAudioEngineUserClient : public IOUserClient + { + OSDeclareDefaultStructors(IOAudioEngineUserClient) + + friend class IOAudioEngine; + friend class IOAudioClientBufferSet; + friend class IOAudioStream; + + protected: + IOAudioEngine *audioEngine; + + IOWorkLoop *workLoop; + IOCommandGate *commandGate; + + IOExternalMethod old_methods[5]; // It's size can't be changed for binary compatibility reasons, no longer used. + IOExternalTrap trap; + + task_t clientTask; + UInt32 numSampleFrames; // Never used... + + IOAudioClientBufferSet *clientBufferSetList; + IORecursiveLock *clientBufferLock; + + IOAudioNotificationMessage *notificationMessage; + + bool online; + + protected: + struct ExpansionData { + IOAudioClientBufferExtendedInfo64 *extendedInfo; + IOExternalMethod methods[kIOAudioEngineNumCalls]; // This size can be changed, this is the new methods pointer + UInt32 classicMode; + }; + + ExpansionData *reserved; + + public: + virtual IOReturn externalMethod( uint32_t selector, IOExternalMethodArguments * arguments, IOExternalMethodDispatch * dispatch, + OSObject * target, void * reference); + // New code added here... + // OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 0); + virtual IOReturn registerClientParameterBuffer (void * parameterBuffer, UInt32 bufferSetID); // unused function + // OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 1); + virtual IOAudioClientBufferExtendedInfo * findExtendedInfo(UInt32 bufferSetID); + // OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 2); + virtual IOReturn getNearestStartTime(IOAudioStream *audioStream, IOAudioTimeStamp *ioTimeStamp, UInt32 isInput); + // OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 3); + virtual IOReturn getClientNearestStartTime(IOAudioStream *audioStream, IOAudioTimeStamp *ioTimeStamp, UInt32 isInput); + // OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 4); + virtual IOReturn safeRegisterClientBuffer(UInt32 audioStreamIndex, void * sourceBuffer, UInt32 bufSizeInBytes, UInt32 bufferSetID); + // OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 5); + virtual bool initWithAudioEngine(IOAudioEngine *engine, task_t task, void *securityToken, UInt32 type, OSDictionary *properties); + // OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 6); + virtual IOReturn safeRegisterClientBuffer64(UInt32 audioStreamIndex, mach_vm_address_t * sourceBuffer, UInt32 bufSizeInBytes, UInt32 bufferSetID); + // OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 7); + virtual IOReturn registerClientBuffer64(IOAudioStream *audioStream, mach_vm_address_t sourceBuffer, UInt32 bufSizeInBytes, UInt32 bufferSetID); + // OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 8); + virtual IOReturn registerBuffer64(IOAudioStream *audioStream, mach_vm_address_t sourceBuffer, UInt32 bufSizeInBytes, UInt32 bufferSetID); + // OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 9); + virtual IOReturn unregisterBuffer64(mach_vm_address_t sourceBuffer, UInt32 bufferSetID); + // OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 10); + virtual IOReturn unregisterClientBuffer64(mach_vm_address_t * sourceBuffer, UInt32 bufferSetID); + // OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 11); + virtual IOAudioClientBufferExtendedInfo64 * findExtendedInfo64(UInt32 bufferSetID); + + + + private: + OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 0); + OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 1); + OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 2); + OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 3); + OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 4); + OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 5); + OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 6); + OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 7); + OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 8); + OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 9); + OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 10); + OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 11); + + + OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 12); + OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 13); + OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 14); + OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 15); + OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 16); + OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 17); + OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 18); + OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 19); + OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 20); + OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 21); + OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 22); + OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 23); + OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 24); + OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 25); + OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 26); + OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 27); + OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 28); + OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 29); + OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 30); + OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 31); + + protected: + virtual IOReturn clientClose(); + virtual IOReturn clientDied(); + + static IOReturn _closeClientAction(OSObject *target, void *arg0, void *arg1, void *arg2, void *arg3); // + static IOReturn closeClientAction(OSObject *owner, void *arg1, void *arg2, void *arg3, void *arg4); + virtual IOReturn closeClient(); + + + virtual IOReturn clientMemoryForType(UInt32 type, UInt32 *flags, IOMemoryDescriptor **memory); + virtual IOExternalMethod *getExternalMethodForIndex(UInt32 index); + virtual IOExternalTrap *getExternalTrapForIndex(UInt32 index); + virtual IOReturn registerNotificationPort(mach_port_t port, UInt32 type, UInt32 refCon); + + static IOReturn _registerNotificationAction(OSObject *target, void *arg0, void *arg1, void *arg2, void *arg3); // + static IOReturn registerNotificationAction(OSObject *owner, void *arg1, void *arg2, void *arg3, void *arg4); + virtual IOReturn registerNotification(mach_port_t port, UInt32 refCon); + + virtual void setOnline(bool newOnline); + + virtual IOReturn performClientOutput(UInt32 firstSampleFrame, UInt32 loopCount, IOAudioClientBufferSet *bufferSet, UInt32 sampleIntervalHi, UInt32 sampleIntervalLo); + virtual IOReturn performClientInput(UInt32 firstSampleFrame, IOAudioClientBufferSet *bufferSet); + virtual void performWatchdogOutput(IOAudioClientBufferSet *clientBufferSet, UInt32 generationCount); + + virtual void lockBuffers(); + virtual void unlockBuffers(); + + public: + + static IOAudioEngineUserClient *withAudioEngine(IOAudioEngine *engine, task_t clientTask, void *securityToken, UInt32 type); + static IOAudioEngineUserClient *withAudioEngine(IOAudioEngine *engine, task_t clientTask, void *securityToken, UInt32 type, OSDictionary *properties); + + virtual bool initWithAudioEngine(IOAudioEngine *engine, task_t task, void *securityToken, UInt32 type); + + virtual void free(); + virtual void freeClientBufferSetList(); + virtual void freeClientBuffer(IOAudioClientBuffer64 *clientBuffer); + + virtual void stop(IOService *provider); + + virtual bool isOnline(); + + virtual IOReturn registerBuffer(IOAudioStream *audioStream, void* sourceBuffer, UInt32 bufSizeInBytes, UInt32 bufferSetID); + virtual IOReturn unregisterBuffer( void * sourceBuffer, UInt32 bufferSetID); + + static IOReturn _registerBufferAction(OSObject *target, void *arg0, void *arg1, void *arg2, void *arg3); // + static IOReturn registerBufferAction(OSObject *owner, void *arg1, void *arg2, void *arg3, void *arg4); + static IOReturn _unregisterBufferAction(OSObject *target, void *arg0, void *arg1, void *arg2, void *arg3); // + static IOReturn unregisterBufferAction(OSObject *owner, void *arg1, void *arg2, void *arg3, void *arg4); + + virtual IOReturn registerClientBuffer(IOAudioStream *audioStream, void * sourceBuffer, UInt32 bufSizeInBytes, UInt32 bufferSetID); + virtual IOReturn unregisterClientBuffer(void * sourceBuffer, UInt32 bufferSetID); + + static IOReturn _getNearestStartTimeAction(OSObject *target, void *arg0, void *arg1, void *arg2, void *arg3); // + static IOReturn getNearestStartTimeAction(OSObject *owner, void *arg1, void *arg2, void *arg3, void *arg4); + + virtual IOAudioClientBufferSet *findBufferSet(UInt32 bufferSetID); + virtual void removeBufferSet(IOAudioClientBufferSet *bufferSet); + + virtual IOReturn getConnectionID(UInt32 *connectionID); + + virtual IOReturn clientStart(); + virtual IOReturn clientStop(); + + static IOReturn _startClientAction(OSObject *target, void *arg0, void *arg1, void *arg2, void *arg3); // + static IOReturn startClientAction(OSObject *owner, void *arg1, void *arg2, void *arg3, void *arg4); + static IOReturn _stopClientAction(OSObject *target, void *arg0, void *arg1, void *arg2, void *arg3); // + static IOReturn stopClientAction(OSObject *owner, void *arg1, void *arg2, void *arg3, void *arg4); + + virtual IOReturn startClient(); + virtual IOReturn stopClient(); + + virtual IOReturn performClientIO(UInt32 firstSampleFrame, UInt32 loopCount, bool inputIO, UInt32 bufferSetID, UInt32 sampleIntervalHi, UInt32 sampleIntervalLo); + + virtual void sendFormatChangeNotification(IOAudioStream *audioStream); + virtual IOReturn sendNotification(UInt32 notificationType); + + }; + +#endif /* _IOKIT_IOAUDIOENGINEUSERCLIENT_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/audio/IOAudioPort.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/audio/IOAudioPort.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/audio/IOAudioPort.h (revision 885) @@ -0,0 +1,184 @@ +/* + * 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_IOAUDIOPORT_H +#define _IOKIT_IOAUDIOPORT_H + +#include + +class IOAudioDevice; +class IOAudioControl; +class OSDictionary; + +/*! + * @class IOAudioPort + * @abstract Represents a logical or physical port or functional unit in an audio device. + * @discussion An IOAudioPort represents an element in the signal chain in the audio device. It may contain + * one or more controls (represented by IOAudioControl) by which different attributes of the port may be + * represented and adjusted. + * + * IOAudioPort objects are connected up in the IORegistry in the IOAudioPlane to represent the signal chain of + * the device. They may be connected to other IOAudioPorts as well as IOAudioEngines to indicate they either + * feed into or are fed by one of the audio engines (i.e. they provide input to or take output from the computer). + */ +class IOAudioPort : public IOService +{ + friend class IOAudioDevice; + + OSDeclareDefaultStructors(IOAudioPort) + +public: + /* @var audioDevice The IOAudioDevice that this IOAudioPort belongs to. */ + IOAudioDevice * audioDevice; + /* @var audioControls A set containg all of the IOAudioControl instances that belong to the port. */ + OSSet * audioControls; + bool isRegistered; + +protected: + struct ExpansionData { }; + + ExpansionData *reserved; + +private: + OSMetaClassDeclareReservedUnused(IOAudioPort, 0); + OSMetaClassDeclareReservedUnused(IOAudioPort, 1); + OSMetaClassDeclareReservedUnused(IOAudioPort, 2); + OSMetaClassDeclareReservedUnused(IOAudioPort, 3); + OSMetaClassDeclareReservedUnused(IOAudioPort, 4); + OSMetaClassDeclareReservedUnused(IOAudioPort, 5); + OSMetaClassDeclareReservedUnused(IOAudioPort, 6); + OSMetaClassDeclareReservedUnused(IOAudioPort, 7); + OSMetaClassDeclareReservedUnused(IOAudioPort, 8); + OSMetaClassDeclareReservedUnused(IOAudioPort, 9); + OSMetaClassDeclareReservedUnused(IOAudioPort, 10); + OSMetaClassDeclareReservedUnused(IOAudioPort, 11); + OSMetaClassDeclareReservedUnused(IOAudioPort, 12); + OSMetaClassDeclareReservedUnused(IOAudioPort, 13); + OSMetaClassDeclareReservedUnused(IOAudioPort, 14); + OSMetaClassDeclareReservedUnused(IOAudioPort, 15); + OSMetaClassDeclareReservedUnused(IOAudioPort, 16); + OSMetaClassDeclareReservedUnused(IOAudioPort, 17); + OSMetaClassDeclareReservedUnused(IOAudioPort, 18); + OSMetaClassDeclareReservedUnused(IOAudioPort, 19); + OSMetaClassDeclareReservedUnused(IOAudioPort, 20); + OSMetaClassDeclareReservedUnused(IOAudioPort, 21); + OSMetaClassDeclareReservedUnused(IOAudioPort, 22); + OSMetaClassDeclareReservedUnused(IOAudioPort, 23); + OSMetaClassDeclareReservedUnused(IOAudioPort, 24); + OSMetaClassDeclareReservedUnused(IOAudioPort, 25); + OSMetaClassDeclareReservedUnused(IOAudioPort, 26); + OSMetaClassDeclareReservedUnused(IOAudioPort, 27); + OSMetaClassDeclareReservedUnused(IOAudioPort, 28); + OSMetaClassDeclareReservedUnused(IOAudioPort, 29); + OSMetaClassDeclareReservedUnused(IOAudioPort, 30); + OSMetaClassDeclareReservedUnused(IOAudioPort, 31); + +public: + /*! + * @function withAttributes + * @abstract Allocates a new IOAudioPort instance with the given attributes + * @discussion This static method allocates a new IOAudioPort and calls initWithAttributes() on it with + * the parameters passed in to it. + * @param portType A readable string representing the type of port. Common port types are defined in + * IOAudioTypes.h and are prefixed with 'kIOAudioPortType'. Please provide feedback if there are + * other common port types that should be included. + * @param portName A readable string representing the name of the port. For example: 'Internal Speaker', + * 'Line Out'. This field is optional, but useful for providing information to the application/user. + * @param subType Developer defined readable string representing a subtype for the port. (optional) + * @param properties Standard property list passed to the init of any new IOService. This dictionary + * gets stored in the registry for this instance. (optional) + * @result Returns the newly allocated and initialized IOAudioPort instance. + */ + static IOAudioPort *withAttributes(UInt32 portType, const char *portName = 0, UInt32 subType = 0, OSDictionary *properties = 0); + + /*! + * @function initWithAttributes + * @abstract Initializes a newly allocated IOAudioPort instance with the given attributes + * @discussion The properties parameter is passed on the superclass' init(). The portType, subType + * and properties parameters are optional, however portType is recommended. + * @param portType A readable string representing the type of port. Common port types are defined in + * IOAudioTypes.h and are prefixed with 'kIOAudioPortType'. Please provide feedback if there are + * other common port types that should be included. + * @param portName A readable string representing the name of the port. For example: 'Internal Speaker', + * 'Line Out'. This field is optional, but useful for providing information to the application/user. + * @param subType Developer defined readable string representing a subtype for the port. (optional) + * @param properties Standard property list passed to the init of any new IOService. This dictionary + * gets stored in the registry for this instance. (optional) + * @result Returns true on success. + */ + virtual bool initWithAttributes(UInt32 portType, const char *portName = 0, UInt32 subType = 0, OSDictionary *properties = 0); + + /*! + * @function free + * @abstract Frees all of the resources allocated by the IOAudioPort. + * @discussion Do not call this directly. This is called automatically by the system when the instance's + * refcount goes to 0. To decrement the refcount, call release() on the object. + */ + virtual void free(); + + /*! + * @function start + * @abstract Called to start a newly created IOAudioPort. + * @discussion This is called automatically by IOAudioDevice when attachAudioPort() is called. + * @param provider The IOAudioDevice that owns this port + * @result Returns true on success + */ + virtual bool start(IOService *provider); + + /*! + * @function stop + * @abstract Called when the IOAudioDevice is stopping when it is no longer available. + * @discussion This method calls deactivateAudioControls() to shut down all of the controls associated with + * this port. + * @param provider The IOAudioDevice that owns this port + */ + virtual void stop(IOService *provider); + + virtual void registerService(IOOptionBits options = 0); + + virtual IOAudioDevice *getAudioDevice(); + + /*! + * @function addAudioControl + * @abstract Adds a newly created IOAudioControl instance to the port. + * @discussion This method is responsible for starting the new IOAudioControl and adding it to the internal + * audioControls array. + * @param control A newly created IOAudioControl instance that should belong to this port. + * @result Returns true on successfully staring the IOAudioControl. + */ + virtual IOReturn addAudioControl(IOAudioControl *control); + + /*! + * @function deactivateAudioControls + * @abstract Called to shut down all of the audio controls for this port. + * @discussion This will stop all of the audio controls and release them so that the instances may be + * freed. This is called from the free() method. + */ + virtual void deactivateAudioControls(); + +protected: + virtual void setType(UInt32 portType); + virtual void setSubType(UInt32 subType); + virtual void setName(const char *name); +}; + +#endif /* _IOKIT_IOAUDIOPORT_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/audio/IOAudioTypes.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/audio/IOAudioTypes.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/audio/IOAudioTypes.h (revision 885) @@ -0,0 +1,661 @@ +/* + * Copyright (c) 1998-2010 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_IOAUDIOTYPES_H +#define _IOKIT_IOAUDIOTYPES_H + +#include +#include +#include + + +/*! + * @enum IOAudioEngineMemory + * @abstract Used to identify the type of memory requested by a client process to be mapped into its process space + * @discussion This is the parameter to the type field of IOMapMemory when called on an IOAudioEngine. This is + * only intended for use by the Audio Device API library. + * @constant kIOAudioSampleBuffer This requests the IOAudioEngine's sample buffer + * @constant kIOAudioStatusBuffer This requests the IOAudioEngine's status buffer. It's type is IOAudioEngineStatus. + * @constant kIOAudioMixBuffer This requests the IOAudioEngine's mix buffer +*/ +typedef enum _IOAudioEngineMemory { + kIOAudioStatusBuffer = 0, + kIOAudioSampleBuffer = 1, + kIOAudioMixBuffer = 2, + kIOAudioBytesInInputBuffer = 3, + kIOAudioBytesInOutputBuffer = 4 +} IOAudioEngineMemory; + +/*! + * @enum IOAudioEngineCalls + * @abstract The set of constants passed to IOAudioEngineUserClient::getExternalMethodForIndex() when making calls + * from the IOAudioFamily user client code. + */ +typedef enum _IOAudioEngineCalls { + kIOAudioEngineCallRegisterClientBuffer = 0, + kIOAudioEngineCallUnregisterClientBuffer = 1, + kIOAudioEngineCallGetConnectionID = 2, + kIOAudioEngineCallStart = 3, + kIOAudioEngineCallStop = 4, + kIOAudioEngineCallGetNearestStartTime = 5 +} IOAudioEngineCalls; + +/*! @defined kIOAudioEngineNumCalls The number of elements in the IOAudioEngineCalls enum. */ +#define kIOAudioEngineNumCalls 6 + +typedef enum _IOAudioEngineTraps { + kIOAudioEngineTrapPerformClientIO = 0 +} IOAudioEngineTraps; + +typedef enum _IOAudioEngineNotifications { + kIOAudioEngineAllNotifications = 0, + kIOAudioEngineStreamFormatChangeNotification = 1, + kIOAudioEngineChangeNotification = 2, + kIOAudioEngineStartedNotification = 3, + kIOAudioEngineStoppedNotification = 4, + kIOAudioEnginePausedNotification = 5, + kIOAudioEngineResumedNotification = 6 +} IOAudioEngineNotifications; + +/*! + * @enum IOAudioEngineState + * @abstract Represents the state of an IOAudioEngine + * @constant kIOAudioEngineRunning The IOAudioEngine is currently running - it is transferring data to or + * from the device. + * @constant kIOAudioEngineStopped The IOAudioEngine is currently stopped - no activity is occurring. + */ + +typedef enum _IOAudioEngineState { + kIOAudioEngineStopped = 0, + kIOAudioEngineRunning = 1, + kIOAudioEnginePaused = 2, + kIOAudioEngineResumed = 3 +} IOAudioEngineState; + + +/*! + * @typedef IOAudioEngineStatus + * @abstract Shared-memory structure giving audio engine status + * @discussion + * @field fVersion Indicates version of this structure + * @field fCurrentLoopCount Number of times around the ring buffer since the audio engine started + * @field fLastLoopTime Timestamp of the last time the ring buffer wrapped + * @field fEraseHeadSampleFrame Location of the erase head in sample frames - erased up to but not + * including the given sample frame + */ + +typedef struct _IOAudioEngineStatus { + UInt32 fVersion; + volatile UInt32 fCurrentLoopCount; + volatile AbsoluteTime fLastLoopTime; + volatile UInt32 fEraseHeadSampleFrame; +} IOAudioEngineStatus; + +#define kIOAudioEngineCurrentStatusStructVersion 2 + +typedef struct _IOAudioStreamFormat { + UInt32 fNumChannels; + UInt32 fSampleFormat; + UInt32 fNumericRepresentation; + UInt8 fBitDepth; + UInt8 fBitWidth; + UInt8 fAlignment; + UInt8 fByteOrder; + UInt8 fIsMixable; + UInt32 fDriverTag; +} IOAudioStreamFormat; + +#define kFormatExtensionInvalidVersion 0 +#define kFormatExtensionCurrentVersion 1 + +typedef struct _IOAudioStreamFormatExtension { + UInt32 fVersion; + UInt32 fFlags; + UInt32 fFramesPerPacket; + UInt32 fBytesPerPacket; +} IOAudioStreamFormatExtension; + +typedef struct _IOAudioBufferDataDescriptor { + UInt32 fActualDataByteSize; + UInt32 fActualNumSampleFrames; + UInt32 fTotalDataByteSize; + UInt32 fNominalDataByteSize; + UInt8 fData[1]; +} IOAudioBufferDataDescriptor; + +#define kStreamDataDescriptorInvalidVersion 0 +#define kStreamDataDescriptorCurrentVersion 1 + +typedef struct _IOAudioStreamDataDescriptor { + UInt32 fVersion; + UInt32 fNumberOfStreams; + UInt32 fStreamLength[1]; // Array with fNumberOfStreams number of entries +} IOAudioStreamDataDescriptor; + +typedef struct _IOAudioSampleIntervalDescriptor { + UInt32 sampleIntervalHi; + UInt32 sampleIntervalLo; +} IOAudioSampleIntervalDescriptor; + +/*! + @struct SMPTETime + @abstract A structure for holding a SMPTE time. + @field fSubframes + The number of subframes in the full message. + @field fSubframeDivisor + The number of subframes per frame (typically 80). + @field fCounter + The total number of messages received. + @field fType + The kind of SMPTE time using the SMPTE time type constants. + @field fFlags + A set of flags that indicate the SMPTE state. + @field fHours + The number of hourse in the full message. + @field fMinutes + The number of minutes in the full message. + @field fSeconds + The number of seconds in the full message. + @field fFrames + The number of frames in the full message. +*/ +typedef struct _IOAudioSMPTETime +{ + SInt16 fSubframes; + SInt16 fSubframeDivisor; + UInt32 fCounter; + UInt32 fType; + UInt32 fFlags; + SInt16 fHours; + SInt16 fMinutes; + SInt16 fSeconds; + SInt16 fFrames; + +} IOAudioSMPTETime; + +// constants describing SMPTE types (taken from the MTC spec) +enum +{ + kIOAudioSMPTETimeType24 = 0, + kIOAudioSMPTETimeType25 = 1, + kIOAudioSMPTETimeType30Drop = 2, + kIOAudioSMPTETimeType30 = 3, + kIOAudioSMPTETimeType2997 = 4, + kIOAudioSMPTETimeType2997Drop = 5 +}; + +// flags describing a SMPTE time stamp +enum +{ + kIOAudioSMPTETimeValid = (1L << 0), // the full time is valid + kIOAudioSMPTETimeRunning = (1L << 1) // time is running +}; + +// A struct for encapsulating the parts of a time stamp. The flags +// say which fields are valid. +typedef struct _IOAudioTimeStamp +{ + UInt64 fSampleTime; // the absolute sample time, was a Float64 + UInt64 fHostTime; // the host's root timebase's time + UInt64 fRateScalar; // the system rate scalar, was a Float64 + UInt64 fWordClockTime; // the word clock time + IOAudioSMPTETime fSMPTETime; // the SMPTE time + UInt32 fFlags; // the flags indicate which fields are valid + UInt32 fReserved; // reserved, pads the structure out to force 8 byte alignment +} IOAudioTimeStamp; + +// flags for the AudioTimeStamp sturcture +enum +{ + kIOAudioTimeStampSampleTimeValid = (1L << 0), + kIOAudioTimeStampHostTimeValid = (1L << 1), + kIOAudioTimeStampRateScalarValid = (1L << 2), + kIOAudioTimeStampWordClockTimeValid = (1L << 3), + kIOAudioTimeStampSMPTETimeValid = (1L << 4) +}; + +// Some commonly used combinations of timestamp flags +enum +{ + kIOAudioTimeStampSampleHostTimeValid = (kIOAudioTimeStampSampleTimeValid | kIOAudioTimeStampHostTimeValid) +}; + +/*! +* @enum IOAudioStreamDirection + * @abstract Represents the direction of an IOAudioStream + * @constant kIOAudioStreamDirectionOutput Output buffer + * @constant kIOAudioStreamDirectionInput Input buffer + */ + +typedef enum _IOAudioStreamDirection { + kIOAudioStreamDirectionOutput = 0, + kIOAudioStreamDirectionInput = 1 +} IOAudioStreamDirection; + +enum { + kIOAudioDeviceCanBeDefaultNothing = 0, + kIOAudioDeviceCanBeDefaultInput = (1L << 0), + kIOAudioDeviceCanBeDefaultOutput = (1L << 1), + kIOAudioDeviceCanBeSystemOutput = (1L << 2) +}; + +/*! + * @defined kIOAudioEngineDefaultMixBufferSampleSize + */ + +#define kIOAudioEngineDefaultMixBufferSampleSize sizeof(float) + +/* The following are for use only by the IOKit.framework audio family code */ + +/*! + * @enum IOAudioControlCalls + * @abstract The set of constants passed to IOAudioControlUserClient::getExternalMethodForIndex() when making calls + * from the IOAudioFamily user client code. + * @constant kIOAudioControlCallSetValue Used to set the value of an IOAudioControl. + * @constant kIOAudioControlCallGetValue Used to get the value of an IOAudioControl. + */ +typedef enum _IOAudioControlCalls { + kIOAudioControlCallSetValue = 0, + kIOAudioControlCallGetValue = 1 +} IOAudioControlCalls; + +/*! @defined kIOAudioControlNumCalls The number of elements in the IOAudioControlCalls enum. */ +#define kIOAudioControlNumCalls 2 + +/*! + * @enum IOAudioControlNotifications + * @abstract The set of constants passed in the type field of IOAudioControlUserClient::registerNotificaitonPort(). + * @constant kIOAudioControlValueChangeNotification Used to request value change notifications. + * @constant kIOAudioControlRangeChangeNotification Used to request range change notifications. + */ +typedef enum _IOAudioControlNotifications { + kIOAudioControlValueChangeNotification = 0, + kIOAudioControlRangeChangeNotification = 1 +} IOAudioControlNotifications; + +/*! + * @struct IOAudioNotificationMessage + * @abstract Used in the mach message for IOAudio notifications. + * @field messageHeader Standard mach message header + * @field ref The param passed to registerNotificationPort() in refCon. + */ +typedef struct _IOAudioNotificationMessage { + mach_msg_header_t messageHeader; + UInt32 type; + UInt32 ref; + void * sender; +} IOAudioNotificationMessage; + +typedef struct _IOAudioSampleRate { + UInt32 whole; + UInt32 fraction; +} IOAudioSampleRate; + +#define kNoIdleAudioPowerDown 0xffffffffffffffffULL + +enum { + kIOAudioPortTypeOutput = 'outp', + kIOAudioPortTypeInput = 'inpt', + kIOAudioPortTypeMixer = 'mixr', + kIOAudioPortTypePassThru = 'pass', + kIOAudioPortTypeProcessing = 'proc' +}; + +enum { + kIOAudioOutputPortSubTypeInternalSpeaker = 'ispk', + kIOAudioOutputPortSubTypeExternalSpeaker = 'espk', + kIOAudioOutputPortSubTypeHeadphones = 'hdpn', + kIOAudioOutputPortSubTypeLine = 'line', + kIOAudioOutputPortSubTypeSPDIF = 'spdf', + + kIOAudioInputPortSubTypeInternalMicrophone = 'imic', + kIOAudioInputPortSubTypeExternalMicrophone = 'emic', + kIOAudioInputPortSubTypeCD = 'cd ', + kIOAudioInputPortSubTypeLine = 'line', + kIOAudioInputPortSubTypeSPDIF = 'spdf' +}; + +enum { + kIOAudioControlTypeLevel = 'levl', + kIOAudioControlTypeToggle = 'togl', + kIOAudioControlTypeJack = 'jack', + kIOAudioControlTypeSelector = 'slct' +}; + +enum { + kIOAudioLevelControlSubTypeVolume = 'vlme', + kIOAudioLevelControlSubTypeLFEVolume = 'subv', + kIOAudioLevelControlSubTypePRAMVolume = 'pram', + kIOAudioToggleControlSubTypeMute = 'mute', + kIOAudioToggleControlSubTypeSolo = 'solo', + kIOAudioToggleControlSubTypeLFEMute = 'subm', + kIOAudioToggleControlSubTypeiSubAttach = 'atch', + kIOAudioSelectorControlSubTypeOutput = 'outp', + kIOAudioSelectorControlSubTypeInput = 'inpt', + kIOAudioSelectorControlSubTypeClockSource = 'clck', + kIOAudioSelectorControlSubTypeDestination = 'dest', + kIOAudioSelectorControlSubTypeChannelNominalLineLevel = 'nlev', + kIOAudioSelectorControlSubTypeChannelLevelPlus4dBu = '4dbu', + kIOAudioSelectorControlSubTypeChannelLevelMinus10dBV = '10db', + kIOAudioSelectorControlSubTypeChannelLevelMinus20dBV = '20db', + kIOAudioSelectorControlSubTypeChannelLevelMicLevel = 'micl', + kIOAudioSelectorControlSubTypeChannelLevelInstrumentLevel = 'istl' +}; + +enum { + kIOAudioControlUsageOutput = 'outp', + kIOAudioControlUsageInput = 'inpt', + kIOAudioControlUsagePassThru = 'pass', + kIOAudioControlUsageCoreAudioProperty = 'prop' +}; + +enum { + kIOAudioControlChannelNumberInactive = -1, + kIOAudioControlChannelIDAll = 0, + kIOAudioControlChannelIDDefaultLeft = 1, + kIOAudioControlChannelIDDefaultRight = 2, + kIOAudioControlChannelIDDefaultCenter = 3, + kIOAudioControlChannelIDDefaultLeftRear = 4, + kIOAudioControlChannelIDDefaultRightRear = 5, + kIOAudioControlChannelIDDefaultSub = 6, + kIOAudioControlChannelIDDefaultFrontLeftCenter = 7, + kIOAudioControlChannelIDDefaultFrontRightCenter = 8, + kIOAudioControlChannelIDDefaultRearCenter = 9, + kIOAudioControlChannelIDDefaultSurroundLeft = 10, + kIOAudioControlChannelIDDefaultSurroundRight = 11 +}; + +enum { + kIOAudioSelectorControlSelectionValueNone = 'none', + + // Output-specific selection IDs + kIOAudioSelectorControlSelectionValueInternalSpeaker = 'ispk', + kIOAudioSelectorControlSelectionValueExternalSpeaker = 'espk', + kIOAudioSelectorControlSelectionValueHeadphones = 'hdpn', + + // Input-specific selection IDs + kIOAudioSelectorControlSelectionValueInternalMicrophone = 'imic', + kIOAudioSelectorControlSelectionValueExternalMicrophone = 'emic', + kIOAudioSelectorControlSelectionValueCD = 'cd ', + + // Common selection IDs + kIOAudioSelectorControlSelectionValueLine = 'line', + kIOAudioSelectorControlSelectionValueSPDIF = 'spdf' +}; + +enum { + kIOAudioStreamSampleFormatLinearPCM = 'lpcm', + kIOAudioStreamSampleFormatIEEEFloat = 'ieee', + kIOAudioStreamSampleFormatALaw = 'alaw', + kIOAudioStreamSampleFormatMuLaw = 'ulaw', + kIOAudioStreamSampleFormatMPEG = 'mpeg', + kIOAudioStreamSampleFormatAC3 = 'ac-3', + kIOAudioStreamSampleFormat1937AC3 = 'cac3', + kIOAudioStreamSampleFormat1937MPEG1 = 'mpg1', + kIOAudioStreamSampleFormat1937MPEG2 = 'mpg2', + kIOAudioStreamSampleFormatTimeCode = 'time' // a stream of IOAudioTimeStamp structures that capture any incoming time code information +}; + +enum { + kIOAudioStreamNumericRepresentationSignedInt = 'sint', + kIOAudioStreamNumericRepresentationUnsignedInt = 'uint', + kIOAudioStreamNumericRepresentationIEEE754Float = 'flot' +}; + +enum { + kIOAudioClockSelectorTypeInternal = 'int ', + kIOAudioClockSelectorTypeExternal = 'ext ', + kIOAudioClockSelectorTypeAESEBU = 'asbu', + kIOAudioClockSelectorTypeTOSLink = 'tosl', + kIOAudioClockSelectorTypeSPDIF = 'spdf', + kIOAudioClockSelectorTypeADATOptical = 'adto', + kIOAudioClockSelectorTypeADAT9Pin = 'adt9', + kIOAudioClockSelectorTypeSMPTE = 'smpt', + kIOAudioClockSelectorTypeVideo = 'vdeo', + kIOAudioClockSelectorTypeControl = 'cnrl', + kIOAudioClockSelectorTypeOther = 'othr', +}; + +enum { + kIOAudioStreamAlignmentLowByte = 0, + kIOAudioStreamAlignmentHighByte = 1 +}; + +enum { + kIOAudioStreamByteOrderBigEndian = 0, + kIOAudioStreamByteOrderLittleEndian = 1 +}; + +enum { + kIOAudioLevelControlNegativeInfinity = 0xffffffff +}; + +enum { + kIOAudioNewClockDomain = 0xffffffff +}; + +// Device connection types +#ifndef __OPEN_SOURCE__ +// Added kIOAudioDeviceTransportTypeDisplayPort +#endif +enum { + kIOAudioDeviceTransportTypeBuiltIn = 'bltn', + kIOAudioDeviceTransportTypePCI = 'pci ', + kIOAudioDeviceTransportTypeUSB = 'usb ', + kIOAudioDeviceTransportTypeFireWire = '1394', + kIOAudioDeviceTransportTypeNetwork = 'ntwk', + kIOAudioDeviceTransportTypeWireless = 'wrls', + kIOAudioDeviceTransportTypeOther = 'othr', + kIOAudioDeviceTransportTypeBluetooth = 'blue', + kIOAudioDeviceTransportTypeVirtual = 'virt', + kIOAudioDeviceTransportTypeDisplayPort = 'dprt', + kIOAudioDeviceTransportTypeHdmi = 'hdmi' + +}; + +// types that go nowhere +enum { + OUTPUT_NULL = 0x0100, + INPUT_NULL = 0x0101 +}; + +// Input terminal types +enum { + INPUT_UNDEFINED = 0x0200, + INPUT_MICROPHONE = 0x0201, + INPUT_DESKTOP_MICROPHONE = 0x0202, + INPUT_PERSONAL_MICROPHONE = 0x0203, + INPUT_OMNIDIRECTIONAL_MICROPHONE = 0x0204, + INPUT_MICROPHONE_ARRAY = 0x0205, + INPUT_PROCESSING_MICROPHONE_ARRAY = 0x0206, + INPUT_MODEM_AUDIO = 0x207 +}; + +// Output terminal types +enum { + OUTPUT_UNDEFINED = 0x0300, + OUTPUT_SPEAKER = 0x0301, + OUTPUT_HEADPHONES = 0x0302, + OUTPUT_HEAD_MOUNTED_DISPLAY_AUDIO = 0x0303, + OUTPUT_DESKTOP_SPEAKER = 0x0304, + OUTPUT_ROOM_SPEAKER = 0x0305, + OUTPUT_COMMUNICATION_SPEAKER = 0x0306, + OUTPUT_LOW_FREQUENCY_EFFECTS_SPEAKER = 0x0307 +}; + +// Bi-directional terminal types +enum { + BIDIRECTIONAL_UNDEFINED = 0x0400, + BIDIRECTIONAL_HANDSET = 0x0401, + BIDIRECTIONAL_HEADSET = 0x0402, + BIDIRECTIONAL_SPEAKERPHONE_NO_ECHO_REDX = 0x0403, + BIDIRECTIONAL_ECHO_SUPPRESSING_SPEAKERPHONE = 0x0404, + BIDIRECTIONAL_ECHO_CANCELING_SPEAKERPHONE = 0x0405 +}; + +// Telephony terminal types +enum { + TELEPHONY_UNDEFINED = 0x0500, + TELEPHONY_PHONE_LINE = 0x0501, + TELEPHONY_TELEPHONE = 0x0502, + TELEPHONY_DOWN_LINE_PHONE = 0x0503 +}; + +// External terminal types +enum { + EXTERNAL_UNDEFINED = 0x0600, + EXTERNAL_ANALOG_CONNECTOR = 0x0601, + EXTERNAL_DIGITAL_AUDIO_INTERFACE = 0x0602, + EXTERNAL_LINE_CONNECTOR = 0x0603, + EXTERNAL_LEGACY_AUDIO_CONNECTOR = 0x0604, + EXTERNAL_SPDIF_INTERFACE = 0x0605, + EXTERNAL_1394_DA_STREAM = 0x0606, + EXTERNAL_1394_DV_STREAM_SOUNDTRACK = 0x0607, + EXTERNAL_ADAT = 0x0608, + EXTERNAL_TDIF = 0x0609, + EXTERNAL_MADI = 0x060A +}; + +// Embedded terminal types +enum { + EMBEDDED_UNDEFINED = 0x0700, + EMBEDDED_LEVEL_CALIBRATION_NOISE_SOURCE = 0x0701, + EMBEDDED_EQUALIZATION_NOISE = 0x0702, + EMBEDDED_CD_PLAYER = 0x0703, + EMBEDDED_DAT = 0x0704, + EMBEDDED_DCC = 0x0705, + EMBEDDED_MINIDISK = 0x0706, + EMBEDDED_ANALOG_TAPE = 0x0707, + EMBEDDED_PHONOGRAPH = 0x0708, + EMBEDDED_VCR_AUDIO = 0x0709, + EMBEDDED_VIDEO_DISC_AUDIO = 0x070A, + EMBEDDED_DVD_AUDIO = 0x070B, + EMBEDDED_TV_TUNER_AUDIO = 0x070C, + EMBEDDED_SATELLITE_RECEIVER_AUDIO = 0x070D, + EMBEDDED_CABLE_TUNER_AUDIO = 0x070E, + EMBEDDED_DSS_AUDIO = 0x070F, + EMBEDDED_RADIO_RECEIVER = 0x0710, + EMBEDDED_RADIO_TRANSMITTER = 0x0711, + EMBEDDED_MULTITRACK_RECORDER = 0x0712, + EMBEDDED_SYNTHESIZER = 0x0713 +}; + +// Processing terminal types +enum { + PROCESSOR_UNDEFINED = 0x0800, + PROCESSOR_GENERAL = 0x0801 +}; + +// Channel spatial position types + +#ifndef __OPEN_SOURCE__ +// NOTE: the following are derived from CoreAudioTypes.h +#endif + +#define kIOAudioChannelLabel_Discrete_field_ba 16 +enum { + kIOAudioChannelLabel_Unknown = 0xFFFFFFFF, // unknown or unspecified other use + kIOAudioChannelLabel_Unused = 0, // channel is present, but has no intended use or destination + kIOAudioChannelLabel_UseCoordinates = 100, // channel is described by the mCoordinates fields. + + kIOAudioChannelLabel_Left = 1, + kIOAudioChannelLabel_Right = 2, + kIOAudioChannelLabel_Center = 3, + kIOAudioChannelLabel_LFEScreen = 4, + kIOAudioChannelLabel_LeftSurround = 5, // WAVE: "Back Left" + kIOAudioChannelLabel_RightSurround = 6, // WAVE: "Back Right" + kIOAudioChannelLabel_LeftCenter = 7, + kIOAudioChannelLabel_RightCenter = 8, + kIOAudioChannelLabel_CenterSurround = 9, // WAVE: "Back Center" or plain "Rear Surround" + kIOAudioChannelLabel_LeftSurroundDirect = 10, // WAVE: "Side Left" + kIOAudioChannelLabel_RightSurroundDirect = 11, // WAVE: "Side Right" + kIOAudioChannelLabel_TopCenterSurround = 12, + kIOAudioChannelLabel_VerticalHeightLeft = 13, // WAVE: "Top Front Left" + kIOAudioChannelLabel_VerticalHeightCenter = 14, // WAVE: "Top Front Center" + kIOAudioChannelLabel_VerticalHeightRight = 15, // WAVE: "Top Front Right" + + kIOAudioChannelLabel_TopBackLeft = 16, + kIOAudioChannelLabel_TopBackCenter = 17, + kIOAudioChannelLabel_TopBackRight = 18, + + kIOAudioChannelLabel_RearSurroundLeft = 33, + kIOAudioChannelLabel_RearSurroundRight = 34, + kIOAudioChannelLabel_LeftWide = 35, + kIOAudioChannelLabel_RightWide = 36, + kIOAudioChannelLabel_LFE2 = 37, + kIOAudioChannelLabel_LeftTotal = 38, // matrix encoded 4 channels + kIOAudioChannelLabel_RightTotal = 39, // matrix encoded 4 channels + kIOAudioChannelLabel_HearingImpaired = 40, + kIOAudioChannelLabel_Narration = 41, + kIOAudioChannelLabel_Mono = 42, + kIOAudioChannelLabel_DialogCentricMix = 43, + + kIOAudioChannelLabel_CenterSurroundDirect = 44, // back center, non diffuse + + kIOAudioChannelLabel_Haptic = 45, + + // first order ambisonic channels + kIOAudioChannelLabel_Ambisonic_W = 200, + kIOAudioChannelLabel_Ambisonic_X = 201, + kIOAudioChannelLabel_Ambisonic_Y = 202, + kIOAudioChannelLabel_Ambisonic_Z = 203, + + // Mid/Side Recording + kIOAudioChannelLabel_MS_Mid = 204, + kIOAudioChannelLabel_MS_Side = 205, + + // X-Y Recording + kIOAudioChannelLabel_XY_X = 206, + kIOAudioChannelLabel_XY_Y = 207, + + // other + kIOAudioChannelLabel_HeadphonesLeft = 301, + kIOAudioChannelLabel_HeadphonesRight = 302, + kIOAudioChannelLabel_ClickTrack = 304, + kIOAudioChannelLabel_ForeignLanguage = 305, + + // generic discrete channel + kIOAudioChannelLabel_Discrete = 400, + + // numbered discrete channel + kIOAudioChannelLabel_Discrete_0 = ( 1 << kIOAudioChannelLabel_Discrete_field_ba ) | 0, + kIOAudioChannelLabel_Discrete_1 = ( 1 << kIOAudioChannelLabel_Discrete_field_ba ) | 1, + kIOAudioChannelLabel_Discrete_2 = ( 1 << kIOAudioChannelLabel_Discrete_field_ba ) | 2, + kIOAudioChannelLabel_Discrete_3 = ( 1 << kIOAudioChannelLabel_Discrete_field_ba ) | 3, + kIOAudioChannelLabel_Discrete_4 = ( 1 << kIOAudioChannelLabel_Discrete_field_ba ) | 4, + kIOAudioChannelLabel_Discrete_5 = ( 1 << kIOAudioChannelLabel_Discrete_field_ba ) | 5, + kIOAudioChannelLabel_Discrete_6 = ( 1 << kIOAudioChannelLabel_Discrete_field_ba ) | 6, + kIOAudioChannelLabel_Discrete_7 = ( 1 << kIOAudioChannelLabel_Discrete_field_ba ) | 7, + kIOAudioChannelLabel_Discrete_8 = ( 1 << kIOAudioChannelLabel_Discrete_field_ba ) | 8, + kIOAudioChannelLabel_Discrete_9 = ( 1 << kIOAudioChannelLabel_Discrete_field_ba ) | 9, + kIOAudioChannelLabel_Discrete_10 = ( 1 << kIOAudioChannelLabel_Discrete_field_ba ) | 10, + kIOAudioChannelLabel_Discrete_11 = ( 1 << kIOAudioChannelLabel_Discrete_field_ba ) | 11, + kIOAudioChannelLabel_Discrete_12 = ( 1 << kIOAudioChannelLabel_Discrete_field_ba ) | 12, + kIOAudioChannelLabel_Discrete_13 = ( 1 << kIOAudioChannelLabel_Discrete_field_ba ) | 13, + kIOAudioChannelLabel_Discrete_14 = ( 1 << kIOAudioChannelLabel_Discrete_field_ba ) | 14, + kIOAudioChannelLabel_Discrete_15 = ( 1 << kIOAudioChannelLabel_Discrete_field_ba ) | 15, + kIOAudioChannelLabel_Discrete_65535 = ( 1 << kIOAudioChannelLabel_Discrete_field_ba ) | 65535 +}; + + + +#endif /* _IOKIT_IOAUDIOTYPES_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/audio/IOAudioEngine.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/audio/IOAudioEngine.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/audio/IOAudioEngine.h (revision 885) @@ -0,0 +1,865 @@ +/* + * Copyright (c) 1998-2010 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 IOAudioEngine + */ + +#ifndef _IOKIT_IOAUDIOENGINE_H +#define _IOKIT_IOAUDIOENGINE_H + +#include + +#ifndef IOAUDIOFAMILY_SELF_BUILD +#include +#else +#include "IOAudioTypes.h" +#endif +#include + +class OSDictionary; +class OSCollection; +class OSOrderedSet; +class IOAudioEngineUserClient; +class IOAudioDevice; +class IOAudioStream; +class IOAudioControl; +class IOCommandGate; + +#define IOAUDIOENGINE_DEFAULT_NUM_ERASES_PER_BUFFER 4 + +/*! + * @typedef IOAudioEnginePosition + * @abstract Represents a position in an audio audio engine. + * @discussion This position is based on the sample frame within a + * loop around the sample buffer, and the loop count which starts at 0 when the audio engine + * begins playback. + * @field fSampleFrame The sample frame within the buffer - starts at 0. + * @field fLoopCount The number of times the ring buffer has looped. + */ +typedef struct { + UInt32 fSampleFrame; + UInt32 fLoopCount; +} IOAudioEnginePosition; + +#define CMP_IOAUDIOENGINEPOSITION(p1, p2) \ + (((p1)->fLoopCount > (p2)->fLoopCount) ? 1 : \ + ((p1)->fLoopCount == (p2)->fLoopCount) && ((p1)->fSampleFrame > (p2)->fSampleFrame) ? 1 : \ + ((p1)->fLoopCount == (p2)->fLoopCount) && ((p1)->fSampleFrame == (p2)->fSampleFrame) ? 0 : -1) + +#define IOAUDIOENGINEPOSITION_IS_ZERO(p1) (((p1)->fLoopCount == 0) && ((p1)->fSampleFrame == 0)) + +/*! + * @class IOAudioEngine + * @abstract Abstract base class for a single audio audio / I/O engine. + * @discussion An IOAudioEngine is defined by a single I/O engine to transfer data to + * or from one or more sample buffers. Each sample buffer is represented by a single IOAudioStream + * instance. A single IOAudioEngine must contain at least one IOAudioStream, but has no upper + * limit on the number of IOAudioStreams it may contain. An IOAudioEngine instance may contain + * both input and output IOAudioStreams. + * + * An audio driver must subclass IOAudioEngine in order to provide certain services. An + * IOAudioEngine subclass must start and stop the I/O engine when requested. The I/O + * engine should be continuously running and loop around from end to beginning. While the audio + * engine is running, it must take a timestamp as the sample buffer(s) wrap around and start at + * the beginning. The CoreAudio.framework uses the timestamp to calculate the exact position of + * the audio engine. An IOAudioEngine subclass must implement getCurrentSampleFrame() to provide + * a sample position on demand. Finally, an IOAudioEngine subclass must provide clipping and + * format conversion routines to go to/from the CoreAudio.framework's native float format. + * + * If multiple stream formats or sample rates are allowed, the IOAudioEngine + * subclass must provide support for changing the hardware when a format or sample rate is + * changed. + * + * There are several attributes associated with a single IOAudioEngine: + * + * The IOAudioEngine superclass provides a shared status buffer that contains all of the dynamic pieces + * of information about the audio engine (type IOAudioEngineStatus). It runs an erase process on + * all of the output streams. The erase head is used to zero out the mix and sample buffers after + * the samples have been played. Additionally, the IOAudioEngine superclass handles the + * communication with the CoreAudio.framework and makes the decision to start and stop the + * audio engine when it detects it is in use. + * + * In order for an audio device to play back or record sound, an IOAudioEngine subclass must be created. + * The subclass must initialize all of the necessary hardware resources to prepare for starting the + * audio I/O engine. It typically will perform these tasks in the initHardware() method. A subclass + * may also implement a stop() method which is called as the driver is being torn down. This is + * typically called in preparation of removing the device from the system for removable devices. + * + * In addition to initializing the necessary hardware, there are a number of other tasks an + * IOAudioEngine must do during initHardware(). It must create the necessary IOAudioStream objects + * to match the device capabilities. Each IOAudioStream must be added using addAudioStream(). It + * also should create the IOAudioControls needed to control the various attributes of the audio engine: + * output volume, mute, input gain, input selection, analog passthru. To do that, addDefaultAudioControl() + * should be called with each IOAudioControl to be attached to the IOAudioEngine. In order to provide + * for proper synchronization, the latency of the audio engine should be specified with setSampleLatency(). + * This value represents the latency between the timestamp taken at the beginning of the buffer and + * when the audio is actually played (or recorded) by the device. If a device is block based or if + * there is a need to keep the CoreAudio.framework a certain number of samples ahead of (or behind for + * input) the I/O head, that value should be specified using setSampleOffset(). If this is not specified + * the CoreAudio.framework may attempt to get as close to the I/O head as possible. + * + * The following fields in the shared IOAudioEngineStatus struct must be maintained by the subclass + * implementation: + *
+ *    fCurrentLoopCount - the number of times the sample buffer has wrapped around to the beginning
+ *    fLastLoopTime - timestamp of the most recent time that the I/O engine looped back to the 
+ *  beginning of the sample buffer
+ *  
+ * It is critically important that the fLastLoopTime field be as accurate as possible. It is + * the basis for the entire timer and synchronization mechanism used by the audio system. + * + * At init time, the IOAudioEngine subclass must call setNumSampleFramesPerBuffer() to indicate how large + * each of the sample buffers are (measured in sample frames). Within a single IOAudioEngine, all sample + * buffers must be the same size and be running at the same sample rate. If different buffers/streams can + * be run at different rates, separate IOAudioEngines should be used. The IOAudioEngine subclass must + * also call setSampleRate() at init time to indicate the starting sample rate of the device. + * + */ + +class IOAudioEngine : public IOService +{ + OSDeclareAbstractStructors(IOAudioEngine) + + friend class IOAudioEngineUserClient; + friend class IOAudioDevice; + friend class IOAudioStream; + +public: + /*! @var gSampleRateWholeNumberKey */ + static const OSSymbol *gSampleRateWholeNumberKey; + /*! @var gSampleRateFractionKey */ + static const OSSymbol *gSampleRateFractionKey; + + /*! @var numSampleFramesPerBuffer */ + UInt32 numSampleFramesPerBuffer; + + /*! @var sampleRate + * The current sample rate of the audio engine in samples per second. */ + IOAudioSampleRate sampleRate; + + /*! @var numErasesPerBuffer + * The number of times the erase head get scheduled to run for each + * cycle of the audio engine. */ + UInt32 numErasesPerBuffer; + /*! @var runEraseHead + * Set to true if the erase head is to run when the audio engine is running. This is the case if there are any output streams. */ + bool runEraseHead; + + /*! @var audioEngineStopPosition + * When all clients have disconnected, this is set to one buffer length past the + * current audio engine position at the time. Then when the stop position is reached, the audio engine + * is stopped */ + IOAudioEnginePosition audioEngineStopPosition; + + /*! @var isRegistered + * Internal state variable to keep track or whether registerService() has been called. */ + bool isRegistered; + /*! @var configurationChangeInProgress + * Set to true after beginConfigurationChange() and false upon a + * subsequent call to completeConfigurationChange() or cancelConfigurationChange(). */ + bool configurationChangeInProgress; + + /*! @var state + * The current state of the IOAudioEngine - running, stopped, paused. */ + IOAudioEngineState state; + + /*! @var status + * Status struct shared with the CoreAudio.framework. */ + IOAudioEngineStatus * status; + + /*! @var audioDevice + * The IOAudioDevice instance to which the IOAudioEngine belongs. */ + IOAudioDevice * audioDevice; + + /*! @var workLoop + * The IOWorkLoop for the audio driver - shared with the IOAudioDevice. */ + IOWorkLoop *workLoop; + /*! @var commandGate + * The IOCommandGate for this audio engine - attached to the driver's IOWorkLoop. */ + IOCommandGate *commandGate; + + /*! @var inputStreams + * An OSSet of all of the input IOAudioStreams attached to this IOAudioEngine. */ + OSOrderedSet *inputStreams; + UInt32 maxNumInputChannels; + /*! @var outputStreams + * An OSSet of all of the output IOAudioStreams attached to this IOAudioEngine. */ + OSOrderedSet *outputStreams; + UInt32 maxNumOutputChannels; + /*! @var userClients + * An OSSet of all of the currently connected user clients. */ + OSSet *userClients; + /*! @var defaultAudioControls + * All of the IOAudioControls that affect this audio engine. */ + OSSet *defaultAudioControls; + + /*! @var numActiveUserClients + * A total of the active user clients - those that are currently playing or + * recording audio. */ + UInt32 numActiveUserClients; + UInt32 sampleOffset; // used for input and output if inputSampleOffset is not set, if inputSampleOffset is set used as output only + + UInt32 index; + bool duringStartup; + +protected: + + /*! + * @var deviceStartedAudioEngine + * Used by the IOAudioDevice to determine responsibility for shutting + * the audio engine down when it is no longer needed. + */ + bool deviceStartedAudioEngine; + +protected: + struct ExpansionData { + UInt32 pauseCount; + IOBufferMemoryDescriptor *statusDescriptor; + IOBufferMemoryDescriptor *bytesInInputBufferArrayDescriptor; + IOBufferMemoryDescriptor *bytesInOutputBufferArrayDescriptor; + UInt32 mixClipOverhead; + OSArray *streams; + UInt32 inputSampleOffset; + }; + + ExpansionData *reserved; + +// static UInt32 sInstanceCount; + +public: + // OSMetaClassDeclareReservedUsed(IOAudioEngine, 0); + virtual IOReturn performFormatChange(IOAudioStream *audioStream, const IOAudioStreamFormat *newFormat, const IOAudioStreamFormatExtension *formatExtension, const IOAudioSampleRate *newSampleRate); + // OSMetaClassDeclareReservedUsed(IOAudioEngine, 1); + virtual IOBufferMemoryDescriptor * getStatusDescriptor(); + // OSMetaClassDeclareReservedUsed(IOAudioEngine, 2); + virtual IOReturn getNearestStartTime(IOAudioStream *audioStream, IOAudioTimeStamp *ioTimeStamp, bool isInput); + // OSMetaClassDeclareReservedUsed(IOAudioEngine, 3); + virtual IOBufferMemoryDescriptor * getBytesInInputBufferArrayDescriptor(); + // OSMetaClassDeclareReservedUsed(IOAudioEngine, 4); + virtual IOBufferMemoryDescriptor * getBytesInOutputBufferArrayDescriptor(); + // OSMetaClassDeclareReservedUsed(IOAudioEngine, 5); + /*! + * @function eraseOutputSamples + * @abstract This function allows for the actual erasing of the mix and sample buffer to be overridden by + * a child class. + * @param mixBuf Pointer to the IOAudioFamily allocated mix buffer. + * @param sampleBuf Pointer to the child class' sample buffer. + * @param firstSampleFrame Index to the first sample frame to erase. + * @param numSampleFrames Number of sample frames to erase. + * @param streamFormat Format of the data to be erased. + * @param audioStream Pointer to stream object that corresponds to the sample buffer being erased. + * @result Must return kIOReturnSuccess if the samples have been erased. + */ + virtual IOReturn eraseOutputSamples(const void *mixBuf, void *sampleBuf, UInt32 firstSampleFrame, UInt32 numSampleFrames, const IOAudioStreamFormat *streamFormat, IOAudioStream *audioStream); + // OSMetaClassDeclareReservedUsed(IOAudioEngine, 6); + /*! + * @function setClockIsStable + * @abstract This function sets a flag that CoreAudio uses to select its sample rate tracking algorithm. Set + * this to TRUE unless that results in dropped audio. If the driver is experiencing unexplained dropouts + * setting this FALSE might help. + * @param clockIsStable TRUE tells CoreAudio to use an agressive PLL to quickly lock to the engine's sample rate + * while FALSE tells CoreAudio to adjust more slowly to perceived sample rate changes that might just be the + * result of an unstable clock. + */ + virtual void setClockIsStable(bool clockIsStable); + + // OSMetaClassDeclareReservedUsed(IOAudioEngine, 7); + /*! + * @function setMixClipOverhead + * @abstract Used to tell IOAudioFamily when the watchdog timer must fire by. + * @discussion setMixClipOverhead allows an audio engine to tell IOAudioFamily how much time + * an engine will take to mix and clip its samples, in percent. + * The default value is 10, meaning 10%. This will cause IOAudioFamily to make + * the watchdog timer fire when there is just over 10% of the time to complete + * a buffer set left (e.g. 51 samples when the HAL is using a buffer size of 512 + * samples). + * @param newMixClipOverhead How much time per buffer should be made available for the + * mix and clip routines to run. Valid values are 1 through 99, inclusive. + * @result return no error + */ + virtual void setMixClipOverhead(UInt32 newMixClipOverhead); + + // OSMetaClassDeclareReservedUsed(IOAudioEngine, 8); + /*! + * @function setClockDomain + * @abstract Sets a property that CoreAudio uses to determine how devices are synchronized. If an audio device can tell that it is + * synchronized to another engine, it should set this value to that engine's clock domain. If an audio device can be a clock master, it may publish + * its own clock domain for other devices to use. + * @param clockDomain is the unique ID of another engine that this engine realizes it is synchronized to, use the default value kIOAudioNewClockDomain + * to have IOAudioEngine create a unique clock domain. + */ + virtual void setClockDomain(UInt32 clockDomain = kIOAudioNewClockDomain); + + // OSMetaClassDeclareReservedUsed(IOAudioEngine, 9); + /*! + * @function convertInputSamplesVBR + * @abstract Override this method if you want to return a different number of sample frames than was requested. + */ + virtual IOReturn convertInputSamplesVBR(const void *sampleBuf, void *destBuf, UInt32 firstSampleFrame, UInt32 &numSampleFrames, const IOAudioStreamFormat *streamFormat, IOAudioStream *audioStream); + + // OSMetaClassDeclareReservedUsed(IOAudioEngine, 10); + /*! + * @function setInputSampleOffset + * @abstract set the offset CoreAudio will read from off the current read pointer + * @param numSamples size of offset in sample + */ + virtual void setInputSampleOffset(UInt32 numSamples); + + // OSMetaClassDeclareReservedUsed(IOAudioEngine, 11); + /*! + * @function setOutputSampleOffset + * @abstract set the offset CoreAudio will write at off the current write pointer + * @param numSamples size of offset in sample + */ + virtual void setOutputSampleOffset(UInt32 numSamples); + +protected: + + // OSMetaClassDeclareReservedUsed(IOAudioEngine, 12); + virtual IOReturn createUserClient(task_t task, void *securityID, UInt32 type, IOAudioEngineUserClient **newUserClient, OSDictionary *properties); + +public: + + // OSMetaClassDeclareReservedUsed(IOAudioEngine, 13); + /*! + * @function setAttributeForConnection + * @abstract Generic method to set some attribute of the audio engine, specific to one connection. + * @discussion IOAudioEngine subclasses may implement this method to allow arbitrary attribute/value pairs to be set, specific to one connection. + * @param attribute Defines the attribute to be set. + * @param value The new value for the attribute. + * @result an IOReturn code. + */ + + virtual IOReturn setAttributeForConnection( SInt32 connectIndex, UInt32 attribute, uintptr_t value ); + + // OSMetaClassDeclareReservedUsed(IOAudioEngine, 14); + /*! @function getAttributeForConnection + * @abstract Generic method to retrieve some attribute of the audio engine, specific to one connection. + * @discussion IOAudioEngine subclasses may implement this method to allow arbitrary attribute/value pairs to be returned, specific to one connection. + * @param attribute Defines the attribute to be returned. Some defined attributes are:
+ * @param value Returns the value for the attribute. + * @result an IOReturn code. + */ + + virtual IOReturn getAttributeForConnection( SInt32 connectIndex, UInt32 attribute, uintptr_t * value ); + +private: + OSMetaClassDeclareReservedUsed(IOAudioEngine, 0); + OSMetaClassDeclareReservedUsed(IOAudioEngine, 1); + OSMetaClassDeclareReservedUsed(IOAudioEngine, 2); + OSMetaClassDeclareReservedUsed(IOAudioEngine, 3); + OSMetaClassDeclareReservedUsed(IOAudioEngine, 4); + OSMetaClassDeclareReservedUsed(IOAudioEngine, 5); + OSMetaClassDeclareReservedUsed(IOAudioEngine, 6); + OSMetaClassDeclareReservedUsed(IOAudioEngine, 7); + OSMetaClassDeclareReservedUsed(IOAudioEngine, 8); + OSMetaClassDeclareReservedUsed(IOAudioEngine, 9); + OSMetaClassDeclareReservedUsed(IOAudioEngine, 10); + OSMetaClassDeclareReservedUsed(IOAudioEngine, 11); + OSMetaClassDeclareReservedUsed(IOAudioEngine, 12); + OSMetaClassDeclareReservedUsed(IOAudioEngine, 13); + OSMetaClassDeclareReservedUsed(IOAudioEngine, 14); + + OSMetaClassDeclareReservedUnused(IOAudioEngine, 15); + OSMetaClassDeclareReservedUnused(IOAudioEngine, 16); + OSMetaClassDeclareReservedUnused(IOAudioEngine, 17); + OSMetaClassDeclareReservedUnused(IOAudioEngine, 18); + OSMetaClassDeclareReservedUnused(IOAudioEngine, 19); + OSMetaClassDeclareReservedUnused(IOAudioEngine, 20); + OSMetaClassDeclareReservedUnused(IOAudioEngine, 21); + OSMetaClassDeclareReservedUnused(IOAudioEngine, 22); + OSMetaClassDeclareReservedUnused(IOAudioEngine, 23); + OSMetaClassDeclareReservedUnused(IOAudioEngine, 24); + OSMetaClassDeclareReservedUnused(IOAudioEngine, 25); + OSMetaClassDeclareReservedUnused(IOAudioEngine, 26); + OSMetaClassDeclareReservedUnused(IOAudioEngine, 27); + OSMetaClassDeclareReservedUnused(IOAudioEngine, 28); + OSMetaClassDeclareReservedUnused(IOAudioEngine, 29); + OSMetaClassDeclareReservedUnused(IOAudioEngine, 30); + OSMetaClassDeclareReservedUnused(IOAudioEngine, 31); + OSMetaClassDeclareReservedUnused(IOAudioEngine, 32); + OSMetaClassDeclareReservedUnused(IOAudioEngine, 33); + OSMetaClassDeclareReservedUnused(IOAudioEngine, 34); + OSMetaClassDeclareReservedUnused(IOAudioEngine, 35); + OSMetaClassDeclareReservedUnused(IOAudioEngine, 36); + OSMetaClassDeclareReservedUnused(IOAudioEngine, 37); + OSMetaClassDeclareReservedUnused(IOAudioEngine, 38); + OSMetaClassDeclareReservedUnused(IOAudioEngine, 39); + OSMetaClassDeclareReservedUnused(IOAudioEngine, 40); + OSMetaClassDeclareReservedUnused(IOAudioEngine, 41); + OSMetaClassDeclareReservedUnused(IOAudioEngine, 42); + OSMetaClassDeclareReservedUnused(IOAudioEngine, 43); + OSMetaClassDeclareReservedUnused(IOAudioEngine, 44); + OSMetaClassDeclareReservedUnused(IOAudioEngine, 45); + OSMetaClassDeclareReservedUnused(IOAudioEngine, 46); + OSMetaClassDeclareReservedUnused(IOAudioEngine, 47); + +public: + /*! + * @function createDictionaryFromSampleRate + * @abstract Generates a dictionary matching the given sample rate. + * @discussion This is an internal routine used to generate a dictionary matching the given sample rate. It is used to generate a sample rate dictionary for the I/O Registry - used by the + * CoreAudio.framework. + * @result Returns the newly create OSDictionary. + */ + static OSDictionary *createDictionaryFromSampleRate(const IOAudioSampleRate *sampleRate, OSDictionary *rateDict = 0); + + /*! + * @function createSampleRateFromDictionary + * @abstract Generates a sample rate from an OSDictionary. + * @discussion This is an internal routine used to generate a sample rate from an OSDictionary. It is used to generate a sample rate give a new OSDictionary from the IORegistry - coming + * from the CoreAudio.framework. + * @result Returns the sample rate. + */ + static IOAudioSampleRate *createSampleRateFromDictionary(const OSDictionary *rateDict, IOAudioSampleRate *sampleRate = 0); + + /*! + * @function init + * @abstract Performs initialization of a newly allocated IOAudioEngine. + * @discussion This function is responsible for initialization of all of the general attributes of + * a new IOAudioEngine. It initializes instance variables to their default + * values and allocates the shared status buffer. Subclasses will likely want to override this method + * and do all of their common initialization in their implementation. They do need to be sure to call + * IOAudioEngine's implementation of init and pay attention to the return value. + * @param properties The default properties for the IOAudioEngine. + * @result Returns true if initialization was successful. + */ + virtual bool init(OSDictionary *properties); + + /*! + * @function free + * @abstract Frees all of the resources allocated by the IOAudioEngine. + * @discussion Do not call this directly. This is called automatically by the system when the instance's + * refcount goes to 0. To decrement the refcount, call release() on the object. + */ + virtual void free(); + + /*! + * @function getWorkLoop + * @abstract Returns the IOWorkLoop for the driver. + */ + virtual IOWorkLoop *getWorkLoop() const; + + /*! + * @function getCommandGate + * @abstract Returns the IOCommandGate for this IOAudioEngine. + */ + virtual IOCommandGate *getCommandGate() const; + + /*! + * @function start + * @abstract A simple cover function for start(IOService *, IOAudioDevice *) that assumes the provider + * is the IOAudioDevice. + * @discussion Subclasses will want to override start(IOService *, IOAudioDevice *) rather than this + * one. + * @param provider The service provider for the IOAudioEngine (the IOAudioDevice in this case). + * @result Returns true if the IOAudioEngine was successfully started. + */ + virtual bool start(IOService *provider); + + /*! + * @function start + * @abstract Standard IOKit start() routine called to start an IOService. + * @discussion This function is called in order to prepare the IOAudioEngine for use. It does NOT + * mean that the audio I/O engine itself should be started. This implementation gets the IOWorkLoop + * from the IOAudioDevice and allocates an IOCommandGate. Finally it calls initHardware() in which + * all of the subclass-specific device initialization should be done. Upon return from initHardware() + * all IOAudioStreams should be created and added to the audio engine. Also, all IOAudioControls + * for this IOAudioEngine should be created and attached. + * @param provider The service provider for the IOAudioEngine. + * @param device The IOAudioDevice to which this IOAudioEngine belongs. + * @result Returns true if the service was successfully started. + */ + virtual bool start(IOService *provider, IOAudioDevice *device); + + /*! + * @function initHardware + * @abstract This function is called by start() to provide a convenient place for the subclass to + * perform its hardware initialization. + * @discussion Upon return from this function, all IOAudioStreams and IOAudioControls should be created + * and the audio engine should be ready to be started when a client requests that playback begin. + * @function provider The service provider numb for this audio engine - typically the IOAudioDevice. + * @result Returns true if the hardware was successfully initialized. + */ + virtual bool initHardware(IOService *provider); + + /*! + * @function stop + * @abstract Stops the service and prepares for the driver to be terminated. + * @discussion This function is called before the driver is terminated and usually means that the device + * has been removed from the system. + * @param provider The service provider for the IOAudioEngine. + */ + virtual void stop(IOService *provider); + + /*! + * @function registerService + * @abstract Called when this audio engine is ready to begin vending services. + * @discussion This function is called by IOAudioDevice::activateAudioEngine() once the audio engine + * has been fully initialized and is ready to begin audio playback. + * @param options + */ + virtual void registerService(IOOptionBits options = 0); + + virtual void setAudioDevice(IOAudioDevice *device); + virtual void setIndex(UInt32 index); + + virtual void setDescription(const char *description); + + /*! + * @function newUserClient + * @abstract Requests a new user client object for this service. + * @discussion This function is called automatically by I/O Kit when a user process attempts + * to connect to this service. It allocates a new IOAudioEngineUserClient object and increments + * the number of connections for this audio engine. If this is the first user client for this IOAudioEngine, + * it calls startAudioEngine(). There is no need to call this function directly. + * A derived class that requires overriding of newUserClient should override the version with the properties + * parameter for Intel targets, and without the properties parameter for PPC targets. The #if __i386__ directive + * can be used to select between the two behaviors. + * @param task The task requesting the new user client. + * @param securityID Optional security paramater passed in by the client - ignored. + * @param type Optional user client type passed in by the client - ignored. + * @param handler The new IOUserClient * must be stored in this param on a successful completion. + * @param properties A dictionary of additional properties for the connection. + * @result Returns kIOReturnSuccess on success. May also result kIOReturnError or kIOReturnNoMemory. + */ + virtual IOReturn newUserClient(task_t task, void *securityID, UInt32 type, IOUserClient **handler); + virtual IOReturn newUserClient(task_t task, void *securityID, UInt32 type, OSDictionary *properties, IOUserClient **handler); + + /*! + * @function addAudioStream + * @abstract Adds an IOAudioStream to the audio engine. + * @discussion This function is called by the driver to add an IOAudioStream to the audio engine. This must be called at least once to make sure the audio engine has at least one IOAudioStream. + * @param stream The IOAudioStream to be added. + * @result Returns kIOReturnSuccess if the stream was successfully added. + */ + virtual IOReturn addAudioStream(IOAudioStream *stream); + + virtual IOAudioStream *getAudioStream(IOAudioStreamDirection direction, UInt32 channelID); + + virtual void lockAllStreams(); + virtual void unlockAllStreams(); + + virtual void updateChannelNumbers(); + + /*! + * @function resetStatusBuffer + * @abstract Resets the status buffer to its default values. + * @discussion This is called during startAudioEngine() and resumeAudioEngine() to clear out the status buffer + * in preparation of starting up the I/O engine. There is no need to call this directly. + */ + virtual void resetStatusBuffer(); + + /*! + * @function clearAllSampleBuffers + * @abstract Zeros out all of the sample and mix buffers associated with the IOAudioEngine + * @discussion This is called during resumeAudioEngine() since the audio engine gets started back at the + * beginning of the sample buffer. + */ + virtual void clearAllSampleBuffers(); + + /*! + * @function getCurrentSampleFrame + * @abstract Gets the current sample frame from the IOAudioEngine subclass. + * @result + */ + virtual UInt32 getCurrentSampleFrame() = 0; + + /*! + * @function startAudioEngine + * @abstract Starts the audio I/O engine. + * @discussion This method is called automatically when the audio engine is placed into use the first time. + * This must be overridden by the subclass. No call to the superclass's implementation is + * necessary. The subclass's implementation must start up the audio I/O engine. This includes any audio + * engine that needs to be started as well as any interrupts that need to be enabled. Upon successfully + * starting the engine, the subclass's implementation must call setState(kIOAudioEngineRunning). If + * it has also checked the state using getState() earlier in the implementation, the stateLock must be + * acquired for the entire initialization process (using IORecursiveLockLock(stateLock) and + * IORecursiveLockUnlock(stateLock)) to ensure that the state remains consistent. See the general class + * comments for an example. + * @result Must return kIOReturnSuccess on a successful start of the engine. + */ + virtual IOReturn startAudioEngine(); + + /*! + * @function stopAudioEngine + * @abstract Stops the audio I/O engine. + * @discussion This method is called automatically when the last client disconnects from this audio engine. + * It must be overridden by the subclass. No call to the superclass's implementation is necessary. + * The subclass's implementation must stop the audio I/O engine. The audio engine (if it exists) should + * be stopped and any interrupts disabled. Upon successfully stopping the engine, the subclass must call + * setState(kAudioEngineStopped). If it has also checked the state using getState() earlier in the + * implementation, the stateLock must be acquired for the entire initialization process (using + * IORecursiveLockLock(stateLock) and IORecursiveLockUnlock(stateLock)) to ensure that the state remains + * consistent. + * @result Must return kIOReturnSuccess on a successful stop of the engine. + */ + virtual IOReturn stopAudioEngine(); + virtual IOReturn pauseAudioEngine(); + virtual IOReturn resumeAudioEngine(); + + /*! + * @function performAudioEngineStart + * @abstract Called to start the audio I/O engine + * @discussion This method is called by startAudioEngine(). This must be overridden by the subclass. + * No call to the superclass' implementation is necessary. The subclass' implementation must start up the + * audio I/O engine. This includes any audio engine that needs to be started as well as any interrupts + * that need to be enabled. + * @result Must return kIOReturnSuccess on a successful start of the engine. + */ + virtual IOReturn performAudioEngineStart(); + + /*! + * @function performAudioEngineStop + * @abstract Called to stop the audio I/O engine + * @discussion This method is called by stopAudioEngine() and pauseAudioEngine. + * This must be overridden by the subclass. No call to the superclass' implementation is + * necessary. The subclass' implementation must stop the audio I/O engine. This includes any audio + * engine that needs to be stopped as well as any interrupts that need to be disabled. + * @result Must return kIOReturnSuccess on a successful stop of the engine. + */ + virtual IOReturn performAudioEngineStop(); + + /*! + * @function getState + * @abstract Returns the current state of the IOAudioEngine. + * @discussion If this method is called in preparation for calling setState(), the stateLock must + * be acquired before the first call to getState() and held until after the last call to setState(). + * Be careful not to return from the code acquiring the lock while the lock is being held. That + * will cause a deadlock situation. + * @result The current state of the IOAudioEngine: kIOAudioEngineRunning, kIOAudioEngineStopped. + */ + virtual IOAudioEngineState getState(); + + /*! + * @function getSampleRate + * @abstract Returns the sample rate of the IOAudioEngine in samples per second. + */ + virtual const IOAudioSampleRate *getSampleRate(); + + virtual IOReturn hardwareSampleRateChanged(const IOAudioSampleRate *sampleRate); + + /*! + * @function getRunEraseHead + * @abstract Returns true if the audio engine will run the erase head when the audio engine is running. + */ + virtual bool getRunEraseHead(); + + /*! + * @function getStatus + * @abstract Returns a pointer to the shared status buffer. + */ + virtual const IOAudioEngineStatus *getStatus(); + + /*! + * @function timerCallback + * @abstract A static method used as a callback for the IOAudioDevice timer services. + * @discussion This method implements the IOAudioDevice::TimerEvent type. + * @param arg1 The IOAudioEngine that is the target of the event. + * @param device The IOAudioDevice that sent the timer event. + */ + static void timerCallback(OSObject *arg1, IOAudioDevice *device); + + /*! + * @function timerFired + * @abstract Indicates the timer has fired. + * @discussion This method is called by timerCallback to indicate the timer has fired. This method calls performErase() and performFlush() to do erase head processing and + * audio engine flushing each time the timer event fires. + */ + virtual void timerFired(); + + /*! + * @function getTimerInterval + * @abstract Gets the timer interval for use by the timer event. + * @discussion This method is called each time the timer event is enabled through addTimer(). The default + * implementation is set to return a value such that the timer event runs n times each cycle of the audio + * engine through the sample buffer. The value n is stored as the instance variable: numErasesPerBuffer. + * The default value of numErasesPerBuffer is set to IOAUDIOENGINE_DEFAULT_NUM_ERASES_PER_BUFFER which is 4. + * A subclass may change the value of numErasesPerBuffer or override getTimerInterval. If it is overridden, + * the subclass should call the superclass's implementation, compare its interval with the superclass's and + * return the smaller of the two. + * @result Returns the interval for the timer event. + */ + virtual AbsoluteTime getTimerInterval(); + + /*! + * @function performErase + * @abstract Performs erase head processing. + * @discussion This method is called automatically each time the timer event fires and erases the sample + * buffer and mix buffer from the previous location up to the current location of the audio engine. + */ + virtual void performErase(); + + /*! + * @function performFlush + * @abstract Performs the flush operation. + * @discussion This method is called automatically each time the timer event fires. It stops the audio engine + * if there are no more clients and the audio engine is passed the latest flush ending position. + */ + virtual void performFlush(); + + virtual void stopEngineAtPosition(IOAudioEnginePosition *endingPosition); + + virtual IOReturn mixOutputSamples(const void *sourceBuf, void *mixBuf, UInt32 firstSampleFrame, UInt32 numSampleFrames, const IOAudioStreamFormat *streamFormat, IOAudioStream *audioStream); + virtual IOReturn clipOutputSamples(const void *mixBuf, void *sampleBuf, UInt32 firstSampleFrame, UInt32 numSampleFrames, const IOAudioStreamFormat *streamFormat, IOAudioStream *audioStream); + virtual void resetClipPosition(IOAudioStream *audioStream, UInt32 clipSampleFrame); + virtual IOReturn convertInputSamples(const void *sampleBuf, void *destBuf, UInt32 firstSampleFrame, UInt32 numSampleFrames, const IOAudioStreamFormat *streamFormat, IOAudioStream *audioStream); + + virtual void takeTimeStamp(bool incrementLoopCount = true, AbsoluteTime *timestamp = NULL); + virtual IOReturn getLoopCountAndTimeStamp(UInt32 *loopCount, AbsoluteTime *timestamp); + + virtual IOReturn calculateSampleTimeout(AbsoluteTime *sampleInterval, UInt32 numSampleFrames, IOAudioEnginePosition *startingPosition, AbsoluteTime *wakeupTime); + + virtual IOReturn performFormatChange(IOAudioStream *audioStream, const IOAudioStreamFormat *newFormat, const IOAudioSampleRate *newSampleRate); + + virtual void beginConfigurationChange(); + virtual void completeConfigurationChange(); + virtual void cancelConfigurationChange(); + + virtual IOReturn addDefaultAudioControl(IOAudioControl *defaultAudioControl); + virtual IOReturn removeDefaultAudioControl(IOAudioControl *defaultAudioControl); + virtual void removeAllDefaultAudioControls(); + + virtual OSString *getGlobalUniqueID(); + virtual OSString *getLocalUniqueID(); + +protected: + + /*! + * @function initKeys + * @abstract Generates the OSSymbols with the keys. + * @discussion Do not call this directly. This is an internal initialization routine. + */ + static void initKeys(); + + virtual void setNumSampleFramesPerBuffer(UInt32 numSampleFrames); + virtual UInt32 getNumSampleFramesPerBuffer(); + + /*! + * @function setState + * @abstract Indicates that the audio engine is in the specified state. + * @discussion This method simply sets the internal state of the audio engine to the specified state. It does not + * affect a change to the state. It does however keep other internal state-related attributes consistent. + * For example, it enables or disables the timer as needed when the state changes to running or stopped. + * @param newState The state the audio engine is in. + * @result Returns the old state. + */ + virtual IOAudioEngineState setState(IOAudioEngineState newState); + + /*! + * @function setSampleRate + * @abstract Records the sample rate of the audio engine. + * @discussion This method must be called during initialization of a new audio engine to record the audio engine's + * initial sample rate. It also is intended to be used to record changes to the sample rate during use. + * Currently changing sample rates after the audio engine has been started is not supported. + * It may require that the sample buffers be re-sized. This will be available in an upcoming release. + * @param newSampleRate The sample rate of the audio engine in samples per second. + */ + virtual void setSampleRate(const IOAudioSampleRate *newSampleRate); + + /*! + * @function setSampleLatency + * @abstract Sets the sample latency for the audio engine. + * @discussion The sample latency represents the number of samples ahead of the playback head + * that it is safe to write into the sample buffer. The audio device API will never write + * closer to the playback head than the number of samples specified. For input audio engines + * the number of samples is behind the record head. + */ + virtual void setSampleLatency(UInt32 numSamples); + virtual void setOutputSampleLatency(UInt32 numSamples); + virtual void setInputSampleLatency(UInt32 numSamples); + virtual void setSampleOffset(UInt32 numSamples); + + /*! + * @function setRunEraseHead + * @abstract Tells the audio engine whether or not to run the erase head. + * @discussion By default, output audio engines run the erase head and input audio engines do not. This method can + * be called after setDirection() is called in order to change the default behavior. + * @param runEraseHead The audio engine will run the erase head if this value is true. + */ + virtual void setRunEraseHead(bool runEraseHead); + + /*! + * @function clientClosed + * @abstract Called automatically when a user client closes its connection to the audio engine. + * @discussion This method decrements the number of connections to the audio engine and if they reach + * zero, the audio engine is called with a call to stopAudioEngine(). This method should not be called directly. + * @param client The user client that has disconnected. + */ + virtual void clientClosed(IOAudioEngineUserClient *client); + + /*! + * @function addTimer + * @abstract Enables the timer event for the audio engine. + * @discussion There is a timer event needed by the IOAudioEngine for processing the erase head + * and performing flushing operations. When the timer fires, the method timerFired() is ultimately + * called which in turn calls performErase() and performFlush(). This is called automatically + * to enable the timer event for this audio engine. It is called by setState() when the audio engine state + * is set to kIOAudioEngineRunning. When the timer is no longer needed, removeTimer() is called. + * There is no need to call this directly. + */ + virtual void addTimer(); + + /*! + * @function removeTimer + * @abstract Disables the timer event for the audio engine. + * @discussion This method is called automatically to disable the timer event for this audio engine. + * There is need to call it directly. This method is called by setState() when the audio engine state + * is changed from kIOAudioEngineRunning to one of the stopped states. + */ + virtual void removeTimer(); + + virtual void sendFormatChangeNotification(IOAudioStream *audioStream); + virtual void sendNotification(UInt32 notificationType); + + virtual IOReturn createUserClient(task_t task, void *securityID, UInt32 type, IOAudioEngineUserClient **newUserClient); + + static IOReturn _addUserClientAction(OSObject *target, void *arg0, void *arg1, void *arg2, void *arg3); // + static IOReturn addUserClientAction(OSObject *owner, void *arg1, void *arg2, void *arg3, void *arg4); + static IOReturn _removeUserClientAction(OSObject *target, void *arg0, void *arg1, void *arg2, void *arg3); // + static IOReturn removeUserClientAction(OSObject *owner, void *arg1, void *arg2, void *arg3, void *arg4); + static IOReturn detachUserClientsAction(OSObject *owner, void *arg1, void *arg2, void *arg3, void *arg4); + + virtual IOReturn addUserClient(IOAudioEngineUserClient *newUserClient); + virtual IOReturn removeUserClient(IOAudioEngineUserClient *userClient); + virtual IOReturn detachUserClients(); + + virtual IOReturn startClient(IOAudioEngineUserClient *userClient); + virtual IOReturn stopClient(IOAudioEngineUserClient *userClient); + + virtual IOReturn incrementActiveUserClients(); + virtual IOReturn decrementActiveUserClients(); + + virtual void detachAudioStreams(); + void setWorkLoopOnAllAudioControls(IOWorkLoop *wl); + + static inline void lockStreamForIO(IOAudioStream *stream); + static inline void unlockStreamForIO(IOAudioStream *stream); + + // These aren't virtual by design + UInt32 getNextStreamID(IOAudioStream * newStream); + IOAudioStream * getStreamForID(UInt32 streamID); + +}; + +#endif /* _IOKIT_IOAUDIOENGINE_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/audio/IOAudioDebug.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/audio/IOAudioDebug.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/audio/IOAudioDebug.h (revision 885) @@ -0,0 +1,61 @@ +/* + * Copyright (c) 1998-2010 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 _IOAUDIODEBUG_H +#define _IOAUDIODEBUG_H + +#ifdef DEBUG + #define DEBUG_LEVEL 1 + #define DEBUG_USE_FIRELOG 1 + + #ifdef DEBUG_USE_FIRELOG + #include + #define audioDebugIOLog( level, message... ) \ + do {FireLog( message ); FireLog("\n");} while (0) + + #else + #include + #define audioDebugIOLog( level, message... ) \ + do {USBLog( level, message );} while (0) + #endif + + + + #ifdef assert + #undef assert + + #define AssertionMessage( cond, file, line ) \ + "assert \"" #cond "\" failed in " #file " at line " #line + + #define AssertionFailed( cond, file, line ) \ + panic(AssertionMessage( cond, file, line )); + + #define assert( cond ) \ + if( !(cond) ) { \ + AssertionFailed( cond, __FILE__, __LINE__ ) \ + } + #endif +#else + #define audioDebugIOLog( level, message... ) ; +#endif + +#endif /* _IOAUDIODEBUG_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/audio/IOAudioLevelControl.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/audio/IOAudioLevelControl.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/audio/IOAudioLevelControl.h (revision 885) @@ -0,0 +1,205 @@ +/* + * Copyright (c) 1998-2010 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_IOAUDIOLEVELCONTROL_H +#define _IOKIT_IOAUDIOLEVELCONTROL_H + +#ifndef IOAUDIOFAMILY_SELF_BUILD +#include +#else +#include "IOAudioControl.h" +#endif + +class OSArray; + +/*! + * @class IOAudioLevelControl + * @abstract + * @discussion + */ + +class IOAudioLevelControl : public IOAudioControl +{ + OSDeclareDefaultStructors(IOAudioLevelControl) + +protected: + SInt32 minValue; + SInt32 maxValue; + IOFixed minDB; + IOFixed maxDB; + + OSArray *ranges; + +protected: + struct ExpansionData { }; + + ExpansionData *reserved; + +public: + static IOAudioLevelControl *createPassThruVolumeControl (SInt32 initialValue, + SInt32 minValue, + SInt32 maxValue, + IOFixed minDB, + IOFixed maxDB, + UInt32 channelID, + const char *channelName, + UInt32 cntrlID); + + // OSMetaClassDefineReservedUnused(IOAudioLevelControl, 0); + /*! + * @function setLinearScale + * @abstract This function tells CoreAudio if it should apply a curve to the scaler representation of the volume. + * @param useLinearScale TRUE instructs CoreAudio to not apply a curve to the scaler representation of the volume, + * FALSE instructs CoreAudio to apply a curve, which is CoreAudio's default behavior. + */ + virtual void setLinearScale(bool useLinearScale); + +private: + OSMetaClassDeclareReservedUsed(IOAudioLevelControl, 0); + + OSMetaClassDeclareReservedUnused(IOAudioLevelControl, 1); + OSMetaClassDeclareReservedUnused(IOAudioLevelControl, 2); + OSMetaClassDeclareReservedUnused(IOAudioLevelControl, 3); + OSMetaClassDeclareReservedUnused(IOAudioLevelControl, 4); + OSMetaClassDeclareReservedUnused(IOAudioLevelControl, 5); + OSMetaClassDeclareReservedUnused(IOAudioLevelControl, 6); + OSMetaClassDeclareReservedUnused(IOAudioLevelControl, 7); + OSMetaClassDeclareReservedUnused(IOAudioLevelControl, 8); + OSMetaClassDeclareReservedUnused(IOAudioLevelControl, 9); + OSMetaClassDeclareReservedUnused(IOAudioLevelControl, 10); + OSMetaClassDeclareReservedUnused(IOAudioLevelControl, 11); + OSMetaClassDeclareReservedUnused(IOAudioLevelControl, 12); + OSMetaClassDeclareReservedUnused(IOAudioLevelControl, 13); + OSMetaClassDeclareReservedUnused(IOAudioLevelControl, 14); + OSMetaClassDeclareReservedUnused(IOAudioLevelControl, 15); + +public: + /*! + * @function create + * @abstract Allocates a new level control with the given attributes + * @param initialValue The initial value of the control + * @param minValue The lowest possible value the control may have + * @param maxValue The highest possible value the control may have + * @param minDB A fixed point representation of the db value matching minValue + * @param maxDB A fixed point representation of the db value matching maxValue + * @param channelID The ID of the channel(s) that the control acts on. Common IDs are located in IOAudioTypes.h. + * @param channelName An optional name for the channel. Common names are located in IOAudioTypes.h. + * @param cntrlID An optional ID for the control that can be used to uniquely identify controls. + * @result Returns a newly allocted and initialized level IOAudioControl + */ + static IOAudioLevelControl *create(SInt32 initialValue, + SInt32 minValue, + SInt32 maxValue, + IOFixed minDB, + IOFixed maxDB, + UInt32 channelID, + const char *channelName = 0, + UInt32 cntrlID = 0, + UInt32 subType = 0, + UInt32 usage = 0); + + static IOAudioLevelControl *createVolumeControl(SInt32 initialValue, + SInt32 minValue, + SInt32 maxValue, + IOFixed minDB, + IOFixed maxDB, + UInt32 channelID, + const char *channelName = 0, + UInt32 cntrlID = 0, + UInt32 usage = 0); + + /*! + * @function init + * @abstract Initializes a newly allocated IOAudioLevelControl with the given attributes + * @param initialValue The initial value of the control + * @param minValue The lowest possible value the control may have + * @param maxValue The highest possible value the control may have + * @param minDB A fixed point representation of the db value matching minValue + * @param maxDB A fixed point representation of the db value matching maxValue + * @param channelID The ID of the channel(s) that the control acts on. Common IDs are located in IOAudioTypes.h. + * @param channelName An optional name for the channel. Common names are located in IOAudioTypes.h. + * @param cntrlID An optional ID for the control that can be used to uniquely identify controls. + * @param properties Standard property list passed to the init() function of any new IOService. This dictionary + * gets stored in the registry entry for this service. + * @result Returns true on success + */ + virtual bool init(SInt32 initialValue, + SInt32 minValue, + SInt32 maxValue, + IOFixed minDB, + IOFixed maxDB, + UInt32 channelID, + const char *channelName = 0, + UInt32 cntrlID = 0, + UInt32 subType = 0, + UInt32 usage = 0, + OSDictionary *properties = 0); + + virtual void free(); + + /*! + * @function setMinValue + * @abstract Sets the minimum value the control may have + * @param minValue The minimum value for the control + */ + virtual void setMinValue(SInt32 minValue); + + virtual SInt32 getMinValue(); + + /*! + * @function setMaxValue + * @abstract Sets the maximum value the control may have + * @param maxValue The maximum value for the control + */ + virtual void setMaxValue(SInt32 maxValue); + + virtual SInt32 getMaxValue(); + + /*! + * @function setMinDB + * @abstract Sets the minimum value in db that the control may have + * @discussion This value is represented as an IOFixed value which is a fixed point number. The IOFixed + * type is a 16.16 fixed point value. + * @param minDB The minimum value in db for the control + */ + virtual void setMinDB(IOFixed minDB); + + virtual IOFixed getMinDB(); + + /*! + * @function setMaxDB + * @abstract Sets the maximum value in db that the control may have + * @discussion This value is represented as an IOFixed value which is a fixed point number. The IOFixed + * type is a 16.16 fixed point value. + * @param maxDB The maximum value in db for the control + */ + virtual void setMaxDB(IOFixed maxDB); + + virtual IOFixed getMaxDB(); + + virtual IOReturn addRange(SInt32 minValue, SInt32 maxValue, IOFixed minDB, IOFixed maxDB); + virtual IOReturn addNegativeInfinity(SInt32 negativeInfinityValue); + + virtual IOReturn validateValue(OSObject *newValue); +}; + +#endif /* _IOKIT_IOAUDIOLEVELCONTROL_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/audio/IOAudioStream.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/audio/IOAudioStream.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/audio/IOAudioStream.h (revision 885) @@ -0,0 +1,289 @@ +/* + * Copyright (c) 1998-2010 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_IOAUDIOSTREAM_H +#define _IOKIT_IOAUDIOSTREAM_H + +#include +#ifndef IOAUDIOFAMILY_SELF_BUILD +#include +#include +#else +#include "IOAudioEngine.h" +#include "IOAudioTypes.h" +#endif + +class OSSymbol; +class OSArray; +class OSDictionary; +class OSSet; + +class IOCommandGate; +class IOAudioControl; + +typedef struct IOAudioClientBuffer; +typedef struct IOAudioStreamFormatDesc; + +/*! + * @class IOAudioStream + * @abstract This class wraps a single sample buffer in an audio driver. + * @discussion An IOAudioStream represents one hardware sample buffer as well as the direction + * of that buffer, the mix buffer that multiple clients mix into as well as a list of + * all of the formats to which this buffer can be set. + * + * When an IOAudioEngine is created during init time in the driver, an IOAudioStream must be + * created for each sample buffer in the device. Typically, the sample buffer will be interleaved + * (or single channel), as a non-interleaved buffer should be divided into multiple single-channel + * buffers (and multiple IOAudioStreams). + * + * Additionally, when an IOAudioStream is created it must have all of the possible formats (and + * allowed sample rates for each format) set and must have the currently set format specified + * (addAvailableFormat() and setFormat()). + */ + +class IOAudioStream : public IOService +{ + OSDeclareDefaultStructors(IOAudioStream) + + friend class IOAudioEngine; + friend class IOAudioEngineUserClient; + +public: + + typedef IOReturn (*AudioIOFunction)(const void *mixBuf, void *sampleBuf, UInt32 firstSampleFrame, UInt32 numSampleFrames, const IOAudioStreamFormat *streamFormat, IOAudioStream *audioStream); + + static const OSSymbol *gDirectionKey; + static const OSSymbol *gNumChannelsKey; + static const OSSymbol *gSampleFormatKey; + static const OSSymbol *gNumericRepresentationKey; + static const OSSymbol *gBitDepthKey; + static const OSSymbol *gBitWidthKey; + static const OSSymbol *gAlignmentKey; + static const OSSymbol *gByteOrderKey; + static const OSSymbol *gIsMixableKey; + static const OSSymbol *gDriverTagKey; + static const OSSymbol *gMinimumSampleRateKey; + static const OSSymbol *gMaximumSampleRateKey; + + static void initKeys(); + + static OSDictionary *createDictionaryFromFormat(const IOAudioStreamFormat *streamFormat, const IOAudioStreamFormatExtension *formatExtension, OSDictionary *formatDict = 0); + static IOAudioStreamFormat *createFormatFromDictionary(const OSDictionary *formatDict, IOAudioStreamFormat *streamFormat = 0, IOAudioStreamFormatExtension *formatExtension = 0); + + IOAudioEngine *audioEngine; + IOWorkLoop *workLoop; + IOCommandGate *commandGate; + IORecursiveLock *streamIOLock; + + UInt32 numClients; + + IOAudioStreamDirection direction; + + IOAudioStreamFormat format; + IOAudioStreamFormatDesc *availableFormats; + OSArray *availableFormatDictionaries; + UInt32 numAvailableFormats; + + UInt32 startingChannelID; + UInt32 maxNumChannels; + + void *sampleBuffer; + UInt32 sampleBufferSize; + + void *mixBuffer; + UInt32 mixBufferSize; + bool streamAllocatedMixBuffer; + + AudioIOFunction *audioIOFunctions; + UInt32 numIOFunctions; + + bool streamAvailable; + + OSSet *defaultAudioControls; + + IOAudioEnginePosition startingPosition; + IOAudioEnginePosition clippedPosition; + + IOAudioClientBuffer *clientBufferListStart; + IOAudioClientBuffer *clientBufferListEnd; + + IOAudioClientBuffer *userClientList; + +protected: + + struct ExpansionData { + IOAudioStreamFormatExtension streamFormatExtension; + UInt32 mSampleFramesReadByEngine; + IOReturn mClipOutputStatus; + }; + + ExpansionData *reserved; + +public: +// New code added here: + // OSMetaClassDeclareReservedUsed(IOAudioStream, 0); + virtual const IOAudioStreamFormatExtension *getFormatExtension(); + // OSMetaClassDeclareReservedUsed(IOAudioStream, 1); + virtual IOReturn setFormat(const IOAudioStreamFormat *streamFormat, const IOAudioStreamFormatExtension *formatExtension, bool callDriver = true); + // OSMetaClassDeclareReservedUsed(IOAudioStream, 2); + virtual IOReturn setFormat(const IOAudioStreamFormat *streamFormat, const IOAudioStreamFormatExtension *formatExtension, OSDictionary *formatDict, bool callDriver = true); + // OSMetaClassDeclareReservedUsed(IOAudioStream, 3); + virtual void addAvailableFormat(const IOAudioStreamFormat *streamFormat, const IOAudioStreamFormatExtension *formatExtension, const IOAudioSampleRate *minRate, const IOAudioSampleRate *maxRate, const AudioIOFunction *ioFunctionList = NULL, UInt32 numFunctions = 0); + // OSMetaClassDeclareReservedUsed(IOAudioStream, 4); + virtual void addAvailableFormat(const IOAudioStreamFormat *streamFormat, const IOAudioStreamFormatExtension *formatExtension, const IOAudioSampleRate *minRate, const IOAudioSampleRate *maxRate, AudioIOFunction ioFunction); + // OSMetaClassDeclareReservedUsed(IOAudioStream, 5); + virtual bool validateFormat(IOAudioStreamFormat *streamFormat, IOAudioStreamFormatExtension *formatExtension, IOAudioStreamFormatDesc *formatDesc); + // OSMetaClassDeclareReservedUsed(IOAudioStream, 6); + virtual void setTerminalType(const UInt32 terminalType); + // OSMetaClassDeclareReservedUsed(IOAudioStream, 7); + virtual IOReturn mixOutputSamples(const void *sourceBuf, void *mixBuf, UInt32 firstSampleFrame, UInt32 numSampleFrames, const IOAudioStreamFormat *streamFormat, IOAudioStream *audioStream); + // OSMetaClassDeclareReservedUsed(IOAudioStream, 8); + virtual void setSampleLatency(UInt32 numSamples); + // OSMetaClassDeclareReservedUsed(IOAudioStream, 9); + virtual bool validateFormat(IOAudioStreamFormat *streamFormat, IOAudioStreamFormatExtension *formatExtension, IOAudioStreamFormatDesc *formatDesc, const IOAudioSampleRate *sampleRate); + // OSMetaClassDeclareReservedUsed(IOAudioStream, 10); + virtual UInt32 getNumSampleFramesRead(); + // OSMetaClassDeclareReservedUsed(IOAudioStream, 11); + virtual void setDefaultNumSampleFramesRead(UInt32); + +private: + OSMetaClassDeclareReservedUsed(IOAudioStream, 0); + OSMetaClassDeclareReservedUsed(IOAudioStream, 1); + OSMetaClassDeclareReservedUsed(IOAudioStream, 2); + OSMetaClassDeclareReservedUsed(IOAudioStream, 3); + OSMetaClassDeclareReservedUsed(IOAudioStream, 4); + OSMetaClassDeclareReservedUsed(IOAudioStream, 5); + OSMetaClassDeclareReservedUsed(IOAudioStream, 6); + OSMetaClassDeclareReservedUsed(IOAudioStream, 7); + OSMetaClassDeclareReservedUsed(IOAudioStream, 8); + OSMetaClassDeclareReservedUsed(IOAudioStream, 9); + OSMetaClassDeclareReservedUsed(IOAudioStream, 10); + OSMetaClassDeclareReservedUsed(IOAudioStream, 11); + + OSMetaClassDeclareReservedUnused(IOAudioStream, 12); + OSMetaClassDeclareReservedUnused(IOAudioStream, 13); + OSMetaClassDeclareReservedUnused(IOAudioStream, 14); + OSMetaClassDeclareReservedUnused(IOAudioStream, 15); + OSMetaClassDeclareReservedUnused(IOAudioStream, 16); + OSMetaClassDeclareReservedUnused(IOAudioStream, 17); + OSMetaClassDeclareReservedUnused(IOAudioStream, 18); + OSMetaClassDeclareReservedUnused(IOAudioStream, 19); + OSMetaClassDeclareReservedUnused(IOAudioStream, 20); + OSMetaClassDeclareReservedUnused(IOAudioStream, 21); + OSMetaClassDeclareReservedUnused(IOAudioStream, 22); + OSMetaClassDeclareReservedUnused(IOAudioStream, 23); + OSMetaClassDeclareReservedUnused(IOAudioStream, 24); + OSMetaClassDeclareReservedUnused(IOAudioStream, 25); + OSMetaClassDeclareReservedUnused(IOAudioStream, 26); + OSMetaClassDeclareReservedUnused(IOAudioStream, 27); + OSMetaClassDeclareReservedUnused(IOAudioStream, 28); + OSMetaClassDeclareReservedUnused(IOAudioStream, 29); + OSMetaClassDeclareReservedUnused(IOAudioStream, 30); + OSMetaClassDeclareReservedUnused(IOAudioStream, 31); + OSMetaClassDeclareReservedUnused(IOAudioStream, 32); + OSMetaClassDeclareReservedUnused(IOAudioStream, 33); + OSMetaClassDeclareReservedUnused(IOAudioStream, 34); + OSMetaClassDeclareReservedUnused(IOAudioStream, 35); + OSMetaClassDeclareReservedUnused(IOAudioStream, 36); + OSMetaClassDeclareReservedUnused(IOAudioStream, 37); + OSMetaClassDeclareReservedUnused(IOAudioStream, 38); + OSMetaClassDeclareReservedUnused(IOAudioStream, 39); + OSMetaClassDeclareReservedUnused(IOAudioStream, 40); + OSMetaClassDeclareReservedUnused(IOAudioStream, 41); + OSMetaClassDeclareReservedUnused(IOAudioStream, 42); + OSMetaClassDeclareReservedUnused(IOAudioStream, 43); + OSMetaClassDeclareReservedUnused(IOAudioStream, 44); + OSMetaClassDeclareReservedUnused(IOAudioStream, 45); + OSMetaClassDeclareReservedUnused(IOAudioStream, 46); + OSMetaClassDeclareReservedUnused(IOAudioStream, 47); + +public: + virtual bool initWithAudioEngine(IOAudioEngine *engine, IOAudioStreamDirection dir, UInt32 startChannelID, const char *streamDescription = NULL, OSDictionary *properties = 0); + virtual void free(); + + virtual void stop(IOService *provider); + + virtual IOWorkLoop *getWorkLoop() const; + + virtual IOReturn setProperties(OSObject *properties); + + virtual IOAudioStreamDirection getDirection(); + + virtual void setSampleBuffer(void *buffer, UInt32 size); + virtual void *getSampleBuffer(); + virtual UInt32 getSampleBufferSize(); + + virtual void setMixBuffer(void *buffer, UInt32 size); + virtual void *getMixBuffer(); + virtual UInt32 getMixBufferSize(); + + virtual void numSampleFramesPerBufferChanged(); + + virtual void clearSampleBuffer(); + + virtual void setIOFunction(AudioIOFunction ioFunction); + virtual void setIOFunctionList(const AudioIOFunction *ioFunctionList, UInt32 numFunctions); + + virtual const IOAudioStreamFormat *getFormat(); + static IOReturn setFormatAction(OSObject *owner, void *arg1, void *arg2, void *arg3, void *arg4); + virtual IOReturn setFormat(const IOAudioStreamFormat *streamFormat, bool callDriver = true); + virtual IOReturn setFormat(OSDictionary *formatDict); + virtual IOReturn setFormat(const IOAudioStreamFormat *streamFormat, OSDictionary *formatDict, bool callDriver = true); + virtual IOReturn hardwareFormatChanged(const IOAudioStreamFormat *streamFormat); + virtual void addAvailableFormat(const IOAudioStreamFormat *streamFormat, const IOAudioSampleRate *minRate, const IOAudioSampleRate *maxRate, const AudioIOFunction *ioFunctionList = NULL, UInt32 numFunctions = 0); + virtual void addAvailableFormat(const IOAudioStreamFormat *streamFormat, const IOAudioSampleRate *minRate, const IOAudioSampleRate *maxRate, AudioIOFunction ioFunction); + virtual void clearAvailableFormats(); + virtual bool validateFormat(IOAudioStreamFormat *streamFormat, IOAudioStreamFormatDesc *formatDesc); + + virtual UInt32 getStartingChannelID(); + virtual UInt32 getMaxNumChannels(); + + virtual void setStreamAvailable(bool available); + virtual bool getStreamAvailable(); + + virtual IOReturn addDefaultAudioControl(IOAudioControl *defaultAudioControl); + virtual void removeDefaultAudioControls(); + +protected: + virtual void lockStreamForIO(); + virtual void unlockStreamForIO(); + + virtual void updateNumClients(); + virtual IOReturn addClient(IOAudioClientBuffer *clientBuffer); + virtual void removeClient(IOAudioClientBuffer *clientBuffer); + virtual UInt32 getNumClients(); + + virtual IOReturn processOutputSamples(IOAudioClientBuffer *clientBuffer, UInt32 firstSampleFrame, UInt32 loopCount, bool samplesAvailable); + virtual IOReturn readInputSamples(IOAudioClientBuffer *clientBuffer, UInt32 firstSampleFrame); + + virtual void resetClipInfo(); + virtual void clipIfNecessary(); + virtual void clipOutputSamples(UInt32 startingSampleFrame, UInt32 numSampleFrames); + + virtual void setStartingChannelNumber(UInt32 channelNumber); + +private: + virtual void setDirection(IOAudioStreamDirection dir); + +}; + +#endif /* _IOKIT_IOAUDIOSTREAM_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/audio/IOAudioDefines.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/audio/IOAudioDefines.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/audio/IOAudioDefines.h (revision 885) @@ -0,0 +1,465 @@ +/* + * Copyright (c) 1998-2010 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 _IOAUDIODEFINES_H +#define _IOAUDIODEFINES_H + +#define kIOAudioDeviceClassName "IOAudioDevice" +#define kIOAudioEngineClassName "IOAudioEngine" +#define kIOAudioStreamClassName "IOAudioStream" +#define kIOAudioPortClassName "IOAudioPort" +#define kIOAudioControlClassName "IOAudioControl" + +/*! + * @defined kIOAudioSampleRateKey + * @abstract The key in the IORegistry for the IOAudioEngine sample rate attribute + * @discussion This value is represented as an integer in samples per second. + */ +#define kIOAudioSampleRateKey "IOAudioSampleRate" + +#define kIOAudioSampleRateWholeNumberKey "IOAudioSampleRateWholeNumber" +#define kIOAudioSampleRateFractionKey "IOAudioSampleRateFraction" + + + +/****** + * + * IOAudioDevice defines + * + *****/ + + +/*! + * @defined kIOAudioDeviceNameKey + * @abstract The key in the IORegistry for the IOAudioDevice name attribute. + */ +#define kIOAudioDeviceNameKey "IOAudioDeviceName" + +#define kIOAudioDeviceShortNameKey "IOAudioDeviceShortName" + +/*! + * @defined kIOAudioDeviceManufacturerNameKey + * @abstract The key in the IORegistry for the IOAudioDevice manufacturer name attribute. + */ +#define kIOAudioDeviceManufacturerNameKey "IOAudioDeviceManufacturerName" + +#define kIOAudioDeviceLocalizedBundleKey "IOAudioDeviceLocalizedBundle" + +#define kIOAudioDeviceTransportTypeKey "IOAudioDeviceTransportType" + +#define kIOAudioDeviceConfigurationAppKey "IOAudioDeviceConfigurationApplication" + +#define kIOAudioDeviceCanBeDefaults "IOAudioDeviceCanBeDefaults" + +#define kIOAudioDeviceModelIDKey "IOAudioDeviceModelID" + + +/*! + * @defined kIOAudioDeviceIconName + * @abstract The key in the IORegistry for the IOAudioDevice icon name attribute. + */ +#define kIOAudioDeviceIconNameKey "IOAudioDeviceIconName" + +#define kIOAudioDeviceIconTypeKey "IOAudioDeviceIconType" + +#define kIOAudioDeviceIconSubDirKey "IOAudioDeviceIconSubDir" + +/***** + * + * IOAudioEngine defines + * + *****/ + + + /*! + * @defined kIOAudioEngineStateKey + * @abstract The key in the IORegistry for the IOAudioEngine state atrribute + * @discussion The value for this key may be one of: "Running", "Stopped" or "Paused". Currently the "Paused" + * state is unimplemented. + */ +#define kIOAudioEngineStateKey "IOAudioEngineState" + +/*! + * @defined kIOAudioEngineOutputSampleLatencyKey + * @abstract The key in the IORegistry for the IOAudioEngine output sample latency key + * @discussion + */ +#define kIOAudioEngineOutputSampleLatencyKey "IOAudioEngineOutputSampleLatency" + +/*! + * @defined kIOAudioStreamSampleLatencyKey + * @abstract The key in the IORegistry for the IOAudioStream output sample latency key + * @discussion Tells the HAL how much latency is on a particular stream. If two streams + * on the same engine have different latencies (e.g. one is analog, one is digital), then + * set this property on both streams to inform the HAL of the latency differences. Alternately, + * you can set the engine latency, and just include the latency additional to that for the particular + * stream. The HAL will add the engine and stream latency numbers together to get the total latency. + */ +#define kIOAudioStreamSampleLatencyKey "IOAudioStreamSampleLatency" + +#define kIOAudioEngineInputSampleLatencyKey "IOAudioEngineInputSampleLatency" + +#define kIOAudioEngineSampleOffsetKey "IOAudioEngineSampleOffset" + +#define kIOAudioEngineInputSampleOffsetKey "IOAudioEngineInputSampleOffset" + +#define kIOAudioEngineNumSampleFramesPerBufferKey "IOAudioEngineNumSampleFramesPerBuffer" + +#define kIOAudioEngineCoreAudioPlugInKey "IOAudioEngineCoreAudioPlugIn" + +#define kIOAudioEngineNumActiveUserClientsKey "IOAudioEngineNumActiveUserClients" + +#define kIOAudioEngineUserClientActiveKey "IOAudioEngineUserClientActive" + +#define kIOAudioEngineGlobalUniqueIDKey "IOAudioEngineGlobalUniqueID" + +#define kIOAudioEngineDescriptionKey "IOAudioEngineDescription" + +#define kIOAudioEngineClockIsStableKey "IOAudioEngineClockIsStable" + +#define kIOAudioEngineClockDomainKey "IOAudioEngineClockDomain" + +#define kIOAudioEngineIsHiddenKey "IOAudioEngineIsHidden" +/*! + * @defined kIOAudioEngineFullChannelNamesKey + * @abstract The key in the IORegistry for the IOAudioEngine's dictionary of fully constructed names for each channel keyed by the device channel + * @discussion + */ +#define kIOAudioEngineFullChannelNamesKey "IOAudioEngineChannelNames" + +/*! + * @defined kIOAudioEngineFullChannelNamesKey + * @abstract The key in the IORegistry for the IOAudioEngine's dictionary of category names for each channel keyed by the device channel + * @discussion + */ +#define kIOAudioEngineFullChannelCategoryNamesKey "IOAudioEngineChannelCategoryNames" + +/*! + * @defined kIOAudioEngineFullChannelNamesKey + * @abstract The key in the IORegistry for the IOAudioEngine's dictionary of number names for each channel keyed by the device channel + * @discussion + */ +#define kIOAudioEngineFullChannelNumberNamesKey "IOAudioEngineChannelNumberNames" + +#define kIOAudioEngineFullChannelNameKeyInputFormat "InputChannel%u" + +#define kIOAudioEngineFullChannelNameKeyOutputFormat "OutputChannel%u" + +#define kIOAudioEngineFlavorKey "IOAudioEngineFlavor" + +#define kIOAudioEngineAlwaysLoadCoreAudioPlugInKey "IOAudioEngineAlwaysLoadCoreAudioPlugIn" + +/*! + * @defined kIOAudioEngineInputChannelLayoutKey + * @abstract The key in the IORegistry for the IOAudioEngine's dictionary describes an array of OSNumber data that describe the spatial position of each channel. See IOAudioTypes.h. + * @discussion + */ + +#ifndef __OPEN_SOURCE__ +// +#endif +#define kIOAudioEngineInputChannelLayoutKey "IOAudioEngineInputChannelLayout" + +/*! + * @defined kIOAudioEngineOutputChannelLayoutKey + * @abstract The key in the IORegistry for the IOAudioEngine's dictionary describes an array of OSNumber data that describe the spatial position of each channel. See IOAudioTypes.h. + * @discussion + */ + +#ifndef __OPEN_SOURCE__ +// +#endif +#define kIOAudioEngineOutputChannelLayoutKey "IOAudioEngineOutputChannelLayout" + +/***** + * + * IOAudioStream defines + * + *****/ + + +#define kIOAudioStreamIDKey "IOAudioStreamID" +#define kIOAudioStreamDescriptionKey "IOAudioStreamDescription" +#define kIOAudioStreamNumClientsKey "IOAudioStreamNumClients" + +/*! + * @defined kIOAudioStreamDirectionKey + * @abstract The key in the IORegistry for the IOAudioStream direction attribute. + * @discussion The value for this key may be either "Output" or "Input". + */ +#define kIOAudioStreamDirectionKey "IOAudioStreamDirection" + +#define kIOAudioStreamStartingChannelIDKey "IOAudioStreamStartingChannelID" +#define kIOAudioStreamStartingChannelNumberKey "IOAudioStreamStartingChannelNumber" +#define kIOAudioStreamAvailableKey "IOAudioStreamAvailable" + +#define kIOAudioStreamFormatKey "IOAudioStreamFormat" +#define kIOAudioStreamAvailableFormatsKey "IOAudioStreamAvailableFormats" + +#define kIOAudioStreamNumChannelsKey "IOAudioStreamNumChannels" +#define kIOAudioStreamSampleFormatKey "IOAudioStreamSampleFormat" + +#define kIOAudioStreamNumericRepresentationKey "IOAudioStreamNumericRepresentation" + +#define kIOAudioStreamFormatFlagsKey "IOAudioStreamFormatFlags" +#define kIOAudioStreamFramesPerPacketKey "IOAudioStreamFramesPerPacket" +#define kIOAudioStreamBytesPerPacketKey "IOAudioStreamBytesPerPacket" + + +#define kIOAudioStreamBitDepthKey "IOAudioStreamBitDepth" +#define kIOAudioStreamBitWidthKey "IOAudioStreamBitWidth" + +#define kIOAudioStreamAlignmentKey "IOAudioStreamAlignment" + +#define kIOAudioStreamByteOrderKey "IOAudioStreamByteOrder" + +#define kIOAudioStreamIsMixableKey "IOAudioStreamIsMixable" + +#define kIOAudioStreamMinimumSampleRateKey "IOAudioStreamMinimumSampleRate" +#define kIOAudioStreamMaximumSampleRateKey "IOAudioStreamMaximumSampleRate" + +#define kIOAudioStreamDriverTagKey "IOAudioStreamDriverTag" + +#define kIOAudioStreamTerminalTypeKey "IOAudioStreamTerminalType" + +/***** + * + * IOAudioPort defines + * + *****/ + + + /*! + * @defined kIOAudioPortTypeKey + * @abstract The key in the IORegistry for the IOAudioPort type attribute. + * @discussion This is a driver-defined text attribute that may contain any type. + * Common types are defined as: "Speaker", "Headphones", "Microphone", "CD", "Line", "Digital", "Mixer", "PassThru". + */ +#define kIOAudioPortTypeKey "IOAudioPortType" + +/*! + * @defined kIOAudioPortSubTypeKey + * @abstract The key in the IORegistry for the IOAudioPort subtype attribute. + * @discussion The IOAudioPort subtype is a driver-defined text attribute designed to complement the type + * attribute. + */ +#define kIOAudioPortSubTypeKey "IOAudioPortSubType" + +/*! + * @defined kIOAudioPortNameKey + * @abstract The key in the IORegistry for the IOAudioPort name attribute. + */ +#define kIOAudioPortNameKey "IOAudioPortName" + + + +/***** + * + * IOAudioControl defines + * + *****/ + + + /*! + * @defined kIOAudioControlTypeKey + * @abstract The key in the IORegistry for the IOAudioCntrol type attribute. + * @discussion The value of this text attribute may be defined by the driver, however system-defined + * types recognized by the upper-level software are "Level", "Mute", "Selector". + */ +#define kIOAudioControlTypeKey "IOAudioControlType" + +#define kIOAudioControlSubTypeKey "IOAudioControlSubType" + +#define kIOAudioControlUsageKey "IOAudioControlUsage" + +#define kIOAudioControlIDKey "IOAudioControlID" + +/*! + * @defined kIOAudioControlChannelIDKey + * @abstract The key in the IORegistry for the IOAudioControl channel ID attribute + * @discussion The value for this key is an integer which may be driver defined. Default values for + * common channel types are provided in the following defines. + */ +#define kIOAudioControlChannelIDKey "IOAudioControlChannelID" + +#define kIOAudioControlChannelNumberKey "IOAudioControlChannelNumber" + +#define kIOAudioControlCoreAudioPropertyIDKey "IOAudioControlCoreAudioPropertyID" +/*! + * @defined kIOAudioControlChannelNameKey + * @abstract The key in the IORegistry for the IOAudioControl name attribute. + * @discussion This name should be a human-readable name for the channel(s) represented by the port. + * *** NOTE *** We really need to make all of the human-readable attributes that have potential to + * be used in a GUI localizable. There will need to be localized strings in the kext bundle matching + * the text. + */ +#define kIOAudioControlChannelNameKey "IOAudioControlChannelName" + +/*! + * @defined kIOAudioControlChannelNameAll + * @abstract The value for the kIOAudioControlChannelNameKey in the IORegistry representing + * the channel name for all channels. + */ +#define kIOAudioControlChannelNameAll "All Channels" + +/*! + * @defined kIOAudioControlChannelNameLeft + * @abstract The value for the kIOAudioControlChannelNameKey in the IORegistry representing + * the channel name for the left channel. + */ +#define kIOAudioControlChannelNameLeft "Left" + +/*! + * @defined kIOAudioControlChannelNameRight + * @abstract The value for the kIOAudioControlChannelNameKey in the IORegistry representing + * the channel name for the right channel. + */ +#define kIOAudioControlChannelNameRight "Right" + +/*! + * @defined kIOAudioControlChannelNameCenter + * @abstract The value for the kIOAudioControlChannelNameKey in the IORegistry representing + * the channel name for the center channel. + */ +#define kIOAudioControlChannelNameCenter "Center" + +/*! + * @defined kIOAudioControlChannelNameLeftRear + * @abstract The value for the kIOAudioControlChannelNameKey in the IORegistry representing + * the channel name for the left rear channel. + */ +#define kIOAudioControlChannelNameLeftRear "LeftRear" + +/*! + * @defined kIOAudioControlChannelNameRightRear + * @abstract The value for the kIOAudioControlChannelNameKey in the IORegistry representing + * the channel name for the right rear channel. + */ +#define kIOAudioControlChannelNameRightRear "RightRear" + +/*! + * @defined kIOAudioControlChannelNameSub + * @abstract The value for the kIOAudioControlChannelNameKey in the IORegistry representing + * the channel name for the sub/LFE channel. + */ +#define kIOAudioControlChannelNameSub "Sub" + +/*! + * @defined kIOAudioControlChannelNameFrontLeftCenter + * @abstract The value for the kIOAudioControlChannelNameKey in the IORegistry representing + * the channel name for the FrontLeftCenter channel. + */ +#define kIOAudioControlChannelNameFrontLeftCenter "FrontLeftCenter" + +/*! + * @defined kIOAudioControlChannelNameFrontRightCenter + * @abstract The value for the kIOAudioControlChannelNameKey in the IORegistry representing + * the channel name for the FrontRightCenter channel. + */ +#define kIOAudioControlChannelNameFrontRightCenter "FrontRightCenter" + +/*! + * @defined kIOAudioControlChannelNameRearCenter + * @abstract The value for the kIOAudioControlChannelNameKey in the IORegistry representing + * the channel name for the RearCenter channel. + */ +#define kIOAudioControlChannelNameRearCenter "RearCenter" + +/*! + * @defined kIOAudioControlChannelNameSurroundLeft + * @abstract The value for the kIOAudioControlChannelNameKey in the IORegistry representing + * the channel name for the SurroundLeft channel. + */ +#define kIOAudioControlChannelNameSurroundLeft "SurroundLeft" + +/*! + * @defined kIOAudioControlChannelNameSurroundRight + * @abstract The value for the kIOAudioControlChannelNameKey in the IORegistry representing + * the channel name for the SurroundRight channel. + */ +#define kIOAudioControlChannelNameSurroundRight "SurroundRight" + + +/*! + * @defined kIOAudioControlValueKey + * @abstract The key in the IORegistry for the IOAudioControl value attribute. + * @discussion The value returned by this key is a 32-bit integer representing the current value of the IOAudioControl. + */ +#define kIOAudioControlValueKey "IOAudioControlValue" + +/*! + * @defined kIOAudioControlValueIsReadOnlyKey + * @abstract The key in the IORegistry for the IOAudioControl value-is-read-only attribute. + * @discussion The value returned by this key is a 32-bit integer but the value doesn't have any direct meaning. + * Instead, the presence of this key indicates that the value for the control is read-only + */ +#define kIOAudioControlValueIsReadOnlyKey "IOAudioControlValueIsReadOnly" + +/*! + * @defined kIOAudioLevelControlMinValueKey + * @abstract The key in the IORegistry for the IOAudioControl minimum value attribute. + * @discussion The value returned by this key is a 32-bit integer representing the minimum value for the IOAudioControl. + * This is currently only valid for Level controls or other driver-defined controls that have a minimum and maximum + * value. + */ +#define kIOAudioLevelControlMinValueKey "IOAudioLevelControlMinValue" + +/*! + * @defined kIOAudioLevelControlMaxValueKey + * @abstract The key in the IORegistry for the IOAudioControl maximum value attribute. + * @discussion The value returned by this key is a 32-bit integer representing the maximum value for the IOAudioControl. + * This is currently only valid for Level controls or other driver-defined controls that have a minimum and maximum + * value. + */ +#define kIOAudioLevelControlMaxValueKey "IOAudioLevelControlMaxValue" + +/*! + * @defined kIOAudioLevelControlMinDBKey + * @abstract The key in the IORgistry for the IOAudioControl minimum db value attribute. + * @discussion The value returned by this key is a fixed point value in 16.16 format represented as a 32-bit + * integer. It represents the minimum value in db for the IOAudioControl. This value matches the minimum + * value attribute. This is currently valid for Level controls or other driver-defined controls that have a + * minimum and maximum db value. + */ +#define kIOAudioLevelControlMinDBKey "IOAudioLevelControlMinDB" + +/*! + * @defined kIOAudioLevelControlMaxDBKey + * @abstract The key in the IORgistry for the IOAudioControl maximum db value attribute. + * @discussion The value returned by this key is a fixed point value in 16.16 format represented as a 32-bit + * integer. It represents the maximum value in db for the IOAudioControl. This value matches the maximum + * value attribute. This is currently valid for Level controls or other driver-defined controls that have a + * minimum and maximum db value. + */ +#define kIOAudioLevelControlMaxDBKey "IOAudioLevelControlMaxDB" + +#define kIOAudioLevelControlRangesKey "IOAudioLevelControlRanges" + +#define kIOAudioLevelControlUseLinearScale "IOAudioLevelControlUseLinearScale" + +#define kIOAudioSelectorControlAvailableSelectionsKey "IOAudioSelectorControlAvailableSelections" +#define kIOAudioSelectorControlSelectionValueKey "IOAudioSelectorControlSelectionValue" +#define kIOAudioSelectorControlSelectionDescriptionKey "IOAudioSelectorControlSelectionDescriptionKey" + +#define kIOAudioSelectorControlClockSourceKey "IOAudioSelectorControlClockSourceKey" + +#endif /* _IOAUDIODEFINES_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/audio/IOAudioControlUserClient.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/audio/IOAudioControlUserClient.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/audio/IOAudioControlUserClient.h (revision 885) @@ -0,0 +1,90 @@ +/* + * Copyright (c) 1998-2010 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_IOAUDIOCONTROLUSERCLIENT_H +#define _IOKIT_IOAUDIOCONTROLUSERCLIENT_H + +#include + +#ifndef IOAUDIOFAMILY_SELF_BUILD +#include +#else +#include "IOAudioTypes.h" +#endif + +class IOAudioControl; + +class IOAudioControlUserClient : public IOUserClient +{ + OSDeclareDefaultStructors(IOAudioControlUserClient) + +protected: + task_t clientTask; + IOAudioControl * audioControl; + IOAudioNotificationMessage * notificationMessage; + + virtual IOReturn clientClose(); + virtual IOReturn clientDied(); + +protected: + struct ExpansionData { }; + + ExpansionData *reserved; + +public: + virtual void sendChangeNotification(UInt32 notificationType); + // OSMetaClassDeclareReservedUsed(IOAudioControlUserClient, 1); + virtual bool initWithAudioControl(IOAudioControl *control, task_t owningTask, void *securityID, UInt32 type, OSDictionary *properties); + +private: + OSMetaClassDeclareReservedUsed(IOAudioControlUserClient, 0); + OSMetaClassDeclareReservedUsed(IOAudioControlUserClient, 1); + + OSMetaClassDeclareReservedUnused(IOAudioControlUserClient, 2); + OSMetaClassDeclareReservedUnused(IOAudioControlUserClient, 3); + OSMetaClassDeclareReservedUnused(IOAudioControlUserClient, 4); + OSMetaClassDeclareReservedUnused(IOAudioControlUserClient, 5); + OSMetaClassDeclareReservedUnused(IOAudioControlUserClient, 6); + OSMetaClassDeclareReservedUnused(IOAudioControlUserClient, 7); + OSMetaClassDeclareReservedUnused(IOAudioControlUserClient, 8); + OSMetaClassDeclareReservedUnused(IOAudioControlUserClient, 9); + OSMetaClassDeclareReservedUnused(IOAudioControlUserClient, 10); + OSMetaClassDeclareReservedUnused(IOAudioControlUserClient, 11); + OSMetaClassDeclareReservedUnused(IOAudioControlUserClient, 12); + OSMetaClassDeclareReservedUnused(IOAudioControlUserClient, 13); + OSMetaClassDeclareReservedUnused(IOAudioControlUserClient, 14); + OSMetaClassDeclareReservedUnused(IOAudioControlUserClient, 15); + +public: + static IOAudioControlUserClient *withAudioControl(IOAudioControl *control, task_t clientTask, void *securityID, UInt32 type); + static IOAudioControlUserClient *withAudioControl(IOAudioControl *control, task_t clientTask, void *securityID, UInt32 type, OSDictionary *properties); + + virtual bool initWithAudioControl(IOAudioControl *control, task_t owningTask, void *securityID, UInt32 type); + + virtual void free(); + + virtual IOReturn registerNotificationPort(mach_port_t port, UInt32 type, UInt32 refCon); + + virtual void sendValueChangeNotification(); +}; + +#endif /* _IOKIT_IOAUDIOCONTROLUSERCLIENT_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/storage/IOBDBlockStorageDriver.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/storage/IOBDBlockStorageDriver.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/storage/IOBDBlockStorageDriver.h (revision 885) @@ -0,0 +1,152 @@ +/* + * Copyright (c) 2006-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 IOBDBlockStorageDriver + * @abstract + * This header contains the IOBDBlockStorageDriver class definition. + * @discussion + * This class implements BD 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 _IOBDBLOCKSTORAGEDRIVER_H +#define _IOBDBLOCKSTORAGEDRIVER_H + +#include +#include + +/*! + * @defined kIOBDBlockStorageDriverClass + * @abstract + * kIOBDBlockStorageDriverClass is the name of the IOBDBlockStorageDriver class. + * @discussion + * kIOBDBlockStorageDriverClass is the name of the IOBDBlockStorageDriver class. + */ + +#define kIOBDBlockStorageDriverClass "IOBDBlockStorageDriver" + +/*! + * @class + * IOBDBlockStorageDriver + * @abstract + * Generic BD Driver. + * @discussion + * Storage drivers are split into two parts: the Generic Driver handles + * all generic device issues, independent of the lower-level transport + * mechanism (e.g. SCSI, ATA, USB, FireWire). All storage operations + * at the Generic Driver level are translated into a series of generic + * device operations. These operations are passed via the Device Nub + * to a Transport Driver, which implements the appropriate + * transport-dependent protocol to execute these operations. + * + * To determine the write-protect state of a device (or media), for + * example, the generic driver would issue a call to the + * Transport Driver's reportWriteProtection method. If this were a SCSI + * device, its Transport Driver would issue a Mode Sense command to + * extract the write-protection status bit. The Transport Driver then + * reports true or false to the generic driver. + * + * The generic driver therefore has no knowledge of, or involvement + * with, the actual commands and mechanisms used to communicate with + * the device. It is expected that the generic driver will rarely, if + * ever, need to be subclassed to handle device idiosyncrasies; rather, + * the Transport Driver should be changed via overrides. + * + * A generic driver could be subclassed to create a different type of + * generic device. The generic driver IOBDBlockStorageDriver class is a subclass + * of IODVDBlockStorageDriver, adding BD functions. Similarly, the Transport Driver + * IOBDBlockStorageDevice is a subclass of IODVDBlockStorageDevice, adding BD + * functions. +*/ + +class IOBDBlockStorageDriver : public IODVDBlockStorageDriver +{ + OSDeclareDefaultStructors(IOBDBlockStorageDriver) + +protected: + + struct ExpansionData { /* */ }; + ExpansionData * _expansionData; + + /* Overrides of IODVDBlockStorageDriver. */ + + virtual IOReturn acceptNewMedia(void); + + /* End of IODVDBlockStorageDriver overrides. */ + +public: + + /* + * Obtain this object's provider. We override the superclass's method to + * return a more specific subclass of IOService -- IOBDBlockStorageDevice. + * This method serves simply as a convenience to subclass developers. + */ + + virtual IOBDBlockStorageDevice * getProvider() const; + + /* Overrides of IODVDBlockStorageDriver: */ + + virtual const char * getDeviceTypeName(void); + virtual IOMedia * instantiateDesiredMediaObject(void); + virtual IOMedia * instantiateMediaObject(UInt64 base,UInt64 byteSize, + UInt32 blockSize,char *mediaName); + virtual IOReturn readStructure(IOMemoryDescriptor *buffer,const DVDStructureFormat format, + const UInt32 address,const UInt8 layer,const UInt8 agid); + + /* End of IODVDBlockStorageDriver overrides. */ + + /*! + * @function splitTrack + * @discussion + * Issue an MMC RESERVE TRACK command with the ARSV bit. + * @param address + * As documented by MMC. + * @result + * Returns the status of the operation. + */ + + virtual IOReturn splitTrack(UInt32 address); + + OSMetaClassDeclareReservedUnused(IOBDBlockStorageDriver, 0); + OSMetaClassDeclareReservedUnused(IOBDBlockStorageDriver, 1); + OSMetaClassDeclareReservedUnused(IOBDBlockStorageDriver, 2); + OSMetaClassDeclareReservedUnused(IOBDBlockStorageDriver, 3); + OSMetaClassDeclareReservedUnused(IOBDBlockStorageDriver, 4); + OSMetaClassDeclareReservedUnused(IOBDBlockStorageDriver, 5); + OSMetaClassDeclareReservedUnused(IOBDBlockStorageDriver, 6); + OSMetaClassDeclareReservedUnused(IOBDBlockStorageDriver, 7); + OSMetaClassDeclareReservedUnused(IOBDBlockStorageDriver, 8); + OSMetaClassDeclareReservedUnused(IOBDBlockStorageDriver, 9); + OSMetaClassDeclareReservedUnused(IOBDBlockStorageDriver, 10); + OSMetaClassDeclareReservedUnused(IOBDBlockStorageDriver, 11); + OSMetaClassDeclareReservedUnused(IOBDBlockStorageDriver, 12); + OSMetaClassDeclareReservedUnused(IOBDBlockStorageDriver, 13); + OSMetaClassDeclareReservedUnused(IOBDBlockStorageDriver, 14); + OSMetaClassDeclareReservedUnused(IOBDBlockStorageDriver, 15); +}; + +#endif /* !_IOBDBLOCKSTORAGEDRIVER_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/storage/IODVDTypes.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/storage/IODVDTypes.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/storage/IODVDTypes.h (revision 885) @@ -0,0 +1,451 @@ +/* + * 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 _IODVDTYPES_H +#define _IODVDTYPES_H + +#include + +#pragma pack(push, 1) /* (enable 8-bit struct packing) */ + +/* + * Media Types + */ + +enum +{ + kDVDMediaTypeUnknown = 0x0200, + kDVDMediaTypeROM = 0x0202, /* DVD-ROM */ + kDVDMediaTypeRAM = 0x0203, /* DVD-RAM */ + kDVDMediaTypeR = 0x0204, /* DVD-R */ + kDVDMediaTypeRW = 0x0205, /* DVD-RW */ + kDVDMediaTypePlusRW = 0x0206, /* DVD+RW */ + kDVDMediaTypePlusR = 0x0207, /* DVD+R */ + kDVDMediaTypeHDROM = 0x0212, /* HD DVD-ROM */ + kDVDMediaTypeHDRAM = 0x0213, /* HD DVD-RAM */ + kDVDMediaTypeHDR = 0x0214, /* HD DVD-R */ + kDVDMediaTypeHDRW = 0x0215, /* HD DVD-RW */ + + kDVDMediaTypeMin = 0x0200, + kDVDMediaTypeMax = 0x02FF +}; + +typedef UInt32 DVDMediaType; + +/* + * Media Speed (kB/s) + */ + +#define kDVDSpeedMin 0x0546 +#define kDVDSpeedMax 0xFFFF + +/* + * MMC Formats + */ + +typedef UInt8 DVDCPRMRegionCode; +enum +{ + kDVDCPRMRegion1 = 0xFE, + kDVDCPRMRegion2 = 0xFD, + kDVDCPRMRegion3 = 0xFB, + kDVDCPRMRegion4 = 0xF7, + kDVDCPRMRegion5 = 0xEF, + kDVDCPRMRegion6 = 0xDF +}; + +typedef UInt8 DVDRegionalPlaybackControlScheme; +enum +{ + kDVDRegionalPlaybackControlSchemePhase1 = 0x00, + kDVDRegionalPlaybackControlSchemePhase2 = 0x01 +}; + +typedef UInt8 DVDBookType; +enum +{ + kDVDBookTypeROM = 0x0, + kDVDBookTypeRAM = 0x1, + kDVDBookTypeR = 0x2, + kDVDBookTypeRW = 0x3, + kDVDBookTypeHDROM = 0x4, + kDVDBookTypeHDRAM = 0x5, + kDVDBookTypeHDR = 0x6, + kDVDBookTypeHDRW = 0x7, + kDVDBookTypePlusRW = 0x9, + kDVDBookTypePlusR = 0xA, + kDVDBookTypePlusRWDoubleLayer = 0xD, + kDVDBookTypePlusRDoubleLayer = 0xE +}; + +#ifdef __LP64__ +typedef UInt8 DVDKeyClass; +enum +#else /* !__LP64__ */ +enum DVDKeyClass +#endif /* !__LP64__ */ +{ + kDVDKeyClassCSS_CPPM_CPRM = 0x00, + kDVDKeyClassRSSA = 0x01 +}; +#ifndef __LP64__ +typedef enum DVDKeyClass DVDKeyClass; +#endif /* !__LP64__ */ + +#ifdef __LP64__ +typedef UInt8 DVDKeyFormat; +enum +#else /* !__LP64__ */ +enum DVDKeyFormat +#endif /* !__LP64__ */ +{ + kDVDKeyFormatAGID_CSS = 0x00, + kDVDKeyFormatChallengeKey = 0x01, + kDVDKeyFormatKey1 = 0x02, + kDVDKeyFormatKey2 = 0x03, + kDVDKeyFormatTitleKey = 0x04, + kDVDKeyFormatASF = 0x05, + kDVDKeyFormatSetRegion = 0x06, + kDVDKeyFormatRegionState = 0x08, + kDVDKeyFormatAGID_CSS2 = 0x10, + kDVDKeyFormatAGID_CPRM = 0x11, + kDVDKeyFormatAGID_Invalidate = 0x3F +}; +#ifndef __LP64__ +typedef enum DVDKeyFormat DVDKeyFormat; +#endif /* !__LP64__ */ + +typedef UInt8 DVDStructureFormat; +enum +{ + kDVDStructureFormatPhysicalFormatInfo = 0x00, + kDVDStructureFormatCopyrightInfo = 0x01, + kDVDStructureFormatDiscKeyInfo = 0x02, + // skip BCA + kDVDStructureFormatManufacturingInfo = 0x04 +}; + +// Read DVD Structures Format 0x00 +struct DVDPhysicalFormatInfo +{ + UInt8 dataLength[2]; + UInt8 reserved[2]; +#ifdef __LITTLE_ENDIAN__ + // Byte 0 + UInt8 partVersion:4; + UInt8 bookType:4; + + // Byte 1 + UInt8 minimumRate:4; + UInt8 discSize:4; + + // Byte 2 + UInt8 layerType:4; + UInt8 trackPath:1; + UInt8 numberOfLayers:2; + UInt8 reserved2:1; + + // Byte 3 + UInt8 trackDensity:4; + UInt8 linearDensity:4; +#else /* !__LITTLE_ENDIAN__ */ + // Byte 0 + UInt8 bookType:4; + UInt8 partVersion:4; + + // Byte 1 + UInt8 discSize:4; + UInt8 minimumRate:4; + + // Byte 2 + UInt8 reserved2:1; + UInt8 numberOfLayers:2; + UInt8 trackPath:1; + UInt8 layerType:4; + + // Byte 3 + UInt8 linearDensity:4; + UInt8 trackDensity:4; +#endif /* !__LITTLE_ENDIAN__ */ + + // Bytes 4-15 + UInt8 zero1; // always 0x00 + UInt8 startingPhysicalSectorNumberOfDataArea[3]; + UInt8 zero2; // always 0x00 + UInt8 endPhysicalSectorNumberOfDataArea[3]; + UInt8 zero3; // always 0x00 + UInt8 endSectorNumberInLayerZero[3]; + + // Byte 16 +#ifdef __LITTLE_ENDIAN__ + UInt8 reserved1:7; + UInt8 bcaFlag:1; +#else /* !__LITTLE_ENDIAN__ */ + UInt8 bcaFlag:1; + UInt8 reserved1:7; +#endif /* !__LITTLE_ENDIAN__ */ + + // Bytes 17-2047 + UInt8 mediaSpecific[2031]; +}; +typedef struct DVDPhysicalFormatInfo DVDPhysicalFormatInfo; + +// Read DVD Structures Format 0x01 +struct DVDCopyrightInfo +{ + UInt8 dataLength[2]; + UInt8 reserved[2]; + UInt8 copyrightProtectionSystemType; + DVDCPRMRegionCode regionMask; + UInt8 reserved2[2]; +}; +typedef struct DVDCopyrightInfo DVDCopyrightInfo; + +// Read DVD Structures Format 0x02 +struct DVDDiscKeyInfo +{ + UInt8 dataLength[2]; + UInt8 reserved[2]; + UInt8 discKeyStructures[2048]; +}; +typedef struct DVDDiscKeyInfo DVDDiscKeyInfo; + +// Read DVD Structures Format 0x04 +struct DVDManufacturingInfo +{ + UInt8 dataLength[2]; + UInt8 reserved[2]; + UInt8 discManufacturingInfo[2048]; +}; +typedef struct DVDManufacturingInfo DVDManufacturingInfo; + +// ReportKey Format 0x00 +struct DVDAuthenticationGrantIDInfo +{ + UInt8 dataLength[2]; + UInt8 reserved[2]; + UInt8 reserved2[3]; +#ifdef __LITTLE_ENDIAN__ + UInt8 reservedBits:6; + UInt8 grantID:2; +#else /* !__LITTLE_ENDIAN__ */ + UInt8 grantID:2; + UInt8 reservedBits:6; +#endif /* !__LITTLE_ENDIAN__ */ +}; +typedef struct DVDAuthenticationGrantIDInfo DVDAuthenticationGrantIDInfo; + +// ReportKey and SendKey Format 0x01 +struct DVDChallengeKeyInfo +{ + UInt8 dataLength[2]; + UInt8 reserved[2]; + UInt8 challengeKeyValue[10]; + UInt8 reserved2[2]; +}; +typedef struct DVDChallengeKeyInfo DVDChallengeKeyInfo; + +// ReportKey Format 0x02 +struct DVDKey1Info +{ + UInt8 dataLength[2]; + UInt8 reserved[2]; + UInt8 key1Value[5]; + UInt8 reserved2[3]; +}; +typedef struct DVDKey1Info DVDKey1Info; + +// SendKey Format 0x03 +struct DVDKey2Info +{ + UInt8 dataLength[2]; + UInt8 reserved[2]; + UInt8 key2Value[5]; + UInt8 reserved2[3]; +}; +typedef struct DVDKey2Info DVDKey2Info; + +// ReportKey Format 0x04 +struct DVDTitleKeyInfo +{ + UInt8 dataLength[2]; + UInt8 reserved[2]; +#ifdef __LITTLE_ENDIAN__ + UInt8 CP_MOD:4; + UInt8 CGMS:2; + UInt8 CP_SEC:1; + UInt8 CPM:1; +#else /* !__LITTLE_ENDIAN__ */ + UInt8 CPM:1; + UInt8 CP_SEC:1; + UInt8 CGMS:2; + UInt8 CP_MOD:4; +#endif /* !__LITTLE_ENDIAN__ */ + UInt8 titleKeyValue[5]; + UInt8 reserved2[2]; +}; +typedef struct DVDTitleKeyInfo DVDTitleKeyInfo; + +// ReportKey Format 0x05 +struct DVDAuthenticationSuccessFlagInfo +{ + UInt8 dataLength[2]; + UInt8 reserved[2]; + UInt8 reserved2[3]; +#ifdef __LITTLE_ENDIAN__ + UInt8 successFlag:1; + UInt8 reservedBits:7; +#else /* !__LITTLE_ENDIAN__ */ + UInt8 reservedBits:7; + UInt8 successFlag:1; +#endif /* !__LITTLE_ENDIAN__ */ +}; +typedef struct DVDAuthenticationSuccessFlagInfo DVDAuthenticationSuccessFlagInfo; + +// ReportKey Format 0x08 +struct DVDRegionPlaybackControlInfo +{ + UInt8 dataLength[2]; + UInt8 reserved[2]; +#ifdef __LITTLE_ENDIAN__ + UInt8 numberUserResets:3; + UInt8 numberVendorResets:3; + UInt8 typeCode:2; +#else /* !__LITTLE_ENDIAN__ */ + UInt8 typeCode:2; + UInt8 numberVendorResets:3; + UInt8 numberUserResets:3; +#endif /* !__LITTLE_ENDIAN__ */ + DVDCPRMRegionCode driveRegion; + DVDRegionalPlaybackControlScheme rpcScheme; + UInt8 reserved2; +}; +typedef struct DVDRegionPlaybackControlInfo DVDRegionPlaybackControlInfo; + +// Read Disc Information Format +struct DVDDiscInfo +{ + UInt16 dataLength; +#ifdef __LITTLE_ENDIAN__ + UInt8 discStatus:2; + UInt8 stateOfLastBorder:2; + UInt8 erasable:1; + UInt8 reserved:3; +#else /* !__LITTLE_ENDIAN__ */ + UInt8 reserved:3; + UInt8 erasable:1; + UInt8 stateOfLastBorder:2; + UInt8 discStatus:2; +#endif /* !__LITTLE_ENDIAN__ */ + UInt8 reserved2; + UInt8 numberOfBordersLSB; + UInt8 firstRZoneNumberInLastBorderLSB; + UInt8 lastRZoneNumberInLastBorderLSB; +#ifdef __LITTLE_ENDIAN__ + UInt8 reserved3:5; + UInt8 unrestrictedUse:1; + UInt8 discBarCodeValid:1; + UInt8 reserved4:1; +#else /* !__LITTLE_ENDIAN__ */ + UInt8 reserved4:1; + UInt8 discBarCodeValid:1; + UInt8 unrestrictedUse:1; + UInt8 reserved3:5; +#endif /* !__LITTLE_ENDIAN__ */ + UInt8 reserved5; + UInt8 numberOfBordersMSB; + UInt8 firstRZoneNumberInLastBorderMSB; + UInt8 lastRZoneNumberInLastBorderMSB; + UInt8 reserved6[4]; + UInt8 reserved7[4]; + UInt8 reserved8[4]; + UInt8 discBarCode[8]; + UInt8 reserved9; + UInt8 numberOfOPCTableEntries; + UInt8 opcTableEntries[0]; +}; +typedef struct DVDDiscInfo DVDDiscInfo; + +// Read RZone Information Address Types +typedef UInt8 DVDRZoneInfoAddressType; +enum +{ + kDVDRZoneInfoAddressTypeLBA = 0x00, + kDVDRZoneInfoAddressTypeRZoneNumber = 0x01, + kDVDRZoneInfoAddressTypeBorderNumber = 0x02, +}; + +// Read RZone Information Format +struct DVDRZoneInfo +{ + UInt16 dataLength; + UInt8 rzoneNumberLSB; + UInt8 borderNumberLSB; + UInt8 reserved; +#ifdef __LITTLE_ENDIAN__ + UInt8 reserved2:4; + UInt8 copy:1; + UInt8 damage:1; + UInt8 reserved3:2; + + UInt8 reserved4:4; + UInt8 restrictedOverwrite:1; + UInt8 incremental:1; + UInt8 blank:1; + UInt8 reservedRZone:1; + + UInt8 nextWritableAddressValid:1; + UInt8 lastRecordedAddressValid:1; + UInt8 reserved5:6; +#else /* !__LITTLE_ENDIAN__ */ + UInt8 reserved3:2; + UInt8 damage:1; + UInt8 copy:1; + UInt8 reserved2:4; + + UInt8 reservedRZone:1; + UInt8 blank:1; + UInt8 incremental:1; + UInt8 restrictedOverwrite:1; + UInt8 reserved4:4; + + UInt8 reserved5:6; + UInt8 lastRecordedAddressValid:1; + UInt8 nextWritableAddressValid:1; +#endif /* !__LITTLE_ENDIAN__ */ + UInt32 rzoneStartAddress; + UInt32 nextWritableAddress; + UInt32 freeBlocks; + UInt32 blockingFactor; + UInt32 rzoneSize; + UInt32 lastRecordedAddress; + UInt8 rzoneNumberMSB; + UInt8 borderNumberMSB; + UInt8 reserved6; + UInt8 reserved7; +}; +typedef struct DVDRZoneInfo DVDRZoneInfo; + +#pragma pack(pop) /* (reset to default struct packing) */ + +#endif /* _IODVDTYPES_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/storage/IOCDBlockStorageDriver.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/storage/IOCDBlockStorageDriver.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/storage/IOCDBlockStorageDriver.h (revision 885) @@ -0,0 +1,259 @@ +/* + * 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@ + */ +/* + * 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 +#include +#include +#include + +/*! + * @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, +#ifdef __LP64__ + IOStorageAttributes *attributes, + IOStorageCompletion *completion, +#else /* !__LP64__ */ + IOStorageCompletion completion, +#endif /* !__LP64__ */ + 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, +#ifdef __LP64__ + IOStorageAttributes *attributes, + IOStorageCompletion *completion); +#else /* !__LP64__ */ + IOStorageCompletion completion); +#endif /* !__LP64__ */ + virtual IOReturn readISRC(UInt8 track,CDISRC isrc); + virtual IOReturn readMCN(CDMCN mcn); + + /* end of IOCDMedia APIs */ + +#ifndef __LP64__ + /* --------------------------------------------------------*/ + /* APIs implemented here, exported by IOCDAudioControl: */ + /* --------------------------------------------------------*/ + + virtual IOReturn audioPause(bool pause) __attribute__ ((deprecated)); + virtual IOReturn audioPlay(CDMSF timeStart,CDMSF timeStop) __attribute__ ((deprecated)); + virtual IOReturn audioScan(CDMSF timeStart,bool reverse) __attribute__ ((deprecated)); + virtual IOReturn audioStop() __attribute__ ((deprecated)); + virtual IOReturn getAudioStatus(CDAudioStatus *status) __attribute__ ((deprecated)); + virtual IOReturn getAudioVolume(UInt8 *leftVolume,UInt8 *rightVolume) __attribute__ ((deprecated)); + virtual IOReturn setAudioVolume(UInt8 leftVolume,UInt8 rightVolume) __attribute__ ((deprecated)); + + /* end of IOCDAudioControl APIs */ +#endif /* !__LP64__ */ + + /* + * 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, +#ifdef __LP64__ + IOStorageAttributes *attributes, + IOStorageCompletion *completion); +#else /* !__LP64__ */ + IOStorageCompletion completion); +#endif /* !__LP64__ */ + + /* ------- */ + + 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); /* 10.1.0 */ + + virtual IOReturn setSpeed(UInt16 kilobytesPerSecond); /* 10.1.0 */ + + virtual IOReturn readTOC(IOMemoryDescriptor *buffer,CDTOCFormat format, + UInt8 formatAsTime,UInt8 trackOrSessionNumber, + UInt16 *actualByteCount); /* 10.1.3 */ + + virtual IOReturn readDiscInfo(IOMemoryDescriptor *buffer, + UInt16 *actualByteCount); /* 10.1.3 */ + + virtual IOReturn readTrackInfo(IOMemoryDescriptor *buffer,UInt32 address, + CDTrackInfoAddressType addressType, + UInt16 *actualByteCount); /* 10.1.3 */ + + virtual void writeCD(IOService *client, + UInt64 byteStart, + IOMemoryDescriptor *buffer, + CDSectorArea sectorArea, + CDSectorType sectorType, +#ifdef __LP64__ + IOStorageAttributes *attributes, + IOStorageCompletion *completion); +#else /* !__LP64__ */ + IOStorageCompletion completion); /* 10.2.0 */ +#endif /* !__LP64__ */ + +#ifdef __LP64__ + OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver, 0); + OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver, 1); + OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver, 2); + OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver, 3); + OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver, 4); + OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver, 5); +#else /* !__LP64__ */ + OSMetaClassDeclareReservedUsed(IOCDBlockStorageDriver, 0); + OSMetaClassDeclareReservedUsed(IOCDBlockStorageDriver, 1); + OSMetaClassDeclareReservedUsed(IOCDBlockStorageDriver, 2); + OSMetaClassDeclareReservedUsed(IOCDBlockStorageDriver, 3); + OSMetaClassDeclareReservedUsed(IOCDBlockStorageDriver, 4); + OSMetaClassDeclareReservedUsed(IOCDBlockStorageDriver, 5); +#endif /* !__LP64__ */ + 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 Index: branches/azimutz/Cleancut/i386/include/IOKit/storage/IOStorage.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/storage/IOStorage.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/storage/IOStorage.h (revision 885) @@ -0,0 +1,562 @@ +/* + * 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 IOStorage + * @abstract + * This header contains the IOStorage class definition. + */ + +#ifndef _IOSTORAGE_H +#define _IOSTORAGE_H + +#include + +/*! + * @defined kIOStorageClass + * @abstract + * The name of the IOStorage class. + */ + +#define kIOStorageClass "IOStorage" + +/*! + * @defined kIOStorageCategory + * @abstract + * kIOStorageCategory is a value for IOService's kIOMatchCategoryKey property. + * @discussion + * The kIOStorageCategory value is the standard value for the IOService property + * kIOMatchCategoryKey ("IOMatchCategory") for all storage drivers. All storage + * objects that expect to drive new content (that is, produce new media objects) + * are expected to compete within the kIOStorageCategory namespace. + * + * See the IOService documentation for more information on match categories. + */ + +#define kIOStorageCategory "IOStorage" /* (as IOMatchCategory) */ + +/*! + * @defined kIOStorageFeaturesKey + * @abstract + * A property of any object in the storage stack. + * @discussion + * kIOStorageFeaturesKey is a property of any object in the storage stack that + * wishes to express support of additional features, such as Force Unit Access. + * It is typically defined in the device object below the block storage driver + * object. It has an OSDictionary value, where each entry describes one given + * feature. + */ + +#define kIOStorageFeaturesKey "IOStorageFeatures" + +/*! + * @defined kIOStorageFeatureDiscard + * @abstract + * Describes the presence of the Discard feature. + * @discussion + * This property describes the ability of the storage stack to delete unused + * data from the media. It is one of the feature entries listed under the top- + * level kIOStorageFeaturesKey property table. It has an OSBoolean value. + */ + +#define kIOStorageFeatureDiscard "Discard" + +/*! + * @defined kIOStorageFeatureForceUnitAccess + * @abstract + * Describes the presence of the Force Unit Access feature. + * @discussion + * This property describes the ability of the storage stack to force a request + * to access the media. It is one of the feature entries listed under the top- + * level kIOStorageFeaturesKey property table. It has an OSBoolean value. + */ + +#define kIOStorageFeatureForceUnitAccess "Force Unit Access" + +#ifdef KERNEL +#ifdef __cplusplus + +/* + * Kernel + */ + +#include +#include +#include + +/*! + * @enum IOStorageAccess + * @discussion + * The IOStorageAccess enumeration describes the possible access levels for open + * requests. + * @constant kIOStorageAccessNone + * No access is requested; should not be passed to open(). + * @constant kIOStorageAccessReader + * Read-only access is requested. + * @constant kIOStorageAccessReaderWriter + * Read and write access is requested. + * @constant kIOStorageAccessSharedLock + * Shared access is requested. + * @constant kIOStorageAccessExclusiveLock + * Exclusive access is requested. + */ + +enum +{ + kIOStorageAccessNone = 0x00, + kIOStorageAccessReader = 0x01, + kIOStorageAccessReaderWriter = 0x03, + kIOStorageAccessSharedLock = 0x04, + kIOStorageAccessExclusiveLock = 0x08 +}; + +typedef UInt32 IOStorageAccess; + +/*! + * @enum IOStorageOptions + * @discussion + * Options for read and write storage requests. + * @constant kIOStorageOptionForceUnitAccess + * Force the request to access the media. + */ + +enum +{ + kIOStorageOptionNone = 0x00000000, + kIOStorageOptionForceUnitAccess = 0x00000001, + kIOStorageOptionReserved = 0xFFFFFFFE +}; + +typedef UInt32 IOStorageOptions; + +/*! + * @struct IOStorageAttributes + * @discussion + * Attributes of read and write storage requests. + * @field options + * Options for the request. See IOStorageOptions. + * @field reserved + * Reserved for future use. Set to zero. + */ + +struct IOStorageAttributes +{ + IOStorageOptions options; + UInt32 reserved0032; + UInt64 reserved0064; +#ifdef __LP64__ + UInt64 reserved0128; + UInt64 reserved0192; +#endif /* __LP64__ */ +}; + +/*! + * @typedef IOStorageCompletionAction + * @discussion + * The IOStorageCompletionAction declaration describes the C (or C++) completion + * routine that is called once an asynchronous storage operation completes. + * @param target + * Opaque client-supplied pointer (or an instance pointer for a C++ callback). + * @param parameter + * Opaque client-supplied pointer. + * @param status + * Status of the data transfer. + * @param actualByteCount + * Actual number of bytes transferred in the data transfer. + */ + +typedef void (*IOStorageCompletionAction)(void * target, + void * parameter, + IOReturn status, + UInt64 actualByteCount); + +/*! + * @struct IOStorageCompletion + * @discussion + * The IOStorageCompletion structure describes the C (or C++) completion routine + * that is called once an asynchronous storage operation completes. The values + * passed for the target and parameter fields will be passed to the routine when + * it is called. + * @field target + * Opaque client-supplied pointer (or an instance pointer for a C++ callback). + * @field action + * Completion routine to call on completion of the data transfer. + * @field parameter + * Opaque client-supplied pointer. + */ + +struct IOStorageCompletion +{ + void * target; + IOStorageCompletionAction action; + void * parameter; +}; + +/*! + * @class IOStorage + * @abstract + * The common base class for mass storage objects. + * @discussion + * The IOStorage class is the common base class for mass storage objects. It is + * an abstract class that defines the open/close/read/write APIs that need to be + * implemented in a given subclass. Synchronous versions of the read/write APIs + * are provided here -- they are coded in such a way as to wrap the asynchronous + * versions implemented in the subclass. + */ + +class IOStorage : public IOService +{ + OSDeclareAbstractStructors(IOStorage); + +protected: + + struct ExpansionData { /* */ }; + ExpansionData * _expansionData; + + /*! + * @function handleOpen + * @discussion + * The handleOpen method grants or denies permission to access this object + * to an interested client. The argument is an IOStorageAccess value that + * specifies the level of access desired -- reader or reader-writer. + * + * This method can be invoked to upgrade or downgrade the access level for + * an existing client as well. The previous access level will prevail for + * upgrades that fail, of course. A downgrade should never fail. If the + * new access level should be the same as the old for a given client, this + * method will do nothing and return success. In all cases, one, singular + * close-per-client is expected for all opens-per-client received. + * @param client + * Client requesting the open. + * @param options + * Options for the open. Set to zero. + * @param access + * Access level for the open. Set to kIOStorageAccessReader or + * kIOStorageAccessReaderWriter. + * @result + * Returns true if the open was successful, false otherwise. + */ + + virtual bool handleOpen(IOService * client, + IOOptionBits options, + void * access) = 0; + + /*! + * @function handleIsOpen + * @discussion + * The handleIsOpen method determines whether the specified client, or any + * client if none is specified, presently has an open on this object. + * @param client + * Client to check the open state of. Set to zero to check the open state + * of all clients. + * @result + * Returns true if the client was (or clients were) open, false otherwise. + */ + + virtual bool handleIsOpen(const IOService * client) const = 0; + + /*! + * @function handleClose + * @discussion + * The handleClose method closes the client's access to this object. + * @param client + * Client requesting the close. + * @param options + * Options for the close. Set to zero. + */ + + virtual void handleClose(IOService * client, IOOptionBits options) = 0; + +public: + +#ifndef __LP64__ + /* + * Initialize this object's minimal state. + */ + + virtual bool init(OSDictionary * properties = 0); +#endif /* !__LP64__ */ + + /*! + * @function complete + * @discussion + * Invokes the specified completion action of the read/write request. If + * the completion action is unspecified, no action is taken. This method + * serves simply as a convenience to storage subclass developers. + * @param completion + * Completion information for the data transfer. + * @param status + * Status of the data transfer. + * @param actualByteCount + * Actual number of bytes transferred in the data transfer. + */ + + static void complete(IOStorageCompletion * completion, + IOReturn status, + UInt64 actualByteCount = 0); + +#ifndef __LP64__ + static void complete(IOStorageCompletion completion, + IOReturn status, + UInt64 actualByteCount = 0); /* DEPRECATED */ +#endif /* !__LP64__ */ + + /*! + * @function open + * @discussion + * Ask the storage object for permission to access its contents; the method + * is equivalent to IOService::open(), but with the correct parameter types. + * + * This method may also be invoked to upgrade or downgrade the access of an + * existing open (if it fails, the existing open prevails). + * @param client + * Client requesting the open. + * @param options + * Options for the open. Set to zero. + * @param access + * Access level for the open. Set to kIOStorageAccessReader or + * kIOStorageAccessReaderWriter. + * @result + * Returns true if the open was successful, false otherwise. + */ + + virtual bool open(IOService * client, + IOOptionBits options, + IOStorageAccess access); + +#ifndef __LP64__ + virtual void read(IOService * client, + UInt64 byteStart, + IOMemoryDescriptor * buffer, + IOStorageCompletion completion) __attribute__ ((deprecated)); + + virtual void write(IOService * client, + UInt64 byteStart, + IOMemoryDescriptor * buffer, + IOStorageCompletion completion) __attribute__ ((deprecated)); +#endif /* !__LP64__ */ + + /*! + * @function read + * @discussion + * Read data from the storage object at the specified byte offset into the + * specified buffer, synchronously. When the read completes, this method + * will return to the caller. The actual byte count field is optional. + * @param client + * Client requesting the read. + * @param byteStart + * Starting byte offset for the data transfer. + * @param buffer + * Buffer for the data transfer. The size of the buffer implies the size of + * the data transfer. + * @param attributes + * Attributes of the data transfer. See IOStorageAttributes. + * @param actualByteCount + * Returns the actual number of bytes transferred in the data transfer. + * @result + * Returns the status of the data transfer. + */ + +#ifdef __LP64__ + virtual IOReturn read(IOService * client, + UInt64 byteStart, + IOMemoryDescriptor * buffer, + IOStorageAttributes * attributes = 0, + UInt64 * actualByteCount = 0); +#else /* !__LP64__ */ + virtual IOReturn read(IOService * client, + UInt64 byteStart, + IOMemoryDescriptor * buffer, + UInt64 * actualByteCount = 0); +#endif /* !__LP64__ */ + + /*! + * @function write + * @discussion + * Write data into the storage object at the specified byte offset from the + * specified buffer, synchronously. When the write completes, this method + * will return to the caller. The actual byte count field is optional. + * @param client + * Client requesting the write. + * @param byteStart + * Starting byte offset for the data transfer. + * @param buffer + * Buffer for the data transfer. The size of the buffer implies the size of + * the data transfer. + * @param attributes + * Attributes of the data transfer. See IOStorageAttributes. + * @param actualByteCount + * Returns the actual number of bytes transferred in the data transfer. + * @result + * Returns the status of the data transfer. + */ + +#ifdef __LP64__ + virtual IOReturn write(IOService * client, + UInt64 byteStart, + IOMemoryDescriptor * buffer, + IOStorageAttributes * attributes = 0, + UInt64 * actualByteCount = 0); +#else /* !__LP64__ */ + virtual IOReturn write(IOService * client, + UInt64 byteStart, + IOMemoryDescriptor * buffer, + UInt64 * actualByteCount = 0); +#endif /* !__LP64__ */ + + /*! + * @function synchronizeCache + * @discussion + * Flush the cached data in the storage object, if any, synchronously. + * @param client + * Client requesting the cache synchronization. + * @result + * Returns the status of the cache synchronization. + */ + + virtual IOReturn synchronizeCache(IOService * client) = 0; + + /*! + * @function read + * @discussion + * Read data from the storage object at the specified byte offset into the + * specified buffer, asynchronously. When the read completes, the caller + * will be notified via the specified completion action. + * + * The buffer will be retained for the duration of the read. + * @param client + * Client requesting the read. + * @param byteStart + * Starting byte offset for the data transfer. + * @param buffer + * Buffer for the data transfer. The size of the buffer implies the size of + * the data transfer. + * @param attributes + * Attributes of the data transfer. See IOStorageAttributes. It is the + * responsibility of the callee to maintain the information for the duration + * of the data transfer, as necessary. + * @param completion + * Completion routine to call once the data transfer is complete. It is the + * responsibility of the callee to maintain the information for the duration + * of the data transfer, as necessary. + */ + +#ifdef __LP64__ + virtual void read(IOService * client, + UInt64 byteStart, + IOMemoryDescriptor * buffer, + IOStorageAttributes * attributes, + IOStorageCompletion * completion) = 0; +#else /* !__LP64__ */ + virtual void read(IOService * client, + UInt64 byteStart, + IOMemoryDescriptor * buffer, + IOStorageAttributes * attributes, + IOStorageCompletion * completion); /* 10.5.0 */ +#endif /* !__LP64__ */ + + /*! + * @function write + * @discussion + * Write data into the storage object at the specified byte offset from the + * specified buffer, asynchronously. When the write completes, the caller + * will be notified via the specified completion action. + * + * The buffer will be retained for the duration of the write. + * @param client + * Client requesting the write. + * @param byteStart + * Starting byte offset for the data transfer. + * @param buffer + * Buffer for the data transfer. The size of the buffer implies the size of + * the data transfer. + * @param attributes + * Attributes of the data transfer. See IOStorageAttributes. It is the + * responsibility of the callee to maintain the information for the duration + * of the data transfer, as necessary. + * @param completion + * Completion routine to call once the data transfer is complete. It is the + * responsibility of the callee to maintain the information for the duration + * of the data transfer, as necessary. + */ + +#ifdef __LP64__ + virtual void write(IOService * client, + UInt64 byteStart, + IOMemoryDescriptor * buffer, + IOStorageAttributes * attributes, + IOStorageCompletion * completion) = 0; +#else /* !__LP64__ */ + virtual void write(IOService * client, + UInt64 byteStart, + IOMemoryDescriptor * buffer, + IOStorageAttributes * attributes, + IOStorageCompletion * completion); /* 10.5.0 */ +#endif /* !__LP64__ */ + + /*! + * @function discard + * @discussion + * Delete unused data from the storage object at the specified byte offset, + * synchronously. + * @param client + * Client requesting the operation. + * @param byteStart + * Starting byte offset for the operation. + * @param byteCount + * Size of the operation. + * @result + * Returns the status of the operation. + */ + + virtual IOReturn discard(IOService * client, + UInt64 byteStart, + UInt64 byteCount); /* 10.6.0 */ + +#ifdef __LP64__ + OSMetaClassDeclareReservedUnused(IOStorage, 0); + OSMetaClassDeclareReservedUnused(IOStorage, 1); + OSMetaClassDeclareReservedUnused(IOStorage, 2); +#else /* !__LP64__ */ + OSMetaClassDeclareReservedUsed(IOStorage, 0); + OSMetaClassDeclareReservedUsed(IOStorage, 1); + OSMetaClassDeclareReservedUsed(IOStorage, 2); +#endif /* !__LP64__ */ + OSMetaClassDeclareReservedUnused(IOStorage, 3); + OSMetaClassDeclareReservedUnused(IOStorage, 4); + OSMetaClassDeclareReservedUnused(IOStorage, 5); + OSMetaClassDeclareReservedUnused(IOStorage, 6); + OSMetaClassDeclareReservedUnused(IOStorage, 7); + OSMetaClassDeclareReservedUnused(IOStorage, 8); + OSMetaClassDeclareReservedUnused(IOStorage, 9); + OSMetaClassDeclareReservedUnused(IOStorage, 10); + OSMetaClassDeclareReservedUnused(IOStorage, 11); + OSMetaClassDeclareReservedUnused(IOStorage, 12); + OSMetaClassDeclareReservedUnused(IOStorage, 13); + OSMetaClassDeclareReservedUnused(IOStorage, 14); + OSMetaClassDeclareReservedUnused(IOStorage, 15); +}; + +#endif /* __cplusplus */ +#endif /* KERNEL */ +#endif /* !_IOSTORAGE_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/storage/IODVDMediaBSDClient.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/storage/IODVDMediaBSDClient.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/storage/IODVDMediaBSDClient.h (revision 885) @@ -0,0 +1,197 @@ +/* + * 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 _IODVDMEDIABSDCLIENT_H +#define _IODVDMEDIABSDCLIENT_H + +#include + +#include + +/* + * Definitions + * + * ioctl description + * ---------------------------- ------------------------------------------------ + * DKIOCDVDREADSTRUCTURE see IODVDMedia::readStructure() in IODVDMedia.h + * + * DKIOCDVDREADDISCINFO see IODVDMedia::readDiscInfo() in IODVDMedia.h + * DKIOCDVDREADRZONEINFO see IODVDMedia::readRZoneInfo() in IODVDMedia.h + * + * DKIOCDVDREPORTKEY see IODVDMedia::reportKey() in IODVDMedia.h + * DKIOCDVDSENDKEY see IODVDMedia::sendKey() in IODVDMedia.h + * + * DKIOCDVDGETSPEED see IODVDMedia::getSpeed() in IODVDMedia.h + * DKIOCDVDSETSPEED see IODVDMedia::setSpeed() in IODVDMedia.h + * + * in /System/Library/Frameworks/Kernel.framework/Headers/IOKit/storage/ + */ + +typedef struct +{ + uint8_t format; + + uint8_t reserved0008[3]; /* reserved, clear to zero */ + + uint32_t address; + uint8_t grantID; + uint8_t layer; + +#ifdef __LP64__ + uint8_t reserved0080[4]; /* reserved, clear to zero */ +#endif /* __LP64__ */ + + uint16_t bufferLength; + void * buffer; +} dk_dvd_read_structure_t; + +typedef struct +{ + uint8_t format; + uint8_t keyClass; + + uint8_t reserved0016[2]; /* reserved, clear to zero */ + + uint32_t address; + uint8_t grantID; + +#ifdef __LP64__ + uint8_t reserved0072[5]; /* reserved, clear to zero */ +#else /* !__LP64__ */ + uint8_t reserved0072[1]; /* reserved, clear to zero */ +#endif /* !__LP64__ */ + + uint16_t bufferLength; + void * buffer; +} dk_dvd_report_key_t; + +typedef struct +{ + uint8_t format; + uint8_t keyClass; + + uint8_t reserved0016[6]; /* reserved, clear to zero */ + + uint8_t grantID; + +#ifdef __LP64__ + uint8_t reserved0072[5]; /* reserved, clear to zero */ +#else /* !__LP64__ */ + uint8_t reserved0072[1]; /* reserved, clear to zero */ +#endif /* !__LP64__ */ + + uint16_t bufferLength; + void * buffer; +} dk_dvd_send_key_t; + +typedef struct +{ +#ifdef __LP64__ + uint8_t reserved0000[14]; /* reserved, clear to zero */ +#else /* !__LP64__ */ + uint8_t reserved0000[10]; /* reserved, clear to zero */ +#endif /* !__LP64__ */ + + uint16_t bufferLength; /* actual length on return */ + void * buffer; +} dk_dvd_read_disc_info_t; + +typedef struct +{ + uint8_t reserved0000[4]; /* reserved, clear to zero */ + + uint32_t address; + uint8_t addressType; + +#ifdef __LP64__ + uint8_t reserved0072[5]; /* reserved, clear to zero */ +#else /* !__LP64__ */ + uint8_t reserved0072[1]; /* reserved, clear to zero */ +#endif /* !__LP64__ */ + + uint16_t bufferLength; /* actual length on return */ + void * buffer; +} dk_dvd_read_rzone_info_t; + +#define DKIOCDVDREADSTRUCTURE _IOW('d', 128, dk_dvd_read_structure_t) +#define DKIOCDVDREPORTKEY _IOW('d', 129, dk_dvd_report_key_t) +#define DKIOCDVDSENDKEY _IOW('d', 130, dk_dvd_send_key_t) + +#define DKIOCDVDGETSPEED _IOR('d', 131, uint16_t) +#define DKIOCDVDSETSPEED _IOW('d', 131, uint16_t) + +#define DKIOCDVDREADDISCINFO _IOWR('d', 132, dk_dvd_read_disc_info_t) +#define DKIOCDVDREADRZONEINFO _IOWR('d', 133, dk_dvd_read_rzone_info_t) + +#ifdef KERNEL +#ifdef __cplusplus + +/* + * Kernel + */ + +#include +#include + +/* + * Class + */ + +class IODVDMediaBSDClient : public IOMediaBSDClient +{ + OSDeclareDefaultStructors(IODVDMediaBSDClient) + +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 -- IODVDMedia. This + * method serves simply as a convenience to subclass developers. + */ + + virtual IODVDMedia * getProvider() const; + + /* + * Process a DVD-specific ioctl. + */ + + virtual int ioctl(dev_t dev, u_long cmd, caddr_t data, int flags, proc_t proc); + + OSMetaClassDeclareReservedUnused(IODVDMediaBSDClient, 0); + OSMetaClassDeclareReservedUnused(IODVDMediaBSDClient, 1); + OSMetaClassDeclareReservedUnused(IODVDMediaBSDClient, 2); + OSMetaClassDeclareReservedUnused(IODVDMediaBSDClient, 3); + OSMetaClassDeclareReservedUnused(IODVDMediaBSDClient, 4); + OSMetaClassDeclareReservedUnused(IODVDMediaBSDClient, 5); + OSMetaClassDeclareReservedUnused(IODVDMediaBSDClient, 6); + OSMetaClassDeclareReservedUnused(IODVDMediaBSDClient, 7); +}; + +#endif /* __cplusplus */ +#endif /* KERNEL */ +#endif /* !_IODVDMEDIABSDCLIENT_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/storage/IOBDBlockStorageDevice.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/storage/IOBDBlockStorageDevice.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/storage/IOBDBlockStorageDevice.h (revision 885) @@ -0,0 +1,157 @@ +/* + * Copyright (c) 2006-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 IOBDBlockStorageDevice + * @abstract + * This header contains the IOBDBlockStorageDevice class definition. + */ + +#ifndef _IOBDBLOCKSTORAGEDEVICE_H +#define _IOBDBLOCKSTORAGEDEVICE_H + +#include + +/*! + * @defined kIOBDBlockStorageDeviceClass + * @abstract + * kIOBDBlockStorageDeviceClass is the name of the IOBDBlockStorageDevice class. + * @discussion + * kIOBDBlockStorageDeviceClass is the name of the IOBDBlockStorageDevice class. + */ + +#define kIOBDBlockStorageDeviceClass "IOBDBlockStorageDevice" + +#ifdef KERNEL +#ifdef __cplusplus + +/* + * Kernel + */ + +#include + +/* Property used for matching, so the generic driver gets the nub it wants. */ +#define kIOBlockStorageDeviceTypeBD "BD" + +/*! + * @class + * IOBDBlockStorageDevice + * @abstract + * The IOBDBlockStorageDevice class is a generic BD block storage device + * abstraction. + * @discussion + * This class is the protocol for generic BD functionality, independent of + * the physical connection protocol (e.g. SCSI, ATA, USB). + * + * The APIs are the union of CD APIs, DVD APIs, and all + * necessary new low-level BD APIs. + * + * A subclass implements relay methods that translate our requests into + * calls to a protocol- and device-specific provider. + */ + +class IOBDBlockStorageDevice : public IODVDBlockStorageDevice +{ + OSDeclareAbstractStructors(IOBDBlockStorageDevice) + +protected: + + struct ExpansionData { /* */ }; + ExpansionData * _expansionData; + +public: + + /*! + * @function init + * @discussion + * Initialize this object's minimal state. + * @param properties + * Substitute property table for this object (optional). + * @result + * Returns true on success, false otherwise. + */ + + virtual bool init(OSDictionary * properties); + + /*! + * @function readDiscStructure + * @discussion + * Issue an MMC READ DISC STRUCTURE command. + * @param buffer + * Buffer for the data transfer. The size of the buffer implies the size of + * the data transfer. + * @param format + * As documented by MMC. + * @param address + * As documented by MMC. + * @param layer + * As documented by MMC. + * @param grantID + * As documented by MMC. + * @param type + * As documented by MMC. + * @result + * Returns the status of the data transfer. + */ + + virtual IOReturn readDiscStructure( IOMemoryDescriptor * buffer, + UInt8 format, + UInt32 address, + UInt8 layer, + UInt8 grantID, + UInt8 type ) = 0; + + /*! + * @function splitTrack + * @discussion + * Issue an MMC RESERVE TRACK command with the ARSV bit. + * @param address + * As documented by MMC. + * @result + * Returns the status of the operation. + */ + + virtual IOReturn splitTrack(UInt32 address) = 0; + + OSMetaClassDeclareReservedUnused(IOBDBlockStorageDevice, 0); + OSMetaClassDeclareReservedUnused(IOBDBlockStorageDevice, 1); + OSMetaClassDeclareReservedUnused(IOBDBlockStorageDevice, 2); + OSMetaClassDeclareReservedUnused(IOBDBlockStorageDevice, 3); + OSMetaClassDeclareReservedUnused(IOBDBlockStorageDevice, 4); + OSMetaClassDeclareReservedUnused(IOBDBlockStorageDevice, 5); + OSMetaClassDeclareReservedUnused(IOBDBlockStorageDevice, 6); + OSMetaClassDeclareReservedUnused(IOBDBlockStorageDevice, 7); + OSMetaClassDeclareReservedUnused(IOBDBlockStorageDevice, 8); + OSMetaClassDeclareReservedUnused(IOBDBlockStorageDevice, 9); + OSMetaClassDeclareReservedUnused(IOBDBlockStorageDevice, 10); + OSMetaClassDeclareReservedUnused(IOBDBlockStorageDevice, 11); + OSMetaClassDeclareReservedUnused(IOBDBlockStorageDevice, 12); + OSMetaClassDeclareReservedUnused(IOBDBlockStorageDevice, 13); + OSMetaClassDeclareReservedUnused(IOBDBlockStorageDevice, 14); + OSMetaClassDeclareReservedUnused(IOBDBlockStorageDevice, 15); +}; + +#endif /* __cplusplus */ +#endif /* KERNEL */ +#endif /* !_IOBDBLOCKSTORAGEDEVICE_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/storage/IOCDPartitionScheme.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/storage/IOCDPartitionScheme.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/storage/IOCDPartitionScheme.h (revision 885) @@ -0,0 +1,226 @@ +/* + * 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 IOCDPartitionScheme + * @abstract + * This header contains the IOCDPartitionScheme class definition. + */ + +#ifndef _IOCDPARTITIONSCHEME_H +#define _IOCDPARTITIONSCHEME_H + +#include + +/*! + * @defined kIOCDPartitionSchemeClass + * @abstract + * kIOCDPartitionSchemeClass is the name of the IOCDPartitionScheme class. + * @discussion + * kIOCDPartitionSchemeClass is the name of the IOCDPartitionScheme class. + */ + +#define kIOCDPartitionSchemeClass "IOCDPartitionScheme" + +/*! + * @defined kIOMediaSessionIDKey + * @abstract + * kIOMediaSessionIDKey is property of IOMedia objects. It has an OSNumber + * value. + * @discussion + * The kIOMediaSessionIDKey property is placed into each IOMedia instance + * created by the CD partition scheme. It identifies the session number + * the track was recorded on. + */ + +#define kIOMediaSessionIDKey "Session ID" + +#ifdef KERNEL +#ifdef __cplusplus + +/* + * Kernel + */ + +#include +#include + +/* + * Class + */ + +class IOCDPartitionScheme : public IOPartitionScheme +{ + OSDeclareDefaultStructors(IOCDPartitionScheme); + +protected: + + struct ExpansionData { /* */ }; + ExpansionData * _expansionData; + + OSSet * _partitions; /* (set of media objects representing partitions) */ + + /* + * Free all of this object's outstanding resources. + */ + + virtual void free(void); + + /* + * Scan the provider media for CD partitions (in TOC). Returns the set + * of media objects representing each of the partitions (the retain for + * the set is passed to the caller), or null should no CD partitions be + * found. The default probe score can be adjusted up or down, based on + * the confidence of the scan. + */ + + virtual OSSet * scan(SInt32 * score); + + /* + * Ask whether the given partition appears to be corrupt. A partition that + * is corrupt will cause the failure of the CD partition scheme altogether. + */ + + virtual bool isPartitionCorrupt( CDTOCDescriptor * partition, + UInt64 partitionSize, + UInt32 partitionBlockSize, + CDSectorType partitionBlockType, + CDTOC * toc ); + + /* + * Ask whether the given partition appears to be invalid. A partition that + * is invalid will cause it to be skipped in the scan, but will not cause a + * failure of the CD partition scheme. + */ + + virtual bool isPartitionInvalid( CDTOCDescriptor * partition, + UInt64 partitionSize, + UInt32 partitionBlockSize, + CDSectorType partitionBlockType, + CDTOC * toc ); + + /* + * Instantiate a new media object to represent the given partition. + */ + + virtual IOMedia * instantiateMediaObject( + CDTOCDescriptor * partition, + UInt64 partitionSize, + UInt32 partitionBlockSize, + CDSectorType partitionBlockType, + CDTOC * toc ); + + /* + * Allocate a new media object (called from instantiateMediaObject). + */ + + virtual IOMedia * instantiateDesiredMediaObject( + CDTOCDescriptor * partition, + UInt64 partitionSize, + UInt32 partitionBlockSize, + CDSectorType partitionBlockType, + CDTOC * toc ); + +public: + + /* + * Initialize this object's minimal state. + */ + + virtual bool init(OSDictionary * properties = 0); + + /* + * Scan the provider media for CD partitions. + */ + + virtual IOService * probe(IOService * provider, SInt32 * score); + + /* + * Determine whether the provider media contains CD partitions. + */ + + virtual bool start(IOService * provider); + + /* + * Read data from the storage object at the specified byte offset into the + * specified buffer, asynchronously. When the read completes, the caller + * will be notified via the specified completion action. + * + * The buffer will be retained for the duration of the read. + * + * For the CD partition scheme, we convert the read from a partition + * object into the appropriate readCD command to our provider media. + */ + + virtual void read(IOService * client, + UInt64 byteStart, + IOMemoryDescriptor * buffer, + IOStorageAttributes * attributes, + IOStorageCompletion * completion); + + /* + * Write data into the storage object at the specified byte offset from the + * specified buffer, asynchronously. When the write completes, the caller + * will be notified via the specified completion action. + * + * The buffer will be retained for the duration of the write. + * + * For the CD partition scheme, we convert the write from a partition + * object into the appropriate writeCD command to our provider media. + */ + + virtual void write(IOService * client, + UInt64 byteStart, + IOMemoryDescriptor * buffer, + IOStorageAttributes * attributes, + IOStorageCompletion * completion); + + /* + * Obtain this object's provider. We override the superclass's method + * to return a more specific subclass of OSObject -- IOCDMedia. This + * method serves simply as a convenience to subclass developers. + */ + + virtual IOCDMedia * getProvider() const; + + OSMetaClassDeclareReservedUnused(IOCDPartitionScheme, 0); + OSMetaClassDeclareReservedUnused(IOCDPartitionScheme, 1); + OSMetaClassDeclareReservedUnused(IOCDPartitionScheme, 2); + OSMetaClassDeclareReservedUnused(IOCDPartitionScheme, 3); + OSMetaClassDeclareReservedUnused(IOCDPartitionScheme, 4); + OSMetaClassDeclareReservedUnused(IOCDPartitionScheme, 5); + OSMetaClassDeclareReservedUnused(IOCDPartitionScheme, 6); + OSMetaClassDeclareReservedUnused(IOCDPartitionScheme, 7); + OSMetaClassDeclareReservedUnused(IOCDPartitionScheme, 8); + OSMetaClassDeclareReservedUnused(IOCDPartitionScheme, 9); + OSMetaClassDeclareReservedUnused(IOCDPartitionScheme, 10); + OSMetaClassDeclareReservedUnused(IOCDPartitionScheme, 11); + OSMetaClassDeclareReservedUnused(IOCDPartitionScheme, 12); + OSMetaClassDeclareReservedUnused(IOCDPartitionScheme, 13); + OSMetaClassDeclareReservedUnused(IOCDPartitionScheme, 14); + OSMetaClassDeclareReservedUnused(IOCDPartitionScheme, 15); +}; + +#endif /* __cplusplus */ +#endif /* KERNEL */ +#endif /* !_IOCDPARTITIONSCHEME_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/storage/IOCDBlockStorageDevice.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/storage/IOCDBlockStorageDevice.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/storage/IOCDBlockStorageDevice.h (revision 885) @@ -0,0 +1,181 @@ +/* + * 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 IOCDBlockStorageDevice + * @abstract + * This header contains the IOCDBlockStorageDevice class definition. + */ + +#ifndef _IOCDBLOCKSTORAGEDEVICE_H +#define _IOCDBLOCKSTORAGEDEVICE_H + +#include + +/*! + * @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 + +/* 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; + +#ifndef __LP64__ + /*-----------------------------------------*/ + /* APIs exported by IOCDAudioControl */ + /*-----------------------------------------*/ + + virtual IOReturn audioPause(bool pause) __attribute__ ((deprecated)); + virtual IOReturn audioPlay(CDMSF timeStart,CDMSF timeStop) __attribute__ ((deprecated)); + virtual IOReturn audioScan(CDMSF timeStart,bool reverse) __attribute__ ((deprecated)); + virtual IOReturn audioStop() __attribute__ ((deprecated)); + virtual IOReturn getAudioStatus(CDAudioStatus *status) __attribute__ ((deprecated)); + virtual IOReturn getAudioVolume(UInt8 *leftVolume,UInt8 *rightVolume) __attribute__ ((deprecated)); + virtual IOReturn setAudioVolume(UInt8 leftVolume,UInt8 rightVolume) __attribute__ ((deprecated)); +#endif /* !__LP64__ */ + + /*-----------------------------------------*/ + /* CD APIs */ + /*-----------------------------------------*/ + +#ifdef __LP64__ + 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; +#else /* !__LP64__ */ + virtual IOReturn getSpeed(UInt16 * kilobytesPerSecond); /* 10.1.0 */ + + virtual IOReturn setSpeed(UInt16 kilobytesPerSecond); /* 10.1.0 */ + + virtual IOReturn readTOC(IOMemoryDescriptor *buffer,CDTOCFormat format, + UInt8 msf,UInt8 trackSessionNumber, + UInt16 *actualByteCount); /* 10.1.3 */ + + virtual IOReturn readDiscInfo(IOMemoryDescriptor *buffer, + UInt16 *actualByteCount); /* 10.1.3 */ + + virtual IOReturn readTrackInfo(IOMemoryDescriptor *buffer,UInt32 address, + CDTrackInfoAddressType addressType, + UInt16 *actualByteCount); /* 10.1.3 */ +#endif /* !__LP64__ */ + +#ifdef __LP64__ + OSMetaClassDeclareReservedUnused(IOCDBlockStorageDevice, 0); + OSMetaClassDeclareReservedUnused(IOCDBlockStorageDevice, 1); + OSMetaClassDeclareReservedUnused(IOCDBlockStorageDevice, 2); + OSMetaClassDeclareReservedUnused(IOCDBlockStorageDevice, 3); + OSMetaClassDeclareReservedUnused(IOCDBlockStorageDevice, 4); +#else /* !__LP64__ */ + OSMetaClassDeclareReservedUsed(IOCDBlockStorageDevice, 0); + OSMetaClassDeclareReservedUsed(IOCDBlockStorageDevice, 1); + OSMetaClassDeclareReservedUsed(IOCDBlockStorageDevice, 2); + OSMetaClassDeclareReservedUsed(IOCDBlockStorageDevice, 3); + OSMetaClassDeclareReservedUsed(IOCDBlockStorageDevice, 4); +#endif /* !__LP64__ */ + 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 */ Index: branches/azimutz/Cleancut/i386/include/IOKit/storage/IOMediaBSDClient.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/storage/IOMediaBSDClient.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/storage/IOMediaBSDClient.h (revision 885) @@ -0,0 +1,150 @@ +/* + * 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 _IOMEDIABSDCLIENT_H +#define _IOMEDIABSDCLIENT_H + +#include + +#ifdef KERNEL +#ifdef __cplusplus + +/* + * Kernel + */ + +#include +#include + +class AnchorTable; +class MinorTable; +struct MinorSlot; + +/* + * Class + */ + +class IOMediaBSDClient : public IOService +{ + OSDeclareDefaultStructors(IOMediaBSDClient) + +protected: + + struct ExpansionData { /* */ }; + ExpansionData * _expansionData; + +private: + + AnchorTable * _anchors; /* (table of anchors) */ + UInt32 _reserved0064; /* (reserved, do not use) */ + UInt32 _reserved0096; /* (reserved, do not use) */ + MinorTable * _minors; /* (table of minors) */ + UInt32 _reserved0160; /* (reserved, do not use) */ + +protected: + + /* + * Find the whole media that roots the given media tree. + */ + + virtual IOMedia * getWholeMedia( IOMedia * media, + UInt32 * slicePathSize = 0, + char * slicePath = 0 ); + + /* + * Create bdevsw and cdevsw nodes for the given media object. + */ + + virtual bool createNodes(IOMedia * media); + + /* + * Free all of this object's outstanding resources. + */ + + virtual void free(); + +public: + + /* + * Obtain this object's provider. We override the superclass's method to + * return a more specific subclass of IOService -- IOMedia. This method + * method serves simply as a convenience to subclass developers. + */ + + virtual IOMedia * getProvider() const; + + /* + * Initialize this object's minimal state. + */ + + virtual bool init(OSDictionary * properties = 0); + + /* + * This method is called once we have been attached to the provider object. + */ + + virtual bool start(IOService * provider); + + /* + * This method is called when we are to terminate from the provider object. + */ + + virtual bool terminate(IOOptionBits options); + +#ifndef __LP64__ + virtual AnchorTable * getAnchors() __attribute__ ((deprecated)); + virtual MinorTable * getMinors() __attribute__ ((deprecated)); + virtual MinorSlot * getMinor(UInt32 minorID) __attribute__ ((deprecated)); +#endif /* !__LP64__ */ + + /* + * Process a foreign ioctl. + */ + + virtual int ioctl(dev_t dev, u_long cmd, caddr_t data, int flags, proc_t proc); + +#ifdef __LP64__ + OSMetaClassDeclareReservedUnused(IOMediaBSDClient, 0); +#else /* !__LP64__ */ + OSMetaClassDeclareReservedUsed(IOMediaBSDClient, 0); +#endif /* !__LP64__ */ + OSMetaClassDeclareReservedUnused(IOMediaBSDClient, 1); + OSMetaClassDeclareReservedUnused(IOMediaBSDClient, 2); + OSMetaClassDeclareReservedUnused(IOMediaBSDClient, 3); + OSMetaClassDeclareReservedUnused(IOMediaBSDClient, 4); + OSMetaClassDeclareReservedUnused(IOMediaBSDClient, 5); + OSMetaClassDeclareReservedUnused(IOMediaBSDClient, 6); + OSMetaClassDeclareReservedUnused(IOMediaBSDClient, 7); + OSMetaClassDeclareReservedUnused(IOMediaBSDClient, 8); + OSMetaClassDeclareReservedUnused(IOMediaBSDClient, 9); + OSMetaClassDeclareReservedUnused(IOMediaBSDClient, 10); + OSMetaClassDeclareReservedUnused(IOMediaBSDClient, 11); + OSMetaClassDeclareReservedUnused(IOMediaBSDClient, 12); + OSMetaClassDeclareReservedUnused(IOMediaBSDClient, 13); + OSMetaClassDeclareReservedUnused(IOMediaBSDClient, 14); + OSMetaClassDeclareReservedUnused(IOMediaBSDClient, 15); +}; + +#endif /* __cplusplus */ +#endif /* KERNEL */ +#endif /* !_IOMEDIABSDCLIENT_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/storage/IOGUIDPartitionScheme.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/storage/IOGUIDPartitionScheme.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/storage/IOGUIDPartitionScheme.h (revision 885) @@ -0,0 +1,234 @@ +/* + * 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@ + */ + +/* + * This header contains the IOGUIDPartitionScheme class definition. + */ + +#ifndef _IOGUIDPARTITIONSCHEME_H +#define _IOGUIDPARTITIONSCHEME_H + +#include + +typedef unsigned char uuid_t[16]; +/* + * kIOGUIDPartitionSchemeClass is the name of the IOGUIDPartitionScheme class. + */ + +#define kIOGUIDPartitionSchemeClass "IOGUIDPartitionScheme" + + +#pragma pack(push, 1) /* (enable 8-bit struct packing) */ + +/* Partition map. */ + +struct gpt_hdr +{ + uint8_t hdr_sig[8]; + uint32_t hdr_revision; + uint32_t hdr_size; + uint32_t hdr_crc_self; + uint32_t __reserved; + uint64_t hdr_lba_self; + uint64_t hdr_lba_alt; + uint64_t hdr_lba_start; + uint64_t hdr_lba_end; + uuid_t hdr_uuid; + uint64_t hdr_lba_table; + uint32_t hdr_entries; + uint32_t hdr_entsz; + uint32_t hdr_crc_table; + uint32_t padding; +}; + +/* Partition map entry. */ + +struct gpt_ent +{ + uuid_t ent_type; + uuid_t ent_uuid; + uint64_t ent_lba_start; + uint64_t ent_lba_end; + uint64_t ent_attr; + uint16_t ent_name[36]; +}; + +/* Partition map signature (hdr_sig). */ + +#define GPT_HDR_SIG "EFI PART" + +/* Partition map version (hdr_revision). */ + +#define GPT_HDR_REVISION 0x00010000 + +/* Partition map entry flags (ent_attr). */ + +#define GPT_ENT_ATTR_PLATFORM 0x00000001 + +#pragma pack(pop) /* (reset to default struct packing) */ + +#ifdef KERNEL +#ifdef __cplusplus + +/* + * Kernel + */ + +#include + +/* + * Class + */ + +class IOGUIDPartitionScheme : public IOPartitionScheme +{ + OSDeclareDefaultStructors(IOGUIDPartitionScheme); + +protected: + + struct ExpansionData { /* */ }; + ExpansionData * _expansionData; + + OSSet * _partitions; /* (set of media objects representing partitions) */ + + /* + * Free all of this object's outstanding resources. + */ + + virtual void free(void); + + /* + * Scan the provider media for a GUID partition map. Returns the set + * of media objects representing each of the partitions (the retain for + * the set is passed to the caller), or null should no partition map be + * found. The default probe score can be adjusted up or down, based on + * the confidence of the scan. + */ + + virtual OSSet * scan(SInt32 * score); + + /* + * Ask whether the given partition is used. + */ + + virtual bool isPartitionUsed(gpt_ent * partition); + + /* + * Ask whether the given partition appears to be corrupt. A partition that + * is corrupt will cause the failure of the GUID partition map recognition + * altogether. + */ + + virtual bool isPartitionCorrupt( gpt_ent * partition, + UInt32 partitionID ); + + /* + * Ask whether the given partition appears to be invalid. A partition that + * is invalid will cause it to be skipped in the scan, but will not cause a + * failure of the GUID partition map recognition. + */ + + virtual bool isPartitionInvalid( gpt_ent * partition, + UInt32 partitionID ); + + /* + * Instantiate a new media object to represent the given partition. + */ + + virtual IOMedia * instantiateMediaObject( gpt_ent * partition, + UInt32 partitionID ); + + /* + * Allocate a new media object (called from instantiateMediaObject). + */ + + virtual IOMedia * instantiateDesiredMediaObject( gpt_ent * partition, + UInt32 partitionID ); + +#ifndef __LP64__ + /* + * Attach the given media object to the device tree plane. + */ + + virtual bool attachMediaObjectToDeviceTree(IOMedia * media) __attribute__ ((deprecated)); + + /* + * Detach the given media object from the device tree plane. + */ + + virtual void detachMediaObjectFromDeviceTree(IOMedia * media) __attribute__ ((deprecated)); +#endif /* !__LP64__ */ + +public: + + /* + * Initialize this object's minimal state. + */ + + virtual bool init(OSDictionary * properties = 0); + + /* + * Determine whether the provider media contains a GUID partition map. + */ + + virtual IOService * probe(IOService * provider, SInt32 * score); + + /* + * Publish the new media objects which represent our partitions. + */ + + virtual bool start(IOService * provider); + + /* + * Clean up after the media objects we published before terminating. + */ + + virtual void stop(IOService * provider); + + /* + * Request that the provider media be re-scanned for partitions. + */ + + virtual IOReturn requestProbe(IOOptionBits options); + + OSMetaClassDeclareReservedUnused(IOGUIDPartitionScheme, 0); + OSMetaClassDeclareReservedUnused(IOGUIDPartitionScheme, 1); + OSMetaClassDeclareReservedUnused(IOGUIDPartitionScheme, 2); + OSMetaClassDeclareReservedUnused(IOGUIDPartitionScheme, 3); + OSMetaClassDeclareReservedUnused(IOGUIDPartitionScheme, 4); + OSMetaClassDeclareReservedUnused(IOGUIDPartitionScheme, 5); + OSMetaClassDeclareReservedUnused(IOGUIDPartitionScheme, 6); + OSMetaClassDeclareReservedUnused(IOGUIDPartitionScheme, 7); + OSMetaClassDeclareReservedUnused(IOGUIDPartitionScheme, 8); + OSMetaClassDeclareReservedUnused(IOGUIDPartitionScheme, 9); + OSMetaClassDeclareReservedUnused(IOGUIDPartitionScheme, 10); + OSMetaClassDeclareReservedUnused(IOGUIDPartitionScheme, 11); + OSMetaClassDeclareReservedUnused(IOGUIDPartitionScheme, 12); + OSMetaClassDeclareReservedUnused(IOGUIDPartitionScheme, 13); + OSMetaClassDeclareReservedUnused(IOGUIDPartitionScheme, 14); + OSMetaClassDeclareReservedUnused(IOGUIDPartitionScheme, 15); +}; + +#endif /* __cplusplus */ +#endif /* KERNEL */ +#endif /* !_IOGUIDPARTITIONSCHEME_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/storage/IOFilterScheme.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/storage/IOFilterScheme.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/storage/IOFilterScheme.h (revision 885) @@ -0,0 +1,289 @@ +/* + * 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 IOFilterScheme + * @abstract + * This header contains the IOFilterScheme class definition. + */ + +#ifndef _IOFILTERSCHEME_H +#define _IOFILTERSCHEME_H + +/*! + * @defined kIOFilterSchemeClass + * @abstract + * The name of the IOFilterScheme class. + * @discussion + * kIOFilterSchemeClass is the name of the IOFilterScheme class. + */ + +#define kIOFilterSchemeClass "IOFilterScheme" + +#ifdef KERNEL +#ifdef __cplusplus + +/* + * Kernel + */ + +#include +#include + +/*! + * @class IOFilterScheme + * @abstract + * The common base class for all filter scheme + * objects. + * @discussion + * The IOFilterScheme class is the common base class for all filter scheme + * objects. It extends the IOStorage class by implementing the appropriate + * open and close semantics for filter objects (standard semantics are act + * as a relay for incoming opens, producing one outgoing open for each + * incoming open). It also implements the default read and write semantics, + * which pass all reads and writes through to the provider media unprocessed. + * For simple schemes, the default behavior is sufficient. More complex + * filter schemes such as RAID will want to do extra processing for reads + * and writes. + */ + +class IOFilterScheme : public IOStorage +{ + OSDeclareDefaultStructors(IOFilterScheme); + +protected: + + struct ExpansionData { /* */ }; + ExpansionData * _expansionData; + + /*! + * @function handleOpen + * @discussion + * The handleOpen method grants or denies permission to access this object + * to an interested client. The argument is an IOStorageAccess value that + * specifies the level of access desired -- reader or reader-writer. + * + * This method can be invoked to upgrade or downgrade the access level for + * an existing client as well. The previous access level will prevail for + * upgrades that fail, of course. A downgrade should never fail. If the + * new access level should be the same as the old for a given client, this + * method will do nothing and return success. In all cases, one, singular + * close-per-client is expected for all opens-per-client received. + * + * This implementation replaces the IOService definition of handleOpen(). + * @param client + * Client requesting the open. + * @param options + * Options for the open. Set to zero. + * @param access + * Access level for the open. Set to kIOStorageAccessReader or + * kIOStorageAccessReaderWriter. + * @result + * Returns true if the open was successful, false otherwise. + */ + + virtual bool handleOpen(IOService * client, + IOOptionBits options, + void * access); + + /*! + * @function handleIsOpen + * @discussion + * The handleIsOpen method determines whether the specified client, or any + * client if none is specified, presently has an open on this object. + * + * This implementation replaces the IOService definition of handleIsOpen(). + * @param client + * Client to check the open state of. Set to zero to check the open state + * of all clients. + * @result + * Returns true if the client was (or clients were) open, false otherwise. + */ + + virtual bool handleIsOpen(const IOService * client) const; + + /*! + * @function handleClose + * @discussion + * The handleClose method closes the client's access to this object. + * + * This implementation replaces the IOService definition of handleClose(). + * @param client + * Client requesting the close. + * @param options + * Options for the close. Set to zero. + */ + + virtual void handleClose(IOService * client, IOOptionBits options); + +public: + + using IOStorage::read; + using IOStorage::write; + + /*! + * @function read + * @discussion + * Read data from the storage object at the specified byte offset into the + * specified buffer, asynchronously. When the read completes, the caller + * will be notified via the specified completion action. + * + * The buffer will be retained for the duration of the read. + * + * For simple filter schemes, the default behavior is to simply pass the + * read through to the provider media. More complex filter schemes such + * as RAID will need to do extra processing here. + * @param client + * Client requesting the read. + * @param byteStart + * Starting byte offset for the data transfer. + * @param buffer + * Buffer for the data transfer. The size of the buffer implies the size of + * the data transfer. + * @param attributes + * Attributes of the data transfer. See IOStorageAttributes. It is the + * responsibility of the callee to maintain the information for the duration + * of the data transfer, as necessary. + * @param completion + * Completion routine to call once the data transfer is complete. It is the + * responsibility of the callee to maintain the information for the duration + * of the data transfer, as necessary. + */ + + virtual void read(IOService * client, + UInt64 byteStart, + IOMemoryDescriptor * buffer, + IOStorageAttributes * attributes, + IOStorageCompletion * completion); + + /*! + * @function write + * @discussion + * Write data into the storage object at the specified byte offset from the + * specified buffer, asynchronously. When the write completes, the caller + * will be notified via the specified completion action. + * + * The buffer will be retained for the duration of the write. + * + * For simple filter schemes, the default behavior is to simply pass the + * write through to the provider media. More complex filter schemes such + * as RAID will need to do extra processing here. + * @param client + * Client requesting the write. + * @param byteStart + * Starting byte offset for the data transfer. + * @param buffer + * Buffer for the data transfer. The size of the buffer implies the size of + * the data transfer. + * @param attributes + * Attributes of the data transfer. See IOStorageAttributes. It is the + * responsibility of the callee to maintain the information for the duration + * of the data transfer, as necessary. + * @param completion + * Completion routine to call once the data transfer is complete. It is the + * responsibility of the callee to maintain the information for the duration + * of the data transfer, as necessary. + */ + + virtual void write(IOService * client, + UInt64 byteStart, + IOMemoryDescriptor * buffer, + IOStorageAttributes * attributes, + IOStorageCompletion * completion); + + /*! + * @function synchronizeCache + * @discussion + * Flush the cached data in the storage object, if any, synchronously. + * @param client + * Client requesting the cache synchronization. + * @result + * Returns the status of the cache synchronization. + */ + + virtual IOReturn synchronizeCache(IOService * client); + + /*! + * @function discard + * @discussion + * Delete unused data from the storage object at the specified byte offset, + * synchronously. + * @param client + * Client requesting the operation. + * @param byteStart + * Starting byte offset for the operation. + * @param byteCount + * Size of the operation. + * @result + * Returns the status of the operation. + */ + + virtual IOReturn discard(IOService * client, + UInt64 byteStart, + UInt64 byteCount); + + /* + * Obtain this object's provider. We override the superclass's method + * to return a more specific subclass of OSObject -- an IOMedia. This + * method serves simply as a convenience to subclass developers. + */ + + virtual IOMedia * getProvider() const; + + OSMetaClassDeclareReservedUnused(IOFilterScheme, 0); + OSMetaClassDeclareReservedUnused(IOFilterScheme, 1); + OSMetaClassDeclareReservedUnused(IOFilterScheme, 2); + OSMetaClassDeclareReservedUnused(IOFilterScheme, 3); + OSMetaClassDeclareReservedUnused(IOFilterScheme, 4); + OSMetaClassDeclareReservedUnused(IOFilterScheme, 5); + OSMetaClassDeclareReservedUnused(IOFilterScheme, 6); + OSMetaClassDeclareReservedUnused(IOFilterScheme, 7); + OSMetaClassDeclareReservedUnused(IOFilterScheme, 8); + OSMetaClassDeclareReservedUnused(IOFilterScheme, 9); + OSMetaClassDeclareReservedUnused(IOFilterScheme, 10); + OSMetaClassDeclareReservedUnused(IOFilterScheme, 11); + OSMetaClassDeclareReservedUnused(IOFilterScheme, 12); + OSMetaClassDeclareReservedUnused(IOFilterScheme, 13); + OSMetaClassDeclareReservedUnused(IOFilterScheme, 14); + OSMetaClassDeclareReservedUnused(IOFilterScheme, 15); + OSMetaClassDeclareReservedUnused(IOFilterScheme, 16); + OSMetaClassDeclareReservedUnused(IOFilterScheme, 17); + OSMetaClassDeclareReservedUnused(IOFilterScheme, 18); + OSMetaClassDeclareReservedUnused(IOFilterScheme, 19); + OSMetaClassDeclareReservedUnused(IOFilterScheme, 20); + OSMetaClassDeclareReservedUnused(IOFilterScheme, 21); + OSMetaClassDeclareReservedUnused(IOFilterScheme, 22); + OSMetaClassDeclareReservedUnused(IOFilterScheme, 23); + OSMetaClassDeclareReservedUnused(IOFilterScheme, 24); + OSMetaClassDeclareReservedUnused(IOFilterScheme, 25); + OSMetaClassDeclareReservedUnused(IOFilterScheme, 26); + OSMetaClassDeclareReservedUnused(IOFilterScheme, 27); + OSMetaClassDeclareReservedUnused(IOFilterScheme, 28); + OSMetaClassDeclareReservedUnused(IOFilterScheme, 29); + OSMetaClassDeclareReservedUnused(IOFilterScheme, 30); + OSMetaClassDeclareReservedUnused(IOFilterScheme, 31); +}; + +#endif /* __cplusplus */ +#endif /* KERNEL */ +#endif /* !_IOFILTERSCHEME_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/storage/IOBDTypes.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/storage/IOBDTypes.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/storage/IOBDTypes.h (revision 885) @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2006-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 _BDTYPES_H +#define _BDTYPES_H + +#include + +#pragma pack(push, 1) /* (enable 8-bit struct packing) */ + +/* + * Media Types + */ + +enum +{ + kBDMediaTypeUnknown = 0x0300, + kBDMediaTypeROM = 0x0302, /* BD-ROM */ + kBDMediaTypeRE = 0x0303, /* BD-RE */ + kBDMediaTypeR = 0x0304, /* BD-R */ + + kBDMediaTypeMin = 0x0300, + kBDMediaTypeMax = 0x03FF +}; + +typedef UInt32 BDMediaType; + +/* + * Media Speed (kB/s) + */ + +#define kBDSpeedMin 0x1126 +#define kBDSpeedMax 0xFFFF + +/* + * MMC Formats + */ + +// Read Disc Information Format +struct BDDiscInfo +{ + UInt16 dataLength; +#ifdef __LITTLE_ENDIAN__ + UInt8 discStatus:2; + UInt8 stateOfLastSession:2; + UInt8 erasable:1; + UInt8 dataType:3; +#else /* !__LITTLE_ENDIAN__ */ + UInt8 dataType:3; + UInt8 erasable:1; + UInt8 stateOfLastSession:2; + UInt8 discStatus:2; +#endif /* !__LITTLE_ENDIAN__ */ + UInt8 reserved2; + UInt8 numberOfSessionsLSB; + UInt8 firstTrackNumberInLastSessionLSB; + UInt8 lastTrackNumberInLastSessionLSB; + UInt8 reserved4[2]; + UInt8 numberOfSessionsMSB; + UInt8 firstTrackNumberInLastSessionMSB; + UInt8 lastTrackNumberInLastSessionMSB; + UInt8 reserved6[22]; +}; +typedef struct BDDiscInfo BDDiscInfo; + +// Read Track Information Format +struct BDTrackInfo +{ + UInt16 dataLength; + UInt8 trackNumberLSB; + UInt8 sessionNumberLSB; + UInt8 reserved; +#ifdef __LITTLE_ENDIAN__ + UInt8 reserved2:5; + UInt8 damage:1; + UInt8 reserved3:2; + + UInt8 reserved4:6; + UInt8 blank:1; + UInt8 reservedTrack:1; + + UInt8 nextWritableAddressValid:1; + UInt8 lastRecordedAddressValid:1; + UInt8 reserved5:6; +#else /* !__LITTLE_ENDIAN__ */ + UInt8 reserved3:2; + UInt8 damage:1; + UInt8 reserved2:5; + + UInt8 reservedTrack:1; + UInt8 blank:1; + UInt8 reserved4:6; + + UInt8 reserved5:6; + UInt8 lastRecordedAddressValid:1; + UInt8 nextWritableAddressValid:1; +#endif /* !__LITTLE_ENDIAN__ */ + UInt32 trackStartAddress; + UInt32 nextWritableAddress; + UInt32 freeBlocks; + UInt32 clusterSize; + UInt32 trackSize; + UInt32 lastRecordedAddress; + UInt8 trackNumberMSB; + UInt8 sessionNumberMSB; + UInt8 reserved6; + UInt8 reserved7; +}; +typedef struct BDTrackInfo BDTrackInfo; + +#pragma pack(pop) /* (reset to default struct packing) */ + +#endif /* _BDTYPES_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/storage/IOCDTypes.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/storage/IOCDTypes.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/storage/IOCDTypes.h (revision 885) @@ -0,0 +1,492 @@ +/* + * 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 _IOCDTYPES_H +#define _IOCDTYPES_H + +#include +#include + +#pragma pack(push, 1) /* (enable 8-bit struct packing) */ + +/* + * Minutes, Seconds, Frames (M:S:F) + * + * All M:S:F values passed across I/O Kit APIs are guaranteed to be + * binary-encoded numbers (no BCD-encoded numbers are ever passed). + */ + +typedef struct +{ + UInt8 minute; + UInt8 second; + UInt8 frame; +} CDMSF; + +/* + * Media Catalogue Numbers (MCN), International Standard Recording Codes (ISRC) + * + * All MCN and ISRC values passed across I/O Kit APIs are guaranteed + * to have a zero-terminating byte, for convenient use as C strings. + */ + +#define kCDMCNMaxLength 13 +#define kCDISRCMaxLength 12 + +typedef char CDMCN [kCDMCNMaxLength + 1]; +typedef char CDISRC[kCDISRCMaxLength + 1]; + +/* + * Audio Status + * + * All CDAudioStatus fields passed across I/O Kit APIs are guaranteed to + * be binary-encoded numbers (no BCD-encoded numbers are ever passed). + */ + +#define kCDAudioStatusUnsupported 0x00 +#define kCDAudioStatusActive 0x11 +#define kCDAudioStatusPaused 0x12 +#define kCDAudioStatusSuccess 0x13 +#define kCDAudioStatusFailure 0x14 +#define kCDAudioStatusNone 0x15 + +typedef struct +{ + UInt8 status; + struct + { + CDMSF time; + struct + { + UInt8 index; + UInt8 number; + CDMSF time; + } track; + } position; +} CDAudioStatus; + +/* + * Table Of Contents + * + * All CDTOC fields passed across I/O Kit APIs are guaranteed to be + * binary-encoded numbers (no BCD-encoded numbers are ever passed). + */ + +typedef struct +{ + UInt8 session; +#ifdef __LITTLE_ENDIAN__ + UInt8 control:4, adr:4; +#else /* !__LITTLE_ENDIAN__ */ + UInt8 adr:4, control:4; +#endif /* !__LITTLE_ENDIAN__ */ + UInt8 tno; + UInt8 point; + CDMSF address; + UInt8 zero; + CDMSF p; +} CDTOCDescriptor; + +typedef struct +{ + UInt16 length; + UInt8 sessionFirst; + UInt8 sessionLast; + CDTOCDescriptor descriptors[0]; +} CDTOC; + +/* + * Table Of Contents Descriptor Count Convenience Function + */ + +static inline UInt32 CDTOCGetDescriptorCount(CDTOC * toc) +{ + UInt32 tocSize = OSSwapBigToHostInt16(toc->length) + (UInt32) sizeof(toc->length); + + return (tocSize < (UInt32) sizeof(CDTOC)) ? 0 : + (tocSize - (UInt32) sizeof(CDTOC)) / (UInt32) sizeof(CDTOCDescriptor); +} + +/* + * M:S:F To LBA Convenience Function + */ + +static inline UInt32 CDConvertMSFToLBA(CDMSF msf) +{ + return (((msf.minute * 60U) + msf.second) * 75U) + msf.frame - 150U; +} + +/* + * M:S:F To Clipped LBA Convenience Function + */ + +static inline UInt32 CDConvertMSFToClippedLBA(CDMSF msf) +{ + return (msf.minute == 0 && msf.second <= 1) ? 0 : CDConvertMSFToLBA(msf); +} + +/* + * LBA To M:S:F Convenience Function + */ + +static inline CDMSF CDConvertLBAToMSF(UInt32 lba) +{ + CDMSF msf; + + lba += 150; + msf.minute = (lba / (75 * 60)); + msf.second = (lba % (75 * 60)) / 75; + msf.frame = (lba % (75 )); + + return msf; +} + +/* + * Track Number To M:S:F Convenience Function + * + * The CDTOC structure is assumed to be complete, that is, none of + * the descriptors are missing or clipped due to an insufficiently + * sized buffer holding the CDTOC contents. + */ + +static inline CDMSF CDConvertTrackNumberToMSF(UInt8 track, CDTOC * toc) +{ + UInt32 count = CDTOCGetDescriptorCount(toc); + UInt32 i; + CDMSF msf = { 0xFF, 0xFF, 0xFF }; + + for (i = 0; i < count; i++) + { + if (toc->descriptors[i].point == track && toc->descriptors[i].adr == 1) + { + msf = toc->descriptors[i].p; + break; + } + } + + return msf; +} + +/* + * Sector Areas, Sector Types + * + * Bytes Per Type CDDA Mode1 Mode2 Mode2Form1 Mode2Form2 + * Per Area +----------+----------+----------+----------+----------+ + * Sync | 0 | 12 | 12 | 12 | 12 | + * Header | 0 | 4 | 4 | 4 | 4 | + * SubHeader | 0 | 0 | 0 | 8 | 8 | + * User | 2352 | 2048 | 2336 | 2048 | 2328 | + * Auxiliary | 0 | 288 | 0 | 280 | 0 | + * ErrorFlags | 294 | 294 | 294 | 294 | 294 | + * SubChannel | 96 | 96 | 96 | 96 | 96 | + * SubChannelQ | 16 | 16 | 16 | 16 | 16 | + * +----------+----------+----------+----------+----------+ + */ + +typedef enum +{ + kCDSectorAreaSync = 0x80, + kCDSectorAreaHeader = 0x20, + kCDSectorAreaSubHeader = 0x40, + kCDSectorAreaUser = 0x10, + kCDSectorAreaAuxiliary = 0x08, + kCDSectorAreaErrorFlags = 0x02, + kCDSectorAreaSubChannel = 0x01, + kCDSectorAreaSubChannelQ = 0x04 +} CDSectorArea; + +typedef enum +{ + kCDSectorTypeUnknown = 0x00, + kCDSectorTypeCDDA = 0x01, + kCDSectorTypeMode1 = 0x02, + kCDSectorTypeMode2 = 0x03, + kCDSectorTypeMode2Form1 = 0x04, + kCDSectorTypeMode2Form2 = 0x05, + kCDSectorTypeCount = 0x06 +} CDSectorType; + +typedef enum +{ + kCDSectorSizeCDDA = 2352, + kCDSectorSizeMode1 = 2048, + kCDSectorSizeMode2 = 2336, + kCDSectorSizeMode2Form1 = 2048, + kCDSectorSizeMode2Form2 = 2328, + kCDSectorSizeWhole = 2352 +} CDSectorSize; + +/* + * Media Types + */ + +typedef enum +{ + kCDMediaTypeUnknown = 0x0100, + kCDMediaTypeROM = 0x0102, /* CD-ROM */ + kCDMediaTypeR = 0x0104, /* CD-R */ + kCDMediaTypeRW = 0x0105, /* CD-RW */ + + kCDMediaTypeMin = 0x0100, + kCDMediaTypeMax = 0x01FF +}; + +typedef UInt32 CDMediaType; + +/* + * Media Speed (kB/s) + */ + +#define kCDSpeedMin 0x00B0 +#define kCDSpeedMax 0xFFFF + +/* + * MMC Formats + */ + +// Read Table Of Contents Format Types +typedef UInt8 CDTOCFormat; +enum +{ + kCDTOCFormatTOC = 0x02, // CDTOC + kCDTOCFormatPMA = 0x03, // CDPMA + kCDTOCFormatATIP = 0x04, // CDATIP + kCDTOCFormatTEXT = 0x05 // CDTEXT +}; + +// Read Table Of Contents Format 0x03 +struct CDPMADescriptor +{ + UInt8 reserved; +#ifdef __LITTLE_ENDIAN__ + UInt8 control:4, adr:4; +#else /* !__LITTLE_ENDIAN__ */ + UInt8 adr:4, control:4; +#endif /* !__LITTLE_ENDIAN__ */ + UInt8 tno; + UInt8 point; + CDMSF address; + UInt8 zero; + CDMSF p; +}; +typedef struct CDPMADescriptor CDPMADescriptor; + +struct CDPMA +{ + UInt16 dataLength; + UInt8 reserved; + UInt8 reserved2; + CDPMADescriptor descriptors[0]; +}; +typedef struct CDPMA CDPMA; + +// Read Table Of Contents Format 0x04 +struct CDATIP +{ + UInt16 dataLength; + UInt8 reserved[2]; +#ifdef __LITTLE_ENDIAN__ + UInt8 referenceSpeed:3; + UInt8 reserved3:1; + UInt8 indicativeTargetWritingPower:3; + UInt8 reserved2:1; + + UInt8 reserved5:6; + UInt8 unrestrictedUse:1; + UInt8 reserved4:1; + + UInt8 a3Valid:1; + UInt8 a2Valid:1; + UInt8 a1Valid:1; + UInt8 discSubType:3; + UInt8 discType:1; + UInt8 reserved6:1; +#else /* !__LITTLE_ENDIAN__ */ + UInt8 reserved2:1; + UInt8 indicativeTargetWritingPower:3; + UInt8 reserved3:1; + UInt8 referenceSpeed:3; + + UInt8 reserved4:1; + UInt8 unrestrictedUse:1; + UInt8 reserved5:6; + + UInt8 reserved6:1; + UInt8 discType:1; + UInt8 discSubType:3; + UInt8 a1Valid:1; + UInt8 a2Valid:1; + UInt8 a3Valid:1; +#endif /* !__LITTLE_ENDIAN__ */ + UInt8 reserved7; + CDMSF startTimeOfLeadIn; + UInt8 reserved8; + CDMSF lastPossibleStartTimeOfLeadOut; + UInt8 reserved9; + UInt8 a1[3]; + UInt8 reserved10; + UInt8 a2[3]; + UInt8 reserved11; + UInt8 a3[3]; + UInt8 reserved12; +}; +typedef struct CDATIP CDATIP; + +// Read Table Of Contents Format 0x05 +struct CDTEXTDescriptor +{ + UInt8 packType; + UInt8 trackNumber; + UInt8 sequenceNumber; +#ifdef __LITTLE_ENDIAN__ + UInt8 characterPosition:4; + UInt8 blockNumber:3; + UInt8 doubleByteCharacterCode:1; +#else /* !__LITTLE_ENDIAN__ */ + UInt8 doubleByteCharacterCode:1; + UInt8 blockNumber:3; + UInt8 characterPosition:4; +#endif /* !__LITTLE_ENDIAN__ */ + UInt8 textData[12]; + UInt8 reserved[2]; +}; +typedef struct CDTEXTDescriptor CDTEXTDescriptor; + +struct CDTEXT +{ + UInt16 dataLength; + UInt8 reserved; + UInt8 reserved2; + CDTEXTDescriptor descriptors[0]; +}; +typedef struct CDTEXT CDTEXT; + +// Read Disc Information Format +struct CDDiscInfo +{ + UInt16 dataLength; +#ifdef __LITTLE_ENDIAN__ + UInt8 discStatus:2; + UInt8 stateOfLastSession:2; + UInt8 erasable:1; + UInt8 reserved:3; +#else /* !__LITTLE_ENDIAN__ */ + UInt8 reserved:3; + UInt8 erasable:1; + UInt8 stateOfLastSession:2; + UInt8 discStatus:2; +#endif /* !__LITTLE_ENDIAN__ */ + UInt8 numberOfFirstTrack; + UInt8 numberOfSessionsLSB; + UInt8 firstTrackNumberInLastSessionLSB; + UInt8 lastTrackNumberInLastSessionLSB; +#ifdef __LITTLE_ENDIAN__ + UInt8 reserved3:5; + UInt8 unrestrictedUse:1; + UInt8 discBarCodeValid:1; + UInt8 discIdentificationValid:1; +#else /* !__LITTLE_ENDIAN__ */ + UInt8 discIdentificationValid:1; + UInt8 discBarCodeValid:1; + UInt8 unrestrictedUse:1; + UInt8 reserved3:5; +#endif /* !__LITTLE_ENDIAN__ */ + UInt8 discType; + UInt8 numberOfSessionsMSB; + UInt8 firstTrackNumberInLastSessionMSB; + UInt8 lastTrackNumberInLastSessionMSB; + UInt32 discIdentification; + UInt8 reserved7; + CDMSF lastSessionLeadInStartTime; + UInt8 reserved8; + CDMSF lastPossibleStartTimeOfLeadOut; + UInt8 discBarCode[8]; + UInt8 reserved9; + UInt8 numberOfOPCTableEntries; + UInt8 opcTableEntries[0]; +}; +typedef struct CDDiscInfo CDDiscInfo; + +// Read Track Information Address Types +typedef UInt8 CDTrackInfoAddressType; +enum +{ + kCDTrackInfoAddressTypeLBA = 0x00, + kCDTrackInfoAddressTypeTrackNumber = 0x01, + kCDTrackInfoAddressTypeSessionNumber = 0x02, +}; + +// Read Track Information Format +struct CDTrackInfo +{ + UInt16 dataLength; + UInt8 trackNumberLSB; + UInt8 sessionNumberLSB; + UInt8 reserved; +#ifdef __LITTLE_ENDIAN__ + UInt8 trackMode:4; + UInt8 copy:1; + UInt8 damage:1; + UInt8 reserved3:2; + + UInt8 dataMode:4; + UInt8 fixedPacket:1; + UInt8 packet:1; + UInt8 blank:1; + UInt8 reservedTrack:1; + + UInt8 nextWritableAddressValid:1; + UInt8 lastRecordedAddressValid:1; + UInt8 reserved5:6; +#else /* !__LITTLE_ENDIAN__ */ + UInt8 reserved3:2; + UInt8 damage:1; + UInt8 copy:1; + UInt8 trackMode:4; + + UInt8 reservedTrack:1; + UInt8 blank:1; + UInt8 packet:1; + UInt8 fixedPacket:1; + UInt8 dataMode:4; + + UInt8 reserved5:6; + UInt8 lastRecordedAddressValid:1; + UInt8 nextWritableAddressValid:1; +#endif /* !__LITTLE_ENDIAN__ */ + UInt32 trackStartAddress; + UInt32 nextWritableAddress; + UInt32 freeBlocks; + UInt32 fixedPacketSize; + UInt32 trackSize; + UInt32 lastRecordedAddress; + UInt8 trackNumberMSB; + UInt8 sessionNumberMSB; + UInt8 reserved6; + UInt8 reserved7; +}; +typedef struct CDTrackInfo CDTrackInfo; + +#pragma pack(pop) /* (reset to default struct packing) */ + +#endif /* _IOCDTYPES_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/storage/IODVDMedia.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/storage/IODVDMedia.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/storage/IODVDMedia.h (revision 885) @@ -0,0 +1,357 @@ +/* + * 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 IODVDMedia + * @abstract + * This header contains the IODVDMedia class definition. + */ + +#ifndef _IODVDMEDIA_H +#define _IODVDMEDIA_H + +/*! + * @defined kIODVDMediaClass + * @abstract + * kIODVDMediaClass is the name of the IODVDMedia class. + * @discussion + * kIODVDMediaClass is the name of the IODVDMedia class. + */ + +#define kIODVDMediaClass "IODVDMedia" + +/*! + * @defined kIODVDMediaTypeKey + * @abstract + * kIODVDMediaTypeKey is a property of IODVDMedia objects. It has an OSString + * value. + * @discussion + * The kIODVDMediaTypeKey property identifies the DVD media type (DVD-ROM, + * DVD-R, DVD-RW, DVD+RW, DVD-RAM, etc). See the kIODVDMediaType contants + * for possible values. + */ + +#define kIODVDMediaTypeKey "Type" + +/*! + * @defined kIODVDMediaTypeROM + * The kIODVDMediaTypeKey constant for DVD-ROM media. + */ + +#define kIODVDMediaTypeROM "DVD-ROM" + +/*! + * @defined kIODVDMediaTypeR + * The kIODVDMediaTypeKey constant for DVD Recordable (DVD-R) media. + */ + +#define kIODVDMediaTypeR "DVD-R" + +/*! + * @defined kIODVDMediaTypeRW + * The kIODVDMediaTypeKey constant for DVD ReWritable (DVD-RW) media. + */ + +#define kIODVDMediaTypeRW "DVD-RW" + +/*! + * @defined kIODVDMediaTypePlusR + * The kIODVDMediaTypeKey constant for DVD "Plus" Recordable (DVD+R) media. + */ + +#define kIODVDMediaTypePlusR "DVD+R" + +/*! + * @defined kIODVDMediaTypePlusRW + * The kIODVDMediaTypeKey constant for DVD "Plus" ReWritable (DVD+RW) media. + */ + +#define kIODVDMediaTypePlusRW "DVD+RW" + +/*! + * @defined kIODVDMediaTypeRAM + * The kIODVDMediaTypeKey constant for DVD-RAM media. + */ + +#define kIODVDMediaTypeRAM "DVD-RAM" + +/*! + * @defined kIODVDMediaTypeHDROM + * The kIODVDMediaTypeKey constant for HD DVD-ROM media. + */ + +#define kIODVDMediaTypeHDROM "HD DVD-ROM" + +/*! + * @defined kIODVDMediaTypeHDR + * The kIODVDMediaTypeKey constant for HD DVD Recordable (HD DVD-R) media. + */ + +#define kIODVDMediaTypeHDR "HD DVD-R" + +/*! + * @defined kIODVDMediaTypeHDRW + * The kIODVDMediaTypeKey constant for HD DVD ReWritable (HD DVD-RW) media. + */ + +#define kIODVDMediaTypeHDRW "HD DVD-RW" + +/*! + * @defined kIODVDMediaTypeHDRAM + * The kIODVDMediaTypeKey constant for HD DVD-RAM media. + */ + +#define kIODVDMediaTypeHDRAM "HD DVD-RAM" + +#ifdef KERNEL +#ifdef __cplusplus + +/* + * Kernel + */ + +#include +#include + +/*! + * @class IODVDMedia + * @abstract + * The IODVDMedia class is a random-access disk device abstraction for DVDs. + * @discussion + * The IODVDMedia class is a random-access disk device abstraction for DVDs. + */ + +class IODVDMedia : public IOMedia +{ + OSDeclareDefaultStructors(IODVDMedia) + +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 -- IODVDBlockStorageDriver. + * This method serves simply as a convenience to subclass developers. + */ + + virtual IODVDBlockStorageDriver * getProvider() const; + + /* + * Compare the properties in the supplied table to this object's properties. + */ + + virtual bool matchPropertyTable(OSDictionary * table, SInt32 * score); + + /*! + * @function reportKey + * @discussion + * Issue an MMC REPORT KEY command. + * @param buffer + * Buffer for the data transfer. The size of the buffer implies the size of + * the data transfer. Pass null for the kDVDKeyFormatAGID_Invalidate format + * case. + * @param keyClass + * As documented by MMC. + * @param address + * As documented by MMC. + * @param grantID + * As documented by MMC. + * @param format + * As documented by MMC. + * @result + * Returns the status of the data transfer. + */ + + virtual IOReturn reportKey( IOMemoryDescriptor * buffer, + const DVDKeyClass keyClass, + const UInt32 address, + const UInt8 grantID, + const DVDKeyFormat format ); /* 10.1.0 */ + + /*! + * @function sendKey + * @discussion + * Issue an MMC SEND KEY command. + * @param buffer + * Buffer for the data transfer. The size of the buffer implies the size of + * the data transfer. Pass null for the kDVDKeyFormatAGID_Invalidate format + * case. + * @param keyClass + * As documented by MMC. + * @param grantID + * As documented by MMC. + * @param format + * As documented by MMC. + * @result + * Returns the status of the data transfer. + */ + + virtual IOReturn sendKey( IOMemoryDescriptor * buffer, + const DVDKeyClass keyClass, + const UInt8 grantID, + const DVDKeyFormat format ); /* 10.1.0 */ + + /*! + * @function readStructure + * @discussion + * Issue an MMC READ DVD STRUCTURE command. + * @param buffer + * Buffer for the data transfer. The size of the buffer implies the size of + * the data transfer. + * @param format + * As documented by MMC. + * @param address + * As documented by MMC. + * @param layer + * As documented by MMC. + * @param grantID + * As documented by MMC. + * @result + * Returns the status of the data transfer. + */ + + virtual IOReturn readStructure( IOMemoryDescriptor * buffer, + const DVDStructureFormat format, + const UInt32 address, + const UInt8 layer, + const UInt8 grantID ); /* 10.1.0 */ + + /*! + * @function getSpeed + * @discussion + * Get the current speed used for data transfers. + * @param kilobytesPerSecond + * Returns the current speed used for data transfers, in kB/s. + * + * kDVDSpeedMin specifies the minimum speed for all DVD media (1X). + * kDVDSpeedMax specifies the maximum speed supported in hardware. + * @result + * Returns the status of the operation. + */ + + virtual IOReturn getSpeed(UInt16 * kilobytesPerSecond); /* 10.1.0 */ + + /*! + * @function setSpeed + * @discussion + * Set the speed to be used for data transfers. + * @param kilobytesPerSecond + * Speed to be used for data transfers, in kB/s. + * + * kDVDSpeedMin specifies the minimum speed for all DVD media (1X). + * kDVDSpeedMax specifies the maximum speed supported in hardware. + * @result + * Returns the status of the operation. + */ + + virtual IOReturn setSpeed(UInt16 kilobytesPerSecond); /* 10.1.0 */ + + /*! + * @function readDiscInfo + * @discussion + * Issue an MMC READ DISC INFORMATION command. + * @param buffer + * Buffer for the data transfer. The size of the buffer implies the size of + * the data transfer. + * @param actualByteCount + * Returns the actual number of bytes transferred in the data transfer. + * @result + * Returns the status of the data transfer. + */ + + virtual IOReturn readDiscInfo( IOMemoryDescriptor * buffer, + UInt16 * actualByteCount ); /* 10.2.0 */ + + /*! + * @function readRZoneInfo + * @discussion + * Issue an MMC READ RZONE INFORMATION (READ TRACK INFORMATION) command. + * @param buffer + * Buffer for the data transfer. The size of the buffer implies the size of + * the data transfer. + * @param address + * As documented by MMC. + * @param addressType + * As documented by MMC. + * @param actualByteCount + * Returns the actual number of bytes transferred in the data transfer. + * @result + * Returns the status of the data transfer. + */ + + virtual IOReturn readRZoneInfo( IOMemoryDescriptor * buffer, + UInt32 address, + DVDRZoneInfoAddressType addressType, + UInt16 * actualByteCount ); /* 10.2.0 */ + +#ifdef __LP64__ + OSMetaClassDeclareReservedUnused(IODVDMedia, 0); + OSMetaClassDeclareReservedUnused(IODVDMedia, 1); + OSMetaClassDeclareReservedUnused(IODVDMedia, 2); + OSMetaClassDeclareReservedUnused(IODVDMedia, 3); + OSMetaClassDeclareReservedUnused(IODVDMedia, 4); + OSMetaClassDeclareReservedUnused(IODVDMedia, 5); + OSMetaClassDeclareReservedUnused(IODVDMedia, 6); +#else /* !__LP64__ */ + OSMetaClassDeclareReservedUsed(IODVDMedia, 0); + OSMetaClassDeclareReservedUsed(IODVDMedia, 1); + OSMetaClassDeclareReservedUsed(IODVDMedia, 2); + OSMetaClassDeclareReservedUsed(IODVDMedia, 3); + OSMetaClassDeclareReservedUsed(IODVDMedia, 4); + OSMetaClassDeclareReservedUsed(IODVDMedia, 5); + OSMetaClassDeclareReservedUsed(IODVDMedia, 6); +#endif /* !__LP64__ */ + OSMetaClassDeclareReservedUnused(IODVDMedia, 7); + OSMetaClassDeclareReservedUnused(IODVDMedia, 8); + OSMetaClassDeclareReservedUnused(IODVDMedia, 9); + OSMetaClassDeclareReservedUnused(IODVDMedia, 10); + OSMetaClassDeclareReservedUnused(IODVDMedia, 11); + OSMetaClassDeclareReservedUnused(IODVDMedia, 12); + OSMetaClassDeclareReservedUnused(IODVDMedia, 13); + OSMetaClassDeclareReservedUnused(IODVDMedia, 14); + OSMetaClassDeclareReservedUnused(IODVDMedia, 15); + OSMetaClassDeclareReservedUnused(IODVDMedia, 16); + OSMetaClassDeclareReservedUnused(IODVDMedia, 17); + OSMetaClassDeclareReservedUnused(IODVDMedia, 18); + OSMetaClassDeclareReservedUnused(IODVDMedia, 19); + OSMetaClassDeclareReservedUnused(IODVDMedia, 20); + OSMetaClassDeclareReservedUnused(IODVDMedia, 21); + OSMetaClassDeclareReservedUnused(IODVDMedia, 22); + OSMetaClassDeclareReservedUnused(IODVDMedia, 23); + OSMetaClassDeclareReservedUnused(IODVDMedia, 24); + OSMetaClassDeclareReservedUnused(IODVDMedia, 25); + OSMetaClassDeclareReservedUnused(IODVDMedia, 26); + OSMetaClassDeclareReservedUnused(IODVDMedia, 27); + OSMetaClassDeclareReservedUnused(IODVDMedia, 28); + OSMetaClassDeclareReservedUnused(IODVDMedia, 29); + OSMetaClassDeclareReservedUnused(IODVDMedia, 30); + OSMetaClassDeclareReservedUnused(IODVDMedia, 31); +}; + +#endif /* __cplusplus */ +#endif /* KERNEL */ +#endif /* !_IODVDMEDIA_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/storage/IOBDMediaBSDClient.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/storage/IOBDMediaBSDClient.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/storage/IOBDMediaBSDClient.h (revision 885) @@ -0,0 +1,182 @@ +/* + * Copyright (c) 2006-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 _IOBDMEDIABSDCLIENT_H +#define _IOBDMEDIABSDCLIENT_H + +#include +#include + +#include + +/* + * 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/ + */ + +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 reserved0016[2]; /* 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; + +#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 +#include + +/* + * Class + */ + +class 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 */ Index: branches/azimutz/Cleancut/i386/include/IOKit/storage/IOCDMediaBSDClient.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/storage/IOCDMediaBSDClient.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/storage/IOCDMediaBSDClient.h (revision 885) @@ -0,0 +1,199 @@ +/* + * 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 _IOCDMEDIABSDCLIENT_H +#define _IOCDMEDIABSDCLIENT_H + +#include + +#include + +/* + * Definitions + * + * ioctl description + * ---------------------------- ------------------------------------------------ + * DKIOCCDREAD see IOCDMedia::readCD() in IOCDMedia.h + * DKIOCCDREADTOC see IOCDMedia::readTOC() in IOCDMedia.h + * + * DKIOCCDREADDISCINFO see IOCDMedia::readDiscInfo() in IOCDMedia.h + * DKIOCCDREADTRACKINFO see IOCDMedia::readTrackInfo() in IOCDMedia.h + * + * DKIOCCDREADISRC see IOCDMedia::readISRC() in IOCDMedia.h + * DKIOCCDREADMCN see IOCDMedia::readMCN() in IOCDMedia.h + * + * DKIOCCDGETSPEED see IOCDMedia::getSpeed() in IOCDMedia.h + * DKIOCCDSETSPEED see IOCDMedia::setSpeed() in IOCDMedia.h + * + * in /System/Library/Frameworks/Kernel.framework/Headers/IOKit/storage/ + */ + +typedef struct +{ + uint64_t offset; + + uint8_t sectorArea; + uint8_t sectorType; + +#ifdef __LP64__ + uint8_t reserved0080[10]; /* reserved, clear to zero */ +#else /* !__LP64__ */ + uint8_t reserved0080[6]; /* reserved, clear to zero */ +#endif /* !__LP64__ */ + + uint32_t bufferLength; /* actual length on return */ + void * buffer; +} dk_cd_read_t; + +typedef struct +{ + CDISRC isrc; + uint8_t track; + + uint8_t reserved0112[2]; /* reserved, clear to zero */ +} dk_cd_read_isrc_t; + +typedef struct +{ + CDMCN mcn; + + uint8_t reserved0112[2]; /* reserved, clear to zero */ +} dk_cd_read_mcn_t; + +typedef struct +{ + uint8_t format; + uint8_t formatAsTime; + + uint8_t reserved0016[5]; /* reserved, clear to zero */ + + union + { + uint8_t session; + uint8_t track; + } address; + +#ifdef __LP64__ + uint8_t reserved0064[6]; /* reserved, clear to zero */ +#else /* !__LP64__ */ + uint8_t reserved0064[2]; /* reserved, clear to zero */ +#endif /* !__LP64__ */ + + uint16_t bufferLength; /* actual length on return */ + void * buffer; +} dk_cd_read_toc_t; + +typedef struct +{ +#ifdef __LP64__ + uint8_t reserved0000[14]; /* reserved, clear to zero */ +#else /* !__LP64__ */ + uint8_t reserved0000[10]; /* reserved, clear to zero */ +#endif /* !__LP64__ */ + + uint16_t bufferLength; /* actual length on return */ + void * buffer; +} dk_cd_read_disc_info_t; + +typedef struct +{ + uint8_t reserved0000[4]; /* reserved, clear to zero */ + + uint32_t address; + uint8_t addressType; + +#ifdef __LP64__ + uint8_t reserved0072[5]; /* reserved, clear to zero */ +#else /* !__LP64__ */ + uint8_t reserved0072[1]; /* reserved, clear to zero */ +#endif /* !__LP64__ */ + + uint16_t bufferLength; /* actual length on return */ + void * buffer; +} dk_cd_read_track_info_t; + +#define DKIOCCDREAD _IOWR('d', 96, dk_cd_read_t) + +#define DKIOCCDREADISRC _IOWR('d', 97, dk_cd_read_isrc_t) +#define DKIOCCDREADMCN _IOWR('d', 98, dk_cd_read_mcn_t) + +#define DKIOCCDGETSPEED _IOR('d', 99, uint16_t) +#define DKIOCCDSETSPEED _IOW('d', 99, uint16_t) + +#define DKIOCCDREADTOC _IOWR('d', 100, dk_cd_read_toc_t) + +#define DKIOCCDREADDISCINFO _IOWR('d', 101, dk_cd_read_disc_info_t) +#define DKIOCCDREADTRACKINFO _IOWR('d', 102, dk_cd_read_track_info_t) + +#ifdef KERNEL +#ifdef __cplusplus + +/* + * Kernel + */ + +#include +#include + +/* + * Class + */ + +class IOCDMediaBSDClient : public IOMediaBSDClient +{ + OSDeclareDefaultStructors(IOCDMediaBSDClient) + +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 -- IOCDMedia. This + * method serves simply as a convenience to subclass developers. + */ + + virtual IOCDMedia * getProvider() const; + + /* + * Process a CD-specific ioctl. + */ + + virtual int ioctl(dev_t dev, u_long cmd, caddr_t data, int flags, proc_t proc); + + OSMetaClassDeclareReservedUnused(IOCDMediaBSDClient, 0); + OSMetaClassDeclareReservedUnused(IOCDMediaBSDClient, 1); + OSMetaClassDeclareReservedUnused(IOCDMediaBSDClient, 2); + OSMetaClassDeclareReservedUnused(IOCDMediaBSDClient, 3); + OSMetaClassDeclareReservedUnused(IOCDMediaBSDClient, 4); + OSMetaClassDeclareReservedUnused(IOCDMediaBSDClient, 5); + OSMetaClassDeclareReservedUnused(IOCDMediaBSDClient, 6); + OSMetaClassDeclareReservedUnused(IOCDMediaBSDClient, 7); +}; + +#endif /* __cplusplus */ +#endif /* KERNEL */ +#endif /* !_IOCDMEDIABSDCLIENT_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/storage/IOFDiskPartitionScheme.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/storage/IOFDiskPartitionScheme.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/storage/IOFDiskPartitionScheme.h (revision 885) @@ -0,0 +1,264 @@ +/* + * 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@ + */ + +/* + * This header contains the IOFDiskPartitionScheme class definition. + */ + +#ifndef _IOFDISKPARTITIONSCHEME_H +#define _IOFDISKPARTITIONSCHEME_H + +#include + +/* + * kIOFDiskPartitionSchemeClass is the name of the IOFDiskPartitionScheme class. + */ + +#define kIOFDiskPartitionSchemeClass "IOFDiskPartitionScheme" + +/* + * FDisk Partition Map Definitions + */ + +#pragma pack(push, 1) /* (enable 8-bit struct packing) */ + +/* Structure constants. */ + +#define DISK_BLK0SZ sizeof(struct disk_blk0) /* (size of partition map) */ +#define DISK_BOOTSZ 446 /* (size of boot code in map) */ +#define DISK_NPART 4 /* (number of entries in map) */ + +/* Partition map entry. */ + +struct fdisk_part +{ + UInt8 bootid; /* (is active boot partition?) */ + UInt8 beghead; /* (beginning head) */ + UInt8 begsect; /* (beginning sector; beginning cylinder, high 2 bits) */ + UInt8 begcyl; /* (beginning cylinder, low 8 bits) */ + UInt8 systid; /* (type) */ + UInt8 endhead; /* (ending head) */ + UInt8 endsect; /* (ending sector; ending cylinder, high 2 bits) */ + UInt8 endcyl; /* (ending cylinder, low 8 bits) */ + UInt32 relsect; /* (block start) */ + UInt32 numsect; /* (block count) */ +}; + +/* Partition map, as found in block zero of the disk (or extended partition). */ + +struct disk_blk0 +{ + UInt8 bootcode[DISK_BOOTSZ]; /* (boot code) */ + struct fdisk_part parts[DISK_NPART]; /* (partition entries) */ + UInt16 signature; /* (unique signature for map) */ +}; + +/* Partition map signature (signature). */ + +#define DISK_SIGNATURE 0xAA55 + +/* Partition map entry types (systid). */ + +#define FDISK_PARTITION_TYPE_01 "DOS_FAT_12" +#define FDISK_PARTITION_TYPE_04 "DOS_FAT_16_S" +#define FDISK_PARTITION_TYPE_06 "DOS_FAT_16" +#define FDISK_PARTITION_TYPE_07 "Windows_NTFS" +#define FDISK_PARTITION_TYPE_0B "DOS_FAT_32" +#define FDISK_PARTITION_TYPE_0C "Windows_FAT_32" +#define FDISK_PARTITION_TYPE_0E "Windows_FAT_16" +#define FDISK_PARTITION_TYPE_42 "Windows_LDM" +#define FDISK_PARTITION_TYPE_82 "Linux_Swap" +#define FDISK_PARTITION_TYPE_83 "Linux" +#define FDISK_PARTITION_TYPE_8E "Linux_LVM" +#define FDISK_PARTITION_TYPE_A5 "FreeBSD" +#define FDISK_PARTITION_TYPE_A6 "OpenBSD" +#define FDISK_PARTITION_TYPE_A7 "Apple_Rhapsody_UFS" +#define FDISK_PARTITION_TYPE_A8 "Apple_UFS" +#define FDISK_PARTITION_TYPE_A9 "NetBSD" +#define FDISK_PARTITION_TYPE_AB "Apple_Boot" +#define FDISK_PARTITION_TYPE_AE "Apple_Encrypted" +#define FDISK_PARTITION_TYPE_AF "Apple_HFS" +#define FDISK_PARTITION_TYPE_FD "Linux_RAID" + +#pragma pack(pop) /* (reset to default struct packing) */ + +#ifdef KERNEL +#ifdef __cplusplus + +/* + * Kernel + */ + +#include + +/* + * Class + */ + +class IOFDiskPartitionScheme : public IOPartitionScheme +{ + OSDeclareDefaultStructors(IOFDiskPartitionScheme); + +protected: + + struct ExpansionData { /* */ }; + ExpansionData * _expansionData; + + OSSet * _partitions; /* (set of media objects representing partitions) */ + + /* + * Free all of this object's outstanding resources. + */ + + virtual void free(void); + + /* + * Scan the provider media for an FDisk partition map. Returns the set + * of media objects representing each of the partitions (the retain for + * the set is passed to the caller), or null should no partition map be + * found. The default probe score can be adjusted up or down, based on + * the confidence of the scan. + */ + + virtual OSSet * scan(SInt32 * score); + + /* + * Ask whether the given partition is extended. + */ + + virtual bool isPartitionExtended(fdisk_part * partition); + + /* + * Ask whether the given partition is used. + */ + + virtual bool isPartitionUsed(fdisk_part * partition); + + /* + * Ask whether the given partition appears to be corrupt. A partition that + * is corrupt will cause the failure of the FDisk partition map recognition + * altogether. + */ + + virtual bool isPartitionCorrupt( fdisk_part * partition, + UInt32 partitionID, + UInt32 fdiskBlock ); + + /* + * Ask whether the given partition appears to be invalid. A partition that + * is invalid will cause it to be skipped in the scan, but will not cause a + * failure of the FDisk partition map recognition. + */ + + virtual bool isPartitionInvalid( fdisk_part * partition, + UInt32 partitionID, + UInt32 fdiskBlock ); + + /* + * Instantiate a new media object to represent the given partition. + */ + + virtual IOMedia * instantiateMediaObject( fdisk_part * partition, + UInt32 partitionID, + UInt32 fdiskBlock ); + + /* + * Allocate a new media object (called from instantiateMediaObject). + */ + + virtual IOMedia * instantiateDesiredMediaObject( fdisk_part * partition, + UInt32 partitionID, + UInt32 fdiskBlock ); + +#ifndef __LP64__ + /* + * Attach the given media object to the device tree plane. + */ + + virtual bool attachMediaObjectToDeviceTree(IOMedia * media) __attribute__ ((deprecated)); + + /* + * Detach the given media object from the device tree plane. + */ + + virtual void detachMediaObjectFromDeviceTree(IOMedia * media) __attribute__ ((deprecated)); +#endif /* !__LP64__ */ + +public: + + /* + * Initialize this object's minimal state. + */ + + virtual bool init(OSDictionary * properties = 0); + + /* + * Determine whether the provider media contains an FDisk partition map. + */ + + virtual IOService * probe(IOService * provider, SInt32 * score); + + /* + * Publish the new media objects which represent our partitions. + */ + + virtual bool start(IOService * provider); + + /* + * Clean up after the media objects we published before terminating. + */ + + virtual void stop(IOService * provider); + + /* + * Request that the provider media be re-scanned for partitions. + */ + + virtual IOReturn requestProbe(IOOptionBits options); + +#ifdef __LP64__ + OSMetaClassDeclareReservedUnused(IOFDiskPartitionScheme, 0); + OSMetaClassDeclareReservedUnused(IOFDiskPartitionScheme, 1); +#else /* !__LP64__ */ + OSMetaClassDeclareReservedUsed(IOFDiskPartitionScheme, 0); + OSMetaClassDeclareReservedUsed(IOFDiskPartitionScheme, 1); +#endif /* !__LP64__ */ + OSMetaClassDeclareReservedUnused(IOFDiskPartitionScheme, 2); + OSMetaClassDeclareReservedUnused(IOFDiskPartitionScheme, 3); + OSMetaClassDeclareReservedUnused(IOFDiskPartitionScheme, 4); + OSMetaClassDeclareReservedUnused(IOFDiskPartitionScheme, 5); + OSMetaClassDeclareReservedUnused(IOFDiskPartitionScheme, 6); + OSMetaClassDeclareReservedUnused(IOFDiskPartitionScheme, 7); + OSMetaClassDeclareReservedUnused(IOFDiskPartitionScheme, 8); + OSMetaClassDeclareReservedUnused(IOFDiskPartitionScheme, 9); + OSMetaClassDeclareReservedUnused(IOFDiskPartitionScheme, 10); + OSMetaClassDeclareReservedUnused(IOFDiskPartitionScheme, 11); + OSMetaClassDeclareReservedUnused(IOFDiskPartitionScheme, 12); + OSMetaClassDeclareReservedUnused(IOFDiskPartitionScheme, 13); + OSMetaClassDeclareReservedUnused(IOFDiskPartitionScheme, 14); + OSMetaClassDeclareReservedUnused(IOFDiskPartitionScheme, 15); +}; + +#endif /* __cplusplus */ +#endif /* KERNEL */ +#endif /* !_IOFDISKPARTITIONSCHEME_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/storage/IOMedia.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/storage/IOMedia.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/storage/IOMedia.h (revision 885) @@ -0,0 +1,668 @@ +/* + * 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 IOMedia + * @abstract + * This header contains the IOMedia class definition. + */ + +#ifndef _IOMEDIA_H +#define _IOMEDIA_H + +#include + +/*! + * @defined kIOMediaClass + * @abstract + * The name of the IOMedia class. + */ + +#define kIOMediaClass "IOMedia" + +/*! + * @defined kIOMediaContentKey + * @abstract + * A property of IOMedia objects. + * @discussion + * The kIOMediaContentKey property has an OSString + * value and contains a description of the media's + * contents. The description is the same as the hint at the time of the + * object's creation, but it is possible that the description has been overridden + * by a client (which has probed the media and identified the content correctly) + * of the media object. It is more accurate than the hint for this reason. The + * string is formed in the likeness of Apple's "Apple_HFS" strings or in the + * likeness of a UUID. + */ + +#define kIOMediaContentKey "Content" + +/*! + * @defined kIOMediaContentHintKey + * @abstract + * A property of IOMedia objects. + * @discussion + * The kIOMediaContentHintKey property has an OSString + * value and contains a hint of the media's contents. + * The hint is set at the time of the object's creation, should the creator have + * a clue as to what it may contain. The hint string does not change for the + * lifetime of the object and is formed in the likeness of Apple's "Apple_HFS" + * strings or in the likeness of a UUID. + */ + +#define kIOMediaContentHintKey "Content Hint" + +/*! + * @defined kIOMediaEjectableKey + * @abstract + * A property of IOMedia objects. + * @discussion + * The kIOMediaEjectableKey property has an OSBoolean + * value and describes whether the media is ejectable + * from the drive mechanism under software control. Implies IOMediaRemovable + * is also true. + */ + +#define kIOMediaEjectableKey "Ejectable" + +/*! + * @defined kIOMediaLeafKey + * @abstract + * A property of IOMedia objects. + * @discussion + * The kIOMediaLeafKey property has an OSBoolean value and describes whether the media is a leaf, that is, + * it is the deepest media object in this branch of the I/O Registry. + */ + +#define kIOMediaLeafKey "Leaf" + +/*! + * @defined kIOMediaOpenKey + * @abstract + * A property of IOMedia objects. + * @discussion + * The kIOMediaOpenKey property has an OSBoolean value and describes whether + * a client presently has an open on this media. + */ + +#define kIOMediaOpenKey "Open" + +/*! + * @defined kIOMediaPreferredBlockSizeKey + * @abstract + * A property of IOMedia objects. + * @discussion + * The kIOMediaPreferredBlockSizeKey property has an + * OSNumber value and describes the media's natural + * block size in bytes. This information is useful to clients that want to + * optimize access to the media. + */ + +#define kIOMediaPreferredBlockSizeKey "Preferred Block Size" + +/*! + * @defined kIOMediaRemovableKey + * @abstract + * A property of IOMedia objects. + * @discussion + * The kIOMediaRemovableKey property has an OSBoolean + * value and describes whether the media is removable + * from the drive mechanism. + */ + +#define kIOMediaRemovableKey "Removable" + +/*! + * @defined kIOMediaSizeKey + * @abstract + * A property of IOMedia objects. + * @discussion + * The kIOMediaSizeKey property has an OSNumber value and describes the total length of the media in + * bytes. + */ + +#define kIOMediaSizeKey "Size" + +/*! + * @defined kIOMediaUUIDKey + * @abstract + * A property of IOMedia objects. + * @discussion + * The kIOMediaUUIDKey property has an OSString value and contains a persistent + * Universal Unique Identifier for the media if such an identifier is available. + */ + +#define kIOMediaUUIDKey "UUID" + +/*! + * @defined kIOMediaWholeKey + * @abstract + * A property of IOMedia objects. + * @discussion + * The kIOMediaWholeKey property has an OSBoolean + * value and describes whether the media is whole, that is, + * it represents the whole disk (the physical disk, or a virtual replica + * thereof). + */ + +#define kIOMediaWholeKey "Whole" + +/*! + * @defined kIOMediaWritableKey + * @abstract + * A property of IOMedia objects. + * @discussion + * The kIOMediaWritableKey property has an OSBoolean + * value and describes whether the media is writable. + */ + +#define kIOMediaWritableKey "Writable" + +/*! + * @defined kIOMediaContentMaskKey + * @abstract + * A property of IOMedia clients. + * @discussion + * The kIOMediaContentMaskKey property has an OSString + * value and must exist in all IOMedia clients that + * drive new content (that is, produce new media objects). When the client + * matches against the provider media, the value of the client's + * kIOMediaContentMaskKey property is used to replace the provider's + * kIOMediaContentKey property. + */ + +#define kIOMediaContentMaskKey "Content Mask" + +/*! + * @defined kIOMediaIconKey + * @abstract + * A property of any object in the media stack. + * @discussion + * kIOMediaIconKey is a property of any object in the media stack that wishes + * to override the default icon shown for the media objects in the stack. It + * is usually defined in a provider object below the media object. It has an + * OSDictionary value, with properties identical to the kIOIconKey definition, + * that is, kCFBundleIdentifierKey and kIOBundleResourceFileKey. + */ + +#define kIOMediaIconKey "IOMediaIcon" + +/*! + * @enum IOMediaAttributeMask + * @discussion + * The IOMediaAttributeMask bit mask describes various attributes of + * the media object, such as its ejectability and its removability. + * @constant kIOMediaAttributeEjectableMask + * Indicates whether the media is ejectable from the drive mechanism + * under software control. Implies kIOMediaAttributeRemovableMask. + * @constant kIOMediaAttributeRemovableMask + * Indicates whether the media is removable from the drive mechanism. + */ + +enum +{ + kIOMediaAttributeEjectableMask = 0x00000001, + kIOMediaAttributeRemovableMask = 0x00000002, + kIOMediaAttributeReservedMask = 0xFFFFFFFC +}; + +typedef UInt32 IOMediaAttributeMask; + +#ifdef KERNEL +#ifdef __cplusplus + +/* + * Kernel + */ + +#include + +/*! + * @class IOMedia + * @abstract + * A random-access disk device abstraction. + * @discussion + * The IOMedia class is a random-access disk device abstraction. It provides a + * consistent interface for both real and virtual disk devices, for subdivisions + * of disks such as partitions, for supersets of disks such as RAID volumes, and + * so on. It extends the IOStorage class by implementing the appropriate open, + * close, read, write, and matching semantics for media objects. The properties + * it has reflect the properties of real disk devices, such as ejectability and + * writability. + * + * The read and write interfaces support byte-level access to the storage space, + * with the appropriate deblocking handled by the block storage driver, however, + * a typical client will want to get the natural block size in order to optimize + * access to the real disk device. A read or write is accepted so long as the + * client's access is valid, the media is formatted and the transfer is within + * the bounds of the media. An optional non-zero base (offset) is then applied + * before the read or write is passed to provider object. + */ + +class IOMedia : public IOStorage +{ + OSDeclareDefaultStructors(IOMedia) + +protected: + + struct ExpansionData { /* */ }; + ExpansionData * _expansionData; + + UInt32 _attributes; + + bool _isWhole; + bool _isWritable; + + UInt64 _mediaBase; /* (relative to the storage object below us) */ + UInt64 _mediaSize; + + IOStorageAccess _openLevel; + OSDictionary * _openClients; + + UInt32 _reserved0320; + + UInt64 _preferredBlockSize; + + /* + * Free all of this object's outstanding resources. + */ + + virtual void free(); + + /*! + * @function handleOpen + * @discussion + * The handleOpen method grants or denies permission to access this object + * to an interested client. The argument is an IOStorageAccess value that + * specifies the level of access desired -- reader or reader-writer. + * + * This method can be invoked to upgrade or downgrade the access level for + * an existing client as well. The previous access level will prevail for + * upgrades that fail, of course. A downgrade should never fail. If the + * new access level should be the same as the old for a given client, this + * method will do nothing and return success. In all cases, one, singular + * close-per-client is expected for all opens-per-client received. + * + * This implementation replaces the IOService definition of handleOpen(). + * @param client + * Client requesting the open. + * @param options + * Options for the open. Set to zero. + * @param access + * Access level for the open. Set to kIOStorageAccessReader or + * kIOStorageAccessReaderWriter. + * @result + * Returns true if the open was successful, false otherwise. + */ + + virtual bool handleOpen(IOService * client, + IOOptionBits options, + void * access); + + /*! + * @function handleIsOpen + * @discussion + * The handleIsOpen method determines whether the specified client, or any + * client if none is specified, presently has an open on this object. + * + * This implementation replaces the IOService definition of handleIsOpen(). + * @param client + * Client to check the open state of. Set to zero to check the open state + * of all clients. + * @result + * Returns true if the client was (or clients were) open, false otherwise. + */ + + virtual bool handleIsOpen(const IOService * client) const; + + /*! + * @function handleClose + * @discussion + * The handleClose method closes the client's access to this object. + * + * This implementation replaces the IOService definition of handleClose(). + * @param client + * Client requesting the close. + * @param options + * Options for the close. Set to zero. + */ + + virtual void handleClose(IOService * client, IOOptionBits options); + +public: + + using IOStorage::read; + using IOStorage::write; + +#ifndef __LP64__ + virtual bool init(UInt64 base, + UInt64 size, + UInt64 preferredBlockSize, + bool isEjectable, + bool isWhole, + bool isWritable, + const char * contentHint = 0, + OSDictionary * properties = 0) __attribute__ ((deprecated)); +#endif /* !__LP64__ */ + + /* + * This method is called for each client interested in the services we + * provide. The superclass links us as a parent to this client in the + * I/O Kit registry on success. + */ + + virtual bool attachToChild(IORegistryEntry * client, + const IORegistryPlane * plane); + + /* + * This method is called for each client that loses interest in the + * services we provide. The superclass unlinks us from this client + * in the I/O Kit registry on success. + */ + + virtual void detachFromChild(IORegistryEntry * client, + const IORegistryPlane * plane); + + /* + * Obtain this object's provider. We override the superclass's method to + * return a more specific subclass of OSObject -- IOStorage. This method + * serves simply as a convenience to subclass developers. + */ + + virtual IOStorage * getProvider() const; + + /* + * Compare the properties in the supplied table to this object's properties. + */ + + virtual bool matchPropertyTable(OSDictionary * table, SInt32 * score); + + /*! + * @function read + * @discussion + * Read data from the storage object at the specified byte offset into the + * specified buffer, asynchronously. When the read completes, the caller + * will be notified via the specified completion action. + * + * The buffer will be retained for the duration of the read. + * @param client + * Client requesting the read. + * @param byteStart + * Starting byte offset for the data transfer. + * @param buffer + * Buffer for the data transfer. The size of the buffer implies the size of + * the data transfer. + * @param attributes + * Attributes of the data transfer. See IOStorageAttributes. It is the + * responsibility of the callee to maintain the information for the duration + * of the data transfer, as necessary. + * @param completion + * Completion routine to call once the data transfer is complete. It is the + * responsibility of the callee to maintain the information for the duration + * of the data transfer, as necessary. + */ + + virtual void read(IOService * client, + UInt64 byteStart, + IOMemoryDescriptor * buffer, + IOStorageAttributes * attributes, + IOStorageCompletion * completion); + + /*! + * @function write + * @discussion + * Write data into the storage object at the specified byte offset from the + * specified buffer, asynchronously. When the write completes, the caller + * will be notified via the specified completion action. + * + * The buffer will be retained for the duration of the write. + * @param client + * Client requesting the write. + * @param byteStart + * Starting byte offset for the data transfer. + * @param buffer + * Buffer for the data transfer. The size of the buffer implies the size of + * the data transfer. + * @param attributes + * Attributes of the data transfer. See IOStorageAttributes. It is the + * responsibility of the callee to maintain the information for the duration + * of the data transfer, as necessary. + * @param completion + * Completion routine to call once the data transfer is complete. It is the + * responsibility of the callee to maintain the information for the duration + * of the data transfer, as necessary. + */ + + virtual void write(IOService * client, + UInt64 byteStart, + IOMemoryDescriptor * buffer, + IOStorageAttributes * attributes, + IOStorageCompletion * completion); + + /*! + * @function synchronizeCache + * @discussion + * Flush the cached data in the storage object, if any, synchronously. + * @param client + * Client requesting the cache synchronization. + * @result + * Returns the status of the cache synchronization. + */ + + virtual IOReturn synchronizeCache(IOService * client); + + /*! + * @function discard + * @discussion + * Delete unused data from the storage object at the specified byte offset, + * synchronously. + * @param client + * Client requesting the operation. + * @param byteStart + * Starting byte offset for the operation. + * @param byteCount + * Size of the operation. + * @result + * Returns the status of the operation. + */ + + virtual IOReturn discard(IOService * client, + UInt64 byteStart, + UInt64 byteCount); + + /*! + * @function getPreferredBlockSize + * @discussion + * Ask the media object for its natural block size. This information + * is useful to clients that want to optimize access to the media. + * @result + * Natural block size, in bytes. + */ + + virtual UInt64 getPreferredBlockSize() const; + + /*! + * @function getSize + * @discussion + * Ask the media object for its total length in bytes. + * @result + * Media size, in bytes. + */ + + virtual UInt64 getSize() const; + + /*! + * @function getBase + * @discussion + * Ask the media object for its byte offset relative to its provider media + * object below it in the storage hierarchy. + * Media offset, in bytes. + */ + + virtual UInt64 getBase() const; + + /*! + * @function isEjectable + * @discussion + * Ask the media object whether it is ejectable. + * @result + * Returns true if the media is ejectable, false otherwise. + */ + + virtual bool isEjectable() const; + + /*! + * @function isFormatted + * @discussion + * Ask the media object whether it is formatted. + * @result + * Returns true if the media is formatted, false otherwise. + */ + + virtual bool isFormatted() const; + + /*! + * @function isWhole + * @discussion + * Ask the media object whether it represents the whole disk. + * @result + * Returns true if the media represents the whole disk, false otherwise. + */ + + virtual bool isWhole() const; + + /*! + * @function isWritable + * @discussion + * Ask the media object whether it is writable. + * @result + * Returns true if the media is writable, false otherwise. + */ + + virtual bool isWritable() const; + + /*! + * @function getContent + * @discussion + * Ask the media object for a description of its contents. The description + * is the same as the hint at the time of the object's creation, but it is + * possible that the description has been overridden by a client (which has probed + * the media and identified the content correctly) of the media object. It + * is more accurate than the hint for this reason. The string is formed in + * the likeness of Apple's "Apple_HFS" strings or in the likeness of a UUID. + * + * The content description can be overridden by any client that matches onto + * this media object with a match category of kIOStorageCategory. The media + * object checks for a kIOMediaContentMaskKey property in the client, and if + * it finds one, it copies it into kIOMediaContentKey property. + * @result + * Description of media's contents. + */ + + virtual const char * getContent() const; + + /*! + * @function getContentHint + * @discussion + * Ask the media object for a hint of its contents. The hint is set at the + * time of the object's creation, should the creator have a clue as to what + * it may contain. The hint string does not change for the lifetime of the + * object and is also formed in the likeness of Apple's "Apple_HFS" strings + * or in the likeness of a UUID. + * @result + * Hint of media's contents. + */ + + virtual const char * getContentHint() const; + + /*! + * @function init + * @discussion + * Initialize this object's minimal state. + * @param base + * Media offset, in bytes. + * @param size + * Media size, in bytes. + * @param preferredBlockSize + * Natural block size, in bytes. + * @param attributes + * Media attributes, such as ejectability and removability. See + * IOMediaAttributeMask. + * @param isWhole + * Indicates whether the media represents the whole disk. + * @param isWritable + * Indicates whether the media is writable. + * @param contentHint + * Hint of media's contents (optional). See getContentHint(). + * @param properties + * Substitute property table for this object (optional). + * @result + * Returns true on success, false otherwise. + */ + + virtual bool init(UInt64 base, + UInt64 size, + UInt64 preferredBlockSize, + IOMediaAttributeMask attributes, + bool isWhole, + bool isWritable, + const char * contentHint = 0, + OSDictionary * properties = 0); /* 10.2.0 */ + + /*! + * @function getAttributes + * @discussion + * Ask the media object for its attributes. + * @result + * Media attributes, such as ejectability and removability. See + * IOMediaAttributeMask. + */ + + virtual IOMediaAttributeMask getAttributes() const; /* 10.2.0 */ + +#ifdef __LP64__ + OSMetaClassDeclareReservedUnused(IOMedia, 0); + OSMetaClassDeclareReservedUnused(IOMedia, 1); +#else /* !__LP64__ */ + OSMetaClassDeclareReservedUsed(IOMedia, 0); + OSMetaClassDeclareReservedUsed(IOMedia, 1); +#endif /* !__LP64__ */ + OSMetaClassDeclareReservedUnused(IOMedia, 2); + OSMetaClassDeclareReservedUnused(IOMedia, 3); + OSMetaClassDeclareReservedUnused(IOMedia, 4); + OSMetaClassDeclareReservedUnused(IOMedia, 5); + OSMetaClassDeclareReservedUnused(IOMedia, 6); + OSMetaClassDeclareReservedUnused(IOMedia, 7); + OSMetaClassDeclareReservedUnused(IOMedia, 8); + OSMetaClassDeclareReservedUnused(IOMedia, 9); + OSMetaClassDeclareReservedUnused(IOMedia, 10); + OSMetaClassDeclareReservedUnused(IOMedia, 11); + OSMetaClassDeclareReservedUnused(IOMedia, 12); + OSMetaClassDeclareReservedUnused(IOMedia, 13); + OSMetaClassDeclareReservedUnused(IOMedia, 14); + OSMetaClassDeclareReservedUnused(IOMedia, 15); +}; + +#endif /* __cplusplus */ +#endif /* KERNEL */ +#endif /* !_IOMEDIA_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/storage/IOApplePartitionScheme.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/storage/IOApplePartitionScheme.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/storage/IOApplePartitionScheme.h (revision 885) @@ -0,0 +1,265 @@ +/* + * 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@ + */ + +/* + * This header contains the IOApplePartitionScheme class definition. + */ + +#ifndef _IOAPPLEPARTITIONSCHEME_H +#define _IOAPPLEPARTITIONSCHEME_H + +#include + +/* + * kIOApplePartitionSchemeClass is the name of the IOApplePartitionScheme class. + */ + +#define kIOApplePartitionSchemeClass "IOApplePartitionScheme" + +/* + * Apple Partition Map Definitions + */ + +#pragma pack(push, 1) /* (enable 8-bit struct packing) */ + +/* Structure constants. */ + +#define DPISTRLEN 32 + +/* Partition map entry, as found in blocks 1 to dpme_map_entries of the disk. */ + +typedef struct dpme +{ + UInt16 dpme_signature; /* (unique value for partition entry, 'PM') */ + UInt16 dpme_reserved_1; /* (reserved for future use) */ + UInt32 dpme_map_entries; /* (number of partition entries) */ + UInt32 dpme_pblock_start; /* (physical block start of partition) */ + UInt32 dpme_pblocks; /* (physical block count of partition) */ + char dpme_name[DPISTRLEN]; /* (name of partition) */ + char dpme_type[DPISTRLEN]; /* (type of partition, eg. Apple_HFS) */ + UInt32 dpme_lblock_start; /* (logical block start of partition) */ + UInt32 dpme_lblocks; /* (logical block count of partition) */ + UInt32 dpme_flags; /* (partition flags, see defines below) */ + UInt32 dpme_boot_block; /* (logical block start of boot code) */ + UInt32 dpme_boot_bytes; /* (byte count of boot code) */ + UInt32 dpme_load_addr; /* (load address in memory of boot code) */ + UInt32 dpme_load_addr_2; /* (reserved for future use) */ + UInt32 dpme_goto_addr; /* (jump address in memory of boot code) */ + UInt32 dpme_goto_addr_2; /* (reserved for future use) */ + UInt32 dpme_checksum; /* (checksum of boot code) */ + UInt8 dpme_process_id[16]; /* (processor type) */ + UInt32 dpme_reserved_2[32]; /* (reserved for future use) */ + UInt32 dpme_reserved_3[62]; /* (reserved for future use) */ +} DPME; + +/* Driver descriptor map entry. */ + +typedef struct DDMap +{ + UInt32 ddBlock; /* (driver's block start, sbBlkSize-blocks) */ + UInt16 ddSize; /* (driver's block count, 512-blocks) */ + UInt16 ddType; /* (driver's system type) */ +} DDMap; + +/* Driver descriptor map, as found in block zero of the disk. */ + +typedef struct Block0 +{ + UInt16 sbSig; /* (unique value for block zero, 'ER') */ + UInt16 sbBlkSize; /* (block size for this device) */ + UInt32 sbBlkCount; /* (block count for this device) */ + UInt16 sbDevType; /* (device type) */ + UInt16 sbDevId; /* (device id) */ + UInt32 sbDrvrData; /* (driver data) */ + UInt16 sbDrvrCount; /* (driver descriptor count) */ + DDMap sbDrvrMap[8]; /* (driver descriptor table) */ + UInt8 sbReserved[430]; /* (reserved for future use) */ +} Block0; + +/* Partition map signature (sbSig). */ + +#define BLOCK0_SIGNATURE 0x4552 + +/* Partition map entry signature (dpme_signature). */ + +#define DPME_SIGNATURE 0x504D + +/* Partition map entry flags (dpme_flags). */ + +#define DPME_FLAGS_VALID 0x00000001 /* (bit 0) */ +#define DPME_FLAGS_ALLOCATED 0x00000002 /* (bit 1) */ +#define DPME_FLAGS_IN_USE 0x00000004 /* (bit 2) */ +#define DPME_FLAGS_BOOTABLE 0x00000008 /* (bit 3) */ +#define DPME_FLAGS_READABLE 0x00000010 /* (bit 4) */ +#define DPME_FLAGS_WRITABLE 0x00000020 /* (bit 5) */ +#define DPME_FLAGS_OS_PIC_CODE 0x00000040 /* (bit 6) */ +#define DPME_FLAGS_OS_SPECIFIC_2 0x00000080 /* (bit 7) */ +#define DPME_FLAGS_OS_SPECIFIC_1 0x00000100 /* (bit 8) */ +#define DPME_FLAGS_RESERVED_2 0xFFFFFE00 /* (bit 9..31) */ + +#pragma pack(pop) /* (reset to default struct packing) */ + +#ifdef KERNEL +#ifdef __cplusplus + +/* + * Kernel + */ + +#include + +/* + * Class + */ + +class IOApplePartitionScheme : public IOPartitionScheme +{ + OSDeclareDefaultStructors(IOApplePartitionScheme); + +protected: + + struct ExpansionData { /* */ }; + ExpansionData * _expansionData; + + OSSet * _partitions; /* (set of media objects representing partitions) */ + + /* + * Free all of this object's outstanding resources. + */ + + virtual void free(void); + + /* + * Scan the provider media for an Apple partition map. Returns the set + * of media objects representing each of the partitions (the retain for + * the set is passed to the caller), or null should no partition map be + * found. The default probe score can be adjusted up or down, based on + * the confidence of the scan. + */ + + virtual OSSet * scan(SInt32 * score); + + /* + * Ask whether the given partition appears to be corrupt. A partition that + * is corrupt will cause the failure of the Apple partition map recognition + * altogether. + */ + + virtual bool isPartitionCorrupt( dpme * partition, + UInt32 partitionID, + UInt32 partitionBlockSize ); + + /* + * Ask whether the given partition appears to be invalid. A partition that + * is invalid will cause it to be skipped in the scan, but will not cause a + * failure of the Apple partition map recognition. + */ + + virtual bool isPartitionInvalid( dpme * partition, + UInt32 partitionID, + UInt32 partitionBlockSize ); + + /* + * Instantiate a new media object to represent the given partition. + */ + + virtual IOMedia * instantiateMediaObject( dpme * partition, + UInt32 partitionID, + UInt32 partitionBlockSize ); + + /* + * Allocate a new media object (called from instantiateMediaObject). + */ + + virtual IOMedia * instantiateDesiredMediaObject( + dpme * partition, + UInt32 partitionID, + UInt32 partitionBlockSize ); + +#ifndef __LP64__ + /* + * Attach the given media object to the device tree plane. + */ + + virtual bool attachMediaObjectToDeviceTree(IOMedia * media) __attribute__ ((deprecated)); + + /* + * Detach the given media object from the device tree plane. + */ + + virtual void detachMediaObjectFromDeviceTree(IOMedia * media) __attribute__ ((deprecated)); +#endif /* !__LP64__ */ + +public: + + /* + * Initialize this object's minimal state. + */ + + virtual bool init(OSDictionary * properties = 0); + + /* + * Determine whether the provider media contains an Apple partition map. + */ + + virtual IOService * probe(IOService * provider, SInt32 * score); + + /* + * Publish the new media objects which represent our partitions. + */ + + virtual bool start(IOService * provider); + + /* + * Clean up after the media objects we published before terminating. + */ + + virtual void stop(IOService * provider); + + /* + * Request that the provider media be re-scanned for partitions. + */ + + virtual IOReturn requestProbe(IOOptionBits options); + + OSMetaClassDeclareReservedUnused(IOApplePartitionScheme, 0); + OSMetaClassDeclareReservedUnused(IOApplePartitionScheme, 1); + OSMetaClassDeclareReservedUnused(IOApplePartitionScheme, 2); + OSMetaClassDeclareReservedUnused(IOApplePartitionScheme, 3); + OSMetaClassDeclareReservedUnused(IOApplePartitionScheme, 4); + OSMetaClassDeclareReservedUnused(IOApplePartitionScheme, 5); + OSMetaClassDeclareReservedUnused(IOApplePartitionScheme, 6); + OSMetaClassDeclareReservedUnused(IOApplePartitionScheme, 7); + OSMetaClassDeclareReservedUnused(IOApplePartitionScheme, 8); + OSMetaClassDeclareReservedUnused(IOApplePartitionScheme, 9); + OSMetaClassDeclareReservedUnused(IOApplePartitionScheme, 10); + OSMetaClassDeclareReservedUnused(IOApplePartitionScheme, 11); + OSMetaClassDeclareReservedUnused(IOApplePartitionScheme, 12); + OSMetaClassDeclareReservedUnused(IOApplePartitionScheme, 13); + OSMetaClassDeclareReservedUnused(IOApplePartitionScheme, 14); + OSMetaClassDeclareReservedUnused(IOApplePartitionScheme, 15); +}; + +#endif /* __cplusplus */ +#endif /* KERNEL */ +#endif /* !_IOAPPLEPARTITIONSCHEME_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/storage/IOStorageDeviceCharacteristics.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/storage/IOStorageDeviceCharacteristics.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/storage/IOStorageDeviceCharacteristics.h (revision 885) @@ -0,0 +1,659 @@ +/* + * 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_STORAGE_DEVICE_CHARACTERISTICS_H_ +#define _IOKIT_IO_STORAGE_DEVICE_CHARACTERISTICS_H_ + +#include + +/* + * Device Characteristics - Characteristics defined for devices. + */ + +/*! +@defined kIOPropertyDeviceCharacteristicsKey +@discussion This key is used to define Device Characteristics for a particular +device and it has an associated dictionary which lists the +device characteristics. The device characteristics are Command Set specific +and are listed in the header files for each command set. + +Requirement: Mandatory + +Example: +
+@textblock
+
+	Device Characteristics
+	
+		Vendor Name
+		Apple
+		Product Name
+		iPod
+		Product Revision Level
+		1.0
+	
+
+@/textblock
+
+*/ +#define kIOPropertyDeviceCharacteristicsKey "Device Characteristics" + + +/*! +@defined kIOPropertyVendorNameKey +@discussion This key is used to define the Vendor Name for a particular device +and it has an associated string. + +Requirement: Mandatory + +Example: +
+@textblock
+
+	Device Characteristics
+	
+		Vendor Name
+		Apple
+		Product Name
+		iPod
+		Product Revision Level
+		1.0
+	
+
+@/textblock
+
+*/ +#define kIOPropertyVendorNameKey "Vendor Name" + + +/*! +@defined kIOPropertyProductNameKey +@discussion This key is used to define the Product Name for a particular device +and it has an associated string. + +Requirement: Mandatory + +Example: +
+@textblock
+
+	Device Characteristics
+	
+		Vendor Name
+		Apple
+		Product Name
+		iPod
+		Product Revision Level
+		1.0
+	
+
+@/textblock
+
+*/ +#define kIOPropertyProductNameKey "Product Name" + + +/*! +@defined kIOPropertyProductRevisionLevelKey +@discussion This key is used to define the Product Revision Level for a +particular device and it has an associated string. + +Requirement: Mandatory + +Example: +
+@textblock
+
+	Device Characteristics
+	
+		Vendor Name
+		Apple
+		Product Name
+		iPod
+		Product Revision Level
+		1.0
+	
+
+@/textblock
+
+*/ +#define kIOPropertyProductRevisionLevelKey "Product Revision Level" + + +/*! +@defined kIOPropertyProductSerialNumberKey +@discussion This key is used to define the Product Serial Number for a +particular device and it has an associated data. + +Requirement: Mandatory + +Example: +
+@textblock
+
+	Device Characteristics
+	
+		Vendor Name
+		Apple
+		Product Name
+		iPod
+		Product Revision Level
+		1.0
+		Serial Number
+		123456789
+	
+
+@/textblock
+
+*/ +#define kIOPropertyProductSerialNumberKey "Serial Number" + + +/*! +@defined kIOPropertySupportedCDFeaturesKey +@discussion This key is used to define the supported CD Features for a +particular optical device and it has an associated bitfield. See + for definitions of the +bits and associated bitmasks. + +Requirement: Mandatory for optical devices (Peripheral Device Type 05h). + +Example: +
+@textblock
+
+	Device Characteristics
+	
+		Vendor Name
+		Apple
+		Product Name
+		SuperDrive
+		Product Revision Level
+		1.0
+		CD Features
+		1663
+		DVD Features
+		103
+	
+
+@/textblock
+
+*/ +#define kIOPropertySupportedCDFeaturesKey "CD Features" + + +/*! +@defined kIOPropertySupportedDVDFeaturesKey +@discussion This key is used to define the supported DVD Features for a +particular optical device and it has an associated bitfield. See + for definitions of the +bits and associated bitmasks. + +Requirement: Mandatory for optical devices (Peripheral Device Type 05h). + +Example: +
+@textblock
+
+	Device Characteristics
+	
+		Vendor Name
+		Apple
+		Product Name
+		SuperDrive
+		Product Revision Level
+		1.0
+		CD Features
+		1663
+		DVD Features
+		103
+	
+
+@/textblock
+
+*/ +#define kIOPropertySupportedDVDFeaturesKey "DVD Features" + + +/*! +@defined kIOPropertySupportedBDFeaturesKey +@discussion This key is used to define the supported BD Features for a +particular optical device and it has an associated bitfield. See + for definitions of the +bits and associated bitmasks. + +Requirement: Mandatory for optical devices (Peripheral Device Type 05h). + +Example: +
+@textblock
+
+	Device Characteristics
+	
+		Vendor Name
+		Apple
+		Product Name
+		SuperDrive
+		Product Revision Level
+		1.0
+		CD Features
+		1663
+		DVD Features
+		103
+		BD Features
+		21
+	
+
+@/textblock
+
+*/ +#define kIOPropertySupportedBDFeaturesKey "BD Features" + + +/*! +@defined kIOPropertyRigidDiskGeometryKey +@discussion This key is used to define a dictionary containing +rigid disk geometry information. + +Requirement: Optional. If a device publishes this dictionary, it +must publish all key/value pairs which are deemed Mandatory. + +Example: +
+@textblock
+
+	Device Characteristics
+	
+		Vendor Name
+		Apple
+		Product Name
+		iPod
+		Product Revision Level
+		1.0
+		Rigid Disk Geometry
+		
+			Sector Count per Track
+			12345
+			Head Count
+			12
+			Cylinder Count
+			12345
+			Bytes per Physical Sector
+			512
+		
+	
+
+@/textblock
+
+*/ +#define kIOPropertyRigidDiskGeometryKey "Rigid Disk Geometry" + + +/*! +@defined kIOPropertySectorCountPerTrackKey +@discussion This key is used to define the number of sectors per +each track for a particular medium. + +Requirement: Mandatory element of the Rigid Disk Geometry dictionary. + +Example: +
+@textblock
+
+	Device Characteristics
+	
+		Vendor Name
+		Apple
+		Product Name
+		iPod
+		Product Revision Level
+		1.0
+		Rigid Disk Geometry
+		
+			Sector Count per Track
+			12345
+		
+	
+
+@/textblock
+
+*/ +#define kIOPropertySectorCountPerTrackKey "Sector Count per Track" + + +/*! +@defined kIOPropertyHeadCountKey +@discussion This key is used to define the number of heads for +a particular medium. + +Requirement: Mandatory element of the Rigid Disk Geometry dictionary. + +Example: +
+@textblock
+
+	Device Characteristics
+	
+		Vendor Name
+		Apple
+		Product Name
+		iPod
+		Product Revision Level
+		1.0
+		Rigid Disk Geometry
+		
+			Sector Count per Track
+			12345
+			Head Count
+			12
+			Cylinder Count
+			12345
+			Bytes per Physical Sector
+			512
+		
+	
+
+@/textblock
+
+*/ +#define kIOPropertyHeadCountKey "Head Count" + + +/*! +@defined kIOPropertyCylinderCountKey +@discussion This key is used to define the number of heads for +a particular medium. + +Requirement: Mandatory element of the Rigid Disk Geometry dictionary. + +Example: +
+@textblock
+
+	Device Characteristics
+	
+		Vendor Name
+		Apple
+		Product Name
+		iPod
+		Product Revision Level
+		1.0
+		Rigid Disk Geometry
+		
+			Sector Count per Track
+			12345
+			Head Count
+			12
+			Cylinder Count
+			12345
+			Bytes per Physical Sector
+			512
+		
+	
+
+@/textblock
+
+*/ +#define kIOPropertyCylinderCountKey "Cylinder Count" + + +/*! +@defined kIOPropertyBytesPerPhysicalSectorKey +@discussion This key is used to define the number of heads for +a particular medium. + +Requirement: Mandatory element of the Rigid Disk Geometry dictionary. + +Example: +
+@textblock
+
+	Device Characteristics
+	
+		Vendor Name
+		Apple
+		Product Name
+		iPod
+		Product Revision Level
+		1.0
+		Rigid Disk Geometry
+		
+			Sector Count per Track
+			12345
+			Head Count
+			12
+			Cylinder Count
+			12345
+			Bytes per Physical Sector
+			512
+		
+	
+
+@/textblock
+
+*/ +#define kIOPropertyBytesPerPhysicalSectorKey "Bytes per Physical Sector" + + +/*! +@defined kIOPropertyPhysicalBlockSizeKey +@discussion This key is used to define the physical block size of a hard disk drive. + +Requirement: Mandatory for hard disk drives with physical block size other than 512 bytes. + +Example: +
+@textblock
+
+	Device Characteristics
+	
+		Vendor Name
+		Apple
+		Product Name
+		iPod
+		Product Revision Level
+		1.0
+		Physical Block Size
+		4096
+		Logical Block Size
+		512
+	
+
+@/textblock
+
+*/ +#define kIOPropertyPhysicalBlockSizeKey "Physical Block Size" + + +/*! +@defined kIOPropertyLogicalBlockSizeKey +@discussion This key is used to define the logical block size of a hard disk drive. + +Requirement: Mandatory for hard disk drives with logical block size other than 512 bytes +or that does not match its physical block size. + +Example: +
+@textblock
+
+	Device Characteristics
+	
+		Vendor Name
+		Apple
+		Product Name
+		iPod
+		Product Revision Level
+		1.0
+		Physical Block Size
+		4096
+		Logical Block Size
+		512
+	
+
+@/textblock
+
+*/ +#define kIOPropertyLogicalBlockSizeKey "Logical Block Size" + + +/*! +@defined kIOPropertyTargetDiskModeKey +@discussion This key is used to indicate the device is another computer in Target Disk Mode. + +Requirement: Optional. + +Example: +
+@textblock
+
+	Device Characteristics
+	
+		Vendor Name
+		AAPL
+		Product Name
+		FireWire Target
+		Product Revision Level
+		0000
+		Target Disk Mode
+		
+	
+
+@/textblock
+
+*/ +#define kIOPropertyTargetDiskModeKey "Target Disk Mode" + + +/*! +@defined kIOPropertyMediumTypeKey +@discussion This key is used to indicate the medium type of the device. + +Requirement: Optional. + +Example: +
+@textblock
+
+	Device Characteristics
+	
+		Vendor Name
+		AAPL
+		Product Name
+		FireWire Target
+		Product Revision Level
+		0000
+		Medium Type
+		Rotational
+	
+
+@/textblock
+
+*/ +#define kIOPropertyMediumTypeKey "Medium Type" + + +/*! +@defined kIOPropertyMediumTypeRotationalKey +@discussion This key is used to indicate the medium type of the device is rotational. + +Requirement: Optional. + +Example: +
+@textblock
+
+	Device Characteristics
+	
+		Vendor Name
+		AAPL
+		Product Name
+		FireWire Target
+		Product Revision Level
+		0000
+		Medium Type
+		Rotational
+	
+
+@/textblock
+
+*/ +#define kIOPropertyMediumTypeRotationalKey "Rotational" + + +/*! +@defined kIOPropertyMediumTypeSolidStateKey +@discussion This key is used to indicate the medium type of the device is solid state. + +Requirement: Optional. + +Example: +
+@textblock
+
+	Device Characteristics
+	
+		Vendor Name
+		AAPL
+		Product Name
+		FireWire Target
+		Product Revision Level
+		0000
+		Medium Type
+		Solid State
+	
+
+@/textblock
+
+*/ +#define kIOPropertyMediumTypeSolidStateKey "Solid State" + + +/*! +@defined kIOPropertyMediumRotationRateKey +@discussion This key is used to indicate the medium rotation rate in RPM of the device. + +Requirement: Optional. + +Example: +
+@textblock
+
+	Device Characteristics
+	
+		Vendor Name
+		AAPL
+		Product Name
+		FireWire Target
+		Product Revision Level
+		0000
+		Rotation Rate
+		7200
+	
+
+@/textblock
+
+*/ +#define kIOPropertyMediumRotationRateKey "Rotation Rate" + + +#endif /* _IOKIT_IO_STORAGE_DEVICE_CHARACTERISTICS_H_ */ Index: branches/azimutz/Cleancut/i386/include/IOKit/storage/IOStorageProtocolCharacteristics.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/storage/IOStorageProtocolCharacteristics.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/storage/IOStorageProtocolCharacteristics.h (revision 885) @@ -0,0 +1,1758 @@ +/* + * 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_STORAGE_PROTOCOL_CHARACTERISTICS_H_ +#define _IOKIT_IO_STORAGE_PROTOCOL_CHARACTERISTICS_H_ + + +/* + * Protocol Characteristics - Characteristics defined for protocols. + */ + + +/*! +@defined kIOPropertyProtocolCharacteristicsKey +@discussion This key is used to define Protocol Characteristics for a particular +protocol and it has an associated dictionary which lists the +protocol characteristics. + +Requirement: Mandatory + +Example: +
+@textblock
+
+	Protocol Characteristics
+	
+		Physical Interconnect
+		ATAPI
+		Physical Interconnect Location
+		Internal
+	
+
+@/textblock
+
+*/ +#define kIOPropertyProtocolCharacteristicsKey "Protocol Characteristics" + + +/*! +@defined kIOPropertySCSIInitiatorIdentifierKey +@discussion An identifier that will uniquely identify this SCSI Initiator for the +SCSI Domain. + +Requirement: Mandatory for SCSI Parallel Interface, SAS, +and Fibre Channel Interface. + +Example: +
+@textblock
+
+	Protocol Characteristics
+	
+		Physical Interconnect
+		SCSI Parallel Interface
+		Physical Interconnect Location
+		Internal
+		SCSI Initiator Identifier
+		7
+	
+
+@/textblock
+
+*/ +#define kIOPropertySCSIInitiatorIdentifierKey "SCSI Initiator Identifier" + + +/*! +@defined kIOPropertySCSIDomainIdentifierKey +@discussion An identifier that will uniquely identify this SCSI Domain for the +Physical Interconnect type. This identifier is only guaranteed to be unique for +any given Physical Interconnect and is not guaranteed to be the same across +restarts or shutdowns. + +Requirement: Mandatory for SCSI Parallel Interface and Fibre Channel Interface. + +Example: +
+@textblock
+
+	Protocol Characteristics
+	
+		Physical Interconnect
+		SCSI Parallel Interface
+		Physical Interconnect Location
+		Internal
+		SCSI Domain Identifier
+		0
+	
+
+@/textblock
+
+*/ +#define kIOPropertySCSIDomainIdentifierKey "SCSI Domain Identifier" + + +/*! +@defined kIOPropertySCSITargetIdentifierKey +@discussion This is the SCSI Target Identifier for a given SCSI Target Device. + +Requirement: Mandatory for SCSI Parallel Interface and Fibre Channel Interface. + +Example: +
+@textblock
+
+	Protocol Characteristics
+	
+		Physical Interconnect
+		SCSI Parallel Interface
+		Physical Interconnect Location
+		Internal
+		SCSI Target Identifier
+		3
+	
+
+@/textblock
+
+*/ +#define kIOPropertySCSITargetIdentifierKey "SCSI Target Identifier" + + +/*! +@defined kIOPropertySCSILogicalUnitNumberKey +@discussion This key is the SCSI Logical Unit Number for the device server +controlled by the driver. + +Requirement: Mandatory for SCSI Parallel Interface, SAS, and Fibre Channel Interface. + +Example: +
+@textblock
+
+	Protocol Characteristics
+	
+		Physical Interconnect
+		SCSI Parallel Interface
+		Physical Interconnect Location
+		Internal
+		SCSI Logical Unit Number
+		2
+	
+
+@/textblock
+
+*/ +#define kIOPropertySCSILogicalUnitNumberKey "SCSI Logical Unit Number" + + +/*! +@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: +
+@textblock
+
+	Protocol Characteristics
+	
+		Physical Interconnect
+		SAS
+		Physical Interconnect Location
+		External
+		SAS Address
+		0011223344556677
+	
+
+@/textblock
+
+ +Example2: +
+@textblock
+
+	Controller Characteristics
+	
+		SAS Address
+		0011223344556677
+	
+
+@/textblock
+
+*/ +#define kIOPropertySASAddressKey "SAS Address" + + +/*! +@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: +
+@textblock
+
+	Protocol Characteristics
+	
+		Physical Interconnect
+		Fibre Channel Interface
+		Physical Interconnect Location
+		External
+		Node World Wide Name
+		0011223344556677
+	
+
+@/textblock
+
+ +Example2: +
+@textblock
+
+	Controller Characteristics
+	
+		Node World Wide Name
+		0011223344556677
+	
+
+@/textblock
+
+*/ +#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: +
+@textblock
+
+	Protocol Characteristics
+	
+		Physical Interconnect
+		Fibre Channel Interface
+		Physical Interconnect Location
+		External
+		Port World Wide Name
+		0011223344556677
+	
+
+@/textblock
+
+ +Example2: +
+@textblock
+
+	Controller Characteristics
+	
+		Port World Wide Name
+		0011223344556677
+	
+
+@/textblock
+
+*/ +#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: +
+@textblock
+
+	Protocol Characteristics
+	
+		Physical Interconnect
+		Fibre Channel Interface
+		Physical Interconnect Location
+		External
+		Address Identifier
+		001122
+	
+
+@/textblock
+
+ +Example2: +
+@textblock
+
+	Controller Characteristics
+	
+		Address Identifier
+		001122
+	
+
+@/textblock
+
+*/ +#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: +
+@textblock
+
+	Protocol Characteristics
+	
+		Physical Interconnect
+		Fibre Channel Interface
+		Physical Interconnect Location
+		External
+		AL_PA
+		04
+	
+
+@/textblock
+
+ +Example2: +
+@textblock
+
+	Controller Characteristics
+	
+		AL_PA
+		04
+	
+
+@/textblock
+
+*/ +#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: +
+@textblock
+
+	Controller Characteristics
+	
+		Port Status
+		Link Established
+	
+
+@/textblock
+
+*/ +#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: +
+@textblock
+
+	Controller Characteristics
+	
+		Port Speed
+		Automatic (1 Gigabit)
+	
+
+@/textblock
+
+*/ +#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: +
+@textblock
+
+	Controller Characteristics
+	
+		Port Topology
+		Automatic (N_Port)
+	
+
+@/textblock
+
+*/ +#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: +
+@textblock
+
+	Controller Characteristics
+	
+		Port Description
+		Channel A
+	
+
+@/textblock
+
+*/ +#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: +
+@textblock
+
+	Controller Characteristics
+	
+		SCSI Parallel Signaling Type
+		High Voltage Differential
+	
+
+@/textblock
+
+*/ +#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: +
+@textblock
+
+	Controller Characteristics
+	
+		Fibre Channel Cabling Type
+		Copper
+	
+
+@/textblock
+
+*/ +#define kIOPropertyFibreChannelCableDescriptionKey "Fibre Channel Cabling Type" + + +/*! +@defined kIOPropertyPhysicalInterconnectTypeKey +@discussion This key is used to define the Physical Interconnect to which +a device is attached. + +Requirement: Mandatory. + +Example: +
+@textblock
+
+	Protocol Characteristics
+	
+		Physical Interconnect
+		SCSI Parallel Interface
+		Physical Interconnect Location
+		Internal
+	
+
+@/textblock
+
+*/ +#define kIOPropertyPhysicalInterconnectTypeKey "Physical Interconnect" + + +/*! +@defined kIOPropertyPhysicalInterconnectLocationKey +@discussion This key is used to define the Physical Interconnect +Location. + +Requirement: Mandatory. + +Example: +
+@textblock
+
+	Protocol Characteristics
+	
+		Physical Interconnect
+		SCSI Parallel Interface
+		Physical Interconnect Location
+		Internal
+	
+
+@/textblock
+
+*/ +#define kIOPropertyPhysicalInterconnectLocationKey "Physical Interconnect Location" + + +/*! +@defined kIOPropertySCSIProtocolMultiInitKey +@discussion This protocol characteristics key is used to inform the system +that the protocol supports having multiple devices that act as initiators. + +Requirement: Optional. + +Example: +
+@textblock
+
+	Protocol Characteristics
+	
+		Physical Interconnect
+		Fibre Channel Interface
+		Physical Interconnect Location
+		External
+		Multiple Initiators
+		True
+	
+
+@/textblock
+
+*/ +#define kIOPropertySCSIProtocolMultiInitKey "Multiple Initiators" + + +/* + * Values - Values for the characteristics defined above. + */ + + +/*! +@defined kIOPropertyInternalKey +@discussion This key defines the value of Internal for the key +kIOPropertyPhysicalInterconnectLocationKey. If the device is +connected to an internal bus, this key should be set. + +Example: +
+@textblock
+
+	Protocol Characteristics
+	
+		Physical Interconnect
+		ATA
+		Physical Interconnect Location
+		Internal
+	
+
+@/textblock
+
+*/ +#define kIOPropertyInternalKey "Internal" + + +/*! +@defined kIOPropertyExternalKey +@discussion This key defines the value of External for the key +kIOPropertyPhysicalInterconnectLocationKey. If the device is +connected to an external bus, this key should be set. + +Example: +
+@textblock
+
+	Protocol Characteristics
+	
+		Physical Interconnect
+		Fibre Channel Interface
+		Physical Interconnect Location
+		External
+	
+
+@/textblock
+
+*/ +#define kIOPropertyExternalKey "External" + + +/*! +@defined kIOPropertyInternalExternalKey +@discussion This key defines the value of Internal/External for the key +kIOPropertyPhysicalInterconnectLocationKey. If the device is connected +to a bus and it is indeterminate whether it is internal or external, +this key should be set. + +Example: +
+@textblock
+
+	Protocol Characteristics
+	
+		Physical Interconnect
+		SCSI Parallel Interface
+		Physical Interconnect Location
+		Internal/External
+	
+
+@/textblock
+
+*/ +#define kIOPropertyInternalExternalKey "Internal/External" + + +/*! +@defined kIOPropertyInterconnectFileKey +@discussion This key defines the value of File for the key +kIOPropertyPhysicalInterconnectLocationKey. If the device is a file +that is being represented as a storage device, this key should be set. + +NOTE: This key should only be used when the Physical Interconnect is set to +Virtual Interface. + +Example: +
+@textblock
+
+	Protocol Characteristics
+	
+		Physical Interconnect
+		Virtual Interface
+		Physical Interconnect Location
+		File
+	
+
+@/textblock
+
+*/ +#define kIOPropertyInterconnectFileKey "File" + + +/*! +@defined kIOPropertyInterconnectRAMKey +@discussion This key defines the value of RAM for the key +kIOPropertyPhysicalInterconnectLocationKey. If the device is system memory +that is being represented as a storage device, this key should be set. + +NOTE: This key should only be used when the Physical Interconnect is set to +Virtual Interface. + +Example: +
+@textblock
+
+	Protocol Characteristics
+	
+		Physical Interconnect
+		Virtual Interface
+		Physical Interconnect Location
+		RAM
+	
+
+@/textblock
+
+*/ +#define kIOPropertyInterconnectRAMKey "RAM" + + +/*! +@defined kIOPropertyPhysicalInterconnectTypeATA +@discussion This key defines the value of ATA for the key +kIOPropertyPhysicalInterconnectTypeKey. If the device is connected +to an ATA bus, this key should be set. + +Example: +
+@textblock
+
+	Protocol Characteristics
+	
+		Physical Interconnect
+		ATA
+		Physical Interconnect Location
+		Internal
+	
+
+@/textblock
+
+*/ +#define kIOPropertyPhysicalInterconnectTypeATA "ATA" + + +/*! +@defined kIOPropertyPhysicalInterconnectTypeSerialATA +@discussion This key defines the value of SATA for the key +kIOPropertyPhysicalInterconnectTypeKey. If the device is connected +to a SATA bus, this key should be set. + +Example: +
+@textblock
+
+	Protocol Characteristics
+	
+		Physical Interconnect
+		SATA
+		Physical Interconnect Location
+		Internal
+	
+
+@/textblock
+
+*/ +#define kIOPropertyPhysicalInterconnectTypeSerialATA "SATA" + + +/*! +@defined kIOPropertyPhysicalInterconnectTypeSerialAttachedSCSI +@discussion This key defines the value of SAS for the key +kIOPropertyPhysicalInterconnectTypeKey. If the device is connected +to a SAS bus, this key should be set. + +Example: +
+@textblock
+
+	Protocol Characteristics
+	
+		Physical Interconnect
+		SAS
+		Physical Interconnect Location
+		External
+	
+
+@/textblock
+
+*/ +#define kIOPropertyPhysicalInterconnectTypeSerialAttachedSCSI "SAS" + + +/*! +@defined kIOPropertyPhysicalInterconnectTypeATAPI +@discussion This key defines the value of ATAPI for the key +kIOPropertyPhysicalInterconnectTypeKey. If the device is connected +to an ATA bus and follows the ATAPI command specification, this key +should be set. + +Example: +
+@textblock
+
+	Protocol Characteristics
+	
+		Physical Interconnect
+		ATAPI
+		Physical Interconnect Location
+		Internal
+	
+
+@/textblock
+
+*/ +#define kIOPropertyPhysicalInterconnectTypeATAPI "ATAPI" + + +/*! +@defined kIOPropertyPhysicalInterconnectTypeUSB +@discussion This key defines the value of USB for the key +kIOPropertyPhysicalInterconnectTypeKey. If the device is connected +to a USB port, this key should be set. + +Example: +
+@textblock
+
+	Protocol Characteristics
+	
+		Physical Interconnect
+		USB
+		Physical Interconnect Location
+		External
+	
+
+@/textblock
+
+*/ +#define kIOPropertyPhysicalInterconnectTypeUSB "USB" + + +/*! +@defined kIOPropertyPhysicalInterconnectTypeFireWire +@discussion This key defines the value of USB for the key +kIOPropertyPhysicalInterconnectTypeKey. If the device is connected +to a FireWire port, this key should be set. + +Example: +
+@textblock
+
+	Protocol Characteristics
+	
+		Physical Interconnect
+		FireWire
+		Physical Interconnect Location
+		External
+	
+
+@/textblock
+
+*/ +#define kIOPropertyPhysicalInterconnectTypeFireWire "FireWire" + + +/*! + @defined kIOPropertyPhysicalInterconnectTypeSecureDigital + @discussion This key defines the value of Secure Digital for the key + kIOPropertyPhysicalInterconnectTypeSecureDigital. If the device is a + connected to a Secure Digital port and follows the Secure Digital + specification, this key should be set. + + Example: +
+ @textblock
+ 
+    Protocol Characteristics
+    
+        Physical Interconnect
+        Secure Digital
+        Physical Interconnect Location
+        Internal
+    
+ 
+ @/textblock
+ 
+ */ +#define kIOPropertyPhysicalInterconnectTypeSecureDigital "Secure Digital" + + +/*! +@defined kIOPropertyPhysicalInterconnectTypeSCSIParallel +@discussion This key defines the value of SCSI Parallel Interface for the key +kIOPropertyPhysicalInterconnectTypeKey. If the device is connected +to a SCSI Parallel port, this key should be set. + +Example: +
+@textblock
+
+	Protocol Characteristics
+	
+		Physical Interconnect
+		SCSI Parallel Interface
+		Physical Interconnect Location
+		External
+	
+
+@/textblock
+
+*/ +#define kIOPropertyPhysicalInterconnectTypeSCSIParallel "SCSI Parallel Interface" + + +/*! +@defined kIOPropertyPhysicalInterconnectTypeFibreChannel +@discussion This key defines the value of Fibre Channel Interface for the key +kIOPropertyPhysicalInterconnectTypeKey. If the device is connected +to a Fibre Channel port, this key should be set. + +Example: +
+@textblock
+
+	Protocol Characteristics
+	
+		Physical Interconnect
+		Fibre Channel Interface
+		Physical Interconnect Location
+		External
+	
+
+@/textblock
+
+*/ +#define kIOPropertyPhysicalInterconnectTypeFibreChannel "Fibre Channel Interface" + + +/*! +@defined kIOPropertyPhysicalInterconnectTypeVirtual +@discussion This key defines the value of Virtual Interface for the key +kIOPropertyPhysicalInterconnectTypeVirtual. If the device is being made to look +like a storage device, but is not such in actuality, such as a File or RAM, this +key should be set. + +Example: +
+@textblock
+
+	Protocol Characteristics
+	
+		Physical Interconnect
+		Virtual Interface
+		Physical Interconnect Location
+		File
+	
+
+@/textblock
+
+*/ +#define kIOPropertyPhysicalInterconnectTypeVirtual "Virtual Interface" + + +/*! +@defined kIOPropertyPortStatusLinkEstablishedKey +@discussion This key defines the value of Link Established for the key +kIOPropertyPortStatusKey. + +Example: +
+@textblock
+
+	Controller Characteristics
+	
+		Port Status
+		Link Established
+	
+
+@/textblock
+
+*/ +#define kIOPropertyPortStatusLinkEstablishedKey "Link Established" + + +/*! +@defined kIOPropertyPortStatusNoLinkEstablishedKey +@discussion This key defines the value of No Link Established for the key +kIOPropertyPortStatusKey. + +Example: +
+@textblock
+
+	Controller Characteristics
+	
+		Port Status
+		No Link Established
+	
+
+@/textblock
+
+*/ +#define kIOPropertyPortStatusNoLinkEstablishedKey "No Link Established" + + +/*! +@defined kIOPropertyPortStatusLinkFailedKey +@discussion This key defines the value of Link Failed for the key +kIOPropertyPortStatusKey. + +Example: +
+@textblock
+
+	Controller Characteristics
+	
+		Port Status
+		Link Failed
+	
+
+@/textblock
+
+*/ +#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: +
+@textblock
+
+	Controller Characteristics
+	
+		Port Speed
+		Automatic
+	
+
+@/textblock
+
+*/ +#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: +
+@textblock
+
+	Controller Characteristics
+	
+		Port Speed
+		1 Gigabit
+	
+
+@/textblock
+
+*/ +#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: +
+@textblock
+
+	Controller Characteristics
+	
+		Port Speed
+		1.5 Gigabit
+	
+
+@/textblock
+
+*/ +#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: +
+@textblock
+
+	Controller Characteristics
+	
+		Port Speed
+		2 Gigabit
+	
+
+@/textblock
+
+*/ +#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: +
+@textblock
+
+	Controller Characteristics
+	
+		Port Speed
+		3 Gigabit
+	
+
+@/textblock
+
+*/ +#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: +
+@textblock
+
+	Controller Characteristics
+	
+		Port Speed
+		4 Gigabit
+	
+
+@/textblock
+
+*/ +#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: +
+@textblock
+
+	Controller Characteristics
+	
+		Port Speed
+		6 Gigabit
+	
+
+@/textblock
+
+*/ +#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: +
+@textblock
+
+	Controller Characteristics
+	
+		Port Speed
+		8 Gigabit
+	
+
+@/textblock
+
+*/ +#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: +
+@textblock
+
+	Controller Characteristics
+	
+		Port Speed
+		10 Gigabit
+	
+
+@/textblock
+
+*/ +#define kIOPropertyPortSpeed10GigabitKey "10 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: +
+@textblock
+
+	Controller Characteristics
+	
+		Port Speed
+		Automatic (1 Gigabit)
+	
+
+@/textblock
+
+*/ +#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: +
+@textblock
+
+	Controller Characteristics
+	
+		Port Speed
+		Automatic (1.5 Gigabit)
+	
+
+@/textblock
+
+*/ +#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: +
+@textblock
+
+	Controller Characteristics
+	
+		Port Speed
+		Automatic (2 Gigabit)
+	
+
+@/textblock
+
+*/ +#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: +
+@textblock
+
+	Controller Characteristics
+	
+		Port Speed
+		Automatic (3 Gigabit)
+	
+
+@/textblock
+
+*/ +#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: +
+@textblock
+
+	Controller Characteristics
+	
+		Port Speed
+		Automatic (4 Gigabit)
+	
+
+@/textblock
+
+*/ +#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: +
+@textblock
+
+	Controller Characteristics
+	
+		Port Speed
+		Automatic (6 Gigabit)
+	
+
+@/textblock
+
+*/ +#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: +
+@textblock
+
+	Controller Characteristics
+	
+		Port Speed
+		Automatic (8 Gigabit)
+	
+
+@/textblock
+
+*/ +#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: +
+@textblock
+
+	Controller Characteristics
+	
+		Port Speed
+		Automatic (10 Gigabit)
+	
+
+@/textblock
+
+*/ +#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: +
+@textblock
+
+	Controller Characteristics
+	
+		Port Topology
+		Automatic
+	
+
+@/textblock
+
+*/ +#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: +
+@textblock
+
+	Controller Characteristics
+	
+		Port Topology
+		N_Port
+	
+
+@/textblock
+
+*/ +#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: +
+@textblock
+
+	Controller Characteristics
+	
+		Port Topology
+		NL_Port
+	
+
+@/textblock
+
+*/ +#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: +
+@textblock
+
+	Controller Characteristics
+	
+		Port Topology
+		Automatic (N_Port)
+	
+
+@/textblock
+
+*/ +#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: +
+@textblock
+
+	Controller Characteristics
+	
+		Port Topology
+		Automatic (NL_Port)
+	
+
+@/textblock
+
+*/ +#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: +
+@textblock
+
+	Controller Characteristics
+	
+		SCSI Parallel Signaling Type
+		High Voltage Differential
+	
+
+@/textblock
+
+*/ +#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: +
+@textblock
+
+	Controller Characteristics
+	
+		SCSI Parallel Signaling Type
+		Low Voltage Differential
+	
+
+@/textblock
+
+*/ +#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: +
+@textblock
+
+	Controller Characteristics
+	
+		SCSI Parallel Signaling Type
+		Single Ended
+	
+
+@/textblock
+
+*/ +#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: +
+@textblock
+
+	Controller Characteristics
+	
+		Fibre Channel Cabling Type
+		Copper
+	
+
+@/textblock
+
+*/ +#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: +
+@textblock
+
+	Controller Characteristics
+	
+		Fibre Channel Cabling Type
+		Fiber Optic
+	
+
+@/textblock
+
+*/ +#define kIOPropertyFibreChannelCableDescriptionFiberOpticKey "Fiber Optic" + + +#endif /* _IOKIT_IO_STORAGE_PROTOCOL_CHARACTERISTICS_H_ */ Index: branches/azimutz/Cleancut/i386/include/IOKit/storage/IOBDMedia.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/storage/IOBDMedia.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/storage/IOBDMedia.h (revision 885) @@ -0,0 +1,297 @@ +/* + * Copyright (c) 2006-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 IOBDMedia + * @abstract + * This header contains the IOBDMedia class definition. + */ + +#ifndef _IOBDMEDIA_H +#define _IOBDMEDIA_H + +/*! + * @defined kIOBDMediaClass + * @abstract + * kIOBDMediaClass is the name of the IOBDMedia class. + * @discussion + * kIOBDMediaClass is the name of the IOBDMedia class. + */ + +#define kIOBDMediaClass "IOBDMedia" + +/*! + * @defined kIOBDMediaTypeKey + * @abstract + * kIOBDMediaTypeKey is a property of IOBDMedia objects. It has an OSString + * value. + * @discussion + * The kIOBDMediaTypeKey property identifies the BD media type (BD-ROM, BD-R, + * BD-RE, etc). See the kIOBDMediaType contants for possible values. + */ + +#define kIOBDMediaTypeKey "Type" + +/*! + * @defined kIOBDMediaTypeROM + * The kIOBDMediaTypeKey constant for BD-ROM media. + */ + +#define kIOBDMediaTypeROM "BD-ROM" + +/*! + * @defined kIOBDMediaTypeR + * The kIOBDMediaTypeKey constant for BD-R media. + */ + +#define kIOBDMediaTypeR "BD-R" + +/*! + * @defined kIOBDMediaTypeRE + * The kIOBDMediaTypeKey constant for BD-RE media. + */ + +#define kIOBDMediaTypeRE "BD-RE" + +#ifdef KERNEL +#ifdef __cplusplus + +/* + * Kernel + */ + +#include +#include + +/*! + * @class IOBDMedia + * @abstract + * The IOBDMedia class is a random-access disk device abstraction for BDs. + * @discussion + * The IOBDMedia class is a random-access disk device abstraction for BDs. + */ + +class IOBDMedia : public IOMedia +{ + OSDeclareDefaultStructors(IOBDMedia) + +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 -- IOBDBlockStorageDriver. + * This method serves simply as a convenience to subclass developers. + */ + + virtual IOBDBlockStorageDriver * getProvider() const; + + /* + * Compare the properties in the supplied table to this object's properties. + */ + + virtual bool matchPropertyTable(OSDictionary * table, SInt32 * score); + + /*! + * @function reportKey + * @discussion + * Issue an MMC REPORT KEY command. + * @param buffer + * Buffer for the data transfer. The size of the buffer implies the size of + * the data transfer. + * @param keyClass + * As documented by MMC. + * @param address + * As documented by MMC. + * @param grantID + * As documented by MMC. + * @param format + * As documented by MMC. + * @result + * Returns the status of the data transfer. + */ + + virtual IOReturn reportKey( IOMemoryDescriptor * buffer, + UInt8 keyClass, + UInt32 address, + UInt8 grantID, + UInt8 format ); + + /*! + * @function sendKey + * @discussion + * Issue an MMC SEND KEY command. + * @param buffer + * Buffer for the data transfer. The size of the buffer implies the size of + * the data transfer. + * @param keyClass + * As documented by MMC. + * @param grantID + * As documented by MMC. + * @param format + * As documented by MMC. + * @result + * Returns the status of the data transfer. + */ + + virtual IOReturn sendKey( IOMemoryDescriptor * buffer, + UInt8 keyClass, + UInt8 grantID, + UInt8 format ); + + /*! + * @function readStructure + * @discussion + * Issue an MMC READ DISC STRUCTURE command. + * @param buffer + * Buffer for the data transfer. The size of the buffer implies the size of + * the data transfer. + * @param format + * As documented by MMC. + * @param address + * As documented by MMC. + * @param layer + * As documented by MMC. + * @param grantID + * As documented by MMC. + * @result + * Returns the status of the data transfer. + */ + + virtual IOReturn readStructure( IOMemoryDescriptor * buffer, + UInt8 format, + UInt32 address, + UInt8 layer, + UInt8 grantID ); + + /*! + * @function getSpeed + * @discussion + * Get the current speed used for data transfers. + * @param kilobytesPerSecond + * Returns the current speed used for data transfers, in kB/s. + * + * kBDSpeedMin specifies the minimum speed for all BD media (1X). + * kBDSpeedMax specifies the maximum speed supported in hardware. + * @result + * Returns the status of the operation. + */ + + virtual IOReturn getSpeed(UInt16 * kilobytesPerSecond); + + /*! + * @function setSpeed + * @discussion + * Set the speed to be used for data transfers. + * @param kilobytesPerSecond + * Speed to be used for data transfers, in kB/s. + * + * kBDSpeedMin specifies the minimum speed for all BD media (1X). + * kBDSpeedMax specifies the maximum speed supported in hardware. + * @result + * Returns the status of the operation. + */ + + virtual IOReturn setSpeed(UInt16 kilobytesPerSecond); + + /*! + * @function readDiscInfo + * @discussion + * Issue an MMC READ DISC INFORMATION command. + * @param buffer + * Buffer for the data transfer. The size of the buffer implies the size of + * the data transfer. + * @param type + * Reserved for future use. Set to zero. + * @param actualByteCount + * Returns the actual number of bytes transferred in the data transfer. + * @result + * Returns the status of the data transfer. + */ + + virtual IOReturn readDiscInfo( IOMemoryDescriptor * buffer, + UInt8 type, + UInt16 * actualByteCount ); + + /*! + * @function readTrackInfo + * @discussion + * Issue an MMC READ TRACK INFORMATION command. + * @param buffer + * Buffer for the data transfer. The size of the buffer implies the size of + * the data transfer. + * @param address + * As documented by MMC. + * @param addressType + * As documented by MMC. + * @param open + * Reserved for future use. Set to zero. + * @param actualByteCount + * Returns the actual number of bytes transferred in the data transfer. + * @result + * Returns the status of the data transfer. + */ + + virtual IOReturn readTrackInfo( IOMemoryDescriptor * buffer, + UInt32 address, + UInt8 addressType, + UInt8 open, + UInt16 * actualByteCount ); + + /*! + * @function splitTrack + * @discussion + * Issue an MMC RESERVE TRACK command with the ARSV bit. + * @param address + * As documented by MMC. + * @result + * Returns the status of the operation. + */ + + virtual IOReturn splitTrack(UInt32 address); + + OSMetaClassDeclareReservedUnused(IOBDMedia, 0); + OSMetaClassDeclareReservedUnused(IOBDMedia, 1); + OSMetaClassDeclareReservedUnused(IOBDMedia, 2); + OSMetaClassDeclareReservedUnused(IOBDMedia, 3); + OSMetaClassDeclareReservedUnused(IOBDMedia, 4); + OSMetaClassDeclareReservedUnused(IOBDMedia, 5); + OSMetaClassDeclareReservedUnused(IOBDMedia, 6); + OSMetaClassDeclareReservedUnused(IOBDMedia, 7); + OSMetaClassDeclareReservedUnused(IOBDMedia, 8); + OSMetaClassDeclareReservedUnused(IOBDMedia, 9); + OSMetaClassDeclareReservedUnused(IOBDMedia, 10); + OSMetaClassDeclareReservedUnused(IOBDMedia, 11); + OSMetaClassDeclareReservedUnused(IOBDMedia, 12); + OSMetaClassDeclareReservedUnused(IOBDMedia, 13); + OSMetaClassDeclareReservedUnused(IOBDMedia, 14); + OSMetaClassDeclareReservedUnused(IOBDMedia, 15); +}; + +#endif /* __cplusplus */ +#endif /* KERNEL */ +#endif /* !_IOBDMEDIA_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/storage/IOCDMedia.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/storage/IOCDMedia.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/storage/IOCDMedia.h (revision 885) @@ -0,0 +1,553 @@ +/* + * 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 IOCDMedia + * @abstract + * This header contains the IOCDMedia class definition. + */ + +#ifndef _IOCDMEDIA_H +#define _IOCDMEDIA_H + +/*! + * @defined kIOCDMediaClass + * @abstract + * kIOCDMediaClass is the name of the IOCDMedia class. + * @discussion + * kIOCDMediaClass is the name of the IOCDMedia class. + */ + +#define kIOCDMediaClass "IOCDMedia" + +/*! + * @defined kIOCDMediaTOCKey + * @abstract + * kIOCDMediaTOCKey is a property of IOCDMedia objects. It has an OSData value + * and a CDTOC structure. + * @discussion + * The kIOCDMediaTOCKey property contains the CD's full table of contents, + * formatted as a CDTOC structure. The CDTOC structure is same as what is + * returned by a READ TOC command, format 0x02. All fields in the TOC are + * guaranteed to be binary-encoded (no BCD-encoded numbers are ever passed). + */ + +#define kIOCDMediaTOCKey "TOC" + +/*! + * @defined kIOCDMediaTypeKey + * @abstract + * kIOCDMediaTypeKey is a property of IOCDMedia objects. It has an OSString + * value. + * @discussion + * The kIOCDMediaTypeKey property identifies the CD media type (CD-ROM, CD-R, + * CD-RW, etc). See the kIOCDMediaType contants for possible values. + */ + +#define kIOCDMediaTypeKey "Type" + +/*! + * @defined kIOCDMediaTypeROM + * The kIOCDMediaTypeKey constant for CD-ROM media (inclusive of the CD-I, + * CD-ROM XA, and CD Audio standards, and mixed mode combinations thereof). + */ + +#define kIOCDMediaTypeROM "CD-ROM" + +/*! + * @defined kIOCDMediaTypeR + * The kIOCDMediaTypeKey constant for CD Recordable (CD-R) media. + */ + +#define kIOCDMediaTypeR "CD-R" + +/*! + * @defined kIOCDMediaTypeRW + * The kIOCDMediaTypeKey constant for CD ReWritable (CD-RW) media. + */ + +#define kIOCDMediaTypeRW "CD-RW" + +#ifdef KERNEL +#ifdef __cplusplus + +/* + * Kernel + */ + +#include +#include + +/*! + * @class IOCDMedia + * @abstract + * The IOCDMedia class is a random-access disk device abstraction for CDs. + * @discussion + * The IOCDMedia class is a random-access disk device abstraction for CDs. It + * extends the IOMedia class by implementing special CD APIs, such as readCD, + * and publishing the TOC as a property of the IOCDMedia object. + */ + +class IOCDMedia : public IOMedia +{ + OSDeclareDefaultStructors(IOCDMedia) + +protected: + + struct ExpansionData { /* */ }; + ExpansionData * _expansionData; + +public: + + using IOStorage::read; + using IOStorage::write; + + /* + * Obtain this object's provider. We override the superclass's method to + * return a more specific subclass of IOService -- IOCDBlockStorageDriver. + * This method serves simply as a convenience to subclass developers. + */ + + virtual IOCDBlockStorageDriver * getProvider() const; + + /* + * Compare the properties in the supplied table to this object's properties. + */ + + virtual bool matchPropertyTable(OSDictionary * table, SInt32 * score); + + /*! + * @function read + * @discussion + * Read data from the storage object at the specified byte offset into the + * specified buffer, asynchronously. When the read completes, the caller + * will be notified via the specified completion action. + * + * The buffer will be retained for the duration of the read. + * @param client + * Client requesting the read. + * @param byteStart + * Starting byte offset for the data transfer. + * @param buffer + * Buffer for the data transfer. The size of the buffer implies the size of + * the data transfer. + * @param attributes + * Attributes of the data transfer. See IOStorageAttributes. It is the + * responsibility of the callee to maintain the information for the duration + * of the data transfer, as necessary. + * @param completion + * Completion routine to call once the data transfer is complete. It is the + * responsibility of the callee to maintain the information for the duration + * of the data transfer, as necessary. + */ + + virtual void read(IOService * client, + UInt64 byteStart, + IOMemoryDescriptor * buffer, + IOStorageAttributes * attributes, + IOStorageCompletion * completion); + + /* + * @function write + * @discussion + * Write data into the storage object at the specified byte offset from the + * specified buffer, asynchronously. When the write completes, the caller + * will be notified via the specified completion action. + * + * The buffer will be retained for the duration of the write. + * @param client + * Client requesting the write. + * @param byteStart + * Starting byte offset for the data transfer. + * @param buffer + * Buffer for the data transfer. The size of the buffer implies the size of + * the data transfer. + * @param attributes + * Attributes of the data transfer. See IOStorageAttributes. It is the + * responsibility of the callee to maintain the information for the duration + * of the data transfer, as necessary. + * @param completion + * Completion routine to call once the data transfer is complete. It is the + * responsibility of the callee to maintain the information for the duration + * of the data transfer, as necessary. + */ + + virtual void write(IOService * client, + UInt64 byteStart, + IOMemoryDescriptor * buffer, + IOStorageAttributes * attributes, + IOStorageCompletion * completion); + + /*! + * @function readCD + * @discussion + * Read data from the CD media object at the specified byte offset into the + * specified buffer, asynchronously. Special areas of the CD sector can be + * read via this method, such as the header and subchannel data. When the + * read completes, the caller will be notified via the specified completion + * action. + * + * The buffer will be retained for the duration of the read. + * @param client + * Client requesting the read. + * @param byteStart + * Starting byte offset for the data transfer (see sectorArea parameter). + * @param buffer + * Buffer for the data transfer. The size of the buffer implies the size of + * the data transfer. + * @param sectorArea + * Sector area(s) to read. The sum of each area's size defines the natural + * block size of the media for the call. This should be taken into account + * when computing the address of byteStart. See IOCDTypes.h. + * @param sectorType + * Sector type that is expected. The data transfer is terminated as soon as + * data is encountered that does not match the expected type. + * @param attributes + * Attributes of the data transfer. See IOStorageAttributes. It is the + * responsibility of the callee to maintain the information for the duration + * of the data transfer, as necessary. + * @param completion + * Completion routine to call once the data transfer is complete. It is the + * responsibility of the callee to maintain the information for the duration + * of the data transfer, as necessary. + */ + +#ifdef __LP64__ + virtual void readCD(IOService * client, + UInt64 byteStart, + IOMemoryDescriptor * buffer, + CDSectorArea sectorArea, + CDSectorType sectorType, + IOStorageAttributes * attributes, + IOStorageCompletion * completion); +#else /* !__LP64__ */ + virtual void readCD(IOService * client, + UInt64 byteStart, + IOMemoryDescriptor * buffer, + CDSectorArea sectorArea, + CDSectorType sectorType, + IOStorageCompletion completion); +#endif /* !__LP64__ */ + + /*! + * @function readCD + * @discussion + * Read data from the CD media object at the specified byte offset into the + * specified buffer, synchronously. Special areas of the CD sector can be + * read via this method, such as the header and subchannel data. When the + * read completes, this method will return to the caller. The actual byte + * count field is optional. + * @param client + * Client requesting the read. + * @param byteStart + * Starting byte offset for the data transfer (see sectorArea parameter). + * @param buffer + * Buffer for the data transfer. The size of the buffer implies the size of + * the data transfer. + * @param sectorArea + * Sector area(s) to read. The sum of each area's size defines the natural + * block size of the media for the call. This should be taken into account + * when computing the address of byteStart. See IOCDTypes.h. + * @param sectorType + * Sector type that is expected. The data transfer is terminated as soon as + * data is encountered that does not match the expected type. + * @param attributes + * Attributes of the data transfer. See IOStorageAttributes. + * @param actualByteCount + * Returns the actual number of bytes transferred in the data transfer. + * @result + * Returns the status of the data transfer. + */ + +#ifdef __LP64__ + virtual IOReturn readCD(IOService * client, + UInt64 byteStart, + IOMemoryDescriptor * buffer, + CDSectorArea sectorArea, + CDSectorType sectorType, + IOStorageAttributes * attributes = 0, + UInt64 * actualByteCount = 0); +#else /* !__LP64__ */ + virtual IOReturn readCD(IOService * client, + UInt64 byteStart, + IOMemoryDescriptor * buffer, + CDSectorArea sectorArea, + CDSectorType sectorType, + UInt64 * actualByteCount = 0); +#endif /* !__LP64__ */ + + /*! + * @function readISRC + * @discussion + * Read the International Standard Recording Code for the specified track. + * @param track + * Track number from which to read the ISRC. + * @param isrc + * Buffer for the ISRC data. Buffer contents will be zero-terminated. + * @result + * Returns the status of the operation. + */ + + virtual IOReturn readISRC(UInt8 track, CDISRC isrc); + + /*! + * @function readMCN + * @discussion + * Read the Media Catalog Number (also known as the Universal Product Code). + * @param mcn + * Buffer for the MCN data. Buffer contents will be zero-terminated. + * @result + * Returns the status of the operation. + */ + + virtual IOReturn readMCN(CDMCN mcn); + + /*! + * @function getTOC + * @discussion + * Get the full Table Of Contents. + * + * All CDTOC fields passed across I/O Kit APIs are guaranteed to be + * binary-encoded (no BCD-encoded numbers are ever passed). + * @result + * Returns a pointer to the TOC buffer (do not deallocate). + */ + + virtual CDTOC * getTOC(); + + /*! + * @function getSpeed + * @discussion + * Get the current speed used for data transfers. + * @param kilobytesPerSecond + * Returns the current speed used for data transfers, in kB/s. + * + * kCDSpeedMin specifies the minimum speed for all CD media (1X). + * kCDSpeedMax specifies the maximum speed supported in hardware. + * @result + * Returns the status of the operation. + */ + + virtual IOReturn getSpeed(UInt16 * kilobytesPerSecond); /* 10.1.0 */ + + /*! + * @function setSpeed + * @discussion + * Set the speed to be used for data transfers. + * @param kilobytesPerSecond + * Speed to be used for data transfers, in kB/s. + * + * kCDSpeedMin specifies the minimum speed for all CD media (1X). + * kCDSpeedMax specifies the maximum speed supported in hardware. + * @result + * Returns the status of the operation. + */ + + virtual IOReturn setSpeed(UInt16 kilobytesPerSecond); /* 10.1.0 */ + + /*! + * @function readTOC + * @discussion + * Issue an MMC READ TOC/PMA/ATIP command. + * @param buffer + * Buffer for the data transfer. The size of the buffer implies the size of + * the data transfer. + * @param format + * As documented by MMC. + * @param formatAsTime + * As documented by MMC. + * @param trackOrSessionNumber + * As documented by MMC. + * @param actualByteCount + * Returns the actual number of bytes transferred in the data transfer. + * @result + * Returns the status of the data transfer. + */ + + virtual IOReturn readTOC(IOMemoryDescriptor * buffer, + CDTOCFormat format, + UInt8 formatAsTime, + UInt8 trackOrSessionNumber, + UInt16 * actualByteCount); /* 10.1.3 */ + + /*! + * @function readDiscInfo + * @discussion + * Issue an MMC READ DISC INFORMATION command. + * @param buffer + * Buffer for the data transfer. The size of the buffer implies the size of + * the data transfer. + * @param actualByteCount + * Returns the actual number of bytes transferred in the data transfer. + * @result + * Returns the status of the data transfer. + */ + + virtual IOReturn readDiscInfo(IOMemoryDescriptor * buffer, + UInt16 * actualByteCount); /* 10.1.3 */ + + /*! + * @function readTrackInfo + * @discussion + * Issue an MMC READ TRACK INFORMATION command. + * @param buffer + * Buffer for the data transfer. The size of the buffer implies the size of + * the data transfer. + * @param address + * As documented by MMC. + * @param addressType + * As documented by MMC. + * @param actualByteCount + * Returns the actual number of bytes transferred in the data transfer. + * @result + * Returns the status of the data transfer. + */ + + virtual IOReturn readTrackInfo(IOMemoryDescriptor * buffer, + UInt32 address, + CDTrackInfoAddressType addressType, + UInt16 * actualByteCount); /* 10.1.3 */ + + /* + * @function writeCD + * @discussion + * Write data into the CD media object at the specified byte offset from the + * specified buffer, asynchronously. When the write completes, the caller + * will be notified via the specified completion action. + * + * The buffer will be retained for the duration of the write. + * @param client + * Client requesting the write. + * @param byteStart + * Starting byte offset for the data transfer (see sectorArea parameter). + * @param buffer + * Buffer for the data transfer. The size of the buffer implies the size of + * the data transfer. + * @param sectorArea + * Sector area(s) to write. The sum of each area's size defines the natural + * block size of the media for the call. This should be taken into account + * when computing the address of byteStart. See IOCDTypes.h. + * @param sectorType + * Sector type that is expected. + * @param attributes + * Attributes of the data transfer. See IOStorageAttributes. It is the + * responsibility of the callee to maintain the information for the duration + * of the data transfer, as necessary. + * @param completion + * Completion routine to call once the data transfer is complete. It is the + * responsibility of the callee to maintain the information for the duration + * of the data transfer, as necessary. + */ + +#ifdef __LP64__ + virtual void writeCD(IOService * client, + UInt64 byteStart, + IOMemoryDescriptor * buffer, + CDSectorArea sectorArea, + CDSectorType sectorType, + IOStorageAttributes * attributes, + IOStorageCompletion * completion); +#else /* !__LP64__ */ + virtual void writeCD(IOService * client, + UInt64 byteStart, + IOMemoryDescriptor * buffer, + CDSectorArea sectorArea, + CDSectorType sectorType, + IOStorageCompletion completion); /* 10.2.0 */ +#endif /* !__LP64__ */ + + /* + * @function writeCD + * @discussion + * Write data into the CD media object at the specified byte offset from the + * specified buffer, synchronously. When the write completes, this method + * will return to the caller. The actual byte count field is optional. + * @param client + * Client requesting the write. + * @param byteStart + * Starting byte offset for the data transfer (see sectorArea parameter). + * @param buffer + * Buffer for the data transfer. The size of the buffer implies the size of + * the data transfer. + * @param sectorArea + * Sector area(s) to write. The sum of each area's size defines the natural + * block size of the media for the call. This should be taken into account + * when computing the address of byteStart. See IOCDTypes.h. + * @param sectorType + * Sector type that is expected. + * @param attributes + * Attributes of the data transfer. See IOStorageAttributes. + * @param actualByteCount + * Returns the actual number of bytes transferred in the data transfer. + * @result + * Returns the status of the data transfer. + */ + +#ifdef __LP64__ + virtual IOReturn writeCD(IOService * client, + UInt64 byteStart, + IOMemoryDescriptor * buffer, + CDSectorArea sectorArea, + CDSectorType sectorType, + IOStorageAttributes * attributes = 0, + UInt64 * actualByteCount = 0); +#else /* !__LP64__ */ + virtual IOReturn writeCD(IOService * client, + UInt64 byteStart, + IOMemoryDescriptor * buffer, + CDSectorArea sectorArea, + CDSectorType sectorType, + UInt64 * actualByteCount = 0); /* 10.2.0 */ +#endif /* !__LP64__ */ + +#ifdef __LP64__ + OSMetaClassDeclareReservedUnused(IOCDMedia, 0); + OSMetaClassDeclareReservedUnused(IOCDMedia, 1); + OSMetaClassDeclareReservedUnused(IOCDMedia, 2); + OSMetaClassDeclareReservedUnused(IOCDMedia, 3); + OSMetaClassDeclareReservedUnused(IOCDMedia, 4); + OSMetaClassDeclareReservedUnused(IOCDMedia, 5); + OSMetaClassDeclareReservedUnused(IOCDMedia, 6); +#else /* !__LP64__ */ + OSMetaClassDeclareReservedUsed(IOCDMedia, 0); + OSMetaClassDeclareReservedUsed(IOCDMedia, 1); + OSMetaClassDeclareReservedUsed(IOCDMedia, 2); + OSMetaClassDeclareReservedUsed(IOCDMedia, 3); + OSMetaClassDeclareReservedUsed(IOCDMedia, 4); + OSMetaClassDeclareReservedUsed(IOCDMedia, 5); + OSMetaClassDeclareReservedUsed(IOCDMedia, 6); +#endif /* !__LP64__ */ + OSMetaClassDeclareReservedUnused(IOCDMedia, 7); + OSMetaClassDeclareReservedUnused(IOCDMedia, 8); + OSMetaClassDeclareReservedUnused(IOCDMedia, 9); + OSMetaClassDeclareReservedUnused(IOCDMedia, 10); + OSMetaClassDeclareReservedUnused(IOCDMedia, 11); + OSMetaClassDeclareReservedUnused(IOCDMedia, 12); + OSMetaClassDeclareReservedUnused(IOCDMedia, 13); + OSMetaClassDeclareReservedUnused(IOCDMedia, 14); + OSMetaClassDeclareReservedUnused(IOCDMedia, 15); +}; + +#endif /* __cplusplus */ +#endif /* KERNEL */ +#endif /* !_IOCDMEDIA_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/storage/IOAppleLabelScheme.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/storage/IOAppleLabelScheme.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/storage/IOAppleLabelScheme.h (revision 885) @@ -0,0 +1,191 @@ +/* + * 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@ + */ + +/* + * This header contains the IOAppleLabelScheme class definition. + */ + +#ifndef _IOAPPLELABELSCHEME_H +#define _IOAPPLELABELSCHEME_H + +#include + +/* + * kIOAppleLabelSchemeClass is the name of the IOAppleLabelScheme class. + */ + +#define kIOAppleLabelSchemeClass "IOAppleLabelScheme" + +/* + * Apple Label Scheme Definitions + */ + +#pragma pack(push, 1) /* (enable 8-bit struct packing) */ + +/* Label scheme. */ + +struct applelabel +{ + uint8_t al_boot0[416]; /* (reserved for boot area) */ + uint16_t al_magic; /* (the magic number) */ + uint16_t al_type; /* (label type) */ + uint32_t al_flags; /* (generic flags) */ + uint64_t al_offset; /* (offset of property area, bytes) */ + uint32_t al_size; /* (size of property area, bytes) */ + uint32_t al_checksum; /* (checksum of property area) */ + uint8_t al_boot1[72]; /* (reserved for boot area) */ +}; + +/* Label scheme signature (al_magic). */ + +#define AL_MAGIC 0x414C + +/* Label scheme version (al_type). */ + +#define AL_TYPE_DEFAULT 0x0000 + +/* Label scheme flags (al_flags). */ + +#define AL_FLAG_DEFAULT 0x00000000 + +#pragma pack(pop) /* (reset to default struct packing) */ + +#ifdef KERNEL +#ifdef __cplusplus + +/* + * Kernel + */ + +#include + +/* + * Class + */ + +class IOAppleLabelScheme : public IOFilterScheme +{ + OSDeclareDefaultStructors(IOAppleLabelScheme); + +protected: + + struct ExpansionData { /* */ }; + ExpansionData * _expansionData; + + IOMedia * _content; + + /* + * Free all of this object's outstanding resources. + */ + + virtual void free(void); + + /* + * Scan the provider media for an Apple label scheme. + */ + + virtual IOMedia * scan(SInt32 * score); + + /* + * Ask whether the given content appears to be corrupt. + */ + + virtual bool isContentCorrupt(OSDictionary * properties); + + /* + * Ask whether the given content appears to be invalid. + */ + + virtual bool isContentInvalid(OSDictionary * properties); + + /* + * Instantiate a new media object to represent the given content. + */ + + virtual IOMedia * instantiateMediaObject(OSDictionary * properties); + + /* + * Allocate a new media object (called from instantiateMediaObject). + */ + + virtual IOMedia * instantiateDesiredMediaObject(OSDictionary * properties); + + /* + * Attach the given media object to the device tree plane. + */ + + virtual bool attachMediaObjectToDeviceTree(IOMedia * media); + + /* + * Detach the given media object from the device tree plane. + */ + + virtual void detachMediaObjectFromDeviceTree(IOMedia * media); + +public: + + /* + * Initialize this object's minimal state. + */ + + virtual bool init(OSDictionary * properties = 0); + + /* + * Determine whether the provider media contains an Apple label scheme. + */ + + virtual IOService * probe(IOService * provider, SInt32 * score); + + /* + * Publish the new media object which represents our content. + */ + + virtual bool start(IOService * provider); + + /* + * Clean up after the media object we published before terminating. + */ + + virtual void stop(IOService * provider); + + OSMetaClassDeclareReservedUnused(IOAppleLabelScheme, 0); + OSMetaClassDeclareReservedUnused(IOAppleLabelScheme, 1); + OSMetaClassDeclareReservedUnused(IOAppleLabelScheme, 2); + OSMetaClassDeclareReservedUnused(IOAppleLabelScheme, 3); + OSMetaClassDeclareReservedUnused(IOAppleLabelScheme, 4); + OSMetaClassDeclareReservedUnused(IOAppleLabelScheme, 5); + OSMetaClassDeclareReservedUnused(IOAppleLabelScheme, 6); + OSMetaClassDeclareReservedUnused(IOAppleLabelScheme, 7); + OSMetaClassDeclareReservedUnused(IOAppleLabelScheme, 8); + OSMetaClassDeclareReservedUnused(IOAppleLabelScheme, 9); + OSMetaClassDeclareReservedUnused(IOAppleLabelScheme, 10); + OSMetaClassDeclareReservedUnused(IOAppleLabelScheme, 11); + OSMetaClassDeclareReservedUnused(IOAppleLabelScheme, 12); + OSMetaClassDeclareReservedUnused(IOAppleLabelScheme, 13); + OSMetaClassDeclareReservedUnused(IOAppleLabelScheme, 14); + OSMetaClassDeclareReservedUnused(IOAppleLabelScheme, 15); +}; + +#endif /* __cplusplus */ +#endif /* KERNEL */ +#endif /* !_IOAPPLELABELSCHEME_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/storage/ata/IOATAStorageDefines.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/storage/ata/IOATAStorageDefines.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/storage/ata/IOATAStorageDefines.h (revision 885) @@ -0,0 +1,321 @@ +/* + * Copyright (c) 1998-2007 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_ATA_STORAGE_DEFINES_H_ +#define _IOKIT_IO_ATA_STORAGE_DEFINES_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Important word offsets in device identify data as + * defined in ATA-5 standard + */ + +enum +{ + kATAIdentifyConfiguration = 0, + kATAIdentifyLogicalCylinderCount = 1, + kATAIdentifyLogicalHeadCount = 3, + kATAIdentifySectorsPerTrack = 6, + kATAIdentifySerialNumber = 10, + kATAIdentifyFirmwareRevision = 23, + kATAIdentifyModelNumber = 27, + kATAIdentifyMultipleSectorCount = 47, + kATAIdentifyDriveCapabilities = 49, + kATAIdentifyDriveCapabilitiesExtended = 50, + kATAIdentifyPIOTiming = 51, + kATAIdentifyExtendedInfoSupport = 53, + kATAIdentifyCurrentCylinders = 54, + kATAIdentifyCurrentHeads = 55, + kATAIdentifyCurrentSectors = 56, + kATAIdentifyCurrentCapacity = 57, + kATAIdentifyCurrentMultipleSectors = 59, + kATAIdentifyLBACapacity = 60, + kATAIdentifySingleWordDMA = 62, + kATAIdentifyMultiWordDMA = 63, + kATAIdentifyAdvancedPIOModes = 64, + kATAIdentifyMinMultiWordDMATime = 65, + kATAIdentifyRecommendedMultiWordDMATime = 66, + kATAIdentifyMinPIOTime = 67, + kATAIdentifyMinPIOTimeWithIORDY = 68, + kATAIdentifyQueueDepth = 75, + kATAIdentifyMajorVersion = 80, + kATAIdentifyMinorVersion = 81, + kATAIdentifyCommandSetSupported = 82, + kATAIdentifyCommandSetSupported2 = 83, + kATAIdentifyCommandExtension1 = 84, + kATAIdentifyCommandExtension2 = 85, + kATAIdentifyCommandsEnabled = 86, + kATAIdentifyCommandsDefault = 87, + kATAIdentifyUltraDMASupported = 88, + kATAIdentifyPhysicalLogicalSectorSize = 106, + kATAIdentifyWordsPerLogicalSector1 = 117, + kATAIdentifyWordsPerLogicalSector2 = 118, + kATAIdentifyLogicalSectorAlignment = 209, + kATAIdentifyIntegrity = 255 +}; + + +/* + * Important bits in device identify data + * as defined in ATA-5 standard + */ + +enum +{ + // Configuration field (word 0) + kFixedDeviceBit = 6, // Fixed disk indicator bit + kRemoveableMediaBit = 7, // Removable media indicator bit + kNonMagneticDriveBit = 15, // Non-magnetic drive indicator bit + + kFixedDeviceMask = (1 << kFixedDeviceBit), // Mask for fixed disk indicator + kRemoveableMediaMask = (1 << kRemoveableMediaBit), // Mask for removable media indicator + kNonMagneticDriveMask = (1 << kNonMagneticDriveBit), // Mask for non-magnetic drive indicator + + // Capabilities field (word 49) + kDMABit = 8, // DMA supported bit + kLBABit = 9, // LBA supported bit + kIORDYDisableBit = 10, // IORDY can be disabled bit + kIORDYBit = 11, // IORDY supported bit + kStandbyTimerBit = 13, // Standby timer supported bit + + kDMASupportedMask = (1 << kDMABit), // Mask for DMA supported + kLBASupportedMask = (1 << kLBABit), // Mask for LBA supported + kDMADisableMask = (1 << kIORDYDisableBit), // Mask for DMA supported + kIORDYSupportedMask = (1 << kIORDYBit), // Mask for IORDY supported + kStandbySupportedMask = (1 << kStandbyTimerBit), // Mask for Standby Timer supported + + // Extensions field (word 53) + kCurFieldsValidBit = 0, // Bit to show words 54-58 are valid + kExtFieldsValidBit = 1, // Bit to show words 64-70 are valid + kCurFieldsValidMask = (1 << kCurFieldsValidBit), // Mask for current fields valid + kExtFieldsValidMask = (1 << kExtFieldsValidBit), // Extension word valid + + // Advanced PIO Transfer Modes field (word 64) + kMode3Bit = 0, // Bit to indicate mode 3 is supported + kMode3Mask = (1 << kMode3Bit), // Mask for mode 3 support + + // Integrity of Identify data (word 255) + kChecksumValidCookie = 0xA5 // Bits 7:0 if device supports feature + +}; + + +/* String size constants */ +enum +{ + kSizeOfATAModelString = 40, + kSizeOfATARevisionString = 8 +}; + +/* ATA Command timeout constants ( in milliseconds ) */ +enum +{ + kATATimeout10Seconds = 10000, + kATATimeout30Seconds = 30000, + kATATimeout45Seconds = 45000, + kATATimeout1Minute = 60000, + kATADefaultTimeout = kATATimeout30Seconds +}; + + +/* Retry constants */ +enum +{ + kATAZeroRetries = 0, + kATADefaultRetries = 4 +}; + +/* max number of blocks supported in ATA transaction */ +enum +{ + kIOATASectorCount8Bit = 8, + kIOATASectorCount16Bit = 16 +}; + +enum +{ + kIOATAMaximumBlockCount8Bit = (1 << kIOATASectorCount8Bit), + kIOATAMaximumBlockCount16Bit = (1 << kIOATASectorCount16Bit), + + // For backwards compatibility + kIOATAMaxBlocksPerXfer = kIOATAMaximumBlockCount8Bit +}; + + + +/* Power Management time constants (in seconds) */ +enum +{ + kSecondsInAMinute = 60, + k5Minutes = 5 * kSecondsInAMinute +}; + +/* Bits for features published in Word 82 of device identify data */ +enum +{ + kATASupportsSMARTBit = 0, + kATASupportsPowerManagementBit = 3, + kATASupportsWriteCacheBit = 5 +}; + +/* Masks for features published in Word 82 of device identify data */ +enum +{ + kATASupportsSMARTMask = (1 << kATASupportsSMARTBit), + kATASupportsPowerManagementMask = (1 << kATASupportsPowerManagementBit), + kATASupportsWriteCacheMask = (1 << kATASupportsWriteCacheBit) +}; + +/* Bits for features published in Word 83 of device identify data */ +enum +{ + kATASupportsCompactFlashBit = 2, + kATASupportsAdvancedPowerManagementBit = 3, + + kATASupports48BitAddressingBit = 10, + + kATASupportsFlushCacheBit = 12, + kATASupportsFlushCacheExtendedBit = 13 +}; + +/* Masks for features published in Word 83 of device identify data */ +enum +{ + kATASupportsCompactFlashMask = (1 << kATASupportsCompactFlashBit), + kATASupportsAdvancedPowerManagementMask = (1 << kATASupportsAdvancedPowerManagementBit), + + kATASupports48BitAddressingMask = (1 << kATASupports48BitAddressingBit), + + kATASupportsFlushCacheMask = (1 << kATASupportsFlushCacheBit), + kATASupportsFlushCacheExtendedMask = (1 << kATASupportsFlushCacheExtendedBit), + + // Mask to ensure data is valid + kIdentifyWordValidationMask = 0xC000, + kIdentifyWordValid = 0x4000 +}; + +/* Bits for features published in Word 84 of device identify data */ +enum +{ + kATAForceUnitAccessFeatureBit = 6, +}; + +/* Masks for features published in Word 84 of device identify data */ +enum +{ + kATAForceUnitAccessFeatureMask = (1 << kATAForceUnitAccessFeatureBit), +}; + +/* Bits for features published in Word 85 of device identify data */ +enum +{ + kATAWriteCacheEnabledBit = 5 +}; + +/* Masks for features published in Word 85 of device identify data */ +enum +{ + kATAWriteCacheEnabledMask = (1 << kATAWriteCacheEnabledBit) +}; + + +/* Bits for features published in Word 106 of device identify data */ +enum +{ + kATAPhysicalLogicalEnabledBit0 = 15, + kATAPhysicalLogicalEnabledBit1 = 14, + kATAMultipleLogicalSectorsBit = 13, + kATAValidLogicalSectorSizeBit = 12 +}; + +/* Masks for features published in Word 106 of device identify data */ +enum +{ + kATAPhysicalLogicalEnabledMask = (1 << kATAPhysicalLogicalEnabledBit0) | (1 << kATAPhysicalLogicalEnabledBit1), + kATAPhysicalLogicalEnabledValue = (0 << kATAPhysicalLogicalEnabledBit0) | (1 << kATAPhysicalLogicalEnabledBit1), + kATAMultipleLogicalSectorsMask = (1 << kATAMultipleLogicalSectorsBit), + kATAValidLogicalSectorSizeMask = (1 << kATAValidLogicalSectorSizeBit), + kATAPhysicalSectorSizeMask = 0xF, + kATALogicalSectorAlignmentMask = 0x3FFF +}; + +// Property table keys +#define kIOATASupportedFeaturesKey "ATA Features" + +/* ATA supported features */ +enum +{ + kIOATAFeaturePowerManagement = 0x01, /* OBSOLETE */ + kIOATAFeatureWriteCache = 0x02, /* OBSOLETE */ + kIOATAFeatureAdvancedPowerManagement = 0x04, + kIOATAFeatureCompactFlash = 0x08, + kIOATAFeature48BitLBA = 0x10, + kIOATAFeatureSMART = 0x20 +}; + +/* ATA Advanced Power Management settings (valid settings range from 1-254), +the settings below are the more common settings */ +enum +{ + kIOATAMaxPerformance = 0xFE, + kIOATADefaultPerformance = 0x80, + kIOATAMaxPowerSavings = 0x01 +}; + +/* ATA Transfer Mode bit masks */ +enum +{ + kATAEnableUltraDMAModeMask = 0x40, + kATAEnableMultiWordDMAModeMask = 0x20, + kATAEnablePIOModeMask = 0x08 +}; + + +typedef uint32_t ATAOperationType; +enum +{ + kATAOperationTypeRead = 0, + kATAOperationTypeWrite = 1, + kATAOperationTypeFlushCache = 2, + kATAOperationTypeSMART = 3, + kATAOperationTypeConfiguration = 4, + kATAOperationTypePowerManagement = 5, + kATAOperationTypeSMS = 6 +}; + +#if defined(KERNEL) + +typedef struct __ATAIORequest * ATARequestIdentifier; + +#endif // defined(KERNEL) + +#ifdef __cplusplus +} +#endif + +#endif /* _IOKIT_IO_ATA_STORAGE_DEFINES_H_ */ Index: branches/azimutz/Cleancut/i386/include/IOKit/storage/ata/IOATAPIProtocolTransport.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/storage/ata/IOATAPIProtocolTransport.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/storage/ata/IOATAPIProtocolTransport.h (revision 885) @@ -0,0 +1,365 @@ +/* + * Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved. + * + * @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@ + */ + +/*! + @header IOATAPIProtocolTransport + Contains the class definition for IOATAPIProtocolTransport. +*/ + + +#ifndef _IOKIT_IO_ATAPI_PROTOCOL_TRANSPORT_H_ +#define _IOKIT_IO_ATAPI_PROTOCOL_TRANSPORT_H_ + +#define kIOPropertyATAPIMassStorageCharacteristics "ATAPI Mass Storage Characteristics" + +#if defined(KERNEL) && defined(__cplusplus) + +/* General IOKit includes */ +#include +#include +#include +#include + +/* IOKit ATA Family includes */ +#include +#include + +/* IOKit ATA Storage includes */ +#include + +/* SCSI Architecture Model Family includes */ +#include + +// Forward class declaration +class IOATAPIProtocolTransport; + +/*! + @typedef ATAPIClientData + @param cmd IOATACommand for request. + @param self Pointer to the object. + @param scsiTask SCSITaskIdentifier of request. + @discussion This structure is stuffed into the refcon so we can associate which + IOATACommand and SCSITaskIdentifier is completing. +*/ + +struct ATAPIClientData +{ + IOATACommand * cmd; + IOATAPIProtocolTransport * self; + SCSITaskIdentifier scsiTask; +}; +typedef struct ATAPIClientData ATAPIClientData; + + +/*! + @class IOATAPIProtocolTransport + @abstract SCSI Protocol Driver Family for ATAPI Devices. + @discussion IOATAPIProtocolTransport contains all the bus specific support for ATAPI compliant devices. + To add vendor specific features or workarounds you will sub-class the appropriate + methods of this family. +*/ + +class IOATAPIProtocolTransport : public IOSCSIProtocolServices +{ + + OSDeclareDefaultStructors ( IOATAPIProtocolTransport ) + +public: + + // ---- IOService methods overridden ---- + + bool init ( OSDictionary * propTable ); + + // The start method is called to start our services. If the device + // can be controlled by this object, then we return true, else we + // return false. start() is usually used to allocate resources once + // it is determined that the device can be controlled by this object. + virtual bool start ( IOService * provider ); + + // The stop method is called to stop our services. It is primarily + // called for deallocation of resources. + virtual void stop ( IOService * provider ); + + // This method is our last chance to free all resources allocated. + virtual void free ( void ); + + +protected: + + // ---- member variables ---- + + IOATADevice * fATADevice; + ataUnitID fATAUnitID; + ataDeviceType fATADeviceType; + ataSocketType fATASocketType; + atapiConfig fATAPIPacketConfig; + UInt8 fPIOMode; + UInt8 fDMAMode; + UInt8 fUltraDMAMode; + IOCommandGate * fCommandGate; + IOCommandPool * fCommandPool; + IOATACommand * fResetCommand; + IOATACommand * fConfigCommand; + IOATACommand * fIdentifyCommand; + char fRevision[kSizeOfATARevisionString + 1]; + char fModel[kSizeOfATAModelString + 1]; + bool fWakeUpResetOccurred; + bool fPhysicallyConnected; + + // Used for low-power polling support + thread_call_t fPollingThread; + + UInt16 fDeviceIdentifyData[256]; + IOMemoryDescriptor * fDeviceIdentifyBuffer; + bool fResetInProgress; + + // Binary Compatibility instance variable expansion + struct ExpansionData + { + UInt32 fSemaphore; + UInt32 fMediaNotifyValue; + }; + ExpansionData * reserved; + + // ---- IOService methods overridden ---- + + // The message method is used to listen to messages from our provider, the ATA controller. + // It sends messages for bus reset notifications and for device removal (such as MediaBay, + // PC card, etc.) + virtual IOReturn message ( UInt32 type, IOService * provider, void * argument = 0 ); + + // ---- Protocol transport methods overridden ---- + + // Send a SCSI Command to the device. 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 ); + + // This is a stub - not implemented in upper layer yet. Eventually, there + // will be a way to abort a task or task set and this method will be called. + // It will abort any commands which have not been executed by the ATA controller + virtual SCSIServiceResponse AbortSCSICommand ( SCSITaskIdentifier request ); + + // The IsProtocolServiceSupported method will return true if the protocol + // layer supports the specified feature. + virtual bool IsProtocolServiceSupported ( SCSIProtocolFeature feature, void * serviceValue ); + + // The HandleProtocolServiceFeature method will return true if the protocol + // layer properly handled the specified feature. + virtual bool HandleProtocolServiceFeature ( SCSIProtocolFeature feature, void * serviceValue ); + + // ------ Power Management Support ------ + + // The HandlePowerOff method is called to do any bus specific activity + // necessary before shutting down and going to sleep. + virtual IOReturn HandlePowerOff ( void ); + + // The HandlePowerOn method is called to do any bus specific activity + // necessary to recover from power-on/wake from sleep (e.g. device reset on ATAPI) + virtual IOReturn HandlePowerOn ( void ); + + + // ---- Methods defined by this class ---- + + // Static callback proc for all SCSITask objects, it calls through to + // SCSITaskCallbackFunction. + static void sSCSITaskCallbackProc ( IOATACommand * cmd ); + + // Callback proc for synchronous ATA only type commands. + static void sATACallbackSync ( IOATACommand * cmd ); + + // Callback proc for asynchronous ATAPI resets. + static void sATAPIResetCallback ( IOATACommand * cmd ); + + // Callback proc that does nothing. + static void sATAPIVoidCallback ( IOATACommand * cmd ); + + // State machine for device configuration. + static void sATAPIConfigStateMachine ( IOATACommand * cmd ); + + // Used for low-power polling. + static void sPollStatusRegister ( void * xptDriver, void * refCon ); + + // Static callback for low-power polling. + static void sPollStatusRegisterCallback ( IOATACommand * cmd ); + + // This method is called by the SCSITaskCallbackFunction and it calls the + // inherited CommandCompleted message with the results of the task. + virtual void CompleteSCSITask ( SCSITaskIdentifier scsiTask, + SCSIServiceResponse serviceResponse, + SCSITaskStatus taskStatus ); + + // The SCSITaskCallbackFunction method is called by the static callback procedure + // to complete SCSITask operations. This method may be subclassed if a device + // workaround is necessary. + virtual void SCSITaskCallbackFunction ( IOATACommand * cmd, + SCSITaskIdentifier scsiTask ); + + // The ReportATAPIDeviceType method returns the ataDeviceType for ATAPI + virtual ataDeviceType ReportATAPIDeviceType ( void ) const; + + // The InspectDevice method is called to inspect the ATA device and verify + // that it is a device which can be controlled by this object + virtual bool InspectDevice ( IOATADevice * ataDevice ); + + // The AllocateATACommandObjects method is called to allocate a pool of + // IOATACommands for general purpose I/O usage. + virtual void AllocateATACommandObjects ( void ); + + // The DeallocateATACommandObjects method is called to deallocate a pool of + // IOATACommands for general purpose I/O usage. + virtual void DeallocateATACommandObjects ( void ); + + // The GetATACommandObject method is called to retrieve a command from + // the pool. Pass true to allow the method to sleep waiting for a command, + // else pass false. If false is passed, there is NO guarantee that a valid + // command will be returned. If true is passed, it IS guaranteed that a + // valid command will be returned, but the thread may be slept waiting for + // those resources. + virtual IOATACommand * GetATACommandObject ( bool okToSleep = true ); + + // The ReturnATACommandObject method is called to return a command to + // the pool. + virtual void ReturnATACommandObject ( IOATACommand * cmd ); + + // The sSwapBytes16 method is used to word-swap the Device Identify data + // on big endian systems. Since all identify data is returned in little endian + // values, it must be word-swapped before inspected. + static void sSwapBytes16 ( UInt8 * buffer, IOByteCount numBytesToSwap ); + + // The sConvertHighestBitToNumber method is used to find the highest bit in a + // word and return a numeric value. This is used to find the highest possible + // values for PIO, DMA, and UltraDMA transfer modes. + static UInt8 sConvertHighestBitToNumber ( UInt16 bitField ); + + // The sSetWakeupResetOccurred method is used to safely set member variables + // behind the command gate. + static void sSetWakeupResetOccurred ( IOATAPIProtocolTransport * driver, + bool resetOccurred ); + + // The sCheckWakeupResetOccur method is used to safely check member variables + // behind the command gate. + static void sCheckWakeupResetOccurred ( IOATAPIProtocolTransport * driver, + bool * resetOccurred ); + + // The DidWakeupResetOccur method is used to safely find out if a reset + // occurred while we were asleep. + virtual bool CheckWakeupResetOccurred ( void ); + + // The WakeupResetOccurred method is used to safely set/clear the reset flag. + virtual void SetWakeupResetOccurred ( bool resetOccurred ); + + // The SetPIOTransferMode method is used to set the programmed input-output (PIO) + // transfer mode. The highest value reported by the device is used. + virtual IOReturn SetPIOTransferMode ( IOATACommand * cmd, bool forceSync ); + + // The SetDMATransferMode method is used to set the direct memory access (DMA) + // transfer mode. The highest value reported by the device is used. + virtual IOReturn SetDMATransferMode ( IOATACommand * cmd, bool forceSync ); + + // The IdentifyAndConfigureATAPIDevice method is called to correctly identify + // and configure an ATAPI device. + virtual IOReturn IdentifyAndConfigureATAPIDevice ( void ); + + // The ConfigureATAPIDevice method is called to correctly configure the ATAPI + // device. It currently configures any PIO/DMA/UDMA transfer modes but may be + // expanded in the future. + virtual IOReturn ConfigureATAPIDevice ( void ); + + // The ReconfigureATAPIDevice method is called to correctly reconfigure the ATAPI + // device after a reset event has occurred (bus reset or device reset). It + // currently reconfigures any PIO/DMA/UDMA transfer modes but may be expanded in + // the future. + virtual IOReturn ReconfigureATAPIDevice ( void ); + + // The IdentifyATAPIDevice method is called to correctly identify the ATAPI + // device. It currently issues the Identify ATAPI Device packet command and + // uses the data to correctly configure the device. + virtual IOReturn IdentifyATAPIDevice ( void ); + + // The ResetATAPIDevice method is called to issue a Device Reset (also known + // as a SOFT RESET). This method will only reset the specified device on the + // bus. + virtual IOReturn ResetATAPIDevice ( void ); + + // The SendATASleepCommand method is called to put an ATAPI drive in sleep + // mode. + virtual IOReturn SendATASleepCommand ( void ); + + // The EnablePollingOfStatusRegister method is called to set up a timer for + // the call to PollStatusRegister. It is called when the SCSI Application Layer + // driver wants to enable low-power polling and after a poll which does not + // see a change in the register status. + virtual void EnablePollingOfStatusRegister ( void ); + + // The DisablePollingOfStatusRegister method is called to cancel any thread + // call which is doing a poll and drop the retain count on the object. + virtual void DisablePollingOfStatusRegister ( void ); + + // The PollStatusRegister method is used to do low-power polling on drives which + // support it. This feature is enabled by the SCSI Application Layer driver. + virtual void PollStatusRegister ( void * refCon ); + + // Callback method for the polling of the status register. + virtual void PollStatusRegisterCallback ( IOATACommand * cmd ); + + // The TurnDrivePowerOff method is called to turn power to the drive OFF + IOReturn TurnDrivePowerOff ( void ); + + IOReturn SendCommand ( IOATACommand * cmd ); + IOReturn GatedWaitForRequest ( void * data ); + +private: + + // Binary Compatibility reserved method space + OSMetaClassDeclareReservedUnused ( IOATAPIProtocolTransport, 1 ); + OSMetaClassDeclareReservedUnused ( IOATAPIProtocolTransport, 2 ); + OSMetaClassDeclareReservedUnused ( IOATAPIProtocolTransport, 3 ); + OSMetaClassDeclareReservedUnused ( IOATAPIProtocolTransport, 4 ); + OSMetaClassDeclareReservedUnused ( IOATAPIProtocolTransport, 5 ); + OSMetaClassDeclareReservedUnused ( IOATAPIProtocolTransport, 6 ); + OSMetaClassDeclareReservedUnused ( IOATAPIProtocolTransport, 7 ); + OSMetaClassDeclareReservedUnused ( IOATAPIProtocolTransport, 8 ); + OSMetaClassDeclareReservedUnused ( IOATAPIProtocolTransport, 9 ); + OSMetaClassDeclareReservedUnused ( IOATAPIProtocolTransport, 10 ); + OSMetaClassDeclareReservedUnused ( IOATAPIProtocolTransport, 11 ); + OSMetaClassDeclareReservedUnused ( IOATAPIProtocolTransport, 12 ); + OSMetaClassDeclareReservedUnused ( IOATAPIProtocolTransport, 13 ); + OSMetaClassDeclareReservedUnused ( IOATAPIProtocolTransport, 14 ); + OSMetaClassDeclareReservedUnused ( IOATAPIProtocolTransport, 15 ); + OSMetaClassDeclareReservedUnused ( IOATAPIProtocolTransport, 16 ); + +}; + +#endif /* defined(KERNEL) && defined(__cplusplus) */ + +#endif /* _IOKIT_IO_ATAPI_PROTOCOL_TRANSPORT_H_ */ \ No newline at end of file Index: branches/azimutz/Cleancut/i386/include/IOKit/storage/IODVDBlockStorageDriver.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/storage/IODVDBlockStorageDriver.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/storage/IODVDBlockStorageDriver.h (revision 885) @@ -0,0 +1,219 @@ +/* + * 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@ + */ +/* + * IODVDBlockStorageDriver.h + * + * This class implements DVD 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 _IODVDBLOCKSTORAGEDRIVER_H +#define _IODVDBLOCKSTORAGEDRIVER_H + +#include +#include +#include +#include + +/*! + * @defined kIODVDBlockStorageDriverClass + * @abstract + * kIODVDBlockStorageDriverClass is the name of the IODVDBlockStorageDriver class. + * @discussion + * kIODVDBlockStorageDriverClass is the name of the IODVDBlockStorageDriver class. + */ + +#define kIODVDBlockStorageDriverClass "IODVDBlockStorageDriver" + +class IODVDBlockStorageDevice; + +/*! + * @class + * IODVDBlockStorageDriver : public IOCDBlockStorageDriver + * @abstract + * Generic DVD Driver. + * @discussion + * Storage drivers are split into two parts: the Generic Driver handles + * all generic device issues, independent of the lower-level transport + * mechanism (e.g. SCSI, ATA, USB, FireWire). All storage operations + * at the Generic Driver level are translated into a series of generic + * device operations. These operations are passed via the Device Nub + * to a Transport Driver, which implements the appropriate + * transport-dependent protocol to execute these operations. + * + * To determine the write-protect state of a device (or media), for + * example, the generic driver would issue a call to the + * Transport Driver's reportWriteProtection method. If this were a SCSI + * device, its Transport Driver would issue a Mode Sense command to + * extract the write-protection status bit. The Transport Driver then + * reports true or false to the generic driver. + * + * The generic driver therefore has no knowledge of, or involvement + * with, the actual commands and mechanisms used to communicate with + * the device. It is expected that the generic driver will rarely, if + * ever, need to be subclassed to handle device idiosyncrasies; rather, + * the Transport Driver should be changed via overrides. + * + * A generic driver could be subclassed to create a different type of + * generic device. The generic driver IODVDBlockStorageDriver class is a subclass + * of IOCDBlockStorageDriver, adding DVD functions. Similarly, the Transport Driver + * IODVDBlockStorageDevice is a subclass of IOCDBlockStorageDevice, adding DVD + * functions. +*/ + +class IODVDBlockStorageDriver : public IOCDBlockStorageDriver { + + OSDeclareDefaultStructors(IODVDBlockStorageDriver) + +protected: + + struct ExpansionData { /* */ }; + ExpansionData * _expansionData; + + /* Overrides of IOCDBlockStorageDriver. */ + + virtual IOReturn acceptNewMedia(void); + + /* End of IOCDBlockStorageDriver overrides. */ + +public: + + /* + * Obtain this object's provider. We override the superclass's method to + * return a more specific subclass of IOService -- IODVDBlockStorageDevice. + * This method serves simply as a convenience to subclass developers. + */ + + virtual IODVDBlockStorageDevice * getProvider() const; + + /* Overrides of IOCDBlockStorageDriver: */ + + virtual const char * getDeviceTypeName(void); + virtual IOMedia * instantiateDesiredMediaObject(void); + virtual IOMedia * instantiateMediaObject(UInt64 base,UInt64 byteSize, + UInt32 blockSize,char *mediaName); + + /* End of IOCDBlockStorageDriver overrides. */ + + /*! + * @function reportKey + * @abstract + * Get key info from the DVD drive. + * @discussion + * This function handles the getting of key- and encryption-related data for the drive. + * @param buffer + * A buffer containing information, as documented in the specification + * "MtFuji Commands For Multimedia Devices." + * @param keyClass + * As documented by MtFuji. See DVDKeyClass. + * @param lba + * As documented by MtFuji. + * @param agid + * As documented by MtFuji. + * @param keyFormat + * As documented by MtFuji. See DVDKeyFormat. + */ + virtual IOReturn reportKey(IOMemoryDescriptor *buffer,const DVDKeyClass keyClass, + const UInt32 lba,const UInt8 agid,const DVDKeyFormat keyFormat); + + /*! + * @function sendKey + * @abstract + * Send key info to the DVD drive. + * @discussion + * This function handles the setting of key- and encryption-related data for the drive. + * @param buffer + * A buffer containing information, as documented in the specification + * "MtFuji Commands For Multimedia Devices." + * @param keyClass + * As documented by MtFuji. See DVDKeyClass. + * @param agid + * As documented by MtFuji. + * @param keyFormat + * As documented by MtFuji. See DVDKeyFormat. + */ + virtual IOReturn sendKey(IOMemoryDescriptor *buffer,const DVDKeyClass keyClass, + const UInt8 agid,const DVDKeyFormat keyFormat); + + /*! + * @function readStructure + * @abstract + * Get control structures from the DVD media. + * @discussion + * This function handles the getting of control structure data for the media. + * @param buffer + * A buffer containing information, as documented in the specification + * "MtFuji Commands For Multimedia Devices." + * @param format + * As documented by MtFuji. See DVDStructureFormat. + * @param address + * As documented by MtFuji. + * @param layer + * As documented by MtFuji. + * @param agid + * As documented by MtFuji. + */ + virtual IOReturn readStructure(IOMemoryDescriptor *buffer,const DVDStructureFormat format, + const UInt32 address,const UInt8 layer,const UInt8 agid); /* 10.1.0 */ + +#ifdef __LP64__ + OSMetaClassDeclareReservedUnused(IODVDBlockStorageDriver, 0); +#else /* !__LP64__ */ + OSMetaClassDeclareReservedUsed(IODVDBlockStorageDriver, 0); +#endif /* !__LP64__ */ + OSMetaClassDeclareReservedUnused(IODVDBlockStorageDriver, 1); + OSMetaClassDeclareReservedUnused(IODVDBlockStorageDriver, 2); + OSMetaClassDeclareReservedUnused(IODVDBlockStorageDriver, 3); + OSMetaClassDeclareReservedUnused(IODVDBlockStorageDriver, 4); + OSMetaClassDeclareReservedUnused(IODVDBlockStorageDriver, 5); + OSMetaClassDeclareReservedUnused(IODVDBlockStorageDriver, 6); + OSMetaClassDeclareReservedUnused(IODVDBlockStorageDriver, 7); + OSMetaClassDeclareReservedUnused(IODVDBlockStorageDriver, 8); + OSMetaClassDeclareReservedUnused(IODVDBlockStorageDriver, 9); + OSMetaClassDeclareReservedUnused(IODVDBlockStorageDriver, 10); + OSMetaClassDeclareReservedUnused(IODVDBlockStorageDriver, 11); + OSMetaClassDeclareReservedUnused(IODVDBlockStorageDriver, 12); + OSMetaClassDeclareReservedUnused(IODVDBlockStorageDriver, 13); + OSMetaClassDeclareReservedUnused(IODVDBlockStorageDriver, 14); + OSMetaClassDeclareReservedUnused(IODVDBlockStorageDriver, 15); + OSMetaClassDeclareReservedUnused(IODVDBlockStorageDriver, 16); + OSMetaClassDeclareReservedUnused(IODVDBlockStorageDriver, 17); + OSMetaClassDeclareReservedUnused(IODVDBlockStorageDriver, 18); + OSMetaClassDeclareReservedUnused(IODVDBlockStorageDriver, 19); + OSMetaClassDeclareReservedUnused(IODVDBlockStorageDriver, 20); + OSMetaClassDeclareReservedUnused(IODVDBlockStorageDriver, 21); + OSMetaClassDeclareReservedUnused(IODVDBlockStorageDriver, 22); + OSMetaClassDeclareReservedUnused(IODVDBlockStorageDriver, 23); + OSMetaClassDeclareReservedUnused(IODVDBlockStorageDriver, 24); + OSMetaClassDeclareReservedUnused(IODVDBlockStorageDriver, 25); + OSMetaClassDeclareReservedUnused(IODVDBlockStorageDriver, 26); + OSMetaClassDeclareReservedUnused(IODVDBlockStorageDriver, 27); + OSMetaClassDeclareReservedUnused(IODVDBlockStorageDriver, 28); + OSMetaClassDeclareReservedUnused(IODVDBlockStorageDriver, 29); + OSMetaClassDeclareReservedUnused(IODVDBlockStorageDriver, 30); + OSMetaClassDeclareReservedUnused(IODVDBlockStorageDriver, 31); +}; +#endif Index: branches/azimutz/Cleancut/i386/include/IOKit/storage/IOBlockStorageDriver.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/storage/IOBlockStorageDriver.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/storage/IOBlockStorageDriver.h (revision 885) @@ -0,0 +1,1571 @@ +/* + * 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 IOBlockStorageDriver + * @abstract + * This header contains the IOBlockStorageDriver class definition. + */ + +#ifndef _IOBLOCKSTORAGEDRIVER_H +#define _IOBLOCKSTORAGEDRIVER_H + +#include + +/*! + * @defined kIOBlockStorageDriverClass + * @abstract + * The name of the IOBlockStorageDriver class. + */ + +#define kIOBlockStorageDriverClass "IOBlockStorageDriver" + +/*! + * @defined kIOBlockStorageDriverStatisticsKey + * @abstract + * Holds a table of numeric values describing the driver's + * operating statistics. + * @discussion + * This property holds a table of numeric values describing the driver's + * operating statistics. The table is an OSDictionary, where each entry + * describes one given statistic. + */ + +#define kIOBlockStorageDriverStatisticsKey "Statistics" + +/*! + * @defined kIOBlockStorageDriverStatisticsBytesReadKey + * @abstract + * Describes the number of bytes read since the block storage + * driver was instantiated. + * @discussion + * This property describes the number of bytes read since the block storage + * driver was instantiated. It is one of the statistic entries listed under + * the top-level kIOBlockStorageDriverStatisticsKey property table. It has + * an OSNumber value. + */ + +#define kIOBlockStorageDriverStatisticsBytesReadKey "Bytes (Read)" + +/*! + * @defined kIOBlockStorageDriverStatisticsBytesWrittenKey + * @abstract + * Describes the number of bytes written since the block storage + * driver was instantiated. + * @discussion + * This property describes the number of bytes written since the block storage + * driver was instantiated. It is one of the statistic entries listed under the + * top-level kIOBlockStorageDriverStatisticsKey property table. It has an + * OSNumber value. + */ + +#define kIOBlockStorageDriverStatisticsBytesWrittenKey "Bytes (Write)" + +/*! + * @defined kIOBlockStorageDriverStatisticsReadErrorsKey + * @abstract + * Describes the number of read errors encountered since the block + * storage driver was instantiated. + * @discussion + * This property describes the number of read errors encountered since the block + * storage driver was instantiated. It is one of the statistic entries listed + * under the top-level kIOBlockStorageDriverStatisticsKey property table. It + * has an OSNumber value. + */ + +#define kIOBlockStorageDriverStatisticsReadErrorsKey "Errors (Read)" + +/*! + * @defined kIOBlockStorageDriverStatisticsWriteErrorsKey + * @abstract + * Describes the number of write errors encountered since the + * block storage driver was instantiated. + * @discussion + * This property describes the number of write errors encountered since the + * block storage driver was instantiated. It is one of the statistic entries + * listed under the top-level kIOBlockStorageDriverStatisticsKey property table. + * It has an OSNumber value. + */ + +#define kIOBlockStorageDriverStatisticsWriteErrorsKey "Errors (Write)" + +/*! + * @defined kIOBlockStorageDriverStatisticsLatentReadTimeKey + * @abstract + * Describes the number of nanoseconds of latency during reads + * since the block storage driver was instantiated. + * @discussion + * This property describes the number of nanoseconds of latency during reads + * since the block storage driver was instantiated. It is one of the statistic + * entries listed under the top-level kIOBlockStorageDriverStatisticsKey + * property table. It has an OSNumber value. + */ + +#define kIOBlockStorageDriverStatisticsLatentReadTimeKey "Latency Time (Read)" + +/*! + * @defined kIOBlockStorageDriverStatisticsLatentWriteTimeKey + * @abstract + * Describes the number of nanoseconds of latency during writes + * since the block storage driver was instantiated. + * @discussion + * This property describes the number of nanoseconds of latency during writes + * since the block storage driver was instantiated. It is one of the statistic + * entries listed under the top-level kIOBlockStorageDriverStatisticsKey + * property table. It has an OSNumber value. + */ + +#define kIOBlockStorageDriverStatisticsLatentWriteTimeKey "Latency Time (Write)" + +/*! + * @defined kIOBlockStorageDriverStatisticsReadsKey + * @abstract + * Describes the number of read operations processed since the + * block storage driver was instantiated. + * @discussion + * This property describes the number of read operations processed since the + * block storage driver was instantiated. It is one of the statistic entries + * listed under the top-level kIOBlockStorageDriverStatisticsKey property table. + * It has an OSNumber value. + */ + +#define kIOBlockStorageDriverStatisticsReadsKey "Operations (Read)" + +/*! + * @defined kIOBlockStorageDriverStatisticsWritesKey + * @abstract + * Describes the number of write operations processed since the + * block storage driver was instantiated. + * @discussion + * This property describes the number of write operations processed since the + * block storage driver was instantiated. It is one of the statistic entries + * listed under the top-level kIOBlockStorageDriverStatisticsKey property table. + * It has an OSNumber value. + */ + +#define kIOBlockStorageDriverStatisticsWritesKey "Operations (Write)" + +/*! + * @defined kIOBlockStorageDriverStatisticsReadRetriesKey + * @abstract + * Describes the number of read retries required since the block + * storage driver was instantiated. + * @discussion + * This property describes the number of read retries required since the block + * storage driver was instantiated. It is one of the statistic entries listed + * under the top-level kIOBlockStorageDriverStatisticsKey property table. It + * has an OSNumber value. + */ + +#define kIOBlockStorageDriverStatisticsReadRetriesKey "Retries (Read)" + +/*! + * @defined kIOBlockStorageDriverStatisticsWriteRetriesKey + * @abstract + * Describes the number of write retries required since the block + * storage driver was instantiated. + * @discussion + * This property describes the number of write retries required since the block + * storage driver was instantiated. It is one of the statistic entries listed + * under the top-level kIOBlockStorageDriverStatisticsKey property table. It + * has an OSNumber value. + */ + +#define kIOBlockStorageDriverStatisticsWriteRetriesKey "Retries (Write)" + +/*! + * @defined kIOBlockStorageDriverStatisticsTotalReadTimeKey + * @abstract + * Describes the number of nanoseconds spent performing reads + * since the block storage driver was instantiated. + * @discussion + * This property describes the number of nanoseconds spent performing reads + * since the block storage driver was instantiated. It is one of the statistic + * entries listed under the top-level kIOBlockStorageDriverStatisticsKey + * property table. It has an OSNumber value. + */ + +#define kIOBlockStorageDriverStatisticsTotalReadTimeKey "Total Time (Read)" + +/*! + * @defined kIOBlockStorageDriverStatisticsTotalWriteTimeKey + * @abstract + * Describes the number of nanoseconds spent performing writes + * since the block storage driver was instantiated. + * @discussion + * This property describes the number of nanoseconds spent performing writes + * since the block storage driver was instantiated. It is one of the statistic + * entries listed under the top-level kIOBlockStorageDriverStatisticsKey + * property table. It has an OSNumber value. + */ + +#define kIOBlockStorageDriverStatisticsTotalWriteTimeKey "Total Time (Write)" + +/*! + * @enum IOMediaState + * @abstract + * The different states that getMediaState() can report. + * @constant kIOMediaStateOffline + * Media is not available. + * @constant kIOMediaStateOnline + * Media is available and ready for operations. + * @constant kIOMediaStateBusy + * Media is available, but not ready for operations. + */ + +enum +{ + kIOMediaStateOffline = 0, + kIOMediaStateOnline = 1, + kIOMediaStateBusy = 2 +}; + +typedef UInt32 IOMediaState; + +#ifdef KERNEL +#ifdef __cplusplus + +/* + * Kernel + */ + +#include +#include +#include +#include + +/*! + * @class IOBlockStorageDriver + * @abstract + * The common base class for generic block storage drivers. + * @discussion + * The IOBlockStorageDriver class is the common base class for generic block + * storage drivers. It matches and communicates via an IOBlockStorageDevice + * interface, and connects to the remainder of the storage framework via the + * IOStorage protocol. It extends the IOStorage protocol by implementing the + * appropriate open and close semantics, deblocking for unaligned transfers, + * polling for ejectable media, locking and ejection policies, media object + * creation and tear-down, and statistics gathering and reporting. + * + * Block storage drivers are split into two parts: the generic driver handles + * all generic device issues, independent of the lower-level transport + * mechanism (e.g. SCSI, ATA, USB, FireWire). All storage operations + * at the generic driver level are translated into a series of generic + * device operations. These operations are passed via the IOBlockStorageDevice + * nub to a transport driver, which implements the appropriate + * transport-dependent protocol to execute these operations. + * + * To determine the write-protect state of a device (or media), for + * example, the generic driver would issue a call to the + * Transport Driver's reportWriteProtection method. If this were a SCSI + * device, its transport driver would issue a Mode Sense command to + * extract the write-protection status bit. The transport driver then + * reports true or false to the generic driver. + * + * The generic driver therefore has no knowledge of, or involvement + * with, the actual commands and mechanisms used to communicate with + * the device. It is expected that the generic driver will rarely, if + * ever, need to be subclassed to handle device idiosyncrasies; rather, + * the transport driver should be changed via overrides. + * + * A generic driver could be subclassed to create a different type of + * generic device. The generic driver IOCDBlockStorageDriver class is + * a subclass of IOBlockStorageDriver, adding CD functions. + */ + +class IOBlockStorageDriver : public IOStorage +{ + OSDeclareDefaultStructors(IOBlockStorageDriver); + +public: + + /*! + * @enum Statistics + * @abstract + * Indices for the different statistics that getStatistics() can report. + * @constant kStatisticsReads Number of read operations thus far. + * @constant kStatisticsBytesRead Number of bytes read thus far. + * @constant kStatisticsTotalReadTime Nanoseconds spent performing reads thus far. + * @constant kStatisticsLatentReadTime Nanoseconds of latency during reads thus far. + * @constant kStatisticsReadRetries Number of read retries thus far. + * @constant kStatisticsReadErrors Number of read errors thus far. + * @constant kStatisticsWrites Number of write operations thus far. + * @constant kStatisticsSingleBlockWrites Number of write operations for a single block thus far. + * @constant kStatisticsBytesWritten Number of bytes written thus far. + * @constant kStatisticsTotalWriteTime Nanoseconds spent performing writes thus far. + * @constant kStatisticsLatentWriteTime Nanoseconds of latency during writes thus far. + * @constant kStatisticsWriteRetries Number of write retries thus far. + * @constant kStatisticsWriteErrors Number of write errors thus far. + */ + + enum Statistics + { + kStatisticsReads, + kStatisticsBytesRead, + kStatisticsTotalReadTime, + kStatisticsLatentReadTime, + kStatisticsReadRetries, + kStatisticsReadErrors, + + kStatisticsWrites, + kStatisticsSingleBlockWrites, + kStatisticsBytesWritten, + kStatisticsTotalWriteTime, + kStatisticsLatentWriteTime, + kStatisticsWriteRetries, + kStatisticsWriteErrors + }; + + static const UInt32 kStatisticsCount = kStatisticsWriteErrors + 1; + +protected: + + struct Context; + + struct ExpansionData + { + bool mediaDirtied; + UInt64 maxReadBlockTransfer; + UInt64 maxWriteBlockTransfer; + IONotifier * powerEventNotifier; + UInt32 deblockRequestWriteLockCount; + UInt64 maxReadSegmentTransfer; + UInt64 maxWriteSegmentTransfer; + UInt64 maxReadSegmentByteTransfer; + UInt64 maxWriteSegmentByteTransfer; + UInt64 minSegmentAlignmentByteTransfer; + UInt64 maxSegmentWidthByteTransfer; + Context * contexts; + IOSimpleLock * contextsLock; + UInt32 contextsCount; + UInt32 contextsMaxCount; + }; + ExpansionData * _expansionData; + + #define _mediaDirtied \ + IOBlockStorageDriver::_expansionData->mediaDirtied + #define _maxReadBlockTransfer \ + IOBlockStorageDriver::_expansionData->maxReadBlockTransfer + #define _maxWriteBlockTransfer \ + IOBlockStorageDriver::_expansionData->maxWriteBlockTransfer + #define _powerEventNotifier \ + IOBlockStorageDriver::_expansionData->powerEventNotifier + #define _deblockRequestWriteLockCount \ + IOBlockStorageDriver::_expansionData->deblockRequestWriteLockCount + #define _maxReadSegmentTransfer \ + IOBlockStorageDriver::_expansionData->maxReadSegmentTransfer + #define _maxWriteSegmentTransfer \ + IOBlockStorageDriver::_expansionData->maxWriteSegmentTransfer + #define _maxReadSegmentByteTransfer \ + IOBlockStorageDriver::_expansionData->maxReadSegmentByteTransfer + #define _maxWriteSegmentByteTransfer \ + IOBlockStorageDriver::_expansionData->maxWriteSegmentByteTransfer + #define _minSegmentAlignmentByteTransfer \ + IOBlockStorageDriver::_expansionData->minSegmentAlignmentByteTransfer + #define _maxSegmentWidthByteTransfer \ + IOBlockStorageDriver::_expansionData->maxSegmentWidthByteTransfer + #define _contexts \ + IOBlockStorageDriver::_expansionData->contexts + #define _contextsLock \ + IOBlockStorageDriver::_expansionData->contextsLock + #define _contextsCount \ + IOBlockStorageDriver::_expansionData->contextsCount + #define _contextsMaxCount \ + IOBlockStorageDriver::_expansionData->contextsMaxCount + + OSSet * _openClients; + OSNumber * _statistics[kStatisticsCount]; + + /* + * @struct Context + * @discussion + * Context structure for a read/write operation. It describes the block size, + * and where applicable, a block type and block sub-type, for a data transfer, + * as well as the completion information for the original request. Note that + * the block type field is unused in the IOBlockStorageDriver class. + * @field block.size + * Block size for the operation. + * @field block.type + * Block type for the operation. Unused in IOBlockStorageDriver. The default + * value for this field is IOBlockStorageDriver::kBlockTypeStandard. + * @field block.typeSub + * Block sub-type for the operation. It's definition depends on block.type. + * Unused in IOBlockStorageDriver. + * @field request.byteStart + * Starting byte offset for the data transfer. + * @param request.buffer + * Buffer for the data transfer. The size of the buffer implies the size of + * the data transfer. + * @param request.attributes + * Attributes of the data transfer. See IOStorageAttributes. + * @param request.completion + * Completion routine to call once the data transfer is complete. + */ + + struct Context + { +#ifdef __LP64__ + struct + { + UInt64 byteStart; + IOMemoryDescriptor * buffer; + IOStorageAttributes attributes; + IOStorageCompletion completion; + } request; + + struct + { + UInt32 size; + UInt8 type; + UInt8 typeSub[3]; + } block; + + AbsoluteTime timeStart; + + UInt64 reserved0704; + UInt64 reserved0768; + UInt64 reserved0832; + UInt64 reserved0896; +#else /* !__LP64__ */ + struct + { + UInt32 size; + UInt8 type; + UInt8 typeSub[3]; + } block; + + struct + { + UInt64 byteStart; + IOMemoryDescriptor * buffer; + IOStorageCompletion completion; + } original; + + AbsoluteTime timeStart; + + struct + { + IOStorageAttributes attributes; + } request; + + UInt32 reserved0448; +#endif /* !__LP64__ */ + + Context * next; + }; + + static const UInt8 kBlockTypeStandard = 0x00; + + /* + * Free all of this object's outstanding resources. + * + * This method's implementation is not typically overridden. + */ + + void free(); + + /*! + * @function handleOpen + * @discussion + * The handleOpen method grants or denies permission to access this object + * to an interested client. The argument is an IOStorageAccess value that + * specifies the level of access desired -- reader or reader-writer. + * + * This method can be invoked to upgrade or downgrade the access level for + * an existing client as well. The previous access level will prevail for + * upgrades that fail, of course. A downgrade should never fail. If the + * new access level should be the same as the old for a given client, this + * method will do nothing and return success. In all cases, one, singular + * close-per-client is expected for all opens-per-client received. + * + * This implementation replaces the IOService definition of handleIsOpen(). + * @param client + * Client requesting the open. + * @param options + * Options for the open. Set to zero. + * @param access + * Access level for the open. Set to kIOStorageAccessReader or + * kIOStorageAccessReaderWriter. + * @result + * Returns true if the open was successful, false otherwise. + */ + + virtual bool handleOpen(IOService * client, + IOOptionBits options, + void * access); + + /*! + * @function handleIsOpen + * @discussion + * The handleIsOpen method determines whether the specified client, or any + * client if none is specified, presently has an open on this object. + * + * This implementation replaces the IOService definition of handleIsOpen(). + * @param client + * Client to check the open state of. Set to zero to check the open state + * of all clients. + * @result + * Returns true if the client was (or clients were) open, false otherwise. + */ + + virtual bool handleIsOpen(const IOService * client) const; + + /*! + * @function handleClose + * @discussion + * The handleClose method closes the client's access to this object. + * + * This implementation replaces the IOService definition of handleIsOpen(). + * @param client + * Client requesting the close. + * @param options + * Options for the close. Set to zero. + */ + + virtual void handleClose(IOService * client, IOOptionBits options); + + /*! + * @function addToBytesTransferred + * @discussion + * Update the total number of bytes transferred, the total transfer time, + * and the total latency time -- used for statistics. + * + * This method's implementation is not typically overridden. + * @param bytesTransferred + * Number of bytes transferred in this operation. + * @param totalTime + * Nanoseconds spent performing this operation. + * @param latentTime + * Nanoseconds of latency during this operation. + * @param isWrite + * Indicates whether this operation was a write, otherwise is was a read. + */ + + virtual void addToBytesTransferred(UInt64 bytesTransferred, + UInt64 totalTime, + UInt64 latentTime, + bool isWrite); + + /*! + * @function incrementErrors + * @discussion + * Update the total error count -- used for statistics. + * + * This method's implementation is not typically overridden. + * @param isWrite + * Indicates whether this operation was a write, otherwise is was a read. + */ + + virtual void incrementErrors(bool isWrite); + + /*! + * @function incrementRetries + * @discussion + * Update the total retry count -- used for statistics. + * + * This method's implementation is not typically overridden. + * @param isWrite + * Indicates whether this operation was a write, otherwise is was a read. + */ + + virtual void incrementRetries(bool isWrite); + + /*! + * @function allocateContext + * @discussion + * Allocate a context structure for a read/write operation. + * @result + * Context structure. + */ + + virtual Context * allocateContext(); + + /*! + * @function deleteContext + * @discussion + * Delete a context structure from a read/write operation. + * @param context + * Context structure to be deleted. + */ + + virtual void deleteContext(Context * context); + +#ifndef __LP64__ + virtual void prepareRequest(UInt64 byteStart, + IOMemoryDescriptor * buffer, + IOStorageCompletion completion) __attribute__ ((deprecated)); +#endif /* !__LP64__ */ + + /*! + * @function deblockRequest + * @discussion + * The deblockRequest method checks to see if the incoming request rests + * on the media's block boundaries, and if not, deblocks it. Deblocking + * involves rounding out the request to the nearest block boundaries and + * transferring the excess bytes into a scratch buffer. + * + * This method is part of a sequence of methods invoked for each read/write + * request. The first is prepareRequest, which allocates and prepares some + * context for the transfer; the second is deblockRequest, which aligns the + * transfer at the media's block boundaries; third is breakUpRequest, which + * breaks up the transfer into multiple sub-transfers when certain hardware + * constraints are exceeded; fourth is executeRequest, which implements the + * actual transfer from the block storage device. + * + * This method's implementation is not typically overridden. + * @param byteStart + * Starting byte offset for the data transfer. + * @param buffer + * Buffer for the data transfer. The size of the buffer implies the size of + * the data transfer. + * @param attributes + * Attributes of the data transfer. See IOStorageAttributes. It is the + * responsibility of the callee to maintain the information for the duration + * of the data transfer, as necessary. + * @param completion + * Completion routine to call once the data transfer is complete. It is the + * responsibility of the callee to maintain the information for the duration + * of the data transfer, as necessary. + * @param context + * Additional context information for the data transfer (e.g. block size). + */ + +#ifdef __LP64__ + virtual void deblockRequest(UInt64 byteStart, + IOMemoryDescriptor * buffer, + IOStorageAttributes * attributes, + IOStorageCompletion * completion, + Context * context); +#else /* !__LP64__ */ + virtual void deblockRequest(UInt64 byteStart, + IOMemoryDescriptor * buffer, + IOStorageCompletion completion, + Context * context); +#endif /* !__LP64__ */ + + /*! + * @function executeRequest + * @discussion + * Execute an asynchronous storage request. The request is guaranteed to be + * block-aligned. + * + * This method is part of a sequence of methods invoked for each read/write + * request. The first is prepareRequest, which allocates and prepares some + * context for the transfer; the second is deblockRequest, which aligns the + * transfer at the media's block boundaries; third is breakUpRequest, which + * breaks up the transfer into multiple sub-transfers when certain hardware + * constraints are exceeded; fourth is executeRequest, which implements the + * actual transfer from the block storage device. + * @param byteStart + * Starting byte offset for the data transfer. + * @param buffer + * Buffer for the data transfer. The size of the buffer implies the size of + * the data transfer. + * @param attributes + * Attributes of the data transfer. See IOStorageAttributes. It is the + * responsibility of the callee to maintain the information for the duration + * of the data transfer, as necessary. + * @param completion + * Completion routine to call once the data transfer is complete. It is the + * responsibility of the callee to maintain the information for the duration + * of the data transfer, as necessary. + * @param context + * Additional context information for the data transfer (e.g. block size). + */ + +#ifdef __LP64__ + virtual void executeRequest(UInt64 byteStart, + IOMemoryDescriptor * buffer, + IOStorageAttributes * attributes, + IOStorageCompletion * completion, + Context * context); +#else /* !__LP64__ */ + virtual void executeRequest(UInt64 byteStart, + IOMemoryDescriptor * buffer, + IOStorageCompletion completion, + Context * context); +#endif /* !__LP64__ */ + + /*! + * @function handleStart + * @discussion + * Prepare the block storage driver for operation. + * + * This is where a media object needs to be created for fixed media, and + * optionally for removable media. + * + * Note that this method is called from within the start() routine; + * if this method returns successfully, it should be prepared to accept + * any of IOBlockStorageDriver's APIs. + * @param provider + * This object's provider. + * @result + * Returns true on success, false otherwise. + */ + + virtual bool handleStart(IOService * provider); + + /*! + * @function handleYield + * @discussion + * Stop the block storage driver. + * + * This method is called as a result of a kIOMessageServiceIsRequestingClose + * provider message. The argument is passed in as-is from the message. The + * options are unused. + * + * This is where the driver should clean up its state in preparation for + * removal from the system. + * + * Note that this method is called from within the yield() routine. + * + * This method is called with the arbitration lock held. + * @param provider + * This object's provider. + */ + + virtual bool handleYield(IOService * provider, + IOOptionBits options = 0, + void * argument = 0); + + + /*! + * @function getMediaBlockSize + * @discussion + * Ask the driver about the media's natural block size. + * @result + * Natural block size, in bytes. + */ + + virtual UInt64 getMediaBlockSize() const; + +public: + + using IOStorage::read; + using IOStorage::write; + + /* + * Initialize this object's minimal state. + * + * This method's implementation is not typically overridden. + */ + + virtual bool init(OSDictionary * properties = 0); + + /* + * This method is called once we have been attached to the provider object. + * + * This method's implementation is not typically overridden. + */ + + virtual bool start(IOService * provider); + + /* + * This method is called before we are detached from the provider object. + * + * This method's implementation is not typically overridden. + */ + + virtual void stop(IOService * provider); + + /* + * This method is called as a result of a kIOMessageServiceIsRequestingClose + * provider message. The argument is passed in as-is from the message. The + * options are unused. + * + * This method's implementation is not typically overridden. + */ + + virtual bool yield(IOService * provider, + IOOptionBits options = 0, + void * argument = 0); + + /*! + * @function read + * @discussion + * The read method is the receiving end for all read requests from the + * storage framework (through the media object created by this driver). + * + * This method initiates a sequence of methods (stages) for each read/write + * request. The first is prepareRequest, which allocates and prepares some + * context for the transfer; the second is deblockRequest, which aligns the + * transfer at the media's block boundaries; third is breakUpRequest, which + * breaks up the transfer into multiple sub-transfers when certain hardware + * constraints are exceeded; fourth is executeRequest, which implements the + * actual transfer from the block storage device. + * + * This method's implementation is not typically overridden. + * @param client + * Client requesting the read. + * @param byteStart + * Starting byte offset for the data transfer. + * @param buffer + * Buffer for the data transfer. The size of the buffer implies the size of + * the data transfer. + * @param attributes + * Attributes of the data transfer. See IOStorageAttributes. It is the + * responsibility of the callee to maintain the information for the duration + * of the data transfer, as necessary. + * @param completion + * Completion routine to call once the data transfer is complete. It is the + * responsibility of the callee to maintain the information for the duration + * of the data transfer, as necessary. + */ + + virtual void read(IOService * client, + UInt64 byteStart, + IOMemoryDescriptor * buffer, + IOStorageAttributes * attributes, + IOStorageCompletion * completion); + + /*! + * @function write + * @discussion + * The write method is the receiving end for all write requests from the + * storage framework (through the media object created by this driver). + * + * This method initiates a sequence of methods (stages) for each read/write + * request. The first is prepareRequest, which allocates and prepares some + * context for the transfer; the second is deblockRequest, which aligns the + * transfer at the media's block boundaries; third is breakUpRequest, which + * breaks up the transfer into multiple sub-transfers when certain hardware + * constraints are exceeded; fourth is executeRequest, which implements the + * actual transfer from the block storage device. + * + * This method's implementation is not typically overridden. + * @param client + * Client requesting the write. + * @param byteStart + * Starting byte offset for the data transfer. + * @param buffer + * Buffer for the data transfer. The size of the buffer implies the size of + * the data transfer. + * @param attributes + * Attributes of the data transfer. See IOStorageAttributes. It is the + * responsibility of the callee to maintain the information for the duration + * of the data transfer, as necessary. + * @param completion + * Completion routine to call once the data transfer is complete. It is the + * responsibility of the callee to maintain the information for the duration + * of the data transfer, as necessary. + */ + + virtual void write(IOService * client, + UInt64 byteStart, + IOMemoryDescriptor * buffer, + IOStorageAttributes * attributes, + IOStorageCompletion * completion); + + /*! + * @function synchronizeCache + * @discussion + * Flush the cached data in the storage object, if any, synchronously. + * @param client + * Client requesting the cache synchronization. + * @result + * Returns the status of the cache synchronization. + */ + + virtual IOReturn synchronizeCache(IOService * client); + + /*! + * @function discard + * @discussion + * Delete unused data from the storage object at the specified byte offset, + * synchronously. + * @param client + * Client requesting the operation. + * @param byteStart + * Starting byte offset for the operation. + * @param byteCount + * Size of the operation. + * @result + * Returns the status of the operation. + */ + + virtual IOReturn discard(IOService * client, + UInt64 byteStart, + UInt64 byteCount); + + /*! + * @function ejectMedia + * @discussion + * Eject the media from the device. The driver is responsible for tearing + * down the media object it created before proceeding with the eject. If + * the tear-down fails, an error should be returned. + * @result + * An IOReturn code. + */ + + virtual IOReturn ejectMedia(); + + /*! + * @function formatMedia + * @discussion + * Format the media with the specified byte capacity. The driver is + * responsible for tearing down the media object and recreating it. + * @param byteCapacity + * Number of bytes to format media to. + * @result + * An IOReturn code. + */ + + virtual IOReturn formatMedia(UInt64 byteCapacity); + + /*! + * @function lockMedia + * @discussion + * Lock or unlock the ejectable media in the device, that is, prevent + * it from manual ejection or allow its manual ejection. + * @param lock + * Pass true to lock the media, otherwise pass false to unlock the media. + * @result + * An IOReturn code. + */ + + virtual IOReturn lockMedia(bool lock); + + /*! + * @function pollMedia + * @discussion + * Poll for the presence of media in the device. The driver is responsible + * for tearing down the media object it created should the media have been + * removed since the last poll, and vice-versa, creating the media object + * should new media have arrived since the last poll. + * @result + * An IOReturn code. + */ + + virtual IOReturn pollMedia(); + + /*! + * @function isMediaEjectable + * @discussion + * Ask the driver whether the media is ejectable. + * @result + * Returns true if the media is ejectable, false otherwise. + */ + + virtual bool isMediaEjectable() const; + +#ifdef __LP64__ + /*! + * @function isMediaRemovable + * @discussion + * Ask the driver whether the media is ejectable. + * @result + * Returns true if the media is ejectable, false otherwise. + */ + + virtual bool isMediaRemovable() const; +#endif /* __LP64__ */ + + /*! + * @function isMediaPollExpensive + * @discussion + * Ask the driver whether a pollMedia() would be an expensive operation, + * that is, one that requires the device to spin up or delay for a while. + * @result + * Returns true if polling the media is expensive, false otherwise. + */ + + virtual bool isMediaPollExpensive() const; + + /*! + * @function isMediaPollRequired + * @discussion + * Ask the driver whether the block storage device requires polling, which is + * typically required for devices without the ability to asynchronously detect + * the arrival or departure of the media. + * @result + * Returns true if polling the media is required, false otherwise. + */ + + virtual bool isMediaPollRequired() const; + + virtual bool isMediaWritable() const; + + /*! + * @function getMediaState + * @discussion + * Ask the driver about the media's current state. + * @result + * An IOMediaState value. + */ + + virtual IOMediaState getMediaState() const; + + /*! + * @function getFormatCapacities + * @discussion + * Ask the driver to report the feasible formatting capacities for the + * inserted media (in bytes). This routine fills the caller's buffer, + * up to the maximum count specified if the real number of capacities + * would overflow the buffer. The return value indicates the actual + * number of capacities copied to the buffer. + * + * If the capacities buffer is not supplied or if the maximum count is + * zero, the routine returns the proposed count of capacities instead. + * @param capacities + * Buffer that will receive the UInt64 capacity values. + * @param capacitiesMaxCount + * Maximum number of capacity values that can be held in the buffer. + * @result + * Actual number of capacity values copied to the buffer, or if no buffer + * is given, the total number of capacity values available. + */ + + virtual UInt32 getFormatCapacities(UInt64 * capacities, + UInt32 capacitiesMaxCount) const; + + /*! + * @function getStatistics + * @discussion + * Ask the driver to report its operating statistics. + * + * The statistics are each indexed by IOBlockStorageDriver::Statistics + * indices. This routine fills the caller's buffer, up to the maximum + * count specified if the real number of statistics would overflow the + * buffer. The return value indicates the actual number of statistics + * copied to the buffer. + * + * If the statistics buffer is not supplied or if the maximum count is + * zero, the routine returns the proposed count of statistics instead. + * @param statistics + * Buffer that will receive the UInt64 statistic values. + * @param statisticsMaxCount + * Maximum number of statistic values that can be held in the buffer. + * @result + * Actual number of statistic values copied to the buffer, or if no buffer + * is given, the total number of statistic values available. + */ + + virtual UInt32 getStatistics(UInt64 * statistics, + UInt32 statisticsMaxCount) const; + + /*! + * @function getStatistic + * @discussion + * Ask the driver to report one of its operating statistics. + * @param statistic + * Statistic index (an IOBlockStorageDriver::Statistics index). + * @result + * Statistic value. + */ + + virtual UInt64 getStatistic(Statistics statistic) const; + + /* + * Generic entry point for calls from the provider. A return value of + * kIOReturnSuccess indicates that the message was received, and where + * applicable, that it was successful. + */ + + virtual IOReturn message(UInt32 type, IOService * provider, void * argument); + + /* + * Obtain this object's provider. We override the superclass's method to + * return a more specific subclass of IOService -- IOBlockStorageDevice. + * This method serves simply as a convenience to subclass developers. + */ + + virtual IOBlockStorageDevice * getProvider() const; + +protected: + + IOLock * _deblockRequestWriteLock; + thread_call_t _pollerCall; + + /* + * This is the completion routine for the broken up breaker sub-requests. + * It verifies the success of the just-completed stage, transitions to + * the next stage, then builds and issues a transfer for the next stage. + */ + + static void breakUpRequestCompletion(void * target, + void * parameter, + IOReturn status, + UInt64 actualByteCount); + + /* + * This is the completion routine for the aligned deblocker sub-requests. + * It verifies the success of the just-completed stage, transitions to + * the next stage, then builds and issues a transfer for the next stage. + */ + + static void deblockRequestCompletion(void * target, + void * parameter, + IOReturn status, + UInt64 actualByteCount); + + /* + * This is the completion routine for the prepared request. It updates + * the driver's statistics, performs some clean up work, then calls the + * original request's completion routine. + */ + + static void prepareRequestCompletion(void * target, + void * parameter, + IOReturn status, + UInt64 actualByteCount); + + /* + * Schedule the poller mechanism. + */ + + virtual void schedulePoller(); + + /* + * Unschedule the poller mechanism. + */ + + virtual void unschedulePoller(); + + /* + * This method is the timeout handler for the poller mechanism. It polls + * for media and reschedules another timeout if there are still no opens. + */ + + static void poller(void *, void *); + + /* + * This method is the power event handler for restarts and shutdowns. + */ + + static IOReturn handlePowerEvent(void * target, + void * parameter, + UInt32 messageType, + IOService * provider, + void * messageArgument, + vm_size_t messageArgumentSize); + +protected: + + /* Device info: */ + + /*! + * @var _removable + * True if the media is removable; False if it is fixed (not removable). + */ + bool _removable; + + /*! + * @var _ejectable + * True if the media is ejectable under software control. + */ + bool _ejectable; /* software-ejectable */ + + /*! + * @var _lockable + * True if the media can be locked in the device under software control. + */ + bool _lockable; /* software lockable in device */ + /*! + * @var _pollIsRequired + * True if we must poll to detect media insertion or removal. + */ + bool _pollIsRequired; + /*! + * @var _pollIsExpensive + * True if polling is expensive; False if not. + */ + bool _pollIsExpensive; + + /* Media info and states: */ + + /*! + * @var _mediaObject + * A pointer to the media object we have instantiated (if any). + */ + IOMedia * _mediaObject; + /*! + * @var _mediaType + * Type of the media (can be used to differentiate between the + * different types of CD media, DVD media, etc). + */ + UInt32 _mediaType; + /*! + * @var _mediaPresent + * True if media is present in the device; False if not. + */ + bool _mediaPresent; /* media is present and ready */ + /*! + * @var _writeProtected + * True if the media is write-protected; False if not. + */ + bool _writeProtected; + +private: + + /*! + * @var _mediaStateLock + * A lock used to protect during media checks. + */ + IOLock * _mediaStateLock; + +protected: + + /*! + * @var _mediaBlockSize + * The block size of the media, in bytes. + */ + UInt64 _mediaBlockSize; + /*! + * @var _maxBlockNumber + * The maximum allowable block number for the media, zero-based. + */ + UInt64 _maxBlockNumber; + + /*! + * @var _maxReadByteTransfer + * The maximum byte transfer allowed for read operations. + */ + UInt64 _maxReadByteTransfer; + + /*! + * @var _maxWriteByteTransfer + * The maximum byte transfer allowed for write operations. + */ + UInt64 _maxWriteByteTransfer; + + /*! + * @function acceptNewMedia + * @abstract + * React to new media insertion. + * @discussion + * This method logs the media block size and block count, then calls + * instantiateMediaObject to get a media object instantiated. The + * media object is then attached above us and registered. + * + * This method can be overridden to control what happens when new media + * is inserted. The default implementation deals with one IOMedia object. + */ + virtual IOReturn acceptNewMedia(void); + + /*! + * @function constrainByteCount + * @abstract + * Constrain the byte count for this IO to device limits. + * @discussion + * This function should be called prior to each read or write operation, so that + * the driver can constrain the requested byte count, as necessary, to meet + * current device limits. Such limits could be imposed by the device depending + * on operating modes, media types, or transport protocol (e.g. ATA, SCSI). + * + * At present, this method is not used. + * @param requestedCount + * The requested byte count for the next read or write operation. + * @param isWrite + * True if the operation will be a write; False if the operation will be a read. + */ + virtual UInt64 constrainByteCount(UInt64 requestedCount,bool isWrite); + + /*! + * @function decommissionMedia + * @abstract + * Decommission an existing piece of media that has gone away. + * @discussion + * This method wraps a call to terminate, to tear down the stack and + * the IOMedia object for the media. If "forcible" is true, the media + * object will be forgotten, and initMediaState will be called. A + * forcible decommission would occur when an unrecoverable error + * happens during tear-down (e.g. perhaps a client is still open), but + * we must still forget about the media. + * @param forcible + * True to force forgetting of the media object even if terminate reports + * that there was an active client. + */ + virtual IOReturn decommissionMedia(bool forcible); + + /*! + * @function instantiateDesiredMediaObject + * @abstract + * Create an IOMedia object for media. + * @discussion + * This method creates the exact type of IOMedia object desired. It is called by + * instantiateMediaObject. A subclass may override this one-line method to change + * the type of media object actually instantiated. + */ + virtual IOMedia * instantiateDesiredMediaObject(void); + + /*! + * @function instantiateMediaObject + * @abstract + * Create an IOMedia object for media. + * @discussion + * This method creates an IOMedia object from the supplied parameters. It is a + * convenience method to wrap the handful of steps to do the job. + * @param base + * Byte number of beginning of active data area of the media. Usually zero. + * @param byteSize + * Size of the data area of the media, in bytes. + * @param blockSize + * Block size of the media, in bytes. + * @param mediaName + * Name of the IOMedia object. + * @result + * A pointer to the created IOMedia object, or a null on error. + */ + virtual IOMedia * instantiateMediaObject(UInt64 base,UInt64 byteSize, + UInt32 blockSize,char *mediaName); + + /*! + * @function recordMediaParameters + * @abstract + * Obtain media-related parameters on media insertion. + * @discussion + * This method obtains media-related parameters via calls to the + * Transport Driver's reportBlockSize, reportMaxValidBlock, + * and reportWriteProtection methods. + */ + virtual IOReturn recordMediaParameters(void); + + /*! + * @function rejectMedia + * @abstract + * Reject new media. + * @discussion + * This method will be called if validateNewMedia returns False (thus rejecting + * the new media. A vendor may choose to override this method to control behavior + * when media is rejected. + * + * The default implementation simply calls ejectMedia. + */ + virtual void rejectMedia(void); /* default ejects */ + + /*! + * @function validateNewMedia + * @abstract + * Verify that new media is acceptable. + * @discussion + * This method will be called whenever new media is detected. Return true to accept + * the media, or false to reject it (and call rejectMedia). Vendors might override + * this method to handle password-protection for new media. + * + * The default implementation always returns True, indicating media is accepted. + */ + virtual bool validateNewMedia(void); + + /* --- Internally used methods. --- */ + + /* + * @group + * Internally Used Methods + * @discussion + * These methods are used internally, and will not generally be modified. + */ + + /*! + * @function checkForMedia + * @abstract + * Check if media has newly arrived or disappeared. + * @discussion + * This method does most of the work in polling for media, first + * calling the block storage device's reportMediaState method. If + * reportMediaState reports no change in the media state, kIOReturnSuccess + * is returned. If the media state has indeed changed, a call is made to + * mediaStateHasChanged to act on the event. + */ + virtual IOReturn checkForMedia(void); + + /*! + * @function getDeviceTypeName + * @abstract + * Return the desired device name. + * @discussion + * This method returns a string, used to compare the + * kIOBlockStorageDeviceTypeKey of our provider. This method is called from + * probe. + * + * The default implementation of this method returns + * kIOBlockStorageDeviceTypeGeneric. + */ + virtual const char * getDeviceTypeName(void); + + /*! + * @function initMediaState + * @abstract + * Initialize media-related instance variables. + * @discussion + * Called when media is not present, this method marks the device state + * as not having media present, not spun up, and write-enabled. + */ + virtual void initMediaState(void); + + /*! + * @function mediaStateHasChanged + * @abstract + * React to a new media insertion or a media removal. + * @discussion + * This method is called on a media state change, that is, an arrival + * or removal. If media has just become available, calls are made to + * recordMediaParameters and acceptNewMedia. If media has just gone + * away, a call is made to decommissionMedia, with the forcible + * parameter set to true. The forcible tear-down is needed to enforce + * the disappearance of media, regardless of interested clients. + */ + virtual IOReturn mediaStateHasChanged(IOMediaState state); + + /* + * @endgroup + */ + +protected: + + /*! + * @function breakUpRequest + * @discussion + * The breakUpRequest method checks to see if the incoming request exceeds + * our transfer constraints, and if so, breaks up the request into smaller + * sub-requests. + * + * This method is part of a sequence of methods invoked for each read/write + * request. The first is prepareRequest, which allocates and prepares some + * context for the transfer; the second is deblockRequest, which aligns the + * transfer at the media's block boundaries; third is breakUpRequest, which + * breaks up the transfer into multiple sub-transfers when certain hardware + * constraints are exceeded; fourth is executeRequest, which implements the + * actual transfer from the block storage device. + * + * This method's implementation is not typically overridden. + * @param byteStart + * Starting byte offset for the data transfer. + * @param buffer + * Buffer for the data transfer. The size of the buffer implies the size of + * the data transfer. + * @param attributes + * Attributes of the data transfer. See IOStorageAttributes. It is the + * responsibility of the callee to maintain the information for the duration + * of the data transfer, as necessary. + * @param completion + * Completion routine to call once the data transfer is complete. It is the + * responsibility of the callee to maintain the information for the duration + * of the data transfer, as necessary. + * @param context + * Additional context information for the data transfer (e.g. block size). + */ + +#ifdef __LP64__ + virtual void breakUpRequest(UInt64 byteStart, + IOMemoryDescriptor * buffer, + IOStorageAttributes * attributes, + IOStorageCompletion * completion, + Context * context); +#else /* !__LP64__ */ + virtual void breakUpRequest(UInt64 byteStart, + IOMemoryDescriptor * buffer, + IOStorageCompletion completion, + Context * context); /* 10.1.2 */ +#endif /* !__LP64__ */ + + /*! + * @function prepareRequest + * @discussion + * The prepareRequest method allocates and prepares state for the transfer. + * + * This method is part of a sequence of methods invoked for each read/write + * request. The first is prepareRequest, which allocates and prepares some + * context for the transfer; the second is deblockRequest, which aligns the + * transfer at the media's block boundaries; third is breakUpRequest, which + * breaks up the transfer into multiple sub-transfers when certain hardware + * constraints are exceeded; fourth is executeRequest, which implements the + * actual transfer from the block storage device. + * + * This method's implementation is not typically overridden. + * @param byteStart + * Starting byte offset for the data transfer. + * @param buffer + * Buffer for the data transfer. The size of the buffer implies the size of + * the data transfer. + * @param attributes + * Attributes of the data transfer. See IOStorageAttributes. It is the + * responsibility of the callee to maintain the information for the duration + * of the data transfer, as necessary. + * @param completion + * Completion routine to call once the data transfer is complete. It is the + * responsibility of the callee to maintain the information for the duration + * of the data transfer, as necessary. + */ + + virtual void prepareRequest(UInt64 byteStart, + IOMemoryDescriptor * buffer, + IOStorageAttributes * attributes, + IOStorageCompletion * completion); /* 10.5.0 */ + +public: + + /*! + * @function requestIdle + * @abstract + * Request that the device enter an idle state. + * @discussion + * Request that the device enter an idle state. The device will exit this state on the + * next read or write request, or as it sees necessary. One example is for a DVD drive + * to spin down when it enters such an idle state, and spin up on the next read request + * from the system. + */ + virtual IOReturn requestIdle(void); /* 10.6.0 */ + +#ifdef __LP64__ + OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 0); + OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 1); + OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 2); +#else /* !__LP64__ */ + OSMetaClassDeclareReservedUsed(IOBlockStorageDriver, 0); + OSMetaClassDeclareReservedUsed(IOBlockStorageDriver, 1); + OSMetaClassDeclareReservedUsed(IOBlockStorageDriver, 2); +#endif /* !__LP64__ */ + OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 3); + OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 4); + OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 5); + OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 6); + OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 7); + OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 8); + OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 9); + OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 10); + OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 11); + OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 12); + OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 13); + OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 14); + OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 15); + OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 16); + OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 17); + OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 18); + OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 19); + OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 20); + OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 21); + OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 22); + OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 23); + OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 24); + OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 25); + OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 26); + OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 27); + OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 28); + OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 29); + OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 30); + OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 31); +}; + +#endif /* __cplusplus */ +#endif /* KERNEL */ +#endif /* !_IOBLOCKSTORAGEDRIVER_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/storage/IODVDBlockStorageDevice.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/storage/IODVDBlockStorageDevice.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/storage/IODVDBlockStorageDevice.h (revision 885) @@ -0,0 +1,145 @@ +/* + * 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 IODVDBlockStorageDevice + * @abstract + * This header contains the IODVDBlockStorageDevice class definition. + */ + +#ifndef _IODVDBLOCKSTORAGEDEVICE_H +#define _IODVDBLOCKSTORAGEDEVICE_H + +#include + +/*! + * @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 + +/* 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) = 0; + + virtual IOReturn sendKey(IOMemoryDescriptor *buffer,const DVDKeyClass keyClass, + const UInt8 agid,const DVDKeyFormat keyFormat) = 0; + +#ifdef __LP64__ + virtual IOReturn readDVDStructure(IOMemoryDescriptor *buffer,const DVDStructureFormat format, + const UInt32 address,const UInt8 layer,const UInt8 agid) = 0; +#else /* !__LP64__ */ + virtual IOReturn readDVDStructure(IOMemoryDescriptor *buffer,const DVDStructureFormat format, + const UInt32 address,const UInt8 layer,const UInt8 agid); /* 10.1.0 */ +#endif /* !__LP64__ */ + +#ifdef __LP64__ + OSMetaClassDeclareReservedUnused(IODVDBlockStorageDevice, 0); +#else /* !__LP64__ */ + OSMetaClassDeclareReservedUsed(IODVDBlockStorageDevice, 0); +#endif /* !__LP64__ */ + 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 */ Index: branches/azimutz/Cleancut/i386/include/IOKit/storage/IOFireWireStorageCharacteristics.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/storage/IOFireWireStorageCharacteristics.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/storage/IOFireWireStorageCharacteristics.h (revision 885) @@ -0,0 +1,63 @@ +/* + * 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: +
+@textblock
+
+	Bridge Characteristics
+	
+		Bridge Vendor Name
+		Oxford Semiconductor
+		Bridge Model Name
+		FW911
+		Bridge Revision Level
+		3.7
+	
+
+@/textblock
+
+*/ + +#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_ */ \ No newline at end of file Index: branches/azimutz/Cleancut/i386/include/IOKit/storage/IOPartitionScheme.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/storage/IOPartitionScheme.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/storage/IOPartitionScheme.h (revision 885) @@ -0,0 +1,373 @@ +/* + * 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 IOPartitionScheme + * @abstract + * This header contains the IOPartitionScheme class definition. + */ + +#ifndef _IOPARTITIONSCHEME_H +#define _IOPARTITIONSCHEME_H + +/*! + * @defined kIOPartitionSchemeClass + * @abstract + * The name of the IOPartitionScheme class. + * @discussion + * kIOPartitionSchemeClass is the name of the IOPartitionScheme class. + */ + +#define kIOPartitionSchemeClass "IOPartitionScheme" + +/*! + * @defined kIOMediaLiveKey + * @abstract + * A property of IOMedia objects. + * @discussion + * The kIOMediaLiveKey property has an OSBoolean + * value and is placed into an IOMedia instance + * created via the partition scheme. It describes whether the + * partition is live, that is, it is up-to-date with respect + * to the on-disk partition table. + */ + +#define kIOMediaLiveKey "Live" + +/*! + * @defined kIOMediaPartitionIDKey + * @abstract + * A property of IOMedia objects. + * @discussion + * The kIOMediaPartitionIDKey property has an OSNumber + * value and is placed into an IOMedia instance + * created via the partition scheme. It is an ID that differentiates one + * partition from the other (within a given scheme). It is typically an index + * into the on-disk partition table. + */ + +#define kIOMediaPartitionIDKey "Partition ID" + +#ifdef KERNEL +#ifdef __cplusplus + +/* + * Kernel + */ + +#include +#include + +/*! + * @class IOPartitionScheme + * @abstract + * The common base class for all partition scheme + * objects. + * @discussion + * The IOPartitionScheme class is the common base class for all partition scheme + * objects. It extends the IOStorage class by implementing the appropriate open + * and close semantics for partition objects (standard semantics are to act as a + * multiplexor for incoming opens, producing one outgoing open with the correct + * access). It also implements the default read and write semantics, which pass + * all reads and writes through to the provider media unprocessed. For simple + * schemes, the default behavior is sufficient. More complex partition schemes + * such as RAID will want to do extra processing for reads and writes. + */ + +class IOPartitionScheme : public IOStorage +{ + OSDeclareDefaultStructors(IOPartitionScheme); + +protected: + + struct ExpansionData { /* */ }; + ExpansionData * _expansionData; + + IOStorageAccess _openLevel; + OSSet * _openReaders; + OSSet * _openReaderWriters; + + /* + * Free all of this object's outstanding resources. + */ + + virtual void free(); + + /*! + * @function handleOpen + * @discussion + * The handleOpen method grants or denies permission to access this object + * to an interested client. The argument is an IOStorageAccess value that + * specifies the level of access desired -- reader or reader-writer. + * + * This method can be invoked to upgrade or downgrade the access level for + * an existing client as well. The previous access level will prevail for + * upgrades that fail, of course. A downgrade should never fail. If the + * new access level should be the same as the old for a given client, this + * method will do nothing and return success. In all cases, one, singular + * close-per-client is expected for all opens-per-client received. + * + * This implementation replaces the IOService definition of handleOpen(). + * @param client + * Client requesting the open. + * @param options + * Options for the open. Set to zero. + * @param access + * Access level for the open. Set to kIOStorageAccessReader or + * kIOStorageAccessReaderWriter. + * @result + * Returns true if the open was successful, false otherwise. + */ + + virtual bool handleOpen(IOService * client, + IOOptionBits options, + void * access); + + /*! + * @function handleIsOpen + * @discussion + * The handleIsOpen method determines whether the specified client, or any + * client if none is specified, presently has an open on this object. + * + * This implementation replaces the IOService definition of handleIsOpen(). + * @param client + * Client to check the open state of. Set to zero to check the open state + * of all clients. + * @result + * Returns true if the client was (or clients were) open, false otherwise. + */ + + virtual bool handleIsOpen(const IOService * client) const; + + /*! + * @function handleClose + * @discussion + * The handleClose method closes the client's access to this object. + * + * This implementation replaces the IOService definition of handleClose(). + * @param client + * Client requesting the close. + * @param options + * Options for the close. Set to zero. + */ + + virtual void handleClose(IOService * client, IOOptionBits options); + + /* + * Attach the given media object to the device tree plane. + */ + +#ifdef __LP64__ + virtual bool attachMediaObjectToDeviceTree(IOMedia * media); +#else /* !__LP64__ */ + virtual bool attachMediaObjectToDeviceTree(IOMedia * media, + IOOptionBits options = 0); /* 10.5.0 */ +#endif /* !__LP64__ */ + + /* + * Detach the given media object from the device tree plane. + */ + +#ifdef __LP64__ + virtual void detachMediaObjectFromDeviceTree(IOMedia * media); +#else /* !__LP64__ */ + virtual void detachMediaObjectFromDeviceTree(IOMedia * media, + IOOptionBits options = 0); /* 10.5.0 */ +#endif /* !__LP64__ */ + + /* + * Updates a set of existing partitions, represented by partitionsOld, + * with possible updates from a rescan of the disk, represented by + * partitionsNew. It returns a new set of partitions with the results, + * removing partitions from partitionsOld where applicable, adding + * partitions from partitionsNew where applicable, and folding in property + * changes to partitions from partitionsNew into partitionsOld where + * applicable. + */ + + virtual OSSet * juxtaposeMediaObjects(OSSet * partitionsOld, + OSSet * partitionsNew); /* 10.5.0 */ + +public: + + using IOStorage::read; + using IOStorage::write; + + /* + * Initialize this object's minimal state. + */ + + virtual bool init(OSDictionary * properties = 0); + + /*! + * @function read + * @discussion + * Read data from the storage object at the specified byte offset into the + * specified buffer, asynchronously. When the read completes, the caller + * will be notified via the specified completion action. + * + * The buffer will be retained for the duration of the read. + * + * For simple partition schemes, the default behavior is to simply pass the + * read through to the provider media. More complex partition schemes such + * as RAID will need to do extra processing here. + * @param client + * Client requesting the read. + * @param byteStart + * Starting byte offset for the data transfer. + * @param buffer + * Buffer for the data transfer. The size of the buffer implies the size of + * the data transfer. + * @param attributes + * Attributes of the data transfer. See IOStorageAttributes. It is the + * responsibility of the callee to maintain the information for the duration + * of the data transfer, as necessary. + * @param completion + * Completion routine to call once the data transfer is complete. It is the + * responsibility of the callee to maintain the information for the duration + * of the data transfer, as necessary. + */ + + virtual void read(IOService * client, + UInt64 byteStart, + IOMemoryDescriptor * buffer, + IOStorageAttributes * attributes, + IOStorageCompletion * completion); + + /*! + * @function write + * @discussion + * Write data into the storage object at the specified byte offset from the + * specified buffer, asynchronously. When the write completes, the caller + * will be notified via the specified completion action. + * + * The buffer will be retained for the duration of the write. + * + * For simple partition schemes, the default behavior is to simply pass the + * write through to the provider media. More complex partition schemes such + * as RAID will need to do extra processing here. + * @param client + * Client requesting the write. + * @param byteStart + * Starting byte offset for the data transfer. + * @param buffer + * Buffer for the data transfer. The size of the buffer implies the size of + * the data transfer. + * @param attributes + * Attributes of the data transfer. See IOStorageAttributes. It is the + * responsibility of the callee to maintain the information for the duration + * of the data transfer, as necessary. + * @param completion + * Completion routine to call once the data transfer is complete. It is the + * responsibility of the callee to maintain the information for the duration + * of the data transfer, as necessary. + */ + + virtual void write(IOService * client, + UInt64 byteStart, + IOMemoryDescriptor * buffer, + IOStorageAttributes * attributes, + IOStorageCompletion * completion); + + /*! + * @function synchronizeCache + * @discussion + * Flush the cached data in the storage object, if any, synchronously. + * @param client + * Client requesting the cache synchronization. + * @result + * Returns the status of the cache synchronization. + */ + + virtual IOReturn synchronizeCache(IOService * client); + + /*! + * @function discard + * @discussion + * Delete unused data from the storage object at the specified byte offset, + * synchronously. + * @param client + * Client requesting the operation. + * @param byteStart + * Starting byte offset for the operation. + * @param byteCount + * Size of the operation. + * @result + * Returns the status of the operation. + */ + + virtual IOReturn discard(IOService * client, + UInt64 byteStart, + UInt64 byteCount); + + /* + * Obtain this object's provider. We override the superclass's method + * to return a more specific subclass of OSObject -- an IOMedia. This + * method serves simply as a convenience to subclass developers. + */ + + virtual IOMedia * getProvider() const; + +#ifdef __LP64__ + OSMetaClassDeclareReservedUnused(IOPartitionScheme, 0); + OSMetaClassDeclareReservedUnused(IOPartitionScheme, 1); + OSMetaClassDeclareReservedUnused(IOPartitionScheme, 2); +#else /* !__LP64__ */ + OSMetaClassDeclareReservedUsed(IOPartitionScheme, 0); + OSMetaClassDeclareReservedUsed(IOPartitionScheme, 1); + OSMetaClassDeclareReservedUsed(IOPartitionScheme, 2); +#endif /* !__LP64__ */ + OSMetaClassDeclareReservedUnused(IOPartitionScheme, 3); + OSMetaClassDeclareReservedUnused(IOPartitionScheme, 4); + OSMetaClassDeclareReservedUnused(IOPartitionScheme, 5); + OSMetaClassDeclareReservedUnused(IOPartitionScheme, 6); + OSMetaClassDeclareReservedUnused(IOPartitionScheme, 7); + OSMetaClassDeclareReservedUnused(IOPartitionScheme, 8); + OSMetaClassDeclareReservedUnused(IOPartitionScheme, 9); + OSMetaClassDeclareReservedUnused(IOPartitionScheme, 10); + OSMetaClassDeclareReservedUnused(IOPartitionScheme, 11); + OSMetaClassDeclareReservedUnused(IOPartitionScheme, 12); + OSMetaClassDeclareReservedUnused(IOPartitionScheme, 13); + OSMetaClassDeclareReservedUnused(IOPartitionScheme, 14); + OSMetaClassDeclareReservedUnused(IOPartitionScheme, 15); + OSMetaClassDeclareReservedUnused(IOPartitionScheme, 16); + OSMetaClassDeclareReservedUnused(IOPartitionScheme, 17); + OSMetaClassDeclareReservedUnused(IOPartitionScheme, 18); + OSMetaClassDeclareReservedUnused(IOPartitionScheme, 19); + OSMetaClassDeclareReservedUnused(IOPartitionScheme, 20); + OSMetaClassDeclareReservedUnused(IOPartitionScheme, 21); + OSMetaClassDeclareReservedUnused(IOPartitionScheme, 22); + OSMetaClassDeclareReservedUnused(IOPartitionScheme, 23); + OSMetaClassDeclareReservedUnused(IOPartitionScheme, 24); + OSMetaClassDeclareReservedUnused(IOPartitionScheme, 25); + OSMetaClassDeclareReservedUnused(IOPartitionScheme, 26); + OSMetaClassDeclareReservedUnused(IOPartitionScheme, 27); + OSMetaClassDeclareReservedUnused(IOPartitionScheme, 28); + OSMetaClassDeclareReservedUnused(IOPartitionScheme, 29); + OSMetaClassDeclareReservedUnused(IOPartitionScheme, 30); + OSMetaClassDeclareReservedUnused(IOPartitionScheme, 31); +}; + +#endif /* __cplusplus */ +#endif /* KERNEL */ +#endif /* !_IOPARTITIONSCHEME_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/storage/IOBlockStorageDevice.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/storage/IOBlockStorageDevice.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/storage/IOBlockStorageDevice.h (revision 885) @@ -0,0 +1,504 @@ +/* + * 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 IOBlockStorageDevice + * @abstract + * This header contains the IOBlockStorageDevice class definition. + */ + +#ifndef _IOBLOCKSTORAGEDEVICE_H +#define _IOBLOCKSTORAGEDEVICE_H + +#include +#include + +/*! + * @defined kIOBlockStorageDeviceClass + * @abstract + * The name of the IOBlockStorageDevice class. + */ + +#define kIOBlockStorageDeviceClass "IOBlockStorageDevice" + +/*! + * @defined kIOBlockStorageDeviceWriteCacheStateKey + * @abstract + * The name of the property used to get or set the write cache state of the + * block storage device. + */ +#define kIOBlockStorageDeviceWriteCacheStateKey "WriteCacheState" + +#ifdef KERNEL +#ifdef __cplusplus + +/* + * Kernel + */ + +#include +#include +#include +#include + +/*! + * @defined kIOMessageMediaParametersHaveChanged + * @abstract + * The message ID which indicates that the media parameters, such as the highest valid block + * for the device, have changed. + * @discussion + * The message is passed to all clients of the IOBlockStorageDevice via the message() method. + */ +#define kIOMessageMediaParametersHaveChanged iokit_family_msg(sub_iokit_block_storage, 2) + +/*! + * @defined kIOMessageMediaStateHasChanged + * @abstract + * The message ID which indicates that the media state has changed. + * @discussion + * The message is passed to all clients of the IOBlockStorageDevice via the message() method. + * The argument that is passed along with this message is an IOMediaState value. + * + * Devices that aren't capable of detecting media state changes indicate this in + * the reportPollRequirements() method. + */ +#define kIOMessageMediaStateHasChanged iokit_family_msg(sub_iokit_block_storage, 1) + +/* Property used for matching, so the generic driver gets the nub it wants. */ +/*! + * @defined kIOBlockStorageDeviceTypeKey + * @abstract The name of the property tested for nub type matching by the generic block + * storage driver. + */ +#define kIOBlockStorageDeviceTypeKey "device-type" +/*! + * @defined kIOBlockStorageDeviceTypeGeneric + * @abstract A character string used for nub matching. + */ +#define kIOBlockStorageDeviceTypeGeneric "Generic" + +/*! + * @class + * IOBlockStorageDevice + * @abstract + * A generic block storage device abstraction. + * @discussion + * The IOBlockStorageDevice class exports the generic block storage protocol, + * independent of the physical connection protocol (e.g. SCSI, ATA, USB), + * forwarding all requests to its provider (the Transport Driver). + * Though the nub does no actual processing of requests, it is necessary + * in a C++ environment. The Transport Driver can be of any type, as + * long as it inherits from IOService. Because Transport Drivers needn't + * derive from a type known to IOBlockStorageDriver, it isn't possible for + * IOBlockStorageDriver to include the appropriate header file to allow direct + * communication with the Transport Driver. Thus we achieve polymorphism by + * having the Transport Driver instantiate a subclass of IOBlockStorageDevice. + * A typical implementation for a concrete subclass of IOBlockStorageDevice + * simply relays all methods to its provider (the Transport Driver), which + * implements the protocol- and device-specific behavior. + * + * All pure-virtual functions must be implemented by the Transport Driver, which + * is responsible for instantiating the Nub. + */ + +class IOBlockStorageDevice : public IOService { + + OSDeclareAbstractStructors(IOBlockStorageDevice) + +protected: + + struct ExpansionData { /* */ }; + ExpansionData * _expansionData; + +public: + + /* Overrides from IORegistryEntry */ + + using IORegistryEntry::getProperty; + + /*! + * @function init + * @discussion + * This function is overridden so that IOBlockStorageDevice can set a + * property, used by IOBlockStorageDriver for matching. Since the concrete + * subclass of IOBlockStorageDevice can be of any class type, the property + * is used for matching. + * + * This function is usually not overridden by developers. + */ + virtual bool init(OSDictionary * properties); + + virtual OSObject * getProperty(const OSSymbol * key) const; + + virtual IOReturn setProperties(OSObject * properties); + + /* --- A subclass must implement the the following methods: --- */ + +#ifndef __LP64__ + virtual IOReturn doAsyncReadWrite(IOMemoryDescriptor *buffer, + UInt32 block, UInt32 nblks, + IOStorageCompletion completion) __attribute__ ((deprecated)); + + virtual IOReturn doSyncReadWrite(IOMemoryDescriptor *buffer, + UInt32 block,UInt32 nblks) __attribute__ ((deprecated)); +#endif /* !__LP64__ */ + + /*! + * @function doEjectMedia + * @abstract + * Eject the media. + */ + virtual IOReturn doEjectMedia(void) = 0; + + /*! + * @function doFormatMedia + * @abstract + * Format the media to the specified byte capacity. + * @discussion + * The specified byte capacity must be one supported by the device. + * Supported capacities can be obtained by calling doGetFormatCapacities. + * @param byteCapacity + * The byte capacity to which the device is to be formatted, if possible. + */ + virtual IOReturn doFormatMedia(UInt64 byteCapacity) = 0; + + /*! + * @function doGetFormatCapacities + * @abstract + * Return the allowable formatting byte capacities. + * @discussion + * This function returns the supported byte capacities for the device. + * @param capacities + * Pointer for returning the list of capacities. + * @param capacitiesMaxCount + * The number of capacity values returned in "capacities," or if no buffer + * is given, the total number of capacity values available. + */ + virtual UInt32 doGetFormatCapacities(UInt64 * capacities, + UInt32 capacitiesMaxCount) const = 0; + + /*! + * @function doLockUnlockMedia + * @abstract + * Lock or unlock the (removable) media in the drive. + * @discussion + * This method should only be called if the media is known to be removable. + * @param doLock + * True to lock the media, False to unlock. + */ + virtual IOReturn doLockUnlockMedia(bool doLock) = 0; + + /*! + * @function doSynchronizeCache + * @abstract + * Force data blocks in the hardware's buffer to be flushed to the media. + * @discussion + * This method should only be called if the media is writable. + */ + virtual IOReturn doSynchronizeCache(void) = 0; + + /*! + * @function getVendorString + * @abstract + * Return Vendor Name string for the device. + * @result + * A pointer to a static character string. + */ + virtual char * getVendorString(void) = 0; + + /*! + * @function getProductString + * @abstract + * Return Product Name string for the device. + * @result + * A pointer to a static character string. + */ + virtual char * getProductString(void) = 0; + + /*! + * @function getRevisionString + * @abstract + * Return Product Revision string for the device. + * @result + * A pointer to a static character string. + */ + virtual char * getRevisionString(void) = 0; + + /*! + * @function getAdditionalDeviceInfoString + * @abstract + * Return additional informational string for the device. + * @result + * A pointer to a static character string. + */ + virtual char * getAdditionalDeviceInfoString(void) = 0; + + /*! + * @function reportBlockSize + * @abstract + * Report the block size for the device, in bytes. + * @param blockSize + * Pointer to returned block size value. + */ + virtual IOReturn reportBlockSize(UInt64 *blockSize) = 0; + + /*! + * @function reportEjectability + * @abstract + * Report if the media is ejectable under software control. + * @discussion + * This method should only be called if the media is known to be removable. + * @param isEjectable + * Pointer to returned result. True indicates the media is ejectable, False indicates + * the media cannot be ejected under software control. + */ + virtual IOReturn reportEjectability(bool *isEjectable) = 0; + + /*! + * @function reportLockability + * @abstract + * Report if the media is lockable under software control. + * @discussion + * This method should only be called if the media is known to be removable. + * @param isLockable + * Pointer to returned result. True indicates the media can be locked in place; False + * indicates the media cannot be locked by software. + */ + virtual IOReturn reportLockability(bool *isLockable) = 0; + +#ifndef __LP64__ + virtual IOReturn reportMaxReadTransfer(UInt64 blockSize,UInt64 *max) __attribute__ ((deprecated)); + + virtual IOReturn reportMaxWriteTransfer(UInt64 blockSize,UInt64 *max) __attribute__ ((deprecated)); +#endif /* !__LP64__ */ + + /*! + * @function reportMaxValidBlock + * @abstract + * Report the highest valid block for the device. + * @param maxBlock + * Pointer to returned result + */ + virtual IOReturn reportMaxValidBlock(UInt64 *maxBlock) = 0; + + /*! + * @function reportMediaState + * @abstract + * Report the device's media state. + * @discussion + * This method reports whether we have media in the drive or not, and + * whether the state has changed from the previously reported state. + * + * A result of kIOReturnSuccess is always returned if the test for media is successful, + * regardless of media presence. The mediaPresent result should be used to determine + * whether media is present or not. A return other than kIOReturnSuccess indicates that + * the Transport Driver was unable to interrogate the device. In this error case, the + * outputs mediaState and changedState will *not* be stored. + * @param mediaPresent Pointer to returned media state. True indicates media is present + * in the device; False indicates no media is present. + * @param changedState Pointer to returned result. True indicates a change of state since + * prior calls, False indicates that the state has not changed. + */ + virtual IOReturn reportMediaState(bool *mediaPresent,bool *changedState) = 0; + + /*! + * @function reportPollRequirements + * @abstract + * Report if it's necessary to poll for media insertion, and if polling is expensive. + * @discussion + * This method reports whether the device must be polled to detect media + * insertion, and whether a poll is expensive to perform. + * + * The term "expensive" typically implies a device that must be spun-up to detect media, + * as on a PC floppy. Most devices can detect media inexpensively. + * @param pollRequired + * Pointer to returned result. True indicates that polling is required; False indicates + * that polling is not required to detect media. + * @param pollIsExpensive + * Pointer to returned result. True indicates that the polling operation is expensive; + * False indicates that the polling operation is cheap. + */ + virtual IOReturn reportPollRequirements(bool *pollRequired, + bool *pollIsExpensive) = 0; + + /*! + * @function reportRemovability + * @abstract + * Report whether the media is removable or not. + * @discussion + * This method reports whether the media is removable, but it does not + * provide detailed information regarding software eject or lock/unlock capability. + * @param isRemovable + * Pointer to returned result. True indicates that the media is removable; False + * indicates the media is not removable. + */ + virtual IOReturn reportRemovability(bool *isRemovable) = 0; + + /*! + * @function reportWriteProtection + * @abstract + * Report whether the media is write-protected or not. + * @param isWriteProtected + * Pointer to returned result. True indicates that the media is write-protected (it + * cannot be written); False indicates that the media is not write-protected (it + * is permissible to write). + */ + virtual IOReturn reportWriteProtection(bool *isWriteProtected) = 0; + +#ifndef __LP64__ + virtual IOReturn doAsyncReadWrite(IOMemoryDescriptor *buffer, + UInt64 block, UInt64 nblks, + IOStorageCompletion completion) __attribute__ ((deprecated)); +#endif /* !__LP64__ */ + + /*! + * @function getWriteCacheState + * @abstract + * Reports the current write cache state of the device. + * @discussion + * Reports the current write cache state of the device. The write cache + * state is not guaranteed to persist across reboots and detaches. + * @param enabled + * Pointer to returned result. True indicates the write cache is enabled; + * False indicates the write cache is disabled. + */ +#ifdef __LP64__ + virtual IOReturn getWriteCacheState(bool *enabled) = 0; +#else /* !__LP64__ */ + virtual IOReturn getWriteCacheState(bool *enabled); /* 10.3.0 */ +#endif /* !__LP64__ */ + + /*! + * @function setWriteCacheState + * @abstract + * Sets the write cache state of the device. + * @discussion + * Sets the write cache state of the device. The write cache state + * is not guaranteed to persist across reboots and detaches. + * @param enabled + * True to enable the write cache; False to disable the write cache. + */ +#ifdef __LP64__ + virtual IOReturn setWriteCacheState(bool enabled) = 0; +#else /* !__LP64__ */ + virtual IOReturn setWriteCacheState(bool enabled); /* 10.3.0 */ +#endif /* !__LP64__ */ + + /*! + * @function doAsyncReadWrite + * @abstract + * Start an asynchronous read or write operation. + * @param buffer + * An IOMemoryDescriptor describing the data-transfer buffer. The data direction + * is contained in the IOMemoryDescriptor. Responsibility for releasing the descriptor + * rests with the caller. + * @param block + * The starting block number of the data transfer. + * @param nblks + * The integral number of blocks to be transferred. + * @param attributes + * Attributes of the data transfer. See IOStorageAttributes. + * @param completion + * The completion routine to call once the data transfer is complete. + */ +#ifdef __LP64__ + virtual IOReturn doAsyncReadWrite(IOMemoryDescriptor *buffer, + UInt64 block, UInt64 nblks, + IOStorageAttributes *attributes, + IOStorageCompletion *completion) = 0; +#else /* !__LP64__ */ + virtual IOReturn doAsyncReadWrite(IOMemoryDescriptor *buffer, + UInt64 block, UInt64 nblks, + IOStorageAttributes *attributes, + IOStorageCompletion *completion); /* 10.5.0 */ +#endif /* !__LP64__ */ + + /*! + * @function requestIdle + * @abstract + * Request that the device enter an idle state. + * @discussion + * Request that the device enter an idle state. The device will exit this state on the + * next read or write request, or as it sees necessary. One example is for a DVD drive + * to spin down when it enters such an idle state, and spin up on the next read request + * from the system. + */ + virtual IOReturn requestIdle(void); /* 10.6.0 */ + + /*! + * @function doDiscard + * @abstract + * Delete unused data blocks from the media. + * @param block + * The starting block number of the operation. + * @param nblks + * The integral number of blocks to be deleted. + */ + virtual IOReturn doDiscard(UInt64 block, UInt64 nblks); /* 10.6.0 */ + +#ifdef __LP64__ + OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 0); + OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 1); + OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 2); + OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 3); + OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 4); + OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 5); +#else /* !__LP64__ */ + OSMetaClassDeclareReservedUsed(IOBlockStorageDevice, 0); + OSMetaClassDeclareReservedUsed(IOBlockStorageDevice, 1); + OSMetaClassDeclareReservedUsed(IOBlockStorageDevice, 2); + OSMetaClassDeclareReservedUsed(IOBlockStorageDevice, 3); + OSMetaClassDeclareReservedUsed(IOBlockStorageDevice, 4); + OSMetaClassDeclareReservedUsed(IOBlockStorageDevice, 5); +#endif /* !__LP64__ */ + OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 6); + OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 7); + OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 8); + OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 9); + OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 10); + OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 11); + OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 12); + OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 13); + OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 14); + OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 15); + OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 16); + OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 17); + OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 18); + OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 19); + OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 20); + OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 21); + OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 22); + OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 23); + OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 24); + OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 25); + OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 26); + OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 27); + OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 28); + OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 29); + OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 30); + OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 31); +}; + +#endif /* __cplusplus */ +#endif /* KERNEL */ +#endif /* !_IOBLOCKSTORAGEDEVICE_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/bluetooth/IOBluetoothHCIRequest.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/bluetooth/IOBluetoothHCIRequest.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/bluetooth/IOBluetoothHCIRequest.h (revision 885) @@ -0,0 +1,155 @@ +/* + File: IOBluetoothHCIRequest.h + Contains: Bluetooth Host Controller request object. + Copyright: (c) 2001-2008 by Apple, all rights reserved. +*/ + +#pragma once + +#import +#import + +#import + + +class IOCommandGate; +class IOTimerEventSource; +class IOBluetoothHCIController; + +// Forward declaration to avoid the need to include IOBluetoothHCIUserLibShared.h +typedef struct BluetoothHCINotificationMessage; + +//=========================================================================================================================== +// enums, macros, etc. +//=========================================================================================================================== + +enum +{ + kMaxHCIBufferLength = 512 +}; + +typedef UInt8 BluetoothHCIRequestState; +enum BluetoothHCIRequestStates +{ + kHCIRequestStateIdle = 0, // Doing nothing - neither waiting nor busy. usually waiting for deletion. + kHCIRequestStateWaiting = 1, // On the wait queue - request has not been processed in any way. + kHCIRequestStateBusy = 2, // On the busy queue - request is sent and is currently processing +}; + + +//=========================================================================================================================== +// IOBluetoothHCIRequest +//=========================================================================================================================== + +class IOBluetoothHCIRequest : public OSObject +{ + OSDeclareDefaultStructors( IOBluetoothHCIRequest ) + + UInt8 mPrivateResultsBuffer[kMaxHCIBufferLength*4]; // Just in case they didn't give a results ptr. + IOByteCount mPrivateResultsSize; // Result size. + BluetoothHCITransportID mTransportID; // Transport ID to use for this request. + UInt8 mState; // Busy, waiting, idle. + bool mAsyncNotify; + task_t mOwningTaskID; + BluetoothHCIRequestCallbackInfo mCallbackInfo; // When this request is complete, call this. + BluetoothHCICommandOpCode mOpCode; + BluetoothDeviceAddress mDeviceAddress; + BluetoothConnectionHandle mConnectionHandle; + BluetoothHCINotificationMessage * mNotificationMessage; + IOByteCount mNotificationMessageSize; + + +public: + + IOBluetoothHCIRequest * mNextBusy; // Points to next request element on busy queue. + IOBluetoothHCIRequest * mNextWait; // Points to next request element on wait queue. + IOBluetoothHCIRequest * mNextAllocated; // Points to next allocated request element. + IOBluetoothHCIRequest * mPreviousAllocated; // Points to next allocated request element. + BluetoothHCIRequestID mID; // For internal identification. + UInt8 mCommandBuffer[kMaxHCIBufferLength]; // Built-up HCI Command to send to the transport. + IOByteCount mCommandBufferSize; // Size of command buffer. + + UInt8 * mResultsPtr; // Result ptr, provided by object creator. + IOByteCount mResultsSize; // Result size. + + IOCommandGate * mCommandGate; + IOTimerEventSource * mTimer; + IOBluetoothHCIController * mHCIController; + IOReturn mStatus; // Success/failure code of request. + UInt32 mTimeout; // Timeout for request to complete, in milliseconds. + UInt32 mControlFlags; + int mPID; // Creating Task + bool mHCIRequestDeleteWasCalled; // Fixed rdar://problem/7044168 + + +public: + + bool init( IOCommandGate *commandGate, IOBluetoothHCIController *hciController ); + void free(); + + static IOBluetoothHCIRequest * Create( IOCommandGate *commandGate, IOBluetoothHCIController *hciController, bool async = TRUE, UInt32 timeout = 5, UInt32 controlFlags = 0 ); + static IOReturn Dispose( IOBluetoothHCIRequest * inObject ); + + + // Called when a request is started on a transport, and completed. + + IOReturn Start(); + void Complete(); + + // Accessors for object members. + + void SetState( BluetoothHCIRequestState inState ); + BluetoothHCIRequestState GetState() { return( mState ); } + + void SetHCIStatus( BluetoothHCIStatus inStatus ) { mStatus = inStatus; } + BluetoothHCIStatus GetHCIStatus() { return( mStatus ); } + + void SetID( BluetoothHCIRequestID inID ) { mID = inID; } + BluetoothHCIRequestID GetID() { return( mID ); } + + void SetCallbackInfo( BluetoothHCIRequestCallbackInfo * inInfo ); + BluetoothHCIRequestCallbackInfo * GetCallbackInfo() { return( &mCallbackInfo ); } + + void SetOwningTaskID( task_t inTaskID ) { mOwningTaskID = inTaskID; } + task_t GetOwningTaskID() { return( mOwningTaskID ); } + + void * GetCommandBuffer(); + + BluetoothHCICommandOpCode GetCommandOpCode(); + void SetCommandOpCode( BluetoothHCICommandOpCode inOpCode ) { mOpCode = inOpCode; } + + BluetoothDeviceAddress * GetDeviceAddress() { return &mDeviceAddress; } + void SetDeviceAddress( const BluetoothDeviceAddress *inDeviceAddress ) { if ( inDeviceAddress != NULL ) memcpy( &mDeviceAddress, inDeviceAddress, sizeof( BluetoothDeviceAddress ) ); } + void ClearDeviceAddress() { bzero( &mDeviceAddress, sizeof( BluetoothDeviceAddress ) ); } + Boolean CompareDeviceAddress( const BluetoothDeviceAddress *inDeviceAddress ); + + BluetoothConnectionHandle GetConnectionHandle() { return mConnectionHandle; } + void SetConnectionHandle( BluetoothConnectionHandle inConnectionHandle ) { mConnectionHandle = inConnectionHandle; } + void ClearConnectionHandle() { mConnectionHandle = kBluetoothConnectionHandleNone; } + + void SetTimeout( UInt32 inTimeout ) { mTimeout = inTimeout; } // in milliseconds + UInt32 GetTimeout() { return( mTimeout ); } + + void StartTimer(); + + static void timerFired( OSObject *owner, IOTimerEventSource *sender ); + void handleTimeout(); + + void CopyDataIntoResultsPtr( UInt8 * inDataPtr, IOByteCount inSize ); + void SetParamPtrAndSize( UInt8 paramNumber, UInt8 * inParamPtr, IOByteCount inSize ); + + void SetResultsBufferPtrAndSize( UInt8 * resultsBuffer, IOByteCount inSize ); + void SetResultsDataSize( IOByteCount inCount ); + UInt8 * GetResultsBuffer(); + IOByteCount GetResultsBufferSize(); + + mach_vm_address_t GetNotificationRefCon() { return( mCallbackInfo.asyncIDRefCon ); } + + void SetDoAsyncNotify( bool inAsyncNotify ) { mAsyncNotify = inAsyncNotify; } + Boolean IsSynchronous() { return !mAsyncNotify; } + + void SetControlFlags( UInt32 controlFlags ) { mControlFlags = controlFlags; } + UInt32 GetControlFlags() { return mControlFlags; } + + const char * RequestDescription(); +}; Index: branches/azimutz/Cleancut/i386/include/IOKit/bluetooth/IOBluetoothInternal.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/bluetooth/IOBluetoothInternal.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/bluetooth/IOBluetoothInternal.h (revision 885) @@ -0,0 +1,103 @@ +/* + File: BluetoothInternal.h + Contains: Internal types and macros needed by public kernel APIs. + Copyright: 2003-2007 by Apple, Inc. All rights reserved. +*/ + +#pragma once + +typedef enum IOBluetoothHCIControllerConfigState +{ + kIOBluetoothHCIControllerConfigStateOnline = 0, // Controller is configured and ready for clients + kIOBluetoothHCIControllerConfigStateKernelSetupPending = 1, // New controller - kernel setup in progress + kIOBluetoothHCIControllerConfigStateDaemonSetupPending = 2, // New controller - daemon setup in progress + kIOBluetoothHCIControllerConfigStateDaemonSetupComplete = 3, // New controller - daemon setup complete + kIOBluetoothHCIControllerConfigStateResetPending = 4, // HCI reset has been issued + kIOBluetoothHCIControllerConfigStateKernelPostResetSetupPending = 5, // HCI reset complete - kernel setup in progress + kIOBluetoothHCIControllerConfigStateDaemonPostResetSetupPending = 6, // HCI reset complete - daemon setup in progress + kIOBluetoothHCIControllerConfigStateDaemonPostResetSetupComplete = 7, // HCI reset complete - daemon setup complete + kIOBluetoothHCIControllerConfigStateUninitialized = 8 +} IOBluetoothHCIControllerConfigState; + +typedef UInt32 IOBluetoothHCIControllerPowerOptions; +enum +{ + kIOBluetoothHCIControllerPowerOptionPowerOffSupported = 0x00000001, + kIOBluetoothHCIControllerPowerOptionWakeFromExistingConnectionSupported = 0x00000002, + kIOBluetoothHCIControllerPowerOptionWakeFromNewConnectionSupported = 0x00000004, + kIOBluetoothHCIControllerPowerOptionIdleWithConnectionSupported = 0x00000008, + kIOBluetoothHCIControllerPowerOptionIdleWhenInternalPower = 0x00000010 +}; + +enum IOBluetoothHCIControllerSleepOptions +{ + kIOBluetoothHCIControllerAllowWakeFromExistingConnection = 0x00000001, + kIOBluetoothHCIControllerAllowWakeFromNewConnection = 0x00000002, + kIOBluetoothHCIControllerTemporaryOnFromIdle = 0x00000004 +}; + +#define HCI_CONTROLLER_POWER_OFF_SUPPORTED( _controllerPowerOptions ) ( ( _controllerPowerOptions & kIOBluetoothHCIControllerPowerOptionPowerOffSupported ) == kIOBluetoothHCIControllerPowerOptionPowerOffSupported ) +#define HCI_CONTROLLER_SLEEP_SUPPORTED( _controllerPowerOptions ) \ + ( ( _controllerPowerOptions & \ + ( kIOBluetoothHCIControllerPowerOptionWakeFromExistingConnectionSupported | \ + kIOBluetoothHCIControllerPowerOptionWakeFromNewConnectionSupported ) ) != 0 ) + +typedef enum IOBluetoothHCIControllerInternalPowerState +{ + kIOBluetoothHCIControllerInternalPowerStateOff = 0, + kIOBluetoothHCIControllerInternalPowerStateOn = 1, + kIOBluetoothHCIControllerInternalPowerStateSleep = 2, + kIOBluetoothHCIControllerInternalPowerStateIdle = 3 +} IOBluetoothHCIControllerInternalPowerState; + +enum IOBluetoothHCIControllerPowerStateOrdinal +{ + kIOBluetoothHCIControllerPowerStateOrdinalOff = 0, + kIOBluetoothHCIControllerPowerStateOrdinalIdle = 1, + kIOBluetoothHCIControllerPowerStateOrdinalOn = 2 +}; + +typedef UInt32 IOBluetoothHCIControllerFeatureFlags; + +enum +{ + kIOBluetoothHCIControllerFeatureFlagVendorCommandFlowControl = 0x00000001, + kIOBluetoothHCIControllerFeatureFlagSCOSupported = 0x00000002, + kIOBluetoothHCIControllerFeatureFlagSerializeCommands = 0x10000000 +}; + +//=========================================================================================================================== +// Private_UnifiedInquiryResult +//=========================================================================================================================== + +typedef struct IOBluetoothHCIUnifiedInquiryResult IOBluetoothHCIUnifiedInquiryResult; +struct IOBluetoothHCIUnifiedInquiryResult +{ + BluetoothHCIInquiryResult originalInquiryResult; + + // event code will be either: + // kBluetoothHCIEventInquiryResult, kBluetoothHCIEventInquiryResultWithRSSI, or kBluetoothHCIEventExtendedInquiryResult + + BluetoothHCIEventCode eventCode; + + // kBluetoothHCIEventExtendedInquiryResult only + + BluetoothHCIExtendedInquiryResponse extendedInquiryResponse; + + // kBluetoothHCIEventExtendedInquiryResult or kBluetoothHCIEventInquiryResultWithRSSI only + + UInt8 reserved; + BluetoothHCIRSSIValue RSSIValue; +}; + +#if BLUETOOTH_VERSION_MAX_ALLOWED >= BLUETOOTH_VERSION_2_0 + +enum BluetoothHCIExtendedInquiryResponseDataTypesAppleSpecificInfo +{ + kBluetoothHCIExtendedInquiryResponseDataTypeAppleSpecificInfoReserved = 0x00, + kBluetoothHCIExtendedInquiryResponseDataTypeAppleSpecificInfoModelIdentifier = 0x01, /* UTF8String char data */ + kBluetoothHCIExtendedInquiryResponseDataTypeAppleSpecificInfoThirdPartyAdvertising = 0x02, +}; + +#endif /* BLUETOOTH_VERSION_MAX_ALLOWED >= BLUETOOTH_VERSION_2_0 */ + Index: branches/azimutz/Cleancut/i386/include/IOKit/bluetooth/IOBluetoothHIDDriver.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/bluetooth/IOBluetoothHIDDriver.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/bluetooth/IOBluetoothHIDDriver.h (revision 885) @@ -0,0 +1,230 @@ +/* + File: IOBluetoothHIDDriver.h + Contains: Driver for generic Bluetooth HID devices. + Copyright: (c) 2001-2008 by Apple, all rights reserved. +*/ + +#ifndef IOBLUETOOTHHIDDRIVER_H +#define IOBLUETOOTHHIDDRIVER_H + +#include +#include + +//=========================================================================================================================== +// Forwards +//=========================================================================================================================== + +class IOTimerEventSource; +class IOWorkLoop; + +class IOBluetoothL2CAPChannel; +class IOBluetoothDevice; +class IOWorkQueue; + +//=========================================================================================================================== +// IOBluetoothHIDDriver +//=========================================================================================================================== + +class IOBluetoothHIDDriver : public IOHIDDevice +{ + OSDeclareDefaultStructors( IOBluetoothHIDDriver ) + + IOWorkLoop* _workLoop; + IOCommandGate* _commandGate; + + IOWorkQueue *_desyncWorkQueue; + + IOBluetoothL2CAPChannel* _controlChannel; + IOBluetoothL2CAPChannel* _interruptChannel; + + IOBluetoothDevice* _device; + + IOMemoryDescriptor* _memDescriptor; + IOMemoryDescriptor* _getReportDescriptor; + IONotifier* _interruptOpenNotification; + IOTimerEventSource* _timer; + IONotifier* _sleepWakeNotifier; + + bool _deviceReady; + + UInt8 _expectedReportID; + UInt8 _expectedReportType; + UInt8 _handshake; + + OSDictionary* _deviceProperties; + + UInt16 _vendorIDSource; + UInt16 _vendorID; + UInt16 _productID; + UInt16 _deviceVersion; + uint32_t _classOfDevice; + UInt16 _countryCode; + + BluetoothDeviceAddress _deviceAddress; + char _deviceAddressString[20]; + + uint32_t _outstandingIO; + bool _sendOutstanding; + + // Debug / Behavior Modifiers + UInt8 _verboseLevel; + bool _logPackets; + bool _decodePackets; + bool _logOutstandingIO; + bool _suppressDisconnectNotifications; + bool _suppressSetProtocol; + bool _driverIsAwake; + bool _reservedFlag4; + UInt8 _reservedByte; + + struct ExpansionData + { + OSArray* _sendQueue; + + uint8_t *interruptBuffer; + uint32_t interruptBufferUsed; + + uint8_t *controlBuffer; + uint32_t controlBufferUsed; + + uint8_t deviceSupportsSuspend; + + uint32_t getReportTimeoutMS; + uint32_t setReportTimeoutMS; + + uint32_t outstandingMemoryBlockCount; + bool waitingForMemoryBlockCount; + }; + ExpansionData *_expansionData; + +public: + // Standard IOService Methods + virtual IOService* probe( IOService * provider, SInt32 * score ); + virtual bool init( OSDictionary *properties ); + virtual void free(); + virtual bool willTerminate( IOService * provider, IOOptionBits options ); + + // Starting & Stopping + virtual bool handleStart( IOService * provider ); + virtual void handleStop( IOService * provider ); + virtual void deviceReady(); + virtual void closeDownServices(); + + // Power Management + virtual void handleSleep(); + virtual void handleWake(); + virtual void handleShutdown(); // Does nothing + virtual void handleRestart(); // Does nothing + + // HID Properties + virtual OSString* newTransportString() const; + virtual OSString* newManufacturerString() const; + virtual OSString* newProductString() const; + virtual OSNumber* newVendorIDSourceNumber() const; + virtual OSNumber* newVendorIDNumber() const; + virtual OSNumber* newProductIDNumber() const; + virtual OSNumber* newVersionNumber() const; + virtual IOReturn newReportDescriptor( IOMemoryDescriptor ** descriptor ) const; + virtual OSString* newSerialNumberString() const; + virtual OSNumber* newLocationIDNumber() const; + virtual OSNumber* newCountryCodeNumber() const; + virtual OSNumber* newReportIntervalNumber() const; + + // Main UserLand Entry Points + virtual IOReturn getReport( IOMemoryDescriptor* report, IOHIDReportType reportType, IOOptionBits options = 0 ); + virtual IOReturn setReport( IOMemoryDescriptor* report, IOHIDReportType reportType, IOOptionBits options = 0 ); + virtual IOReturn setProperties( OSObject* properties ); + + // General IO + virtual IOReturn sendData( IOBluetoothL2CAPChannel* theChannel, void* theData, IOByteCount theSize ); + virtual void processControlData( UInt8 *buffer, UInt16 length ); + virtual void processInterruptData( UInt8 *buffer, UInt16 length ); + virtual IOReturn waitForData( IOMemoryDescriptor* report, UInt8 btReportType, UInt8 reportID ); + virtual IOReturn waitForHandshake(); + + // HID Transaction Methods + virtual IOReturn hidControl( UInt8 controlOperation ); + virtual int getProtocol(); + virtual IOReturn setProtocol( UInt8 protocol ); + virtual int getIdle(); + virtual IOReturn setIdle( UInt8 idleRate ); + + // Device Introspection + virtual bool isKeyboard(); + virtual bool isMouse(); + + // Misc + virtual IOReturn setPowerState( unsigned long powerStateOrdinal, IOService* whatDevice ); + virtual IOReturn createCommandGate( IOService* provider ); + virtual IOReturn getDeviceProperties( IOService* provider ); + virtual bool readDeviceName(); + + // Command Gate Actions + static IOReturn staticCloseDownServicesAction( OSObject* owner, void* arg1, void* arg2, void* arg3, void* arg4 ); + static IOReturn staticSendToAction( OSObject* owner, void* theChannel, void* theData, void *theSize, void* ); + static IOReturn staticPrepControlChannelAction( OSObject* owner, void* arg1, void* arg2, void* arg3, void* arg4 ); + static IOReturn staticPrepInterruptChannelAction( OSObject* owner, void* arg1, void* arg2, void* arg3, void* arg4 ); + static IOReturn staticGetReportAction( OSObject* owner, void* arg1, void* arg2, void* arg3, void* arg4 ); + static IOReturn staticSetReportAction( OSObject* owner, void* arg1, void* arg2, void* arg3, void* arg4 ); + static IOReturn staticProcessCommandAction( OSObject* owner, void* arg1, void* arg2, void* arg3, void* arg4 ); + static IOReturn staticGetDevicePropertiesAction( OSObject* owner, void* arg1, void* arg2, void* arg3, void* arg4 ); + static IOReturn staticInterruptChannelOpeningAction( OSObject* owner, void* newService, void* arg2, void* arg3, void* arg4 ); + static IOReturn staticWillTerminateAction( OSObject* owner, void* arg1, void* arg2, void* arg3, void* arg4 ); + + // Work Loop Methods + virtual void closeDownServicesWL(); + virtual IOReturn prepInterruptChannelWL(); + virtual IOReturn getReportWL( IOMemoryDescriptor* report, IOHIDReportType reportType, IOOptionBits options ); + virtual IOReturn setReportWL( IOMemoryDescriptor* report, IOHIDReportType reportType, IOOptionBits options ); + virtual IOReturn processCommandWL( OSString* command, OSNumber* commandParameter ); + virtual IOReturn getDevicePropertiesWL( IOService* provider ); + virtual IOReturn interruptChannelOpeningWL( IOBluetoothL2CAPChannel* theChannel ); + + // Timeout Handler + static void timerFired( OSObject* owner, IOTimerEventSource* sender ); + virtual void handleTimeout(); + + // IO Counting + virtual void incrementOutstandingIO(); + virtual void decrementOutstandingIO(); + +private: + // Lazy Interrupt Channel Methods + static bool interruptChannelOpeningCallback( void* me, void* ignoreMe, IOService* newService, IONotifier *notifier ); + static IOReturn powerStateHandler( void *target, void *refCon, UInt32 messageType, IOService *service, void *messageArgument, vm_size_t argSize ); + +public: + OSMetaClassDeclareReservedUsed( IOBluetoothHIDDriver, 0 ); + virtual void sendDeviceDisconnectNotifications( void ); + + OSMetaClassDeclareReservedUsed( IOBluetoothHIDDriver, 1 ); + virtual IOReturn setPowerStateWL( unsigned long powerStateOrdinal, IOService* whatDevice ); + + OSMetaClassDeclareReservedUsed( IOBluetoothHIDDriver, 2 ); + virtual void sendDeviceConnectNotifications( void ); + + OSMetaClassDeclareReservedUsed( IOBluetoothHIDDriver, 3 ); + virtual void decrementOutstandingMemoryBlockCount( void ); + + OSMetaClassDeclareReservedUsed( IOBluetoothHIDDriver, 4 ); + virtual IOReturn willTerminateWL( void ); + +public: + OSMetaClassDeclareReservedUnused( IOBluetoothHIDDriver, 5 ); + OSMetaClassDeclareReservedUnused( IOBluetoothHIDDriver, 6 ); + OSMetaClassDeclareReservedUnused( IOBluetoothHIDDriver, 7 ); + OSMetaClassDeclareReservedUnused( IOBluetoothHIDDriver, 8 ); + OSMetaClassDeclareReservedUnused( IOBluetoothHIDDriver, 9 ); + OSMetaClassDeclareReservedUnused( IOBluetoothHIDDriver, 10 ); + OSMetaClassDeclareReservedUnused( IOBluetoothHIDDriver, 11 ); + OSMetaClassDeclareReservedUnused( IOBluetoothHIDDriver, 12 ); + OSMetaClassDeclareReservedUnused( IOBluetoothHIDDriver, 13 ); + OSMetaClassDeclareReservedUnused( IOBluetoothHIDDriver, 14 ); + OSMetaClassDeclareReservedUnused( IOBluetoothHIDDriver, 15 ); + OSMetaClassDeclareReservedUnused( IOBluetoothHIDDriver, 16 ); + OSMetaClassDeclareReservedUnused( IOBluetoothHIDDriver, 17 ); + OSMetaClassDeclareReservedUnused( IOBluetoothHIDDriver, 18 ); + OSMetaClassDeclareReservedUnused( IOBluetoothHIDDriver, 19 ); +}; + +#endif // IOBLUETOOTHHIDDRIVER_H Index: branches/azimutz/Cleancut/i386/include/IOKit/bluetooth/BluetoothAssignedNumbers.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/bluetooth/BluetoothAssignedNumbers.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/bluetooth/BluetoothAssignedNumbers.h (revision 885) @@ -0,0 +1,552 @@ +/* + File: BluetoothAssignedNumbers.h + Copyright: (c) 2002-2008 by Apple Computer, Inc. All rights reserved. +*/ + +#pragma once + +#ifdef __cplusplus + extern "C" { +#endif + +#if BLUETOOTH_VERSION_MAX_ALLOWED >= BLUETOOTH_VERSION_2_0 + +#pragma mark - +#pragma mark === General === + +enum BluetoothCompanyIdentifers +{ + kBluetoothCompanyIdentiferEricssonTechnologyLicensing = 0, + kBluetoothCompanyIdentiferNokiaMobilePhones = 1, + kBluetoothCompanyIdentiferIntel = 2, + kBluetoothCompanyIdentiferIBM = 3, + kBluetoothCompanyIdentiferToshiba = 4, + kBluetoothCompanyIdentifer3Com = 5, + kBluetoothCompanyIdentiferMicrosoft = 6, + kBluetoothCompanyIdentiferLucent = 7, + kBluetoothCompanyIdentiferMotorola = 8, + kBluetoothCompanyIdentiferInfineonTechnologiesAG = 9, + kBluetoothCompanyIdentiferCambridgeSiliconRadio = 10, + kBluetoothCompanyIdentiferSiliconWave = 11, + kBluetoothCompanyIdentiferDigianswerAS = 12, + kBluetoothCompanyIdentiferTexasInstruments = 13, + kBluetoothCompanyIdentiferParthusTechnologies = 14, + kBluetoothCompanyIdentiferBroadcom = 15, + kBluetoothCompanyIdentiferMitelSemiconductor = 16, + kBluetoothCompanyIdentiferWidcomm = 17, + kBluetoothCompanyIdentiferZeevo = 18, + kBluetoothCompanyIdentiferAtmel = 19, + kBluetoothCompanyIdentiferMistubishiElectric = 20, + kBluetoothCompanyIdentiferRTXTelecom = 21, + kBluetoothCompanyIdentiferKCTechnology = 22, + kBluetoothCompanyIdentiferNewlogic = 23, + kBluetoothCompanyIdentiferTransilica = 24, + kBluetoothCompanyIdentiferRohdeandSchwarz = 25, + kBluetoothCompanyIdentiferTTPCom = 26, + kBluetoothCompanyIdentiferSigniaTechnologies = 27, + kBluetoothCompanyIdentiferConexantSystems = 28, + kBluetoothCompanyIdentiferQualcomm = 29, + kBluetoothCompanyIdentiferInventel = 30, + kBluetoothCompanyIdentiferAVMBerlin = 31, + kBluetoothCompanyIdentiferBandspeed = 32, + kBluetoothCompanyIdentiferMansella = 33, + kBluetoothCompanyIdentiferNEC = 34, + kBluetoothCompanyIdentiferWavePlusTechnology = 35, + kBluetoothCompanyIdentiferAlcatel = 36, + kBluetoothCompanyIdentiferPhilipsSemiconductor = 37, + kBluetoothCompanyIdentiferCTechnologies = 38, + kBluetoothCompanyIdentiferOpenInterface = 39, + kBluetoothCompanyIdentiferRFCMicroDevices = 40, + kBluetoothCompanyIdentiferHitachi = 41, + kBluetoothCompanyIdentiferSymbolTechnologies = 42, + kBluetoothCompanyIdentiferTenovis = 43, + kBluetoothCompanyIdentiferMacronixInternational = 44, + kBluetoothCompanyIdentiferGCTSemiconductor = 45, + kBluetoothCompanyIdentiferNorwoodSystems = 46, + kBluetoothCompanyIdentiferMewTelTechnology = 47, + kBluetoothCompanyIdentiferSTMicroelectronics = 48, + kBluetoothCompanyIdentiferSynopsys = 49, + kBluetoothCompanyIdentiferRedMCommunications = 50, + kBluetoothCompanyIdentiferCommil = 51, + kBluetoothCompanyIdentiferCATC = 52, + kBluetoothCompanyIdentiferEclipse = 53, + kBluetoothCompanyIdentiferRenesasTechnology = 54, + kBluetoothCompanyIdentiferMobilian = 55, + kBluetoothCompanyIdentiferTerax = 56, + kBluetoothCompanyIdentiferIntegratedSystemSolution = 57, + kBluetoothCompanyIdentiferMatsushitaElectricIndustrial = 58, + kBluetoothCompanyIdentiferGennum = 59, + kBluetoothCompanyIdentiferResearchInMotion = 60, + kBluetoothCompanyIdentiferIPextreme = 61, + kBluetoothCompanyIdentiferSystemsAndChips = 62, + kBluetoothCompanyIdentiferBluetoothSIG = 63, + kBluetoothCompanyIdentiferSeikoEpson = 64, + kBluetoothCompanyIdentiferIntegratedSiliconSolution = 65, + kBluetoothCompanyIdentiferCONWISETechnology = 66, + kBluetoothCompanyIdentiferParrotSA = 67, + kBluetoothCompanyIdentiferSocketCommunications = 68, + kBluetoothCompanyIdentiferAtherosCommunications = 69, + kBluetoothCompanyIdentiferMediaTek = 70, + kBluetoothCompanyIdentiferBluegiga = 71, + kBluetoothCompanyIdentiferMarvellTechnologyGroup = 72, + kBluetoothCompanyIdentifer3DSP = 73, + kBluetoothCompanyIdentiferAccelSemiconductor = 74, + kBluetoothCompanyIdentiferContinentialAutomotiveSystems = 75, + kBluetoothCompanyIdentiferApple = 76, + kBluetoothCompanyIdentiferStaccatoCommunications = 77, + kBluetoothCompanyIdentiferAvagoTechnologies = 78, + kBluetoothCompanyIdentiferAPT = 79, + + kBluetoothCompanyIdentiferInteropIdentifier = 65535 +}; + +#endif /* BLUETOOTH_VERSION_MAX_ALLOWED >= BLUETOOTH_VERSION_2_0 */ + +#pragma mark - +#pragma mark === Baseband === + +//================================================================================================================== +// Baseband +//================================================================================================================== + +// +// Service Class Major +// + +enum +{ + kBluetoothServiceClassMajorLimitedDiscoverableMode = 0x001, // Bit 13 - Limited Discoverable Mode + kBluetoothServiceClassMajorReserved1 = 0x002, // Bit 14 - Reserved for future use. + kBluetoothServiceClassMajorReserved2 = 0x004, // Bit 15 - Reserved for future use. + kBluetoothServiceClassMajorPositioning = 0x008, // Bit 16 - Positioning (Location ID) + kBluetoothServiceClassMajorNetworking = 0x010, // Bit 17 - LAN, Ad hoc, etc... + kBluetoothServiceClassMajorRendering = 0x020, // Bit 18 - Printing, Speaker, etc... + kBluetoothServiceClassMajorCapturing = 0x040, // Bit 19 - Scanner, Microphone, etc... + kBluetoothServiceClassMajorObjectTransfer = 0x080, // Bit 20 - v-Inbox, v-Folder, etc... + kBluetoothServiceClassMajorAudio = 0x100, // Bit 21 - Speaker, Microphone, Headset, etc... + kBluetoothServiceClassMajorTelephony = 0x200, // Bit 22 - Cordless telephony, Modem, Headset, etc... + kBluetoothServiceClassMajorInformation = 0x400, // Bit 23 - Web server, WAP server, etc... + + kBluetoothServiceClassMajorAny = '****', // Pseudo-class - means anything acceptable. + kBluetoothServiceClassMajorNone = 'none', // Pseudo-class - means no matching. + + kBluetoothServiceClassMajorEnd +}; + +// +// Device Class Major +// + +enum +{ + kBluetoothDeviceClassMajorMiscellaneous = 0x00, // [00000] Miscellaneous + kBluetoothDeviceClassMajorComputer = 0x01, // [00001] Desktop, Notebook, PDA, Organizers, etc... + kBluetoothDeviceClassMajorPhone = 0x02, // [00010] Cellular, Cordless, Payphone, Modem, etc... + kBluetoothDeviceClassMajorLANAccessPoint = 0x03, // [00011] LAN Access Point + kBluetoothDeviceClassMajorAudio = 0x04, // [00100] Headset, Speaker, Stereo, etc... + kBluetoothDeviceClassMajorPeripheral = 0x05, // [00101] Mouse, Joystick, Keyboards, etc... + kBluetoothDeviceClassMajorImaging = 0x06, // [00110] Printing, scanner, camera, display, etc... + kBluetoothDeviceClassMajorUnclassified = 0x1F, // [11111] Specific device code not assigned + + // Range 0x06 to 0x1E Reserved for future use. + + kBluetoothDeviceClassMajorAny = '****', // Pseudo-class - means anything acceptable. + kBluetoothDeviceClassMajorNone = 'none', // Pseudo-class - means no matching. + + kBluetoothDeviceClassMajorEnd +}; + +// +// Device Class Minor +// + +enum +{ + /// + /// Computer Major Class + /// + + kBluetoothDeviceClassMinorComputerUnclassified = 0x00, // [000000] Specific device code not assigned + kBluetoothDeviceClassMinorComputerDesktopWorkstation = 0x01, // [000001] Desktop workstation + kBluetoothDeviceClassMinorComputerServer = 0x02, // [000010] Server-class computer + kBluetoothDeviceClassMinorComputerLaptop = 0x03, // [000011] Laptop + kBluetoothDeviceClassMinorComputerHandheld = 0x04, // [000100] Handheld PC/PDA (clam shell) + kBluetoothDeviceClassMinorComputerPalmSized = 0x05, // [000101] Palm-sized PC/PDA + kBluetoothDeviceClassMinorComputerWearable = 0x06, // [000110] Wearable computer (watch sized) + + // Range 0x06 to 0x7F Reserved for future use. + + + /// + /// Phone Major Class + /// + + kBluetoothDeviceClassMinorPhoneUnclassified = 0x00, // [000000] Specific device code not assigned + kBluetoothDeviceClassMinorPhoneCellular = 0x01, // [000001] Cellular + kBluetoothDeviceClassMinorPhoneCordless = 0x02, // [000010] Cordless + kBluetoothDeviceClassMinorPhoneSmartPhone = 0x03, // [000011] Smart phone + kBluetoothDeviceClassMinorPhoneWiredModemOrVoiceGateway = 0x04, // [000100] Wired modem or voice gateway + kBluetoothDeviceClassMinorPhoneCommonISDNAccess = 0x05, // [000101] Common ISDN Access + + // Range 0x05 to 0x7F Reserved for future use. + + + /// + /// LAN Access Point Major Class + /// + + // $$$ TO DO: LAN Access Point minor classes are broken into bits 5-7 for utilization and bits 2-4 for class. + + + /// + /// Audio Major Class + /// + + kBluetoothDeviceClassMinorAudioUnclassified = 0x00, // [000000] Specific device code not assigned + kBluetoothDeviceClassMinorAudioHeadset = 0x01, // [000001] Device conforms to the Headset profile + kBluetoothDeviceClassMinorAudioHandsFree = 0x02, // [000010] Hands-free + kBluetoothDeviceClassMinorAudioReserved1 = 0x03, // [000011] Reserved + kBluetoothDeviceClassMinorAudioMicrophone = 0x04, // [000100] Microphone + kBluetoothDeviceClassMinorAudioLoudspeaker = 0x05, // [000101] Loudspeaker + kBluetoothDeviceClassMinorAudioHeadphones = 0x06, // [000110] Headphones + kBluetoothDeviceClassMinorAudioPortable = 0x07, // [000111] Portable Audio + kBluetoothDeviceClassMinorAudioCar = 0x08, // [001000] Car Audio + kBluetoothDeviceClassMinorAudioSetTopBox = 0x09, // [001001] Set-top box + kBluetoothDeviceClassMinorAudioHiFi = 0x0a, // [001010] HiFi Audio Device + kBluetoothDeviceClassMinorAudioVCR = 0x0b, // [001011] VCR + kBluetoothDeviceClassMinorAudioVideoCamera = 0x0c, // [001100] Video Camera + kBluetoothDeviceClassMinorAudioCamcorder = 0x0d, // [001101] Camcorder + kBluetoothDeviceClassMinorAudioVideoMonitor = 0x0e, // [001110] Video Monitor + kBluetoothDeviceClassMinorAudioVideoDisplayAndLoudspeaker = 0x0f, // [001111] Video Display and Loudspeaker + kBluetoothDeviceClassMinorAudioVideoConferencing = 0x10, // [010000] Video Conferencing + kBluetoothDeviceClassMinorAudioReserved2 = 0x11, // [010001] Reserved + kBluetoothDeviceClassMinorAudioGamingToy = 0x12, // [010010] Gaming/Toy + + + // Range 0x13 to 0x7F Reserved for future use. + + + /// + /// Peripheral Major Class + /// + + // Peripheral1 subclass is bits 7 & 6 + + kBluetoothDeviceClassMinorPeripheral1Keyboard = 0x10, // [01XXXX] Keyboard + kBluetoothDeviceClassMinorPeripheral1Pointing = 0x20, // [10XXXX] Pointing device + kBluetoothDeviceClassMinorPeripheral1Combo = 0x30, // [11XXXX] Combo keyboard/pointing device + + // Peripheral2 subclass is bits 5-2 + + kBluetoothDeviceClassMinorPeripheral2Unclassified = 0x00, // [XX0000] Uncategorized device + kBluetoothDeviceClassMinorPeripheral2Joystick = 0x01, // [XX0001] Joystick + kBluetoothDeviceClassMinorPeripheral2Gamepad = 0x02, // [XX0010] Gamepad + kBluetoothDeviceClassMinorPeripheral2RemoteControl = 0x03, // [XX0011] Remote control + kBluetoothDeviceClassMinorPeripheral2SensingDevice = 0x04, // [XX0100] Sensing device + kBluetoothDeviceClassMinorPeripheral2DigitizerTablet = 0x05, // [XX0101] Digitizer Tablet + kBluetoothDeviceClassMinorPeripheral2CardReader = 0x06, // [XX0110] Card Reader + + kBluetoothDeviceClassMinorPeripheral2AnyPointing = 'poin', // Anything under MinorPeripheral1Pointing + + // Range 0x05 to 0x0f reserved for future use + + + /// + /// Imaging Major Class + /// + + // Imaging1 subclass is bits 7 - 4 + + kBluetoothDeviceClassMinorImaging1Display = 0x04, // [XXX1XX] Display + kBluetoothDeviceClassMinorImaging1Camera = 0x08, // [XX1XXX] Camera + kBluetoothDeviceClassMinorImaging1Scanner = 0x10, // [X1XXXX] Scanner + kBluetoothDeviceClassMinorImaging1Printer = 0x20, // [1XXXXX] Printer + + // Imaging2 subclass is bits 3 - 2 + + kBluetoothDeviceClassMinorImaging2Unclassified = 0x00, // [XXXX00] Uncategorized, default + + // Range 0x01 - 0x03 reserved for future use + + + /// + /// Misc + /// + + kBluetoothDeviceClassMinorAny = '****', // Pseudo-class - means anything acceptable. + kBluetoothDeviceClassMinorNone = 'none', // Pseudo-class - means no matching. + + kBluetoothDeviceClassMinorEnd +}; + + +// Peripheral devices bits 7 & 6 +#define BluetoothCoDMinorPeripheral1(minorClass) (minorClass & 0x30) + +// Peripheral devices bits 5 - 2 +#define BluetoothCoDMinorPeripheral2(minorClass) (minorClass & 0x0f) + +#pragma mark - +#pragma mark === L2CAP === + +//=========================================================================================================================== +// L2CAP +//=========================================================================================================================== + +enum +{ + kBluetoothL2CAPPSMSDP = 0x0001, + kBluetoothL2CAPPSMRFCOMM = 0x0003, + kBluetoothL2CAPPSMTCS_BIN = 0x0005, // Telephony Control Specifictation / TCS Binary + kBluetoothL2CAPPSMTCS_BIN_Cordless = 0x0007, // Telephony Control Specifictation / TCS Binary + kBluetoothL2CAPPSMBNEP = 0x000F, // Bluetooth Network Encapsulation Protocol + kBluetoothL2CAPPSMHIDControl = 0x0011, // HID profile - control interface + kBluetoothL2CAPPSMHIDInterrupt = 0x0013, // HID profile - interrupt interface + kBluetoothL2CAPPSMAVCTP = 0x0017, // Audio/Video Control Transport Protocol + kBluetoothL2CAPPSMAVDTP = 0x0019, // Audio/Video Distribution Transport Protocol + kBluetoothL2CAPPSMUID_C_Plane = 0x001D, // Unrestricted Digital Information Profile (UDI) + + // Range < 0x1000 reserved. + kBluetoothL2CAPPSMReservedStart = 0x0001, + kBluetoothL2CAPPSMReservedEnd = 0x1000, + + // Range 0x1001-0xFFFF dynamically assigned. + kBluetoothL2CAPPSMDynamicStart = 0x1001, + kBluetoothL2CAPPSMD2D = 0x100F, + kBluetoothL2CAPPSMDynamicEnd = 0xFFFF, + + kBluetoothL2CAPPSMNone = 0x0000 +}; + + +#pragma mark - +#pragma mark === SDP === + +//=========================================================================================================================== +// Service Discovery Protocol +//=========================================================================================================================== + +enum +{ + // General + + kBluetoothSDPUUID16Base = 0x0000, // 00000000-0000-1000-8000-00805f9b34fb + + // Protocols + + kBluetoothSDPUUID16SDP = 0x0001, // 00000001-0000-1000-8000-00805f9b34fb + kBluetoothSDPUUID16UDP = 0x0002, // 00000002-0000-1000-8000-00805f9b34fb + kBluetoothSDPUUID16RFCOMM = 0x0003, // 00000003-0000-1000-8000-00805f9b34fb + kBluetoothSDPUUID16TCP = 0x0004, // 00000004-0000-1000-8000-00805f9b34fb + kBluetoothSDPUUID16TCSBIN = 0x0005, // 00000005-0000-1000-8000-00805f9b34fb + kBluetoothSDPUUID16TCSAT = 0x0006, // 00000006-0000-1000-8000-00805f9b34fb + kBluetoothSDPUUID16OBEX = 0x0008, // 00000008-0000-1000-8000-00805f9b34fb + kBluetoothSDPUUID16IP = 0x0009, // 00000009-0000-1000-8000-00805f9b34fb + kBluetoothSDPUUID16FTP = 0x000A, // 0000000A-0000-1000-8000-00805f9b34fb + kBluetoothSDPUUID16HTTP = 0x000C, // 0000000C-0000-1000-8000-00805f9b34fb + kBluetoothSDPUUID16WSP = 0x000E, // 0000000E-0000-1000-8000-00805f9b34fb + kBluetoothSDPUUID16BNEP = 0x000F, + kBluetoothSDPUUID16UPNP = 0x0010, + kBluetoothSDPUUID16HIDP = 0x0011, + kBluetoothSDPUUID16HardcopyControlChannel = 0x0012, + kBluetoothSDPUUID16HardcopyDataChannel = 0x0014, + kBluetoothSDPUUID16HardcopyNotification = 0x0016, + kBluetoothSDPUUID16AVCTP = 0x0017, + kBluetoothSDPUUID16AVDTP = 0x0019, + kBluetoothSDPUUID16CMPT = 0x001B, + kBluetoothSDPUUID16UDI_C_Plane = 0x001D, + kBluetoothSDPUUID16L2CAP = 0x0100, // 00000100-0000-1000-8000-00805f9b34fb +}; + +enum SDPServiceClasses +{ + kBluetoothSDPUUID16ServiceClassServiceDiscoveryServer = 0x1000, // 00001000-0000-1000-8000-00805f9b34fb + kBluetoothSDPUUID16ServiceClassBrowseGroupDescriptor = 0x1001, // 00001001-0000-1000-8000-00805f9b34fb + kBluetoothSDPUUID16ServiceClassPublicBrowseGroup = 0x1002, // 00001002-0000-1000-8000-00805f9b34fb + kBluetoothSDPUUID16ServiceClassSerialPort = 0x1101, // 00001101-0000-1000-8000-00805f9b34fb + kBluetoothSDPUUID16ServiceClassLANAccessUsingPPP = 0x1102, // 00001102-0000-1000-8000-00805f9b34fb + kBluetoothSDPUUID16ServiceClassDialupNetworking = 0x1103, // 00001103-0000-1000-8000-00805f9b34fb + kBluetoothSDPUUID16ServiceClassIrMCSync = 0x1104, // 00001104-0000-1000-8000-00805f9b34fb + kBluetoothSDPUUID16ServiceClassOBEXObjectPush = 0x1105, // 00001105-0000-1000-8000-00805f9b34fb + kBluetoothSDPUUID16ServiceClassOBEXFileTransfer = 0x1106, // 00001106-0000-1000-8000-00805f9b34fb + kBluetoothSDPUUID16ServiceClassIrMCSyncCommand = 0x1107, // 00001107-0000-1000-8000-00805f9b34fb + kBluetoothSDPUUID16ServiceClassHeadset = 0x1108, // 00001108-0000-1000-8000-00805f9b34fb + kBluetoothSDPUUID16ServiceClassCordlessTelephony = 0x1109, // 00001109-0000-1000-8000-00805f9b34fb + kBluetoothSDPUUID16ServiceClassAudioSource = 0x110A, + kBluetoothSDPUUID16ServiceClassAudioSink = 0x110B, + kBluetoothSDPUUID16ServiceClassAVRemoteControlTarget = 0x110C, + kBluetoothSDPUUID16ServiceClassAdvancedAudioDistribution = 0x110D, + kBluetoothSDPUUID16ServiceClassAVRemoteControl = 0x110E, + kBluetoothSDPUUID16ServiceClassVideoConferencing = 0x110F, + kBluetoothSDPUUID16ServiceClassIntercom = 0x1110, // 00001110-0000-1000-8000-00805f9b34fb + kBluetoothSDPUUID16ServiceClassFax = 0x1111, // 00001111-0000-1000-8000-00805f9b34fb + kBluetoothSDPUUID16ServiceClassHeadsetAudioGateway = 0x1112, // 00001112-0000-1000-8000-00805f9b34fb + kBluetoothSDPUUID16ServiceClassWAP = 0x1113, + kBluetoothSDPUUID16ServiceClassWAPClient = 0x1114, + kBluetoothSDPUUID16ServiceClassPANU = 0x1115, + kBluetoothSDPUUID16ServiceClassNAP = 0x1116, + kBluetoothSDPUUID16ServiceClassGN = 0x1117, + kBluetoothSDPUUID16ServiceClassDirectPrinting = 0x1118, + kBluetoothSDPUUID16ServiceClassReferencePrinting = 0x1119, + kBluetoothSDPUUID16ServiceClassImaging = 0x111A, + kBluetoothSDPUUID16ServiceClassImagingResponder = 0x111B, + kBluetoothSDPUUID16ServiceClassImagingAutomaticArchive = 0x111C, + kBluetoothSDPUUID16ServiceClassImagingReferencedObjects = 0x111D, + kBluetoothSDPUUID16ServiceClassHandsFree = 0x111E, + kBluetoothSDPUUID16ServiceClassHandsFreeAudioGateway = 0x111F, + kBluetoothSDPUUID16ServiceClassDirectPrintingReferenceObjectsService = 0x1120, + kBluetoothSDPUUID16ServiceClassReflectedUI = 0x1121, + kBluetoothSDPUUID16ServiceClassBasicPrinting = 0x1122, + kBluetoothSDPUUID16ServiceClassPrintingStatus = 0x1123, + kBluetoothSDPUUID16ServiceClassHumanInterfaceDeviceService = 0x1124, + kBluetoothSDPUUID16ServiceClassHardcopyCableReplacement = 0x1125, + kBluetoothSDPUUID16ServiceClassHCR_Print = 0x1126, + kBluetoothSDPUUID16ServiceClassHCR_Scan = 0x1127, + kBluetoothSDPUUID16ServiceClassCommonISDNAccess = 0x1128, + kBluetoothSDPUUID16ServiceClassVideoConferencingGW = 0x1129, + kBluetoothSDPUUID16ServiceClassUDI_MT = 0x112A, + kBluetoothSDPUUID16ServiceClassUDI_TA = 0x112B, + kBluetoothSDPUUID16ServiceClassAudioVideo = 0x112C, + kBluetoothSDPUUID16ServiceClassSIM_Access = 0x112D, + kBluetoothSDPUUID16ServiceClassPhonebookAccess_PCE = 0x112E, + kBluetoothSDPUUID16ServiceClassPhonebookAccess_PSE = 0x112F, + kBluetoothSDPUUID16ServiceClassPhonebookAccess = 0x1130, + kBluetoothSDPUUID16ServiceClassHeadset_HS = 0x1131, + kBluetoothSDPUUID16ServiceClassMessageAccessServer = 0x1132, + kBluetoothSDPUUID16ServiceClassMessageNotificationServer = 0x1133, + kBluetoothSDPUUID16ServiceClassMessageAccessProfile = 0x1134, + kBluetoothSDPUUID16ServiceClassPnPInformation = 0x1200, // 00001200-0000-1000-8000-00805f9b34fb + kBluetoothSDPUUID16ServiceClassGenericNetworking = 0x1201, // 00001201-0000-1000-8000-00805f9b34fb + kBluetoothSDPUUID16ServiceClassGenericFileTransfer = 0x1202, // 00001202-0000-1000-8000-00805f9b34fb + kBluetoothSDPUUID16ServiceClassGenericAudio = 0x1203, // 00001203-0000-1000-8000-00805f9b34fb + kBluetoothSDPUUID16ServiceClassGenericTelephony = 0x1204 // 00001204-0000-1000-8000-00805f9b34fb +}; + +enum SDPAttributeIdentifierCodes +{ + kBluetoothSDPAttributeIdentifierServiceRecordHandle = 0x0000, + kBluetoothSDPAttributeIdentifierServiceClassIDList = 0x0001, + kBluetoothSDPAttributeIdentifierServiceRecordState = 0x0002, + kBluetoothSDPAttributeIdentifierServiceID = 0x0003, + kBluetoothSDPAttributeIdentifierProtocolDescriptorList = 0x0004, + kBluetoothSDPAttributeIdentifierBrowseGroupList = 0x0005, + kBluetoothSDPAttributeIdentifierLanguageBaseAttributeIDList = 0x0006, + kBluetoothSDPAttributeIdentifierServiceInfoTimeToLive = 0x0007, + kBluetoothSDPAttributeIdentifierServiceAvailability = 0x0008, + kBluetoothSDPAttributeIdentifierBluetoothProfileDescriptorList = 0x0009, + kBluetoothSDPAttributeIdentifierDocumentationURL = 0x000A, + kBluetoothSDPAttributeIdentifierClientExecutableURL = 0x000B, + kBluetoothSDPAttributeIdentifierIconURL = 0x000C, + kBluetoothSDPAttributeIdentifierAdditionalProtocolsDescriptorList = 0x000D, + + // Service Discovery Server + kBluetoothSDPAttributeIdentifierVersionNumberList = 0x0200, + kBluetoothSDPAttributeIdentifierServiceDatabaseState = 0x0201, + + // Browse Group Descriptor + kBluetoothSDPAttributeIdentifierGroupID = 0x0200, + + // PAN + kBluetoothSDPAttributeIdentifierIPSubnet = 0x0200, + +#if BLUETOOTH_VERSION_MAX_ALLOWED >= BLUETOOTH_VERSION_2_1_1 + + // HID Required Type Section Notes + kBluetoothSDPAttributeIdentifierHIDReleaseNumber = 0x0200, // O uint16 7.11.1 + kBluetoothSDPAttributeIdentifierHIDParserVersion = 0x0201, // M uint16 - + kBluetoothSDPAttributeIdentifierHIDDeviceSubclass = 0x0202, // M uint8 7.11.2 Should match the low order 8 bits of CoD unless a combo device + kBluetoothSDPAttributeIdentifierHIDCountryCode = 0x0203, // M uint8 7.11.3 + kBluetoothSDPAttributeIdentifierHIDVirtualCable = 0x0204, // M bool 7.11.4 + kBluetoothSDPAttributeIdentifierHIDReconnectInitiate = 0x0205, // M bool 7.11.5 + kBluetoothSDPAttributeIdentifierHIDDescriptorList = 0x0206, // M sequence 7.11.6 Layout is defined in Section 6.2 of the HID Specification + kBluetoothSDPAttributeIdentifierHIDLangIDBaseList = 0x0207, // M sequence 7.11.7 + kBluetoothSDPAttributeIdentifierHIDSDPDisable = 0x0208, // O bool 7.11.8 + kBluetoothSDPAttributeIdentifierHIDBatteryPower = 0x0209, // O bool 7.11.9 + kBluetoothSDPAttributeIdentifierHIDRemoteWake = 0x020A, // O bool 7.11.10 + kBluetoothSDPAttributeIdentifierHIDProfileVersion = 0x020B, // M uint16 7.11.14 + kBluetoothSDPAttributeIdentifierHIDSupervisionTimeout = 0x020C, // O uint16 7.11.12 Default to 5 seconds or longer if not defined + kBluetoothSDPAttributeIdentifierHIDNormallyConnectable = 0x020D, // O bool 7.11.13 + kBluetoothSDPAttributeIdentifierHIDBootDevice = 0x020E, // M bool 7.11.11 Only defined for mice and keyboards as of HID 1.0 + +#endif + + kBluetoothSDPAttributeIdentifierServiceVersion = 0x0300, + kBluetoothSDPAttributeIdentifierExternalNetwork = 0x0301, // Cordless telephony + kBluetoothSDPAttributeIdentifierNetwork = 0x0301, // Handsfree Profile (HFP) + kBluetoothSDPAttributeIdentifierSupportedDataStoresList = 0x0301, // Sync Profile + kBluetoothSDPAttributeIdentifierFaxClass1Support = 0x0302, // Fax Profile + kBluetoothSDPAttributeIdentifierRemoteAudioVolumeControl = 0x0302, // GAP??? + kBluetoothSDPAttributeIdentifierFaxClass2_0Support = 0x0303, + kBluetoothSDPAttributeIdentifierSupporterFormatsList = 0x0303, + kBluetoothSDPAttributeIdentifierFaxClass2Support = 0x0304, + kBluetoothSDPAttributeIdentifierAudioFeedbackSupport = 0x0305, + kBluetoothSDPAttributeIdentifierNetworkAddress = 0x0306, // WAP + kBluetoothSDPAttributeIdentifierWAPGateway = 0x0307, // WAP + kBluetoothSDPAttributeIdentifierHomepageURL = 0x0308, // WAP + kBluetoothSDPAttributeIdentifierWAPStackType = 0x0309, // WAP + kBluetoothSDPAttributeIdentifierSecurityDescription = 0x030A, // PAN + kBluetoothSDPAttributeIdentifierNetAccessType = 0x030B, // PAN + kBluetoothSDPAttributeIdentifierMaxNetAccessRate = 0x030C, // PAN + kBluetoothSDPAttributeIdentifierSupportedCapabilities = 0x0310, // Imaging + kBluetoothSDPAttributeIdentifierSupportedFeatures = 0x0311, // Imaging & HFP + kBluetoothSDPAttributeIdentifierSupportedFunctions = 0x0312, // Imaging + kBluetoothSDPAttributeIdentifierTotalImagingDataCapacity = 0x0313, // Imaging + + kBluetoothSDPAttributeIdentifierServiceName = 0x0000, /* +language base offset*/ + kBluetoothSDPAttributeIdentifierServiceDescription = 0x0001, /* +language base offset*/ + kBluetoothSDPAttributeIdentifierProviderName = 0x0002 /* +language base offset*/ +}; + +enum SDPAttributeDeviceIdentificationRecord +{ + /* Values taken from the Bluetooth Device Identification specification, 1.0 draft, 1.16.2003 */ + + kBluetoothSDPAttributeDeviceIdentifierServiceDescription = 0x0001, /* String */ + kBluetoothSDPAttributeDeviceIdentifierDocumentationURL = 0x000A, /* URL */ + kBluetoothSDPAttributeDeviceIdentifierClientExecutableURL = 0x000B, /* URL */ + kBluetoothSDPAttributeDeviceIdentifierSpecificationID = 0x0200, /* 2 byte unsigned integer */ + kBluetoothSDPAttributeDeviceIdentifierVendorID = 0x0201, /* 2 byte unsigned integer */ + kBluetoothSDPAttributeDeviceIdentifierProductID = 0x0202, /* 2 byte unsigned integer */ + kBluetoothSDPAttributeDeviceIdentifierVersion = 0x0203, /* 2 byte unsigned integer */ + kBluetoothSDPAttributeDeviceIdentifierPrimaryRecord = 0x0204, /* Boolean */ + kBluetoothSDPAttributeDeviceIdentifierVendorIDSource = 0x0205, /* 2 byte unsigned integer */ + kBluetoothSDPAttributeDeviceIdentifierReservedRangeStart = 0x0206, + kBluetoothSDPAttributeDeviceIdentifierReservedRangeEnd = 0x02FF + +}; + +enum ProtocolParameters +{ + kBluetoothSDPProtocolParameterL2CAPPSM = 1, + kBluetoothSDPProtocolParameterRFCOMMChannel = 1, + kBluetoothSDPProtocolParameterTCPPort = 1, + kBluetoothSDPProtocolParameterUDPPort = 1, + kBluetoothSDPProtocolParameterBNEPVersion = 1, + kBluetoothSDPProtocolParameterBNEPSupportedNetworkPacketTypeList = 2 +}; + +#if BLUETOOTH_VERSION_MAX_ALLOWED >= BLUETOOTH_VERSION_2_0 + +//Inquiries with 'Extended Inquiry Response' (v2.1 specification) + +enum BluetoothHCIExtendedInquiryResponseDataTypes +{ + kBluetoothHCIExtendedInquiryResponseDataTypeFlags = 0x01, + kBluetoothHCIExtendedInquiryResponseDataType16BitServiceClassUUIDsWithMoreAvailable = 0x02, + kBluetoothHCIExtendedInquiryResponseDataType16BitServiceClassUUIDsCompleteList = 0x03, + kBluetoothHCIExtendedInquiryResponseDataType32BitServiceClassUUIDsWithMoreAvailable = 0x04, + kBluetoothHCIExtendedInquiryResponseDataType32BitServiceClassUUIDsCompleteList = 0x05, + kBluetoothHCIExtendedInquiryResponseDataType128BitServiceClassUUIDsWithMoreAvailable = 0x06, + kBluetoothHCIExtendedInquiryResponseDataType128BitServiceClassUUIDsCompleteList = 0x07, + kBluetoothHCIExtendedInquiryResponseDataTypeShortenedLocalName = 0x08, + kBluetoothHCIExtendedInquiryResponseDataTypeCompleteLocalName = 0x09, + kBluetoothHCIExtendedInquiryResponseDataTypeDeviceID = 0x10, + kBluetoothHCIExtendedInquiryResponseDataTypeManufacturerSpecificData = 0xFF +}; + +#endif /* BLUETOOTH_VERSION_MAX_ALLOWED >= BLUETOOTH_VERSION_2_0 */ + + +#ifdef __cplusplus + } +#endif Index: branches/azimutz/Cleancut/i386/include/IOKit/bluetooth/IOBluetoothTypes.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/bluetooth/IOBluetoothTypes.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/bluetooth/IOBluetoothTypes.h (revision 885) @@ -0,0 +1,23 @@ +/* + File: IOBluetoothTypes.h + Contains: Family provided types and defines - shared between user and kernel code. + Copyright: © 2002-2007 by Apple Inc. All rights reserved. +*/ + +#pragma once + +#include + +// Error returns +#ifndef sub_iokit_bluetooth +#define sub_iokit_bluetooth err_sub(8) +#endif + +#define iokit_bluetooth_err(return) (sys_iokit|sub_iokit_bluetooth|return) + +#define kIOBluetoothDeviceResetError iokit_bluetooth_err(1) // Device reset interrupted pending operation +#define kIOBluetoothConnectionAlreadyExists iokit_bluetooth_err(2) // Attempting to open a connection that already exists +#define kIOBluetoothNoHCIController iokit_bluetooth_err(3) // No HCI controller is present +#define kIOBluetoothHCIPowerStatesNotSupported iokit_bluetooth_err(4) // HCI controller does not support changing power states + + Index: branches/azimutz/Cleancut/i386/include/IOKit/bluetooth/IOBluetoothHIDDriverTypes.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/bluetooth/IOBluetoothHIDDriverTypes.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/bluetooth/IOBluetoothHIDDriverTypes.h (revision 885) @@ -0,0 +1,61 @@ +/* + File: IOBluetoothHIDDriverTypes.h + Contains: Type defined for the IOBluetoothHIDDriver.h. + Copyright: (c) 2001-2008 by Apple, all rights reserved. +*/ + + +#ifndef IOBLUETOOTHHIDDRIVERTYPES_H +#define IOBLUETOOTHHIDDRIVERTYPES_H + +// Vendor ID Sources +//------------------ +#define kVendorIDSourceBluetoothSIG 0x1 +#define kVendorIDSourceUSBIF 0x2 + +// Bluetooth HID Transaction Headers +//---------------------------------- +#define IOBTHID_HANDSHAKE_HEADER 0x00 +#define IOBTHID_HID_CONTROL_HEADER 0x10 +#define IOBTHID_GET_REPORT_HEADER 0x40 +#define IOBTHID_SET_REPORT_HEADER 0x50 +#define IOBTHID_GET_PROTOCOL_HEADER 0x60 +#define IOBTHID_SET_PROTOCOL_HEADER 0x70 +#define IOBTHID_GET_IDLE_HEADER 0x80 +#define IOBTHID_SET_IDLE_HEADER 0x90 +#define IOBTHID_DATA_HEADER 0xA0 +#define IOBTHID_DATC_HEADER 0xB0 + +// Handshake Types +//---------------- +#define IOBTHID_HANDSHAKE_SUCCESSFUL 0x0 +#define IOBTHID_HANDSHAKE_NOT_READY 0x1 +#define IOBTHID_HANDSHAKE_INVALID_REPORT_ID 0x2 +#define IOBTHID_HANDSHAKE_UNSUPPORTED_REQUEST 0x3 +#define IOBTHID_HANDSHAKE_INVALID_PARAMETER 0x4 +#define IOBTHID_HANDSHAKE_ERR_UNKNOWN 0xE +#define IOBTHID_HANDSHAKE_ERR_FATAL 0xF + +// HID_Control Types +//------------------ +#define IOBTHID_CONTROL_NOP 0x0 +#define IOBTHID_CONTROL_HARD_RESET 0x1 +#define IOBTHID_CONTROL_SOFT_RESET 0x2 +#define IOBTHID_CONTROL_SUSPEND 0x3 +#define IOBTHID_CONTROL_EXIT_SUSPEND 0x4 +#define IOBTHID_CONTROL_VC_UNPLUG 0x5 + +// Protocol Types +//--------------- +#define IOBTHID_BOOT_PROTOCOL 0x0 +#define IOBTHID_REPORT_PROTOCOL 0x1 + +// Report Types +//------------- +#define IOBTHID_RESERVED_REPORT 0x0 +#define IOBTHID_OTHER_REPORT 0x0 +#define IOBTHID_INPUT_REPORT 0x1 +#define IOBTHID_OUTPUT_REPORT 0x2 +#define IOBTHID_FEATURE_REPORT 0x3 + +#endif // IOBLUETOOTHHIDDRIVERTYPES_H Index: branches/azimutz/Cleancut/i386/include/IOKit/bluetooth/Bluetooth.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/bluetooth/Bluetooth.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/bluetooth/Bluetooth.h (revision 885) @@ -0,0 +1,2158 @@ +/* + File: Bluetooth.h + Contains: Public interfaces for Bluetooth technology. + Copyright: (c) 2002-2007 by Apple Inc. All rights reserved. +*/ + +#pragma once + +#ifdef KERNEL +#include +#else +#include +#include +#endif + +#include +#include + +//--------------------------------------------------------------------------------------------------------------------------- +/*! @header Bluetooth + Bluetooth wireless technology +*/ + +#ifdef __cplusplus + extern "C" { +#endif + + +#if 0 + +#pragma mark === Baseband === +#endif + +//=========================================================================================================================== +// Baseband +//=========================================================================================================================== + +typedef UInt16 BluetoothConnectionHandle; // Upper 4 bits are reserved. +typedef uint8_t BluetoothLMPHandle; +enum +{ + kBluetoothConnectionHandleNone = 0xffff +}; + +typedef UInt8 BluetoothReasonCode; +typedef UInt8 BluetoothEncryptionEnable; +enum +{ + kBluetoothEncryptionEnableOff = 0x00, + kBluetoothEncryptionEnableOn = 0x01 +}; + +typedef UInt8 BluetoothKeyFlag; +enum +{ + kBluetoothKeyFlagSemiPermanent = 0x00, + kBluetoothKeyFlagTemporary = 0x01 +}; + +typedef UInt8 BluetoothKeyType; +enum +{ + kBluetoothKeyTypeCombination = 0x00, + kBluetoothKeyTypeLocalUnit = 0x01, + kBluetoothKeyTypeRemoteUnit = 0x02, + kBluetoothKeyTypeDebugCombination = 0x03, + kBluetoothKeyTypeUnauthenticatedCombination = 0x04, + kBluetoothKeyTypeAuthenticatedCombination = 0x05, + kBluetoothKeyTypeChangedCombination = 0x06, +}; + +// Packet types (Bluetooth spec section 7.1.5 - Create Connection) + +typedef UInt16 BluetoothPacketType; +enum +{ + kBluetoothPacketTypeReserved1 = 0x0001, + kBluetoothPacketType2DH1Omit = 0x0002, // Masks OUT this packet type + kBluetoothPacketType3DH1Omit = 0x0004, // Masks OUT this packet type + + kBluetoothPacketTypeDM1 = 0x0008, + kBluetoothPacketTypeDH1 = 0x0010, + kBluetoothPacketTypeHV1 = 0x0020, // Reserved + kBluetoothPacketTypeHV2 = 0x0040, // Reserved + kBluetoothPacketTypeHV3 = 0x0080, // Reserved + kBluetoothPacketTypeDV = 0x0100, // Reserved + kBluetoothPacketType2DH3Omit = 0x0100, // Masks OUT this packet type + kBluetoothPacketType3DH3Omit = 0x0200, // Masks OUT this packet type + kBluetoothPacketTypeAUX = 0x0200, // Deprecated + + kBluetoothPacketTypeDM3 = 0x0400, + kBluetoothPacketTypeDH3 = 0x0800, + + kBluetoothPacketType2DH5Omit = 0x1000, // Masks OUT this packet type + kBluetoothPacketType3DM5Omit = 0x2000, // Masks OUT this packet type + + kBluetoothPacketTypeDM5 = 0x4000, + kBluetoothPacketTypeDH5 = 0x8000, + + kBluetoothPacketTypeEnd +}; + +// Setup Synchronous Packet types (Bluetooth 2.1 spec section 7.1.26 - Setup Synchronous Command) + +enum +{ + kBluetoothSynchronousConnectionPacketTypeHV1 = 0x0001, + kBluetoothSynchronousConnectionPacketTypeHV2 = 0x0002, + kBluetoothSynchronousConnectionPacketTypeHV3 = 0x0004, + kBluetoothSynchronousConnectionPacketTypeEV3 = 0x0008, + kBluetoothSynchronousConnectionPacketTypeEV4 = 0x0010, + kBluetoothSynchronousConnectionPacketTypeEV5 = 0x0020, + + // masking out certain types: + + kBluetoothSynchronousConnectionPacketType2EV3Omit = 0x0040, + kBluetoothSynchronousConnectionPacketType3EV3Omit = 0x0080, + kBluetoothSynchronousConnectionPacketType2EV5Omit = 0x0100, + kBluetoothSynchronousConnectionPacketType3EV5Omit = 0x0200, + + kBluetoothSynchronousConnectionPacketTypeAll = 0xFFFF, + + kBluetoothSynchronousConnectionPacketTypeEnd +}; + + +// LAP/Inquiry Access Codes + +typedef UInt32 BluetoothLAP; +enum +{ + kBluetoothGeneralInquiryAccessCodeIndex = 0, // General/Unlimited Inquiry Access Code (GIAC) + kBluetoothGeneralInquiryAccessCodeLAPValue = 0x9E8B33, // General/Unlimited Inquiry Access Code (GIAC) + + kBluetoothLimitedInquiryAccessCodeIndex = 1, // Limited Dedicated Inquiry Access Code (LIAC) + kBluetoothLimitedInquiryAccessCodeLAPValue = 0x9E8B00, // Limited Dedicated Inquiry Access Code (LIAC) + + // All other access codes are reserved for future use (indices 2-63, LAP values 0x9E8B01-0x9E8B32 and 0x9E8B34-0x9E8B3F). + + kBluetoothLimitedInquiryAccessCodeEnd +}; + +// PageScanRepetitionMode + +typedef UInt8 BluetoothPageScanRepetitionMode; +enum +{ + kBluetoothPageScanRepetitionModeR0 = 0x00, + kBluetoothPageScanRepetitionModeR1 = 0x01, + kBluetoothPageScanRepetitionModeR2 = 0x02 + + // All other values are reserved for future use. +}; + +// PageScanPeriodMode + +typedef UInt8 BluetoothPageScanPeriodMode; +enum +{ + kBluetoothPageScanPeriodModeP0 = 0x00, + kBluetoothPageScanPeriodModeP1 = 0x01, + kBluetoothPageScanPeriodModeP2 = 0x02 + + // All other values are reserved for future use. +}; + +// PageScanMode + +typedef UInt8 BluetoothPageScanMode; +enum +{ + kBluetoothPageScanModeMandatory = 0x00, + kBluetoothPageScanModeOptional1 = 0x01, + kBluetoothPageScanModeOptional2 = 0x02, + kBluetoothPageScanModeOptional3 = 0x03 + + // All other values are reserved for future use. +}; + +#if 0 +#pragma mark - +#pragma mark === Devices === +#endif + +typedef struct BluetoothDeviceAddress BluetoothDeviceAddress; +struct BluetoothDeviceAddress +{ + UInt8 data[ 6 ]; +}; + +typedef struct BluetoothKey BluetoothKey; +struct BluetoothKey +{ + UInt8 data[ 16 ]; +}; + +typedef struct BluetoothPINCode BluetoothPINCode; +struct BluetoothPINCode +{ + UInt8 data[ 16 ]; // PIN codes may be up to 128 bits. +}; + + +// Physical layout of the "class of device/service" field (see Bluetooth Assigned Numbers section 1.2): +// +// 2 2 2 2 1 1 1 1 1 1 1 1 1 1 +// 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 <- Bit Transmission Order +// +---------------+---------------+---------------+ +// | octet 3 | octet 2 | octet 1 | <- Octet Transmission Order +// +---------------+---------------+---------------+ +// <------ 11 bits ----->< 5 bits ><- 6 bits -> +// +---------------------+---------+-----------+-+-+ +// | Service Classes | Major | Minor | | | +// +-+-+-+-+-+-+-+-+-+-+-+ Device | Device |0|0| +// | | | | | | | |*|*|*| | Class | Class | | | +// +-+-+-+-+-+-+-+-+-+-+-+---------+-----------+-+-+ +// | | | | | | | | | +// | | | | | | | + Limited Discoverable +- Format Type +// | | | | | | +- Networking +// | | | | | +- Rendering +// | | | | +- Capturing +// | | | +- Object Transfer +// | | +- Audio +// | +- Telephony +// +- Information + +typedef UInt32 BluetoothClassOfDevice; + +#define BluetoothGetDeviceClassMajor( inCOD ) ( (inCOD & 0x00001F00) >> 8 ) +#define BluetoothGetDeviceClassMinor( inCOD ) ( (inCOD & 0x000000FC) >> 2 ) +#define BluetoothGetServiceClassMajor( inCOD ) ( (inCOD & 0x00FFE000) >> 13 ) +#define BluetoothMakeClassOfDevice( inServiceClassMajor, inDeviceClassMajor, inDeviceClassMinor ) \ + (((inServiceClassMajor << 13) & 0x00FFE000) | ((inDeviceClassMajor << 8) & 0x00001F00) | ((inDeviceClassMinor << 2) & 0x000000FC)) + +/// +/// Major Service Classes (11-bit value - bits 13-23 of Device/Service field) +/// + +typedef UInt32 BluetoothServiceClassMajor; +// Service Class Major enum in BluetoothAssignedNumbers.h + +/// +/// Major Device Classes (5-bit value - bits 8-12 of Device/Service field) +/// + +typedef UInt32 BluetoothDeviceClassMajor; +// Device Class Major enum in BluetoothAssignedNumbers.h + +/// +/// Minor Device Classes (6-bit value - bits 2-7 of Device/Service field) +/// + +typedef UInt32 BluetoothDeviceClassMinor; +// Device Class Minor enum in BluetoothAssignedNumbers.h + +// Misc Device Types + +enum +{ + kBluetoothDeviceNameMaxLength = 248 +}; +typedef UInt8 BluetoothDeviceName[ 256 ]; // Max 248 bytes of UTF-8 encoded Unicode. +typedef UInt16 BluetoothClockOffset; // Bits 14-0 come from bits 16-2 of CLKslav-CLKmaster. +typedef UInt8 BluetoothRole; // +typedef UInt8 BluetoothAllowRoleSwitch; // 0x00-0x01 valid, 0x02-0xFF reserved. +enum +{ + kBluetoothDontAllowRoleSwitch = 0x00, + kBluetoothAllowRoleSwitch = 0x01 +}; + +enum +{ + kBluetoothRoleBecomeMaster = 0x00, + kBluetoothRoleRemainSlave = 0x01 +}; + +typedef struct BluetoothSetEventMask BluetoothSetEventMask; +struct BluetoothSetEventMask +{ + UInt8 data[ 8 ]; +}; + +typedef UInt8 BluetoothPINType; + + +#if 0 +#pragma mark - +#pragma mark === L2CAP === +#endif + +//=========================================================================================================================== +// Logical Link Control and Adaptation Protocol (L2CAP) +//=========================================================================================================================== + + +// ACL Packet values (Bluetooth L2CAP spec section 1). + +enum +{ + kBluetoothL2CAPMaxPacketSize = 65535, // Max number of data bytes in an L2CAP packet. + + kBluetoothACLLogicalChannelReserved = 0, // [00] Reserved for future use + kBluetoothACLLogicalChannelL2CAPContinue = 1, // [01] Continuation of L2CAP packet. + kBluetoothACLLogicalChannelL2CAPStart = 2, // [10] Start of L2CAP packet. + kBluetoothACLLogicalChannelLMP = 3 // [11] Link Manager Protocol packet. +}; + +// Channel Identifiers (Bluetooth L2CAP spec section 2.1). + +typedef UInt16 BluetoothL2CAPChannelID; +enum +{ + kBluetoothL2CAPChannelNull = 0x0000, // Illegal, should not be used + kBluetoothL2CAPChannelSignalling = 0x0001, // L2CAP signalling channel + kBluetoothL2CAPChannelConnectionLessData = 0x0002, // L2CAP connection less data + kBluetoothL2CAPChannelAMPManagerProtocol = 0x0003, // AMP Manager Protocol + + // Range 0x0003 to 0x003F reserved for future use. + kBluetoothL2CAPChannelReservedStart = 0x0004, + kBluetoothL2CAPChannelReservedEnd = 0x003F, + + // Range 0x0040 to 0xFFFF are dynamically allocated. + kBluetoothL2CAPChannelDynamicStart = 0x0040, + kBluetoothL2CAPChannelDynamicEnd = 0xffff, + kBluetoothL2CAPChannelEnd = 0xffff +}; + +typedef BluetoothL2CAPChannelID BluetoothL2CAPGroupID; + +// Protocol/Service Multiplexor (PSM) values (Bluetooth L2CAP spec section 5.2). + +typedef UInt16 BluetoothL2CAPPSM; +// PSM enum in BluetoothAssignedNumbers.h + +// Command Codes + +typedef enum +{ + kBluetoothL2CAPCommandCodeReserved = 0x00, + kBluetoothL2CAPCommandCodeCommandReject = 0x01, + kBluetoothL2CAPCommandCodeConnectionRequest = 0x02, + kBluetoothL2CAPCommandCodeConnectionResponse = 0x03, + kBluetoothL2CAPCommandCodeConfigureRequest = 0x04, + kBluetoothL2CAPCommandCodeConfigureResponse = 0x05, + kBluetoothL2CAPCommandCodeDisconnectionRequest = 0x06, + kBluetoothL2CAPCommandCodeDisconnectionResponse = 0x07, + kBluetoothL2CAPCommandCodeEchoRequest = 0x08, + kBluetoothL2CAPCommandCodeEchoResponse = 0x09, + kBluetoothL2CAPCommandCodeInformationRequest = 0x0A, + kBluetoothL2CAPCommandCodeInformationResponse = 0x0B, + kBluetoothL2CAPCommandCodeCreateChannelRequest = 0x0C, + kBluetoothL2CAPCommandCodeCreateChannelResponse = 0x0D, + kBluetoothL2CAPCommandCodeMoveChannelRequest = 0x0E, + kBluetoothL2CAPCommandCodeMoveChannelResponse = 0x0F, + kBluetoothL2CAPCommandCodeMoveChannelConfirmation = 0x10, + kBluetoothL2CAPCommandCodeMoveChannelConfirmationResponse = 0x11, +} BluetoothL2CAPCommandCode; + +// Command Reject + +typedef enum +{ + kBluetoothL2CAPCommandRejectReasonCommandNotUnderstood = 0x0000, + kBluetoothL2CAPCommandRejectReasonSignallingMTUExceeded = 0x0001, + kBluetoothL2CAPCommandRejectReasonInvalidCIDInRequest = 0x0002, +} BluetoothL2CAPCommandRejectReason; + +typedef UInt16 BluetoothL2CAPMTU; +typedef UInt16 BluetoothL2CAPLinkTimeout; +typedef UInt16 BluetoothL2CAPFlushTimeout; +enum +{ + kBluetoothL2CAPFlushTimeoutUseExisting = 0x0000, + kBluetoothL2CAPFlushTimeoutImmediate = 0x0001, + kBluetoothL2CAPFlushTimeoutForever = 0xFFFF, + + kBluetoothL2CAPFlushTimeoutEnd +}; + +typedef struct BluetoothL2CAPQualityOfServiceOptions BluetoothL2CAPQualityOfServiceOptions; +struct BluetoothL2CAPQualityOfServiceOptions +{ + UInt8 flags; + UInt8 serviceType; + UInt32 tokenRate; + UInt32 tokenBucketSize; + UInt32 peakBandwidth; + UInt32 latency; + UInt32 delayVariation; +}; + +typedef struct BluetoothL2CAPRetransmissionAndFlowControlOptions BluetoothL2CAPRetransmissionAndFlowControlOptions; +struct BluetoothL2CAPRetransmissionAndFlowControlOptions +{ + UInt8 flags; + UInt8 txWindowSize; + UInt8 maxTransmit; + UInt16 retransmissionTimeout; + UInt16 monitorTimeout; + UInt16 maxPDUPayloadSize; +}; + +enum +{ + kBluetoothL2CAPInfoTypeMaxConnectionlessMTUSize = 0x0001 +}; + +// Packets + +enum +{ + kBluetoothL2CAPPacketHeaderSize = 4 +}; + +typedef UInt16 BluetoothL2CAPByteCount; +typedef UInt8 BluetoothL2CAPCommandID; +typedef UInt16 BluetoothL2CAPCommandByteCount; + +typedef enum +{ + kBluetoothL2CAPConnectionResultSuccessful = 0x0000, + kBluetoothL2CAPConnectionResultPending = 0x0001, + kBluetoothL2CAPConnectionResultRefusedPSMNotSupported = 0x0002, + kBluetoothL2CAPConnectionResultRefusedSecurityBlock = 0x0003, + kBluetoothL2CAPConnectionResultRefusedNoResources = 0x0004, +} BluetoothL2CAPConnectionResult; + +typedef enum +{ + kBluetoothL2CAPConnectionStatusNoInfoAvailable = 0x0000, + kBluetoothL2CAPConnectionStatusAuthenticationPending = 0x0001, + kBluetoothL2CAPConnectionStatusAuthorizationPending = 0x0002, +} BluetoothL2CAPConnectionStatus; + +typedef enum +{ + kBluetoothL2CAPConfigurationResultSuccess = 0x0000, + kBluetoothL2CAPConfigurationResultUnacceptableParams = 0x0001, + kBluetoothL2CAPConfigurationResultRejected = 0x0002, + kBluetoothL2CAPConfigurationResultUnknownOptions = 0x0003, +} BluetoothL2CAPConfigurationResult; + +typedef enum +{ + kBluetoothL2CAPConfigurationOptionMTU = 0x01, + kBluetoothL2CAPConfigurationOptionFlushTimeout = 0x02, + kBluetoothL2CAPConfigurationOptionQoS = 0x03, + kBluetoothL2CAPConfigurationOptionRetransmissionAndFlowControl = 0x04 +} BluetoothL2CAPConfigurationOption; + +enum +{ + kBluetoothL2CAPConfigurationOptionMTULength = 2, + kBluetoothL2CAPConfigurationOptionFlushTimeoutLength = 2, + kBluetoothL2CAPConfigurationOptionQoSLength = 22, + kBluetoothL2CAPConfigurationOptionRetransmissionAndFlowControlLength = 9 +}; + +typedef enum +{ + kBluetoothL2CAPConfigurationRetransmissionModeFlag = 0x01, + kBluetoothL2CAPConfigurationFlowControlModeFlag = 0x02, + kBluetoothL2CAPConfigurationBasicL2CAPModeFlag = 0x00, +} BluetoothL2CAPConfigurationRetransmissionAndFlowControlFlags; + + +typedef enum +{ + kBluetoothL2CAPInformationTypeConnectionlessMTU = 0x0001, + kBluetoothL2CAPInformationTypeExtendedFeatures = 0x0002, + kBluetoothL2CAPInformationTypeFixedChannelsSupported = 0x0003, +} BluetoothL2CAPInformationType; + +typedef enum +{ + kBluetoothL2CAPInformationResultSuccess = 0x0000, + kBluetoothL2CAPInformationResultNotSupported = 0x0001, +} BluetoothL2CAPInformationResult; + +typedef enum +{ + kBluetoothL2CAPInformationNoExtendedFeatures = 0x00000000, + kBluetoothL2CAPInformationFlowControlMode = 0x00000001, + kBluetoothL2CAPInformationRetransmissionMode = 0x00000002, + kBluetoothL2CAPInformationBidirectionalQoS = 0x00000004, + kBluetoothL2CAPInformationEnhancedRetransmissionMode = 0x00000008, + kBluetoothL2CAPInformationStreamingMode = 0x00000010, + kBluetoothL2CAPInformationFCSOption = 0x00000020, + kBluetoothL2CAPInformationExtendedFlowSpecification = 0x00000040, + kBluetoothL2CAPInformationFixedChannels = 0x00000080, + kBluetoothL2CAPInformationExtendedWindowSize = 0x00000100, + kBluetoothL2CAPUnicastConnectionlessDataReception = 0x00000200, +} BluetoothL2CAPInformationExtendedFeaturesMask; + +typedef enum +{ + kBluetoothL2CAPQoSTypeNoTraffic = 0x00, + kBluetoothL2CAPQoSTypeBestEffort = 0x01, + kBluetoothL2CAPQoSTypeGuaranteed = 0x02, +} BluetoothL2CAPQoSType; + +enum +{ + kBluetoothL2CAPMTUMinimum = 0x0030, // 48 bytes + kBluetoothL2CAPMTUDefault = 0x03F9, // 11.10.08 - dropped back to 1017 from 1021 (don't aggravate the 3DH5 problem between CSR<->BRCM just yet) + kBluetoothL2CAPMTUMaximum = 0xffff, + kBluetoothL2CAPMTUStart = 0x7fff, + kBluetoothL2CAPMTUSIG = 0x0030, // 48 bytes + kBluetoothL2CAPFlushTimeoutDefault = kBluetoothL2CAPFlushTimeoutForever, // 0xffff + kBluetoothL2CAPQoSFlagsDefault = 0, + kBluetoothL2CAPQoSTypeDefault = kBluetoothL2CAPQoSTypeBestEffort, // 0x01 + kBluetoothL2CAPQoSTokenRateDefault = 0x00000000, + kBluetoothL2CAPQoSTokenBucketSizeDefault = 0x00000000, + kBluetoothL2CAPQoSPeakBandwidthDefault = 0x00000000, + kBluetoothL2CAPQoSLatencyDefault = 0xffffffff, + kBluetoothL2CAPQoSDelayVariationDefault = 0xffffffff +}; + +#pragma mark === AMP Manager === +typedef enum { + kBluetoothAMPManagerCodeReserved = 0x00, + kBluetoothAMPManagerCodeAMPCommandReject = 0x01, + kBluetoothAMPManagerCodeAMPDiscoverRequest = 0x02, + kBluetoothAMPManagerCodeAMPDiscoverResponse = 0x03, + kBluetoothAMPManagerCodeAMPChangeNotify = 0x04, + kBluetoothAMPManagerCodeAMPChangeResponse = 0x05, + kBluetoothAMPManagerCodeAMPGetInfoRequest = 0x06, + kBluetoothAMPManagerCodeAMPGetInfoResponse = 0x07, + kBluetoothAMPManagerCodeAMPGetAssocRequest = 0x08, + kBluetoothAMPManagerCodeAMPGetAssocResponse = 0x09, + kBluetoothAMPManagerCodeAMPCreatePhysicalLinkRequest = 0x0A, + kBluetoothAMPManagerCodeAMPCreatePhysicalLinkResponse = 0x0B, + kBluetoothAMPManagerCodeAMPDisconnectPhysicalLinkRequest = 0x0C, + kBluetoothAMPManagerCodeAMPDisconnectPhysicalLinkResponse = 0x0D, +} BluetoothAMPManagerCode; + +typedef enum { + kBluetoothAMPManagerCommandRejectReasonCommandNotRecognized = 0x0000, +} BluetoothAMPCommandRejectReason; + +typedef enum { + kBluetoothAMPManagerDiscoverResponseControllerStatusPoweredDown = 0x00, + kBluetoothAMPManagerDiscoverResponseControllerStatusBluetoothOnly = 0x01, + kBluetoothAMPManagerDiscoverResponseControllerStatusNoCapacity = 0x02, + kBluetoothAMPManagerDiscoverResponseControllerStatusLowCapacity = 0x03, + kBluetoothAMPManagerDiscoverResponseControllerStatusMediumCapacity = 0x04, + kBluetoothAMPManagerDiscoverResponseControllerStatusHighCapacity = 0x05, + kBluetoothAMPManagerDiscoverResponseControllerStatusFullCapacity = 0x06, +} BluetoothAMPDiscoverResponseControllerStatus; + +typedef enum { + kBluetoothAMPManagerGetInfoResponseSuccess = 0x00, + kBluetoothAMPManagerGetInfoResponseInvalidControllerID = 0x01, +} BluetoothAMPGetInfoResponseStatus; + +typedef enum { + kBluetoothAMPManagerGetAssocResponseSuccess = 0x00, + kBluetoothAMPManagerGetAssocResponseInvalidControllerID = 0x01, +} BluetoothAMPGetAssocResponseStatus; + +typedef enum { + kBluetoothAMPManagerCreatePhysicalLinkResponseSuccess = 0x00, + kBluetoothAMPManagerCreatePhysicalLinkResponseInvalidControllerID = 0x01, + kBluetoothAMPManagerCreatePhysicalLinkResponseUnableToStartLinkCreation = 0x02, + kBluetoothAMPManagerCreatePhysicalLinkResponseCollisionOccurred = 0x03, + kBluetoothAMPManagerCreatePhysicalLinkResponseAMPDisconnectedPhysicalLinkRequestReceived = 0x04, + kBluetoothAMPManagerCreatePhysicalLinkResponsePhysicalLinkAlreadyExists = 0x05, + kBluetoothAMPManagerCreatePhysicalLinkResponseSecurityViolation = 0x06, +} BluetoothAMPCreatePhysicalLinkResponseStatus; + +typedef enum { + kBluetoothAMPManagerDisconnectPhysicalLinkResponseSuccess = 0x00, + kBluetoothAMPManagerDisconnectPhysicalLinkResponseInvalidControllerID = 0x01, + kBluetoothAMPManagerDisconnectPhysicalLinkResponseNoPhysicalLink = 0x02, +} BluetoothAMPDisconnectPhysicalLinkResponseStatus; + +#if 0 +#pragma mark - +#pragma mark === HCI === +#endif + +//=========================================================================================================================== +// Host Controller Interface (HCI) +//=========================================================================================================================== + +// HCI Command Packet +// ------------------ +// +// 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 +// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +// +--------------------------------+---------------+--------------+ +// | OpCode | | | +// +--------------------+-----------| Param Length | Params... | +// | OCF | OGF | | | +// +--------------------+-----------+---------------+--------------+ +// | | +// | Params... | +// | | +// +---------------------------------------------------------------+ + +// Commands + +typedef UInt8 BluetoothHCICommandOpCodeGroup; +typedef UInt16 BluetoothHCICommandOpCodeCommand; +typedef UInt16 BluetoothHCICommandOpCode; +typedef UInt32 BluetoothHCIVendorCommandSelector; + +#define BluetoothHCIMakeCommandOpCode( GROUP, CMD ) ( ( ( ( GROUP ) & 0x003F ) << 10 ) | ( ( CMD ) & 0x03FF ) ) +#define BluetoothHCIMakeCommandOpCodeEndianSwap( GROUP, CMD ) ( CFSwapInt16HostToLittle ( BluetoothHCIMakeCommandOpCode( GROUP, CMD ) ) ) +#define BluetoothHCIExtractCommandOpCodeGroup( OPCODE ) ( ( ( OPCODE ) >> 10 ) & 0x003F ) +#define BluetoothHCIExtractCommandOpCodeCommand( OPCODE ) ( ( OPCODE ) & 0x03FF ) + +#define BluetoothHCIMakeCommandOpCodeHostOrder(GROUP, CMD ) OSSwapLittleToHostConstInt16( ( ( ( GROUP ) & 0x003F ) << 10 ) | ( ( CMD ) & 0x03FF ) ) + + +enum +{ + // Command Group: NoOp + + kBluetoothHCIOpCodeNoOp = 0, + kBluetoothHCICommandGroupNoOp = 0x00, + kBluetoothHCICommandNoOp = 0x0000, + + // Command Group: Link Control + + kBluetoothHCICommandGroupLinkControl = 0x01, + kBluetoothHCICommandInquiry = 0x0001, + kBluetoothHCICommandInquiryCancel = 0x0002, + kBluetoothHCICommandPeriodicInquiryMode = 0x0003, + kBluetoothHCICommandExitPeriodicInquiryMode = 0x0004, + kBluetoothHCICommandCreateConnection = 0x0005, + kBluetoothHCICommandDisconnect = 0x0006, + kBluetoothHCICommandAddSCOConnection = 0x0007, + kBluetoothHCICommandCreateConnectionCancel = 0x0008, + kBluetoothHCICommandAcceptConnectionRequest = 0x0009, + kBluetoothHCICommandRejectConnectionRequest = 0x000A, + kBluetoothHCICommandLinkKeyRequestReply = 0x000B, + kBluetoothHCICommandLinkKeyRequestNegativeReply = 0x000C, + kBluetoothHCICommandPINCodeRequestReply = 0x000D, + kBluetoothHCICommandPINCodeRequestNegativeReply = 0x000E, + kBluetoothHCICommandChangeConnectionPacketType = 0x000F, + kBluetoothHCICommandAuthenticationRequested = 0x0011, + kBluetoothHCICommandSetConnectionEncryption = 0x0013, + kBluetoothHCICommandChangeConnectionLinkKey = 0x0015, + kBluetoothHCICommandMasterLinkKey = 0x0017, + kBluetoothHCICommandRemoteNameRequest = 0x0019, + kBluetoothHCICommandReadRemoteSupportedFeatures = 0x001B, + kBluetoothHCICommandReadRemoteExtendedFeatures = 0x001C, + kBluetoothHCICommandReadRemoteVersionInformation = 0x001D, + kBluetoothHCICommandReadClockOffset = 0x001F, + kBluetoothHCICommandRemoteNameRequestCancel = 0x001A, + kBluetoothHCICommandReadLMPHandle = 0x0020, + kBluetoothHCICommandSetupSynchronousConnection = 0x0028, + kBluetoothHCICommandAcceptSynchronousConnectionRequest = 0x0029, + kBluetoothHCICommandRejectSynchronousConnectionRequest = 0x002A, + kBluetoothHCICommandIOCapabilityRequestReply = 0x002B, + kBluetoothHCICommandUserConfirmationRequestReply = 0x002C, + kBluetoothHCICommandUserConfirmationRequestNegativeReply = 0x002D, + kBluetoothHCICommandUserPasskeyRequestReply = 0x002E, + kBluetoothHCICommandUserPasskeyRequestNegativeReply = 0x002F, + kBluetoothHCICommandRemoteOOBDataRequestReply = 0x0030, + kBluetoothHCICommandRemoteOOBDataRequestNegativeReply = 0x0033, + + // Command Group: Link Policy + + kBluetoothHCICommandGroupLinkPolicy = 0x02, + kBluetoothHCICommandHoldMode = 0x0001, + kBluetoothHCICommandSniffMode = 0x0003, + kBluetoothHCICommandExitSniffMode = 0x0004, + kBluetoothHCICommandParkMode = 0x0005, + kBluetoothHCICommandExitParkMode = 0x0006, + kBluetoothHCICommandQoSSetup = 0x0007, + kBluetoothHCICommandRoleDiscovery = 0x0009, + kBluetoothHCICommandSwitchRole = 0x000B, + kBluetoothHCICommandReadLinkPolicySettings = 0x000C, + kBluetoothHCICommandWriteLinkPolicySettings = 0x000D, + kBluetoothHCICommandReadDefaultLinkPolicySettings = 0x000E, + kBluetoothHCICommandWriteDefaultLinkPolicySettings = 0x000F, + kBluetoothHCICommandFlowSpecification = 0x0010, + kBluetoothHCICommandSniffSubrating = 0x0011, + kBluetoothHCICommandAcceptSniffRequest = 0x0031, + kBluetoothHCICommandRejectSniffRequest = 0x0032, + + // Command Group: Host Controller & Baseband + + kBluetoothHCICommandGroupHostController = 0x03, + kBluetoothHCICommandSetEventMask = 0x0001, + kBluetoothHCICommandReset = 0x0003, + kBluetoothHCICommandSetEventFilter = 0x0005, + kBluetoothHCICommandFlush = 0x0008, + kBluetoothHCICommandReadPINType = 0x0009, + kBluetoothHCICommandWritePINType = 0x000A, + kBluetoothHCICommandCreateNewUnitKey = 0x000B, + kBluetoothHCICommandReadStoredLinkKey = 0x000D, + kBluetoothHCICommandWriteStoredLinkKey = 0x0011, + kBluetoothHCICommandDeleteStoredLinkKey = 0x0012, + kBluetoothHCICommandChangeLocalName = 0x0013, + kBluetoothHCICommandReadLocalName = 0x0014, + kBluetoothHCICommandReadConnectionAcceptTimeout = 0x0015, + kBluetoothHCICommandWriteConnectionAcceptTimeout = 0x0016, + kBluetoothHCICommandReadPageTimeout = 0x0017, + kBluetoothHCICommandWritePageTimeout = 0x0018, + kBluetoothHCICommandReadScanEnable = 0x0019, + kBluetoothHCICommandWriteScanEnable = 0x001A, + kBluetoothHCICommandReadPageScanActivity = 0x001B, + kBluetoothHCICommandWritePageScanActivity = 0x001C, + kBluetoothHCICommandReadInquiryScanActivity = 0x001D, + kBluetoothHCICommandWriteInquiryScanActivity = 0x001E, + kBluetoothHCICommandReadAuthenticationEnable = 0x001F, + kBluetoothHCICommandWriteAuthenticationEnable = 0x0020, + kBluetoothHCICommandReadEncryptionMode = 0x0021, + kBluetoothHCICommandWriteEncryptionMode = 0x0022, + kBluetoothHCICommandReadClassOfDevice = 0x0023, + kBluetoothHCICommandWriteClassOfDevice = 0x0024, + kBluetoothHCICommandReadVoiceSetting = 0x0025, + kBluetoothHCICommandWriteVoiceSetting = 0x0026, + kBluetoothHCICommandReadAutomaticFlushTimeout = 0x0027, + kBluetoothHCICommandWriteAutomaticFlushTimeout = 0x0028, + kBluetoothHCICommandReadNumberOfBroadcastRetransmissions = 0x0029, + kBluetoothHCICommandWriteNumberOfBroadcastRetransmissions = 0x002A, + kBluetoothHCICommandReadHoldModeActivity = 0x002B, + kBluetoothHCICommandWriteHoldModeActivity = 0x002C, + kBluetoothHCICommandReadTransmitPowerLevel = 0x002D, + kBluetoothHCICommandReadSCOFlowControlEnable = 0x002E, + kBluetoothHCICommandWriteSCOFlowControlEnable = 0x002F, + kBluetoothHCICommandSetHostControllerToHostFlowControl = 0x0031, + kBluetoothHCICommandHostBufferSize = 0x0033, + kBluetoothHCICommandHostNumberOfCompletedPackets = 0x0035, + kBluetoothHCICommandReadLinkSupervisionTimeout = 0x0036, + kBluetoothHCICommandWriteLinkSupervisionTimeout = 0x0037, + kBluetoothHCICommandReadNumberOfSupportedIAC = 0x0038, + kBluetoothHCICommandReadCurrentIACLAP = 0x0039, + kBluetoothHCICommandWriteCurrentIACLAP = 0x003A, + kBluetoothHCICommandReadPageScanPeriodMode = 0x003B, + kBluetoothHCICommandWritePageScanPeriodMode = 0x003C, + kBluetoothHCICommandReadPageScanMode = 0x003D, + kBluetoothHCICommandWritePageScanMode = 0x003E, + kBluetoothHCICommandSetAFHClassification = 0x003F, + kBluetoothHCICommandReadInquiryScanType = 0x0042, + kBluetoothHCICommandWriteInquiryScanType = 0x0043, + kBluetoothHCICommandReadInquiryMode = 0x0044, + kBluetoothHCICommandWriteInquiryMode = 0x0045, + kBluetoothHCICommandReadPageScanType = 0x0046, + kBluetoothHCICommandWritePageScanType = 0x0047, + kBluetoothHCICommandReadAFHChannelAssessmentMode = 0x0048, + kBluetoothHCICommandWriteAFHChannelAssessmentMode = 0x0049, + kBluetoothHCICommandReadExtendedInquiryResponse = 0x0051, + kBluetoothHCICommandWriteExtendedInquiryResponse = 0x0052, + kBluetoothHCICommandReadSimplePairingMode = 0x0055, + kBluetoothHCICommandWriteSimplePairingMode = 0x0056, + kBluetoothHCICommandReadLocalOOBData = 0x0057, + kBluetoothHCICommandReadInquiryResponseTransmitPower = 0x0058, + kBluetoothHCICommandWriteInquiryResponseTransmitPower = 0x0059, + kBluetoothHCICommandReadDefaultErroneousDataReporting = 0x005A, + kBluetoothHCICommandWriteDefaultErroneousDataReporting = 0x005B, + kBluetoothHCICommandReadPersistentSniffInterval = 0x005C, + kBluetoothHCICommandWritePersistentSniffInterval = 0x005D, + kBluetoothHCICommandDeletePersistentSniffInterval = 0x005E, + kBluetoothHCICommandEnhancedFlush = 0x005F, + kBluetoothHCICommandSendKeypressNotification = 0x0060, + + // Command Group: Informational + + kBluetoothHCICommandGroupInformational = 0x04, + kBluetoothHCICommandReadLocalVersionInformation = 0x0001, + kBluetoothHCICommandReadLocalSupportedCommands = 0x0002, + kBluetoothHCICommandReadLocalSupportedFeatures = 0x0003, + kBluetoothHCICommandReadLocalExtendedFeatures = 0x0004, + kBluetoothHCICommandReadBufferSize = 0x0005, + kBluetoothHCICommandReadCountryCode = 0x0007, + kBluetoothHCICommandReadDeviceAddress = 0x0009, + + // Command Group: Status + + kBluetoothHCICommandGroupStatus = 0x05, + kBluetoothHCICommandReadFailedContactCounter = 0x0001, + kBluetoothHCICommandResetFailedContactCounter = 0x0002, + kBluetoothHCICommandGetLinkQuality = 0x0003, + kBluetoothHCICommandReadRSSI = 0x0005, + kBluetoothHCICommandReadAFHMappings = 0x0006, + kBluetoothHCICommandReadClock = 0x0007, + + // Command Group: Testing + + kBluetoothHCICommandGroupTesting = 0x06, + kBluetoothHCICommandReadLoopbackMode = 0x0001, + kBluetoothHCICommandWriteLoopbackMode = 0x0002, + kBluetoothHCICommandEnableDeviceUnderTestMode = 0x0003, + kBluetoothHCICommandWriteSimplePairingDebugMode = 0x0004, + + // Command Group: Logo Testing (no commands yet) + + kBluetoothHCICommandGroupLogoTesting = 0x3E, + + // Command Group: Vendor Specific (from Broadcom HCI Programmer's Reference Guide) + + kBluetoothHCICommandGroupVendorSpecific = 0x3f, + kBluetoothHCICommandWriteDeviceAddress = 0x0001, + kBluetoothHCICommandWriteHoppingChannels = 0x0012, + kBluetoothHCICommandInvalidateFlashAndReboot = 0x0017, + kBluetoothHCICommandSetMaxPower = 0x0026, + kBluetoothHCICommandEnableHIDEmulation = 0x003B, + kBluetoothHCICommandEnableRadio = 0x0034, + kBluetoothHCIGetHIDDeviceList = 0x0036, + kBluetoothHCIAddHIDDevice = 0x0037, + kBluetoothHCIRemoveHIDDevice = 0x0039, + + kBluetoothHCICommandGroupMax = 0x40, + kBluetoothHCICommandMax = 0x03FF +}; + +// HCI Data Types + +typedef UInt8 BluetoothHCIQoSFlags; +typedef UInt8 BluetoothHCIParamByteCount; +typedef UInt16 BluetoothHCIACLDataByteCount; +typedef UInt8 BluetoothHCISCODataByteCount; +typedef UInt8 BluetoothHCIInquiryLength; +typedef UInt8 BluetoothHCIResponseCount; +typedef UInt8 BluetoothHCICountryCode; +typedef UInt16 BluetoothHCIModeInterval; +typedef UInt16 BluetoothHCISniffAttemptCount; +typedef UInt16 BluetoothHCISniffTimeout; +typedef UInt16 BluetoothHCIParkModeBeaconInterval; + +typedef UInt8 BluetoothMaxSlots; +typedef UInt16 BluetoothManufacturerName; +typedef UInt8 BluetoothLMPVersion; +typedef UInt16 BluetoothLMPSubversion; + +typedef UInt8 BluetoothHCIConnectionMode; +enum BluetoothHCIConnectionModes +{ + kConnectionActiveMode = 0, + kConnectionHoldMode = 1, + kConnectionSniffMode = 2, + kConnectionParkMode = 3, + kConnectionModeReservedForFutureUse = 4, +}; + +typedef struct BluetoothHCISupportedFeatures BluetoothHCISupportedFeatures; +struct BluetoothHCISupportedFeatures +{ + UInt8 data[8]; +}; + +#if BLUETOOTH_VERSION_MAX_ALLOWED >= BLUETOOTH_VERSION_2_1_1 +typedef UInt8 BluetoothHCIPageNumber; +typedef struct BluetoothHCIExtendedFeaturesInfo BluetoothHCIExtendedFeaturesInfo; +struct BluetoothHCIExtendedFeaturesInfo +{ + BluetoothHCIPageNumber page; + BluetoothHCIPageNumber maxPage; + UInt8 data[8]; +}; +#endif /* BLUETOOTH_VERSION_MAX_ALLOWED >= BLUETOOTH_VERSION_2_1_1 */ + +enum BluetoothFeatureBits +{ + // Byte 0 of the support features data structure. + + kBluetoothFeatureThreeSlotPackets = (1 << 0L), + kBluetoothFeatureFiveSlotPackets = (1 << 1L), + kBluetoothFeatureEncryption = (1 << 2L), + kBluetoothFeatureSlotOffset = (1 << 3L), + kBluetoothFeatureTimingAccuracy = (1 << 4L), + kBluetoothFeatureSwitchRoles = (1 << 5L), + kBluetoothFeatureHoldMode = (1 << 6L), + kBluetoothFeatureSniffMode = (1 << 7L), + + // Byte 1 of the support features data structure. + + kBluetoothFeatureParkMode = (1 << 0L), + kBluetoothFeatureRSSI = (1 << 1L), + kBluetoothFeaturePowerControlRequests = (1 << 1L), + kBluetoothFeatureChannelQuality = (1 << 2L), + kBluetoothFeatureSCOLink = (1 << 3L), + kBluetoothFeatureHV2Packets = (1 << 4L), + kBluetoothFeatureHV3Packets = (1 << 5L), + kBluetoothFeatureULawLog = (1 << 6L), + kBluetoothFeatureALawLog = (1 << 7L), + + // Byte 2 of the support features data structure. + + kBluetoothFeatureCVSD = (1 << 0L), + kBluetoothFeaturePagingScheme = (1 << 1L), + kBluetoothFeaturePowerControl = (1 << 2L), + kBluetoothFeatureTransparentSCOData = (1 << 3L), + kBluetoothFeatureFlowControlLagBit0 = (1 << 4L), + kBluetoothFeatureFlowControlLagBit1 = (1 << 5L), + kBluetoothFeatureFlowControlLagBit2 = (1 << 6L), + kBluetoothFeatureBroadcastEncryption = (1 << 7L), + + // Byte 3 of the support features data structure. + + kBluetoothFeatureScatterMode = (1 << 0L), + kBluetoothFeatureEnhancedDataRateACL2MbpsMode = (1 << 1L), + kBluetoothFeatureEnhancedDataRateACL3MbpsMode = (1 << 2L), + kBluetoothFeatureEnhancedInquiryScan = (1 << 3L), + kBluetoothFeatureInterlacedInquiryScan = (1 << 4L), + kBluetoothFeatureInterlacedPageScan = (1 << 5L), + kBluetoothFeatureRSSIWithInquiryResult = (1 << 6L), + kBluetoothFeatureExtendedSCOLink = (1 << 7L), + + // Byte 4 of the support features data structure. + + kBluetoothFeatureEV4Packets = (1 << 0L), + kBluetoothFeatureEV5Packets = (1 << 1L), + kBluetoothFeatureAbsenceMasks = (1 << 2L), + kBluetoothFeatureAFHCapableSlave = (1 << 3L), + kBluetoothFeatureAFHClassificationSlave = (1 << 4L), + kBluetoothFeatureAliasAuhentication = (1 << 5L), + kBluetoothFeatureAnonymityMode = (1 << 6L), + kBluetoothFeature3SlotEnhancedDataRateACLPackets = (1 << 7L), + + // Byte 5 of the support features data structure. + + kBluetoothFeature5SlotEnhancedDataRateACLPackets = (1 << 0L), // 2.0 version of this header had this at the wrong bit location + kBluetoothFeatureSniffSubrating = (1 << 1L), + kBluetoothFeaturePauseEncryption = (1 << 2L), + kBluetoothFeatureAFHCapableMaster = (1 << 3L), + kBluetoothFeatureAFHClassificationMaster = (1 << 4L), + kBluetoothFeatureEnhancedDataRateeSCO2MbpsMode = (1 << 5L), + kBluetoothFeatureEnhancedDataRateeSCO3MbpsMode = (1 << 6L), + kBluetoothFeature3SlotEnhancedDataRateeSCOPackets = (1 << 7L), + + // Byte 6 of the support features data structure. + + kBluetoothFeatureExtendedInquiryResponse = (1 << 0L), + kBluetoothFeatureSecureSimplePairing = (1 << 3L), + kBluetoothFeatureEncapsulatedPDU = (1 << 4L), + kBluetoothFeatureErroneousDataReporting = (1 << 5L), + kBluetoothFeatureNonFlushablePacketBoundaryFlag = (1 << 6L), + + // Byte 7 of the support features data structure. + + kBluetoothFeatureLinkSupervisionTimeoutChangedEvent = (1 << 0L), + kBluetoothFeatureInquiryTransmissionPowerLevel = (1 << 1L), + kBluetoothFeatureExtendedFeatures = (1 << 7L), + + // Byte 8 of the support features data structure (extended) + + kBluetoothFeatureSimpleSecurePairingHostMode = (1 << 0L), + +}; + +typedef UInt16 BluetoothHCIFailedContactCount; +typedef struct BluetoothHCIFailedContactInfo BluetoothHCIFailedContactInfo; +struct BluetoothHCIFailedContactInfo +{ + BluetoothHCIFailedContactCount count; + BluetoothConnectionHandle handle; +}; + +typedef SInt8 BluetoothHCIRSSIValue; /* Valid Range: -127 to +20 */ +typedef struct BluetoothHCIRSSIInfo BluetoothHCIRSSIInfo; +struct BluetoothHCIRSSIInfo +{ + BluetoothConnectionHandle handle; + BluetoothHCIRSSIValue RSSIValue; +}; + +typedef UInt8 BluetoothHCILinkQuality; +typedef struct BluetoothHCILinkQualityInfo BluetoothHCILinkQualityInfo; +struct BluetoothHCILinkQualityInfo +{ + BluetoothConnectionHandle handle; + BluetoothHCILinkQuality qualityValue; +}; + +typedef UInt8 BluetoothHCIRole; +typedef struct BluetoothHCIRoleInfo BluetoothHCIRoleInfo; +struct BluetoothHCIRoleInfo +{ + UInt8 role; + BluetoothConnectionHandle handle; +}; + +enum BluetoothHCIRoles +{ + kBluetoothHCIMasterRole = 0x00, + kBluetoothHCISlaveRole = 0x01 +}; + +typedef UInt16 BluetoothHCILinkPolicySettings; +enum BluetoothHCILinkPolicySettingsValues +{ + kDisableAllLMModes = 0x0000, + kEnableMasterSlaveSwitch = 0x0001, + kEnableHoldMode = 0x0002, + kEnableSniffMode = 0x0004, + kEnableParkMode = 0x0008, + kReservedForFutureUse = 0x0010 +}; + +typedef struct BluetoothHCILinkPolicySettingsInfo BluetoothHCILinkPolicySettingsInfo; +struct BluetoothHCILinkPolicySettingsInfo +{ + BluetoothHCILinkPolicySettings settings; + BluetoothConnectionHandle handle; +}; + + +typedef struct BluetoothHCIQualityOfServiceSetupParams BluetoothHCIQualityOfServiceSetupParams; +struct BluetoothHCIQualityOfServiceSetupParams +{ + UInt8 flags; + UInt8 serviceType; + UInt32 tokenRate; + UInt32 peakBandwidth; + UInt32 latency; + UInt32 delayVariation; +}; + +typedef UInt8 BluetoothHCILoopbackMode; +enum +{ + kBluetoothHCILoopbackModeOff = 0x00, + kBluetoothHCILoopbackModeLocal = 0x01, + kBluetoothHCILoopbackModeRemote = 0x02 +}; + +typedef UInt32 BluetoothHCIOperationID; +typedef UInt32 BluetoothHCIEventID; +typedef UInt32 BluetoothHCIDataID; +typedef UInt32 BluetoothHCISignalID; +typedef UInt32 BluetoothHCITransportID; +typedef UInt32 BluetoothHCITransportCommandID; +typedef UInt32 BluetoothHCIRequestID; + + +// Version Information + +typedef struct BluetoothHCIVersionInfo BluetoothHCIVersionInfo; +struct BluetoothHCIVersionInfo +{ + // Local & Remote information + + BluetoothManufacturerName manufacturerName; + BluetoothLMPVersion lmpVersion; + BluetoothLMPSubversion lmpSubVersion; + + // Local information only + + UInt8 hciVersion; + UInt16 hciRevision; +}; + +// HCI buffer sizes. + +typedef struct BluetoothHCIBufferSize BluetoothHCIBufferSize; +struct BluetoothHCIBufferSize +{ + UInt16 ACLDataPacketLength; + UInt8 SCODataPacketLength; + UInt16 totalNumACLDataPackets; + UInt16 totalNumSCODataPackets; +}; + +// Timeouts +typedef UInt16 BluetoothHCIConnectionAcceptTimeout; +typedef UInt16 BluetoothHCIPageTimeout; +enum BluetoothHCITimeoutValues +{ + kDefaultPageTimeout = 0x2000, +}; + +#define BluetoothGetSlotsFromSeconds( inSeconds ) ( (inSeconds/.000625 ) ) + + +// Link Keys +typedef UInt16 BluetoothHCINumLinkKeysDeleted; +typedef UInt8 BluetoothHCINumLinkKeysToWrite; +typedef UInt8 BluetoothHCIDeleteStoredLinkKeyFlag; +enum BluetoothHCIDeleteStoredLinkKeyFlags +{ + kDeleteKeyForSpecifiedDeviceOnly = 0x00, + kDeleteAllStoredLinkKeys = 0x01, +}; + +typedef UInt8 BluetoothHCIReadStoredLinkKeysFlag; +enum BluetoothHCIReadStoredLinkKeysFlags +{ + kReturnLinkKeyForSpecifiedDeviceOnly = 0x00, + kReadAllStoredLinkKeys = 0x01, +}; + +typedef struct BluetoothHCIStoredLinkKeysInfo BluetoothHCIStoredLinkKeysInfo; +struct BluetoothHCIStoredLinkKeysInfo +{ + UInt16 numLinkKeysRead; + UInt16 maxNumLinkKeysAllowedInDevice; +}; + + +// Page Scan + +typedef UInt8 BluetoothHCIPageScanMode; +enum BluetoothHCIPageScanModes +{ + kMandatoryPageScanMode = 0x00, + kOptionalPageScanMode1 = 0x01, + kOptionalPageScanMode2 = 0x02, + kOptionalPageScanMode3 = 0x03, +}; + +typedef UInt8 BluetoothHCIPageScanPeriodMode; +enum BluetoothHCIPageScanPeriodModes +{ + kP0Mode = 0x00, + kP1Mode = 0x01, + kP2Mode = 0x02, +}; + +typedef UInt8 BluetoothHCIPageScanEnableState; +enum BluetoothHCIPageScanEnableStates +{ + kNoScansEnabled = 0x00, + kInquiryScanEnabledPageScanDisabled = 0x01, + kInquiryScanDisabledPageScanEnabled = 0x02, + kInquiryScanEnabledPageScanEnabled = 0x03, +}; + +typedef struct BluetoothHCIScanActivity BluetoothHCIScanActivity; +struct BluetoothHCIScanActivity +{ + UInt16 scanInterval; + UInt16 scanWindow; +}; + +typedef struct BluetoothHCIInquiryAccessCode BluetoothHCIInquiryAccessCode; +struct BluetoothHCIInquiryAccessCode +{ + UInt8 data[3]; +}; + +typedef UInt8 BluetoothHCIInquiryAccessCodeCount; +typedef struct BluetoothHCICurrentInquiryAccessCodes BluetoothHCICurrentInquiryAccessCodes; +struct BluetoothHCICurrentInquiryAccessCodes +{ + BluetoothHCIInquiryAccessCodeCount count; // Number of codes in array. + BluetoothHCIInquiryAccessCode * codes; // Ptr to array of codes. +}; + +typedef struct BluetoothHCILinkSupervisionTimeout BluetoothHCILinkSupervisionTimeout; +struct BluetoothHCILinkSupervisionTimeout +{ + BluetoothConnectionHandle handle; + UInt16 timeout; +}; + +typedef UInt8 BluetoothHCIFlowControlState; +enum BluetoothHCISCOFlowControlStates +{ + kSCOFlowControlDisabled = 0x00, + kSCOFlowControlEnabled = 0x01 +}; + +enum BluetoothHCIGeneralFlowControlStates +{ + kHostControllerToHostFlowControlOff = 0x00, + kHCIACLDataPacketsOnHCISCODataPacketsOff = 0x01, + kHCIACLDataPacketsOffHCISCODataPacketsOn = 0x02, + kHCIACLDataPacketsOnHCISCODataPacketsOn = 0x03, +}; + +typedef SInt8 BluetoothHCITransmitPowerLevel; +typedef UInt8 BluetoothHCITransmitPowerLevelType; +enum BluetoothHCITransmitReadPowerLevelTypes +{ + kReadCurrentTransmitPowerLevel = 0x00, + kReadMaximumTransmitPowerLevel = 0x01, +}; + +typedef UInt8 BluetoothHCIAFHChannelAssessmentMode; +enum BluetoothHCIAFHChannelAssessmentModes +{ + kAFHChannelAssessmentModeDisabled = 0x00, + kAFHChannelAssessmentModeEnabled = 0x01 +}; + + +typedef struct BluetoothHCITransmitPowerLevelInfo BluetoothHCITransmitPowerLevelInfo; +struct BluetoothHCITransmitPowerLevelInfo +{ + BluetoothConnectionHandle handle; + BluetoothHCITransmitPowerLevel level; // Range: -70 <= N <= 20 (units are dBm) +}; + +typedef UInt8 BluetoothHCINumBroadcastRetransmissions; +typedef UInt8 BluetoothHCIHoldModeActivity; +enum BluetoothHCIHoldModeActivityStates +{ + kMaintainCurrentPowerState = 0x00, + kSuspendPageScan = 0x01, + kSuspendInquiryScan = 0x02, + kSuspendPeriodicInquiries = 0x03, +}; + +typedef UInt8 BluetoothHCIAuthenticationEnable; +enum BluetoothHCIAuthentionEnableModes +{ + kAuthenticationDisabled = 0x00, + kAuthenticationEnabled = 0x01, +}; + +typedef UInt8 BluetoothHCIEncryptionMode; +enum BluetoothHCIEncryptionModes +{ + kEncryptionDisabled = 0x00, // Default. + kEncryptionOnlyForPointToPointPackets = 0x01, + kEncryptionForBothPointToPointAndBroadcastPackets = 0x02, +}; + +typedef UInt16 BluetoothHCIAutomaticFlushTimeout; +typedef struct BluetoothHCIAutomaticFlushTimeoutInfo BluetoothHCIAutomaticFlushTimeoutInfo; +struct BluetoothHCIAutomaticFlushTimeoutInfo +{ + BluetoothConnectionHandle handle; + BluetoothHCIAutomaticFlushTimeout timeout; +}; + +#define kInfoStringMaxLength 25 +typedef struct BluetoothTransportInfo BluetoothTransportInfo; +typedef BluetoothTransportInfo* BluetoothTransportInfoPtr; +struct BluetoothTransportInfo +{ + UInt32 productID; + UInt32 vendorID; + UInt32 type; + char productName[kInfoStringMaxLength]; + char vendorName[kInfoStringMaxLength]; +}; + +enum BluetoothTransportTypes +{ + kBluetoothTransportTypeUSB = 0x01, + kBluetoothTransportTypePCCard = 0x02, + kBluetoothTransportTypePCICard = 0x03 +}; + +// Inquiries + +typedef struct BluetoothHCIInquiryResult BluetoothHCIInquiryResult; +struct BluetoothHCIInquiryResult +{ + BluetoothDeviceAddress deviceAddress; + BluetoothPageScanRepetitionMode pageScanRepetitionMode; + BluetoothHCIPageScanPeriodMode pageScanPeriodMode; + BluetoothHCIPageScanMode pageScanMode; + BluetoothClassOfDevice classOfDevice; + BluetoothClockOffset clockOffset; +}; + +#define kBluetoothHCIInquiryResultsMaxResults 50 +typedef struct BluetoothHCIInquiryResults BluetoothHCIInquiryResults; +struct BluetoothHCIInquiryResults +{ + BluetoothHCIInquiryResult results[kBluetoothHCIInquiryResultsMaxResults]; + IOItemCount count; +}; + +#if BLUETOOTH_VERSION_MAX_ALLOWED >= BLUETOOTH_VERSION_2_0 + +//Inquiries with RSSI (v1.2 specification) + +typedef struct BluetoothHCIInquiryWithRSSIResult BluetoothHCIInquiryWithRSSIResult; +struct BluetoothHCIInquiryWithRSSIResult +{ + BluetoothDeviceAddress deviceAddress; + BluetoothPageScanRepetitionMode pageScanRepetitionMode; + UInt8 reserved; + BluetoothClassOfDevice classOfDevice; + BluetoothClockOffset clockOffset; + BluetoothHCIRSSIValue RSSIValue; +}; + +typedef struct BluetoothHCIInquiryWithRSSIResults BluetoothHCIInquiryWithRSSIResults; +struct BluetoothHCIInquiryWithRSSIResults +{ + BluetoothHCIInquiryWithRSSIResult results[50]; + IOItemCount count; +}; + +//Inquiries with 'Extended Inquiry Response' (v2.1 specification) + +typedef UInt8 BluetoothHCIFECRequired; +enum BluetoothHCIFECRequiredValues +{ + kBluetoothHCIFECRequired = 0x00, + kBluetoothHCIFECNotRequired = 0x01 +}; + +typedef UInt8 BluetoothHCIInquiryMode; +enum BluetoothHCIInquiryModes +{ + kBluetoothHCIInquiryModeResultFormatStandard = 0x00, + kBluetoothHCIInquiryModeResultFormatWithRSSI = 0x01, + kBluetoothHCIInquiryModeResultFormatWithRSSIOrExtendedInquiryResultFormat = 0x02 +}; + +typedef UInt8 BluetoothHCIExtendedInquiryResponseDataType; + +typedef struct BluetoothHCIExtendedInquiryResponse BluetoothHCIExtendedInquiryResponse; /* Extended Inquiry Response [EIR] data, consisting of a sequence of data structures in this format: [length(1byte)][data type(1byte)][data(e.g. device name)] */ +struct BluetoothHCIExtendedInquiryResponse +{ + UInt8 data[ 240 ]; +}; + +typedef struct BluetoothHCIReadExtendedInquiryResponseResults BluetoothHCIReadExtendedInquiryResponseResults; +struct BluetoothHCIReadExtendedInquiryResponseResults +{ + BluetoothHCIFECRequired outFECRequired; + BluetoothHCIExtendedInquiryResponse extendedInquiryResponse; +}; + +typedef struct BluetoothHCIExtendedInquiryResult BluetoothHCIExtendedInquiryResult; +struct BluetoothHCIExtendedInquiryResult +{ + UInt8 numberOfReponses; /* always a value of 1 */ + BluetoothDeviceAddress deviceAddress; + BluetoothPageScanRepetitionMode pageScanRepetitionMode; + UInt8 reserved; + BluetoothClassOfDevice classOfDevice; + BluetoothClockOffset clockOffset; + BluetoothHCIRSSIValue RSSIValue; + BluetoothHCIExtendedInquiryResponse extendedInquiryResponse; +}; + +// 'Simple Pairing' (v2.1 specification) + +typedef UInt8 BluetoothHCISimplePairingMode; +enum BluetoothHCISimplePairingModes +{ + kBluetoothHCISimplePairingModeNotSet = 0x00, + kBluetoothHCISimplePairingModeEnabled = 0x01 +}; + +typedef UInt8 BluetoothSimplePairingDebugMode; +enum BluetoothSimplePairingDebugModes +{ + kBluetoothHCISimplePairingDebugModeDisabled = 0x00, + kBluetoothHCISimplePairingDebugModeEnabled = 0x01 +}; + +typedef struct BluetoothHCISimplePairingOOBData BluetoothHCISimplePairingOOBData; +struct BluetoothHCISimplePairingOOBData +{ + UInt8 data[ 16 ]; +}; + +typedef struct BluetoothHCIReadLocalOOBDataResults BluetoothHCIReadLocalOOBDataResults; +struct BluetoothHCIReadLocalOOBDataResults +{ + BluetoothHCISimplePairingOOBData hash; + BluetoothHCISimplePairingOOBData randomizer; +}; + +typedef UInt8 BluetoothIOCapability; +enum BluetoothIOCapabilities +{ + kBluetoothCapabilityTypeDisplayOnly = 0x00, + kBluetoothCapabilityTypeDisplayYesNo = 0x01, + kBluetoothCapabilityTypeKeyboardOnly = 0x02, + kBluetoothCapabilityTypeNoInputNoOutput = 0x03 +}; + +typedef UInt8 BluetoothOOBDataPresence; +enum BluetoothOOBDataPresenceValues +{ + kBluetoothOOBAuthenticationDataNotPresent = 0x00, + kBluetoothOOBAuthenticationDataFromRemoteDevicePresent = 0x01 +}; + +typedef UInt8 BluetoothAuthenticationRequirements; +enum BluetoothAuthenticationRequirementsValues +{ + kBluetoothAuthenticationRequirementsMITMProtectionNotRequired = 0x00, /* Numeric comparison with automatic accept allowed */ + kBluetoothAuthenticationRequirementsMITMProtectionRequired = 0x01, /* Refer to BluetoothIOCapabilities to determine authentication procedure */ + kBluetoothAuthenticationRequirementsMITMProtectionNotRequiredNoBonding = 0x00, + kBluetoothAuthenticationRequirementsMITMProtectionRequiredNoBonding = 0x01, + kBluetoothAuthenticationRequirementsMITMProtectionNotRequiredDedicatedBonding = 0x02, + kBluetoothAuthenticationRequirementsMITMProtectionRequiredDedicatedBonding = 0x03, + kBluetoothAuthenticationRequirementsMITMProtectionNotRequiredGeneralBonding = 0x04, + kBluetoothAuthenticationRequirementsMITMProtectionRequiredGeneralBonding = 0x05 +}; + +typedef struct BluetoothIOCapabilityResponse BluetoothIOCapabilityResponse; +struct BluetoothIOCapabilityResponse +{ + BluetoothDeviceAddress deviceAddress; + BluetoothIOCapability ioCapability; /* possible values from BluetoothIOCapabilities above */ + BluetoothOOBDataPresence OOBDataPresence; + BluetoothAuthenticationRequirements authenticationRequirements; +}; + +typedef UInt32 BluetoothPasskey; + +typedef struct BluetoothUserPasskeyNotification BluetoothUserPasskeyNotification; +struct BluetoothUserPasskeyNotification +{ + BluetoothDeviceAddress deviceAddress; + BluetoothPasskey passkey; /* passkey for display. valid values are 000000 - 999999 */ +}; + +typedef UInt8 BluetoothKeypressNotificationType; +enum BluetoothKeypressNotificationTypes +{ + kBluetoothKeypressNotificationTypePasskeyEntryStarted = 0, + kBluetoothKeypressNotificationTypePasskeyDigitEntered = 1, + kBluetoothKeypressNotificationTypePasskeyDigitErased = 2, + kBluetoothKeypressNotificationTypePasskeyCleared = 3, + kBluetoothKeypressNotificationTypePasskeyEntryCompleted = 4 +}; + +typedef struct BluetoothKeypressNotification BluetoothKeypressNotification; +struct BluetoothKeypressNotification +{ + BluetoothDeviceAddress deviceAddress; + BluetoothKeypressNotificationType notificationType; +}; + +typedef SInt8 TransmissionPower; + +typedef UInt8 BluetoothAFHMode; +typedef struct BluetoothAFHResults BluetoothAFHResults; +struct BluetoothAFHResults +{ + BluetoothConnectionHandle handle; + BluetoothAFHMode mode; + UInt8 afhMap[10]; +}; + +#endif /* BLUETOOTH_VERSION_MAX_ALLOWED >= BLUETOOTH_VERSION_2_0 */ + +#if BLUETOOTH_VERSION_MAX_ALLOWED >= BLUETOOTH_VERSION_2_1_1 + +typedef UInt32 BluetoothNumericValue; + +typedef struct BluetoothUserConfirmationRequest BluetoothUserConfirmationRequest; +struct BluetoothUserConfirmationRequest +{ + BluetoothDeviceAddress deviceAddress; + BluetoothNumericValue numericValue; /* numeric value for display. valid values are 000000 - 999999 */ +}; + +typedef struct BluetoothHCIEventSimplePairingCompleteResults BluetoothHCIEventSimplePairingCompleteResults; +struct BluetoothHCIEventSimplePairingCompleteResults +{ + BluetoothDeviceAddress deviceAddress; +}; + +#endif /* BLUETOOTH_VERSION_MAX_ALLOWED >= BLUETOOTH_VERSION_2_1_1 */ + + +// Packet Sizes + +enum +{ + kBluetoothHCICommandPacketHeaderSize = 3, + kBluetoothHCICommandPacketMaxDataSize = 255, + kBluetoothHCIMaxCommandPacketSize = kBluetoothHCICommandPacketHeaderSize + kBluetoothHCICommandPacketMaxDataSize, + + kBluetoothHCIEventPacketHeaderSize = 2, + kBluetoothHCIEventPacketMaxDataSize = 255, + kBluetoothHCIMaxEventPacketSize = kBluetoothHCIEventPacketHeaderSize + kBluetoothHCIEventPacketMaxDataSize, + + kBluetoothHCIDataPacketHeaderSize = 4, + kBluetoothHCIDataPacketMaxDataSize = 65535, + kBluetoothHCIMaxDataPacketSize = kBluetoothHCIDataPacketHeaderSize + kBluetoothHCIDataPacketMaxDataSize +}; + +typedef UInt8 BluetoothHCIEventCode; +typedef UInt8 BluetoothLinkType; +enum BluetoothLinkTypes +{ + kBluetoothSCOConnection = 0, + kBluetoothACLConnection = 1, + kBluetoothESCOConnection = 2, + kBluetoothLinkTypeNone = 0xff +}; + +typedef UInt16 BluetoothHCIVoiceSetting; // 10 bits meaningful +typedef UInt8 BluetoothHCISupportedIAC; + +typedef uint32_t BluetoothHCITransmitBandwidth; +typedef uint32_t BluetoothHCIReceiveBandwidth; +typedef uint16_t BluetoothHCIMaxLatency; +typedef uint8_t BluetoothHCIRetransmissionEffort; +enum BluetoothHCIRetransmissionEffortTypes +{ + kHCIRetransmissionEffortTypeNone = 0x00, + kHCIRetransmissionEffortTypeAtLeastOneAndOptimizeForPower = 0x01, + kHCIRetransmissionEffortTypeAtLeastOneAndOptimizeLinkQuality = 0x02, + kHCIRetransmissionEffortTypeDontCare = 0xFF, +}; + + +// Setup Synchronous Packet types (Bluetooth 2.1 spec section 7.7.35 - Setup Synchronous Command Complete Event) + +typedef uint8_t BluetoothAirMode; +enum +{ + kBluetoothAirModeULawLog = 0x00, + kBluetoothAirModeALawLog = 0x01, + kBluetoothAirModeCVSD = 0x02, + kBluetoothAirModeTransparentData = 0x03 +}; + +typedef struct BluetoothSynchronousConnectionInfo BluetoothSynchronousConnectionInfo; +struct BluetoothSynchronousConnectionInfo +{ + BluetoothHCITransmitBandwidth transmitBandWidth; + BluetoothHCIReceiveBandwidth receiveBandWidth; + BluetoothHCIMaxLatency maxLatency; + BluetoothHCIVoiceSetting voiceSetting; + BluetoothHCIRetransmissionEffort retransmissionEffort; + BluetoothPacketType packetType; +}; + +typedef struct BluetoothHCIEventSynchronousConnectionCompleteResults BluetoothHCIEventSynchronousConnectionCompleteResults; +struct BluetoothHCIEventSynchronousConnectionCompleteResults +{ + BluetoothConnectionHandle connectionHandle; + BluetoothDeviceAddress deviceAddress; + BluetoothLinkType linkType; + uint8_t transmissionInterval; + uint8_t retransmissionWindow; + uint16_t receivePacketLength; + uint16_t transmitPacketLength; + BluetoothAirMode airMode; +}; + + +typedef UInt8 BluetoothHCIStatus; +typedef UInt8 BluetoothHCIEventStatus; + +// Events. + +enum +{ + kBluetoothHCIEventInquiryComplete = 0x01, + kBluetoothHCIEventInquiryResult = 0x02, + kBluetoothHCIEventConnectionComplete = 0x03, + kBluetoothHCIEventConnectionRequest = 0x04, + kBluetoothHCIEventDisconnectionComplete = 0x05, + kBluetoothHCIEventAuthenticationComplete = 0x06, + kBluetoothHCIEventRemoteNameRequestComplete = 0x07, + kBluetoothHCIEventEncryptionChange = 0x08, + kBluetoothHCIEventChangeConnectionLinkKeyComplete = 0x09, + kBluetoothHCIEventMasterLinkKeyComplete = 0x0A, + kBluetoothHCIEventReadRemoteSupportedFeaturesComplete = 0x0B, + kBluetoothHCIEventReadRemoteVersionInformationComplete = 0x0C, + kBluetoothHCIEventQoSSetupComplete = 0x0D, + kBluetoothHCIEventCommandComplete = 0x0E, + kBluetoothHCIEventCommandStatus = 0x0F, + kBluetoothHCIEventHardwareError = 0x10, + kBluetoothHCIEventFlushOccurred = 0x11, + kBluetoothHCIEventRoleChange = 0x12, + kBluetoothHCIEventNumberOfCompletedPackets = 0x13, + kBluetoothHCIEventModeChange = 0x14, + kBluetoothHCIEventReturnLinkKeys = 0x15, + kBluetoothHCIEventPINCodeRequest = 0x16, + kBluetoothHCIEventLinkKeyRequest = 0x17, + kBluetoothHCIEventLinkKeyNotification = 0x18, + kBluetoothHCIEventLoopbackCommand = 0x19, + kBluetoothHCIEventDataBufferOverflow = 0x1A, + kBluetoothHCIEventMaxSlotsChange = 0x1B, + kBluetoothHCIEventReadClockOffsetComplete = 0x1C, + kBluetoothHCIEventConnectionPacketType = 0x1D, + kBluetoothHCIEventQoSViolation = 0x1E, + kBluetoothHCIEventPageScanModeChange = 0x1F, + kBluetoothHCIEventPageScanRepetitionModeChange = 0x20, + + // [v1.2] + + kBluetoothHCIEventFlowSpecificationComplete = 0x21, + kBluetoothHCIEventInquiryResultWithRSSI = 0x22, + kBluetoothHCIEventReadRemoteExtendedFeaturesComplete = 0x23, + kBluetoothHCIEventSynchronousConnectionComplete = 0x2C, + kBluetoothHCIEventSynchronousConnectionChanged = 0x2D, + + // [v2.1] + + kBluetoothHCIEventSniffSubstrate = 0x2E, + kBluetoothHCIEventExtendedInquiryResult = 0x2F, + kBluetoothHCIEventIOCapabilityRequest = 0x31, + kBluetoothHCIEventIOCapabilityResponse = 0x32, + kBluetoothHCIEventUserConfirmationRequest = 0x33, + kBluetoothHCIEventUserPasskeyRequest = 0x34, + kBluetoothHCIEventRemoteOOBDataRequest = 0x35, + kBluetoothHCIEventSimplePairingComplete = 0x36, + kBluetoothHCIEventLinkSupervisionTimeoutChanged = 0x38, + kBluetoothHCIEventEnhancedFlushComplete = 0x39, + kBluetoothHCIEventSniffRequest = 0x3A, + kBluetoothHCIEventUserPasskeyNotification = 0x3B, + kBluetoothHCIEventKeypressNotification = 0x3C, + + kBluetoothHCIEventLogoTesting = 0xFE, + kBluetoothHCIEventVendorSpecific = 0xFF +}; + +// HCI Event Masks + +// Event masks are 8 octets according to the spec. v2.1 introduces some event masks that +// actually exceed 32 bits so the 4 byte enum we had before Bluetooth 2.0 will still work for old +// the masks, but the new masks need to be defined as 64 bits. + +typedef uint64_t BluetoothHCIEventMask; + +#define kBluetoothHCIEventMaskDefault64Bit 0x00001FFFFFFFFFFFLL +#define kBluetoothHCIEventMaskAll64Bit 0xFFFFFFFFFFFFFFFFLL + + // [v1.2] + +#define kBluetoothHCIEventMaskFlowSpecificationCompleteEvent 0x0000000100000000LL +#define kBluetoothHCIEventMaskInquiryResultWithRSSIEvent 0x0000000200000000LL +#define kBluetoothHCIEventMaskReadRemoteExtendedFeaturesCompleteEvent 0x0000000400000000LL +#define kBluetoothHCIEventMaskSynchronousConnectionCompleteEvent 0x0000080000000000LL +#define kBluetoothHCIEventMaskSynchronousConnectionChangedEvent 0x0000100000000000LL + + // [v2.1] + +#define kBluetoothHCIEventMaskSniffSubstrateEvent 0x0000200000000000LL +#define kBluetoothHCIEventMaskExtendedInquiryResultEvent 0x0000400000000000LL +#define kBluetoothHCIEventMaskLinkSupervisionTimeoutChangedEvent 0x0080000000000000LL +#define kBluetoothHCIEventMaskEnhancedFlushCompleteEvent 0x0100000000000000LL + + // [v2.1 Secure Simple Pairing] + +#define kBluetoothHCIEventMaskIOCapabilityRequestEvent 0x0001000000000000LL +#define kBluetoothHCIEventMaskIOCapabilityRequestReplyEvent 0x0002000000000000LL +#define kBluetoothHCIEventMaskUserConfirmationRequestEvent 0x0004000000000000LL +#define kBluetoothHCIEventMaskUserPasskeyRequestEvent 0x0008000000000000LL +#define kBluetoothHCIEventMaskRemoteOOBDataRequestEvent 0x0010000000000000LL +#define kBluetoothHCIEventMaskSimplePairingCompleteEvent 0x0020000000000000LL +#define kBluetoothHCIEventMaskUserPasskeyNotificationEvent 0x0400000000000000LL +#define kBluetoothHCIEventMaskKeypressNotificationEvent 0x0800000000000000LL + +enum +{ + kBluetoothHCIEventMaskNone = 0x00000000, + kBluetoothHCIEventMaskInquiryComplete = 0x00000001, + kBluetoothHCIEventMaskInquiryResult = 0x00000002, + kBluetoothHCIEventMaskConnectionComplete = 0x00000004, + kBluetoothHCIEventMaskConnectionRequest = 0x00000008, + kBluetoothHCIEventMaskDisconnectionComplete = 0x00000010, + kBluetoothHCIEventMaskAuthenticationComplete = 0x00000020, + kBluetoothHCIEventMaskRemoteNameRequestComplete = 0x00000040, + kBluetoothHCIEventMaskEncryptionChange = 0x00000080, + kBluetoothHCIEventMaskChangeConnectionLinkKeyComplete = 0x00000100, + kBluetoothHCIEventMaskMasterLinkKeyComplete = 0x00000200, + kBluetoothHCIEventMaskReadRemoteSupportedFeaturesComplete = 0x00000400, + kBluetoothHCIEventMaskReadRemoteVersionInformationComplete = 0x00000800, + kBluetoothHCIEventMaskQoSSetupComplete = 0x00001000, + kBluetoothHCIEventMaskCommandComplete = 0x00002000, + kBluetoothHCIEventMaskCommandStatus = 0x00004000, + kBluetoothHCIEventMaskHardwareError = 0x00008000, + kBluetoothHCIEventMaskFlushOccurred = 0x00010000, + kBluetoothHCIEventMaskRoleChange = 0x00020000, + + kBluetoothHCIEventMaskNumberOfCompletedPackets = 0x00040000, + kBluetoothHCIEventMaskModeChange = 0x00080000, + kBluetoothHCIEventMaskReturnLinkKeys = 0x00100000, + kBluetoothHCIEventMaskPINCodeRequest = 0x00200000, + kBluetoothHCIEventMaskLinkKeyRequest = 0x00400000, + kBluetoothHCIEventMaskLinkKeyNotification = 0x00800000, + kBluetoothHCIEventMaskLoopbackCommand = 0x01000000, + kBluetoothHCIEventMaskDataBufferOverflow = 0x02000000, + kBluetoothHCIEventMaskMaxSlotsChange = 0x04000000, + kBluetoothHCIEventMaskReadClockOffsetComplete = 0x08000000, + kBluetoothHCIEventMaskConnectionPacketTypeChanged = 0x10000000, + kBluetoothHCIEventMaskQoSViolation = 0x20000000, + kBluetoothHCIEventMaskPageScanModeChange = 0x40000000, + kBluetoothHCIEventMaskPageScanRepetitionModeChange = 0x80000000, + + kBluetoothHCIEventMaskAll = 0xFFFFFFFF, + kBluetoothHCIEventMaskDefault = kBluetoothHCIEventMaskAll /* Use kBluetoothHCIEventMaskDefault64Bit above! */ +}; + +// Event results structures. + +typedef struct BluetoothHCIEventConnectionCompleteResults BluetoothHCIEventConnectionCompleteResults; +struct BluetoothHCIEventConnectionCompleteResults +{ + BluetoothConnectionHandle connectionHandle; + BluetoothDeviceAddress deviceAddress; + BluetoothLinkType linkType; + BluetoothHCIEncryptionMode encryptionMode; +}; + +typedef struct BluetoothHCIEventDisconnectionCompleteResults BluetoothHCIEventDisconnectionCompleteResults; +struct BluetoothHCIEventDisconnectionCompleteResults +{ + BluetoothConnectionHandle connectionHandle; + BluetoothReasonCode reason; +}; + +typedef struct BluetoothHCIEventReadSupportedFeaturesResults BluetoothHCIEventReadSupportedFeaturesResults; +struct BluetoothHCIEventReadSupportedFeaturesResults +{ + BluetoothConnectionHandle connectionHandle; + BluetoothHCISupportedFeatures supportedFeatures; +}; + +#if BLUETOOTH_VERSION_MAX_ALLOWED >= BLUETOOTH_VERSION_2_1_1 +typedef struct BluetoothHCIEventReadExtendedFeaturesResults BluetoothHCIEventReadExtendedFeaturesResults; +struct BluetoothHCIEventReadExtendedFeaturesResults +{ + BluetoothConnectionHandle connectionHandle; + BluetoothHCIExtendedFeaturesInfo supportedFeaturesInfo; +}; +#endif /* BLUETOOTH_VERSION_MAX_ALLOWED >= BLUETOOTH_VERSION_2_1_1 */ + +typedef struct BluetoothHCIEventReadRemoteVersionInfoResults BluetoothHCIEventReadRemoteVersionInfoResults; +struct BluetoothHCIEventReadRemoteVersionInfoResults +{ + BluetoothConnectionHandle connectionHandle; + BluetoothLMPVersion lmpVersion; + BluetoothManufacturerName manufacturerName; + BluetoothLMPSubversion lmpSubversion; +}; + +typedef struct BluetoothHCIEventRemoteNameRequestResults BluetoothHCIEventRemoteNameRequestResults; +struct BluetoothHCIEventRemoteNameRequestResults +{ + BluetoothDeviceAddress deviceAddress; + BluetoothDeviceName deviceName; +}; + +typedef struct BluetoothHCIEventReadClockOffsetResults BluetoothHCIEventReadClockOffsetResults; +struct BluetoothHCIEventReadClockOffsetResults +{ + BluetoothConnectionHandle connectionHandle; + BluetoothClockOffset clockOffset; +}; + +typedef struct BluetoothHCIEventConnectionRequestResults BluetoothHCIEventConnectionRequestResults; +struct BluetoothHCIEventConnectionRequestResults +{ + BluetoothDeviceAddress deviceAddress; + BluetoothClassOfDevice classOfDevice; + BluetoothLinkType linkType; +}; + +typedef struct BluetoothHCIEventLinkKeyNotificationResults BluetoothHCIEventLinkKeyNotificationResults; +struct BluetoothHCIEventLinkKeyNotificationResults +{ + BluetoothDeviceAddress deviceAddress; + BluetoothKey linkKey; + BluetoothKeyType keyType; +}; + +typedef struct BluetoothHCIEventMaxSlotsChangeResults BluetoothHCIEventMaxSlotsChangeResults; +struct BluetoothHCIEventMaxSlotsChangeResults +{ + BluetoothConnectionHandle connectionHandle; + BluetoothMaxSlots maxSlots; +}; + +typedef struct BluetoothHCIEventModeChangeResults BluetoothHCIEventModeChangeResults; +struct BluetoothHCIEventModeChangeResults +{ + BluetoothConnectionHandle connectionHandle; + BluetoothHCIConnectionMode mode; + BluetoothHCIModeInterval modeInterval; +}; + +typedef struct BluetoothHCIEventReturnLinkKeysResults BluetoothHCIEventReturnLinkKeysResults; +struct BluetoothHCIEventReturnLinkKeysResults +{ + UInt8 numLinkKeys; + struct { + BluetoothDeviceAddress deviceAddress; + BluetoothKey linkKey; + } linkKeys[1]; +}; + +typedef struct BluetoothHCIEventAuthenticationCompleteResults BluetoothHCIEventAuthenticationCompleteResults; +struct BluetoothHCIEventAuthenticationCompleteResults +{ + BluetoothConnectionHandle connectionHandle; +}; + +typedef struct BluetoothHCIEventEncryptionChangeResults BluetoothHCIEventEncryptionChangeResults; +struct BluetoothHCIEventEncryptionChangeResults +{ + BluetoothConnectionHandle connectionHandle; + BluetoothEncryptionEnable enable; +}; + +typedef struct BluetoothHCIEventChangeConnectionLinkKeyCompleteResults BluetoothHCIEventChangeConnectionLinkKeyCompleteResults; +struct BluetoothHCIEventChangeConnectionLinkKeyCompleteResults +{ + BluetoothConnectionHandle connectionHandle; +}; + +typedef struct BluetoothHCIEventMasterLinkKeyCompleteResults BluetoothHCIEventMasterLinkKeyCompleteResults; +struct BluetoothHCIEventMasterLinkKeyCompleteResults +{ + BluetoothConnectionHandle connectionHandle; + BluetoothKeyFlag keyFlag; +}; + +typedef struct BluetoothHCIEventQoSSetupCompleteResults BluetoothHCIEventQoSSetupCompleteResults; +struct BluetoothHCIEventQoSSetupCompleteResults +{ + BluetoothConnectionHandle connectionHandle; + BluetoothHCIQualityOfServiceSetupParams setupParams; +}; + +typedef struct BluetoothHCIEventHardwareErrorResults BluetoothHCIEventHardwareErrorResults; +struct BluetoothHCIEventHardwareErrorResults +{ + BluetoothHCIStatus error; +}; + +typedef struct BluetoothHCIEventFlushOccurredResults BluetoothHCIEventFlushOccurredResults; +struct BluetoothHCIEventFlushOccurredResults +{ + BluetoothConnectionHandle connectionHandle; +}; + +typedef struct BluetoothHCIEventRoleChangeResults BluetoothHCIEventRoleChangeResults; +struct BluetoothHCIEventRoleChangeResults +{ + BluetoothConnectionHandle connectionHandle; + BluetoothDeviceAddress deviceAddress; + BluetoothRole role; +}; + +typedef struct BluetoothHCIEventDataBufferOverflowResults BluetoothHCIEventDataBufferOverflowResults; +struct BluetoothHCIEventDataBufferOverflowResults +{ + BluetoothLinkType linkType; +}; + +typedef struct BluetoothHCIEventConnectionPacketTypeResults BluetoothHCIEventConnectionPacketTypeResults; +struct BluetoothHCIEventConnectionPacketTypeResults +{ + BluetoothConnectionHandle connectionHandle; + BluetoothPacketType packetType; +}; + +typedef struct BluetoothHCIEventReadRemoteSupportedFeaturesResults BluetoothHCIEventReadRemoteSupportedFeaturesResults; +struct BluetoothHCIEventReadRemoteSupportedFeaturesResults +{ + BluetoothHCIStatus error; + BluetoothConnectionHandle connectionHandle; + BluetoothHCISupportedFeatures lmpFeatures; +}; + +#if BLUETOOTH_VERSION_MAX_ALLOWED >= BLUETOOTH_VERSION_2_1_1 +typedef struct BluetoothHCIEventReadRemoteExtendedFeaturesResults BluetoothHCIEventReadRemoteExtendedFeaturesResults; +struct BluetoothHCIEventReadRemoteExtendedFeaturesResults +{ + BluetoothHCIStatus error; + BluetoothConnectionHandle connectionHandle; + BluetoothHCIPageNumber page; + BluetoothHCIPageNumber maxPage; + BluetoothHCISupportedFeatures lmpFeatures; +}; +#endif /* BLUETOOTH_VERSION_MAX_ALLOWED >= BLUETOOTH_VERSION_2_1_1 */ + +typedef struct BluetoothHCIEventQoSViolationResults BluetoothHCIEventQoSViolationResults; +struct BluetoothHCIEventQoSViolationResults +{ + BluetoothConnectionHandle connectionHandle; +}; + +typedef struct BluetoothHCIEventPageScanModeChangeResults BluetoothHCIEventPageScanModeChangeResults; +struct BluetoothHCIEventPageScanModeChangeResults +{ + BluetoothDeviceAddress deviceAddress; + BluetoothPageScanMode pageScanMode; +}; + +typedef struct BluetoothHCIEventPageScanRepetitionModeChangeResults BluetoothHCIEventPageScanRepetitionModeChangeResults; +struct BluetoothHCIEventPageScanRepetitionModeChangeResults +{ + BluetoothDeviceAddress deviceAddress; + BluetoothPageScanRepetitionMode pageScanRepetitionMode; +}; + +typedef struct BluetoothHCIEventVendorSpecificResults BluetoothHCIEventVendorSpecificResults; +struct BluetoothHCIEventVendorSpecificResults +{ + UInt8 length; + UInt8 data[255]; +}; + +#define kNoNotifyProc NULL +#define kNoUserRefCon NULL + +typedef struct BluetoothHCIRequestCallbackInfo BluetoothHCIRequestCallbackInfo; +struct BluetoothHCIRequestCallbackInfo +{ + mach_vm_address_t userCallback; // Proc to call when async handler is called. + mach_vm_address_t userRefCon; // For user's info. + mach_vm_address_t internalRefCon; // For our purposes. + mach_vm_address_t asyncIDRefCon; // For our aync calls. + mach_vm_address_t reserved; // For the future. Currently Unused. +}; + +// Error codes + +enum +{ + kBluetoothHCIErrorSuccess = 0x00, + kBluetoothHCIErrorUnknownHCICommand = 0x01, + kBluetoothHCIErrorNoConnection = 0x02, + kBluetoothHCIErrorHardwareFailure = 0x03, + kBluetoothHCIErrorPageTimeout = 0x04, + kBluetoothHCIErrorAuthenticationFailure = 0x05, + kBluetoothHCIErrorKeyMissing = 0x06, + kBluetoothHCIErrorMemoryFull = 0x07, + kBluetoothHCIErrorConnectionTimeout = 0x08, + kBluetoothHCIErrorMaxNumberOfConnections = 0x09, + kBluetoothHCIErrorMaxNumberOfSCOConnectionsToADevice = 0x0A, + kBluetoothHCIErrorACLConnectionAlreadyExists = 0x0B, + kBluetoothHCIErrorCommandDisallowed = 0x0C, + kBluetoothHCIErrorHostRejectedLimitedResources = 0x0D, + kBluetoothHCIErrorHostRejectedSecurityReasons = 0x0E, + kBluetoothHCIErrorHostRejectedRemoteDeviceIsPersonal = 0x0F, + kBluetoothHCIErrorHostTimeout = 0x10, + kBluetoothHCIErrorUnsupportedFeatureOrParameterValue = 0x11, + kBluetoothHCIErrorInvalidHCICommandParameters = 0x12, + kBluetoothHCIErrorOtherEndTerminatedConnectionUserEnded = 0x13, + kBluetoothHCIErrorOtherEndTerminatedConnectionLowResources = 0x14, + kBluetoothHCIErrorOtherEndTerminatedConnectionAboutToPowerOff = 0x15, + kBluetoothHCIErrorConnectionTerminatedByLocalHost = 0x16, + kBluetoothHCIErrorRepeatedAttempts = 0x17, + kBluetoothHCIErrorPairingNotAllowed = 0x18, + kBluetoothHCIErrorUnknownLMPPDU = 0x19, + kBluetoothHCIErrorUnsupportedRemoteFeature = 0x1A, + kBluetoothHCIErrorSCOOffsetRejected = 0x1B, + kBluetoothHCIErrorSCOIntervalRejected = 0x1C, + kBluetoothHCIErrorSCOAirModeRejected = 0x1D, + kBluetoothHCIErrorInvalidLMPParameters = 0x1E, + kBluetoothHCIErrorUnspecifiedError = 0x1F, + kBluetoothHCIErrorUnsupportedLMPParameterValue = 0x20, + kBluetoothHCIErrorRoleChangeNotAllowed = 0x21, + kBluetoothHCIErrorLMPResponseTimeout = 0x22, + kBluetoothHCIErrorLMPErrorTransactionCollision = 0x23, + kBluetoothHCIErrorLMPPDUNotAllowed = 0x24, + kBluetoothHCIErrorEncryptionModeNotAcceptable = 0x25, // Added Core Spec, v1.1 + kBluetoothHCIErrorUnitKeyUsed = 0x26, // 1.1 + kBluetoothHCIErrorQoSNotSupported = 0x27, // 1.1 + kBluetoothHCIErrorInstantPassed = 0x28, // 1.1 + kBluetoothHCIErrorPairingWithUnitKeyNotSupported = 0x29, // 1.1 + kBluetoothHCIErrorHostRejectedUnacceptableDeviceAddress = 0x0F, // 2.0+ + kBluetoothHCIErrorDifferentTransactionCollision = 0x2A, // 1.2 + kBluetoothHCIErrorQoSUnacceptableParameter = 0x2C, // 1.2 + kBluetoothHCIErrorQoSRejected = 0x2D, // 1.2 + kBluetoothHCIErrorChannelClassificationNotSupported = 0x2E, // 1.2 + kBluetoothHCIErrorInsufficientSecurity = 0x2F, // 1.2 + kBluetoothHCIErrorParameterOutOfMandatoryRange = 0x30, // 1.2 + kBluetoothHCIErrorRoleSwitchPending = 0x31, // 1.2 + kBluetoothHCIErrorReservedSlotViolation = 0x34, // 1.2 + kBluetoothHCIErrorRoleSwitchFailed = 0x35, // 1.2 + kBluetoothHCIErrorExtendedInquiryResponseTooLarge = 0x36, // 2.1 + kBluetoothHCIErrorSecureSimplePairingNotSupportedByHost = 0x37, // 2.1 + + kBluetoothHCIErrorMax = 0x37 +}; + +#if 0 +#pragma mark === HCI Power Mode === +#endif + +//=========================================================================================================================== +// HCI Power Mode +//=========================================================================================================================== + +typedef enum +{ + kBluetoothHCIPowerStateON = 0x01, + kBluetoothHCIPowerStateOFF = 0x00, + kBluetoothHCIPowerStateUnintialized = 0xFF, +} BluetoothHCIPowerState; + +enum +{ + kBluetoothHCIErrorPowerIsOFF = (kBluetoothHCIErrorMax + 1) +}; + +#if 0 +#pragma mark === HCI USB Transport === +#endif + +//=========================================================================================================================== +// HCI USB Transport +//=========================================================================================================================== + +//--------------------------------------------------------------------------------------------------------------------------- +/*! @enum BluetoothHCIUSBDeviceMatchingConstants + @abstract Bluetooth USB device matching constants + @constant kBluetoothHCITransportUSBClassCode Wireless Controller + @constant kBluetoothHCITransportUSBSubClassCode RF Controller + @constant kBluetoothHCITransportUSBProtocolCode Bluetooth Programming +*/ + +enum +{ + kBluetoothHCITransportUSBClassCode = 0xE0, + kBluetoothHCITransportUSBSubClassCode = 0x01, + kBluetoothHCITransportUSBProtocolCode = 0x01 +}; + +#if 0 +#pragma mark === TCI - L2CAP === +#endif + +//=========================================================================================================================== +// TCI - L2CAP +//=========================================================================================================================== + +enum +{ + kBluetoothL2CAPTCIEventIDReserved = 0x00, + kBluetoothL2CAPTCIEventIDL2CA_ConnectInd = 0x01, + kBluetoothL2CAPTCIEventIDL2CA_ConfigInd = 0x02, + kBluetoothL2CAPTCIEventIDL2CA_DisconnectInd = 0x03, + kBluetoothL2CAPTCIEventIDL2CA_QoSViolationInd = 0x04, + kBluetoothL2CAPTCIEventIDL2CA_TimeOutInd = 0x05 +}; + +enum +{ + kBluetoothL2CAPTCICommandReserved = 0x0000, + kBluetoothL2CAPTCICommandL2CA_ConnectReq = 0x0001, + kBluetoothL2CAPTCICommandL2CA_DisconnectReq = 0x0002, + kBluetoothL2CAPTCICommandL2CA_ConfigReq = 0x0003, + kBluetoothL2CAPTCICommandL2CA_DisableCLT = 0x0004, + kBluetoothL2CAPTCICommandL2CA_EnableCLT = 0x0005, + kBluetoothL2CAPTCICommandL2CA_GroupCreate = 0x0006, + kBluetoothL2CAPTCICommandL2CA_GroupClose = 0x0007, + kBluetoothL2CAPTCICommandL2CA_GroupAddMember = 0x0008, + kBluetoothL2CAPTCICommandL2CA_GroupRemoveMember = 0x0009, + kBluetoothL2CAPTCICommandL2CA_GroupMembership = 0x000A, + kBluetoothL2CAPTCICommandL2CA_WriteData = 0x000B, + kBluetoothL2CAPTCICommandL2CA_ReadData = 0x000C, + kBluetoothL2CAPTCICommandL2CA_Ping = 0x000D, + kBluetoothL2CAPTCICommandL2CA_GetInfo = 0x000E, + kBluetoothL2CAPTCICommandL2CA_Reserved1 = 0x000F, + kBluetoothL2CAPTCICommandL2CA_Reserved2 = 0x0010, + kBluetoothL2CAPTCICommandL2CA_ConnectResp = 0x0011, + kBluetoothL2CAPTCICommandL2CA_DisconnectResp = 0x0012, + kBluetoothL2CAPTCICommandL2CA_ConfigResp = 0x0013 +}; + +#if 0 +#pragma mark - +#pragma mark === RFCOMM === +#endif + +//=========================================================================================================================== +// RFCOMM +//=========================================================================================================================== +#define kMaxChannelIDPerSide 31 + +typedef UInt8 BluetoothRFCOMMChannelID; + +#define RFCOMM_CHANNEL_ID_IS_VALID( CHANNEL ) (( CHANNEL >= 1 ) && ( CHANNEL <= 30 )) + +typedef UInt16 BluetoothRFCOMMMTU; + +typedef enum BluetoothRFCOMMParityType +{ + kBluetoothRFCOMMParityTypeNoParity = 0, + kBluetoothRFCOMMParityTypeOddParity, + kBluetoothRFCOMMParityTypeEvenParity, + kBluetoothRFCOMMParityTypeMaxParity +} BluetoothRFCOMMParityType; + +typedef enum BluetoothRFCOMMLineStatus +{ + BluetoothRFCOMMLineStatusNoError = 0, + BluetoothRFCOMMLineStatusOverrunError, + BluetoothRFCOMMLineStatusParityError, + BluetoothRFCOMMLineStatusFramingError +} BluetoothRFCOMMLineStatus; + +#if 0 +#pragma mark - +#pragma mark === SDP === +#endif + +//=========================================================================================================================== +// SDP +//=========================================================================================================================== + +typedef UInt8 BluetoothSDPPDUID; +enum { + kBluetoothSDPPDUIDReserved = 0, + kBluetoothSDPPDUIDErrorResponse = 1, + kBluetoothSDPPDUIDServiceSearchRequest = 2, + kBluetoothSDPPDUIDServiceSearchResponse = 3, + kBluetoothSDPPDUIDServiceAttributeRequest = 4, + kBluetoothSDPPDUIDServiceAttributeResponse = 5, + kBluetoothSDPPDUIDServiceSearchAttributeRequest = 6, + kBluetoothSDPPDUIDServiceSearchAttributeResponse = 7 +}; + +#define IS_REQUEST_PDU( _pduID ) ( ( _pduID == kBluetoothSDPPDUIDServiceSearchRequest ) || \ + ( _pduID == kBluetoothSDPPDUIDServiceAttributeRequest ) || \ + ( _pduID == kBluetoothSDPPDUIDServiceSearchAttributeRequest ) ) + +#define IS_RESPONSE_PDU( _pduID ) ( ( _pduID == kBluetoothSDPPDUIDErrorResponse ) || \ + ( _pduID == kBluetoothSDPPDUIDServiceSearchResponse ) || \ + ( _pduID == kBluetoothSDPPDUIDServiceAttributeResponse ) || \ + ( _pduID == kBluetoothSDPPDUIDServiceSearchAttributeResponse ) ) + +typedef UInt16 BluetoothSDPErrorCode; +enum { + kBluetoothSDPErrorCodeSuccess = 0x0000, + kBluetoothSDPErrorCodeReserved = 0x0000, + kBluetoothSDPErrorCodeInvalidSDPVersion = 0x0001, + kBluetoothSDPErrorCodeInvalidServiceRecordHandle = 0x0002, + kBluetoothSDPErrorCodeInvalidRequestSyntax = 0x0003, + kBluetoothSDPErrorCodeInvalidPDUSize = 0x0004, + kBluetoothSDPErrorCodeInvalidContinuationState = 0x0005, + kBluetoothSDPErrorCodeInsufficientResources = 0x0006, + + kBluetoothSDPErrorCodeReservedStart = 0x0007, + kBluetoothSDPErrorCodeReservedEnd = 0xFFFF +}; + +typedef UInt16 BluetoothSDPTransactionID; + +typedef UInt32 BluetoothSDPServiceRecordHandle; + +enum { + kBluetoothSDPDataElementTypeNil = 0, + kBluetoothSDPDataElementTypeUnsignedInt = 1, + kBluetoothSDPDataElementTypeSignedInt = 2, + kBluetoothSDPDataElementTypeUUID = 3, + kBluetoothSDPDataElementTypeString = 4, + kBluetoothSDPDataElementTypeBoolean = 5, + kBluetoothSDPDataElementTypeDataElementSequence = 6, + kBluetoothSDPDataElementTypeDataElementAlternative = 7, + kBluetoothSDPDataElementTypeURL = 8, + kBluetoothSDPDataElementTypeReservedStart = 9, + kBluetoothSDPDataElementTypeReservedEnd = 31 +}; + +typedef UInt16 BluetoothSDPUUID16; +typedef UInt32 BluetoothSDPUUID32; + +typedef UInt8 BluetoothSDPDataElementTypeDescriptor; +typedef UInt8 BluetoothSDPDataElementSizeDescriptor; + +typedef UInt16 BluetoothSDPServiceAttributeID; + +#ifdef __cplusplus + } +#endif Index: branches/azimutz/Cleancut/i386/include/IOKit/bluetooth/IOBluetoothHCIController.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/bluetooth/IOBluetoothHCIController.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/bluetooth/IOBluetoothHCIController.h (revision 885) @@ -0,0 +1,1370 @@ +/* + File: IOBluetoothHCIController.h + Contains: Bluetooth Host Controller base class. + Copyright: (c) 2001-2008 by Apple, all rights reserved. +*/ + + +#pragma once + +//==================================================================================================== +// Imports +//==================================================================================================== + +#import +#import +#import +#import + +#import + +#include + +#import + +#import +#import + +//==================================================================================================== +// Forward declarations +//==================================================================================================== + +class OSSet; +class IOWorkLoop; +class IOCommandGate; +class IOWorkQueue; +class IOBluetoothDevice; +class IOBluetoothHCIRequest; +class IOBluetoothHCIController; +class IOBluetoothACLMemoryDescriptor; +class IOTimerEventSource; +class IOBluetoothInactivityTimerEventSource; +class IOBluetoothHCIPacketLogUserClient; + +//==================================================================================================== +// defines, typdefs, etc. +//==================================================================================================== + +#define kNoReturnParam NULL + +typedef uint16_t DevicePublishNotificationStateType; +enum DevicePublishNotificationStateTypes +{ + kHasNotRegisteredForDevicePublishNotification = 0x0001, + kHasRegisteredForDevicePublishNotification = 0x0002, + kDevicePublishNotificationCalled = 0x0004, + kDevicePublishNotificationProcessed = 0x0008 +}; + +typedef UInt32 HCIDataHandlerType; +enum HCIDataHandlerTypes +{ + kTransportDataTypeHCIEvents, + kTransportDataTypeACL, + kTransportDataTypeSCO +}; + +typedef IOReturn (*IOBluetoothIncomingDataAction) ( IOBluetoothHCIController *hciController, UInt8 *inDataPtr, UInt32 inDataSize, UInt32 inSequenceNumber ); +typedef IOReturn (*IOBluetoothHCIControllerDataHandler) ( void * contextPtr, const UInt8 * data, UInt32 dataSize ); + +typedef struct HCIDataHandler HCIDataHandler; +struct HCIDataHandler +{ + IOBluetoothHCIControllerDataHandler procPtr; + void * contextPtr; +}; + +typedef struct HCIEventNotificationListener HCIEventNotificationListener; +struct HCIEventNotificationListener +{ + task_t owningTask; // Used to ID these things when adding/removing them from our listener pool. + mach_port_t port; // Mach port to send out the notificaton. + void * refCon; // RefCon for the port's use. +}; + +#define POWER_STATE_CHANGE_IN_PROGRESS() ( mCurrentInternalPowerState != mPendingInternalPowerState ) +#define IS_POWERING_DOWN() ( POWER_STATE_CHANGE_IN_PROGRESS() && ( mPendingInternalPowerState == kIOBluetoothHCIControllerInternalPowerStateOff ) ) + +//==================================================================================================== +// Callback structure for data: +//==================================================================================================== + +typedef struct SendDataContext +{ + // Data sent: + IOMemoryDescriptor *memoryDescriptorPointer; + + // Referece to the device that sent the data: + IOBluetoothDevice *devicePointer; + void *devicePointerContextInfo0; + void *devicePointerContextInfo1; + + // And the controller that received it: + IOBluetoothHCIController *hciController; + void *controllerPointerContextInfo0; + void *controllerPointerContextInfo1; + + // ReturnValue: + IOReturn sendingWasSuccessful; +} SendDataContext; + + +//==================================================================================================== +// Keep track of hearing devices +//==================================================================================================== +typedef struct HearingDeviceListType +{ + BluetoothDeviceAddress mDeviceAddress; + bool mRemoveDeviceCalled; + DevicePublishNotificationStateType mDevicePublishNotificationState; + HearingDeviceListType * mNextDevice; + HearingDeviceListType * mPreviousDevice; +} HearingDeviceListType; + +//==================================================================================================== +// IOBluetoothHCIController +//==================================================================================================== + +class IOBluetoothHCIController : public IOService +{ + // We don't make many friends, but at least we have a few... + + friend class IOBluetoothHCIPacketLogUserClient; + friend class IOBluetoothSerialManager; + friend class IOBluetoothHCIUserClient; + friend class IOBluetoothDevice; + friend class IOBluetoothHCIRequest; + + // IOKit stuff. + + OSDeclareDefaultStructors( IOBluetoothHCIController ) + +protected: + + IOWorkLoop * mWorkLoop; + IOCommandGate * mCommandGate; + IOWorkQueue * mWorkQueue; + IOTimerEventSource * mTimerEventSource; + Boolean mShouldRunInactivityTimer; + + // Data and request queue stuff. + + HCIEventNotificationListener* mHCIEventListenersList; + size_t mHCIEventListenersListSize; + HCIDataHandler* mHCIEventDataHandlerList; + size_t mHCIEventDataHandlerListSize; + HCIDataHandler* mACLDataHandlerList; + size_t mACLDataHandlerListSize; + HCIDataHandler* mSCODataHandlerList; + size_t mSCODataHandlerListSize; + + IOBluetoothHCIRequest * mBusyQueueHead; + IOBluetoothHCIRequest * mWaitQueueHead; + IOBluetoothHCIRequest ** mHCIRequestList; + + IOBluetoothDevice * mDeviceListHead; + + OSSet * mPacketLogClients; + UInt8 * mPacketLogBuffer; + UInt32 mPacketLogBufferSize; + + uint8_t * mEventDataBuffer; // Events without matching requests will use this. + size_t mEventDataBufferSize; + + // This keeps track of the ACL packets we actually sent: + BluetoothHCIBufferSize mHCIBufferSize; + UInt16 mNumOutstandingACLPackets; + + OSArray * mAllowedIncomingL2CAPChannels; + + UInt32 mNextAvailableSequenceNumber; + UInt32 mCurrentlyExecutingSequenceNumber; + UInt16 mActiveConnections; + + // Packet Queue description: + typedef struct QueuePacketHolder { + IOMemoryDescriptor *memDescriptor; // The data we need to send + SendDataContext * contextPtr; // Context pointer for the sent data. + IOBluetoothDevice * inTargetDevice; // The device that enqueued the data. + struct QueuePacketHolder *next; // The next block in the queue. + } QueuePacketHolder; + QueuePacketHolder *mACLQueueHead, *mACLQueueTail; + + // Counters to limit the number of packets in the queue (we do not want to go out of memory) + UInt32 mNumberOfPacketsInQueue; + + // The allowed RFCOMM channels + OSArray *mAllowedIncomingRFCOMMChannels; + + IOBluetoothHCIControllerInternalPowerState mCurrentInternalPowerState; + IOBluetoothHCIControllerInternalPowerState mPendingInternalPowerState; + Boolean mAsyncPowerStateChangeInProgress; + UInt32 mPendingPowerStateChangeOptions; + IOBluetoothHCIControllerPowerOptions mControllerPowerOptions; + Boolean mPowerStateChangeIsUserEnforced; + + Boolean mHardwareSetupComplete; + + IOBluetoothHCIControllerConfigState mControllerConfigState; + IOBluetoothHCIControllerConfigState mPreviousControllerConfigState; + + IOBluetoothHCIControllerFeatureFlags mControllerFeatureFlags; + + // Overrides. + + bool start( IOService * provider ); + + bool init( OSDictionary* dictionary ); + + virtual void free(); + +#if defined( MAC_OS_X_VERSION_10_5 ) + virtual void systemWillShutdown( IOOptionBits specifier ); +#endif + + static IOReturn initHardwareAction( OSObject *owner, + void *arg1, + void *arg2, + void *arg3, + void *arg4 ); + + virtual bool initHardware( IOService * provider ); + + static IOReturn setupHardwareAction( OSObject *owner, + void *arg1, + void *arg2, + void *arg3, + void *arg4 ); + + virtual IOReturn setupHardware( IOService* provider ); + + virtual void hardwareSetupComplete( IOReturn status ); + + virtual void setConfigState( IOBluetoothHCIControllerConfigState configState ); + virtual bool terminate( IOOptionBits options = 0 ); + virtual bool willTerminate( IOService * provider, IOOptionBits options ); + virtual bool didTerminate( IOService * provider, IOOptionBits options, bool * defer ); + + void stop( IOService * provider ); + + IOReturn newUserClient( task_t owningTask, + void * securityID, + UInt32 type, + IOUserClient ** handler ); + + uint32_t CountExistingHCIControllers(); + + virtual IOReturn powerStateWillChangeTo( IOPMPowerFlags powerFlags, + unsigned long powerState, + IOService * from ); + + virtual unsigned long maxCapabilityForDomainState( IOPMPowerFlags domainState ); + + virtual unsigned long initialPowerStateForDomainState ( IOPMPowerFlags powerFlags ); + + // Our protected custom stuff. + + static IOReturn DetachUserClientsAction( OSObject *owner, + void *arg1, + void *arg2, + void *arg3, + void *arg4 ); + + virtual void DetachUserClients(); + + static IOReturn setPropertiesAction( OSObject *owner, + void *arg1, + void *arg2, + void *arg3, + void *arg4 ); + + virtual IOReturn setPropertiesWL( OSObject * properties ); + + static IOReturn AddPacketLogUserClientAction( OSObject *owner, + void *arg1, + void *arg2, + void *arg3, + void *arg4 ); + + virtual IOReturn AddPacketLogUserClient( IOBluetoothHCIPacketLogUserClient *newPacketLogUserClient ); + + virtual bool PacketLogFillBufferedData(); + + virtual void PacketLogClientClosed( IOBluetoothHCIPacketLogUserClient *packetLogClient ); + + virtual void LogPacket( UInt8 packetType, void *packetData, size_t packetSize ); + + static IOReturn LogPacketAction( OSObject *owner, void *arg1, void *arg2, void *arg3, void *arg4 ); + + virtual void DesyncIncomingData( IOBluetoothIncomingDataAction action, UInt8 *inDataPtr, UInt32 inDataSize ); + + static void DesyncIncomingDataAction( IOBluetoothHCIController *hciController, IOBluetoothIncomingDataAction action, void *inDataPtr, UInt32 inDataSize, UInt32 sequenceNumber ); + + virtual void SynchronizePacketSequence( UInt32 sequenceNumber ); + + virtual IOReturn AddDevice( IOBluetoothDevice *inDevice ); + + virtual IOReturn RemoveDevice( IOBluetoothDevice *inDevice ); + + virtual IOReturn CreateDeviceFromConnectionResults( BluetoothHCIEventConnectionCompleteResults *connectionResults ); + + virtual IOReturn DestroyDeviceWithDisconnectionResults( BluetoothHCIEventDisconnectionCompleteResults *disconnectionResults ); + + virtual IOReturn DestroyDevice( IOBluetoothDevice *inDevice ); + + virtual IOReturn DestroyAllDevices(); + + virtual void FlushDeviceACLPackets( IOBluetoothDevice *inDevice ); + + virtual void DecrementOutstandingACLPackets( UInt16 delta ); + + virtual void ProcessFlushOccurredEvent( BluetoothHCIEventFlushOccurredResults *inFlushResults ); + + virtual void ProcessNumCompletedPacketsEvent( UInt8 *inDataPtr ); + + virtual void ProcessHCIControllerResetEvent(); + + virtual IOReturn DispatchIncomingACLData( UInt8 *inDataPtr, UInt32 inDataSize ); + + // Common methods for L2CAP and RFCOMM channel managment: + virtual void MergeChannelDescription(OSDictionary *destination , OSDictionary *source); + virtual void RemoveChannelRestrictions(OSDictionary *toChange , OSDictionary *removeRule, const char *key); + virtual Boolean IsAllowedDevice(OSDictionary *description , IOBluetoothDevice *device); + virtual void RemoveAllRules(); + + // L2CAP channel managment methods: + virtual void RemoveAllowedIncomingL2CAPChannel( OSObject *channelID ); + virtual IOReturn AddAllowedIncomingL2CAPChannel( OSDictionary *channelDescription ); + virtual OSDictionary *GetIncomingL2CAPChannelDescription( OSNumber *psmNumber ); + + // L2CAP channel accessory methods: + virtual void AddAllowedIncomingL2CAPChannel( BluetoothL2CAPPSM incomingPSM ); + virtual void AddAllowedIncomingL2CAPChannel( OSNumber *psmNumber ); + virtual void RemoveAllowedIncomingL2CAPChannel( BluetoothL2CAPPSM incomingPSM ); + + // RFCOMM channel managment methods: + virtual OSDictionary *GetIncomingRFCOMMChannelDescription( OSNumber *channelIDNumber ); + virtual IOReturn AddAllowedIncomingRFCOMMChannel( OSDictionary *channelDescription ); + virtual void RemoveAllowedIncomingRFCOMMChannel( OSObject *channelID ); + + // RFCOMM channel accessory methods: + virtual void AddAllowedIncomingRFCOMMChannel( BluetoothRFCOMMChannelID incomingChannelID ); + virtual void AddAllowedIncomingRFCOMMChannel( OSNumber *channelIDNumber ); + virtual void AddSecureIncomingRFCOMMChannel( BluetoothRFCOMMChannelID incomingChannelID ); + virtual void AddSecureIncomingRFCOMMChannel( OSNumber *channelIDNumber ); + virtual void RemoveAllowedIncomingRFCOMMChannel( BluetoothRFCOMMChannelID incomingChannelID ); + + virtual IOReturn TransferACLPacketToHW(IOMemoryDescriptor *memDescriptor, + SendDataContext * contextPtr); + + // ACL Packet queue: + virtual IOReturn EnqueuePacket( IOMemoryDescriptor *memDescriptor, + SendDataContext *contextPtr, + IOBluetoothDevice *inTargetDevice); + + virtual IOReturn DequeuePacket(); + + virtual IOReturn RemoveAllPacketsBelongingTo(IOBluetoothDevice *inTargetDevice); + +public: + + // IOWorkLoop and IOCommandGate accessors + + virtual IOWorkLoop *getWorkLoop() const; + + virtual IOCommandGate *getCommandGate() const; + + virtual IOReturn setProperties( OSObject * properties ); + + // Subclasses must implement these for it to be a working transport + // in the Bluetooth Family world. + + virtual IOReturn SendHCIRequest( UInt8 * buffer, + IOByteCount bufferSize ); + + static IOReturn SendACLCompletedAction ( OSObject *owner, void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6 ); + + virtual void SendACLCompleted( SendDataContext *contextPtr); + + virtual IOReturn SendACLData( IOMemoryDescriptor *memDescriptor, + SendDataContext * contextPtr ); + + virtual IOReturn GetTransportInfo( BluetoothTransportInfo * infoStruct ); + + static IOReturn SendSCOCompletedAction ( OSObject *owner, void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6 ); + + // Override to do something custom with the data. Otherwise, the registered data handler + // will get a peek at it. + + // The ProcessXXXData() functions are safe to be called from anywhere. + // They call ProcessXXXDataWL() on the workloop using ProcessXXXDataAction() + + virtual void ProcessEventData( UInt8 * inDataPtr, UInt32 inDataSize ); + + virtual void ProcessACLData( UInt8 * data, UInt32 dataSize ); + + virtual void ProcessSCOData( UInt8 * data, UInt32 dataSize, UInt32 inMissingData, AbsoluteTime inTimestamp, Boolean copyData ); + + virtual void ProcessEventDataWL( UInt8 * inDataPtr, UInt32 inDataSize, UInt32 sequenceNumber ); + + virtual void ProcessACLDataWL( UInt8 * data, UInt32 dataSize, UInt32 sequenceNumber ); + + virtual void ProcessSCODataWL( UInt8 * data, UInt32 dataSize, UInt32 inMissingData, AbsoluteTime inTimestamp, Boolean copyData ); + + static IOReturn ProcessEventDataAction( IOBluetoothHCIController * hciController, + UInt8 * incomingDataPtr, + UInt32 inDataSize, + UInt32 inSequenceNumber ); + + static IOReturn ProcessACLDataAction( IOBluetoothHCIController * hciController, + UInt8 * incomingDataPtr, + UInt32 inDataSize, + UInt32 inSequenceNumber ); + + // The following is only a "ghost" call and exists only to make the compiler happy, its implementation + // does not do anything. + static IOReturn ProcessSCODataAction( IOBluetoothHCIController * hciController, + UInt8 * incomingDataPtr, + UInt32 inDataSize, + UInt32 inMissingData, + UInt32 inTimestampHi, + UInt32 inTimestampLo, + Boolean inCopyData ); + + static IOReturn ProcessSCODataActionAT( IOBluetoothHCIController * hciController, + UInt8 * incomingDataPtr, + UInt32 inDataSize, + UInt32 inMissingData, + AbsoluteTime* inTimestamp, + Boolean inCopyData ); + + // Data processing helpers. + + virtual bool GetCompleteCodeForCommand( BluetoothHCICommandOpCode inOpCode, + BluetoothHCIEventCode *outEventCode ); + + virtual bool GetOpCodeAndEventCode( UInt8 * inDataPtr, + BluetoothHCICommandOpCode * outOpCode, + BluetoothHCIEventCode * eventCode, + BluetoothHCIEventStatus * outStatus, + BluetoothDeviceAddress * outDeviceAddress, + BluetoothConnectionHandle * outConnectionHandle ); + + virtual IOReturn FindConnectionCompleteType( BluetoothHCICommandOpCode * outOpCode ); + + virtual IOReturn HandleSpecialOpcodes( BluetoothHCICommandOpCode opCode ); + + // This is a hook for other interested parties to get HCI event notifications. When a user client is created, + // that mach_port_t will be passed on to us via these calls so that their port will get HCI events that aren't + // specifically tied to a requst object, but occur due to requests they make. + + virtual IOReturn AddHCIEventNotification( task_t inOwningTask, mach_port_t inPort, void * refCon ); + + virtual void BroadcastEventNotification( BluetoothHCIRequestID inID, + BluetoothHCIEventCode inEventCode, + IOReturn eventStatus, + UInt8 * inDataToSendPtr, + IOByteCount inDataSize, + BluetoothHCICommandOpCode inOpCode ); + + virtual void BroadcastConfigStateChangeNotification( IOBluetoothHCIControllerConfigState oldState, + IOBluetoothHCIControllerConfigState newState ); + + virtual IOReturn RemoveHCIEventNotification( task_t inOwningTask ); + + // This is a hook for other interested parties to get data from transports. They will register itself + // with these to receive the raw data from the transport, bypassing HCI code. + + virtual IOReturn AddDataClient( HCIDataHandlerType inType, + IOBluetoothHCIControllerDataHandler inProcPtr, + void * inContextPtr ); + + virtual IOReturn NotifyDataClients( HCIDataHandlerType inType, UInt8 * inDataPtr, UInt32 inDataSize ); + + virtual IOReturn RemoveDataClient( HCIDataHandlerType inType, IOBluetoothHCIControllerDataHandler inProcPtr ); + + // Request creation, deletion and other data processing stuff. + + virtual IOReturn HCIRequestCreate( BluetoothHCIRequestID * outRequestID, + bool inDoAsyncNotify = TRUE, + UInt32 inTimeout = 5, + BluetoothHCIRequestCallbackInfo * inCallbackInfo = NULL, + task_t inTaskID = 0, + UInt32 inControlFlags = 0 ); + + virtual IOReturn HCIRequestDelete( task_t inTask, BluetoothHCIRequestID inID ); + + virtual IOReturn LookupRequest( BluetoothHCIRequestID inID, IOBluetoothHCIRequest ** outRequestPtr ); + + virtual IOReturn PrepareRequestForNewCommand( BluetoothHCIRequestID inID, + const BluetoothDeviceAddress * inDeviceAddress, + BluetoothConnectionHandle inConnectionHandle ); + + virtual IOReturn EnqueueRequest( IOBluetoothHCIRequest * inRequestPtr ); + + virtual IOReturn FindQueuedRequest( BluetoothHCICommandOpCode opCode, + BluetoothDeviceAddress * inDeviceAddress, + BluetoothConnectionHandle inConnectionHandle, + Boolean inUseAttributes, + IOBluetoothHCIRequest ** outRequestPtr ); + + virtual IOReturn DequeueRequest( IOBluetoothHCIRequest * inRequestPtr ); + + virtual IOReturn EnqueueWaitRequest( IOBluetoothHCIRequest * inRequestPtr ); + + virtual IOReturn FindQueuedWaitRequest( BluetoothHCICommandOpCode opCode, IOBluetoothHCIRequest ** outRequestPtr ); + + virtual IOReturn DequeueWaitRequest( IOBluetoothHCIRequest * inRequestPtr ); + + virtual IOReturn AbortRequest( IOBluetoothHCIRequest * inRequestPtr ); + + virtual IOReturn FindNextExpiringRequest( BluetoothHCICommandOpCode opCode, IOBluetoothHCIRequest ** outRequestPtr ); + + virtual IOReturn ProcessWaitingRequests(); + + inline IOBluetoothHCIRequest* GetNextWaitRequest() { return( mWaitQueueHead ); } + + inline IOBluetoothHCIRequest* GetNextBusyRequest() { return( mBusyQueueHead ); } + + virtual void TakeAHexDump( const void *inData, UInt32 inDataSize ); + + virtual IOReturn DumpStats(); + + virtual IOBluetoothHCIControllerPowerOptions GetControllerPowerOptions(); + virtual IOBluetoothHCIControllerInternalPowerState GetControllerPowerState(); + virtual IOReturn WaitForControllerPowerState( IOBluetoothHCIControllerInternalPowerState powerState ); + + virtual IOReturn RequestPowerStateChange( IOBluetoothHCIControllerInternalPowerState newPowerState ); + + virtual IOReturn SendHCIRequestFormatted( BluetoothHCIRequestID inID, + BluetoothHCICommandOpCode inOpCode, + IOByteCount outResultsSize, + void * outResultsPtr, + const char * inFormat, + ... ); + + static void RequestExpired( OSObject *owner, IOTimerEventSource *sender ); + + // Misc stuff. + + IOReturn DisposeRequestsForTaskID( task_t inTaskID ); + + IOReturn KillAllPendingRequests( Boolean destroy, Boolean includeIdleRequests ); + void SendingRequest( IOBluetoothHCIRequest *requestPtr ); + void DecrementActiveConnections( ); + + virtual void ActiveConnectionsInProgress( ); + virtual void AllConnectionsGone( ); + + virtual IOReturn SendRawHCICommand( BluetoothHCIRequestID inID, + char * buffer, + UInt32 bufferSize ); + + // Vendor Specific stuff. + + virtual IOReturn VendorCommand( BluetoothHCIRequestID inID, + BluetoothHCIVendorCommandSelector inSelector, + UInt8 * inCommandData, + IOByteCount inCommandDataSize, + IOByteCount outBufferSize, + UInt8 * outBuffer ); + + // IOBluetoothDevice object management + + virtual IOBluetoothDevice * FindDeviceWithHandle( BluetoothConnectionHandle inConnectionHandle ); + + virtual IOBluetoothDevice * FindDeviceWithAddress( const BluetoothDeviceAddress *inDeviceAddress ); + + virtual IOReturn SendACLPacket( IOBluetoothACLMemoryDescriptor *memDescriptor, + SendDataContext * contextPtr, + IOBluetoothDevice * inTargetDevice = NULL ); + + + // API for the serial manager to open a new connection + + virtual IOBluetoothDevice *OpenDeviceConnection( const BluetoothDeviceAddress *inDeviceAddress ); + + static IOReturn OpenDeviceConnectionAction( OSObject *owner, + void *arg1, + void *arg2, + void *arg3, + void *arg4 ); + + virtual IOBluetoothDevice *OpenDeviceConnectionWL( const BluetoothDeviceAddress *inDeviceAddress ); + + // API to track the secure state of RFCOMM channels + virtual Boolean IsSecureIncomingRFCOMMChannel( BluetoothRFCOMMChannelID incomingChannelID ); + virtual Boolean IsSecureIncomingRFCOMMChannel( OSNumber *channelIDNumber ); + + // API to track allowed incoming L2CAP and RFCOMM channels given a device: + virtual Boolean IsAllowedIncomingL2CAPChannelForDevice( BluetoothL2CAPPSM incomingPSM, IOBluetoothDevice *device ); + virtual Boolean IsAllowedIncomingRFCOMMChannelForDevice( BluetoothRFCOMMChannelID incomingChannelID, IOBluetoothDevice *device ); + + // Enabled state for RFCOMM channels: + virtual void SetEnabledIncomingRFCOMMChannel( OSNumber *channelIDNumber, bool ShouldBeEnabled); + virtual void SetEnabledIncomingRFCOMMChannel( BluetoothRFCOMMChannelID incomingChannelID, bool ShouldBeEnabled); + + virtual Boolean ShouldRunInactivityTimer(); // NOT USED: See StartIdleTimer + virtual void SetRunInactivityTimer( Boolean shouldRun ); // NOT USED: See StopIdleTimer + + //============================ + + // From here on out, we implement each of the commands in the HCI spec. You can work around + // hardware bugs by overriding any of these functions if necessary. + + + // Link Control Commands. + + virtual IOReturn BluetoothHCIInquiry( BluetoothHCIRequestID inID, + BluetoothLAP inLAP, + BluetoothHCIInquiryLength inInquiryLength, + BluetoothHCIResponseCount inMaxResponseCount, + BluetoothHCIInquiryResults * outResults ); + + virtual IOReturn BluetoothHCIInquiryCancel( BluetoothHCIRequestID inID ); + + virtual IOReturn BluetoothHCIPeriodicInquiryMode( BluetoothHCIRequestID inID, + BluetoothHCIInquiryLength inMaxPeriodLength, + BluetoothHCIInquiryLength inMinPeriodLength, + BluetoothLAP inLAP, + BluetoothHCIInquiryLength inInquiryLength, + BluetoothHCIResponseCount inMaxResponses, + BluetoothHCIInquiryResults * outResults ); + + virtual IOReturn BluetoothHCIExitPeriodicInquiryMode( BluetoothHCIRequestID inID ); + + virtual IOReturn BluetoothHCICreateConnection( BluetoothHCIRequestID inID, + const BluetoothDeviceAddress * inAddressPtr, + BluetoothPacketType inPacketType, + BluetoothPageScanRepetitionMode inPageScanRepetitionMode, + BluetoothPageScanMode inPageScanMode, + BluetoothClockOffset inClockOffset, + BluetoothAllowRoleSwitch inAllowRoleSwitch, + BluetoothHCIEventConnectionCompleteResults *outConnectionHandle ); + + virtual IOReturn BluetoothHCIDisconnect( BluetoothHCIRequestID inID, + BluetoothConnectionHandle inConnectionHandle, + BluetoothReasonCode inReason, + BluetoothHCIEventDisconnectionCompleteResults * outResults ); + + virtual IOReturn BluetoothHCIAddSCOConnection( BluetoothHCIRequestID inID, + BluetoothConnectionHandle inACLConnectionHandle, + BluetoothPacketType inPacketType ); + + virtual IOReturn BluetoothHCIAcceptConnectionRequest( BluetoothHCIRequestID inID, + const BluetoothDeviceAddress * inAddressPtr, + BluetoothRole inRole ); + + virtual IOReturn BluetoothHCIRejectConnectionRequest( BluetoothHCIRequestID inID, + const BluetoothDeviceAddress * inAddressPtr, + BluetoothReasonCode inReason ); + + virtual IOReturn BluetoothHCILinkKeyRequestReply( BluetoothHCIRequestID inID, + const BluetoothDeviceAddress * inAddressPtr, + const BluetoothKey * inKeyPtr, + BluetoothDeviceAddress * outAddress ); + + virtual IOReturn BluetoothHCILinkKeyRequestNegativeReply( BluetoothHCIRequestID inID, + const BluetoothDeviceAddress * inAddressPtr, + BluetoothDeviceAddress * outAddress ); + + virtual IOReturn BluetoothHCIPINCodeRequestReply( BluetoothHCIRequestID inID, + const BluetoothDeviceAddress * inAddressPtr, + IOByteCount inPINCodeSize, + const BluetoothPINCode * inPINCode, + BluetoothDeviceAddress * outAddress ); + + virtual IOReturn BluetoothHCIPINCodeRequestNegativeReply( BluetoothHCIRequestID inID, + const BluetoothDeviceAddress * inAddressPtr, + BluetoothDeviceAddress * outAddress ); + + virtual IOReturn BluetoothHCIChangeConnectionPacketType( BluetoothHCIRequestID inID, + BluetoothConnectionHandle inConnectionHandle, + BluetoothPacketType inPacketType ); + + virtual IOReturn BluetoothHCIAuthenticationRequested( BluetoothHCIRequestID inID, + BluetoothConnectionHandle inConnectionHandle ); + + virtual IOReturn BluetoothHCISetEncryptionEnable( BluetoothHCIRequestID inID, + BluetoothConnectionHandle inConnectionHandle, + BluetoothEncryptionEnable inEncryptionEnable ); + + virtual IOReturn BluetoothHCIChangeConnectionLinkKey( BluetoothHCIRequestID inID, + BluetoothConnectionHandle inConnectionHandle ); + + virtual IOReturn BluetoothHCIMasterLinkKey( BluetoothHCIRequestID inID, + BluetoothKeyFlag inKeyFlag ); + + virtual IOReturn BluetoothHCIRemoteNameRequest( BluetoothHCIRequestID inID, + const BluetoothDeviceAddress * inAddressPtr, + BluetoothPageScanRepetitionMode inPageScanRepetitionMode, + BluetoothPageScanMode inPageScanMode, + BluetoothClockOffset inClockOffset, + BluetoothHCIEventRemoteNameRequestResults * outName ); + + virtual IOReturn BluetoothHCIReadRemoteSupportedFeatures( BluetoothHCIRequestID inID, + BluetoothConnectionHandle inConnectionHandle, + BluetoothHCIEventReadRemoteSupportedFeaturesResults * outFeatures ); + + virtual IOReturn BluetoothHCIReadRemoteVersionInformation( BluetoothHCIRequestID inID, + BluetoothConnectionHandle inConnectionHandle, + BluetoothHCIEventReadRemoteVersionInfoResults * outVersionInfo ); + + virtual IOReturn BluetoothHCIReadClockOffset( BluetoothHCIRequestID inID, + BluetoothConnectionHandle inConnectionHandle, + BluetoothClockOffset * outClockOffset ); + + // Link Policy commands. + + virtual IOReturn BluetoothHCIHoldMode( BluetoothHCIRequestID inID, + BluetoothConnectionHandle inConnectionHandle, + BluetoothHCIModeInterval inHoldModeMaxInterval, + BluetoothHCIModeInterval inHoldModeMinInterval ); + + virtual IOReturn BluetoothHCISniffMode( BluetoothHCIRequestID inID, + BluetoothConnectionHandle inConnectionHandle, + BluetoothHCIModeInterval inSniffModeMaxInterval, + BluetoothHCIModeInterval inSniffModeMinInterval, + BluetoothHCISniffAttemptCount inSniffAttemptCount, + BluetoothHCISniffTimeout inSniffModeTimeout ); + + virtual IOReturn BluetoothHCIExitSniffMode( BluetoothHCIRequestID inID, + BluetoothConnectionHandle inConnectionHandle ); + + virtual IOReturn BluetoothHCIParkMode( BluetoothHCIRequestID inID, + BluetoothConnectionHandle inConnectionHandle, + BluetoothHCIParkModeBeaconInterval inMaxInterval, + BluetoothHCIParkModeBeaconInterval inMinInterval ); + + virtual IOReturn BluetoothHCIExitParkMode( BluetoothHCIRequestID inID, + BluetoothConnectionHandle inConnectionHandle ); + + virtual IOReturn BluetoothHCIQualityOfServiceSetup( BluetoothHCIRequestID inID, + BluetoothConnectionHandle inConnectionHandle, + BluetoothHCIQualityOfServiceSetupParams * inSetupPtr ); + + virtual IOReturn BluetoothHCIRoleDiscovery( BluetoothHCIRequestID inID, + BluetoothConnectionHandle inConnectionHandle, + BluetoothHCIRoleInfo * outRoleInfo ); + + virtual IOReturn BluetoothHCISwitchRole( BluetoothHCIRequestID inID, + BluetoothDeviceAddress * inAddressPtr, + BluetoothHCIRole inNewRole ); + + virtual IOReturn BluetoothHCIReadLinkPolicySettings( BluetoothHCIRequestID inID, + BluetoothConnectionHandle inConnectionHandle, + BluetoothHCILinkPolicySettingsInfo * outSettingsInfo ); + + virtual IOReturn BluetoothHCIWriteLinkPolicySettings( BluetoothHCIRequestID inID, + BluetoothConnectionHandle inConnectionHandle, + BluetoothHCILinkPolicySettings inSettings, + BluetoothConnectionHandle * outConnectionHandle ); + + // Host controller and baseband commands. + + virtual IOReturn BluetoothHCISetEventMask( BluetoothHCIRequestID inID, + BluetoothSetEventMask * inMask ); + + virtual IOReturn BluetoothHCIReset( BluetoothHCIRequestID inID ); + + virtual IOReturn BluetoothHCISetEventFilter( BluetoothHCIRequestID inID ); + + virtual IOReturn BluetoothHCIFlush( BluetoothHCIRequestID inID, + BluetoothConnectionHandle inHandle ); + + virtual IOReturn BluetoothHCIReadPINType( BluetoothHCIRequestID inID, + BluetoothPINType * outType ); + + virtual IOReturn BluetoothHCIWritePINType( BluetoothHCIRequestID inID, + BluetoothPINType inType ); + + virtual IOReturn BluetoothHCICreateNewUnitKey( BluetoothHCIRequestID inID ); + + virtual IOReturn BluetoothHCIReadStoredLinkKey( BluetoothHCIRequestID inID, + BluetoothDeviceAddress * targetDevice, + BluetoothHCIReadStoredLinkKeysFlag * inFlags, + BluetoothHCIStoredLinkKeysInfo * outKeysInfo ); + + virtual IOReturn BluetoothHCIWriteStoredLinkKey( BluetoothHCIRequestID inID, + IOItemCount inNumKeysToWrite, + BluetoothDeviceAddress inDeviceAddresses[], + BluetoothKey inLinkKeys[], + BluetoothHCINumLinkKeysToWrite * outNumKeysWritten ); + + virtual IOReturn BluetoothHCIDeleteStoredLinkKey( BluetoothHCIRequestID inID, + BluetoothDeviceAddress * targetDevice, + BluetoothHCIDeleteStoredLinkKeyFlag * inFlag, + BluetoothHCINumLinkKeysDeleted * outNumDeleted ); + + virtual IOReturn BluetoothHCIReadLocalName( BluetoothHCIRequestID inID, + BluetoothDeviceName name ); + + virtual IOReturn BluetoothHCIChangeLocalName( BluetoothHCIRequestID inID, + BluetoothDeviceName newName ); + + virtual IOReturn BluetoothHCIReadConnectionAcceptTimeout( BluetoothHCIRequestID inID, + BluetoothHCIConnectionAcceptTimeout * outTimeout ); + + virtual IOReturn BluetoothHCIWriteConnectionAcceptTimeout( BluetoothHCIRequestID inID, + BluetoothHCIConnectionAcceptTimeout inTimeout ); + + virtual IOReturn BluetoothHCIReadPageTimeout( BluetoothHCIRequestID inID, + BluetoothHCIPageTimeout * outDataPtr ); + + virtual IOReturn BluetoothHCIWritePageTimeout( BluetoothHCIRequestID inID, + BluetoothHCIPageTimeout inTimeout ); + + virtual IOReturn BluetoothHCIReadScanEnable( BluetoothHCIRequestID inID, + BluetoothHCIPageScanEnableState * outState ); + + virtual IOReturn BluetoothHCIWriteScanEnable( BluetoothHCIRequestID inID, + BluetoothHCIPageScanEnableState inState ); + + virtual IOReturn BluetoothHCIReadPageScanActivity( BluetoothHCIRequestID inID, + BluetoothHCIScanActivity * outActivityInfo ); + + virtual IOReturn BluetoothHCIWritePageScanActivity( BluetoothHCIRequestID inID, + BluetoothHCIScanActivity * inActivityInfo ); + + virtual IOReturn BluetoothHCIReadInquiryScanActivity( BluetoothHCIRequestID inID, + BluetoothHCIScanActivity * outActivityInfo ); + + virtual IOReturn BluetoothHCIWriteInquiryScanActivity( BluetoothHCIRequestID inID, + BluetoothHCIScanActivity * inActivityInfo ); + + virtual IOReturn BluetoothHCIReadAuthenticationEnable( BluetoothHCIRequestID inID, + BluetoothHCIAuthenticationEnable * outAuthenticationState ); + + virtual IOReturn BluetoothHCIWriteAuthenticationEnable( BluetoothHCIRequestID inID, + BluetoothHCIAuthenticationEnable inAuthenticationState ); + + virtual IOReturn BluetoothHCIReadEncryptionMode( BluetoothHCIRequestID inID, + BluetoothHCIEncryptionMode * outEncryptionState ); + + virtual IOReturn BluetoothHCIWriteEncryptionMode( BluetoothHCIRequestID inID, + BluetoothHCIEncryptionMode inEncryptionMode ); + + virtual IOReturn BluetoothHCIReadClassOfDevice( BluetoothHCIRequestID inID, + BluetoothClassOfDevice * outClassOfDevice ); + + virtual IOReturn BluetoothHCIWriteClassOfDevice( BluetoothHCIRequestID inID, + BluetoothClassOfDevice inClassOfDevice ); + + virtual IOReturn BluetoothHCIReadVoiceSetting( BluetoothHCIRequestID inID, + BluetoothHCIVoiceSetting * outVoiceSetting ); + + virtual IOReturn BluetoothHCIWriteVoiceSetting( BluetoothHCIRequestID inID, + BluetoothHCIVoiceSetting inVoiceSetting ); + + virtual IOReturn BluetoothHCIReadAutomaticFlushTimeout( BluetoothHCIRequestID inID, + BluetoothConnectionHandle inConnectionHandle, + BluetoothHCIAutomaticFlushTimeoutInfo * outAutomaticFlushTimeoutInfo ); + + + virtual IOReturn BluetoothHCIWriteAutomaticFlushTimeout( BluetoothHCIRequestID inID, + BluetoothHCIAutomaticFlushTimeoutInfo * inAutomaticFlushTimeoutInfo, + BluetoothConnectionHandle * outConnectionHandle ); + + virtual IOReturn BluetoothHCIReadNumBroadcastRetransmissions( BluetoothHCIRequestID inID, + BluetoothHCINumBroadcastRetransmissions * outNumRetrans ); + + virtual IOReturn BluetoothHCIWriteNumBroadcastRetransmissions( BluetoothHCIRequestID inID, + BluetoothHCINumBroadcastRetransmissions inNumRetrans ); + + virtual IOReturn BluetoothHCIReadHoldModeActivity( BluetoothHCIRequestID inID, + BluetoothHCIHoldModeActivity * outState ); + + virtual IOReturn BluetoothHCIWriteHoldModeActivity( BluetoothHCIRequestID inID, + BluetoothHCIHoldModeActivity inState ); + + virtual IOReturn BluetoothHCIReadTransmitPowerLevel( BluetoothHCIRequestID inID, + BluetoothConnectionHandle inHandle, + BluetoothHCITransmitPowerLevelType inType, + BluetoothHCITransmitPowerLevelInfo * outLevelInfo ); + + virtual IOReturn BluetoothHCIReadSCOFlowControlEnable( BluetoothHCIRequestID inID, + BluetoothHCIFlowControlState * outState ); + + virtual IOReturn BluetoothHCIWriteSCOFlowControlEnable( BluetoothHCIRequestID inID, + BluetoothHCIFlowControlState inState ); + + virtual IOReturn BluetoothHCISetHostControllerToHostFlowControl( BluetoothHCIRequestID inID, + BluetoothHCIFlowControlState inState ); + + virtual IOReturn BluetoothHCIHostBufferSize( BluetoothHCIRequestID inID, + BluetoothHCIBufferSize * inSize ); + + virtual IOReturn BluetoothHCIHostNumberOfCompletePackets( BluetoothHCIRequestID inID ); + + virtual IOReturn BluetoothHCIReadLinkSupervisionTimeout( BluetoothHCIRequestID inID, + BluetoothConnectionHandle inHandle, + BluetoothHCILinkSupervisionTimeout * outInfo ); + + virtual IOReturn BluetoothHCIWriteLinkSupervisionTimeout( BluetoothHCIRequestID inID, + BluetoothHCILinkSupervisionTimeout * inInfo, + BluetoothConnectionHandle * outHandle ); + + virtual IOReturn BluetoothHCIReadNumberOfSupportedIAC( BluetoothHCIRequestID inID, + BluetoothHCISupportedIAC * outNumSupported ); + + virtual IOReturn BluetoothHCIReadCurrentIACLAP( BluetoothHCIRequestID inID ); + + virtual IOReturn BluetoothHCIWriteCurrentIACLAP( BluetoothHCIRequestID inID ); + + virtual IOReturn BluetoothHCIReadPageScanPeriodMode( BluetoothHCIRequestID inID, + BluetoothHCIPageScanPeriodMode * outMode ); + + virtual IOReturn BluetoothHCIWritePageScanPeriodMode( BluetoothHCIRequestID inID, + BluetoothHCIPageScanPeriodMode inMode ); + + virtual IOReturn BluetoothHCIReadPageScanMode( BluetoothHCIRequestID inID, + BluetoothHCIPageScanMode * outMode ); + + virtual IOReturn BluetoothHCIWritePageScanMode( BluetoothHCIRequestID inID, + BluetoothHCIPageScanMode inMode ); + + // Informational commands. + + virtual IOReturn BluetoothHCIReadLocalVersionInformation( BluetoothHCIRequestID inID, + BluetoothHCIVersionInfo * outVersionInfo ); + + virtual IOReturn BluetoothHCIReadLocalSupportedFeatures( BluetoothHCIRequestID inID, + BluetoothHCISupportedFeatures * outFeatures ); + + virtual IOReturn BluetoothHCIReadBufferSize( BluetoothHCIRequestID inID, + BluetoothHCIBufferSize * outSize ); + + virtual IOReturn BluetoothHCIReadCountryCode( BluetoothHCIRequestID inID, + BluetoothHCICountryCode * outCountryCode ); + + virtual IOReturn BluetoothHCIReadDeviceAddress( BluetoothHCIRequestID inID, + BluetoothDeviceAddress * outAddress ); + + // Status commands. + + virtual IOReturn BluetoothHCIReadFailedContactCounter( BluetoothHCIRequestID inID, + BluetoothConnectionHandle inConnectionHandle, + BluetoothHCIFailedContactInfo * outFailedContactCount ); + + virtual IOReturn BluetoothHCIResetFailedContactCounter( BluetoothHCIRequestID inID, + BluetoothConnectionHandle inConnectionHandle ); + + virtual IOReturn BluetoothHCIGetLinkQuality( BluetoothHCIRequestID inID, + BluetoothConnectionHandle inConnectionHandle, + BluetoothHCILinkQualityInfo * outLinkQualityInfo ); + + virtual IOReturn BluetoothHCIReadRSSI( BluetoothHCIRequestID inID, + BluetoothConnectionHandle inConnectionHandle, + BluetoothHCIRSSIInfo * outRSSIInfo ); + + // Testing Commands. + + virtual IOReturn BluetoothHCIReadLoopbackMode( BluetoothHCIRequestID inID, + BluetoothHCILoopbackMode * inLoopbackMode ); + + virtual IOReturn BluetoothHCIWriteLoopbackMode( BluetoothHCIRequestID inID, + BluetoothHCILoopbackMode inLoopbackMode ); + + virtual IOReturn BluetoothHCIEnableDeviceUnderTestMode( BluetoothHCIRequestID inID ); + + virtual IOBluetoothHCIControllerFeatureFlags GetControllerFeatureFlags(); + +protected: + + // Power managment functions: + + virtual bool configurePM(IOService *provider); + + virtual IOReturn setPowerState( unsigned long powerStateOrdinal, IOService* whatDevice ); + static IOReturn setPowerStateAction( OSObject *owner, void *arg1, void *arg2, void *arg3, void *arg4 ); + virtual IOReturn setPowerStateWL( unsigned long powerStateOrdinal, IOService* whatDevice ); + + virtual void UpdatePowerStateProperty( IOBluetoothHCIControllerInternalPowerState powerState ); + + virtual void SetControllerPowerOptions( IOBluetoothHCIControllerPowerOptions controllerPowerOptions ); + virtual IOReturn PerformPowerStateChange( IOBluetoothHCIControllerInternalPowerState oldPowerState, + IOBluetoothHCIControllerInternalPowerState newPowerState, + UInt32 powerStateOptions, + UInt32 *microsecondsUntilComplete ); + virtual void CompletePowerStateChange(); + + virtual void SetControllerFeatureFlags( IOBluetoothHCIControllerFeatureFlags featureFlags ); + + virtual IOReturn setAggressiveness( unsigned long type, unsigned long newLevel ); + + // Enablers for future Changes. + + typedef struct ExpansionData + { + void *mUnsedPointer1, *mUnsedPointer2; + + // Max number of HCI command allowed; + UInt8 mNumberOfCommandsAllowedByHardware; + UInt8 mNumConfiguredHIDDevices; + UInt8 mControllerSleepFlags; + + // This pointer is depreacted and free for future uses. + void* mUnusedPointer; + + // AFH support: + // the mask for the channels to use: + UInt8 mMaskByte[10]; + + // AirPort changes notifications: + IONotifier *windowServerNotifier; + IONotifier *mAirPortPCI; + Boolean mProcessingConnectionRequest; + Boolean mWaitingForCompletedACLPacketsToSleep; + + // SCO Support + UInt8 mNumSCOConnections; + UInt8 *mSCOPacketBuffer; + UInt16 mNumBufferedSCOBytes; + AbsoluteTime mBufferedSCOPacketTimestamp; + + // Repository for the packets when logging at boot + OSArray *mRepositoryForBoot; + UInt16 mMaxNumberOfBootPackets; + + IOService *mOverriddenControllerProvider; + + size_t mHCIRequestListSize; + uint32_t mNewRequestIndex; + + IOBluetoothInactivityTimerEventSource *mIdleTimer; + Boolean mSystemOnTheWayToSleep; + + // New Airport notifications: + IONotifier *mIO80211Interface; + + UInt32 mNextAvailableSCOSequenceNumber; + UInt32 mCurrentlyExecutingSCOSequenceNumber; + + Boolean mNeedToCleanUpWaitForAckQueue; + Boolean mResettingDevice; + + HearingDeviceListType *mConnectedHearingDeviceListHead; + HearingDeviceListType *mConnectedHearingDeviceListTail; + + } ExpansionData; + + ExpansionData* mExpansionData; + +#define mConnectedHearingDeviceListTail IOBluetoothHCIController::mExpansionData->mConnectedHearingDeviceListTail +#define mConnectedHearingDeviceListHead IOBluetoothHCIController::mExpansionData->mConnectedHearingDeviceListHead +#define mResettingDevice IOBluetoothHCIController::mExpansionData->mResettingDevice +#define mNeedToCleanUpWaitForAckQueue IOBluetoothHCIController::mExpansionData->mNeedToCleanUpWaitForAckQueue +#define mNextAvailableSCOSequenceNumber IOBluetoothHCIController::mExpansionData->mNextAvailableSCOSequenceNumber +#define mCurrentlyExecutingSCOSequenceNumber IOBluetoothHCIController::mExpansionData->mCurrentlyExecutingSCOSequenceNumber + +#define mNumberOfCommandsAllowedByHardware IOBluetoothHCIController::mExpansionData->mNumberOfCommandsAllowedByHardware +#define mNumConfiguredHIDDevices IOBluetoothHCIController::mExpansionData->mNumConfiguredHIDDevices +#define mControllerSleepFlags IOBluetoothHCIController::mExpansionData->mControllerSleepFlags +#define mSleepWakeNotifier IOBluetoothHCIController::mExpansionData->mSleepWakeNotifier + +#define mMaskByte IOBluetoothHCIController::mExpansionData->mMaskByte +#define windowServerNotifier IOBluetoothHCIController::mExpansionData->windowServerNotifier +#define mAirPortPCI IOBluetoothHCIController::mExpansionData->mAirPortPCI +#define mProcessingConnectionRequest IOBluetoothHCIController::mExpansionData->mProcessingConnectionRequest +#define mWaitingForCompletedACLPacketsToSleep IOBluetoothHCIController::mExpansionData->mWaitingForCompletedACLPacketsToSleep + +#define mNumSCOConnections IOBluetoothHCIController::mExpansionData->mNumSCOConnections +#define mSCOPacketBuffer IOBluetoothHCIController::mExpansionData->mSCOPacketBuffer +#define mNumBufferedSCOBytes IOBluetoothHCIController::mExpansionData->mNumBufferedSCOBytes +#define mBufferedSCOPacketTimestamp IOBluetoothHCIController::mExpansionData->mBufferedSCOPacketTimestamp +#define mRepositoryForBoot IOBluetoothHCIController::mExpansionData->mRepositoryForBoot +#define mMaxNumberOfBootPackets IOBluetoothHCIController::mExpansionData->mMaxNumberOfBootPackets +#define mOverriddenControllerProvider IOBluetoothHCIController::mExpansionData->mOverriddenControllerProvider +#define mHCIRequestListSize IOBluetoothHCIController::mExpansionData->mHCIRequestListSize +#define mNewRequestIndex IOBluetoothHCIController::mExpansionData->mNewRequestIndex +#define mIdleTimer IOBluetoothHCIController::mExpansionData->mIdleTimer +#define mSystemOnTheWayToSleep IOBluetoothHCIController::mExpansionData->mSystemOnTheWayToSleep +#define mIO80211Interface IOBluetoothHCIController::mExpansionData->mIO80211Interface + + enum { + kIOBluetoothHCIControllerSleepFlagInquiryScanWasEnabled = 0x01 + }; + + +private: + + // Command Packet Queue: + virtual IOReturn EnqueueRequestForController( IOBluetoothHCIRequest *requestPtr ); // Was OSMetaClassDeclareReservedUnused( IOBluetoothHCIController, 0 ) + virtual IOReturn DequeueAndSendRequests(); // Was OSMetaClassDeclareReservedUnused( IOBluetoothHCIController, 1 ) + virtual IOReturn RemoveAllRequestsFromQueue(); // Was OSMetaClassDeclareReservedUnused( IOBluetoothHCIController, 2 ) + + // New Device creation upon connection: + IOReturn CreateDeviceFromConnectionResults( BluetoothHCIEventConnectionCompleteResults *connectionResults, bool isInitiator); + + // Expanded version of OpenDeviceConnection MUST BE CALLED IN THE WORKLOOP + virtual IOBluetoothDevice *OpenDeviceConnection( const BluetoothDeviceAddress *inDeviceAddress, BluetoothHCIPageTimeout pageTimeoutValue, bool authenticationRequired); + + // sleepWakeHandler DEPRECATED METHOD RETURNS kIOReturnUnsupported ALL THE TIME ! + static IOReturn sleepWakeHandler( void *target, void *refCon, UInt32 messageType, IOService *service, void *messageArgument, vm_size_t argSize ); + + static IOReturn restartShutdownAction( OSObject *owner, void *arg1, void *arg2, void *arg3, void *arg4 ); + static IOReturn systemSleepWakeAction( OSObject *owner, void *arg1, void *arg2, void *arg3, void *arg4 ); + +public: + virtual IOReturn restartShutdownWL( UInt32 messageType, void *reserved); + + // AFH support: + virtual UInt8 *rangeForChannel(UInt16 channel); + virtual IOReturn handleAirPortChangesChannelWL(IOService *serviceForAirport); + + // Version of stop in the workloop + virtual void stopWL( IOService * provider ); + +private: + static bool staticAirPortDriverNotification(void *us, void *unused, IOService * yourDevice); + static IOReturn handleAirPortChangesChannelAction( OSObject *owner, void *castMeToServiceForAirport, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6 ); + + static bool windowServerDidAppear( void * target, void * refCon, IOService * newService, IONotifier * notifier ); + static IOReturn windowServerDidAppearAction( OSObject *owner, void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6 ); + + // Expansion slots: + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 0 ); + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 1 ); + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 2 ); + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 3 ); + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 4 ); + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 5 ); + + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 6 ); + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 7 ); + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 8 ); + + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 9 ); + virtual void SetNumSCOConnections( UInt8 numSCOConnections ); + + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 10 ); + virtual void UpdateSCOConnections( UInt8 numSCOConnections ); + + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 11 ); + virtual IOBluetoothDevice *FindDeviceWithSCOHandle( BluetoothConnectionHandle inConnectionHandle ); + + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 12 ); + virtual IOReturn SendSCOData( IOMemoryDescriptor *scoDataDescriptor, + SendDataContext *scoDataContext ); + +protected: + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 13 ); + virtual void SendSCOCompleted( SendDataContext *contextPtr, AbsoluteTime timestamp ); + + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 14 ); + virtual IOReturn DispatchIncomingSCOData( UInt8 *inDataPtr, UInt32 inDataSize, UInt32 inMissingData, AbsoluteTime inTimestamp ); + + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 15 ); + virtual bool willTerminateWL( IOService * provider, IOOptionBits options ); + + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 16 ); + virtual bool shouldOverrideExistingController( IOBluetoothHCIController *controller ); + + static void idleTimerFired( OSObject *owner, IOTimerEventSource *timerEventSource ); + + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 17 ); + virtual void handleIdleTimeout(); + + static IOReturn terminateAction( OSObject *owner, + void *arg1, + void *arg2, + void *arg3, + void *arg4 ); + + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 18 ); + virtual IOReturn terminateWL( IOOptionBits options ); + + // Support for dynamic channel width + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 19 ); + virtual UInt8 *rangeForChannel(UInt16 channel, SInt16 width); + +public: + + // v1.2 + v2.1 commands + + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 20 ); + virtual IOReturn BluetoothHCIReadExtendedInquiryResponse( BluetoothHCIRequestID inID, + BluetoothHCIReadExtendedInquiryResponseResults * outData ); + + + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 21 ); + virtual IOReturn BluetoothHCIWriteExtendedInquiryResponse( BluetoothHCIRequestID inID, + BluetoothHCIFECRequired inFECRequired, + BluetoothHCIExtendedInquiryResponse * inData ); + + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 22 ); + virtual IOReturn BluetoothHCIReadInquiryMode( BluetoothHCIRequestID inID, + BluetoothHCIInquiryMode * outMode ); + + + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 23 ); + virtual IOReturn BluetoothHCIWriteInquiryMode( BluetoothHCIRequestID inID, + BluetoothHCIInquiryMode inMode ); + + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 24 ); + virtual IOReturn BluetoothHCIReadSimplePairingMode( BluetoothHCIRequestID inID, + BluetoothHCISimplePairingMode * outMode ); + + + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 25 ); + virtual IOReturn BluetoothHCIWriteSimplePairingMode( BluetoothHCIRequestID inID, + BluetoothHCISimplePairingMode inMode ); + + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 26 ); + virtual IOReturn BluetoothHCIIOCapabilityRequestReply( BluetoothHCIRequestID inID, + const BluetoothDeviceAddress * inAddress, + BluetoothIOCapability inIOCapability, + BluetoothOOBDataPresence inOOBDataPresence, + BluetoothAuthenticationRequirements inAuthenticationRequirements ); + + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 27 ); + virtual IOReturn BluetoothHCIReadLocalOOBData( BluetoothHCIRequestID inID, + BluetoothHCIReadLocalOOBDataResults * outData ); + + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 28 ); + virtual IOReturn BluetoothHCIReadInquiryResponseTransmitPower( BluetoothHCIRequestID inID, + BluetoothHCITransmitPowerLevel * outData ); + + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 29 ); + virtual IOReturn BluetoothHCIWriteInquiryResponseTransmitPower( BluetoothHCIRequestID inID, + BluetoothHCITransmitPowerLevel inData ); + + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 30 ); + virtual IOReturn BluetoothHCIUserConfirmationRequestReply( BluetoothHCIRequestID inID, + const BluetoothDeviceAddress * inAddress ); + + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 31 ); + virtual IOReturn BluetoothHCIUserConfirmationRequestNegativeReply( BluetoothHCIRequestID inID, + const BluetoothDeviceAddress * inAddress ); + + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 32 ); + virtual IOReturn BluetoothHCIUserPasskeyRequestReply( BluetoothHCIRequestID inID, + const BluetoothDeviceAddress * inAddress, + BluetoothPasskey inPasskey); + + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 33 ); + virtual IOReturn BluetoothHCIUserPasskeyRequestNegativeReply( BluetoothHCIRequestID inID, + const BluetoothDeviceAddress * inAddress ); + + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 34 ); + virtual IOReturn BluetoothHCIRemoteOOBDataRequestReply( BluetoothHCIRequestID inID, + const BluetoothDeviceAddress * inAddress, + BluetoothHCISimplePairingOOBData * hash, + BluetoothHCISimplePairingOOBData * randomizer ); + + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 35 ); + virtual IOReturn BluetoothHCIRemoteOOBDataRequestNegativeReply( BluetoothHCIRequestID inID, + const BluetoothDeviceAddress * inAddress ); + + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 36 ); + virtual IOReturn BluetoothHCIWriteSimplePairingDebugMode( BluetoothHCIRequestID inID, + BluetoothSimplePairingDebugMode inData ); + + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 37 ); + virtual IOReturn BluetoothHCISendKeypressNotification( BluetoothHCIRequestID inID, + const BluetoothDeviceAddress * inAddress, + BluetoothKeypressNotificationType inData ); + +protected: + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 38 ); + virtual IOReturn systemSleepWakeWL( UInt32 messageType, void *reserved); + +public: + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 39 ); + virtual IOReturn BluetoothHCIReadLocalExtendedFeatures( BluetoothHCIRequestID inID, + BluetoothHCIPageNumber inPageNumber, + BluetoothHCIExtendedFeaturesInfo * outFeatures ); + + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 40 ); + virtual IOReturn BluetoothHCIReadRemoteExtendedFeatures( BluetoothHCIRequestID inID, + BluetoothConnectionHandle inConnectionHandle, + BluetoothHCIPageNumber inPageNumber, + BluetoothHCIEventReadRemoteExtendedFeaturesResults * outFeatures ); + + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 41 ); + virtual IOReturn BluetoothHCIReadAFHChannelAssessmentMode( BluetoothHCIRequestID inID, + BluetoothHCIAFHChannelAssessmentMode * outData ); + + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 42 ); + virtual IOReturn BluetoothHCIWriteAFHChannelAssessmentMode( BluetoothHCIRequestID inID, + BluetoothHCIAFHChannelAssessmentMode inData ); + + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 43 ); + virtual IOReturn BluetoothHCISetAFHHostChannelClassification( BluetoothHCIRequestID inID, + uint8_t * inDataPtr, + uint8_t inDataLength ); + +private: + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 44 ); + virtual IOReturn BluetoothHCIReadAFHChannelMap( BluetoothHCIRequestID inID, + BluetoothConnectionHandle inConnectionHandle, + BluetoothAFHResults * outData ); + + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 45 ); + virtual void SynchronizeSCOPacketSequence( UInt32 sequenceNumber ); + + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 46 ); + virtual IOReturn BluetoothHCICreateConnectionCancel( BluetoothHCIRequestID inID, + const BluetoothDeviceAddress * inAddressPtr, + BluetoothDeviceAddress * outAddress ); + + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 47 ); + virtual IOReturn BluetoothHCIRemoteNameRequestCancel( BluetoothHCIRequestID inID, + const BluetoothDeviceAddress * inAddressPtr, + BluetoothDeviceAddress * outAddress ); + + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 48 ); + void StartIdleTimer( uint32_t milliseconds ); + + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 49 ); + void StopIdleTimer(); + +public: + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 50 ); + virtual IOReturn setUnackQueueCompletionCalled(void * memoryDescriptor); + +protected: + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 51 ); + virtual IOReturn RemovePacket(IOMemoryDescriptor *memDescriptor); + +public: + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 52 ); + IOReturn exitHIDSniff(bool exitSniff); + +public: + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 53 ); + virtual IOReturn WaitForControllerPowerStateWithTimeout( IOBluetoothHCIControllerInternalPowerState powerState, + UInt32 waitTimeInMicroSecond); +public: + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 54 ); + void SetHCIDriverExistsVariableTo( bool isLoaded ); + +public: + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 55 ); + virtual IOReturn ToggleLMPLogging( ); + +public: + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 56 ); + virtual HearingDeviceListType * FindHearingDeviceWithAddress( const BluetoothDeviceAddress *inDeviceAddress ); + +public: + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 57 ); + virtual IOReturn AddHearingDevice( IOBluetoothDevice *inDevice ); + +public: + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 58 ); + virtual IOReturn RemoveHearingDevice( IOBluetoothDevice *inDevice, bool all ); + +public: + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 59 ); + virtual IOReturn SetDevicePublishNotificationState( const BluetoothDeviceAddress *inDeviceAddress, DevicePublishNotificationStateType state ); + +public: + OSMetaClassDeclareReservedUsed( IOBluetoothHCIController, 60 ); + virtual DevicePublishNotificationStateType * GetDevicePublishNotificationState( const BluetoothDeviceAddress *inDeviceAddress ); + +private: + OSMetaClassDeclareReservedUnused( IOBluetoothHCIController, 61 ); + OSMetaClassDeclareReservedUnused( IOBluetoothHCIController, 62 ); + OSMetaClassDeclareReservedUnused( IOBluetoothHCIController, 63 ); +}; Index: branches/azimutz/Cleancut/i386/include/IOKit/sbp2/IOFireWireSBP2UserClient.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/sbp2/IOFireWireSBP2UserClient.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/sbp2/IOFireWireSBP2UserClient.h (revision 885) @@ -0,0 +1,186 @@ +/* + * 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 + +#define FIREWIREPRIVATE +#include +#undef FIREWIREPRIVATE + +#include + +#include +#include + +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; + + virtual IOReturn externalMethod( uint32_t selector, + IOExternalMethodArguments * args, + IOExternalMethodDispatch * dispatch, + OSObject * target, + void * reference ); +public: + + virtual bool initWithTask( task_t owningTask, void * securityToken, UInt32 type, OSDictionary * properties ); + virtual void free (); + + virtual bool start( IOService * provider ); + + virtual IOReturn clientClose( void ); + virtual IOReturn clientDied( void ); + + // 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 ); + + ///////////////////////////////////////////////// + // 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 \ No newline at end of file Index: branches/azimutz/Cleancut/i386/include/IOKit/sbp2/IOFireWireSBP2LUN.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/sbp2/IOFireWireSBP2LUN.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/sbp2/IOFireWireSBP2LUN.h (revision 885) @@ -0,0 +1,270 @@ +/* + * 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 +#include + +#include + +#include +#include + +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 ); + + /*! @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 ); + /*! + @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 ); + + /*! + @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); + +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 ); + virtual IOReturn message( UInt32 type, IOService * provider, void * argument = 0 ); + + // 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 ); + +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 \ No newline at end of file Index: branches/azimutz/Cleancut/i386/include/IOKit/sbp2/IOFireWireSBP2ManagementORB.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/sbp2/IOFireWireSBP2ManagementORB.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/sbp2/IOFireWireSBP2ManagementORB.h (revision 885) @@ -0,0 +1,345 @@ +/* + * 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 +#include + +#include + +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 ); + + // command execution + virtual IOReturn execute( void ); + virtual IOReturn complete( IOReturn state ); + + // 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; + +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 \ No newline at end of file Index: branches/azimutz/Cleancut/i386/include/IOKit/sbp2/IOFireWireSerialBusProtocolTransport.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/sbp2/IOFireWireSerialBusProtocolTransport.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/sbp2/IOFireWireSerialBusProtocolTransport.h (revision 885) @@ -0,0 +1,449 @@ +/* + * 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 +#include +#include +#include +#include +#include +#include + +#include + +/*! + @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 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 + IOSimpleLock * fQueueLock; + + UInt32 fLoginRetryCount; + bool fDeferRegisterService; + bool fNeedLogin; + + // /!\ WARNING! NOT USED left behind for legacy binary reasons + 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 ); + + /*! + @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 ); + + /*! + @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 ); + + /*! + @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 ); + + /*! + @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 ); + + /*! + @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 ); + + /*! + @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 ); + + /*! + @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 ); + + /*! + @function free + @discussion See IOService for discussion. + @result none. + */ + + virtual void free ( void ); + +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_ */ \ No newline at end of file Index: branches/azimutz/Cleancut/i386/include/IOKit/sbp2/IOFireWireSBP2LSIWorkaroundDescriptor.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/sbp2/IOFireWireSBP2LSIWorkaroundDescriptor.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/sbp2/IOFireWireSBP2LSIWorkaroundDescriptor.h (revision 885) @@ -0,0 +1,292 @@ +/* + * 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 + +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 = kIODirectionOutIn ); + + // 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 = kIODirectionOutIn ); + + + /////////////////////////////////// + + + /*! + @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 Index: branches/azimutz/Cleancut/i386/include/IOKit/sbp2/IOFireWireSBP2ORB.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/sbp2/IOFireWireSBP2ORB.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/sbp2/IOFireWireSBP2ORB.h (revision 885) @@ -0,0 +1,547 @@ +/* + * 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 + +#include +#include +#include + +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 ); + + // 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; + + /*! + @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: +

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.

+

kFWSBP2CommandTransferDataFromTarget - Transfer direction as specified in SBP2 standard. Set if data is to be written by the device into the host's memory.

+

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.

+

kFWSBP2CommandNormalORB - ORB format 0 - Format specified by SBP2 standard. Set this for most ORBs.

+

kFWSBP2CommandReservedORB - ORB format 1 - Format reserved by SBP2 standard for future standardization.

+

kFWSBP2CommandVendorORB - ORB format 2 - Format specified by SBP2 standard for vendor dependent ORBs.

+

kFWSBP2CommandDummyORB - ORB format 3 - Format specified by SBP2 standard for dummy ORBs.

+

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.

+

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.

+

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.

+ @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 Index: branches/azimutz/Cleancut/i386/include/IOKit/sbp2/IOFireWireSBP2Target.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/sbp2/IOFireWireSBP2Target.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/sbp2/IOFireWireSBP2Target.h (revision 885) @@ -0,0 +1,224 @@ +/* + * 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 +#include + +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 ); + virtual IOReturn message( UInt32 type, + IOService * provider, + void * argument = 0); + + 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 ); + + /*! + @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 ); + + /*! + @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; + + /*! + @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 ); + + /*! + @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 ); + + /*! + @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 ); + + 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 ); + + 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 Index: branches/azimutz/Cleancut/i386/include/IOKit/sbp2/IOFireWireSBP2UserClientCommon.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/sbp2/IOFireWireSBP2UserClientCommon.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/sbp2/IOFireWireSBP2UserClientCommon.h (revision 885) @@ -0,0 +1,79 @@ +/* + * 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 \ No newline at end of file Index: branches/azimutz/Cleancut/i386/include/IOKit/sbp2/IOFireWireSBP2Login.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/sbp2/IOFireWireSBP2Login.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/sbp2/IOFireWireSBP2Login.h (revision 885) @@ -0,0 +1,1078 @@ +/* + * 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 + +#include + +#include +#include + +// 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 ); + + // 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; + + /*! + @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 Index: branches/azimutz/Cleancut/i386/include/IOKit/IORegistryEntry.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/IORegistryEntry.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/IORegistryEntry.h (revision 885) @@ -0,0 +1,947 @@ +/* + * 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_IOREGISTRYENTRY_H +#define _IOKIT_IOREGISTRYENTRY_H + +#include +#include + + +extern const OSSymbol * gIONameKey; +extern const OSSymbol * gIOLocationKey; +extern const OSSymbol * gIORegistryEntryIDKey; + +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 + { + uint64_t fRegistryEntryID; + }; + +/*! @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 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 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 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 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 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 = 0, void *arg1 = 0, + void *arg2 = 0, void *arg3 = 0); + +private: +#if __LP64__ + OSMetaClassDeclareReservedUnused(IORegistryEntry, 0); + OSMetaClassDeclareReservedUnused(IORegistryEntry, 1); + OSMetaClassDeclareReservedUnused(IORegistryEntry, 2); + OSMetaClassDeclareReservedUnused(IORegistryEntry, 3); + OSMetaClassDeclareReservedUnused(IORegistryEntry, 4); + OSMetaClassDeclareReservedUnused(IORegistryEntry, 5); +#else + OSMetaClassDeclareReservedUsed(IORegistryEntry, 0); + OSMetaClassDeclareReservedUsed(IORegistryEntry, 1); + OSMetaClassDeclareReservedUsed(IORegistryEntry, 2); + OSMetaClassDeclareReservedUsed(IORegistryEntry, 3); + OSMetaClassDeclareReservedUsed(IORegistryEntry, 4); + OSMetaClassDeclareReservedUsed(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 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 = 0 ); + +/*! @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 ); + +/*! @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; + +/*! @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; + +/*! @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; + +/*! @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; + +/*! @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; + +/*! @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; + +/*! @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 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 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 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 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 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 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 = 0) 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 parent 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 = 0 ) 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 const OSSymbol * copyName( + const IORegistryPlane * plane = 0 ) 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 = 0 ) 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 = 0 ) 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 = 0 ); + +/*! @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 = 0 ); + +/*! @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 = 0 ) 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 const OSSymbol * copyLocation( + const IORegistryPlane * plane = 0 ) 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 = 0 ); + virtual void setLocation( const char * location, + const IORegistryPlane * plane = 0 ); + +/*! @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 : 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 IORegistryEntry * fromPath( const char * path, + const IORegistryPlane * plane = 0, + char * residualPath = 0, + int * residualLength = 0, + IORegistryEntry * fromEntry = 0 ); + +/*! @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 IORegistryEntry * childFromPath( const char * path, + const IORegistryPlane * plane = 0, + char * residualPath = 0, + int * residualLength = 0 ); + +/*! @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 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 IOService::registryEntryIDMatching() 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 IORegistryEntry * initialize( void ); + +private: + inline bool arrayMember( OSArray * set, + const IORegistryEntry * member, + unsigned int * index = 0 ) 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 + const OSSymbol * hasAlias( const IORegistryPlane * plane, + char * opath = 0, int * length = 0 ) 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 ); + +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 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 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 ); + +/*! @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 ); + +/*! @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 ); + +/*! @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) until successful (ie. the iterator is valid at the end of the iteration). + @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 OSOrderedSet * iterateAll( void ); +}; + +#endif /* _IOKIT_IOREGISTRYENTRY_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/pci/IOAGPDevice.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/pci/IOAGPDevice.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/pci/IOAGPDevice.h (revision 885) @@ -0,0 +1,222 @@ +/* + * 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@ + */ +/* + * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * + * HISTORY + * + */ + + +#ifndef _IOKIT_IOAGPDEVICE_H +#define _IOKIT_IOAGPDEVICE_H + +#include +#include + +/* Definitions of AGP config registers */ +enum { + kIOPCIConfigAGPStatusOffset = 4, + kIOPCIConfigAGPCommandOffset = 8 +}; + +/* Definitions of AGP Command & Status registers */ +enum { + kIOAGPRequestQueueMask = 0xff000000, + kIOAGPSideBandAddresssing = 0x00000200, + kIOAGPEnable = 0x00000100, + kIOAGP4GbAddressing = 0x00000020, + kIOAGPFastWrite = 0x00000010, + kIOAGP4xDataRate = 0x00000004, + kIOAGP2xDataRate = 0x00000002, + kIOAGP1xDataRate = 0x00000001 +}; + +enum { + kIOAGPGartInvalidate = 0x00000001 +}; + +// getAGPStatus() defines +enum { + kIOAGPDefaultStatus = 0 +}; +enum { + kIOAGPIdle = 0x00000001, + kIOAGPInvalidGARTEntry = 0x00000002, + kIOAGPAccessOutOfRange = 0x00000004 +}; + +#define kIOAGPBusFlagsKey "IOAGPFlags" +enum { + // the AGP target must be idle before invalidating its gart tlb + kIOAGPGartIdleInvalidate = 0x00000001, + + // the AGP target cannot handle operations that cross page boundaries + kIOAGPDisablePageSpans = 0x00000002, + + // the AGP target cannot handle master -> target AGP writes + kIOAGPDisableAGPWrites = 0x00000004, + + // the AGP target cannot handle target -> master PCI reads + kIOAGPDisablePCIReads = 0x00000008, + + // the AGP target cannot handle master -> target PCI writes + kIOAGPDisablePCIWrites = 0x00000010, + + // the AGP target cannot handle all unaligned transactions + kIOAGPDisableUnaligned = 0x00000020, + + kIOAGPDisableFeature6 = 0x00000040, + kIOAGPDisableFeature7 = 0x00000080, + kIOAGPDisableFeature8 = 0x00000100, + kIOAGPDisableFeature9 = 0x00000200 +}; + +// masterState +enum { + kIOAGPStateEnabled = 0x00000001, + kIOAGPStateEnablePending = 0x00010000 +}; + + +/*! @class IOAGPDevice + @abstract An IOService class representing an AGP master device. + @discussion The discovery of an AGP master device by the PCI bus family results in an instance of the IOAGPDevice being created and published. It provides services specific to AGP, in addition to the PCI services supplied by its superclass IOPCIDevice. +*/ + +class IOAGPDevice : public IOPCIDevice +{ + OSDeclareDefaultStructors(IOAGPDevice) + +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) +*/ + ExpansionData *reserved; + +public: + UInt32 masterState; + UInt8 masterAGPRegisters; + +/*! @function createAGPSpace + @abstract Allocates the AGP space, and enables AGP transactions on the master and slave. + @discussion This method should be called by the driver for the AGP master device to set the size of the space and enable AGP transactions. It will destroy any AGP space currently allocated. + @param options No options are currently defined, pass zero. + @param address The physical range allocated for the AGP space is passed back to the caller. + @param length An in/out parameter - the caller sets the devices maximum AGP addressing and the actual size created is passed back. + @result Returns an IOReturn code indicating success or failure. +*/ + + virtual IOReturn createAGPSpace( IOOptionBits options, + IOPhysicalAddress * address, + IOPhysicalLength * length ); + +/*! @function destroyAGPSpace + @abstract Destroys the AGP space, and disables AGP transactions on the master and slave. + @discussion This method should be called by the driver to shutdown AGP transactions and release resources. +*/ + + virtual IOReturn destroyAGPSpace( void ); + +/*! @function getAGPRangeAllocator + @abstract Accessor to obtain the AGP range allocator. + @discussion To allocate ranges in AGP space, obtain a range allocator for the space with this method. It is retained while the space is created (until destroyAGPSpace is called) and should not be released by the caller. + @result Returns a pointer to the range allocator for the AGP space. +*/ + + virtual IORangeAllocator * getAGPRangeAllocator( void ); + +/*! @function getAGPStatus + @abstract Returns the current state of the AGP bus. + @discussion Returns state bits for the AGP bus. Only one type of status is currently defined. + @param which Type of status - only kIOAGPDefaultStatus is currently valid. + @result Returns mask of status bits for the AGP bus. +*/ + + virtual IOOptionBits getAGPStatus( IOOptionBits which = kIOAGPDefaultStatus ); + +/*! @function commitAGPMemory + @abstract Makes memory addressable by AGP transactions. + @discussion Makes the memory described by the IOMemoryDescriptor object addressable by AGP by entering its pages into the GART array, given an offset into AGP space supplied by the caller (usually allocated by the AGP range allocator). It is the caller's responsibility to prepare non-kernel pageable memory before calling this method, with IOMemoryDescriptor::prepare. + @param memory A IOMemoryDescriptor object describing the memory to add to the GART. + @param agpOffset An offset into AGP space that the caller has allocated - usually allocated by the AGP range allocator. + @param options Pass kIOAGPGartInvalidate if the AGP target should invalidate any GART TLB. + @result Returns an IOReturn code indicating success or failure. +*/ + + virtual IOReturn commitAGPMemory( IOMemoryDescriptor * memory, + IOByteCount agpOffset, + IOOptionBits options = 0 ); + +/*! @function releaseAGPMemory + @abstract Releases memory addressable by AGP transactions. + @discussion Makes the memory described by the IOMemoryDescriptor object unaddressable by AGP by removing its pages from the GART array, given an offset into AGP space supplied by the caller (usually allocated by the AGP range allocator). It is the caller's responsibility to complete non-kernel pageable memory before calling this method, with IOMemoryDescriptor::complete. + @param memory A IOMemoryDescriptor object describing the memory to remove from the GART. + @param agpOffset An offset into AGP space that the caller has allocated - usually allocated by the AGP range allocator. + @param options Pass kIOAGPGartInvalidate if the AGP target should invalidate any GART TLB. + @result Returns an IOReturn code indicating success or failure. +*/ + + virtual IOReturn releaseAGPMemory( IOMemoryDescriptor * memory, + IOByteCount agpOffset, + IOOptionBits options = 0 ); + + virtual IOReturn resetAGP( IOOptionBits options = 0 ); + +/*! @function getAGPSpace + @abstract Returns the allocated AGP space. + @discussion This method can be called by the driver for the AGP master device to retrieve the physical address and size of the space created with createAGPSpace. + @param address The physical range allocated for the AGP space is passed back to the caller. Zero may be passed if the address is not needed by the caller. + @param length The size of the the AGP space created is passed back. Zero may be passed if the length is not needed by the caller. + @result Returns an IOReturn code indicating success or failure. +*/ + + virtual IOReturn getAGPSpace( IOPhysicalAddress * address, + IOPhysicalLength * length ); + + // Unused Padding + OSMetaClassDeclareReservedUnused(IOAGPDevice, 0); + OSMetaClassDeclareReservedUnused(IOAGPDevice, 1); + OSMetaClassDeclareReservedUnused(IOAGPDevice, 2); + OSMetaClassDeclareReservedUnused(IOAGPDevice, 3); + OSMetaClassDeclareReservedUnused(IOAGPDevice, 4); + OSMetaClassDeclareReservedUnused(IOAGPDevice, 5); + OSMetaClassDeclareReservedUnused(IOAGPDevice, 6); + OSMetaClassDeclareReservedUnused(IOAGPDevice, 7); + OSMetaClassDeclareReservedUnused(IOAGPDevice, 8); + OSMetaClassDeclareReservedUnused(IOAGPDevice, 9); + OSMetaClassDeclareReservedUnused(IOAGPDevice, 10); + OSMetaClassDeclareReservedUnused(IOAGPDevice, 11); + OSMetaClassDeclareReservedUnused(IOAGPDevice, 12); + OSMetaClassDeclareReservedUnused(IOAGPDevice, 13); + OSMetaClassDeclareReservedUnused(IOAGPDevice, 14); + OSMetaClassDeclareReservedUnused(IOAGPDevice, 15); + OSMetaClassDeclareReservedUnused(IOAGPDevice, 16); +}; + +#endif /* ! _IOKIT_IOAGPDEVICE_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/pci/IOPCIBridge.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/pci/IOPCIBridge.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/pci/IOPCIBridge.h (revision 885) @@ -0,0 +1,381 @@ +/* + * 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@ + */ +/* + * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved. + * + * HISTORY + * + */ + + +#ifndef _IOKIT_IOPCIBRIDGE_H +#define _IOKIT_IOPCIBRIDGE_H + +#include +#include +#include +#include + + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +typedef uint64_t IOPCIScalar; + +struct IOPCIRange +{ + IOPCIScalar start; + IOPCIScalar size; + IOPCIScalar alignment; + UInt32 type; + UInt32 flags; + struct IOPCIRange * next; + struct IOPCIRange * nextSubRange; + struct IOPCIRange * subRange; +}; + +enum { + kIOPCIResourceTypeMemory = 0, + kIOPCIResourceTypePrefetchMemory, + kIOPCIResourceTypeIO, + kIOPCIResourceTypeBusNumber, + kIOPCIResourceTypeCount +}; + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/*! + @class IOPCIBridge + @abstract Base class for all PCI bridge drivers. +*/ +class IOPCIConfigurator; +class IOPCIDevice; + +class IOPCIBridge : public IOService +{ + friend class IOPCIDevice; + friend class IOPCIConfigurator; + + OSDeclareAbstractStructors(IOPCIBridge) + +private: + static void initialize(void); + IORegistryEntry * findMatching( OSIterator * in, IOPCIAddressSpace space ); + virtual bool isDTNub( IOPCIDevice * nub ); + bool checkProperties( IOPCIDevice * entry ); + + void removeDevice( IOPCIDevice * device, IOOptionBits options = 0 ); + IOReturn restoreMachineState( IOOptionBits options = 0); + IOReturn _restoreDeviceState( IOPCIDevice * device, IOOptionBits options ); + IOReturn resolveLegacyInterrupts( IOService * provider, IOPCIDevice * nub ); + IOReturn resolveMSIInterrupts ( IOService * provider, IOPCIDevice * nub ); + +protected: + static void nvLocation( IORegistryEntry * entry, + UInt8 * busNum, UInt8 * deviceNum, UInt8 * functionNum ); + static SInt32 compareAddressCell( UInt32 cellCount, UInt32 cleft[], UInt32 cright[] ); + void checkTerminateChildren(IOService * bridgeDevice, bool eject); + IOReturn setDeviceASPMBits(IOPCIDevice * device, IOOptionBits state); + + IORangeAllocator * bridgeMemoryRanges; + IORangeAllocator * bridgeIORanges; + +/*! @struct ExpansionData + @discussion This structure will be used to expand the capablilties of the IOPCIBridge in the future. +*/ + struct ExpansionData + { + friend class IOPCIConfigurator; + IORangeAllocator * cardBusMemoryRanges; + IOPCIRange * rangeLists[kIOPCIResourceTypeCount]; + }; + +/*! @var reserved + Reserved for future use. (Internal use only) +*/ + ExpansionData *reserved; + +protected: +public: + virtual void probeBus( IOService * provider, UInt8 busNum ); + + virtual UInt8 firstBusNum( void ); + virtual UInt8 lastBusNum( void ); + + virtual void spaceFromProperties( OSDictionary * propTable, + IOPCIAddressSpace * space ); + virtual OSDictionary * constructProperties( IOPCIAddressSpace space ); + + virtual IOPCIDevice * createNub( OSDictionary * from ); + + virtual bool initializeNub( IOPCIDevice * nub, OSDictionary * from ); + + virtual bool publishNub( IOPCIDevice * nub, UInt32 index ); + + virtual bool addBridgeMemoryRange( IOPhysicalAddress start, + IOPhysicalLength length, bool host ); + + virtual bool addBridgeIORange( IOByteCount start, IOByteCount length ); + + virtual bool constructRange( IOPCIAddressSpace * flags, + IOPhysicalAddress phys, IOPhysicalLength len, + OSArray * array ); + + virtual bool matchNubWithPropertyTable( IOService * nub, + OSDictionary * propertyTable, + SInt32 * score ); + + virtual bool compareNubName( const IOService * nub, OSString * name, + OSString ** matched = 0 ) const; + + virtual bool pciMatchNub( IOPCIDevice * nub, + OSDictionary * table, SInt32 * score); + + virtual bool matchKeys( IOPCIDevice * nub, const char * keys, + UInt32 defaultMask, UInt8 regNum ); + + virtual IOReturn getNubResources( IOService * nub ); + + virtual IOReturn getNubAddressing( IOPCIDevice * nub ); + + virtual IOReturn getDTNubAddressing( IOPCIDevice * nub ); + +public: + virtual void free( void ); + + virtual bool start( IOService * provider ); + + virtual void stop( IOService * provider ); + + virtual bool configure( IOService * provider ); + + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + + virtual IODeviceMemory * ioDeviceMemory( void ) = 0; + + virtual UInt32 configRead32( IOPCIAddressSpace space, UInt8 offset ) = 0; + virtual void configWrite32( IOPCIAddressSpace space, + UInt8 offset, UInt32 data ) = 0; + virtual UInt16 configRead16( IOPCIAddressSpace space, UInt8 offset ) = 0; + virtual void configWrite16( IOPCIAddressSpace space, + UInt8 offset, UInt16 data ) = 0; + virtual UInt8 configRead8( IOPCIAddressSpace space, UInt8 offset ) = 0; + virtual void configWrite8( IOPCIAddressSpace space, + UInt8 offset, UInt8 data ) = 0; + + virtual IOPCIAddressSpace getBridgeSpace( void ) = 0; + + virtual UInt32 findPCICapability( IOPCIAddressSpace space, + UInt8 capabilityID, UInt8 * offset = 0 ); + + virtual IOReturn setDevicePowerState( IOPCIDevice * device, + unsigned long whatToDo ); + virtual IOReturn saveDeviceState( IOPCIDevice * device, + IOOptionBits options = 0 ); + virtual IOReturn restoreDeviceState( IOPCIDevice * device, + IOOptionBits options = 0 ); + + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + + virtual IOReturn createAGPSpace( IOAGPDevice * master, + IOOptionBits options, + IOPhysicalAddress * address, + IOPhysicalLength * length ); + + virtual IOReturn destroyAGPSpace( IOAGPDevice * master ); + + virtual IORangeAllocator * getAGPRangeAllocator( IOAGPDevice * master ); + + virtual IOOptionBits getAGPStatus( IOAGPDevice * master, + IOOptionBits options = 0 ); + virtual IOReturn resetAGPDevice( IOAGPDevice * master, + IOOptionBits options = 0 ); + + virtual IOReturn getAGPSpace( IOAGPDevice * master, + IOPhysicalAddress * address, + IOPhysicalLength * length ); + + virtual IOReturn commitAGPMemory( IOAGPDevice * master, + IOMemoryDescriptor * memory, + IOByteCount agpOffset, + IOOptionBits options ); + + virtual IOReturn releaseAGPMemory( IOAGPDevice * master, + IOMemoryDescriptor * memory, + IOByteCount agpOffset, + IOOptionBits options ); + +protected: + OSMetaClassDeclareReservedUsed(IOPCIBridge, 0); + virtual bool addBridgePrefetchableMemoryRange( IOPhysicalAddress start, + IOPhysicalLength length, + bool host ); + + OSMetaClassDeclareReservedUsed(IOPCIBridge, 1); + virtual UInt32 extendedFindPCICapability( IOPCIAddressSpace space, + UInt32 capabilityID, IOByteCount * offset = 0 ); + + OSMetaClassDeclareReservedUsed(IOPCIBridge, 2); + virtual IOReturn setDeviceASPMState(IOPCIDevice * device, + IOService * client, IOOptionBits state); + + // Unused Padding + OSMetaClassDeclareReservedUnused(IOPCIBridge, 3); + OSMetaClassDeclareReservedUnused(IOPCIBridge, 4); + OSMetaClassDeclareReservedUnused(IOPCIBridge, 5); + OSMetaClassDeclareReservedUnused(IOPCIBridge, 6); + OSMetaClassDeclareReservedUnused(IOPCIBridge, 7); + OSMetaClassDeclareReservedUnused(IOPCIBridge, 8); + OSMetaClassDeclareReservedUnused(IOPCIBridge, 9); + OSMetaClassDeclareReservedUnused(IOPCIBridge, 10); + OSMetaClassDeclareReservedUnused(IOPCIBridge, 11); + OSMetaClassDeclareReservedUnused(IOPCIBridge, 12); + OSMetaClassDeclareReservedUnused(IOPCIBridge, 13); + OSMetaClassDeclareReservedUnused(IOPCIBridge, 14); + OSMetaClassDeclareReservedUnused(IOPCIBridge, 15); + OSMetaClassDeclareReservedUnused(IOPCIBridge, 16); + OSMetaClassDeclareReservedUnused(IOPCIBridge, 17); + OSMetaClassDeclareReservedUnused(IOPCIBridge, 18); + OSMetaClassDeclareReservedUnused(IOPCIBridge, 19); + OSMetaClassDeclareReservedUnused(IOPCIBridge, 20); + OSMetaClassDeclareReservedUnused(IOPCIBridge, 21); + OSMetaClassDeclareReservedUnused(IOPCIBridge, 22); + OSMetaClassDeclareReservedUnused(IOPCIBridge, 23); + OSMetaClassDeclareReservedUnused(IOPCIBridge, 24); + OSMetaClassDeclareReservedUnused(IOPCIBridge, 25); + OSMetaClassDeclareReservedUnused(IOPCIBridge, 26); + OSMetaClassDeclareReservedUnused(IOPCIBridge, 27); + OSMetaClassDeclareReservedUnused(IOPCIBridge, 28); + OSMetaClassDeclareReservedUnused(IOPCIBridge, 29); + OSMetaClassDeclareReservedUnused(IOPCIBridge, 30); + OSMetaClassDeclareReservedUnused(IOPCIBridge, 31); + + + +}; + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#define kIOPCIBridgeRegs (32) +/*! + @class IOPCI2PCIBridge + @abstract Base class for all PCI-to-PCI bridge drivers. +*/ + +class IOPCI2PCIBridge : public IOPCIBridge +{ + OSDeclareDefaultStructors(IOPCI2PCIBridge) + +private: + + IOPCIDevice * bridgeDevice; + UInt32 bridgeState[kIOPCIBridgeRegs]; + +protected: +/*! @struct ExpansionData + @discussion This structure will be used to expand the capablilties of the IOWorkLoop in the future. + */ + struct ExpansionData + { + // /hotp + IOByteCount xpressCapability; + IOFilterInterruptEventSource * bridgeInterruptSource; + IOWorkLoop * workLoop; + uint32_t hotplugCount; + uint8_t presence; + uint8_t waitingLinkEnable; + uint8_t linkChangeOnly; + uint8_t interruptEnablePending; + uint8_t __reserved[4]; + // hotp/ + }; + +/*! @var reserved + Reserved for future use. (Internal use only) */ + ExpansionData *reserved; +public: + + virtual UInt8 firstBusNum( void ); + virtual UInt8 lastBusNum( void ); + +public: + virtual void free(); + + virtual bool serializeProperties( OSSerialize * serialize ) const; + + virtual IOService * probe( IOService * provider, + SInt32 * score ); + + virtual bool start( IOService * provider ); + + virtual void stop( IOService * provider ); + + virtual bool configure( IOService * provider ); + + virtual void probeBus( IOService * provider, UInt8 busNum ); + + virtual IOReturn requestProbe( IOOptionBits options ); + + virtual void saveBridgeState( void ); + + virtual void restoreBridgeState( void ); + + IOReturn setPowerState( unsigned long powerState, + IOService * whatDevice ); + + virtual bool publishNub( IOPCIDevice * nub, UInt32 index ); + + virtual IODeviceMemory * ioDeviceMemory( void ); + + virtual IOPCIAddressSpace getBridgeSpace( void ); + + virtual UInt32 configRead32( IOPCIAddressSpace space, UInt8 offset ); + virtual void configWrite32( IOPCIAddressSpace space, + UInt8 offset, UInt32 data ); + virtual UInt16 configRead16( IOPCIAddressSpace space, UInt8 offset ); + virtual void configWrite16( IOPCIAddressSpace space, + UInt8 offset, UInt16 data ); + virtual UInt8 configRead8( IOPCIAddressSpace space, UInt8 offset ); + virtual void configWrite8( IOPCIAddressSpace space, + UInt8 offset, UInt8 data ); + + virtual IOReturn setDeviceASPMState(IOPCIDevice * device, + IOService * client, IOOptionBits state); + + // Unused Padding + OSMetaClassDeclareReservedUnused(IOPCI2PCIBridge, 0); + OSMetaClassDeclareReservedUnused(IOPCI2PCIBridge, 1); + OSMetaClassDeclareReservedUnused(IOPCI2PCIBridge, 2); + OSMetaClassDeclareReservedUnused(IOPCI2PCIBridge, 3); + OSMetaClassDeclareReservedUnused(IOPCI2PCIBridge, 4); + OSMetaClassDeclareReservedUnused(IOPCI2PCIBridge, 5); + OSMetaClassDeclareReservedUnused(IOPCI2PCIBridge, 6); + OSMetaClassDeclareReservedUnused(IOPCI2PCIBridge, 7); + OSMetaClassDeclareReservedUnused(IOPCI2PCIBridge, 8); + +protected: + bool filterInterrupt( IOFilterInterruptEventSource * source); + + void handleInterrupt( IOInterruptEventSource * source, + int count ); + +}; + +#endif /* ! _IOKIT_IOPCIBRIDGE_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/pci/IOPCIDevice.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/pci/IOPCIDevice.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/pci/IOPCIDevice.h (revision 885) @@ -0,0 +1,673 @@ +/* + * 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_IOPCIDEVICE_H +#define _IOKIT_IOPCIDEVICE_H + +#include + +/* Definitions of PCI Config Registers */ +enum { + kIOPCIConfigVendorID = 0x00, + kIOPCIConfigDeviceID = 0x02, + kIOPCIConfigCommand = 0x04, + kIOPCIConfigStatus = 0x06, + kIOPCIConfigRevisionID = 0x08, + kIOPCIConfigClassCode = 0x09, + kIOPCIConfigCacheLineSize = 0x0C, + kIOPCIConfigLatencyTimer = 0x0D, + kIOPCIConfigHeaderType = 0x0E, + kIOPCIConfigBIST = 0x0F, + kIOPCIConfigBaseAddress0 = 0x10, + kIOPCIConfigBaseAddress1 = 0x14, + kIOPCIConfigBaseAddress2 = 0x18, + kIOPCIConfigBaseAddress3 = 0x1C, + kIOPCIConfigBaseAddress4 = 0x20, + kIOPCIConfigBaseAddress5 = 0x24, + kIOPCIConfigCardBusCISPtr = 0x28, + kIOPCIConfigSubSystemVendorID = 0x2C, + kIOPCIConfigSubSystemID = 0x2E, + kIOPCIConfigExpansionROMBase = 0x30, + kIOPCIConfigCapabilitiesPtr = 0x34, + kIOPCIConfigInterruptLine = 0x3C, + kIOPCIConfigInterruptPin = 0x3D, + kIOPCIConfigMinimumGrant = 0x3E, + kIOPCIConfigMaximumLatency = 0x3F +}; + +/* Definitions of Capabilities PCI Config Register */ +enum { + kIOPCICapabilityIDOffset = 0x00, + kIOPCINextCapabilityOffset = 0x01, + + kIOPCIPowerManagementCapability = 0x01, + kIOPCIAGPCapability = 0x02, + kIOPCIVitalProductDataCapability = 0x03, + kIOPCISlotIDCapability = 0x04, + kIOPCIMSICapability = 0x05, + kIOPCICPCIHotswapCapability = 0x06, + kIOPCIPCIXCapability = 0x07, + kIOPCILDTCapability = 0x08, + kIOPCIVendorSpecificCapability = 0x09, + kIOPCIDebugPortCapability = 0x0a, + kIOPCICPCIResourceControlCapability = 0x0b, + kIOPCIHotplugCapability = 0x0c, + kIOPCIAGP8Capability = 0x0e, + kIOPCISecureCapability = 0x0f, + kIOPCIPCIExpressCapability = 0x10, + kIOPCIMSIXCapability = 0x11, + + kIOPCIExpressErrorReportingCapability = -1UL, + kIOPCIExpressVirtualChannelCapability = -2UL, + kIOPCIExpressDeviceSerialNumberCapability = -3UL, + kIOPCIExpressPowerBudgetCapability = -4UL +}; + +/* Space definitions */ +enum { + kIOPCIConfigSpace = 0, + kIOPCIIOSpace = 1, + kIOPCI32BitMemorySpace = 2, + kIOPCI64BitMemorySpace = 3 +}; + +/* Command register definitions */ +enum { + kIOPCICommandIOSpace = 0x0001, + kIOPCICommandMemorySpace = 0x0002, + kIOPCICommandBusMaster = 0x0004, + kIOPCICommandSpecialCycles = 0x0008, + kIOPCICommandMemWrInvalidate = 0x0010, + kIOPCICommandPaletteSnoop = 0x0020, + kIOPCICommandParityError = 0x0040, + kIOPCICommandAddressStepping = 0x0080, + kIOPCICommandSERR = 0x0100, + kIOPCICommandFastBack2Back = 0x0200, + kIOPCICommandInterruptDisable = 0x0400 +}; + +/* Status register definitions */ +enum { + kIOPCIStatusCapabilities = 0x0010, + kIOPCIStatusPCI66 = 0x0020, + kIOPCIStatusUDF = 0x0040, + kIOPCIStatusFastBack2Back = 0x0080, + kIOPCIStatusDevSel0 = 0x0000, + kIOPCIStatusDevSel1 = 0x0200, + kIOPCIStatusDevSel2 = 0x0400, + kIOPCIStatusDevSel3 = 0x0600, + kIOPCIStatusTargetAbortCapable = 0x0800, + kIOPCIStatusTargetAbortActive = 0x1000, + kIOPCIStatusMasterAbortActive = 0x2000, + kIOPCIStatusSERRActive = 0x4000, + kIOPCIStatusParityErrActive = 0x8000 +}; + +// constants which are part of the PCI Bus Power Management Spec. +enum +{ + // capabilities bits in the 16 bit capabilities register + kPCIPMCPMESupportFromD3Cold = 0x8000, + kPCIPMCPMESupportFromD3Hot = 0x4000, + kPCIPMCPMESupportFromD2 = 0x2000, + kPCIPMCPMESupportFromD1 = 0x1000, + kPCIPMCPMESupportFromD0 = 0x0800, + kPCIPMCD2Support = 0x0400, + kPCIPMCD1Support = 0x0200, + + kPCIPMCD3Support = 0x0001 +}; + +enum +{ + // bits in the power management control/status register + kPCIPMCSPMEStatus = 0x8000, + kPCIPMCSPMEEnable = 0x0100, + kPCIPMCSPowerStateMask = 0x0003, + kPCIPMCSPowerStateD3 = 0x0003, + kPCIPMCSPowerStateD2 = 0x0002, + kPCIPMCSPowerStateD1 = 0x0001, + kPCIPMCSPowerStateD0 = 0x0000, + + kPCIPMCSDefaultEnableBits = (~(IOOptionBits)0) +}; + +union IOPCIAddressSpace { + UInt32 bits; + struct { +#if __BIG_ENDIAN__ + unsigned int reloc:1; + unsigned int prefetch:1; + unsigned int t:1; + unsigned int resv:3; + unsigned int space:2; + unsigned int busNum:8; + unsigned int deviceNum:5; + unsigned int functionNum:3; + unsigned int registerNum:8; +#elif __LITTLE_ENDIAN__ + unsigned int registerNum:8; + unsigned int functionNum:3; + unsigned int deviceNum:5; + unsigned int busNum:8; + unsigned int space:2; + unsigned int resv:3; + unsigned int t:1; + unsigned int prefetch:1; + unsigned int reloc:1; +#endif + } s; + struct { +#if __BIG_ENDIAN__ + unsigned int resv:4; + unsigned int registerNumExtended:4; + unsigned int busNum:8; + unsigned int deviceNum:5; + unsigned int functionNum:3; + unsigned int registerNum:8; +#elif __LITTLE_ENDIAN__ + unsigned int registerNum:8; + unsigned int functionNum:3; + unsigned int deviceNum:5; + unsigned int busNum:8; + unsigned int registerNumExtended:4; + unsigned int resv:4; +#endif + } es; +}; + +struct IOPCIPhysicalAddress { + IOPCIAddressSpace physHi; + UInt32 physMid; + UInt32 physLo; + UInt32 lengthHi; + UInt32 lengthLo; +}; + +// IOPCIDevice matching property names +#define kIOPCIMatchKey "IOPCIMatch" +#define kIOPCIPrimaryMatchKey "IOPCIPrimaryMatch" +#define kIOPCISecondaryMatchKey "IOPCISecondaryMatch" +#define kIOPCIClassMatchKey "IOPCIClassMatch" + +// property to control PCI default config space save on sleep +#define kIOPMPCIConfigSpaceVolatileKey "IOPMPCIConfigSpaceVolatile" + +// pci express link status +#define kIOPCIExpressLinkStatusKey "IOPCIExpressLinkStatus" +// pci express link capabilities +#define kIOPCIExpressLinkCapabilitiesKey "IOPCIExpressLinkCapabilities" + +#ifndef kIOPlatformDeviceASPMEnableKey +#define kIOPlatformDeviceASPMEnableKey "IOPlatformDeviceASPMEnable" +#endif + +#ifndef kIOPCIDeviceASPMSupportedKey +#define kIOPCIDeviceASPMSupportedKey "pci-aspm-supported" +#endif + +#define kIOPCIPMEOptionsKey "IOPCIPMEOptions" + + +enum { + kIOPCIDevicePowerStateCount = 3, + kIOPCIDeviceOffState = 0, + kIOPCIDeviceDozeState = 1, + kIOPCIDeviceOnState = 2, +}; + +enum +{ + // bits getInterruptType result + kIOInterruptTypePCIMessaged = 0x00010000 +}; + +class IOPCIBridge; +class IOPCI2PCIBridge; +class IOPCIMessagedInterruptController; + +/*! @class IOPCIDevice : public IOService + @abstract An IOService class representing a PCI device. + @discussion The discovery of a PCI device by the PCI bus family results in an instance of the IOPCIDevice being created and published. It provides services for looking up and mapping memory mapped hardware, and access to the PCI configuration and I/O spaces. + +

Matching Supported by IOPCIDevice

+ +Two types of matching are available, OpenFirmware name matching and PCI register matching. Currently, only one of these two matching schemes can be used in the same property table. + +

OpenFirmware Name Matching

+ +IOService performs matching based on the IONameMatch property (see IOService). IOPCIDevices created with OpenFirmware device tree entries will name match based on the standard OpenFirmware name matching properties. + +

PCI Register Matching

+ +A PCI device driver can also match on the values of certain config space registers. + +In each case, several matching values can be specified, and an optional mask for the value of the config space register may follow the value, preceded by an '&' character. +
+
+ kIOPCIMatchKey, "IOPCIMatch" +
+The kIOPCIMatchKey property matches the vendor and device ID (0x00) register, or the subsystem register (0x2c). +
+
+ kIOPCIPrimaryMatchKey, "IOPCIPrimaryMatch" +
+The kIOPCIPrimaryMatchKey property matches the vendor and device ID (0x00) register. +
+
+ kIOPCISecondaryMatchKey, "IOPCISecondaryMatch" +
+The kIOPCISecondaryMatchKey property matches the subsystem register (0x2c). +
+
+ kIOPCIClassMatchKey, "IOPCIClassMatch" +
+The kIOPCIClassMatchKey property matches the class code register (0x08). The default mask for this register is 0xffffff00. +
+
+Examples: +
+
+ <key>IOPCIMatch</key>
+ <string>0x00261011</string> +
+Matches a device whose vendor ID is 0x1011, and device ID is 0x0026, including subsystem IDs. +
+
+ <key>IOPCIMatch</key>
+ <string>0x00789004&0x00ffffff 0x78009004&0x0xff00ffff</string> +
+Matches with any device with a vendor ID of 0x9004, and a device ID of 0xzz78 or 0x78zz, where 'z' is don't care. +
+
+ <key>IOPCIClassMatch</key>
+ <string>0x02000000&0xffff0000</string> +
+
+Matches a device whose class code is 0x0200zz, an ethernet device. + +*/ + +class IOPCIDevice : public IOService +{ + OSDeclareDefaultStructors(IOPCIDevice) + + friend class IOPCIBridge; + friend class IOPCI2PCIBridge; + friend class IOPCIMessagedInterruptController; + +protected: + IOPCIBridge * parent; + IOMemoryMap * ioMap; + OSObject * slotNameProperty; + +/*! @var reserved + Reserved for future use. (Internal use only) */ + struct IOPCIDeviceExpansionData * reserved; + +public: + IOPCIAddressSpace space; + UInt32 * savedConfig; + +public: + /* IOService/IORegistryEntry methods */ + + virtual bool init( OSDictionary * propTable ); + virtual bool init( IORegistryEntry * from, + const IORegistryPlane * inPlane ); + virtual void free(); + virtual bool attach( IOService * provider ); + virtual void detach( IOService * provider ); + + virtual IOReturn newUserClient( task_t owningTask, void * securityID, + UInt32 type, OSDictionary * properties, + IOUserClient ** handler ); + + virtual IOReturn powerStateWillChangeTo (IOPMPowerFlags capabilities, + unsigned long stateNumber, + IOService* whatDevice); + virtual IOReturn setPowerState( unsigned long, IOService * ); + + virtual bool compareName( OSString * name, OSString ** matched = 0 ) const; + virtual bool matchPropertyTable( OSDictionary * table, + SInt32 * score ); + virtual IOService * matchLocation( IOService * client ); + virtual IOReturn getResources( void ); + virtual IOReturn setProperties(OSObject * properties); + virtual IOReturn callPlatformFunction(const OSSymbol * functionName, + bool waitForFunction, + void * p1, void * p2, + void * p3, void * p4); + virtual IOReturn callPlatformFunction(const char * functionName, + bool waitForFunction, + void * p1, void * p2, + void * p3, void * p4); + + /* Config space accessors */ + + virtual UInt32 configRead32( IOPCIAddressSpace space, UInt8 offset ); + virtual void configWrite32( IOPCIAddressSpace space, + UInt8 offset, UInt32 data ); + virtual UInt16 configRead16( IOPCIAddressSpace space, UInt8 offset ); + virtual void configWrite16( IOPCIAddressSpace space, + UInt8 offset, UInt16 data ); + virtual UInt8 configRead8( IOPCIAddressSpace space, UInt8 offset ); + virtual void configWrite8( IOPCIAddressSpace space, + UInt8 offset, UInt8 data ); + +/*! @function configRead32 + @abstract Reads a 32-bit value from the PCI device's configuration space. + @discussion This method reads a 32-bit configuration space register on the device and returns its value. + @param offset An 8-bit offset into configuration space, of which bits 0-1 are ignored. + @result An 32-bit value in host byte order (big endian on PPC). */ + + virtual UInt32 configRead32( UInt8 offset ); + +/*! @function configRead16 + @abstract Reads a 16-bit value from the PCI device's configuration space. + @discussion This method reads a 16-bit configuration space register on the device and returns its value. + @param offset An 8-bit offset into configuration space, of which bit 0 is ignored. + @result An 16-bit value in host byte order (big endian on PPC). */ + + virtual UInt16 configRead16( UInt8 offset ); + +/*! @function configRead8 + @abstract Reads a 8-bit value from the PCI device's configuration space. + @discussion This method reads a 8-bit configuration space register on the device and returns its value. + @param offset An 8-bit offset into configuration space. + @result An 8-bit value. */ + + virtual UInt8 configRead8( UInt8 offset ); + +/*! @function configWrite32 + @abstract Writes a 32-bit value to the PCI device's configuration space. + @discussion This method write a 32-bit value to a configuration space register on the device. + @param offset An 8-bit offset into configuration space, of which bits 0-1 are ignored. + @param data An 32-bit value to be written in host byte order (big endian on PPC). */ + + virtual void configWrite32( UInt8 offset, UInt32 data ); + +/*! @function configWrite16 + @abstract Writes a 16-bit value to the PCI device's configuration space. + @discussion This method write a 16-bit value to a configuration space register on the device. + @param offset An 8-bit offset into configuration space, of which bit 0 is ignored. + @param data An 16-bit value to be written in host byte order (big endian on PPC). */ + + virtual void configWrite16( UInt8 offset, UInt16 data ); + +/*! @function configWrite8 + @abstract Writes a 8-bit value to the PCI device's configuration space. + @discussion This method write a 8-bit value to a configuration space register on the device. + @param offset An 8-bit offset into configuration space. + @param data An 8-bit value to be written. */ + + virtual void configWrite8( UInt8 offset, UInt8 data ); + + virtual IOReturn saveDeviceState( IOOptionBits options = 0 ); + virtual IOReturn restoreDeviceState( IOOptionBits options = 0 ); + +/*! @function setConfigBits + @abstract Sets masked bits in a configuration space register. + @discussion This method sets masked bits in a configuration space register on the device by reading and writing the register. The value of the masked bits before the write is returned. + @param offset An 8-bit offset into configuration space, of which bits 0-1 are ignored. + @param mask An 32-bit mask indicating which bits in the value parameter are valid. + @param data An 32-bit value to be written in host byte order (big endian on PPC). + @result The value of the register masked with the mask before the write. */ + + virtual UInt32 setConfigBits( UInt8 offset, UInt32 mask, UInt32 value ); + +/*! @function setMemoryEnable + @abstract Sets the device's memory space response. + @discussion This method sets the memory space response bit in the device's command config space register to the passed value, and returns the previous state of the enable. + @param enable True or false to enable or disable the memory space response. + @result True if the memory space response was previously enabled, false otherwise. */ + + virtual bool setMemoryEnable( bool enable ); + +/*! @function setIOEnable + @abstract Sets the device's I/O space response. + @discussion This method sets the I/O space response bit in the device's command config space register to the passed value, and returns the previous state of the enable. The exclusive option allows only one exclusive device on the bus to be enabled concurrently, this should be only for temporary access. + @param enable True or false to enable or disable the I/O space response. + @param exclusive If true, only one setIOEnable with the exclusive flag set will be allowed at a time on the bus, this should be only for temporary access. + @result True if the I/O space response was previously enabled, false otherwise. */ + + virtual bool setIOEnable( bool enable, bool exclusive = false ); + +/*! @function setBusMasterEnable + @abstract Sets the device's bus master enable. + @discussion This method sets the bus master enable bit in the device's command config space register to the passed value, and returns the previous state of the enable. + @param enable True or false to enable or disable bus mastering. + @result True if bus mastering was previously enabled, false otherwise. */ + + virtual bool setBusMasterEnable( bool enable ); + +/*! @function findPCICapability + @abstract Search configuration space for a PCI capability register. + @discussion This method searches the device's config space for a PCI capability register matching the passed capability ID, if the device supports PCI capabilities. To search for PCI Express extended capabilities or for multiple capablities with the same ID, use the extendedFindPCICapability() method. + @param capabilityID An 8-bit PCI capability ID. + @param offset An optional pointer to return the offset into config space where the capability was found. + @result The 32-bit value of the capability register if one was found, zero otherwise. */ + + virtual UInt32 findPCICapability( UInt8 capabilityID, UInt8 * offset = 0 ); + +/*! @function getBusNumber + @abstract Accessor to return the PCI device's assigned bus number. + @discussion This method is an accessor to return the PCI device's assigned bus number. + @result The 8-bit value of device's PCI bus number. */ + + virtual UInt8 getBusNumber( void ); + +/*! @function getDeviceNumber + @abstract Accessor to return the PCI device's device number. + @discussion This method is an accessor to return the PCI device's device number. + @result The 5-bit value of device's device number. */ + + virtual UInt8 getDeviceNumber( void ); + +/*! @function getFunctionNumber + @abstract Accessor to return the PCI device's function number. + @discussion This method is an accessor to return the PCI device's function number. + @result The 3-bit value of device's function number. */ + + virtual UInt8 getFunctionNumber( void ); + + /* Device memory accessors */ + +/*! @function getDeviceMemoryWithRegister + @abstract Returns an instance of IODeviceMemory representing one of the device's memory mapped ranges. + @discussion This method will return a pointer to an instance of IODeviceMemory for the physical memory range that was assigned to the configuration space base address register passed in. It is analogous to IOService::getDeviceMemoryWithIndex. + @param reg The 8-bit configuration space register that is the base address register for the desired range. + @result A pointer to an instance of IODeviceMemory, or zero no such range was found. 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. */ + + virtual IODeviceMemory * getDeviceMemoryWithRegister( UInt8 reg ); + +/*! @function mapDeviceMemoryWithRegister + @abstract Maps a physical range of the device. + @discussion This method will create a mapping for the IODeviceMemory for the physical memory range that was assigned to the configuration space base address register passed in, with IODeviceMemory::map(options). The mapping is represented by the returned instance of IOMemoryMap, which should not be released until the mapping is no longer required. This method is analogous to IOService::mapDeviceMemoryWithIndex. + @param reg The 8-bit configuration space register that is the base address register for the desired range. + @param options Options to be passed to the IOMemoryDescriptor::map() method. + @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 * mapDeviceMemoryWithRegister( UInt8 reg, + IOOptionBits options = 0 ); + +/*! @function ioDeviceMemory + @abstract Accessor to the I/O space aperture for the bus. + @discussion This method will return a reference to the IODeviceMemory for the I/O aperture of the bus the device is on. + @result A pointer to an IODeviceMemory object for the I/O aperture. 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. */ + + virtual IODeviceMemory * ioDeviceMemory( void ); + + /* I/O space accessors */ + +/*! @function ioWrite32 + @abstract Writes a 32-bit value to an I/O space aperture. + @discussion This method will write a 32-bit value to a 4 byte aligned offset in an I/O space aperture. If a map object is passed in, the value is written relative to it, otherwise to the value is written relative to the I/O space aperture for the bus. This function encapsulates the differences between architectures in generating I/O space operations. An eieio instruction is included on PPC. + @param offset An offset into a bus or device's I/O space aperture. + @param value The value to be written in host byte order (big endian on PPC). + @param map If the offset is relative to the beginning of a device's aperture, an IOMemoryMap object for that object should be passed in. Otherwise, passing zero will write the value relative to the beginning of the bus' I/O space. */ + + virtual void ioWrite32( UInt16 offset, UInt32 value, + IOMemoryMap * map = 0 ); + +/*! @function ioWrite16 + @abstract Writes a 16-bit value to an I/O space aperture. + @discussion This method will write a 16-bit value to a 2 byte aligned offset in an I/O space aperture. If a map object is passed in, the value is written relative to it, otherwise to the value is written relative to the I/O space aperture for the bus. This function encapsulates the differences between architectures in generating I/O space operations. An eieio instruction is included on PPC. + @param offset An offset into a bus or device's I/O space aperture. + @param value The value to be written in host byte order (big endian on PPC). + @param map If the offset is relative to the beginning of a device's aperture, an IOMemoryMap object for that object should be passed in. Otherwise, passing zero will write the value relative to the beginning of the bus' I/O space. */ + + virtual void ioWrite16( UInt16 offset, UInt16 value, + IOMemoryMap * map = 0 ); + +/*! @function ioWrite8 + @abstract Writes a 8-bit value to an I/O space aperture. + @discussion This method will write a 8-bit value to an offset in an I/O space aperture. If a map object is passed in, the value is written relative to it, otherwise to the value is written relative to the I/O space aperture for the bus. This function encapsulates the differences between architectures in generating I/O space operations. An eieio instruction is included on PPC. + @param offset An offset into a bus or device's I/O space aperture. + @param value The value to be written in host byte order (big endian on PPC). + @param map If the offset is relative to the beginning of a device's aperture, an IOMemoryMap object for that object should be passed in. Otherwise, passing zero will write the value relative to the beginning of the bus' I/O space. */ + + virtual void ioWrite8( UInt16 offset, UInt8 value, + IOMemoryMap * map = 0 ); + +/*! @function ioRead32 + @abstract Reads a 32-bit value from an I/O space aperture. + @discussion This method will read a 32-bit value from a 4 byte aligned offset in an I/O space aperture. If a map object is passed in, the value is read relative to it, otherwise to the value is read relative to the I/O space aperture for the bus. This function encapsulates the differences between architectures in generating I/O space operations. An eieio instruction is included on PPC. + @param offset An offset into a bus or device's I/O space aperture. + @param map If the offset is relative to the beginning of a device's aperture, an IOMemoryMap object for that object should be passed in. Otherwise, passing zero will write the value relative to the beginning of the bus' I/O space. + @result The value read in host byte order (big endian on PPC). */ + + virtual UInt32 ioRead32( UInt16 offset, IOMemoryMap * map = 0 ); + +/*! @function ioRead16 + @abstract Reads a 16-bit value from an I/O space aperture. + @discussion This method will read a 16-bit value from a 2 byte aligned offset in an I/O space aperture. If a map object is passed in, the value is read relative to it, otherwise to the value is read relative to the I/O space aperture for the bus. This function encapsulates the differences between architectures in generating I/O space operations. An eieio instruction is included on PPC. + @param offset An offset into a bus or device's I/O space aperture. + @param map If the offset is relative to the beginning of a device's aperture, an IOMemoryMap object for that object should be passed in. Otherwise, passing zero will write the value relative to the beginning of the bus' I/O space. + @result The value read in host byte order (big endian on PPC). */ + + virtual UInt16 ioRead16( UInt16 offset, IOMemoryMap * map = 0 ); + +/*! @function ioRead8 + @abstract Reads a 8-bit value from an I/O space aperture. + @discussion This method will read a 8-bit value from an offset in an I/O space aperture. If a map object is passed in, the value is read relative to it, otherwise to the value is read relative to the I/O space aperture for the bus. This function encapsulates the differences between architectures in generating I/O space operations. An eieio instruction is included on PPC. + @param offset An offset into a bus or device's I/O space aperture. + @param map If the offset is relative to the beginning of a device's aperture, an IOMemoryMap object for that object should be passed in. Otherwise, passing zero will write the value relative to the beginning of the bus' I/O space. + @result The value read. */ + + virtual UInt8 ioRead8( UInt16 offset, IOMemoryMap * map = 0 ); + + OSMetaClassDeclareReservedUsed(IOPCIDevice, 0); +/*! @function hasPCIPowerManagement + @abstract determine whether or not the device supports PCI Bus Power Management. + @discussion This method will look at the device's capabilties registers and determine whether or not the device supports the PCI BUS Power Management Specification. + @param state(optional) Check for support of a specific state (e.g. kPCIPMCPMESupportFromD3Cold). If state is not suuplied or is 0, then check for a property in the registry which tells which state the hardware expects the device to go to during sleep. + @result true if the specified state is supported */ + virtual bool hasPCIPowerManagement(IOOptionBits state = 0); + + OSMetaClassDeclareReservedUsed(IOPCIDevice, 1); +/*! @function enablePCIPowerManagement + @abstract enable PCI power management for sleep state + @discussion This method will enable PCI Bus Powermanagement when going to sleep mode. + @param state(optional) Enables PCI Power Management by placing the function in the given state (e.g. kPCIPMCSPowerStateD3). If state is not specified or is 0xffffffff, then the IOPCIDevice determines the desired state. If state is kPCIPMCSPowerStateD0 (0) then PCI Power Management is disabled. + @result kIOReturnSuccess if there were no errors */ + virtual IOReturn enablePCIPowerManagement(IOOptionBits state = 0xffffffff); + + OSMetaClassDeclareReservedUsed(IOPCIDevice, 2); +/*! @function extendedFindPCICapability + @abstract Search configuration space for a PCI capability register. + @discussion This method searches the device's config space for a PCI capability register matching the passed capability ID, if the device supports PCI capabilities. + @param capabilityID A PCI capability ID. PCI Express devices may support extended capabilities in config space starting at offset 0x100. To search this space, the ID passed should be the negated value of the PCI-SIG assigned ID for the extended capability. + @param offset An optional in/out parameter to return the offset into config space where the capability was found, and to set the start point of the next search. Initialize the offset to zero before the first call to extendedFindPCICapability() and subsequent calls will find all capabilty blocks that may exist on the device with the same ID. + @result The 32-bit value of the capability register if one was found, zero otherwise. */ + + virtual UInt32 extendedFindPCICapability( UInt32 capabilityID, IOByteCount * offset = 0 ); + + // Unused Padding + OSMetaClassDeclareReservedUnused(IOPCIDevice, 3); + OSMetaClassDeclareReservedUnused(IOPCIDevice, 4); + OSMetaClassDeclareReservedUnused(IOPCIDevice, 5); + OSMetaClassDeclareReservedUnused(IOPCIDevice, 6); + OSMetaClassDeclareReservedUnused(IOPCIDevice, 7); + OSMetaClassDeclareReservedUnused(IOPCIDevice, 8); + OSMetaClassDeclareReservedUnused(IOPCIDevice, 9); + OSMetaClassDeclareReservedUnused(IOPCIDevice, 10); + OSMetaClassDeclareReservedUnused(IOPCIDevice, 11); + OSMetaClassDeclareReservedUnused(IOPCIDevice, 12); + OSMetaClassDeclareReservedUnused(IOPCIDevice, 13); + OSMetaClassDeclareReservedUnused(IOPCIDevice, 14); + OSMetaClassDeclareReservedUnused(IOPCIDevice, 15); + +public: + +/*! @function extendedConfigRead32 + @abstract Reads a 32-bit value from the PCI device's configuration space. + @discussion This method reads a 32-bit configuration space register on the device and returns its value. + @param offset A byte offset into configuration space, of which bits 0-1 are ignored. + @result An 32-bit value in host byte order (big endian on PPC). */ + + UInt32 extendedConfigRead32( IOByteCount offset ); + +/*! @function extendedConfigRead16 + @abstract Reads a 16-bit value from the PCI device's configuration space. + @discussion This method reads a 16-bit configuration space register on the device and returns its value. + @param offset A byte offset into configuration space, of which bit 0 is ignored. + @result An 16-bit value in host byte order (big endian on PPC). */ + + UInt16 extendedConfigRead16( IOByteCount offset ); + +/*! @function extendedConfigRead8 + @abstract Reads a 8-bit value from the PCI device's configuration space. + @discussion This method reads a 8-bit configuration space register on the device and returns its value. + @param offset A byte offset into configuration space. + @result An 8-bit value. */ + + UInt8 extendedConfigRead8( IOByteCount offset ); + +/*! @function extendedConfigWrite32 + @abstract Writes a 32-bit value to the PCI device's configuration space. + @discussion This method writes a 32-bit value to a configuration space register on the device. + @param offset A byte offset into configuration space, of which bits 0-1 are ignored. + @param data An 32-bit value to be written in host byte order (big endian on PPC). */ + + void extendedConfigWrite32( IOByteCount offset, UInt32 data ); + +/*! @function extendedConfigWrite16 + @abstract Writes a 16-bit value to the PCI device's configuration space. + @discussion This method writes a 16-bit value to a configuration space register on the device. + @param offset A byte offset into configuration space, of which bit 0 is ignored. + @param data An 16-bit value to be written in host byte order (big endian on PPC). */ + + void extendedConfigWrite16( IOByteCount offset, UInt16 data ); + +/*! @function extendedConfigWrite8 + @abstract Writes a 8-bit value to the PCI device's configuration space. + @discussion This method writes a 8-bit value to a configuration space register on the device. + @param offset A byte offset into configuration space. + @param data An 8-bit value to be written. */ + + void extendedConfigWrite8( IOByteCount offset, UInt8 data ); +}; + +#endif /* ! _IOKIT_IOPCIDEVICE_H */ + Index: branches/azimutz/Cleancut/i386/include/IOKit/IORangeAllocator.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/IORangeAllocator.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/IORangeAllocator.h (revision 885) @@ -0,0 +1,171 @@ +/* + * 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. + * + * + * HISTORY + * + * sdouglas 05 Nov 99 - created. + */ + +#ifndef _IOKIT_IORANGEALLOCATOR_H +#define _IOKIT_IORANGEALLOCATOR_H + +#include +#include + +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 IORangeAllocator * withRange( IORangeScalar endOfRange, + IORangeScalar defaultAlignment = 0, + UInt32 capacity = 0, + IOOptionBits options = 0 ); + + virtual void free(); + virtual bool serialize(OSSerialize *s) const; + +/*! @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 */ Index: branches/azimutz/Cleancut/i386/include/IOKit/IOConditionLock.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/IOConditionLock.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/IOConditionLock.h (revision 885) @@ -0,0 +1,71 @@ +/* + * 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. + * Copyright (c) 1994-1996 NeXT Software, Inc. All rights reserved. + */ + +#ifndef _IOKIT_IOCONDITIONLOCK_H +#define _IOKIT_IOCONDITIONLOCK_H + +#include +#include +#include + +#include + +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 IOConditionLock *withCondition(int condition, bool inIntr = true); + virtual bool initWithCondition(int condition, bool inIntr = true); + virtual void free(); + + 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 */ Index: branches/azimutz/Cleancut/i386/include/IOKit/pwr_mgt/RootDomain.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/pwr_mgt/RootDomain.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/pwr_mgt/RootDomain.h (revision 885) @@ -0,0 +1,251 @@ +/* + * 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_ROOTDOMAIN_H +#define _IOKIT_ROOTDOMAIN_H + +#include +#include +#include "IOKit/pwr_mgt/IOPMPrivate.h" + + +class IOPMPowerStateQueue; +class RootDomainUserClient; +class PMTraceWorker; + +/* + * Flags for get/setSleepSupported() + */ +enum { + kRootDomainSleepNotSupported = 0x00000000, + kRootDomainSleepSupported = 0x00000001, + kFrameBufferDeepSleepSupported = 0x00000002, + kPCICantSleep = 0x00000004 +}; + +/* + *IOPMrootDomain registry property keys + */ +#define kRootDomainSupportedFeatures "Supported Features" +#define kRootDomainSleepReasonKey "Last Sleep Reason" +#define kRootDomainSleepOptionsKey "Last Sleep Options" +#define kIOPMRootDomainWakeReasonKey "Wake Reason" +#define kIOPMRootDomainWakeTypeKey "Wake Type" +#define kIOPMRootDomainPowerStatusKey "Power Status" + +/* + * Possible sleep reasons found under kRootDomainSleepReasonsKey + */ +#define kIOPMClamshellSleepKey "Clamshell Sleep" +#define kIOPMPowerButtonSleepKey "Power Button Sleep" +#define kIOPMSoftwareSleepKey "Software Sleep" +#define kIOPMOSSwitchHibernationKey "OS Switch Sleep" +#define kIOPMIdleSleepKey "Idle Sleep" +#define kIOPMLowPowerSleepKey "Low Power Sleep" +#define kIOPMThermalEmergencySleepKey "Thermal Emergency Sleep" +#define kIOPMMaintenanceSleepKey "Maintenance Sleep" + +/* + * String constants for communication with PM CPU + */ +#define kIOPMRootDomainLidCloseCString "LidClose" +#define kIOPMRootDomainBatPowerCString "BatPower" + +/* + * Supported Feature bitfields for IOPMrootDomain::publishFeature() + */ +enum { + kIOPMSupportedOnAC = (1<<0), + kIOPMSupportedOnBatt = (1<<1), + kIOPMSupportedOnUPS = (1<<2) +}; + +typedef IOReturn (*IOPMSettingControllerCallback) + (OSObject *target, const OSSymbol *type, + OSObject *val, uintptr_t refcon); + +__BEGIN_DECLS +IONotifier * registerSleepWakeInterest( + IOServiceInterestHandler, void *, void * = 0); + +IONotifier * registerPrioritySleepWakeInterest( + IOServiceInterestHandler handler, + void * self, void * ref = 0); + +IOReturn acknowledgeSleepWakeNotification(void * ); + +IOReturn vetoSleepWakeNotification(void * PMrefcon); +__END_DECLS + +#define IOPM_ROOTDOMAIN_REV 2 + +class IOPMrootDomain: public IOService +{ + OSDeclareFinalStructors(IOPMrootDomain) + +public: + static IOPMrootDomain * construct( void ); + + virtual bool start( IOService * provider ); + virtual IOReturn setAggressiveness( unsigned long, unsigned long ); + virtual IOReturn getAggressiveness( unsigned long, unsigned long * ); + + virtual IOReturn sleepSystem( void ); + IOReturn sleepSystemOptions( OSDictionary *options ); + + virtual IOReturn setProperties( OSObject * ); + +/*! @function systemPowerEventOccurred + @abstract Other drivers may inform IOPMrootDomain of system PM events + @discussion systemPowerEventOccurred is a richer alternative to receivePowerNotification() + Only Apple-owned kexts should have reason to call systemPowerEventOccurred. + @param event An OSSymbol describing the type of power event. + @param value A 32-bit integer value associated with the event. + @param shouldUpdate indicates whether the root domain should send a notification + to interested parties. Pass false if you're calling systemPowerEventOccurred + several times in succession; and pass true only on the last invocatino. + @result kIOReturnSuccess on success */ + + IOReturn systemPowerEventOccurred( + const OSSymbol *event, + uint32_t intValue ); + + IOReturn systemPowerEventOccurred( + const OSSymbol *event, + OSObject *value ); + + virtual IOReturn receivePowerNotification( UInt32 msg ); + + virtual void setSleepSupported( IOOptionBits flags ); + + virtual IOOptionBits getSleepSupported( void ); + + void wakeFromDoze( void ); + + // KEXT driver announces support of power management feature + + void publishFeature( const char *feature ); + + // KEXT driver announces support of power management feature + // And specifies power sources with kIOPMSupportedOn{AC/Batt/UPS} bitfield. + // Returns a unique uint32_t identifier for later removing support for this + // feature. + // NULL is acceptable for uniqueFeatureID for kexts without plans to unload. + + void publishFeature( const char *feature, + uint32_t supportedWhere, + uint32_t *uniqueFeatureID); + + // KEXT driver announces removal of a previously published power management + // feature. Pass 'uniqueFeatureID' returned from publishFeature() + + IOReturn removePublishedFeature( uint32_t removeFeatureID ); + +/*! @function copyPMSetting + @abstract Copy the current value for a PM setting. Returns an OSNumber or + OSData depending on the setting. + @param whichSetting Name of the desired setting. + @result OSObject value if valid, NULL otherwise. */ + + OSObject * copyPMSetting( OSSymbol *whichSetting ); + +/*! @function registerPMSettingController + @abstract Register for callbacks on changes to certain PM settings. + @param settings NULL terminated array of C strings, each string for a PM + setting that the caller is interested in and wants to get callbacks for. + @param callout C function ptr or member function cast as such. + @param target The target of the callback, usually 'this' + @param refcon Will be passed to caller in callback; for caller's use. + @param handle Caller should keep the OSObject * returned here. If non-NULL, + handle will have a retain count of 1 on return. To deregister, pass to + unregisterPMSettingController() + @result kIOReturnSuccess on success. */ + + IOReturn registerPMSettingController( + const OSSymbol *settings[], + IOPMSettingControllerCallback callout, + OSObject *target, + uintptr_t refcon, + OSObject **handle); // out param + +/*! @function registerPMSettingController + @abstract Register for callbacks on changes to certain PM settings. + @param settings NULL terminated array of C strings, each string for a PM + setting that the caller is interested in and wants to get callbacks for. + @param supportedPowerSources bitfield indicating which power sources these + settings are supported for (kIOPMSupportedOnAC, etc.) + @param callout C function ptr or member function cast as such. + @param target The target of the callback, usually 'this' + @param refcon Will be passed to caller in callback; for caller's use. + @param handle Caller should keep the OSObject * returned here. If non-NULL, + handle will have a retain count of 1 on return. To deregister, pass to + unregisterPMSettingController() + @result kIOReturnSuccess on success. */ + + IOReturn registerPMSettingController( + const OSSymbol *settings[], + uint32_t supportedPowerSources, + IOPMSettingControllerCallback callout, + OSObject *target, + uintptr_t refcon, + OSObject **handle); // out param + + virtual IONotifier * registerInterest( + const OSSymbol * typeOfInterest, + IOServiceInterestHandler handler, + void * target, void * ref = 0 ); + + void pmStatsRecordEvent( + int eventIndex, + AbsoluteTime timestamp); + + void pmStatsRecordApplicationResponse( + const OSSymbol *response, + const char *name, + int messageType, + uint32_t delay_ms, + int app_pid); + + virtual IOReturn callPlatformFunction( + const OSSymbol *functionName, + bool waitForFunction, + void *param1, void *param2, + void *param3, void *param4 ); + +private: + virtual IOReturn changePowerStateTo( unsigned long ordinal ); + virtual IOReturn changePowerStateToPriv( unsigned long ordinal ); + virtual IOReturn requestPowerDomainState( IOPMPowerFlags, IOPowerConnection *, unsigned long ); + virtual void powerChangeDone( unsigned long ); + virtual bool tellChangeDown( unsigned long ); + virtual bool askChangeDown( unsigned long ); + virtual void tellChangeUp( unsigned long ); + virtual void tellNoChangeDown( unsigned long ); +}; + + +#endif /* _IOKIT_ROOTDOMAIN_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/pwr_mgt/IOPMLibDefs.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/pwr_mgt/IOPMLibDefs.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/pwr_mgt/IOPMLibDefs.h (revision 885) @@ -0,0 +1,40 @@ +/* + * 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@ + */ + + +#define kPMSetAggressiveness 0 +#define kPMGetAggressiveness 1 +#define kPMSleepSystem 2 +#define kPMAllowPowerChange 3 +#define kPMCancelPowerChange 4 +#define kPMShutdownSystem 5 +#define kPMRestartSystem 6 +#define kPMSleepSystemOptions 7 +#define kPMSetMaintenanceWakeCalendar 8 + +#define kNumPMMethods 9 Index: branches/azimutz/Cleancut/i386/include/IOKit/pwr_mgt/IOPMPowerSourceList.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/pwr_mgt/IOPMPowerSourceList.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/pwr_mgt/IOPMPowerSourceList.h (revision 885) @@ -0,0 +1,54 @@ +/* + * Copyright (c) 1998-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@ + */ +#include +#include + +class IOPMPowerSource; + +class IOPMPowerSourceList : public OSObject +{ + OSDeclareDefaultStructors(IOPMPowerSourceList) + private: + // pointer to first power source in list + IOPMPowerSource *firstItem; + + // how many power sources are in the list + unsigned long length; + + public: + void initialize(void); + void free(void); + + unsigned long numberOfItems(void); + IOReturn addToList(IOPMPowerSource *newPowerSource); + IOReturn removeFromList(IOPMPowerSource *theItem); + + IOPMPowerSource *firstInList(void); + IOPMPowerSource *nextInList(IOPMPowerSource *currentItem); +}; + Index: branches/azimutz/Cleancut/i386/include/IOKit/pwr_mgt/IOPMPrivate.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/pwr_mgt/IOPMPrivate.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/pwr_mgt/IOPMPrivate.h (revision 885) @@ -0,0 +1,269 @@ +/* + * Copyright (c) 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@ + */ +#ifndef _IOKIT_IOPMPRIVATE_H +#define _IOKIT_IOPMPRIVATE_H + +#include + +/*****************************************************************************/ + +// Private power commands issued to root domain +// bits 0-7 in IOPM.h + +enum { + kIOPMSetValue = (1<<16), + // don't sleep on clamshell closure on a portable with AC connected + kIOPMSetDesktopMode = (1<<17), + // set state of AC adaptor connected + kIOPMSetACAdaptorConnected = (1<<18) +}; + +/*****************************************************************************/ +/*****************************************************************************/ + +/* + * PM notification types + */ + +/* @constant kIOPMStateConsoleUserShutdown + * @abstract Notification of GUI shutdown state available to kexts. + * @discussion This type can be passed as arguments to registerPMSettingController() + * to receive callbacks. + */ +#define kIOPMStateConsoleShutdown "ConsoleShutdown" + +/* @enum ShutdownValues + * @abstract Potential values shared with key kIOPMStateConsoleUserShutdown + */ +enum { +/* @constant kIOPMStateConsoleShutdownNone + * @abstract System shutdown (or restart) hasn't started; system is ON. + * @discussion Next state: 2 + */ + kIOPMStateConsoleShutdownNone = 1, +/* @constant kIOPMStateConsoleShutdownPossible + * @abstract User has been presented with the option to shutdown or restart. Shutdown may be cancelled. + * @discussion Next state may be: 1, 4 + */ + kIOPMStateConsoleShutdownPossible = 2, +/* @constant kIOPMStateConsoleShutdownUnderway + * @abstract Shutdown or restart is proceeding. It may still be cancelled. + * @discussion Next state may be: 1, 4. This state is currently unused. + */ + kIOPMStateConsoleShutdownUnderway = 3, +/* @constant kIOPMStateConsoleShutdownCertain + * @abstract Shutdown is in progress and irrevocable. + * @discussion State remains 4 until power is removed from CPU. + */ + kIOPMStateConsoleShutdownCertain = 4 +}; + +/*****************************************************************************/ +/*****************************************************************************/ + +/* PM Statistics - event indices + * These are arguments to IOPMrootDomain::pmStatsRecordEvent(). + */ +enum { + kIOPMStatsHibernateImageWrite = 1, + kIOPMStatsHibernateImageRead, + kIOPMStatsDriversNotify, + kIOPMStatsApplicationNotify, + kIOPMStatsLateDriverAcknowledge, + kIOPMStatsLateAppAcknowledge, + + // To designate if you're specifying the start or stop end of + // each of the above events, do a bitwise OR of the appropriate + // Start/Stop flag and pass the result to IOPMrootDomain to record + // the event. + kIOPMStatsEventStartFlag = (1 << 24), + kIOPMStatsEventStopFlag = (1 << 25) +}; + +// Keys for IOPMrootDomain registry properties +#define kIOPMSleepStatisticsKey "SleepStatistics" +#define kIOPMSleepStatisticsAppsKey "AppStatistics" + +// Application response statistics +#define kIOPMStatsNameKey "Name" +#define kIOPMStatsPIDKey "Pid" +#define kIOPMStatsTimeMSKey "TimeMS" +#define kIOPMStatsApplicationResponseTypeKey "ResponseType" +#define kIOPMStatsMessageTypeKey "MessageType" + +// PM Statistics: potential values for the key kIOPMStatsApplicationResponseTypeKey +// entry in the application results array. +#define kIOPMStatsResponseTimedOut "ResponseTimedOut" +#define kIOPMStatsResponseCancel "ResponseCancel" +#define kIOPMStatsResponseSlow "ResponseSlow" + +typedef struct { + struct bounds{ + uint64_t start; + uint64_t stop; + }; + + struct bounds hibWrite; + struct bounds hibRead; +// bounds driverNotifySleep; +// bounds driverNotifyWake; +// bounds appNotifySleep; +// bounds appNotifyWake; +// OSDictionary *tardyApps; +// OSDictionary *tardyDrivers; +} PMStatsStruct; + +/*****************************************************************************/ + +/* PM RootDomain tracePoints + * + * In the sleep/wake process, we expect the sleep trace points to proceed + * in increasing order. Once sleep begins with code kIOPMTracePointSleepStarted = 0x11, + * we expect sleep to continue in a monotonically increasing order of tracepoints + * to kIOPMTracePointSystemLoginwindowPhase = 0x30. After trace point SystemLoginWindowPhase, + * the system will return to kIOPMTracePointSystemUp = 0x00. + * + * If the trace point decreases (instead of increasing) before reaching kIOPMTracePointSystemUp, + * that indicates that the sleep process was cancelled. The cancel reason shall be indicated + * in the cancel tracepoint. (TBD) + */ + +enum { +/* When kTracePointSystemUp is the latest tracePoint, + the system is awake. It is not asleep, sleeping, or waking. + + * Phase begins: At boot, at completion of wake from sleep, + immediately following kIOPMTracePointSystemLoginwindowPhase. + * Phase ends: When a sleep attempt is initiated. + */ + kIOPMTracePointSystemUp = 0, + +/* When kIOPMTracePointSleepStarted we have just initiated sleep. + + Note: The state prior to kIOPMTracePointSleepStarted may be only one of: + * kIOPMTracePointSystemUp + * kIOPMTracePointSystemLoginwindowPhase or + + * Phase begins: At initiation of system sleep (idle or forced). + * Phase ends: As we start to notify applications of system sleep. + */ + kIOPMTracePointSleepStarted = 0x11, + +/* When kTracePointSystemSleepAppsPhase is the latest tracePoint, + a system sleep has been irrevocably inititated and PM waits + for responses from notified applications. + + * Phase begins: Begin to asynchronously fire kIOMessageSystemWillSleep notifications, + * and in the case of an idle sleep kIOMessageCanSystemSleep as well. + * Phase ends: When we have received all user & interested kernel acknowledgements. + */ + kIOPMTracePointSystemSleepAppsPhase = 0x12, + + +/* When kIOPMTracePointSystemHibernatePhase is the latest tracePoint, + PM is writing the hiernate image to disk. + */ + kIOPMTracePointSystemHibernatePhase = 0x13, + +/* When kTracePointSystemSleepDriversPhase is the latest tracePoint, + PM is iterating the driver tree powering off devices individually. + + * Phase begins: When IOPMrootDomain has received all of its power acknowledgements and begins + * executing IOService::powerDomainWillChangeTo() + * Phase ends: When IOPMrootDomain::powerChangeDone begins executing CPU shutoff code. + */ + kIOPMTracePointSystemSleepDriversPhase = 0x14, + +/* When kTracePointSystemSleepPlatformPhase is the latest tracePoint, + all apps and drivers have notified of sleep. Plotfarm is powering + off CPU; or system is asleep; or low level wakeup is underway. + + Note: If a system is asleep and then loses power, and it does not have a hibernate + image to restore from (e.g. hibernatemode = 0), then OS X may interpret this power + loss as a system crash in the kTracePointSystemSleepPlatformPhase, since the + power loss resembles a hang or crash, and the power being removed by the user. + + * Phase begins: IOPMrootDomain has already shut off drivers, and is now powering off CPU. + * Phase ends: Immediately after CPU's are powered back on during wakeup. + */ + kIOPMTracePointSystemSleepPlatformPhase = 0x15, + +/* When kTracePointSystemWakeDriversPhase is the latest tracePoint, + System CPU is powered, PM is notifying drivers of system wake. + + * Phase begins: CPU's have successfully powered up and OS is executing. + * Phase ends: All drivers have handled power events & acknowledged completion. + IOPMrootDomain is about to deliver kIOMessageSystemHasPoweredOn. + */ + kIOPMTracePointSystemWakeDriversPhase = 0x21, + +/* When kTracePointSystemWakeAppsPhase is the latest tracePoint, + System CPU is powered, PM has powered on each driver. + + * Phase begins: IOPMrootDomain::tellChangeUp before sending asynchronous + kIOMessageSystemHasPoweredOn notifications + * Phase ends: IOPMrootDomain::tellChangeUp after sending asynchronous notifications + */ + kIOPMTracePointSystemWakeAppsPhase = 0x22, + +/* kIOPMTracePointSystemLoginwindowPhase + This phase represents a several minute window after the system has powered on. + Higher levels of system diagnostics are in a heightened state of alert in this phase, + in case any user errors occurred that we could not detect in software. + + This several minute window + + * Phase begins: After IOPMrootDomain sends kIOMessageSystemHasPoweredOn message. + * Phase ends: When loginwindow calls IOPMSleepWakeSetUUID(NULL) the system shall + be considered awake and usable. The next phase shall be kIOPMTracePointSystemUp. + */ + kIOPMTracePointSystemLoginwindowPhase = 0x30 +}; + +/*****************************************************************************/ + +/* +Ê* kIOPMLoginWindowSecurityDebugKey - identifies PM debug data specific to LoginWindow + * for use with IOPMrootDomain. +Ê*/ +#define kIOPMLoginWindowSecurityDebugKey "LoginWindowSecurity" + +// For PM internal use only - key to locate sleep failure results within SCDynamicStore. +#define kIOPMDynamicStoreSleepFailureKey "SleepFailure" + +/*****************************************************************************/ + +// For IOPMLibPrivate.h +#define kIOPMSleepWakeFailureKey "PMFailurePhase" +#define kIOPMSleepWakeFailureCodeKey "PMStatusCode" +#define kIOPMSleepWakeFailureLoginKey "LWFailurePhase" +#define kIOPMSleepWakeFailureUUIDKey "UUID" +#define kIOPMSleepWakeFailureDateKey "Date" + +#endif /* ! _IOKIT_IOPMPRIVATE_H */ + Index: branches/azimutz/Cleancut/i386/include/IOKit/pwr_mgt/IOPMPowerSource.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/pwr_mgt/IOPMPowerSource.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/pwr_mgt/IOPMPowerSource.h (revision 885) @@ -0,0 +1,300 @@ +/* + * Copyright (c) 1998-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 _IOPMPowerSource_h_ +#define _IOPMPowerSource_h_ + +#include +#include +#include +#include +#include + +enum { + kSecondsPerHour = 3600, + kTenMinutesInSeconds = 600 +}; + +/* class IOPMPowerSource + * + * See IOKit/pwr_mgt/IOPM.h for power source keys relevant to this class. These + * report-type keys are required for calls to IOPMPowerSource::setReportables(), + * and they define the IORegistry interface through which data is passed back + * up to the rest of the system. + * + * A subclassing driver that doesn't want to do anything fancy should: + * 1. Subclass IOPMPowerSource + * 3. Install its own battery change notifications or polling routine that can + * converse with actual battery hardware. + * 4. When battery state changes, change the relevant member variables + * through setCurrentCapacity() style accessors. + * 5. Call updateStatus() on itself when all such settings have been updated. + * + * The subclass driver should also initially populate its settings and call + * updateStatus() on launch. + * + * + * Settings + * + * ExternalConnected + * Type: bool + * IORegistry Key: kIOPMPSExternalConnectedKey + * True if computer is drawing external power + * + * ExternalChargeCapable + * Type: bool + * IORegistry Key: kIOPMPSExternalChargeCapableKey + * True if external power is capable of charging internal battery + * + * BatteryInstalled + * Type: bool + * IORegistry Key: kIOPMPSBatteryInstalledKey + * True if a battery is present; false if removed + * + * IsCharging + * Type: bool + * IORegistry Key: kIOPMPSIsChargingKey + * True if battery is charging itself from external power + * + * AtWarnLevel + * Type: bool + * IORegistry Key: kIOPMPSAtWarnLevelKey + * True if draining battery capacity and past warn level + * + * AtCriticalLevel + * Type: bool + * IORegistry Key: kIOPMPSAtCriticalLevelKey + * True if draining battery capacity and past critical level + * + * CurrentCapacity + * MaxCapacity + * Type: unsigned int + * IORegistry Key: kIOPMPSCurrentCapacityKey, kIOPMPSMaxCapacityKey + * Capacity measured in mAh + * + * TimeRemaining + * Type: int + * IORegistry Key: kIOPMPSTimeRemainingKey + * Time remaining measured in minutes + * + * Amperage + * Type: int + * IORegistry Key: kIOPMPSAmperageKey + * Current is measured in mA + * + * Voltage + * Type: unsigned int + * IORegistry Key: kIOPMPSVoltageKey + * Voltage measured in mV + * + * CycleCount + * Type: unsigned int + * IORegistry Key: kIOPMPSCycleCountKey + * Number of charge/discharge cycles + * + * AdapterInfo + * Type: int + * IORegistry Key: kIOPMPSAdapterInfoKey + * Power adapter information + * + * Location + * Type: int + * IORegistry Key: kIOPMPSLocationKey + * Clue about battery's location in machine - Left vs. Right + * + * ErrorCondition + * Type: OSSymbol + * IORegistry Key: kIOPMPSErrorConditionKey + * String describing error state of battery + * + * Manufacturer + * Type: OSSymbol + * IORegistry Key: kIOPMPSManufacturerKey + * String describing battery manufacturer + * + * Manufactured Date + * Type: unsigned 16-bit bitfield + * IORegistry Key: kIOPMPSManufactureDateKey + * Date is published in a bitfield per the Smart Battery Data spec rev 1.1 + * in section 5.1.26 + * Bits 0...4 => day (value 1-31; 5 bits) + * Bits 5...8 => month (value 1-12; 4 bits) + * Bits 9...15 => years since 1980 (value 0-127; 7 bits) + * + * Model + * Type: OSSymbol + * IORegistry Key: kIOPMPSModelKey + * String describing model number + * + * Serial + * Type: OSSymbol + * IORegistry Key: kIOPMPSSerialKey + * String describing serial number or unique info + * The serial number published hear bears no correspondence to the Apple serial + * number printed on each battery. This is a manufacturer serial number with + * no correlation to the printed serial number. + * + * LegacyIOBatteryInfo + * Type: OSDictionary + * IORegistry Key: kIOPMPSLegacyBatteryInfoKey + * Dictionary conforming to the OS X 10.0-10.4 + */ + +class IOPMPowerSource : public IOService +{ + OSDeclareDefaultStructors(IOPMPowerSource) + + friend class IOPMPowerSourceList; + + protected: + +/* bool settingsChangedSinceLastUpdate + * Used by subclasses to determine if any settings have been modified via the + * accessors below since last call to update(). true is settings have changed; + * false otherwise. + */ + bool settingsChangedSinceUpdate; + +/* OSDictionary properties + * Stores power source state + */ + OSDictionary *properties; + + const OSSymbol *externalConnectedKey; + const OSSymbol *externalChargeCapableKey; + const OSSymbol *batteryInstalledKey; + const OSSymbol *chargingKey; + const OSSymbol *warnLevelKey; + const OSSymbol *criticalLevelKey; + const OSSymbol *currentCapacityKey; + const OSSymbol *maxCapacityKey; + const OSSymbol *timeRemainingKey; + const OSSymbol *amperageKey; + const OSSymbol *voltageKey; + const OSSymbol *cycleCountKey; + const OSSymbol *adapterInfoKey; + const OSSymbol *locationKey; + const OSSymbol *errorConditionKey; + const OSSymbol *manufacturerKey; + const OSSymbol *modelKey; + const OSSymbol *serialKey; + const OSSymbol *batteryInfoKey; + + // Tracking for IOPMPowerSourceList + IOPMPowerSource *nextInList; + + public: + +/*! @function powerSource + @abstract Creates a new IOPMPowerSource nub. Must be attached to IORegistry, + and registered by provider. +*/ + static IOPMPowerSource *powerSource(void); + + virtual bool init(void); + + virtual void free(void); + +/*! @function updateStatus + @abstract Must be called by physical battery controller when battery state + has changed significantly. + @discussion The system will not poll this object for battery updates. Rather \ + the battery's controller must call updateStatus() every time state changes \ + and the settings will be relayed to higher levels of power management. \ + The subclassing driver should override this only if the driver needs to add \ + new settings to the base class. +*/ + virtual void updateStatus(void); + +/* Public accessors for battery state + */ + bool externalConnected(void); + bool externalChargeCapable(void); + bool batteryInstalled(void); + bool isCharging(void); + bool atWarnLevel(void); + bool atCriticalLevel(void); + + unsigned int currentCapacity(void); + unsigned int maxCapacity(void); + unsigned int capacityPercentRemaining(void); + int timeRemaining(void); + int amperage(void); + unsigned int voltage(void); + unsigned int cycleCount(void); + int adapterInfo(void); + int location(void); + + OSSymbol *errorCondition(void); + OSSymbol *manufacturer(void); + OSSymbol *model(void); + OSSymbol *serial(void); + OSDictionary *legacyIOBatteryInfo(void); + + OSObject *getPSProperty(const OSSymbol *); + +protected: + +/* Protected "setter" methods for subclasses + * Subclasses should use these setters to modify all battery properties. + * + * Subclasses must follow all property changes with a call to updateStatus() + * to flush settings changes to upper level battery API clients. + * + */ + void setExternalConnected(bool); + void setExternalChargeCapable(bool); + void setBatteryInstalled(bool); + void setIsCharging(bool); + void setAtWarnLevel(bool); + void setAtCriticalLevel(bool); + + void setCurrentCapacity(unsigned int); + void setMaxCapacity(unsigned int); + void setTimeRemaining(int); + void setAmperage(int); + void setVoltage(unsigned int); + void setCycleCount(unsigned int); + void setAdapterInfo(int); + void setLocation(int); + + void setErrorCondition(OSSymbol *); + void setManufacturer(OSSymbol *); + void setModel(OSSymbol *); + void setSerial(OSSymbol *); + void setLegacyIOBatteryInfo(OSDictionary *); + +/* All of these methods funnel through the generic accessor method + setPSProperty. Caller can pass in any arbitrary OSSymbol key, and + that value will be stored in the PM settings dictionary, and relayed + onto the IORegistry at update time. + */ + void setPSProperty(const OSSymbol *, OSObject *); +}; + +#endif Index: branches/azimutz/Cleancut/i386/include/IOKit/pwr_mgt/IOPMpowerState.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/pwr_mgt/IOPMpowerState.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/pwr_mgt/IOPMpowerState.h (revision 885) @@ -0,0 +1,72 @@ +/* + * 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@ + */ +#include + +/*! @header IOPMpowerState.h + @abstract Defines the struct IOPMPowerState that power managed drivers should use to describe their power states. +*/ + +/*! @struct IOPMPowerState + @abstract Describes a device's power state. + @discussion To take part in system power management, drivers should define an array of 2 or more power states and pass it to kernel power management through IOService::registerPowerDriver. + @field version Defines version number of this struct. Just use the value "1" when defining an IOPMPowerState. + @field capabilityFlags Describes the capability of the device in this state. + @field outputPowerCharacter Describes the power provided in this state. + @field inputPowerRequirement Describes the input power required in this state. + @field staticPower Describes average consumption in milliwatts. Unused; drivers may specify 0. + @field unbudgetedPower Describes additional consumption from separate power supply (milliWatts). Unused; drivers may specify 0. + @field powerToAttain Describes dditional power to attain this state from next lower state (in milliWatts). Unused; drivers may specify 0. + @field timeToAttain Describes time required to enter this state from next lower state (in microseconds). Unused; drivers may specify 0. + @field settleUpTime Describes settle time required after entering this state from next lower state (microseconds). Unused; drivers may specify 0. + @field timeToLower Describes time required to enter next lower state from this one (microseconds). Unused; drivers may specify 0. + @field settleDownTime Settle time required after entering next lower state from this state (microseconds). Unused; drivers may specify 0. + @field powerDomainBudget Describes power in milliWatts a domain in this state can deliver to its children. Unused; drivers may specify 0. +} +*/ + +struct IOPMPowerState +{ + unsigned long version; + IOPMPowerFlags capabilityFlags; + IOPMPowerFlags outputPowerCharacter; + IOPMPowerFlags inputPowerRequirement; + unsigned long staticPower; + unsigned long unbudgetedPower; + unsigned long powerToAttain; + unsigned long timeToAttain; + unsigned long settleUpTime; + unsigned long timeToLower; + unsigned long settleDownTime; + unsigned long powerDomainBudget; +}; + +typedef struct IOPMPowerState IOPMPowerState; + +enum { + kIOPMPowerStateVersion1 = 1 +}; Index: branches/azimutz/Cleancut/i386/include/IOKit/pwr_mgt/IOPM.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/pwr_mgt/IOPM.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/pwr_mgt/IOPM.h (revision 885) @@ -0,0 +1,654 @@ +/* + * Copyright (c) 1998-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_IOPM_H +#define _IOKIT_IOPM_H + +#include +#include +#include + +#ifdef __ppc__ +#include +#endif + +/*! @header IOPM.h + @abstract Defines power management constants and keys used by both in-kernel and user space power management. + @discussion IOPM.h defines a range of power management constants used in several in-kernel and user space APIs. Most significantly, the IOPMPowerFlags used to specify the fields of an IOPMPowerState struct are defined here. + + Most of the constants defined in IOPM.h are deprecated or for Apple internal use only, and are not elaborated on in headerdoc. +*/ + +enum { + kIOPMMaxPowerStates = 10, + IOPMMaxPowerStates = kIOPMMaxPowerStates +}; + +/*! @enum IOPMPowerFlags + @abstract Bits are used in defining capabilityFlags, inputPowerRequirements, and outputPowerCharacter in the IOPMPowerState structure. + @discussion These bits may be bitwise-OR'd together in the IOPMPowerState capabilityFlags field, the outputPowerCharacter field, and/or the inputPowerRequirement field. + + The comments clearly mark whether each flag should be used in the capabilityFlags field, outputPowerCharacter field, and inputPowerRequirement field, or all three. + + The value of capabilityFlags, inputPowerRequirement or outputPowerCharacter may be 0. Most drivers implement their 'OFF' state, used when asleep, by defininf each of the 3 fields as 0. + + The bits listed below are only the most common bits used to define a device's power states. Your device's IO family may require that your device specify other input or output power flags to interact properly. Consult family-specific documentation to determine if your IOPower plane parents or children require other power flags; they probably don't. + + @constant kIOPMPowerOn Indicates the device is on, requires power, and provides power. Useful as a: Capability, InputPowerRequirement, OutputPowerCharacter + + @constant kIOPMDeviceUsable Indicates the device is usable in this state. Useful only as a Capability + + @constant kIOPMLowPower + Indicates device is in a low power state. May be bitwis-OR'd together + with kIOPMDeviceUsable flag, to indicate the device is still usable. + + A device with a capability of kIOPMLowPower may: + Require either 0 or kIOPMPowerOn from its power parent + Offer either kIOPMLowPower, kIOPMPowerOn, or 0 (no power at all) + to its power plane children. + + Useful only as a Capability, although USB drivers should consult USB family documentation for other valid circumstances to use the kIOPMLowPower bit. + + @constant kIOPMPreventIdleSleep + In the capability field of a power state, disallows idle system sleep while the device is in that state. + + For example, displays and disks set this capability for their ON power state; since the system may not idle sleep while the display (and thus keyboard or mouse) or the disk is active. + + Useful only as a Capability. + + @constant kIOPMSleepCapability + Used only by certain IOKit Families (USB). Not defined or used by generic Power Management. Read your family documentation to see if you should define a powerstate using these capabilities. + + @constant kIOPMRestartCapability + Used only by certain IOKit Families (USB). Not defined or used by generic Power Management. Read your family documentation to see if you should define a powerstate using these capabilities. + + @constant kIOPMSleep + Used only by certain IOKit Families (USB). Not defined or used by generic Power Management. Read your family documentation to see if you should define a powerstate using these capabilities. + + @constant kIOPMRestart + Used only by certain IOKit Families (USB). Not defined or used by generic Power Management. Read your family documentation to see if you should define a powerstate using these capabilities. +*/ +typedef unsigned long IOPMPowerFlags; +enum { + kIOPMPowerOn = 0x00000002, + kIOPMDeviceUsable = 0x00008000, + kIOPMLowPower = 0x00010000, + kIOPMPreventIdleSleep = 0x00000040, + kIOPMSleepCapability = 0x00000004, + kIOPMRestartCapability = 0x00000080, + kIOPMSleep = 0x00000001, + kIOPMRestart = 0x00000080 +}; + +/* + * Private IOPMPowerFlags + * + * For Apple use only + * Not for use with non-Apple drivers + * Their behavior is undefined + */ +enum { + kIOPMClockNormal = 0x0004, + kIOPMClockRunning = 0x0008, + kIOPMPreventSystemSleep = 0x0010, + kIOPMDoze = 0x0400, + kIOPMChildClamp = 0x0080, + kIOPMChildClamp2 = 0x0200, + kIOPMNotPowerManaged = 0x0800 +}; + + +/* + * Deprecated IOPMPowerFlags + * Their behavior is undefined when used in IOPMPowerState + * Capability, InputPowerRequirement, or OutputPowerCharacter fields. + */ +enum { + kIOPMMaxPerformance = 0x4000, + kIOPMPassThrough = 0x0100, + kIOPMAuxPowerOn = 0x0020, + kIOPMNotAttainable = 0x0001, + kIOPMContextRetained = 0x2000, + kIOPMConfigRetained = 0x1000, + kIOPMStaticPowerValid = 0x0800, + kIOPMSoftSleep = 0x0400, + kIOPMCapabilitiesMask = kIOPMPowerOn | kIOPMDeviceUsable | + kIOPMMaxPerformance | kIOPMContextRetained | + kIOPMConfigRetained | kIOPMSleepCapability | + kIOPMRestartCapability +}; + +/* + * Support for old names of IOPMPowerFlag constants + */ +enum { + IOPMNotAttainable = kIOPMNotAttainable, + IOPMPowerOn = kIOPMPowerOn, + IOPMClockNormal = kIOPMClockNormal, + IOPMClockRunning = kIOPMClockRunning, + IOPMAuxPowerOn = kIOPMAuxPowerOn, + IOPMDeviceUsable = kIOPMDeviceUsable, + IOPMMaxPerformance = kIOPMMaxPerformance, + IOPMContextRetained = kIOPMContextRetained, + IOPMConfigRetained = kIOPMConfigRetained, + IOPMNotPowerManaged = kIOPMNotPowerManaged, + IOPMSoftSleep = kIOPMSoftSleep +}; + + +enum { + kIOPMNextHigherState = 1, + kIOPMHighestState = 2, + kIOPMNextLowerState = 3, + kIOPMLowestState = 4 +}; + +enum { + IOPMNextHigherState = kIOPMNextHigherState, + IOPMHighestState = kIOPMHighestState, + IOPMNextLowerState = kIOPMNextLowerState, + IOPMLowestState = kIOPMLowestState +}; + +// Internal commands used by power managment command queue +enum { + kIOPMBroadcastAggressiveness = 1, + kIOPMUnidleDevice +}; + +// Power consumption unknown value +enum { + kIOPMUnknown = 0xFFFF +}; + +/******************************************************************************* + * + * Root Domain property keys of interest + * + ******************************************************************************/ + +/* AppleClamshellState + * reflects the state of the clamshell (lid) on a portable. + * It has a boolean value. + * true == clamshell is closed + * false == clamshell is open + * not present == no clamshell on this hardware + */ +#define kAppleClamshellStateKey "AppleClamshellState" + +/* AppleClamshellCausesSleep + * reflects the clamshell close behavior on a portable. + * It has a boolean value. + * true == system will sleep when clamshell is closed + * false == system will not sleep on clamshell close + * (typically external display mode) + * not present == no clamshell on this hardware + */ +#define kAppleClamshellCausesSleepKey "AppleClamshellCausesSleep" + +/* kIOPMSleepWakeUUIDKey + * Key refers to a CFStringRef that will uniquely identify + * a sleep/wake cycle for logging & tracking. + * The key becomes valid at the beginning of a sleep cycle - before we + * initiate any sleep/wake notifications. + * The key becomes invalid at the completion of a system wakeup. The + * property will not be present in the IOPMrootDomain's registry entry + * when it is invalid. + * + * See IOPMrootDomain notification kIOPMMessageSleepWakeUUIDChange + */ + #define kIOPMSleepWakeUUIDKey "SleepWakeUUID" + +/******************************************************************************* + * + * Root Domain general interest messages + * + * Available by registering for interest type 'gIOGeneralInterest' + * on IOPMrootDomain. + * + ******************************************************************************/ + +/* kIOPMMessageClamshellStateChange + * Delivered as a general interest notification on the IOPMrootDomain + * IOPMrootDomain sends this message when state of either AppleClamshellState + * or AppleClamshellCausesSleep changes. If this clamshell change results in + * a sleep, the sleep will initiate soon AFTER delivery of this message. + * The state of both variables is encoded in a bitfield argument sent with + * the message. Check bits 0 and 1 using kClamshellStateBit & kClamshellSleepBit + */ +enum { + kClamshellStateBit = (1 << 0), + kClamshellSleepBit = (1 << 1) +}; + +#define kIOPMMessageClamshellStateChange \ + iokit_family_msg(sub_iokit_powermanagement, 0x100) + +/* kIOPMMessageFeatureChange + * Delivered when the set of supported features ("Supported Features" dictionary + * under IOPMrootDomain registry) changes in some way. Typically addition or + * removal of a supported feature. + * RootDomain passes no argument with this message. + */ +#define kIOPMMessageFeatureChange \ + iokit_family_msg(sub_iokit_powermanagement, 0x110) + +/* kIOPMMessageInflowDisableCancelled + * The battery has drained completely to its "Fully Discharged" state. + * If a user process has disabled battery inflow for battery + * calibration, we forcibly re-enable Inflow at this point. + * If inflow HAS been forcibly re-enabled, bit 0 + * (kInflowForciblyEnabledBit) will be set. + */ +enum { + kInflowForciblyEnabledBit = (1 << 0) +}; + +/* kIOPMMessageInternalBatteryFullyDischarged + * The battery has drained completely to its "Fully Discharged" state. + */ +#define kIOPMMessageInternalBatteryFullyDischarged \ + iokit_family_msg(sub_iokit_powermanagement, 0x120) + +/* kIOPMMessageSystemPowerEventOccurred + * Some major system thermal property has changed, and interested clients may + * modify their behavior. + */ +#define kIOPMMessageSystemPowerEventOccurred \ + iokit_family_msg(sub_iokit_powermanagement, 0x130) + +/* kIOPMMessageSleepWakeUUIDChange + * Either a new SleepWakeUUID has been specified at the beginning of a sleep, + * or we're removing the existing property upon completion of a wakeup. + */ +#define kIOPMMessageSleepWakeUUIDChange \ + iokit_family_msg(sub_iokit_powermanagement, 0x140) + +/* kIOPMMessageSleepWakeUUIDSet + * Argument accompanying the kIOPMMessageSleepWakeUUIDChange notification when + * a new UUID has been specified. + */ +#define kIOPMMessageSleepWakeUUIDSet ((void *)1) + +/* kIOPMMessageSleepWakeUUIDCleared + * Argument accompanying the kIOPMMessageSleepWakeUUIDChange notification when + * the current UUID has been removed. + */ +#define kIOPMMessageSleepWakeUUIDCleared ((void *)0) + +/******************************************************************************* + * + * Power commands issued to root domain + * Use with IOPMrootDomain::receivePowerNotification() + * + * These commands are issued from system drivers only: + * ApplePMU, AppleSMU, IOGraphics, AppleACPIFamily + * + ******************************************************************************/ +enum { + kIOPMSleepNow = (1<<0), // put machine to sleep now + kIOPMAllowSleep = (1<<1), // allow idle sleep + kIOPMPreventSleep = (1<<2), // do not allow idle sleep + kIOPMPowerButton = (1<<3), // power button was pressed + kIOPMClamshellClosed = (1<<4), // clamshell was closed + kIOPMPowerEmergency = (1<<5), // battery dangerously low + kIOPMDisableClamshell = (1<<6), // do not sleep on clamshell closure + kIOPMEnableClamshell = (1<<7), // sleep on clamshell closure + kIOPMProcessorSpeedChange = (1<<8), // change the processor speed + kIOPMOverTemp = (1<<9), // system dangerously hot + kIOPMClamshellOpened = (1<<10) // clamshell was opened +}; + + +/******************************************************************************* + * + * Power Management Return Codes + * + ******************************************************************************/ +enum { + kIOPMNoErr = 0, + + // Returned by driver's setPowerState(), powerStateWillChangeTo(), + // powerStateDidChangeTo(), or acknowledgeSetPowerState() to + // implicitly acknowledge power change upon function return. + kIOPMAckImplied = 0, + + // Deprecated + kIOPMWillAckLater = 1, + + // Returned by requestPowerDomainState() to indicate + // unrecognized specification parameter. + kIOPMBadSpecification = 4, + + // Returned by requestPowerDomainState() to indicate + // no power state matches search specification. + kIOPMNoSuchState = 5, + + // Deprecated + kIOPMCannotRaisePower = 6, + + // Deprecated + kIOPMParameterError = 7, + + // Returned when power management state is accessed + // before driver has called PMinit(). + kIOPMNotYetInitialized = 8, + + // And the old constants; deprecated + IOPMNoErr = kIOPMNoErr, + IOPMAckImplied = kIOPMAckImplied, + IOPMWillAckLater = kIOPMWillAckLater, + IOPMBadSpecification = kIOPMBadSpecification, + IOPMNoSuchState = kIOPMNoSuchState, + IOPMCannotRaisePower = kIOPMCannotRaisePower, + IOPMParameterError = kIOPMParameterError, + IOPMNotYetInitialized = kIOPMNotYetInitialized +}; + + +// IOPMPowerSource class descriptive strings +// Power Source state is published as properties to the IORegistry under these +// keys. +#define kIOPMPSExternalConnectedKey "ExternalConnected" +#define kIOPMPSExternalChargeCapableKey "ExternalChargeCapable" +#define kIOPMPSBatteryInstalledKey "BatteryInstalled" +#define kIOPMPSIsChargingKey "IsCharging" +#define kIOPMFullyChargedKey "FullyCharged" +#define kIOPMPSAtWarnLevelKey "AtWarnLevel" +#define kIOPMPSAtCriticalLevelKey "AtCriticalLevel" +#define kIOPMPSCurrentCapacityKey "CurrentCapacity" +#define kIOPMPSMaxCapacityKey "MaxCapacity" +#define kIOPMPSDesignCapacityKey "DesignCapacity" +#define kIOPMPSTimeRemainingKey "TimeRemaining" +#define kIOPMPSAmperageKey "Amperage" +#define kIOPMPSVoltageKey "Voltage" +#define kIOPMPSCycleCountKey "CycleCount" +#define kIOPMPSMaxErrKey "MaxErr" +#define kIOPMPSAdapterInfoKey "AdapterInfo" +#define kIOPMPSLocationKey "Location" +#define kIOPMPSErrorConditionKey "ErrorCondition" +#define kIOPMPSManufacturerKey "Manufacturer" +#define kIOPMPSManufactureDateKey "ManufactureDate" +#define kIOPMPSModelKey "Model" +#define kIOPMPSSerialKey "Serial" +#define kIOPMDeviceNameKey "DeviceName" +#define kIOPMPSLegacyBatteryInfoKey "LegacyBatteryInfo" +#define kIOPMPSBatteryHealthKey "BatteryHealth" +#define kIOPMPSHealthConfidenceKey "HealthConfidence" +#define kIOPMPSCapacityEstimatedKey "CapacityEstimated" +#define kIOPMPSBatteryChargeStatusKey "ChargeStatus" +#define kIOPMPSBatteryTemperatureKey "Temperature" + +// kIOPMPSBatteryChargeStatusKey may have one of the following values, or may have +// no value. If kIOPMBatteryChargeStatusKey has a NULL value (or no value) associated with it +// then charge is proceeding normally. If one of these battery charge status reasons is listed, +// then the charge may have been interrupted. +#define kIOPMBatteryChargeStatusTooHot "HighTemperature" +#define kIOPMBatteryChargeStatusTooCold "LowTemperature" +#define kIOPMBatteryChargeStatusGradient "BatteryTemperatureGradient" + +// Definitions for battery location, in case of multiple batteries. +// A location of 0 is unspecified +// Location is undefined for single battery systems +enum { + kIOPMPSLocationLeft = 1001, + kIOPMPSLocationRight = 1002 +}; + +// Battery quality health types, specified by BatteryHealth and HealthConfidence +// properties in an IOPMPowerSource battery kext. +enum { + kIOPMUndefinedValue = 0, + kIOPMPoorValue = 1, + kIOPMFairValue = 2, + kIOPMGoodValue = 3 +}; + +// Battery's time remaining estimate is invalid this long (seconds) after a wake +#define kIOPMPSInvalidWakeSecondsKey "BatteryInvalidWakeSeconds" + +// Battery must wait this long (seconds) after being completely charged before +// the battery is settled. +#define kIOPMPSPostChargeWaitSecondsKey "PostChargeWaitSeconds" + +// Battery must wait this long (seconds) after being completely discharged +// before the battery is settled. +#define kIOPMPSPostDishargeWaitSecondsKey "PostDischargeWaitSeconds" + + +/* CPU Power Management status keys + * Pass as arguments to IOPMrootDomain::systemPowerEventOccurred + * Or as arguments to IOPMSystemPowerEventOccurred() + * Or to decode the dictionary obtained from IOPMCopyCPUPowerStatus() + * These keys reflect restrictions placed on the CPU by the system + * to bring the CPU's power consumption within allowable thermal and + * power constraints. + */ + + +/* kIOPMGraphicsPowerLimitsKey + * The key representing the dictionary of graphics power limits. + * The dictionary contains the other kIOPMCPUPower keys & their associated + * values (e.g. Speed limit, Processor Count, and Schedule limits). + */ +#define kIOPMGraphicsPowerLimitsKey "Graphics_Power_Limits" + +/* kIOPMGraphicsPowerLimitPerformanceKey + * The key representing the percent of overall performance made available + * by the graphics chip as a percentage (integer 0 - 100). + */ +#define kIOPMGraphicsPowerLimitPerformanceKey "Graphics_Power_Performance" + + + +/* kIOPMCPUPowerLimitsKey + * The key representing the dictionary of CPU Power Limits. + * The dictionary contains the other kIOPMCPUPower keys & their associated + * values (e.g. Speed limit, Processor Count, and Schedule limits). + */ +#define kIOPMCPUPowerLimitsKey "CPU_Power_Limits" + +/* kIOPMCPUPowerLimitProcessorSpeedKey defines the speed & voltage limits placed + * on the CPU. + * Represented as a percentage (0-100) of maximum CPU speed. + */ +#define kIOPMCPUPowerLimitProcessorSpeedKey "CPU_Speed_Limit" + +/* kIOPMCPUPowerLimitProcessorCountKey reflects how many, if any, CPUs have been + * taken offline. Represented as an integer number of CPUs (0 - Max CPUs). + */ +#define kIOPMCPUPowerLimitProcessorCountKey "CPU_Available_CPUs" + +/* kIOPMCPUPowerLimitSchedulerTimeKey represents the percentage (0-100) of CPU time + * available. 100% at normal operation. The OS may limit this time for a percentage + * less than 100%. + */ +#define kIOPMCPUPowerLimitSchedulerTimeKey "CPU_Scheduler_Limit" + + +/* Thermal Level Warning Key + * Indicates the thermal constraints placed on the system. This value may + * cause clients to action to consume fewer system resources. + * The value associated with this warning is defined by the platform. + */ +#define kIOPMThermalLevelWarningKey "Thermal_Level_Warning" + +/* Thermal Warning Level values + * kIOPMThermalWarningLevelNormal - under normal operating conditions + * kIOPMThermalWarningLevelDanger - thermal pressure may cause system slowdown + * kIOPMThermalWarningLevelCrisis - thermal conditions may cause imminent shutdown + * + * The platform may define additional thermal levels if necessary. + */ +enum { + kIOPMThermalWarningLevelNormal = 0, + kIOPMThermalWarningLevelDanger = 5, + kIOPMThermalWarningLevelCrisis = 10 +}; + + +// PM Settings Controller setting types +// Settings types used primarily with: +// IOPMrootDomain::registerPMSettingController +// The values are identical to the similarly named keys for use in user space +// PM settings work. Those keys are defined in IOPMLibPrivate.h. +#define kIOPMSettingWakeOnRingKey "Wake On Modem Ring" +#define kIOPMSettingRestartOnPowerLossKey "Automatic Restart On Power Loss" +#define kIOPMSettingWakeOnACChangeKey "Wake On AC Change" +#define kIOPMSettingSleepOnPowerButtonKey "Sleep On Power Button" +#define kIOPMSettingWakeOnClamshellKey "Wake On Clamshell Open" +#define kIOPMSettingReduceBrightnessKey "ReduceBrightness" +#define kIOPMSettingDisplaySleepUsesDimKey "Display Sleep Uses Dim" +#define kIOPMSettingTimeZoneOffsetKey "TimeZoneOffsetSeconds" +#define kIOPMSettingMobileMotionModuleKey "MobileMotionModule" +#define kIOPMSettingGraphicsSwitchKey "GPUSwitch" + +// Setting controlling drivers can register to receive scheduled wake data +// Either in "CF seconds" type, or structured calendar data in a formatted +// IOPMCalendarStruct defined below. +#define kIOPMSettingAutoWakeSecondsKey "wake" +#define kIOPMSettingAutoWakeCalendarKey "WakeByCalendarDate" +#define kIOPMSettingAutoPowerSecondsKey "poweron" +#define kIOPMSettingAutoPowerCalendarKey "PowerByCalendarDate" + +// Debug seconds auto wake +// Used by sleep cycling debug tools +#define kIOPMSettingDebugWakeRelativeKey "WakeRelativeToSleep" +#define kIOPMSettingDebugPowerRelativeKey "PowerRelativeToShutdown" + +// Maintenance wake calendar. +#define kIOPMSettingMaintenanceWakeCalendarKey "MaintenanceWakeCalendarDate" + +struct IOPMCalendarStruct { + UInt32 year; + UInt8 month; + UInt8 day; + UInt8 hour; + UInt8 minute; + UInt8 second; +}; +typedef struct IOPMCalendarStruct IOPMCalendarStruct; + +// SetAggressiveness types +enum { + kPMGeneralAggressiveness = 0, + kPMMinutesToDim, + kPMMinutesToSpinDown, + kPMMinutesToSleep, + kPMEthernetWakeOnLANSettings, + kPMSetProcessorSpeed, + kPMPowerSource, + kPMMotionSensor, + kPMLastAggressivenessType +}; +#define kMaxType (kPMLastAggressivenessType-1) + +// SetAggressiveness values for the kPMPowerSource aggressiveness type +enum { + kIOPMInternalPower = 1, + kIOPMExternalPower +}; + +#define kIOREMSleepEnabledKey "REMSleepEnabled" + +// Strings for deciphering the dictionary returned from IOPMCopyBatteryInfo +#define kIOBatteryInfoKey "IOBatteryInfo" +#define kIOBatteryCurrentChargeKey "Current" +#define kIOBatteryCapacityKey "Capacity" +#define kIOBatteryFlagsKey "Flags" +#define kIOBatteryVoltageKey "Voltage" +#define kIOBatteryAmperageKey "Amperage" +#define kIOBatteryCycleCountKey "Cycle Count" + +enum { + kIOBatteryInstalled = (1 << 2), + kIOBatteryCharge = (1 << 1), + kIOBatteryChargerConnect = (1 << 0) +}; + + +// Private power management message indicating battery data has changed +// Indicates new data resides in the IORegistry +#define kIOPMMessageBatteryStatusHasChanged iokit_family_msg(sub_iokit_pmu, 0x100) + +// Apple private Legacy messages for re-routing AutoWake and AutoPower messages to the PMU +// through newer user space IOPMSchedulePowerEvent API +#define kIOPMUMessageLegacyAutoWake iokit_family_msg(sub_iokit_pmu, 0x200) +#define kIOPMUMessageLegacyAutoPower iokit_family_msg(sub_iokit_pmu, 0x210) + +// For use with IOPMPowerSource bFlags +#define IOPM_POWER_SOURCE_REV 2 +enum { + kIOPMACInstalled = kIOBatteryChargerConnect, + kIOPMBatteryCharging = kIOBatteryCharge, + kIOPMBatteryInstalled = kIOBatteryInstalled, + kIOPMUPSInstalled = (1<<3), + kIOPMBatteryAtWarn = (1<<4), + kIOPMBatteryDepleted = (1<<5), + kIOPMACnoChargeCapability = (1<<6), // AC adapter cannot charge battery + kIOPMRawLowBattery = (1<<7), // used only by Platform Expert + kIOPMForceLowSpeed = (1<<8), // set by Platfm Expert, chk'd by Pwr Plugin + kIOPMClosedClamshell = (1<<9), // set by PMU - reflects state of the clamshell + kIOPMClamshellStateOnWake = (1<<10) // used only by Platform Expert +}; + + +// ********************************************** +// Internal power management data structures +// ********************************************** + +#if KERNEL && __cplusplus +class IOService; + +enum { + kIOPowerEmergencyLevel = 1000 +}; + +enum { + kIOPMSubclassPolicy, + kIOPMSuperclassPolicy1 +}; + +struct stateChangeNote{ + IOPMPowerFlags stateFlags; + unsigned long stateNum; + void * powerRef; +}; +typedef struct stateChangeNote stateChangeNote; + +struct IOPowerStateChangeNotification { + void * powerRef; + unsigned long returnValue; + unsigned long stateNumber; + IOPMPowerFlags stateFlags; +}; +typedef struct IOPowerStateChangeNotification IOPowerStateChangeNotification; +typedef IOPowerStateChangeNotification sleepWakeNote; +#endif /* KERNEL && __cplusplus */ + +#endif /* ! _IOKIT_IOPM_H */ + Index: branches/azimutz/Cleancut/i386/include/IOKit/pwr_mgt/IOPowerConnection.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/pwr_mgt/IOPowerConnection.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/pwr_mgt/IOPowerConnection.h (revision 885) @@ -0,0 +1,159 @@ +/* + * 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_IOPOWERCONNECTION_H +#define _IOKIT_IOPOWERCONNECTION_H + +#include +#include + +class IOPowerConnection : public IOService +{ + OSDeclareDefaultStructors(IOPowerConnection) + +protected: + /*! @field parentKnowsState true: parent knows state of its domain + used by child */ + bool stateKnown; + /*! @field currentPowerFlags power flags which describe the current state of the power domain + used by child */ + IOPMPowerFlags currentPowerFlags; + /*! @field desiredDomainState state number which corresponds to the child's desire + used by parent */ + unsigned long desiredDomainState; + + /*! @field requestFlag set to true when desiredDomainState is set */ + bool requestFlag; + + /*! @field preventIdleSleepFlag true if child has this bit set in its desired state + used by parent */ + unsigned long preventIdleSleepFlag; + + /*! @field preventSystemSleepFlag true if child has this bit set in its desired state + used by parent */ + unsigned long preventSystemSleepFlag; + + /*! @field awaitingAck true if child has not yet acked our notification + used by parent */ + bool awaitingAck; + + /*! @field readyFlag true if the child has been added as a power child + used by parent */ + bool readyFlag; + +public: + /*! @function setParentKnowsState + @abstract Sets the stateKnown variable. + @discussion Called by the parent when the object is created and called by the child when it discovers that the parent now knows its state. */ + void setParentKnowsState (bool ); + + /*! @function setParentCurrentPowerFlags + @abstract Sets the currentPowerFlags variable. + @discussion Called by the parent when the object is created and called by the child when it discovers that the parent state is changing. */ + void setParentCurrentPowerFlags (IOPMPowerFlags ); + + /*! @function parentKnowsState + @abstract Returns the stateKnown variable. */ + bool parentKnowsState (void ); + + /*! @function parentCurrentPowerFlags + @abstract Returns the currentPowerFlags variable. */ + IOPMPowerFlags parentCurrentPowerFlags (void ); + + /*! @function setDesiredDomainState + @abstract Sets the desiredDomainState variable. + @discussion Called by the parent. */ + void setDesiredDomainState (unsigned long ); + + /*! @function getDesiredDomainState + @abstract Returns the desiredDomainState variable. + @discussion Called by the parent. */ + unsigned long getDesiredDomainState ( void ); + + /*! @function setChildHasRequestedPower + @abstract Set the flag that says that the child has called requestPowerDomainState. + @discussion Called by the parent. */ + void setChildHasRequestedPower ( void ); + + + /*! @function childHasRequestedPower + @abstract Return the flag that says whether the child has called requestPowerDomainState. + @discussion Called by the PCI Aux Power Supply Driver to see if a device driver + is power managed. */ + bool childHasRequestedPower ( void ); + + /*! @function setPreventIdleSleepFlag + @abstract Sets the preventIdleSleepFlag variable. + @discussion Called by the parent. */ + void setPreventIdleSleepFlag (unsigned long ); + + /*! @function getPreventIdleSleepFlag + @abstract Returns the preventIdleSleepFlag variable. + @discussion Called by the parent. */ + bool getPreventIdleSleepFlag ( void ); + + /*! @function setPreventSystemSleepFlag + @abstract Sets the preventSystemSleepFlag variable. + @discussion Called by the parent. */ + void setPreventSystemSleepFlag (unsigned long ); + + /*! @function getPreventSystemSleepFlag + @abstract Returns the preventSystemSleepFlag variable. + @discussion Called by the parent. */ + bool getPreventSystemSleepFlag ( void ); + + /*! @function setAwaitingAck + @abstract Sets the awaitingAck variable. + @discussion Called by the parent. */ + void setAwaitingAck ( bool ); + + /*! @function getAwaitingAck + @abstract Returns the awaitingAck variable. + @discussion Called by the parent. */ + bool getAwaitingAck ( void ); + + /*! @function setReadyFlag + @abstract Sets the readyFlag variable. + @discussion Called by the parent. */ + void setReadyFlag( bool flag ); + + /*! @function getReadyFlag + @abstract Returns the readyFlag variable. + @discussion Called by the parent. */ + bool getReadyFlag( void ) const; +}; + +#endif /* ! _IOKIT_IOPOWERCONNECTION_H */ + Index: branches/azimutz/Cleancut/i386/include/IOKit/pwr_mgt/IOPMDeprecated.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/pwr_mgt/IOPMDeprecated.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/pwr_mgt/IOPMDeprecated.h (revision 885) @@ -0,0 +1,177 @@ +/* + * Copyright (c) 1998-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 _IOPMDeprecated_h_ +#define _IOPMDeprecated_h_ + +#ifdef __ppc__ + +// Power events +enum { + kClamshellClosedEventMask = (1<<0), // User closed lid + kDockingBarEventMask = (1<<1), // OBSOLETE + kACPlugEventMask = (1<<2), // User plugged or unplugged adapter + kFrontPanelButtonEventMask = (1<<3), // User hit the front panel button + kBatteryStatusEventMask = (1<<4) // Battery status has changed +}; + +// PUBLIC power management features +// NOTE: this is a direct port from classic, some of these bits +// are obsolete but are included for completeness +enum { + kPMHasWakeupTimerMask = (1<<0), // 1=wake timer is supported + kPMHasSharedModemPortMask = (1<<1), // Not used + kPMHasProcessorCyclingMask = (1<<2), // 1=processor cycling supported + kPMMustProcessorCycleMask = (1<<3), // Not used + kPMHasReducedSpeedMask = (1<<4), // 1=supports reduced processor speed + kPMDynamicSpeedChangeMask = (1<<5), // 1=supports changing processor speed on the fly + kPMHasSCSIDiskModeMask = (1<<6), // 1=supports using machine as SCSI drive + kPMCanGetBatteryTimeMask = (1<<7), // 1=battery time can be calculated + kPMCanWakeupOnRingMask = (1<<8), // 1=machine can wake on modem ring + kPMHasDimmingSupportMask = (1<<9), // 1=has monitor dimming support + kPMHasStartupTimerMask = (1<<10), // 1=can program startup timer + kPMHasChargeNotificationMask = (1<<11), // 1=client can determine charger status/get notifications + kPMHasDimSuspendSupportMask = (1<<12), // 1=can dim diplay to DPMS ('off') state + kPMHasWakeOnNetActivityMask = (1<<13), // 1=supports waking upon receipt of net packet + kPMHasWakeOnLidMask = (1<<14), // 1=can wake upon lid/case opening + kPMCanPowerOffPCIBusMask = (1<<15), // 1=can remove power from PCI bus on sleep + kPMHasDeepSleepMask = (1<<16), // 1=supports deep (hibernation) sleep + kPMHasSleepMask = (1<<17), // 1=machine support low power sleep (ala powerbooks) + kPMSupportsServerModeAPIMask = (1<<18), // 1=supports reboot on AC resume for unexpected power loss + kPMHasUPSIntegrationMask = (1<<19) // 1=supports incorporating UPS devices into power source calcs +}; + +// PRIVATE power management features +// NOTE: this is a direct port from classic, some of these bits +// are obsolete but are included for completeness. +enum { + kPMHasExtdBattInfoMask = (1<<0), // Not used + kPMHasBatteryIDMask = (1<<1), // Not used + kPMCanSwitchPowerMask = (1<<2), // Not used + kPMHasCelsiusCyclingMask = (1<<3), // Not used + kPMHasBatteryPredictionMask = (1<<4), // Not used + kPMHasPowerLevelsMask = (1<<5), // Not used + kPMHasSleepCPUSpeedMask = (1<<6), // Not used + kPMHasBtnIntHandlersMask = (1<<7), // 1=supports individual button interrupt handlers + kPMHasSCSITermPowerMask = (1<<8), // 1=supports SCSI termination power switch + kPMHasADBButtonHandlersMask = (1<<9), // 1=supports button handlers via ADB + kPMHasICTControlMask = (1<<10), // 1=supports ICT control + kPMHasLegacyDesktopSleepMask = (1<<11), // 1=supports 'doze' style sleep + kPMHasDeepIdleMask = (1<<12), // 1=supports Idle2 in hardware + kPMOpenLidPreventsSleepMask = (1<<13), // 1=open case prevent machine from sleeping + kPMClosedLidCausesSleepMask = (1<<14), // 1=case closed (clamshell closed) causes sleep + kPMHasFanControlMask = (1<<15), // 1=machine has software-programmable fan/thermostat controls + kPMHasThermalControlMask = (1<<16), // 1=machine supports thermal monitoring + kPMHasVStepSpeedChangeMask = (1<<17), // 1=machine supports processor voltage/clock change + kPMEnvironEventsPolledMask = (1<<18) // 1=machine doesn't generate pmu env ints, we must poll instead +}; + +// DEFAULT public and private features for machines whose device tree +// does NOT contain this information (pre-Core99). + +// For Cuda-based Desktops + +#define kStdDesktopPMFeatures kPMHasWakeupTimerMask |\ + kPMHasProcessorCyclingMask |\ + kPMHasDimmingSupportMask |\ + kPMHasStartupTimerMask |\ + kPMSupportsServerModeAPIMask |\ + kPMHasUPSIntegrationMask + +#define kStdDesktopPrivPMFeatures kPMHasExtdBattInfoMask |\ + kPMHasICTControlMask |\ + kPMHasLegacyDesktopSleepMask + +#define kStdDesktopNumBatteries 0 + +// For Wallstreet (PowerBook G3 Series 1998) + +#define kWallstreetPMFeatures kPMHasWakeupTimerMask |\ + kPMHasProcessorCyclingMask |\ + kPMHasReducedSpeedMask |\ + kPMDynamicSpeedChangeMask |\ + kPMHasSCSIDiskModeMask |\ + kPMCanGetBatteryTimeMask |\ + kPMHasDimmingSupportMask |\ + kPMHasChargeNotificationMask |\ + kPMHasDimSuspendSupportMask |\ + kPMHasSleepMask + +#define kWallstreetPrivPMFeatures kPMHasExtdBattInfoMask |\ + kPMHasBatteryIDMask |\ + kPMCanSwitchPowerMask |\ + kPMHasADBButtonHandlersMask |\ + kPMHasSCSITermPowerMask |\ + kPMHasICTControlMask |\ + kPMClosedLidCausesSleepMask |\ + kPMEnvironEventsPolledMask + +#define kStdPowerBookPMFeatures kWallstreetPMFeatures +#define kStdPowerBookPrivPMFeatures kWallstreetPrivPMFeatures + +#define kStdPowerBookNumBatteries 2 + +// For 101 (PowerBook G3 Series 1999) + +#define k101PMFeatures kPMHasWakeupTimerMask |\ + kPMHasProcessorCyclingMask |\ + kPMHasReducedSpeedMask |\ + kPMDynamicSpeedChangeMask |\ + kPMHasSCSIDiskModeMask |\ + kPMCanGetBatteryTimeMask |\ + kPMHasDimmingSupportMask |\ + kPMHasChargeNotificationMask |\ + kPMHasDimSuspendSupportMask |\ + kPMHasSleepMask |\ + kPMHasUPSIntegrationMask + +#define k101PrivPMFeatures kPMHasExtdBattInfoMask |\ + kPMHasBatteryIDMask |\ + kPMCanSwitchPowerMask |\ + kPMHasADBButtonHandlersMask |\ + kPMHasSCSITermPowerMask |\ + kPMHasICTControlMask |\ + kPMClosedLidCausesSleepMask |\ + kPMEnvironEventsPolledMask + + +// These flags are deprecated. Use the version with the kIOPM prefix in IOPM.h +enum { + kACInstalled = (1<<0), + kBatteryCharging = (1<<1), + kBatteryInstalled = (1<<2), + kUPSInstalled = (1<<3), + kBatteryAtWarn = (1<<4), + kBatteryDepleted = (1<<5), + kACnoChargeCapability = (1<<6), // AC adapter cannot charge battery + kRawLowBattery = (1<<7), // used only by Platform Expert + kForceLowSpeed = (1<<8) // set by Platfm Expert, chk'd by Pwr Plugin}; +}; + +#endif /* __ppc32 */ +#endif /* _IOPMDeprecated_h_ */ Index: branches/azimutz/Cleancut/i386/include/IOKit/IOEventSource.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/IOEventSource.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/IOEventSource.h (revision 885) @@ -0,0 +1,244 @@ +/* + * 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 + 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 + +#include + +#include +#include +#include + + +__BEGIN_DECLS +#include +#include +__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. +

+ 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. +

+ 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. +

+ The IOEventSource makes no attempt to maintain the consitency of it's 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 handing off change request to its own thread and thus single threading access to its state. +

+ All subclasses of the IOEventSource are expected to implement the checkForWork() member function. + +

+ checkForWork() is the key method in this class. It is called by some work-loop when convienient and is expected to evaluate it's 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. +

+ 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; + +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 + +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 { }; + +/*! @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 will generally be an OSObject it doesn't have to +be as no member functions will be called directly in it. It can just be a +refcon for a client routine. + @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 = 0); + +/*! @function checkForWork + @abstract Pure Virtual member function used by IOWorkLoop for work +scheduling. + @discussion This function will be called to request a subclass to check +it's internal state 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() = 0; + +/*! @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; + +/*! @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 */ Index: branches/azimutz/Cleancut/i386/include/IOKit/IODMAController.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/IODMAController.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/IODMAController.h (revision 885) @@ -0,0 +1,67 @@ +/* + * 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 +#include +#include + +class IODMAEventSource; + +class IODMAController : public IOService +{ + OSDeclareAbstractStructors(IODMAController); + + friend class IODMAEventSource; + + private: + IOService *_provider; + 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); + virtual IOReturn queryDMACommand(UInt32 dmaIndex, IODMACommand **dmaCommand, IOByteCount *transferCount, bool waitForIdle = false) = 0; + virtual IOByteCount getFIFODepth(UInt32 dmaIndex) = 0; + + public: + static const OSSymbol *createControllerName(UInt32 phandle); + static IODMAController *getController(IOService *provider, UInt32 dmaIndex); + + virtual bool start(IOService *provider); +}; + + +#endif /* _IOKIT_IODMACONTROLLER_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/assert.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/assert.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/assert.h (revision 885) @@ -0,0 +1,54 @@ +/* + * 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 + +#ifdef __cplusplus +extern "C" { +#endif + +#if IOASSERT +#undef MACH_ASSERT +#define MACH_ASSERT 1 +#endif +#include + +#ifdef __cplusplus +} +#endif + + +#if( !defined( OSCompileAssert ) ) +# define OSCompileAssert( TEST ) \ + extern int OSCompileAssertFailed[ ( TEST ) ? 1 : -1 ] __unused; +#endif + +#endif /* _IO_ASSERT_H_ */ + Index: branches/azimutz/Cleancut/i386/include/IOKit/power/IOPwrController.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/power/IOPwrController.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/power/IOPwrController.h (revision 885) @@ -0,0 +1,41 @@ +/* + * 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@ + */ +/* + * 24 Nov 1998 suurballe Created. + */ + +#include + +class IOPwrController: public IOService +{ +OSDeclareAbstractStructors(IOPwrController) + +public: + +}; + Index: branches/azimutz/Cleancut/i386/include/IOKit/IOCommandGate.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/IOCommandGate.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/IOCommandGate.h (revision 885) @@ -0,0 +1,241 @@ +/* + * Copyright (c) 1998-2009 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@ + */ +/*[ + 1999-8-10 Godfrey van der Linden(gvdl) + Created. +]*/ +/*! @language embedded-c++ */ + +#ifndef _IOKIT_IOCOMMANDGATE_H +#define _IOKIT_IOCOMMANDGATE_H + +#include + +/*! + @class IOCommandGate : public IOEventSource + @abstract Single-threaded work-loop client request mechanism. + @discussion An IOCommandGate instance is an extremely light way mechanism +that executes an action on the driver's work-loop. 'On the work-loop' is +actually a lie but the work-loop single threaded semantic is maintained for this +event source. Using the work-loop gate rather than execution by the workloop. +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. +

+ 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. +

+ 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: +/*! + @function checkForWork + @abstract Not used, $link IOEventSource::checkForWork(). */ + virtual bool checkForWork(); + +/*! @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) */ + ExpansionData *reserved; + +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 IOCommandGate *commandGate(OSObject *owner, Action action = 0); + +/*! @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 = 0); + + // Superclass overrides + virtual void free(); + virtual void setWorkLoop(IOWorkLoop *inWorkLoop); + +/*! @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 = 0, void *arg1 = 0, + void *arg2 = 0, void *arg3 = 0); + +/*! @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 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 kIOReturnSuccess if successful. 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 = 0, void *arg1 = 0, + void *arg2 = 0, void *arg3 = 0); + +/*! @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 = 0, void *arg1 = 0, + void *arg2 = 0, void *arg3 = 0); + +/*! @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 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 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 = 0, void *arg1 = 0, + void *arg2 = 0, void *arg3 = 0); + +/*! @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. + @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, kIOReturnNotPermitted if the calling thread does not hold the command gate. */ + 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 onlyOneThread 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(); + +/*! @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(); + +/*! @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. + @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, kIOReturnNotPermitted if the calling thread does not hold the command gate. */ + virtual IOReturn commandSleep(void *event, + AbsoluteTime deadline, + UInt32 interruptible); + +private: +#if __LP64__ + OSMetaClassDeclareReservedUnused(IOCommandGate, 0); +#else + OSMetaClassDeclareReservedUsed(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 */ Index: branches/azimutz/Cleancut/i386/include/IOKit/graphics/IOAccelerator.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/graphics/IOAccelerator.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/graphics/IOAccelerator.h (revision 885) @@ -0,0 +1,42 @@ +/* + * 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 _IO_ACCELERATOR_H +#define _IO_ACCELERATOR_H + +#include +#include + +class IOAccelerator : public IOService +{ + OSDeclareDefaultStructors(IOAccelerator) + +public: + static IOReturn createAccelID(IOOptionBits options, IOAccelID * identifier); + static IOReturn retainAccelID(IOOptionBits options, IOAccelID identifier); + static IOReturn releaseAccelID(IOOptionBits options, IOAccelID identifier); + +}; + + +#endif /* _IO_ACCELERATOR_H */ + Index: branches/azimutz/Cleancut/i386/include/IOKit/graphics/IOFramebuffer.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/graphics/IOFramebuffer.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/graphics/IOFramebuffer.h (revision 885) @@ -0,0 +1,827 @@ +/* + * 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_IOFRAMEBUFFER_H +#define _IOKIT_IOFRAMEBUFFER_H + +#include +#include +#include +#include +#include + +class IOFramebuffer; +class IOBufferMemoryDescriptor; + +typedef void (*CursorBlitProc)( + IOFramebuffer * inst, + void * shmem, + volatile unsigned char *vramPtr, + unsigned int cursStart, + unsigned int vramRow, + unsigned int cursRow, + int width, + int height ); + +typedef void (*CursorRemoveProc)( + IOFramebuffer * inst, + void * shmem, + volatile unsigned char *vramPtr, + unsigned int vramRow, + int width, + int height ); + + +typedef void * IOFBCursorRef; + +struct IOFBCursorControlCallouts { + IOReturn (*setCursorImage) (void * self, void * ref, + IOHardwareCursorDescriptor * description, IOFBCursorRef cursorImage); + IOReturn (*setCursorState) (void * self, void * ref, + SInt32 x, SInt32 y, bool visible); + UInt32 reserved[30]; +}; +typedef struct IOFBCursorControlCallouts IOFBCursorControlCallouts; + +struct IOFBCursorControlAttribute { + void * self; + void * ref; + const IOFBCursorControlCallouts * callouts; + UInt32 reserved[29]; +}; +typedef struct IOFBCursorControlAttribute IOFBCursorControlAttribute; + +// clock & data values +enum { + kIODDCLow = 0, + kIODDCHigh = 1, + kIODDCTristate = 2 +}; +// ddcBlockType constants +enum { + // EDID block type. + kIODDCBlockTypeEDID = 0 +}; + +// ddcFlags constants +enum { + // Force a new read of the EDID. + kIODDCForceRead = 0x00000001 +}; + +enum { + kDisabledInterruptState = 0, + kEnabledInterruptState = 1 +}; + +typedef void (*IOFBInterruptProc)( OSObject * target, void * ref ); + + +typedef IOReturn (*IOFramebufferNotificationHandler) + (OSObject * self, void * ref, + IOFramebuffer * framebuffer, IOIndex event, + void * info); + +// IOFramebufferNotificationHandler events +enum { + kIOFBNotifyDisplayModeWillChange = 1, + kIOFBNotifyDisplayModeDidChange = 2, + + kIOFBNotifyWillSleep = 3, + kIOFBNotifyDidWake = 4, + + kIOFBNotifyDidPowerOff = 5, + kIOFBNotifyWillPowerOn = 6, + + kIOFBNotifyDidSleep = kIOFBNotifyDidPowerOff, + kIOFBNotifyWillWake = kIOFBNotifyWillPowerOn, + + kIOFBNotifyWillPowerOff = 7, + kIOFBNotifyDidPowerOn = 8, + + kIOFBNotifyWillChangeSpeed = 9, + kIOFBNotifyDidChangeSpeed = 10, + + kIOFBNotifyClamshellChange = 20, + + kIOFBNotifyCaptureChange = 30, + + kIOFBNotifyOnlineChange = 40, + + kIOFBNotifyDisplayDimsChange = 50, + + kIOFBNotifyProbed = 60, +}; + +enum { + kFBDisplayUsablePowerState = 0x80000000, + kFBDisplayPowerStateMask = 0x0000ffff +}; + +#define kIOFBDependentIDKey "IOFBDependentID" +#define kIOFBDependentIndexKey "IOFBDependentIndex" + +struct StdFBShmem_t; +class IOFramebufferUserClient; + +/*! @class IOFramebuffer : public IOGraphicsDevice + @abstract The base class for graphics devices to be made available as part of the desktop. + @discussion The IOFramebuffer base class defines APIs used to publish a linear framebuffer device. Device driver writers should subclass this class to provide a X native driver. Mac OS X will also utilize 'ndrv' drivers via a subclass of IOFramebuffer IONDRVFramebuffer that does not require device driver writers to provide a X native driver. + + There are no in kernel clients of IOFramebuffer aside from rudimentary console and panic UI supported by the IOFramebuffer class. The IOFramebuffer class provides the IOUserClient implementation to allow the CoreGraphics server to provide the user accessible interface to all displays on a Mac OS X system, and this is further layered underneath application frameworks. Device driver writers should not need any knowledge of this part of the interfaces. Similarly the instance variables of IOFramebuffer are mostly used for cursor rendering which is handled by the IOFramebuffer class, and should be avoided by subclass implementors. Only IOFramebuffer methods with header documentation in this header are designed for subclasses to implement. + + IOFramebuffer provides simple dumb framebuffer operation - accceleration for 2D, 3D and video may be provided by a separate implementation of the IOAccelerator class. +*/ + +class IOFramebuffer : public IOGraphicsDevice +{ + friend class IOFramebufferUserClient; + friend class IOFramebufferSharedUserClient; + friend class IODisplay; + + OSDeclareDefaultStructors(IOFramebuffer) + +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: + +protected: + StdFBShmem_t * priv; + int shmemClientVersion; + IOBufferMemoryDescriptor * sharedCursor; + + union { + struct { + /* Mapping tables used in cursor drawing to 5-5-5 displays. */ + unsigned char * _bm34To35SampleTable; + unsigned char * _bm35To34SampleTable; + /* Mapping tables used in cursor drawing to 8-bit RGB displays. */ + unsigned int * _bm256To38SampleTable; + unsigned char * _bm38To256SampleTable; + } t; + UInt8 * tables[ 4 ]; + } colorConvert; + + /* cursor blitting vars */ + CursorBlitProc cursorBlitProc; + CursorRemoveProc cursorRemoveProc; + + IOGSize maxCursorSize; + void * _IOFramebuffer_reservedE[7]; + const char * thisName; + volatile unsigned char * cursorSave; + unsigned int white; + + IOGPoint nextCursorLoc; + int nextCursorFrame; + SInt32 connectChange; + semaphore_t vblSemaphore; + + /* memory ranges */ + volatile unsigned char * frameBuffer; + unsigned int totalWidth; + unsigned int rowBytes; + unsigned int bytesPerPixel; + + IOMemoryMap * vramMap; + IOByteCount vramMapOffset; + OSArray * userAccessRanges; + unsigned int suspended:1; + unsigned int captured:1; + unsigned int sleepConnectCheck:1; + unsigned int messaged:1; + unsigned int _IOFramebuffer_reservedC:28; + IOFramebuffer * nextDependent; + OSSet * fbNotifications; + + class IOFramebufferUserClient * serverConnect; + class IOFramebufferSharedUserClient * sharedConnect; + + unsigned int opened:1; + unsigned int dead:1; + unsigned int configPending:1; + unsigned int serverNotified:1; + unsigned int serverState:1; + unsigned int serverPendingAck:1; + unsigned int isUsable:1; + unsigned int mirrored:1; + unsigned int pendingPowerState:4; + unsigned int pendingPowerChange:1; + unsigned int pagingState:1; + unsigned int mirrorPrimary:1; + unsigned int mirrorSWCursor:1; + + bool clutValid; + bool currentMono; + bool needCursorService; + bool haveVBLService; + bool haveHWCursor; + bool hwCursorLoaded; + + void * serverMsg; + IOInterruptEventSource * deferredEvents; + + /* Reserved for future expansion. */ + int _IOFramebuffer_reserved[5]; + +private: + struct IOFramebufferPrivate * __private; + +public: +/*! @function doI2CRequest + @abstract Carry out an I2C request. + @discussion IOFramebuffer subclasses may optionally implement this method to perform I2C bus requests on one of the buses they support. Alternatively they may implement the setDDCClock(), setDDCData(), readDDCClock(), readDDCData() methods and respond from getAttributeForConnection() to the kConnectionSupportsLLDDCSense attribute with success, in which case IOFramebuffer::doI2CRequest() will carry out a software implementation of I2C using the low level routines and conforming to the timing constraints passed in the timing parameter. Subclasses may pass timing parameters tuned for the specific bus, otherwise VESA DDC defaults will apply. + @timing event Subclasses may pass timing parameters tuned for the specific bus, otherwise if NULL, VESA DDC defaults will apply. + @param request An IOI2CRequest structure. The request should be carried out synchronously if the completion routine is NULL, otherwise it may optionally be carried out asynchronously. The completion routine should be called if supplied. + @result an IOReturn code. If kIOReturnSuccces, the result of the transaction is returned in the requests result field. +*/ + virtual IOReturn doI2CRequest( UInt32 bus, struct IOI2CBusTiming * timing, struct IOI2CRequest * request ); + +private: + OSMetaClassDeclareReservedUsed(IOFramebuffer, 0); + + OSMetaClassDeclareReservedUnused(IOFramebuffer, 1); + OSMetaClassDeclareReservedUnused(IOFramebuffer, 2); + OSMetaClassDeclareReservedUnused(IOFramebuffer, 3); + OSMetaClassDeclareReservedUnused(IOFramebuffer, 4); + OSMetaClassDeclareReservedUnused(IOFramebuffer, 5); + OSMetaClassDeclareReservedUnused(IOFramebuffer, 6); + OSMetaClassDeclareReservedUnused(IOFramebuffer, 7); + OSMetaClassDeclareReservedUnused(IOFramebuffer, 8); + OSMetaClassDeclareReservedUnused(IOFramebuffer, 9); + OSMetaClassDeclareReservedUnused(IOFramebuffer, 10); + OSMetaClassDeclareReservedUnused(IOFramebuffer, 11); + OSMetaClassDeclareReservedUnused(IOFramebuffer, 12); + OSMetaClassDeclareReservedUnused(IOFramebuffer, 13); + OSMetaClassDeclareReservedUnused(IOFramebuffer, 14); + OSMetaClassDeclareReservedUnused(IOFramebuffer, 15); + OSMetaClassDeclareReservedUnused(IOFramebuffer, 16); + OSMetaClassDeclareReservedUnused(IOFramebuffer, 17); + OSMetaClassDeclareReservedUnused(IOFramebuffer, 18); + OSMetaClassDeclareReservedUnused(IOFramebuffer, 19); + OSMetaClassDeclareReservedUnused(IOFramebuffer, 20); + OSMetaClassDeclareReservedUnused(IOFramebuffer, 21); + OSMetaClassDeclareReservedUnused(IOFramebuffer, 22); + OSMetaClassDeclareReservedUnused(IOFramebuffer, 23); + OSMetaClassDeclareReservedUnused(IOFramebuffer, 24); + OSMetaClassDeclareReservedUnused(IOFramebuffer, 25); + OSMetaClassDeclareReservedUnused(IOFramebuffer, 26); + OSMetaClassDeclareReservedUnused(IOFramebuffer, 27); + OSMetaClassDeclareReservedUnused(IOFramebuffer, 28); + OSMetaClassDeclareReservedUnused(IOFramebuffer, 29); + OSMetaClassDeclareReservedUnused(IOFramebuffer, 30); + OSMetaClassDeclareReservedUnused(IOFramebuffer, 31); + + +public: + static void initialize(); + + virtual bool requestTerminate( IOService * provider, IOOptionBits options ); + virtual IOService * probe( IOService * provider, SInt32 * score ); + virtual bool start( IOService * provider ); + virtual void stop( IOService * provider ); + virtual void free(); + virtual IOWorkLoop * getWorkLoop() const; + + IOWorkLoop * getGraphicsSystemWorkLoop() const; + IOWorkLoop * getControllerWorkLoop() const; + + virtual IOReturn requestProbe( IOOptionBits options ); + + virtual IOReturn powerStateWillChangeTo ( IOPMPowerFlags, unsigned long, IOService* ); + virtual IOReturn powerStateDidChangeTo ( IOPMPowerFlags, unsigned long, IOService* ); + virtual IOReturn setPowerState( unsigned long powerStateOrdinal, IOService * device); + virtual IOReturn setAggressiveness( unsigned long type, unsigned long newLevel ); + virtual IOReturn getAggressiveness( unsigned long type, unsigned long * currentLevel ); + virtual IOReturn newUserClient( task_t owningTask, + void * security_id, + UInt32 type, + IOUserClient ** handler ); + virtual IOReturn callPlatformFunction( const OSSymbol * functionName, + bool waitForFunction, + void *p1, void *p2, + void *p3, void *p4 ); + + virtual void hideCursor( void ); + virtual void showCursor( IOGPoint * cursorLoc, int frame ); + virtual void moveCursor( IOGPoint * cursorLoc, int frame ); + // virtual + void resetCursor( void ); + + virtual void getVBLTime( AbsoluteTime * time, AbsoluteTime * delta ); + + virtual void getBoundingRect ( IOGBounds ** bounds ); + + virtual IOReturn open( void ); + + virtual void close( void ); + + virtual bool isConsoleDevice( void ); + + virtual IOReturn setupForCurrentConfig( void ); + + virtual bool serializeInfo( OSSerialize * s ); + virtual bool setNumber( OSDictionary * dict, const char * key, + UInt32 number ); + + IONotifier * addFramebufferNotification( + IOFramebufferNotificationHandler handler, + OSObject * self, void * ref); + +/*! @function getApertureRange + @abstract Return reference to IODeviceMemory object representing memory range of framebuffer. + @discussion IOFramebuffer subclasses must implement this method to describe the memory used by the framebuffer in the current mode. The OS will map this memory range into user space for client access - the range should only include vram memory not hardware registers. + @param aperture The system will only access the aperture kIOFBSystemAperture. + @result an IODeviceMemory instance. A reference will be consumed by the caller for each call of this method - the implementatation should create a new instance of IODeviceMemory for each call, or return one instance with a retain for each call. +*/ + + virtual IODeviceMemory * getApertureRange( IOPixelAperture aperture ) = 0; + +/*! @function getVRAMRange + @abstract Return reference to IODeviceMemory object representing memory range of all the cards vram. + @discussion IOFramebuffer subclasses should implement this method to describe all the vram memory available on the card. The OS will map this memory range into user space for client access - the range should only include vram memory not hardware registers. + @result an IODeviceMemory instance. A reference will be consumed by the caller for each call of this method - the implementatation should create a new instance of IODeviceMemory for each call, or return one instance with a retain for each call. +*/ + + virtual IODeviceMemory * getVRAMRange( void ); + +protected: + +/*! @function handleEvent + @abstract Notify IOFramebuffer superclass code of events. + @discussion IOFramebuffer subclasses should call this IOFramebuffer method on certain power state changes. + @param event The event that has occurred:
+ kIOFBNotifyWillPowerOff call before entering a state other than the maximum.
+ kIOFBNotifyDidPowerOn call after entering the maximum power state.
+ kIOFBNotifyWillPowerOff call before entering a state other than the maximum.
+ kIOFBNotifyDidPowerOn call after entering a state other than the maximum.
+ @param info None of the above events require additional info, pass zero. + @result an IOReturn code, safely ignored. +*/ + + IOReturn handleEvent( IOIndex event, void * info = 0 ); + + + IOReturn deliverFramebufferNotification( + IOIndex event, void * info = 0 ); + +#ifdef IOFRAMEBUFFER_PRIVATE +#include +#endif + +public: +/*! @function enableController + @abstract Perform first time setup of the framebuffer. + @discussion IOFramebuffer subclasses should perform their initialization of the hardware here. The IOService start() method is not called at a time appropriate for this initialization. + @result an IOReturn code. A return other than kIOReturnSuccess will prevent the system from using the device. +*/ + + virtual IOReturn enableController( void ); + +/*! @function getPixelFormats + @abstract List the pixel formats the framebuffer supports. + @discussion IOFramebuffer subclasses must implement this method to return an array of strings representing the possible pixel formats available in the framebuffer. + @result A const char * pointer. The string consists of a concatenation of each pixel format string separated by the NULL character. The commonly supported pixel formats for Mac OS X are defined as IO8BitIndexedPixels, IO16BitDirectPixels, IO32BitDirectPixels. +*/ + + virtual const char * getPixelFormats( void ) = 0; + +/*! @function getDisplayModeCount + @abstract Return the number of display modes the framebuffer supports. + @discussion IOFramebuffer subclasses must implement this method to return a count of the display modes available. This count should change unless a connection change is posted for the device indicated the framebuffer and/or display configuration has changed. + @result A count of the display modes available. +*/ + + virtual IOItemCount getDisplayModeCount( void ) = 0; + +/*! @function getDisplayModes + @abstract Return the number of display modes the framebuffer supports. + @discussion IOFramebuffer subclasses must implement this method to return an array of display mode IDs available for the framebuffer. The IDs are defined by the driver in the range 0x00000001 - 0x7fffffff, and should be constant for a given display mode. + @param allDisplayModes A caller allocated buffer with the size given by the result of getDisplayModeCount(). + @result an IOReturn code. A return other than kIOReturnSuccess will prevent the system from using the device. +*/ + + virtual IOReturn getDisplayModes( IODisplayModeID * allDisplayModes ) = 0; + +/*! @function getInformationForDisplayMode + @abstract Return information about a given display mode. + @discussion IOFramebuffer subclasses must implement this method to return information in the IODisplayModeInformation structure for the display mode with the passed ID. + @param displayMode A display mode ID previously returned by getDisplayModes(). + @param info Pointer to a structure of type IODisplayModeInformation to be filled out by the driver. IODisplayModeInformation is documented in IOGraphicsTypes.h. + @result an IOReturn code. A return other than kIOReturnSuccess will prevent the system from using the device. +*/ + + virtual IOReturn getInformationForDisplayMode( IODisplayModeID displayMode, + IODisplayModeInformation * info ) = 0; + +/*! @function getPixelFormatsForDisplayMode + @abstract Obsolete. + @discussion IOFramebuffer subclasses must implement this method to return zero. + @param displayMode Ignored. + @param depth Ignored. + @result Return zero. +*/ + + virtual UInt64 getPixelFormatsForDisplayMode( IODisplayModeID displayMode, + IOIndex depth ) = 0; + +/*! @function getPixelInformation + @abstract Return information about the framebuffer format for a given display mode and depth. + @discussion IOFramebuffer subclasses must implement this method to return information in the IOPixelInformation structure for the display mode with the passed ID, depth index and aperture. The aperture utilized by the system is always kIOFBSystemAperture. Drivers may define alternative apertures, being a view of the framebuffer in a different pixel format from the default. + @param displayMode A display mode ID previously returned by getDisplayModes(). + @param depth An index from zero to the value of the maxDepthIndex field from the IODisplayModeInformation structure (inclusive). + @param info Pointer to a structure of type IOPixelInformation to be filled out by the driver. IOPixelInformation is documented in IOGraphicsTypes.h. + @result an IOReturn code. A return other than kIOReturnSuccess will prevent the system from using the device. +*/ + + virtual IOReturn getPixelInformation( + IODisplayModeID displayMode, IOIndex depth, + IOPixelAperture aperture, IOPixelInformation * pixelInfo ) = 0; + +/*! @function getCurrentDisplayMode + @abstract Return the framebuffers current display mode and depth. + @discussion IOFramebuffer subclasses must implement this method to return the current mode and depth. + @param displayMode A display mode ID representing the current mode. + @param depth An index indicating the depth configuration of the framebuffer. The index should range from zero to the value of the maxDepthIndex field from the IODisplayModeInformation structure for the display mode. + @result an IOReturn code. A return other than kIOReturnSuccess will prevent the system from using the device. +*/ + + virtual IOReturn getCurrentDisplayMode( IODisplayModeID * displayMode, + IOIndex * depth ) = 0; + +/*! @function setCurrentDisplayMode + @abstract Set the framebuffers current display mode and depth. + @discussion IOFramebuffer subclasses should implement this method to set the current mode and depth. Other than at enableController() time, this is the only method that should change the framebuffer format and is synchronized with clients and attached accelerators to make sure access to the device is disallowed during the change. + @param displayMode A display mode ID representing the new mode. + @param depth An index indicating the new depth configuration of the framebuffer. The index should range from zero to the value of the maxDepthIndex field from the IODisplayModeInformation structure for the display mode. + @result an IOReturn code. A return other than kIOReturnSuccess will prevent the system from using the device. +*/ + + virtual IOReturn setDisplayMode( IODisplayModeID displayMode, + IOIndex depth ); + +/*! @function setApertureEnable + @abstract Enable an aperture on the framebuffer (usually unimplemented, no OS usage). + @discussion IOFramebuffer subclasses may implement this method to set enable a non standard aperture. The system does not call this method. + @param aperture A device specific aperture index. + @param enable Device specific mask of options. + @result an IOReturn code. +*/ + + virtual IOReturn setApertureEnable( IOPixelAperture aperture, + IOOptionBits enable ); + +/*! @function setStartupDisplayMode + @abstract Set the framebuffers display mode and depth to be used during boot and at startup. + @discussion IOFramebuffer subclasses should implement this method to set the mode and depth to be used during boot and at startup, to reduce needed mode changes during boot when the display connection type is the same. If possible this mode should also be used by the OpenFirmware driver for the card. + @param displayMode A display mode ID representing the new startup mode. + @param depth An index indicating the new startup depth configuration of the framebuffer. The index should range from zero to the value of the maxDepthIndex field from the IODisplayModeInformation structure for the display mode. + @result an IOReturn code. +*/ + + virtual IOReturn setStartupDisplayMode( IODisplayModeID displayMode, + IOIndex depth ); + +/*! @function getCurrentDisplayMode + @abstract Return the framebuffers display mode and depth to be used during boot and at startup. + @discussion IOFramebuffer subclasses should implement this method to return the current mode and depth. + @param displayMode A display mode ID representing the mode used during startup. + @param depth An index indicating the depth configuration of the framebuffer used during startup. The index should range from zero to the value of the maxDepthIndex field from the IODisplayModeInformation structure for the display mode. + @result an IOReturn code. +*/ + + virtual IOReturn getStartupDisplayMode( IODisplayModeID * displayMode, + IOIndex * depth ); + +/*! @function setCLUTWithEntries + @abstract Set the color lookup table to be used by the framebuffer in indexed modes. + @discussion IOFramebuffer subclasses may implement this method to allow a palette to be set for indexed display modes. It will not be called on framebuffers in direct display modes. + @param colors A pointer to an array of numEntries RGB color entries. + @param index The index of the first entry to set. + @param numEntries The number of entries in the table. + @param options Options controlling the operation.
+ kSetCLUTByValue is set if the index field of each entry should be used to set the table sparsely, otherwise consecutive entries from the index parameter should be set.
+ kSetCLUTImmediately is set if the CLUT set should not be synchronized with the vertical blank, otherwise it should.
+ kSetCLUTWithLuminance is set if the CLUT should be set to a gray value equivalent in luminance to the passed color entry.
+ @result an IOReturn code. +*/ + + virtual IOReturn setCLUTWithEntries( IOColorEntry * colors, UInt32 index, + UInt32 numEntries, IOOptionBits options ); + +/*! @function setGammaTable + @abstract Set the gamma table to be used by the framebuffer. + @discussion IOFramebuffer subclasses should implement this method to allow a gamma table to be set. + @param channelCount Defines the number of channels in the supplied data. OS X will pass three for separate R, G, B data, or one if the same data should apply to all channels. + @param dataCount The number of data entries per channel. + @param dataWidth The number of bits in each entry. 8 for Mac OS X 10.1 and earlier, 16 for later releases. + @param data The packed array of correction data. Data is passed for the R (or single) channel followed by the G & B channels. Each entry is one or two bytes (if dataWidth > 8). + @result an IOReturn code. +*/ + + virtual IOReturn setGammaTable( UInt32 channelCount, UInt32 dataCount, + UInt32 dataWidth, void * data ); + +/*! @function setAttribute + @abstract Generic method to set some attribute of the framebuffer device. + @discussion IOFramebuffer subclasses may implement this method to allow arbitrary attribute/value pairs to be set. + @param attribute Defines the attribute to be set. Some defined attributes are:
+ kIOPowerAttribute The IOFramebuffer class implements most power management (IOService) methods. It calls the subclass to carry out the power management state change with this attribute. When carrying out power state changes, the subclass should call IOFramebuffer::handleEvent for certain changes - set that method for more information. + @param value The new value for the attribute. + @result an IOReturn code. +*/ + + virtual IOReturn setAttribute( IOSelect attribute, uintptr_t value ); + +/*! @function getAttribute + @abstract Generic method to retrieve some attribute of the framebuffer device. + @discussion IOFramebuffer subclasses may implement this method to allow arbitrary attribute/value pairs to be returned. + @param attribute Defines the attribute to be set. Some defined attributes are:
+ kIOHardwareCursorAttribute If the device supports a hardware cursor and implements the setCursorImage() and setCursorState() calls it should return true for this attribute. + @param value Returns the value for the attribute. + @result an IOReturn code. +*/ + + virtual IOReturn getAttribute( IOSelect attribute, uintptr_t * value ); + +/*! @function getTimingInfoForDisplayMode + @abstract Returns a timing description for a display mode. + @discussion IOFramebuffer subclasses should implement this method to return timing information for a display mode. This allows the OS to enable display modes based on its knowledge of the connected display type. Two types of timing information are defined, by Apple defined constant, or by a detailed description of the timing parameters of the mode. + @param displayMode A display mode ID representing the mode to examine. + @param info The driver returns the information for the display mode in this structure.
+ If the mode has an Apple defined constant, such as timingVESA_1024x768_75hz, it should be returned in the appleTimingID field. Otherwise the field should be set to timingInvalid.
+ If the driver is able to supply detailed timing information, it should return it in the detailedInfo.v2 field of the structure, otherwise the driver should clear the kIODetailedTimingValid flag from the flags field.
+ The IODetailedTimingInformationV2 structure is documented in IOGraphicsTypes.h + @result an IOReturn code. A return other than kIOReturnSuccess will prevent the system from using the device. +*/ + + virtual IOReturn getTimingInfoForDisplayMode( + IODisplayModeID displayMode, IOTimingInformation * info ); + +/*! @function validateDetailedTiming + @abstract Reports whether a detailed timing is able to be programmed with the device. + @discussion IOFramebuffer subclasses may implement programmable mode functionality where the OS is able to install modes described by a detailed timing into the driver. + @param description A pointer to a IODetailedTimingInformationV2 structure. The driver should examine this description and change any fields that it cannot implement to reflect its closest possible implementation. + @param descripSize sizeof(IODetailedTimingInformationV2) + @result an IOReturn code. A return other than kIOReturnSuccess will prevent the system from installing the programmable mode. +*/ + + virtual IOReturn validateDetailedTiming( + void * description, IOByteCount descripSize ); + +/*! @function setDetailedTimings + @abstract Installs an array of OS programmed detailed timings to be made available by the driver. + @discussion IOFramebuffer subclasses may implement programmable mode functionality where the OS is able to install modes described by a detailed timing into the driver. The driver needs to add these modes to its internal mode list if it provides this functionality. + @param array An OSArray of OSData objects. Each OSData contains one IODetailedTimingInformationV2 structure. All the data described by the array should be copied or retained by this call until the next invocation of this method. + @result an IOReturn code. A return other than kIOReturnSuccess will prevent the system from installing the programmable modes. +*/ + + virtual IOReturn setDetailedTimings( OSArray * array ); + +/*! @function getConnectionCount + @abstract Reports the number of display connections the device supports, driven from one framebuffer. + @discussion IOFramebuffer subclasses may implement functionality where a single framebuffer drives multiple displays. This is not recommended or fully supported and instead multihead cards should implement multiple instances of IOFramebuffer objects to provide full functionality. + @result A count of the number of display connections reported by the framebuffer. Current versions of OS X only support one connection completely. +*/ + + virtual IOItemCount getConnectionCount( void ); + + +/*! @function setAttributeForConnection + @abstract Generic method to set some attribute of the framebuffer device, specific to one display connection. + @discussion IOFramebuffer subclasses may implement this method to allow arbitrary attribute/value pairs to be set, specific to one display connection. + @param attribute Defines the attribute to be set. Some defined attributes are:
+ kIOCapturedAttribute If the device supports hotplugging displays, it should disable the generation of hot plug interrupts when the attribute kIOCapturedAttribute is set to true. + @param value The new value for the attribute. + @result an IOReturn code. +*/ + + virtual IOReturn setAttributeForConnection( IOIndex connectIndex, + IOSelect attribute, uintptr_t value ); + +/*! @function getAttributeForConnection + @abstract Generic method to retrieve some attribute of the framebuffer device, specific to one display connection. + @discussion IOFramebuffer subclasses may implement this method to allow arbitrary attribute/value pairs to be returned, specific to one display connection. + @param attribute Defines the attribute to be returned. Some defined attributes are:
+ kConnectionSupportsHLDDCSense If the framebuffer supports the DDC methods hasDDCConnect() and getDDCBlock() it should return success (and no value) for this attribute.
+ kConnectionSupportsLLDDCSense If the framebuffer wishes to make use of IOFramebuffer::doI2CRequest software implementation of I2C it should implement the I2C methods setDDCClock(), setDDCData(), readDDCClock(), readDDCData(), and it should return success (and no value) for this attribute.
+ @param value Returns the value for the attribute. + @result an IOReturn code. +*/ + + virtual IOReturn getAttributeForConnection( IOIndex connectIndex, + IOSelect attribute, uintptr_t * value ); + +/*! @function convertCursorImage + @abstract Utility method of IOFramebuffer to convert cursor image to a hardware cursor format. + @discussion IOFramebuffer subclasses may implement hardware cursor functionality, if so they should pass the cursor image given by the setCursorImage() method, with a description of their hardware cursor format, to this helper function to this routine to convert the image to one suitable for the hardware. + @param cursorImage Opaque cursor parameter from the setCursorImage() call. + @param description Describes the cursor format supported by the driver. + @param cursor Structure describing the drivers allocated buffer to receive the converted image. + @result a bool indicating the conversion was successful. +*/ + + virtual bool convertCursorImage( void * cursorImage, + IOHardwareCursorDescriptor * description, + IOHardwareCursorInfo * cursor ); + +/*! @function setCursorImage + @abstract Set a new image for the hardware cursor. + @discussion IOFramebuffer subclasses may implement hardware cursor functionality, if so they should implement this method to change the hardware cursor image. The image should be passed to the convertCursorImage() method with each type of cursor format the hardware supports until success, if all fail the hardware cursor should be hidden and kIOReturnUnsupported returned. + @param cursorImage Opaque cursor description. This should be passed to the convertCursorImage() method to convert to a format specific to the hardware. + @result An IOReturn code. +*/ + + virtual IOReturn setCursorImage( void * cursorImage ); + +/*! @function setCursorState + @abstract Set a new position and visibility for the hardware cursor. + @discussion IOFramebuffer subclasses may implement hardware cursor functionality, if so they should implement this method to change the position and visibility of the cursor. + @param x Left coordinate of the cursor image. A signed value, will be negative if the cursor's hot spot and position place it partly offscreen. + @param y Top coordinate of the cursor image. A signed value, will be negative if the cursor's hot spot and position place it partly offscreen. + @param visible Visible state of the cursor. + @result An IOReturn code. +*/ + + virtual IOReturn setCursorState( SInt32 x, SInt32 y, bool visible ); + +/*! @function flushCursor + @abstract Perform any needed cache flushing after software cursor rendering. + @discussion IOFramebuffer implements software cursor functionality when a hardware cursor is unavailable. Some hardware may need to flush a cache after the processor has finished lifting and dropping the software cursor. +*/ + + virtual void flushCursor( void ); + +/*! @function getAppleSense + @abstract Return display sense information for legacy Apple sensing. + @discussion Hardware that supports simple display sensing, or the classic 3 pin Apple sensing described in Designing Cards and Drivers, should implement this method to return sense information. + @param connectIndex Index of the display connection, from zero to the value of getConnectionCount(). + @param senseType Return zero to indicate legacy Apple sensing. + @param primary Return the value of the primary Apple sense code. + @param extended Return the value of the secondary Apple sense code. + @param displayType Return an Apple defined constant for the type of display sensed. For example, kVGAConnect, kNTSCConnect, kPALConnect etc. + @result An IOReturn code. +*/ + + virtual IOReturn getAppleSense( IOIndex connectIndex, + UInt32 * senseType, + UInt32 * primary, + UInt32 * extended, + UInt32 * displayType ); + +/*! @function connectFlags + @abstract Return display sense information for legacy Apple sensing. + @discussion Hardware that supports simple display sensing, or the classic 3 pin Apple sensing described in Designing Cards and Drivers, should implement this method to return mode flags relative to the sensed display. If this method is unimplemented, all modes have are given the flags kDisplayModeValidFlag | kDisplayModeSafeFlag. + @param connectIndex Index of the display connection, from zero to the value of getConnectionCount(). + @param displayMode A display mode ID. + @param flags Return the flags value for the given mode with the connected display. Flags are:
+ kDisplayModeValidFlag - mode is considered valid for the connected display by the driver. + kDisplayModeSafeFlag - mode is considered safe (not requiring mode change confirmation) for the connected display by the driver. + kDisplayModeDefaultFlag - mode is considered default for the connected display by the driver. + @result An IOReturn code. +*/ + + virtual IOReturn connectFlags( IOIndex connectIndex, + IODisplayModeID displayMode, IOOptionBits * flags ); + + //// IOLowLevelDDCSense + +/*! @function setDDCClock + @abstract Sets the state of the I2C clock line on a bus. + @discussion Framebuffers making use of the IOFramebuffer::doI2CRequest() software implementation of I2C should implement this method to set the state of the I2C clock line on the given bus. Otherwise may be unimplemented. + @param bus Index of the bus. + @param value One of kIODDCLow, kIODDCHigh, kIODDCTristate. +*/ + + virtual void setDDCClock( IOIndex bus, UInt32 value ); + +/*! @function setDDCData + @abstract Sets the state of the I2C data line on a bus. + @discussion Framebuffers making use of the IOFramebuffer::doI2CRequest() software implementation of I2C should implement this method to set the state of the I2C data line on the given bus. Otherwise may be unimplemented. + @param bus Index of the bus. + @param value One of kIODDCLow, kIODDCHigh, kIODDCTristate. +*/ + virtual void setDDCData( IOIndex bus, UInt32 value ); + +/*! @function readDDCClock + @abstract Reads the input state of the I2C clock line on a bus. + @discussion Framebuffers making use of the IOFramebuffer::doI2CRequest() software implementation of I2C should implement this method to return the input state of the I2C clock line on the given bus. Otherwise may be unimplemented. + @param bus Index of the bus. + @result A boolean reflecting the current state of the clock line on the given bus. +*/ + virtual bool readDDCClock( IOIndex bus ); + +/*! @function readDDCData + @abstract Reads the input state of the I2C data line on a bus. + @discussion Framebuffers making use of the IOFramebuffer::doI2CRequest() software implementation of I2C should implement this method to return the input state of the I2C data line on the given bus. Otherwise may be unimplemented. + @param bus Index of the bus. + @result A boolean reflecting the current state of the data line on the given bus. +*/ + virtual bool readDDCData( IOIndex bus ); + + virtual IOReturn enableDDCRaster( bool enable ); + +/*! @function hasDDCConnect + @abstract Return display DDC connect state. + @discussion Hardware that supports DDC/EDID display sensing should implement this method to return true if a DDC display is detected. They should also return success for the connection attribute kConnectionSupportsHLDDCSense (from getAttributeForConnection()). + @param connectIndex Index of the display connection, from zero to the value of getConnectionCount(). + @result True if a DDC display is detected. +*/ + + virtual bool hasDDCConnect( IOIndex connectIndex ); + +/*! @function getDDCBlock + @abstract Return display EDID data. + @discussion Hardware that supports DDC/EDID display sensing should implement this method to return EDID data in 128 byte blocks. + @param connectIndex Index of the display connection, from zero to the value of getConnectionCount(). + @param blockNumber Block number, ranging from one to the number of blocks return by the display. + @param blockType kIODDCBlockTypeEDID will be passed. + @param options No options are currently defined. + @param data Caller allocated buffer to receive the blocks data. + @param length In/out parameter - callers allocated buffer size, driver returns actual size. + @result An IOReturn code. +*/ + + virtual IOReturn getDDCBlock( IOIndex connectIndex, UInt32 blockNumber, + IOSelect blockType, IOOptionBits options, + UInt8 * data, IOByteCount * length ); + +/*! @function registerForInterruptType + @abstract Set callbacks for driver to call on interrupt events. + @discussion The IOFramebuffer class will call its subclasses to set callbacks to be called on interrupt events generated by hardware events. Only two are currently in use - vertical blank interrupts and connection changed interrupts. + @param interruptType One of these constants:
+ kIOFBVBLInterruptType Specifying a vertical blanking interrupt. + kIOFBConnectInterruptType Specify the display connection should be resensed. + @param proc C callback to be called by the driver when the specified event occurs. + @param target Target parameter for the callback proc. + @param ref Ref parameter for the callback proc. + @param interruptRef The subclass should return an opaque reference to the installed interrupt handler, for use with unregisterInterrupt() and setInterruptState(). + @result An IOReturn code. +*/ + + virtual IOReturn registerForInterruptType( IOSelect interruptType, + IOFBInterruptProc proc, OSObject * target, void * ref, + void ** interruptRef ); + +/*! @function unregisterInterrupt + @abstract Remove a callback previously installed by registerForInterruptType(). + @discussion Remove a callback previously installed by registerForInterruptType(). + @param interruptRef The interruptRef returned from the registerForInterruptType call that installed the interrupt. + @result An IOReturn code. +*/ + + virtual IOReturn unregisterInterrupt( void * interruptRef ); + +/*! @function unregisterInterrupt + @abstract Enable or disable a callback previously installed by registerForInterruptType(). + @discussion Enable or disable a callback previously installed by registerForInterruptType(). + @param state True or false to enable the callback. + @result An IOReturn code. +*/ + + virtual IOReturn setInterruptState( void * interruptRef, UInt32 state ); + + virtual IOReturn getNotificationSemaphore( IOSelect interruptType, + semaphore_t * semaphore ); + +/* non WL clients apis +*/ + IOReturn setAttributeExt( IOSelect attribute, uintptr_t value ); + + IOReturn getAttributeExt( IOSelect attribute, uintptr_t * value ); + + IOReturn setAttributeForConnectionExt( IOIndex connectIndex, + IOSelect attribute, uintptr_t value ); + + IOReturn getAttributeForConnectionExt( IOIndex connectIndex, + IOSelect attribute, uintptr_t * value ); +}; + +#endif /* ! _IOKIT_IOFRAMEBUFFER_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/graphics/IODisplay.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/graphics/IODisplay.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/graphics/IODisplay.h (revision 885) @@ -0,0 +1,292 @@ +/* + * 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_IODISPLAY_H +#define _IOKIT_IODISPLAY_H + +#include +#include + +extern const OSSymbol * gIODisplayParametersKey; +extern const OSSymbol * gIODisplayGUIDKey; + +extern const OSSymbol * gIODisplayValueKey; +extern const OSSymbol * gIODisplayMinValueKey; +extern const OSSymbol * gIODisplayMaxValueKey; + +extern const OSSymbol * gIODisplayContrastKey; +extern const OSSymbol * gIODisplayBrightnessKey; +extern const OSSymbol * gIODisplayHorizontalPositionKey; +extern const OSSymbol * gIODisplayHorizontalSizeKey; +extern const OSSymbol * gIODisplayVerticalPositionKey; +extern const OSSymbol * gIODisplayVerticalSizeKey; +extern const OSSymbol * gIODisplayTrapezoidKey; +extern const OSSymbol * gIODisplayPincushionKey; +extern const OSSymbol * gIODisplayParallelogramKey; +extern const OSSymbol * gIODisplayRotationKey; +extern const OSSymbol * gIODisplayOverscanKey; +extern const OSSymbol * gIODisplayVideoBestKey; + +extern const OSSymbol * gIODisplayParametersTheatreModeKey; +extern const OSSymbol * gIODisplayParametersTheatreModeWindowKey; + +extern const OSSymbol * gIODisplayMCCSVersionKey; +extern const OSSymbol * gIODisplayTechnologyTypeKey; +extern const OSSymbol * gIODisplayUsageTimeKey; +extern const OSSymbol * gIODisplayFirmwareLevelKey; + +extern const OSSymbol * gIODisplaySpeakerVolumeKey; +extern const OSSymbol * gIODisplaySpeakerSelectKey; +extern const OSSymbol * gIODisplayMicrophoneVolumeKey; +extern const OSSymbol * gIODisplayAmbientLightSensorKey; +extern const OSSymbol * gIODisplayAudioMuteAndScreenBlankKey; +extern const OSSymbol * gIODisplayAudioTrebleKey; +extern const OSSymbol * gIODisplayAudioBassKey; +extern const OSSymbol * gIODisplayAudioBalanceLRKey; +extern const OSSymbol * gIODisplayAudioProcessorModeKey; +extern const OSSymbol * gIODisplayPowerModeKey; +extern const OSSymbol * gIODisplayManufacturerSpecificKey; + +extern const OSSymbol * gIODisplayParametersCommitKey; +extern const OSSymbol * gIODisplayParametersDefaultKey; +extern const OSSymbol * gIODisplayParametersFlushKey; + +enum { + kIODisplayNumPowerStates = 4, + kIODisplayMaxPowerState = kIODisplayNumPowerStates - 1 +}; + +// these are the private instance variables for power management +struct DisplayPMVars +{ + UInt32 currentState; + // highest state number normally, lowest usable state in emergency + unsigned long maxState; + // true if the display has had power lowered due to user inactivity + bool displayIdle; +}; + +class IODisplayConnect : public IOService +{ + OSDeclareDefaultStructors(IODisplayConnect) + +private: + IOIndex connection; + +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; + +public: + virtual bool initWithConnection( IOIndex connection ); + virtual IOFramebuffer * getFramebuffer( void ); + virtual IOIndex getConnection( void ); + virtual IOReturn getAttributeForConnection( IOSelect selector, uintptr_t * value ); + virtual IOReturn setAttributeForConnection( IOSelect selector, uintptr_t value ); + virtual void joinPMtree ( IOService * driver ); +}; + +class IODisplay : public IOService +{ + OSDeclareAbstractStructors(IODisplay) + +public: + static void initialize( void ); + +protected: + // used to query the framebuffer controller + IODisplayConnect * fConnection; + class IODisplayParameterHandler * fParameterHandler; + void * __resv; + IONotifier * fNotifier; + + // pointer to protected instance variables for power management + struct DisplayPMVars * fDisplayPMVars; + + // reserved for future expansion + void * _IODisplay_reserved[32]; + +public: + virtual IOService * probe( IOService * provider, + SInt32 * score ); + + virtual bool start( IOService * provider ); + virtual void stop( IOService * provider ); + virtual void free(); + + virtual IODisplayConnect * getConnection( void ); + + virtual IOReturn getConnectFlagsForDisplayMode( + IODisplayModeID mode, UInt32 * flags ); + + virtual IOReturn getGammaTableByIndex( + UInt32 * channelCount, UInt32 * dataCount, + UInt32 * dataWidth, void ** data ); + + virtual IOReturn readFramebufferEDID( void ); + + // + virtual IOReturn framebufferEvent( IOFramebuffer * framebuffer, + IOIndex event, void * info ); + + // parameter setting + virtual IOReturn setProperties( OSObject * properties ); + virtual bool setForKey( OSDictionary * params, const OSSymbol * key, + SInt32 value, SInt32 min, SInt32 max ); + + static bool addParameter( OSDictionary * params, const OSSymbol * paramName, SInt32 min, SInt32 max ); + static bool setParameter( OSDictionary * params, const OSSymbol * paramName, SInt32 value ); + static OSDictionary * getIntegerRange( OSDictionary * params, const OSSymbol * sym, + SInt32 * value, SInt32 * min, SInt32 * max ); + + // low level set/get + virtual bool doIntegerSet( OSDictionary * params, + const OSSymbol * paramName, UInt32 value ); + virtual bool doDataSet( const OSSymbol * paramName, OSData * value ); + virtual bool doUpdate( void ); + + // power management methods + virtual IOReturn setPowerState( unsigned long, IOService * ); + virtual unsigned long maxCapabilityForDomainState( IOPMPowerFlags ); + virtual unsigned long initialPowerStateForDomainState( IOPMPowerFlags ); + virtual unsigned long powerStateForDomainState( IOPMPowerFlags ); + + // + virtual void initPowerManagement( IOService * provider); + virtual void dropOneLevel( void ); + virtual void makeDisplayUsable( void ); + +private: + OSMetaClassDeclareReservedUnused(IODisplay, 0); + OSMetaClassDeclareReservedUnused(IODisplay, 1); + OSMetaClassDeclareReservedUnused(IODisplay, 2); + OSMetaClassDeclareReservedUnused(IODisplay, 3); + OSMetaClassDeclareReservedUnused(IODisplay, 4); + OSMetaClassDeclareReservedUnused(IODisplay, 5); + OSMetaClassDeclareReservedUnused(IODisplay, 6); + OSMetaClassDeclareReservedUnused(IODisplay, 7); + OSMetaClassDeclareReservedUnused(IODisplay, 8); + OSMetaClassDeclareReservedUnused(IODisplay, 9); + OSMetaClassDeclareReservedUnused(IODisplay, 10); + OSMetaClassDeclareReservedUnused(IODisplay, 11); + OSMetaClassDeclareReservedUnused(IODisplay, 12); + OSMetaClassDeclareReservedUnused(IODisplay, 13); + OSMetaClassDeclareReservedUnused(IODisplay, 14); + OSMetaClassDeclareReservedUnused(IODisplay, 15); + OSMetaClassDeclareReservedUnused(IODisplay, 16); + OSMetaClassDeclareReservedUnused(IODisplay, 17); + OSMetaClassDeclareReservedUnused(IODisplay, 18); + OSMetaClassDeclareReservedUnused(IODisplay, 19); + +private: + static IOReturn _framebufferEvent( OSObject * self, void * ref, + IOFramebuffer *framebuffer, IOIndex event, void * info ); + + bool addParameterHandler( IODisplayParameterHandler * parameterHandler ); + bool removeParameterHandler( IODisplayParameterHandler * parameterHandler ); + static bool updateNumber( OSDictionary * params, const OSSymbol * key, SInt32 value ); +}; + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +class IOBacklightDisplay : public IODisplay +{ + OSDeclareDefaultStructors(IOBacklightDisplay) + +protected: + // User preferred brightness level + SInt32 fCurrentUserBrightness; + SInt32 fCurrentBrightness; + UInt32 fCurrentPowerState; + SInt32 fMinBrightness; + SInt32 fMaxBrightness; + UInt16 fMaxBrightnessLevel[kIODisplayNumPowerStates]; + +public: + virtual IOService * probe( IOService *, SInt32 * ); + virtual void stop( IOService * provider ); + virtual IOReturn setPowerState( unsigned long, IOService * ); + virtual unsigned long maxCapabilityForDomainState( IOPMPowerFlags ); + virtual unsigned long initialPowerStateForDomainState( IOPMPowerFlags ); + virtual unsigned long powerStateForDomainState( IOPMPowerFlags ); + + // + virtual void initPowerManagement( IOService * ); + +public: + virtual bool doIntegerSet( OSDictionary * params, + const OSSymbol * paramName, UInt32 value ); + virtual bool doUpdate( void ); + virtual void makeDisplayUsable( void ); + virtual bool setBrightness( SInt32 value ); + +private: + void handlePMSettingCallback(const OSSymbol *, OSObject *, uintptr_t); + + OSMetaClassDeclareReservedUnused(IOBacklightDisplay, 0); + OSMetaClassDeclareReservedUnused(IOBacklightDisplay, 1); + OSMetaClassDeclareReservedUnused(IOBacklightDisplay, 2); + OSMetaClassDeclareReservedUnused(IOBacklightDisplay, 3); + OSMetaClassDeclareReservedUnused(IOBacklightDisplay, 4); + OSMetaClassDeclareReservedUnused(IOBacklightDisplay, 5); + OSMetaClassDeclareReservedUnused(IOBacklightDisplay, 6); + OSMetaClassDeclareReservedUnused(IOBacklightDisplay, 7); + OSMetaClassDeclareReservedUnused(IOBacklightDisplay, 8); + OSMetaClassDeclareReservedUnused(IOBacklightDisplay, 9); +}; + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +class IODisplayParameterHandler : public IOService +{ + OSDeclareDefaultStructors(IODisplayParameterHandler) + +public: + virtual bool setDisplay( IODisplay * display ) = 0; + virtual bool doIntegerSet( OSDictionary * params, + const OSSymbol * paramName, UInt32 value ) = 0; + virtual bool doDataSet( const OSSymbol * paramName, OSData * value ) = 0; + virtual bool doUpdate( void ) = 0; + +private: + OSMetaClassDeclareReservedUnused(IODisplayParameterHandler, 0); + OSMetaClassDeclareReservedUnused(IODisplayParameterHandler, 1); + OSMetaClassDeclareReservedUnused(IODisplayParameterHandler, 2); + OSMetaClassDeclareReservedUnused(IODisplayParameterHandler, 3); + OSMetaClassDeclareReservedUnused(IODisplayParameterHandler, 4); + OSMetaClassDeclareReservedUnused(IODisplayParameterHandler, 5); + OSMetaClassDeclareReservedUnused(IODisplayParameterHandler, 6); + OSMetaClassDeclareReservedUnused(IODisplayParameterHandler, 7); + OSMetaClassDeclareReservedUnused(IODisplayParameterHandler, 8); + OSMetaClassDeclareReservedUnused(IODisplayParameterHandler, 9); +}; + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#endif /* ! _IOKIT_IODISPLAY_H */ + Index: branches/azimutz/Cleancut/i386/include/IOKit/graphics/IOGraphicsTypes.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/graphics/IOGraphicsTypes.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/graphics/IOGraphicsTypes.h (revision 885) @@ -0,0 +1,1260 @@ +/* + * 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_IOGRAPHICSTYPES_H +#define _IOKIT_IOGRAPHICSTYPES_H + + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define IOGRAPHICSTYPES_REV 24 + +typedef SInt32 IOIndex; +typedef UInt32 IOSelect; +typedef UInt32 IOFixed1616; +typedef UInt32 IODisplayVendorID; +typedef UInt32 IODisplayProductID; + +typedef SInt32 IODisplayModeID; +enum { + // This is the ID given to a programmable timing used at boot time + kIODisplayModeIDBootProgrammable = (IODisplayModeID)0xFFFFFFFB, + // Lowest (unsigned) DisplayModeID reserved by Apple + kIODisplayModeIDReservedBase = (IODisplayModeID)0x80000000 +}; + +enum { + kIOMaxPixelBits = 64 +}; +typedef char IOPixelEncoding[ kIOMaxPixelBits ]; + +// Common Apple pixel formats + +#define IO1BitIndexedPixels "P" +#define IO2BitIndexedPixels "PP" +#define IO4BitIndexedPixels "PPPP" +#define IO8BitIndexedPixels "PPPPPPPP" +#define IO16BitDirectPixels "-RRRRRGGGGGBBBBB" +#define IO32BitDirectPixels "--------RRRRRRRRGGGGGGGGBBBBBBBB" + +#define kIO30BitDirectPixels "--RRRRRRRRRRGGGGGGGGGGBBBBBBBBBB" +#define kIO64BitDirectPixels "-16R16G16B16" + +#define kIO16BitFloatPixels "-16FR16FG16FB16" +#define kIO32BitFloatPixels "-32FR32FG32FB32" + +// other possible pixel formats + +#define IOYUV422Pixels "Y4U2V2" +#define IO8BitOverlayPixels "O8" +// page flipping +#define IOPagedPixels "Page1" + +#define IO_SampleTypeAlpha 'A' +#define IO_SampleTypeSkip '-' + +// Info about a pixel format +enum { + kIOCLUTPixels = 0, + kIOFixedCLUTPixels = 1, + kIORGBDirectPixels = 2, + kIOMonoDirectPixels = 3, + kIOMonoInverseDirectPixels = 4, + kIORGBSignedDirectPixels = 5, + kIORGBSignedFloatingPointPixels = 6 +}; + +/*! + * @struct IOPixelInformation + * @abstract A structure defining the format of a framebuffer. + * @discussion This structure is used by IOFramebuffer to define the format of the pixels. + * @field bytesPerRow The number of bytes per row. + * @field bytesPerPlane Not used. + * @field bitsPerPixel The number of bits per pixel, including unused bits and alpha. + * @field pixelType One of kIOCLUTPixels (indexed pixels with changeable CLUT), kIORGBDirectPixels (direct pixels). + * @field componentCount One for indexed pixels, three for direct pixel formats. + * @field bitsPerComponent Number of bits per component in each pixel. + * @field componentMasks Mask of the bits valid for each component of the pixel - in R, G, B order for direct pixels. + * @field pixelFormat String description of the pixel format - IO32BitDirectPixels, IO16BitDirectPixels etc. + * @field flags None defined - set to zero. + * @field activeWidth Number of pixels visible per row. + * @field activeHeight Number of visible pixel rows. + * @field reserved Set to zero. + */ + +struct IOPixelInformation { + UInt32 bytesPerRow; + UInt32 bytesPerPlane; + UInt32 bitsPerPixel; + UInt32 pixelType; + UInt32 componentCount; + UInt32 bitsPerComponent; + UInt32 componentMasks[ 8 * 2 ]; + IOPixelEncoding pixelFormat; + UInt32 flags; + UInt32 activeWidth; + UInt32 activeHeight; + UInt32 reserved[ 2 ]; +}; +typedef struct IOPixelInformation IOPixelInformation; + +// ID for industry standard display timings +typedef UInt32 IOAppleTimingID; + +/*! + * @struct IODisplayModeInformation + * @abstract A structure defining the format of a framebuffer. + * @discussion This structure is used by IOFramebuffer to define the format of the pixels. + * @field nominalWidth Number of pixels visible per row. + * @field nominalHeight Number of visible pixel rows. + * @field refreshRate Refresh rate in fixed point 16.16. + * @field maxDepthIndex Highest depth index available in this display mode. + * @field flags Flags for the mode, including:
+ * kDisplayModeInterlacedFlag mode is interlaced.
+ * kDisplayModeSimulscanFlag mode is available on multiple display connections.
+ * kDisplayModeNotPresetFlag mode is not a factory preset for the display (geometry may need correction).
+ * kDisplayModeStretchedFlag mode is stretched/distorted to match the display aspect ratio.
+ * @field reserved Set to zero. + */ + +struct IODisplayModeInformation { + UInt32 nominalWidth; + UInt32 nominalHeight; + IOFixed1616 refreshRate; + IOIndex maxDepthIndex; + UInt32 flags; + UInt32 reserved[ 4 ]; +}; +typedef struct IODisplayModeInformation IODisplayModeInformation; + +// flags +enum { + kDisplayModeSafetyFlags = 0x00000007, + + kDisplayModeAlwaysShowFlag = 0x00000008, + kDisplayModeNeverShowFlag = 0x00000080, + kDisplayModeNotResizeFlag = 0x00000010, + kDisplayModeRequiresPanFlag = 0x00000020, + + kDisplayModeInterlacedFlag = 0x00000040, + + kDisplayModeSimulscanFlag = 0x00000100, + kDisplayModeBuiltInFlag = 0x00000400, + kDisplayModeNotPresetFlag = 0x00000200, + kDisplayModeStretchedFlag = 0x00000800, + kDisplayModeNotGraphicsQualityFlag = 0x00001000, + kDisplayModeValidateAgainstDisplay = 0x00002000, + kDisplayModeTelevisionFlag = 0x00100000, + kDisplayModeValidForMirroringFlag = 0x00200000 +}; +enum { + kDisplayModeValidFlag = 0x00000001, + kDisplayModeSafeFlag = 0x00000002, + kDisplayModeDefaultFlag = 0x00000004 +}; + +#ifndef KERNEL +// Framebuffer info - obsolete + +struct IOFramebufferInformation { + IOPhysicalAddress baseAddress; + UInt32 activeWidth; + UInt32 activeHeight; + IOByteCount bytesPerRow; + IOByteCount bytesPerPlane; + UInt32 bitsPerPixel; + UInt32 pixelType; + UInt32 flags; + UInt32 reserved[ 4 ]; +}; +typedef struct IOFramebufferInformation IOFramebufferInformation; +#endif + +// flags +enum { + kFramebufferSupportsCopybackCache = 0x00010000, + kFramebufferSupportsWritethruCache = 0x00020000, + kFramebufferSupportsGammaCorrection = 0x00040000, + kFramebufferDisableAltivecAccess = 0x00080000 +}; + +// Aperture is an index into supported pixel formats for a mode & depth +typedef IOIndex IOPixelAperture; +enum { + kIOFBSystemAperture = 0 +}; + +//// CLUTs + +typedef UInt16 IOColorComponent; + +/*! + * @struct IOColorEntry + * @abstract A structure defining one entry of a color lookup table. + * @discussion This structure is used by IOFramebuffer to define an entry of a color lookup table. + * @field index Number of pixels visible per row. + * @field red Value of red component 0-65535. + * @field green Value of green component 0-65535. + * @field blue Value of blue component 0-65535. + */ + +struct IOColorEntry { + UInt16 index; + IOColorComponent red; + IOColorComponent green; + IOColorComponent blue; +}; +typedef struct IOColorEntry IOColorEntry; + +// options (masks) +enum { + kSetCLUTByValue = 0x00000001, // else at index + kSetCLUTImmediately = 0x00000002, // else at VBL + kSetCLUTWithLuminance = 0x00000004 // else RGB +}; + +//// Controller attributes + +enum { + kIOPowerStateAttribute = 'pwrs', + kIOPowerAttribute = 'powr', + kIODriverPowerAttribute = 'dpow', + kIOHardwareCursorAttribute = 'crsr', + + kIOMirrorAttribute = 'mirr', + kIOMirrorDefaultAttribute = 'mrdf', + + kIOCapturedAttribute = 'capd', + + kIOCursorControlAttribute = 'crsc', + + kIOSystemPowerAttribute = 'spwr', + kIOVRAMSaveAttribute = 'vrsv', + kIODeferCLUTSetAttribute = 'vclt', + + kIOClamshellStateAttribute = 'clam' +}; + +// values for kIOMirrorAttribute +enum { + kIOMirrorIsPrimary = 0x80000000, + kIOMirrorHWClipped = 0x40000000 +}; + +// values for kIOMirrorDefaultAttribute +enum { + kIOMirrorDefault = 0x00000001, + kIOMirrorForced = 0x00000002 +}; + +//// Display mode timing information + +struct IODetailedTimingInformationV1 { + // from EDID defn + UInt32 pixelClock; // Hertz + UInt32 horizontalActive; // pixels + UInt32 horizontalBlanking; // pixels + UInt32 horizontalBorder; // pixels + UInt32 horizontalSyncOffset; // pixels + UInt32 horizontalSyncWidth; // pixels + UInt32 verticalActive; // lines + UInt32 verticalBlanking; // lines + UInt32 verticalBorder; // lines + UInt32 verticalSyncOffset; // lines + UInt32 verticalSyncWidth; // lines +}; +typedef struct IODetailedTimingInformationV1 IODetailedTimingInformationV1; + +/*! + * @struct IODetailedTimingInformationV2 + * @abstract A structure defining the detailed timing information of a display mode. + * @discussion This structure is used by IOFramebuffer to define detailed timing information for a display mode. The VESA EDID document has more information. + * @field __reservedA Set to zero. + * @field horizontalScaledInset If the mode is scaled, sets the number of active pixels to remove the left and right edges in order to display an underscanned image. + * @field verticalScaledInset If the mode is scaled, sets the number of active lines to remove the top and bottom edges in order to display an underscanned image. + * @field scalerFlags If the mode is scaled, + * kIOScaleStretchToFit may be set to allow stretching. + * kIOScaleRotateFlags is mask which may have the value given by kIOScaleRotate90, kIOScaleRotate180, kIOScaleRotate270 to display a rotated framebuffer. + * @field horizontalScaled If the mode is scaled, sets the size of the image before scaling or rotation. + * @field verticalScaled If the mode is scaled, sets the size of the image before scaling or rotation. + * @field signalConfig + * kIOAnalogSetupExpected set if display expects a blank-to-black setup or pedestal. See VESA signal standards.
+ * kIOInterlacedCEATiming set for a CEA style interlaced timing:
+ * Field 1 vertical blanking = half specified vertical blanking lines.
+ * Field 2 vertical blanking = (half vertical blanking lines) + 1 line.
+ * Field 1 vertical offset = half specified vertical sync offset.
+ * Field 2 vertical offset = (half specified vertical sync offset) + 0.5 lines.
+ * @field signalLevels One of:
+ * kIOAnalogSignalLevel_0700_0300 0.700 - 0.300 V p-p.
+ * kIOAnalogSignalLevel_0714_0286 0.714 - 0.286 V p-p.
+ * kIOAnalogSignalLevel_1000_0400 1.000 - 0.400 V p-p.
+ * kIOAnalogSignalLevel_0700_0000 0.700 - 0.000 V p-p.
+ * @field pixelClock Pixel clock frequency in Hz. + * @field minPixelClock Minimum pixel clock frequency in Hz, with error. + * @field maxPixelClock Maximum pixel clock frequency in Hz, with error. + * @field horizontalActive Pixel clocks per line. + * @field horizontalBlanking Blanking clocks per line. + * @field horizontalSyncOffset First clock of horizontal sync. + * @field horizontalSyncPulseWidth Width of horizontal sync. + * @field verticalActive Number of lines per frame. + * @field verticalBlanking Blanking lines per frame. + * @field verticalSyncOffset First line of vertical sync. + * @field verticalSyncPulseWidth Height of vertical sync. + * @field horizontalBorderLeft Number of pixels in left horizontal border. + * @field horizontalBorderRight Number of pixels in right horizontal border. + * @field verticalBorderTop Number of lines in top vertical border. + * @field verticalBorderBottom Number of lines in bottom vertical border. + * @field horizontalSyncConfig kIOSyncPositivePolarity for positive polarity horizontal sync (0 for negative). + * @field horizontalSyncLevel Zero. + * @field verticalSyncConfig kIOSyncPositivePolarity for positive polarity vertical sync (0 for negative). + * @field verticalSyncLevel Zero. + * @field numLinks number of links to be used by a dual link timing, if zero, assume one link. + * @field __reservedB Reserved set to zero. + */ + +struct IODetailedTimingInformationV2 { + + UInt32 __reservedA[3]; // Init to 0 + UInt32 horizontalScaledInset; // pixels + UInt32 verticalScaledInset; // lines + + UInt32 scalerFlags; + UInt32 horizontalScaled; + UInt32 verticalScaled; + + UInt32 signalConfig; + UInt32 signalLevels; + + UInt64 pixelClock; // Hz + + UInt64 minPixelClock; // Hz - With error what is slowest actual clock + UInt64 maxPixelClock; // Hz - With error what is fasted actual clock + + UInt32 horizontalActive; // pixels + UInt32 horizontalBlanking; // pixels + UInt32 horizontalSyncOffset; // pixels + UInt32 horizontalSyncPulseWidth; // pixels + + UInt32 verticalActive; // lines + UInt32 verticalBlanking; // lines + UInt32 verticalSyncOffset; // lines + UInt32 verticalSyncPulseWidth; // lines + + UInt32 horizontalBorderLeft; // pixels + UInt32 horizontalBorderRight; // pixels + UInt32 verticalBorderTop; // lines + UInt32 verticalBorderBottom; // lines + + UInt32 horizontalSyncConfig; + UInt32 horizontalSyncLevel; // Future use (init to 0) + UInt32 verticalSyncConfig; + UInt32 verticalSyncLevel; // Future use (init to 0) + UInt32 numLinks; + + UInt32 __reservedB[7]; // Init to 0 +}; +typedef struct IODetailedTimingInformationV2 IODetailedTimingInformationV2; +typedef struct IODetailedTimingInformationV2 IODetailedTimingInformation; + +struct IOTimingInformation { + IOAppleTimingID appleTimingID; // kIOTimingIDXXX const + UInt32 flags; + union { + IODetailedTimingInformationV1 v1; + IODetailedTimingInformationV2 v2; + } detailedInfo; +}; +typedef struct IOTimingInformation IOTimingInformation; + +enum { + // IOTimingInformation flags + kIODetailedTimingValid = 0x80000000, + kIOScalingInfoValid = 0x40000000 +}; + +enum { + // scalerFlags + kIOScaleStretchToFit = 0x00000001, + + kIOScaleRotateFlags = 0x000000f0, + + kIOScaleSwapAxes = 0x00000010, + kIOScaleInvertX = 0x00000020, + kIOScaleInvertY = 0x00000040, + + kIOScaleRotate0 = 0x00000000, + kIOScaleRotate90 = kIOScaleSwapAxes | kIOScaleInvertX, + kIOScaleRotate180 = kIOScaleInvertX | kIOScaleInvertY, + kIOScaleRotate270 = kIOScaleSwapAxes | kIOScaleInvertY +}; + + +#pragma pack(push, 4) +struct IOFBDisplayModeDescription { + IODisplayModeInformation info; + IOTimingInformation timingInfo; +}; +typedef struct IOFBDisplayModeDescription IOFBDisplayModeDescription; +#pragma pack(pop) + +/*! + * @struct IODisplayTimingRange + * @abstract A structure defining the limits and attributes of a display or framebuffer. + * @discussion This structure is used to define the limits for modes programmed as detailed timings by the OS. The VESA EDID is useful background information for many of these fields. A data property with this structure under the key kIOFBTimingRangeKey in a framebuffer will allow the OS to program detailed timings that fall within its range. + * @field __reservedA Set to zero. + * @field version Set to zero. + * @field __reservedB Set to zero. + * @field minPixelClock minimum pixel clock frequency in range, in Hz. + * @field minPixelClock maximum pixel clock frequency in range, in Hz. + * @field maxPixelError largest variation between specified and actual pixel clock frequency, in Hz. + * @field supportedSyncFlags mask of supported sync attributes. The following are defined:
+ * kIORangeSupportsSeparateSyncs - digital separate syncs.
+ * kIORangeSupportsSyncOnGreen - sync on green.
+ * kIORangeSupportsCompositeSync - composite sync.
+ * kIORangeSupportsVSyncSerration - vertical sync has serration and equalization pulses.
+ * @field supportedSignalLevels mask of possible signal levels. The following are defined:
+ * kIORangeSupportsSignal_0700_0300 0.700 - 0.300 V p-p.
+ * kIORangeSupportsSignal_0714_0286 0.714 - 0.286 V p-p.
+ * kIORangeSupportsSignal_1000_0400 1.000 - 0.400 V p-p.
+ * kIORangeSupportsSignal_0700_0000 0.700 - 0.000 V p-p.
+ * @field supportedSignalConfigs mask of possible signal configurations. The following are defined:
+ * kIORangeSupportsInterlacedCEATiming Supports CEA style interlaced timing:
+ * Field 1 vertical blanking = specified vertical blanking lines.
+ * Field 2 vertical blanking = vertical blanking lines + 1 line.
+ * Field 1 vertical offset = specified vertical sync offset.
+ * Field 2 vertical offset = specified vertical sync offset + 0.5 lines.
+ * kIORangeSupportsInterlacedCEATimingWithConfirm Supports CEA style interlaced timing, but require a confirm. + * @field minFrameRate minimum frame rate (vertical refresh frequency) in range, in Hz. + * @field maxFrameRate maximum frame rate (vertical refresh frequency) in range, in Hz. + * @field minLineRate minimum line rate (horizontal refresh frequency) in range, in Hz. + * @field maxLineRate maximum line rate (horizontal refresh frequency) in range, in Hz. + * @field maxHorizontalTotal maximum clocks in horizontal line (active + blanking). + * @field maxVerticalTotal maximum lines in vertical frame (active + blanking). + * @field __reservedD Set to zero. + * @field charSizeHorizontalActive horizontalActive must be a multiple of charSizeHorizontalActive. + * @field charSizeHorizontalBlanking horizontalBlanking must be a multiple of charSizeHorizontalBlanking. + * @field charSizeHorizontalSyncOffset horizontalSyncOffset must be a multiple of charSizeHorizontalSyncOffset. + * @field charSizeHorizontalSyncPulse horizontalSyncPulse must be a multiple of charSizeHorizontalSyncPulse. + * @field charSizeVerticalActive verticalActive must be a multiple of charSizeVerticalActive. + * @field charSizeVerticalBlanking verticalBlanking must be a multiple of charSizeVerticalBlanking. + * @field charSizeVerticalSyncOffset verticalSyncOffset must be a multiple of charSizeVerticalSyncOffset. + * @field charSizeVerticalSyncPulse verticalSyncPulse must be a multiple of charSizeVerticalSyncPulse. + * @field charSizeHorizontalBorderLeft horizontalBorderLeft must be a multiple of charSizeHorizontalBorderLeft. + * @field charSizeHorizontalBorderRight horizontalBorderRight must be a multiple of charSizeHorizontalBorderRight. + * @field charSizeVerticalBorderTop verticalBorderTop must be a multiple of charSizeVerticalBorderTop. + * @field charSizeVerticalBorderBottom verticalBorderBottom must be a multiple of charSizeVerticalBorderBottom. + * @field charSizeHorizontalTotal (horizontalActive + horizontalBlanking) must be a multiple of charSizeHorizontalTotal. + * @field charSizeVerticalTotal (verticalActive + verticalBlanking) must be a multiple of charSizeVerticalTotal. + * @field __reservedE Set to zero. + * @field minHorizontalActiveClocks minimum value of horizontalActive. + * @field maxHorizontalActiveClocks maximum value of horizontalActive. + * @field minHorizontalBlankingClocks minimum value of horizontalBlanking. + * @field maxHorizontalBlankingClocks maximum value of horizontalBlanking. + * @field minHorizontalSyncOffsetClocks minimum value of horizontalSyncOffset. + * @field maxHorizontalSyncOffsetClocks maximum value of horizontalSyncOffset. + * @field minHorizontalPulseWidthClocks minimum value of horizontalPulseWidth. + * @field maxHorizontalPulseWidthClocks maximum value of horizontalPulseWidth. + * @field minVerticalActiveClocks minimum value of verticalActive. + * @field maxVerticalActiveClocks maximum value of verticalActive. + * @field minVerticalBlankingClocks minimum value of verticalBlanking. + * @field maxVerticalBlankingClocks maximum value of verticalBlanking. + * @field minVerticalSyncOffsetClocks minimum value of verticalSyncOffset. + * @field maxVerticalSyncOffsetClocks maximum value of verticalSyncOffset. + * @field minVerticalPulseWidthClocks minimum value of verticalPulseWidth. + * @field maxVerticalPulseWidthClocks maximum value of verticalPulseWidth. + * @field minHorizontalBorderLeft minimum value of horizontalBorderLeft. + * @field maxHorizontalBorderLeft maximum value of horizontalBorderLeft. + * @field minHorizontalBorderRight minimum value of horizontalBorderRight. + * @field maxHorizontalBorderRight maximum value of horizontalBorderRight. + * @field minVerticalBorderTop minimum value of verticalBorderTop. + * @field maxVerticalBorderTop maximum value of verticalBorderTop. + * @field minVerticalBorderBottom minimum value of verticalBorderBottom. + * @field maxVerticalBorderBottom maximum value of verticalBorderBottom. + * @field maxNumLinks number of links supported, if zero, 1 link is assumed. + * @field minLink0PixelClock minimum pixel clock for link 0 (kHz). + * @field maxLink0PixelClock maximum pixel clock for link 0 (kHz). + * @field minLink1PixelClock minimum pixel clock for link 1 (kHz). + * @field maxLink1PixelClock maximum pixel clock for link 1 (kHz). + * @field __reservedF Set to zero. + */ + +struct IODisplayTimingRange +{ + UInt32 __reservedA[2]; // Init to 0 + UInt32 version; // Init to 0 + UInt32 __reservedB[5]; // Init to 0 + + UInt64 minPixelClock; // Min dot clock in Hz + UInt64 maxPixelClock; // Max dot clock in Hz + + UInt32 maxPixelError; // Max dot clock error + UInt32 supportedSyncFlags; + UInt32 supportedSignalLevels; + UInt32 supportedSignalConfigs; + + UInt32 minFrameRate; // Hz + UInt32 maxFrameRate; // Hz + UInt32 minLineRate; // Hz + UInt32 maxLineRate; // Hz + + UInt32 maxHorizontalTotal; // Clocks - Maximum total (active + blanking) + UInt32 maxVerticalTotal; // Clocks - Maximum total (active + blanking) + UInt32 __reservedD[2]; // Init to 0 + + UInt8 charSizeHorizontalActive; + UInt8 charSizeHorizontalBlanking; + UInt8 charSizeHorizontalSyncOffset; + UInt8 charSizeHorizontalSyncPulse; + + UInt8 charSizeVerticalActive; + UInt8 charSizeVerticalBlanking; + UInt8 charSizeVerticalSyncOffset; + UInt8 charSizeVerticalSyncPulse; + + UInt8 charSizeHorizontalBorderLeft; + UInt8 charSizeHorizontalBorderRight; + UInt8 charSizeVerticalBorderTop; + UInt8 charSizeVerticalBorderBottom; + + UInt8 charSizeHorizontalTotal; // Character size for active + blanking + UInt8 charSizeVerticalTotal; // Character size for active + blanking + UInt16 __reservedE; // Reserved (Init to 0) + + UInt32 minHorizontalActiveClocks; + UInt32 maxHorizontalActiveClocks; + UInt32 minHorizontalBlankingClocks; + UInt32 maxHorizontalBlankingClocks; + + UInt32 minHorizontalSyncOffsetClocks; + UInt32 maxHorizontalSyncOffsetClocks; + UInt32 minHorizontalPulseWidthClocks; + UInt32 maxHorizontalPulseWidthClocks; + + UInt32 minVerticalActiveClocks; + UInt32 maxVerticalActiveClocks; + UInt32 minVerticalBlankingClocks; + UInt32 maxVerticalBlankingClocks; + + UInt32 minVerticalSyncOffsetClocks; + UInt32 maxVerticalSyncOffsetClocks; + UInt32 minVerticalPulseWidthClocks; + UInt32 maxVerticalPulseWidthClocks; + + UInt32 minHorizontalBorderLeft; + UInt32 maxHorizontalBorderLeft; + UInt32 minHorizontalBorderRight; + UInt32 maxHorizontalBorderRight; + + UInt32 minVerticalBorderTop; + UInt32 maxVerticalBorderTop; + UInt32 minVerticalBorderBottom; + UInt32 maxVerticalBorderBottom; + UInt32 maxNumLinks; // number of links, if zero, assume link 1 + UInt32 minLink0PixelClock; // min pixel clock for link 0 (kHz) + UInt32 maxLink0PixelClock; // max pixel clock for link 0 (kHz) + UInt32 minLink1PixelClock; // min pixel clock for link 1 (kHz) + UInt32 maxLink1PixelClock; // max pixel clock for link 1 (kHz) + + UInt32 __reservedF[3]; // Init to 0 +}; +typedef struct IODisplayTimingRange IODisplayTimingRange; + +enum { + // supportedSignalLevels + kIORangeSupportsSignal_0700_0300 = 0x00000001, + kIORangeSupportsSignal_0714_0286 = 0x00000002, + kIORangeSupportsSignal_1000_0400 = 0x00000004, + kIORangeSupportsSignal_0700_0000 = 0x00000008 +}; +enum { + // supportedSyncFlags + kIORangeSupportsSeparateSyncs = 0x00000001, + kIORangeSupportsSyncOnGreen = 0x00000002, + kIORangeSupportsCompositeSync = 0x00000004, + kIORangeSupportsVSyncSerration = 0x00000008 +}; +enum { + // supportedSignalConfigs + kIORangeSupportsInterlacedCEATiming = 0x00000004, + kIORangeSupportsInterlacedCEATimingWithConfirm = 0x00000008 +}; + +enum { + // signalConfig + kIODigitalSignal = 0x00000001, + kIOAnalogSetupExpected = 0x00000002, + kIOInterlacedCEATiming = 0x00000004, + kIONTSCTiming = 0x00000008, + kIOPALTiming = 0x00000010 +}; + +enum { + // signalLevels for analog + kIOAnalogSignalLevel_0700_0300 = 0, + kIOAnalogSignalLevel_0714_0286 = 1, + kIOAnalogSignalLevel_1000_0400 = 2, + kIOAnalogSignalLevel_0700_0000 = 3 +}; + +enum { + // horizontalSyncConfig and verticalSyncConfig + kIOSyncPositivePolarity = 0x00000001 +}; + +/*! + * @struct IODisplayScalerInformation + * @abstract A structure defining the scaling capabilities of a framebuffer. + * @discussion This structure is used to define the limits for modes programmed as detailed timings by the OS. A data property with this structure under the key kIOFBScalerInfoKey in a framebuffer will allow the OS to program detailed timings that are scaled to a displays native resolution. + * @field __reservedA Set to zero. + * @field version Set to zero. + * @field __reservedB Set to zero. + * @field scalerFeatures Mask of scaling features. The following are defined:
+ * kIOScaleStretchOnly If set the framebuffer can only provide stretched scaling with non-square pixels, without borders.
+ * kIOScaleCanUpSamplePixels If set framebuffer can scale up from a smaller number of source pixels to a larger native timing (eg. 640x480 pixels on a 1600x1200 timing).
+ * kIOScaleCanDownSamplePixels If set framebuffer can scale down from a larger number of source pixels to a smaller native timing (eg. 1600x1200 pixels on a 640x480 timing).
+ * kIOScaleCanScaleInterlaced If set framebuffer can scale an interlaced detailed timing.
+ * kIOScaleCanSupportInset If set framebuffer can support scaled modes with non-zero horizontalScaledInset, verticalScaledInset fields.
+ * kIOScaleCanRotate If set framebuffer can support some of the flags in the kIOScaleRotateFlags mask.
+ * kIOScaleCanBorderInsetOnly If set framebuffer can support scaled modes with non-zero horizontalScaledInset, verticalScaledInset fields, but requires the active pixels to be equal in size to the inset area, ie. can do insets with a border versus scaling an image.
+ * @field maxHorizontalPixels Maximum number of horizontal source pixels (horizontalScaled).
+ * @field maxVerticalPixels Maximum number of vertical source pixels (verticalScaled).
+ * @field __reservedC Set to zero. + */ + +struct IODisplayScalerInformation { + UInt32 __reservedA[1]; // Init to 0 + UInt32 version; // Init to 0 + UInt32 __reservedB[2]; // Init to 0 + + IOOptionBits scalerFeatures; + UInt32 maxHorizontalPixels; + UInt32 maxVerticalPixels; + UInt32 __reservedC[5]; // Init to 0 +}; +typedef struct IODisplayScalerInformation IODisplayScalerInformation; + +enum { + /* scalerFeatures */ + kIOScaleStretchOnly = 0x00000001, + kIOScaleCanUpSamplePixels = 0x00000002, + kIOScaleCanDownSamplePixels = 0x00000004, + kIOScaleCanScaleInterlaced = 0x00000008, + kIOScaleCanSupportInset = 0x00000010, + kIOScaleCanRotate = 0x00000020, + kIOScaleCanBorderInsetOnly = 0x00000040 +}; + +//// Connections + +enum { + kOrConnections = 0xffffffe, + kAndConnections = 0xffffffd +}; + +enum { + kConnectionFlags = 'flgs', + kConnectionSyncEnable = 'sync', + kConnectionSyncFlags = 'sycf', + kConnectionSupportsAppleSense = 'asns', + kConnectionSupportsLLDDCSense = 'lddc', + kConnectionSupportsHLDDCSense = 'hddc', + kConnectionEnable = 'enab', + kConnectionCheckEnable = 'cena', + kConnectionProbe = 'prob', + kConnectionChanged = 'chng', + kConnectionPower = 'powr', + kConnectionPostWake = 'pwak', + kConnectionDisplayParameterCount = 'pcnt', + kConnectionDisplayParameters = 'parm', + kConnectionOverscan = 'oscn', + kConnectionVideoBest = 'vbst', + + kConnectionRedGammaScale = 'rgsc', + kConnectionGreenGammaScale = 'ggsc', + kConnectionBlueGammaScale = 'bgsc', + + kConnectionHandleDisplayPortEvent = 'dpir', + + kConnectionPanelTimingDisable = 'pnlt', + + kConnectionColorMode = 'cyuv', + kConnectionColorModesSupported = 'colr', + kConnectionColorDepthsSupported = ' bpc', + + kConnectionControllerDepthsSupported = '\0grd', + kConnectionControllerColorDepth = '\0dpd', + kConnectionControllerDitherControl = '\0gdc', + + kConnectionDisplayFlags = 'dflg', +}; + +// kConnectionFlags values +enum { + kIOConnectionBuiltIn = 0x00000800, + kIOConnectionStereoSync = 0x00008000 +}; + +// kConnectionSyncControl values +enum { + kIOHSyncDisable = 0x00000001, + kIOVSyncDisable = 0x00000002, + kIOCSyncDisable = 0x00000004, + kIONoSeparateSyncControl = 0x00000040, + kIOTriStateSyncs = 0x00000080, + kIOSyncOnBlue = 0x00000008, + kIOSyncOnGreen = 0x00000010, + kIOSyncOnRed = 0x00000020 +}; + +// kConnectionHandleDisplayPortEvent values +enum { + kIODPEventStart = 1, + kIODPEventIdle = 2, + + kIODPEventForceRetrain = 3, + + kIODPEventRemoteControlCommandPending = 256, + kIODPEventAutomatedTestRequest = 257, + kIODPEventContentProtection = 258, + kIODPEventMCCS = 259, + kIODPEventSinkSpecific = 260 +}; + +#define kIODisplayAttributesKey "IODisplayAttributes" + +#define kIODisplaySupportsUnderscanKey "IODisplaySupportsUnderscan" +#define kIODisplaySupportsBasicAudioKey "IODisplaySupportsBasicAudio" +#define kIODisplaySupportsYCbCr444Key "IODisplaySupportsYCbCr444" +#define kIODisplaySupportsYCbCr422Key "IODisplaySupportsYCbCr422" + +enum +{ + kIODisplayColorMode = kConnectionColorMode, +}; + +#if 0 +enum +{ + // kConnectionColorMode attribute + kIODisplayColorModeReserved = 0x00000000, + kIODisplayColorModeRGB = 0x00000001, + kIODisplayColorModeYCbCr422 = 0x00000010, + kIODisplayColorModeYCbCr444 = 0x00000100, + kIODisplayColorModeRGBLimited = 0x00001000, + kIODisplayColorModeAuto = 0x10000000, +}; +#endif + +enum +{ + // kConnectionColorDepthsSupported attribute + kIODisplayRGBColorComponentBitsUnknown = 0x00000000, + kIODisplayRGBColorComponentBits6 = 0x00000001, + kIODisplayRGBColorComponentBits8 = 0x00000002, + kIODisplayRGBColorComponentBits10 = 0x00000004, + kIODisplayRGBColorComponentBits12 = 0x00000008, + kIODisplayRGBColorComponentBits14 = 0x00000010, + kIODisplayRGBColorComponentBits16 = 0x00000020, + + kIODisplayYCbCr444ColorComponentBitsUnknown = 0x00000000, + kIODisplayYCbCr444ColorComponentBits6 = 0x00000100, + kIODisplayYCbCr444ColorComponentBits8 = 0x00000200, + kIODisplayYCbCr444ColorComponentBits10 = 0x00000400, + kIODisplayYCbCr444ColorComponentBits12 = 0x00000800, + kIODisplayYCbCr444ColorComponentBits14 = 0x00001000, + kIODisplayYCbCr444ColorComponentBits16 = 0x00002000, + + kIODisplayYCbCr422ColorComponentBitsUnknown = 0x00000000, + kIODisplayYCbCr422ColorComponentBits6 = 0x00010000, + kIODisplayYCbCr422ColorComponentBits8 = 0x00020000, + kIODisplayYCbCr422ColorComponentBits10 = 0x00040000, + kIODisplayYCbCr422ColorComponentBits12 = 0x00080000, + kIODisplayYCbCr422ColorComponentBits14 = 0x00100000, + kIODisplayYCbCr422ColorComponentBits16 = 0x00200000, +}; + +enum +{ + // kConnectionDitherControl attribute + kIODisplayDitherDisable = 0x00000000, + kIODisplayDitherSpatial = 0x00000001, + kIODisplayDitherTemporal = 0x00000002, + kIODisplayDitherFrameRateControl = 0x00000004, + kIODisplayDitherDefault = 0x00000080, + kIODisplayDitherAll = 0x000000FF, + kIODisplayDitherRGBShift = 0, + kIODisplayDitherYCbCr444Shift = 8, + kIODisplayDitherYCbCr422Shift = 16, +}; + +enum +{ + // kConnectionDisplayFlags attribute + kIODisplayNeedsCEAUnderscan = 0x00000001, +}; + + +#define IO_DISPLAY_CAN_FILL 0x00000040 +#define IO_DISPLAY_CAN_BLIT 0x00000020 + +#define IO_24BPP_TRANSFER_TABLE_SIZE 256 +#define IO_15BPP_TRANSFER_TABLE_SIZE 256 +#define IO_8BPP_TRANSFER_TABLE_SIZE 256 +#define IO_12BPP_TRANSFER_TABLE_SIZE 256 +#define IO_2BPP_TRANSFER_TABLE_SIZE 256 + +#define STDFB_BM256_TO_BM38_MAP_SIZE 256 +#define STDFB_BM38_TO_BM256_MAP_SIZE 256 +#define STDFB_BM38_TO_256_WITH_LOGICAL_SIZE \ + (STDFB_BM38_TO_BM256_MAP_SIZE + (256/sizeof(int))) + +#define STDFB_4BPS_TO_5BPS_MAP_SIZE 16 +#define STDFB_5BPS_TO_4BPS_MAP_SIZE 32 + +enum { + // connection types for IOServiceOpen + kIOFBServerConnectType = 0, + kIOFBSharedConnectType = 1 +}; + +enum { + // options for IOServiceRequestProbe() + kIOFBUserRequestProbe = 0x00000001 +}; + +struct IOGPoint { + SInt16 x; + SInt16 y; +}; +typedef struct IOGPoint IOGPoint; + +struct IOGSize { + SInt16 width; + SInt16 height; +}; +typedef struct IOGSize IOGSize; + +struct IOGBounds { + SInt16 minx; + SInt16 maxx; + SInt16 miny; + SInt16 maxy; +}; +typedef struct IOGBounds IOGBounds; + +#ifndef kIODescriptionKey + +#if !defined(__Point__) && !defined(BINTREE_H) && !defined(__MACTYPES__) +#define __Point__ +typedef IOGPoint Point; +#endif + +#if !defined(__Bounds__) && !defined(BINTREE_H) && !defined(__MACTYPES__) +#define __Bounds__ +typedef IOGBounds Bounds; +#endif + +#endif /* !kIODescriptionKey */ + +// cursor description + +enum { + kTransparentEncoding = 0, + kInvertingEncoding +}; + +enum { + kTransparentEncodingShift = (kTransparentEncoding << 1), + kTransparentEncodedPixel = (0x01 << kTransparentEncodingShift), + + kInvertingEncodingShift = (kInvertingEncoding << 1), + kInvertingEncodedPixel = (0x01 << kInvertingEncodingShift) +}; + +enum { + kHardwareCursorDescriptorMajorVersion = 0x0001, + kHardwareCursorDescriptorMinorVersion = 0x0000 +}; + +/*! + * @struct IOHardwareCursorDescriptor + * @abstract A structure defining the format of a hardware cursor. + * @discussion This structure is used by IOFramebuffer to define the format of a hardware cursor. + * @field majorVersion Set to kHardwareCursorDescriptorMajorVersion. + * @field minorVersion Set to kHardwareCursorDescriptorMinorVersion. + * @field height Maximum size of the cursor. + * @field width Maximum size of the cursor. + * @field bitDepth Number bits per pixel, or a QD/QT pixel type, for example kIO8IndexedPixelFormat, kIO32ARGBPixelFormat. + * @field maskBitDepth Unused. + * @field numColors Number of colors for indexed pixel types. + * @field colorEncodings An array pointer specifying the pixel values corresponding to the indices into the color table, for indexed pixel types. + * @field flags None defined, set to zero. + * @field supportedSpecialEncodings Mask of supported special pixel values, eg. kTransparentEncodedPixel, kInvertingEncodedPixel. + * @field specialEncodings Array of pixel values for each supported special encoding. + */ + +struct IOHardwareCursorDescriptor { + UInt16 majorVersion; + UInt16 minorVersion; + UInt32 height; + UInt32 width; + UInt32 bitDepth; // bits per pixel, or a QD/QT pixel type + UInt32 maskBitDepth; // unused + UInt32 numColors; // number of colors in the colorMap. ie. + UInt32 * colorEncodings; + UInt32 flags; + UInt32 supportedSpecialEncodings; + UInt32 specialEncodings[16]; +}; +typedef struct IOHardwareCursorDescriptor IOHardwareCursorDescriptor; + +enum { + kHardwareCursorInfoMajorVersion = 0x0001, + kHardwareCursorInfoMinorVersion = 0x0000 +}; + +/*! + * @struct IOHardwareCursorInfo + * @abstract A structure defining the converted data of a hardware cursor. + * @discussion This structure is used by IOFramebuffer to return the data of a hardware cursor by convertCursorImage() after conversion based on the IOHardwareCursorDescriptor passed to that routine. + * @field majorVersion Set to kHardwareCursorInfoMajorVersion. + * @field minorVersion Set to kHardwareCursorInfoMinorVersion. + * @field cursorHeight The actual size of the cursor is returned. + * @field cursorWidth The actual size of the cursor is returned. + * @field colorMap Pointer to array of IOColorEntry structures, with the number of elements set by the numColors field of the IOHardwareCursorDescriptor. Zero should be passed for direct pixel formats. + * @field hardwareCursorData Buffer to receive the converted cursor data. + * @field cursorHotSpotX Cursor's hotspot. + * @field cursorHotSpotY Cursor's hotspot. + * @field reserved Reserved, set to zero. + */ + +struct IOHardwareCursorInfo { + UInt16 majorVersion; + UInt16 minorVersion; + UInt32 cursorHeight; + UInt32 cursorWidth; + // nil or big enough for hardware's max colors + IOColorEntry * colorMap; + UInt8 * hardwareCursorData; + UInt16 cursorHotSpotX; + UInt16 cursorHotSpotY; + UInt32 reserved[5]; +}; +typedef struct IOHardwareCursorInfo IOHardwareCursorInfo; + +// interrupt types + +enum { + kIOFBVBLInterruptType = 'vbl ', + kIOFBHBLInterruptType = 'hbl ', + kIOFBFrameInterruptType = 'fram', + // Demand to check configuration (Hardware unchanged) + kIOFBConnectInterruptType = 'dci ', + // Demand to rebuild (Hardware has reinitialized on dependent change) + kIOFBChangedInterruptType = 'chng', + // Demand to remove framebuffer (Hardware not available on dependent change -- but must not buserror) + kIOFBOfflineInterruptType = 'remv', + // Notice that hardware is available (after being removed) + kIOFBOnlineInterruptType = 'add ', + // DisplayPort short pulse + kIOFBDisplayPortInterruptType = 'dpir', + // DisplayPort link event + kIOFBDisplayPortLinkChangeInterruptType = 'dplk', + // MCCS + kIOFBMCCSInterruptType = 'mccs' +}; + +// IOAppleTimingID's +enum { + kIOTimingIDInvalid = 0, /* Not a standard timing */ + kIOTimingIDApple_FixedRateLCD = 42, /* Lump all fixed-rate LCDs into one category.*/ + kIOTimingIDApple_512x384_60hz = 130, /* 512x384 (60 Hz) Rubik timing. */ + kIOTimingIDApple_560x384_60hz = 135, /* 560x384 (60 Hz) Rubik-560 timing. */ + kIOTimingIDApple_640x480_67hz = 140, /* 640x480 (67 Hz) HR timing. */ + kIOTimingIDApple_640x400_67hz = 145, /* 640x400 (67 Hz) HR-400 timing. */ + kIOTimingIDVESA_640x480_60hz = 150, /* 640x480 (60 Hz) VGA timing. */ + kIOTimingIDVESA_640x480_72hz = 152, /* 640x480 (72 Hz) VGA timing. */ + kIOTimingIDVESA_640x480_75hz = 154, /* 640x480 (75 Hz) VGA timing. */ + kIOTimingIDVESA_640x480_85hz = 158, /* 640x480 (85 Hz) VGA timing. */ + kIOTimingIDGTF_640x480_120hz = 159, /* 640x480 (120 Hz) VESA Generalized Timing Formula */ + kIOTimingIDApple_640x870_75hz = 160, /* 640x870 (75 Hz) FPD timing.*/ + kIOTimingIDApple_640x818_75hz = 165, /* 640x818 (75 Hz) FPD-818 timing.*/ + kIOTimingIDApple_832x624_75hz = 170, /* 832x624 (75 Hz) GoldFish timing.*/ + kIOTimingIDVESA_800x600_56hz = 180, /* 800x600 (56 Hz) SVGA timing. */ + kIOTimingIDVESA_800x600_60hz = 182, /* 800x600 (60 Hz) SVGA timing. */ + kIOTimingIDVESA_800x600_72hz = 184, /* 800x600 (72 Hz) SVGA timing. */ + kIOTimingIDVESA_800x600_75hz = 186, /* 800x600 (75 Hz) SVGA timing. */ + kIOTimingIDVESA_800x600_85hz = 188, /* 800x600 (85 Hz) SVGA timing. */ + kIOTimingIDVESA_1024x768_60hz = 190, /* 1024x768 (60 Hz) VESA 1K-60Hz timing. */ + kIOTimingIDVESA_1024x768_70hz = 200, /* 1024x768 (70 Hz) VESA 1K-70Hz timing. */ + kIOTimingIDVESA_1024x768_75hz = 204, /* 1024x768 (75 Hz) VESA 1K-75Hz timing (very similar to kIOTimingIDApple_1024x768_75hz). */ + kIOTimingIDVESA_1024x768_85hz = 208, /* 1024x768 (85 Hz) VESA timing. */ + kIOTimingIDApple_1024x768_75hz = 210, /* 1024x768 (75 Hz) Apple 19" RGB. */ + kIOTimingIDApple_1152x870_75hz = 220, /* 1152x870 (75 Hz) Apple 21" RGB. */ + kIOTimingIDAppleNTSC_ST = 230, /* 512x384 (60 Hz, interlaced, non-convolved). */ + kIOTimingIDAppleNTSC_FF = 232, /* 640x480 (60 Hz, interlaced, non-convolved). */ + kIOTimingIDAppleNTSC_STconv = 234, /* 512x384 (60 Hz, interlaced, convolved). */ + kIOTimingIDAppleNTSC_FFconv = 236, /* 640x480 (60 Hz, interlaced, convolved). */ + kIOTimingIDApplePAL_ST = 238, /* 640x480 (50 Hz, interlaced, non-convolved). */ + kIOTimingIDApplePAL_FF = 240, /* 768x576 (50 Hz, interlaced, non-convolved). */ + kIOTimingIDApplePAL_STconv = 242, /* 640x480 (50 Hz, interlaced, convolved). */ + kIOTimingIDApplePAL_FFconv = 244, /* 768x576 (50 Hz, interlaced, convolved). */ + kIOTimingIDVESA_1280x960_75hz = 250, /* 1280x960 (75 Hz) */ + kIOTimingIDVESA_1280x960_60hz = 252, /* 1280x960 (60 Hz) */ + kIOTimingIDVESA_1280x960_85hz = 254, /* 1280x960 (85 Hz) */ + kIOTimingIDVESA_1280x1024_60hz = 260, /* 1280x1024 (60 Hz) */ + kIOTimingIDVESA_1280x1024_75hz = 262, /* 1280x1024 (75 Hz) */ + kIOTimingIDVESA_1280x1024_85hz = 268, /* 1280x1024 (85 Hz) */ + kIOTimingIDVESA_1600x1200_60hz = 280, /* 1600x1200 (60 Hz) VESA timing. */ + kIOTimingIDVESA_1600x1200_65hz = 282, /* 1600x1200 (65 Hz) VESA timing. */ + kIOTimingIDVESA_1600x1200_70hz = 284, /* 1600x1200 (70 Hz) VESA timing. */ + kIOTimingIDVESA_1600x1200_75hz = 286, /* 1600x1200 (75 Hz) VESA timing (pixel clock is 189.2 Mhz dot clock). */ + kIOTimingIDVESA_1600x1200_80hz = 288, /* 1600x1200 (80 Hz) VESA timing (pixel clock is 216>? Mhz dot clock) - proposed only. */ + kIOTimingIDVESA_1600x1200_85hz = 289, /* 1600x1200 (85 Hz) VESA timing (pixel clock is 229.5 Mhz dot clock). */ + kIOTimingIDVESA_1792x1344_60hz = 296, /* 1792x1344 (60 Hz) VESA timing (204.75 Mhz dot clock). */ + kIOTimingIDVESA_1792x1344_75hz = 298, /* 1792x1344 (75 Hz) VESA timing (261.75 Mhz dot clock). */ + kIOTimingIDVESA_1856x1392_60hz = 300, /* 1856x1392 (60 Hz) VESA timing (218.25 Mhz dot clock). */ + kIOTimingIDVESA_1856x1392_75hz = 302, /* 1856x1392 (75 Hz) VESA timing (288 Mhz dot clock). */ + kIOTimingIDVESA_1920x1440_60hz = 304, /* 1920x1440 (60 Hz) VESA timing (234 Mhz dot clock). */ + kIOTimingIDVESA_1920x1440_75hz = 306, /* 1920x1440 (75 Hz) VESA timing (297 Mhz dot clock). */ + kIOTimingIDSMPTE240M_60hz = 400, /* 60Hz V, 33.75KHz H, interlaced timing, 16:9 aspect, typical resolution of 1920x1035. */ + kIOTimingIDFilmRate_48hz = 410, /* 48Hz V, 25.20KHz H, non-interlaced timing, typical resolution of 640x480. */ + kIOTimingIDSony_1600x1024_76hz = 500, /* 1600x1024 (76 Hz) Sony timing (pixel clock is 170.447 Mhz dot clock). */ + kIOTimingIDSony_1920x1080_60hz = 510, /* 1920x1080 (60 Hz) Sony timing (pixel clock is 159.84 Mhz dot clock). */ + kIOTimingIDSony_1920x1080_72hz = 520, /* 1920x1080 (72 Hz) Sony timing (pixel clock is 216.023 Mhz dot clock). */ + kIOTimingIDSony_1920x1200_76hz = 540, /* 1900x1200 (76 Hz) Sony timing (pixel clock is 243.20 Mhz dot clock). */ + kIOTimingIDApple_0x0_0hz_Offline = 550, /* Indicates that this timing will take the display off-line and remove it from the system. */ + kIOTimingIDVESA_848x480_60hz = 570, /* 848x480 (60 Hz) VESA timing. */ + kIOTimingIDVESA_1360x768_60hz = 590 /* 1360x768 (60 Hz) VESA timing. */ +}; + +// framebuffer property keys + +#define kIOFramebufferInfoKey "IOFramebufferInformation" + +#define kIOFBWidthKey "IOFBWidth" +#define kIOFBHeightKey "IOFBHeight" +#define kIOFBRefreshRateKey "IOFBRefreshRate" +#define kIOFBFlagsKey "IOFBFlags" +#define kIOFBBytesPerRowKey "IOFBBytesPerRow" +#define kIOFBBytesPerPlaneKey "IOFBBytesPerPlane" +#define kIOFBBitsPerPixelKey "IOFBBitsPerPixel" +#define kIOFBComponentCountKey "IOFBComponentCount" +#define kIOFBBitsPerComponentKey "IOFBBitsPerComponent" + +#define kIOFBDetailedTimingsKey "IOFBDetailedTimings" +#define kIOFBTimingRangeKey "IOFBTimingRange" +#define kIOFBScalerInfoKey "IOFBScalerInfo" +#define kIOFBCursorInfoKey "IOFBCursorInfo" + +#define kIOFBHostAccessFlagsKey "IOFBHostAccessFlags" + +#define kIOFBMemorySizeKey "IOFBMemorySize" + +#define kIOFBProbeOptionsKey "IOFBProbeOptions" + +#define kIOFBGammaWidthKey "IOFBGammaWidth" +#define kIOFBGammaCountKey "IOFBGammaCount" +#define kIOFBCLUTDeferKey "IOFBCLUTDefer" + +// exists on the hibernate progress display device +#ifndef kIOHibernatePreviewActiveKey +#define kIOHibernatePreviewActiveKey "IOHibernatePreviewActive" +// values for kIOHibernatePreviewActiveKey set by driver +enum { + kIOHibernatePreviewActive = 0x00000001, + kIOHibernatePreviewUpdates = 0x00000002 +}; +#endif + +// CFNumber/CFData +#define kIOFBAVSignalTypeKey "av-signal-type" +enum { + kIOFBAVSignalTypeUnknown = 0x00000000, + kIOFBAVSignalTypeVGA = 0x00000001, + kIOFBAVSignalTypeDVI = 0x00000002, + kIOFBAVSignalTypeHDMI = 0x00000008, + kIOFBAVSignalTypeDP = 0x00000010, +}; + +// diagnostic keys + +#define kIOFBConfigKey "IOFBConfig" +#define kIOFBModesKey "IOFBModes" +#define kIOFBModeIDKey "ID" +#define kIOFBModeDMKey "DM" +#define kIOFBModeTMKey "TM" +#define kIOFBModeAIDKey "AID" +#define kIOFBModeDFKey "DF" + +// display property keys + +#define kIODisplayEDIDKey "IODisplayEDID" +#define kIODisplayLocationKey "IODisplayLocation" // CFString +#define kIODisplayConnectFlagsKey "IODisplayConnectFlags" // CFNumber +#define kIODisplayHasBacklightKey "IODisplayHasBacklight" // CFBoolean +#define kIODisplayIsDigitalKey "IODisplayIsDigital" // CFBoolean +#define kDisplayBundleKey "DisplayBundle" + +#define kAppleDisplayTypeKey "AppleDisplayType" +#define kAppleSenseKey "AppleSense" + +#define kIODisplayMCCSVersionKey "IODisplayMCCSVersion" +#define kIODisplayTechnologyTypeKey "IODisplayTechnologyType" +#define kIODisplayUsageTimeKey "IODisplayUsageTime" +#define kIODisplayFirmwareLevelKey "IODisplayFirmwareLevel" + +enum { + kDisplayVendorIDUnknown = 'unkn', + kDisplayProductIDGeneric = 0x717 +}; + +#define kDisplayVendorID "DisplayVendorID" // CFNumber +#define kDisplayProductID "DisplayProductID" // CFNumber +#define kDisplaySerialNumber "DisplaySerialNumber" // CFNumber +#define kDisplaySerialString "DisplaySerialString" // CFString +#define kDisplayWeekOfManufacture "DisplayWeekManufacture" // CFNumber +#define kDisplayYearOfManufacture "DisplayYearManufacture" // CFNumber + +// CFDictionary of language-locale keys, name values +// eg. "en"="Color LCD", "en-GB"="Colour LCD" +#define kDisplayProductName "DisplayProductName" + +// all CFNumber or CFArray of CFNumber (floats) +#define kDisplayWhitePointX "DisplayWhitePointX" +#define kDisplayWhitePointY "DisplayWhitePointY" +#define kDisplayRedPointX "DisplayRedPointX" +#define kDisplayRedPointY "DisplayRedPointY" +#define kDisplayGreenPointX "DisplayGreenPointX" +#define kDisplayGreenPointY "DisplayGreenPointY" +#define kDisplayBluePointX "DisplayBluePointX" +#define kDisplayBluePointY "DisplayBluePointY" +#define kDisplayWhiteGamma "DisplayWhiteGamma" +#define kDisplayRedGamma "DisplayRedGamma" +#define kDisplayGreenGamma "DisplayGreenGamma" +#define kDisplayBlueGamma "DisplayBlueGamma" + +// Display gamma +#define kDisplayGammaChannels "DisplayGammaChannels" // CFNumber 1 or 3 channel count +#define kDisplayGammaEntryCount "DisplayGammaEntryCount" // CFNumber 1-based count of entries per channel +#define kDisplayGammaEntrySize "DisplayGammaEntrySize" // CFNumber size in bytes of each table entry +#define kDisplayGammaTable "DisplayGammaTable" // CFData + +// CFBoolean +#define kDisplayBrightnessAffectsGamma "DisplayBrightnessAffectsGamma" +#define kDisplayViewAngleAffectsGamma "DisplayViewAngleAffectsGamma" + +// CFData +#define kDisplayCSProfile "DisplayCSProfile" + +// CFNumber +#define kDisplayHorizontalImageSize "DisplayHorizontalImageSize" +#define kDisplayVerticalImageSize "DisplayVerticalImageSize" + +// Pixel description + +// CFBoolean +#define kDisplayFixedPixelFormat "DisplayFixedPixelFormat" + +enum { + kDisplaySubPixelLayoutUndefined = 0x00000000, + kDisplaySubPixelLayoutRGB = 0x00000001, + kDisplaySubPixelLayoutBGR = 0x00000002, + kDisplaySubPixelLayoutQuadGBL = 0x00000003, + kDisplaySubPixelLayoutQuadGBR = 0x00000004, + + kDisplaySubPixelConfigurationUndefined = 0x00000000, + kDisplaySubPixelConfigurationDelta = 0x00000001, + kDisplaySubPixelConfigurationStripe = 0x00000002, + kDisplaySubPixelConfigurationStripeOffset = 0x00000003, + kDisplaySubPixelConfigurationQuad = 0x00000004, + + kDisplaySubPixelShapeUndefined = 0x00000000, + kDisplaySubPixelShapeRound = 0x00000001, + kDisplaySubPixelShapeSquare = 0x00000002, + kDisplaySubPixelShapeRectangular = 0x00000003, + kDisplaySubPixelShapeOval = 0x00000004, + kDisplaySubPixelShapeElliptical = 0x00000005 +}; + +// CFNumbers +#define kDisplaySubPixelLayout "DisplaySubPixelLayout" +#define kDisplaySubPixelConfiguration "DisplaySubPixelConfiguration" +#define kDisplaySubPixelShape "DisplaySubPixelShape" + +#define kIODisplayOverrideMatchingKey "IODisplayOverrideMatching" + +// Display parameters + +#define kIODisplayParametersKey "IODisplayParameters" +#define kIODisplayGUIDKey "IODisplayGUID" + +#define kIODisplayValueKey "value" +#define kIODisplayMinValueKey "min" +#define kIODisplayMaxValueKey "max" + +#define kIODisplayBrightnessKey "brightness" +#define kIODisplayContrastKey "contrast" +#define kIODisplayHorizontalPositionKey "horizontal-position" +#define kIODisplayHorizontalSizeKey "horizontal-size" +#define kIODisplayVerticalPositionKey "vertical-position" +#define kIODisplayVerticalSizeKey "vertical-size" +#define kIODisplayTrapezoidKey "trapezoid" +#define kIODisplayPincushionKey "pincushion" +#define kIODisplayParallelogramKey "parallelogram" +#define kIODisplayRotationKey "rotation" +#define kIODisplayTheatreModeKey "theatre-mode" +#define kIODisplayTheatreModeWindowKey "theatre-mode-window" +#define kIODisplayOverscanKey "oscn" +#define kIODisplayVideoBestKey "vbst" + +#define kIODisplaySpeakerVolumeKey "speaker-volume" +#define kIODisplaySpeakerSelectKey "speaker-select" +#define kIODisplayMicrophoneVolumeKey "microphone-volume" +#define kIODisplayAmbientLightSensorKey "ambient-light-sensor" +#define kIODisplayAudioMuteAndScreenBlankKey "audio-mute-and-screen-blank" +#define kIODisplayAudioTrebleKey "audio-treble" +#define kIODisplayAudioBassKey "audio-bass" +#define kIODisplayAudioBalanceLRKey "audio-balance-LR" +#define kIODisplayAudioProcessorModeKey "audio-processor-mode" +#define kIODisplayPowerModeKey "power-mode" +#define kIODisplayManufacturerSpecificKey "manufacturer-specific" + + +#define kIODisplayRedGammaScaleKey "rgsc" +#define kIODisplayGreenGammaScaleKey "ggsc" +#define kIODisplayBlueGammaScaleKey "bgsc" + +#define kIODisplayParametersCommitKey "commit" +#define kIODisplayParametersDefaultKey "defaults" +#define kIODisplayParametersFlushKey "flush" + +#ifdef __cplusplus +} +#endif + +#endif /* ! _IOKIT_IOGRAPHICSTYPES_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/graphics/IOGraphicsEngine.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/graphics/IOGraphicsEngine.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/graphics/IOGraphicsEngine.h (revision 885) @@ -0,0 +1,51 @@ +/* + * 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@ + */ +/* + * Copyright (c) 1998 Apple Computer, Inc. All rights reserved. + * + * HISTORY + * + * 10 Mar 99 sdouglas created. + */ + + +struct IOGraphicsEngineContext { + IOSharedLockData contextLock; + IOOptionBits state; + void * owner; + UInt32 version; + IOByteCount structSize; + UInt32 reserved[ 8 ]; +}; +#ifndef __cplusplus +typedef volatile struct IOGraphicsEngineContext IOGraphicsEngineContext; +#endif + +enum { + // memory type for IOMapMemory + kIOGraphicsEngineContext = 100 +}; + +enum { + // version + kIOGraphicsEngineContextVersion = 1 +}; Index: branches/azimutz/Cleancut/i386/include/IOKit/graphics/IOGraphicsInterfaceTypes.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/graphics/IOGraphicsInterfaceTypes.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/graphics/IOGraphicsInterfaceTypes.h (revision 885) @@ -0,0 +1,301 @@ +/* + * Copyright (c) 1999-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_IOGRAPHICSINTERFACETYPES_H +#define _IOKIT_IOGRAPHICSINTERFACETYPES_H + +#include + +#define IO_FOUR_CHAR_CODE(x) (x) + +typedef UInt32 IOFourCharCode; + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#define kCurrentGraphicsInterfaceVersion 1 +#define kCurrentGraphicsInterfaceRevision 2 + + +#ifdef IOGA_COMPAT +typedef SInt32 IOBlitCompletionToken; +#endif + +typedef UInt32 IOBlitType; +enum { + kIOBlitTypeVerbMask = 0x000000ff, + kIOBlitTypeRects = 0, + kIOBlitTypeCopyRects, + kIOBlitTypeLines, + kIOBlitTypeScanlines, + kIOBlitTypeCopyRegion, + + kIOBlitTypeMoveCursor, + kIOBlitTypeShowCursor, + kIOBlitTypeHideCursor, + + kIOBlitTypeMonoExpand = 0x00000100, + kIOBlitTypeColorSpaceConvert = 0x00000200, + kIOBlitTypeScale = 0x00000400, + + kIOBlitTypeSourceKeyColorModeMask = 0x00003000, + kIOBlitTypeDestKeyColorModeMask = 0x0000c000, + kIOBlitTypeSourceKeyColorEqual = 0x00001000, + kIOBlitTypeSourceKeyColorNotEqual = 0x00002000, + kIOBlitTypeDestKeyColorEqual = 0x00004000, + kIOBlitTypeDestKeyColorNotEqual = 0x00008000, + + kIOBlitTypeOperationMask = 0x0fff0000, + kIOBlitTypeOperationShift = 16, + kIOBlitTypeOperationTypeMask = 0x0f000000, + + kIOBlitTypeOperationType0 = 0x00000000, + kIOBlitCopyOperation = 0x00000000 | kIOBlitTypeOperationType0, + kIOBlitOrOperation = 0x00010000 | kIOBlitTypeOperationType0, + kIOBlitXorOperation = 0x00020000 | kIOBlitTypeOperationType0, + kIOBlitBlendOperation = 0x00030000 | kIOBlitTypeOperationType0, + kIOBlitHighlightOperation = 0x00040000 | kIOBlitTypeOperationType0 +}; + +typedef UInt32 IOBlitSourceType; +enum { + kIOBlitSourceDefault = 0x00000000, + kIOBlitSourceFramebuffer = 0x00001000, + kIOBlitSourceMemory = 0x00002000, + kIOBlitSourceOOLMemory = 0x00003000, + kIOBlitSourcePattern = 0x00004000, + kIOBlitSourceOOLPattern = 0x00005000, + kIOBlitSourceSolid = 0x00006000, + kIOBlitSourceCGSSurface = 0x00007000, + kIOBlitSourceIsSame = 0x80000000 +}; + +#ifdef IOGA_COMPAT +typedef IOBlitSourceType IOBlitSourceDestType; +enum { + kIOBlitDestFramebuffer = 0x00000001 +}; +#endif + +typedef struct IOBlitOperationStruct { + UInt32 color0; + UInt32 color1; + SInt32 offsetX; + SInt32 offsetY; + UInt32 sourceKeyColor; + UInt32 destKeyColor; + UInt32 specific[16]; +} IOBlitOperation; + +typedef struct IOBlitRectangleStruct { + SInt32 x; + SInt32 y; + SInt32 width; + SInt32 height; +} IOBlitRectangle; + +typedef struct IOBlitRectanglesStruct { + IOBlitOperation operation; + IOItemCount count; + IOBlitRectangle rects[1]; +} IOBlitRectangles; + +typedef struct IOBlitCopyRectangleStruct { + SInt32 sourceX; + SInt32 sourceY; + SInt32 x; + SInt32 y; + SInt32 width; + SInt32 height; +} IOBlitCopyRectangle; + +typedef struct IOBlitCopyRectanglesStruct { + IOBlitOperation operation; + IOItemCount count; + IOBlitCopyRectangle rects[1]; +} IOBlitCopyRectangles; + + +typedef struct IOBlitCopyRegionStruct { + IOBlitOperation operation; + SInt32 deltaX; + SInt32 deltaY; + IOAccelDeviceRegion * region; +} IOBlitCopyRegion; + + +typedef struct IOBlitVertexStruct { + SInt32 x; + SInt32 y; +} IOBlitVertex; + +typedef struct IOBlitVerticesStruct { + IOBlitOperation operation; + IOItemCount count; + IOBlitVertex vertices[2]; +} IOBlitVertices; + +typedef struct IOBlitScanlinesStruct { + IOBlitOperation operation; + IOItemCount count; + SInt32 y; + SInt32 height; + SInt32 x[2]; +} IOBlitScanlines; + + +typedef struct IOBlitCursorStruct { + IOBlitOperation operation; + IOBlitRectangle rect; +} IOBlitCursor; + +typedef struct _IOBlitMemory * IOBlitMemoryRef; + + +/* Quickdraw.h pixel formats*/ + +enum { + kIO1MonochromePixelFormat = 0x00000001, /* 1 bit indexed*/ + kIO2IndexedPixelFormat = 0x00000002, /* 2 bit indexed*/ + kIO4IndexedPixelFormat = 0x00000004, /* 4 bit indexed*/ + kIO8IndexedPixelFormat = 0x00000008, /* 8 bit indexed*/ + kIO16BE555PixelFormat = 0x00000010, /* 16 bit BE rgb 555 (Mac)*/ + kIO24RGBPixelFormat = 0x00000018, /* 24 bit rgb */ + kIO32ARGBPixelFormat = 0x00000020, /* 32 bit argb (Mac)*/ + kIO1IndexedGrayPixelFormat = 0x00000021, /* 1 bit indexed gray*/ + kIO2IndexedGrayPixelFormat = 0x00000022, /* 2 bit indexed gray*/ + kIO4IndexedGrayPixelFormat = 0x00000024, /* 4 bit indexed gray*/ + kIO8IndexedGrayPixelFormat = 0x00000028 /* 8 bit indexed gray*/ +}; + +enum { + kIO16LE555PixelFormat = IO_FOUR_CHAR_CODE('L555'), /* 16 bit LE rgb 555 (PC)*/ + kIO16LE5551PixelFormat = IO_FOUR_CHAR_CODE('5551'), /* 16 bit LE rgb 5551*/ + kIO16BE565PixelFormat = IO_FOUR_CHAR_CODE('B565'), /* 16 bit BE rgb 565*/ + kIO16LE565PixelFormat = IO_FOUR_CHAR_CODE('L565'), /* 16 bit LE rgb 565*/ + kIO24BGRPixelFormat = IO_FOUR_CHAR_CODE('24BG'), /* 24 bit bgr */ + kIO32BGRAPixelFormat = IO_FOUR_CHAR_CODE('BGRA'), /* 32 bit bgra (Matrox)*/ + kIO32ABGRPixelFormat = IO_FOUR_CHAR_CODE('ABGR'), /* 32 bit abgr */ + kIO32RGBAPixelFormat = IO_FOUR_CHAR_CODE('RGBA'), /* 32 bit rgba */ + kIOYUVSPixelFormat = IO_FOUR_CHAR_CODE('yuvs'), /* YUV 4:2:2 byte ordering 16-unsigned = 'YUY2'*/ + kIOYUVUPixelFormat = IO_FOUR_CHAR_CODE('yuvu'), /* YUV 4:2:2 byte ordering 16-signed*/ + kIOYVU9PixelFormat = IO_FOUR_CHAR_CODE('YVU9'), /* YVU9 Planar 9*/ + kIOYUV411PixelFormat = IO_FOUR_CHAR_CODE('Y411'), /* YUV 4:1:1 Interleaved 16*/ + kIOYVYU422PixelFormat = IO_FOUR_CHAR_CODE('YVYU'), /* YVYU 4:2:2 byte ordering 16*/ + kIOUYVY422PixelFormat = IO_FOUR_CHAR_CODE('UYVY'), /* UYVY 4:2:2 byte ordering 16*/ + kIOYUV211PixelFormat = IO_FOUR_CHAR_CODE('Y211'), /* YUV 2:1:1 Packed 8*/ + kIO2vuyPixelFormat = IO_FOUR_CHAR_CODE('2vuy') /* UYVY 4:2:2 byte ordering 16*/ +}; + +/* Non Quickdraw.h pixel formats*/ +enum { + kIO16LE4444PixelFormat = IO_FOUR_CHAR_CODE('L444'), /* 16 bit LE argb 4444*/ + kIO16BE4444PixelFormat = IO_FOUR_CHAR_CODE('B444'), /* 16 bit BE argb 4444*/ + kIO64BGRAPixelFormat = IO_FOUR_CHAR_CODE('B16I'), /* 64 bit bgra */ + kIO64RGBAFloatPixelFormat = IO_FOUR_CHAR_CODE('B16F'), /* 64 bit rgba */ + kIO128RGBAFloatPixelFormat = IO_FOUR_CHAR_CODE('B32F') /* 128 bit rgba float */ +}; + +enum { + kIOBlitMemoryRequiresHostFlush = 0x00000001 +}; + +typedef struct IOBlitSurfaceStruct { + union { + UInt8 * bytes; + IOBlitMemoryRef ref; + } memory; + IOFourCharCode pixelFormat; + IOBlitRectangle size; + UInt32 rowBytes; + UInt32 byteOffset; + UInt32 * palette; + IOOptionBits accessFlags; + IOBlitMemoryRef interfaceRef; + UInt32 more[14]; +} IOBlitSurface; + +typedef IOBlitSurface IOBlitMemory; + + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +enum { + // options for Synchronize + kIOBlitSynchronizeWaitBeamExit = 0x00000001, + kIOBlitSynchronizeFlushHostWrites = 0x00000002 +}; + +enum { + // options for WaitComplete & Flush + kIOBlitWaitContext = 0x00000000, + kIOBlitWaitAll2D = 0x00000001, + kIOBlitWaitGlobal = 0x00000001, + kIOBlitWaitAll = 0x00000002, + kIOBlitWaitCheck = 0x00000080, + kIOBlitFlushWithSwap = 0x00010000 +}; + +enum { + // options for AllocateSurface + kIOBlitHasCGSSurface = 0x00000001, + kIOBlitFixedSource = 0x00000002, + kIOBlitBeamSyncSwaps = 0x00000004, + kIOBlitReferenceSource = 0x00000008 +}; + +enum { + // options for UnlockSurface + kIOBlitUnlockWithSwap = 0x80000000 +}; + +enum { + // options for SetDestination + kIOBlitFramebufferDestination = 0x00000000, + kIOBlitSurfaceDestination = 0x00000001 +}; + + + +enum { + // options for blit procs + kIOBlitBeamSync = 0x00000001, + kIOBlitBeamSyncAlways = 0x00000002, + kIOBlitBeamSyncSpin = 0x00000004, + + kIOBlitAllOptions = 0xffffffff +}; + +enum { + // capabilities + kIOBlitColorSpaceTypes = IO_FOUR_CHAR_CODE('cspc') +}; + + +// keys for IOAccelFindAccelerator() +#define kIOAccelTypesKey "IOAccelTypes" +#define kIOAccelIndexKey "IOAccelIndex" + +#define kIOAccelRevisionKey "IOAccelRevision" + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#endif /* !_IOKIT_IOGRAPHICSINTERFACETYPES_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/graphics/IOAccelSurfaceConnect.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/graphics/IOAccelSurfaceConnect.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/graphics/IOAccelSurfaceConnect.h (revision 885) @@ -0,0 +1,182 @@ +/* + * Copyright (c) 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 _IOACCEL_SURFACE_CONNECT_H +#define _IOACCEL_SURFACE_CONNECT_H + +#include +#include + +/* +** Surface visible region in device coordinates. +** +** num_rects: The number of rectangles in the rect array. If num_rects +** is zero the bounds rectangle is used for the visible rectangle. +** If num_rects is zero the surface must be completely contained +** by the device. +** +** bounds: The unclipped surface rectangle in device coords. Extends +** beyond the device bounds if the surface is not totally on +** the device. +** +** rect[]: An array of visible rectangles in device coords. If num_rects +** is non-zero only the region described by these rectangles is +** copied to the frame buffer during a flush operation. +*/ +typedef struct +{ + UInt32 num_rects; + IOAccelBounds bounds; + IOAccelBounds rect[0]; +} IOAccelDeviceRegion; + + +/* +** Determine the size of a region. +*/ +#define IOACCEL_SIZEOF_DEVICE_REGION(_rgn_) (sizeof(IOAccelDeviceRegion) + (_rgn_)->num_rects * sizeof(IOAccelBounds)) + + +/* +** Surface client public memory types. Private memory types start with +** kIOAccelNumSurfaceMemoryTypes. +*/ +enum eIOAccelSurfaceMemoryTypes { + kIOAccelNumSurfaceMemoryTypes +}; + + +/* +** Surface client public methods. Private methods start with +** kIOAccelNumSurfaceMethods. +*/ +enum eIOAccelSurfaceMethods { + kIOAccelSurfaceReadLockOptions, + kIOAccelSurfaceReadUnlockOptions, + kIOAccelSurfaceGetState, + kIOAccelSurfaceWriteLockOptions, + kIOAccelSurfaceWriteUnlockOptions, + kIOAccelSurfaceRead, + kIOAccelSurfaceSetShapeBacking, + + kIOAccelSurfaceSetIDMode, + kIOAccelSurfaceSetScale, + + kIOAccelSurfaceSetShape, + kIOAccelSurfaceFlush, + + kIOAccelSurfaceQueryLock, + + kIOAccelSurfaceReadLock, + kIOAccelSurfaceReadUnlock, + kIOAccelSurfaceWriteLock, + kIOAccelSurfaceWriteUnlock, + + kIOAccelSurfaceControl, + kIOAccelSurfaceSetShapeBackingAndLength, + + kIOAccelNumSurfaceMethods +}; + + +/* +** Option bits for IOAccelCreateSurface and the kIOAccelSurfaceSetIDMode method. +** The color depth field can take any value of the _CGSDepth enumeration. +*/ +typedef enum { + kIOAccelSurfaceModeColorDepth1555 = 0x00000003, + kIOAccelSurfaceModeColorDepth8888 = 0x00000004, +// kIOAccelSurfaceModeColorDepthRGB565 = 0x00000005, + kIOAccelSurfaceModeColorDepthYUV = 0x00000006, + kIOAccelSurfaceModeColorDepthYUV9 = 0x00000007, + kIOAccelSurfaceModeColorDepthYUV12 = 0x00000008, + kIOAccelSurfaceModeColorDepthYUV2 = 0x00000009, + kIOAccelSurfaceModeColorDepthBGRA32 = 0x0000000A, + +// kIOAccelSurfaceModeColorDepthRGBA64 = 0x0000000B, +// kIOAccelSurfaceModeColorDepthRGBAFloat64 = 0x0000000C, +// kIOAccelSurfaceModeColorDepthRGBAFloat128 = 0x0000000D, + +// kIOAccelSurfaceModeColorDepthYUV420 = 0x0000000E, + kIOAccelSurfaceModeColorDepth2101010 = 0x0000000F, + + kIOAccelSurfaceModeColorDepthBits = 0x0000000F, + + kIOAccelSurfaceModeStereoBit = 0x00000010, + kIOAccelSurfaceModeWindowedBit = 0x00000020, + + kIOAccelSurfaceModeBeamSync = 0x00008000 +} eIOAccelSurfaceModeBits; + + +/* +** Options bits for IOAccelSetSurfaceShape and the kIOAccelSurfaceSetShape method. +*/ +typedef enum { + kIOAccelSurfaceShapeNone = 0x00000000, + kIOAccelSurfaceShapeNonBlockingBit = 0x00000001, + kIOAccelSurfaceShapeNonSimpleBit = 0x00000002, + kIOAccelSurfaceShapeIdentityScaleBit = 0x00000004, + kIOAccelSurfaceShapeFrameSyncBit = 0x00000008, + kIOAccelSurfaceShapeBeamSyncBit = 0x00000010, + kIOAccelSurfaceShapeStaleBackingBit = 0x00000020, + kIOAccelSurfaceShapeAssemblyBit = 0x00000040, + kIOAccelSurfaceShapeWaitEnabledBit = 0x00000080, + + /* wrong name, use kIOAccelSurfaceShapeNonBlockingBit */ + kIOAccelSurfaceShapeBlockingBit = kIOAccelSurfaceShapeNonBlockingBit +} eIOAccelSurfaceShapeBits; + +/* +** Return bits for the kIOAccelSurfaceGetState method. +*/ +typedef enum { + kIOAccelSurfaceStateNone = 0x00000000, + kIOAccelSurfaceStateIdleBit = 0x00000001 +} eIOAccelSurfaceStateBits; + +/* +** Option bits for the kIOAccelSurfaceSetScale method. +*/ +typedef enum { + kIOAccelSurfaceBeamSyncSwaps = 0x00000001, + kIOAccelSurfaceFixedSource = 0x00000002, + + kIOAccelSurfaceFiltering = 0x000000f0, + kIOAccelSurfaceFilterDefault = 0x00000000, + kIOAccelSurfaceFilterNone = 0x00000010, + kIOAccelSurfaceFilterLinear = 0x00000020 + +} eIOAccelSurfaceScaleBits; + +/* +** Option bits for the kIOAccelSurfaceLock methods. +*/ +typedef enum { + kIOAccelSurfaceLockInBacking = 0, + kIOAccelSurfaceLockInAccel = 1, + kIOAccelSurfaceLockInDontCare = 2, + kIOAccelSurfaceLockInMask = 0x00000003 +} eIOAccelSurfaceLockBits; + +#endif /* _IOACCEL_SURFACE_CONNECT_H */ + Index: branches/azimutz/Cleancut/i386/include/IOKit/graphics/IOFramebufferShared.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/graphics/IOFramebufferShared.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/graphics/IOFramebufferShared.h (revision 885) @@ -0,0 +1,255 @@ +/* + * 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_IOFRAMEBUFFERSHARED_H +#define _IOKIT_IOFRAMEBUFFERSHARED_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/*! @header IOFramebufferShared +The IOFramebufferShared.h header contains definitions of objects and types shared between a kernel level IOFrameBuffer service and a non-kernel window server. In Mac OS X this structure is used by the CoreGraphics server and IOGraphics Family, and is not available to other clients. IOFramebuffer subclasses and IOFramebuffer clients within the kernel should also not rely on this structure definition and constants. It is public only for use on Darwin based window servers. Cursor and window server state data is exchanged by kernel and non-kernel tasks through a slice of shared memory containing a StdFBShmem_t structure.
+For a non-kernel task to get access to this slice of shared memory, a connection to an IOFramebuffer service must be made. A connection is made with the IOServiceOpen() function described in IOKitLib.h. A connection type of kIOFBServerConnectType or kIOFBSharedConnectType (for read-only access) should be specified. An io_connect_t handle is returned by IOServiceOpen(). This handle must be passed to IOFBCreateSharedCursor() to create the slice of shared memory. Then IOConnectMapMemory() may be called with a memory type of kIOFBCursorMemory to map the shared memory into the non-kernel task. +*/ + +#ifdef KERNEL +// CGS use optional +/*! @defined IOFB_ARBITRARY_SIZE_CURSOR + @discussion When IOFB_ARBITRARY_SIZE_CURSOR is not defined, the maximum cursor size is assumed to be CURSORWIDTH x CURSORHEIGHT and this header file will define a number of structures for storing cursor images accordingly. A non-kernel task may define IOFB_ARBITRARY_SIZE_CURSOR and use cursors up to the size specified when IOFBCreateSharedCursor() was called. In this case appropriate structures for storing cursor images must be defined elsewhere. In the kernel, IOFB_ARBITRARY_SIZE_CURSOR is always defined. +*/ +#define IOFB_ARBITRARY_SIZE_CURSOR +#define IOFB_ARBITRARY_FRAMES_CURSOR 1 +#endif + +#define IOFB_SUPPORTS_XOR_CURSOR +#define IOFB_SUPPORTS_HW_SHIELD +#define IOFB_SUPPORTS_ARBITRARY_FRAMES_CURSOR + +// +// Cursor and Window Server state data, occupying a slice of shared memory +// between the kernel and WindowServer. +// +/*! @enum CursorParameters + @constant kIOFBNumCursorFrames The number of cursor images stored in the StdFBShmem_t structure. + @constant kIOFBNumCursorFramesShift Used with waiting cursors. + @constant kIOFBMaxCursorDepth The maximum cursor pixel depth. +*/ +enum { +#if IOFB_ARBITRARY_FRAMES_CURSOR + kIOFBMainCursorIndex = 0, + kIOFBWaitCursorIndex = 1, + kIOFBNumCursorIndex = 4, +#else + kIOFBNumCursorFrames = 4, + kIOFBNumCursorFramesShift = 2, +#endif + kIOFBMaxCursorDepth = 32 +}; + +#ifndef IOFB_ARBITRARY_SIZE_CURSOR + +/*! @defined CURSORWIDTH + @discussion The maximum width of the cursor image in pixels. This is only defined if IOFB_ARBITRARY_SIZE_CURSOR is not defined. +*/ +#define CURSORWIDTH 16 /* width in pixels */ + +/*! @defined CURSORHEIGHT + @discussion The maximum height of the cursor image in pixels. This is only defined if IOFB_ARBITRARY_SIZE_CURSOR is not defined. +*/ +#define CURSORHEIGHT 16 /* height in pixels */ + +/*! @struct bm12Cursor + @abstract Cursor image for 1-bit cursor. + @discussion This structure stores 16 pixel x 16 pixel cursors to be used with 1-bit color depth. This structure is only defined if IOFB_ARBITRARY_SIZE_CURSOR is not defined. + @field image This array contains the cursor images. + @field mask This array contains the cursor mask. + @field save This array stores the pixel values of the region underneath the cursor in its last drawn position. +*/ +struct bm12Cursor { + unsigned int image[4][16]; + unsigned int mask[4][16]; + unsigned int save[16]; +}; + +/*! @struct bm18Cursor + @abstract Cursor image for 8-bit cursor. + @discussion This structure stores 16 pixel x 16 pixel cursors to be used with 8-bit color depth. This structure is only defined if IOFB_ARBITRARY_SIZE_CURSOR is not defined. + @field image This array contains cursor color values, which are converted to displayed colors through the color table. The array is two dimensional and its first index is the cursor frame and the second index is the cursor pixel. + @field mask This array contains the cursor alpha mask. The array is two dimensional with the same indexing as the image. If an alpha mask pixel is 0 and the corresponding image pixel is set to white for the display, then this cursor pixel will invert pixels on the display. + @field save This array stores the color values of the region underneath the cursor in its last drawn position. +*/ +struct bm18Cursor { + unsigned char image[4][256]; + unsigned char mask[4][256]; + unsigned char save[256]; +}; + +/*! @struct bm34Cursor + @abstract Cursor image for 15-bit cursor. + @discussion This structure stores 16 pixel x 16 pixel cursors to be used with 15-bit color depth. This structure is only defined if IOFB_ARBITRARY_SIZE_CURSOR is not defined. + @field image This array defines the cursor color values and transparency. The array is two dimensional and its first index is the cursor frame and the second index is the cursor pixel. A value of 0 means the pixel is transparent. Non-zero values are stored with the red, green, blue, and alpha values encoded with the following masks:
+ red mask = 0xF000
+ blue mask 0x0F00
+ green mask 0x00F0
+ alpha mask = 0x000F
+Note, only 4 bits are allocated for each color component. + @field save This array stores the color values of the region underneath the cursor in its last drawn position. +*/ +struct bm34Cursor { + unsigned short image[4][256]; + unsigned short save[256]; +}; + +/*! @struct bm38Cursor + @abstract Cursor image for 24-bit cursor. + @discussion This structure stores 16 pixel x 16 pixel cursors to be used with 24-bit color depth. This structure is only defined if IOFB_ARBITRARY_SIZE_CURSOR is not defined. + @field image This array defines the cursor color values and transparency. The array is two dimensional and its first index is the cursor frame and the second index is the cursor pixel. The lower 24 bits of a pixel's value contain the RGB color, while the upper 8 bits contain the alpha value. + @field save This array stores the color values of the region underneath the cursor in its last drawn position. +*/ +struct bm38Cursor { + unsigned int image[4][256]; + unsigned int save[256]; +}; + +#endif /* IOFB_ARBITRARY_SIZE_CURSOR */ + +enum { + kIOFBCursorImageNew = 0x01, + kIOFBCursorHWCapable = 0x02 +}; +enum { + kIOFBHardwareCursorActive = 0x01, + kIOFBHardwareCursorInVRAM = 0x02 +}; + +/*! @struct StdFBShmem_t + @discussion This structure contains cursor and window server state data and occupies a slice of shared memory between the kernel and window server. Several elements of this structure are only used in software cursor mode. Unless otherwise indicated, the coordinates in this structure are given in display space. Display space is the coordinate space that encompasses all the screens. The positions of the screens within display space indicate their location relative to each other as the cursor moves between them. If there is only one screen, the screen coordinates and display space coordinates will be the same. + @field cursorSema Semaphore lock for write access to the shared data in this structure. + @field frame The current cursor frame index. + @field cursorShow The cursor is displayed when cursorShow is 0. + @field cursorObscured If this is true, the cursor has been obscured and cursorShow should not be 0. The cursor will be shown again the next time it is moved. + @field shieldFlag When this is set to true the cursor will not be displayed in the region specified by shieldRect. + @field shielded True if the cursor has been hidden because it entered the shielded region. + @field saveRect The region that is saved underneath the cursor in software cursor mode. + @field shieldRect The region that the cursor will not be displayed in if shieldFlag is true. + @field cursorLoc The location of the cursor hot spot. + @field cursorRect The region that the cursor image currently occupies in software cursor mode. + @field oldCursorRect The region that the cursor image occupied the last time the cursor was drawn in software cursor mode. + @field screenBounds The region that the current screen occupies. + @field version Contains kIOFBCurrentShmemVersion so that a user client can ensure it is using the same version of this structure as the kernel. + @field structSize Contains the size of this structure. + @field vblTime The time of the most recent vertical blanking. + @field vblDelta The interval between the two most recent vertical blankings. + @field vblCount A running count of vertical blank interrupts. + @field reservedC Reserved for future use. + @field hardwareCursorCapable True if the hardware is capable of using hardware cursor mode. + @field hardwareCursorActive True if currently using the hardware cursor mode. + @field reservedB Reserved for future use. + @field cursorSize This array contains the cursor sizes indexed by frame. + @field hotSpot This array contains the location of the cursor hot spots indexed by frame. The hot spots coordinates are given relative to the top left corner of the cursor image. + @field cursor A union of structures that define the cursor images. The structure used depends on the framebuffer's bit depth. These structures are defined above. +*/ + +struct StdFBShmem_t { + ev_lock_data_t cursorSema; + int frame; + char cursorShow; + char cursorObscured; + char shieldFlag; + char shielded; + IOGBounds saveRect; + IOGBounds shieldRect; + IOGPoint cursorLoc; + IOGBounds cursorRect; + IOGBounds oldCursorRect; + IOGBounds screenBounds; + int version; + int structSize; + AbsoluteTime vblTime; + AbsoluteTime vblDelta; + unsigned long long int vblCount; +#if IOFB_ARBITRARY_FRAMES_CURSOR + unsigned int reservedC[28]; +#else + unsigned int reservedC[27]; + unsigned char hardwareCursorFlags[kIOFBNumCursorFrames]; +#endif + unsigned char hardwareCursorCapable; + unsigned char hardwareCursorActive; + unsigned char hardwareCursorShields; + unsigned char reservedB[1]; +#if IOFB_ARBITRARY_FRAMES_CURSOR + IOGSize cursorSize[kIOFBNumCursorIndex]; + IOGPoint hotSpot[kIOFBNumCursorIndex]; +#else + IOGSize cursorSize[kIOFBNumCursorFrames]; + IOGPoint hotSpot[kIOFBNumCursorFrames]; +#endif +#ifndef IOFB_ARBITRARY_SIZE_CURSOR + union { + struct bm12Cursor bw; + struct bm18Cursor bw8; + struct bm34Cursor rgb; + struct bm38Cursor rgb24; + } cursor; +#else /* IOFB_ARBITRARY_SIZE_CURSOR */ + unsigned char cursor[0]; +#endif /* IOFB_ARBITRARY_SIZE_CURSOR */ +}; +#ifndef __cplusplus +typedef volatile struct StdFBShmem_t StdFBShmem_t; +#endif + + +/*! @enum FramebufferConstants + @constant kIOFBCurrentShmemVersion The current version of the slice of shared memory that contains the cursor and window server state data in the StdFBShmem_t structure. + @constant kIOFBCursorMemory The memory type for IOConnectMapMemory() to get a slice of shared memory that contains the StdFBShmem_t structure. +*/ +enum { + // version for IOFBCreateSharedCursor + kIOFBShmemVersionMask = 0x000000ff, + kIOFBTenPtOneShmemVersion = 2, + kIOFBTenPtTwoShmemVersion = 3, + kIOFBCurrentShmemVersion = 2, + + // number of frames in animating cursor (if > kIOFBTenPtTwoShmemVersion) + kIOFBShmemCursorNumFramesMask = 0x00ff0000, + kIOFBShmemCursorNumFramesShift = 16, + + // memory types for IOConnectMapMemory. + kIOFBCursorMemory = 100 +}; + +/*! @defined IOFRAMEBUFFER_CONFORMSTO + @discussion The class name of the framebuffer service. +*/ +#define IOFRAMEBUFFER_CONFORMSTO "IOFramebuffer" + +#ifdef __cplusplus +} +#endif + +#endif /* ! _IOKIT_IOFRAMEBUFFERSHARED_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/graphics/IOAccelTypes.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/graphics/IOAccelTypes.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/graphics/IOAccelTypes.h (revision 885) @@ -0,0 +1,101 @@ +/* + * Copyright (c) 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 _IOACCEL_TYPES_H +#define _IOACCEL_TYPES_H + +#include +#include + +#define IOACCEL_TYPES_REV 12 + +#if !defined(OSTYPES_K64_REV) && !defined(MAC_OS_X_VERSION_10_6) +#define IOACCELTYPES_10_5 1 +#endif + +/* Integer rectangle in device coordinates */ +typedef struct +{ + SInt16 x; + SInt16 y; + SInt16 w; + SInt16 h; +} IOAccelBounds; + +typedef struct +{ + SInt16 w; + SInt16 h; +} IOAccelSize; + +/* Surface information */ + +enum { + kIOAccelVolatileSurface = 0x00000001, + kIOAccelKeycolorSurface = 0x00000002 +}; + +typedef struct +{ +#if IOACCELTYPES_10_5 + vm_address_t address[4]; +#else + mach_vm_address_t address[4]; +#endif /* IOACCELTYPES_10_5 */ + UInt32 rowBytes; + UInt32 width; + UInt32 height; + UInt32 pixelFormat; + IOOptionBits flags; + IOFixed colorTemperature[4]; + UInt32 typeDependent[4]; +} IOAccelSurfaceInformation; + +typedef struct +{ +#if IOACCELTYPES_10_5 + long x, y, w, h; + void *client_addr; + unsigned long client_row_bytes; +#else + SInt32 x, y, w, h; + mach_vm_address_t client_addr; + UInt32 client_row_bytes; +#endif /* IOACCELTYPES_10_5 */ +} IOAccelSurfaceReadData; + +typedef struct { + IOAccelBounds buffer; + IOAccelSize source; + UInt32 reserved[8]; +} IOAccelSurfaceScaling; + + +typedef SInt32 IOAccelID; + +enum { + kIOAccelPrivateID = 0x00000001 +}; + + +#endif /* _IOACCEL_TYPES_H */ + Index: branches/azimutz/Cleancut/i386/include/IOKit/graphics/IOAccelClientConnect.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/graphics/IOAccelClientConnect.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/graphics/IOAccelClientConnect.h (revision 885) @@ -0,0 +1,44 @@ +/* + * Copyright (c) 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 _IOACCEL_CLIENT_CONNECT_H +#define _IOACCEL_CLIENT_CONNECT_H + + +/* +** The IOAccelerator service name +*/ +#define kIOAcceleratorClassName "IOAccelerator" + + +/* +** IOAccelerator public client types. Private client types start with +** kIOAccelNumClientTypes. +*/ +enum eIOAcceleratorClientTypes { + kIOAccelSurfaceClientType, + kIOAccelNumClientTypes +}; + + +#endif /* _IOACCEL_CLIENT_CONNECT_H */ + Index: branches/azimutz/Cleancut/i386/include/IOKit/graphics/IOGraphicsDevice.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/graphics/IOGraphicsDevice.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/graphics/IOGraphicsDevice.h (revision 885) @@ -0,0 +1,47 @@ +/* + * 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_IOGRAPHICSDEVICE_H +#define _IOKIT_IOGRAPHICSDEVICE_H + +#include +#include + + +class IOGraphicsDevice : public IOService +{ + OSDeclareAbstractStructors(IOGraphicsDevice) + +public: + + virtual void hideCursor( void ) = 0; + virtual void showCursor( IOGPoint * cursorLoc, int frame ) = 0; + virtual void moveCursor( IOGPoint * cursorLoc, int frame ) = 0; + + virtual void getVBLTime( AbsoluteTime * time, AbsoluteTime * delta ) = 0; + + virtual void getBoundingRect ( IOGBounds ** bounds ) = 0; +}; + +#endif /* ! _IOKIT_IOGRAPHICSDEVICE_H */ + Index: branches/azimutz/Cleancut/i386/include/IOKit/IOKitKeys.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/IOKitKeys.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/IOKitKeys.h (revision 885) @@ -0,0 +1,164 @@ +/* + * 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" + +// 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" + +// IOService matching property names +#define kIOProviderClassKey "IOProviderClass" +#define kIONameMatchKey "IONameMatch" +#define kIOPropertyMatchKey "IOPropertyMatch" +#define kIOPathMatchKey "IOPathMatch" +#define kIOLocationMatchKey "IOLocationMatch" +#define kIOParentMatchKey "IOParentMatch" +#define kIOResourceMatchKey "IOResourceMatch" +#define kIOMatchedServiceCountKey "IOMatchedServiceCountMatch" + +#define kIONameMatchedKey "IONameMatched" + +#define kIOMatchCategoryKey "IOMatchCategory" +#define kIODefaultMatchCategoryKey "IODefaultMatchCategory" + +// 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" +// diagnostic string describing the creating task +#define kIOUserClientCreatorKey "IOUserClientCreator" + +// IOService notification types +#define kIOPublishNotification "IOServicePublish" +#define kIOFirstPublishNotification "IOServiceFirstPublish" +#define kIOMatchedNotification "IOServiceMatched" +#define kIOFirstMatchNotification "IOServiceFirstMatch" +#define kIOTerminatedNotification "IOServiceTerminate" + +// 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" + +// properties found in services that implement command pooling +#define kIOCommandPoolSizeKey "IOCommandPoolSize" // (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) + +// 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 kIONVRAMDeletePropertyKey "IONVRAM-DELETE-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" + +#endif /* ! _IOKIT_IOKITKEYS_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/IOMessage.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/IOMessage.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/IOMessage.h (revision 885) @@ -0,0 +1,75 @@ +/* + * 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 +#include + +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 be 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 kIOMessageServicePropertyChange iokit_common_msg(0x130) + +#define kIOMessageCanDevicePowerOff iokit_common_msg(0x200) +#define kIOMessageDeviceWillPowerOff iokit_common_msg(0x210) +#define kIOMessageDeviceWillNotPowerOff iokit_common_msg(0x220) +#define kIOMessageDeviceHasPoweredOn iokit_common_msg(0x230) +#define kIOMessageCanSystemPowerOff iokit_common_msg(0x240) +#define kIOMessageSystemWillPowerOff iokit_common_msg(0x250) +#define kIOMessageSystemWillNotPowerOff iokit_common_msg(0x260) +#define kIOMessageCanSystemSleep iokit_common_msg(0x270) +#define kIOMessageSystemWillSleep iokit_common_msg(0x280) +#define kIOMessageSystemWillNotSleep iokit_common_msg(0x290) +#define kIOMessageSystemHasPoweredOn iokit_common_msg(0x300) +#define kIOMessageSystemWillRestart iokit_common_msg(0x310) +#define kIOMessageSystemWillPowerOn iokit_common_msg(0x320) + +#define kIOMessageCopyClientID iokit_common_msg(0x330) + +#endif /* ! __IOKIT_IOMESSAGE_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/IOFilterInterruptEventSource.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/IOFilterInterruptEventSource.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/IOFilterInterruptEventSource.h (revision 885) @@ -0,0 +1,156 @@ +/* + * 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 + 1999-4-15 Godfrey van der Linden(gvdl) + Created. +*/ +#ifndef _IOKIT_IOFILTERINTERRUPTEVENTSOURCE_H +#define _IOKIT_IOFILTERINTERRUPTEVENTSOURCE_H + +#include + +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. +

+ 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. +

+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. +

+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 *, IOFilterInterruptEventSource *); + +/*! @defined IOFilterInterruptAction + @discussion Backward compatibilty define for the old non-class scoped type definition. See $link IOFilterInterruptSource::Filter */ +#define IOFilterInterruptAction IOFilterInterruptEventSource::Filter + +private: + // Hide the superclass initializers + virtual bool init(OSObject *inOwner, + IOInterruptEventSource::Action inAction = 0, + IOService *inProvider = 0, + int inIntIndex = 0); + + static IOInterruptEventSource * + interruptEventSource(OSObject *inOwner, + IOInterruptEventSource::Action inAction = 0, + IOService *inProvider = 0, + 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) */ + ExpansionData *reserved; + +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 IOFilterInterruptEventSource * + filterInterruptEventSource(OSObject *owner, + IOInterruptEventSource::Action action, + Filter filter, + IOService *provider, + int intIndex = 0); + +/*! @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); + + +/*! @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; + +/*! @function normalInterruptOccurred + @abstract Override $link IOInterruptEventSource::normalInterruptOccured to make a filter callout. */ + virtual void normalInterruptOccurred(void *self, IOService *prov, int ind); + +/*! @function disableInterruptOccurred + @abstract Override $link IOInterruptEventSource::disableInterruptOccurred to make a filter callout. */ + virtual void disableInterruptOccurred(void *self, IOService *prov, int ind); + +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 */ Index: branches/azimutz/Cleancut/i386/include/IOKit/avc/IOFireWireAVCCommand.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/avc/IOFireWireAVCCommand.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/avc/IOFireWireAVCCommand.h (revision 885) @@ -0,0 +1,94 @@ +/* + * Copyright (c) 1998-2001 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_IOFireWireAVCCommand_H +#define _IOKIT_IOFireWireAVCCommand_H + +#include + +/*! @class IOFireWireAVCCommand +*/ +class IOFireWireAVCCommand : public IOFWCommand +{ + OSDeclareDefaultStructors(IOFireWireAVCCommand) + +protected: + IOFWCommand *fWriteCmd; + IOMemoryDescriptor *fMem; + const UInt8 *fCommand; + + UInt32 fCmdLen; + UInt8 *fResponse; + UInt32 *fResponseLen; + int fCurRetries; + int fMaxRetries; + + UInt32 fWriteGen; + UInt16 fWriteNodeID; + bool bypassRobustCommandResponseMatching; + +/*! @struct ExpansionData + @discussion This structure will be used to expand the capablilties of the class in the future. + */ + struct ExpansionData { + bool fStarted; + bool fSyncWakeupSignaled; + }; + +/*! @var reserved + Reserved for future use. (Internal use only) */ + ExpansionData *fIOFireWireAVCCommandExpansion; + + static void writeDone(void *refcon, IOReturn status, IOFireWireNub *device, IOFWCommand *fwCmd); + + virtual IOReturn complete(IOReturn status); + virtual IOReturn execute(); + virtual void free(); + +public: + virtual bool init(IOFireWireNub *device, const UInt8 * command, UInt32 cmdLen, + UInt8 * response, UInt32 * responseLen); + virtual IOReturn reinit(IOFireWireNub *device, const UInt8 * command, UInt32 cmdLen, + UInt8 * response, UInt32 * responseLen); + + static IOFireWireAVCCommand *withNub(IOFireWireNub *device, const UInt8 * command, UInt32 cmdLen, + UInt8 * response, UInt32 * responseLen); + + static IOFireWireAVCCommand *withNub(IOFireWireNub *device, UInt32 generation, + const UInt8 * command, UInt32 cmdLen, UInt8 * response, UInt32 * responseLen); + + virtual UInt32 handleResponse(UInt16 nodeID, UInt32 len, const void *buf); + + virtual IOReturn resetInterimTimeout(); + + virtual UInt32 handleResponseWithSimpleMatching(UInt16 nodeID, UInt32 len, const void *buf); + + virtual IOReturn submit(bool queue = false); + +private: + OSMetaClassDeclareReservedUsed(IOFireWireAVCCommand, 0); + OSMetaClassDeclareReservedUnused(IOFireWireAVCCommand, 1); + OSMetaClassDeclareReservedUnused(IOFireWireAVCCommand, 2); + OSMetaClassDeclareReservedUnused(IOFireWireAVCCommand, 3); +}; + +#endif // _IOKIT_IOFireWireAVCCommand_H + Index: branches/azimutz/Cleancut/i386/include/IOKit/avc/IOFireWireAVCUnit.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/avc/IOFireWireAVCUnit.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/avc/IOFireWireAVCUnit.h (revision 885) @@ -0,0 +1,408 @@ +/* + * Copyright (c) 1998-2001 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_IOFIREWIREAVCUNIT_H +#define _IOKIT_IOFIREWIREAVCUNIT_H + +#include +#include +#include +#include +#include + +extern const OSSymbol *gIOAVCUnitType; + +class IOFireWireNub; +class IOFireWireAVCCommand; +class IOFireWirePCRSpace; +class IOFireWireAVCUnit; +class IOFireWireAVCSubUnit; +class IOFireWireAVCAsynchronousCommand; +class IOFireWireAVCNub; + +// The callback prototype for AVC Asynchronous Commands +typedef void (*IOFireWireAVCAsynchronousCommandCallback)(void *pRefCon, IOFireWireAVCAsynchronousCommand *pCommandObject); + +const UInt16 kIOFWAVCAsyncCmdFreed = 0xdead; + +/*! +@class IOFireWireAVCAsynchronousCommand +*/ +class IOFireWireAVCAsynchronousCommand : public IOCommand +{ + OSDeclareDefaultStructors(IOFireWireAVCAsynchronousCommand) + void free(void); + + friend class IOFireWireAVCUnit; + +protected: + /*! @struct ExpansionData + @discussion This structure will be used to expand the capablilties of the class in the future. + */ + struct ExpansionData { }; + + /*! @var reserved + Reserved for future use. (Internal use only) */ + ExpansionData *reserved; + +public: + IOReturn init(const UInt8 * command, UInt32 len, IOFireWireAVCAsynchronousCommandCallback completionCallback, void *pClientRefCon); + IOReturn submit(IOFireWireAVCNub *pAVCNub); + IOReturn cancel(void); + IOReturn reinit(const UInt8 * command, UInt32 cmdLen); + + // This function returns true if this command is currently waiting for a response + bool isPending(void); + + IOFWAVCAsyncCommandState cmdState; + void *pRefCon; + UInt8 *pCommandBuf; + UInt32 cmdLen; + UInt8 *pInterimResponseBuf; + UInt32 interimResponseLen; + UInt8 *pFinalResponseBuf; + UInt32 finalResponseLen; + +protected: + IOFireWireAVCAsynchronousCommandCallback fCallback; + IOFireWireAVCUnit *fAVCUnit; + IOMemoryDescriptor *fMem; + IOFWCommand *fWriteCmd; + IOFWDelayCommand *fDelayCmd; + UInt16 fWriteNodeID; + UInt32 fWriteGen; + +private: + OSMetaClassDeclareReservedUnused(IOFireWireAVCAsynchronousCommand, 0); + OSMetaClassDeclareReservedUnused(IOFireWireAVCAsynchronousCommand, 1); + OSMetaClassDeclareReservedUnused(IOFireWireAVCAsynchronousCommand, 2); + OSMetaClassDeclareReservedUnused(IOFireWireAVCAsynchronousCommand, 3); +}; + +/*! + @class IOFireWireAVCNub + @abstract nub for AVC devices +*/ +class IOFireWireAVCNub : public IOService +{ + OSDeclareDefaultStructors(IOFireWireAVCNub) + +protected: + IOFireWireNub * fDevice; + +public: + // execute AVC command +/*! + @function AVCCommand + @abstract Sends an AVC command to the device and stores the response. + @param command Pointer to command to send. + @param cmdLen Length of the command. + @param response Pointer to place to store the response. + @param responseLen Pointer to response length - initialize to the size of the buffer pointed to by response, + updated to the number of bytes returned by the device. +*/ + virtual IOReturn AVCCommand(const UInt8 * command, UInt32 cmdLen, UInt8 * response, UInt32 *responseLen) = 0; + +/*! + @function AVCCommandInGeneration + @abstract Sends an AVC command to the device and stores the response. The command must complete in the specified + FireWire bus generation otherwise kIOFireWireBusReset is returned. + @param generation The bus generation that the command must execute in. + @param command Pointer to command to send. + @param cmdLen Length of the command. + @param response Pointer to place to store the response. + @param responseLen Pointer to response length - initialize to the size of the buffer pointed to by response, + updated to the number of bytes returned by the device. +*/ + virtual IOReturn AVCCommandInGeneration(UInt32 generation, + const UInt8 * command, UInt32 cmdLen, UInt8 * response, UInt32 *responseLen) = 0; + +/*! + @function getDevice + @abstract Returns the FireWire device nub that is this object's provider . +*/ + IOFireWireNub* getDevice() const + {return fDevice;}; + +/*! + @function updateAVCCommandTimeout + @abstract By default, AVCCommands timeout 10 seconds after receiving an Interim response. + This function resets the timeout of the current command to 10 seconds from the current time. + Call this repeatedly for AVC commands that take a very long time to execute to prevent premature + timeout. +*/ + virtual IOReturn updateAVCCommandTimeout() = 0; + +private: + OSMetaClassDeclareReservedUsed(IOFireWireAVCNub, 0); + OSMetaClassDeclareReservedUnused(IOFireWireAVCNub, 1); + OSMetaClassDeclareReservedUnused(IOFireWireAVCNub, 2); + OSMetaClassDeclareReservedUnused(IOFireWireAVCNub, 3); +}; + +/*! + @class IOFireWireAVCUnit + @abstract nub for AVC devices +*/ +class IOFireWireAVCUnit : public IOFireWireAVCNub +{ + OSDeclareDefaultStructors(IOFireWireAVCUnit) + + friend class IOFireWireAVCAsynchronousCommand; + +protected: + IOFWPseudoAddressSpace *fFCPResponseSpace; + IOLock *avcLock; + IOFireWireAVCCommand *fCommand; + + UInt8 fSubUnitCount[kAVCNumSubUnitTypes]; + + bool fStarted; + IOLock *cmdLock; + +/*! @struct ExpansionData + @discussion This structure is used to expand the capablilties of the class in a binary compatible way + */ + struct ExpansionData + { + OSArray * fAVCAsyncCommands; + IOFireWireController *fControl; + bool enableRobustAVCCommandResponseMatching; + }; + +/*! @var fIOFireWireAVCUnitExpansion + */ + ExpansionData *fIOFireWireAVCUnitExpansion; + + static UInt32 AVCResponse(void *refcon, UInt16 nodeID, IOFWSpeed &speed, + FWAddress addr, UInt32 len, const void *buf, IOFWRequestRefCon requestRefcon); + + static void rescanSubUnits(void *arg); + + virtual void free(void); + + virtual void updateSubUnits(bool firstTime); + + static void AVCAsynchRequestWriteDone(void *refcon, IOReturn status, IOFireWireNub *device, IOFWCommand *fwCmd); + static void AVCAsynchDelayDone(void *refcon, IOReturn status, IOFireWireBus *bus, IOFWBusCommand *fwCmd); + +public: + // IOService overrides + virtual bool start(IOService *provider); + virtual IOReturn message(UInt32 type, IOService *provider, void *argument); + virtual IOReturn setProperties (OSObject * properties ); + +/*! @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 ); +/*! + @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 ); + + +/*! + @function matchPropertyTable + @abstract Matching language support + Match on the following properties of the unit: + Vendor_ID + GUID + Unit_Type + and available sub-units, match if the device has at least the requested number of a sub-unit type: + AVCSubUnit_0 -> AVCSubUnit_1f +*/ + virtual bool matchPropertyTable(OSDictionary * table); + + // execute AVC command +/*! + @function AVCCommand + @abstract Sends an AVC command to the device and stores the response. + @param command Pointer to command to send. + @param cmdLen Length of the command. + @param response Pointer to place to store the response. + @param responseLen Pointer to response length - initialize to the size of the buffer pointed to by response, + updated to the number of bytes returned by the device. +*/ + virtual IOReturn AVCCommand(const UInt8 * command, UInt32 cmdLen, UInt8 * response, UInt32 *responseLen); + +/*! + @function AVCCommandInGeneration + @abstract Sends an AVC command to the device and stores the response. The command must complete in the specified + FireWire bus generation otherwise kIOFireWireBusReset is returned. + @param generation The bus generation that the command must execute in. + @param command Pointer to command to send. + @param cmdLen Length of the command. + @param response Pointer to place to store the response. + @param responseLen Pointer to response length - initialize to the size of the buffer pointed to by response, + updated to the number of bytes returned by the device. +*/ + virtual IOReturn AVCCommandInGeneration(UInt32 generation, + const UInt8 * command, UInt32 cmdLen, UInt8 * response, UInt32 *responseLen); + +/*! + @function updateAVCCommandTimeout + @abstract By default, AVCCommands timeout 10 seconds after receiving an Interim response. + This function resets the timeout of the current command to 10 seconds from the current time. + Call this repeatedly for AVC commands that take a very long time to execute to prevent premature + timeout. +*/ + virtual IOReturn updateAVCCommandTimeout(); + +protected: + UInt32 indexOfAVCAsynchronousCommandObject(IOFireWireAVCAsynchronousCommand *pCommandObject); + void removeAVCAsynchronousCommandObjectAtIndex(UInt32 index); + + void lockAVCAsynchronousCommandLock(); + + void unlockAVCAsynchronousCommandLock(); + + bool available(); + +private: + + OSMetaClassDeclareReservedUnused(IOFireWireAVCUnit, 0); + OSMetaClassDeclareReservedUnused(IOFireWireAVCUnit, 1); + OSMetaClassDeclareReservedUnused(IOFireWireAVCUnit, 2); + OSMetaClassDeclareReservedUnused(IOFireWireAVCUnit, 3); + +}; + +/*! + @class IOFireWireAVCSubUnit + @abstract nub for sub unit of AVC devices. Just for matching, calls the AVC unit for all functions. +*/ +class IOFireWireAVCSubUnit : public IOFireWireAVCNub +{ + OSDeclareDefaultStructors(IOFireWireAVCSubUnit) + + friend class IOFireWireAVCAsynchronousCommand; + +protected: + IOFireWireAVCUnit *fAVCUnit; + +/*! @struct ExpansionData + @discussion This structure will be used to expand the capablilties of the class in the future. + */ + struct ExpansionData { }; + +/*! @var reserved + Reserved for future use. (Internal use only) */ + ExpansionData *reserved; + +public: + virtual bool init(OSDictionary *propTable, IOFireWireAVCUnit *provider); + + // IOService overrides + virtual IOReturn message(UInt32 type, IOService *provider, void *argument); + +/*! @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 ); +/*! + @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 ); + + +/*! + @function matchPropertyTable + @abstract Matching language support + Match on the following properties of the sub unit: + Vendor_ID + GUID + SubUnit_Type +*/ + virtual bool matchPropertyTable(OSDictionary * table); + + // execute AVC command +/*! + @function AVCCommand + @abstract Sends an AVC command to the device and stores the response. + @param command Pointer to command to send. + @param cmdLen Length of the command. + @param response Pointer to place to store the response. + @param responseLen Pointer to response length - initialize to the size of the buffer pointed to by response, + updated to the number of bytes returned by the device. +*/ + virtual IOReturn AVCCommand(const UInt8 * command, UInt32 cmdLen, UInt8 * response, UInt32 *responseLen); + +/*! + @function AVCCommandInGeneration + @abstract Sends an AVC command to the device and stores the response. The command must complete in the specified + FireWire bus generation otherwise kIOFireWireBusReset is returned. + @param generation The bus generation that the command must execute in. + @param command Pointer to command to send. + @param cmdLen Length of the command. + @param response Pointer to place to store the response. + @param responseLen Pointer to response length - initialize to the size of the buffer pointed to by response, + updated to the number of bytes returned by the device. +*/ + virtual IOReturn AVCCommandInGeneration(UInt32 generation, + const UInt8 * command, UInt32 cmdLen, UInt8 * response, UInt32 *responseLen); + +/*! + @function updateAVCCommandTimeout + @abstract By default, AVCCommands timeout 10 seconds after receiving an Interim response. + This function resets the timeout of the current command to 10 seconds from the current time. + Call this repeatedly for AVC commands that take a very long time to execute to prevent premature + timeout. +*/ + virtual IOReturn updateAVCCommandTimeout(); + +private: + OSMetaClassDeclareReservedUnused(IOFireWireAVCSubUnit, 0); + OSMetaClassDeclareReservedUnused(IOFireWireAVCSubUnit, 1); + OSMetaClassDeclareReservedUnused(IOFireWireAVCSubUnit, 2); + OSMetaClassDeclareReservedUnused(IOFireWireAVCSubUnit, 3); + +}; + +#endif // _IOKIT_IOFIREWIREAVCUNIT_H + Index: branches/azimutz/Cleancut/i386/include/IOKit/avc/IOFireWireAVCTargetSpace.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/avc/IOFireWireAVCTargetSpace.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/avc/IOFireWireAVCTargetSpace.h (revision 885) @@ -0,0 +1,297 @@ +/* + * Copyright (c) 2003 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@ + */ + +/* + * + * IOFireWireAVCTargetSpace.h + * + * Class to centralize the AVC Target mode support + * + */ + +#ifndef _IOKIT_IOFIREWIREAVCTARGETSPACE_H +#define _IOKIT_IOFIREWIREAVCTARGETSPACE_H + +#include +#include + +#include +#include +#include +#include + +class IOFireWireAVCProtocolUserClient; +class AVCCommandHandlerInfo; +class AVCSubunitInfo; + +typedef void (*IOFireWireAVCTargetCommandHandlerCallback)(const AVCCommandHandlerInfo *pCmdInfo, + UInt32 generation, + UInt16 nodeID, + const void *command, + UInt32 cmdLen, + IOFWSpeed &speed, + UInt32 handlerSearchIndex); + +typedef void (*IOFireWireAVCSubunitPlugHandlerCallback)(const AVCSubunitInfo *pSubunitInfo, + IOFWAVCSubunitPlugMessages plugMessage, + IOFWAVCPlugTypes plugType, + UInt32 plugNum, + UInt32 messageParams, + UInt32 generation, + UInt16 nodeID); + +/*! +@class AVCCommandHandlerInfo +@abstract internal class to manage installed command handlers +*/ +class AVCCommandHandlerInfo : public OSObject +{ + OSDeclareDefaultStructors(AVCCommandHandlerInfo) +public: + IOFireWireAVCProtocolUserClient * userClient; + IOFireWireAVCTargetCommandHandlerCallback callBack; + OSAsyncReference64 asyncRef; + UInt32 subUnitTypeAndID; + UInt32 opCode; + uint64_t userCallBack; + uint64_t userRefCon; +}; + +typedef struct _AVCSubunitPlugRecord +{ + UInt32 plugSignalFormat; + UInt32 connectionCount; +}AVCSubunitPlugRecord; + +/*! +@class AVCSubunitInfo +@abstract internal class to manage installed subunits +*/ +class AVCSubunitInfo : public OSObject +{ + OSDeclareDefaultStructors(AVCSubunitInfo) + bool init(); + void free(); +public: + static AVCSubunitInfo *create(); + IOFireWireAVCProtocolUserClient * userClient; + IOFireWireAVCSubunitPlugHandlerCallback callBack; + OSAsyncReference64 asyncRef; + UInt32 subunitTypeAndID; + UInt32 numSourcePlugs; + UInt32 numDestPlugs; + uint64_t userCallBack; + uint64_t userRefCon; + AVCSubunitPlugRecord *sourcePlugRecords; + AVCSubunitPlugRecord *destPlugRecords; +}; + +typedef struct _AVCUnitPlugRecord +{ + UInt32 connectionCount; +}AVCUnitPlugRecord; + +typedef struct _AVCUnitPlugs +{ + UInt32 numIsochInPlugs; + UInt32 numIsochOutPlugs; + UInt32 numExternalInPlugs; + UInt32 numExternalOutPlugs; + AVCUnitPlugRecord isochInPlugRecord[kAVCMaxNumPlugs]; + AVCUnitPlugRecord isochOutPlugRecord[kAVCMaxNumPlugs]; + AVCUnitPlugRecord externalInPlugRecord[kAVCMaxNumPlugs]; + AVCUnitPlugRecord externalOutPlugRecord[kAVCMaxNumPlugs]; +}AVCUnitPlugs; + +/*! +@class UCInfo +@abstract internal class to manage multiple protocol user clients +*/ +class UCInfo : public OSObject +{ + OSDeclareDefaultStructors(UCInfo) +public: + IOFireWireAVCProtocolUserClient *fUserClient; +}; + +/*! +@class AVCConnectionRecord +@abstract internal class to manage AVC connections +*/ +class AVCConnectionRecord : public OSObject +{ + OSDeclareDefaultStructors(AVCConnectionRecord) +public: + UInt32 sourceSubunitTypeAndID; + IOFWAVCPlugTypes sourcePlugType; + UInt32 sourcePlugNum; + UInt32 destSubunitTypeAndID; + IOFWAVCPlugTypes destPlugType; + UInt32 destPlugNum; + bool lockConnection; + bool permConnection; +}; + +/*! +@class IOFireWireAVCTargetSpace +@abstract object to centralize the AVC Target mode support +*/ +class IOFireWireAVCTargetSpace : public IOFWPseudoAddressSpace +{ + OSDeclareDefaultStructors(IOFireWireAVCTargetSpace) + +protected: + UInt32 fBuf[512]; + UInt32 fActivations; + IOFireWireController *fController; + IOLocalConfigDirectory * fAVCLocalConfigDirectory; + OSArray * fUserClients; + OSArray * fCommandHandlers; + OSArray * fSubunits; + OSArray * fConnectionRecords; + AVCUnitPlugs fUnitPlugs; + IORecursiveLock * fLock; + + /*! @struct ExpansionData + @discussion This structure will be used to expand the capablilties of the class in the future. + */ + struct ExpansionData { }; + + /*! @var reserved + Reserved for future use. (Internal use only) */ + ExpansionData *reserved; + + virtual UInt32 doWrite(UInt16 nodeID, IOFWSpeed &speed, FWAddress addr, UInt32 len, + const void *buf, IOFWRequestRefCon refcon); + + + IOReturn targetSendAVCResponse(UInt32 generation, UInt16 nodeID, IOBufferMemoryDescriptor *pBufMemDesc, UInt32 size); + + // Internal AVC Target Command Handlers + IOReturn handleUnitInfoCommand(UInt16 nodeID, UInt32 generation, const char *buf, UInt32 len); + IOReturn handleSubUnitInfoCommand(UInt16 nodeID, UInt32 generation, const char *buf, UInt32 len); + IOReturn handlePlugInfoCommand(UInt16 nodeID, UInt32 generation, const char *buf, UInt32 len); + IOReturn handlePowerCommand(UInt16 nodeID, UInt32 generation, const char *buf, UInt32 len); + IOReturn handleConnectCommand(UInt16 nodeID, UInt32 generation, const char *buf, UInt32 len); + IOReturn handleDisconnectCommand(UInt16 nodeID, UInt32 generation, const char *buf, UInt32 len); + IOReturn handleInputPlugSignalFormatCommand(UInt16 nodeID, UInt32 generation, const char *buf, UInt32 len); + IOReturn handleOutputPlugSignalFormatCommand(UInt16 nodeID, UInt32 generation, const char *buf, UInt32 len); + IOReturn handleConnectionsCommand(UInt16 nodeID, UInt32 generation, const char *buf, UInt32 len); + IOReturn handleSignalSourceCommand(UInt16 nodeID, UInt32 generation, const char *buf, UInt32 len); + + UInt32 subUnitOfTypeCount(UInt32 type); + AVCSubunitInfo *getSubunitInfo(UInt32 subunitTypeAndID); + bool canConnectDestPlug(UInt32 destSubunitTypeAndID, + IOFWAVCPlugTypes destPlugType, + UInt32 *destPlugNum); + +public: + + // Activate/Deactivate Functions + virtual IOReturn activateWithUserClient(IOFireWireAVCProtocolUserClient *userClient); + virtual void deactivateWithUserClient(IOFireWireAVCProtocolUserClient *userClient); + + /*! + @function init + @abstract initializes the IOFireWireAVCTargetSpace object + */ + virtual bool init(IOFireWireController *controller); + + /*! + @function getAVCTargetSpace + @abstract returns the IOFireWireAVCTargetSpace object for the given FireWire bus + @param bus The FireWire bus + */ + static IOFireWireAVCTargetSpace *getAVCTargetSpace(IOFireWireController *controller); + + /*! + @function publishAVCUnitDirectory + @abstract Creates a local AVC Unit directory if it doesn't already exist + */ + virtual IOReturn publishAVCUnitDirectory(void); + + virtual IOReturn installAVCCommandHandler(IOFireWireAVCProtocolUserClient *userClient, + IOFireWireAVCTargetCommandHandlerCallback callBack, + OSAsyncReference64 asyncRef, + UInt32 subUnitTypeAndID, + UInt32 opCode, + uint64_t userCallBack, + uint64_t userRefCon); + + virtual IOReturn addSubunit(IOFireWireAVCProtocolUserClient *userClient, + IOFireWireAVCSubunitPlugHandlerCallback callBack, + OSAsyncReference64 asyncRef, + UInt32 subunitType, + UInt32 numSourcePlugs, + UInt32 numDestPlugs, + uint64_t userCallBack, + uint64_t userRefCon, + UInt32 *subUnitID); + + virtual IOReturn setSubunitPlugSignalFormat(IOFireWireAVCProtocolUserClient *userClient, + UInt32 subunitTypeAndID, + IOFWAVCPlugTypes plugType, + UInt32 plugNum, + UInt32 signalFormat); + + virtual IOReturn getSubunitPlugSignalFormat(IOFireWireAVCProtocolUserClient *userClient, + UInt32 subunitTypeAndID, + IOFWAVCPlugTypes plugType, + UInt32 plugNum, + UInt32 *pSignalFormat); + + virtual IOReturn connectTargetPlugs(IOFireWireAVCProtocolUserClient *userClient, + AVCConnectTargetPlugsInParams *inParams, + AVCConnectTargetPlugsOutParams *outParams); + + virtual IOReturn disconnectTargetPlugs(IOFireWireAVCProtocolUserClient *userClient, + UInt32 sourceSubunitTypeAndID, + IOFWAVCPlugTypes sourcePlugType, + UInt32 sourcePlugNum, + UInt32 destSubunitTypeAndID, + IOFWAVCPlugTypes destPlugType, + UInt32 destPlugNum); + + virtual IOReturn getTargetPlugConnection(IOFireWireAVCProtocolUserClient *userClient, + AVCGetTargetPlugConnectionInParams *inParams, + AVCGetTargetPlugConnectionOutParams *outParams); + + virtual IOReturn findAVCRequestHandler(IOFireWireAVCProtocolUserClient *userClient, + UInt32 generation, + UInt16 nodeID, + IOFWSpeed speed, + UInt32 handlerSearchIndex, + const char *pCmdBuf, + UInt32 cmdLen); + + virtual void pcrModified(IOFWAVCPlugTypes plugType, + UInt32 plugNum, + UInt32 newValue); + +private: + OSMetaClassDeclareReservedUnused(IOFireWireAVCTargetSpace, 0); + OSMetaClassDeclareReservedUnused(IOFireWireAVCTargetSpace, 1); + OSMetaClassDeclareReservedUnused(IOFireWireAVCTargetSpace, 2); + OSMetaClassDeclareReservedUnused(IOFireWireAVCTargetSpace, 3); +}; + +#endif /*_IOKIT_IOFIREWIREAVCTARGETSPACE_H */ \ No newline at end of file Index: branches/azimutz/Cleancut/i386/include/IOKit/avc/IOFireWireAVCRequestSpace.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/avc/IOFireWireAVCRequestSpace.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/avc/IOFireWireAVCRequestSpace.h (revision 885) @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2001 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@ + */ +/* + * + * IOFireWirePCRSpace.h + * + * Class to multiplex access to the FCP request address. + */ +#ifndef _IOKIT_IOFIREWIREAVCREQUESTSPACE_H +#define _IOKIT_IOFIREWIREAVCREQUESTSPACE_H + +#endif /* _IOKIT_IOFIREWIREAVCREQUESTSPACE_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/avc/IOFireWireAVCUserClientCommon.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/avc/IOFireWireAVCUserClientCommon.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/avc/IOFireWireAVCUserClientCommon.h (revision 885) @@ -0,0 +1,124 @@ +/* + * Copyright (c) 1998-2001 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_IOFIREWIREAVCUSERCLIENTCOMMON_H_ +#define _IOKIT_IOFIREWIREAVCUSERCLIENTCOMMON_H_ + +#include + +#define kIOFireWireAVCLibConnection 13 + +enum IOFWAVCUserClientCommandCodes { + kIOFWAVCUserClientOpen, // kIOUCScalarIScalarO 0,0 + kIOFWAVCUserClientClose, // kIOUCScalarIScalarO 0,0 + kIOFWAVCUserClientOpenWithSessionRef, // kIOUCScalarIScalarO 1,0 + kIOFWAVCUserClientGetSessionRef, // kIOUCScalarIScalarO 0,1 + kIOFWAVCUserClientAVCCommand, // kIOUCStructIStructO -1,-1 + kIOFWAVCUserClientAVCCommandInGen, // kIOUCStructIStructO -1,-1 + kIOFWAVCUserClientUpdateAVCCommandTimeout, // kIOUCScalarIScalarO 0,0 + kIOFWAVCUserClientMakeP2PInputConnection, // KIOUCScalarIScalarO 1, 0 + kIOFWAVCUserClientBreakP2PInputConnection, // KIOUCScalarIScalarO 1, 0 + kIOFWAVCUserClientMakeP2POutputConnection, // KIOUCScalarIScalarO 1, 0 + kIOFWAVCUserClientBreakP2POutputConnection, // KIOUCScalarIScalarO 1, 0 + kIOFWAVCUserClientCreateAsyncAVCCommand, // kIOUCStructIStructO -1,-1 + kIOFWAVCUserClientSubmitAsyncAVCCommand, // kIOUCScalarIScalarO 1, 0 + kIOFWAVCUserClientCancelAsyncAVCCommand, // kIOUCScalarIScalarO 1, 0 + kIOFWAVCUserClientReleaseAsyncAVCCommand, // kIOUCScalarIScalarO 1, 0 + kIOFWAVCUserClientReinitAsyncAVCCommand, // // kIOUCScalarIStructI 1, -1 + kIOFWAVCUserClientNumCommands +}; + +enum IOFWAVCUserClientAsyncCommandCodes { + kIOFWAVCUserClientInstallAsyncAVCCommandCallback = kIOFWAVCUserClientNumCommands, // kIOUCScalarIScalarO 1, 1 + kIOFWAVCUserClientNumAsyncCommands +}; + + +enum IOFWAVCProtocolUserClientCommandCodes { + kIOFWAVCProtocolUserClientSendAVCResponse, // kIOUCScalarIStructI 2, -1 + kIOFWAVCProtocolUserClientFreeInputPlug, // kIOUCScalarIScalarO 1, 0 + kIOFWAVCProtocolUserClientReadInputPlug, // kIOUCScalarIScalarO 1, 1 + kIOFWAVCProtocolUserClientUpdateInputPlug, // kIOUCScalarIScalarO 3, 0 + kIOFWAVCProtocolUserClientFreeOutputPlug, // kIOUCScalarIScalarO 1, 0 + kIOFWAVCProtocolUserClientReadOutputPlug, // kIOUCScalarIScalarO 1, 1 + kIOFWAVCProtocolUserClientUpdateOutputPlug, // kIOUCScalarIScalarO 3, 0 + kIOFWAVCProtocolUserClientReadOutputMasterPlug, // kIOUCScalarIScalarO 0, 1 + kIOFWAVCProtocolUserClientUpdateOutputMasterPlug, // kIOUCScalarIScalarO 2, 0 + kIOFWAVCProtocolUserClientReadInputMasterPlug, // kIOUCScalarIScalarO 0, 1 + kIOFWAVCProtocolUserClientUpdateInputMasterPlug, // kIOUCScalarIScalarO 2, 0 + kIOFWAVCProtocolUserClientPublishAVCUnitDirectory, // kIOUCScalarIScalarO 0, 0 + kIOFWAVCProtocolUserClientSetSubunitPlugSignalFormat, // kIOUCScalarIScalarO 4, 0 + kIOFWAVCProtocolUserClientGetSubunitPlugSignalFormat, // kIOUCScalarIScalarO 3, 1 + kIOFWAVCProtocolUserClientConnectTargetPlugs, // kIOUCStructIStructO + kIOFWAVCProtocolUserClientDisconnectTargetPlugs, // kIOUCScalarIScalarO 6, 0 + kIOFWAVCProtocolUserClientGetTargetPlugConnection, // kIOUCStructIStructO + kIOFWAVCProtocolUserClientAVCRequestNotHandled, // kIOUCScalarIStructI 4, -1 + kIOFWAVCProtocolUserClientNumCommands +}; + +enum IOFWAVCProtocolUserClientAsyncCommandCodes { + kIOFWAVCProtocolUserClientSetAVCRequestCallback = kIOFWAVCProtocolUserClientNumCommands, // kIOUCScalarIScalarO 2, 0 + kIOFWAVCProtocolUserClientAllocateInputPlug, // kIOUCScalarIScalarO 1, 1 + kIOFWAVCProtocolUserClientAllocateOutputPlug, // kIOUCScalarIScalarO 1, 1 + kIOFWAVCProtocolUserClientInstallAVCCommandHandler, // kIOUCScalarIScalarO 4, 0 + kIOFWAVCProtocolUserClientAddSubunit, // kIOUCScalarIScalarO 5, 1 + kIOFWAVCProtocolUserClientNumAsyncCommands +}; + +typedef struct _AVCConnectTargetPlugsInParams +{ + UInt32 sourceSubunitTypeAndID; + IOFWAVCPlugTypes sourcePlugType; + UInt32 sourcePlugNum; + UInt32 destSubunitTypeAndID; + IOFWAVCPlugTypes destPlugType; + UInt32 destPlugNum; + Boolean lockConnection; + Boolean permConnection; +}AVCConnectTargetPlugsInParams; + +typedef struct _AVCConnectTargetPlugsOutParams +{ + UInt32 sourcePlugNum; + UInt32 destPlugNum; +}AVCConnectTargetPlugsOutParams; + +typedef struct _AVCGetTargetPlugConnectionInParams +{ + UInt32 subunitTypeAndID; + IOFWAVCPlugTypes plugType; + UInt32 plugNum; +}AVCGetTargetPlugConnectionInParams; + +typedef struct _AVCGetTargetPlugConnectionOutParams +{ + UInt32 connectedSubunitTypeAndID; + IOFWAVCPlugTypes connectedPlugType; + UInt32 connectedPlugNum; + Boolean lockConnection; + Boolean permConnection; +}AVCGetTargetPlugConnectionOutParams; + +#define kAsyncCmdSharedBufInterimRespOffset 0 +#define kAsyncCmdSharedBufFinalRespOffset 512 + +#endif // _IOKIT_IOFIREWIREAVCUSERCLIENTCOMMON_H_ \ No newline at end of file Index: branches/azimutz/Cleancut/i386/include/IOKit/avc/IOFireWirePCRSpace.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/avc/IOFireWirePCRSpace.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/avc/IOFireWirePCRSpace.h (revision 885) @@ -0,0 +1,202 @@ +/* + * Copyright (c) 2001 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@ + */ +/* + * + * IOFireWirePCRSpace.h + * + * Class to multiplex access to the PCR addresses. + */ +#ifndef _IOKIT_IOFIREWIREPCRSPACE_H +#define _IOKIT_IOFIREWIREPCRSPACE_H + +#include +#include + +/*! + @typedef IOFireWirePCRCallback + @abstract Callback called after a successful lock transaction to a plug. + @param refcon refcon supplied to the IOFireWireFCPSpace when a client is registered + @param nodeID is the node originating the request + @param plugNo is the plug number + @param oldVal is the value the plug used to contain + @param newVal is the quad written into the plug + + */ +typedef void (*IOFireWirePCRCallback)(void *refcon, UInt16 nodeID, UInt32 plug, UInt32 oldVal, UInt32 newVal); + +class IOFireWireBus; + +/*! + @class IOFireWirePCRSpace + @abstract object to multiplex users of the PCR plug registers +*/ +class IOFireWirePCRSpace : public IOFWPseudoAddressSpace +{ + OSDeclareDefaultStructors(IOFireWirePCRSpace) + +protected: + struct Client { + IOFireWirePCRCallback func; + void * refcon; + }; + UInt32 fBuf[64]; + + Client fClients[64]; + UInt32 fActivations; + IOFireWireAVCTargetSpace * fAVCTargetSpace; + IONotifier *fNotifier; + +/*! @struct ExpansionData + @discussion This structure will be used to expand the capablilties of the class in the future. + */ + struct ExpansionData { }; + +/*! @var reserved + Reserved for future use. (Internal use only) */ + ExpansionData *reserved; + + // Override to notify client of each plug seperately + virtual UInt32 doWrite(UInt16 nodeID, IOFWSpeed &speed, FWAddress addr, UInt32 len, + const void *buf, IOFWRequestRefCon refcon); + + virtual IOReturn allocatePlug(void *refcon, IOFireWirePCRCallback func, UInt32 &plug, Client* head); + virtual void freePlug(UInt32 plug, Client* head); + virtual UInt32 readPlug(UInt32 plug); + virtual IOReturn updatePlug(UInt32 plug, UInt32 oldVal, UInt32 newVal); + +public: + + // Override to handle multiple activations (one per client) + virtual IOReturn activate(); + virtual void deactivate(); + +/*! + @function init + @abstract initializes the IOFireWirePCRSpace object +*/ + virtual bool init(IOFireWireBus *bus); +/*! + @function getPCRAddressSpace + @abstract returns the IOFireWirePCRSpace object for the given FireWire bus + @param bus The FireWire bus +*/ + static IOFireWirePCRSpace *getPCRAddressSpace(IOFireWireBus *bus); +/*! + @function allocateInputPlug + @abstract allocates an input plug. + @param refcon arbitrary value passed back as first argument of callback. + @param func callback function when a successful lock transaction to the plug has been performed + @param plug set to the plug number if a plug is successfully allocated +*/ + virtual IOReturn allocateInputPlug(void *refcon, IOFireWirePCRCallback func, UInt32 &plug); +/*! + @function freeInputPlug + @abstract deallocates an input plug. + @param plug value returned by allocateInputPlug. +*/ + virtual void freeInputPlug(UInt32 plug); +/*! + @function readInputPlug + @abstract returns the current value of an input plug. + @param plug value returned by allocateInputPlug. +*/ + virtual UInt32 readInputPlug(UInt32 plug); +/*! + @function updateInputPlug + @abstract updates the value of an input plug (simulating a lock transaction). + @param plug value returned by allocateInputPlug. + @param oldVal value returned by readInputPlug. + @param newVal new value to store in plug if it's current value is oldVal. +*/ + virtual IOReturn updateInputPlug(UInt32 plug, UInt32 oldVal, UInt32 newVal); +/*! + @function allocateOutputPlug + @abstract allocates an output plug. + @param refcon arbitrary value passed back as first argument of callback. + @param func callback function when a successful lock transaction to the plug has been performed + @param plug set to the plug number if a plug is successfully allocated +*/ + virtual IOReturn allocateOutputPlug(void *refcon, IOFireWirePCRCallback func, UInt32 &plug); +/*! + @function freeOutputPlug + @abstract deallocates an output plug. + @param plug value returned by allocateOutputPlug. +*/ + virtual void freeOutputPlug(UInt32 plug); +/*! + @function readOutputPlug + @abstract returns the current value of an output plug. + @param plug value returned by allocateOutputPlug. +*/ + virtual UInt32 readOutputPlug(UInt32 plug); +/*! + @function updateOutputPlug + @abstract updates the value of an output plug (simulating a lock transaction). + @param plug value returned by allocateOutputPlug. + @param oldVal value returned by readOutputPlug. + @param newVal new value to store in plug if it's current value is oldVal. +*/ + virtual IOReturn updateOutputPlug(UInt32 plug, UInt32 oldVal, UInt32 newVal); +/*! + @function readOutputMasterPlug + @abstract returns the current value of the output master plug. +*/ + virtual UInt32 readOutputMasterPlug(); +/*! + @function updateOutputMasterPlug + @abstract updates the value of the master output plug (simulating a lock transaction). + @param oldVal value returned by readOutputMasterPlug. + @param newVal new value to store in plug if it's current value is oldVal. +*/ + virtual IOReturn updateOutputMasterPlug(UInt32 oldVal, UInt32 newVal); +/*! + @function readInputMasterPlug + @abstract returns the current value of the input master plug. +*/ + virtual UInt32 readInputMasterPlug(); +/*! + @function updateInputMasterPlug + @abstract updates the value of the master input plug (simulating a lock transaction). + @param oldVal value returned by readInputMasterPlug. + @param newVal new value to store in plug if it's current value is oldVal. +*/ + virtual IOReturn updateInputMasterPlug(UInt32 oldVal, UInt32 newVal); + + /*! + @function setAVCTargetSpacePointer + */ + virtual void setAVCTargetSpacePointer(IOFireWireAVCTargetSpace *pAVCTargetSpace); + + /*! + @function clearAllP2PConnections + */ + virtual void clearAllP2PConnections(void); + +private: + OSMetaClassDeclareReservedUnused(IOFireWirePCRSpace, 0); + OSMetaClassDeclareReservedUnused(IOFireWirePCRSpace, 1); + OSMetaClassDeclareReservedUnused(IOFireWirePCRSpace, 2); + OSMetaClassDeclareReservedUnused(IOFireWirePCRSpace, 3); + +}; + +#endif /* _IOKIT_IOFIREWIREPCRSPACE_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/avc/IOFireWireAVCConsts.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/avc/IOFireWireAVCConsts.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/avc/IOFireWireAVCConsts.h (revision 885) @@ -0,0 +1,259 @@ +/* + * Copyright (c) 1998-2001 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_IOFIREWIREAVCCONSTS_H +#define _IOKIT_IOFIREWIREAVCCONSTS_H + +// Fields of AVC frame +typedef enum { + kAVCCommandResponse = 0, + kAVCAddress = 1, + kAVCOpcode = 2, + kAVCOperand0 = 3, + kAVCOperand1 = 4, + kAVCOperand2 = 5, + kAVCOperand3 = 6, + kAVCOperand4 = 7, + kAVCOperand5 = 8, + kAVCOperand6 = 9, + kAVCOperand7 = 10, + kAVCOperand8 = 11 +} IOAVCFrameFields; + +// Command/Response values +typedef enum { + kAVCControlCommand = 0x00, + kAVCStatusInquiryCommand = 0x01, + kAVCSpecificInquiryCommand = 0x02, + kAVCNotifyCommand = 0x03, + kAVCGeneralInquiryCommand = 0x04, + kAVCNotImplementedStatus = 0x08, + kAVCAcceptedStatus = 0x09, + kAVCRejectedStatus = 0x0a, + kAVCInTransitionStatus = 0x0b, + kAVCImplementedStatus = 0x0c, + kAVCChangedStatus = 0x0d, + kAVCInterimStatus = 0x0f +} IOAVCCommandResponse; + +// Opcodes +typedef enum { + + // Unit commands + kAVCPlugInfoOpcode = 0x02, + kAVCOutputPlugSignalFormatOpcode = 0x18, + kAVCInputPlugSignalFormatOpcode = 0x19, + kAVCUnitInfoOpcode = 0x30, + kAVCSubunitInfoOpcode = 0x31, + kAVCConnectionsOpcode = 0x22, + kAVCConnectOpcode = 0x24, + kAVCDisconnectOpcode = 0x25, + kAVCPowerOpcode = 0xB2, + kAVCSignalSourceOpcode = 0x1A, + + // Vendor dependent commands + kAVCVendorDependentOpcode = 0x00, + + // Subunit commands + kAVCOutputSignalModeOpcode = 0x78, + kAVCInputSignalModeOpcode = 0x79, + kAVCSignalModeSD525_60 = 0x00, + kAVCSignalModeSDL525_60 = 0x04, + kAVCSignalModeHD1125_60 = 0x08, + kAVCSignalModeSD625_50 = 0x80, + kAVCSignalModeSDL625_50 = 0x84, + kAVCSignalModeHD1250_50 = 0x88, + kAVCSignalModeDVCPro525_60 = 0x78, + kAVCSignalModeDVCPro625_50 = 0xf8, + + kAVCSignalModeDummyOperand = 0xff, + kAVCSignalModeMask_50 = 0x80, + kAVCSignalModeMask_STYPE = 0x7c, + kAVCSignalModeMask_SDL = 0x04, + kAVCSignalModeMask_DVCPro25 = 0x78 + +} IOAVCOpcodes; + +// Unit/Subunit types +typedef enum { + kAVCVideoMonitor = 0x00, + kAVCAudio = 0x01, + kAVCPrinter = 0x02, + kAVCDiskRecorder = 0x03, + kAVCTapeRecorder = 0x04, + kAVCTuner = 0x05, + kAVCVideoCamera = 0x07, + kAVCCameraStorage = 0x0b, + kAVCVendorUnique = 0x1c, + kAVCNumSubUnitTypes = 0x20 +} IOAVCUnitTypes; + +#define kAVCAllOpcodes 0xFF +#define kAVCAllSubunitsAndUnit 0xEE +#define kAVCMaxNumPlugs 31 +#define kAVCAnyAvailableIsochPlug 0x7F +#define kAVCAnyAvailableExternalPlug 0xFF +#define kAVCAnyAvailableSubunitPlug 0xFF +#define kAVCMultiplePlugs 0xFD +#define kAVCInvalidPlug 0xFE + + +#define IOAVCAddress(type, id) (((type) << 3) | (id)) +#define kAVCUnitAddress 0xff +#define IOAVCType(address) ((address) >> 3) +#define IOAVCId(address) ((address) & 0x7) + +// Macros for Plug Control Register field manipulation + +// Master control registers +#define kIOFWPCRDataRate FWBitRange(0,1) +#define kIOFWPCRDataRatePhase FWBitRangePhase(0,1) +#define kIOFWPCRExtension FWBitRange(8,15) +#define kIOFWPCRExtensionPhase FWBitRangePhase(8,15) +#define kIOFWPCRNumPlugs FWBitRange(27,31) +#define kIOFWPCRNumPlugsPhase FWBitRangePhase(27,31) + +// master output register +#define kIOFWPCRBroadcastBase FWBitRange(2,7) +#define kIOFWPCRBroadcastBasePhase FWBitRangePhase(2,7) + +// plug registers +#define kIOFWPCROnline FWBitRange(0,0) +#define kIOFWPCROnlinePhase FWBitRangePhase(0,0) +#define kIOFWPCRBroadcast FWBitRange(1,1) +#define kIOFWPCRBroadcastPhase FWBitRangePhase(1,1) +#define kIOFWPCRP2PCount FWBitRange(2,7) +#define kIOFWPCRP2PCountPhase FWBitRangePhase(2,7) +#define kIOFWPCRChannel FWBitRange(10,15) +#define kIOFWPCRChannelPhase FWBitRangePhase(10,15) + +// Extra fields for output plug registers +#define kIOFWPCROutputDataRate FWBitRange(16,17) +#define kIOFWPCROutputDataRatePhase FWBitRangePhase(16,17) +#define kIOFWPCROutputOverhead FWBitRange(18,21) +#define kIOFWPCROutputOverheadPhase FWBitRangePhase(18,21) +#define kIOFWPCROutputPayload FWBitRange(22,31) +#define kIOFWPCROutputPayloadPhase FWBitRangePhase(22,31) + +// async plug numbers + +enum +{ + kFWAVCAsyncPlug0 = 0xa0, + kFWAVCAsyncPlug1 = 0xa1, + kFWAVCAsyncPlug2 = 0xa2, + kFWAVCAsyncPlug3 = 0xa3, + kFWAVCAsyncPlug4 = 0xa4, + kFWAVCAsyncPlug5 = 0xa5, + kFWAVCAsyncPlug6 = 0xa6, + kFWAVCAsyncPlug7 = 0xa7, + kFWAVCAsyncPlug8 = 0xa8, + kFWAVCAsyncPlug9 = 0xa9, + kFWAVCAsyncPlug10 = 0xa1, + kFWAVCAsyncPlug11 = 0xab, + kFWAVCAsyncPlug12 = 0xac, + kFWAVCAsyncPlug13 = 0xad, + kFWAVCAsyncPlug14 = 0xae, + kFWAVCAsyncPlug15 = 0xaf, + kFWAVCAsyncPlug16 = 0xb0, + kFWAVCAsyncPlug17 = 0xb1, + kFWAVCAsyncPlug18 = 0xb2, + kFWAVCAsyncPlug19 = 0xb3, + kFWAVCAsyncPlug20 = 0xb4, + kFWAVCAsyncPlug21 = 0xb5, + kFWAVCAsyncPlug22 = 0xb6, + kFWAVCAsyncPlug23 = 0xb7, + kFWAVCAsyncPlug24 = 0xb8, + kFWAVCAsyncPlug25 = 0xb9, + kFWAVCAsyncPlug26 = 0xba, + kFWAVCAsyncPlug27 = 0xbb, + kFWAVCAsyncPlug28 = 0xbc, + kFWAVCAsyncPlug29 = 0xbd, + kFWAVCAsyncPlug30 = 0xbe, + kFWAVCAsyncPlugAny = 0xbf +}; + +enum +{ + kFWAVCStateBusSuspended = 0, + kFWAVCStateBusResumed = 1, + kFWAVCStatePlugReconnected = 2, + kFWAVCStatePlugDisconnected = 3, + kFWAVCStateDeviceRemoved = 4 +}; + +enum +{ + kFWAVCConsumerMode_MORE = 1, + kFWAVCConsumerMode_LAST = 4, + kFWAVCConsumerMode_LESS = 5, + kFWAVCConsumerMode_JUNK = 6, + kFWAVCConsumerMode_LOST = 7 +}; + +enum +{ + kFWAVCProducerMode_SEND = 5, + kFWAVCProducerMode_TOSS = 7 +}; + + +typedef enum +{ + IOFWAVCPlugSubunitSourceType, + IOFWAVCPlugSubunitDestType, + IOFWAVCPlugIsochInputType, + IOFWAVCPlugIsochOutputType, + IOFWAVCPlugAsynchInputType, + IOFWAVCPlugAsynchOutputType, + IOFWAVCPlugExternalInputType, + IOFWAVCPlugExternalOutputType +} IOFWAVCPlugTypes; + +typedef enum +{ + kIOFWAVCSubunitPlugMsgConnected, + kIOFWAVCSubunitPlugMsgDisconnected, + kIOFWAVCSubunitPlugMsgConnectedPlugModified, + kIOFWAVCSubunitPlugMsgSignalFormatModified +} IOFWAVCSubunitPlugMessages; + +// Some plug signal formats +#define kAVCPlugSignalFormatNTSCDV 0x80000000 +#define kAVCPlugSignalFormatPalDV 0x80800000 +#define kAVCPlugSignalFormatMPEGTS 0xA0000000 + +// Possible states of an AVCAsynchronousCommand +typedef enum +{ + kAVCAsyncCommandStatePendingRequest, + kAVCAsyncCommandStateRequestSent, + kAVCAsyncCommandStateRequestFailed, + kAVCAsyncCommandStateWaitingForResponse, + kAVCAsyncCommandStateReceivedInterimResponse, + kAVCAsyncCommandStateReceivedFinalResponse, + kAVCAsyncCommandStateTimeOutBeforeResponse, + kAVCAsyncCommandStateBusReset, + kAVCAsyncCommandStateOutOfMemory, + kAVCAsyncCommandStateCanceled +} IOFWAVCAsyncCommandState; + +#endif // _IOKIT_IOFIREWIREAVCCONSTS_H Index: branches/azimutz/Cleancut/i386/include/IOKit/IOKitDebug.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/IOKitDebug.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/IOKitDebug.h (revision 885) @@ -0,0 +1,111 @@ +/* + * 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_IOKITDEBUG_H +#define _IOKIT_IOKITDEBUG_H + +#include + + +#ifdef __cplusplus + +#include +#include +#include + +class IOKitDiagnostics : public OSObject +{ + OSDeclareDefaultStructors(IOKitDiagnostics) + +public: + static OSObject * diagnostics( void ); + virtual bool serialize(OSSerialize *s) const; +private: + static void updateOffset( OSDictionary * dict, + UInt32 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, + 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, + kIOLogHibernate = 0x00100000ULL, + + // debug aids - change behaviour + kIONoFreeObjects = 0x00100000ULL, + kIOLogSynchronous = 0x00200000ULL, // IOLog completes synchronously + kOSTraceObjectAlloc = 0x00400000ULL, + + _kIODebugTopFlag = 0x8000000000000000ULL // force enum to be 64 bits +}; + +extern SInt64 gIOKitDebug; + +#ifdef __cplusplus +extern "C" { +#endif + +struct IORegistryPlane; +extern void IOPrintPlane( const struct IORegistryPlane * plane ); +#ifndef _OSCPPDEBUG_H +extern void OSPrintMemory( void ); +#endif +#define IOPrintMemory OSPrintMemory + +#ifdef __cplusplus +} /* extern "C" */ +#endif /* __cplusplus */ + +#endif /* ! _IOKIT_IOKITDEBUG_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/acpi/IOACPIPlatformDevice.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/acpi/IOACPIPlatformDevice.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/acpi/IOACPIPlatformDevice.h (revision 885) @@ -0,0 +1,254 @@ +/* + * Copyright (c) 2003-2005 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_IOACPIPLATFORMDEVICE_H +#define _IOKIT_IOACPIPLATFORMDEVICE_H + +#include +#include +#include + +class IOACPIPlatformExpert; + +class IOACPIPlatformDevice : public IOPlatformDevice +{ + OSDeclareDefaultStructors( IOACPIPlatformDevice ) + +protected: + void * _deviceHandle; + UInt32 _deviceType; + UInt32 _powerFlags; + UInt32 * _powerStateFlags; + UInt32 _sleepPowerState; + IOService * _acpiParent; + IOACPIPlatformExpert * _platform; + + /*! @struct ExpansionData + @discussion This structure will be used to expand the capablilties + of the class in the future. + */ + struct ExpansionData { }; + + /*! @var reserved + Reserved for future use. (Internal use only) + */ + ExpansionData * reserved; + + virtual bool initACPIPowerManagement( IOService * powerParent ); + virtual void stopACPIPowerManagement( IOService * powerParent ); + +public: + virtual bool init( IOService * platform, + void * handle, + OSDictionary * properties ); + + virtual void free( void ); + + virtual bool attachToParent( IORegistryEntry * parent, + const IORegistryPlane * plane ); + + virtual void detachFromParent( IORegistryEntry * parent, + const IORegistryPlane * plane ); + + virtual bool getPathComponent( char * path, int * length, + const IORegistryPlane * plane ) const; + + virtual bool compareName( OSString * name, + OSString ** matched ) const; + + virtual IOReturn getResources( void ); + + virtual void * getDeviceHandle( void ) const; + + virtual UInt32 getDeviceStatus( void ) const; + + enum { + kTypeDevice = 0, + kTypeProcessor = 1, + kTypePowerResource = 2 + }; + + virtual UInt32 getDeviceType( void ) const; + + virtual void setDeviceType( UInt32 deviceType ); + + // Method (object) evaluation + + virtual IOReturn validateObject( const OSSymbol * objectName ); + + virtual IOReturn validateObject( const char * objectName ); + + virtual IOReturn evaluateObject( const OSSymbol * objectName, + OSObject ** result = 0, + OSObject * params[] = 0, + IOItemCount paramCount = 0, + IOOptionBits options = 0 ); + + virtual IOReturn evaluateObject( const char * objectName, + OSObject ** result = 0, + OSObject * params[] = 0, + IOItemCount paramCount = 0, + IOOptionBits options = 0 ); + + virtual IOReturn evaluateInteger( const OSSymbol * objectName, + UInt32 * resultInt32, + OSObject * params[] = 0, + IOItemCount paramCount = 0, + IOOptionBits options = 0 ); + + virtual IOReturn evaluateInteger( const char * objectName, + UInt32 * resultInt32, + OSObject * params[] = 0, + IOItemCount paramCount = 0, + IOOptionBits options = 0 ); + + virtual IOReturn evaluateInteger( const OSSymbol * objectName, + UInt64 * resultInt64, + OSObject * params[] = 0, + IOItemCount paramCount = 0, + IOOptionBits options = 0 ); + + virtual IOReturn evaluateInteger( const char * objectName, + UInt64 * resultInt64, + OSObject * params[] = 0, + IOItemCount paramCount = 0, + IOOptionBits options = 0 ); + + // ACPI table access + + virtual const OSData * getACPITableData( const char * tableName, + UInt32 tableInstance = 0 ) const; + + // Map ACPI event to interrupt event source index + + virtual SInt32 installInterruptForFixedEvent( UInt32 fixedEvent ); + + virtual SInt32 installInterruptForGPE( UInt32 gpeNumber, + void * gpeBlockDevice = 0, + IOOptionBits options = 0 ); + + // ACPI global lock acquire/release + + virtual IOReturn acquireGlobalLock( UInt32 * lockToken, + const mach_timespec_t * timeout = 0 ); + + virtual void releaseGlobalLock( UInt32 lockToken ); + + // Address space handler registration + + virtual IOReturn registerAddressSpaceHandler( + IOACPIAddressSpaceID spaceID, + IOACPIAddressSpaceHandler handler, + void * context, + IOOptionBits options = 0 ); + + virtual void unregisterAddressSpaceHandler( + IOACPIAddressSpaceID spaceID, + IOACPIAddressSpaceHandler handler, + IOOptionBits options = 0 ); + + // Address space access + + virtual IOReturn readAddressSpace( UInt64 * value, + IOACPIAddressSpaceID spaceID, + IOACPIAddress address, + UInt32 bitWidth, + UInt32 bitOffset = 0, + IOOptionBits options = 0 ); + + virtual IOReturn writeAddressSpace( UInt64 value, + IOACPIAddressSpaceID spaceID, + IOACPIAddress address, + UInt32 bitWidth, + UInt32 bitOffset = 0, + IOOptionBits options = 0 ); + + // Power management + + virtual bool hasSystemWakeCapability( void ) const; + + virtual IOReturn setSystemWakeCapabilityEnable( bool enable ); + + virtual bool hasACPIPowerStateSupport( UInt32 powerState ) const; + + virtual IOReturn setACPIPowerManagementEnable( + bool enable, + UInt32 powerState = kIOACPIDevicePowerStateD3, + IOOptionBits options = 0 ); + + virtual IOReturn setPowerState( unsigned long powerState, + IOService * whatDevice ); + + // I/O space helpers + + virtual void ioWrite32( UInt16 offset, UInt32 value, + IOMemoryMap * map = 0 ); + + virtual void ioWrite16( UInt16 offset, UInt16 value, + IOMemoryMap * map = 0 ); + + virtual void ioWrite8( UInt16 offset, UInt8 value, + IOMemoryMap * map = 0 ); + + virtual UInt32 ioRead32( UInt16 offset, IOMemoryMap * map = 0 ); + + virtual UInt16 ioRead16( UInt16 offset, IOMemoryMap * map = 0 ); + + virtual UInt8 ioRead8( UInt16 offset, IOMemoryMap * map = 0 ); + + // vtable padding + + OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 0 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 1 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 2 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 3 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 4 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 5 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 6 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 7 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 8 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 9 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 10 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 11 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 12 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 13 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 14 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 15 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 16 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 17 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 18 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 19 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 20 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 21 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 22 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 23 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 24 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 25 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 26 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 27 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 28 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 29 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 30 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 31 ); +}; + +#endif /* !_IOKIT_IOACPIPLATFORMDEVICE_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/acpi/IOACPITypes.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/acpi/IOACPITypes.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/acpi/IOACPITypes.h (revision 885) @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2003-2005 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_IOACPITYPES_H +#define __IOKIT_IOACPITYPES_H + +#include + +extern const IORegistryPlane * gIOACPIPlane; +extern const OSSymbol * gIOACPIHardwareIDKey; +extern const OSSymbol * gIOACPIUniqueIDKey; +extern const OSSymbol * gIOACPIAddressKey; +extern const OSSymbol * gIOACPIDeviceStatusKey; + +#pragma pack(1) + +struct IOACPIAddressSpaceDescriptor { + UInt32 resourceType; + UInt32 generalFlags; + UInt32 typeSpecificFlags; + UInt32 reserved1; + UInt64 granularity; + UInt64 minAddressRange; + UInt64 maxAddressRange; + UInt64 translationOffset; + UInt64 addressLength; + UInt64 reserved2; + UInt64 reserved3; + UInt64 reserved4; +}; + +enum { + kIOACPIMemoryRange = 0, + kIOACPIIORange = 1, + kIOACPIBusNumberRange = 2 +}; + +typedef UInt32 IOACPIAddressSpaceID; + +enum { + kIOACPIAddressSpaceIDSystemMemory = 0, + kIOACPIAddressSpaceIDSystemIO = 1, + kIOACPIAddressSpaceIDPCIConfiguration = 2, + kIOACPIAddressSpaceIDEmbeddedController = 3, + kIOACPIAddressSpaceIDSMBus = 4 +}; + +/* + * Address space operation + */ +enum { + kIOACPIAddressSpaceOpRead = 0, + kIOACPIAddressSpaceOpWrite = 1 +}; + +/* + * 64-bit ACPI address + */ +union IOACPIAddress { + UInt64 addr64; + struct { + unsigned int offset :16; + unsigned int function :3; + unsigned int device :5; + unsigned int bus :8; + unsigned int segment :16; + unsigned int reserved :16; + } pci; +}; + +/* + * Address space handler + */ +typedef IOReturn (*IOACPIAddressSpaceHandler)( UInt32 operation, + IOACPIAddress address, + UInt64 * value, + UInt32 bitWidth, + UInt32 bitOffset, + void * context ); + +/* + * ACPI fixed event types + */ +enum { + kIOACPIFixedEventPMTimer = 0, + kIOACPIFixedEventPowerButton = 2, + kIOACPIFixedEventSleepButton = 3, + kIOACPIFixedEventRealTimeClock = 4 +}; + +#pragma pack() + +/* + * FIXME: Move to xnu/iokit to reserve the ACPI family code. + */ +#ifndef sub_iokit_acpi +#define sub_iokit_acpi err_sub(10) +#endif + +/* + * ACPI notify message sent to all clients and interested parties. + * The notify code can be read from the argument as an UInt32. + */ +#define kIOACPIMessageDeviceNotification iokit_family_msg(sub_iokit_acpi, 0x10) + +/* + * ACPI device power states + */ +enum { + kIOACPIDevicePowerStateD0 = 0, + kIOACPIDevicePowerStateD1 = 1, + kIOACPIDevicePowerStateD2 = 2, + kIOACPIDevicePowerStateD3 = 3, + kIOACPIDevicePowerStateCount = 4 +}; + +#endif /* !__IOKIT_IOACPITYPES_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/acpi/IOACPIPlatformExpert.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/acpi/IOACPIPlatformExpert.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/acpi/IOACPIPlatformExpert.h (revision 885) @@ -0,0 +1,178 @@ +/* + * Copyright (c) 2003-2005 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_IOACPIPLATFORMEXPERT_H +#define _IOKIT_IOACPIPLATFORMEXPERT_H + +#include // superclass +#include // children + +class IOACPIPlatformExpert : public IODTPlatformExpert +{ + OSDeclareAbstractStructors( IOACPIPlatformExpert ) + + friend class IOACPIPlatformDevice; + +protected: + /*! @struct ExpansionData + @discussion This structure will be used to expand the capablilties + of the class in the future. + */ + struct ExpansionData { }; + + /*! @var reserved + Reserved for future use. (Internal use only) + */ + ExpansionData * reserved; + +public: + virtual bool start( IOService * provider ); + +protected: + // Map ACPI event to interrupt event source index + + virtual SInt32 installDeviceInterruptForFixedEvent( + IOService * device, + UInt32 fixedEvent ) = 0; + + virtual SInt32 installDeviceInterruptForGPE( + IOService * device, + UInt32 gpeNumber, + void * gpeBlockDevice, + IOOptionBits options ) = 0; + + // ACPI global lock acquisition + + virtual IOReturn acquireGlobalLock( IOService * client, + UInt32 * lockToken, + const mach_timespec_t * timeout ) = 0; + + virtual void releaseGlobalLock( IOService * client, + UInt32 lockToken ) = 0; + + // ACPI method and object evaluation + + virtual IOReturn validateObject( IOACPIPlatformDevice * device, + const OSSymbol * objectName ) = 0; + + virtual IOReturn validateObject( IOACPIPlatformDevice * device, + const char * objectName ); + + virtual IOReturn evaluateObject( IOACPIPlatformDevice * device, + const OSSymbol * objectName, + OSObject ** result, + OSObject * params[], + IOItemCount paramCount, + IOOptionBits options ) = 0; + + virtual IOReturn evaluateObject( IOACPIPlatformDevice * device, + const char * objectName, + OSObject ** result, + OSObject * params[], + IOItemCount paramCount, + IOOptionBits options ); + + // ACPI table + + virtual const OSData * getACPITableData( + const char * tableName, + UInt32 tableInstance ) = 0; + + // Address space handler + + virtual IOReturn registerAddressSpaceHandler( + IOACPIPlatformDevice * device, + IOACPIAddressSpaceID spaceID, + IOACPIAddressSpaceHandler handler, + void * context, + IOOptionBits options ) = 0; + + virtual void unregisterAddressSpaceHandler( + IOACPIPlatformDevice * device, + IOACPIAddressSpaceID spaceID, + IOACPIAddressSpaceHandler handler, + IOOptionBits options ) = 0; + + // Address space read/write + + virtual IOReturn readAddressSpace( UInt64 * value, + IOACPIAddressSpaceID spaceID, + IOACPIAddress address, + UInt32 bitWidth, + UInt32 bitOffset, + IOOptionBits options ) = 0; + + virtual IOReturn writeAddressSpace( UInt64 value, + IOACPIAddressSpaceID spaceID, + IOACPIAddress address, + UInt32 bitWidth, + UInt32 bitOffset, + IOOptionBits options ) = 0; + + // Device power management + + virtual IOReturn setDevicePowerState( IOACPIPlatformDevice * device, + UInt32 powerState ) = 0; + + virtual IOReturn getDevicePowerState( IOACPIPlatformDevice * device, + UInt32 * powerState ) = 0; + + virtual IOReturn setDeviceWakeEnable( IOACPIPlatformDevice * device, + bool enable ) = 0; + + // vtable padding + + OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 0 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 1 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 2 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 3 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 4 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 5 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 6 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 7 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 8 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 9 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 10 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 11 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 12 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 13 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 14 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 15 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 16 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 17 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 18 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 19 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 20 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 21 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 22 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 23 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 24 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 25 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 26 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 27 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 28 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 29 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 30 ); + OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 31 ); +}; + +#endif /* !_IOKIT_IOACPIPLATFORMEXPERT_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWCommand.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWCommand.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWCommand.h (revision 885) @@ -0,0 +1,977 @@ +/* + * Copyright (c) 1998-2002 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@ + */ +/* + * + * IOFWCommand.h + * + */ +#ifndef _IOKIT_IOFWCOMMAND_H +#define _IOKIT_IOFWCOMMAND_H + +#include +#include + +#include + +#include + +#define kFWCmdDefaultRetries 3 +#define kFWCmdZeroRetries 0 +#define kFWCmdReducedRetries 2 +#define kFWCmdIncreasedRetries 6 + +class IOMemoryDescriptor; +class IOSyncer; +class IOFireWireBus; +class IOFireWireController; +class IOFireWireNub; +class IOFWAddressSpace; // Description of chunk of local FW address space +class IOFWCommand; +class IOFWBusCommand; +class IOFWAsyncStreamCommand; +class IOCommandGate; +class IOFWAsyncPHYCommand; + +struct AsyncPendingTrans; + +// Struct for head of command queue +/*! + @struct IOFWCmdQ + @abstract Structure for head of a queue of IOFWCommands + @field fHead Points to the head of the queue, or NULL if queue is empty + @field fTail Points to the tail of the queue, or NULL if queue is empty + @function headChanged called when head command is changed, or the command + itself changes state. +*/ + +struct IOFWCmdQ +{ + IOFWCommand *fHead; + IOFWCommand *fTail; + bool executeQueue(bool all); + virtual void headChanged(IOFWCommand *oldHead); + + virtual ~IOFWCmdQ() {} + + void checkProgress( void ); +}; + +// Callback when device command completes asynchronously +typedef void (*FWDeviceCallback)(void *refcon, IOReturn status, IOFireWireNub *device, IOFWCommand *fwCmd); + +// Callback when bus command completes asynchronously +typedef void (*FWBusCallback)(void *refcon, IOReturn status, IOFireWireBus *bus, IOFWBusCommand *fwCmd); + +// Callback when async stream command completes asynchronously +typedef void (*FWAsyncStreamCallback)(void *refcon, IOReturn status, IOFireWireBus *bus, IOFWAsyncStreamCommand *fwCmd); + +// Callback when async stream command completes asynchronously +typedef void (*FWAsyncPHYCallback)(void *refcon, IOReturn status, IOFireWireBus *bus, IOFWAsyncPHYCommand *fwCmd ); + +// Callback when async stream packet is received +typedef void (*FWAsyncStreamReceiveCallback)(void *refcon, const void *buf); + +#pragma mark - + +/* + * Base class for FireWire commands + */ +/*! @class IOFWCommand +*/ +class IOFWCommand : public IOCommand +{ + OSDeclareAbstractStructors(IOFWCommand) + +protected: + IOReturn fStatus; + IOFireWireController *fControl; + IOFWCommand * fQueuePrev; + IOFWCommand * fQueueNext; + IOFWCmdQ * fQueue; + UInt32 fTimeout; // How long (in microsecs) after execute() to timeout + AbsoluteTime fDeadline; // Time after which this command has timed out. + IOFWSyncer * fSyncWakeup; + UInt8 fSync; + UInt8 fCancelOnReset; + UInt8 spare[2]; + +/*! @struct ExpansionData + @discussion This structure will be used to expand the capablilties of the class in the future. + */ + struct MemberVariables + { + void * fFWIMRefCon; + IOReturn fCompletionStatus; + bool fSubmitTimeLatched; + AbsoluteTime fSubmitTime; + bool fFlush; + }; + +/*! @var reserved + Reserved for future use. (Internal use only) */ + MemberVariables * fMembers; + + virtual IOReturn complete(IOReturn status); + virtual void updateTimer(); + virtual IOReturn startExecution(); + + /* + * Execute the FWCommand immediately + * must be called with the workloop gate closed + */ + virtual IOReturn execute() = 0; + +public: + + virtual bool initWithController(IOFireWireController *control); + virtual void free( void ); + + IOReturn getStatus() const { return fStatus; }; + + /* + * Submit the FWCommand. + * if queue is false the command's execute() + * method will be called on the caller's thread, otherwise + * the command wil be queued for execution on the work loop thread. + */ + virtual IOReturn submit(bool queue = false); + + /* + * Cancel command, causes it to complete with given status + */ + virtual IOReturn cancel(IOReturn reason); + + /*! + @function setHead + inserts a command at the head of a queue. + @param queue queue command is being added to + */ + virtual void setHead(IOFWCmdQ &queue); + /*! + @function insertAfter + inserts a command after the specified one. + @param prev command to insert after + @param queue queue command is being added to + */ + virtual void insertAfter(IOFWCommand &prev); + + /*! + @function removeFromQ + Removes command from current queue. + */ + virtual void removeFromQ(); + + IOFWCommand *getPrevious() const + { return fQueuePrev; }; + IOFWCommand *getNext() const + { return fQueueNext; }; + const AbsoluteTime &getDeadline() const + { return fDeadline; }; + + bool cancelOnReset() const + { return fCancelOnReset; }; + + bool Busy() const + { return fStatus == kIOReturnBusy || fStatus == kIOFireWirePending;}; + + void setTimeout( UInt32 timeout ) + { fTimeout = timeout; }; + + friend class IOFWCmdQ; + + void * getFWIMRefCon( void ) + { + return fMembers->fFWIMRefCon; + } + + void setFWIMRefCon( void * refcon ) + { + fMembers->fFWIMRefCon = refcon; + } + + void setFlush( bool flush ) + { + fMembers->fFlush = flush; + } + + virtual IOReturn checkProgress( void ); + +private: + OSMetaClassDeclareReservedUsed(IOFWCommand, 0); + OSMetaClassDeclareReservedUnused(IOFWCommand, 1); + +}; + +#pragma mark - + +/* + * Bus control commands + */ +/*! @class IOFWBusCommand +*/ +class IOFWBusCommand : public IOFWCommand +{ + OSDeclareAbstractStructors(IOFWBusCommand) + +protected: + FWBusCallback fComplete; + void * fRefCon; + +/*! @struct ExpansionData + @discussion This structure will be used to expand the capablilties of the class in the future. + */ + struct ExpansionData { }; + +/*! @var reserved + Reserved for future use. (Internal use only) */ + ExpansionData *reserved; + + virtual IOReturn complete(IOReturn status); + + virtual bool initWithController(IOFireWireController *control, + FWBusCallback completion=NULL, void *refcon=NULL); + virtual IOReturn reinit(FWBusCallback completion, void *refcon); + +private: + OSMetaClassDeclareReservedUnused(IOFWBusCommand, 0); + +}; + +#pragma mark - + +/* + * Command to execute some code after a specified delay (in microseconds) + * All it does is timeout after the specified delay, hence calling the completion + * callback. + */ +/*! @class IOFWDelayCommand +*/ +class IOFWDelayCommand : public IOFWBusCommand +{ + OSDeclareDefaultStructors(IOFWDelayCommand) + +/*! @struct ExpansionData + @discussion This structure will be used to expand the capablilties of the class in the future. + */ + struct ExpansionData { }; + +/*! @var reserved + Reserved for future use. (Internal use only) */ + ExpansionData *reserved; + +protected: + virtual IOReturn execute(); + +public: + virtual bool initWithDelay(IOFireWireController *control, UInt32 uSecs, + FWBusCallback completion, void *refcon); + virtual IOReturn reinit(UInt32 uSecs, FWBusCallback completion, void *refcon); + +private: + OSMetaClassDeclareReservedUnused(IOFWDelayCommand, 0); + +}; + +/* + * Send an async request to a device + */ +class IOFWUserReadQuadletCommand ; +class IOFWUserWriteCommand ; + +#pragma mark - + +/*! @class IOFWAsyncCommand +*/ +class IOFWAsyncCommand : public IOFWCommand +{ + OSDeclareAbstractStructors(IOFWAsyncCommand) + +protected: + IOFireWireNub * fDevice; + FWDeviceCallback fComplete; + void * fRefCon; + IOMemoryDescriptor *fMemDesc; + AsyncPendingTrans * fTrans; + UInt32 fAddressHi; + UInt32 fAddressLo; + IOByteCount fBytesTransferred; + int fSize; + int fSpeed; + int fMaxPack; + int fCurRetries; + int fMaxRetries; + UInt32 fGeneration; // bus topology fNodeID is valid for. + UInt16 fNodeID; + bool fFailOnReset; + bool fWrite; + + typedef struct + { + // some of our subclasses didn't have room for expansion data, so + // we've reserved space for their use here. + + void * fSubclassMembers; + int fMaxSpeed; + int fAckCode; + UInt32 fResponseCode; + UInt32 fFastRetryCount; + int fResponseSpeed; + bool fForceBlockRequests; + } + MemberVariables; + + MemberVariables * fMembers; + + virtual IOReturn complete(IOReturn status); + virtual bool initWithController(IOFireWireController *control); + virtual bool initAll(IOFireWireNub *device, FWAddress devAddress, + IOMemoryDescriptor *hostMem, + FWDeviceCallback completion, void *refcon, bool failOnReset); + virtual bool initAll(IOFireWireController *control, + UInt32 generation, FWAddress devAddress, + IOMemoryDescriptor *hostMem, + FWDeviceCallback completion, void *refcon); + virtual void free( void ); + virtual IOReturn reinit(FWAddress devAddress, IOMemoryDescriptor *hostMem, + FWDeviceCallback completion, void *refcon, bool failOnReset); + virtual IOReturn reinit(UInt32 generation, FWAddress devAddress, IOMemoryDescriptor *hostMem, + FWDeviceCallback completion, void *refcon); + bool createMemberVariables( void ); + void destroyMemberVariables( void ); +public: + // Utility for setting generation on newly created command + virtual void setGeneration(UInt32 generation) + { fGeneration = generation; } + + // To be called by IOFireWireController and derived classes. + virtual void gotPacket(int rcode, const void* data, int size) = 0; + virtual void gotAck(int ackCode); + + // update nodeID/generation after bus reset, from the device object + IOReturn updateGeneration(); + // explicitly update nodeID/generation after bus reset + IOReturn updateNodeID(UInt32 generation, UInt16 nodeID); + + // Generally useful stuff + IOByteCount getBytesTransferred() const + { return fBytesTransferred; }; + + FWAddress getAddress() const + { return FWAddress(fAddressHi, fAddressLo, fNodeID); } + + bool failOnReset() const + { return fFailOnReset; } + + IOFireWireNub * getDevice() const + { return fDevice; } + + /*! + @function setMaxPacket + Sets the maximum size for block transfers used by the command. + The command is initialized to use the maximum packet size calculated from the device's + PHY speed, bus info block and the bus topology. + Call this method before calling submit(). + @param maxBytes Maximum packet size in bytes. If the maxsize is 4 then quadlet transfers will be used. + */ + IOReturn setMaxPacket(UInt32 maxBytes) + { + if(fStatus == kIOReturnBusy || fStatus == kIOFireWirePending) + return fStatus; + fMaxPack = maxBytes; + return kIOReturnSuccess; + } + + void setMaxSpeed( int speed ); + + void setAckCode( int ack ); + int getAckCode( void ); + + void setRetries( int retries); + int getMaxRetries( void ); + + void setResponseCode( UInt32 rcode ); + UInt32 getResponseCode( void ) const; + + void setFastRetryCount( UInt32 count ) + { fMembers->fFastRetryCount = count; }; + + UInt32 getFastRetryCount( void ) + { return fMembers->fFastRetryCount; }; + + void setResponseSpeed( int speed ) + { fMembers->fResponseSpeed = speed; }; + + int getResponseSpeed( void ) + { return fMembers->fResponseSpeed; }; + + // forces even 4 byte transactions to be block requests + void setForceBlockRequests( bool enabled ) + { fMembers->fForceBlockRequests = enabled; } + + virtual IOReturn checkProgress( void ); + +private: + OSMetaClassDeclareReservedUnused(IOFWAsyncCommand, 0); + OSMetaClassDeclareReservedUnused(IOFWAsyncCommand, 1); + OSMetaClassDeclareReservedUnused(IOFWAsyncCommand, 2); + OSMetaClassDeclareReservedUnused(IOFWAsyncCommand, 3); + +}; + +#pragma mark - + +/* + * Concrete async requests - read, write and hordes of read/modify/write + */ +class IOFWReadCommand : public IOFWAsyncCommand +{ + OSDeclareDefaultStructors(IOFWReadCommand) + +protected: + + virtual void gotPacket(int rcode, const void* data, int size); + + virtual IOReturn execute(); + +public: + virtual bool initAll(IOFireWireNub *device, FWAddress devAddress, + IOMemoryDescriptor *hostMem, + FWDeviceCallback completion, void *refcon, bool failOnReset); + virtual bool initAll(IOFireWireController *control, + UInt32 generation, FWAddress devAddress, + IOMemoryDescriptor *hostMem, + FWDeviceCallback completion, void *refcon); + virtual IOReturn reinit(FWAddress devAddress, IOMemoryDescriptor *hostMem, + FWDeviceCallback completion=NULL, void *refcon=NULL, + bool failOnReset=false); + virtual IOReturn reinit(UInt32 generation, FWAddress devAddress, IOMemoryDescriptor *hostMem, + FWDeviceCallback completion=NULL, void *refcon=NULL); + +private: + OSMetaClassDeclareReservedUnused(IOFWReadCommand, 0); + OSMetaClassDeclareReservedUnused(IOFWReadCommand, 1); +}; + +#pragma mark - + +/*! + @class IOFWReadQuadCommand + @discussion An easier to use version of IOFWReadCommand for use when the data to be transferred + is an integer number of quads. + Note that block read requests will be used for transfers greater than one quad unless setMaxPacket(4) + is called. +*/ + +class IOFWReadQuadCommand : public IOFWAsyncCommand +{ + OSDeclareDefaultStructors(IOFWReadQuadCommand) + +protected: + + UInt32 * fQuads; + + typedef struct + { + bool fPingTime; + } + MemberVariables; + + bool createMemberVariables( void ); + void destroyMemberVariables( void ); + virtual void free( void ); + + virtual void gotPacket(int rcode, const void* data, int size); + + virtual IOReturn execute(); + +public: + virtual bool initAll(IOFireWireNub *device, FWAddress devAddress, + UInt32 *quads, int numQuads, + FWDeviceCallback completion, void *refcon, bool failOnReset); + + virtual bool initAll(IOFireWireController *control, + UInt32 generation, FWAddress devAddress, + UInt32 *quads, int numQuads, + FWDeviceCallback completion, void *refcon); + + virtual IOReturn reinit(FWAddress devAddress, UInt32 *quads, int numQuads, + FWDeviceCallback completion=NULL, void *refcon=NULL, + bool failOnReset=false); + + virtual IOReturn reinit(UInt32 generation, FWAddress devAddress, UInt32 *quads, int numQuads, + FWDeviceCallback completion=NULL, void *refcon=NULL); + + void setPingTime( bool state ) + { ((MemberVariables*)fMembers->fSubclassMembers)->fPingTime = state; }; + +private: + OSMetaClassDeclareReservedUnused(IOFWReadQuadCommand, 0); + OSMetaClassDeclareReservedUnused(IOFWReadQuadCommand, 1); +}; + +#pragma mark - + +class IOFWWriteCommand : public IOFWAsyncCommand +{ + + OSDeclareDefaultStructors(IOFWWriteCommand) + +protected: + + int fPackSize; + + typedef struct + { + bool fDeferredNotify; + bool fFastRetryOnBusy; + } + MemberVariables; + + virtual IOReturn execute(); + + virtual void gotPacket( int rcode, const void* data, int size ); + + bool createMemberVariables( void ); + void destroyMemberVariables( void ); + +public: + + virtual bool initWithController(IOFireWireController *control); + virtual bool initAll( IOFireWireNub * device, + FWAddress devAddress, + IOMemoryDescriptor * hostMem, + FWDeviceCallback completion, + void * refcon, + bool failOnReset ); + + virtual bool initAll( IOFireWireController * control, + UInt32 generation, + FWAddress devAddress, + IOMemoryDescriptor * hostMem, + FWDeviceCallback completion, + void * refcon ); + virtual void free( void ); + + virtual IOReturn reinit( FWAddress devAddress, + IOMemoryDescriptor * hostMem, + FWDeviceCallback completion = NULL, + void * refcon = NULL, + bool failOnReset = false ); + + virtual IOReturn reinit( UInt32 generation, + FWAddress devAddress, + IOMemoryDescriptor * hostMem, + FWDeviceCallback completion = NULL, + void * refcon = NULL ); + + void setDeferredNotify( bool state ) + { ((MemberVariables*)fMembers->fSubclassMembers)->fDeferredNotify = state; }; + + void setFastRetryOnBusy( bool state ) + { ((MemberVariables*)fMembers->fSubclassMembers)->fFastRetryOnBusy = state; }; + +private: + + OSMetaClassDeclareReservedUnused(IOFWWriteCommand, 0); + OSMetaClassDeclareReservedUnused(IOFWWriteCommand, 1); + +}; + +#pragma mark - + +/*! + @class IOFWWriteQuadCommand + @discussion An easier to use version of IOFWWriteCommand for use when the data to be transferred + is small and an integer number of quads. + Note that block read requests will be used for transfers greater than one quad unless setMaxPacket(4) + is called. + kMaxWriteQuads is the largest legal number of quads that this object can be asked to transfer + (the data is copied into an internal buffer in init() and reinit()). +*/ + +class IOFWWriteQuadCommand : public IOFWAsyncCommand +{ + + OSDeclareDefaultStructors(IOFWWriteQuadCommand) + +public: + + enum + { + kMaxWriteQuads = 8 + }; + +protected: + + UInt32 fQuads[kMaxWriteQuads]; + UInt32 * fQPtr; + int fPackSize; + + typedef struct + { + bool fDeferredNotify; + IOMemoryDescriptor * fMemory; + } + MemberVariables; + + virtual void gotPacket( int rcode, const void* data, int size ); + + virtual IOReturn execute(); + + bool createMemberVariables( void ); + void destroyMemberVariables( void ); + +public: + virtual bool initWithController(IOFireWireController *control); + + virtual bool initAll( IOFireWireNub * device, + FWAddress devAddress, + UInt32 * quads, + int numQuads, + FWDeviceCallback completion, + void * refcon, + bool failOnReset ); + + virtual bool initAll( IOFireWireController * control, + UInt32 generation, + FWAddress devAddress, + UInt32 * quads, + int numQuads, + FWDeviceCallback completion, + void * refcon ); + + virtual void free( void ); + + virtual IOReturn reinit( FWAddress devAddress, + UInt32 * quads, + int numQuads, + FWDeviceCallback completion = NULL, + void * refcon = NULL, + bool failOnReset = false ); + + virtual IOReturn reinit( UInt32 generation, + FWAddress devAddress, + UInt32 * quads, + int numQuads, + FWDeviceCallback completion = NULL, + void * refcon = NULL ); + +protected: + + void setQuads( UInt32 * quads, int numQuads ); + bool createMemoryDescriptor( void ); + void destroyMemoryDescriptor( void ); + +public: + + void setDeferredNotify( bool state ) + { ((MemberVariables*)fMembers->fSubclassMembers)->fDeferredNotify = state; }; + +private: + + OSMetaClassDeclareReservedUnused(IOFWWriteQuadCommand, 0); + OSMetaClassDeclareReservedUnused(IOFWWriteQuadCommand, 1); + +}; + +/* + * May need more parameters for some of these, + * and/or derive from a base Lock transaction command + */ + +#pragma mark - + +/*! @class IOFWCompareAndSwapCommand +*/ +class IOFWCompareAndSwapCommand : public IOFWAsyncCommand +{ + OSDeclareDefaultStructors(IOFWCompareAndSwapCommand) + +protected: + UInt32 fInputVals[4]; + UInt32 fOldVal[2]; + + typedef struct + { + IOMemoryDescriptor * fMemory; + } + MemberVariables; + + MemberVariables * fMembers; + + virtual void gotPacket(int rcode, const void* data, int size); + + virtual IOReturn execute(); + +public: + // Compare to cmpVal, and if equal replace with newVal. + // Size = 1 for 32 bit operation (one quad), 2 for 64 bit (two quads) + virtual bool initWithController(IOFireWireController *control); + virtual bool initAll(IOFireWireNub *device, FWAddress devAddress, + const UInt32 *cmpVal, const UInt32 *newVal, int size, + FWDeviceCallback completion, void *refcon, bool failOnReset); + virtual bool initAll(IOFireWireController *control, + UInt32 generation, FWAddress devAddress, + const UInt32 *cmpVal, const UInt32 *newVal, int size, + FWDeviceCallback completion, void *refcon); + + virtual IOReturn reinit(FWAddress devAddress, const UInt32 *cmpVal, const UInt32 *newVal, int size, + FWDeviceCallback completion=NULL, void *refcon=NULL, bool failOnReset=false); + virtual IOReturn reinit(UInt32 generation, FWAddress devAddress, + const UInt32 *cmpVal, const UInt32 *newVal, int size, + FWDeviceCallback completion=NULL, void *refcon=NULL); + + // sets oldVal to the old value returned by the device, and + // returns true if it was the expected value, ie. the lock succeeded + virtual bool locked(UInt32 *oldVal); + + virtual void free( void ); + +protected: + + bool createMemberVariables( void ); + void destroyMemberVariables( void ); + + void setInputVals( const UInt32 * cmpVal, const UInt32 * newVal, int size ); + + bool createMemoryDescriptor( void ); + void destroyMemoryDescriptor( void ); + +private: + OSMetaClassDeclareReservedUnused(IOFWCompareAndSwapCommand, 0); + OSMetaClassDeclareReservedUnused(IOFWCompareAndSwapCommand, 1); + OSMetaClassDeclareReservedUnused(IOFWCompareAndSwapCommand, 2); + OSMetaClassDeclareReservedUnused(IOFWCompareAndSwapCommand, 3); + +}; + +/* + * Send an async stream packet + */ + +#pragma mark - + +/*! @class IOFWAsyncStreamCommand +*/ +class IOFWAsyncStreamCommand : public IOFWCommand +{ + // temporary for debugging: + friend class IOFireWireUserClient ; + + OSDeclareDefaultStructors(IOFWAsyncStreamCommand) + +protected: + FWAsyncStreamCallback fComplete; + void * fRefCon; + IOMemoryDescriptor * fMemDesc; + int fSpeed; + int fSize; + int fCurRetries; + int fMaxRetries; + int fChannel; + int fSyncBits; + int fTag; + UInt32 fGeneration; // bus topology fNodeID is valid for. + bool fFailOnReset; + + typedef struct + { } + MemberVariables; + + MemberVariables * fMembers; + + virtual IOReturn complete( + IOReturn status); + + // To be called by IOFireWireController and derived classes. + virtual IOReturn execute(); + +public: + + virtual bool initAll( + IOFireWireController * control, + UInt32 generation, + UInt32 channel, + UInt32 sync, + UInt32 tag, + IOMemoryDescriptor * hostMem, + UInt32 size, + int speed, + FWAsyncStreamCallback completion, + void * refcon); + + virtual void free( void ); + + virtual IOReturn reinit( UInt32 generation, + UInt32 channel, + UInt32 sync, + UInt32 tag, + IOMemoryDescriptor * hostMem, + UInt32 size, + int speed, + FWAsyncStreamCallback completion, + void * refcon); + + virtual void gotAck( + int ackCode); + // Utility for setting generation on newly created command + virtual void setGeneration( + UInt32 generation) + { fGeneration = generation; } + + + // update nodeID/generation after bus reset, from the device object + IOReturn updateGeneration(); + + bool failOnReset() const + { return fFailOnReset; } + +private: + OSMetaClassDeclareReservedUnused(IOFWAsyncStreamCommand, 0); + OSMetaClassDeclareReservedUnused(IOFWAsyncStreamCommand, 1); + +public: + virtual bool initAll( + IOFireWireController * control, + UInt32 generation, + UInt32 channel, + UInt32 sync, + UInt32 tag, + IOMemoryDescriptor * hostMem, + UInt32 size, + int speed, + FWAsyncStreamCallback completion, + void * refcon, + bool failOnReset ); + + + virtual IOReturn reinit( + UInt32 generation, + UInt32 channel, + UInt32 sync, + UInt32 tag, + IOMemoryDescriptor * hostMem, + UInt32 size, + int speed, + FWAsyncStreamCallback completion, + void * refcon, + bool failOnReset); + + +}; + +/* + * Send an async PHY packet + */ + +#pragma mark - + +/*! @class IOFWAsyncPHYCommand +*/ +class IOFWAsyncPHYCommand : public IOFWCommand +{ + // temporary for debugging: + friend class IOFireWireUserClient; + + OSDeclareDefaultStructors( IOFWAsyncPHYCommand ) + +protected: + AsyncPendingTrans * fTrans; + FWAsyncPHYCallback fComplete; + void * fRefCon; + int fCurRetries; + int fMaxRetries; + UInt32 fGeneration; + bool fFailOnReset; + UInt32 fData1; + UInt32 fData2; + int fAckCode; + UInt32 fResponseCode; + + typedef struct + { } + MemberVariables; + + MemberVariables * fMembers; + + virtual IOReturn complete( + IOReturn status ); + + // To be called by IOFireWireController and derived classes. + virtual IOReturn execute(); + + void setResponseCode( UInt32 rcode ); + void setAckCode( int ack ); + +public: + + virtual bool initAll( + IOFireWireController * control, + UInt32 generation, + UInt32 data1, + UInt32 data2, + FWAsyncPHYCallback completion, + void * refcon, + bool failOnReset ); + virtual void free( void ); + + virtual IOReturn reinit( UInt32 generation, + UInt32 data1, + UInt32 data2, + FWAsyncPHYCallback completion, + void * refcon, + bool failOnReset ); + + virtual void gotAck( + int ackCode ); + + // Utility for setting generation on newly created command + virtual void setGeneration( + UInt32 generation ) + { fGeneration = generation; } + + + // update nodeID/generation after bus reset, from the device object + IOReturn updateGeneration(); + + bool failOnReset() const + { return fFailOnReset; } + + + virtual void gotPacket( int rcode ); + + int getAckCode( void ); + UInt32 getResponseCode( void ) const; + + void setRetries( int retries); +private: + OSMetaClassDeclareReservedUnused(IOFWAsyncPHYCommand, 0); + OSMetaClassDeclareReservedUnused(IOFWAsyncPHYCommand, 1); + OSMetaClassDeclareReservedUnused(IOFWAsyncPHYCommand, 2); + OSMetaClassDeclareReservedUnused(IOFWAsyncPHYCommand, 3); + OSMetaClassDeclareReservedUnused(IOFWAsyncPHYCommand, 4); + OSMetaClassDeclareReservedUnused(IOFWAsyncPHYCommand, 5); + OSMetaClassDeclareReservedUnused(IOFWAsyncPHYCommand, 6); + OSMetaClassDeclareReservedUnused(IOFWAsyncPHYCommand, 7); +}; + +#endif /* _IOKIT_IOFWCOMMAND_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFireWireMultiIsochReceive.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFireWireMultiIsochReceive.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFireWireMultiIsochReceive.h (revision 885) @@ -0,0 +1,137 @@ +/* + * Copyright (c) 2008 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_IOFIREWIREMULTIISOCHRECEIVE_H_ +#define _IOKIT_IOFIREWIREMULTIISOCHRECEIVE_H_ + +class IOFireWireMultiIsochReceiveListener; +class IOFireWireMultiIsochReceivePacket; +class IOFireWireController; + +typedef IOReturn (*FWMultiIsochReceiveListenerCallback)(void *refcon, IOFireWireMultiIsochReceivePacket *pPacket); + +// These are the parameters clients can set which help us to optimize the mult-isoch-receiver +// polling interval, and memory resources +typedef struct FWMultiIsochReceiveListenerParamsStruct + { + // How much latency, from when the packet arrives to when the client is notified, can the client tolerate. + UInt32 maxLatencyInFireWireCycles; + + // In bits per second, the expected bit-rate of the incoming stream + UInt32 expectedStreamBitRate; + + // How long does the client expect to hold onto packets objects before returning them back to the receiver + UInt32 clientPacketReturnLatencyInFireWireCycles; + }FWMultiIsochReceiveListenerParams; + +/*! @class IOFireWireMultiIsochReceiveListener +*/ + +class IOFireWireMultiIsochReceiveListener : public OSObject + { + friend class IOFireWireLink; + + protected: + OSDeclareDefaultStructors(IOFireWireMultiIsochReceiveListener) + bool init(IOFireWireController *fwController, + UInt32 receiveChannel, + FWMultiIsochReceiveListenerCallback callback, + void *pCallbackRefCon, + FWMultiIsochReceiveListenerParams *pListenerParams); + void free(); + public: + static IOFireWireMultiIsochReceiveListener *create(IOFireWireController *fwController, + UInt32 channel, + FWMultiIsochReceiveListenerCallback callback, + void *pCallbackRefCon, + FWMultiIsochReceiveListenerParams *pListenerParams); + + // Call this to activate the listener + IOReturn Activate(); + + // Call this to deactivate the listener + IOReturn Deactivate(); + + // Call this to modify the callback/refcon pointers. Only call this when not activated! + IOReturn SetCallback(FWMultiIsochReceiveListenerCallback callback, + void *pCallbackRefCon); + + // Accessors + inline UInt32 getReceiveChannel(void) {return fChannel;}; + inline FWMultiIsochReceiveListenerCallback getCallback(void){return fClientCallback;}; + inline void * getRefCon(void){return fClientCallbackRefCon;}; + inline bool getActivatedState(void) {return fActivated;}; + + protected: + IOFireWireController *fControl; + UInt32 fChannel; + FWMultiIsochReceiveListenerCallback fClientCallback; + void *fClientCallbackRefCon; + bool fActivated; + FWMultiIsochReceiveListenerParams *fListenerParams; + }; + +#define kMaxRangesPerMultiIsochReceivePacket 6 + +/*! @class IOFireWireMultiIsochReceivePacket +*/ + +class IOFireWireMultiIsochReceivePacket : public OSObject + { + OSDeclareDefaultStructors(IOFireWireMultiIsochReceivePacket) + bool init(IOFireWireController *fwController); + void free(); + public: + static IOFireWireMultiIsochReceivePacket *create(IOFireWireController *fwController); + + // The clients who are passed this packet by the + // multi-isoch receiver calling their callback + // MUST call clientDone() on this packet to + // return it back for reuse! + void clientDone(void); + + UInt32 isochChannel(void); + UInt32 packetReceiveTime(void); + + UInt32 isochPayloadSize(void); // The size of just the isoch payload, not including header/trailer quads. + inline UInt32 isochPacketSize(void) {return isochPayloadSize()+8; }; // The size of the packet, including header/trailer quads. + + // This returns a memory descriptor to the client. The client must call complete(), and release() on the + // memory descriptor when done. + IOMemoryDescriptor *createMemoryDescriptorForRanges(void); + + // These should be treated as read-only by clients, + // as should the data contained in these buffers! + IOAddressRange ranges[kMaxRangesPerMultiIsochReceivePacket] ; + UInt32 numRanges; + + // These should be treated private for clients! + // Messing with them will screw up the bookkeepping + // in the Multi-Isoch Receiver! + UInt32 numClientReferences; + void* elements[kMaxRangesPerMultiIsochReceivePacket]; + + protected: + IOFireWireController *fControl; + }; + +#endif \ No newline at end of file Index: branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWLocalIsochPort.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWLocalIsochPort.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWLocalIsochPort.h (revision 885) @@ -0,0 +1,135 @@ +/* + * Copyright (c) 1998-2002 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@ + */ +/* + * Copyright (c) 1999-2002 Apple Computer, Inc. All rights reserved. + * + * IOFWIsochPort is an abstract object that represents hardware on the bus + * (locally or remotely) that sends or receives isochronous packets. + * Local ports are implemented by the local device driver, + * Remote ports are implemented by the driver for the remote device. + * + * HISTORY + * + * $Log: IOFWLocalIsochPort.h,v $ + * Revision 1.10 2004/06/10 20:57:36 niels + * *** empty log message *** + * + * Revision 1.9 2003/08/30 00:16:44 collin + * *** empty log message *** + * + * Revision 1.8 2003/08/15 04:36:55 niels + * *** empty log message *** + * + * Revision 1.7 2003/07/29 22:49:22 niels + * *** empty log message *** + * + * Revision 1.6 2003/07/21 06:52:58 niels + * merge isoch to TOT + * + * Revision 1.5.14.1 2003/07/01 20:54:07 niels + * isoch merge + * + */ + + +#ifndef _IOKIT_IOFWLOCALISOCHPORT_H +#define _IOKIT_IOFWLOCALISOCHPORT_H + +#import +#import + +class IOFireWireController; +class IODCLProgram; + +/*! @class IOFWLocalIsochPort +*/ +class IOFWLocalIsochPort : public IOFWIsochPort +{ + OSDeclareDefaultStructors(IOFWLocalIsochPort) + + protected: + + IOFireWireController * fControl; + IODCLProgram * fProgram; + + /*! @struct ExpansionData + @discussion This structure will be used to expand the capablilties of the class in the future. + */ + struct ExpansionData + { + } ; + + ExpansionData * fExpansion ; + + protected : + + virtual void free ( void ) ; + + public: + + virtual bool init ( + IODCLProgram * program, + IOFireWireController * control ) ; + + // Return maximum speed and channels supported + // (bit n set = chan n supported) + virtual IOReturn getSupported ( + IOFWSpeed & maxSpeed, + UInt64 & chanSupported ) ; + + // Allocate hardware resources for port + virtual IOReturn allocatePort ( + IOFWSpeed speed, + UInt32 chan ) ; + virtual IOReturn releasePort ( void ) ; // Free hardware resources + virtual IOReturn start ( void ) ; // Start port processing packets + virtual IOReturn stop ( void ) ; // Stop processing packets + + /*! @function notify + @abstract Informs hardware of a change to the DCL program. + @param notificationType Type of change. + @param dclCommandList List of DCL commands that have been changed. + @param numDCLCommands Number of commands in list. + @result IOKit error code. */ + virtual IOReturn notify( + IOFWDCLNotificationType notificationType, + DCLCommand ** dclCommandList, + UInt32 numDCLCommands ) ; + static void printDCLProgram ( + const DCLCommand * dcl, + UInt32 count = 0, + void (*printFN)( const char *format, ...) = NULL, + unsigned lineDelayMS = 0 ) ; + IOReturn setIsochResourceFlags ( + IOFWIsochResourceFlags flags ) ; + IODCLProgram * getProgramRef() const ; + + IOReturn synchronizeWithIO() ; + + private: + + OSMetaClassDeclareReservedUnused ( IOFWLocalIsochPort, 0 ) ; + OSMetaClassDeclareReservedUnused ( IOFWLocalIsochPort, 1 ) ; +}; + +#endif /* ! _IOKIT_IOFWLOCALISOCHPORT_H */ + Index: branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFireWirePowerManager.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFireWirePowerManager.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFireWirePowerManager.h (revision 885) @@ -0,0 +1,78 @@ +/* + * Copyright (c) 1998-2002 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_IOFIREWIREPOWERMANAGER_H +#define _IOKIT_IOFIREWIREPOWERMANAGER_H + +#include + +#include +#include + +class IOFireWireController; + +/*! @class IOFireWirePowerManager +*/ + +class IOFireWirePowerManager : public OSObject +{ + OSDeclareAbstractStructors(IOFireWirePowerManager); + +protected: + +/*! @struct ExpansionData + @discussion This structure will be used to expand the capablilties of the class in the future. + */ + struct ExpansionData { }; + +/*! @var reserved + Reserved for future use. (Internal use only) */ + ExpansionData *reserved; + + IOFireWireController * fControl; + + UInt32 fMaximumDeciwatts; + UInt32 fAllocatedDeciwatts; + +public: + static IOFireWirePowerManager * createWithController( IOFireWireController * controller ); + + virtual bool initWithController( IOFireWireController * controller ); + + virtual void setMaximumDeciwatts( UInt32 deciwatts ); + virtual IOReturn allocateDeciwatts( UInt32 deciwatts ); + virtual void deallocateDeciwatts( UInt32 deciwatts ); + +private: + OSMetaClassDeclareReservedUnused(IOFireWirePowerManager, 0); + OSMetaClassDeclareReservedUnused(IOFireWirePowerManager, 1); + OSMetaClassDeclareReservedUnused(IOFireWirePowerManager, 2); + OSMetaClassDeclareReservedUnused(IOFireWirePowerManager, 3); + OSMetaClassDeclareReservedUnused(IOFireWirePowerManager, 4); + OSMetaClassDeclareReservedUnused(IOFireWirePowerManager, 5); + OSMetaClassDeclareReservedUnused(IOFireWirePowerManager, 6); + OSMetaClassDeclareReservedUnused(IOFireWirePowerManager, 7); + OSMetaClassDeclareReservedUnused(IOFireWirePowerManager, 8); + OSMetaClassDeclareReservedUnused(IOFireWirePowerManager, 9); +}; + +#endif \ No newline at end of file Index: branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWSimpleContiguousPhysicalAddressSpace.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWSimpleContiguousPhysicalAddressSpace.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWSimpleContiguousPhysicalAddressSpace.h (revision 885) @@ -0,0 +1,66 @@ +/* + * Copyright (c) 1998-2006 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 _IOFWSIMPLECONTIGUOUSPHYSICALADDRESSSPACE_H_ +#define _IOFWSIMPLECONTIGUOUSPHYSICALADDRESSSPACE_H_ + +#include + +/*! @class IOFWSimpleContiguousPhysicalAddressSpace +*/ + +class IOFWSimpleContiguousPhysicalAddressSpace : public IOFWSimplePhysicalAddressSpace +{ + OSDeclareDefaultStructors( IOFWSimpleContiguousPhysicalAddressSpace ) + +private: + + void * fSimpleContigPhysSpaceMembers; + + IOReturn cachePhysicalAddress( void ); + +protected: + virtual bool createMemberVariables( void ); + virtual void destroyMemberVariables( void ); + +public: + + virtual bool init( IOFireWireBus * control, vm_size_t size, IODirection direction ); + virtual void free( void ); + + FWAddress getFWAddress( void ); + +private: + OSMetaClassDeclareReservedUnused(IOFWSimpleContiguousPhysicalAddressSpace, 0); + OSMetaClassDeclareReservedUnused(IOFWSimpleContiguousPhysicalAddressSpace, 1); + OSMetaClassDeclareReservedUnused(IOFWSimpleContiguousPhysicalAddressSpace, 2); + OSMetaClassDeclareReservedUnused(IOFWSimpleContiguousPhysicalAddressSpace, 3); + OSMetaClassDeclareReservedUnused(IOFWSimpleContiguousPhysicalAddressSpace, 4); + OSMetaClassDeclareReservedUnused(IOFWSimpleContiguousPhysicalAddressSpace, 5); + OSMetaClassDeclareReservedUnused(IOFWSimpleContiguousPhysicalAddressSpace, 6); + OSMetaClassDeclareReservedUnused(IOFWSimpleContiguousPhysicalAddressSpace, 7); + OSMetaClassDeclareReservedUnused(IOFWSimpleContiguousPhysicalAddressSpace, 8); + OSMetaClassDeclareReservedUnused(IOFWSimpleContiguousPhysicalAddressSpace, 9); + +}; + +#endif Index: branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFireWireFamilyCommon.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFireWireFamilyCommon.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFireWireFamilyCommon.h (revision 885) @@ -0,0 +1,1235 @@ +/* + * 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@ + */ +/* + * IOFireWireFamilyCommon.h + * IOFireWireUserClient/IOFireWireFamily + * + * Created by NWG on Fri Apr 28 2000. + * Copyright (c) 2000-2001 Apple Computer, Inc. All rights reserved. + * + */ +/* + $Log: IOFireWireFamilyCommon.h,v $ + Revision 1.79 2008/07/15 01:29:44 collin + & + + Revision 1.78 2008/05/08 02:33:22 collin + more K64 + + Revision 1.77 2008/04/24 00:01:39 collin + more K640 + + Revision 1.76 2007/12/05 04:52:08 collin + integrate chex workaround + + Revision 1.75 2007/08/31 20:29:06 collin + fixed 5437835 + + Revision 1.74 2007/04/24 21:40:23 arulchan + headerdoc changes + + Revision 1.73 2007/04/24 21:28:24 arulchan + changes for headerdoc + + Revision 1.72 2007/04/13 19:37:01 calderon + Integrated FireWireKPrintf implemented + + Revision 1.71 2007/03/14 18:41:43 collin + *** empty log message *** + + Revision 1.70 2007/02/28 23:10:13 ayanowit + Another IRMAllocation fix. + + Revision 1.69 2007/02/20 01:25:28 collin + *** empty log message *** + + Revision 1.68 2007/02/17 00:26:51 collin + *** empty log message *** + + Revision 1.67 2007/02/15 19:42:07 ayanowit + For 4369537, eliminated support for legacy DCL SendPacketWithHeader, since it didn't work anyway, and NuDCL does support it. + + Revision 1.66 2007/02/15 01:23:39 arulchan + changes in AssignCycleMaster + + Revision 1.65 2007/02/09 04:44:06 collin + *** empty log message *** + + Revision 1.64 2007/01/26 20:52:31 ayanowit + changes to user-space isoch stuff to support 64-bit apps. + + Revision 1.63 2007/01/16 01:41:02 gecko1 + 4159728 Add improved async lock based check for bad IRMs + + Revision 1.62 2007/01/15 23:29:05 arulchan + Fixed Skipped Packet Handler Notifications + + Revision 1.61 2007/01/12 22:15:14 arulchan + Added flag kIOFWEnableBeingRoot + + Revision 1.60 2007/01/10 22:14:44 calderon + Fixed 4046607 Propagate vendor/model from IIDC UnitDepedantInfoDir + Fixed some null termination shinanigans in getIndexValue(string) + + Revision 1.59 2007/01/08 18:47:19 ayanowit + More 64-bit changes for isoch. + + Revision 1.58 2006/07/07 20:18:25 calderon + 4227201: SpeedMap and HopCount table reductions. + + Revision 1.57 2006/04/03 21:29:48 collin + *** empty log message *** + + Revision 1.56 2006/02/09 00:21:51 niels + merge chardonnay branch to tot + + Revision 1.55.4.1 2005/08/06 01:31:31 collin + *** empty log message *** + + Revision 1.55 2005/03/12 03:27:51 collin + *** empty log message *** + + Revision 1.54 2005/01/12 06:34:53 collin + *** empty log message *** + + Revision 1.53 2004/05/04 22:52:19 niels + *** empty log message *** + + Revision 1.52 2004/03/26 01:42:53 gecko1 + Add code to disable any port directly connected to an iPod when we go to sleep. + + Revision 1.51 2004/03/05 00:33:59 calderon + Fixed 3570909 - FireWire - iokit_fw_errs should be defined in hex + All decimal #define errors in header changed to hex + + Revision 1.50 2003/11/07 21:01:18 niels + Revision 1.49 2003/10/21 01:16:41 collin + Revision 1.48 2003/10/17 00:25:24 collin + Revision 1.47 2003/10/15 02:19:45 collin + Revision 1.46 2003/07/22 10:49:47 niels + Revision 1.45 2003/07/21 06:52:59 niels + merge isoch to TOT + + Revision 1.44.4.5 2003/07/21 06:44:44 niels + Revision 1.44.4.4 2003/07/18 00:17:42 niels + Revision 1.44.4.3 2003/07/14 22:08:53 niels + Revision 1.44.4.2 2003/07/09 21:24:01 niels + Revision 1.44.4.1 2003/07/01 20:54:07 niels + isoch merge + + Revision 1.44 2003/03/17 01:05:22 collin + Revision 1.43 2003/03/07 01:26:06 collin + Revision 1.42 2003/02/19 22:33:17 niels + add skip cycle DCL + + Revision 1.41 2003/02/18 00:14:01 collin + Revision 1.40 2003/02/17 21:47:52 collin + Revision 1.39 2002/12/05 19:08:37 niels + remove trailing commas from enums in IOFireWireFamilyCommon.h + + Revision 1.38 2002/11/01 20:45:57 collin + add enhanced IRM with support for the BROADCAST_CHANNEL register + + Revision 1.37 2002/10/01 02:40:27 collin + security mode support + + Revision 1.36 2002/09/25 21:17:14 collin + fix headers again. + + Revision 1.35 2002/09/25 00:27:23 niels + flip your world upside-down + + Revision 1.34 2002/09/12 22:41:53 niels + add GetIRMNodeID() to user client + +*/ + +/*! @header IOFireWireFamilyCommon.h +This file contains useful definitions for working with FireWire +in the kernel and in user space +*/ + +#ifndef __IOFireWireFamilyCommon_H__ +#define __IOFireWireFamilyCommon_H__ + +#ifdef KERNEL +#ifndef __IOKIT_IOTYPES_H + #include +#endif +#else +#include +#endif + +//#define LEGACY_SHUTDOWN + +#define FW_OLD_DCL_DEFS +#define FW_OLD_BIT_DEFS + +// ================================================================= +// bit ranges and fields +// ================================================================= +#pragma mark - +#pragma mark BITS + +// FireWire bit defs. + +#define BIT(x) ( 1 << (x) ) +#define FW_BIT(x) ( 1 << (31 - (x) ) ) + +#define FWBitRange(start, end) \ +( \ + ((((UInt32) 0xFFFFFFFF) << (start)) >> \ + ((start) + (31 - (end)))) << \ + (31 - (end)) \ +) + +#define FWBitRangePhase(start, end) \ + (31 - (end)) + +#define BitRange(start, end) \ +( \ + ((((UInt32) 0xFFFFFFFF) << (31 - (end))) >> \ + ((31 - (end)) + (start))) << \ + (start) \ +) + + +#define BitRangePhase(start, end) \ + (start) + +// ================================================================= +// FireWire messages & errors +// ================================================================= +#pragma mark - +#pragma mark MESSAGES AND ERRORS + +#define iokit_fw_err(return) (sys_iokit|sub_iokit_firewire|return) + +// e0008010 -> 0xe000801f Response codes from response packets + +// Base of Response error codes +#define kIOFireWireResponseBase iokit_fw_err(0x10) + +// e0008020 -- Bus reset during command execution (current bus generation does +// not match that specified in command.) +#define kIOFireWireBusReset (kIOFireWireResponseBase+kFWResponseBusResetError) + +// e0008001 -- Can't find requested entry in ROM +#define kIOConfigNoEntry iokit_fw_err(0x1) + +// e0008002 -- In pending queue waiting to execute +#define kIOFireWirePending iokit_fw_err(0x2) + +// e0008003 -- Last DCL callback of program (internal use) +#define kIOFireWireLastDCLToken iokit_fw_err(0x3) + +// e0008004 +#define kIOFireWireConfigROMInvalid iokit_fw_err(0x4) + +// e0008005 +#define kIOFireWireAlreadyRegistered iokit_fw_err(0x5) + +// e0008006 +#define kIOFireWireMultipleTalkers iokit_fw_err(0x6) + +// e0008007 +#define kIOFireWireChannelActive iokit_fw_err(0x7) + +// e0008008 +#define kIOFireWireNoListenerOrTalker iokit_fw_err(0x8) + +// e0008009 +#define kIOFireWireNoChannels iokit_fw_err(0x9) + +// e000800A +#define kIOFireWireChannelNotAvailable iokit_fw_err(0xA) + +// e000800B +#define kIOFireWireSeparateBus iokit_fw_err(0xB) + +// e000800C +#define kIOFireWireBadSelfIDs iokit_fw_err(0xC) + +// e000800D +#define kIOFireWireLowCableVoltage iokit_fw_err(0xD) + +// e000800E +#define kIOFireWireInsufficientPower iokit_fw_err(0xE) + +// e000800f +#define kIOFireWireOutOfTLabels iokit_fw_err(0xF) + +// NOTE: errors 16Ñ31 used for address space response codes.. (see above) + +// e0008101 +#define kIOFireWireBogusDCLProgram iokit_fw_err(0x101) + +// e0008102 +#define kIOFireWireTalkingAndListening iokit_fw_err(0x102) + +// e0008103 +#define kIOFireWireHardwareSlept iokit_fw_err(0x103) + +// e0008104 // let's resume here... + +// e0008104 -- In the middle of completing +#define kIOFireWireCompleting iokit_fw_err(0x104) + +// e0008105 -- Invalid Response Length +#define kIOFireWireInvalidResponseLength iokit_fw_err(0x105) + +// e0008106 -- Isoch Bandwidth Not Available +#define kIOFireWireIsochBandwidthNotAvailable iokit_fw_err(0x106) + + +// e00087d0 +#define kIOFWMessageServiceIsRequestingClose (UInt32)iokit_fw_err(0x7D0) +#define kIOFWMessagePowerStateChanged (UInt32)iokit_fw_err(0x7D1) +#define kIOFWMessageTopologyChanged (UInt32)iokit_fw_err(0x7D2) +// ================================================================= +// Pseudo address space response codes +// ================================================================= +#pragma mark - +#pragma mark PSEDUO ADDRESS SPACE RESPONSE CODES +enum +{ + kFWResponseComplete = 0, // OK! + kFWResponseConflictError = 4, // Resource conflict, may retry + kFWResponseDataError = 5, // Data not available + kFWResponseTypeError = 6, // Operation not supported + kFWResponseAddressError = 7, // Address not valid in target device + kFWResponseBusResetError = 16, // Pseudo response generated locally + kFWResponsePending = 17 // Pseudo response, real response sent later. +}; + +// +// Pseudo address space response codes +// +enum +{ + kFWAckTimeout = -1, // Pseudo ack generated locally + kFWAckComplete = 1, + kFWAckPending = 2, + kFWAckBusyX = 4, + kFWAckBusyA = 5, + kFWAckBusyB = 6, + kFWAckDataError = 13, + kFWAckTypeError = 14 +}; + +// ================================================================= +// FireWire bus speed numbers +// ================================================================= +#pragma mark - +#pragma mark BUS SPEED NUMBERS + +typedef enum +{ + kFWSpeed100MBit = 0, + kFWSpeed200MBit = 1, + kFWSpeed400MBit = 2, + kFWSpeed800MBit = 3, + kFWSpeedReserved = 3, // In all cases, 1394B Devices report this speed, + // each port of the PHY could be different + + kFWSpeedUnknownMask = 0x80, // If speed was reserved and we haven't probed it further + + kFWSpeedMaximum = 0x7FFFFFFF, + kFWSpeedInvalid = 0x80000000 +} IOFWSpeed; + +// ================================================================= +// FWAddress +// ================================================================= +#pragma mark - +#pragma mark FWADDRESS +// +// The venerable FWAddress structure. This is the standard +// struct to use for passing FireWire addresses. +// + +typedef struct FWAddressStruct +{ + UInt16 nodeID; // bus/node + UInt16 addressHi; // Top 16 bits of node address. + UInt32 addressLo; // Bottom 32 bits of node address + + // + // Useful C++ only constructors + // + #ifdef __cplusplus + FWAddressStruct(const FWAddressStruct & a): + nodeID(a.nodeID), addressHi(a.addressHi), addressLo(a.addressLo) {}; + FWAddressStruct(UInt16 h=0xdead, UInt32 l=0xcafebabe) : + nodeID(0), addressHi(h), addressLo(l) {}; + FWAddressStruct(UInt16 h, UInt32 l, UInt16 n) : + nodeID(n), addressHi(h), addressLo(l) {}; + #endif +} FWAddress, *FWAddressPtr ; + +// ================================================================= +// Config ROM +// ================================================================= +#pragma mark - +#pragma mark CONFIG ROM + +// +// CSR bit defs. +// + +#define CSR_BIT(x) FW_BIT(x) + +#define CSRBitRange(start, end) \ +( \ + ((((UInt32) 0xFFFFFFFF) << (start)) >> \ + ((start) + (31 - (end)))) << \ + (31 - (end)) \ +) + +#define CSRBitRangePhase(start, end) \ + (31 - end) + +// +// Key types. +// + +typedef enum +{ + kConfigImmediateKeyType = 0, + kConfigOffsetKeyType = 1, + kConfigLeafKeyType = 2, + kConfigDirectoryKeyType = 3, + kInvalidConfigROMEntryType = 0xff +} IOConfigKeyType; + +// +// Key values. +// + +enum +{ + kConfigTextualDescriptorKey = 0x01, + kConfigBusDependentInfoKey = 0x02, + kConfigModuleVendorIdKey = 0x03, + kConfigModuleHwVersionKey = 0x04, + kConfigModuleSpecIdKey = 0x05, + kConfigModuleSwVersionKey = 0x06, + kConfigModuleDependentInfoKey = 0x07, + kConfigNodeVendorIdKey = 0x08, + kConfigNodeHwVersionKey = 0x09, + kConfigNodeSpecIdKey = 0x0A, + kConfigNodeSwVersionKey = 0x0B, + kConfigNodeCapabilitiesKey = 0x0C, + kConfigNodeUniqueIdKey = 0x0D, + kConfigNodeUnitsExtentKey = 0x0E, + kConfigNodeMemoryExtentKey = 0x0F, + kConfigNodeDependentInfoKey = 0x10, + kConfigUnitDirectoryKey = 0x11, + kConfigUnitSpecIdKey = 0x12, + kConfigUnitSwVersionKey = 0x13, + kConfigUnitDependentInfoKey = 0x14, + kConfigUnitLocationKey = 0x15, + kConfigUnitPollMaskKey = 0x16, + kConfigModelIdKey = 0x17, + kConfigGenerationKey = 0x38, // Apple-specific + + kConfigRootDirectoryKey = 0xffff // Not a real key +}; + +enum +{ + kConfigSBP2LUN = 0x14, + kConfigSBP2Revision = 0x21, + kConfigSBP2MAO = 0x54 +}; + +// Core CSR registers. +enum +{ + kCSRStateUnitDepend = CSRBitRange(0, 15), + kCSRStateUnitDependPhase = CSRBitRangePhase(0, 15), + + kCSRStateBusDepend = CSRBitRange(16, 23), + kCSRStateBusDependPhase = CSRBitRangePhase(16, 23), + + kCSRStateLost = CSR_BIT(24), + kCSRStateDReq = CSR_BIT(25), + kCSRStateELog = CSR_BIT(27), + kCSRStateAtn = CSR_BIT(28), + kCSRStateOff = CSR_BIT(29), + + kCSRStateState = CSRBitRange(30, 31), + kCSRStateStatePhase = CSRBitRangePhase(30, 31), + kCSRStateStateRunning = 0, + kCSRStateStateInitializing = 1, + kCSRStateStateTesting = 2, + kCSRStateStateDead = 3 +}; + +// Config ROM entry bit locations. + +enum +{ + kConfigBusInfoBlockLength = CSRBitRange (0, 7), + kConfigBusInfoBlockLengthPhase = CSRBitRangePhase (0, 7), + + kConfigROMCRCLength = CSRBitRange (8, 15), + kConfigROMCRCLengthPhase = CSRBitRangePhase (8, 15), + + kConfigROMCRCValue = CSRBitRange (16, 31), + kConfigROMCRCValuePhase = CSRBitRangePhase (16, 31), + + kConfigEntryKeyType = CSRBitRange (0, 1), + kConfigEntryKeyTypePhase = CSRBitRangePhase (0, 1), + + kConfigEntryKeyValue = CSRBitRange (2, 7), + kConfigEntryKeyValuePhase = CSRBitRangePhase (2, 7), + + kConfigEntryValue = CSRBitRange (8, 31), + kConfigEntryValuePhase = CSRBitRangePhase (8, 31), + + kConfigLeafDirLength = CSRBitRange (0, 15), + kConfigLeafDirLengthPhase = CSRBitRangePhase (0, 15), + + kConfigLeafDirCRC = CSRBitRange (16, 31), + kConfigLeafDirCRCPhase = CSRBitRangePhase (16, 31) +}; + +// +// Key types. +// +typedef enum +{ + kCSRImmediateKeyType = 0, + kCSROffsetKeyType = 1, + kCSRLeafKeyType = 2, + kCSRDirectoryKeyType = 3, + kInvalidCSRROMEntryType = 0xff +} IOCSRKeyType; + +// CSR 64-bit fixed address defs. + +enum +{ + kCSRNodeID = CSRBitRange (0, 15), + kCSRNodeIDPhase = CSRBitRangePhase (0, 15), + + kCSRInitialMemorySpaceBaseAddressHi = 0x00000000, + kCSRInitialMemorySpaceBaseAddressLo = 0x00000000, + + kCSRPrivateSpaceBaseAddressHi = 0x0000FFFF, + kCSRPrivateSpaceBaseAddressLo = 0xE0000000, + + kCSRRegisterSpaceBaseAddressHi = 0x0000FFFF, + kCSRRegisterSpaceBaseAddressLo = 0xF0000000, + + kCSRCoreRegistersBaseAddress = kCSRRegisterSpaceBaseAddressLo, + kCSRStateClearAddress = kCSRCoreRegistersBaseAddress + 0x0000, + kCSRStateSetAddress = kCSRCoreRegistersBaseAddress + 0x0004, + kCSRNodeIDsAddress = kCSRCoreRegistersBaseAddress + 0x0008, + kCSRResetStartAddress = kCSRCoreRegistersBaseAddress + 0x000C, + kCSRIndirectAddressAddress = kCSRCoreRegistersBaseAddress + 0x0010, + kCSRIndirectDataAddress = kCSRCoreRegistersBaseAddress + 0x0014, + kCSRSplitTimeoutHiAddress = kCSRCoreRegistersBaseAddress + 0x0018, + kCSRSplitTimeoutLoAddress = kCSRCoreRegistersBaseAddress + 0x001C, + kCSRArgumentHiAddress = kCSRCoreRegistersBaseAddress + 0x0020, + kCSRArgumentLoAddress = kCSRCoreRegistersBaseAddress + 0x0024, + kCSRTestStartAddress = kCSRCoreRegistersBaseAddress + 0x0028, + kCSRTestStatusAddress = kCSRCoreRegistersBaseAddress + 0x002C, + kCSRUnitsBaseHiAddress = kCSRCoreRegistersBaseAddress + 0x0030, + kCSRUnitsBaseLoAddress = kCSRCoreRegistersBaseAddress + 0x0034, + kCSRUnitsBoundHiAddress = kCSRCoreRegistersBaseAddress + 0x0038, + kCSRUnitsBoundLoAddress = kCSRCoreRegistersBaseAddress + 0x003C, + kCSRMemoryBaseHiAddress = kCSRCoreRegistersBaseAddress + 0x0040, + kCSRMemoryBaseLoAddress = kCSRCoreRegistersBaseAddress + 0x0044, + kCSRMemoryBoundHiAddress = kCSRCoreRegistersBaseAddress + 0x0048, + kCSRMemoryBoundLoAddress = kCSRCoreRegistersBaseAddress + 0x004C, + kCSRInterruptTargetAddress = kCSRCoreRegistersBaseAddress + 0x0050, + kCSRInterruptMaskAddress = kCSRCoreRegistersBaseAddress + 0x0054, + kCSRClockValueHiAddress = kCSRCoreRegistersBaseAddress + 0x0058, + kCSRClockValueMidAddress = kCSRCoreRegistersBaseAddress + 0x005C, + kCSRClockTickPeriodMidAddress = kCSRCoreRegistersBaseAddress + 0x0060, + kCSRClockTickPeriodLoAddress = kCSRCoreRegistersBaseAddress + 0x0064, + kCSRClockStrobeArrivedHiAddress = kCSRCoreRegistersBaseAddress + 0x0068, + kCSRClockStrobeArrivedMidAddress = kCSRCoreRegistersBaseAddress + 0x006C, + kCSRClockInfo0Address = kCSRCoreRegistersBaseAddress + 0x0070, + kCSRClockInfo1Address = kCSRCoreRegistersBaseAddress + 0x0074, + kCSRClockInfo2Address = kCSRCoreRegistersBaseAddress + 0x0078, + kCSRClockInfo3Address = kCSRCoreRegistersBaseAddress + 0x007C, + kCSRMessageRequestAddress = kCSRCoreRegistersBaseAddress + 0x0080, + kCSRMessageResponseAddress = kCSRCoreRegistersBaseAddress + 0x00C0, + kCSRErrorLogBufferAddress = kCSRCoreRegistersBaseAddress + 0x0180, + + kCSRBusDependentRegistersBaseAddress = kCSRRegisterSpaceBaseAddressLo + 0x0200, + kCSRBusyTimeout = kCSRRegisterSpaceBaseAddressLo + 0x0210, + kCSRBusManagerID = kCSRRegisterSpaceBaseAddressLo + 0x021C, + kCSRBandwidthAvailable = kCSRRegisterSpaceBaseAddressLo + 0x0220, + kCSRChannelsAvailable31_0 = kCSRRegisterSpaceBaseAddressLo + 0x0224, + kCSRChannelsAvailable63_32 = kCSRRegisterSpaceBaseAddressLo + 0x0228, + kCSRBroadcastChannel = kCSRRegisterSpaceBaseAddressLo + 0x0234, + + kConfigROMBaseAddress = kCSRRegisterSpaceBaseAddressLo + 0x0400, + kConfigBIBHeaderAddress = kConfigROMBaseAddress, + kConfigBIBBusNameAddress = kConfigROMBaseAddress + 4, + + kPCRBaseAddress = kCSRRegisterSpaceBaseAddressLo + 0x900, + kFCPCommandAddress = kCSRRegisterSpaceBaseAddressLo + 0xb00, + kFCPResponseAddress = kCSRRegisterSpaceBaseAddressLo + 0xd00 +}; + +// from figure 10-7 of 1394a +#define kBroadcastChannelInitialValues 0x8000001f +#define kBroadcastChannelValidMask 0x40000000 + +// CSR defined 64 bit unique ID. + +typedef UInt64 CSRNodeUniqueID; + +// FireWire core CSR registers. + +enum +{ + kFWCSRStateGone = FW_BIT(16), + kFWCSRStateLinkOff = FW_BIT(22), + kFWCSRStateCMstr = FW_BIT(23) +}; + +// FireWire bus/nodeID address defs. + +enum +{ + kFWAddressBusID = FWBitRange (16, 25) << kCSRNodeIDPhase, + kFWAddressBusIDPhase = FWBitRangePhase (16, 25) + kCSRNodeIDPhase, + + kFWAddressNodeID = FWBitRange (26, 31) << kCSRNodeIDPhase, + kFWAddressNodeIDPhase = FWBitRangePhase (26, 31) + kCSRNodeIDPhase, + + kFWLocalBusID = 1023, + kFWBroadcastNodeID = 63, + kFWBadNodeID = 0xffff, + + kFWLocalBusAddress = kFWLocalBusID << kFWAddressBusIDPhase, + kFWBroadcastAddress = kFWBroadcastNodeID << kFWAddressNodeIDPhase +}; + +#define FWNodeBaseAddress(busID, nodeID) \ +( \ + (busID << kFWAddressBusIDPhase) | \ + (nodeID << kFWAddressNodeIDPhase) \ +) + +#define FWNodeRegisterSpaceBaseAddressHi(busID, nodeID) \ +( \ + FWNodeBaseAddress (busID, nodeID) | \ + kCSRRegisterSpaceBaseAddressHi \ +) + +// FireWire CSR bus info block defs. + +enum +{ + kFWBIBHeaderAddress = kConfigBIBHeaderAddress, + kFWBIBBusNameAddress = kConfigBIBBusNameAddress, + kFWBIBNodeCapabilitiesAddress = kConfigROMBaseAddress + 8, + kFWBIBNodeUniqueIDHiAddress = kConfigROMBaseAddress + 12, + kFWBIBNodeUniqueIDLoAddress = kConfigROMBaseAddress + 16, + + kFWBIBBusName = 0x31333934, //'1394' + + kFWBIBIrmc = FW_BIT(0), + kFWBIBCmc = FW_BIT(1), + kFWBIBIsc = FW_BIT(2), + kFWBIBBmc = FW_BIT(3), + kFWBIBCycClkAcc = FWBitRange (8, 15), + kFWBIBCycClkAccPhase = FWBitRangePhase (8, 15), + kFWBIBMaxRec = FWBitRange (16, 19), + kFWBIBMaxRecPhase = FWBitRangePhase (16, 19), + kFWBIBMaxROM = FWBitRange (20, 21), + kFWBIBMaxROMPhase = FWBitRangePhase (20, 21), + kFWBIBGeneration = FWBitRange (24, 27), + kFWBIBGenerationPhase = FWBitRangePhase (24, 27), + kFWBIBLinkSpeed = FWBitRange (29, 31), + kFWBIBLinkSpeedPhase = FWBitRangePhase (29, 31) +}; + +enum +{ + kConfigUnitSpecAppleA27 = 0x000a27, + kConfigUnitSpec1394TA1 = 0x00a02d, + + kConfigUnitSWVersMacintosh10 = 10, + kConfigUnitSWVersIIDC100 = 0x000100, + kConfigUnitSWVersIIDC101 = 0x000101, + kConfigUnitSWVersIIDC102 = 0x000102 +}; + + +// ================================================================= +// Isoch defines +// ================================================================= +#pragma mark - +#pragma mark ISOCH + +enum +{ + kFWIsochDataLength = FWBitRange (0, 15), + kFWIsochDataLengthPhase = FWBitRangePhase (0, 15), + + kFWIsochTag = FWBitRange (16, 17), + kFWIsochTagPhase = FWBitRangePhase (16, 17), + + kFWIsochChanNum = FWBitRange (18, 23), + kFWIsochChanNumPhase = FWBitRangePhase (18, 23), + + kFWIsochTCode = FWBitRange (24, 27), + kFWIsochTCodePhase = FWBitRangePhase (24, 27), + + kFWIsochSy = FWBitRange (28, 31), + kFWIsochSyPhase = FWBitRangePhase (28, 31) +}; + +#define CHAN_BIT(x) (((UInt64)1) << (63 - (x)) +#define CHAN_MASK(x) (~CHAN_BIT(X)) + +typedef enum +{ + kFWNeverMultiMode = 0, + kFWAllowMultiMode, + kFWSuggestMultiMode, + kFWAlwaysMultiMode, + + kFWDefaultIsochResourceFlags = kFWNeverMultiMode +} IOFWIsochResourceFlags ; + +enum +{ + kFWIsochChannelDefaultFlags = 0, + kFWIsochChannelDoNotResumeOnWake = BIT(1) +} ; + +typedef enum +{ + kFWIsochPortDefaultOptions = 0, + kFWIsochPortUseSeparateKernelThread = BIT(1), + kFWIsochEnableRobustness = BIT(2), + kFWIsochBigEndianUpdates = BIT(3), // private + kFWIsochRequireLastContext = BIT(4), // private +} IOFWIsochPortOptions ; + +// ================================================================= +// DCL opcode defs. +// ================================================================= +#pragma mark - +#pragma mark DCL OPCODES + +enum +{ + kFWDCLImmediateEvent = 0, + kFWDCLCycleEvent = 1, + kFWDCLSyBitsEvent = 2 +}; + +typedef enum +{ + kFWDCLInvalidNotification = 0 + , kFWDCLUpdateNotification = 1 + , kFWDCLModifyNotification = 2 + , kFWNuDCLModifyNotification = 3 + , kFWNuDCLModifyJumpNotification = 4 + , kFWNuDCLUpdateNotification = 5 +} IOFWDCLNotificationType ; + +enum +{ + kFWDCLOpDynamicFlag = BIT(16), + kFWDCLOpVendorDefinedFlag = BIT(17), + kFWDCLOpFlagMask = BitRange (16, 31), + kFWDCLOpFlagPhase = BitRangePhase (16, 31) +}; + +enum +{ + kDCLInvalidOp = 0, + kDCLSendPacketStartOp = 1, + //kDCLSendPacketWithHeaderStartOp = 2, // Deprecated legacy DCL opcode! Use NuDCL instead! + kDCLSendPacketOp = 3, + kDCLSendBufferOp = 4, // obsolete - do not use + kDCLReceivePacketStartOp = 5, + kDCLReceivePacketOp = 6, + kDCLReceiveBufferOp = 7, // obsolete - do not use + kDCLCallProcOp = 8, + kDCLLabelOp = 9, + kDCLJumpOp = 10, + kDCLSetTagSyncBitsOp = 11, + kDCLUpdateDCLListOp = 12, + kDCLTimeStampOp = 13, + kDCLPtrTimeStampOp = 14, + kDCLSkipCycleOp = 15, + + kDCLNuDCLLeaderOp = 20 // compilerData field contains NuDCLRef to start of NuDCL + // program. + // Should not need to use this directly. +}; + +#ifdef FW_OLD_DCL_DEFS + +//typedef struct DCLCommandStruct ; +//typedef void (DCLCallCommandProc)(DCLCommandStruct* command); + +#else + +//typedef struct DCLCommand ; +//typedef void (DCLCallCommandProc)(DCLCommand* command); + +#endif + +// ================================================================= +// DCL structs +// ================================================================= +#pragma mark - +#pragma mark DCL + +#ifdef __LP64__ +typedef void* DCLCallProcDataType; +#else +typedef UInt32 DCLCallProcDataType; +#endif + +#ifdef KERNEL + #ifdef __LP64__ + typedef void* DCLCompilerDataType; + #else + typedef UInt32 DCLCompilerDataType; + #endif +#else + typedef UInt32 DCLCompilerDataType; +#endif + +typedef struct DCLCommandStruct +{ + struct DCLCommandStruct * pNextDCLCommand; // Next DCL command. + DCLCompilerDataType compilerData; // Data for use by DCL compiler. + UInt32 opcode; // DCL opcode. + UInt32 operands[1]; // DCL operands (size varies) +} DCLCommand; + +typedef void (DCLCallCommandProc)(DCLCommand * command); + +typedef struct DCLTransferPacketStruct +{ + DCLCommand * pNextDCLCommand; // Next DCL command. + DCLCompilerDataType compilerData; // Data for use by DCL compiler. + UInt32 opcode; // DCL opcode. + void * buffer; // Packet buffer. + UInt32 size; // Buffer size. +} DCLTransferPacket ; + +typedef struct DCLTransferBufferStruct +{ + DCLCommand * pNextDCLCommand; // Next DCL command. + DCLCompilerDataType compilerData; // Data for use by DCL compiler. + UInt32 opcode; // DCL opcode. + void * buffer; // Buffer. + UInt32 size; // Buffer size. + UInt16 packetSize; // Size of packets to send. + UInt16 reserved; + UInt32 bufferOffset; // Current offset into buffer. +} DCLTransferBuffer ; + +typedef struct DCLCallProcStruct +{ + DCLCommand * pNextDCLCommand; // Next DCL command. + DCLCompilerDataType compilerData; // Data for use by DCL compiler. + UInt32 opcode; // DCL opcode. + DCLCallCommandProc * proc; // Procedure to call. + DCLCallProcDataType procData; // Data for use by called procedure. +} DCLCallProc; + +typedef struct DCLLabelStruct +{ + DCLCommand * pNextDCLCommand; // Next DCL command. + DCLCompilerDataType compilerData; // Data for use by DCL compiler. + UInt32 opcode; // DCL opcode. +} DCLLabel; + +typedef struct DCLJumpStruct +{ + DCLCommand * pNextDCLCommand; // Next DCL command. + DCLCompilerDataType compilerData; // Data for use by DCL compiler. + UInt32 opcode; // DCL opcode. + DCLLabel * pJumpDCLLabel; // DCL label to jump to. +} DCLJump; + +typedef struct DCLSetTagSyncBitsStruct +{ + DCLCommand * pNextDCLCommand; // Next DCL command. + DCLCompilerDataType compilerData; // Data for use by DCL compiler. + UInt32 opcode; // DCL opcode. + UInt16 tagBits; // Tag bits for following packets. + UInt16 syncBits; // Sync bits for following packets. +} DCLSetTagSyncBits; + +typedef struct DCLUpdateDCLListStruct +{ + DCLCommand * pNextDCLCommand; // Next DCL command. + DCLCompilerDataType compilerData; // Data for use by DCL compiler. + UInt32 opcode; // DCL opcode. + DCLCommand ** dclCommandList; // List of DCL commands to update. + UInt32 numDCLCommands; // Number of DCL commands in list. +} DCLUpdateDCLList; + +typedef struct DCLTimeStampStruct +{ + DCLCommand * pNextDCLCommand; // Next DCL command. + DCLCompilerDataType compilerData; // Data for use by DCL compiler. + UInt32 opcode; // DCL opcode. + UInt32 timeStamp; // Time stamp. +} DCLTimeStamp; + +typedef struct DCLPtrTimeStampStruct +{ + DCLCommand * pNextDCLCommand; // Next DCL command. + DCLCompilerDataType compilerData; // Data for use by DCL compiler. + UInt32 opcode; // DCL opcode. + UInt32 * timeStampPtr; // Where to store the time stamp. +} DCLPtrTimeStamp ; + +typedef struct +{ + DCLCommand * pNextDCLCommand ; // unused - always NULL + DCLCompilerDataType compilerData; // Data for use by DCL compiler. + UInt32 opcode ; // must be kDCLNuDCLLeaderOp + void* program ; // NuDCL program here... +} DCLNuDCLLeader ; + +#ifdef FW_OLD_DCL_DEFS + +// should not use these... + +typedef DCLCommand* DCLCommandPtr ; +typedef DCLTransferBuffer* DCLTransferBufferPtr ; +typedef DCLTransferPacket* DCLTransferPacketPtr ; +typedef DCLCallProc* DCLCallProcPtr ; +typedef DCLLabel* DCLLabelPtr ; +typedef DCLJump* DCLJumpPtr ; +typedef DCLSetTagSyncBits* DCLSetTagSyncBitsPtr ; +typedef DCLUpdateDCLList* DCLUpdateDCLListPtr ; +typedef DCLTimeStamp* DCLTimeStampPtr ; +typedef DCLPtrTimeStamp* DCLPtrTimeStampPtr ; +typedef DCLCallCommandProc* DCLCallCommandProcPtr ; + +#endif + + +// ================================================================= +// User-Lib Export DCL structs - Thses structus are used to pass +// a user-created legacy DCL program down into kernel space. These +// structs allow support for both 32-bit and 64-bit user-space clients. +// These structs should only be used internally. They are not for +// clients to create DCL programs with. +// ================================================================= + +typedef struct UserExportDCLCommandStruct +{ + mach_vm_address_t pClientDCLStruct; // A pointer to the client's DCL struct + mach_vm_address_t pNextDCLCommand; // Next DCL command. + uint64_t compilerData; // Data for use by DCL compiler. + UInt32 opcode; // DCL opcode. + UInt32 operands[1]; // DCL operands (size varies) +} __attribute__ ((packed)) UserExportDCLCommand; + +typedef void (UserExportDCLCallCommandProc)(UserExportDCLCommand * command); + +typedef struct UserExportDCLTransferPacketStruct +{ + mach_vm_address_t pClientDCLStruct; // A pointer to the client's DCL struct + mach_vm_address_t pNextDCLCommand; // Next DCL command. + uint64_t compilerData; // Data for use by DCL compiler. + UInt32 opcode; // DCL opcode. + mach_vm_address_t buffer; // Packet buffer. + UInt32 size; // Buffer size. +} __attribute__ ((packed)) UserExportDCLTransferPacket ; + +typedef struct UserExportDCLTransferBufferStruct +{ + mach_vm_address_t pClientDCLStruct; // A pointer to the client's DCL struct + mach_vm_address_t pNextDCLCommand; // Next DCL command. + uint64_t compilerData; // Data for use by DCL compiler. + UInt32 opcode; // DCL opcode. + mach_vm_address_t buffer; // Buffer. + UInt32 size; // Buffer size. + UInt16 packetSize; // Size of packets to send. + UInt16 reserved; + UInt32 bufferOffset; // Current offset into buffer. +} __attribute__ ((packed)) UserExportDCLTransferBuffer ; + +typedef struct UserExportDCLCallProcStruct +{ + mach_vm_address_t pClientDCLStruct; // A pointer to the client's DCL struct + mach_vm_address_t pNextDCLCommand; // Next DCL command. + uint64_t compilerData; // Data for use by DCL compiler. + UInt32 opcode; // DCL opcode. + mach_vm_address_t proc; // Procedure to call. + uint64_t procData; // Data for use by called procedure. +} __attribute__ ((packed)) UserExportDCLCallProc; + +typedef struct UserExportDCLLabelStruct +{ + mach_vm_address_t pClientDCLStruct; // A pointer to the client's DCL struct + mach_vm_address_t pNextDCLCommand; // Next DCL command. + uint64_t compilerData; // Data for use by DCL compiler. + UInt32 opcode; // DCL opcode. +} __attribute__ ((packed)) UserExportDCLLabel; + +typedef struct UserExportDCLJumpStruct +{ + mach_vm_address_t pClientDCLStruct; // A pointer to the client's DCL struct + mach_vm_address_t pNextDCLCommand; // Next DCL command. + uint64_t compilerData; // Data for use by DCL compiler. + UInt32 opcode; // DCL opcode. + mach_vm_address_t pJumpDCLLabel; // DCL label to jump to. +} __attribute__ ((packed)) UserExportDCLJump; + +typedef struct UserExportDCLSetTagSyncBitsStruct +{ + mach_vm_address_t pClientDCLStruct; // A pointer to the client's DCL struct + mach_vm_address_t pNextDCLCommand; // Next DCL command. + uint64_t compilerData; // Data for use by DCL compiler. + UInt32 opcode; // DCL opcode. + UInt16 tagBits; // Tag bits for following packets. + UInt16 syncBits; // Sync bits for following packets. +} __attribute__ ((packed)) UserExportDCLSetTagSyncBits; + +typedef struct UserExportDCLUpdateDCLListStruct +{ + mach_vm_address_t pClientDCLStruct; // A pointer to the client's DCL struct + mach_vm_address_t pNextDCLCommand; // Next DCL command. + uint64_t compilerData; // Data for use by DCL compiler. + UInt32 opcode; // DCL opcode. + mach_vm_address_t dclCommandList; // List of DCL commands to update. + UInt32 numDCLCommands; // Number of DCL commands in list. +} __attribute__ ((packed)) UserExportDCLUpdateDCLList; + +typedef struct UserExportDCLTimeStampStruct +{ + mach_vm_address_t pClientDCLStruct; // A pointer to the client's DCL struct + mach_vm_address_t pNextDCLCommand; // Next DCL command. + uint64_t compilerData; // Data for use by DCL compiler. + UInt32 opcode; // DCL opcode. + UInt32 timeStamp; // Time stamp. +} __attribute__ ((packed)) UserExportDCLTimeStamp; + +typedef struct UserExportDCLPtrTimeStampStruct +{ + mach_vm_address_t pClientDCLStruct; // A pointer to the client's DCL struct + mach_vm_address_t pNextDCLCommand; // Next DCL command. + uint64_t compilerData; // Data for use by DCL compiler. + UInt32 opcode; // DCL opcode. + mach_vm_address_t timeStampPtr; // Where to store the time stamp. +} __attribute__ ((packed)) UserExportDCLPtrTimeStamp ; + +typedef struct +{ + mach_vm_address_t pClientDCLStruct; // A pointer to the client's DCL struct + mach_vm_address_t pNextDCLCommand ; // unused - always NULL + uint64_t compilerData; // Data for use by DCL compiler. + UInt32 opcode ; // must be kDCLNuDCLLeaderOp + mach_vm_address_t program ; // NuDCL program here... +} __attribute__ ((packed)) UserExportDCLNuDCLLeader ; + + +// ================================================================= +// NuDCL +// ================================================================= +#pragma mark - +#pragma mark NUDCL + +typedef struct __NuDCL * NuDCLRef ; +typedef NuDCLRef NuDCLSendPacketRef ; +typedef NuDCLRef NuDCLSkipCycleRef ; +typedef NuDCLRef NuDCLReceivePacketRef ; + +typedef void (*NuDCLCallback)( void* refcon, NuDCLRef dcl ); + +typedef enum +{ + kNuDCLDynamic = BIT( 1 ), + kNuDCLUpdateBeforeCallback = BIT( 2 ) + +} NuDCLFlags ; + +// ================================================================= +// Miscellaneous +// ================================================================= +#pragma mark - +#pragma mark MISCELLANEOUS + +typedef void* FWClientCommandID ; + +typedef struct IOFireWireSessionRefOpaqueStuct* IOFireWireSessionRef ; + +// +// bus management constants. +// + +enum +{ + kFWBusManagerArbitrationTimeoutDuration = 625 // durationMillisecond +}; + +// +// bus characteristics. +// + +enum +{ + kFWMaxBusses = 1023, + kFWMaxNodesPerBus = 63, + kFWMaxNodeHops = 16 +}; + +/*! @enum NodeFlags + + @abstract Flags that specify characteristics of the FireWire device node. + + @constant kIOFWDisablePhysicalAccess Disable physical memory access + + @constant kIOFWDisableAllPhysicalAccess Disable all physical memory access + + @constant kIOFWEnableRetryOnAckD Enable retry on Ack D + + @constant kIOFWLimitAsyncPacketSize Limit async packet size + + @constant kIOFWDisablePhyOnSleep Disable Phy, when machine is in Sleep mode + + @constant kIOFWMustBeRoot Attempt to make this device root, There is no guarentee Mac OS will succeed in making the device + root. + + @constant kIOFWMustNotBeRoot Attempt to prevent this device from being root, There is no guarentee Mac OS will succeed in preventing the device + from being root. + + @constant kIOFWMustHaveGap63 Attempt to ensure the gap count is 63, when this device is on the bus. Gap 63 reduces bus performance significantly, + so this flag should be used only when absolutely necessary. There is no guarentee Mac OS will succeed in forcing + the gap count to 63. +*/ +enum +{ + kIOFWDisablePhysicalAccess = (1 << 0), + kIOFWDisableAllPhysicalAccess = (1 << 1), + kIOFWEnableRetryOnAckD = (1 << 2), + kIOFWLimitAsyncPacketSize = (1 << 3), + kIOFWDisablePhyOnSleep = (1 << 4), + kIOFWMustBeRoot = (1 << 5), + kIOFWMustNotBeRoot = (1 << 6), + kIOFWMustHaveGap63 = (1 << 7) +}; + +// +// write flags +// + +enum IOFWWriteFlags +{ + kIOFWWriteFlagsNone = 0x00000000, + kIOFWWriteFlagsDeferredNotify = 0x00000001, + kIOFWWriteFastRetryOnBusy = 0x00000002, + kIOFWWriteBlockRequest = 0x00000004, // force a block request +}; + +// +// read flags +// + +enum IOFWReadFlags +{ + kIOFWReadFlagsNone = 0x00000000, + kIOFWReadBlockRequest = 0x00000004, // force a block request + kIOFWReadPingTime = 0x00000008 // ping time +}; + +// +// security modes +// + +enum IOFWSecurityMode +{ + kIOFWSecurityModeNormal = 0, + kIOFWSecurityModeSecure = 1, + kIOFWSecurityModeSecurePermanent = 2 +}; + +// +// physical access settings +// + +enum IOFWPhysicalAccessMode +{ + kIOFWPhysicalAccessEnabled = 0, + kIOFWPhysicalAccessDisabled = 1, + kIOFWPhysicalAccessDisabledForGeneration = 2 +}; + +enum +{ + kIOFWSpecID_AAPL = 0xa27, + kIOFWSWVers_KPF = 0x40 +}; + +// old style bit defs +#ifdef FW_OLD_BIT_DEFS + + #define kBit0 BIT(0) + #define kBit1 BIT(1) + #define kBit2 BIT(2) + #define kBit3 BIT(3) + #define kBit4 BIT(4) + #define kBit5 BIT(5) + #define kBit6 BIT(6) + #define kBit7 BIT(7) + #define kBit8 BIT(8) + #define kBit9 BIT(9) + #define kBit10 BIT(10) + #define kBit11 BIT(11) + #define kBit12 BIT(12) + #define kBit13 BIT(13) + #define kBit14 BIT(14) + #define kBit15 BIT(15) + #define kBit16 BIT(16) + #define kBit17 BIT(17) + #define kBit18 BIT(18) + #define kBit19 BIT(19) + #define kBit20 BIT(20) + #define kBit21 BIT(21) + #define kBit22 BIT(22) + #define kBit23 BIT(23) + #define kBit24 BIT(24) + #define kBit25 BIT(25) + #define kBit26 BIT(26) + #define kBit27 BIT(27) + #define kBit28 BIT(28) + #define kBit29 BIT(29) + #define kBit30 BIT(30) + #define kBit31 BIT(31) + +#endif + +#endif //__IOFireWireFamilyCommon_H__ Index: branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWDCLProgram.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWDCLProgram.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWDCLProgram.h (revision 885) @@ -0,0 +1,133 @@ +/* + * Copyright (c) 1998-2002 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@ + */ +/* + * Copyright (c) 1999-2002 Apple Computer, Inc. All rights reserved. + * + * HISTORY + * + */ + + +#ifndef _IOKIT_IOFWDCLPROGRAM_H +#define _IOKIT_IOFWDCLPROGRAM_H + +#include +#include +#include +#include + +/*! @class IODCLProgram +*/ +class IODCLProgram : public OSObject +{ + OSDeclareAbstractStructors(IODCLProgram) + + private : + + void * reserved0 ;//fDCLTaskToKernel; + void * reserved1 ;//fDataTaskToKernel; + void * reserved2 ;//fDataBase; + void * reserved3 ;// IOMemoryDescriptor * fDCLDesc; + IOMemoryMap * fBufferMem ; + void * reserved5 ;// IOMemoryCursor * fDataCursor; + + protected: + + /*! @struct ExpansionData + @discussion This structure will be used to expand the capablilties of the class in the future. + */ + struct ExpansionData + { + IOFWIsochResourceFlags resourceFlags ; + }; + + /*! @var reserved + Reserved for future use. (Internal use only) */ + ExpansionData * fExpansionData ; + + public : + + virtual void setIsochResourceFlags ( IOFWIsochResourceFlags flags ) ; // formerly getPhysicalSegs() + IOFWIsochResourceFlags getIsochResourceFlags () const ; + + protected: + + virtual void free () ; + + public: + + virtual bool init ( IOFireWireBus::DCLTaskInfo * info = NULL ) ; + virtual IOReturn allocateHW ( + IOFWSpeed speed, + UInt32 chan) = 0; + virtual IOReturn releaseHW () = 0; + virtual IOReturn compile ( + IOFWSpeed speed, + UInt32 chan) = 0; + virtual IOReturn notify ( + IOFWDCLNotificationType notificationType, + DCLCommand ** dclCommandList, + UInt32 numDCLCommands ) = 0; + virtual IOReturn start () = 0; + virtual void stop () = 0; + virtual IOReturn pause (); + virtual IOReturn resume (); + + virtual void setForceStopProc( + IOFWIsochChannel::ForceStopNotificationProc proc, + void * refCon, + IOFWIsochChannel * channel ) ; + protected : + + void generateBufferMap( DCLCommand * program ) ; + IOReturn virtualToPhysical( + IOVirtualRange ranges[], + unsigned rangeCount, + IOMemoryCursor::IOPhysicalSegment outSegments[], + unsigned & outPhysicalSegmentCount, + unsigned maxSegments ) ; + + public : + + IOMemoryMap * getBufferMap() const ; + + public : + + // close/open isoch workloop gate... + // clients should not need to call these. + virtual void closeGate() = 0 ; + virtual void openGate() = 0 ; + + virtual IOReturn synchronizeWithIO() = 0 ; + + private: + + OSMetaClassDeclareReservedUsed(IODCLProgram, 0); + OSMetaClassDeclareReservedUsed(IODCLProgram, 1); + OSMetaClassDeclareReservedUnused(IODCLProgram, 2); + OSMetaClassDeclareReservedUnused(IODCLProgram, 3); + OSMetaClassDeclareReservedUnused(IODCLProgram, 4); + +}; + +#endif /* ! _IOKIT_IOFWDCLPROGRAM_H */ + Index: branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOConfigDirectory.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOConfigDirectory.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOConfigDirectory.h (revision 885) @@ -0,0 +1,182 @@ +/* + * Copyright (c) 1998-2002 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 __IOCONFIGDIRECTORY_H__ +#define __IOCONFIGDIRECTORY_H__ + +#include +#include + +#include + +class OSData; +class OSString; +class OSIterator; +class IOFireWireDevice; + +/*! @class IOConfigDirectory +*/ +class IOConfigDirectory : public OSObject +{ + OSDeclareAbstractStructors(IOConfigDirectory); + +protected: + int fStart; // Offset into ROM of start of this dir + int fType; // Directory type + int fNumEntries; // In directory + +/*! @struct ExpansionData + @discussion This structure will be used to expand the capablilties of the class in the future. + */ + struct ExpansionData { }; + +/*! @var reserved + Reserved for future use. (Internal use only) */ + ExpansionData *reserved; + + virtual bool initWithOffset(int start, int type); + + virtual const UInt32 *getBase() = 0; + virtual IOReturn createIterator(UInt32 testVal, UInt32 testMask, + OSIterator *&iterator); + virtual IOConfigDirectory *getSubDir(int start, int type) = 0; + +public: + /*! + @function update + makes sure that the ROM has at least the specified capacity, + and that the ROM is uptodate from its start to at least the + specified quadlet offset. + @result kIOReturnSuccess if the specified offset is now + accessable at romBase[offset]. + */ + virtual IOReturn update(UInt32 offset, const UInt32 *&romBase) = 0; + + /*! + @function getKeyType + Gets the data type for the specified key + @param type on return, set to the data type + @result kIOReturnSuccess if the key exists in the dictionary + */ + virtual IOReturn getKeyType(int key, IOConfigKeyType &type); + /*! + @function getKeyValue + Gets the value for the specified key, in a variety of forms. + @param value on return, set to the data type + @param text if non-zero, on return points to the + string description of the field, or NULL if no text found. + @result kIOReturnSuccess if the key exists in the dictionary + and is of a type appropriate for the value parameter + @param value reference to variable to store the entry's value + */ + virtual IOReturn getKeyValue(int key, UInt32 &value, OSString** text = NULL); + virtual IOReturn getKeyValue(int key, OSData *&value, + OSString** text = NULL); + virtual IOReturn getKeyValue(int key, IOConfigDirectory *&value, + OSString** text = NULL); + virtual IOReturn getKeyOffset(int key, FWAddress &value, + OSString** text = NULL); + + + /*! + @function getIndexType + Gets the data type for entry at the specified index + @param type on return, set to the data type + @result kIOReturnSuccess if the index exists in the dictionary + */ + virtual IOReturn getIndexType(int index, IOConfigKeyType &type); + /*! + @function getIndexKey + Gets the key for entry at the specified index + @param key on return, set to the key + @result kIOReturnSuccess if the index exists in the dictionary + */ + virtual IOReturn getIndexKey(int index, int &key); + + /*! + @function getIndexValue + Gets the value at the specified index of the directory, + in a variety of forms. + @param type on return, set to the data type + @result kIOReturnSuccess if the index exists in the dictionary + and is of a type appropriate for the value parameter + @param value reference to variable to store the entry's value + */ + virtual IOReturn getIndexValue(int index, UInt32 &value); + virtual IOReturn getIndexValue(int index, OSData *&value); + virtual IOReturn getIndexValue(int index, OSString *&value); + virtual IOReturn getIndexValue(int index, IOConfigDirectory *&value); + virtual IOReturn getIndexOffset(int index, FWAddress &value); + virtual IOReturn getIndexOffset(int index, UInt32 &value); + + /*! + @function getIndexEntry + Gets the entry at the specified index of the directory, + as a raw UInt32. + @param entry on return, set to the entry value + @result kIOReturnSuccess if the index exists in the dictionary + @param value reference to variable to store the entry's value + */ + virtual IOReturn getIndexEntry(int index, UInt32 &value); + + /*! + @function getSubdirectories + Creates an iterator over the subdirectories of the directory. + @param iterator on return, set to point to an OSIterator + @result kIOReturnSuccess if the iterator could be created + */ + virtual IOReturn getSubdirectories(OSIterator *&iterator); + + /*! + @function getKeySubdirectories + Creates an iterator over subdirectories of a given type of the directory. + @param key type of subdirectory to iterate over + @param iterator on return, set to point to an OSIterator + @result kIOReturnSuccess if the iterator could be created + */ + virtual IOReturn getKeySubdirectories(int key, OSIterator *&iterator); + + int getType() const; + + int getNumEntries() const; + +protected: + + virtual const UInt32 * lockData( void ) = 0; + virtual void unlockData( void ) = 0; + virtual IOReturn updateROMCache( UInt32 offset, UInt32 length ) = 0; + virtual IOReturn checkROMState( void ) = 0; + +private: + OSMetaClassDeclareReservedUnused(IOConfigDirectory, 0); + OSMetaClassDeclareReservedUnused(IOConfigDirectory, 1); + OSMetaClassDeclareReservedUnused(IOConfigDirectory, 2); + OSMetaClassDeclareReservedUnused(IOConfigDirectory, 3); + OSMetaClassDeclareReservedUnused(IOConfigDirectory, 4); + OSMetaClassDeclareReservedUnused(IOConfigDirectory, 5); + OSMetaClassDeclareReservedUnused(IOConfigDirectory, 6); + OSMetaClassDeclareReservedUnused(IOConfigDirectory, 7); + OSMetaClassDeclareReservedUnused(IOConfigDirectory, 8); + +}; + +#endif /* __IOCONFIGDIRECTORY_H__ */ Index: branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFireWireLocalNode.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFireWireLocalNode.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFireWireLocalNode.h (revision 885) @@ -0,0 +1,143 @@ +/* + * IOFireWireLocalNode.h + * IOFireWireFamily + * + * Created by Niels on Fri Aug 16 2002. + * Copyright (c) 2002 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@ + */ +/* + $Log: IOFireWireLocalNode.h,v $ + Revision 1.8 2009/03/26 22:45:17 calderon + User client fails to terminate with unexpected consuequences + + Revision 1.7 2008/11/14 00:17:12 arulchan + fix for rdar://5939334 + + Revision 1.6 2005/02/18 22:56:53 gecko1 + 3958781 Q45C EVT: FireWire ASP reporter says port speed is 800 Mb/sec + + Revision 1.5 2003/02/20 02:00:12 collin + *** empty log message *** + + Revision 1.4 2003/02/17 21:47:53 collin + *** empty log message *** + + Revision 1.3 2002/10/18 23:29:44 collin + fix includes, fix cast which fails on new compiler + + Revision 1.2 2002/09/25 00:27:24 niels + flip your world upside-down + +*/ + +// public +#import + +class IOFireWireLocalNode; + +#pragma mark - + +/*! + @class IOFireWireLocalNodeAux +*/ + +class IOFireWireLocalNodeAux : public IOFireWireNubAux +{ + OSDeclareDefaultStructors(IOFireWireLocalNodeAux) + + friend class IOFireWireLocalNode; + +protected: + + /*! + @struct ExpansionData + @discussion This structure will be used to expand the capablilties of the class in the future. + */ + + struct ExpansionData { }; + + /*! + @var reserved + Reserved for future use. (Internal use only) + */ + + ExpansionData * reserved; + + virtual bool init( IOFireWireLocalNode * primary ); + virtual void free(); + +private: + OSMetaClassDeclareReservedUnused(IOFireWireLocalNodeAux, 0); + OSMetaClassDeclareReservedUnused(IOFireWireLocalNodeAux, 1); + OSMetaClassDeclareReservedUnused(IOFireWireLocalNodeAux, 2); + OSMetaClassDeclareReservedUnused(IOFireWireLocalNodeAux, 3); + +}; + +#pragma mark - + +/*! @class IOFireWireLocalNode +*/ + +class IOFireWireLocalNode : public IOFireWireNub +{ + OSDeclareDefaultStructors(IOFireWireLocalNode) + + friend class IOFireWireLocalNodeAux; + + /*------------------Useful info about device (also available in the registry)--------*/ +protected: + + /*-----------Methods provided to FireWire device clients-------------*/ +public: + + // Set up properties affected by bus reset + virtual void setNodeProperties(UInt32 generation, UInt16 nodeID, UInt32 *selfIDs, int numIDs, IOFWSpeed maxSpeed ); + + /* + * Standard nub initialization + */ + virtual bool init(OSDictionary * propTable); + virtual bool attach(IOService * provider ); + + virtual void handleClose( IOService * forClient, + IOOptionBits options ) ; + virtual bool handleOpen( IOService * forClient, + IOOptionBits options, + void * arg ) ; + virtual bool handleIsOpen( const IOService * forClient ) const; + + /* + * Trick method to create protocol user clients + */ + virtual IOReturn setProperties( OSObject * properties ); + +protected: + + virtual IOFireWireNubAux * createAuxiliary( void ); + +public: + virtual IOReturn message( UInt32 type, IOService * provider, void * argument ); + virtual void free(); + +protected: + OSSet * fOpenClients; +}; Index: branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWUtils.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWUtils.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWUtils.h (revision 885) @@ -0,0 +1,32 @@ +/* + * IOFWUtils.h + * IOFireWireFamily + * + * Created by Niels on Fri Aug 16 2002. + * Copyright (c) 2002 Apple Computer, Inc. All rights reserved. + * + */ + +#import + +//////////////////////////////////////////////////////////////////////////////// +// +// Useful FireWire utility functions. +// + +#ifdef __cplusplus +extern "C" { +#endif + +UInt16 FWComputeCRC16(const UInt32 *pQuads, UInt32 numQuads); +UInt16 FWUpdateCRC16(UInt16 crc16, UInt32 quad); + +UInt32 AddFWCycleTimeToFWCycleTime( UInt32 cycleTime1, UInt32 cycleTime2 ); +UInt32 SubtractFWCycleTimeFromFWCycleTime( UInt32 cycleTime1, UInt32 cycleTime2); + +void IOFWGetAbsoluteTime( AbsoluteTime * result ); + +#ifdef __cplusplus +} +#endif + Index: branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWRegs.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWRegs.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWRegs.h (revision 885) @@ -0,0 +1,73 @@ +/* +* Copyright (c) 1998-2002 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@ +*/ +/* + File: IOFWRegs.h + + Copyright: © 1996-1999 by Apple Computer, Inc., all rights reserved. + +*/ + +#ifndef __IOFWREGS_H__ +#define __IOFWREGS_H__ + +#include + +#ifndef NEW_ERROR_CODES + +// +// (!) The following error codes are obsolete... +// Please use the error codes defined in IOFireWireFamilyCommon.h +// + +enum { + inUseErr = -4160, // Item already in use + notFoundErr = -4161, // Item not found + timeoutErr = -4162, // Something timed out + busReconfiguredErr = -4163, // Bus was reconfigured + invalidIDTypeErr = -4166, // Given ID is of an invalid type for the requested operation. + alreadyRegisteredErr = -4168, // Item has already been registered. + disconnectedErr = -4169, // Target of request has been disconnected. + retryExceededErr = -4170, // Retry limit was exceeded. + addressRangeErr = -4171, // Address is not in range. + addressAlignmentErr = -4172, // Address is not of proper alignment. + + multipleTalkerErr = -4180, // Tried to install multiple talkers + channelActiveErr = -4181, // Operation not permitted when channel is active + noListenerOrTalkerErr = -4182, // Every isochronous channel must have one talker and at least + // one listener + noChannelsAvailableErr = -4183, // No supported isochronous channels are available + channelNotAvailableErr = -4184, // Required channel was not available. + invalidIsochPortIDErr = -4185, // An isochronous port ID is invalid. + invalidFWReferenceTypeErr = -4186, // Operation does not support type of given reference ID + separateBusErr = -4187, // Two or more entities are on two or more busses and cannot be associated with eachother. + badSelfIDsErr = -4188, // Received self IDs are bad. + +//zzz Do we own these next ID numbers? + cableVoltageTooLowErr = -4190, // Cable power below device's minimum voltage + cablePowerInsufficientErr = -4191 // Can't grant power request at this time +}; + + +#endif //NEW_ERROR_CODES + +#endif /* __IOFWREGS_H */ + Index: branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWAddressSpace.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWAddressSpace.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWAddressSpace.h (revision 885) @@ -0,0 +1,331 @@ +/* + * Copyright (c) 1998-2002 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@ + */ + +/* + * + * IOFWAddressSpace.h + * + * Classes which describe addresses in the local node which are accessable to other nodes + * via firewire asynchronous read/write/lock requests. + */ + +#ifndef _IOKIT_IOFWADDRESSSPACE_H +#define _IOKIT_IOFWADDRESSSPACE_H + +#include +#include + +class IOFireWireDevice; +class IOFireWireBus; +class IOFireWireController; + +typedef void * IOFWRequestRefCon; + +/*! @function FWWriteCallback + @abstract Callback called when a write request packet is received for + a 'virtual' firewire address. + @param device is the node originating the request + @param speed is the FireWire speed of the request, update it if you need to control + the speed of the reply, otherwise the response will be the same speed. + @param addr is the address the device is requesting to write to + @param len is the number of bytes to write + @param buf contains the packet data + @param requestRefcon refcon Can be queried for extra info about the request, + using IOFireWireController::isLockRequest(), isQuadRequest() + @result return: + kFWResponseComplete = 0, OK + kFWResponseConflictError = 4, Resource conflict, may retry + kFWResponseDataError = 5, Data not available + kFWResponseTypeError = 6, Operation not supported + kFWResponseAddressError = 7 Address not valid in target device */ +typedef UInt32 (*FWWriteCallback)(void *refcon, UInt16 nodeID, IOFWSpeed &speed, + FWAddress addr, UInt32 len, const void *buf, IOFWRequestRefCon requestRefcon); + +/*! @function FWReadCallback + @abstract Callback called when a read request packet is received for + a 'virtual' firewire address. + @param nodeID is the node originating the request + @param speed is the FireWire speed of the request, update it if you need to control + the speed of the reply, otherwise the response will be the same speed. + @param addr is the address the device is requesting to read from + @param len is the number of bytes to read + @param buf contains the packet data + @param offset on return points to the offset into *buf of the packet data + @param requestRefcon refcon to pass back if sending a delayed response. Also can be queried + for extra info about the request + @result return: + kFWResponsePending = -1, Pseudo response, real response sent later. + kFWResponseComplete = 0, OK! + kFWResponseConflictError = 4, Resource conflict, may retry + kFWResponseDataError = 5, Data not available + kFWResponseTypeError = 6, Operation not supported + kFWResponseAddressError = 7 Address not valid in target device + + A return of kFWResponsePending should be followed at some later time by a call to + IOFireWireController::asyncReadResponse */ +typedef UInt32 (*FWReadCallback)(void *refcon, UInt16 nodeID, IOFWSpeed &speed, + FWAddress addr, UInt32 len, IOMemoryDescriptor **buf, + IOByteCount * offset, IOFWRequestRefCon requestRefcon); + +class IOFWAddressSpace; + +#pragma mark - + +/*! @class IOFWAddressSpaceAux + @discussion An IOFWAddressSpaceAux is for internal use only. You should never subclass IOFWAddressSpaceAux +*/ + +class IOFWAddressSpaceAux : public OSObject +{ + OSDeclareDefaultStructors(IOFWAddressSpaceAux) + + friend class IOFWAddressSpace; + +protected: + + IOFWAddressSpace * fPrimary; + IOFireWireController * fControl; + + OSSet * fTrustedNodeSet; + OSIterator * fTrustedNodeSetIterator; + + bool fExclusive; + + /*! + @struct ExpansionData + @discussion This structure will be used to expand the capablilties of the class in the future. + */ + + struct ExpansionData { }; + + /*! + @var reserved + Reserved for future use. (Internal use only) + */ + + ExpansionData * reserved; + + virtual bool init( IOFWAddressSpace * primary ); + virtual void free(); + + virtual bool isTrustedNode( UInt16 nodeID ); + virtual void addTrustedNode( IOFireWireDevice * device ); + virtual void removeTrustedNode( IOFireWireDevice * device ); + virtual void removeAllTrustedNodes( void ); + + bool isExclusive( void ); + void setExclusive( bool exclusive ); + + virtual bool intersects( IOFWAddressSpace * space ); + +private: + OSMetaClassDeclareReservedUsed(IOFWAddressSpaceAux, 0); + OSMetaClassDeclareReservedUnused(IOFWAddressSpaceAux, 1); + OSMetaClassDeclareReservedUnused(IOFWAddressSpaceAux, 2); + OSMetaClassDeclareReservedUnused(IOFWAddressSpaceAux, 3); + OSMetaClassDeclareReservedUnused(IOFWAddressSpaceAux, 4); + OSMetaClassDeclareReservedUnused(IOFWAddressSpaceAux, 5); + OSMetaClassDeclareReservedUnused(IOFWAddressSpaceAux, 6); + OSMetaClassDeclareReservedUnused(IOFWAddressSpaceAux, 7); + OSMetaClassDeclareReservedUnused(IOFWAddressSpaceAux, 8); + OSMetaClassDeclareReservedUnused(IOFWAddressSpaceAux, 9); + +}; + +#pragma mark - + +/* + * Base class for FireWire address space objects + */ + +/*! + @class IOFWAddressSpace +*/ + +class IOFWAddressSpace : public OSObject +{ + OSDeclareAbstractStructors(IOFWAddressSpace) + + friend class IOFWAddressSpaceAux; + +protected: + + IOFireWireController *fControl; + + /*! + @struct ExpansionData + @discussion This structure will be used to expand the capablilties of the class in the future. + */ + + struct ExpansionData + { + IOFWAddressSpaceAux * fAuxiliary; + }; + + /*! + @var reserved + Reserved for future use. (Internal use only) + */ + + ExpansionData * fIOFWAddressSpaceExpansion; + + virtual bool init(IOFireWireBus *bus); + virtual void free(); + +public: + + /*! @function doRead + @abstract An abstract method for processing an address space read request + @param nodeID FireWire Read from nodeID. + @param speed at this 'speed'. + @param addr with FireWire address 'addr'. + @param len read 'len' bytes from nodeID. + @param buf points to a memory descriptor containing the packet data. + @param offset start from this 'offset' in 'buf'. + @param refcon Can be queried for extra info about the request. + @result UIn32 returns kFWResponseComplete on success */ + virtual UInt32 doRead(UInt16 nodeID, IOFWSpeed &speed, FWAddress addr, UInt32 len, + IOMemoryDescriptor **buf, IOByteCount * offset, + IOFWRequestRefCon refcon) = 0; + + /*! @function doWrite + @abstract An abstract method for processing an address space write request + @param nodeID FireWire Write to nodeID. + @param speed at this 'speed'. + @param addr with FireWire address 'addr'. + @param len write 'len' bytes to nodeID. + @param buf obtain bytes from location given by 'buf'. + @param refcon Can be queried for extra info about the request. + @result UIn32 returns kFWResponseComplete on success */ + virtual UInt32 doWrite(UInt16 nodeID, IOFWSpeed &speed, FWAddress addr, UInt32 len, + const void *buf, IOFWRequestRefCon refcon) = 0; + + /*! @function doLock + @abstract A method for processing a lock request. + @param nodeID FireWire Lock request for nodeID. + @param speed at this 'speed'. + @param addr with FireWire address 'addr'. + @param inlen 'inlen' bytes to use. + @param newVal new value to write at 'addr' location . + @param outLen 'outLen' bytes for result. + @param oldVal old value read from 'addr' location. + @param extType Type like kFWExtendedTCodeCompareSwap. + @param refcon Can be queried for extra info about the request. + @result UIn32 returns kFWResponseComplete on success */ + virtual UInt32 doLock(UInt16 nodeID, IOFWSpeed &speed, FWAddress addr, UInt32 inlen, + const UInt32 *newVal, UInt32 &outLen, UInt32 *oldVal, + UInt32 extType, IOFWRequestRefCon refcon); + + /*! @function activate + @abstract Address space is ready for handling requests. + @result IOReturn + */ + virtual IOReturn activate(); + + /*! @function deactivate + @abstract Address space request handler is disabled. + @result none + */ + virtual void deactivate(); + + /*! @function contains + @abstract returns number of bytes starting at addr in this space + @result 0 if it doesn't contain the address + */ + virtual UInt32 contains(FWAddress addr); + + /*! @function isTrustedNode + @abstract returns true if the node is added as a trusted node + @param nodeID is the nodeID to verify whether its trusted. + @result false if nodeID is not trusted + */ + inline bool isTrustedNode( UInt16 nodeID ) + { return fIOFWAddressSpaceExpansion->fAuxiliary->isTrustedNode( nodeID ); } + + /*! @function addTrustedNode + @abstract Add a trusted node. + @param device object pointing to a FireWire node on the bus. + @result none + */ + inline void addTrustedNode( IOFireWireDevice * device ) + { fIOFWAddressSpaceExpansion->fAuxiliary->addTrustedNode( device ); } + + /*! @function removeTrustedNode + @abstract Remove a trusted node. + @param device object pointing to a FireWire node on the bus. + @result none + */ + inline void removeTrustedNode( IOFireWireDevice * device ) + { fIOFWAddressSpaceExpansion->fAuxiliary->removeTrustedNode( device ); } + + /*! @function removeAllTrustedNodes + @abstract Remove all trusted nodes. + @result none + */ + inline void removeAllTrustedNodes( void ) + { fIOFWAddressSpaceExpansion->fAuxiliary->removeAllTrustedNodes(); } + + /*! @function isExclusive + @abstract Checks if an address space wants exclusive control of its address range + @result True if the address space is marked exclusive false otherwise + */ + + inline bool isExclusive( void ) + { return fIOFWAddressSpaceExpansion->fAuxiliary->isExclusive(); } + + /*! @function setExclusive + @abstract Sets if this address space requires exclusive control of its address range. Exclusivity should be set before an address space is activated. + @param exclusive True if address space should be exclusive, false otherwise + @result none + */ + + inline void setExclusive( bool exclusive ) + { fIOFWAddressSpaceExpansion->fAuxiliary->setExclusive( exclusive ); } + + /*! @function intersects + @abstract Checks this address space intersects with the given address range. Currently only supports IOFWPsuedoAddressSpaces. + @param space An address space to compare against + @result True if the address spaces intersect false otherwise + */ + + inline bool intersects( IOFWAddressSpace * space ) + { return fIOFWAddressSpaceExpansion->fAuxiliary->intersects( space ); } + + +protected: + + virtual IOFWAddressSpaceAux * createAuxiliary( void ); + +private: + OSMetaClassDeclareReservedUsed(IOFWAddressSpace, 0); + OSMetaClassDeclareReservedUsed(IOFWAddressSpace, 1); + +}; + +// the physical and psuedo address space classes used to be defined here +// for backwards compatibility, we pull them in now. the ifdefs surrounding +// the content of the header files ensures we do not multiply include a header. + +#include +#include + +#endif /* _IOKIT_IOFWADDRESSSPACE */ Index: branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWSyncer.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWSyncer.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWSyncer.h (revision 885) @@ -0,0 +1,54 @@ +/* + * Copyright (c) 1998-2007 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 _IOFWSYNCER_H +#define _IOFWSYNCER_H + +#include +#include +#include + +class IOFWSyncer : public OSObject +{ + OSDeclareDefaultStructors(IOFWSyncer) + +private: + // The spin lock that is used to guard the 'threadMustStop' variable. + IOSimpleLock *guardLock; + volatile bool threadMustStop; + IOReturn fResult; + virtual void free(); + virtual void privateSignal(); + +public: + + static IOFWSyncer * create(bool twoRetains = true); + + virtual bool init(bool twoRetains); + virtual void reinit(); + virtual IOReturn wait(bool autoRelease = true); + virtual void signal(IOReturn res = kIOReturnSuccess, + bool autoRelease = true); +}; + +#endif /* !_IOFWSYNCER */ + Index: branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOLocalConfigDirectory.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOLocalConfigDirectory.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOLocalConfigDirectory.h (revision 885) @@ -0,0 +1,110 @@ +/* +* Copyright (c) 1998-2002 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 __IOLOCALCONFIGDIRECTORY_H__ +#define __IOLOCALCONFIGDIRECTORY_H__ + +#include +#include +#include +#include + +class OSArray; +class OSData; +class IOFireWireController; +class IOFWUserObjectExporter ; + +/*! @class IOLocalConfigDirectory +*/ +class IOLocalConfigDirectory : public IOConfigDirectory +{ + friend class IOFireWireController; + friend class IOFireWireUserClient ; + + OSDeclareDefaultStructors(IOLocalConfigDirectory); + +protected: + OSArray *fEntries; // Entries for this directory. + OSData *fROM; // Local ROM, if compiled. + UInt32 fHeader; // Num entries and CRC. + +/*! @struct ExpansionData + @discussion This structure will be used to expand the capablilties of the class in the future. + */ + struct ExpansionData { }; + +/*! @var reserved + Reserved for future use. (Internal use only) */ + ExpansionData *reserved; + + virtual bool init(); + virtual void free(); + + virtual const UInt32 *getBase(); + virtual IOConfigDirectory *getSubDir(int start, int type); + +public: + static IOLocalConfigDirectory *create(); + + /*! + @function update + makes sure that the ROM has at least the specified capacity, + and that the ROM is uptodate from its start to at least the + specified quadlet offset. + @result kIOReturnSuccess if the specified offset is now + accessable at romBase[offset]. + */ + virtual IOReturn update(UInt32 offset, const UInt32 *&romBase); + + virtual IOReturn compile(OSData *rom); + + // All flavours of addEntry eat a retain of the desc string + virtual IOReturn addEntry(int key, UInt32 value, OSString *desc = NULL); + virtual IOReturn addEntry(int key, IOLocalConfigDirectory *value, + OSString *desc = NULL); + virtual IOReturn addEntry(int key, OSData *value, OSString *desc = NULL); + virtual IOReturn addEntry(int key, FWAddress value, OSString *desc = NULL); + virtual IOReturn removeSubDir(IOLocalConfigDirectory *value); + const OSArray *getEntries() const; + + virtual IOReturn getIndexValue(int index, IOConfigDirectory *&value); + +protected: + + virtual const UInt32 * lockData( void ); + virtual void unlockData( void ); + virtual IOReturn updateROMCache( UInt32 offset, UInt32 length ); + virtual IOReturn checkROMState( void ); + + // call eats a retain count + virtual IOReturn addEntry(OSString *desc); + + IOReturn incrementGeneration( void ); + static void exporterCleanup( const OSObject * self, IOFWUserObjectExporter * exporter ) ; + +private: + OSMetaClassDeclareReservedUsed(IOLocalConfigDirectory, 0); + OSMetaClassDeclareReservedUnused(IOLocalConfigDirectory, 1); + OSMetaClassDeclareReservedUnused(IOLocalConfigDirectory, 2); +}; + +#endif /* __IOLOCALCONFIGDIRECTORY_H__ */ Index: branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWSimplePhysicalAddressSpace.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWSimplePhysicalAddressSpace.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWSimplePhysicalAddressSpace.h (revision 885) @@ -0,0 +1,70 @@ +/* + * Copyright (c) 1998-2006 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 _IOFWSIMPLEPHYSICALADDRESSSPACE_H_ +#define _IOFWSIMPLEPHYSICALADDRESSSPACE_H_ + +#include +#include +#include +#include + +/*! @class IOFWSimplePhysicalAddressSpace +*/ + +class IOFWSimplePhysicalAddressSpace : public IOFWPhysicalAddressSpace +{ + OSDeclareDefaultStructors( IOFWSimplePhysicalAddressSpace ) + +private: + + void * fSimplePhysSpaceMembers; + + IOReturn allocateMemory( void ); + void deallocateMemory( void ); + +protected: + virtual bool createMemberVariables( void ); + virtual void destroyMemberVariables( void ); + +public: + + virtual bool init( IOFireWireBus * control, vm_size_t size, IODirection direction, bool contiguous = false ); + virtual void free( void ); + + IOVirtualAddress getVirtualAddress( void ); + +private: + OSMetaClassDeclareReservedUnused(IOFWSimplePhysicalAddressSpace, 0); + OSMetaClassDeclareReservedUnused(IOFWSimplePhysicalAddressSpace, 1); + OSMetaClassDeclareReservedUnused(IOFWSimplePhysicalAddressSpace, 2); + OSMetaClassDeclareReservedUnused(IOFWSimplePhysicalAddressSpace, 3); + OSMetaClassDeclareReservedUnused(IOFWSimplePhysicalAddressSpace, 4); + OSMetaClassDeclareReservedUnused(IOFWSimplePhysicalAddressSpace, 5); + OSMetaClassDeclareReservedUnused(IOFWSimplePhysicalAddressSpace, 6); + OSMetaClassDeclareReservedUnused(IOFWSimplePhysicalAddressSpace, 7); + OSMetaClassDeclareReservedUnused(IOFWSimplePhysicalAddressSpace, 8); + OSMetaClassDeclareReservedUnused(IOFWSimplePhysicalAddressSpace, 9); + +}; + +#endif Index: branches/azimutz/Cleancut/i386/include/IOKit/firewire/IORemoteConfigDirectory.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/firewire/IORemoteConfigDirectory.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/firewire/IORemoteConfigDirectory.h (revision 885) @@ -0,0 +1,92 @@ +/* + * Copyright (c) 1998-2002 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 __IOREMOTECONFIGDIRECTORY_H__ +#define __IOREMOTECONFIGDIRECTORY_H__ + +#include +#include + +#include +#include + +#include "IOFireWireROMCache.h" + +class OSString; +class OSIterator; +class IOFireWireDevice; + +/*! @class IORemoteConfigDirectory +*/ +class IORemoteConfigDirectory : public IOConfigDirectory +{ + OSDeclareDefaultStructors(IORemoteConfigDirectory); + +protected: + IOFireWireROMCache *fROM; // Our cache of the ROM + +/*! @struct ExpansionData + @discussion This structure will be used to expand the capablilties of the class in the future. + */ + struct ExpansionData { }; + +/*! @var reserved + Reserved for future use. (Internal use only) */ + ExpansionData *reserved; + + virtual bool initWithOwnerOffset(IOFireWireROMCache *rom, + int start, int type); + virtual void free(); + + virtual const UInt32 *getBase(); + virtual IOConfigDirectory *getSubDir(int start, int type); + +public: + static IOConfigDirectory *withOwnerOffset(IOFireWireROMCache *rom, + int start, int type); + + + /*! + @function update + makes sure that the ROM has at least the specified capacity, + and that the ROM is uptodate from its start to at least the + specified quadlet offset. + @result kIOReturnSuccess if the specified offset is now + accessable at romBase[offset]. + */ + virtual IOReturn update(UInt32 offset, const UInt32 *&romBase); + +protected: + + virtual const UInt32 * lockData( void ); + virtual void unlockData( void ); + virtual IOReturn updateROMCache( UInt32 offset, UInt32 length ); + virtual IOReturn checkROMState( void ); + +private: + OSMetaClassDeclareReservedUnused(IORemoteConfigDirectory, 0); + OSMetaClassDeclareReservedUnused(IORemoteConfigDirectory, 1); + OSMetaClassDeclareReservedUnused(IORemoteConfigDirectory, 2); +}; + + +#endif /* __IOREMOTECONFIGDIRECTORY_H__ */ Index: branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWIsochPort.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWIsochPort.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWIsochPort.h (revision 885) @@ -0,0 +1,66 @@ +/* + * Copyright (c) 1998-2002 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@ + */ +/* + * Copyright (c) 1999-2002 Apple Computer, Inc. All rights reserved. + * + * IOFWIsochPort is an abstract object that represents hardware on the bus + * (locally or remotely) that sends or receives isochronous packets. + * Local ports are implemented by the local device driver, + * Remote ports are implemented by the driver for the remote device. + * + * HISTORY + * + */ + + +#ifndef _IOKIT_IOFWISOCHPORT_H +#define _IOKIT_IOFWISOCHPORT_H + +#include +#include + +/*! @class IOFWIsochPort +*/ + +class IOFWIsochPort : public OSObject +{ + OSDeclareAbstractStructors(IOFWIsochPort) + +public: + // Return maximum speed and channels supported + // (bit n set = chan n supported) + virtual IOReturn getSupported(IOFWSpeed &maxSpeed, UInt64 &chanSupported) = 0; + + // Allocate hardware resources for port + virtual IOReturn allocatePort(IOFWSpeed speed, UInt32 chan) = 0; + virtual IOReturn releasePort() = 0; // Free hardware resources + virtual IOReturn start() = 0; // Start port processing packets + virtual IOReturn stop() = 0; // Stop processing packets + +private: + OSMetaClassDeclareReservedUnused(IOFWIsochPort, 0); + OSMetaClassDeclareReservedUnused(IOFWIsochPort, 1); + +}; + +#endif /* ! _IOKIT_IOFWISOCHPORT_H */ + Index: branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWDCLTranslator.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWDCLTranslator.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWDCLTranslator.h (revision 885) @@ -0,0 +1,114 @@ +/* + * Copyright (c) 1998-2002 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@ + */ +/* + * Copyright (c) 1999-2002 Apple Computer, Inc. All rights reserved. + * + * A DCL program to interpret (in software) a program that's too complicated + * for the DMA engine. + * + * HISTORY + * + */ + + +#ifndef _IOKIT_IOFWDCLTRANSLATOR_H +#define _IOKIT_IOFWDCLTRANSLATOR_H + +#include +#include + + +/*! @class IODCLTranslator +*/ + +class IODCLTranslator : public IODCLProgram +{ + OSDeclareAbstractStructors(IODCLTranslator) + +protected: + enum + { + kNumPingPongs = 2, + kNumPacketsPerPingPong = 500, + kMaxIsochPacketSize = 1000, + kPingPongBufferSize = kNumPingPongs * kNumPacketsPerPingPong * kMaxIsochPacketSize + }; + + // Opcodes and buffer for pingpong program + DCLLabel fStartLabel; + DCLTransferPacket fTransfers[kNumPingPongs*kNumPacketsPerPingPong]; + DCLCallProc fCalls[kNumPingPongs]; + DCLJump fJumpToStart; + UInt8 fBuffer[kPingPongBufferSize]; + + IODCLProgram * fHWProgram; // Hardware program executing our opcodes + DCLCommand* fToInterpret; // The commands to interpret + DCLCommand* fCurrentDCLCommand; // Current command to interpret + int fPingCount; // Are we pinging or ponging? + UInt32 fPacketHeader; + + static void ListeningDCLPingPongProc(DCLCommand* pDCLCommand); + static void TalkingDCLPingPongProc(DCLCommand* pDCLCommand); + +public: + virtual bool init(DCLCommand* toInterpret); + virtual IOReturn allocateHW(IOFWSpeed speed, UInt32 chan); + virtual IOReturn releaseHW(); + virtual IOReturn notify(IOFWDCLNotificationType notificationType, + DCLCommand** dclCommandList, UInt32 numDCLCommands); + virtual void stop(); + + DCLCommand* getTranslatorOpcodes(); + void setHWProgram(IODCLProgram *program); +}; + +/*! @class IODCLTranslateTalk +*/ + +class IODCLTranslateTalk : public IODCLTranslator +{ + OSDeclareDefaultStructors(IODCLTranslateTalk) + +protected: + +public: + virtual IOReturn compile(IOFWSpeed speed, UInt32 chan); + virtual IOReturn start(); + +}; + +/*! @class IODCLTranslateListen +*/ + +class IODCLTranslateListen : public IODCLTranslator +{ + OSDeclareDefaultStructors(IODCLTranslateListen) + +protected: + +public: + virtual IOReturn compile(IOFWSpeed speed, UInt32 chan); + virtual IOReturn start(); + +}; +#endif /* ! _IOKIT_IOFWDCLPROGRAM_H */ + Index: branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFireWireUnit.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFireWireUnit.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFireWireUnit.h (revision 885) @@ -0,0 +1,167 @@ +/* + * Copyright (c) 1998-2002 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@ + */ +/* + * + * IOFireWireUnit.h + * + * + */ +#ifndef _IOKIT_IOFIREWIREUNIT_H +#define _IOKIT_IOFIREWIREUNIT_H + +// public +#include + +class IOFireWireDevice; +class IOFireWireUnit; + +#pragma mark - + +/*! + @class IOFireWireUnitAux +*/ + +class IOFireWireUnitAux : public IOFireWireNubAux +{ + OSDeclareDefaultStructors(IOFireWireUnitAux) + + friend class IOFireWireUnit; + +protected: + + /*! + @struct ExpansionData + @discussion This structure will be used to expand the capablilties of the class in the future. + */ + + struct ExpansionData { }; + + /*! + @var reserved + Reserved for future use. (Internal use only) + */ + + ExpansionData * reserved; + + virtual bool init( IOFireWireUnit * primary ); + virtual void free(); + + virtual bool isPhysicalAccessEnabled( void ); + + virtual IOFWSimpleContiguousPhysicalAddressSpace * createSimpleContiguousPhysicalAddressSpace( vm_size_t size, IODirection direction ); + + virtual IOFWSimplePhysicalAddressSpace * createSimplePhysicalAddressSpace( vm_size_t size, IODirection direction ); + +private: + OSMetaClassDeclareReservedUnused(IOFireWireUnitAux, 0); + OSMetaClassDeclareReservedUnused(IOFireWireUnitAux, 1); + OSMetaClassDeclareReservedUnused(IOFireWireUnitAux, 2); + OSMetaClassDeclareReservedUnused(IOFireWireUnitAux, 3); + +}; + +#pragma mark - + +/*! @class IOFireWireUnit +*/ +class IOFireWireUnit : public IOFireWireNub +{ + OSDeclareDefaultStructors(IOFireWireUnit) + + friend class IOFireWireUnitAux; + friend class IOFireWireDevice; + +protected: + IOFireWireDevice *fDevice; // The device unit is part of + +/*! @struct ExpansionData + @discussion This structure will be used to expand the capablilties of the class in the future. + */ + struct ExpansionData { }; + +/*! @var reserved + Reserved for future use. (Internal use only) */ + ExpansionData *reserved; + +/*------------------Methods provided to FireWire device clients-----------------------*/ +public: + + virtual bool init(OSDictionary *propTable, IOConfigDirectory *directory); + + /* + * Standard nub initialization + */ + virtual bool attach(IOService * provider ); + virtual void free(); + + /* + * Matching language support + * Match on the following properties of the unit: + * Vendor_ID + * GUID + * Unit_Spec_ID + * Unit_SW_Version + */ + virtual bool matchPropertyTable(OSDictionary * table); + + + virtual IOReturn message( UInt32 type, IOService * provider, void * argument ); + + // Override handleOpen() and handleClose() to pass on to device + virtual bool handleOpen( IOService * forClient, + IOOptionBits options, + void * arg ); + + virtual void handleClose( IOService * forClient, + IOOptionBits options ); + + virtual void setNodeFlags( UInt32 flags ); + virtual void clearNodeFlags( UInt32 flags ); + virtual UInt32 getNodeFlags( void ); + + virtual IOReturn setConfigDirectory( IOConfigDirectory *directory ); + + /* + * Create local FireWire address spaces for the device to access + */ + virtual IOFWPhysicalAddressSpace *createPhysicalAddressSpace(IOMemoryDescriptor *mem); + virtual IOFWPseudoAddressSpace *createPseudoAddressSpace(FWAddress *addr, UInt32 len, + FWReadCallback reader, FWWriteCallback writer, void *refcon); + +protected: + + virtual IOFireWireNubAux * createAuxiliary( void ); + +public: + void setMaxSpeed( IOFWSpeed speed ); + +protected: + void terminateUnit( void ); + static void terminateUnitThreadFunc( void * refcon ); + +private: + OSMetaClassDeclareReservedUnused(IOFireWireUnit, 0); + OSMetaClassDeclareReservedUnused(IOFireWireUnit, 1); + +}; + +#endif /* ! _IOKIT_IOFIREWIREDEVICE_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWPseudoAddressSpace.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWPseudoAddressSpace.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWPseudoAddressSpace.h (revision 885) @@ -0,0 +1,370 @@ +/* + * Copyright (c) 1998-2002 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_IOFWPSEUDOADDRESSSPACE_H +#define _IOKIT_IOFWPSEUDOADDRESSSPACE_H + +#include + +/* + * If installed, this callback is invoked for drivers which + * would like to coalesce incoming writes and do batch processing + * of incoming block write packets. + * This callback can be installed by calling setARxReqIntCompleteHandler + * method in IOFWPseudoAddressSpace object. + */ +typedef void (*IOFWARxReqIntCompleteHandler)( void * refcon ); + +/* + * Pseudo firewire addresses usually represent emulated registers of some kind. + * Accesses to these addresses will result in the owner being notified. + * + * Virtual addresses should not have zero as the top 16 bits of the 48 bit local address, + * since that may look like a physical address to hardware (eg. OHCI). + * if reader is NULL then reads will not be allowed. + * if writer is NULL then writes will not be allowed. + * if either is NULL then lock requests will not be allowed. + * refcon is passed back as the first argument of read and write callbacks. + */ + +class IOFWPseudoAddressSpace; + +#pragma mark - + +/*! + @class IOFWPseudoAddressSpaceAux +*/ + +class IOFWPseudoAddressSpaceAux : public IOFWAddressSpaceAux +{ + OSDeclareDefaultStructors(IOFWPseudoAddressSpaceAux) + + friend class IOFWAddressSpace; + friend class IOFWPseudoAddressSpace; + friend class IOFireWireController; + +protected: + + struct MemberVariables + { + IOFWARxReqIntCompleteHandler fARxReqIntCompleteHandler; + void * fARxReqIntCompleteHandlerRefcon; + }; + + MemberVariables * fMembers; + +public: + + virtual bool init( IOFWAddressSpace * primary ); + virtual void free(); + +protected: + + bool createMemberVariables( void ); + void destroyMemberVariables( void ); + + virtual void handleARxReqIntComplete(); + +public: + +/*! @function setARxReqIntCompleteHandler + @abstract Installs a callback to receive notification, when FWIM has completed + ARxReqInt processing and no incoming packets are left in the queue. + @param refcon Client's callback object. + @param handler Client callback to be invoked, at the end of interrupt processing. + @result none. */ + virtual void setARxReqIntCompleteHandler( void * refcon, IOFWARxReqIntCompleteHandler handler ); + + virtual bool intersects( IOFWAddressSpace * space ); + +private: + + OSMetaClassDeclareReservedUsed(IOFWPseudoAddressSpaceAux, 0); + OSMetaClassDeclareReservedUsed(IOFWPseudoAddressSpaceAux, 1); + OSMetaClassDeclareReservedUnused(IOFWPseudoAddressSpaceAux, 2); + OSMetaClassDeclareReservedUnused(IOFWPseudoAddressSpaceAux, 3); + OSMetaClassDeclareReservedUnused(IOFWPseudoAddressSpaceAux, 4); + OSMetaClassDeclareReservedUnused(IOFWPseudoAddressSpaceAux, 5); + OSMetaClassDeclareReservedUnused(IOFWPseudoAddressSpaceAux, 6); + OSMetaClassDeclareReservedUnused(IOFWPseudoAddressSpaceAux, 7); + OSMetaClassDeclareReservedUnused(IOFWPseudoAddressSpaceAux, 8); + OSMetaClassDeclareReservedUnused(IOFWPseudoAddressSpaceAux, 9); + +}; + +/*! + @class IOFWPseudoAddressSpace +*/ + +class IOFWPseudoAddressSpace : public IOFWAddressSpace +{ + OSDeclareDefaultStructors(IOFWPseudoAddressSpace) + + friend class IOFWPseudoAddressSpaceAux; + friend class IOFireWireController; + +protected: + + IOMemoryDescriptor* fDesc; + void * fRefCon; + FWReadCallback fReader; + FWWriteCallback fWriter; + FWAddress fBase; + UInt32 fLen; + +/*! @struct ExpansionData + @discussion This structure will be used to expand the capablilties of the class in the future. + */ + struct ExpansionData { }; + +/*! @var reserved + Reserved for future use. (Internal use only) */ + ExpansionData *reserved; + + static OSData * allocatedAddresses; // unused + + virtual void free(); + +public: + +/*! @function simpleReader + @abstract A method for processing an address space read request + @param refcon Client's callback object. + @param nodeID FireWire Read from nodeID. + @param speed at this 'speed'. + @param addr with FireWire address 'addr'. + @param len read 'len' bytes from nodeID. + @param buf points to a memory descriptor containing the packet data. + @param offset start from this 'offset' in 'buf'. + @param reqrefcon Can be queried for extra info about the request. + @result UIn32 returns kFWResponseComplete on success */ + static UInt32 simpleReader( + void* refcon, + UInt16 nodeID, + IOFWSpeed & speed, + FWAddress addr, + UInt32 len, + IOMemoryDescriptor** buf, + IOByteCount* offset, + IOFWRequestRefCon reqrefcon); + +/*! @function simpleWriter + @abstract A method for processing an address space write request + @param refcon Client's callback object. + @param nodeID FireWire Write to nodeID. + @param speed at this 'speed'. + @param addr with FireWire address 'addr'. + @param len write 'len' bytes to nodeID. + @param buf obtain bytes from location given by 'buf'. + @param reqrefcon Can be queried for extra info about the request. + @result UIn32 returns kFWResponseComplete on success */ + static UInt32 simpleWriter( + void* refcon, + UInt16 nodeID, + IOFWSpeed& speed, + FWAddress addr, + UInt32 len, + const void* buf, + IOFWRequestRefCon reqrefcon); +protected: + + // Get a unique address range + IOReturn allocateAddress( + FWAddress* addr, + UInt32 len); + // free address + void freeAddress( + FWAddress addr, + UInt32 len); + +public: + + static IOFWPseudoAddressSpace* readWrite( + FWAddress addr, + UInt32 len, + FWReadCallback reader, + FWWriteCallback writer, + void* refcon); + +/*! @function simpleRead + @abstract Create an address space object to handle read-only memory (eg. the local ROM) + handles everything itself + @param bus Points to IOFireWireBus object. + @param addr Points to starting address for the Pseudo Address Space. + @param len Length of the Pseudo Address Space. + @param data The virtual address of the first byte in the memory. + @result returns valid IOFWPseudoAddressSpace on success, null on failure */ + static IOFWPseudoAddressSpace* simpleRead( + IOFireWireBus* bus, + FWAddress* addr, + UInt32 len, + const void* data); + +/*! @function simpleReadFixed + @abstract Create an address space object to handle fixed read-only memory (eg. the local ROM) + handles everything itself + @param bus Points to IOFireWireBus object. + @param addr Points to starting address for the Pseudo Address Space. + @param len Length of the Pseudo Address Space. + @param data The virtual address of the first byte in the memory. + @result returns valid IOFWPseudoAddressSpace on success, null on failure */ + static IOFWPseudoAddressSpace* simpleReadFixed( + IOFireWireBus* bus, + FWAddress addr, + UInt32 len, + const void* data); + +/*! @function simpleRW + @abstract Create an address space object to handle r/w memory + handles everything itself + @param bus Points to IOFireWireBus object. + @param addr Points to starting address for the Pseudo Address Space. + @param len Length of the Pseudo Address Space. + @param data The virtual address of the first byte in the memory. + @result returns valid IOFWPseudoAddressSpace on success, null on failure */ + static IOFWPseudoAddressSpace* simpleRW( + IOFireWireBus* bus, + FWAddress* addr, + UInt32 len, + void * data); + +/*! @function simpleRW + @abstract Create an address space object to handle r/w memory + handles everything itself + @param bus Points to IOFireWireBus object. + @param addr Points to starting address for the Pseudo Address Space. + @param data The virtual address of the first byte in the memory. + @result returns valid IOFWPseudoAddressSpace on success, null on failure */ + static IOFWPseudoAddressSpace* simpleRW( + IOFireWireBus* bus, + FWAddress* addr, + IOMemoryDescriptor * data); + +/*! @function initAll + @abstract Initialize an address space object to handle r/w memory + @param bus Points to IOFireWireBus object. + @param addr Points to starting address for the Pseudo Address Space. + @param len Length of the Pseudo Address Space. + @param reader Callback handler for incoming Read. + @param writer Callback handler for incoming Write. + @param refcon Client's callback object. + @result returns true on success, false on failure */ + virtual bool initAll( + IOFireWireBus* bus, + FWAddress* addr, + UInt32 len, + FWReadCallback reader, + FWWriteCallback writer, + void* refcon); + +/*! @function initFixed + @abstract Initialize a fixed address space at top of kCSRRegisterSpaceBaseAddressHi + @param bus Points to IOFireWireBus object. + @param addr Points to starting address for the Pseudo Address Space. + @param reader Callback handler for incoming Read. + @param writer Callback handler for incoming Write. + @param refcon Client's callback object. + @result returns true on success, false on failure */ + virtual bool initFixed( + IOFireWireBus* bus, + FWAddress addr, + UInt32 len, + FWReadCallback reader, + FWWriteCallback writer, + void* refcon); + +/*! @function doRead + @abstract A method for processing an address space read request + @param nodeID FireWire Read from nodeID. + @param speed at this 'speed'. + @param addr with FireWire address 'addr'. + @param len read 'len' bytes from nodeID. + @param buf points to a memory descriptor containing the packet data. + @param offset start from this 'offset' in 'buf'. + @param reqrefcon Can be queried for extra info about the request. + @result UIn32 returns kFWResponseComplete on success */ + virtual UInt32 doRead( + UInt16 nodeID, + IOFWSpeed & speed, + FWAddress addr, + UInt32 len, + IOMemoryDescriptor ** buf, + IOByteCount * offset, + IOFWRequestRefCon reqrefcon); +/*! @function doWrite + @abstract A method for processing an address space write request + @param nodeID FireWire Write to nodeID. + @param speed at this 'speed'. + @param addr with FireWire address 'addr'. + @param len write 'len' bytes to nodeID. + @param buf obtain bytes from location given by 'buf'. + @param reqrefcon Can be queried for extra info about the request. + @result UIn32 returns kFWResponseComplete on success */ + virtual UInt32 doWrite( + UInt16 nodeID, + IOFWSpeed& speed, + FWAddress addr, + UInt32 len, + const void* buf, + IOFWRequestRefCon reqrefcon); + +/*! @function contains + @abstract returns number of bytes starting at addr in this space + @result 0 if it doesn't contain the address + */ + virtual UInt32 contains(FWAddress addr); + +/*! @function simpleRWFixed + @abstract Create a Read/Write fixed address space at top of kCSRRegisterSpaceBaseAddressHi. + @param control Points to IOFireWireBus object. + @param addr Points to starting address for the Pseudo Address Space. + @param len Length of the address range. + @param data The virtual address of the first byte in the memory. + @result returns valid IOFWPseudoAddressSpace on success, null on failure */ + static IOFWPseudoAddressSpace * simpleRWFixed( IOFireWireBus *control, FWAddress addr, UInt32 len, const void *data ); + +protected: + + virtual IOFWAddressSpaceAux * createAuxiliary( void ); + +protected: + inline void handleARxReqIntComplete( void ) + { ((IOFWPseudoAddressSpaceAux*)fIOFWAddressSpaceExpansion->fAuxiliary)->handleARxReqIntComplete(); } + +public: +/*! @function setARxReqIntCompleteHandler + @abstract Installs a callback to receive notification, when FWIM has completed + ARxReqInt processing and no incoming packets are left in the queue. + @param refcon Client's callback object. + @param handler Client callback to be invoked, at the end of interrupt processing. + @result none. */ + inline void setARxReqIntCompleteHandler( void * refcon, IOFWARxReqIntCompleteHandler handler ) + { ((IOFWPseudoAddressSpaceAux*)fIOFWAddressSpaceExpansion->fAuxiliary)->setARxReqIntCompleteHandler( refcon, handler ); } + +private: + + OSMetaClassDeclareReservedUnused(IOFWPseudoAddressSpace, 0); + OSMetaClassDeclareReservedUnused(IOFWPseudoAddressSpace, 1); + +}; + +#endif Index: branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFireWireController.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFireWireController.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFireWireController.h (revision 885) @@ -0,0 +1,1089 @@ +/* + * Copyright (c) 1998-2002 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@ + */ +/* + * Copyright (c) 1999-2002 Apple Computer, Inc. All rights reserved. + * + * HISTORY + * + */ + +#ifndef _IOKIT_IOFIREWIRECONTROLLER_H +#define _IOKIT_IOFIREWIRECONTROLLER_H + +#ifndef FIREWIREPRIVATE +#warning Please do not include this file. Include IOFireWireBus.h instead. +#endif + +#include +#include +#include +#include +#include +#include + +class OSData; +class IOWorkLoop; +class IOEventSource; +class IOFWQEventSource; +class IOTimerEventSource; +class IOMemoryDescriptor; +class IOFireWireController; +class IOFWAddressSpace; +class IOFWPseudoAddressSpace; +class IOFireWireNub; +class IOFireWireDevice; +class IOFireWireDeviceAux; +class IOFireWireUnit; +class IODCLProgram; +class IOLocalConfigDirectory; +class IOFireWireLink; +class IOFireWireSBP2ORB; +class IOFireWireSBP2Login; +class IOFireWireROMCache; +class IOFireWireLocalNode; +class IOFWWorkLoop; +class IOFireWireIRM; +class IOFireWirePowerManager; +class IOFWSimplePhysicalAddressSpace; +class IOFWSimpleContiguousPhysicalAddressSpace; +class IOFWAsyncStreamReceiver; +class IOFWAsyncStreamListener; +class IOFWUserVectorCommand; +class IOFWAsyncPHYCommand; +class IOFWPHYPacketListener; +class IOFWUserPHYPacketListener; + +#if FIRELOGCORE +class IOFireLog; +class IOFireLogPublisher; +#endif + +const UInt32 kMaxWaitForValidSelfID = 20; // Still invalid SelfID after 20 retries + +// Phy packet defs. + +enum +{ + kFWPhyPacketID = FWBitRange (0, 1), + kFWPhyPacketIDPhase = FWBitRangePhase (0, 1), + + kFWPhyPacketPhyID = FWBitRange (2, 7), + kFWPhyPacketPhyIDPhase = FWBitRangePhase (2, 7) +}; + +enum +{ + kSelfIDPacketSize = 8, + kMaxSelfIDs = 4 // SelfID 0,1,3,8 +}; + +enum +{ + kFWConfigurationPacketID = 0, + kFWLinkOnPacketID = 1, + kFWSelfIDPacketID = 2 +}; + +enum +{ + kFWPhyConfigurationR = FW_BIT(8), + kFWPhyConfigurationT = FW_BIT(9), + kFWPhyConfigurationGapCnt = FWBitRange (10, 15), + kFWPhyConfigurationGapCntPhase = FWBitRangePhase (10, 15) +}; + +enum +{ + kFWSelfIDPortStatusChild = 3, + kFWSelfIDPortStatusParent = 2, + kFWSelfIDPortStatusNotConnected = 1, + kFWSelfIDPortStatusNotPresent = 0, + + kFWSelfIDNoPower = 0, + kFWSelfIDSelfPowered15W = 1, + kFWSelfIDSelfPowered30W = 2, + kFWSelfIDSelfPowered45W = 3, + kFWSelfIDBusPowered1W = 4, + kFWSelfIDBusPowered3W = 5, + kFWSelfIDBusPowered6W = 6, + kFWSelfIDBusPowered10W = 7, + + kFWSelfIDPhyID = kFWPhyPacketPhyID,//zzz do we need or want this? + kFWSelfIDPhyIDPhase = kFWPhyPacketPhyIDPhase, + kFWSelfIDM = FW_BIT(31), + + kFWSelfID0L = FW_BIT(9), + kFWSelfID0GapCnt = FWBitRange (10, 15), + kFWSelfID0GapCntPhase = FWBitRangePhase (10, 15), + kFWSelfID0SP = FWBitRange (16, 17), + kFWSelfID0SPPhase = FWBitRangePhase (16, 17), + kFWSelfID0Del = FWBitRange (18, 19), + kFWSelfID0DelPhase = FWBitRangePhase (18, 19), + kFWSelfID0C = FW_BIT(20), + kFWSelfID0Pwr = FWBitRange (21, 23), + kFWSelfID0PwrPhase = FWBitRangePhase (21, 23), + kFWSelfID0P0 = FWBitRange (24, 25), + kFWSelfID0P0Phase = FWBitRangePhase (24, 25), + kFWSelfID0P1 = FWBitRange (26, 27), + kFWSelfID0P1Phase = FWBitRangePhase (26, 27), + kFWSelfID0P2 = FWBitRange (28, 29), + kFWSelfID0P2Phase = FWBitRangePhase (28, 29), + kFWSelfID0I = FW_BIT(30), + + kFWSelfIDPacketType = FW_BIT(8), + kFWSelfIDNN = FWBitRange (9, 11), + kFWSelfIDNNPhase = FWBitRangePhase (9, 11), + kFWSelfIDNPa = FWBitRange (14, 15), + kFWSelfIDNPaPhase = FWBitRangePhase (14, 15), + kFWSelfIDNPb = FWBitRange (16, 17), + kFWSelfIDNPbPhase = FWBitRangePhase (16, 17), + kFWSelfIDNPc = FWBitRange (18, 19), + kFWSelfIDNPcPhase = FWBitRangePhase (18, 19), + kFWSelfIDNPd = FWBitRange (20, 21), + kFWSelfIDNPdPhase = FWBitRangePhase (20, 21), + kFWSelfIDNPe = FWBitRange (22, 23), + kFWSelfIDNPePhase = FWBitRangePhase (22, 23), + kFWSelfIDNPf = FWBitRange (24, 25), + kFWSelfIDNPfPhase = FWBitRangePhase (24, 25), + kFWSelfIDNPg = FWBitRange (26, 27), + kFWSelfIDNPgPhase = FWBitRangePhase (26, 27), + kFWSelfIDNPh = FWBitRange (28, 29), + kFWSelfIDNPhPhase = FWBitRangePhase (28, 29), + kFWSelfIDMore = FW_BIT(31) +}; + +// Primary packet defs. +enum +{ + kFWPacketTCode = FWBitRange (24, 27), + kFWPacketTCodePhase = FWBitRangePhase (24, 27) +}; + + +enum +{ + kFWAsynchSpd = FWBitRange (14, 15), + kFWAsynchSpdPhase = FWBitRangePhase (14, 15), + + kFWAsynchTLabel = FWBitRange (16, 21), + kFWAsynchTLabelPhase = FWBitRangePhase (16, 21), + kFWAsynchTTotal = ((0xffffffff & kFWAsynchTLabel) >> kFWAsynchTLabelPhase)+1, + kFWAsynchRt = FWBitRange (22, 23), + kFWAsynchRtPhase = FWBitRangePhase (22, 23), + kFWAsynchNew = 0, + kFWAsynchRetryA = 2, + kTIAsycnhRetryB = 3, + + kFWAsynchPriority = FWBitRange (28, 31), + kFWAsynchPriorityPhase = FWBitRangePhase (28, 31), + + kFWAsynchDestinationID = FWBitRange (0, 15), + kFWAsynchDestinationIDPhase = FWBitRangePhase (0, 15), + + kFWAsynchSourceID = FWBitRange (0, 15), + kFWAsynchSourceIDPhase = FWBitRangePhase (0, 15), + + kFWAsynchDestinationOffsetHigh = FWBitRange (16, 31), + kFWAsynchDestinationOffsetHighPhase = FWBitRangePhase (16, 31), + + kFWAsynchDestinationOffsetLow = FWBitRange (0, 31), + kFWAsynchDestinationOffsetLowPhase = FWBitRangePhase (0, 31), + + kFWAsynchDataLength = FWBitRange (0, 15), + kFWAsynchDataLengthPhase = FWBitRangePhase (0, 15), + + kFWAsynchExtendedTCode = FWBitRange (16, 31), + kFWAsynchExtendedTCodePhase = FWBitRangePhase (16, 31), + + kFWAsynchAckSent = FWBitRange (28, 31), + kFWAsynchAckSentPhase = FWBitRangePhase (28, 31), + + kFWAsynchRCode = FWBitRange (16, 19), + kFWAsynchRCodePhase = FWBitRangePhase (16, 19) +}; + +enum +{ + kFWTCodeWriteQuadlet = 0, + kFWTCodeWriteBlock = 1, + kFWTCodeWriteResponse = 2, + kFWTCodeReadQuadlet = 4, + kFWTCodeReadBlock = 5, + kFWTCodeReadQuadletResponse = 6, + kFWTCodeReadBlockResponse = 7, + kFWTCodeCycleStart = 8, + kFWTCodeLock = 9, + kFWTCodeIsochronousBlock = 10, + kFWTCodeLockResponse = 11, + kFWTCodePHYPacket = 14 +}; + +enum +{ + kFWExtendedTCodeMaskSwap = 1, + kFWExtendedTCodeCompareSwap = 2, + kFWExtendedTCodeFetchAdd = 3, + kFWExtendedTCodeLittleAdd = 4, + kFWExtendedTCodeBoundedAdd = 5, + kFWExtendedTCodeWrapAdd = 6, + kFWExtendedTCodeVendorDependent = 7 +}; + +// debug boot-arg constants +enum +{ + kFWDebugIgnoreNodeNone = 0xFFFFFFFF +}; + +struct AsyncPendingTrans { + IOFWAsyncCommand * fHandler; + IOFWCommand * fAltHandler; + int fTCode; + bool fInUse; +}; + +struct IOFWNodeScan { + IOFireWireController * fControl; + FWAddress fAddr; + UInt32 fBuf[5]; // Enough for bus info block + UInt32 * fSelfIDs; + int fNumSelfIDs; + int fROMSize; + int fRead; + IOFWReadQuadCommand * fCmd; + IOFWCompareAndSwapCommand * fLockCmd; + UInt32 generation; + UInt32 fIRMBitBucketOld; + UInt32 fIRMBitBucketNew; + bool fIRMisBad; + bool speedChecking; + bool fContenderNeedsChecking; + bool fIRMCheckingRead; + bool fIRMCheckingLock; + int fRetriesBumped; + bool fMustNotBeRoot; +}; + + +typedef struct IOFWDuplicateGUIDStruct IOFWDuplicateGUIDRec; +struct IOFWDuplicateGUIDStruct + { + IOFWDuplicateGUIDRec * fNextGUID; + CSRNodeUniqueID fGUID; + UInt32 fLastGenSeen; +}; + + +// IOFireWireDuplicateGUIDList +// +// A little class for keeping track of GUIDs which where we have observed 2 nodes with +// the same GUID + +class IOFireWireDuplicateGUIDList : public OSObject +{ + OSDeclareDefaultStructors(IOFireWireDuplicateGUIDList); + +private: + IOFWDuplicateGUIDRec * fFirstGUID; + +protected: + virtual void free(); + +public: + + static IOFireWireDuplicateGUIDList * create( void ); + + void addDuplicateGUID( CSRNodeUniqueID guid, UInt32 gen ); + void removeDuplicateGUID( CSRNodeUniqueID guid ); + + bool findDuplicateGUID( CSRNodeUniqueID guid, UInt32 gen ); + +}; + +#define kMaxPendingTransfers kFWAsynchTTotal + +class IOFireWireController; + +#pragma mark - + +/*! + @class IOFireWireControllerAux +*/ + +class IOFireWireControllerAux : public IOFireWireBusAux +{ + OSDeclareDefaultStructors(IOFireWireControllerAux) + + friend class IOFireWireController; + +protected: + + IOFireWireController * fPrimary; + + UInt8 fMaxRec; + + UInt8 fPadding; + UInt16 fPadding2; + + IOFWUserObjectExporter * fSessionRefExporter; + + /*! + @struct ExpansionData + @discussion This structure will be used to expand the capablilties of the class in the future. + */ + + struct ExpansionData { }; + + /*! + @var reserved + Reserved for future use. (Internal use only) + */ + + ExpansionData * reserved; + + virtual bool init ( + IOFireWireController * primary ); + virtual void free (); + virtual IOFWDCLPool * createDCLPool ( unsigned capacity ) const ; + virtual UInt8 getMaxRec( void ); + + virtual UInt64 getFireWirePhysicalAddressMask( void ); + virtual UInt32 getFireWirePhysicalAddressBits( void ); + virtual UInt64 getFireWirePhysicalBufferMask( void ); + virtual UInt32 getFireWirePhysicalBufferBits( void ); + + virtual IOFWSimpleContiguousPhysicalAddressSpace * createSimpleContiguousPhysicalAddressSpace( vm_size_t size, IODirection direction ); + virtual IOFWSimplePhysicalAddressSpace * createSimplePhysicalAddressSpace( vm_size_t size, IODirection direction ); + + virtual IOFWUserObjectExporter * getSessionRefExporter( void ); + +private: + OSMetaClassDeclareReservedUnused(IOFireWireControllerAux, 0); + OSMetaClassDeclareReservedUnused(IOFireWireControllerAux, 1); + OSMetaClassDeclareReservedUnused(IOFireWireControllerAux, 2); + OSMetaClassDeclareReservedUnused(IOFireWireControllerAux, 3); + OSMetaClassDeclareReservedUnused(IOFireWireControllerAux, 4); + OSMetaClassDeclareReservedUnused(IOFireWireControllerAux, 5); + OSMetaClassDeclareReservedUnused(IOFireWireControllerAux, 6); + OSMetaClassDeclareReservedUnused(IOFireWireControllerAux, 7); + +}; + + +#pragma mark - + +/*! @class IOFireWireController +*/ +class IOFireWireController : public IOFireWireBus +{ + OSDeclareAbstractStructors(IOFireWireController) + +protected: + enum busState { + kStarting = 0, + kAsleep, // Link off, zzzzzz + kWaitingBusReset, + kWaitingSelfIDs, // Bus has been reset, no selfIDs yet + kWaitingScan, // Got selfIDs, waiting a bit before hitting lame devices + kScanning, // Reading node ROMs + kWaitingPrune, // Read all ROMs, pausing before pruning missing devices + kRunning, // Normal happy state, + kWaitingBusResetStart // bus reset is desired, but not yet sent to the fwim + }; + + enum ResetState + { + kResetStateResetting, + kResetStateDisabled, + kResetStateArbitrated + }; + + enum + { + kDisablePhysicalAccess = (1 << 0) + }; + + struct timeoutQ: public IOFWCmdQ + { + IOTimerEventSource *fTimer; + virtual void headChanged(IOFWCommand *oldHead); + void busReset(); + }; + + struct pendingQ: public IOFWCmdQ + { + IOFWQEventSource *fSource; + virtual void headChanged(IOFWCommand *oldHead); + }; + + friend class IOFireWireLink; + friend class IOFireWireDevice; + friend class IOFireWireDeviceAux; + friend class IOFWAddressSpace; + friend class IOFWAddressSpaceAux; + friend class IOFWPseudoAddressSpace; + friend class IOFireWireSBP2ORB; + friend class IOFireWireSBP2Login; + friend class IOFWLocalIsochPort; + friend class IOFWCommand; + friend class IOFireWireUnit; + friend class IOFireWirePCRSpace; + friend class IOFireWireROMCache; + friend class IOFWAsyncStreamCommand; + friend class IOFireWireAVCLocalUnit; + friend class IOFireWireAVCUnit; + friend class IOFireWireAVCCommand; + friend class IOFireWirePowerManager; + friend class IOFWWriteQuadCommand; + friend class IOFWWriteCommand; + friend class IOFWCompareAndSwapCommand; + friend class IOFWAsyncCommand; + friend class IOFireWireAVCTargetSpace; + friend class AppleFWOHCI; + friend class IOFireWireNub; + friend class IOFWAsyncStreamListener; + friend class IOFireWireLocalNode; + friend class IOFireWireIRMAllocation; + friend class IOFWUserVectorCommand; + friend class IOFWAsyncPHYCommand; + friend class IOFWUserPHYPacketListener; + friend class IOFWAsyncStreamReceiver; + +#if FIRELOGCORE + friend class IOFireLog; +#endif + + IOFireWireLink * fFWIM; + IOFWWorkLoop * fWorkLoop; + IOTimerEventSource * fTimer; + OSSet * fLocalAddresses; // Collection of local adress spaces + OSIterator * fSpaceIterator; // Iterator over local addr spaces + + OSSet * fAllocatedChannels; // Need to be informed of bus resets + OSIterator * fAllocChannelIterator; // Iterator over channels + + OSSet * fIRMAllocations; // Need to be informed of bus resets + OSIterator * fIRMAllocationsIterator; // Iterator over channels + OSSet * fIRMAllocationsAllocated; // Need to be informed of bus resets + + // Bus management variables (although we aren't a FireWire Bus Manager...) + AbsoluteTime fResetTime; // Time of last reset + UInt32 fBusGeneration; // ID of current bus topology. + UInt16 fLocalNodeID; // ID of local node, ie. this computer + UInt16 fRootNodeID; // ID of root, ie. highest node id in use. + UInt16 fIRMNodeID; // ID of Isochronous resource manager, or kFWBadNodeID + bool fBusMgr; // true if at least one node is bus manager capable + IORegistryEntry * fNodes[kFWMaxNodesPerBus]; // FireWire nodes on this bus + UInt32 * fNodeIDs[kFWMaxNodesPerBus+1]; // Pointer to SelfID list for each node + // +1 so we know how many selfIDs the last node has + + UInt32 fGapCount; // What we think the gap count should be + //UInt8 fSpeedCodes[(kFWMaxNodesPerBus+1)*kFWMaxNodesPerBus]; + UInt8 fSpeedVector[((kFWMaxNodesPerBus+1)*kFWMaxNodesPerBus)/2]; + // Max speed between two nodes + busState fBusState; // Which state are we in? + int fNumROMReads; // Number of device ROMs we are still reading + // SelfIDs + int fNumSelfIDs; // Total number of SelfID packets + UInt32 fSelfIDs[kMaxSelfIDs*kFWMaxNodesPerBus]; + + // The local device's Config ROM + UInt32 fROMHeader[5]; // More or less fixed header and bus info block + IOLocalConfigDirectory * fRootDir; // Local Config ROM root directory. + + // log base 2 of maximum packet size the FWIM can send/receive + // Normally calculated from bus info block. + int fMaxSendLog; + int fMaxRecvLog; + + IOFWAddressSpace * fROMAddrSpace; + IOMemoryDescriptor * fBadReadResponse; // Send back easily identified bad data to out of range addrs. + + // Array for outstanding requests (up to 64) + AsyncPendingTrans fTrans[kMaxPendingTransfers]; + int fLastTrans; + + // queue for executing commands that may timeout + timeoutQ fTimeoutQ; + + // queue for commands that can't execute yet + pendingQ fPendingQ; + + // queue for async commands interrupted by bus reset + IOFWCmdQ fAfterResetHandledQ; + + // Command to change bus state after a delay. + IOFWDelayCommand * fDelayedStateChangeCmd; + bool fDelayedStateChangeCmdNeedAbort; + + UInt32 fDelayedPhyPacket; + bool fBusResetScheduled; + ResetState fBusResetState; + IOFWDelayCommand * fBusResetStateChangeCmd; + UInt32 fBusResetDisabledCount; + +#if FIRELOGCORE + IOFireLogPublisher * fFireLogPublisher; +#else + void * fFireLogPublisher; +#endif + + OSData * fAllocatedAddresses; + + UInt32 fDevicePruneDelay; + + IOFWPhysicalAccessMode fPhysicalAccessMode; + IOFWSecurityMode fSecurityMode; + IONotifier * fKeyswitchNotifier; + + IOFireWireIRM * fIRM; + IOFireWirePowerManager * fBusPowerManager; + + bool fGapCountMismatch; + + bool fUseHalfSizePackets; + bool fRequestedHalfSizePackets; + + IOFWNodeScan * fScans[kFWMaxNodesPerBus]; + IOFireWireDuplicateGUIDList * fGUIDDups; + + bool fDelegateCycleMaster; + bool fBadIRMsKnown; + + UInt32 fPreviousGap; + + UInt32 fOutOfTLabels; + UInt32 fOutOfTLabels10S; + UInt32 fOutOfTLabelsThreshold; + +#ifdef LEGACY_SHUTDOWN + IONotifier * fPowerEventNotifier; +#endif + + bool fStarted; + + UInt32 fIOCriticalSectionCount; + UInt32 fHubPort; + UInt32 fDebugIgnoreNode; + + OSSet * fLocalAsyncStreamReceivers; + OSIterator * fAsyncStreamReceiverIterator; + + bool fInstantiated; + + IOReturn fStartStatus; + UInt32 fWaitingForSelfID; + + UInt32 fForcedRootNodeID; + bool fNodeMustBeRootFlag; + bool fNodeMustNotBeRootFlag; + + UInt32 fForcedGapCount; + bool fForcedGapFlag; + + OSSet * fPHYPacketListeners; + OSIterator * fPHYPacketListenersIterator; + + bool fDSLimited; + +/*! @struct ExpansionData + @discussion This structure will be used to expand the capablilties of the class in the future. + */ + struct ExpansionData { }; + +/*! @var reserved + Reserved for future use. (Internal use only) */ + ExpansionData *reserved; + + static void clockTick(OSObject *, IOTimerEventSource *); + static void readROMGlue(void *refcon, IOReturn status, + IOFireWireNub *device, IOFWCommand *fwCmd); + static void delayedStateChange(void *refcon, IOReturn status, + IOFireWireBus *bus, IOFWBusCommand *fwCmd); + + virtual void processBusReset(); + virtual void processSelfIDs(UInt32 *IDs, int numIDs, UInt32 *ownIDs, int numOwnIDs); + virtual void processTimeout(IOTimerEventSource *src); + virtual void processRcvPacket( UInt32 *data, int numQuads, IOFWSpeed speed ); + virtual void processWriteRequest(UInt16 sourceID, UInt32 tlabel, + UInt32 *hdr, void *buf, int len, IOFWSpeed speed); + virtual void processLockRequest(UInt16 sourceID, UInt32 tlabel, + UInt32 *hdr, void *buf, int len, IOFWSpeed speed); + + // Process read from a local address, return rcode + virtual UInt32 doReadSpace(UInt16 nodeID, IOFWSpeed &speed, FWAddress addr, UInt32 len, + IOMemoryDescriptor **buf, IOByteCount * offset, IODMACommand **dma_command, + IOFWRequestRefCon refcon); + + // Process write to a local address, return rcode + virtual UInt32 doWriteSpace(UInt16 nodeID, IOFWSpeed &speed, FWAddress addr, UInt32 len, + const void *buf, IOFWRequestRefCon refcon); + + // Process lock to a local address, return rcode + UInt32 doLockSpace(UInt16 nodeID, IOFWSpeed &speed, FWAddress addr, UInt32 inlen, + const UInt32 *newVal, UInt32 &outLen, UInt32 *oldVal, + UInt32 extType, IOFWRequestRefCon refcon); + + virtual void updatePlane(); + virtual void startBusScan(); + + // Called when all devices on bus have been examined + virtual void finishedBusScan(); + + virtual void buildTopology(bool doFWPlane); + + virtual void readDeviceROM(IOFWNodeScan *refCon, IOReturn status); + + virtual IOReturn UpdateROM(); + virtual IOReturn allocAddress(IOFWAddressSpace *space); + virtual void freeAddress(IOFWAddressSpace *space); + + IOFireWireBusAux * createAuxiliary( void ); + +public: + + // Initialization + virtual bool init(IOFireWireLink *fwim); + virtual void free(); + virtual bool start(IOService *provider); + virtual void stop( IOService * provider ); + virtual bool finalize( IOOptionBits options ); + virtual bool requestTerminate( IOService * provider, IOOptionBits options ); + + // Power management + virtual IOReturn setPowerState ( unsigned long powerStateOrdinal, IOService* whatDevice ); + + // Implement IOService::getWorkLoop + virtual IOWorkLoop *getWorkLoop() const; + + // Allocate struct for tracking a transaction + virtual AsyncPendingTrans *allocTrans(IOFWAsyncCommand *cmd=NULL); + virtual void freeTrans(AsyncPendingTrans *trans); + + // Really public methods + + virtual IOReturn getCycleTime(UInt32 &cycleTime); + virtual IOReturn getBusCycleTime(UInt32 &busTime, UInt32 &cycleTime); + + // Methods to manipulate the local Config ROM + virtual IOReturn AddUnitDirectory(IOLocalConfigDirectory *unitDir); + virtual IOReturn RemoveUnitDirectory(IOLocalConfigDirectory *unitDir); + + // Cause a bus reset + virtual IOReturn resetBus(); + + // Send async request packets + virtual IOReturn asyncRead( UInt32 generation, + UInt16 nodeID, + UInt16 addrHi, + UInt32 addrLo, + int speed, + int label, + int size, + IOFWAsyncCommand * cmd ); + + virtual IOReturn asyncWrite( UInt32 generation, + UInt16 nodeID, + UInt16 addrHi, + UInt32 addrLo, + int speed, + int label, + IOMemoryDescriptor * buf, + IOByteCount offset, + int size, + IOFWAsyncCommand * cmd ); + + /* DEPRECATED */ virtual IOReturn asyncWrite( UInt32 generation, + /* DEPRECATED */ UInt16 nodeID, + /* DEPRECATED */ UInt16 addrHi, + /* DEPRECATED */ UInt32 addrLo, + /* DEPRECATED */ int speed, + /* DEPRECATED */ int label, + /* DEPRECATED */ void * data, + /* DEPRECATED */ int size, + /* DEPRECATED */ IOFWAsyncCommand * cmd ); + + /* DEPRECATED */ virtual IOReturn asyncLock( UInt32 generation, + /* DEPRECATED */ UInt16 nodeID, + /* DEPRECATED */ UInt16 addrHi, + /* DEPRECATED */ UInt32 addrLo, + /* DEPRECATED */ int speed, + /* DEPRECATED */ int label, + /* DEPRECATED */ int type, + /* DEPRECATED */ void * data, + /* DEPRECATED */ int size, + /* DEPRECATED */ IOFWAsyncCommand * cmd); + + + // Send async read response packets + // useful for pseudo address spaces that require servicing outside the FireWire work loop. + virtual IOReturn asyncReadResponse( UInt32 generation, + UInt16 nodeID, + int speed, + IOMemoryDescriptor * buf, + IOByteCount offset, + int len, + IOFWRequestRefCon refcon ); + + virtual IOReturn asyncLockResponse( UInt32 generation, + UInt16 nodeID, + int speed, + IOMemoryDescriptor * buf, + IOByteCount offset, + int len, + IOFWRequestRefCon refcon ); + + // Try to fix whatever might have caused the other device to not respond + virtual IOReturn handleAsyncTimeout(IOFWAsyncCommand *cmd); + + // Convert a firewire nodeID into the IOFireWireDevice for it + virtual IOFireWireDevice * nodeIDtoDevice(UInt32 generation, UInt16 nodeID); + + // Add/remove a channel from the list informed of bus resets + virtual void addAllocatedChannel(IOFWIsochChannel *channel); + virtual void removeAllocatedChannel(IOFWIsochChannel *channel); + + // Add/remove a IRM allocation from the list informed of bus resets + virtual void addIRMAllocation(IOFireWireIRMAllocation *irmAllocation); + virtual void removeIRMAllocation(IOFireWireIRMAllocation *irmAllocation); + + // Create an Isochronous Channel object + // doIRM = true => allocate channel and bandwith in Isochronous Resource Manager + // packetSize packet size (in bytes), used to calculate bandwidth needed. + virtual IOFWIsochChannel *createIsochChannel( + bool doIRM, UInt32 packetSize, IOFWSpeed prefSpeed, + FWIsochChannelForceStopNotificationProc stopProc=NULL, + void *stopRefCon=NULL); + + // Create a local isochronous port to run the given DCL program + // if task is 0, the DCL program is for the kernel task, + // otherwise all DCL pointers are valid in the specified task. + // opcodes is also pointer valid in the specified task. + virtual IOFWLocalIsochPort *createLocalIsochPort(bool talking, + DCLCommand* opcodes, DCLTaskInfo *info = 0, + UInt32 startEvent = 0, UInt32 startState = 0, UInt32 startMask = 0); + + // Execute specified function on workloop after specified delay + // Returned command is for delay, call it's cancel() function to cancel timeout. + virtual IOFWDelayCommand * createDelayedCmd(UInt32 uSecDelay, FWBusCallback func, void *refcon); + + virtual IOFWPhysicalAddressSpace *createPhysicalAddressSpace(IOMemoryDescriptor *mem); + virtual IOFWPseudoAddressSpace *createPseudoAddressSpace(FWAddress *addr, UInt32 len, + FWReadCallback reader, FWWriteCallback writer, void *refcon); + + // Extract info about the async request + virtual bool isLockRequest(IOFWRequestRefCon refcon); + virtual bool isQuadRequest(IOFWRequestRefCon refcon); + virtual UInt32 getExtendedTCode(IOFWRequestRefCon refcon); + + // Inline accessors for protected member variables + IOFWCmdQ &getTimeoutQ(); + IOFWCmdQ &getPendingQ(); + IOFWCmdQ &getAfterResetHandledQ(); + IOFireWireLink * getLink() const; + + IOLocalConfigDirectory *getRootDir() const; + bool checkGeneration(UInt32 gen) const; + UInt32 getGeneration() const; + UInt16 getLocalNodeID() const; + IOReturn getIRMNodeID(UInt32 &generation, UInt16 &id); + + const AbsoluteTime * getResetTime() const; + + IOFWSpeed FWSpeed(UInt16 nodeAddress) const; + IOFWSpeed FWSpeed(UInt16 nodeA, UInt16 nodeB) const; + + // How big (as a power of two) can packets sent to/received from the node be? + virtual int maxPackLog(bool forSend, UInt16 nodeAddress) const; + + // How big (as a power of two) can packets sent from A to B be? + virtual int maxPackLog(UInt16 nodeA, UInt16 nodeB) const; + + // Force given node to be root (via root holdoff Phy packet) + virtual IOReturn makeRoot(UInt32 generation, UInt16 nodeID) ; + + virtual IOFWPseudoAddressSpace *createInitialAddressSpace(UInt32 addressLo, UInt32 len, + FWReadCallback reader, FWWriteCallback writer, void *refcon); + + virtual IOFWAddressSpace *getAddressSpace(FWAddress address); + + // Extract info about the async request - was the request ack'ed complete already? + virtual bool isCompleteRequest(IOFWRequestRefCon refcon); + + // Are we currently scanning the bus? + bool scanningBus() const; + +protected: + + void openGate(); + void closeGate(); + +protected: + virtual void doBusReset( void ); + static void resetStateChange( void *refcon, IOReturn status, + IOFireWireBus *bus, IOFWBusCommand *fwCmd); + +public: + virtual IOReturn disableSoftwareBusResets( void ); + virtual void enableSoftwareBusResets( void ); + + virtual IOFWAsyncStreamCommand * createAsyncStreamCommand( UInt32 generation, + UInt32 channel, UInt32 sync, UInt32 tag, IOMemoryDescriptor *hostMem, + UInt32 size, int speed,FWAsyncStreamCallback completion, void *refcon); + + virtual IOReturn asyncStreamWrite(UInt32 generation, + int speed, int tag, int sync, int channel, + IOMemoryDescriptor *buf, IOByteCount offset, + int size, IOFWAsyncStreamCommand *cmd); + +protected: + bool inGate(); + + virtual IOReturn allocatePseudoAddress(FWAddress *addr, UInt32 lenDummy); + virtual void freePseudoAddress(FWAddress addr, UInt32 lenDummy); + + virtual IORegistryEntry * createDummyRegistryEntry( IOFWNodeScan *scan ); + + static IOFireWireLocalNode * getLocalNode(IOFireWireController *control); + + virtual void setPhysicalAccessMode( IOFWPhysicalAccessMode mode ); + virtual IOFWPhysicalAccessMode getPhysicalAccessMode( void ); + virtual void physicalAccessProcessBusReset( void ); + virtual void setNodeIDPhysicalFilter( UInt16 nodeID, bool state ); + + virtual void initSecurity( void ); + virtual void freeSecurity( void ); + static bool serverKeyswitchCallback( void * target, void * refCon, IOService * service, IONotifier * notifier ); + virtual void setSecurityMode( IOFWSecurityMode mode ); + virtual IOFWSecurityMode getSecurityMode( void ); + + virtual IOReturn createTimeoutQ( void ); + virtual void destroyTimeoutQ( void ); + virtual IOReturn createPendingQ( void ); + virtual void destroyPendingQ( void ); + + virtual UInt32 countNodeIDChildren( UInt16 nodeID, int hub_port = 0, int * hubChildRemainder = NULL, bool * hubParentFlag = NULL ); + +public: + virtual UInt32 hopCount(UInt16 nodeAAddress, UInt16 nodeBAddress ); + virtual UInt32 hopCount(UInt16 nodeAAddress ); + + virtual IOFireWirePowerManager * getBusPowerManager( void ); + +protected: + virtual void handleARxReqIntComplete(); + + virtual IOReturn asyncLock( UInt32 generation, + UInt16 nodeID, + UInt16 addrHi, + UInt32 addrLo, + int speed, + int label, + int type, + IOMemoryDescriptor * buf, + IOByteCount offset, + int size, + IOFWAsyncCommand * cmd ); + + virtual IOReturn asyncWrite( UInt32 generation, + UInt16 nodeID, + UInt16 addrHi, + UInt32 addrLo, + int speed, + int label, + IOMemoryDescriptor * buf, + IOByteCount offset, + int size, + IOFWAsyncCommand * cmd, + IOFWWriteFlags flags ); + +protected: + bool delayedStateCommandInUse() const; + void enterBusResetDisabledState( ); + + virtual UInt32 getPortNumberFromIndex( UInt16 index ); + + virtual bool checkForDuplicateGUID(IOFWNodeScan *scan, CSRNodeUniqueID *currentGUIDs ); + virtual void updateDevice(IOFWNodeScan *scan ); + virtual bool AssignCycleMaster(); + +public: + + IOReturn clipMaxRec2K(Boolean clipMaxRec ); + void setNodeSpeed( UInt16 nodeAddress, IOFWSpeed speed ); + void useHalfSizePackets( void ); + void disablePhyPortOnSleepForNodeID( UInt32 nodeID ); + + IOReturn handleAsyncCompletion( IOFWCommand *cmd, IOReturn status ); + void processCycle64Int(); + +#ifdef LEGACY_SHUTDOWN + static IOReturn systemShutDownHandler( void * target, void * refCon, + UInt32 messageType, IOService * service, + void * messageArgument, vm_size_t argSize ); +#else + virtual void systemWillShutdown( IOOptionBits specifier ); +#endif + + IOReturn beginIOCriticalSection( void ); + void endIOCriticalSection( void ); + +protected: + IOReturn poweredStart( void ); + void setNodeSpeed( UInt16 nodeA, UInt16 nodeB, UInt8 speed ); + void setNodeSpeed( UInt16 nodeAddress, UInt8 speed ); + +public: + bool isPhysicalAccessEnabledForNodeID( UInt16 nodeID ); + + // Allocate IRM bandwidth if the specified generation is the current FireWire generation. + IOReturn allocateIRMBandwidthInGeneration(UInt32 bandwidthUnits, UInt32 generation) ; + + // Release IRM bandwidth if the specified generation is the current FireWire generation. + IOReturn releaseIRMBandwidthInGeneration(UInt32 bandwidthUnits, UInt32 generation) ; + + // Allocate IRM channel if the specified generation is the current FireWire generation. + IOReturn allocateIRMChannelInGeneration(UInt8 isochChannel, UInt32 generation) ; + + // Release IRM channel if the specified generation is the current FireWire generation. + IOReturn releaseIRMChannelInGeneration(UInt8 isochChannel, UInt32 generation) ; + + // Create an IOFireWireIRMAllocation object which can be used to allocate isoch resources that are automatically reallocated after bus-resets! + IOFireWireIRMAllocation *createIRMAllocation(Boolean releaseIRMResourcesOnFree = true, + IOFireWireIRMAllocation::AllocationLostNotificationProc allocationLostProc = NULL, + void *pLostNotificationProcRefCon = NULL); + + IOFWAsyncStreamListener *createAsyncStreamListener( UInt32 channel, FWAsyncStreamReceiveCallback proc, void *refcon ); + + void removeAsyncStreamListener( IOFWAsyncStreamListener *listener ); + + IOFWSpeed getBroadcastSpeed(){ return FWSpeed( fLocalNodeID ); }; + +private: + + IOFWAsyncStreamReceiver *allocAsyncStreamReceiver( UInt32 channel, FWAsyncStreamReceiveCallback proc, void *refcon ); + + IOFWAsyncStreamReceiver *getAsyncStreamReceiver( UInt32 channel ); + + void freeAllAsyncStreamReceiver(); + + void activateAsyncStreamReceivers(); + + void deactivateAsyncStreamReceivers(); + +protected: + IOService *findKeyswitchDevice( void ); + void suspendBus( void ); + +public: + virtual IOReturn asyncRead( UInt32 generation, + UInt16 nodeID, + UInt16 addrHi, + UInt32 addrLo, + int speed, + int label, + int size, + IOFWAsyncCommand * cmd, + IOFWReadFlags flags ); + + void checkProgress( void ); + + void terminateDevice( IOFireWireDevice * device ); + + void nodeMustBeRoot( UInt32 nodeID ); + + void nodeMustNotBeRoot( UInt32 nodeID ); + + void setGapCount( UInt32 gapCount ); + + IOReturn asyncPHYPacket( UInt32 generation, + UInt32 data, + UInt32 data2, + IOFWAsyncPHYCommand * cmd ); + + IOFWAsyncPHYCommand * createAsyncPHYCommand( UInt32 generation, + UInt32 data1, + UInt32 data2, + FWAsyncPHYCallback completion, + void * refcon, + bool failOnReset ); + +private: + AsyncPendingTrans * allocTrans( IOFWAsyncCommand * cmd, IOFWCommand * altcmd ); + +public: + + IOReturn activatePHYPacketListener( IOFWPHYPacketListener * listener ); + void deactivatePHYPacketListener( IOFWPHYPacketListener * listener ); + + IOFWPHYPacketListener * createPHYPacketListener( FWPHYPacketCallback proc, void * refcon ); + +private: + void processPHYPacket( UInt32 data1, UInt32 data2 ); + void enterLoggingMode( void ); + +public: + IOReturn getCycleTimeAndUpTime( UInt32 &cycleTime, UInt64 &uptime ); + +protected: + void removeAsyncStreamReceiver( IOFWAsyncStreamReceiver *receiver ); + +public: + + // Create a multi-isoch-receive listener + IOFireWireMultiIsochReceiveListener * createMultiIsochReceiveListener(UInt32 channel, + FWMultiIsochReceiveListenerCallback callback, + void *pCallbackRefCon, + FWMultiIsochReceiveListenerParams *pListenerParams = NULL); + + // Activate a multi-isoch-receive listener + IOReturn activateMultiIsochReceiveListener(IOFireWireMultiIsochReceiveListener *pListener); + + // Deactivate a multi-isoch-receive listener + IOReturn deactivateMultiIsochReceiveListener(IOFireWireMultiIsochReceiveListener *pListener); + + // Call for client to specify he is done with a multi-isoch receiver isoch packet + void clientDoneWithMultiIsochReceivePacket(IOFireWireMultiIsochReceivePacket *pPacket); + +public: + virtual IOFWAsyncStreamCommand * createAsyncStreamCommand( UInt32 generation, + UInt32 channel, UInt32 sync, UInt32 tag, IOMemoryDescriptor *hostMem, + UInt32 size, int speed,FWAsyncStreamCallback completion, void *refcon, bool failOnReset); + +private: + void addToIRMAllocationSet(IOFireWireIRMAllocation *anObject); + void removeFromIRMAllocationSet(IOFireWireIRMAllocation *anObject); + +protected: + OSMetaClassDeclareReservedUnused(IOFireWireController, 0); + OSMetaClassDeclareReservedUnused(IOFireWireController, 1); + OSMetaClassDeclareReservedUnused(IOFireWireController, 2); + OSMetaClassDeclareReservedUnused(IOFireWireController, 3); + OSMetaClassDeclareReservedUnused(IOFireWireController, 4); + OSMetaClassDeclareReservedUnused(IOFireWireController, 5); + OSMetaClassDeclareReservedUnused(IOFireWireController, 6); + OSMetaClassDeclareReservedUnused(IOFireWireController, 7); + OSMetaClassDeclareReservedUnused(IOFireWireController, 8); + +}; + +#endif /* ! _IOKIT_IOFIREWIRECONTROLLER_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFireWireNub.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFireWireNub.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFireWireNub.h (revision 885) @@ -0,0 +1,293 @@ +/* + * Copyright (c) 1998-2002 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@ + */ +/* + * + * IOFireWireNub.h + * + * + * Note: IOFWCommand(s) are allocated by methods in this class. + * The remaining methods to setup and submit IOFWCommands are defined in + * IOFWCommand.h + */ +#ifndef _IOKIT_IOFIREWIRENUB_H +#define _IOKIT_IOFIREWIRENUB_H + +// public +#include +#include +#include + +class IOFireWireController; +class IOFireWireBus; +class IOConfigDirectory; +class IOFireWireNub; +class IOFireWireDevice; +class IOFireWireUnit; +class IOFWSimplePhysicalAddressSpace; +class IOFWSimpleContiguousPhysicalAddressSpace; + +enum TerminationState +{ + kNotTerminated = 0, + kNeedsTermination, + kTerminated +}; + +#pragma mark - + +/*! + @class IOFireWireNubAux +*/ + +class IOFireWireNubAux : public OSObject +{ + OSDeclareDefaultStructors(IOFireWireNubAux) + + friend class IOFireWireNub; + +protected: + + IOFireWireNub * fPrimary; + TerminationState fTerminationState; + + /*! + @struct ExpansionData + @discussion This structure will be used to expand the capablilties of the class in the future. + */ + + struct ExpansionData { }; + + /*! + @var reserved + Reserved for future use. (Internal use only) + */ + + ExpansionData * reserved; + + virtual bool init( IOFireWireNub * primary ); + virtual void free(); + + virtual UInt32 hopCount( IOFireWireNub * nub ); + virtual UInt32 hopCount( void ); + + virtual TerminationState getTerminationState( void ); + virtual void setTerminationState( TerminationState state ); + + virtual bool isPhysicalAccessEnabled( void ); + + virtual IOFWSimpleContiguousPhysicalAddressSpace * createSimpleContiguousPhysicalAddressSpace( vm_size_t size, IODirection direction ); + + virtual IOFWSimplePhysicalAddressSpace * createSimplePhysicalAddressSpace( vm_size_t size, IODirection direction ); + +private: + OSMetaClassDeclareReservedUnused(IOFireWireNubAux, 0); + OSMetaClassDeclareReservedUnused(IOFireWireNubAux, 1); + OSMetaClassDeclareReservedUnused(IOFireWireNubAux, 2); + OSMetaClassDeclareReservedUnused(IOFireWireNubAux, 3); + OSMetaClassDeclareReservedUnused(IOFireWireNubAux, 4); + OSMetaClassDeclareReservedUnused(IOFireWireNubAux, 5); + OSMetaClassDeclareReservedUnused(IOFireWireNubAux, 6); + OSMetaClassDeclareReservedUnused(IOFireWireNubAux, 7); + OSMetaClassDeclareReservedUnused(IOFireWireNubAux, 8); + OSMetaClassDeclareReservedUnused(IOFireWireNubAux, 9); + OSMetaClassDeclareReservedUnused(IOFireWireNubAux, 10); + OSMetaClassDeclareReservedUnused(IOFireWireNubAux, 11); + OSMetaClassDeclareReservedUnused(IOFireWireNubAux, 12); + OSMetaClassDeclareReservedUnused(IOFireWireNubAux, 13); + OSMetaClassDeclareReservedUnused(IOFireWireNubAux, 14); + OSMetaClassDeclareReservedUnused(IOFireWireNubAux, 15); + +}; + +#pragma mark - + +/*! @class IOFireWireNub +*/ +class IOFireWireNub : public IOService +{ + OSDeclareAbstractStructors(IOFireWireNub) + + friend class IOFireWireController; + friend class IOFireWireNubAux; + friend class IOFireWireDeviceAux; + friend class IOFireWireUnitAux; + friend class IOFireWireDevice; + friend class IOFireWireUnit; + +/*------------------Useful info about device (also available in the registry)--------*/ +protected: + int fDeviceSpeed; // Max supported by device + int fCommsSpeed; // Max speed this node can communicate with device + UInt16 fNodeID; // Current node ID (could change after bus reset!) + UInt16 fLocalNodeID; // ID of the local node (could change after bus reset!) + UInt32 fGeneration; // ID Of bus topology that fNodeID is valid for. + CSRNodeUniqueID fUniqueID; // Device's globally unique ID (never changes) + mach_timespec_t fAsyncTimeout; // Guesstimate of how long to wait for response + // from device when making async requests + // Different values for quad/block transfers? + // OS8 FW has 40/100 mSec. + + int fMaxReadPackLog; + int fMaxWritePackLog; + int fMaxReadROMPackLog; + + IOFireWireController *fControl; + IOConfigDirectory *fDirectory; + + UInt32 fNodeFlags; + + OSSet * fConfigDirectorySet; + + IOFireWireNubAux * fAuxiliary; + +/*! @struct ExpansionData + @discussion This structure will be used to expand the capablilties of the class in the future. + */ + struct ExpansionData { }; + +/*! @var reserved + Reserved for future use. (Internal use only) */ + ExpansionData *reserved; + + virtual void free(); + +/*------------------Methods provided to FireWire device clients-----------------------*/ +public: + + // Get nodeID and bus generation info + IOReturn getNodeIDGeneration(UInt32 &generation, UInt16 &nodeID, UInt16 &localID) const; + IOReturn getNodeIDGeneration(UInt32 &generation, UInt16 &nodeID) const; + + // How fast can this system talk to the node? + virtual IOFWSpeed FWSpeed() const; + + // How fast can this node talk to another node? + virtual IOFWSpeed FWSpeed(const IOFireWireNub *dst) const; + + // How big (as a power of two) can packets sent to/received from the node be? + virtual int maxPackLog(bool forSend) const; + + // How big (as a power of two) can packets sent to/received from a specified address in the node be? + virtual int maxPackLog(bool forSend, FWAddress address) const; + + // How big (as a power of two) can packets sent from this node to dst node/received from dst be? + virtual int maxPackLog(bool forSend, const IOFireWireNub *dst) const; + + // Set maximum packet size nub can handle + virtual void setMaxPackLog(bool forSend, bool forROM, int maxPackLog); + + /* + * Create various FireWire commands to send to the device + */ + virtual IOFWReadCommand *createReadCommand(FWAddress devAddress, IOMemoryDescriptor *hostMem, + FWDeviceCallback completion=NULL, void *refcon=NULL, + bool failOnReset=false); + virtual IOFWReadQuadCommand *createReadQuadCommand(FWAddress devAddress, UInt32 *quads, int numQuads, + FWDeviceCallback completion=NULL, void *refcon=NULL, + bool failOnReset=false); + + virtual IOFWWriteCommand *createWriteCommand(FWAddress devAddress, IOMemoryDescriptor *hostMem, + FWDeviceCallback completion=NULL, void *refcon=NULL, + bool failOnReset=false); + virtual IOFWWriteQuadCommand *createWriteQuadCommand(FWAddress devAddress, UInt32 *quads, int numQuads, + FWDeviceCallback completion=NULL, void *refcon=NULL, + bool failOnReset=false); + + // size is 1 for 32 bit compare, 2 for 64 bit. + virtual IOFWCompareAndSwapCommand *createCompareAndSwapCommand(FWAddress devAddress, + const UInt32 *cmpVal, const UInt32 *newVal, int size, + FWDeviceCallback completion=NULL, void *refcon=NULL, + bool failOnReset=false); + /* + * Create local FireWire address spaces for the device to access + */ + virtual IOFWPhysicalAddressSpace *createPhysicalAddressSpace(IOMemoryDescriptor *mem); + virtual IOFWPseudoAddressSpace *createPseudoAddressSpace(FWAddress *addr, UInt32 len, + FWReadCallback reader, FWWriteCallback writer, void *refcon); + + /* + * Get Config directory for nub + * Device nub directory is root directory, Unit nub directory is Unit directory. + * + * Depricated use getConfigDirectoryRef + * + */ + + virtual IOReturn getConfigDirectory(IOConfigDirectory *&dir); + + /* + * Get bus for nub + */ + IOFireWireBus * getBus() const; + + IOFireWireController * getController() const; + + const CSRNodeUniqueID &getUniqueID() const; + + /* + * Standard nub initialization + */ + virtual bool init(OSDictionary * propTable); + + virtual void setNodeFlags( UInt32 flags ); + virtual UInt32 getNodeFlags( void ); + virtual void clearNodeFlags( UInt32 flags ); + + virtual IOReturn setConfigDirectory( IOConfigDirectory *directory ); + + virtual IOReturn getConfigDirectoryRef( IOConfigDirectory *&dir ); + + inline UInt32 hopCount( IOFireWireNub * nub ) + { return fAuxiliary->hopCount( nub ); } + + inline UInt32 hopCount( void ) + { return fAuxiliary->hopCount(); } + + inline TerminationState getTerminationState( void ) + { return fAuxiliary->getTerminationState(); } + +protected: + inline void setTerminationState( TerminationState state ) + { fAuxiliary->setTerminationState( state ); } + + virtual IOFireWireNubAux * createAuxiliary( void ); + +public: + + inline bool isPhysicalAccessEnabled( void ) + { return fAuxiliary->isPhysicalAccessEnabled(); } + + inline IOFWSimpleContiguousPhysicalAddressSpace * createSimpleContiguousPhysicalAddressSpace( vm_size_t size, IODirection direction ) + { return fAuxiliary->createSimpleContiguousPhysicalAddressSpace( size, direction ); } + + inline IOFWSimplePhysicalAddressSpace * createSimplePhysicalAddressSpace( vm_size_t size, IODirection direction ) + { return fAuxiliary->createSimplePhysicalAddressSpace( size, direction ); } + +private: + OSMetaClassDeclareReservedUsed(IOFireWireNub, 0); + OSMetaClassDeclareReservedUsed(IOFireWireNub, 1); + OSMetaClassDeclareReservedUnused(IOFireWireNub, 2); + OSMetaClassDeclareReservedUnused(IOFireWireNub, 3); + +}; + +#endif /* ! _IOKIT_IOFIREWIRENUB_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFireWireBus.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFireWireBus.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFireWireBus.h (revision 885) @@ -0,0 +1,373 @@ +/* + * Copyright (c) 1998-2002 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@ + */ +/* + * Copyright (c) 1999-2002 Apple Computer, Inc. All rights reserved. + * + * HISTORY + * + */ + + +#ifndef _IOKIT_IOFIREWIREBUS_H +#define _IOKIT_IOFIREWIREBUS_H + +#include +#include +#include +#include +#include + +extern const OSSymbol *gFireWireROM; +extern const OSSymbol *gFireWireNodeID; +extern const OSSymbol *gFireWireSelfIDs; +extern const OSSymbol *gFireWireSpeed; +extern const OSSymbol *gFireWireUnit_Spec_ID; +extern const OSSymbol *gFireWireUnit_SW_Version; +extern const OSSymbol *gFireWireVendor_ID; +extern const OSSymbol *gFireWire_GUID; +extern const OSSymbol *gFireWireVendor_Name; +extern const OSSymbol *gFireWireProduct_Name; +extern const OSSymbol *gFireWireModel_ID; +extern const OSSymbol *gFireWireTDM; + +class IOFireWireDevice; +class IOLocalConfigDirectory; +class IOFWLocalIsochPort; +class IOFireWirePowerManager; +class IOFireWireBus; +class IOFWDCLPool; +class IOFWSimpleContiguousPhysicalAddressSpace; +class IOFWSimplePhysicalAddressSpace; +class IOFWUserObjectExporter; + +#pragma mark - + +/*! + @class IOFireWireBusAux +*/ + +class IOFireWireBusAux : public OSObject +{ + OSDeclareAbstractStructors(IOFireWireBusAux) + + friend class IOFireWireBus; + + protected: + + /*! + @struct ExpansionData + @discussion This structure will be used to expand the capablilties of the class in the future. + */ + + struct ExpansionData { }; + + /*! + @var reserved + Reserved for future use. (Internal use only) + */ + + ExpansionData * reserved; + + public : + + virtual IOFWDCLPool * createDCLPool ( unsigned capacity ) const = 0 ; + OSMetaClassDeclareReservedUnused(IOFireWireBusAux, 32); + virtual UInt8 getMaxRec( void ) = 0; + + virtual UInt64 getFireWirePhysicalAddressMask( void ) = 0; + virtual UInt32 getFireWirePhysicalAddressBits( void ) = 0; + virtual UInt64 getFireWirePhysicalBufferMask( void ) = 0; + virtual UInt32 getFireWirePhysicalBufferBits( void ) = 0; + + virtual IOFWSimpleContiguousPhysicalAddressSpace * createSimpleContiguousPhysicalAddressSpace( vm_size_t size, IODirection direction ) = 0; + virtual IOFWSimplePhysicalAddressSpace * createSimplePhysicalAddressSpace( vm_size_t size, IODirection direction ) = 0; + + virtual IOFWUserObjectExporter * getSessionRefExporter( void ) = 0; + + private: + OSMetaClassDeclareReservedUsed(IOFireWireBusAux, 0); + OSMetaClassDeclareReservedUsed(IOFireWireBusAux, 1); + OSMetaClassDeclareReservedUsed(IOFireWireBusAux, 2); + OSMetaClassDeclareReservedUsed(IOFireWireBusAux, 3); + OSMetaClassDeclareReservedUnused(IOFireWireBusAux, 4); + OSMetaClassDeclareReservedUnused(IOFireWireBusAux, 5); + OSMetaClassDeclareReservedUnused(IOFireWireBusAux, 6); + OSMetaClassDeclareReservedUnused(IOFireWireBusAux, 7); + OSMetaClassDeclareReservedUnused(IOFireWireBusAux, 8); + OSMetaClassDeclareReservedUnused(IOFireWireBusAux, 9); + OSMetaClassDeclareReservedUnused(IOFireWireBusAux, 10); + OSMetaClassDeclareReservedUnused(IOFireWireBusAux, 11); + OSMetaClassDeclareReservedUnused(IOFireWireBusAux, 12); + OSMetaClassDeclareReservedUnused(IOFireWireBusAux, 13); + OSMetaClassDeclareReservedUnused(IOFireWireBusAux, 14); + OSMetaClassDeclareReservedUnused(IOFireWireBusAux, 15); + OSMetaClassDeclareReservedUnused(IOFireWireBusAux, 16); + OSMetaClassDeclareReservedUnused(IOFireWireBusAux, 17); + OSMetaClassDeclareReservedUnused(IOFireWireBusAux, 18); + OSMetaClassDeclareReservedUnused(IOFireWireBusAux, 19); + OSMetaClassDeclareReservedUnused(IOFireWireBusAux, 20); + OSMetaClassDeclareReservedUnused(IOFireWireBusAux, 21); + OSMetaClassDeclareReservedUnused(IOFireWireBusAux, 22); + OSMetaClassDeclareReservedUnused(IOFireWireBusAux, 23); + OSMetaClassDeclareReservedUnused(IOFireWireBusAux, 24); + OSMetaClassDeclareReservedUnused(IOFireWireBusAux, 25); + OSMetaClassDeclareReservedUnused(IOFireWireBusAux, 26); + OSMetaClassDeclareReservedUnused(IOFireWireBusAux, 27); + OSMetaClassDeclareReservedUnused(IOFireWireBusAux, 28); + OSMetaClassDeclareReservedUnused(IOFireWireBusAux, 29); + OSMetaClassDeclareReservedUnused(IOFireWireBusAux, 30); + OSMetaClassDeclareReservedUnused(IOFireWireBusAux, 31); + +}; + +#pragma mark - + +/*! + @class IOFireWireBus + @abstract IOFireWireBus is a public class the provides access to + general FireWire functionality... +*/ + +class IOFireWireBus : public IOService +{ + OSDeclareAbstractStructors(IOFireWireBus) + +public: + + struct DCLTaskInfoAux + { + unsigned version ; + union // u + { + struct // v0 + { + IOMemoryMap * bufferMemoryMap ; // This field required to get physical addresses to program DMA. + // If NULL, we try to make the map ourselves. + // If you created a buffer memory descriptor + // for your program's buffers, just call map() on it + // and pass the returned object here... + } v0 ; + + struct // v1 + { + IOMemoryMap * bufferMemoryMap ; // same as 'bufferMemoryMap' from version 0, above. + + IOWorkLoop * workloop ; // A workloop on which to run callbacks for this port.. + // Can be NULL to use FireWire isochronous workloop... + // The workloop will be retained by the program object. + } v1 ; + + struct + { + IOMemoryMap * bufferMemoryMap ; // same as 'bufferMemoryMap' from version 0, above. + + IOWorkLoop * workloop ; // A workloop on which to run callbacks for this port.. + // Can be NULL to use FireWire isochronous workloop... + // The workloop will be retained by the program object. + IOFWIsochPortOptions options ; // extra options + } v2 ; + } u ; + } ; + + // this struct has been redefined for our next generation isochronous architecture, + // but is backwards compatible with the old definition.. This means we should + // be safe when an old-style driver is loaded.. + // To use DCLTaskInfo (see createLocalIsochPort) make sure all 'unused' fields are set to 0 or NULL + // and that auxInfo points to a valid DCLTaskInfoAux struct, defined above. + + struct DCLTaskInfo + { + task_t unused0 ; + vm_address_t unused1 ; + UInt32 unused2 ; + vm_address_t unused3 ; + UInt32 unused4 ; + void (*unused5)(void) ; + DCLTaskInfoAux * auxInfo ; // Refcon for user call + } ; + + static const IORegistryPlane * gIOFireWirePlane; + + IOFireWireBusAux * fAuxiliary; + + // Create an Isochronous Channel object + virtual IOFWIsochChannel *createIsochChannel( + bool doIRM, UInt32 bandwidth, IOFWSpeed prefSpeed, + IOFWIsochChannel::ForceStopNotificationProc stopProc=NULL, + void *stopRefCon=NULL) = 0; + + /*! @function createLocalIsochPort + @abstract Create a local isochronous port to run the given DCL program + @param talking Pass true to create a talker port; pass false to create a listener port. + @param opcodes A pointer to your DCL program (linked list of DCLCommand structs) + To use an IOFWDCL/IOFWDCLPool program, pass the DCLCommand returned by + IOFWDCLPool::getProgram(). + @param info (Optional) Pointer to DCLTaskInfo struct containing additional + configuration information. If you have an IOMemoryMap for your DCL program data buffers, + pass it here. You can also pass an IOWorkLoop if you want to use your own + workloop to handle callbacks for the created port object. + @param startEvent Specifies a bus condition on which the port should start receiving/sending packets + Must be kFWDCLImmediateEvent, kFWDCLCycleEvent, or kFWDCLSyBitsEvent. + Pass kFWDCLImmediateEvent to start without waiting when start() is called. Pass kFWDCLCycleEvent + to start() transmitting at a specified bus cycle time. Pass kFWDCLSyBitsEvent (receive only) + to start receiving packets once an isochronous packet with a specified sync field arrives. + @param startState Pass the value for the desired start condition, as specified by 'startEvent' + kFWDCLImmediateEvent: set to 0 + kFWDCLCycleEvent: the cycle timer value on which to start processing packets. For talker + ports, This value will be masked by 'startMask' and packet processing will be begin on the + next cycle whose lowest bits match the masked value. For listener ports, pass a 15-bit value + containg to the low order two bits of cycleSeconds and the 13-bit cycleCount on which to start + processing packets. + kFWDCLSyBitsEvent: The value of the sync field on which to start receive packets. The value will be masked + by 'startMask'. For DCLCommand based isoch ports, processing will begin on the first received packet + that has an isochronous header sync field matching 'startState'. For IOFWDCL/IOFWDCLPool based + ports, processing will pause on each IOFWDCL that has wait set to true until a packet that has + an isochronous header sync field matching 'startState' is received. + @result Returns an IOFWLocalIsochPort on success.*/ + virtual IOFWLocalIsochPort *createLocalIsochPort(bool talking, + DCLCommand *opcodes, DCLTaskInfo *info = 0, + UInt32 startEvent = 0, UInt32 startState = 0, UInt32 startMask = 0) = 0; + + virtual IOReturn getCycleTime(UInt32 &cycleTime) = 0; + virtual IOReturn getBusCycleTime(UInt32 &busTime, UInt32 &cycleTime) = 0; + + // Methods to manipulate the local Config ROM + virtual IOReturn AddUnitDirectory(IOLocalConfigDirectory *unitDir) = 0; + virtual IOReturn RemoveUnitDirectory(IOLocalConfigDirectory *unitDir) = 0; + + // Cause a bus reset + virtual IOReturn resetBus() = 0; + + // Convert a firewire nodeID into the IOFireWireDevice for it + virtual IOFireWireDevice * nodeIDtoDevice(UInt32 generation, UInt16 nodeID) = 0; + + // Execute specified function on workloop after specified delay + // Returned command is for delay, call it's cancel() function to cancel timeout. + virtual IOFWDelayCommand * createDelayedCmd(UInt32 uSecDelay, FWBusCallback func, void *refcon) = 0; + + virtual IOFWPhysicalAddressSpace *createPhysicalAddressSpace(IOMemoryDescriptor *mem) = 0; + virtual IOFWPseudoAddressSpace *createPseudoAddressSpace(FWAddress *addr, UInt32 len, + FWReadCallback reader, FWWriteCallback writer, void *refcon) = 0; + + + // Extract info about the async request + virtual bool isLockRequest(IOFWRequestRefCon refcon) = 0; + virtual bool isQuadRequest(IOFWRequestRefCon refcon) = 0; + virtual UInt32 getExtendedTCode(IOFWRequestRefCon refcon) = 0; + + // How big (as a power of two) can packets sent to/received from the node be? + virtual int maxPackLog ( bool forSend, UInt16 nodeAddress) const = 0; + + // How big (as a power of two) can packets sent from A to B be? + virtual int maxPackLog ( UInt16 nodeA, UInt16 nodeB) const = 0; + + // Force given node to be root (via root holdoff Phy packet) + virtual IOReturn makeRoot ( UInt32 generation, UInt16 nodeID) = 0; + + // Create address space at fixed address in initial register space + virtual IOFWPseudoAddressSpace * createInitialAddressSpace ( UInt32 addressLo, UInt32 len, + FWReadCallback reader, FWWriteCallback writer, void *refcon) = 0; + + // Get address space object for given address, if any + virtual IOFWAddressSpace * getAddressSpace(FWAddress address) = 0; + + // Extract info about the async request - was the request ack'ed complete already? + virtual bool isCompleteRequest(IOFWRequestRefCon refcon) = 0; + + virtual IOFWAsyncStreamCommand * createAsyncStreamCommand( UInt32 generation, + UInt32 channel, UInt32 sync, UInt32 tag, IOMemoryDescriptor *hostMem, + UInt32 size, int speed,FWAsyncStreamCallback completion=NULL, void *refcon=NULL) = 0; + virtual UInt32 hopCount(UInt16 nodeAAddress, UInt16 nodeBAddress ) = 0; + virtual UInt32 hopCount(UInt16 nodeAAddress ) = 0; + virtual IOFireWirePowerManager * getBusPowerManager( void ) = 0; + +protected: + + virtual IOFireWireBusAux * createAuxiliary( void ) = 0; + + public : + + inline IOFWDCLPool * createDCLPool ( UInt32 capacity = 0 ) { return fAuxiliary->createDCLPool ( capacity ) ; } + inline UInt8 getMaxRec( void ) { return fAuxiliary->getMaxRec(); } + + // get the physical addressing limitations for this controller + + // returns the physical mask for memory addressable by the bus and this controller's DMA engine + // intended for use with IOBufferMemoryDescriptor::inTaskWithPhysicalMask() + // all current hardware is 32 bit --- currently returns 0x00000000FFFFFFFF + // this API is intended for allocating physical buffers. + // it will not return more than 48 bits so that buffer addresses can be turned into FWAddresses + inline UInt64 getFireWirePhysicalAddressMask( void ) + { return fAuxiliary->getFireWirePhysicalAddressMask(); } + + // returns a count of the maximum addressing bits supported by the bus and this controller + // intended for use with IODMACommand::withSpecification() + // all current hardware is 32 bit --- currently returns 32 + // this API is intended for allocating physical buffers. + // it will not return more than 48 bits so that buffer addresses can be turned into FWAddresses + inline UInt32 getFireWirePhysicalAddressBits( void ) + { return fAuxiliary->getFireWirePhysicalAddressBits(); } + + // returns the physical mask for memory addressable by this controller's DMA engine + // intended for use with IOBufferMemoryDescriptor::inTaskWithPhysicalMask() + // all current hardware is 32 bit --- currently returns 0x00000000FFFFFFFF + // this API is to allocate isoch and other buffers that don't need to be addressable by the bus + // it may someday return as high 64 bits + inline UInt64 getFireWirePhysicalBufferMask( void ) + { return fAuxiliary->getFireWirePhysicalBufferMask(); } + + // returns a count of the maximum addressing bits supported by this controller + // intended for use with IODMACommand::withSpecification() + // all current hardware is 32 bit --- currently returns 32 + // this API is to allocate isoch and other buffers that don't need to be addressable by the bus + // it may someday return as high 64 bits + inline UInt32 getFireWirePhysicalBufferBits( void ) + { return fAuxiliary->getFireWirePhysicalBufferBits(); } + + inline IOFWSimpleContiguousPhysicalAddressSpace * createSimpleContiguousPhysicalAddressSpace( vm_size_t size, IODirection direction ) + { return fAuxiliary->createSimpleContiguousPhysicalAddressSpace( size, direction ); } + + inline IOFWSimplePhysicalAddressSpace * createSimplePhysicalAddressSpace( vm_size_t size, IODirection direction ) + { return fAuxiliary->createSimplePhysicalAddressSpace( size, direction ); } + + virtual IOFWAsyncStreamCommand * createAsyncStreamCommand( UInt32 generation, + UInt32 channel, UInt32 sync, UInt32 tag, IOMemoryDescriptor *hostMem, + UInt32 size, int speed,FWAsyncStreamCallback completion, void *refcon, bool failOnReset) = 0; + + inline IOFWUserObjectExporter * getSessionRefExporter( void ) + { return fAuxiliary->getSessionRefExporter(); } + + private: + + OSMetaClassDeclareReservedUsed(IOFireWireBus, 0); + OSMetaClassDeclareReservedUsed(IOFireWireBus, 1); + OSMetaClassDeclareReservedUsed(IOFireWireBus, 2); + OSMetaClassDeclareReservedUsed(IOFireWireBus, 3); + OSMetaClassDeclareReservedUsed(IOFireWireBus, 4); + OSMetaClassDeclareReservedUsed(IOFireWireBus, 5); + OSMetaClassDeclareReservedUsed(IOFireWireBus, 6); + OSMetaClassDeclareReservedUsed(IOFireWireBus, 7); + +}; + +#endif /* ! _IOKIT_IOFIREWIREBUS_H */ + Index: branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWDCLPool.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWDCLPool.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWDCLPool.h (revision 885) @@ -0,0 +1,160 @@ +/* + * IOFWNuDCLPool.h + * IOFireWireFamily + * + * Created by Niels on Fri Mar 07 2003. + * Copyright (c) 2003 Apple Computer, Inc. All rights reserved. + * + * $Log: IOFWDCLPool.h,v $ + * Revision 1.15 2008/11/14 00:17:12 arulchan + * fix for rdar://5939334 + * + * Revision 1.14 2008/03/03 23:31:42 ayanowit + * another gcc-42 fix. + * + * Revision 1.13 2007/01/26 20:52:31 ayanowit + * changes to user-space isoch stuff to support 64-bit apps. + * + * Revision 1.12 2006/02/09 00:21:50 niels + * merge chardonnay branch to tot + * + * Revision 1.11 2005/04/12 20:09:13 niels + * fix memory leak importing NuDCL programs from user space + * + * Revision 1.10.20.2 2006/01/31 04:49:50 collin + * *** empty log message *** + * + * Revision 1.10 2003/11/07 21:24:28 niels + * *** empty log message *** + * + * Revision 1.9 2003/11/07 21:01:18 niels + * *** empty log message *** + * + * Revision 1.8 2003/08/25 08:39:15 niels + * *** empty log message *** + * + * Revision 1.7 2003/08/22 18:15:16 niels + * *** empty log message *** + * + * Revision 1.6 2003/08/15 04:36:55 niels + * *** empty log message *** + * + * Revision 1.5 2003/07/30 05:22:14 niels + * *** empty log message *** + * + * Revision 1.4 2003/07/21 08:48:20 niels + * *** empty log message *** + * + * Revision 1.3 2003/07/21 07:52:13 niels + * *** empty log message *** + * + * Revision 1.2 2003/07/21 06:52:58 niels + * merge isoch to TOT + * + * Revision 1.1.2.3 2003/07/11 18:15:34 niels + * *** empty log message *** + * + * Revision 1.1.2.2 2003/07/09 21:24:00 niels + * *** empty log message *** + * + * Revision 1.1.2.1 2003/07/01 20:54:06 niels + * isoch merge + * + */ + +#import +#import +#import + +class IOFireWireLink ; +class IOFWDCL ; +class IOFWReceiveDCL ; +class IOFWSendDCL ; +class IOFWSkipCycleDCL ; +class IOFireWireUserClient ; +class IOMemoryDescriptor ; +class IOMemoryMap ; +class OSSet; + +/*! @class IOFWDCLPool + @discussion You should never subclass IOFWDCLPool +*/ + +class IOFWDCLPool : public OSObject +{ + OSDeclareAbstractStructors( IOFWDCLPool ) + + friend class IOFireWireUserClient ; + friend class IOFWUserLocalIsochPort ; + + protected: + + class Expansion* fReserved ; // for class expansion + + IOFireWireLink * fLink ; + UInt8 fCurrentTag ; + UInt8 fCurrentSync ; + OSArray* fProgram ; + DCLNuDCLLeader fLeader ; + + public: + + // OSObject + + virtual void free() ; + + // me + + virtual bool initWithLink ( IOFireWireLink& link, UInt32 capacity ) ; + + virtual void setCurrentTagAndSync ( UInt8 tag, UInt8 sync ) ; + + virtual IOFWReceiveDCL* appendReceiveDCL ( + OSSet * updateSet, + UInt8 headerBytes, + UInt32 rangesCount, + IOVirtualRange ranges[] ) ; + virtual IOFWSendDCL* appendSendDCL ( + OSSet * updateSet, + UInt32 rangesCount, + IOVirtualRange ranges[] ) ; + virtual IOFWSkipCycleDCL* appendSkipCycleDCL () ; + virtual const OSArray * getProgramRef () const ; + + protected : + + IOReturn importUserProgram ( + IOMemoryDescriptor * userExportDesc, + unsigned bufferRangeCount, + IOAddressRange bufferRanges[], + IOMemoryMap * bufferMap ) ; + IOReturn importUserDCL( + IOFWDCL * dcl, + void * importData, + IOByteCount & dataSize, + IOMemoryMap * bufferMap ) ; + + + protected : + + virtual IOFWReceiveDCL * allocReceiveDCL () = 0 ; + virtual IOFWSendDCL * allocSendDCL () = 0 ; + virtual IOFWSkipCycleDCL * allocSkipCycleDCL () = 0 ; + + private : + + void appendDCL( IOFWDCL * dcl ) ; + + public : + + DCLCommand * getProgram() ; + + OSMetaClassDeclareReservedUnused ( IOFWDCLPool, 0); + OSMetaClassDeclareReservedUnused ( IOFWDCLPool, 1); + OSMetaClassDeclareReservedUnused ( IOFWDCLPool, 2); + OSMetaClassDeclareReservedUnused ( IOFWDCLPool, 3); + OSMetaClassDeclareReservedUnused ( IOFWDCLPool, 4); + OSMetaClassDeclareReservedUnused ( IOFWDCLPool, 5); + OSMetaClassDeclareReservedUnused ( IOFWDCLPool, 6); + OSMetaClassDeclareReservedUnused ( IOFWDCLPool, 7); +} ; Index: branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFireWireIRMAllocation.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFireWireIRMAllocation.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFireWireIRMAllocation.h (revision 885) @@ -0,0 +1,116 @@ +/* + * Copyright (c) 1998-2006 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_IOFIREWIREIRMALLOCATION_H +#define _IOKIT_IOFIREWIREIRMALLOCATION_H + +#include + +class IOFireWireController; + +//#include +//#include + +/*! @class IOFireWireIRMAllocation +*/ + +class IOFireWireIRMAllocation : public OSObject +{ + friend class IOFireWireController; + + OSDeclareDefaultStructors(IOFireWireIRMAllocation) + +public: + + // Prototype for the callback if reallocation after bus-reset is unsuccessful. + typedef IOReturn (*AllocationLostNotificationProc)(void* refCon, class IOFireWireIRMAllocation* allocation); + + // Initialize the IRM allocation object. + virtual bool init( IOFireWireController * control, + Boolean releaseIRMResourcesOnFree = true, + AllocationLostNotificationProc allocationLostProc = NULL, + void *pLostProcRefCon = NULL); + + // Specify whether of not the IRM resources should automatically + // be released when freeing this allocation object. + virtual void setReleaseIRMResourcesOnFree(Boolean doRelease); + + // Use the IRMAllocation object to allocate isoch resources + virtual IOReturn allocateIsochResources(UInt8 isochChannel, UInt32 bandwidthUnits); + + // Free isoch resources previously allocated with a call to allocateIsochResources + virtual IOReturn deallocateIsochResources(void); + + // Returns true if isoch resources are currently allocated, and if true, the allocated channel, and amount of isoch bandwidth. + virtual Boolean areIsochResourcesAllocated(UInt8 *pAllocatedIsochChannel, UInt32 *pAllocatedBandwidthUnits); + + // Get the refcon + virtual void * GetRefCon(void); + virtual void SetRefCon(void* refCon); + + // Override the base-class release function for special processing + virtual void release() const; + +protected: + + /*! @struct ExpansionData + @discussion This structure will be used to expand the capablilties of the class in the future. + */ + struct ExpansionData { }; + + /*! @var reserved + Reserved for future use. (Internal use only) */ + ExpansionData *reserved; + + // Free the allocation object (and release IRM resources if needed) + virtual void free( void ); + + // Controller will call this to notify about bus-reset complete. + virtual void handleBusReset(UInt32 generation); + + virtual void failedToRealloc(void); + virtual UInt32 getAllocationGeneration(void); + static void threadFunc( void * arg ); + +private: + + AllocationLostNotificationProc fAllocationLostProc; + void *fLostProcRefCon; + Boolean fReleaseIRMResourcesOnFree; + UInt8 fIsochChannel; + UInt32 fBandwidthUnits; + UInt32 fAllocationGeneration; + IORecursiveLock *fLock ; + IOFireWireController *fControl; + Boolean isAllocated; + + OSMetaClassDeclareReservedUnused(IOFireWireIRMAllocation, 0); + OSMetaClassDeclareReservedUnused(IOFireWireIRMAllocation, 1); + OSMetaClassDeclareReservedUnused(IOFireWireIRMAllocation, 2); + OSMetaClassDeclareReservedUnused(IOFireWireIRMAllocation, 3); + OSMetaClassDeclareReservedUnused(IOFireWireIRMAllocation, 4); + OSMetaClassDeclareReservedUnused(IOFireWireIRMAllocation, 5); + OSMetaClassDeclareReservedUnused(IOFireWireIRMAllocation, 6); + OSMetaClassDeclareReservedUnused(IOFireWireIRMAllocation, 7); +}; + +#endif // _IOKIT_IOFIREWIREIRMALLOCATION_H Index: branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWPhysicalAddressSpace.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWPhysicalAddressSpace.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWPhysicalAddressSpace.h (revision 885) @@ -0,0 +1,263 @@ +/* + * Copyright (c) 1998-2002 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_IOFWPHYSICALADDRESSSPACE_H +#define _IOKIT_IOFWPHYSICALADDRESSSPACE_H + +#include +#include + +/* + * Direct physical memory <-> FireWire address. + * Accesses to these addresses may be handled automatically by the + * hardware without notification. + * + * The 64 bit FireWire address of (32 bit) physical addr xxxx:xxxx is hostNode:0000:xxxx:xxxx + */ + +class IOFWPhysicalAddressSpace; + +struct FWSegment +{ + FWAddress address; + UInt32 length; +}; + +#pragma mark - + +/*! + @class IOFWPhysicalAddressSpaceAux +*/ + +class IOFWPhysicalAddressSpaceAux : public IOFWAddressSpaceAux +{ + OSDeclareDefaultStructors(IOFWPhysicalAddressSpaceAux) + + friend class IOFWAddressSpace; + friend class IOFWPhysicalAddressSpace; + +protected: + + /*! + @struct ExpansionData + @discussion This structure will be used to expand the capablilties of the class in the future. + */ + + struct ExpansionData { }; + + /*! + @var reserved + Reserved for future use. (Internal use only) + */ + + ExpansionData *reserved; + + IODMACommand * fDMACommand; + bool fDMACommandPrepared; + +public: + virtual bool init( IOFWAddressSpace * primary ); + virtual void free(); + + void setDMACommand( IODMACommand * dma_command ); + IODMACommand * getDMACommand( void ); + UInt64 getPhysicalSegment( UInt64 offset, UInt64 * length ); + + IOReturn prepare( void ); + IOReturn synchronize( IOOptionBits options ); + IOReturn complete( void ); + + bool isPrepared( void ); + + IOReturn getSegments( UInt64 * offset, FWSegment * fw_segments, UInt32 * num_segments ); + +private: + OSMetaClassDeclareReservedUnused(IOFWPhysicalAddressSpaceAux, 0); + OSMetaClassDeclareReservedUnused(IOFWPhysicalAddressSpaceAux, 1); + OSMetaClassDeclareReservedUnused(IOFWPhysicalAddressSpaceAux, 2); + OSMetaClassDeclareReservedUnused(IOFWPhysicalAddressSpaceAux, 3); + OSMetaClassDeclareReservedUnused(IOFWPhysicalAddressSpaceAux, 4); + OSMetaClassDeclareReservedUnused(IOFWPhysicalAddressSpaceAux, 5); + OSMetaClassDeclareReservedUnused(IOFWPhysicalAddressSpaceAux, 6); + OSMetaClassDeclareReservedUnused(IOFWPhysicalAddressSpaceAux, 7); + OSMetaClassDeclareReservedUnused(IOFWPhysicalAddressSpaceAux, 8); + OSMetaClassDeclareReservedUnused(IOFWPhysicalAddressSpaceAux, 9); + +}; + +#pragma mark - + +/*! + @class IOFWPhysicalAddressSpace +*/ + +class IOFWPhysicalAddressSpace : public IOFWAddressSpace +{ + OSDeclareDefaultStructors(IOFWPhysicalAddressSpace) + + friend class IOFWPhysicalAddressSpaceAux; + +protected: + + IOMemoryDescriptor * fMem; // unused + vm_size_t fLen; // unused + + virtual void free(); + +public: + +/*! @function init + @abstract Initialize physical address space. + @param bus Points to IOFireWireBus object. + @result returns true if success, else false */ + virtual bool init( IOFireWireBus * bus ); + +/*! @function initWithDesc + @abstract Initialize physical address space with IOMemoryDescriptor. + @param bus Points to IOFireWireBus object. + @param mem Points to IOMemoryDescriptor. + @result returns true if success, else false */ + virtual bool initWithDesc(IOFireWireBus *bus, + IOMemoryDescriptor *mem); + +/*! @function doRead + @abstract A method for processing an address space read request + @param nodeID FireWire Read from nodeID. + @param speed at this 'speed'. + @param addr with FireWire address 'addr'. + @param len read 'len' bytes from nodeID. + @param buf points to a memory descriptor containing the packet data. + @param offset start from this 'offset' in 'buf'. + @param refcon Can be queried for extra info about the request. + @result UIn32 returns kFWResponseComplete on success */ + virtual UInt32 doRead(UInt16 nodeID, IOFWSpeed &speed, FWAddress addr, UInt32 len, + IOMemoryDescriptor **buf, IOByteCount * offset, + IOFWRequestRefCon refcon); + +/*! @function doWrite + @abstract A method for processing an address space write request + @param nodeID FireWire Write to nodeID. + @param speed at this 'speed'. + @param addr with FireWire address 'addr'. + @param len write 'len' bytes to nodeID. + @param buf obtain bytes from location given by 'buf'. + @param reqrefcon Can be queried for extra info about the request. + @result UIn32 returns kFWResponseComplete on success */ + virtual UInt32 doWrite(UInt16 nodeID, IOFWSpeed &speed, FWAddress addr, UInt32 len, + const void *buf, IOFWRequestRefCon refcon); + +/*! @function getMemoryDescriptor + @abstract Gets the memory descriptor, which is associated to this + PhysicalAddressSpace. + @param none. + @result returns the IOMemoryDescriptor */ + IOMemoryDescriptor * getMemoryDescriptor( void ); + +/*! @function setMemoryDescriptor + @abstract Sets the memory descriptor, which will be associated to this + PhysicalAddressSpace. + @param none. + @result returns the IOMemoryDescriptor */ + IOReturn setMemoryDescriptor( IOMemoryDescriptor * descriptor ); + +/*! @function getLength + @abstract Get the length of the memory backed by PhysicalAddressSpace. + @param none. + @result returns the length */ + UInt64 getLength( void ); + +/*! @function setDMACommand + @abstract Set the DMACommand for this PhysicalAddressSpace. + @param dma_command Points to IODMACommand object. + @result none */ + inline void setDMACommand( IODMACommand * dma_command ) + { ((IOFWPhysicalAddressSpaceAux*)fIOFWAddressSpaceExpansion->fAuxiliary)->setDMACommand( dma_command ); }; + +/*! @function getDMACommand + @abstract Get the DMACommand from this PhysicalAddressSpace. + @param none. + @result return previously assigned IODMACommand, null if not initialized */ + inline IODMACommand * getDMACommand( void ) + { return ((IOFWPhysicalAddressSpaceAux*)fIOFWAddressSpaceExpansion->fAuxiliary)->getDMACommand(); }; + +/*! @function initWithDMACommand + @abstract Initialize physical address space with IODMACommand. + @param bus Points to IOFireWireBus object. + @param command Points to IODMACommand. + @result returns true if success, else false */ + virtual bool initWithDMACommand( IOFireWireBus * control, IODMACommand * command ); + +/*! @function prepare + @abstract Prepare the IODMACommand used by this PhysicalAddressSpace. + @param none. + @result returns kIOReturnSuccess on success */ + inline IOReturn prepare( void ) + { return ((IOFWPhysicalAddressSpaceAux*)fIOFWAddressSpaceExpansion->fAuxiliary)->prepare(); }; + +/*! @function synchronize + @abstract synchronize the IODMACommand used by this PhysicalAddressSpace. + @param none. + @result returns kIOReturnSuccess on success */ + inline IOReturn synchronize( IOOptionBits options ) + { return ((IOFWPhysicalAddressSpaceAux*)fIOFWAddressSpaceExpansion->fAuxiliary)->synchronize( options ); }; + +/*! @function complete + @abstract complete the IODMACommand used by this PhysicalAddressSpace. + @param none. + @result returns kIOReturnSuccess on success */ + inline IOReturn complete( void ) + { return ((IOFWPhysicalAddressSpaceAux*)fIOFWAddressSpaceExpansion->fAuxiliary)->complete(); }; + +/*! @function isPrepared + @abstract Inspects whether the IODMACommand was prepared in this PhysicalAddressSpace. + @param none. + @result returns true if prepared, else false */ + inline bool isPrepared( void ) + { return ((IOFWPhysicalAddressSpaceAux*)fIOFWAddressSpaceExpansion->fAuxiliary)->isPrepared(); }; + +/*! @function getSegments + @abstract Returns the scatter gather list of memory segments from the IODMACommand + used in this PhysicalAddressSpace. + @param offset input/output parameter, defines the starting and ending offset in the memory + descriptor, relative to any offset passed to the prepare() method. + FWSegment Points to an array of memory segments. + num_segments Size of the FWSegment array. + @result returns kIOReturnSuccess on success */ + inline IOReturn getSegments( UInt64 * offset, FWSegment * fw_segments, UInt32 * num_segments ) + { return ((IOFWPhysicalAddressSpaceAux*)fIOFWAddressSpaceExpansion->fAuxiliary)->getSegments( offset, fw_segments, num_segments ); }; + +/*! @function checkMemoryInRange + @abstract Validates the IOMemoryDescriptor, which is used to initialize the PhysicalAddressSpace. + @param memory Points to a valid IOMemoryDescriptor. + @result returns kIOReturnSuccess on success */ + IOReturn checkMemoryInRange( IOMemoryDescriptor * memory ); + +protected: + + UInt64 getPhysicalSegment( UInt64 offset, UInt64 * length ) + { return ((IOFWPhysicalAddressSpaceAux*)fIOFWAddressSpaceExpansion->fAuxiliary)->getPhysicalSegment( offset, length); }; + + virtual IOFWAddressSpaceAux * createAuxiliary( void ); + +}; + +#endif Index: branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWPHYPacketListener.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWPHYPacketListener.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWPHYPacketListener.h (revision 885) @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2007 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 _IOFWPHYPACKETLISTENER_H_ +#define _IOFWPHYPACKETLISTENER_H_ + +#include + +class IOFireWireController; + +// Callback when phy packet is received +typedef void (*FWPHYPacketCallback)( void *refcon, UInt32 data1, UInt32 data2 ); + +/*! @class IOFWPHYPacketListener +*/ + +class IOFWPHYPacketListener : public OSObject +{ + OSDeclareDefaultStructors( IOFWPHYPacketListener ); + + friend class IOFireWireController; + +protected: + + IOFireWireController * fControl; + FWPHYPacketCallback fCallback; + void * fRefCon; + + static IOFWPHYPacketListener * createWithController( IOFireWireController * controller ); + + virtual bool initWithController( IOFireWireController * control ); + virtual void free( void ); + +public: + + virtual IOReturn activate( void ); + virtual void deactivate( void ); + + virtual void setCallback( FWPHYPacketCallback callback ); + virtual void setRefCon( void * refcon ); + virtual void * getRefCon( void ); + +protected: + virtual void processPHYPacket( UInt32 data1, UInt32 data2 ); + + OSMetaClassDeclareReservedUnused( IOFWPHYPacketListener, 0 ); + OSMetaClassDeclareReservedUnused( IOFWPHYPacketListener, 1 ); + OSMetaClassDeclareReservedUnused( IOFWPHYPacketListener, 2 ); + OSMetaClassDeclareReservedUnused( IOFWPHYPacketListener, 3 ); + OSMetaClassDeclareReservedUnused( IOFWPHYPacketListener, 4 ); + OSMetaClassDeclareReservedUnused( IOFWPHYPacketListener, 5 ); + OSMetaClassDeclareReservedUnused( IOFWPHYPacketListener, 6 ); + OSMetaClassDeclareReservedUnused( IOFWPHYPacketListener, 7 ); + OSMetaClassDeclareReservedUnused( IOFWPHYPacketListener, 8 ); + OSMetaClassDeclareReservedUnused( IOFWPHYPacketListener, 9 ); +}; + +#endif \ No newline at end of file Index: branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWIsochChannel.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWIsochChannel.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWIsochChannel.h (revision 885) @@ -0,0 +1,132 @@ +/* + * Copyright (c) 1998-2002 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@ + */ +/* + * Copyright (c) 1999-2002 Apple Computer, Inc. All rights reserved. + * + * HISTORY + * + */ + + +#ifndef _IOKIT_IOFWISOCHCHANNEL_H +#define _IOKIT_IOFWISOCHCHANNEL_H + +#include +#include + +enum +{ + kFWIsochChannelUnknownCondition = 0, + kFWIsochChannelNotEnoughBandwidth = 1, + kFWIsochChannelChannelNotAvailable = 2 +}; + +class IOFireWireController; +class IOFWIsochChannel; +class IOFWIsochPort; +class OSSet; +class IOFWReadQuadCommand; +class IOFWCompareAndSwapCommand; + +/*! @class IOFWIsochChannel +*/ +class IOFWIsochChannel : public OSObject +{ + OSDeclareDefaultStructors(IOFWIsochChannel) + + public: + + typedef IOReturn (ForceStopNotificationProc)(void* refCon, IOFWIsochChannel* channel, UInt32 stopCondition ); + +protected: + IOFireWireController * fControl; + ForceStopNotificationProc* fStopProc; + void * fStopRefCon; + IOFWIsochPort * fTalker; + OSSet * fListeners; + bool fDoIRM; + UInt32 fBandwidth; // Allocation units used + UInt32 fPacketSize; + IOFWSpeed fPrefSpeed; + IOFWSpeed fSpeed; // Actual speed used + UInt32 fChannel; // Actual channel used + IOFWReadQuadCommand * fReadCmd; + IOFWCompareAndSwapCommand * fLockCmd; + UInt32 fGeneration; // When bandwidth was allocated + + IOLock * fLock; + +/*! @struct ExpansionData + @discussion This structure will be used to expand the capablilties of the class in the future. + */ + struct ExpansionData { }; + +/*! @var reserved + Reserved for future use. (Internal use only) */ + ExpansionData *reserved; + + static void threadFunc( void * arg ); + + virtual IOReturn updateBandwidth(bool claim); + virtual void reallocBandwidth( UInt32 generation ); + virtual void free(); + +public: + // Called from IOFireWireController + virtual bool init( IOFireWireController *control, bool doIRM, UInt32 packetSize, + IOFWSpeed prefSpeed, ForceStopNotificationProc* stopProc, + void *stopRefCon ); + virtual void handleBusReset(); + + // Called by clients + virtual IOReturn setTalker(IOFWIsochPort *talker); + virtual IOReturn addListener(IOFWIsochPort *listener); + + virtual IOReturn allocateChannel(); + virtual IOReturn releaseChannel(); + virtual IOReturn start(); + virtual IOReturn stop(); + +protected: + // handles IRM and channel determination and allocation. + // called by both user and kernel isoch channels + IOReturn allocateChannelBegin( IOFWSpeed speed, UInt64 allowedChans, UInt32 * channel = NULL ) ; + + // handles IRM and channel allocation. + // called by both user and kernel isoch channels + IOReturn releaseChannelComplete() ; + + IOReturn checkMemoryInRange( IOMemoryDescriptor * memory ); + +private: + OSMetaClassDeclareReservedUnused(IOFWIsochChannel, 0); + OSMetaClassDeclareReservedUnused(IOFWIsochChannel, 1); + OSMetaClassDeclareReservedUnused(IOFWIsochChannel, 2); + OSMetaClassDeclareReservedUnused(IOFWIsochChannel, 3); + +}; + +typedef IOFWIsochChannel::ForceStopNotificationProc FWIsochChannelForceStopNotificationProc ; +typedef IOFWIsochChannel::ForceStopNotificationProc* FWIsochChannelForceStopNotificationProcPtr ; + +#endif /* ! _IOKIT_IOFWISOCHCHANNEL_H */ + Index: branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWUserObjectExporter.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWUserObjectExporter.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWUserObjectExporter.h (revision 885) @@ -0,0 +1,95 @@ +/* + * Copyright (c) 1998-2008 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@ + */ + +/*! @class IOFWUserObjectExporter + @discussion An IOFWUserObjectExporter is for internal use only. You should never subclass IOFWUserObjectExporter +*/ + + namespace IOFireWireLib + { + typedef UInt32 UserObjectHandle; + } + +#ifdef KERNEL + + class IOFWUserObjectExporter : public OSObject + { + OSDeclareDefaultStructors (IOFWUserObjectExporter ) + + public : + + typedef void (*CleanupFunction)( const OSObject * obj ); + typedef void (*CleanupFunctionWithExporter)( const OSObject * obj, IOFWUserObjectExporter * ); + + private : + + unsigned fCapacity; + unsigned fObjectCount; + const OSObject ** fObjects; + CleanupFunctionWithExporter * fCleanupFunctions; + IOLock * fLock; + OSObject * fOwner; + + public : + + static IOFWUserObjectExporter * createWithOwner( OSObject * owner ); + bool initWithOwner( OSObject * owner ); + + virtual bool init(); + + virtual void free (); + virtual bool serialize ( OSSerialize * s ) const; + + // me + IOReturn addObject ( OSObject * obj, CleanupFunction cleanup, IOFireWireLib::UserObjectHandle * outHandle ); + void removeObject ( IOFireWireLib::UserObjectHandle handle ); + + // the returned object is retained! This is for thread safety.. if someone else released + // the object from the pool after you got it, you be in for Trouble + // Release the returned value when you're done!! + const OSObject * lookupObject ( IOFireWireLib::UserObjectHandle handle ) const; + const OSObject * lookupObjectForType( IOFireWireLib::UserObjectHandle handle, const OSMetaClass * toType ) const; + void removeAllObjects (); + + void lock () const; + void unlock () const; + + OSObject * getOwner() const; + + const IOFireWireLib::UserObjectHandle lookupHandle ( OSObject * object ) const; + + // don't subclass, but just in case someone does... + + private: + + OSMetaClassDeclareReservedUnused(IOFWUserObjectExporter, 0); + OSMetaClassDeclareReservedUnused(IOFWUserObjectExporter, 1); + OSMetaClassDeclareReservedUnused(IOFWUserObjectExporter, 2); + OSMetaClassDeclareReservedUnused(IOFWUserObjectExporter, 3); + OSMetaClassDeclareReservedUnused(IOFWUserObjectExporter, 4); + OSMetaClassDeclareReservedUnused(IOFWUserObjectExporter, 5); + OSMetaClassDeclareReservedUnused(IOFWUserObjectExporter, 6); + OSMetaClassDeclareReservedUnused(IOFWUserObjectExporter, 7); + + }; + +#endif Index: branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWAsyncStreamListener.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWAsyncStreamListener.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWAsyncStreamListener.h (revision 885) @@ -0,0 +1,132 @@ +/* + * Copyright (c) 1998-2001 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_IOFWASYNCSTREAMLISTENER_H +#define _IOKIT_IOFWASYNCSTREAMLISTENER_H + +#include +#include +#include +#include + +class IOFWAsyncStreamReceiver; +class IOFWAsyncStreamReceivePort; + +/*! @class IOFWAsyncStreamListener +*/ +class IOFWAsyncStreamListener : public OSObject +{ + OSDeclareDefaultStructors(IOFWAsyncStreamListener) + +friend class IOFWAsyncStreamReceiver; +friend class IOFireWireController; + +public: + +/*! @function initAll + @abstract Creates an AsyncStream client for an Isoch channel. + @param control Points to IOFireWireController. + @param channel Isoch channel for listening. + @param proc Callback on packet reception. + @param obj Client's callback object. + @result returns true on success, else false. */ + bool initAll( IOFireWireController *control, UInt32 channel, FWAsyncStreamReceiveCallback proc, void *refcon ); + +/*! @function setListenerHandler + @abstract Set the callback that should be called to handle incoming async stream packets + @param inReceiver The callback to set. + @result Returns the callback that was previously set or nil for none.*/ + const FWAsyncStreamReceiveCallback setListenerHandler( FWAsyncStreamReceiveCallback inReceiver ); + +/*! @function TurnOffNotification + @abstract Turns off client callback notification. + @result none. */ + inline void TurnOffNotification() { fNotify = false; }; + +/*! @function TurnOnNotification + @abstract Turns on client callback notification. + @result none. */ + inline void TurnOnNotification() { fNotify = true; }; + +/*! @function IsNotificationOn + @abstract checks the notification state. + @result true if ON, else false */ + inline bool IsNotificationOn() { return fNotify; }; + +/*! @function setFlags + @abstract set flags for the listener. + @param flags indicate performance metrics. + @result none. */ + void setFlags( UInt32 flags ); + +/*! @function getFlags + @abstract get the flags of listener. + @param none. + @result flags. */ + UInt32 getFlags(); + +/*! @function getRefCon + @abstract get the refcon specific to this listener. + @param none. + @result fRefCon refcon passed during initialization. */ + inline void* getRefCon() { return fRefCon; }; + +/*! @function getOverrunCounter + @abstract get overrun counter from the DCL program. + @param none. + @result returns the counter value. */ + UInt32 getOverrunCounter(); + +protected: + + FWAsyncStreamReceiveCallback fClientProc; + void *fRefCon; + IOFWAsyncStreamReceiver *fReceiver; + bool fNotify; + UInt32 fFlags; + IOFireWireController *fControl; + +/*! @struct ExpansionData + @discussion This structure will be used to expand the capablilties of the class in the future. + */ + struct ExpansionData { }; + +/*! @var reserved + Reserved for future use. (Internal use only) */ + ExpansionData *reserved; + + virtual void free(); + +private: +/*! function getReceiver + abstract Returns the Async Stream receiver object which tracks multiple + IOFWAsyncStreamListeners for the same Isoc channel. */ + inline IOFWAsyncStreamReceiver *getReceiver() { return fReceiver; }; + +/*! function invokeClients + abstract Invokes client's callback function with fRefCon. */ + void invokeClients( UInt8 *buffer ); + + OSMetaClassDeclareReservedUnused(IOFWAsyncStreamListener, 0); + OSMetaClassDeclareReservedUnused(IOFWAsyncStreamListener, 1); +}; +#endif // _IOKIT_IOFWASYNCSTREAMLISTENER_H + Index: branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFireWireDevice.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFireWireDevice.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFireWireDevice.h (revision 885) @@ -0,0 +1,289 @@ +/* + * Copyright (c) 1998-2002 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 + This header contains the definition of the IOFireWireDevice and IOFireWireDeviceAux classes. + An IOFireWireDevice object represents a FireWire device in the I/O Registry. + It is strongly recommended that you write applications that access FireWire devices rather than in-kernel device drivers. + For more information on how to do this, see {@linkdoc //apple_ref/doc/uid/TP40000969 FireWire Device Interface Guide}. + @indexgroup FireWire + */ +#ifndef _IOKIT_IOFIREWIREDEVICE_H +#define _IOKIT_IOFIREWIREDEVICE_H + +#include + +class IOFireWireROMCache; + +struct IOFWNodeScan; +struct RomScan; + +class IOFireWireDevice; + +#pragma mark - + +/*! @class IOFireWireDeviceAux + @discussion An IOFireWireDeviceAux is for internal use only. You should never subclass IOFireWireDeviceAux +*/ + +class IOFireWireDeviceAux : public IOFireWireNubAux +{ + OSDeclareDefaultStructors(IOFireWireDeviceAux) + + friend class IOFireWireDevice; + +protected: + + UInt32 fUnitCount; + IOFWSpeed fMaxSpeed; + OSSet * fOpenUnitSet; + AbsoluteTime fResumeTime; + + /*! + @struct ExpansionData + @discussion This structure will be used to expand the capablilties of the class in the future. + */ + + struct ExpansionData { }; + + /*! + @var reserved + Reserved for future use. (Internal use only) + */ + + ExpansionData * reserved; + + virtual bool init( IOFireWireDevice * primary ); + + virtual void free(); + + virtual bool isTerminated( void ); + + virtual void setTerminationState( TerminationState state ); + + void setMaxSpeed( IOFWSpeed speed ); + + void setUnitCount( UInt32 count ); + + UInt32 getUnitCount( void ); + + bool isPhysicalAccessEnabled( void ); + + virtual IOFWSimpleContiguousPhysicalAddressSpace * createSimpleContiguousPhysicalAddressSpace( vm_size_t size, IODirection direction ); + + virtual IOFWSimplePhysicalAddressSpace * createSimplePhysicalAddressSpace( vm_size_t size, IODirection direction ); + + OSSet * getOpenUnitSet() const; + + void latchResumeTime( void ); + + AbsoluteTime getResumeTime( void ); + +private: + OSMetaClassDeclareReservedUnused(IOFireWireDeviceAux, 0); + OSMetaClassDeclareReservedUnused(IOFireWireDeviceAux, 1); + OSMetaClassDeclareReservedUnused(IOFireWireDeviceAux, 2); + OSMetaClassDeclareReservedUnused(IOFireWireDeviceAux, 3); +}; + +#pragma mark - +/*! @class IOFireWireDevice + @abstract Represents a FireWire device. + @discussion The FireWire family tries to read the configuration ROM of each device on the FireWire bus. For each device that responds with + its bus information block, the FireWire family publishes an IOFireWireDevice object in the I/O Registry. An + IOFireWireDevice object keeps track of the device's node ID, copies config ROM properties into the object's property + list, and scans the config ROM for unit directories, publishing an IOFireWireUnit object for each unit directory it finds. +*/ + +class IOFireWireDevice : public IOFireWireNub +{ + OSDeclareDefaultStructors(IOFireWireDevice) + + friend class IOFireWireController; + friend class IOFireWireDeviceAux; + +protected: + + enum RegistrationState + { + kDeviceRegistered, + kDeviceNeedsRegisterService, + kDeviceNotRegistered + }; + + IOFireWireROMCache *fDeviceROM; + bool fOpenFromDevice; + UInt32 fOpenFromUnitCount; + UInt32 fROMGeneration; + IORecursiveLock *fROMLock; + RegistrationState fRegistrationState; + UInt32 fROMReadRetry; + +/*! @struct ExpansionData + @discussion This structure will be used to expand the capablilties of the class in the future. + */ + struct ExpansionData { }; + +/*! @var reserved + Reserved for future use. (Internal use only) */ + ExpansionData *reserved; + + static void readROMDirGlue(void *refcon, IOReturn status, + IOFireWireNub *device, IOFWCommand *fwCmd); + static void readROMThreadFunc(void *arg); + + static void terminateDevice(void *arg); + + void processROM(RomScan *romScan); + + virtual void free(); + +public: + virtual IOReturn message( UInt32 type, IOService * provider, void * argument ); + + virtual bool handleOpen( IOService * forClient, IOOptionBits options, void * arg ); + + virtual void handleClose( IOService * forClient, IOOptionBits options ); + + virtual bool handleIsOpen( const IOService * forClient ) const; + +protected: + virtual IOReturn cacheROM(OSData *rom, UInt32 offset, const UInt32 *&romBase); + + virtual const UInt32 * getROMBase(); + + virtual void setNodeROM(UInt32 generation, UInt16 localNodeID, const IOFWNodeScan *info); + +public: + virtual bool matchPropertyTable(OSDictionary * table); + + /*! @function init + @abstract Initializes the nub. + @param propTable Property table passed to the standard nub initialization. + @param scan Pointer to the node scan structure. + @result Returns true if initialization was successful; false otherwise. + */ + virtual bool init(OSDictionary * propTable, const IOFWNodeScan *scan); + + virtual bool attach(IOService * provider ); + + virtual bool finalize( IOOptionBits options ); + + /*! @function setNodeFlags + @abstract Sets the node's characteristics. + @param flags Refer to "node flags" in IOFireWireFamilyCommon.h. + */ + virtual void setNodeFlags( UInt32 flags ); + + /*! @function clearNodeFlags + @abstract Resets the node's characteristics. + @param flags Refer to "node flags" in IOFireWireFamilyCommon.h. + */ + virtual void clearNodeFlags( UInt32 flags ); + + /*! @function getNodeFlags + @abstract Retrieves the node's characteristics. + @param flags Refer to "node flags" in IOFireWireFamilyCommon.h. + @result UInt32 The flags set for a particular node. + */ + virtual UInt32 getNodeFlags( void ); + +protected: + virtual IOReturn configureNode( void ); + +public: + /*! @function createPhysicalAddressSpace + @abstract Creates local physical FireWire address spaces for the device to access. + @param mem Memory area allocated to back the physical access by Link hardware. + @result A valid IOFWPhysicalAddressSpace object on success; NULL on failure. + */ + virtual IOFWPhysicalAddressSpace *createPhysicalAddressSpace(IOMemoryDescriptor *mem); + + /*! @function createPseudoAddressSpace + @abstract Creates local pseudo FireWire address spaces for the device to access. + @param addr The FireWire address that is mapped to the pseudo address access. + @param len Size of the address space to allocate. + @param reader Read callback, when the device reads from this address space. + @param writer Write callback, when the device writes to this address space. + @param refcon Client's callback object returned during reader/writer callbacks. + @result A valid IOFWPseudoAddressSpace object on success; NULL on failure. + */ + virtual IOFWPseudoAddressSpace *createPseudoAddressSpace(FWAddress *addr, UInt32 len, + FWReadCallback reader, FWWriteCallback writer, void *refcon); + +protected: + virtual IOReturn readRootDirectory( IOConfigDirectory * directory, OSDictionary * propTable ); + + virtual IOReturn processRootDirectory( OSDictionary * propTable ); + + virtual IOReturn readUnitDirectories( IOConfigDirectory * directory, OSSet * unitInfo ); + + virtual IOReturn processUnitDirectories( OSSet * unitSet ); + + virtual void setRegistrationState( RegistrationState fRegistrationState ); + + virtual void preprocessDirectories( OSDictionary * rootPropTable, OSSet * unitSet ); + + virtual void configurePhysicalFilter( void ); + +protected: + virtual IOFireWireNubAux * createAuxiliary( void ); + +public: + inline bool isTerminated( void ) + { return ((IOFireWireDeviceAux*)fAuxiliary)->isTerminated(); } + + /*! @function setMaxSpeed + @abstract Sets the maximum speed for this node. + @param speed Maximum speed. Refer to "bus speed numbers" in IOFireWireFamilyCommon.h. + */ + inline void setMaxSpeed( IOFWSpeed speed ) + { ((IOFireWireDeviceAux*)fAuxiliary)->setMaxSpeed( speed ); } + +protected: + inline void setUnitCount( UInt32 count ) + { ((IOFireWireDeviceAux*)fAuxiliary)->setUnitCount( count ); } + + inline OSSet * getOpenUnitSet( void ) const + { return ((IOFireWireDeviceAux*)fAuxiliary)->getOpenUnitSet(); } + +public: + /*! @function getUnitCount + @abstract Returns number of units attached to this device. + @result UInt32 The number of units attached to this device. + */ + inline UInt32 getUnitCount( void ) + { return ((IOFireWireDeviceAux*)fAuxiliary)->getUnitCount(); } + +protected: + inline AbsoluteTime getResumeTime( void ) + { return ((IOFireWireDeviceAux*)fAuxiliary)->getResumeTime(); } + + inline void latchResumeTime( void ) + { ((IOFireWireDeviceAux*)fAuxiliary)->latchResumeTime(); } + +private: + OSMetaClassDeclareReservedUnused(IOFireWireDevice, 0); + OSMetaClassDeclareReservedUnused(IOFireWireDevice, 1); + +}; + +#endif /* ! _IOKIT_IOFIREWIREDEVICE_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWDCL.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWDCL.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/firewire/IOFWDCL.h (revision 885) @@ -0,0 +1,346 @@ +/* +* IOFWDCL.h +* IOFireWireFamily +* +* Created by Niels on Fri Feb 21 2003. +* Copyright (c) 2003 Apple Computer, Inc. All rights reserved. +* +* $Log: IOFWDCL.h,v $ +* Revision 1.20 2008/11/14 00:17:11 arulchan +* fix for rdar://5939334 +* +* Revision 1.19 2007/03/14 01:01:12 collin +* *** empty log message *** +* +* Revision 1.18 2007/01/26 23:42:19 ayanowit +* another fix for nuDCL rosetta mode +* +* Revision 1.17 2006/08/16 01:41:41 collin +* *** empty log message *** +* +* Revision 1.16 2006/03/09 22:26:46 niels +* fix 4466075 +* +* Revision 1.15 2006/03/09 22:20:14 niels +* fix 4466075 +* +* Revision 1.14 2006/03/09 21:40:44 niels +* fix 4466075 +* +* Revision 1.13 2006/02/09 00:21:50 niels +* merge chardonnay branch to tot +* +* Revision 1.12.4.1 2005/08/06 01:31:31 collin +* *** empty log message *** +* +* Revision 1.12 2005/02/18 03:19:03 niels +* fix isight +* +* Revision 1.11 2004/04/19 21:51:49 niels +* *** empty log message *** +* +* Revision 1.10 2004/03/25 00:00:23 niels +* fix panic allocating large physical address spaces +* +* Revision 1.9 2003/10/31 02:40:58 niels +* *** empty log message *** +* +* Revision 1.8 2003/08/26 05:11:21 niels +* *** empty log message *** +* +* Revision 1.7 2003/08/25 08:39:15 niels +* *** empty log message *** +* +* Revision 1.6 2003/08/18 23:18:14 niels +* *** empty log message *** +* +* Revision 1.5 2003/08/08 22:30:32 niels +* *** empty log message *** +* +* Revision 1.4 2003/07/30 05:22:14 niels +* *** empty log message *** +* +* Revision 1.3 2003/07/29 22:49:22 niels +* *** empty log message *** +* +* Revision 1.2 2003/07/21 06:52:58 niels +* merge isoch to TOT +* +* Revision 1.1.2.5 2003/07/18 00:17:41 niels +* *** empty log message *** +* +* Revision 1.1.2.4 2003/07/14 22:08:53 niels +* *** empty log message *** +* +* Revision 1.1.2.3 2003/07/11 18:15:33 niels +* *** empty log message *** +* +* Revision 1.1.2.2 2003/07/03 22:10:24 niels +* fix iidc/dv rcv +* +* Revision 1.1.2.1 2003/07/01 20:54:06 niels +* isoch merge +* +*/ + +#import + +#import +#import +#import + +class IODCLProgram ; +class OSIterator ; +class IOFireWireLink ; +class IOMemoryMap ; + +/*! @class IOFWDCL +*/ + +class IOFWDCL : public OSObject +{ + OSDeclareAbstractStructors( IOFWDCL ) ; + + public: + + typedef void (*Callback)( void * refcon ) ; + + enum + { + kDynamic = BIT(1)//kNuDCLDynamic, + ,kUpdateBeforeCallback = BIT(2)//kNuDCLUpdateBeforeCallback + ,kUser = BIT(18) // kNuDCLUser + ,kBigEndianUpdates = BIT(19) // NOTE: Don't change this without making similar change to IOFireWireLib's NuDCL::Export(...)! + } ; + + class InternalData + { + public: + + IOFWDCL * lastBranch ; + } ; + + protected: + + IOFWDCL* fBranch ; + Callback fCallback ; + volatile UInt32 * fTimeStampPtr ; + UInt32 fRangeCount ; + IOVirtualRange * fRanges ; + OSSet* fUpdateList ; + OSIterator * fUpdateIterator ; + volatile UInt32 * fUserStatusPtr ; + void* fRefcon ; + UInt32 fFlags ; + + InternalData * fLoLevel ; + + public: + + // + // IOFWDCL public API: + // + + virtual bool initWithRanges ( + OSSet * updateSet, + unsigned rangesCount = 0, + IOVirtualRange ranges [] = NULL ) ; + + void setBranch( IOFWDCL* branch ) ; + IOFWDCL* getBranch() const ; + void setTimeStampPtr ( UInt32* timeStampPtr ) ; + UInt32* getTimeStampPtr () const ; + void setCallback( Callback callback ) ; + Callback getCallback() const ; + void setStatusPtr( UInt32* statusPtr ) ; + UInt32* getStatusPtr() const ; + void setRefcon( void * refcon ) ; + void * getRefcon() const ; + const OSSet* getUpdateList() const ; + + virtual IOReturn addRange ( IOVirtualRange& range ) ; + virtual IOReturn setRanges ( UInt32 numRanges, IOVirtualRange ranges[] ) ; + virtual UInt32 getRanges( UInt32 maxRanges, IOVirtualRange ranges[] ) const ; + virtual UInt32 countRanges() ; + virtual IOReturn getSpan( IOVirtualRange& result ) const ; + virtual IOByteCount getSize() const ; + IOReturn appendUpdateList( IOFWDCL* updateDCL ) ; + IOReturn setUpdateList( OSSet* updateList ) ; + void emptyUpdateList() ; + void setFlags( UInt32 flags ) ; + UInt32 getFlags() const ; + + + virtual void update() = 0 ; + + // OSObject + + virtual void free () ; + + public: + + // + // internal use only; please don't use... + // + + virtual IOReturn compile( IODCLProgram & , bool & ) = 0 ; + virtual void link () = 0 ; + + OSMetaClassDeclareReservedUnused ( IOFWDCL, 4 ) ; // used to be relink() + + public : + virtual bool interrupt( bool &, IOFWDCL * & ) = 0 ; + virtual void finalize ( IODCLProgram & ) ; + virtual IOReturn importUserDCL ( + UInt8 * data, + IOByteCount & dataSize, + IOMemoryMap * bufferMap, + const OSArray * dcl ) ; + + protected : + + friend class IOFWDCLFriend ; + + public : + + // dump DCL info... + virtual void debug() ; + + public: + + // + // internal use only; please don't use... + // + + virtual bool checkForInterrupt() = 0 ; + + OSMetaClassDeclareReservedUsed ( IOFWDCL, 0 ) ; + OSMetaClassDeclareReservedUnused ( IOFWDCL, 1 ) ; + OSMetaClassDeclareReservedUnused ( IOFWDCL, 2 ) ; + OSMetaClassDeclareReservedUnused ( IOFWDCL, 3 ) ; +// OSMetaClassDeclareReservedUnused ( ***, 4 ) ; // used above + +} ; + +#pragma mark - + +/*! @class IOFWReceiveDCL +*/ + +class IOFWReceiveDCL : public IOFWDCL +{ + OSDeclareAbstractStructors( IOFWReceiveDCL ) + + protected : + + UInt8 fHeaderBytes ; + bool fWait ; + + public: + + // me + virtual bool initWithParams( + OSSet * updateSet, + UInt8 headerBytes, + unsigned rangesCount, + IOVirtualRange ranges [] ) ; + IOReturn setWaitControl( bool wait ) ; + + public : + + // internal use only: + virtual IOReturn importUserDCL ( + UInt8 * data, + IOByteCount & dataSize, + IOMemoryMap * bufferMap, + const OSArray * dcl ) ; + + protected : + + virtual void debug() ; + +} ; + +#pragma mark - + +/*! @class IOFWSendDCL +*/ + +class IOFWSendDCL : public IOFWDCL +{ + OSDeclareAbstractStructors( IOFWSendDCL ) + + protected: + + UInt32 * fUserHeaderPtr ; // pointer to 2 quadlets containing isoch header for this packet + UInt32 * fUserHeaderMaskPtr ; // pointer to 2 quadlets; used to mask header quadlets + IOFWDCL * fSkipBranchDCL ; + Callback fSkipCallback ; + void * fSkipRefcon ; + UInt8 fSync ; + UInt8 fTag ; + + public: + + // OSObject + virtual void free() ; + + // IOFWDCL + virtual IOReturn addRange ( IOVirtualRange& range ) ; + virtual IOReturn setRanges ( UInt32 numRanges, IOVirtualRange ranges[] ) ; + + // me + virtual bool initWithParams( OSSet * updateSet, + unsigned rangesCount = 0, + IOVirtualRange ranges [] = NULL, + UInt8 sync = 0, + UInt8 tag = 0 ) ; + + void setUserHeaderPtr( UInt32* userHeaderPtr, UInt32 * maskPtr ) ; + UInt32 * getUserHeaderPtr() ; + UInt32 * getUserHeaderMask() ; + void setSkipBranch( IOFWDCL * skipBranchDCL ) ; + IOFWDCL * getSkipBranch() const ; + void setSkipCallback( Callback callback ) ; + Callback getSkipCallback() const ; + void setSkipRefcon( void * refcon = 0 ) ; + void * getSkipRefcon() const ; + void setSync( UInt8 sync ) ; + UInt8 getSync() const ; + void setTag( UInt8 tag ) ; + UInt8 getTag() const ; + + public : + + // internal use only: + virtual IOReturn importUserDCL ( + UInt8 * data, + IOByteCount & dataSize, + IOMemoryMap * bufferMap, + const OSArray * dcl ) ; + protected : + + virtual void debug() ; +} ; + +#pragma mark - + +/*! @class IOFWSkipCycleDCL +*/ + +class IOFWSkipCycleDCL : public IOFWDCL +{ + OSDeclareAbstractStructors( IOFWSkipCycleDCL ) + + public: + + virtual bool init() ; + + virtual IOReturn addRange ( IOVirtualRange& range ) ; + virtual IOReturn setRanges ( UInt32 numRanges, IOVirtualRange ranges[] ) ; + virtual IOReturn getSpan( IOVirtualRange& result ) ; + + protected : + + virtual void debug() ; +} ; Index: branches/azimutz/Cleancut/i386/include/IOKit/IODMACommand.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/IODMACommand.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/IODMACommand.h (revision 885) @@ -0,0 +1,557 @@ +/* + * 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 _IODMACOMMAND_H +#define _IODMACOMMAND_H + +#include +#include +class IOMapper; + +/**************************** 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. +

+ 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 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. +

+ 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 and for sample code on manipulating the command's doubly linked list entries. +

+ 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 +{ + OSDeclareDefaultStructors(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 = 0x00000000, + kBypassed = 0x00000001, + kNonCoherent = 0x00000002, + kTypeMask = 0x0000000f, + + kNoCacheStore = 0x00000010, // Memory in descriptor + kOnChip = 0x00000020, // Indicates DMA is on South Bridge + kIterateOnly = 0x00000040 // DMACommand will be used as a cursor only + }; + +/*! @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 kIODMACommandOutputLittle64 + @abstract Output little-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 kIODMACommandOutputBig64 + @abstract Output big-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. + @result Returns a new memory cursor if successfully created and initialized, 0 otherwise. +*/ + static IODMACommand * + withSpecification(SegmentFunction outSegFunc, + UInt8 numAddressBits, + UInt64 maxSegmentSize, + MappingOptions mappingOptions = kMapped, + UInt64 maxTransferSize = 0, + UInt32 alignment = 1, + IOMapper *mapper = 0, + void *refCon = 0); + +/*! @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. + @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 = 0, + void *refCon = 0) __attribute__((always_inline)); + +/*! + @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 memory cursor if successfully created and initialised, 0 otherwise. +*/ + virtual IODMACommand *cloneCommand(void *refCon = 0); + +/*! @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. + @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 = 0, + void *refCon = 0); + +/*! @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 memory descriptor 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 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 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 invalidCache 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(); + +private: + 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(UInt8 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 = 0, + 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); + +private: + OSMetaClassDeclareReservedUsed(IODMACommand, 0); + OSMetaClassDeclareReservedUsed(IODMACommand, 1); + OSMetaClassDeclareReservedUsed(IODMACommand, 2); + OSMetaClassDeclareReservedUnused(IODMACommand, 3); + OSMetaClassDeclareReservedUnused(IODMACommand, 4); + OSMetaClassDeclareReservedUnused(IODMACommand, 5); + OSMetaClassDeclareReservedUnused(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; + +/*! @var fBypassMask + Mask to be ored into the address to bypass the given iommu's mapping. */ + UInt64 fBypassMask; + +/*! @var fMapper + Client defined mapper. */ + IOMapper *fMapper; + +/*! @var fMemory + memory descriptor for current I/O. */ + const 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 */ + MappingOptions 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 = 0; + ret = kIOReturnError; + } + + *newCommand = self; + return ret; +}; +#endif /* !_IODMACOMMAND_H */ + Index: branches/azimutz/Cleancut/i386/include/IOKit/system_management/IOWatchDogTimer.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/system_management/IOWatchDogTimer.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/system_management/IOWatchDogTimer.h (revision 885) @@ -0,0 +1,55 @@ +/* + * Copyright (c) 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 _IOWATCHDOGTIMER_H +#define _IOWATCHDOGTIMER_H + +#include + +class IOWatchDogTimer : public IOService +{ + OSDeclareAbstractStructors(IOWatchDogTimer); + +protected: + IONotifier *notifier; + struct ExpansionData { }; + ExpansionData *reserved; + +public: + virtual bool start(IOService *provider); + virtual void stop(IOService *provider); + virtual IOReturn setProperties(OSObject *properties); + virtual void setWatchDogTimer(UInt32 timeOut) = 0; + + OSMetaClassDeclareReservedUnused(IOWatchDogTimer, 0); + OSMetaClassDeclareReservedUnused(IOWatchDogTimer, 1); + OSMetaClassDeclareReservedUnused(IOWatchDogTimer, 2); + OSMetaClassDeclareReservedUnused(IOWatchDogTimer, 3); +}; + +#endif /* !_IOWATCHDOGTIMER_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/IOTimeStamp.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/IOTimeStamp.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/IOTimeStamp.h (revision 885) @@ -0,0 +1,189 @@ +/* + * 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_IOTIMESTAMP_H +#define IOKIT_IOTIMESTAMP_H + +#include + +static inline void +IOTimeStampStartConstant(unsigned int csc, + uintptr_t a = 0, uintptr_t b = 0, + uintptr_t c = 0, uintptr_t d = 0) +{ + KERNEL_DEBUG_CONSTANT(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) +{ + KERNEL_DEBUG_CONSTANT(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) +{ + KERNEL_DEBUG_CONSTANT(csc | DBG_FUNC_NONE, a, b, c, d, 0); +} + +#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) +{ + KERNEL_DEBUG(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) +{ + KERNEL_DEBUG(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) +{ + KERNEL_DEBUG(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_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)) + +/* 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_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 */ + +/* 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 */ + +#endif /* ! IOKIT_IOTIMESTAMP_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/ppc/IODBDMA.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/ppc/IODBDMA.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/ppc/IODBDMA.h (revision 885) @@ -0,0 +1,367 @@ +/* + * 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) 1997 Apple Computer, Inc. + * + * + * HISTORY + * + * Simon Douglas 10 Nov 97 + * - first checked in, mostly from MacOS DBDMA.i, machdep/ppc/dbdma.h + * but use byte reverse ops. + */ + +#ifndef _IODBDMA_H_ +#define _IODBDMA_H_ + +#include +#include + + +/* DBDMA definitions */ + +struct IODBDMAChannelRegisters { + volatile unsigned long channelControl; + volatile unsigned long channelStatus; + volatile unsigned long commandPtrHi; /* implementation optional*/ + volatile unsigned long commandPtrLo; + volatile unsigned long interruptSelect; /* implementation optional*/ + volatile unsigned long branchSelect; /* implementation optional*/ + volatile unsigned long waitSelect; /* implementation optional*/ + volatile unsigned long transferModes; /* implementation optional*/ + volatile unsigned long data2PtrHi; /* implementation optional*/ + volatile unsigned long data2PtrLo; /* implementation optional*/ + + volatile unsigned long reserved1; + volatile unsigned long addressHi; /* implementation optional*/ + volatile unsigned long reserved2[4]; + volatile unsigned long unimplemented[16]; + +/* This structure must remain fully padded to 256 bytes.*/ + volatile unsigned long undefined[32]; +}; +typedef struct IODBDMAChannelRegisters IODBDMAChannelRegisters; + +/* These constants define the DB-DMA channel control words and status flags.*/ + +enum { + kdbdmaRun = 0x00008000, + kdbdmaPause = 0x00004000, + kdbdmaFlush = 0x00002000, + kdbdmaWake = 0x00001000, + kdbdmaDead = 0x00000800, + kdbdmaActive = 0x00000400, + kdbdmaBt = 0x00000100, + kdbdmaS7 = 0x00000080, + kdbdmaS6 = 0x00000040, + kdbdmaS5 = 0x00000020, + kdbdmaS4 = 0x00000010, + kdbdmaS3 = 0x00000008, + kdbdmaS2 = 0x00000004, + kdbdmaS1 = 0x00000002, + kdbdmaS0 = 0x00000001 +}; + + +#define IOSetDBDMAChannelControlBits(mask) ( ((mask) | (mask) << 16) ) +#define IOClearDBDMAChannelControlBits(mask) ( (mask) << 16) + + +/* This structure defines the DB-DMA channel command descriptor.*/ + +/* + *** WARNING: Endian-ness issues must be considered when performing load/store! *** +*/ + +struct IODBDMADescriptor { + unsigned long operation; /* cmd || key || i || b || w || reqCount*/ + unsigned long address; + volatile unsigned long cmdDep; + volatile unsigned long result; /* xferStatus || resCount*/ +}; +typedef struct IODBDMADescriptor IODBDMADescriptor; + +/* These constants define the DB-DMA channel command operations and modifiers.*/ + + +enum { +/* Command.cmd operations*/ + kdbdmaOutputMore = 0, + kdbdmaOutputLast = 1, + kdbdmaInputMore = 2, + kdbdmaInputLast = 3, + kdbdmaStoreQuad = 4, + kdbdmaLoadQuad = 5, + kdbdmaNop = 6, + kdbdmaStop = 7 +}; + + +enum { +/* Command.key modifiers (choose one for INPUT, OUTPUT, LOAD, and STORE)*/ + kdbdmaKeyStream0 = 0, /* default modifier*/ + kdbdmaKeyStream1 = 1, + kdbdmaKeyStream2 = 2, + kdbdmaKeyStream3 = 3, + kdbdmaKeyRegs = 5, + kdbdmaKeySystem = 6, + kdbdmaKeyDevice = 7, + + kdbdmaIntNever = 0, /* default modifier*/ + kdbdmaIntIfTrue = 1, + kdbdmaIntIfFalse = 2, + kdbdmaIntAlways = 3, + + kdbdmaBranchNever = 0, /* default modifier*/ + kdbdmaBranchIfTrue = 1, + kdbdmaBranchIfFalse = 2, + kdbdmaBranchAlways = 3, + + kdbdmaWaitNever = 0, /* default modifier*/ + kdbdmaWaitIfTrue = 1, + kdbdmaWaitIfFalse = 2, + kdbdmaWaitAlways = 3, + + kdbdmaCommandMask = (long)0xFFFF0000, + kdbdmaReqCountMask = 0x0000FFFF +}; + + +/* These constants define the DB-DMA channel command results.*/ + +enum { + /* result masks*/ + kdbdmaStatusRun = kdbdmaRun << 16, + kdbdmaStatusPause = kdbdmaPause << 16, + kdbdmaStatusFlush = kdbdmaFlush << 16, + kdbdmaStatusWake = kdbdmaWake << 16, + kdbdmaStatusDead = kdbdmaDead << 16, + kdbdmaStatusActive = kdbdmaActive << 16, + kdbdmaStatusBt = kdbdmaBt << 16, + kdbdmaStatusS7 = kdbdmaS7 << 16, + kdbdmaStatusS6 = kdbdmaS6 << 16, + kdbdmaStatusS5 = kdbdmaS5 << 16, + kdbdmaStatusS4 = kdbdmaS4 << 16, + kdbdmaStatusS3 = kdbdmaS3 << 16, + kdbdmaStatusS2 = kdbdmaS2 << 16, + kdbdmaStatusS1 = kdbdmaS1 << 16, + kdbdmaStatusS0 = kdbdmaS0 << 16, + kdbdmaResCountMask = 0x0000FFFF, + kdbdmaXferStatusMask = 0xFFFF0000 +}; + + +/* These macros are are IODBDMAChannelRegisters accessor functions. */ + +#define IOSetDBDMAChannelRegister(registerSetPtr,field,value) \ +OSWriteSwapInt32(registerSetPtr,offsetof(IODBDMAChannelRegisters,field),value) + +#define IOGetDBDMAChannelRegister(registerSetPtr, field) \ +OSReadSwapInt32(registerSetPtr,offsetof(IODBDMAChannelRegisters, field)) + + +/* void IOSetDBDMAChannelControl (IODBDMAChannelRegisters *registerSetPtr, unsigned long ctlValue); */ + +#define IOSetDBDMAChannelControl(registerSetPtr,ctlValue) \ +do { \ + eieio(); \ + IOSetDBDMAChannelRegister(registerSetPtr,channelControl,ctlValue); \ + eieio(); \ +} while(0) + +/* unsigned long IOGetDBDMAChannelStatus (IODBDMAChannelRegisters *registerSetPtr); */ + +#define IOGetDBDMAChannelStatus(registerSetPtr) \ + IOGetDBDMAChannelRegister(registerSetPtr,channelStatus) + +/* unsigned long IOGetDBDMACommandPtr (IODBDMAChannelRegisters *registerSetPtr); */ + +#define IOGetDBDMACommandPtr(registerSetPtr) \ + IOGetDBDMAChannelRegister(registerSetPtr,commandPtrLo) + +/* void IOSetDBDMACommandPtr (IODBDMAChannelRegisters *registerSetPtr, unsigned long cclPtr); */ + +#define IOSetDBDMACommandPtr(registerSetPtr,cclPtr) \ +do { \ + IOSetDBDMAChannelRegister(registerSetPtr,commandPtrHi,0); \ + eieio(); \ + IOSetDBDMAChannelRegister(registerSetPtr,commandPtrLo,cclPtr); \ + eieio(); \ +} while(0) + + +/* unsigned long IOGetDBDMAInterruptSelect (IODBDMAChannelRegisters *registerSetPtr); */ + +#define IOGetDBDMAInterruptSelect(registerSetPtr) \ + IOGetDBDMAChannelRegister(registerSetPtr,interruptSelect) + +/* void IOSetDBDMAInterruptSelect (IODBDMAChannelRegisters *registerSetPtr, unsigned long intSelValue); */ + +#define IOSetDBDMAInterruptSelect(registerSetPtr,intSelValue) \ +do { \ + IOSetDBDMAChannelRegister(registerSetPtr,interruptSelect,intSelValue); \ + eieio(); \ +} while(0) + +/* unsigned long IOGetDBDMABranchSelect (IODBDMAChannelRegisters *registerSetPtr); */ + +#define IOGetDBDMABranchSelect(registerSetPtr) \ + IOGetDBDMAChannelRegister(registerSetPtr,branchSelect) + +/* void IOSetDBDMABranchSelect (IODBDMAChannelRegisters *registerSetPtr, unsigned long braSelValue); */ + +#define IOSetDBDMABranchSelect(registerSetPtr,braSelValue) \ +do { \ + IOSetDBDMAChannelRegister(registerSetPtr,branchSelect,braSelValue); \ + eieio(); \ +} while(0) + +/* unsigned long IOGetDBDMAWaitSelect (IODBDMAChannelRegisters *registerSetPtr); */ + +#define IOGetDBDMAWaitSelect(registerSetPtr) \ + IOGetDBDMAChannelRegister(registerSetPtr,waitSelect) + +/* void IOSetDBDMAWaitSelect (IODBDMAChannelRegisters *registerSetPtr, unsigned long waitSelValue); */ + +#define IOSetDBDMAWaitSelect(registerSetPtr,waitSelValue) \ +do { \ + IOSetDBDMAChannelRegister(registerSetPtr,waitSelect,waitSelValue); \ + eieio(); \ +} while(0) + + +/* These macros are IODBDMADescriptor accessor functions. */ + +#define IOSetDBDMADescriptor(descPtr,field,value) \ +OSWriteSwapInt32( descPtr, offsetof( IODBDMADescriptor, field), value) + +#define IOGetDBDMADescriptor(descPtr,field) \ +OSReadSwapInt32( descPtr, offsetof( IODBDMADescriptor, field)) + +#define IOMakeDBDMAOperation(cmd,key,interrupt,branch,wait,count) \ + ( ((cmd) << 28) | ((key) << 24) | ((interrupt) << 20) \ + | ((branch) << 18) | ( (wait) << 16) | (count) ) + +/* void IOMakeDBDMADescriptor (IODBDMADescriptor *descPtr, + unsigned long cmd, + unsigned long key, + unsigned long interrupt, + unsigned long branch, + unsigned long wait, + unsigned long count, + unsigned long addr); */ + +#define IOMakeDBDMADescriptor(descPtr,cmd,key,interrupt,branch,wait,count,addr)\ +do { \ + IOSetDBDMADescriptor(descPtr, address, addr); \ + IOSetDBDMADescriptor(descPtr, cmdDep, 0); \ + IOSetDBDMADescriptor(descPtr, result, 0); \ + eieio(); \ + IOSetDBDMADescriptor(descPtr, operation, \ + IOMakeDBDMAOperation(cmd,key,interrupt,branch,wait,count)); \ + eieio(); \ +} while(0) + +/* void IOMakeDBDMADescriptorDep (IODBDMADescriptor *descPtr, + unsigned long cmd, + unsigned long key, + unsigned long interrupt, + unsigned long branch, + unsigned long wait, + unsigned long count, + unsigned long addr, + unsigned long dep); */ + +#define IOMakeDBDMADescriptorDep(descPtr,cmd,key,interrupt,branch,wait,count,addr,dep) \ +do { \ + IOSetDBDMADescriptor(descPtr, address, addr); \ + IOSetDBDMADescriptor(descPtr, cmdDep, dep); \ + IOSetDBDMADescriptor(descPtr, result, 0); \ + eieio(); \ + IOSetDBDMADescriptor(descPtr, operation, \ + IOMakeDBDMAOperation(cmd, key, interrupt, branch, wait, count)); \ + eieio(); \ +} while(0) + +/* Field accessors - NOTE: unsynchronized */ + +/* unsigned long IOGetDBDMAOperation (IODBDMADescriptor *descPtr) */ + +#define IOGetCCOperation(descPtr) \ + IOGetDBDMADescriptor(descPtr,operation) + +/* void IOSetCCOperation (IODBDMADescriptor *descPtr, unsigned long operationValue) */ + +#define IOSetCCOperation(descPtr,operationValue) \ + IOSetDBDMADescriptor(descPtr,operation,operationValue) + +/* unsigned long IOGetCCAddress (IODBDMADescriptor *descPtr) */ + +#define IOGetCCAddress(descPtr) \ + IOGetDBDMADescriptor(descPtr,address) + +/* void IOSetCCAddress (IODBDMADescriptor *descPtr, unsigned long addressValue) */ + +#define IOSetCCAddress(descPtr,addressValue) \ + IOSetDBDMADescriptor(descPtr,address, addressValue) + +/* unsigned long IOGetCCCmdDep (IODBDMADescriptor *descPtr) */ + +#define IOGetCCCmdDep(descPtr) \ + IOGetDBDMADescriptor(descPtr,cmdDep) + +/* void IOSetCCCmdDep (IODBDMADescriptor *descPtr, unsigned long cmdDepValue) */ + +#define IOSetCCCmdDep(descPtr,cmdDepValue) \ + IOSetDBDMADescriptor(descPtr,cmdDep,cmdDepValue) + +/* unsigned long IOGetCCResult (IODBDMADescriptor *descPtr) */ + +#define IOGetCCResult(descPtr) \ + IOGetDBDMADescriptor(descPtr,result) + +/* void IOSetCCResult (IODBDMADescriptor *descPtr, unsigned long resultValue) */ + +#define IOSetCCResult(descPtr,resultValue) \ + IOSetDBDMADescriptor(descPtr,result,resultValue) + + +/* DBDMA routines */ + +extern void IODBDMAStart( volatile IODBDMAChannelRegisters *registerSetPtr, volatile IODBDMADescriptor *physicalDescPtr); +extern void IODBDMAStop( volatile IODBDMAChannelRegisters *registerSetPtr); +extern void IODBDMAFlush( volatile IODBDMAChannelRegisters *registerSetPtr); +extern void IODBDMAReset( volatile IODBDMAChannelRegisters *registerSetPtr); +extern void IODBDMAContinue( volatile IODBDMAChannelRegisters *registerSetPtr); +extern void IODBDMAPause( volatile IODBDMAChannelRegisters *registerSetPtr); + +extern IOReturn IOAllocatePhysicallyContiguousMemory( unsigned int size, unsigned int options, + IOVirtualAddress * logical, IOPhysicalAddress * physical ); +extern IOReturn IOFreePhysicallyContiguousMemory( IOVirtualAddress * logical, unsigned int size); + +#endif /* !defined(_IODBDMA_H_) */ Index: branches/azimutz/Cleancut/i386/include/IOKit/IODataQueueShared.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/IODataQueueShared.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/IODataQueueShared.h (revision 885) @@ -0,0 +1,92 @@ +/* + * 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 +#include +#include + +/*! + * @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 port The notification 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 */ + Index: branches/azimutz/Cleancut/i386/include/IOKit/platform/AppleMacIO.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/platform/AppleMacIO.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/platform/AppleMacIO.h (revision 885) @@ -0,0 +1,79 @@ +/* + * 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_APPLEMACIO_H +#define _IOKIT_APPLEMACIO_H + +#include + +#include + +class AppleMacIO : public IOService +{ + OSDeclareAbstractStructors(AppleMacIO); + + IOService * fNub; + IOMemoryMap * fMemory; + + struct ExpansionData { }; + ExpansionData *fReserved; + +protected: + virtual bool selfTest( void ); + +public: + virtual bool start( IOService * provider ); + + virtual IOService * createNub( IORegistryEntry * from ); + + virtual void processNub( IOService * nub ); + + virtual void publishBelow( IORegistryEntry * root ); + + virtual const char * deleteList( void ); + virtual const char * excludeList( void ); + + virtual bool compareNubName( const IOService * nub, OSString * name, + OSString ** matched = 0 ) const; + + virtual IOReturn getNubResources( IOService * nub ); + + OSMetaClassDeclareReservedUnused(AppleMacIO, 0); + OSMetaClassDeclareReservedUnused(AppleMacIO, 1); + OSMetaClassDeclareReservedUnused(AppleMacIO, 2); + OSMetaClassDeclareReservedUnused(AppleMacIO, 3); +}; + +#endif /* ! _IOKIT_APPLEMACIO_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/platform/AppleMacIODevice.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/platform/AppleMacIODevice.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/platform/AppleMacIODevice.h (revision 885) @@ -0,0 +1,60 @@ +/* + * 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 _IOKIT_APPLEMACIODEVICE_H +#define _IOKIT_APPLEMACIODEVICE_H + +#include + +class AppleMacIODevice : public IOService +{ + OSDeclareDefaultStructors(AppleMacIODevice); + +private: + struct ExpansionData { }; + ExpansionData *reserved; + +public: + virtual bool compareName( OSString * name, OSString ** matched = 0 ) const; + virtual IOService *matchLocation(IOService *client); + virtual IOReturn getResources( void ); + + OSMetaClassDeclareReservedUnused(AppleMacIODevice, 0); + OSMetaClassDeclareReservedUnused(AppleMacIODevice, 1); + OSMetaClassDeclareReservedUnused(AppleMacIODevice, 2); + OSMetaClassDeclareReservedUnused(AppleMacIODevice, 3); +}; + +#endif /* ! _IOKIT_APPLEMACIODEVICE_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/platform/ApplePlatformExpert.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/platform/ApplePlatformExpert.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/platform/ApplePlatformExpert.h (revision 885) @@ -0,0 +1,91 @@ +/* + * 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-2000 Apple Computer, Inc. All rights reserved. + * + * HISTORY + * + */ + + +#ifndef _IOKIT_APPLEPLATFORM_H +#define _IOKIT_APPLEPLATFORM_H + +#include + +enum { + kBootROMTypeOldWorld = 0, + kBootROMTypeNewWorld +}; + +enum { + kChipSetTypePowerSurge = 0, + kChipSetTypePowerStar, + kChipSetTypeGossamer, + kChipSetTypePowerExpress, + kChipSetTypeCore99, + kChipSetTypeCore2001 +}; + +enum { + kMachineTypeUnknown = 0 +}; + +extern const OSSymbol *gGetDefaultBusSpeedsKey; + +class ApplePlatformExpert : public IODTPlatformExpert +{ + OSDeclareAbstractStructors(ApplePlatformExpert); + +private: + SInt32 _timeToGMT; + + struct ExpansionData { }; + ExpansionData *reserved; + +public: + virtual bool start( IOService * provider ); + virtual bool configure( IOService * provider ); + virtual const char * deleteList( void ); + virtual const char * excludeList( void ); + + virtual void registerNVRAMController( IONVRAMController * nvram ); + + virtual long getGMTTimeOfDay(void); + virtual void setGMTTimeOfDay(long secs); + + virtual bool getMachineName(char *name, int maxLength); + + OSMetaClassDeclareReservedUnused(ApplePlatformExpert, 0); + OSMetaClassDeclareReservedUnused(ApplePlatformExpert, 1); + OSMetaClassDeclareReservedUnused(ApplePlatformExpert, 2); + OSMetaClassDeclareReservedUnused(ApplePlatformExpert, 3); +}; + + +#endif /* ! _IOKIT_APPLEPLATFORM_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/platform/AppleNMI.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/platform/AppleNMI.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/platform/AppleNMI.h (revision 885) @@ -0,0 +1,76 @@ +/* + * 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-9 Apple Computer, Inc. All rights reserved. + * + * DRI: Josh de Cesare + * + */ + +#ifndef _IOKIT_APPLENMI_H +#define _IOKIT_APPLENMI_H + +#include +#include + +// NMI Interrupt Constants +enum +{ + kExtInt9_NMIIntSource = 0x800506E0, + kNMIIntLevelMask = 0x00004000, + kNMIIntMask = 0x00000080 +}; + + +class AppleNMI : public IOService +{ + OSDeclareDefaultStructors(AppleNMI); + +private: + bool enable_debugger; + bool mask_NMI; + + struct ExpansionData { }; + ExpansionData * reserved; // Reserved for future use + +public: + IOService *rootDomain; + virtual bool start(IOService *provider); + virtual IOReturn initNMI(IOInterruptController *parentController, OSData *parentSource); + virtual IOReturn handleInterrupt(void *refCon, IOService *nub, int source); + + // Power handling methods: + virtual IOReturn powerStateWillChangeTo(IOPMPowerFlags, unsigned long, IOService*); + + OSMetaClassDeclareReservedUnused(AppleNMI, 0); + OSMetaClassDeclareReservedUnused(AppleNMI, 1); + OSMetaClassDeclareReservedUnused(AppleNMI, 2); + OSMetaClassDeclareReservedUnused(AppleNMI, 3); +}; + +#endif /* ! _IOKIT_APPLENMI_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/IOMemoryCursor.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/IOMemoryCursor.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/IOMemoryCursor.h (revision 885) @@ -0,0 +1,462 @@ +/* + * 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 _IOMEMORYCURSOR_H +#define _IOMEMORYCURSOR_H + +#include +#include + +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. +

+ 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. +

+Below is the simplest example of a SegmentFunction:
+void IONaturalMemoryCursor::outputSegment(PhysicalSegment segment,
+ void * outSegments,
+ UInt32 outSegmentIndex)
+{
+ ((PhysicalSegment *) outSegments)[outSegmentIndex] = segment;
+} + +*/ +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 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 = 0); +}; + +/************************ 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 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 = 0) + { + 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 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 = 0) + { + 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 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 = 0) + { + return genPhysicalSegments(descriptor, fromPosition, segments, + maxSegments, inMaxTransferSize, transferSize); + } +}; + +/************************* class IODBDMAMemoryCursor *************************/ + +#if defined(__ppc__) + +struct IODBDMADescriptor; + +/*! + @class IODBDMAMemoryCursor + @abstract An IOMemoryCursor subclass that outputs a vector of DBDMA descriptors where the address and length are filled in. + @discussion The IODBDMAMemoryCursor would be used when the DBDMA hardware is available for the device for that will use an instance of this cursor. +*/ +class IODBDMAMemoryCursor : public IOMemoryCursor +{ + OSDeclareDefaultStructors(IODBDMAMemoryCursor) + +public: +/*! @function outputSegment + @abstract Outpust the given segment into the output segments array in address and length fields of an DBDMA descriptor. + @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 dbdmaOutputSegment + @discussion Backward compatibility define for the old global function definition. See IODBDMAMemoryCursor::outputSegment. */ +#define dbdmaOutputSegment IODBDMAMemoryCursor::outputSegment + +/*! @function withSpecification + @abstract Creates and initializes an IODBDMAMemoryCursor in one operation. + @discussion Factory function to create and initialize an IODBDMAMemoryCursor in one operation. See also IODBDMAMemoryCursor::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 IODBDMAMemoryCursor * + withSpecification(IOPhysicalLength maxSegmentSize, + IOPhysicalLength maxTransferSize, + IOPhysicalLength alignment = 1); + +/*! @function initWithSpecification + @abstract Primary initializer for the IODBDMAMemoryCursor 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 DBDMA physical scatter/gather list given a memory descriptor. + @discussion Generates a list of DBDMA descriptors where the address and length fields are filled in appropriately. But the client is expected to fill in the rest of the DBDMA descriptor as is appropriate for their particular hardware. 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 DBDMA descriptors for the output physical scatter/gather list. Be warned no room is left for a preamble in the output array. 'segments' should point to the first memory description slot in a DBDMA command. + @param maxSegments Maximum number of segments that can be written to the DBDMA descriptor table. + @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, + IODBDMADescriptor * segments, + UInt32 maxSegments, + UInt32 inMaxTransferSize = 0, + IOByteCount * transferSize = 0) + { + return genPhysicalSegments(descriptor, fromPosition, segments, + maxSegments, inMaxTransferSize, transferSize); + } +}; + +#endif /* defined(__ppc__) */ + +#endif /* !_IOMEMORYCURSOR_H */ + Index: branches/azimutz/Cleancut/i386/include/IOKit/IOCommandPool.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/IOCommandPool.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/IOCommandPool.h (revision 885) @@ -0,0 +1,230 @@ +/* + * Copyright (c) 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) 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 +#include +#include +#include +#include +#include + +/*! + * @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 */ + 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); + + +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 inWorkLoop + * 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 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 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 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 commmand + * The command to place in the pool. + */ + + virtual void returnCommand(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 vCommand + * A pointer to a pointer to an IOCommand object where the returned + * command will be stored. + * @param vBlock + * 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(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 vCommand + * 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_ */ Index: branches/azimutz/Cleancut/i386/include/IOKit/rtc/IORTCController.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/rtc/IORTCController.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/rtc/IORTCController.h (revision 885) @@ -0,0 +1,46 @@ +/* + * 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@ + */ +/* + * 24 Nov 1998 suurballe Created. + */ + +#include + +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; +}; + Index: branches/azimutz/Cleancut/i386/include/IOKit/IOLocks.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/IOLocks.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/IOLocks.h (revision 885) @@ -0,0 +1,409 @@ +/* + * Copyright (c) 1998-2009 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 + +#include + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/*! @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. Any blocked waiters will not be woken. + @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 +#if defined(__i386__) +void IOLockUnlock( IOLock * lock) __DARWIN10_ALIAS(IOLockUnlock); +#else /* !__i386__ */ +void IOLockUnlock( IOLock * lock); +#endif /* __i386__ */ +#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. + @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); + +int IOLockSleepDeadline( IOLock * lock, void *event, + AbsoluteTime deadline, UInt32 interType); + +void IOLockWakeup(IOLock * lock, void *event, bool oneThread); + +#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. Any blocked waiters will not be woken. + @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. Any blocked waiters will not be woken. + @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 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 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 an embedded spin lock, to the unlocked state. + @param lock Pointer to the lock. */ + +void IOSimpleLockInit( 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 */ + Index: branches/azimutz/Cleancut/i386/include/IOKit/network/IOEthernetController.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/network/IOEthernetController.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/network/IOEthernetController.h (revision 885) @@ -0,0 +1,502 @@ +/* + * 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 + +/*! @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 WakeOnLANFilters. + @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 +}; + +/* + * Kernel + */ +#if defined(KERNEL) && defined(__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; + +/*! @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 IOEthernetController : public IONetworkController +{ + OSDeclareAbstractStructors( IOEthernetController ) + +protected: + struct ExpansionData { }; + /*! @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); + +/*! @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; + +/*! @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); + +/*! @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); + +/*! @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); + +/*! @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); + +/*! @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; + +/*! @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; + +/*! @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(); + +/*! @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(); + +/*! @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(); + + /*! @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 packet 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. */ + + OSMetaClassDeclareReservedUsed( IOEthernetController, 0); + virtual bool getVlanTagDemand(mbuf_t m, UInt32 *vlanTag); + + /*! @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 packet 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. */ + + OSMetaClassDeclareReservedUsed( IOEthernetController, 1); + virtual void setVlanTag(mbuf_t m, UInt32 vlanTag); + + // Virtual function padding + OSMetaClassDeclareReservedUnused( IOEthernetController, 2); + OSMetaClassDeclareReservedUnused( IOEthernetController, 3); + OSMetaClassDeclareReservedUnused( IOEthernetController, 4); + OSMetaClassDeclareReservedUnused( IOEthernetController, 5); + OSMetaClassDeclareReservedUnused( IOEthernetController, 6); + OSMetaClassDeclareReservedUnused( IOEthernetController, 7); + OSMetaClassDeclareReservedUnused( IOEthernetController, 8); + OSMetaClassDeclareReservedUnused( IOEthernetController, 9); + 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 /* defined(KERNEL) && defined(__cplusplus) */ + +#endif /* !_IOETHERNETCONTROLLER_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/network/IONetworkData.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/network/IONetworkData.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/network/IONetworkData.h (revision 885) @@ -0,0 +1,477 @@ +/* + * 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. + @constant kIONetworkDataAccessTypeReset Reset access. + @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 +#include + +/*! @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 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(); + +/*! @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; + + // Virtual function padding + OSMetaClassDeclareReservedUnused( IONetworkData, 0); + OSMetaClassDeclareReservedUnused( IONetworkData, 1); + OSMetaClassDeclareReservedUnused( IONetworkData, 2); + OSMetaClassDeclareReservedUnused( IONetworkData, 3); +}; + +#endif /* KERNEL */ + +#endif /* !_IONETWORKDATA_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/network/IOKernelDebugger.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/network/IOKernelDebugger.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/network/IOKernelDebugger.h (revision 885) @@ -0,0 +1,324 @@ +/* + * 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 + +/*! @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 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 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; + }; + + /*! @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 free + @abstract Frees the IOKernelDebugger instance. */ + + virtual void free(); + +/*! @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 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 + registered if the argument is zero. +*/ + + static void registerHandler( IOService * target, + IODebuggerTxHandler txHandler = 0, + IODebuggerRxHandler rxHandler = 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 ); + +/*! @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 ); + +/*! @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 ); + +/*! @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 ); + +/*! @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; + + static bool interfacePublished( void *target, void *param, IOService *service ); + +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. + @result Returns true if the instance initialized successfully, false otherwise. +*/ + + virtual bool init( IOService * target, + IODebuggerTxHandler txHandler, + IODebuggerRxHandler rxHandler ); + +/*! @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. + @result Returns an IOKernelDebugger instance on success, 0 otherwise. +*/ + + static IOKernelDebugger * debugger( IOService * target, + IODebuggerTxHandler txHandler, + IODebuggerRxHandler rxHandler ); + + /* + * Entry point for generic messages delivered from the provider. + */ + + virtual IOReturn message( UInt32 type, IOService * provider, void * arg ); + +/*! @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 */ Index: branches/azimutz/Cleancut/i386/include/IOKit/network/IOOutputQueue.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/network/IOOutputQueue.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/network/IOOutputQueue.h (revision 885) @@ -0,0 +1,270 @@ +/* + * 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 + +// Forward declarations. +// +struct mbuf; +class IONetworkData; + +// FIXME - We do not want the enqueue/dequeue macros defined in queue.h. +// +#undef enqueue(queue,elt) +#undef dequeue(queue) + +// 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 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(); + +/*! @function free + @abstract Frees the IOOutputQueue object. + @discussion Release allocated resources, then call super::free(). +*/ + + virtual void free(); + +/*! @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); + +/*! @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; + + // Virtual function padding + OSMetaClassDeclareReservedUnused( IOOutputQueue, 0); + 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 */ Index: branches/azimutz/Cleancut/i386/include/IOKit/network/IOBasicOutputQueue.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/network/IOBasicOutputQueue.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/network/IOBasicOutputQueue.h (revision 885) @@ -0,0 +1,319 @@ +/* + * 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 +#include +#include // FIXME - remove + +struct IOMbufQueue; + +/*! @class IOBasicOutputQueue + @abstract A concrete implementation of an IOOutputQueue. + @discussion This object uses a spinlock 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 IOBasicOutputQueue : public IOOutputQueue +{ + OSDeclareDefaultStructors( IOBasicOutputQueue ) + +private: + static IOReturn dispatchNetworkDataNotification(void * target, + void * param, + IONetworkData * data, + UInt32 type); + + void dequeue(); + +protected: + OSObject * _target; + IOOutputAction _action; + IOOutputQueueStats * _stats; + IONetworkData * _statsData; + IOSimpleLock * _spinlock; + IOMbufQueue * _inQueue; + IOMbufQueue * _queues[2]; + 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); + +/*! @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(); + +/*! @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); + +/*! @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 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 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); + +/*! @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(); + +/*! @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(); + +/*! @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); + +/*! @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(); + +/*! @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); + +/*! @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; + +/*! @function getSize + @abstract Gets the number of packets currently held in the queue. + @result Returns the size of the queue. +*/ + + virtual UInt32 getSize() const; + +/*! @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; +}; + +#endif /* !_IOBASICOUTPUTQUEUE_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/network/IONetworkStats.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/network/IONetworkStats.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/network/IONetworkStats.h (revision 885) @@ -0,0 +1,87 @@ +/* + * 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 + +/*! @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 */ Index: branches/azimutz/Cleancut/i386/include/IOKit/network/IOGatedOutputQueue.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/network/IOGatedOutputQueue.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/network/IOGatedOutputQueue.h (revision 885) @@ -0,0 +1,140 @@ +/* + * 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 +#include +#include +#include + +/*! @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 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); + +/*! @function free + @abstract Frees the IOGatedOutputQueue object. + @discussion Release allocated resources, then call super::free(). */ + + virtual void free(); + +/*! @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); + +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); + +/*! @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 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); +}; + +#endif /* !_IOGATEDOUTPUTQUEUE_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/network/IONetworkInterface.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/network/IONetworkInterface.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/network/IONetworkInterface.h (revision 885) @@ -0,0 +1,1104 @@ +/* + * 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 extra flags. The extra flag 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" + +/*! @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 +}; + +/* + * Kernel + */ +#if defined(KERNEL) && defined(__cplusplus) + +#include +#include +#include +#include +#include + +class IONetworkController; +class IONetworkStack; +class IOCommandGate; + +/*! @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 m 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 +}; + +/*! @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 IONetworkInterface : public IOService +{ + OSDeclareAbstractStructors( IONetworkInterface ) + + friend class IONetworkStack; + +private: + IONetworkController * _controller; + ifnet_t _backingIfnet; + IORecursiveLock * _ifLock; + OSSet * _clientSet; + OSNumber * _stateBits; + bpf_packet_func _inputFilterFunc; + bpf_packet_func _outputFilterFunc; + OSObject * _outTarget; + IOOutputAction _outAction; + UInt32 _clientVar[4]; + OSDictionary * _dataDict; + mbuf_t _inputQHead; + mbuf_t _inputQTail; + UInt32 _inputQCount; + + struct ExpansionData { + int unit; + int type; + int mtu; + int flags; + int eflags; + int addrlen; + int hdrlen; + IONetworkStats driverStats; + IONetworkStats lastDriverStats; + struct ifnet_stat_increment_param inputDeltas; + IOLock *detachLock; + char *remote_NMI_pattern; + unsigned int remote_NMI_len; + }; + + ExpansionData * _reserved; + + void _syncFromBackingIfnet() const; + void _syncToBackingIfnet(); + + bool _syncNetworkDataDict(); + bool _setInterfaceProperty(UInt32 value, + UInt32 mask, + UInt32 bytes, + void * addr, + char * name); + + SInt32 syncSIOCSIFMEDIA(IONetworkController * ctlr, struct ifreq * ifr); + SInt32 syncSIOCGIFMEDIA(IONetworkController * ctlr, struct ifreq * ifr, unsigned long cmd); + SInt32 syncSIOCSIFMTU(IONetworkController * ctlr, struct ifreq * ifr); + + static int performGatedCommand(void *, void *, void *, void *, void *); + static errno_t ioctl_shim(ifnet_t ifp, unsigned long cmd, void * data); + static errno_t set_bpf_tap_shim(ifnet_t ifn, bpf_tap_mode mode, bpf_packet_func func); + static int output_shim(ifnet_t ifp, mbuf_t); + void DLIL_INPUT(mbuf_t m_head); + static void detach_shim(ifnet_t ifp); + static void powerChangeHandler(void *, void *, void *); + +public: + +/*! @function isPrimaryInterface + @abstract Queries whether the interface object provided represents + the "primary" network interface for the system. + @result Returns true if the interface provided is the primary inteface, + false otherwise. +*/ + + virtual bool isPrimaryInterface() const; + +/*! @function init + @abstract Initializes an IONetworkInterface object. + @discussion Initializes instance variables, and allocates resources. + @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 ); + +/*! @function isRegistered + @abstract Returns true if the interface has been registered with + the data link layer. + @discussion Once registered, the interface will be assigned a + BSD name (such as en0), and a kIOBSDNameKey property is added to the + property table containing this name. Calling this method performs + the same function as checking for the kIONetworkInterfaceRegisteredState + bit in the value returned by getInterfaceState(). + @result Returns true if interface is registered. Returns false if the data link layer + has no references to this network interface, which implies that either the + interface has yet to attach to the data link layer, or the interface has + been detached. +*/ + + virtual bool isRegistered() const; + +/*! @function getInterfaceState + @abstract Reports the current state of the interface object by returning + the interface state flags. + @result Returns the interface state flags. +*/ + + virtual UInt32 getInterfaceState() const; + +/*! @function matchPropertyTable + @abstract Overrides the implementation in IOService to + implement family-specific matching. + @discussion When the gIOLocationMatchKey property is present in the + dictionary provided, then fail the match unless the kIOBSDNameKey property + is found. This is to prevent a premature match when hunting for a root + device for BSD. The presence of the kIOBSDNameKey property indicates that + the interface has registered with BSD, and is a valid candidate for + matching against the gIOLocationMatchKey property. If the + gIOLocationMatchKey property is absent, then this method will always + return true. + @param table The dictionary of properties to match against. + @param score Pointer to the current driver's probe score, not used. + @result Returns true for a positive match, false otherwise. +*/ + + virtual bool matchPropertyTable( OSDictionary * table, + SInt32 * score ); + +/*! @function getController + @abstract Returns the provider, an IONetworkController object, that + is servicing this interface object. + @discussion This is the same controller object that was supplied as + an argument to the init() method. + @result Returns the IONetworkController object that is providing service to + this interface object. +*/ + + virtual IONetworkController * getController() const; + +/*! @function inputPacket + @abstract Submits a single packet received from the network to the data link layer. + @discussion This method is called by the network controller to submit a single packet + received from the network to the data link layer. The packet received by this method may be added to an input + queue on the interface object, which the controller can use to postpone + the packet handoff to the upper layers, until all received packets have + been transferred to the input queue. A subsequent call to flushInputQueue(), + will transfer the entire contents of the queue to the data link layer, + by making a single call to dlil_input(). Other methods that can be used + to manage the input queue are flushInputQueue() and clearInputQueue(). + This input queue is not protected by a lock. Access to the queue by the + controller must be serialized, otherwise its use must be avoided. + @param m 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 Options defined by inputPacket() that the caller + can use to specify this method call. + @param param A parameter provided by the caller. Not used by + IONetworkInterface. + @result Returns the number of packets that were submitted to the data link layer, + or 0 if the packet was queued. +*/ + + virtual UInt32 inputPacket(mbuf_t, + UInt32 length = 0, + IOOptionBits options = 0, + void * param = 0); + +/*! @enum InputOptionQueuePacket + @discussion The option bits that can be specified + in the options argument when calling inputPacket(). + @constant kInputOptionQueuePacket Keep the packet provided in the + input packet queue. No packets are sent to the data link layers, + and the caller's thread will not venture outside the interface + object. Calls to inputPacket() must be serialized. +*/ + + enum { + kInputOptionQueuePacket = 0x1 + }; + +/*! @function flushInputQueue + @abstract Sends all packets held in the input queue to the data + link layer. + @discussion Remove all packets from the input queue and + send them to the data link layer by calling dlil_input(). This + method should be used in connection with the inputPacket() method, + to flush the input queue after inputPacket() was used to queue up + some number of received packets. See inputPacket() and clearInputQueue(). + @result Returns the number of packets that were submitted to the data link layer. + May be zero if the queue was empty. +*/ + + virtual UInt32 flushInputQueue(); + +/*! @function clearInputQueue + @abstract Removes and 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. Also see flushInputQueue(). + @result Returns the number of packets freed. +*/ + + virtual UInt32 clearInputQueue(); + +/*! @function inputEvent + @abstract Sends an event to the data link layer. + @discussion This method can be used by the network controller to + send an event to the data link layer. + @param type A constant describing the event type. + @param data 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 was unsuccesful. +*/ + + virtual bool inputEvent(UInt32 type, void * data); + +/*! @function registerOutputHandler + @abstract Registers a target/action to handle output packets. + @discussion The interface object will forward all output packets, + received from the data link layer, to the output handler registered + through this method. The default target and action are set by the init() + method to the controller, and the handler returned by the controller's + getOutputHandler() method. Once the interface becomes registered with + the data link layer, this method will return false and will reject any + further changes. + @param target Target object that implements the output handler. + @param action The function that will process 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 a string containing the prefix to use when + creating a BSD name for this interface. + @discussion The BSD name for each interface object is generated by + concatenating a string returned by this method, with an unique + unit number assigned by IONetworkStack. + A concrete subclass of IONetworkInterface must implement this method + and enforce a consistent name for all of 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 value in the if_type field in the ifnet structure. + @result Returns a constant defined in bsd/net/if_types.h header file + that describes the interface type. +*/ + + virtual UInt8 getInterfaceType() const; + +/*! @function getMaxTransferUnit + @abstract Gets the maximum transfer unit for this interface. + @discussion This method returns the value in the if_mtu field in the ifnet structure. + @result Returns the interface MTU size in bytes. +*/ + + virtual UInt32 getMaxTransferUnit() const; + +/*! @function getFlags + @abstract Gets the value of the interface flags. + @discussion This method returns the value in the if_flags field in the ifnet structure. + @result Returns the value of the interface flags. +*/ + + virtual UInt16 getFlags() const; + +/*! @function getExtraFlags + @abstract Gets the value of the interface extra flags. + @discussion This method returns the value in the if_eflags field in the ifnet structure. + @result Returns the value of the interface extra flags. +*/ + + virtual UInt32 getExtraFlags() const; + +/*! @function getMediaAddressLength + @abstract Gets the size of the media (MAC-layer) address. + @discussion This method returns the value in the if_addrlen field in the ifnet structure. + @result Returns the size of the media address in bytes. +*/ + + virtual UInt8 getMediaAddressLength() const; + +/*! @function getMediaHeaderLength + @abstract Gets the size of the media header. + @discussion This method returns the value in the if_hdrlen field in the ifnet structure. + @result Returns the size of the media header in bytes. +*/ + + virtual UInt8 getMediaHeaderLength() const; + +/*! @function getUnitNumber + @abstract Gets the unit number assigned to this interface object. + @discussion This method returns the value in the if_unit field in the ifnet structure. + @result Returns the assigned interface unit number. +*/ + + virtual UInt16 getUnitNumber() const; + +/*! @function addNetworkData + @abstract Adds an IONetworkData object to a dictionary managed by + the interface. + @param aData An IONetworkData object to be added to a dictionary + managed by the interface. This object is retained by the dictionary. + @result Returns true if the operation was successful, false otherwise. +*/ + + virtual bool addNetworkData(IONetworkData * aData); + +/*! @function removeNetworkData + @abstract Removes an entry from the IONetworkData dictionary + managed by the interface. + @discussion This method removes an entry from the IONetworkData dictionary + managed by the interface. The removed object is released. + @param aKey A unique OSSymbol identifying the IONetworkData object + to be removed from the dictionary. + @result Returns true if the operation was successful, false otherwise. +*/ + + virtual bool removeNetworkData(const OSSymbol * aKey); + +/*! @function removeNetworkData + @abstract Removes an entry from the IONetworkData dictionary + managed by the interface. + @discussion This method removes an entry from the IONetworkData dictionary + managed by the interface. The removed object is released. + @param aKey A unique string identifying the IONetworkData object + to be removed from the dictionary. + @result Returns true if the operation was successful, false otherwise. +*/ + + virtual bool removeNetworkData(const char * aKey); + +/*! @function getNetworkData + @abstract Gets an IONetworkData object from the interface that is + associated with the given key. + @param aKey The unique string identifying the IONetworkData object to be + returned to caller. + @result Returns a reference to the matching IONetworkData object, + or 0 if no match was found. +*/ + + virtual IONetworkData * getNetworkData(const char * aKey) const; + +/*! @function getNetworkData + @abstract Gets an IONetworkData object from the interface that is + associated with the given key. + @param aKey The unique OSSymbol identifying the IONetworkData object to be + returned to caller. + @result Returns a reference to the matching IONetworkData object, + or 0 if no match was found. +*/ + + virtual IONetworkData * getNetworkData(const OSSymbol * aKey) const; + +/*! @function setProperties + @abstract Handles a request to set network interface properties from + kernel or non-kernel clients. + @discussion For non-kernel clients, the preferred + access mechanism is through a user client connection. + @param properties An OSDictionary containing a collection of + properties. + @result Returns kIOReturnUnsupported if the interface did not + recognize any of the properties provided. Otherwise, the return + code will be kIOReturnSuccess to indicate no errors, or an + IOReturn error code to indicate that an error occurred while + handling one of the properties. +*/ + + virtual IOReturn setProperties( OSObject * properties ); + + // FIXME - Compatibility methods (to be removed) + IONetworkData * getParameter(const char * aKey) const; + bool setExtendedFlags(UInt32 flags, UInt32 clear = 0); + + virtual IOReturn message( UInt32 type, IOService * provider, void * argument ); + +/*! @function debuggerRegistered + @abstract Tells the IONetworkInterface that this interface will be used + by the debugger. +*/ + void debuggerRegistered(void); + +protected: + +/*! @function setInterfaceType + @abstract Sest the interface type. + @discussion Both the if_type field in the ifnet structure, and the + kIOInterfaceType property are updated with the value provided. + @param type A constant defined in bsd/net/if_types.h header file + that describes the interface type. + @result Returns true if the update was successful, false otherwise. +*/ + + virtual bool setInterfaceType(UInt8 type); + +/*! @function setMaxTransferUnit + @abstract Sets the maximum transfer unit for this interface. + @discussion Both the if_mtu field in the ifnet structure, and the + kIOMaxTransferUnit property are updated with the value provided. + @param mtu The interface MTU size in bytes. + @result Returns true if the update was successful, false otherwise. +*/ + + virtual bool setMaxTransferUnit(UInt32 mtu); + +/*! @function setFlags + @abstract Performs a read-modify-write operation on the current + interface flags value. + @discussion See bsd/net/if.h header file for the definition of the + flag constants. Both the if_flags field in the ifnet structure, and + the kIOInterfaceFlags property are updated with the value provided. + @param flags The bits that should be set. + @param clear The bits that should be cleared. If 0, then non + of the flags are cleared and the result is formed by OR'ing the + original flags value with the new flags. + @result Returns true if the update was successful, false otherwise. +*/ + + virtual bool setFlags(UInt16 flags, UInt16 clear = 0); + +/*! @function setExtraFlags + @abstract Performs a read-modify-write operation on the current + interface extra flags value. + @discussion See bsd/net/if.h header file for the definition of the + extra flag constants. Both the if_eflags field in the ifnet structure, + and the kIOInterfaceExtraFlags property are updated with the value + provided. + @param flags The bits that should be set. + @param flags The bits that should be set. + @param clear The bits that should be cleared. If 0, then non + of the flags are cleared and the result is formed by OR'ing the + original flags with the new flags. + @result Returns true if the update was successful, false otherwise. +*/ + + virtual bool setExtraFlags(UInt32 flags, UInt32 clear = 0); + +/*! @function setMediaAddressLength + @abstract Sets the size of the media (MAC-layer) address. + @discussion Both the if_addrlen field in the ifnet structure, and the + kIOMediaAddressLength property are updated with the value provided. + @param length The size of the media address in bytes. + @result Returns true if the update was successful, false otherwise. +*/ + + virtual bool setMediaAddressLength(UInt8 length); + +/*! @function setMediaHeaderLength + @abstract Sets the size of the media header. + @discussion Both the if_hdrlen field in the ifnet structure, and the + kIOMediaHeaderLength property are updated with the value provided. + @param length The size of the media header in bytes. + @result Returns true if the update was successful, false otherwise. +*/ + + virtual bool setMediaHeaderLength(UInt8 length); + +/*! @function setUnitNumber + @abstract Assigns a unique unit number to this interface. + @discussion This method is called by IONetworkStack before the + interface is registered with the data link layer, to assign a + unique unit number to the interface object. Both the if_unit field + in the ifnet structure, and the kIOInterfaceUnit property are updated + with the value provided. + @param unit The unit number assigned to this interface object. + @result Returns true if the update was successful, false otherwise. +*/ + + virtual bool setUnitNumber(UInt16 unit); + +/*! @function free + @abstract Frees the IONetworkInterface object. + @discussion Resource allocated by init() are released, and + clearInputQueue() is called to ensure that the input queue is empty. +*/ + + virtual void free(); + +/*! @function handleOpen + @abstract Handles 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. Since the controller is opened by the interface + in a lazy fashion, the interface may also perform an open on the + controller before this method returns. If the controller was opened, + then controllerDidOpen() is called to notify interested subclasses. + Subclasses should not override this method. + @param client The client object that requested the open. + @param options Options passed to IOService::open(). + @param argument Argument passed to IOService::open(). + @result Returns true to accept the client open, false otherwise. +*/ + + virtual bool handleOpen(IOService * client, + IOOptionBits options, + void * argument); + +/*! @function handleClose + @abstract Handles 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); + +/*! @function handleIsOpen + @abstract Queries 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 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; + +/*! @function lock + @abstract Takes the network interface lock. + @discussion This method takes the recursive lock that protects the interface + state. All updates to the interface state and to the ifnet structure + must be performed while holding this lock. This call must be balanced + by a subsequent call to unlock(). +*/ + + virtual void lock(); + +/*! @function unlock + @abstract Releases the network interface lock. + @discussion This method releases the recursive lock that protects the interface + state to balance a previous lock() call. +*/ + + virtual void unlock(); + +/*! @function controllerDidOpen + @abstract Sends a notification that the interface has opened the network + controller. + @discussion This method is called by handleOpen() to notify subclasses that the + controller has been opened. The open on the controller is done 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. The implementation in the subclass must first + call the method in super and check the return value. This method is + called with our 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 be refused. +*/ + + 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 handleClose() after receiving a close from the + last 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 our 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 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, + and then call super for any commands not handled in the subclass. + The ioctl commands handled by IONetworkInterface are + SIOCGIFMTU (Get interface MTU size), + SIOCSIFMTU (Set interface MTU size), + SIOCSIFMEDIA (Set media), and + SIOCGIFMEDIA (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 bsd/sys/errno.h. +*/ + + virtual SInt32 performCommand(IONetworkController * controller, + unsigned long cmd, + void * arg0, + void * arg1); + +public: + +/*! @function getIfnet + @abstract Gets the ifnet_t allocated by the interface object. + @discussion Reveal the interface's ifnet_t. The ifnet_t is managed + primarily by IONetworkInterface, however sub-classes or drivers + can use this method to get a reference to the ifnet_t object for + interface KPI calls. + @result Returns the ifnet_t object that is attached to the datalink layer. +*/ + + virtual ifnet_t getIfnet() const ; + +protected: + +/*! @function initIfnet + @abstract Initializes the ifnet structure given. + @discussion A concrete subclass must override this method and initialize + the ifnet structure given. The implementation in the subclass must call + super before it returns, to allow IONetworkInterface to complete the + initialization, and to insert the BSD shim functions implemented in + IONetworkInterface to the appropriate function pointer fields in the + ifnet structure. IONetworkInterface will call this method during its + init() method. Subclasses are encouraged to use the ifnet accessor + methods to update the ifnet structure when possible, since this will + ensure that properties in the registry will also be updated to reflect + any changes made. + @param ifp Pointer to an ifnet structure obtained earlier through + the getIfnet() method call. + @result Returns true on success, false otherwise. +*/ + + virtual bool initIfnet(struct ifnet * ifp); + +/*! @function handleClientOpen + @abstract Handles a client open on the interface. + @discussion This method is called by handleOpen() to handle an open from a client object. + Unlike handleOpen(), subclasses may override this method to catch an open + request from a client. This method is called with the arbitration lock held. + @param client The client object requesting the open. + @param options Options passed to IONetworkInterface::handleOpen(). + @param argument Argument passed to IONetworkInterface::handleOpen(). + @result Returns true to accept the client open, false to refuse it. +*/ + + 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 handleClose() to handle a close from a client object. + Unlike handleClose(), subclasses may override this method to catch a close + reuqest from a client. This method is called with the arbitration lock held. + @param client The client object requesting the close. + @param options Options passed to IONetworkInterface::handleClose(). +*/ + + virtual void handleClientClose(IOService * client, + IOOptionBits options); + +/*! @function newUserClient + @abstract Creates a connection for a non kernel client. + @discussion This method creates a new IOUserClient to service a connection to a + non kernel client. + @param owningTask The mach task requesting the connection. + @param security_id A token representing the access level for the task. + @param type A constant specifying the type of connection to be created. + An IONetworkUserClient object is created if the type specified is + kIONetworkUserClientTypeID. + @param handler The IOUserClient object returned. + @result Returns kIOReturnSuccess if an IONetworkUserClient was created, + kIOReturnNoMemory for a memory allocation error, or + kIOReturnBadArgument if the type specified is unknown. +*/ + + virtual IOReturn newUserClient(task_t owningTask, + void * security_id, + UInt32 type, + IOUserClient ** handler); + +/*! @function setInterfaceState + @abstract Updates the interface object state flags. + @discussion The kIOInterfaceState property is updated with the value + provided. + @param flags The bits that should be set. + @param clear The bits that should be cleared. + @result Returns the resulting interface state flags following any changes + made by this method. +*/ + + virtual UInt32 setInterfaceState( UInt32 set, UInt32 clear = 0 ); + +/*! @function powerStateWillChangeTo + @abstract Handles a notification that the network controller servicing + this interface object is about to transition to a new power state. + @discussion This method will call the controllerWillChangePowerState() method + on the controller's work loop context to prepare for the power state change. + Subclasses should not 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 The return will always be IOPMAckImplied to indicate that the + preparation for the power change has already completed when this method + returns. +*/ + + virtual IOReturn powerStateWillChangeTo( IOPMPowerFlags flags, + unsigned long stateNumber, + IOService * policyMaker ); + +/*! @function powerStateDidChangeTo + @abstract Handles a notification that the network controller servicing + this interface object has transitioned to a new power state. + @discussion This method will call the controllerDidChangePowerState() method + on the controller's work loop context to prepare for the power state change. + Subclasses should not 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 The return will always be IOPMAckImplied to indicate that the + preparation for the power change has already completed when this method + returns. +*/ + + virtual IOReturn powerStateDidChangeTo( IOPMPowerFlags flags, + unsigned long stateNumber, + IOService * policyMaker ); + +/*! @function controllerWillChangePowerState + @abstract Handles a notification that the network controller servicing + this interface object is about to 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 kIOReturnSuccess. +*/ + + 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 kIOReturnSuccess. +*/ + + virtual IOReturn controllerDidChangePowerState( + IONetworkController * controller, + IOPMPowerFlags flags, + UInt32 stateNumber, + IOService * policyMaker); + +public: + /* Override IOService::willTerminate() */ + + virtual bool willTerminate( IOService * provider, + IOOptionBits options ); + + /* Override IOService::serializeProperties() */ + + virtual bool serializeProperties( OSSerialize * s ) const; + +/*! @function attachToDataLinkLayer + @abstract Attaches the network interface to the BSD data link layer. + @discussion This function is called by the family to attach the network + interface managed by an IONetworkInterface to the BSD data link layer. + This call occurs after the interface initialization and setup, and the + assignment of an interface unit number. The family does not implicitly + close the gate on the network controller's work loop when calling this + function. Prior to the data link attachment, services provided by an + IONetworkInterface will be inaccessible to BSD networking, though the + object can be found in the I/O Kit Registry. Subclasses can override + this function to perform interface specific work. + @param options Options for the attach call. None are currently defined. + @param parameter Parameter for the attach call. Not currently used. + @result Returns kIOReturnSuccess on success. +*/ + + virtual IOReturn attachToDataLinkLayer( IOOptionBits options, + void * parameter ); + + OSMetaClassDeclareReservedUsed(IONetworkInterface, 0); + +/*! @function detachFromDataLinkLayer + @abstract Detaches the network interface from the BSD data link layer. + @discussion This function is called by the family to detach the network + interface managed by an IONetworkInterface from the BSD data link layer. + This call is made when the interface is terminated, before the last close. + The family does not implicitly close the gate on the network controller's + work loop when calling this function. Subclasses can override this function + to perform additional interface specific work. + @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 feedInputPacketTap + @abstract Feed received packets to the BPF + @discussion This function is called by the family for each inbound packet + to feed it to the BPF function. Interface classes can override if they + need to provide class specific functionality or modifications to the BPF tap. + @param mbuf Pointer to the packet. +*/ + virtual void feedPacketInputTap(mbuf_t); + + OSMetaClassDeclareReservedUsed( IONetworkInterface, 2); + +/*! @function feedOutputPacketTap + @abstract Feed sent packets to the BPF + @discussion This function is called by the family for each outbound packet + to feed it to the BPF function. Interface classes can override if they + need to provide class specific functionality or modifications to the BPF tap. + @param mbuf Pointer to the packet. +*/ + virtual void feedPacketOutputTap(mbuf_t); + + OSMetaClassDeclareReservedUsed( IONetworkInterface, 3); + + virtual bool initIfnetParams(struct ifnet_init_params *params); + OSMetaClassDeclareReservedUsed( IONetworkInterface, 4); + +public: + // Virtual function padding + 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 /* defined(KERNEL) && defined(__cplusplus) */ + +#endif /* !_IONETWORKINTERFACE_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/network/IONetworkMedium.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/network/IONetworkMedium.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/network/IONetworkMedium.h (revision 885) @@ -0,0 +1,426 @@ +/* + * 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 _IONETWORKMEDIUM_H +#define _IONETWORKMEDIUM_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/*! @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. +// +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 ) +}; + +// 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, + 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) & kIOMediumNetworkMask) +#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. +}; + +#ifdef __cplusplus +} +#endif + +//=========================================================================== +// IONetworkMedium class. + +#ifdef KERNEL + +#include +#include + +/*! @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 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(); + +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; + +/*! @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; + + // 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 */ Index: branches/azimutz/Cleancut/i386/include/IOKit/network/IOPacketQueue.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/network/IOPacketQueue.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/network/IOPacketQueue.h (revision 885) @@ -0,0 +1,290 @@ +/* + * 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 +#include +extern "C" { +#include +} +// 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(queue,elt) +#undef dequeue(queue) + +/*! @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 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(); + +/*! @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 const 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 */ Index: branches/azimutz/Cleancut/i386/include/IOKit/network/IOEthernetStats.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/network/IOEthernetStats.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/network/IOEthernetStats.h (revision 885) @@ -0,0 +1,161 @@ +/* + * 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 */ Index: branches/azimutz/Cleancut/i386/include/IOKit/network/IONetworkController.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/network/IONetworkController.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/network/IONetworkController.h (revision 885) @@ -0,0 +1,1452 @@ +/* + * 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 NetworkFeatureFlags + @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 kIONetworkFeaturesHardwareVlan 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 kIONetworkFeaturesSoftwareVlan 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. +*/ + +enum { + kIONetworkFeatureNoBSDWait = 0x01, + kIONetworkFeatureHardwareVlan = 0x02, + kIONetworkFeatureSoftwareVlan = 0x04, + kIONetworkFeatureMultiPages = 0x08, + kIONetworkFeatureTSOIPv4 = 0x10, + kIONetworkFeatureTSOIPv6 = 0x20 +}; + +/* + * Kernel + */ +#if defined(KERNEL) && defined(__cplusplus) + +#include +#include +#include +#include + +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 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 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); + +/*! @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); + +/*! @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); + +/*! @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 packet 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, 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 buffer 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 m 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/IPChecksums + @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 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, + 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 IOService::systemWillShutdown in order + to notify network clients that the power-managed controller should be disabled. + As a result, drivers can expect their disable method to be called + before system shutdown or restart. This implementation is synchronous and can + block before calling IOService::systemWillShutdown and return. + @param See IOService::systemWillShutdown. +*/ + + virtual void systemWillShutdown( IOOptionBits specifier ); + + /* Override IOService::setAggressiveness() */ + + virtual IOReturn setAggressiveness( + unsigned long type, unsigned long newLevel ); + +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(); + +/*! @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); + +/*! @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); + +/*! @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; + +/*! @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 interface client object. + @discussion This method creates a new interface object and attaches it to the + controller. The createInterface() method is called to perform + the interface allocation and initialization, followed by a call to + configureInterface() to configure it. Subclasses can override those + two methods to customize the interface client attached. Drivers will + usually call this method from start(), after they are ready to process + client requests. Since most drivers will have a single interface + client, this method will likely be called only once. + @param interface Upon success (return value is true), the + interface object will be written to the handle provided. + @param doRegister If true, then registerService() is called to register + the interface, which will trigger the matching process, and will ultimately + cause the interface to become registered with the data link layer. + Drivers that wish to delay the registration can set doRegister to false, + and call registerService() on the interface object when the controller + becomes ready. This allows the driver to attach an interface without + making its services available to the rest of the system. + @result Returns true on success, false 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); + + // Virtual function padding + OSMetaClassDeclareReservedUnused( IONetworkController, 0); + OSMetaClassDeclareReservedUnused( IONetworkController, 1); + 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 /* defined(KERNEL) && defined(__cplusplus) */ + +#endif /* !_IONETWORKCONTROLLER_H */ + Index: branches/azimutz/Cleancut/i386/include/IOKit/network/IOEthernetInterface.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/network/IOEthernetInterface.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/network/IOEthernetInterface.h (revision 885) @@ -0,0 +1,328 @@ +/* + * 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 + +/* + * Kernel + */ +#if defined(KERNEL) && defined(__cplusplus) + +#include +#include +#include + +/*! @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 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 + }; + /*! @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); + void _fixupVlanPacket(mbuf_t, u_int16_t, int); + void reportInterfaceWakeFlags(void); + + 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 ); + +/*! @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; + +/*! @function setProperties + @abstract Handles a request to set Ethernet interface properties from + kernel or non-kernel clients. + @discussion For non-kernel clients, the preferred + access mechanism is through a user client connection. + @param properties An OSDictionary containing a collection of + properties. + @result Returns kIOReturnUnsupported if the interface did not + recognize any of the properties provided. Otherwise, the return + code will be kIOReturnSuccess to indicate no errors, or an + IOReturn error code to indicate that an error occurred while + handling one of the properties. +*/ + + virtual IOReturn setProperties( OSObject * properties ); + +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(); + +/*! @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); + +/*! @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); + +/*! @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); + + +/*! @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); + +/*! @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); + +public: + /* Override IONetworkInterface::willTerminate() */ + + virtual bool willTerminate( IOService * provider, + IOOptionBits options ); + + /* Override IONetworkInterface::attachToDataLinkLayer() */ + + virtual IOReturn attachToDataLinkLayer( IOOptionBits options, + void * parameter ); + + /* Override IONetworkInterface::inputEvent() */ + + virtual bool inputEvent( UInt32 type, void * data ); + +protected: + virtual void feedPacketInputTap(mbuf_t); + virtual void feedPacketOutputTap(mbuf_t); + virtual bool initIfnetParams(struct ifnet_init_params *params); + +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 /* defined(KERNEL) && defined(__cplusplus) */ + +#endif /* !_IOETHERNETINTERFACE_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/network/IOMbufMemoryCursor.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/network/IOMbufMemoryCursor.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/network/IOMbufMemoryCursor.h (revision 885) @@ -0,0 +1,381 @@ +/* + * 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 + + +/*! @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. +

+ 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. +

+ 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 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 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 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 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 */ + Index: branches/azimutz/Cleancut/i386/include/IOKit/IOPlatformExpert.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/IOPlatformExpert.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/IOPlatformExpert.h (revision 885) @@ -0,0 +1,318 @@ +/* + * 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_IOPLATFORMEXPERT_H +#define _IOKIT_IOPLATFORMEXPERT_H + +#ifdef __cplusplus +#include +#include +#include +#include + +extern "C" { +#endif + +#include + +extern boolean_t PEGetMachineName( char * name, int maxLength ); +extern boolean_t PEGetModelName( char * name, int maxLength ); +extern int PEGetPlatformEpoch( void ); + +enum { + kPEHaltCPU, + kPERestartCPU, + kPEHangCPU, + kPEUPSDelayHaltCPU, + kPEPanicRestartCPU, + kPEPanicSync +}; +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 long PEGetGMTTimeOfDay( void ); +extern void PESetGMTTimeOfDay( long secs ); + +#ifdef __cplusplus +} /* extern "C" */ + +#define kIOPlatformMapperPresentKey "IOPlatformMapperPresent" + + +extern OSSymbol * gPlatformInterruptControllerName; + +extern const OSSymbol * gIOPlatformSleepActionKey; +extern const OSSymbol * gIOPlatformWakeActionKey; +extern const OSSymbol * gIOPlatformQuiesceActionKey; +extern const OSSymbol * gIOPlatformActiveActionKey; + +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 *reserved; + + 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 ); + virtual bool start( IOService * provider ); + virtual bool configure( IOService * provider ); + virtual IOService * createNub( OSDictionary * from ); + + virtual bool compareNubName( const IOService * nub, OSString * name, + OSString ** matched = 0 ) const; + virtual IOReturn getNubResources( IOService * nub ); + + virtual long getBootROMType(void); + virtual long getChipSetType(void); + virtual long getMachineType(void); + + 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 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); + + 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); + + OSMetaClassDeclareReservedUsed(IOPlatformExpert, 0); + OSMetaClassDeclareReservedUsed(IOPlatformExpert, 1); + OSMetaClassDeclareReservedUnused(IOPlatformExpert, 2); + OSMetaClassDeclareReservedUnused(IOPlatformExpert, 3); + OSMetaClassDeclareReservedUnused(IOPlatformExpert, 4); + OSMetaClassDeclareReservedUnused(IOPlatformExpert, 5); + OSMetaClassDeclareReservedUnused(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 *reserved; + +public: + virtual IOService * probe( IOService * provider, + SInt32 * score ); + virtual bool configure( IOService * provider ); + + 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, OSIterator * iter ); + + virtual bool compareNubName( const IOService * nub, OSString * name, + OSString ** matched = 0 ) const; + + virtual IOReturn getNubResources( IOService * nub ); + + virtual bool getModelName( char * name, int maxLength ); + virtual bool getMachineName( char * name, int maxLength ); + + virtual void registerNVRAMController( IONVRAMController * nvram ); + + virtual int haltRestart(unsigned int type); + + /* 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 ); + + // 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); + virtual OSString* createSystemSerialNumberString(OSData* myProperty); + + 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 *reserved; + +public: + virtual bool initWithArgs( void * p1, void * p2, + void * p3, void *p4 ); + virtual bool compareName( OSString * name, OSString ** matched = 0 ) const; + + virtual IOWorkLoop *getWorkLoop() const; + virtual IOReturn setProperties( OSObject * properties ); + + virtual void free(); + + 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 *reserved; + +public: + virtual bool compareName( OSString * name, OSString ** matched = 0 ) const; + virtual IOService * matchLocation( IOService * client ); + virtual IOReturn getResources( void ); + + OSMetaClassDeclareReservedUnused(IOPlatformDevice, 0); + OSMetaClassDeclareReservedUnused(IOPlatformDevice, 1); + OSMetaClassDeclareReservedUnused(IOPlatformDevice, 2); + OSMetaClassDeclareReservedUnused(IOPlatformDevice, 3); +}; + +#endif /* __cplusplus */ + +#endif /* ! _IOKIT_IOPLATFORMEXPERT_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/IOWorkLoop.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/IOWorkLoop.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/IOWorkLoop.h (revision 885) @@ -0,0 +1,321 @@ +/* + * Copyright (c) 1998-2007 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_IOWORKLOOP_H +#define __IOKIT_IOWORKLOOP_H + +#include +#include +#include +#include + +#include + +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. +

+ 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. +

+ 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); + enum { + kPreciousStack = 0x00000001 + }; + +private: +/*! @function threadMainContinuation + @abstract Static function that calls the threadMain function. +*/ + static void threadMainContinuation(IOWorkLoop *self); + +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; + }; + +/*! @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. +

+ 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(); + +/*! @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 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 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(); + +/*! @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 IODynamicCast(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 IODynamicCast(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; + 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 = 0, void *arg1 = 0, + void *arg2 = 0, void *arg3 = 0); + +/*! @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. +

+ 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(); + +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 + OSMetaClassDeclareReservedUsed(IOWorkLoop, 0); + OSMetaClassDeclareReservedUsed(IOWorkLoop, 1); + OSMetaClassDeclareReservedUsed(IOWorkLoop, 2); +#endif + OSMetaClassDeclareReservedUnused(IOWorkLoop, 3); + OSMetaClassDeclareReservedUnused(IOWorkLoop, 4); + OSMetaClassDeclareReservedUnused(IOWorkLoop, 5); + OSMetaClassDeclareReservedUnused(IOWorkLoop, 6); + OSMetaClassDeclareReservedUnused(IOWorkLoop, 7); +}; + +#endif /* !__IOKIT_IOWORKLOOP_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/IOUserClient.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/IOUserClient.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/IOUserClient.h (revision 885) @@ -0,0 +1,333 @@ +/* + * 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@ + */ + +/* + * Changes to this API are expected. + */ + +#ifndef _IOKIT_IOUSERCLIENT_H +#define _IOKIT_IOUSERCLIENT_H + +#include +#include +#include + + +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 +}; + +// 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 __reserved[32]; +}; + +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 1 + 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 +{ + OSDeclareAbstractStructors(IOUserClient) + +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: + OSSet * mappings; + UInt8 sharedInstance; + UInt8 __reservedA[3]; + void * __reserved[7]; + +public: + virtual IOReturn externalMethod( uint32_t selector, IOExternalMethodArguments * arguments, + IOExternalMethodDispatch * dispatch = 0, OSObject * target = 0, void * reference = 0 ); + + virtual IOReturn registerNotificationPort( + mach_port_t port, UInt32 type, io_user_reference_t refCon); + +private: +#if __LP64__ + OSMetaClassDeclareReservedUnused(IOUserClient, 0); + OSMetaClassDeclareReservedUnused(IOUserClient, 1); +#else + OSMetaClassDeclareReservedUsed(IOUserClient, 0); + OSMetaClassDeclareReservedUsed(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); + static void setAsyncReference64(OSAsyncReference64 asyncRef, + mach_port_t wakePort, + mach_vm_address_t callback, io_user_reference_t refcon); +public: + + static IOReturn clientHasPrivilege( void * securityToken, + const char * privilegeName ); + + /*! + @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 reference 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(); + virtual bool init( OSDictionary * dictionary ); + // 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(); + + 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 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 ); + +#if !__LP64__ +private: + APPLE_KEXT_COMPATIBILITY_VIRTUAL + IOMemoryMap * mapClientMemory( IOOptionBits type, + task_t task, + IOOptionBits mapFlags = kIOMapAnywhere, + IOVirtualAddress atAddress = 0 ); +#endif + +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. + */ + 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, + 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( IOService ** targetP, UInt32 index ); + virtual IOExternalAsyncMethod * + getAsyncTargetAndMethodForIndex( IOService ** targetP, UInt32 index ); + + // Methods for accessing trap vector - old and new style + virtual IOExternalTrap * + getExternalTrapForIndex( UInt32 index ) + APPLE_KEXT_DEPRECATED; + + virtual IOExternalTrap * + getTargetAndTrapForIndex( IOService **targetP, UInt32 index ); +}; + +#endif /* ! _IOKIT_IOUSERCLIENT_H */ + Index: branches/azimutz/Cleancut/i386/include/IOKit/IOInterrupts.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/IOInterrupts.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/IOInterrupts.h (revision 885) @@ -0,0 +1,58 @@ +/* + * 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 */ Index: branches/azimutz/Cleancut/i386/include/IOKit/IOReturn.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/IOReturn.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/IOReturn.h (revision 885) @@ -0,0 +1,137 @@ +/* + * 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 + +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_pccard err_sub(21) + +#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 */ Index: branches/azimutz/Cleancut/i386/include/IOKit/IODMAEventSource.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/IODMAEventSource.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/IODMAEventSource.h (revision 885) @@ -0,0 +1,84 @@ +/* + * 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 +#include +#include +#include + +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); +#define IODMAEventAction IODMAEventSource::Action + + protected: + virtual void completeDMACommand(IODMACommand *dmaCommand); + virtual void notifyDMACommand(IODMACommand *dmaCommand, IOReturn status, IOByteCount actualByteCount); + + public: + static IODMAEventSource *dmaEventSource(OSObject *owner, + IOService *provider, + Action completion = 0, + Action notification = 0, + 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(); + + private: + IOService *dmaProvider; + 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 = 0, + Action notification = 0, + UInt32 dmaIndex = 0); + virtual bool checkForWork(void); +}; + +#endif /* _IOKIT_IODMAEVENTSOURCE_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/hid/IOHIDDevice.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/hid/IOHIDDevice.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/hid/IOHIDDevice.h (revision 885) @@ -0,0 +1,706 @@ +/* + * + * @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_IOHIDDEVICE_H +#define _IOKIT_HID_IOHIDDEVICE_H + +#include +#include +#include +#include +#include + +class IOHIDSystem; +class IOHIDPointing; +class IOHIDKeyboard; +class IOHIDConsumer; +class IOHIDElementPrivate; +class IOHIDEventQueue; +class IOHIDInterface; +class IOHIDDeviceShim; +struct IOHIDReportHandler; + +/*! + @typedef IOHIDCompletionAction + @abstract Function called when set/get report completes + @param target The target specified in the IOHIDCompletion struct. + @param parameter The parameter specified in the IOHIDCompletion struct. + @param status Completion status +*/ +typedef void (*IOHIDCompletionAction)( + void * target, + void * parameter, + IOReturn status, + UInt32 bufferSizeRemaining); + +/*! + @typedef IOHIDCompletion + @abstract Struct spefifying action to perform when set/get report completes. + @param target The target to pass to the action function. + @param action The function to call. + @param parameter The parameter to pass to the action function. +*/ +typedef struct IOHIDCompletion { + void * target; + IOHIDCompletionAction action; + void * parameter; +} IOHIDCompletion; + +/*! + @enum IOHIDReportOption + @abstract Option bits for IOHIDDevice::handleReport, + IOHIDDevice::getReport, and IOHIDDevice::setReport + @constant kIOHIDReportOptionNotInterrupt Tells method that the report + passed was not interrupt driven. +*/ +enum +{ + kIOHIDReportOptionNotInterrupt = 0x100 +}; + + +/*! @class IOHIDDevice : public IOService + @abstract IOHIDDevice defines a Human Interface Device (HID) object, + which will interact with the HID Manager by publishing static properties + in the registry, and also by reporting HID events through shared memory. + IOHIDDevice is an abstract class that must be subclassed to support a + specific type of HID devices, such as USB HID class devices. +
+ Since most HID devices are expected to be USB devices, IOHIDDevice + uses the USB HID specification to define the format of the report + descriptor, and also reports that are used to communicate with the + hardware via some intervening transport layer. However, there is no + mandate that the transport layer must be restricted to USB. A subclass + may be created to support legacy ADB joysticks, and issue packets on + the ADB bus and translate those packets to USB reports, and vice versa. + IOHIDDevice does not care how those reports are generated or consumed + by the physical device, as long as the reports abide to the USB + specification. */ + +class IOHIDDevice : public IOService +{ + OSDeclareDefaultStructors( IOHIDDevice ) + + friend class IOHIDLibUserClient; + friend class IOHIDDeviceShim; + +private: + OSArray * _elementArray; + UInt32 _dataElementIndex; + IORecursiveLock * _elementLock; + IOHIDReportHandler * _reportHandlers; + IOBufferMemoryDescriptor * _elementValuesDescriptor; + bool _readyForInputReports; + UInt32 _reportCount; + UInt32 _maxInputReportSize; + UInt32 _maxOutputReportSize; + UInt32 _maxFeatureReportSize; + + struct ExpansionData { + OSSet * clientSet; + IOService * seizedClient; + AbsoluteTime eventDeadline; + IONotifier * publishNotify; + OSArray * inputInterruptElementArray; + bool performTickle; + IOHIDInterface * interfaceNub; + IOHIDElementPrivate * rollOverElement; + OSArray * hierarchElements; + }; + /*! @var reserved + Reserved for future use. (Internal use only) */ + ExpansionData * _reserved; + + // HID report descriptor parsing support. + + bool linkToParent( const OSArray * array, + UInt32 parentIndex, + UInt32 childIndex ); + + bool createCollectionElements( HIDPreparsedDataRef parseData, + OSArray * array, + UInt32 maxCount ); + + bool createValueElements( HIDPreparsedDataRef parseData, + OSArray * array, + UInt32 hidReportType, + IOHIDElementType elementType, + UInt32 maxCount ); + + bool createButtonElements( HIDPreparsedDataRef parseData, + OSArray * array, + UInt32 hidReportType, + IOHIDElementType elementType, + UInt32 maxCount ); + + bool createReportHandlerElements( HIDPreparsedDataRef parseData); + + OSArray * newDeviceUsagePairs(); + + bool getReportCountAndSizes( HIDPreparsedDataRef parseData ); + + bool setReportSize( UInt8 reportID, + IOHIDReportType reportType, + UInt32 bits ); + + IOReturn createElementHierarchy( HIDPreparsedDataRef parseData ); + + IOReturn parseReportDescriptor( IOMemoryDescriptor * report, + IOOptionBits options = 0 ); + + IOBufferMemoryDescriptor * createMemoryForElementValues(); + + + static bool _publishNotificationHandler( void * target, + void * ref, IOService * newService ); + +protected: + +/*! @function free + @abstract Free the IOHIDDevice object. + @discussion Release all resources that were previously allocated, + then call super::free() to propagate the call to our superclass. */ + + virtual void free(); + +/*! @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); + +/*! @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); + +/*! @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; + +/*! @function handleStart + @abstract Prepare the hardware and driver to support I/O operations. + @discussion IOHIDDevice will call this method from start() before + any I/O operations are issued to the concrete subclass. Methods + such as newReportDescriptor() 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 IOHIDDevice 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 ); + +/*! @function newUserClient + @abstract Handle a request to create a connection for a non kernel + client. + @discussion Create a new IOUserClient, or a subclass of IOUserClient, + to service a connection to a non kernel client. This implementation + will simply call the implementation in IOService to handle the call. + @param owningTask The mach task requesting the connection. + @param security_id A token representing the access level for the task. + @param type A constant specifying the type of connection to be created. + @param properties A dictionary of additional properties for the connection. + @param handler The IOUserClient object returned. + @result The return from IOService::newUserClient() is returned. */ + + virtual IOReturn newUserClient( task_t owningTask, + void * security_id, + UInt32 type, + OSDictionary * properties, + IOUserClient ** handler ); + IOReturn newUserClientGated(task_t owningTask, + void * security_id, + OSDictionary * properties, + IOUserClient ** handler ); + +/*! @function publishProperties + @abstract Publish HID properties to the I/O Kit registry. + @discussion Called by the start() method to fetch and publish all + HID properties to the I/O Kit registry. These properties will allow + the HID Manager to identify all HID device(s) in the system, by + iterating through objects that are subclasses of IOHIDDevice, and + then fetch their published property values. The implementation in + IOHIDDevice will call methods to get each individual HID property, + and subclasses will not normally need to override this method. + @param provider The provider argument passed to start(). + @result True to indicate that all properties were discovered and + published to the registry, false otherwise. Returning false will + cause start() to fail and return false. */ + + virtual bool publishProperties( IOService * provider ); + +public: + +/*! @function init + @abstract Initialize an IOHIDDevice object. + @discussion Prime the IOHIDDevice object and prepare it to support + a probe() or a start() call. This implementation will simply call + super::init(). + @param A dictionary A property table associated with this IOHIDDevice + instance. + @result True on sucess, or false otherwise. */ + + virtual bool init( OSDictionary * dictionary = 0 ); + +/*! @function start + @abstract Start up the driver using the given provider. + @discussion IOHIDDevice will allocate resources, then call handleStart() + before fetching the report descriptor through newReportDescriptor(), and + publishing HID properties to the registry. Before returning true to + indicate success, registerService() is called to trigger client matching. + Subclasses are recommended to override handleStart(). + @param provider The provider that the driver was matched to, and selected + to run with. + @result True on success, or false otherwise. */ + + virtual bool start( IOService * provider ); + +/*! @function stop + @abstract Called by a provider (during its termination) before detaching + all its clients. + @discussion IOHIDDevice will call handleStop(), then release allocated + resources. Subclasses are recommended to override handleStop(). + @param provider The provider that the driver was started on. */ + + virtual void stop( IOService * provider ); + +/*! @function matchPropertyTable + @abstract Called by the provider during a match + @discussion Compare the properties in the supplied table to this + object's properties. + @param table The property table that this device will match against +*/ + + virtual bool matchPropertyTable(OSDictionary * table, SInt32 * score); + +/*! @function newTransportString + @abstract Returns a string object that describes the transport + layer used by the HID device. + @result A string object. The caller must decrement the retain count + on the object returned. */ + + virtual OSString * newTransportString() const; + +/*! @function newManufacturerString + @abstract Returns a string object that describes the manufacturer + of the HID device. + @result A string object. The caller must decrement the retain count + on the object returned. */ + + virtual OSString * newManufacturerString() const; + +/*! @function newProductString + @abstract Returns a string object that describes the product + of the HID device. + @result A string object. The caller must decrement the retain count + on the object returned. */ + + virtual OSString * newProductString() const; + +/*! @function newVendorIDNumber + @abstract Returns a number object that describes the vendor ID + of the HID device. + @result A number object. The caller must decrement the retain count + on the object returned. */ + + virtual OSNumber * newVendorIDNumber() const; + +/*! @function newProductIDNumber + @abstract Returns a number object that describes the product ID + of the HID device. + @result A number object. The caller must decrement the retain count + on the object returned. */ + + virtual OSNumber * newProductIDNumber() const; + +/*! @function newVersionNumber + @abstract Returns a number object that describes the version number + of the HID device. + @result A number object. The caller must decrement the retain count + on the object returned. */ + + virtual OSNumber * newVersionNumber() const; + +// *** THIS HAS BEEN DEPRECATED. PLEASE USE newSerialNumberString *** +/*! @function newSerialNumber + @abstract THIS HAS BEEN DEPRECATED. PLEASE USE newSerialNumberString. + @result A number object. The caller must decrement the retain count + on the object returned. */ + + virtual OSNumber * newSerialNumber() const; + +/*! @function newPrimaryUsageNumber + @abstract Returns a number object that describes the primary usage + of the HID device. + @result A number object. The caller must decrement the retain count + on the object returned. */ + + virtual OSNumber * newPrimaryUsageNumber() const; + +/*! @function newPrimaryUsagePageNumber + @abstract Returns a number object that describes the primary usage + page of the HID device. + @result A number object. The caller must decrement the retain count + on the object returned. */ + + virtual OSNumber * newPrimaryUsagePageNumber() const; + +/*! @function newReportDescriptor + @abstract Create and return a new memory descriptor that describes the + report descriptor for the HID device. + @discussion A subclass must override this pure virtual function, and + return a memory descriptor that describes the HID report descriptor as + defined by the USB Device Class Definition for Human Interface Devices + Version 1.1 specification. + @param descriptor Pointer to the memory descriptor returned. This + memory descriptor will be released by the caller. + @result kIOReturnSuccess on success, or an error return otherwise. */ + + virtual IOReturn newReportDescriptor( + IOMemoryDescriptor ** descriptor ) const = 0; + +/*! @function handleReport + @abstract Handle an asynchronous report received from the HID device. + @param report A memory descriptor that describes the report. + @param reportType The type of report. + @param options Options to specify the request. No options are + currently defined, and the default value is 0. + @result kIOReturnSuccess on success, or an error return otherwise. */ + + virtual IOReturn handleReport( + IOMemoryDescriptor * report, + IOHIDReportType reportType = kIOHIDReportTypeInput, + IOOptionBits options = 0 ); + +/*! @function getReport + @abstract Get a report from the HID device. + @discussion A completion parameter may be added in the future. + @param report A memory descriptor that describes the memory to store + the report read from the HID device. + @param reportType The report type. + @param options The lower 8 bits will represent the Report ID. The + other 24 bits are options to specify the request. + @result kIOReturnSuccess on success, or an error return otherwise. */ + + virtual IOReturn getReport( IOMemoryDescriptor * report, + IOHIDReportType reportType, + IOOptionBits options ); + +/*! @function setReport + @abstract Send a report to the HID device. + @discussion A completion parameter may be added in the future. + @param report A memory descriptor that describes the report to send + to the HID device. + @param reportType The report type. + @param options The lower 8 bits will represent the Report ID. The + other 24 bits are options to specify the request. + @result kIOReturnSuccess on success, or an error return otherwise. */ + + virtual IOReturn setReport( IOMemoryDescriptor * report, + IOHIDReportType reportType, + IOOptionBits options = 0 ); + +/*! @function getMemoryWithCurrentElementValues + @abstract Get a reference to a memory descriptor that describes the + memory block containing the current HID element values. + @discussion Each HID element that can contribute to an input, output, + or feature report, is assigned an area of memory from a common memory + block allocated by IOHIDDevice. Each element will use its assigned + memory area to store its current value, defined by an IOHIDElementValue + structure. The memory described by the memory descriptor may be mapped + to user space to allow the HID Manager to poll the current element + value without the cost of a user-kernel transition. Subclasses should + not override this method. + @result A reference to a memory descriptor that describes the current + element values, or 0 to indicate a resource shortage. */ + + virtual IOMemoryDescriptor * getMemoryWithCurrentElementValues() const; + +/*! @function registerElement + @abstract A registration function called by a HID element to register + itself, and also to obtain an unique cookie identifier + (unique per device, not unique system-wide). + @discussion An internal data type, an IOHIDElementPrivate, is created to + represent each HID element discovered by parsing the HID report + descriptor. Each element created will call this method to register + itself with its owner (IOHIDDevice), and also to obtain an element + cookie that is used by HID Manager to specify and identify the element. + Subclasses should not override this method. + @param element The element that is requesting registration with its + owner. + @param cookie Pointer to the returned cookie assigned to this element. + @result True on success, or false otherwise. */ + + virtual bool registerElement( IOHIDElementPrivate * element, + IOHIDElementCookie * cookie ); + +/*! @function startEventDelivery + @abstract Start delivering events from a HID element to the event + queue specified. + @discussion Clients of IOHIDDevice may create an IOHIDEventQueue, and + then call this method to register for delivery of events generated by + one or more HID elements to that event queue. Subclasses should not + override this method. + @param queue The event queue that is interested in receiving events + generated by the HID element specified. The retain count on the queue + will be incremented by one. + @param cookie The cookie for a HID element published by the HID device. + @param options Options to specify the request. No options are currently + defined, and the default value is zero. + @result kIOReturnSuccess on success, or kIOReturnBadArgument if the + queue or the cookie argument specified is invalid, or kIOReturnNoMemory + if a resource shortage was encountered. */ + + virtual IOReturn startEventDelivery( IOHIDEventQueue * queue, + IOHIDElementCookie cookie, + IOOptionBits options = 0 ); + +/*! @function stopEventDelivery + @abstract Stop delivering events from one or more HID elements to the + event queue specified. + @discussion Clients that called startEventDelivery() must eventually + call this method to stop event delivery to its queue from one or more + HID elements. + @param queue The event queue that no longer wishes to receive events + generated by the HID element specified. + @param cookie The cookie for a HID element published by the HID device. + The default value of zero indicates that the queue should be removed from + the event dispatch list of all HID elements published by the HID device. + Subclasses should not override this method. + @result kIOReturnSuccess if the queue was removed from the event dispatch + list for one or more HID elements, or kIOReturnBadArgument if the queue + or the cookie argument specified is invalid, or kIOReturnNotFound if the + queue was not found. */ + + virtual IOReturn stopEventDelivery( IOHIDEventQueue * queue, + IOHIDElementCookie cookie = 0 ); + +/*! @function checkEventDelivery + @abstract Check whether events from a HID element will be delivered to + the event queue specified. + @param queue The event queue. + @param cookie The cookie for a HID element published by the HID device. + @param isActive Pointer to the return value that is set to true if events + generated by the HID element will be delivered to the queue, or false + otherwise. This return value is set only if kIOReturnSuccess is + returned. + @result kIOReturnSuccess on success, or kIOReturnBadArgument if one or + more of the arguments provided are invalid. */ + + virtual IOReturn checkEventDelivery( IOHIDEventQueue * queue, + IOHIDElementCookie cookie, + bool * isActive ); + +/*! @function updateElementValues + @abstract Updates element values from a HID device via getReport. + @discussion A completion parameter may be added in the future. + @param cookies A list of element cookies who's values need to be + set on the device. + @param cookieCount The number of element cookies. + @result kIOReturnSuccess on success, or an error return otherwise. */ + OSMetaClassDeclareReservedUsed(IOHIDDevice, 0); + virtual IOReturn updateElementValues(IOHIDElementCookie * cookies, UInt32 cookieCount = 1); + +/*! @function postElementValues + @abstract Posts element values to a HID device via setReport. + @discussion A completion parameter may be added in the future. + @param cookies A list of element cookies who's values need to be + set on the device. + @param cookieCount The number of element cookies. + @result kIOReturnSuccess on success, or an error return otherwise. */ + OSMetaClassDeclareReservedUsed(IOHIDDevice, 1); + virtual IOReturn postElementValues(IOHIDElementCookie * cookies, UInt32 cookieCount = 1); + +/*! @function newSerialNumberString + @abstract Returns a string object that describes the serial number + of the HID device. + @result A number object. The caller must decrement the retain count + on the object returned. */ + OSMetaClassDeclareReservedUsed(IOHIDDevice, 2); + virtual OSString * newSerialNumberString() const; + +/*! @function newLocationIDNumber + @abstract Returns a number object that describes the location ID + of the HID device. + @result A number object. The caller must decrement the retain count + on the object returned. */ + OSMetaClassDeclareReservedUsed(IOHIDDevice, 3); + virtual OSNumber * newLocationIDNumber() const; + +/*! @function getReport + @abstract Get a report from the HID device. + @discussion A completion parameter may be added in the future. + @param report A memory descriptor that describes the memory to store + the report read from the HID device. + @param reportType The report type. + @param options The lower 8 bits will represent the Report ID. The + other 24 bits are options to specify the request. + @param completionTimeout Specifies an amount of time (in ms) after which + the command will be aborted if the entire command has not been completed. + @param completion Function to call when request completes. If omitted then + getReport() executes synchronously, blocking until the request is complete. + @result kIOReturnSuccess on success, or an error return otherwise. */ + + OSMetaClassDeclareReservedUsed(IOHIDDevice, 4); + virtual IOReturn getReport( IOMemoryDescriptor * report, + IOHIDReportType reportType, + IOOptionBits options, + UInt32 completionTimeout, + IOHIDCompletion * completion = 0); + +/*! @function setReport + @abstract Send a report to the HID device. + @discussion A completion parameter may be added in the future. + @param report A memory descriptor that describes the report to send + to the HID device. + @param reportType The report type. + @param options The lower 8 bits will represent the Report ID. The + other 24 bits are options to specify the request. + @param completionTimeout Specifies an amount of time (in ms) after which + the command will be aborted if the entire command has not been completed. + @param completion Function to call when request completes. If omitted then + setReport() executes synchronously, blocking until the request is complete. + @result kIOReturnSuccess on success, or an error return otherwise. */ + + OSMetaClassDeclareReservedUsed(IOHIDDevice, 5); + virtual IOReturn setReport( IOMemoryDescriptor * report, + IOHIDReportType reportType, + IOOptionBits options, + UInt32 completionTimeout, + IOHIDCompletion * completion = 0); + +/*! @function newVendorIDSourceNumber + @abstract Returns a number object that describes the vendor ID + source of the HID device. + @result A number object. The caller must decrement the retain count + on the object returned. */ + OSMetaClassDeclareReservedUsed(IOHIDDevice, 6); + virtual OSNumber * newVendorIDSourceNumber() const; + +/*! @function newCountryCodeNumber + @abstract Returns a number object that describes the country code + of the HID device. + @result A number object. The caller must decrement the retain count + on the object returned. */ + OSMetaClassDeclareReservedUsed(IOHIDDevice, 7); + virtual OSNumber * newCountryCodeNumber() const; + + +/*! @function handleReportWithTime + @abstract Handle an asynchronous report received from the HID device. + @param timeStamp The timestamp of report. + @param report A memory descriptor that describes the report. + @param reportType The type of report. Currently, only + kIOHIDReportTypeInput report type is handled. + @param options Options to specify the request. No options are + currently defined, and the default value is 0. + @result kIOReturnSuccess on success, or an error return otherwise. */ + + OSMetaClassDeclareReservedUsed(IOHIDDevice, 8); + virtual IOReturn handleReportWithTime( + AbsoluteTime timeStamp, + IOMemoryDescriptor * report, + IOHIDReportType reportType = kIOHIDReportTypeInput, + IOOptionBits options = 0); + +/*! @function newReportInterval + @abstract Returns a number object that describes the actual polling + interval of the HID device in microseconds. + @result A number object. The caller must decrement the retain count + on the object returned. */ + OSMetaClassDeclareReservedUsed(IOHIDDevice, 9); + virtual OSNumber * newReportIntervalNumber() const; + + OSMetaClassDeclareReservedUnused(IOHIDDevice, 10); + OSMetaClassDeclareReservedUnused(IOHIDDevice, 11); + OSMetaClassDeclareReservedUnused(IOHIDDevice, 12); + OSMetaClassDeclareReservedUnused(IOHIDDevice, 13); + OSMetaClassDeclareReservedUnused(IOHIDDevice, 14); + OSMetaClassDeclareReservedUnused(IOHIDDevice, 15); + OSMetaClassDeclareReservedUnused(IOHIDDevice, 16); + OSMetaClassDeclareReservedUnused(IOHIDDevice, 17); + OSMetaClassDeclareReservedUnused(IOHIDDevice, 18); + OSMetaClassDeclareReservedUnused(IOHIDDevice, 19); + OSMetaClassDeclareReservedUnused(IOHIDDevice, 20); + OSMetaClassDeclareReservedUnused(IOHIDDevice, 21); + OSMetaClassDeclareReservedUnused(IOHIDDevice, 22); + OSMetaClassDeclareReservedUnused(IOHIDDevice, 23); + OSMetaClassDeclareReservedUnused(IOHIDDevice, 24); + OSMetaClassDeclareReservedUnused(IOHIDDevice, 25); + OSMetaClassDeclareReservedUnused(IOHIDDevice, 26); + OSMetaClassDeclareReservedUnused(IOHIDDevice, 27); + OSMetaClassDeclareReservedUnused(IOHIDDevice, 28); + OSMetaClassDeclareReservedUnused(IOHIDDevice, 29); + OSMetaClassDeclareReservedUnused(IOHIDDevice, 30); + OSMetaClassDeclareReservedUnused(IOHIDDevice, 31); + +#ifndef __ppc__ + OSMetaClassDeclareReservedUnused(IOHIDDevice, 32); + OSMetaClassDeclareReservedUnused(IOHIDDevice, 33); + OSMetaClassDeclareReservedUnused(IOHIDDevice, 34); + OSMetaClassDeclareReservedUnused(IOHIDDevice, 35); + OSMetaClassDeclareReservedUnused(IOHIDDevice, 36); + OSMetaClassDeclareReservedUnused(IOHIDDevice, 37); + OSMetaClassDeclareReservedUnused(IOHIDDevice, 38); + OSMetaClassDeclareReservedUnused(IOHIDDevice, 39); + OSMetaClassDeclareReservedUnused(IOHIDDevice, 40); +#endif + +}; + +#endif /* !_IOKIT_HID_IOHIDDEVICE_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/hid/IOHIDUsageTables.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/hid/IOHIDUsageTables.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/hid/IOHIDUsageTables.h (revision 885) @@ -0,0 +1,1665 @@ +/* + * @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 _IOHIDUSAGETABLES_H +#define _IOHIDUSAGETABLES_H + +/* ****************************************************************************************** + * HID Usage Tables + * + * The following constants are from the USB 'HID Usage Tables' specification, revision 1.1rc3 + * ****************************************************************************************** */ + + +/* Usage Pages */ +enum +{ + kHIDPage_Undefined = 0x00, + kHIDPage_GenericDesktop = 0x01, + kHIDPage_Simulation = 0x02, + kHIDPage_VR = 0x03, + kHIDPage_Sport = 0x04, + kHIDPage_Game = 0x05, + /* Reserved 0x06 */ + kHIDPage_KeyboardOrKeypad = 0x07, /* USB Device Class Definition for Human Interface Devices (HID). Note: the usage type for all key codes is Selector (Sel). */ + kHIDPage_LEDs = 0x08, + kHIDPage_Button = 0x09, + kHIDPage_Ordinal = 0x0A, + kHIDPage_Telephony = 0x0B, + kHIDPage_Consumer = 0x0C, + kHIDPage_Digitizer = 0x0D, + /* Reserved 0x0E */ + kHIDPage_PID = 0x0F, /* USB Physical Interface Device definitions for force feedback and related devices. */ + kHIDPage_Unicode = 0x10, + /* Reserved 0x11 - 0x13 */ + kHIDPage_AlphanumericDisplay = 0x14, + /* Reserved 0x15 - 0x7F */ + /* Monitor 0x80 - 0x83 USB Device Class Definition for Monitor Devices */ + /* Power 0x84 - 0x87 USB Device Class Definition for Power Devices */ + kHIDPage_PowerDevice = 0x84, /* Power Device Page */ + kHIDPage_BatterySystem = 0x85, /* Battery System Page */ + /* Reserved 0x88 - 0x8B */ + kHIDPage_BarCodeScanner = 0x8C, /* (Point of Sale) USB Device Class Definition for Bar Code Scanner Devices */ + kHIDPage_WeighingDevice = 0x8D, /* (Point of Sale) USB Device Class Definition for Weighing Devices */ + kHIDPage_Scale = 0x8D, /* (Point of Sale) USB Device Class Definition for Scale Devices */ + kHIDPage_MagneticStripeReader = 0x8E, + /* ReservedPointofSalepages 0x8F */ + kHIDPage_CameraControl = 0x90, /* USB Device Class Definition for Image Class Devices */ + kHIDPage_Arcade = 0x91, /* OAAF Definitions for arcade and coinop related Devices */ + /* Reserved 0x92 - 0xFEFF */ + /* VendorDefined 0xFF00 - 0xFFFF */ + kHIDPage_VendorDefinedStart = 0xFF00 +}; + +/* Undefined Usage for all usage pages */ +enum +{ + kHIDUsage_Undefined = 0x00 +}; + +/* GenericDesktop Page (0x01) */ +enum +{ + kHIDUsage_GD_Pointer = 0x01, /* Physical Collection */ + kHIDUsage_GD_Mouse = 0x02, /* Application Collection */ + /* 0x03 Reserved */ + kHIDUsage_GD_Joystick = 0x04, /* Application Collection */ + kHIDUsage_GD_GamePad = 0x05, /* Application Collection */ + kHIDUsage_GD_Keyboard = 0x06, /* Application Collection */ + kHIDUsage_GD_Keypad = 0x07, /* Application Collection */ + kHIDUsage_GD_MultiAxisController = 0x08, /* Application Collection */ + /* 0x09 - 0x2F Reserved */ + kHIDUsage_GD_X = 0x30, /* Dynamic Value */ + kHIDUsage_GD_Y = 0x31, /* Dynamic Value */ + kHIDUsage_GD_Z = 0x32, /* Dynamic Value */ + kHIDUsage_GD_Rx = 0x33, /* Dynamic Value */ + kHIDUsage_GD_Ry = 0x34, /* Dynamic Value */ + kHIDUsage_GD_Rz = 0x35, /* Dynamic Value */ + kHIDUsage_GD_Slider = 0x36, /* Dynamic Value */ + kHIDUsage_GD_Dial = 0x37, /* Dynamic Value */ + kHIDUsage_GD_Wheel = 0x38, /* Dynamic Value */ + kHIDUsage_GD_Hatswitch = 0x39, /* Dynamic Value */ + kHIDUsage_GD_CountedBuffer = 0x3A, /* Logical Collection */ + kHIDUsage_GD_ByteCount = 0x3B, /* Dynamic Value */ + kHIDUsage_GD_MotionWakeup = 0x3C, /* One-Shot Control */ + kHIDUsage_GD_Start = 0x3D, /* On/Off Control */ + kHIDUsage_GD_Select = 0x3E, /* On/Off Control */ + /* 0x3F Reserved */ + kHIDUsage_GD_Vx = 0x40, /* Dynamic Value */ + kHIDUsage_GD_Vy = 0x41, /* Dynamic Value */ + kHIDUsage_GD_Vz = 0x42, /* Dynamic Value */ + kHIDUsage_GD_Vbrx = 0x43, /* Dynamic Value */ + kHIDUsage_GD_Vbry = 0x44, /* Dynamic Value */ + kHIDUsage_GD_Vbrz = 0x45, /* Dynamic Value */ + kHIDUsage_GD_Vno = 0x46, /* Dynamic Value */ + /* 0x47 - 0x7F Reserved */ + kHIDUsage_GD_SystemControl = 0x80, /* Application Collection */ + kHIDUsage_GD_SystemPowerDown = 0x81, /* One-Shot Control */ + kHIDUsage_GD_SystemSleep = 0x82, /* One-Shot Control */ + kHIDUsage_GD_SystemWakeUp = 0x83, /* One-Shot Control */ + kHIDUsage_GD_SystemContextMenu = 0x84, /* One-Shot Control */ + kHIDUsage_GD_SystemMainMenu = 0x85, /* One-Shot Control */ + kHIDUsage_GD_SystemAppMenu = 0x86, /* One-Shot Control */ + kHIDUsage_GD_SystemMenuHelp = 0x87, /* One-Shot Control */ + kHIDUsage_GD_SystemMenuExit = 0x88, /* One-Shot Control */ + kHIDUsage_GD_SystemMenu = 0x89, /* Selector */ + kHIDUsage_GD_SystemMenuRight = 0x8A, /* Re-Trigger Control */ + kHIDUsage_GD_SystemMenuLeft = 0x8B, /* Re-Trigger Control */ + kHIDUsage_GD_SystemMenuUp = 0x8C, /* Re-Trigger Control */ + kHIDUsage_GD_SystemMenuDown = 0x8D, /* Re-Trigger Control */ + /* 0x8E - 0x8F Reserved */ + kHIDUsage_GD_DPadUp = 0x90, /* On/Off Control */ + kHIDUsage_GD_DPadDown = 0x91, /* On/Off Control */ + kHIDUsage_GD_DPadRight = 0x92, /* On/Off Control */ + kHIDUsage_GD_DPadLeft = 0x93, /* On/Off Control */ + /* 0x94 - 0xFFFF Reserved */ + kHIDUsage_GD_Reserved = 0xFFFF +}; + +/* Simulation Page (0x02) */ +/* This section provides detailed descriptions of the usages employed by simulation devices. */ +enum +{ + kHIDUsage_Sim_FlightSimulationDevice = 0x01, /* Application Collection */ + kHIDUsage_Sim_AutomobileSimulationDevice = 0x02, /* Application Collection */ + kHIDUsage_Sim_TankSimulationDevice = 0x03, /* Application Collection */ + kHIDUsage_Sim_SpaceshipSimulationDevice = 0x04, /* Application Collection */ + kHIDUsage_Sim_SubmarineSimulationDevice = 0x05, /* Application Collection */ + kHIDUsage_Sim_SailingSimulationDevice = 0x06, /* Application Collection */ + kHIDUsage_Sim_MotorcycleSimulationDevice = 0x07, /* Application Collection */ + kHIDUsage_Sim_SportsSimulationDevice = 0x08, /* Application Collection */ + kHIDUsage_Sim_AirplaneSimulationDevice = 0x09, /* Application Collection */ + kHIDUsage_Sim_HelicopterSimulationDevice = 0x0A, /* Application Collection */ + kHIDUsage_Sim_MagicCarpetSimulationDevice = 0x0B, /* Application Collection */ + kHIDUsage_Sim_BicycleSimulationDevice = 0x0C, /* Application Collection */ + /* 0x0D - 0x1F Reserved */ + kHIDUsage_Sim_FlightControlStick = 0x20, /* Application Collection */ + kHIDUsage_Sim_FlightStick = 0x21, /* Application Collection */ + kHIDUsage_Sim_CyclicControl = 0x22, /* Physical Collection */ + kHIDUsage_Sim_CyclicTrim = 0x23, /* Physical Collection */ + kHIDUsage_Sim_FlightYoke = 0x24, /* Application Collection */ + kHIDUsage_Sim_TrackControl = 0x25, /* Physical Collection */ + /* 0x26 - 0xAF Reserved */ + kHIDUsage_Sim_Aileron = 0xB0, /* Dynamic Value */ + kHIDUsage_Sim_AileronTrim = 0xB1, /* Dynamic Value */ + kHIDUsage_Sim_AntiTorqueControl = 0xB2, /* Dynamic Value */ + kHIDUsage_Sim_AutopilotEnable = 0xB3, /* On/Off Control */ + kHIDUsage_Sim_ChaffRelease = 0xB4, /* One-Shot Control */ + kHIDUsage_Sim_CollectiveControl = 0xB5, /* Dynamic Value */ + kHIDUsage_Sim_DiveBrake = 0xB6, /* Dynamic Value */ + kHIDUsage_Sim_ElectronicCountermeasures = 0xB7, /* On/Off Control */ + kHIDUsage_Sim_Elevator = 0xB8, /* Dynamic Value */ + kHIDUsage_Sim_ElevatorTrim = 0xB9, /* Dynamic Value */ + kHIDUsage_Sim_Rudder = 0xBA, /* Dynamic Value */ + kHIDUsage_Sim_Throttle = 0xBB, /* Dynamic Value */ + kHIDUsage_Sim_FlightCommunications = 0xBC, /* On/Off Control */ + kHIDUsage_Sim_FlareRelease = 0xBD, /* One-Shot Control */ + kHIDUsage_Sim_LandingGear = 0xBE, /* On/Off Control */ + kHIDUsage_Sim_ToeBrake = 0xBF, /* Dynamic Value */ + kHIDUsage_Sim_Trigger = 0xC0, /* Momentary Control */ + kHIDUsage_Sim_WeaponsArm = 0xC1, /* On/Off Control */ + kHIDUsage_Sim_Weapons = 0xC2, /* Selector */ + kHIDUsage_Sim_WingFlaps = 0xC3, /* Dynamic Value */ + kHIDUsage_Sim_Accelerator = 0xC4, /* Dynamic Value */ + kHIDUsage_Sim_Brake = 0xC5, /* Dynamic Value */ + kHIDUsage_Sim_Clutch = 0xC6, /* Dynamic Value */ + kHIDUsage_Sim_Shifter = 0xC7, /* Dynamic Value */ + kHIDUsage_Sim_Steering = 0xC8, /* Dynamic Value */ + kHIDUsage_Sim_TurretDirection = 0xC9, /* Dynamic Value */ + kHIDUsage_Sim_BarrelElevation = 0xCA, /* Dynamic Value */ + kHIDUsage_Sim_DivePlane = 0xCB, /* Dynamic Value */ + kHIDUsage_Sim_Ballast = 0xCC, /* Dynamic Value */ + kHIDUsage_Sim_BicycleCrank = 0xCD, /* Dynamic Value */ + kHIDUsage_Sim_HandleBars = 0xCE, /* Dynamic Value */ + kHIDUsage_Sim_FrontBrake = 0xCF, /* Dynamic Value */ + kHIDUsage_Sim_RearBrake = 0xD0, /* Dynamic Value */ + /* 0xD1 - 0xFFFF Reserved */ + kHIDUsage_Sim_Reserved = 0xFFFF +}; + +/* VR Page (0x03) */ +/* Virtual Reality controls depend on designators to identify the individual controls. Most of the following are */ +/* usages are applied to the collections of entities that comprise the actual device. */ +enum +{ + kHIDUsage_VR_Belt = 0x01, /* Application Collection */ + kHIDUsage_VR_BodySuit = 0x02, /* Application Collection */ + kHIDUsage_VR_Flexor = 0x03, /* Physical Collection */ + kHIDUsage_VR_Glove = 0x04, /* Application Collection */ + kHIDUsage_VR_HeadTracker = 0x05, /* Physical Collection */ + kHIDUsage_VR_HeadMountedDisplay = 0x06, /* Application Collection */ + kHIDUsage_VR_HandTracker = 0x07, /* Application Collection */ + kHIDUsage_VR_Oculometer = 0x08, /* Application Collection */ + kHIDUsage_VR_Vest = 0x09, /* Application Collection */ + kHIDUsage_VR_AnimatronicDevice = 0x0A, /* Application Collection */ + /* 0x0B - 0x1F Reserved */ + kHIDUsage_VR_StereoEnable = 0x20, /* On/Off Control */ + kHIDUsage_VR_DisplayEnable = 0x21, /* On/Off Control */ + /* 0x22 - 0xFFFF Reserved */ + kHIDUsage_VR_Reserved = 0xFFFF +}; + +/* Sport Page (0x04) */ +enum +{ + kHIDUsage_Sprt_BaseballBat = 0x01, /* Application Collection */ + kHIDUsage_Sprt_GolfClub = 0x02, /* Application Collection */ + kHIDUsage_Sprt_RowingMachine = 0x03, /* Application Collection */ + kHIDUsage_Sprt_Treadmill = 0x04, /* Application Collection */ + /* 0x05 - 0x2F Reserved */ + kHIDUsage_Sprt_Oar = 0x30, /* Dynamic Value */ + kHIDUsage_Sprt_Slope = 0x31, /* Dynamic Value */ + kHIDUsage_Sprt_Rate = 0x32, /* Dynamic Value */ + kHIDUsage_Sprt_StickSpeed = 0x33, /* Dynamic Value */ + kHIDUsage_Sprt_StickFaceAngle = 0x34, /* Dynamic Value */ + kHIDUsage_Sprt_StickHeelOrToe = 0x35, /* Dynamic Value */ + kHIDUsage_Sprt_StickFollowThrough = 0x36, /* Dynamic Value */ + kHIDUsage_Sprt_StickTempo = 0x37, /* Dynamic Value */ + kHIDUsage_Sprt_StickType = 0x38, /* Named Array */ + kHIDUsage_Sprt_StickHeight = 0x39, /* Dynamic Value */ + /* 0x3A - 0x4F Reserved */ + kHIDUsage_Sprt_Putter = 0x50, /* Selector */ + kHIDUsage_Sprt_1Iron = 0x51, /* Selector */ + kHIDUsage_Sprt_2Iron = 0x52, /* Selector */ + kHIDUsage_Sprt_3Iron = 0x53, /* Selector */ + kHIDUsage_Sprt_4Iron = 0x54, /* Selector */ + kHIDUsage_Sprt_5Iron = 0x55, /* Selector */ + kHIDUsage_Sprt_6Iron = 0x56, /* Selector */ + kHIDUsage_Sprt_7Iron = 0x57, /* Selector */ + kHIDUsage_Sprt_8Iron = 0x58, /* Selector */ + kHIDUsage_Sprt_9Iron = 0x59, /* Selector */ + kHIDUsage_Sprt_10Iron = 0x5A, /* Selector */ + kHIDUsage_Sprt_11Iron = 0x5B, /* Selector */ + kHIDUsage_Sprt_SandWedge = 0x5C, /* Selector */ + kHIDUsage_Sprt_LoftWedge = 0x5D, /* Selector */ + kHIDUsage_Sprt_PowerWedge = 0x5E, /* Selector */ + kHIDUsage_Sprt_1Wood = 0x5F, /* Selector */ + kHIDUsage_Sprt_3Wood = 0x60, /* Selector */ + kHIDUsage_Sprt_5Wood = 0x61, /* Selector */ + kHIDUsage_Sprt_7Wood = 0x62, /* Selector */ + kHIDUsage_Sprt_9Wood = 0x63, /* Selector */ + /* 0x64 - 0xFFFF Reserved */ + kHIDUsage_Sprt_Reserved = 0xFFFF +}; + +/* Game Page (0x05) */ +enum +{ + kHIDUsage_Game_3DGameController = 0x01, /* Application Collection */ + kHIDUsage_Game_PinballDevice = 0x02, /* Application Collection */ + kHIDUsage_Game_GunDevice = 0x03, /* Application Collection */ + /* 0x04 - 0x1F Reserved */ + kHIDUsage_Game_PointofView = 0x20, /* Physical Collection */ + kHIDUsage_Game_TurnRightOrLeft = 0x21, /* Dynamic Value */ + kHIDUsage_Game_PitchUpOrDown = 0x22, /* Dynamic Value */ + kHIDUsage_Game_RollRightOrLeft = 0x23, /* Dynamic Value */ + kHIDUsage_Game_MoveRightOrLeft = 0x24, /* Dynamic Value */ + kHIDUsage_Game_MoveForwardOrBackward = 0x25, /* Dynamic Value */ + kHIDUsage_Game_MoveUpOrDown = 0x26, /* Dynamic Value */ + kHIDUsage_Game_LeanRightOrLeft = 0x27, /* Dynamic Value */ + kHIDUsage_Game_LeanForwardOrBackward = 0x28, /* Dynamic Value */ + kHIDUsage_Game_HeightOfPOV = 0x29, /* Dynamic Value */ + kHIDUsage_Game_Flipper = 0x2A, /* Momentary Control */ + kHIDUsage_Game_SecondaryFlipper = 0x2B, /* Momentary Control */ + kHIDUsage_Game_Bump = 0x2C, /* Momentary Control */ + kHIDUsage_Game_NewGame = 0x2D, /* One-Shot Control */ + kHIDUsage_Game_ShootBall = 0x2E, /* One-Shot Control */ + kHIDUsage_Game_Player = 0x2F, /* One-Shot Control */ + kHIDUsage_Game_GunBolt = 0x30, /* On/Off Control */ + kHIDUsage_Game_GunClip = 0x31, /* On/Off Control */ + kHIDUsage_Game_Gun = 0x32, /* Selector */ + kHIDUsage_Game_GunSingleShot = 0x33, /* Selector */ + kHIDUsage_Game_GunBurst = 0x34, /* Selector */ + kHIDUsage_Game_GunAutomatic = 0x35, /* Selector */ + kHIDUsage_Game_GunSafety = 0x36, /* On/Off Control */ + kHIDUsage_Game_GamepadFireOrJump = 0x37, /* Logical Collection */ + kHIDUsage_Game_GamepadTrigger = 0x39, /* Logical Collection */ + /* 0x3A - 0xFFFF Reserved */ + kHIDUsage_Game_Reserved = 0xFFFF +}; + +/* KeyboardOrKeypad Page (0x07) */ +/* This section is the Usage Page for key codes to be used in implementing a USB keyboard. A Boot Keyboard (84-, 101- or 104-key) should at a minimum support all associated usage codes as indicated in the ÒBootÓ */ +/* column below. */ +/* The usage type of all key codes is Selectors (Sel), except for the modifier keys Keyboard Left Control (0x224) to Keyboard Right GUI (0x231) which are Dynamic Flags (DV). */ +/* Note: A general note on Usages and languages: Due to the variation of keyboards from language to language, it is not feasible to specify exact key mappings for every language. Where this list is not specific for a key function in a language, the closest equivalent key position should be used, so that a keyboard may be modified for a different language by simply printing different keycaps. One example is the Y key on a North American keyboard. In Germany this is typically Z. Rather than changing the keyboard firmware to put the Z Usage into that place in the descriptor list, the vendor should use the Y Usage on both the North American and German keyboards. This continues to be the existing practice in the industry, in order to minimize the number of changes to the electronics to accommodate otherlanguages. */ +enum +{ + kHIDUsage_KeyboardErrorRollOver = 0x01, /* ErrorRollOver */ + kHIDUsage_KeyboardPOSTFail = 0x02, /* POSTFail */ + kHIDUsage_KeyboardErrorUndefined = 0x03, /* ErrorUndefined */ + kHIDUsage_KeyboardA = 0x04, /* a or A */ + kHIDUsage_KeyboardB = 0x05, /* b or B */ + kHIDUsage_KeyboardC = 0x06, /* c or C */ + kHIDUsage_KeyboardD = 0x07, /* d or D */ + kHIDUsage_KeyboardE = 0x08, /* e or E */ + kHIDUsage_KeyboardF = 0x09, /* f or F */ + kHIDUsage_KeyboardG = 0x0A, /* g or G */ + kHIDUsage_KeyboardH = 0x0B, /* h or H */ + kHIDUsage_KeyboardI = 0x0C, /* i or I */ + kHIDUsage_KeyboardJ = 0x0D, /* j or J */ + kHIDUsage_KeyboardK = 0x0E, /* k or K */ + kHIDUsage_KeyboardL = 0x0F, /* l or L */ + kHIDUsage_KeyboardM = 0x10, /* m or M */ + kHIDUsage_KeyboardN = 0x11, /* n or N */ + kHIDUsage_KeyboardO = 0x12, /* o or O */ + kHIDUsage_KeyboardP = 0x13, /* p or P */ + kHIDUsage_KeyboardQ = 0x14, /* q or Q */ + kHIDUsage_KeyboardR = 0x15, /* r or R */ + kHIDUsage_KeyboardS = 0x16, /* s or S */ + kHIDUsage_KeyboardT = 0x17, /* t or T */ + kHIDUsage_KeyboardU = 0x18, /* u or U */ + kHIDUsage_KeyboardV = 0x19, /* v or V */ + kHIDUsage_KeyboardW = 0x1A, /* w or W */ + kHIDUsage_KeyboardX = 0x1B, /* x or X */ + kHIDUsage_KeyboardY = 0x1C, /* y or Y */ + kHIDUsage_KeyboardZ = 0x1D, /* z or Z */ + kHIDUsage_Keyboard1 = 0x1E, /* 1 or ! */ + kHIDUsage_Keyboard2 = 0x1F, /* 2 or @ */ + kHIDUsage_Keyboard3 = 0x20, /* 3 or # */ + kHIDUsage_Keyboard4 = 0x21, /* 4 or $ */ + kHIDUsage_Keyboard5 = 0x22, /* 5 or % */ + kHIDUsage_Keyboard6 = 0x23, /* 6 or ^ */ + kHIDUsage_Keyboard7 = 0x24, /* 7 or & */ + kHIDUsage_Keyboard8 = 0x25, /* 8 or * */ + kHIDUsage_Keyboard9 = 0x26, /* 9 or ( */ + kHIDUsage_Keyboard0 = 0x27, /* 0 or ) */ + kHIDUsage_KeyboardReturnOrEnter = 0x28, /* Return (Enter) */ + kHIDUsage_KeyboardEscape = 0x29, /* Escape */ + kHIDUsage_KeyboardDeleteOrBackspace = 0x2A, /* Delete (Backspace) */ + kHIDUsage_KeyboardTab = 0x2B, /* Tab */ + kHIDUsage_KeyboardSpacebar = 0x2C, /* Spacebar */ + kHIDUsage_KeyboardHyphen = 0x2D, /* - or _ */ + kHIDUsage_KeyboardEqualSign = 0x2E, /* = or + */ + kHIDUsage_KeyboardOpenBracket = 0x2F, /* [ or { */ + kHIDUsage_KeyboardCloseBracket = 0x30, /* ] or } */ + kHIDUsage_KeyboardBackslash = 0x31, /* \ or | */ + kHIDUsage_KeyboardNonUSPound = 0x32, /* Non-US # or _ */ + kHIDUsage_KeyboardSemicolon = 0x33, /* ; or : */ + kHIDUsage_KeyboardQuote = 0x34, /* ' or " */ + kHIDUsage_KeyboardGraveAccentAndTilde = 0x35, /* Grave Accent and Tilde */ + kHIDUsage_KeyboardComma = 0x36, /* , or < */ + kHIDUsage_KeyboardPeriod = 0x37, /* . or > */ + kHIDUsage_KeyboardSlash = 0x38, /* / or ? */ + kHIDUsage_KeyboardCapsLock = 0x39, /* Caps Lock */ + kHIDUsage_KeyboardF1 = 0x3A, /* F1 */ + kHIDUsage_KeyboardF2 = 0x3B, /* F2 */ + kHIDUsage_KeyboardF3 = 0x3C, /* F3 */ + kHIDUsage_KeyboardF4 = 0x3D, /* F4 */ + kHIDUsage_KeyboardF5 = 0x3E, /* F5 */ + kHIDUsage_KeyboardF6 = 0x3F, /* F6 */ + kHIDUsage_KeyboardF7 = 0x40, /* F7 */ + kHIDUsage_KeyboardF8 = 0x41, /* F8 */ + kHIDUsage_KeyboardF9 = 0x42, /* F9 */ + kHIDUsage_KeyboardF10 = 0x43, /* F10 */ + kHIDUsage_KeyboardF11 = 0x44, /* F11 */ + kHIDUsage_KeyboardF12 = 0x45, /* F12 */ + kHIDUsage_KeyboardPrintScreen = 0x46, /* Print Screen */ + kHIDUsage_KeyboardScrollLock = 0x47, /* Scroll Lock */ + kHIDUsage_KeyboardPause = 0x48, /* Pause */ + kHIDUsage_KeyboardInsert = 0x49, /* Insert */ + kHIDUsage_KeyboardHome = 0x4A, /* Home */ + kHIDUsage_KeyboardPageUp = 0x4B, /* Page Up */ + kHIDUsage_KeyboardDeleteForward = 0x4C, /* Delete Forward */ + kHIDUsage_KeyboardEnd = 0x4D, /* End */ + kHIDUsage_KeyboardPageDown = 0x4E, /* Page Down */ + kHIDUsage_KeyboardRightArrow = 0x4F, /* Right Arrow */ + kHIDUsage_KeyboardLeftArrow = 0x50, /* Left Arrow */ + kHIDUsage_KeyboardDownArrow = 0x51, /* Down Arrow */ + kHIDUsage_KeyboardUpArrow = 0x52, /* Up Arrow */ + kHIDUsage_KeypadNumLock = 0x53, /* Keypad NumLock or Clear */ + kHIDUsage_KeypadSlash = 0x54, /* Keypad / */ + kHIDUsage_KeypadAsterisk = 0x55, /* Keypad * */ + kHIDUsage_KeypadHyphen = 0x56, /* Keypad - */ + kHIDUsage_KeypadPlus = 0x57, /* Keypad + */ + kHIDUsage_KeypadEnter = 0x58, /* Keypad Enter */ + kHIDUsage_Keypad1 = 0x59, /* Keypad 1 or End */ + kHIDUsage_Keypad2 = 0x5A, /* Keypad 2 or Down Arrow */ + kHIDUsage_Keypad3 = 0x5B, /* Keypad 3 or Page Down */ + kHIDUsage_Keypad4 = 0x5C, /* Keypad 4 or Left Arrow */ + kHIDUsage_Keypad5 = 0x5D, /* Keypad 5 */ + kHIDUsage_Keypad6 = 0x5E, /* Keypad 6 or Right Arrow */ + kHIDUsage_Keypad7 = 0x5F, /* Keypad 7 or Home */ + kHIDUsage_Keypad8 = 0x60, /* Keypad 8 or Up Arrow */ + kHIDUsage_Keypad9 = 0x61, /* Keypad 9 or Page Up */ + kHIDUsage_Keypad0 = 0x62, /* Keypad 0 or Insert */ + kHIDUsage_KeypadPeriod = 0x63, /* Keypad . or Delete */ + kHIDUsage_KeyboardNonUSBackslash = 0x64, /* Non-US \ or | */ + kHIDUsage_KeyboardApplication = 0x65, /* Application */ + kHIDUsage_KeyboardPower = 0x66, /* Power */ + kHIDUsage_KeypadEqualSign = 0x67, /* Keypad = */ + kHIDUsage_KeyboardF13 = 0x68, /* F13 */ + kHIDUsage_KeyboardF14 = 0x69, /* F14 */ + kHIDUsage_KeyboardF15 = 0x6A, /* F15 */ + kHIDUsage_KeyboardF16 = 0x6B, /* F16 */ + kHIDUsage_KeyboardF17 = 0x6C, /* F17 */ + kHIDUsage_KeyboardF18 = 0x6D, /* F18 */ + kHIDUsage_KeyboardF19 = 0x6E, /* F19 */ + kHIDUsage_KeyboardF20 = 0x6F, /* F20 */ + kHIDUsage_KeyboardF21 = 0x70, /* F21 */ + kHIDUsage_KeyboardF22 = 0x71, /* F22 */ + kHIDUsage_KeyboardF23 = 0x72, /* F23 */ + kHIDUsage_KeyboardF24 = 0x73, /* F24 */ + kHIDUsage_KeyboardExecute = 0x74, /* Execute */ + kHIDUsage_KeyboardHelp = 0x75, /* Help */ + kHIDUsage_KeyboardMenu = 0x76, /* Menu */ + kHIDUsage_KeyboardSelect = 0x77, /* Select */ + kHIDUsage_KeyboardStop = 0x78, /* Stop */ + kHIDUsage_KeyboardAgain = 0x79, /* Again */ + kHIDUsage_KeyboardUndo = 0x7A, /* Undo */ + kHIDUsage_KeyboardCut = 0x7B, /* Cut */ + kHIDUsage_KeyboardCopy = 0x7C, /* Copy */ + kHIDUsage_KeyboardPaste = 0x7D, /* Paste */ + kHIDUsage_KeyboardFind = 0x7E, /* Find */ + kHIDUsage_KeyboardMute = 0x7F, /* Mute */ + kHIDUsage_KeyboardVolumeUp = 0x80, /* Volume Up */ + kHIDUsage_KeyboardVolumeDown = 0x81, /* Volume Down */ + kHIDUsage_KeyboardLockingCapsLock = 0x82, /* Locking Caps Lock */ + kHIDUsage_KeyboardLockingNumLock = 0x83, /* Locking Num Lock */ + kHIDUsage_KeyboardLockingScrollLock = 0x84, /* Locking Scroll Lock */ + kHIDUsage_KeypadComma = 0x85, /* Keypad Comma */ + kHIDUsage_KeypadEqualSignAS400 = 0x86, /* Keypad Equal Sign for AS/400 */ + kHIDUsage_KeyboardInternational1 = 0x87, /* International1 */ + kHIDUsage_KeyboardInternational2 = 0x88, /* International2 */ + kHIDUsage_KeyboardInternational3 = 0x89, /* International3 */ + kHIDUsage_KeyboardInternational4 = 0x8A, /* International4 */ + kHIDUsage_KeyboardInternational5 = 0x8B, /* International5 */ + kHIDUsage_KeyboardInternational6 = 0x8C, /* International6 */ + kHIDUsage_KeyboardInternational7 = 0x8D, /* International7 */ + kHIDUsage_KeyboardInternational8 = 0x8E, /* International8 */ + kHIDUsage_KeyboardInternational9 = 0x8F, /* International9 */ + kHIDUsage_KeyboardLANG1 = 0x90, /* LANG1 */ + kHIDUsage_KeyboardLANG2 = 0x91, /* LANG2 */ + kHIDUsage_KeyboardLANG3 = 0x92, /* LANG3 */ + kHIDUsage_KeyboardLANG4 = 0x93, /* LANG4 */ + kHIDUsage_KeyboardLANG5 = 0x94, /* LANG5 */ + kHIDUsage_KeyboardLANG6 = 0x95, /* LANG6 */ + kHIDUsage_KeyboardLANG7 = 0x96, /* LANG7 */ + kHIDUsage_KeyboardLANG8 = 0x97, /* LANG8 */ + kHIDUsage_KeyboardLANG9 = 0x98, /* LANG9 */ + kHIDUsage_KeyboardAlternateErase = 0x99, /* AlternateErase */ + kHIDUsage_KeyboardSysReqOrAttention = 0x9A, /* SysReq/Attention */ + kHIDUsage_KeyboardCancel = 0x9B, /* Cancel */ + kHIDUsage_KeyboardClear = 0x9C, /* Clear */ + kHIDUsage_KeyboardPrior = 0x9D, /* Prior */ + kHIDUsage_KeyboardReturn = 0x9E, /* Return */ + kHIDUsage_KeyboardSeparator = 0x9F, /* Separator */ + kHIDUsage_KeyboardOut = 0xA0, /* Out */ + kHIDUsage_KeyboardOper = 0xA1, /* Oper */ + kHIDUsage_KeyboardClearOrAgain = 0xA2, /* Clear/Again */ + kHIDUsage_KeyboardCrSelOrProps = 0xA3, /* CrSel/Props */ + kHIDUsage_KeyboardExSel = 0xA4, /* ExSel */ + /* 0xA5-0xDF Reserved */ + kHIDUsage_KeyboardLeftControl = 0xE0, /* Left Control */ + kHIDUsage_KeyboardLeftShift = 0xE1, /* Left Shift */ + kHIDUsage_KeyboardLeftAlt = 0xE2, /* Left Alt */ + kHIDUsage_KeyboardLeftGUI = 0xE3, /* Left GUI */ + kHIDUsage_KeyboardRightControl = 0xE4, /* Right Control */ + kHIDUsage_KeyboardRightShift = 0xE5, /* Right Shift */ + kHIDUsage_KeyboardRightAlt = 0xE6, /* Right Alt */ + kHIDUsage_KeyboardRightGUI = 0xE7, /* Right GUI */ + /* 0xE8-0xFFFF Reserved */ + kHIDUsage_Keyboard_Reserved = 0xFFFF +}; + +/* LEDs Page (0x08) */ +/* An LED or indicator is implemented as an On/Off Control (OOF) using the ÒSingle button toggleÓ mode, where a value of 1 will turn on the indicator, and a value of 0 will turn it off. The exceptions are described below. */ +enum +{ + kHIDUsage_LED_NumLock = 0x01, /* On/Off Control */ + kHIDUsage_LED_CapsLock = 0x02, /* On/Off Control */ + kHIDUsage_LED_ScrollLock = 0x03, /* On/Off Control */ + kHIDUsage_LED_Compose = 0x04, /* On/Off Control */ + kHIDUsage_LED_Kana = 0x05, /* On/Off Control */ + kHIDUsage_LED_Power = 0x06, /* On/Off Control */ + kHIDUsage_LED_Shift = 0x07, /* On/Off Control */ + kHIDUsage_LED_DoNotDisturb = 0x08, /* On/Off Control */ + kHIDUsage_LED_Mute = 0x09, /* On/Off Control */ + kHIDUsage_LED_ToneEnable = 0x0A, /* On/Off Control */ + kHIDUsage_LED_HighCutFilter = 0x0B, /* On/Off Control */ + kHIDUsage_LED_LowCutFilter = 0x0C, /* On/Off Control */ + kHIDUsage_LED_EqualizerEnable = 0x0D, /* On/Off Control */ + kHIDUsage_LED_SoundFieldOn = 0x0E, /* On/Off Control */ + kHIDUsage_LED_SurroundOn = 0x0F, /* On/Off Control */ + kHIDUsage_LED_Repeat = 0x10, /* On/Off Control */ + kHIDUsage_LED_Stereo = 0x11, /* On/Off Control */ + kHIDUsage_LED_SamplingRateDetect = 0x12, /* On/Off Control */ + kHIDUsage_LED_Spinning = 0x13, /* On/Off Control */ + kHIDUsage_LED_CAV = 0x14, /* On/Off Control */ + kHIDUsage_LED_CLV = 0x15, /* On/Off Control */ + kHIDUsage_LED_RecordingFormatDetect = 0x16, /* On/Off Control */ + kHIDUsage_LED_OffHook = 0x17, /* On/Off Control */ + kHIDUsage_LED_Ring = 0x18, /* On/Off Control */ + kHIDUsage_LED_MessageWaiting = 0x19, /* On/Off Control */ + kHIDUsage_LED_DataMode = 0x1A, /* On/Off Control */ + kHIDUsage_LED_BatteryOperation = 0x1B, /* On/Off Control */ + kHIDUsage_LED_BatteryOK = 0x1C, /* On/Off Control */ + kHIDUsage_LED_BatteryLow = 0x1D, /* On/Off Control */ + kHIDUsage_LED_Speaker = 0x1E, /* On/Off Control */ + kHIDUsage_LED_HeadSet = 0x1F, /* On/Off Control */ + kHIDUsage_LED_Hold = 0x20, /* On/Off Control */ + kHIDUsage_LED_Microphone = 0x21, /* On/Off Control */ + kHIDUsage_LED_Coverage = 0x22, /* On/Off Control */ + kHIDUsage_LED_NightMode = 0x23, /* On/Off Control */ + kHIDUsage_LED_SendCalls = 0x24, /* On/Off Control */ + kHIDUsage_LED_CallPickup = 0x25, /* On/Off Control */ + kHIDUsage_LED_Conference = 0x26, /* On/Off Control */ + kHIDUsage_LED_StandBy = 0x27, /* On/Off Control */ + kHIDUsage_LED_CameraOn = 0x28, /* On/Off Control */ + kHIDUsage_LED_CameraOff = 0x29, /* On/Off Control */ + kHIDUsage_LED_OnLine = 0x2A, /* On/Off Control */ + kHIDUsage_LED_OffLine = 0x2B, /* On/Off Control */ + kHIDUsage_LED_Busy = 0x2C, /* On/Off Control */ + kHIDUsage_LED_Ready = 0x2D, /* On/Off Control */ + kHIDUsage_LED_PaperOut = 0x2E, /* On/Off Control */ + kHIDUsage_LED_PaperJam = 0x2F, /* On/Off Control */ + kHIDUsage_LED_Remote = 0x30, /* On/Off Control */ + kHIDUsage_LED_Forward = 0x31, /* On/Off Control */ + kHIDUsage_LED_Reverse = 0x32, /* On/Off Control */ + kHIDUsage_LED_Stop = 0x33, /* On/Off Control */ + kHIDUsage_LED_Rewind = 0x34, /* On/Off Control */ + kHIDUsage_LED_FastForward = 0x35, /* On/Off Control */ + kHIDUsage_LED_Play = 0x36, /* On/Off Control */ + kHIDUsage_LED_Pause = 0x37, /* On/Off Control */ + kHIDUsage_LED_Record = 0x38, /* On/Off Control */ + kHIDUsage_LED_Error = 0x39, /* On/Off Control */ + kHIDUsage_LED_Usage = 0x3A, /* Selector */ + kHIDUsage_LED_UsageInUseIndicator = 0x3B, /* Usage Switch */ + kHIDUsage_LED_UsageMultiModeIndicator = 0x3C, /* Usage Modifier */ + kHIDUsage_LED_IndicatorOn = 0x3D, /* Selector */ + kHIDUsage_LED_IndicatorFlash = 0x3E, /* Selector */ + kHIDUsage_LED_IndicatorSlowBlink = 0x3F, /* Selector */ + kHIDUsage_LED_IndicatorFastBlink = 0x40, /* Selector */ + kHIDUsage_LED_IndicatorOff = 0x41, /* Selector */ + kHIDUsage_LED_FlashOnTime = 0x42, /* Dynamic Value */ + kHIDUsage_LED_SlowBlinkOnTime = 0x43, /* Dynamic Value */ + kHIDUsage_LED_SlowBlinkOffTime = 0x44, /* Dynamic Value */ + kHIDUsage_LED_FastBlinkOnTime = 0x45, /* Dynamic Value */ + kHIDUsage_LED_FastBlinkOffTime = 0x46, /* Dynamic Value */ + kHIDUsage_LED_UsageIndicatorColor = 0x47, /* Usage Modifier */ + kHIDUsage_LED_IndicatorRed = 0x48, /* Selector */ + kHIDUsage_LED_IndicatorGreen = 0x49, /* Selector */ + kHIDUsage_LED_IndicatorAmber = 0x4A, /* Selector */ + kHIDUsage_LED_GenericIndicator = 0x4B, /* On/Off Control */ + kHIDUsage_LED_SystemSuspend = 0x4C, /* On/Off Control */ + kHIDUsage_LED_ExternalPowerConnected = 0x4D, /* On/Off Control */ + /* 0x4E - 0xFFFF Reserved */ + kHIDUsage_LED_Reserved = 0xFFFF +}; + +/* Button Page (0x09) */ +/* The Button page is the first place an application should look for user selection controls. System graphical user interfaces typically employ a pointer and a set of hierarchical selectors to select, move and otherwise manipulate their environment. For these purposes the following assignment of significance can be applied to the Button usages: */ +/* ¥ Button 1, Primary Button. Used for object selecting, dragging, and double click activation. On MacOS, this is the only button. Microsoft operating systems call this a logical left button, because it */ +/* is not necessarily physically located on the left of the pointing device. */ +/* ¥ Button 2, Secondary Button. Used by newer graphical user interfaces to browse object properties. Exposed by systems to applications that typically assign application-specific functionality. */ +/* ¥ Button 3, Tertiary Button. Optional control. Exposed to applications, but seldom assigned functionality due to prevalence of two- and one-button devices. */ +/* ¥ Buttons 4 -55. As the button number increases, its significance as a selector decreases. */ +/* In many ways the assignment of button numbers is similar to the assignment of Effort in Physical descriptors. Button 1 would be used to define the button a finger rests on when the hand is in the Òat restÓ position, that is, virtually no effort is required by the user to activate the button. Button values increment as the finger has to stretch to reach a control. See Section 6.2.3, ÒPhysical Descriptors,Ó in the HID Specification for methods of further qualifying buttons. */ +enum +{ + kHIDUsage_Button_1 = 0x01, /* (primary/trigger) */ + kHIDUsage_Button_2 = 0x02, /* (secondary) */ + kHIDUsage_Button_3 = 0x03, /* (tertiary) */ + kHIDUsage_Button_4 = 0x04, /* 4th button */ + /* ... */ + kHIDUsage_Button_65535 = 0xFFFF +}; + +/* Ordinal Page (0x0A) */ +/* The Ordinal page allows multiple instances of a control or sets of controls to be declared without requiring individual enumeration in the native usage page. For example, it is not necessary to declare usages of Pointer 1, Pointer 2, and so forth on the Generic Desktop page. When parsed, the ordinal instance number is, in essence, concatenated to the usages attached to the encompassing collection to create Pointer 1, Pointer 2, and so forth. */ +/* For an example, see Section A.5, ÒMultiple Instances of a Control,Ó in Appendix A, ÒUsage Examples.Ó By convention, an Ordinal collection is placed inside the collection for which it is declaring multiple instances. */ +/* Instances do not have to be identical. */ +enum +{ + /* 0x00 Reserved */ + kHIDUsage_Ord_Instance1 = 0x01, /* Usage Modifier */ + kHIDUsage_Ord_Instance2 = 0x02, /* Usage Modifier */ + kHIDUsage_Ord_Instance3 = 0x03, /* Usage Modifier */ + kHIDUsage_Ord_Instance4 = 0x04, /* Usage Modifier */ + kHIDUsage_Ord_Instance65535 = 0xFFFF /* Usage Modifier */ +}; + +/* Telephony Page (0x0B) */ +/* This usage page defines the keytop and control usages for telephony devices. */ +/* Indicators on a phone are handled by wrapping them in LED: Usage In Use Indicator and LED: Usage Selected Indicator usages. For example, a message-indicator LED would be identified by a Telephony: Message usage declared as a Feature or Output in a LED: Usage In Use Indicator collection. */ +/* See Section 14, ÒConsumer Page (0x0C),Ó for audio volume and tone controls. */ +enum +{ + kHIDUsage_Tfon_Phone = 0x01, /* Application Collection */ + kHIDUsage_Tfon_AnsweringMachine = 0x02, /* Application Collection */ + kHIDUsage_Tfon_MessageControls = 0x03, /* Logical Collection */ + kHIDUsage_Tfon_Handset = 0x04, /* Logical Collection */ + kHIDUsage_Tfon_Headset = 0x05, /* Logical Collection */ + kHIDUsage_Tfon_TelephonyKeyPad = 0x06, /* Named Array */ + kHIDUsage_Tfon_ProgrammableButton = 0x07, /* Named Array */ + /* 0x08 - 0x1F Reserved */ + kHIDUsage_Tfon_HookSwitch = 0x20, /* On/Off Control */ + kHIDUsage_Tfon_Flash = 0x21, /* Momentary Control */ + kHIDUsage_Tfon_Feature = 0x22, /* One-Shot Control */ + kHIDUsage_Tfon_Hold = 0x23, /* On/Off Control */ + kHIDUsage_Tfon_Redial = 0x24, /* One-Shot Control */ + kHIDUsage_Tfon_Transfer = 0x25, /* One-Shot Control */ + kHIDUsage_Tfon_Drop = 0x26, /* One-Shot Control */ + kHIDUsage_Tfon_Park = 0x27, /* On/Off Control */ + kHIDUsage_Tfon_ForwardCalls = 0x28, /* On/Off Control */ + kHIDUsage_Tfon_AlternateFunction = 0x29, /* Momentary Control */ + kHIDUsage_Tfon_Line = 0x2A, /* One-Shot Control */ + kHIDUsage_Tfon_SpeakerPhone = 0x2B, /* On/Off Control */ + kHIDUsage_Tfon_Conference = 0x2C, /* On/Off Control */ + kHIDUsage_Tfon_RingEnable = 0x2D, /* On/Off Control */ + kHIDUsage_Tfon_Ring = 0x2E, /* Selector */ + kHIDUsage_Tfon_PhoneMute = 0x2F, /* On/Off Control */ + kHIDUsage_Tfon_CallerID = 0x30, /* Momentary Control */ + /* 0x31 - 0x4F Reserved */ + kHIDUsage_Tfon_SpeedDial = 0x50, /* One-Shot Control */ + kHIDUsage_Tfon_StoreNumber = 0x51, /* One-Shot Control */ + kHIDUsage_Tfon_RecallNumber = 0x52, /* One-Shot Control */ + kHIDUsage_Tfon_PhoneDirectory = 0x53, /* On/Off Control */ + /* 0x54 - 0x6F Reserved */ + kHIDUsage_Tfon_VoiceMail = 0x70, /* On/Off Control */ + kHIDUsage_Tfon_ScreenCalls = 0x71, /* On/Off Control */ + kHIDUsage_Tfon_DoNotDisturb = 0x72, /* On/Off Control */ + kHIDUsage_Tfon_Message = 0x73, /* One-Shot Control */ + kHIDUsage_Tfon_AnswerOnOrOff = 0x74, /* On/Off Control */ + /* 0x75 - 0x8F Reserved */ + kHIDUsage_Tfon_InsideDialTone = 0x90, /* Momentary Control */ + kHIDUsage_Tfon_OutsideDialTone = 0x91, /* Momentary Control */ + kHIDUsage_Tfon_InsideRingTone = 0x92, /* Momentary Control */ + kHIDUsage_Tfon_OutsideRingTone = 0x93, /* Momentary Control */ + kHIDUsage_Tfon_PriorityRingTone = 0x94, /* Momentary Control */ + kHIDUsage_Tfon_InsideRingback = 0x95, /* Momentary Control */ + kHIDUsage_Tfon_PriorityRingback = 0x96, /* Momentary Control */ + kHIDUsage_Tfon_LineBusyTone = 0x97, /* Momentary Control */ + kHIDUsage_Tfon_ReorderTone = 0x98, /* Momentary Control */ + kHIDUsage_Tfon_CallWaitingTone = 0x99, /* Momentary Control */ + kHIDUsage_Tfon_ConfirmationTone1 = 0x9A, /* Momentary Control */ + kHIDUsage_Tfon_ConfirmationTone2 = 0x9B, /* Momentary Control */ + kHIDUsage_Tfon_TonesOff = 0x9C, /* On/Off Control */ + kHIDUsage_Tfon_OutsideRingback = 0x9D, /* Momentary Control */ + /* 0x9E - 0xAF Reserved */ + kHIDUsage_Tfon_PhoneKey0 = 0xB0, /* Selector/One-Shot Control */ + kHIDUsage_Tfon_PhoneKey1 = 0xB1, /* Selector/One-Shot Control */ + kHIDUsage_Tfon_PhoneKey2 = 0xB2, /* Selector/One-Shot Control */ + kHIDUsage_Tfon_PhoneKey3 = 0xB3, /* Selector/One-Shot Control */ + kHIDUsage_Tfon_PhoneKey4 = 0xB4, /* Selector/One-Shot Control */ + kHIDUsage_Tfon_PhoneKey5 = 0xB5, /* Selector/One-Shot Control */ + kHIDUsage_Tfon_PhoneKey6 = 0xB6, /* Selector/One-Shot Control */ + kHIDUsage_Tfon_PhoneKey7 = 0xB7, /* Selector/One-Shot Control */ + kHIDUsage_Tfon_PhoneKey8 = 0xB8, /* Selector/One-Shot Control */ + kHIDUsage_Tfon_PhoneKey9 = 0xB9, /* Selector/One-Shot Control */ + kHIDUsage_Tfon_PhoneKeyStar = 0xBA, /* Selector/One-Shot Control */ + kHIDUsage_Tfon_PhoneKeyPound = 0xBB, /* Selector/One-Shot Control */ + kHIDUsage_Tfon_PhoneKeyA = 0xBC, /* Selector/One-Shot Control */ + kHIDUsage_Tfon_PhoneKeyB = 0xBD, /* Selector/One-Shot Control */ + kHIDUsage_Tfon_PhoneKeyC = 0xBE, /* Selector/One-Shot Control */ + kHIDUsage_Tfon_PhoneKeyD = 0xBF, /* Selector/One-Shot Control */ + /* 0xC0 - 0xFFFF Reserved */ + kHIDUsage_TFon_Reserved = 0xFFFF +}; + +/* Consumer Page (0x0C) */ +/* All controls on the Consumer page are application-specific. That is, they affect a specific device, not the system as a whole. */ +enum +{ + kHIDUsage_Csmr_ConsumerControl = 0x01, /* Application Collection */ + kHIDUsage_Csmr_NumericKeyPad = 0x02, /* Named Array */ + kHIDUsage_Csmr_ProgrammableButtons = 0x03, /* Named Array */ + /* 0x03 - 0x1F Reserved */ + kHIDUsage_Csmr_Plus10 = 0x20, /* One-Shot Control */ + kHIDUsage_Csmr_Plus100 = 0x21, /* One-Shot Control */ + kHIDUsage_Csmr_AMOrPM = 0x22, /* One-Shot Control */ + /* 0x23 - 0x3F Reserved */ + kHIDUsage_Csmr_Power = 0x30, /* On/Off Control */ + kHIDUsage_Csmr_Reset = 0x31, /* One-Shot Control */ + kHIDUsage_Csmr_Sleep = 0x32, /* One-Shot Control */ + kHIDUsage_Csmr_SleepAfter = 0x33, /* One-Shot Control */ + kHIDUsage_Csmr_SleepMode = 0x34, /* Re-Trigger Control */ + kHIDUsage_Csmr_Illumination = 0x35, /* On/Off Control */ + kHIDUsage_Csmr_FunctionButtons = 0x36, /* Named Array */ + /* 0x37 - 0x3F Reserved */ + kHIDUsage_Csmr_Menu = 0x40, /* On/Off Control */ + kHIDUsage_Csmr_MenuPick = 0x41, /* One-Shot Control */ + kHIDUsage_Csmr_MenuUp = 0x42, /* One-Shot Control */ + kHIDUsage_Csmr_MenuDown = 0x43, /* One-Shot Control */ + kHIDUsage_Csmr_MenuLeft = 0x44, /* One-Shot Control */ + kHIDUsage_Csmr_MenuRight = 0x45, /* One-Shot Control */ + kHIDUsage_Csmr_MenuEscape = 0x46, /* One-Shot Control */ + kHIDUsage_Csmr_MenuValueIncrease = 0x47, /* One-Shot Control */ + kHIDUsage_Csmr_MenuValueDecrease = 0x48, /* One-Shot Control */ + /* 0x49 - 0x5F Reserved */ + kHIDUsage_Csmr_DataOnScreen = 0x60, /* On/Off Control */ + kHIDUsage_Csmr_ClosedCaption = 0x61, /* On/Off Control */ + kHIDUsage_Csmr_ClosedCaptionSelect = 0x62, /* Selector */ + kHIDUsage_Csmr_VCROrTV = 0x63, /* On/Off Control */ + kHIDUsage_Csmr_BroadcastMode = 0x64, /* One-Shot Control */ + kHIDUsage_Csmr_Snapshot = 0x65, /* One-Shot Control */ + kHIDUsage_Csmr_Still = 0x66, /* One-Shot Control */ + /* 0x67 - 0x7F Reserved */ + kHIDUsage_Csmr_Selection = 0x80, /* Named Array */ + kHIDUsage_Csmr_Assign = 0x81, /* Selector */ + kHIDUsage_Csmr_ModeStep = 0x82, /* One-Shot Control */ + kHIDUsage_Csmr_RecallLast = 0x83, /* One-Shot Control */ + kHIDUsage_Csmr_EnterChannel = 0x84, /* One-Shot Control */ + kHIDUsage_Csmr_OrderMovie = 0x85, /* One-Shot Control */ + kHIDUsage_Csmr_Channel = 0x86, /* Linear Control */ + kHIDUsage_Csmr_MediaSelection = 0x87, /* Selector */ + kHIDUsage_Csmr_MediaSelectComputer = 0x88, /* Selector */ + kHIDUsage_Csmr_MediaSelectTV = 0x89, /* Selector */ + kHIDUsage_Csmr_MediaSelectWWW = 0x8A, /* Selector */ + kHIDUsage_Csmr_MediaSelectDVD = 0x8B, /* Selector */ + kHIDUsage_Csmr_MediaSelectTelephone = 0x8C, /* Selector */ + kHIDUsage_Csmr_MediaSelectProgramGuide = 0x8D, /* Selector */ + kHIDUsage_Csmr_MediaSelectVideoPhone = 0x8E, /* Selector */ + kHIDUsage_Csmr_MediaSelectGames = 0x8F, /* Selector */ + kHIDUsage_Csmr_MediaSelectMessages = 0x90, /* Selector */ + kHIDUsage_Csmr_MediaSelectCD = 0x91, /* Selector */ + kHIDUsage_Csmr_MediaSelectVCR = 0x92, /* Selector */ + kHIDUsage_Csmr_MediaSelectTuner = 0x93, /* Selector */ + kHIDUsage_Csmr_Quit = 0x94, /* One-Shot Control */ + kHIDUsage_Csmr_Help = 0x95, /* On/Off Control */ + kHIDUsage_Csmr_MediaSelectTape = 0x96, /* Selector */ + kHIDUsage_Csmr_MediaSelectCable = 0x97, /* Selector */ + kHIDUsage_Csmr_MediaSelectSatellite = 0x98, /* Selector */ + kHIDUsage_Csmr_MediaSelectSecurity = 0x99, /* Selector */ + kHIDUsage_Csmr_MediaSelectHome = 0x9A, /* Selector */ + kHIDUsage_Csmr_MediaSelectCall = 0x9B, /* Selector */ + kHIDUsage_Csmr_ChannelIncrement = 0x9C, /* One-Shot Control */ + kHIDUsage_Csmr_ChannelDecrement = 0x9D, /* One-Shot Control */ + kHIDUsage_Csmr_Media = 0x9E, /* Selector */ + /* 0x9F Reserved */ + kHIDUsage_Csmr_VCRPlus = 0xA0, /* One-Shot Control */ + kHIDUsage_Csmr_Once = 0xA1, /* One-Shot Control */ + kHIDUsage_Csmr_Daily = 0xA2, /* One-Shot Control */ + kHIDUsage_Csmr_Weekly = 0xA3, /* One-Shot Control */ + kHIDUsage_Csmr_Monthly = 0xA4, /* One-Shot Control */ + /* 0xA5 - 0xAF Reserved */ + kHIDUsage_Csmr_Play = 0xB0, /* On/Off Control */ + kHIDUsage_Csmr_Pause = 0xB1, /* On/Off Control */ + kHIDUsage_Csmr_Record = 0xB2, /* On/Off Control */ + kHIDUsage_Csmr_FastForward = 0xB3, /* On/Off Control */ + kHIDUsage_Csmr_Rewind = 0xB4, /* On/Off Control */ + kHIDUsage_Csmr_ScanNextTrack = 0xB5, /* One-Shot Control */ + kHIDUsage_Csmr_ScanPreviousTrack = 0xB6, /* One-Shot Control */ + kHIDUsage_Csmr_Stop = 0xB7, /* One-Shot Control */ + kHIDUsage_Csmr_Eject = 0xB8, /* One-Shot Control */ + kHIDUsage_Csmr_RandomPlay = 0xB9, /* On/Off Control */ + kHIDUsage_Csmr_SelectDisc = 0xBA, /* Named Array */ + kHIDUsage_Csmr_EnterDisc = 0xBB, /* Momentary Control */ + kHIDUsage_Csmr_Repeat = 0xBC, /* One-Shot Control */ + kHIDUsage_Csmr_Tracking = 0xBD, /* Linear Control */ + kHIDUsage_Csmr_TrackNormal = 0xBE, /* One-Shot Control */ + kHIDUsage_Csmr_SlowTracking = 0xBF, /* Linear Control */ + kHIDUsage_Csmr_FrameForward = 0xC0, /* Re-Trigger Control */ + kHIDUsage_Csmr_FrameBack = 0xC1, /* Re-Trigger Control */ + kHIDUsage_Csmr_Mark = 0xC2, /* One-Shot Control */ + kHIDUsage_Csmr_ClearMark = 0xC3, /* One-Shot Control */ + kHIDUsage_Csmr_RepeatFromMark = 0xC4, /* On/Off Control */ + kHIDUsage_Csmr_ReturnToMark = 0xC5, /* One-Shot Control */ + kHIDUsage_Csmr_SearchMarkForward = 0xC6, /* One-Shot Control */ + kHIDUsage_Csmr_SearchMarkBackwards = 0xC7, /* One-Shot Control */ + kHIDUsage_Csmr_CounterReset = 0xC8, /* One-Shot Control */ + kHIDUsage_Csmr_ShowCounter = 0xC9, /* One-Shot Control */ + kHIDUsage_Csmr_TrackingIncrement = 0xCA, /* Re-Trigger Control */ + kHIDUsage_Csmr_TrackingDecrement = 0xCB, /* Re-Trigger Control */ + kHIDUsage_Csmr_StopOrEject = 0xCC, /* One-Shot Control */ + kHIDUsage_Csmr_PlayOrPause = 0xCD, /* One-Shot Control */ + kHIDUsage_Csmr_PlayOrSkip = 0xCE, /* One-Shot Control */ + /* 0xCF - 0xDF Reserved */ + kHIDUsage_Csmr_Volume = 0xE0, /* Linear Control */ + kHIDUsage_Csmr_Balance = 0xE1, /* Linear Control */ + kHIDUsage_Csmr_Mute = 0xE2, /* On/Off Control */ + kHIDUsage_Csmr_Bass = 0xE3, /* Linear Control */ + kHIDUsage_Csmr_Treble = 0xE4, /* Linear Control */ + kHIDUsage_Csmr_BassBoost = 0xE5, /* On/Off Control */ + kHIDUsage_Csmr_SurroundMode = 0xE6, /* One-Shot Control */ + kHIDUsage_Csmr_Loudness = 0xE7, /* On/Off Control */ + kHIDUsage_Csmr_MPX = 0xE8, /* On/Off Control */ + kHIDUsage_Csmr_VolumeIncrement = 0xE9, /* Re-Trigger Control */ + kHIDUsage_Csmr_VolumeDecrement = 0xEA, /* Re-Trigger Control */ + /* 0xEB - 0xEF Reserved */ + kHIDUsage_Csmr_Speed = 0xF0, /* Selector */ + kHIDUsage_Csmr_PlaybackSpeed = 0xF1, /* Named Array */ + kHIDUsage_Csmr_StandardPlay = 0xF2, /* Selector */ + kHIDUsage_Csmr_LongPlay = 0xF3, /* Selector */ + kHIDUsage_Csmr_ExtendedPlay = 0xF4, /* Selector */ + kHIDUsage_Csmr_Slow = 0xF5, /* One-Shot Control */ + /* 0xF6 - 0xFF Reserved */ + kHIDUsage_Csmr_FanEnable = 0x100, /* On/Off Control */ + kHIDUsage_Csmr_FanSpeed = 0x101, /* Linear Control */ + kHIDUsage_Csmr_LightEnable = 0x102, /* On/Off Control */ + kHIDUsage_Csmr_LightIlluminationLevel = 0x103, /* Linear Control */ + kHIDUsage_Csmr_ClimateControlEnable = 0x104, /* On/Off Control */ + kHIDUsage_Csmr_RoomTemperature = 0x105, /* Linear Control */ + kHIDUsage_Csmr_SecurityEnable = 0x106, /* On/Off Control */ + kHIDUsage_Csmr_FireAlarm = 0x107, /* One-Shot Control */ + kHIDUsage_Csmr_PoliceAlarm = 0x108, /* One-Shot Control */ + /* 0x109 - 0x14F Reserved */ + kHIDUsage_Csmr_BalanceRight = 0x150, /* Re-Trigger Control */ + kHIDUsage_Csmr_BalanceLeft = 0x151, /* Re-Trigger Control */ + kHIDUsage_Csmr_BassIncrement = 0x152, /* Re-Trigger Control */ + kHIDUsage_Csmr_BassDecrement = 0x153, /* Re-Trigger Control */ + kHIDUsage_Csmr_TrebleIncrement = 0x154, /* Re-Trigger Control */ + kHIDUsage_Csmr_TrebleDecrement = 0x155, /* Re-Trigger Control */ + /* 0x156 - 0x15F Reserved */ + kHIDUsage_Csmr_SpeakerSystem = 0x160, /* Logical Collection */ + kHIDUsage_Csmr_ChannelLeft = 0x161, /* Logical Collection */ + kHIDUsage_Csmr_ChannelRight = 0x162, /* Logical Collection */ + kHIDUsage_Csmr_ChannelCenter = 0x163, /* Logical Collection */ + kHIDUsage_Csmr_ChannelFront = 0x164, /* Logical Collection */ + kHIDUsage_Csmr_ChannelCenterFront = 0x165, /* Logical Collection */ + kHIDUsage_Csmr_ChannelSide = 0x166, /* Logical Collection */ + kHIDUsage_Csmr_ChannelSurround = 0x167, /* Logical Collection */ + kHIDUsage_Csmr_ChannelLowFrequencyEnhancement = 0x168, /* Logical Collection */ + kHIDUsage_Csmr_ChannelTop = 0x169, /* Logical Collection */ + kHIDUsage_Csmr_ChannelUnknown = 0x16A, /* Logical Collection */ + /* 0x16B - 0x16F Reserved */ + kHIDUsage_Csmr_SubChannel = 0x170, /* Linear Control */ + kHIDUsage_Csmr_SubChannelIncrement = 0x171, /* One-Shot Control */ + kHIDUsage_Csmr_SubChannelDecrement = 0x172, /* One-Shot Control */ + kHIDUsage_Csmr_AlternateAudioIncrement = 0x173, /* One-Shot Control */ + kHIDUsage_Csmr_AlternateAudioDecrement = 0x174, /* One-Shot Control */ + /* 0x175 - 0x17F Reserved */ + kHIDUsage_Csmr_ApplicationLaunchButtons = 0x180, /* Named Array */ + kHIDUsage_Csmr_ALLaunchButtonConfigurationTool = 0x181, /* Selector */ + kHIDUsage_Csmr_ALProgrammableButtonConfiguration = 0x182, /* Selector */ + kHIDUsage_Csmr_ALConsumerControlConfiguration = 0x183, /* Selector */ + kHIDUsage_Csmr_ALWordProcessor = 0x184, /* Selector */ + kHIDUsage_Csmr_ALTextEditor = 0x185, /* Selector */ + kHIDUsage_Csmr_ALSpreadsheet = 0x186, /* Selector */ + kHIDUsage_Csmr_ALGraphicsEditor = 0x187, /* Selector */ + kHIDUsage_Csmr_ALPresentationApp = 0x188, /* Selector */ + kHIDUsage_Csmr_ALDatabaseApp = 0x189, /* Selector */ + kHIDUsage_Csmr_ALEmailReader = 0x18A, /* Selector */ + kHIDUsage_Csmr_ALNewsreader = 0x18B, /* Selector */ + kHIDUsage_Csmr_ALVoicemail = 0x18C, /* Selector */ + kHIDUsage_Csmr_ALContactsOrAddressBook = 0x18D, /* Selector */ + kHIDUsage_Csmr_ALCalendarOrSchedule = 0x18E, /* Selector */ + kHIDUsage_Csmr_ALTaskOrProjectManager = 0x18F, /* Selector */ + kHIDUsage_Csmr_ALLogOrJournalOrTimecard = 0x190, /* Selector */ + kHIDUsage_Csmr_ALCheckbookOrFinance = 0x191, /* Selector */ + kHIDUsage_Csmr_ALCalculator = 0x192, /* Selector */ + kHIDUsage_Csmr_ALAOrVCaptureOrPlayback = 0x193, /* Selector */ + kHIDUsage_Csmr_ALLocalMachineBrowser = 0x194, /* Selector */ + kHIDUsage_Csmr_ALLANOrWANBrowser = 0x195, /* Selector */ + kHIDUsage_Csmr_ALInternetBrowser = 0x196, /* Selector */ + kHIDUsage_Csmr_ALRemoteNetworkingOrISPConnect = 0x197, /* Selector */ + kHIDUsage_Csmr_ALNetworkConference = 0x198, /* Selector */ + kHIDUsage_Csmr_ALNetworkChat = 0x199, /* Selector */ + kHIDUsage_Csmr_ALTelephonyOrDialer = 0x19A, /* Selector */ + kHIDUsage_Csmr_ALLogon = 0x19B, /* Selector */ + kHIDUsage_Csmr_ALLogoff = 0x19C, /* Selector */ + kHIDUsage_Csmr_ALLogonOrLogoff = 0x19D, /* Selector */ + kHIDUsage_Csmr_ALTerminalLockOrScreensaver = 0x19E, /* Selector */ + kHIDUsage_Csmr_ALControlPanel = 0x19F, /* Selector */ + kHIDUsage_Csmr_ALCommandLineProcessorOrRun = 0x1A0, /* Selector */ + kHIDUsage_Csmr_ALProcessOrTaskManager = 0x1A1, /* Selector */ + kHIDUsage_Csmr_AL = 0x1A2, /* Selector */ + kHIDUsage_Csmr_ALNextTaskOrApplication = 0x1A3, /* Selector */ + kHIDUsage_Csmr_ALPreviousTaskOrApplication = 0x1A4, /* Selector */ + kHIDUsage_Csmr_ALPreemptiveHaltTaskOrApplication = 0x1A5, /* Selector */ + kHIDUsage_Csmr_ALIntegratedHelpCenter = 0x1A6, /* Selector */ + kHIDUsage_Csmr_ALDocuments = 0x1A7, /* Selector */ + kHIDUsage_Csmr_ALThesaurus = 0x1A8, /* Selector */ + kHIDUsage_Csmr_ALDictionary = 0x1A9, /* Selector */ + kHIDUsage_Csmr_ALDesktop = 0x1AA, /* Selector */ + kHIDUsage_Csmr_ALSpellCheck = 0x1AB, /* Selector */ + kHIDUsage_Csmr_ALGrammerCheck = 0x1AC, /* Selector */ + kHIDUsage_Csmr_ALWirelessStatus = 0x1AD, /* Selector */ + kHIDUsage_Csmr_ALKeyboardLayout = 0x1AE, /* Selector */ + kHIDUsage_Csmr_ALVirusProtection = 0x1AF, /* Selector */ + kHIDUsage_Csmr_ALEncryption = 0x1B0, /* Selector */ + kHIDUsage_Csmr_ALScreenSaver = 0x1B1, /* Selector */ + kHIDUsage_Csmr_ALAlarms = 0x1B2, /* Selector */ + kHIDUsage_Csmr_ALClock = 0x1B3, /* Selector */ + kHIDUsage_Csmr_ALFileBrowser = 0x1B4, /* Selector */ + kHIDUsage_Csmr_ALPowerStatus = 0x1B5, /* Selector */ + /* 0x1A6 - 0x1FF Reserved */ + kHIDUsage_Csmr_GenericGUIApplicationControls = 0x200, /* Named Array */ + kHIDUsage_Csmr_ACNew = 0x201, /* Selector */ + kHIDUsage_Csmr_ACOpen = 0x202, /* Selector */ + kHIDUsage_Csmr_ACClose = 0x203, /* Selector */ + kHIDUsage_Csmr_ACExit = 0x204, /* Selector */ + kHIDUsage_Csmr_ACMaximize = 0x205, /* Selector */ + kHIDUsage_Csmr_ACMinimize = 0x206, /* Selector */ + kHIDUsage_Csmr_ACSave = 0x207, /* Selector */ + kHIDUsage_Csmr_ACPrint = 0x208, /* Selector */ + kHIDUsage_Csmr_ACProperties = 0x209, /* Selector */ + kHIDUsage_Csmr_ACUndo = 0x21A, /* Selector */ + kHIDUsage_Csmr_ACCopy = 0x21B, /* Selector */ + kHIDUsage_Csmr_ACCut = 0x21C, /* Selector */ + kHIDUsage_Csmr_ACPaste = 0x21D, /* Selector */ + kHIDUsage_Csmr_AC = 0x21E, /* Selector */ + kHIDUsage_Csmr_ACFind = 0x21F, /* Selector */ + kHIDUsage_Csmr_ACFindandReplace = 0x220, /* Selector */ + kHIDUsage_Csmr_ACSearch = 0x221, /* Selector */ + kHIDUsage_Csmr_ACGoTo = 0x222, /* Selector */ + kHIDUsage_Csmr_ACHome = 0x223, /* Selector */ + kHIDUsage_Csmr_ACBack = 0x224, /* Selector */ + kHIDUsage_Csmr_ACForward = 0x225, /* Selector */ + kHIDUsage_Csmr_ACStop = 0x226, /* Selector */ + kHIDUsage_Csmr_ACRefresh = 0x227, /* Selector */ + kHIDUsage_Csmr_ACPreviousLink = 0x228, /* Selector */ + kHIDUsage_Csmr_ACNextLink = 0x229, /* Selector */ + kHIDUsage_Csmr_ACBookmarks = 0x22A, /* Selector */ + kHIDUsage_Csmr_ACHistory = 0x22B, /* Selector */ + kHIDUsage_Csmr_ACSubscriptions = 0x22C, /* Selector */ + kHIDUsage_Csmr_ACZoomIn = 0x22D, /* Selector */ + kHIDUsage_Csmr_ACZoomOut = 0x22E, /* Selector */ + kHIDUsage_Csmr_ACZoom = 0x22F, /* Selector */ + kHIDUsage_Csmr_ACFullScreenView = 0x230, /* Selector */ + kHIDUsage_Csmr_ACNormalView = 0x231, /* Selector */ + kHIDUsage_Csmr_ACViewToggle = 0x232, /* Selector */ + kHIDUsage_Csmr_ACScrollUp = 0x233, /* Selector */ + kHIDUsage_Csmr_ACScrollDown = 0x234, /* Selector */ + kHIDUsage_Csmr_ACScroll = 0x235, /* Selector */ + kHIDUsage_Csmr_ACPanLeft = 0x236, /* Selector */ + kHIDUsage_Csmr_ACPanRight = 0x237, /* Selector */ + kHIDUsage_Csmr_ACPan = 0x238, /* Selector */ + kHIDUsage_Csmr_ACNewWindow = 0x239, /* Selector */ + kHIDUsage_Csmr_ACTileHorizontally = 0x23A, /* Selector */ + kHIDUsage_Csmr_ACTileVertically = 0x23B, /* Selector */ + kHIDUsage_Csmr_ACFormat = 0x23C, /* Selector */ + /* 0x23D - 0xFFFF Reserved */ + kHIDUsage_Csmr_Reserved = 0xFFFF +}; + +/* Physical Interface Device Page (0x0F) */ +/* This section provides detailed descriptions of the usages employed by Digitizer Devices. */ +enum +{ + kHIDUsage_PID_PhysicalInterfaceDevice = 0x01, /* CA - A collection of PID usages */ + /* 0x02 - 0x1F Reserved */ + kHIDUsage_PID_Normal = 0x20, /* DV - A force applied perpendicular to the surface of an object */ + kHIDUsage_PID_SetEffectReport = 0x21, /* XXX */ + kHIDUsage_PID_EffectBlockIndex = 0x22, /* XXX */ + kHIDUsage_PID_ParamBlockOffset = 0x23, /* XXX */ + kHIDUsage_PID_ROM_Flag = 0x24, /* XXX */ + kHIDUsage_PID_EffectType = 0x25, /* XXX */ + kHIDUsage_PID_ET_ConstantForce = 0x26, /* XXX */ + kHIDUsage_PID_ET_Ramp = 0x27, /* XXX */ + kHIDUsage_PID_ET_CustomForceData = 0x28, /* XXX */ + /* 0x29 - 0x2F Reserved */ + kHIDUsage_PID_ET_Square = 0x30, /* XXX */ + kHIDUsage_PID_ET_Sine = 0x31, /* XXX */ + kHIDUsage_PID_ET_Triangle = 0x32, /* XXX */ + kHIDUsage_PID_ET_SawtoothUp = 0x33, /* XXX */ + kHIDUsage_PID_ET_SawtoothDown = 0x34, /* XXX */ + /* 0x35 - 0x3F Reserved */ + kHIDUsage_PID_ET_Spring = 0x40, /* XXX */ + kHIDUsage_PID_ET_Damper = 0x41, /* XXX */ + kHIDUsage_PID_ET_Inertia = 0x42, /* XXX */ + kHIDUsage_PID_ET_Friction = 0x43, /* XXX */ + /* 0x44 - 0x4F Reserved */ + kHIDUsage_PID_Duration = 0x50, /* XXX */ + kHIDUsage_PID_SamplePeriod = 0x51, /* XXX */ + kHIDUsage_PID_Gain = 0x52, /* XXX */ + kHIDUsage_PID_TriggerButton = 0x53, /* XXX */ + kHIDUsage_PID_TriggerRepeatInterval = 0x54, /* XXX */ + kHIDUsage_PID_AxesEnable = 0x55, /* XXX */ + kHIDUsage_PID_DirectionEnable = 0x56, /* XXX */ + kHIDUsage_PID_Direction = 0x57, /* XXX */ + kHIDUsage_PID_TypeSpecificBlockOffset = 0x58, /* XXX */ + kHIDUsage_PID_BlockType = 0x59, /* XXX */ + kHIDUsage_PID_SetEnvelopeReport = 0x5A, /* XXX */ + kHIDUsage_PID_AttackLevel = 0x5B, /* XXX */ + kHIDUsage_PID_AttackTime = 0x5C, /* XXX */ + kHIDUsage_PID_FadeLevel = 0x5D, /* XXX */ + kHIDUsage_PID_FadeTime = 0x5E, /* XXX */ + kHIDUsage_PID_SetConditionReport = 0x5F, /* XXX */ + + kHIDUsage_PID_CP_Offset = 0x60, /* XXX */ + kHIDUsage_PID_PositiveCoefficient = 0x61, /* XXX */ + kHIDUsage_PID_NegativeCoefficient = 0x62, /* XXX */ + kHIDUsage_PID_PositiveSaturation = 0x63, /* XXX */ + kHIDUsage_PID_NegativeSaturation = 0x64, /* XXX */ + kHIDUsage_PID_DeadBand = 0x65, /* XXX */ + kHIDUsage_PID_DownloadForceSample = 0x66, /* XXX */ + kHIDUsage_PID_IsochCustomForceEnable = 0x67, /* XXX */ + kHIDUsage_PID_CustomForceDataReport = 0x68, /* XXX */ + kHIDUsage_PID_CustomForceData = 0x69, /* XXX */ + kHIDUsage_PID_CustomForceVendorDefinedData = 0x6A, /* XXX */ + kHIDUsage_PID_SetCustomForceReport = 0x6B, /* XXX */ + kHIDUsage_PID_CustomForceDataOffset = 0x6C, /* XXX */ + kHIDUsage_PID_SampleCount = 0x6D, /* XXX */ + kHIDUsage_PID_SetPeriodicReport = 0x6E, /* XXX */ + kHIDUsage_PID_Offset = 0x6F, /* XXX */ + + kHIDUsage_PID_Magnitude = 0x70, /* XXX */ + kHIDUsage_PID_Phase = 0x71, /* XXX */ + kHIDUsage_PID_Period = 0x72, /* XXX */ + kHIDUsage_PID_SetConstantForceReport = 0x73, /* XXX */ + kHIDUsage_PID_SetRampForceReport = 0x74, /* XXX */ + kHIDUsage_PID_RampStart = 0x75, /* XXX */ + kHIDUsage_PID_RampEnd = 0x76, /* XXX */ + kHIDUsage_PID_EffectOperationReport = 0x77, /* XXX */ + kHIDUsage_PID_EffectOperation = 0x78, /* XXX */ + kHIDUsage_PID_OpEffectStart = 0x79, /* XXX */ + kHIDUsage_PID_OpEffectStartSolo = 0x7A, /* XXX */ + kHIDUsage_PID_OpEffectStop = 0x7B, /* XXX */ + kHIDUsage_PID_LoopCount = 0x7C, /* XXX */ + kHIDUsage_PID_DeviceGainReport = 0x7D, /* XXX */ + kHIDUsage_PID_DeviceGain = 0x7E, /* XXX */ + kHIDUsage_PID_PoolReport = 0x7F, /* XXX */ + + kHIDUsage_PID_RAM_PoolSize = 0x80, /* XXX */ + kHIDUsage_PID_ROM_PoolSize = 0x81, /* XXX */ + kHIDUsage_PID_ROM_EffectBlockCount = 0x82, /* XXX */ + kHIDUsage_PID_SimultaneousEffectsMax = 0x83, /* XXX */ + kHIDUsage_PID_PoolAlignment = 0x84, /* XXX */ + kHIDUsage_PID_PoolMoveReport = 0x85, /* XXX */ + kHIDUsage_PID_MoveSource = 0x86, /* XXX */ + kHIDUsage_PID_MoveDestination = 0x87, /* XXX */ + kHIDUsage_PID_MoveLength = 0x88, /* XXX */ + kHIDUsage_PID_BlockLoadReport = 0x89, /* XXX */ + /* 0x8A Reserved */ + kHIDUsage_PID_BlockLoadStatus = 0x8B, /* XXX */ + kHIDUsage_PID_BlockLoadSuccess = 0x8C, /* XXX */ + kHIDUsage_PID_BlockLoadFull = 0x8D, /* XXX */ + kHIDUsage_PID_BlockLoadError = 0x8E, /* XXX */ + kHIDUsage_PID_BlockHandle = 0x8F, /* XXX */ + + kHIDUsage_PID_BlockFreeReport = 0x90, /* XXX */ + kHIDUsage_PID_TypeSpecificBlockHandle = 0x91, /* XXX */ + kHIDUsage_PID_StateReport = 0x92, /* XXX */ + /* 0x93 Reserved */ + kHIDUsage_PID_EffectPlaying = 0x94, /* XXX */ + kHIDUsage_PID_DeviceControlReport = 0x95, /* XXX */ + kHIDUsage_PID_DeviceControl = 0x96, /* XXX */ + kHIDUsage_PID_DC_EnableActuators = 0x97, /* XXX */ + kHIDUsage_PID_DC_DisableActuators = 0x98, /* XXX */ + kHIDUsage_PID_DC_StopAllEffects = 0x99, /* XXX */ + kHIDUsage_PID_DC_DeviceReset = 0x9A, /* XXX */ + kHIDUsage_PID_DC_DevicePause = 0x9B, /* XXX */ + kHIDUsage_PID_DC_DeviceContinue = 0x9C, /* XXX */ + /* 0x9d - 0x9E Reserved */ + kHIDUsage_PID_DevicePaused = 0x9F, /* XXX */ + + kHIDUsage_PID_ActuatorsEnabled = 0xA0, /* XXX */ + /* 0xA1 - 0xA3 Reserved */ + kHIDUsage_PID_SafetySwitch = 0xA4, /* XXX */ + kHIDUsage_PID_ActuatorOverrideSwitch = 0xA5, /* XXX */ + kHIDUsage_PID_ActuatorPower = 0xA6, /* XXX */ + kHIDUsage_PID_StartDelay = 0xA7, /* XXX */ + kHIDUsage_PID_ParameterBlockSize = 0xA8, /* XXX */ + kHIDUsage_PID_DeviceManagedPool = 0xA9, /* XXX */ + kHIDUsage_PID_SharedParameterBlocks = 0xAA, /* XXX */ + kHIDUsage_PID_CreateNewEffectReport = 0xAB, /* XXX */ + kHIDUsage_PID_RAM_PoolAvailable = 0xAC, /* XXX */ + /* 0xAD - 0xFFFF Reserved */ + kHIDUsage_PID_Reserved = 0xFFFF +}; + +/* Digitizer Page (0x0D) */ +/* This section provides detailed descriptions of the usages employed by Digitizer Devices. */ +enum +{ + kHIDUsage_Dig_Digitizer = 0x01, /* Application Collection */ + kHIDUsage_Dig_Pen = 0x02, /* Application Collection */ + kHIDUsage_Dig_LightPen = 0x03, /* Application Collection */ + kHIDUsage_Dig_TouchScreen = 0x04, /* Application Collection */ + kHIDUsage_Dig_TouchPad = 0x05, /* Application Collection */ + kHIDUsage_Dig_WhiteBoard = 0x06, /* Application Collection */ + kHIDUsage_Dig_CoordinateMeasuringMachine = 0x07, /* Application Collection */ + kHIDUsage_Dig_3DDigitizer = 0x08, /* Application Collection */ + kHIDUsage_Dig_StereoPlotter = 0x09, /* Application Collection */ + kHIDUsage_Dig_ArticulatedArm = 0x0A, /* Application Collection */ + kHIDUsage_Dig_Armature = 0x0B, /* Application Collection */ + kHIDUsage_Dig_MultiplePointDigitizer = 0x0C, /* Application Collection */ + kHIDUsage_Dig_FreeSpaceWand = 0x0D, /* Application Collection */ + /* 0x0E - 0x1F Reserved */ + kHIDUsage_Dig_Stylus = 0x20, /* Logical Collection */ + kHIDUsage_Dig_Puck = 0x21, /* Logical Collection */ + kHIDUsage_Dig_Finger = 0x22, /* Logical Collection */ + /* 0x23 - 0x2F Reserved */ + kHIDUsage_Dig_TipPressure = 0x30, /* Dynamic Value */ + kHIDUsage_Dig_BarrelPressure = 0x31, /* Dynamic Value */ + kHIDUsage_Dig_InRange = 0x32, /* Momentary Control */ + kHIDUsage_Dig_Touch = 0x33, /* Momentary Control */ + kHIDUsage_Dig_Untouch = 0x34, /* One-Shot Control */ + kHIDUsage_Dig_Tap = 0x35, /* One-Shot Control */ + kHIDUsage_Dig_Quality = 0x36, /* Dynamic Value */ + kHIDUsage_Dig_DataValid = 0x37, /* Momentary Control */ + kHIDUsage_Dig_TransducerIndex = 0x38, /* Dynamic Value */ + kHIDUsage_Dig_TabletFunctionKeys = 0x39, /* Logical Collection */ + kHIDUsage_Dig_ProgramChangeKeys = 0x3A, /* Logical Collection */ + kHIDUsage_Dig_BatteryStrength = 0x3B, /* Dynamic Value */ + kHIDUsage_Dig_Invert = 0x3C, /* Momentary Control */ + kHIDUsage_Dig_XTilt = 0x3D, /* Dynamic Value */ + kHIDUsage_Dig_YTilt = 0x3E, /* Dynamic Value */ + kHIDUsage_Dig_Azimuth = 0x3F, /* Dynamic Value */ + kHIDUsage_Dig_Altitude = 0x40, /* Dynamic Value */ + kHIDUsage_Dig_Twist = 0x41, /* Dynamic Value */ + kHIDUsage_Dig_TipSwitch = 0x42, /* Momentary Control */ + kHIDUsage_Dig_SecondaryTipSwitch = 0x43, /* Momentary Control */ + kHIDUsage_Dig_BarrelSwitch = 0x44, /* Momentary Control */ + kHIDUsage_Dig_Eraser = 0x45, /* Momentary Control */ + kHIDUsage_Dig_TabletPick = 0x46, /* Momentary Control */ + /* 0x47 - 0xFFFF Reserved */ + kHIDUsage_Dig_Reserved = 0xFFFF +}; + +/* AlphanumericDisplay Page (0x14) */ +/* The Alphanumeric Display page is intended for use by simple alphanumeric displays that are used on consumer devices. */ +enum +{ + kHIDUsage_AD_AlphanumericDisplay = 0x01, /* Application Collection */ + /* 0x02 - 0x1F Reserved */ + kHIDUsage_AD_DisplayAttributesReport = 0x20, /* Logical Collection */ + kHIDUsage_AD_ASCIICharacterSet = 0x21, /* Static Flag */ + kHIDUsage_AD_DataReadBack = 0x22, /* Static Flag */ + kHIDUsage_AD_FontReadBack = 0x23, /* Static Flag */ + kHIDUsage_AD_DisplayControlReport = 0x24, /* Logical Collection */ + kHIDUsage_AD_ClearDisplay = 0x25, /* Dynamic Flag */ + kHIDUsage_AD_DisplayEnable = 0x26, /* Dynamic Flag */ + kHIDUsage_AD_ScreenSaverDelay = 0x27, /* Static Value */ + kHIDUsage_AD_ScreenSaverEnable = 0x28, /* Dynamic Flag */ + kHIDUsage_AD_VerticalScroll = 0x29, /* Static Flag */ + kHIDUsage_AD_HorizontalScroll = 0x2A, /* Static Flag */ + kHIDUsage_AD_CharacterReport = 0x2B, /* Logical Collection */ + kHIDUsage_AD_DisplayData = 0x2C, /* Dynamic Value */ + kHIDUsage_AD_DisplayStatus = 0x2D, /* Logical Collection */ + kHIDUsage_AD_StatNotReady = 0x2E, /* Selector */ + kHIDUsage_AD_StatReady = 0x2F, /* Selector */ + kHIDUsage_AD_ErrNotaloadablecharacter = 0x30, /* Selector */ + kHIDUsage_AD_ErrFontdatacannotberead = 0x31, /* Selector */ + kHIDUsage_AD_CursorPositionReport = 0x32, /* Logical Collection */ + kHIDUsage_AD_Row = 0x33, /* Dynamic Value */ + kHIDUsage_AD_Column = 0x34, /* Dynamic Value */ + kHIDUsage_AD_Rows = 0x35, /* Static Value */ + kHIDUsage_AD_Columns = 0x36, /* Static Value */ + kHIDUsage_AD_CursorPixelPositioning = 0x37, /* Static Flag */ + kHIDUsage_AD_CursorMode = 0x38, /* Dynamic Flag */ + kHIDUsage_AD_CursorEnable = 0x39, /* Dynamic Flag */ + kHIDUsage_AD_CursorBlink = 0x3A, /* Dynamic Flag */ + kHIDUsage_AD_FontReport = 0x3B, /* Logical Collection */ + kHIDUsage_AD_FontData = 0x3C, /* Buffered Byte */ + kHIDUsage_AD_CharacterWidth = 0x3D, /* Static Value */ + kHIDUsage_AD_CharacterHeight = 0x3E, /* Static Value */ + kHIDUsage_AD_CharacterSpacingHorizontal = 0x3F, /* Static Value */ + kHIDUsage_AD_CharacterSpacingVertical = 0x40, /* Static Value */ + kHIDUsage_AD_UnicodeCharacterSet = 0x41, /* Static Flag */ + /* 0x42 - 0xFFFF Reserved */ + kHIDUsage_AD_Reserved = 0xFFFF +}; + +/* Power Device Page (0x84) */ +/* This section provides detailed descriptions of the usages employed by Power Devices. */ +enum +{ + + kHIDUsage_PD_Undefined = 0x00, /* Power Device Undefined Usage */ + kHIDUsage_PD_iName = 0x01, /* CL- Power Device Name Index */ + kHIDUsage_PD_PresentStatus = 0x02, /* CL- Power Device Present Status */ + kHIDUsage_PD_ChangedStatus = 0x03, /* CA- Power Device Changed Status */ + kHIDUsage_PD_UPS = 0x04, /* CA- Uninterruptible Power Supply */ + kHIDUsage_PD_PowerSupply = 0x05, /* CA- Power Supply */ + /* Reserved 0x06 - 0x0F */ + kHIDUsage_PD_BatterySystem = 0x10, /* CP- Battery System power module */ + kHIDUsage_PD_BatterySystemID = 0x11, /* SV IF- Battery System ID */ + kHIDUsage_PD_Battery = 0x12, /* CP- Battery */ + kHIDUsage_PD_BatteryID = 0x13, /* SV IF- Battery ID */ + kHIDUsage_PD_Charger = 0x14, /* CP- Charger */ + kHIDUsage_PD_ChargerID = 0x15, /* SV IF- Charger ID */ + kHIDUsage_PD_PowerConverter = 0x16, /* CP- Power Converter power module */ + kHIDUsage_PD_PowerConverterID = 0x17, /* SV IF- Power Converter ID */ + kHIDUsage_PD_OutletSystem = 0x18, /* CP- Outlet System power module */ + kHIDUsage_PD_OutletSystemID = 0x19, /* SV IF-Outlet System ID */ + kHIDUsage_PD_Input = 0x1A, /* CP- Power Device Input */ + kHIDUsage_PD_InputID = 0x1B, /* SV IF- Power Device Input ID */ + kHIDUsage_PD_Output = 0x1C, /* CP- Power Device Output */ + kHIDUsage_PD_OutputID = 0x1D, /* SV IF- Power Device Output ID */ + kHIDUsage_PD_Flow = 0x1E, /* CP- Power Device Flow */ + kHIDUsage_PD_FlowID = 0x1F, /* Item IF- Power Device Flow ID */ + kHIDUsage_PD_Outlet = 0x20, /* CP- Power Device Outlet */ + kHIDUsage_PD_OutletID = 0x21, /* SV IF- Power Device Outlet ID */ + kHIDUsage_PD_Gang = 0x22, /* CL/CP- Power Device Gang */ + kHIDUsage_PD_GangID = 0x23, /* SV IF- Power Device Gang ID */ + kHIDUsage_PD_PowerSummary = 0x24, /* CL/CP- Power Device Power Summary */ + kHIDUsage_PD_PowerSummaryID = 0x25, /* SV IF- Power Device Power Summary ID */ + /* Reserved 0x26 - 0x2F */ + kHIDUsage_PD_Voltage = 0x30, /* DV IF- Power Device Voltage */ + kHIDUsage_PD_Current = 0x31, /* DV IF- Power Device Current */ + kHIDUsage_PD_Frequency = 0x32, /* DV IF- Power Device Frequency */ + kHIDUsage_PD_ApparentPower = 0x33, /* DV IF- Power Device Apparent Power */ + kHIDUsage_PD_ActivePower = 0x34, /* DV IF- Power Device RMS Power */ + kHIDUsage_PD_PercentLoad = 0x35, /* DV IF- Power Device Percent Load */ + kHIDUsage_PD_Temperature = 0x36, /* DV IF- Power Device Temperature */ + kHIDUsage_PD_Humidity = 0x37, /* DV IF- Power Device Humidity */ + kHIDUsage_PD_BadCount = 0x38, /* DV IF- Power Device Bad Condition Count */ + /* Reserved 0x39 - 0x3F */ + kHIDUsage_PD_ConfigVoltage = 0x40, /* SV/DV F- Power Device Nominal Voltage */ + kHIDUsage_PD_ConfigCurrent = 0x41, /* SV/DV F- Power Device Nominal Current */ + kHIDUsage_PD_ConfigFrequency = 0x42, /* SV/DV F- Power Device Nominal Frequency */ + kHIDUsage_PD_ConfigApparentPower = 0x43, /* SV/DV F- Power Device Nominal Apparent Power */ + kHIDUsage_PD_ConfigActivePower = 0x44, /* SV/DV F- Power Device Nominal RMS Power */ + kHIDUsage_PD_ConfigPercentLoad = 0x45, /* SV/DV F- Power Device Nominal Percent Load */ + kHIDUsage_PD_ConfigTemperature = 0x46, /* SV/DV F- Power Device Nominal Temperature */ + kHIDUsage_PD_ConfigHumidity = 0x47, /* SV/DV F- Power Device Nominal Humidity */ + /* Reserved 0x48 - 0x4F */ + kHIDUsage_PD_SwitchOnControl = 0x50, /* DV F- Power Device Switch On Control */ + kHIDUsage_PD_SwitchOffControl = 0x51, /* DV F- Power Device Switch Off Control */ + kHIDUsage_PD_ToggleControl = 0x52, /* DV F- Power Device Toogle Sequence Control */ + kHIDUsage_PD_LowVoltageTransfer = 0x53, /* DV F- Power Device Min Transfer Voltage */ + kHIDUsage_PD_HighVoltageTransfer = 0x54, /* DV F- Power Device Max Transfer Voltage */ + kHIDUsage_PD_DelayBeforeReboot = 0x55, /* DV F- Power Device Delay Before Reboot */ + kHIDUsage_PD_DelayBeforeStartup = 0x56, /* DV F- Power Device Delay Before Startup */ + kHIDUsage_PD_DelayBeforeShutdown = 0x57, /* DV F- Power Device Delay Before Shutdown */ + kHIDUsage_PD_Test = 0x58, /* DV F- Power Device Test Request/Result */ + kHIDUsage_PD_ModuleReset = 0x59, /* DV F- Power Device Reset Request/Result */ + kHIDUsage_PD_AudibleAlarmControl = 0x5A, /* DV F- Power Device Audible Alarm Control */ + /* Reserved 0x5B - 0x5F */ + kHIDUsage_PD_Present = 0x60, /* DV IOF- Power Device Present */ + kHIDUsage_PD_Good = 0x61, /* DV IOF- Power Device Good */ + kHIDUsage_PD_InternalFailure = 0x62, /* DV IOF- Power Device Internal Failure */ + kHIDUsage_PD_VoltageOutOfRange = 0x63, /* DV IOF- Power Device Voltage Out Of Range */ + kHIDUsage_PD_FrequencyOutOfRange = 0x64, /* DV IOF- Power Device Frequency Out Of Range */ + kHIDUsage_PD_Overload = 0x65, /* DV IOF- Power Device Overload */ + kHIDUsage_PD_OverCharged = 0x66, /* DV IOF- Power Device Over Charged */ + kHIDUsage_PD_OverTemperature = 0x67, /* DV IOF- Power Device Over Temperature */ + kHIDUsage_PD_ShutdownRequested = 0x68, /* DV IOF- Power Device Shutdown Requested */ + kHIDUsage_PD_ShutdownImminent = 0x69, /* DV IOF- Power Device Shutdown Imminent */ + /* Reserved 0x6A */ + kHIDUsage_PD_SwitchOnOff = 0x6B, /* DV IOF- Power Device On/Off Switch Status */ + kHIDUsage_PD_Switchable = 0x6C, /* DV IOF- Power Device Switchable */ + kHIDUsage_PD_Used = 0x6D, /* DV IOF- Power Device Used */ + kHIDUsage_PD_Boost = 0x6E, /* DV IOF- Power Device Boosted */ + kHIDUsage_PD_Buck = 0x6F, /* DV IOF- Power Device Bucked */ + kHIDUsage_PD_Initialized = 0x70, /* DV IOF- Power Device Initialized */ + kHIDUsage_PD_Tested = 0x71, /* DV IOF- Power Device Tested */ + kHIDUsage_PD_AwaitingPower = 0x72, /* DV IOF- Power Device Awaiting Power */ + kHIDUsage_PD_CommunicationLost = 0x73, /* DV IOF- Power Device Communication Lost */ + /* Reserved 0x74 - 0xFC */ + kHIDUsage_PD_iManufacturer = 0xFD, /* SV F- Power Device Manufacturer String Index */ + kHIDUsage_PD_iProduct = 0xFE, /* SV F- Power Device Product String Index */ + kHIDUsage_PD_iserialNumber = 0xFF /* SV F- Power Device Serial Number String Index */ +}; + +/* Battery System Page (x85) */ +/* This section provides detailed descriptions of the usages employed by Battery Systems. */ +enum +{ + kHIDUsage_BS_Undefined = 0x00, /* Battery System Undefined */ + kHIDUsage_BS_SMBBatteryMode = 0x01, /* CL - SMB Mode */ + kHIDUsage_BS_SMBBatteryStatus = 0x02, /* CL - SMB Status */ + kHIDUsage_BS_SMBAlarmWarning = 0x03, /* CL - SMB Alarm Warning */ + kHIDUsage_BS_SMBChargerMode = 0x04, /* CL - SMB Charger Mode */ + kHIDUsage_BS_SMBChargerStatus = 0x05, /* CL - SMB Charger Status */ + kHIDUsage_BS_SMBChargerSpecInfo = 0x06, /* CL - SMB Charger Extended Status */ + kHIDUsage_BS_SMBSelectorState = 0x07, /* CL - SMB Selector State */ + kHIDUsage_BS_SMBSelectorPresets = 0x08, /* CL - SMB Selector Presets */ + kHIDUsage_BS_SMBSelectorInfo = 0x09, /* CL - SMB Selector Info */ + /* Reserved 0x0A - 0x0F */ + kHIDUsage_BS_OptionalMfgFunction1 = 0x10, /* DV F - Battery System Optional SMB Mfg Function 1 */ + kHIDUsage_BS_OptionalMfgFunction2 = 0x11, /* DV F - Battery System Optional SMB Mfg Function 2 */ + kHIDUsage_BS_OptionalMfgFunction3 = 0x12, /* DV F - Battery System Optional SMB Mfg Function 3 */ + kHIDUsage_BS_OptionalMfgFunction4 = 0x13, /* DV F - Battery System Optional SMB Mfg Function 4 */ + kHIDUsage_BS_OptionalMfgFunction5 = 0x14, /* DV F - Battery System Optional SMB Mfg Function 5 */ + kHIDUsage_BS_ConnectionToSMBus = 0x15, /* DF F - Battery System Connection To System Management Bus */ + kHIDUsage_BS_OutputConnection = 0x16, /* DF F - Battery System Output Connection Status */ + kHIDUsage_BS_ChargerConnection = 0x17, /* DF F - Battery System Charger Connection */ + kHIDUsage_BS_BatteryInsertion = 0x18, /* DF F - Battery System Battery Insertion */ + kHIDUsage_BS_Usenext = 0x19, /* DF F - Battery System Use Next */ + kHIDUsage_BS_OKToUse = 0x1A, /* DF F - Battery System OK To Use */ + kHIDUsage_BS_BatterySupported = 0x1B, /* DF F - Battery System Battery Supported */ + kHIDUsage_BS_SelectorRevision = 0x1C, /* DF F - Battery System Selector Revision */ + kHIDUsage_BS_ChargingIndicator = 0x1D, /* DF F - Battery System Charging Indicator */ + /* Reserved 0x1E - 0x27 */ + kHIDUsage_BS_ManufacturerAccess = 0x28, /* DV F - Battery System Manufacturer Access */ + kHIDUsage_BS_RemainingCapacityLimit = 0x29, /* DV F - Battery System Remaining Capacity Limit */ + kHIDUsage_BS_RemainingTimeLimit = 0x2A, /* DV F - Battery System Remaining Time Limit */ + kHIDUsage_BS_AtRate = 0x2B, /* DV F - Battery System At Rate... */ + kHIDUsage_BS_CapacityMode = 0x2C, /* DV F - Battery System Capacity Mode */ + kHIDUsage_BS_BroadcastToCharger = 0x2D, /* DV F - Battery System Broadcast To Charger */ + kHIDUsage_BS_PrimaryBattery = 0x2E, /* DV F - Battery System Primary Battery */ + kHIDUsage_BS_ChargeController = 0x2F, /* DV F - Battery System Charge Controller */ + /* Reserved 0x30 - 0x3F */ + kHIDUsage_BS_TerminateCharge = 0x40, /* DF IOF - Battery System Terminate Charge */ + kHIDUsage_BS_TerminateDischarge = 0x41, /* DF IOF - Battery System Terminate Discharge */ + kHIDUsage_BS_BelowRemainingCapacityLimit = 0x42, /* DF IOF - Battery System Below Remaining Capacity Limit */ + kHIDUsage_BS_RemainingTimeLimitExpired = 0x43, /* DF IOF - Battery System Remaining Time Limit Expired */ + kHIDUsage_BS_Charging = 0x44, /* DF IOF - Battery System Charging */ + kHIDUsage_BS_Discharging = 0x45, /* DV IOF - Battery System Discharging */ + kHIDUsage_BS_FullyCharged = 0x46, /* DF IOF - Battery System Fully Charged */ + kHIDUsage_BS_FullyDischarged = 0x47, /* DV IOF - Battery System Fully Discharged */ + kHIDUsage_BS_ConditioningFlag = 0x48, /* DV IOF - Battery System Conditioning Flag */ + kHIDUsage_BS_AtRateOK = 0x49, /* DV IOF - Battery System At Rate OK */ + kHIDUsage_BS_SMBErrorCode = 0x4A, /* DF IOF - Battery System SMB Error Code */ + kHIDUsage_BS_NeedReplacement = 0x4B, /* DF IOF - Battery System Need Replacement */ + /* Reserved 0x4C - 0x5F */ + kHIDUsage_BS_AtRateTimeToFull = 0x60, /* DV IF - Battery System At Rate Time To Full */ + kHIDUsage_BS_AtRateTimeToEmpty = 0x61, /* DV IF - Battery System At Rate Time To Empty */ + kHIDUsage_BS_AverageCurrent = 0x62, /* DV IF - Battery System Average Current */ + kHIDUsage_BS_Maxerror = 0x63, /* DV IF - Battery System Max Error */ + kHIDUsage_BS_RelativeStateOfCharge = 0x64, /* DV IF - Battery System Relative State Of Charge */ + kHIDUsage_BS_AbsoluteStateOfCharge = 0x65, /* DV IF - Battery System Absolute State Of Charge */ + kHIDUsage_BS_RemainingCapacity = 0x66, /* DV IF - Battery System Remaining Capacity */ + kHIDUsage_BS_FullChargeCapacity = 0x67, /* DV IF - Battery System Full Charge Capacity */ + kHIDUsage_BS_RunTimeToEmpty = 0x68, /* DV IF - Battery System Run Time To Empty */ + kHIDUsage_BS_AverageTimeToEmpty = 0x69, /* DV IF - Battery System Average Time To Empty */ + kHIDUsage_BS_AverageTimeToFull = 0x6A, /* DV IF - Battery System Average Time To Full */ + kHIDUsage_BS_CycleCount = 0x6B, /* DV IF - Battery System Cycle Count */ + /* Reserved 0x6C - 0x7F */ + kHIDUsage_BS_BattPackModelLevel = 0x80, /* SV F - Battery System Batt Pack Model Level */ + kHIDUsage_BS_InternalChargeController = 0x81, /* SF F - Battery System Internal Charge Controller */ + kHIDUsage_BS_PrimaryBatterySupport = 0x82, /* SF F - Battery System Primary Battery Support */ + kHIDUsage_BS_DesignCapacity = 0x83, /* SV F - Battery System Design Capacity */ + kHIDUsage_BS_SpecificationInfo = 0x84, /* SV F - Battery System Specification Info */ + kHIDUsage_BS_ManufacturerDate = 0x85, /* SV F - Battery System Manufacturer Date */ + kHIDUsage_BS_SerialNumber = 0x86, /* SV F - Battery System Serial Number */ + kHIDUsage_BS_iManufacturerName = 0x87, /* SV F - Battery System Manufacturer Name Index */ + kHIDUsage_BS_iDevicename = 0x88, /* SV F - Battery System Device Name Index */ + kHIDUsage_BS_iDeviceChemistry = 0x89, /* SV F - Battery System Device Chemistry Index */ + kHIDUsage_BS_ManufacturerData = 0x8A, /* SV F - Battery System Manufacturer Data */ + kHIDUsage_BS_Rechargable = 0x8B, /* SV F - Battery System Rechargable */ + kHIDUsage_BS_WarningCapacityLimit = 0x8C, /* SV F - Battery System Warning Capacity Limit */ + kHIDUsage_BS_CapacityGranularity1 = 0x8D, /* SV F - Battery System Capacity Granularity 1 */ + kHIDUsage_BS_CapacityGranularity2 = 0x8E, /* SV F - Battery System Capacity Granularity 2 */ + kHIDUsage_BS_iOEMInformation = 0x8F, /* SV F - Battery System OEM Information Index */ + /* Reserved 0x90 - 0xBF */ + kHIDUsage_BS_InhibitCharge = 0xC0, /* DF IOF - Battery System Inhibit Charge */ + kHIDUsage_BS_EnablePolling = 0xC1, /* DF IOF - Battery System Enable Polling */ + kHIDUsage_BS_ResetToZero = 0xC2, /* DF IOF - Battery System Reset To Zero */ + /* Reserved 0xC3 - 0xCF */ + kHIDUsage_BS_ACPresent = 0xD0, /* DF IOF - Battery System AC Present */ + kHIDUsage_BS_BatteryPresent = 0xD1, /* DF IOF - Battery System Battery Present */ + kHIDUsage_BS_PowerFail = 0xD2, /* DF IOF - Battery System Power Fail */ + kHIDUsage_BS_AlarmInhibited = 0xD3, /* DF IOF - Battery System Alarm Inhibited */ + kHIDUsage_BS_ThermistorUnderRange = 0xD4, /* DF IOF - Battery System Thermistor Under Range */ + kHIDUsage_BS_ThermistorHot = 0xD5, /* DF IOF - Battery System Thermistor Hot */ + kHIDUsage_BS_ThermistorCold = 0xD6, /* DF IOF - Battery System Thermistor Cold */ + kHIDUsage_BS_ThermistorOverRange = 0xD7, /* DF IOF - Battery System Thermistor Over Range */ + kHIDUsage_BS_VoltageOutOfRange = 0xD8, /* DF IOF - Battery System Voltage Out Of Range */ + kHIDUsage_BS_CurrentOutOfRange = 0xD9, /* DF IOF - Battery System Current Out Of Range */ + kHIDUsage_BS_CurrentNotRegulated = 0xDA, /* DF IOF - Battery System Current Not Regulated */ + kHIDUsage_BS_VoltageNotRegulated = 0xDB, /* DF IOF - Battery System Voltage Not Regulated */ + kHIDUsage_BS_MasterMode = 0xDC, /* DF IOF - Battery System Master Mode */ + /* Reserved 0xDD - 0xEF */ + kHIDUsage_BS_ChargerSelectorSupport = 0xF0, /* SF F- Battery System Charger Support Selector */ + kHIDUsage_BS_ChargerSpec = 0xF1, /* SF F- Battery System Charger Specification */ + kHIDUsage_BS_Level2 = 0xF2, /* SF F- Battery System Charger Level 2 */ + kHIDUsage_BS_Level3 = 0xF3 /* SF F- Battery System Charger Level 3 */ + /* Reserved 0xF2 - 0xFF */ +}; + +/* Bar Code Scanner Page (0x8C) */ +/* This section provides detailed descriptions of the usages employed by Bar Code Scanner Devices. */ +enum +{ + kHIDUsage_BCS_Undefined = 0x00, /* Bar Code Scanner Undefined Usage */ + kHIDUsage_BCS_BadgeReader = 0x01, /* CA - Bar Code Badge Reader */ + kHIDUsage_BCS_BarCodeScanner = 0x02, /* CA -Bar Code Scanner */ + kHIDUsage_BCS_DumbBarCodeScanner = 0x03, /* CA -Dumb Bar Code Scanner Usage */ + kHIDUsage_BCS_CordlessScannerBase = 0x04, /* CA -Cordless Base Usage */ + kHIDUsage_BCS_BarCodeScannerCradle = 0x05, /* CA -Bar Code Scanner Cradle Usage */ + /* Reserved 0x06 - 0x0F */ + kHIDUsage_BCS_AttributeReport = 0x10, /* CL - Attribute Report */ + kHIDUsage_BCS_SettingsReport = 0x11, /* CL - Settings Report */ + kHIDUsage_BCS_ScannedDataReport = 0x12, /* CL - Scanned Data Report */ + kHIDUsage_BCS_RawScannedDataReport = 0x13, /* CL - Raw Scanned Data Report */ + kHIDUsage_BCS_TriggerReport = 0x14, /* CL - Trigger Report */ + kHIDUsage_BCS_StatusReport = 0x15, /* CL - Status Report */ + kHIDUsage_BCS_UPC_EANControlReport = 0x16, /* CL - UPC/EAN Control Report */ + kHIDUsage_BCS_EAN2_3LabelControlReport = 0x17, /* CL - EAN 2/3 Label Control Report */ + kHIDUsage_BCS_Code39ControlReport = 0x18, /* CL - Code 39 Control Report */ + kHIDUsage_BCS_Interleaved2of5ControlReport = 0x19, /* CL - Interleaved 2 of 5 Control Report */ + kHIDUsage_BCS_Standard2of5ControlReport = 0x1A, /* CL - Standard 2 of 5 Control Report */ + kHIDUsage_BCS_MSIPlesseyControlReport = 0x1B, /* CL - MSI Plessey Control Report */ + kHIDUsage_BCS_CodabarControlReport = 0x1C, /* CL - Codabar Control Report */ + kHIDUsage_BCS_Code128ControlReport = 0x1D, /* CL - Code 128 Control Report */ + kHIDUsage_BCS_Misc1DControlReport = 0x1E, /* CL - Misc 1D Control Report */ + kHIDUsage_BCS_2DControlReport = 0x1F, /* CL - 2D Control Report */ + /* Reserved 0x20 - 0x2F */ + kHIDUsage_BCS_Aiming_PointerMide = 0x30, /* SF - Aiming Pointer Mode */ + kHIDUsage_BCS_BarCodePresentSensor = 0x31, /* SF - Bar Code Present Sensor */ + kHIDUsage_BCS_Class1ALaser = 0x32, /* SF - Class 1A Laser */ + kHIDUsage_BCS_Class2Laser = 0x33, /* SF - Class 2 Laser */ + kHIDUsage_BCS_HeaterPresent = 0x34, /* SF - Heater Present */ + kHIDUsage_BCS_ContactScanner = 0x35, /* SF - Contact Scanner */ + kHIDUsage_BCS_ElectronicArticleSurveillanceNotification = 0x36, /* SF - Electronic Article Surveillance Notification */ + kHIDUsage_BCS_ConstantElectronicArticleSurveillance = 0x37, /* SF - Constant Electronic Article Surveillance */ + kHIDUsage_BCS_ErrorIndication = 0x38, /* SF - Error Indication */ + kHIDUsage_BCS_FixedBeeper = 0x39, /* SF - Fixed Beeper */ + kHIDUsage_BCS_GoodDecodeIndication = 0x3A, /* SF - Good Decode Indication */ + kHIDUsage_BCS_HandsFreeScanning = 0x3B, /* SF - Hands Free Scanning */ + kHIDUsage_BCS_IntrinsicallySafe = 0x3C, /* SF - Intrinsically Safe */ + kHIDUsage_BCS_KlasseEinsLaser = 0x3D, /* SF - Klasse Eins Laser */ + kHIDUsage_BCS_LongRangeScanner = 0x3E, /* SF - Long Range Scanner */ + kHIDUsage_BCS_MirrorSpeedControl = 0x3F, /* SF - Mirror Speed Control */ + kHIDUsage_BCS_NotOnFileIndication = 0x40, /* SF - Not On File Indication */ + kHIDUsage_BCS_ProgrammableBeeper = 0x41, /* SF - Programmable Beeper */ + kHIDUsage_BCS_Triggerless = 0x42, /* SF - Triggerless */ + kHIDUsage_BCS_Wand = 0x43, /* SF - Wand */ + kHIDUsage_BCS_WaterResistant = 0x44, /* SF - Water Resistant */ + kHIDUsage_BCS_MultiRangeScanner = 0x45, /* SF - Multi-Range Scanner */ + kHIDUsage_BCS_ProximitySensor = 0x46, /* SF - Proximity Sensor */ + /* Reserved 0x47 - 0x4C */ + kHIDUsage_BCS_FragmentDecoding = 0x4D, /* DF - Fragment Decoding */ + kHIDUsage_BCS_ScannerReadConfidence = 0x4E, /* DV - Scanner Read Confidence */ + kHIDUsage_BCS_DataPrefix = 0x4F, /* NAry - Data Prefix */ + kHIDUsage_BCS_PrefixAIMI = 0x50, /* SEL - Prefix AIMI */ + kHIDUsage_BCS_PrefixNone = 0x51, /* SEL - Prefix None */ + kHIDUsage_BCS_PrefixProprietary = 0x52, /* SEL - Prefix Proprietary */ + /* Reserved 0x53 - 0x54 */ + kHIDUsage_BCS_ActiveTime = 0x55, /* DV - Active Time */ + kHIDUsage_BCS_AimingLaserPattern = 0x56, /* DF - Aiming Laser Pattern */ + kHIDUsage_BCS_BarCodePresent = 0x57, /* OOC - Bar Code Present */ + kHIDUsage_BCS_BeeperState = 0x58, /* OOC - Beeper State */ + kHIDUsage_BCS_LaserOnTime = 0x59, /* DV - Laser On Time */ + kHIDUsage_BCS_LaserState = 0x5A, /* OOC - Laser State */ + kHIDUsage_BCS_LockoutTime = 0x5B, /* DV - Lockout Time */ + kHIDUsage_BCS_MotorState = 0x5C, /* OOC - Motor State */ + kHIDUsage_BCS_MotorTimeout = 0x5D, /* DV - Motor Timeout */ + kHIDUsage_BCS_PowerOnResetScanner = 0x5E, /* DF - Power On Reset Scanner */ + kHIDUsage_BCS_PreventReadOfBarcodes = 0x5F, /* DF - Prevent Read of Barcodes */ + kHIDUsage_BCS_InitiateBarcodeRead = 0x60, /* DF - Initiate Barcode Read */ + kHIDUsage_BCS_TriggerState = 0x61, /* DF - Trigger State */ + kHIDUsage_BCS_TriggerMode = 0x62, /* NAry - Trigger Mode */ + kHIDUsage_BCS_TriggerModeBlinkingLaserOn = 0x63, /* SEL - Trigger Mode Blinking Laser On */ + kHIDUsage_BCS_TriggerModeContinuousLaserOn = 0x64, /* SEL - Trigger Mode Continuous Laser On */ + kHIDUsage_BCS_TriggerModeLaserOnWhilePulled = 0x65, /* SEL - Trigger Mode Laser on while Pulled */ + kHIDUsage_BCS_TriggerModeLaserStaysOnAfterTriggerRelease = 0x66, /* SEL - Trigger Mode Laser stays on after Trigger Release */ + /* Reserved 0x67 - 0x6C */ + kHIDUsage_BCS_CommitParametersToNVM = 0x6D, /* DF - Commit Parameters to NVM */ + kHIDUsage_BCS_ParameterScanning = 0x6E, /* DF - Parameter Scanning */ + kHIDUsage_BCS_ParametersChanged = 0x6F, /* OOC - Parameters Changed */ + kHIDUsage_BCS_SetParameterDefaultValues = 0x70, /* DF - Set parameter default values */ + /* Reserved 0x71 - 0x74 */ + kHIDUsage_BCS_ScannerInCradle = 0x75, /* OOC - Scanner In Cradle */ + kHIDUsage_BCS_ScannerInRange = 0x76, /* OOC - Scanner In Range */ + /* Reserved 0x77 - 0x79 */ + kHIDUsage_BCS_AimDuration = 0x7A, /* DV - Aim Duration */ + kHIDUsage_BCS_GoodReadLampDuration = 0x7B, /* DV - Good Read Lamp Duration */ + kHIDUsage_BCS_GoodReadLampIntensity = 0x7C, /* DV - Good Read Lamp Intensity */ + kHIDUsage_BCS_GoodReadLED = 0x7D, /* DF - Good Read LED */ + kHIDUsage_BCS_GoodReadToneFrequency = 0x7E, /* DV - Good Read Tone Frequency*/ + kHIDUsage_BCS_GoodReadToneLength = 0x7F, /* DV - Good Read Tone Length */ + kHIDUsage_BCS_GoodReadToneVolume = 0x80, /* DV - Good Read Tone Volume */ + /* Reserved 0x81 */ + kHIDUsage_BCS_NoReadMessage = 0x82, /* DF - No Read Message */ + kHIDUsage_BCS_NotOnFileVolume = 0x83, /* DV - Not on File Volume */ + kHIDUsage_BCS_PowerupBeep = 0x84, /* DF - Powerup Beep */ + kHIDUsage_BCS_SoundErrorBeep = 0x85, /* DF - Sound Error Beep */ + kHIDUsage_BCS_SoundGoodReadBeep = 0x86, /* DF - Sound Good Read Beep */ + kHIDUsage_BCS_SoundNotOnFileBeep = 0x87, /* DF - Sound Not On File Beep */ + kHIDUsage_BCS_GoodReadWhenToWrite = 0x88, /* NArry - Good Read When to Write */ + kHIDUsage_BCS_GRWTIAfterDecode = 0x89, /* SEL - GRWTI After Decode */ + kHIDUsage_BCS_GRWTIBeep_LampAfterTransmit = 0x8A, /* SEL - GRWTI Beep/Lamp after transmit */ + kHIDUsage_BCS_GRWTINoBeep_LampUseAtAll = 0x8B, /* SEL - GRWTI No Beep/Lamp at all */ + /* Reserved 0x8C - 0x90 */ + kHIDUsage_BCS_BooklandEAN = 0x91, /* DF - Bookland EAN */ + kHIDUsage_BCS_ConvertEAN8To13Type = 0x92, /* DF - Convert EAN 8 to 13 Type */ + kHIDUsage_BCS_ConvertUPCAToEAN_13 = 0x93, /* DF - Convert UPC A to EAN-13 */ + kHIDUsage_BCS_ConvertUPC_EToA = 0x94, /* DF - Convert UPC-E to A */ + kHIDUsage_BCS_EAN_13 = 0x95, /* DF - EAN-13 */ + kHIDUsage_BCS_EAN_8 = 0x96, /* DF - EAN_8 */ + kHIDUsage_BCS_EAN_99_128_Mandatory = 0x97, /* DF - EAN-99 128_Mandatory */ + kHIDUsage_BCS_EAN_99_P5_128_Optional = 0x98, /* DF - EAN-99 P5/128_Optional */ + /* Reserved 0x99 */ + kHIDUsage_BCS_UPC_EAN = 0x9A, /* DF - UPC/EAN */ + kHIDUsage_BCS_UPC_EANCouponCode = 0x9B, /* DF - UPC/EAN Coupon Code */ + kHIDUsage_BCS_UPC_EANPeriodicals = 0x9C, /* DV - UPC/EAN Periodicals */ + kHIDUsage_BCS_UPC_A = 0x9D, /* DF - UPC-A */ + kHIDUsage_BCS_UPC_AWith128Mandatory = 0x9E, /* DF - UPC-A with 128 Mandatory */ + kHIDUsage_BCS_UPC_AWith128Optical = 0x9F, /* DF - UPC-A with 128 Optical */ + kHIDUsage_BCS_UPC_AWithP5Optional = 0xA0, /* DF - UPC-A with P5 Optional */ + kHIDUsage_BCS_UPC_E = 0xA1, /* DF - UPC-E */ + kHIDUsage_BCS_UPC_E1 = 0xA2, /* DF - UPC-E1 */ + /* Reserved 0xA3 - 0xA8 */ + kHIDUsage_BCS_Periodical = 0xA9, /* NArry - Periodical */ + kHIDUsage_BCS_PeriodicalAutoDiscriminatePlus2 = 0xAA,/* SEL - Periodical Auto-Discriminate + 2 */ + kHIDUsage_BCS_PeriodicalOnlyDecodeWithPlus2 = 0xAB, /* SEL - Periodical Only Decode with + 2 */ + kHIDUsage_BCS_PeriodicalIgnorePlus2 = 0xAC, /* SEL - Periodical Ignore + 2 */ + kHIDUsage_BCS_PeriodicalAutoDiscriminatePlus5 = 0xAD,/* SEL - Periodical Auto-Discriminate + 5 */ + kHIDUsage_BCS_PeriodicalOnlyDecodeWithPlus5 = 0xAE, /* SEL - Periodical Only Decode with + 5 */ + kHIDUsage_BCS_PeriodicalIgnorePlus5 = 0xAF, /* SEL - Periodical Ignore + 5 */ + kHIDUsage_BCS_Check = 0xB0, /* NArry - Check */ + kHIDUsage_BCS_CheckDisablePrice = 0xB1, /* SEL - Check Disable Price */ + kHIDUsage_BCS_CheckEnable4DigitPrice = 0xB2, /* SEL - Check Enable 4 digit Price */ + kHIDUsage_BCS_CheckEnable5DigitPrice = 0xB3, /* SEL - Check Enable 5 digit Price */ + kHIDUsage_BCS_CheckEnableEuropean4DigitPrice = 0xB4,/* SEL - Check Enable European 4 digit Price */ + kHIDUsage_BCS_CheckEnableEuropean5DigitPrice = 0xB5,/* SEL - Check Enable European 5 digit Price */ + /* Reserved 0xB6 */ + kHIDUsage_BCS_EANTwoLabel = 0xB7, /* DF - EAN Two Label */ + kHIDUsage_BCS_EANThreeLabel = 0xB8, /* DF - EAN Thread Label */ + kHIDUsage_BCS_EAN8FlagDigit1 = 0xB9, /* DV - EAN 8 Flag Digit 1 */ + kHIDUsage_BCS_EAN8FlagDigit2 = 0xBA, /* DV - EAN 8 Flag Digit 2 */ + kHIDUsage_BCS_EAN8FlagDigit3 = 0xBB, /* DV - EAN 8 Flag Digit 3 */ + kHIDUsage_BCS_EAN13FlagDigit1 = 0xBC, /* DV - EAN 13 Flag Digit 1 */ + kHIDUsage_BCS_EAN13FlagDigit2 = 0xBD, /* DV - EAN 13 Flag Digit 2 */ + kHIDUsage_BCS_EAN13FlagDigit3 = 0xBE, /* DV - EAN 13 Flag Digit 3 */ + kHIDUsage_BCS_AddEAN2_3LabelDefinition = 0xBF, /* DF - Add EAN 2/3 Label Definition */ + kHIDUsage_BCS_ClearAllEAN2_3LabelDefinitions = 0xC0,/* DF - Clear all EAN 2/3 Label Definitions */ + /* Reserved 0xC1 - 0xC2 */ + kHIDUsage_BCS_Codabar = 0xC3, /* DF - Codabar */ + kHIDUsage_BCS_Code128 = 0xC4, /* DF - Code 128 */ + /* Reserved 0xC5 - 0xC6 */ + kHIDUsage_BCS_Code39 = 0xC7, /* DF - Code 39 */ + kHIDUsage_BCS_Code93 = 0xC8, /* DF - Code 93 */ + kHIDUsage_BCS_FullASCIIConversion = 0xC9, /* DF - Full ASCII Conversion */ + kHIDUsage_BCS_Interleaved2of5 = 0xCA, /* DF - Interleaved 2 of 5 */ + kHIDUsage_BCS_ItalianPharmacyCode = 0xCB, /* DF - Italian Pharmacy Code */ + kHIDUsage_BCS_MSI_Plessey = 0xCC, /* DF - MSI/Plessey */ + kHIDUsage_BCS_Standard2of5IATA = 0xCD, /* DF - Standard 2 of 5 IATA */ + kHIDUsage_BCS_Standard2of5 = 0xCE, /* DF - Standard 2 of 5 */ + /* Reserved 0xCF - 0xD2 */ + kHIDUsage_BCS_TransmitStart_Stop = 0xD3, /* DF - Transmit Start/Stop */ + kHIDUsage_BCS_TriOptic = 0xD4, /* DF - Tri-Optic */ + kHIDUsage_BCS_UCC_EAN_128 = 0xD5, /* DF - UCC/EAN-128 */ + kHIDUsage_BCS_CheckDigit = 0xD6, /* NArry - Check Digit */ + kHIDUsage_BCS_CheckDigitDisable = 0xD7, /* SEL - Check Digit Disable */ + kHIDUsage_BCS_CheckDigitEnableInterleaved2of5OPCC = 0xD8, /* SEL - Check Digit Enable Interleaved 2 of 5 OPCC */ + kHIDUsage_BCS_CheckDigitEnableInterleaved2of5USS = 0xD9, /* SEL - Check Digit Enable Interleaved 2 of 5 USS */ + kHIDUsage_BCS_CheckDigitEnableStandard2of5OPCC = 0xD8, /* SEL - Check Digit Enable Standard 2 of 5 OPCC */ + kHIDUsage_BCS_CheckDigitEnableStandard2of5USS = 0xD9, /* SEL - Check Digit Enable Standard 2 of 5 USS */ + kHIDUsage_BCS_CheckDigitEnableOneMSIPlessey = 0xDC, /* SEL - Check Digit Enable One MSI Plessey */ + kHIDUsage_BCS_CheckDigitEnableTwoMSIPlessey = 0xDD, /* SEL - Check Digit Enable Two MSI Plessey */ + kHIDUsage_BCS_CheckDigitCodabarEnable = 0xDE, /* SEL - Check Digit Codabar Enable */ + kHIDUsage_BCS_CheckDigitCode99Enable = 0xDF, /* SEL - Check Digit Code 99 Enable */ + /* Reserved 0xE0 - 0xEF */ + kHIDUsage_BCS_TransmitCheckDigit = 0xF0, /* NArry - Transmit Check Digit */ + kHIDUsage_BCS_DisableCheckDigitTransmit = 0xF1, /* SEL - Disable Check Digit Transmit */ + kHIDUsage_BCS_EnableCheckDigitTransmit = 0xF2, /* SEL - Enable Check Digit Transmit */ + /* Reserved 0xF3 - 0xFA */ + kHIDUsage_BCS_SymbologyIdentifier1 = 0xFB, /* DV - Symbology Identifier 1 */ + kHIDUsage_BCS_SymbologyIdentifier2 = 0xFC, /* DV - Symbology Identifier 2 */ + kHIDUsage_BCS_SymbologyIdentifier3 = 0xFD, /* DV - Symbology Identifier 3 */ + kHIDUsage_BCS_DecodedData = 0xFE, /* DV - Decoded Data */ + kHIDUsage_BCS_DecodeDataContinued = 0xFF, /* DF - Decode Data Continued */ + kHIDUsage_BCS_BarSpaceData = 0x100, /* DV - Bar Space Data */ + kHIDUsage_BCS_ScannerDataAccuracy = 0x101, /* DV - Scanner Data Accuracy */ + kHIDUsage_BCS_RawDataPolarity = 0x102, /* NArry - Raw Data Polarity */ + kHIDUsage_BCS_PolarityInvertedBarCode = 0x103, /* SEL - Polarity Inverted Bar Code */ + kHIDUsage_BCS_PolarityNormalBarCode = 0x103, /* SEL - Polarity Normal Bar Code */ + /* Reserved 0x105 */ + kHIDUsage_BCS_MinimumLengthToDecode = 0x106, /* DV - Minimum Length to Decode */ + kHIDUsage_BCS_MaximumLengthToDecode = 0x107, /* DV - Maximum Length to Decode */ + kHIDUsage_BCS_FirstDiscreteLengthToDecode = 0x108, /* DV - First Discrete Length to Decode */ + kHIDUsage_BCS_SecondDiscreteLengthToDecode = 0x109, /* DV - Second Discrete Length to Decode */ + kHIDUsage_BCS_DataLengthMethod = 0x10A, /* NArry - Data Length Method */ + kHIDUsage_BCS_DLMethodReadAny = 0x10B, /* DF - DL Method Read any */ + kHIDUsage_BCS_DLMethodCheckInRange = 0x10C, /* DF - DL Method Check in Range */ + kHIDUsage_BCS_DLMethodCheckForDiscrete = 0x10D, /* DF - DL Method Check for Discrete */ + /* Reserved 0x10E - 0x10F */ + kHIDUsage_BCS_AztecCode = 0x110, /* DF - Aztec Code */ + kHIDUsage_BCS_BC412 = 0x111, /* DF - BC412 */ + kHIDUsage_BCS_ChannelCode = 0x112, /* DF - Channel Code */ + kHIDUsage_BCS_Code16 = 0x113, /* DF - Code 16 */ + kHIDUsage_BCS_Code32 = 0x114, /* DF - Code 32 */ + kHIDUsage_BCS_Code49 = 0x115, /* DF - Code 49 */ + kHIDUsage_BCS_CodeOne = 0x116, /* DF - Code One */ + kHIDUsage_BCS_Colorcode = 0x117, /* DF - Colorcode */ + kHIDUsage_BCS_DataMatrix = 0x118, /* DF - Data Matrix */ + kHIDUsage_BCS_MaxiCode = 0x119, /* DF - MaxiCode */ + kHIDUsage_BCS_MicroPDF = 0x11A, /* DF - MicroPDF */ + kHIDUsage_BCS_PDF_417 = 0x11B, /* DF - PDF-417 */ + kHIDUsage_BCS_PosiCode = 0x11C, /* DF - PosiCode */ + kHIDUsage_BCS_QRCode = 0x11D, /* DF - QR Code */ + kHIDUsage_BCS_SuperCode = 0x11E, /* DF - SuperCode */ + kHIDUsage_BCS_UltraCode = 0x11F, /* DF - UltraCode */ + kHIDUsage_BCS_USB_5_SlugCode = 0x120, /* DF - USD-5 (Slug Code) */ + kHIDUsage_BCS_VeriCode = 0x121 /* DF - VeriCode */ + /* Reserved 0x122 - 0xFFFF */ +}; + +/* Weighing Devices Page (0x8D) */ +/* This section provides detailed descriptions of the usages employed by Weighing Devices. */ +enum +{ + kHIDUsage_WD_Undefined = 0x00, /* Weighing Device Undefined Usage */ + kHIDUsage_WD_WeighingDevice = 0x01, /* CA - Weighing Device */ + /* Reserved 0x02 - 0x1F */ + kHIDUsage_WD_ScaleScaleDevice = 0x20, /* CL - Scale Device */ + kHIDUsage_WD_ScaleScaleClassIMetricCL = 0x21, /* CL - Scale Class I Metric */ + kHIDUsage_WD_ScaleScaleClassIMetric = 0x22, /* SEL - Scale Class I Metric */ + kHIDUsage_WD_ScaleScaleClassIIMetric = 0x23, /* SEL - Scale Class II Metric */ + kHIDUsage_WD_ScaleScaleClassIIIMetric = 0x24, /* SEL - Scale Class III Metric */ + kHIDUsage_WD_ScaleScaleClassIIILMetric = 0x25, /* SEL - Scale Class IIIL Metric */ + kHIDUsage_WD_ScaleScaleClassIVMetric = 0x26, /* SEL - Scale Class IV Metric */ + kHIDUsage_WD_ScaleScaleClassIIIEnglish = 0x27, /* SEL - Scale Class III English */ + kHIDUsage_WD_ScaleScaleClassIIILEnglish = 0x28, /* SEL - Scale Class IIIL English */ + kHIDUsage_WD_ScaleScaleClassIVEnglish = 0x29, /* SEL - Scale Class IV English */ + kHIDUsage_WD_ScaleScaleClassGeneric = 0x2A, /* SEL - Scale Class Generic */ + /* Reserved 0x2B - 0x2F */ + kHIDUsage_WD_ScaleAtrributeReport = 0x30, /* CL - Scale Attribute Report */ + kHIDUsage_WD_ScaleControlReport = 0x31, /* CL - Scale Control Report */ + kHIDUsage_WD_ScaleDataReport = 0x32, /* CL - Scale Data Report */ + kHIDUsage_WD_ScaleStatusReport = 0x33, /* CL - Scale Status Report */ + kHIDUsage_WD_ScaleWeightLimitReport = 0x34, /* CL - Scale Weight Limit Report */ + kHIDUsage_WD_ScaleStatisticsReport = 0x35, /* CL - Scale Statistics Report */ + /* Reserved 0x36 - 0x3F */ + kHIDUsage_WD_DataWeight = 0x40, /* DV - Data Weight */ + kHIDUsage_WD_DataScaling = 0x41, /* DV - Data Scaling */ + /* Reserved 0x42 - 0x4F */ + kHIDUsage_WD_WeightUnit = 0x50, /* CL - Weight Unit */ + kHIDUsage_WD_WeightUnitMilligram = 0x51, /* SEL - Weight Unit Milligram */ + kHIDUsage_WD_WeightUnitGram = 0x52, /* SEL - Weight Unit Gram */ + kHIDUsage_WD_WeightUnitKilogram = 0x53, /* SEL - Weight Unit Kilogram */ + kHIDUsage_WD_WeightUnitCarats = 0x54, /* SEL - Weight Unit Carats */ + kHIDUsage_WD_WeightUnitTaels = 0x55, /* SEL - Weight Unit Taels */ + kHIDUsage_WD_WeightUnitGrains = 0x56, /* SEL - Weight Unit Grains */ + kHIDUsage_WD_WeightUnitPennyweights = 0x57, /* SEL - Weight Unit Pennyweights */ + kHIDUsage_WD_WeightUnitMetricTon = 0x58, /* SEL - Weight Unit Metric Ton */ + kHIDUsage_WD_WeightUnitAvoirTon = 0x59, /* SEL - Weight Unit Avoir Ton */ + kHIDUsage_WD_WeightUnitTroyOunce = 0x5A, /* SEL - Weight Unit Troy Ounce */ + kHIDUsage_WD_WeightUnitOunce = 0x5B, /* SEL - Weight Unit Ounce */ + kHIDUsage_WD_WeightUnitPound = 0x5C, /* SEL - Weight Unit Pound */ + /* Reserved 0x5D - 0x5F */ + kHIDUsage_WD_CalibrationCount = 0x60, /* DV - Calibration Count */ + kHIDUsage_WD_RezeroCount = 0x61, /* DV - Re-Zero Count*/ + /* Reserved 0x62 - 0x6F */ + kHIDUsage_WD_ScaleStatus = 0x70, /* CL - Scale Status */ + kHIDUsage_WD_ScaleStatusFault = 0x71, /* SEL - Scale Status Fault */ + kHIDUsage_WD_ScaleStatusStableAtZero = 0x72, /* SEL - Scale Status Stable at Center of Zero */ + kHIDUsage_WD_ScaleStatusInMotion = 0x73, /* SEL - Scale Status In Motion */ + kHIDUsage_WD_ScaleStatusWeightStable = 0x74, /* SEL - Scale Status Weight Stable */ + kHIDUsage_WD_ScaleStatusUnderZero = 0x75, /* SEL - Scale Status Under Zero */ + kHIDUsage_WD_ScaleStatusOverWeightLimit = 0x76, /* SEL - Scale Status Over Weight Limit */ + kHIDUsage_WD_ScaleStatusRequiresCalibration = 0x77, /* SEL - Scale Status Requires Calibration */ + kHIDUsage_WD_ScaleStatusRequiresRezeroing = 0x78, /* SEL - Scale Status Requires Re-zeroing */ + /* Reserved 0x79 - 0x7F */ + kHIDUsage_WD_ZeroScale = 0x80, /* OOC - Zero Scale */ + kHIDUsage_WD_EnforcedZeroReturn = 0x81 /* OOC - Enforced Zero Return */ + /* Reserved 0x82 - 0xFFFF */ + +}; + +/* Magnetic Stripe Reader Page (0x8E) */ +/* This section provides detailed descriptions of the usages employed by Magnetic Stripe Reader Devices. */ +enum +{ + kHIDUsage_MSR_Undefined = 0x00, /* MagStripe Undefined Usage */ + kHIDUsage_MSR_DeviceReadOnly = 0x01, /* CA - MSR Device Read-Only */ + /* Reserved 0x02 - 0x10 */ + kHIDUsage_MSR_Track1Length = 0x11, /* SF, DF, SEL - Track 1 Length */ + kHIDUsage_MSR_Track2Length = 0x12, /* SF, DF, SEL - Track 2 Length */ + kHIDUsage_MSR_Track3Length = 0x13, /* SF, DF, SEL - Track 3 Length */ + kHIDUsage_MSR_TrackJISLength = 0x14, /* SF, DF, SEL - Track JIS Length */ + /* Reserved 0x15 - 0x1F */ + kHIDUsage_MSR_TrackData = 0x20, /* SF, DF, SEL - Track Data */ + kHIDUsage_MSR_Track1Data = 0x21, /* SF, DF, SEL - Track 1 Data */ + kHIDUsage_MSR_Track2Data = 0x22, /* SF, DF, SEL - Track 2 Data */ + kHIDUsage_MSR_Track3Data = 0x23, /* SF, DF, SEL - Track 3 Data */ + kHIDUsage_MSR_TrackJISData = 0x24 /* SF, DF, SEL - Track JIS Data */ + /* Reserved 0x25 - 0xFFFF */ +}; + +#endif /* _IOHIDUSAGETABLES_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/hid/IOHIDInterface.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/hid/IOHIDInterface.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/hid/IOHIDInterface.h (revision 885) @@ -0,0 +1,252 @@ +/* + * + * @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_IOHIDINTERFACE_H +#define _IOKIT_HID_IOHIDINTERFACE_H + +#include +#include + +class IOHIDDevice; + +/*! @class IOHIDInterface : public IOService + @abstract In kernel interface to a HID device. + @discussion +*/ + +class IOHIDInterface: public IOService +{ + OSDeclareDefaultStructors( IOHIDInterface ) + +public: + + /*! @typedef IOHIDInterface::InterruptReportAction + @abstract Callback to handle an asynchronous report received from + the HID device. + @discussion This callback is set when calling IOHIDInterface::open. + @param target Pointer to your data object. + @param timestamp Time when the report was delivered. + @param report A memory descriptor that describes the report. + @param reportType The type of report. + @param reportID The ID of the report. + @param refcon void * pointer to more data. + */ + typedef void (*InterruptReportAction)( + OSObject * target, + AbsoluteTime timestamp, + IOMemoryDescriptor * report, + IOHIDReportType type, + UInt32 reportID, + void * refcon); + + /*! + @typedef IOHIDInterface::CompletionAction + @discussion Function called when HID I/O completes. + @param target + @param refcon + @param status Completion status. + @param bufferSizeRemaining Bytes left to be transferred. + */ + + typedef void (*CompletionAction)( + OSObject * target, + void * refcon, + IOReturn status, + UInt32 bufferSizeRemaining); + +private: + IOHIDDevice * _owner; + OSArray * _elementArray; + InterruptReportAction _interruptAction; + void * _interruptRefCon; + OSObject * _interruptTarget; + OSString * _transportString; + OSString * _manufacturerString; + OSString * _productString; + OSString * _serialNumberString; + UInt32 _locationID; + UInt32 _vendorID; + UInt32 _vendorIDSource; + UInt32 _productID; + UInt32 _version; + UInt32 _countryCode; + IOByteCount _maxReportSize[kIOHIDReportTypeCount]; + + struct ExpansionData { + UInt32 reportInterval; + }; + /*! @var reserved + Reserved for future use. (Internal use only) */ + ExpansionData * _reserved; + +protected: + + /*! + @function free + @abstract Free the IOHIDInterface object. + @discussion Release all resources that were previously allocated, + then call super::free() to propagate the call to our superclass. + */ + + virtual void free(); + +public: + + static IOHIDInterface * withElements ( OSArray * elements ); + + /*! + @function init + @abstract Initialize an IOHIDInterface object. + @discussion Prime the IOHIDInterface object and prepare it to support + a probe() or a start() call. This implementation will simply call + super::init(). + @param A dictionary A property table associated with this IOHIDInterface + instance. + @result True on sucess, or false otherwise. + */ + + virtual bool init( OSDictionary * dictionary = 0 ); + + /*! + @function start + @abstract Start up the driver using the given provider. + @discussion IOHIDInterface will allocate resources. Before returning true + to indicate success, registerService() is called to trigger client matching. + @param provider The provider that the driver was matched to, and selected + to run with. + @result True on success, or false otherwise. + */ + + virtual bool start( IOService * provider ); + + /*! + @function matchPropertyTable + @abstract Called by the provider during a match + @discussion Compare the properties in the supplied table to this + object's properties. + @param table The property table that this device will match against + */ + + virtual bool matchPropertyTable( + OSDictionary * table, + SInt32 * score); + + virtual bool open ( + IOService * client, + IOOptionBits options, + InterruptReportAction action, + void * refCon); + + virtual void close( + IOService * client, + IOOptionBits options = 0 ); + + 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 IOByteCount getMaxReportSize (IOHIDReportType type); + + virtual OSArray * createMatchingElements ( + OSDictionary * matching = 0, + IOOptionBits options = 0); + + virtual void handleReport ( + AbsoluteTime timeStamp, + IOMemoryDescriptor * report, + IOHIDReportType reportType, + UInt32 reportID, + IOOptionBits options = 0); + + virtual IOReturn setReport ( + IOMemoryDescriptor * report, + IOHIDReportType reportType, + UInt32 reportID = 0, + IOOptionBits options = 0); + + virtual IOReturn getReport ( + IOMemoryDescriptor * report, + IOHIDReportType reportType, + UInt32 reportID = 0, + IOOptionBits options = 0); + + virtual IOReturn setReport ( + IOMemoryDescriptor * report, + IOHIDReportType reportType, + UInt32 reportID = 0, + IOOptionBits options = 0, + UInt32 completionTimeout = 0, + CompletionAction * completion = 0); + + virtual IOReturn getReport ( + IOMemoryDescriptor * report, + IOHIDReportType reportType, + UInt32 reportID = 0, + IOOptionBits options = 0, + UInt32 completionTimeout = 0, + CompletionAction * completion = 0); + + OSMetaClassDeclareReservedUsed(IOHIDInterface, 0); + virtual UInt32 getReportInterval (); + + OSMetaClassDeclareReservedUnused(IOHIDInterface, 1); + OSMetaClassDeclareReservedUnused(IOHIDInterface, 2); + OSMetaClassDeclareReservedUnused(IOHIDInterface, 3); + OSMetaClassDeclareReservedUnused(IOHIDInterface, 4); + OSMetaClassDeclareReservedUnused(IOHIDInterface, 5); + OSMetaClassDeclareReservedUnused(IOHIDInterface, 6); + OSMetaClassDeclareReservedUnused(IOHIDInterface, 7); + OSMetaClassDeclareReservedUnused(IOHIDInterface, 8); + OSMetaClassDeclareReservedUnused(IOHIDInterface, 9); + OSMetaClassDeclareReservedUnused(IOHIDInterface, 10); + OSMetaClassDeclareReservedUnused(IOHIDInterface, 11); + OSMetaClassDeclareReservedUnused(IOHIDInterface, 12); + OSMetaClassDeclareReservedUnused(IOHIDInterface, 13); + OSMetaClassDeclareReservedUnused(IOHIDInterface, 14); + OSMetaClassDeclareReservedUnused(IOHIDInterface, 15); + OSMetaClassDeclareReservedUnused(IOHIDInterface, 16); + OSMetaClassDeclareReservedUnused(IOHIDInterface, 17); + OSMetaClassDeclareReservedUnused(IOHIDInterface, 18); + OSMetaClassDeclareReservedUnused(IOHIDInterface, 19); + OSMetaClassDeclareReservedUnused(IOHIDInterface, 20); + OSMetaClassDeclareReservedUnused(IOHIDInterface, 21); + OSMetaClassDeclareReservedUnused(IOHIDInterface, 22); + OSMetaClassDeclareReservedUnused(IOHIDInterface, 23); + OSMetaClassDeclareReservedUnused(IOHIDInterface, 24); + OSMetaClassDeclareReservedUnused(IOHIDInterface, 25); + OSMetaClassDeclareReservedUnused(IOHIDInterface, 26); + OSMetaClassDeclareReservedUnused(IOHIDInterface, 27); + OSMetaClassDeclareReservedUnused(IOHIDInterface, 28); + OSMetaClassDeclareReservedUnused(IOHIDInterface, 29); + OSMetaClassDeclareReservedUnused(IOHIDInterface, 30); + OSMetaClassDeclareReservedUnused(IOHIDInterface, 31); +}; + +#endif /* !_IOKIT_HID_IOHIDINTERFACE_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/hid/IOHIDElement.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/hid/IOHIDElement.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/hid/IOHIDElement.h (revision 885) @@ -0,0 +1,106 @@ +/* + * + * @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_IOHIDELEMENT_H +#define _IOKIT_HID_IOHIDELEMENT_H + +#include +#include +#include + +//=========================================================================== +// An object that describes a single HID element. + +class IOHIDElement: public OSObject +{ + OSDeclareAbstractStructors( IOHIDElement ) + + struct ExpansionData { + }; + /*! @var reserved + Reserved for future use. (Internal use only) */ + ExpansionData * _reserved; + + +public: + + virtual IOHIDElementCookie getCookie() = 0; + virtual IOHIDElement * getParentElement() = 0; + virtual OSArray * getChildElements() = 0; + virtual IOHIDElementType getType() = 0; + virtual IOHIDElementCollectionType getCollectionType() = 0; + virtual UInt32 getUsagePage() = 0; + virtual UInt32 getUsage() = 0; + virtual UInt32 getLogicalMin() = 0; + virtual UInt32 getLogicalMax() = 0; + virtual UInt32 getPhysicalMin() = 0; + virtual UInt32 getPhysicalMax() = 0; + virtual UInt32 getUnitExponent() = 0; + virtual UInt32 getUnit() = 0; + virtual UInt32 getReportSize() = 0; + virtual UInt32 getReportCount() = 0; + virtual UInt32 getReportID() = 0; + virtual UInt32 getFlags() = 0; + virtual AbsoluteTime getTimeStamp() = 0; + virtual UInt32 getValue() = 0; + virtual OSData * getDataValue() = 0; + virtual void setValue(UInt32 value) = 0; + virtual void setDataValue(OSData * value) = 0; + + OSMetaClassDeclareReservedUnused(IOHIDElement, 0); + OSMetaClassDeclareReservedUnused(IOHIDElement, 1); + OSMetaClassDeclareReservedUnused(IOHIDElement, 2); + OSMetaClassDeclareReservedUnused(IOHIDElement, 3); + OSMetaClassDeclareReservedUnused(IOHIDElement, 4); + OSMetaClassDeclareReservedUnused(IOHIDElement, 5); + OSMetaClassDeclareReservedUnused(IOHIDElement, 6); + OSMetaClassDeclareReservedUnused(IOHIDElement, 7); + OSMetaClassDeclareReservedUnused(IOHIDElement, 8); + OSMetaClassDeclareReservedUnused(IOHIDElement, 9); + OSMetaClassDeclareReservedUnused(IOHIDElement, 10); + OSMetaClassDeclareReservedUnused(IOHIDElement, 11); + OSMetaClassDeclareReservedUnused(IOHIDElement, 12); + OSMetaClassDeclareReservedUnused(IOHIDElement, 13); + OSMetaClassDeclareReservedUnused(IOHIDElement, 14); + OSMetaClassDeclareReservedUnused(IOHIDElement, 15); + OSMetaClassDeclareReservedUnused(IOHIDElement, 16); + OSMetaClassDeclareReservedUnused(IOHIDElement, 17); + OSMetaClassDeclareReservedUnused(IOHIDElement, 18); + OSMetaClassDeclareReservedUnused(IOHIDElement, 19); + OSMetaClassDeclareReservedUnused(IOHIDElement, 20); + OSMetaClassDeclareReservedUnused(IOHIDElement, 21); + OSMetaClassDeclareReservedUnused(IOHIDElement, 22); + OSMetaClassDeclareReservedUnused(IOHIDElement, 23); + OSMetaClassDeclareReservedUnused(IOHIDElement, 24); + OSMetaClassDeclareReservedUnused(IOHIDElement, 25); + OSMetaClassDeclareReservedUnused(IOHIDElement, 26); + OSMetaClassDeclareReservedUnused(IOHIDElement, 27); + OSMetaClassDeclareReservedUnused(IOHIDElement, 28); + OSMetaClassDeclareReservedUnused(IOHIDElement, 29); + OSMetaClassDeclareReservedUnused(IOHIDElement, 30); + OSMetaClassDeclareReservedUnused(IOHIDElement, 31); + +}; + +#endif /* !_IOKIT_HID_IOHIDELEMENT_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/hid/IOHIDKeys.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/hid/IOHIDKeys.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/hid/IOHIDKeys.h (revision 885) @@ -0,0 +1,349 @@ +/* + * + * @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_IOHIDKEYS_H_ +#define _IOKIT_HID_IOHIDKEYS_H_ + +#include +#include + +__BEGIN_DECLS + +/* The following keys are used to search the IORegistry for HID related services +*/ + +/* This is used to find HID Devices in the IORegistry */ +#define kIOHIDDeviceKey "IOHIDDevice" + +/*! + @defined HID Device Property Keys + @abstract Keys that represent properties of a paticular device. + @discussion Keys that represent properties of a paticular device. Can be added + to your matching dictionary when refining searches for HID devices. +

+ Please note:
+ kIOHIDPrimaryUsageKey and kIOHIDPrimaryUsagePageKey are no longer + rich enough to describe a device's capabilities. Take, for example, a + device that describes both a keyboard and a mouse in the same descriptor. + The previous behavior was to only describe the keyboard behavior with the + primary usage and usage page. Needless to say, this would sometimes cause + a program interested in mice to skip this device when matching. +
+ Thus we have added 3 + additional keys: +
    +
  • kIOHIDDeviceUsageKey
  • +
  • kIOHIDDeviceUsagePageKey
  • +
  • kIOHIDDeviceUsagePairsKey
  • +
+ kIOHIDDeviceUsagePairsKey is used to represent an array of dictionaries containing + key/value pairs referenced by kIOHIDDeviceUsageKey and kIOHIDDeviceUsagePageKey. + These usage pairs describe all application type collections (behaviors) defined + by the device. +

+ An application intersted in only matching on one criteria would only add the + kIOHIDDeviceUsageKey and kIOHIDDeviceUsagePageKey keys to the matching dictionary. + If it is interested in a device that has multiple behaviors, the application would + instead add an array or dictionaries referenced by kIOHIDDeviceUsagePairsKey to his + matching dictionary. +*/ +#define kIOHIDTransportKey "Transport" +#define kIOHIDVendorIDKey "VendorID" +#define kIOHIDVendorIDSourceKey "VendorIDSource" +#define kIOHIDProductIDKey "ProductID" +#define kIOHIDVersionNumberKey "VersionNumber" +#define kIOHIDManufacturerKey "Manufacturer" +#define kIOHIDProductKey "Product" +#define kIOHIDSerialNumberKey "SerialNumber" +#define kIOHIDCountryCodeKey "CountryCode" +#define kIOHIDStandardTypeKey "StandardType" +#define kIOHIDLocationIDKey "LocationID" +#define kIOHIDDeviceUsageKey "DeviceUsage" +#define kIOHIDDeviceUsagePageKey "DeviceUsagePage" +#define kIOHIDDeviceUsagePairsKey "DeviceUsagePairs" +#define kIOHIDPrimaryUsageKey "PrimaryUsage" +#define kIOHIDPrimaryUsagePageKey "PrimaryUsagePage" +#define kIOHIDMaxInputReportSizeKey "MaxInputReportSize" +#define kIOHIDMaxOutputReportSizeKey "MaxOutputReportSize" +#define kIOHIDMaxFeatureReportSizeKey "MaxFeatureReportSize" +#define kIOHIDReportIntervalKey "ReportInterval" +#define kIOHIDReportDescriptorKey "ReportDescriptor" + +/*! + @define kIOHIDElementKey + @abstract Keys that represents an element property. + @discussion Property for a HID Device or element dictionary. + Elements can be heirarchical, so they can contain other elements. +*/ +#define kIOHIDElementKey "Elements" + +/*! + @defined HID Element Dictionary Keys + @abstract Keys that represent properties of a particular elements. + @discussion These keys can also be added to a matching dictionary + when searching for elements via copyMatchingElements. +*/ +#define kIOHIDElementCookieKey "ElementCookie" +#define kIOHIDElementTypeKey "Type" +#define kIOHIDElementCollectionTypeKey "CollectionType" +#define kIOHIDElementUsageKey "Usage" +#define kIOHIDElementUsagePageKey "UsagePage" +#define kIOHIDElementMinKey "Min" +#define kIOHIDElementMaxKey "Max" +#define kIOHIDElementScaledMinKey "ScaledMin" +#define kIOHIDElementScaledMaxKey "ScaledMax" +#define kIOHIDElementSizeKey "Size" +#define kIOHIDElementReportSizeKey "ReportSize" +#define kIOHIDElementReportCountKey "ReportCount" +#define kIOHIDElementReportIDKey "ReportID" +#define kIOHIDElementIsArrayKey "IsArray" +#define kIOHIDElementIsRelativeKey "IsRelative" +#define kIOHIDElementIsWrappingKey "IsWrapping" +#define kIOHIDElementIsNonLinearKey "IsNonLinear" +#define kIOHIDElementHasPreferredStateKey "HasPreferredState" +#define kIOHIDElementHasNullStateKey "HasNullState" +#define kIOHIDElementFlagsKey "Flags" +#define kIOHIDElementUnitKey "Unit" +#define kIOHIDElementUnitExponentKey "UnitExponent" +#define kIOHIDElementNameKey "Name" +#define kIOHIDElementValueLocationKey "ValueLocation" +#define kIOHIDElementDuplicateIndexKey "DuplicateIndex" +#define kIOHIDElementParentCollectionKey "ParentCollection" + +#ifndef __ppc__ + #define kIOHIDElementVendorSpecificKey "VendorSpecific" +#else + #define kIOHIDElementVendorSpecificKey "VendorSpecifc" +#endif + +/*! + @defined HID Element Match Keys + @abstract Keys used for matching particular elements. + @discussion These keys should only be used with a matching + dictionary when searching for elements via copyMatchingElements. +*/ +#define kIOHIDElementCookieMinKey "ElementCookieMin" +#define kIOHIDElementCookieMaxKey "ElementCookieMax" +#define kIOHIDElementUsageMinKey "UsageMin" +#define kIOHIDElementUsageMaxKey "UsageMax" + +/*! + @defined kIOHIDElementCalibrationMinKey + @abstract The minimum bounds for a calibrated value. +*/ +#define kIOHIDElementCalibrationMinKey "CalibrationMin" + +/*! + @defined kIOHIDElementCalibrationMaxKey + @abstract The maximum bounds for a calibrated value. +*/ +#define kIOHIDElementCalibrationMaxKey "CalibrationMax" + +/*! + @defined kIOHIDElementCalibrationSaturationMinKey + @abstract The mininum tolerance to be used when calibrating a logical element value. + @discussion The saturation property is used to allow for slight differences in the minimum and maximum value returned by an element. +*/ +#define kIOHIDElementCalibrationSaturationMinKey "CalibrationSaturationMin" + +/*! + @defined kIOHIDElementCalibrationSaturationMaxKey + @abstract The maximum tolerance to be used when calibrating a logical element value. + @discussion The saturation property is used to allow for slight differences in the minimum and maximum value returned by an element. +*/ +#define kIOHIDElementCalibrationSaturationMaxKey "CalibrationSaturationMax" + +/*! + @defined kIOHIDElementCalibrationDeadZoneMinKey + @abstract The minimum bounds near the midpoint of a logical value in which the value is ignored. + @discussion The dead zone property is used to allow for slight differences in the idle value returned by an element. +*/ +#define kIOHIDElementCalibrationDeadZoneMinKey "CalibrationDeadZoneMin" + +/*! + @defined kIOHIDElementCalibrationDeadZoneMinKey + @abstract The maximum bounds near the midpoint of a logical value in which the value is ignored. + @discussion The dead zone property is used to allow for slight differences in the idle value returned by an element. +*/ +#define kIOHIDElementCalibrationDeadZoneMaxKey "CalibrationDeadZoneMax" + +/*! + @defined kIOHIDElementCalibrationGranularityKey + @abstract The scale or level of detail returned in a calibrated element value. + @discussion Values are rounded off such that if granularity=0.1, values after calibration are 0, 0.1, 0.2, 0.3, etc. +*/ +#define kIOHIDElementCalibrationGranularityKey "CalibrationGranularity" + +/*! + @typedef IOHIDElementCookie + @abstract Abstract data type used as a unique identifier for an element. +*/ +#ifdef __LP64__ + typedef uint32_t IOHIDElementCookie; +#else + typedef void * IOHIDElementCookie; +#endif + +/*! + @typedef IOHIDElementType + @abstract Describes different types of HID elements. + @discussion Used by the IOHIDFamily to identify the type of + element processed. Represented by the key kIOHIDElementTypeKey in the + dictionary describing the element. + @constant kIOHIDElementTypeInput_Misc + Misc input data field or varying size. + @constant kIOHIDElementTypeInput_Button + One bit input data field. + @constant kIOHIDElementTypeInput_Axis + Input data field used to represent an axis. + @constant kIOHIDElementTypeInput_ScanCodes + Input data field used to represent a scan code or usage selector. + @constant kIOHIDElementTypeOutput + Used to represent an output data field in a report. + @constant kIOHIDElementTypeFeature + Describes input and output elements not intended for + consumption by the end user. + @constant kIOHIDElementTypeCollection + Element used to identify a relationship between two or more elements. +*/ +enum IOHIDElementType { + kIOHIDElementTypeInput_Misc = 1, + kIOHIDElementTypeInput_Button = 2, + kIOHIDElementTypeInput_Axis = 3, + kIOHIDElementTypeInput_ScanCodes = 4, + kIOHIDElementTypeOutput = 129, + kIOHIDElementTypeFeature = 257, + kIOHIDElementTypeCollection = 513 +}; +typedef enum IOHIDElementType IOHIDElementType; + +/*! + @typedef IOHIDElementCollectionType + @abstract Describes different types of HID collections. + @discussion Collections identify a relationship between two or more + elements. + @constant kIOHIDElementCollectionTypePhysical + Used for a set of data items that represent data points + collected at one geometric point. + @constant kIOHIDElementCollectionTypeApplication + Identifies item groups serving different purposes in a single device. + @constant kIOHIDElementCollectionTypeLogical + Used when a set of data items form a composite data structure. + @constant kIOHIDElementCollectionTypeReport + Wraps all the fields in a report. + @constant kIOHIDElementCollectionTypeNamedArray + Contains an array of selector usages. + @constant kIOHIDElementCollectionTypeUsageSwitch + Modifies the meaning of the usage it contains. + @constant kIOHIDElementCollectionTypeUsageModifier + Modifies the meaning of the usage attached to the encompassing collection. +*/ +enum IOHIDElementCollectionType{ + kIOHIDElementCollectionTypePhysical = 0x00, + kIOHIDElementCollectionTypeApplication, + kIOHIDElementCollectionTypeLogical, + kIOHIDElementCollectionTypeReport, + kIOHIDElementCollectionTypeNamedArray, + kIOHIDElementCollectionTypeUsageSwitch, + kIOHIDElementCollectionTypeUsageModifier +}; +typedef enum IOHIDElementCollectionType IOHIDElementCollectionType; + + +/*! + @typedef IOHIDReportType + @abstract Describes different type of HID reports. + @discussion Used by the IOHIDFamily to identify the type of + report being processed. + @constant kIOHIDReportTypeInput Input report. + @constant kIOHIDReportTypeOutput Output report. + @constant kIOHIDReportTypeFeature Feature report. +*/ +enum IOHIDReportType{ + kIOHIDReportTypeInput = 0, + kIOHIDReportTypeOutput, + kIOHIDReportTypeFeature, + kIOHIDReportTypeCount +}; +typedef enum IOHIDReportType IOHIDReportType; + +/*! + @typedef IOHIDOptionsType + @abstract Options for opening a device via IOHIDLib. + @constant kIOHIDOptionsTypeNone Default option. + @constant kIOHIDOptionsTypeSeizeDevice Used to open exclusive + communication with the device. This will prevent the system + and other clients from receiving events from the device. +*/ +enum { + kIOHIDOptionsTypeNone = 0x00, + kIOHIDOptionsTypeSeizeDevice = 0x01 +}; +typedef uint32_t IOHIDOptionsType; + + +/*! + @typedef IOHIDQueueOptionsType + @abstract Options for creating a queue via IOHIDLib. + @constant kIOHIDQueueOptionsTypeNone Default option. + @constant kIOHIDQueueOptionsTypeEnqueueAll Force the IOHIDQueue + to enqueue all events, relative or absolute, regardless of change. +*/ +enum { + kIOHIDQueueOptionsTypeNone = 0x00, + kIOHIDQueueOptionsTypeEnqueueAll = 0x01 +}; +typedef uint32_t IOHIDQueueOptionsType; + + +enum { + kIOHIDElementFlagsConstantMask = 0x0001, + kIOHIDElementFlagsVariableMask = 0x0002, + kIOHIDElementFlagsRelativeMask = 0x0004, + kIOHIDElementFlagsWrapMask = 0x0008, + kIOHIDElementFlagsNonLinearMask = 0x0010, + kIOHIDElementFlagsNoPreferredMask = 0x0020, + kIOHIDElementFlagsNullStateMask = 0x0040, + kIOHIDElementFlagsVolativeMask = 0x0080, + kIOHIDElementFlagsBufferedByteMask = 0x0100 +}; +typedef uint32_t IOHIDElementFlags; + +/*! + @typedef IOHIDStandardType + @abstract Type to define what industrial standard the device is referencing. + @constant kIOHIDStandardTypeANSI ANSI. + @constant kIOHIDStandardTypeISO ISO. + @constant kIOHIDStandardTypeJIS JIS. +*/ +enum { + kIOHIDStandardTypeANSI = 0, + kIOHIDStandardTypeISO = 1, + kIOHIDStandardTypeJIS = 2 +}; +typedef uint32_t IOHIDStandardType; + +__END_DECLS + +#endif /* !_IOKIT_HID_IOHIDKEYS_H_ */ Index: branches/azimutz/Cleancut/i386/include/IOKit/hidevent/IOHIDEventDriver.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/hidevent/IOHIDEventDriver.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/hidevent/IOHIDEventDriver.h (revision 885) @@ -0,0 +1,171 @@ +/* + * + * @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 +#include +#include +#include + + +/*! @class IOHIDEventDriver : public IOHIDEventService + @abstract + @discussion +*/ +struct IOHIDReportHandler; + +class IOHIDEventDriver: public IOHIDEventService +{ + OSDeclareDefaultStructors( IOHIDEventDriver ) + +private: + IOHIDInterface * _interface; + IOHIDReportHandler * _reportHandlers; + + IOHIDElement * _ledElements[2]; + OSArray * _supportedElements; + + UInt32 _bootSupport; + bool _multipleReports; + bool _relativeButtonCollection; + UInt32 _cachedButtonState; + bool _cachedRangeState; + + struct ExpansionData { + }; + /*! @var reserved + Reserved for future use. (Internal use only) */ + ExpansionData * _reserved; + + bool findElements ( OSArray * elementArray, UInt32 bootProtocol ); + + bool storeReportElement ( IOHIDElement * element ); + + void handleBootPointingReport ( + IOMemoryDescriptor * report, + SInt32 * dX, + SInt32 * dY, + UInt32 * buttonState); + + static void _handleInterruptReport ( + OSObject * target, + AbsoluteTime timeStamp, + IOMemoryDescriptor * report, + IOHIDReportType reportType, + UInt32 reportID, + void * refcon); + +protected: + + virtual void free(); + + virtual OSArray * getReportElements(); + + virtual bool handleStart( IOService * provider ); + + virtual void handleStop( IOService * provider ); + + virtual void handleInterruptReport ( + AbsoluteTime timeStamp, + IOMemoryDescriptor * report, + IOHIDReportType reportType, + UInt32 reportID); + + 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 void setElementValue ( + UInt32 usagePage, + UInt32 usage, + UInt32 value ); + + virtual UInt32 getElementValue ( + UInt32 usagePage, + UInt32 usage ); + +public: + + + virtual bool init( OSDictionary * dictionary = 0 ); + + virtual bool didTerminate( + IOService * provider, + IOOptionBits options, + bool * defer ); + + 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 */ Index: branches/azimutz/Cleancut/i386/include/IOKit/hidevent/IOHIDEventService.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/hidevent/IOHIDEventService.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/hidevent/IOHIDEventService.h (revision 885) @@ -0,0 +1,394 @@ +/* + * + * @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 + +#include +#include +#include +#include +#include +#include +#include + +#if TARGET_OS_EMBEDDED + #include +#endif + +enum +{ + kHIDDispatchOptionPointerNoAcceleration = 0x01, + kHIDDispatchOptionPointerAffixToScreen = 0x02, + kHIDDispatchOptionPointerAbsolutToRelative = 0x04 +}; + +enum +{ + kHIDDispatchOptionScrollNoAcceleration = 0x01, + kHIDDispatchOptionScrollMomentumContinue = 0x02, + kHIDDispatchOptionScrollMomentumStart = 0x04, + kHIDDispatchOptionScrollMomentumEnd = 0x08, + + kHIDDispatchOptionScrollMomentumAny = kHIDDispatchOptionScrollMomentumContinue | kHIDDispatchOptionScrollMomentumStart | kHIDDispatchOptionScrollMomentumEnd +}; + +enum +{ + kHIDDispatchOptionKeyboardNoRepeat = 0x01 +}; + +/*! @class IOHIDEventService : public IOService + @abstract + @discussion +*/ +class IOHIDPointing; +class IOHIDKeyboard; +class IOHIDConsumer; +struct TransducerData; + +class IOHIDEventService: public IOService +{ + OSDeclareAbstractStructors( IOHIDEventService ) + + friend class IOHIDPointing; + friend class IOHIDKeyboard; + friend class IOHIDConsumer; + friend class AppleEmbeddedKeyboard; + friend class IOHIDEventServiceUserClient; + +private: + IOHIDKeyboard * _keyboardNub; + IOHIDPointing * _pointingNub; + IOHIDConsumer * _consumerNub; + + IONotifier * _publishNotify; + IORecursiveLock * _nubLock; + + OSArray * _transducerDataArray; + + bool _readyForInputReports; + + + struct ExpansionData { + IOService * provider; + IOWorkLoop * workLoop; + UInt32 ejectDelayMS; + IOTimerEventSource * ejectTimerEventSource; + UInt32 ejectState; + IOOptionBits ejectOptions; + UInt32 capsDelayMS; + IOTimerEventSource * capsTimerEventSource; + UInt32 capsState; + IOOptionBits capsOptions; + OSArray * deviceUsagePairs; + +#if TARGET_OS_EMBEDDED + OSDictionary * clientDict; + UInt32 debuggerMask; + UInt32 startDebuggerMask; + IOTimerEventSource * debuggerTimerEventSource; + bool shouldSwapISO; +#endif + }; + /*! @var reserved + Reserved for future use. (Internal use only) */ + ExpansionData * _reserved; + + IOHIDPointing * newPointingShim ( + UInt32 buttonCount = 1, + IOFixed pointerResolution = (400 << 16), + IOFixed scrollResolution = 0, + IOOptionBits options = 0 ); + + IOHIDKeyboard * newKeyboardShim ( + UInt32 supportedModifiers = 0, + IOOptionBits options = 0 ); + + IOHIDConsumer * newConsumerShim ( IOOptionBits options = 0 ); + + void parseSupportedElements ( + OSArray * elementArray, + UInt32 bootProtocol ); + + void processTabletElement ( IOHIDElement * element ); + + void processTransducerData (); + + TransducerData * createTransducerData ( UInt32 tranducerID ); + + TransducerData * getTransducerData ( UInt32 tranducerID ); + + IOFixed determineResolution ( IOHIDElement * element ); + + static bool _publishMatchingNotificationHandler(void * target, void * ref, IOService * newService, IONotifier * notifier); + + void ejectTimerCallback(IOTimerEventSource *sender); + + void capsTimerCallback(IOTimerEventSource *sender); + +#if TARGET_OS_EMBEDDED + void debuggerTimerCallback(IOTimerEventSource *sender); +#endif + void calculateCapsLockDelay(); + + void calculateStandardType(); + +protected: + + virtual void free(); + +/*! @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); + +/*! @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); + +/*! @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; + +/*! @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 void 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 ); + + 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 tranducerID, + 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 tranducerID, + bool inRange, + bool invert, + UInt32 vendorTransducerUniqueID = 0, + UInt32 vendorTransducerSerialNumber = 0, + IOOptionBits options = 0 ); + +public: + bool readyForReports(); + + virtual bool init(OSDictionary * properties = 0); + + virtual bool start( IOService * provider ); + + virtual void stop( IOService * provider ); + + virtual bool matchPropertyTable(OSDictionary * table, SInt32 * score); + + virtual IOReturn setSystemProperties( OSDictionary * properties ); + + virtual IOReturn setProperties( OSObject * properties ); + +protected: + OSMetaClassDeclareReservedUsed(IOHIDEventService, 0); + virtual OSArray * getDeviceUsagePairs(); + + +#if TARGET_OS_EMBEDDED +public: + typedef void (*Action)(OSObject *target, OSObject * sender, void *context, OSObject *event, IOOptionBits options); + + OSMetaClassDeclareReservedUsed(IOHIDEventService, 1); + virtual bool open( + IOService * client, + IOOptionBits options, + void * context, + Action action); + +protected: + OSMetaClassDeclareReservedUsed(IOHIDEventService, 2); + virtual void dispatchEvent(IOHIDEvent * event, IOOptionBits options=0); + + OSMetaClassDeclareReservedUsed(IOHIDEventService, 3); + virtual UInt32 getPrimaryUsagePage(); + + OSMetaClassDeclareReservedUsed(IOHIDEventService, 4); + virtual UInt32 getPrimaryUsage(); + + OSMetaClassDeclareReservedUsed(IOHIDEventService, 5); + virtual UInt32 getReportInterval(); + +public: + OSMetaClassDeclareReservedUsed(IOHIDEventService, 6); + virtual IOHIDEvent * copyEvent( + IOHIDEventType type, + IOHIDEvent * matching = 0, + IOOptionBits options = 0); +#else + OSMetaClassDeclareReservedUnused(IOHIDEventService, 1); + OSMetaClassDeclareReservedUnused(IOHIDEventService, 2); + OSMetaClassDeclareReservedUnused(IOHIDEventService, 3); + OSMetaClassDeclareReservedUnused(IOHIDEventService, 4); + OSMetaClassDeclareReservedUnused(IOHIDEventService, 5); + OSMetaClassDeclareReservedUnused(IOHIDEventService, 6); +#endif + OSMetaClassDeclareReservedUnused(IOHIDEventService, 7); + OSMetaClassDeclareReservedUnused(IOHIDEventService, 8); + OSMetaClassDeclareReservedUnused(IOHIDEventService, 9); + OSMetaClassDeclareReservedUnused(IOHIDEventService, 10); + OSMetaClassDeclareReservedUnused(IOHIDEventService, 11); + OSMetaClassDeclareReservedUnused(IOHIDEventService, 12); + OSMetaClassDeclareReservedUnused(IOHIDEventService, 13); + OSMetaClassDeclareReservedUnused(IOHIDEventService, 14); + OSMetaClassDeclareReservedUnused(IOHIDEventService, 15); + OSMetaClassDeclareReservedUnused(IOHIDEventService, 16); + OSMetaClassDeclareReservedUnused(IOHIDEventService, 17); + OSMetaClassDeclareReservedUnused(IOHIDEventService, 18); + OSMetaClassDeclareReservedUnused(IOHIDEventService, 19); + OSMetaClassDeclareReservedUnused(IOHIDEventService, 20); + OSMetaClassDeclareReservedUnused(IOHIDEventService, 21); + OSMetaClassDeclareReservedUnused(IOHIDEventService, 22); + OSMetaClassDeclareReservedUnused(IOHIDEventService, 23); + OSMetaClassDeclareReservedUnused(IOHIDEventService, 24); + OSMetaClassDeclareReservedUnused(IOHIDEventService, 25); + OSMetaClassDeclareReservedUnused(IOHIDEventService, 26); + OSMetaClassDeclareReservedUnused(IOHIDEventService, 27); + OSMetaClassDeclareReservedUnused(IOHIDEventService, 28); + OSMetaClassDeclareReservedUnused(IOHIDEventService, 29); + OSMetaClassDeclareReservedUnused(IOHIDEventService, 30); + OSMetaClassDeclareReservedUnused(IOHIDEventService, 31); + +}; + +#endif /* !_IOKIT_HID_IOHIDEVENTSERVICE_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/hidsystem/IOHIKeyboard.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/hidsystem/IOHIKeyboard.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/hidsystem/IOHIKeyboard.h (revision 885) @@ -0,0 +1,268 @@ +/* + * @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@ + */ +/* Copyright (c) 1992 NeXT Computer, Inc. All rights reserved. + * + * EventSrcPCKeyboard.h - PC Keyboard EventSrc subclass definition + * + * HISTORY + * 28 Aug 1992 Joe Pasqua + * Created. + */ + +#ifndef _IOHIKEYBOARD_H +#define _IOHIKEYBOARD_H + +#include +#include + +/* Start Action Definitions */ + +/* + * HISTORICAL NOTE: + * The following entry points were part of the IOHIKeyboardEvents + * protocol. + */ + +typedef void (*KeyboardEventAction)( OSObject * target, + /* eventFlags */ unsigned eventType, + /* flags */ unsigned flags, + /* keyCode */ unsigned key, + /* charCode */ unsigned charCode, + /* charSet */ unsigned charSet, + /* originalCharCode */ unsigned origCharCode, + /* originalCharSet */ unsigned origCharSet, + /* keyboardType */ unsigned keyboardType, + /* repeat */ bool repeat, + /* atTime */ AbsoluteTime ts); + +typedef void (*KeyboardSpecialEventAction)(OSObject * target, + /* eventType */ unsigned eventType, + /* flags */ unsigned flags, + /* keyCode */ unsigned key, + /* specialty */ unsigned flavor, + /* source id */ UInt64 guid, + /* repeat */ bool repeat, + /* atTime */ AbsoluteTime ts); + +typedef void (*UpdateEventFlagsAction)( OSObject * target, + /* flags */ unsigned flags); + +/* Event Callback Definitions */ + +typedef void (*KeyboardEventCallback)( + /* target */ OSObject * target, + /* eventFlags */ unsigned eventType, + /* flags */ unsigned flags, + /* keyCode */ unsigned key, + /* charCode */ unsigned charCode, + /* charSet */ unsigned charSet, + /* originalCharCode */ unsigned origCharCode, + /* originalCharSet */ unsigned origCharSet, + /* keyboardType */ unsigned keyboardType, + /* repeat */ bool repeat, + /* atTime */ AbsoluteTime ts, + /* sender */ OSObject * sender, + /* refcon */ void * refcon); + +typedef void (*KeyboardSpecialEventCallback)( + /* target */ OSObject * target, + /* eventType */ unsigned eventType, + /* flags */ unsigned flags, + /* keyCode */ unsigned key, + /* specialty */ unsigned flavor, + /* source id */ UInt64 guid, + /* repeat */ bool repeat, + /* atTime */ AbsoluteTime ts, + /* sender */ OSObject * sender, + /* refcon */ void * refcon); + +typedef void (*UpdateEventFlagsCallback)( + /* target */ OSObject * target, + /* flags */ unsigned flags, + /* sender */ OSObject * sender, + /* refcon */ void * refcon); + +/* End Action Definitions */ + + + +/* Default key repeat parameters */ +#define EV_DEFAULTINITIALREPEAT 500000000ULL // 1/2 sec in nanoseconds +#define EV_DEFAULTKEYREPEAT 83333333ULL // 1/12 sec in nanoseconds +#define EV_MINKEYREPEAT 16700000ULL // 1/60 sec + +class IOHIKeyboard : public IOHIDevice +{ + OSDeclareDefaultStructors(IOHIKeyboard); + + friend class IOHIDKeyboardDevice; + friend class IOHIDKeyboard; + friend class IOHIDConsumer; + +protected: + IOLock * _deviceLock; // Lock for all device access + IOHIKeyboardMapper * _keyMap; // KeyMap instance + + // The following fields describe the kind of keyboard + UInt32 _interfaceType; + UInt32 _deviceType; + + // The following fields describe the state of the keyboard + UInt32 * _keyState; // kbdBitVector + IOByteCount _keyStateSize; // kbdBitVector allocated size + unsigned _eventFlags; // Current eventFlags + bool _alphaLock; // true means alpha lock is on + bool _numLock; // true means num lock is on + bool _charKeyActive; // true means char gen. key active + + // The following fields are used in performing key repeats + bool _isRepeat; // true means we're generating repeat + unsigned _codeToRepeat; // What we are repeating + bool _calloutPending; // true means we've sched. a callout + AbsoluteTime _lastEventTime; // Time last event was dispatched + AbsoluteTime _downRepeatTime; // Time when we should next repeat + AbsoluteTime _keyRepeat; // Delay between key repeats + AbsoluteTime _initialKeyRepeat; // Delay before initial key repeat + UInt64 _guid; + + OSObject * _keyboardEventTarget; + KeyboardEventAction _keyboardEventAction; + OSObject * _keyboardSpecialEventTarget; + KeyboardSpecialEventAction _keyboardSpecialEventAction; + OSObject * _updateEventFlagsTarget; + UpdateEventFlagsAction _updateEventFlagsAction; + +protected: + virtual void dispatchKeyboardEvent(unsigned int keyCode, + /* direction */ bool goingDown, + /* timeStamp */ AbsoluteTime time); + +public: + virtual bool init(OSDictionary * properties = 0); + virtual bool start(IOService * provider); + virtual void stop(IOService * provider); + virtual void free(); + + virtual bool open(IOService * client, + IOOptionBits options, + KeyboardEventAction keAction, + KeyboardSpecialEventAction kseAction, + UpdateEventFlagsAction uefAction); + + bool open( IOService * client, + IOOptionBits options, + void *, + KeyboardEventCallback keCallback, + KeyboardSpecialEventCallback kseCallback, + UpdateEventFlagsCallback uefCallback); + + virtual void close(IOService * client, IOOptionBits ); + + virtual IOReturn message( UInt32 type, IOService * provider, + void * argument = 0 ); + + virtual IOHIDKind hidKind(); + virtual bool updateProperties( void ); + virtual IOReturn setParamProperties(OSDictionary * dict); + virtual IOReturn setProperties( OSObject * properties ); + + inline bool isRepeat() {return _isRepeat;} + +protected: // for subclasses to implement + virtual const unsigned char * defaultKeymapOfLength(UInt32 * length); + virtual void setAlphaLockFeedback(bool val); + virtual void setNumLockFeedback(bool val); + virtual UInt32 maxKeyCodes(); + + +private: + virtual bool resetKeyboard(); + virtual void scheduleAutoRepeat(); + static void _autoRepeat(void * arg, void *); + virtual void autoRepeat(); + virtual void setRepeat(unsigned eventType, unsigned keyCode); + void setRepeatMode(bool repeat); + static void _createKeyboardNub(thread_call_param_t param0, thread_call_param_t param1); + +/* + * HISTORICAL NOTE: + * The following methods were part of the KeyMapDelegate protocol; + * the declarations have now been merged directly into this class. + */ + +public: + virtual void keyboardEvent(unsigned eventType, + /* flags */ unsigned flags, + /* keyCode */ unsigned keyCode, + /* charCode */ unsigned charCode, + /* charSet */ unsigned charSet, + /* originalCharCode */ unsigned origCharCode, + /* originalCharSet */ unsigned origCharSet); + + virtual void keyboardSpecialEvent(unsigned eventType, + /* flags */ unsigned flags, + /* keyCode */ unsigned keyCode, + /* specialty */ unsigned flavor); + + virtual void updateEventFlags(unsigned flags); // Does not generate events + + virtual unsigned eventFlags(); // Global event flags + virtual unsigned deviceFlags(); // per-device event flags + virtual void setDeviceFlags(unsigned flags); // Set device event flags + virtual bool alphaLock(); // current alpha-lock state + virtual void setAlphaLock(bool val); // Set current alpha-lock state + virtual bool numLock(); + virtual void setNumLock(bool val); + virtual bool charKeyActive(); // Is a character gen. key down? + virtual void setCharKeyActive(bool val); // Note that a char gen key is down. + virtual bool doesKeyLock(unsigned key); //does key lock physically + virtual unsigned getLEDStatus(); //check hardware for LED status + +private: + static void _keyboardEvent( IOHIKeyboard * self, + unsigned eventType, + /* flags */ unsigned flags, + /* keyCode */ unsigned key, + /* charCode */ unsigned charCode, + /* charSet */ unsigned charSet, + /* originalCharCode */ unsigned origCharCode, + /* originalCharSet */ unsigned origCharSet, + /* keyboardType */ unsigned keyboardType, + /* repeat */ bool repeat, + /* atTime */ AbsoluteTime ts); + static void _keyboardSpecialEvent( + IOHIKeyboard * self, + unsigned eventType, + /* flags */ unsigned flags, + /* keyCode */ unsigned key, + /* specialty */ unsigned flavor, + /* guid */ UInt64 guid, + /* repeat */ bool repeat, + /* atTime */ AbsoluteTime ts); + + static void _updateEventFlags( IOHIKeyboard * self, + unsigned flags); /* Does not generate events */ + +}; + +#endif /* !_IOHIKEYBOARD_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/hidsystem/IOHIDUsageTables.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/hidsystem/IOHIDUsageTables.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/hidsystem/IOHIDUsageTables.h (revision 885) @@ -0,0 +1,1665 @@ +/* + * @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 _IOHIDUSAGETABLES_H +#define _IOHIDUSAGETABLES_H + +/* ****************************************************************************************** + * HID Usage Tables + * + * The following constants are from the USB 'HID Usage Tables' specification, revision 1.1rc3 + * ****************************************************************************************** */ + + +/* Usage Pages */ +enum +{ + kHIDPage_Undefined = 0x00, + kHIDPage_GenericDesktop = 0x01, + kHIDPage_Simulation = 0x02, + kHIDPage_VR = 0x03, + kHIDPage_Sport = 0x04, + kHIDPage_Game = 0x05, + /* Reserved 0x06 */ + kHIDPage_KeyboardOrKeypad = 0x07, /* USB Device Class Definition for Human Interface Devices (HID). Note: the usage type for all key codes is Selector (Sel). */ + kHIDPage_LEDs = 0x08, + kHIDPage_Button = 0x09, + kHIDPage_Ordinal = 0x0A, + kHIDPage_Telephony = 0x0B, + kHIDPage_Consumer = 0x0C, + kHIDPage_Digitizer = 0x0D, + /* Reserved 0x0E */ + kHIDPage_PID = 0x0F, /* USB Physical Interface Device definitions for force feedback and related devices. */ + kHIDPage_Unicode = 0x10, + /* Reserved 0x11 - 0x13 */ + kHIDPage_AlphanumericDisplay = 0x14, + /* Reserved 0x15 - 0x7F */ + /* Monitor 0x80 - 0x83 USB Device Class Definition for Monitor Devices */ + /* Power 0x84 - 0x87 USB Device Class Definition for Power Devices */ + kHIDPage_PowerDevice = 0x84, /* Power Device Page */ + kHIDPage_BatterySystem = 0x85, /* Battery System Page */ + /* Reserved 0x88 - 0x8B */ + kHIDPage_BarCodeScanner = 0x8C, /* (Point of Sale) USB Device Class Definition for Bar Code Scanner Devices */ + kHIDPage_WeighingDevice = 0x8D, /* (Point of Sale) USB Device Class Definition for Weighing Devices */ + kHIDPage_Scale = 0x8D, /* (Point of Sale) USB Device Class Definition for Scale Devices */ + kHIDPage_MagneticStripeReader = 0x8E, + /* ReservedPointofSalepages 0x8F */ + kHIDPage_CameraControl = 0x90, /* USB Device Class Definition for Image Class Devices */ + kHIDPage_Arcade = 0x91, /* OAAF Definitions for arcade and coinop related Devices */ + /* Reserved 0x92 - 0xFEFF */ + /* VendorDefined 0xFF00 - 0xFFFF */ + kHIDPage_VendorDefinedStart = 0xFF00 +}; + +/* Undefined Usage for all usage pages */ +enum +{ + kHIDUsage_Undefined = 0x00 +}; + +/* GenericDesktop Page (0x01) */ +enum +{ + kHIDUsage_GD_Pointer = 0x01, /* Physical Collection */ + kHIDUsage_GD_Mouse = 0x02, /* Application Collection */ + /* 0x03 Reserved */ + kHIDUsage_GD_Joystick = 0x04, /* Application Collection */ + kHIDUsage_GD_GamePad = 0x05, /* Application Collection */ + kHIDUsage_GD_Keyboard = 0x06, /* Application Collection */ + kHIDUsage_GD_Keypad = 0x07, /* Application Collection */ + kHIDUsage_GD_MultiAxisController = 0x08, /* Application Collection */ + /* 0x09 - 0x2F Reserved */ + kHIDUsage_GD_X = 0x30, /* Dynamic Value */ + kHIDUsage_GD_Y = 0x31, /* Dynamic Value */ + kHIDUsage_GD_Z = 0x32, /* Dynamic Value */ + kHIDUsage_GD_Rx = 0x33, /* Dynamic Value */ + kHIDUsage_GD_Ry = 0x34, /* Dynamic Value */ + kHIDUsage_GD_Rz = 0x35, /* Dynamic Value */ + kHIDUsage_GD_Slider = 0x36, /* Dynamic Value */ + kHIDUsage_GD_Dial = 0x37, /* Dynamic Value */ + kHIDUsage_GD_Wheel = 0x38, /* Dynamic Value */ + kHIDUsage_GD_Hatswitch = 0x39, /* Dynamic Value */ + kHIDUsage_GD_CountedBuffer = 0x3A, /* Logical Collection */ + kHIDUsage_GD_ByteCount = 0x3B, /* Dynamic Value */ + kHIDUsage_GD_MotionWakeup = 0x3C, /* One-Shot Control */ + kHIDUsage_GD_Start = 0x3D, /* On/Off Control */ + kHIDUsage_GD_Select = 0x3E, /* On/Off Control */ + /* 0x3F Reserved */ + kHIDUsage_GD_Vx = 0x40, /* Dynamic Value */ + kHIDUsage_GD_Vy = 0x41, /* Dynamic Value */ + kHIDUsage_GD_Vz = 0x42, /* Dynamic Value */ + kHIDUsage_GD_Vbrx = 0x43, /* Dynamic Value */ + kHIDUsage_GD_Vbry = 0x44, /* Dynamic Value */ + kHIDUsage_GD_Vbrz = 0x45, /* Dynamic Value */ + kHIDUsage_GD_Vno = 0x46, /* Dynamic Value */ + /* 0x47 - 0x7F Reserved */ + kHIDUsage_GD_SystemControl = 0x80, /* Application Collection */ + kHIDUsage_GD_SystemPowerDown = 0x81, /* One-Shot Control */ + kHIDUsage_GD_SystemSleep = 0x82, /* One-Shot Control */ + kHIDUsage_GD_SystemWakeUp = 0x83, /* One-Shot Control */ + kHIDUsage_GD_SystemContextMenu = 0x84, /* One-Shot Control */ + kHIDUsage_GD_SystemMainMenu = 0x85, /* One-Shot Control */ + kHIDUsage_GD_SystemAppMenu = 0x86, /* One-Shot Control */ + kHIDUsage_GD_SystemMenuHelp = 0x87, /* One-Shot Control */ + kHIDUsage_GD_SystemMenuExit = 0x88, /* One-Shot Control */ + kHIDUsage_GD_SystemMenu = 0x89, /* Selector */ + kHIDUsage_GD_SystemMenuRight = 0x8A, /* Re-Trigger Control */ + kHIDUsage_GD_SystemMenuLeft = 0x8B, /* Re-Trigger Control */ + kHIDUsage_GD_SystemMenuUp = 0x8C, /* Re-Trigger Control */ + kHIDUsage_GD_SystemMenuDown = 0x8D, /* Re-Trigger Control */ + /* 0x8E - 0x8F Reserved */ + kHIDUsage_GD_DPadUp = 0x90, /* On/Off Control */ + kHIDUsage_GD_DPadDown = 0x91, /* On/Off Control */ + kHIDUsage_GD_DPadRight = 0x92, /* On/Off Control */ + kHIDUsage_GD_DPadLeft = 0x93, /* On/Off Control */ + /* 0x94 - 0xFFFF Reserved */ + kHIDUsage_GD_Reserved = 0xFFFF +}; + +/* Simulation Page (0x02) */ +/* This section provides detailed descriptions of the usages employed by simulation devices. */ +enum +{ + kHIDUsage_Sim_FlightSimulationDevice = 0x01, /* Application Collection */ + kHIDUsage_Sim_AutomobileSimulationDevice = 0x02, /* Application Collection */ + kHIDUsage_Sim_TankSimulationDevice = 0x03, /* Application Collection */ + kHIDUsage_Sim_SpaceshipSimulationDevice = 0x04, /* Application Collection */ + kHIDUsage_Sim_SubmarineSimulationDevice = 0x05, /* Application Collection */ + kHIDUsage_Sim_SailingSimulationDevice = 0x06, /* Application Collection */ + kHIDUsage_Sim_MotorcycleSimulationDevice = 0x07, /* Application Collection */ + kHIDUsage_Sim_SportsSimulationDevice = 0x08, /* Application Collection */ + kHIDUsage_Sim_AirplaneSimulationDevice = 0x09, /* Application Collection */ + kHIDUsage_Sim_HelicopterSimulationDevice = 0x0A, /* Application Collection */ + kHIDUsage_Sim_MagicCarpetSimulationDevice = 0x0B, /* Application Collection */ + kHIDUsage_Sim_BicycleSimulationDevice = 0x0C, /* Application Collection */ + /* 0x0D - 0x1F Reserved */ + kHIDUsage_Sim_FlightControlStick = 0x20, /* Application Collection */ + kHIDUsage_Sim_FlightStick = 0x21, /* Application Collection */ + kHIDUsage_Sim_CyclicControl = 0x22, /* Physical Collection */ + kHIDUsage_Sim_CyclicTrim = 0x23, /* Physical Collection */ + kHIDUsage_Sim_FlightYoke = 0x24, /* Application Collection */ + kHIDUsage_Sim_TrackControl = 0x25, /* Physical Collection */ + /* 0x26 - 0xAF Reserved */ + kHIDUsage_Sim_Aileron = 0xB0, /* Dynamic Value */ + kHIDUsage_Sim_AileronTrim = 0xB1, /* Dynamic Value */ + kHIDUsage_Sim_AntiTorqueControl = 0xB2, /* Dynamic Value */ + kHIDUsage_Sim_AutopilotEnable = 0xB3, /* On/Off Control */ + kHIDUsage_Sim_ChaffRelease = 0xB4, /* One-Shot Control */ + kHIDUsage_Sim_CollectiveControl = 0xB5, /* Dynamic Value */ + kHIDUsage_Sim_DiveBrake = 0xB6, /* Dynamic Value */ + kHIDUsage_Sim_ElectronicCountermeasures = 0xB7, /* On/Off Control */ + kHIDUsage_Sim_Elevator = 0xB8, /* Dynamic Value */ + kHIDUsage_Sim_ElevatorTrim = 0xB9, /* Dynamic Value */ + kHIDUsage_Sim_Rudder = 0xBA, /* Dynamic Value */ + kHIDUsage_Sim_Throttle = 0xBB, /* Dynamic Value */ + kHIDUsage_Sim_FlightCommunications = 0xBC, /* On/Off Control */ + kHIDUsage_Sim_FlareRelease = 0xBD, /* One-Shot Control */ + kHIDUsage_Sim_LandingGear = 0xBE, /* On/Off Control */ + kHIDUsage_Sim_ToeBrake = 0xBF, /* Dynamic Value */ + kHIDUsage_Sim_Trigger = 0xC0, /* Momentary Control */ + kHIDUsage_Sim_WeaponsArm = 0xC1, /* On/Off Control */ + kHIDUsage_Sim_Weapons = 0xC2, /* Selector */ + kHIDUsage_Sim_WingFlaps = 0xC3, /* Dynamic Value */ + kHIDUsage_Sim_Accelerator = 0xC4, /* Dynamic Value */ + kHIDUsage_Sim_Brake = 0xC5, /* Dynamic Value */ + kHIDUsage_Sim_Clutch = 0xC6, /* Dynamic Value */ + kHIDUsage_Sim_Shifter = 0xC7, /* Dynamic Value */ + kHIDUsage_Sim_Steering = 0xC8, /* Dynamic Value */ + kHIDUsage_Sim_TurretDirection = 0xC9, /* Dynamic Value */ + kHIDUsage_Sim_BarrelElevation = 0xCA, /* Dynamic Value */ + kHIDUsage_Sim_DivePlane = 0xCB, /* Dynamic Value */ + kHIDUsage_Sim_Ballast = 0xCC, /* Dynamic Value */ + kHIDUsage_Sim_BicycleCrank = 0xCD, /* Dynamic Value */ + kHIDUsage_Sim_HandleBars = 0xCE, /* Dynamic Value */ + kHIDUsage_Sim_FrontBrake = 0xCF, /* Dynamic Value */ + kHIDUsage_Sim_RearBrake = 0xD0, /* Dynamic Value */ + /* 0xD1 - 0xFFFF Reserved */ + kHIDUsage_Sim_Reserved = 0xFFFF +}; + +/* VR Page (0x03) */ +/* Virtual Reality controls depend on designators to identify the individual controls. Most of the following are */ +/* usages are applied to the collections of entities that comprise the actual device. */ +enum +{ + kHIDUsage_VR_Belt = 0x01, /* Application Collection */ + kHIDUsage_VR_BodySuit = 0x02, /* Application Collection */ + kHIDUsage_VR_Flexor = 0x03, /* Physical Collection */ + kHIDUsage_VR_Glove = 0x04, /* Application Collection */ + kHIDUsage_VR_HeadTracker = 0x05, /* Physical Collection */ + kHIDUsage_VR_HeadMountedDisplay = 0x06, /* Application Collection */ + kHIDUsage_VR_HandTracker = 0x07, /* Application Collection */ + kHIDUsage_VR_Oculometer = 0x08, /* Application Collection */ + kHIDUsage_VR_Vest = 0x09, /* Application Collection */ + kHIDUsage_VR_AnimatronicDevice = 0x0A, /* Application Collection */ + /* 0x0B - 0x1F Reserved */ + kHIDUsage_VR_StereoEnable = 0x20, /* On/Off Control */ + kHIDUsage_VR_DisplayEnable = 0x21, /* On/Off Control */ + /* 0x22 - 0xFFFF Reserved */ + kHIDUsage_VR_Reserved = 0xFFFF +}; + +/* Sport Page (0x04) */ +enum +{ + kHIDUsage_Sprt_BaseballBat = 0x01, /* Application Collection */ + kHIDUsage_Sprt_GolfClub = 0x02, /* Application Collection */ + kHIDUsage_Sprt_RowingMachine = 0x03, /* Application Collection */ + kHIDUsage_Sprt_Treadmill = 0x04, /* Application Collection */ + /* 0x05 - 0x2F Reserved */ + kHIDUsage_Sprt_Oar = 0x30, /* Dynamic Value */ + kHIDUsage_Sprt_Slope = 0x31, /* Dynamic Value */ + kHIDUsage_Sprt_Rate = 0x32, /* Dynamic Value */ + kHIDUsage_Sprt_StickSpeed = 0x33, /* Dynamic Value */ + kHIDUsage_Sprt_StickFaceAngle = 0x34, /* Dynamic Value */ + kHIDUsage_Sprt_StickHeelOrToe = 0x35, /* Dynamic Value */ + kHIDUsage_Sprt_StickFollowThrough = 0x36, /* Dynamic Value */ + kHIDUsage_Sprt_StickTempo = 0x37, /* Dynamic Value */ + kHIDUsage_Sprt_StickType = 0x38, /* Named Array */ + kHIDUsage_Sprt_StickHeight = 0x39, /* Dynamic Value */ + /* 0x3A - 0x4F Reserved */ + kHIDUsage_Sprt_Putter = 0x50, /* Selector */ + kHIDUsage_Sprt_1Iron = 0x51, /* Selector */ + kHIDUsage_Sprt_2Iron = 0x52, /* Selector */ + kHIDUsage_Sprt_3Iron = 0x53, /* Selector */ + kHIDUsage_Sprt_4Iron = 0x54, /* Selector */ + kHIDUsage_Sprt_5Iron = 0x55, /* Selector */ + kHIDUsage_Sprt_6Iron = 0x56, /* Selector */ + kHIDUsage_Sprt_7Iron = 0x57, /* Selector */ + kHIDUsage_Sprt_8Iron = 0x58, /* Selector */ + kHIDUsage_Sprt_9Iron = 0x59, /* Selector */ + kHIDUsage_Sprt_10Iron = 0x5A, /* Selector */ + kHIDUsage_Sprt_11Iron = 0x5B, /* Selector */ + kHIDUsage_Sprt_SandWedge = 0x5C, /* Selector */ + kHIDUsage_Sprt_LoftWedge = 0x5D, /* Selector */ + kHIDUsage_Sprt_PowerWedge = 0x5E, /* Selector */ + kHIDUsage_Sprt_1Wood = 0x5F, /* Selector */ + kHIDUsage_Sprt_3Wood = 0x60, /* Selector */ + kHIDUsage_Sprt_5Wood = 0x61, /* Selector */ + kHIDUsage_Sprt_7Wood = 0x62, /* Selector */ + kHIDUsage_Sprt_9Wood = 0x63, /* Selector */ + /* 0x64 - 0xFFFF Reserved */ + kHIDUsage_Sprt_Reserved = 0xFFFF +}; + +/* Game Page (0x05) */ +enum +{ + kHIDUsage_Game_3DGameController = 0x01, /* Application Collection */ + kHIDUsage_Game_PinballDevice = 0x02, /* Application Collection */ + kHIDUsage_Game_GunDevice = 0x03, /* Application Collection */ + /* 0x04 - 0x1F Reserved */ + kHIDUsage_Game_PointofView = 0x20, /* Physical Collection */ + kHIDUsage_Game_TurnRightOrLeft = 0x21, /* Dynamic Value */ + kHIDUsage_Game_PitchUpOrDown = 0x22, /* Dynamic Value */ + kHIDUsage_Game_RollRightOrLeft = 0x23, /* Dynamic Value */ + kHIDUsage_Game_MoveRightOrLeft = 0x24, /* Dynamic Value */ + kHIDUsage_Game_MoveForwardOrBackward = 0x25, /* Dynamic Value */ + kHIDUsage_Game_MoveUpOrDown = 0x26, /* Dynamic Value */ + kHIDUsage_Game_LeanRightOrLeft = 0x27, /* Dynamic Value */ + kHIDUsage_Game_LeanForwardOrBackward = 0x28, /* Dynamic Value */ + kHIDUsage_Game_HeightOfPOV = 0x29, /* Dynamic Value */ + kHIDUsage_Game_Flipper = 0x2A, /* Momentary Control */ + kHIDUsage_Game_SecondaryFlipper = 0x2B, /* Momentary Control */ + kHIDUsage_Game_Bump = 0x2C, /* Momentary Control */ + kHIDUsage_Game_NewGame = 0x2D, /* One-Shot Control */ + kHIDUsage_Game_ShootBall = 0x2E, /* One-Shot Control */ + kHIDUsage_Game_Player = 0x2F, /* One-Shot Control */ + kHIDUsage_Game_GunBolt = 0x30, /* On/Off Control */ + kHIDUsage_Game_GunClip = 0x31, /* On/Off Control */ + kHIDUsage_Game_Gun = 0x32, /* Selector */ + kHIDUsage_Game_GunSingleShot = 0x33, /* Selector */ + kHIDUsage_Game_GunBurst = 0x34, /* Selector */ + kHIDUsage_Game_GunAutomatic = 0x35, /* Selector */ + kHIDUsage_Game_GunSafety = 0x36, /* On/Off Control */ + kHIDUsage_Game_GamepadFireOrJump = 0x37, /* Logical Collection */ + kHIDUsage_Game_GamepadTrigger = 0x39, /* Logical Collection */ + /* 0x3A - 0xFFFF Reserved */ + kHIDUsage_Game_Reserved = 0xFFFF +}; + +/* KeyboardOrKeypad Page (0x07) */ +/* This section is the Usage Page for key codes to be used in implementing a USB keyboard. A Boot Keyboard (84-, 101- or 104-key) should at a minimum support all associated usage codes as indicated in the ÒBootÓ */ +/* column below. */ +/* The usage type of all key codes is Selectors (Sel), except for the modifier keys Keyboard Left Control (0x224) to Keyboard Right GUI (0x231) which are Dynamic Flags (DV). */ +/* Note: A general note on Usages and languages: Due to the variation of keyboards from language to language, it is not feasible to specify exact key mappings for every language. Where this list is not specific for a key function in a language, the closest equivalent key position should be used, so that a keyboard may be modified for a different language by simply printing different keycaps. One example is the Y key on a North American keyboard. In Germany this is typically Z. Rather than changing the keyboard firmware to put the Z Usage into that place in the descriptor list, the vendor should use the Y Usage on both the North American and German keyboards. This continues to be the existing practice in the industry, in order to minimize the number of changes to the electronics to accommodate otherlanguages. */ +enum +{ + kHIDUsage_KeyboardErrorRollOver = 0x01, /* ErrorRollOver */ + kHIDUsage_KeyboardPOSTFail = 0x02, /* POSTFail */ + kHIDUsage_KeyboardErrorUndefined = 0x03, /* ErrorUndefined */ + kHIDUsage_KeyboardA = 0x04, /* a or A */ + kHIDUsage_KeyboardB = 0x05, /* b or B */ + kHIDUsage_KeyboardC = 0x06, /* c or C */ + kHIDUsage_KeyboardD = 0x07, /* d or D */ + kHIDUsage_KeyboardE = 0x08, /* e or E */ + kHIDUsage_KeyboardF = 0x09, /* f or F */ + kHIDUsage_KeyboardG = 0x0A, /* g or G */ + kHIDUsage_KeyboardH = 0x0B, /* h or H */ + kHIDUsage_KeyboardI = 0x0C, /* i or I */ + kHIDUsage_KeyboardJ = 0x0D, /* j or J */ + kHIDUsage_KeyboardK = 0x0E, /* k or K */ + kHIDUsage_KeyboardL = 0x0F, /* l or L */ + kHIDUsage_KeyboardM = 0x10, /* m or M */ + kHIDUsage_KeyboardN = 0x11, /* n or N */ + kHIDUsage_KeyboardO = 0x12, /* o or O */ + kHIDUsage_KeyboardP = 0x13, /* p or P */ + kHIDUsage_KeyboardQ = 0x14, /* q or Q */ + kHIDUsage_KeyboardR = 0x15, /* r or R */ + kHIDUsage_KeyboardS = 0x16, /* s or S */ + kHIDUsage_KeyboardT = 0x17, /* t or T */ + kHIDUsage_KeyboardU = 0x18, /* u or U */ + kHIDUsage_KeyboardV = 0x19, /* v or V */ + kHIDUsage_KeyboardW = 0x1A, /* w or W */ + kHIDUsage_KeyboardX = 0x1B, /* x or X */ + kHIDUsage_KeyboardY = 0x1C, /* y or Y */ + kHIDUsage_KeyboardZ = 0x1D, /* z or Z */ + kHIDUsage_Keyboard1 = 0x1E, /* 1 or ! */ + kHIDUsage_Keyboard2 = 0x1F, /* 2 or @ */ + kHIDUsage_Keyboard3 = 0x20, /* 3 or # */ + kHIDUsage_Keyboard4 = 0x21, /* 4 or $ */ + kHIDUsage_Keyboard5 = 0x22, /* 5 or % */ + kHIDUsage_Keyboard6 = 0x23, /* 6 or ^ */ + kHIDUsage_Keyboard7 = 0x24, /* 7 or & */ + kHIDUsage_Keyboard8 = 0x25, /* 8 or * */ + kHIDUsage_Keyboard9 = 0x26, /* 9 or ( */ + kHIDUsage_Keyboard0 = 0x27, /* 0 or ) */ + kHIDUsage_KeyboardReturnOrEnter = 0x28, /* Return (Enter) */ + kHIDUsage_KeyboardEscape = 0x29, /* Escape */ + kHIDUsage_KeyboardDeleteOrBackspace = 0x2A, /* Delete (Backspace) */ + kHIDUsage_KeyboardTab = 0x2B, /* Tab */ + kHIDUsage_KeyboardSpacebar = 0x2C, /* Spacebar */ + kHIDUsage_KeyboardHyphen = 0x2D, /* - or _ */ + kHIDUsage_KeyboardEqualSign = 0x2E, /* = or + */ + kHIDUsage_KeyboardOpenBracket = 0x2F, /* [ or { */ + kHIDUsage_KeyboardCloseBracket = 0x30, /* ] or } */ + kHIDUsage_KeyboardBackslash = 0x31, /* \ or | */ + kHIDUsage_KeyboardNonUSPound = 0x32, /* Non-US # or _ */ + kHIDUsage_KeyboardSemicolon = 0x33, /* ; or : */ + kHIDUsage_KeyboardQuote = 0x34, /* ' or " */ + kHIDUsage_KeyboardGraveAccentAndTilde = 0x35, /* Grave Accent and Tilde */ + kHIDUsage_KeyboardComma = 0x36, /* , or < */ + kHIDUsage_KeyboardPeriod = 0x37, /* . or > */ + kHIDUsage_KeyboardSlash = 0x38, /* / or ? */ + kHIDUsage_KeyboardCapsLock = 0x39, /* Caps Lock */ + kHIDUsage_KeyboardF1 = 0x3A, /* F1 */ + kHIDUsage_KeyboardF2 = 0x3B, /* F2 */ + kHIDUsage_KeyboardF3 = 0x3C, /* F3 */ + kHIDUsage_KeyboardF4 = 0x3D, /* F4 */ + kHIDUsage_KeyboardF5 = 0x3E, /* F5 */ + kHIDUsage_KeyboardF6 = 0x3F, /* F6 */ + kHIDUsage_KeyboardF7 = 0x40, /* F7 */ + kHIDUsage_KeyboardF8 = 0x41, /* F8 */ + kHIDUsage_KeyboardF9 = 0x42, /* F9 */ + kHIDUsage_KeyboardF10 = 0x43, /* F10 */ + kHIDUsage_KeyboardF11 = 0x44, /* F11 */ + kHIDUsage_KeyboardF12 = 0x45, /* F12 */ + kHIDUsage_KeyboardPrintScreen = 0x46, /* Print Screen */ + kHIDUsage_KeyboardScrollLock = 0x47, /* Scroll Lock */ + kHIDUsage_KeyboardPause = 0x48, /* Pause */ + kHIDUsage_KeyboardInsert = 0x49, /* Insert */ + kHIDUsage_KeyboardHome = 0x4A, /* Home */ + kHIDUsage_KeyboardPageUp = 0x4B, /* Page Up */ + kHIDUsage_KeyboardDeleteForward = 0x4C, /* Delete Forward */ + kHIDUsage_KeyboardEnd = 0x4D, /* End */ + kHIDUsage_KeyboardPageDown = 0x4E, /* Page Down */ + kHIDUsage_KeyboardRightArrow = 0x4F, /* Right Arrow */ + kHIDUsage_KeyboardLeftArrow = 0x50, /* Left Arrow */ + kHIDUsage_KeyboardDownArrow = 0x51, /* Down Arrow */ + kHIDUsage_KeyboardUpArrow = 0x52, /* Up Arrow */ + kHIDUsage_KeypadNumLock = 0x53, /* Keypad NumLock or Clear */ + kHIDUsage_KeypadSlash = 0x54, /* Keypad / */ + kHIDUsage_KeypadAsterisk = 0x55, /* Keypad * */ + kHIDUsage_KeypadHyphen = 0x56, /* Keypad - */ + kHIDUsage_KeypadPlus = 0x57, /* Keypad + */ + kHIDUsage_KeypadEnter = 0x58, /* Keypad Enter */ + kHIDUsage_Keypad1 = 0x59, /* Keypad 1 or End */ + kHIDUsage_Keypad2 = 0x5A, /* Keypad 2 or Down Arrow */ + kHIDUsage_Keypad3 = 0x5B, /* Keypad 3 or Page Down */ + kHIDUsage_Keypad4 = 0x5C, /* Keypad 4 or Left Arrow */ + kHIDUsage_Keypad5 = 0x5D, /* Keypad 5 */ + kHIDUsage_Keypad6 = 0x5E, /* Keypad 6 or Right Arrow */ + kHIDUsage_Keypad7 = 0x5F, /* Keypad 7 or Home */ + kHIDUsage_Keypad8 = 0x60, /* Keypad 8 or Up Arrow */ + kHIDUsage_Keypad9 = 0x61, /* Keypad 9 or Page Up */ + kHIDUsage_Keypad0 = 0x62, /* Keypad 0 or Insert */ + kHIDUsage_KeypadPeriod = 0x63, /* Keypad . or Delete */ + kHIDUsage_KeyboardNonUSBackslash = 0x64, /* Non-US \ or | */ + kHIDUsage_KeyboardApplication = 0x65, /* Application */ + kHIDUsage_KeyboardPower = 0x66, /* Power */ + kHIDUsage_KeypadEqualSign = 0x67, /* Keypad = */ + kHIDUsage_KeyboardF13 = 0x68, /* F13 */ + kHIDUsage_KeyboardF14 = 0x69, /* F14 */ + kHIDUsage_KeyboardF15 = 0x6A, /* F15 */ + kHIDUsage_KeyboardF16 = 0x6B, /* F16 */ + kHIDUsage_KeyboardF17 = 0x6C, /* F17 */ + kHIDUsage_KeyboardF18 = 0x6D, /* F18 */ + kHIDUsage_KeyboardF19 = 0x6E, /* F19 */ + kHIDUsage_KeyboardF20 = 0x6F, /* F20 */ + kHIDUsage_KeyboardF21 = 0x70, /* F21 */ + kHIDUsage_KeyboardF22 = 0x71, /* F22 */ + kHIDUsage_KeyboardF23 = 0x72, /* F23 */ + kHIDUsage_KeyboardF24 = 0x73, /* F24 */ + kHIDUsage_KeyboardExecute = 0x74, /* Execute */ + kHIDUsage_KeyboardHelp = 0x75, /* Help */ + kHIDUsage_KeyboardMenu = 0x76, /* Menu */ + kHIDUsage_KeyboardSelect = 0x77, /* Select */ + kHIDUsage_KeyboardStop = 0x78, /* Stop */ + kHIDUsage_KeyboardAgain = 0x79, /* Again */ + kHIDUsage_KeyboardUndo = 0x7A, /* Undo */ + kHIDUsage_KeyboardCut = 0x7B, /* Cut */ + kHIDUsage_KeyboardCopy = 0x7C, /* Copy */ + kHIDUsage_KeyboardPaste = 0x7D, /* Paste */ + kHIDUsage_KeyboardFind = 0x7E, /* Find */ + kHIDUsage_KeyboardMute = 0x7F, /* Mute */ + kHIDUsage_KeyboardVolumeUp = 0x80, /* Volume Up */ + kHIDUsage_KeyboardVolumeDown = 0x81, /* Volume Down */ + kHIDUsage_KeyboardLockingCapsLock = 0x82, /* Locking Caps Lock */ + kHIDUsage_KeyboardLockingNumLock = 0x83, /* Locking Num Lock */ + kHIDUsage_KeyboardLockingScrollLock = 0x84, /* Locking Scroll Lock */ + kHIDUsage_KeypadComma = 0x85, /* Keypad Comma */ + kHIDUsage_KeypadEqualSignAS400 = 0x86, /* Keypad Equal Sign for AS/400 */ + kHIDUsage_KeyboardInternational1 = 0x87, /* International1 */ + kHIDUsage_KeyboardInternational2 = 0x88, /* International2 */ + kHIDUsage_KeyboardInternational3 = 0x89, /* International3 */ + kHIDUsage_KeyboardInternational4 = 0x8A, /* International4 */ + kHIDUsage_KeyboardInternational5 = 0x8B, /* International5 */ + kHIDUsage_KeyboardInternational6 = 0x8C, /* International6 */ + kHIDUsage_KeyboardInternational7 = 0x8D, /* International7 */ + kHIDUsage_KeyboardInternational8 = 0x8E, /* International8 */ + kHIDUsage_KeyboardInternational9 = 0x8F, /* International9 */ + kHIDUsage_KeyboardLANG1 = 0x90, /* LANG1 */ + kHIDUsage_KeyboardLANG2 = 0x91, /* LANG2 */ + kHIDUsage_KeyboardLANG3 = 0x92, /* LANG3 */ + kHIDUsage_KeyboardLANG4 = 0x93, /* LANG4 */ + kHIDUsage_KeyboardLANG5 = 0x94, /* LANG5 */ + kHIDUsage_KeyboardLANG6 = 0x95, /* LANG6 */ + kHIDUsage_KeyboardLANG7 = 0x96, /* LANG7 */ + kHIDUsage_KeyboardLANG8 = 0x97, /* LANG8 */ + kHIDUsage_KeyboardLANG9 = 0x98, /* LANG9 */ + kHIDUsage_KeyboardAlternateErase = 0x99, /* AlternateErase */ + kHIDUsage_KeyboardSysReqOrAttention = 0x9A, /* SysReq/Attention */ + kHIDUsage_KeyboardCancel = 0x9B, /* Cancel */ + kHIDUsage_KeyboardClear = 0x9C, /* Clear */ + kHIDUsage_KeyboardPrior = 0x9D, /* Prior */ + kHIDUsage_KeyboardReturn = 0x9E, /* Return */ + kHIDUsage_KeyboardSeparator = 0x9F, /* Separator */ + kHIDUsage_KeyboardOut = 0xA0, /* Out */ + kHIDUsage_KeyboardOper = 0xA1, /* Oper */ + kHIDUsage_KeyboardClearOrAgain = 0xA2, /* Clear/Again */ + kHIDUsage_KeyboardCrSelOrProps = 0xA3, /* CrSel/Props */ + kHIDUsage_KeyboardExSel = 0xA4, /* ExSel */ + /* 0xA5-0xDF Reserved */ + kHIDUsage_KeyboardLeftControl = 0xE0, /* Left Control */ + kHIDUsage_KeyboardLeftShift = 0xE1, /* Left Shift */ + kHIDUsage_KeyboardLeftAlt = 0xE2, /* Left Alt */ + kHIDUsage_KeyboardLeftGUI = 0xE3, /* Left GUI */ + kHIDUsage_KeyboardRightControl = 0xE4, /* Right Control */ + kHIDUsage_KeyboardRightShift = 0xE5, /* Right Shift */ + kHIDUsage_KeyboardRightAlt = 0xE6, /* Right Alt */ + kHIDUsage_KeyboardRightGUI = 0xE7, /* Right GUI */ + /* 0xE8-0xFFFF Reserved */ + kHIDUsage_Keyboard_Reserved = 0xFFFF +}; + +/* LEDs Page (0x08) */ +/* An LED or indicator is implemented as an On/Off Control (OOF) using the ÒSingle button toggleÓ mode, where a value of 1 will turn on the indicator, and a value of 0 will turn it off. The exceptions are described below. */ +enum +{ + kHIDUsage_LED_NumLock = 0x01, /* On/Off Control */ + kHIDUsage_LED_CapsLock = 0x02, /* On/Off Control */ + kHIDUsage_LED_ScrollLock = 0x03, /* On/Off Control */ + kHIDUsage_LED_Compose = 0x04, /* On/Off Control */ + kHIDUsage_LED_Kana = 0x05, /* On/Off Control */ + kHIDUsage_LED_Power = 0x06, /* On/Off Control */ + kHIDUsage_LED_Shift = 0x07, /* On/Off Control */ + kHIDUsage_LED_DoNotDisturb = 0x08, /* On/Off Control */ + kHIDUsage_LED_Mute = 0x09, /* On/Off Control */ + kHIDUsage_LED_ToneEnable = 0x0A, /* On/Off Control */ + kHIDUsage_LED_HighCutFilter = 0x0B, /* On/Off Control */ + kHIDUsage_LED_LowCutFilter = 0x0C, /* On/Off Control */ + kHIDUsage_LED_EqualizerEnable = 0x0D, /* On/Off Control */ + kHIDUsage_LED_SoundFieldOn = 0x0E, /* On/Off Control */ + kHIDUsage_LED_SurroundOn = 0x0F, /* On/Off Control */ + kHIDUsage_LED_Repeat = 0x10, /* On/Off Control */ + kHIDUsage_LED_Stereo = 0x11, /* On/Off Control */ + kHIDUsage_LED_SamplingRateDetect = 0x12, /* On/Off Control */ + kHIDUsage_LED_Spinning = 0x13, /* On/Off Control */ + kHIDUsage_LED_CAV = 0x14, /* On/Off Control */ + kHIDUsage_LED_CLV = 0x15, /* On/Off Control */ + kHIDUsage_LED_RecordingFormatDetect = 0x16, /* On/Off Control */ + kHIDUsage_LED_OffHook = 0x17, /* On/Off Control */ + kHIDUsage_LED_Ring = 0x18, /* On/Off Control */ + kHIDUsage_LED_MessageWaiting = 0x19, /* On/Off Control */ + kHIDUsage_LED_DataMode = 0x1A, /* On/Off Control */ + kHIDUsage_LED_BatteryOperation = 0x1B, /* On/Off Control */ + kHIDUsage_LED_BatteryOK = 0x1C, /* On/Off Control */ + kHIDUsage_LED_BatteryLow = 0x1D, /* On/Off Control */ + kHIDUsage_LED_Speaker = 0x1E, /* On/Off Control */ + kHIDUsage_LED_HeadSet = 0x1F, /* On/Off Control */ + kHIDUsage_LED_Hold = 0x20, /* On/Off Control */ + kHIDUsage_LED_Microphone = 0x21, /* On/Off Control */ + kHIDUsage_LED_Coverage = 0x22, /* On/Off Control */ + kHIDUsage_LED_NightMode = 0x23, /* On/Off Control */ + kHIDUsage_LED_SendCalls = 0x24, /* On/Off Control */ + kHIDUsage_LED_CallPickup = 0x25, /* On/Off Control */ + kHIDUsage_LED_Conference = 0x26, /* On/Off Control */ + kHIDUsage_LED_StandBy = 0x27, /* On/Off Control */ + kHIDUsage_LED_CameraOn = 0x28, /* On/Off Control */ + kHIDUsage_LED_CameraOff = 0x29, /* On/Off Control */ + kHIDUsage_LED_OnLine = 0x2A, /* On/Off Control */ + kHIDUsage_LED_OffLine = 0x2B, /* On/Off Control */ + kHIDUsage_LED_Busy = 0x2C, /* On/Off Control */ + kHIDUsage_LED_Ready = 0x2D, /* On/Off Control */ + kHIDUsage_LED_PaperOut = 0x2E, /* On/Off Control */ + kHIDUsage_LED_PaperJam = 0x2F, /* On/Off Control */ + kHIDUsage_LED_Remote = 0x30, /* On/Off Control */ + kHIDUsage_LED_Forward = 0x31, /* On/Off Control */ + kHIDUsage_LED_Reverse = 0x32, /* On/Off Control */ + kHIDUsage_LED_Stop = 0x33, /* On/Off Control */ + kHIDUsage_LED_Rewind = 0x34, /* On/Off Control */ + kHIDUsage_LED_FastForward = 0x35, /* On/Off Control */ + kHIDUsage_LED_Play = 0x36, /* On/Off Control */ + kHIDUsage_LED_Pause = 0x37, /* On/Off Control */ + kHIDUsage_LED_Record = 0x38, /* On/Off Control */ + kHIDUsage_LED_Error = 0x39, /* On/Off Control */ + kHIDUsage_LED_Usage = 0x3A, /* Selector */ + kHIDUsage_LED_UsageInUseIndicator = 0x3B, /* Usage Switch */ + kHIDUsage_LED_UsageMultiModeIndicator = 0x3C, /* Usage Modifier */ + kHIDUsage_LED_IndicatorOn = 0x3D, /* Selector */ + kHIDUsage_LED_IndicatorFlash = 0x3E, /* Selector */ + kHIDUsage_LED_IndicatorSlowBlink = 0x3F, /* Selector */ + kHIDUsage_LED_IndicatorFastBlink = 0x40, /* Selector */ + kHIDUsage_LED_IndicatorOff = 0x41, /* Selector */ + kHIDUsage_LED_FlashOnTime = 0x42, /* Dynamic Value */ + kHIDUsage_LED_SlowBlinkOnTime = 0x43, /* Dynamic Value */ + kHIDUsage_LED_SlowBlinkOffTime = 0x44, /* Dynamic Value */ + kHIDUsage_LED_FastBlinkOnTime = 0x45, /* Dynamic Value */ + kHIDUsage_LED_FastBlinkOffTime = 0x46, /* Dynamic Value */ + kHIDUsage_LED_UsageIndicatorColor = 0x47, /* Usage Modifier */ + kHIDUsage_LED_IndicatorRed = 0x48, /* Selector */ + kHIDUsage_LED_IndicatorGreen = 0x49, /* Selector */ + kHIDUsage_LED_IndicatorAmber = 0x4A, /* Selector */ + kHIDUsage_LED_GenericIndicator = 0x4B, /* On/Off Control */ + kHIDUsage_LED_SystemSuspend = 0x4C, /* On/Off Control */ + kHIDUsage_LED_ExternalPowerConnected = 0x4D, /* On/Off Control */ + /* 0x4E - 0xFFFF Reserved */ + kHIDUsage_LED_Reserved = 0xFFFF +}; + +/* Button Page (0x09) */ +/* The Button page is the first place an application should look for user selection controls. System graphical user interfaces typically employ a pointer and a set of hierarchical selectors to select, move and otherwise manipulate their environment. For these purposes the following assignment of significance can be applied to the Button usages: */ +/* ¥ Button 1, Primary Button. Used for object selecting, dragging, and double click activation. On MacOS, this is the only button. Microsoft operating systems call this a logical left button, because it */ +/* is not necessarily physically located on the left of the pointing device. */ +/* ¥ Button 2, Secondary Button. Used by newer graphical user interfaces to browse object properties. Exposed by systems to applications that typically assign application-specific functionality. */ +/* ¥ Button 3, Tertiary Button. Optional control. Exposed to applications, but seldom assigned functionality due to prevalence of two- and one-button devices. */ +/* ¥ Buttons 4 -55. As the button number increases, its significance as a selector decreases. */ +/* In many ways the assignment of button numbers is similar to the assignment of Effort in Physical descriptors. Button 1 would be used to define the button a finger rests on when the hand is in the Òat restÓ position, that is, virtually no effort is required by the user to activate the button. Button values increment as the finger has to stretch to reach a control. See Section 6.2.3, ÒPhysical Descriptors,Ó in the HID Specification for methods of further qualifying buttons. */ +enum +{ + kHIDUsage_Button_1 = 0x01, /* (primary/trigger) */ + kHIDUsage_Button_2 = 0x02, /* (secondary) */ + kHIDUsage_Button_3 = 0x03, /* (tertiary) */ + kHIDUsage_Button_4 = 0x04, /* 4th button */ + /* ... */ + kHIDUsage_Button_65535 = 0xFFFF +}; + +/* Ordinal Page (0x0A) */ +/* The Ordinal page allows multiple instances of a control or sets of controls to be declared without requiring individual enumeration in the native usage page. For example, it is not necessary to declare usages of Pointer 1, Pointer 2, and so forth on the Generic Desktop page. When parsed, the ordinal instance number is, in essence, concatenated to the usages attached to the encompassing collection to create Pointer 1, Pointer 2, and so forth. */ +/* For an example, see Section A.5, ÒMultiple Instances of a Control,Ó in Appendix A, ÒUsage Examples.Ó By convention, an Ordinal collection is placed inside the collection for which it is declaring multiple instances. */ +/* Instances do not have to be identical. */ +enum +{ + /* 0x00 Reserved */ + kHIDUsage_Ord_Instance1 = 0x01, /* Usage Modifier */ + kHIDUsage_Ord_Instance2 = 0x02, /* Usage Modifier */ + kHIDUsage_Ord_Instance3 = 0x03, /* Usage Modifier */ + kHIDUsage_Ord_Instance4 = 0x04, /* Usage Modifier */ + kHIDUsage_Ord_Instance65535 = 0xFFFF /* Usage Modifier */ +}; + +/* Telephony Page (0x0B) */ +/* This usage page defines the keytop and control usages for telephony devices. */ +/* Indicators on a phone are handled by wrapping them in LED: Usage In Use Indicator and LED: Usage Selected Indicator usages. For example, a message-indicator LED would be identified by a Telephony: Message usage declared as a Feature or Output in a LED: Usage In Use Indicator collection. */ +/* See Section 14, ÒConsumer Page (0x0C),Ó for audio volume and tone controls. */ +enum +{ + kHIDUsage_Tfon_Phone = 0x01, /* Application Collection */ + kHIDUsage_Tfon_AnsweringMachine = 0x02, /* Application Collection */ + kHIDUsage_Tfon_MessageControls = 0x03, /* Logical Collection */ + kHIDUsage_Tfon_Handset = 0x04, /* Logical Collection */ + kHIDUsage_Tfon_Headset = 0x05, /* Logical Collection */ + kHIDUsage_Tfon_TelephonyKeyPad = 0x06, /* Named Array */ + kHIDUsage_Tfon_ProgrammableButton = 0x07, /* Named Array */ + /* 0x08 - 0x1F Reserved */ + kHIDUsage_Tfon_HookSwitch = 0x20, /* On/Off Control */ + kHIDUsage_Tfon_Flash = 0x21, /* Momentary Control */ + kHIDUsage_Tfon_Feature = 0x22, /* One-Shot Control */ + kHIDUsage_Tfon_Hold = 0x23, /* On/Off Control */ + kHIDUsage_Tfon_Redial = 0x24, /* One-Shot Control */ + kHIDUsage_Tfon_Transfer = 0x25, /* One-Shot Control */ + kHIDUsage_Tfon_Drop = 0x26, /* One-Shot Control */ + kHIDUsage_Tfon_Park = 0x27, /* On/Off Control */ + kHIDUsage_Tfon_ForwardCalls = 0x28, /* On/Off Control */ + kHIDUsage_Tfon_AlternateFunction = 0x29, /* Momentary Control */ + kHIDUsage_Tfon_Line = 0x2A, /* One-Shot Control */ + kHIDUsage_Tfon_SpeakerPhone = 0x2B, /* On/Off Control */ + kHIDUsage_Tfon_Conference = 0x2C, /* On/Off Control */ + kHIDUsage_Tfon_RingEnable = 0x2D, /* On/Off Control */ + kHIDUsage_Tfon_Ring = 0x2E, /* Selector */ + kHIDUsage_Tfon_PhoneMute = 0x2F, /* On/Off Control */ + kHIDUsage_Tfon_CallerID = 0x30, /* Momentary Control */ + /* 0x31 - 0x4F Reserved */ + kHIDUsage_Tfon_SpeedDial = 0x50, /* One-Shot Control */ + kHIDUsage_Tfon_StoreNumber = 0x51, /* One-Shot Control */ + kHIDUsage_Tfon_RecallNumber = 0x52, /* One-Shot Control */ + kHIDUsage_Tfon_PhoneDirectory = 0x53, /* On/Off Control */ + /* 0x54 - 0x6F Reserved */ + kHIDUsage_Tfon_VoiceMail = 0x70, /* On/Off Control */ + kHIDUsage_Tfon_ScreenCalls = 0x71, /* On/Off Control */ + kHIDUsage_Tfon_DoNotDisturb = 0x72, /* On/Off Control */ + kHIDUsage_Tfon_Message = 0x73, /* One-Shot Control */ + kHIDUsage_Tfon_AnswerOnOrOff = 0x74, /* On/Off Control */ + /* 0x75 - 0x8F Reserved */ + kHIDUsage_Tfon_InsideDialTone = 0x90, /* Momentary Control */ + kHIDUsage_Tfon_OutsideDialTone = 0x91, /* Momentary Control */ + kHIDUsage_Tfon_InsideRingTone = 0x92, /* Momentary Control */ + kHIDUsage_Tfon_OutsideRingTone = 0x93, /* Momentary Control */ + kHIDUsage_Tfon_PriorityRingTone = 0x94, /* Momentary Control */ + kHIDUsage_Tfon_InsideRingback = 0x95, /* Momentary Control */ + kHIDUsage_Tfon_PriorityRingback = 0x96, /* Momentary Control */ + kHIDUsage_Tfon_LineBusyTone = 0x97, /* Momentary Control */ + kHIDUsage_Tfon_ReorderTone = 0x98, /* Momentary Control */ + kHIDUsage_Tfon_CallWaitingTone = 0x99, /* Momentary Control */ + kHIDUsage_Tfon_ConfirmationTone1 = 0x9A, /* Momentary Control */ + kHIDUsage_Tfon_ConfirmationTone2 = 0x9B, /* Momentary Control */ + kHIDUsage_Tfon_TonesOff = 0x9C, /* On/Off Control */ + kHIDUsage_Tfon_OutsideRingback = 0x9D, /* Momentary Control */ + /* 0x9E - 0xAF Reserved */ + kHIDUsage_Tfon_PhoneKey0 = 0xB0, /* Selector/One-Shot Control */ + kHIDUsage_Tfon_PhoneKey1 = 0xB1, /* Selector/One-Shot Control */ + kHIDUsage_Tfon_PhoneKey2 = 0xB2, /* Selector/One-Shot Control */ + kHIDUsage_Tfon_PhoneKey3 = 0xB3, /* Selector/One-Shot Control */ + kHIDUsage_Tfon_PhoneKey4 = 0xB4, /* Selector/One-Shot Control */ + kHIDUsage_Tfon_PhoneKey5 = 0xB5, /* Selector/One-Shot Control */ + kHIDUsage_Tfon_PhoneKey6 = 0xB6, /* Selector/One-Shot Control */ + kHIDUsage_Tfon_PhoneKey7 = 0xB7, /* Selector/One-Shot Control */ + kHIDUsage_Tfon_PhoneKey8 = 0xB8, /* Selector/One-Shot Control */ + kHIDUsage_Tfon_PhoneKey9 = 0xB9, /* Selector/One-Shot Control */ + kHIDUsage_Tfon_PhoneKeyStar = 0xBA, /* Selector/One-Shot Control */ + kHIDUsage_Tfon_PhoneKeyPound = 0xBB, /* Selector/One-Shot Control */ + kHIDUsage_Tfon_PhoneKeyA = 0xBC, /* Selector/One-Shot Control */ + kHIDUsage_Tfon_PhoneKeyB = 0xBD, /* Selector/One-Shot Control */ + kHIDUsage_Tfon_PhoneKeyC = 0xBE, /* Selector/One-Shot Control */ + kHIDUsage_Tfon_PhoneKeyD = 0xBF, /* Selector/One-Shot Control */ + /* 0xC0 - 0xFFFF Reserved */ + kHIDUsage_TFon_Reserved = 0xFFFF +}; + +/* Consumer Page (0x0C) */ +/* All controls on the Consumer page are application-specific. That is, they affect a specific device, not the system as a whole. */ +enum +{ + kHIDUsage_Csmr_ConsumerControl = 0x01, /* Application Collection */ + kHIDUsage_Csmr_NumericKeyPad = 0x02, /* Named Array */ + kHIDUsage_Csmr_ProgrammableButtons = 0x03, /* Named Array */ + /* 0x03 - 0x1F Reserved */ + kHIDUsage_Csmr_Plus10 = 0x20, /* One-Shot Control */ + kHIDUsage_Csmr_Plus100 = 0x21, /* One-Shot Control */ + kHIDUsage_Csmr_AMOrPM = 0x22, /* One-Shot Control */ + /* 0x23 - 0x3F Reserved */ + kHIDUsage_Csmr_Power = 0x30, /* On/Off Control */ + kHIDUsage_Csmr_Reset = 0x31, /* One-Shot Control */ + kHIDUsage_Csmr_Sleep = 0x32, /* One-Shot Control */ + kHIDUsage_Csmr_SleepAfter = 0x33, /* One-Shot Control */ + kHIDUsage_Csmr_SleepMode = 0x34, /* Re-Trigger Control */ + kHIDUsage_Csmr_Illumination = 0x35, /* On/Off Control */ + kHIDUsage_Csmr_FunctionButtons = 0x36, /* Named Array */ + /* 0x37 - 0x3F Reserved */ + kHIDUsage_Csmr_Menu = 0x40, /* On/Off Control */ + kHIDUsage_Csmr_MenuPick = 0x41, /* One-Shot Control */ + kHIDUsage_Csmr_MenuUp = 0x42, /* One-Shot Control */ + kHIDUsage_Csmr_MenuDown = 0x43, /* One-Shot Control */ + kHIDUsage_Csmr_MenuLeft = 0x44, /* One-Shot Control */ + kHIDUsage_Csmr_MenuRight = 0x45, /* One-Shot Control */ + kHIDUsage_Csmr_MenuEscape = 0x46, /* One-Shot Control */ + kHIDUsage_Csmr_MenuValueIncrease = 0x47, /* One-Shot Control */ + kHIDUsage_Csmr_MenuValueDecrease = 0x48, /* One-Shot Control */ + /* 0x49 - 0x5F Reserved */ + kHIDUsage_Csmr_DataOnScreen = 0x60, /* On/Off Control */ + kHIDUsage_Csmr_ClosedCaption = 0x61, /* On/Off Control */ + kHIDUsage_Csmr_ClosedCaptionSelect = 0x62, /* Selector */ + kHIDUsage_Csmr_VCROrTV = 0x63, /* On/Off Control */ + kHIDUsage_Csmr_BroadcastMode = 0x64, /* One-Shot Control */ + kHIDUsage_Csmr_Snapshot = 0x65, /* One-Shot Control */ + kHIDUsage_Csmr_Still = 0x66, /* One-Shot Control */ + /* 0x67 - 0x7F Reserved */ + kHIDUsage_Csmr_Selection = 0x80, /* Named Array */ + kHIDUsage_Csmr_Assign = 0x81, /* Selector */ + kHIDUsage_Csmr_ModeStep = 0x82, /* One-Shot Control */ + kHIDUsage_Csmr_RecallLast = 0x83, /* One-Shot Control */ + kHIDUsage_Csmr_EnterChannel = 0x84, /* One-Shot Control */ + kHIDUsage_Csmr_OrderMovie = 0x85, /* One-Shot Control */ + kHIDUsage_Csmr_Channel = 0x86, /* Linear Control */ + kHIDUsage_Csmr_MediaSelection = 0x87, /* Selector */ + kHIDUsage_Csmr_MediaSelectComputer = 0x88, /* Selector */ + kHIDUsage_Csmr_MediaSelectTV = 0x89, /* Selector */ + kHIDUsage_Csmr_MediaSelectWWW = 0x8A, /* Selector */ + kHIDUsage_Csmr_MediaSelectDVD = 0x8B, /* Selector */ + kHIDUsage_Csmr_MediaSelectTelephone = 0x8C, /* Selector */ + kHIDUsage_Csmr_MediaSelectProgramGuide = 0x8D, /* Selector */ + kHIDUsage_Csmr_MediaSelectVideoPhone = 0x8E, /* Selector */ + kHIDUsage_Csmr_MediaSelectGames = 0x8F, /* Selector */ + kHIDUsage_Csmr_MediaSelectMessages = 0x90, /* Selector */ + kHIDUsage_Csmr_MediaSelectCD = 0x91, /* Selector */ + kHIDUsage_Csmr_MediaSelectVCR = 0x92, /* Selector */ + kHIDUsage_Csmr_MediaSelectTuner = 0x93, /* Selector */ + kHIDUsage_Csmr_Quit = 0x94, /* One-Shot Control */ + kHIDUsage_Csmr_Help = 0x95, /* On/Off Control */ + kHIDUsage_Csmr_MediaSelectTape = 0x96, /* Selector */ + kHIDUsage_Csmr_MediaSelectCable = 0x97, /* Selector */ + kHIDUsage_Csmr_MediaSelectSatellite = 0x98, /* Selector */ + kHIDUsage_Csmr_MediaSelectSecurity = 0x99, /* Selector */ + kHIDUsage_Csmr_MediaSelectHome = 0x9A, /* Selector */ + kHIDUsage_Csmr_MediaSelectCall = 0x9B, /* Selector */ + kHIDUsage_Csmr_ChannelIncrement = 0x9C, /* One-Shot Control */ + kHIDUsage_Csmr_ChannelDecrement = 0x9D, /* One-Shot Control */ + kHIDUsage_Csmr_Media = 0x9E, /* Selector */ + /* 0x9F Reserved */ + kHIDUsage_Csmr_VCRPlus = 0xA0, /* One-Shot Control */ + kHIDUsage_Csmr_Once = 0xA1, /* One-Shot Control */ + kHIDUsage_Csmr_Daily = 0xA2, /* One-Shot Control */ + kHIDUsage_Csmr_Weekly = 0xA3, /* One-Shot Control */ + kHIDUsage_Csmr_Monthly = 0xA4, /* One-Shot Control */ + /* 0xA5 - 0xAF Reserved */ + kHIDUsage_Csmr_Play = 0xB0, /* On/Off Control */ + kHIDUsage_Csmr_Pause = 0xB1, /* On/Off Control */ + kHIDUsage_Csmr_Record = 0xB2, /* On/Off Control */ + kHIDUsage_Csmr_FastForward = 0xB3, /* On/Off Control */ + kHIDUsage_Csmr_Rewind = 0xB4, /* On/Off Control */ + kHIDUsage_Csmr_ScanNextTrack = 0xB5, /* One-Shot Control */ + kHIDUsage_Csmr_ScanPreviousTrack = 0xB6, /* One-Shot Control */ + kHIDUsage_Csmr_Stop = 0xB7, /* One-Shot Control */ + kHIDUsage_Csmr_Eject = 0xB8, /* One-Shot Control */ + kHIDUsage_Csmr_RandomPlay = 0xB9, /* On/Off Control */ + kHIDUsage_Csmr_SelectDisc = 0xBA, /* Named Array */ + kHIDUsage_Csmr_EnterDisc = 0xBB, /* Momentary Control */ + kHIDUsage_Csmr_Repeat = 0xBC, /* One-Shot Control */ + kHIDUsage_Csmr_Tracking = 0xBD, /* Linear Control */ + kHIDUsage_Csmr_TrackNormal = 0xBE, /* One-Shot Control */ + kHIDUsage_Csmr_SlowTracking = 0xBF, /* Linear Control */ + kHIDUsage_Csmr_FrameForward = 0xC0, /* Re-Trigger Control */ + kHIDUsage_Csmr_FrameBack = 0xC1, /* Re-Trigger Control */ + kHIDUsage_Csmr_Mark = 0xC2, /* One-Shot Control */ + kHIDUsage_Csmr_ClearMark = 0xC3, /* One-Shot Control */ + kHIDUsage_Csmr_RepeatFromMark = 0xC4, /* On/Off Control */ + kHIDUsage_Csmr_ReturnToMark = 0xC5, /* One-Shot Control */ + kHIDUsage_Csmr_SearchMarkForward = 0xC6, /* One-Shot Control */ + kHIDUsage_Csmr_SearchMarkBackwards = 0xC7, /* One-Shot Control */ + kHIDUsage_Csmr_CounterReset = 0xC8, /* One-Shot Control */ + kHIDUsage_Csmr_ShowCounter = 0xC9, /* One-Shot Control */ + kHIDUsage_Csmr_TrackingIncrement = 0xCA, /* Re-Trigger Control */ + kHIDUsage_Csmr_TrackingDecrement = 0xCB, /* Re-Trigger Control */ + kHIDUsage_Csmr_StopOrEject = 0xCC, /* One-Shot Control */ + kHIDUsage_Csmr_PlayOrPause = 0xCD, /* One-Shot Control */ + kHIDUsage_Csmr_PlayOrSkip = 0xCE, /* One-Shot Control */ + /* 0xCF - 0xDF Reserved */ + kHIDUsage_Csmr_Volume = 0xE0, /* Linear Control */ + kHIDUsage_Csmr_Balance = 0xE1, /* Linear Control */ + kHIDUsage_Csmr_Mute = 0xE2, /* On/Off Control */ + kHIDUsage_Csmr_Bass = 0xE3, /* Linear Control */ + kHIDUsage_Csmr_Treble = 0xE4, /* Linear Control */ + kHIDUsage_Csmr_BassBoost = 0xE5, /* On/Off Control */ + kHIDUsage_Csmr_SurroundMode = 0xE6, /* One-Shot Control */ + kHIDUsage_Csmr_Loudness = 0xE7, /* On/Off Control */ + kHIDUsage_Csmr_MPX = 0xE8, /* On/Off Control */ + kHIDUsage_Csmr_VolumeIncrement = 0xE9, /* Re-Trigger Control */ + kHIDUsage_Csmr_VolumeDecrement = 0xEA, /* Re-Trigger Control */ + /* 0xEB - 0xEF Reserved */ + kHIDUsage_Csmr_Speed = 0xF0, /* Selector */ + kHIDUsage_Csmr_PlaybackSpeed = 0xF1, /* Named Array */ + kHIDUsage_Csmr_StandardPlay = 0xF2, /* Selector */ + kHIDUsage_Csmr_LongPlay = 0xF3, /* Selector */ + kHIDUsage_Csmr_ExtendedPlay = 0xF4, /* Selector */ + kHIDUsage_Csmr_Slow = 0xF5, /* One-Shot Control */ + /* 0xF6 - 0xFF Reserved */ + kHIDUsage_Csmr_FanEnable = 0x100, /* On/Off Control */ + kHIDUsage_Csmr_FanSpeed = 0x101, /* Linear Control */ + kHIDUsage_Csmr_LightEnable = 0x102, /* On/Off Control */ + kHIDUsage_Csmr_LightIlluminationLevel = 0x103, /* Linear Control */ + kHIDUsage_Csmr_ClimateControlEnable = 0x104, /* On/Off Control */ + kHIDUsage_Csmr_RoomTemperature = 0x105, /* Linear Control */ + kHIDUsage_Csmr_SecurityEnable = 0x106, /* On/Off Control */ + kHIDUsage_Csmr_FireAlarm = 0x107, /* One-Shot Control */ + kHIDUsage_Csmr_PoliceAlarm = 0x108, /* One-Shot Control */ + /* 0x109 - 0x14F Reserved */ + kHIDUsage_Csmr_BalanceRight = 0x150, /* Re-Trigger Control */ + kHIDUsage_Csmr_BalanceLeft = 0x151, /* Re-Trigger Control */ + kHIDUsage_Csmr_BassIncrement = 0x152, /* Re-Trigger Control */ + kHIDUsage_Csmr_BassDecrement = 0x153, /* Re-Trigger Control */ + kHIDUsage_Csmr_TrebleIncrement = 0x154, /* Re-Trigger Control */ + kHIDUsage_Csmr_TrebleDecrement = 0x155, /* Re-Trigger Control */ + /* 0x156 - 0x15F Reserved */ + kHIDUsage_Csmr_SpeakerSystem = 0x160, /* Logical Collection */ + kHIDUsage_Csmr_ChannelLeft = 0x161, /* Logical Collection */ + kHIDUsage_Csmr_ChannelRight = 0x162, /* Logical Collection */ + kHIDUsage_Csmr_ChannelCenter = 0x163, /* Logical Collection */ + kHIDUsage_Csmr_ChannelFront = 0x164, /* Logical Collection */ + kHIDUsage_Csmr_ChannelCenterFront = 0x165, /* Logical Collection */ + kHIDUsage_Csmr_ChannelSide = 0x166, /* Logical Collection */ + kHIDUsage_Csmr_ChannelSurround = 0x167, /* Logical Collection */ + kHIDUsage_Csmr_ChannelLowFrequencyEnhancement = 0x168, /* Logical Collection */ + kHIDUsage_Csmr_ChannelTop = 0x169, /* Logical Collection */ + kHIDUsage_Csmr_ChannelUnknown = 0x16A, /* Logical Collection */ + /* 0x16B - 0x16F Reserved */ + kHIDUsage_Csmr_SubChannel = 0x170, /* Linear Control */ + kHIDUsage_Csmr_SubChannelIncrement = 0x171, /* One-Shot Control */ + kHIDUsage_Csmr_SubChannelDecrement = 0x172, /* One-Shot Control */ + kHIDUsage_Csmr_AlternateAudioIncrement = 0x173, /* One-Shot Control */ + kHIDUsage_Csmr_AlternateAudioDecrement = 0x174, /* One-Shot Control */ + /* 0x175 - 0x17F Reserved */ + kHIDUsage_Csmr_ApplicationLaunchButtons = 0x180, /* Named Array */ + kHIDUsage_Csmr_ALLaunchButtonConfigurationTool = 0x181, /* Selector */ + kHIDUsage_Csmr_ALProgrammableButtonConfiguration = 0x182, /* Selector */ + kHIDUsage_Csmr_ALConsumerControlConfiguration = 0x183, /* Selector */ + kHIDUsage_Csmr_ALWordProcessor = 0x184, /* Selector */ + kHIDUsage_Csmr_ALTextEditor = 0x185, /* Selector */ + kHIDUsage_Csmr_ALSpreadsheet = 0x186, /* Selector */ + kHIDUsage_Csmr_ALGraphicsEditor = 0x187, /* Selector */ + kHIDUsage_Csmr_ALPresentationApp = 0x188, /* Selector */ + kHIDUsage_Csmr_ALDatabaseApp = 0x189, /* Selector */ + kHIDUsage_Csmr_ALEmailReader = 0x18A, /* Selector */ + kHIDUsage_Csmr_ALNewsreader = 0x18B, /* Selector */ + kHIDUsage_Csmr_ALVoicemail = 0x18C, /* Selector */ + kHIDUsage_Csmr_ALContactsOrAddressBook = 0x18D, /* Selector */ + kHIDUsage_Csmr_ALCalendarOrSchedule = 0x18E, /* Selector */ + kHIDUsage_Csmr_ALTaskOrProjectManager = 0x18F, /* Selector */ + kHIDUsage_Csmr_ALLogOrJournalOrTimecard = 0x190, /* Selector */ + kHIDUsage_Csmr_ALCheckbookOrFinance = 0x191, /* Selector */ + kHIDUsage_Csmr_ALCalculator = 0x192, /* Selector */ + kHIDUsage_Csmr_ALAOrVCaptureOrPlayback = 0x193, /* Selector */ + kHIDUsage_Csmr_ALLocalMachineBrowser = 0x194, /* Selector */ + kHIDUsage_Csmr_ALLANOrWANBrowser = 0x195, /* Selector */ + kHIDUsage_Csmr_ALInternetBrowser = 0x196, /* Selector */ + kHIDUsage_Csmr_ALRemoteNetworkingOrISPConnect = 0x197, /* Selector */ + kHIDUsage_Csmr_ALNetworkConference = 0x198, /* Selector */ + kHIDUsage_Csmr_ALNetworkChat = 0x199, /* Selector */ + kHIDUsage_Csmr_ALTelephonyOrDialer = 0x19A, /* Selector */ + kHIDUsage_Csmr_ALLogon = 0x19B, /* Selector */ + kHIDUsage_Csmr_ALLogoff = 0x19C, /* Selector */ + kHIDUsage_Csmr_ALLogonOrLogoff = 0x19D, /* Selector */ + kHIDUsage_Csmr_ALTerminalLockOrScreensaver = 0x19E, /* Selector */ + kHIDUsage_Csmr_ALControlPanel = 0x19F, /* Selector */ + kHIDUsage_Csmr_ALCommandLineProcessorOrRun = 0x1A0, /* Selector */ + kHIDUsage_Csmr_ALProcessOrTaskManager = 0x1A1, /* Selector */ + kHIDUsage_Csmr_AL = 0x1A2, /* Selector */ + kHIDUsage_Csmr_ALNextTaskOrApplication = 0x1A3, /* Selector */ + kHIDUsage_Csmr_ALPreviousTaskOrApplication = 0x1A4, /* Selector */ + kHIDUsage_Csmr_ALPreemptiveHaltTaskOrApplication = 0x1A5, /* Selector */ + kHIDUsage_Csmr_ALIntegratedHelpCenter = 0x1A6, /* Selector */ + kHIDUsage_Csmr_ALDocuments = 0x1A7, /* Selector */ + kHIDUsage_Csmr_ALThesaurus = 0x1A8, /* Selector */ + kHIDUsage_Csmr_ALDictionary = 0x1A9, /* Selector */ + kHIDUsage_Csmr_ALDesktop = 0x1AA, /* Selector */ + kHIDUsage_Csmr_ALSpellCheck = 0x1AB, /* Selector */ + kHIDUsage_Csmr_ALGrammerCheck = 0x1AC, /* Selector */ + kHIDUsage_Csmr_ALWirelessStatus = 0x1AD, /* Selector */ + kHIDUsage_Csmr_ALKeyboardLayout = 0x1AE, /* Selector */ + kHIDUsage_Csmr_ALVirusProtection = 0x1AF, /* Selector */ + kHIDUsage_Csmr_ALEncryption = 0x1B0, /* Selector */ + kHIDUsage_Csmr_ALScreenSaver = 0x1B1, /* Selector */ + kHIDUsage_Csmr_ALAlarms = 0x1B2, /* Selector */ + kHIDUsage_Csmr_ALClock = 0x1B3, /* Selector */ + kHIDUsage_Csmr_ALFileBrowser = 0x1B4, /* Selector */ + kHIDUsage_Csmr_ALPowerStatus = 0x1B5, /* Selector */ + /* 0x1A6 - 0x1FF Reserved */ + kHIDUsage_Csmr_GenericGUIApplicationControls = 0x200, /* Named Array */ + kHIDUsage_Csmr_ACNew = 0x201, /* Selector */ + kHIDUsage_Csmr_ACOpen = 0x202, /* Selector */ + kHIDUsage_Csmr_ACClose = 0x203, /* Selector */ + kHIDUsage_Csmr_ACExit = 0x204, /* Selector */ + kHIDUsage_Csmr_ACMaximize = 0x205, /* Selector */ + kHIDUsage_Csmr_ACMinimize = 0x206, /* Selector */ + kHIDUsage_Csmr_ACSave = 0x207, /* Selector */ + kHIDUsage_Csmr_ACPrint = 0x208, /* Selector */ + kHIDUsage_Csmr_ACProperties = 0x209, /* Selector */ + kHIDUsage_Csmr_ACUndo = 0x21A, /* Selector */ + kHIDUsage_Csmr_ACCopy = 0x21B, /* Selector */ + kHIDUsage_Csmr_ACCut = 0x21C, /* Selector */ + kHIDUsage_Csmr_ACPaste = 0x21D, /* Selector */ + kHIDUsage_Csmr_AC = 0x21E, /* Selector */ + kHIDUsage_Csmr_ACFind = 0x21F, /* Selector */ + kHIDUsage_Csmr_ACFindandReplace = 0x220, /* Selector */ + kHIDUsage_Csmr_ACSearch = 0x221, /* Selector */ + kHIDUsage_Csmr_ACGoTo = 0x222, /* Selector */ + kHIDUsage_Csmr_ACHome = 0x223, /* Selector */ + kHIDUsage_Csmr_ACBack = 0x224, /* Selector */ + kHIDUsage_Csmr_ACForward = 0x225, /* Selector */ + kHIDUsage_Csmr_ACStop = 0x226, /* Selector */ + kHIDUsage_Csmr_ACRefresh = 0x227, /* Selector */ + kHIDUsage_Csmr_ACPreviousLink = 0x228, /* Selector */ + kHIDUsage_Csmr_ACNextLink = 0x229, /* Selector */ + kHIDUsage_Csmr_ACBookmarks = 0x22A, /* Selector */ + kHIDUsage_Csmr_ACHistory = 0x22B, /* Selector */ + kHIDUsage_Csmr_ACSubscriptions = 0x22C, /* Selector */ + kHIDUsage_Csmr_ACZoomIn = 0x22D, /* Selector */ + kHIDUsage_Csmr_ACZoomOut = 0x22E, /* Selector */ + kHIDUsage_Csmr_ACZoom = 0x22F, /* Selector */ + kHIDUsage_Csmr_ACFullScreenView = 0x230, /* Selector */ + kHIDUsage_Csmr_ACNormalView = 0x231, /* Selector */ + kHIDUsage_Csmr_ACViewToggle = 0x232, /* Selector */ + kHIDUsage_Csmr_ACScrollUp = 0x233, /* Selector */ + kHIDUsage_Csmr_ACScrollDown = 0x234, /* Selector */ + kHIDUsage_Csmr_ACScroll = 0x235, /* Selector */ + kHIDUsage_Csmr_ACPanLeft = 0x236, /* Selector */ + kHIDUsage_Csmr_ACPanRight = 0x237, /* Selector */ + kHIDUsage_Csmr_ACPan = 0x238, /* Selector */ + kHIDUsage_Csmr_ACNewWindow = 0x239, /* Selector */ + kHIDUsage_Csmr_ACTileHorizontally = 0x23A, /* Selector */ + kHIDUsage_Csmr_ACTileVertically = 0x23B, /* Selector */ + kHIDUsage_Csmr_ACFormat = 0x23C, /* Selector */ + /* 0x23D - 0xFFFF Reserved */ + kHIDUsage_Csmr_Reserved = 0xFFFF +}; + +/* Physical Interface Device Page (0x0F) */ +/* This section provides detailed descriptions of the usages employed by Digitizer Devices. */ +enum +{ + kHIDUsage_PID_PhysicalInterfaceDevice = 0x01, /* CA - A collection of PID usages */ + /* 0x02 - 0x1F Reserved */ + kHIDUsage_PID_Normal = 0x20, /* DV - A force applied perpendicular to the surface of an object */ + kHIDUsage_PID_SetEffectReport = 0x21, /* XXX */ + kHIDUsage_PID_EffectBlockIndex = 0x22, /* XXX */ + kHIDUsage_PID_ParamBlockOffset = 0x23, /* XXX */ + kHIDUsage_PID_ROM_Flag = 0x24, /* XXX */ + kHIDUsage_PID_EffectType = 0x25, /* XXX */ + kHIDUsage_PID_ET_ConstantForce = 0x26, /* XXX */ + kHIDUsage_PID_ET_Ramp = 0x27, /* XXX */ + kHIDUsage_PID_ET_CustomForceData = 0x28, /* XXX */ + /* 0x29 - 0x2F Reserved */ + kHIDUsage_PID_ET_Square = 0x30, /* XXX */ + kHIDUsage_PID_ET_Sine = 0x31, /* XXX */ + kHIDUsage_PID_ET_Triangle = 0x32, /* XXX */ + kHIDUsage_PID_ET_SawtoothUp = 0x33, /* XXX */ + kHIDUsage_PID_ET_SawtoothDown = 0x34, /* XXX */ + /* 0x35 - 0x3F Reserved */ + kHIDUsage_PID_ET_Spring = 0x40, /* XXX */ + kHIDUsage_PID_ET_Damper = 0x41, /* XXX */ + kHIDUsage_PID_ET_Inertia = 0x42, /* XXX */ + kHIDUsage_PID_ET_Friction = 0x43, /* XXX */ + /* 0x44 - 0x4F Reserved */ + kHIDUsage_PID_Duration = 0x50, /* XXX */ + kHIDUsage_PID_SamplePeriod = 0x51, /* XXX */ + kHIDUsage_PID_Gain = 0x52, /* XXX */ + kHIDUsage_PID_TriggerButton = 0x53, /* XXX */ + kHIDUsage_PID_TriggerRepeatInterval = 0x54, /* XXX */ + kHIDUsage_PID_AxesEnable = 0x55, /* XXX */ + kHIDUsage_PID_DirectionEnable = 0x56, /* XXX */ + kHIDUsage_PID_Direction = 0x57, /* XXX */ + kHIDUsage_PID_TypeSpecificBlockOffset = 0x58, /* XXX */ + kHIDUsage_PID_BlockType = 0x59, /* XXX */ + kHIDUsage_PID_SetEnvelopeReport = 0x5A, /* XXX */ + kHIDUsage_PID_AttackLevel = 0x5B, /* XXX */ + kHIDUsage_PID_AttackTime = 0x5C, /* XXX */ + kHIDUsage_PID_FadeLevel = 0x5D, /* XXX */ + kHIDUsage_PID_FadeTime = 0x5E, /* XXX */ + kHIDUsage_PID_SetConditionReport = 0x5F, /* XXX */ + + kHIDUsage_PID_CP_Offset = 0x60, /* XXX */ + kHIDUsage_PID_PositiveCoefficient = 0x61, /* XXX */ + kHIDUsage_PID_NegativeCoefficient = 0x62, /* XXX */ + kHIDUsage_PID_PositiveSaturation = 0x63, /* XXX */ + kHIDUsage_PID_NegativeSaturation = 0x64, /* XXX */ + kHIDUsage_PID_DeadBand = 0x65, /* XXX */ + kHIDUsage_PID_DownloadForceSample = 0x66, /* XXX */ + kHIDUsage_PID_IsochCustomForceEnable = 0x67, /* XXX */ + kHIDUsage_PID_CustomForceDataReport = 0x68, /* XXX */ + kHIDUsage_PID_CustomForceData = 0x69, /* XXX */ + kHIDUsage_PID_CustomForceVendorDefinedData = 0x6A, /* XXX */ + kHIDUsage_PID_SetCustomForceReport = 0x6B, /* XXX */ + kHIDUsage_PID_CustomForceDataOffset = 0x6C, /* XXX */ + kHIDUsage_PID_SampleCount = 0x6D, /* XXX */ + kHIDUsage_PID_SetPeriodicReport = 0x6E, /* XXX */ + kHIDUsage_PID_Offset = 0x6F, /* XXX */ + + kHIDUsage_PID_Magnitude = 0x70, /* XXX */ + kHIDUsage_PID_Phase = 0x71, /* XXX */ + kHIDUsage_PID_Period = 0x72, /* XXX */ + kHIDUsage_PID_SetConstantForceReport = 0x73, /* XXX */ + kHIDUsage_PID_SetRampForceReport = 0x74, /* XXX */ + kHIDUsage_PID_RampStart = 0x75, /* XXX */ + kHIDUsage_PID_RampEnd = 0x76, /* XXX */ + kHIDUsage_PID_EffectOperationReport = 0x77, /* XXX */ + kHIDUsage_PID_EffectOperation = 0x78, /* XXX */ + kHIDUsage_PID_OpEffectStart = 0x79, /* XXX */ + kHIDUsage_PID_OpEffectStartSolo = 0x7A, /* XXX */ + kHIDUsage_PID_OpEffectStop = 0x7B, /* XXX */ + kHIDUsage_PID_LoopCount = 0x7C, /* XXX */ + kHIDUsage_PID_DeviceGainReport = 0x7D, /* XXX */ + kHIDUsage_PID_DeviceGain = 0x7E, /* XXX */ + kHIDUsage_PID_PoolReport = 0x7F, /* XXX */ + + kHIDUsage_PID_RAM_PoolSize = 0x80, /* XXX */ + kHIDUsage_PID_ROM_PoolSize = 0x81, /* XXX */ + kHIDUsage_PID_ROM_EffectBlockCount = 0x82, /* XXX */ + kHIDUsage_PID_SimultaneousEffectsMax = 0x83, /* XXX */ + kHIDUsage_PID_PoolAlignment = 0x84, /* XXX */ + kHIDUsage_PID_PoolMoveReport = 0x85, /* XXX */ + kHIDUsage_PID_MoveSource = 0x86, /* XXX */ + kHIDUsage_PID_MoveDestination = 0x87, /* XXX */ + kHIDUsage_PID_MoveLength = 0x88, /* XXX */ + kHIDUsage_PID_BlockLoadReport = 0x89, /* XXX */ + /* 0x8A Reserved */ + kHIDUsage_PID_BlockLoadStatus = 0x8B, /* XXX */ + kHIDUsage_PID_BlockLoadSuccess = 0x8C, /* XXX */ + kHIDUsage_PID_BlockLoadFull = 0x8D, /* XXX */ + kHIDUsage_PID_BlockLoadError = 0x8E, /* XXX */ + kHIDUsage_PID_BlockHandle = 0x8F, /* XXX */ + + kHIDUsage_PID_BlockFreeReport = 0x90, /* XXX */ + kHIDUsage_PID_TypeSpecificBlockHandle = 0x91, /* XXX */ + kHIDUsage_PID_StateReport = 0x92, /* XXX */ + /* 0x93 Reserved */ + kHIDUsage_PID_EffectPlaying = 0x94, /* XXX */ + kHIDUsage_PID_DeviceControlReport = 0x95, /* XXX */ + kHIDUsage_PID_DeviceControl = 0x96, /* XXX */ + kHIDUsage_PID_DC_EnableActuators = 0x97, /* XXX */ + kHIDUsage_PID_DC_DisableActuators = 0x98, /* XXX */ + kHIDUsage_PID_DC_StopAllEffects = 0x99, /* XXX */ + kHIDUsage_PID_DC_DeviceReset = 0x9A, /* XXX */ + kHIDUsage_PID_DC_DevicePause = 0x9B, /* XXX */ + kHIDUsage_PID_DC_DeviceContinue = 0x9C, /* XXX */ + /* 0x9d - 0x9E Reserved */ + kHIDUsage_PID_DevicePaused = 0x9F, /* XXX */ + + kHIDUsage_PID_ActuatorsEnabled = 0xA0, /* XXX */ + /* 0xA1 - 0xA3 Reserved */ + kHIDUsage_PID_SafetySwitch = 0xA4, /* XXX */ + kHIDUsage_PID_ActuatorOverrideSwitch = 0xA5, /* XXX */ + kHIDUsage_PID_ActuatorPower = 0xA6, /* XXX */ + kHIDUsage_PID_StartDelay = 0xA7, /* XXX */ + kHIDUsage_PID_ParameterBlockSize = 0xA8, /* XXX */ + kHIDUsage_PID_DeviceManagedPool = 0xA9, /* XXX */ + kHIDUsage_PID_SharedParameterBlocks = 0xAA, /* XXX */ + kHIDUsage_PID_CreateNewEffectReport = 0xAB, /* XXX */ + kHIDUsage_PID_RAM_PoolAvailable = 0xAC, /* XXX */ + /* 0xAD - 0xFFFF Reserved */ + kHIDUsage_PID_Reserved = 0xFFFF +}; + +/* Digitizer Page (0x0D) */ +/* This section provides detailed descriptions of the usages employed by Digitizer Devices. */ +enum +{ + kHIDUsage_Dig_Digitizer = 0x01, /* Application Collection */ + kHIDUsage_Dig_Pen = 0x02, /* Application Collection */ + kHIDUsage_Dig_LightPen = 0x03, /* Application Collection */ + kHIDUsage_Dig_TouchScreen = 0x04, /* Application Collection */ + kHIDUsage_Dig_TouchPad = 0x05, /* Application Collection */ + kHIDUsage_Dig_WhiteBoard = 0x06, /* Application Collection */ + kHIDUsage_Dig_CoordinateMeasuringMachine = 0x07, /* Application Collection */ + kHIDUsage_Dig_3DDigitizer = 0x08, /* Application Collection */ + kHIDUsage_Dig_StereoPlotter = 0x09, /* Application Collection */ + kHIDUsage_Dig_ArticulatedArm = 0x0A, /* Application Collection */ + kHIDUsage_Dig_Armature = 0x0B, /* Application Collection */ + kHIDUsage_Dig_MultiplePointDigitizer = 0x0C, /* Application Collection */ + kHIDUsage_Dig_FreeSpaceWand = 0x0D, /* Application Collection */ + /* 0x0E - 0x1F Reserved */ + kHIDUsage_Dig_Stylus = 0x20, /* Logical Collection */ + kHIDUsage_Dig_Puck = 0x21, /* Logical Collection */ + kHIDUsage_Dig_Finger = 0x22, /* Logical Collection */ + /* 0x23 - 0x2F Reserved */ + kHIDUsage_Dig_TipPressure = 0x30, /* Dynamic Value */ + kHIDUsage_Dig_BarrelPressure = 0x31, /* Dynamic Value */ + kHIDUsage_Dig_InRange = 0x32, /* Momentary Control */ + kHIDUsage_Dig_Touch = 0x33, /* Momentary Control */ + kHIDUsage_Dig_Untouch = 0x34, /* One-Shot Control */ + kHIDUsage_Dig_Tap = 0x35, /* One-Shot Control */ + kHIDUsage_Dig_Quality = 0x36, /* Dynamic Value */ + kHIDUsage_Dig_DataValid = 0x37, /* Momentary Control */ + kHIDUsage_Dig_TransducerIndex = 0x38, /* Dynamic Value */ + kHIDUsage_Dig_TabletFunctionKeys = 0x39, /* Logical Collection */ + kHIDUsage_Dig_ProgramChangeKeys = 0x3A, /* Logical Collection */ + kHIDUsage_Dig_BatteryStrength = 0x3B, /* Dynamic Value */ + kHIDUsage_Dig_Invert = 0x3C, /* Momentary Control */ + kHIDUsage_Dig_XTilt = 0x3D, /* Dynamic Value */ + kHIDUsage_Dig_YTilt = 0x3E, /* Dynamic Value */ + kHIDUsage_Dig_Azimuth = 0x3F, /* Dynamic Value */ + kHIDUsage_Dig_Altitude = 0x40, /* Dynamic Value */ + kHIDUsage_Dig_Twist = 0x41, /* Dynamic Value */ + kHIDUsage_Dig_TipSwitch = 0x42, /* Momentary Control */ + kHIDUsage_Dig_SecondaryTipSwitch = 0x43, /* Momentary Control */ + kHIDUsage_Dig_BarrelSwitch = 0x44, /* Momentary Control */ + kHIDUsage_Dig_Eraser = 0x45, /* Momentary Control */ + kHIDUsage_Dig_TabletPick = 0x46, /* Momentary Control */ + /* 0x47 - 0xFFFF Reserved */ + kHIDUsage_Dig_Reserved = 0xFFFF +}; + +/* AlphanumericDisplay Page (0x14) */ +/* The Alphanumeric Display page is intended for use by simple alphanumeric displays that are used on consumer devices. */ +enum +{ + kHIDUsage_AD_AlphanumericDisplay = 0x01, /* Application Collection */ + /* 0x02 - 0x1F Reserved */ + kHIDUsage_AD_DisplayAttributesReport = 0x20, /* Logical Collection */ + kHIDUsage_AD_ASCIICharacterSet = 0x21, /* Static Flag */ + kHIDUsage_AD_DataReadBack = 0x22, /* Static Flag */ + kHIDUsage_AD_FontReadBack = 0x23, /* Static Flag */ + kHIDUsage_AD_DisplayControlReport = 0x24, /* Logical Collection */ + kHIDUsage_AD_ClearDisplay = 0x25, /* Dynamic Flag */ + kHIDUsage_AD_DisplayEnable = 0x26, /* Dynamic Flag */ + kHIDUsage_AD_ScreenSaverDelay = 0x27, /* Static Value */ + kHIDUsage_AD_ScreenSaverEnable = 0x28, /* Dynamic Flag */ + kHIDUsage_AD_VerticalScroll = 0x29, /* Static Flag */ + kHIDUsage_AD_HorizontalScroll = 0x2A, /* Static Flag */ + kHIDUsage_AD_CharacterReport = 0x2B, /* Logical Collection */ + kHIDUsage_AD_DisplayData = 0x2C, /* Dynamic Value */ + kHIDUsage_AD_DisplayStatus = 0x2D, /* Logical Collection */ + kHIDUsage_AD_StatNotReady = 0x2E, /* Selector */ + kHIDUsage_AD_StatReady = 0x2F, /* Selector */ + kHIDUsage_AD_ErrNotaloadablecharacter = 0x30, /* Selector */ + kHIDUsage_AD_ErrFontdatacannotberead = 0x31, /* Selector */ + kHIDUsage_AD_CursorPositionReport = 0x32, /* Logical Collection */ + kHIDUsage_AD_Row = 0x33, /* Dynamic Value */ + kHIDUsage_AD_Column = 0x34, /* Dynamic Value */ + kHIDUsage_AD_Rows = 0x35, /* Static Value */ + kHIDUsage_AD_Columns = 0x36, /* Static Value */ + kHIDUsage_AD_CursorPixelPositioning = 0x37, /* Static Flag */ + kHIDUsage_AD_CursorMode = 0x38, /* Dynamic Flag */ + kHIDUsage_AD_CursorEnable = 0x39, /* Dynamic Flag */ + kHIDUsage_AD_CursorBlink = 0x3A, /* Dynamic Flag */ + kHIDUsage_AD_FontReport = 0x3B, /* Logical Collection */ + kHIDUsage_AD_FontData = 0x3C, /* Buffered Byte */ + kHIDUsage_AD_CharacterWidth = 0x3D, /* Static Value */ + kHIDUsage_AD_CharacterHeight = 0x3E, /* Static Value */ + kHIDUsage_AD_CharacterSpacingHorizontal = 0x3F, /* Static Value */ + kHIDUsage_AD_CharacterSpacingVertical = 0x40, /* Static Value */ + kHIDUsage_AD_UnicodeCharacterSet = 0x41, /* Static Flag */ + /* 0x42 - 0xFFFF Reserved */ + kHIDUsage_AD_Reserved = 0xFFFF +}; + +/* Power Device Page (0x84) */ +/* This section provides detailed descriptions of the usages employed by Power Devices. */ +enum +{ + + kHIDUsage_PD_Undefined = 0x00, /* Power Device Undefined Usage */ + kHIDUsage_PD_iName = 0x01, /* CL- Power Device Name Index */ + kHIDUsage_PD_PresentStatus = 0x02, /* CL- Power Device Present Status */ + kHIDUsage_PD_ChangedStatus = 0x03, /* CA- Power Device Changed Status */ + kHIDUsage_PD_UPS = 0x04, /* CA- Uninterruptible Power Supply */ + kHIDUsage_PD_PowerSupply = 0x05, /* CA- Power Supply */ + /* Reserved 0x06 - 0x0F */ + kHIDUsage_PD_BatterySystem = 0x10, /* CP- Battery System power module */ + kHIDUsage_PD_BatterySystemID = 0x11, /* SV IF- Battery System ID */ + kHIDUsage_PD_Battery = 0x12, /* CP- Battery */ + kHIDUsage_PD_BatteryID = 0x13, /* SV IF- Battery ID */ + kHIDUsage_PD_Charger = 0x14, /* CP- Charger */ + kHIDUsage_PD_ChargerID = 0x15, /* SV IF- Charger ID */ + kHIDUsage_PD_PowerConverter = 0x16, /* CP- Power Converter power module */ + kHIDUsage_PD_PowerConverterID = 0x17, /* SV IF- Power Converter ID */ + kHIDUsage_PD_OutletSystem = 0x18, /* CP- Outlet System power module */ + kHIDUsage_PD_OutletSystemID = 0x19, /* SV IF-Outlet System ID */ + kHIDUsage_PD_Input = 0x1A, /* CP- Power Device Input */ + kHIDUsage_PD_InputID = 0x1B, /* SV IF- Power Device Input ID */ + kHIDUsage_PD_Output = 0x1C, /* CP- Power Device Output */ + kHIDUsage_PD_OutputID = 0x1D, /* SV IF- Power Device Output ID */ + kHIDUsage_PD_Flow = 0x1E, /* CP- Power Device Flow */ + kHIDUsage_PD_FlowID = 0x1F, /* Item IF- Power Device Flow ID */ + kHIDUsage_PD_Outlet = 0x20, /* CP- Power Device Outlet */ + kHIDUsage_PD_OutletID = 0x21, /* SV IF- Power Device Outlet ID */ + kHIDUsage_PD_Gang = 0x22, /* CL/CP- Power Device Gang */ + kHIDUsage_PD_GangID = 0x23, /* SV IF- Power Device Gang ID */ + kHIDUsage_PD_PowerSummary = 0x24, /* CL/CP- Power Device Power Summary */ + kHIDUsage_PD_PowerSummaryID = 0x25, /* SV IF- Power Device Power Summary ID */ + /* Reserved 0x26 - 0x2F */ + kHIDUsage_PD_Voltage = 0x30, /* DV IF- Power Device Voltage */ + kHIDUsage_PD_Current = 0x31, /* DV IF- Power Device Current */ + kHIDUsage_PD_Frequency = 0x32, /* DV IF- Power Device Frequency */ + kHIDUsage_PD_ApparentPower = 0x33, /* DV IF- Power Device Apparent Power */ + kHIDUsage_PD_ActivePower = 0x34, /* DV IF- Power Device RMS Power */ + kHIDUsage_PD_PercentLoad = 0x35, /* DV IF- Power Device Percent Load */ + kHIDUsage_PD_Temperature = 0x36, /* DV IF- Power Device Temperature */ + kHIDUsage_PD_Humidity = 0x37, /* DV IF- Power Device Humidity */ + kHIDUsage_PD_BadCount = 0x38, /* DV IF- Power Device Bad Condition Count */ + /* Reserved 0x39 - 0x3F */ + kHIDUsage_PD_ConfigVoltage = 0x40, /* SV/DV F- Power Device Nominal Voltage */ + kHIDUsage_PD_ConfigCurrent = 0x41, /* SV/DV F- Power Device Nominal Current */ + kHIDUsage_PD_ConfigFrequency = 0x42, /* SV/DV F- Power Device Nominal Frequency */ + kHIDUsage_PD_ConfigApparentPower = 0x43, /* SV/DV F- Power Device Nominal Apparent Power */ + kHIDUsage_PD_ConfigActivePower = 0x44, /* SV/DV F- Power Device Nominal RMS Power */ + kHIDUsage_PD_ConfigPercentLoad = 0x45, /* SV/DV F- Power Device Nominal Percent Load */ + kHIDUsage_PD_ConfigTemperature = 0x46, /* SV/DV F- Power Device Nominal Temperature */ + kHIDUsage_PD_ConfigHumidity = 0x47, /* SV/DV F- Power Device Nominal Humidity */ + /* Reserved 0x48 - 0x4F */ + kHIDUsage_PD_SwitchOnControl = 0x50, /* DV F- Power Device Switch On Control */ + kHIDUsage_PD_SwitchOffControl = 0x51, /* DV F- Power Device Switch Off Control */ + kHIDUsage_PD_ToggleControl = 0x52, /* DV F- Power Device Toogle Sequence Control */ + kHIDUsage_PD_LowVoltageTransfer = 0x53, /* DV F- Power Device Min Transfer Voltage */ + kHIDUsage_PD_HighVoltageTransfer = 0x54, /* DV F- Power Device Max Transfer Voltage */ + kHIDUsage_PD_DelayBeforeReboot = 0x55, /* DV F- Power Device Delay Before Reboot */ + kHIDUsage_PD_DelayBeforeStartup = 0x56, /* DV F- Power Device Delay Before Startup */ + kHIDUsage_PD_DelayBeforeShutdown = 0x57, /* DV F- Power Device Delay Before Shutdown */ + kHIDUsage_PD_Test = 0x58, /* DV F- Power Device Test Request/Result */ + kHIDUsage_PD_ModuleReset = 0x59, /* DV F- Power Device Reset Request/Result */ + kHIDUsage_PD_AudibleAlarmControl = 0x5A, /* DV F- Power Device Audible Alarm Control */ + /* Reserved 0x5B - 0x5F */ + kHIDUsage_PD_Present = 0x60, /* DV IOF- Power Device Present */ + kHIDUsage_PD_Good = 0x61, /* DV IOF- Power Device Good */ + kHIDUsage_PD_InternalFailure = 0x62, /* DV IOF- Power Device Internal Failure */ + kHIDUsage_PD_VoltageOutOfRange = 0x63, /* DV IOF- Power Device Voltage Out Of Range */ + kHIDUsage_PD_FrequencyOutOfRange = 0x64, /* DV IOF- Power Device Frequency Out Of Range */ + kHIDUsage_PD_Overload = 0x65, /* DV IOF- Power Device Overload */ + kHIDUsage_PD_OverCharged = 0x66, /* DV IOF- Power Device Over Charged */ + kHIDUsage_PD_OverTemperature = 0x67, /* DV IOF- Power Device Over Temperature */ + kHIDUsage_PD_ShutdownRequested = 0x68, /* DV IOF- Power Device Shutdown Requested */ + kHIDUsage_PD_ShutdownImminent = 0x69, /* DV IOF- Power Device Shutdown Imminent */ + /* Reserved 0x6A */ + kHIDUsage_PD_SwitchOnOff = 0x6B, /* DV IOF- Power Device On/Off Switch Status */ + kHIDUsage_PD_Switchable = 0x6C, /* DV IOF- Power Device Switchable */ + kHIDUsage_PD_Used = 0x6D, /* DV IOF- Power Device Used */ + kHIDUsage_PD_Boost = 0x6E, /* DV IOF- Power Device Boosted */ + kHIDUsage_PD_Buck = 0x6F, /* DV IOF- Power Device Bucked */ + kHIDUsage_PD_Initialized = 0x70, /* DV IOF- Power Device Initialized */ + kHIDUsage_PD_Tested = 0x71, /* DV IOF- Power Device Tested */ + kHIDUsage_PD_AwaitingPower = 0x72, /* DV IOF- Power Device Awaiting Power */ + kHIDUsage_PD_CommunicationLost = 0x73, /* DV IOF- Power Device Communication Lost */ + /* Reserved 0x74 - 0xFC */ + kHIDUsage_PD_iManufacturer = 0xFD, /* SV F- Power Device Manufacturer String Index */ + kHIDUsage_PD_iProduct = 0xFE, /* SV F- Power Device Product String Index */ + kHIDUsage_PD_iserialNumber = 0xFF /* SV F- Power Device Serial Number String Index */ +}; + +/* Battery System Page (x85) */ +/* This section provides detailed descriptions of the usages employed by Battery Systems. */ +enum +{ + kHIDUsage_BS_Undefined = 0x00, /* Battery System Undefined */ + kHIDUsage_BS_SMBBatteryMode = 0x01, /* CL - SMB Mode */ + kHIDUsage_BS_SMBBatteryStatus = 0x02, /* CL - SMB Status */ + kHIDUsage_BS_SMBAlarmWarning = 0x03, /* CL - SMB Alarm Warning */ + kHIDUsage_BS_SMBChargerMode = 0x04, /* CL - SMB Charger Mode */ + kHIDUsage_BS_SMBChargerStatus = 0x05, /* CL - SMB Charger Status */ + kHIDUsage_BS_SMBChargerSpecInfo = 0x06, /* CL - SMB Charger Extended Status */ + kHIDUsage_BS_SMBSelectorState = 0x07, /* CL - SMB Selector State */ + kHIDUsage_BS_SMBSelectorPresets = 0x08, /* CL - SMB Selector Presets */ + kHIDUsage_BS_SMBSelectorInfo = 0x09, /* CL - SMB Selector Info */ + /* Reserved 0x0A - 0x0F */ + kHIDUsage_BS_OptionalMfgFunction1 = 0x10, /* DV F - Battery System Optional SMB Mfg Function 1 */ + kHIDUsage_BS_OptionalMfgFunction2 = 0x11, /* DV F - Battery System Optional SMB Mfg Function 2 */ + kHIDUsage_BS_OptionalMfgFunction3 = 0x12, /* DV F - Battery System Optional SMB Mfg Function 3 */ + kHIDUsage_BS_OptionalMfgFunction4 = 0x13, /* DV F - Battery System Optional SMB Mfg Function 4 */ + kHIDUsage_BS_OptionalMfgFunction5 = 0x14, /* DV F - Battery System Optional SMB Mfg Function 5 */ + kHIDUsage_BS_ConnectionToSMBus = 0x15, /* DF F - Battery System Connection To System Management Bus */ + kHIDUsage_BS_OutputConnection = 0x16, /* DF F - Battery System Output Connection Status */ + kHIDUsage_BS_ChargerConnection = 0x17, /* DF F - Battery System Charger Connection */ + kHIDUsage_BS_BatteryInsertion = 0x18, /* DF F - Battery System Battery Insertion */ + kHIDUsage_BS_Usenext = 0x19, /* DF F - Battery System Use Next */ + kHIDUsage_BS_OKToUse = 0x1A, /* DF F - Battery System OK To Use */ + kHIDUsage_BS_BatterySupported = 0x1B, /* DF F - Battery System Battery Supported */ + kHIDUsage_BS_SelectorRevision = 0x1C, /* DF F - Battery System Selector Revision */ + kHIDUsage_BS_ChargingIndicator = 0x1D, /* DF F - Battery System Charging Indicator */ + /* Reserved 0x1E - 0x27 */ + kHIDUsage_BS_ManufacturerAccess = 0x28, /* DV F - Battery System Manufacturer Access */ + kHIDUsage_BS_RemainingCapacityLimit = 0x29, /* DV F - Battery System Remaining Capacity Limit */ + kHIDUsage_BS_RemainingTimeLimit = 0x2A, /* DV F - Battery System Remaining Time Limit */ + kHIDUsage_BS_AtRate = 0x2B, /* DV F - Battery System At Rate... */ + kHIDUsage_BS_CapacityMode = 0x2C, /* DV F - Battery System Capacity Mode */ + kHIDUsage_BS_BroadcastToCharger = 0x2D, /* DV F - Battery System Broadcast To Charger */ + kHIDUsage_BS_PrimaryBattery = 0x2E, /* DV F - Battery System Primary Battery */ + kHIDUsage_BS_ChargeController = 0x2F, /* DV F - Battery System Charge Controller */ + /* Reserved 0x30 - 0x3F */ + kHIDUsage_BS_TerminateCharge = 0x40, /* DF IOF - Battery System Terminate Charge */ + kHIDUsage_BS_TerminateDischarge = 0x41, /* DF IOF - Battery System Terminate Discharge */ + kHIDUsage_BS_BelowRemainingCapacityLimit = 0x42, /* DF IOF - Battery System Below Remaining Capacity Limit */ + kHIDUsage_BS_RemainingTimeLimitExpired = 0x43, /* DF IOF - Battery System Remaining Time Limit Expired */ + kHIDUsage_BS_Charging = 0x44, /* DF IOF - Battery System Charging */ + kHIDUsage_BS_Discharging = 0x45, /* DV IOF - Battery System Discharging */ + kHIDUsage_BS_FullyCharged = 0x46, /* DF IOF - Battery System Fully Charged */ + kHIDUsage_BS_FullyDischarged = 0x47, /* DV IOF - Battery System Fully Discharged */ + kHIDUsage_BS_ConditioningFlag = 0x48, /* DV IOF - Battery System Conditioning Flag */ + kHIDUsage_BS_AtRateOK = 0x49, /* DV IOF - Battery System At Rate OK */ + kHIDUsage_BS_SMBErrorCode = 0x4A, /* DF IOF - Battery System SMB Error Code */ + kHIDUsage_BS_NeedReplacement = 0x4B, /* DF IOF - Battery System Need Replacement */ + /* Reserved 0x4C - 0x5F */ + kHIDUsage_BS_AtRateTimeToFull = 0x60, /* DV IF - Battery System At Rate Time To Full */ + kHIDUsage_BS_AtRateTimeToEmpty = 0x61, /* DV IF - Battery System At Rate Time To Empty */ + kHIDUsage_BS_AverageCurrent = 0x62, /* DV IF - Battery System Average Current */ + kHIDUsage_BS_Maxerror = 0x63, /* DV IF - Battery System Max Error */ + kHIDUsage_BS_RelativeStateOfCharge = 0x64, /* DV IF - Battery System Relative State Of Charge */ + kHIDUsage_BS_AbsoluteStateOfCharge = 0x65, /* DV IF - Battery System Absolute State Of Charge */ + kHIDUsage_BS_RemainingCapacity = 0x66, /* DV IF - Battery System Remaining Capacity */ + kHIDUsage_BS_FullChargeCapacity = 0x67, /* DV IF - Battery System Full Charge Capacity */ + kHIDUsage_BS_RunTimeToEmpty = 0x68, /* DV IF - Battery System Run Time To Empty */ + kHIDUsage_BS_AverageTimeToEmpty = 0x69, /* DV IF - Battery System Average Time To Empty */ + kHIDUsage_BS_AverageTimeToFull = 0x6A, /* DV IF - Battery System Average Time To Full */ + kHIDUsage_BS_CycleCount = 0x6B, /* DV IF - Battery System Cycle Count */ + /* Reserved 0x6C - 0x7F */ + kHIDUsage_BS_BattPackModelLevel = 0x80, /* SV F - Battery System Batt Pack Model Level */ + kHIDUsage_BS_InternalChargeController = 0x81, /* SF F - Battery System Internal Charge Controller */ + kHIDUsage_BS_PrimaryBatterySupport = 0x82, /* SF F - Battery System Primary Battery Support */ + kHIDUsage_BS_DesignCapacity = 0x83, /* SV F - Battery System Design Capacity */ + kHIDUsage_BS_SpecificationInfo = 0x84, /* SV F - Battery System Specification Info */ + kHIDUsage_BS_ManufacturerDate = 0x85, /* SV F - Battery System Manufacturer Date */ + kHIDUsage_BS_SerialNumber = 0x86, /* SV F - Battery System Serial Number */ + kHIDUsage_BS_iManufacturerName = 0x87, /* SV F - Battery System Manufacturer Name Index */ + kHIDUsage_BS_iDevicename = 0x88, /* SV F - Battery System Device Name Index */ + kHIDUsage_BS_iDeviceChemistry = 0x89, /* SV F - Battery System Device Chemistry Index */ + kHIDUsage_BS_ManufacturerData = 0x8A, /* SV F - Battery System Manufacturer Data */ + kHIDUsage_BS_Rechargable = 0x8B, /* SV F - Battery System Rechargable */ + kHIDUsage_BS_WarningCapacityLimit = 0x8C, /* SV F - Battery System Warning Capacity Limit */ + kHIDUsage_BS_CapacityGranularity1 = 0x8D, /* SV F - Battery System Capacity Granularity 1 */ + kHIDUsage_BS_CapacityGranularity2 = 0x8E, /* SV F - Battery System Capacity Granularity 2 */ + kHIDUsage_BS_iOEMInformation = 0x8F, /* SV F - Battery System OEM Information Index */ + /* Reserved 0x90 - 0xBF */ + kHIDUsage_BS_InhibitCharge = 0xC0, /* DF IOF - Battery System Inhibit Charge */ + kHIDUsage_BS_EnablePolling = 0xC1, /* DF IOF - Battery System Enable Polling */ + kHIDUsage_BS_ResetToZero = 0xC2, /* DF IOF - Battery System Reset To Zero */ + /* Reserved 0xC3 - 0xCF */ + kHIDUsage_BS_ACPresent = 0xD0, /* DF IOF - Battery System AC Present */ + kHIDUsage_BS_BatteryPresent = 0xD1, /* DF IOF - Battery System Battery Present */ + kHIDUsage_BS_PowerFail = 0xD2, /* DF IOF - Battery System Power Fail */ + kHIDUsage_BS_AlarmInhibited = 0xD3, /* DF IOF - Battery System Alarm Inhibited */ + kHIDUsage_BS_ThermistorUnderRange = 0xD4, /* DF IOF - Battery System Thermistor Under Range */ + kHIDUsage_BS_ThermistorHot = 0xD5, /* DF IOF - Battery System Thermistor Hot */ + kHIDUsage_BS_ThermistorCold = 0xD6, /* DF IOF - Battery System Thermistor Cold */ + kHIDUsage_BS_ThermistorOverRange = 0xD7, /* DF IOF - Battery System Thermistor Over Range */ + kHIDUsage_BS_VoltageOutOfRange = 0xD8, /* DF IOF - Battery System Voltage Out Of Range */ + kHIDUsage_BS_CurrentOutOfRange = 0xD9, /* DF IOF - Battery System Current Out Of Range */ + kHIDUsage_BS_CurrentNotRegulated = 0xDA, /* DF IOF - Battery System Current Not Regulated */ + kHIDUsage_BS_VoltageNotRegulated = 0xDB, /* DF IOF - Battery System Voltage Not Regulated */ + kHIDUsage_BS_MasterMode = 0xDC, /* DF IOF - Battery System Master Mode */ + /* Reserved 0xDD - 0xEF */ + kHIDUsage_BS_ChargerSelectorSupport = 0xF0, /* SF F- Battery System Charger Support Selector */ + kHIDUsage_BS_ChargerSpec = 0xF1, /* SF F- Battery System Charger Specification */ + kHIDUsage_BS_Level2 = 0xF2, /* SF F- Battery System Charger Level 2 */ + kHIDUsage_BS_Level3 = 0xF3 /* SF F- Battery System Charger Level 3 */ + /* Reserved 0xF2 - 0xFF */ +}; + +/* Bar Code Scanner Page (0x8C) */ +/* This section provides detailed descriptions of the usages employed by Bar Code Scanner Devices. */ +enum +{ + kHIDUsage_BCS_Undefined = 0x00, /* Bar Code Scanner Undefined Usage */ + kHIDUsage_BCS_BadgeReader = 0x01, /* CA - Bar Code Badge Reader */ + kHIDUsage_BCS_BarCodeScanner = 0x02, /* CA -Bar Code Scanner */ + kHIDUsage_BCS_DumbBarCodeScanner = 0x03, /* CA -Dumb Bar Code Scanner Usage */ + kHIDUsage_BCS_CordlessScannerBase = 0x04, /* CA -Cordless Base Usage */ + kHIDUsage_BCS_BarCodeScannerCradle = 0x05, /* CA -Bar Code Scanner Cradle Usage */ + /* Reserved 0x06 - 0x0F */ + kHIDUsage_BCS_AttributeReport = 0x10, /* CL - Attribute Report */ + kHIDUsage_BCS_SettingsReport = 0x11, /* CL - Settings Report */ + kHIDUsage_BCS_ScannedDataReport = 0x12, /* CL - Scanned Data Report */ + kHIDUsage_BCS_RawScannedDataReport = 0x13, /* CL - Raw Scanned Data Report */ + kHIDUsage_BCS_TriggerReport = 0x14, /* CL - Trigger Report */ + kHIDUsage_BCS_StatusReport = 0x15, /* CL - Status Report */ + kHIDUsage_BCS_UPC_EANControlReport = 0x16, /* CL - UPC/EAN Control Report */ + kHIDUsage_BCS_EAN2_3LabelControlReport = 0x17, /* CL - EAN 2/3 Label Control Report */ + kHIDUsage_BCS_Code39ControlReport = 0x18, /* CL - Code 39 Control Report */ + kHIDUsage_BCS_Interleaved2of5ControlReport = 0x19, /* CL - Interleaved 2 of 5 Control Report */ + kHIDUsage_BCS_Standard2of5ControlReport = 0x1A, /* CL - Standard 2 of 5 Control Report */ + kHIDUsage_BCS_MSIPlesseyControlReport = 0x1B, /* CL - MSI Plessey Control Report */ + kHIDUsage_BCS_CodabarControlReport = 0x1C, /* CL - Codabar Control Report */ + kHIDUsage_BCS_Code128ControlReport = 0x1D, /* CL - Code 128 Control Report */ + kHIDUsage_BCS_Misc1DControlReport = 0x1E, /* CL - Misc 1D Control Report */ + kHIDUsage_BCS_2DControlReport = 0x1F, /* CL - 2D Control Report */ + /* Reserved 0x20 - 0x2F */ + kHIDUsage_BCS_Aiming_PointerMide = 0x30, /* SF - Aiming Pointer Mode */ + kHIDUsage_BCS_BarCodePresentSensor = 0x31, /* SF - Bar Code Present Sensor */ + kHIDUsage_BCS_Class1ALaser = 0x32, /* SF - Class 1A Laser */ + kHIDUsage_BCS_Class2Laser = 0x33, /* SF - Class 2 Laser */ + kHIDUsage_BCS_HeaterPresent = 0x34, /* SF - Heater Present */ + kHIDUsage_BCS_ContactScanner = 0x35, /* SF - Contact Scanner */ + kHIDUsage_BCS_ElectronicArticleSurveillanceNotification = 0x36, /* SF - Electronic Article Surveillance Notification */ + kHIDUsage_BCS_ConstantElectronicArticleSurveillance = 0x37, /* SF - Constant Electronic Article Surveillance */ + kHIDUsage_BCS_ErrorIndication = 0x38, /* SF - Error Indication */ + kHIDUsage_BCS_FixedBeeper = 0x39, /* SF - Fixed Beeper */ + kHIDUsage_BCS_GoodDecodeIndication = 0x3A, /* SF - Good Decode Indication */ + kHIDUsage_BCS_HandsFreeScanning = 0x3B, /* SF - Hands Free Scanning */ + kHIDUsage_BCS_IntrinsicallySafe = 0x3C, /* SF - Intrinsically Safe */ + kHIDUsage_BCS_KlasseEinsLaser = 0x3D, /* SF - Klasse Eins Laser */ + kHIDUsage_BCS_LongRangeScanner = 0x3E, /* SF - Long Range Scanner */ + kHIDUsage_BCS_MirrorSpeedControl = 0x3F, /* SF - Mirror Speed Control */ + kHIDUsage_BCS_NotOnFileIndication = 0x40, /* SF - Not On File Indication */ + kHIDUsage_BCS_ProgrammableBeeper = 0x41, /* SF - Programmable Beeper */ + kHIDUsage_BCS_Triggerless = 0x42, /* SF - Triggerless */ + kHIDUsage_BCS_Wand = 0x43, /* SF - Wand */ + kHIDUsage_BCS_WaterResistant = 0x44, /* SF - Water Resistant */ + kHIDUsage_BCS_MultiRangeScanner = 0x45, /* SF - Multi-Range Scanner */ + kHIDUsage_BCS_ProximitySensor = 0x46, /* SF - Proximity Sensor */ + /* Reserved 0x47 - 0x4C */ + kHIDUsage_BCS_FragmentDecoding = 0x4D, /* DF - Fragment Decoding */ + kHIDUsage_BCS_ScannerReadConfidence = 0x4E, /* DV - Scanner Read Confidence */ + kHIDUsage_BCS_DataPrefix = 0x4F, /* NAry - Data Prefix */ + kHIDUsage_BCS_PrefixAIMI = 0x50, /* SEL - Prefix AIMI */ + kHIDUsage_BCS_PrefixNone = 0x51, /* SEL - Prefix None */ + kHIDUsage_BCS_PrefixProprietary = 0x52, /* SEL - Prefix Proprietary */ + /* Reserved 0x53 - 0x54 */ + kHIDUsage_BCS_ActiveTime = 0x55, /* DV - Active Time */ + kHIDUsage_BCS_AimingLaserPattern = 0x56, /* DF - Aiming Laser Pattern */ + kHIDUsage_BCS_BarCodePresent = 0x57, /* OOC - Bar Code Present */ + kHIDUsage_BCS_BeeperState = 0x58, /* OOC - Beeper State */ + kHIDUsage_BCS_LaserOnTime = 0x59, /* DV - Laser On Time */ + kHIDUsage_BCS_LaserState = 0x5A, /* OOC - Laser State */ + kHIDUsage_BCS_LockoutTime = 0x5B, /* DV - Lockout Time */ + kHIDUsage_BCS_MotorState = 0x5C, /* OOC - Motor State */ + kHIDUsage_BCS_MotorTimeout = 0x5D, /* DV - Motor Timeout */ + kHIDUsage_BCS_PowerOnResetScanner = 0x5E, /* DF - Power On Reset Scanner */ + kHIDUsage_BCS_PreventReadOfBarcodes = 0x5F, /* DF - Prevent Read of Barcodes */ + kHIDUsage_BCS_InitiateBarcodeRead = 0x60, /* DF - Initiate Barcode Read */ + kHIDUsage_BCS_TriggerState = 0x61, /* DF - Trigger State */ + kHIDUsage_BCS_TriggerMode = 0x62, /* NAry - Trigger Mode */ + kHIDUsage_BCS_TriggerModeBlinkingLaserOn = 0x63, /* SEL - Trigger Mode Blinking Laser On */ + kHIDUsage_BCS_TriggerModeContinuousLaserOn = 0x64, /* SEL - Trigger Mode Continuous Laser On */ + kHIDUsage_BCS_TriggerModeLaserOnWhilePulled = 0x65, /* SEL - Trigger Mode Laser on while Pulled */ + kHIDUsage_BCS_TriggerModeLaserStaysOnAfterTriggerRelease = 0x66, /* SEL - Trigger Mode Laser stays on after Trigger Release */ + /* Reserved 0x67 - 0x6C */ + kHIDUsage_BCS_CommitParametersToNVM = 0x6D, /* DF - Commit Parameters to NVM */ + kHIDUsage_BCS_ParameterScanning = 0x6E, /* DF - Parameter Scanning */ + kHIDUsage_BCS_ParametersChanged = 0x6F, /* OOC - Parameters Changed */ + kHIDUsage_BCS_SetParameterDefaultValues = 0x70, /* DF - Set parameter default values */ + /* Reserved 0x71 - 0x74 */ + kHIDUsage_BCS_ScannerInCradle = 0x75, /* OOC - Scanner In Cradle */ + kHIDUsage_BCS_ScannerInRange = 0x76, /* OOC - Scanner In Range */ + /* Reserved 0x77 - 0x79 */ + kHIDUsage_BCS_AimDuration = 0x7A, /* DV - Aim Duration */ + kHIDUsage_BCS_GoodReadLampDuration = 0x7B, /* DV - Good Read Lamp Duration */ + kHIDUsage_BCS_GoodReadLampIntensity = 0x7C, /* DV - Good Read Lamp Intensity */ + kHIDUsage_BCS_GoodReadLED = 0x7D, /* DF - Good Read LED */ + kHIDUsage_BCS_GoodReadToneFrequency = 0x7E, /* DV - Good Read Tone Frequency*/ + kHIDUsage_BCS_GoodReadToneLength = 0x7F, /* DV - Good Read Tone Length */ + kHIDUsage_BCS_GoodReadToneVolume = 0x80, /* DV - Good Read Tone Volume */ + /* Reserved 0x81 */ + kHIDUsage_BCS_NoReadMessage = 0x82, /* DF - No Read Message */ + kHIDUsage_BCS_NotOnFileVolume = 0x83, /* DV - Not on File Volume */ + kHIDUsage_BCS_PowerupBeep = 0x84, /* DF - Powerup Beep */ + kHIDUsage_BCS_SoundErrorBeep = 0x85, /* DF - Sound Error Beep */ + kHIDUsage_BCS_SoundGoodReadBeep = 0x86, /* DF - Sound Good Read Beep */ + kHIDUsage_BCS_SoundNotOnFileBeep = 0x87, /* DF - Sound Not On File Beep */ + kHIDUsage_BCS_GoodReadWhenToWrite = 0x88, /* NArry - Good Read When to Write */ + kHIDUsage_BCS_GRWTIAfterDecode = 0x89, /* SEL - GRWTI After Decode */ + kHIDUsage_BCS_GRWTIBeep_LampAfterTransmit = 0x8A, /* SEL - GRWTI Beep/Lamp after transmit */ + kHIDUsage_BCS_GRWTINoBeep_LampUseAtAll = 0x8B, /* SEL - GRWTI No Beep/Lamp at all */ + /* Reserved 0x8C - 0x90 */ + kHIDUsage_BCS_BooklandEAN = 0x91, /* DF - Bookland EAN */ + kHIDUsage_BCS_ConvertEAN8To13Type = 0x92, /* DF - Convert EAN 8 to 13 Type */ + kHIDUsage_BCS_ConvertUPCAToEAN_13 = 0x93, /* DF - Convert UPC A to EAN-13 */ + kHIDUsage_BCS_ConvertUPC_EToA = 0x94, /* DF - Convert UPC-E to A */ + kHIDUsage_BCS_EAN_13 = 0x95, /* DF - EAN-13 */ + kHIDUsage_BCS_EAN_8 = 0x96, /* DF - EAN_8 */ + kHIDUsage_BCS_EAN_99_128_Mandatory = 0x97, /* DF - EAN-99 128_Mandatory */ + kHIDUsage_BCS_EAN_99_P5_128_Optional = 0x98, /* DF - EAN-99 P5/128_Optional */ + /* Reserved 0x99 */ + kHIDUsage_BCS_UPC_EAN = 0x9A, /* DF - UPC/EAN */ + kHIDUsage_BCS_UPC_EANCouponCode = 0x9B, /* DF - UPC/EAN Coupon Code */ + kHIDUsage_BCS_UPC_EANPeriodicals = 0x9C, /* DV - UPC/EAN Periodicals */ + kHIDUsage_BCS_UPC_A = 0x9D, /* DF - UPC-A */ + kHIDUsage_BCS_UPC_AWith128Mandatory = 0x9E, /* DF - UPC-A with 128 Mandatory */ + kHIDUsage_BCS_UPC_AWith128Optical = 0x9F, /* DF - UPC-A with 128 Optical */ + kHIDUsage_BCS_UPC_AWithP5Optional = 0xA0, /* DF - UPC-A with P5 Optional */ + kHIDUsage_BCS_UPC_E = 0xA1, /* DF - UPC-E */ + kHIDUsage_BCS_UPC_E1 = 0xA2, /* DF - UPC-E1 */ + /* Reserved 0xA3 - 0xA8 */ + kHIDUsage_BCS_Periodical = 0xA9, /* NArry - Periodical */ + kHIDUsage_BCS_PeriodicalAutoDiscriminatePlus2 = 0xAA,/* SEL - Periodical Auto-Discriminate + 2 */ + kHIDUsage_BCS_PeriodicalOnlyDecodeWithPlus2 = 0xAB, /* SEL - Periodical Only Decode with + 2 */ + kHIDUsage_BCS_PeriodicalIgnorePlus2 = 0xAC, /* SEL - Periodical Ignore + 2 */ + kHIDUsage_BCS_PeriodicalAutoDiscriminatePlus5 = 0xAD,/* SEL - Periodical Auto-Discriminate + 5 */ + kHIDUsage_BCS_PeriodicalOnlyDecodeWithPlus5 = 0xAE, /* SEL - Periodical Only Decode with + 5 */ + kHIDUsage_BCS_PeriodicalIgnorePlus5 = 0xAF, /* SEL - Periodical Ignore + 5 */ + kHIDUsage_BCS_Check = 0xB0, /* NArry - Check */ + kHIDUsage_BCS_CheckDisablePrice = 0xB1, /* SEL - Check Disable Price */ + kHIDUsage_BCS_CheckEnable4DigitPrice = 0xB2, /* SEL - Check Enable 4 digit Price */ + kHIDUsage_BCS_CheckEnable5DigitPrice = 0xB3, /* SEL - Check Enable 5 digit Price */ + kHIDUsage_BCS_CheckEnableEuropean4DigitPrice = 0xB4,/* SEL - Check Enable European 4 digit Price */ + kHIDUsage_BCS_CheckEnableEuropean5DigitPrice = 0xB5,/* SEL - Check Enable European 5 digit Price */ + /* Reserved 0xB6 */ + kHIDUsage_BCS_EANTwoLabel = 0xB7, /* DF - EAN Two Label */ + kHIDUsage_BCS_EANThreeLabel = 0xB8, /* DF - EAN Thread Label */ + kHIDUsage_BCS_EAN8FlagDigit1 = 0xB9, /* DV - EAN 8 Flag Digit 1 */ + kHIDUsage_BCS_EAN8FlagDigit2 = 0xBA, /* DV - EAN 8 Flag Digit 2 */ + kHIDUsage_BCS_EAN8FlagDigit3 = 0xBB, /* DV - EAN 8 Flag Digit 3 */ + kHIDUsage_BCS_EAN13FlagDigit1 = 0xBC, /* DV - EAN 13 Flag Digit 1 */ + kHIDUsage_BCS_EAN13FlagDigit2 = 0xBD, /* DV - EAN 13 Flag Digit 2 */ + kHIDUsage_BCS_EAN13FlagDigit3 = 0xBE, /* DV - EAN 13 Flag Digit 3 */ + kHIDUsage_BCS_AddEAN2_3LabelDefinition = 0xBF, /* DF - Add EAN 2/3 Label Definition */ + kHIDUsage_BCS_ClearAllEAN2_3LabelDefinitions = 0xC0,/* DF - Clear all EAN 2/3 Label Definitions */ + /* Reserved 0xC1 - 0xC2 */ + kHIDUsage_BCS_Codabar = 0xC3, /* DF - Codabar */ + kHIDUsage_BCS_Code128 = 0xC4, /* DF - Code 128 */ + /* Reserved 0xC5 - 0xC6 */ + kHIDUsage_BCS_Code39 = 0xC7, /* DF - Code 39 */ + kHIDUsage_BCS_Code93 = 0xC8, /* DF - Code 93 */ + kHIDUsage_BCS_FullASCIIConversion = 0xC9, /* DF - Full ASCII Conversion */ + kHIDUsage_BCS_Interleaved2of5 = 0xCA, /* DF - Interleaved 2 of 5 */ + kHIDUsage_BCS_ItalianPharmacyCode = 0xCB, /* DF - Italian Pharmacy Code */ + kHIDUsage_BCS_MSI_Plessey = 0xCC, /* DF - MSI/Plessey */ + kHIDUsage_BCS_Standard2of5IATA = 0xCD, /* DF - Standard 2 of 5 IATA */ + kHIDUsage_BCS_Standard2of5 = 0xCE, /* DF - Standard 2 of 5 */ + /* Reserved 0xCF - 0xD2 */ + kHIDUsage_BCS_TransmitStart_Stop = 0xD3, /* DF - Transmit Start/Stop */ + kHIDUsage_BCS_TriOptic = 0xD4, /* DF - Tri-Optic */ + kHIDUsage_BCS_UCC_EAN_128 = 0xD5, /* DF - UCC/EAN-128 */ + kHIDUsage_BCS_CheckDigit = 0xD6, /* NArry - Check Digit */ + kHIDUsage_BCS_CheckDigitDisable = 0xD7, /* SEL - Check Digit Disable */ + kHIDUsage_BCS_CheckDigitEnableInterleaved2of5OPCC = 0xD8, /* SEL - Check Digit Enable Interleaved 2 of 5 OPCC */ + kHIDUsage_BCS_CheckDigitEnableInterleaved2of5USS = 0xD9, /* SEL - Check Digit Enable Interleaved 2 of 5 USS */ + kHIDUsage_BCS_CheckDigitEnableStandard2of5OPCC = 0xD8, /* SEL - Check Digit Enable Standard 2 of 5 OPCC */ + kHIDUsage_BCS_CheckDigitEnableStandard2of5USS = 0xD9, /* SEL - Check Digit Enable Standard 2 of 5 USS */ + kHIDUsage_BCS_CheckDigitEnableOneMSIPlessey = 0xDC, /* SEL - Check Digit Enable One MSI Plessey */ + kHIDUsage_BCS_CheckDigitEnableTwoMSIPlessey = 0xDD, /* SEL - Check Digit Enable Two MSI Plessey */ + kHIDUsage_BCS_CheckDigitCodabarEnable = 0xDE, /* SEL - Check Digit Codabar Enable */ + kHIDUsage_BCS_CheckDigitCode99Enable = 0xDF, /* SEL - Check Digit Code 99 Enable */ + /* Reserved 0xE0 - 0xEF */ + kHIDUsage_BCS_TransmitCheckDigit = 0xF0, /* NArry - Transmit Check Digit */ + kHIDUsage_BCS_DisableCheckDigitTransmit = 0xF1, /* SEL - Disable Check Digit Transmit */ + kHIDUsage_BCS_EnableCheckDigitTransmit = 0xF2, /* SEL - Enable Check Digit Transmit */ + /* Reserved 0xF3 - 0xFA */ + kHIDUsage_BCS_SymbologyIdentifier1 = 0xFB, /* DV - Symbology Identifier 1 */ + kHIDUsage_BCS_SymbologyIdentifier2 = 0xFC, /* DV - Symbology Identifier 2 */ + kHIDUsage_BCS_SymbologyIdentifier3 = 0xFD, /* DV - Symbology Identifier 3 */ + kHIDUsage_BCS_DecodedData = 0xFE, /* DV - Decoded Data */ + kHIDUsage_BCS_DecodeDataContinued = 0xFF, /* DF - Decode Data Continued */ + kHIDUsage_BCS_BarSpaceData = 0x100, /* DV - Bar Space Data */ + kHIDUsage_BCS_ScannerDataAccuracy = 0x101, /* DV - Scanner Data Accuracy */ + kHIDUsage_BCS_RawDataPolarity = 0x102, /* NArry - Raw Data Polarity */ + kHIDUsage_BCS_PolarityInvertedBarCode = 0x103, /* SEL - Polarity Inverted Bar Code */ + kHIDUsage_BCS_PolarityNormalBarCode = 0x103, /* SEL - Polarity Normal Bar Code */ + /* Reserved 0x105 */ + kHIDUsage_BCS_MinimumLengthToDecode = 0x106, /* DV - Minimum Length to Decode */ + kHIDUsage_BCS_MaximumLengthToDecode = 0x107, /* DV - Maximum Length to Decode */ + kHIDUsage_BCS_FirstDiscreteLengthToDecode = 0x108, /* DV - First Discrete Length to Decode */ + kHIDUsage_BCS_SecondDiscreteLengthToDecode = 0x109, /* DV - Second Discrete Length to Decode */ + kHIDUsage_BCS_DataLengthMethod = 0x10A, /* NArry - Data Length Method */ + kHIDUsage_BCS_DLMethodReadAny = 0x10B, /* DF - DL Method Read any */ + kHIDUsage_BCS_DLMethodCheckInRange = 0x10C, /* DF - DL Method Check in Range */ + kHIDUsage_BCS_DLMethodCheckForDiscrete = 0x10D, /* DF - DL Method Check for Discrete */ + /* Reserved 0x10E - 0x10F */ + kHIDUsage_BCS_AztecCode = 0x110, /* DF - Aztec Code */ + kHIDUsage_BCS_BC412 = 0x111, /* DF - BC412 */ + kHIDUsage_BCS_ChannelCode = 0x112, /* DF - Channel Code */ + kHIDUsage_BCS_Code16 = 0x113, /* DF - Code 16 */ + kHIDUsage_BCS_Code32 = 0x114, /* DF - Code 32 */ + kHIDUsage_BCS_Code49 = 0x115, /* DF - Code 49 */ + kHIDUsage_BCS_CodeOne = 0x116, /* DF - Code One */ + kHIDUsage_BCS_Colorcode = 0x117, /* DF - Colorcode */ + kHIDUsage_BCS_DataMatrix = 0x118, /* DF - Data Matrix */ + kHIDUsage_BCS_MaxiCode = 0x119, /* DF - MaxiCode */ + kHIDUsage_BCS_MicroPDF = 0x11A, /* DF - MicroPDF */ + kHIDUsage_BCS_PDF_417 = 0x11B, /* DF - PDF-417 */ + kHIDUsage_BCS_PosiCode = 0x11C, /* DF - PosiCode */ + kHIDUsage_BCS_QRCode = 0x11D, /* DF - QR Code */ + kHIDUsage_BCS_SuperCode = 0x11E, /* DF - SuperCode */ + kHIDUsage_BCS_UltraCode = 0x11F, /* DF - UltraCode */ + kHIDUsage_BCS_USB_5_SlugCode = 0x120, /* DF - USD-5 (Slug Code) */ + kHIDUsage_BCS_VeriCode = 0x121 /* DF - VeriCode */ + /* Reserved 0x122 - 0xFFFF */ +}; + +/* Weighing Devices Page (0x8D) */ +/* This section provides detailed descriptions of the usages employed by Weighing Devices. */ +enum +{ + kHIDUsage_WD_Undefined = 0x00, /* Weighing Device Undefined Usage */ + kHIDUsage_WD_WeighingDevice = 0x01, /* CA - Weighing Device */ + /* Reserved 0x02 - 0x1F */ + kHIDUsage_WD_ScaleScaleDevice = 0x20, /* CL - Scale Device */ + kHIDUsage_WD_ScaleScaleClassIMetricCL = 0x21, /* CL - Scale Class I Metric */ + kHIDUsage_WD_ScaleScaleClassIMetric = 0x22, /* SEL - Scale Class I Metric */ + kHIDUsage_WD_ScaleScaleClassIIMetric = 0x23, /* SEL - Scale Class II Metric */ + kHIDUsage_WD_ScaleScaleClassIIIMetric = 0x24, /* SEL - Scale Class III Metric */ + kHIDUsage_WD_ScaleScaleClassIIILMetric = 0x25, /* SEL - Scale Class IIIL Metric */ + kHIDUsage_WD_ScaleScaleClassIVMetric = 0x26, /* SEL - Scale Class IV Metric */ + kHIDUsage_WD_ScaleScaleClassIIIEnglish = 0x27, /* SEL - Scale Class III English */ + kHIDUsage_WD_ScaleScaleClassIIILEnglish = 0x28, /* SEL - Scale Class IIIL English */ + kHIDUsage_WD_ScaleScaleClassIVEnglish = 0x29, /* SEL - Scale Class IV English */ + kHIDUsage_WD_ScaleScaleClassGeneric = 0x2A, /* SEL - Scale Class Generic */ + /* Reserved 0x2B - 0x2F */ + kHIDUsage_WD_ScaleAtrributeReport = 0x30, /* CL - Scale Attribute Report */ + kHIDUsage_WD_ScaleControlReport = 0x31, /* CL - Scale Control Report */ + kHIDUsage_WD_ScaleDataReport = 0x32, /* CL - Scale Data Report */ + kHIDUsage_WD_ScaleStatusReport = 0x33, /* CL - Scale Status Report */ + kHIDUsage_WD_ScaleWeightLimitReport = 0x34, /* CL - Scale Weight Limit Report */ + kHIDUsage_WD_ScaleStatisticsReport = 0x35, /* CL - Scale Statistics Report */ + /* Reserved 0x36 - 0x3F */ + kHIDUsage_WD_DataWeight = 0x40, /* DV - Data Weight */ + kHIDUsage_WD_DataScaling = 0x41, /* DV - Data Scaling */ + /* Reserved 0x42 - 0x4F */ + kHIDUsage_WD_WeightUnit = 0x50, /* CL - Weight Unit */ + kHIDUsage_WD_WeightUnitMilligram = 0x51, /* SEL - Weight Unit Milligram */ + kHIDUsage_WD_WeightUnitGram = 0x52, /* SEL - Weight Unit Gram */ + kHIDUsage_WD_WeightUnitKilogram = 0x53, /* SEL - Weight Unit Kilogram */ + kHIDUsage_WD_WeightUnitCarats = 0x54, /* SEL - Weight Unit Carats */ + kHIDUsage_WD_WeightUnitTaels = 0x55, /* SEL - Weight Unit Taels */ + kHIDUsage_WD_WeightUnitGrains = 0x56, /* SEL - Weight Unit Grains */ + kHIDUsage_WD_WeightUnitPennyweights = 0x57, /* SEL - Weight Unit Pennyweights */ + kHIDUsage_WD_WeightUnitMetricTon = 0x58, /* SEL - Weight Unit Metric Ton */ + kHIDUsage_WD_WeightUnitAvoirTon = 0x59, /* SEL - Weight Unit Avoir Ton */ + kHIDUsage_WD_WeightUnitTroyOunce = 0x5A, /* SEL - Weight Unit Troy Ounce */ + kHIDUsage_WD_WeightUnitOunce = 0x5B, /* SEL - Weight Unit Ounce */ + kHIDUsage_WD_WeightUnitPound = 0x5C, /* SEL - Weight Unit Pound */ + /* Reserved 0x5D - 0x5F */ + kHIDUsage_WD_CalibrationCount = 0x60, /* DV - Calibration Count */ + kHIDUsage_WD_RezeroCount = 0x61, /* DV - Re-Zero Count*/ + /* Reserved 0x62 - 0x6F */ + kHIDUsage_WD_ScaleStatus = 0x70, /* CL - Scale Status */ + kHIDUsage_WD_ScaleStatusFault = 0x71, /* SEL - Scale Status Fault */ + kHIDUsage_WD_ScaleStatusStableAtZero = 0x72, /* SEL - Scale Status Stable at Center of Zero */ + kHIDUsage_WD_ScaleStatusInMotion = 0x73, /* SEL - Scale Status In Motion */ + kHIDUsage_WD_ScaleStatusWeightStable = 0x74, /* SEL - Scale Status Weight Stable */ + kHIDUsage_WD_ScaleStatusUnderZero = 0x75, /* SEL - Scale Status Under Zero */ + kHIDUsage_WD_ScaleStatusOverWeightLimit = 0x76, /* SEL - Scale Status Over Weight Limit */ + kHIDUsage_WD_ScaleStatusRequiresCalibration = 0x77, /* SEL - Scale Status Requires Calibration */ + kHIDUsage_WD_ScaleStatusRequiresRezeroing = 0x78, /* SEL - Scale Status Requires Re-zeroing */ + /* Reserved 0x79 - 0x7F */ + kHIDUsage_WD_ZeroScale = 0x80, /* OOC - Zero Scale */ + kHIDUsage_WD_EnforcedZeroReturn = 0x81 /* OOC - Enforced Zero Return */ + /* Reserved 0x82 - 0xFFFF */ + +}; + +/* Magnetic Stripe Reader Page (0x8E) */ +/* This section provides detailed descriptions of the usages employed by Magnetic Stripe Reader Devices. */ +enum +{ + kHIDUsage_MSR_Undefined = 0x00, /* MagStripe Undefined Usage */ + kHIDUsage_MSR_DeviceReadOnly = 0x01, /* CA - MSR Device Read-Only */ + /* Reserved 0x02 - 0x10 */ + kHIDUsage_MSR_Track1Length = 0x11, /* SF, DF, SEL - Track 1 Length */ + kHIDUsage_MSR_Track2Length = 0x12, /* SF, DF, SEL - Track 2 Length */ + kHIDUsage_MSR_Track3Length = 0x13, /* SF, DF, SEL - Track 3 Length */ + kHIDUsage_MSR_TrackJISLength = 0x14, /* SF, DF, SEL - Track JIS Length */ + /* Reserved 0x15 - 0x1F */ + kHIDUsage_MSR_TrackData = 0x20, /* SF, DF, SEL - Track Data */ + kHIDUsage_MSR_Track1Data = 0x21, /* SF, DF, SEL - Track 1 Data */ + kHIDUsage_MSR_Track2Data = 0x22, /* SF, DF, SEL - Track 2 Data */ + kHIDUsage_MSR_Track3Data = 0x23, /* SF, DF, SEL - Track 3 Data */ + kHIDUsage_MSR_TrackJISData = 0x24 /* SF, DF, SEL - Track JIS Data */ + /* Reserved 0x25 - 0xFFFF */ +}; + +#endif /* _IOHIDUSAGETABLES_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/hidsystem/IOHIDParameter.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/hidsystem/IOHIDParameter.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/hidsystem/IOHIDParameter.h (revision 885) @@ -0,0 +1,310 @@ +/* + * @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@ + */ +/* Copyright (c) 1992 NeXT Computer, Inc. All rights reserved. + * + * evsio.h - Get/Set parameter calls for Event Status Driver. + * + * CAUTION: Developers should stick to the API exported in + * to guarantee + * binary compatability of their applications in future + * releases. + * + * HISTORY + * 22 May 1992 Mike Paquette at NeXT + * Created. + */ +#ifndef _DEV_EVSIO_H +#define _DEV_EVSIO_H + +/* Public type definitions. */ +#include +#include + +/* + * Identify this driver as one that uses the new driverkit and messaging API + */ +#ifndef _NeXT_MACH_EVENT_DRIVER_ +#define _NeXT_MACH_EVENT_DRIVER_ (1) +#endif /* !_NeXT_MACH_EVENT_DRIVER_ */ + +/* * */ + +#define kIOHIDKindKey "HIDKind" +#define kIOHIDInterfaceIDKey "HIDInterfaceID" +#define kIOHIDSubinterfaceIDKey "HIDSubinterfaceID" + +#define kIOHIDParametersKey "HIDParameters" + +#define kIOHIDVirtualHIDevice "HIDVirtualDevice" + +#define kIOHIDKeyRepeatKey "HIDKeyRepeat" +#define kIOHIDInitialKeyRepeatKey "HIDInitialKeyRepeat" +#define kIOHIDKeyMappingKey "HIDKeyMapping" +#define kIOHIDResetKeyboardKey "HIDResetKeyboard" + +#define kIOHIDKeyboardModifierMappingPairsKey "HIDKeyboardModifierMappingPairs" +#define kIOHIDKeyboardModifierMappingSrcKey "HIDKeyboardModifierMappingSrc" +#define kIOHIDKeyboardModifierMappingDstKey "HIDKeyboardModifierMappingDst" + +#define kIOHIDKeyboardCapsLockDoesLockKey "HIDKeyboardCapsLockDoesLock" +#define kIOHIDKeyboardSupportsF12EjectKey "HIDKeyboardSupportsF12Eject" +#define kIOHIDKeyboardSupportedModifiersKey "HIDKeyboardSupportedModifiers" + +#define kIOHIDPointerResolutionKey "HIDPointerResolution" +#define kIOHIDResetPointerKey "HIDResetPointer" +#define kIOHIDPointerConvertAbsoluteKey "HIDPointerConvertAbsolute" +#define kIOHIDPointerContactToMoveKey "HIDPointerContactToMove" +#define kIOHIDPointerPressureToClickKey "HIDPointerPressureToClick" +#define kIOHIDPointerButtonMode "HIDPointerButtonMode" +#define kIOHIDPointerButtonCountKey "HIDPointerButtonCount" + +#define kIOHIDPointerAccelerationKey "HIDPointerAcceleration" +#define kIOHIDPointerAccelerationSettingsKey "HIDPointerAccelerationSettings" +#define kIOHIDPointerAccelerationTypeKey "HIDPointerAccelerationType" +#define kIOHIDPointerAccelerationTableKey "HIDPointerAccelerationTable" + +#define kIOHIDScrollResetKey "HIDScrollReset" +#define kIOHIDScrollResolutionKey "HIDScrollResolution" +#define kIOHIDScrollReportRateKey "HIDScrollReportRate" +#define kIOHIDScrollAccelerationKey "HIDScrollAcceleration" +#define kIOHIDScrollAccelerationTypeKey "HIDScrollAccelerationType" +#define kIOHIDScrollAccelerationTableKey "HIDScrollAccelerationTable" + +#define kIOHIDScrollResolutionXKey "HIDScrollResolutionX" +#define kIOHIDScrollResolutionYKey "HIDScrollResolutionY" +#define kIOHIDScrollResolutionZKey "HIDScrollResolutionZ" + +#define kIOHIDScrollAccelerationTableXKey "HIDScrollAccelerationTableX" +#define kIOHIDScrollAccelerationTableYKey "HIDScrollAccelerationTableY" +#define kIOHIDScrollAccelerationTableZKey "HIDScrollAccelerationTableZ" + +#define kIOHIDScrollMouseButtonKey "HIDScrollMouseButton" + +#define kIOHIDScrollZoomModifierMaskKey "HIDScrollZoomModifierMask" + +#define kIOHIDTrackpadScrollAccelerationKey "HIDTrackpadScrollAcceleration" +#define kIOHIDMouseScrollAccelerationKey "HIDMouseScrollAcceleration" + +#define kIOHIDTrackpadAccelerationType "HIDTrackpadAcceleration" +#define kIOHIDMouseAccelerationType "HIDMouseAcceleration" + +#define kIOHIDClickTimeKey "HIDClickTime" +#define kIOHIDClickSpaceKey "HIDClickSpace" + +#define kIOHIDWaitCursorFrameIntervalKey "HIDWaitCursorFrameInterval" + +#define kIOHIDAutoDimThresholdKey "HIDAutoDimThreshold" +#define kIOHIDAutoDimStateKey "HIDAutoDimState" +#define kIOHIDAutoDimTimeKey "HIDAutoDimTime" +#define kIOHIDIdleTimeKey "HIDIdleTime" + +#define kIOHIDBrightnessKey "HIDBrightness" +#define kIOHIDAutoDimBrightnessKey "HIDAutoDimBrightness" + +#define kIOHIDFKeyModeKey "HIDFKeyMode" + +// if kIOHIDStickyKeysDisabledKey is 1, then all sticky keys functionality +// is completely turned off. Multiple shifts will have no effect. +#define kIOHIDStickyKeysDisabledKey "HIDStickyKeysDisabled" + +// if kIOHIDStickyKeysOnKey is 1 then a depressed modifier will stay down +// until a non-modifer key is pressed (or sticky keys is turned off) +#define kIOHIDStickyKeysOnKey "HIDStickyKeysOn" + +// if kIOHIDStickyKeysShiftTogglesKey is 1, then a sequence of five +// shift keys in sequence will toggle sticky keys on or off +#define kIOHIDStickyKeysShiftTogglesKey "HIDStickyKeysShiftToggles" + +// if kIOHIDMouseKeysOptionTogglesKey is 1, then a sequence of five +// option keys in sequence will toggle mouse keys on or off +#define kIOHIDMouseKeysOptionTogglesKey "HIDMouseKeysOptionToggles" + +// kIOHIDSlowKeysDelayKey represents the delay used for slow keys. +// if kIOHIDSlowKeysDelayKey is 0, then slow keys off +#define kIOHIDSlowKeysDelayKey "HIDSlowKeysDelay" + +#define kIOHIDF12EjectDelayKey "HIDF12EjectDelay" + +#define kIOHIDMouseKeysOnKey "HIDMouseKeysOn" + +#define kIOHIDUseKeyswitchKey "HIDUseKeyswitch" + +#define kIOHIDDisallowRemappingOfPrimaryClickKey "HIDDisallowRemappingOfPrimaryClick" +#define kIOHIDMouseKeysEnablesVirtualNumPadKey "HIDMouseKeysEnablesVirtualNumPad" + +#define kIOHIDResetLEDsKey "HIDResetLEDs" + + +#ifdef __ppc__ + // the following are misspelled keys present in the system + // they are being kept around, but will eventually be deprecated + #define kIOHIDSickyKeysDisabledKey kIOHIDStickyKeysDisabledKey + #define kIOHIDSickyKeysOnKey kIOHIDStickyKeysOnKey + #define kIOHIDSickyKeysShiftTogglesKey kIOHIDStickyKeysShiftTogglesKey +#endif + +// the following values are used in kIOHIDPointerButtonMode +typedef enum { + kIOHIDButtonMode_BothLeftClicks = 0, + kIOHIDButtonMode_ReverseLeftRightClicks = 1, + kIOHIDButtonMode_EnableRightClick = 2 +} IOHIDButtonModes; + +#ifdef _undef +#define EVS_PREFIX "Evs_" /* All EVS calls start with this string */ + +/* WaitCursor-related ioctls */ + +#define EVSIOSWT "Evs_SetWaitThreshold" +#define EVSIOSWT_SIZE EVS_PACKED_TIME_SIZE + +#define EVSIOSWS "Evs_SetWaitSustain" +#define EVSIOSWS_SIZE EVS_PACKED_TIME_SIZE + +#define EVSIOSWFI "Evs_SetWaitFrameInterval" +#define EVSIOSWFI_SIZE EVS_PACKED_TIME_SIZE + +#define EVSIOCWINFO "Evs_CurrentWaitCursorInfo" +#define EVSIOCWINFO_THRESH 0 +#define EVSIOCWINFO_SUSTAIN (EVSIOCWINFO_THRESH + EVS_PACKED_TIME_SIZE) +#define EVSIOCWINFO_FINTERVAL (EVSIOCWINFO_SUSTAIN + EVS_PACKED_TIME_SIZE) +#define EVSIOCWINFO_SIZE (EVSIOCWINFO_FINTERVAL + EVS_PACKED_TIME_SIZE) +#endif + +#define EVS_PACKED_TIME_SIZE (sizeof(UInt64) / sizeof( unsigned int)) + +/* Device control ioctls. Levels specified may be in the range 0 - 64. */ + +#define EVSIOSB kIOHIDBrightnessKey +#define EVSIOSB_SIZE 1 + +#define EVSIOSADB kIOHIDAutoDimBrightnessKey +#define EVSIOSADB_SIZE 1 + +#ifdef _undef +#define EVSIOSA "Evs_SetAttenuation" +#define EVIOSA_SIZE 1 + +#define EVSIO_DCTLINFO "Evs_DeviceControlInfo" +typedef enum { + EVSIO_DCTLINFO_BRIGHT, + EVSIO_DCTLINFO_ATTEN, + EVSIO_DCTLINFO_AUTODIMBRIGHT +} evsio_DCTLINFOIndices; +#define EVSIO_DCTLINFO_SIZE (EVSIO_DCTLINFO_AUTODIMBRIGHT + 1) +#endif + +/* + * Device status request + */ +#define EVSIOINFO NX_EVS_DEVICE_INFO + + +/* Keyboard-related ioctls - implemented within Event Sources */ + +#define EVSIOSKR kIOHIDKeyRepeatKey +#define EVSIOSKR_SIZE EVS_PACKED_TIME_SIZE + +#define EVSIOSIKR kIOHIDInitialKeyRepeatKey +#define EVSIOSIKR_SIZE EVS_PACKED_TIME_SIZE + +#define EVSIORKBD kIOHIDResetKeyboardKey +#define EVSIORKBD_SIZE 1 + +#define EVSIOCKR_SIZE EVS_PACKED_TIME_SIZE + +#define EVSIOCKML kIOHIDKeyMappingKey +#define EVSIOCKML_SIZE 1 + +/* The following two tokens are for use with the get/set character routines. */ +#define EVSIOSKM kIOHIDKeyMappingKey +#define EVSIOSKM_SIZE 4096 + +#define EVSIOCKM kIOHIDKeyMappingKey +#define EVSIOCKM_SIZE 4096 + +/* Mouse-related ioctls - implemented within Event Sources */ + +#define EVSIOSMS kIOHIDPointerAccelerationKey +#define EVSIOSMS_SIZE (1) + +#define EVSIOCMS kIOHIDPointerAccelerationKey +#define EVSIOCMS_SIZE (1) + +#ifdef _undef +#define EVSIOSMH "Evs_SetMouseHandedness" +#define EVSIOSMH_SIZE 1 // value from NXMouseButton enum + +#define EVSIOCMH "Evs_CurrentMouseHandedness" +#define EVSIOCMH_SIZE 1 +#endif + +/* Generic pointer device controls, implemented by the Event Driver. */ +#define EVSIOSCT kIOHIDClickTimeKey +#define EVSIOSCT_SIZE EVS_PACKED_TIME_SIZE + +#define EVSIOSCS kIOHIDClickSpaceKey +typedef enum { + EVSIOSCS_X, + EVSIOSCS_Y +} evsioEVSIOSCSIndices; +#define EVSIOSCS_SIZE (EVSIOSCS_Y + 1) + +#define EVSIOSADT kIOHIDAutoDimThresholdKey +#define EVSIOSADT_SIZE EVS_PACKED_TIME_SIZE + +#define EVSIOSADS kIOHIDAutoDimStateKey +#define EVSIOSADS_SIZE 1 + +#define EVSIORMS kIOHIDResetPointerKey +#define EVSIORMS_SIZE 1 + +#define EVSIOCCT kIOHIDClickTimeKey +#define EVSIOCCT_SIZE EVS_PACKED_TIME_SIZE + +#define EVSIOCADT kIOHIDAutoDimThresholdKey +#define EVSIOCADT_SIZE EVS_PACKED_TIME_SIZE + +#define EVSIOGDADT kIOHIDAutoDimTimeKey +#define EVSIOGDADT_SIZE EVS_PACKED_TIME_SIZE + +#define EVSIOIDLE kIOHIDIdleTimeKey +#define EVSIOIDLE_SIZE EVS_PACKED_TIME_SIZE + +#define EVSIOCCS kIOHIDClickSpaceKey +typedef enum { + EVSIOCCS_X, + EVSIOCCS_Y +} evsioEVSIOCCSIndices; +#define EVSIOCCS_SIZE (EVSIOCCS_Y + 1) + +#define EVSIOCADS kIOHIDAutoDimStateKey +#define EVSIOCADS_SIZE 1 + +enum { + // Selectors for IOHIDGetModifierLockState and IOHIDSetModifierLockState + kIOHIDCapsLockState = 0x00000001, + kIOHIDNumLockState = 0x00000002, +}; + +#endif /* !_DEV_EVSIO_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/hidsystem/IOHIKeyboardMapper.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/hidsystem/IOHIKeyboardMapper.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/hidsystem/IOHIKeyboardMapper.h (revision 885) @@ -0,0 +1,350 @@ +/* + * @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 _IOHIKEYBOARDMAPPER_H +#define _IOHIKEYBOARDMAPPER_H + +#include +#include +#include +#include + +class IOHIKeyboard; +class IOHIDSystem; + +/* + * Key ip/down state is tracked in a bit list. Bits are set + * for key-down, and cleared for key-up. The bit vector and macros + * for it's manipulation are defined here. + */ + +typedef UInt32 * kbdBitVector; + +#define EVK_BITS_PER_UNIT 32 +#define EVK_BITS_MASK 31 +#define EVK_BITS_SHIFT 5 // 1<<5 == 32, for cheap divide + +#define EVK_KEYDOWN(n, bits) \ + (bits)[((n)>>EVK_BITS_SHIFT)] |= (1 << ((n) & EVK_BITS_MASK)) + +#define EVK_KEYUP(n, bits) \ + (bits)[((n)>>EVK_BITS_SHIFT)] &= ~(1 << ((n) & EVK_BITS_MASK)) + +#define EVK_IS_KEYDOWN(n, bits) \ + (((bits)[((n)>>EVK_BITS_SHIFT)] & (1 << ((n) & EVK_BITS_MASK))) != 0) + +/* the maximum number of modifier keys sticky keys can hold at once */ +#define kMAX_MODIFIERS 5 + +/* the number of shift keys in a row that must be depressed to toggle state */ +#define kNUM_SHIFTS_TO_ACTIVATE 5 + +/* the number of milliseconds all the shifts must be pressed in - 30 seconds (30000 mS)*/ +#define kDEFAULT_SHIFTEXPIREINTERVAL 30000 + + +// sticky keys state flags +enum +{ + kState_Disabled_Flag = 0x0001, // disabled and will do nothing until this is changed + kState_ShiftActivates_Flag = 0x0002, // the 'on' gesture (5 shifts) will activate + kState_On = 0x0004, // currently on, will hold down modifiers when pressed + kState_On_ModifiersDown = 0x0008, // one or more modifiers being held down + + kState_Mask = 0x00FF, // mask for all states +}; + +typedef struct _stickyKeys_ToggleInfo +{ + // size of this allocation + IOByteCount size; + + // which modifier key we are tracking (using NX_WHICHMODMASK) + unsigned toggleModifier; + + // the number of times the modifier must be pressed to toggle + unsigned repetitionsToToggle; + + // how long the user has to press the modifier repetitionsToToggle times + // the default is 30 seconds + AbsoluteTime expireInterval; + + // the number of times the modifier used within the alloted time + unsigned currentCount; + + // the times that the last shift must occer for this one to be used + // this array will actually be of size repetitionsToToggle + AbsoluteTime deadlines[1]; +} StickyKeys_ToggleInfo; + +// Flags for each sticky key modifier +// This will allow for chording of keys +// and for key locking +enum +{ + kModifier_DidPerformModifiy = 0x01, + kModifier_DidKeyUp = 0x02, + kModifier_Locked = 0x04, +}; +typedef struct _stickyKeys_ModifierInfo +{ + UInt8 key; // Key code of the sticky modifier + UInt8 state; // The state of the sticky modifier + UInt8 leftModBit; // System Mod bit of the sticky modifier +} StickyKeys_ModifierInfo; + +class IOHIDKeyboardDevice; + +class IOHIKeyboardMapper : public OSObject +{ + OSDeclareDefaultStructors(IOHIKeyboardMapper); + +private: + IOHIKeyboard * _delegate; // KeyMap delegate + bool _mappingShouldBeFreed; // true if map can be IOFree'd + NXParsedKeyMapping _parsedMapping; // current system-wide keymap + IOHIDSystem * _hidSystem; // target of IOHIKeyboard (should be IOHIDSystem) + + // binary compatibility padding + struct ExpansionData { + + // This is for F12 eject + UInt16 f12Eject_State; + UInt32 eject_Delay_MS; + IOTimerEventSource *ejectTimerEventSource; + + // This is for sticky keys + kbdBitVector cached_KeyBits; + StickyKeys_ModifierInfo stickyKeys_StuckModifiers[kMAX_MODIFIERS]; + IOInterruptEventSource *stickyKeysMouseClickEventSource; + IOInterruptEventSource *stickyKeysSetFnStateEventSource; + // The following should really be statics, but placing here + // to match design by predecesor. + OSDictionary *offFnParamDict; + OSDictionary *onFnParamDict; + + // This is for SlowKeys + UInt16 slowKeys_State; + UInt32 slowKeys_Delay_MS; + IOTimerEventSource *slowKeysTimerEventSource; + + // stored for slowKeysPostProcess + UInt8 slowKeys_Aborted_Key; + UInt8 slowKeys_Current_Key; + + UInt32 specialKeyModifierFlags; + + bool supportsF12Eject; + + SInt32 modifierSwap_Modifiers[NX_NUMMODIFIERS]; + + unsigned char * cachedAlphaLockModDefs; + }; + ExpansionData * _reserved; // Reserved for future use. (Internal use only) + +public: + static IOHIKeyboardMapper * keyboardMapper( + IOHIKeyboard * delegate, + const UInt8 * mapping, + UInt32 mappingLength, + bool mappingShouldBeFreed ); + + virtual bool init(IOHIKeyboard * delegate, + const UInt8 * mapping, + UInt32 mappingLength, + bool mappingShouldBeFreed); + virtual void free(); + + virtual const UInt8 * mapping(); + virtual UInt32 mappingLength(); + virtual bool serialize(OSSerialize *s) const; + + virtual void translateKeyCode(UInt8 key, bool keyDown, kbdBitVector keyBits); + virtual UInt8 getParsedSpecialKey(UInt8 logical); //retrieve a key from _parsedMapping + + virtual void setKeyboardTarget (IOService * keyboardTarget); + + virtual bool updateProperties (void); + virtual IOReturn setParamProperties (OSDictionary * dict); + + // keyEventPostProcess is called while a lock is not held, so a recursive + // call back into HIKeyboard is possible + virtual void keyEventPostProcess (void); + +private: + static void makeNumberParamProperty( OSDictionary * dict, const char * key, + unsigned long long number, unsigned int bits ); + + + virtual bool parseKeyMapping(const UInt8 * mapping, + UInt32 mappingLength, + NXParsedKeyMapping * parsedMapping) const; + + virtual void calcModBit(int bit, kbdBitVector keyBits); + virtual void doModCalc(int key, kbdBitVector keyBits); + virtual void doCharGen(int keyCode, bool down); + + /* sticky keys functionality */ +private: + // original translateKeyCode + void rawTranslateKeyCode (UInt8 key, bool keyDown, kbdBitVector keyBits); + bool modifierSwapFilterKey(UInt8 * key); + + // the current state of stickyKeys + UInt32 _stickyKeys_State; + + // the number of modifiers being held down by stickyKeys + int _stickyKeys_NumModifiersDown; + + ////////////////////////////////////////////////////////////// + // THE FOLLOWING CLASS VARIABLE HAS BEEN DEPRECATED + // + // PLEASE USE _stickyKeys_StuckModifiers + // + UInt8 _stickyKeys_Modifiers[kMAX_MODIFIERS]; + ////////////////////////////////////////////////////////////// + + // contains the info needed to keep track of shift repetitions + StickyKeys_ToggleInfo * _stickyKeys_ShiftToggle; + + // contains the info needed to keep track of option repetitions + StickyKeys_ToggleInfo * _stickyKeys_OptionToggle; + + // dictionaries with cached on and off states, used to set params when state changes + bool _stateDirty; + OSDictionary * _onParamDict; + OSDictionary * _offParamDict; + + // init/free vars + bool stickyKeysinit (void); + void stickyKeysfree (void); + + // allocate/free a StickyKeys_ToggleInfo struct + static StickyKeys_ToggleInfo * stickyKeysAllocToggleInfo (unsigned maxCount); + static void stickyKeysFreeToggleInfo (StickyKeys_ToggleInfo * toggleInfo); + + // create on/off dicts as part of init + bool createParamDicts (void); + + // post special keyboard events thru the event system + void postKeyboardSpecialEvent (unsigned subtype, unsigned eventType=NX_SYSDEFINED); + + // check any modifier to see if it is pressed 5 times + // based on StickyKeys_ToggleInfo + bool stickyKeysModifierToggleCheck( + StickyKeys_ToggleInfo * toggleInfo, + UInt8 key, + bool keyDown, + kbdBitVector keyBits, + bool mouseClick = false); + + // non-modifier key pressed + void stickyKeysNonModifierKey (UInt8 key, bool keyDown, kbdBitVector keyBits, bool mouseClick = false); + + // modifier key pressed (shift, command, option, control) + bool stickyKeysModifierKey (UInt8 key, bool keyDown, kbdBitVector keyBits); + + // main entry point, called for all keys (returns true if key handled) + bool stickyKeysFilterKey (UInt8 key, bool keyDown, kbdBitVector keyBits, bool mouseClick = false); + + // called by interrupt event source to inform sticky keys of mouse down event + static void stickyKeysMouseUp(IOHIKeyboardMapper *owner, IOEventSource *sender); + + void stickyKeysCleanup(); + + // called by interrupt event source to restore prior fn state + static void stickyKeysSetFnState(IOHIKeyboardMapper *owner, IOEventSource *sender); + + /* F12 Eject Functionality */ +private: + + // Determining f12 eject key press + // Returns true if f12 held down for a predetermined period of time. + bool f12EjectFilterKey (UInt8 key, bool keyDown, kbdBitVector keyBits); + + // Timer function for eject + static void performF12Eject(IOHIKeyboardMapper *owner, IOTimerEventSource *sender); + + /* SlowKeys Functionality */ +private: + // Slow keys methods + bool slowKeysFilterKey (UInt8 key, bool keyDown, kbdBitVector keyBits); + + static void slowKeysPostProcess (IOHIKeyboardMapper *owner, IOTimerEventSource *sender); + + +public: + OSMetaClassDeclareReservedUsed(IOHIKeyboardMapper, 0); + virtual IOReturn message( UInt32 type, IOService * provider, void * argument = 0 ); + + // binary compatibility padding + OSMetaClassDeclareReservedUnused(IOHIKeyboardMapper, 1); + OSMetaClassDeclareReservedUnused(IOHIKeyboardMapper, 2); + OSMetaClassDeclareReservedUnused(IOHIKeyboardMapper, 3); + OSMetaClassDeclareReservedUnused(IOHIKeyboardMapper, 4); + OSMetaClassDeclareReservedUnused(IOHIKeyboardMapper, 5); + OSMetaClassDeclareReservedUnused(IOHIKeyboardMapper, 6); + OSMetaClassDeclareReservedUnused(IOHIKeyboardMapper, 7); + OSMetaClassDeclareReservedUnused(IOHIKeyboardMapper, 8); + OSMetaClassDeclareReservedUnused(IOHIKeyboardMapper, 9); + OSMetaClassDeclareReservedUnused(IOHIKeyboardMapper, 10); + OSMetaClassDeclareReservedUnused(IOHIKeyboardMapper, 11); + OSMetaClassDeclareReservedUnused(IOHIKeyboardMapper, 12); + OSMetaClassDeclareReservedUnused(IOHIKeyboardMapper, 13); + OSMetaClassDeclareReservedUnused(IOHIKeyboardMapper, 14); + OSMetaClassDeclareReservedUnused(IOHIKeyboardMapper, 15); +}; + +#endif _IOHIKEYBOARDMAPPER_H + +/* + * HISTORICAL NOTE: + * The "delegate" object had to respond to the following protocol; + * this protocol has since been merged into the IOHIKeyboard class. + * + * @protocol KeyMapDelegate + * + * - keyboardEvent :(unsigned)eventType + * flags :(unsigned)flags + * keyCode :(unsigned)keyCode + * charCode:(unsigned)charCode + * charSet :(unsigned)charSet + * originalCharCode:(unsigned)origCharCode + * originalCharSet:(unsigned)origCharSet; + * + * - keyboardSpecialEvent:(unsigned)eventType + * flags :(unsigned)flags + * keyCode :(unsigned)keyCode + * specialty:(unsigned)flavor; + * + * - updateEventFlags:(unsigned)flags; // Does not generate events + * + * - (unsigned)eventFlags; // Global event flags + * - (unsigned)deviceFlags; // per-device event flags + * - setDeviceFlags:(unsigned)flags; // Set device event flags + * - (bool)alphaLock; // current alpha-lock state + * - setAlphaLock:(bool)val; // Set current alpha-lock state + * - (bool)charKeyActive; // Is a character gen. key down? + * - setCharKeyActive:(bool)val; // Note that a char gen key is down. + * + * @end + */ Index: branches/azimutz/Cleancut/i386/include/IOKit/hidsystem/IOHIPointing.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/hidsystem/IOHIPointing.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/hidsystem/IOHIPointing.h (revision 885) @@ -0,0 +1,280 @@ +/* + * @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 _IOHIPOINTING_H +#define _IOHIPOINTING_H + +#include +#include +#include + +/* Start Action Definitions */ + +/* + * HISTORICAL NOTE: + * The following entry points were part of the IOHIPointingEvents + * protocol. + */ +typedef void (*RelativePointerEventAction)(OSObject * target, + /* buttons */ int buttons, + /* deltaX */ int dx, + /* deltaY */ int dy, + /* atTime */ AbsoluteTime ts); + +typedef void (*AbsolutePointerEventAction)(OSObject * target, + /* buttons */ int buttons, + /* at */ IOGPoint * newLoc, + /* withBounds */ IOGBounds *bounds, + /* inProximity */ bool proximity, + /* withPressure */ int pressure, + /* withAngle */ int stylusAngle, + /* atTime */ AbsoluteTime ts); + +typedef void (*ScrollWheelEventAction)(OSObject * target, + short deltaAxis1, + short deltaAxis2, + short deltaAxis3, + AbsoluteTime ts); + +/* Event Callback Definitions */ + +typedef void (*RelativePointerEventCallback)( + /* target */ OSObject * target, + /* buttons */ int buttons, + /* deltaX */ int dx, + /* deltaY */ int dy, + /* atTime */ AbsoluteTime ts, + /* sender */ OSObject * sender, + /* refcon */ void * refcon); + +typedef void (*AbsolutePointerEventCallback)( + /* target */ OSObject * target, + /* buttons */ int buttons, + /* at */ IOGPoint * newLoc, + /* withBounds */ IOGBounds *bounds, + /* inProximity */ bool proximity, + /* withPressure */ int pressure, + /* withAngle */ int stylusAngle, + /* atTime */ AbsoluteTime ts, + /* sender */ OSObject * sender, + /* refcon */ void * refcon); + +typedef void (*ScrollWheelEventCallback)( + /* target */ OSObject * target, + /* delta1 */ short deltaAxis1, + /* delta2 */ short deltaAxis2, + /* delta3 */ short deltaAxis3, + /* fixedDelta1 */ IOFixed fixedDelta1, + /* fixedDelta2 */ IOFixed fixedDelta2, + /* fixedDelta3 */ IOFixed fixedDelta3, + /* pointDelta1 */ SInt32 pointDelta1, + /* pointDelta2 */ SInt32 pointDelta2, + /* pointDelta3 */ SInt32 pointDelta3, + /* reserved */ SInt32 options, + /* atTime */ AbsoluteTime ts, + /* sender */ OSObject * sender, + /* refcon */ void * refcon); + +/* End Action Definitions */ + +/* Default accel level parameters */ +#define EV_DEFAULTPOINTERACCELLEVEL 0x0000b000 +#define EV_DEFAULTSCROLLACCELLEVEL 0x00005000 + +class IOHIDPointingDevice; +struct ScrollAccelInfo; + +class IOHIPointing : public IOHIDevice +{ + OSDeclareDefaultStructors(IOHIPointing); + + friend class IOHITablet; + friend class IOHIDPointing; + +private: + IOLock * _deviceLock; // Lock for all device access + int _buttonMode; // The "handedness" of the pointer + IOFixed _acceleration; + bool _convertAbsoluteToRelative; + bool _contactToMove; + bool _hadContact; + IOGPoint _previousLocation; + UInt8 _pressureThresholdToClick; // A scale factor of 0 to 255 to determine how much pressure is necessary to generate a primary mouse click - a value of 255 means no click will be generated + void * _scaleSegments; + IOItemCount _scaleSegCount; + IOFixed _fractX; + IOFixed _fractY; + + OSObject * _relativePointerEventTarget; + RelativePointerEventAction _relativePointerEventAction; + OSObject * _absolutePointerEventTarget; + AbsolutePointerEventAction _absolutePointerEventAction; + OSObject * _scrollWheelEventTarget; + ScrollWheelEventAction _scrollWheelEventAction; + + struct ExpansionData { + UInt32 scrollType; + + ScrollAccelInfo * scrollWheelInfo; + ScrollAccelInfo * scrollPointerInfo; + + IOFixed scrollFixedDeltaAxis1; + IOFixed scrollFixedDeltaAxis2; + IOFixed scrollFixedDeltaAxis3; + SInt32 scrollPointDeltaAxis1; + SInt32 scrollPointDeltaAxis2; + SInt32 scrollPointDeltaAxis3; + UInt32 scrollButtonMask; + + // Added to post events to the HID Manager + IOHIDPointingDevice * hidPointingNub; + IOService * openClient; + + bool isSeized; + UInt32 accelerateMode; + + UInt32 scrollZoomMask; + bool lastScrollWasZoom; + bool scrollOff; + }; + + ExpansionData * _reserved; + + void setPointingMode(UInt32 accelerateMode); + UInt32 getPointingMode (); + void setScrollType(UInt32 scrollType); + UInt32 getScrollType(); + + void dispatchScrollWheelEventWithAccelInfo( + SInt32 deltaAxis1, + SInt32 deltaAxis2, + SInt32 deltaAxis3, + ScrollAccelInfo * info, + AbsoluteTime ts); + + +protected: + virtual void dispatchRelativePointerEvent(int dx, + int dy, + UInt32 buttonState, + AbsoluteTime ts); + + virtual void dispatchAbsolutePointerEvent(IOGPoint * newLoc, + IOGBounds * bounds, + UInt32 buttonState, + bool proximity, + int pressure, + int pressureMin, + int pressureMax, + int stylusAngle, + AbsoluteTime ts); + + virtual void dispatchScrollWheelEvent(short deltaAxis1, + short deltaAxis2, + short deltaAxis3, + AbsoluteTime ts); + +public: + virtual bool init(OSDictionary * properties = 0); + virtual bool start(IOService * provider); + virtual void free(); + + virtual bool open(IOService * client, + IOOptionBits options, + RelativePointerEventAction rpeAction, + AbsolutePointerEventAction apeAction, + ScrollWheelEventAction sweAction); + + bool open( IOService * client, + IOOptionBits options, + void *, + RelativePointerEventCallback rpeCallback, + AbsolutePointerEventCallback apeCallback, + ScrollWheelEventCallback sweCallback); + + virtual void close(IOService * client, IOOptionBits ); + virtual IOReturn message( UInt32 type, IOService * provider, + void * argument = 0 ); + + virtual IOHIDKind hidKind(); + virtual bool updateProperties( void ); + virtual IOReturn setParamProperties( OSDictionary * dict ); + virtual IOReturn powerStateWillChangeTo( IOPMPowerFlags powerFlags, + unsigned long newState, IOService * device); + virtual IOReturn powerStateDidChangeTo( IOPMPowerFlags powerFlags, + unsigned long newState, IOService * device); + +protected: // for subclasses to implement + virtual OSData * copyAccelerationTable(); + virtual IOItemCount buttonCount(); + virtual IOFixed resolution(); + + // RY: Adding method to copy scroll wheel accel table. + // Unfortunately, we don't have any padding, so this + // is going to be non-virtual. + /*virtual*/ OSData * copyScrollAccelerationTable(); + +private: + virtual bool resetPointer(); + virtual void scalePointer(int * dxp, int * dyp); + virtual void setupForAcceleration(IOFixed accl); + + // RY: Adding methods to support scroll wheel accel. + // Unfortunately, we don't have any padding, so these + // are going to be non-virtual. + /*virtual*/ bool resetScroll(); + /*virtual*/ void setupScrollForAcceleration(IOFixed accl); + + // RY: We have to make sure that subclasses that will + // take advantage of this have their defined resolution + // in their property table. + /*virtual*/ IOFixed scrollResolutionForType(SInt32 type=-1); + /*virtual*/ IOFixed scrollReportRate(); + /*virtual*/ OSData * copyScrollAccelerationTableForType(SInt32 type=-1); + +private: + static void _relativePointerEvent( IOHIPointing * self, + int buttons, + /* deltaX */ int dx, + /* deltaY */ int dy, + /* atTime */ AbsoluteTime ts); + + /* Tablet event reporting */ + static void _absolutePointerEvent(IOHIPointing * self, + int buttons, + /* at */ IOGPoint * newLoc, + /* withBounds */ IOGBounds *bounds, + /* inProximity */ bool proximity, + /* withPressure */ int pressure, + /* withAngle */ int stylusAngle, + /* atTime */ AbsoluteTime ts); + + /* Mouse scroll wheel event reporting */ + static void _scrollWheelEvent(IOHIPointing *self, + short deltaAxis1, + short deltaAxis2, + short deltaAxis3, + AbsoluteTime ts); + +}; + +#endif /* !_IOHIPOINTING_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/hidsystem/ev_keymap.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/hidsystem/ev_keymap.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/hidsystem/ev_keymap.h (revision 885) @@ -0,0 +1,166 @@ +/* + * @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@ + */ +/* Copyright (c) 1992 NeXT Computer, Inc. All rights reserved. + * + * ev_keymap.h + * Defines the structure used for parsing keymappings. These structures + * and definitions are used by event sources in the kernel and by + * applications and utilities which manipulate keymaps. + * + * HISTORY + * 02-Jun-1992 Mike Paquette at NeXT + * Created. + */ + +#ifndef _DEV_EV_KEYMAP_H +#define _DEV_EV_KEYMAP_H + +#define NX_NUMKEYCODES 256 /* Highest key code is 0xff. ADB used to use 0x80 for keydown state, but who the heck uses adb anymore. */ +#define NX_NUMSEQUENCES 128 /* Maximum possible number of sequences */ +#define NX_NUMMODIFIERS 16 /* Maximum number of modifier bits */ +#define NX_BYTE_CODES 0 /* If first short 0, all are bytes (else shorts) */ + +#define NX_WHICHMODMASK 0x0f /* bits out of keyBits for bucky bits */ +#define NX_MODMASK 0x10 /* Bit out of keyBits indicates modifier bit */ +#define NX_CHARGENMASK 0x20 /* bit out of keyBits for char gen */ +#define NX_SPECIALKEYMASK 0x40 /* bit out of keyBits for specialty key */ +#define NX_KEYSTATEMASK 0x80 /* OBSOLETE - DO NOT USE IN NEW DESIGNS */ + +/* + * Special keys currently known to and understood by the system. + * If new specialty keys are invented, extend this list as appropriate. + * The presence of these keys in a particular implementation is not + * guaranteed. + */ +#define NX_NOSPECIALKEY 0xFFFF +#define NX_KEYTYPE_SOUND_UP 0 +#define NX_KEYTYPE_SOUND_DOWN 1 +#define NX_KEYTYPE_BRIGHTNESS_UP 2 +#define NX_KEYTYPE_BRIGHTNESS_DOWN 3 +#define NX_KEYTYPE_CAPS_LOCK 4 +#define NX_KEYTYPE_HELP 5 +#define NX_POWER_KEY 6 +#define NX_KEYTYPE_MUTE 7 +#define NX_UP_ARROW_KEY 8 +#define NX_DOWN_ARROW_KEY 9 +#define NX_KEYTYPE_NUM_LOCK 10 + +#define NX_KEYTYPE_CONTRAST_UP 11 +#define NX_KEYTYPE_CONTRAST_DOWN 12 +#define NX_KEYTYPE_LAUNCH_PANEL 13 +#define NX_KEYTYPE_EJECT 14 +#define NX_KEYTYPE_VIDMIRROR 15 + +#define NX_KEYTYPE_PLAY 16 +#define NX_KEYTYPE_NEXT 17 +#define NX_KEYTYPE_PREVIOUS 18 +#define NX_KEYTYPE_FAST 19 +#define NX_KEYTYPE_REWIND 20 + +#define NX_KEYTYPE_ILLUMINATION_UP 21 +#define NX_KEYTYPE_ILLUMINATION_DOWN 22 +#define NX_KEYTYPE_ILLUMINATION_TOGGLE 23 + +#define NX_NUMSPECIALKEYS 24 /* Maximum number of special keys */ +#define NX_NUM_SCANNED_SPECIALKEYS 24 /* First 24 special keys are */ + /* actively scanned in kernel */ + +/* Mask of special keys that are posted as events */ + +#define NX_SPECIALKEY_POST_MASK \ + ((1 << NX_KEYTYPE_SOUND_UP) | (1 << NX_KEYTYPE_SOUND_DOWN) | \ + (1 << NX_POWER_KEY) | (1 << NX_KEYTYPE_MUTE) | \ + (1 << NX_KEYTYPE_BRIGHTNESS_UP) | (1 << NX_KEYTYPE_BRIGHTNESS_DOWN) | \ + (1 << NX_KEYTYPE_CONTRAST_UP) | (1 << NX_KEYTYPE_CONTRAST_UP) | \ + (1 << NX_KEYTYPE_LAUNCH_PANEL) | (1 << NX_KEYTYPE_EJECT) | \ + (1 << NX_KEYTYPE_VIDMIRROR) | (1 << NX_KEYTYPE_PLAY) | \ + (1 << NX_KEYTYPE_NEXT) | (1 << NX_KEYTYPE_PREVIOUS) | \ + (1 << NX_KEYTYPE_FAST) | (1 << NX_KEYTYPE_REWIND) | \ + (1 << NX_KEYTYPE_ILLUMINATION_UP) | \ + (1 << NX_KEYTYPE_ILLUMINATION_DOWN) | \ + (1 << NX_KEYTYPE_ILLUMINATION_TOGGLE) | 0) + +/* Modifier key indices into modDefs[] */ +#define NX_MODIFIERKEY_ALPHALOCK 0 +#define NX_MODIFIERKEY_SHIFT 1 +#define NX_MODIFIERKEY_CONTROL 2 +#define NX_MODIFIERKEY_ALTERNATE 3 +#define NX_MODIFIERKEY_COMMAND 4 +#define NX_MODIFIERKEY_NUMERICPAD 5 +#define NX_MODIFIERKEY_HELP 6 +#define NX_MODIFIERKEY_SECONDARYFN 7 +#define NX_MODIFIERKEY_NUMLOCK 8 + +/* support for right hand modifier */ +#define NX_MODIFIERKEY_RSHIFT 9 +#define NX_MODIFIERKEY_RCONTROL 10 +#define NX_MODIFIERKEY_RALTERNATE 11 +#define NX_MODIFIERKEY_RCOMMAND 12 + + +typedef struct _NXParsedKeyMapping_ { + /* If nonzero, all numbers are shorts; if zero, all numbers are bytes*/ + short shorts; + + /* + * For each keycode, low order bit says if the key + * generates characters. + * High order bit says if the key is assigned to a modifier bit. + * The second to low order bit gives the current state of the key. + */ + char keyBits[NX_NUMKEYCODES]; + + /* Bit number of highest numbered modifier bit */ + int maxMod; + + /* Pointers to where the list of keys for each modifiers bit begins, + * or NULL. + */ + unsigned char *modDefs[NX_NUMMODIFIERS]; + + /* Key code of highest key deinfed to generate characters */ + int numDefs; + + /* Pointer into the keyMapping where this key's definitions begin */ + unsigned char *keyDefs[NX_NUMKEYCODES]; + + /* number of sequence definitions */ + int numSeqs; + + /* pointers to sequences */ + unsigned char *seqDefs[NX_NUMSEQUENCES]; + + /* Special key definitions */ + int numSpecialKeys; + + /* Special key values, or 0xFFFF if none */ + unsigned short specialKeys[NX_NUMSPECIALKEYS]; + + /* Pointer to the original keymapping string */ + const unsigned char *mapping; + + /* Length of the original string */ + int mappingLen; +} NXParsedKeyMapping; + +#endif /* !_DEV_EV_KEYMAP_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/hidsystem/IOHIDSystem.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/hidsystem/IOHIDSystem.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/hidsystem/IOHIDSystem.h (revision 885) @@ -0,0 +1,785 @@ +/* + * @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@ + */ +/* Copyright (c) 1992 NeXT Computer, Inc. All rights reserved. + * + * EventDriver.h - Exported Interface Event Driver object. + * + * The EventDriver is a pseudo-device driver. + * + * HISTORY + * 19 Mar 1992 Mike Paquette at NeXT + * Created. + * 4 Aug 1993 Erik Kay at NeXT + * API cleanup + */ + +#ifndef _IOHIDSYSTEM_H +#define _IOHIDSYSTEM_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if TARGET_OS_EMBEDDED +class IOGraphicsDevice; +#else +#include +#endif +#include +#include +#include +#include +#include +#include /* For NX_NUM_SCANNED_SPECIALKEYS */ + + +// The following messages should be unique across the entire system +#ifndef sub_iokit_hidsystem +#define sub_iokit_hidsystem err_sub(14) +#endif + +#define kIOHIDSystem508MouseClickMessage iokit_family_msg(sub_iokit_hidsystem, 1) +#define kIOHIDSystemDeviceSeizeRequestMessage iokit_family_msg(sub_iokit_hidsystem, 2) +#define kIOHIDSystem508SpecialKeyDownMessage iokit_family_msg(sub_iokit_hidsystem, 3) + +class IOHIDKeyboardDevice; +class IOHIDPointingDevice; +class IOHIDEvent; + +class IOHIDSystem : public IOService +{ + OSDeclareDefaultStructors(IOHIDSystem); + + friend class IOHIDUserClient; + friend class IOHIDParamUserClient; + friend class IOHIDEventSystemUserClient; + +private: + IOWorkLoop * workLoop; + IOTimerEventSource * timerES; + IOTimerEventSource * vblES; + IOInterruptEventSource * eventConsumerES; + IOInterruptEventSource * keyboardEQES; + IOCommandGate * cmdGate; + IOUserClient * serverConnect; + IOUserClient * paramConnect; + IONotifier * eventPublishNotify; + IONotifier * eventTerminateNotify; + IONotifier * publishNotify; + IONotifier * terminateNotify; + + OSArray * ioHIDevices; + OSSet * touchEventPosters; + + // Ports on which we hold send rights + mach_port_t eventPort; // Send msg here when event queue + // goes non-empty + mach_port_t stackShotPort; + mach_port_t _specialKeyPort[NX_NUM_SCANNED_SPECIALKEYS]; // Special key msgs + void *eventMsg; // Msg to be sent to Window Server. + void *stackShotMsg; // Msg to be sent to Stack Shot. + + // Shared memory area information + IOBufferMemoryDescriptor * globalMemory; + uintptr_t shmem_addr; // kernel address of shared memory + vm_size_t shmem_size; // size of shared memory + + // Pointers to structures which occupy the shared memory area. + volatile void *evs; // Pointer to private driver shmem + volatile EvGlobals *evg; // Pointer to EvGlobals (shmem) + // Internal variables related to the shared memory area + int lleqSize; // # of entries in low-level queue + // FIXME: why is this ivar lleqSize an ivar? {Dan] + + // Screens list + vm_size_t evScreenSize; // Byte size of evScreen array + void *evScreen; // array of screens known to driver + volatile void *lastShmemPtr; // Pointer used to index thru shmem + // while assigning shared areas to + // drivers. + int screens; // running total of allocated screens + UInt32 cursorScreens; // bit mask of screens with cursor present + UInt32 cursorPinScreen;// a screen to pin against + IOGBounds cursorPin; // Range to which cursor is pinned + // while on this screen. + IOGBounds workSpace; // IOGBounds of full workspace. + // Event Status state - This includes things like event timestamps, + // time til screen dim, and related things manipulated through the + // Event Status API. + // + IOGPoint pointerLoc; // Current pointing device location + // The value leads evg->cursorLoc. + IOGPoint pointerDelta; // The cumulative pointer delta values since + // previous mouse move event was posted + + IOGPoint clickLoc; // location of last mouse click + IOGPoint clickSpaceThresh; // max mouse delta to be a doubleclick + int clickState; // Current click state + + bool evOpenCalled; // Has the driver been opened? + bool evInitialized; // Has the first-open-only initialization run? + bool evStateChanging; // Is the event system state changing. + bool eventsOpen; // Boolean: has evmmap been called yet? + bool cursorStarted; // periodic events running? + bool cursorEnabled; // cursor positioning ok? + bool cursorCoupled; // cursor positioning on pointer moves ok? + bool cursorPinned; // cursor positioning on pointer moves ok? + + short leftENum; // Unique ID for last left down event + short rightENum; // Unique ID for last right down event + + // The periodic event mechanism timestamps and state + // are recorded here. + AbsoluteTime thisPeriodicRun; + AbsoluteTime periodicEventDelta;// Time between periodic events + // todo: make infinite + AbsoluteTime clickTime; // Timestamps used to determine doubleclicks + AbsoluteTime clickTimeThresh; + + AbsoluteTime waitSustain; // Sustain time before removing cursor + AbsoluteTime waitSusTime; // Sustain counter + AbsoluteTime waitFrameRate; // Ticks per wait cursor frame + AbsoluteTime waitFrameTime; // Wait cursor frame timer + + AbsoluteTime lastRelativeEventTime; // Used to post mouse events once per frame + AbsoluteTime lastRelativeMoveTime; + AbsoluteTime lastEventTime; + AbsoluteTime lastUndimEvent; + SInt32 postDeltaX, accumDX; + SInt32 postDeltaY, accumDY; + + // Flags used in scheduling periodic event callbacks + bool needSetCursorPosition; + bool needToKickEventConsumer; + + IOService * displayManager; // points to display manager + IOPMPowerFlags displayState; + + IOService * rootDomain; + AbsoluteTime stateChangeDeadline; + + OSDictionary * savedParameters; // keep user settings + + const char * registryName; // cache our name + UInt32 maxWaitCursorFrame; // animation frames + UInt32 firstWaitCursorFrame; // + + int cachedEventFlags; + OSArray * cachedButtonStates; + + OSArray * systemInfo; + + IOHIDPointingDevice * _hidPointingDevice; + IOHIDKeyboardDevice * _hidKeyboardDevice; + + unsigned consumedKeyCode; + + OSObject * lastSender; + + UInt32 scrollZoomMask; + + bool setParamPropertiesInProgress; + + OSSet * dataQueueSet; + +private: + void vblEvent(void); + UInt8 getSubtypeForSender(OSObject * sender); + void updateMouseEventForSender(OSObject * sender, NXEventData * evData); + void updateMouseMoveEventForSender(OSObject * sender, NXEventData * evData); + void updateScrollEventForSender(OSObject * sender, NXEventData * evData); + static void _vblEvent(OSObject *self, IOTimerEventSource *sender); + + inline short getUniqueEventNum(); + + virtual IOReturn powerStateDidChangeTo( IOPMPowerFlags, unsigned long, IOService * ); + /* Resets */ + void _resetMouseParameters(); + + /* Initialize the shared memory area */ + void initShmem(bool clean); + /* Dispatch low level events through shared memory to the WindowServer */ + void postEvent(int what, + /* at */ IOGPoint * location, + /* atTime */ AbsoluteTime ts, + /* withData */ NXEventData * myData, + /* sender */ OSObject * sender = 0, + /* pid */ UInt32 extPID = 0, + /* processKEQ*/bool processKEQ = true); + /* Dispatch mechanisms for screen state changes */ + void evDispatch( + /* command */ EvCmd evcmd); + /* Dispatch mechanism for special key press */ + void evSpecialKeyMsg(unsigned key, + /* direction */ unsigned dir, + /* flags */ unsigned f, + /* level */ unsigned l); + /* Message the event consumer to process posted events */ + void kickEventConsumer(); + void sendStackShotMessage(); + + OSDictionary * createFilteredParamPropertiesForService(IOService * service, OSDictionary * dict); + + static void _periodicEvents(IOHIDSystem * self, + IOTimerEventSource *timer); + + static void doSpecialKeyMsg(IOHIDSystem * self, + struct evioSpecialKeyMsg *msg); + static void doKickEventConsumer(IOHIDSystem * self); + + static void doProcessKeyboardEQ(IOHIDSystem * self); + static void processKeyboardEQ(IOHIDSystem * self, AbsoluteTime * deadline = 0); + + static bool genericNotificationHandler( void * target, + void * ref, IOService * newService ); + + static bool handlePublishNotification( void * target, IOService * newService ); + + static bool handleTerminateNotification( void * target, IOService * service ); + + static void makeNumberParamProperty( OSDictionary * dict, const char * key, + unsigned long long number, unsigned int bits ); + + static void makeInt32ArrayParamProperty( OSDictionary * dict, const char * key, + UInt32 * array, unsigned int count ); + +/* + * HISTORICAL NOTE: + * The following methods were part of the IOHIDSystem(Input) category; + * the declarations have now been merged directly into this class. + * + * Exported Interface Event Driver object input services. + */ + +private: + // Schedule next periodic run based on current event system state. + void scheduleNextPeriodicEvent(); + // Message invoked to run periodic events. This method runs in the workloop. + void periodicEvents(IOTimerEventSource *timer); + // Start the cursor running. + bool startCursor(); + // Repin cursor location. + bool resetCursor(); + // Wait Cursor machinery. + void showWaitCursor(); + void hideWaitCursor(); + void animateWaitCursor(); + void changeCursor(int frame); + // Return screen number a point lies on. + int pointToScreen(IOGPoint * p); + + inline void showCursor(); + inline void hideCursor(); + inline void moveCursor(); + // Claim ownership of event sources. + void attachDefaultEventSources(); + // Give up ownership of event sources. + void detachEventSources(); + bool registerEventSource(IOService * source); + + // Set abs cursor position. + void setCursorPosition(IOGPoint * newLoc, bool external, OSObject * sender=0); + void _setButtonState(int buttons, + /* atTime */ AbsoluteTime ts, + OSObject * sender); + void _setCursorPosition(IOGPoint * newLoc, bool external, bool proximityChange = false, OSObject * sender=0); + + static bool _idleTimeSerializerCallback(void * target, void * ref, OSSerialize *s); + + void _postMouseMoveEvent(int what, + IOGPoint * location, + AbsoluteTime theClock, + OSObject * sender); + void createParameters( void ); + +/* END HISTORICAL NOTE */ + +public: + static IOHIDSystem * instance(); /* Return the current instance of the */ + /* EventDriver, or 0 if none. */ + static void scaleLocationToCurrentScreen(IOGPoint *location, IOGBounds *bounds); + + virtual bool init(OSDictionary * properties = 0); + virtual IOHIDSystem * probe(IOService * provider, + SInt32 * score); + virtual bool start(IOService * provider); + virtual IOReturn message(UInt32 type, IOService * provider, + void * argument); + virtual void free(); + virtual bool attach( IOService * provider ); + virtual void detach( IOService * provider ); + + virtual IOWorkLoop *getWorkLoop() const; + + virtual IOReturn evOpen(void); + virtual IOReturn evClose(void); + + virtual IOReturn setProperties( OSObject * properties ); + virtual IOReturn setParamProperties(OSDictionary * dict); + + /* Create the shared memory area */ + virtual IOReturn createShmem(void*,void*,void*,void*,void*,void*); + + /* register the IODataQueue for the new user events */ + virtual IOReturn registerEventQueue(IODataQueue * queue); + + /* Unregister the IODataQueue for the new user events */ + virtual IOReturn unregisterEventQueue(IODataQueue * queue); + + /* Set the port for event available notify msg */ + virtual void setEventPort(mach_port_t port); + /* Set the port for the special key keypress msg */ + virtual IOReturn setSpecialKeyPort( + /* keyFlavor */ int special_key, + /* keyPort */ mach_port_t key_port); + virtual mach_port_t specialKeyPort(int special_key); + + + virtual IOReturn newUserClient(task_t owningTask, + /* withToken */ void * security_id, + /* ofType */ UInt32 type, + /* withProps*/ OSDictionary * properties, + /* client */ IOUserClient ** handler); + +/* + * HISTORICAL NOTE: + * The following methods were part of the IOHIPointingEvents protocol; + * the declarations have now been merged directly into this class. + */ + +public: + /* Mouse event reporting */ + virtual void relativePointerEvent(int buttons, + /* deltaX */ int dx, + /* deltaY */ int dy, + /* atTime */ AbsoluteTime ts); + + /* Tablet event reporting */ + virtual void absolutePointerEvent(int buttons, + /* at */ IOGPoint * newLoc, + /* withBounds */ IOGBounds *bounds, + /* inProximity */ bool proximity, + /* withPressure */ int pressure, + /* withAngle */ int stylusAngle, + /* atTime */ AbsoluteTime ts); + + /* Mouse scroll wheel event reporting */ + virtual void scrollWheelEvent(short deltaAxis1, + short deltaAxis2, + short deltaAxis3, + AbsoluteTime ts); + + + virtual void tabletEvent(NXEventData *tabletData, + AbsoluteTime ts); + + virtual void proximityEvent(NXEventData *proximityData, + AbsoluteTime ts); + +/* + * HISTORICAL NOTE: + * The following methods were part of the IOHIKeyboardEvents protocol; + * the declarations have now been merged directly into this class. + */ + +public: + virtual void keyboardEvent(unsigned eventType, + /* flags */ unsigned flags, + /* keyCode */ unsigned key, + /* charCode */ unsigned charCode, + /* charSet */ unsigned charSet, + /* originalCharCode */ unsigned origCharCode, + /* originalCharSet */ unsigned origCharSet, + /* keyboardType */ unsigned keyboardType, + /* repeat */ bool repeat, + /* atTime */ AbsoluteTime ts); + + virtual void keyboardSpecialEvent( unsigned eventType, + /* flags */ unsigned flags, + /* keyCode */ unsigned key, + /* specialty */ unsigned flavor, + /* guid */ UInt64 guid, + /* repeat */ bool repeat, + /* atTime */ AbsoluteTime ts); + + virtual void updateEventFlags(unsigned flags); /* Does not generate events */ + + + + +private: + + /* + * statics for upstream callouts + */ + + void _scaleLocationToCurrentScreen(IOGPoint *location, IOGPoint *fraction, IOGBounds *bounds); // Should this one be public??? + + static void _relativePointerEvent(IOHIDSystem * self, + int buttons, + /* deltaX */ int dx, + /* deltaY */ int dy, + /* atTime */ AbsoluteTime ts, + OSObject * sender, + void * refcon); + + /* Tablet event reporting */ + static void _absolutePointerEvent(IOHIDSystem * self, + int buttons, + /* at */ IOGPoint * newLoc, + /* withBounds */ IOGBounds *bounds, + /* inProximity */ bool proximity, + /* withPressure */ int pressure, + /* withAngle */ int stylusAngle, + /* atTime */ AbsoluteTime ts, + OSObject * sender, + void * refcon); + + /* Mouse scroll wheel event reporting */ + static void _scrollWheelEvent( IOHIDSystem *self, + short deltaAxis1, + short deltaAxis2, + short deltaAxis3, + IOFixed fixedDelta1, + IOFixed fixedDelta2, + IOFixed fixedDelta3, + SInt32 pointDeltaAxis1, + SInt32 pointDeltaAxis2, + SInt32 pointDeltaAxis3, + UInt32 options, + AbsoluteTime ts, + OSObject * sender, + void * refcon); + + static void _tabletEvent( IOHIDSystem *self, + NXEventData *tabletData, + AbsoluteTime ts, + OSObject * sender, + void * refcon); + + static void _proximityEvent( IOHIDSystem *self, + NXEventData *proximityData, + AbsoluteTime ts, + OSObject * sender, + void * refcon); + + static void _keyboardEvent( IOHIDSystem * self, + unsigned eventType, + /* flags */ unsigned flags, + /* keyCode */ unsigned key, + /* charCode */ unsigned charCode, + /* charSet */ unsigned charSet, + /* originalCharCode */ unsigned origCharCode, + /* originalCharSet */ unsigned origCharSet, + /* keyboardType */ unsigned keyboardType, + /* repeat */ bool repeat, + /* atTime */ AbsoluteTime ts, + OSObject * sender, + void * refcon); + + static void _keyboardSpecialEvent(IOHIDSystem * self, + unsigned eventType, + /* flags */ unsigned flags, + /* keyCode */ unsigned key, + /* specialty */ unsigned flavor, + /* guid */ UInt64 guid, + /* repeat */ bool repeat, + /* atTime */ AbsoluteTime ts, + OSObject * sender, + void * refcon); + + static void _updateEventFlags( IOHIDSystem * self, + unsigned flags, + OSObject * sender, + void * refcon); /* Does not generate events */ + + +/* + * HISTORICAL NOTE: + * The following methods were part of the IOUserClient protocol; + * the declarations have now been merged directly into this class. + */ + +public: + + virtual IOReturn setEventsEnable(void*,void*,void*,void*,void*,void*); + virtual IOReturn setCursorEnable(void*,void*,void*,void*,void*,void*); + virtual IOReturn extPostEvent(void*,void*,void*,void*,void*,void*); + virtual IOReturn extSetMouseLocation(void*,void*,void*,void*,void*,void*); + virtual IOReturn extGetButtonEventNum(void*,void*,void*,void*,void*,void*); + IOReturn extSetBounds( IOGBounds * bounds ); + IOReturn extGetModifierLockState(void*,void*,void*,void*,void*,void*); + IOReturn extSetModifierLockState(void*,void*,void*,void*,void*,void*); + +/* + * HISTORICAL NOTE: + * The following methods were part of the IOScreenRegistration protocol; + * the declarations have now been merged directly into this class. + * + * Methods exported by the EventDriver for display systems. + * + * The screenRegister protocol is used by frame buffer drivers to register + * themselves with the Event Driver. These methods are called in response + * to an _IOGetParameterInIntArray() call with "IO_Framebuffer_Register" or + * "IO_Framebuffer_Unregister". + */ + +public: + virtual int registerScreen(IOGraphicsDevice * instance, + /* bounds */ IOGBounds * bp); +// /* shmem */ void ** addr, +// /* size */ int * size) + virtual void unregisterScreen(int index); + +/* + * HISTORICAL NOTE: + * The following methods were part of the IOWorkspaceBounds protocol; + * the declarations have now been merged directly into this class. + * + * Absolute position input devices and some specialized output devices + * may need to know the bounding rectangle for all attached displays. + * The following method returns a IOGBounds* for the workspace. Please note + * that the bounds are kept as signed values, and that on a multi-display + * system the minx and miny values may very well be negative. + */ + +public: + virtual IOGBounds * workspaceBounds(); + +/* END HISTORICAL NOTES */ + +private: +void relativePointerEvent( int buttons, + /* deltaX */ int dx, + /* deltaY */ int dy, + /* atTime */ AbsoluteTime ts, + /* senderID */ OSObject * sender); + + /* Tablet event reporting */ +void absolutePointerEvent( int buttons, + /* at */ IOGPoint * newLoc, + /* withBounds */ IOGBounds *bounds, + /* inProximity */ bool proximity, + /* withPressure */ int pressure, + /* withAngle */ int stylusAngle, + /* atTime */ AbsoluteTime ts, + /* senderID */ OSObject * sender); + + /* Mouse scroll wheel event reporting */ +void scrollWheelEvent( short deltaAxis1, + short deltaAxis2, + short deltaAxis3, + IOFixed fixedDelta1, + IOFixed fixedDelta2, + IOFixed fixedDelta3, + SInt32 pointDeltaAxis1, + SInt32 pointDeltaAxis2, + SInt32 pointDeltaAxis3, + UInt32 options, + AbsoluteTime ts, + OSObject * sender); + +void tabletEvent( NXEventData * tabletData, + AbsoluteTime ts, + OSObject * sender); + +void proximityEvent( NXEventData * proximityData, + AbsoluteTime ts, + OSObject * sender); + +void keyboardEvent(unsigned eventType, + /* flags */ unsigned flags, + /* keyCode */ unsigned key, + /* charCode */ unsigned charCode, + /* charSet */ unsigned charSet, + /* originalCharCode */ unsigned origCharCode, + /* originalCharSet */ unsigned origCharSet, + /* keyboardType */ unsigned keyboardType, + /* repeat */ bool repeat, + /* atTime */ AbsoluteTime ts, + /* sender */ OSObject * sender); + +void keyboardSpecialEvent( unsigned eventType, + /* flags */ unsigned flags, + /* keyCode */ unsigned key, + /* specialty */ unsigned flavor, + /* guid */ UInt64 guid, + /* repeat */ bool repeat, + /* atTime */ AbsoluteTime ts, + /* sender */ OSObject * sender); + +void updateEventFlags(unsigned flags, OSObject * sender); + +/* + * COMMAND GATE COMPATIBILITY: + * The following method is part of the work needed to make IOHIDSystem + * compatible with IOCommandGate. The use of IOCommandQueue has been + * deprecated, thus requiring this move. This should allow for less + * context switching as all actions formerly run on the I/O Workloop + * thread, will now be run on the caller thread. The static methods + * will be called from cmdGate->runAction and returns the appropriate + * non-static helper method. Arguments are stored in the void* array, + * args, and are passed through. Since we are returning in the static + * function, gcc3 should translate that to one instruction, thus + * minimizing cost. + */ + +static IOReturn doEvClose (IOHIDSystem *self); + IOReturn evCloseGated (void); + +static IOReturn doSetEventsEnablePre (IOHIDSystem *self, void *p1); + IOReturn setEventsEnablePreGated (void *p1); + +static IOReturn doSetEventsEnablePost (IOHIDSystem *self, void *p1); + IOReturn setEventsEnablePostGated (void *p1); + +static IOReturn doUnregisterScreen (IOHIDSystem *self, void * arg0); + void unregisterScreenGated (int index); + +static IOReturn doCreateShmem (IOHIDSystem *self, void * arg0); + IOReturn createShmemGated (void * p1); + +static IOReturn doRegisterEventQueue (IOHIDSystem *self, void * arg0); + IOReturn registerEventQueueGated (void * p1); + +static IOReturn doUnregisterEventQueue (IOHIDSystem *self, void * arg0); + IOReturn unregisterEventQueueGated (void * p1); + +static IOReturn doRelativePointerEvent (IOHIDSystem *self, void * args); + void relativePointerEventGated(int buttons, + int dx, + int dy, + AbsoluteTime ts, + OSObject * sender); + +static IOReturn doAbsolutePointerEvent (IOHIDSystem *self, void * args); + void absolutePointerEventGated (int buttons, + IOGPoint * newLoc, + IOGBounds *bounds, + bool proximity, + int pressure, + int stylusAngle, + AbsoluteTime ts, + OSObject * sender); + +static IOReturn doScrollWheelEvent(IOHIDSystem *self, void * args); + void scrollWheelEventGated (short deltaAxis1, + short deltaAxis2, + short deltaAxis3, + IOFixed fixedDelta1, + IOFixed fixedDelta2, + IOFixed fixedDelta3, + SInt32 pointDeltaAxis1, + SInt32 pointDeltaAxis2, + SInt32 pointDeltaAxis3, + UInt32 options, + AbsoluteTime ts, + OSObject * sender); + +static IOReturn doTabletEvent (IOHIDSystem *self, void * arg0, void * arg1, void * arg2); + void tabletEventGated ( NXEventData *tabletData, + AbsoluteTime ts, + OSObject * sender); + +static IOReturn doProximityEvent (IOHIDSystem *self, void * arg0, void * arg1, void * arg2); + void proximityEventGated ( NXEventData *proximityData, + AbsoluteTime ts, + OSObject * sender); + +static IOReturn doKeyboardEvent (IOHIDSystem *self, void * args); + void keyboardEventGated (unsigned eventType, + unsigned flags, + unsigned key, + unsigned charCode, + unsigned charSet, + unsigned origCharCode, + unsigned origCharSet, + unsigned keyboardType, + bool repeat, + AbsoluteTime ts, + OSObject * sender); + +static IOReturn doKeyboardSpecialEvent (IOHIDSystem *self, void * args); + void keyboardSpecialEventGated ( + unsigned eventType, + unsigned flags, + unsigned key, + unsigned flavor, + UInt64 guid, + bool repeat, + AbsoluteTime ts, + OSObject * sender); + +static IOReturn doUpdateEventFlags (IOHIDSystem *self, void * args); + void updateEventFlagsGated (unsigned flags, OSObject * sender); + +static IOReturn doNewUserClient (IOHIDSystem *self, void * args); + IOReturn newUserClientGated (task_t owningTask, + void * security_id, + UInt32 type, + OSDictionary * properties, + IOUserClient ** handler); + +static IOReturn doSetCursorEnable (IOHIDSystem *self, void * arg0); + IOReturn setCursorEnableGated (void * p1); + +static IOReturn doExtPostEvent(IOHIDSystem *self, void * arg0, void * arg1, void * arg2, void * arg3); + IOReturn extPostEventGated (void * p1, void * p2, void * p3); + +static IOReturn doExtSetMouseLocation (IOHIDSystem *self, void * args); + IOReturn extSetMouseLocationGated (void * args); + +static IOReturn doExtGetButtonEventNum (IOHIDSystem *self, void * arg0, void * arg1); + IOReturn extGetButtonEventNumGated (void * p1, void * p2); + +static IOReturn doSetParamPropertiesPre (IOHIDSystem *self, void * arg0, void * arg1); + IOReturn setParamPropertiesPreGated (OSDictionary * dict, OSIterator ** pOpenIter); + +static IOReturn doSetParamPropertiesPost (IOHIDSystem *self, void * arg0); + IOReturn setParamPropertiesPostGated (OSDictionary * dict); + +static IOReturn doExtGetToggleState (IOHIDSystem *self, void *p1, void *p2); +static IOReturn doExtSetToggleState (IOHIDSystem *self, void *p1, void *p2); + IOReturn getCapsLockState(unsigned int *state_O); + IOReturn setCapsLockState(unsigned int state_I); + IOReturn getNumLockState(unsigned int *state_O); + IOReturn setNumLockState(unsigned int state_I); + +/* END COMMAND GATE COMPATIBILITY */ + +public: + virtual void setStackShotPort(mach_port_t port); + + virtual UInt32 eventFlags(); + + virtual void dispatchEvent(IOHIDEvent *event, IOOptionBits options=0); + +}; + +#endif /* !_IOHIDSYSTEM_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/hidsystem/IOHIDTypes.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/hidsystem/IOHIDTypes.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/hidsystem/IOHIDTypes.h (revision 885) @@ -0,0 +1,171 @@ +/* + * @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@ + */ +/****************************************************************************** + ev_types.h + Data types for the events status driver. + This file contains public API. + mpaque 11Oct91 + + Copyright 1991 NeXT Computer, Inc. + + Modified: + +******************************************************************************/ + +#ifndef _DEV_EV_TYPES_H +#define _DEV_EV_TYPES_H + +#include +#include +#include + +/* Shared memory versions */ +#define EVENT_SYSTEM_VERSION 2 + +/* Maximum length of SetMouseScaling arrays */ +#define NX_MAXMOUSESCALINGS 20 + +typedef struct evsioKeymapping /* Match old struct names in kernel */ +{ + int size; + char *mapping; +} NXKeyMapping; + +typedef struct evsioMouseScaling /* Match old struct names in kernel */ +{ + int numScaleLevels; + short scaleThresholds[NX_MAXMOUSESCALINGS]; + short scaleFactors[NX_MAXMOUSESCALINGS]; +} NXMouseScaling; + +typedef enum { + NX_OneButton, + NX_LeftButton, + NX_RightButton +} NXMouseButton; + +/* + * NXEventSystemInfo() information structures. These are designed to + * allow for expansion. + * + * The current implementation of NXEventSystemInfo() uses an ioctl call. + * THIS WILL CHANGE. + */ + +/* + * Generic query max size and typedefs. + * + * The maximum size is selected to support anticipated future extensions + * of request flavors. Certain flavors planned for future releases may + * require roughtly 800 ints to represent. We allow a little extra, in + * case further growth is needed. + */ +typedef int *NXEventSystemInfoType; +#define NX_EVS_INFO_MAX (1024) /* Max array size */ +typedef int NXEventSystemInfoData[NX_EVS_INFO_MAX]; + +/* Event System Devices query */ +#define NX_EVS_DEVICE_MAX 16 + + /* Interface types */ +#define NX_EVS_DEVICE_INTERFACE_OTHER 0 +#define NX_EVS_DEVICE_INTERFACE_NeXT 1 // NeXT custom, in older sys +#define NX_EVS_DEVICE_INTERFACE_ADB 2 // NeXT/fruit keybds/mice +#define NX_EVS_DEVICE_INTERFACE_ACE 3 // For x86 PC keyboards +#define NX_EVS_DEVICE_INTERFACE_SERIAL_ACE 4 // For PC serial mice +#define NX_EVS_DEVICE_INTERFACE_BUS_ACE 5 // For PC bus mice +#define NX_EVS_DEVICE_INTERFACE_HIL 6 // For HIL hp keyboard +#define NX_EVS_DEVICE_INTERFACE_TYPE5 7 // For Sun Type5 keyboard + +/* + * Note! if any new interface types are added above, the following + * definition of the number of interfaces supported must reflect this. + * This is used in the libkeymap project (storemap.c module) which needs + * to be cognizant of the number of new devices coming online + * via support for heterogeneous architecture platforms. + * e.g., PCs, HP's HIL, Sun's Type5 keyboard,... + */ +#define NUM_SUPPORTED_INTERFACES (NX_EVS_DEVICE_INTERFACE_TYPE5 + 1) + // Other, NeXT, ADB, ACE,... + + /* Device types */ +#define NX_EVS_DEVICE_TYPE_OTHER 0 +#define NX_EVS_DEVICE_TYPE_KEYBOARD 1 +#define NX_EVS_DEVICE_TYPE_MOUSE 2 // Relative position devices +#define NX_EVS_DEVICE_TYPE_TABLET 3 // Absolute position devices + +typedef struct { + int interface; /* NeXT, ADB, other */ + int interface_addr; /* Device address on the interface */ + int dev_type; /* Keyboard, mouse, tablet, other */ + int id; /* manufacturer's device handler ID */ +} NXEventSystemDevice; + +typedef struct { + NXEventSystemDevice dev[NX_EVS_DEVICE_MAX]; +} NXEventSystemDeviceList; + +#define __OLD_NX_EVS_DEVICE_INFO 1 +#define NX_EVS_DEVICE_INFO "Evs_EventDeviceInfo" +#define NX_EVS_DEVICE_INFO_COUNT \ + (sizeof (NXEventSystemDeviceList) / sizeof (int)) + +/* + * Types used in evScreen protocol compliant operations. + */ + +typedef enum {EVNOP, EVHIDE, EVSHOW, EVMOVE, EVLEVEL} EvCmd; /* Cursor state */ + +#define EV_SCREEN_MIN_BRIGHTNESS 0 +#define EV_SCREEN_MAX_BRIGHTNESS 64 +/* Scale should lie between MIN_BRIGHTNESS and MAX_BRIGHTNESS */ +#define EV_SCALE_BRIGHTNESS( scale, datum ) \ + ((((UInt32)(datum))*((UInt32)scale)) >> 6) + +/* + * Definition of a tick, as a time in milliseconds. This controls how + * often the event system periodic jobs are run. All actual tick times + * are derived from the nanosecond timer. These values are typically used + * as part of computing mouse velocity for acceleration purposes. + */ +#define EV_TICK_TIME 16 /* 16 milliseconds */ +#define EV_TICKS_PER_SEC (1000/EV_TICK_TIME) /* ~ 62 Hz */ + +/* Mouse Button bits, as passed from an EventSrc to the Event Driver */ +#define EV_RB (0x01) +#define EV_LB (0x04) +#define EV_MOUSEBUTTONMASK (EV_LB | EV_RB) + +/* Tablet Pressure Constants, as passed from an EventSrc to the Event Driver */ +#define EV_MINPRESSURE 0 +#define EV_MAXPRESSURE 255 + +/* Cursor size in pixels */ +#define EV_CURSOR_WIDTH 16 +#define EV_CURSOR_HEIGHT 16 + + +#define kAppleOnboardGUID 0x0610000000000000ULL + +#endif /* !_DEV_EV_TYPES_H */ + Index: branches/azimutz/Cleancut/i386/include/IOKit/hidsystem/IOLLEvent.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/hidsystem/IOLLEvent.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/hidsystem/IOLLEvent.h (revision 885) @@ -0,0 +1,558 @@ +/* + * @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@ + */ +/****************************************************************************** + event.h (PostScript side version) + + CONFIDENTIAL + Copyright (c) 1988 NeXT, Inc. as an unpublished work. + All Rights Reserved. + + Created Leo 01Mar88 + + Modified: + 04May88 Leo Final event types and record + 22Aug88 Leo Change short -> int for window, add reserved + 26May90 Ted Added NX_UNDIMMASK to correct triggering of UndoAutoDim + 12Dec91 Mike Brought into sync with dpsclient/event.h, and fixed + the #ifndef interlock with dpsclient/event.h that was + broken during the Great Header Revision. + + The PostScript version of this file differs from the + Window Kit version in that the coordinates here are + ints instead of floats. +******************************************************************************/ + +#ifndef _DEV_EVENT_H +#define _DEV_EVENT_H + +#include +#include + +#ifdef EVENT_H /* Interlock with dpsclient/event.h */ +#if !defined(_NXSIZE_) /* Work around patch for old event.h in Phase 3 projs*/ +#define _NXSIZE_ 1 /* NXCoord, NXPoint, NXSize decl seen */ +#define _NXSize_ NXSize +#endif /* _NXSIZE_ */ +#else /* EVENT_H */ /* Haven't seen dpsclient/event.h, so define away */ +#define EVENT_H + +#ifdef KERNEL +#else /* KERNEL */ + +#if !defined(_NXSIZE_) /* Work around patch for old event.h in Phase 3 projs*/ +#define _NXSIZE_ 1 /* NXCoord, NXPoint, NXSize decl seen */ +typedef float NXCoord; + +typedef struct _NXPoint { /* point */ + NXCoord x, y; +} NXPoint; + +typedef struct _NXSize { /* size */ + NXCoord width, height; +} NXSize; +#define _NXSize_ NXSize /* Correct usage in event_status_driver.h */ +#endif /* _NXSIZE_ */ + +#endif /* KERNEL */ + +/* Event types */ + +#define NX_NULLEVENT 0 /* internal use */ + +/* mouse events */ + +#define NX_LMOUSEDOWN 1 /* left mouse-down event */ +#define NX_LMOUSEUP 2 /* left mouse-up event */ +#define NX_RMOUSEDOWN 3 /* right mouse-down event */ +#define NX_RMOUSEUP 4 /* right mouse-up event */ +#define NX_MOUSEMOVED 5 /* mouse-moved event */ +#define NX_LMOUSEDRAGGED 6 /* left mouse-dragged event */ +#define NX_RMOUSEDRAGGED 7 /* right mouse-dragged event */ +#define NX_MOUSEENTERED 8 /* mouse-entered event */ +#define NX_MOUSEEXITED 9 /* mouse-exited event */ + +/* other mouse events + * + * event.data.mouse.buttonNumber should contain the + * button number (2-31) changing state. + */ +#define NX_OMOUSEDOWN 25 /* other mouse-down event */ +#define NX_OMOUSEUP 26 /* other mouse-up event */ +#define NX_OMOUSEDRAGGED 27 /* other mouse-dragged event */ + +/* keyboard events */ + +#define NX_KEYDOWN 10 /* key-down event */ +#define NX_KEYUP 11 /* key-up event */ +#define NX_FLAGSCHANGED 12 /* flags-changed event */ + +/* composite events */ + +#define NX_KITDEFINED 13 /* application-kit-defined event */ +#define NX_SYSDEFINED 14 /* system-defined event */ +#define NX_APPDEFINED 15 /* application-defined event */ +/* There are additional DPS client defined events past this point. */ + +/* Scroll wheel events */ + +#define NX_SCROLLWHEELMOVED 22 + +/* Zoom events */ +#define NX_ZOOM 28 + +/* tablet events */ + +#define NX_TABLETPOINTER 23 /* for non-mousing transducers */ +#define NX_TABLETPROXIMITY 24 /* for non-mousing transducers */ + +/* event range */ + +#define NX_FIRSTEVENT 0 +#define NX_LASTEVENT 28 +#define NX_NUMPROCS (NX_LASTEVENT-NX_FIRSTEVENT+1) + +/* Event masks */ +#define NX_NULLEVENTMASK (1 << NX_NULLEVENT) /* NULL event */ +#define NX_LMOUSEDOWNMASK (1 << NX_LMOUSEDOWN) /* left mouse-down */ +#define NX_LMOUSEUPMASK (1 << NX_LMOUSEUP) /* left mouse-up */ +#define NX_RMOUSEDOWNMASK (1 << NX_RMOUSEDOWN) /* right mouse-down */ +#define NX_RMOUSEUPMASK (1 << NX_RMOUSEUP) /* right mouse-up */ +#define NX_OMOUSEDOWNMASK (1 << NX_OMOUSEDOWN) /* other mouse-down */ +#define NX_OMOUSEUPMASK (1 << NX_OMOUSEUP) /* other mouse-up */ +#define NX_MOUSEMOVEDMASK (1 << NX_MOUSEMOVED) /* mouse-moved */ +#define NX_LMOUSEDRAGGEDMASK (1 << NX_LMOUSEDRAGGED) /* left-dragged */ +#define NX_RMOUSEDRAGGEDMASK (1 << NX_RMOUSEDRAGGED) /* right-dragged */ +#define NX_OMOUSEDRAGGEDMASK (1 << NX_OMOUSEDRAGGED) /* other-dragged */ +#define NX_MOUSEENTEREDMASK (1 << NX_MOUSEENTERED) /* mouse-entered */ +#define NX_MOUSEEXITEDMASK (1 << NX_MOUSEEXITED) /* mouse-exited */ +#define NX_KEYDOWNMASK (1 << NX_KEYDOWN) /* key-down */ +#define NX_KEYUPMASK (1 << NX_KEYUP) /* key-up */ +#define NX_FLAGSCHANGEDMASK (1 << NX_FLAGSCHANGED) /* flags-changed */ +#define NX_KITDEFINEDMASK (1 << NX_KITDEFINED) /* kit-defined */ +#define NX_SYSDEFINEDMASK (1 << NX_SYSDEFINED) /* system-defined */ +#define NX_APPDEFINEDMASK (1 << NX_APPDEFINED) /* app-defined */ +#define NX_SCROLLWHEELMOVEDMASK (1 << NX_SCROLLWHEELMOVED) /* scroll wheel moved */ +#define NX_ZOOMMASK (1 << NX_ZOOM) /* Zoom */ +#define NX_TABLETPOINTERMASK (1 << NX_TABLETPOINTER) /* tablet pointer moved */ +#define NX_TABLETPROXIMITYMASK (1 << NX_TABLETPROXIMITY) /* tablet pointer proximity */ + +#define EventCodeMask(type) (1 << (type)) +#define NX_ALLEVENTS -1 /* Check for all events */ + +/* sub types for mouse and move events */ + +#define NX_SUBTYPE_DEFAULT 0 +#define NX_SUBTYPE_TABLET_POINT 1 +#define NX_SUBTYPE_TABLET_PROXIMITY 2 +#define NX_SUBTYPE_MOUSE_TOUCH 3 + +/* sub types for system defined events */ + +#define NX_SUBTYPE_POWER_KEY 1 +#define NX_SUBTYPE_AUX_MOUSE_BUTTONS 7 + +/* + * NX_SUBTYPE_AUX_CONTROL_BUTTONS usage + * + * The incoming NXEvent for other mouse button down/up has event.type + * NX_SYSDEFINED and event.data.compound.subtype NX_SUBTYPE_AUX_MOUSE_BUTTONS. + * Within the event.data.compound.misc.L[0] contains bits for all the buttons + * that have changed state, and event.data.compound.misc.L[1] contains the + * current button state as a bitmask, with 1 representing down, and 0 + * representing up. Bit 0 is the left button, bit one is the right button, + * bit 2 is the center button and so forth. + */ +#define NX_SUBTYPE_AUX_CONTROL_BUTTONS 8 + +#define NX_SUBTYPE_EJECT_KEY 10 +#define NX_SUBTYPE_SLEEP_EVENT 11 +#define NX_SUBTYPE_RESTART_EVENT 12 +#define NX_SUBTYPE_SHUTDOWN_EVENT 13 + +#define NX_SUBTYPE_STICKYKEYS_ON 100 +#define NX_SUBTYPE_STICKYKEYS_OFF 101 +#define NX_SUBTYPE_STICKYKEYS_SHIFT 102 +#define NX_SUBTYPE_STICKYKEYS_CONTROL 103 +#define NX_SUBTYPE_STICKYKEYS_ALTERNATE 104 +#define NX_SUBTYPE_STICKYKEYS_COMMAND 105 +#define NX_SUBTYPE_STICKYKEYS_RELEASE 106 +#define NX_SUBTYPE_STICKYKEYS_TOGGLEMOUSEDRIVING 107 + +// New stickykeys key events +// These were created to send an event describing the +// different state of the modifiers +#define NX_SUBTYPE_STICKYKEYS_SHIFT_DOWN 110 +#define NX_SUBTYPE_STICKYKEYS_CONTROL_DOWN 111 +#define NX_SUBTYPE_STICKYKEYS_ALTERNATE_DOWN 112 +#define NX_SUBTYPE_STICKYKEYS_COMMAND_DOWN 113 +#define NX_SUBTYPE_STICKYKEYS_FN_DOWN 114 + +#define NX_SUBTYPE_STICKYKEYS_SHIFT_LOCK 120 +#define NX_SUBTYPE_STICKYKEYS_CONTROL_LOCK 121 +#define NX_SUBTYPE_STICKYKEYS_ALTERNATE_LOCK 122 +#define NX_SUBTYPE_STICKYKEYS_COMMAND_LOCK 123 +#define NX_SUBTYPE_STICKYKEYS_FN_LOCK 124 + +#define NX_SUBTYPE_STICKYKEYS_SHIFT_UP 130 +#define NX_SUBTYPE_STICKYKEYS_CONTROL_UP 131 +#define NX_SUBTYPE_STICKYKEYS_ALTERNATE_UP 132 +#define NX_SUBTYPE_STICKYKEYS_COMMAND_UP 133 +#define NX_SUBTYPE_STICKYKEYS_FN_UP 134 + + + +// SlowKeys +#define NX_SUBTYPE_SLOWKEYS_START 200 +#define NX_SUBTYPE_SLOWKEYS_ABORT 201 +#define NX_SUBTYPE_SLOWKEYS_END 202 + +// HID Parameter Property Modified +#define NX_SUBTYPE_HIDPARAMETER_MODIFIED 210 + +/* Masks for the bits in event.flags */ + +/* device-independent */ + +#define NX_ALPHASHIFTMASK 0x00010000 +#define NX_SHIFTMASK 0x00020000 +#define NX_CONTROLMASK 0x00040000 +#define NX_ALTERNATEMASK 0x00080000 +#define NX_COMMANDMASK 0x00100000 +#define NX_NUMERICPADMASK 0x00200000 +#define NX_HELPMASK 0x00400000 +#define NX_SECONDARYFNMASK 0x00800000 + +/* device-dependent (really?) */ + +#define NX_DEVICELCTLKEYMASK 0x00000001 +#define NX_DEVICELSHIFTKEYMASK 0x00000002 +#define NX_DEVICERSHIFTKEYMASK 0x00000004 +#define NX_DEVICELCMDKEYMASK 0x00000008 +#define NX_DEVICERCMDKEYMASK 0x00000010 +#define NX_DEVICELALTKEYMASK 0x00000020 +#define NX_DEVICERALTKEYMASK 0x00000040 +#define NX_DEVICERCTLKEYMASK 0x00002000 + +/* + * Additional reserved bits in event.flags + */ + +#define NX_STYLUSPROXIMITYMASK 0x00000080 /* deprecated */ +#define NX_NONCOALSESCEDMASK 0x00000100 + +/* click state values + * If you have the following events in close succession, the click + * field has the indicated value: + * + * Event Click Value Comments + * mouse-down 1 Not part of any click yet + * mouse-up 1 Aha! A click! + * mouse-down 2 Doing a double-click + * mouse-up 2 It's finished + * mouse-down 3 A triple + * mouse-up 3 + */ + +/* Values for the character set in event.data.key.charSet */ + +#define NX_ASCIISET 0 +#define NX_SYMBOLSET 1 +#define NX_DINGBATSSET 2 + +/* tablet button masks + * Mask bits for the tablet barrel buttons placed in tablet.buttons. + * The buttons field uses adopts the following convention: + * + * Bit Comments + * 0 Left Mouse Button ( kHIDUsage_Button_1 ) + * 1 Right Mouse Button ( kHIDUsage_Button_2 ) + * 2 Middle Mouse Button ( kHIDUsage_Button_3 ) + * 3 4th Mouse Button ( kHIDUsage_Button_4 ) + * ... + * 15 15th Mouse Button + * + * For your convenience, the following mask bits have been defined + * for tablet specific application: + */ + +#define NX_TABLET_BUTTON_PENTIPMASK 0x0001 +#define NX_TABLET_BUTTON_PENLOWERSIDEMASK 0x0002 +#define NX_TABLET_BUTTON_PENUPPERSIDEMASK 0x0004 + + +/* tablet capability masks + * Mask bits for the tablet capabilities field. Use these + * masks with the capabilities field of a proximity event to + * determine what fields in a Tablet Event are valid for this + * device. + */ +#define NX_TABLET_CAPABILITY_DEVICEIDMASK 0x0001 +#define NX_TABLET_CAPABILITY_ABSXMASK 0x0002 +#define NX_TABLET_CAPABILITY_ABSYMASK 0x0004 +#define NX_TABLET_CAPABILITY_VENDOR1MASK 0x0008 +#define NX_TABLET_CAPABILITY_VENDOR2MASK 0x0010 +#define NX_TABLET_CAPABILITY_VENDOR3MASK 0x0020 +#define NX_TABLET_CAPABILITY_BUTTONSMASK 0x0040 +#define NX_TABLET_CAPABILITY_TILTXMASK 0x0080 +#define NX_TABLET_CAPABILITY_TILTYMASK 0x0100 +#define NX_TABLET_CAPABILITY_ABSZMASK 0x0200 +#define NX_TABLET_CAPABILITY_PRESSUREMASK 0x0400 +#define NX_TABLET_CAPABILITY_TANGENTIALPRESSUREMASK 0x0800 +#define NX_TABLET_CAPABILITY_ORIENTINFOMASK 0x1000 +#define NX_TABLET_CAPABILITY_ROTATIONMASK 0x2000 + +/* proximity pointer types + * Value that describes the type of pointing device placed in + * proximity.pointerType. + */ + +#define NX_TABLET_POINTER_UNKNOWN 0 +#define NX_TABLET_POINTER_PEN 1 +#define NX_TABLET_POINTER_CURSOR 2 +#define NX_TABLET_POINTER_ERASER 3 + +/* TabletPointData type: defines the tablet data for points included + * in mouse events created by a tablet driver. + */ + +typedef struct _NXTabletPointData { + SInt32 x; /* absolute x coordinate in tablet space at full tablet resolution */ + SInt32 y; /* absolute y coordinate in tablet space at full tablet resolution */ + SInt32 z; /* absolute z coordinate in tablet space at full tablet resolution */ + UInt16 buttons; /* one bit per button - bit 0 is first button - 1 = closed */ + UInt16 pressure; /* scaled pressure value; MAX=(2^16)-1, MIN=0 */ + struct { /* tilt range is -((2^15)-1) to (2^15)-1 (-32767 to 32767) */ + SInt16 x; /* scaled tilt x value */ + SInt16 y; /* scaled tilt y value */ + } tilt; + UInt16 rotation; /* Fixed-point representation of device rotation in a 10.6 format */ + SInt16 tangentialPressure; /* tangential pressure on the device; same range as tilt */ + UInt16 deviceID; /* system-assigned unique device ID */ + SInt16 vendor1; /* vendor-defined signed 16-bit integer */ + SInt16 vendor2; /* vendor-defined signed 16-bit integer */ + SInt16 vendor3; /* vendor-defined signed 16-bit integer */ +} NXTabletPointData, *NXTabletPointDataPtr; + +/* TabletProximityData type: defines the tablet data for proximity + * events included in mouse events created by a tablet driver. + */ + +typedef struct _NXTabletProximityData { + UInt16 vendorID; /* vendor-defined ID - typically the USB vendor ID */ + UInt16 tabletID; /* vendor-defined tablet ID - typically the USB product ID */ + UInt16 pointerID; /* vendor-defined ID of the specific pointing device */ + UInt16 deviceID; /* system-assigned unique device ID */ + UInt16 systemTabletID; /* system-assigned unique tablet ID */ + UInt16 vendorPointerType; /* vendor-defined pointer type */ + UInt32 pointerSerialNumber; /* vendor-defined serial number */ + UInt64 uniqueID __attribute__ ((packed)); /* vendor-defined unique ID */ + UInt32 capabilityMask; /* capabilities mask of the device */ + UInt8 pointerType; /* type of pointing device */ + UInt8 enterProximity; /* non-zero = entering; zero = leaving */ + SInt16 reserved1; +} NXTabletProximityData, *NXTabletProximityDataPtr; + +/* EventData type: defines the data field of an event */ + +typedef union { + struct { /* For mouse-down and mouse-up events */ + UInt8 subx; /* sub-pixel position for x */ + UInt8 suby; /* sub-pixel position for y */ + SInt16 eventNum; /* unique identifier for this button */ + SInt32 click; /* click state of this event */ + UInt8 pressure; /* pressure value: 0=none, 255=full */ + UInt8 buttonNumber;/* button generating other button event (0-31) */ + UInt8 subType; + UInt8 reserved2; + SInt32 reserved3; + union { + NXTabletPointData point; /* tablet point data */ + NXTabletProximityData proximity; /* tablet proximity data */ + } tablet; + } mouse; + struct { + SInt32 dx; + SInt32 dy; + UInt8 subx; + UInt8 suby; + UInt8 subType; + UInt8 reserved1; + SInt32 reserved2; + union { + NXTabletPointData point; /* tablet point data */ + NXTabletProximityData proximity; /* tablet proximity data */ + } tablet; + } mouseMove; + struct { /* For key-down and key-up events */ + UInt16 origCharSet; /* unmodified character set code */ + SInt16 repeat; /* for key-down: nonzero if really a repeat */ + UInt16 charSet; /* character set code */ + UInt16 charCode; /* character code in that set */ + UInt16 keyCode; /* device-dependent key number */ + UInt16 origCharCode; /* unmodified character code */ + SInt32 reserved1; + UInt32 keyboardType; + SInt32 reserved2; + SInt32 reserved3; + SInt32 reserved4; + SInt32 reserved5[4]; + } key; + struct { /* For mouse-entered and mouse-exited events */ + SInt16 reserved; + SInt16 eventNum; /* unique identifier from mouse down event */ + SInt32 trackingNum; /* unique identifier from settrackingrect */ + SInt32 userData; /* uninterpreted integer from settrackingrect */ + SInt32 reserved1; + SInt32 reserved2; + SInt32 reserved3; + SInt32 reserved4; + SInt32 reserved5; + SInt32 reserved6[4]; + } tracking; + struct { + SInt16 deltaAxis1; + SInt16 deltaAxis2; + SInt16 deltaAxis3; + SInt16 reserved1; + SInt32 fixedDeltaAxis1; + SInt32 fixedDeltaAxis2; + SInt32 fixedDeltaAxis3; + SInt32 pointDeltaAxis1; + SInt32 pointDeltaAxis2; + SInt32 pointDeltaAxis3; + SInt32 reserved8[4]; + } scrollWheel, zoom; + struct { /* For window-changed, sys-defined, and app-defined events */ + SInt16 reserved; + SInt16 subType; /* event subtype for compound events */ + union { + float F[11]; /* for use in compound events */ + SInt32 L[11]; /* for use in compound events */ + SInt16 S[22]; /* for use in compound events */ + char C[44]; /* for use in compound events */ + } misc; + } compound; + struct { + SInt32 x; /* absolute x coordinate in tablet space at full tablet resolution */ + SInt32 y; /* absolute y coordinate in tablet space at full tablet resolution */ + SInt32 z; /* absolute z coordinate in tablet space at full tablet resolution */ + UInt16 buttons; /* one bit per button - bit 0 is first button - 1 = closed */ + UInt16 pressure; /* scaled pressure value; MAX=(2^16)-1, MIN=0 */ + struct { /* tilt range is -((2^15)-1) to (2^15)-1 (-32767 to 32767) */ + SInt16 x; /* scaled tilt x value */ + SInt16 y; /* scaled tilt y value */ + } tilt; + UInt16 rotation; /* Fixed-point representation of device rotation in a 10.6 format */ + SInt16 tangentialPressure; /* tangential pressure on the device; same range as tilt */ + UInt16 deviceID; /* system-assigned unique device ID */ + SInt16 vendor1; /* vendor-defined signed 16-bit integer */ + SInt16 vendor2; /* vendor-defined signed 16-bit integer */ + SInt16 vendor3; /* vendor-defined signed 16-bit integer */ + SInt32 reserved[4]; + } tablet; + struct { + UInt16 vendorID; /* vendor-defined ID - typically the USB vendor ID */ + UInt16 tabletID; /* vendor-defined tablet ID - typically the USB product ID */ + UInt16 pointerID; /* vendor-defined ID of the specific pointing device */ + UInt16 deviceID; /* system-assigned unique device ID */ + UInt16 systemTabletID; /* system-assigned unique tablet ID */ + UInt16 vendorPointerType; /* vendor-defined pointer type */ + UInt32 pointerSerialNumber; /* vendor-defined serial number */ + UInt64 uniqueID __attribute__ ((packed)); /* vendor-defined unique ID */ + UInt32 capabilityMask; /* capabilities mask of the device */ + UInt8 pointerType; /* type of pointing device */ + UInt8 enterProximity; /* non-zero = entering; zero = leaving */ + SInt16 reserved1; + SInt32 reserved2[4]; + } proximity; +} NXEventData; + +/* The current version number of the NXEventData structure. */ + +#define kNXEventDataVersion 2 + +/* Finally! The event record! */ +#ifndef __ppc__ +typedef struct _NXEvent { + SInt32 type; /* An event type from above */ + struct { + SInt32 x, y; /* Base coordinates in window, */ + } location; /* from bottom left */ + UInt64 time __attribute__ ((packed)); /* time since launch */ + SInt32 flags; /* key state flags */ + UInt32 window; /* window number of assigned window */ + UInt64 service_id __attribute__ ((packed)); /* service id */ + SInt32 ext_pid; /* external pid */ + NXEventData data; /* type-dependent data */ +} NXEvent, *NXEventPtr; + +#else + +typedef struct _NXEvent { + SInt32 type; /* An event type from above */ + struct { + SInt32 x, y; /* Base coordinates in window, */ + } location; /* from bottom left */ + UInt64 time __attribute__ ((packed)); /* time since launch */ + SInt32 flags; /* key state flags */ + UInt32 window; /* window number of assigned window */ + NXEventData data; /* type-dependent data */ + UInt64 service_id __attribute__ ((packed)); /* service id */ + SInt32 ext_pid; /* external pid */ +} NXEvent, *NXEventPtr; +#endif + +/* The current version number of the NXEvent structure. */ + +#define kNXEventVersion 2 + +/* How to pick window(s) for event (for PostEvent) */ +#define NX_NOWINDOW -1 +#define NX_BYTYPE 0 +#define NX_BROADCAST 1 +#define NX_TOPWINDOW 2 +#define NX_FIRSTWINDOW 3 +#define NX_MOUSEWINDOW 4 +#define NX_NEXTWINDOW 5 +#define NX_LASTLEFT 6 +#define NX_LASTRIGHT 7 +#define NX_LASTKEY 8 +#define NX_EXPLICIT 9 +#define NX_TRANSMIT 10 +#define NX_BYPSCONTEXT 11 + +#endif /* EVENT_H */ /* End of defs common with dpsclient/event.h */ + +/* Mask of events that cause screen to undim */ + +#define NX_UNDIMMASK (NX_KEYDOWNMASK | NX_KEYUPMASK | \ + NX_LMOUSEDOWNMASK | NX_LMOUSEUPMASK | \ + NX_RMOUSEDOWNMASK | NX_RMOUSEUPMASK | \ + NX_MOUSEMOVEDMASK | NX_FLAGSCHANGEDMASK | \ + NX_MOUSEENTEREDMASK | NX_MOUSEEXITEDMASK | \ + NX_LMOUSEDRAGGEDMASK | NX_RMOUSEDRAGGEDMASK | \ + NX_SCROLLWHEELMOVEDMASK | NX_TABLETPOINTERMASK | \ + NX_TABLETPROXIMITYMASK | NX_NULLEVENTMASK) + +#endif /* !_DEV_EVENT_H */ + Index: branches/azimutz/Cleancut/i386/include/IOKit/hidsystem/IOHIDShared.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/hidsystem/IOHIDShared.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/hidsystem/IOHIDShared.h (revision 885) @@ -0,0 +1,341 @@ +/* + * @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@ + */ +/****************************************************************************** + + evio.h + Ioctl calls for the events driver + Leovitch 02Jan88 + + Copyright 1988 NeXT, Inc. + + CAUTION: Developers should stick to the API exported in + to guarantee + binary compatability of their applications in future + releases. + + Modified: + + 09Dec88 Leo Broken out from evsio.h + 24Aug89 Ted ANSI function prototyping. + 19Feb90 Ted Major revision for multiple driver support. + 26Feb90 Ted New evioScreen structure and EVIOST ioctl. + 12Mar90 Ted New ev_unregister_screen function, SCREENTOKEN constant. + 06May90 Ted Added AALastEventSent and AALastEventConsumed to EvVars. + 22May90 Trey More wait cursor vars in EvVars. + 13Jun90 Ted NXCursorData structure. + 18Jun90 Ted Default wait cursor constants. + 26Sep90 Ted Enhanced cursor system to support intelligent drivers. + 26Nov90 Ted Removed NXSaveCursor and NXCursorData structures + 28Nov90 Ted Remove EvVars, rolled into EventGlobals + 28Nov90 Ted Renamed EventGlobals -> EvGlobals, eventGlobals -> evg + 05May92 Mike Reworked for NRW driver architecture. + +******************************************************************************/ + +#ifndef _DEV_EVIO_H +#define _DEV_EVIO_H + +#include + +__BEGIN_DECLS + +#if KERNEL +#include +#else /* !KERNEL */ +#include +#include +#endif /* KERNEL */ + +#include +#include +#include +#include + +/* + * Identify this driver as one that uses the new driverkit and messaging API + */ +#ifndef _NeXT_MACH_EVENT_DRIVER_ +#define _NeXT_MACH_EVENT_DRIVER_ (1) +#endif /* _NeXT_MACH_EVENT_DRIVER_ */ + + +/* Pressure Constants */ +#define MINPRESSURE EV_MINPRESSURE +#define MAXPRESSURE EV_MAXPRESSURE + +#define LLEQSIZE 240 /* Entries in low-level event queue */ + +typedef struct _NXEQElStruct { + int next; /* Slot of lleq for next event */ + ev_lock_data_t sema; /* Is high-level code reading this event now? */ + NXEvent event; /* The event itself */ +} NXEQElement; + + +/****************************************************************************** + SHARED MEMORY OVERVIEW + + PERSPECTIVE + The ev driver and PostScript share at least one page of wired memory. + This memory contains the low-level event queue which ev deposits events + into and PostScript reads events from. Also, this memory contains other + important data such as wait cursor state and some general cursor state. + This memory is critical for speed. That is, we avoid having to make + system calls for common operations. + + SHARED MEMORY REGIONS + There are currently three "regions" or "zones" delineated within this + shared memory. The first zone is the EvOffsets structure. This structure + contains two offsets from the beginning of shared memory. The first offset + is to the second zone, EvGlobals. The second offset is to the third + zone, private shmem for drivers. + + INITIALIZATION OF SHARED MEMORY + When the WindowServer starts up, it finds all screens that will be active. + It then opens the ev driver and calls the EVIOSSCR ioctl repeatedly for + each screen in use. This lets the ev driver set up the evScreen array + and fill in each element. This ioctl also returns to PostScript a running + total shared memory size with which to allocate. PostScript then allocates + a region of memory this size and calls evmmap to "map in" this shared + region. Evmmap initializes and fills in the EvOffsets and EvGlobals. + Next the WindowServer calls each screen in turn to register itself with + the ev driver in the same sequence as presented to EVIOSSCR. Each screen + driver calls ev_register_screen() which among other things allocates a + part of the private shmem (of the third shared memory zone) for the driver. + + DEBUGGING NOTES + You can easily display and set this shared memory from kgdb, but usually + cannot do so from within PostScript. Gdb (or some weird interaction + between gdb and the os) chokes on this shmem. So if you read or write + this area of memory, copy-on-write will occur and you'll get a completely + new page for PostScript. This will render the shared memory scheme + useless and you will have to restart PostScript. It was my understanding + that before, we were able to "read" this area from PS, but not write to + it (the idea behind copy-on-WRITE). However, this seems to be broken + in 2.0. We think this is a kernel bug. +******************************************************************************/ + +typedef volatile struct _evOffsets { + int evGlobalsOffset; /* Offset to EvGlobals structure */ + int evShmemOffset; /* Offset to private shmem regions */ +} EvOffsets; + +/****************************************************************************** + EvGlobals + This structures defines the portion of the events driver data structure + that is exported to the PostScript server. It contains the event queue + which is in memory shared between the driver and the PostScript server. + All the variables necessary to read and process events from the queue are + contained here. +******************************************************************************/ + +#ifndef __ppc__ +typedef volatile struct _evGlobals { + ev_lock_data_t cursorSema; /* set to disable periodic code */ + int eNum; /* Unique id for mouse events */ + int buttons; /* State of the mouse buttons 1==down, 0==up */ + int eventFlags; /* The current value of event.flags */ + int VertRetraceClock; /* The current value of event.time */ + IOGPoint cursorLoc; /* The current location of the cursor */ + int frame; /* current cursor frame */ + IOGBounds workBounds; /* bounding box of all screens */ + IOGBounds mouseRect; /* Rect for mouse-exited events */ + int version; /* for run time checks */ + int structSize; /* for run time checks */ + int lastFrame; + unsigned int reservedA[31]; + + unsigned reserved:27; + unsigned wantPressure:1; /* pressure in current mouseRect? */ + unsigned wantPrecision:1; /* precise coordinates in current mouseRect? */ + unsigned dontWantCoalesce:1;/* coalesce within the current mouseRect? */ + unsigned dontCoalesce:1; /* actual flag which determines coalescing */ + unsigned mouseRectValid:1; /* If nonzero, post a mouse-exited + whenever mouse outside mouseRect. */ + int movedMask; /* This contains an event mask for the + three events MOUSEMOVED, + LMOUSEDRAGGED, and RMOUSEDRAGGED. + It says whether driver should + generate those events. */ + ev_lock_data_t waitCursorSema; /* protects wait cursor fields */ + int AALastEventSent; /* timestamp for wait cursor */ + int AALastEventConsumed; /* timestamp for wait cursor */ + int waitCursorUp; /* Is wait cursor up? */ + char ctxtTimedOut; /* Has wait cursor timer expired? */ + char waitCursorEnabled; /* Play wait cursor game (per ctxt)? */ + char globalWaitCursorEnabled; /* Play wait cursor game (global)? */ + int waitThreshold; /* time before wait cursor appears */ + + int LLEHead; /* The next event to be read */ + int LLETail; /* Where the next event will go */ + int LLELast; /* The last event entered */ + NXEQElement lleq[LLEQSIZE]; /* The event queue itself */ +} EvGlobals; + +#else + +typedef volatile struct _evGlobals { + ev_lock_data_t cursorSema; /* set to disable periodic code */ + int LLEHead; /* The next event to be read */ + int LLETail; /* Where the next event will go */ + int LLELast; /* The last event entered */ + int eNum; /* Unique id for mouse events */ + int buttons; /* State of the mouse buttons 1==down, 0==up */ + int eventFlags; /* The current value of event.flags */ + int VertRetraceClock; /* The current value of event.time */ + IOGPoint cursorLoc; /* The current location of the cursor */ + int frame; /* current cursor frame */ + IOGBounds workBounds; /* bounding box of all screens */ + IOGBounds mouseRect; /* Rect for mouse-exited events */ + int version; /* for run time checks */ + int structSize; /* for run time checks */ + int lastFrame; + unsigned int reservedA[31]; + + unsigned reserved:27; + unsigned wantPressure:1; /* pressure in current mouseRect? */ + unsigned wantPrecision:1; /* precise coordinates in current mouseRect? */ + unsigned dontWantCoalesce:1;/* coalesce within the current mouseRect? */ + unsigned dontCoalesce:1; /* actual flag which determines coalescing */ + unsigned mouseRectValid:1; /* If nonzero, post a mouse-exited + whenever mouse outside mouseRect. */ + int movedMask; /* This contains an event mask for the + three events MOUSEMOVED, + LMOUSEDRAGGED, and RMOUSEDRAGGED. + It says whether driver should + generate those events. */ + int AALastEventSent; /* timestamp for wait cursor */ + int AALastEventConsumed; /* timestamp for wait cursor */ + ev_lock_data_t waitCursorSema; /* protects wait cursor fields */ + int waitCursorUp; /* Is wait cursor up? */ + char ctxtTimedOut; /* Has wait cursor timer expired? */ + char waitCursorEnabled; /* Play wait cursor game (per ctxt)? */ + char globalWaitCursorEnabled; /* Play wait cursor game (global)? */ + int waitThreshold; /* time before wait cursor appears */ + NXEQElement lleq[LLEQSIZE]; /* The event queue itself */ +} EvGlobals; +#endif + +/* These evio structs are used in various calls supported by the ev driver. */ + +struct evioLLEvent { + int setCursor; + int type; + IOGPoint location; + NXEventData data; + int setFlags; + int flags; +}; + +typedef struct evioLLEvent _NXLLEvent; + +#ifdef mach3xxx + +/* + * On a keypress of a VOL UP or VOL DOWN key, we send a message to the + * sound server to notify it of the volume change. The message includes + * a flag to indicate which key was pressed, and the machine independant + * flag bits to indicate which modifier keys were pressed. + */ + +struct evioSpecialKeyMsg +{ + msg_header_t Head; + msg_type_t keyType; + int key; // special key number, from bsd/dev/ev_keymap.h + msg_type_t directionType; + int direction; // NX_KEYDOWN, NX_KEYUP from event.h + msg_type_t flagsType; + int flags; // device independant flags from event.h + msg_type_t levelType; + int level; // EV_AUDIO_MIN_VOLUME to EV_AUDIO_MAX_VOLUME +}; +#else +struct evioSpecialKeyMsg +{ + mach_msg_header_t Head; + int key; // special key number, from bsd/dev/ev_keymap.h + int direction; // NX_KEYDOWN, NX_KEYUP from event.h + int flags; // device independant flags from event.h + int level; // EV_AUDIO_MIN_VOLUME to EV_AUDIO_MAX_VOLUME +}; +#endif + +#define EV_SPECIAL_KEY_MSG_ID (('S'<<24) | ('k'<<16) | ('e'<<8) | ('y')) +typedef struct evioSpecialKeyMsg *evioSpecialKeyMsg_t; + +/* + * Volume ranges + */ +#define EV_AUDIO_MIN_VOLUME 0 +#define EV_AUDIO_MAX_VOLUME 64 + +#define kIOHIDSystemClass "IOHIDSystem" +#define kIOHIKeyboardClass "IOHIKeyboard" +#define kIOHIPointingClass "IOHIPointing" + +#define IOHIDSYSTEM_CONFORMSTO kIOHIDSystemClass + +enum { + kIOHIDCurrentShmemVersion = 3, + kIOHIDEventNotification = 0, +}; + +enum { + kIOHIDServerConnectType = 0, + kIOHIDParamConnectType = 1, + kIOHIDEventSystemConnectType = 3, +}; + +enum { + kIOHIDGlobalMemory = 0 +}; + +enum { + kIOHIDEventQueueTypeKernel = 0, + kIOHIDEventQueueTypeUser = 1 +}; + +#ifdef KERNEL +typedef UInt16 (*MasterVolumeUpdate)(void); +typedef bool (*MasterMuteUpdate)(void); + +typedef struct { + MasterVolumeUpdate incrementMasterVolume; + MasterVolumeUpdate decrementMasterVolume; + MasterMuteUpdate toggleMasterMute; +} MasterAudioFunctions; + +extern MasterAudioFunctions *masterAudioFunctions; +#endif + +#ifndef KERNEL +#ifndef _IOKIT_IOHIDLIB_H +#include +#endif +#endif /* !KERNEL */ + +__END_DECLS + + +#endif /* !_DEV_EVIO_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/hidsystem/IOHIDDescriptorParser.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/hidsystem/IOHIDDescriptorParser.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/hidsystem/IOHIDDescriptorParser.h (revision 885) @@ -0,0 +1,939 @@ +/* + * @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 __IOHIDDescriptorParser__ +#define __IOHIDDescriptorParser__ + +#include +#include +#include +#if !TARGET_OS_EMBEDDED + #include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#if TARGET_OS_EMBEDDED +/* Types and enums required by these functions but not in IOTypes.h */ + +typedef UInt8 Byte; +typedef SInt8 SignedByte; +typedef unsigned long FourCharCode; +typedef FourCharCode OSType; +typedef UInt32 ByteCount; + +enum { + noErr = 0 +}; +#endif + +/* End missing types and enums */ + +enum +{ + kHIDSuccess = 0, + +/* HID assigned error numbers are -13949 .. -13900 */ + kHIDBaseError = -13950, + + kHIDNullStateErr, + kHIDBufferTooSmallErr, + kHIDValueOutOfRangeErr, + kHIDUsageNotFoundErr, + kHIDNotValueArrayErr, + kHIDInvalidPreparsedDataErr, + kHIDIncompatibleReportErr, + kHIDBadLogPhysValuesErr, + kHIDInvalidReportTypeErr, + kHIDInvalidReportLengthErr, + kHIDNullPointerErr, + kHIDBadParameterErr, + kHIDNotEnoughMemoryErr, + kHIDEndOfDescriptorErr, + kHIDUsagePageZeroErr, + kHIDBadLogicalMinimumErr, + kHIDBadLogicalMaximumErr, + kHIDInvertedLogicalRangeErr, + kHIDInvertedPhysicalRangeErr, + kHIDUnmatchedUsageRangeErr, + kHIDInvertedUsageRangeErr, + kHIDUnmatchedStringRangeErr, + kHIDUnmatchedDesignatorRangeErr, + kHIDReportSizeZeroErr, + kHIDReportCountZeroErr, + kHIDReportIDZeroErr, + kHIDInvalidRangePageErr, + + // + // HID device driver errors + // + + kHIDDeviceNotReady = -13910, // The device is still initializing, try again later + kHIDVersionIncompatibleErr, +}; + +// types of HID reports (input, output, feature) +enum +{ + kHIDInputReport = 1, + kHIDOutputReport, + kHIDFeatureReport, + kHIDUnknownReport = 255 +}; + +// flags passed to HIDOpenReportDescriptor +enum +{ + kHIDFlag_StrictErrorChecking = 0x00000001 +}; + +typedef UInt32 HIDReportType; +typedef UInt32 HIDUsage; + +typedef void *HIDPreparsedDataRef; + +/*! + @typedef HIDUsageAndPage + @abstract The HIDUsageAndPage data structure is used by HID clients when obtaining status of buttons to hold the usage page and usage of a button that is down. + @discussion Clients use the HIDUSageAndPage structure with the HIDGetButtonsEx function to obtain both the usage page and usage identifiers of each button that is down. + @field usage Specifies the usage identifier within the usage page specified by usagePage of a button that is down. + @field usagePage Specifies the usage page identifier of a button that is down. + */ +struct HIDUsageAndPage +{ + HIDUsage usage; + HIDUsage usagePage; +}; +typedef struct HIDUsageAndPage HIDUsageAndPage, *HIDUsageAndPagePtr; + +/*! + @typedef HIDCaps + @abstract The HIDCaps data structure is used by HID clients to hold the capabilities of a HID device. + @discussion This structure holds the parsed capabilities and data maximums returned for a device by the HIDGetCaps function. + @field usage Specifies the specific class of functionality that this device provides. This value is dependent and specific to the value provided in the usagePage field. For example, a keyboard could have a usagePage of kHIDUsagePage_Generic and a usage of kHIDUsage_Generic_Keyboard. + @field usagePage Specifies the usage page identifier for this top level collection. + @field inputReportByteLength Specifies the maximum length, in bytes, of an input report for this device, including the report ID which is unilaterally prepended to the device data. + @field outputReportByteLength Specifies the maximum length, in bytes, of an output report for this device, including the report ID which is unilaterally prepended to the device data. + @field featureReportByteLength Specifies the maximum length, in bytes, of a feature report for this device, including the report ID which is unilaterally prepended to the device data. + @field numberCollectionNodes Specifies the number of HIDCollectionNode structures that are returned for this top level collection by the HIDGetConnectionNodes function. + @field numberInputButtonCaps Specifies the number of input buttons. + @field numberInputValueCaps Specifies the number of input values. + @field numberOutputButtonCaps Specifies the number of output buttons. + @field numberOutputValueCaps Specifies the number of output values + @field numberFeatureButtonCaps Specifies the number of feature buttons. + @field numberFeatureValueCaps Specifies the number of feature values. + */ +struct HIDCaps +{ + HIDUsage usage; + HIDUsage usagePage; + ByteCount inputReportByteLength; + ByteCount outputReportByteLength; + ByteCount featureReportByteLength; + UInt32 numberCollectionNodes; + UInt32 numberInputButtonCaps; + UInt32 numberInputValueCaps; + UInt32 numberOutputButtonCaps; + UInt32 numberOutputValueCaps; + UInt32 numberFeatureButtonCaps; + UInt32 numberFeatureValueCaps; +}; +typedef struct HIDCaps HIDCaps, * HIDCapsPtr; + +struct HIDCapabilities { + HIDUsage usage; + HIDUsage usagePage; + ByteCount inputReportByteLength; + ByteCount outputReportByteLength; + ByteCount featureReportByteLength; + UInt32 numberCollectionNodes; + UInt32 numberInputButtonCaps; + UInt32 numberInputValueCaps; + UInt32 numberOutputButtonCaps; + UInt32 numberOutputValueCaps; + UInt32 numberFeatureButtonCaps; + UInt32 numberFeatureValueCaps; +}; +typedef struct HIDCapabilities HIDCapabilities, * HIDCapabilitiesPtr; + + +struct HIDCollectionNode +{ + HIDUsage collectionUsage; + HIDUsage collectionUsagePage; + UInt32 parent; + UInt32 numberOfChildren; + UInt32 nextSibling; + UInt32 firstChild; +}; +typedef struct HIDCollectionNode HIDCollectionNode, * HIDCollectionNodePtr; + +struct HIDButtonCaps +{ + HIDUsage usagePage; + UInt32 reportID; + UInt32 bitField; + UInt32 collection; + HIDUsage collectionUsage; + HIDUsage collectionUsagePage; + Boolean isRange; + Boolean isStringRange; + Boolean isDesignatorRange; + Boolean isAbsolute; + SInt32 startBit; // Added esb 9-29-99 + + union + { + struct + { + HIDUsage usageMin; + HIDUsage usageMax; + UInt32 stringMin; + UInt32 stringMax; + UInt32 designatorMin; + UInt32 designatorMax; + } range; + struct + { + HIDUsage usage; + HIDUsage reserved1; + UInt32 stringIndex; + UInt32 reserved2; + UInt32 designatorIndex; + UInt32 reserved3; + } notRange; + } u; +}; +typedef struct HIDButtonCaps HIDButtonCaps, * HIDButtonCapsPtr; + +struct HIDButtonCapabilities +{ + HIDUsage usagePage; + UInt32 reportID; + UInt32 bitField; + UInt32 collection; + HIDUsage collectionUsage; + HIDUsage collectionUsagePage; + Boolean isRange; + Boolean isStringRange; + Boolean isDesignatorRange; + Boolean isAbsolute; + + SInt32 unitExponent; // Added KH 1/25/01 + SInt32 units; // Added KH 1/25/01 +// UInt32 reserved; // Not added KH 1/25/01 + SInt32 startBit; // Added esb 9-29-99 + UInt32 pbVersion; // Added KH 1/25/01 + + union + { + struct + { + HIDUsage usageMin; + HIDUsage usageMax; + UInt32 stringMin; + UInt32 stringMax; + UInt32 designatorMin; + UInt32 designatorMax; + } range; + struct + { + HIDUsage usage; + HIDUsage reserved1; + UInt32 stringIndex; + UInt32 reserved2; + UInt32 designatorIndex; + UInt32 reserved3; + } notRange; + } u; +}; +typedef struct HIDButtonCapabilities HIDButtonCapabilities, * HIDButtonCapabilitiesPtr; + +struct HIDValueCaps +{ + HIDUsage usagePage; + UInt32 reportID; + UInt32 bitField; + UInt32 collection; + HIDUsage collectionUsage; + HIDUsage collectionUsagePage; + + Boolean isRange; + Boolean isStringRange; + Boolean isDesignatorRange; + Boolean isAbsolute; + + UInt32 startBit; // Added by esb 9-28-99 + UInt32 bitSize; + UInt32 reportCount; + + SInt32 logicalMin; + SInt32 logicalMax; + SInt32 physicalMin; + SInt32 physicalMax; + + union + { + struct + { + HIDUsage usageMin; + HIDUsage usageMax; + UInt32 stringMin; + UInt32 stringMax; + UInt32 designatorMin; + UInt32 designatorMax; + } range; + struct + { + HIDUsage usage; + HIDUsage reserved1; + UInt32 stringIndex; + UInt32 reserved2; + UInt32 designatorIndex; + UInt32 reserved3; + } notRange; + } u; +}; +typedef struct HIDValueCaps HIDValueCaps, * HIDValueCapsPtr; + +struct HIDValueCapabilities +{ + HIDUsage usagePage; + UInt32 reportID; + UInt32 bitField; + UInt32 collection; + HIDUsage collectionUsage; + HIDUsage collectionUsagePage; + + Boolean isRange; + Boolean isStringRange; + Boolean isDesignatorRange; + Boolean isAbsolute; + + UInt32 bitSize; + UInt32 reportCount; + + SInt32 logicalMin; + SInt32 logicalMax; + SInt32 physicalMin; + SInt32 physicalMax; + + SInt32 unitExponent; // Added KH 1/25/01 + SInt32 units; // Added KH 1/25/01 +// UInt32 reserved; // Not added KH 1/25/01 + SInt32 startBit; // Added esb 9-29-99 // Moved here KH 1/25/01 + UInt32 pbVersion; // Added KH 1/25/01 + + union + { + struct + { + HIDUsage usageMin; + HIDUsage usageMax; + UInt32 stringMin; + UInt32 stringMax; + UInt32 designatorMin; + UInt32 designatorMax; + } range; + struct + { + HIDUsage usage; + HIDUsage reserved1; + UInt32 stringIndex; + UInt32 reserved2; + UInt32 designatorIndex; + UInt32 reserved3; + } notRange; + } u; +}; +typedef struct HIDValueCapabilities HIDValueCapabilities, * HIDValueCapabilitiesPtr; + +/*! + @function HIDOpenReportDescriptor + @abstract The HIDOpenReportDescriptor function allocates the memory the parser needs to handle the given report descriptor, and then parses the report descriptor. + @discussion When the parsed information is no longer needed, clients should call the HIDCloseReportDescriptor function. + @param hidReportDescriptor Contains a pointer to the actual HID report descriptor from the USB device's firmware + @param descriptorLength The length of the HID report descriptor + @param preparsedDataRef Preparsed data reference to be used for subsequent function calls + @param flags Flags for this runction are kHIDFlag_StrictErrorChecking = 0x00000001 + @result OSStatus Returns an error code if an error was encountered or noErr on success. + */ + +extern +OSStatus +HIDOpenReportDescriptor (void * hidReportDescriptor, + ByteCount descriptorLength, + HIDPreparsedDataRef * preparsedDataRef, + UInt32 flags); + +/*! + @function HIDCloseReportDescriptor + @abstract Disposes of the memory the parser allocated for the HIDOpenReportDescriptor function. + @param hidReportDescriptor Contains a pointer to the actual HID report descriptor from the USB device's firmware + @param preparsedDataRef Preparsed data reference for the report that is returned by the HIDOpenReportDescriptor function. After making a call to the HIDCloseReportDescriptor function, the preparsedDataRef is invalid and should not be used. + @result OSStatus Returns an error code if an error was encountered or noErr on success. + */ + +extern +OSStatus +HIDCloseReportDescriptor (HIDPreparsedDataRef preparsedDataRef); + +/*! + @function HIDGetButtonCaps + @abstract Returns the button capabilities structures for a HID device based on the given preparsed data. + @param reportType Specifies the type of report for which to retrieve the scaled value. This parameter must be one of the following: kHIDInputReport, kHIDOutputReport, or kHIDFeatureReport + @param buttonCaps Points to a caller-allocated buffer that will contain, on return, an array of HIDButtonCaps structures. The structures contain information for all buttons that meet the search criteria + @param buttonCapsSize Contains the size of the buttonCaps array passed in to the function and is set to the number of elements actually placed in the array after the call completes. + @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function + @result OSStatus Returns an error code if an error was encountered or noErr on success. + */ + +extern +OSStatus +HIDGetButtonCaps (HIDReportType reportType, + HIDButtonCapsPtr buttonCaps, + UInt32 * buttonCapsSize, + HIDPreparsedDataRef preparsedDataRef); + +/*! + @function HIDGetButtonCapabilities + @abstract Returns the button capabilities structures for a HID device based on the given preparsed data. + @param reportType Specifies the type of report for which to retrieve the scaled value. This parameter must be one of the following: kHIDInputReport, kHIDOutputReport, or kHIDFeatureReport + @param buttonCaps Points to a caller-allocated buffer that will contain, on return, an array of HIDButtonCapabilities structures. The structures contain information for all buttons that meet the search criteria + @param buttonCapsSize Contains the size of the buttonCaps array passed in to the function and is set to the number of elements actually placed in the array after the call completes. + @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function + @result OSStatus Returns an error code if an error was encountered or noErr on success. + */ + +extern +OSStatus +HIDGetButtonCapabilities (HIDReportType reportType, + HIDButtonCapabilitiesPtr buttonCaps, + UInt32 * buttonCapsSize, + HIDPreparsedDataRef preparsedDataRef); + +/*! + @function HIDGetCaps + @abstract Returns the capabilities of a HID device based on the given preparsed data. + @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function + @param capabilities Points to a caller allocated buffer, that upon return contains the parsed capability information for this HID device. + @result OSStatus Returns an error code if an error was encountered or noErr on success. + */ + +extern +OSStatus +HIDGetCaps (HIDPreparsedDataRef preparsedDataRef, + HIDCapsPtr capabilities); + +/*! + @function HIDGetCapabilities + @abstract Returns the capabilities of a HID device based on the given preparsed data. + @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function + @param capabilities Points to a caller allocated buffer, that upon return contains the parsed capability information for this HID device. + @result OSStatus Returns an error code if an error was encountered or noErr on success. + */ + +extern +OSStatus +HIDGetCapabilities (HIDPreparsedDataRef preparsedDataRef, + HIDCapabilitiesPtr capabilities); + +/*! + @function HIDGetCollectionNodes + @abstract Returns an array of HIDCollectionNode structures that describe the relationships and layout of the link collections within this top level collection. + @discussion The length of the buffer required, in array elements, for an entire collection node array is found in the HIDCaps structure member numberCollectionNodes. You obtain the HIDCaps information by calling the HIDGetCaps function. For information on the relationships of link collections described by the data returned from this routine, see the descripton of the HIDCollectionNode structure. + @param collectionNodes Points to a caller-allocated array of HIDCollectionNode structures in which this routine returns an entry for each collection within the top level collection. A collection is a group of corresponding HID descriptors containing input, output, and feature items that have some common relationship to one another. For example, a pointer collection contains items for x and y position data, and button data. + @param collectionNodesSize On input, specifies the length in array elements of the buffer provided at collectionNodes. On output, this parameter is set to the number of entries in the collectionNodes array that were initialized. + @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function + @result OSStatus Returns an error code if an error was encountered or noErr on success. + */ + +extern +OSStatus +HIDGetCollectionNodes (HIDCollectionNodePtr collectionNodes, + UInt32 * collectionNodesSize, + HIDPreparsedDataRef preparsedDataRef); + +/*! + @function HIDGetScaledUsageValue + @abstract The HIDGetScaledUsageValue function returns the capabilities for all buttons for a given top level collection. + @discussion Clients who which to obtain all capabilities for a usage that contains multiple data items for a single usage that corresponds to a HID byte array, must call the HIDGetUsageValueArray function. + @param reportType Specifies the type of report for which to retrieve the scaled value. This parameter must be one of the following: kHIDInputReport, kHIDOutputReport, or kHIDFeatureReport. + @param usagePage Specifies the usage page of the value to be retrieved. + @param collection Optionally specifies the link collection identifier of the value to be retrieved. + @param usage Specifies the usage of the scaled value to be retrieved. + @param usageValue Points to a variable, that on return from this routine holds the scaled value retrieved from the device report. + @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function + @param report Points to the caller-allocated buffer that contains the device report data + @param reportLength Specifies the length, in bytes, of the report data provided at report + @result OSStatus Returns an error code if an error was encountered or noErr on success. + */ + +extern +OSStatus +HIDGetScaledUsageValue (HIDReportType reportType, + HIDUsage usagePage, + UInt32 collection, + HIDUsage usage, + SInt32 * usageValue, + HIDPreparsedDataRef preparsedDataRef, + void * report, + ByteCount reportLength); + +/*! + @function HIDGetSpecificButtonCaps + @abstract Retrieves the capabilities for all buttons in a specific type of report that meet the search criteria. + @discussion The HIDGetSpecificButtonCaps function retrieves capability data for buttons that meet a given search criteria, as opposed to the HIDGetButtonCaps function which returns the capability data for all buttons on the device. Calling this routine specifying zero for usagePage, usage and collection is equivalent to calling the HIDGetButtonCaps function. + @param reportType Specifies the type of report for which to retrieve the button capabilities. This parameter must be one of the following: kHIDInputReport, kHIDOutputReport, or kHIDFeatureReport. + @param usagePage Specifies a usage page identifier to use as a search criteria. If this parameter is non-zero, then only buttons that specify this usage page will be retrieved. + @param collection Specifies a link collection identifier to use as a search criteria. If this parameter is non-zero, then only buttons that are part of the specified link collection are retrieved. + @param usage Specifies a usage identifier to use as a search criteria. If this parameter is non-zero, then only buttons that match the value specified are retrieved. + @param buttonCaps Points to a caller-allocated buffer that will contain, on return, an array of HIDButtonCaps structures. The structures contain information for all buttons that meet the search criteria. + @param buttonCapsLength On input, specifies the length, in array elements, of the buffer provided in the buttonCaps parameter. On output, this parameter is set to the actual number of elements that were returned by the function call, in the buffer provided in the buttonCaps parameter, if the routine completed without error. The correct length necessary to retrieve the button capabilities can be found in the capability data returned for the device by the HIDGetCaps function. + @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function + @result OSStatus Returns an error code if an error was encountered or noErr on success. + */ + +extern +OSStatus +HIDGetSpecificButtonCaps (HIDReportType reportType, + HIDUsage usagePage, + UInt32 collection, + HIDUsage usage, + HIDButtonCapsPtr buttonCaps, + UInt32 * buttonCapsSize, + HIDPreparsedDataRef preparsedDataRef); + +/*! + @function HIDGetSpecificButtonCapabilities + @abstract Retrieves the capabilities for all buttons in a specific type of report that meet the search criteria. + @discussion The HIDGetSpecificButtonCapabilities function retrieves capability data for buttons that meet a given search criteria, as opposed to the HIDGetButtonCapabilities function which returns the capability data for all buttons on the device. Calling this routine specifying zero for usagePage, usage and collection is equivalent to calling the HIDGetButtonCapabilities function. + @param reportType Specifies the type of report for which to retrieve the button capabilities. This parameter must be one of the following: kHIDInputReport, kHIDOutputReport, or kHIDFeatureReport. + @param usagePage Specifies a usage page identifier to use as a search criteria. If this parameter is non-zero, then only buttons that specify this usage page will be retrieved. + @param collection Specifies a link collection identifier to use as a search criteria. If this parameter is non-zero, then only buttons that are part of the specified link collection are retrieved. + @param usage Specifies a usage identifier to use as a search criteria. If this parameter is non-zero, then only buttons that match the value specified are retrieved. + @param buttonCaps Points to a caller-allocated buffer that will contain, on return, an array of HIDButtonCapabilities structures. The structures contain information for all buttons that meet the search criteria. + @param buttonCapsLength On input, specifies the length, in array elements, of the buffer provided in the buttonCaps parameter. On output, this parameter is set to the actual number of elements that were returned by the function call, in the buffer provided in the buttonCaps parameter, if the routine completed without error. The correct length necessary to retrieve the button capabilities can be found in the capability data returned for the device by the HIDGetCaps function. + @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function + @result OSStatus Returns an error code if an error was encountered or noErr on success. + */ + +extern +OSStatus +HIDGetSpecificButtonCapabilities (HIDReportType reportType, + HIDUsage usagePage, + UInt32 collection, + HIDUsage usage, + HIDButtonCapabilitiesPtr buttonCaps, + UInt32 * buttonCapsSize, + HIDPreparsedDataRef preparsedDataRef); + +/*! + @function HIDGetSpecificValueCaps + @abstract Retrieves the capabilities for all values in a specific type of report that meet the search criteria. + @discussion The HIDGetSpecificValueCaps function retrieves capability data for values that meet given search criteria, as opposed to the HIDGetValueCaps function, which returns the capability data for all values on the device. Calling this routine with a value of zero for usagePage, usage and collection parameters is equivalent to calling the HIDGetValueCaps function. + @param reportType Specifies the type of report for which to retrieve the value capabilities. This parameter must be one of the following: kHIDInputReport, kHIDOutputReport or kHIDFeatureReport. + @param usagePage Specifies a usage page identifier to use as a search criteria. If this parameter is non-zero, then only values that specify this usage page will be retrieved. + @param collection Specifies a link collection identifier to use as a search criteria. If this parameter is non-zero, then only values that are part of this link collection will be retrieved. + @param usage Specifies a usage identifier to use as a search criteria. If this parameter is non-zero, then only values that specify this usage will be retrieved. + @param valueCaps Points to a caller-allocated buffer that will contain, on return, an array of HIDValueCaps structures that contain information for all values that meet the search criteria. + @param valueCapsSize Specifies the length on input, in array elements, of the buffer provided in the valueCaps parameter. On output, this parameter is set to the actual number of elements that were returned by this function call, in the buffer provided in the valueCaps parameter, if the routine completed without error. The correct length necessary to retrieve the value capabilities can be found in the capability data returned for the device from the HIDGetCaps function. + @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function + @result OSStatus Returns an error code if an error was encountered or noErr on success. + */ + +extern +OSStatus +HIDGetSpecificValueCaps (HIDReportType reportType, + HIDUsage usagePage, + UInt32 collection, + HIDUsage usage, + HIDValueCapsPtr valueCaps, + UInt32 * valueCapsSize, + HIDPreparsedDataRef preparsedDataRef); + +/*! + @function HIDGetSpecificValueCapabilities + @abstract Retrieves the capabilities for all values in a specific type of report that meet the search criteria. + @discussion The HIDGetSpecificValueCapabilities function retrieves capability data for values that meet given search criteria, as opposed to the HIDGetValueCapabilities function, which returns the capability data for all values on the device. Calling this routine with a value of zero for usagePage, usage and collection parameters is equivalent to calling the HIDGetValueCapabilities function. + @param reportType Specifies the type of report for which to retrieve the value capabilities. This parameter must be one of the following: kHIDInputReport, kHIDOutputReport or kHIDFeatureReport. + @param usagePage Specifies a usage page identifier to use as a search criteria. If this parameter is non-zero, then only values that specify this usage page will be retrieved. + @param collection Specifies a link collection identifier to use as a search criteria. If this parameter is non-zero, then only values that are part of this link collection will be retrieved. + @param usage Specifies a usage identifier to use as a search criteria. If this parameter is non-zero, then only values that specify this usage will be retrieved. + @param valueCaps Points to a caller-allocated buffer that will contain, on return, an array of HIDValueCapabilities structures that contain information for all values that meet the search criteria. + @param valueCapsSize Specifies the length on input, in array elements, of the buffer provided in the valueCaps parameter. On output, this parameter is set to the actual number of elements that were returned by this function call, in the buffer provided in the valueCaps parameter, if the routine completed without error. The correct length necessary to retrieve the value capabilities can be found in the capability data returned for the device from the HIDGetCaps function. + @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function + @result OSStatus Returns an error code if an error was encountered or noErr on success. + */ + +extern +OSStatus +HIDGetSpecificValueCapabilities (HIDReportType reportType, + HIDUsage usagePage, + UInt32 collection, + HIDUsage usage, + HIDValueCapabilitiesPtr valueCaps, + UInt32 * valueCapsSize, + HIDPreparsedDataRef preparsedDataRef); + +/*! + @function HIDGetButtonsOnPage + @abstract Retrieves the button stat information for buttons on a specified usage page. + @param reportType Specifies the type of report, provided in the report parameter, from which to retrieve the buttons. This parameter must be one of the following: kHIDInputReport, kHIDOutputReport or kHIDFeatureReport. + @param usagePage Specifies the usage page of the buttons for which to retrieve the current state. + @param collection Optionally specifies the link collection identifier used to retrieve only specific button states. If this value is non-zero, only the buttons that are part of the given collection are returned. + @param usageList On return, points to a caller-allocated buffer that contains the usages of all the buttons that are perssed and belong to the usage page specified in the usagePage parameter. + @param usageListSize Is the size, in array elements, of the buffer provided in the usageList parameter. On return, this parameter contains the number of button states that were set by this routine. If the error kHIDBufferTooSmallErr was returned, this parameter contains the number of array elements required to hold all button data requested. The maximum number of buttons that can ever be returned for a given type of report can be obtained by calling the HIDMaxUsageListLength function. + @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function + @param report Points to the caller-allocated buffer that contains the device report data + @param reportLength Specifies the size, in bytes, of the report data provided in the report parameter + @result OSStatus Returns an error code if an error was encountered or noErr on success. + */ + +extern +OSStatus +HIDGetButtonsOnPage (HIDReportType reportType, + HIDUsage usagePage, + UInt32 collection, + HIDUsage * usageList, + UInt32 * usageListSize, + HIDPreparsedDataRef preparsedDataRef, + void * report, + ByteCount reportLength); + +/*! + @function HIDGetButtons + @abstract The HIDGetButtons function takes a report from a HID device and gets the current state of the buttons in that report. + @param reportType Specifies the type of report, provided in the report parameter, from which to retrieve the buttons. This parameter must be one of the following: kHIDInputReport, kHIDOutputReport or kHIDFeatureReport + @param collection Optionally specifies the link collection identifier used to retrieve only specific button states. If this value is non-zero, only the buttons that are part of the given collection are returned. + @param usageList On return, points to a caller-allocated buffer that contains the usages of all the buttons that are pressed. + @param usageListSize Is the size, in array elements, of the buffer provided in the usageList parameter. On return, this parameter contains the number of button states that were set by this routine. If the error kHIDBufferToSmallErr was returned, this parameter contains the number of array elements required to hold all button data requested. The maximum number of buttons that can ever be returned for a given type of report can be obtained by calling the HIDMaxUsageListLength function. + @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function + @param report Points to the caller-allocated buffer that contains the device report data. + @param reportLength Specifies the length, in bytes, of the report data provided in the report parameter. + @result OSStatus Returns an error code if an error was encountered or noErr on success. + */ + +extern +OSStatus +HIDGetButtons (HIDReportType reportType, + UInt32 collection, + HIDUsageAndPagePtr usageList, + UInt32 * usageListSize, + HIDPreparsedDataRef preparsedDataRef, + void * report, + ByteCount reportLength); + +extern +OSStatus +HIDGetNextButtonInfo (HIDReportType reportType, + HIDUsage usagePage, + HIDUsage usage, + UInt32 * collection, + UInt8 * reportID, + HIDPreparsedDataRef preparsedDataRef); + +extern +OSStatus +HIDGetNextUsageValueInfo (HIDReportType reportType, + HIDUsage usagePage, + HIDUsage usage, + UInt32 * collection, + UInt8 * reportID, + HIDPreparsedDataRef preparsedDataRef); + +extern +OSStatus +HIDGetReportLength (HIDReportType reportType, + UInt8 reportID, + ByteCount * reportLength, + HIDPreparsedDataRef preparsedDataRef); + +/*! + @function HIDGetUsageValue + @abstract The HIDGetUsageValue function returns a value from a device data report given a selected search criteria. + @discussion The HIDGetUsageValue function does not sign the value. To have the sign bit automatically applied, use the HIDGetScaledUsageValue function instead. For manually assigning the sign bit, the position of the sign bit can be found in the HIDValueCaps structure for this value. Clients who wish to obtain all data for a usage that contains multiple data items for a single usage, corresponding to a HID byte array, must call the HIDGetUsageValueArray function instead. + @param reportType Specifies the type of report, provided in report, from which to retrieve the value. This parameter must be one of the following: kHIDInputReport, kHIDOutputReport, or kHIDFeatureReport. + @param usagePage Specifies the usage page of the value to retrieve. + @param collection Optionally specifies the link collection identifier of the value to be retrieved. + @param usage Specifies the usage of the value to be retrieved. + @param usageValue Points to a variable, that on return from this routine holds the value retrieved from the device report. + @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function + @param report Points to the caller-allocated buffer that contains the device report data. + @param reportLength Specifies the size, in bytes, of the report data provided in the report parameter. + @result OSStatus Returns an error code if an error was encountered or noErr on success. + */ + +extern +OSStatus +HIDGetUsageValue (HIDReportType reportType, + HIDUsage usagePage, + UInt32 collection, + HIDUsage usage, + SInt32 * usageValue, + HIDPreparsedDataRef preparsedDataRef, + void * report, + ByteCount reportLength); + +/*! + @function HIDGetUsageValueArray + @abstract The HIDGetUsageValueArray function returns a value from a device data report given a selected search criteria. + @discussion When the HIDGetUsageValueArray function retrieves the data, it fills in the buffer in little-endian order beginning with the least significant bit of the data for this usage. The data is filled in without regard to byte alignment and is shifted such that the least significant bit is placed as the 1st bit of the given buffer. + @param reportType Specifies the type of report, provided in report, from which to retrieve the value. This parameter must be one of the following: kHIDInputReport, kHIDOutputReport, or kHIDFeatureReport. + @param usagePage Specifies the usage page of the data to be retrieved. + @param collection Optionally specifies the link collection identifier of the data to be retrieved. + @param usage Specifies the usage identifier of the value to be retrieved. + @param usageValueBuffer Points to a caller-allocated buffer that contains, on output, the data from the device. The correct length for this buffer can be found by multiplying the reportCount and bitSize fields of the HIDValueCaps structure for the value and rounding the resulting value up to the nearest byte. + @param usageValueBufferSize Specifies the size, in bytes, of the buffer in the usageValueBuffer parameter. + @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function + @param report Points to the caller-allocated buffer that contains the device report data. + @param reportLength Specifies the size, in bytes, of the report data provided in report. + @result OSStatus Returns an error code if an error was encountered or noErr on success. + */ + +extern +OSStatus +HIDGetUsageValueArray (HIDReportType reportType, + HIDUsage usagePage, + UInt32 collection, + HIDUsage usage, + Byte * usageValueBuffer, + ByteCount usageValueBufferSize, + HIDPreparsedDataRef preparsedDataRef, + void * report, + ByteCount reportLength); + +/*! + @function HIDGetValueCaps + @abstract The HIDGetValueCaps function retrieves the capabilities for all values for a specified top level collection. + @discussion The HIDGetValueCaps function retrieves the capability data for all values in a top level collection without regard for the usage, usage page or collection of the value. To retrieve value capabilities for a specific usage, usage page or collection, use the HIDGetSpecificValueCaps function. + @param reportType Specifies the type of report for which to retrieve the value capabilities. This parameter must be one of the following: kHIDInputReport, kHIDOutputReport, or kHIDFeatureReport. + @param valueCaps On return, points to a caller-allocated buffer that contains an array of HIDValueCaps structures containing information for all values in the top level collection. + @param valueCapsSize On input, specifies the size in array elements of the buffer provided in the valueCaps parameter. On output, this parameter is set to the actual number of elements that were returned in the buffer provided in the valueCaps parameter, if the function completed without error. The correct length necessary to retrieve the value capabilities can be found in the capability data returned for the device by the HIDGetCaps function. + @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function + @result OSStatus Returns an error code if an error was encountered or noErr on success. + */ + +extern +OSStatus +HIDGetValueCaps (HIDReportType reportType, + HIDValueCapsPtr valueCaps, + UInt32 * valueCapsSize, + HIDPreparsedDataRef preparsedDataRef); + +/*! + @function HIDGetValueCapabilities + @abstract The HIDGetValueCapabilities function retrieves the capabilities for all values for a specified top level collection. + @discussion The HIDGetValueCapabilities function retrieves the capability data for all values in a top level collection without regard for the usage, usage page or collection of the value. To retrieve value capabilities for a specific usage, usage page or collection, use the HIDGetSpecificValueCapabilities function. + @param reportType Specifies the type of report for which to retrieve the value capabilities. This parameter must be one of the following: kHIDInputReport, kHIDOutputReport, or kHIDFeatureReport. + @param valueCaps On return, points to a caller-allocated buffer that contains an array of HIDValueCapabilities structures containing information for all values in the top level collection. + @param valueCapsSize On input, specifies the size in array elements of the buffer provided in the valueCaps parameter. On output, this parameter is set to the actual number of elements that were returned in the buffer provided in the valueCaps parameter, if the function completed without error. The correct length necessary to retrieve the value capabilities can be found in the capability data returned for the device by the HIDGetCapabilities function. + @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function + @result OSStatus Returns an error code if an error was encountered or noErr on success. + */ + +extern +OSStatus +HIDGetValueCapabilities (HIDReportType reportType, + HIDValueCapabilitiesPtr valueCaps, + UInt32 * valueCapsSize, + HIDPreparsedDataRef preparsedDataRef); + +extern +OSStatus +HIDInitReport (HIDReportType reportType, + UInt8 reportID, + HIDPreparsedDataRef preparsedDataRef, + void * report, + ByteCount reportLength); + +/*! + @function HIDMaxUsageListLength + @abstract The HIDMaxUsageListLength function returns the maximum number of buttons that can be returned from a given report type for the top level collection. + @param reportType Specifies the type of report for which to get a maximum usage count. This parameter must be one of the following: kHIDInputReport, kHIDOutputReport, or kHIDFeatureReport. + @param usagePage Optionally specifies the usage page identifier to use as a search criteria. If this parameter is zero, the function returns the number of buttons for the entire top-level collection regardless of the actual value of the usage page. + @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function + @result OSStatus Returns an error code if an error was encountered or noErr on success. + */ + +extern +UInt32 +HIDMaxUsageListLength (HIDReportType reportType, + HIDUsage usagePage, + HIDPreparsedDataRef preparsedDataRef); + +/*! + @function HIDSetScaledUsageValue + @abstract The HIDSetScaledUsageValue function takes a signed physical (scaled) number and converts it to the logical, or device representation and inserts it in a given report. + @discussion The HIDSetScaledUsageValue function automatically handles the setting of the signed bit in the data to be sent to the device. + @param reportType Specifies the type of report. This parameter must be one of the following: kHIDInputReport, kHIDOutputReport, or kHIDFeatureReport. + @param usagePage Specifies the usage page identifier of the value to be set in the report. + @param collection Optionally specifies the link collection identifier to distinguish between values that have the same usage page and usage identifiers. If this parameter is zero, it will be ignored. + @param usage Specifies the usage identifier of the value to be set in the report. + @param usageValue Specifies the physical, or scaled, value to be set in the value for the given report. + @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function + @param report Points to the caller-allocated buffer that contains the device report data. + @param Specifies the length, in bytes of the report data specified in the report parameter. + @result OSStatus Returns an error code if an error was encountered or noErr on success. + */ + +extern +OSStatus +HIDSetScaledUsageValue (HIDReportType reportType, + HIDUsage usagePage, + UInt32 collection, + HIDUsage usage, + SInt32 usageValue, + HIDPreparsedDataRef preparsedDataRef, + void * report, + ByteCount reportLength); + +/*! + @function HIDSetButtons + @abstract The HIDSetButtons function takes a report from a HID device and returns the current state of the buttons in that report. + @param reportType Specifies the type of repor. This parameter must be one of the following: kHIDInputReport, kHIDOutputReport, or kHIDFeatureReport. + @param usagePage Specifies the usage page identifier of the value to be set in the report. + @param collection Optionally specifies the link collection identifier to distinguish between buttons. If this parameter is zero, it is ignored. + @param usageList Points to a caller-allocated buffer that contains an array of button data to be set in the report in the report parameter. + @param usageListSize Specifies the size, in array elements, of the buffer provided in the usageList parameter. If an error is returned by a call to this function, the usageListLength parameter contains the location in the array provided in the usageList parameter where the error was encountered. All array entries encountered prior to the error location were successfully set in the report provided in the report parameter. + @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function + @param report Points to the caller-allocated buffer that contains the device report data. + @param reportLength Specifies the size, in bytes, of the report data provided in the report parameter. + @result OSStatus Returns an error code if an error was encountered or noErr on success. + */ + +extern +OSStatus +HIDSetButtons (HIDReportType reportType, + HIDUsage usagePage, + UInt32 collection, + HIDUsage * usageList, + UInt32 * usageListSize, + HIDPreparsedDataRef preparsedDataRef, + void * report, + ByteCount reportLength); + +/*! + @function HIDSetUsageValue + @abstract The HIDSetUsageValue function sets a value in a give report. + @discussion The HIDSetUsageVlaue function does not automatically handle the sign bit. Clients must either manually set the sign bit, at the position provided in the HIDValueCaps structure for this value, or call the HIDSetScaledUsageValue function. + @param reportType Specifies the type of report. This parameter must be one of the following: kHIDInputReport, kHIDOutputReport, or kHIDFeatureReport. + @param usagePage Specifies the usage page identifier of the value to be set in the report. + @param collection Optionally specifies the link collection identifier to distinguish between values that have the same usage page and usage identifiers. If this parameter is zero, it is ignored. + @param usage Specifies the usage identifier of the value to be set in the report. + @param usageValue Specifies the data that is to be set in the value for the given report. + @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function + @param report Points to the caller-allocated buffer that contains the device report data. + @param reportLength Specifies the size, in bytes, of the report data provided in the report parameter. + @result OSStatus Returns an error code if an error was encountered or noErr on success. + */ + +extern +OSStatus +HIDSetUsageValue (HIDReportType reportType, + HIDUsage usagePage, + UInt32 collection, + HIDUsage usage, + SInt32 usageValue, + HIDPreparsedDataRef preparsedDataRef, + void * report, + ByteCount reportLength); + +/*! + @function HIDSetUsageValueArray + @abstract The HIDSetUsageValueArray function sets an array of values in a given report. + @discussion The HIDSetUsageValue function does not automatically handle the sign bit. Clients must either manually set the sign bit, at the position provided in the HIDValueCaps structure for this value, or call the HIDSetScaledUsageValue function. + @param reportType Specifies the type of report. This parameter must be one of the following: kHIDInputReport, kHIDOutputReport, or kHIDFeatureReport. + @param usagePage Specifies the usage page identifier of the value to be set in the report. + @param collection Optionally specifies the link collection identifier to distinguish between values that have the same usage page and usage identifiers. If this parameter is zero, it is ignored. + @param usage Specifies the usage identifier of the value to be set in the report. + @param usageValueBuffer Points to a caller-allocated buffer that contains, on output, the data from the device. The correct length for this buffer can be found by multiplying the reportCount and bitSize fields of the HIDValueCaps structure for this value and rounding the resulting value up to the nearest byte. + @param usageValueBufferLength Specifies the size, in bytes, of the buffer in the usageValueBuffer parameter. + @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function + @param report Points to the caller-allocated buffer that contains the device report data. + @param reportLength Specifies the size, in bytes, of the report data provided in the report parameter. + @result OSStatus Returns an error code if an error was encountered or noErr on success. + */ + +extern +OSStatus +HIDSetUsageValueArray (HIDReportType reportType, + HIDUsage usagePage, + UInt32 collection, + HIDUsage usage, + Byte * usageValueBuffer, + ByteCount usageValueBufferLength, + HIDPreparsedDataRef preparsedDataRef, + void * report, + ByteCount reportLength); + +/*! + @function HIDUsageListDifference + @abstract The HIDUsageListDifference function compares and provides the differences between two lists of buttons. + @param previousUsageList Points to the older button list to be used for comparison. + @param currentUsageList Points to the newer button list to be used for comparison. + @param breakUsageList On return, points to a caller-allocated buffer that contains the buttons set in the older list, specified in the previousUsageList parameter, but not set in the new list, specified in the currentUsageList parameter. + @param makeUsageList On return, points to a caller-allocated buffer that contains the buttons set in the new list, specified in the currentUsageList parameter, but not set in the old list, specified in the previousUsageList parameter. + @param usageListsLength Specifies the length, in array elements, of the buffers provided in the currentUsageList and previousUssageList parameters. + @result OSStatus Returns an error code if an error was encountered or noErr on success. + */ + +extern +OSStatus +HIDUsageListDifference (HIDUsage * previousUsageList, + HIDUsage * currentUsageList, + HIDUsage * breakUsageList, + HIDUsage * makeUsageList, + UInt32 usageListsSize); + +/*! + @function HIDSetButton + @abstract The HIDSetButton function takes a report from a HID device and sets the current state of the specified button in that report. + @param reportType Specifies the type of report. This parameter must be one of the following: kHIDInputReport, kHIDOutputReport, or kHIDFeatureReport. + @param usagePage Specifies the usage page identifier of the value to be set in the report. + @param collection Optionally specifies the link collection identifier to distinguish between buttons. If this parameter is zero, it is ignored. + @param usage Points to a caller-allocated buffer that contains the button data to be set in the report in the report parameter. + @param preparsedDataRef Preparsed data reference for the report that is retuned by the HIDOpenReportDescriptor function + @param report Points to the caller-allocated buffer that contains the device report data. + @param reportLength Specifies the size, in bytes, of the report data provided in the report parameter. + @result OSStatus Returns an error code if an error was encountered or noErr on success. + */ + +extern +OSStatus +HIDSetButton (HIDReportType reportType, + HIDUsage usagePage, + UInt32 collection, + HIDUsage usage, + HIDPreparsedDataRef preparsedDataRef, + void * report, + ByteCount reportLength); + + +#ifdef __cplusplus +} +#endif + + +#endif Index: branches/azimutz/Cleancut/i386/include/IOKit/hidsystem/IOHIDevice.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/hidsystem/IOHIDevice.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/hidsystem/IOHIDevice.h (revision 885) @@ -0,0 +1,71 @@ +/* + * @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@ + */ +/* Copyright (c) 1992 NeXT Computer, Inc. All rights reserved. + * + * IOHIDevice.h - Common Event Source object class. + * + * HISTORY + * 22 May 1992 Mike Paquette at NeXT + * Created. + * 4 Aug 1993 Erik Kay at NeXT + * API cleanup + * 5 Aug 1993 Erik Kay at NeXT + * added ivar space for future expansion + */ + +#ifndef _IOHIDEVICE_H +#define _IOHIDEVICE_H + +#include +#include + +typedef enum { + kHIUnknownDevice = 0, + kHIKeyboardDevice = 1, + kHIRelativePointingDevice = 2 +} IOHIDKind; + +class IOHIDevice : public IOService +{ + OSDeclareDefaultStructors(IOHIDevice); + +public: + virtual bool init(OSDictionary * properties = 0); + virtual void free(); + virtual bool start(IOService * provider); + virtual bool open( IOService * forClient, + IOOptionBits options = 0, + void * arg = 0 ); + + virtual UInt32 deviceType(); + virtual IOHIDKind hidKind(); + virtual UInt32 interfaceID(); + virtual bool updateProperties(void); + virtual IOReturn setProperties( OSObject * properties ); + virtual IOReturn setParamProperties(OSDictionary * dict); + virtual UInt64 getGUID(); + + static SInt32 GenerateKey(OSObject *object); +}; + +#endif /* !_IOHIDEVICE_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/system.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/system.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/system.h (revision 885) @@ -0,0 +1,67 @@ +/* + * 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 + +__BEGIN_DECLS + +#include +#include +#include + +#include +#include +#include + +#include /* Must be before other includes of kern/assert.h */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#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 */ Index: branches/azimutz/Cleancut/i386/include/IOKit/IOInterruptController.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/IOInterruptController.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/IOInterruptController.h (revision 885) @@ -0,0 +1,155 @@ +/* + * 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 +#include +#include + + +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 *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); + + OSMetaClassDeclareReservedUnused(IOInterruptController, 0); + OSMetaClassDeclareReservedUnused(IOInterruptController, 1); + OSMetaClassDeclareReservedUnused(IOInterruptController, 2); + OSMetaClassDeclareReservedUnused(IOInterruptController, 3); + OSMetaClassDeclareReservedUnused(IOInterruptController, 4); + OSMetaClassDeclareReservedUnused(IOInterruptController, 5); +}; + + +class IOSharedInterruptController : public IOInterruptController +{ + OSDeclareDefaultStructors(IOSharedInterruptController); + +private: + IOService *provider; + int numVectors; + int vectorsRegistered; + int vectorsEnabled; + volatile int controllerDisabled; + bool sourceIsLevel; + + struct ExpansionData { }; + ExpansionData *reserved; + +public: + virtual IOReturn initInterruptController(IOInterruptController *parentController, OSData *parentSource); + + 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 IOInterruptAction getInterruptHandlerAddress(void); + virtual IOReturn handleInterrupt(void *refCon, IOService *nub, int source); + + OSMetaClassDeclareReservedUnused(IOSharedInterruptController, 0); + OSMetaClassDeclareReservedUnused(IOSharedInterruptController, 1); + OSMetaClassDeclareReservedUnused(IOSharedInterruptController, 2); + OSMetaClassDeclareReservedUnused(IOSharedInterruptController, 3); +}; + + +#endif /* ! _IOKIT_IOINTERRUPTCONTROLLER_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/IOService.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/IOService.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/IOService.h (revision 885) @@ -0,0 +1,1690 @@ +/* + * Copyright (c) 1998-2009 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,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 +#include +#include +#include +#include + +#include +#include + +#include +#include + +extern "C" { +#include +} + +#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 +}; + +enum { + // options for registerService() + kIOServiceExclusive = 0x00000001, + + // options for terminate() + kIOServiceRequired = 0x00000001, + kIOServiceTerminate = 0x00000004, + + // 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 * gIOProviderClassKey; +extern const OSSymbol * gIONameMatchKey; +extern const OSSymbol * gIONameMatchedKey; +extern const OSSymbol * gIOPropertyMatchKey; +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 * gIOUserClientClassKey; +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 * gIOGeneralInterest; +extern const OSSymbol * gIOBusyInterest; +extern const OSSymbol * gIOOpenInterest; +extern const OSSymbol * gIOAppPowerStateInterest; +extern const OSSymbol * gIOPriorityPowerStateInterest; + +extern const OSSymbol * gIODeviceMemoryKey; +extern const OSSymbol * gIOInterruptControllersKey; +extern const OSSymbol * gIOInterruptSpecifiersKey; + +extern SInt32 IOServiceOrdering( const OSMetaClassBase * inObj1, const OSMetaClassBase * inObj2, void * ref ); + +typedef void (*IOInterruptAction)( OSObject * target, void * refCon, + IOService * nub, int source ); + +/*! @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 ); + +/*! @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 ); + +typedef void (*IOServiceApplierFunction)(IOService * service, void * context); +typedef void (*OSObjectApplierFunction)(OSObject * object, void * context); + +class IOUserClient; +class IOPlatformExpert; + +/*! @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 OpenFirmware 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 OpenFirmware paths), a name assigned by BSD, or by its location (its point of attachment). + +

Driver Instantiation by IOService

+ +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 kIOProbeScoreKey ("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 init() 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 probe 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 kIOMatchCategoryKey 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 start 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. + +

Properties used by IOService

+ + kIOClassKey, extern const OSSymbol * gIOClassKey, "IOClass" +
+
+Class of the driver to instantiate on matching providers. +
+
+ kIOProviderClassKey, extern const OSSymbol * gIOProviderClassKey, "IOProviderClass" +
+
+Class of the provider(s) to be considered for matching, checked with OSDynamicCast so subclasses will also match. +
+
+ kIOProbeScoreKey, extern const OSSymbol * gIOProbeScoreKey, "IOProbeScore" +
+
+The probe score initially used to order multiple matching drivers. +
+
+ kIOMatchCategoryKey, extern const OSSymbol * gIOMatchCategoryKey, "IOMatchCategory" +
+
+A string defining the driver category for matching purposes. All drivers with no IOMatchCategory property are considered to be in the same default category. Only one driver in a category can be started on each provider. +
+
+ kIONameMatchKey, extern const OSSymbol * gIONameMatchKey, "IONameMatch" +
+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 OpenFirmware 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 kIONameMatchedKey property. +
+Examples +
+@textblock
+	IONameMatch
+	pci106b,7
+@/textblock
+
+ +For a list of possible matching names, a serialized array of strings should used, eg. +
+@textblock
+	IONameMatch
+	
+		APPL,happy16
+		pci106b,7
+	
+@/textblock
+
+ +
+ kIONameMatchedKey, extern const OSSymbol * gIONameMatchedKey, "IONameMatched" +
+The name successfully matched name from the kIONameMatchKey property will be left in the driver's property table as the kIONameMatchedKey property. +
+
+ kIOPropertyMatchKey, extern const OSSymbol * gIOPropertyMatchKey, "IOPropertyMatch" +
+A dictionary of properties that each must exist in the matching IOService and compare successfully with the isEqualTo method. + +
+@textblock
+	IOPropertyMatch
+	
+		APPL,happy16
+		APPL,meek8
+	
+@/textblock
+
+ +
+ kIOUserClientClassKey, extern const OSSymbol * gIOUserClientClassKey, "IOUserClientClass" +
+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. +
+
+ kIOKitDebugKey, extern const OSSymbol * gIOKitDebugKey, "IOKitDebug" +
+Set some debug flags for logging the driver loading process. Flags are defined in IOKit/IOKitDebug.h, but 65535 works well.*/ + +class IOService : public IORegistryEntry +{ + OSDeclareDefaultStructors(IOService) + +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: + 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 true 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 kIOServiceRecursing. + @result true 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 true. */ + + 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 defer to true and call the IOService::didTerminate() implementation when the I/O completes. Otherwise, leave defer set to its default value of false. + @result true. */ + + 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 systemWillShutdown 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 kIOMessageSystemWillPowerOff or kIOMessageSystemWillRestart. */ + + 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 ); + +private: +#if __LP64__ + OSMetaClassDeclareReservedUnused(IOService, 0); + OSMetaClassDeclareReservedUnused(IOService, 1); + OSMetaClassDeclareReservedUnused(IOService, 2); + OSMetaClassDeclareReservedUnused(IOService, 3); + OSMetaClassDeclareReservedUnused(IOService, 4); + OSMetaClassDeclareReservedUnused(IOService, 5); +#else + OSMetaClassDeclareReservedUsed(IOService, 0); + OSMetaClassDeclareReservedUsed(IOService, 1); + OSMetaClassDeclareReservedUsed(IOService, 2); + OSMetaClassDeclareReservedUsed(IOService, 3); + OSMetaClassDeclareReservedUsed(IOService, 4); + OSMetaClassDeclareReservedUsed(IOService, 5); +#endif + + OSMetaClassDeclareReservedUnused(IOService, 6); + OSMetaClassDeclareReservedUnused(IOService, 7); + 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); + +#ifdef __ppc__ + OSMetaClassDeclareReservedUnused(IOService, 48); + OSMetaClassDeclareReservedUnused(IOService, 49); + OSMetaClassDeclareReservedUnused(IOService, 50); + OSMetaClassDeclareReservedUnused(IOService, 51); + OSMetaClassDeclareReservedUnused(IOService, 52); + OSMetaClassDeclareReservedUnused(IOService, 53); + OSMetaClassDeclareReservedUnused(IOService, 54); + OSMetaClassDeclareReservedUnused(IOService, 55); + OSMetaClassDeclareReservedUnused(IOService, 56); + OSMetaClassDeclareReservedUnused(IOService, 57); + OSMetaClassDeclareReservedUnused(IOService, 58); + OSMetaClassDeclareReservedUnused(IOService, 59); + OSMetaClassDeclareReservedUnused(IOService, 60); + OSMetaClassDeclareReservedUnused(IOService, 61); + OSMetaClassDeclareReservedUnused(IOService, 62); + OSMetaClassDeclareReservedUnused(IOService, 63); +#endif + +public: +/*! @function getState + @abstract Accessor for IOService state bits, not normally needed or used outside IOService. + @result State bits for the IOService, eg. kIOServiceInactiveState, kIOServiceRegisteredState. */ + + 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 true 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 registerService 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. kIOServiceSynchronous 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 probe 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 probe method can be left unimplemented by IOService subclasses. The client is already attached to the provider when probe 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 IOProbeScore property in the drivers property table, or kIODefaultProbeScore if none is specified. The probe 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 this 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 start. */ + + virtual 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 start 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 start is called.
Implementations of start must call start on their superclass at an appropriate point. If an implementation of start has already called super::start but subsequently determines that it will fail, it must call super::stop to balance the prior call to super::start and prevent reference leaks. + @result true if the start was successful; false 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 open 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 kIOServiceSeize to request the device be withdrawn from its current owner. + @result true if the open was successful; false otherwise. */ + + virtual bool open( IOService * forClient, + IOOptionBits options = 0, + void * arg = 0 ); + +/*! @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 close, 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. + @param arg Family specific arguments which are ignored by IOService. */ + + 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, open. The object is locked via @link lockForArbitration lockForArbitration@/link before handleOpen 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 handleOpen. + @result trueif the open was successful; false 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 handleClose 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 handleIsOpen is called. + @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 true 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; terminate 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, terminate fails. If the kIOServiceRequired flag is passed however, terminate 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 kIOMessageServiceIsTerminated. 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 stop, @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. kIOServiceSynchronous may be passed to cause terminate 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 finalize 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 finalize 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 finalize. + @result true. */ + + virtual bool finalize( IOOptionBits options ); + +/*! @function free + @abstract Frees data structures that were allocated when power management was initialized on this service. */ + + virtual void free( void ); + +/*! @function lockForArbitration + @abstract Locks an IOService object against changes in state or ownership. + @discussion The registration, termination and open / close functions of IOService use lockForArbtration to single-thread access to an IOService object. lockForArbitration 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 false, otherwise pass true. */ + + 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 unlockForArbitration. */ + + 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 kIOServiceRecursing. + @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 busyState of an IOService object. + @discussion Many activities in IOService are asynchronous. When registration, matching, or termination is in progress on an IOService object, its busyState is increased by one. Change in busyState to or from zero also changes the IOService object's provider's busyState 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 busyState value. */ + + virtual UInt32 getBusyState( void ); + +/*! @function adjustBusy + @abstract Adjusts the busyState of an IOService object. + @discussion Applies a delta to an IOService object's busyState. A change in the busyState to or from zero will change the IOService object's provider's busyState by one (in the same direction). + @param delta The delta to be applied to the IOService object's busyState. */ + + 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 busyState 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, kIOReturnTimeout, or kIOReturnSuccess. */ + + 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 IOProbeScore property in the drivers property table, or kIODefaultProbeScore if none is specified. + @result false if the family considers the matching dictionary does not match in properties it understands; true 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 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. publishResource 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 The object to be published. */ + + static void publishResource( const OSSymbol * key, OSObject * value = 0 ); + +/*! @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. publishResource 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 The object to be published. */ + + static void publishResource( const char * key, OSObject * value = 0 ); + 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 gIOMatchedNotification or gIOTerminatedNotification, and notifications will only include IOService objects that match the supplied matching dictionary. Notifications are ordered by a priority set with addNotification. 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. addNotification 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: +
gIOPublishNotification Delivered when an IOService object is registered. +
gIOFirstPublishNotification Delivered when an IOService object is registered, but only once per IOService instance. Some IOService objects may be reregistered when their state is changed. +
gIOMatchedNotification Delivered when an IOService object has been matched with all client drivers, and they have been probed and started. +
gIOFirstMatchNotification 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. +
gIOTerminatedNotification Delivered after an IOService object has been terminated, during its finalize stage. + @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 IONotifier * addNotification( + const OSSymbol * type, OSDictionary * matching, + IOServiceNotificationHandler handler, + void * target, void * ref = 0, + 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 gIOMatchedNotification or gIOTerminatedNotification, and notifications will only include IOService objects that match the supplied matching dictionary. Notifications are ordered by a priority set with addNotification. 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. addMatchingNotification 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: +
gIOPublishNotification Delivered when an IOService object is registered. +
gIOFirstPublishNotification Delivered when an IOService object is registered, but only once per IOService instance. Some IOService objects may be reregistered when their state is changed. +
gIOMatchedNotification Delivered when an IOService object has been matched with all client drivers, and they have been probed and started. +
gIOFirstMatchNotification 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. +
gIOTerminatedNotification Delivered after an IOService object has been terminated, during its finalize stage. + @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 = 0, + SInt32 priority = 0 ); + +/*! @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. waitForService consumes one reference of the matching dictionary. + @param timeout The maximum time to wait. + @result A published IOService object matching the supplied dictionary. */ + + static IOService * waitForService( OSDictionary * matching, + mach_timespec_t * timeout = 0); + +/*! @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 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 OSIterator * getMatchingServices( 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. serviceMatching 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, serviceMatching 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 * serviceMatching( const char * className, + OSDictionary * table = 0 ); + +/*! @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. serviceMatching 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, serviceMatching 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 * serviceMatching( const OSString * className, + OSDictionary * table = 0 ); + +/*! @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. nameMatching 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 IORegistryEntry::compareName method. + @param table If zero, nameMatching 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 * nameMatching( const char * name, + OSDictionary * table = 0 ); + +/*! @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. nameMatching 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 IORegistryEntry::compareName method. + @param table If zero, nameMatching 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 * nameMatching( const OSString* name, + OSDictionary * table = 0 ); + +/*! @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 publishResource method. + @param table If zero, resourceMatching 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 * resourceMatching( const char * name, + OSDictionary * table = 0 ); + +/*! @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 publishResource method. + @param table If zero, resourceMatching 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 * resourceMatching( const OSString * name, + OSDictionary * table = 0 ); + + +/*! @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 OSDictionary * propertyMatching( const OSSymbol * key, const OSObject * value, + OSDictionary * table = 0 ); + +/*! @function registryEntryIDMatching + @abstract Creates a matching dictionary, or adds matching properties to an existing dictionary, that specify a IORegistryEntryID match. + @discussion registryEntryIDMatching creates a matching dictionary that specifies the IOService object with the assigned registry entry ID (returned by IORegistryEntry::getRegistryEntryID()). 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 ID. Matching is successful on the IOService object that return that ID from the IORegistryEntry::getRegistryEntryID() method. + @param table If zero, registryEntryIDMatching 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 = 0 ); + + +/*! @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 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 key 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 isEqualTo 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 true 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 isEqualTo 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 key 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 isEqualTo 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 true 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 isEqualTo 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 compareProperty, with an IOService object's property table, if compareProperty returns true 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 compareProperty returns true 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 false if the provider is inactive or on a resource failure; otherwise true. */ + + 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 provider->getWorkLoop. + @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 getWorkLoop. 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 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 lockForArbitration, protecting it from state changes. */ + + virtual 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 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 lockForArbitration, protecting it from state changes. */ + + virtual 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. callPlatformFunction allows any IOService object to access these functions. Normally callPlatformFunction 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 publishResource(functionName, this). If no service can be found to execute the function an error is returned. + @param functionName Name of the function to be called. When functionName is a C string, callPlatformFunction converts the C string to an OSSymbol and calls the OSSymbol version of callPlatformFunction. This process can block and should not be used from an interrupt context. + @param waitForFunction If true, callPlatformFunction will not return until the function has been called. + @result An IOReturn code; kIOReturnSuccess if the function was successfully executed, kIOReturnUnsupported 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 IOPlatformExport 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 ); + + /* 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; kIOReturnSuccess 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 IODeviceMemory::map(options). 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.
kIOReturnNoInterrupt is returned if the source is not valid; kIOReturnNoResources is returned if the interrupt already has an installed handler. */ + + virtual IOReturn registerInterrupt(int source, OSObject *target, + IOInterruptAction handler, + void *refCon = 0); + +/*! @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 (kIOReturnNoInterrupt is returned if the source is not valid). */ + + virtual IOReturn unregisterInterrupt(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 getInterruptType.
kIOInterruptTypeEdge will be returned for edge-trigggered sources.
kIOInterruptTypeLevel will be returned for level-trigggered sources. + @result An IOReturn code (kIOReturnNoInterrupt 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 (kIOReturnNoInterrupt 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 (kIOReturnNoInterrupt 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 (kIOReturnNoInterrupt 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 message method to its clients informing them of state changes, such as kIOMessageServiceIsTerminated or kIOMessageServiceIsSuspended. Certain messages are defined by the I/O Kit in IOMessage.h while others may be family dependent. This method is implemented in the client to receive messages. + @param type A type defined in IOMessage.h 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 = 0 ); + +/*! @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 kIOMessageServiceIsTerminated or kIOMessageServiceIsSuspended. Certain messages are defined by the I/O Kit in IOMessage.h 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 IOMessage.h 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 = 0, 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 kIOMessageServiceIsTerminated or kIOMessageServiceIsSuspended. Certain messages are defined by the I/O Kit in IOMessage.h 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 IOMessage.h 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-kIOReturnSuccess return codes returned by the clients, or kIOReturnSuccess if all return kIOReturnSuccess. */ + + virtual IOReturn messageClients( UInt32 type, + void * argument = 0, vm_size_t argSize = 0 ); + + virtual IONotifier * registerInterest( const OSSymbol * typeOfInterest, + IOServiceInterestHandler handler, + void * target, void * ref = 0 ); + + virtual void applyToProviders( IOServiceApplierFunction applier, + void * context ); + + virtual void applyToClients( IOServiceApplierFunction applier, + void * context ); + + 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 kIOReturnUnsupported, 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 IOServiceOpen. */ + + virtual IOReturn newUserClient( task_t owningTask, void * securityID, + UInt32 type, OSDictionary * properties, + IOUserClient ** handler ); + + virtual IOReturn newUserClient( task_t owningTask, void * securityID, + UInt32 type, 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 IOReturn.h 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 errno. + @discussion BSD defines its own return codes for its functions in sys/errno.h, and I/O Kit families may need to supply compliant results in BSD shims. Results are available for the standard return codes in IOReturn.h in IOService, while subclasses may implement this method to interpret family dependent return codes. + @param rtn The IOReturn code. + @result The BSD errno or EIO 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; + + void requireMaxBusStall(UInt32 ns); + void 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( 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 ); + +private: + static OSObject * copyExistingServices( OSDictionary * matching, + IOOptionBits inState, IOOptionBits options = 0 ); + + static IONotifier * setNotification( + const OSSymbol * type, OSDictionary * matching, + IOServiceMatchingNotificationHandler handler, + void * target, void * ref, + SInt32 priority = 0 ); + + static 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 ); + + APPLE_KEXT_COMPATIBILITY_VIRTUAL + void deliverNotification( const OSSymbol * type, + IOOptionBits orNewState, IOOptionBits andNewState ); + + bool invokeNotifer( class _IOServiceNotifier * notify ); + + APPLE_KEXT_COMPATIBILITY_VIRTUAL + void unregisterAllInterest( void ); + + APPLE_KEXT_COMPATIBILITY_VIRTUAL + IOReturn waitForState( UInt32 mask, UInt32 value, + mach_timespec_t * timeout = 0 ); + + 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 ); + void scheduleFinalize( void ); + static void terminateThread( void * arg, wait_result_t unused ); + static void terminateWorker( IOOptionBits options ); + static void actionWillTerminate( IOService * victim, IOOptionBits options, + OSArray * doPhase2List ); + static void actionDidTerminate( IOService * victim, IOOptionBits options ); + static void actionFinalize( IOService * victim, IOOptionBits options ); + static void actionStop( IOService * client, IOService * provider ); + + APPLE_KEXT_COMPATIBILITY_VIRTUAL + IOReturn resolveInterrupt(IOService *nub, int source); + APPLE_KEXT_COMPATIBILITY_VIRTUAL + IOReturn lookupInterrupt(int source, bool resolve, IOInterruptController **interruptController); + + + /* power management */ +public: + +/*! @function PMinit + @abstract Initializes power management for a driver. + @discussion PMinit 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 start routine and must be paired with a call to @link PMstop PMstop@/link. + Most calls to PMinit are followed by calls to @link joinPMtree joinPMtree@/link and @link registerPowerDriver registerPowerDriver@/link. */ + + virtual void PMinit( void ); + +/*! @function PMstop + @abstract Frees and removes the driver from power management. + @discussion The power managment variables don't exist after this call and the power managment methods in the caller shouldn't be called. + Calling PMstop 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 start 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 this. */ + + 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 start 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 registerPowerDriver. A nub may override registerPowerDriver 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 this. + @param powerStates A driver-defined array of power states that the driver and device support. Power states are defined in pwr_mgt/IOPMpowerState.h. + @param numberOfStates The number of power states in the array. + @result IOPMNoErr. All errors are logged via kprintf. */ + + 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 registerInterestedDriver on the IOService object you are interested in receiving power state messages from, and pass a pointer to the interested driver (this) as an argument. + 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 powerStateWillChangeTo or powerStateDidChangeTo, 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 registerInterestedDriver. + @discussion Most drivers do not need to override deRegisterInterestedDriver. + @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 acknowledgePowerChange. + 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 acknowledgePowerChange, or use an immediate acknowledgement return from powerStateWillChangeTo or powerStateDidChangeTo. + @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 IOPMNoErr. */ + + APPLE_KEXT_COMPATIBILITY_VIRTUAL + IOReturn acknowledgePowerChange( IOService * whichDriver ); + +/*! @function acknowledgeSetPowerState + @abstract Acknowledges the belated completion of a driver's setPowerState 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 setPowerState, or delayed, via this call to acknowledgeSetPowerState. + Any driver that does not return kIOPMAckImplied from its setPowerState implementation must later call acknowledgeSetPowerState. + @result IOPMNoErr. */ + + 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. + makeUsable is implemented using @link changePowerStateToPriv changePowerStateToPriv@/link. Subsequent requests for lower power, such as from changePowerStateToPriv, 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 temporaryPowerClampOn 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 changePowerStateTo, changePowerStateToPriv, 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 changePowerStateToPriv to change your device's power state, you might need to call changePowerStateTo in the following circumstances: +
  • If a driver will be using changePowerStateToPriv to change its power state, it should call changePowerStateTo(0) in its start routine to eliminate the influence changePowerStateTo has on power state calculations. +
  • Call changePowerStateTo 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, changePowerStateTo(1) 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.
+ @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 capabilityFlags 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 staticPower field. Thus this call will not accurately reflect power consumption for most drivers. + @result A copy of the staticPower 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 activityTickle 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 activityTickle call. To start this up, the driver calls its superclass's setIdleTimerPeriod. 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 activityTickle 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 activityTickle 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 type parameter should be kIOPMSubclassPolicy, and the driver should override the activityTickle method. The superclass IOService implementation of activityTickle does nothing with the kIOPMSubclassPolicy argument. + @param type When type is kIOPMSubclassPolicy, activityTickle is not handled in IOService and should be intercepted by the subclass. When type is kIOPMSuperclassPolicy1, 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 type is kIOPMSuperclassPolicy1, stateNumber 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 type is kIOPMSuperclassPolicy1, the superclass returns true if the device is currently in the state specified by stateNumber. If the device is in a lower state and must be powered up, the superclass returns false; 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 setAggressiveness 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 setAgressiveness 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 setAgressiveness method in its own setAgressiveness implementation. + Most drivers do not need to implement setAgressiveness. + @param type The aggressiveness factor type, such as kPMMinutesToDim, kPMMinutesToSpinDown, kPMMinutesToSleep, and kPMPowerSource. (Aggressiveness factors are defined in pwr_mgt/IOPM.h.) + @param newLevel The aggressiveness factor's new value. + @result IOPMNoErr. */ + + 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 type. + @result kIOReturnSuccess 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 kIOReturnSuccess upon success; an I/O Kit error code otherwise. */ + + virtual IOReturn setIdleTimerPeriod( unsigned long ); + +#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 getPowerState 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 setPowerState to take part in system power management. After a driver is registered with power management, the system uses setPowerState 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 setPowerState. setPowerState 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, whatDevice will be equal to your driver's own this pointer. + @result The driver must return IOPMAckImplied 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 inputPowerRequirement field exactly matches the value of the domainState 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 outputPowerCharacter 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 inputPowerRequirement field exactly matches the value of the domainState 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 outputPowerCharacter 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 Power management calls a driver with this method to find out what power state the device would be in for a given power domain state. This happens when the power domain is changing state and power management needs to determine the effect of the change. + 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 inputPowerRequirement field exactly matches the value of the domainState 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 outputPowerCharacter 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 registerInterestedDriver on a power managed driver, you must implement powerStateWillChangeTo and @link powerStateDidChangeTo powerStateDidChangeTo@/link to receive the notifications. + powerStateWillChangeTo is called in a clean and separate thread context. powerStateWillChangeTo is called before a power state transition takes place; powerStateDidChangeTo 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 capabilityFlags 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 IOPMAckImplied 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 registerInterestedDriver on a power managed driver, you must implemnt @link powerStateWillChangeTo powerStateWillChangeTo@/link and powerStateDidChangeTo to receive the notifications. + powerStateDidChangeTo is called in a clean and separate thread context. powerStateWillChangeTo is called before a power state transition takes place; powerStateDidChangeTo 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 capabilityFlags 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 IOPMAckImplied 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 didYouWakeSystem and return true if its device was responsible for waking the system. + @result true if the driver's device woke the system and false 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, changePowerStateToPriv, 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 changePowerStateTo method on power state one of two ways. See @link powerOverrideOnPriv powerOverrideOnPriv@/link to ignore the method's influence, or call changePowerStateTo(0) in the driver's start routine to remove the changePowerStateTo 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. */ + + 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 powerOverrideOnPriv. When the override is on, power management keeps the device's power state in the state specified by changePowerStateToPriv. Turning on the override will initiate a power change if the driver's changePowerStateToPriv desired power state is different from the maximum of the changePowerStateTo 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 changePowerStateTo, changePowerStateToPriv, 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 */ Index: branches/azimutz/Cleancut/i386/include/IOKit/IOBufferMemoryDescriptor.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/IOBufferMemoryDescriptor.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/IOBufferMemoryDescriptor.h (revision 885) @@ -0,0 +1,261 @@ +/* + * 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 _IOBUFFERMEMORYDESCRIPTOR_H +#define _IOBUFFERMEMORYDESCRIPTOR_H + +#include + +enum { + kIOMemoryPhysicallyContiguous = 0x00000010, + kIOMemoryPageable = 0x00000020, + kIOMemoryPurgeable = 0x00000040, + kIOMemorySharingTypeMask = 0x000f0000, + kIOMemoryUnshared = 0x00000000, + kIOMemoryKernelUserShared = 0x00010000, + // shared IOMemoryDescriptor options for IOBufferMemoryDescriptor: + kIOBufferDescriptorMemoryFlags = kIOMemoryDirectionMask + | kIOMemoryThreadSafe +}; + +#define _IOBUFFERMEMORYDESCRIPTOR_INTASKWITHOPTIONS_ 1 +/*! + @class IOBufferMemoryDescriptor + @abstract Provides a simple memory descriptor that allocates its own buffer memory. +*/ + +class IOBufferMemoryDescriptor : public IOGeneralMemoryDescriptor +{ + OSDeclareDefaultStructors(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) */ + ExpansionData * reserved; + +protected: + void * _buffer; + vm_size_t _capacity; + vm_offset_t _alignment; + IOOptionBits _options; +private: + uintptr_t _internalReserved; + unsigned _internalFlags; + +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__ */ + + 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__ */ + OSMetaClassDeclareReservedUsed(IOBufferMemoryDescriptor, 0); + OSMetaClassDeclareReservedUsed(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(); + +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 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:
+ kIODirectionOut, kIODirectionIn - set the direction of the I/O transfer.
+ 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.
+ kIOMemoryPageable - pass to request memory be non-wired - the default for kernel allocated memory is wired.
+ kIOMemoryPurgeable - pass to request memory that may later have its purgeable state set with IOMemoryDescriptor::setPurgeable. Only supported for kIOMemoryPageable allocations.
+ kIOMemoryKernelUserShared - pass to request memory that will be mapped into both the kernel and client applications. + @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 IOBufferMemoryDescriptor * inTaskWithOptions( + task_t inTask, + IOOptionBits options, + vm_size_t capacity, + vm_offset_t alignment = 1); + +/*! @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:
+ kIODirectionOut, kIODirectionIn - set the direction of the I/O transfer.
+ 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.
+ kIOMemoryKernelUserShared - pass to request memory that will be mapped into both the kernel and client applications. + @param capacity The number of bytes to allocate. + @param mask 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 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 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 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_DEPRECATED; /* use getBytesNoCopy() instead */ +#endif /* !__LP64__ */ +}; + +#endif /* !_IOBUFFERMEMORYDESCRIPTOR_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/IOCatalogue.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/IOCatalogue.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/IOCatalogue.h (revision 885) @@ -0,0 +1,272 @@ +/* + * Copyright (c) 1998-2000 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 +#include +#include +#include +#include +#include + +#include + +class IOService; + +/*! + @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: + OSCollectionIterator * kernelTables; + OSArray * array; + IOLock * lock; + SInt32 generation; + +/* This stuff is no longer used at all but was exported in prior + * releases, so we keep it around for PPC/i386 only. + */ +#if __ppc__ || __i386__ + IOLock * kld_lock; +#endif /* __ppc__ || __i386__ */ + +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 ); + + /*! + @function findDrivers + @abstract This is the primary entry point for IOService. + @param 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. + */ + 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. + */ + 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 doNubMatchng 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 doNubMatchng 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. + @param moduleName Name of the module. + @result Returns true if the associated kernel module has been loaded into the kernel. + */ + bool isModuleLoaded( OSString * moduleName ) const; + + /*! + @function isModuleLoaded + @abstract Reports if a kernel module has been loaded. + @param moduleName Name of the module. + @result Returns true if the associated kernel module has been loaded into the kernel. + */ + bool isModuleLoaded( const char * moduleName ) const; + + /*! + @function isModuleLoaded + @abstract Reports if a kernel module has been loaded for a particular personality. + @param driver A driver personality's property list. + @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 ) const; + + /*! + @function moduleHasLoaded + @abstract Callback function called after a IOKit dependent kernel module is loaded. + @param name Name of the kernel module. + */ + void moduleHasLoaded( OSString * 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 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 Starts an IOService matching thread where matching keys and values are provided by the matching dictionary. + @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 start matching for all personalities which have the key 'IOProviderClass' equal to 'IOPCIDevice'. + */ + bool startMatching( OSDictionary * matching ); + + /*! + @function reset + @abstract Return the Catalogue to its initial state. + */ + void reset(void); + + /*! + @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; + + bool serializeData(IOOptionBits kind, OSSerialize * s) const; + +/* This stuff is no longer used at all we keep it around for PPC/i386 + * binary compatibility only. Symbols are no longer exported. + */ +#if __ppc__ || __i386__ + /*! + @function recordStartupExtensions + @abstract Records extensions made available by the primary booter. +

+ This function is for internal use by the kernel startup linker. + Kernel extensions should never call it. + @result Returns true if startup extensions were successfully recorded, + false if not. + */ + virtual bool recordStartupExtensions(void); + + /*! + @function addExtensionsFromArchive() + @abstract Records an archive of extensions, as from device ROM. +

+ This function is currently for internal use. + Kernel extensions should never call it. + @param mkext An OSData object containing a multikext archive. + @result Returns true if mkext was properly unserialized and its + contents recorded, false if not. + */ + virtual bool addExtensionsFromArchive(OSData * mkext); + + + /*! + @function removeKernelLinker + @abstract Removes from memory all code and data related to + boot-time loading of kernel extensions. kextd triggers + this when it first starts in order to pass responsibility + for loading extensions from the kernel itself to kextd. + @result Returns KERN_SUCCESS if the kernel linker is successfully + removed or wasn't present, KERN_FAILURE otherwise. + */ + virtual kern_return_t removeKernelLinker(void); +#endif /* __ppc__ || __i386__ */ + +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; +}; + +extern const OSSymbol * gIOClassKey; +extern const OSSymbol * gIOProbeScoreKey; +extern IOCatalogue * gIOCatalogue; + +#endif /* ! _IOKIT_IOCATALOGUE_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/IOTypes.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/IOTypes.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/IOTypes.h (revision 885) @@ -0,0 +1,238 @@ +/* + * Copyright (c) 1998-2006 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 */ + +#if KERNEL +#include +#else +#include +#include +#endif + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef NULL +#if defined (__cplusplus) +#define NULL 0 +#else +#define NULL ((void *)0) +#endif +#endif + +/* + * Simple data types. + */ +#ifndef __MACTYPES__ /* CF MacTypes.h */ +#ifndef __TYPES__ /* guess... Mac Types.h */ + +#include +#include + +#endif /* __TYPES__ */ +#endif /* __MACTYPES__ */ + +#if KERNEL +#include +#endif + +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; + +#ifdef __LP64__ +typedef mach_vm_address_t IOVirtualAddress; +#else +typedef vm_address_t IOVirtualAddress; +#endif + +#if defined(__LP64__) && defined(KERNEL) +typedef IOByteCount64 IOByteCount; +#else +typedef IOByteCount32 IOByteCount; +#endif + +typedef IOVirtualAddress IOLogicalAddress; + +#if defined(__LP64__) && 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; + +#ifdef __LP64__ +typedef IOVirtualRange IOAddressRange; +#else /* !__LP64__ */ +typedef struct +{ + mach_vm_address_t address; + mach_vm_size_t length; +} IOAddressRange; +#endif /* !__LP64__ */ + +/* + * 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 + +#ifndef MACH_KERNEL + +#ifndef __IOKIT_PORTS_DEFINED__ +#define __IOKIT_PORTS_DEFINED__ +typedef struct OSObject * io_object_t; +#endif /* __IOKIT_PORTS_DEFINED__ */ + +#include + +typedef io_object_t io_connect_t; +typedef io_object_t io_enumerator_t; +typedef io_object_t io_iterator_t; +typedef io_object_t io_registry_entry_t; +typedef io_object_t io_service_t; + +#define IO_OBJECT_NULL ((io_object_t) 0) + +#endif /* MACH_KERNEL */ + +// IOConnectMapMemory memoryTypes +enum { + kIODefaultMemoryType = 0 +}; + +enum { + kIODefaultCache = 0, + kIOInhibitCache = 1, + kIOWriteThruCache = 2, + kIOCopybackCache = 3, + kIOWriteCombineCache = 4 +}; + +// IOMemory mapping options +enum { + kIOMapAnywhere = 0x00000001, + + kIOMapCacheMask = 0x00000700, + kIOMapCacheShift = 8, + kIOMapDefaultCache = kIODefaultCache << kIOMapCacheShift, + kIOMapInhibitCache = kIOInhibitCache << kIOMapCacheShift, + kIOMapWriteThruCache = kIOWriteThruCache << kIOMapCacheShift, + kIOMapCopybackCache = kIOCopybackCache << kIOMapCacheShift, + kIOMapWriteCombineCache = kIOWriteCombineCache << kIOMapCacheShift, + + kIOMapUserOptionsMask = 0x00000fff, + + kIOMapReadOnly = 0x00001000, + + kIOMapStatic = 0x01000000, + kIOMapReference = 0x02000000, + kIOMapUnique = 0x04000000 +}; + +/*! @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) +}; + +/* compatibility types */ + + +#ifdef __cplusplus +} +#endif + +#endif /* ! __IOKIT_IOTYPES_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/IOSharedDataQueue.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/IOSharedDataQueue.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/IOSharedDataQueue.h (revision 885) @@ -0,0 +1,129 @@ +/* + * 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_IOSHAREDDATAQUEUE_H +#define _IOKIT_IOSHAREDDATAQUEUE_H + +#ifdef dequeue +#undef dequeue +#endif + +#include + +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. + * + *
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. + * + *
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. + * + *
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 { + }; + /*! @var reserved + Reserved for future use. (Internal use only) */ + ExpansionData * _reserved; + +protected: + virtual void free(); + +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 . 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 .
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 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.
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 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 . 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 . + * @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 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 IOMemoryDescriptor *getMemoryDescriptor(); + + /*! + * @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); + + 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 /* _IOKIT_IOSHAREDDATAQUEUE_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/OSMessageNotification.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/OSMessageNotification.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/OSMessageNotification.h (revision 885) @@ -0,0 +1,158 @@ +/* + * 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 +#include +#include + +enum { + kFirstIOKitNotificationType = 100, + kIOServicePublishNotificationType = 100, + kIOServiceMatchedNotificationType = 101, + kIOServiceTerminatedNotificationType = 102, + kIOAsyncCompletionNotificationType = 150, + kIOServiceMessageNotificationType = 160, + kLastIOKitNotificationType = 199 +}; + +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]; + +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 */ + Index: branches/azimutz/Cleancut/i386/include/IOKit/IOMemoryDescriptor.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/IOMemoryDescriptor.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/IOMemoryDescriptor.h (revision 885) @@ -0,0 +1,898 @@ +/* + * 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 _IOMEMORYDESCRIPTOR_H +#define _IOMEMORYDESCRIPTOR_H + +#include + +#include +#include +#include + +#include + +class IOMemoryMap; +class IOMapper; + +/* + * 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 +}; +#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, + kIOMemoryPersistent = 0x00010000, + kIOMemoryThreadSafe = 0x00100000, // Shared with Buffer MD +}; + +#define kIOMapperSystem ((IOMapper *) 0) + +enum +{ + kIOMemoryPurgeableKeepCurrent = 1, + kIOMemoryPurgeableNonVolatile = 2, + kIOMemoryPurgeableVolatile = 3, + kIOMemoryPurgeableEmpty = 4 +}; +enum +{ + kIOMemoryIncoherentIOFlush = 1, + kIOMemoryIncoherentIOStore = 2, +}; + +#define IOMEMORYDESCRIPTOR_SUPPORTS_DMACOMMAND 1 + +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; + + OSDeclareDefaultStructors(IOMemoryDescriptor); + +protected: +/*! @struct ExpansionData + @discussion This structure will be used to expand the capablilties of this class in the future. + */ + struct ExpansionData { + void * devicePager; + unsigned int pagerContig:1; + unsigned int unused:31; + IOMemoryDescriptor * memory; + }; + +/*! @var reserved + Reserved for future use. (Internal use only) */ + ExpansionData * reserved; + +protected: + OSSet * _mappings; + IOOptionBits _flags; + void * _memEntry; + +#ifdef __LP64__ + uint64_t __iomd_reserved1; + uint64_t __iomd_reserved2; + uint64_t __iomd_reserved3; + uint64_t __iomd_reserved4; +#else /* !__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:
+ kIOMemoryPurgeableKeepCurrent - make no changes to the memory's purgeable state.
+ kIOMemoryPurgeableVolatile - make the memory volatile - the memory may be reclaimed by the VM system without saving its contents to backing store.
+ kIOMemoryPurgeableNonVolatile - make the memory nonvolatile - the memory is treated as with usual allocations and must be saved to backing store if paged.
+ 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:
+ kIOMemoryPurgeableNonVolatile - the memory was nonvolatile.
+ kIOMemoryPurgeableVolatile - the memory was volatile but its content has not been discarded by the VM system.
+ kIOMemoryPurgeableEmpty - the memory was volatile and has been discarded by the VM system.
+ @result An IOReturn code. */ + + virtual IOReturn setPurgeable( IOOptionBits newState, + IOOptionBits * oldState ); + +/*! @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:
+ 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.
+ 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 ); + +private: + OSMetaClassDeclareReservedUsed(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__ */ + OSMetaClassDeclareReservedUsed(IOMemoryDescriptor, 1); + OSMetaClassDeclareReservedUsed(IOMemoryDescriptor, 2); + OSMetaClassDeclareReservedUsed(IOMemoryDescriptor, 3); + OSMetaClassDeclareReservedUsed(IOMemoryDescriptor, 4); + OSMetaClassDeclareReservedUsed(IOMemoryDescriptor, 5); + OSMetaClassDeclareReservedUsed(IOMemoryDescriptor, 6); + OSMetaClassDeclareReservedUsed(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(); +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 IOMemoryDescriptor * withAddress(void * address, + IOByteCount withLength, + IODirection withDirection); + +#ifndef __LP64__ + static 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 IOMemoryDescriptor * withPhysicalAddress( + IOPhysicalAddress address, + IOByteCount withLength, + IODirection withDirection ); + +#ifndef __LP64__ + static 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 withLength 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. + @result The created IOMemoryDescriptor on success, to be released by the caller, or zero on failure. */ + + static 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. + @result The created IOMemoryDescriptor on success, to be released by the caller, or zero on failure. */ + + static 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 IOMemoryDescriptor *withOptions(void * buffers, + UInt32 count, + UInt32 offset, + task_t task, + IOOptionBits options, + IOMapper * mapper = kIOMapperSystem); + +#ifndef __LP64__ + static IOMemoryDescriptor * withPhysicalRanges( + IOPhysicalRange * ranges, + UInt32 withCount, + IODirection withDirection, + bool asReference = false) APPLE_KEXT_DEPRECATED; /* use withOptions() and kIOMemoryTypePhysical instead */ +#endif /* !__LP64__ */ + +#ifndef __LP64__ + static 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 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; + +/*! @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 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,
+ 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.
+ kIOMapDefaultCache to inhibit the cache in I/O areas, kIOMapCopybackCache in general purpose RAM.
+ kIOMapInhibitCache, kIOMapWriteThruCache, kIOMapCopybackCache to set the appropriate caching.
+ kIOMapReadOnly to allow only read only accesses to the memory - writes will cause and access fault.
+ 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.
+ 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.
+ @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. */ + + 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 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 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 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, + vm_map_t addressMap, + mach_vm_address_t address, + mach_vm_size_t sourceOffset, + mach_vm_size_t length, + IOOptionBits options ); + + virtual 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 +{ + OSDeclareDefaultStructors(IOMemoryMap) + +protected: + virtual void taggedRelease(const void *tag = 0) const; + virtual void free(); + +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. + @result A virtual address. */ + + virtual IOVirtualAddress getVirtualAddress(); + +/*! @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(); + +/*! @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(); + +/*! @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__ + inline mach_vm_address_t getAddress() __attribute__((always_inline)); + inline mach_vm_size_t getSize() __attribute__((always_inline)); +#else /* !__LP64__ */ + virtual mach_vm_address_t getAddress(); + virtual mach_vm_size_t getSize(); +#endif /* !__LP64__ */ + + + OSMetaClassDeclareReservedUnused(IOMemoryMap, 0); + OSMetaClassDeclareReservedUnused(IOMemoryMap, 1); + OSMetaClassDeclareReservedUnused(IOMemoryMap, 2); + OSMetaClassDeclareReservedUnused(IOMemoryMap, 3); + OSMetaClassDeclareReservedUnused(IOMemoryMap, 4); + OSMetaClassDeclareReservedUnused(IOMemoryMap, 5); + OSMetaClassDeclareReservedUnused(IOMemoryMap, 6); + OSMetaClassDeclareReservedUnused(IOMemoryMap, 7); +}; + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#if !defined(__LP64) || defined(_IOMEMORYDESCRIPTOR_INTERNAL_) + +// 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(); + + virtual IOReturn dmaCommandOperation(DMACommandOps op, void *vData, UInt dataSize) const; + + virtual uint64_t getPreparationID( void ); + +private: + +#ifndef __LP64__ + virtual void setPosition(IOByteCount position); + virtual void mapIntoKernel(unsigned rangeIndex); + virtual void unmapFromKernel(); +#endif /* !__LP64__ */ + + // Internal APIs may be made virtual at some time in the future. + IOReturn wireVirtual(IODirection forDirection); + void *createNamedEntry(); + + // Internal + OSData * _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); + +#ifndef __LP64__ + // Secondary initialisers + virtual bool initWithAddress(void * address, + IOByteCount withLength, + IODirection withDirection) APPLE_KEXT_DEPRECATED; + + virtual bool initWithAddress(IOVirtualAddress address, + IOByteCount withLength, + IODirection withDirection, + task_t withTask) APPLE_KEXT_DEPRECATED; + + virtual bool initWithPhysicalAddress( + IOPhysicalAddress address, + IOByteCount withLength, + IODirection withDirection ) APPLE_KEXT_DEPRECATED; + + virtual bool initWithRanges( IOVirtualRange * ranges, + UInt32 withCount, + IODirection withDirection, + task_t withTask, + bool asReference = false) APPLE_KEXT_DEPRECATED; + + virtual bool initWithPhysicalRanges(IOPhysicalRange * ranges, + UInt32 withCount, + IODirection withDirection, + bool asReference = false) APPLE_KEXT_DEPRECATED; + + virtual addr64_t getPhysicalSegment64( IOByteCount offset, + IOByteCount * length ) APPLE_KEXT_DEPRECATED; + + virtual IOPhysicalAddress getPhysicalSegment(IOByteCount offset, + IOByteCount * length); + + virtual IOPhysicalAddress getSourceSegment(IOByteCount offset, + IOByteCount * length) APPLE_KEXT_DEPRECATED; + + virtual void * getVirtualSegment(IOByteCount offset, + IOByteCount * length) APPLE_KEXT_DEPRECATED; +#endif /* !__LP64__ */ + + virtual IOReturn setPurgeable( IOOptionBits newState, + IOOptionBits * oldState ); + + virtual addr64_t getPhysicalSegment( IOByteCount offset, + IOByteCount * length, +#ifdef __LP64__ + IOOptionBits options = 0 ); +#else /* !__LP64__ */ + IOOptionBits options ); +#endif /* !__LP64__ */ + + virtual IOReturn prepare(IODirection forDirection = kIODirectionNone); + + virtual IOReturn complete(IODirection forDirection = kIODirectionNone); + + 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 ); + + virtual bool serialize(OSSerialize *s) const; + + // Factory method for cloning a persistent IOMD, see IOMemoryDescriptor + static IOMemoryDescriptor * + withPersistentMemoryDescriptor(IOGeneralMemoryDescriptor *originalMD); + +}; + +#endif /* !defined(__LP64) || defined(_IOMEMORYDESCRIPTOR_INTERNAL_) */ + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#ifdef __LP64__ +mach_vm_address_t IOMemoryMap::getAddress() +{ + return (getVirtualAddress()); +} + +mach_vm_size_t IOMemoryMap::getSize() +{ + return (getLength()); +} +#else /* !__LP64__ */ +#include +#endif /* !__LP64__ */ + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#endif /* !_IOMEMORYDESCRIPTOR_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/usb/USB.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/usb/USB.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/usb/USB.h (revision 885) @@ -0,0 +1,1076 @@ +/* + * Copyright (c) 1998-2006 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 _USB_H +#define _USB_H + +#if KERNEL + #include + #include +#else + #include +#endif + +#include + +#if !defined(__USB__) +# include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + + /*! + @header USB.h + @abstract Public Interfaces to the USB implementation in Mac OS X. + @discussion This header file contains definitions and structures that are used in the different USB API's in Mac OS X, both in the kernel and in the user space. + */ + + /*! + @defined Endian conversion definitions + @discussion The USB API's use a convention of specifying parameters in the host order. The USB spec specifies that multi-byte items should be + formatted in little endian order. The following macros allow one to translate multi-byte values from Host order to USB order and vice versa. There are separate macros for + in-kernel use and for user space use. + */ +#define USBToHostWord OSSwapLittleToHostInt16 +#define HostToUSBWord OSSwapHostToLittleInt16 +#define USBToHostLong OSSwapLittleToHostInt32 +#define HostToUSBLong OSSwapHostToLittleInt32 + + /*! + @enum Miscellaneous Constants + @discussion + */ + enum { + kUSBDeviceIDShift = 7, + kUSBMaxDevices = 128, + kUSBMaxDevice = kUSBMaxDevices-1, + kUSBDeviceIDMask = 0x7f, + + kUSBPipeIDMask = 0xf, + kUSBMaxPipes = 32, // In and Out pipes can have same pipe number. + + kUSBInterfaceIDShift = 8, + kUSBMaxInterfaces = 1 << kUSBInterfaceIDShift, + kUSBInterfaceIDMask = kUSBMaxInterfaces-1, + + kUSBEndPtShift = 7, + kUSBDeviceMask = ((1 << kUSBEndPtShift) -1), + + kUSBNoPipeIdx = -1 +}; + +/*! +@enum bRequest Shifts and Masks +@discussion These are used to create the macro to encode the bRequest filed of a Device Request +*/ +enum { + kUSBRqDirnShift = 7, + kUSBRqDirnMask = 1, + + kUSBRqTypeShift = 5, + kUSBRqTypeMask = 3, + + kUSBRqRecipientMask = 0X1F +}; + +/*! +@defined USBmakebmRequestType +@discussion Macro to encode the bRequest field of a Device Request. It is used when constructing an IOUSBDevRequest. +*/ +#define USBmakebmRequestType(direction, type, recipient) \ + ((direction & kUSBRqDirnMask) << kUSBRqDirnShift) | \ + ((type & kUSBRqTypeMask) << kUSBRqTypeShift) | \ + (recipient & kUSBRqRecipientMask) + +/*! +@enum kUSBMaxIsocFrameReqCount +@discussion Maximum size in bytes allowed for one Isochronous frame +*/ +enum { + kUSBMaxFSIsocEndpointReqCount = 1023, // max size (bytes) of any one Isoc frame for 1 FS endpoint + kUSBMaxHSIsocEndpointReqCount = 3072, // max size (bytes) of any one Isoc frame for 1 HS endpoint + kUSBMaxHSIsocFrameCount = 7168 // max size (bytes) of all Isoc transfers in a HS frame +}; + +/*! +@defined EncodeRequest +@discussion Macro that encodes the bRequest and bRequestType fields of a IOUSBDevRequest into a single value. It is useful when one needs +to know what type of request the IOUSBDevRequest encodes and simplifies comparisons. +*/ +#define EncodeRequest(request, direction, type, recipient) \ + (((UInt16)request << 8) + \ + ((UInt16)recipient + \ + ((UInt16)type << kUSBRqTypeShift) + \ + ((UInt16)direction << kUSBRqDirnShift))) + + +/*! +@enum Standard Device Requests +@discussion Encoding of the standard device requests. + +


+bmRequestType bRequest          wValue        wIndex     wLength Data
+00000000B     CLEAR_FEATURE     Feature       Zero       Zero    None (device)
+00000001B                       Feature       Interface  Zero    None (Interface)
+00000010B                       Feature       Endpoint   Zero    None (Endpoint)
+
+10000000B     GET_CONFIGURATION Zero          Zero       One     Configuration
+10000000B     GET_DESCRIPTOR    Type          LangID     Length  Descriptor
+10000001B     GET_INTERFACE     Zero          Interface  One     Alternate
+
+10000000B     GET_STATUS        Zero          Zero       Two     status (device)
+10000001B                       Zero          Interface  Two     status (Interface)
+10000010B                       Zero          Endpoint   Two     status (Endpoint)
+
+00000000B     SET_ADDRESS       Address       Zero       Zero    None
+00000000B     SET_CONFIGURATION Configuration Zero       Zero    None
+00000000B     SET_DESCRIPTOR    Type          LangID     Length  Descriptor
+
+00000000B     SET_FEATURE       Feature       Zero       Zero    None (device)
+00000001B                       Feature       Interface  Zero    None (Interface)
+00000010B                       Feature       Endpoint   Zero    None (Endpoint)
+
+00000001B     SET_INTERFACE     Alternate     Interface  Zero    None
+10000010B     SYNCH_FRAME       Zero          Endpoint   Two     Frame Number
+
+ +*/ +enum { + kClearDeviceFeature = EncodeRequest(kUSBRqClearFeature, kUSBOut, kUSBStandard, kUSBDevice), + kClearInterfaceFeature = EncodeRequest(kUSBRqClearFeature, kUSBOut, kUSBStandard, kUSBInterface), + kClearEndpointFeature = EncodeRequest(kUSBRqClearFeature, kUSBOut, kUSBStandard, kUSBEndpoint), + kGetConfiguration = EncodeRequest(kUSBRqGetConfig, kUSBIn, kUSBStandard, kUSBDevice), + kGetDescriptor = EncodeRequest(kUSBRqGetDescriptor, kUSBIn, kUSBStandard, kUSBDevice), + kGetInterface = EncodeRequest(kUSBRqGetInterface, kUSBIn, kUSBStandard, kUSBInterface), + kGetDeviceStatus = EncodeRequest(kUSBRqGetStatus, kUSBIn, kUSBStandard, kUSBDevice), + kGetInterfaceStatus = EncodeRequest(kUSBRqGetStatus, kUSBIn, kUSBStandard, kUSBInterface), + kGetEndpointStatus = EncodeRequest(kUSBRqGetStatus, kUSBIn, kUSBStandard, kUSBEndpoint), + kSetAddress = EncodeRequest(kUSBRqSetAddress, kUSBOut, kUSBStandard, kUSBDevice), + kSetConfiguration = EncodeRequest(kUSBRqSetConfig, kUSBOut, kUSBStandard, kUSBDevice), + kSetDescriptor = EncodeRequest(kUSBRqSetDescriptor, kUSBOut, kUSBStandard, kUSBDevice), + kSetDeviceFeature = EncodeRequest(kUSBRqSetFeature, kUSBOut, kUSBStandard, kUSBDevice), + kSetInterfaceFeature = EncodeRequest(kUSBRqSetFeature, kUSBOut, kUSBStandard, kUSBInterface), + kSetEndpointFeature = EncodeRequest(kUSBRqSetFeature, kUSBOut, kUSBStandard, kUSBEndpoint), + kSetInterface = EncodeRequest(kUSBRqSetInterface, kUSBOut, kUSBStandard, kUSBInterface), + kSyncFrame = EncodeRequest(kUSBRqSyncFrame, kUSBIn, kUSBStandard, kUSBEndpoint), +}; + +/*! +@defined kCallInterfaceOpenWithGate + @discussion If the USB Device has this property, drivers for any of its interfaces will have their handleOpen method called while holding the workloop gate. + */ +#define kCallInterfaceOpenWithGate "kCallInterfaceOpenWithGate" + +// TYPES + +typedef UInt16 USBDeviceAddress; + +typedef uint32_t USBPhysicalAddress32; + +/*! + @typedef IOUSBIsocFrame + @discussion Structure used to encode information about each isoc frame. + @param frStatus Returns status associated with the frame. + @param frReqCount Input specifiying how many bytes to read or write. + @param frActCount Actual # of bytes transferred. +*/ +typedef struct IOUSBIsocFrame { + IOReturn frStatus; + UInt16 frReqCount; + UInt16 frActCount; +} IOUSBIsocFrame; + + +/*! + @typedef IOUSBLowLatencyIsocFrame + @discussion Structure used to encode information about each isoc frame that is processed + at hardware interrupt time (low latency). + @param frStatus Returns status associated with the frame. + @param frReqCount Input specifiying how many bytes to read or write. + @param frActCount Actual # of bytes transferred. + @param frTimeStamp Time stamp that indicates time when frame was procesed. +*/ +struct IOUSBLowLatencyIsocFrame { + IOReturn frStatus; + UInt16 frReqCount; + UInt16 frActCount; + AbsoluteTime frTimeStamp; +}; +typedef struct IOUSBLowLatencyIsocFrame IOUSBLowLatencyIsocFrame; + +/*! +@typedef IOUSBCompletionAction + @discussion Function called when USB I/O completes. + @param target The target specified in the IOUSBCompletion struct. + @param parameter The parameter specified in the IOUSBCompletion struct. + @param status Completion status. + @param bufferSizeRemaining Bytes left to be transferred. + */ +typedef void (*IOUSBCompletionAction)( + void * target, + void * parameter, + IOReturn status, + UInt32 bufferSizeRemaining); + +/*! +@typedef IOUSBCompletionActionWithTimeStamp + @discussion Function called when USB I/O completes. + @param target The target specified in the IOUSBCompletion struct. + @param parameter The parameter specified in the IOUSBCompletion struct. + @param status Completion status. + @param bufferSizeRemaining Bytes left to be transferred. + @param timeStamp Time at which the transaction was processed. + */ +typedef void (*IOUSBCompletionActionWithTimeStamp)( + void * target, + void * parameter, + IOReturn status, + UInt32 bufferSizeRemaining, + AbsoluteTime timeStamp); + +/*! + @typedef IOUSBIsocCompletionAction + @discussion Function called when Isochronous USB I/O completes. + @param target The target specified in the IOUSBIsocCompletionn struct. + @param parameter The parameter specified in the IOUSBIsocCompletion struct. + @param status Completion status. + @param pFrames Pointer to the frame list containing the status for each frame transferred. +*/ +typedef void (*IOUSBIsocCompletionAction)( + void * target, + void * parameter, + IOReturn status, + IOUSBIsocFrame *pFrames); + +/*! + @typedef IOUSBLowLatencyIsocCompletionAction + @discussion Function called when Low Latency Isochronous USB I/O completes. + @param target The target specified in the IOUSBLowLatencyIsocCompletion struct. + @param parameter The parameter specified in the IOUSBLowLatencyIsocCompletion struct. + @param status Completion status. + @param pFrames Pointer to the low latency frame list containing the status for each frame transferred. +*/ +typedef void (*IOUSBLowLatencyIsocCompletionAction)( + void * target, + void * parameter, + IOReturn status, + IOUSBLowLatencyIsocFrame *pFrames); + +/*! +@typedef IOUSBCompletion + @discussion Struct specifying action to perform when a USB I/O completes. + @param target The target to pass to the action function. + @param action The function to call. + @param parameter The parameter to pass to the action function. + */ +typedef struct IOUSBCompletion { + void * target; + IOUSBCompletionAction action; + void * parameter; +} IOUSBCompletion; + +/*! +@typedef IOUSBCompletionWithTimeStamp + @discussion Struct specifying action to perform when a USB I/O completes. + @param target The target to pass to the action function. + @param action The function to call. + @param parameter The parameter to pass to the action function. + */ +typedef struct IOUSBCompletionWithTimeStamp { + void * target; + IOUSBCompletionActionWithTimeStamp action; + void * parameter; +} IOUSBCompletionWithTimeStamp; + +/*! + @typedef IOUSBIsocCompletion + @discussion Struct specifying action to perform when an Isochronous USB I/O completes. + @param target The target to pass to the action function. + @param action The function to call. + @param parameter The parameter to pass to the action function. +*/ +typedef struct IOUSBIsocCompletion { + void * target; + IOUSBIsocCompletionAction action; + void * parameter; +} IOUSBIsocCompletion; + +/*! + @typedef IOUSBLowLatencyIsocCompletion + @discussion Struct specifying action to perform when an Low Latency Isochronous USB I/O completes. + @param target The target to pass to the action function. + @param action The function to call. + @param parameter The parameter to pass to the action function. +*/ +typedef struct IOUSBLowLatencyIsocCompletion { + void * target; + IOUSBLowLatencyIsocCompletionAction action; + void * parameter; +} IOUSBLowLatencyIsocCompletion; + + +/*! +@defined IOUSBFamily error codes +@discussion Errors specific to the IOUSBFamily. Note that the iokit_usb_err(x) translates to 0xe0004xxx, where xxx is the value in parenthesis as a hex number. +*/ +#define iokit_usb_err(return) (sys_iokit|sub_iokit_usb|return) +#define kIOUSBUnknownPipeErr iokit_usb_err(0x61) // 0xe0004061 Pipe ref not recognized +#define kIOUSBTooManyPipesErr iokit_usb_err(0x60) // 0xe0004060 Too many pipes +#define kIOUSBNoAsyncPortErr iokit_usb_err(0x5f) // 0xe000405f no async port +#define kIOUSBNotEnoughPipesErr iokit_usb_err(0x5e) // 0xe000405e not enough pipes in interface +#define kIOUSBNotEnoughPowerErr iokit_usb_err(0x5d) // 0xe000405d not enough power for selected configuration +#define kIOUSBEndpointNotFound iokit_usb_err(0x57) // 0xe0004057 Endpoint Not found +#define kIOUSBConfigNotFound iokit_usb_err(0x56) // 0xe0004056 Configuration Not found +#define kIOUSBTransactionTimeout iokit_usb_err(0x51) // 0xe0004051 Transaction timed out +#define kIOUSBTransactionReturned iokit_usb_err(0x50) // 0xe0004050 The transaction has been returned to the caller +#define kIOUSBPipeStalled iokit_usb_err(0x4f) // 0xe000404f Pipe has stalled, error needs to be cleared +#define kIOUSBInterfaceNotFound iokit_usb_err(0x4e) // 0xe000404e Interface ref not recognized +#define kIOUSBLowLatencyBufferNotPreviouslyAllocated iokit_usb_err(0x4d) // 0xe000404d Attempted to use user land low latency isoc calls w/out calling PrepareBuffer (on the data buffer) first +#define kIOUSBLowLatencyFrameListNotPreviouslyAllocated iokit_usb_err(0x4c) // 0xe000404c Attempted to use user land low latency isoc calls w/out calling PrepareBuffer (on the frame list) first +#define kIOUSBHighSpeedSplitError iokit_usb_err(0x4b) // 0xe000404b Error to hub on high speed bus trying to do split transaction +#define kIOUSBSyncRequestOnWLThread iokit_usb_err(0x4a) // 0xe000404a A synchronous USB request was made on the workloop thread (from a callback?). Only async requests are permitted in that case +#define kIOUSBDeviceNotHighSpeed iokit_usb_err(0x49) // 0xe0004049 The device is not a high speed device, so the EHCI driver returns an error +#define kIOUSBDevicePortWasNotSuspended iokit_usb_err(0x50) // 0xe0004050 Port was not suspended + +/*! +@defined IOUSBFamily hardware error codes +@discussion These errors are returned by the OHCI controller. The # in parenthesis (xx) corresponds to the OHCI Completion Code. +For the following Completion codes, we return a generic IOKit error instead of a USB specific error. + +
+Completion Code         Error Returned              Description
+9                       kIOReturnUnderrun           (Data Underrun) EP returned less data than max packet size
+8                       kIOReturnOverrun            (Data Overrun) Packet too large or more data than buffer
+5                       kIOReturnNotResponding      Device Not responding
+4                       kIOUSBPipeStalled           Endpoint returned a STALL PID
+
+
+*/ +#define kIOUSBLinkErr iokit_usb_err(0x10) // 0xe0004010 +#define kIOUSBNotSent2Err iokit_usb_err(0x0f) // 0xe000400f Transaction not sent +#define kIOUSBNotSent1Err iokit_usb_err(0x0e) // 0xe000400e Transaction not sent +#define kIOUSBBufferUnderrunErr iokit_usb_err(0x0d) // 0xe000400d Buffer Underrun (Host hardware failure on data out, PCI busy?) +#define kIOUSBBufferOverrunErr iokit_usb_err(0x0c) // 0xe000400c Buffer Overrun (Host hardware failure on data out, PCI busy?) +#define kIOUSBReserved2Err iokit_usb_err(0x0b) // 0xe000400b Reserved +#define kIOUSBReserved1Err iokit_usb_err(0x0a) // 0xe000400a Reserved +#define kIOUSBWrongPIDErr iokit_usb_err(0x07) // 0xe0004007 Pipe stall, Bad or wrong PID +#define kIOUSBPIDCheckErr iokit_usb_err(0x06) // 0xe0004006 Pipe stall, PID CRC error +#define kIOUSBDataToggleErr iokit_usb_err(0x03) // 0xe0004003 Pipe stall, Bad data toggle +#define kIOUSBBitstufErr iokit_usb_err(0x02) // 0xe0004002 Pipe stall, bitstuffing +#define kIOUSBCRCErr iokit_usb_err(0x01) // 0xe0004001 Pipe stall, bad CRC + +/*! +@defined IOUSBFamily message codes +@discussion Messages specific to the IOUSBFamily. Note that the iokit_usb_msg(x) translates to 0xe0004xxx, where xxx is the value in parenthesis as a hex number. +*/ +#define iokit_usb_msg(message) (UInt32)(sys_iokit|sub_iokit_usb|message) +#define kIOUSBMessageHubResetPort iokit_usb_msg(0x01) // 0xe0004001 Message sent to a hub to reset a particular port +#define kIOUSBMessageHubSuspendPort iokit_usb_msg(0x02) // 0xe0004002 Message sent to a hub to suspend a particular port +#define kIOUSBMessageHubResumePort iokit_usb_msg(0x03) // 0xe0004003 Message sent to a hub to resume a particular port +#define kIOUSBMessageHubIsDeviceConnected iokit_usb_msg(0x04) // 0xe0004004 Message sent to a hub to inquire whether a particular port has a device connected or not +#define kIOUSBMessageHubIsPortEnabled iokit_usb_msg(0x05) // 0xe0004005 Message sent to a hub to inquire whether a particular port is enabled or not +#define kIOUSBMessageHubReEnumeratePort iokit_usb_msg(0x06) // 0xe0004006 Message sent to a hub to reenumerate the device attached to a particular port +#define kIOUSBMessagePortHasBeenReset iokit_usb_msg(0x0a) // 0xe000400a Message sent to a device indicating that the port it is attached to has been reset +#define kIOUSBMessagePortHasBeenResumed iokit_usb_msg(0x0b) // 0xe000400b Message sent to a device indicating that the port it is attached to has been resumed +#define kIOUSBMessageHubPortClearTT iokit_usb_msg(0x0c) // 0xe000400c Message sent to a hub to clear the transaction translator +#define kIOUSBMessagePortHasBeenSuspended iokit_usb_msg(0x0d) // 0xe000400d Message sent to a device indicating that the port it is attached to has been suspended +#define kIOUSBMessageFromThirdParty iokit_usb_msg(0x0e) // 0xe000400e Message sent from a third party. Uses IOUSBThirdPartyParam to encode the sender's ID +#define kIOUSBMessagePortWasNotSuspended iokit_usb_msg(0x0f) // 0xe000400f Message indicating that the hub driver received a resume request for a port that was not suspended +#define kIOUSBMessageExpressCardCantWake iokit_usb_msg(0x10) // 0xe0004010 Message from a driver to a bus that an express card will disconnect on sleep and thus shouldn't wake +#define kIOUSBMessageCompositeDriverReconfigured iokit_usb_msg(0x11) // 0xe0004011 Message from the composite driver indicating that it has finished re-configuring the device after a reset +#define kIOUSBMessageHubSetPortRecoveryTime iokit_usb_msg(0x12) // 0xe0004012 Message sent to a hub to set the # of ms required when resuming a particular port +#define kIOUSBMessageOvercurrentCondition iokit_usb_msg(0x13) // 0xe0004013 Message sent to the clients of the device's hub parent, when a device causes an overcurrent condition. The message argument contains the locationID of the device +#define kIOUSBMessageNotEnoughPower iokit_usb_msg(0x14) // 0xe0004014 Message sent to the clients of the device's hub parent, when a device causes an low power notice to be displayed. The message argument contains the locationID of the device +#define kIOUSBMessageController iokit_usb_msg(0x15) // 0xe0004015 Generic message sent from controller user client to controllers +#define kIOUSBMessageRootHubWakeEvent iokit_usb_msg(0x16) // 0xe0004016 Message from the HC Wakeup code indicating that a Root Hub port has a wake event + +// Obsolete +// +struct IOUSBMouseData { + UInt16 buttons; + SInt16 XDelta; + SInt16 YDelta; +}; +typedef struct IOUSBMouseData IOUSBMouseData; +typedef IOUSBMouseData * IOUSBMouseDataPtr; + +// Obsolete +// +struct IOUSBKeyboardData { + UInt16 keycount; + UInt16 usbkeycode[32]; +}; +typedef struct IOUSBKeyboardData IOUSBKeyboardData; +typedef IOUSBKeyboardData * IOUSBKeyboardDataPtr; + +// Obsolete +// +union IOUSBHIDData { + IOUSBKeyboardData kbd; + IOUSBMouseData mouse; +}; +typedef union IOUSBHIDData IOUSBHIDData; +typedef IOUSBHIDData * IOUSBHIDDataPtr; + +/*! + @typedef IOUSBDeviceDescriptor + @discussion Descriptor for a USB Device. See the USB Specification at http://www.usb.org. +*/ +struct IOUSBDeviceDescriptor { + UInt8 bLength; + UInt8 bDescriptorType; + UInt16 bcdUSB; + UInt8 bDeviceClass; + UInt8 bDeviceSubClass; + UInt8 bDeviceProtocol; + UInt8 bMaxPacketSize0; + UInt16 idVendor; + UInt16 idProduct; + UInt16 bcdDevice; + UInt8 iManufacturer; + UInt8 iProduct; + UInt8 iSerialNumber; + UInt8 bNumConfigurations; +}; +typedef struct IOUSBDeviceDescriptor IOUSBDeviceDescriptor; +typedef IOUSBDeviceDescriptor * IOUSBDeviceDescriptorPtr; + +/*! + @typedef IOUSBDescriptorHeader + @discussion Standard header used for all USB descriptors. Used to read the length of a descriptor so that we can allocate storage for the whole descriptor later on. +*/ +struct IOUSBDescriptorHeader { + UInt8 bLength; + UInt8 bDescriptorType; +}; +typedef struct IOUSBDescriptorHeader IOUSBDescriptorHeader; +typedef IOUSBDescriptorHeader * IOUSBDescriptorHeaderPtr; + +/*! + @typedef IOUSBConfigurationDescriptor + @discussion Standard USB Configuration Descriptor. It is variable length, so this only specifies the known fields. We use the wTotalLength field to read the whole descriptor. + See the USB Specification at http://www.usb.org. +*/ +struct IOUSBConfigurationDescriptor { + UInt8 bLength; + UInt8 bDescriptorType; + UInt16 wTotalLength; + UInt8 bNumInterfaces; + UInt8 bConfigurationValue; + UInt8 iConfiguration; + UInt8 bmAttributes; + UInt8 MaxPower; +}; +typedef struct IOUSBConfigurationDescriptor IOUSBConfigurationDescriptor; +typedef IOUSBConfigurationDescriptor * IOUSBConfigurationDescriptorPtr; + +/*! + @typedef IOUSBConfigurationDescHeader + @discussion Header of a IOUSBConfigurationDescriptor. Used to get the total length of the descriptor. +*/ +struct IOUSBConfigurationDescHeader { + UInt8 bLength; + UInt8 bDescriptorType; + UInt16 wTotalLength; +}; +typedef struct IOUSBConfigurationDescHeader IOUSBConfigurationDescHeader; +typedef IOUSBConfigurationDescHeader * IOUSBConfigurationDescHeaderPtr; + +/*! + @typedef IOUSBInterfaceDescriptor + @discussion Descriptor for a USB Interface. See the USB Specification at http://www.usb.org. +*/ +struct IOUSBInterfaceDescriptor { + UInt8 bLength; + UInt8 bDescriptorType; + UInt8 bInterfaceNumber; + UInt8 bAlternateSetting; + UInt8 bNumEndpoints; + UInt8 bInterfaceClass; + UInt8 bInterfaceSubClass; + UInt8 bInterfaceProtocol; + UInt8 iInterface; +}; +typedef struct IOUSBInterfaceDescriptor IOUSBInterfaceDescriptor; +typedef IOUSBInterfaceDescriptor * IOUSBInterfaceDescriptorPtr; + +/*! + @typedef IOUSBEndpointDescriptor + @discussion Descriptor for a USB Endpoint. See the USB Specification at http://www.usb.org. +*/ +struct IOUSBEndpointDescriptor { + UInt8 bLength; + UInt8 bDescriptorType; + UInt8 bEndpointAddress; + UInt8 bmAttributes; + UInt16 wMaxPacketSize; + UInt8 bInterval; +}; +typedef struct IOUSBEndpointDescriptor IOUSBEndpointDescriptor; +typedef IOUSBEndpointDescriptor * IOUSBEndpointDescriptorPtr; + +enum{addPacketShift = 11}; // Bits for additional packets in maxPacketField. (Table 9-13) +#define mungeMaxPacketSize(w) ((w>1024)?(((w>>(addPacketShift))+1)*(w&((1<http://www.usb.org. (This structure + should have used the #pragma pack(1) compiler directive to get byte alignment. +*/ +struct IOUSBHIDDescriptor { + UInt8 descLen; + UInt8 descType; + UInt16 descVersNum; + UInt8 hidCountryCode; + UInt8 hidNumDescriptors; + UInt8 hidDescriptorType; + UInt8 hidDescriptorLengthLo; + UInt8 hidDescriptorLengthHi; +}; +typedef struct IOUSBHIDDescriptor IOUSBHIDDescriptor; +typedef IOUSBHIDDescriptor *IOUSBHIDDescriptorPtr; + +/*! + @typedef IOUSBHIDReportDesc + @discussion USB HID Report Descriptor header. See the USB HID Specification at http://www.usb.org. (This structure + should have used the #pragma pack(1) compiler directive to get byte alignment. +*/ +struct IOUSBHIDReportDesc { + UInt8 hidDescriptorType; + UInt8 hidDescriptorLengthLo; + UInt8 hidDescriptorLengthHi; +}; +typedef struct IOUSBHIDReportDesc IOUSBHIDReportDesc; +typedef IOUSBHIDReportDesc * IOUSBHIDReportDescPtr; + +/*! + @typedef IOUSBDeviceQualifierDescriptor + @discussion USB Device Qualifier Descriptor. See the USB Specification at http://www.usb.org. +*/ +#pragma pack(1) +struct IOUSBDeviceQualifierDescriptor +{ + UInt8 bLength; + UInt8 bDescriptorType; + UInt16 bcdUSB; + UInt8 bDeviceClass; + UInt8 bDeviceSubClass; + UInt8 bDeviceProtocol; + UInt8 bMaxPacketSize0; + UInt8 bNumConfigurations; + UInt8 bReserved; +}; +typedef struct IOUSBDeviceQualifierDescriptor IOUSBDeviceQualifierDescriptor; +typedef IOUSBDeviceQualifierDescriptor * IOUSBDeviceQualifierDescriptorPtr; +#pragma options align=reset + +/*! + @typedef IOUSBDFUDescriptor + @discussion USB Device Firmware Update Descriptor. See the USB Device Firmware Update Specification at http://www.usb.org. +*/ +#pragma pack(1) +struct IOUSBDFUDescriptor +{ + UInt8 bLength; + UInt8 bDescriptorType; + UInt8 bmAttributes; + UInt16 wDetachTimeout; + UInt16 wTransferSize; +}; +typedef struct IOUSBDFUDescriptor IOUSBDFUDescriptor; +typedef IOUSBDFUDescriptor * IOUSBDFUDescriptorPtr; + +#pragma options align=reset + +/*! +@typedef IOUSBInterfaceAssociationDescriptor + @discussion USB Inerface Association Descriptor. ECN to the USB 2.0 Spec. See the USB Specification at http://www.usb.org. + */ +#pragma pack(1) +struct IOUSBInterfaceAssociationDescriptor +{ + UInt8 bLength; + UInt8 bDescriptorType; + UInt8 bFirstInterface; + UInt8 bInterfaceCount; + UInt8 bFunctionClass; + UInt8 bFunctionSubClass; + UInt8 bFunctionProtocol; + UInt8 iFunction; +}; +typedef struct IOUSBInterfaceAssociationDescriptor IOUSBInterfaceAssociationDescriptor; +typedef IOUSBInterfaceAssociationDescriptor * IOUSBInterfaceAssociationDescriptorPtr; +#pragma options align=reset + +/*! + @typedef USBStatus + @discussion Type used to get a DeviceStatus as a single quantity. +*/ +typedef UInt16 USBStatus; +typedef USBStatus * USBStatusPtr; + +// These constants are obsolete +// +enum { + kIOUSBAnyClass = 0xFFFF, + kIOUSBAnySubClass = 0xFFFF, + kIOUSBAnyProtocol = 0xFFFF, + kIOUSBAnyVendor = 0xFFFF, + kIOUSBAnyProduct = 0xFFFF +}; + +// This structure are obsolete +// +typedef struct IOUSBMatch { + UInt16 usbClass; + UInt16 usbSubClass; + UInt16 usbProtocol; + UInt16 usbVendor; + UInt16 usbProduct; +} IOUSBMatch; + +/*! + @typedef IOUSBFindEndpointRequest + @discussion Struct used to find endpoints of an interface + type and direction are used to match endpoints, + type, direction, maxPacketSize and interval are updated + with the properties of the found endpoint. + @field type Type of endpoint: kUSBControl, kUSBIsoc, kUSBBulk, kUSBInterrupt, kUSBAnyType. If kUSBAnyType is specified, this field is treated as a don't care. + @field direction Direction of endpoint: kUSBOut, kUSBIn, kUSBAnyDirn. If kUSBAnyDirn is specified, this field is treated as a don't care. + @field maxPacketSize maximum packet size of endpoint. + @field interval Polling interval in mSec for endpoint. +*/ +typedef struct { + UInt8 type; + UInt8 direction; + UInt16 maxPacketSize; + UInt8 interval; +} IOUSBFindEndpointRequest; + +/*! + @struct IOUSBDevRequest + @discussion Parameter block for control requests, using a simple pointer + for the data to be transferred. + @field bmRequestType Request type: kUSBStandard, kUSBClass or kUSBVendor + @field bRequest Request code + @field wValue 16 bit parameter for request, host endianess + @field wIndex 16 bit parameter for request, host endianess + @field wLength Length of data part of request, 16 bits, host endianess + @field pData Pointer to data for request - data returned in bus endianess + @field wLenDone Set by standard completion routine to number of data bytes + actually transferred +*/ +typedef struct { + UInt8 bmRequestType; + UInt8 bRequest; + UInt16 wValue; + UInt16 wIndex; + UInt16 wLength; + void * pData; + UInt32 wLenDone; +} IOUSBDevRequest; +typedef IOUSBDevRequest * IOUSBDeviceRequestPtr; + +/*! + @struct IOUSBDevRequestTO + @discussion Parameter block for control requests with timeouts, using a simple pointer + for the data to be transferred. Same as a IOUSBDevRequest except for the two extra timeout fields. + @field bmRequestType Request type: kUSBStandard, kUSBClass or kUSBVendor + @field bRequest Request code + @field wValue 16 bit parameter for request, host endianess + @field wIndex 16 bit parameter for request, host endianess + @field wLength Length of data part of request, 16 bits, host endianess + @field pData Pointer to data for request - data returned in bus endianess + @field wLenDone Set by standard completion routine to number of data bytes + actually transferred + @field noDataTimeout Specifies a time value in milliseconds. Once the request is queued on the bus, if no data is transferred in this amount of time, the request will be aborted and returned. + @field completionTimeout Specifies a time value in milliseconds. Once the request is queued on the bus, if the entire request is not completed in this amount of time, the request will be aborted and returned +*/ +typedef struct { + UInt8 bmRequestType; + UInt8 bRequest; + UInt16 wValue; + UInt16 wIndex; + UInt16 wLength; + void * pData; + UInt32 wLenDone; + UInt32 noDataTimeout; + UInt32 completionTimeout; +} IOUSBDevRequestTO; + +/*! + @enum Default timeout values + @discussion default values used for data and completion timeouts. +*/ +enum +{ + kUSBDefaultControlNoDataTimeoutMS = 5000, + kUSBDefaultControlCompletionTimeoutMS = 0 +}; + +// Internal structure to pass parameters between IOUSBLib and UserClient +// +typedef struct +{ + UInt32 pipeRef; + void * buf; + UInt32 size; + UInt32 noDataTimeout; + UInt32 completionTimeout; +} IOUSBBulkPipeReq; + + +#if KERNEL +/*! + @struct IOUSBDevRequestDesc + @discussion Parameter block for control requests, using a memory descriptor + for the data to be transferred. Only available in the kernel. + @field bmRequestType Request type: kUSBStandard, kUSBClass or kUSBVendor + @field bRequest Request code + @field wValue 16 bit parameter for request, host endianess + @field wIndex 16 bit parameter for request, host endianess + @field wLength Length of data part of request, 16 bits, host endianess + @field pData Pointer to memory descriptor for data for request - data returned in bus endianess + @field wLenDone Set by standard completion routine to number of data bytes + actually transferred +*/ +typedef struct { + UInt8 bmRequestType; + UInt8 bRequest; + UInt16 wValue; + UInt16 wIndex; + UInt16 wLength; + IOMemoryDescriptor * pData; + UInt32 wLenDone; +} IOUSBDevRequestDesc; + + +/*! + @enum IOOptionBits + @discussion Parameter passed to an IOService::open() call. + @constant kIOUSBInterfaceOpenAlt Open the alternate interface specified when creating the interface. +*/ +enum { + kIOUSBInterfaceOpenAlt = 0x00010000 +}; + +#endif + +// Internal structure to pass parameters between IOUSBLib and UserClient +// +// use a structure because there's a limit of 6 total arguments +// to a user client method. +typedef struct { + UInt8 bmRequestType; + UInt8 bRequest; + UInt16 wValue; + UInt16 wIndex; + UInt16 wLength; + void * pData; // data pointer + UInt32 wLenDone; // # bytes transferred + UInt8 pipeRef; +} IOUSBDevReqOOL; + +// Internal structure to pass parameters between IOUSBLib and UserClient +// +typedef struct { + UInt8 bmRequestType; + UInt8 bRequest; + UInt16 wValue; + UInt16 wIndex; + UInt16 wLength; + void * pData; // data pointer + UInt32 wLenDone; // # bytes transferred + UInt8 pipeRef; + UInt32 noDataTimeout; + UInt32 completionTimeout; +} IOUSBDevReqOOLTO; + +// Internal structure to pass parameters between IOUSBLib and UserClient +// +// Structure to request isochronous transfer +// +typedef struct { + UInt32 fPipe; + void *fBuffer; + UInt32 fBufSize; + UInt64 fStartFrame; + UInt32 fNumFrames; + IOUSBIsocFrame *fFrameCounts; +} IOUSBIsocStruct; + +// Internal structure to pass parameters between IOUSBLib and UserClient +// +// Structure to request low latency isochronous transfer +// +struct IOUSBLowLatencyIsocStruct { + UInt32 fPipe; + UInt32 fBufSize; + UInt64 fStartFrame; + UInt32 fNumFrames; + UInt32 fUpdateFrequency; + UInt32 fDataBufferCookie; + UInt32 fDataBufferOffset; + UInt32 fFrameListBufferCookie; + UInt32 fFrameListBufferOffset; +}; + +typedef struct IOUSBLowLatencyIsocStruct IOUSBLowLatencyIsocStruct; + + +/*! + @struct IOUSBGetFrameStruct + @discussion Structure used from user space to return the frame number and a timestamp on when the frame register was read. + @field frame frame number + @field timeStamp AbsoluteTime when the frame was updated +*/ +typedef struct { + UInt64 frame; + AbsoluteTime timeStamp; +} IOUSBGetFrameStruct; + + +/*! + @struct IOUSBFindInterfaceRequest + @discussion Structure used with FindNextInterface. +*/ +typedef struct { + UInt16 bInterfaceClass; // requested class + UInt16 bInterfaceSubClass; // requested subclass + UInt16 bInterfaceProtocol; // requested protocol + UInt16 bAlternateSetting; // requested alt setting +} IOUSBFindInterfaceRequest; + +/*! + @enum kIOUSBFindInterfaceDontCare + @discussion Constant that can be used for the fields of IOUSBFindInterfaceRequest to specify that they should not be matched. +*/ +enum { + kIOUSBFindInterfaceDontCare = 0xFFFF + }; + +/*! + @enum kIOUSBVendorIDAppleComputer + @discussion USB Vendor ID for Apple Computer, Inc. +*/ +enum { + kIOUSBVendorIDAppleComputer = 0x05AC + }; + +/*! + @enum USBDeviceSpeed + @discussion Returns the speed of a particular USB device. + @constant kUSBDeviceSpeedLow The device a low speed device. + @constant kUSBDeviceSpeedFull The device a full speed device. + @constant kUSBDeviceSpeedHigh The device a high speed device. +*/ +enum { + kUSBDeviceSpeedLow = 0, + kUSBDeviceSpeedFull = 1, + kUSBDeviceSpeedHigh = 2 + }; + +/*! + @enum MicrosecondsInFrame + @discussion Returns the number of microseconds in a USB frame. + @constant kUSBFullSpeedMicrosecondsInFrame The device is attached to a bus running at full speed (1 ms / frame). + @constant kUSBHighSpeedMicrosecondsInFrame The device is attached to a bus running at high speed (125 microseconds / frame). +*/ +enum { + kUSBFullSpeedMicrosecondsInFrame = 1000, + kUSBHighSpeedMicrosecondsInFrame = 125 +}; + +// During low latency transfers, the stack will set the frStatus for each frame to this value. A client can check that to see if the transfer has completed. We set the frStatus to a +// valid return code when the transfer completes. +// +enum { + kUSBLowLatencyIsochTransferKey = 'llit' // Set frStatus field of first frame in isoch transfer to designate as low latency + }; + +// This structure is DEPRECATED. See the LowLatencyUserBufferInfoV2 +// +typedef struct LowLatencyUserBufferInfo LowLatencyUserBufferInfo; + +struct LowLatencyUserBufferInfo { + UInt32 cookie; + void * bufferAddress; + IOByteCount bufferSize; + UInt32 bufferType; + Boolean isPrepared; + LowLatencyUserBufferInfo * nextBuffer; +}; + +// This structure is DEPRECATED. See the LowLatencyUserBufferInfoV3 + +typedef struct LowLatencyUserBufferInfoV2 LowLatencyUserBufferInfoV2; + +struct LowLatencyUserBufferInfoV2 +{ + UInt32 cookie; + void * bufferAddress; + IOByteCount bufferSize; + UInt32 bufferType; + Boolean isPrepared; + void * mappedUHCIAddress; + LowLatencyUserBufferInfoV2 * nextBuffer; +}; + + +// This structure is used to pass information for the low latency calls between user space and the kernel. +// +typedef struct LowLatencyUserBufferInfoV3 LowLatencyUserBufferInfoV3; + +struct LowLatencyUserBufferInfoV3 +{ + uint64_t cookie; + mach_vm_address_t bufferAddress; + mach_vm_size_t bufferSize; + uint64_t bufferType; + uint64_t isPrepared; + mach_vm_address_t mappedUHCIAddress; + LowLatencyUserBufferInfoV3 * nextBuffer; +}; + + + /*! + @enum USBLowLatencyBufferType + @discussion Used to specify what kind of buffer to create when calling LowLatencyCreateBuffer(). + @constant kUSBLowLatencyWriteBuffer The buffer will be used to write data out to a device. + @constant kUSBLowLatencyReadBuffer The buffer will be used to read data from a device. + @constant kUSBLowLatencyFrameListBuffer The buffer will be used for a low latency isoch frame list. +*/ +typedef enum { + kUSBLowLatencyWriteBuffer = 0, + kUSBLowLatencyReadBuffer = 1, + kUSBLowLatencyFrameListBuffer = 2 +} USBLowLatencyBufferType; + +// USB User Notification Types +// +enum { + kUSBNoUserNotificationType = 0, + kUSBNotEnoughPowerNotificationType = 1, + kUSBIndividualOverCurrentNotificationType = 2, + kUSBGangOverCurrentNotificationType = 3 +}; + +/*! + @defined Property Definitions + @discussion Useful property names in USB land. +*/ +#define kUSBDevicePropertySpeed "Device Speed" +#define kUSBDevicePropertyBusPowerAvailable "Bus Power Available" +#define kUSBDevicePropertyAddress "USB Address" +#define kUSBDevicePropertyLocationID "locationID" +#define kUSBProductIDMask "idProductMask" +#define kUSBPreferredConfiguration "Preferred Configuration" +#define kUSBSuspendPort "kSuspendPort" +#define kUSBExpressCardCantWake "ExpressCardCantWake" +#define kUSBControllerNeedsContiguousMemoryForIsoch "Need contiguous memory for isoch" +#define kUSBHubDontAllowLowPower "kUSBHubDontAllowLowPower" +#define kUSBDeviceResumeRecoveryTime "kUSBDeviceResumeRecoveryTime" +#define kUSBOutOfSpecMPSOK "Out of spec MPS OK" +#define kConfigurationDescriptorOverride "ConfigurationDescriptorOverride" +#define kOverrideIfAtLocationID "OverrideIfAtLocationID" + +/*! +@enum USBReEnumerateOptions + @discussion Options used when calling ReEnumerateDevice. + @constant kUSBAddExtraResetTimeBit Setting this bit will cause the Hub driver to wait 100ms before addressing the device after the reset following the re-enumeration. + */ +typedef enum { + kUSBAddExtraResetTimeBit = 31, + kUSBAddExtraResetTimeMask = ( 1 << kUSBAddExtraResetTimeBit) +} USBReEnumerateOptions; + +/*! + @enum USBDeviceInformationBits + @discussion GetUSBDeviceInformation will return a unit32_t value with bits set indicating that a particular state is present in the USB device. These bits are described here + + @constant kUSBInformationDeviceIsCaptiveBit The USB device is directly attached to its hub and cannot be removed. + @constant kUSBInformationDeviceIsAttachedToRootHubBit The USB device is directly attached to the root hub + @constant kUSBInformationDeviceIsInternalBit The USB device is internal to the computer (all the hubs it attaches to are captive) + @constant kUSBInformationDeviceIsConnectedBit The USB device is connected to its hub + @constant kUSBInformationDeviceIsEnabledBit The hub port to which the USB device is attached is enabled + @constant kUSBInformationDeviceIsSuspendedBit The hub port to which the USB device is attached is suspended + @constant kUSBInformationDeviceIsInResetBit The hub port to which the USB device is attached is being reset + @constant kUSBInformationDeviceOvercurrentBit The USB device generated an overcurrent + @constant kUSBInformationDevicePortIsInTestModeBit The hub port to which the USB device is attached is in test mode + @constant kUSBInformationDeviceIsRootHub The device is actually the root hub simulation + @constant kUSBInformationRootHubisBuiltIn If this is a root hub simulation and it's built into the machine, this bit is set. If it's on an expansion card, it will be cleared + + */ + typedef enum { + kUSBInformationDeviceIsCaptiveBit = 0, + kUSBInformationDeviceIsAttachedToRootHubBit = 1, + kUSBInformationDeviceIsInternalBit = 2, + kUSBInformationDeviceIsConnectedBit = 3, + kUSBInformationDeviceIsEnabledBit = 4, + kUSBInformationDeviceIsSuspendedBit = 5, + kUSBInformationDeviceIsInResetBit = 6, + kUSBInformationDeviceOvercurrentBit = 7, + kUSBInformationDevicePortIsInTestModeBit = 8, + kUSBInformationDeviceIsRootHub = 9, + kUSBInformationRootHubisBuiltIn = 10, + kUSBInformationDeviceIsRemote = 11, + kUSBInformationDeviceIsCaptiveMask = (1 << kUSBInformationDeviceIsCaptiveBit), + kUSBInformationDeviceIsAttachedToRootHubMask = (1 << kUSBInformationDeviceIsAttachedToRootHubBit), + kUSBInformationDeviceIsInternalMask = (1 << kUSBInformationDeviceIsInternalBit), + kUSBInformationDeviceIsConnectedMask = (1 << kUSBInformationDeviceIsConnectedBit), + kUSBInformationDeviceIsEnabledMask = (1 << kUSBInformationDeviceIsEnabledBit), + kUSBInformationDeviceIsSuspendedMask = (1 << kUSBInformationDeviceIsSuspendedBit), + kUSBInformationDeviceIsInResetMask = (1 << kUSBInformationDeviceIsInResetBit), + kUSBInformationDeviceOvercurrentMask = (1 << kUSBInformationDeviceOvercurrentBit), + kUSBInformationDevicePortIsInTestModeMask = (1 << kUSBInformationDevicePortIsInTestModeBit), + kUSBInformationDeviceIsRootHubMask = (1 << kUSBInformationDeviceIsRootHub), + kUSBInformationRootHubisBuiltInMask = (1 << kUSBInformationRootHubisBuiltIn), + kUSBInformationDeviceIsRemoteMask = (1 << kUSBInformationDeviceIsRemote) + } USBDeviceInformationBits; + + /*! + @enum USBPowerRequestTypes + @discussion Used to specify what kind of power will be reserved using the IOUSBDevice RequestExtraPower and ReturnExtraPower APIs. + @constant kUSBPowerDuringSleep The power is to be used during sleep. + @constant kUSBPowerDuringWake The power is to be used while the system is awake (i.e not sleeping) + */ + typedef enum { + kUSBPowerDuringSleep = 0, + kUSBPowerDuringWake = 1 + } USBPowerRequestTypes; + + // Apple specific properties +#define kAppleCurrentAvailable "AAPL,current-available" +#define kAppleCurrentInSleep "AAPL,current-in-sleep" +#define kAppleCurrentExtra "AAPL,current-extra" +#define kAppleInternalUSBDevice "AAPL,device-internal" +#define kUSBBusID "AAPL,bus-id" + + +#ifdef __cplusplus +} +#endif + +#endif /* _USB_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBBus.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBBus.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBBus.h (revision 885) @@ -0,0 +1,35 @@ +/* + * Copyright (c) 1998-2006 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_IOUSBBUS_H +#define _IOKIT_IOUSBBUS_H + +#include + +class IOUSBBus : public IOService +{ + OSDeclareAbstractStructors(IOUSBBus) +}; + +#endif /* ! _IOKIT_IOUSBBUS_H */ + Index: branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBControllerListElement.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBControllerListElement.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBControllerListElement.h (revision 885) @@ -0,0 +1,126 @@ +/* + * + * @APPLE_LICENSE_HEADER_START@ + * + * Copyright (c) 1998-2007 Apple 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 _IOUSBCONTROLLERLISTELEMENT_H +#define _IOUSBCONTROLLERLISTELEMENT_H + + +#include + +#include + +#include + + +/*! + @class IOUSBControllerListElement + @abstract Used by the IOUSBController to manage the USB controller lists that are common between EHCI and UHCI. + */ +class IOUSBControllerListElement : public OSObject +{ + OSDeclareDefaultStructors(IOUSBControllerListElement) + +private: + +public: + + virtual void SetPhysicalLink(IOPhysicalAddress next) = 0; + virtual IOPhysicalAddress GetPhysicalLink(void) = 0; + virtual IOPhysicalAddress GetPhysicalAddrWithType(void) = 0; + virtual void print(int level); + + IOPhysicalAddress _sharedPhysical; // phys address of the memory shared with the controller + void * _sharedLogical; // logical address of the above + IOUSBControllerListElement *_logicalNext; // the next element in the list + +}; + + +class IOUSBControllerV2; // needed for a parameter +class IOUSBControllerIsochEndpoint; + +class IOUSBControllerIsochListElement : public IOUSBControllerListElement +{ + OSDeclareDefaultStructors(IOUSBControllerIsochListElement) + +private: + +public: + + virtual void SetPhysicalLink(IOPhysicalAddress next) = 0; + virtual IOPhysicalAddress GetPhysicalLink(void) = 0; + virtual IOPhysicalAddress GetPhysicalAddrWithType(void) = 0; + virtual void print(int level); + + IOUSBControllerIsochEndpoint *_pEndpoint; + IOUSBIsocFrame *_pFrames; + IOUSBIsocCompletion _completion; + Boolean _lowLatency; + bool _requestFromRosettaClient; // True if the request originated from a Rosetta client in user space + UInt8 _framesInTD; // used for HS Isoch only + UInt64 _frameNumber; // frame number for scheduling purposes + UInt32 _frameIndex; // index into the myFrames array + IOUSBControllerIsochListElement *_doneQueueLink; // linkage used by done queue processing + + // pure virtual methods which must be implemented by descendants + virtual IOReturn UpdateFrameList(AbsoluteTime timeStamp) = 0; + virtual IOReturn Deallocate(IOUSBControllerV2 *uim) = 0; +}; + +class IOUSBControllerIsochEndpoint : public OSObject +{ + OSDeclareDefaultStructors(IOUSBControllerIsochEndpoint) + +public: + + virtual bool init(); + + IOUSBControllerIsochEndpoint *nextEP; + IOUSBControllerIsochListElement *toDoList; // ITD or SITD + IOUSBControllerIsochListElement *toDoEnd; // ITD or SITD + IOUSBControllerIsochListElement *doneQueue; // ITD or SITD + IOUSBControllerIsochListElement *doneEnd; // ITD or SITD + IOUSBControllerIsochListElement *deferredQueue; // ITD or SITD + IOUSBControllerIsochListElement *deferredEnd; // ITD or SITD + UInt64 firstAvailableFrame; // next frame available for a transfer on this EP + UInt32 maxPacketSize; + UInt32 activeTDs; // + when added to todo list, - when taken from done queue + UInt32 onToDoList; // + when added to todo list, - when taken from done queue + UInt32 onDoneQueue; // + when added to todo list, - when taken from done queue + volatile SInt32 scheduledTDs; // + when linked onto periodic list, - when unlinked + UInt32 deferredTDs; + UInt32 onProducerQ; + UInt32 onReversedList; + UInt16 inSlot; // where Isoc TDs are being put in the periodic list + short functionAddress; + short endpointNumber; + IOReturn accumulatedStatus; + UInt32 interval; // this is the decoded interval value for HS endpoints and is 1 for FS endpoints + UInt8 direction; + bool aborting; +}; + + +#endif + Index: branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBControllerV2.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBControllerV2.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBControllerV2.h (revision 885) @@ -0,0 +1,374 @@ +/* + * Copyright (c) 1998-2006 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.2 (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, 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_IOUSBCONTROLLERV2_H +#define _IOKIT_IOUSBCONTROLLERV2_H + +#include + +#include +#include + +enum +{ + kUSBHSHubCommandAddHub = 1, + kUSBHSHubCommandRemoveHub = 2, + + kUSBHSHubFlagsMultiTT = 1 +}; + + +/*! + @class IOUSBControllerV2 + @abstract subclass of the IOUSBController to provide support for high speed + devices and split transactions. + @discussion The IOUSBController class provide sufficient functionality to + work with full (12Mb/s) and low (1.5Mb/s) devices. IOUSBControllerV2 + introduces the support for high (480Mb/s) speed devices from the + USB 2.0 spec. In particular IOUSBControllerV2 indicates the high + speed hub a full or low speed device is attached to so that split + transactions can be directed to the hub at high speed to be forwarded + to the full or low speed device by the hub. + It also gives support for bulk endoints of greater than 256 bytes. +*/ + +class IOUSBControllerV2 : public IOUSBController +{ + OSDeclareAbstractStructors(IOUSBControllerV2) + +protected: + + // These for keeping track of high speed ancestor to allow controller to do splits. + // + UInt8 _highSpeedHub[128]; + UInt8 _highSpeedPort[128]; + + struct V2ExpansionData { + UInt8 _multiTT[128]; + IOUSBCommand *ClearTTCommand; + IOUSBControllerIsochEndpoint *_isochEPList; // linked list of active Isoch "endpoints" + IOUSBControllerIsochEndpoint *_freeIsochEPList; // linked list of freed Isoch EP data structures + thread_call_t _returnIsochDoneQueueThread; + }; + V2ExpansionData *_v2ExpansionData; + + // Super's expansion data + #define _freeUSBCommandPool _expansionData->freeUSBCommandPool + #define _freeUSBIsocCommandPool _expansionData->freeUSBIsocCommandPool + #define _watchdogUSBTimer _expansionData->watchdogUSBTimer + #define _controllerTerminating _expansionData->_terminating + #define _watchdogTimerActive _expansionData->_watchdogTimerActive + #define _busNumber _expansionData->_busNumber + #define _currentSizeOfCommandPool _expansionData->_currentSizeOfCommandPool + #define _currentSizeOfIsocCommandPool _expansionData->_currentSizeOfIsocCommandPool + #define _controllerSpeed _expansionData->_controllerSpeed + #define _activeIsochTransfers _expansionData->_activeIsochTransfers + + // this class's expansion data + #define _isochEPList _v2ExpansionData->_isochEPList + #define _freeIsochEPList _v2ExpansionData->_freeIsochEPList + #define _returnIsochDoneQueueThread _v2ExpansionData->_returnIsochDoneQueueThread + + virtual bool init( OSDictionary * propTable ); + virtual bool start( IOService * provider ); + virtual void free(); + + static IOReturn DoCreateEP(OSObject *owner, + void *arg0, void *arg1, + void *arg2, void *arg3); + + static void clearTTHandler( + OSObject * target, + void * parameter, + IOReturn status, + UInt32 bufferSizeRemaining ); + +public: + + /*! + @function openPipe + Open a pipe to the specified device endpoint + @param address Address of the device on the USB bus + @param speed of the device: kUSBDeviceSpeedLow, kUSBDeviceSpeedFull or kUSBDeviceSpeedHigh + @param endpoint description of endpoint to connect to + */ + virtual IOReturn OpenPipe( USBDeviceAddress address, + UInt8 speed, + Endpoint * endpoint ); + + /*! + @function CreateDevice + @abstract Create a new device as IOUSBController, making a note of the + high speed hub device ID and port number the full/low speed + device is attached to. + @param newDevice new device object to work with + @param deviceAddress USB device ID + @param maxPacketSize max packet size of endpoint zero + @param speed speed of the device kUSBDeviceSpeedLow, kUSBDeviceSpeedFull, kUSBDeviceSpeedHigh + @param powerAvailable power available to the device + @param hub USB ID of hub the device is immediatly attached to. (Not necessarily high speed) + @param port port number of port the device is attached to. +*/ + virtual IOReturn CreateDevice( IOUSBDevice *newDevice, + USBDeviceAddress deviceAddress, + UInt8 maxPacketSize, + UInt8 speed, + UInt32 powerAvailable, + USBDeviceAddress hub, + int port); + +/*! + @function ConfigureDeviceZero + @abstract configure pipe zero of device zero, as IOUSBController, but also keeping + note of high speed hub device is attached to. + @param maxPacketSize max packet size for the pipe + @param speed speed of the device kUSBDeviceSpeedLow, kUSBDeviceSpeedFull, kUSBDeviceSpeedHigh + @param hub USB ID of hub the device is immediatly attached to. (Not necessarily high speed) + @param port port number of port the device is attached to. +*/ + virtual IOReturn ConfigureDeviceZero(UInt8 maxPacketSize, UInt8 speed, USBDeviceAddress hub, int port); + +/*! + @function UIMCreateControlEndpoint + @abstract Create an endpoint in the controller to do control transactions. + @param functionNumber USB device ID of device + @param endpointNumber endpoint address of the endpoint in the device + @param maxPacketSize maximum packet size of this endpoint + @param speed speed of the device kUSBDeviceSpeedLow, kUSBDeviceSpeedFull, kUSBDeviceSpeedHigh + @param highSpeedHub If speed is not kUSBDeviceSpeedHigh, the address of the high speed hub to + address split transactions to. + @param highSpeedPort If speed is not kUSBDeviceSpeedHigh, the hub port to address split transactions to +*/ + virtual IOReturn UIMCreateControlEndpoint( + UInt8 functionNumber, + UInt8 endpointNumber, + UInt16 maxPacketSize, + UInt8 speed, + USBDeviceAddress highSpeedHub, + int highSpeedPort) = 0; + +/*! + @function UIMCreateBulkEndpoint + @abstract Create an endpoint in the controller to do bulk transactions. + @param functionNumber USB device ID of device + @param endpointNumber endpoint address of the endpoint in the device + @param direction Direction of data flow. kUSBIn or kUSBOut + @param maxPacketSize maximum packet size of this endpoint + @param speed speed of the device kUSBDeviceSpeedFull, kUSBDeviceSpeedHigh + @param highSpeedHub If speed is not kUSBDeviceSpeedHigh, the address of the high speed hub to + address split transactions to. + @param highSpeedPort If speed is not kUSBDeviceSpeedHigh, the hub port to address split transactions to +*/ + virtual IOReturn UIMCreateBulkEndpoint( + UInt8 functionNumber, + UInt8 endpointNumber, + UInt8 direction, + UInt8 speed, + UInt16 maxPacketSize, + USBDeviceAddress highSpeedHub, + int highSpeedPort) = 0; + +/*! + @function UIMCreateInterruptEndpoint + @abstract Create an endpoint in the controller to do interrupt transactions. + @param functionAddress USB device ID of device + @param endpointNumber endpoint address of the endpoint in the device + @param direction Direction of data flow. kUSBIn or kUSBOut + @param speed speed of the device kUSBDeviceSpeedLow, kUSBDeviceSpeedFull, kUSBDeviceSpeedHigh + @param maxPacketSize maximum packet size of this endpoint + @param pollingRate The maximum polling interval from the endpoint descriptor. + @param highSpeedHub If speed is not kUSBDeviceSpeedHigh, the address of the high speed hub to + address split transactions to. + @param highSpeedPort If speed is not kUSBDeviceSpeedHigh, the hub port to address split transactions to +*/ + virtual IOReturn UIMCreateInterruptEndpoint( + short functionAddress, + short endpointNumber, + UInt8 direction, + short speed, + UInt16 maxPacketSize, + short pollingRate, + USBDeviceAddress highSpeedHub, + int highSpeedPort) = 0; + +/*! + @function UIMCreateIsochEndpoint + @abstract Create an endpoint in the controller to do Isochronous transactions. + @param functionAddress USB device ID of device + @param endpointNumber endpoint address of the endpoint in the device + @param maxPacketSize maximum packet size of this endpoint + @param direction Specifies direction for the endpoint. kUSBIn or KUSBOut. + @param highSpeedHub If non zero, this is a full speed device, the address of the high speed hub to + address split transactions to. + @param highSpeedPort If highSpeedHub is non zero, the hub port to address split transactions to +*/ + virtual IOReturn UIMCreateIsochEndpoint( + short functionAddress, + short endpointNumber, + UInt32 maxPacketSize, + UInt8 direction, + USBDeviceAddress highSpeedHub, + int highSpeedPort) = 0; + + + static void ReturnIsochDoneQueueEntry(OSObject *target, thread_call_param_t endpointPtr); + + + OSMetaClassDeclareReservedUsed(IOUSBControllerV2, 0); + virtual IOReturn AddHSHub(USBDeviceAddress highSpeedHub, UInt32 flags); + + static IOReturn DOHSHubMaintenance(OSObject *owner, void *arg0, void *arg1, void *arg2, void *arg3); + + OSMetaClassDeclareReservedUsed(IOUSBControllerV2, 1); + virtual IOReturn UIMHubMaintenance(USBDeviceAddress highSpeedHub, UInt32 highSpeedPort, UInt32 command, UInt32 flags); + + OSMetaClassDeclareReservedUsed(IOUSBControllerV2, 2); + virtual IOReturn RemoveHSHub(USBDeviceAddress highSpeedHub); + + static IOReturn DOSetTestMode(OSObject *owner, void *arg0, void *arg1, void *arg2, void *arg3); + + OSMetaClassDeclareReservedUsed(IOUSBControllerV2, 3); + virtual IOReturn SetTestMode(UInt32 mode, UInt32 port); + + OSMetaClassDeclareReservedUsed(IOUSBControllerV2, 4); + virtual IOReturn UIMSetTestMode(UInt32 mode, UInt32 port); + + OSMetaClassDeclareReservedUsed(IOUSBControllerV2, 5); + virtual UInt64 GetMicroFrameNumber( void ); + + OSMetaClassDeclareReservedUsed(IOUSBControllerV2, 6); + virtual void ClearTT(USBDeviceAddress addr, UInt8 endpt, Boolean IN); + + OSMetaClassDeclareReservedUsed(IOUSBControllerV2, 7); + /*! + @function Read + Read from an interrupt or bulk endpoint + @param buffer place to put the transferred data + @param address Address of the device on the USB bus + @param endpoint description of endpoint + @param completion describes action to take when buffer has been filled + @param noDataTimeout number of milliseconds of no data movement before the request is aborted + @param completionTimeout number of milliseonds after the command is on the bus in which it must complete + @param reqCount number of bytes requested for the transfer (must not be greater than the length of the buffer) + */ + virtual IOReturn ReadV2( IOMemoryDescriptor * buffer, + USBDeviceAddress address, + Endpoint * endpoint, + IOUSBCompletionWithTimeStamp * completion, + UInt32 noDataTimeout, + UInt32 completionTimeout, + IOByteCount reqCount ); + + OSMetaClassDeclareReservedUsed(IOUSBControllerV2, 8); +/*! + @function UIMCreateIsochEndpoint + @abstract Create an endpoint in the controller to do Isochronous transactions. + @param functionAddress USB device ID of device + @param endpointNumber endpoint address of the endpoint in the device + @param maxPacketSize maximum packet size of this endpoint + @param direction Specifies direction for the endpoint. kUSBIn or KUSBOut. + @param highSpeedHub If non zero, this is a full speed device, the address of the high speed hub to + address split transactions to. + @param highSpeedPort If highSpeedHub is non zero, the hub port to address split transactions to + @param interval The encoded interval value from the endpoint descriptor +*/ + virtual IOReturn UIMCreateIsochEndpoint( short functionAddress, + short endpointNumber, + UInt32 maxPacketSize, + UInt8 direction, + USBDeviceAddress highSpeedHub, + int highSpeedPort, + UInt8 interval); + + + OSMetaClassDeclareReservedUsed(IOUSBControllerV2, 9); + virtual IOUSBControllerIsochEndpoint* AllocateIsochEP(void); + + OSMetaClassDeclareReservedUsed(IOUSBControllerV2, 10); + virtual IOReturn DeallocateIsochEP(IOUSBControllerIsochEndpoint *pEP); + + OSMetaClassDeclareReservedUsed(IOUSBControllerV2, 11); + virtual IOUSBControllerIsochEndpoint* FindIsochronousEndpoint(short functionNumber, short endpointNumber, short direction, IOUSBControllerIsochEndpoint* *pEDBack); + + OSMetaClassDeclareReservedUsed(IOUSBControllerV2, 12); + virtual IOUSBControllerIsochEndpoint* CreateIsochronousEndpoint(short functionNumber, short endpointNumber, short direction); + + OSMetaClassDeclareReservedUsed(IOUSBControllerV2, 13); + virtual void PutTDonToDoList(IOUSBControllerIsochEndpoint* pED, IOUSBControllerIsochListElement *pTD); + + OSMetaClassDeclareReservedUsed(IOUSBControllerV2, 14); + virtual IOUSBControllerIsochListElement *GetTDfromToDoList(IOUSBControllerIsochEndpoint* pED); + + OSMetaClassDeclareReservedUsed(IOUSBControllerV2, 15); + virtual void PutTDonDeferredQueue(IOUSBControllerIsochEndpoint* pED, IOUSBControllerIsochListElement *pTD); + + OSMetaClassDeclareReservedUsed(IOUSBControllerV2, 16); + virtual IOUSBControllerIsochListElement *GetTDfromDeferredQueue(IOUSBControllerIsochEndpoint* pED); + + OSMetaClassDeclareReservedUsed(IOUSBControllerV2, 17); + virtual void PutTDonDoneQueue(IOUSBControllerIsochEndpoint* pED, IOUSBControllerIsochListElement *pTD, bool checkDeferred); + + OSMetaClassDeclareReservedUsed(IOUSBControllerV2, 18); + virtual IOUSBControllerIsochListElement *GetTDfromDoneQueue(IOUSBControllerIsochEndpoint* pED); + + // 7185026 - this is to make this call from behind the gate + static IOReturn GatedGetTDfromDoneQueue(OSObject *target, void *arg0, void *arg1, void *arg2, void *arg3); + + OSMetaClassDeclareReservedUsed(IOUSBControllerV2, 19); + virtual void ReturnIsochDoneQueue(IOUSBControllerIsochEndpoint*); + + OSMetaClassDeclareReservedUsed(IOUSBControllerV2, 20); + virtual IODMACommand *GetNewDMACommand(); + + OSMetaClassDeclareReservedUsed(IOUSBControllerV2, 21); + /*! + @function GetLowLatencyOptionsAndPhysicalMask + @abstract Low Latency transfers require that the client have access to the memory after the Isochronous I/O request has already been scheduled. This might be used, for example to fill in outgoing data "just in time." Some controllers, however, may have requirements which need to be followed in order to make sure that the memory buffer isn't moved after the call is made. This call will return an IOOptionBits and mach_vm_address_t which can be used in a call to IOBufferMemoryDescriptor::inTaskWithPhysicalMask which will help meet these requirements. + @param optionBits Pointer to an an IOOptionBits. The only bit which may be returned is kIOMemoryPhysicallyContiguous. Other bits, e.g. direction bits, must be ORd in by the client as needed. This call replaces the old property based method of obtaining this information. + @param physicalMask Pointer to a mach_vm_address_t which should be used in the call to IOBufferMemoryDescriptor::inTaskWithPhysicalMask and will guarantee that when the memory is wired down it will be accessible by both the client and the USB controller at the same time. + @result returns kIOReturnSuccess if the method is implemented by the controller, otherwise kIOReturnUnsupported + */ + virtual IOReturn GetLowLatencyOptionsAndPhysicalMask(IOOptionBits *optionBits, mach_vm_address_t *physicalMask); + + OSMetaClassDeclareReservedUsed(IOUSBControllerV2, 22); + /*! + @function GetFrameNumberWithTime + @abstract Real Time A/V applications send and receive Iscohronous data scheduled on certain USB frame numbers. The clock for these frame numbers is independent of the system clock, and drivers need to synchronize these two clocks. This routine will return a system time which corresponds to the beginning of a USB frame number. It is not necessarily the currrent frame, but it will be a frame in the recent past (within the past minute). The jitter between the start of the USB frame and the system time will be as low as possible, but due to hardware interrupt latencies could be as high as 200 microseconds. + @param frameNumber A pointer to a UInt64 in which to hold the USB frame number corresponding to the given system time. + @param theTime A pointer to an AbsoluteTime corresponding to the system time at the beginning of the given USB frame number. + @result returns kIOReturnSuccess if the method is implemented by the controller, otherwise kIOReturnUnsupported + */ + virtual IOReturn GetFrameNumberWithTime(UInt64* frameNumber, AbsoluteTime *theTime); + + + OSMetaClassDeclareReservedUnused(IOUSBControllerV2, 23); + OSMetaClassDeclareReservedUnused(IOUSBControllerV2, 24); + OSMetaClassDeclareReservedUnused(IOUSBControllerV2, 25); + OSMetaClassDeclareReservedUnused(IOUSBControllerV2, 26); + OSMetaClassDeclareReservedUnused(IOUSBControllerV2, 27); + OSMetaClassDeclareReservedUnused(IOUSBControllerV2, 28); + OSMetaClassDeclareReservedUnused(IOUSBControllerV2, 29); + +}; + + +#endif /* ! _IOKIT_IOUSBCONTROLLERV2_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBControllerV3.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBControllerV3.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBControllerV3.h (revision 885) @@ -0,0 +1,233 @@ +/* +* Copyright (c) 2007-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.2 (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, 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_IOUSBCONTROLLERV3_H +#define _IOKIT_IOUSBCONTROLLERV3_H + +#include + +#include +#include + +// Constants that define the different power states in the setPowerState call +enum +{ + kUSBPowerStateOff = 0, // controller is reset, nothing is attached + kUSBPowerStateRestart = 1, // same as OFF + kUSBPowerStateSleep = 2, // controller is suspended, preparing to lose main power + kUSBPowerStateLowPower = 3, // controller is suspended, power remains on + kUSBPowerStateOn = 4, // up and running + kUSBNumberBusPowerStates = 5 +}; + +#define kUSBPowerStateStable -1 + +enum +{ + kUSBBusStateReset = 0, // bus is in RESET + kUSBBusStateSuspended = 1, // bus is in SUSPEND mode + kUSBBusStateRunning = 2 // bus is operational +}; + + +// Root Hub things +typedef struct IOUSBRootHubInterruptTransaction +{ + IOMemoryDescriptor * buf; + UInt32 bufLen; + IOUSBCompletion completion; +} IOUSBRootHubInterruptTransaction; + +enum +{ + kIOUSBMaxRootHubTransactions = 2 +}; + + + +/*! + @class IOUSBControllerV3 + @abstract subclass of the IOUSBControllerV2 to provide support for new USB Power Management techniques. + @discussion With Leopard, we are providing more information to USB Device Drivers in the IOPower + tree to allow for more efficient Power Management. This controller class encapulates many of the changes + needed for that, without disturbing third party subclasses of IOUSBController or IOUSBControllerV2 + */ + +class IOUSBControllerV3 : public IOUSBControllerV2 +{ + OSDeclareAbstractStructors(IOUSBControllerV3) + + protected: + // static variable shared by all instances + static uint32_t * _gHibernateState; + + + UInt8 _myBusState; // kUSBBusStateReset, kUSBBusStateSuspended, kUSBBusStateRunning + bool _wakingFromHibernation; // True while the Hibernation Wake thread is active + bool _needToAckPowerDown; // True while we are changing power state due to shutdown/restart + bool _onCardBus; // OBSOLETE + bool _controllerAvailable; // true if we can talk to the controller + SInt32 _powerStateChangingTo; // a power state that we are in the process of changing to, or -1 if we are stable + bool _poweringDown; // true is the controller is powering down because of a systemWillPowerDown message + bool _restarting; // true is the controller is restarting because of a systemWillPowerDown message + unsigned long _myPowerState; // my current state (since getPowerState doesn't always change in time) + IOUSBControllerV3 *_ehciController; // set if I am a companion controller + unsigned long _numPowerStates; // how many power states do I support (defaults to kUSBNumDefaultPowerStates) + IOPMPowerState *_myPowerStates; // my power state array (allocated on the fly) + IOPCIDevice *_device; // my PCI device + + // root hub support + IOTimerEventSource *_rootHubTimer; // timer which fires at the rate of the root hub interrupt endpoint + UInt8 _rootHubPollingRate; // Obsolete -- we need to have it be a uint32_t + UInt8 _rootHubNumPorts; // number of root hub ports - should be 15 or fewer! + UInt16 _rootHubStatusChangedBitmap; // support up to 15 ports for status changes + bool _rootHubTimerActive; // UNUSED + IOUSBRootHubInterruptTransaction _outstandingRHTrans[4]; // Transactions for the Root Hub. We need 2, one for the current transaction and one for the next. This is declared as 4 for binary compatibility + + struct V3ExpansionData { + uint32_t _rootHubPollingRate32; + bool _rootHubTransactionWasAborted; + }; + V3ExpansionData *_v3ExpansionData; + + // IOKit methods + virtual bool init( OSDictionary * propTable ); + virtual bool start( IOService * provider ); + virtual void stop( IOService * provider ); + virtual unsigned long maxCapabilityForDomainState ( IOPMPowerFlags domainState ); + virtual unsigned long initialPowerStateForDomainState ( IOPMPowerFlags domainState ); + virtual IOReturn powerStateWillChangeTo ( IOPMPowerFlags capabilities, unsigned long stateNumber, IOService* whatDevice); + virtual IOReturn setPowerState( unsigned long powerStateOrdinal, IOService* whatDevice ); + virtual IOReturn powerStateDidChangeTo ( IOPMPowerFlags capabilities, unsigned long stateNumber, IOService* whatDevice); + virtual void powerChangeDone ( unsigned long fromState); + virtual void systemWillShutdown( IOOptionBits specifier ); + virtual void free(void); + + // IOUSBController methods + // we override these to deal with methods attempting to go through the workloop while we are in sleep + virtual IOReturn AcquireDeviceZero( void ); + virtual void ReleaseDeviceZero( void ); + virtual IOReturn DeviceRequest(IOUSBDevRequest *request, IOUSBCompletion *completion, USBDeviceAddress address, UInt8 epNum, UInt32 noDataTimeout, UInt32 completionTimeout); + virtual IOReturn DeviceRequest(IOUSBDevRequestDesc *request, IOUSBCompletion *completion, USBDeviceAddress address, UInt8 epNum, UInt32 noDataTimeout, UInt32 completionTimeout); + virtual IOReturn ClosePipe(USBDeviceAddress address, Endpoint *endpoint); + virtual IOReturn AbortPipe(USBDeviceAddress address, Endpoint *endpoint); + virtual IOReturn ResetPipe(USBDeviceAddress address, Endpoint *endpoint); + virtual IOReturn ClearPipeStall(USBDeviceAddress address, Endpoint *endpoint); + virtual IOReturn Read(IOMemoryDescriptor *buffer, USBDeviceAddress address, Endpoint *endpoint, IOUSBCompletion *completion, UInt32 noDataTimeout, UInt32 completionTimeout, IOByteCount reqCount); + virtual IOReturn Write(IOMemoryDescriptor *buffer, USBDeviceAddress address, Endpoint *endpoint, IOUSBCompletion *completion, UInt32 noDataTimeout, UInt32 completionTimeout, IOByteCount reqCount); + virtual IOReturn IsocIO(IOMemoryDescriptor *buffer, UInt64 frameStart, UInt32 numFrames, IOUSBIsocFrame *frameList, USBDeviceAddress address, Endpoint *endpoint, IOUSBIsocCompletion *completion ); + virtual IOReturn IsocIO(IOMemoryDescriptor *buffer, UInt64 frameStart, UInt32 numFrames, IOUSBLowLatencyIsocFrame *frameList, USBDeviceAddress address, Endpoint *endpoint, IOUSBLowLatencyIsocCompletion *completion, UInt32 updateFrequency ); + + // IOUSBControllerV2 methods + // we override these to deal with methods attempting to go through the workloop while we are in sleep + virtual IOReturn OpenPipe(USBDeviceAddress address, UInt8 speed, Endpoint *endpoint); + virtual IOReturn AddHSHub(USBDeviceAddress highSpeedHub, UInt32 flags); + virtual IOReturn RemoveHSHub(USBDeviceAddress highSpeedHub); + virtual IOReturn SetTestMode(UInt32 mode, UInt32 port); + virtual IOReturn ReadV2(IOMemoryDescriptor *buffer, USBDeviceAddress address, Endpoint *endpoint, IOUSBCompletionWithTimeStamp *completion, UInt32 noDataTimeout, UInt32 completionTimeout, IOByteCount reqCount); + + // IOUSBControllerV3 methods + + // these are called through the workloop + static IOReturn DoEnableAddressEndpoints(OSObject *owner, void *arg0, void *arg1, void *arg2, void *arg3 ); + static IOReturn DoEnableAllEndpoints(OSObject *owner, void *arg0, void *arg1, void *arg2, void *arg3 ); + static IOReturn GatedPowerChange(OSObject *owner, void *arg0, void *arg1, void *arg2, void *arg3 ); + + // also on the workloop + static void RootHubTimerFired(OSObject *owner, IOTimerEventSource *sender); + + // subclassable methods + virtual IOReturn CheckForEHCIController(IOService *provider); + virtual IOReturn AllocatePowerStateArray(void); + virtual IOReturn InitForPM(void); + virtual IOReturn CheckPowerModeBeforeGatedCall(char *fromStr); + virtual IOReturn EnableAllEndpoints(bool enable); + virtual IOReturn EnableBusMastering(bool enable); + virtual IOReturn EnsureUsability(void); + virtual IOReturn CheckForRootHubChanges(void); + virtual IOReturn RootHubQueueInterruptRead(IOMemoryDescriptor *buf, UInt32 bufLen, IOUSBCompletion completion); + virtual IOReturn RootHubAbortInterruptRead(void); + virtual IOReturn RootHubStartTimer(UInt8 pollingRate); // Obsolete see RootHubStartTimer32 + virtual IOReturn RootHubStopTimer(void); + + // these methods have a default implementation using some of the virtual methods below + virtual void ControllerOff(void); + virtual void ControllerRestart(void); + virtual void ControllerSleep(void); + virtual void ControllerDoze(void); + virtual void ControllerOn(void); + + // these methods are pure virtual, and need to be implemented in the subclass driver + virtual IOReturn ResetControllerState(void) = 0; + virtual IOReturn RestartControllerFromReset(void) = 0; + virtual IOReturn SaveControllerStateForSleep(void) = 0; + virtual IOReturn RestoreControllerStateFromSleep(void) = 0; + virtual IOReturn DozeController(void) = 0; + virtual IOReturn WakeControllerFromDoze(void) = 0; + virtual IOReturn UIMEnableAddressEndpoints(USBDeviceAddress address, bool enable) = 0; + virtual IOReturn UIMEnableAllEndpoints(bool enable) = 0; + virtual IOReturn EnableInterruptsFromController(bool enable) = 0; + + public: + + // public methods + virtual IOReturn EnableAddressEndpoints(USBDeviceAddress address, bool enable); + virtual bool IsControllerAvailable(void); + virtual IOReturn HandlePowerChange(unsigned long powerStateOrdinal); + virtual UInt32 AllocateExtraRootHubPortPower(UInt32 extraPowerRequested); + virtual void ReturnExtraRootHubPortPower(UInt32 extraPowerReturned); + + OSMetaClassDeclareReservedUsed(IOUSBControllerV3, 0); + virtual IOReturn RootHubStartTimer32(uint32_t pollingRate); + + OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 1); + OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 2); + OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 3); + OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 4); + OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 5); + OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 6); + OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 7); + OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 8); + OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 9); + OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 10); + OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 11); + OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 12); + OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 13); + OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 14); + OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 15); + OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 16); + OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 17); + OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 18); + OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 19); + OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 20); + OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 21); + OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 22); + OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 23); + OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 24); + OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 25); + OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 26); + OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 27); + OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 28); + OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 29); +}; + +#endif // _IOKIT_IOUSBCONTROLLERV3_H \ No newline at end of file Index: branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBMassStorageUFISubclass.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBMassStorageUFISubclass.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBMassStorageUFISubclass.h (revision 885) @@ -0,0 +1,355 @@ +/* + * 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_IOUSBMASSSTORAGEUFISUBCLASS_H +#define _IOKIT_IOUSBMASSSTORAGEUFISUBCLASS_H + +// This class' header file +#include +#include + + +#pragma mark - +#pragma mark IOUSBMassStorageUFIDevice declaration + +class IOUSBMassStorageUFIDevice : public IOSCSIPrimaryCommandsDevice +{ + OSDeclareDefaultStructors(IOUSBMassStorageUFIDevice) + +private: + static void AsyncReadWriteComplete( SCSITaskIdentifier completedTask ); + +protected: + // Reserve space for future expansion. + struct IOUSBMassStorageUFIDeviceExpansionData + { + }; + IOUSBMassStorageUFIDeviceExpansionData *fIOUSBMassStorageUFIDeviceReserved; + + // ---- Medium Characteristics ---- + bool fMediumPresent; + + // The byte count of each physical block on the medium. + UInt32 fMediumBlockSize; + + // The total number of blocks of fMediumBlockSize on the medium. + UInt32 fMediumBlockCount; + + // Whether the installed medium is protected from writes + bool fMediumIsWriteProtected; + + // Polling thread variables + thread_call_t fPollingThread; + UInt32 fPollingMode; + enum + { + kPollingMode_Suspended = 0, + kPollingMode_NewMedia = 1, + kPollingMode_MediaRemoval = 2 + }; + + // ---- Methods for controlling the current state of device support ---- + virtual bool InitializeDeviceSupport( void ); + virtual void StartDeviceSupport ( void ); + virtual void SuspendDeviceSupport( void ); + virtual void ResumeDeviceSupport( void ); + virtual void StopDeviceSupport ( void ); + virtual void TerminateDeviceSupport( void ); + + // ---- Methods used for misc ---- + virtual bool ClearNotReadyStatus( void ); + virtual void CreateStorageServiceNub( void ); + virtual bool DetermineDeviceCharacteristics( void ); + + // ---- Methods used for controlling the polling thread ---- + virtual void ProcessPoll( void ); + virtual void EnablePolling( void ); + virtual void DisablePolling( void ); + + // ---- Main and support methods for polling for new Media ---- + virtual void PollForNewMedia( void ); + virtual bool DetermineMediaPresence( void ); + virtual bool DetermineMediumCapacity( + UInt64 * blockSize, + UInt64 * blockCount ); + virtual bool DetermineMediumWriteProtectState( void ); + + // ---- Main and support methods for polling for Media removal ---- + virtual void PollForMediaRemoval( void ); + + // ---- Methods used for power managment ---- + virtual UInt32 GetInitialPowerState ( void ); + virtual void InitializePowerManagement ( IOService * provider ); + virtual void HandlePowerChange ( void ); + virtual void HandleCheckPowerState ( void ); + virtual void TicklePowerManager ( void ); + virtual UInt32 GetNumberOfPowerStateTransitions ( void ); + + // ---- Methods used for handling medium characteristics ---- + virtual void SetMediumCharacteristics( + UInt32 blockSize, + UInt32 blockCount ); + + virtual void ResetMediumCharacteristics( void ); + + virtual IOReturn IssueRead( + IOMemoryDescriptor * buffer, + UInt64 startBlock, + UInt64 blockCount ); + + virtual IOReturn IssueRead( + IOMemoryDescriptor * buffer, + UInt64 startBlock, + UInt64 blockCount, + void * clientData ); + + + virtual IOReturn IssueWrite( + IOMemoryDescriptor * buffer, + UInt64 startBlock, + UInt64 blockCount ); + + virtual IOReturn IssueWrite( + IOMemoryDescriptor * buffer, + UInt64 startBlock, + UInt64 blockCount, + void * clientData ); + +public: + + static void sProcessPoll( void * pdtDriver, void * refCon ); + + // Interface to the UFI Storage Services Driver + // ---- Methods for controlling the device ---- + virtual IOReturn SyncReadWrite( + IOMemoryDescriptor * buffer, + UInt64 startBlock, + UInt64 blockCount, + UInt64 blockSize ); + + virtual IOReturn AsyncReadWrite( + IOMemoryDescriptor * buffer, + UInt64 startBlock, + UInt64 blockCount, + UInt64 blockSize, + void * clientData ); + + // ---- Methods for controlling medium state ---- + virtual IOReturn EjectTheMedium( void ); + + // ---- Methods for controlling media format ---- + virtual IOReturn FormatMedium( + UInt64 blockCount, + UInt64 blockSize ); + virtual UInt32 GetFormatCapacities( + UInt64 * capacities, + UInt32 capacitiesMaxCount ) const; + + // ---- Query methods to report device characteristics ---- + // Report the maximum number of blocks that the device can handle per + // read or write. A value of 0 (zero) indicates there is no limit aside + // from the size of the method's return parameter. + virtual UInt64 ReportDeviceMaxBlocksReadTransfer( void ); + virtual UInt64 ReportDeviceMaxBlocksWriteTransfer( void ); + + // ---- Query methods to report installed medium characteristics ---- + virtual UInt64 ReportMediumBlockSize( void ); + virtual UInt64 ReportMediumTotalBlockCount( void ); + virtual bool ReportMediumWriteProtection( void ); + + // Methods for getting device information strings + virtual char * GetVendorString( void ); + virtual char * GetProductString( void ); + virtual char * GetRevisionString( void ); + OSDictionary * GetProtocolCharacteristicsDictionary ( void ); + OSDictionary * GetDeviceCharacteristicsDictionary ( void ); + +protected: + // Utility methods used by all SCSI Command Set objects + + // isParameterValid methods are used to validate that the parameter passed into + // the command methods are of the correct value. + + // Validate Parameter used for 1 bit to 1 byte paramaters + bool IsParameterValid( + SCSICmdField1Byte param, + SCSICmdField1Byte mask ); + + // Validate Parameter used for 9 bit to 2 byte paramaters + bool IsParameterValid( + SCSICmdField2Byte param, + SCSICmdField2Byte mask ); + + // Validate Parameter used for 17 bit to 4 byte paramaters + bool IsParameterValid( + SCSICmdField4Byte param, + SCSICmdField4Byte mask ); + + // UFI Required Commands + virtual bool FORMAT_UNIT( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + IOByteCount defectListSize, + SCSICmdField1Byte TRACK_NUMBER, + SCSICmdField2Byte INTERLEAVE ); + + virtual bool INQUIRY( + SCSITaskIdentifier request, + IOMemoryDescriptor *dataBuffer, + SCSICmdField1Byte PAGE_OR_OPERATION_CODE, + SCSICmdField1Byte ALLOCATION_LENGTH ); + + virtual bool MODE_SELECT_10( + SCSITaskIdentifier request, + IOMemoryDescriptor *dataBuffer, + SCSICmdField1Bit PF, + SCSICmdField1Bit SP, + SCSICmdField2Byte PARAMETER_LIST_LENGTH ); + + virtual bool MODE_SENSE_10( + SCSITaskIdentifier request, + IOMemoryDescriptor *dataBuffer, + SCSICmdField1Bit DBD, + SCSICmdField2Bit PC, + SCSICmdField6Bit PAGE_CODE, + SCSICmdField2Byte PARAMETER_LIST_LENGTH ); + + virtual bool PREVENT_ALLOW_MEDIUM_REMOVAL( + SCSITaskIdentifier request, + SCSICmdField1Bit PREVENT ); + + virtual bool READ_10( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + UInt32 blockSize, + SCSICmdField1Bit DPO, + SCSICmdField1Bit FUA, + SCSICmdField1Bit RELADR, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField2Byte TRANSFER_LENGTH ); + + virtual bool READ_12( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + UInt32 blockSize, + SCSICmdField1Bit DPO, + SCSICmdField1Bit FUA, + SCSICmdField1Bit RELADR, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField4Byte TRANSFER_LENGTH ); + + virtual bool READ_CAPACITY( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Bit RELADR, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField1Bit PMI ); + + virtual bool READ_FORMAT_CAPACITIES( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField2Byte ALLOCATION_LENGTH ); + + virtual bool REQUEST_SENSE( + SCSITaskIdentifier request, + IOMemoryDescriptor *dataBuffer, + SCSICmdField1Byte ALLOCATION_LENGTH ); + + virtual bool REZERO_UNIT( + SCSITaskIdentifier request ); + + virtual bool SEEK( + SCSITaskIdentifier request, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS ); + + virtual bool SEND_DIAGNOSTICS( + SCSITaskIdentifier request, + SCSICmdField1Bit PF, + SCSICmdField1Bit SELF_TEST, + SCSICmdField1Bit DEF_OFL, + SCSICmdField1Bit UNIT_OFL ); + + virtual bool START_STOP_UNIT( + SCSITaskIdentifier request, + SCSICmdField1Bit IMMED, + SCSICmdField1Bit LOEJ, + SCSICmdField1Bit START ); + + virtual bool TEST_UNIT_READY( + SCSITaskIdentifier request ); + + virtual bool VERIFY( + SCSITaskIdentifier request, + SCSICmdField1Bit DPO, + SCSICmdField1Bit BYTCHK, + SCSICmdField1Bit RELADR, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField2Byte VERIFICATION_LENGTH ); + + virtual bool WRITE_10( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + UInt32 blockSize, + SCSICmdField1Bit DPO, + SCSICmdField1Bit FUA, + SCSICmdField1Bit RELADR, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField2Byte TRANSFER_LENGTH ); + + virtual bool WRITE_12( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + UInt32 blockSize, + SCSICmdField1Bit DPO, + SCSICmdField1Bit EBP, + SCSICmdField1Bit RELADR, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField4Byte TRANSFER_LENGTH ); + + virtual bool WRITE_AND_VERIFY( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + UInt32 blockSize, + SCSICmdField1Bit DPO, + SCSICmdField1Bit BYTCHK, + SCSICmdField1Bit RELADR, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField2Byte TRANSFER_LENGTH ); +}; + + +#pragma mark - +#pragma mark IOUSBMassStorageUFISubclass declaration + + +class IOUSBMassStorageUFISubclass : public IOUSBMassStorageClass +{ + OSDeclareDefaultStructors(IOUSBMassStorageUFISubclass) + +protected: + virtual bool BeginProvidedServices( void ); + virtual bool EndProvidedServices( void ); +}; + +#endif _IOKIT_IOUSBMASSSTORAGEUFISUBCLASS_H Index: branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBPipe.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBPipe.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBPipe.h (revision 885) @@ -0,0 +1,387 @@ +/* + * Copyright (c) 1998-2006 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.2 (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, 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_IOUSBPIPE_H +#define _IOKIT_IOUSBPIPE_H + +#include +#include + +#include +#include +#include + +class IOUSBInterface; + +/*! + @class IOUSBPipe + @abstract The object representing an open pipe for a device. +*/ +class IOUSBPipe : public OSObject +{ + friend class IOUSBInterface; + friend class IOUSBDevice; + + OSDeclareDefaultStructors(IOUSBPipe) + +protected: + + const IOUSBEndpointDescriptor * _descriptor; + IOUSBController::Endpoint _endpoint; // tidied up version of descriptor + IOUSBController * _controller; + USBDeviceAddress _address; + UInt8 _status; // was previously used for status. Now used to detect whether a property exists or not + + struct ExpansionData + { + IOReturn _correctStatus; + IOUSBDevice * _device; // Remember containing device for clearing TTs + UInt8 _speed; + IOUSBInterface * _interface; + bool _crossEndianCompatible; + UInt32 _locationID; + }; + ExpansionData * _expansionData; + + virtual void free(); + + IOReturn ClosePipe(void); + +public: + + virtual bool InitToEndpoint(const IOUSBEndpointDescriptor *endpoint, UInt8 speed, + USBDeviceAddress address, IOUSBController * controller); + + // The following 2 methods are obsolete + // + static IOUSBPipe *ToEndpoint(const IOUSBEndpointDescriptor *endpoint, UInt8 speed, + USBDeviceAddress address, IOUSBController * controller); + + static IOUSBPipe *ToEndpoint(const IOUSBEndpointDescriptor *endpoint, + IOUSBDevice * device, IOUSBController * controller); + + static IOUSBPipe *ToEndpoint(const IOUSBEndpointDescriptor *endpoint, + IOUSBDevice * device, IOUSBController * controller, IOUSBInterface *interface); + + // Controlling pipe state + /*! + @function GetStatus + This method does NOT work. Do not call it. See GetPipeStatus for the correct method. + GetStatus will always return 0. + */ + virtual UInt8 GetStatus(void); + /*! + @function Abort + This method causes all outstanding I/O on a pipe to complete with return code kIOReturnAborted. It clears the halted bit but does NOT clear the + toggle bit on the endpoint in the controller. If you wish to clear the toggle bit, see ClearPipeStall + */ + virtual IOReturn Abort(void); + /*! + @function Reset + This method is identical to ClearPipeStall(false). The use of that API is preferred. + */ + virtual IOReturn Reset(void); + /*! + @function ClearStall + This method is equivalent to ClearPipeStall(false). This method is available before version 1.9. + */ + virtual IOReturn ClearStall(void); + + // + // Transferring Data + // + + // deprecated + virtual IOReturn Read(IOMemoryDescriptor * buffer, + IOUSBCompletion * completion = 0, + IOByteCount * bytesRead = 0); + + // deprecated + virtual IOReturn Write(IOMemoryDescriptor * buffer, + IOUSBCompletion * completion = 0); + + // Transfer data over Isochronous pipes + /*! + @function Read + Read from an isochronous endpoint + @param buffer place to put the transferred data + @param frameStart USB frame number of the frame to start transfer + @param numFrames Number of frames to transfer + @param frameList Bytes to transfer and result for each frame + @param completion describes action to take when buffer has been filled + */ + virtual IOReturn Read(IOMemoryDescriptor * buffer, + UInt64 frameStart, UInt32 numFrames, IOUSBIsocFrame *frameList, + IOUSBIsocCompletion * completion = 0); + /*! + @function Write + Write to an isochronous endpoint + @param buffer place to get the transferred data + @param frameStart USB frame number of the frame to start transfer + @param numFrames Number of frames to transfer + @param frameList Bytes to transfer and result for each frame + @param completion describes action to take when buffer has been emptied + */ + virtual IOReturn Write(IOMemoryDescriptor * buffer, + UInt64 frameStart, UInt32 numFrames, IOUSBIsocFrame *frameList, + IOUSBIsocCompletion * completion = 0); + + // Do a control request over a Control pipe, using a memory descriptor + /*! + @function ControlRequest + Make a control request + There are two versions of this method, one uses a simple void * + to point to the data portion of the transfer, the other uses an + IOMemoryDescriptor to point to the data. + @param request parameter block for the control request + @param completion describes action to take when the request has been executed + */ + virtual IOReturn ControlRequest(IOUSBDevRequestDesc *request, + IOUSBCompletion *completion = 0); + + // Do a control request over a Control pipe, using a simple buffer + virtual IOReturn ControlRequest(IOUSBDevRequest *request, + IOUSBCompletion *completion = 0); + + /* + * Accessors + */ + /*! + @function GetEndpoint + returns a pointer to the Endpoint structure for the pipe. + */ + virtual const IOUSBController::Endpoint * GetEndpoint(); + /*! + @function GetEndpointDescriptor + returns the endpoint descriptor for the pipe. + */ + virtual const IOUSBEndpointDescriptor * GetEndpointDescriptor(); + /*! + @function GetDirection + returns the direction of the pipe:kUSBOut/kUSBIn for a bulk or interrupt pipe, + kUSBAnyDirn for a control pipe. + */ + virtual UInt8 GetDirection(); + /*! + @function GetType + returns the pipe type: kUSBControl, kUSBBulk or kUSBInterrupt. + */ + virtual UInt8 GetType(); + /*! + @function GetEndpointNumber + returns the endpoint number in the device that the pipe is connected to. + */ + virtual UInt8 GetEndpointNumber(); + virtual USBDeviceAddress GetAddress(); + virtual UInt16 GetMaxPacketSize(); + virtual UInt8 GetInterval(); + + // Transfer data over Bulk pipes with timeouts. + OSMetaClassDeclareReservedUsed(IOUSBPipe, 0); + + // deprecated + virtual IOReturn Read(IOMemoryDescriptor * buffer, + UInt32 noDataTimeout, + UInt32 completionTimeout, + IOUSBCompletion * completion = 0, + IOByteCount * bytesRead = 0); + + OSMetaClassDeclareReservedUsed(IOUSBPipe, 1); + + // deprecated + virtual IOReturn Write(IOMemoryDescriptor * buffer, + UInt32 noDataTimeout, + UInt32 completionTimeout, + IOUSBCompletion * completion = 0); + + OSMetaClassDeclareReservedUsed(IOUSBPipe, 2); + // Do a control request over a Control pipe, using a memory descriptor + /*! + @function ControlRequest + Make a control request. + There are two versions of this method, one uses a simple void * + to point to the data portion of the transfer, the other uses an + IOMemoryDescriptor to point to the data. + @param request parameter block for the control request + @param noDataTimeout Specifies an amount of time (in ms) after which the command will be aborted + if no data has been transferred on the bus. + @param completionTimeout Specifies an amount of time (in ms) after which the command will be aborted if the entire command has + not been completed. + @param completion describes action to take when the request has been executed + */ + virtual IOReturn ControlRequest(IOUSBDevRequestDesc *request, + UInt32 noDataTimeout, + UInt32 completionTimeout, + IOUSBCompletion *completion = 0); + + OSMetaClassDeclareReservedUsed(IOUSBPipe, 3); + // Do a control request over a Control pipe, using a simple buffer + virtual IOReturn ControlRequest(IOUSBDevRequest *request, + UInt32 noDataTimeout, + UInt32 completionTimeout, + IOUSBCompletion *completion = 0); + + OSMetaClassDeclareReservedUsed(IOUSBPipe, 4); + /*! + @function Read + Read from an interrupt or bulk endpoint + @param buffer place to put the transferred data + @param noDataTimeout number of milliseconds of no bus activity until transaction times out. Note that if a tranasction times out + the driver software may have to resynchronize the data toggle. See ClearPipeStall. + @param completionTimeout number of milliseconds from the time the transaction is placed on the bus until it times out + @param reqCount requested number of bytes to transfer. must be <= buffer->getLength() + @param completion describes action to take when buffer has been filled + @param bytesRead returns total bytes read for synchronous reads + */ + virtual IOReturn Read(IOMemoryDescriptor * buffer, + UInt32 noDataTimeout, + UInt32 completionTimeout, + IOByteCount reqCount, + IOUSBCompletion * completion = 0, + IOByteCount * bytesRead = 0); + + OSMetaClassDeclareReservedUsed(IOUSBPipe, 5); + /*! + @function Write + Write to an interrupt or bulk endpoint + @param buffer place to get the transferred data + @param noDataTimeout number of milliseconds of no bus activity until transaction times out. Note that if a tranasction times out + the driver software may have to resynchronize the data toggle. See ClearPipeStall. + @param completionTimeout number of milliseconds from the time the transaction is placed on the bus until it times out + @param reqCount requested number of bytes to transfer. must be <= buffer->getLength() + @param completion describes action to take when buffer has been emptied + */ + virtual IOReturn Write(IOMemoryDescriptor * buffer, + UInt32 noDataTimeout, + UInt32 completionTimeout, + IOByteCount reqCount, + IOUSBCompletion * completion = 0); + + OSMetaClassDeclareReservedUsed(IOUSBPipe, 6); + /*! + @function GetPipeStatus + Returns the status of the pipe (kIOUSBPipeStalled of the pipe is stalled, else kIOReturnSuccess) + */ + virtual IOReturn GetPipeStatus(void); + + OSMetaClassDeclareReservedUsed(IOUSBPipe, 7); + /*! + @function ClearPipeStall + AVAILABLE ONLY IN VERSION 1.9 AND ABOVE + This method causes all outstanding I/O on a pipe to complete with return code kIOUSBTransactionReturned. It also clears both the halted bit and the + toggle bit on the endpoint in the controller. The driver may need to reset the data toggle within the device to avoid losing any data. If the + device correctly handles the ClearFeature(ENDPOINT_HALT) device request, then this API will handle that by sending the correct request to the + device. + @param withDeviceRequest if true, a ClearFeature(ENDPOINT_HALT) is sent to the appropriate endpoint on the device after the transactions on the + controllers endpoint are returned and the toggle bit on the controllers endpoint is cleared. if this parameter is false, then this is equivalent + to the pre-1.9 API. This means that the endpoint on the controller is cleared, but no DeviceRequest is sent to the device's endpoint. + */ + virtual IOReturn ClearPipeStall(bool withDeviceRequest); + + OSMetaClassDeclareReservedUsed(IOUSBPipe, 8); + /*! + @function SetPipePolicy + AVAILABLE ONLY IN VERSION 1.9 AND ABOVE + This method allows a driver to change the maxPacketSize of an Isochronous pipe, or the polling interval for an interrupt pipe. There is a limited + amount of bandwidth on any single bus, and isochronous pipes tend to use much of this bandwidth. The driver may know, however, that there + will never be as much bandwidth used as is specified in the pipe's endpoint descriptor. Therefore, the driver may return some of this + bandwidth to the system by using this method. Additionally, if on an open of an IOUSBInterface any of the Isochronous pipes is unable to be + opened because of a lack of bandwidth, the pipe will be created with a bandwidth of zero, and the driver may get some of the limited bandwidth + remaining by using this call. + This method returns kIOReturnBadArgument if the pipe is a bulk on control pipe, or if the maxPacketSize parameter is larger than the amount specified + in the endpoint descriptor. It returns kIOReturnNoBandwidth if the bandwidth requested cannot be allocated. Otherwise it returns kIOReturnSuccess. + @param maxPacketSize specifies the maximum number of bytes to be used in any one millisecond frame by this pipe. The value must be less than or + equal to the maxPacketSize specified in the endpoint descriptor. + @param maxInterval not currently used. reserved for future expansion + + */ + virtual IOReturn SetPipePolicy(UInt16 maxPacketSize, UInt8 maxInterval); + + OSMetaClassDeclareReservedUsed(IOUSBPipe, 9); + + // Transfer data over Isochronous pipes and process the frame list at hardware interrupt time + /*! + @function Read + AVAILABLE ONLY IN VERSION 1.9.2 AND ABOVE + Read from an isochronous endpoint and process the IOUSBLowLatencyIsocFrame fields at + hardware interrupt time + @param buffer place to put the transferred data + @param frameStart USB frame number of the frame to start transfer + @param numFrames Number of frames to transfer + @param frameList Bytes to transfer, result, and time stamp for each frame + @param completion describes action to take when buffer has been filled + @param updateFrequency describes how often (in milliseconds) should the frame list be processed + */ + virtual IOReturn Read(IOMemoryDescriptor * buffer, + UInt64 frameStart, UInt32 numFrames, IOUSBLowLatencyIsocFrame *frameList, + IOUSBLowLatencyIsocCompletion * completion = 0, UInt32 updateFrequency = 0); + + OSMetaClassDeclareReservedUsed(IOUSBPipe, 10); + /*! + @function Write + AVAILABLE ONLY IN VERSION 1.9.2 AND ABOVE + Write to an isochronous endpoint + @param buffer place to get the data to transfer + @param frameStart USB frame number of the frame to start transfer + @param numFrames Number of frames to transfer + @param frameList Pointer to list of frames indicating bytes to transfer and result for each frame + @param completion describes action to take when buffer has been emptied + @param updateFrequency describes how often (in milliseconds) should the frame list be processed + */ + virtual IOReturn Write(IOMemoryDescriptor * buffer, + UInt64 frameStart, UInt32 numFrames, IOUSBLowLatencyIsocFrame *frameList, + IOUSBLowLatencyIsocCompletion * completion = 0, UInt32 updateFrequency = 0); + + OSMetaClassDeclareReservedUsed(IOUSBPipe, 11); + /*! + @function Read + Read from an interrupt or bulk endpoint + @param buffer place to put the transferred data + @param noDataTimeout number of milliseconds of no bus activity until transaction times out. Note that if a tranasction times out + the driver software may have to resynchronize the data toggle. See ClearPipeStall. + @param completionTimeout number of milliseconds from the time the transaction is placed on the bus until it times out + @param reqCount requested number of bytes to transfer. must be <= buffer->getLength() + @param completion describes action to take when buffer has been filled + @param bytesRead returns total bytes read for synchronous reads + */ + virtual IOReturn Read(IOMemoryDescriptor * buffer, + UInt32 noDataTimeout, + UInt32 completionTimeout, + IOByteCount reqCount, + IOUSBCompletionWithTimeStamp * completion = 0, + IOByteCount * bytesRead = 0); + + OSMetaClassDeclareReservedUsed(IOUSBPipe, 12); + virtual bool InitToEndpoint(const IOUSBEndpointDescriptor *endpoint, UInt8 speed, + USBDeviceAddress address, IOUSBController * controller, IOUSBDevice * device, IOUSBInterface * interface); + + OSMetaClassDeclareReservedUnused(IOUSBPipe, 13); + OSMetaClassDeclareReservedUnused(IOUSBPipe, 14); + OSMetaClassDeclareReservedUnused(IOUSBPipe, 15); + OSMetaClassDeclareReservedUnused(IOUSBPipe, 16); + OSMetaClassDeclareReservedUnused(IOUSBPipe, 17); + OSMetaClassDeclareReservedUnused(IOUSBPipe, 18); + OSMetaClassDeclareReservedUnused(IOUSBPipe, 19); + +}; + +#endif /* _IOKIT_IOUSBPIPE_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBHubDevice.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBHubDevice.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBHubDevice.h (revision 885) @@ -0,0 +1,247 @@ +/* + * Copyright (c) 2006 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 __OPEN_SOURCE__ +/* + * + * $Log: IOUSBHubDevice.h,v $ + * Revision 1.11 2009/09/12 03:42:16 rhoads + * merge in the changes for the 390.3.4b QL + * + * Revision 1.10.52.1 2009/09/10 18:50:52 nano + * Task: Extra Current support for Ibex Peak RMHs -- look for a property that tells us to ask our USB plane parent for the extra current. This will allow the RMH to pass on the request to it's parent. + * + * Revision 1.10 2009/05/07 19:43:09 nano + * Move our SnowLeopard branch to TOT + * + * Revision 1.6.102.3 2008/06/16 22:02:16 nano + * Bring in changes from Foxound 320.2.19 + * + + * Revision 1.6.102.2 2008/04/22 22:38:01 nano + * Bring in changes from Foxhound-320.2.9 + * + * Revision 1.8.62.2 2008/06/06 21:08:44 nano + * Enable dynamic allocation of power for M89, so we don't reserve it if there isn't a high power device attached + * + * Revision 1.8.62.1 2008/06/06 04:14:32 nano + * Fix SleepCurrent allocation so it will work with hub devices and root hub devices as well as consolidating it across all controllers + * + * Revision 1.8 2008/04/17 16:56:57 nano + * Bring in branches for rdar://5867990 & rdar://5768343 + * + * Revision 1.7.4.1 2008/04/17 15:54:07 nano + * Merged PR-5768343 into this branch and fixed a couple of issues + * + * Revision 1.7.2.1 2008/04/16 00:48:49 ferg + * Bug #: 5768343 + * Add support for hubs with high-power downstream port capability. This is + * controlled by the properties "AAPL,current-available" and "AAPL,current-extra". + * + * Revision 1.7 2008/04/14 16:08:38 nano + * Add new APIs for high power and for GetDeviceInformation. + * + * Revision 1.6.144.1 2008/04/11 22:25:44 nano + * Initial work on new user-client APIs and new IOUSBDevice APIs to return port state information and manage extra power requests, as well as groundwork for calling the policy maker directly from the IOUSBDevice + * + * Revision 1.6 2007/08/01 16:10:18 rhoads + * roll in extra power changes + * + * Revision 1.5.118.1 2007/07/27 16:49:10 rhoads + * merge the extra current stuff into Leopard, and add extra sleep current for self powered hubs + * + * Revision 1.5 2007/01/20 00:47:01 rhoads + * roll in Hub Policy Maker changes + * + * Revision 1.4 2006/12/22 23:05:46 rhoads + * roll in branches 4364835 and 4277683-2 + * + * Revision 1.3.20.3 2007/01/15 19:58:07 rhoads + * saving more changes + * + * Revision 1.3.20.2 2007/01/09 21:55:53 rhoads + * commit some stuff to try to fix a permissions issue + * + * Revision 1.3.20.1 2006/12/18 19:13:56 rhoads + * re-integrate the old branch into TOT + * + * Revision 1.3.12.4 2006/12/18 17:33:48 rhoads + * looking good except for sleep/wake + * + * Revision 1.3.12.3 2006/12/08 05:42:40 rhoads + * mostly working + * + * Revision 1.3.12.2 2006/11/14 22:37:06 rhoads + * more changes with the root hubs + * + * Revision 1.3.12.1 2006/11/07 16:55:52 rhoads + * change to get the IOUSBHubDevice nubs into the IOPower tree + * + * Revision 1.3 2006/10/06 04:42:02 rhoads + * roll in branches 4727961, 4758404, 4759810, 4760274, and 4762769 + * + * Revision 1.2.4.2 2006/10/04 23:01:24 rhoads + * better naming + * + * Revision 1.2.4.1 2006/10/04 16:03:57 rhoads + * better IOUSBHubDevice design + * + */ +#endif + + +#ifndef _IOKIT_IOUSBHUBDEVICE_H +#define _IOKIT_IOUSBHUBDEVICE_H + +#include // our superclass + +// forward refeference. we don't include the header file because it would cause a circular reference +class IOUSBHubPolicyMaker; + +enum { + kIOUSBHubDeviceIsRootHub = 0x0001, + kIOUSBHubDeviceIsOnHighSpeedBus = 0x0002, + kIOUSBHubDeviceCanSleep = 0x0004 +}; + +/*! + @class IOUSBHubDevice + @abstract New in MAC OS X 10.5. The IOKit object representing a hub device on the USB bus. It is a subclass of IOUSBDevice. + @discussion With the exception of the IOUSBRootHubDevice objects representing the root hubs, every IOUSBDevice + will have an IOUSBHubDevice as its parent in the IOUSB plane. USB KEXT drivers will have the ability to + query this device for characteristics of the hub into which they are connected. This class will also give a dive driver + the abilty to get an IOService* pointing to the hub driver itself, which can then be used as the parent in the power plane. +*/ + +class IOUSBHubDevice : public IOUSBDevice +{ + friend class IOUSBHubPolicyMaker; + friend class AppleUSBHub; + friend class IOUSBController; // for the "can sleep" characteristic + +private: + OSDeclareDefaultStructors(IOUSBHubDevice) + + UInt32 _myCharacteristics; // bitmap of my characteristics + IOUSBHubPolicyMaker *_myPolicyMaker; // pointer to the policy maker in the IOPower tree for this hub + + struct ExpansionData + { + UInt32 _maxPortCurrent; // maximum current in milliamps per downstream port + UInt32 _totalExtraCurrent; // total amount of current above the spec'ed current per port available (during normal operation) + UInt32 _totalSleepCurrent; // total amount of current that can be drawn during sleep + UInt32 _canRequestExtraPower; // If 0, this hub does not support requesting extra power from its parent, non-zero: how much power we need to request in order to give out _extraPowerForPorts + UInt32 _extraPowerForPorts; // Of the power requested from our parent, how much can we parcel out -- the rest is consumed by voltage drop thru the cable + UInt32 _extraPowerAllocated; // Amount of power that we actually got from our parent + bool _requestFromParent; // True if we are to request the extra power from our parent, without modifying the request. Used for RMHs + }; + ExpansionData *_expansionData; + +protected: + // IOUSBHubDevice methods which will be used by the hub driver (which is also the Policy Maker) + virtual void SetPolicyMaker(IOUSBHubPolicyMaker *policyMaker); + virtual void SetHubCharacteristics(UInt32); + virtual bool InitializeCharacteristics(void); // used at start + +public: + // static constructor + static IOUSBHubDevice *NewHubDevice(void); + + // IOKit methods + virtual bool init(); + virtual bool start( IOService * provider ); + virtual void stop( IOService *provider ); + virtual void free(); + + // public IOUSBHubDevice methods + + void SetTotalSleepCurrent(UInt32 sleepCurrent); + UInt32 GetTotalSleepCurrent(); + + /*! + @function GetPolicyMaker + returns a pointer to the policy maker for the hub, which can be used as the power plane parent. + @result returns an IOUSBHubPolicyMaker* pointing to the policy maker for this hub. returns NULL is no policy maker is active on the hub device. + */ + virtual IOUSBHubPolicyMaker *GetPolicyMaker(void); + + /*! + @function GetHubCharacteristics + returns characteristics of the hub device which might be useful for the driver of a device connected to the hub. + kIOUSBHubDeviceIsRootHub indicates that the hub is a root hub + kIOUSBHubDeviceIsOnHighSpeedBus indicates that the hub is running on a High Speed bus. If this bit is set and kIOUSBHubDeviceIsHighSpeed is clear, then this is a Classic Speed hub running on a High Speed bus, which means that Split Transactions will be used to communicate with downstream devices. + + @result returns a bitmap of characteristics + */ + virtual UInt32 GetHubCharacteristics(); + + /*! + @function GetMaxProvidedPower + returns the maximum amount of power available on any downstream port of this hub + @result the power is returned in milliamps - usually 100ma or 500 ma. + */ + virtual UInt32 GetMaxProvidedPower(); + + /*! + @function RequestProvidedPower + requests power from the hub device + @param requestedPower - the amount of power requested in milliamps (usually 100ma or 500 ma) + @result the amount of power allocated for this driver in milliamps (usually 100ma or 500 ma) + */ + virtual UInt32 RequestProvidedPower(UInt32 requestedPower); + + virtual UInt32 RequestExtraPower(UInt32 requestedPower); + + virtual void ReturnExtraPower(UInt32 returnedPower); + + OSMetaClassDeclareReservedUsed(IOUSBHubDevice, 0); + + virtual void InitializeExtraPower(UInt32 maxPortCurrent, UInt32 totalExtraCurrent); + + OSMetaClassDeclareReservedUsed(IOUSBHubDevice, 1); + virtual UInt32 RequestSleepPower(UInt32 requestedPower); + + OSMetaClassDeclareReservedUsed(IOUSBHubDevice, 2); + virtual void ReturnSleepPower(UInt32 returnedPower); + + OSMetaClassDeclareReservedUsed(IOUSBHubDevice, 3); + virtual void SetSleepCurrent(UInt32 sleepCurrent); + + OSMetaClassDeclareReservedUsed(IOUSBHubDevice, 4); + virtual UInt32 GetSleepCurrent(); + + OSMetaClassDeclareReservedUnused(IOUSBHubDevice, 5); + OSMetaClassDeclareReservedUnused(IOUSBHubDevice, 6); + OSMetaClassDeclareReservedUnused(IOUSBHubDevice, 7); + OSMetaClassDeclareReservedUnused(IOUSBHubDevice, 8); + OSMetaClassDeclareReservedUnused(IOUSBHubDevice, 9); + OSMetaClassDeclareReservedUnused(IOUSBHubDevice, 10); + OSMetaClassDeclareReservedUnused(IOUSBHubDevice, 11); + OSMetaClassDeclareReservedUnused(IOUSBHubDevice, 12); + OSMetaClassDeclareReservedUnused(IOUSBHubDevice, 13); + OSMetaClassDeclareReservedUnused(IOUSBHubDevice, 14); + OSMetaClassDeclareReservedUnused(IOUSBHubDevice, 15); +}; + +#endif /* _IOKIT_IOUSBROOTHUBDEVICE_H */ + Index: branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBDevice.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBDevice.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBDevice.h (revision 885) @@ -0,0 +1,639 @@ +/* + * Copyright (c) 1998-2007 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.2 (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, 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 __OPEN_SOURCE__ +/* + * + * $Log: IOUSBDevice.h,v $ + * Revision 1.65 2009/10/18 20:20:37 nano + * Bring in fixes in 390.4.0 QL: 7310698 7301024 7307079 and 7310698 + * + * Revision 1.64.32.4 2009/10/15 21:17:43 nano + * If OverrideAtLocationID does not see a override property, return true + * + * Revision 1.64.32.3.2.1 2009/10/15 21:36:27 nano + * If OverrideAtLocationID does not see a override property, return true + * + * Revision 1.64.32.3 2009/10/14 19:16:15 nano + * Minor name changes + * + * Revision 1.64.32.2 2009/10/14 19:05:21 nano + * 7284477 7293893 Simplify scheme to decide whether we want to override a property for a hub at a particular ID for a particular MacModel. Added a IOUSBDevice API that tells us if we are in the right model and locationID to override a property + * + * Revision 1.64.32.1 2009/10/08 19:55:56 nano + * rdar://7284477 Allow us to overide the config descriptor of a 2514 hub on a K23F + * + * Revision 1.64 2009/09/08 12:28:45 nano + * IOUSBDevice headerdoc comment problem - GetNumConfigs name is wrong, should be GetNumConfigurations + * + * Revision 1.63 2009/05/07 19:43:09 nano + * Move our SnowLeopard branch to TOT + * + * Revision 1.57.84.6 2009/03/13 22:45:11 nano + * Bring in branches to fix 6676089 6675858 6567987 6490273 + * + * Revision 1.57.84.5.4.1 2009/03/11 20:01:56 nano + * rdar://6567987 Do not let a Reset or a ReEnumerate through while the other is executing. + * + * Revision 1.57.84.5 2009/02/26 13:44:32 nano + * Bring in rdar://6536090&6586312 to SL branch + * + * Revision 1.57.84.4.10.1 2009/02/25 00:51:06 rhoads + * change the mechanism of getConfigLock so as to prevent a deadlock + * + * Revision 1.57.84.4 2009/02/13 15:57:33 rhoads + * roll in rdars: 6213394, 6489431, 6513000, 6515115, 6535200, 6567783 + * + * Revision 1.57.84.3.48.3 2009/02/11 19:19:08 rhoads + * add back an expansionData variable to preserve binary compatibility + * + * Revision 1.57.84.3.48.2 2009/02/11 03:05:56 arulchan + * more ::SuspendDevice changes + * + * Revision 1.57.84.3.48.1 2009/01/23 21:34:15 arulchan + * fix for rdar://6213394 + * + * Revision 1.57.84.3 2008/06/16 21:31:16 nano + * Bring in changes from Foxhound 320.2.17 + * + * Revision 1.57.84.2 2008/04/22 22:38:01 nano + * Bring in changes from Foxhound-320.2.9 + * + * Revision 1.60.28.2 2008/05/22 17:36:18 nano + * Fix the reporting of the internal bit for GetDeviceInformation + * + * Revision 1.60.28.1 2008/05/21 17:51:43 nano + * GetDeviceInformation needs some fixes + * + * Revision 1.60 2008/04/18 22:03:28 nano + * Bring in fix for rdar://5874560 + * + * Revision 1.59.4.1 2008/04/18 21:55:55 nano + * Need API to know how much extra power has been allocated + * + * Revision 1.59 2008/04/17 16:56:57 nano + * Bring in branches for rdar://5867990 & rdar://5768343 + * + * Revision 1.58.4.1 2008/04/16 20:26:13 nano + * Add API to allocate sleep current, as well as making sure that we return any extra power if our client dies or our device is terminated without returning it + * + * Revision 1.58 2008/04/14 16:08:38 nano + * Add new APIs for high power and for GetDeviceInformation. + * + * Revision 1.57.126.2 2008/04/13 05:25:40 nano + * Call into PolicyMaker for the GetPortInformation + * + * Revision 1.57.126.1 2008/04/11 22:25:44 nano + * Initial work on new user-client APIs and new IOUSBDevice APIs to return port state information and manage extra power requests, as well as groundwork for calling the policy maker directly from the IOUSBDevice + * + * Revision 1.57 2007/08/07 20:30:36 rhoads + * rolled in a few branches to TOT + * + * Revision 1.56.92.1 2007/08/07 03:43:34 nano + * Bring in more changes for M89 suppport -- like actually use the dang power if the properties are available + * + * Revision 1.56 2007/03/06 12:23:41 rhoads + * roll in 5024412, 5035829, and 5039670 + * + * Revision 1.55.30.1 2007/02/27 16:08:33 rhoads + * some fine tuning of our IOService overrides, including not overriding willTerminate and didTerminate (5024412) + * + * Revision 1.55 2007/01/19 17:58:48 rhoads + * roll in branches for a leopard build + * + * Revision 1.54.30.1 2007/01/17 16:37:02 rhoads + * remove the IOUSBDevice::attach method which is not really useful + * + * Revision 1.54 2006/10/06 04:42:01 rhoads + * roll in branches 4727961, 4758404, 4759810, 4760274, and 4762769 + * + * Revision 1.53.4.1 2006/10/04 16:03:57 rhoads + * better IOUSBHubDevice design + * + */ +#endif + +#ifndef _IOKIT_IOUSBDEVICE_H +#define _IOKIT_IOUSBDEVICE_H + +#include +#include +#include +#include +#include + +#include + +// The following are definitions for errata properties needed for different devices. This +// should be but in the dictionary of the IOUSBDevice in question. This can be achieved +// by using the AppleUSBMergeNub class and having an IOProviderMergeProperties dictionary +// with the required properties. + +// This property allows a device to specify a configuration value of 0 in its configuration +// descriptor. This does not follow the spec, but we will allow it in order to get the device +// to work. The property should be a Boolean +// +#define kAllowConfigValueOfZero "kAllowZeroConfigValue" +#define kAllowNumConfigsOfZero "kAllowZeroNumConfigs" + + +class IOUSBController; +class IOUSBControllerV2; +class IOUSBInterface; +class IOUSBHubPolicyMaker; +/*! + @class IOUSBDevice + @abstract The IOService object representing a device on the USB bus. + @discussion This class provides functionality to configure a device and to create + IOUSBInterface objects to represent the interfaces of the device. +*/ + +class IOUSBDevice : public IOUSBNub +{ + friend class IOUSBController; + friend class IOUSBControllerV2; + friend class IOUSBInterface; + friend class IOUSBPipe; + + OSDeclareDefaultStructors(IOUSBDevice) + +protected: + + USBDeviceAddress _address; + IOUSBController * _controller; + IOUSBPipe * _pipeZero; + IOUSBDeviceDescriptor _descriptor; + UInt32 _busPowerAvailable; + UInt8 _speed; + IOUSBEndpointDescriptor _endpointZero; // Fake ep for control pipe + void * _port; // Obsolete, do not use + IOBufferMemoryDescriptor** _configList; + IOUSBInterface** _interfaceList; + UInt8 _currentConfigValue; + UInt8 _numInterfaces; + + struct ExpansionData + { + UInt32 _portNumber; + thread_call_t _doPortResetThread; + IOUSBDevice * _usbPlaneParent; + bool _portResetThreadActive; + bool _allowConfigValueOfZero; + thread_call_t _doPortSuspendThread; + bool _portSuspendThreadActive; + thread_call_t _doPortReEnumerateThread; + bool _resetInProgress; + bool _portHasBeenReset; + IORecursiveLock* _XgetConfigLock; // Obsolete + bool _doneWaiting; // Obsolete + bool _notifiedWhileBooting; // Obsolete + IOWorkLoop * _workLoop; + IOTimerEventSource * _notifierHandlerTimer; + UInt32 _notificationType; + bool _suspendInProgress; + bool _portHasBeenSuspendedOrResumed; + bool _addExtraResetTime; + bool _suspendCommand; + IOCommandGate * _commandGate; + OSSet * _openInterfaces; + bool _resetCommand; + IOReturn _resetError; + IOReturn _suspendError; + thread_call_t _doMessageClientsThread; + IOUSBHubPolicyMaker * _hubPolicyMaker; + UInt32 _sleepPowerAllocated; // how much sleep power we already gave to our client + UInt32 _wakePowerAllocated; // how much extra power during wake did we already give our client + UInt32 _devicePortInfo; + bool _deviceIsInternal; // Will be set if all our upstream hubs are captive (internal to the computer) + bool _deviceIsInternalIsValid; // true if we have already determined whether the device is internal + bool _newGetConfigLock; // new lock, taken within the WL gate, when doing a GetConfig + UInt32 _resetAndReEnumerateLock; // "Lock" to prevent us from doing a reset or a re-enumerate while the other one is in progress + UInt32 _locationID; + }; + ExpansionData * _expansionData; + + const IOUSBConfigurationDescriptor *FindConfig(UInt8 configValue, UInt8 *configIndex=0); + + virtual IOUSBInterface * GetInterface(const IOUSBInterfaceDescriptor *interface); + +public: + virtual IOReturn SetFeature(UInt8 feature); + +protected: + virtual IOReturn GetConfigDescriptor(UInt8 configIndex, void *data, UInt32 len); + + virtual IOReturn GetDeviceDescriptor(IOUSBDeviceDescriptor *desc, UInt32 size); + + virtual bool init(USBDeviceAddress deviceAddress, UInt32 powerAvaiable, UInt8 speed, UInt8 maxPacketSize ); + + virtual bool matchPropertyTable(OSDictionary * table, SInt32 *score); + +public: + // IOService methods + virtual bool init( void ); + virtual bool start( IOService *provider ); + virtual bool handleIsOpen(const IOService *forClient) const; + virtual bool handleOpen(IOService *forClient, IOOptionBits options, void *arg); + virtual void handleClose(IOService *forClient, IOOptionBits options); + virtual IOReturn message( UInt32 type, IOService * provider, void * argument = 0 ); + virtual bool terminate( IOOptionBits options = 0 ); + virtual bool requestTerminate( IOService * provider, IOOptionBits options ); + virtual void stop( IOService *provider ); + virtual bool finalize(IOOptionBits options); + virtual void free( void ); + + // IOUSBDevice methods + virtual void SetProperties(); + + static IOUSBDevice *NewDevice(void); + + virtual void SetPort(void *port); // Obsolete, do NOT use + + /*! + @function FindNextInterfaceDescriptor + return a pointer to the next interface descriptor within the given full configuration descriptor satisfying the requirements specified, or NULL if there aren't any. + @param configDescIn the configuration descriptor within which to search. obtained from GetFullConfigurationDescriptor(configIndex). use NULL to specify the current configuration's descriptor. + @param intfDesc interface descriptor from which to start the search. NULL for the first interface descriptor in the given configuration descriptor + @param request IOUSBFindInterfaceRequest specifying the desired interface. Not changed. + @param descOut pointer to placeholder for the returned descriptor ptr + @result returns kIOReturnBadArgument if configDesc is not correct, or if configDesc is NULL and the device is not configured, or if intfDesc is not in configDesc. Otherwise returns kIOReturnSuccess or kIOUSBInterfaceNotFound. + */ + virtual IOReturn FindNextInterfaceDescriptor(const IOUSBConfigurationDescriptor *configDescIn, + const IOUSBInterfaceDescriptor *intfDesc, + const IOUSBFindInterfaceRequest *request, + IOUSBInterfaceDescriptor **descOut); + /*! + @function FindNextInterface + return an pointer to an IOUSBInterface object satisfying the requirements specified in request, or NULL if there aren't any. the device + must be configured for there to be any interfaces. + @param current interface to start searching from, NULL to start at the beginning of the device's interface list for the current configuration. + @param request specifies what properties an interface must have to match. + @result Pointer to a matching IOUSBInterface, or NULL if none match. Note: The IOUSBInterface is NOT retained for the caller. If the caller wishes to continue to use the returned object, it should call retain() on that object. + */ + virtual IOUSBInterface *FindNextInterface(IOUSBInterface *current, + IOUSBFindInterfaceRequest *request); + + /*! + @function CreateInterfaceIterator + return an OSIterator to iterate through interfaces satisfying the requirements specified in request. + @param request specifies what properties an interface must have to match. + @result Pointer to an OSIterator. + */ + virtual OSIterator *CreateInterfaceIterator(IOUSBFindInterfaceRequest *request); + + // Get pointer to full config info (cached in device, don't free returned pointer) + /*! + @function GetFullConfigurationDescriptor + return a pointer to all the descriptors for the requested configuration. + @param configIndex The configuration index (not the configuration value) + @result Pointer to the descriptors, which are cached in the IOUSBDevice object. + */ + virtual const IOUSBConfigurationDescriptor *GetFullConfigurationDescriptor(UInt8 configIndex); + + /*! + @function GetConfigurationDescriptor + Copy the specified amount of data for a configuration into the suppled buffer. + @param configValue The configuration value + @param data Buffer to copy data into + @param len number of bytes to copy + */ + virtual IOReturn GetConfigurationDescriptor(UInt8 configValue, void *data, UInt32 len); + + /*! + @function ResetDevice + Reset the device, returning it to the addressed, unconfigured state. + This is useful if a device has got badly confused. Note that the AppleUSBComposite driver will automatically + reconfigure the device if it is a composite device. + */ + virtual IOReturn ResetDevice(); + + /*! + @function SetConfiguration + Do a USB SetConfiguration call to the device. The caller must have the device open() in order to + actually cause a configuration change. If the device is currently configured, all IOUSBInterface objects + associated with the device are freed. After the new configuration has been set, all of its IOUSBInterface objects are + instantiated automatically. + @param forClient The client requesting the configuration change + @param configValue The desired configuration value. + @param startInterfaceMatching A boolean specifying whether IOKit should begin the process of finding + matching drivers for the new IOUSBInterface objects. + */ + virtual IOReturn SetConfiguration(IOService *forClient, UInt8 configValue, bool startInterfaceMatching=true); + + // Access to addressing and cached info + /*! + @function GetAddress + returns the bus address of the device + */ + virtual USBDeviceAddress GetAddress(void); + + /*! + @function GetSpeed + returns the speed of the device + */ + virtual UInt8 GetSpeed(void); + /*! + @function GetBus + returns a pointer to the IOUSBController object for the device + */ + virtual IOUSBController *GetBus(void); + /*! + @function GetBusPowerAvailable + returns the power available to the device, in units of 2mA + */ + virtual UInt32 GetBusPowerAvailable( void ); + /*! + @function GetMaxPacketSize + returns the maximum packet size for endpoint zero (only 8, 16, 32, 64 are valid) + */ + virtual UInt8 GetMaxPacketSize(void); + /*! + @function GetVendorID + returns the Vendor ID of the device + */ + virtual UInt16 GetVendorID(void); + /*! + @function GetProductID + returns the Product ID of the device + */ + virtual UInt16 GetProductID(void); + /*! + @function GetDeviceRelease + returns the DeviceRelease information + */ + virtual UInt16 GetDeviceRelease(void); + /*! + @function GetNumConfigurations + returns the number of configs in the device config descriptor + */ + virtual UInt8 GetNumConfigurations(void); + /*! + @function GetManufacturerStringIndex + returns the index of string descriptor describing manufacturer + */ + virtual UInt8 GetManufacturerStringIndex(void ); + /*! + @function GetProductStringIndex + returns the index of string descriptor describing product + */ + virtual UInt8 GetProductStringIndex(void ); + /*! + @function GetSerialNumberStringIndex + returns the index of string descriptor describing the device's serial number + */ + virtual UInt8 GetSerialNumberStringIndex(void ); + /*! + @function GetPipeZero + returns a pointer to the device's default control pipe + */ + virtual IOUSBPipe * GetPipeZero(void); + + // Deprecated but needed for binary compatibility + virtual IOUSBPipe* MakePipe(const IOUSBEndpointDescriptor *ep); + + // this method is deprecated. use the other DeviceRequest methods + virtual IOReturn DeviceRequest(IOUSBDevRequest *request, + IOUSBCompletion *completion = 0); + + // Same but with a memory descriptor + virtual IOReturn DeviceRequest(IOUSBDevRequestDesc *request, + IOUSBCompletion *completion = 0); + + /*! + @function GetConfiguration + Gets the current configuration from the IOUSBDevice object. Note that this call will send a control + request on the bus to get the current configuration from the physical device. + @param configNum Pointer to place to store configuration value. + */ + virtual IOReturn GetConfiguration(UInt8 *configNumber); + + /*! + @function GetDeviceStatus + Gets the device's status. Note that this sends a control request to the physical device. + @param status Pointer to place to store the status. + */ + virtual IOReturn GetDeviceStatus(USBStatus *status); + + /*! + @function GetStringDescriptor + Get a string descriptor as ASCII, in the specified language (default is US English) + @param index Index of the string descriptor to get. + @param buf Pointer to place to store ASCII string + @param maxLen Size of buffer pointed to by buf + @param lang Language to get string in (default is US English) + */ + virtual IOReturn GetStringDescriptor(UInt8 index, char *buf, int maxLen, UInt16 lang=0x409); + + /*! + @function GetChildLocationID + Get the locationID (UInt32) given the port number and the parent's location + @param parentLocationID locationID for the hub to which this device is attached. + @param port Port number of the hub where this device is attached + */ + virtual UInt32 GetChildLocationID(UInt32 parentLocationID, int port); + + virtual const IOUSBDescriptorHeader* FindNextDescriptor(const void *cur, UInt8 descType); + + virtual void DisplayNotEnoughPowerNotice(); + + // this is a non-virtual function so that we don't have to take up a binary compatibility slot. + UInt16 GetbcdUSB(void); + UInt8 GetProtocol(void); + void SetBusPowerAvailable(UInt32 newPower); + + OSMetaClassDeclareReservedUsed(IOUSBDevice, 0); + /*! + @function DeviceRequest + @abstract execute a control request to the default control pipe (pipe zero) + @param request The parameter block to send to the device + @param noDataTimeout Specifies an amount of time (in ms) after which the command will be aborted + if no data has been transferred on the bus. + @param completionTimeout Specifies an amount of time (in ms) after which the command will be aborted if the entire command has + not been completed. + @param completion Function to call when request completes. If omitted then + DeviceRequest() executes synchronously, blocking until the request is complete. If the request is asynchronous, the client must make sure that + the IOUSBDevRequest is not released until the callback has occurred. + + */ + virtual IOReturn DeviceRequest(IOUSBDevRequest *request, + UInt32 noDataTimeout, + UInt32 completionTimeout, + IOUSBCompletion *completion = 0); + + /*! + @function DeviceRequest + @abstract execute a control request to the default control pipe (pipe zero) + @param request The parameter block to send to the device (with the pData as an IOMemoryDesriptor) + @param noDataTimeout Specifies an amount of time (in ms) after which the command will be aborted + if no data has been transferred on the bus. + @param completionTimeout Specifies an amount of time (in ms) after which the command will be aborted if the entire command has + not been completed. + @param completion Function to call when request completes. If omitted then + DeviceRequest() executes synchronously, blocking until the request is complete. If the request is asynchronous, the client must make sure that + the IOUSBDevRequest is not released until the callback has occurred. + + */ + OSMetaClassDeclareReservedUsed(IOUSBDevice, 1); + virtual IOReturn DeviceRequest(IOUSBDevRequestDesc *request, + UInt32 noDataTimeout, + UInt32 completionTimeout, + IOUSBCompletion *completion = 0); + + OSMetaClassDeclareReservedUsed(IOUSBDevice, 2); + /*! + @function SuspendDevice + @abstract Instruct the hub to which this device is attached to suspend or resume the port to which the device is attached. + Note that if there are any outstanding transactions on any pipes in the device, those transactions will get returned with a + kIOReturnNotResponding error. + @param suspend Boolean value. true = suspend, false = resume. + */ + virtual IOReturn SuspendDevice( bool suspend); + + OSMetaClassDeclareReservedUsed(IOUSBDevice, 3); + /*! + @function ReEnumerateDevice + @abstract Instruct the hub to which this device is attached to reset the port to which this device is attached. This causes the + IOUSBDevice object and any child objects (IOUSBInterface objects or driver objects) to be terminated, and the device to be + completely reenumerated, as if it had been detached and reattached. + @param options Reserved for future use. + */ + virtual IOReturn ReEnumerateDevice( UInt32 options ); + + OSMetaClassDeclareReservedUsed(IOUSBDevice, 4); + /*! + @function DisplayUserNotification + @abstract Will use the KUNCUserNotification mechanism to display a notification to the user. + @param notificationType Which notification to display. + */ + virtual void DisplayUserNotification(UInt32 notificationType); + + OSMetaClassDeclareReservedUsed(IOUSBDevice, 5); + /*! + @function MakePipe + @abstract build a pipe on a given endpoint + @param ep A description of the endpoint + @param interface The IOUSBInterface object requesting the pipe + returns the desired IOUSBPipe object + */ + virtual IOUSBPipe* MakePipe(const IOUSBEndpointDescriptor *ep, IOUSBInterface *interface); + + + OSMetaClassDeclareReservedUsed(IOUSBDevice, 6); + /*! + @function SetHubParent + @abstract Used by the hub driver to give the nub a pointer to its HubPolicyMaker object + @param hubPolicyMaker The object representing the Hub driver + */ + virtual void SetHubParent(IOUSBHubPolicyMaker *hubParent); + + OSMetaClassDeclareReservedUsed(IOUSBDevice, 7); + /*! + @function GetHubParent + @abstract Used by the hub driver to give the nub a pointer to its HubPolicyMaker object + @param hubPolicyMaker The object representing the Hub driver + */ + virtual IOUSBHubPolicyMaker* GetHubParent(); + + OSMetaClassDeclareReservedUsed(IOUSBDevice, 8); + /*! + @function GetDeviceInformation + @abstract Returns status information about the USB device, such as whether the device is captive or whether it is in the suspended state. + @param requestedPower The desired amount of power that the client wishes to reserve + @result Actual power that was reserved + + */ + virtual IOReturn GetDeviceInformation(UInt32 *info); + + OSMetaClassDeclareReservedUsed(IOUSBDevice, 9); + /*! + @function RequestExtraPower + @abstract Clients can use this API to reserve extra power for use by this device while the machine is asleep or while it is awake. Units are milliAmps (mA). + @param type Indicates whether the power is to be used during wake or sleep (One of kUSBPowerDuringSleep or kUSBPowerDuringWake) + @param requestedPower Amount of power desired, in mA + @result Amount of power actually reserved, in mA. It can be less than the requested or zero. + + */ + virtual UInt32 RequestExtraPower(UInt32 type, UInt32 requestedPower); + + OSMetaClassDeclareReservedUsed(IOUSBDevice, 10); + /*! + @function ReturnExtraPower + @abstract Clients can use this API to tell the system that they will not use power that was previously reserved by using the RequestExtraPower API. + @param type Indicates whether the power is to be used during wake or sleep (One of kUSBPowerDuringSleep or kUSBPowerDuringWake) + @param returnedPower Amount of power that is no longer needed, in mA + @result If the returnedPower was not previously allocated, an error will be returned. This will include the case for power that was requested for sleep but was returned for wake. + + */ + virtual IOReturn ReturnExtraPower(UInt32 type, UInt32 returnedPower); + + OSMetaClassDeclareReservedUsed(IOUSBDevice, 11); + /*! + @function GetExtraPowerAllocated + @abstract Clients can use this API to ask how much extra power has already been reserved by this device. Units are milliAmps (mA). + @param type Indicates whether the allocated power was to be used during wake or sleep (One of kUSBPowerDuringSleep or kUSBPowerDuringWake) + @result Amount of power allocated, in mA. + + */ + virtual UInt32 GetExtraPowerAllocated(UInt32 type); + + OSMetaClassDeclareReservedUsed(IOUSBDevice, 12); + /*! + @function DoLocationOverrideAndModelMatch + @abstract Will look for a kOverrideIfAtLocationID array proerty with locationID entries and a "MacModel" property. If any of the locationIDs match to the Mac Model, will return true. + If there is no kOverrideAtLocationID property, it will also return true. + @result True if we have a match, false otherwise + */ + virtual bool DoLocationOverrideAndModelMatch(); + + OSMetaClassDeclareReservedUnused(IOUSBDevice, 13); + OSMetaClassDeclareReservedUnused(IOUSBDevice, 14); + OSMetaClassDeclareReservedUnused(IOUSBDevice, 15); + OSMetaClassDeclareReservedUnused(IOUSBDevice, 16); + OSMetaClassDeclareReservedUnused(IOUSBDevice, 17); + OSMetaClassDeclareReservedUnused(IOUSBDevice, 18); + OSMetaClassDeclareReservedUnused(IOUSBDevice, 19); + +private: + + static void ProcessPortResetEntry(OSObject *target); + void ProcessPortReset(void); + + void TerminateInterfaces(void); + + static void ProcessPortReEnumerateEntry(OSObject *target, thread_call_param_t options); + void ProcessPortReEnumerate(UInt32 options); + + static void DoMessageClientsEntry(OSObject *target, thread_call_param_t messageStruct); + void DoMessageClients( void * messageStructPtr); + + static void DisplayUserNotificationForDeviceEntry (OSObject *owner, IOTimerEventSource *sender); + void DisplayUserNotificationForDevice( ); + + UInt32 SimpleUnicodeToUTF8(UInt16 uChar, UInt8 utf8Bytes[4]); + void SwapUniWords (UInt16 **unicodeString, UInt32 uniSize); + + IOReturn TakeGetConfigLock(void); + IOReturn ReleaseGetConfigLock(void); + static IOReturn ChangeGetConfigLock(OSObject *target, void *arg0, void *arg1, void *arg2, void *arg3); +}; + +#endif /* _IOKIT_IOUSBDEVICE_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBInterface.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBInterface.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBInterface.h (revision 885) @@ -0,0 +1,264 @@ +/* + * Copyright (c) 1998-2007 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_IOUSBINTERFACE_H +#define _IOKIT_IOUSBINTERFACE_H + +#include +#include + +#include +#include +#include + +/*! + @class IOUSBInterface + @abstract The object representing an interface of a device on the USB bus. + @discussion This class provides functionality to find the pipes of an interface and + to read the descriptors associated with an interface. When an interface is open()ed, + all its pipes are created +*/ +class IOUSBInterface : public IOUSBNub +{ + friend class IOUSBInterfaceUserClientV2; + + OSDeclareDefaultStructors(IOUSBInterface) + +protected: + IOUSBPipe * _pipeList[kUSBMaxPipes]; + const IOUSBConfigurationDescriptor *_configDesc; + const IOUSBInterfaceDescriptor * _interfaceDesc; + IOUSBDevice * _device; + + // these variable are the parsed interface descriptor + UInt8 _bInterfaceNumber; + UInt8 _bAlternateSetting; + UInt8 _bNumEndpoints; + UInt8 _bInterfaceClass; + UInt8 _bInterfaceSubClass; + UInt8 _bInterfaceProtocol; + UInt8 _iInterface; + + struct ExpansionData { + IOCommandGate *_gate; + IOWorkLoop *_workLoop; + bool _needToClose; + IOLock * _pipeObjLock; // Lock to synchronize accesses to our pipeObjects + }; + ExpansionData * _expansionData; + + // private methods + virtual void ClosePipes(void); // close all pipes (except pipe zero) + virtual IOReturn CreatePipes(void); // open all pipes in the current interface/alt interface + virtual void SetProperties(void); // update my property table with the correct properties + +public: + // static methods + static IOUSBInterface *withDescriptors(const IOUSBConfigurationDescriptor *cfDesc, const IOUSBInterfaceDescriptor *ifDesc); + static IOReturn CallSuperOpen(OSObject *target, void *arg0, void *arg1, void *arg2, void *arg3); + static IOReturn CallSuperClose(OSObject *target, void *arg0, void *arg1, void *arg2, void *arg3); + static UInt8 hex2char( UInt8 digit ); + + // IOService methods + virtual bool start(IOService * provider); + virtual bool handleOpen(IOService *forClient, IOOptionBits options = 0, void *arg = 0 ); + virtual bool open(IOService *forClient, IOOptionBits options = 0, void *arg = 0 ); + virtual void close(IOService *forClient, IOOptionBits options = 0); + virtual void handleClose(IOService *forClient, IOOptionBits options = 0); + virtual IOReturn message( UInt32 type, IOService * provider, void * argument = 0 ); + virtual bool finalize(IOOptionBits options); + virtual void stop(IOService * provider); + virtual bool terminate( IOOptionBits options = 0 ); + virtual void free(); + + // IOUSBInterface class methods + virtual bool init( const IOUSBConfigurationDescriptor *cfDesc, + const IOUSBInterfaceDescriptor *ifDesc); + /*! + @function FindNextAltInterface + return alternate interface descriptor satisfying the requirements specified in request, or NULL if there aren't any. + request is updated with the properties of the returned interface. + @param current interface descriptor to start searching from, NULL to start at alternate interface 0. + @param request specifies what properties an interface must have to match. + @result Pointer to a matching interface descriptor, or NULL if none match. + */ + virtual const IOUSBInterfaceDescriptor *FindNextAltInterface(const IOUSBInterfaceDescriptor *current, + IOUSBFindInterfaceRequest *request); + + /*! + @function FindNextPipe + Find a pipe of the interface that matches the requirements, either + starting from the beginning of the interface's pipe list or from a specified + pipe. + @param current Pipe to start searching from, NULL to start from beginning of list. + @param request Requirements for pipe to match, updated with the found pipe's + properties. + @result Pointer to the pipe, or NULL if no pipe matches the request. + */ + virtual IOUSBPipe *FindNextPipe(IOUSBPipe *current, IOUSBFindEndpointRequest *request); + + /*! + @function FindNextAssociatedDescriptor + Find the next descriptor of the requested type associated with the interface. + @param current Descriptor to start searching from, NULL to start from beginning of list. + @param type Descriptor type to search for, or kUSBAnyDesc to return any descriptor type. + @result Pointer to the descriptor, or NULL if no matching descriptors found. + */ + virtual const IOUSBDescriptorHeader * FindNextAssociatedDescriptor(const void *current, UInt8 type); + + /*! + @function SetAlternateInterface + Select the specified alternate interface. + @param forClient The client requesting the alternate setting. This client must have the interface open in order to perform the request. + @param alternateSetting Alternate setting (from the alternate interface's interface descriptor). + @result exclusive access error if the interface is not open. otherwise the result of the transaction + */ + virtual IOReturn SetAlternateInterface(IOService *forClient, UInt16 alternateSetting); + + /*! + @function GetPipeObj + returns a handle to the pipe at the corresponding index + @param index value from zero to kUSBMaxPipes-1 + @result The IOUSBPipe object. Note that the client does not own a reference to this pipe, so the client should retain() the IOUSBPipe object if necessary. + */ + virtual IOUSBPipe *GetPipeObj(UInt8 index); + /*! + @function GetConfigValue + returns the device configuration value for the interface + @result The device configuration value. + */ + virtual UInt8 GetConfigValue(); + /*! + @function GetDevice + returns the device the interface is part of. + @result Pointer to the IOUSBDevice object which is the parent of this IOUSBInterface object. + */ + virtual IOUSBDevice *GetDevice(); + /*! + @function GetInterfaceNumber + returns the zero based value identifying the index in the array of concurrent + interfaces supported by the current configuration + @result the interface index + */ + virtual UInt8 GetInterfaceNumber(); + /*! + @function GetAlternateSetting + returns the alternate setting for this interface. + @result the alternate setting + */ + virtual UInt8 GetAlternateSetting(); + /*! + @function GetNumEndpoints + returns the number of endpoints used by this interface (excluding + device endpoint zero. If the value is zero, this interface only + uses endpoint zero. + @result the number of endpoints + */ + virtual UInt8 GetNumEndpoints(); + /*! + @function GetInterfaceClass + returns the class code for this interface (assigned by the USB) + a value of zero is reserved + if the value is FFh, the interface class is vendor-specific + all other values are reserved for assignment by the USB + @result the interface class + */ + virtual UInt8 GetInterfaceClass(); + /*! + @function GetInterfaceSubClass + returns the subclass code (assigned by the USB). + These codes are qualified by the value returned by GetInterfaceClass + @result the interface subclass + */ + virtual UInt8 GetInterfaceSubClass(); + /*! + @function GetInterfaceProtocol + returns the protocol code (assigned by the USB). + @result the interface index + */ + virtual UInt8 GetInterfaceProtocol(); + /*! + @function GetInterfaceStringIndex + returns the index of the string descriptor describing the interface + @result the string index + */ + virtual UInt8 GetInterfaceStringIndex(); + + /*! + @function DeviceRequest + @abstract Sends a control request to the default control pipe in the device (pipe zero) + @param request The parameter block to send to the device + @param completion Function to call when request completes. If omitted then + DeviceRequest() executes synchronously, blocking until the request is complete. If the request is asynchronous, the client must make sure that + the IOUSBDevRequest is not released until the callback has occurred. + */ + virtual IOReturn DeviceRequest(IOUSBDevRequest *request, IOUSBCompletion *completion = 0); + + /*! + @function DeviceRequest + @abstract Sends a control request to the default control pipe in the device (pipe zero) + @param request The parameter block to send to the device (with the pData as an IOMemoryDesriptor) + @param completion Function to call when request completes. If omitted then + DeviceRequest() executes synchronously, blocking until the request is complete. If the request is asynchronous, the client must make sure that + the IOUSBDevRequest is not released until the callback has occurred. + */ + virtual IOReturn DeviceRequest(IOUSBDevRequestDesc *request, IOUSBCompletion *completion = 0); + + virtual bool matchPropertyTable(OSDictionary * table, SInt32 *score); + + OSMetaClassDeclareReservedUsed(IOUSBInterface, 0); + /*! + @function GetEndpointProperties + @abstract Returns the properties of an endpoint, possibly in an alternate interface. + @param alternateSetting specifies the desired alternate setting + @param endpointNumber specifies the endpoint number + @param direction specifies the direction (kUSBIn, kUSBOut) + @param transferType a pointer to hold the transfer type (kUSBControl, kUSBBulk, etc.) of the endpoint if found. + @param maxPacketSize a pointer to hold the maxPacketSize in the endpoint descriptor. + @param interval a pointer to hold the interval value in the endpoint descriptor. + @result returns kIOReturnSuccess if the endpoint is found, and kIOUSBEndpointNotFound if it is not. + */ + virtual IOReturn GetEndpointProperties(UInt8 alternateSetting, UInt8 endpointNumber, UInt8 direction, UInt8 *transferType, UInt16 *maxPacketSize, UInt8 *interval); + + OSMetaClassDeclareReservedUnused(IOUSBInterface, 1); + OSMetaClassDeclareReservedUnused(IOUSBInterface, 2); + OSMetaClassDeclareReservedUnused(IOUSBInterface, 3); + OSMetaClassDeclareReservedUnused(IOUSBInterface, 4); + OSMetaClassDeclareReservedUnused(IOUSBInterface, 5); + OSMetaClassDeclareReservedUnused(IOUSBInterface, 6); + OSMetaClassDeclareReservedUnused(IOUSBInterface, 7); + OSMetaClassDeclareReservedUnused(IOUSBInterface, 8); + OSMetaClassDeclareReservedUnused(IOUSBInterface, 9); + OSMetaClassDeclareReservedUnused(IOUSBInterface, 10); + OSMetaClassDeclareReservedUnused(IOUSBInterface, 11); + OSMetaClassDeclareReservedUnused(IOUSBInterface, 12); + OSMetaClassDeclareReservedUnused(IOUSBInterface, 13); + OSMetaClassDeclareReservedUnused(IOUSBInterface, 14); + OSMetaClassDeclareReservedUnused(IOUSBInterface, 15); + OSMetaClassDeclareReservedUnused(IOUSBInterface, 16); + OSMetaClassDeclareReservedUnused(IOUSBInterface, 17); + OSMetaClassDeclareReservedUnused(IOUSBInterface, 18); + OSMetaClassDeclareReservedUnused(IOUSBInterface, 19); +}; + +#endif /* _IOKIT_IOUSBINTERFACE_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/usb/USBSpec.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/usb/USBSpec.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/usb/USBSpec.h (revision 885) @@ -0,0 +1,470 @@ +/* + * Copyright (c) 1998-2006 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@ + */ + + +/* + * Constants that both OS9 and OSX want to define, and whose values are + * specified by the USB Standard. + * Put in a seperate file so they can be included if the OS9 include file isn't already + * included. + */ +#ifndef _USBSPEC_H +#define _USBSPEC_H + +#ifdef __cplusplus +extern "C" { +#endif + + /*! + @header USBSpec.h + @abstract Constants and definitions of parameters that are used in communcating with USB devices and interfaces. + @discussion + */ + + /*! + @enum Endpoint type + @discussion Used in IOUSBFindEndpointRequest's type field + */ +enum { + kUSBControl = 0, + kUSBIsoc = 1, + kUSBBulk = 2, + kUSBInterrupt = 3, + kUSBAnyType = 0xFF +}; + + /*! + @enum Endpoint direction + @discussion Used in IOUSBFindEndpointRequest's direction field + */ +enum { + kUSBOut = 0, + kUSBIn = 1, + kUSBNone = 2, + kUSBAnyDirn = 3 +}; + + /*! + @enum Device Request Type + @discussion This type is encoded in the bmRequestType field of a Device Request. It specifies the type of request: standard, class or vendor specific. + */ +enum { + kUSBStandard = 0, + kUSBClass = 1, + kUSBVendor = 2 +}; + + /*! + @enum Device Request Recipient + @discussion This recipient is encoded in the bmRequestType field of a Device Request. It specifies the type of recipient for a request: the device, the interface, or an endpoint. + */ +enum { + kUSBDevice = 0, + kUSBInterface = 1, + kUSBEndpoint = 2, + kUSBOther = 3 +}; + + /*! + @enum Device Request + @discussion Specifies values for the bRequest field of a Device Request. + */ +enum { + kUSBRqGetStatus = 0, + kUSBRqClearFeature = 1, + kUSBRqGetState = 2, + kUSBRqSetFeature = 3, + kUSBRqReserved2 = 4, + kUSBRqSetAddress = 5, + kUSBRqGetDescriptor = 6, + kUSBRqSetDescriptor = 7, + kUSBRqGetConfig = 8, + kUSBRqSetConfig = 9, + kUSBRqGetInterface = 10, + kUSBRqSetInterface = 11, + kUSBRqSyncFrame = 12 +}; + + /*! + @enum USB Descriptors + @discussion Specifies values for diffent descriptor types. + */ +enum { + kUSBAnyDesc = 0, // Wildcard for searches + kUSBDeviceDesc = 1, + kUSBConfDesc = 2, + kUSBStringDesc = 3, + kUSBInterfaceDesc = 4, + kUSBEndpointDesc = 5, + kUSBDeviceQualifierDesc = 6, + kUSBOtherSpeedConfDesc = 7, + kUSBInterfacePowerDesc = 8, + kUSBOnTheGoDesc = 9, + kUSDebugDesc = 10, + kUSBInterfaceAssociationDesc = 11, + kUSBHIDDesc = 0x21, + kUSBReportDesc = 0x22, + kUSBPhysicalDesc = 0x23, + kUSBHUBDesc = 0x29 +}; + + /*! + @enum Feature Selectors + @discussion Used with SET/CLEAR_FEATURE requests. + */ +enum { + kUSBFeatureEndpointStall = 0, + kUSBFeatureDeviceRemoteWakeup = 1 +}; + + /*! + @enum USB Power constants + @discussion Constants relating to USB Power. + */ +enum { + kUSB100mAAvailable = 50, + kUSB500mAAvailable = 250, + kUSB100mA = 50, + kUSBAtrBusPowered = 0x80, + kUSBAtrSelfPowered = 0x40, + kUSBAtrRemoteWakeup = 0x20 +}; + + /*! + @enum USB Release constants + @discussion Constants relating to USB releases as found in the bcdUSB field of the Device Descriptor. + */ +enum { + kUSBRel10 = 0x0100, + kUSBRel11 = 0x0110, + kUSBRel20 = 0x0200 +}; + + + /*! + @enum HID requests + @discussion Constants for HID requests. + */ +enum { + kHIDRqGetReport = 1, + kHIDRqGetIdle = 2, + kHIDRqGetProtocol = 3, + kHIDRqSetReport = 9, + kHIDRqSetIdle = 10, + kHIDRqSetProtocol = 11 +}; + + /*! + @enum HID report types + @discussion Constants for the three kinds of HID reports. + */ +enum { + kHIDRtInputReport = 1, + kHIDRtOutputReport = 2, + kHIDRtFeatureReport = 3 +}; + + + /*! + @enum HID Protocol + @discussion Used in the SET_PROTOCOL device request + */ +enum { + kHIDBootProtocolValue = 0, + kHIDReportProtocolValue = 1 +}; + + + +enum { + kUSBCapsLockKey = 0x39, + kUSBNumLockKey = 0x53, + kUSBScrollLockKey = 0x47 +}; + +/*! +@enum Device Class Codes + @discussion Constants for USB Device classes (bDeviceClass). + */ +enum { + kUSBCompositeClass = 0, + kUSBCommClass = 2, // Deprecated + kUSBCommunicationClass = 2, + kUSBHubClass = 9, + kUSBDataClass = 10, + kUSBPersonalHealthcareClass = 15, + kUSBDiagnosticClass = 220, + kUSBWirelessControllerClass = 224, + kUSBMiscellaneousClass = 239, + kUSBApplicationSpecificClass = 254, + kUSBVendorSpecificClass = 255 +}; + +/*! +@enum Interface Class + @discussion Constants for Interface classes (bInterfaceClass). + */ +enum { + kUSBAudioClass = 1, // Deprecated + kUSBAudioInterfaceClass = 1, + + kUSBCommunicationControlInterfaceClass = 2, + kUSBCommunicationDataInterfaceClass = 10, + + kUSBHIDClass = 3, + kUSBHIDInterfaceClass = 3, + + kUSBPhysicalInterfaceClass = 5, + + kUSBImageInterfaceClass = 6, + + kUSBPrintingClass = 7, // Deprecated + kUSBPrintingInterfaceClass = 7, + + kUSBMassStorageClass = 8, // Deprecated + kUSBMassStorageInterfaceClass = 8, + + kUSBChipSmartCardInterfaceClass = 11, + + kUSBContentSecurityInterfaceClass = 13, + + kUSBVideoInterfaceClass = 14, + + kUSBPersonalHealthcareInterfaceClass = 15, + + kUSBDiagnosticDeviceInterfaceClass = 220, + + kUSBWirelessControllerInterfaceClass = 224, + + kUSBApplicationSpecificInterfaceClass = 254, + + kUSBVendorSpecificInterfaceClass = 255 +}; + +// Obsolete +enum { + + kUSBDisplayClass = 4, // Obsolete +}; + +/*! + @enum Interface SubClass + @discussion Constants for USB Interface SubClasses (bInterfaceSubClass). +*/ +enum { + kUSBCompositeSubClass = 0, + + kUSBHubSubClass = 0, + + // For the kUSBAudioInterfaceClass + // + kUSBAudioControlSubClass = 0x01, + kUSBAudioStreamingSubClass = 0x02, + kUSBMIDIStreamingSubClass = 0x03, + + // For the kUSBApplicationSpecificInterfaceClass + // + kUSBDFUSubClass = 0x01, + kUSBIrDABridgeSubClass = 0x02, + kUSBTestMeasurementSubClass = 0x03, + + // For the kUSBMassStorageInterfaceClass + // + kUSBMassStorageRBCSubClass = 0x01, + kUSBMassStorageATAPISubClass = 0x02, + kUSBMassStorageQIC157SubClass = 0x03, + kUSBMassStorageUFISubClass = 0x04, + kUSBMassStorageSFF8070iSubClass = 0x05, + kUSBMassStorageSCSISubClass = 0x06, + + // For the kUSBHIDInterfaceClass + // + kUSBHIDBootInterfaceSubClass = 0x01, + + // For the kUSBCommunicationDataInterfaceClass + // + kUSBCommDirectLineSubClass = 0x01, + kUSBCommAbstractSubClass = 0x02, + kUSBCommTelephoneSubClass = 0x03, + kUSBCommMultiChannelSubClass = 0x04, + kUSBCommCAPISubClass = 0x05, + kUSBCommEthernetNetworkingSubClass = 0x06, + kUSBATMNetworkingSubClass = 0x07, + + // For the kUSBDiagnosticDeviceInterfaceClass + // + kUSBReprogrammableDiagnosticSubClass = 0x01, + + // For the kUSBWirelessControllerInterfaceClass + // + kUSBRFControllerSubClass = 0x01, + + // For the kUSBMiscellaneousClass + // + kUSBCommonClassSubClass = 0x02, + + // For the kUSBVideoInterfaceClass + // + kUSBVideoControlSubClass = 0x01, + kUSBVideoStreamingSubClass = 0x02, + kUSBVideoInterfaceCollectionSubClass = 0x03 + +}; + +/*! +@enum Interface Protocol + @discussion Reported in the bInterfaceProtocol field of the Interface Descriptor. + */ +enum { + + // For kUSBHIDInterfaceClass + // + kHIDNoInterfaceProtocol = 0, + kHIDKeyboardInterfaceProtocol = 1, + kHIDMouseInterfaceProtocol = 2, + kUSBVendorSpecificProtocol = 0xff, + + // For kUSBDiagnosticDeviceInterfaceClass + // + kUSB2ComplianceDeviceProtocol = 0x01, + + // For kUSBWirelessControllerInterfaceClass + // + kUSBBluetoothProgrammingInterfaceProtocol = 0x01, + + // For kUSBMiscellaneousClass + // + KUSBInterfaceAssociationDescriptorProtocol = 0x01 + +}; + + +/*! + @enum DFU Class Attributes + @discussion +*/ +enum { + kUSBDFUAttributesMask = 0x07, + kUSBDFUCanDownloadBit = 0, + kUSBDFUCanUploadBit = 1, + kUSBDFUManifestationTolerantBit = 2 +}; + +/*! + @enum Printer Class Requests + @discussion The bRequest parameter for Printing Class Sepcific Requests + */ +enum { + kUSPrintingClassGetDeviceID = 0, + kUSPrintingClassGePortStatus = 1, + kUSPrintingClassSoftReset = 2 +}; + + /*! +@enum Endpoint Descriptor bits + @discussion Bit definitions for endpoint descriptor fields + */ +enum { + kUSBbEndpointAddressMask = 0x0f, + kUSBbEndpointDirectionBit = 7, + kUSBbEndpointDirectionMask = ( 1 << kUSBbEndpointDirectionBit ), + kUSBEndpointDirectionOut = 0x00, + kUSBEndpointDirectionIn = 0x80, + kUSBEndpointbmAttributesTransferTypeMask = 0x03, + kUSBEndpointbmAttributesSynchronizationTypeMask = 0x0c, + kUSBEndpointbmAttributesSynchronizationTypeShift = 2, + kUSBEndpointbmAttributesUsageTypeMask = 0x30, + kUSBEndpointbmAttributesUsageTypeShift = 4 +}; + + /*! + @defineblock USB Descriptor and IORegistry constants + @discussion Various constants used to describe the fields in the various USB Device Descriptors and IORegistry names used for some of those fields + + @define kUSBDeviceClass The field in the USB Device Descriptor corresponding to the device class + @define kUSBDeviceSubClass The field in the USB Device Descriptor corresponding to the device sub class + @define kUSBDeviceProtocol The field in the USB Device Descriptor corresponding to the device protocol + @define kUSBDeviceMaxPacketSize The field in the USB Device Descriptor corresponding to the maximum packet size for endpoint 0 + @define kUSBVendorID The field in the USB Device Descriptor corresponding to the device USB Vendor ID + @define kUSBVendorName Deprecated. Use kUSBVendorID + @define kUSBProductID The field in the USB Device Descriptor corresponding to the device USB Product ID + @define kUSBProductName Deprecated. Use kUSBProductID + @define kUSBDeviceReleaseNumber The field in the USB Device Descriptor corresponding to the device release version + @define kUSBManufacturerStringIndex The field in the USB Device Descriptor corresponding to the index for the manufacturer's string + @define kUSBProductStringIndex The field in the USB Device Descriptor corresponding to the index for the product name's string + @define kUSBSerialNumberStringIndex The field in the USB Device Descriptor corresponding to the index for the serial number's string + @define kUSBDeviceNumConfigs The field in the USB Configuration Descriptor corresponding to the number of configurations + @define kUSBInterfaceNumber The field in the USB Configuration Descriptor corresponding to the number of configurations + @define kUSBAlternateSetting The field in the USB Configuration Descriptor corresponding to the number of configurations + @define kUSBNumEndpoints The field in the USB Configuration Descriptor corresponding to the number of configurations + @define kUSBInterfaceClass The field in the USB Interface Descriptor corresponding to the interface class + @define kUSBInterfaceSubClass The field in the USB Interface Descriptor corresponding to the interface sub class + @define kUSBInterfaceProtocol The field in the USB Interface Descriptor corresponding to the interface protocol + @define kUSBInterfaceStringIndex The field in the USB Interface Descriptor corresponding to the index for the interface name's string + @define kUSBConfigurationValue The field in the USB Interface Descriptor corresponding to the configuration + @define kUSBProductString IORegistry key for the device's USB Product string + @define kUSBVendorString IORegistry key for the device's USB manufacturer string + @define kUSBSerialNumberString IORegistry key for the device's USB serial number string + @define kUSB1284DeviceID IORegistry key for the 1284 Device ID of a printer + + */ +#define kUSBDeviceClass "bDeviceClass" +#define kUSBDeviceSubClass "bDeviceSubClass" +#define kUSBDeviceProtocol "bDeviceProtocol" +#define kUSBDeviceMaxPacketSize "bMaxPacketSize0" +#define kUSBVendorID "idVendor" // good name +#define kUSBVendorName kUSBVendorID // bad name - keep for backward compatibility +#define kUSBProductID "idProduct" // good name +#define kUSBProductName kUSBProductID // bad name - keep for backward compatibility +#define kUSBDeviceReleaseNumber "bcdDevice" +#define kUSBManufacturerStringIndex "iManufacturer" +#define kUSBProductStringIndex "iProduct" +#define kUSBSerialNumberStringIndex "iSerialNumber" +#define kUSBDeviceNumConfigs "bNumConfigurations" +#define kUSBInterfaceNumber "bInterfaceNumber" +#define kUSBAlternateSetting "bAlternateSetting" +#define kUSBNumEndpoints "bNumEndpoints" +#define kUSBInterfaceClass "bInterfaceClass" +#define kUSBInterfaceSubClass "bInterfaceSubClass" +#define kUSBInterfaceProtocol "bInterfaceProtocol" +#define kUSBInterfaceStringIndex "iInterface" +#define kUSBConfigurationValue "bConfigurationValue" +#define kUSBProductString "USB Product Name" +#define kUSBVendorString "USB Vendor Name" +#define kUSBSerialNumberString "USB Serial Number" +#define kUSB1284DeviceID "1284 Device ID" + /*! @/defineblock */ + + /*! + @enum Apple USB Vendor ID + @discussion Apple's vendor ID, assigned by the USB-IF +*/ +enum { + kAppleVendorID = 0x05AC +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _USBSPEC_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBRootHubDevice.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBRootHubDevice.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBRootHubDevice.h (revision 885) @@ -0,0 +1,97 @@ +/* + * Copyright (c) 1998-2006 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_IOUSBROOTHUBDEVICE_H +#define _IOKIT_IOUSBROOTHUBDEVICE_H + +#include + +/*! + @class IOUSBRootHubDevice + @abstract The object representing the Root Hub simulation. + */ +class IOUSBRootHubDevice : public IOUSBHubDevice +{ + OSDeclareDefaultStructors(IOUSBRootHubDevice) + +private: + UInt16 configuration; + IOCommandGate *_commandGate; + + // private method which overrides the same method in IOUSBHubDevice + virtual bool InitializeCharacteristics(void); // used at start + + struct ExpansionData + { + IOService * _IOResourcesEntry; + }; + ExpansionData *_expansionData; + +public: + // static methods + static IOUSBRootHubDevice *NewRootHubDevice(void); + static IOReturn GatedDeviceRequest (OSObject * owner, + void * arg0, + void * arg1, + void * arg2, + void * arg3 ); + + // IOKit methods + virtual bool init(); + virtual bool start( IOService * provider ); + virtual void stop( IOService *provider ); + virtual void free(); + + // IOUSBHubDevice methods + virtual bool IsRootHub(void); + virtual UInt32 RequestExtraPower(UInt32 requestedPower); + virtual void ReturnExtraPower(UInt32 returnedPower); + + // + virtual UInt32 RequestSleepPower(UInt32 requestedPower); + virtual void ReturnSleepPower(UInt32 returnedPower); + + // a non static but non-virtual function + IOReturn DeviceRequestWorker(IOUSBDevRequest *request, UInt32 noDataTimeout, UInt32 completionTimeout, IOUSBCompletion *completion); + + // IOUSBDevice methods overriden here + virtual IOReturn DeviceRequest(IOUSBDevRequest *request, IOUSBCompletion *completion = 0); + virtual IOReturn DeviceRequest(IOUSBDevRequest *request, UInt32 noDataTimeout, UInt32 completionTimeout, IOUSBCompletion *completion = 0); + + OSMetaClassDeclareReservedUsed(IOUSBRootHubDevice, 0); + virtual IOReturn GetDeviceInformation(UInt32 *info); + + OSMetaClassDeclareReservedUsed(IOUSBRootHubDevice, 1); + virtual void InitializeExtraPower(UInt32 maxPortCurrent, UInt32 totalExtraCurrent); + + OSMetaClassDeclareReservedUsed(IOUSBRootHubDevice, 2); + virtual void SetSleepCurrent(UInt32 sleepCurrent); + + OSMetaClassDeclareReservedUsed(IOUSBRootHubDevice, 3); + virtual UInt32 GetSleepCurrent(); + + OSMetaClassDeclareReservedUnused(IOUSBRootHubDevice, 4); +}; + +#endif /* _IOKIT_IOUSBROOTHUBDEVICE_H */ + Index: branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUFIStorageServices.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUFIStorageServices.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUFIStorageServices.h (revision 885) @@ -0,0 +1,136 @@ +/* + * 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_UFI_STORAGE_SERVICES_H_ +#define _IOKIT_UFI_STORAGE_SERVICES_H_ + +#if defined(KERNEL) && defined(__cplusplus) + +#include +#include +#include + + +class IOUFIStorageServices : public IOBlockStorageDevice +{ + + OSDeclareDefaultStructors ( IOUFIStorageServices ) + +private: + bool fMediaChanged; + bool fMediaPresent; + +protected: + + IOUSBMassStorageUFIDevice * fProvider; + + UInt64 fMaxReadBlocks; + UInt64 fMaxWriteBlocks; + + virtual bool attach ( IOService * provider ); + virtual void detach ( IOService * provider ); + + // Reserve space for future expansion. + struct IOUFIStorageServicesExpansionData { }; + IOUFIStorageServicesExpansionData *fIOUFIStorageServicesReserved; + +public: + + virtual IOReturn message ( UInt32 type, IOService * provider, void * argument ); + + static void AsyncReadWriteComplete ( void * clientData, + IOReturn status, + UInt64 actualByteCount ); + + // Deprecated + virtual IOReturn doAsyncReadWrite ( IOMemoryDescriptor * buffer, + UInt32 block, + UInt32 nblks, + IOStorageCompletion completion ); + + virtual IOReturn doAsyncReadWrite ( IOMemoryDescriptor * buffer, + UInt64 block, + UInt64 nblks, + IOStorageAttributes * attributes, + IOStorageCompletion * completion ); + + virtual IOReturn doSyncReadWrite ( IOMemoryDescriptor * buffer, + UInt32 block, + UInt32 nblks ); + + virtual IOReturn doEjectMedia ( void ); + + virtual IOReturn doFormatMedia ( UInt64 byteCapacity ); + + virtual UInt32 doGetFormatCapacities ( UInt64 * capacities, + UInt32 capacitiesMaxCount ) const; + + virtual IOReturn doLockUnlockMedia ( bool doLock ); + + virtual IOReturn doSynchronizeCache ( void ); + + virtual char * getVendorString ( void ); + + virtual char * getProductString ( void ); + + virtual char * getRevisionString ( void ); + + virtual char * getAdditionalDeviceInfoString ( void ); + + virtual IOReturn reportBlockSize ( UInt64 * blockSize ); + + virtual IOReturn reportEjectability ( bool * isEjectable ); + + virtual IOReturn reportLockability ( bool * isLockable ); + + virtual IOReturn reportMediaState ( bool * mediaPresent, bool * changed ); + + virtual IOReturn reportPollRequirements ( bool * pollIsRequired, + bool * pollIsExpensive ); + + virtual IOReturn reportMaxValidBlock ( UInt64 * maxBlock ); + + virtual IOReturn reportRemovability ( bool * isRemovable ); + + virtual IOReturn reportWriteProtection ( bool * isWriteProtected ); + + virtual IOReturn getWriteCacheState ( bool * enabled ); + + virtual IOReturn setWriteCacheState ( bool enabled ); + + // Space reserved for future expansion. + OSMetaClassDeclareReservedUnused( IOUFIStorageServices, 1 ); + OSMetaClassDeclareReservedUnused( IOUFIStorageServices, 2 ); + OSMetaClassDeclareReservedUnused( IOUFIStorageServices, 3 ); + OSMetaClassDeclareReservedUnused( IOUFIStorageServices, 4 ); + OSMetaClassDeclareReservedUnused( IOUFIStorageServices, 5 ); + OSMetaClassDeclareReservedUnused( IOUFIStorageServices, 6 ); + OSMetaClassDeclareReservedUnused( IOUFIStorageServices, 7 ); + OSMetaClassDeclareReservedUnused( IOUFIStorageServices, 8 ); + +}; + +#endif /* defined(KERNEL) && defined(__cplusplus) */ + +#endif /* _IOKIT_UFI_STORAGE_SERVICES_H_ */ Index: branches/azimutz/Cleancut/i386/include/IOKit/usb/USBTracepoints.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/usb/USBTracepoints.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/usb/USBTracepoints.h (revision 885) @@ -0,0 +1,662 @@ +/* + * Copyright � 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_USB_FAMILY_TRACEPOINTS__ +#define __IOKIT_IO_USB_FAMILY_TRACEPOINTS__ + +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define USB_SYSCTL "debug.USB" +#define kUSBTypeDebug 'USBD' +#define DEBUG_UNUSED( X ) ( void )( X ) + + extern UInt32 gUSBStackDebugFlags; + + typedef struct USBSysctlArgs + { + uint32_t type; + uint32_t operation; + uint32_t debugFlags; + } USBSysctlArgs; + + enum + { + kUSBOperationGetFlags = 0, + kUSBOperationSetFlags = 1 + }; + + // the following bits/masks are for use in the usb boot args + // e.g. boot-args="usb=0x102" will turn on Trace Points and set the EHCI retry count to 1 + // the bits can also be set with a sysctl call + enum + { + kUSBEnableDebugLoggingBit = 0, // bit 0 currently not used + kUSBEnableTracePointsBit = 1, // bit 1 used to turn on Trace Points when a USB controller first loads + kUSBEnableErrorLogBit = 2, // bit 2 (4) turns level 1 log for errors + kUSBDebugRetryCountShift = 8, // bits 8 and 9 will set the retry count for low level bus transactions + kUSBDebugRetryCountReserved = 9, // must be 1, 2, or 3 (0 is invalid, 3 is the default) + + kUSBEnableDebugLoggingMask = (1 << kUSBEnableDebugLoggingBit), + kUSBEnableTracePointsMask = (1 << kUSBEnableTracePointsBit), + kUSBDebugRetryCountMask = (3 << kUSBDebugRetryCountShift), + kUSBEnableErrorLogMask = (1 << kUSBEnableErrorLogBit) + }; + + + /* Kernel Tracepoints + * + * Kernel tracepoints are a logging mechanism reduces the size of a log-laden binary. + * Codes are placed into a buffer, from the kernel, and picked up by a userspace + * tool that displays a unique log message for each tracepoint. Additionally, each + * tracepoint may contain up-to four 32-bit (may change with LP64) arguments. + * + * To add a tracepoint, use the code below as an example: + * USBTrace( kUSBTController, kTPControllerStart, (uintptr_t)myArgValue ); + * Next, add the corresponding tracepoint code in the USBTracer tool, using + * the existing examples. Avoid using confidential information in the log strings. + * Some functions have a argument counter, to signify which of the function's tracepoints + * are actually being logged. When adding a tracepoint using an existing code, you + * must verify that you increment this argument counter properly. + * + * The trace codes consist of the following: + * + * ---------------------------------------------------------------------- + *| Class (8) | SubClass (8) | USBGroup(6) | Code (8) |Func | + *| DBG_IOKIT | DBG_IOUSB | | |Qual(2)| + * ---------------------------------------------------------------------- + * + * DBG_IOKIT(05h) DBG_IOUSB(2Dh) + * + * See and IOTimeStamp.h for more details. + */ + + + // USB groupings (max of 64) + enum + { + // Family groupings + kUSBTController = 0, + kUSBTControllerUserClient = 1, + + kUSBTDevice = 2, + kUSBTDeviceUserClient = 3, + + kUSBTHub = 4, + kUSBTHubPort = 5, + kUSBTHSHubUserClient = 6, + kUSBTHID = 7, + kUSBTPipe = 8, + + kUSBTInterfaceUserClient = 9, + + kUSBTEnumeration = 10, // Tracepoints in various components to debug USB enumeration + + + // UIM groupings + kUSBTUHCI = 11, + kUSBTUHCIUIM = 12, + kUSBTUHCIInterrupts = 13, + + kUSBTOHCI = 14, + kUSBTOHCIInterrupts = 15, + + kUSBTEHCI = 20, + kUSBTEHCIHubInfo = 22, + kUSBTEHCIInterrupts = 23, + + // 30-33 reserved + + // 21-25 reserved + kUSBTHubPolicyMaker = 35, + kUSBTCompositeDriver = 36, + + // Actions + kUSBTOutstandingIO = 42, + + // kUSBAudio + kUSBAudio = 50 + + // 61-63 reserved + }; + + // USB Controller Tracepoints 0x052D0000 - 0x052D03FF + // kUSBTController + enum + { + kTPControllerStart = 1, + kTPControllerControlPacketHandler = 2, + kTPControllerMakeDevice = 3, + kTPControllerMakeHubDevice = 4, + kTPControllerCreateRootHubDevice = 5, + kTPControllerClearTTHandler = 6, + kTPControllerClearTT = 7, + kTPControllerDoCreateEP = 8, + kTPControllerReadV2 = 9, + kTPControllerReturnIsochDoneQueue = 10, + kTPControllersetPowerState = 11, + kTPControllerCheckPowerModeBeforeGatedCall = 12, + kTPControllerGatedPowerChange = 13, + kTPControllerCheckForRootHubChanges = 14, + kTPControllerRootHubQueueInterruptRead = 15, + kTPControllerRootHubTimer = 16, + kTPControllerDisjointCompletion = 17, + kTPControllerCheckForDisjointDescriptor = 18, + kTPControllerRead = 19, + kTPControllerV3Start = 20, + kTPAllocatePowerStateArray = 21, + kTPInitForPM = 22, + kTPIsocIOLL = 23, + kTPIsocIO = 24, + kTPControllerWrite = 25, + kTPCompletionCall = 26, + kTPControlTransaction = 27, + kTPInterruptTransaction = 28, + kTPInterruptTransactionData = 29, + kTPBulkTransaction = 30, + kTPBulkTransactionData = 31, + kTPIsocTransaction = 32, + kTPInterruptPacketHandler = 33, + kTPBulkPacketHandler = 34, + kTPDevZeroLock = 35, + kTPControlPacketHandlerData = 36, + kTPDoIOTransferIntrSync = 37, + kTPDoIOTransferBulkSync = 38, + kTPBulkPacketHandlerData = 39, + kTPInterruptPacketHandlerData = 40 + }; + + // USB Device Tracepoints + // kUSBTDevice + enum + { + kTPDeviceInit = 1, + kTPDeviceMessage = 2, + kTPDeviceResetDevice = 3, + kTPDeviceGetFullConfigurationDescriptor = 4, + kTPDeviceGetDeviceDescriptor = 5, + kTPDeviceGetConfigDescriptor = 6, + kTPDeviceSetConfiguration = 7, + kTPDeviceSetFeature = 8, + kTPDeviceDeviceRequest = 9, + kTPDeviceGetConfiguration = 10, + kTPDeviceGetDeviceStatus = 11, + kTPDeviceSuspendDevice = 12, + kTPDeviceReEnumerateDevice = 13, + kTPDeviceConfigLock = 14 + }; + + // USB Pipe Tracepoints + // kUSBTPipe + enum + { + kTPPipeInitToEndpoint = 1, + kTPBulkPipeRead = 2, + kTPBulkPipeWrite = 3, + kTPIsocPipeRead = 4, + kTPIsocPipeWrite = 5, + kTPIsocPipeReadLL = 6, + kTPIsocPipeWriteLL = 7, + kTPIBulkReadTS = 8, + kTPPipeControlRequest = 9, + kTPPipeControlRequestMemDesc = 10 + }; + + + // USB kUSBTControllerUserClient Tracepoints + // kUSBTControllerUserClient + enum + { + kTPControllerUCStart = 1, + kTPControllerUCOpen = 2, + kTPControllerUCReadRegister = 3, + kTPControllerUCWriteRegister = 4 + }; + + // USB kUSBTDeviceUserClient Tracepoints + // kUSBTDeviceUserClient + enum + { + kTPDeviceUCDeviceRequestIn = 1, + kTPDeviceUCDeviceRequestOut = 2, + kTPDeviceUCChangeOutstandingIO = 3, + kTPDeviceUCGetGatedOutstandingIO = 4, + kTPDeviceUCReqComplete = 5 + }; + + // USB InterfaceUserClient Tracepoints + // kUSBTInterfaceUserClient + enum + { + kTPInterfaceUCReadPipe = 1, + kTPInterfaceUCWritePipe = 2, + kTPInterfaceUCControlRequestOut = 3, + kTPInterfaceUCControlRequestIn = 4, + kTPInterfaceUCDoIsochPipeAsync = 5, + kTPInterfaceUCLowLatencyPrepareBuffer = 6, + kTPInterfaceUCChangeOutstandingIO = 7, + kTPInterfaceUCReqComplete = 8, + kTPInterfaceUCIsoReqComplete = 9, + kTPInterfaceUCLLIsoReqComplete = 10 + }; + + + // USB HSHubUserClient Tracepoints + // kUSBTHSHubUserClient + enum + { + kTPHSHubUCInitWithTask = 1, + kTPHSHubUCStart = 2, + kTPHSHubUCClose = 3, + kTPHSHubUCGetNumberOfPorts = 4, + kTPHSHubUCGetLocationID = 5, + kTPHSHubUCPutPortIntoTestMode = 6, + kTPHSHubUCSupportsIndicators = 7, + kTPHSHubUCSetIndicatorForPort = 8, + kTPHSHubUCGetPortIndicatorControl = 9, + kTPHSHubUCSetIndicatorsToAutomatic = 10, + kTPHSHubUCGetPowerSwitchingMode = 11, + kTPHSHubUCGetPortPower = 12, + kTPHSHubUCSetPortPower = 13, + kTPHSHubUCDisablePwrMgmt = 14 + }; + + // USB Hub Tracepoints + // kUSBTHub + enum + { + kTPHubStart = 1, + kTPHubMessage = 2, + kTPHubWillTerminate = 3, + kTPHubPowerStateWillChangeTo = 4, + kTPHubPowerChangeDone = 5, + kTPHubConfigureHub = 6, + kTPHubCheckPowerPowerRequirements = 7, + kTPHubHubPowerChange = 8, + kTPHubAreAllPortsDisconnectedOrSuspended= 9, + kTPHubSuspendPorts = 10, + kTPHubSetPortFeature = 11, + kTPHubClearPortFeature = 12, + kTPHubDoPortAction = 13, + kTPHubInterruptReadHandler = 14, + kTPHubResetPortZero = 15, + kTPHubProcessStateChanged = 16, + kTPHubRearmInterruptRead = 17, + kTPHubDoDeviceRequest = 18, + kTPHubWaitForPortResumes = 19, + kTPHubResetMyPort = 20, + kTPHubDecrementOutstandingIO = 21, + kTPHubChangeOutstandingIO = 22, + kTPHubChangeRaisedPowerState = 23, + kTPHubChangeOutstandingResumes = 24, + kTPHubEnterTestMode = 25, + kTPHubLeaveTestMode = 26, + kTPHubPutPortIntoTestMode = 27, + kTPHubGetPortIndicatorControl = 28, + kTPHubSetIndicatorsToAutomatic = 29, + kTPHubGetPortPower = 30, + kTPHubEnsureUsability = 31, + kTPHubCheckPowerRequirements = 32, + kTPHubWaitForPowerOn = 33, + kTPHubDoPortActionLock = 34, + kTPHubCheckForDeadDevice = 35 + }; + + // USB HubPort Tracepoints + // kUSBTHubPort + enum + { + kTPHubPortStop = 1, + kTPHubPortAddDevice = 2, + kTPHubPortSuspendPort = 3, + kTPHubPortFatalError = 4, + kTPHubPortAddDeviceResetChangeHandler = 5, + kTPHubPortHandleResetPortHandler = 6, + kTPHubPortDefaultOverCrntChangeHandler = 7, + kTPHubPortDefaultConnectionChangeHandler = 8, + kTPHubPortReleaseDevZeroLock = 9, + kTPHubPortDetachDevice = 10, + kTPHubPortGetDevZeroDescriptorWithRetries = 11, + kTPHubPortDisplayOverCurrentNotice = 12, + kTPHubPortWakeSuspendCommand = 13, + kTPHubPortWaitForSuspendCommand = 14, + kTPHubPortEnablePowerAfterOvercurrent = 15 + }; + + // USB HID Tracepoints + // kUSBTHID + enum + { + kTPHIDStart = 1, + kTPHIDpowerStateWillChangeTo = 2, + kTPHIDsetPowerState = 3, + kTPHIDpowerStateDidChangeTo = 4, + kTPHIDpowerChangeDone = 5, + kTPHIDhandleStart = 6, + kTPHIDClearFeatureEndpointHalt = 7, + kTPHIDHandleReport = 8, + kTPHIDSuspendPort = 9, + kTPHIDAbortAndSuspend = 10, + kTPHIDClaimPendingRead = 11, + kTPHIDChangeOutstandingIO = 12, + kTPHIDRearmInterruptRead = 13, + kTPHIDInitializeUSBHIDPowerManagement = 14, + kTPHIDInterruptRead = 15, + kTPHIDInterruptReadError = 16, + kTPHIDCheckForDeadDevice = 17 + }; + + // USB Enumeration Tracepoints + // kUSBTEnumeration + enum + { + kTPEnumerationProcessStatusChanged = 1, + kTPEnumerationInitialGetPortStatus = 2, + kTPEnumerationCallAddDevice = 3, + kTPEnumerationAddDevice = 4, + kTPEnumerationResetPort = 5, + kTPEnumerationAddDeviceResetChangeHandler = 6, + kTPEnumerationRegisterService = 7, + kTPEnumerationLowSpeedDevice = 8, + kTPEnumerationFullSpeedDevice = 9 + + }; + + // USB UHCI Tracepoints + // kUSBTUHCI + enum + { + kTPUHCIMessage = 1, + kTPUHCIGetFrameNumber = 2, + kTPUHCIScavengeIsocTransactions = 3, + kTPUHCIScavengeQueueHeads = 4, + kTPUHCIAllocateQH = 5, + kTPUHCIRootHubStatusChange = 6, + kTPUHCIRHSuspendPort = 7, + kTPUHCIRHHoldPortReset = 8, + kTPUHCIRHResumePortCompletion = 9, + kTPUHCISuspendController = 10, + KTPUHCIResumeController = 11, + KTPUHCIResetControllerState = 12, + KTPUHCIRestartControllerFromReset = 13, + KTPUHCIEnableInterrupts = 14, + KTPUHCIDozeController = 15, + KTPUHCIWakeFromDoze = 16, + KTPUHCIPowerState = 17, + }; + + + // USB UHCI Tracepoints + // kUSBTUHCIUIM + enum + { + kTPUHCIUIMCreateControlEndpoint = 1, + kTPUHCIUIMCreateBulkEndpoint = 2, + kTPUHCIUIMCreateInterruptEndpoint = 3, + kTPUHCIUIMCreateIsochEndpoint = 4, + kTPUHCIUIMCreateIsochTransfer = 5, + kTPUHCIUIMDeleteEndpoint = 6, + kTPUHCIUIMUnlinkQueueHead = 7, + kTPUHCIUIMCheckForTimeouts = 8, + kTPUHCIUIMReturnOneTransaction = 9, + kTPUHCIUIMAllocateTDChain = 10, + kTPUHCIUIMAddIsochFramesToSchedule = 11, + kTPUHCIUIMAbortIsochEP = 12, + kTPUHCIUIMCreateInterruptTransfer = 13, + kTPUHCIUIMHandleEndpointAbort = 14 + }; + + // USB UHCI Interrupt Tracepoints + // kUSBTUHCIInterrupts + enum + { + kTPUHCIInterruptsGetFrameNumberInternal = 1, + kTPUHCIInterruptsFilterInterrupt = 2, + kTPUHCIInterruptsHandleInterrupt = 3, + kTPUHCIUpdateFrameList = 4 + }; + + // USB EHCI Tracepoints + // kUSBTEHCI + enum + { + kTPEHCIRootHubResetPort = 1, + kTPEHCIRootHubPortEnable = 2, + kTPEHCIRootHubPortSuspend = 3, + // kTPEHCIRootHubStatusChange = 4, + kTPEHCIRHResumePortCompletion = 5, + kTPEHCIUIMFinalize = 6, + kTPEHCIGetFrameNumber32 = 7, + kTPEHCIGetFrameNumber = 8, + kTPEHCIAllocateQH = 9, + kTPEHCIEnableAsyncSchedule = 10, + kTPEHCIDisableAsyncSchedule = 11, + kTPEHCIEnablePeriodicSchedule = 12, + kTPEHCIDisablePeriodicSchedule = 13, + kTPEHCIMessage = 14, + kTPEHCIMakeEmptyEndPoint = 15, + kTPEHCIAllocateTDs = 16, + kTPEHCIMungeECHIStatus = 17, + kTPEHCIScavengeIsocTransactions = 18, + kTPEHCIScavengeAnEndpointQueue = 19, + kTPEHCIScavengeCompletedTransactions = 20, + kTPEHCICreateBulkEndpoint = 21, + kTPEHCICreateBulkTransfer = 22, + + kTPEHCICreateInterruptEndpoint = 24, + kTPEHCICreateIsochEndpoint = 25, + kTPEHCIAbortIsochEP = 26, + kTPEHCIHandleEndpointAbort = 27, + kTPEHCICreateInterruptTransfer = 28, + kTPEHCIUnlinkAsyncEndpoint = 29, + kTPEHCIDeleteEndpoint = 30, + kTPEHCICreateHSIsochTransfer = 31, + kTPEHCICreateSplitIsochTransfer = 32, + kTPEHCICreateIsochTransfer = 33, + kTPEHCIAddIsocFramesToSchedule = 34, + kTPEHCIReturnOneTransaction = 35, + kTPEHCICheckEDListForTimeouts = 36, + kTPEHCISuspendUSBBus = 37, + kTPEHCICheckForTimeouts = 38, + kTPEHCIResumeUSBBus = 39, + kTPEHCIRestartUSBBus = 40, + kTPEHCIResetControllerState = 41, + kTPEHCIDozeController = 42, + kTPEHCIWakeControllerFromDoze = 43, + kTPEHCIEnableInterrupts = 44, + kTPEHCIPowerState = 45, + kTPEHCIStopUSBBus = 46, + kTPEHCIRestartControllerFromReset = 47 + }; + + // USB EHCI Interrupt Tracepoints + // kUSBTEHCIInterrupts + enum + { + kTPEHCIInterruptsPollInterrupts = 1, + kTPEHCIInterruptsPrimaryInterruptFilter = 2, + kTPEHCIUpdateFrameList = 3, + }; + + + // USB EHCI Interrupt Tracepoints + // kUSBTEHCIHubInfo + enum + { + kTPEHCIAvailableIsochBandwidth = 1, + kTPEHCIAllocateIsochBandwidth = 2 + }; + + // USB OHCI Tracepoints + // kUSBTOHCI + enum + { + kTPOHCIInitialize = 1, + kTPOHCICreateGeneralTransfer = 2, + kTPOHCIAbortEndpoint = 3, + kTPOHCIDeleteEndpoint = 4, + kTPOHCIEndpointStall = 5, + kTPOHCICreateIsochTransfer = 6, + kTPOHCIAllocateTD = 7, + kTPOHCIAllocateITD = 8, + kTPOHCIAllocateED = 9, + kTPOHCIProcessCompletedITD = 10, + kTPOHCIReturnTransactions = 11, + kTPOHCIMessage = 12, + KTPOHCISuspendUSBBus = 13, + KTPOHCIResumeUSBBus = 14, + KTPOHCIResetControllerState = 15, + KTPOHCIRestartControllerFromReset = 16, + KTPOHCIEnableInterrupts = 17, + KTPOHCIDozeController = 18, + KTPOHCIWakeControllerFromDoze = 19, + KTPOHCIPowerState = 20, + kTPOHCIDoneQueueCompletion = 21 + }; + + // USB OHCI Interrupt Tracepoints + // kUSBTOHCIInterrupts + enum + { + kTPOHCIInterruptsPollInterrupts = 1, + kTPOHCIInterruptsPrimaryInterruptFilter = 2, + kTPOHCIUpdateFrameList = 3 + }; + + + // USB HubPolicyMaker Tracepoints + // kUSBTHubPolicyMaker + enum + { + kTPSetPowerState = 1 + }; + + // USB CompositeDriver Tracepoints + // kUSBTCompositeDriver + enum + { + kTPCompositeDriverConfigureDevice = 1 + }; + + // USB USB OutstandingIO Tracepoints + // kUSBTOutstandingIO + enum + { + kTPDeviceUCDecrement = 1, + kTPDeviceUCIncrement = 2, + kTPInterfaceUCDecrement = 3, + kTPInterfaceUCIncrement = 4, + kTPHubDecrement = 5, + kTPHubIncrement = 6, + kTPHIDDecrement = 7, + kTPHIDIncrement = 8 + }; + + // USB Audio driver Tracepoints + // kUSBAudio + enum + { + kTPAudioDriverRead = 1, + kTPAudioDriverCoalesceInputSamples = 2, + kTPAudioDriverCoalesceError = 3, + kTPAudioDriverCoalesce = 4, + kTPAudioDriverReadHandler = 5, + kTPAudioDriverCoalesceError2 = 6, + kTPAudioDriverConvertInputSamples = 7 + }; + + // Tracepoint macros. +#define USB_TRACE(USBClass, code, funcQualifier) ( ( ( DBG_IOKIT & 0xFF ) << 24) | ( ( DBG_IOUSB & 0xFF ) << 16 ) | ( ( USBClass & 0x3F ) << 10 ) | ( ( code & 0xFF ) << 2 ) | ( funcQualifier & 0x3 ) ) + +#define kTPAllUSB USB_TRACE ( 0, 0, 0 ) + +#define USB_CONTROLLER_TRACE(code) USB_TRACE( kUSBTController, code, DBG_FUNC_NONE ) +#define USB_CONTROLLER_UC_TRACE(code) USB_TRACE( kUSBTControllerUserClient, code, DBG_FUNC_NONE ) +#define USB_DEVICE_TRACE(code) USB_TRACE( kUSBTDevice, code, DBG_FUNC_NONE ) +#define USB_DEVICE_UC_TRACE(code) USB_TRACE( kUSBTDeviceUserClient, code, DBG_FUNC_NONE ) + +#define USB_HUB_TRACE(code) USB_TRACE( kUSBTHub, code, DBG_FUNC_NONE ) +#define USB_HUB_PORT_TRACE(code) USB_TRACE( kUSBTHubPort, code, DBG_FUNC_NONE ) +#define USB_HUB_UC_TRACE(code) USB_TRACE( kUSBTHSHubUserClient, code, DBG_FUNC_NONE ) +#define USB_HID_TRACE(code) USB_TRACE( kUSBTHID, code, DBG_FUNC_NONE ) +#define USB_PIPE_TRACE(code) USB_TRACE( kUSBTPipe, code, DBG_FUNC_NONE ) + +#define USB_INTERFACE_UC_TRACE(code) USB_TRACE( kUSBTInterfaceUserClient, code, DBG_FUNC_NONE ) + +#define USB_ENUMERATION_TRACE(code) USB_TRACE( kUSBTEnumeration, code, DBG_FUNC_NONE ) + +#define USB_UHCI_TRACE(code) USB_TRACE( kUSBTUHCI, code, DBG_FUNC_NONE ) +#define USB_UHCI_UIM_TRACE(code) USB_TRACE( kUSBTUHCIUIM, code, DBG_FUNC_NONE ) +#define USB_UHCI_INTERRUPTS_TRACE(code) USB_TRACE( kUSBTUHCIInterrupts, code, DBG_FUNC_NONE ) + +#define USB_OHCI_TRACE(code) USB_TRACE( kUSBTOHCI, code, DBG_FUNC_NONE ) +#define USB_OHCI_INTERRUPTS_TRACE(code) USB_TRACE( kUSBTOHCIInterrupts, code, DBG_FUNC_NONE ) + +#define USB_EHCI_TRACE(code) USB_TRACE( kUSBTEHCI, code, DBG_FUNC_NONE ) +#define USB_EHCI_HUBINFO_TRACE(code) USB_TRACE( kUSBTEHCIHubInfo, code, DBG_FUNC_NONE ) +#define USB_EHCI_INTERRUPTS_TRACE(code) USB_TRACE( kUSBTEHCIInterrupts, code, DBG_FUNC_NONE ) + +#define USB_HUB_POLICYMAKER_TRACE(code) USB_TRACE( kUSBTHubPolicyMaker, code, DBG_FUNC_NONE ) +#define USB_COMPOSITE_DRIVER_TRACE(code) USB_TRACE( kUSBTCompositeDriver, code, DBG_FUNC_NONE ) + +#define USB_OUTSTANDING_IO_TRACE(code) USB_TRACE( kUSBTOutstandingIO, code, DBG_FUNC_NONE ) + +#define USB_AUDIO_DRIVER_TRACE(code) USB_TRACE( kUSBAudio, code, DBG_FUNC_NONE ) + +#ifdef KERNEL + +#include + +#define USBTrace(USBClass, code, a, b, c, d) { \ + if (gUSBStackDebugFlags & kUSBEnableTracePointsMask) { \ + IOTimeStampConstant( USB_TRACE(USBClass, code, DBG_FUNC_NONE), a, b, c, d ); \ + } \ + } + +#define USBTrace_Start(USBClass, code, a, b, c, d) { \ + if (gUSBStackDebugFlags & kUSBEnableTracePointsMask) { \ + IOTimeStampConstant( USB_TRACE(USBClass, code, DBG_FUNC_START), a, b, c, d ); \ + } \ + } + +#define USBTrace_End(USBClass, code, a, b, c, d) { \ + if (gUSBStackDebugFlags & kUSBEnableTracePointsMask) { \ + IOTimeStampConstant( USB_TRACE(USBClass, code, DBG_FUNC_END), a, b, c, d ); \ + } \ + } + +#endif + + + +#ifdef __cplusplus +} +#endif + + +#endif /* __IOKIT_IO_USB_FAMILY_TRACEPOINTS__ */ Index: branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBWorkLoop.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBWorkLoop.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBWorkLoop.h (revision 885) @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2001-2006 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_IOUSBWORKLOOP_H +#define _IOKIT_IOUSBWORKLOOP_H + +#include + +/*! + @class IOUSBWorkLoop + @abstract Subclass of IOWorkloop that allows the USB stack to more finely control sleep and wake. + */ +class IOUSBWorkLoop : public IOWorkLoop +{ + OSDeclareDefaultStructors(IOUSBWorkLoop) + +protected: + void * fSleepToken; +#ifndef __OPEN_SOURCE__ + lck_grp_t * fLockGroup; +#endif + bool init ( const char * controllerLocation ); + void free ( void ); + + // Overrides to check for sleeping + virtual void closeGate(); + virtual bool tryCloseGate(); + +public: + // Create a workloop + static IOUSBWorkLoop * workLoop(const char * controllerLocation); + + // Put workloop to sleep (Must have gate closed, opens gate if successful) + virtual IOReturn sleep(void *token); + + // Wake workloop up (closes gate if successful) + virtual IOReturn wake(void *token); + + void CloseGate(void); + void OpenGate(void); +}; + +#endif /* ! _IOKIT_IOUSBWORKLOOP_H */ + Index: branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBUserClient.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBUserClient.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBUserClient.h (revision 885) @@ -0,0 +1,144 @@ +/* + * Copyright (c) 1998-2006 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_IOUSBUSERCLIENT_H +#define _IOKIT_IOUSBUSERCLIENT_H + +// these are the new User Client method names +enum { + kUSBDeviceUserClientOpen, + kUSBDeviceUserClientClose, + kUSBDeviceUserClientSetConfig, + kUSBDeviceUserClientGetConfig, + kUSBDeviceUserClientGetConfigDescriptor, + kUSBDeviceUserClientGetFrameNumber, + kUSBDeviceUserClientDeviceRequestOut, + kUSBDeviceUserClientDeviceRequestIn, + kUSBDeviceUserClientCreateInterfaceIterator, + kUSBDeviceUserClientResetDevice, + kUSBDeviceUserClientSuspend, + kUSBDeviceUserClientAbortPipeZero, + kUSBDeviceUserClientReEnumerateDevice, + kUSBDeviceUserClientGetMicroFrameNumber, + kUSBDeviceUserClientGetFrameNumberWithTime, + kUSBDeviceUserClientSetAsyncPort, + kUSBDeviceUserClientGetDeviceInformation, + kUSBDeviceUserClientRequestExtraPower, + kUSBDeviceUserClientReturnExtraPower, + kUSBDeviceUserClientGetExtraPowerAllocated, + kIOUSBLibDeviceUserClientNumCommands + }; + +enum { + kUSBInterfaceUserClientOpen, + kUSBInterfaceUserClientClose, + kUSBInterfaceUserClientGetDevice, + kUSBInterfaceUserClientSetAlternateInterface, + kUSBInterfaceUserClientGetFrameNumber, + kUSBInterfaceUserClientGetPipeProperties, + kUSBInterfaceUserClientReadPipe, + kUSBInterfaceUserClientWritePipe, + kUSBInterfaceUserClientGetPipeStatus, + kUSBInterfaceUserClientAbortPipe, + kUSBInterfaceUserClientResetPipe, + kUSBInterfaceUserClientClearPipeStall, + kUSBInterfaceUserClientControlRequestOut, + kUSBInterfaceUserClientControlRequestIn, + kUSBInterfaceUserClientSetPipePolicy, + kUSBInterfaceUserClientGetBandwidthAvailable, + kUSBInterfaceUserClientGetEndpointProperties, + kUSBInterfaceUserClientLowLatencyPrepareBuffer, + kUSBInterfaceUserClientLowLatencyReleaseBuffer, + kUSBInterfaceUserClientGetMicroFrameNumber, + kUSBInterfaceUserClientGetFrameListTime, + kUSBInterfaceUserClientGetFrameNumberWithTime, + kUSBInterfaceUserClientSetAsyncPort, + kUSBInterfaceUserClientReadIsochPipe, + kUSBInterfaceUserClientWriteIsochPipe, + kUSBInterfaceUserClientLowLatencyReadIsochPipe, + kUSBInterfaceUserClientLowLatencyWriteIsochPipe, + kUSBInterfaceUserClientGetConfigDescriptor, + kIOUSBLibInterfaceUserClientNumCommands + }; + + +#if KERNEL +#include +#include +#include + +//================================================================================================ +// +// Structure declarations +// +//================================================================================================ +// +typedef struct IOUSBUserClientAsyncParamBlock IOUSBUserClientAsyncParamBlock; + +struct IOUSBUserClientAsyncParamBlock +{ + OSAsyncReference64 fAsyncRef; + uint32_t fAsyncCount; + uint32_t fMax; + IOMemoryDescriptor * fMem; + IOUSBDevRequestDesc req; +}; + +typedef struct IOUSBInterfaceUserClientISOAsyncParamBlock IOUSBInterfaceUserClientISOAsyncParamBlock; +struct IOUSBInterfaceUserClientISOAsyncParamBlock +{ + OSAsyncReference64 fAsyncRef; + uint32_t fAsyncCount; + mach_vm_size_t frameLen; // In bytes + mach_vm_address_t frameBase; // In user task + IOMemoryDescriptor * dataMem; + IOMemoryDescriptor * countMem; + uint64_t numFrames; + IOUSBIsocFrame frames[0]; // Must be the last one +}; + + +//================================================================================================ +// +// This class is used to add an IOProviderMergeProperties dictionary entry to a provider's +// property list, thus providing a tie between hardware and a CFBundle at hardware +// load time. This property usually contains the user client class name and the CFPlugInTypes UUID's +// but it can contain other properties. +// +//================================================================================================ +// +class IOUSBUserClientInit : public IOService +{ + OSDeclareDefaultStructors(IOUSBUserClientInit); + +public: + + virtual bool start(IOService * provider) ; + virtual bool MergeDictionaryIntoProvider(IOService * provider, OSDictionary * mergeDict); + virtual bool MergeDictionaryIntoDictionary(OSDictionary * sourceDictionary, OSDictionary * targetDictionary); +}; + +#endif // KERNEL + +#endif /* ! _IOKIT_IOUSBUSERCLIENT_H */ + Index: branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBMassStorageClass.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBMassStorageClass.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBMassStorageClass.h (revision 885) @@ -0,0 +1,507 @@ +/* + * 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_IOUSBMASSSTORAGECLASS_H +#define _IOKIT_IOUSBMASSSTORAGECLASS_H + +// Headers for general IOKit definitions +#include +#include +#include +#include + +// Headers for USB specific definitions +#include +#include +#include +#include + +// Headers for SCSI Protocol support definitions +#include + +// BSD includes +#include + +#define UNUSED(x) ((void)x) + + +#pragma mark - +#pragma mark Vendor Specific Device Support +#define kIOUSBMassStorageCharacteristics "USB Mass Storage Characteristics" +#define kIOUSBMassStoragePreferredSubclass "Preferred Subclass" +#define kIOUSBMassStoragePreferredProtocol "Preferred Protocol" +#define kIOUSBMassStorageResetOnResume "Reset On Resume" +#define kIOUSBMassStorageUseStandardUSBReset "Use Standard USB Reset" +#define kIOUSBKnownCSWTagIssues "Known CSW Tag Issues" +#define kIOUSBMassStorageMaxLogicalUnitNumber "Max Logical Unit Number" +#define kIOPropertyIOUnitKey "IOUnit" +#define kIOUSBMassStorageDoNotMatch "Do Not Match MSC" +#define kIOUSBMassStorageDoNotOperate "Do Not Operate" +#define kIOUSBMassStorageEnableSuspendResumePM "Enable Port Suspend-Resume PM" + +enum +{ + kUSBDAddressLength = 10 +}; + +#pragma mark - +#pragma mark CBI Protocol Strutures +// Structure for the global PB's +struct CBIRequestBlock +{ + SCSITaskIdentifier request; + IOUSBDevRequest cbiDevRequest; + SCSICommandDescriptorBlock cbiCDB; + IOUSBCompletion cbiCompletion; + UInt32 currentState; + IOMemoryDescriptor * cbiPhaseDesc; + UInt8 cbiGetStatusBuffer[2]; // 2 bytes as specified in the USB spec +}; + +typedef struct CBIRequestBlock CBIRequestBlock; + +#pragma mark - +#pragma mark Bulk Only Protocol Structures + +struct StorageBulkOnlyCBW +{ + UInt32 cbwSignature; + UInt32 cbwTag; + UInt32 cbwTransferLength; + UInt8 cbwFlags; + UInt8 cbwLUN; // Bits 0-3: LUN, 4-7: Reserved + UInt8 cbwCDBLength; // Bits 0-4: CDB Length, 5-7: Reserved + UInt8 cbwCDB[16]; +}; + +typedef struct StorageBulkOnlyCBW StorageBulkOnlyCBW; + +struct StorageBulkOnlyCSW +{ + UInt32 cswSignature; + UInt32 cswTag; + UInt32 cswDataResidue; + UInt8 cswStatus; +}; + +typedef struct StorageBulkOnlyCSW StorageBulkOnlyCSW; + +struct BulkOnlyRequestBlock +{ + SCSITaskIdentifier request; + IOUSBCompletion boCompletion; + UInt32 currentState; + StorageBulkOnlyCBW boCBW; + StorageBulkOnlyCSW boCSW; + IOMemoryDescriptor * boPhaseDesc; + UInt8 boGetStatusBuffer[2]; // 2 bytes as specified in the USB spec +}; + +typedef struct BulkOnlyRequestBlock BulkOnlyRequestBlock; + + +#pragma mark - +#pragma mark IOUSBMassStorageClass definition + +class IOUSBMassStorageClass : public IOSCSIProtocolServices +{ + OSDeclareDefaultStructors(IOUSBMassStorageClass) + +private: + // ---- Member variables used by all protocols ---- + // The interface object that provides the driver with access to the + // USB so that it may talk to its device. + IOUSBInterface * fInterface; + + // The pipe objects that the driver uses to transport data through a + // pipe to the appropriate endpoint. + IOUSBPipe * fBulkInPipe; + IOUSBPipe * fBulkOutPipe; + IOUSBPipe * fInterruptPipe; + IOUSBDevRequest fUSBDeviceRequest; + UInt8 fPreferredSubclass; + UInt8 fPreferredProtocol; + + // The maximum Logical Unit Number. This is the highest valid LUN + // that the USB device supports, so if the device only supports one + // LUN, such as CBI and CB, this number will be zero. + UInt8 fMaxLogicalUnitNumber; + + // ---- Member variables used by CBI protocol ---- + bool fCBICommandStructInUse; + + CBIRequestBlock fCBICommandRequestBlock; + + // ---- Member variables used by Bulk Only protocol ---- + // Command tag, this driver just uses a sequential counter that is + // incremented for each CBW that is sent to the device. + UInt32 fBulkOnlyCommandTag; + + bool fBulkOnlyCommandStructInUse; + + // Dedicated CBW and CSW IOMemoryDescriptors are listed in the ExpansionData struct. + + // The Request block that contains all the necessary data for + // transporting a Bulk Only request across the USB. + BulkOnlyRequestBlock fBulkOnlyCommandRequestBlock; + +protected: + // Reserve space for future expansion. + struct ExpansionData + { + bool fResetInProgress; + OSSet * fClients; + IOUSBPipe * fPotentiallyStalledPipe; + bool fUseUSBResetNotBOReset; + bool fAbortCurrentSCSITaskInProgress; + IOMemoryDescriptor * fCBIMemoryDescriptor; + IOMemoryDescriptor * fBulkOnlyCBWMemoryDescriptor; + IOMemoryDescriptor * fBulkOnlyCSWMemoryDescriptor; + bool fDeviceAttached; + bool fWaitingForReconfigurationMessage; + bool fTerminating; + bool fKnownCSWTagMismatchIssues; + bool fPortSuspendResumeForPMEnabled; + bool fPortIsSuspended; + bool fRequiresResetOnResume; + bool fAutonomousSpinDownWorkAround; + UInt8 fConsecutiveResetCount; + bool fClearStallInProgress; /* OBSOLETE */ + bool fTerminationDeferred; + }; + ExpansionData * reserved; + + #define fResetInProgress reserved->fResetInProgress + #define fClients reserved->fClients + #define fPotentiallyStalledPipe reserved->fPotentiallyStalledPipe + #define fUseUSBResetNotBOReset reserved->fUseUSBResetNotBOReset + #define fAbortCurrentSCSITaskInProgress reserved->fAbortCurrentSCSITaskInProgress + #define fCBIMemoryDescriptor reserved->fCBIMemoryDescriptor + #define fBulkOnlyCBWMemoryDescriptor reserved->fBulkOnlyCBWMemoryDescriptor + #define fBulkOnlyCSWMemoryDescriptor reserved->fBulkOnlyCSWMemoryDescriptor + #define fDeviceAttached reserved->fDeviceAttached + #define fWaitingForReconfigurationMessage reserved->fWaitingForReconfigurationMessage + #define fTerminating reserved->fTerminating + #define fKnownCSWTagMismatchIssues reserved->fKnownCSWTagMismatchIssues + #define fPortSuspendResumeForPMEnabled reserved->fPortSuspendResumeForPMEnabled + #define fPortIsSuspended reserved->fPortIsSuspended + #define fRequiresResetOnResume reserved->fRequiresResetOnResume + #define fAutonomousSpinDownWorkAround reserved->fAutonomousSpinDownWorkAround + #define fConsecutiveResetCount reserved->fConsecutiveResetCount + #define fClearStallInProgress reserved->fClearStallInProgress + #define fTerminationDeferred reserved->fTerminationDeferred + + // Enumerated constants used to control various aspects of this + // driver. + + // Enumerations for Mass Storage Class Subclass types + enum + { + kUSBStorageRBCSubclass = 1, + kUSBStorageSFF8020iSubclass = 2, + kUSBStorageQIC157Subclass = 3, + kUSBStorageUFISubclass = 4, + kUSBStorageSFF8070iSubclass = 5, + kUSBStorageSCSITransparentSubclass = 6 + }; + + // The supported USB Mass Storage Class transport protocols. + enum + { + kProtocolControlBulkInterrupt = 0x00, + kProtocolControlBulk = 0x01, + kProtocolBulkOnly = 0x50 + }; + + // ------- Protocol support functions ------------ + // The SendSCSICommand function will take a SCSITask Object and transport + // it across the physical wire(s) to the device + virtual bool SendSCSICommand( + SCSITaskIdentifier request, + SCSIServiceResponse * serviceResponse, + SCSITaskStatus * taskStatus ); + + // The AbortSCSICommand function will abort the indicated SCSITask object, + // if it is possible and the SCSITask has not already completed. + virtual SCSIServiceResponse AbortSCSICommand( SCSITaskIdentifier abortTask ); + + virtual bool IsProtocolServiceSupported( + SCSIProtocolFeature feature, + void * serviceValue ); + + virtual bool HandleProtocolServiceFeature( + SCSIProtocolFeature feature, + void * serviceValue ); + + // Methods for retrieving and setting the object for the Interface + IOUSBInterface * GetInterfaceReference( void ); + void SetInterfaceReference( IOUSBInterface * newInterface ); + + UInt8 GetInterfaceSubclass( void ); + UInt8 GetInterfaceProtocol( void ); + + // Methods for retrieving an object for a Pipe. + IOUSBPipe * GetControlPipe( void ); + IOUSBPipe * GetBulkInPipe( void ); + IOUSBPipe * GetBulkOutPipe( void ); + IOUSBPipe * GetInterruptPipe( void ); + + // Methods for getting and setting the maximum LUN of a device. + UInt8 GetMaxLogicalUnitNumber( void ) const; + void SetMaxLogicalUnitNumber( UInt8 maxLUN ); + + virtual void CompleteSCSICommand( + SCSITaskIdentifier request, + IOReturn status ); + + virtual bool BeginProvidedServices( void ); + virtual bool EndProvidedServices( void ); + + // The Protocol specific helper methods for SendSCSICommand + virtual IOReturn SendSCSICommandForCBIProtocol( + SCSITaskIdentifier request ); + + virtual IOReturn SendSCSICommandForBulkOnlyProtocol( + SCSITaskIdentifier request ); + + // The Protocol specific helper methods for AbortSCSICommand + virtual IOReturn AbortSCSICommandForCBIProtocol( + SCSITaskIdentifier abortTask ); + + virtual IOReturn AbortSCSICommandForBulkOnlyProtocol( + SCSITaskIdentifier abortTask ); + + // Helper methods for performing general USB device requests + virtual IOReturn ClearFeatureEndpointStall( + IOUSBPipe * thePipe, + IOUSBCompletion * completion ); + virtual IOReturn GetStatusEndpointStatus( + IOUSBPipe * thePipe, + void * endpointStatus, + IOUSBCompletion * completion ); + + /* All CBI transport related methods. + */ + // All definitions and structures for the CBI Protocol + enum + { + kUSBStorageAutoStatusSize = 2 // Per the USB CBI Protocol + }; + + // Methods for accessing Bulk Only specific member variables. + CBIRequestBlock * GetCBIRequestBlock( void ); + + void ReleaseCBIRequestBlock( + CBIRequestBlock * cbiRequestBlock ); + + // Methods used for CBI/CB command transportation. + static void CBIProtocolUSBCompletionAction( + void * target, + void * parameter, + IOReturn status, + UInt32 bufferSizeRemaining); + + IOReturn CBIProtocolTransferData( + CBIRequestBlock * cbiRequestBlock, + UInt32 nextExecutionState ); + + IOReturn CBIProtocolReadInterrupt( + CBIRequestBlock * cbiRequestBlock, + UInt32 nextExecutionState ); + + IOReturn CBIGetStatusEndpointStatus( + IOUSBPipe * targetPipe, + CBIRequestBlock * cbiRequestBlock, + UInt32 nextExecutionState ); + + IOReturn CBIClearFeatureEndpointStall( + IOUSBPipe * targetPipe, + CBIRequestBlock * cbiRequestBlock, + UInt32 nextExecutionState ); + + void CBIProtocolCommandCompletion( + CBIRequestBlock * cbiRequestBlock, + IOReturn resultingStatus, + UInt32 bufferSizeRemaining ); + + /* All Bulk Only transport related methods, structures and enums. + */ + // All Bulk Only specific structures and enums. + + // All definitions and structures for the Bulk Only Protocol + // Command Block Wrapper (CBW) + enum + { + // CBW general struture definitions + kCommandBlockWrapperSignature = OSSwapHostToBigConstInt32 ( 'USBC' ), + kByteCountOfCBW = 31, + + // CBW LUN related definitions + kCBWLUNMask = 0x0F, + + kCBWFlagsDataOut = 0x00, + kCBWFlagsDataIn = 0x80 + }; + + // All definitions and structures for the Bulk Only Protocol + // Command Status Wrapper (CSW) + enum + { + // CSW general struture definitions + kCommandStatusWrapperSignature = OSSwapHostToBigConstInt32 ( 'USBS' ), + kByteCountOfCSW = 13, + + // CSW status definitions + kCSWCommandPassedError = 0x00, // No error occurred + kCSWCommandFailedError = 0x01, /* An error occurred (probably a + * bad command or parameter ) */ + kCSWPhaseError = 0x02 /* A transfer was performed in + * the wrong sequence */ + }; + + // Methods for accessing Bulk Only specific member variables. + BulkOnlyRequestBlock * GetBulkOnlyRequestBlock( void ); + + void ReleaseBulkOnlyRequestBlock( + BulkOnlyRequestBlock * boRequestBlock ); + + UInt32 GetNextBulkOnlyCommandTag( void ); + + // Methods for Bulk Only specific utility commands + IOReturn BulkDeviceResetDevice( + BulkOnlyRequestBlock * boRequestBlock, + UInt32 nextExecutionState ); + + // Methods used for Bulk Only command transportation. + IOReturn BulkOnlySendCBWPacket( + BulkOnlyRequestBlock * boRequestBlock, + UInt32 nextExecutionState ); + + IOReturn BulkOnlyTransferData( + BulkOnlyRequestBlock * boRequestBlock, + UInt32 nextExecutionState ); + + IOReturn BulkOnlyReceiveCSWPacket( + BulkOnlyRequestBlock * boRequestBlock, + UInt32 nextExecutionState ); + + void BulkOnlyExecuteCommandCompletion ( + BulkOnlyRequestBlock * boRequestBlock, + IOReturn resultingStatus, + UInt32 bufferSizeRemaining ); + + static void BulkOnlyUSBCompletionAction ( + void * target, + void * parameter, + IOReturn status, + UInt32 bufferSizeRemaining ); + +public: + + bool init( OSDictionary * propTable ); + virtual bool start( IOService * provider ); + virtual void stop( IOService * provider ); + virtual void free( void ); + virtual IOReturn message( UInt32 type, IOService * provider, void * argument = 0 ); + + virtual bool willTerminate( IOService * provider, + IOOptionBits options ); + + virtual bool didTerminate( IOService * provider, + IOOptionBits options, + bool * defer ); + + virtual bool handleOpen( IOService * client, + IOOptionBits options, + void * arg ); + + virtual void handleClose( IOService * client, + IOOptionBits options ); + + virtual bool handleIsOpen( const IOService * client ) const; + + virtual IOReturn HandlePowerOn( void ); + +protected: + + static IOReturn sWaitForReset( void * refcon ); + IOReturn GatedWaitForReset( void ); + + static IOReturn sWaitForTaskAbort( void * refcon ); /* OBSOLETE */ + IOReturn GatedWaitForTaskAbort( void ); /* OBSOLETE */ + + static void sResetDevice( void * refcon ); + + static void sAbortCurrentSCSITask( void * refcon ); /* OBSOLETE */ + + OSMetaClassDeclareReservedUsed( IOUSBMassStorageClass, 1 ); + virtual IOReturn StartDeviceRecovery( void ); /* OBSOLETE */ + + OSMetaClassDeclareReservedUsed( IOUSBMassStorageClass, 2 ); + virtual void FinishDeviceRecovery( IOReturn status ); /* OBSOLETE */ + + static void DeviceRecoveryCompletionAction( + void * target, + void * parameter, + IOReturn status, + UInt32 bufferSizeRemaining ); /* OBSOLETE */ + + void ResetDeviceNow( bool waitForReset ); + + void AbortCurrentSCSITask( void ); + + bool IsPhysicalInterconnectLocationInternal ( void ); + + IOReturn SuspendPort ( bool suspend ); + +private: + + void ClearPipeStall ( void ); + + IOReturn AcceptSCSITask ( SCSITaskIdentifier scsiTask, bool * pAccepted ); + + void CheckDeferredTermination ( void ); + + void GatedCompleteSCSICommand ( SCSITaskIdentifier request, SCSIServiceResponse * serviceResponse, SCSITaskStatus * taskStatus ); + + // Space reserved for future expansion. + OSMetaClassDeclareReservedUnused( IOUSBMassStorageClass, 3 ); + OSMetaClassDeclareReservedUnused( IOUSBMassStorageClass, 4 ); + OSMetaClassDeclareReservedUnused( IOUSBMassStorageClass, 5 ); + OSMetaClassDeclareReservedUnused( IOUSBMassStorageClass, 6 ); + OSMetaClassDeclareReservedUnused( IOUSBMassStorageClass, 7 ); + OSMetaClassDeclareReservedUnused( IOUSBMassStorageClass, 8 ); + OSMetaClassDeclareReservedUnused( IOUSBMassStorageClass, 9 ); + OSMetaClassDeclareReservedUnused( IOUSBMassStorageClass, 10 ); + OSMetaClassDeclareReservedUnused( IOUSBMassStorageClass, 11 ); + OSMetaClassDeclareReservedUnused( IOUSBMassStorageClass, 12 ); + OSMetaClassDeclareReservedUnused( IOUSBMassStorageClass, 13 ); + OSMetaClassDeclareReservedUnused( IOUSBMassStorageClass, 14 ); + OSMetaClassDeclareReservedUnused( IOUSBMassStorageClass, 15 ); + OSMetaClassDeclareReservedUnused( IOUSBMassStorageClass, 16 ); + +}; + + +#endif _IOKIT_IOUSBMASSSTORAGECLASS_H Index: branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBHubPolicyMaker.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBHubPolicyMaker.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBHubPolicyMaker.h (revision 885) @@ -0,0 +1,218 @@ +/* + * Copyright (c) 2007 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 __OPEN_SOURCE__ +/* + * + * $Log: IOUSBHubPolicyMaker.h,v $ + * Revision 1.10 2009/05/07 19:43:09 nano + * Move our SnowLeopard branch to TOT + * + * Revision 1.7.72.3 2008/07/23 17:43:32 nano + * IOUSBHIDDriver, IOHIDEventService missing HeaderDoc class declarations + * + * Revision 1.7.72.2 2008/04/22 22:38:01 nano + * Bring in changes from Foxhound-320.2.9 + * + * Revision 1.9 2008/04/17 16:56:57 nano + * Bring in branches for rdar://5867990 & rdar://5768343 + * + * Revision 1.8.4.1 2008/04/16 20:26:15 nano + * Add API to allocate sleep current, as well as making sure that we return any extra power if our client dies or our device is terminated without returning it + * + * Revision 1.8 2008/04/14 16:08:38 nano + * Add new APIs for high power and for GetDeviceInformation. + * + * Revision 1.7.114.1 2008/04/11 22:25:44 nano + * Initial work on new user-client APIs and new IOUSBDevice APIs to return port state information and manage extra power requests, as well as groundwork for calling the policy maker directly from the IOUSBDevice + * + * Revision 1.7 2007/08/17 22:41:11 nano + * Bring in branch that fixes USB not honoring Resume recovery time (hub driver) and adds extra time for iPods + * + * Revision 1.6.30.1 2007/08/16 19:14:02 nano + * ResumeRecovery additions. + * + * Revision 1.6 2007/08/01 16:10:18 rhoads + * roll in extra power changes + * + * Revision 1.5.12.1 2007/07/27 16:49:10 rhoads + * merge the extra current stuff into Leopard, and add extra sleep current for self powered hubs + * + * Revision 1.5 2007/07/20 22:31:22 rhoads + * roll in branch300-3-2 + * + * Revision 1.4.40.1 2007/07/18 18:44:24 rhoads + * this is the 300.3.2g version plus some quieter logs + * + * Revision 1.4.34.2 2007/07/17 06:30:35 rhoads + * more hub chain fixes + * + * Revision 1.4.34.1 2007/07/16 16:45:00 rhoads + * more power management and termination tweaks + * + * Revision 1.4 2007/05/18 01:59:12 rhoads + * roll in 5112084 and 5204170 + * + * Revision 1.3.2.1 2007/05/15 18:23:48 rhoads + * some initial power state bug fixes + * + * Revision 1.3 2007/05/10 22:25:35 rhoads + * roll in branch 5113395 - the last major piece of the new power architecture + * + * Revision 1.2.64.4 2007/04/13 22:34:59 rhoads + * fix restart and shutdown + * + * Revision 1.2.64.3 2007/04/11 23:56:23 rhoads + * first mostly working dozing hub + * + * Revision 1.2.64.2 2007/04/10 02:09:09 rhoads + * got UHCI almost working + * + * Revision 1.2.64.1 2007/04/05 02:57:50 rhoads + * move power management out of AppleUSBHub and into IOUSBHubPolicyMaker + * + * Revision 1.2 2007/01/20 00:47:01 rhoads + * roll in Hub Policy Maker changes + * + * Revision 1.1.2.4 2007/01/18 22:51:08 rhoads + * add some padding + * + * Revision 1.1.2.3 2007/01/15 19:58:07 rhoads + * saving more changes + * + * Revision 1.1.2.2 2007/01/09 23:55:36 rhoads + * working version + * + * Revision 1.1.2.1 2007/01/09 21:57:02 rhoads + * commit some stuff to try to fix a permissions issue + * + * + */ +#endif +#ifndef _IOKIT_IOUSBHUBPOLICYMAKER_H +#define _IOKIT_IOUSBHUBPOLICYMAKER_H + +#include +#include +#include + + +enum { + kIOUSBHubPowerStateOff = 0, // losing power + kIOUSBHubPowerStateRestart = 1, // reseting bus, but may maintain power + kIOUSBHubPowerStateSleep = 2, // upstream port and all downstream ports suspended (from the top) + kIOUSBHubPowerStateLowPower = 3, // upstream port and all downstream ports suspended (from the bottom) + kIOUSBHubPowerStateOn = 4, // upstream port and at least one downstream port on + kIOUSBHubNumberPowerStates = 5 +}; + +enum { + kHubResumeRecoveryTime = 10, // 10 ms to recover after I resume myself + kPortResumeRecoveryTime = 10 // 10 ms to recover another device +}; + +#define kIOUSBHubPowerStateStable -1 + +/*! + @class IOUSBHubPolicyMaker + @abstract Super class for Hub drivers to incorporate common Power Management code. + */ +class IOUSBHubPolicyMaker : public IOService +{ + OSDeclareAbstractStructors(IOUSBHubPolicyMaker) + +protected: + IOUSBControllerV2 * _bus; + IOUSBHubDevice * _device; // our provider + IOUSBHubDevice * _parentHubDevice; // for non root hub drivers, this is the hub device that my hub device is connected to + bool _isRootHub; // this is a root hub + bool _dozeEnabled; // true if the controller has been enabled to go into doze mode + bool _dontAllowLowPower; // If true, we will not allow the hub to go into low power mode. + bool _dontAllowSleepPower; // If true, we will not allow extra sleep power for a self powered hub. + SInt32 _powerStateChangingTo; // a power state if we are changing to one, or -1 if we are stable + unsigned long _myPowerState; // my current state (since getPowerState doesn't always change in time) + UInt32 _extraPower; // how much extra power we might be able to get from our parent hub + UInt32 _extraPowerRemaining; // how many milliamps we can still give to any one port + UInt32 _hubResumeRecoveryTime; // # of ms that we will wait before issuing any transactions on our port (nominally 10ms) + struct ExpansionData + { + }; + ExpansionData *_expansionData; + +public: + // IOService methods + virtual bool start(IOService * provider); + virtual IOReturn powerStateWillChangeTo ( IOPMPowerFlags capabilities, unsigned long stateNumber, IOService* whatDevice); + virtual unsigned long powerStateForDomainState ( IOPMPowerFlags domainState ); + virtual IOReturn setPowerState ( unsigned long powerStateOrdinal, IOService* whatDevice ); + virtual IOReturn powerStateDidChangeTo ( IOPMPowerFlags capabilities, unsigned long stateNumber, IOService* whatDevice); + virtual unsigned long maxCapabilityForDomainState ( IOPMPowerFlags domainState ); + virtual void powerChangeDone ( unsigned long fromState ); + + // public methods which MAY be implemented in subclass + virtual IOReturn EnsureUsability(void); + + // Extra Port Power calls + void AllocateExtraPower(); + IOReturn GetExtraPortPower(UInt32 portNum, UInt32 *extraPower); + IOReturn ReturnExtraPortPower(UInt32 portNum, UInt32 extraPower); + + // virtual methods to be implemented in the controlling driver subclass + virtual bool ConfigureHubDriver(void) = 0; + virtual IOReturn HubPowerChange(unsigned long powerStateOrdinal) = 0; + + OSMetaClassDeclareReservedUsed(IOUSBHubPolicyMaker, 0); + virtual IOReturn GetPortInformation(UInt32 portNum, UInt32 *info); + + OSMetaClassDeclareReservedUsed(IOUSBHubPolicyMaker, 1); + virtual IOReturn ResetPort(UInt32 portNum); + + OSMetaClassDeclareReservedUsed(IOUSBHubPolicyMaker, 2); + virtual IOReturn SuspendPort(UInt32 portNum, bool suspend); + + OSMetaClassDeclareReservedUsed(IOUSBHubPolicyMaker, 3); + virtual IOReturn ReEnumeratePort(UInt32 portNum, UInt32 options); + + OSMetaClassDeclareReservedUsed(IOUSBHubPolicyMaker, 4); + virtual UInt32 RequestExtraPower(UInt32 portNum, UInt32 type, UInt32 requestedPower); + + OSMetaClassDeclareReservedUsed(IOUSBHubPolicyMaker, 5); + virtual IOReturn ReturnExtraPower(UInt32 portNum, UInt32 type, UInt32 returnedPower); + + OSMetaClassDeclareReservedUnused(IOUSBHubPolicyMaker, 6); + OSMetaClassDeclareReservedUnused(IOUSBHubPolicyMaker, 7); + OSMetaClassDeclareReservedUnused(IOUSBHubPolicyMaker, 8); + OSMetaClassDeclareReservedUnused(IOUSBHubPolicyMaker, 9); + OSMetaClassDeclareReservedUnused(IOUSBHubPolicyMaker, 10); + OSMetaClassDeclareReservedUnused(IOUSBHubPolicyMaker, 11); + OSMetaClassDeclareReservedUnused(IOUSBHubPolicyMaker, 12); + OSMetaClassDeclareReservedUnused(IOUSBHubPolicyMaker, 13); + OSMetaClassDeclareReservedUnused(IOUSBHubPolicyMaker, 14); + OSMetaClassDeclareReservedUnused(IOUSBHubPolicyMaker, 15); + OSMetaClassDeclareReservedUnused(IOUSBHubPolicyMaker, 16); + OSMetaClassDeclareReservedUnused(IOUSBHubPolicyMaker, 17); + OSMetaClassDeclareReservedUnused(IOUSBHubPolicyMaker, 18); + OSMetaClassDeclareReservedUnused(IOUSBHubPolicyMaker, 19); +}; + +#endif _IOKIT_IOUSBHUBPOLICYMAKER_H Index: branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBCompositeDriver.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBCompositeDriver.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBCompositeDriver.h (revision 885) @@ -0,0 +1,127 @@ +/* + * + * @APPLE_LICENSE_HEADER_START@ + * + * Copyright (c) 1998-2006 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_IOUSBCompositeDriver_H +#define _IOKIT_IOUSBCompositeDriver_H + +//================================================================================================ +// +// Headers +// +//================================================================================================ +// +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +//================================================================================================ +// +// Class Declaration for IOUSBCompositeDriver +// +//================================================================================================ +// +/*! + @class IOUSBCompositeDriver + @abstract Driver that matches to USB composite devices. + @discussion This class can be overriden to provide for specific behaviors. The driver itself essentially + just calls SetConfiguration(). + */ +class IOUSBCompositeDriver : public IOService +{ + OSDeclareDefaultStructors(IOUSBCompositeDriver) + + IOUSBDevice * fDevice; + IONotifier * fNotifier; + bool fExpectingClose; + UInt8 fConfigValue; + UInt8 fConfigbmAttributes; + + struct IOUSBCompositeDriverExpansionData + { + }; + + IOUSBCompositeDriverExpansionData * fIOUSBCompositeExpansionData; + + static IOReturn CompositeDriverInterestHandler( void * target, void * refCon, UInt32 messageType, IOService * provider, void * messageArgument, vm_size_t argSize ); + +public: + + // IOService Methods + // + virtual bool start(IOService * provider); + virtual IOReturn message( UInt32 type, IOService * provider, void * argument = 0 ); + virtual bool willTerminate( IOService * provider, IOOptionBits options ); + virtual bool didTerminate( IOService * provider, IOOptionBits options, bool * defer ); + + // IOUSBCompositeDriver Methods + // + virtual bool ConfigureDevice(); + virtual IOReturn ReConfigureDevice(); + /*! + @function SetConfiguration + @abstract Call IOUSBDevice to do a SetConfiguration call to the device. + @param configValue The desired configuration value. + @param startInterfaceMatching A boolean specifying whether IOKit should begin the process of finding + matching drivers for the new IOUSBInterface objects. + */ + virtual IOReturn SetConfiguration(UInt8 configValue, bool startInterfaceMatching=true); + + // Getters + // + bool GetExpectingClose() { return fExpectingClose; } + UInt8 GetConfigValue() { return fConfigValue; } + UInt8 GetConfigbmAttributes() { return fConfigbmAttributes; } + IONotifier * GetNotifier() { return fNotifier; } + + OSMetaClassDeclareReservedUnused(IOUSBCompositeDriver, 0); + OSMetaClassDeclareReservedUnused(IOUSBCompositeDriver, 1); + OSMetaClassDeclareReservedUnused(IOUSBCompositeDriver, 2); + OSMetaClassDeclareReservedUnused(IOUSBCompositeDriver, 3); + OSMetaClassDeclareReservedUnused(IOUSBCompositeDriver, 4); + OSMetaClassDeclareReservedUnused(IOUSBCompositeDriver, 5); + OSMetaClassDeclareReservedUnused(IOUSBCompositeDriver, 6); + OSMetaClassDeclareReservedUnused(IOUSBCompositeDriver, 7); + OSMetaClassDeclareReservedUnused(IOUSBCompositeDriver, 8); + OSMetaClassDeclareReservedUnused(IOUSBCompositeDriver, 9); + OSMetaClassDeclareReservedUnused(IOUSBCompositeDriver, 10); + OSMetaClassDeclareReservedUnused(IOUSBCompositeDriver, 11); + OSMetaClassDeclareReservedUnused(IOUSBCompositeDriver, 12); + OSMetaClassDeclareReservedUnused(IOUSBCompositeDriver, 13); + OSMetaClassDeclareReservedUnused(IOUSBCompositeDriver, 14); + OSMetaClassDeclareReservedUnused(IOUSBCompositeDriver, 15); + OSMetaClassDeclareReservedUnused(IOUSBCompositeDriver, 16); + OSMetaClassDeclareReservedUnused(IOUSBCompositeDriver, 17); + OSMetaClassDeclareReservedUnused(IOUSBCompositeDriver, 18); + OSMetaClassDeclareReservedUnused(IOUSBCompositeDriver, 19); +}; + +#endif _IOKIT_IOUSBCompositeDriver_H Index: branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBCommand.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBCommand.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBCommand.h (revision 885) @@ -0,0 +1,266 @@ +/* + * Copyright (c) 1998-2006 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_IOUSBCOMMAND_H +#define _IOKIT_IOUSBCOMMAND_H + +#include +#include +#include +#include +#include + +/* + * USB Command + * This is the command block for a USB command to be queued on the + * Command Gate of the WorkLoop. Although the actual work of creating + * the command and enqueueing it is done for them via the deviceRequest, + * read, and write methods, this is the primary way that devices will get + * work done. + * Note: This is private to IOUSBController and should be moved to a + * private header. + */ + +typedef enum { + DEVICE_REQUEST, // Device request using pointer + READ, + WRITE, + CREATE_EP, + DELETE_EP, + DEVICE_REQUEST_DESC, // Device request using descriptor + DEVICE_REQUEST_BUFFERCOMMAND // Device request using a second IOUSBCommand in _bufferCommand +} usbCommand; + + + +/*! + @class IOUSBCommand + @abstract A subclass of IOCommand that is used to add USB specific data. + */ +class IOUSBCommand : public IOCommand +{ + OSDeclareAbstractStructors(IOUSBCommand) + +protected: + usbCommand _selector; + IOUSBDeviceRequestPtr _request; + USBDeviceAddress _address; + UInt8 _endpoint; + UInt8 _direction; + UInt8 _type; + bool _bufferRounding; + IOMemoryDescriptor * _buffer; + IOUSBCompletion _uslCompletion; + IOUSBCompletion _clientCompletion; + UInt32 _dataRemaining; // For Control transfers + UInt8 _stage; // For Control transfers + IOReturn _status; + IOMemoryDescriptor * _origBuffer; + IOUSBCompletion _disjointCompletion; + IOByteCount _dblBufLength; + UInt32 _noDataTimeout; + UInt32 _completionTimeout; + UInt32 _UIMScratch[10]; + + struct ExpansionData + { + IOByteCount _reqCount; + IOMemoryDescriptor *_requestMemoryDescriptor; + IOMemoryDescriptor *_bufferMemoryDescriptor; + bool _multiTransferTransaction; + bool _finalTransferInTransaction; + bool _useTimeStamp; + AbsoluteTime _timeStamp; + bool _isSyncTransfer; // Returns true if the command is used for a synchronous transfer + IODMACommand *_dmaCommand; // used to get memory mapping + IOUSBCommand *_bufferUSBCommand; // points to another IOUSBCommand used for phase 2 of control transactions + IOUSBCommand *_masterUSBCommand; // points from the bufferUSBCommand back to the parent command + }; + ExpansionData * _expansionData; + + // we override these OSObject method in order to allocate and release our expansion data + virtual bool init(); + virtual void free(); + +public: + + // static constructor + static IOUSBCommand * NewCommand(void); + + // Manipulators + void SetSelector(usbCommand sel); + void SetRequest(IOUSBDeviceRequestPtr req); + void SetAddress(USBDeviceAddress addr); + void SetEndpoint(UInt8 ep); + void SetDirection(UInt8 dir); + void SetType(UInt8 type); + void SetBufferRounding(bool br); + void SetBuffer(IOMemoryDescriptor *buf); + void SetUSLCompletion(IOUSBCompletion completion); + void SetClientCompletion(IOUSBCompletion completion); + void SetDataRemaining(UInt32 dr); + void SetStage(UInt8 stage); + void SetStatus(IOReturn stat); + void SetOrigBuffer(IOMemoryDescriptor *buf); + void SetDisjointCompletion(IOUSBCompletion completion); + void SetDblBufLength(IOByteCount len); + void SetNoDataTimeout(UInt32 to); + void SetCompletionTimeout(UInt32 to); + void SetUIMScratch(UInt32 index, UInt32 value); + void SetReqCount(IOByteCount reqCount); + void SetRequestMemoryDescriptor(IOMemoryDescriptor *requestMemoryDescriptor); + void SetBufferMemoryDescriptor(IOMemoryDescriptor *bufferMemoryDescriptor); + void SetMultiTransferTransaction(bool); + void SetFinalTransferInTransaction(bool); + void SetUseTimeStamp(bool); + void SetTimeStamp(AbsoluteTime timeStamp); + void SetIsSyncTransfer(bool); + inline void SetDMACommand(IODMACommand *dmaCommand) { _expansionData->_dmaCommand = dmaCommand; } + void SetBufferUSBCommand(IOUSBCommand *bufferUSBCommand); + + // Accessors + usbCommand GetSelector(void); + IOUSBDeviceRequestPtr GetRequest(void); + USBDeviceAddress GetAddress(void); + UInt8 GetEndpoint(void); + UInt8 GetDirection(void); + UInt8 GetType(void); + bool GetBufferRounding(void); + IOMemoryDescriptor * GetBuffer(void); + IOUSBCompletion GetUSLCompletion(void); + IOUSBCompletion GetClientCompletion(void); + UInt32 GetDataRemaining(void); + UInt8 GetStage(void); + IOReturn GetStatus(void); + IOMemoryDescriptor * GetOrigBuffer(void); + IOUSBCompletion GetDisjointCompletion(void); + IOByteCount GetDblBufLength(void); + UInt32 GetNoDataTimeout(void); + UInt32 GetCompletionTimeout(void); + UInt32 GetUIMScratch(UInt32 index); + IOByteCount GetReqCount(void); + IOMemoryDescriptor * GetRequestMemoryDescriptor(void); + IOMemoryDescriptor * GetBufferMemoryDescriptor(void); + bool GetMultiTransferTransaction(void); + bool GetFinalTransferInTransaction(void); + bool GetUseTimeStamp(void); + AbsoluteTime GetTimeStamp(void); + bool GetIsSyncTransfer(void); + inline IODMACommand * GetDMACommand(void) {return _expansionData->_dmaCommand; } + inline IOUSBCommand * GetBufferUSBCommand(void) {return _expansionData->_bufferUSBCommand; } +}; + + +class IOUSBIsocCommand : public IOCommand +{ + OSDeclareAbstractStructors(IOUSBIsocCommand) + +protected: + usbCommand _selector; + USBDeviceAddress _address; + UInt8 _endpoint; + UInt8 _direction; + IOMemoryDescriptor * _buffer; + IOUSBIsocCompletion _completion; + UInt64 _startFrame; + UInt32 _numFrames; + IOUSBIsocFrame * _frameList; + IOReturn _status; + + struct ExpansionData + { + UInt32 _updateFrequency; + bool _useTimeStamp; + AbsoluteTime _timeStamp; + bool _isSyncTransfer; // Returns true if the command is used for a synchronous transfer + bool _rosettaClient; + IODMACommand * _dmaCommand; + IOUSBIsocCompletion _uslCompletion; + bool _lowLatency; + }; + ExpansionData * _expansionData; + + // we override these OSObject method in order to allocate and release our expansion data + virtual bool init(); + virtual void free(); + +public: + // static constructor + static IOUSBIsocCommand *NewCommand(void); + + // Manipulators + void SetSelector(usbCommand sel) {_selector = sel; } + void SetAddress(USBDeviceAddress addr) {_address = addr; } + void SetEndpoint(UInt8 ep) {_endpoint = ep; } + void SetDirection(UInt8 dir) {_direction = dir; } + void SetBuffer(IOMemoryDescriptor *buf) {_buffer = buf; } + void SetCompletion(IOUSBIsocCompletion completion) {_completion = completion; } + void SetStartFrame(UInt64 sf) {_startFrame = sf; } + void SetNumFrames(UInt32 nf) {_numFrames = nf; } + void SetFrameList(IOUSBIsocFrame *fl) {_frameList = fl; } + void SetStatus(IOReturn stat) {_status = stat; } + void SetUpdateFrequency( UInt32 fr) { _expansionData->_updateFrequency = fr; } + void SetUseTimeStamp(bool useIt) { _expansionData->_useTimeStamp= useIt; } + void SetTimeStamp(AbsoluteTime timeStamp) { _expansionData->_timeStamp= timeStamp; } + void SetIsSyncTransfer(bool isSync) { _expansionData->_isSyncTransfer = isSync; } + void SetRosettaClient(bool isRosetta) { _expansionData->_rosettaClient = isRosetta; } + void SetDMACommand(IODMACommand *dmaCommand) { _expansionData->_dmaCommand = dmaCommand; } + void SetUSLCompletion(IOUSBIsocCompletion completion) { _expansionData->_uslCompletion = completion; } + void SetLowLatency(bool lowLatency) { _expansionData->_lowLatency = lowLatency; } + + // Accessors + usbCommand GetSelector(void) { return _selector; } + USBDeviceAddress GetAddress(void) { return _address; } + UInt8 GetEndpoint(void) { return _endpoint; } + UInt8 GetDirection(void) { return _direction; } + IOMemoryDescriptor * GetBuffer(void) { return _buffer; } + IOUSBIsocCompletion GetCompletion(void) { return _completion; } + UInt64 GetStartFrame(void) { return _startFrame; } + UInt32 GetNumFrames(void) { return _numFrames; } + IOUSBIsocFrame * GetFrameList(void) { return _frameList; } + UInt32 GetUpdateFrequency(void) { return _expansionData->_updateFrequency; } + IOReturn GetStatus(void) { return _status; } + bool GetUseTimeStamp(void) { return _expansionData->_useTimeStamp; } + AbsoluteTime GetTimeStamp(void) { return _expansionData->_timeStamp; } + bool GetIsSyncTransfer(void) { return _expansionData->_isSyncTransfer; } + bool GetIsRosettaClient(void) { return _expansionData->_rosettaClient; } + IODMACommand * GetDMACommand(void) { return _expansionData->_dmaCommand; } + IOUSBIsocCompletion GetUSLCompletion(void) { return _expansionData->_uslCompletion; } + bool GetLowLatency(void) { return _expansionData->_lowLatency; } +}; + +class IOUSBCommandPool : public IOCommandPool +{ + OSDeclareDefaultStructors( IOUSBCommandPool ) + +protected: + virtual IOReturn gatedReturnCommand(IOCommand * command); + virtual IOReturn gatedGetCommand(IOCommand ** command, bool blockForCommand); + +public: + static IOCommandPool * withWorkLoop(IOWorkLoop * inWorkLoop); +}; + + +#endif + Index: branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBHIDDriver.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBHIDDriver.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBHIDDriver.h (revision 885) @@ -0,0 +1,289 @@ +/* + * Copyright (c) 1998-2006 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 IOUSBHIDDRIVER_H +#define IOUSBHIDDRIVER_H + +#include + +#include + +#include +#include +#include + + +#define ENABLE_HIDREPORT_LOGGING 0 + +// Report types from low level USB: +// from USBSpec.h: +// enum { +// kHIDRtInputReport = 1, +// kHIDRtOutputReport = 2, +// kHIDRtFeatureReport = 3 +// }; +// +// from IOHIDDescriptorParser.h: +// // types of HID reports (input, output, feature) +// enum +// { +// kHIDInputReport = 1, +// kHIDOutputReport, +// kHIDFeatureReport, +// kHIDUnknownReport = 255 +// }; +// +// Report types from high level HID Manager: +// from IOHIDKeys.h: +// enum IOHIDReportType +// { +// kIOHIDReportTypeInput = 0, +// kIOHIDReportTypeOutput, +// kIOHIDReportTypeFeature, +// kIOHIDReportTypeCount +// }; +// +#define HIDMGR2USBREPORTTYPE(x) (x + 1) +#define USB2HIDMGRREPORTTYPE(x) (x - 1) + + +// Note: In other Neptune files, kMaxHIDReportSize was defined as 64. But Ferg & Keithen were unable to +// find that value in the USB HID 1.1 specs. Brent had previously changed it to 256 in the OS 9 HID Driver +// to allow for reports spanning multiple packets. 256 may be no more a hard and fast limit, but it's +// working for now in OS 9. +#define kMaxHIDReportSize 256 // Max packet size = 8 for low speed & 64 for high speed. +#define kHIDDriverRetryCount 3 +#define kUSBHIDReportLoggingLevel "USB HID Report Logging Level" + + +// power states for the driver (awake or suspended) +enum +{ + kUSBHIDPowerStateOff = 0, + kUSBHIDPowerStateRestart = 1, + kUSBHIDPowerStateSleep = 2, // this could be system sleep or idle sleep + kUSBHIDPowerStateLowPower = 3, // this is idling + kUSBHIDPowerStateOn = 4, // this is fully on + kUSBHIDNumberPowerStates = 5 +}; + + +/*! + @class IOUSBHIDDriver + @abstract Driver that matches to USB HID devices. + @discussion This class can be overriden to provide for specific behaviors. + */ +class IOUSBHIDDriver : public IOHIDDevice +{ + OSDeclareDefaultStructors(IOUSBHIDDriver) + + IOUSBInterface * _interface; + IOUSBDevice * _device; + IOUSBPipe * _interruptPipe; + UInt32 _maxReportSize; + IOBufferMemoryDescriptor * _buffer; + IOUSBCompletion _completion; + UInt32 _retryCount; + thread_call_t _deviceDeadCheckThread; + thread_call_t _clearFeatureEndpointHaltThread; + bool _deviceDeadThreadActive; + bool _deviceIsDead; // Should really be called "abort expected" + bool _deviceHasBeenDisconnected; + bool _needToClose; + UInt32 _outstandingIO; + IOCommandGate * _gate; + IOUSBPipe * _interruptOutPipe; + UInt32 _locationID; + IOBufferMemoryDescriptor * _outBuffer; // Obsolete + UInt32 _deviceUsage; // Obsolete + UInt32 _deviceUsagePage; // Obsolete + + struct IOUSBHIDDriverExpansionData + { + IOWorkLoop * _workLoop; + thread_call_t _handleReportThread; + IOService * _rootDomain; + AbsoluteTime _wakeUpTime; + IOUSBCompletionWithTimeStamp _completionWithTimeStamp; + bool _checkForTimeStamp; + UInt32 _msToIgnoreTransactionsAfterWake; + IOTimerEventSource * _suspendPortTimer; + bool _portSuspended; + UInt32 _suspendTimeoutInMS; + UInt8 _interfaceNumber; + bool _logHIDReports; + UInt8 _hidLoggingLevel; + bool _needToClearPipeStall; + SInt32 _queuedReports; + AbsoluteTime _interruptTimeStamp; + bool _powerStateChanging; + unsigned long _myPowerState; + bool _pendingRead; + UInt32 _deviceDeadCheckLock; // "Lock" to prevent us from executing the device dead check while in progress + }; + IOUSBHIDDriverExpansionData *_usbHIDExpansionData; + + static void InterruptReadHandlerEntry(OSObject *target, void *param, IOReturn status, UInt32 bufferSizeRemaining); + static void InterruptReadHandlerWithTimeStampEntry(OSObject *target, void *param, IOReturn status, UInt32 bufferSizeRemaining, AbsoluteTime timeStamp); + void InterruptReadHandler(IOReturn status, UInt32 bufferSizeRemaining, AbsoluteTime timeStamp); + + static void CheckForDeadDeviceEntry(OSObject *target); + void CheckForDeadDevice(); + + static void ClearFeatureEndpointHaltEntry(OSObject *target); + void ClearFeatureEndpointHalt(void); + + static void HandleReportEntry(OSObject *target, thread_call_param_t timeStamp); + void HandleReport(AbsoluteTime timeStamp); + + virtual void processPacket(void *data, UInt32 size); // Obsolete + + static IOReturn ChangeOutstandingIO(OSObject *target, void *arg0, void *arg1, void *arg2, void *arg3); + static IOReturn ClaimPendingRead(OSObject *target, void *arg0, void *arg1, void *arg2, void *arg3); + + static void SuspendPortTimer(OSObject *target, IOTimerEventSource *sender); + +public: + + // IOService methods + // + virtual bool init(OSDictionary *properties); + virtual bool start(IOService * provider); + virtual bool didTerminate( IOService * provider, IOOptionBits options, bool * defer ); + virtual bool willTerminate( IOService * provider, IOOptionBits options ); + virtual void stop(IOService * provider); + virtual void free(); + virtual IOReturn message( UInt32 type, IOService * provider, void * argument = 0 ); + virtual unsigned long maxCapabilityForDomainState ( IOPMPowerFlags domainState ); + virtual IOReturn powerStateWillChangeTo ( IOPMPowerFlags capabilities, unsigned long stateNumber, IOService* whatDevice); + virtual IOReturn setPowerState ( unsigned long powerStateOrdinal, IOService* whatDevice ); + virtual IOReturn powerStateDidChangeTo ( IOPMPowerFlags capabilities, unsigned long stateNumber, IOService* whatDevice); + virtual void powerChangeDone ( unsigned long fromState); + + + // IOHIDDevice methods + // + virtual bool handleStart(IOService * provider); + virtual void handleStop(IOService * provider); + + virtual IOReturn newReportDescriptor( IOMemoryDescriptor ** descriptor ) const; + + virtual OSString * newTransportString() const; + + virtual OSNumber * newVendorIDNumber() const; + + virtual OSNumber * newProductIDNumber() const; + + virtual OSNumber * newVersionNumber() const; + + virtual OSString * newManufacturerString() const; + + virtual OSString * newProductString() const; + + virtual OSString * newSerialNumberString() const; + + virtual OSNumber * newLocationIDNumber() const; + + virtual OSNumber * newCountryCodeNumber() const; + + virtual IOReturn getReport( IOMemoryDescriptor * report, + IOHIDReportType reportType, + IOOptionBits options = 0 ); + + virtual IOReturn setReport( IOMemoryDescriptor * report, + IOHIDReportType reportType, + IOOptionBits options = 0 ); + + // HID driver methods + // + virtual OSString * newIndexedString(UInt8 index) const; + + virtual UInt32 getMaxReportSize(); + + virtual void DecrementOutstandingIO(void); + virtual void IncrementOutstandingIO(void); + virtual IOReturn StartFinalProcessing(); + virtual IOReturn SetIdleMillisecs(UInt16 msecs); + +private: + + IOReturn GetHIDDescriptor(UInt8 inDescriptorType, UInt8 inDescriptorIndex, UInt8 *vOutBuf, UInt32 *vOutSize); + IOReturn GetReport(UInt8 inReportType, UInt8 inReportID, UInt8 *vInBuf, UInt32 *vInSize); + IOReturn SetReport(UInt8 outReportType, UInt8 outReportID, UInt8 *vOutBuf, UInt32 vOutSize); + IOReturn GetIndexedString(UInt8 index, UInt8 *vOutBuf, UInt32 *vOutSize, UInt16 lang = 0x409) const; + IOReturn SetProtocol(UInt32 protocolType); + char GetHexChar(char hexChar); + IOReturn AbortAndSuspend( bool suspend ); + + + +#if ENABLE_HIDREPORT_LOGGING + void LogBufferReport(char *report, UInt32 len); + void LogMemReport(IOMemoryDescriptor * reportBuffer); + char GetHexChar(char hexChar); +#endif + +public: + OSMetaClassDeclareReservedUsed(IOUSBHIDDriver, 0); + virtual IOReturn RearmInterruptRead(); + + /*! + @function SuspendPort + @abstract Suspends the port for this device or optionally sets a timeout to suspend after a period of inactivity. + @discussion This call can be used to immediately suspend/resume a port or to enable the suspension of the port after a period of inactivity. If called with suspendPort = true (no timeout parameter), the HID driver + will immediately suspend the port, after aborting any outstanding reads on the interrupt pipe. If called with suspendPort = true and timeout != 0, it will suspend the port after the timeout number of ms have + passed without any read completions. If called with suspendPort = false, the port will be immediately resumed and the reads will be re-issued. If a timeout was enabled, it will be cancelled. + @param suspendPort Boolean value. true = suspend the port, false = resume the port. + @param timeoutMS Value in milliseconds If value is non-zero, the port will be suspended after the timeout milliseconds have passed without any read completions. + @result The IOReturn value from the IOUSBDevice::Suspend() call. + */ + OSMetaClassDeclareReservedUsed(IOUSBHIDDriver, 1); + virtual IOReturn SuspendPort(bool suspendPort, UInt32 timeoutMS = 0); + + OSMetaClassDeclareReservedUsed(IOUSBHIDDriver, 2); + virtual bool IsPortSuspended(); + + OSMetaClassDeclareReservedUsed(IOUSBHIDDriver, 3); + virtual void LogMemReport(UInt8 level, IOMemoryDescriptor * reportBuffer, IOByteCount size); + + OSMetaClassDeclareReservedUsed(IOUSBHIDDriver, 4); + virtual IOReturn InitializeUSBHIDPowerManagement(IOService *provider); + + OSMetaClassDeclareReservedUnused(IOUSBHIDDriver, 5); + OSMetaClassDeclareReservedUnused(IOUSBHIDDriver, 6); + OSMetaClassDeclareReservedUnused(IOUSBHIDDriver, 7); + OSMetaClassDeclareReservedUnused(IOUSBHIDDriver, 8); + OSMetaClassDeclareReservedUnused(IOUSBHIDDriver, 9); + OSMetaClassDeclareReservedUnused(IOUSBHIDDriver, 10); + OSMetaClassDeclareReservedUnused(IOUSBHIDDriver, 11); + OSMetaClassDeclareReservedUnused(IOUSBHIDDriver, 12); + OSMetaClassDeclareReservedUnused(IOUSBHIDDriver, 13); + OSMetaClassDeclareReservedUnused(IOUSBHIDDriver, 14); + OSMetaClassDeclareReservedUnused(IOUSBHIDDriver, 15); + OSMetaClassDeclareReservedUnused(IOUSBHIDDriver, 16); + OSMetaClassDeclareReservedUnused(IOUSBHIDDriver, 17); + OSMetaClassDeclareReservedUnused(IOUSBHIDDriver, 18); + OSMetaClassDeclareReservedUnused(IOUSBHIDDriver, 19); +}; + +#endif // IOUSBHIDDRIVER_H Index: branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBLog.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBLog.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBLog.h (revision 885) @@ -0,0 +1,240 @@ +/* + * Copyright © 1998-20010 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_IOUSBLOG_H +#define _IOKIT_IOUSBLOG_H + +#include +#include + + +#ifdef __cplusplus + extern "C" { +#endif + +// USB Specific defines +#define USBLog( LEVEL, ARGS...) KernelDebugLogTag( LEVEL, 'USBF', ## ARGS ) +#define USBError( LEVEL, ARGS...) KernelDebugLogInternal( ( LEVEL ), 'USBF', ## ARGS ) +#define USBStringFromReturn( IORETURN) (IOUSBController::_log)->stringFromReturn( IORETURN ) + + +// Possible Debug levels. If DEBUG_LEVEL is set to DEBUG_LEVEL_PRODUCTION, all debug logs will be +// stripped of the final code. + +#define DEBUG_LEVEL_PRODUCTION 0 +#define DEBUG_LEVEL_DEVELOPMENT 1 +#define DEBUG_LEVEL_ALPHA 2 +#define DEBUG_LEVEL_BETA 3 +#define DEBUG_LEVEL_FINAL DEBUG_LEVEL_PRODUCTION + +// Allow clients to define their own debug level. + +#if ( !defined( DEBUG_LEVEL ) ) + #define DEBUG_LEVEL DEBUG_LEVEL_PRODUCTION +#endif + +// Index for user client methods +// +enum +{ + kUSBControllerUserClientOpen = 0, + kUSBControllerUserClientClose, + kUSBControllerUserClientEnableLogger, + kUSBControllerUserClientSetDebuggingLevel, + kUSBControllerUserClientSetDebuggingType, + kUSBControllerUserClientGetDebuggingLevel, + kUSBControllerUserClientGetDebuggingType, +#ifndef __OPEN_SOURCE__ + kUSBControllerUserClientSetTestMode, + kUSBControllerUserClientReadRegister, + kUSBControllerUserClientWriteRegister, + kUSBControllerUserClientMessageController, +#endif + kNumUSBControllerMethods +}; + +#ifndef __OPEN_SOURCE__ +// Enums for the private kIOUSBMessageController message +enum +{ + kIOUSBMessageControllerDoGPIOReset = 0x00000001 +}; +#endif + +// Info Debug Output Types. + +typedef UInt32 KernelDebuggingOutputType; +enum +{ + kKernelDebugOutputIOLogType = 0x00000001, + kKernelDebugOutputKextLoggerType = 0x00000002 +}; + + +// Info Debug levels. + +typedef UInt32 KernelDebugLevel; +enum +{ + kKernelDebugInfoLevel = 1000, + kKernelDebugRareInfoLevel = 2000, + kKernelDebugAllowedErrorLevel = 3000, + kKernelDebugAssertLevel = 4000, + kKernelDebugRequireLevel = 5000, + kKernelDebugErrorLevel = 6000, + kKernelDebugCriticalErrorLevel = 7000, + kKernelDebugTragicErrorLevel = 8000, + kKernelDebugAnyLevel = 0 +}; + +// Function prototypes. + +void KernelDebugSetLevel( KernelDebugLevel inLevel ); +KernelDebugLevel KernelDebugGetLevel(); +void KernelDebugSetOutputType( KernelDebuggingOutputType inType ); +KernelDebuggingOutputType KernelDebugGetOutputType(); +IOReturn KernelDebugFindKernelLogger(); +void KernelDebugEnable( bool enable ); + +// Yes, you can call this directly. But, why? If you use the macros declared below, such as +// KernelIOLog, you get the benefit of having your logs compiled out when you set the +// DEBUG_LEVEL to production mode and recompile. Dude. Sweet. What's mine say? + +void KernelDebugLogInternal( KernelDebugLevel inLevel, UInt32 inTag, char const *inFormatString, ... ) __attribute__ ((format(printf,3,4)));; +void KernelDebugLogDataInternal( UInt32 inLevel, UInt32 inTag, void *buffer, UInt32 byteCount, bool preBuffer); + +// Handy macros. + +#define REQUIRE_NO_ERR_PRINTF( VALUE, LABEL, ARGS... ) \ + if ( VALUE != kIOReturnSuccess ) \ + { \ + KernelDebugLogInternal( kDebugInfoLevel, 'BluD', ## ARGS ); \ + goto LABEL; \ + } + +#define REQUIRE_PRINTF( TEST, LABEL, ARGS... ) \ + do \ + { \ + if ( !( TEST ) ) \ + { \ + KernelDebugLogInternal( kDebugInfoLevel, 'BluD', ## ARGS ); \ + goto LABEL; \ + } \ + } while( false ) + +// Some macros to call the debugging outputs. We'll strip out the debug logs if we are production code. + +#if DEBUG_LEVEL != DEBUG_LEVEL_PRODUCTION +#define KernelDebugLog( LEVEL, ARGS... ) KernelDebugLogInternal( ( LEVEL ), 'KDbg', ## ARGS ) __attribute__ ((format(printf,1,2))); + #define KernelDebugLogTag( LEVEL, TAG, ARGS... ) KernelDebugLogInternal( ( LEVEL ), ( TAG ), ## ARGS ) + #define KernelDebugLogData( LEVEL, TAG, BUFFER, SIZE, HOLD) KernelDebugLogDataInternal( ( LEVEL ), ( TAG ), ( BUFFER ), ( SIZE ), ( HOLD )) +#else + #define KernelDebugLog( LEVEL, ARGS... ) + #define KernelDebugLogTag( LEVEL, TAG, ARGS... ) + #define KernelDebugLogData( LEVEL, TAG, BUFFER, SIZE, HOLD) +#endif + + +#ifdef __cplusplus + } + +//================================================================================================ +// Forward declarations +//================================================================================================ +class com_apple_iokit_KLogClient; + +//================================================================================================ +// Defines +//================================================================================================ +#define kLogKextName "com_apple_iokit_KLog" +#define MAXUSERS 5 + +//================================================================================================ +// Custom Types +//================================================================================================ + +typedef UInt32 KLogLevel; +typedef UInt32 KLogTag; + +//================================================================================================ +// com_apple_iokit_KLog +//================================================================================================ + +class com_apple_iokit_KLog : public IOService +{ + + OSDeclareDefaultStructors(com_apple_iokit_KLog) + + com_apple_iokit_KLogClient * mClientPtr[MAXUSERS+1]; + + unsigned char * mMsgBuffer; + UInt8 mClientCount; + UInt8 mMsgSize; + bool mErrFlag; + struct timeval * mTimeVal; + IOLock * mLogLock; + +public: + + static com_apple_iokit_KLog * logger; + + virtual bool init(OSDictionary *dictionary = 0); + virtual void free(void); + + virtual IOService * probe(IOService *provider, SInt32 *score); + virtual bool start(IOService *provider); + virtual void stop(IOService *provider); + virtual IOReturn newUserClient( task_t owningTask, void * securityID, + UInt32 type, IOUserClient ** handler ); + + virtual SInt8 Log( KLogLevel level, KLogTag tag, const char *format, ... ); + virtual SInt8 vLog( KLogLevel level, KLogTag tag, const char *format, va_list in_va_list ); + + void closeChild(com_apple_iokit_KLogClient *ptr); + void setErr(bool set); + +}; + +#define kMaxStatusBufSize (8*1024) + + +class IOUSBLog : public IOService +{ + OSDeclareAbstractStructors(IOUSBLog) + +private: +public: + virtual bool init( OSDictionary * dictionary = 0 ); + virtual const char * stringFromReturn( IOReturn rtn ); + static IOUSBLog *usblog(); + virtual void AddStatusLevel (UInt32 level, UInt32 ref, char *status, UInt32 value); + virtual void AddStatus(char *message); + virtual void AddStatus(UInt32 level, char *message); + virtual void USBLogPrintf(UInt32 level, char *format,...); + virtual char * strstr(const char *in, const char *str); +}; + + +#endif +#endif /* ! _IOKIT_IOUSBLOG_H */ + Index: branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBController.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBController.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBController.h (revision 885) @@ -0,0 +1,1073 @@ +/* + * Copyright (c) 1998-2010 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.2 (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, 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_IOUSBCONTROLLER_H +#define _IOKIT_IOUSBCONTROLLER_H + +//================================================================================================ +// +// Headers +// +//================================================================================================ +// +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + + +//================================================================================================ +// +// Types and Constants +// +//================================================================================================ +// +enum +{ + kErrataCMDDisableTestMode = (1 << 0), // turn off UHCI test mode + kErrataOnlySinglePageTransfers = (1 << 1), // Don't cross page boundaries in a single transfer + kErrataRetryBufferUnderruns = (1 << 2), // Don't cross page boundaries in a single transfer + kErrataLSHSOpti = (1 << 3), // Don't cross page boundaries in a single transfer + kErrataDisableOvercurrent = (1 << 4), // Always set the NOCP bit in rhDescriptorA register + kErrataLucentSuspendResume = (1 << 5), // Don't allow port suspend at the root hub + kErrataNeedsWatchdogTimer = (1 << 6), // Use Watchdog timer to reset confused controllers + kErrataNeedsPortPowerOff = (1 << 7), // Power off the ports and back on again to clear weird status. + kErrataAgereEHCIAsyncSched = (1 << 8), // needs workaround for Async Sched bug + kErrataNECOHCIIsochWraparound = (1 << 9), // needs workaround for NEC isoch buffer wraparound problem + kErrataNECIncompleteWrite = (1 << 10), // needs workaround for NEC bits not sticking (errata IBB-2UE-00030 Jun 23 2005) + kErrataICH6PowerSequencing = (1 << 11), // needs special power sequencing for early Transition machines + kErrataICH7ISTBuffer = (1 << 12), // buffer for Isochronous Scheduling Threshold + kErrataUHCISupportsOvercurrent = (1 << 13), // UHCI controller supports overcurrent detection + kErrataNeedsOvercurrentDebounce = (1 << 14), // The overcurrent indicator should be debounced by 10ms + kErrataSupportsPortResumeEnable = (1 << 15), // UHCI has resume enable bits at config address 0xC4 + kErrataNoCSonSplitIsoch = (1 << 16), // MCP79 - split iscoh is a little different + kErrataOHCINoGlobalSuspendOnSleep = (1 << 17), // when sleeping, do not put the OHCI controller in SUSPEND state. just leave it Operational with suspended downstream ports + kErrataMissingPortChangeInt = (1 << 18), // sometimes the port change interrupt may be missing + kErrataMCP79IgnoreDisconnect = (1 << 19), // MCP79 - need to ignore a connect/disconnect on wake + kErrataUse32bitEHCI = (1 << 20) , // MCP79 - EHCI should only run with 32 bit DMA addresses + kErrataUHCISupportsResumeDetectOnConnect = (1 << 21), // UHCI controller will generate a ResumeDetect interrupt while in Global Suspend if a device is plugged in + kErrataDontUseCompanionController = (1 << 22) // For systems which will end up being EHCI only +}; + +enum +{ + kUSBWatchdogTimeoutMS = 1000 +}; + + +/*! + @struct + @discussion This table contains the list of errata that are necessary for known problems with particular devices. + The format is vendorID, product ID, lowest revisionID needing errata, highest rev needing errata, errataBits. + The result of all matches is ORed together, so more than one entry may match. + Typically for a given errata a list of revisions that this applies to is supplied. + @field vendID The Vendor ID of the device + @field deviceID Product ID of device + @field revisionLo Lowest product revsion to apply errata to + @field revisionHi Highest product revision to apply errata to + @field errata Bit field flagging which errata to apply to device. +*/ + +struct ErrataListEntryStruct +{ + UInt16 vendID; + UInt16 deviceID; + UInt16 revisionLo; + UInt16 revisionHi; + UInt32 errata; +}; + +typedef struct ErrataListEntryStruct ErrataListEntry, *ErrataListEntryPtr; + + +//================================================================================================ +// +// Routines used to implement synchronous I/O +// +//================================================================================================ +// +void IOUSBSyncCompletion(void *target, void * parameter, IOReturn status, UInt32 bufferSizeRemaining); + +void IOUSBSyncIsoCompletion(void *target, void * parameter, IOReturn status, IOUSBIsocFrame *pFrames); + + +//================================================================================================ +// +// Forward Declarations +// +//================================================================================================ +// +class IOUSBDevice; +class IOUSBLog; +class IOUSBHubDevice; +class IOUSBRootHubDevice; +class IOMemoryDescriptor; + + +//================================================================================================ +// +// IOUSBController Class +// +//================================================================================================ +// +/*! + @class IOUSBController + @abstract Base class for USB hardware driver + @discussion Not many directly useful methods for USB device driver writers, + IOUSBDevice, IOUSBInterface and IOUSBPipe provide more useful abstractions. + The bulk of this class interfaces between IOKit and the low-level UIM, which is + based on the MacOS9 UIM. To impliment a new controller type, subclass + IOUSBController and impiment all the "UIM functions". AppleUSBOHCI + is an example of this implementing all the functions necessary to drive an + OHCI controller. +*/ +class IOUSBController : public IOUSBBus +{ + OSDeclareAbstractStructors(IOUSBController) + friend class IOUSBControllerV2; + friend class IOUSBControllerV3; + +protected: + + IOUSBWorkLoop * _workLoop; + IOCommandGate * _commandGate; + IOUSBRootHubDevice * _rootHubDevice; + UInt32 _devZeroLock; + static UInt32 _busCount; + static bool gUsedBusIDs[256]; + + struct ExpansionData + { + IOCommandPool *freeUSBCommandPool; + IOCommandPool *freeUSBIsocCommandPool; + IOTimerEventSource *watchdogUSBTimer; + bool _terminating; + bool _watchdogTimerActive; + bool _pcCardEjected; // Obsolete + UInt32 _busNumber; + UInt32 _currentSizeOfCommandPool; + UInt32 _currentSizeOfIsocCommandPool; + UInt8 _controllerSpeed; // Controller speed, passed down for splits + thread_call_t _terminatePCCardThread; // Obsolete + bool _addressPending[128]; + SInt32 _activeIsochTransfers; // isochronous transfers in the queue + IOService *_provider; // common name for our provider + bool _controllerCanSleep; // true iff the controller is able to support sleep/wake + bool _needToClose; + UInt32 _isochMaxBusStall; // value (in ns) of the maximum PCI bus stall allowed for Isoch.. + }; + ExpansionData *_expansionData; + + // The following methods do not use and upper case initial letter because they are part of IOKit + // + +public: + virtual bool init( OSDictionary * propTable ); + virtual bool start( IOService * provider ); + virtual void stop( IOService * provider ); + virtual bool finalize(IOOptionBits options); + virtual IOReturn message( UInt32 type, IOService * provider, void * argument = 0 ); + virtual bool didTerminate( IOService * provider, IOOptionBits options, bool * defer ); + +protected: + + IOReturn getNubResources( IOService * regEntry ); + + virtual UInt32 GetErrataBits( + UInt16 vendorID, + UInt16 deviceID, + UInt16 revisionID ); + + + static IOReturn DoDeleteEP( + OSObject * owner, + void * arg0, + void * arg1, + void * arg2, + void * arg3 ); + + static IOReturn DoAbortEP( + OSObject * owner, + void * arg0, + void * arg1, + void * arg2, + void * arg3 ); + + static IOReturn DoClearEPStall( + OSObject * owner, + void * arg0, + void * arg1, + void * arg2, + void * arg3 ); + + static IOReturn DoCreateEP( + OSObject * owner, + void * arg0, + void * arg1, + void * arg2, + void * arg3 ); + static IOReturn DoControlTransfer( + OSObject * owner, + void * arg0, + void * arg1, + void * arg2, + void * arg3 ); + + static IOReturn DoIOTransfer( + OSObject * owner, + void * arg0, + void * arg1, + void * arg2, + void * arg3 ); + + static IOReturn DoIsocTransfer( + OSObject * owner, + void * arg0, + void * arg1, + void * arg2, + void * arg3 ); + + static IOReturn DoLowLatencyIsocTransfer( + OSObject * owner, + void * arg0, + void * arg1, + void * arg2, + void * arg3 ); + + static void ControlPacketHandler( + OSObject * target, + void * parameter, + IOReturn status, + UInt32 bufferSizeRemaining ); + + static void InterruptPacketHandler( + OSObject * target, + void * parameter, + IOReturn status, + UInt32 bufferSizeRemaining ); + + static void BulkPacketHandler( + OSObject * target, + void * parameter, + IOReturn status, + UInt32 bufferSizeRemaining ); + + static void IsocCompletionHandler( + OSObject * target, + void * parameter, + IOReturn status, + IOUSBIsocFrame *pFrames ); + + static void LowLatencyIsocCompletionHandler( + OSObject * target, + void * parameter, + IOReturn status, + IOUSBLowLatencyIsocFrame *pFrames ); + + static void WatchdogTimer(OSObject *target, IOTimerEventSource *sender); + + // Obsolete + static void TerminatePCCard(OSObject *target); + + static IOReturn ProtectedDevZeroLock(OSObject *target, void* lock, void *, void *, void*); + + + USBDeviceAddress GetNewAddress( void ); + + IOReturn ControlTransaction( IOUSBCommand * command ); + + IOReturn InterruptTransaction( IOUSBCommand * command ); + + IOReturn BulkTransaction( IOUSBCommand * command ); + + IOReturn IsocTransaction( IOUSBIsocCommand * command ); + + IOReturn LowLatencyIsocTransaction( IOUSBIsocCommand * command ); + + void FreeCommand( IOUSBCommand * command ); + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + // Invokes the specified completion action of the request. If + // the completion action is unspecified, no action is taken. + void Complete( + IOUSBCompletion completion, + IOReturn status, + UInt32 actualByteCount = 0 ); + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + // Invokes the specified completion action of the request. If + // the completion action is unspecified, no action is taken. + void CompleteWithTimeStamp ( + IOUSBCompletionWithTimeStamp completion, + IOReturn status, + UInt32 actualByteCount, + AbsoluteTime timeStamp); + + + + // + // UIM methods + // + +/*! + @function UIMInitialize + @abstract UIM function, initialise the controller and UIM data structures. +*/ + virtual IOReturn UIMInitialize( IOService * provider ) = 0; + +/*! + @function UIMFinalize + @abstract UIM function, finalise the controller and UIM data structures prior to removal. +*/ + virtual IOReturn UIMFinalize() = 0; + + // Control +/*! + @function UIMCreateControlEndpoint + @abstract UIM function, create a control endpoint for the controller. + @param functionNumber The USB device ID of the device for this endpoint + @param endpointNumber The endpoint number for this endpoint + @param maxPacketSize Maximum packet size of this endpoint + @param speed speed of the device: kUSBDeviceSpeedLow or kUSBDeviceSpeedFull +*/ + virtual IOReturn UIMCreateControlEndpoint( + UInt8 functionNumber, + UInt8 endpointNumber, + UInt16 maxPacketSize, + UInt8 speed) = 0; + +/* Note: this function has been superceded. */ + virtual IOReturn UIMCreateControlTransfer( short functionNumber, + short endpointNumber, + IOUSBCompletion completion, + void * CBP, + bool bufferRounding, + UInt32 bufferSize, + short direction) = 0; + +/*! + @function UIMCreateControlTransfer + @abstract UIM function, Do a transfer on a control endpoint. + This method supercedes the method which takes a void * parameter. + @param functionNumber The USB device ID of the device to perform the transaction with + @param endpointNumber The endpoint number for the transaction + @param completion Action to perform when I/O completes + @param CBP Memory descriptor describing the buffer to transfer. Will never describe + memory which has disjoint packets. + @param bufferRounding If true, short packets are OK and do not cause an error + @param bufferSize Size of the data to transfer in the data phase. (C + @param direction Specifies direction and PID for transaction. kUSBIn, KUSBOut (DATA PID) or kUSBSetup (SETUP PID). +*/ + virtual IOReturn UIMCreateControlTransfer( short functionNumber, + short endpointNumber, + IOUSBCompletion completion, + IOMemoryDescriptor * CBP, + bool bufferRounding, + UInt32 bufferSize, + short direction) = 0; + + // Bulk +/*! + @function UIMCreateBulkEndpoint + @abstract UIM function, create a bulk endpoint for the controller. + @param functionNumber The USB device ID of the device for this endpoint + @param endpointNumber The endpoint number for this endpoint + @param direction Specifies direction for the endpoint. kUSBIn or KUSBOut. + @param speed speed of the device: kUSBDeviceSpeedLow or kUSBDeviceSpeedFull + @param maxPacketSize Maximum packet size of this endpoint +*/ + virtual IOReturn UIMCreateBulkEndpoint( + UInt8 functionNumber, + UInt8 endpointNumber, + UInt8 direction, + UInt8 speed, + UInt8 maxPacketSize) = 0; + +/* Note: this function has been superceded. */ + virtual IOReturn UIMCreateBulkTransfer( short functionNumber, + short endpointNumber, + IOUSBCompletion completion, + IOMemoryDescriptor * CBP, + bool bufferRounding, + UInt32 bufferSize, + short direction) = 0; + + // Interrupt +/*! + @function UIMCreateInterruptEndpoint + @abstract UIM function, create an interrupt endpoint for the controller. + @param functionNumber The USB device ID of the device for this endpoint + @param endpointNumber The endpoint number for this endpoint + @param direction Specifies direction for the endpoint. kUSBIn or KUSBOut. + @param speed speed of the device: kUSBDeviceSpeedLow or kUSBDeviceSpeedFull + @param maxPacketSize Maximum packet size of this endpoint + @param pollingRate The maximum polling interval from the endpoint descriptor. +*/ + virtual IOReturn UIMCreateInterruptEndpoint( + short functionAddress, + short endpointNumber, + UInt8 direction, + short speed, + UInt16 maxPacketSize, + short pollingRate) = 0; + +/* Note: this function has been superceded. */ + virtual IOReturn UIMCreateInterruptTransfer( short functionNumber, + short endpointNumber, + IOUSBCompletion completion, + IOMemoryDescriptor * CBP, + bool bufferRounding, + UInt32 bufferSize, + short direction) = 0; + + // Isoch +/*! + @function UIMCreateIsochEndpoint + @abstract Create an Isochronous endpoint in the controller. + @param functionNumber The USB device ID of the device for this endpoint + @param endpointNumber The endpoint number for this endpoint + @param maxPacketSize Maximum packet size of this endpoint + @param direction Specifies direction for the endpoint. kUSBIn or KUSBOut. +*/ + virtual IOReturn UIMCreateIsochEndpoint( + short functionAddress, + short endpointNumber, + UInt32 maxPacketSize, + UInt8 direction) = 0; + +/*! + @function UIMCreateIsochTransfer + @abstract UIM function, Do a transfer on an Isocchronous endpoint. + @param functionNumber The USB device ID of the device to perform the transaction with + @param endpointNumber The endpoint number for the transaction + @param completion Action to perform when I/O completes + @param direction Specifies direction for transfer. kUSBIn or KUSBOut. + @param frameStart The frame number in which to start the transactions + @param pBuffer describes memory buffer. + @param frameCount number of frames to do transactions in + @param pFrames Describes transactions in individual frames, gives sizes and reults for transactions. +*/ + virtual IOReturn UIMCreateIsochTransfer( + short functionAddress, + short endpointNumber, + IOUSBIsocCompletion completion, + UInt8 direction, + UInt64 frameStart, + IOMemoryDescriptor * pBuffer, + UInt32 frameCount, + IOUSBIsocFrame *pFrames) = 0; + +/*! + @function UIMAbortEndpoint + @abstract UIM function Abort the specified endpoint, return all transactions queued on it. + @param functionNumber The USB device ID of the device to Abort + @param endpointNumber The endpoint number to Abort + @param direction Specifies direction of the endpoint for uniqueness. kUSBIn or KUSBOut. +*/ + virtual IOReturn UIMAbortEndpoint( + short functionNumber, + short endpointNumber, + short direction) = 0; + +/*! + @function UIMDeleteEndpoint + @abstract UIM function Delete the specified endpoint, returning all transactions queued on it. + @param functionNumber The USB device ID of the device to Delete + @param endpointNumber The endpoint number to Delete + @param direction Specifies direction of the endpoint for uniqueness. kUSBIn or KUSBOut. +*/ + virtual IOReturn UIMDeleteEndpoint( + short functionNumber, + short endpointNumber, + short direction) = 0; + +/*! + @function UIMClearEndpointStall + @abstract UIM function Clear stall on the specified endpoint, set data toggle to zero, + return all transactions queued on it. + @param functionNumber The USB device ID of the device to Clear + @param endpointNumber The endpoint number to Clear + @param direction Specifies direction of the endpoint for uniqueness. kUSBIn or KUSBOut. +*/ + virtual IOReturn UIMClearEndpointStall( + short functionNumber, + short endpointNumber, + short direction) = 0; + +/*! + @function UIMRootHubStatusChange + @abstract UIM function UIMRootHubStatusChange - This method was internal to the UIM (never called by the superclass) until + IOUSBControllerV3. For UIMs which are a subclass of IOUSBController or IOUSBControllerV2, it can + still be used internally only. For subclasses of IOUSBControllerV3, however, the meaning has changed + slightly. Now, it is used to determine if there is a status change on the root hub, and if so, it + needs to update the IOUSBControllerV3 instance variable _rootHubStatusChangedBitmap +*/ + virtual void UIMRootHubStatusChange(void) = 0; + + static const IORegistryPlane *gIOUSBPlane; + +public: + + static IOUSBLog *_log; + + IOCommandGate * GetCommandGate(void); + + /*! + @struct Endpoint + Describes an endpoint of a device. + Simply an easier to use version of the endpoint descriptor. + @field descriptor The raw endpoint descriptor. + @field number Endpoint number + @field direction Endpoint direction: kUSBOut, kUSBIn, kUSBAnyDirn + @field transferType Type of endpoint: kUSBControl, kUSBIsoc, kUSBBulk, kUSBInterrupt + @field maxPacketSize Maximum packet size for endpoint + @field interval Polling interval in milliseconds (only relevent for Interrupt endpoints) + */ + struct Endpoint { + IOUSBEndpointDescriptor * descriptor; + UInt8 number; + UInt8 direction; // in, out + UInt8 transferType; // cntrl, bulk, isoc, int + UInt16 maxPacketSize; + UInt8 interval; + }; + + // Implements IOService::getWorkLoop const member function + virtual IOWorkLoop * getWorkLoop() const; + + /* + * Root hub methods + * Only of interest to the IOUSBRootHubDevice object + */ +/*! + @function GetRootHubDeviceDescriptor + @abstract UIM function, return the device descriptor of the simulated root hub device + As GET_DESCRIPTOR control request for device descrptor + @param desc Descriptor structure to return data in +*/ + virtual IOReturn GetRootHubDeviceDescriptor( IOUSBDeviceDescriptor *desc ) = 0; + +/*! + @function GetRootHubDescriptor + @abstract UIM function, return the hub descriptor of the simulated root hub device + As GET_DESCRIPTOR control request for hub descrptor + @param desc Descriptor structure to return data in +*/ + virtual IOReturn GetRootHubDescriptor( IOUSBHubDescriptor *desc ) = 0; + +/*! + @function SetRootHubDescriptor + @abstract UIM function, optional. Set the hub descriptor data. + As SET_DESCRIPTOR control request for hub descrptor + @param buffer Descriptor data +*/ + virtual IOReturn SetRootHubDescriptor( OSData *buffer ) = 0; + +/*! + @function GetRootHubConfDescriptor + @abstract UIM function, retrun the configuration descriptor of the simulated root hub device + As GET_DESCRIPTOR control request for configuration descrptor + @param desc Descriptor structure to return data in +*/ + virtual IOReturn GetRootHubConfDescriptor( OSData *desc ) = 0; + +/*! + @function GetRootHubStatus + @abstract UIM function, get the status of the root hub. As GET_STATUS control request to device. + @param status Status structure to return +*/ + virtual IOReturn GetRootHubStatus( IOUSBHubStatus *status ) = 0; + +/*! + @function SetRootHubFeature + @abstract UIM function, set feature of root hub, As SET_FEATURE control request. + @param wValue The feature to set, as would be transferred in wValue field of SETUP packet. +*/ + virtual IOReturn SetRootHubFeature( UInt16 wValue ) = 0; + +/*! + @function ClearRootHubFeature + @abstract UIM function, set feature of root hub, As CLEAR_FEATURE control request. + @param wValue The feature to clear, as would be transferred in wValue field of SETUP packet. +*/ + virtual IOReturn ClearRootHubFeature( UInt16 wValue ) = 0; + +/*! + @function GetRootHubPortStatus + @abstract UIM function, get the status of a root hub port. As GET_STATUS control request to the port. + @param status Status structure to return + @param port Port to get status for. +*/ + virtual IOReturn GetRootHubPortStatus( IOUSBHubPortStatus *status, UInt16 port ) = 0; + +/*! + @function SetRootHubPortFeature + @abstract UIM function, set feature of a root hub port, As SET_FEATURE control request to a port. + @param wValue The feature to set, as would be transferred in wValue field of SETUP packet. + @param port Port to set feature for +*/ + virtual IOReturn SetRootHubPortFeature( UInt16 wValue, UInt16 port ) = 0; + +/*! + @function ClearRootHubPortFeature + @abstract UIM function, clear feature of a root hub port, As CLEAR_FEATURE control request to a port. + @param wValue The feature to clear, as would be transferred in wValue field of SETUP packet. + @param port Port to clear feature for +*/ + virtual IOReturn ClearRootHubPortFeature( UInt16 wValue, UInt16 port ) = 0; + +/*! + @function ClearRootHubPortFeature + @abstract UIM function, Impliments GET_BUS_STATE control request, now obsolete. +*/ + virtual IOReturn GetRootHubPortState( UInt8 *state, UInt16 port ) = 0; + +/*! + @function SetHubAddress + @abstract UIM function, set the address of the simulated root hub device, as SET_ADDRESS + @param wValue New address for root hub. +*/ + virtual IOReturn SetHubAddress( UInt16 wValue ) = 0; + + + /*! + @function openPipe + Open a pipe to the specified device endpoint + @param address Address of the device on the USB bus + @param speed of the device: kUSBHighSpeed or kUSBLowSpeed + @param endpoint description of endpoint to connect to + */ + virtual IOReturn OpenPipe( USBDeviceAddress address, + UInt8 speed, + Endpoint * endpoint ); + /*! + @function closePipe + Close a pipe to the specified device endpoint + @param address Address of the device on the USB bus + @param endpoint description of endpoint + */ + virtual IOReturn ClosePipe( USBDeviceAddress address, + Endpoint * endpoint ); + + // Controlling pipe state + /*! + @function abortPipe + Abort pending I/O to/from the specified endpoint, causing them to complete with return code kIOReturnAborted + @param address Address of the device on the USB bus + @param endpoint description of endpoint + */ + virtual IOReturn AbortPipe( + USBDeviceAddress address, + Endpoint * endpoint ); + /*! + @function resetPipe + Abort pending I/O and clear stalled state - this method is a combination of abortPipe and clearPipeStall + @param address Address of the device on the USB bus + @param endpoint description of endpoint + */ + virtual IOReturn ResetPipe( USBDeviceAddress address, + Endpoint * endpoint ); + /*! + @function clearPipeStall + Clear a pipe stall. + @param address Address of the device on the USB bus + @param endpoint description of endpoint + */ + virtual IOReturn ClearPipeStall( USBDeviceAddress address, + Endpoint * endpoint ); + + // Transferring Data + /*! + @function read + Read from an interrupt or bulk endpoint + @param buffer place to put the transferred data + @param address Address of the device on the USB bus + @param endpoint description of endpoint + @param completion describes action to take when buffer has been filled + */ + virtual IOReturn Read( IOMemoryDescriptor * buffer, + USBDeviceAddress address, + Endpoint * endpoint, + IOUSBCompletion * completion ); + /*! + @function write + Write to an interrupt or bulk endpoint + @param buffer place to get the transferred data + @param address Address of the device on the USB bus + @param endpoint description of endpoint + @param completion describes action to take when buffer has been emptied + */ + virtual IOReturn Write( IOMemoryDescriptor * buffer, + USBDeviceAddress address, + Endpoint * endpoint, + IOUSBCompletion * completion ); + + /*! + @function isocIO + Read from or write to an isochronous endpoint + @param buffer place to put the transferred data + @param frameStart USB frame number of the frame to start transfer + @param numFrames Number of frames to transfer + @param frameList Bytes to transfer and result for each frame + @param address Address of the device on the USB bus + @param endpoint description of endpoint + @param completion describes action to take when buffer has been filled + */ + virtual IOReturn IsocIO( IOMemoryDescriptor * buffer, + UInt64 frameStart, + UInt32 numFrames, + IOUSBIsocFrame * frameList, + USBDeviceAddress address, + Endpoint * endpoint, + IOUSBIsocCompletion * completion ); + /*! + @function deviceRequest + Make a control request to the specified endpoint + There are two versions of this method, one uses a simple void * + to point to the data portion of the transfer, the other uses an + IOMemoryDescriptor to point to the data. + @param request parameter block for the control request + @param completion describes action to take when the request has been executed + @param address Address of the device on the USB bus + @param epNum endpoint number + */ + virtual IOReturn DeviceRequest( IOUSBDevRequest * request, + IOUSBCompletion * completion, + USBDeviceAddress address, + UInt8 epNum ); + + virtual IOReturn DeviceRequest( IOUSBDevRequestDesc * request, + IOUSBCompletion * completion, + USBDeviceAddress address, + UInt8 epNum ); + + /* + * Methods used by the hub driver to initialize a device + */ + /*! + @function AcquireDeviceZero + Get the device zero lock - call this before resetting a device, to ensure there's + only one device with address 0 + */ + virtual IOReturn AcquireDeviceZero( void ); + /*! + @function ReleaseDeviceZero + Release the device zero lock - call this to release the device zero lock, + when there is no longer a device at address 0 + */ + virtual void ReleaseDeviceZero( void ); + + // non-virtual methods + void WaitForReleaseDeviceZero( void ); + IOReturn ConfigureDeviceZero( UInt8 maxPacketSize, UInt8 speed ); + IOReturn GetDeviceZeroDescriptor( IOUSBDeviceDescriptor * desc, UInt16 size ); + IOReturn SetDeviceZeroAddress(USBDeviceAddress address); + IOUSBDevice * MakeDevice(USBDeviceAddress *address); + IOUSBHubDevice * MakeHubDevice(USBDeviceAddress *address); + IOReturn CreateDevice( IOUSBDevice * device, + USBDeviceAddress deviceAddress, + UInt8 maxPacketSize, + UInt8 speed, + UInt32 powerAvailable ); + + /*! + @function GetBandwidthAvailable + Returns the available bandwidth (in bytes) per frame or microframe for + isochronous transfers. + @result maximum number of bytes that a new iso pipe could transfer + per frame given current allocations. + */ + virtual UInt32 GetBandwidthAvailable( void ) = 0; + + /*! + @function GetFrameNumber + Returns the full current frame number. + @result The frame number. + */ + virtual UInt64 GetFrameNumber( void ) = 0; + + /*! + @function GetFrameNumber32 + Returns the least significant 32 bits of the frame number. + @result The lsb 32 bits of the frame number. + */ + virtual UInt32 GetFrameNumber32( void ) = 0; + + // Debugger polled mode + virtual void PollInterrupts( IOUSBCompletionAction safeAction = 0 ) = 0; + + virtual IOReturn PolledRead( + short functionNumber, + short endpointNumber, + IOUSBCompletion completion, + IOMemoryDescriptor * CBP, + bool bufferRounding, + UInt32 bufferSize); + + OSMetaClassDeclareReservedUsed(IOUSBController, 0); + virtual void UIMCheckForTimeouts(void); + + OSMetaClassDeclareReservedUsed(IOUSBController, 1); + virtual IOReturn UIMCreateControlTransfer( short functionNumber, + short endpointNumber, + IOUSBCommand* command, + void* CBP, + bool bufferRounding, + UInt32 bufferSize, + short direction); + + OSMetaClassDeclareReservedUsed(IOUSBController, 2); + virtual IOReturn UIMCreateControlTransfer( short functionNumber, + short endpointNumber, + IOUSBCommand* command, + IOMemoryDescriptor* CBP, + bool bufferRounding, + UInt32 bufferSize, + short direction); + + OSMetaClassDeclareReservedUsed(IOUSBController, 3); +/*! + @function UIMCreateBulkTransfer + @abstract UIM function, Do a transfer on a bulk endpoint. + This method supercedes the method which takes multiple parameters. + @param command paramters for transfer. +*/ + virtual IOReturn UIMCreateBulkTransfer(IOUSBCommand* command); + + OSMetaClassDeclareReservedUsed(IOUSBController, 4); +/*! + @function UIMCreateInterruptTransfer + @abstract UIM function, Do a transfer on an interrupt endpoint. + This method supercedes the method which takes multiple parameters. + @param command paramters for transfer. +*/ + virtual IOReturn UIMCreateInterruptTransfer(IOUSBCommand* command); + + /*! + @function deviceRequest + Make a control request to the specified endpoint + There are two versions of this method, one uses a simple void * + to point to the data portion of the transfer, the other uses an + IOMemoryDescriptor to point to the data. + @param request parameter block for the control request + @param completion describes action to take when the request has been executed + @param address Address of the device on the USB bus + @param epNum endpoint number + */ + OSMetaClassDeclareReservedUsed(IOUSBController, 5); + virtual IOReturn DeviceRequest( IOUSBDevRequest * request, + IOUSBCompletion * completion, + USBDeviceAddress address, + UInt8 epNum, + UInt32 noDataTimeout, + UInt32 completionTimeout ); + + OSMetaClassDeclareReservedUsed(IOUSBController, 6); + virtual IOReturn DeviceRequest( IOUSBDevRequestDesc * request, + IOUSBCompletion * completion, + USBDeviceAddress address, + UInt8 epNum, + UInt32 noDataTimeout, + UInt32 completionTimeout ); + + + + OSMetaClassDeclareReservedUsed(IOUSBController, 7); + /*! + @function read + Read from an interrupt or bulk endpoint + @param buffer place to put the transferred data + @param address Address of the device on the USB bus + @param endpoint description of endpoint + @param completion describes action to take when buffer has been filled + */ + virtual IOReturn Read( IOMemoryDescriptor * buffer, + USBDeviceAddress address, + Endpoint * endpoint, + IOUSBCompletion * completion, + UInt32 noDataTimeout, + UInt32 completionTimeout ); + + OSMetaClassDeclareReservedUsed(IOUSBController, 8); + /*! + @function write + Write to an interrupt or bulk endpoint + @param buffer place to get the transferred data + @param address Address of the device on the USB bus + @param endpoint description of endpoint + @param completion describes action to take when buffer has been emptied + */ + virtual IOReturn Write( IOMemoryDescriptor * buffer, + USBDeviceAddress address, + Endpoint * endpoint, + IOUSBCompletion * completion, + UInt32 noDataTimeout, + UInt32 completionTimeout ); + + // this should really not be using a padding slot, since free is in our superclas, but we shipped this way so now we need to leave it. + OSMetaClassDeclareReservedUsed(IOUSBController, 9); + virtual void free(); + +protected: + +/*! + @function UIMRootHubStatusChange(bool) + @abstract UIM function UIMRootHubStatusChange(bool) - This method was internal to the UIM (never called by the superclass) until + IOUSBControllerV3. For UIMs which are a subclass of IOUSBController or IOUSBControllerV2, it can + still be used internally only. For subclasses of IOUSBControllerV3, however, it has become obsolete + (it still needs to be implemented since it is pure virtual) +*/ + OSMetaClassDeclareReservedUsed(IOUSBController, 10); + virtual void UIMRootHubStatusChange( bool abort ) = 0; + +public: + + OSMetaClassDeclareReservedUsed(IOUSBController, 11); + virtual IOReturn CreateRootHubDevice( IOService * provider, IOUSBRootHubDevice ** rootHubDevice); + + OSMetaClassDeclareReservedUsed(IOUSBController, 12); + /*! + @function Read + Read from an interrupt or bulk endpoint + @param buffer place to put the transferred data + @param address Address of the device on the USB bus + @param endpoint description of endpoint + @param completion describes action to take when buffer has been filled + @param noDataTimeout number of milliseconds of no data movement before the request is aborted + @param completionTimeout number of milliseonds after the command is on the bus in which it must complete + @param reqCount number of bytes requested for the transfer (must not be greater than the length of the buffer) + */ + virtual IOReturn Read( IOMemoryDescriptor * buffer, + USBDeviceAddress address, + Endpoint * endpoint, + IOUSBCompletion * completion, + UInt32 noDataTimeout, + UInt32 completionTimeout, + IOByteCount reqCount ); + + OSMetaClassDeclareReservedUsed(IOUSBController, 13); + /*! + @function Write + Write to an interrupt or bulk endpoint + @param buffer place to get the transferred data + @param address Address of the device on the USB bus + @param endpoint description of endpoint + @param completion describes action to take when buffer has been emptied + @param noDataTimeout number of milliseconds of no data movement before the request is aborted + @param completionTimeout number of milliseonds after the command is on the bus in which it must complete + @param reqCount number of bytes requested for the transfer (must not be greater than the length of the buffer) + */ + virtual IOReturn Write( IOMemoryDescriptor * buffer, + USBDeviceAddress address, + Endpoint * endpoint, + IOUSBCompletion * completion, + UInt32 noDataTimeout, + UInt32 completionTimeout, + IOByteCount reqCount ); + + OSMetaClassDeclareReservedUsed(IOUSBController, 14); + + virtual IOReturn GetRootHubStringDescriptor(UInt8 index, OSData *desc) = 0; + + OSMetaClassDeclareReservedUsed(IOUSBController, 15); + /*! + @function IsocIO + Read from or write to an isochronous endpoint + @param buffer place to put the transferred data + @param frameStart USB frame number of the frame to start transfer + @param numFrames Number of frames to transfer + @param frameList Bytes to transfer and result for each frame + @param address Address of the device on the USB bus + @param endpoint description of endpoint + @param completion describes action to take when buffer has been filled + @param updateFrequency describes how often to update the framelist once the transfer has completed (in ms) + */ + virtual IOReturn IsocIO( IOMemoryDescriptor * buffer, + UInt64 frameStart, + UInt32 numFrames, + IOUSBLowLatencyIsocFrame * frameList, + USBDeviceAddress address, + Endpoint * endpoint, + IOUSBLowLatencyIsocCompletion * completion, + UInt32 updateFrequency ); + + OSMetaClassDeclareReservedUsed(IOUSBController, 16); + + /*! + @function UIMCreateIsochTransfer + @abstract UIM function, Do a transfer on an Isocchronous endpoint. + @param functionNumber The USB device ID of the device to perform the transaction with + @param endpointNumber The endpoint number for the transaction + @param completion Action to perform when I/O completes + @param direction Specifies direction for transfer. kUSBIn or KUSBOut. + @param frameStart The frame number in which to start the transactions + @param pBuffer describes memory buffer. + @param frameCount number of frames to do transactions in + @param pFrames Describes transactions in individual frames, gives sizes and reults for transactions. + @param updateFrequency Describes how often we update the frameList parameters (in ms) + */ + virtual IOReturn UIMCreateIsochTransfer( + short functionAddress, + short endpointNumber, + IOUSBIsocCompletion completion, + UInt8 direction, + UInt64 frameStart, + IOMemoryDescriptor * pBuffer, + UInt32 frameCount, + IOUSBLowLatencyIsocFrame *pFrames, + UInt32 updateFrequency); + + + OSMetaClassDeclareReservedUsed(IOUSBController, 17); + virtual IOReturn CheckForDisjointDescriptor(IOUSBCommand *command, UInt16 maxPacketSize); + + /*! + @function UIMCreateIsochTransfer + @abstract UIM function, Do a transfer on an Isocchronous endpoint. + @param command an IOUSBIsocCommand object with all the necessary information + */ + OSMetaClassDeclareReservedUsed(IOUSBController, 18); + virtual IOReturn UIMCreateIsochTransfer(IOUSBIsocCommand *command); + + // do not use this slot without first checking bug rdar://6022420 + OSMetaClassDeclareReservedUnused(IOUSBController, 19); + +protected: + void IncreaseIsocCommandPool(); + void IncreaseCommandPool(); + void ParsePCILocation(const char *str, int *deviceNum, int *functionNum); + int ValueOfHexDigit(char c); +}; + +#endif /* ! _IOKIT_IOUSBCONTROLLER_H */ + Index: branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBNub.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBNub.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/usb/IOUSBNub.h (revision 885) @@ -0,0 +1,69 @@ +/* + * Copyright (c) 1998-2006 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_IOUSBNUB_H +#define _IOKIT_IOUSBNUB_H + +#include +#include +#include + +#include + +class IOUSBController; +class IOUSBPipe; + +/*! + @class IOUSBNub + @abstract Super class for for IOUSBDevice and IOUSBInterface. + */ +class IOUSBNub : public IOService +{ + OSDeclareDefaultStructors(IOUSBNub) + +public: + + // IOKit method + virtual void joinPMtree ( IOService * driver ); + + virtual bool USBCompareProperty(OSDictionary * matching, const char * key ); + + bool IsWildCardMatch( OSDictionary * matching, const char * key ); + bool USBComparePropertyWithMask( OSDictionary *matching, const char *key, const char * maskKey ); +}; + +#ifdef __cplusplus +extern "C" { +#endif + +void printDescriptor(const IOUSBDescriptorHeader *desc); +void printDeviceDescriptor(const IOUSBDeviceDescriptor *desc); +void printConfigDescriptor(const IOUSBConfigurationDescriptor *cd); +void printEndpointDescriptor(const IOUSBEndpointDescriptor *ed); +void printInterfaceDescriptor(const IOUSBInterfaceDescriptor *id); + +#ifdef __cplusplus +} +#endif + +#endif /* _IOKIT_IOUSBNUB_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/usb/USBHub.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/usb/USBHub.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/usb/USBHub.h (revision 885) @@ -0,0 +1,240 @@ +/* + * Copyright (c) 1998-2006 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 _USBHUB_H +#define _USBHUB_H + +#include +#include + + /*! + @header USBHub.h + @abstract Constants and definitions used with Hub devices. + @discussion + */ + + /*! + @enum Hub Descriptor Type + @discussion + */ +enum { + kUSBHubDescriptorType = 0x29 +}; + + /*! + @enum HubFeatures + @discussion Used with SET_FEATURE to set hub and port features + */ +enum { + + kUSBHubLocalPowerChangeFeature = 0, /* Hub features */ + kUSBHubOverCurrentChangeFeature = 1, + + kUSBHubPortConnectionFeature = 0, /* port features */ + kUSBHubPortEnableFeature = 1, + kUSBHubPortSuspendFeature = 2, + kUSBHubPortOverCurrentFeature = 3, + kUSBHubPortResetFeature = 4, + kUSBHubPortPowerFeature = 8, + kUSBHubPortLowSpeedFeature = 9, + kUSBHubPortConnectionChangeFeature = 16, + kUSBHubPortEnableChangeFeature = 17, + kUSBHubPortSuspendChangeFeature = 18, + kUSBHubPortOverCurrentChangeFeature = 19, + kUSBHubPortResetChangeFeature = 20, + kUSBHubPortTestFeature = 21, + kUSBHubPortIndicatorFeature = 22 +}; + + /*! + @enum HubPortStatus + @discussion Used to decode the Port Status and Change + */ +enum { + kHubPortConnection = 0x0001, + kHubPortEnabled = 0x0002, + kHubPortSuspend = 0x0004, + kHubPortOverCurrent = 0x0008, + kHubPortBeingReset = 0x0010, + kHubPortPower = 0x0100, + kHubPortLowSpeed = 0x0200, + kHubPortHighSpeed = 0x0400, + kHubPortTestMode = 0x0800, + kHubPortIndicator = 0x1000, + + // these are the bits which cause the hub port state machine to keep moving + kHubPortStateChangeMask = kHubPortConnection | kHubPortEnabled | kHubPortSuspend | kHubPortOverCurrent | kHubPortBeingReset +}; + + + /*! + @enum HubStatus + @discussion Used to decode the Hub Status and Change + */ +enum { + kHubLocalPowerStatus = 1, + kHubOverCurrentIndicator = 2, + kHubLocalPowerStatusChange = 1, + kHubOverCurrentIndicatorChange = 2 +}; + + /*! + @enum HubCharacteristics + @discussion + */ +enum { + kPerPortSwitchingBit = (1 << 0), + kNoPowerSwitchingBit = (1 << 1), + kCompoundDeviceBit = (1 << 2), + kPerPortOverCurrentBit = (1 << 3), + kNoOverCurrentBit = (1 << 4), + + kHubPortIndicatorBit = 7, + kHubPortIndicatorMask = 0x0080 +}; + +/*! +@enum PowerSwitching + @discussion + */ +enum { + kHubSupportsGangPower = 0, + kHubSupportsIndividualPortPower = 1, + kHubPortSetPowerOff = 0, + kHubPortSetPowerOn = 1 +}; + +/*! +@enum PortIndicatorSelectors + @discussion + */ +enum { + kHubPortIndicatorAutomatic = 0, + kHubPortIndicatorAmber, + kHubPortIndicatorGreen, + kHubPortIndicatorOff +}; + +/*! + @enum Root Hub specific + @discussion + */ +enum { + kPrdRootHubApple = 0x8005, // ProductID for classic speed root hubs + kPrdRootHubAppleE = 0x8006, // ProductID for high speed root hubs + kUSBRootHubPollingRate = 32 // Enpoint polling rate interval for root hubs +}; + +/*! +@enum Hub Device Requests +@discussion Encoding of the hub specific standard requests + +

+Request          bmRequestType bRequest       wValue  wIndex wLength Data
+ClearHubFeature  0010 0000B    CLEAR_FEATURE  Feature Zero    Zero   None
+ClearPortFeature 0010 0011B                   Feature Port    Zero   None
+
+GetBusState      1010 0011B    GET_STATE      Zero    Port    One    Port Bus State
+
+GetHubDescriptor 1010 0000B    GET_DESCRIPTOR Type    Zero    Length Descriptor
+
+GetHubStatus     1010 0000B    GET_STATUS     Zero    Zero    Four   Hub Status
+GetPortStatus    1010 0011B                   Zero    Port    Four   Port Status
+
+SetHubDescriptor 0010 0000B    SET_DESCRIPTOR Type    Zero    Length Descriptor
+
+SetHubFeature    0010 0000B    SET_FEATURE    Feature Zero    Zero   None
+SetPortFeature   0010 0011B                   Feature Port    Zero   None
+
+
+ */ +enum { + kClearHubFeature = EncodeRequest(kUSBRqClearFeature, kUSBOut, kUSBClass, kUSBDevice), + kClearPortFeature = EncodeRequest(kUSBRqClearFeature, kUSBOut, kUSBClass, kUSBOther), + kGetPortState = EncodeRequest(kUSBRqGetState, kUSBIn, kUSBClass, kUSBOther), + kGetHubDescriptor = EncodeRequest(kUSBRqGetDescriptor, kUSBIn, kUSBClass, kUSBDevice), + kGetHubStatus = EncodeRequest(kUSBRqGetStatus, kUSBIn, kUSBClass, kUSBDevice), + kGetPortStatus = EncodeRequest(kUSBRqGetStatus, kUSBIn, kUSBClass, kUSBOther), + kSetHubDescriptor = EncodeRequest(kUSBRqGetDescriptor, kUSBOut, kUSBClass, kUSBDevice), + kSetHubFeature = EncodeRequest(kUSBRqSetFeature, kUSBOut, kUSBClass, kUSBDevice), + kSetPortFeature = EncodeRequest(kUSBRqSetFeature, kUSBOut, kUSBClass, kUSBOther) +}; + + +/*! + @typedef IOUSBHubDescriptor + @discussion USB Hub Descriptor. See the USB HID Specification at http://www.usb.org. +*/ +struct IOUSBHubDescriptor { + UInt8 length; + UInt8 hubType; + UInt8 numPorts; + UInt16 characteristics __attribute__((packed)); + UInt8 powerOnToGood; /* Port settling time, in 2ms */ + UInt8 hubCurrent; + /* These are received packed, will have to be unpacked */ + UInt8 removablePortFlags[8]; + UInt8 pwrCtlPortFlags[8]; +}; + +typedef struct IOUSBHubDescriptor IOUSBHubDescriptor; + +/*! + @typedef IOUSBHubStatus + @discussion Used to get the port status and change flags using GetPortStatus() +*/ +struct IOUSBHubStatus { + UInt16 statusFlags; + UInt16 changeFlags; +}; +typedef struct IOUSBHubStatus IOUSBHubStatus; +typedef IOUSBHubStatus * IOUSBHubStatusPtr; + +typedef struct IOUSBHubStatus IOUSBHubPortStatus; + + +/*! + @typedef IOUSBHubPortReEnumerateParam + @discussion Used to specify the port that needs to be reenumerated +*/ +typedef struct IOUSBHubPortReEnumerateParam IOUSBHubPortReEnumerateParam; + +struct IOUSBHubPortReEnumerateParam { + UInt32 portNumber; + UInt32 options; +}; + +typedef struct IOUSBHubPortClearTTParam IOUSBHubPortClearTTParam; + +struct IOUSBHubPortClearTTParam { + UInt32 portNumber; + UInt32 options; +#if 0 + UInt8 deviceAddress; <<0 + UInt8 endpointNum; <<8 + UInt8 endpointType; <<16 // As split transaction. 00 Control, 10 Bulk + UInt8 IN; <<24 // Direction, 1 = IN, 0 = OUT +#endif +}; + +#endif /* _USBHUB_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/IOSharedLock.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/IOSharedLock.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/IOSharedLock.h (revision 885) @@ -0,0 +1,86 @@ +/* + * 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 + * + */ + +/* + * Multiprocessor locks used within the shared memory area between the + * kernel and event system. These must work in both user and kernel mode. + * + * These routines are public, for the purpose of writing frame buffer device + * drivers which handle their own cursors. Certain architectures define a + * generic display class which handles cursor drawing and is subclassed by + * driver writers. These drivers need not be concerned with the following + * types and definitions. + * + * The ev_lock(), ev_unlock(), and ev_try_lock() functions are available only + * to drivers built in or dynamically loaded into the kernel, and to DPS + * drivers built in or dynamically loaded into the Window Server. They do not + * exist in any shared library. + * + * --> They're now in IOKit user lib. + */ + +#ifndef _IOKIT_IOSHAREDLOCK_H +#define _IOKIT_IOSHAREDLOCK_H + +#ifdef __cplusplus +extern "C" { +#endif + +// should be 32 bytes on PPC +typedef volatile int IOSharedLockData; +typedef IOSharedLockData * IOSharedLock; + +#define IOSpinLockInit(l) (*(l) = (IOSharedLockData)0) + + +extern void IOSpinUnlock(IOSharedLock l); +extern boolean_t IOTrySpinLock(IOSharedLock l); + +/* exact same stuff & implementation */ + +typedef IOSharedLockData ev_lock_data_t; +typedef ev_lock_data_t * ev_lock_t; + +#define ev_init_lock(l) (*(l) = (ev_lock_data_t)0) +// needs isync? +//#define ev_is_locked(l) (*(l) != (ev_lock_data_t)0) + + +extern void ev_unlock(ev_lock_t l); +extern boolean_t ev_try_lock(ev_lock_t l); + +#ifdef __cplusplus +} +#endif +#endif /* ! _IOKIT_IOSHAREDLOCK_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/IOInterruptEventSource.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/IOInterruptEventSource.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/IOInterruptEventSource.h (revision 885) @@ -0,0 +1,200 @@ +/* + * 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 + 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 + +class IOService; + +/*! @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. +

+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. +

+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. +

+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. +

+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. +

+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 *, IOInterruptEventSource *, int count); + +/*! @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 { }; + +/*! @var reserved + Reserved for future use. (Internal use only) */ + ExpansionData *reserved; + +/*! @function free + @abstract Sub-class implementation of free method, disconnects from the interrupt source. */ + virtual void free(); + +/*! @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(); + +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 IOInterruptEventSource * + interruptEventSource(OSObject *owner, + Action action, + IOService *provider = 0, + int intIndex = 0); + +/*! @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 = 0, + 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(); + +/*! @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 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); + +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 */ Index: branches/azimutz/Cleancut/i386/include/IOKit/IONotifier.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/IONotifier.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/IONotifier.h (revision 885) @@ -0,0 +1,72 @@ +/* + * 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 _IOKIT_IONOTIFIER_H +#define _IOKIT_IONOTIFIER_H + +#include + +/*! @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 */ Index: branches/azimutz/Cleancut/i386/include/IOKit/IOSubMemoryDescriptor.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/IOSubMemoryDescriptor.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/IOSubMemoryDescriptor.h (revision 885) @@ -0,0 +1,109 @@ +/* + * 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 + +/*! @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(); + +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 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 ); + + virtual IOReturn prepare(IODirection forDirection = kIODirectionNone); + + virtual IOReturn complete(IODirection forDirection = kIODirectionNone); + +#ifdef __LP64__ + virtual +#endif /* __LP64__ */ + IOReturn redirect( task_t safeTask, bool redirect ); + + virtual IOReturn setPurgeable( IOOptionBits newState, + IOOptionBits * oldState ); + + // support map() on kIOMemoryTypeVirtual without prepare() + virtual IOMemoryMap * makeMapping( + IOMemoryDescriptor * owner, + task_t intoTask, + IOVirtualAddress atAddress, + IOOptionBits options, + IOByteCount offset, + IOByteCount length ); + + virtual uint64_t getPreparationID( void ); + +}; + +#endif /* !_IOSUBMEMORYDESCRIPTOR_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/IONVRAM.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/IONVRAM.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/IONVRAM.h (revision 885) @@ -0,0 +1,167 @@ +/* + * 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_IONVRAM_H +#define _IOKIT_IONVRAM_H + +#include +#include +#include +#include + + +#define kIODTNVRAMOFPartitionName "common" +#define kIODTNVRAMXPRAMPartitionName "APL,MacOS75" +#define kIODTNVRAMPanicInfoPartitonName "APL,OSXPanic" +#define kIODTNVRAMFreePartitionName "wwwwwwwwwwww" + +enum { + kIODTNVRAMImageSize = 0x2000, + kIODTNVRAMXPRAMSize = 0x0100, + kIODTNVRAMNameRegistrySize = 0x0400 +}; + +enum { + kOFVariableTypeBoolean = 1, + kOFVariableTypeNumber, + kOFVariableTypeString, + kOFVariableTypeData +}; + +enum { + kOFVariablePermRootOnly = 0, + kOFVariablePermUserRead, + kOFVariablePermUserWrite, + kOFVariablePermKernelOnly +}; + +class IODTNVRAM : public IOService +{ + OSDeclareDefaultStructors(IODTNVRAM); + +private: + IONVRAMController *_nvramController; + const OSSymbol *_registryPropertiesKey; + UInt8 *_nvramImage; + bool _nvramImageDirty; + UInt32 _ofPartitionOffset; + UInt32 _ofPartitionSize; + UInt8 *_ofImage; + bool _ofImageDirty; + OSDictionary *_ofDict; + OSDictionary *_nvramPartitionOffsets; + OSDictionary *_nvramPartitionLengths; + UInt32 _xpramPartitionOffset; + UInt32 _xpramPartitionSize; + UInt8 *_xpramImage; + UInt32 _nrPartitionOffset; + UInt32 _nrPartitionSize; + UInt8 *_nrImage; + UInt32 _piPartitionOffset; + UInt32 _piPartitionSize; + UInt8 *_piImage; + bool _systemPaniced; + + virtual UInt8 calculatePartitionChecksum(UInt8 *partitionHeader); + virtual IOReturn initOFVariables(void); +public: + virtual IOReturn syncOFVariables(void); +private: + virtual UInt32 getOFVariableType(const OSSymbol *propSymbol) const; + virtual UInt32 getOFVariablePerm(const OSSymbol *propSymbol) const; + virtual bool getOWVariableInfo(UInt32 variableNumber, const OSSymbol **propSymbol, + UInt32 *propType, UInt32 *propOffset); + virtual bool convertPropToObject(UInt8 *propName, UInt32 propNameLength, + UInt8 *propData, UInt32 propDataLength, + const OSSymbol **propSymbol, + OSObject **propObject); + virtual bool convertObjectToProp(UInt8 *buffer, UInt32 *length, + const OSSymbol *propSymbol, OSObject *propObject); + virtual UInt16 generateOWChecksum(UInt8 *buffer); + virtual bool validateOWChecksum(UInt8 *buffer); + virtual void updateOWBootArgs(const OSSymbol *key, OSObject *value); + virtual bool searchNVRAMProperty(struct IONVRAMDescriptor *hdr, + UInt32 *where); + + virtual IOReturn readNVRAMPropertyType0(IORegistryEntry *entry, + const OSSymbol **name, + OSData **value); + virtual IOReturn writeNVRAMPropertyType0(IORegistryEntry *entry, + const OSSymbol *name, + OSData * value); + + virtual OSData *unescapeBytesToData(const UInt8 *bytes, UInt32 length); + virtual OSData *escapeDataToData(OSData * value); + + virtual IOReturn readNVRAMPropertyType1(IORegistryEntry *entry, + const OSSymbol **name, + OSData **value); + virtual IOReturn writeNVRAMPropertyType1(IORegistryEntry *entry, + const OSSymbol *name, + OSData *value); + +public: + virtual bool init(IORegistryEntry *old, const IORegistryPlane *plane); + + virtual void registerNVRAMController(IONVRAMController *nvram); + + virtual void sync(void); + + virtual bool serializeProperties(OSSerialize *s) const; + virtual OSObject *getProperty(const OSSymbol *aKey) const; + virtual OSObject *getProperty(const char *aKey) const; + virtual bool setProperty(const OSSymbol *aKey, OSObject *anObject); + virtual void removeProperty(const OSSymbol *aKey); + virtual IOReturn setProperties(OSObject *properties); + + 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 /* !_IOKIT_IONVRAM_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/scsi/IOSCSIPeripheralDeviceNub.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/scsi/IOSCSIPeripheralDeviceNub.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/scsi/IOSCSIPeripheralDeviceNub.h (revision 885) @@ -0,0 +1,233 @@ +/* + * 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_SCSI_PERIPHERAL_DEVICE_NUB_H_ +#define _IOKIT_IO_SCSI_PERIPHERAL_DEVICE_NUB_H_ + + +//----------------------------------------------------------------------------- +// Constants +//----------------------------------------------------------------------------- + +// Probe score values +enum +{ + kPeripheralDeviceTypeNoMatch = 0, + kDefaultProbeRanking = 5000, + kFirstOrderRanking = 10000, + kSecondOrderRanking = 15000, + kThirdOrderRanking = 20000 +}; + + +#if defined(KERNEL) && defined(__cplusplus) + + +//----------------------------------------------------------------------------- +// Includes +//----------------------------------------------------------------------------- + +// General IOKit headers +#include +#include +#include + +// SCSI Architecture Model Family includes +#include + + +// Forward definitions for internal use only classes. +class SCSIPrimaryCommands; + +//----------------------------------------------------------------------------- +// Class Declarations +//----------------------------------------------------------------------------- + +class IOSCSIPeripheralDeviceNub : public IOSCSIProtocolServices +{ + + OSDeclareDefaultStructors ( IOSCSIPeripheralDeviceNub ) + +private: + + static bool sCompareIOProperty ( + IOService * object, + OSDictionary * table, + char * propertyKeyName, + bool * matches ); + + static void TaskCallback ( SCSITaskIdentifier completedTask ); + void TaskCompletion ( SCSITaskIdentifier completedTask ); + + static IOReturn sWaitForTask ( void * object, SCSITask * request ); + IOReturn GatedWaitForTask ( SCSITask * request ); + +protected: + + SCSIServiceResponse SendTask ( SCSITask * request ); + + bool InterrogateDevice ( void ); + + // Reserve space for future expansion. + struct IOSCSIPeripheralDeviceNubExpansionData { }; + IOSCSIPeripheralDeviceNubExpansionData * fIOSCSIPeripheralDeviceNubReserved; + + IOSCSIProtocolInterface * fProvider; +#ifndef __LP64__ + SCSIPrimaryCommands * fSCSIPrimaryCommandObject; +#endif + UInt8 fDefaultInquiryCount; + + virtual bool SendSCSICommand ( SCSITaskIdentifier request, + SCSIServiceResponse * serviceResponse, + SCSITaskStatus * taskStatus ); + + virtual SCSIServiceResponse AbortSCSICommand ( SCSITaskIdentifier request ); + + // The IsProtocolServiceSupported will return true if the specified + // feature is supported by the protocol layer. If the service has a value that must be + // returned, it will be returned in the serviceValue output parameter. + virtual bool IsProtocolServiceSupported ( SCSIProtocolFeature feature, void * serviceValue ); + + virtual bool HandleProtocolServiceFeature ( SCSIProtocolFeature feature, void * serviceValue ); + + // We override this method in order to NOT do power management + virtual void InitializePowerManagement ( IOService * provider ); + +public: + + bool init ( OSDictionary * propTable ); + virtual bool start ( IOService * provider ); + virtual void free ( void ); + + virtual IOReturn message ( UInt32 type, IOService * nub, void * arg ); + + virtual bool matchPropertyTable ( OSDictionary * table, + SInt32 * score ); + + // The ExecuteCommand method will take a SCSITask object and transport + // it across the physical wires to the device + virtual void ExecuteCommand ( SCSITaskIdentifier request ); + + // The Task Management function to allow the SCSI Application Layer client to request + // that a specific task be aborted. + virtual SCSIServiceResponse AbortTask ( UInt8 theLogicalUnit, SCSITaggedTaskIdentifier theTag ); + + // The Task Management function to allow the SCSI Application Layer client to request + // that a all tasks curerntly in the task set be aborted. + virtual SCSIServiceResponse AbortTaskSet ( UInt8 theLogicalUnit ); + + virtual SCSIServiceResponse ClearACA ( UInt8 theLogicalUnit ); + + virtual SCSIServiceResponse ClearTaskSet ( UInt8 theLogicalUnit ); + + virtual SCSIServiceResponse LogicalUnitReset ( UInt8 theLogicalUnit ); + + virtual SCSIServiceResponse TargetReset ( void ); + + // ************* Obsoleted Member Routine **************** + // The AbortCommand method is replaced by the AbortTask Management function and + // should no longer be called. + virtual SCSIServiceResponse AbortCommand ( SCSITaskIdentifier abortTask ); + +private: + + // Space reserved for future expansion. + OSMetaClassDeclareReservedUnused ( IOSCSIPeripheralDeviceNub, 1 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPeripheralDeviceNub, 2 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPeripheralDeviceNub, 3 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPeripheralDeviceNub, 4 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPeripheralDeviceNub, 5 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPeripheralDeviceNub, 6 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPeripheralDeviceNub, 7 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPeripheralDeviceNub, 8 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPeripheralDeviceNub, 9 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPeripheralDeviceNub, 10 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPeripheralDeviceNub, 11 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPeripheralDeviceNub, 12 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPeripheralDeviceNub, 13 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPeripheralDeviceNub, 14 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPeripheralDeviceNub, 15 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPeripheralDeviceNub, 16 ); + +}; + + + +class IOSCSILogicalUnitNub : public IOSCSIPeripheralDeviceNub +{ + + OSDeclareDefaultStructors ( IOSCSILogicalUnitNub ) + +private: + + UInt8 fLogicalUnitNumber; + +protected: + + // Reserve space for future expansion. + struct IOSCSILogicalUnitNubExpansionData { }; + IOSCSILogicalUnitNubExpansionData * fIOSCSILogicalUnitNubReserved; + +public: + + virtual bool start ( IOService * provider ); + + virtual void SetLogicalUnitNumber ( UInt8 newLUN ); + + UInt8 GetLogicalUnitNumber ( void ); + + // The ExecuteCommand method will take a SCSITask object and transport + // it across the physical wires to the device + virtual void ExecuteCommand ( SCSITaskIdentifier request ); + + // The AbortCommand method will abort the indicated SCSI Task object, + // if it is possible and the SCSI Task has not already completed. + virtual SCSIServiceResponse AbortCommand ( SCSITaskIdentifier abortTask ); + +private: + + // Space reserved for future expansion. + OSMetaClassDeclareReservedUnused ( IOSCSILogicalUnitNub, 1 ); + OSMetaClassDeclareReservedUnused ( IOSCSILogicalUnitNub, 2 ); + OSMetaClassDeclareReservedUnused ( IOSCSILogicalUnitNub, 3 ); + OSMetaClassDeclareReservedUnused ( IOSCSILogicalUnitNub, 4 ); + OSMetaClassDeclareReservedUnused ( IOSCSILogicalUnitNub, 5 ); + OSMetaClassDeclareReservedUnused ( IOSCSILogicalUnitNub, 6 ); + OSMetaClassDeclareReservedUnused ( IOSCSILogicalUnitNub, 7 ); + OSMetaClassDeclareReservedUnused ( IOSCSILogicalUnitNub, 8 ); + OSMetaClassDeclareReservedUnused ( IOSCSILogicalUnitNub, 9 ); + OSMetaClassDeclareReservedUnused ( IOSCSILogicalUnitNub, 10 ); + OSMetaClassDeclareReservedUnused ( IOSCSILogicalUnitNub, 11 ); + OSMetaClassDeclareReservedUnused ( IOSCSILogicalUnitNub, 12 ); + OSMetaClassDeclareReservedUnused ( IOSCSILogicalUnitNub, 13 ); + OSMetaClassDeclareReservedUnused ( IOSCSILogicalUnitNub, 14 ); + OSMetaClassDeclareReservedUnused ( IOSCSILogicalUnitNub, 15 ); + OSMetaClassDeclareReservedUnused ( IOSCSILogicalUnitNub, 16 ); + +}; + +#endif /* defined(KERNEL) && defined(__cplusplus) */ + +#endif /* _IOKIT_IO_SCSI_PERIPHERAL_DEVICE_NUB_H_ */ Index: branches/azimutz/Cleancut/i386/include/IOKit/scsi/SCSICommandDefinitions.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/scsi/SCSICommandDefinitions.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/scsi/SCSICommandDefinitions.h (revision 885) @@ -0,0 +1,479 @@ +/* + * Copyright (c) 2001-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_SCSI_COMMAND_DEFINITIONS_H_ +#define _IOKIT_SCSI_COMMAND_DEFINITIONS_H_ + + +#if KERNEL +#include +#else +#include +#endif + + +/*! @header SCSICommandDefinitions + @discussion + This file contains all the definitions for types and constants that are + used by the command set classes for building CDBs. The field type + definitions are used for the parameters passed to a method that builds and + sends any SCSI defined command to clearly identify the type of value + expected for a parameter. + + The command methods will then use the appropriate mask to verify that the + value passed into a parameter is of the specified type. + + Currently only types and masks are defined for 8 bytes and smaller fields. + If a command is defined that uses a larger field, these should be expanded + to include those sizes. +*/ + +#pragma mark Field Type Definitions +/* These are the type definitions used for the parameters of methods that + * build and send Command Descriptor Blocks. + */ + +/* 1 Byte or smaller fields. */ + +/*! @typedef SCSICmdField1Bit */ +typedef UInt8 SCSICmdField1Bit; + +/*! @typedef SCSICmdField2Bit */ +typedef UInt8 SCSICmdField2Bit; + +/*! @typedef SCSICmdField3Bit */ +typedef UInt8 SCSICmdField3Bit; + +/*! @typedef SCSICmdField4Bit */ +typedef UInt8 SCSICmdField4Bit; + +/*! @typedef SCSICmdField5Bit */ +typedef UInt8 SCSICmdField5Bit; + +/*! @typedef SCSICmdField6Bit */ +typedef UInt8 SCSICmdField6Bit; + +/*! @typedef SCSICmdField7Bit */ +typedef UInt8 SCSICmdField7Bit; + +/*! @typedef SCSICmdField1Byte */ +typedef UInt8 SCSICmdField1Byte; + +/* 2 Bytes or smaller fields. */ + +/*! @typedef SCSICmdField9Bit */ +typedef UInt16 SCSICmdField9Bit; + +/*! @typedef SCSICmdField10Bit */ +typedef UInt16 SCSICmdField10Bit; + +/*! @typedef SCSICmdField11Bit */ +typedef UInt16 SCSICmdField11Bit; + +/*! @typedef SCSICmdField12Bit */ +typedef UInt16 SCSICmdField12Bit; + +/*! @typedef SCSICmdField13Bit */ +typedef UInt16 SCSICmdField13Bit; + +/*! @typedef SCSICmdField14Bit */ +typedef UInt16 SCSICmdField14Bit; + +/*! @typedef SCSICmdField15Bit */ +typedef UInt16 SCSICmdField15Bit; + +/*! @typedef SCSICmdField2Byte */ +typedef UInt16 SCSICmdField2Byte; + +/* 3 Bytes or smaller fields. */ + +/*! @typedef SCSICmdField17Bit */ +typedef UInt32 SCSICmdField17Bit; + +/*! @typedef SCSICmdField18Bit */ +typedef UInt32 SCSICmdField18Bit; + +/*! @typedef SCSICmdField19Bit */ +typedef UInt32 SCSICmdField19Bit; + +/*! @typedef SCSICmdField20Bit */ +typedef UInt32 SCSICmdField20Bit; + +/*! @typedef SCSICmdField21Bit */ +typedef UInt32 SCSICmdField21Bit; + +/*! @typedef SCSICmdField22Bit */ +typedef UInt32 SCSICmdField22Bit; + +/*! @typedef SCSICmdField23Bit */ +typedef UInt32 SCSICmdField23Bit; + +/*! @typedef SCSICmdField3Byte */ +typedef UInt32 SCSICmdField3Byte; + +/* 4 Bytes or smaller fields. */ + +/*! @typedef SCSICmdField25Bit */ +typedef UInt32 SCSICmdField25Bit; + +/*! @typedef SCSICmdField26Bit */ +typedef UInt32 SCSICmdField26Bit; + +/*! @typedef SCSICmdField27Bit */ +typedef UInt32 SCSICmdField27Bit; + +/*! @typedef SCSICmdField28Bit */ +typedef UInt32 SCSICmdField28Bit; + +/*! @typedef SCSICmdField29Bit */ +typedef UInt32 SCSICmdField29Bit; + +/*! @typedef SCSICmdField30Bit */ +typedef UInt32 SCSICmdField30Bit; + +/*! @typedef SCSICmdField31Bit */ +typedef UInt32 SCSICmdField31Bit; + +/*! @typedef SCSICmdField4Byte */ +typedef UInt32 SCSICmdField4Byte; + +/* 5 Bytes or smaller fields. */ + +/*! @typedef SCSICmdField33Bit */ +typedef UInt64 SCSICmdField33Bit; + +/*! @typedef SCSICmdField34Bit */ +typedef UInt64 SCSICmdField34Bit; + +/*! @typedef SCSICmdField35Bit */ +typedef UInt64 SCSICmdField35Bit; + +/*! @typedef SCSICmdField36Bit */ +typedef UInt64 SCSICmdField36Bit; + +/*! @typedef SCSICmdField37Bit */ +typedef UInt64 SCSICmdField37Bit; + +/*! @typedef SCSICmdField38Bit */ +typedef UInt64 SCSICmdField38Bit; + +/*! @typedef SCSICmdField39Bit */ +typedef UInt64 SCSICmdField39Bit; + +/*! @typedef SCSICmdField5Byte */ +typedef UInt64 SCSICmdField5Byte; + +/* 6 Bytes or smaller fields. */ + +/*! @typedef SCSICmdField41Bit */ +typedef UInt64 SCSICmdField41Bit; + +/*! @typedef SCSICmdField42Bit */ +typedef UInt64 SCSICmdField42Bit; + +/*! @typedef SCSICmdField43Bit */ +typedef UInt64 SCSICmdField43Bit; + +/*! @typedef SCSICmdField44Bit */ +typedef UInt64 SCSICmdField44Bit; + +/*! @typedef SCSICmdField45Bit */ +typedef UInt64 SCSICmdField45Bit; + +/*! @typedef SCSICmdField46Bit */ +typedef UInt64 SCSICmdField46Bit; + +/*! @typedef SCSICmdField47Bit */ +typedef UInt64 SCSICmdField47Bit; + +/*! @typedef SCSICmdField6Byte */ +typedef UInt64 SCSICmdField6Byte; + +/* 7 Bytes or smaller fields. */ + +/*! @typedef SCSICmdField49Bit */ +typedef UInt64 SCSICmdField49Bit; + +/*! @typedef SCSICmdField50Bit */ +typedef UInt64 SCSICmdField50Bit; + +/*! @typedef SCSICmdField51Bit */ +typedef UInt64 SCSICmdField51Bit; + +/*! @typedef SCSICmdField52Bit */ +typedef UInt64 SCSICmdField52Bit; + +/*! @typedef SCSICmdField53Bit */ +typedef UInt64 SCSICmdField53Bit; + +/*! @typedef SCSICmdField54Bit */ +typedef UInt64 SCSICmdField54Bit; + +/*! @typedef SCSICmdField55Bit */ +typedef UInt64 SCSICmdField55Bit; + +/*! @typedef SCSICmdField7Byte */ +typedef UInt64 SCSICmdField7Byte; + +/* 8 Bytes or smaller fields. */ + +/*! @typedef SCSICmdField57Bit */ +typedef UInt64 SCSICmdField57Bit; + +/*! @typedef SCSICmdField58Bit */ +typedef UInt64 SCSICmdField58Bit; + +/*! @typedef SCSICmdField59Bit */ +typedef UInt64 SCSICmdField59Bit; + +/*! @typedef SCSICmdField60Bit */ +typedef UInt64 SCSICmdField60Bit; + +/*! @typedef SCSICmdField61Bit */ +typedef UInt64 SCSICmdField61Bit; + +/*! @typedef SCSICmdField62Bit */ +typedef UInt64 SCSICmdField62Bit; + +/*! @typedef SCSICmdField63Bit */ +typedef UInt64 SCSICmdField63Bit; + +/*! @typedef SCSICmdField8Byte */ +typedef UInt64 SCSICmdField8Byte; + + +#pragma mark Field Mask Definitions +/* These are masks that are used to verify that the values passed into the + * parameters for the fields are not larger than the field size. + * + * NB: These have changed from enums to #define since enums greater than + * 32 bits in size are not well-defined in C99. + */ + +/* 1 Byte or smaller fields. */ + +/*! @constant kSCSICmdFieldMask1Bit */ +#define kSCSICmdFieldMask1Bit 0x01 + +/*! @constant kSCSICmdFieldMask2Bit */ +#define kSCSICmdFieldMask2Bit 0x03 + +/*! @constant kSCSICmdFieldMask3Bit */ +#define kSCSICmdFieldMask3Bit 0x07 + +/*! @constant kSCSICmdFieldMask4Bit */ +#define kSCSICmdFieldMask4Bit 0x0F + +/*! @constant kSCSICmdFieldMask5Bit */ +#define kSCSICmdFieldMask5Bit 0x1F + +/*! @constant kSCSICmdFieldMask6Bit */ +#define kSCSICmdFieldMask6Bit 0x3F + +/*! @constant kSCSICmdFieldMask7Bit */ +#define kSCSICmdFieldMask7Bit 0x7F + +#define kSCSICmdFieldMask1Byte 0xFF + +/* 2 Bytes or smaller fields. */ + +/*! @constant kSCSICmdFieldMask9Bit */ +#define kSCSICmdFieldMask9Bit 0x01FF + +/*! @constant kSCSICmdFieldMask10Bit */ +#define kSCSICmdFieldMask10Bit 0x03FF + +/*! @constant kSCSICmdFieldMask11Bit */ +#define kSCSICmdFieldMask11Bit 0x07FF + +/*! @constant kSCSICmdFieldMask12Bit */ +#define kSCSICmdFieldMask12Bit 0x0FFF + +/*! @constant kSCSICmdFieldMask13Bit */ +#define kSCSICmdFieldMask13Bit 0x1FFF + +/*! @constant kSCSICmdFieldMask14Bit */ +#define kSCSICmdFieldMask14Bit 0x3FFF + +/*! @constant kSCSICmdFieldMask15Bit */ +#define kSCSICmdFieldMask15Bit 0x7FFF + +/*! @constant kSCSICmdFieldMask2Byte */ +#define kSCSICmdFieldMask2Byte 0xFFFF + +/* 3 Bytes or smaller fields. */ + +/*! @constant kSCSICmdFieldMask17Bit */ +#define kSCSICmdFieldMask17Bit 0x01FFFF + +/*! @constant kSCSICmdFieldMask18Bit */ +#define kSCSICmdFieldMask18Bit 0x03FFFF + +/*! @constant kSCSICmdFieldMask19Bit */ +#define kSCSICmdFieldMask19Bit 0x07FFFF + +/*! @constant kSCSICmdFieldMask20Bit */ +#define kSCSICmdFieldMask20Bit 0x0FFFFF + +/*! @constant kSCSICmdFieldMask21Bit */ +#define kSCSICmdFieldMask21Bit 0x1FFFFF + +/*! @constant kSCSICmdFieldMask22Bit */ +#define kSCSICmdFieldMask22Bit 0x3FFFFF + +/*! @constant kSCSICmdFieldMask23Bit */ +#define kSCSICmdFieldMask23Bit 0x7FFFFF + +/*! @constant kSCSICmdFieldMask3Byte */ +#define kSCSICmdFieldMask3Byte 0xFFFFFF + +/* 4 Bytes or smaller fields. */ +/*! @constant kSCSICmdFieldMask25Bit */ +#define kSCSICmdFieldMask25Bit 0x01FFFFFFUL + +/*! @constant kSCSICmdFieldMask26Bit */ +#define kSCSICmdFieldMask26Bit 0x03FFFFFFUL + +/*! @constant kSCSICmdFieldMask27Bit */ +#define kSCSICmdFieldMask27Bit 0x07FFFFFFUL + +/*! @constant kSCSICmdFieldMask28Bit */ +#define kSCSICmdFieldMask28Bit 0x0FFFFFFFUL + +/*! @constant kSCSICmdFieldMask29Bit */ +#define kSCSICmdFieldMask29Bit 0x1FFFFFFFUL + +/*! @constant kSCSICmdFieldMask30Bit */ +#define kSCSICmdFieldMask30Bit 0x3FFFFFFFUL + +/*! @constant kSCSICmdFieldMask31Bit */ +#define kSCSICmdFieldMask31Bit 0x7FFFFFFFUL + +/*! @constant kSCSICmdFieldMask4Byte */ +#define kSCSICmdFieldMask4Byte 0xFFFFFFFFUL + +/* 5 Bytes or smaller fields. */ + +/*! @constant kSCSICmdFieldMask33Bit */ +#define kSCSICmdFieldMask33Bit 0x01FFFFFFFFULL + +/*! @constant kSCSICmdFieldMask34Bit */ +#define kSCSICmdFieldMask34Bit 0x03FFFFFFFFULL + +/*! @constant kSCSICmdFieldMask35Bit */ +#define kSCSICmdFieldMask35Bit 0x07FFFFFFFFULL + +/*! @constant kSCSICmdFieldMask36Bit */ +#define kSCSICmdFieldMask36Bit 0x0FFFFFFFFFULL + +/*! @constant kSCSICmdFieldMask37Bit */ +#define kSCSICmdFieldMask37Bit 0x1FFFFFFFFFULL + +/*! @constant kSCSICmdFieldMask38Bit */ +#define kSCSICmdFieldMask38Bit 0x3FFFFFFFFFULL + +/*! @constant kSCSICmdFieldMask39Bit */ +#define kSCSICmdFieldMask39Bit 0x7FFFFFFFFFULL + +/*! @constant kSCSICmdFieldMask5Byte */ +#define kSCSICmdFieldMask5Byte 0xFFFFFFFFFFULL + +/* 6 Bytes or smaller fields. */ + +/*! @constant kSCSICmdFieldMask41Bit */ +#define kSCSICmdFieldMask41Bit 0x01FFFFFFFFFFULL + +/*! @constant kSCSICmdFieldMask42Bit */ +#define kSCSICmdFieldMask42Bit 0x03FFFFFFFFFFULL + +/*! @constant kSCSICmdFieldMask43Bit */ +#define kSCSICmdFieldMask43Bit 0x07FFFFFFFFFFULL + +/*! @constant kSCSICmdFieldMask44Bit */ +#define kSCSICmdFieldMask44Bit 0x0FFFFFFFFFFFULL + +/*! @constant kSCSICmdFieldMask45Bit */ +#define kSCSICmdFieldMask45Bit 0x1FFFFFFFFFFFULL + +/*! @constant kSCSICmdFieldMask46Bit */ +#define kSCSICmdFieldMask46Bit 0x3FFFFFFFFFFFULL + +/*! @constant kSCSICmdFieldMask47Bit */ +#define kSCSICmdFieldMask47Bit 0x7FFFFFFFFFFFULL + +/*! @constant kSCSICmdFieldMask6Byte */ +#define kSCSICmdFieldMask6Byte 0xFFFFFFFFFFFFULL + +/* 7 Bytes or smaller fields. */ + +/*! @constant kSCSICmdFieldMask49Bit */ +#define kSCSICmdFieldMask49Bit 0x01FFFFFFFFFFFFULL + +/*! @constant kSCSICmdFieldMask50Bit */ +#define kSCSICmdFieldMask50Bit 0x03FFFFFFFFFFFFULL + +/*! @constant kSCSICmdFieldMask51Bit */ +#define kSCSICmdFieldMask51Bit 0x07FFFFFFFFFFFFULL + +/*! @constant kSCSICmdFieldMask52Bit */ +#define kSCSICmdFieldMask52Bit 0x0FFFFFFFFFFFFFULL + +/*! @constant kSCSICmdFieldMask53Bit */ +#define kSCSICmdFieldMask53Bit 0x1FFFFFFFFFFFFFULL + +/*! @constant kSCSICmdFieldMask54Bit */ +#define kSCSICmdFieldMask54Bit 0x3FFFFFFFFFFFFFULL + +/*! @constant kSCSICmdFieldMask55Bit */ +#define kSCSICmdFieldMask55Bit 0x7FFFFFFFFFFFFFULL + +/*! @constant kSCSICmdFieldMask7Byte */ +#define kSCSICmdFieldMask7Byte 0xFFFFFFFFFFFFFFULL + +/* 8 Bytes or smaller fields. */ + +/*! @constant kSCSICmdFieldMask57Bit */ +#define kSCSICmdFieldMask57Bit 0x01FFFFFFFFFFFFFFULL + +/*! @constant kSCSICmdFieldMask58Bit */ +#define kSCSICmdFieldMask58Bit 0x03FFFFFFFFFFFFFFULL + +/*! @constant kSCSICmdFieldMask59Bit */ +#define kSCSICmdFieldMask59Bit 0x07FFFFFFFFFFFFFFULL + +/*! @constant kSCSICmdFieldMask60Bit */ +#define kSCSICmdFieldMask60Bit 0x0FFFFFFFFFFFFFFFULL + +/*! @constant kSCSICmdFieldMask61Bit */ +#define kSCSICmdFieldMask61Bit 0x1FFFFFFFFFFFFFFFULL + +/*! @constant kSCSICmdFieldMask62Bit */ +#define kSCSICmdFieldMask62Bit 0x3FFFFFFFFFFFFFFFULL + +/*! @constant kSCSICmdFieldMask63Bit */ +#define kSCSICmdFieldMask63Bit 0x7FFFFFFFFFFFFFFFULL + +/*! @constant kSCSICmdFieldMask8Byte */ +#define kSCSICmdFieldMask8Byte 0xFFFFFFFFFFFFFFFFULL + +#endif /* _IOKIT_SCSI_COMMAND_DEFINITIONS_H_ */ Index: branches/azimutz/Cleancut/i386/include/IOKit/scsi/IOSCSIPeripheralDeviceType05.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/scsi/IOSCSIPeripheralDeviceType05.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/scsi/IOSCSIPeripheralDeviceType05.h (revision 885) @@ -0,0 +1,75 @@ +/* + * 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_SCSI_PERIPHERAL_DEVICE_TYPE_05_H_ +#define _IOKIT_IO_SCSI_PERIPHERAL_DEVICE_TYPE_05_H_ + +#if defined(KERNEL) && defined(__cplusplus) + + +//----------------------------------------------------------------------------- +// Includes +//----------------------------------------------------------------------------- + +// SCSI Architecture Model Family includes +#include + + +//----------------------------------------------------------------------------- +// Class Declaration +//----------------------------------------------------------------------------- + +class IOSCSIPeripheralDeviceType05 : public IOSCSIMultimediaCommandsDevice +{ + + OSDeclareDefaultStructors ( IOSCSIPeripheralDeviceType05 ) + +protected: + + // Reserve space for future expansion. + struct IOSCSIPeripheralDeviceType05ExpansionData { }; + IOSCSIPeripheralDeviceType05ExpansionData * fIOSCSIPeripheralDeviceType05Reserved; + +public: + + bool init ( OSDictionary * propTable ); + virtual bool start ( IOService * provider ); + virtual void stop ( IOService * provider ); + +private: + + // Space reserved for future expansion. + OSMetaClassDeclareReservedUnused ( IOSCSIPeripheralDeviceType05, 1 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPeripheralDeviceType05, 2 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPeripheralDeviceType05, 3 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPeripheralDeviceType05, 4 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPeripheralDeviceType05, 5 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPeripheralDeviceType05, 6 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPeripheralDeviceType05, 7 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPeripheralDeviceType05, 8 ); + +}; + +#endif /* defined(KERNEL) && defined(__cplusplus) */ + +#endif /* _IOKIT_IO_SCSI_PERIPHERAL_DEVICE_TYPE_05_H_ */ Index: branches/azimutz/Cleancut/i386/include/IOKit/scsi/IOSCSIProtocolInterface.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/scsi/IOSCSIProtocolInterface.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/scsi/IOSCSIProtocolInterface.h (revision 885) @@ -0,0 +1,854 @@ +/* + * 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_SCSI_PROTOCOL_INTERFACE_H_ +#define _IOKIT_IO_SCSI_PROTOCOL_INTERFACE_H_ + + +/*! @header SCSI Protocol Interface + @discussion + This file contains definitions for the IOSCSIProtocolInterface class, + SCSI Protocol Features used by this interface, and additional constants + used by this interface. +*/ + + +//----------------------------------------------------------------------------- +// Includes +//----------------------------------------------------------------------------- + +#include + + +//----------------------------------------------------------------------------- +// Constants +//----------------------------------------------------------------------------- + +/* +SCSI Device Characteristics - Defined between SCSI Application Layer and + SCSI Protocol Layer only. +*/ + +/*! +@constant kIOPropertySCSIDeviceCharacteristicsKey +@discussion +This key is used to define SCSI Device Characteristics for a particular device. +It is the key for the dictionary containing the keys of characteristics. These keys +are only defined between the SCSI Protocol Layer and the SCSI Applicaiton Layer. Some +properties may be copied from this dictionary to the more generic Device Characteristics +or Protocol Characteristics dictionaries. +*/ +#define kIOPropertySCSIDeviceCharacteristicsKey "SCSI Device Characteristics" + +/*! +@constant kIOPropertySCSIInquiryLengthKey +@discussion +This key is used to define a default INQUIRY length to issue to the device. The +value is a UInt32 corresponding to the number of bytes to request in the INQUIRY +command. +*/ +#define kIOPropertySCSIInquiryLengthKey "Inquiry Length" + +/*! +@constant kIOPropertySCSIManualEjectKey +@discussion +This key is used to indicate that the device is known to be a manual ejectable media +device. This property overrides all of the driver checks for determining this capability. +This property is a string, although if it exists it should always be true. +*/ +#define kIOPropertySCSIManualEjectKey "Manual Eject" + +/*! +@constant kIOPropertyReadTimeOutDurationKey +@discussion +This key is used to define the Read Time Out for a particular device. +This property overrides all of the protocol defaults. +This property is a value, in milliseconds. +*/ +#define kIOPropertyReadTimeOutDurationKey "Read Time Out Duration" + +/*! +@constant kIOPropertyWriteTimeOutDurationKey +@discussion +This key is used to define the Write Time Out for a particular device. +This property overrides all of the protocol defaults. +This property is a value, in milliseconds. +*/ +#define kIOPropertyWriteTimeOutDurationKey "Write Time Out Duration" + +/*! +@constant kIOPropertyRetryCountKey +@discussion +This key is used to define the number of Read/Write retries for a particular device. +This property overrides all of the protocol defaults. +The value is a UInt32 corresponding to the number of retries. +*/ +#define kIOPropertyRetryCountKey "Retry Count" + +/*! + @constant kIOPropertyAutonomousSpinDownKey + @discussion + This key is used to indicate that the device is known to have its own internal logic + for idle disk spin down. This key is used to mark device which respon poorly to our + efforts to manually spin down or spin up the device when it is already in the desired + state. + */ +#define kIOPropertyAutonomousSpinDownKey "Autonomous Spin Down" + +/*! + @constant kIOPropertyEjectRequireStartStopUnitKey + @discussion + This key is used to indicate that while the device may have failed PREVENT_ALLOW_MEDIUM + REMOVAL it still requires a START_STOP_UNIT to eject/unload media. + */ +#define kIOPropertyEjectRequireStartStopUnitKey "Eject Requires START_STOP_UNIT" + +#if defined(KERNEL) && defined(__cplusplus) + + +/*! +@constant kCFBundleIdentifierKey +@discussion +Property key for CFBundleIdentifier. +*/ +#define kCFBundleIdentifierKey "CFBundleIdentifier" + +/*! +@constant kIOSCSIArchitectureBundleIdentifierKey +@discussion +IOSCSIArchitectureModelFamily's CFBundle identifier. +*/ +#define kIOSCSIArchitectureBundleIdentifierKey "com.apple.iokit.IOSCSIArchitectureModelFamily" + + +// General kernel headers +#include + +// General IOKit headers +#include +#include +#include +#include + +// SCSI Architecture Model Family includes +#include + + +/*! +@enum SCSI Protocol Interface Device Notification values +@discussion +Message values for SCSI Protocol Interface Device Notifications. +@constant kSCSIProtocolNotification_DeviceRemoved +Private message sent between a SCSI protocol service provider and +SCSI application layer driver to indicate device removal. +@constant kSCSIProtocolNotification_VerifyDeviceState +Private message sent between a SCSI protocol service provider and +SCSI application layer driver to indicate device state may have +changed and the device state should be re-verified by the SCSI +Application Layer driver. An example would be a bus reset which clears +the tray locking state of an ATAPI device. +@constant kSCSIServicesNotification_ExclusivityChanged +Message sent when a change in exclusivity state occurs. Usually in +response to acquiring/releasing exclusive access to a device via a user client. +*/ +enum +{ + kSCSIProtocolNotification_DeviceRemoved = 0x69000010, + kSCSIProtocolNotification_VerifyDeviceState = 0x69000020, + kSCSIServicesNotification_ExclusivityChanged = 0x69000030 +}; + + +/*! +@typedef SCSIProtocolFeature +@discussion +Typedef for SCSIProtocolFeature, a 32-bit quantity. +*/ +typedef UInt32 SCSIProtocolFeature; + +/*! +@enum SCSI Protocol Features +@discussion +The list of SCSI Protocol Features currently supported. +*/ +enum +{ + + /*! + @constant kSCSIProtocolFeature_ACA Not yet used. + */ + kSCSIProtocolFeature_ACA = 1, + + /*! + @constant kSCSIProtocolFeature_CPUInDiskMode Used to determine + if the SCSI Protocol Services Driver supports a CPU which is in + target disk mode. + */ + kSCSIProtocolFeature_CPUInDiskMode = 2, + + /*! + @constant kSCSIProtocolFeature_ProtocolSpecificPolling Used + to determine if the SCSI Protocol Services Driver supports + protocol specific polling for media. This is used for low-power + polling specifically for ATAPI devices on ATA buses + */ + kSCSIProtocolFeature_ProtocolSpecificPolling = 3, + + /*! + @constant kSCSIProtocolFeature_ProtocolSpecificSleepCommand Used + to determine if the SCSI Protocol Services Driver supports + protocol specific sleep commands to a drive. This is used for + sleeping drives specifically ATAPI devices on ATA buses. + */ + kSCSIProtocolFeature_ProtocolSpecificSleepCommand = 4, + + /*! + @constant kSCSIProtocolFeature_GetMaximumLogicalUnitNumber If + the SCSI Protocol Services Driver supports logical units, it will + report the maximum addressable ID that it supports in the UInt32 pointer + that is passed in as the serviceValue. If only one unit is supported, + the driver should return false for this query. + */ + kSCSIProtocolFeature_GetMaximumLogicalUnitNumber = 5, + + /*! + @constant kSCSIProtocolFeature_MaximumReadBlockTransferCount If + the SCSI Protocol Services Driver has a maximum number of + blocks that can be transfered in a read request, it will return + true to this query and return the block count in the UInt32 pointer + that is passed in as the serviceValue. + */ + kSCSIProtocolFeature_MaximumReadBlockTransferCount = 6, + + /*! + @constant kSCSIProtocolFeature_MaximumWriteBlockTransferCount If + the SCSI Protocol Services Driver has a maximum number of + blocks that can be transferred in a write request, it will return + true to this query and return the block count in the UInt32 pointer + that is passed in as the serviceValue. + */ + kSCSIProtocolFeature_MaximumWriteBlockTransferCount = 7, + + /*! + @constant kSCSIProtocolFeature_MaximumReadTransferByteCount If + the SCSI Protocol Services Driver has a maximum byte count + that can be transferred in a read request, it will return + true to this query and return the byte count in the UInt64 pointer + that is passed in as the serviceValue. + */ + kSCSIProtocolFeature_MaximumReadTransferByteCount = 8, + + /*! + @constant kSCSIProtocolFeature_MaximumWriteTransferByteCount If + the SCSI Protocol Services Driver has a maximum byte count + that can be transferred in a write request, it will return + true to this query and return the byte count in the UInt64 pointer + that is passed in as the serviceValue. + */ + kSCSIProtocolFeature_MaximumWriteTransferByteCount = 9, + + /*! + @constant kSCSIProtocolFeature_SubmitDefaultInquiryData If + the SCSI Protocol Services Driver needs any extra information to + make any negotiation settings from the standard INQUIRY data, this + will be called to set that appropriately. The serviceValue will + point to a SCSICmd_INQUIRY_StandardData buffer. The size + of the buffer depends on the SCSI Device Characteristics + dictionary for the device or bus. If there is no + kIOPropertySCSIInquiryLengthKey value set in the dictionary + or if it doesn't exist, then the size of the data will be + the size of the full amount of Inquiry retrieved from the device. + */ + kSCSIProtocolFeature_SubmitDefaultInquiryData = 10, + + /*! + @constant kSCSIProtocolFeature_ProtocolAlwaysReportsAutosenseData If + the SCSI Protocol Services Driver always reports available + autosense data when a kSCSITaskStatus_CHECK_CONDITION is set, + then the protocol layer should return true. E.g. FireWire + transport drivers should respond true to this. + */ + kSCSIProtocolFeature_ProtocolAlwaysReportsAutosenseData = 11, + + /*! + @constant kSCSIProtocolFeature_ProtocolSpecificPowerOff If + the SCSI Protocol Services Driver supports removing the power + to the drive, then the protocol layer should return true. This is + used for aggressive power management, specifically for ATAPI + devices on ATA buses. + */ + kSCSIProtocolFeature_ProtocolSpecificPowerOff = 12, + + /*! + @constant kSCSIProtocolFeature_ProtocolSpecificPowerControl + Used to determine if the SCSI Protocol Services Driver supports + switching the power to the drive on and off. This is used for aggressive + power management, specifically for SATAPI devices on AHCI buses. + */ + kSCSIProtocolFeature_ProtocolSpecificPowerControl = 13, + + /*! + @constant kSCSIProtocolFeature_ProtocolSpecificAsyncNotification + Used to determine if the SCSI Protocol Services Driver supports + asynchronous notifications from the drive. This is used to prevent + polling for media, specifically for SATAPI devices on AHCI buses. + */ + kSCSIProtocolFeature_ProtocolSpecificAsyncNotification = 14 + +}; + + +/*! +@typedef SCSIProtocolPowerState +@discussion +Typedef for SCSIProtocolPowerState, a 32-bit quantity. +*/ +typedef UInt32 SCSIProtocolPowerState; + +/*! +@enum SCSI Protocol Power States +@discussion +The list of SCSI Protocol Power States. +*/ +enum +{ + /*! + @constant kSCSIProtocolPowerStateOff + Off power state. + */ + kSCSIProtocolPowerStateOff = 0, + + /*! + @constant kSCSIProtocolPowerStateOn + On power state. + */ + kSCSIProtocolPowerStateOn = 1 +}; + + +//----------------------------------------------------------------------------- +// Class Declaration +//----------------------------------------------------------------------------- + +/*! +@class IOSCSIProtocolInterface +@superclass IOService +@discussion +This class defines the public SCSI Protocol Layer API for any class that +provides Protocol services or needs to provide the Protocol Service API +for passing service requests to a Protocol Service driver. +*/ +class IOSCSIProtocolInterface : public IOService +{ + + OSDeclareAbstractStructors ( IOSCSIProtocolInterface ) + +public: + + /*! + @function start + @abstract During an IOService object's instantiation, starts the IOService object that has been selected to run on the provider. + @discussion See IOService.h for details. + @result true if the start was successful; false otherwise (which will cause the instance to be detached and usually freed). + */ + virtual bool start ( IOService * provider ); + + /*! + @function free + @abstract Called to release all resources held by the object. + @discussion Release all resources held by the object, then call super::free(). + */ + virtual void free ( void ); + + /*! + @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 true. + */ + virtual bool willTerminate ( IOService * provider, IOOptionBits options ); + + /*! + @function GetUserClientExclusivityState + @abstract Gets the current exclusivity state of the user client. + @discussion The GetUserClientExclusivityState() method is called by the SCSITaskUserClient + to determine if any user client is holding exclusive access at the current time. This is simply + a preflight check and a return value of false does not guarantee that a subsequent + call to SetUserClientExclusivityState() will return successfully. + @result true if a user client is in exclusive control of the device, false otherwise. + */ + virtual bool GetUserClientExclusivityState ( void ); + + /*! + @function SetUserClientExclusivityState + @abstract Sets the current exclusivity state of the user client. + @discussion The SetUserClientExclusivityState() method is called by the SCSITaskUserClient + to set the exclusive access mode. + @param userClient The instance of SCSITaskUserClient for which to change exclusivity state. + @param state Exclusivity state. true means exclusive access is desired, false + means exclusive access is being released. + @result A valid IOReturn code indicating success or the type of failure. + */ + virtual IOReturn SetUserClientExclusivityState ( IOService * userClient, bool state ); + + + /*! + @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. + Subclasses should not need to override this method. + @param flags Flags that describe the character of "domain power"; they represent the outputPowerCharacter field of a state in the power domain's power state array. + @result A state number. + */ + virtual unsigned long initialPowerStateForDomainState ( IOPMPowerFlags flags ); + + /*! + @function setPowerState + @abstract Requests a power managed driver to change the power state of its device. + @discussion Requests a power managed driver to change the power state of its device. Most subclasses + of IOSCSIProtocolInterface have class-specific mechanisms and should not override this routine. + See IOSCSIProtocolServices.h, IOSCSIBlockCommandsDevice.h, IOSCSIReducedBlockCommandsDevice.h, and + IOSCSIMultimediaCommandsDevice.h for more information about power management changes. + Subclasses should not need to override this method. + @param powerStateOrdinal The number in the power state array to which the drive is being instructed to change. + @param whichDevice A pointer to the power management object which registered to manage power for this device. + The whichDevice field is not pertinent to us since the driver is both the "policy maker" for the device, + and the "policy implementor" for the device. + @result See IOService.h for details. + */ + virtual IOReturn setPowerState ( unsigned long powerStateOrdinal, IOService * whichDevice ); + + /*! + @function IsPowerManagementIntialized + @abstract Called to determine if power management is initialized. + @discussion Called to determine if power management is initialized. + Subclasses should not need to override this method. + @result true if power management has been initialized, false otherwise. + */ + virtual bool IsPowerManagementIntialized ( void ); + + /*! + @function CheckPowerState + @abstract Called by clients to ensure device is in correct power state before issuing I/O. + @discussion Called by clients to ensure device is in correct power state before issuing I/O. + If the device is not ready to handle such requests, it gives the driver a chance to block the + thread until the device is ready. Subclasses should not need to override this method. + */ + virtual void CheckPowerState ( void ); + + /*! + @function ExecuteCommand + @abstract Called to send a SCSITask and transport it across the physical wire(s) to the device. + @discussion Called to send a SCSITask and transport it across the physical wire(s) to the device. + Subclasses internal to IOSCSIArchitectureModelFamily will need to override this method. Third + party subclasses should not need to override this method. + @param request A valid SCSITaskIdentifier representing the task to transport across the wire(s). + */ + virtual void ExecuteCommand ( SCSITaskIdentifier request ) = 0; + + /*! + @function AbortCommand + @abstract Obsolete. Do not use this method. + @discussion Obsolete. Do not use this method. + */ + virtual SCSIServiceResponse AbortCommand ( SCSITaskIdentifier request ) = 0; + + /*! + @function IsProtocolServiceSupported + @abstract This method is called to query for support of a protocol specific service feature. + @discussion This method is called to query for support of a protocol specific service feature. + Subclasses of IOSCSIProtocolServices should override this method. + @param feature A valid SCSIProtocolFeature. See enums for SCSIProtocolFeature. + @param serviceValue A pointer to a structure/value that is used in conjunction with the feature + requested. See enums for SCSIProtocolFeature. NB: This parameter may be NULL for certain + feature requests. + @result true if the feature is supported, false otherwise. + */ + virtual bool IsProtocolServiceSupported ( + SCSIProtocolFeature feature, + void * serviceValue ) = 0; + + /*! + @function HandleProtocolServiceFeature + @abstract This method is called to enact support of a protocol specific service feature. + @discussion This method is called to enact support of a protocol specific service feature. + Subclasses of IOSCSIProtocolServices should override this method. + @param feature A valid SCSIProtocolFeature. See enums for SCSIProtocolFeature. + @param serviceValue A pointer to a structure/value that is used in conjunction with the feature + requested. See enums for SCSIProtocolFeature. NB: This parameter may be NULL for certain + feature requests. + @result true if the service feature request succeeded, false otherwise. + */ + virtual bool HandleProtocolServiceFeature ( + SCSIProtocolFeature feature, + void * serviceValue ) = 0; + +protected: + + // Reserve space for future expansion. + struct IOSCSIProtocolInterfaceExpansionData + { + IOWorkLoop * fWorkLoop; + }; + IOSCSIProtocolInterfaceExpansionData * fIOSCSIProtocolInterfaceReserved; + + // ------ Power Management Support ------ + + thread_call_t fPowerManagementThread; + IOCommandGate * fCommandGate; + UInt32 fCurrentPowerState; + UInt32 fProposedPowerState; + bool fPowerTransitionInProgress; + bool fPowerAckInProgress; + bool fPowerManagementInitialized; + + /*! + @function GetCommandGate + @abstract Accessor method to obtain the IOCommandGate. + @discussion Accessor method to obtain the IOCommandGate. + @result The IOCommandGate for this instance. May return NULL. + */ + IOCommandGate * GetCommandGate ( void ); + + /*! + @function InitializePowerManagement + @abstract This method is called to initialize power management. + @discussion This method is called to initialize power management. It will call PMinit(), joinPMTree(), + setIdleTimerPeriod(), and makeUsable(). This method does not call registerPowerDriver(). + Subclasses may override this method to change the behavior (such as the number of power states). + @param provider The power management provider (i.e. the provider to attach to in the PowerManagement + tree). This may be a device that is not in the PM Tree itself, in which case, the IOService plane + is traversed towards the root node in an effort to find a node in the PM Tree. + */ + virtual void InitializePowerManagement ( IOService * provider ); + + /*! + @function GetInitialPowerState + @abstract This method is called to obtain the initial power state of the device (usually the highest). + @discussion This method is called to obtain the initial power state of the device (usually the highest). + Subclasses must override this method. + @result A power state ordinal. + */ + virtual UInt32 GetInitialPowerState ( void ) = 0; + + /*! + @function finalize + @abstract Finalizes the destruction of an IOService object. + @discussion See IOService.h + Subclasses may override this method, but should call super::finalize(). + @result true. + */ + virtual bool finalize ( IOOptionBits options ); + + /*! + @function sHandleSetPowerState + @abstract The sHandleSetPowerState method is a static function used as C->C++ glue + for going behind the command gate. + @discussion The sHandleSetPowerState method is a static function used as C->C++ glue + for going behind the command gate. + @param self The 'this' pointer for the class. + @param powerStateOrdinal The power state to which device shall be changed. + @result A valid IOReturn code indicating success or failure. + */ + static IOReturn sHandleSetPowerState ( IOSCSIProtocolInterface * self, UInt32 powerStateOrdinal ); + + /*! + @function sGetPowerTransistionInProgress + @abstract The sGetPowerTransistionInProgress method is a static function used as C->C++ glue + for going behind the command gate. + @discussion The sGetPowerTransistionInProgress method is a static function used as C->C++ glue + for going behind the command gate. + @param self The 'this' pointer for the class. + @result true if a power state is in progress, otherwise false. + */ + static bool sGetPowerTransistionInProgress ( IOSCSIProtocolInterface * self ); + + /*! + @function HandleSetPowerState + @abstract The HandleSetPowerState method is called by the glue code and is on the + serialized side of the command gate. + @discussion The HandleSetPowerState method is called by the glue code and is on the + serialized side of the command gate. This allows us to touch any member + variables as necessary without any multi-threading issues. + Subclasses may override this method to change behavior. Third party subclasses + should not need to override this method, but may. + @param powerStateOrdinal The power state to which device shall be changed. + */ + virtual void HandleSetPowerState ( UInt32 powerStateOrdinal ); + + /*! + @function sPowerManagement + @abstract The sPowerManagement method is a static C-function which is called using + mach's thread_call API. It guarantees us a thread of execution which is + different than the power management thread and the workloop thread on which + we can issue commands to the device synchronously or asynchronously without + worrying about deadlocks. It calls through to HandlePowerChange, which is + a state machine used to direct power management. + @discussion The sPowerManagement method is a static C-function which is called using + mach's thread_call API. It guarantees us a thread of execution which is + different than the power management thread and the workloop thread on which + we can issue commands to the device synchronously or asynchronously without + worrying about deadlocks. It calls through to HandlePowerChange, which is + a state machine used to direct power management. + @param whichDevice The 'this' pointer. + */ + static void sPowerManagement ( thread_call_param_t whichDevice ); + + /*! + @function HandlePowerChange + @abstract The HandlePowerChange method is pure virtual and is left to each protocol or + application layer driver to implement. It is guaranteed to be called on its + own thread of execution and can make synchronous or asynchronous calls. + @discussion The HandlePowerChange method is pure virtual and is left to each protocol or + application layer driver to implement. It is guaranteed to be called on its + own thread of execution and can make synchronous or asynchronous calls. + Subclasses must override this method. Third party subclasses shouldn't need to override + this method but can to alter the default behavior. + */ + virtual void HandlePowerChange ( void ) = 0; + + /*! + @function sHandleCheckPowerState + @abstract The sHandleCheckPowerState method is a static function used as C->C++ glue + for going behind the command gate. + @discussion The sHandleCheckPowerState method is a static function used as C->C++ glue + for going behind the command gate. + @param self The 'this' pointer for the class. + */ + static void sHandleCheckPowerState ( IOSCSIProtocolInterface * self ); + + /*! + @function HandleCheckPowerState(void) + @abstract The HandleCheckPowerState (void) method is on the serialized side of the command + gate and can change member variables safely without multi-threading issues. + It's main purpose is to call the superclass' HandleCheckPowerState ( UInt32 maxPowerState ) + with the max power state the class registered with. + @discussion The HandleCheckPowerState (void) method is on the serialized side of the command + gate and can change member variables safely without multi-threading issues. + It's main purpose is to call the superclass' HandleCheckPowerState ( UInt32 maxPowerState ) + with the max power state the class registered with. + Subclasses must override this method. Third party subclasses shouldn't need to override + this method but can to alter the default behavior. + */ + virtual void HandleCheckPowerState ( void ) = 0; + + /*! + @function HandleCheckPowerState(UInt32 maxPowerState) + @abstract The HandleCheckPowerState(UInt32 maxPowerState) method is called by + the subclasses and is passed the maxPowerState number given to the power + manager at initialization time. This guarantees the threads block until that + power state has been achieved. + @discussion The HandleCheckPowerState(UInt32 maxPowerState) method is called by + the subclasses and is passed the maxPowerState number given to the power + manager at initialization time. This guarantees the threads block until that + power state has been achieved. + @param maxPowerState The maximum power state in the power state array. + */ + void HandleCheckPowerState ( UInt32 maxPowerState ); + + /*! + @function TicklePowerManager(void) + @abstract The TicklePowerManager(void) method is called by CheckPowerState and + sends an activity tickle to the power manager so that the idle timer is + reset. + @discussion The TicklePowerManager(void) method is called by CheckPowerState and + sends an activity tickle to the power manager so that the idle timer is + reset. + Subclasses must override this method. Third party subclasses shouldn't need to override + this method but can to alter the default behavior. + */ + virtual void TicklePowerManager ( void ) = 0; + + /*! + @function TicklePowerManager(UInt32 maxPowerState) + @abstract The TicklePowerManager(UInt32 maxPowerState) method is a convenience + function which can be called by subclasses in TicklePowerManager (void) + in order to tell the power manager to reset idle timer or bring the device + into the requested state. It returns whatever is returned by activityTickle + (true if device is in the requested state, false if it is not). + @discussion The TicklePowerManager(UInt32 maxPowerState) method is a convenience + function which can be called by subclasses in TicklePowerManager(void) + in order to tell the power manager to reset idle timer or bring the device + into the requested state. It returns whatever is returned by activityTickle + (true if device is in the requested state, false if it is not). + @param maxPowerState The maximum power state in the power state array. + @result The result of the call to activityTickle(). See IOService.h for details. + */ + bool TicklePowerManager ( UInt32 maxPowerState ); + + // ------ User Client Support ------ + + bool fUserClientExclusiveControlled; + IOService * fUserClient; + + /*! + @function sGetUserClientExclusivityState + @abstract The sGetUserClientExclusivityState method is a static function used as C->C++ glue + for going behind the command gate. + @discussion The sGetUserClientExclusivityState method is a static function used as C->C++ glue + for going behind the command gate. + @param self The 'this' pointer for the class. + @param state A pointer to a bool in which the state should be set. + */ + static void sGetUserClientExclusivityState ( IOSCSIProtocolInterface * self, bool * state ); + + /*! + @function sSetUserClientExclusivityState + @abstract The sSetUserClientExclusivityState method is a static function used as C->C++ glue + for going behind the command gate. + @discussion The sSetUserClientExclusivityState method is a static function used as C->C++ glue + for going behind the command gate. + @param self The 'this' pointer for the class. + @param result A pointer to an IOReturn for the resulting status. + @param userClient The instance of SCSITaskUserClient for which to change exclusivity state. + @param state A bool indicating the desired state to set. + */ + static void sSetUserClientExclusivityState ( IOSCSIProtocolInterface * self, IOReturn * result, IOService * userClient, bool state ); + + /*! + @function HandleGetUserClientExclusivityState + @abstract Gets the current exclusivity state of the user client. + @discussion The HandleGetUserClientExclusivityState() method is called on the serialized side + of the command gate to determine if any user client is holding exclusive access at the current + time. See discussion for GetUserClientExclusivityState(). + Subclasses may override this method to alter default behavior. Third party subclasses should + not need to override this method. + @result true if a user client is in exclusive control of the device, false otherwise. + */ + virtual bool HandleGetUserClientExclusivityState ( void ); + + /*! + @function HandleSetUserClientExclusivityState + @abstract Sets the current exclusivity state of the user client. + @discussion The HandleSetUserClientExclusivityState() method is called on the serialized side + of the command gate to set the exclusive access mode. + @param userClient The instance of SCSITaskUserClient for which to change exclusivity state. + @param state Exclusivity state. true means exclusive access is desired, false + means exclusive access is being released. + @result A valid IOReturn code indicating success or the type of failure. + */ + virtual IOReturn HandleSetUserClientExclusivityState ( IOService * userClient, bool state ); + +public: + + // ------- SCSI Architecture Model Task Management Functions ------ + + OSMetaClassDeclareReservedUsed ( IOSCSIProtocolInterface, 1 ); + /*! + @function AbortTask + @abstract Aborts a task based on the Logical Unit and tagged task identifier. + @discussion Aborts a task based on the Logical Unit and tagged task identifier. + Subclasses must override this method. Third party subclasses should not need to override + this method. + @param theLogicalUnit This value should be zero unless the device driver is + more complex and managing multiple Logical Units. + @param theTag A valid SCSITaggedTaskIdentifier representing an outstanding SCSITask. + @result A valid SCSIServiceResponse code. + */ + virtual SCSIServiceResponse AbortTask ( UInt8 theLogicalUnit, SCSITaggedTaskIdentifier theTag ) = 0; + + OSMetaClassDeclareReservedUsed ( IOSCSIProtocolInterface, 2 ); + /*! + @function AbortTaskSet + @abstract Aborts a task set based on the Logical Unit. + @discussion Aborts a task set based on the Logical Unit. + Subclasses must override this method. Third party subclasses should not need to override + this method. + @param theLogicalUnit This value should be zero unless the device driver is + more complex and managing multiple Logical Units. + @result A valid SCSIServiceResponse code. + */ + virtual SCSIServiceResponse AbortTaskSet ( UInt8 theLogicalUnit ) = 0; + + OSMetaClassDeclareReservedUsed ( IOSCSIProtocolInterface, 3 ); + /*! + @function ClearACA + @abstract Clears an Auto-Contingent Allegiance (ACA) for the specified Logical Unit. + @discussion Clears an Auto-Contingent Allegiance (ACA) for the specified Logical Unit. + Subclasses must override this method. Third party subclasses should not need to override + this method. + @param theLogicalUnit This value should be zero unless the device driver is + more complex and managing multiple Logical Units. + @result A valid SCSIServiceResponse code. + */ + virtual SCSIServiceResponse ClearACA ( UInt8 theLogicalUnit ) = 0; + + OSMetaClassDeclareReservedUsed ( IOSCSIProtocolInterface, 4 ); + /*! + @function ClearTaskSet + @abstract Clears a task set for the specified Logical Unit. + @discussion Clears a task set for the specified Logical Unit. + Subclasses must override this method. Third party subclasses should not need to override + this method. + @param theLogicalUnit This value should be zero unless the device driver is + more complex and managing multiple Logical Units. + @result A valid SCSIServiceResponse code. + */ + virtual SCSIServiceResponse ClearTaskSet ( UInt8 theLogicalUnit ) = 0; + + OSMetaClassDeclareReservedUsed ( IOSCSIProtocolInterface, 5 ); + /*! + @function LogicalUnitReset + @abstract Resets the specified Logical Unit. + @discussion Resets the specified Logical Unit. + Subclasses must override this method. Third party subclasses should not need to override + this method. + @param theLogicalUnit This value should be zero unless the device driver is + more complex and managing multiple Logical Units. + @result A valid SCSIServiceResponse code. + */ + virtual SCSIServiceResponse LogicalUnitReset ( UInt8 theLogicalUnit ) = 0; + + OSMetaClassDeclareReservedUsed ( IOSCSIProtocolInterface, 6 ); + + /*! + @function TargetReset + @abstract Resets the target device. + @discussion Resets the target device. + Subclasses must override this method. Third party subclasses should not need to override + this method. + @result A valid SCSIServiceResponse code. + */ + virtual SCSIServiceResponse TargetReset ( void ) = 0; + +private: + + // Space reserved for future expansion. + OSMetaClassDeclareReservedUnused ( IOSCSIProtocolInterface, 7 ); + OSMetaClassDeclareReservedUnused ( IOSCSIProtocolInterface, 8 ); + OSMetaClassDeclareReservedUnused ( IOSCSIProtocolInterface, 9 ); + OSMetaClassDeclareReservedUnused ( IOSCSIProtocolInterface, 10 ); + OSMetaClassDeclareReservedUnused ( IOSCSIProtocolInterface, 11 ); + OSMetaClassDeclareReservedUnused ( IOSCSIProtocolInterface, 12 ); + OSMetaClassDeclareReservedUnused ( IOSCSIProtocolInterface, 13 ); + OSMetaClassDeclareReservedUnused ( IOSCSIProtocolInterface, 14 ); + OSMetaClassDeclareReservedUnused ( IOSCSIProtocolInterface, 15 ); + OSMetaClassDeclareReservedUnused ( IOSCSIProtocolInterface, 16 ); + +}; + +#endif /* defined(KERNEL) && defined(__cplusplus) */ + +#endif /* _IOKIT_IO_SCSI_PROTOCOL_INTERFACE_H_ */ Index: branches/azimutz/Cleancut/i386/include/IOKit/scsi/IOSCSIPeripheralDeviceType07.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/scsi/IOSCSIPeripheralDeviceType07.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/scsi/IOSCSIPeripheralDeviceType07.h (revision 885) @@ -0,0 +1,75 @@ +/* + * 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_SCSI_PERIPHERAL_DEVICE_TYPE_07_H_ +#define _IOKIT_IO_SCSI_PERIPHERAL_DEVICE_TYPE_07_H_ + +#if defined(KERNEL) && defined(__cplusplus) + + +//----------------------------------------------------------------------------- +// Includes +//----------------------------------------------------------------------------- + +// SCSI Architecture Model Family includes +#include + + +//----------------------------------------------------------------------------- +// Class Declaration +//----------------------------------------------------------------------------- + +class IOSCSIPeripheralDeviceType07 : public IOSCSIBlockCommandsDevice +{ + + OSDeclareDefaultStructors ( IOSCSIPeripheralDeviceType07 ) + +protected: + + // Reserve space for future expansion. + struct IOSCSIPeripheralDeviceType07ExpansionData { }; + IOSCSIPeripheralDeviceType07ExpansionData * fIOSCSIPeripheralDeviceType07Reserved; + +public: + + bool init ( OSDictionary * propTable ); + virtual bool start ( IOService * provider ); + virtual void stop ( IOService * provider ); + +private: + + // Space reserved for future expansion. + OSMetaClassDeclareReservedUnused ( IOSCSIPeripheralDeviceType07, 1 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPeripheralDeviceType07, 2 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPeripheralDeviceType07, 3 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPeripheralDeviceType07, 4 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPeripheralDeviceType07, 5 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPeripheralDeviceType07, 6 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPeripheralDeviceType07, 7 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPeripheralDeviceType07, 8 ); + +}; + +#endif /* defined(KERNEL) && defined(__cplusplus) */ + +#endif /* _IOKIT_IO_SCSI_PERIPHERAL_DEVICE_TYPE_07_H_ */ Index: branches/azimutz/Cleancut/i386/include/IOKit/scsi/SCSICommandOperationCodes.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/scsi/SCSICommandOperationCodes.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/scsi/SCSICommandOperationCodes.h (revision 885) @@ -0,0 +1,941 @@ +/* + * Copyright (c) 2001-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 _SCSI_COMMAND_OPERATION_CODES_H_ +#define _SCSI_COMMAND_OPERATION_CODES_H_ + +#pragma mark About this file +/* This file contains the operation code definitions for all commands defined + * by the SCSI specifications. The commands are listed in three formats: + * 1) All commands are listed in alphabetical order. This list is the live + * enumeration for all of the command constants. + * 2) The commands are listed in ascending numerical order. + * 3) The commands are grouped by Peripheral Device Type. + * + * In the command listings by Peripheral Device Type, there will be a comment + * following each command. This comment indentifies the section of the related + * specification where the commands is defined and the requirement type of the + * command, Mandatory or Optional. + * If a specification redefines an optional command from SPC as mandatory, + * the command will be relisted in the Peripheral Device Type command list with + * the mandatory tag next to it. + * All commands that are listed in SPC as Device Type Specifc will be relisted + * as a comment in all specifications lists that support that command with the + * appropriate Mandatory or Optional tag for that specification. + * + * The section number and the requirement type of the command are based on the + * version of the specification listed in the header comment for the Peripheral + * Device Type. This data is provided for informational purposes only. The + * specification document and version that the device adheres to as indicated + * by the data returned in response to the INQUIRY command should be used as + * the authorative source for supported and required behavior of the device. + * + * The SPC set is listed before all other Peripheral Device Type commands as + * this is the base document from which all of the other documents are derived. + * + * The Peripheral Device Types and associated command sets as defined by SPC-2, + * section 7.4.1 are as follows: + * Peripheral Device Type Associated Command Specification + * ------------------------------------ ----------------------------------- + * 0x00 Direct Access Device SBC - SCSI-3 Block Commands + * 0x01 Sequential Access Device SSC - SCSI-3 Stream Commands + * 0x02 Printer Device SSC - SCSI-3 Stream Commands + * 0x03 Processor Device SPC - SCSI Primary Commands-2 + * 0x04 Write Once Device SBC - SCSI-3 Block Commands + * 0x05 CD-ROM Device MMC - SCSI Multimedia Commands-2 + * 0x06 Scanner Device SGC - SCSI-3 Graphics Commands + * 0x07 Optical Memory Device SBC - SCSI-3 Block Commands + * 0x08 Medium Changer Device SMC - SCSI-3 Medium Changer Cmds + * 0x09 Communications Device SSC - SCSI-3 Stream Commands + * 0x0A - 0x0B Graphic Arts Prepress Dev ASC IT8 + * 0x0C Storage Array Controller Device SCC-2 - SCSI Controller Commands-2 + * 0x0D Enclosure Services SES - SCSI-3 Enclosure Services + * 0x0E Simplified Direct Access Device RBC - SCSI Reduced Block Commands + * 0x0F Optical Card Reader/Writer Device OCRW - SCSI Specification for + * Optical Card Reader/Writer + * 0x10 Reserved No command specification + * 0x11 Object-Based Storage Device OSD - SCSI Object Based Storage + * Device Commands + * 0x12 - 0x14 Reserved No command specification + * 0x15 Multimedia Media Access Engine RMC - Reduced Multimedia Commands + * 0x16 - 0x1E Reserved No command specification + * 0x1F Unknown or No Device No command specification + */ + +#pragma mark - +#pragma mark Command Definitions by Name +/* All SCSI Commands listed in alphabetical order. These are the live + * definitions of the commands. All other command lists are informative. + */ +enum +{ + kSCSICmd_ACCESS_CONTROL_IN = 0x86, + kSCSICmd_ACCESS_CONTROL_OUT = 0x87, + kSCSICmd_BLANK = 0xA1, + kSCSICmd_CHANGE_DEFINITION = 0x40, + kSCSICmd_CLOSE_TRACK_SESSION = 0x5B, + kSCSICmd_COMPARE = 0x39, + kSCSICmd_COPY = 0x18, + kSCSICmd_COPY_AND_VERIFY = 0x3A, + kSCSICmd_ERASE_10 = 0x2C, + kSCSICmd_ERASE_12 = 0xAC, + kSCSICmd_EXTENDED_COPY = 0x83, + kSCSICmd_FORMAT_UNIT = 0x04, + kSCSICmd_GET_CONFIGURATION = 0x46, + kSCSICmd_GET_EVENT_STATUS_NOTIFICATION = 0x4A, + kSCSICmd_GET_PERFORMANCE = 0xAC, + kSCSICmd_INQUIRY = 0x12, + kSCSICmd_LOAD_UNLOAD_MEDIUM = 0xA6, + kSCSICmd_LOCK_UNLOCK_CACHE = 0x36, + kSCSICmd_LOCK_UNLOCK_CACHE_16 = 0x92, + kSCSICmd_LOG_SELECT = 0x4C, + kSCSICmd_LOG_SENSE = 0x4D, + kSCSICmd_MAINTENANCE_IN = 0xA3, + kSCSICmd_MAINTENANCE_OUT = 0xA4, + kSCSICmd_MECHANISM_STATUS = 0xBD, + kSCSICmd_MEDIUM_SCAN = 0x38, + kSCSICmd_MODE_SELECT_6 = 0x15, + kSCSICmd_MODE_SELECT_10 = 0x55, + kSCSICmd_MODE_SENSE_6 = 0x1A, + kSCSICmd_MODE_SENSE_10 = 0x5A, + kSCSICmd_MOVE_MEDIUM_ATTACHED = 0xA7, + kSCSICmd_PAUSE_RESUME = 0x4B, + kSCSICmd_PERSISTENT_RESERVE_IN = 0x5E, + kSCSICmd_PERSISTENT_RESERVE_OUT = 0x5F, + kSCSICmd_PLAY_AUDIO_10 = 0x45, + kSCSICmd_PLAY_AUDIO_12 = 0xA5, + kSCSICmd_PLAY_AUDIO_MSF = 0x47, + kSCSICmd_PLAY_AUDIO_TRACK_INDEX = 0x48, + kSCSICmd_PLAY_CD = 0xBC, + kSCSICmd_PLAY_RELATIVE_10 = 0x49, + kSCSICmd_PLAY_RELATIVE_12 = 0xA9, + kSCSICmd_PREFETCH = 0x34, + kSCSICmd_PREFETCH_16 = 0x90, + kSCSICmd_PREVENT_ALLOW_MEDIUM_REMOVAL = 0x1E, + kSCSICmd_READ_6 = 0x08, + kSCSICmd_READ_10 = 0x28, + kSCSICmd_READ_12 = 0xA8, + kSCSICmd_READ_16 = 0x88, + kSCSICmd_READ_ATTRIBUTE = 0x8C, + kSCSICmd_READ_BUFFER = 0x3C, + kSCSICmd_READ_BUFFER_CAPACITY = 0x5C, + kSCSICmd_READ_CAPACITY = 0x25, + kSCSICmd_READ_CD = 0xBE, + kSCSICmd_READ_CD_MSF = 0xB9, + kSCSICmd_READ_DEFECT_DATA_10 = 0x37, + kSCSICmd_READ_DEFECT_DATA_12 = 0xB7, + kSCSICmd_READ_DISC_INFORMATION = 0x51, + kSCSICmd_READ_DVD_STRUCTURE = 0xAD, + kSCSICmd_READ_DISC_STRUCTURE = 0xAD, + kSCSICmd_READ_ELEMENT_STATUS_ATTACHED = 0xB4, + kSCSICmd_READ_FORMAT_CAPACITIES = 0x23, + kSCSICmd_READ_GENERATION = 0x29, + kSCSICmd_READ_HEADER = 0x44, + kSCSICmd_READ_LONG = 0x3E, + kSCSICmd_READ_MASTER_CUE = 0x59, + kSCSICmd_READ_SUB_CHANNEL = 0x42, + kSCSICmd_READ_TOC_PMA_ATIP = 0x43, + kSCSICmd_READ_TRACK_INFORMATION = 0x52, + kSCSICmd_READ_UPDATED_BLOCK_10 = 0x2D, + kSCSICmd_REASSIGN_BLOCKS = 0x07, + kSCSICmd_REBUILD = 0x81, + kSCSICmd_RECEIVE = 0x08, + kSCSICmd_RECEIVE_COPY_RESULTS = 0x84, + kSCSICmd_RECEIVE_DIAGNOSTICS_RESULTS = 0x1C, + kSCSICmd_REDUNDANCY_GROUP_IN = 0xBA, + kSCSICmd_REDUNDANCY_GROUP_OUT = 0xBB, + kSCSICmd_REGENERATE = 0x82, + kSCSICmd_RELEASE_6 = 0x17, + kSCSICmd_RELEASE_10 = 0x57, + kSCSICmd_REPAIR_TRACK = 0x58, + kSCSICmd_REPORT_DEVICE_IDENTIFIER = 0xA3, + kSCSICmd_REPORT_KEY = 0xA4, + kSCSICmd_REPORT_LUNS = 0xA0, + kSCSICmd_REQUEST_SENSE = 0x03, + kSCSICmd_RESERVE_6 = 0x16, + kSCSICmd_RESERVE_10 = 0x56, + kSCSICmd_RESERVE_TRACK = 0x53, + kSCSICmd_REZERO_UNIT = 0x01, + kSCSICmd_SCAN_MMC = 0xBA, + kSCSICmd_SEARCH_DATA_EQUAL_10 = 0x31, + kSCSICmd_SEARCH_DATA_EQUAL_12 = 0xB1, + kSCSICmd_SEARCH_DATA_HIGH_10 = 0x30, + kSCSICmd_SEARCH_DATA_HIGH_12 = 0xB0, + kSCSICmd_SEARCH_DATA_LOW_10 = 0x32, + kSCSICmd_SEARCH_DATA_LOW_12 = 0xB2, + kSCSICmd_SEEK_6 = 0x0B, + kSCSICmd_SEEK_10 = 0x2B, + kSCSICmd_SEND = 0x0A, + kSCSICmd_SEND_CUE_SHEET = 0x5D, + kSCSICmd_SEND_DIAGNOSTICS = 0x1D, + kSCSICmd_SEND_DVD_STRUCTURE = 0xBF, + kSCSICmd_SEND_EVENT = 0xA2, + kSCSICmd_SEND_KEY = 0xA3, + kSCSICmd_SEND_OPC_INFORMATION = 0x54, + kSCSICmd_SERVICE_ACTION_IN = 0x9E, + kSCSICmd_SERVICE_ACTION_OUT = 0x9F, + kSCSICmd_SET_CD_SPEED = 0xBB, + kSCSICmd_SET_DEVICE_IDENTIFIER = 0xA4, + kSCSICmd_SET_LIMITS_10 = 0x33, + kSCSICmd_SET_LIMITS_12 = 0xB3, + kSCSICmd_SET_READ_AHEAD = 0xA7, + kSCSICmd_SET_STREAMING = 0xB6, + kSCSICmd_SPARE_IN = 0xBC, + kSCSICmd_SPARE_OUT = 0xBD, + kSCSICmd_START_STOP_UNIT = 0x1B, + kSCSICmd_STOP_PLAY_SCAN = 0x4E, + kSCSICmd_SYNCHRONIZE_CACHE = 0x35, + kSCSICmd_SYNCHRONIZE_CACHE_16 = 0x91, + kSCSICmd_TEST_UNIT_READY = 0x00, + kSCSICmd_UPDATE_BLOCK = 0x3D, + kSCSICmd_VERIFY_10 = 0x2F, + kSCSICmd_VERIFY_12 = 0xAF, + kSCSICmd_VERIFY_16 = 0x8F, + kSCSICmd_VOLUME_SET_IN = 0xBE, + kSCSICmd_VOLUME_SET_OUT = 0xBF, + kSCSICmd_WRITE_6 = 0x0A, + kSCSICmd_WRITE_10 = 0x2A, + kSCSICmd_WRITE_12 = 0xAA, + kSCSICmd_WRITE_16 = 0x8A, + kSCSICmd_WRITE_AND_VERIFY_10 = 0x2E, + kSCSICmd_WRITE_AND_VERIFY_12 = 0xAE, + kSCSICmd_WRITE_AND_VERIFY_16 = 0x8E, + kSCSICmd_WRITE_ATTRIBUTE = 0x8D, + kSCSICmd_WRITE_BUFFER = 0x3B, + kSCSICmd_WRITE_LONG = 0x3F, + kSCSICmd_WRITE_SAME = 0x41, + kSCSICmd_WRITE_SAME_16 = 0x93, + kSCSICmd_XDREAD = 0x52, + kSCSICmd_XDWRITE = 0x50, + kSCSICmd_XDWRITE_EXTENDED = 0x80, + kSCSICmd_XDWRITEREAD_10 = 0x53, + kSCSICmd_XPWRITE = 0x51, + + kSCSICmdVariableLengthCDB = 0x7F +}; + +/* Service Action Definitions for the Variable Length CDB (7Fh) command */ +enum +{ + kSCSIServiceAction_READ_32 = 0x0009, + kSCSIServiceAction_VERIFY_32 = 0x000A, + kSCSIServiceAction_WRITE_32 = 0x000B, + kSCSIServiceAction_WRITE_AND_VERIFY_32 = 0x000C, + kSCSIServiceAction_WRITE_SAME_32 = 0x000D, + kSCSIServiceAction_XDREAD_32 = 0x0003, + kSCSIServiceAction_XDWRITE_32 = 0x0004, + kSCSIServiceAction_XDWRITEREAD_32 = 0x0007, + kSCSIServiceAction_XPWRITE_32 = 0x0006 +}; + +/* Service Action Definitions for the MAINTENANCE IN (A3h) command */ +enum +{ + kSCSIServiceAction_REPORT_ALIASES = 0x0B, + kSCSIServiceAction_REPORT_DEVICE_IDENTIFIER = 0x05, + kSCSIServiceAction_REPORT_PRIORITY = 0x0E, + kSCSIServiceAction_REPORT_SUPPORTED_OPERATION_CODES = 0x0C, + kSCSIServiceAction_REPORT_SUPPORTED_TASK_MANAGEMENT_FUNCTIONS = 0x0D, + kSCSIServiceAction_REPORT_TARGET_PORT_GROUPS = 0x0A +}; + +/* Service Action Definitions for the MAINTENANCE OUT (A4h) command */ +enum +{ + kSCSIServiceAction_CHANGE_ALIASES = 0x0B, + kSCSIServiceAction_SET_DEVICE_IDENTIFIER = 0x06, + kSCSIServiceAction_SET_PRIORITY = 0x0E, + kSCSIServiceAction_SET_TARGET_PORT_GROUPS = 0x0A +}; + +/* Service Action Definitions for the SERVICE ACTION IN (9Eh) command */ +enum +{ + kSCSIServiceAction_READ_CAPACITY_16 = 0x10, + kSCSIServiceAction_READ_LONG_16 = 0x11 +}; + +/* Service Action Definitions for the SERVICE ACTION OUT (9Fh) command */ +enum +{ + kSCSIServiceAction_WRITE_LONG_16 = 0x11 +}; + +#pragma mark - +#pragma mark Command Definitions by Number +#if 0 +enum +{ +}; +#endif + + +#pragma mark - +#pragma mark All Types SPC Commands +/* Commands defined by the T10:1236-D SCSI Primary Commands-2 (SPC-2) + * command specification. The definitions and section numbers are based on + * section 7 of the revision 18, 21 May 2000 version of the specification. + * + * These commands are defined for all devices. + */ +#if 0 +enum +{ + kSCSICmd_CHANGE_DEFINITION = 0x40, /* Obsolete */ + kSCSICmd_COMPARE = 0x39, /* Sec. 7.2: Optional */ + kSCSICmd_COPY = 0x18, /* Sec. 7.3: Optional */ + kSCSICmd_COPY_AND_VERIFY = 0x3A, /* Sec. 7.4: Optional */ + kSCSICmd_EXTENDED_COPY = 0x83, /* Sec. 7.5: Optional */ + kSCSICmd_INQUIRY = 0x12, /* Sec. 7.6: Mandatory */ + kSCSICmd_LOG_SELECT = 0x4C, /* Sec. 7.7: Optional */ + kSCSICmd_LOG_SENSE = 0x4D, /* Sec. 7.8: Optional */ + kSCSICmd_MODE_SELECT_6 = 0x15, /* Sec. 7.9: Device Type + * Specific */ + kSCSICmd_MODE_SELECT_10 = 0x55, /* Sec. 7.10: Device Type + * Specific */ + kSCSICmd_MODE_SENSE_6 = 0x1A, /* Sec. 7.11: Device Type + * Specific */ + kSCSICmd_MODE_SENSE_10 = 0x5A, /* Sec. 7.12: Device Type + * Specific */ + kSCSICmd_MOVE_MEDIUM_ATTACHED = 0xA7, /* Defined in SMC */ + kSCSICmd_PERSISTENT_RESERVE_IN = 0x5E, /* Sec. 7.13: Device Type + * Specific */ + kSCSICmd_PERSISTENT_RESERVE_OUT = 0x5F, /* Sec. 7.14: Device Type + * Specific */ + kSCSICmd_PREVENT_ALLOW_MEDIUM_REMOVAL = 0x1E, /* Sec. 7.15: Device Type + * Specific */ + kSCSICmd_READ_BUFFER = 0x3C, /* Sec. 7.16: Optional */ + kSCSICmd_READ_ELEMENT_STATUS_ATTACHED = 0xB4, /* Defined in SMC */ + kSCSICmd_RECEIVE_COPY_RESULTS = 0x84, /* Sec. 7.17: Optional */ + kSCSICmd_RECEIVE_DIAGNOSTICS_RESULTS = 0x1C, /* Sec. 7.18: Optional */ + kSCSICmd_RELEASE_10 = 0x57, /* Sec. 7.19: Device Type + * Specific */ + kSCSICmd_RELEASE_6 = 0x17, /* Sec. 7.20: Device Type + * Specific */ + kSCSICmd_REPORT_DEVICE_IDENTIFIER = 0xA3, /* Sec. 7.21: Optional */ + kSCSICmd_REPORT_LUNS = 0xA0, /* Sec. 7.22: Mandatory for + * LUN Supporting devices*/ + kSCSICmd_REQUEST_SENSE = 0x03, /* Sec. 7.23: Device Type + * Specific */ + kSCSICmd_RESERVE_10 = 0x56, /* Sec. 7.24: Device Type + * Specific */ + kSCSICmd_RESERVE_6 = 0x16, /* Sec. 7.25: Device Type + * Specific */ + kSCSICmd_SEND_DIAGNOSTICS = 0x1D, /* Sec. 7.26: Optional */ + kSCSICmd_SET_DEVICE_IDENTIFIER = 0xA4, /* Sec. 7.27: Optional */ + kSCSICmd_TEST_UNIT_READY = 0x00, /* Sec. 7.28: Mandatory */ + kSCSICmd_WRITE_BUFFER = 0x3B /* Sec. 7.29: Optional */ +}; +#endif + +#pragma mark - +#pragma mark 0x00 SBC Direct Access Commands +/* Commands defined by the T10:990-D SCSI-3 Block Commands (SBC) command + * specification. The definitions and section numbers are based on section 6.1 + * of the revision 8c, 13 November 1997 version of the specification. + */ +#if 0 +enum +{ + kSCSICmd_CHANGE_DEFINITION = 0x40, /* Obsolete */ + kSCSICmd_COMPARE = 0x39, /* SPC: Optional */ + kSCSICmd_COPY = 0x18, /* SPC: Optional */ + kSCSICmd_COPY_AND_VERIFY = 0x3A, /* SPC: Optional*/ + kSCSICmd_FORMAT_UNIT = 0x04, /* Sec. 6.1.1: Mandatory */ + kSCSICmd_INQUIRY = 0x12, /* SPC: Mandatory */ + kSCSICmd_LOCK_UNLOCK_CACHE = 0x36, /* Sec. 6.1.2: Optional */ + kSCSICmd_LOG_SELECT = 0x4C, /* SPC: Optional */ + kSCSICmd_LOG_SENSE = 0x4D, /* SPC: Optional */ + kSCSICmd_MODE_SELECT_6 = 0x15, /* SPC: Optional */ + kSCSICmd_MODE_SELECT_10 = 0x55, /* SPC: Optional */ + kSCSICmd_MODE_SENSE_6 = 0x1A, /* SPC: Optional */ + kSCSICmd_MODE_SENSE_10 = 0x5A, /* SPC: Optional */ + kSCSICmd_MOVE_MEDIUM_ATTACHED = 0xA7, /* SMC: Optional */ + kSCSICmd_PERSISTENT_RESERVE_IN = 0x5E, /* SPC: Optional */ + kSCSICmd_PERSISTENT_RESERVE_OUT = 0x5F, /* SPC: Optional */ + kSCSICmd_PREFETCH = 0x34, /* Sec. 6.1.3: Optional */ + kSCSICmd_PREVENT_ALLOW_MEDIUM_REMOVAL = 0x1E, /* SPC: Optional */ + kSCSICmd_READ_6 = 0x08, /* Sec. 6.1.4: Mandatory */ + kSCSICmd_READ_10 = 0x28, /* Sec. 6.1.5: Mandatory */ + kSCSICmd_READ_12 = 0xA8, /* Sec. 6.2.4: Optional */ + kSCSICmd_READ_BUFFER = 0x3C, /* SPC: Optional */ + kSCSICmd_READ_CAPACITY = 0x25, /* Sec. 6.1.6: Mandatory */ + kSCSICmd_READ_DEFECT_DATA_10 = 0x37, /* Sec. 6.1.7: Optional */ + kSCSICmd_READ_DEFECT_DATA_12 = 0xB7, /* Sec. 6.2.5: Optional */ + kSCSICmd_READ_ELEMENT_STATUS_ATTACHED = 0xB4, /* SMC: Optional */ + kSCSICmd_READ_GENERATION = 0x29, /* Sec. 6.2.6: Optional */ + kSCSICmd_READ_LONG = 0x3E, /* Sec. 6.1.8: Optional */ + kSCSICmd_READ_UPDATED_BLOCK_10 = 0x2D, /* Sec. 6.2.7: Optional */ + kSCSICmd_REASSIGN_BLOCKS = 0x07, /* Sec. 6.1.9: Optional */ + kSCSICmd_REBUILD = 0x81, /* Sec. 6.1.10: Optional */ + kSCSICmd_RECEIVE_DIAGNOSTICS_RESULTS = 0x1C, /* SPC: Optional */ + kSCSICmd_REGENERATE = 0x82, /* Sec. 6.1.11: Optional */ + kSCSICmd_RELEASE_6 = 0x17, /* SPC: Optional */ + kSCSICmd_RELEASE_10 = 0x57, /* SPC: Mandatory */ + kSCSICmd_REPORT_LUNS = 0xA0, /* SPC: Optional */ + kSCSICmd_REQUEST_SENSE = 0x03, /* SPC: Mandatory */ + kSCSICmd_RESERVE_6 = 0x16, /* SPC: Optional */ + kSCSICmd_RESERVE_10 = 0x56, /* SPC: Mandatory */ + kSCSICmd_REZERO_UNIT = 0x01, /* Obsolete */ + kSCSICmd_SEARCH_DATA_EQUAL_10 = 0x31, /* Obsolete */ + kSCSICmd_SEARCH_DATA_HIGH_10 = 0x30, /* Obsolete */ + kSCSICmd_SEARCH_DATA_LOW_10 = 0x32, /* Obsolete */ + kSCSICmd_SEEK_6 = 0x0B, /* Obsolete */ + kSCSICmd_SEEK_10 = 0x2B, /* Sec. 6.1.12: Optional */ + kSCSICmd_SEND_DIAGNOSTICS = 0x1D, /* SPC: Mandatory */ + kSCSICmd_SET_LIMITS_10 = 0x33, /* Sec. 6.1.13: Optional */ + kSCSICmd_SET_LIMITS_12 = 0xB3, /* Sec. 6.2.8: Optional */ + kSCSICmd_START_STOP_UNIT = 0x1B, /* Sec. 6.1.14: Optional */ + kSCSICmd_SYNCHRONIZE_CACHE = 0x35, /* Sec. 6.1.15: Optional */ + kSCSICmd_TEST_UNIT_READY = 0x00, /* SPC: Mandatory */ + kSCSICmd_UPDATE_BLOCK = 0x3D, /* Sec. 6.2.9: Optional */ + kSCSICmd_VERIFY_10 = 0x2F, /* Sec. 6.1.16: Optional */ + kSCSICmd_WRITE_6 = 0x0A, /* Sec. 6.1.17: Optional */ + kSCSICmd_WRITE_10 = 0x2A, /* Sec. 6.1.18: Optional */ + kSCSICmd_WRITE_12 = 0xAA, /* Sec. 6.2.13: Optional */ + kSCSICmd_WRITE_AND_VERIFY_10 = 0x2E, /* Sec. 6.1.19: Optional */ + kSCSICmd_WRITE_AND_VERIFY_12 = 0xAE, /* Sec. 6.2.15: Optional */ + kSCSICmd_WRITE_BUFFER = 0x3B, /* SPC: Optional */ + kSCSICmd_WRITE_LONG = 0x3F, /* Sec. 6.1.20: Optional */ + kSCSICmd_WRITE_SAME = 0x41, /* Sec. 6.1.21: Optional */ + kSCSICmd_XDREAD = 0x52, /* Sec. 6.1.22: Optional */ + kSCSICmd_XDWRITE = 0x50, /* Sec. 6.1.23: Optional */ + kSCSICmd_XDWRITE_EXTENDED = 0x80, /* Sec. 6.1.24: Optional */ + kSCSICmd_XPWRITE = 0x51 /* Sec. 6.1.25: Optional */ +}; +#endif + +#pragma mark - +#pragma mark 0x01 SSC Sequential Access Commands +/* Commands defined by the T10:997-D SCSI-3 Stream Commands (SSC) command + * specification. The definitions and section numbers are based on section 5 + * of the revision 22, January 1, 2000 version of the specification. + */ +#if 0 +enum +{ + kSCSICmd_CHANGE_DEFINITION = 0x40, /* Obsolete */ + kSCSICmd_COMPARE = 0x39, /* SPC: Optional */ + kSCSICmd_COPY = 0x18, /* SPC: Optional */ + kSCSICmd_COPY_AND_VERIFY = 0x3A, /* SPC: Optional */ + kSCSICmd_ERASE = 0x19, /* Sec. 5.3.1: Mandatory */ + kSCSICmd_FORMAT_MEDIUM = 0x04, /* Sec. 5.3.2: Optional */ + kSCSICmd_INQUIRY = 0x12, /* SPC: Mandatory */ + kSCSICmd_LOAD_UNLOAD = 0x1B, /* Sec. 5.3.3: Optional */ + kSCSICmd_LOCATE = 0x2B, /* Sec. 5.3.4: Optional */ + kSCSICmd_LOG_SELECT = 0x4C, /* SPC: Optional */ + kSCSICmd_LOG_SENSE = 0x4D, /* SPC: Optional */ + kSCSICmd_MODE_SELECT_6 = 0x15, /* SPC: Mandatory */ + kSCSICmd_MODE_SELECT_10 = 0x55, /* SPC: Optional */ + kSCSICmd_MODE_SENSE_6 = 0x1A, /* SPC: Mandatory */ + kSCSICmd_MODE_SENSE_10 = 0x5A, /* SPC: Optional */ + kSCSICmd_MOVE_MEDIUM = 0xA5, /* SMC: Optional */ + kSCSICmd_MOVE_MEDIUM_ATTACHED = 0xA7, /* SMC: Optional */ + kSCSICmd_PERSISTENT_RESERVE_IN = 0x5E, /* SPC: Optional */ + kSCSICmd_PERSISTENT_RESERVE_OUT = 0x5F, /* SPC: Optional */ + kSCSICmd_PREVENT_ALLOW_MEDIUM_REMOVAL = 0x1E, /* SPC: Optional */ + kSCSICmd_READ_6 = 0x08, /* Sec. 5.3.5: Mandatory */ + kSCSICmd_READ_BLOCK_LIMITS = 0x05, /* Sec. 5.3.6: Mandatory */ + kSCSICmd_READ_BUFFER = 0x3C, /* SPC: Optional */ + kSCSICmd_READ_ELEMENT_STATUS = 0xB8, /* SMC: Optional */ + kSCSICmd_READ_ELEMENT_STATUS_ATTACHED = 0xB4, /* SMC: Optional */ + kSCSICmd_READ_POSITION = 0x34, /* Sec. 5.3.7: Mandatory */ + kSCSICmd_READ_REVERSE = 0x0F, /* Sec. 5.3.8: Optional */ + kSCSICmd_RECEIVE_DIAGNOSTICS_RESULTS = 0x1C, /* SPC: Optional */ + kSCSICmd_RECOVER_BUFFERED_DATA = 0x14, /* Sec. 5.3.9: Optional */ + kSCSICmd_RELEASE_6 = 0x17, /* SPC: Mandatory */ + kSCSICmd_RELEASE_10 = 0x57, /* SPC: Mandatory */ + kSCSICmd_REPORT_DENSITY_SUPPORT = 0x44, /* Sec. 5.3.10: Mandatory*/ + kSCSICmd_REPORT_LUNS = 0xA0, /* SPC: Mandatory */ + kSCSICmd_REQUEST_SENSE = 0x03, /* SPC: Mandatory */ + kSCSICmd_RESERVE_6 = 0x16, /* SPC: Mandatory */ + kSCSICmd_RESERVE_10 = 0x56, /* SPC: Mandatory */ + kSCSICmd_REWIND = 0x01, /* Sec. 5.3.11: Mandatory*/ + kSCSICmd_SEND_DIAGNOSTICS = 0x1D, /* SPC: Mandatory */ + kSCSICmd_SPACE = 0x11, /* Sec. 5.3.12: Mandatory*/ + kSCSICmd_TEST_UNIT_READY = 0x00, /* SPC: Mandatory */ + kSCSICmd_VERIFY_6 = 0x13, /* Sec. 5.3.13: Optional */ + kSCSICmd_WRITE_6 = 0x0A, /* Sec. 5.3.14: Mandatory*/ + kSCSICmd_WRITE_BUFFER = 0x3B, /* SPC: Optional */ + kSCSICmd_WRITE_FILEMARKS = 0x10 /* Sec. 5.3.15: Mandatory*/ +}; +#endif + +#pragma mark - +#pragma mark 0x02 SSC Printer Commands +/* Commands defined by the T10:997-D SCSI-3 Stream Commands (SSC) command + * specification. The definitions and section numbers are based on section 6 + * of the revision 22, January 1, 2000 version of the specification. + */ +#if 0 +enum +{ + kSCSICmd_CHANGE_DEFINITION = 0x40, /* Obsolete */ + kSCSICmd_COMPARE = 0x39, /* SPC: Optional */ + kSCSICmd_COPY = 0x18, /* SPC: Optional */ + kSCSICmd_COPY_AND_VERIFY = 0x3A, /* SPC: Optional */ + kSCSICmd_FORMAT = 0x04, /* Sec. 6.2.1: Optional */ + kSCSICmd_INQUIRY = 0x12, /* SPC: Mandatory */ + kSCSICmd_LOG_SELECT = 0x4C, /* SPC: Optional */ + kSCSICmd_LOG_SENSE = 0x4D, /* SPC: Optional */ + kSCSICmd_MODE_SELECT_6 = 0x15, /* SPC: Mandatory */ + kSCSICmd_MODE_SELECT_10 = 0x55, /* SPC: Optional */ + kSCSICmd_MODE_SENSE_6 = 0x1A, /* SPC: Mandatory */ + kSCSICmd_MODE_SENSE_10 = 0x5A, /* SPC: Optional */ + kSCSICmd_PERSISTENT_RESERVE_IN = 0x5E, /* SPC: Optional */ + kSCSICmd_PERSISTENT_RESERVE_OUT = 0x5F, /* SPC: Optional */ + kSCSICmd_PRINT = 0x0A, /* Sec. 6.2.2: Mandatory */ + kSCSICmd_READ_BUFFER = 0x3C, /* SPC: Optional */ + kSCSICmd_RECEIVE_DIAGNOSTICS_RESULTS = 0x1C, /* SPC: Optional */ + kSCSICmd_RECOVER_BUFFERED_DATA = 0x14, /* Sec. 6.2.3: Optional */ + kSCSICmd_RELEASE_6 = 0x17, /* SPC: Mandatory */ + kSCSICmd_RELEASE_10 = 0x57, /* SPC: Mandatory */ + kSCSICmd_REPORT_LUNS = 0xA0, /* SPC: Mandatory */ + kSCSICmd_REQUEST_SENSE = 0x03, /* SPC: Mandatory */ + kSCSICmd_RESERVE_6 = 0x16, /* SPC: Mandatory */ + kSCSICmd_RESERVE_10 = 0x56, /* SPC: Mandatory */ + kSCSICmd_SEND_DIAGNOSTICS = 0x1D, /* SPC: Mandatory */ + kSCSICmd_SLEW_AND_PRINT = 0x0B, /* Sec. 6.2.4: Optional */ + kSCSICmd_STOP_PRINT = 0x1B, /* Sec. 6.2.5: Optional */ + kSCSICmd_SYNCHRONIZE_BUFFER = 0x10, /* Sec. 6.2.6: Optional */ + kSCSICmd_TEST_UNIT_READY = 0x00, /* SPC: Mandatory */ + kSCSICmd_WRITE_BUFFER = 0x3B /* SPC: Optional */ +}; +#endif + +#pragma mark - +#pragma mark 0x03 SPC Processor Commands +/* Commands defined by the T10:1236-D SCSI Primary Commands-2 (SPC-2) + * command specification. The definitions and section numbers are based on + * section 9 of the revision 18, 21 May 2000 version of the specification. + */ +#if 0 +enum +{ + kSCSICmd_CHANGE_DEFINITION = 0x40, /* Obsolete */ + kSCSICmd_COMPARE = 0x39, /* Sec. 7.2: Optional */ + kSCSICmd_COPY = 0x18, /* Sec. 7.3: Optional */ + kSCSICmd_COPY_AND_VERIFY = 0x3A, /* Sec. 7.4: Optional */ + kSCSICmd_EXTENDED_COPY = 0x83, /* Sec. 7.5: Optional */ + kSCSICmd_INQUIRY = 0x12, /* Sec. 7.6: Mandatory */ + kSCSICmd_LOG_SELECT = 0x4C, /* Sec. 7.7: Optional */ + kSCSICmd_LOG_SENSE = 0x4D, /* Sec. 7.8: Optional */ + kSCSICmd_PERSISTENT_RESERVE_IN = 0x5E, /* Sec. 7.13: Optional */ + kSCSICmd_PERSISTENT_RESERVE_OUT = 0x5F, /* Sec. 7.14: Optional */ + kSCSICmd_READ_BUFFER = 0x3C, /* Sec. 7.16: Optional */ + kSCSICmd_RECEIVE = 0x08, /* Sec. 9.2: Optional */ + kSCSICmd_RECEIVE_COPY_RESULTS = 0x84, /* Sec. 7.17: Optional */ + kSCSICmd_RECEIVE_DIAGNOSTICS_RESULTS = 0x1C, /* Sec. 7.18: Optional */ + kSCSICmd_RELEASE_10 = 0x57, /* Sec. 7.19: Optional */ + kSCSICmd_RELEASE_6 = 0x17, /* Sec. 7.20: Optional */ + kSCSICmd_REPORT_LUNS = 0xA0, /* Sec. 7.22: Optional */ + kSCSICmd_REQUEST_SENSE = 0x03, /* Sec. 7.23: Mandatory */ + kSCSICmd_RESERVE_10 = 0x56, /* Sec. 7.24: Optional */ + kSCSICmd_RESERVE_6 = 0x16, /* Sec. 7.25: Optional */ + kSCSICmd_SEND = 0x0A, /* Sec. 9.3: Optional */ + kSCSICmd_SEND_DIAGNOSTICS = 0x1D, /* Sec. 7.26: Mandatory */ + kSCSICmd_TEST_UNIT_READY = 0x00, /* Sec. 7.27: Mandatory */ + kSCSICmd_WRITE_BUFFER = 0x3B /* Sec. 7.29: Optional */ +}; +#endif + +#pragma mark - +#pragma mark 0x04 SBC Write Once Commands +/* Commands defined by the T10:990-D SCSI-3 Block Commands (SBC) command + * specification. The definitions and section numbers are based on section 6.3 + * of the revision 8c, 13 November 1997 version of the specification. + */ +#if 0 +enum +{ + kSCSICmd_CHANGE_DEFINITION = 0x40, /* SPC: Optional */ + kSCSICmd_COMPARE = 0x39, /* SPC: Optional */ + kSCSICmd_COPY = 0x18, /* SPC: Optional */ + kSCSICmd_COPY_AND_VERIFY = 0x3A, /* SPC: Optional*/ + kSCSICmd_INQUIRY = 0x12, /* SPC: Mandatory */ + kSCSICmd_LOCK_UNLOCK_CACHE = 0x36, /* Sec. 6.1.2: Optional */ + kSCSICmd_LOG_SELECT = 0x4C, /* SPC: Optional */ + kSCSICmd_LOG_SENSE = 0x4D, /* SPC: Optional */ + kSCSICmd_MEDIUM_SCAN = 0x38, /* Sec. 6.2.3: Optional */ + kSCSICmd_MODE_SELECT_6 = 0x15, /* SPC: Optional */ + kSCSICmd_MODE_SELECT_10 = 0x55, /* SPC: Optional */ + kSCSICmd_MODE_SENSE_6 = 0x1A, /* SPC: Optional */ + kSCSICmd_MODE_SENSE_10 = 0x5A, /* SPC: Optional */ + kSCSICmd_MOVE_MEDIUM = 0xA5, /* SMC: Optional */ + kSCSICmd_PERSISTENT_RESERVE_IN = 0x5E, /* SPC: Optional */ + kSCSICmd_PERSISTENT_RESERVE_OUT = 0x5F, /* SPC: Optional */ + kSCSICmd_PREFETCH = 0x34, /* Sec. 6.1.3: Optional */ + kSCSICmd_PREVENT_ALLOW_MEDIUM_REMOVAL = 0x1E, /* SPC: Optional */ + kSCSICmd_READ_6 = 0x08, /* Sec. 6.1.4: Optional */ + kSCSICmd_READ_10 = 0x28, /* Sec. 6.1.5: Mandatory */ + kSCSICmd_READ_12 = 0xA8, /* Sec. 6.2.4: Optional */ + kSCSICmd_READ_BUFFER = 0x3C, /* SPC: Optional */ + kSCSICmd_READ_CAPACITY = 0x25, /* Sec. 6.1.6: Mandatory */ + kSCSICmd_READ_ELEMENT_STATUS = 0xB8, /* SMC: Optional */ + kSCSICmd_READ_LONG = 0x3E, /* Sec. 6.1.8: Optional */ + kSCSICmd_REASSIGN_BLOCKS = 0x07, /* Sec. 6.1.9: Optional */ + kSCSICmd_RECEIVE_DIAGNOSTICS_RESULTS = 0x1C, /* SPC: Optional */ + kSCSICmd_RELEASE_6 = 0x17, /* SPC: Optional */ + kSCSICmd_RELEASE_10 = 0x57, /* SPC: Mandatory */ + kSCSICmd_REQUEST_SENSE = 0x03, /* SPC: Mandatory */ + kSCSICmd_RESERVE_6 = 0x16, /* SPC: Optional */ + kSCSICmd_RESERVE_10 = 0x56, /* SPC: Mandatory */ + kSCSICmd_REZERO_UNIT = 0x01, /* Obsolete */ + kSCSICmd_SEARCH_DATA_EQUAL_10 = 0x31, /* Obsolete */ + kSCSICmd_SEARCH_DATA_EQUAL_12 = 0xB1, /* Obsolete */ + kSCSICmd_SEARCH_DATA_HIGH_10 = 0x30, /* Obsolete */ + kSCSICmd_SEARCH_DATA_HIGH_12 = 0xB0, /* Obsolete */ + kSCSICmd_SEARCH_DATA_LOW_10 = 0x32, /* Obsolete */ + kSCSICmd_SEARCH_DATA_LOW_12 = 0xB2, /* Obsolete */ + kSCSICmd_SEEK_6 = 0x0B, /* Obsolete */ + kSCSICmd_SEEK_10 = 0x2B, /* Sec. 6.1.12: Optional */ + kSCSICmd_SEND_DIAGNOSTICS = 0x1D, /* SPC: Mandatory */ + kSCSICmd_SET_LIMITS_10 = 0x33, /* Sec. 6.1.13: Optional */ + kSCSICmd_SET_LIMITS_12 = 0xB3, /* Sec. 6.2.8: Optional */ + kSCSICmd_START_STOP_UNIT = 0x1B, /* Sec. 6.1.14: Optional */ + kSCSICmd_SYNCHRONIZE_CACHE = 0x35, /* Sec. 6.1.15: Optional */ + kSCSICmd_TEST_UNIT_READY = 0x00, /* SPC: Mandatory */ + kSCSICmd_VERIFY_10 = 0x2F, /* Sec. 6.2.10: Optional */ + kSCSICmd_VERIFY_12 = 0xAF, /* Sec. 6.2.11: Optional */ + kSCSICmd_WRITE_6 = 0x0A, /* Sec. 6.1.17: Optional */ + kSCSICmd_WRITE_10 = 0x2A, /* Sec. 6.2.10: Mandatory*/ + kSCSICmd_WRITE_12 = 0xAA, /* Sec. 6.2.13: Optional */ + kSCSICmd_WRITE_AND_VERIFY_10 = 0x2E, /* Sec. 6.2.14: Optional */ + kSCSICmd_WRITE_AND_VERIFY_12 = 0xAE, /* Sec. 6.2.15: Optional */ + kSCSICmd_WRITE_BUFFER = 0x3B, /* SPC: Optional */ + kSCSICmd_WRITE_LONG = 0x3F /* Sec. 6.1.20: Optional */ +}; +#endif + +#pragma mark - +#pragma mark 0x05 MMC CD-ROM Commands +/* Commands defined by the T10:1363-D SCSI Multimedia Commands-3 (MMC-3) + * specification. The definitions and section numbers are based on section 6.1 + * of the revision 01, March 03, 2000 version of the specification. + * + * NOTE: The comments following each command may not be accurate. These are + * not from the MMC-3 specification, but have been derived from the SCSI-2 and + * original MMC specifications. Unlike the other SCSI command specifications, + * MMC-2 and MMC-3 do not provide a command requirement type and therefore does + * not relist the SPC commands with these requirements as they apply to MMC + * devices. The MMC-2 and MMC-3 specifications also refer back to the SBC + * specification which seems invalid since MMC devices do not represent a + * Peripheral Device Type defined by SBC. It is assumed that the SBC + * references refer to the Peripheral Device Type 0x00 - Direct Access Commands + * definitions from that specification. + */ +#if 0 +enum +{ + kSCSICmd_BLANK = 0xA1, /* Sec. 6.1.1: */ + kSCSICmd_CHANGE_DEFINITION = 0x40, /* Obsolete */ + kSCSICmd_CLOSE_TRACK_SESSION = 0x5B, /* Sec. 6.1.2: */ + kSCSICmd_COMPARE = 0x39, /* SPC: Optional */ + kSCSICmd_COPY = 0x18, /* SPC: Optional */ + kSCSICmd_COPY_AND_VERIFY = 0x3A, /* SPC: Optional */ + kSCSICmd_ERASE = 0x2C, /* SBC: */ + kSCSICmd_FORMAT_UNIT = 0x04, /* Sec. 6.1.3: */ + kSCSICmd_GET_CONFIGURATION = 0x46, /* Sec. 6.1.4: */ + kSCSICmd_GET_EVENT_STATUS_NOTIFICATION = 0x4A, /* Sec. 6.1.5: */ + kSCSICmd_GET_PERFORMANCE = 0xAC, /* Sec. 6.1.6: */ + kSCSICmd_INQUIRY = 0x12, /* SPC: Mandatory */ + kSCSICmd_LOAD_UNLOAD_MEDIUM = 0xA6, /* Sec. 6.1.7: */ + kSCSICmd_LOG_SELECT = 0x4C, /* SPC: Optional */ + kSCSICmd_LOG_SENSE = 0x4D, /* SPC: Optional */ + kSCSICmd_MECHANISM_STATUS = 0xBD, /* Sec. 6.1.8: */ + kSCSICmd_MODE_SELECT_6 = 0x15, /* SPC: Mandatory */ + kSCSICmd_MODE_SELECT_10 = 0x55, /* SPC: Mandatory */ + kSCSICmd_MODE_SENSE_6 = 0x1A, /* SPC: Mandatory */ + kSCSICmd_MODE_SENSE_10 = 0x5A, /* SPC: Mandatory */ + kSCSICmd_PAUSE_RESUME = 0x4B, /* Sec. 6.1.9: */ + kSCSICmd_PLAY_AUDIO_10 = 0x45, /* Sec. 6.1.10: */ + kSCSICmd_PLAY_AUDIO_12 = 0xA5, /* Sec. 6.1.11: */ + kSCSICmd_PLAY_AUDIO_MSF = 0x47, /* Sec. 6.1.12: */ + kSCSICmd_PLAY_AUDIO_TRACK_INDEX = 0x48, /* Obsolete */ + kSCSICmd_PLAY_CD = 0xBC, /* Sec. 6.1.13: */ + kSCSICmd_PLAY_RELATIVE_10 = 0x49, /* Obsolete */ + kSCSICmd_PLAY_RELATIVE_12 = 0xA9, /* Obsolete */ + kSCSICmd_PREFETCH = 0x34, /* Optional */ + kSCSICmd_PREVENT_ALLOW_MEDIUM_REMOVAL = 0x1E, /* Optional */ + kSCSICmd_READ_6 = 0x08, /* Optional */ + kSCSICmd_READ_10 = 0x28, /* Mandatory */ + kSCSICmd_READ_12 = 0xA8, /* Optional */ + kSCSICmd_READ_BUFFER = 0x3C, /* Optional */ + kSCSICmd_READ_BUFFER_CAPACITY = 0x5C, /* Sec. 6.1.15: */ + kSCSICmd_READ_CD = 0xBE, /* Sec. 6.1.16: */ + kSCSICmd_READ_CD_MSF = 0xB9, /* Sec. 6.1.17: */ + kSCSICmd_READ_CAPACITY = 0x25, /* Sec. 6.1.18: */ + kSCSICmd_READ_DISC_INFORMATION = 0x51, /* Sec. 6.1.19: */ + kSCSICmd_READ_DVD_STRUCTURE = 0xAD, /* Sec. 6.1.20: */ + kSCSICmd_READ_DISC_STRUCTURE = 0xAD, /* Sec. 6.1.20: */ + kSCSICmd_READ_FORMAT_CAPACITIES = 0x23, /* Sec. 6.1.21: */ + kSCSICmd_READ_HEADER = 0x44, /* Sec. 6.1.22: */ + kSCSICmd_READ_LONG = 0x3E, /* Optional */ + kSCSICmd_READ_MASTER_CUE = 0x59, /* Sec. 6.1.23: */ + kSCSICmd_READ_SUB_CHANNEL = 0x42, /* Sec. 6.1.24: */ + kSCSICmd_READ_TOC_PMA_ATIP = 0x43, /* Sec. 6.1.25: */ + kSCSICmd_READ_TRACK_INFORMATION = 0x52, /* Sec. 6.1.27: */ + kSCSICmd_RECEIVE_DIAGNOSTICS_RESULTS = 0x1C, /* Optional */ + kSCSICmd_RELEASE_6 = 0x17, /* Mandatory */ + kSCSICmd_RELEASE_10 = 0x57, /* Optional */ + kSCSICmd_REPAIR_TRACK = 0x58, /* Sec. 6.1.28: */ + kSCSICmd_REPORT_KEY = 0xA4, /* Sec. 6.1.29: */ + kSCSICmd_REQUEST_SENSE = 0x03, /* Mandatory */ + kSCSICmd_RESERVE_6 = 0x16, /* Mandatory */ + kSCSICmd_RESERVE_10 = 0x56, /* Optional */ + kSCSICmd_RESERVE_TRACK = 0x53, /* Sec. 6.1.30: */ + kSCSICmd_SCAN_MMC = 0xBA, /* Sec. 6.1.31: */ + kSCSICmd_SEARCH_DATA_EQUAL_10 = 0x31, /* Obsolete */ + kSCSICmd_SEARCH_DATA_EQUAL_12 = 0xB1, /* Obsolete */ + kSCSICmd_SEARCH_DATA_HIGH_10 = 0x30, /* Obsolete */ + kSCSICmd_SEARCH_DATA_HIGH_12 = 0xB0, /* Obsolete */ + kSCSICmd_SEARCH_DATA_LOW_10 = 0x32, /* Obsolete */ + kSCSICmd_SEARCH_DATA_LOW_12 = 0xB2, /* Obsolete */ + kSCSICmd_SEEK_6 = 0x0B, /* Obsolete */ + kSCSICmd_SEEK_10 = 0x2B, /* SBC: */ + kSCSICmd_SEND_CUE_SHEET = 0x5D, /* Sec. 6.1.32: */ + kSCSICmd_SEND_DIAGNOSTICS = 0x1D, /* Mandatory */ + kSCSICmd_SEND_DVD_STRUCTURE = 0xBF, /* Sec. 6.1.33: */ + kSCSICmd_SEND_EVENT = 0xA2, /* Sec. 6.1.34: */ + kSCSICmd_SEND_KEY = 0xA3, /* Sec. 6.1.35: */ + kSCSICmd_SEND_OPC_INFORMATION = 0x54, /* Sec. 6.1.36: */ + kSCSICmd_SET_CD_SPEED = 0xBB, /* Sec. 6.1.37: */ + kSCSICmd_SET_LIMITS_10 = 0x33, /* Optional */ + kSCSICmd_SET_LIMITS_12 = 0xB3, /* Optional */ + kSCSICmd_SET_READ_AHEAD = 0xA7, /* Sec. 6.1.38: */ + kSCSICmd_SET_STREAMING = 0xB6, /* Sec. 6.1.39: */ + kSCSICmd_START_STOP_UNIT = 0x1B, /* Optional */ + kSCSICmd_STOP_PLAY_SCAN = 0x4E, /* Sec. 6.1.40: */ + kSCSICmd_SYNCHRONIZE_CACHE = 0x35, /* Sec. 6.1.41: */ + kSCSICmd_TEST_UNIT_READY = 0x00, /* Mandatory */ + kSCSICmd_VERIFY_10 = 0x2F, /* Optional */ + kSCSICmd_VERIFY_12 = 0xAF, /* Optional */ + kSCSICmd_WRITE_10 = 0x2A, /* Sec. 6.1.42: */ + kSCSICmd_WRITE_12 = 0xAA, /* Sec. 6.1.43: */ + kSCSICmd_WRITE_AND_VERIFY_10 = 0x2E, /* Sec. 6.1.44: */ + kSCSICmd_WRITE_BUFFER = 0x3B /* Optional */ +}; +#endif + +#pragma mark - +#pragma mark 0x06 SGC Scanner Commands +/* Commands defined by the T10:998-D SCSI-3 Graphics Commands (SGC) + * specification. The definitions and section numbers are based on section 6 + * of the revision 0, April 1995 version of the specification. + */ +#if 0 +enum +{ + kSCSICmd_CHANGE_DEFINITION = 0x40, /* SPC: Optional */ + kSCSICmd_COMPARE = 0x39, /* SPC: Optional */ + kSCSICmd_COPY = 0x18, /* SPC: Optional */ + kSCSICmd_COPY_AND_VERIFY = 0x3A, /* SPC: Optional */ + kSCSICmd_GET_DATA_BUFFER_STATUS = 0x34, /* Sec. 6.1.1: Optional */ + kSCSICmd_GET_WINDOW = 0x25, /* Sec. 6.1.2: Optional */ + kSCSICmd_INQUIRY = 0x12, /* SPC: Mandatory */ + kSCSICmd_LOG_SELECT = 0x4C, /* SPC: Optional */ + kSCSICmd_LOG_SENSE = 0x4D, /* SPC: Optional */ + kSCSICmd_MODE_SELECT_6 = 0x15, /* SPC: Optional */ + kSCSICmd_MODE_SELECT_10 = 0x55, /* SPC: Optional */ + kSCSICmd_MODE_SENSE_6 = 0x1A, /* SPC: Optional */ + kSCSICmd_MODE_SENSE_10 = 0x5A, /* SPC: Optional */ + kSCSICmd_OBJECT_POSITION = 0x31, /* Sec. 6.1.3: Optional */ + kSCSICmd_PORT_STATUS = 0x11, /* SPC (??): Mandatory + * for dual port devices */ + kSCSICmd_READ = 0x28, /* Sec. 6.1.4: Mandatory */ + kSCSICmd_READ_BUFFER = 0x3C, /* SPC: Optional */ + kSCSICmd_RECEIVE_DIAGNOSTICS_RESULTS = 0x1C, /* SPC: Optional */ + kSCSICmd_RELEASE_6 = 0x17, /* SPC: Mandatory */ + kSCSICmd_REQUEST_SENSE = 0x03, /* SPC: Mandatory */ + kSCSICmd_RESERVE_6 = 0x16, /* SPC: Mandatory */ + kSCSICmd_SCAN = 0x1B, /* Sec. 6.1.5: Optional */ + kSCSICmd_SEND = 0x1B, /* Sec. 6.1.6: Optional */ + kSCSICmd_SEND_DIAGNOSTICS = 0x1D, /* SPC: Mandatory */ + kSCSICmd_SET_WINDOW = 0x24, /* Sec. 6.1.7: Mandatory */ + kSCSICmd_TEST_UNIT_READY = 0x00, /* SPC: Mandatory */ + kSCSICmd_WRITE_BUFFER = 0x3B /* SPC: Optional */ +}; +#endif + +#pragma mark - +#pragma mark 0x07 SBC Optical Media Commands +/* Commands defined by the T10:990-D SCSI-3 Block Commands (SBC) + * (revision 8c, 13 November 1998) command specification. + */ + +#pragma mark - +#pragma mark 0x08 SMC Medium Changer Commands +/* Commands defined by the T10:1228-D SCSI-3 Medium Changer Commands-2 (SMC-2) + * (revision 0, March 16, 2000) command specification. + */ +#if 0 +enum +{ + /* Commands For Independent Medium Changers */ + kSCSICmd_EXCHANGE_MEDIUM = 0xA6, /* Optional */ + kSCSICmd_INITIALIZE_ELEMENT_STATUS = 0x07, /* Optional */ + kSCSICmd_MODE_SELECT_6 = 0x15, /* Optional */ + kSCSICmd_MODE_SELECT_10 = 0x55, /* Optional */ + kSCSICmd_MODE_SENSE_6 = 0x1A, /* Optional */ + kSCSICmd_MODE_SENSE_10 = 0x5A, /* Optional */ + kSCSICmd_MOVE_MEDIUM = 0xA5, /* Mandatory */ + kSCSICmd_PERSISTENT_RESERVE_IN = 0x5E, /* Optional */ + kSCSICmd_PERSISTENT_RESERVE_OUT = 0x5F, /* Optional */ + kSCSICmd_POSITION_TO_ELEMENT = 0x2B, /* Optional */ + kSCSICmd_READ_ELEMENT_STATUS = 0xB8, /* Mandatory */ + kSCSICmd_RELEASE_ELEMENT_6 = 0x16, /* Optional */ + kSCSICmd_RELEASE_ELEMENT_10 = 0x56, /* Optional */ + kSCSICmd_REQUEST_VOLUME_ELEMENT_ADDRESS = 0xB5, /* Optional */ + kSCSICmd_REQUEST_SENSE = 0x03, /* Mandatory */ + kSCSICmd_RESERVE_ELEMENT_6 = 0x16, /* Optional */ + kSCSICmd_RESERVE_ELEMENT_10 = 0x56 /* Optional */ +}; +#endif + +#pragma mark - +#pragma mark 0x09 SSC Communications Commands +/* Commands defined by the T10:997-D SCSI-3 Stream Commands (SSC) + * (revision 22, January 1, 2000) command specification. + */ + +#pragma mark - +#pragma mark 0x0A ASC IT8 Prepress Commands +#pragma mark 0x0B ASC IT8 Prepress Commands +/* Commands defined by the ASC IT8 specification + * (revision xx, month day, year) command specification. + */ +#if 0 +enum +{ +}; +#endif + +#pragma mark - +#pragma mark 0x0C SCC Array Controller Commands +/* Commands defined by the ANSI NCITS.318-199x SCSI Controller + * Commands (SCC-2) ratified command specification. + */ +#if 0 +enum +{ + kSCSICmd_MAINTENANCE_IN = 0xA3, /* Mandatory */ + kSCSICmd_MAINTENANCE_OUT = 0xA4, /* Optional */ + kSCSICmd_MODE_SELECT_6 = 0x15, /* Optional */ + kSCSICmd_MODE_SELECT_10 = 0x55, /* Optional */ + kSCSICmd_MODE_SENSE_6 = 0x1A, /* Optional */ + kSCSICmd_MODE_SENSE_10 = 0x5A, /* Optional */ + kSCSICmd_PERSISTENT_RESERVE_IN = 0x5E, /* Optional */ + kSCSICmd_PERSISTENT_RESERVE_OUT = 0x5F, /* Optional */ + kSCSICmd_PORT_STATUS = 0x1F, /* Optional */ + kSCSICmd_REDUNDANCY_GROUP_IN = 0xBA, /* Mandatory */ + kSCSICmd_REDUNDANCY_GROUP_OUT = 0xBB, /* Optional */ + kSCSICmd_RELEASE_6 = 0x17, /* Optional */ + kSCSICmd_RELEASE_10 = 0x57, /* Optional */ + kSCSICmd_REPORT_LUNS = 0xA0, /* Mandatory */ + kSCSICmd_REQUEST_SENSE = 0x03, /* Mandatory */ + kSCSICmd_RESERVE_6 = 0x16, /* Optional */ + kSCSICmd_RESERVE_10 = 0x56, /* Optional*/ + kSCSICmd_SEND_DIAGNOSTICS = 0x1D, /* Optional */ + kSCSICmd_SPARE_IN = 0xBC, /* Mandatory */ + kSCSICmd_SPARE_OUT = 0xBD /* Optional */ +}; +#endif + +#pragma mark - +#pragma mark 0x0D SES Enclosure Services Commands +/* Commands defined by the T10:1212-D SCSI-3 Enclosure Services (SES) + * (revision 8b, February 11, 1998) command specification. + */ +#if 0 +enum +{ + kSCSICmd_MODE_SELECT_6 = 0x15, /* Optional */ + kSCSICmd_MODE_SELECT_10 = 0x55, /* Optional */ + kSCSICmd_MODE_SENSE_6 = 0x1A, /* Optional */ + kSCSICmd_MODE_SENSE_10 = 0x5A, /* Optional */ + kSCSICmd_PERSISTENT_RESERVE_IN = 0x5E, /* Optional */ + kSCSICmd_PERSISTENT_RESERVE_OUT = 0x5F, /* Optional */ + kSCSICmd_RECEIVE_DIAGNOSTICS_RESULTS = 0x17, /* Mandatory */ + kSCSICmd_RELEASE_6 = 0x17, /* Optional */ + kSCSICmd_RELEASE_10 = 0x57, /* Optional */ + kSCSICmd_REQUEST_SENSE = 0x03, /* Mandatory */ + kSCSICmd_RESERVE_6 = 0x16, /* Optional */ + kSCSICmd_RESERVE_10 = 0x56, /* Optional */ + kSCSICmd_SEND_DIAGNOSTICS = 0x1D /* Mandatory */ +}; +#endif + +#pragma mark - +#pragma mark 0x0E RBC Reduced Block Commands +/* Commands defined by the T10:1240-D Reduced Block Commands (RBC) + * (revision 10a, August 18, 1999) command specification. + */ +#if 0 +enum +{ + kSCSICmd_FORMAT_UNIT = 0x04, /* Optional */ + kSCSICmd_READ_10 = 0x28, /* Mandatory */ + kSCSICmd_READ_CAPACITY = 0x25, /* Mandatory */ + kSCSICmd_START_STOP_UNIT = 0x1B, /* Mandatory */ + kSCSICmd_SYNCHRONIZE_CACHE = 0x35, /* Optional */ + kSCSICmd_VERIFY_10 = 0x2F, /* Mandatory */ + kSCSICmd_WRITE_10 = 0x2A, /* Mandatory */ + kSCSICmd_WRITE_BUFFER = 0x3B /* Mandatory for fixed media + * Optional for removable */ +}; +#endif + +#pragma mark - +#pragma mark 0x0F OCRW Optical Card Commands +/* Commands defined by the ISO/IEC 14776-381 SCSI Specification for + * Optical Card Reader/Writer (OCRW) ratified command specification. + */ +#if 0 +enum +{ +}; +#endif + +#pragma mark - +#pragma mark 0x11 OSD Object-based Storage Commands +/* Commands defined by the T10:1355-D Object-based Storage Commands (OSD) + * (revision 1, 18 May 2000) command specification. + */ +#if 0 +enum +{ +}; +#endif + +#pragma mark - +#pragma mark 0x15 RMC Simplified Multimedia Commands +/* Commands defined by the T10:1364-D Reduced Multimedia Commands (RMC) + * (revision 1, November 11, 1999) command specification. + */ +#if 0 +enum +{ +}; +#endif + +#endif /* _SCSI_COMMAND_OPERATION_CODES_H_ */ Index: branches/azimutz/Cleancut/i386/include/IOKit/scsi/SCSICmds_REPORT_LUNS_Definitions.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/scsi/SCSICmds_REPORT_LUNS_Definitions.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/scsi/SCSICmds_REPORT_LUNS_Definitions.h (revision 885) @@ -0,0 +1,146 @@ +/* + * Copyright (c) 2004-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_SCSI_CMDS_REPORT_LUNS_DEFINITIONS_H_ +#define _IOKIT_SCSI_CMDS_REPORT_LUNS_DEFINITIONS_H_ + + +#if KERNEL +#include <IOKit/IOTypes.h> +#else +#include <CoreFoundation/CoreFoundation.h> +#endif + + +/*! @header SCSI Request Sense Definitions + @discussion + This file contains all definitions for the data returned from + the REPORT_LUNS (0xA0) command. +*/ + + +/*! +@struct SCSICmd_REPORT_LUNS_LUN_ENTRY +@discussion +This structure represents a single LUN entry in a LUN list +returned via the REPORT_LUNS command. +*/ +typedef struct SCSICmd_REPORT_LUNS_LUN_ENTRY +{ + UInt16 FIRST_LEVEL_ADDRESSING; + UInt16 SECOND_LEVEL_ADDRESSING; + UInt16 THIRD_LEVEL_ADDRESSING; + UInt16 FOURTH_LEVEL_ADDRESSING; +} SCSICmd_REPORT_LUNS_LUN_ENTRY; + + +/*! +@constant kREPORT_LUNS_HeaderSize +@discussion +Size of the REPORT_LUNS header as defined in the SPC-3 specification. +*/ +#define kREPORT_LUNS_HeaderSize 8 + +/*! +@enum REPORT_LUNS addressing methods. +@discussion +REPORT_LUNS addressing methods described in +SAM-2 documents. +@constant kREPORT_LUNS_ADDRESS_METHOD_PERIPHERAL_DEVICE +Peripheral Device Addressing Method. +@constant kREPORT_LUNS_ADDRESS_DEVICE_TYPE_SPECIFIC +Device Type Specific Addressing Method. +@constant kREPORT_LUNS_ADDRESS_METHOD_LOGICAL_UNIT +Logical Unit Specific Addressing Method. +@constant kREPORT_LUNS_ADDRESS_METHOD_OFFSET +Offset to the address method data. +*/ +enum +{ + kREPORT_LUNS_ADDRESS_METHOD_PERIPHERAL_DEVICE = 0, + kREPORT_LUNS_ADDRESS_DEVICE_TYPE_SPECIFIC = 1, + kREPORT_LUNS_ADDRESS_METHOD_LOGICAL_UNIT = 2, + // Reserved [3] + kREPORT_LUNS_ADDRESS_METHOD_OFFSET = 14 +}; + + +/*! +@struct REPORT_LUNS_LOGICAL_UNIT_ADDRESSING +@discussion +This structure represents a LUN Addressing scheme. +*/ +typedef struct REPORT_LUNS_LOGICAL_UNIT_ADDRESSING +{ +#ifdef __LITTLE_ENDIAN__ + UInt16 LUN : 5; + UInt16 BUS_NUMBER : 3; + UInt16 TARGET : 6; + UInt16 reserved2 : 1; + UInt16 reserved : 1; +#else /* !__LITTLE_ENDIAN__ */ + UInt16 reserved : 1; + UInt16 reserved2 : 1; + UInt16 TARGET : 6; + UInt16 BUS_NUMBER : 3; + UInt16 LUN : 5; +#endif /* !__LITTLE_ENDIAN__ */ +} REPORT_LUNS_LOGICAL_UNIT_ADDRESSING; + + +/*! +@struct REPORT_LUNS_PERIPHERAL_DEVICE_ADDRESSING +@discussion +This structure represents a Peripheral Device Addressing scheme. +*/ +typedef struct REPORT_LUNS_PERIPHERAL_DEVICE_ADDRESSING +{ +#ifdef __LITTLE_ENDIAN__ + UInt16 TARGET_LUN : 8; + UInt16 BUS_IDENTIFIER : 6; + UInt16 reserved2 : 1; + UInt16 reserved : 1; +#else /* !__LITTLE_ENDIAN__ */ + UInt16 reserved : 1; + UInt16 reserved2 : 1; + UInt16 BUS_IDENTIFIER : 6; + UInt16 TARGET_LUN : 8; +#endif /* !__LITTLE_ENDIAN__ */ +} REPORT_LUNS_PERIPHERAL_DEVICE_ADDRESSING; + + +/*! +@struct SCSICmd_REPORT_LUNS_Header +@discussion +This structure defines the format of the data that is returned for +the REPORT_LUNS command. +*/ +typedef struct SCSICmd_REPORT_LUNS_Header +{ + UInt32 LUN_LIST_LENGTH; // LUN list length in bytes. + UInt32 RESERVED; + SCSICmd_REPORT_LUNS_LUN_ENTRY LUN[1]; // Variable length list. Must have at least LUN 0 if +} SCSICmd_REPORT_LUNS_Header; // Target supports REPORT_LUNS command. + + +#endif /* _IOKIT_SCSI_CMDS_REPORT_LUNS_DEFINITIONS_H_ */ Index: branches/azimutz/Cleancut/i386/include/IOKit/scsi/IOSCSIPrimaryCommandsDevice.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/scsi/IOSCSIPrimaryCommandsDevice.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/scsi/IOSCSIPrimaryCommandsDevice.h (revision 885) @@ -0,0 +1,805 @@ +/* + * 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_SCSI_PRIMARY_COMMANDS_DEVICE_H_ +#define _IOKIT_IO_SCSI_PRIMARY_COMMANDS_DEVICE_H_ + +#if defined(KERNEL) && defined(__cplusplus) + + +//----------------------------------------------------------------------------- +// Includes +//----------------------------------------------------------------------------- + +// General IOKit headers +#include <IOKit/IOLib.h> +#include <IOKit/IOService.h> +#include <IOKit/IOReturn.h> +#include <IOKit/IOMemoryDescriptor.h> +#include <IOKit/IOSyncer.h> + +// SCSI Architecture Model Family includes +#include <IOKit/scsi/SCSICommandDefinitions.h> +#include <IOKit/scsi/SCSICmds_INQUIRY_Definitions.h> +#include <IOKit/scsi/SCSICmds_REQUEST_SENSE_Defs.h> +#include <IOKit/scsi/IOSCSIProtocolInterface.h> + + +//----------------------------------------------------------------------------- +// Constants +//----------------------------------------------------------------------------- + +// Notification messages +enum +{ + kSCSIServicesNotification_Suspend = 0x69000080, + kSCSIServicesNotification_Resume = 0x69000090 +}; + + +// Timeout values +enum +{ + kOneSecondTimeoutInMS = 1000, + kTenSecondTimeoutInMS = 10 * kOneSecondTimeoutInMS, + kThirtySecondTimeoutInMS = 30 * kOneSecondTimeoutInMS, + kFortyFiveSecondTimeoutInMS = 45 * kOneSecondTimeoutInMS +}; + +// Mode page values for page control field +enum +{ + kModePageControlCurrentValues = 0x00, + kModePageControlChangeableValues = 0x01, + kModePageControlDefaultValues = 0x02, + kModePageControlSavedValues = 0x03 +}; + +// The command should be tried 5 times. The original attempt +// plus 4 retries. +#define kDefaultRetryCount 4 + +// Forward declarations for internal use only classes +class SCSIPrimaryCommands; + + +//----------------------------------------------------------------------------- +// Class Declaration +//----------------------------------------------------------------------------- + +class IOSCSIPrimaryCommandsDevice : public IOSCSIProtocolInterface +{ + + OSDeclareAbstractStructors ( IOSCSIPrimaryCommandsDevice ) + +private: + +#ifndef __LP64__ + SCSIPrimaryCommands * fSCSIPrimaryCommandObject; +#endif + + IOSCSIProtocolInterface * fProtocolDriver; + + // The fProtocolAccessEnabled member variable indicates whether + // requests coming from the client can be sent to the device. + // This will be set to true after the Protocol Service driver is successfully + // opened and before the call to InitializeDeviceSupport and set to false before + // TerminateDeviceSupport is called. + bool fProtocolAccessEnabled; + + // The fDeviceAccessEnabled member variable indicates whether + // requests coming from the client can be sent to the device. + // This will be set to true after InitializeDeviceSupport is called and + // set to false before StopDeviceSupport is called. + bool fDeviceAccessEnabled; + bool fDeviceAccessSuspended; + + static bool ServerKeyswitchCallback ( void * target, + void * refCon, + IOService * newService ); + + static void TaskCallback ( SCSITaskIdentifier completedTask ); + void TaskCompletion ( SCSITaskIdentifier completedTask ); + + static IOReturn sWaitForTask ( void * object, SCSITaskIdentifier request ); + IOReturn GatedWaitForTask ( SCSITaskIdentifier request ); + +protected: + + // Reserve space for future expansion. + struct IOSCSIPrimaryCommandsDeviceExpansionData + { + IONotifier * fKeySwitchNotifier; + UInt8 fANSIVersion; + UInt32 fReadTimeoutDuration; + UInt32 fWriteTimeoutDuration; + bool fCMDQUE; + SCSITaggedTaskIdentifier fTaskID; + IOSimpleLock * fTaskIDLock; + UInt32 fRetryCount; + }; + IOSCSIPrimaryCommandsDeviceExpansionData * fIOSCSIPrimaryCommandsDeviceReserved; + + #define fReadTimeoutDuration fIOSCSIPrimaryCommandsDeviceReserved->fReadTimeoutDuration + #define fWriteTimeoutDuration fIOSCSIPrimaryCommandsDeviceReserved->fWriteTimeoutDuration + #define fRetryCount fIOSCSIPrimaryCommandsDeviceReserved->fRetryCount + + + UInt8 fDefaultInquiryCount; + OSDictionary * fDeviceCharacteristicsDictionary; + UInt32 fNumCommandsOutstanding; + + virtual void free ( void ); + void SetANSIVersion ( UInt8 ); + void SetCMDQUE ( bool value ); + IOReturn GetModeSense ( + IOMemoryDescriptor * dataBuffer, + SCSICmdField6Bit PAGE_CODE, + SCSICmdField2Byte ALLOCATION_LENGTH, + bool * use10ByteModeSense ); + bool RetrieveINQUIRYData ( + UInt8 EVPD, + UInt8 inquiryPage, + UInt8 * inquiryBuffer, + UInt16 * dataSize ); + + // This flag is set if the device responds to a MODE_SENSE_10 command + // with the page code set to 0x1A (Power Conditions Mode Page) + bool fDeviceSupportsPowerConditions; + + // This method will retreive the SCSI Primary Command Set object for + // the class. For subclasses, this will be overridden using a + // dynamic cast on the base command set object of the subclass. + +#ifndef __LP64__ + + // ------ DEPRECATED API ---------- + // This should no longer be called by subclasses as the command builder + // objects will be removed in a later release. + virtual SCSIPrimaryCommands * GetSCSIPrimaryCommandObject ( void ); + + // This method is called by the start method to create all the command + // objects needed by the class. For subclasses, this will be overridden + // to create its needed command set objects. + virtual bool CreateCommandSetObjects ( void ); + + // This method is called by the free method to free all the command + // objects needed by the class. For subclasses, this will be overridden + // to free its needed command set objects. + virtual void FreeCommandSetObjects ( void ); + +#endif + + + // This method is called by the start method to obtain information from + // the device with regards to whether it supports the power conditions mode page. + virtual void CheckPowerConditionsModePage ( void ); + + // This will return back the Protocol driver that is used to + // send service requests to the device. + virtual IOSCSIProtocolInterface * GetProtocolDriver ( void ); + + // This will get a new SCSITask for the caller + virtual SCSITaskIdentifier GetSCSITask ( void ); + + // This will release a SCSITask (eventually return it to a pool) + virtual void ReleaseSCSITask ( SCSITaskIdentifier request ); + + // This will return a unique value for the tagged task identifier + SCSITaggedTaskIdentifier GetUniqueTagID ( void ); + + // Call for executing the command synchronously + SCSIServiceResponse SendCommand ( + SCSITaskIdentifier request, + UInt32 timeoutDuration ); + + // Call for executing the command asycnchronously + void SendCommand ( + SCSITaskIdentifier request, + UInt32 timeoutDuration, + SCSITaskCompletion taskCompletion ); + + + virtual bool InitializeDeviceSupport ( void ) = 0; + virtual void StartDeviceSupport ( void ) = 0; + virtual void SuspendDeviceSupport ( void ) = 0; + virtual void ResumeDeviceSupport ( void ) = 0; + virtual void StopDeviceSupport ( void ) = 0; + virtual void TerminateDeviceSupport ( void ) = 0; + virtual UInt32 GetNumberOfPowerStateTransitions ( void ) = 0; + + virtual IOReturn VerifyDeviceState ( void ); + // Called to clear any power-on/reset status in the drive + virtual bool ClearPowerOnReset ( void ); + virtual bool ClearNotReadyStatus ( void ) = 0; + + bool IsProtocolAccessEnabled ( void ); + bool IsDeviceAccessEnabled ( void ); + bool IsDeviceAccessSuspended ( void ); + + // Accessors for saving and retrieving data from an SCSITask object. + bool ResetForNewTask( + SCSITaskIdentifier request ); + bool SetTaskAttribute ( + SCSITaskIdentifier request, + SCSITaskAttribute newAttribute ); + SCSITaskAttribute GetTaskAttribute ( + SCSITaskIdentifier request ); + bool SetTaggedTaskIdentifier ( + SCSITaskIdentifier request, + SCSITaggedTaskIdentifier taggedTaskIdentifier ); + SCSITaggedTaskIdentifier GetTaggedTaskIdentifier ( + SCSITaskIdentifier request ); + bool SetTaskState ( + SCSITaskIdentifier request, + SCSITaskState newTaskState ); + SCSITaskState GetTaskState ( + SCSITaskIdentifier request ); + bool SetTaskStatus ( + SCSITaskIdentifier request, + SCSITaskStatus newStatus ); + SCSITaskStatus GetTaskStatus ( + SCSITaskIdentifier request ); + bool SetCommandDescriptorBlock ( + SCSITaskIdentifier request, + UInt8 cdbByte0, + UInt8 cdbByte1, + UInt8 cdbByte2, + UInt8 cdbByte3, + UInt8 cdbByte4, + UInt8 cdbByte5 ); + + // Populate the 10 Byte Command Descriptor Block + bool SetCommandDescriptorBlock ( + SCSITaskIdentifier request, + UInt8 cdbByte0, + UInt8 cdbByte1, + UInt8 cdbByte2, + UInt8 cdbByte3, + UInt8 cdbByte4, + UInt8 cdbByte5, + UInt8 cdbByte6, + UInt8 cdbByte7, + UInt8 cdbByte8, + UInt8 cdbByte9 ); + + // Populate the 12 Byte Command Descriptor Block + bool SetCommandDescriptorBlock ( + SCSITaskIdentifier request, + UInt8 cdbByte0, + UInt8 cdbByte1, + UInt8 cdbByte2, + UInt8 cdbByte3, + UInt8 cdbByte4, + UInt8 cdbByte5, + UInt8 cdbByte6, + UInt8 cdbByte7, + UInt8 cdbByte8, + UInt8 cdbByte9, + UInt8 cdbByte10, + UInt8 cdbByte11 ); + + // Populate the 16 Byte Command Descriptor Block + bool SetCommandDescriptorBlock ( + SCSITaskIdentifier request, + UInt8 cdbByte0, + UInt8 cdbByte1, + UInt8 cdbByte2, + UInt8 cdbByte3, + UInt8 cdbByte4, + UInt8 cdbByte5, + UInt8 cdbByte6, + UInt8 cdbByte7, + UInt8 cdbByte8, + UInt8 cdbByte9, + UInt8 cdbByte10, + UInt8 cdbByte11, + UInt8 cdbByte12, + UInt8 cdbByte13, + UInt8 cdbByte14, + UInt8 cdbByte15 ); + + bool SetDataTransferDirection ( + SCSITaskIdentifier request, + UInt8 newDirection ); + UInt8 GetDataTransferDirection ( + SCSITaskIdentifier request ); + bool SetRequestedDataTransferCount ( + SCSITaskIdentifier request, + UInt64 newRequestedCount ); + UInt64 GetRequestedDataTransferCount ( + SCSITaskIdentifier request ); + bool SetRealizedDataTransferCount ( + SCSITaskIdentifier request, + UInt64 newRealizedDataCount ); + UInt64 GetRealizedDataTransferCount ( + SCSITaskIdentifier request ); + bool SetDataBuffer ( + SCSITaskIdentifier request, + IOMemoryDescriptor * newBuffer ); + IOMemoryDescriptor * GetDataBuffer ( + SCSITaskIdentifier request ); + bool SetTimeoutDuration ( + SCSITaskIdentifier request, + UInt32 newTimeout ); + UInt32 GetTimeoutDuration ( + SCSITaskIdentifier request ); + bool SetTaskCompletionCallback ( + SCSITaskIdentifier request, + SCSITaskCompletion newCallback ); + void TaskCompletedNotification ( + SCSITaskIdentifier request ); + + bool SetServiceResponse ( + SCSITaskIdentifier request, + SCSIServiceResponse serviceResponse ); + SCSIServiceResponse GetServiceResponse ( + SCSITaskIdentifier request ); + bool SetAutosenseCommand ( + SCSITaskIdentifier request, + UInt8 cdbByte0, + UInt8 cdbByte1, + UInt8 cdbByte2, + UInt8 cdbByte3, + UInt8 cdbByte4, + UInt8 cdbByte5 ); + bool GetAutoSenseData ( + SCSITaskIdentifier request, + SCSI_Sense_Data * senseData ); // DEPRECATED, use below function instead + bool GetAutoSenseData ( + SCSITaskIdentifier request, + SCSI_Sense_Data * senseData, + UInt8 senseDataSize ); + UInt8 GetAutoSenseDataSize ( + SCSITaskIdentifier request ); + + bool SetApplicationLayerReference ( + SCSITaskIdentifier request, + void * newReferenceValue ); + void * GetApplicationLayerReference ( + SCSITaskIdentifier request ); + + void IncrementOutstandingCommandsCount ( void ); + static void sIncrementOutstandingCommandsCount ( + IOSCSIPrimaryCommandsDevice * self ); + virtual void HandleIncrementOutstandingCommandsCount ( void ); + + + // This static member routine provides a mechanism for retrieving a pointer to + // the object that is claimed as the owner of the specified SCSITask. + static OSObject * sGetOwnerForTask ( SCSITaskIdentifier request ); + +public: + + bool init ( OSDictionary * propTable ); + virtual bool start ( IOService * provider ); + virtual void stop ( IOService * provider ); + virtual IOReturn message ( UInt32 type, IOService * nub, void * arg ); + + // The setAgressiveness method is called by the power manager + // to notify us of certain power management settings. We override + // this method in order to catch the kPMMinutesToSpinDown message + // in order to set our idle timer. + virtual IOReturn setAggressiveness ( unsigned long type, unsigned long minutes ); + + // Methods for getting device information strings + virtual char * GetVendorString ( void ); + virtual char * GetProductString ( void ); + virtual char * GetRevisionString ( void ); + OSDictionary * GetProtocolCharacteristicsDictionary ( void ); + OSDictionary * GetDeviceCharacteristicsDictionary ( void ); + UInt8 GetANSIVersion ( void ); + bool GetCMDQUE ( void ); + OSString * MapINQUIRYDataToIconFile ( void ); + UInt32 GetRetryCount ( void ); + + // -- SCSI Protocol Interface Methods -- + // The ExecuteCommand method will take a SCSI Task and transport + // it across the physical wire(s) to the device + virtual void ExecuteCommand ( SCSITaskIdentifier request ); + + // The Task Management function to allow the SCSI Application Layer client to request + // that a specific task be aborted. + SCSIServiceResponse AbortTask ( UInt8 theLogicalUnit, SCSITaggedTaskIdentifier theTag ); + + // The Task Management function to allow the SCSI Application Layer client to request + // that a all tasks curerntly in the task set be aborted. + SCSIServiceResponse AbortTaskSet ( UInt8 theLogicalUnit ); + + SCSIServiceResponse ClearACA ( UInt8 theLogicalUnit ); + + SCSIServiceResponse ClearTaskSet ( UInt8 theLogicalUnit ); + + SCSIServiceResponse LogicalUnitReset ( UInt8 theLogicalUnit ); + + SCSIServiceResponse TargetReset ( void ); + + // The AbortCommand method will abort the indicated SCSI Task, + // if it is possible and the task has not already completed. + virtual SCSIServiceResponse AbortCommand ( SCSITaskIdentifier request ); + + // The IsProtocolServiceSupported will return true if the specified + // feature is supported by the protocol layer. If the service has a value that must be + // returned, it will be returned in the serviceValue output parameter. + virtual bool IsProtocolServiceSupported ( + SCSIProtocolFeature feature, + void * serviceValue ); + + // The HandleProtocolServiceFeature will return true if the specified feature could + // be handled properly by the protocol layer. + virtual bool HandleProtocolServiceFeature ( + SCSIProtocolFeature feature, + void * serviceValue ); + + // Utility methods for use by all peripheral device objects. + + // isParameterValid are used to validate that the parameter passed into + // the command methods are of the correct value. + + // Validate Parameter used for 1 bit to 1 byte paramaters + bool IsParameterValid ( + SCSICmdField1Byte param, + SCSICmdField1Byte mask ); + + // Validate Parameter used for 9 bit to 2 byte paramaters + bool IsParameterValid ( + SCSICmdField2Byte param, + SCSICmdField2Byte mask ); + + // Validate Parameter used for 17 bit to 4 byte paramaters + bool IsParameterValid ( + SCSICmdField4Byte param, + SCSICmdField4Byte mask ); + + // Validate Parameter used for 33 bit to 8 byte paramaters + bool IsParameterValid ( + SCSICmdField8Byte param, + SCSICmdField8Byte mask ); + + + bool IsMemoryDescriptorValid ( + IOMemoryDescriptor * dataBuffer ); + + bool IsMemoryDescriptorValid ( + IOMemoryDescriptor * dataBuffer, + UInt64 requiredSize ); + +#ifndef __LP64__ + + // SCSI Primary command implementations + virtual bool CHANGE_DEFINITION ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Bit SAVE, + SCSICmdField7Bit DEFINITION_PARAMETER, + SCSICmdField1Byte PARAMETER_DATA_LENGTH, + SCSICmdField1Byte CONTROL ); + + virtual bool COMPARE ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Bit PAD, + SCSICmdField3Byte PARAMETER_LIST_LENGTH, + SCSICmdField1Byte CONTROL ); + + virtual bool COPY ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Bit PAD, + SCSICmdField3Byte PARAMETER_LIST_LENGTH, + SCSICmdField1Byte CONTROL ); + + virtual bool COPY_AND_VERIFY ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Bit BYTCHK, + SCSICmdField1Bit PAD, + SCSICmdField3Byte PARAMETER_LIST_LENGTH, + SCSICmdField1Byte CONTROL ); + + virtual bool EXTENDED_COPY ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField4Byte PARAMETER_LIST_LENGTH, + SCSICmdField1Byte CONTROL ); + +#endif /* !__LP64__ */ + + virtual bool INQUIRY ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Bit CMDDT, + SCSICmdField1Bit EVPD, + SCSICmdField1Byte PAGE_OR_OPERATION_CODE, + SCSICmdField1Byte ALLOCATION_LENGTH, + SCSICmdField1Byte CONTROL ); + + virtual bool LOG_SELECT ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Bit PCR, + SCSICmdField1Bit SP, + SCSICmdField2Bit PC, + SCSICmdField2Byte PARAMETER_LIST_LENGTH, + SCSICmdField1Byte CONTROL ); + + virtual bool LOG_SENSE ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Bit PPC, + SCSICmdField1Bit SP, + SCSICmdField2Bit PC, + SCSICmdField6Bit PAGE_CODE, + SCSICmdField2Byte PARAMETER_POINTER, + SCSICmdField2Byte ALLOCATION_LENGTH, + SCSICmdField1Byte CONTROL ); + + virtual bool MODE_SELECT_6 ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Bit PF, + SCSICmdField1Bit SP, + SCSICmdField1Byte PARAMETER_LIST_LENGTH, + SCSICmdField1Byte CONTROL ); + + virtual bool MODE_SELECT_10 ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Bit PF, + SCSICmdField1Bit SP, + SCSICmdField2Byte PARAMETER_LIST_LENGTH, + SCSICmdField1Byte CONTROL ); + + virtual bool MODE_SENSE_6 ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Bit DBD, + SCSICmdField2Bit PC, + SCSICmdField6Bit PAGE_CODE, + SCSICmdField1Byte ALLOCATION_LENGTH, + SCSICmdField1Byte CONTROL ); + + virtual bool MODE_SENSE_10 ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Bit LLBAA, + SCSICmdField1Bit DBD, + SCSICmdField2Bit PC, + SCSICmdField6Bit PAGE_CODE, + SCSICmdField2Byte ALLOCATION_LENGTH, + SCSICmdField1Byte CONTROL ); + + virtual bool PERSISTENT_RESERVE_IN ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField5Bit SERVICE_ACTION, + SCSICmdField2Byte ALLOCATION_LENGTH, + SCSICmdField1Byte CONTROL ); + + virtual bool PERSISTENT_RESERVE_OUT ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField5Bit SERVICE_ACTION, + SCSICmdField4Bit SCOPE, + SCSICmdField4Bit TYPE, + SCSICmdField1Byte CONTROL ); + + virtual bool PREVENT_ALLOW_MEDIUM_REMOVAL ( + SCSITaskIdentifier request, + SCSICmdField2Bit PREVENT, + SCSICmdField1Byte CONTROL ); + + virtual bool READ_BUFFER ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField4Bit MODE, + SCSICmdField1Byte BUFFER_ID, + SCSICmdField3Byte BUFFER_OFFSET, + SCSICmdField3Byte ALLOCATION_LENGTH, + SCSICmdField1Byte CONTROL ); + + virtual bool RECEIVE ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField3Byte TRANSFER_LENGTH, + SCSICmdField1Byte CONTROL ); + + virtual bool RECEIVE_DIAGNOSTICS_RESULTS ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Bit PCV, + SCSICmdField1Byte PAGE_CODE, + SCSICmdField2Byte ALLOCATION_LENGTH, + SCSICmdField1Byte CONTROL ); + + virtual bool RELEASE_6 ( + SCSITaskIdentifier request, + SCSICmdField1Byte CONTROL ); + +#ifndef __LP64__ + + virtual bool RELEASE_6 ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Bit EXTENT, + SCSICmdField1Byte RESERVATION_IDENTIFICATION, + SCSICmdField1Byte CONTROL ); + +#endif /* !__LP64__ */ + + virtual bool RELEASE_10 ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Bit THRDPTY, + SCSICmdField1Bit LONGID, + SCSICmdField1Byte THIRD_PARTY_DEVICE_ID, + SCSICmdField2Byte PARAMETER_LIST_LENGTH, + SCSICmdField1Byte CONTROL ); + +#ifndef __LP64__ + + virtual bool RELEASE_10 ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Bit THRDPTY, + SCSICmdField1Bit LONGID, + SCSICmdField1Bit EXTENT, + SCSICmdField1Byte RESERVATION_IDENTIFICATION, + SCSICmdField1Byte THIRD_PARTY_DEVICE_ID, + SCSICmdField2Byte PARAMETER_LIST_LENGTH, + SCSICmdField1Byte CONTROL ); + +#endif /* !__LP64__ */ + + virtual bool REPORT_DEVICE_IDENTIFIER ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField4Byte ALLOCATION_LENGTH, + SCSICmdField1Byte CONTROL ); + + virtual bool REPORT_LUNS ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField4Byte ALLOCATION_LENGTH, + SCSICmdField1Byte CONTROL ); + + virtual bool REQUEST_SENSE ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Byte ALLOCATION_LENGTH, + SCSICmdField1Byte CONTROL ); + + virtual bool RESERVE_6 ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Byte CONTROL ); + +#ifndef __LP64__ + + virtual bool RESERVE_6 ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Bit EXTENT, + SCSICmdField1Byte RESERVATION_IDENTIFICATION, + SCSICmdField2Byte PARAMETER_LIST_LENGTH, + SCSICmdField1Byte CONTROL ); + +#endif /* !__LP64__ */ + + virtual bool RESERVE_10 ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Bit THRDPTY, + SCSICmdField1Bit LONGID, + SCSICmdField1Byte THIRD_PARTY_DEVICE_ID, + SCSICmdField2Byte PARAMETER_LIST_LENGTH, + SCSICmdField1Byte CONTROL ); + +#ifndef __LP64__ + + virtual bool RESERVE_10 ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Bit THRDPTY, + SCSICmdField1Bit LONGID, + SCSICmdField1Bit EXTENT, + SCSICmdField1Byte RESERVATION_IDENTIFICATION, + SCSICmdField1Byte THIRD_PARTY_DEVICE_ID, + SCSICmdField2Byte PARAMETER_LIST_LENGTH, + SCSICmdField1Byte CONTROL ); + +#endif /* !__LP64__ */ + + virtual bool SEND ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Bit AER, + SCSICmdField3Byte TRANSFER_LENGTH, + SCSICmdField1Byte CONTROL ); + + virtual bool SEND_DIAGNOSTICS ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField3Bit SELF_TEST_CODE, + SCSICmdField1Bit PF, + SCSICmdField1Bit SELF_TEST, + SCSICmdField1Bit DEVOFFL, + SCSICmdField1Bit UNITOFFL, + SCSICmdField2Byte PARAMETER_LIST_LENGTH, + SCSICmdField1Byte CONTROL ); + + virtual bool SET_DEVICE_IDENTIFIER ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField5Bit SERVICE_ACTION, + SCSICmdField4Byte PARAMETER_LIST_LENGTH, + SCSICmdField1Byte CONTROL ); + + virtual bool TEST_UNIT_READY ( + SCSITaskIdentifier request, + SCSICmdField1Byte CONTROL ); + + virtual bool WRITE_BUFFER ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField4Bit MODE, + SCSICmdField1Byte BUFFER_ID, + SCSICmdField3Byte BUFFER_OFFSET, + SCSICmdField3Byte PARAMETER_LIST_LENGTH, + SCSICmdField1Byte CONTROL ); + + // The SPC-3 INQUIRY command as defined in section 6.4.1 of SPC-3. + bool INQUIRY ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Bit EVPD, + SCSICmdField1Byte PAGE_CODE, + SCSICmdField2Byte ALLOCATION_LENGTH, + SCSICmdField1Byte CONTROL ); + +private: + + // Space reserved for future expansion. + OSMetaClassDeclareReservedUnused ( IOSCSIPrimaryCommandsDevice, 1 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPrimaryCommandsDevice, 2 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPrimaryCommandsDevice, 3 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPrimaryCommandsDevice, 4 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPrimaryCommandsDevice, 5 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPrimaryCommandsDevice, 6 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPrimaryCommandsDevice, 7 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPrimaryCommandsDevice, 8 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPrimaryCommandsDevice, 9 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPrimaryCommandsDevice, 10 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPrimaryCommandsDevice, 11 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPrimaryCommandsDevice, 12 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPrimaryCommandsDevice, 13 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPrimaryCommandsDevice, 14 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPrimaryCommandsDevice, 15 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPrimaryCommandsDevice, 16 ); + +}; + +#endif /* defined(KERNEL) && defined(__cplusplus) */ + +#endif /* _IOKIT_IO_SCSI_PRIMARY_COMMANDS_DEVICE_H_ */ Index: branches/azimutz/Cleancut/i386/include/IOKit/scsi/IOSCSIReducedBlockCommandsDevice.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/scsi/IOSCSIReducedBlockCommandsDevice.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/scsi/IOSCSIReducedBlockCommandsDevice.h (revision 885) @@ -0,0 +1,438 @@ +/* + * 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_SCSI_REDUCED_BLOCK_COMMANDS_DEVICE_H_ +#define _IOKIT_IO_SCSI_REDUCED_BLOCK_COMMANDS_DEVICE_H_ + +#if defined(KERNEL) && defined(__cplusplus) + + +//----------------------------------------------------------------------------- +// Includes +//----------------------------------------------------------------------------- + +// General IOKit headers +#include <IOKit/IOLib.h> +#include <IOKit/IOMemoryDescriptor.h> + +// Generic IOKit storage related headers +#include <IOKit/storage/IOStorage.h> + +// SCSI Architecture Model Family includes +#include <IOKit/scsi/IOSCSIPrimaryCommandsDevice.h> + + +//----------------------------------------------------------------------------- +// Constants +//----------------------------------------------------------------------------- + + +// RBC power states as defined in T10:1240D SCSI Reduced Block Commands (RBC) +// Revision 10a, August 18, 1999, page 13. +enum +{ + kRBCPowerStateSystemSleep = 0, + kRBCPowerStateSleep = 1, + kRBCPowerStateStandby = 2, + kRBCPowerStateIdle = 3, + kRBCPowerStateActive = 4, + kRBCNumPowerStates = 5 +}; + +enum +{ + kMediaStateUnlocked = 0, + kMediaStateLocked = 1 +}; + +#define kCapacityDataBufferSize 8 + +// Forward declaration for the SCSIReducedBlockCommands that is used internally by the +// IOSCSIReducedBlockCommandsDevice class. +class SCSIReducedBlockCommands; + +//----------------------------------------------------------------------------- +// Class Declaration +//----------------------------------------------------------------------------- + +class IOSCSIReducedBlockCommandsDevice : public IOSCSIPrimaryCommandsDevice +{ + + OSDeclareAbstractStructors ( IOSCSIReducedBlockCommandsDevice ); + +private: + +#ifndef __LP64__ + + SCSIReducedBlockCommands * fSCSIReducedBlockCommandObject; + SCSIReducedBlockCommands * GetSCSIReducedBlockCommandObject ( void ); + +#endif /* !__LP64__ */ + + static void AsyncReadWriteComplete ( SCSITaskIdentifier completedTask ); + +protected: + + // Reserve space for future expansion. + struct IOSCSIReducedBlockCommandsDeviceExpansionData + { + IONotifier * fPowerDownNotifier; + bool fMediumRemovalPrevented; + bool fKnownManualEject; + UInt32 fPollingMode; + bool fProtocolSpecificPowerControl; + }; + IOSCSIReducedBlockCommandsDeviceExpansionData * fIOSCSIReducedBlockCommandsDeviceReserved; + + #define fPowerDownNotifier fIOSCSIReducedBlockCommandsDeviceReserved->fPowerDownNotifier + #define fMediumRemovalPrevented fIOSCSIReducedBlockCommandsDeviceReserved->fMediumRemovalPrevented + #define fKnownManualEject fIOSCSIReducedBlockCommandsDeviceReserved->fKnownManualEject + #define fPollingMode fIOSCSIReducedBlockCommandsDeviceReserved->fPollingMode + #define fProtocolSpecificPowerControl fIOSCSIReducedBlockCommandsDeviceReserved->fProtocolSpecificPowerControl + + bool fMediaChanged; + bool fMediaPresent; + + // The byte count of each physical block on the media. + UInt32 fMediaBlockSize; + + // The total number of blocks of mediaBlockSize on the media. + UInt32 fMediaBlockCount; + + // Flags used to indicate device feature + bool fMediaIsRemovable; + bool fMediaIsWriteProtected; + + thread_call_t fPollingThread; + + enum + { + kPollingMode_Suspended = 0, + kPollingMode_NewMedia = 1, + kPollingMode_MediaRemoval = 2 + }; + + virtual void CreateStorageServiceNub ( void ); + virtual bool DetermineDeviceCharacteristics ( void ); + virtual void PollForMedia ( void ); + virtual void EnablePolling ( void ); + virtual void DisablePolling ( void ); + virtual void CheckWriteProtection ( void ); + virtual void SetMediaCharacteristics ( UInt32 blockSize, UInt32 blockCount ); + virtual void ResetMediaCharacteristics ( void ); + virtual bool ClearNotReadyStatus ( void ); + + virtual IOReturn IssueRead ( IOMemoryDescriptor * buffer, + UInt64 startBlock, + UInt64 blockCount ); + + virtual IOReturn IssueWrite ( IOMemoryDescriptor* buffer, + UInt64 startBlock, + UInt64 blockCount ); + + virtual IOReturn IssueRead ( IOMemoryDescriptor * buffer, + UInt64 startBlock, + UInt64 blockCount, + void * clientData ); + + virtual IOReturn IssueWrite ( IOMemoryDescriptor * buffer, + UInt64 startBlock, + UInt64 blockCount, + void * clientData ); + +#ifndef __LP64__ + + // This method will retreive the SCSI Primary Command Set object for + // the class. For subclasses, this will be overridden using a + // dynamic cast on the subclasses base command set object. + virtual SCSIPrimaryCommands * GetSCSIPrimaryCommandObject ( void ); + +#endif /* !__LP64__ */ + + // ----- Power Management Support ------ + + // We override this method to set our power states and register ourselves + // as a power policy maker. + virtual void InitializePowerManagement ( IOService * provider ); + + // We override this method so that when we register for power management, + // we go to our active power state (which the drive is definitely in + // at startup time). + virtual UInt32 GetInitialPowerState ( void ); + + // We override this method in order to provide the number of transitions + // from Fully active to Sleep state so that the idle timer can be adjusted + // to the appropriate time period based on the disk spindown time set in + // the Energy Saver prefs panel. + virtual UInt32 GetNumberOfPowerStateTransitions ( void ); + + // The TicklePowerManager method is called to tell the power manager that the + // device needs to be in a certain power state to handle requests. + virtual void TicklePowerManager ( void ); + + // The HandlePowerChange method is the state machine for power management. + // It is guaranteed to be on its own thread of execution (different from + // the power manager thread AND the workloop thread. This routine can + // send sync or async calls to the drive without worrying about threading + // issues. + virtual void HandlePowerChange ( void ); + + // The HandleCheckPowerState (void) method is on the serialized side of the command + // gate and can change member variables safely without multi-threading issues. + // It's main purpose is to call the superclass' HandleCheckPowerState ( UInt32 maxPowerState ) + // with the max power state the class registered with. + virtual void HandleCheckPowerState ( void ); + + // The CheckMediaPresence method is called to see if the media which we + // anticipated being there is still there. + virtual bool CheckMediaPresence ( void ); + + virtual bool InitializeDeviceSupport ( void ); + virtual void StartDeviceSupport ( void ); + virtual void SuspendDeviceSupport ( void ); + virtual void ResumeDeviceSupport ( void ); + virtual void StopDeviceSupport ( void ); + virtual void TerminateDeviceSupport ( void ); + + virtual void free ( void ); + +#ifndef __LP64__ + + virtual bool CreateCommandSetObjects ( void ); + virtual void FreeCommandSetObjects ( void ); + +#endif /* !__LP64__ */ + +public: + + virtual IOReturn SyncReadWrite ( IOMemoryDescriptor * buffer, + UInt64 startBlock, + UInt64 blockCount ); + + virtual IOReturn AsyncReadWrite ( IOMemoryDescriptor * buffer, + UInt64 block, + UInt64 nblks, + void * clientData ); + + + virtual IOReturn EjectTheMedia ( void ); + virtual IOReturn FormatMedia ( UInt64 byteCapacity ); + virtual UInt32 GetFormatCapacities ( UInt64 * capacities, + UInt32 capacitiesMaxCount ) const; + virtual IOReturn LockUnlockMedia ( bool doLock ); + virtual IOReturn SynchronizeCache ( void ); + virtual IOReturn ReportBlockSize ( UInt64 * blockSize ); + virtual IOReturn ReportEjectability ( bool * isEjectable ); + virtual IOReturn ReportLockability ( bool * isLockable ); + virtual IOReturn ReportPollRequirements ( bool * pollIsRequired, + bool * pollIsExpensive ); + virtual IOReturn ReportMaxReadTransfer ( UInt64 blockSize, + UInt64 * max ); + virtual IOReturn ReportMaxValidBlock ( UInt64 * maxBlock ); + virtual IOReturn ReportMaxWriteTransfer ( UInt64 blockSize, + UInt64 * max ); + virtual IOReturn ReportMediaState ( bool * mediaPresent, + bool * changed ); + virtual IOReturn ReportRemovability ( bool * isRemovable ); + virtual IOReturn ReportWriteProtection ( bool * isWriteProtected ); + + static void sPollForMedia ( void * pdtDriver, void * refCon ); + + +protected: + + + // The FORMAT_UNIT command as defined in section 5.1 + virtual bool FORMAT_UNIT ( + SCSITaskIdentifier request, + SCSICmdField1Bit IMMED, + SCSICmdField1Bit PROGRESS, + SCSICmdField1Bit PERCENT_TIME, + SCSICmdField1Bit INCREMENT ); + + // The INQUIRY command as defined in SPC-2 w/o CONTROL byte + virtual bool INQUIRY ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Bit CMDDT, + SCSICmdField1Bit EVPD, + SCSICmdField1Byte PAGE_OR_OPERATION_CODE, + SCSICmdField1Byte ALLOCATION_LENGTH ); + + // The MODE_SELECT(6) command as defined in SPC-2 w/o CONTROL byte + virtual bool MODE_SELECT_6 ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Bit PF, + SCSICmdField1Bit SP, + SCSICmdField1Byte PARAMETER_LIST_LENGTH ); + + // The MODE_SENSE(6) command as defined in SPC-2 w/o CONTROL byte + virtual bool MODE_SENSE_6 ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Bit DBD, + SCSICmdField2Bit PC, + SCSICmdField6Bit PAGE_CODE, + SCSICmdField1Byte ALLOCATION_LENGTH ); + + // The PERSISTENT_RESERVE_IN command as defined in SPC-2 w/o CONTROL byte + virtual bool PERSISTENT_RESERVE_IN ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField5Bit SERVICE_ACTION, + SCSICmdField2Byte ALLOCATION_LENGTH ); + + // The PERSISTENT_RESERVE_OUT command as defined in SPC-2 w/o CONTROL byte + virtual bool PERSISTENT_RESERVE_OUT ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField5Bit SERVICE_ACTION, + SCSICmdField4Bit SCOPE, + SCSICmdField4Bit TYPE ); + + // The PREVENT_ALLOW_MEDIUM_REMOVAL command as defined in SPC-2 w/o CONTROL byte + virtual bool PREVENT_ALLOW_MEDIUM_REMOVAL ( + SCSITaskIdentifier request, + SCSICmdField2Bit PREVENT ); + + // The READ_10 command as defined in section 5.2 + virtual bool READ_10 ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + UInt32 blockSize, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField2Byte TRANSFER_LENGTH ); + + // The READ_CAPACITY command as defined in section 5.3 + virtual bool READ_CAPACITY ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer ); + + // The RELEASE(6) command as defined in SPC-2 w/o CONTROL byte + virtual bool RELEASE_6 ( + SCSITaskIdentifier request ); + + // The REQUEST_SENSE command as defined in SPC-2 w/o CONTROL byte + virtual bool REQUEST_SENSE ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Byte ALLOCATION_LENGTH ); + + // The RESERVE(6) command as defined in SPC-2 w/o CONTROL byte + virtual bool RESERVE_6 ( + SCSITaskIdentifier request ); + + // The START_STOP_UNIT command as defined in section 5.4 + virtual bool START_STOP_UNIT ( + SCSITaskIdentifier request, + SCSICmdField1Bit IMMED, + SCSICmdField4Bit POWER_CONDITIONS, + SCSICmdField1Bit LEOJ, + SCSICmdField1Bit START ); + + // The SYNCRONIZE_CACHE command as defined in section 5.5 + virtual bool SYNCHRONIZE_CACHE ( + SCSITaskIdentifier request ); + + // The TEST_UNIT_READY command as defined in SPC-2 w/o CONTROL byte + virtual bool TEST_UNIT_READY ( + SCSITaskIdentifier request ); + + // The VERIFY command as defined in section 5.7 + virtual bool VERIFY ( + SCSITaskIdentifier request, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField2Byte VERIFICATION_LENGTH ); + + // The WRITE_10 command as defined in section 5.6 + virtual bool WRITE_10 ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + UInt32 blockSize, + SCSICmdField1Bit FUA, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField2Byte TRANSFER_LENGTH ); + + // The WRITE_BUFFER command as defined in SPC-2 w/o CONTROL byte + virtual bool WRITE_BUFFER ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField4Bit MODE, + SCSICmdField1Byte BUFFER_ID, + SCSICmdField3Byte BUFFER_OFFSET, + SCSICmdField3Byte PARAMETER_LIST_LENGTH ); + + + + /* Added with 10.2 */ + OSMetaClassDeclareReservedUsed ( IOSCSIReducedBlockCommandsDevice, 1 ); + +public: + + virtual IOReturn PowerDownHandler ( void * refCon, + UInt32 messageType, + IOService * provider, + void * messageArgument, + vm_size_t argSize ); + + + /* Added with 10.2 */ + OSMetaClassDeclareReservedUsed ( IOSCSIReducedBlockCommandsDevice, 2 ); + +protected: + + virtual void SetMediaIcon ( void ); + + + /* Added with 10.3.3 */ + OSMetaClassDeclareReservedUsed ( IOSCSIReducedBlockCommandsDevice, 3 ); + +protected: + + virtual void AsyncReadWriteCompletion ( SCSITaskIdentifier completedTask ); + + +private: + + // Space reserved for future expansion. + OSMetaClassDeclareReservedUnused ( IOSCSIReducedBlockCommandsDevice, 4 ); + OSMetaClassDeclareReservedUnused ( IOSCSIReducedBlockCommandsDevice, 5 ); + OSMetaClassDeclareReservedUnused ( IOSCSIReducedBlockCommandsDevice, 6 ); + OSMetaClassDeclareReservedUnused ( IOSCSIReducedBlockCommandsDevice, 7 ); + OSMetaClassDeclareReservedUnused ( IOSCSIReducedBlockCommandsDevice, 8 ); + OSMetaClassDeclareReservedUnused ( IOSCSIReducedBlockCommandsDevice, 9 ); + OSMetaClassDeclareReservedUnused ( IOSCSIReducedBlockCommandsDevice, 10 ); + OSMetaClassDeclareReservedUnused ( IOSCSIReducedBlockCommandsDevice, 11 ); + OSMetaClassDeclareReservedUnused ( IOSCSIReducedBlockCommandsDevice, 12 ); + OSMetaClassDeclareReservedUnused ( IOSCSIReducedBlockCommandsDevice, 13 ); + OSMetaClassDeclareReservedUnused ( IOSCSIReducedBlockCommandsDevice, 14 ); + OSMetaClassDeclareReservedUnused ( IOSCSIReducedBlockCommandsDevice, 15 ); + OSMetaClassDeclareReservedUnused ( IOSCSIReducedBlockCommandsDevice, 16 ); + +}; + +#endif /* defined(KERNEL) && defined(__cplusplus) */ + +#endif /* _IOKIT_IO_SCSI_REDUCED_BLOCK_COMMANDS_DEVICE_H_ */ Index: branches/azimutz/Cleancut/i386/include/IOKit/scsi/spi/IOSCSIParallelInterfaceController.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/scsi/spi/IOSCSIParallelInterfaceController.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/scsi/spi/IOSCSIParallelInterfaceController.h (revision 885) @@ -0,0 +1,1568 @@ +/* + * Copyright (c) 2002-2008 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_SCSI_PARALLEL_INTERFACE_CONTROLLER_H__ +#define __IOKIT_IO_SCSI_PARALLEL_INTERFACE_CONTROLLER_H__ + + + /*! + @header IOSCSIParallelInterfaceController + The IOSCSIParallelInterfaceController class and the associated HBA child + class is responsible for the management of all related hardware. This + includes the onboard HBA controller chip and the physical state of the + bus. These classes are not responsible for any of the management of + the SCSI Devices on the bus with the exception of maintaining the queue that + holds the objects representing those SCSI Devices. +*/ + + +//----------------------------------------------------------------------------- +// Includes +//----------------------------------------------------------------------------- + +// General IOKit includes +#include <IOKit/IOService.h> +#include <IOKit/IOWorkLoop.h> +#include <IOKit/IOCommandGate.h> +#include <IOKit/IODMACommand.h> +#include <IOKit/IOInterruptEventSource.h> +#include <IOKit/IOFilterInterruptEventSource.h> +#include <IOKit/IOTimerEventSource.h> +#include <IOKit/IOCommandPool.h> + +// IOKit SCSI ArchitectureModel Family includes +#include <IOKit/scsi/SCSITask.h> +#include <IOKit/scsi/SCSICmds_REQUEST_SENSE_Defs.h> +#include <IOKit/scsi/SCSIPort.h> + +//----------------------------------------------------------------------------- +// Constants +//----------------------------------------------------------------------------- + + +#define kIOPropertySCSIDeviceFeaturesKey "SCSI Device Features" +#define kIOPropertySCSI_I_T_NexusFeaturesKey "SCSI I_T Nexus Features" + +// This is the alignment mask used when allocating per-task HBA data. It allows +// the HBA to declare whether or not it supports 64-bit addressability and what the +// minimum byte alignment is for the data. E.g. By specifying 0x0000FFFFFFFFFFFEULL, +// the controller would be indicating that it supports 48-bits of addressability, but +// at a minimum of being 2-byte aligned. +#define kIOMinimumHBADataAlignmentMaskKey "HBA Data Alignment" + +// The Feature Selectors used to identify features of the SCSI Parallel +// Interface. These are used by the DoesHBASupportSCSIParallelFeature +// to report whether the HBA supports a given SCSI Parallel Interface +// feature and are used for requesting negotiation and reporting negotiation +// results between the controller and the device. + +// When the DoesHBASupportSCSIParallelFeature() member routine of the controller +// child class is called, it will return true if the HBA that it controls +// supports the specified SCSIParallelFeature or false if it does not. +typedef enum SCSIParallelFeature +{ + // The selector for support of Wide Data Transfers. Only Wide16 is supported + // as Wide32 has been obsoleted by the SPI-3 specification. + kSCSIParallelFeature_WideDataTransfer = 0, + + // The selector for support of Synchronous Data Transfers. + kSCSIParallelFeature_SynchronousDataTransfer = 1, + + // The selector for support of Quick Arbitration and Selection (QAS). + kSCSIParallelFeature_QuickArbitrationAndSelection = 2, + + // The selector for support of Double Transition (DT) data transfers. + kSCSIParallelFeature_DoubleTransitionDataTransfers = 3, + + // The selector for SPI Information Unit (IU) transfers. + kSCSIParallelFeature_InformationUnitTransfers = 4, + + // Since the Feature selectors are zero base, this will always have the + // correct total. + kSCSIParallelFeature_TotalFeatureCount +} SCSIParallelFeature; + + +typedef enum SCSIParallelFeatureRequest +{ + // This selector indicates that current negotiation + // should be used. + kSCSIParallelFeature_NoNegotiation = 0, + + // This selector indicates that the controller + // should attempt negotiation for the feature + kSCSIParallelFeature_AttemptNegotiation = 1, + + // This selector indicates that the controller + // should clear any negotiation for the feature + kSCSIParallelFeature_ClearNegotiation = 2 +}; + +typedef enum SCSIParallelFeatureResult +{ + kSCSIParallelFeature_NegotitiationUnchanged = 0, + kSCSIParallelFeature_NegotitiationCleared = 1, + kSCSIParallelFeature_NegotitiationSuccess = 2 +}; + + +// The SCSI Message Codes used for MESSAGE IN and MESSAGE OUT phases. +enum SCSIParallelMessages +{ + // Link Control Messages + kSCSIParallelMessage_TASK_COMPLETE = 0x00, + kSCSIParallelMessage_EXTENDED_MESSAGE = 0x01, + kSCSIParallelMessage_SAVE_DATA_POINTER = 0x02, + kSCSIParallelMessage_RESTORE_POINTERS = 0x03, + kSCSIParallelMessage_DISCONNECT = 0x04, + kSCSIParallelMessage_INITIATOR_DETECTED_ERROR = 0x05, + kSCSIParallelMessage_MESSAGE_REJECT = 0x07, + kSCSIParallelMessage_NO_OPERATION = 0x08, + kSCSIParallelMessage_MESSAGE_PARITY_ERROR = 0x09, + kSCSIParallelMessage_IGNORE_WIDE_RESIDUE = 0x23, + kSCSIParallelMessage_QAS_REQUEST = 0x55, + kSCSIParallelMessage_IDENTIFY = 0x80, + + // The Message Codes used in the EXTENDED_MESSAGE message. + kSCSIParallelMessage_MODIFY_DATA_POINTER = 0x00, + kSCSIParallelMessage_SYNCHONOUS_DATA_TRANSFER_REQUEST = 0x01, + // Reserved = 0x02 + kSCSIParallelMessage_WIDE_DATA_TRANSFER_REQUEST = 0x03, + kSCSIParallelMessage_PARALLEL_PROTOCOL_REQUEST = 0x04, + // Reserved = 0x05 through 0xFF + + // Task Attribute Message Codes + kSCSIParallelMessage_ACA = 0x24, + kSCSIParallelMessage_HEAD_OF_QUEUE = 0x21, + kSCSIParallelMessage_LINKED_COMMAND_COMPLETE = 0x0A, + kSCSIParallelMessage_ORDERED = 0x22, + kSCSIParallelMessage_SIMPLE = 0x20, + + // Task Management Message Codes + kSCSIParallelMessage_ABORT_TASK = 0x0D, + kSCSIParallelMessage_ABORT_TASK_SET = 0x06, + kSCSIParallelMessage_CLEAR_ACA = 0x16, + kSCSIParallelMessage_CLEAR_TASK_SET = 0x0E, + kSCSIParallelMessage_LOGICAL_UNIT_RESET = 0x17, + kSCSIParallelMessage_TARGET_RESET = 0x0C +}; + +enum +{ + kSCSIParallelTaskControllerIDQueueHead = 0 +}; + +// Notifications +enum +{ + kSCSIControllerNotificationBusReset = 0x68000000 +}; + +// Forward declaration for the internally used Parallel Device object. +class IOSCSIParallelInterfaceDevice; + +// This is the identifier that is used to specify a given parallel Task. +typedef OSObject * SCSIParallelTaskIdentifier; + + +//----------------------------------------------------------------------------- +// Class Declarations +//----------------------------------------------------------------------------- + +/*! @class IOSCSIParallelInterfaceController + @abstract Class that represents a SCSI Host Bus Adapter. + @discussion Class that represents a SCSI Host Bus Adapter. +*/ +class IOSCSIParallelInterfaceController : public IOService +{ + + OSDeclareAbstractStructors ( IOSCSIParallelInterfaceController ) + +#if 0 +#pragma mark - +#pragma mark Client API +#endif + + +public: + + /*! + @function GetSCSIParallelTask + @abstract Method to allow the client to get a SCSIParallelTask + @discussion Get a SCSIParallelTask from the controller so that a request + can be issued to the HBA driver. + @param blockForCommand If the blockForCommand parameter is set to false + and there are no free SCSIParallelTasks, this method will return NULL, + otherwise it will wait for one to become available before returning. + @result If there is a SCSI Parallel Task available, a reference to it + will be returned. + */ + + SCSIParallelTaskIdentifier GetSCSIParallelTask ( bool blockForCommand ); + + /*! + @function FreeSCSIParallelTask + @abstract Method to allow the client to release a SCSIParallelTask + @discussion The FreeSCSIParallelTask method is called by the client when + a SCSIParallelTask has been completed and the associated returnTask + needs to be returned to the pool. + @param returnTask is a reference to the SCSIParallelTaskIdentifier to be + returned. + */ + + void FreeSCSIParallelTask ( SCSIParallelTaskIdentifier returnTask ); + + /*! + @function FindTaskForAddress + @abstract Find a task for a given Task Address, if one exists. + @discussion If a valid Tagged Task Identifier is specified, this method + will return the task specified by the Tagged Task Address if one is + found, or else NULL will be returned. If zero is used as the Tagged + Task Identifier, then this routine will search for an outstanding task + based on the Untagged Task Address and return the task or else, if one + is not found, return NULL. + @param theT is the Target component of the I_T_L or I_T_L_Q nexus. + @param theL is the Logical Unit component of the I_T_L or I_T_L_Q nexus. + @param theQ is the Queue Tag component of the I_T_L_Q nexus. If this is + an I_T_L nexus, then the kSCSIUntaggedTaskIdentifier constant should be + used for theQ. + @result returns a valid SCSIParallelTaskIdentifier or NULL if none + found. + */ + + SCSIParallelTaskIdentifier FindTaskForAddress ( + SCSIDeviceIdentifier theT, + SCSILogicalUnitNumber theL, + SCSITaggedTaskIdentifier theQ ); + + + /*! + @function FindTaskForControllerIdentifier + @abstract Find a task for a given Target and Controller Task Identifier + @discussion Allows the controller child class to find an outstanding task + for a specified target and controller task identifier + @param theTarget is the Target that the task . + @param theIdentifier is the controller task identifier set using the SCSI + Parallel Task's SetControllerTaskIdentifier() method. + @result returns a valid SCSIParallelTaskIdentifier or NULL if none + found. + */ + + SCSIParallelTaskIdentifier FindTaskForControllerIdentifier ( + SCSIDeviceIdentifier theTarget, + UInt64 theIdentifier ); + + + /*! + @function ExecuteParallelTask + @abstract Submit a SCSIParallelTask for execution. + @discussion The ExecuteParallelTask call is made by the client to submit + a SCSIParallelTask for execution. + @param parallelRequest is a reference to the SCSIParallelTaskIdentifier + to be executed. + @result is an appropriate SCSIServiceResponse which are defined in the + file <IOKit/scsi/SCSITask.h>. + */ + + SCSIServiceResponse ExecuteParallelTask ( + SCSIParallelTaskIdentifier parallelRequest ); + + // --- Public API methods provided by HBA child classes ---- + + /*! + @function ReportHBAHighestLogicalUnitNumber + @abstract Gets the Highest Logical Unit Number. + @discussion This method is used to query the HBA child class to + determine what the highest Logical Unit Number that the controller can + address. + @result returns a valid 64-bit logical unit number. + */ + + virtual SCSILogicalUnitNumber ReportHBAHighestLogicalUnitNumber ( void ) = 0; + + /*! + @function DoesHBASupportSCSIParallelFeature + @abstract Queries the HBA child class to determine if it supports a + specific SPI feature. + @discussion Queries the HBA child class to determine if it supports the + specified feature as defined by the SCSI Parallel Interconnect + specifications. + @result Returns true if requested feature is supported. + */ + + virtual bool DoesHBASupportSCSIParallelFeature ( + SCSIParallelFeature theFeature ) = 0; + + /*! + @function InitializeTargetForID + @abstract Called to initialize a target device. + @discussion This method will be called to initialize a target device in + a single-threaded manner. The HBA can use this method to probe the + target or do anything else necessary before the device object is + registered with IOKit for matching. + @result Returns true if the target was successfully initialized. + */ + + virtual bool InitializeTargetForID ( + SCSITargetIdentifier targetID ) = 0; + + // The SCSI Task Management Functions as defined in the SCSI Architecture + // Model - 2 (SAM-2) specification. These are used by the client to request + // the specified function. The controller can complete these immmediately + // by returning the appropriate SCSIServiceResponse, or these can be completed + // asyncronously by the controller returning a SCSIServiceResponse of + // kSCSIServiceResponse_Request_In_Process and then calling the appropriate + // function complete member routine listed in the child class API section. + + virtual SCSIServiceResponse AbortTaskRequest ( + SCSITargetIdentifier theT, + SCSILogicalUnitNumber theL, + SCSITaggedTaskIdentifier theQ ) = 0; + + virtual SCSIServiceResponse AbortTaskSetRequest ( + SCSITargetIdentifier theT, + SCSILogicalUnitNumber theL ) = 0; + + virtual SCSIServiceResponse ClearACARequest ( + SCSITargetIdentifier theT, + SCSILogicalUnitNumber theL ) = 0; + + virtual SCSIServiceResponse ClearTaskSetRequest ( + SCSITargetIdentifier theT, + SCSILogicalUnitNumber theL ) = 0; + + virtual SCSIServiceResponse LogicalUnitResetRequest ( + SCSITargetIdentifier theT, + SCSILogicalUnitNumber theL ) = 0; + + virtual SCSIServiceResponse TargetResetRequest ( + SCSITargetIdentifier theT ) = 0; + + + + /*! + @function DoesHBAPerformAutoSense + @abstract Queries the HBA child class to determine if it automatically + performs AutoSense and provides AutoSense data for each I/O. If the HBA + allocates space for AutoSense in its HBA specific data region on a per + task basis, the HBA should respond true. + @discussion Queries the HBA child class to determine if it automatically + performs AutoSense and provides AutoSense data for each I/O. If the HBA + allocates space for AutoSense in its HBA specific data region on a per + task basis, the HBA should respond true. + @result Return true if HBA performs AutoSense into its own private data + buffer. + */ + + OSMetaClassDeclareReservedUsed ( IOSCSIParallelInterfaceController, 1 ); + + virtual bool DoesHBAPerformAutoSense ( void ); + + /*! + @function ReportHBAConstraints + @abstract Called to report the I/O constraints for this controller. + A list of valid keys includes: + kIOMaximumSegmentCountReadKey, (required) + kIOMaximumSegmentCountWriteKey, (required) + kIOMaximumSegmentByteCountReadKey, (required) + kIOMaximumSegmentByteCountWriteKey, (required) + kIOMinimumSegmentAlignmentByteCountKey, (required) + kIOMaximumSegmentAddressableBitCountKey, (required) + kIOMinimumHBADataAlignmentMaskKey (required). + NB: These keys and their values are described in this header and <IOKit/IOKitKeys.h> + @param constraints. An OSDictionary object used to aggregate the key/value pairs. + Subclasses must set the required keys if they override this method. If a subclass does + not provide the required keys, the system will panic. + */ + OSMetaClassDeclareReservedUsed ( IOSCSIParallelInterfaceController, 2 ); + + virtual void ReportHBAConstraints ( OSDictionary * constraints ); + + // Padding for the Client API + OSMetaClassDeclareReservedUnused ( IOSCSIParallelInterfaceController, 3 ); + OSMetaClassDeclareReservedUnused ( IOSCSIParallelInterfaceController, 4 ); + OSMetaClassDeclareReservedUnused ( IOSCSIParallelInterfaceController, 5 ); + OSMetaClassDeclareReservedUnused ( IOSCSIParallelInterfaceController, 6 ); + OSMetaClassDeclareReservedUnused ( IOSCSIParallelInterfaceController, 7 ); + OSMetaClassDeclareReservedUnused ( IOSCSIParallelInterfaceController, 8 ); + + +#if 0 +#pragma mark - +#pragma mark Child Class API +#endif + + +protected: + + // ---- Target Creation and Destruction methods --- + + /*! + @function CreateTargetForID + @abstract Method to perform device creation. + @discussion For HBA child classes that report true to the + DoesHBAPerformDeviceManagement() method, the child class will be + responsible for all device management by using these methods; + otherwise, the superclass will be responsible for all device management. + This method must be used to perform SCSI Parallel Device creation and + cannot be overridden. + @param targetID SCSIDeviceIdentifier of desired targetID. + @result returns true if successful. + */ + + bool CreateTargetForID ( SCSIDeviceIdentifier targetID ); + + /*! + @function CreateTargetForID + @abstract Method to perform device creation. + @discussion For HBA child classes that report true to the + DoesHBAPerformDeviceManagement() method, the child class will be + responsible for all device management by using these methods; + otherwise, the superclass will be responsible for all device management. + This method must be used to perform SCSI Parallel Device creation and + cannot be overridden. + @param targetID SCSIDeviceIdentifier of desired targetID. + @param properties A dictionary of properties to associate with the device + upon creation. The list of valid property keys is as follows: + kIOPropertySASAddressKey, + kIOPropertyFibreChannelNodeWorldWideNameKey, + kIOPropertyFibreChannelPortWorldWideNameKey, + kIOPropertyFibreChannelAddressIdentifierKey, and + kIOPropertyFibreChannelALPAKey. + These keys are defined in + <IOKit/storage/IOStorageProtocolCharacteristics.h> and the values + associated with these keys must be of the proper type/size, + or the target creation will not succeed. + @result returns true if successful. + */ + + bool CreateTargetForID ( SCSIDeviceIdentifier targetID, + OSDictionary * properties ); + + /*! + @function DestroyTargetForID + @abstract Method to perform device destruction. + @discussion For HBA child classes that report true to the + DoesHBAPerformDeviceManagement() method, the child class will be + responsible for all device management by using these methods; otherwise, + the superclass will be responsible for all device management. + This method must be used to perform SCSI Parallel Device destruction and + cannot be overridden. + @param targetID SCSIDeviceIdentifier of desired targetID. + */ + + void DestroyTargetForID ( SCSIDeviceIdentifier targetID ); + + /*! + @function GetTargetForID + @abstract Accessor for getting pointer to IOSCSIParallelInterfaceDevice. + @param targetID SCSIDeviceIdentifier of desired targetID. + @result returns pointer to IOSCSIParallelInterfaceDevice or NULL if not + found. + */ + + IOSCSIParallelInterfaceDevice * GetTargetForID ( + SCSIDeviceIdentifier targetID ); + + /*! + @function SetTargetProperty + @abstract Accessor for setting a property for a specific target. + @param device A pointer to a valid IOSCSIParallelInterfaceDevice. + @param key A pointer to a valid OSString object which represents the key. + A list of valid keys includes: + kIOPropertySASAddressKey, + kIOPropertyFibreChannelNodeWorldWideNameKey, + kIOPropertyFibreChannelPortWorldWideNameKey, + kIOPropertyFibreChannelAddressIdentifierKey, and + kIOPropertyFibreChannelALPAKey. + NB: These keys and their values are described in <IOKit/storage/IOStorageProtocolCharacteristics.h> + @param value Pointer to an OSObject (one of type OSData, OSString, etc.) + which represents the value for the property. The value must be of the proper type + and size for the specified key. + @result returns true if identifier was properly set, otherwise false. + */ + + bool SetTargetProperty ( SCSIDeviceIdentifier targetID, + const char * key, + OSObject * value ); + + /*! + @function RemoveTargetProperty + @abstract Accessor for removing a property from a specific target. + @param device A pointer to a valid IOSCSIParallelInterfaceDevice. + @param key A pointer to a valid OSString object which represents the key. + */ + + void RemoveTargetProperty ( SCSIDeviceIdentifier targetID, + const char * key ); + + // ---- Methods for HBA specifics. ---- + + /*! + @function SetHBAProperty + @abstract Accessor for setting a property for this object. + @param key A pointer to a valid OSString object which represents the key. + A list of valid keys includes: + kIOPropertyVendorNameKey, + kIOPropertyProductNameKey, + kIOPropertyProductRevisionLevelKey, + kIOPropertyPortDescriptionKey, + kIOPropertyPortSpeedKey, + kIOPropertyPortTopologyKey, + kIOPropertySCSIParallelSignalingTypeKey, + kIOPropertyFibreChannelCableDescriptionKey, + kIOPropertyFibreChannelNodeWorldWideNameKey, + kIOPropertyFibreChannelPortWorldWideNameKey, + kIOPropertyFibreChannelAddressIdentifierKey, and + kIOPropertyFibreChannelALPAKey. + NB: These keys and their values are described in <IOKit/storage/IOStorageDeviceCharacteristics.h> + and <IOKit/storage/IOStorageProtocolCharacteristics.h> + @param value Pointer to an OSObject (one of type OSData, OSString, etc.) + which represents the value for the property. The value must be of the proper type, + and/or size for the specified key. + @result returns true if identifier was properly set, otherwise false. + */ + + bool SetHBAProperty ( const char * key, + OSObject * value ); + + /*! + @function RemoveHBAProperty + @abstract Accessor for removing a property for this object. + @param key A pointer to a valid OSString object which represents the key. + See the SetHBAProperty() method for a list of valid keys. + */ + + void RemoveHBAProperty ( const char * key ); + + // These methods will not be called before the InitializeController() call, + // and will not be called after the TerminateController() call. But in the + // interval between those calls, they shall report the correct requested + // information. They are implemented as seperate pure virtual methods + // instead of a selector driven method because the HBA child class is + // required to report this information. + + /*! + @function ReportInitiatorIdentifier + @abstract Get the SCSI Device Identifier for the HBA. + @discussion This method will be called to determine the SCSI Device + Identifier that the Initiator has assigned for this HBA. + @result returns SCSIInitiatorIdentifier. + */ + + virtual SCSIInitiatorIdentifier ReportInitiatorIdentifier ( void ) = 0; + + /*! + @function ReportHighestSupportedDeviceID + @abstract Get the highest supported SCSI Device Identifier. + @discussion This method will be called to determine the value of the + highest SCSI Device Identifier supported by the HBA. This value will be + used to determine the last ID to process. + @result returns highest SCSIDeviceIdentifier + */ + + virtual SCSIDeviceIdentifier ReportHighestSupportedDeviceID ( void ) = 0; + + /*! + @function ReportMaximumTaskCount + @abstract Report Maximum Task Count + @discussion This method will be called to retrieve the maximum number of + outstanding tasks the HBA can process. This number must be greater than + zero or the controller driver will fail to match and load. + @result returns maximum (non-zero) task count. + */ + + virtual UInt32 ReportMaximumTaskCount ( void ) = 0; + + /*! + @function ReportHBASpecificTaskDataSize + @abstract Determine memory needed for HBA Task specific use. + @discussion This method is used to retrieve the amount of memory that + will be allocated in the SCSI Parallel Task for HBA specific use. + @result returns memory required in bytes + */ + + virtual UInt32 ReportHBASpecificTaskDataSize ( void ) = 0; + + /*! + @function ReportHBASpecificDeviceDataSize + @abstract Determine memory needed for HBA Device specific use. + @discussion This method is used to retrieve the amount of memory that + will be allocated in the SCSI Parallel Device for HBA specific use. + @result returns memory required in bytes + */ + + virtual UInt32 ReportHBASpecificDeviceDataSize ( void ) = 0; + + /*! + @function DoesHBAPerformDeviceManagement + @abstract Determine if HBA will manage devices. + @discussion This method is used to determine if the HBA will manage + target device creation and destruction. + @result return true means objects for target devices will only be + created when the child class calls the CreateTargetForID method. + */ + + virtual bool DoesHBAPerformDeviceManagement ( void ) = 0; + + // ---- Initialize and Terminate methods for the subclass to implement ----- + // The subclass shall not override the IOKit init and terminate methods, + // but shall instead rely on these methods for initialization and + // termination. + + // This is done to allow for this superclass to manage all IOKit specifics + // and to require only a Family specific API to be implemented by the + // subclass drivers. + + /*! + @function InitializeController + @abstract Called to initialize the controller + @discussion It is guaranteed that the InitializeController() will only be + called once per instantiation. The InitializeController() methods allows + the subclass driver to do all the necessary initialization required by + the hardware before it is able to accept requests to execute. All + necessary allocation of resources should be made during this method + call. This is the first method that will be called in the subclass. + @result return true means that initialization was successful. + */ + + virtual bool InitializeController ( void ) = 0; + + /*! + @function TerminateController + @abstract Called to terminate the controller + @discussion It is guaranteed that the TerminateController() will only be + called once and only after the InitializeController() method and only if + true was returned in response to the InitializeController() method. + The TerminateController() method allows the subclass to release all + resources that were acquired for operation of the hardware and shutdown + all hardware services. + This is the last method of the subclass that will be called before the + class is destroyed. + */ + + virtual void TerminateController ( void ) = 0; + + // ---- Start and Stop methods for the subclass ---- + + /*! + @function StartController + @abstract Called to start the controller + @discussion The StartController will always be called before any + requests are sent to the driver for execution. This method is called + after an initialize to start the services provided by the specific HBA + driver or called after a StopController call to restart those services. + After this call completes, all services provided by the HBA driver are + available to the client. + @result return true means that start was successful. + */ + + virtual bool StartController ( void ) = 0; + + /*! + @function StopController + @abstract Called to stop the controller + @discussion The StopController method will be called any time that the + system wants the card to stop accepting requests. ( See StartController + discussion ). The subclass should disable the hardware interrupt for + the particular controller (if possible) in this method. + */ + + virtual void StopController ( void ) = 0; + + // ---- Suspend and Resume Methods for the subclass ---- + + /*! + @function SuspendServices + @abstract Called to suspend controller services + @discussion Method will be called when the system wants to suspend the + services that are provided by the HBA driver. This call is not a reset + and the driver shall retain all state data between this so that if a + ResumeServices call is received, the driver can continue providing + services without a visible difference to the client. The driver may + receive multiple SuspendServices calls without receiving a + ResumeServices call and should ignore any after the first until a + ResumeServices call is received. + */ + + virtual void SuspendServices ( void ); + + /*! + @function ResumeServices + @abstract Called to resume controller services + @discussion Method that will be called to resume services + provided by the driver. ( See SuspendServices discussion ) + */ + + virtual void ResumeServices ( void ); + + /*! + @function HandleInterruptRequest + @abstract Handle Interrupt Request + @discussion The HandleInterruptRequest is used to notify an HBA + specific subclass that an interrupt request needs to be serviced. It is + called on the workloop (it holds the gate) at secondary interrupt level. + */ + + virtual void HandleInterruptRequest ( void ) = 0; + + /*! + @function EnableInterrupt + @abstract Enable Interrupt + @discussion Method that the HBA child class can call to enable + the associated IOInterruptEventSource. + */ + + void EnableInterrupt ( void ); + + /*! + @function DisableInterrupt + @abstract Disable Interrupt + @discussion Method that the HBA child class can call to disable + the associated IOInterruptEventSource. + */ + + void DisableInterrupt ( void ); + + /*! + @function SignalInterrupt + @abstract Signals that an interrupt has occurred. + @discussion Subclasses of IOSCSIParallelInterfaceController + should call this method in order to get the secondary interrupt + thread scheduled if and only if they will be returning false from + their overriden FilterInterruptRequest() method. See the + discussion for the FilterInterruptRequest() method for more + details. + + NOTE: This method should only be called from within the + FilterInterruptRequest() method and at no other time. + + Available in 10.3.3 or later. + + */ + + void SignalInterrupt ( void ); + + /*! + @function ProcessParallelTask + @abstract Called by client to process a parallel task. + @discussion This method is called to process a parallel task (i.e. put + the command on the bus). The HBA specific sublcass must implement this + method. + @param parallelRequest A valid SCSIParallelTaskIdentifier. + @result serviceResponse (see <IOKit/scsi/SCSITask.h>) + */ + + virtual SCSIServiceResponse ProcessParallelTask ( + SCSIParallelTaskIdentifier parallelRequest ) = 0; + + /*! + @function CompleteParallelTask + @abstract Parallel Task Completion + @discussion The HBA specific sublcass inherits the CompleteParallelTask() + method which shall be called when the HBA has completed the processing + of a parallel task. + @param parallelTask A valid SCSIParallelTaskIdentifier. + @param completionStatus The status of the SCSI bus. + @param serviceResponse (see <IOKit/scsi/SCSITask.h>) + */ + + void CompleteParallelTask ( + SCSIParallelTaskIdentifier parallelRequest, + SCSITaskStatus completionStatus, + SCSIServiceResponse serviceResponse ); + + + // Completion routines for the SCSI Task Management functions as described + // in the SCSI ArchitectureModel - 2 (SAM-2) specification. Each of these + // correspond to a client request for the specific Task Management functions. + // If the Controller Child Class completed the request by returning a + // SCSIServiceResponse of anything other than kSCSIServiceResponse_Request_In_Process, + // then the controller class does not need to call the completion member routine. + // If the controller did not complete the request immediately, then it will + // need to call the appropriate completion member routine listed here. + void CompleteAbortTask ( + SCSITargetIdentifier theT, + SCSILogicalUnitNumber theL, + SCSITaggedTaskIdentifier theQ, + SCSIServiceResponse serviceResponse ); + + void CompleteAbortTaskSet ( + SCSITargetIdentifier theT, + SCSILogicalUnitNumber theL, + SCSIServiceResponse serviceResponse ); + + void CompleteClearACA ( + SCSITargetIdentifier theT, + SCSILogicalUnitNumber theL, + SCSIServiceResponse serviceResponse ); + + void CompleteClearTaskSet ( + SCSITargetIdentifier theT, + SCSILogicalUnitNumber theL, + SCSIServiceResponse serviceResponse ); + + void CompleteLogicalUnitReset ( + SCSITargetIdentifier theT, + SCSILogicalUnitNumber theL, + SCSIServiceResponse serviceResponse ); + + void CompleteTargetReset ( + SCSITargetIdentifier theT, + SCSIServiceResponse serviceResponse ); + + /*! + @function NotifyClientsOfBusReset + @abstract Method called to notify clients that a bus reset has occurred. + @discussion This method is used by the HBA child class to inform the + parent class and any clients that a bus reset has occurred. + */ + + void NotifyClientsOfBusReset ( void ); + + /*! + @function NotifyClientsOfPortStatusChange + @abstract Method called to notify clients of port status change events. + @discussion This method is used by the HBA child class to inform the + parent class and any clients that a port has changed status. + */ + + void NotifyClientsOfPortStatusChange ( SCSIPortStatus newStatus ); + + /*! + @function GetSCSIDomainIdentifier + @abstract Accessor method to get the SCSI Domain Identifier. + @discussion Accessor method to get the SCSI Domain Identifier. + @result returns SCSI Domain Identifier. + */ + + SInt32 GetSCSIDomainIdentifier ( void ); + + /*! + @function GetProvider + @abstract Accessor method to get the IOService which is the controller's + provider. + @discussion Accessor method to get the IOService which is the + controller's provider. + @result returns pointer to IOService. + */ + + IOService * GetProvider ( void ); + + /*! + @function GetWorkLoop + @abstract Accessor method to get the IOWorkLoop associated with this + HBA. + @discussion Accessor method to get the IOWorkLoop associated with this + HBA. + @result returns pointer to IOWorkLoop. + */ + + IOWorkLoop * GetWorkLoop ( void ) const; + + /*! + @function GetCommandGate + @abstract Accessor to get an IOCommandGate associated with the workloop. + @discussion Accessor to get an IOCommandGate associated with the + workloop. + @result returns pointer to IOCommandGate. + */ + + IOCommandGate * GetCommandGate ( void ); + + // ---- SCSI Parallel Task Object Accessors ---- + + /*! + @function GetSCSITaskIdentifier + @abstract Method to retrieve a SCSITaskIdentifier from a valid + SCSIParallelTaskIdentifier. + @discussion Method to retrieve a SCSITaskIdentifier from a valid + SCSIParallelTaskIdentifier. + @param parallelTask A valid SCSIParallelTaskIdentifier. + @result returns SCSITaskIdentifier that represents the original request + from the SCSI Application Layer client. + */ + + SCSITaskIdentifier GetSCSITaskIdentifier ( + SCSIParallelTaskIdentifier parallelTask ); + + /*! + @function GetTargetIdentifier + @abstract Method to get the SCSITargetIdentifier associated with a + request. + @discussion Method to get the SCSITargetIdentifier associated with a + request. + @param parallelTask A valid SCSIParallelTaskIdentifier. + @result returns SCSITargetIdentifier + */ + + SCSITargetIdentifier GetTargetIdentifier ( + SCSIParallelTaskIdentifier parallelTask ); + + // ---- Methods for Accessing data in the client's SCSI Task Object ---- + // Method to retrieve the LUN that identifies the Logical Unit whose Task + // Set to which this task is to be added. + + /*! + @function GetLogicalUnitNumber + @abstract Method to get the logical unit number associated with a + request. + @discussion Method to get the logical unit number associated with a + request. + @param parallelTask A valid SCSIParallelTaskIdentifier. + @result returns a valid 64-bit logical unit number. + */ + + SCSILogicalUnitNumber GetLogicalUnitNumber ( + SCSIParallelTaskIdentifier parallelTask ); + + /*! + @function GetTaggedTaskIdentifier + @abstract Method to retrieve the SCSI Tagged Task Identifier of the + task. If the returned value is equal to kSCSIUntaggedTaskIdentifier, + then this task is untagged. + @param parallelTask A valid SCSIParallelTaskIdentifier. + @result an SCSITaskAttribute value. + */ + + SCSITaggedTaskIdentifier GetTaggedTaskIdentifier ( + SCSIParallelTaskIdentifier parallelTask ); + + /*! + @function GetTaskAttribute + @abstract Method to retrieve the SCSI Task Attribute of the task + @param parallelTask A valid SCSIParallelTaskIdentifier. + @result an SCSITaskAttribute value. + */ + + SCSITaskAttribute GetTaskAttribute ( + SCSIParallelTaskIdentifier parallelTask ); + + /*! + @function GetCommandDescriptorBlockSize + @abstract Method to retrieve the size of the SCSI Command Descriptor + Block (CDB). + @param parallelTask A valid SCSIParallelTaskIdentifier. + @result returns the size of the SCSI Command Descriptor Block in bytes. + */ + + UInt8 GetCommandDescriptorBlockSize ( + SCSIParallelTaskIdentifier parallelTask ); + + /*! + @function GetCommandDescriptorBlock + @abstract Method to retrieve the SCSI Command Descriptor Block (CDB). + @discussion This will always return a 16 Byte CDB. If the Protocol Layer + driver does not support 16 Byte CDBs, it will have to create a local + SCSICommandDescriptorBlock variable to get the CDB data and then + transfer the needed bytes from there. + @param parallelTask A valid SCSIParallelTaskIdentifier. + @param cdbData is a SCSICommandDescriptorBlock pointer to 16 byte CDB + @result returns true if data was copied to cdbData pointer + */ + + bool GetCommandDescriptorBlock ( + SCSIParallelTaskIdentifier parallelTask, + SCSICommandDescriptorBlock * cdbData ); + + /*! + @function GetDataTransferDirection + @abstract Retrieves the data transfer direction for any data associated + with the request. + @param parallelTask A valid SCSIParallelTaskIdentifier. + @result One of the valid data transfer directions described in + <IOKit/scsi/SCSITask.h> + */ + + UInt8 GetDataTransferDirection ( SCSIParallelTaskIdentifier parallelTask ); + + /*! + @function GetRequestedDataTransferCount + @abstract Retrieves the requested data transfer count for any data + associated with the request. + @param parallelTask A valid SCSIParallelTaskIdentifier. + @result The requested data transfer count in bytes. + */ + + UInt64 GetRequestedDataTransferCount ( + SCSIParallelTaskIdentifier parallelTask ); + + /*! + @function GetRealizedDataTransferCount + @abstract Retrieves the realized data transfer count for any data + associated with the request. + @param parallelTask A valid SCSIParallelTaskIdentifier. + @result The realized data transfer count in bytes. + */ + + UInt64 GetRealizedDataTransferCount ( + SCSIParallelTaskIdentifier parallelTask ); + + /*! + @function SetRealizedDataTransferCount + @abstract Sets the realized data transfer count in bytes. + @param parallelTask A valid SCSIParallelTaskIdentifier. + @param realizedTransferCountInBytes is the number of bytes actually + transferred. + @result true means the data transfer count was successfully set. + */ + + bool SetRealizedDataTransferCount ( + SCSIParallelTaskIdentifier parallelTask, + UInt64 realizedTransferCountInBytes ); + + /*! + @function IncrementRealizedDataTransferCount + @abstract Increments the realized data transfer count. This method is + helpful for when the HBA has to do multiple passes of DMA because there + are more scatter-gather elements than it can process in one pass. + @param parallelTask A valid SCSIParallelTaskIdentifier. + @param realizedTransferCountInBytes is the number of bytes to add to the + realized data count for the task. + */ + + void IncrementRealizedDataTransferCount ( + SCSIParallelTaskIdentifier parallelTask, + UInt64 realizedTransferCountInBytes ); + + /*! + @function GetDataBuffer + @abstract Method to retrieve client buffer from the request. + @param parallelTask A valid SCSIParallelTaskIdentifier. + @result returns pointer to an IOMemoryDescriptor which represents the + buffer. + */ + + IOMemoryDescriptor * GetDataBuffer ( + SCSIParallelTaskIdentifier parallelTask ); + + /*! + @function GetDataBufferOffset + @abstract Method to retrieve offset into client buffer at which to start + processing. + @param parallelTask A valid SCSIParallelTaskIdentifier. + @result returns offset in bytes + */ + + UInt64 GetDataBufferOffset ( SCSIParallelTaskIdentifier parallelTask ); + + /*! + @function GetDMACommand + @abstract Method to retrieve a pointer to an IODMACommand from the request. + @discussion For devices utilizing DMA, the IODMACommand object should be + obtained via GetDMACommand(). The subclass is responsible for calling prepare() + on the IODMACommand object using the proper offset obtained via GetDataBufferOffset() + and correct size obtained via GetRequestedDataTransferCount(). The subclass + is further responsible for calling complete() on the IODMACommand object once + all DMA operations have finished. + NB: Subclasses should not call IODMACommand::setMemoryDescriptor(). + @param parallelTask A valid SCSIParallelTaskIdentifier. + @result returns pointer to an IODMACommand which is used in conjunction + with the task. + */ + + IODMACommand * GetDMACommand ( + SCSIParallelTaskIdentifier parallelTask ); + + /*! + @function GetTimeoutDuration + @abstract Method to retrieve the timeout duration in milliseconds for a + request. + @discussion Method to retrieve the timeout duration in milliseconds for + a request. A value of zero represents an infinite timeout, or on + hardware where infinite timeouts are not possible, substitute the + longest timeout possible. + @param parallelTask A valid SCSIParallelTaskIdentifier. + @result returns timeout duration in milliseconds + */ + + UInt32 GetTimeoutDuration ( SCSIParallelTaskIdentifier parallelTask ); + + /*! + @function SetAutoSenseData + @abstract Method to set the auto sense data buffer associated with a + request. + @param parallelTask A valid SCSIParallelTaskIdentifier. + @param newSensedata pointer to auto sense data buffer + @result returns true if data in newSenseData was succesfully into the + task object + */ + + bool SetAutoSenseData ( + SCSIParallelTaskIdentifier parallelTask, + SCSI_Sense_Data * newSenseData, + UInt8 senseDataSize ); + + /*! + @function GetAutoSenseData + @abstract Method to retrieve auto sense data buffer associated with a + request. + @param parallelTask A valid SCSIParallelTaskIdentifier. + @param receivingBuffer pointer to auto sense data buffer + @result returns true if successfully copied data into receivingBuffer + */ + + bool GetAutoSenseData ( + SCSIParallelTaskIdentifier parallelTask, + SCSI_Sense_Data * receivingBuffer, + UInt8 senseDataSize ); + + /*! + @function GetAutoSenseDataSize + @abstract Method to retrieve auto sense data buffer size associated with a + request. + @param parallelTask A valid SCSIParallelTaskIdentifier. + @result returns Size of auto sense data buffer. + */ + + UInt8 GetAutoSenseDataSize ( + SCSIParallelTaskIdentifier parallelTask ); + + + /*! + @function GetSCSIParallelFeatureNegotiation + @abstract Method to retrieve the requested value for negotiation of the. + @discussion Query as to whether the SCSI Parallel Device object has + negotiated wide data transfers. + @param parallelTask A valid SCSIParallelTaskIdentifier. + @result A valid SCSIParallelFeatureControl. + */ + + SCSIParallelFeatureRequest GetSCSIParallelFeatureNegotiation ( + SCSIParallelTaskIdentifier parallelTask, + SCSIParallelFeature requestedFeature ); + + /*! + @function GetSCSIParallelFeatureNegotiationCount + @abstract Method to retrieve the number of requested negotiations. + @discussion Query as to the number of SCSI Parallel Features that are + requested to either be negotitated or cleared. These are all features + that are set to either kSCSIParallelFeature_AttemptNegotiation or + kSCSIParallelFeature_ClearNegotiation. If the return value is zero, + then all features are set to kSCSIParallelFeature_NoNegotiation + and all feature negotiations are to remain as they currently exist. + @param parallelTask A valid SCSIParallelTaskIdentifier. + @result an unsigned integer up to 64 bits in size. + */ + + UInt64 GetSCSIParallelFeatureNegotiationCount ( + SCSIParallelTaskIdentifier parallelTask); + + /*! + @function SetSCSIParallelFeatureNegotiationResult + @abstract Method to set the wide data transfer negotiation result. + @discussion Method to set the wide data transfer negotiation result. + @param parallelTask A valid SCSIParallelTaskIdentifier. + @param requestedFeature The SCSIParallelFeature that the has been set to + newResult. + @param newResult A valid SCSIParallelFeatureResult value. + */ + + void SetSCSIParallelFeatureNegotiationResult ( + SCSIParallelTaskIdentifier parallelTask, + SCSIParallelFeature requestedFeature, + SCSIParallelFeatureResult newResult ); + + /*! + @function GetSCSIParallelFeatureNegotiationResult + @abstract Method to retrieve the result of any wide transfer + negotiations. + @discussion Query as to whether the SCSI Parallel Controller object has + negotiated wide data transfers. + @param parallelTask A valid SCSIParallelTaskIdentifier. + @result A valid SCSIParallelFeatureResult. + */ + + SCSIParallelFeatureResult GetSCSIParallelFeatureNegotiationResult ( + SCSIParallelTaskIdentifier parallelTask, + SCSIParallelFeature requestedFeature ); + + /*! + @function GetSCSIParallelFeatureNegotiationResultCount + @abstract Method to retrieve the number of changed negotiations. + @discussion Query as to the number of SCSI Parallel Features that have + been changed to either negotitated or cleared. These are all features + that are set to either kSCSIParallelFeature_NegotitiationCleared or + kSCSIParallelFeature_NegotitiationSuccess. If the return value is zero, + then all features are set to kSCSIParallelFeature_NegotitiationUnchanged. + @param parallelTask A valid SCSIParallelTaskIdentifier. + @result an unsigned integer up to 64 bits in size. + */ + + UInt64 GetSCSIParallelFeatureNegotiationResultCount ( + SCSIParallelTaskIdentifier parallelTask); + + // Controller Task Identifier related member routines + + /*! + @function SetControllerTaskIdentifier + @abstract Method to set the Controller Task Identifier. + @discussion This method allows the Controller Child Class + driver to set a unique identifier to associate with the specified + SCSI Parallel Task. This identifier is designed to be used by + controllers that do not have access to the LUN and Tag information + when notified by the HBA that a request has completed. + If the kSCSIParallelTaskControllerIDQueueHead is used, this + member routine will return the first Task on the queue. + @param parallelTask A valid SCSIParallelTaskIdentifier. + @param newIdentifier unsigned 64 bit integer token. + @result none + */ + + void SetControllerTaskIdentifier ( + SCSIParallelTaskIdentifier parallelTask, + UInt64 newIdentifier ); + + UInt64 GetControllerTaskIdentifier ( + SCSIParallelTaskIdentifier parallelTask); + + + // The HBA Data related fields + + /*! + @function GetHBADataSize + @abstract Method to retrieve the HBA Data Size in bytes. + @discussion Method to retrieve the HBA Data Size in bytes. + @param parallelTask A valid SCSIParallelTaskIdentifier. + @result returns HBA Data size in bytes. + */ + + UInt32 GetHBADataSize ( SCSIParallelTaskIdentifier parallelTask ); + + /*! + @function GetHBADataPointer + @abstract Method to retrieve the HBA Data pointer. + @discussion Method to retrieve the HBA Data pointer. + @param parallelTask A valid SCSIParallelTaskIdentifier. + @result returns pointer to buffer for HBA specific data, NULL if + none found or GetHBADataSize() returns zero. + */ + + void * GetHBADataPointer ( SCSIParallelTaskIdentifier parallelTask ); + + /*! + @function GetHBADataDescriptor + @abstract Method to retrieve the IOMemoryDescriptor associated with + the HBA Data. + @discussion Method to retrieve the IOMemoryDescriptor associated with + the HBA Data. + @param parallelTask A valid SCSIParallelTaskIdentifier. + @result returns pointer to an IOMemoryDescriptor that wraps the HBA + specific data buffer, NULL if none found or GetHBADataSize() returns zero. + */ + + IOMemoryDescriptor * GetHBADataDescriptor ( + SCSIParallelTaskIdentifier parallelTask ); + + // ---- SCSI Parallel Device Object Accessors ---- + + // The HBA Data related fields + + /*! + @function GetHBATargetDataSize + @abstract Method to retrieve the HBA Data Size in bytes. + @discussion Method to retrieve the HBA Data Size in bytes. + @param targetDevice A valid SCSITargetIdentifier. + @result returns HBA Data size in bytes. + */ + + UInt32 GetHBATargetDataSize ( SCSITargetIdentifier targetID ); + + /*! + @function GetHBATargetDataPointer + @abstract Method to retrieve the HBA Data pointer. + @discussion Method to retrieve the HBA Data pointer. + @param targetDevice A valid SCSITargetIdentifier. + @result returns pointer to buffer for HBA specific data, NULL if + none found or GetHBADataSize is zero. + */ + + void * GetHBATargetDataPointer ( SCSITargetIdentifier targetID ); + + +#if 0 +#pragma mark - +#pragma mark Additional Child Class APIs +#endif + + + // ---- Timeout Related Methods ---- + + /*! + @function SetTimeoutForTask + @abstract Method to set the timeout duration in milliseconds for a + request. + @discussion Method to set the timeout duration in milliseconds for a + request. + @param parallelTask A valid SCSIParallelTaskIdentifier. + @param timeoutOverride A timeout value in milliseconds in case the + HBA driver wishes to override the default value provided in the + parallelTask. + */ + + void SetTimeoutForTask ( SCSIParallelTaskIdentifier parallelTask, + UInt32 timeoutOverride = 0 ); + + /*! + @function HandleTimeout + @abstract Method to handle command timeouts. + @discussion Method to handle command timeouts. This should + be overridden by the child class in order to clean up HBA + specific structures after a timeout has occurred. This method + is called on the workloop (it holds the gate). + @param parallelRequest A valid SCSIParallelTaskIdentifier. + */ + + OSMetaClassDeclareReservedUsed ( IOSCSIParallelInterfaceController, 9 ); + + virtual void HandleTimeout ( + SCSIParallelTaskIdentifier parallelRequest ); + + + // ---- Filter Interrupt ---- + + /*! + @function FilterInterruptRequest + @abstract Filter method called at primary interrupt time. + @discussion Filter method called at primary interrupt time. + This should only be overridden by the child class in order + to determine if an interrupt occurred for this controller instance. + Since all work occurs at primary interrupt time, this routine + should be quick and efficient and defer as much processing as + possible to the HandleInterruptRequest() method. + + NOTE: Unlike the HandleInterruptRequest() and HandleTimeout() + methods, FilterInterruptRequest() is NOT called with the + workloop lock held. + + If the value returned by FilterInterruptRequest() is true, the + secondary interrupt thread will be scheduled and the hardware + interrupt line will be disabled. If the controller instance shares + that interrupt line with other devices, it can cause large + interrupt latencies. If the controller instance can disable the + interrupt in the chip itself, the following can be done to reduce + interrupt latencies: + + - Interrupt occurs + - FilterInterruptRequest() method is called. + - If the interrupt is not for this controller, return false + immediately. + - If the interrupt is for this controller, and the controller + can disable interrupts for this chip, the controller should + disable the interrupts for this chip, call SignalInterrupt(), + and return false. This causes the secondary interrupt thread + to get scheduled, yet does not disable the interrupt line for + all devices tied to that interrupt. This effectively allows + other devices to process their interrrupts, thus reducing + interrupt latency for those devices. + - HandleInterruptRequest() method is called. + - Controller processes interrupt and completes I/O requests. + - Controller re-enables interrupts for the device. + + NOTE: If you use this approach, the interrupting condition MUST be + cleared from the hardware, otherwise an infinite process interrupt + loop will occur. + + If the controller cannot disable interrupts on the chip, it should + simply return true if an interrupt has occurred for its device. + + @result True if the hardware interrupt line should be disabled, + otherwise false. + */ + + OSMetaClassDeclareReservedUsed ( IOSCSIParallelInterfaceController, 10 ); + + virtual bool FilterInterruptRequest ( void ); + + /*! + @function InitializeDMASpecification + @abstract Called to initialize an IODMACommand with a DMA specification. + @param command A pointer to a valid IODMACommand object. Subclasses + should override this method and call IODMACommand::initWithSpecification() + supplying the proper arguments to that method based on the DMA strategy. + @result boolean value indicating success or failure. + */ + OSMetaClassDeclareReservedUsed ( IOSCSIParallelInterfaceController, 11 ); + + virtual bool InitializeDMASpecification ( IODMACommand * command ); + + /*! + @function CreateDeviceInterrupt + @abstract Called to create an IOInterruptEventSource for the device. Subclasses + may wish to use a different interrupt index than 0 (e.g. for using PCI Message + Signaled Interrupts) or might not need an interrupt at all (virtual HBA). + @param action A pointer to the action routine that should be passed to either + IOInterruptEventSource::interruptEventSource() or + IOFilterInterruptEventSource::filterInterruptEventSource as the method to call + when an interrupt occurs for the device (sometimes called the "deferred procedure call" + or the "secondary context method". By passing this routine along, it will + properly wire up the HandleInterruptRequest() method you should override to handle + interrupts. + @param filter A pointer to the filter routine that should be passed to + IOFilterInterruptEventSource::filterInterruptEventSource as the method to call + at primary interrupt time when an interrupt occurs for the device. + By passing this routine along, it will properly wire up the + FilterInterruptRequest() method you may override to handle primary interrupts. + @result IOInterruptEventSource. May return NULL if and only if there is no + hardware interrupt associated with this device. + */ + OSMetaClassDeclareReservedUsed ( IOSCSIParallelInterfaceController, 12 ); + + virtual IOInterruptEventSource * CreateDeviceInterrupt ( + IOInterruptEventSource::Action action, + IOFilterInterruptEventSource::Filter filter, + IOService * provider ); + + // Padding for the Child Class API + OSMetaClassDeclareReservedUnused ( IOSCSIParallelInterfaceController, 13 ); + OSMetaClassDeclareReservedUnused ( IOSCSIParallelInterfaceController, 14 ); + OSMetaClassDeclareReservedUnused ( IOSCSIParallelInterfaceController, 15 ); + OSMetaClassDeclareReservedUnused ( IOSCSIParallelInterfaceController, 16 ); + + +#if 0 +#pragma mark - +#pragma mark Internal Use Only +#endif + +private: + + // binary compatibility instance variable expansion + struct ExpansionData { }; + ExpansionData * fIOSCSIParallelInterfaceControllerExpansionData; + + IOService * fProvider; + OSSet * fClients; + + static SInt32 fSCSIParallelDomainCount; + SInt32 fSCSIDomainIdentifier; + + // The HBA attributes + SCSIInitiatorIdentifier fInitiatorIdentifier; + + // The maximum SCSI Device Identifier support by the HBA + // This is retreived from the child class via the + SCSIDeviceIdentifier fHighestSupportedDeviceID; + + // The total number of tasks that the HBA can proccess at a time. + // This is retrieved from the child class via ReportMaximumTaskCount + UInt32 fSupportedTaskCount; + + // The Number of requests that are currently outstanding for the current + // instantiation. + UInt16 fOutstandingRequests; + + // The member variable to indicate if the current instantiation has been + // succesfully intialized. + bool fHBAHasBeenInitialized; + + // The member variable to indicate if the current instantiation is running. + // A true means that the last or only Start call made was successful. A + // false value means that either a successful Start has not been made or a + // Stop call has been made. + bool fHBACanAcceptClientRequests; + + // The pool for the available SCSI Parallel Task objects + IOCommandPool * fParallelTaskPool; + + // WorkLoop variables + IOWorkLoop * fWorkLoop; + IOTimerEventSource * fTimerEvent; + IOInterruptEventSource * fDispatchEvent; + + IOCommandGate * fControllerGate; + + bool AllocateSCSIParallelTasks ( void ); + void DeallocateSCSIParallelTasks ( void ); + + IOWorkLoop * getWorkLoop ( void ) const; + bool CreateWorkLoop ( IOService * provider ); + void ReleaseWorkLoop ( void ); + + // SCSI Parallel Device List + // The SCSI Parallel Device List will consist of 16 elements to represent + // identifiers that end in 0h through Fh. Each array element will point + // to a device object that represents the beginning of a linked list of + // device objects. By using an array of linked lists, the traversal time + // to find an object on a bus that supports a large number of devices, such + // as Fibre Channel, will be significantly lower than having to walk a list + // that is comprised of all devices on the bus. For parallel wide and + // narrow busses, which support 16 and 8 devices respectively, this will act + // like a simple array of device objects. + enum + { + kSCSIParallelDeviceListArrayCount = 16, + kSCSIParallelDeviceListIndexMask = 0x0F + }; + + IOSimpleLock * fDeviceLock; + IOSCSIParallelInterfaceDevice * + fParallelDeviceList[kSCSIParallelDeviceListArrayCount]; + + void InitializeDeviceList ( void ); + void AddDeviceToTargetList ( + IOSCSIParallelInterfaceDevice * newDevice ); + void RemoveDeviceFromTargetList ( + IOSCSIParallelInterfaceDevice * victimDevice ); + + // The Interrupt Service Routine for the controller. + static void ServiceInterrupt ( + OSObject * theObject, + IOInterruptEventSource * theSource, + int count ); + + static void TimeoutOccurred ( OSObject * owner, IOTimerEventSource * sender ); + + static bool FilterInterrupt ( + OSObject * theObject, + IOFilterInterruptEventSource * theSource ); + + // IOService support methods + // These shall not be overridden by the HBA child classes. + bool start ( IOService * provider ); + void stop ( IOService * provider ); + + +protected: + + // These may be overriden by the HBA child classes if necessary, but should + // call the superclass implementation. + virtual bool handleOpen ( + IOService * client, + IOOptionBits options, + void * arg ); + + virtual void handleClose ( + IOService * client, + IOOptionBits options ); + + virtual bool handleIsOpen ( + const IOService * client ) const; + + virtual bool willTerminate ( IOService * provider, IOOptionBits options ); + virtual bool didTerminate ( IOService * provider, IOOptionBits options, bool * defer ); + +}; + + +#endif /* __IOKIT_IO_SCSI_PARALLEL_INTERFACE_CONTROLLER_H__ */ \ No newline at end of file Index: branches/azimutz/Cleancut/i386/include/IOKit/scsi/SCSIPort.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/scsi/SCSIPort.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/scsi/SCSIPort.h (revision 885) @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2004-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_SCSI_PORTS_H_ +#define _IOKIT_SCSI_PORTS_H_ + + +/*! @header SCSIPort + @discussion + This file contains all the definitions for SCSIPort notifications and status. +*/ + + +/*! +@enum kSCSIPort_NotificationStatusChange +@discussion +Message definition to be used with the messageClients +call to inform of a change in port status. +*/ +enum +{ + kSCSIPort_NotificationStatusChange = 0x68000001 +}; + + +/*! @typedef SCSIPortStatus + @abstract 32-bit number to represent a SCSIPortStatus. + @discussion Type for SCSIPortStatus. +*/ + +typedef UInt32 SCSIPortStatus; + +/*! @enum SCSI Port Status Values + @discussion Definitions for the possible port status values +*/ +enum +{ + /*! + @constant kSCSIPort_StatusOnline + The port is online. + */ + kSCSIPort_StatusOnline = 0, + + /*! + @constant kSCSIPort_StatusOffline + The port is offline (e.g. unplugged cable). + */ + kSCSIPort_StatusOffline = 1, + + /*! + @constant kSCSIPort_StatusFailure + Driver has detected unrecoverable port failure (e.g. hardware port failure) + */ + kSCSIPort_StatusFailure = 2 +}; + +#endif /* _IOKIT_SCSI_PORTS_H_ */ Index: branches/azimutz/Cleancut/i386/include/IOKit/scsi/IOSCSIBlockCommandsDevice.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/scsi/IOSCSIBlockCommandsDevice.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/scsi/IOSCSIBlockCommandsDevice.h (revision 885) @@ -0,0 +1,1146 @@ +/* + * 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_SCSI_BLOCK_COMMANDS_DEVICE_H_ +#define _IOKIT_IO_SCSI_BLOCK_COMMANDS_DEVICE_H_ + +#if defined(KERNEL) && defined(__cplusplus) + +//----------------------------------------------------------------------------- +// Constants +//----------------------------------------------------------------------------- + +// SBC power states as defined in T10:996D SCSI Block Commands - 3 (SBC-3) +// Revision 8c, November 13, 1997, pages 10-11. +enum +{ + kSBCPowerStateSystemSleep = 0, + kSBCPowerStateSleep = 1, + kSBCPowerStateStandby = 2, + kSBCPowerStateIdle = 3, + kSBCPowerStateActive = 4, + kSBCNumPowerStates = 5 +}; + +enum +{ + kMediaStateUnlocked = 0, + kMediaStateLocked = 1 +}; + + +//----------------------------------------------------------------------------- +// Includes +//----------------------------------------------------------------------------- + +// General IOKit headers +#include <IOKit/IOLib.h> +#include <IOKit/IOMemoryDescriptor.h> +#include <IOKit/IOService.h> +#include <IOKit/IOUserClient.h> + +// Generic IOKit storage related headers +#include <IOKit/storage/IOStorage.h> + +// SCSI Architecture Model Family includes +#include <IOKit/scsi/IOSCSIPrimaryCommandsDevice.h> + + +// Forward declaration for the SCSIBlockCommands that is used internally by the +// IOSCSIBlockCommandsDevice class. +class SCSIBlockCommands; + +//----------------------------------------------------------------------------- +// Class Declaration +//----------------------------------------------------------------------------- + +class IOSCSIBlockCommandsDevice : public IOSCSIPrimaryCommandsDevice +{ + + OSDeclareAbstractStructors ( IOSCSIBlockCommandsDevice ) + +private: + + +#ifndef __LP64__ + + SCSIBlockCommands * fSCSIBlockCommandObject; + SCSIBlockCommands * GetSCSIBlockCommandObject ( void ); + +#endif /* !__LP64__ */ + + IOReturn GetWriteCacheState ( IOMemoryDescriptor * buffer, + UInt8 modePageControlValue ); + + static void AsyncReadWriteComplete ( SCSITaskIdentifier completedTask ); + +protected: + + // Reserve space for future expansion. + struct IOSCSIBlockCommandsDeviceExpansionData + { + IONotifier * fPowerDownNotifier; + bool fWriteCacheEnabled; + bool fDeviceIsShared; + UInt64 fMediumBlockCount64; + bool fDeviceHasSATTranslation; + bool fProtocolSpecificPowerControl; + bool fRequiresEjectWithStartStopUnit; + }; + IOSCSIBlockCommandsDeviceExpansionData * fIOSCSIBlockCommandsDeviceReserved; + + #define fPowerDownNotifier fIOSCSIBlockCommandsDeviceReserved->fPowerDownNotifier + #define fWriteCacheEnabled fIOSCSIBlockCommandsDeviceReserved->fWriteCacheEnabled + + // The fDeviceIsShared is used to indicate whether this device exists on a Physical + // Interconnect that allows multiple initiators to access it. This is used mainly + // by the power management code to not send power state related START_STOP_UNIT + // commands to the device. + // The fDeviceIsShared value is also used to prevent power state commands from being + // sent to manual eject device since these devices behave better when allowed to + // manage their own power. + #define fDeviceIsShared fIOSCSIBlockCommandsDeviceReserved->fDeviceIsShared + + // The fMediumBlockCount64 provides support for 64 bit LBAs and + // replaces fMediumBlockCount which only supports 32 bits. + // This value should not be directly accessed and instead the member routine + // ReportMediumTotalBlockCount() should be used to retrieve it and the member routine + // SetMediumCharacteristics() should be used to set it. + #define fMediumBlockCount64 fIOSCSIBlockCommandsDeviceReserved->fMediumBlockCount64 + + #define fDeviceHasSATTranslation fIOSCSIBlockCommandsDeviceReserved->fDeviceHasSATTranslation + + // Device support protocol specific power off + #define fProtocolSpecificPowerControl fIOSCSIBlockCommandsDeviceReserved->fProtocolSpecificPowerControl + + // Device requires START_STOP_UNIT for ejects, regardless if PREVENT_ALLOW_MEIDUMREMOVAL + // failed. + #define fRequiresEjectWithStartStopUnit fIOSCSIBlockCommandsDeviceReserved->fRequiresEjectWithStartStopUnit + +private: + /* OBSOLETE. Use IOSCSIPrimaryCommandsDevice::Get/SetANSIVersion */ + UInt8 fANSIVersion; + +protected: + // ---- Device Characteristics ---- + bool fMediaIsRemovable; + + // ---- Medium Characteristics ---- + bool fMediumPresent; + +private: + // The byte count of each physical block on the medium. + // This value should not be directly accessed and instead the member routine + // ReportMediumBlockSize() should be used to retrieve it and the member routine + // SetMediumCharacteristics() should be used to set it. + UInt32 fMediumBlockSize; + + // The total number of blocks of fMediumBlockSize on the medium. + // OBSOLETE. Use fMediumBlockCount64 instead which allows for support of + // devices that have 33 through 64 bit LBA values. + UInt32 fMediumBlockCount; + +protected: + // Whether the installed medium is protected from writes + bool fMediumIsWriteProtected; + + // Whether user removal of medium has been prevented + bool fMediumRemovalPrevented; + + // Indicates whether this is a known manual eject device + bool fKnownManualEject; + + // Polling thread variables + thread_call_t fPollingThread; + UInt32 fPollingMode; + enum + { + kPollingMode_Suspended = 0, + kPollingMode_NewMedia = 1, + kPollingMode_MediaRemoval = 2 + }; + + // ---- Methods for controlling the current state of device support ---- + virtual bool InitializeDeviceSupport ( void ); + virtual void StartDeviceSupport ( void ); + virtual void SuspendDeviceSupport ( void ); + virtual void ResumeDeviceSupport ( void ); + virtual void StopDeviceSupport ( void ); + virtual void TerminateDeviceSupport ( void ); + + virtual void free ( void ); + +#ifndef __LP64__ + + // This method will retrieve the SCSI Primary Command Set object for + // the class. For subclasses, this will be overridden using a + // dynamic cast on the subclasses base command set object. + virtual SCSIPrimaryCommands * GetSCSIPrimaryCommandObject ( void ); + + virtual bool CreateCommandSetObjects ( void ); + virtual void FreeCommandSetObjects ( void ); + +#endif /* !__LP64__ */ + + virtual bool ClearNotReadyStatus ( void ); + virtual void CreateStorageServiceNub ( void ); + virtual bool DetermineDeviceCharacteristics ( void ); + + // ---- Methods used for controlling the polling thread ---- + virtual void ProcessPoll ( void ); + virtual void EnablePolling ( void ); + virtual void DisablePolling ( void ); + + // Main and support methods for polling for new Media + virtual void PollForNewMedia ( void ); + virtual bool DetermineMediaPresence ( void ); + virtual bool PreventMediumRemoval ( void ); + virtual bool DetermineMediumCapacity ( + UInt64 * blockSize, + UInt64 * blockCount ); + virtual bool DetermineMediumWriteProtectState ( void ); + + // Main and support methods for polling for Media removal + virtual void PollForMediaRemoval ( void ); + + // ---- Methods used for handling medium characteristics ---- + + // OBSOLETE - Use the version compatible with 64 bit LBAs instead. + virtual void SetMediumCharacteristics ( + UInt32 blockSize, + UInt32 blockCount ); + + void SetMediumCharacteristics ( + UInt64 blockSize, + UInt64 blockCount ); + + virtual void ResetMediumCharacteristics ( void ); + + virtual IOReturn IssueRead ( + IOMemoryDescriptor * buffer, + UInt64 startBlock, + UInt64 blockCount ); + + virtual IOReturn IssueRead ( + IOMemoryDescriptor * buffer, + UInt64 startBlock, + UInt64 blockCount, + void * clientData ); + + virtual IOReturn IssueWrite ( + IOMemoryDescriptor * buffer, + UInt64 startBlock, + UInt64 blockCount ); + + virtual IOReturn IssueWrite ( + IOMemoryDescriptor * buffer, + UInt64 startBlock, + UInt64 blockCount, + void * clientData ); + + // ----- Power Management Support ------ + + // We override this method to set our power states and register ourselves + // as a power policy maker. + virtual void InitializePowerManagement ( IOService * provider ); + + // We override this method so that when we register for power management, + // we go to our active power state (which the drive is definitely in + // at startup time). + virtual UInt32 GetInitialPowerState ( void ); + + // We override this method in order to provide the number of transitions + // from Fully active to Sleep state so that the idle timer can be adjusted + // to the appropriate time period based on the disk spindown time set in + // the Energy Saver prefs panel. + virtual UInt32 GetNumberOfPowerStateTransitions ( void ); + + // The TicklePowerManager method is called to tell the power manager that + // the device needs to be in a certain power state to handle requests. + virtual void TicklePowerManager ( void ); + + // The HandlePowerChange method is the state machine for power management. + // It is guaranteed to be on its own thread of execution (different from + // the power manager thread AND the workloop thread. This routine can + // send sync or async calls to the drive without worrying about threading + // issues. + virtual void HandlePowerChange ( void ); + + // The HandleCheckPowerState (void) method is on the serialized side of the + // command gate and can change member variables safely without + // multi-threading issues. It's main purpose is to call the superclass' + // HandleCheckPowerState ( UInt32 maxPowerState ) with the max power state + // the class registered with. + virtual void HandleCheckPowerState ( void ); + + // The VerifyMediumPresence method is called to see if the medium which we + // anticipated being there is still there. + virtual bool VerifyMediumPresence ( void ); + +public: + + static void sProcessPoll ( void * pdtDriver, void * refCon ); + + // ---- Methods for controlling the device ---- + virtual IOReturn SyncReadWrite ( + IOMemoryDescriptor * buffer, + UInt64 startBlock, + UInt64 blockCount, + UInt64 blockSize ); + + virtual IOReturn AsyncReadWrite ( + IOMemoryDescriptor * buffer, + UInt64 startBlock, + UInt64 blockCount, + UInt64 blockSize, + void * clientData ); + + IOReturn GetWriteCacheState ( bool * enabled ); + IOReturn SetWriteCacheState ( bool enabled ); + void DetermineMediumGeometry ( void ); + + // ---- Methods for controlling medium state ---- + virtual IOReturn EjectTheMedium ( void ); + virtual IOReturn LockUnlockMedium ( bool doLock ); + virtual IOReturn SynchronizeCache ( void ); + + // ---- Methods for controlling media format ---- + virtual IOReturn FormatMedium ( + UInt64 blockCount, + UInt64 blockSize ); + virtual UInt32 GetFormatCapacities ( + UInt64 * capacities, + UInt32 capacitiesMaxCount ) const; + + // ---- Query methods to report device characteristics ---- + + // Report the maximum number of blocks that the device can handle per + // read or write. A value of 0 (zero) indicates there is no limit aside + // from the size of the method's return parameter. + virtual UInt64 ReportDeviceMaxBlocksReadTransfer ( void ); + virtual UInt64 ReportDeviceMaxBlocksWriteTransfer ( void ); + + // Report whether the device supports removal of the media. + virtual bool ReportDeviceMediaRemovability ( void ); + + // ---- Query methods to report installed medium characteristics ---- + virtual UInt64 ReportMediumBlockSize ( void ); + virtual UInt64 ReportMediumTotalBlockCount ( void ); + virtual bool ReportMediumWriteProtection ( void ); + + +protected: + + +#ifndef __LP64__ + + // Command methods to access all commands available to SBC based devices. + virtual bool ERASE_10 ( + SCSITaskIdentifier request, + SCSICmdField1Bit ERA, + SCSICmdField1Bit RELADR, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField2Byte TRANSFER_LENGTH, + SCSICmdField1Byte CONTROL ); + + virtual bool ERASE_12 ( + SCSITaskIdentifier request, + SCSICmdField1Bit ERA, + SCSICmdField1Bit RELADR, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField4Byte TRANSFER_LENGTH, + SCSICmdField1Byte CONTROL ); + + virtual bool FORMAT_UNIT ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + IOByteCount defectListSize, + SCSICmdField1Bit FMTDATA, + SCSICmdField1Bit CMPLST, + SCSICmdField3Bit DEFECT_LIST_FORMAT, + SCSICmdField1Byte VENDOR_SPECIFIC, + SCSICmdField2Byte INTERLEAVE, + SCSICmdField1Byte CONTROL ); + + // Defined in SBC-2 Section 5.41 + bool FORMAT_UNIT ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + IOByteCount defectListSize, + SCSICmdField1Bit FMTPINFO, + SCSICmdField1Bit RTO_REQ, + SCSICmdField1Bit LONGLIST, + SCSICmdField1Bit FMTDATA, + SCSICmdField1Bit CMPLST, + SCSICmdField3Bit DEFECT_LIST_FORMAT, + SCSICmdField1Byte VENDOR_SPECIFIC, + SCSICmdField1Byte CONTROL ); + + virtual bool LOCK_UNLOCK_CACHE ( + SCSITaskIdentifier request, + SCSICmdField1Bit LOCK, + SCSICmdField1Bit RELADR, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField2Byte NUMBER_OF_BLOCKS, + SCSICmdField1Byte CONTROL ); + + // Defined in SBC-2 section 5.5 + bool LOCK_UNLOCK_CACHE ( + SCSITaskIdentifier request, + SCSICmdField1Bit LOCK, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField2Byte NUMBER_OF_BLOCKS, + SCSICmdField1Byte CONTROL ); + + bool LOCK_UNLOCK_CACHE_16 ( + SCSITaskIdentifier request, + SCSICmdField1Bit LOCK, + SCSICmdField8Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField4Byte NUMBER_OF_BLOCKS, + SCSICmdField1Byte CONTROL ); + + virtual bool MEDIUM_SCAN ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Bit WBS, + SCSICmdField1Bit ASA, + SCSICmdField1Bit PSD, + SCSICmdField1Bit PRA, + SCSICmdField1Bit RELADR, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField2Byte PARAMETER_LIST_LENGTH, + SCSICmdField1Byte CONTROL ); + + virtual bool PREFETCH ( + SCSITaskIdentifier request, + SCSICmdField1Bit IMMED, + SCSICmdField1Bit RELADR, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField2Byte TRANSFER_LENGTH, + SCSICmdField1Byte CONTROL ); + + // Defined in SBC-2 section 5.7 + bool PREFETCH ( + SCSITaskIdentifier request, + SCSICmdField1Bit IMMED, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField5Bit GROUP_NUMBER, + SCSICmdField2Byte TRANSFER_LENGTH, + SCSICmdField1Byte CONTROL ); + + bool PREFETCH_16 ( + SCSITaskIdentifier request, + SCSICmdField1Bit IMMED, + SCSICmdField8Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField4Byte TRANSFER_LENGTH, + SCSICmdField5Bit GROUP_NUMBER, + SCSICmdField1Byte CONTROL ); + + virtual bool READ_6 ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + UInt32 blockSize, + SCSICmdField21Bit LOGICAL_BLOCK_ADDRESS, + SCSICmdField1Byte TRANSFER_LENGTH, + SCSICmdField1Byte CONTROL ); + +#endif /* __LP64__ */ + + virtual bool READ_10 ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + UInt32 blockSize, + SCSICmdField1Bit DPO, + SCSICmdField1Bit FUA, + SCSICmdField1Bit RELADR, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField2Byte TRANSFER_LENGTH, + SCSICmdField1Byte CONTROL ); + + // Defined in SBC-2 section 5.10 + bool READ_10 ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + UInt32 blockSize, + SCSICmdField3Bit RDPROTECT, + SCSICmdField1Bit DPO, + SCSICmdField1Bit FUA, + SCSICmdField1Bit FUA_NV, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField5Bit GROUP_NUMBER, + SCSICmdField2Byte TRANSFER_LENGTH, + SCSICmdField1Byte CONTROL ); + + virtual bool READ_12 ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + UInt32 blockSize, + SCSICmdField1Bit DPO, + SCSICmdField1Bit FUA, + SCSICmdField1Bit RELADR, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField4Byte TRANSFER_LENGTH, + SCSICmdField1Byte CONTROL ); + + // Defined in SBC-2 section 5.11 + bool READ_12 ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + UInt32 blockSize, + SCSICmdField3Bit RDPROTECT, + SCSICmdField1Bit DPO, + SCSICmdField1Bit FUA, + SCSICmdField1Bit FUA_NV, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField4Byte TRANSFER_LENGTH, + SCSICmdField5Bit GROUP_NUMBER, + SCSICmdField1Byte CONTROL ); + + bool READ_16 ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + UInt32 blockSize, + SCSICmdField3Bit RDPROTECT, + SCSICmdField1Bit DPO, + SCSICmdField1Bit FUA, + SCSICmdField1Bit FUA_NV, + SCSICmdField8Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField4Byte TRANSFER_LENGTH, + SCSICmdField5Bit GROUP_NUMBER, + SCSICmdField1Byte CONTROL ); + + virtual bool READ_CAPACITY ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Bit RELADR, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField1Bit PMI, + SCSICmdField1Byte CONTROL ); + + bool READ_CAPACITY_16 ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField8Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField4Byte ALLOCATION_LENGTH, + SCSICmdField1Bit PMI, + SCSICmdField1Byte CONTROL ); + +#ifndef __LP64__ + + virtual bool READ_DEFECT_DATA_10 ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Bit PLIST, + SCSICmdField1Bit GLIST, + SCSICmdField3Bit DEFECT_LIST_FORMAT, + SCSICmdField2Byte ALLOCATION_LENGTH, + SCSICmdField1Byte CONTROL ); + + virtual bool READ_DEFECT_DATA_12 ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Bit PLIST, + SCSICmdField1Bit GLIST, + SCSICmdField3Bit DEFECT_LIST_FORMAT, + SCSICmdField4Byte ALLOCATION_LENGTH, + SCSICmdField1Byte CONTROL ); + + virtual bool READ_GENERATION ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Bit RELADR, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField1Byte ALLOCATION_LENGTH, + SCSICmdField1Byte CONTROL ); + + virtual bool READ_LONG ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Bit CORRCT, + SCSICmdField1Bit RELADR, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField2Byte BYTE_TRANSFER_LENGTH, + SCSICmdField1Byte CONTROL ); + + bool READ_LONG_16 ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField8Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField2Byte BYTE_TRANSFER_LENGTH, + SCSICmdField1Bit CORRCT, + SCSICmdField1Byte CONTROL ); + + virtual bool READ_UPDATED_BLOCK_10 ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Bit DPO, + SCSICmdField1Bit FUA, + SCSICmdField1Bit RELADR, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField1Bit LATEST, + SCSICmdField15Bit GENERATION_ADDRESS, + SCSICmdField1Byte CONTROL ); + + virtual bool REASSIGN_BLOCKS ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Byte CONTROL ); + + // Defined in SBC-2 section 5.20 + bool REASSIGN_BLOCKS ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Bit LONGLBA, + SCSICmdField1Bit LONGLIST, + SCSICmdField1Byte CONTROL ); + + virtual bool REBUILD ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Bit DPO, + SCSICmdField1Bit FUA, + SCSICmdField1Bit INTDATA, + SCSICmdField2Bit PORT_CONTROL, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField4Byte REBUILD_LENGTH, + SCSICmdField4Byte PARAMETER_LIST_LENGTH, + SCSICmdField1Byte CONTROL ); + + virtual bool REGENERATE ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Bit DPO, + SCSICmdField1Bit FUA, + SCSICmdField1Bit INTDATA, + SCSICmdField2Bit PORT_CONTROL, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField4Byte REBUILD_LENGTH, + SCSICmdField4Byte PARAMETER_LIST_LENGTH, + SCSICmdField1Byte CONTROL ); + + virtual bool REZERO_UNIT ( + SCSITaskIdentifier request, + SCSICmdField1Byte CONTROL ); + + virtual bool SEARCH_DATA_EQUAL_10 ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Bit INVERT, + SCSICmdField1Bit SPNDAT, + SCSICmdField1Bit RELADR, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField2Byte NUMBER_OF_BLOCKS_TO_SEARCH, + SCSICmdField1Byte CONTROL ); + + virtual bool SEARCH_DATA_HIGH_10 ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Bit INVERT, + SCSICmdField1Bit SPNDAT, + SCSICmdField1Bit RELADR, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField2Byte NUMBER_OF_BLOCKS_TO_SEARCH, + SCSICmdField1Byte CONTROL ); + + virtual bool SEARCH_DATA_LOW_10 ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Bit INVERT, + SCSICmdField1Bit SPNDAT, + SCSICmdField1Bit RELADR, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField2Byte NUMBER_OF_BLOCKS_TO_SEARCH, + SCSICmdField1Byte CONTROL ); + + virtual bool SEEK_6 ( + SCSITaskIdentifier request, + SCSICmdField21Bit LOGICAL_BLOCK_ADDRESS, + SCSICmdField1Byte CONTROL ); + + virtual bool SEEK_10 ( + SCSITaskIdentifier request, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField1Byte CONTROL ); + + virtual bool SET_LIMITS_10 ( + SCSITaskIdentifier request, + SCSICmdField1Bit RDINH, + SCSICmdField1Bit WRINH, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField2Byte NUMBER_OF_BLOCKS, + SCSICmdField1Byte CONTROL ); + + virtual bool SET_LIMITS_12 ( + SCSITaskIdentifier request, + SCSICmdField1Bit RDINH, + SCSICmdField1Bit WRINH, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField4Byte NUMBER_OF_BLOCKS, + SCSICmdField1Byte CONTROL ); + +#endif /* __LP64__ */ + + virtual bool START_STOP_UNIT ( + SCSITaskIdentifier request, + SCSICmdField1Bit IMMED, + SCSICmdField4Bit POWER_CONDITIONS, + SCSICmdField1Bit LOEJ, + SCSICmdField1Bit START, + SCSICmdField1Byte CONTROL ); + + virtual bool SYNCHRONIZE_CACHE ( + SCSITaskIdentifier request, + SCSICmdField1Bit IMMED, + SCSICmdField1Bit RELADR, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField2Byte NUMBER_OF_BLOCKS, + SCSICmdField1Byte CONTROL ); + + // Defined in SBC-2 section 5.22 + bool SYNCHRONIZE_CACHE ( + SCSITaskIdentifier request, + SCSICmdField1Bit IMMED, + SCSICmdField1Bit SYNC_NV, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField5Bit GROUP_NUMBER, + SCSICmdField2Byte NUMBER_OF_BLOCKS, + SCSICmdField1Byte CONTROL ); + + bool SYNCRONIZE_CACHE_16 ( + SCSITaskIdentifier request, + SCSICmdField1Bit SYNC_NV, + SCSICmdField1Bit IMMED, + SCSICmdField8Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField4Byte NUMBER_OF_BLOCKS, + SCSICmdField5Bit GROUP_NUMBER, + SCSICmdField1Byte CONTROL ); + +#ifndef __LP64__ + + virtual bool UPDATE_BLOCK ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Bit RELADR, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField1Byte CONTROL ); + + virtual bool VERIFY_10 ( + SCSITaskIdentifier request, + SCSICmdField1Bit DPO, + SCSICmdField1Bit BLKVFY, + SCSICmdField1Bit BYTCHK, + SCSICmdField1Bit RELADR, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField2Byte VERIFICATION_LENGTH, + SCSICmdField1Byte CONTROL ); + + // Defined in SBC-2 section 5.24 + bool VERIFY_10 ( + SCSITaskIdentifier request, + SCSICmdField3Bit VRPROTECT, + SCSICmdField1Bit DPO, + SCSICmdField1Bit BYTCHK, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField5Bit GROUP_NUMBER, + SCSICmdField2Byte VERIFICATION_LENGTH, + SCSICmdField1Byte CONTROL ); + + virtual bool VERIFY_12 ( + SCSITaskIdentifier request, + SCSICmdField1Bit DPO, + SCSICmdField1Bit BLKVFY, + SCSICmdField1Bit BYTCHK, + SCSICmdField1Bit RELADR, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField4Byte VERIFICATION_LENGTH, + SCSICmdField1Byte CONTROL ); + + // Defined in SBC-2 section 5.25 + bool VERIFY_12 ( + SCSITaskIdentifier request, + SCSICmdField3Bit VRPROTECT, + SCSICmdField1Bit DPO, + SCSICmdField1Bit BYTCHK, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField5Bit GROUP_NUMBER, + SCSICmdField4Byte VERIFICATION_LENGTH, + SCSICmdField1Byte CONTROL ); + + bool VERIFY_16 ( + SCSITaskIdentifier request, + SCSICmdField3Bit VRPROTECT, + SCSICmdField1Bit DPO, + SCSICmdField1Bit BYTCHK, + SCSICmdField8Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField4Byte VERIFICATION_LENGTH, + SCSICmdField5Bit GROUP_NUMBER, + SCSICmdField1Byte CONTROL ); + + virtual bool WRITE_6 ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + UInt32 blockSize, + SCSICmdField2Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField1Byte TRANSFER_LENGTH, + SCSICmdField1Byte CONTROL ); + +#endif /* __LP64__ */ + + virtual bool WRITE_10 ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + UInt32 blockSize, + SCSICmdField1Bit DPO, + SCSICmdField1Bit FUA, + SCSICmdField1Bit EBP, + SCSICmdField1Bit RELADR, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField2Byte TRANSFER_LENGTH, + SCSICmdField1Byte CONTROL ); + + // Defined in SBC-2 section 5.29 + bool WRITE_10 ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + UInt32 blockSize, + SCSICmdField3Bit WRPROTECT, + SCSICmdField1Bit DPO, + SCSICmdField1Bit FUA, + SCSICmdField1Bit FUA_NV, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField5Bit GROUP_NUMBER, + SCSICmdField2Byte TRANSFER_LENGTH, + SCSICmdField1Byte CONTROL ); + + virtual bool WRITE_12 ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + UInt32 blockSize, + SCSICmdField1Bit DPO, + SCSICmdField1Bit FUA, + SCSICmdField1Bit EBP, + SCSICmdField1Bit RELADR, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField4Byte TRANSFER_LENGTH, + SCSICmdField1Byte CONTROL ); + + // Defined in SBC-2 section 5.30 + bool WRITE_12 ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + UInt32 blockSize, + SCSICmdField3Bit WRPROTECT, + SCSICmdField1Bit DPO, + SCSICmdField1Bit FUA, + SCSICmdField1Bit FUA_NV, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField5Bit GROUP_NUMBER, + SCSICmdField4Byte TRANSFER_LENGTH, + SCSICmdField1Byte CONTROL ); + + bool WRITE_16 ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + UInt32 blockSize, + SCSICmdField3Bit WRPROTECT, + SCSICmdField1Bit DPO, + SCSICmdField1Bit FUA, + SCSICmdField1Bit FUA_NV, + SCSICmdField8Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField4Byte TRANSFER_LENGTH, + SCSICmdField5Bit GROUP_NUMBER, + SCSICmdField1Byte CONTROL ); + +#ifndef __LP64__ + + virtual bool WRITE_AND_VERIFY_10 ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + UInt32 blockSize, + SCSICmdField1Bit DPO, + SCSICmdField1Bit EBP, + SCSICmdField1Bit BYTCHK, + SCSICmdField1Bit RELADR, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField2Byte TRANSFER_LENGTH, + SCSICmdField1Byte CONTROL ); + + // Defined in SBC-2 section 5.33 + bool WRITE_AND_VERIFY_10 ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + UInt32 blockSize, + SCSICmdField3Bit WRPROTECT, + SCSICmdField1Bit DPO, + SCSICmdField1Bit BYTCHK, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField5Bit GROUP_NUMBER, + SCSICmdField2Byte TRANSFER_LENGTH, + SCSICmdField1Byte CONTROL ); + + virtual bool WRITE_AND_VERIFY_12 ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + UInt32 blockSize, + SCSICmdField1Bit DPO, + SCSICmdField1Bit EBP, + SCSICmdField1Bit BYTCHK, + SCSICmdField1Bit RELADR, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField4Byte TRANSFER_LENGTH, + SCSICmdField1Byte CONTROL ); + + // Defined in SBC-2 section 5.34 + bool WRITE_AND_VERIFY_12 ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + UInt32 blockSize, + SCSICmdField3Bit WRPROTECT, + SCSICmdField1Bit DPO, + SCSICmdField1Bit BYTCHK, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField4Byte TRANSFER_LENGTH, + SCSICmdField5Bit GROUP_NUMBER, + SCSICmdField1Byte CONTROL ); + + bool WRITE_AND_VERIFY_16 ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + UInt32 blockSize, + SCSICmdField3Bit WRPROTECT, + SCSICmdField1Bit DPO, + SCSICmdField1Bit BYTCHK, + SCSICmdField8Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField4Byte TRANSFER_LENGTH, + SCSICmdField5Bit GROUP_NUMBER, + SCSICmdField1Byte CONTROL ); + + + virtual bool WRITE_LONG ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Bit RELADR, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField2Byte TRANSFER_LENGTH, + SCSICmdField1Byte CONTROL ); + + bool WRITE_LONG_16 ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField8Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField2Byte TRANSFER_LENGTH, + SCSICmdField1Bit CORRCT, + SCSICmdField1Byte CONTROL ); + + virtual bool WRITE_SAME ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Bit PBDATA, + SCSICmdField1Bit LBDATA, + SCSICmdField1Bit RELADR, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField2Byte TRANSFER_LENGTH, + SCSICmdField1Byte CONTROL ); + + // Defined in SBC-2 section 5.39 + bool WRITE_SAME ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField3Bit WRPROTECT, + SCSICmdField1Bit PBDATA, + SCSICmdField1Bit LBDATA, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField5Bit GROUP_NUMBER, + SCSICmdField2Byte TRANSFER_LENGTH, + SCSICmdField1Byte CONTROL ); + + bool WRITE_SAME_16 ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField3Bit WRPROTECT, + SCSICmdField1Bit PBDATA, + SCSICmdField1Bit LBDATA, + SCSICmdField8Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField4Byte TRANSFER_LENGTH, + SCSICmdField5Bit GROUP_NUMBER, + SCSICmdField1Byte CONTROL ); + + virtual bool XDREAD ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField2Byte TRANSFER_LENGTH, + SCSICmdField1Byte CONTROL ); + + // Defined in SBC-2 section 5.42 + bool XDREAD ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Bit XORPINFO, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField5Bit GROUP_NUMBER, + SCSICmdField2Byte TRANSFER_LENGTH, + SCSICmdField1Byte CONTROL ); + + virtual bool XDWRITE ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Bit DPO, + SCSICmdField1Bit FUA, + SCSICmdField1Bit DISABLE_WRITE, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField2Byte TRANSFER_LENGTH, + SCSICmdField1Byte CONTROL ); + + // Defined in SBC-2 section 5.43 + bool XDWRITE ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField3Bit WRPROTECT, + SCSICmdField1Bit DPO, + SCSICmdField1Bit FUA, + SCSICmdField1Bit DISABLE_WRITE, + SCSICmdField1Bit FUA_NV, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField5Bit GROUP_NUMBER, + SCSICmdField2Byte TRANSFER_LENGTH, + SCSICmdField1Byte CONTROL ); + + virtual bool XDWRITE_EXTENDED ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Bit TABLE_ADDRESS, + SCSICmdField1Bit DPO, + SCSICmdField1Bit FUA, + SCSICmdField1Bit DISABLE_WRITE, + SCSICmdField2Bit PORT_CONTROL, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField4Byte SECONDARY_BLOCK_ADDRESS, + SCSICmdField4Byte TRANSFER_LENGTH, + SCSICmdField1Byte SECONDARY_ADDRESS, + SCSICmdField1Byte CONTROL ); + + // Defined in SBC-2 section 5.46 + bool XDWRITEREAD_10 ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField3Bit WRPROTECT, + SCSICmdField1Bit DPO, + SCSICmdField1Bit FUA, + SCSICmdField1Bit DISABLE_WRITE, + SCSICmdField1Bit FUA_NV, + SCSICmdField1Bit XORPINFO, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField5Bit GROUP_NUMBER, + SCSICmdField2Byte TRANSFER_LENGTH, + SCSICmdField1Byte CONTROL ); + + virtual bool XPWRITE ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Bit DPO, + SCSICmdField1Bit FUA, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField2Byte TRANSFER_LENGTH, + SCSICmdField1Byte CONTROL ); + + // Defined in SBC-2 section 5.48 + bool XPWRITE ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Bit DPO, + SCSICmdField1Bit FUA, + SCSICmdField1Bit FUA_NV, + SCSICmdField1Bit XORPINFO, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField5Bit GROUP_NUMBER, + SCSICmdField2Byte TRANSFER_LENGTH, + SCSICmdField1Byte CONTROL ); + +#endif /* __LP64__ */ + + + /* Added with 10.2 */ + OSMetaClassDeclareReservedUsed ( IOSCSIBlockCommandsDevice, 1 ); + +public: + + virtual IOReturn PowerDownHandler ( void * refCon, + UInt32 messageType, + IOService * provider, + void * messageArgument, + vm_size_t argSize ); + + + /* Added with 10.2 */ + OSMetaClassDeclareReservedUsed ( IOSCSIBlockCommandsDevice, 2 ); + +protected: + + virtual void SetMediumIcon ( void ); + + + /* Added with 10.3.3 */ + OSMetaClassDeclareReservedUsed ( IOSCSIBlockCommandsDevice, 3 ); + +protected: + + virtual void AsyncReadWriteCompletion ( SCSITaskIdentifier completedTask ); + + + /* Added with 10.6.0 */ + OSMetaClassDeclareReservedUsed ( IOSCSIBlockCommandsDevice, 4 ); + +public: + + virtual IOReturn AsyncReadWrite ( + IOMemoryDescriptor * buffer, + UInt64 startBlock, + UInt64 blockCount, + UInt64 blockSize, + IOStorageAttributes * attributes, + void * clientData ); + + +private: + + // Space reserved for future expansion. + OSMetaClassDeclareReservedUnused ( IOSCSIBlockCommandsDevice, 5 ); + OSMetaClassDeclareReservedUnused ( IOSCSIBlockCommandsDevice, 6 ); + OSMetaClassDeclareReservedUnused ( IOSCSIBlockCommandsDevice, 7 ); + OSMetaClassDeclareReservedUnused ( IOSCSIBlockCommandsDevice, 8 ); + OSMetaClassDeclareReservedUnused ( IOSCSIBlockCommandsDevice, 9 ); + OSMetaClassDeclareReservedUnused ( IOSCSIBlockCommandsDevice, 10 ); + OSMetaClassDeclareReservedUnused ( IOSCSIBlockCommandsDevice, 11 ); + OSMetaClassDeclareReservedUnused ( IOSCSIBlockCommandsDevice, 12 ); + OSMetaClassDeclareReservedUnused ( IOSCSIBlockCommandsDevice, 13 ); + OSMetaClassDeclareReservedUnused ( IOSCSIBlockCommandsDevice, 14 ); + OSMetaClassDeclareReservedUnused ( IOSCSIBlockCommandsDevice, 15 ); + OSMetaClassDeclareReservedUnused ( IOSCSIBlockCommandsDevice, 16 ); + +}; + +#endif /* defined(KERNEL) && defined(__cplusplus) */ + +#endif /* _IOKIT_IO_SCSI_BLOCK_COMMANDS_DEVICE_H_ */ Index: branches/azimutz/Cleancut/i386/include/IOKit/scsi/IOSCSIMultimediaCommandsDevice.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/scsi/IOSCSIMultimediaCommandsDevice.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/scsi/IOSCSIMultimediaCommandsDevice.h (revision 885) @@ -0,0 +1,1057 @@ +/* + * 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_SCSI_MULTIMEDIA_COMMANDS_DEVICE_H_ +#define _IOKIT_IO_SCSI_MULTIMEDIA_COMMANDS_DEVICE_H_ + +#if KERNEL +#include <IOKit/IOTypes.h> +#else +#include <CoreFoundation/CoreFoundation.h> +#endif + +#include <IOKit/storage/IOStorageDeviceCharacteristics.h> + + +//----------------------------------------------------------------------------- +// Constants +//----------------------------------------------------------------------------- + + +// Message constants +#define kIOMessageTrayStateChange 0x69000035 +#define kIOMessageTrayStateHasChanged kIOMessageTrayStateChange // DEPRECATED, use kIOMessageTrayStateChange instead + +// Message values for kIOMessageTrayStateChange +enum +{ + kMessageTrayStateChangeRequestAccepted = 0, + kMessageTrayStateChangeRequestRejected = 1 +}; + +#define kIOMessageMediaAccessChange 0x69000036 + +// Message values for kIOMessageMediaAccessChange +enum +{ + kMessageDeterminingMediaPresence = 0, + kMessageFoundMedia = 1, + kMessageMediaTypeDetermined = 2 +}; + +// IOKit property keys and constants +#define kIOPropertySupportedCDFeatures kIOPropertySupportedCDFeaturesKey +#define kIOPropertySupportedDVDFeatures kIOPropertySupportedDVDFeaturesKey +#define kIOPropertySupportedBDFeatures kIOPropertySupportedBDFeaturesKey +#define kIOPropertyLowPowerPolling "Low Power Polling" + +typedef UInt32 CDFeatures; +enum +{ + kCDFeaturesAnalogAudioBit = 0, // Analog Audio playback + kCDFeaturesReadStructuresBit = 1, // CD-ROM + kCDFeaturesWriteOnceBit = 2, // CD-R + kCDFeaturesReWriteableBit = 3, // CD-R/W + kCDFeaturesCDDAStreamAccurateBit = 4, // CD-DA stream accurate + kCDFeaturesPacketWriteBit = 5, // Packet Writing + kCDFeaturesTAOWriteBit = 6, // CD Track At Once + kCDFeaturesSAOWriteBit = 7, // CD Mastering - Session At Once + kCDFeaturesRawWriteBit = 8, // CD Mastering - Raw + kCDFeaturesTestWriteBit = 9, // CD Mastering/TAO - Test Write + kCDFeaturesBUFWriteBit = 10 // CD Mastering/TAO - Buffer Underrun Free +}; + +enum +{ + kCDFeaturesAnalogAudioMask = (1 << kCDFeaturesAnalogAudioBit), + kCDFeaturesReadStructuresMask = (1 << kCDFeaturesReadStructuresBit), + kCDFeaturesWriteOnceMask = (1 << kCDFeaturesWriteOnceBit), + kCDFeaturesReWriteableMask = (1 << kCDFeaturesReWriteableBit), + kCDFeaturesCDDAStreamAccurateMask = (1 << kCDFeaturesCDDAStreamAccurateBit), + kCDFeaturesPacketWriteMask = (1 << kCDFeaturesPacketWriteBit), + kCDFeaturesTAOWriteMask = (1 << kCDFeaturesTAOWriteBit), + kCDFeaturesSAOWriteMask = (1 << kCDFeaturesSAOWriteBit), + kCDFeaturesRawWriteMask = (1 << kCDFeaturesRawWriteBit), + kCDFeaturesTestWriteMask = (1 << kCDFeaturesTestWriteBit), + kCDFeaturesBUFWriteMask = (1 << kCDFeaturesBUFWriteBit) +}; + +typedef UInt32 DVDFeatures; +enum +{ + kDVDFeaturesCSSBit = 0, // DVD-CSS + kDVDFeaturesReadStructuresBit = 1, // DVD-ROM + kDVDFeaturesWriteOnceBit = 2, // DVD-R + kDVDFeaturesRandomWriteableBit = 3, // DVD-RAM + kDVDFeaturesReWriteableBit = 4, // DVD-RW + kDVDFeaturesTestWriteBit = 5, // DVD-R Write - Test Write + kDVDFeaturesBUFWriteBit = 6, // DVD-R Write - Buffer Underrun Free + kDVDFeaturesPlusRBit = 7, // DVD+R + kDVDFeaturesPlusRWBit = 8, // DVD+RW (implies backgound format support) + kDVDFeaturesHDReadBit = 9, // HD DVD-ROM + kDVDFeaturesHDRBit = 10, // HD DVD-R + kDVDFeaturesHDRAMBit = 11, // HD DVD-RAM + kDVDFeaturesHDRWBit = 12 // HD DVD-RW +}; + +enum +{ + kDVDFeaturesCSSMask = (1 << kDVDFeaturesCSSBit), + kDVDFeaturesReadStructuresMask = (1 << kDVDFeaturesReadStructuresBit), + kDVDFeaturesWriteOnceMask = (1 << kDVDFeaturesWriteOnceBit), + kDVDFeaturesRandomWriteableMask = (1 << kDVDFeaturesRandomWriteableBit), + kDVDFeaturesReWriteableMask = (1 << kDVDFeaturesReWriteableBit), + kDVDFeaturesTestWriteMask = (1 << kDVDFeaturesTestWriteBit), + kDVDFeaturesBUFWriteMask = (1 << kDVDFeaturesBUFWriteBit), + kDVDFeaturesPlusRMask = (1 << kDVDFeaturesPlusRBit), + kDVDFeaturesPlusRWMask = (1 << kDVDFeaturesPlusRWBit), + kDVDFeaturesHDReadMask = (1 << kDVDFeaturesHDReadBit), + kDVDFeaturesHDRMask = (1 << kDVDFeaturesHDRBit), + kDVDFeaturesHDRAMMask = (1 << kDVDFeaturesHDRAMBit), + kDVDFeaturesHDRWMask = (1 << kDVDFeaturesHDRWBit) +}; + +typedef UInt32 BDFeatures; +enum +{ + kBDFeaturesReadBit = 0, // BD-ROM + kBDFeaturesWriteBit = 1 // BD-R / BD-RE +}; + +enum +{ + kBDFeaturesReadMask = (1 << kBDFeaturesReadBit), + kBDFeaturesWriteMask = (1 << kBDFeaturesWriteBit) +}; + +enum +{ + kDiscStatusEmpty = 0, + kDiscStatusIncomplete = 1, + kDiscStatusComplete = 2, + kDiscStatusOther = 3, + kDiscStatusMask = 0x03, + kDiscStatusErasableMask = 0x10 +}; + + +#if defined(KERNEL) && defined(__cplusplus) + +// MMC power states as defined in T10:1228D SCSI Multimedia Commands - 2 (MMC-2) +// Revision 11a, August 30, 1999, page 312 (Annex F). +enum +{ + kMMCPowerStateSystemSleep = 0, + kMMCPowerStateSleep = 1, + kMMCPowerStateStandby = 2, + kMMCPowerStateIdle = 3, + kMMCPowerStateActive = 4, + kMMCNumPowerStates = 5 +}; + +enum +{ + kMediaStateUnlocked = 0, + kMediaStateLocked = 1 +}; + + +//----------------------------------------------------------------------------- +// Includes +//----------------------------------------------------------------------------- + +// General IOKit headers +#include <IOKit/IOLib.h> +#include <IOKit/IOMemoryDescriptor.h> + +// Generic IOKit storage related headers +#include <IOKit/storage/IOStorage.h> +#include <IOKit/storage/IOCDTypes.h> +#include <IOKit/storage/IODVDTypes.h> + +// SCSI Architecture Model Family includes +#include <IOKit/scsi/IOSCSIPrimaryCommandsDevice.h> + +// Forward definitions for internal use only classes +class SCSIMultimediaCommands; +class SCSIBlockCommands; + + +//----------------------------------------------------------------------------- +// Class Declaration +//----------------------------------------------------------------------------- + +class IOSCSIMultimediaCommandsDevice : public IOSCSIPrimaryCommandsDevice +{ + + OSDeclareAbstractStructors ( IOSCSIMultimediaCommandsDevice ) + +private: + +#ifndef __LP64__ + + SCSIMultimediaCommands * fSCSIMultimediaCommandObject; + SCSIMultimediaCommands * GetSCSIMultimediaCommandObject ( void ); + + SCSIBlockCommands * fSCSIBlockCommandObject; /* OBSOLETE */ + SCSIBlockCommands * GetSCSIBlockCommandObject ( void ); /* OBSOLETE */ + +#endif /* !__LP64__ */ + + static void AsyncReadWriteComplete ( SCSITaskIdentifier completedTask ); + +protected: + + // Reserve space for future expansion. + struct IOSCSIMultimediaCommandsDeviceExpansionData + { + IONotifier * fPowerDownNotifier; + bool fDeviceSupportsPowerOff; + BDFeatures fSupportedBDFeatures; + bool fDeviceSupportsAsyncNotification; + bool fDeviceSupportsFastSpindown; + UInt8 fCDLoadingMechanism; + }; + IOSCSIMultimediaCommandsDeviceExpansionData * fIOSCSIMultimediaCommandsDeviceReserved; + + #define fPowerDownNotifier fIOSCSIMultimediaCommandsDeviceReserved->fPowerDownNotifier + #define fDeviceSupportsPowerOff fIOSCSIMultimediaCommandsDeviceReserved->fDeviceSupportsPowerOff + #define fSupportedBDFeatures fIOSCSIMultimediaCommandsDeviceReserved->fSupportedBDFeatures + #define fDeviceSupportsAsyncNotification fIOSCSIMultimediaCommandsDeviceReserved->fDeviceSupportsAsyncNotification + #define fDeviceSupportsFastSpindown fIOSCSIMultimediaCommandsDeviceReserved->fDeviceSupportsFastSpindown + #define fCDLoadingMechanism fIOSCSIMultimediaCommandsDeviceReserved->fCDLoadingMechanism + +#ifndef __LP64__ + + // This method will retreive the SCSI Primary Command Set object for + // the class. For subclasses, this will be overridden using a + // dynamic cast on the subclasses base command set object. + virtual SCSIPrimaryCommands * GetSCSIPrimaryCommandObject ( void ); + +#endif /* !__LP64__ */ + + CDFeatures fSupportedCDFeatures; + DVDFeatures fSupportedDVDFeatures; + + UInt16 fCurrentDiscSpeed; + bool fMediaChanged; + bool fMediaPresent; + + // The byte count of each physical block on the media. + UInt32 fMediaBlockSize; + + // The total number of blocks of fMediaBlockSize on the media. + UInt32 fMediaBlockCount; + + // Flags used to indicate device feature + bool fMediaIsRemovable; + bool fMediaIsWriteProtected; + UInt32 fMediaType; + + thread_call_t fPollingThread; + bool fDeviceSupportsLowPowerPolling; + bool fLowPowerPollingEnabled; + UInt32 fPollingMode; + + enum + { + kPollingMode_Suspended = 0, + kPollingMode_NewMedia = 1, + kPollingMode_MediaRemoval = 2 + }; + + virtual IOReturn setProperties ( OSObject * properties ); + + virtual void CreateStorageServiceNub ( void ); + virtual bool DetermineDeviceCharacteristics ( void ); + virtual IOReturn DetermineIfMediaIsRemovable ( void ); + virtual IOReturn DetermineDeviceFeatures ( void ); + virtual void DetermineMediaType ( void ); + virtual bool CheckForDVDMediaType ( void ); + virtual bool CheckForCDMediaType ( void ); + virtual void PollForMedia ( void ); + virtual void EnablePolling ( void ); + virtual void DisablePolling ( void ); + virtual void CheckWriteProtection ( void ); + virtual bool ClearNotReadyStatus ( void ); + + virtual IOReturn GetDeviceConfiguration ( void ); + virtual IOReturn GetDeviceConfigurationSize ( UInt32 * size ); + virtual IOReturn ParseFeatureList ( UInt32 numProfiles, UInt8 * firstFeaturePtr ); + + virtual IOReturn GetMechanicalCapabilities ( void ); + virtual IOReturn GetMechanicalCapabilitiesSize ( UInt32 * size ); + virtual IOReturn ParseMechanicalCapabilities ( UInt8 * mechanicalCapabilitiesPtr ); + + virtual IOReturn CheckForLowPowerPollingSupport ( void ); + virtual IOReturn GetCurrentPowerStateOfDrive ( UInt32 * powerState ); + + virtual IOReturn IssueRead ( IOMemoryDescriptor * buffer, + UInt64 startBlock, + UInt64 blockCount ); + + virtual IOReturn IssueRead ( IOMemoryDescriptor * buffer, + void * clientData, + UInt64 startBlock, + UInt64 blockCount ); + + virtual IOReturn IssueWrite ( IOMemoryDescriptor * buffer, + UInt64 startBlock, + UInt64 blockCount ); + + virtual IOReturn IssueWrite ( IOMemoryDescriptor * buffer, + void * clientData, + UInt64 startBlock, + UInt64 blockCount ); + + virtual void SetMediaCharacteristics ( UInt32 blockSize, UInt32 blockCount ); + virtual void ResetMediaCharacteristics ( void ); + + UInt8 ConvertBCDToHex ( UInt8 binaryCodedDigit ); + + // ------ User Client Support ------ + + virtual IOReturn HandleSetUserClientExclusivityState ( IOService * userClient, bool state ); + + // ----- Power Management Support ------ + + // We override this method to set our power states and register ourselves + // as a power policy maker. + virtual void InitializePowerManagement ( IOService * provider ); + + // We override this method so that when we register for power management, + // we go to our active power state (which the drive is definitely in + // at startup time). + virtual UInt32 GetInitialPowerState ( void ); + + // We override this method in order to provide the number of transitions + // from Fully active to Sleep state so that the idle timer can be adjusted + // to the appropriate time period based on the disk spindown time set in + // the Energy Saver prefs panel. + virtual UInt32 GetNumberOfPowerStateTransitions ( void ); + + // The TicklePowerManager method is called to tell the power manager that the + // device needs to be in a certain power state to handle requests. + virtual void TicklePowerManager ( void ); + + // The HandlePowerChange method is the state machine for power management. + // It is guaranteed to be on its own thread of execution (different from + // the power manager thread AND the workloop thread. This routine can + // send sync or async calls to the drive without worrying about threading + // issues. + virtual void HandlePowerChange ( void ); + + // The HandleCheckPowerState (void) method is on the serialized side of the command + // gate and can change member variables safely without multi-threading issues. + // It's main purpose is to call the superclass' HandleCheckPowerState ( UInt32 maxPowerState ) + // with the max power state the class registered with. + virtual void HandleCheckPowerState ( void ); + + // The CheckMediaPresence method is called to see if the media which we + // anticipated being there is still there. + virtual bool CheckMediaPresence ( void ); + + virtual bool InitializeDeviceSupport ( void ); + virtual void StartDeviceSupport ( void ); + virtual void SuspendDeviceSupport ( void ); + virtual void ResumeDeviceSupport ( void ); + virtual void StopDeviceSupport ( void ); + virtual void TerminateDeviceSupport ( void ); + + virtual void free ( void ); + +#ifndef __LP64__ + + virtual bool CreateCommandSetObjects ( void ); + virtual void FreeCommandSetObjects ( void ); + +#endif /* !__LP64__ */ + + virtual IOReturn VerifyDeviceState ( void ); + + +public: + + virtual IOReturn setAggressiveness ( unsigned long type, unsigned long minutes ); + + virtual IOReturn SyncReadWrite ( IOMemoryDescriptor * buffer, + UInt64 startBlock, + UInt64 blockCount ); + + virtual IOReturn AsyncReadWrite ( IOMemoryDescriptor * buffer, + UInt64 block, + UInt64 nblks, + void * clientData ); + + virtual IOReturn EjectTheMedia ( void ); + virtual IOReturn GetTrayState ( UInt8 * trayState ); + virtual IOReturn SetTrayState ( UInt8 trayState ); + virtual IOReturn FormatMedia ( UInt64 byteCapacity ); + virtual UInt32 GetFormatCapacities ( UInt64 * capacities, + UInt32 capacitiesMaxCount ) const; + virtual IOReturn LockUnlockMedia ( bool doLock ); + virtual IOReturn SynchronizeCache ( void ); + virtual IOReturn ReportBlockSize ( UInt64 * blockSize ); + virtual IOReturn ReportEjectability ( bool * isEjectable ); + virtual IOReturn ReportLockability ( bool * isLockable ); + virtual IOReturn ReportPollRequirements ( bool * pollIsRequired, + bool * pollIsExpensive ); + virtual IOReturn ReportMaxReadTransfer ( UInt64 blockSize, + UInt64 * max ); + virtual IOReturn ReportMaxValidBlock ( UInt64 * maxBlock ); + virtual IOReturn ReportMaxWriteTransfer ( UInt64 blockSize, + UInt64 * max ); + virtual IOReturn ReportMediaState ( bool * mediaPresent, + bool * changed ); + virtual IOReturn ReportRemovability ( bool * isRemovable ); + virtual IOReturn ReportWriteProtection ( bool * isWriteProtected ); + + static void sPollForMedia ( void * pdtDriver, void * refCon ); + + /* CD Specific */ + virtual IOReturn SetMediaAccessSpeed ( UInt16 kilobytesPerSecond ); + + virtual IOReturn GetMediaAccessSpeed ( UInt16 * kilobytesPerSecond ); + + virtual IOReturn AsyncReadCD ( IOMemoryDescriptor * buffer, + UInt32 block, + UInt32 nblks, + CDSectorArea sectorArea, + CDSectorType sectorType, + void * clientData ); + + virtual IOReturn ReadISRC ( UInt8 track, CDISRC isrc ); + + virtual IOReturn ReadMCN ( CDMCN mcn); + + virtual IOReturn ReadTOC ( IOMemoryDescriptor * buffer ); + +#ifndef __LP64__ + + virtual IOReturn AudioPause ( bool pause ); + + virtual IOReturn AudioPlay ( CDMSF timeStart, CDMSF timeStop ); + + virtual IOReturn AudioScan ( CDMSF timeStart, bool reverse ); + + virtual IOReturn AudioStop ( void ); + + virtual IOReturn GetAudioStatus ( CDAudioStatus * status ); + + virtual IOReturn GetAudioVolume ( UInt8 * leftVolume, UInt8 * rightVolume ); + + virtual IOReturn SetAudioVolume ( UInt8 leftVolume, UInt8 rightVolume ); + +#endif /* !__LP64__ */ + + /* DVD Specific */ + virtual UInt32 GetMediaType ( void ); + + virtual IOReturn ReportKey ( IOMemoryDescriptor * buffer, + const DVDKeyClass keyClass, + const UInt32 lba, + const UInt8 agid, + const DVDKeyFormat keyFormat ); + + virtual IOReturn SendKey ( IOMemoryDescriptor * buffer, + const DVDKeyClass keyClass, + const UInt8 agid, + const DVDKeyFormat keyFormat ); + + virtual IOReturn ReadDVDStructure ( IOMemoryDescriptor * buffer, + const UInt32 length, + const UInt8 structureFormat, + const UInt32 logicalBlockAddress, + const UInt8 layer, + const UInt8 agid ); + + // The block size decoding for Read CD and Read CD MSF as defined in table 255 + bool GetBlockSize ( + UInt32 * requestedByteCount, + SCSICmdField3Bit EXPECTED_SECTOR_TYPE, + SCSICmdField1Bit SYNC, + SCSICmdField2Bit HEADER_CODES, + SCSICmdField1Bit USER_DATA, + SCSICmdField1Bit EDC_ECC, + SCSICmdField2Bit ERROR_FIELD, + SCSICmdField3Bit SUBCHANNEL_SELECTION_BITS ); + + SCSICmdField4Byte ConvertMSFToLBA ( SCSICmdField3Byte MSF ); + +#ifndef __LP64__ + + // Command methods to access all commands available to MMC based devices. + // The BLANK command as defined in section 6.1.1 + virtual bool BLANK ( + SCSITaskIdentifier request, + SCSICmdField1Bit IMMED, + SCSICmdField3Bit BLANKING_TYPE, + SCSICmdField4Byte START_ADDRESS_TRACK_NUMBER, + SCSICmdField1Byte CONTROL ); + + // The CLOSE TRACK/SESSION command as defined in section 6.1.2 + virtual bool CLOSE_TRACK_SESSION ( + SCSITaskIdentifier request, + SCSICmdField1Bit IMMED, + SCSICmdField1Bit SESSION, + SCSICmdField1Bit TRACK, + SCSICmdField2Byte TRACK_NUMBER, + SCSICmdField1Byte CONTROL ); + + // The FORMAT UNIT command as defined in section 6.1.3 + virtual bool FORMAT_UNIT ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + IOByteCount parameterListSize, + SCSICmdField1Bit FMT_DATA, + SCSICmdField1Bit CMP_LIST, + SCSICmdField3Bit FORMAT_CODE, + SCSICmdField2Byte INTERLEAVE_VALUE, + SCSICmdField1Byte CONTROL ); + +#endif /* !__LP64__ */ + + + // The GET CONFIGURATION command as defined in section 6.1.4 + virtual bool GET_CONFIGURATION ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField2Bit RT, + SCSICmdField2Byte STARTING_FEATURE_NUMBER, + SCSICmdField2Byte ALLOCATION_LENGTH, + SCSICmdField1Byte CONTROL ); + + // The GET EVENT/STATUS NOTIFICATION command as defined in section 6.1.5 + virtual bool GET_EVENT_STATUS_NOTIFICATION ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Bit IMMED, + SCSICmdField1Byte NOTIFICATION_CLASS_REQUEST, + SCSICmdField2Byte ALLOCATION_LENGTH, + SCSICmdField1Byte CONTROL ); + + // The GET PERFORMANCE command as defined in section 6.1.6 + virtual bool GET_PERFORMANCE ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField2Bit TOLERANCE, + SCSICmdField1Bit WRITE, + SCSICmdField2Bit EXCEPT, + SCSICmdField4Byte STARTING_LBA, + SCSICmdField2Byte MAXIMUM_NUMBER_OF_DESCRIPTORS, + SCSICmdField1Byte CONTROL ); + + // The LOAD/UNLOAD MEDIUM command as defined in section 6.1.7 + virtual bool LOAD_UNLOAD_MEDIUM ( + SCSITaskIdentifier request, + SCSICmdField1Bit IMMED, + SCSICmdField1Bit LO_UNLO, + SCSICmdField1Bit START, + SCSICmdField1Byte SLOT, + SCSICmdField1Byte CONTROL ); + + // The MECHANISM STATUS command as defined in section 6.1.8 + virtual bool MECHANISM_STATUS ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField2Byte ALLOCATION_LENGTH, + SCSICmdField1Byte CONTROL ); + +#ifndef __LP64__ + + // The PAUSE/RESUME command as defined in section 6.1.9 + virtual bool PAUSE_RESUME ( + SCSITaskIdentifier request, + SCSICmdField1Bit RESUME, + SCSICmdField1Byte CONTROL ); + + // The PLAY AUDIO (10) command as defined in section 6.1.10 + virtual bool PLAY_AUDIO_10 ( + SCSITaskIdentifier request, + SCSICmdField1Bit RELADR, + SCSICmdField4Byte STARTING_LOGICAL_BLOCK_ADDRESS, + SCSICmdField2Byte PLAY_LENGTH, + SCSICmdField1Byte CONTROL ); + + // The PLAY AUDIO (12) command as defined in section 6.1.11 + virtual bool PLAY_AUDIO_12 ( + SCSITaskIdentifier request, + SCSICmdField1Bit RELADR, + SCSICmdField4Byte STARTING_LOGICAL_BLOCK_ADDRESS, + SCSICmdField4Byte PLAY_LENGTH, + SCSICmdField1Byte CONTROL ); + + // The PLAY AUDIO MSF command as defined in section 6.1.12 + virtual bool PLAY_AUDIO_MSF ( + SCSITaskIdentifier request, + SCSICmdField3Byte STARTING_MSF, + SCSICmdField3Byte ENDING_MSF, + SCSICmdField1Byte CONTROL ); + + /*********************** LEGACY COMMAND SUPPORT ***********************/ + // The PLAY CD command as defined in section 6.1.13 + virtual bool PLAY_CD ( + SCSITaskIdentifier request, + SCSICmdField3Bit EXPECTED_SECTOR_TYPE, + SCSICmdField1Bit CMSF, + SCSICmdField4Byte STARTING_LOGICAL_BLOCK_ADDRESS, + SCSICmdField4Byte PLAY_LENGTH_IN_BLOCKS, + SCSICmdField1Bit SPEED, + SCSICmdField1Bit PORT2, + SCSICmdField1Bit PORT1, + SCSICmdField1Bit COMPOSITE, + SCSICmdField1Bit AUDIO, + SCSICmdField1Byte CONTROL ); + /*********************** END LEGACY COMMAND SUPPORT *******************/ + +#endif /* !__LP64__ */ + + virtual bool READ_10 ( + SCSITaskIdentifier request, + IOMemoryDescriptor *dataBuffer, + UInt32 blockSize, + SCSICmdField1Bit DPO, + SCSICmdField1Bit FUA, + SCSICmdField1Bit RELADR, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField2Byte TRANSFER_LENGTH, + SCSICmdField1Byte CONTROL ); + +#ifndef __LP64__ + + /*********************** LEGACY COMMAND SUPPORT ***********************/ + // The READ BUFFER CAPACITY command as defined in section 6.1.14 + virtual bool READ_BUFFER_CAPACITY ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField2Byte ALLOCATION_LENGTH, + SCSICmdField1Byte CONTROL ); + /*********************** END LEGACY COMMAND SUPPORT *******************/ + +#endif /* !__LP64__ */ + + // The READ CD command as defined in section 6.1.15 + virtual bool READ_CD ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField3Bit EXPECTED_SECTOR_TYPE, + SCSICmdField1Bit RELADR, + SCSICmdField4Byte STARTING_LOGICAL_BLOCK_ADDRESS, + SCSICmdField3Byte TRANSFER_LENGTH, + SCSICmdField1Bit SYNC, + SCSICmdField2Bit HEADER_CODES, + SCSICmdField1Bit USER_DATA, + SCSICmdField1Bit EDC_ECC, + SCSICmdField2Bit ERROR_FIELD, + SCSICmdField3Bit SUBCHANNEL_SELECTION_BITS, + SCSICmdField1Byte CONTROL ); + + // The READ CD MSF command as defined in section 6.1.16 + virtual bool READ_CD_MSF ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField3Bit EXPECTED_SECTOR_TYPE, + SCSICmdField3Byte STARTING_MSF, + SCSICmdField3Byte ENDING_MSF, + SCSICmdField1Bit SYNC, + SCSICmdField2Bit HEADER_CODES, + SCSICmdField1Bit USER_DATA, + SCSICmdField1Bit EDC_ECC, + SCSICmdField2Bit ERROR_FIELD, + SCSICmdField3Bit SUBCHANNEL_SELECTION_BITS, + SCSICmdField1Byte CONTROL ); + + // The READ CAPACITY command as defined in section 6.1.17 + virtual bool READ_CAPACITY ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Bit RELADR, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField1Bit PMI, + SCSICmdField1Byte CONTROL ); + + // The READ DISC INFORMATION command as defined in section 6.1.18 + virtual bool READ_DISC_INFORMATION ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField2Byte ALLOCATION_LENGTH, + SCSICmdField1Byte CONTROL ); + + // The READ DVD STRUCTURE command as defined in section 6.1.19 + virtual bool READ_DVD_STRUCTURE ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField4Byte ADDRESS, + SCSICmdField1Byte LAYER_NUMBER, + SCSICmdField1Byte FORMAT, + SCSICmdField2Byte ALLOCATION_LENGTH, + SCSICmdField2Bit AGID, + SCSICmdField1Byte CONTROL ); + + // The READ FORMAT CAPACITIES command as defined in section 6.1.20 + virtual bool READ_FORMAT_CAPACITIES ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField2Byte ALLOCATION_LENGTH, + SCSICmdField1Byte CONTROL ); + +#ifndef __LP64__ + + /*********************** LEGACY COMMAND SUPPORT ***********************/ + // The READ HEADER command as defined in section 6.1.21 + virtual bool READ_HEADER ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Bit MSF, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField2Byte ALLOCATION_LENGTH, + SCSICmdField1Byte CONTROL ); + /*********************** END LEGACY COMMAND SUPPORT ***********************/ + + /*********************** LEGACY COMMAND SUPPORT ***********************/ + // The READ MASTER CUE command as defined in section 6.1.22 + virtual bool READ_MASTER_CUE ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Byte SHEET_NUMBER, + SCSICmdField3Byte ALLOCATION_LENGTH, + SCSICmdField1Byte CONTROL ); + /*********************** END LEGACY COMMAND SUPPORT ***********************/ + +#endif /* !__LP64__ */ + + // The READ SUB-CHANNEL command as defined in section 6.1.23 + virtual bool READ_SUB_CHANNEL ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Bit MSF, + SCSICmdField1Bit SUBQ, + SCSICmdField1Byte SUB_CHANNEL_PARAMETER_LIST, + SCSICmdField1Byte TRACK_NUMBER, + SCSICmdField2Byte ALLOCATION_LENGTH, + SCSICmdField1Byte CONTROL ); + + // The READ TOC/PMA/ATIP command as defined in section 6.1.24/25 + virtual bool READ_TOC_PMA_ATIP ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Bit MSF, + SCSICmdField4Bit FORMAT, + SCSICmdField1Byte TRACK_SESSION_NUMBER, + SCSICmdField2Byte ALLOCATION_LENGTH, + SCSICmdField1Byte CONTROL ); + + // The READ TRACK INFORMATION command as defined in section 6.1.26 + virtual bool READ_TRACK_INFORMATION ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField2Bit ADDRESS_NUMBER_TYPE, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS_TRACK_SESSION_NUMBER, + SCSICmdField2Byte ALLOCATION_LENGTH, + SCSICmdField1Byte CONTROL ); + +#ifndef __LP64__ + /*********************** LEGACY COMMAND SUPPORT ***********************/ + // The REPAIR TRACK command as defined in section 6.1.27 + virtual bool REPAIR_TRACK ( + SCSITaskIdentifier request, + SCSICmdField2Byte TRACK_NUMBER, + SCSICmdField1Byte CONTROL ); + /*********************** END LEGACY COMMAND SUPPORT ***********************/ + + // The REPORT KEY command as defined in section 6.1.28 + virtual bool REPORT_KEY ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField2Byte ALLOCATION_LENGTH, + SCSICmdField2Bit AGID, + SCSICmdField6Bit KEY_FORMAT, + SCSICmdField1Byte CONTROL ); + + // The RESERVE TRACK command as defined in section 6.1.29 + virtual bool RESERVE_TRACK ( + SCSITaskIdentifier request, + SCSICmdField4Byte RESERVATION_SIZE, + SCSICmdField1Byte CONTROL ); + + // The SCAN command as defined in section 6.1.30 + virtual bool SCAN ( + SCSITaskIdentifier request, + SCSICmdField1Bit DIRECT, + SCSICmdField1Bit RELADR, + SCSICmdField4Byte SCAN_STARTING_ADDRESS_FIELD, + SCSICmdField2Bit TYPE, + SCSICmdField1Byte CONTROL ); + + // The SEND CUE SHEET command as defined in section 6.1.31 + virtual bool SEND_CUE_SHEET ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField3Byte CUE_SHEET_SIZE, + SCSICmdField1Byte CONTROL ); + + // The SEND DVD STRUCTURE command as defined in section 6.1.32 + virtual bool SEND_DVD_STRUCTURE ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Byte FORMAT, + SCSICmdField2Byte STRUCTURE_DATA_LENGTH, + SCSICmdField1Byte CONTROL ); + + // The SEND EVENT command as defined in section 6.1.33 + virtual bool SEND_EVENT ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Bit IMMED, + SCSICmdField2Byte PARAMETER_LIST_LENGTH, + SCSICmdField1Byte CONTROL ); + + // The SEND KEY command as defined in section 6.1.34 + virtual bool SEND_KEY ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField2Byte PARAMETER_LIST_LENGTH, + SCSICmdField2Bit AGID, + SCSICmdField6Bit KEY_FORMAT, + SCSICmdField1Byte CONTROL ); + + // The SEND OPC INFORMATION command as defined in section 6.1.35 + virtual bool SEND_OPC_INFORMATION ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Bit DO_OPC, + SCSICmdField2Byte PARAMETER_LIST_LENGTH, + SCSICmdField1Byte CONTROL ); +#endif /* !__LP64__ */ + + /*********************** LEGACY COMMAND SUPPORT ***********************/ + // The SET CD SPEED command as defined in section 6.1.36 + virtual bool SET_CD_SPEED ( + SCSITaskIdentifier request, + SCSICmdField2Byte LOGICAL_UNIT_READ_SPEED, + SCSICmdField2Byte LOGICAL_UNIT_WRITE_SPEED, + SCSICmdField1Byte CONTROL ); + /*********************** END LEGACY COMMAND SUPPORT ***********************/ + + // The SET READ AHEAD command as defined in section 6.1.37 + virtual bool SET_READ_AHEAD ( + SCSITaskIdentifier request, + SCSICmdField4Byte TRIGGER_LOGICAL_BLOCK_ADDRESS, + SCSICmdField4Byte READ_AHEAD_LOGICAL_BLOCK_ADDRESS, + SCSICmdField1Byte CONTROL ); + + // The SET STREAMING command as defined in section 6.1.38 + virtual bool SET_STREAMING ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField2Byte PARAMETER_LIST_LENGTH, + SCSICmdField1Byte CONTROL ); + + virtual bool START_STOP_UNIT ( + SCSITaskIdentifier request, + SCSICmdField1Bit IMMED, + SCSICmdField4Bit POWER_CONDITIONS, + SCSICmdField1Bit LOEJ, + SCSICmdField1Bit START, + SCSICmdField1Byte CONTROL ); + +#ifndef __LP64__ + + // The STOP PLAY/SCAN command as defined in section 6.1.39 + virtual bool STOP_PLAY_SCAN ( + SCSITaskIdentifier request, + SCSICmdField1Byte CONTROL ); + +#endif /* !__LP64__ */ + + // The SYNCHRONIZE CACHE command as defined in section 6.1.40 + virtual bool SYNCHRONIZE_CACHE ( + SCSITaskIdentifier request, + SCSICmdField1Bit IMMED, + SCSICmdField1Bit RELADR, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField2Byte NUMBER_OF_BLOCKS, + SCSICmdField1Byte CONTROL ); + + // The WRITE (10) command as defined in section 6.1.41 + virtual bool WRITE_10 ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + UInt32 blockSize, + SCSICmdField1Bit DPO, + SCSICmdField1Bit FUA, + SCSICmdField1Bit RELADR, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField2Byte TRANSFER_LENGTH, + SCSICmdField1Byte CONTROL ); + + // The WRITE AND VERIFY (10) command as defined in section 6.1.42 + virtual bool WRITE_AND_VERIFY_10 ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + UInt32 blockSize, + SCSICmdField1Bit DPO, + SCSICmdField1Bit BYT_CHK, + SCSICmdField1Bit RELADR, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField4Byte TRANSFER_LENGTH, + SCSICmdField1Byte CONTROL ); + + /* Added with 10.1.3 */ + OSMetaClassDeclareReservedUsed ( IOSCSIMultimediaCommandsDevice, 1 ); + + virtual IOReturn ReadTOC ( IOMemoryDescriptor * buffer, + CDTOCFormat format, + UInt8 msf, + UInt32 trackSessionNumber, + UInt16 * actualByteCount ); + + /* Added with 10.1.3 */ + OSMetaClassDeclareReservedUsed ( IOSCSIMultimediaCommandsDevice, 2 ); + + virtual IOReturn ReadDiscInfo ( IOMemoryDescriptor * buffer, + UInt16 * actualByteCount ); + + /* Added with 10.1.3 */ + OSMetaClassDeclareReservedUsed ( IOSCSIMultimediaCommandsDevice, 3 ); + + virtual IOReturn ReadTrackInfo ( IOMemoryDescriptor * buffer, + UInt32 address, + CDTrackInfoAddressType addressType, + UInt16 * actualByteCount ); + + /* Added with 10.2 */ + OSMetaClassDeclareReservedUsed ( IOSCSIMultimediaCommandsDevice, 4 ); + + virtual IOReturn PowerDownHandler ( void * refCon, + UInt32 messageType, + IOService * provider, + void * messageArgument, + vm_size_t argSize ); + + /* Added with 10.3.3 */ + OSMetaClassDeclareReservedUsed ( IOSCSIMultimediaCommandsDevice, 5 ); + + +protected: + + + virtual void AsyncReadWriteCompletion ( SCSITaskIdentifier completedTask ); + + +public: + + + /* Added with 10.5 */ + OSMetaClassDeclareReservedUsed ( IOSCSIMultimediaCommandsDevice, 6 ); + + virtual IOReturn ReadDiscStructure ( IOMemoryDescriptor * buffer, + const UInt32 length, + const UInt8 structureFormat, + const UInt32 logicalBlockAddress, + const UInt8 layer, + const UInt8 agid, + const UInt8 mediaType ); + + + bool CheckForBDMediaType ( void ); + + + bool READ_DISC_STRUCTURE ( + SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField4Bit MEDIA_TYPE, + SCSICmdField4Byte ADDRESS, + SCSICmdField1Byte LAYER_NUMBER, + SCSICmdField1Byte FORMAT, + SCSICmdField2Byte ALLOCATION_LENGTH, + SCSICmdField2Bit AGID, + SCSICmdField1Byte CONTROL ); + + + OSMetaClassDeclareReservedUsed ( IOSCSIMultimediaCommandsDevice, 7 ); + + virtual IOReturn ReserveTrack ( UInt8 reservationType, + UInt8 reservationFormat, + UInt64 ReservationParameter ); + + + bool RESERVE_TRACK_V2 ( SCSITaskIdentifier request, + SCSICmdField1Bit RMZ, + SCSICmdField1Bit ARSV, + SCSICmdField7Byte RESERVATION_PARAMETER, + SCSICmdField1Byte CONTROL ); + + + bool REPORT_KEY_V2 ( SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS, + SCSICmdField1Byte KEY_CLASS, + SCSICmdField2Byte ALLOCATION_LENGTH, + SCSICmdField2Bit AGID, + SCSICmdField6Bit KEY_FORMAT, + SCSICmdField1Byte CONTROL ); + + + bool SEND_KEY_V2 ( SCSITaskIdentifier request, + IOMemoryDescriptor * dataBuffer, + SCSICmdField1Byte KEY_CLASS, + SCSICmdField2Byte PARAMETER_LIST_LENGTH, + SCSICmdField2Bit AGID, + SCSICmdField6Bit KEY_FORMAT, + SCSICmdField1Byte CONTROL ); + + +protected: + + + void SetPollingMode ( UInt32 newPollingMode ); + + +public: + + + /* 10.6.0 */ + + IOReturn RequestIdle ( void ); + +private: + + // Space reserved for future expansion. + OSMetaClassDeclareReservedUnused ( IOSCSIMultimediaCommandsDevice, 8 ); + OSMetaClassDeclareReservedUnused ( IOSCSIMultimediaCommandsDevice, 9 ); + OSMetaClassDeclareReservedUnused ( IOSCSIMultimediaCommandsDevice, 10 ); + OSMetaClassDeclareReservedUnused ( IOSCSIMultimediaCommandsDevice, 11 ); + OSMetaClassDeclareReservedUnused ( IOSCSIMultimediaCommandsDevice, 12 ); + OSMetaClassDeclareReservedUnused ( IOSCSIMultimediaCommandsDevice, 13 ); + OSMetaClassDeclareReservedUnused ( IOSCSIMultimediaCommandsDevice, 14 ); + OSMetaClassDeclareReservedUnused ( IOSCSIMultimediaCommandsDevice, 15 ); + OSMetaClassDeclareReservedUnused ( IOSCSIMultimediaCommandsDevice, 16 ); + +}; + +#endif /* defined(KERNEL) && defined(__cplusplus) */ + +#endif /* _IOKIT_IO_SCSI_MULTIMEDIA_COMMANDS_DEVICE_H_ */ Index: branches/azimutz/Cleancut/i386/include/IOKit/scsi/SCSICmds_MODE_Definitions.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/scsi/SCSICmds_MODE_Definitions.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/scsi/SCSICmds_MODE_Definitions.h (revision 885) @@ -0,0 +1,559 @@ +/* + * 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_SCSI_CMDS_MODE_DEFINITIONS_H_ +#define _IOKIT_SCSI_CMDS_MODE_DEFINITIONS_H_ + + +//----------------------------------------------------------------------------- +// Includes +//----------------------------------------------------------------------------- + +#if KERNEL +#include <IOKit/IOTypes.h> +#else +#include <CoreFoundation/CoreFoundation.h> +#endif + + +/*! @header SCSI Request Sense Definitions + @discussion + This file contains all definitions for the data returned from + the MODE_SENSE_6 and MODE_SENSE_10 commands. +*/ + +#pragma pack(1) + +/*! +@struct SPCModeParameterHeader6 +@discussion +Mode Parameter Header for the MODE_SENSE_6 command. +*/ +typedef struct SPCModeParameterHeader6 +{ + UInt8 MODE_DATA_LENGTH; + UInt8 MEDIUM_TYPE; + UInt8 DEVICE_SPECIFIC_PARAMETER; + UInt8 BLOCK_DESCRIPTOR_LENGTH; +} SPCModeParameterHeader6; + + +/*! +@struct SPCModeParameterHeader10 +@discussion +Mode Parameter Header for the MODE_SENSE_10 command. +*/ +typedef struct SPCModeParameterHeader10 +{ + UInt16 MODE_DATA_LENGTH; + UInt8 MEDIUM_TYPE; + UInt8 DEVICE_SPECIFIC_PARAMETER; + UInt8 LONGLBA; + UInt8 RESERVED; + UInt16 BLOCK_DESCRIPTOR_LENGTH; +} SPCModeParameterHeader10; + + +/*! +@enum Long LBA Bitfield definitions +@discussion +Long LBA Bitfield definitions for Mode Parameter Header +for MODE_SENSE_10 command. +@constant kModeSenseParameterHeader10_LongLBABit +Bit to indicate Long LBA block descriptors follow. +@constant kModeSenseParameterHeader10_LongLBAMask +Mask to test for kModeSenseParameterHeader10_LongLBABit. +*/ +enum +{ + kModeSenseParameterHeader10_LongLBABit = 0, + kModeSenseParameterHeader10_LongLBAMask = (1 << kModeSenseParameterHeader10_LongLBABit), +}; + + +/*! +@enum Device Specific Parameter Bitfield definitions +@discussion +SBC definitions for Device Specific Parameter in the +Mode Sense Header Block. +@constant kModeSenseSBCDeviceSpecific_DPOFUABit +Bit to indicate DPO and FUA bits are accepted by the device server. +@constant kModeSenseSBCDeviceSpecific_WriteProtectBit +Bit to indicate medium is write protected. +@constant kModeSenseSBCDeviceSpecific_DPOFUAMask +Mask to test for kModeSenseSBCDeviceSpecific_DPOFUABit. +@constant kModeSenseSBCDeviceSpecific_WriteProtectMask +Mask to test for kModeSenseSBCDeviceSpecific_WriteProtectBit. +*/ +enum +{ + kModeSenseSBCDeviceSpecific_DPOFUABit = 4, + kModeSenseSBCDeviceSpecific_WriteProtectBit = 7, + kModeSenseSBCDeviceSpecific_DPOFUAMask = (1 << kModeSenseSBCDeviceSpecific_DPOFUABit), + kModeSenseSBCDeviceSpecific_WriteProtectMask = (1 << kModeSenseSBCDeviceSpecific_WriteProtectBit) +}; + + +/*! +@struct ModeParameterBlockDescriptor +@discussion +General mode parameter block descriptor. +*/ +typedef struct ModeParameterBlockDescriptor +{ + UInt8 DENSITY_CODE; + UInt8 NUMBER_OF_BLOCKS[3]; + UInt8 RESERVED; + UInt8 BLOCK_LENGTH[3]; +} ModeParameterBlockDescriptor; + + +/*! +@struct DASDModeParameterBlockDescriptor +@discussion +Direct Access Storage Device mode parameter block descriptor. +*/ +typedef struct DASDModeParameterBlockDescriptor +{ + UInt32 NUMBER_OF_BLOCKS; + UInt8 DENSITY_CODE; + UInt8 BLOCK_LENGTH[3]; +} DASDModeParameterBlockDescriptor; + + +/*! +@struct LongLBAModeParameterBlockDescriptor +@discussion +Long LBA mode parameter block descriptor. +*/ +typedef struct LongLBAModeParameterBlockDescriptor +{ + UInt64 NUMBER_OF_BLOCKS; + UInt8 DENSITY_CODE; + UInt8 RESERVED[3]; + UInt32 BLOCK_LENGTH; +} LongLBAModeParameterBlockDescriptor; + + +/*! +@struct ModePageFormatHeader +@discussion +Mode Page format header. +*/ +typedef struct ModePageFormatHeader +{ + UInt8 PS_PAGE_CODE; + UInt8 PAGE_LENGTH; +} ModePageFormatHeader; + + +/*! +@enum Mode Page Format bit definitions +@discussion +Mode Page Format bit definitions. +@constant kModePageFormat_PS_Bit +Bit to indicate Parameters Saveable. +@constant kModePageFormat_PAGE_CODE_Mask +Mask to obtain the PAGE_CODE from the PS_PAGE_CODE field. +@constant kModePageFormat_PS_Mask +Mask to test for kModePageFormat_PS_Bit. +*/ +enum +{ + kModePageFormat_PS_Bit = 7, + + kModePageFormat_PAGE_CODE_Mask = 0x3F, + kModePageFormat_PS_Mask = (1 << kModePageFormat_PS_Bit) +}; + + +#if 0 +#pragma mark - +#pragma mark SPC Mode Pages +#pragma mark - +#endif + + +/*! +@enum SPC Mode Pages +@discussion +SPC Mode Page definitions. +@constant kSPCModePagePowerConditionCode +Power Conditions Mode Page value. +@constant kSPCModePageAllPagesCode +All Mode Pages value. +*/ +enum +{ + kSPCModePagePowerConditionCode = 0x1A, + kSPCModePageAllPagesCode = 0x3F +}; + +/*! +@struct SPCModePagePowerCondition +@discussion +Power Conditions Mode Page (PAGE CODE 0x1A) format. +*/ +typedef struct SPCModePagePowerCondition +{ + ModePageFormatHeader header; + UInt8 RESERVED; + UInt8 IDLE_STANDBY; + UInt32 IDLE_CONDITION_TIMER; + UInt32 STANDBY_CONDITION_TIMER; +} SPCModePagePowerCondition; + + +#if 0 +#pragma mark - +#pragma mark 0x00 SBC Direct Access Mode Pages +#pragma mark - +#endif + + +/*! +@enum SBC Mode Pages +@discussion +SBC Mode Page definitions. +@constant kSBCModePageFormatDeviceCode +Format Device Mode Page value. +@constant kSBCModePageRigidDiskGeometryCode +Rigid Disk Geometry Page value. +@constant kSBCModePageFlexibleDiskCode +Flexible Disk Page value. +@constant kSBCModePageCachingCode +Caching Page value. +*/ +enum +{ + kSBCModePageFormatDeviceCode = 0x03, + kSBCModePageRigidDiskGeometryCode = 0x04, + kSBCModePageFlexibleDiskCode = 0x05, + kSBCModePageCachingCode = 0x08 +}; + + +/*! +@struct SBCModePageFormatDevice +@discussion +Format Device Mode Page (PAGE CODE 0x03) format. +*/ +typedef struct SBCModePageFormatDevice +{ + ModePageFormatHeader header; + UInt16 TRACKS_PER_ZONE; + UInt16 ALTERNATE_SECTORS_PER_ZONE; + UInt16 ALTERNATE_TRACKS_PER_ZONE; + UInt16 ALTERNATE_TRACKS_PER_LOGICAL_UNIT; + UInt16 SECTORS_PER_TRACK; + UInt16 DATA_BYTES_PER_PHYSICAL_SECTOR; + UInt16 INTERLEAVE; + UInt16 TRACK_SKEW_FACTOR; + UInt16 CYLINDER_SKEW_FACTOR; + UInt8 SSEC_HSEC_RMB_SURF; + UInt8 RESERVED[3]; +} SBCModePageFormatDevice; + + +/*! +@struct SBCModePageRigidDiskGeometry +@discussion +Rigid Disk Geometry Mode Page (PAGE CODE 0x04) format. +*/ +typedef struct SBCModePageRigidDiskGeometry +{ + ModePageFormatHeader header; + UInt8 NUMBER_OF_CYLINDERS[3]; + UInt8 NUMBER_OF_HEADS; + UInt8 STARTING_CYLINDER_WRITE_PRECOMPENSATION[3]; + UInt8 STARTING_CYLINDER_REDUCED_WRITE_CURRENT[3]; + UInt16 DEVICE_STEP_RATE; + UInt8 LANDING_ZONE_CYLINDER[3]; + UInt8 RPL; + UInt8 ROTATIONAL_OFFSET; + UInt8 RESERVED; + UInt16 MEDIUM_ROTATION_RATE; + UInt8 RESERVED1[2]; +} SBCModePageRigidDiskGeometry; + + +/*! +@enum Rigid Disk Geometry bitfields +@discussion +Bit field masks for Rigid Disk Geometry structure fields. +@constant kSBCModePageRigidDiskGeometry_RPL_Mask +Mask for use with the RPL field. +*/ +enum +{ + kSBCModePageRigidDiskGeometry_RPL_Mask = 0x03 +}; + + +/*! +@struct SBCModePageFlexibleDisk +@discussion +Flexible Disk Mode Page (PAGE CODE 0x05) format. +*/ +typedef struct SBCModePageFlexibleDisk +{ + ModePageFormatHeader header; + UInt16 TRANSFER_RATE; + UInt8 NUMBER_OF_HEADS; + UInt8 SECTORS_PER_TRACK; + UInt16 DATA_BYTES_PER_SECTOR; + UInt16 NUMBER_OF_CYLINDERS; + UInt16 STARTING_CYLINDER_WRITE_PRECOMPENSATION; + UInt16 STARTING_CYLINDER_REDUCED_WRITE_CURRENT; + UInt16 DEVICE_STEP_RATE; + UInt8 DEVICE_STEP_PULSE_WIDTH; + UInt16 HEAD_SETTLE_DELAY; + UInt8 MOTOR_ON_DELAY; + UInt8 MOTOR_OFF_DELAY; + UInt8 TRDY_SSN_MO; + UInt8 SPC; + UInt8 WRITE_COMPENSATION; + UInt8 HEAD_LOAD_DELAY; + UInt8 HEAD_UNLOAD_DELAY; + UInt8 PIN_34_PIN_2; + UInt8 PIN_4_PIN_1; + UInt16 MEDIUM_ROTATION_RATE; + UInt8 RESERVED[2]; +} SBCModePageFlexibleDisk; + + +/*! +@enum TRDY_SSN_MO bitfields +@discussion +Bit field definitions and masks for Flexible Disk TRDY_SSN_MO field. +@constant kSBCModePageFlexibleDisk_MO_Bit +MO Bit definition. +@constant kSBCModePageFlexibleDisk_SSN_Bit +SSN Bit definition. +@constant kSBCModePageFlexibleDisk_TRDY_Bit +TRDY Bit definition. +@constant kSBCModePageFlexibleDisk_MO_Mask +Mask for use with TRDY_SSN_MO field. +@constant kSBCModePageFlexibleDisk_SSN_Mask +Mask for use with TRDY_SSN_MO field. +@constant kSBCModePageFlexibleDisk_TRDY_Mask +Mask for use with TRDY_SSN_MO field. +*/ +enum +{ + // Bits 0:4 Reserved + kSBCModePageFlexibleDisk_MO_Bit = 5, + kSBCModePageFlexibleDisk_SSN_Bit = 6, + kSBCModePageFlexibleDisk_TRDY_Bit = 7, + + kSBCModePageFlexibleDisk_MO_Mask = (1 << kSBCModePageFlexibleDisk_MO_Bit), + kSBCModePageFlexibleDisk_SSN_Mask = (1 << kSBCModePageFlexibleDisk_SSN_Bit), + kSBCModePageFlexibleDisk_TRDY_Mask = (1 << kSBCModePageFlexibleDisk_TRDY_Bit) +}; + + +/*! +@enum SPC bitfields +@discussion +Bit field definitions and masks for Flexible Disk SPC field. +@constant kSBCModePageFlexibleDisk_SPC_Mask +Mask for use with SPC field. +*/ +enum +{ + kSBCModePageFlexibleDisk_SPC_Mask = 0x0F +}; + + +/*! +@enum PIN_34_PIN_2 bitfields +@discussion +Bit field definitions and masks for Flexible Disk PIN_34_PIN_2 field. +@constant kSBCModePageFlexibleDisk_PIN_2_Mask +Mask for use with PIN_34_PIN_2 field. +@constant kSBCModePageFlexibleDisk_PIN_34_Mask +Mask for use with PIN_34_PIN_2 field. +*/ +enum +{ + kSBCModePageFlexibleDisk_PIN_2_Mask = 0x0F, + kSBCModePageFlexibleDisk_PIN_34_Mask = 0xF0 +}; + + +/*! +@enum PIN_4_PIN_1 bitfields +@discussion +Bit field definitions and masks for Flexible Disk PIN_4_PIN_1 field. +@constant kSBCModePageFlexibleDisk_PIN_1_Mask +Mask for use with PIN_4_PIN_1 field. +@constant kSBCModePageFlexibleDisk_PIN_4_Mask +Mask for use with PIN_4_PIN_1 field. +*/ +enum +{ + kSBCModePageFlexibleDisk_PIN_1_Mask = 0x0F, + kSBCModePageFlexibleDisk_PIN_4_Mask = 0xF0 +}; + + +/*! +@struct SBCModePageCaching +@discussion +Caching Mode Page (PAGE CODE 0x08) format. +*/ +typedef struct SBCModePageCaching +{ + ModePageFormatHeader header; + UInt8 flags; + UInt8 DEMAND_READ_WRITE_RETENTION_PRIORITY; + UInt16 DISABLE_PREFETCH_TRANSFER_LENGTH; + UInt16 MINIMUM_PREFETCH; + UInt16 MAXIMUM_PREFETCH; + UInt16 MAXIMUM_PREFETCH_CEILING; + UInt8 flags2; + UInt8 NUMBER_OF_CACHE_SEGMENTS; + UInt16 CACHE_SEGMENT_SIZE; + UInt8 RESERVED; + UInt8 NON_CACHE_SEGMENT_SIZE[3]; +} SBCModePageCaching; + + +/*! +@enum Caching flags bitfields +@discussion +Bit field definitions and masks for Caching flags field. +@constant kSBCModePageCaching_RCD_Bit +RCD Bit definition. +@constant kSBCModePageCaching_MF_Bit +MF Bit definition. +@constant kSBCModePageCaching_WCE_Bit +WCE Bit definition. +@constant kSBCModePageCaching_SIZE_Bit +SIZE Bit definition. +@constant kSBCModePageCaching_DISC_Bit +DISC Bit definition. +@constant kSBCModePageCaching_CAP_Bit +CAP Bit definition. +@constant kSBCModePageCaching_ABPF_Bit +ABPF Bit definition. +@constant kSBCModePageCaching_IC_Bit +IC Bit definition. +@constant kSBCModePageCaching_RCD_Mask +Mask for use with flags field. +@constant kSBCModePageCaching_MF_Mask +Mask for use with flags field. +@constant kSBCModePageCaching_WCE_Mask +Mask for use with flags field. +@constant kSBCModePageCaching_SIZE_Mask +Mask for use with flags field. +@constant kSBCModePageCaching_DISC_Mask +Mask for use with flags field. +@constant kSBCModePageCaching_CAP_Mask +Mask for use with flags field. +@constant kSBCModePageCaching_ABPF_Mask +Mask for use with flags field. +@constant kSBCModePageCaching_IC_Mask +Mask for use with flags field. +*/ +enum +{ + kSBCModePageCaching_RCD_Bit = 0, + kSBCModePageCaching_MF_Bit = 1, + kSBCModePageCaching_WCE_Bit = 2, + kSBCModePageCaching_SIZE_Bit = 3, + kSBCModePageCaching_DISC_Bit = 4, + kSBCModePageCaching_CAP_Bit = 5, + kSBCModePageCaching_ABPF_Bit = 6, + kSBCModePageCaching_IC_Bit = 7, + + kSBCModePageCaching_RCD_Mask = (1 << kSBCModePageCaching_RCD_Bit), + kSBCModePageCaching_MF_Mask = (1 << kSBCModePageCaching_MF_Bit), + kSBCModePageCaching_WCE_Mask = (1 << kSBCModePageCaching_WCE_Bit), + kSBCModePageCaching_SIZE_Mask = (1 << kSBCModePageCaching_SIZE_Bit), + kSBCModePageCaching_DISC_Mask = (1 << kSBCModePageCaching_DISC_Bit), + kSBCModePageCaching_CAP_Mask = (1 << kSBCModePageCaching_CAP_Bit), + kSBCModePageCaching_ABPF_Mask = (1 << kSBCModePageCaching_ABPF_Bit), + kSBCModePageCaching_IC_Mask = (1 << kSBCModePageCaching_IC_Bit) +}; + + +/*! +@enum Demand Read/Write Retention masks +@discussion +Demand Read/Write Retention masks. +@constant kSBCModePageCaching_DEMAND_WRITE_Mask +Mask for the DEMAND_READ_WRITE_RETENTION_PRIORITY field. +@constant kSBCModePageCaching_DEMAND_READ_Mask +Mask for the DEMAND_READ_WRITE_RETENTION_PRIORITY field. +*/ +enum +{ + kSBCModePageCaching_DEMAND_WRITE_Mask = 0x00FF, + kSBCModePageCaching_DEMAND_READ_Mask = 0xFF00 +}; + +/*! +@enum Caching flags2 bitfields +@discussion +Bit field definitions and masks for Caching flags2 field. +@constant kSBCModePageCaching_VS1_Bit +VS1 Bit definition. +@constant kSBCModePageCaching_VS2_Bit +VS2 Bit definition. +@constant kSBCModePageCaching_DRA_Bit +DRA Bit definition. +@constant kSBCModePageCaching_LBCSS_Bit +LBCSS Bit definition. +@constant kSBCModePageCaching_FSW_Bit +FSW Bit definition. +@constant kSBCModePageCaching_VS1_Mask +Mask for use with flags2 field. +@constant kSBCModePageCaching_VS2_Mask +Mask for use with flags2 field. +@constant kSBCModePageCaching_DRA_Mask +Mask for use with flags2 field. +@constant kSBCModePageCaching_LBCSS_Mask +Mask for use with flags2 field. +@constant kSBCModePageCaching_FSW_Mask +Mask for use with flags2 field. +*/ +enum +{ + // Bits 0:2 Reserved + kSBCModePageCaching_VS1_Bit = 3, + kSBCModePageCaching_VS2_Bit = 4, + kSBCModePageCaching_DRA_Bit = 5, + kSBCModePageCaching_LBCSS_Bit = 6, + kSBCModePageCaching_FSW_Bit = 7, + + kSBCModePageCaching_VS1_Mask = (1 << kSBCModePageCaching_VS1_Bit), + kSBCModePageCaching_VS2_Mask = (1 << kSBCModePageCaching_VS2_Bit), + kSBCModePageCaching_DRA_Mask = (1 << kSBCModePageCaching_DRA_Bit), + kSBCModePageCaching_LBCSS_Mask = (1 << kSBCModePageCaching_LBCSS_Bit), + kSBCModePageCaching_FSW_Mask = (1 << kSBCModePageCaching_FSW_Bit) +}; + +#pragma options align=reset + +#endif /* _IOKIT_SCSI_CMDS_MODE_DEFINITIONS_H_ */ Index: branches/azimutz/Cleancut/i386/include/IOKit/scsi/IODVDServices.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/scsi/IODVDServices.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/scsi/IODVDServices.h (revision 885) @@ -0,0 +1,251 @@ +/* + * 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_DVD_SERVICES_H_ +#define _IOKIT_IO_DVD_SERVICES_H_ + +#if defined(KERNEL) && defined(__cplusplus) + + +//----------------------------------------------------------------------------- +// Includes +//----------------------------------------------------------------------------- + +// IOKit includes +#include <IOKit/IOTypes.h> + +// Generic IOKit storage related headers +#include <IOKit/storage/IODVDTypes.h> +#include <IOKit/storage/IODVDBlockStorageDevice.h> + +// SCSI Architecture Model Family includes +#include <IOKit/scsi/IOSCSIPeripheralDeviceType05.h> + +class IOMemoryDescriptor; + +// Use this switch to turn off the data cache. +#define _DVD_USE_DATA_CACHING_ 1 + + +//----------------------------------------------------------------------------- +// Class Declaration +//----------------------------------------------------------------------------- + +class IODVDServices : public IODVDBlockStorageDevice +{ + + OSDeclareDefaultStructors ( IODVDServices ) + +#if (_DVD_USE_DATA_CACHING_) + // Data Cache members + bool fUseDataCache; // Indicates if cache should be used. This + // will be set to false if all the necessary support + // for the data cache could not be allocated or + // initialized. + UInt8 * fDataCacheStorage; // Storage space for the cache + UInt32 fDataCacheStartBlock; // Starting block of the data in the cache. + UInt32 fDataCacheBlockCount; // Number of contiguous blocks in the cache + // starting with fDataCacheStartBlock. A value of + // zero in this member indicates that all data + // in the cache is invalid. + + IOSimpleLock * fDataCacheLock; // This is the lock for preventing multiple access + // while manipulating the data cache. +#endif + +protected: + + OSSet * fClients; + IOSCSIPeripheralDeviceType05 * fProvider; + + virtual void free ( void ); + + // Reserve space for future expansion. + struct IODVDServicesExpansionData { }; + IODVDServicesExpansionData * fIODVDServicesReserved; + +public: + + static void AsyncReadWriteComplete ( void * clientData, + IOReturn status, + UInt64 actualByteCount ); + + // Deprecated + virtual IOReturn doAsyncReadWrite ( IOMemoryDescriptor * buffer, + UInt32 block, + UInt32 nblks, + IOStorageCompletion completion ); + + virtual IOReturn doAsyncReadWrite ( IOMemoryDescriptor * buffer, + UInt64 block, + UInt64 nblks, + IOStorageCompletion completion ); + + virtual IOReturn doAsyncReadWrite ( IOMemoryDescriptor * buffer, + UInt64 block, + UInt64 nblks, + IOStorageAttributes * attributes, + IOStorageCompletion * completion ); + + virtual IOReturn doEjectMedia ( void ); + + virtual IOReturn doFormatMedia ( UInt64 byteCapacity ); + + virtual UInt32 doGetFormatCapacities ( UInt64 * capacities, + UInt32 capacitiesMaxCount ) const; + + virtual IOReturn doLockUnlockMedia ( bool doLock ); + + virtual IOReturn doSynchronizeCache ( void ); + + virtual IOReturn getWriteCacheState ( bool * enabled ); + + virtual IOReturn setWriteCacheState ( bool enabled ); + + virtual char * getVendorString ( void ); + + virtual char * getProductString ( void ); + + virtual char * getRevisionString ( void ); + + virtual char * getAdditionalDeviceInfoString ( void ); + + virtual IOReturn reportBlockSize ( UInt64 * blockSize ); + + virtual IOReturn reportEjectability ( bool * isEjectable ); + + virtual IOReturn reportLockability ( bool * isLockable ); + + virtual IOReturn reportMediaState ( bool * mediaPresent, bool * changed ); + + virtual IOReturn reportPollRequirements ( bool * pollIsRequired, + bool * pollIsExpensive ); + + virtual IOReturn reportMaxValidBlock ( UInt64 * maxBlock ); + + virtual IOReturn reportRemovability ( bool * isRemovable ); + + virtual IOReturn reportWriteProtection ( bool * isWriteProtected ); + + /* CD Specific */ + virtual IOReturn doAsyncReadCD ( IOMemoryDescriptor * buffer, + UInt32 block, + UInt32 nblks, + CDSectorArea sectorArea, + CDSectorType sectorType, + IOStorageCompletion completion ); + + virtual IOReturn readISRC ( UInt8 track, CDISRC isrc ); + + virtual IOReturn readMCN ( CDMCN mcn); + + virtual IOReturn readTOC ( IOMemoryDescriptor * buffer ); + + virtual IOReturn audioPause ( bool pause ); + + virtual IOReturn audioPlay ( CDMSF timeStart, CDMSF timeStop ); + + virtual IOReturn audioScan ( CDMSF timeStart, bool reverse ); + + virtual IOReturn audioStop ( void ); + + virtual IOReturn getAudioStatus ( CDAudioStatus * status ); + + virtual IOReturn getAudioVolume ( UInt8 * leftVolume, UInt8 * rightVolume ); + + virtual IOReturn setAudioVolume ( UInt8 leftVolume, UInt8 rightVolume ); + + virtual IOReturn getSpeed ( UInt16 * kilobytesPerSecond ); + + virtual IOReturn setSpeed ( UInt16 kilobytesPerSecond ); + + /* DVD Specific */ + virtual UInt32 getMediaType ( void ); + + virtual IOReturn reportKey ( IOMemoryDescriptor * buffer, + const DVDKeyClass keyClass, + const UInt32 lba, + const UInt8 agid, + const DVDKeyFormat keyFormat ); + + virtual IOReturn sendKey ( IOMemoryDescriptor * buffer, + const DVDKeyClass keyClass, + const UInt8 agid, + const DVDKeyFormat keyFormat ); + + virtual IOReturn readDVDStructure ( IOMemoryDescriptor * buffer, + const UInt8 structureFormat, + const UInt32 logicalBlockAddress, + const UInt8 layer, + const UInt8 agid ); + + /* 10.6.0 */ + virtual IOReturn requestIdle ( void ); + + /* System Specific */ + virtual IOReturn message ( UInt32 type, IOService * provider, void * argument ); + virtual IOReturn setProperties ( OSObject * properties ); + + /* User Client Specific */ + virtual bool start ( IOService * provider ); + virtual bool open ( IOService * client, IOOptionBits options, IOStorageAccess access ); + + virtual bool handleOpen ( IOService * client, IOOptionBits options, void * access ); + virtual void handleClose ( IOService * client, IOOptionBits options ); + virtual bool handleIsOpen ( const IOService * client ) const; + + /* Added with 10.1.3 */ + virtual IOReturn readTOC ( IOMemoryDescriptor * buffer, + CDTOCFormat format, + UInt8 msf, + UInt8 trackSessionNumber, + UInt16 * actualByteCount ); + + /* Added with 10.1.3 */ + virtual IOReturn readDiscInfo ( IOMemoryDescriptor * buffer, + UInt16 * actualByteCount ); + + /* Added with 10.1.3 */ + virtual IOReturn readTrackInfo ( IOMemoryDescriptor * buffer, + UInt32 address, + CDTrackInfoAddressType addressType, + UInt16 * actualByteCount ); + +private: + + // Space reserved for future expansion. + OSMetaClassDeclareReservedUnused ( IODVDServices, 1 ); + OSMetaClassDeclareReservedUnused ( IODVDServices, 2 ); + OSMetaClassDeclareReservedUnused ( IODVDServices, 3 ); + OSMetaClassDeclareReservedUnused ( IODVDServices, 4 ); + OSMetaClassDeclareReservedUnused ( IODVDServices, 5 ); + OSMetaClassDeclareReservedUnused ( IODVDServices, 6 ); + OSMetaClassDeclareReservedUnused ( IODVDServices, 7 ); + OSMetaClassDeclareReservedUnused ( IODVDServices, 8 ); + +}; + +#endif /* defined(KERNEL) && defined(__cplusplus) */ + +#endif /* _IOKIT_IO_DVD_SERVICES_H_ */ Index: branches/azimutz/Cleancut/i386/include/IOKit/scsi/IOBlockStorageServices.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/scsi/IOBlockStorageServices.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/scsi/IOBlockStorageServices.h (revision 885) @@ -0,0 +1,158 @@ +/* + * 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_BLOCK_STORAGE_SERVICES_H_ +#define _IOKIT_IO_BLOCK_STORAGE_SERVICES_H_ + +#if defined(KERNEL) && defined(__cplusplus) + + +//----------------------------------------------------------------------------- +// Includes +//----------------------------------------------------------------------------- + +// IOKit includes +#include <IOKit/IOTypes.h> + +// Generic IOKit storage related headers +#include <IOKit/storage/IOBlockStorageDevice.h> + +// SCSI Architecture Model Family includes +#include <IOKit/scsi/IOSCSIBlockCommandsDevice.h> + + +//----------------------------------------------------------------------------- +// Class Declaration +//----------------------------------------------------------------------------- + +class IOBlockStorageServices : public IOBlockStorageDevice +{ + + OSDeclareDefaultStructors ( IOBlockStorageServices ) + +private: + + bool fMediaChanged; /* DEPRECATED */ + bool fMediaPresent; + +protected: + + IOSCSIBlockCommandsDevice * fProvider; + + UInt64 fMaxReadBlocks; + UInt64 fMaxWriteBlocks; + + virtual bool attach ( IOService * provider ); + virtual void detach ( IOService * provider ); + virtual IOReturn newUserClient ( + task_t owningTask, + void * securityID, + UInt32 type, + OSDictionary * properties, + IOUserClient ** handler ); + + // Reserve space for future expansion. + struct IOBlockStorageServicesExpansionData { }; + IOBlockStorageServicesExpansionData * fIOBlockStorageServicesReserved; + +public: + + virtual IOReturn message ( UInt32 type, IOService * provider, void * argument ); + + static void AsyncReadWriteComplete ( void * clientData, + IOReturn status, + UInt64 actualByteCount ); + + // Deprecated + virtual IOReturn doAsyncReadWrite ( IOMemoryDescriptor * buffer, + UInt32 block, + UInt32 nblks, + IOStorageCompletion completion ); + + virtual IOReturn doAsyncReadWrite ( IOMemoryDescriptor * buffer, + UInt64 block, + UInt64 nblks, + IOStorageCompletion completion ); + + virtual IOReturn doAsyncReadWrite ( IOMemoryDescriptor * buffer, + UInt64 block, + UInt64 nblks, + IOStorageAttributes * attributes, + IOStorageCompletion * completion ); + + virtual IOReturn doEjectMedia ( void ); + + virtual IOReturn doFormatMedia ( UInt64 byteCapacity ); + + virtual UInt32 doGetFormatCapacities ( UInt64 * capacities, + UInt32 capacitiesMaxCount ) const; + + virtual IOReturn doLockUnlockMedia ( bool doLock ); + + virtual IOReturn doSynchronizeCache ( void ); + + virtual char * getVendorString ( void ); + + virtual char * getProductString ( void ); + + virtual char * getRevisionString ( void ); + + virtual char * getAdditionalDeviceInfoString ( void ); + + virtual IOReturn reportBlockSize ( UInt64 * blockSize ); + + virtual IOReturn reportEjectability ( bool * isEjectable ); + + virtual IOReturn reportLockability ( bool * isLockable ); + + virtual IOReturn reportMediaState ( bool * mediaPresent, bool * changed ); + + virtual IOReturn reportPollRequirements ( bool * pollIsRequired, + bool * pollIsExpensive ); + + virtual IOReturn reportMaxValidBlock ( UInt64 * maxBlock ); + + virtual IOReturn reportRemovability ( bool * isRemovable ); + + virtual IOReturn reportWriteProtection ( bool * isWriteProtected ); + + virtual IOReturn getWriteCacheState ( bool * enabled ); + + virtual IOReturn setWriteCacheState ( bool enabled ); + + // Space reserved for future expansion. + OSMetaClassDeclareReservedUnused ( IOBlockStorageServices, 1 ); + OSMetaClassDeclareReservedUnused ( IOBlockStorageServices, 2 ); + OSMetaClassDeclareReservedUnused ( IOBlockStorageServices, 3 ); + OSMetaClassDeclareReservedUnused ( IOBlockStorageServices, 4 ); + OSMetaClassDeclareReservedUnused ( IOBlockStorageServices, 5 ); + OSMetaClassDeclareReservedUnused ( IOBlockStorageServices, 6 ); + OSMetaClassDeclareReservedUnused ( IOBlockStorageServices, 7 ); + OSMetaClassDeclareReservedUnused ( IOBlockStorageServices, 8 ); + +}; + +#endif /* defined(KERNEL) && defined(__cplusplus) */ + +#endif /* _IOKIT_IO_BLOCK_STORAGE_SERVICES_H_ */ Index: branches/azimutz/Cleancut/i386/include/IOKit/scsi/SCSICmds_READ_CAPACITY_Definitions.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/scsi/SCSICmds_READ_CAPACITY_Definitions.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/scsi/SCSICmds_READ_CAPACITY_Definitions.h (revision 885) @@ -0,0 +1,141 @@ +/* + * 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_SCSI_CMDS_READ_CAPACITY_H_ +#define _IOKIT_SCSI_CMDS_READ_CAPACITY_H_ + + +#if KERNEL +#include <IOKit/IOTypes.h> +#else +#include <CoreFoundation/CoreFoundation.h> +#endif + + +/*! @header SCSI Request Sense Definitions + @discussion + This file contains all definitions for the data returned from + the READ CAPACITY 10 (0x25) and READ CAPACITY 16 (0x9E) commands. +*/ + +/*! +@enum READ CAPACITY Payload Sizes +@discussion +Sizes of the payload for the READ CAPACITY 10 and +READ CAPACITY 16 commands. +@constant kREPORT_CAPACITY_DataSize +Data size for a READ_CAPACITY command. +@constant kREPORT_CAPACITY_16_DataSize +Data size for a READ_CAPACITY_16 command. +*/ +enum +{ + kREPORT_CAPACITY_DataSize = 8, + kREPORT_CAPACITY_16_DataSize = 32 +}; + + +/*! +@constant kREPORT_CAPACITY_MaximumLBA +@discussion +Maximum LBA supported via READ CAPACITY 10 command. +*/ +#define kREPORT_CAPACITY_MaximumLBA 0xFFFFFFFFUL + + +/*! +@constant kREPORT_CAPACITY_16_MaximumLBA +@discussion +Maximum LBA supported via READ CAPACITY 16 command. +*/ +#define kREPORT_CAPACITY_16_MaximumLBA 0xFFFFFFFFFFFFFFFFULL + + +/*! +@struct SCSI_Capacity_Data +@discussion +Capacity return structure for READ CAPACITY 10 command. +*/ +typedef struct SCSI_Capacity_Data +{ + UInt32 RETURNED_LOGICAL_BLOCK_ADDRESS; + UInt32 BLOCK_LENGTH_IN_BYTES; +} SCSI_Capacity_Data; + + +/*! +@struct SCSI_Capacity_Data_Long +@discussion +Capacity return structure for READ CAPACITY 16 command. +*/ +typedef struct SCSI_Capacity_Data_Long +{ + UInt64 RETURNED_LOGICAL_BLOCK_ADDRESS; + UInt32 BLOCK_LENGTH_IN_BYTES; + UInt8 RTO_EN_PROT_EN; + UInt8 Reserved[19]; +} SCSI_Capacity_Data_Long; + + +/*! +@enum RTO_EN definitions +@discussion +Values for the REFERENCE TAG OWN (RTO_EN) bit in the +READ CAPACITY Long Data structure. +@constant kREAD_CAPACITY_RTO_Enabled +Reference Tag Own enabled. +@constant kREAD_CAPACITY_RTO_Disabled +Reference Tag Own disabled. +@constant kREAD_CAPACITY_RTO_Mask +Mask to use when checking the RTO_EN_PROT_EN field. +*/ +enum +{ + kREAD_CAPACITY_RTO_Enabled = 0x02, + kREAD_CAPACITY_RTO_Disabled = 0x00, + kREAD_CAPACITY_RTO_Mask = 0x02 +}; + + +/*! +@enum PROTECTION INFORMATION definitions +@discussion +Values for the PROTECTION INFORMATION (PROT_EN) bit in the +READ CAPACITY Long Data structure. +@constant kREAD_CAPACITY_PROT_Enabled +Protection Information enabled. +@constant kREAD_CAPACITY_PROT_Disabled +Protection Information disabled. +@constant kREAD_CAPACITY_PROT_Mask +Mask to use when checking the RTO_EN_PROT_EN field. +*/ + +enum +{ + kREAD_CAPACITY_PROT_Enabled = 0x01, + kREAD_CAPACITY_PROT_Disabled = 0x00, + kREAD_CAPACITY_PROT_Mask = 0x01 +}; + + +#endif /* _IOKIT_SCSI_CMDS_READ_CAPACITY_H_ */ Index: branches/azimutz/Cleancut/i386/include/IOKit/scsi/IOSCSIPeripheralDeviceType0E.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/scsi/IOSCSIPeripheralDeviceType0E.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/scsi/IOSCSIPeripheralDeviceType0E.h (revision 885) @@ -0,0 +1,77 @@ +/* + * 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_SCSI_PERIPHERAL_DEVICE_TYPE_0E_H_ +#define _IOKIT_IO_SCSI_PERIPHERAL_DEVICE_TYPE_0E_H_ + +#if defined(KERNEL) && defined(__cplusplus) + +//----------------------------------------------------------------------------- +// Includes +//----------------------------------------------------------------------------- + +// General IOKit headers +#include <IOKit/IOLib.h> + +// SCSI Architecture Model Family includes +#include <IOKit/scsi/IOSCSIReducedBlockCommandsDevice.h> + + +//----------------------------------------------------------------------------- +// Class Declaration +//----------------------------------------------------------------------------- + +class IOSCSIPeripheralDeviceType0E : public IOSCSIReducedBlockCommandsDevice +{ + + OSDeclareDefaultStructors ( IOSCSIPeripheralDeviceType0E ) + +protected: + + // Reserve space for future expansion. + struct IOSCSIPeripheralDeviceType0EExpansionData { }; + IOSCSIPeripheralDeviceType0EExpansionData * fIOSCSIPeripheralDeviceType0EReserved; + +public: + + bool init ( OSDictionary * propTable ); + virtual bool start ( IOService * provider ); + virtual void stop ( IOService * provider ); + +private: + + // Space reserved for future expansion. + OSMetaClassDeclareReservedUnused ( IOSCSIPeripheralDeviceType0E, 1 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPeripheralDeviceType0E, 2 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPeripheralDeviceType0E, 3 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPeripheralDeviceType0E, 4 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPeripheralDeviceType0E, 5 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPeripheralDeviceType0E, 6 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPeripheralDeviceType0E, 7 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPeripheralDeviceType0E, 8 ); + +}; + +#endif /* defined(KERNEL) && defined(__cplusplus) */ + +#endif /* _IOKIT_IO_SCSI_PERIPHERAL_DEVICE_TYPE_0E_H_ */ Index: branches/azimutz/Cleancut/i386/include/IOKit/scsi/SCSICmds_REQUEST_SENSE_Defs.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/scsi/SCSICmds_REQUEST_SENSE_Defs.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/scsi/SCSICmds_REQUEST_SENSE_Defs.h (revision 885) @@ -0,0 +1,234 @@ +/* + * 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_SCSI_CMDS_REQUEST_SENSE_H_ +#define _IOKIT_SCSI_CMDS_REQUEST_SENSE_H_ + + +#if KERNEL +#include <IOKit/IOTypes.h> +#else +#include <CoreFoundation/CoreFoundation.h> +#endif + + +/*! @header SCSI Request Sense Definitions + @discussion + This file contains all definitions for the data returned from + the REQUEST SENSE (0x03) command and from auto sense on protocols + that support it. +*/ + + +/*! +@enum kSenseDefaultSize +@discussion +The default size for SCSI Request Sense data. +*/ +enum +{ + kSenseDefaultSize = 18 +}; + + +/*! +@struct SCSI_Sense_Data +@discussion +The basic SCSI Request Sense data structure. +*/ +typedef struct SCSI_Sense_Data +{ + UInt8 VALID_RESPONSE_CODE; // 7 = Valid. 6-0 = Response Code. + UInt8 SEGMENT_NUMBER; // Segment number + UInt8 SENSE_KEY; // 7 = FILEMARK, 6 = EOM, 5 = ILI, 3-0 = SENSE KEY. + UInt8 INFORMATION_1; // INFORMATION. + UInt8 INFORMATION_2; // INFORMATION. + UInt8 INFORMATION_3; // INFORMATION. + UInt8 INFORMATION_4; // INFORMATION. + UInt8 ADDITIONAL_SENSE_LENGTH; // Number of additional bytes available in sense data + UInt8 COMMAND_SPECIFIC_INFORMATION_1; // Command Specific Information + UInt8 COMMAND_SPECIFIC_INFORMATION_2; // Command Specific Information + UInt8 COMMAND_SPECIFIC_INFORMATION_3; // Command Specific Information + UInt8 COMMAND_SPECIFIC_INFORMATION_4; // Command Specific Information + UInt8 ADDITIONAL_SENSE_CODE; // Additional Sense Code + UInt8 ADDITIONAL_SENSE_CODE_QUALIFIER; // Additional Sense Code Qualifier + UInt8 FIELD_REPLACEABLE_UNIT_CODE; // Field Replaceable Unit Code + UInt8 SKSV_SENSE_KEY_SPECIFIC_MSB; // 7 = Sense Key Specific Valid bit, 6-0 Sense Key Specific MSB + UInt8 SENSE_KEY_SPECIFIC_MID; // Sense Key Specific Middle + UInt8 SENSE_KEY_SPECIFIC_LSB; // Sense Key Specific LSB +} SCSI_Sense_Data; + + +/*! +@enum Sense Valid +@discussion +Masks to use to determine if sense data is valid or not. +@constant kSENSE_DATA_VALID +Sense data is valid. +@constant kSENSE_NOT_DATA_VALID +Sense data is not valid. +@constant kSENSE_DATA_VALID_Mask +Validity mask to use when checking the VALID_RESPONSE_CODE field. +*/ +enum +{ + kSENSE_DATA_VALID = 0x80, + kSENSE_NOT_DATA_VALID = 0x00, + kSENSE_DATA_VALID_Mask = 0x80 +}; + + +/*! +@enum Sense Response Codes +@discussion +Masks and values to determine the Response Code. +@constant kSENSE_RESPONSE_CODE_Current_Errors +Response code indicating current errors are reported. +@constant kSENSE_RESPONSE_CODE_Deferred_Errors +Response code indicating deferred errors are reported. +@constant kSENSE_RESPONSE_CODE_Mask +Mask to use when checking the VALID_RESPONSE_CODE field. +*/ +enum +{ + kSENSE_RESPONSE_CODE_Current_Errors = 0x70, + kSENSE_RESPONSE_CODE_Deferred_Errors = 0x71, + kSENSE_RESPONSE_CODE_Mask = 0x7F +}; + + +/*! +@enum FILEMARK bit field definitions +@discussion +Masks and values to determine the FileMark bit field. +@constant kSENSE_FILEMARK_Set +Filemark bit is set. +@constant kSENSE_FILEMARK_Not_Set +Filemark bit is not set. +@constant kSENSE_FILEMARK_Mask +Mask to use when checking the SENSE_KEY field for the FILEMARK bit. +*/ +enum +{ + kSENSE_FILEMARK_Set = 0x80, + kSENSE_FILEMARK_Not_Set = 0x00, + kSENSE_FILEMARK_Mask = 0x80 +}; + + +/*! +@enum EOM bit field definitions +@discussion +Masks and values to determine the End Of Medium bit field. +@constant kSENSE_EOM_Set +End Of Medium bit is set. +@constant kSENSE_EOM_Not_Set +End Of Medium bit is not set. +@constant kSENSE_EOM_Mask +Mask to use when checking the SENSE_KEY field for the EOM bit. +*/ +enum +{ + kSENSE_EOM_Set = 0x40, + kSENSE_EOM_Not_Set = 0x00, + kSENSE_EOM_Mask = 0x40 +}; + + +/*! +@enum ILI bit field definitions +@discussion +Masks and values to determine the Incorrect Length Indicator bit field. +@constant kSENSE_ILI_Set +Incorrect Length Indicator bit is set. +@constant kSENSE_ILI_Not_Set +Incorrect Length Indicator bit is not set. +@constant kSENSE_ILI_Mask +Mask to use when checking the SENSE_KEY field for the ILI bit. +*/ +enum +{ + kSENSE_ILI_Set = 0x20, + kSENSE_ILI_Not_Set = 0x00, + kSENSE_ILI_Mask = 0x20 +}; + + +/*! +@enum Sense Key definitions +@discussion +Masks and values to determine the SENSE_KEY. +@constant kSENSE_KEY_NO_SENSE +No sense data is present. +@constant kSENSE_KEY_RECOVERED_ERROR +A recovered error has occurred. +@constant kSENSE_KEY_NOT_READY +Device server is not ready. +@constant kSENSE_KEY_MEDIUM_ERROR +Device server detected a medium error. +@constant kSENSE_KEY_HARDWARE_ERROR +Device server detected a hardware error. +@constant kSENSE_KEY_ILLEGAL_REQUEST +Device server detected an illegal request. +@constant kSENSE_KEY_UNIT_ATTENTION +Device server indicates a unit attention condition. +@constant kSENSE_KEY_DATA_PROTECT +Device server indicates a data protect condition. +@constant kSENSE_KEY_BLANK_CHECK +Device server indicates a blank check condition. +@constant kSENSE_KEY_VENDOR_SPECIFIC +Device server indicates a vendor specific condition. +@constant kSENSE_KEY_COPY_ABORTED +Device server indicates a copy aborted condition. +@constant kSENSE_KEY_ABORTED_COMMAND +Device server indicates an aborted command condition. +@constant kSENSE_KEY_VOLUME_OVERFLOW +Device server indicates a volume overflow condition. +@constant kSENSE_KEY_MISCOMPARE +Device server indicates a miscompare condition. +@constant kSENSE_KEY_Mask +Mask to use when checking the SENSE_KEY field for the SENSE_KEY value. +*/ +enum +{ + kSENSE_KEY_NO_SENSE = 0x00, + kSENSE_KEY_RECOVERED_ERROR = 0x01, + kSENSE_KEY_NOT_READY = 0x02, + kSENSE_KEY_MEDIUM_ERROR = 0x03, + kSENSE_KEY_HARDWARE_ERROR = 0x04, + kSENSE_KEY_ILLEGAL_REQUEST = 0x05, + kSENSE_KEY_UNIT_ATTENTION = 0x06, + kSENSE_KEY_DATA_PROTECT = 0x07, + kSENSE_KEY_BLANK_CHECK = 0x08, + kSENSE_KEY_VENDOR_SPECIFIC = 0x09, + kSENSE_KEY_COPY_ABORTED = 0x0A, + kSENSE_KEY_ABORTED_COMMAND = 0x0B, + /* SENSE KEY 0x0C is obsoleted */ + kSENSE_KEY_VOLUME_OVERFLOW = 0x0D, + kSENSE_KEY_MISCOMPARE = 0x0E, + /* SENSE KEY 0x0F is reserved */ + kSENSE_KEY_Mask = 0x0F +}; + + +#endif /* _IOKIT_SCSI_CMDS_REQUEST_SENSE_H_ */ Index: branches/azimutz/Cleancut/i386/include/IOKit/scsi/IOSCSIProtocolServices.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/scsi/IOSCSIProtocolServices.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/scsi/IOSCSIProtocolServices.h (revision 885) @@ -0,0 +1,362 @@ +/* + * 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_SCSI_PROTOCOL_SERVICES_H_ +#define _IOKIT_IO_SCSI_PROTOCOL_SERVICES_H_ + +#if defined(KERNEL) && defined(__cplusplus) + + +//----------------------------------------------------------------------------- +// Includes +//----------------------------------------------------------------------------- + +// Mach includes +#include <kern/queue.h> + +// General IOKit headers +#include <IOKit/IOLib.h> +#include <IOKit/IOCommandGate.h> + +// SCSI Architecture Model Family includes +#include <IOKit/scsi/SCSITask.h> +#include <IOKit/scsi/IOSCSIProtocolInterface.h> +#include <IOKit/scsi/SCSICmds_REQUEST_SENSE_Defs.h> + + +//----------------------------------------------------------------------------- +// Constants +//----------------------------------------------------------------------------- + +// Power Management values +enum +{ + kSCSIProtocolLayerPowerStateOff = 0, + kSCSIProtocolLayerPowerStateOn = 1, + kSCSIProtocolLayerNumDefaultStates = 2 +}; + +// Forward definitions of internal use only classes +class SCSITask; + +//----------------------------------------------------------------------------- +// Class Declaration +//----------------------------------------------------------------------------- + +class IOSCSIProtocolServices : public IOSCSIProtocolInterface +{ + + OSDeclareAbstractStructors ( IOSCSIProtocolServices ) + +private: + + // The head pointer for the queue of waiting SCSI Tasks. + SCSITask * fSCSITaskQueueHead; /* OBSOLETE */ + + // This is the lock for preventing multiple access while + // manipulating the SCSI Task queue. + IOSimpleLock * fQueueLock; + + // The internal flag to indicate whether service requests should be + // executed or immediately errored, such as when a device is removed. + bool fAllowServiceRequests; + +protected: + + // Reserve space for future expansion. + struct IOSCSIProtocolServicesExpansionData + { + // For internal use only. Do not use. + UInt32 fSemaphore; + bool fRequiresAutosenseDescriptor; + SCSITaskCompletion fCompletionRoutine; + queue_head_t fTaskQueueHead; + queue_head_t fAutoSenseQueueHead; + }; + IOSCSIProtocolServicesExpansionData * fIOSCSIProtocolServicesReserved; + + // ---- Protocol transport methods overridden by each subclass ---- + + // Send a SCSI Command to the device. 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 ) = 0; + + virtual SCSIServiceResponse AbortSCSICommand ( SCSITaskIdentifier request ) = 0; + + // ---- Command completion notification method --------- + // Subclasses will call this inherited method when the command + // executed by SendSCSICommand has completed. + // The subclasses will return a service response that is derived + // from protocol specific status information and as specified in + // the specification for that protocol. + // If the service response is kSCSIServiceResponse_TASK_COMPLETE, + // the subclass will also return a SCSI status value. + void CommandCompleted ( SCSITaskIdentifier request, + SCSIServiceResponse serviceResponse, + SCSITaskStatus taskStatus ); + + // ---- Utility methods for accessing SCSITask attributes ---- + // Method for retreiving the attribute for a task. + SCSITaskAttribute GetTaskAttribute ( SCSITaskIdentifier request ); + + bool SetTaskState ( SCSITaskIdentifier request, + SCSITaskState newTaskState ); + SCSITaskState GetTaskState ( SCSITaskIdentifier request ); + + UInt8 GetLogicalUnitNumber ( SCSITaskIdentifier request ); + + // Method to determine the size of the command descriptor block. + UInt8 GetCommandDescriptorBlockSize ( SCSITaskIdentifier request ); + + // This will always return the define max CDB size. If the Protocol Layer + // driver only supports a smaller size CDB, it will have to create a local + // SCSICommandDescriptorBlock variable to get the CDB data and then + // transfer the needed bytes from there. + bool GetCommandDescriptorBlock ( SCSITaskIdentifier request, + SCSICommandDescriptorBlock * cdbData ); + + // Get the transfer direction for the request. + UInt8 GetDataTransferDirection ( SCSITaskIdentifier request ); + + UInt64 GetRequestedDataTransferCount ( SCSITaskIdentifier request ); + + bool SetRealizedDataTransferCount ( SCSITaskIdentifier request, + UInt64 newRealizedDataCount ); + + UInt64 GetRealizedDataTransferCount ( SCSITaskIdentifier request ); + + IOMemoryDescriptor * GetDataBuffer ( SCSITaskIdentifier request ); + + UInt64 GetDataBufferOffset ( SCSITaskIdentifier request ); + + UInt32 GetTimeoutDuration ( SCSITaskIdentifier request ); + + UInt64 GetAutosenseRequestedDataTransferCount ( SCSITaskIdentifier request ); + + // Set the auto sense data that was returned for the SCSI Task. + // A return value of true indicates that the data was copied to the member + // sense data structure, false indicates that the data could not be copied. + bool SetAutoSenseData ( SCSITaskIdentifier request, + SCSI_Sense_Data * senseData ); // DEPRECATED, use the one on the line below. + + bool SetAutoSenseData ( SCSITaskIdentifier request, + SCSI_Sense_Data * senseData, + UInt8 senseDataSize ); + + void EnsureAutosenseDescriptorExists ( SCSITaskIdentifier request ); + + bool SetProtocolLayerReference ( + SCSITaskIdentifier request, + void * newReferenceValue ); + void * GetProtocolLayerReference ( SCSITaskIdentifier request ); + + + bool SetTaskExecutionMode ( + SCSITaskIdentifier request, + SCSITaskMode newTaskMode ); + SCSITaskMode GetTaskExecutionMode ( SCSITaskIdentifier request ); + + // ---- Method calls for messaging device connectedness ---- + void SendNotification_DeviceRemoved ( void ); + + void SendNotification_VerifyDeviceState ( void ); + + // -- SCSI Task Queue Management Methods -- + // Following are the commands used to manipulate the queue of pending SCSI Tasks. + + // Add the SCSI Task to the queue. The Task's Attribute determines where in + // the queue the Task is placed. + void AddSCSITaskToQueue ( SCSITaskIdentifier request ); + + // Add the SCSI Task to the head of the queue. This is used when the task + // has been removed from the head of the queue, but the subclass indicates + // that it can not yet process this task. + void AddSCSITaskToHeadOfQueue ( SCSITask * request ); + + // Remove the next SCSI Task for the queue and return it. + SCSITask * RetrieveNextSCSITaskFromQueue ( void ); + + // Check to see if the SCSI Task resides in the queue and abort it if it does. + bool AbortSCSITaskFromQueue ( SCSITask * request ); + + // Methods for sending and completing SCSI tasks + void SendSCSITasksFromQueue ( void ); + + void RejectSCSITasksCurrentlyQueued ( void ); + + void ProcessCompletedTask ( SCSITaskIdentifier request, + SCSIServiceResponse serviceResponse, + SCSITaskStatus taskStatus ); + void RejectTask ( SCSITaskIdentifier request ); + + // ------ Power Management Support ------ + + // The InitializePowerManagement method is called to initialize power management. + // In the protocol services layer, this method calls the protocol interface layer + // to initialize power management state variables and then registers the protocol + // layer driver with the power manager with two(2) states, ON and OFF. + virtual void InitializePowerManagement ( IOService * provider ); + + // The GetInitialPowerState method is called once, right after InitializePowerManagement() + // in order to determine what state the device is initially in at startup time (usually + // the highest power mode). + virtual UInt32 GetInitialPowerState ( void ); + + // The HandlePowerChange method is pure virtual and is left to each protocol or + // application layer driver to implement. It is guaranteed to be called on its + // own thread of execution and can make synchronous or asynchronous calls. + virtual void HandlePowerChange ( void ); + + // The HandleCheckPowerState (void) method is on the serialized side of the command + // gate and can change member variables safely without multi-threading issues. + // It's main purpose is to call the superclass' HandleCheckPowerState ( UInt32 maxPowerState ) + // with the max power state the class registered with. + virtual void HandleCheckPowerState ( void ); + + // The TicklePowerManager ( void ) method is called by CheckPowerState and + // sends an activity tickle to the power manager so that the idle timer is + // reset. + virtual void TicklePowerManager ( void ); + + // The HandlePowerOff method is called to do any bus specific activity + // necessary before shutting down and going to sleep. + virtual IOReturn HandlePowerOff ( void ); + + // The HandlePowerOn method is called to do any bus specific activity + // necessary to recover from power-on/wake from sleep (e.g. bus reset on ATAPI) + virtual IOReturn HandlePowerOn ( void ); + +public: + + virtual bool start ( IOService * provider ); + virtual void free ( void ); + + void RegisterSCSITaskCompletionRoutine ( SCSITaskCompletion completion ); + + // ------- SCSI Architecture Model Task Management Functions ------ + // The ExecuteCommand method will take a SCSI Task and transport + // it across the physical wire(s) to the device + void ExecuteCommand ( SCSITaskIdentifier request ); + + // The Task Management function to allow the SCSI Application Layer client to request + // that a specific task be aborted. + SCSIServiceResponse AbortTask ( UInt8 theLogicalUnit, SCSITaggedTaskIdentifier theTag ); + + // The Task Management function to allow the SCSI Application Layer client to request + // that a all tasks curerntly in the task set be aborted. + SCSIServiceResponse AbortTaskSet ( UInt8 theLogicalUnit ); + + SCSIServiceResponse ClearACA ( UInt8 theLogicalUnit ); + + SCSIServiceResponse ClearTaskSet ( UInt8 theLogicalUnit ); + + SCSIServiceResponse LogicalUnitReset ( UInt8 theLogicalUnit ); + + SCSIServiceResponse TargetReset ( void ); + + // ************* Obsoleted Member Routine **************** + // The AbortCommand method is replaced by the AbortTask Management function and + // should no longer be called. + virtual SCSIServiceResponse AbortCommand ( SCSITaskIdentifier request ); + + + // ---- Method used for determining protocol or physical interconnect characteristics. ---- + // The IsProtocolServiceSupported will return true if the specified + // feature is supported by the protocol layer. If the service has a value that must be + // returned, it will be returned in the serviceValue output parameter. + virtual bool IsProtocolServiceSupported ( SCSIProtocolFeature feature, void * serviceValue ) = 0; + + // The HandleProtocolServiceFeature instructs the Protocol Services driver to perform the necessary + // tasks for the indicated feature. + virtual bool HandleProtocolServiceFeature ( SCSIProtocolFeature feature, void * serviceValue ) = 0; + +protected: + + // ----- Protocol Services Driver request handlers for Task Management functions ----- + // These should be abstract so that every Protocol Services Driver would have to + // override them, but since they are new member routines, this class will provide + // a default implementation. + OSMetaClassDeclareReservedUsed ( IOSCSIProtocolServices, 1 ); + virtual SCSIServiceResponse HandleAbortTask ( + UInt8 theLogicalUnit, + SCSITaggedTaskIdentifier theTag ); + + OSMetaClassDeclareReservedUsed ( IOSCSIProtocolServices, 2 ); + virtual SCSIServiceResponse HandleAbortTaskSet ( + UInt8 theLogicalUnit ); + + OSMetaClassDeclareReservedUsed ( IOSCSIProtocolServices, 3 ); + virtual SCSIServiceResponse HandleClearACA ( + UInt8 theLogicalUnit ); + + OSMetaClassDeclareReservedUsed ( IOSCSIProtocolServices, 4 ); + virtual SCSIServiceResponse HandleClearTaskSet ( + UInt8 theLogicalUnit ); + + OSMetaClassDeclareReservedUsed ( IOSCSIProtocolServices, 5 ); + virtual SCSIServiceResponse HandleLogicalUnitReset ( + UInt8 theLogicalUnit ); + + OSMetaClassDeclareReservedUsed ( IOSCSIProtocolServices, 6 ); + // The HandleTargetReset member routine requests that the Protocol Services Driver + // perform the necessary steps detailed in the specification that defines the + // protocol the driver represents for the TargetReset management function. + virtual SCSIServiceResponse HandleTargetReset ( void ); + + + OSMetaClassDeclareReservedUsed ( IOSCSIProtocolServices, 7 ); + // The CreateSCSITargetDevice member routine will create the appropriate object + // to represent the Target portion of a SCSI Device. This object is responsible + // for managing the Target functions of the SCSI Device including the Task Manager and + // Logical Units. + // If the SCSITargetDevice object was successfully created, a true value will be + // returned, otherwisw, this will return false. + virtual bool CreateSCSITargetDevice ( void ); + +private: + + // Space reserved for future expansion. + OSMetaClassDeclareReservedUnused ( IOSCSIProtocolServices, 8 ); + OSMetaClassDeclareReservedUnused ( IOSCSIProtocolServices, 9 ); + OSMetaClassDeclareReservedUnused ( IOSCSIProtocolServices, 10 ); + OSMetaClassDeclareReservedUnused ( IOSCSIProtocolServices, 11 ); + OSMetaClassDeclareReservedUnused ( IOSCSIProtocolServices, 12 ); + OSMetaClassDeclareReservedUnused ( IOSCSIProtocolServices, 13 ); + OSMetaClassDeclareReservedUnused ( IOSCSIProtocolServices, 14 ); + OSMetaClassDeclareReservedUnused ( IOSCSIProtocolServices, 15 ); + OSMetaClassDeclareReservedUnused ( IOSCSIProtocolServices, 16 ); + +}; + +#endif /* defined(KERNEL) && defined(__cplusplus) */ + +#endif /* _IOKIT_IO_SCSI_PROTOCOL_SERVICES_H_ */ Index: branches/azimutz/Cleancut/i386/include/IOKit/scsi/IOBDServices.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/scsi/IOBDServices.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/scsi/IOBDServices.h (revision 885) @@ -0,0 +1,241 @@ +/* + * Copyright (c) 2006-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_BD_SERVICES_H_ +#define _IOKIT_IO_BD_SERVICES_H_ + +#if defined(KERNEL) && defined(__cplusplus) + + +//----------------------------------------------------------------------------- +// Includes +//----------------------------------------------------------------------------- + +// IOKit includes +#include <IOKit/IOTypes.h> + +// Generic IOKit storage related headers +#include <IOKit/storage/IOBDTypes.h> +#include <IOKit/storage/IOBDBlockStorageDevice.h> + +// SCSI Architecture Model Family includes +#include <IOKit/scsi/IOSCSIPeripheralDeviceType05.h> + +class IOMemoryDescriptor; + +//----------------------------------------------------------------------------- +// Class Declaration +//----------------------------------------------------------------------------- + +class IOBDServices : public IOBDBlockStorageDevice +{ + + OSDeclareDefaultStructors ( IOBDServices ) + +protected: + + OSSet * fClients; + IOSCSIPeripheralDeviceType05 * fProvider; + + virtual void free ( void ); + + // Reserve space for future expansion. + struct IOBDServicesExpansionData { }; + IOBDServicesExpansionData * fIOBDServicesReserved; + +public: + + static void AsyncReadWriteComplete ( void * clientData, + IOReturn status, + UInt64 actualByteCount ); + + // Deprecated + virtual IOReturn doAsyncReadWrite ( IOMemoryDescriptor * buffer, + UInt32 block, + UInt32 nblks, + IOStorageCompletion completion ); + + virtual IOReturn doAsyncReadWrite ( IOMemoryDescriptor * buffer, + UInt64 block, + UInt64 nblks, + IOStorageCompletion completion ); + + virtual IOReturn doAsyncReadWrite ( IOMemoryDescriptor * buffer, + UInt64 block, + UInt64 nblks, + IOStorageAttributes * attributes, + IOStorageCompletion * completion ); + + virtual IOReturn doEjectMedia ( void ); + + virtual IOReturn doFormatMedia ( UInt64 byteCapacity ); + + virtual UInt32 doGetFormatCapacities ( UInt64 * capacities, + UInt32 capacitiesMaxCount ) const; + + virtual IOReturn doLockUnlockMedia ( bool doLock ); + + virtual IOReturn doSynchronizeCache ( void ); + + virtual IOReturn getWriteCacheState ( bool * enabled ); + + virtual IOReturn setWriteCacheState ( bool enabled ); + + virtual char * getVendorString ( void ); + + virtual char * getProductString ( void ); + + virtual char * getRevisionString ( void ); + + virtual char * getAdditionalDeviceInfoString ( void ); + + virtual IOReturn reportBlockSize ( UInt64 * blockSize ); + + virtual IOReturn reportEjectability ( bool * isEjectable ); + + virtual IOReturn reportLockability ( bool * isLockable ); + + virtual IOReturn reportMediaState ( bool * mediaPresent, bool * changed ); + + virtual IOReturn reportPollRequirements ( bool * pollIsRequired, + bool * pollIsExpensive ); + + virtual IOReturn reportMaxValidBlock ( UInt64 * maxBlock ); + + virtual IOReturn reportRemovability ( bool * isRemovable ); + + virtual IOReturn reportWriteProtection ( bool * isWriteProtected ); + + /* CD Specific */ + virtual IOReturn doAsyncReadCD ( IOMemoryDescriptor * buffer, + UInt32 block, + UInt32 nblks, + CDSectorArea sectorArea, + CDSectorType sectorType, + IOStorageCompletion completion ); + + virtual IOReturn readISRC ( UInt8 track, CDISRC isrc ); + + virtual IOReturn readMCN ( CDMCN mcn); + + virtual IOReturn readTOC ( IOMemoryDescriptor * buffer ); + + virtual IOReturn audioPause ( bool pause ); + + virtual IOReturn audioPlay ( CDMSF timeStart, CDMSF timeStop ); + + virtual IOReturn audioScan ( CDMSF timeStart, bool reverse ); + + virtual IOReturn audioStop ( void ); + + virtual IOReturn getAudioStatus ( CDAudioStatus * status ); + + virtual IOReturn getAudioVolume ( UInt8 * leftVolume, UInt8 * rightVolume ); + + virtual IOReturn setAudioVolume ( UInt8 leftVolume, UInt8 rightVolume ); + + virtual IOReturn getSpeed ( UInt16 * kilobytesPerSecond ); + + virtual IOReturn setSpeed ( UInt16 kilobytesPerSecond ); + + /* DVD Specific */ + virtual UInt32 getMediaType ( void ); + + virtual IOReturn reportKey ( IOMemoryDescriptor * buffer, + const DVDKeyClass keyClass, + const UInt32 lba, + const UInt8 agid, + const DVDKeyFormat keyFormat ); + + virtual IOReturn sendKey ( IOMemoryDescriptor * buffer, + const DVDKeyClass keyClass, + const UInt8 agid, + const DVDKeyFormat keyFormat ); + + virtual IOReturn readDVDStructure ( IOMemoryDescriptor * buffer, + const UInt8 structureFormat, + const UInt32 logicalBlockAddress, + const UInt8 layer, + const UInt8 agid ); + + /* BD Specific */ + virtual IOReturn readDiscStructure ( IOMemoryDescriptor * buffer, + UInt8 structureFormat, + UInt32 logicalBlockAddress, + UInt8 layer, + UInt8 agid, + UInt8 mediaType ); + + /* 10.6.0 */ + virtual IOReturn requestIdle ( void ); + + /* System Specific */ + virtual IOReturn message ( UInt32 type, IOService * provider, void * argument ); + virtual IOReturn setProperties ( OSObject * properties ); + + /* User Client Specific */ + virtual bool start ( IOService * provider ); + virtual bool open ( IOService * client, IOOptionBits options, IOStorageAccess access ); + + virtual bool handleOpen ( IOService * client, IOOptionBits options, void * access ); + virtual void handleClose ( IOService * client, IOOptionBits options ); + virtual bool handleIsOpen ( const IOService * client ) const; + + /* Added with 10.1.3 */ + virtual IOReturn readTOC ( IOMemoryDescriptor * buffer, + CDTOCFormat format, + UInt8 msf, + UInt8 trackSessionNumber, + UInt16 * actualByteCount ); + + /* Added with 10.1.3 */ + virtual IOReturn readDiscInfo ( IOMemoryDescriptor * buffer, + UInt16 * actualByteCount ); + + /* Added with 10.1.3 */ + virtual IOReturn readTrackInfo ( IOMemoryDescriptor * buffer, + UInt32 address, + CDTrackInfoAddressType addressType, + UInt16 * actualByteCount ); + + /* Added with 10.5 */ + virtual IOReturn splitTrack ( UInt32 address ); + +private: + + // Space reserved for future expansion. + OSMetaClassDeclareReservedUnused ( IOBDServices, 1 ); + OSMetaClassDeclareReservedUnused ( IOBDServices, 2 ); + OSMetaClassDeclareReservedUnused ( IOBDServices, 3 ); + OSMetaClassDeclareReservedUnused ( IOBDServices, 4 ); + OSMetaClassDeclareReservedUnused ( IOBDServices, 5 ); + OSMetaClassDeclareReservedUnused ( IOBDServices, 6 ); + OSMetaClassDeclareReservedUnused ( IOBDServices, 7 ); + OSMetaClassDeclareReservedUnused ( IOBDServices, 8 ); + +}; + +#endif /* defined(KERNEL) && defined(__cplusplus) */ + +#endif /* _IOKIT_IO_BD_SERVICES_H_ */ Index: branches/azimutz/Cleancut/i386/include/IOKit/scsi/IOReducedBlockServices.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/scsi/IOReducedBlockServices.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/scsi/IOReducedBlockServices.h (revision 885) @@ -0,0 +1,147 @@ +/* + * 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_REDUCED_BLOCK_SERVICES_H_ +#define _IOKIT_IO_REDUCED_BLOCK_SERVICES_H_ + +#if defined(KERNEL) && defined(__cplusplus) + + +//----------------------------------------------------------------------------- +// Includes +//----------------------------------------------------------------------------- + +// Generic IOKit related headers +#include <IOKit/IOTypes.h> + +// Generic IOKit storage related headers +#include <IOKit/storage/IOBlockStorageDevice.h> + +// SCSI Architecture Model Family includes +#include <IOKit/scsi/IOSCSIPeripheralDeviceType0E.h> + + +//----------------------------------------------------------------------------- +// Class Declaration +//----------------------------------------------------------------------------- + +class IOReducedBlockServices : public IOBlockStorageDevice +{ + + OSDeclareDefaultStructors ( IOReducedBlockServices ) + + +protected: + // Reserve space for future expansion. + struct IOReducedBlockServicesExpansionData { }; + IOReducedBlockServicesExpansionData * fIOReducedBlockServicesReserved; + + IOSCSIPeripheralDeviceType0E * fProvider; + + virtual bool attach ( IOService * provider ); + virtual void detach ( IOService * provider ); + + +public: + + virtual IOReturn message ( UInt32 type, IOService * provider, void * argument ); + + static void AsyncReadWriteComplete ( void * clientData, + IOReturn status, + UInt64 actualByteCount ); + + // Deprecated + virtual IOReturn doAsyncReadWrite ( IOMemoryDescriptor * buffer, + UInt32 block, + UInt32 nblks, + IOStorageCompletion completion ); + + virtual IOReturn doAsyncReadWrite ( IOMemoryDescriptor * buffer, + UInt64 block, + UInt64 nblks, + IOStorageCompletion completion ); + + virtual IOReturn doAsyncReadWrite ( IOMemoryDescriptor * buffer, + UInt64 block, + UInt64 nblks, + IOStorageAttributes * attributes, + IOStorageCompletion * completion ); + + virtual IOReturn doEjectMedia ( void ); + + virtual IOReturn doFormatMedia ( UInt64 byteCapacity ); + + virtual UInt32 doGetFormatCapacities ( UInt64 * capacities, + UInt32 capacitiesMaxCount ) const; + + virtual IOReturn doLockUnlockMedia ( bool doLock ); + + virtual IOReturn doSynchronizeCache ( void ); + + virtual IOReturn getWriteCacheState ( bool * enabled ); + + virtual IOReturn setWriteCacheState ( bool enabled ); + + virtual char * getVendorString ( void ); + + virtual char * getProductString ( void ); + + virtual char * getRevisionString ( void ); + + virtual char * getAdditionalDeviceInfoString ( void ); + + virtual IOReturn reportBlockSize ( UInt64 * blockSize ); + + virtual IOReturn reportEjectability ( bool * isEjectable ); + + virtual IOReturn reportLockability ( bool * isLockable ); + + virtual IOReturn reportMediaState ( bool * mediaPresent, bool * changed ); + + virtual IOReturn reportPollRequirements ( bool * pollIsRequired, + bool * pollIsExpensive ); + + virtual IOReturn reportMaxValidBlock ( UInt64 * maxBlock ); + + virtual IOReturn reportRemovability ( bool * isRemovable ); + + virtual IOReturn reportWriteProtection ( bool * isWriteProtected ); + +private: + + // Space reserved for future expansion. + OSMetaClassDeclareReservedUnused ( IOReducedBlockServices, 1 ); + OSMetaClassDeclareReservedUnused ( IOReducedBlockServices, 2 ); + OSMetaClassDeclareReservedUnused ( IOReducedBlockServices, 3 ); + OSMetaClassDeclareReservedUnused ( IOReducedBlockServices, 4 ); + OSMetaClassDeclareReservedUnused ( IOReducedBlockServices, 5 ); + OSMetaClassDeclareReservedUnused ( IOReducedBlockServices, 6 ); + OSMetaClassDeclareReservedUnused ( IOReducedBlockServices, 7 ); + OSMetaClassDeclareReservedUnused ( IOReducedBlockServices, 8 ); + +}; + +#endif /* defined(KERNEL) && defined(__cplusplus) */ + +#endif /* _IOKIT_IO_REDUCED_BLOCK_SERVICES_H_ */ Index: branches/azimutz/Cleancut/i386/include/IOKit/scsi/SCSICmds_INQUIRY_Definitions.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/scsi/SCSICmds_INQUIRY_Definitions.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/scsi/SCSICmds_INQUIRY_Definitions.h (revision 885) @@ -0,0 +1,923 @@ +/* + * 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_SCSI_CMDS_INQUIRY_H_ +#define _IOKIT_SCSI_CMDS_INQUIRY_H_ + + +//----------------------------------------------------------------------------- +// Includes +//----------------------------------------------------------------------------- + +#if KERNEL +#include <IOKit/IOTypes.h> +#else +#include <CoreFoundation/CoreFoundation.h> +#endif + + +/*! @header SCSI Inquiry Definitions + @discussion + This file contains all definitions for the data returned from + the INQUIRY (0x12) command. +*/ + + +/*! + * @enum Payload sizes + * @discussion + * Definitions for sizes related to the INQUIRY data. + * @constant kINQUIRY_StandardDataHeaderSize + * INQUIRY data header size. + * @constant kINQUIRY_MaximumDataSize + * Maximum size for INQUIRY data. +*/ +enum +{ + kINQUIRY_StandardDataHeaderSize = 5, + kINQUIRY_MaximumDataSize = 255 +}; + + +/*! +@enum INQUIRY field sizes +@discussion +Sizes for some of the inquiry data fields. +@constant kINQUIRY_VENDOR_IDENTIFICATION_Length +Size of VENDOR_IDENTIFICATION field. +@constant kINQUIRY_PRODUCT_IDENTIFICATION_Length +Size of PRODUCT_IDENTIFICATION field. +@constant kINQUIRY_PRODUCT_REVISION_LEVEL_Length +Size of PRODUCT_REVISION_LEVEL field. +*/ +enum +{ + kINQUIRY_VENDOR_IDENTIFICATION_Length = 8, + kINQUIRY_PRODUCT_IDENTIFICATION_Length = 16, + kINQUIRY_PRODUCT_REVISION_LEVEL_Length = 4 +}; + + +/*! +@struct SCSICmd_INQUIRY_StandardData +@discussion +This structure defines the format of the required standard data that is +returned for the INQUIRY command. This is the data that is required to +be returned from all devices. +*/ +typedef struct SCSICmd_INQUIRY_StandardData +{ + UInt8 PERIPHERAL_DEVICE_TYPE; // 7-5 = Qualifier. 4-0 = Device type. + UInt8 RMB; // 7 = removable + UInt8 VERSION; // 7/6 = ISO/IEC, 5-3 = ECMA, 2-0 = ANSI. + UInt8 RESPONSE_DATA_FORMAT; // 7 = AERC, 6 = Obsolete, 5 = NormACA, 4 = HiSup 3-0 = Response data format. (SPC-3 obsoletes AERC) + // If ANSI Version = 0, this is ATAPI and bits 7-4 = ATAPI version. + UInt8 ADDITIONAL_LENGTH; // Number of additional bytes available in inquiry data + UInt8 SCCSReserved; // SCC-2 device flag and reserved fields (SPC-3 adds PROTECT 3PC TPGS, and ACC) + UInt8 flags1; // First byte of support flags (See SPC-3 section 6.4.2) + UInt8 flags2; // Second byte of support flags (Byte 7) (See SPC-3 section 6.4.2) + char VENDOR_IDENTIFICATION[kINQUIRY_VENDOR_IDENTIFICATION_Length]; + char PRODUCT_IDENTIFICATION[kINQUIRY_PRODUCT_IDENTIFICATION_Length]; + char PRODUCT_REVISION_LEVEL[kINQUIRY_PRODUCT_REVISION_LEVEL_Length]; +} SCSICmd_INQUIRY_StandardData; +typedef SCSICmd_INQUIRY_StandardData * SCSICmd_INQUIRY_StandardDataPtr; + + +/*! +@struct SCSICmd_INQUIRY_StandardDataAll +@discussion +This structure defines the all of the fields that can be returned in +repsonse to the INQUIRy request for the standard data. There is no +requirement as to how much of the additional data must be returned by a device. +*/ +typedef struct SCSICmd_INQUIRY_StandardDataAll +{ + UInt8 PERIPHERAL_DEVICE_TYPE; // 7-5 = Qualifier. 4-0 = Device type. + UInt8 RMB; // 7 = removable + UInt8 VERSION; // 7/6 = ISO/IEC, 5-3 = ECMA, 2-0 = ANSI. + UInt8 RESPONSE_DATA_FORMAT; // 7 = AERC, 6 = Obsolete, 5 = NormACA, 4 = HiSup 3-0 = Response data format. + // If ANSI Version = 0, this is ATAPI and bits 7-4 = ATAPI version. + UInt8 ADDITIONAL_LENGTH; // Number of additional bytes available in inquiry data + UInt8 SCCSReserved; // SCC-2 device flag and reserved fields + UInt8 flags1; // First byte of support flags (Byte 6) + UInt8 flags2; // Second byte of support flags (Byte 7) + char VENDOR_IDENTIFICATION[kINQUIRY_VENDOR_IDENTIFICATION_Length]; + char PRODUCT_IDENTIFICATION[kINQUIRY_PRODUCT_IDENTIFICATION_Length]; + char PRODUCT_REVISION_LEVEL[kINQUIRY_PRODUCT_REVISION_LEVEL_Length]; + + // Following is the optional data that may be returned by a device. + UInt8 VendorSpecific1[20]; + UInt8 flags3; // Third byte of support flags, mainly SPI-3 (Byte 56) + UInt8 Reserved1; + UInt16 VERSION_DESCRIPTOR[8]; + UInt8 Reserved2[22]; + UInt8 VendorSpecific2[160]; +} SCSICmd_INQUIRY_StandardDataAll; + + +/*! +@enum Peripheral Qualifier +@discussion +Inquiry Peripheral Qualifier definitions +@constant kINQUIRY_PERIPHERAL_QUALIFIER_Connected +Peripheral Device is connected. +@constant kINQUIRY_PERIPHERAL_QUALIFIER_SupportedButNotConnected +Peripheral Device is supported, but not connected. +@constant kINQUIRY_PERIPHERAL_QUALIFIER_NotSupported +Peripheral Device is not supported. +@constant kINQUIRY_PERIPHERAL_QUALIFIER_Mask +Mask to use for PERIPHERAL_DEVICE_TYPE field. +*/ +enum +{ + kINQUIRY_PERIPHERAL_QUALIFIER_Connected = 0x00, + kINQUIRY_PERIPHERAL_QUALIFIER_SupportedButNotConnected = 0x20, + kINQUIRY_PERIPHERAL_QUALIFIER_NotSupported = 0x60, + kINQUIRY_PERIPHERAL_QUALIFIER_Mask = 0xE0 +}; + + +/*! +@enum Peripheral Device types +@discussion +Inquiry Peripheral Device type definitions +@constant kINQUIRY_PERIPHERAL_TYPE_DirectAccessSBCDevice +SBC Device. +@constant kINQUIRY_PERIPHERAL_TYPE_SequentialAccessSSCDevice +Sequential Access (Tape) SSC Device. +@constant kINQUIRY_PERIPHERAL_TYPE_PrinterSSCDevice +SSC Device. +@constant kINQUIRY_PERIPHERAL_TYPE_ProcessorSPCDevice +SPC Device. +@constant kINQUIRY_PERIPHERAL_TYPE_WriteOnceSBCDevice +SBC Device. +@constant kINQUIRY_PERIPHERAL_TYPE_CDROM_MMCDevice +MMC Device. +@constant kINQUIRY_PERIPHERAL_TYPE_ScannerSCSI2Device +SCSI2 Device. +@constant kINQUIRY_PERIPHERAL_TYPE_OpticalMemorySBCDevice +SBC Device. +@constant kINQUIRY_PERIPHERAL_TYPE_MediumChangerSMCDevice +SMC Device. +@constant kINQUIRY_PERIPHERAL_TYPE_CommunicationsSSCDevice +Comms SSC Device. +@constant kINQUIRY_PERIPHERAL_TYPE_StorageArrayControllerSCC2Device +SCC2 Device. +@constant kINQUIRY_PERIPHERAL_TYPE_EnclosureServicesSESDevice +SES Device. +@constant kINQUIRY_PERIPHERAL_TYPE_SimplifiedDirectAccessRBCDevice +RBC Device. +@constant kINQUIRY_PERIPHERAL_TYPE_OpticalCardReaderOCRWDevice +OCRW Device. +@constant kINQUIRY_PERIPHERAL_TYPE_ObjectBasedStorageDevice +OSD device. +@constant kINQUIRY_PERIPHERAL_TYPE_AutomationDriveInterface +Automation Drive Interface device. +@constant kINQUIRY_PERIPHERAL_TYPE_WellKnownLogicalUnit +Well known logical unit. +@constant kINQUIRY_PERIPHERAL_TYPE_UnknownOrNoDeviceType +Unknown or no device. +@constant kINQUIRY_PERIPHERAL_TYPE_Mask +Mask to use for PERIPHERAL_DEVICE_TYPE field. +*/ +enum +{ + kINQUIRY_PERIPHERAL_TYPE_DirectAccessSBCDevice = 0x00, + kINQUIRY_PERIPHERAL_TYPE_SequentialAccessSSCDevice = 0x01, + kINQUIRY_PERIPHERAL_TYPE_PrinterSSCDevice = 0x02, + kINQUIRY_PERIPHERAL_TYPE_ProcessorSPCDevice = 0x03, + kINQUIRY_PERIPHERAL_TYPE_WriteOnceSBCDevice = 0x04, + kINQUIRY_PERIPHERAL_TYPE_CDROM_MMCDevice = 0x05, + kINQUIRY_PERIPHERAL_TYPE_ScannerSCSI2Device = 0x06, + kINQUIRY_PERIPHERAL_TYPE_OpticalMemorySBCDevice = 0x07, + kINQUIRY_PERIPHERAL_TYPE_MediumChangerSMCDevice = 0x08, + kINQUIRY_PERIPHERAL_TYPE_CommunicationsSSCDevice = 0x09, + /* 0x0A - 0x0B ASC IT8 Graphic Arts Prepress Devices */ + kINQUIRY_PERIPHERAL_TYPE_StorageArrayControllerSCC2Device = 0x0C, + kINQUIRY_PERIPHERAL_TYPE_EnclosureServicesSESDevice = 0x0D, + kINQUIRY_PERIPHERAL_TYPE_SimplifiedDirectAccessRBCDevice = 0x0E, + kINQUIRY_PERIPHERAL_TYPE_OpticalCardReaderOCRWDevice = 0x0F, + /* 0x10 - 0x1E Reserved Device Types */ + kINQUIRY_PERIPHERAL_TYPE_ObjectBasedStorageDevice = 0x11, + kINQUIRY_PERIPHERAL_TYPE_AutomationDriveInterface = 0x12, + kINQUIRY_PERIPHERAL_TYPE_WellKnownLogicalUnit = 0x1E, + kINQUIRY_PERIPHERAL_TYPE_UnknownOrNoDeviceType = 0x1F, + + + kINQUIRY_PERIPHERAL_TYPE_Mask = 0x1F +}; + + +/*! +@enum Removable Bit field definitions +@discussion +Inquiry Removable Bit field definitions +@constant kINQUIRY_PERIPHERAL_RMB_MediumFixed +Medium type is fixed disk. +@constant kINQUIRY_PERIPHERAL_RMB_MediumRemovable +Medium type is removable disk. +@constant kINQUIRY_PERIPHERAL_RMB_BitMask +Mask to use for RMB field. +*/ +enum +{ + kINQUIRY_PERIPHERAL_RMB_MediumFixed = 0x00, + kINQUIRY_PERIPHERAL_RMB_MediumRemovable = 0x80, + kINQUIRY_PERIPHERAL_RMB_BitMask = 0x80 +}; + + +/*! +@enum Version field definitions +@discussion +Definitions for bits/masks in the INQUIRY Version field. +@constant kINQUIRY_ISO_IEC_VERSION_Mask +Mask for valid bits for ISO/IEC Version. +@constant kINQUIRY_ECMA_VERSION_Mask +Mask for valid bits for ECMA Version. +@constant kINQUIRY_ANSI_VERSION_NoClaimedConformance +No ANSI conformance claimed by the device server. +@constant kINQUIRY_ANSI_VERSION_SCSI_1_Compliant +SCSI-1 conformance claimed by the device server. +@constant kINQUIRY_ANSI_VERSION_SCSI_2_Compliant +SCSI-2 conformance claimed by the device server. +@constant kINQUIRY_ANSI_VERSION_SCSI_SPC_Compliant +SPC conformance claimed by the device server. +@constant kINQUIRY_ANSI_VERSION_SCSI_SPC_2_Compliant +SPC-2 conformance claimed by the device server. +@constant kINQUIRY_ANSI_VERSION_SCSI_SPC_3_Compliant +SPC-3 conformance claimed by the device server. +@constant kINQUIRY_ANSI_VERSION_Mask +Mask for valid bits for ANSI Version. +*/ +enum +{ + kINQUIRY_ISO_IEC_VERSION_Mask = 0xC0, + + kINQUIRY_ECMA_VERSION_Mask = 0x38, + + kINQUIRY_ANSI_VERSION_NoClaimedConformance = 0x00, + kINQUIRY_ANSI_VERSION_SCSI_1_Compliant = 0x01, + kINQUIRY_ANSI_VERSION_SCSI_2_Compliant = 0x02, + kINQUIRY_ANSI_VERSION_SCSI_SPC_Compliant = 0x03, + kINQUIRY_ANSI_VERSION_SCSI_SPC_2_Compliant = 0x04, + kINQUIRY_ANSI_VERSION_SCSI_SPC_3_Compliant = 0x05, + kINQUIRY_ANSI_VERSION_Mask = 0x07 +}; + + +/*! +@enum Response Data Format field definitions +@discussion +Definitions for bits/masks in the INQUIRY RESPONSE_DATA_FORMAT field. +@constant kINQUIRY_Byte3_HISUP_Bit +HISUP bit definition. +@constant kINQUIRY_Byte3_NORMACA_Bit +NORMACA bit definition. +@constant kINQUIRY_Byte3_AERC_Bit +AERC bit definition. +@constant kINQUIRY_RESPONSE_DATA_FORMAT_Mask +Mask for valid bits for RESPONSE_DATA_FORMAT. +@constant kINQUIRY_Byte3_HISUP_Mask +Mask to use to test the HISUP bit. +@constant kINQUIRY_Byte3_NORMACA_Mask +Mask to use to test the NORMACA bit. +@constant kINQUIRY_Byte3_AERC_Mask +Mask to use to test the AERC bit. +*/ +enum +{ + // Bit definitions + // Bits 0-3: RESPONSE DATA FORMAT + kINQUIRY_Byte3_HISUP_Bit = 4, + kINQUIRY_Byte3_NORMACA_Bit = 5, + // Bit 6 is Obsolete + kINQUIRY_Byte3_AERC_Bit = 7, + + // Masks + kINQUIRY_RESPONSE_DATA_FORMAT_Mask = 0x0F, // Bits 0-3 + kINQUIRY_Byte3_HISUP_Mask = (1 << kINQUIRY_Byte3_HISUP_Bit), + kINQUIRY_Byte3_NORMACA_Mask = (1 << kINQUIRY_Byte3_NORMACA_Bit), + // Bit 6 is Obsolete + kINQUIRY_Byte3_AERC_Mask = (1 << kINQUIRY_Byte3_AERC_Bit) +}; + + +/*! +@enum SCCS field definitions +@discussion +Definitions for bits/masks in the INQUIRY SCCSReserved field. +@constant kINQUIRY_Byte5_SCCS_Bit +SCCS bit definition. +@constant kINQUIRY_Byte5_ACC_Bit +ACC bit definition. +@constant kINQUIRY_Byte5_3PC_Bit +3PC bit definition. +@constant kINQUIRY_Byte5_PROTECT_Bit +PROTECT bit definition. +@constant kINQUIRY_Byte5_SCCS_Mask +Mask to use to test the SCCS bit. +@constant kINQUIRY_Byte5_ACC_Mask +Mask to use to test the ACC bit. +@constant kINQUIRY_Byte5_TPGS_Mask +Mask to use for the TPGS bits. +@constant kINQUIRY_Byte5_3PC_Mask +Mask to use to test the 3PC bit. +@constant kINQUIRY_Byte5_PROTECT_Mask +Mask to use to test the PROTECT bit. +*/ +enum +{ + // Bit definitions + kINQUIRY_Byte5_SCCS_Bit = 7, + kINQUIRY_Byte5_ACC_Bit = 6, + // Bits 4-5: TPGS + kINQUIRY_Byte5_3PC_Bit = 3, + // Bits 1-2: Reserved + kINQUIRY_Byte5_PROTECT_Bit = 0, + + // Masks + kINQUIRY_Byte5_SCCS_Mask = (1 << kINQUIRY_Byte5_SCCS_Bit), + kINQUIRY_Byte5_ACC_Mask = (1 << kINQUIRY_Byte5_ACC_Bit), + kINQUIRY_Byte5_TPGS_Mask = 0x18, + kINQUIRY_Byte5_3PC_Mask = (1 << kINQUIRY_Byte5_3PC_Bit), + // Bits 1-2: Reserved + kINQUIRY_Byte5_PROTECT_Mask = (1 << kINQUIRY_Byte5_PROTECT_Bit) +}; + + +/*! +@enum flags1 field definitions +@discussion +Definitions for bits/masks in the INQUIRY flags1 field. +@constant kINQUIRY_Byte6_ADDR16_Bit +ADDR16 bit definition. +@constant kINQUIRY_Byte6_MCHNGR_Bit +MCHNGR bit definition. +@constant kINQUIRY_Byte6_MULTIP_Bit +MULTIP bit definition. +@constant kINQUIRY_Byte6_VS_Bit +VS bit definition. +@constant kINQUIRY_Byte6_ENCSERV_Bit +ENCSERV bit definition. +@constant kINQUIRY_Byte6_BQUE_Bit +BQUE bit definition. +@constant kINQUIRY_Byte6_ADDR16_Mask +Mask to use to test the ADDR16 bit. +@constant kINQUIRY_Byte6_MCHNGR_Mask +Mask to use to test the MCHNGR bit. +@constant kINQUIRY_Byte6_MULTIP_Mask +Mask to use to test the MULTIP bit. +@constant kINQUIRY_Byte6_VS_Mask +Mask to use to test the VS bit. +@constant kINQUIRY_Byte6_ENCSERV_Mask +Mask to use to test the ENCSERV bit. +@constant kINQUIRY_Byte6_BQUE_Mask +Mask to use to test the BQUE bit. +*/ +enum +{ + // Byte offset + kINQUIRY_Byte6_Offset = 6, + + // Bit definitions + kINQUIRY_Byte6_ADDR16_Bit = 0, // SPI Specific + // Bit 1 is Obsolete + // Bit 2 is Obsolete + kINQUIRY_Byte6_MCHNGR_Bit = 3, + kINQUIRY_Byte6_MULTIP_Bit = 4, + kINQUIRY_Byte6_VS_Bit = 5, + kINQUIRY_Byte6_ENCSERV_Bit = 6, + kINQUIRY_Byte6_BQUE_Bit = 7, + + // Masks + kINQUIRY_Byte6_ADDR16_Mask = (1 << kINQUIRY_Byte6_ADDR16_Bit), // SPI Specific + // Bit 1 is Obsolete + // Bit 2 is Obsolete + kINQUIRY_Byte6_MCHNGR_Mask = (1 << kINQUIRY_Byte6_MCHNGR_Bit), + kINQUIRY_Byte6_MULTIP_Mask = (1 << kINQUIRY_Byte6_MULTIP_Bit), + kINQUIRY_Byte6_VS_Mask = (1 << kINQUIRY_Byte6_VS_Bit), + kINQUIRY_Byte6_ENCSERV_Mask = (1 << kINQUIRY_Byte6_ENCSERV_Bit), + kINQUIRY_Byte6_BQUE_Mask = (1 << kINQUIRY_Byte6_BQUE_Bit) +}; + + +/*! +@enum flags2 field definitions +@discussion +Definitions for bits/masks in the INQUIRY flags2 field. +@constant kINQUIRY_Byte7_VS_Bit +VS bit definition. +@constant kINQUIRY_Byte7_CMDQUE_Bit +CMDQUE bit definition. +@constant kINQUIRY_Byte7_TRANDIS_Bit +TRANDIS bit definition. +@constant kINQUIRY_Byte7_LINKED_Bit +LINKED bit definition. +@constant kINQUIRY_Byte7_SYNC_Bit +SYNC bit definition. +@constant kINQUIRY_Byte7_WBUS16_Bit +WBUS16 bit definition. +@constant kINQUIRY_Byte7_RELADR_Bit +RELADR bit definition. +@constant kINQUIRY_Byte7_VS_Mask +Mask to use to test the VS bit. +@constant kINQUIRY_Byte7_CMDQUE_Mask +Mask to use to test the CMDQUE bit. +@constant kINQUIRY_Byte7_TRANDIS_Mask +Mask to use to test the TRANDIS bit. +@constant kINQUIRY_Byte7_LINKED_Mask +Mask to use to test the LINKED bit. +@constant kINQUIRY_Byte7_SYNC_Mask +Mask to use to test the SYNC bit. +@constant kINQUIRY_Byte7_WBUS16_Mask +Mask to use to test the WBUS16 bit. +@constant kINQUIRY_Byte7_RELADR_Mask +Mask to use to test the RELADR bit. +*/ +enum +{ + // Byte offset + kINQUIRY_Byte7_Offset = 7, + + // Bit definitions + kINQUIRY_Byte7_VS_Bit = 0, + kINQUIRY_Byte7_CMDQUE_Bit = 1, + kINQUIRY_Byte7_TRANDIS_Bit = 2, // SPI Specific + kINQUIRY_Byte7_LINKED_Bit = 3, + kINQUIRY_Byte7_SYNC_Bit = 4, // SPI Specific + kINQUIRY_Byte7_WBUS16_Bit = 5, // SPI Specific + // Bit 6 is Obsolete + kINQUIRY_Byte7_RELADR_Bit = 7, + + // Masks + kINQUIRY_Byte7_VS_Mask = (1 << kINQUIRY_Byte7_VS_Bit), + kINQUIRY_Byte7_CMDQUE_Mask = (1 << kINQUIRY_Byte7_CMDQUE_Bit), + kINQUIRY_Byte7_TRANDIS_Mask = (1 << kINQUIRY_Byte7_TRANDIS_Bit),// SPI Specific + kINQUIRY_Byte7_LINKED_Mask = (1 << kINQUIRY_Byte7_LINKED_Bit), + kINQUIRY_Byte7_SYNC_Mask = (1 << kINQUIRY_Byte7_SYNC_Bit), // SPI Specific + kINQUIRY_Byte7_WBUS16_Mask = (1 << kINQUIRY_Byte7_WBUS16_Bit), // SPI Specific + // Bit 6 is Obsolete + kINQUIRY_Byte7_RELADR_Mask = (1 << kINQUIRY_Byte7_RELADR_Bit) +}; + + +/*! +@enum Byte 56 features field definitions +@discussion +Definitions for bits/masks in the INQUIRY Byte 56 field. +Inquiry Byte 56 features (for devices that report an ANSI VERSION of +kINQUIRY_ANSI_VERSION_SCSI_SPC_Compliant or later). +These are SPI-3 Specific. +@constant kINQUIRY_Byte56_IUS_Bit +IUS bit definition. +@constant kINQUIRY_Byte56_QAS_Bit +QAS bit definition. +@constant kINQUIRY_Byte56_IUS_Mask +Mask to use to test the IUS bit. +@constant kINQUIRY_Byte56_QAS_Mask +Mask to use to test the QAS bit. +@constant kINQUIRY_Byte56_CLOCKING_Mask +Mask to use to test CLOCKING bits. +@constant kINQUIRY_Byte56_CLOCKING_ONLY_ST +Single-transition clocking only. +@constant kINQUIRY_Byte56_CLOCKING_ONLY_DT +Double-transition clocking only. +@constant kINQUIRY_Byte56_CLOCKING_ST_AND_DT +Single-transition and double-transition clocking. +*/ +enum +{ + // Byte offset + kINQUIRY_Byte56_Offset = 56, + + // Bit definitions + kINQUIRY_Byte56_IUS_Bit = 0, + kINQUIRY_Byte56_QAS_Bit = 1, + // Bits 2 and 3 are the CLOCKING bits + // All other bits are reserved + + kINQUIRY_Byte56_IUS_Mask = (1 << kINQUIRY_Byte56_IUS_Bit), + kINQUIRY_Byte56_QAS_Mask = (1 << kINQUIRY_Byte56_QAS_Bit), + kINQUIRY_Byte56_CLOCKING_Mask = 0x0C, + + // Definitions for the CLOCKING bits + kINQUIRY_Byte56_CLOCKING_ONLY_ST = 0x00, + kINQUIRY_Byte56_CLOCKING_ONLY_DT = 0x04, + // kINQUIRY_Byte56_CLOCKING_RESERVED = 0x08, + kINQUIRY_Byte56_CLOCKING_ST_AND_DT = 0x0C +}; + + +/*! +@define kINQUIRY_VERSION_DESCRIPTOR_MaxCount +Maximum number of INQUIRY version descriptors supported. +*/ +#define kINQUIRY_VERSION_DESCRIPTOR_MaxCount 8 + + +/*! +@enum kINQUIRY_VERSION_DESCRIPTOR_SAT +SAT specification version descriptor. +*/ +enum +{ + kINQUIRY_VERSION_DESCRIPTOR_SAT = 0x1EA0 +}; + + +/* +IORegistry property names for information derived from the Inquiry data. +The Peripheral Device Type is the only property that the +generic Logical Unit Drivers will use to match. These properties are +listed in order of matching priority. First is the Peripheral Device Type. +Second is the Vendor Identification. Third is the Product Identification. +Last is the Product Revision Level. To match a particular product, you would +specify the Peripheral Device Type, Vendor Identification, and Product +Identification. To restrict the match to a particular firmware revision, you +would add the Product Revision Level. To not match on a particular product, +but on a particular vendor's products, you would only include the +Peripheral Device Type and the Vendor Identification. +*/ + +/*! +@define kIOPropertySCSIPeripheralDeviceType +SCSI Peripheral Device Type as reported in the INQUIRY data. +*/ +#define kIOPropertySCSIPeripheralDeviceType "Peripheral Device Type" + +/*! +@define kIOPropertySCSIPeripheralDeviceTypeSize +Size of the kIOPropertySCSIPeripheralDeviceType key. +*/ +#define kIOPropertySCSIPeripheralDeviceTypeSize 8 + +/* These properties are listed in order of matching priority */ + +/*! +@define kIOPropertySCSIVendorIdentification +Vendor ID as reported in the INQUIRY data. Additional space characters (0x20) +are truncated. +*/ +#define kIOPropertySCSIVendorIdentification "Vendor Identification" + +/*! +@define kIOPropertySCSIProductIdentification +Product ID as reported in the INQUIRY data. Additional space characters (0x20) +are truncated. +*/ +#define kIOPropertySCSIProductIdentification "Product Identification" + +/*! +@define kIOPropertySCSIProductRevisionLevel +Product Revision Level as reported in the INQUIRY data. +*/ +#define kIOPropertySCSIProductRevisionLevel "Product Revision Level" + + +/*! +@enum INQUIRY Page Codes +@discussion INQUIRY Page Codes to be used when EVPD is set in the +INQUIRY command. +@constant kINQUIRY_Page00_PageCode +Page Code 00h. +@constant kINQUIRY_Page80_PageCode +Page Code 80h. +@constant kINQUIRY_Page83_PageCode +Page Code 83h. +@constant kINQUIRY_Page89_PageCode +Page Code 89h. +*/ +enum +{ + kINQUIRY_Page00_PageCode = 0x00, + kINQUIRY_Page80_PageCode = 0x80, + kINQUIRY_Page83_PageCode = 0x83, + kINQUIRY_Page89_PageCode = 0x89 +}; + + +/*! +@struct SCSICmd_INQUIRY_Page00_Header +@discussion INQUIRY Page 00h Header. +*/ +typedef struct SCSICmd_INQUIRY_Page00_Header +{ + UInt8 PERIPHERAL_DEVICE_TYPE; // 7-5 = Qualifier. 4-0 = Device type. + UInt8 PAGE_CODE; // Must be equal to 00h + UInt8 RESERVED; // reserved field + UInt8 PAGE_LENGTH; // n-3 bytes +} SCSICmd_INQUIRY_Page00_Header; + + +/*! +@struct SCSICmd_INQUIRY_Page80_Header +@discussion INQUIRY Page 80h Header. +*/ +typedef struct SCSICmd_INQUIRY_Page80_Header +{ + UInt8 PERIPHERAL_DEVICE_TYPE; // 7-5 = Qualifier. 4-0 = Device type. + UInt8 PAGE_CODE; // Must be equal to 80h + UInt8 RESERVED; // reserved field + UInt8 PAGE_LENGTH; // n-3 bytes + UInt8 PRODUCT_SERIAL_NUMBER; // 4-n +} SCSICmd_INQUIRY_Page80_Header; + + +/*! +@define kIOPropertySCSIINQUIRYUnitSerialNumber +Key that describes the INQUIRY Unit Serial Number in the IORegistry. +*/ +#define kIOPropertySCSIINQUIRYUnitSerialNumber "INQUIRY Unit Serial Number" + + +/*! +@struct SCSICmd_INQUIRY_Page83_Header +@discussion INQUIRY Page 83h Header. +*/ +typedef struct SCSICmd_INQUIRY_Page83_Header +{ + UInt8 PERIPHERAL_DEVICE_TYPE; // 7-5 = Qualifier. 4-0 = Device type. + UInt8 PAGE_CODE; // Must be equal to 83h + UInt8 RESERVED; // reserved field + UInt8 PAGE_LENGTH; // n-3 bytes +} SCSICmd_INQUIRY_Page83_Header; + + +/*! +@struct SCSICmd_INQUIRY_Page83_Header_SPC_16 +@discussion INQUIRY Page 83h Header used with the 16 byte INQUIRY command. +*/ +typedef struct SCSICmd_INQUIRY_Page83_Header_SPC_16 +{ + UInt8 PERIPHERAL_DEVICE_TYPE; // 7-5 = Qualifier. 4-0 = Device type. + UInt8 PAGE_CODE; // Must be equal to 83h + UInt16 PAGE_LENGTH; // n-3 bytes +} SCSICmd_INQUIRY_Page83_Header_SPC_16; + + +/*! +@struct SCSICmd_INQUIRY_Page83_Identification_Descriptor +@discussion INQUIRY Page 83h Identification Descriptor. +*/ +typedef struct SCSICmd_INQUIRY_Page83_Identification_Descriptor +{ + UInt8 CODE_SET; // 7-4 = Protocol Identifier. 3-0 = Code Set + UInt8 IDENTIFIER_TYPE; // 7 = PIV 5-4 = ASSOCIATION 3-0 = Identifier + UInt8 RESERVED; + UInt8 IDENTIFIER_LENGTH; + UInt8 IDENTIFIER; +} SCSICmd_INQUIRY_Page83_Identification_Descriptor; + + +/*! +@enum INQUIRY Page 83h Code Set +@discussion +Definitions for the Code Set field. +@constant kINQUIRY_Page83_CodeSetBinaryData +The identifier contains binary data. +@constant kINQUIRY_Page83_CodeSetASCIIData +The identifier contains ASCII data. +@constant kINQUIRY_Page83_CodeSetUTF8Data +The identifier contains UTF-8 data. +*/ +enum +{ + kINQUIRY_Page83_CodeSetReserved = 0x0, + kINQUIRY_Page83_CodeSetBinaryData = 0x1, + kINQUIRY_Page83_CodeSetASCIIData = 0x2, + kINQUIRY_Page83_CodeSetUTF8Data = 0x3, + // 0x4 - 0xF reserved + kINQUIRY_Page83_CodeSetMask = 0xF +}; + + +/*! +@enum INQUIRY Page 83h Association +@discussion +Definitions for the Association field. +@constant kINQUIRY_Page83_AssociationLogicalUnit +Association of the identifier is with the logical unit. +@constant kINQUIRY_Page83_AssociationDevice +Association of the identifier is with the device (same as logical unit in SPC-2). +@constant kINQUIRY_Page83_AssociationTargetPort +Association of the identifier is with the target port. +@constant kINQUIRY_Page83_AssociationTargetDevice +Association of the identifier is with the target device (i.e. all ports). +@constant kINQUIRY_Page83_AssociationMask +Mask to use to determine association. +*/ +enum +{ + // SPC-3 - Association is changed to be specific to + // Logical Units + kINQUIRY_Page83_AssociationLogicalUnit = 0x00, + + // Backwards compatibility for SPC-2 + kINQUIRY_Page83_AssociationDevice = kINQUIRY_Page83_AssociationLogicalUnit, + + // Association is related to a Target Port + kINQUIRY_Page83_AssociationTargetPort = 0x10, + + // SPC-3 - Added as specific association to + // a Target device. + kINQUIRY_Page83_AssociationTargetDevice = 0x20, + + kINQUIRY_Page83_AssociationMask = 0x30 +}; + + +/*! +@enum INQUIRY Page 83h Identifier Type +@discussion +Definitions for the Identifier Type field. +@constant kINQUIRY_Page83_IdentifierTypeUndefined +Undefined Identifier Type. +@constant kINQUIRY_Page83_IdentifierTypeVendorID +Vendor Specific Identifier Type. +@constant kINQUIRY_Page83_IdentifierTypeIEEE_EUI64 +EUI-64 Identifier Type. +@constant kINQUIRY_Page83_IdentifierTypeNAAIdentifier +NAA Identifier Type. +@constant kINQUIRY_Page83_IdentifierTypeRelativePortIdentifier +Relative Target Port Identifier Type. +@constant kINQUIRY_Page83_IdentifierTypeTargetPortGroup +Target Port Group Identifier Type. +@constant kINQUIRY_Page83_IdentifierTypeLogicalUnitGroup +Logical Unit Group Identifier Type. +@constant kINQUIRY_Page83_IdentifierTypeMD5LogicalUnitIdentifier +MD5 Logical Unit Identifier Type. +@constant kINQUIRY_Page83_IdentifierTypeSCSINameString +SCSI Name String Identifier Type. +@constant kINQUIRY_Page83_IdentifierTypeMask +Mask to use to determine association. +@constant kINQUIRY_Page83_ProtocolIdentifierValidBit +PIV Bit definition. +@constant kINQUIRY_Page83_ProtocolIdentifierValidMask +Mask to use to determine if PIV is set. +*/ +enum +{ + kINQUIRY_Page83_IdentifierTypeUndefined = 0, + kINQUIRY_Page83_IdentifierTypeVendorID = 1, + kINQUIRY_Page83_IdentifierTypeIEEE_EUI64 = 2, + kINQUIRY_Page83_IdentifierTypeNAAIdentifier = 3, + kINQUIRY_Page83_IdentifierTypeRelativePortIdentifier = 4, + kINQUIRY_Page83_IdentifierTypeTargetPortGroup = 5, + kINQUIRY_Page83_IdentifierTypeLogicalUnitGroup = 6, + kINQUIRY_Page83_IdentifierTypeMD5LogicalUnitIdentifier = 7, + kINQUIRY_Page83_IdentifierTypeSCSINameString = 8, + // 0x9 - 0xF Reserved + + kINQUIRY_Page83_IdentifierTypeMask = 0xF, + + kINQUIRY_Page83_ProtocolIdentifierValidBit = 7, + kINQUIRY_Page83_ProtocolIdentifierValidMask = (1 << kINQUIRY_Page83_ProtocolIdentifierValidBit) + +}; + +// Backwards compatibility +#define kINQUIRY_Page83_IdentifierTypeFCNameIdentifier kINQUIRY_Page83_IdentifierTypeNAAIdentifier + + +/*! +@enum Protocol Identifier values +@discussion +Definitions for the protocol identifier values. +@constant kSCSIProtocolIdentifier_FibreChannel +FibreChannel Protocol Identifier. +@constant kSCSIProtocolIdentifier_ParallelSCSI +Parallel SCSI Protocol Identifier. +@constant kSCSIProtocolIdentifier_SSA +SSA Protocol Identifier. +@constant kSCSIProtocolIdentifier_FireWire +FireWire (IEEE-1394) Protocol Identifier. +@constant kSCSIProtocolIdentifier_RDMA +RDMA Protocol Identifier. +@constant kSCSIProtocolIdentifier_iSCSI +iSCSI Protocol Identifier. +@constant kSCSIProtocolIdentifier_SAS +SAS Protocol Identifier. +@constant kSCSIProtocolIdentifier_ADT +ADT Protocol Identifier. +@constant kSCSIProtocolIdentifier_ATAPI +ATAPI Protocol Identifier. +@constant kSCSIProtocolIdentifier_None +No Protocol Identifier. +*/ +enum +{ + kSCSIProtocolIdentifier_FibreChannel = 0, + kSCSIProtocolIdentifier_ParallelSCSI = 1, + kSCSIProtocolIdentifier_SSA = 2, + kSCSIProtocolIdentifier_FireWire = 3, + kSCSIProtocolIdentifier_RDMA = 4, + kSCSIProtocolIdentifier_iSCSI = 5, + kSCSIProtocolIdentifier_SAS = 6, + kSCSIProtocolIdentifier_ADT = 7, + kSCSIProtocolIdentifier_ATAPI = 8, + // 0x9-0xE Reserved + kSCSIProtocolIdentifier_None = 0xF +}; + + +/*! +@define kIOPropertySCSIINQUIRYDeviceIdentification +Device Identification key. +*/ +#define kIOPropertySCSIINQUIRYDeviceIdentification "INQUIRY Device Identification" + + +/*! +@define kIOPropertySCSIINQUIRYDeviceIdCodeSet +Code Set type key. +*/ +#define kIOPropertySCSIINQUIRYDeviceIdCodeSet "Code Set" + + +/*! +@define kIOPropertySCSIINQUIRYDeviceIdType +Identifier Type key. +*/ +#define kIOPropertySCSIINQUIRYDeviceIdType "Identifier Type" + + +/*! +@define kIOPropertySCSIINQUIRYDeviceIdAssociation +Association key. +*/ +#define kIOPropertySCSIINQUIRYDeviceIdAssociation "Association" + + +/*! +@define kIOPropertySCSIINQUIRYDeviceIdentifier +Identifier key (data or string). +*/ +#define kIOPropertySCSIINQUIRYDeviceIdentifier "Identifier" + + +/*! +@struct SCSICmd_INQUIRY_Page89_Data +@discussion INQUIRY Page 89h data as defined in the SAT 1.0 +specification. This section contians all structures and +definitions used by the INQUIRY command in response to a request +for page 89h - ATA information VPD Page. +*/ +typedef struct SCSICmd_INQUIRY_Page89_Data +{ + UInt8 PERIPHERAL_DEVICE_TYPE; // 7-5 = Qualifier. 4-0 = Device type. + UInt8 PAGE_CODE; // Must be equal to 89h + UInt16 PAGE_LENGTH; // Must be equal to 238h + UInt32 Reserved; + UInt8 SAT_VENDOR_IDENTIFICATION[kINQUIRY_VENDOR_IDENTIFICATION_Length]; + UInt8 SAT_PRODUCT_IDENTIFICATION[kINQUIRY_PRODUCT_IDENTIFICATION_Length]; + UInt8 SAT_PRODUCT_REVISION_LEVEL[kINQUIRY_PRODUCT_REVISION_LEVEL_Length]; + UInt8 ATA_DEVICE_SIGNATURE[20]; + UInt8 COMMAND_CODE; + UInt8 Reserved2[3]; + UInt8 IDENTIFY_DATA[512]; +} SCSICmd_INQUIRY_Page89_Data; + + +/*! +@define kIOPropertySATVendorIdentification +Vendor Identification of the SATL. +*/ +#define kIOPropertySATVendorIdentification "SAT Vendor Identification" + + +/*! +@define kIOPropertySATProductIdentification +Product Identification of the SATL. +*/ +#define kIOPropertySATProductIdentification "SAT Product Identification" + + +/*! +@define kIOPropertySATProductRevisonLevel +Product Revision Level of the SATL. +*/ +#define kIOPropertySATProductRevisonLevel "SAT Product Revision Level" + + +#endif /* _IOKIT_SCSI_CMDS_INQUIRY_H_ */ Index: branches/azimutz/Cleancut/i386/include/IOKit/scsi/SCSITask.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/scsi/SCSITask.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/scsi/SCSITask.h (revision 885) @@ -0,0 +1,456 @@ +/* + * 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_SCSI_TASK_H_ +#define _IOKIT_SCSI_TASK_H_ + + +#if KERNEL +#include <IOKit/IOTypes.h> +#else +#include <CoreFoundation/CoreFoundation.h> +#endif + + +/*! @header SCSITask +SCSITask typedefs and constants used inside the kernel and user space. + +Note that the SCSITaskIdentifier is an opaque object and that directly +casting the SCSITaskIdentifier to any other type is discouraged. The SCSITask +implementation changes when necessary to accomodate architectural changes, +performance improvements, and bug fixes. + +Device and protocol layer drivers that need to access information +contained in a SCSITask should use the appropriate accessor methods in +IOSCSIPrimaryCommandsDevice.h or IOSCSIProtocolServices.h +*/ + + +/*! @typedef SCSIDeviceIdentifier + @abstract 64-bit number to represent a SCSI Device. + @discussion If the identifier can either be that of an initiator or a target, + SCSIDeviceIdentifier should be used. +*/ + +typedef UInt64 SCSIDeviceIdentifier; + +/*! @typedef SCSITargetIdentifier + @abstract 64-bit number to represent a SCSI Target Device. + @discussion If the identifier is for a target only and not an initiator, then + SCSITargetIdentifier should be used. +*/ + +typedef SCSIDeviceIdentifier SCSITargetIdentifier; + +/*! @typedef SCSIInitiatorIdentifier + @abstract 64-bit number to represent a SCSI Initiator Device. + @discussion If the identifier is for an initiator only and not a target, then + SCSIInitiatorIdentifier should be used. +*/ + +typedef SCSIDeviceIdentifier SCSIInitiatorIdentifier; + +/*! @typedef SCSILogicalUnitNumber + @abstract 64-bit number to represent a logical unit. + @discussion 64-bit number to represent a logical unit. +*/ + +typedef UInt64 SCSILogicalUnitNumber; + +/*! @typedef SCSITaggedTaskIdentifier + @abstract 64-bit number to represent a unique task identifier. + @discussion The Tagged Task Identifier is used when a Task has a Task Attribute other + than SIMPLE. The SCSI Application Layer client that controls the Logical + Unit for which a Task is intended is required to guarantee that the Task + Tag Identifier is unique. Zero cannot be used a a Tag value as this is used + to when a Tagged Task Identifier value is needed for a Task with a SIMPLE + attribute. +*/ + +typedef UInt64 SCSITaggedTaskIdentifier; + +/*! + @enum Untagged Task Identifier + @discussion The Untagged Task Identifier is used to indicate no unique tag + is associated with the Task. + @constant kSCSIUntaggedTaskIdentifier This value means the task is untagged. + */ + +enum +{ + kSCSIUntaggedTaskIdentifier = 0 +}; + +/*! + @typedef SCSITaskAttribute + @abstract Attributes for task delivery. + @discussion The Task Attribute defines how this task should be managed + when determing order for queueing and submission to the + appropriate device server. The Task Attribute is set by the SCSI + Application Layer and cannot be modified by the SCSI Protocol Layer. + @constant kSCSITask_SIMPLE The task has a simple attribute. + @constant kSCSITask_ORDERED The task has an ordered attribute. + @constant kSCSITask_HEAD_OF_QUEUE The task has a head-of-queue attribute. + @constant kSCSITask_ACA The task has an auto-contingent-allegiance attribute. + */ + +typedef enum SCSITaskAttribute +{ + kSCSITask_SIMPLE = 0, + kSCSITask_ORDERED = 1, + kSCSITask_HEAD_OF_QUEUE = 2, + kSCSITask_ACA = 3 +} SCSITaskAttribute; + +/*! + @typedef SCSITaskState + @abstract Attributes for task state. + @discussion The Task State represents the current state of the task. + The state is set to NEW_TASK when the task is created. The SCSI Protocol + Layer will then adjust the state as the task is queued and during + execution. The SCSI Application Layer can examine the state to monitor + the progress of a task. The Task State can only be modified by the SCSI + Protocol Layer. The SCSI Application Layer can only read the state. + @constant kSCSITaskState_NEW_TASK The task state is new task. + @constant kSCSITaskState_ENABLED The task is enabled and queued. + @constant kSCSITaskState_BLOCKED The task is blocked. + @constant kSCSITaskState_DORMANT The task is dormant. + @constant kSCSITaskState_ENDED The task is complete. + */ + +typedef enum SCSITaskState +{ + kSCSITaskState_NEW_TASK = 0, + kSCSITaskState_ENABLED = 1, + kSCSITaskState_BLOCKED = 2, + kSCSITaskState_DORMANT = 3, + kSCSITaskState_ENDED = 4 +} SCSITaskState; + + +/*! + @typedef SCSIServiceResponse + @abstract Attributes for task service response. + @discussion The Service Response represents the execution status of + a service request made to a Protocol Services Driver. The Service + Response can only be modified by the SCSI Protocol Layer. The SCSI + Application Layer can only read the state. + */ + +typedef enum SCSIServiceResponse +{ + /*! + @constant kSCSIServiceResponse_Request_In_Process + Not defined in SAM specification, but is a service response used + for asynchronous commands that are not yet completed. + */ + kSCSIServiceResponse_Request_In_Process = 0, + + /*! + @constant kSCSIServiceResponse_SERVICE_DELIVERY_OR_TARGET_FAILURE + The service request failed because of a delivery or target failure. + */ + kSCSIServiceResponse_SERVICE_DELIVERY_OR_TARGET_FAILURE = 1, + + /*! + @constant kSCSIServiceResponse_TASK_COMPLETE + The task completed. + */ + kSCSIServiceResponse_TASK_COMPLETE = 2, + + /*! + @constant kSCSIServiceResponse_LINK_COMMAND_COMPLETE + The linked command completed. + */ + kSCSIServiceResponse_LINK_COMMAND_COMPLETE = 3, + + /*! + @constant kSCSIServiceResponse_FUNCTION_COMPLETE + The task management function completed. + */ + kSCSIServiceResponse_FUNCTION_COMPLETE = 4, + + /*! + @constant kSCSIServiceResponse_FUNCTION_REJECTED + The task management function was rejected. + */ + kSCSIServiceResponse_FUNCTION_REJECTED = 5 +} SCSIServiceResponse; + +/*! + @typedef SCSITaskStatus + @abstract Attributes for task status. + @discussion The Task Status represents the completion status + of the task which provides the SCSI Application Layer with + additional information about how to procede in handling a + completed task. + + The SCSI Architecture Model specification only defines task + status values for when a task completes with a service response + of either TASK_COMPLETED or LINK_COMMAND_COMPLETE. + + Since additional information will aid in error recovery when + a task fails to be completed by a device due to a service + response of kSCSIServiceResponse_SERVICE_DELIVERY_OR_TARGET_FAILURE, + additional values have been defined that can be returned by the + SCSI Protocol Layer to inform the SCSI Application Layer of the + cause of the delivery failure. + + The Task Status can only be modified by the SCSI Protocol Layer. + The SCSI Application Layer can only read the status +*/ +typedef enum SCSITaskStatus +{ + + /*! + @constant kSCSITaskStatus_GOOD + The task completed with a status of GOOD. + */ + + kSCSITaskStatus_GOOD = 0x00, + + /*! + @constant kSCSITaskStatus_CHECK_CONDITION + The task completed with a status of CHECK_CONDITION. Additional + information about the condition should be available in the sense data. + */ + + kSCSITaskStatus_CHECK_CONDITION = 0x02, + + /*! + @constant kSCSITaskStatus_CONDITION_MET + The task completed with a status of CONDITION_MET. + */ + + kSCSITaskStatus_CONDITION_MET = 0x04, + + /*! + @constant kSCSITaskStatus_BUSY + The task completed with a status of BUSY. The device server might need + time to process a request and a delay may be required. + */ + kSCSITaskStatus_BUSY = 0x08, + + /*! + @constant kSCSITaskStatus_INTERMEDIATE + The task completed with a status of INTERMEDIATE. + */ + kSCSITaskStatus_INTERMEDIATE = 0x10, + + /*! + @constant kSCSITaskStatus_INTERMEDIATE_CONDITION_MET + The task completed with a status of INTERMEDIATE_CONDITION_MET. + */ + kSCSITaskStatus_INTERMEDIATE_CONDITION_MET = 0x14, + + /*! + @constant kSCSITaskStatus_RESERVATION_CONFLICT + The task completed with a status of RESERVATION_CONFLICT. + */ + kSCSITaskStatus_RESERVATION_CONFLICT = 0x18, + + /*! + @constant kSCSITaskStatus_TASK_SET_FULL + The task completed with a status of TASK_SET_FULL. The device server + may need to complete a task before the initiator sends another. + */ + kSCSITaskStatus_TASK_SET_FULL = 0x28, + + /*! + @constant kSCSITaskStatus_ACA_ACTIVE + The task completed with a status of ACA_ACTIVE. The device server may + need the initiator to clear the Auto-Contingent Allegiance condition + before it will respond to new commands. + */ + kSCSITaskStatus_ACA_ACTIVE = 0x30, + + /*! + @constant kSCSITaskStatus_TaskTimeoutOccurred + If a task is aborted by the SCSI Protocol Layer due to it exceeding + the timeout value specified by the task, the task status shall be + set to kSCSITaskStatus_TaskTimeoutOccurred. + */ + + kSCSITaskStatus_TaskTimeoutOccurred = 0x01, + + /*! + @constant kSCSITaskStatus_ProtocolTimeoutOccurred + If a task is aborted by the SCSI Protocol Layer due to it exceeding a + timeout value specified by the support for the protocol or a related + specification, the task status shall be set to + kSCSITaskStatus_ProtocolTimeoutOccurred. + */ + + kSCSITaskStatus_ProtocolTimeoutOccurred = 0x02, + + /*! + @constant kSCSITaskStatus_DeviceNotResponding + If a task is unable to be delivered due to a failure of the device not + accepting the task or the device acknowledging the attempt to send it the + device the task status shall be set to kSCSITaskStatus_DeviceNotResponding. + This will allow the SCSI Application driver to perform the necessary steps + to try to recover the device. This shall only be reported after the SCSI + Protocol Layer driver has attempted all protocol specific attempts to recover + the device. + */ + + kSCSITaskStatus_DeviceNotResponding = 0x03, + + /*! + @constant kSCSITaskStatus_DeviceNotPresent + If the task is unable to be delivered because the device has been + detached, the task status shall be set to kSCSITaskStatus_DeviceNotPresent. + This will allow the SCSI Application Layer to halt the sending of tasks + to the device and, if supported, perform any device failover or system + cleanup. + */ + kSCSITaskStatus_DeviceNotPresent = 0x04, + + /*! + @constant kSCSITaskStatus_DeliveryFailure + If the task is unable to be + delivered to the device due to a failure in the SCSI Protocol Layer, + such as a bus reset or communications error, but the device is is + known to be functioning properly, the task status shall be set to + kSCSITaskStatus_DeliveryFailure. This can also be reported if the + task could not be delivered due to a protocol error that has since + been corrected. + */ + kSCSITaskStatus_DeliveryFailure = 0x05, + + /*! + @constant kSCSITaskStatus_No_Status + This status is not defined by + the SCSI specifications, but is here to provide a status that can + be returned in cases where there is not status available from the + device or protocol, for example, when the service response is + neither TASK_COMPLETED nor LINK_COMMAND_COMPLETE or when the + service response is SERVICE_DELIVERY_OR_TARGET_FAILURE and the + reason for failure could not be determined. + */ + kSCSITaskStatus_No_Status = 0xFF +} SCSITaskStatus; + +/*! + @enum Command Descriptor Block Size + @discussion Command Descriptor Block Size constants. +*/ +enum +{ + /*! + @constant kSCSICDBSize_Maximum This is the largest size a Command Descriptor + Block can be as specified in SPC-2. + */ + kSCSICDBSize_Maximum = 16, + + /*! + @constant kSCSICDBSize_6Byte Use this for a 6-byte CDB. + */ + kSCSICDBSize_6Byte = 6, + + /*! + @constant kSCSICDBSize_10Byte Use this for a 10-byte CDB. + */ + kSCSICDBSize_10Byte = 10, + + /*! + @constant kSCSICDBSize_12Byte Use this for a 12-byte CDB. + */ + kSCSICDBSize_12Byte = 12, + + /*! + @constant kSCSICDBSize_16Byte Use this for a 16-byte CDB. + */ + kSCSICDBSize_16Byte = 16 +}; + +typedef UInt8 SCSICommandDescriptorBlock[kSCSICDBSize_Maximum]; + +/*! + @enum Data Transfer Direction + @discussion DataTransferDirection constants. +*/ +enum +{ + /*! + @constant kSCSIDataTransfer_NoDataTransfer Use this for tasks + that transfer no data. + */ + kSCSIDataTransfer_NoDataTransfer = 0x00, + + /*! + @constant kSCSIDataTransfer_FromInitiatorToTarget Use this for tasks that transfer + data from the initiator to the target. + */ + kSCSIDataTransfer_FromInitiatorToTarget = 0x01, + + /*! + @constant kSCSIDataTransfer_FromTargetToInitiator Use this for tasks that transfer + data from the target to the initiator. + */ + kSCSIDataTransfer_FromTargetToInitiator = 0x02 +}; + + +#if defined(KERNEL) && defined(__cplusplus) + +/* Libkern includes */ +#include <libkern/c++/OSObject.h> + + +/*! + @enum SCSITaskMode + @discussion The SCSI Task mode is used by the SCSI + Protocol Layer to indicate what mode the task is executing. +*/ +typedef enum SCSITaskMode +{ + kSCSITaskMode_CommandExecution = 1, + kSCSITaskMode_Autosense = 2 +} SCSITaskMode; + +/*! + @typedef SCSITaskIdentifier + @discussion This is an opaque object that represents a task. + This is used so that drivers for both the SCSI Protocol Layer + and the SCSI Application Layer cannot modify the SCSITask object + directly but must instead use the inherited methods to do so. This + allows the implementation of SCSITask to change without directly + impacting device and protocol layer drivers. In addition, it + prevents changing of properties that are not allowed to be + changed by a given layer. +*/ +typedef OSObject * SCSITaskIdentifier; + + +/*! + @typedef SCSITaskCompletion + @discussion This is the typedef for completion routines that + work with SCSITaskIdentifiers. +*/ +typedef void ( *SCSITaskCompletion )( SCSITaskIdentifier completedTask ); + +#endif /* defined(KERNEL) && defined(__cplusplus) */ + +#endif /* _IOKIT_SCSI_TASK_H_ */ Index: branches/azimutz/Cleancut/i386/include/IOKit/scsi/IOCompactDiscServices.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/scsi/IOCompactDiscServices.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/scsi/IOCompactDiscServices.h (revision 885) @@ -0,0 +1,230 @@ +/* + * 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_COMPACT_DISC_SERVICES_H_ +#define _IOKIT_IO_COMPACT_DISC_SERVICES_H_ + +#if defined(KERNEL) && defined(__cplusplus) + + +//----------------------------------------------------------------------------- +// Includes +//----------------------------------------------------------------------------- + +// IOKit includes +#include <IOKit/IOTypes.h> + +// Generic IOKit storage related headers +#include <IOKit/storage/IOCDTypes.h> +#include <IOKit/storage/IOCDBlockStorageDevice.h> + +// SCSI Architecture Model Family includes +#include <IOKit/scsi/IOSCSIPeripheralDeviceType05.h> + +class IOMemoryDescriptor; + +// Use this switch to turn off the data cache. +#define _USE_DATA_CACHING_ 1 + + +//----------------------------------------------------------------------------- +// Class Declaration +//----------------------------------------------------------------------------- + +class IOCompactDiscServices : public IOCDBlockStorageDevice +{ + + OSDeclareDefaultStructors ( IOCompactDiscServices ) + +#if (_USE_DATA_CACHING_) + // Data Cache members + bool fUseDataCache; // Indicates if cache should be used. This + // will be set to false if all the necessary support + // for the data cache could not be allocated or + // initialized. + UInt8 * fDataCacheStorage; // Storage space for the cache + UInt32 fDataCacheStartBlock; // Starting block of the data in the cache. + UInt32 fDataCacheBlockCount; // Number of contiguous blocks in the cache + // starting with fDataCacheStartBlock. A value of + // zero in this member indicates that all data + // in the cache is invalid. + + IOSimpleLock * fDataCacheLock; // This is the lock for preventing multiple access + // while manipulating the data cache. +#endif + +protected: + + OSSet * fClients; + IOSCSIPeripheralDeviceType05 * fProvider; + + virtual void free ( void ); + + // Reserve space for future expansion. + struct IOCompactDiscServicesExpansionData { }; + IOCompactDiscServicesExpansionData * fIOCompactDiscServicesReserved; + +public: + + static void AsyncReadWriteComplete ( void * clientData, + IOReturn status, + UInt64 actualByteCount ); + + // Deprecated + virtual IOReturn doAsyncReadWrite ( IOMemoryDescriptor * buffer, + UInt32 block, + UInt32 nblks, + IOStorageCompletion completion ); + + virtual IOReturn doAsyncReadWrite ( IOMemoryDescriptor * buffer, + UInt64 block, + UInt64 nblks, + IOStorageCompletion completion ); + + virtual IOReturn doAsyncReadWrite ( IOMemoryDescriptor * buffer, + UInt64 block, + UInt64 nblks, + IOStorageAttributes * attributes, + IOStorageCompletion * completion ); + + virtual IOReturn doEjectMedia ( void ); + + virtual IOReturn doFormatMedia ( UInt64 byteCapacity ); + + virtual UInt32 doGetFormatCapacities ( UInt64 * capacities, + UInt32 capacitiesMaxCount ) const; + + virtual IOReturn doLockUnlockMedia ( bool doLock ); + + virtual IOReturn doSynchronizeCache ( void ); + + virtual IOReturn getWriteCacheState ( bool * enabled ); + + virtual IOReturn setWriteCacheState ( bool enabled ); + + virtual char * getVendorString ( void ); + + virtual char * getProductString ( void ); + + virtual char * getRevisionString ( void ); + + virtual char * getAdditionalDeviceInfoString ( void ); + + virtual IOReturn reportBlockSize ( UInt64 * blockSize ); + + virtual IOReturn reportEjectability ( bool * isEjectable ); + + virtual IOReturn reportLockability ( bool * isLockable ); + + virtual IOReturn reportMediaState ( bool * mediaPresent, bool * changed ); + + virtual IOReturn reportPollRequirements ( bool * pollIsRequired, + bool * pollIsExpensive ); + + virtual IOReturn reportMaxValidBlock ( UInt64 * maxBlock ); + + virtual IOReturn reportRemovability ( bool * isRemovable ); + + virtual IOReturn reportWriteProtection ( bool * isWriteProtected ); + + /* CD Specific */ + virtual IOReturn doAsyncReadCD ( IOMemoryDescriptor * buffer, + UInt32 block, + UInt32 nblks, + CDSectorArea sectorArea, + CDSectorType sectorType, + IOStorageCompletion completion ); + + virtual IOReturn readISRC ( UInt8 track, CDISRC isrc ); + + virtual IOReturn readMCN ( CDMCN mcn); + + virtual IOReturn readTOC ( IOMemoryDescriptor * buffer ); + + virtual IOReturn audioPause ( bool pause ); + + virtual IOReturn audioPlay ( CDMSF timeStart, CDMSF timeStop ); + + virtual IOReturn audioScan ( CDMSF timeStart, bool reverse ); + + virtual IOReturn audioStop ( void ); + + virtual IOReturn getAudioStatus ( CDAudioStatus * status ); + + virtual IOReturn getAudioVolume ( UInt8 * leftVolume, UInt8 * rightVolume ); + + virtual IOReturn setAudioVolume ( UInt8 leftVolume, UInt8 rightVolume ); + + virtual UInt32 getMediaType ( void ); + + virtual IOReturn getSpeed ( UInt16 * kilobytesPerSecond ); + + virtual IOReturn setSpeed ( UInt16 kilobytesPerSecond ); + + /* System Specific */ + virtual IOReturn message ( UInt32 type, IOService * provider, void * argument ); + virtual IOReturn setProperties ( OSObject * properties ); + + /* User Client Specific */ + virtual bool start ( IOService * provider ); + virtual bool open ( IOService * client, IOOptionBits options, IOStorageAccess access ); + + virtual bool handleOpen ( IOService * client, IOOptionBits options, void * access ); + virtual void handleClose ( IOService * client, IOOptionBits options ); + virtual bool handleIsOpen ( const IOService * client ) const; + + /* Added with 10.1.3 */ + virtual IOReturn readTOC ( IOMemoryDescriptor * buffer, + CDTOCFormat format, + UInt8 msf, + UInt8 trackSessionNumber, + UInt16 * actualByteCount ); + + /* Added with 10.1.3 */ + virtual IOReturn readDiscInfo ( IOMemoryDescriptor * buffer, + UInt16 * actualByteCount ); + + /* Added with 10.1.3 */ + virtual IOReturn readTrackInfo ( IOMemoryDescriptor * buffer, + UInt32 address, + CDTrackInfoAddressType addressType, + UInt16 * actualByteCount ); + +private: + + // Space reserved for future expansion. + OSMetaClassDeclareReservedUnused ( IOCompactDiscServices, 1 ); + OSMetaClassDeclareReservedUnused ( IOCompactDiscServices, 2 ); + OSMetaClassDeclareReservedUnused ( IOCompactDiscServices, 3 ); + OSMetaClassDeclareReservedUnused ( IOCompactDiscServices, 4 ); + OSMetaClassDeclareReservedUnused ( IOCompactDiscServices, 5 ); + OSMetaClassDeclareReservedUnused ( IOCompactDiscServices, 6 ); + OSMetaClassDeclareReservedUnused ( IOCompactDiscServices, 7 ); + OSMetaClassDeclareReservedUnused ( IOCompactDiscServices, 8 ); + +}; + +#endif /* defined(KERNEL) && defined(__cplusplus) */ + +#endif /* _IOKIT_IO_COMPACT_DISC_SERVICES_H_ */ Index: branches/azimutz/Cleancut/i386/include/IOKit/scsi/IOSCSIPeripheralDeviceType00.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/scsi/IOSCSIPeripheralDeviceType00.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/scsi/IOSCSIPeripheralDeviceType00.h (revision 885) @@ -0,0 +1,102 @@ +/* + * 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_SCSI_PERIPHERAL_DEVICE_TYPE_OO_H_ +#define _IOKIT_IO_SCSI_PERIPHERAL_DEVICE_TYPE_OO_H_ + +#if defined(KERNEL) && defined(__cplusplus) + + +//----------------------------------------------------------------------------- +// Includes +//----------------------------------------------------------------------------- + +// SCSI Architecture Model Family includes +#include <IOKit/scsi/IOSCSIBlockCommandsDevice.h> + + +//----------------------------------------------------------------------------- +// Class Declaration +//----------------------------------------------------------------------------- + +class IOSCSIPeripheralDeviceType00 : public IOSCSIBlockCommandsDevice +{ + + OSDeclareDefaultStructors ( IOSCSIPeripheralDeviceType00 ) + +protected: + + // Reserve space for future expansion. + struct IOSCSIPeripheralDeviceType00ExpansionData + { + OSSet * fClients; + }; + IOSCSIPeripheralDeviceType00ExpansionData * fIOSCSIPeripheralDeviceType00Reserved; + +public: + + bool init ( OSDictionary * propTable ); + virtual bool start ( IOService * provider ); + virtual void free ( void ); + + virtual bool handleOpen ( + IOService * client, + IOOptionBits options, + void * access ); + + virtual void handleClose ( + IOService * client, + IOOptionBits options ); + + virtual bool handleIsOpen ( const IOService * client ) const; + + virtual IOReturn newUserClient ( + task_t owningTask, + void * securityID, + UInt32 type, + OSDictionary * properties, + IOUserClient ** handler ); + virtual void CreateStorageServiceNub ( void ); + + virtual char * GetVendorString ( void ); + virtual char * GetProductString ( void ); + virtual char * GetRevisionString ( void ); + + +private: + + // Space reserved for future expansion. + OSMetaClassDeclareReservedUnused ( IOSCSIPeripheralDeviceType00, 1 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPeripheralDeviceType00, 2 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPeripheralDeviceType00, 3 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPeripheralDeviceType00, 4 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPeripheralDeviceType00, 5 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPeripheralDeviceType00, 6 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPeripheralDeviceType00, 7 ); + OSMetaClassDeclareReservedUnused ( IOSCSIPeripheralDeviceType00, 8 ); + +}; + +#endif /* defined(KERNEL) && defined(__cplusplus) */ + +#endif /* _IOKIT_IO_SCSI_PERIPHERAL_DEVICE_TYPE_OO_H_ */ Index: branches/azimutz/Cleancut/i386/include/IOKit/IOMapper.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/IOMapper.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/IOMapper.h (revision 885) @@ -0,0 +1,154 @@ +/* + * Copyright (c) 1998-2003 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_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); +void IOMapperInsertPPNPages(ppnum_t addr, unsigned offset, + ppnum_t *pageList, unsigned pageCount); +void IOMapperInsertUPLPages(ppnum_t addr, unsigned offset, + upl_page_info_t *pageList, unsigned pageCount); + +mach_vm_address_t IOMallocPhysical(mach_vm_size_t size, mach_vm_address_t mask); + +void IOFreePhysical(mach_vm_address_t address, mach_vm_size_t size); + +__END_DECLS + +#if __cplusplus + +#include <IOKit/IOService.h> +#include <IOKit/IOMemoryDescriptor.h> + +class OSData; +class IODMACommand; + +extern const OSSymbol * gIOMapperIDKey; + +class IOMapper : public IOService +{ + OSDeclareAbstractStructors(IOMapper); + + // Give the platform expert access to setMapperRequired(); + friend class IOPlatformExpert; + +private: + enum SystemMapperState { + kNoMapper = 0, + kUnknown = 1, + kHasMapper = 2, // Any other value is pointer to a live mapper + kWaitMask = 3, + }; +protected: + void *fTable; + ppnum_t fTablePhys; + IOItemCount fTableSize; + OSData *fTableHandle; + bool fIsSystem; + + + static void setMapperRequired(bool hasMapper); + static void waitForSystemMapper(); + + virtual bool initHardware(IOService *provider) = 0; + + virtual bool allocTable(IOByteCount size); + +public: + virtual bool start(IOService *provider); + virtual void free(); + + // Static routines capable of allocating tables that are physically + // contiguous in real memory space. + static OSData * NewARTTable(IOByteCount size, + void ** virtAddrP, ppnum_t *physAddrP); + static void FreeARTTable(OSData *handle, IOByteCount size); + + + // To get access to the system mapper IOMapper::gSystem + static IOMapper *gSystem; + + virtual ppnum_t iovmAlloc(IOItemCount pages) = 0; + virtual void iovmFree(ppnum_t addr, IOItemCount pages) = 0; + + virtual void iovmInsert(ppnum_t addr, IOItemCount offset, ppnum_t page) = 0; + virtual void iovmInsert(ppnum_t addr, IOItemCount offset, + ppnum_t *pageList, IOItemCount pageCount); + virtual void iovmInsert(ppnum_t addr, IOItemCount offset, + upl_page_info_t *pageList, IOItemCount pageCount); + + static void checkForSystemMapper() + { if ((uintptr_t) gSystem & kWaitMask) waitForSystemMapper(); }; + + static IOMapper * copyMapperForDevice(IOService * device); + + + // Function will panic if the given address is not found in a valid + // iovm mapping. + virtual addr64_t mapAddr(IOPhysicalAddress addr) = 0; + + // Get the address mask to or into an address to bypass this mapper + virtual bool getBypassMask(addr64_t *maskP) const; + + virtual ppnum_t iovmAllocDMACommand(IODMACommand * command, IOItemCount pageCount); + virtual void iovmFreeDMACommand(IODMACommand * command, ppnum_t addr, IOItemCount pageCount); + + OSMetaClassDeclareReservedUsed(IOMapper, 0); + OSMetaClassDeclareReservedUsed(IOMapper, 1); + OSMetaClassDeclareReservedUsed(IOMapper, 2); + +private: + 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 */ Index: branches/azimutz/Cleancut/i386/include/IOKit/ata/ATATimerEventSource.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/ata/ATATimerEventSource.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/ata/ATATimerEventSource.h (revision 885) @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2001-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 _ATATIMEREVENTSOURCE_H +#define _ATATIMEREVENTSOURCE_H + + +#include <IOKit/IOTypes.h> +#include <IOKit/IOCommandGate.h> +#include <IOKit/IOService.h> +#include <IOKit/IOWorkLoop.h> +#include <IOKit/IOTimerEventSource.h> + + +/*! +@class ATATimerEventSource + +@discussion +Extend the timer event source to allow checking for timer expiration +from behind the workloop. +*/ + +class ATATimerEventSource : public IOTimerEventSource +{ + OSDeclareDefaultStructors(ATATimerEventSource); + + public: + + /*!@function ataTimerEventSource + @abstract allocate an instance of this type. + */ + static ATATimerEventSource * + ataTimerEventSource(OSObject *owner, Action action = 0); + + /*!@function hasTimedOut + @abstract returns true if the timer has expired since the last enable/disable or setTimeout() or wakeAtTime() call. + */ + virtual bool hasTimedOut( void ); + + // override to initialize the time out flag. + /*!@function + @abstract + */ + virtual bool init(OSObject *owner, Action action = 0); + + /*!@function enable + @abstract overrides in order to set/clear the timed out flag + */ + virtual void enable(); + + /*!@function disable + @abstract overrides in order to set/clear the timed out flag + */ + virtual void disable(); + + /*!@function wakeAtTime + @abstract overrides in order to set/clear the timed out flag + */ + virtual IOReturn wakeAtTime(UnsignedWide abstime); + + /*!@function cancelTimeout + @abstract overrides in order to set/clear the timed out flag + */ + virtual void cancelTimeout(); + +protected: + + enum{ kTimedOutTrue = 'true', + kTimedOutFalse = 'fals' + }; + + UInt32 hasExpired; + + + /*!@function myTimeout + @abstract my timeout function which sets the timedOut flag atomically. + */ + static void myTimeout(void *self); + + /*!@function setTimeoutFunc + @abstract override to install my timeout function instead of the super's. + */ + virtual void setTimeoutFunc(); + + /*! @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) */ + ExpansionData *reserved; + +private: + OSMetaClassDeclareReservedUnused(ATATimerEventSource, 0); + OSMetaClassDeclareReservedUnused(ATATimerEventSource, 1); + OSMetaClassDeclareReservedUnused(ATATimerEventSource, 2); + OSMetaClassDeclareReservedUnused(ATATimerEventSource, 3); + OSMetaClassDeclareReservedUnused(ATATimerEventSource, 4); + OSMetaClassDeclareReservedUnused(ATATimerEventSource, 5); + OSMetaClassDeclareReservedUnused(ATATimerEventSource, 6); + OSMetaClassDeclareReservedUnused(ATATimerEventSource, 7); + +}; + + +#endif /*_ATATIMEREVENTSOURCE_H*/ Index: branches/azimutz/Cleancut/i386/include/IOKit/ata/IOPCIATA.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/ata/IOPCIATA.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/ata/IOPCIATA.h (revision 885) @@ -0,0 +1,200 @@ +/* + * 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 _DRV_PCI_ATA_H +#define _DRV_PCI_ATA_H + +#include <libkern/c++/OSObject.h> +#include <IOKit/IOTypes.h> +#include "IOATAController.h" +#include <IOKit/IOMemoryCursor.h> +#include <IOKit/IOBufferMemoryDescriptor.h> + +#include <IOKit/IOInterruptEventSource.h> + +/*! @class IOPCIATA + @abstract The base class for PCI-IDE ata controller family. + @discussion class defining the common elements of bus-mastering PCI ATA controllers which meet or at least loosely follow the pci bus mastering pci-ide controller spec. Header doc is incomplete, but source is heavily commented. + +*/ + + + +class IOPCIATA : public IOATAController +{ + OSDeclareDefaultStructors(IOPCIATA); + +public: + + /*--- Overrides from IOATAController ---*/ + virtual bool init(OSDictionary * properties); + virtual bool start( IOService* provider ); + +protected: + + // The DMA states: not in use, in use and running with additional passes needed, + // in use on final pass, transfer complete, and failure + enum ATADMAState + { + // DMA state flags + kATADMAInactive, + kATADMAStarting, + kATADMAActive, + kATADMAStatus, + kATADMAComplete, + kATADMAError, + + }; + + enum { + // PRD flags + kLast_PRD = 0x8000, + kContinue_PRD = 0, + + }; + + + enum { + mBMCmdStartOutput = 0x01, // start engine to transfer from memory to device. + mBMCmdStartInput = (1 << 3 ) | 0x01, // start engine to transfer from device to memory + mBMCmdStop = 0x00, // halt engine. + }; + + enum { + // bus master status register definitions. + bBMStatusSimplex = 7, // 0 = simultaneous transactions allowed. 1 = primary and secondary busses may not be active at same time. + bBMStatusDrv1 = 6, // 1 = device 1 and bus are already configured by some other software/firmware + bBMStatusDrv0 = 5, // 1 = device 0 and bus are already configured by some other software/firmware + bBMStatusInt = 2, // 1 = device has asserted INTRQ and all data is flushed to/from memory. + bBMStatusError = 1, // 1 = an error in the DMA has occured. Software clears by writing 1 to this bit. + bBMStatusActive = 0, // 1 = DMA engine is active. + }; + + enum{ + + mBMStatusSimplex = 1 << 7, + mBMStatusDrv1 = 1 << 6, + mBMStatusDrv0 = 1 << 5, + mBMStatusInt = 1 << 2, + mBMStatusError = 1 << 1, + mBMStatusActive = 1 + }; + + // the physical region descriptor used for the dma engine. + struct PRD + { + UInt32 bufferPtr; // address + UInt16 byteCount; // 16 bit byte count where 0x0000 = 64K + UInt16 flags; // 0 in flags means contine, 0x80 means stop + }; + + + // descendants of this class MUST initialize these values + // prior to activating any DMA command. + IOATARegPtr8 _bmCommandReg; + IOATARegPtr8 _bmStatusReg; + IOATARegPtr32 _bmPRDAddresReg; + + // semaphore for DMA state + UInt32 _dmaState; + + // table of PRD descriptors + PRD* _prdTable; + IOPhysicalAddress _prdTablePhysical; + + IONaturalMemoryCursor* _DMACursor; + + // override from IOATAController + // activate the DMA engine as per the current command + virtual IOReturn startDMA( void ); + + // override from IOATAController + // safely halt the DMA engine regardless of state + virtual IOReturn stopDMA( void ); + + // allocate memory for the PRD descriptors. + virtual bool allocDMAChannel(void); + + // fill CC with stop commands. + virtual void initATADMAChains (PRD* descPtr); + + // fill out a PRD, respecting endianess + virtual void setPRD(UInt8 *bffr, UInt16 count, PRD *tableElement, UInt16 end); + + // setup the CC with IO commands + virtual IOReturn createChannelCommands(void); + + // deallocate memory for the DMA engine + virtual bool freeDMAChannel(void); + + // clean up on device interrupt + virtual IOReturn handleDeviceInterrupt(void); + + // activate the DMA engine + virtual void activateDMAEngine(void); + + // shutdown the DMA engine + virtual void stopDMAEngine(void); + + // safely suspend the DMA engine + virtual void shutDownATADMA (void); + + // overrides + virtual void free(); +protected: +/*! @struct ExpansionData + @discussion This structure will be used to expand the capablilties of the IOPCIATA class in the future. + */ + typedef struct ExpansionData + { + IOBufferMemoryDescriptor* _prdBuffer; + } ExpansionData; + +/*! @var reserved + Reserved for future use. (Internal use only) */ + ExpansionData *reserved; + +private: + OSMetaClassDeclareReservedUnused(IOPCIATA, 0); + OSMetaClassDeclareReservedUnused(IOPCIATA, 1); + OSMetaClassDeclareReservedUnused(IOPCIATA, 2); + OSMetaClassDeclareReservedUnused(IOPCIATA, 3); + OSMetaClassDeclareReservedUnused(IOPCIATA, 4); + OSMetaClassDeclareReservedUnused(IOPCIATA, 5); + OSMetaClassDeclareReservedUnused(IOPCIATA, 6); + OSMetaClassDeclareReservedUnused(IOPCIATA, 7); + OSMetaClassDeclareReservedUnused(IOPCIATA, 8); + OSMetaClassDeclareReservedUnused(IOPCIATA, 9); + OSMetaClassDeclareReservedUnused(IOPCIATA, 10); + OSMetaClassDeclareReservedUnused(IOPCIATA, 11); + OSMetaClassDeclareReservedUnused(IOPCIATA, 12); + OSMetaClassDeclareReservedUnused(IOPCIATA, 13); + OSMetaClassDeclareReservedUnused(IOPCIATA, 14); + OSMetaClassDeclareReservedUnused(IOPCIATA, 15); + OSMetaClassDeclareReservedUnused(IOPCIATA, 16); + OSMetaClassDeclareReservedUnused(IOPCIATA, 17); + OSMetaClassDeclareReservedUnused(IOPCIATA, 18); + OSMetaClassDeclareReservedUnused(IOPCIATA, 19); + OSMetaClassDeclareReservedUnused(IOPCIATA, 20); +}; + +#endif // _DRV_PCI_ATA_H Index: branches/azimutz/Cleancut/i386/include/IOKit/ata/ATADeviceNub.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/ata/ATADeviceNub.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/ata/ATADeviceNub.h (revision 885) @@ -0,0 +1,164 @@ +/* + * 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@ + */ + +/*! + @header ATADeviceNub.h + @abstract A concrete implementation of IOATADevice. + */ + +#ifndef _ATADEVICENUB_H +#define _ATADEVICENUB_H + +#include <IOKit/IOTypes.h> +#include "IOATATypes.h" +#include "IOATADevice.h" +#include "IOATAController.h" + +#include "IOATABusCommand.h" + + +/*! +@class ATADeviceNub +@abstract ATADeviceNub is a concrete implementation of IOATADevice. +@discussion clients of IOATA (disk drivers) should use the interface presented +by IOATADevice. Concrete nubs are private to the IOATA family and +specific subclasses of IOATADevice are instantiated by controller +drivers to provide the abstract interface to clients. + +*/ +class ATADeviceNub : public IOATADevice +{ + OSDeclareDefaultStructors(ATADeviceNub); + +public: + + /*!@function ataDeviceNub + @abstract static creator function - used by IOATAControllers to create nubs. + */ + static ATADeviceNub* ataDeviceNub( IOATAController* provider, ataUnitID unit, ataDeviceType devType); + + /*!@function attach + @abstract override of IOService method. + */ + virtual bool attach(IOService* provider ); + + + // overrides from IOATADevice to provide actual client interface + + + /*!@function executeCommand + @abstract Submit IO requests + */ + virtual IOReturn executeCommand(IOATACommand* command); + + // create and destroy IOATACommands + /*!@function allocCommand + @abstract create command objects for clients. + */ + virtual IOATACommand* allocCommand( void ); + + /*!@function freeCommand + @abstract Clients use this method to dispose of command objects. + */ + virtual void freeCommand( IOATACommand* inCommand); + + +protected: + + /*!@function init + @abstract used after creating the nub. + */ + virtual bool init(IOATAController* provider, ataUnitID unit, ataDeviceType devType); + + /*!@function publishProperties + @abstract publish the nub's properties in the device tree. + */ + virtual void publishProperties( void ); + + /*!@function publishBusProperties + @abstract puts info about this device's bus capability in the device tree. + */ + virtual void publishBusProperties(void); + + /*!@function publishVendorProperties + @abstract will be deprecated. + */ + virtual void publishVendorProperties( void ); + + /*!@function getDeviceID + @abstract get the unit id of this drive (0 or 1) + */ + virtual IOReturn getDeviceID(void); + + /*!@function MyATACallback + @abstract to be deprecated. + */ + static void MyATACallback(IOATACommand* command ); + + /*!@function processCallback + @abstract to be deprecated. + */ + void processCallback(IOATACommand* command ); + + /*!@function swapBytes16 + @abstract to be deprecated. + */ + void swapBytes16( UInt8* dataBuffer, IOByteCount length); + + UInt8* buffer; + +protected: +/*! @struct ExpansionData + @discussion This structure will be used to expand the capablilties of the ATADeviceNub in the future. + */ + struct ExpansionData { }; + +/*! @var reserved + Reserved for future use. (Internal use only) */ + ExpansionData *reserved; + +private: + OSMetaClassDeclareReservedUnused(ATADeviceNub, 0); + OSMetaClassDeclareReservedUnused(ATADeviceNub, 1); + OSMetaClassDeclareReservedUnused(ATADeviceNub, 2); + OSMetaClassDeclareReservedUnused(ATADeviceNub, 3); + OSMetaClassDeclareReservedUnused(ATADeviceNub, 4); + OSMetaClassDeclareReservedUnused(ATADeviceNub, 5); + OSMetaClassDeclareReservedUnused(ATADeviceNub, 6); + OSMetaClassDeclareReservedUnused(ATADeviceNub, 7); + OSMetaClassDeclareReservedUnused(ATADeviceNub, 8); + OSMetaClassDeclareReservedUnused(ATADeviceNub, 9); + OSMetaClassDeclareReservedUnused(ATADeviceNub, 10); + OSMetaClassDeclareReservedUnused(ATADeviceNub, 11); + OSMetaClassDeclareReservedUnused(ATADeviceNub, 12); + OSMetaClassDeclareReservedUnused(ATADeviceNub, 13); + OSMetaClassDeclareReservedUnused(ATADeviceNub, 14); + OSMetaClassDeclareReservedUnused(ATADeviceNub, 15); + OSMetaClassDeclareReservedUnused(ATADeviceNub, 16); + OSMetaClassDeclareReservedUnused(ATADeviceNub, 17); + OSMetaClassDeclareReservedUnused(ATADeviceNub, 18); + OSMetaClassDeclareReservedUnused(ATADeviceNub, 19); + OSMetaClassDeclareReservedUnused(ATADeviceNub, 20); + +}; + +#endif /* !_IOATABUSNUB_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/ata/IOATACommand.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/ata/IOATACommand.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/ata/IOATACommand.h (revision 885) @@ -0,0 +1,478 @@ +/* + * 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@ + */ + +/* + * + * IOATACommand.h + * + */ + +#ifndef _IOATACOMMAND_H +#define _IOATACOMMAND_H + +#include <libkern/c++/OSObject.h> +#include <IOKit/IOTypes.h> +#include <IOKit/IOMemoryDescriptor.h> +#include <IOKit/IOCommand.h> +#include "IOATATypes.h" + + +class IOExtendedLBA; +class IOATACommand; + + +/*! @typedef IOATACompletionFunction callback function for ATA disk devices. +*/ +typedef void (IOATACompletionFunction)(IOATACommand* command ); + + +/*! +@class IOATACommand + +@discussion +Command structure superclass, created and freed only by IOATADevice objects +populated by disk device drivers with command parameters +then submitted for operation to their IOATADevice provider for execution. + +IOATACommand is a virtual class, a concrete subclass contains the methods and fields needed +by IOATAControllers. Subclasses may be specific to particular controller hardware. +Disk device drivers will only have visibility to this interface and may not subclass this object. +Disk device drivers should instead make use of the void* refcon field which the controllers will not +touch +*/ + +class IOATACommand : public IOCommand { + + OSDeclareAbstractStructors( IOATACommand ); + + public: + + /*!@function zeroCommand + @abstract set to blank state, MUST call prior to re-use of this object + */ + virtual void zeroCommand(void); + + /*!@function setOpcode + @abstract command opcode as defined in IOATATypes. + */ + virtual void setOpcode( ataOpcode inCode); + + /*!@function setFlags + @abstract set the flags for this command, as defined in IOATATypes. + */ + virtual void setFlags( UInt32 inFlags); + + /*!@function setUnit + @abstract set the unit number for this command. + */ + virtual void setUnit( ataUnitID inUnit); + + /*!@function setTimeoutMS + @abstract how long to allow this command to complete, in milliseconds, once issued to + the hardware. if the time period expires, this command will return with a timeout error. + */ + virtual void setTimeoutMS( UInt32 inMs); + + /*!@function setCallbackPtr + @abstract set the function pointer to call when this command completes. + */ + virtual void setCallbackPtr (IOATACompletionFunction* inCompletion); + + /*!@function setRegMask + @abstract used when accessing registers or reading registers on an error result. Mask is defined + in IOATATypes.h + */ + virtual void setRegMask( ataRegMask mask); + + // memory information + // Since ATA hardware is limited in the amount of bytes + // that can be transfered in a command, the disk driver shall supply + // a seperate offset and byte count per transfer. + // the offset may be any amount. The byte count must be a multiple of the + // sector size of the device, ie, N * 512 bytes for ata hard drives. + /*!@function setBuffer + @abstract set the IIOMemoryDescriptor for this transaction. + */ + virtual void setBuffer ( IOMemoryDescriptor* inDesc); + + /*!@function setPosition + @abstract used to set an offset into the memory descriptor for this transfer. + */ + virtual void setPosition (IOByteCount fromPosition); + + /*!@function setByteCount + @abstract set the byte count for this transaction. Should agree with the device command and the + memory descriptor in use. + */ + virtual void setByteCount (IOByteCount numBytes); + + /*!@function setTransferChunkSize + @abstract set the size of transfer between intervening interrupts. necessary when doing PIO Read/Write Multiple, etc. so the controller knows when to expect an interrupt during multi-sector data transfers. + */ + virtual void setTransferChunkSize( IOByteCount chunk = kATADefaultSectorSize); + + /*!@function setFeatures + @abstract Taskfile access. Registers are named in accordance with ATA Standards conventions + */ + virtual void setFeatures( UInt8 in); + + /*!@function getErrorReg + @abstract Taskfile access. Registers are named in accordance with ATA Standards conventions + */ + virtual UInt8 getErrorReg (void ); + + /*!@function setSectorCount + @abstract Taskfile access. Registers are named in accordance with ATA Standards conventions + */ + virtual void setSectorCount( UInt8 in); + + /*!@function getSectorCount + @abstract Taskfile access. Registers are named in accordance with ATA Standards conventions + */ + virtual UInt8 getSectorCount (void ); + + /*!@function setSectorNumber + @abstract Taskfile access. Registers are named in accordance with ATA Standards conventions + */ + virtual void setSectorNumber( UInt8 in); + + /*!@function getSectorNumber + @abstract Taskfile access. Registers are named in accordance with ATA Standards conventions + */ + virtual UInt8 getSectorNumber (void ); + + /*!@function setCylLo + @abstract Taskfile access. Registers are named in accordance with ATA Standards conventions + */ + virtual void setCylLo ( UInt8 in); + + /*!@function getCylLo + @abstract Taskfile access. Registers are named in accordance with ATA Standards conventions + */ + virtual UInt8 getCylLo (void ); + + /*!@function setCylHi + @abstract Taskfile access. Registers are named in accordance with ATA Standards conventions + */ + virtual void setCylHi( UInt8 in); + + /*!@function getCylHi + @abstract Taskfile access. Registers are named in accordance with ATA Standards conventions + */ + virtual UInt8 getCylHi (void ); + + /*!@function setDevice_Head + @abstract Taskfile access. Registers are named in accordance with ATA Standards conventions + */ + virtual void setDevice_Head( UInt8 in); + + /*!@function getDevice_Head + @abstract Taskfile access. Registers are named in accordance with ATA Standards conventions + */ + virtual UInt8 getDevice_Head (void ); + + /*!@function setCommand + @abstract Taskfile access. Registers are named in accordance with ATA Standards conventions + */ + virtual void setCommand ( UInt8 in); + + /*!@function getStatus + @abstract Taskfile access. Registers are named in accordance with ATA Standards conventions + */ + virtual UInt8 getStatus (void ); + + /*!@function setLBA28 + @abstract convenience method that sets the taskfile registers into a 28-bit LBA address, with unit selected and LBA bit set. return err if param out of range, return kIOSuccess (kATANoErr) = 0 on return if successful + */ + virtual IOReturn setLBA28( UInt32 lba, ataUnitID inUnit); + + /*!@function setPacketCommand + @abstract ATAPI command packet max size is 16 bytes. Makes deep copy of data. + */ + virtual IOReturn setPacketCommand( UInt16 packetSizeBytes, UInt8* command); + + // the following registers are only accessed by register access + // commands. Not by normal command dispatch where they are handled + // by the controller. + + // not part of task file params. not written to device when sending commands. + virtual void setDataReg ( UInt16 in); + virtual UInt16 getDataReg (void ); + + // not part of taskfile. Not usually used except by controller. + virtual void setControl ( UInt8 in); + virtual UInt8 getAltStatus (void ); + + // return values + /*!@function getResult + @abstract IOReturn value of the result of this command. ATA family errors are defined in IOATATypes.h + */ + virtual IOReturn getResult (void); + + /*!@function getBuffer + @abstract the IOMemoryDescriptor used in this transaction. + */ + virtual IOMemoryDescriptor* getBuffer ( void ); + + /*!@function getActualTransfer + @abstract The byte count on the ending result, as best as can be determined by the controller. May be zero, but partial transfer may have occurred on error in some cases. + */ + virtual IOByteCount getActualTransfer ( void ); + + /*!@function getEndStatusReg + @abstract the value of the status register on the end of the command. + */ + virtual UInt8 getEndStatusReg (void); // always returned + + /*!@function getEndErrorReg + @abstract If the error bit was set in the status register, the value of the error register is returned at the end of a command. + */ + virtual UInt8 getEndErrorReg( void ); + + /*!@function getCommandInUse + @abstract returns true if IOATAController is still in control of the command. + */ + virtual bool getCommandInUse( void ); // returns true if IOATAController is using the command. + + // for use by disk drivers, clients of IOATADevice only. + // IOATADevice and IOATAControllers shall not use this field in any manner + /*!@var refCon + @abstract for use by disk drivers, clients of IOATADevice only. IOATADevice and IOATAControllers shall not use this field in any manner. + */ + void* refCon; + + /*!@var refCon2 + @abstract for use by disk drivers, clients of IOATADevice only. IOATADevice and IOATAControllers shall not use this field in any manner. + */ + void* refCon2; + + protected: + // < return from ATA controllers to disk drivers + // > sent to ATA controllers from disk drivers + ataOpcode _opCode; // > Command code for the controller. + UInt32 _flags; // > Flags for this command + ataRegisterImage _taskFile; // <> Taskfile + data and control registers. + ATAPICmdPacket _packet; // > ATAPI packet + ataUnitID _unit; // > Unit number + UInt32 _timeoutMS; // > timeout command in ms. + IOMemoryDescriptor* _desc; // > Buffer for data may be nil if command transfer no data + IOByteCount _position; // > Position within the descriptor for this command + IOByteCount _byteCount; // > How many bytes to transfer. + IOByteCount _logicalChunkSize; // > How many bytes between intervening interrupts (R/W Multiple) + ataRegMask _regMask; // > Which registers to write or read for reg access commands + IOATACompletionFunction* _callback; // > if nil, command is synchronous + + IOReturn _result; // < result + IOByteCount _actualByteCount; // < actual bytes transfered. + UInt8 _status; // < Status register at end of command + UInt8 _errReg; // < Error register at end of command if error bit set. + bool _inUse; // < true while IOATAController has possesion of the command + + + virtual bool init(); +protected: +/*! @struct ExpansionData + @discussion This structure will be used to expand the capablilties of the IOWorkLoop in the future. + */ + struct ExpansionData {IOExtendedLBA* extLBA; }; + +/*! @var reserved + Reserved for future use. (Internal use only) */ + ExpansionData *fExpansionData; + + // overrides + virtual void free(); + + +private: + OSMetaClassDeclareReservedUsed(IOATACommand, 0); // set end result + OSMetaClassDeclareReservedUsed(IOATACommand, 1); // get extendedLBAPtr + OSMetaClassDeclareReservedUnused(IOATACommand, 2); + OSMetaClassDeclareReservedUnused(IOATACommand, 3); + OSMetaClassDeclareReservedUnused(IOATACommand, 4); + OSMetaClassDeclareReservedUnused(IOATACommand, 5); + OSMetaClassDeclareReservedUnused(IOATACommand, 6); + OSMetaClassDeclareReservedUnused(IOATACommand, 7); + OSMetaClassDeclareReservedUnused(IOATACommand, 8); + OSMetaClassDeclareReservedUnused(IOATACommand, 9); + OSMetaClassDeclareReservedUnused(IOATACommand, 10); + OSMetaClassDeclareReservedUnused(IOATACommand, 11); + OSMetaClassDeclareReservedUnused(IOATACommand, 12); + OSMetaClassDeclareReservedUnused(IOATACommand, 13); + OSMetaClassDeclareReservedUnused(IOATACommand, 14); + OSMetaClassDeclareReservedUnused(IOATACommand, 15); + OSMetaClassDeclareReservedUnused(IOATACommand, 16); + OSMetaClassDeclareReservedUnused(IOATACommand, 17); + OSMetaClassDeclareReservedUnused(IOATACommand, 18); + OSMetaClassDeclareReservedUnused(IOATACommand, 19); + OSMetaClassDeclareReservedUnused(IOATACommand, 20); + +public: + virtual void setEndResult(UInt8 inStatus, UInt8 endError ); + virtual IOExtendedLBA* getExtendedLBA(void); + + +}; + + +/*! +@class IOExtendedLBA + +@discussion +If 48-bit LBAs are supported, IOExtendedLBA is used to represent a 48-bit LBA. +The driver examines the ATA identify data to determine if 48-bit addressing is +supported. +*/ + +class IOExtendedLBA : public OSObject +{ + OSDeclareDefaultStructors( IOExtendedLBA ); + + public: + static IOExtendedLBA* createIOExtendedLBA(IOATACommand* owner); + + // terminology as established in ATA/ATAPI-6. + // for the extended LBA address + + /*!@function setLBALow16 + @abstract convenience method that sets the lower 16 bits of a 48-bit LBA + */ + virtual void setLBALow16( UInt16 lbaLow); + + /*!@function getLBALow16 + @abstract convenience method that gets the lower 16 bits of a 48-bit LBA + */ + virtual UInt16 getLBALow16 (void); + + /*!@function setLBAMid16 + @abstract convenience method that sets the middle 16 bits of a 48-bit LBA + */ + virtual void setLBAMid16 (UInt16 lbaMid); + + /*!@function getLBAMid16 + @abstract convenience method that gets the middle 16 bits of a 48-bit LBA + */ + virtual UInt16 getLBAMid16( void ); + + /*!@function setLBAHigh16 + @abstract convenience method that sets the high 16 bits of a 48-bit LBA + */ + virtual void setLBAHigh16( UInt16 lbaHigh ); + + /*!@function getLBAHigh16 + @abstract convenience method that gets the high 16 bits of a 48-bit LBA + */ + virtual UInt16 getLBAHigh16( void ); + + /*!@function setSectorCount16 + @abstract Taskfile access. Registers are named in accordance with ATA Standards conventions + */ + virtual void setSectorCount16( UInt16 sectorCount ); + + /*!@function getSectorCount16 + @abstract Taskfile access. Registers are named in accordance with ATA Standards conventions + */ + virtual UInt16 getSectorCount16( void ); + + /*!@function setFeatures16 + @abstract Taskfile access. Registers are named in accordance with ATA Standards conventions + */ + virtual void setFeatures16( UInt16 features ); + + /*!@function getFeatures16 + @abstract Taskfile access. Registers are named in accordance with ATA Standards conventions + */ + virtual UInt16 getFeatures16( void ); + + /*!@function setDevice + @abstract Taskfile access. Registers are named in accordance with ATA Standards conventions + */ + virtual void setDevice( UInt8 inDevice ); + + /*!@function getDevice + @abstract Taskfile access. Registers are named in accordance with ATA Standards conventions + */ + virtual UInt8 getDevice( void ); + + /*!@function setCommand + @abstract Taskfile access. Registers are named in accordance with ATA Standards conventions + */ + virtual void setCommand( UInt8 inCommand ); + + /*!@function getCommand + @abstract Taskfile access. Registers are named in accordance with ATA Standards conventions + */ + virtual UInt8 getCommand( void ); + + /*!@function setExtendedLBA + @abstract convenience method that sets the taskfile registers into a 48-bit LBA address, along with sector count, and unit selected and LBA bit set + */ + virtual void setExtendedLBA( UInt32 inLBAHi, UInt32 inLBALo, ataUnitID inUnit, UInt16 extendedCount, UInt8 extendedCommand); + + /*!@function getExtendedLBA + @abstract convenience method that gets a 48-bit LBA + */ + virtual void getExtendedLBA( UInt32* outLBAHi, UInt32* outLBALo ); + + /*!@function zeroData + @abstract convenience method that zeros out the lba, sector count, features, device, and command member variables + */ + virtual void zeroData(void); + + /*! @struct ExpansionData + @discussion This structure will be used to expand the capablilties in the future. + */ + struct ExpansionData { }; + + /*! @var reserved + Reserved for future use. (Internal use only) */ + ExpansionData *reserved; + + + protected: + + IOATACommand* owner; + UInt16 lbaLow; + UInt16 lbaMid; + UInt16 lbaHigh; + UInt16 sectorCount; + UInt16 features; + UInt16 device; + UInt16 command; + + private: + OSMetaClassDeclareReservedUnused(IOExtendedLBA, 0); + OSMetaClassDeclareReservedUnused(IOExtendedLBA, 1); + OSMetaClassDeclareReservedUnused(IOExtendedLBA, 2); + OSMetaClassDeclareReservedUnused(IOExtendedLBA, 3); + OSMetaClassDeclareReservedUnused(IOExtendedLBA, 4); + OSMetaClassDeclareReservedUnused(IOExtendedLBA, 5); + OSMetaClassDeclareReservedUnused(IOExtendedLBA, 6); + OSMetaClassDeclareReservedUnused(IOExtendedLBA, 7); + OSMetaClassDeclareReservedUnused(IOExtendedLBA, 8); + OSMetaClassDeclareReservedUnused(IOExtendedLBA, 9); + OSMetaClassDeclareReservedUnused(IOExtendedLBA, 10); + + +}; + +#endif Index: branches/azimutz/Cleancut/i386/include/IOKit/ata/IOATADevice.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/ata/IOATADevice.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/ata/IOATADevice.h (revision 885) @@ -0,0 +1,179 @@ +/* + * 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@ + */ +/* + * IOATADevice.h + * + * This object implements a relay to an ATA Bus where a drive is attached. + */ + + +#ifndef _IOATADEVICE_H +#define _IOATADEVICE_H + +#include <IOKit/IOService.h> +#include <IOKit/IOTypes.h> +#include "IOATATypes.h" +#include "IOATACommand.h" +#include "IOATABusInfo.h" +#include "IOATADevConfig.h" + +class IOATAController; + + +/*! + @class IOATADevice + @abstract This object implements a relay to an ATA Bus where a drive is attached. + @discussion IOATADevice is the superclass which represents a particular device attached to a particular IOATAController (bus). IOATADevice is the provider for ATA mass-storage device drivers.IOATADevice is the factory for all IOATACommand objects and is responsible for creating and freeing IOATACommands. IOATAControllers will create an instance of IOATADevice for each device physically connected to the ata bus. IOATADevice is virtual and specific subclass should be implemented for particular types of IOATAController. In this manner, controller-specifc IOATACommands may be paired with the proper type of controller. +*/ + +class IOATADevice : public IOService +{ + OSDeclareDefaultStructors(IOATADevice); + +public: + + // + /*!@function getUnitID + @abstract Determine whether this device is number 0 or 1 (ie, master/slave) + @result ataUnitID - 0 or 1. + */ + virtual ataUnitID getUnitID( void ); + + // + /*!@function getDeviceType + @abstract Find out what kind of device this nub is (ata or atapi) + @result ataDeviceType as defined in IOATATypes.h + */ + virtual ataDeviceType getDeviceType( void ); + + // + /*!@function provideBusInfo + @abstract Find out the bus capability so the client can choose the features to set and commands to run. + @param getInfo a pointer to a valid IOATABusInfo object. + @result kIOSuccess (0) and the getInfo object will be filled out by the bus controller with information about the bus. + */ + virtual IOReturn provideBusInfo( IOATABusInfo* getInfo); + + // + /*!@function selectConfig + @abstract Tell the bus what speed to use for your device. + @param configRequest pointer to a valid and initialized IOATADevConfig object. + @result kIOSuccess (0) if the configuration was succesfully selected. + @discussion This should only be called once during a disk drivers start method before registering its availability, and must be called prior to issuing any data IO transactions. + */ + virtual IOReturn selectConfig( IOATADevConfig* configRequest); + + // + /*!@function provideConfig + @abstract Find out what speed the bus has configured for this unit. + @param configRequest pointer to a valid IOATADevConfig object. + @result kIOSuccess (0) on successful completion and configRequest will contain the configuration information. + */ + virtual IOReturn provideConfig( IOATADevConfig* configRequest); + + // Submit IO requests + /*! + @function executeCommand + @abstract Submit IO requests + @param command pointer to a valid IOATACommand with the command to be executed. + @result kIOSuccess (0) if the command was successfully queued in the controller. + */ + virtual IOReturn executeCommand(IOATACommand* command); + + // create and destroy IOATACommands + /*! + @function allocCommand + @abstract create IOATACommands. Device drivers should allocate command objects only through this method. + @result null if allocation failed. Retain count is one. + */ + virtual IOATACommand* allocCommand( void ); + + /*! + @function freeCommand + @abstract release a command object that is no longer needed. Do not free an object in use and do not release the object anymore times than you have retained it. + @param inCommand the command to be released. + */ + virtual void freeCommand( IOATACommand* inCommand); + + // matching stuff for IOBSDInit and so on. + /*!@function matchPropertyTable + @abstract matching stuff for IOBSDInit and so on. + */ + virtual bool matchPropertyTable(OSDictionary * table); + + /*!@function matchLocation + @abstract matching stuff for IOBSDInit and so on. + */ + virtual IOService* matchLocation(IOService * client); + + /*!@function matchPropertyTable + @abstract matching stuff for IOBSDInit and so on. + */ + virtual bool matchPropertyTable(OSDictionary * table, SInt32 * score); + + // called by controllers when they need to send a message to client drivers. + /*! + @function notifyEvent + @abstract called by controllers when they need to send a message to client (disk) drivers. + */ + virtual void notifyEvent( UInt32 event ); + + +protected: + IOATAController* _provider; + ataUnitID _unitNumber; // 0 - master, 1 - slave, -1 = not Valid + ataDeviceType _deviceType; // ata, atapi, unknown +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) */ + ExpansionData *reserved; + +private: + OSMetaClassDeclareReservedUnused(IOATADevice, 0); + OSMetaClassDeclareReservedUnused(IOATADevice, 1); + OSMetaClassDeclareReservedUnused(IOATADevice, 2); + OSMetaClassDeclareReservedUnused(IOATADevice, 3); + OSMetaClassDeclareReservedUnused(IOATADevice, 4); + OSMetaClassDeclareReservedUnused(IOATADevice, 5); + OSMetaClassDeclareReservedUnused(IOATADevice, 6); + OSMetaClassDeclareReservedUnused(IOATADevice, 7); + OSMetaClassDeclareReservedUnused(IOATADevice, 8); + OSMetaClassDeclareReservedUnused(IOATADevice, 9); + OSMetaClassDeclareReservedUnused(IOATADevice, 10); + OSMetaClassDeclareReservedUnused(IOATADevice, 11); + OSMetaClassDeclareReservedUnused(IOATADevice, 12); + OSMetaClassDeclareReservedUnused(IOATADevice, 13); + OSMetaClassDeclareReservedUnused(IOATADevice, 14); + OSMetaClassDeclareReservedUnused(IOATADevice, 15); + OSMetaClassDeclareReservedUnused(IOATADevice, 16); + OSMetaClassDeclareReservedUnused(IOATADevice, 17); + OSMetaClassDeclareReservedUnused(IOATADevice, 18); + OSMetaClassDeclareReservedUnused(IOATADevice, 19); + OSMetaClassDeclareReservedUnused(IOATADevice, 20); +}; + +#endif /* !_IOATABUSNUB_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/ata/MacIOATA.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/ata/MacIOATA.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/ata/MacIOATA.h (revision 885) @@ -0,0 +1,225 @@ +/* + * 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@ + */ + +#if defined(__ppc__) + + +#ifndef _DRV_MACIO_ATA_H +#define _DRV_MACIO_ATA_H + +#include <libkern/c++/OSObject.h> +#include <IOKit/IOTypes.h> +#include "IOATAController.h" +#include <IOKit/ppc/IODBDMA.h> +#include <IOKit/IOMemoryCursor.h> + +#include <IOKit/IOInterruptEventSource.h> + + +/*! @class MacIOATA + @abstract The base class for MAC-IO ata controller family. . + @discussion class defining the portions of MacIO ATA cells which are shared + in common between Heathrow and Key Largo ATA Cells. + These controllers share a common register file layout, interrupt + source format and all use DBDMA engines. These are different from + other ATA controllers, such as most PCI-IDE and PC-Card ATA ports. + Each cell type has some distinctive features that must be implemented + by a specific driver subclass. As much common code as possible is + presented in this superclass. + +*/ + +class MacIOATA : public IOATAController +{ + OSDeclareDefaultStructors(MacIOATA); + +public: + + /*--- Overrides from IOATAController ---*/ + virtual bool init(OSDictionary * properties); + virtual bool start( IOService* provider ); + virtual IOReturn message (UInt32 type, IOService* provider, void* argument = 0); + +protected: + + // The DMA states: not in use, in use and running with additional passes needed, + // in use on final pass, transfer complete, and failure + enum ATADMAState + { + kATADMAInactive, + kATADMAStarting, + kATADMAActive, + kATADMAStatus, + kATADMAComplete, + kATADMAError + }; + + + + // the address of the timing register in the controller + volatile UInt32* _timingConfigReg; + // the timing values to use for each device. + UInt32 _timingConfig[2]; + + // semaphore for DMA state + UInt32 _dmaState; + + // indicates whether a DMA interrupt is expected + UInt32 _dmaIntExpected; + + // pointer to the DMA control register address. + volatile IODBDMAChannelRegisters* _dmaControlReg; + + // mappings to the controller and DMA engine registers + // we have to free these when we go away. + IOMemoryMap* _baseAddressMap; + IOMemoryMap* _dmaBaseMap; + + // the DBDMA memory cursor + IODBDMAMemoryCursor* _DMACursor; + + // the DBDMA descriptor table + IODBDMADescriptor* _descriptors; + IOPhysicalAddress _descriptorsPhysical; + + // interrupt event sources + IOInterruptEventSource* _devIntSrc; + IOInterruptEventSource* _dmaIntSrc; + + // flag indicating device and dma engine interrupts need + // re-synchronization. + + bool _resyncInterrupts; +/*! @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) */ + ExpansionData *reserved; + + // overriden to allow synchronization of DMA vs. device interrupts. + virtual IOReturn handleDeviceInterrupt(void); + // overriden here to allow for reporting of DMA errs + virtual IOReturn asyncStatus(void); + + // overriden here to allow for clean up of DMA resynch flag on timeout. + virtual void handleTimeout(void); + + + // called by the superclass::start method in order to + // find and enable access to the ATA task file. + virtual bool configureTFPointers(void); + + // allocate memory for the DMA descriptors. + virtual bool allocDMAChannel(void); + + // fill CC with stop commands. + virtual void initATADMAChains (IODBDMADescriptor* descPtr); + + // setup the CC with IO commands + virtual IOReturn createChannelCommands(void); + + // deallocate memory for the DMA engine + virtual bool freeDMAChannel(void); + + // connect the device (drive) interrupt to our workloop + virtual bool createDeviceInterrupt(void); + + // connect the DMA interrupt to our workloop. + virtual bool createDMAInterrupt(void); + + + // override from IOATAController + // activate the DMA engine as per the current command + virtual IOReturn startDMA( void ); + + // override from IOATAController + // safely halt the DMA engine regardless of state + virtual IOReturn stopDMA( void ); + + // handle the interrupt processing + virtual void processDMAInterrupt (void); + + // activate the DMA engine + virtual void activateDMAEngine(void); + + // shutdown the DMA engine + virtual void stopDMAEngine(void); + + // safely suspend the DMA engine + virtual void shutDownATADMA (void); + + // check the command chain after run to update byte counts + // and check for errors + virtual bool scanATADMAChain (IOByteCount* byteCount); + + + // c to c++ glue code. + static void deviceInterruptOccurred(OSObject*, IOInterruptEventSource *, int count); + static void dmaInterruptOccurred(OSObject*, IOInterruptEventSource *, int count); + + // overrides + virtual void free(); + + // media bay specific code + bool isMediaBay; + bool isBusOnline; + + virtual IOReturn executeCommand(IOATADevice* nub, IOATABusCommand* command); + virtual IOReturn handleQueueFlush( void ); + virtual bool checkTimeout( void ); + static void cleanUpAction(OSObject * owner, void*, void*, void*, void*); + virtual void cleanUpBus(void); + virtual IOReturn handleBusReset(void); + // end media bay specific. + +private: + OSMetaClassDeclareReservedUnused(MacIOATA, 0); + OSMetaClassDeclareReservedUnused(MacIOATA, 1); + OSMetaClassDeclareReservedUnused(MacIOATA, 2); + OSMetaClassDeclareReservedUnused(MacIOATA, 3); + OSMetaClassDeclareReservedUnused(MacIOATA, 4); + OSMetaClassDeclareReservedUnused(MacIOATA, 5); + OSMetaClassDeclareReservedUnused(MacIOATA, 6); + OSMetaClassDeclareReservedUnused(MacIOATA, 7); + OSMetaClassDeclareReservedUnused(MacIOATA, 8); + OSMetaClassDeclareReservedUnused(MacIOATA, 9); + OSMetaClassDeclareReservedUnused(MacIOATA, 10); + OSMetaClassDeclareReservedUnused(MacIOATA, 11); + OSMetaClassDeclareReservedUnused(MacIOATA, 12); + OSMetaClassDeclareReservedUnused(MacIOATA, 13); + OSMetaClassDeclareReservedUnused(MacIOATA, 14); + OSMetaClassDeclareReservedUnused(MacIOATA, 15); + OSMetaClassDeclareReservedUnused(MacIOATA, 16); + OSMetaClassDeclareReservedUnused(MacIOATA, 17); + OSMetaClassDeclareReservedUnused(MacIOATA, 18); + OSMetaClassDeclareReservedUnused(MacIOATA, 19); + OSMetaClassDeclareReservedUnused(MacIOATA, 20); + +}; + +#endif // _DRV_MACIO_ATA_H + + +#endif // defined(ppc) Index: branches/azimutz/Cleancut/i386/include/IOKit/ata/IOATAController.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/ata/IOATAController.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/ata/IOATAController.h (revision 885) @@ -0,0 +1,314 @@ +/* + * 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 _IOATACONTROLLER_H +#define _IOATACONTROLLER_H + +#include <IOKit/IOTypes.h> +#include <IOKit/IOBufferMemoryDescriptor.h> +#include <IOKit/IOCommandGate.h> +#include <IOKit/IOService.h> +#include <IOKit/IOWorkLoop.h> +#include "ATATimerEventSource.h" + +class IOATADevice; +class IOATABusCommand; +class IOATABusInfo; +class IOATADevConfig; + +/*! @class IOATAController + @abstract The base class for ata controller family. Provides the interface common to all ata bus controllers. + @discussion Subclasses of IOATAController implement drivers for specific bus hardware. Disk devices are clients of + IOATAController and communicate via the IOATABusNub instantiated for each device discovered by the specific IOATAController + subclass when it probes hardware. Via the nub, the ATA Controller provides standard information about bus capability, accepts + requests for transfer mode configuration (timing), accepts requests for IO and bus operations, notifies the device driver about + bus events which may affect the device, such as soft-resets or device removal (ie, media-bay and PC-card) and removal of queued + IO requests which have not been dispatched into the hardware. + + @discussion The header doc for this class is incomplete. The source however is heavily commented and should be consulted until + such time as complete header doc is available. +*/ + + + +class IOATAController : public IOService +{ + OSDeclareDefaultStructors(IOATAController); + +public: + + + /*--- Common ATA Controller Interface ---*/ + // find out bus capability + virtual IOReturn provideBusInfo( IOATABusInfo* infoOut); + + // set and get bus timing configuration for a specific unit + virtual IOReturn selectConfig( IOATADevConfig* configRequest, UInt32 unitNumber); + virtual IOReturn getConfig( IOATADevConfig* configRequest, UInt32 unitNumber); + + // The main call puts something on the work loop + virtual IOReturn executeCommand( IOATADevice* nub, IOATABusCommand* cmd); + + + + /*-- Power Management ---*/ + + // TBD + + + /*--- Overrides from IOService ---*/ + virtual bool init(OSDictionary * properties); + + virtual IOService* probe( IOService* provider, SInt32* score ); + virtual bool start( IOService* provider ); + + +protected: + + enum { + kBusFree = 'free', // bus is available + kBusBusy = 'busy', // bus is busy with request + kQueueOpen = '!lck', // queue is not locked + kQueueLocked = 'LOCK', // queue is frozen and not + kImmediateLocked = '!Imd', // immediate commands may not be processed + kImmediateOK = 'Immd' // immediate commands allowed. + }; + + /* Transaction State indicator definition - indicates what action is next*/ + enum transState { + kATAInitial = 0x00, // in queue + kATAStarted = 0x01, // issue taskfile + kATAPICmd = 0x02, // issue packet + kATADataTx = 0x03, // data transfer phase + kATAStatus = 0x04, // read status + kATAComplete = 0x05, // io complete + kATADone = 0x06 // completion callout called + }; + + struct ataDevInfo { + ataDeviceType type; // ata, atapi, unknown + atapiConfig packetSend; // slow DRQ, IRQ, or fast DRQ for packet + }; + + + struct ataDoubleBuffer + { + IOPhysicalAddress physicalBuffer; + IOLogicalAddress logicalBuffer; + IOByteCount bufferSize; + + }; + + + IOService* _provider; + IOWorkLoop* _workLoop; + IOCommandGate* _cmdGate; + ATATimerEventSource* _timer; + queue_head_t _commandQueue; + IOATABusCommand* _currentCommand; + UInt32 _busState; + UInt32 _queueState; + UInt32 _immediateGate; + ataUnitID _selectedUnit; + ataDevInfo _devInfo[2]; + IOATADevice* _nub[2]; + ataDoubleBuffer _doubleBuffer; + + IOATARegPtr8 _tfFeatureReg; + IOATARegPtr8 _tfSCountReg; + IOATARegPtr8 _tfSectorNReg; + IOATARegPtr8 _tfCylLoReg; + IOATARegPtr8 _tfCylHiReg; + IOATARegPtr8 _tfSDHReg; + IOATARegPtr8 _tfStatusCmdReg; + IOATARegPtr16 _tfDataReg; + IOATARegPtr8 _tfAltSDevCReg; + + + // false if couldn't allocate the per-bus double buffer. + // controllers should provide implementation where needed + // for DMA hardware compatibility. The default method provides + // a 4K buffer for PIO since MemoryDescriptors do not by default have + // logical addresses in the kernel space. + virtual bool allocateDoubleBuffer( void ); + + // perform 2-byte endian swap. Only useful on PIO transfers and identify data + virtual void swapBytes16( UInt8* dataBuffer, IOByteCount length); + +/*! @function handleCommand + @abstract Called by executeCommand() to handle the client command + from the workloop context. + @param command The command code. + @param param1 Command parameter. + @param param2 Command parameter. + @param param3 Command parameter. + @result kIOReturnSuccess on success, or an error code otherwise. */ + + virtual IOReturn handleCommand( void * command, + void * param1 = 0, + void * param2 = 0, + void * param3 = 0); + + +/*! @function busCanDispatch + @abstract answers whether the bus is in state such that the next command + can be dispatched. + @result true - bus is free to issue commands. false - bus cannot issue + commands at this time. */ + virtual bool busCanDispatch( void ); + + +/*! @function dispatchNext + @abstract Causes the command at the front of the queue to dequeue, made the + current command and begin execution. + @result noErr indicates successful dispatch. */ + virtual IOReturn dispatchNext( void ); + + // sets the result code, free's the bus state, dispatch next command and execute completion + virtual void completeIO( IOReturn commandResult ); + + // Command queue handlers. + virtual IOReturn enqueueCommand( IOATABusCommand* command); + virtual IOATABusCommand* dequeueFirstCommand( void ); + + // event notifier for clients + virtual void executeEventCallouts( ataEventCode event, ataUnitID unit); + + // default handler for device interrupts. + virtual IOReturn handleDeviceInterrupt( void ); + + + // timer functions + // starts the timeout on the current command + virtual IOReturn startTimer( UInt32 inMS); + //disable and clear a running timer. + virtual void stopTimer( void ); + // called when a timeout occurs. + virtual void handleTimeout( void ); + // true if the timer has expired + virtual bool checkTimeout( void ); + + // handle IO opcodes + virtual IOReturn handleExecIO( void ); + virtual IOReturn handleRegAccess( void ); + virtual IOReturn handleBusReset(void); + virtual IOReturn handleQueueFlush( void ); + + // various protocol phases + virtual IOReturn asyncData(void); + virtual IOReturn asyncStatus(void); + virtual IOReturn asyncIO(void); + virtual IOReturn asyncCommand(void); + virtual IOReturn synchronousIO(void); + + // hardware access + virtual IOReturn selectDevice( ataUnitID unit ); + virtual IOReturn issueCommand( void ); + virtual IOReturn writePacket( void ); + virtual IOReturn softResetBus( bool doATAPI = false ); + + virtual IOReturn startDMA( void ); + virtual IOReturn stopDMA( void ); + + virtual bool ATAPISlaveExists( void ); + virtual UInt32 scanForDrives( void ); + + virtual bool waitForU8Status (UInt8 mask, UInt8 value); + + virtual IOByteCount readATAPIByteCount( void ); + virtual void handleOverrun( IOByteCount length); + virtual IOReturn registerAccess(bool isWrite); + + // PIO data transfers + virtual IOReturn txDataIn (IOLogicalAddress buf, IOByteCount length); + virtual IOReturn txDataOut (IOLogicalAddress buf, IOByteCount length); + + virtual IOATAController::transState determineATAPIState(void); + + // device should set the controller to the config for this device + virtual void selectIOTiming( ataUnitID unit ); + + // subclasses MUST implement this function in order to initialize + // the pointers to the ATA task file registers during start() time. + virtual bool configureTFPointers(void); + + // convert a bit-significant indicator to a numeric value. + virtual UInt16 bitSigToNumeric( UInt16 binary); + + // for 48 bit register reading and writing + UInt16 readExtRegister( IOATARegPtr8 inRegister ); + void writeExtRegister( IOATARegPtr8 inRegister, UInt16 inValue ); + + // overrides + virtual void free(); + +private: + + // used called by the commandgate in executeCommand. + static void executeCommandAction(OSObject * owner, + void * arg0, + void * arg1, + void * arg2, + void * arg3); + + // callout used by the timer to indicate the timeout failure. + static void timeoutOccured( OSObject *owner, + IOTimerEventSource *sender); + +protected: +/*! @struct ExpansionData + @discussion This structure will be used to expand the capablilties of the IOATAController in the future. + */ + typedef struct ExpansionData + { + IOBufferMemoryDescriptor* _doubleBufferDesc; + } ExpansionData; + +/*! @var reserved + Reserved for future use. (Internal use only) */ + ExpansionData *reserved; + +private: + OSMetaClassDeclareReservedUnused(IOATAController, 0); + OSMetaClassDeclareReservedUnused(IOATAController, 1); + OSMetaClassDeclareReservedUnused(IOATAController, 2); + OSMetaClassDeclareReservedUnused(IOATAController, 3); + OSMetaClassDeclareReservedUnused(IOATAController, 4); + OSMetaClassDeclareReservedUnused(IOATAController, 5); + OSMetaClassDeclareReservedUnused(IOATAController, 6); + OSMetaClassDeclareReservedUnused(IOATAController, 7); + OSMetaClassDeclareReservedUnused(IOATAController, 8); + OSMetaClassDeclareReservedUnused(IOATAController, 9); + OSMetaClassDeclareReservedUnused(IOATAController, 10); + OSMetaClassDeclareReservedUnused(IOATAController, 11); + OSMetaClassDeclareReservedUnused(IOATAController, 12); + OSMetaClassDeclareReservedUnused(IOATAController, 13); + OSMetaClassDeclareReservedUnused(IOATAController, 14); + OSMetaClassDeclareReservedUnused(IOATAController, 15); + OSMetaClassDeclareReservedUnused(IOATAController, 16); + OSMetaClassDeclareReservedUnused(IOATAController, 17); + OSMetaClassDeclareReservedUnused(IOATAController, 18); + OSMetaClassDeclareReservedUnused(IOATAController, 19); + OSMetaClassDeclareReservedUnused(IOATAController, 20); +}; +#endif /* !_IOATACONTROLLER_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/ata/IOATADevConfig.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/ata/IOATADevConfig.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/ata/IOATADevConfig.h (revision 885) @@ -0,0 +1,239 @@ +/* + * Copyright (c) 2000-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 _IOATADEVCONFIG_H +#define _IOATADEVCONFIG_H + +#include <libkern/c++/OSObject.h> +#include <IOKit/IOTypes.h> +#include "IOATATypes.h" +#include "IOATABusInfo.h" + + +/*! + @class IOATADevConfig + @abstract used for configuring and communicating the desired transfer modes of a device. + A disk driver would typically use this object in conjunction with the 512-bytes of identification + data from the drive and the IOATABusInfo object for the bus it is connected to. + This object will determine the best matching transfer speeds available. + the device driver will then send a series of Set Features commands to configure the drive + and this object to the bus through the IOATADevice nub in order to configure the optimum transfer mode. + The driver for the disk drive may choose to populate this object with whatever transfer mode + desired, in the event that a different mode is required. + @discussion usually use the initWithBestSelection to make a best mode match. + The Mode accessors use bit significance to indicate a selected mode or supported modes(s) + ie, 00000001b indicates Mode-0, 00000010b indicates mode 1, etc. + Selected mode is indicated by a single set bit. No bit set indicates no mode in that class is selected. + ie, a bus will support multiple possible modes, but will only have one mode selected at that time. + +*/ + +class IOATADevConfig : public OSObject { + + OSDeclareDefaultStructors( IOATADevConfig ); + + public: + + /*!@function atadevconfig + @abstract static creator function. + */ + static IOATADevConfig* atadevconfig(void); + + /*!@function initWithBestSelection + @abstract Handy initializer: pass the 512-byte result of the Identify Device or + Identify Packet Device in endian-order for your platform (byte-swapped on PPC) + and the IOATABusInfo object for the bus. The object will initialize all fields + and select the best transfer modes that match on bus and device. + If the return value was 0 (success or noErr), then a matching mode is supported. + Examine the PIO and UDMA/DMA fields and to generate the apropriate SET FEATURES + parameters for your drive and send this initialised object to the IOATAController + when requesting a speed configuration. + failure means no supported transfer modes matched between bus and device info. + + @param identifyData 512 bytes of data obtained from the device via IDENTIFY DEVICE or IDENTIFY PACKET DEVICE command. + @param busInfo pointer to an IOATAbusInfo object obtained from a previous atanub->provideBusInfo() call. + @result kIOSuccess (0) when a matching transfer mode is available between the device and controller. + */ + IOReturn initWithBestSelection( const UInt16* identifyData, IOATABusInfo* busInfo); + + // intitialize with the 512 byte data from an ATA device identify command + IOReturn assignFromData( const UInt16* identifyData ); + + /*!@function setPacketConfig + @param packetConfig + @abstract For ATAPI devices, if the device asserts interrupt after the Packet Command when it is ready to accept the packet, set this value to true (mostly older devices). If the device accepts the packet only by asserting DRQ bit in status, then set this value false. Tells the bus controller whether to wait for packet acceptance or set pending interrupt. + */ + void setPacketConfig ( atapiConfig packetConfig); + + /*!@function getPacketConfig + @result atapiConfig as defined in IOATATypes.h + */ + atapiConfig getPacketConfig( void ); + + // The following Mode accessors use bit significance to indicate a selected mode or supported modes(s) + // ie, 00000001b indicates Mode-0, 00000010b indicates mode 1, etc. + // Selected mode is indicated by a single set bit. No bit set indicates no mode in that class is selected. + // ie, a bus will support multiple possible modes, but will only have one mode selected at that time. + + /*!@function setPIOMode + @param inModeBitMap bit-significant map of PIO mode + */ + void setPIOMode( UInt8 inModeBitMap); // bit-significant map of PIO mode(s) + + /*!@function getPIOMode + @result bit-significant map of PIO mode + */ + UInt8 getPIOMode( void ); + + /*!@function setDMAMode + @param inModeBitMap bit-significant map of DMA mode + */ + void setDMAMode( UInt8 inModeBitMap ); // bit-significant map of DMA mode(s) + + /*!@function getDMAMode + @result bit-significant map of DMA mode + */ + UInt8 getDMAMode( void ); + + /*!@function setUltraMode + @param inModeBitMap bit-significant map of Ultra mode + */ + void setUltraMode( UInt8 inModeBitMap ); // bit-significant map of Ultra mode(s) + + /*!@function getUltraMode + @result bit-significant map of Ultra mode + */ + UInt8 getUltraMode( void ); + + // The following cycle time accessors report cycle times in nanoseconds. + // A device requesting a mode should also request a cycle time as reported in the device's identification page. + // A bus controller will configure the bus not to exceed (go faster than) the minimum time requested. + // When a bus controller reports a mode configuration, the cycle time indicates the busses contract not to go + // faster than. However an actual cycle time may be slower than the indicated time. + /*!@function setPIOCycleTime + @param inNS PIO cycle time in nanoseconds. + */ + void setPIOCycleTime( UInt16 inNS ); + + /*!@function getPIOCycleTime + @result reported PIO CycleTime in nanoseconds. + */ + UInt16 getPIOCycleTime( void ); + + /*!@function setDMACycleTime + @param inNS reported multiword DMA Cycle time in nanoseconds. + */ + void setDMACycleTime( UInt16 inNS ); + + /*!@function getDMACycleTime + @result Reported multiword DMA cycle time in nanoseconds. + */ + UInt16 getDMACycleTime( void ); + + // Ultra ATA defines cycle times a device must meet to comply with standards. + // No cycle time field is needed. + + // convert bit-significant to numeric value + /*!@function bitSigToNumeric + @abstract converts a bit-significant field to a numerical value. Note that a bit field of 0x00 has no defined result. + @param binary the bit significant field. + @result the numerical value of the highest bit set in the field. + */ + virtual UInt8 bitSigToNumeric( UInt16 binary); + + + protected: + + atapiConfig _atapiIRQForPacket; // enum for bits 5 and 6 of word zero of + // the identify packet device info data for PACKET devices ONLY. + // shift word-0 5-bits left, mask 0x03 and these enums apply. + // values are: + + // kATAPIDRQSlow = 0x00 - wait up to 3MS for packet on DRQ + // kATAPIIRQPacket = 0x01, - device asserts IRQ for packet + // kATAPIDRQFast = 0x10, - packet on DRQ within 50us + // kATAPIUnknown = 0x11 - reserved as of ATA/ATAPI-5 + + + + + UInt8 _ataPIOMode; /* <->: PIO Mode Timing class bit-significant */ + UInt16 _ataPIOCycleTime; /* <->: Cycle time in ns for PIO mode */ + UInt8 _ataMultiDMAMode; /* <->: Multiple Word DMA Timing Class bit-significant*/ + UInt16 _ataMultiCycleTime; /* <->: Cycle time in ns for Multiword DMA mode */ + UInt8 _ataUltraDMAMode; /* <->: Ultra DMA timing class bit-significant */ + + IOReturn _AssignPIOData( const UInt16* identifyData); + IOReturn _AssignDMAData(const UInt16* identifyData); + IOReturn _AssignUltraData(const UInt16* identifyData); + UInt8 _MostSignificantBit( UInt8 inByte); + + + virtual bool init(); +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) */ + ExpansionData *reserved; + +private: + OSMetaClassDeclareReservedUnused(IOATADevConfig, 0); + OSMetaClassDeclareReservedUnused(IOATADevConfig, 1); + OSMetaClassDeclareReservedUnused(IOATADevConfig, 2); + OSMetaClassDeclareReservedUnused(IOATADevConfig, 3); + OSMetaClassDeclareReservedUnused(IOATADevConfig, 4); + OSMetaClassDeclareReservedUnused(IOATADevConfig, 5); + OSMetaClassDeclareReservedUnused(IOATADevConfig, 6); + OSMetaClassDeclareReservedUnused(IOATADevConfig, 7); + OSMetaClassDeclareReservedUnused(IOATADevConfig, 8); + OSMetaClassDeclareReservedUnused(IOATADevConfig, 9); + OSMetaClassDeclareReservedUnused(IOATADevConfig, 10); + OSMetaClassDeclareReservedUnused(IOATADevConfig, 11); + OSMetaClassDeclareReservedUnused(IOATADevConfig, 12); + OSMetaClassDeclareReservedUnused(IOATADevConfig, 13); + OSMetaClassDeclareReservedUnused(IOATADevConfig, 14); + OSMetaClassDeclareReservedUnused(IOATADevConfig, 15); + OSMetaClassDeclareReservedUnused(IOATADevConfig, 16); + OSMetaClassDeclareReservedUnused(IOATADevConfig, 17); + OSMetaClassDeclareReservedUnused(IOATADevConfig, 18); + OSMetaClassDeclareReservedUnused(IOATADevConfig, 19); + OSMetaClassDeclareReservedUnused(IOATADevConfig, 20); + +public: + +//some static utility functions to parse the identify data for feature support + + static bool sDriveSupports48BitLBA( const UInt16* identifyData ); + static UInt32 sDriveExtendedLBASize( UInt32* lbaHi, UInt32* lbaLo, const UInt16* identifyData); // result returned is same as lbaLo. + +}; + + +// header doc info goes here. I find putting it within the delcarations more confusing than putting it all in the bottom of the header. + + +#endif /* !_IOATADEVCONFIG_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/ata/IOATATypes.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/ata/IOATATypes.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/ata/IOATATypes.h (revision 885) @@ -0,0 +1,393 @@ +/* + * Copyright (c) 2000-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 _IOATATYPES_H +#define _IOATATYPES_H + +#include <IOKit/IOTypes.h> + + +/*! + +@header IOATAtypes.h +@discussion contains various definitions and constants for use in the IOATAFamily and clients. Header Doc is incomplete at this point, but file is heavily commented. + +*/ +// property strings +#define kATADevPropertyKey "ata device type" +#define kATATypeATAString "ata" +#define kATATypeATAPIString "atapi" +#define kATATypeUnknownString "unknown" + +#define kATAVendorPropertyKey "device model" +#define kATARevisionPropertyKey "device revision" +#define kATASerialNumPropertyKey "device serial" + +#define kATAUnitNumberKey "unit number" + +#define kATASocketKey "socket type" +#define kATAInternalSocketString "internal" +#define kATAMediaBaySocketString "media-bay" +#define kATAPCCardSocketString "pccard" +#define kATAInternalSATAString "serial-ata" +#define kATASATABayString "sata-bay" +#define kATAInternalSATA2 "serial-ata-2" +#define kATASATA2BayString "sata-2-bay" +#define kATAUnkownSocketString "unknown" + +#define kATANotifyOnChangeKey "media-notify" + +// allows for porting to non-memory-mapped IO systems, such as x86. +// for such a platform, create a class and overload the assignment operators +// so that the correct IO operation is performed and define the type for that architecture port. +#ifdef __ppc__ +#define IOATARegPtr8 volatile UInt8* +#define IOATARegPtr16 volatile UInt16* +#define IOATARegPtr32 volatile UInt32* +#define IOATARegPtr8Cast(x) ((IOATARegPtr8)(x)) +#elif defined( __i386__ ) || defined( __x86_64__ ) +#include <IOKit/ata/IOATARegI386.h> +#else +#error Unknown machine architecture +#endif + +enum ataSocketType{ + + kUnknownSocket = 0, + kInternalATASocket, + kMediaBaySocket , + kPCCardSocket, + kInternalSATA, + kSATABay, + kInternalSATA2, + kSATA2Bay + +} ; + + +enum ataDeviceType { + + kUnknownATADeviceType = 0, + kATADeviceType, + kATAPIDeviceType + +} ; + +// enum for bits 5 and 6 of word zero of +// the identify packet device info data. +// shift word-0 5-bits left, mask 0x03 and these enums apply. +enum atapiConfig { + + kATAPIDRQSlow = 0x00, + kATAPIIRQPacket = 0x01, + kATAPIDRQFast = 0x10, + kATAPIUnknown = 0x11 + +}; + + +enum ataUnitID { + + kATAInvalidDeviceID = -1, + kATADevice0DeviceID = 0, /* aka, Master. Device 0 is the correct terminology */ + kATADevice1DeviceID = 1 /* aka, Slave. Device 1 is the correct terminology */ + +} ; + +enum { + + kATADefaultSectorSize = 512 +}; + +/* Task file definition *** Error Register *** */ +enum { + bATABadBlock = 7, /* bit number of bad block error bit*/ + bATAUncorrectable = 6, /* bit number of uncorrectable error bit*/ + bATAMediaChanged = 5, /* bit number of media changed indicator*/ + bATAIDNotFound = 4, /* bit number of ID not found error bit*/ + bATAMediaChangeReq = 3, /* bit number of media changed request*/ + bATACommandAborted = 2, /* bit number of command abort bit*/ + bATATrack0NotFound = 1, /* bit number of track not found*/ + bATAAddressNotFound = 0, /* bit number of address mark not found*/ + mATABadBlock = 1 << bATABadBlock, /* Bad Block Detected*/ + mATAUncorrectable = 1 << bATAUncorrectable, /* Uncorrectable Data Error*/ + mATAMediaChanged = 1 << bATAMediaChanged, /* Media Changed Indicator (for removable)*/ + mATAIDNotFound = 1 << bATAIDNotFound, /* ID Not Found*/ + mATAMediaChangeReq = 1 << bATAMediaChangeReq, /* Media Change Requested (NOT IMPLEMENTED)*/ + mATACommandAborted = 1 << bATACommandAborted, /* Aborted Command*/ + mATATrack0NotFound = 1 << bATATrack0NotFound, /* Track 0 Not Found*/ + mATAAddressNotFound = 1 << bATAAddressNotFound /* Address Mark Not Found*/ +}; + +/* Task file definition *** Features register *** */ +enum { + bATAPIuseDMA = 0, /* bit number of useDMA bit (ATAPI)*/ + mATAPIuseDMA = 1 << bATAPIuseDMA +}; + +/* Task file definition *** ataTFSDH Register *** */ +enum { + mATAHeadNumber = 0x0F, /* Head Number (bits 0-3) */ + mATASectorSize = 0xA0, /* bit 7=1; bit 5 = 01 (512 sector size) <DP4>*/ + mATADriveSelect = 0x10, /* Drive (0 = master, 1 = slave) */ + mATALBASelect = 0x40 /* LBA mode bit (0 = chs, 1 = LBA)*/ +}; + +/* Task file definition *** Status Register *** */ +enum { + bATABusy = 7, /* bit number of BSY bit*/ + bATADriveReady = 6, /* bit number of drive ready bit*/ + bATAWriteFault = 5, /* bit number of write fault bit*/ + bATASeekComplete = 4, /* bit number of seek complete bit*/ + bATADataRequest = 3, /* bit number of data request bit*/ + bATADataCorrected = 2, /* bit number of data corrected bit*/ + bATAIndex = 1, /* bit number of index mark*/ + bATAError = 0, /* bit number of error bit*/ + mATABusy = 1 << bATABusy, /* Unit is busy*/ + mATADriveReady = 1 << bATADriveReady, /* Unit is ready*/ + mATAWriteFault = 1 << bATAWriteFault, /* Unit has a write fault condition*/ + mATASeekComplete = 1 << bATASeekComplete, /* Unit seek complete*/ + mATADataRequest = 1 << bATADataRequest, /* Unit data request*/ + mATADataCorrected = 1 << bATADataCorrected, /* Data corrected*/ + mATAIndex = 1 << bATAIndex, /* Index mark - NOT USED*/ + mATAError = 1 << bATAError /* Error condition - see error register*/ +}; + +/* Task file definition *** Device Control Register *** */ +enum { + bATADCROne = 3, /* bit number of always one bit*/ + bATADCRReset = 2, /* bit number of reset bit*/ + bATADCRnIntEnable = 1, /* bit number of interrupt disable*/ + mATADCROne = 1 << bATADCROne, /* always one bit*/ + mATADCRReset = 1 << bATADCRReset, /* Reset (1 = reset)*/ + mATADCRnIntEnable = 1 << bATADCRnIntEnable /* Interrupt Disable(0 = enabled)*/ +}; + + +/* 'ataRegMask' field of the ataRegAccess definition*/ +enum ataRegMask{ + + bATAAltSDevCValid = 14, /* bit number of alternate status/device cntrl valid bit*/ + bATAStatusCmdValid = 7, /* bit number of status/command valid bit*/ + bATASDHValid = 6, /* bit number of ataTFSDH valid bit*/ + bATACylinderHiValid = 5, /* bit number of cylinder high valid bit*/ + bATACylinderLoValid = 4, /* bit number of cylinder low valid bit*/ + bATASectorNumValid = 3, /* bit number of sector number valid bit*/ + bATASectorCntValid = 2, /* bit number of sector count valid bit*/ + bATAErrFeaturesValid = 1, /* bit number of error/features valid bit*/ + bATADataValid = 0, /* bit number of data valid bit*/ + mATAAltSDevCValid = 1 << bATAAltSDevCValid, /* alternate status/device control valid*/ + mATAStatusCmdValid = 1 << bATAStatusCmdValid, /* status/command valid*/ + mATASDHValid = 1 << bATASDHValid, /* ataTFSDH valid*/ + mATACylinderHiValid = 1 << bATACylinderHiValid, /* cylinder high valid*/ + mATACylinderLoValid = 1 << bATACylinderLoValid, /* cylinder low valid*/ + mATASectorNumValid = 1 << bATASectorNumValid, /* sector number valid*/ + mATASectorCntValid = 1 << bATASectorCntValid, /* sector count valid*/ + mATAErrFeaturesValid = 1 << bATAErrFeaturesValid, /* error/features valid*/ + mATADataValid = 1 << bATADataValid /* data valid*/ + +} ; + + +enum ataFlags{ + bATAFlagQuiesce = 20, + bATAFlagNoIRQ = 19, /* bit Number of no IRQ protocol flag*/ + bATAFlag48BitLBA = 18, + bATAFlagDMAQueued = 17, + bATAFlagOverlapped = 16, + bATAFlagUseConfigSpeed = 15, /* bit number of use configured speed flag*/ + bATAFlagByteSwap = 14, /* bit number of byte swap flag*/ + bATAFlagIORead = 13, /* bit number of I/O read flag*/ + bATAFlagIOWrite = 12, /* bit number of I/O write flag*/ + bATAFlagTFAccessResult = 8, /* bit number of get register results on command completion.*/ + bATAFlagUseDMA = 7, /* bit number of use DMA flag*/ + bATAFlagProtocolATAPI = 5, /* bit number of ATAPI protocol*/ + bATAFlagImmediate = 1, /* bit number of immediate flag */ + bATAFlagTFAccess = 0, /* bit number of TF access */ + + mATAFlagQuiesce = 1 << bATAFlagQuiesce, + mATAFlagUseNoIRQ = 1 << bATAFlagNoIRQ, /* Special purpose! Avoid using! No-IRQ, polled synchronous protocol valid only for PIO commands*/ + mATAFlag48BitLBA = 1 << bATAFlag48BitLBA, /* Use 48 bit extended LBA protocol on this command. Requires support from the controller.*/ + mATAFlagDMAQueued = 1 << bATAFlagDMAQueued, /* Use tagged dma queuing protocol on this command. Requires support from the controller.*/ + mATAFlagOverlapped = 1 << bATAFlagOverlapped, /* Use overllaped protocol on this command. Requires support from the controller.*/ + mATAFlagUseConfigSpeed = 1 << bATAFlagUseConfigSpeed, /* Use the configured interface speed = true. False = use default PIO (slow) speed. valid only for PIO commands*/ + mATAFlagByteSwap = 1 << bATAFlagByteSwap, /* Swap data bytes (read - after; write - before)*/ + mATAFlagIORead = 1 << bATAFlagIORead, /* Read (in) operation*/ + mATAFlagIOWrite = 1 << bATAFlagIOWrite, /* Write (out) operation*/ + mATAFlagTFAccessResult = 1 << bATAFlagTFAccessResult, /* get contents of TaskFile registers indicated in TFMask on command completion, even if no error*/ + mATAFlagUseDMA = 1 << bATAFlagUseDMA, + mATAFlagProtocolATAPI = 1 << bATAFlagProtocolATAPI, /* ATAPI protocol indicator*/ + mATAFlagImmediate = 1 << bATAFlagImmediate, /* Put command at head of queue */ + mATAFlagTFAccess = 1 << bATAFlagTFAccess, /* Return Taskfile on error status*/ + +} ; + +/* The Function codes sent to controllers*/ +enum ataOpcode { + + kATANoOp = 0, + kATAFnExecIO , /* Execute ATA I/O */ + kATAPIFnExecIO, /* ATAPI I/O */ + kATAFnRegAccess , /* Register Access */ + + kATAFnQFlush , /* I/O Queue flush requests for your unit number */ + kATAFnBusReset /* Reset ATA bus */ + +} ; + + +/* The ATA Event codes */ +/* sent when calling the device driver's event handler*/ +enum ataEventCode { + kATANullEvent = 0x00, /* Just kidding -- nothing happened*/ + kATAOnlineEvent = 0x01, /* An ATA device has come online*/ + kATAOfflineEvent = 0x02, /* An ATA device has gone offline*/ + kATARemovedEvent = 0x03, /* An ATA device has been removed from the bus*/ + kATAResetEvent = 0x04, /* Someone gave a hard reset to the drive*/ + kATAOfflineRequest = 0x05, /* Someone requesting to offline the drive*/ + kATAEjectRequest = 0x06, /* Someone requesting to eject the drive*/ + kATAPIResetEvent = 0x07, /* Someone gave a ATAPI reset to the drive*/ + kATAReservedEvent = 0x80 /* RESERVED*/ +}; + + +// These need to be combined with a new enumeration of the current ATA/ATAPI command set. +// Some opcodes are of interest to ATA controllers, since they imply special protocols +// or handling. Device Reset, Execute Device Diagnostics have subtle side effects that +// controllers need to be aware of, so we snoop for those commands being issued. +// the rest are here for informational purposes. + +// BUG make new enum for all current ATA commands. + +enum { + kSOFTRESET = 0x008, // ATAPI Soft Reset command + kPACKET = 0x0A0, // ATAPI Packet command + kID_DRIVE = 0x0A1 // ATAPI Identify drive command +}; +/* ATA Command Opcode definition*/ +enum { + kATAcmdWORetry = 0x01, /* Without I/O retry option*/ + kATAcmdNOP = 0x0000, /* NOP operation - media detect*/ + kATAcmdRecal = 0x0010, /* Recalibrate command */ + kATAcmdRead = 0x0020, /* Read command */ + kATAcmdReadLong = 0x0022, /* Read Long command*/ + kATAcmdReadExtended = 0x0024, /* Read Extended (with retries)*/ + kATAcmdReadDMAExtended = 0x0025, /* Read DMA Extended (with retries)*/ + kATAcmdWrite = 0x0030, /* Write command */ + kATAcmdWriteLong = 0x0032, /* Write Long*/ + kATAcmdWriteExtended = 0x0034, /* Write Extended (with retries)*/ + kATAcmdWriteDMAExtended = 0x0035, /* Write DMA Extended (with retries)*/ + kATAcmdWriteVerify = 0x003C, /* Write verify*/ + kATAcmdReadVerify = 0x0040, /* Read Verify command */ + kATAcmdFormatTrack = 0x0050, /* Format Track command */ + kATAcmdSeek = 0x0070, /* Seek command */ + kATAcmdDiagnostic = 0x0090, /* Drive Diagnostic command */ + kATAcmdInitDrive = 0x0091, /* Init drive parameters command */ + kATAcmdReadMultiple = 0x00C4, /* Read multiple*/ + kATAcmdWriteMultiple = 0x00C5, /* Write multiple*/ + kATAcmdSetRWMultiple = 0x00C6, /* Set Multiple for Read/Write Multiple*/ + kATAcmdReadDMA = 0x00C8, /* Read DMA (with retries)*/ + kATAcmdWriteDMA = 0x00CA, /* Write DMA (with retries)*/ + kATAcmdMCAcknowledge = 0x00DB, /* Acknowledge media change - removable*/ + kATAcmdDoorLock = 0x00DE, /* Door lock*/ + kATAcmdDoorUnlock = 0x00DF, /* Door unlock*/ + kATAcmdStandbyImmed = 0x00E0, /* Standby Immediate*/ + kATAcmdIdleImmed = 0x00E1, /* Idle Immediate*/ + kATAcmdStandby = 0x00E2, /* Standby*/ + kATAcmdIdle = 0x00E3, /* Idle*/ + kATAcmdReadBuffer = 0x00E4, /* Read sector buffer command */ + kATAcmdCheckPowerMode = 0x00E5, /* Check power mode command <04/04/94>*/ + kATAcmdSleep = 0x00E6, /* Sleep*/ + kATAcmdFlushCache = 0x00E7, /* Flush Cache */ + kATAcmdWriteBuffer = 0x00E8, /* Write sector buffer command */ + kATAcmdWriteSame = 0x00E9, /* Write same data to multiple sectors*/ + kATAcmdFlushCacheExtended = 0x00EA, /* Flush Cache Extended */ + kATAcmdDriveIdentify = 0x00EC, /* Identify Drive command */ + kATAcmdMediaEject = 0x00ED, /* Media Eject*/ + kATAcmdSetFeatures = 0x00EF /* Set Features*/ +}; + +/* Set feature command opcodes*/ +enum { + kATAEnableWriteCache = 0x02, /* Enable write cache*/ + kATASetTransferMode = 0x03, /* Set transfer mode*/ + kATAEnableAPM = 0x05, /* Enable Advanced Power Management*/ + kATASetPIOMode = 0x08, /* PIO Flow Control Tx Mode bit*/ + kATADisableWriteCache = 0x82, /* disable write cache*/ + kATAEnableReadAhead = 0xAA /* Read look-ahead enable*/ +}; + +// revisit the opcode enumerations. + +////////////////////// + + +/* task file for ata */ +typedef struct ataTaskFile { + + UInt8 ataTFFeatures; /* <-> Error(R) or ataTFFeatures(W) register image */ + UInt8 ataTFCount; /* <-> Sector count/remaining */ + UInt8 ataTFSector; /* <-> Sector start/finish */ + UInt8 ataTFCylLo; /* <-> ataTFCylLo */ + UInt8 ataTFCylHigh; /* <-> ataTFCylHigh */ + UInt8 ataTFSDH; /* <-> ataTFSDH register image*/ + UInt8 ataTFCommand; /* <-> Status(R) or Command(W) register image */ + +} ataTaskFile; + + +typedef struct ataRegisterImage { + + ataTaskFile taskFile; + UInt16 ataDataRegister; /* <-> Data register. */ + UInt8 ataAltSDevCReg; /* <->: Alternate status(R) or Device Control(W) register image*/ + +} ataRegisterImage ; + + +typedef struct ATAPICmdPacket{ + + UInt16 atapiPacketSize; /* Size of command packet in bytes */ + UInt16 atapiCommandByte[8]; /* The command packet itself*/ + +}ATAPICmdPacket; + + + +// Error and result codes: TBD +enum { + kATAErrUnknownType = -1, + kATANoErr = 0, + kATAQueueEmpty = 1, + kATAUnknownOpcode, + kATATimeoutErr, + kATAInvalidDevID, + kATAErrDevBusy, + kATAModeNotSupported, + kATADevIntNoCmd, + kATADeviceError, + kATADMAErr +}; + + +#endif /* !_IOATATYPES_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/ata/IOATABusInfo.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/ata/IOATABusInfo.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/ata/IOATABusInfo.h (revision 885) @@ -0,0 +1,219 @@ +/* + * Copyright (c) 2000-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 _IOATABUSINFO_H +#define _IOATABUSINFO_H + +#include <libkern/c++/OSObject.h> +#include <IOKit/IOTypes.h> +#include "IOATATypes.h" + +/*! +@class IOATABusInfo +@discussion used to indicate the capabilities of the bus the device is connected to, PIO and DMA modes supported, etc. +*/ + +class IOATABusInfo : public OSObject +{ + OSDeclareDefaultStructors( IOATABusInfo ); + + public: + + /*!@function atabusinfo + @abstract factory method + */ + static IOATABusInfo* atabusinfo(void); + + /*!@function zeroData + @abstract set this object to a blank state. + */ + virtual void zeroData(void); + + // Used by clients of ATAControllers to find out about the bus + // capability. + + /*!@function getSocketType + @abstract returns the socket type, internal fixed, media-bay, PC-Card + Used by clients of ATAControllers to find out about the bus + */ + ataSocketType getSocketType( void ); + + /*!@function getPIOModes + @abstract returns the bit-significant map of PIO mode(s) supported on the bus. + Used by clients of ATAControllers to find out about the bus. + */ + UInt8 getPIOModes( void ); + + /*!@function getDMAModes + @abstract bit-significant map of DMA mode(s) supported on the bus. + Used by clients of ATAControllers to find out about the bus. + */ + UInt8 getDMAModes( void ); + + /*!@function getUltraModes + @abstract bit-significant map of Ultra mode(s) supported on the bus. + Used by clients of ATAControllers to find out about the bus. + */ + UInt8 getUltraModes( void ); + + /*!@function getUnits + @abstract How many devices are present on bus. + Used by clients of ATAControllers to find out about the bus. + */ + UInt8 getUnits( void ); + + /*!@function supportsDMA + @abstract True = DMA supported on bus - inferred by looking at the DMA mode bits. + Used by clients of ATAControllers to find out about the bus. + */ + bool supportsDMA( void ); + + /*!@function supportsExtendedLBA + @abstract Supports 48-bit LBA if true. + Used by clients of ATAControllers to find out about the bus. + */ + bool supportsExtendedLBA( void ); + + /*!@function maxBlocksExtended + @abstract The maximum number of 512-byte blocks this controller supports + in a single Extended LBA transfer. Some controllers may be limited to less than + the maximum sector count allowed under extended LBA protocol. + */ + UInt16 maxBlocksExtended(void); + + /*!@function supportsOverlapped + @abstract Supports overlapped packet feature set if true. + Used by clients of ATAControllers to find out about the bus. + */ + bool supportsOverlapped( void ); + + /*!@function supportsDMAQueued + @abstract Supports DMA Queued Feature set if true. + Used by clients of ATAControllers to find out about the bus. + */ + bool supportsDMAQueued( void ); + + + // Used by ATAControllers to generate an information object. + // Would not be used by disk device drivers normally. + // Bus controllers should set these items everytime. + + /*!@function setSocketType + @abstract internal fixed, media-bay, PC-Card. Set by ATAControllers. + */ + void setSocketType( ataSocketType inSocketType ); + + /*!@function setPIOModes + @abstract Bit significant map of supported transfer modes. Set by ATAControllers. + */ + void setPIOModes( UInt8 inModeBitMap); + + /*!@function setDMAModes + @abstract Bit significant map of supported transfer modes. Set by ATAControllers. + */ + void setDMAModes( UInt8 inModeBitMap ); + + /*!@function setUltraModes + @abstract Bit significant map of supported transfer modes. Set by ATAControllers. + */ + void setUltraModes( UInt8 inModeBitMap ); + + /*!@function setUnits + @abstract set to indicate how many devices are on this bus. Set by ATAControllers. + */ + void setUnits( UInt8 inNumUnits ); + + // Optional bus protocols some busses may support + /*!@function setExtendedLBA + @abstract Set true for supports 48-bit LBA. Set by ATAControllers. + */ + void setExtendedLBA( bool inState ); + + /*!function setMaxBlocksExtended + @abstract value set by controllers to indicate the maximum number of blocks + allowed in a single transfer of data. Some dma engines may not be capable of supporting the full + 16-bit worth of sector count allowed under 48 bit extended LBA. Default is 256 blocks, same as + standard ATA. + */ + void setMaxBlocksExtended( UInt16 inMaxBlocks); + + /*!@function setOverlapped + @abstract Set true for supports overlapped packet feature set. Set by ATAControllers. + */ + void setOverlapped( bool inState); + + /*!@function setDMAQueued + @abstract Set true if supports DMA Queued Feature. Set by ATAControllers. + */ + void setDMAQueued( bool inState); // + + protected: + + UInt8 _PIOModes; /* PIO modes supported (bit-significant) */ + UInt8 _MultiDMAModes; /* <--: Multiword DMA modes supported (b-sig) */ + UInt8 _UltraDMAModes; /* <--: Ultra DMA modes supported (b-sig) */ + bool _ExtendedLBA; /* <--: Suppports 48-bit LBA protocol */ + bool _Overlapped; /* <--: Supports overlapped packet feature set */ + bool _DMAQueued; /* <--: Supports DMA Queued Feature set */ + ataSocketType _SocketType; /* <--: Indicates bus is fixed internal, removable media-bay, removable PC-Card or unknown type */ + UInt8 _numUnits; /* <--: How many devices on this bus */ + UInt16 _maxBlocksExtended; + + 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) */ + ExpansionData *reserved; + + virtual bool init(); + +private: + OSMetaClassDeclareReservedUnused(IOATABusInfo, 0); + OSMetaClassDeclareReservedUnused(IOATABusInfo, 1); + OSMetaClassDeclareReservedUnused(IOATABusInfo, 2); + OSMetaClassDeclareReservedUnused(IOATABusInfo, 3); + OSMetaClassDeclareReservedUnused(IOATABusInfo, 4); + OSMetaClassDeclareReservedUnused(IOATABusInfo, 5); + OSMetaClassDeclareReservedUnused(IOATABusInfo, 6); + OSMetaClassDeclareReservedUnused(IOATABusInfo, 7); + OSMetaClassDeclareReservedUnused(IOATABusInfo, 8); + OSMetaClassDeclareReservedUnused(IOATABusInfo, 9); + OSMetaClassDeclareReservedUnused(IOATABusInfo, 10); + OSMetaClassDeclareReservedUnused(IOATABusInfo, 11); + OSMetaClassDeclareReservedUnused(IOATABusInfo, 12); + OSMetaClassDeclareReservedUnused(IOATABusInfo, 13); + OSMetaClassDeclareReservedUnused(IOATABusInfo, 14); + OSMetaClassDeclareReservedUnused(IOATABusInfo, 15); + OSMetaClassDeclareReservedUnused(IOATABusInfo, 16); + OSMetaClassDeclareReservedUnused(IOATABusInfo, 17); + OSMetaClassDeclareReservedUnused(IOATABusInfo, 18); + OSMetaClassDeclareReservedUnused(IOATABusInfo, 19); + OSMetaClassDeclareReservedUnused(IOATABusInfo, 20); +}; + + +#endif /* !_IOATABUSINFO_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/ata/IOATARegI386.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/ata/IOATARegI386.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/ata/IOATARegI386.h (revision 885) @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2000-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 _IOATAREGI386_H +#define _IOATAREGI386_H + +#include <libkern/c++/OSObject.h> + +/* + * IOATAReg: ATA register abstract base class. + */ +#define DefineIOATAReg(w) \ +class IOATAReg##w : public OSObject \ +{ \ + OSDeclareAbstractStructors( IOATAReg##w ) \ + \ +public: \ + virtual void operator = (UInt##w rhs) = 0; \ + virtual operator UInt##w() const = 0; \ +} + +DefineIOATAReg( 8 ); +DefineIOATAReg( 16 ); +DefineIOATAReg( 32 ); + +typedef IOATAReg8 * IOATARegPtr8; +typedef IOATAReg16 * IOATARegPtr16; +typedef IOATAReg32 * IOATARegPtr32; + +#define IOATARegPtr8Cast(x) (x) + +/* + * IOATAIOReg: I/O mapped ATA registers. + */ +#define DefineIOATAIOReg(w) \ +class IOATAIOReg##w : public IOATAReg##w \ +{ \ + OSDeclareDefaultStructors( IOATAIOReg##w ) \ + \ +protected: \ + UInt16 _address; \ + \ +public: \ + static IOATAIOReg##w * withAddress( UInt16 address ); \ + \ + virtual bool initWithAddress( UInt16 address ); \ + virtual UInt16 getAddress() const; \ + \ + virtual void operator = (UInt##w rhs); \ + virtual operator UInt##w() const; \ +} + +DefineIOATAIOReg( 8 ); +DefineIOATAIOReg( 16 ); +DefineIOATAIOReg( 32 ); + +#endif /* !_IOATAREGI386_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/ata/IOATABusCommand.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/ata/IOATABusCommand.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/ata/IOATABusCommand.h (revision 885) @@ -0,0 +1,250 @@ +/* + * 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@ + */ + +/* + * + * IOATABusCommand.h + * + */ + +#ifndef _IOATABUSCOMMAND_H +#define _IOATABUSCOMMAND_H + +#include <IOKit/IOTypes.h> +#include "IOATATypes.h" +#include "IOATACommand.h" + + +class IOSyncer; + + +/*! + +@class IOATABusCommand + +@discussion ATA Device (disk) drivers should use the superclass, IOATACommand +and may not derive or use any subclass of IOATACommand. + +IOATABusCommand is the subclass of IOATACommand used by +IOATAControllers. Controller classes may override this class to +provide additional fields as their needs dictate or may use this +as a concrete class if it is sufficient. + +IOATAControllers are always paired with specific IOATADevices +and each specific subclass of IOATADevice is in turn the factory method +for IOATACommands for use by disk drivers. + +In this manner, mass-storage device drivers (disk drivers, clients of +ATA bus controllers) see only the generalized interface of IOATADevice +and the generalized interface of IOATACommand. This provides isolation +from specific bus details for disk drivers and offers flexibility to +controllers to add per-command fields and state variables for their own +internal use. + +*/ + +class IOATABusCommand : public IOATACommand { + + OSDeclareDefaultStructors( IOATABusCommand ); + + public: + + // data items for use by IOATAController + + /*! @var queueChain queue header for use by IOATAController. */ + queue_chain_t queueChain; + + /*! @var state state-semaphore for use by IOATAController */ + UInt32 state; + + /*! @var syncer IOSyncer for use by IOATAController */ + IOSyncer* syncer; + + + + /*!@function allocateCmd + @abstract factory method to create an instance of this class used by subclasses of IOATADevice + */ + static IOATABusCommand* allocateCmd(void); + + /*!@function zeroCommand + @abstract set to blank state, call prior to re-use of this object + */ + virtual void zeroCommand(void); + + /*!@function getOpcode + @abstract return the command opcode + */ + virtual ataOpcode getOpcode( void ); + + /*!@function getFlags + @abstract return the flags for this command. + */ + virtual ataFlags getFlags ( void ); + + /*!@function getRegMask + @abstract get the register mask for desired regs + */ + virtual ataRegMask getRegMask( void ); + + /*!@function getUnit + @abstract return the unit id (0 master, 1 slave) + */ + virtual ataUnitID getUnit( void ); + + /*!@function getTimeoutMS + @abstract return the timeout value for this command + */ + virtual UInt32 getTimeoutMS (void ); + + /*!@function setResult + @abstract set the result code + */ + virtual void setResult( IOReturn ); + + /*!@function getCallbackPtr + @abstract return the callback pointer + */ + virtual IOATACompletionFunction* getCallbackPtr (void ); + + + /*!@function executeCallback + @abstract call the completion callback function + */ + virtual void executeCallback(void); + + /*!@function getTaskFilePtr + @abstract return the taskfile structure pointer. + */ + virtual ataTaskFile* getTaskFilePtr(void); + + /*!@function getPacketSize + @abstract return the size of atapi packet if any. + */ + virtual UInt16 getPacketSize(void); + + /*!@function getPacketData + @abstract return pointer to the array of packet data. + */ + virtual UInt16* getPacketData(void); + + /*!@function getTransferChunkSize + @abstract number of bytes between interrupts. + */ + virtual IOByteCount getTransferChunkSize(void); + + /*!@function setActualTransfer + @abstract set the byte count of bytes actually transferred. + */ + virtual void setActualTransfer ( IOByteCount bytesTransferred ); + + /*!@function getBuffer + @abstract get pointer to the memory descriptor for this transaction + */ + virtual IOMemoryDescriptor* getBuffer ( void); + + /*!@function getPosition + @abstract the position within the memory buffer for the transaction. + */ + virtual IOByteCount getPosition (void); + + /*!@function getByteCount + @abstract return the byte count for this transaction to transfer. + */ + virtual IOByteCount getByteCount (void); + + /*!@function setCommandInUse + @abstract mark the command as being in progress. + */ + virtual void setCommandInUse( bool inUse = true); + + + protected: + + // + /*!@function init + @abstract Zeroes all data, returns false if allocation fails. protected. + */ + virtual bool init(); + +/*! @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) */ + ExpansionData *reserved; + +private: + OSMetaClassDeclareReservedUnused(IOATABusCommand, 0); + OSMetaClassDeclareReservedUnused(IOATABusCommand, 1); + OSMetaClassDeclareReservedUnused(IOATABusCommand, 2); + OSMetaClassDeclareReservedUnused(IOATABusCommand, 3); + OSMetaClassDeclareReservedUnused(IOATABusCommand, 4); + OSMetaClassDeclareReservedUnused(IOATABusCommand, 5); + OSMetaClassDeclareReservedUnused(IOATABusCommand, 6); + OSMetaClassDeclareReservedUnused(IOATABusCommand, 7); + OSMetaClassDeclareReservedUnused(IOATABusCommand, 8); + OSMetaClassDeclareReservedUnused(IOATABusCommand, 9); + OSMetaClassDeclareReservedUnused(IOATABusCommand, 10); + OSMetaClassDeclareReservedUnused(IOATABusCommand, 11); + OSMetaClassDeclareReservedUnused(IOATABusCommand, 12); + OSMetaClassDeclareReservedUnused(IOATABusCommand, 13); + OSMetaClassDeclareReservedUnused(IOATABusCommand, 14); + OSMetaClassDeclareReservedUnused(IOATABusCommand, 15); + OSMetaClassDeclareReservedUnused(IOATABusCommand, 16); + OSMetaClassDeclareReservedUnused(IOATABusCommand, 17); + OSMetaClassDeclareReservedUnused(IOATABusCommand, 18); + OSMetaClassDeclareReservedUnused(IOATABusCommand, 19); + OSMetaClassDeclareReservedUnused(IOATABusCommand, 20); +}; + +#include <IOKit/IODMACommand.h> + +class IOATABusCommand64 : public IOATABusCommand +{ + + OSDeclareDefaultStructors( IOATABusCommand64 ); + + public: + + // new features + static IOATABusCommand64* allocateCmd32(void); + virtual IODMACommand* GetDMACommand( void ); + + + + // overrides for IODMACommand setup + virtual void zeroCommand(void); + virtual void setBuffer ( IOMemoryDescriptor* inDesc); + virtual void setCommandInUse( bool inUse = true); + virtual void executeCallback(void); + + + protected: + IODMACommand* _dmaCmd; + virtual bool init(); + virtual void free(); +}; + +#endif /*_IOATABUSCOMMAND_H*/ Index: branches/azimutz/Cleancut/i386/include/IOKit/ndrvsupport/IONDRVLibraries.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/ndrvsupport/IONDRVLibraries.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/ndrvsupport/IONDRVLibraries.h (revision 885) @@ -0,0 +1,696 @@ + +#ifndef __IONDRVLIBRARIES__ +#define __IONDRVLIBRARIES__ + +#include <libkern/OSByteOrder.h> +#include <libkern/OSAtomic.h> +#include <IOKit/ndrvsupport/IOMacOSTypes.h> +#include <IOKit/graphics/IOGraphicsTypes.h> + + +#ifdef __cplusplus +extern "C" { +#endif + +/* NameRegistry error codes */ +enum { + nrLockedErr = -2536, + nrNotEnoughMemoryErr = -2537, + nrInvalidNodeErr = -2538, + nrNotFoundErr = -2539, + nrNotCreatedErr = -2540, + nrNameErr = -2541, + nrNotSlotDeviceErr = -2542, + nrDataTruncatedErr = -2543, + nrPowerErr = -2544, + nrPowerSwitchAbortErr = -2545, + nrTypeMismatchErr = -2546, + nrNotModifiedErr = -2547, + nrOverrunErr = -2548, + nrResultCodeBase = -2549, + nrPathNotFound = -2550, /* a path component lookup failed */ + nrPathBufferTooSmall = -2551, /* buffer for path is too small */ + nrInvalidEntryIterationOp = -2552, /* invalid entry iteration operation */ + nrPropertyAlreadyExists = -2553, /* property already exists */ + nrIterationDone = -2554, /* iteration operation is done */ + nrExitedIteratorScope = -2555, /* outer scope of iterator was exited */ + nrTransactionAborted = -2556, /* transaction was aborted */ + + gestaltUndefSelectorErr = -5551 /*undefined selector was passed to Gestalt*/ +}; + +enum { + kNVRAMProperty = 0x00000020, // matches NR +}; + + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#ifndef _IOKIT_IOSERVICE_H +typedef struct IOService IOService; +#endif + +IOReturn _IONDRVLibrariesInitialize( IOService * provider ); +IOReturn _IONDRVLibrariesFinalize( IOService * provider ); + +#ifndef kAAPLRegEntryIDKey +#define kAAPLRegEntryIDKey "AAPL,RegEntryID" +#endif + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +UInt32 EndianSwap32Bit( UInt32 data ); + +UInt16 EndianSwap16Bit( UInt16 data ); + +void SynchronizeIO(void); + +OSErr ExpMgrConfigReadLong( + RegEntryIDPtr node, + LogicalAddress configAddr, + UInt32 * valuePtr); + +OSErr ExpMgrConfigWriteLong( + RegEntryIDPtr node, + LogicalAddress configAddr, + UInt32 value); + +OSErr ExpMgrConfigReadWord( + RegEntryIDPtr node, + LogicalAddress configAddr, + UInt16 * valuePtr); + +OSErr ExpMgrConfigWriteWord( + RegEntryIDPtr node, + LogicalAddress configAddr, + UInt16 value); + +OSErr ExpMgrConfigReadByte( + RegEntryIDPtr node, + LogicalAddress configAddr, + UInt8 * valuePtr); + +OSErr ExpMgrConfigWriteByte( + RegEntryIDPtr node, + LogicalAddress configAddr, + UInt8 value); + +OSErr ExpMgrIOReadLong( + RegEntryIDPtr node, + LogicalAddress ioAddr, + UInt32 * valuePtr); + +OSErr ExpMgrIOWriteLong( + RegEntryIDPtr node, + LogicalAddress ioAddr, + UInt32 value); + +OSErr ExpMgrIOReadWord( + RegEntryIDPtr node, + LogicalAddress ioAddr, + UInt16 * valuePtr); + +OSErr ExpMgrIOWriteWord( + RegEntryIDPtr node, + LogicalAddress ioAddr, + UInt16 value); + +OSErr ExpMgrIOReadByte( + RegEntryIDPtr node, + LogicalAddress ioAddr, + UInt8 * valuePtr); + +OSErr ExpMgrIOWriteByte( + RegEntryIDPtr node, + LogicalAddress ioAddr, + UInt8 value); + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/******************************************************************************* + * + * Foundation Types + * + */ +/* Value of a property */ +typedef void * RegPropertyValue; +/* Length of property value */ +typedef UInt32 RegPropertyValueSize; + +/*******************************************************************************/ + +/******************************************************************************* + * + * Root Entry Name Definitions (Applies to all Names in the RootNameSpace) + * + * + Names are a colon-separated list of name components. Name components + * may not themselves contain colons. + * + Names are presented as null-terminated ASCII character strings. + * + Names follow similar parsing rules to Apple file system absolute + * and relative paths. However the '::' parent directory syntax is + * not currently supported. + */ +/* Max length of Entry Name */ +enum { + kRegCStrMaxEntryNameLength = 47 +}; + +/* Entry Names are single byte ASCII */ +typedef char RegCStrEntryName; +typedef char * RegCStrEntryNamePtr; +/* length of RegCStrEntryNameBuf = kRegCStrMaxEntryNameLength+1*/ +typedef char RegCStrEntryNameBuf[48]; +typedef char RegCStrPathName; +typedef UInt32 RegPathNameSize; +enum { + kRegPathNameSeparator = ':', /* 0x3A */ + kRegEntryNameTerminator = 0x00, /* '\0' */ + kRegPathNameTerminator = 0x00 /* '\0' */ +}; + +/******************************************************************************* + * + * Property Name and ID Definitions + * (Applies to all Properties Regardless of NameSpace) + */ +enum { + kRegMaximumPropertyNameLength = 31, /* Max length of Property Name */ + kRegPropertyNameTerminator = 0x00 /* '\0' */ +}; + +typedef char RegPropertyNameBuf[32]; +typedef char RegPropertyName; +typedef char * RegPropertyNamePtr; +enum { + kRegMaxPropertyNameLength = kRegMaximumPropertyNameLength +}; + +/******************************************************************************* + * + * Iteration Operations + * + * These specify direction when traversing the name relationships + */ +typedef UInt32 RegIterationOp; +typedef RegIterationOp RegEntryIterationOp; +enum { + /* Absolute locations*/ + kRegIterRoot = 0x00000002, /* "Upward" Relationships */ + kRegIterParents = 0x00000003, /* include all parent(s) of entry */ + /* "Downward" Relationships*/ + kRegIterChildren = 0x00000004, /* include all children */ + kRegIterSubTrees = 0x00000005, /* include all sub trees of entry */ + kRegIterDescendants = 0x00000005, /* include all descendants of entry */ + /* "Horizontal" Relationships */ + kRegIterSibling = 0x00000006, /* include all siblings */ + /* Keep doing the same thing*/ + kRegIterContinue = 0x00000001 +}; + +/******************************************************************************* + * + * Name Entry and Property Modifiers + * + * + * + * Modifiers describe special characteristics of names + * and properties. Modifiers might be supported for + * some names and not others. + * + * Device Drivers should not rely on functionality + * specified as a modifier. + */ +typedef UInt32 RegModifiers; +typedef RegModifiers RegEntryModifiers; +typedef RegModifiers RegPropertyModifiers; +enum { + kRegNoModifiers = 0x00000000, /* no entry modifiers in place */ + kRegUniversalModifierMask = 0x0000FFFF, /* mods to all entries */ + kRegNameSpaceModifierMask = 0x00FF0000, /* mods to all entries within namespace */ + kRegModifierMask = (RegModifiers)0xFF000000 /* mods to just this entry */ +}; + +/* Universal Property Modifiers */ +enum { + kRegPropertyValueIsSavedToNVRAM = 0x00000020, /* property is non-volatile (saved in NVRAM) */ + kRegPropertyValueIsSavedToDisk = 0x00000040 /* property is non-volatile (saved on disk) */ +}; + +typedef size_t Size; + +#ifndef _IOKIT_IOREGISTRYENTRY_H +typedef struct IORegistryIterator IORegistryIterator; +typedef struct OSIterator OSIterator; +#endif /* _IOKIT_IOREGISTRYENTRY_H */ +typedef IORegistryIterator * RegEntryIter; +typedef OSIterator * RegPropertyIter; + +OSStatus RegistryEntryIDCopy( const RegEntryID * entryID, RegEntryID * to ); + +OSStatus RegistryEntryIDInit( RegEntryID * entryID ); + +Boolean RegistryEntryIDCompare( const RegEntryID * id1, const RegEntryID * id2); + +OSStatus RegistryPropertyGetSize( + const RegEntryID * entryID, + const RegPropertyName * propertyName, + RegPropertyValueSize * propertySize); + +OSStatus RegistryPropertyGet( + const RegEntryID * entryID, + const RegPropertyName * propertyName, + void * propertyValue, + RegPropertyValueSize * propertySize); + +OSStatus RegistryPropertyCreate( + const RegEntryID * entryID, + const RegPropertyName * propertyName, + const void * propertyValue, + RegPropertyValueSize propertySize); + +OSStatus RegistryPropertyDelete( + const RegEntryID * entryID, + const RegPropertyName * propertyName); + +OSStatus RegistryPropertySet( + const RegEntryID * entryID, + const RegPropertyName * propertyName, + const void * propertyValue, + RegPropertyValueSize propertySize); + +OSStatus RegistryPropertyGetMod( + const RegEntryID * entry, + const RegPropertyName * name, + RegPropertyModifiers * modifiers); + +OSStatus RegistryPropertySetMod( + const RegEntryID * entry, + const RegPropertyName * name, + RegPropertyModifiers modifiers); + +OSStatus RegistryPropertyIterateCreate( + const RegEntryID * entry, + RegPropertyIter * cookie); + +OSStatus RegistryPropertyIterateDispose( RegPropertyIter * cookie); + +OSStatus RegistryPropertyIterate( + RegPropertyIter * cookie, + RegPropertyName * foundProperty, + Boolean * done); + +OSStatus RegistryEntryIterateCreate( RegEntryIter * cookie); + +OSStatus RegistryEntryIterateDispose( RegEntryIter * cookie); + +OSStatus RegistryEntryIterateSet( RegEntryIter * cookie, + const RegEntryID * startEntryID); + +OSStatus RegistryEntryIterate( RegEntryIter * cookie, + RegEntryIterationOp relationship, + RegEntryID * foundEntry, + Boolean * done); + +OSStatus RegistryCStrEntryToName( const RegEntryID * entryID, + RegEntryID * parentEntry, + RegCStrEntryName * nameComponent, + Boolean * done ); + +OSStatus RegistryCStrEntryLookup( const RegEntryID * parentEntry, + const RegCStrPathName * path, + RegEntryID * newEntry); + +OSStatus RegistryCStrEntryCreate( const RegEntryID * parentEntry, + const RegCStrPathName * name, + RegEntryID * newEntry); + +OSStatus RegistryEntryDelete(const RegEntryID * entryID); + +OSStatus RegistryEntryIDDispose(RegEntryID * entryID); + +// + +OSStatus RegistryEntryCopy( + RegEntryID * parentEntryID, + RegEntryID * sourceDevice, + RegEntryID * destDevice); + +OSStatus RegistryEntrySearch( + RegEntryIter * cookie, + RegEntryIterationOp relationship, + RegEntryID * foundEntry, + Boolean * done, + const RegPropertyName * propertyName, + const void * propertyValue, + RegPropertyValueSize propertySize); + +OSStatus RegistryEntryToPathSize( + const RegEntryID * entryID, + RegPathNameSize * pathSize); + +OSStatus RegistryCStrEntryToPath( + const RegEntryID * entryID, + RegCStrPathName * pathName, + RegPathNameSize pathSize); + +OSStatus RegistryPropertyRename( + const RegEntryID * entry, + const RegPropertyName * oldName, + const RegPropertyName * newName); + +OSStatus RegistryEntryGetMod( + const RegEntryID * entry, + RegEntryModifiers * modifiers); + +OSStatus RegistryEntrySetMod( + const RegEntryID * entry, + RegEntryModifiers modifiers); + +OSStatus RegistryEntryMod( + RegEntryIter * cookie, + RegEntryIterationOp relationship, + RegEntryID * foundEntry, + Boolean * done, + RegEntryModifiers matchingModifiers); + +OSStatus RegistryEntryPropertyMod( + RegEntryIter * cookie, + RegEntryIterationOp relationship, + RegEntryID * foundEntry, + Boolean * done, + RegPropertyModifiers matchingModifiers); + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +void SynchronizeIO(void); + +Boolean CompareAndSwap( + UInt32 oldVvalue, + UInt32 newValue, + UInt32 * OldValueAdr); + +UInt32 CStrLen(const char * src); + +char * CStrCopy( char * dst, const char * src); + +SInt16 CStrCmp( + const char * s1, + const char * s2); + +char * CStrCat( + char * dst, + const char * src); +char * CStrNCopy( + char * dst, + const char * src, + UInt32 max); +SInt16 CStrNCmp( + const char * s1, + const char * s2, + UInt32 max); +char * CStrNCat( + char * dst, + const char * src, + UInt32 max); + +void BlockCopy( + const void * srcPtr, + void * destPtr, + Size byteCount); +void BlockMove( + const void * srcPtr, + void * destPtr, + Size byteCount); +void BlockMoveData( + const void * srcPtr, + void * destPtr, + Size byteCount); +void BlockMoveDataUncached( + const void * srcPtr, + void * destPtr, + Size byteCount); +void BlockMoveUncached( + const void * srcPtr, + void * destPtr, + Size byteCount); +void BlockZero( + const void * srcPtr, + Size byteCount); +void BlockZeroUncached( + const void * srcPtr, + Size byteCount); + +char * PStrCopy( char *to, const char *from ); + +void PStrToCStr( char *to, const char *from ); + +void CStrToPStr( char *to, const char *from ); + +LogicalAddress PoolAllocateResident(ByteCount byteSize, Boolean clear); + +OSStatus PoolDeallocate( LogicalAddress address ); + +UInt32 CurrentExecutionLevel(void); + +UnsignedWide UpTime( void ); + +UnsignedWide AddAbsoluteToAbsolute(UnsignedWide left, UnsignedWide right); + +UnsignedWide SubAbsoluteFromAbsolute(UnsignedWide left, UnsignedWide right); + +UnsignedWide DurationToAbsolute( Duration theDuration); + +UnsignedWide AddDurationToAbsolute( Duration duration, UnsignedWide absolute ); + +UnsignedWide NanosecondsToAbsolute ( UnsignedWide theNanoseconds); + +UnsignedWide AbsoluteToNanoseconds( UnsignedWide absolute ); + +Duration AbsoluteDeltaToDuration( UnsignedWide left, UnsignedWide right ); + +Duration AbsoluteToDuration( UnsignedWide result ); + +OSStatus DelayForHardware( UnsignedWide time ); + +OSStatus DelayUntil( UnsignedWide time ); + +OSStatus DelayFor( Duration theDuration ); + +void SysDebugStr( const char * from ); + +void SysDebug( void ); + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +enum { + paramErr = -50, /*error in user parameter list*/ + noHardwareErr = -200, /*Sound Manager Error Returns*/ + notEnoughHardwareErr = -201, /*Sound Manager Error Returns*/ + userCanceledErr = -128, + qErr = -1, /*queue element not found during deletion*/ + vTypErr = -2, /*invalid queue element*/ + corErr = -3, /*core routine number out of range*/ + unimpErr = -4, /*unimplemented core routine*/ + SlpTypeErr = -5, /*invalid queue element*/ + seNoDB = -8, /*no debugger installed to handle debugger command*/ + controlErr = -17, /*I/O System Errors*/ + statusErr = -18, /*I/O System Errors*/ + readErr = -19, /*I/O System Errors*/ + writErr = -20, /*I/O System Errors*/ + badUnitErr = -21, /*I/O System Errors*/ + unitEmptyErr = -22, /*I/O System Errors*/ + openErr = -23, /*I/O System Errors*/ + closErr = -24, /*I/O System Errors*/ + dRemovErr = -25, /*tried to remove an open driver*/ + dInstErr = -26, /*DrvrInstall couldn't find driver in resources*/ + + badCksmErr = -69, /*addr mark checksum didn't check*/ +}; +enum { + durationMicrosecond = -1, /* Microseconds are negative*/ + durationMillisecond = 1, /* Milliseconds are positive*/ + durationSecond = 1000, /* 1000 * durationMillisecond*/ + durationMinute = 60000, /* 60 * durationSecond,*/ + durationHour = 3600000, /* 60 * durationMinute,*/ + durationDay = 86400000, /* 24 * durationHour,*/ + durationNoWait = 0, /* don't block*/ + durationForever = 0x7FFFFFFF /* no time limit*/ +}; +#ifndef NULL + #if !defined(__cplusplus) && (defined(__SC__) || defined(THINK_C)) + /* Symantec C compilers (but not C++) want NULL and nil to be (void*)0 */ + #define NULL ((void *) 0) + #else + /* in case int is 16-bits, make sure NULL is 32-bits */ + #define NULL 0L + #endif +#endif + +#ifndef nil + #define nil NULL +#endif + +typedef ResType VSLGestaltType; + +enum { + clutType = 0, /*0 if lookup table*/ + fixedType = 1, /*1 if fixed table*/ + directType = 2, /*2 if direct values*/ + RGBDirect = 16 /* 16 & 32 bits/pixel pixelType value */ +}; +typedef UInt32 * UInt32Ptr; + +typedef struct IOHardwareCursorDescriptor HardwareCursorDescriptorRec; +typedef HardwareCursorDescriptorRec * HardwareCursorDescriptorPtr; +typedef struct IOHardwareCursorInfo HardwareCursorInfoRec; +typedef HardwareCursorInfoRec * HardwareCursorInfoPtr; + +typedef ResType InterruptServiceType; +typedef struct _VSLService * InterruptServiceIDType; +typedef InterruptServiceIDType * InterruptServiceIDPtr; + +enum { + kVBLInterruptServiceType = 'vbl ', + kHBLInterruptServiceType = 'hbl ', + kFrameInterruptServiceType = 'fram', + kConnectInterruptServiceType = 'dci ', /* Renamed -- Use kFBCheckInterruptServiceType*/ + kFBConnectInterruptServiceType = kConnectInterruptServiceType, /* Demand to check configuration (Hardware unchanged)*/ + kFBChangedInterruptServiceType = 'chng', /* Demand to rebuild (Hardware has reinitialized on dependent change)*/ + kFBOfflineInterruptServiceType = 'remv', /* Demand to remove framebuffer (Hardware not available on dependent change -- but must not buserror)*/ + kFBOnlineInterruptServiceType = 'add ' /* Notice that hardware is available (after being removed)*/ +}; + +enum { + kVSLClamshellStateGestaltType = 'clam', +}; + +OSStatus +VSLGestalt( VSLGestaltType selector, UInt32 * response ); + +OSStatus +VSLSetDisplayConfiguration(RegEntryID * entryID, + RegPropertyName * propertyName, + RegPropertyValue configData, + RegPropertyValueSize configDataSize); +OSErr +VSLNewInterruptService( + RegEntryID * serviceDevice, + InterruptServiceType serviceType, + InterruptServiceIDPtr serviceID); + +OSErr +VSLWaitOnInterruptService( + InterruptServiceIDType serviceID, + Duration timeout); + +OSErr +VSLDisposeInterruptService(InterruptServiceIDType serviceID); + +OSErr +VSLDoInterruptService(InterruptServiceIDType serviceID); + +Boolean +VSLPrepareCursorForHardwareCursor( + void * cursorRef, + IOHardwareCursorDescriptor * hardwareDescriptor, + IOHardwareCursorInfo * hwCursorInfo); + +typedef UnsignedWide Nanoseconds; +enum { + /* Version Release Stage Codes */ + developStage = 0x20, + alphaStage = 0x40, + betaStage = 0x60, + finalStage = 0x80 +}; + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +typedef struct OpaqueIOCommandID* IOCommandID; + +typedef UInt32 IOCommandKind; +typedef UInt32 IOCommandCode; + +OSErr IOCommandIsComplete( IOCommandID commandID, OSErr result); + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#ifndef __IONDRV__ +typedef struct OpaqueInterruptSetID* InterruptSetID; +#else +typedef class IONDRVInterruptSet * InterruptSetID; +#endif /* __IONDRV__ */ + +typedef long InterruptMemberNumber; +struct InterruptSetMember { + InterruptSetID setID; + InterruptMemberNumber member; +}; +typedef struct InterruptSetMember InterruptSetMember; +enum { + kISTChipInterruptSource = 0, + kISTOutputDMAInterruptSource = 1, + kISTInputDMAInterruptSource = 2, + kISTPropertyMemberCount = 3 +}; + +typedef InterruptSetMember ISTProperty[3]; +#define kISTPropertyName "driver-ist" + +typedef long InterruptReturnValue; +enum { + kFirstMemberNumber = 1, + kIsrIsComplete = 0, + kIsrIsNotComplete = -1, + kMemberNumberParent = -2 +}; + +typedef Boolean InterruptSourceState; +enum { + kSourceWasEnabled = true, + kSourceWasDisabled = false +}; + +typedef InterruptMemberNumber (*InterruptHandler) (InterruptSetMember ISTmember, void *refCon, UInt32 theIntCount); +typedef void (*InterruptEnabler) (InterruptSetMember ISTmember, void *refCon); +typedef InterruptSourceState (*InterruptDisabler)(InterruptSetMember ISTmember, void *refCon); + +enum { + kReturnToParentWhenComplete = 0x00000001, + kReturnToParentWhenNotComplete = 0x00000002 +}; + +typedef OptionBits InterruptSetOptions; + + +OSStatus GetInterruptFunctions( + InterruptSetID setID, + InterruptMemberNumber member, + void ** refCon, + InterruptHandler * handlerFunction, + InterruptEnabler * enableFunction, + InterruptDisabler * disableFunction); + +OSStatus InstallInterruptFunctions( + InterruptSetID setID, + InterruptMemberNumber member, + void * refCon, + InterruptHandler handlerFunction, + InterruptEnabler enableFunction, + InterruptDisabler disableFunction); + +OSStatus CreateInterruptSet( + InterruptSetID parentSet, + InterruptMemberNumber parentMember, + InterruptMemberNumber setSize, + InterruptSetID * setID, + InterruptSetOptions options); + +OSStatus DeleteInterruptSet( InterruptSetID setID ); + + +#ifdef __cplusplus +} +#endif + +#endif /* __IONDRVLIBRARIES__ */ + Index: branches/azimutz/Cleancut/i386/include/IOKit/ndrvsupport/IONDRVSupport.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/ndrvsupport/IONDRVSupport.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/ndrvsupport/IONDRVSupport.h (revision 885) @@ -0,0 +1,95 @@ +/* + * 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 __IONDRVSUPPORT__ +#define __IONDRVSUPPORT__ + +#include <libkern/OSTypes.h> + +#ifndef __LP64__ +#pragma options align=mac68k +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define kIONDRVIgnoreKey "AAPL,iokit-ignore-ndrv" +#define kIONDRVForXKey "AAPL,iokit-ndrv" + +struct IOTVector { + void * pc; + UInt32 toc; +}; +typedef struct IOTVector IOTVector; + +struct IONDRVInterruptSetMember { + void * setID; + UInt32 member; +}; +typedef struct IONDRVInterruptSetMember IONDRVInterruptSetMember; + +typedef SInt32 (*IONDRVInterruptHandler)( IONDRVInterruptSetMember setMember, void *refCon, UInt32 theIntCount); +typedef void (*IONDRVInterruptEnabler)( IONDRVInterruptSetMember setMember, void *refCon); +typedef Boolean (*IONDRVInterruptDisabler)( IONDRVInterruptSetMember setMember, void *refCon); + +enum { + kIONDRVFirstMemberNumber = 1, + kIONDRVIsrIsComplete = 0, + kIONDRVIsrIsNotComplete = -1, + kIONDRVMemberNumberParent = -2 +}; + +enum { + kIONDRVReturnToParentWhenComplete = 0x00000001, + kIONDRVReturnToParentWhenNotComplete = 0x00000002 +}; + +enum { + kIONDRVISTChipInterruptSource = 0, + kIONDRVISTOutputDMAInterruptSource = 1, + kIONDRVISTInputDMAInterruptSource = 2, + kIONDRVISTPropertyMemberCount = 3 +}; + +#define kIONDRVISTPropertyName "driver-ist" + +IOReturn +IONDRVInstallInterruptFunctions(void * setID, + UInt32 member, + void * refCon, + IOTVector * handler, + IOTVector * enabler, + IOTVector * disabler ); + +typedef const IOTVector * (*IONDRVUndefinedSymbolHandler)( void * self, + const char * libraryName, const char * symbolName ); + +#ifndef __LP64__ +#pragma options align=reset +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* __IONDRVSUPPORT__ */ Index: branches/azimutz/Cleancut/i386/include/IOKit/ndrvsupport/IOMacOSTypes.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/ndrvsupport/IOMacOSTypes.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/ndrvsupport/IOMacOSTypes.h (revision 885) @@ -0,0 +1,441 @@ +/* + * 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@ + */ +/* + * Copyright (c) 1997 Apple Computer, Inc. + * + * + * HISTORY + * + * sdouglas 22 Oct 97 - first checked in. + * sdouglas 21 July 98 - start IOKit + */ + +/* + File: Types.h + + Contains: Basic Macintosh data types. + + Version: Technology: PowerSurge 1.0.2. + Package: Universal Interfaces 2.1.2 on ETO #20 + + Copyright: � 1984-1995 by Apple Computer, Inc. + All rights reserved. + + Bugs?: If you find a problem with this file, use the Apple Bug Reporter + stack. Include the file and version information (from above) + in the problem description and send to: + Internet: apple.bugs@applelink.apple.com + AppleLink: APPLE.BUGS + +*/ + +#ifndef _IOKIT_IOMACOSTYPES_H +#define _IOKIT_IOMACOSTYPES_H +#ifndef __MACTYPES__ + +#include <IOKit/IOTypes.h> + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __LP64__ +#pragma options align=mac68k +#endif + +#ifndef NULL +#if !defined(__cplusplus) && (defined(__SC__) || defined(THINK_C)) +#define NULL ((void *) 0) +#else +#define NULL 0 +#endif +#endif + +enum { + noErr = 0 +}; + +typedef uintptr_t KernelProcessID; +typedef uintptr_t AddressSpaceID; + +#if 0 +#ifndef __cplusplus +enum { false, true }; +#endif +#endif + +typedef unsigned char Byte; + +typedef signed char SignedByte; + +typedef UInt16 UniChar; + +typedef char *Ptr; + +typedef Ptr *Handle; + +typedef UInt32 Fixed; + +typedef Fixed *FixedPtr; + +typedef UInt32 Fract; + +typedef Fract *FractPtr; + +struct _extended80 { + short exp; + short man[4]; +}; +struct _extended96 { + short exp[2]; + short man[4]; +}; +typedef struct wide *WidePtr; + +typedef struct UnsignedWide *UnsignedWidePtr; + + +/* +enum { + false, + true +}; +#if !__option(bool) + #ifndef true + #define true 1 + #endif + #ifndef false + #define false 0 + #endif +#endif + +typedef unsigned char Boolean; +*/ + + +typedef short OSErr; + +typedef unsigned int FourCharCode; + +typedef FourCharCode OSType; + +typedef FourCharCode ResType; + +typedef OSType *OSTypePtr; + +typedef ResType *ResTypePtr; + +struct Rect { + short top; + short left; + short bottom; + short right; +}; +typedef struct Rect Rect; + +typedef Rect *RectPtr; + +// Quickdraw.i + +/* + kVariableLengthArray is used in array bounds to specify a variable length array. + It is ususally used in variable length structs when the last field is an array + of any size. Before ANSI C, we used zero as the bounds of variable length + array, but that is illegal in ANSI C. Example: + + struct FooList + { + short listLength; + Foo elements[kVariableLengthArray]; + }; +*/ + +enum { + kVariableLengthArray = 1 +}; + +/* Numeric version part of 'vers' resource */ +struct NumVersion { + UInt8 majorRev; /*1st part of version number in BCD*/ + UInt8 minorAndBugRev; /*2nd & 3rd part of version number share a byte*/ + UInt8 stage; /*stage code: dev, alpha, beta, final*/ + UInt8 nonRelRev; /*revision level of non-released version*/ +}; +typedef struct NumVersion NumVersion; + +typedef struct OpaqueRef *KernelID; + +typedef UInt8 *BytePtr; + +typedef IOByteCount ByteCount; + +typedef IOItemCount ItemCount; + +typedef void *LogicalAddress; + +#if !defined(__LP64__) +typedef void *PhysicalAddress; +#endif + +typedef UInt32 PBVersion; + +typedef SInt32 Duration; + +#define kInvalidID 0 + +enum { + kNilOptions = 0 +}; + + +typedef unsigned char Str31[32]; + + +/* +From: + File: DriverFamilyMatching.i <18> + Copyright: � 1995-1996 by Apple Computer, Inc., all rights reserved. +*/ + +//############################################## +// Well known properties in the Name Registry +//############################################## + +#define kPropertyName "name" +#define kPropertyCompatible "compatible" +#define kPropertyDriverPtr "driver-ptr" +#define kPropertyDriverDesc "driver-description" +#define kPropertyReg "reg" +#define kPropertyAAPLAddress "AAPL,address" +#define kPropertyMatching "matching" + + +//######################################################### +// Descriptor for Drivers and NDRVs +//######################################################### +/* Driver Typing Information Used to Match Drivers With Devices */ +struct DriverType { + Str31 nameInfoStr; /* Driver Name/Info String*/ + NumVersion version; /* Driver Version Number*/ +}; +typedef struct DriverType DriverType; +typedef DriverType * DriverTypePtr; + +/* OS Runtime Information Used to Setup and Maintain a Driver's Runtime Environment */ +typedef OptionBits RuntimeOptions; + + +enum { + kDriverIsLoadedUponDiscovery = 0x00000001, /* auto-load driver when discovered*/ + kDriverIsOpenedUponLoad = 0x00000002, /* auto-open driver when loaded*/ + kDriverIsUnderExpertControl = 0x00000004, /* I/O expert handles loads/opens*/ + kDriverIsConcurrent = 0x00000008, /* supports concurrent requests*/ + kDriverQueuesIOPB = 0x00000010, /* device manager doesn't queue IOPB*/ + kDriverIsLoadedAtBoot = 0x00000020, /* Driver is loaded at the boot time */ + kDriverIsForVirtualDevice = 0x00000040, /* Driver is for a virtual Device */ + kDriverSupportDMSuspendAndResume = 0x00000080 /* Driver supports Device Manager Suspend and Resume command */ +}; + +struct DriverOSRuntime { + RuntimeOptions driverRuntime; /* Options for OS Runtime*/ + Str31 driverName; /* Driver's name to the OS*/ + UInt32 driverDescReserved[8]; /* Reserved area*/ +}; +typedef struct DriverOSRuntime DriverOSRuntime; +typedef DriverOSRuntime * DriverOSRuntimePtr; + +/* OS Service Information Used To Declare What APIs a Driver Supports */ +typedef UInt32 ServiceCount; + +struct DriverServiceInfo { + OSType serviceCategory; /* Service Category Name*/ + OSType serviceType; /* Type within Category*/ + NumVersion serviceVersion; /* Version of service*/ +}; +typedef struct DriverServiceInfo DriverServiceInfo; +typedef DriverServiceInfo * DriverServiceInfoPtr; + +struct DriverOSService { + ServiceCount nServices; /* Number of Services Supported*/ + DriverServiceInfo service[1]; /* The List of Services (at least one)*/ +}; +typedef struct DriverOSService DriverOSService; +typedef DriverOSService * DriverOSServicePtr; + +/* Categories */ + +enum { + kServiceCategoryDisplay = 'disp', /* Display Manager*/ + kServiceCategoryOpenTransport = 'otan', /* Open Transport*/ + kServiceCategoryBlockStorage = 'blok', /* Block Storage*/ + kServiceCategoryNdrvDriver = 'ndrv', /* Generic Native Driver*/ + kServiceCategoryScsiSIM = 'scsi', /* SCSI */ + kServiceCategoryFileManager = 'file', /* File Manager */ + kServiceCategoryIDE = 'ide-', /* ide */ + kServiceCategoryADB = 'adb-', /* adb */ + kServiceCategoryPCI = 'pci-', /* pci bus */ + /* Nu Bus */ + kServiceCategoryDFM = 'dfm-', /* DFM */ + kServiceCategoryMotherBoard = 'mrbd', /* mother Board */ + kServiceCategoryKeyboard = 'kybd', /* Keyboard */ + kServiceCategoryPointing = 'poit', /* Pointing */ + kServiceCategoryRTC = 'rtc-', /* RTC */ + kServiceCategoryNVRAM = 'nram', /* NVRAM */ + kServiceCategorySound = 'sond', /* Sound (1/3/96 MCS) */ + kServiceCategoryPowerMgt = 'pgmt', /* Power Management */ + kServiceCategoryGeneric = 'genr' /* Generic Service Category to receive general Events */ +}; + +/* Ndrv ServiceCategory Types */ +enum { + kNdrvTypeIsGeneric = 'genr', /* generic*/ + kNdrvTypeIsVideo = 'vido', /* video*/ + kNdrvTypeIsBlockStorage = 'blok', /* block storage*/ + kNdrvTypeIsNetworking = 'netw', /* networking*/ + kNdrvTypeIsSerial = 'serl', /* serial*/ + kNdrvTypeIsParallel = 'parl', /* parallel */ + kNdrvTypeIsSound = 'sond', /* sound*/ + kNdrvTypeIsBusBridge = 'brdg' +}; + +typedef UInt32 DriverDescVersion; + +/* The Driver Description */ +enum { + kInitialDriverDescriptor = 0, + kVersionOneDriverDescriptor = 1 +}; + +enum { + kTheDescriptionSignature = 'mtej', + kDriverDescriptionSignature = 'pdes' +}; + + +struct DriverDescription { + OSType driverDescSignature; /* Signature field of this structure*/ + DriverDescVersion driverDescVersion; /* Version of this data structure*/ + DriverType driverType; /* Type of Driver*/ + DriverOSRuntime driverOSRuntimeInfo; /* OS Runtime Requirements of Driver*/ + DriverOSService driverServices; /* Apple Service API Membership*/ +}; +typedef struct DriverDescription DriverDescription; +typedef DriverDescription * DriverDescriptionPtr; + + +#ifndef __LP64__ +#pragma options align=reset +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* __MACTYPES__ */ + +#ifndef __QUICKDRAW__ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __LP64__ +#pragma options align=mac68k +#endif + +struct RGBColor { + unsigned short red; /*magnitude of red component*/ + unsigned short green; /*magnitude of green component*/ + unsigned short blue; /*magnitude of blue component*/ +}; +typedef struct RGBColor RGBColor; +typedef RGBColor *RGBColorPtr; +typedef RGBColorPtr *RGBColorHdl; + +struct ColorSpec { + short value; /*index or other value*/ + RGBColor rgb; /*true color*/ +}; + +typedef struct ColorSpec ColorSpec; +typedef ColorSpec *ColorSpecPtr; + +struct GammaTbl { + short gVersion; /*gamma version number*/ + short gType; /*gamma data type*/ + short gFormulaSize; /*Formula data size*/ + short gChanCnt; /*number of channels of data*/ + short gDataCnt; /*number of values/channel*/ + short gDataWidth; /*bits/corrected value (data packed to next larger byte size)*/ + short gFormulaData[1]; /*data for formulas followed by gamma values*/ +}; +typedef struct GammaTbl GammaTbl; +typedef GammaTbl *GammaTblPtr; + +struct RegEntryID +{ + void * opaque[4]; +}; +typedef struct RegEntryID RegEntryID; +typedef RegEntryID * RegEntryIDPtr; + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +struct IONDRVControlParameters { + UInt8 __reservedA[0x1a]; + UInt16 code; + void * params; + UInt8 __reservedB[0x12]; +}; + +enum { + kIONDRVOpenCommand = 128 + 0, + kIONDRVCloseCommand = 128 + 1, + kIONDRVReadCommand = 128 + 2, + kIONDRVWriteCommand = 128 + 3, + kIONDRVControlCommand = 128 + 4, + kIONDRVStatusCommand = 128 + 5, + kIONDRVKillIOCommand = 128 + 6, + kIONDRVInitializeCommand = 128 + 7, /* init driver and device*/ + kIONDRVFinalizeCommand = 128 + 8, /* shutdown driver and device*/ + kIONDRVReplaceCommand = 128 + 9, /* replace an old driver*/ + kIONDRVSupersededCommand = 128 + 10 /* prepare to be replaced by a new driver*/ +}; +enum { + kIONDRVSynchronousIOCommandKind = 0x00000001, + kIONDRVAsynchronousIOCommandKind = 0x00000002, + kIONDRVImmediateIOCommandKind = 0x00000004 +}; + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#ifndef __LP64__ +#pragma options align=reset +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* __QUICKDRAW__ */ + +#endif /* _IOKIT_IOMACOSTYPES_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/ndrvsupport/IOMacOSVideo.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/ndrvsupport/IOMacOSVideo.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/ndrvsupport/IOMacOSVideo.h (revision 885) @@ -0,0 +1,1391 @@ +/* + * 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@ + */ +/* + File: Video.h + + Contains: Video Driver Interfaces. + + Copyright: (c) 1986-2000 by Apple Computer, Inc., all rights reserved + + Bugs?: For bug reports, consult the following page on + the World Wide Web: + + http://developer.apple.com/bugreporter/ + +*/ +#ifndef __IOMACOSVIDEO__ +#define __IOMACOSVIDEO__ + +#define PRAGMA_STRUCT_ALIGN 1 +#define FOUR_CHAR_CODE(x) (x) +#include <IOKit/ndrvsupport/IOMacOSTypes.h> + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __LP64__ +#pragma options align=mac68k +#endif + +enum { + mBaseOffset = 1, /*Id of mBaseOffset.*/ + mRowBytes = 2, /*Video sResource parameter Id's */ + mBounds = 3, /*Video sResource parameter Id's */ + mVersion = 4, /*Video sResource parameter Id's */ + mHRes = 5, /*Video sResource parameter Id's */ + mVRes = 6, /*Video sResource parameter Id's */ + mPixelType = 7, /*Video sResource parameter Id's */ + mPixelSize = 8, /*Video sResource parameter Id's */ + mCmpCount = 9, /*Video sResource parameter Id's */ + mCmpSize = 10, /*Video sResource parameter Id's */ + mPlaneBytes = 11, /*Video sResource parameter Id's */ + mVertRefRate = 14, /*Video sResource parameter Id's */ + mVidParams = 1, /*Video parameter block id.*/ + mTable = 2, /*Offset to the table.*/ + mPageCnt = 3, /*Number of pages*/ + mDevType = 4, /*Device Type*/ + oneBitMode = 128, /*Id of OneBitMode Parameter list.*/ + twoBitMode = 129, /*Id of TwoBitMode Parameter list.*/ + fourBitMode = 130, /*Id of FourBitMode Parameter list.*/ + eightBitMode = 131 /*Id of EightBitMode Parameter list.*/ +}; + +enum { + sixteenBitMode = 132, /*Id of SixteenBitMode Parameter list.*/ + thirtyTwoBitMode = 133, /*Id of ThirtyTwoBitMode Parameter list.*/ + firstVidMode = 128, /*The new, better way to do the above. */ + secondVidMode = 129, /* QuickDraw only supports six video */ + thirdVidMode = 130, /* at this time. */ + fourthVidMode = 131, + fifthVidMode = 132, + sixthVidMode = 133, + spGammaDir = 64, + spVidNamesDir = 65 +}; + +typedef UInt32 AVIDType; +typedef AVIDType DisplayIDType; +typedef IODisplayModeID DisplayModeID; +typedef UInt16 DepthMode; +typedef UInt32 VideoDeviceType; +typedef UInt32 GammaTableID; + +/* csTimingFormat values in VDTimingInfo */ +/* look in the declaration rom for timing info */ +enum { + kDeclROMtables = FOUR_CHAR_CODE('decl'), + kDetailedTimingFormat = FOUR_CHAR_CODE('arba') /* Timing is a detailed timing*/ +}; + +/* Size of a block of EDID (Extended Display Identification Data) */ +enum { + kDDCBlockSize = 128 +}; + +/* ddcBlockType constants*/ +enum { + kDDCBlockTypeEDID = 0 /* EDID block type. */ +}; + +/* ddcFlags constants*/ +enum { + kDDCForceReadBit = 0, /* Force a new read of the EDID. */ + kDDCForceReadMask = (1 << kDDCForceReadBit) /* Mask for kddcForceReadBit. */ +}; + + +/* Timing mode constants for Display Manager MultiMode support + Corresponding .h equates are in Video.h + .a equates are in Video.a + .r equates are in DepVideoEqu.r + + The second enum is the old names (for compatibility). + The first enum is the new names. +*/ +enum { + timingInvalid = 0, /* Unknown timing... force user to confirm. */ + timingInvalid_SM_T24 = 8, /* Work around bug in SM Thunder24 card.*/ + timingApple_FixedRateLCD = 42, /* Lump all fixed-rate LCDs into one category.*/ + timingApple_512x384_60hz = 130, /* 512x384 (60 Hz) Rubik timing. */ + timingApple_560x384_60hz = 135, /* 560x384 (60 Hz) Rubik-560 timing. */ + timingApple_640x480_67hz = 140, /* 640x480 (67 Hz) HR timing. */ + timingApple_640x400_67hz = 145, /* 640x400 (67 Hz) HR-400 timing. */ + timingVESA_640x480_60hz = 150, /* 640x480 (60 Hz) VGA timing. */ + timingVESA_640x480_72hz = 152, /* 640x480 (72 Hz) VGA timing. */ + timingVESA_640x480_75hz = 154, /* 640x480 (75 Hz) VGA timing. */ + timingVESA_640x480_85hz = 158, /* 640x480 (85 Hz) VGA timing. */ + timingGTF_640x480_120hz = 159, /* 640x480 (120 Hz) VESA Generalized Timing Formula */ + timingApple_640x870_75hz = 160, /* 640x870 (75 Hz) FPD timing.*/ + timingApple_640x818_75hz = 165, /* 640x818 (75 Hz) FPD-818 timing.*/ + timingApple_832x624_75hz = 170, /* 832x624 (75 Hz) GoldFish timing.*/ + timingVESA_800x600_56hz = 180, /* 800x600 (56 Hz) SVGA timing. */ + timingVESA_800x600_60hz = 182, /* 800x600 (60 Hz) SVGA timing. */ + timingVESA_800x600_72hz = 184, /* 800x600 (72 Hz) SVGA timing. */ + timingVESA_800x600_75hz = 186, /* 800x600 (75 Hz) SVGA timing. */ + timingVESA_800x600_85hz = 188, /* 800x600 (85 Hz) SVGA timing. */ + timingVESA_1024x768_60hz = 190, /* 1024x768 (60 Hz) VESA 1K-60Hz timing. */ + timingVESA_1024x768_70hz = 200, /* 1024x768 (70 Hz) VESA 1K-70Hz timing. */ + timingVESA_1024x768_75hz = 204, /* 1024x768 (75 Hz) VESA 1K-75Hz timing (very similar to timingApple_1024x768_75hz). */ + timingVESA_1024x768_85hz = 208, /* 1024x768 (85 Hz) VESA timing. */ + timingApple_1024x768_75hz = 210, /* 1024x768 (75 Hz) Apple 19" RGB. */ + timingApple_1152x870_75hz = 220, /* 1152x870 (75 Hz) Apple 21" RGB. */ + timingAppleNTSC_ST = 230, /* 512x384 (60 Hz, interlaced, non-convolved). */ + timingAppleNTSC_FF = 232, /* 640x480 (60 Hz, interlaced, non-convolved). */ + timingAppleNTSC_STconv = 234, /* 512x384 (60 Hz, interlaced, convolved). */ + timingAppleNTSC_FFconv = 236, /* 640x480 (60 Hz, interlaced, convolved). */ + timingApplePAL_ST = 238, /* 640x480 (50 Hz, interlaced, non-convolved). */ + timingApplePAL_FF = 240, /* 768x576 (50 Hz, interlaced, non-convolved). */ + timingApplePAL_STconv = 242, /* 640x480 (50 Hz, interlaced, convolved). */ + timingApplePAL_FFconv = 244, /* 768x576 (50 Hz, interlaced, convolved). */ + timingVESA_1280x960_75hz = 250, /* 1280x960 (75 Hz) */ + timingVESA_1280x960_60hz = 252, /* 1280x960 (60 Hz) */ + timingVESA_1280x960_85hz = 254, /* 1280x960 (85 Hz) */ + timingVESA_1280x1024_60hz = 260, /* 1280x1024 (60 Hz) */ + timingVESA_1280x1024_75hz = 262, /* 1280x1024 (75 Hz) */ + timingVESA_1280x1024_85hz = 268, /* 1280x1024 (85 Hz) */ + timingVESA_1600x1200_60hz = 280, /* 1600x1200 (60 Hz) VESA timing. */ + timingVESA_1600x1200_65hz = 282, /* 1600x1200 (65 Hz) VESA timing. */ + timingVESA_1600x1200_70hz = 284, /* 1600x1200 (70 Hz) VESA timing. */ + timingVESA_1600x1200_75hz = 286, /* 1600x1200 (75 Hz) VESA timing (pixel clock is 189.2 Mhz dot clock). */ + timingVESA_1600x1200_80hz = 288, /* 1600x1200 (80 Hz) VESA timing (pixel clock is 216>? Mhz dot clock) - proposed only. */ + timingVESA_1600x1200_85hz = 289, /* 1600x1200 (85 Hz) VESA timing (pixel clock is 229.5 Mhz dot clock). */ + timingVESA_1792x1344_60hz = 296, /* 1792x1344 (60 Hz) VESA timing (204.75 Mhz dot clock). */ + timingVESA_1792x1344_75hz = 298, /* 1792x1344 (75 Hz) VESA timing (261.75 Mhz dot clock). */ + timingVESA_1856x1392_60hz = 300, /* 1856x1392 (60 Hz) VESA timing (218.25 Mhz dot clock). */ + timingVESA_1856x1392_75hz = 302, /* 1856x1392 (75 Hz) VESA timing (288 Mhz dot clock). */ + timingVESA_1920x1440_60hz = 304, /* 1920x1440 (60 Hz) VESA timing (234 Mhz dot clock). */ + timingVESA_1920x1440_75hz = 306, /* 1920x1440 (75 Hz) VESA timing (297 Mhz dot clock). */ + timingSMPTE240M_60hz = 400, /* 60Hz V, 33.75KHz H, interlaced timing, 16:9 aspect, typical resolution of 1920x1035. */ + timingFilmRate_48hz = 410, /* 48Hz V, 25.20KHz H, non-interlaced timing, typical resolution of 640x480. */ + timingSony_1600x1024_76hz = 500, /* 1600x1024 (76 Hz) Sony timing (pixel clock is 170.447 Mhz dot clock). */ + timingSony_1920x1080_60hz = 510, /* 1920x1080 (60 Hz) Sony timing (pixel clock is 159.84 Mhz dot clock). */ + timingSony_1920x1080_72hz = 520, /* 1920x1080 (72 Hz) Sony timing (pixel clock is 216.023 Mhz dot clock). */ + timingSony_1920x1200_76hz = 540, /* 1900x1200 (76 Hz) Sony timing (pixel clock is 243.20 Mhz dot clock). */ + timingApple_0x0_0hz_Offline = 550 /* Indicates that this timing will take the display off-line and remove it from the system. */ +}; + + +/* Deprecated timing names.*/ +enum { + timingApple12 = timingApple_512x384_60hz, + timingApple12x = timingApple_560x384_60hz, + timingApple13 = timingApple_640x480_67hz, + timingApple13x = timingApple_640x400_67hz, + timingAppleVGA = timingVESA_640x480_60hz, + timingApple15 = timingApple_640x870_75hz, + timingApple15x = timingApple_640x818_75hz, + timingApple16 = timingApple_832x624_75hz, + timingAppleSVGA = timingVESA_800x600_56hz, + timingApple1Ka = timingVESA_1024x768_60hz, + timingApple1Kb = timingVESA_1024x768_70hz, + timingApple19 = timingApple_1024x768_75hz, + timingApple21 = timingApple_1152x870_75hz, + timingSony_1900x1200_74hz = 530, /* 1900x1200 (74 Hz) Sony timing (pixel clock is 236.25 Mhz dot clock). */ + timingSony_1900x1200_76hz = timingSony_1920x1200_76hz /* 1900x1200 (76 Hz) Sony timing (pixel clock is 245.48 Mhz dot clock). */ +}; + +/* csConnectFlags values in VDDisplayConnectInfo */ +enum { + kAllModesValid = 0, /* All modes not trimmed by primary init are good close enough to try */ + kAllModesSafe = 1, /* All modes not trimmed by primary init are know to be safe */ + kReportsTagging = 2, /* Can detect tagged displays (to identify smart monitors) */ + kHasDirectConnection = 3, /* True implies that driver can talk directly to device (e.g. serial data link via sense lines) */ + kIsMonoDev = 4, /* Says whether there's an RGB (0) or Monochrome (1) connection. */ + kUncertainConnection = 5, /* There may not be a display (no sense lines?). */ + kTaggingInfoNonStandard = 6, /* Set when csConnectTaggedType/csConnectTaggedData are non-standard (i.e., not the Apple CRT sense codes). */ + kReportsDDCConnection = 7, /* Card can do ddc (set kHasDirectConnect && kHasDDCConnect if you actually found a ddc display). */ + kHasDDCConnection = 8, /* Card has ddc connect now. */ + kConnectionInactive = 9, /* Set when the connection is NOT currently active (generally used in a multiconnection environment). */ + kDependentConnection = 10, /* Set when some ascpect of THIS connection depends on another (will generally be set in a kModeSimulscan environment). */ + kBuiltInConnection = 11, /* Set when connection is KNOWN to be built-in (this is not the same as kHasDirectConnection). */ + kOverrideConnection = 12, /* Set when the reported connection is not the true one, but is one that has been forced through a SetConnection call */ + kFastCheckForDDC = 13, /* Set when all 3 are true: 1) sense codes indicate DDC display could be attached 2) attempted fast check 3) DDC failed */ + kReportsHotPlugging = 14, /* Detects and reports hot pluggging on connector (via VSL also implies DDC will be up to date w/o force read) */ + kStereoSyncConnection = 15 /* Connection supports stereo sync signalling */ +}; + + +/* csDisplayType values in VDDisplayConnectInfo */ +enum { + kUnknownConnect = 1, /* Not sure how we'll use this, but seems like a good idea. */ + kPanelConnect = 2, /* For use with fixed-in-place LCD panels. */ + kPanelTFTConnect = 2, /* Alias for kPanelConnect */ + kFixedModeCRTConnect = 3, /* For use with fixed-mode (i.e., very limited range) displays. */ + kMultiModeCRT1Connect = 4, /* 320x200 maybe, 12" maybe, 13" (default), 16" certain, 19" maybe, 21" maybe */ + kMultiModeCRT2Connect = 5, /* 320x200 maybe, 12" maybe, 13" certain, 16" (default), 19" certain, 21" maybe */ + kMultiModeCRT3Connect = 6, /* 320x200 maybe, 12" maybe, 13" certain, 16" certain, 19" default, 21" certain */ + kMultiModeCRT4Connect = 7, /* Expansion to large multi mode (not yet used) */ + kModelessConnect = 8, /* Expansion to modeless model (not yet used) */ + kFullPageConnect = 9, /* 640x818 (to get 8bpp in 512K case) and 640x870 (these two only) */ + kVGAConnect = 10, /* 640x480 VGA default -- question everything else */ + kNTSCConnect = 11, /* NTSC ST (default), FF, STconv, FFconv */ + kPALConnect = 12, /* PAL ST (default), FF, STconv, FFconv */ + kHRConnect = 13, /* Straight-6 connect -- 640x480 and 640x400 (to get 8bpp in 256K case) (these two only) */ + kPanelFSTNConnect = 14, /* For use with fixed-in-place LCD FSTN (aka "Supertwist") panels */ + kMonoTwoPageConnect = 15, /* 1152x870 Apple color two-page display */ + kColorTwoPageConnect = 16, /* 1152x870 Apple B&W two-page display */ + kColor16Connect = 17, /* 832x624 Apple B&W two-page display */ + kColor19Connect = 18, /* 1024x768 Apple B&W two-page display */ + kGenericCRT = 19, /* Indicates nothing except that connection is CRT in nature. */ + kGenericLCD = 20, /* Indicates nothing except that connection is LCD in nature. */ + kDDCConnect = 21, /* DDC connection, always set kHasDDCConnection */ + kNoConnect = 22 /* No display is connected - load sensing or similar level of hardware detection is assumed (used by resident drivers that support hot plugging when nothing is currently connected) */ +}; + +/* csTimingFlags values in VDTimingInfoRec */ +enum { + kModeValid = 0, /* Says that this mode should NOT be trimmed. */ + kModeSafe = 1, /* This mode does not need confirmation */ + kModeDefault = 2, /* This is the default mode for this type of connection */ + kModeShowNow = 3, /* This mode should always be shown (even though it may require a confirm) */ + kModeNotResize = 4, /* This mode should not be used to resize the display (eg. mode selects a different connector on card) */ + kModeRequiresPan = 5, /* This mode has more pixels than are actually displayed */ + kModeInterlaced = 6, /* This mode is interlaced (single pixel lines look bad). */ + kModeShowNever = 7, /* This mode should not be shown in the user interface. */ + kModeSimulscan = 8, /* Indicates that more than one display connection can be driven from a single framebuffer controller. */ + kModeNotPreset = 9, /* Indicates that the timing is not a factory preset for the current display (geometry may need correction) */ + kModeBuiltIn = 10, /* Indicates that the display mode is for the built-in connect only (on multiconnect devices like the PB 3400) Only the driver is quieried */ + kModeStretched = 11, /* Indicates that the display mode will be stretched/distorted to match the display aspect ratio */ + kModeNotGraphicsQuality = 12, /* Indicates that the display mode is not the highest quality (eg. stretching artifacts). Intended as a hint */ + kModeValidateAgainstDisplay = 13 /* Indicates that this mode should be validated against the display EDID */ +}; + +/* csDepthFlags in VDVideoParametersInfoRec */ +enum { + kDepthDependent = 0, /* Says that this depth mode may cause dependent changes in other framebuffers (and . */ + kDepthDependentMask = (1 << kDepthDependent) /* mask for kDepthDependent */ +}; + +/* csResolutionFlags bit flags for VDResolutionInfoRec */ +enum { + kResolutionHasMultipleDepthSizes = 0 /* Says that this mode has different csHorizontalPixels, csVerticalLines at different depths (usually slightly larger at lower depths) */ +}; + + +enum { + /* Power Mode constants for VDPowerStateRec.powerState. Note the numeric order does not match the power state order */ + kAVPowerOff = 0, /* Power fully off*/ + kAVPowerStandby = 1, + kAVPowerSuspend = 2, + kAVPowerOn = 3, + kHardwareSleep = 128, + kHardwareWake = 129, + kHardwareWakeFromSuspend = 130, + kHardwareWakeToDoze = 131, + kHardwareWakeToDozeFromSuspend = 132, + kHardwarePark = 133, + kHardwareDrive = 134 +}; + +/* Reduced perf level, for GetPowerState, SetPowerState*/ +enum { + kPowerStateReducedPowerMask = 0x00000300, + kPowerStateFullPower = 0x00000000, + kPowerStateReducedPower1 = 0x00000100, + kPowerStateReducedPower2 = 0x00000200, + kPowerStateReducedPower3 = 0x00000300 +}; + +enum { + /* Power Mode masks and bits for VDPowerStateRec.powerFlags. */ + kPowerStateNeedsRefresh = 0, /* When leaving this power mode, a display will need refreshing */ + kPowerStateSleepAwareBit = 1, /* if gestaltPCCardDockingSelectorFix, Docking mgr checks this bit before checking kPowerStateSleepAllowedBit */ + kPowerStateSleepForbiddenBit = 2, /* if kPowerStateSleepAwareBit, Docking mgr checks this bit before sleeping */ + kPowerStateSleepCanPowerOffBit = 3, /* supports power down sleep (ie PCI power off)*/ + kPowerStateSleepNoDPMSBit = 4, /* Bug #2425210. Do not use DPMS with this display.*/ + kPowerStateSleepWaketoDozeBit = 5, /* Supports Wake to Doze */ + kPowerStateSleepWakeNeedsProbeBit = 6, /* Does not sense connection changes on wake */ + + kPowerStateNeedsRefreshMask = (1 << kPowerStateNeedsRefresh), + kPowerStateSleepAwareMask = (1 << kPowerStateSleepAwareBit), + kPowerStateSleepForbiddenMask = (1 << kPowerStateSleepForbiddenBit), + kPowerStateSleepCanPowerOffMask = (1 << kPowerStateSleepCanPowerOffBit), + kPowerStateSleepNoDPMSMask = (1 << kPowerStateSleepNoDPMSBit), + kPowerStateSleepWaketoDozeMask = (1 << kPowerStateSleepWaketoDozeBit), + kPowerStateSleepWakeNeedsProbeMask = (1 << kPowerStateSleepWakeNeedsProbeBit), + + kPowerStateSupportsReducedPower1Bit = 10, + kPowerStateSupportsReducedPower2Bit = 11, + kPowerStateSupportsReducedPower3Bit = 12, + kPowerStateSupportsReducedPower1BitMask = (1 << 10), + kPowerStateSupportsReducedPower2BitMask = (1 << 11), + kPowerStateSupportsReducedPower3BitMask = (1 << 12) +}; + + +enum { + /* Control Codes */ + cscReset = 0, + cscKillIO = 1, + cscSetMode = 2, + cscSetEntries = 3, + cscSetGamma = 4, + cscGrayPage = 5, + cscGrayScreen = 5, + cscSetGray = 6, + cscSetInterrupt = 7, + cscDirectSetEntries = 8, + cscSetDefaultMode = 9, + cscSwitchMode = 10, /* Takes a VDSwitchInfoPtr */ + cscSetSync = 11, /* Takes a VDSyncInfoPtr */ + cscSavePreferredConfiguration = 16, /* Takes a VDSwitchInfoPtr */ + cscSetHardwareCursor = 22, /* Takes a VDSetHardwareCursorPtr */ + cscDrawHardwareCursor = 23, /* Takes a VDDrawHardwareCursorPtr */ + cscSetConvolution = 24, /* Takes a VDConvolutionInfoPtr */ + cscSetPowerState = 25, /* Takes a VDPowerStatePtr */ + cscPrivateControlCall = 26, /* Takes a VDPrivateSelectorDataRec*/ + cscSetMultiConnect = 28, /* From a GDI point of view, this call should be implemented completely in the HAL and not at all in the core.*/ + cscSetClutBehavior = 29, /* Takes a VDClutBehavior */ + cscSetDetailedTiming = 31, /* Takes a VDDetailedTimingPtr */ + cscDoCommunication = 33, /* Takes a VDCommunicationPtr */ + cscProbeConnection = 34, /* Takes nil pointer */ + /* (may generate a kFBConnectInterruptServiceType service interrupt) */ + cscSetScaler = 36, /* Takes a VDScalerPtr */ + cscSetMirror = 37, /* Takes a VDMirrorPtr*/ + cscSetFeatureConfiguration = 38, /* Takes a VDConfigurationPtr*/ + cscUnusedCall = 127 /* This call used to expand the scrn resource. Its imbedded data contains more control info */ +}; + +enum { + /* Status Codes */ + cscGetMode = 2, + cscGetEntries = 3, + cscGetPageCnt = 4, + cscGetPages = 4, /* This is what C&D 2 calls it. */ + cscGetPageBase = 5, + cscGetBaseAddr = 5, /* This is what C&D 2 calls it. */ + cscGetGray = 6, + cscGetInterrupt = 7, + cscGetGamma = 8, + cscGetDefaultMode = 9, + cscGetCurMode = 10, /* Takes a VDSwitchInfoPtr */ + cscGetSync = 11, /* Takes a VDSyncInfoPtr */ + cscGetConnection = 12, /* Return information about the connection to the display */ + cscGetModeTiming = 13, /* Return timing info for a mode */ + cscGetModeBaseAddress = 14, /* Return base address information about a particular mode */ + cscGetScanProc = 15, /* QuickTime scan chasing routine */ + cscGetPreferredConfiguration = 16, /* Takes a VDSwitchInfoPtr */ + cscGetNextResolution = 17, /* Takes a VDResolutionInfoPtr */ + cscGetVideoParameters = 18, /* Takes a VDVideoParametersInfoPtr */ + cscGetGammaInfoList = 20, /* Takes a VDGetGammaListPtr */ + cscRetrieveGammaTable = 21, /* Takes a VDRetrieveGammaPtr */ + cscSupportsHardwareCursor = 22, /* Takes a VDSupportsHardwareCursorPtr */ + cscGetHardwareCursorDrawState = 23, /* Takes a VDHardwareCursorDrawStatePtr */ + cscGetConvolution = 24, /* Takes a VDConvolutionInfoPtr */ + cscGetPowerState = 25, /* Takes a VDPowerStatePtr */ + cscPrivateStatusCall = 26, /* Takes a VDPrivateSelectorDataRec*/ + cscGetDDCBlock = 27, /* Takes a VDDDCBlockRec */ + cscGetMultiConnect = 28, /* From a GDI point of view, this call should be implemented completely in the HAL and not at all in the core.*/ + cscGetClutBehavior = 29, /* Takes a VDClutBehavior */ + cscGetTimingRanges = 30, /* Takes a VDDisplayTimingRangePtr */ + cscGetDetailedTiming = 31, /* Takes a VDDetailedTimingPtr */ + cscGetCommunicationInfo = 32, /* Takes a VDCommunicationInfoPtr */ + cscGetScalerInfo = 35, /* Takes a VDScalerInfoPtr */ + cscGetScaler = 36, /* Takes a VDScalerPtr */ + cscGetMirror = 37, /* Takes a VDMirrorPtr*/ + cscGetFeatureConfiguration = 38, /* Takes a VDConfigurationPtr*/ + cscGetFeatureList = 39 +}; + +/* Bit definitions for the Get/Set Sync call*/ +enum { + kDisableHorizontalSyncBit = 0, + kDisableVerticalSyncBit = 1, + kDisableCompositeSyncBit = 2, + kEnableSyncOnBlue = 3, + kEnableSyncOnGreen = 4, + kEnableSyncOnRed = 5, + kNoSeparateSyncControlBit = 6, + kTriStateSyncBit = 7, + kHorizontalSyncMask = 0x01, + kVerticalSyncMask = 0x02, + kCompositeSyncMask = 0x04, + kDPMSSyncMask = 0x07, + kTriStateSyncMask = 0x80, + kSyncOnBlueMask = 0x08, + kSyncOnGreenMask = 0x10, + kSyncOnRedMask = 0x20, + kSyncOnMask = 0x38 +}; + +enum { + /* Power Mode constants for translating DPMS modes to Get/SetSync calls. */ + kDPMSSyncOn = 0, + kDPMSSyncStandby = 1, + kDPMSSyncSuspend = 2, + kDPMSSyncOff = 7 +}; + +/* Bit definitions for the Get/Set Convolution call*/ +enum { + kConvolved = 0, + kLiveVideoPassThru = 1, + kConvolvedMask = 0x01, + kLiveVideoPassThruMask = 0x02 +}; + + + +struct VPBlock { + UInt32 vpBaseOffset; /*Offset to page zero of video RAM (From minorBaseOS).*/ +#if __LP64__ + UInt32 vpRowBytes; /*Width of each row of video memory.*/ +#else + SInt16 vpRowBytes; /*Width of each row of video memory.*/ +#endif + Rect vpBounds; /*BoundsRect for the video display (gives dimensions).*/ + SInt16 vpVersion; /*PixelMap version number.*/ + SInt16 vpPackType; + UInt32 vpPackSize; + UInt32 vpHRes; /*Horizontal resolution of the device (pixels per inch).*/ + UInt32 vpVRes; /*Vertical resolution of the device (pixels per inch).*/ + SInt16 vpPixelType; /*Defines the pixel type.*/ + SInt16 vpPixelSize; /*Number of bits in pixel.*/ + SInt16 vpCmpCount; /*Number of components in pixel.*/ + SInt16 vpCmpSize; /*Number of bits per component*/ + UInt32 vpPlaneBytes; /*Offset from one plane to the next.*/ +}; +typedef struct VPBlock VPBlock; +typedef VPBlock * VPBlockPtr; + +struct VDEntryRecord { + Ptr csTable; /* pointer to color table entry=value, r,g,b:INTEGER*/ +}; +typedef struct VDEntryRecord VDEntryRecord; + +typedef VDEntryRecord * VDEntRecPtr; +/* Parm block for SetGray control call */ + +struct VDGrayRecord { + Boolean csMode; /*Same as GDDevType value (0=color, 1=mono)*/ + SInt8 filler; +}; +typedef struct VDGrayRecord VDGrayRecord; + +typedef VDGrayRecord * VDGrayPtr; +/* Parm block for SetInterrupt call */ + +struct VDFlagRecord { + SInt8 csMode; + SInt8 filler; +}; +typedef struct VDFlagRecord VDFlagRecord; + +typedef VDFlagRecord * VDFlagRecPtr; +/* Parm block for SetEntries control call */ + +struct VDSetEntryRecord { + ColorSpec * csTable; /*Pointer to an array of color specs*/ + SInt16 csStart; /*Which spec in array to start with, or -1*/ + SInt16 csCount; /*Number of color spec entries to set*/ +}; +typedef struct VDSetEntryRecord VDSetEntryRecord; + +typedef VDSetEntryRecord * VDSetEntryPtr; +/* Parm block for SetGamma control call */ + +struct VDGammaRecord { + Ptr csGTable; /*pointer to gamma table*/ +}; +typedef struct VDGammaRecord VDGammaRecord; + +typedef VDGammaRecord * VDGamRecPtr; + +struct VDSwitchInfoRec { + DepthMode csMode; /* mode depth*/ + DisplayModeID csData; /* functional sResource of mode*/ + UInt16 csPage; /* page to switch in*/ + Ptr csBaseAddr; /* base address of page (return value)*/ + uintptr_t csReserved; /* Reserved (set to 0) */ +}; +typedef struct VDSwitchInfoRec VDSwitchInfoRec; + +typedef VDSwitchInfoRec * VDSwitchInfoPtr; + +struct VDTimingInfoRec { + DisplayModeID csTimingMode; /* timing mode (a la InitGDevice) */ + uintptr_t csTimingReserved; /* reserved */ + UInt32 csTimingFormat; /* what format is the timing info */ + UInt32 csTimingData; /* data supplied by driver */ + UInt32 csTimingFlags; /* mode within device */ +}; +typedef struct VDTimingInfoRec VDTimingInfoRec; + +typedef VDTimingInfoRec * VDTimingInfoPtr; + +struct VDDisplayConnectInfoRec { + UInt16 csDisplayType; /* Type of display connected */ + UInt8 csConnectTaggedType; /* type of tagging */ + UInt8 csConnectTaggedData; /* tagging data */ + UInt32 csConnectFlags; /* tell us about the connection */ + uintptr_t csDisplayComponent; /* if the card has a direct connection to the display, it returns the display component here (FUTURE) */ + uintptr_t csConnectReserved; /* reserved */ +}; +typedef struct VDDisplayConnectInfoRec VDDisplayConnectInfoRec; + +typedef VDDisplayConnectInfoRec * VDDisplayConnectInfoPtr; + +struct VDMultiConnectInfoRec { + UInt32 csDisplayCountOrNumber; /* For GetMultiConnect, returns count n of 1..n connections; otherwise, indicates the ith connection.*/ + VDDisplayConnectInfoRec csConnectInfo; /* Standard VDDisplayConnectionInfo for connection i.*/ +}; +typedef struct VDMultiConnectInfoRec VDMultiConnectInfoRec; + +typedef VDMultiConnectInfoRec * VDMultiConnectInfoPtr; +/* RawSenseCode + This abstract data type is not exactly abstract. Rather, it is merely enumerated constants + for the possible raw sense code values when 'standard' sense code hardware is implemented. + + For 'standard' sense code hardware, the raw sense is obtained as follows: + o Instruct the frame buffer controller NOT to actively drive any of the monitor sense lines + o Read the state of the monitor sense lines 2, 1, and 0. (2 is the MSB, 0 the LSB) + + IMPORTANT Note: + When the 'kTaggingInfoNonStandard' bit of 'csConnectFlags' is FALSE, then these constants + are valid 'csConnectTaggedType' values in 'VDDisplayConnectInfo' + +*/ +typedef UInt8 RawSenseCode; +enum { + kRSCZero = 0, + kRSCOne = 1, + kRSCTwo = 2, + kRSCThree = 3, + kRSCFour = 4, + kRSCFive = 5, + kRSCSix = 6, + kRSCSeven = 7 +}; + + +/* ExtendedSenseCode + This abstract data type is not exactly abstract. Rather, it is merely enumerated constants + for the values which are possible when the extended sense algorithm is applied to hardware + which implements 'standard' sense code hardware. + + For 'standard' sense code hardware, the extended sense code algorithm is as follows: + (Note: as described here, sense line 'A' corresponds to '2', 'B' to '1', and 'C' to '0') + o Drive sense line 'A' low and read the values of 'B' and 'C'. + o Drive sense line 'B' low and read the values of 'A' and 'C'. + o Drive sense line 'C' low and read the values of 'A' and 'B'. + + In this way, a six-bit number of the form BC/AC/AB is generated. + + IMPORTANT Note: + When the 'kTaggingInfoNonStandard' bit of 'csConnectFlags' is FALSE, then these constants + are valid 'csConnectTaggedData' values in 'VDDisplayConnectInfo' + +*/ +typedef UInt8 ExtendedSenseCode; +enum { + kESCZero21Inch = 0x00, /* 21" RGB */ + kESCOnePortraitMono = 0x14, /* Portrait Monochrome */ + kESCTwo12Inch = 0x21, /* 12" RGB */ + kESCThree21InchRadius = 0x31, /* 21" RGB (Radius) */ + kESCThree21InchMonoRadius = 0x34, /* 21" Monochrome (Radius) */ + kESCThree21InchMono = 0x35, /* 21" Monochrome */ + kESCFourNTSC = 0x0A, /* NTSC */ + kESCFivePortrait = 0x1E, /* Portrait RGB */ + kESCSixMSB1 = 0x03, /* MultiScan Band-1 (12" thru 1Six") */ + kESCSixMSB2 = 0x0B, /* MultiScan Band-2 (13" thru 19") */ + kESCSixMSB3 = 0x23, /* MultiScan Band-3 (13" thru 21") */ + kESCSixStandard = 0x2B, /* 13"/14" RGB or 12" Monochrome */ + kESCSevenPAL = 0x00, /* PAL */ + kESCSevenNTSC = 0x14, /* NTSC */ + kESCSevenVGA = 0x17, /* VGA */ + kESCSeven16Inch = 0x2D, /* 16" RGB (GoldFish) */ + kESCSevenPALAlternate = 0x30, /* PAL (Alternate) */ + kESCSeven19Inch = 0x3A, /* Third-Party 19" */ + kESCSevenDDC = 0x3E, /* DDC display */ + kESCSevenNoDisplay = 0x3F /* No display connected */ +}; + +/* DepthMode + This abstract data type is used to to reference RELATIVE pixel depths. + Its definition is largely derived from its past usage, analogous to 'xxxVidMode' + + Bits per pixel DOES NOT directly map to 'DepthMode' For example, on some + graphics hardware, 'kDepthMode1' may represent 1 BPP, whereas on other + hardware, 'kDepthMode1' may represent 8BPP. + + DepthMode IS considered to be ordinal, i.e., operations such as <, >, ==, etc. + behave as expected. The values of the constants which comprise the set are such + that 'kDepthMode4 < kDepthMode6' behaves as expected. +*/ +enum { + kDepthMode1 = 128, + kDepthMode2 = 129, + kDepthMode3 = 130, + kDepthMode4 = 131, + kDepthMode5 = 132, + kDepthMode6 = 133 +}; + +enum { + kFirstDepthMode = 128, /* These constants are obsolete, and just included */ + kSecondDepthMode = 129, /* for clients that have converted to the above */ + kThirdDepthMode = 130, /* kDepthModeXXX constants. */ + kFourthDepthMode = 131, + kFifthDepthMode = 132, + kSixthDepthMode = 133 +}; + + + +struct VDPageInfo { + DepthMode csMode; /* mode within device*/ + DisplayModeID csData; /* data supplied by driver*/ + SInt16 csPage; /* page to switch in*/ + Ptr csBaseAddr; /* base address of page*/ +}; +typedef struct VDPageInfo VDPageInfo; + +typedef VDPageInfo * VDPgInfoPtr; + +struct VDSizeInfo { + SInt16 csHSize; /* desired/returned h size*/ + SInt16 csHPos; /* desired/returned h position*/ + SInt16 csVSize; /* desired/returned v size*/ + SInt16 csVPos; /* desired/returned v position*/ +}; +typedef struct VDSizeInfo VDSizeInfo; + +typedef VDSizeInfo * VDSzInfoPtr; + +struct VDSettings { + SInt16 csParamCnt; /* number of params*/ + SInt16 csBrightMax; /* max brightness*/ + SInt16 csBrightDef; /* default brightness*/ + SInt16 csBrightVal; /* current brightness*/ + SInt16 csCntrstMax; /* max contrast*/ + SInt16 csCntrstDef; /* default contrast*/ + SInt16 csCntrstVal; /* current contrast*/ + SInt16 csTintMax; /* max tint*/ + SInt16 csTintDef; /* default tint*/ + SInt16 csTintVal; /* current tint*/ + SInt16 csHueMax; /* max hue*/ + SInt16 csHueDef; /* default hue*/ + SInt16 csHueVal; /* current hue*/ + SInt16 csHorizDef; /* default horizontal*/ + SInt16 csHorizVal; /* current horizontal*/ + SInt16 csHorizMax; /* max horizontal*/ + SInt16 csVertDef; /* default vertical*/ + SInt16 csVertVal; /* current vertical*/ + SInt16 csVertMax; /* max vertical*/ +}; +typedef struct VDSettings VDSettings; +typedef VDSettings * VDSettingsPtr; + +struct VDDefMode { + UInt8 csID; + SInt8 filler; +}; +typedef struct VDDefMode VDDefMode; +typedef VDDefMode * VDDefModePtr; + +struct VDSyncInfoRec { + UInt8 csMode; + UInt8 csFlags; +}; +typedef struct VDSyncInfoRec VDSyncInfoRec; + +typedef VDSyncInfoRec * VDSyncInfoPtr; +/* + All displayModeID values from 0x80000000 to 0xFFFFFFFF and 0x00 + are reserved for Apple Computer. +*/ +/* Constants for the cscGetNextResolution call */ +enum { + kDisplayModeIDCurrent = 0x00, /* Reference the Current DisplayModeID */ + kDisplayModeIDInvalid = (IODisplayModeID)0xFFFFFFFF, /* A bogus DisplayModeID in all cases */ + kDisplayModeIDFindFirstResolution = (IODisplayModeID)0xFFFFFFFE, /* Used in cscGetNextResolution to reset iterator */ + kDisplayModeIDNoMoreResolutions = (IODisplayModeID)0xFFFFFFFD, /* Used in cscGetNextResolution to indicate End Of List */ + kDisplayModeIDFindFirstProgrammable = (IODisplayModeID)0xFFFFFFFC, /* Used in cscGetNextResolution to find unused programmable timing */ + kDisplayModeIDBootProgrammable = (IODisplayModeID)0xFFFFFFFB, /* This is the ID given at boot time by the OF driver to a programmable timing */ + kDisplayModeIDReservedBase = (IODisplayModeID)0x80000000 /* Lowest (unsigned) DisplayModeID reserved by Apple */ +}; + +/* Constants for the GetGammaInfoList call */ +enum { + kGammaTableIDFindFirst = (GammaTableID)0xFFFFFFFE, /* Get the first gamma table ID */ + kGammaTableIDNoMoreTables = (GammaTableID)0xFFFFFFFD, /* Used to indicate end of list */ + kGammaTableIDSpecific = 0x00 /* Return the info for the given table id */ +}; + +/* Constants for GetMultiConnect call*/ +enum { + kGetConnectionCount = 0xFFFFFFFF, /* Used to get the number of possible connections in a "multi-headed" framebuffer environment.*/ + kActivateConnection = (0 << kConnectionInactive), /* Used for activating a connection (csConnectFlags value).*/ + kDeactivateConnection = (1 << kConnectionInactive) /* Used for deactivating a connection (csConnectFlags value.)*/ +}; + +/* VDCommunicationRec.csBusID values*/ +enum { + kVideoDefaultBus = 0 +}; + + +/* VDCommunicationInfoRec.csBusType values*/ +enum { + kVideoBusTypeInvalid = 0, + kVideoBusTypeI2C = 1, + kVideoBusTypeDisplayPort = 2 +}; + + +/* VDCommunicationRec.csSendType and VDCommunicationRec.csReplyType values*/ +enum { + kVideoNoTransactionType = 0, /* No transaction*/ + kVideoNoTransactionTypeMask = (1 << kVideoNoTransactionType), + kVideoSimpleI2CType = 1, /* Simple I2C message*/ + kVideoSimpleI2CTypeMask = (1 << kVideoSimpleI2CType), + kVideoDDCciReplyType = 2, /* DDC/ci message (with imbedded length)*/ + kVideoDDCciReplyTypeMask = (1 << kVideoDDCciReplyType), + kVideoCombinedI2CType = 3, /* Combined format I2C R/~W transaction*/ + kVideoCombinedI2CTypeMask = (1 << kVideoCombinedI2CType), + kVideoDisplayPortNativeType = 4, /* DisplayPort Native */ + kVideoDisplayPortNativeTypeMask = (1 << kVideoDisplayPortNativeType) +}; + +// VDCommunicationRec.csCommFlags and VDCommunicationInfoRec.csSupportedCommFlags +enum { + kVideoReplyMicroSecDelayBit = 0, /* If bit set, the driver should delay csMinReplyDelay micro seconds between send and receive*/ + kVideoReplyMicroSecDelayMask = (1 << kVideoReplyMicroSecDelayBit), + kVideoUsageAddrSubAddrBit = 1, /* If bit set, the driver understands to use the lower 16 bits of the address field as two 8 bit values (address/subaddress) for the I2C transaction*/ + kVideoUsageAddrSubAddrMask = (1 << kVideoUsageAddrSubAddrBit) +}; + + +struct VDResolutionInfoRec { + DisplayModeID csPreviousDisplayModeID; /* ID of the previous resolution in a chain */ + DisplayModeID csDisplayModeID; /* ID of the next resolution */ + UInt32 csHorizontalPixels; /* # of pixels in a horizontal line at the max depth */ + UInt32 csVerticalLines; /* # of lines in a screen at the max depth */ + Fixed csRefreshRate; /* Vertical Refresh Rate in Hz */ + DepthMode csMaxDepthMode; /* 0x80-based number representing max bit depth */ + UInt32 csResolutionFlags; /* Reserved - flag bits */ + uintptr_t csReserved; /* Reserved */ +}; +typedef struct VDResolutionInfoRec VDResolutionInfoRec; + +typedef VDResolutionInfoRec * VDResolutionInfoPtr; + +struct VDVideoParametersInfoRec { + DisplayModeID csDisplayModeID; /* the ID of the resolution we want info on */ + DepthMode csDepthMode; /* The bit depth we want the info on (0x80 based) */ + VPBlockPtr csVPBlockPtr; /* Pointer to a video parameter block */ + UInt32 csPageCount; /* Number of pages supported by the resolution */ + VideoDeviceType csDeviceType; /* Device Type: Direct, Fixed or CLUT; */ + UInt32 csDepthFlags; /* Flags */ +}; +typedef struct VDVideoParametersInfoRec VDVideoParametersInfoRec; + +typedef VDVideoParametersInfoRec * VDVideoParametersInfoPtr; + +struct VDGammaInfoRec { + GammaTableID csLastGammaID; /* the ID of the previous gamma table */ + GammaTableID csNextGammaID; /* the ID of the next gamma table */ + Ptr csGammaPtr; /* Ptr to a gamma table data */ + uintptr_t csReserved; /* Reserved */ +}; +typedef struct VDGammaInfoRec VDGammaInfoRec; + +typedef VDGammaInfoRec * VDGammaInfoPtr; + +struct VDGetGammaListRec { + GammaTableID csPreviousGammaTableID; /* ID of the previous gamma table */ + GammaTableID csGammaTableID; /* ID of the gamma table following csPreviousDisplayModeID */ + UInt32 csGammaTableSize; /* Size of the gamma table in bytes */ + char * csGammaTableName; /* Gamma table name (c-string) */ +}; +typedef struct VDGetGammaListRec VDGetGammaListRec; + +typedef VDGetGammaListRec * VDGetGammaListPtr; + +struct VDRetrieveGammaRec { + GammaTableID csGammaTableID; /* ID of gamma table to retrieve */ + GammaTbl * csGammaTablePtr; /* Location to copy desired gamma to */ +}; +typedef struct VDRetrieveGammaRec VDRetrieveGammaRec; + +typedef VDRetrieveGammaRec * VDRetrieveGammaPtr; + +struct VDSetHardwareCursorRec { + void * csCursorRef; /* reference to cursor data */ + UInt32 csReserved1; /* reserved for future use */ + UInt32 csReserved2; /* should be ignored */ +}; +typedef struct VDSetHardwareCursorRec VDSetHardwareCursorRec; + +typedef VDSetHardwareCursorRec * VDSetHardwareCursorPtr; + +struct VDDrawHardwareCursorRec { + SInt32 csCursorX; /* x coordinate */ + SInt32 csCursorY; /* y coordinate */ + UInt32 csCursorVisible; /* true if cursor is must be visible */ + UInt32 csReserved1; /* reserved for future use */ + UInt32 csReserved2; /* should be ignored */ +}; +typedef struct VDDrawHardwareCursorRec VDDrawHardwareCursorRec; + +typedef VDDrawHardwareCursorRec * VDDrawHardwareCursorPtr; + +struct VDSupportsHardwareCursorRec { + UInt32 csSupportsHardwareCursor; + /* true if hardware cursor is supported */ + UInt32 csReserved1; /* reserved for future use */ + UInt32 csReserved2; /* must be zero */ +}; +typedef struct VDSupportsHardwareCursorRec VDSupportsHardwareCursorRec; + +typedef VDSupportsHardwareCursorRec * VDSupportsHardwareCursorPtr; + +struct VDHardwareCursorDrawStateRec { + SInt32 csCursorX; /* x coordinate */ + SInt32 csCursorY; /* y coordinate */ + UInt32 csCursorVisible; /* true if cursor is visible */ + UInt32 csCursorSet; /* true if cursor successfully set by last set control call */ + UInt32 csReserved1; /* reserved for future use */ + UInt32 csReserved2; /* must be zero */ +}; +typedef struct VDHardwareCursorDrawStateRec VDHardwareCursorDrawStateRec; + +typedef VDHardwareCursorDrawStateRec * VDHardwareCursorDrawStatePtr; + +struct VDConvolutionInfoRec { + DisplayModeID csDisplayModeID; /* the ID of the resolution we want info on */ + DepthMode csDepthMode; /* The bit depth we want the info on (0x80 based) */ + UInt32 csPage; + UInt32 csFlags; + UInt32 csReserved; +}; +typedef struct VDConvolutionInfoRec VDConvolutionInfoRec; + +typedef VDConvolutionInfoRec * VDConvolutionInfoPtr; + +struct VDPowerStateRec { + UInt32 powerState; + UInt32 powerFlags; + + uintptr_t powerReserved1; + uintptr_t powerReserved2; +}; +typedef struct VDPowerStateRec VDPowerStateRec; + +typedef VDPowerStateRec * VDPowerStatePtr; +/* + Private Data to video drivers. + + In versions of MacOS with multiple address spaces (System 8), the OS + must know the extent of parameters in order to move them between the caller + and driver. The old private-selector model for video drivers does not have + this information so: + + For post-7.x Systems private calls should be implemented using the cscPrivateCall +*/ + +struct VDPrivateSelectorDataRec { + LogicalAddress privateParameters; /* Caller's parameters*/ + ByteCount privateParametersSize; /* Size of data sent from caller to driver*/ + LogicalAddress privateResults; /* Caller's return area. Can be nil, or same as privateParameters.*/ + ByteCount privateResultsSize; /* Size of data driver returns to caller. Can be nil, or same as privateParametersSize.*/ +}; +typedef struct VDPrivateSelectorDataRec VDPrivateSelectorDataRec; + + +struct VDPrivateSelectorRec { + UInt32 reserved; /* Reserved (set to 0). */ + VDPrivateSelectorDataRec data[1]; +}; +typedef struct VDPrivateSelectorRec VDPrivateSelectorRec; + +struct VDDDCBlockRec { + UInt32 ddcBlockNumber; /* Input -- DDC EDID (Extended Display Identification Data) number (1-based) */ + ResType ddcBlockType; /* Input -- DDC block type (EDID/VDIF) */ + UInt32 ddcFlags; /* Input -- DDC Flags*/ + UInt32 ddcReserved; /* Reserved */ + Byte ddcBlockData[128]; /* Output -- DDC EDID/VDIF data (kDDCBlockSize) */ +}; +typedef struct VDDDCBlockRec VDDDCBlockRec; + +typedef VDDDCBlockRec * VDDDCBlockPtr; + +enum { + /* timingSyncConfiguration*/ + kSyncInterlaceMask = (1 << 7), + kSyncAnalogCompositeMask = 0, + kSyncAnalogCompositeSerrateMask = (1 << 2), + kSyncAnalogCompositeRGBSyncMask = (1 << 1), + kSyncAnalogBipolarMask = (1 << 3), + kSyncAnalogBipolarSerrateMask = (1 << 2), + kSyncAnalogBipolarSRGBSyncMask = (1 << 1), + kSyncDigitalCompositeMask = (1 << 4), + kSyncDigitalCompositeSerrateMask = (1 << 2), + kSyncDigitalCompositeMatchHSyncMask = (1 << 2), + kSyncDigitalSeperateMask = (1 << 4) + (1 << 3), + kSyncDigitalVSyncPositiveMask = (1 << 2), + kSyncDigitalHSyncPositiveMask = (1 << 1) +}; + + + + +struct VDDisplayTimingRangeRec { + UInt32 csRangeSize; /* Init to sizeof(VDDisplayTimingRangeRec) */ + UInt32 csRangeType; /* Init to 0 */ + UInt32 csRangeVersion; /* Init to 0 */ + UInt32 csRangeReserved; /* Init to 0 */ + + UInt32 csRangeBlockIndex; /* Requested block (first index is 0)*/ + UInt32 csRangeGroup; /* set to 0 */ + UInt32 csRangeBlockCount; /* # blocks */ + UInt32 csRangeFlags; /* dependent video */ + + UInt64 csMinPixelClock; /* Min dot clock in Hz */ + UInt64 csMaxPixelClock; /* Max dot clock in Hz */ + + UInt32 csMaxPixelError; /* Max dot clock error */ + UInt32 csTimingRangeSyncFlags; + UInt32 csTimingRangeSignalLevels; + UInt32 csTimingRangeSupportedSignalConfigs; + + UInt32 csMinFrameRate; /* Hz */ + UInt32 csMaxFrameRate; /* Hz */ + UInt32 csMinLineRate; /* Hz */ + UInt32 csMaxLineRate; /* Hz */ + + + UInt32 csMaxHorizontalTotal; /* Clocks - Maximum total (active + blanking) */ + UInt32 csMaxVerticalTotal; /* Clocks - Maximum total (active + blanking) */ + UInt32 csMaxTotalReserved1; /* Reserved */ + UInt32 csMaxTotalReserved2; /* Reserved */ + + + + /* Some cards require that some timing elements*/ + /* be multiples of a "character size" (often 8*/ + /* clocks). The "xxxxCharSize" fields document*/ + /* those requirements.*/ + + + UInt8 csCharSizeHorizontalActive; /* Character size */ + UInt8 csCharSizeHorizontalBlanking; /* Character size */ + UInt8 csCharSizeHorizontalSyncOffset; /* Character size */ + UInt8 csCharSizeHorizontalSyncPulse; /* Character size */ + + UInt8 csCharSizeVerticalActive; /* Character size */ + UInt8 csCharSizeVerticalBlanking; /* Character size */ + UInt8 csCharSizeVerticalSyncOffset; /* Character size */ + UInt8 csCharSizeVerticalSyncPulse; /* Character size */ + + UInt8 csCharSizeHorizontalBorderLeft; /* Character size */ + UInt8 csCharSizeHorizontalBorderRight; /* Character size */ + UInt8 csCharSizeVerticalBorderTop; /* Character size */ + UInt8 csCharSizeVerticalBorderBottom; /* Character size */ + + UInt8 csCharSizeHorizontalTotal; /* Character size for active + blanking */ + UInt8 csCharSizeVerticalTotal; /* Character size for active + blanking */ + UInt16 csCharSizeReserved1; /* Reserved (Init to 0) */ + + + UInt32 csMinHorizontalActiveClocks; + UInt32 csMaxHorizontalActiveClocks; + UInt32 csMinHorizontalBlankingClocks; + UInt32 csMaxHorizontalBlankingClocks; + + UInt32 csMinHorizontalSyncOffsetClocks; + UInt32 csMaxHorizontalSyncOffsetClocks; + UInt32 csMinHorizontalPulseWidthClocks; + UInt32 csMaxHorizontalPulseWidthClocks; + + UInt32 csMinVerticalActiveClocks; + UInt32 csMaxVerticalActiveClocks; + UInt32 csMinVerticalBlankingClocks; + UInt32 csMaxVerticalBlankingClocks; + + UInt32 csMinVerticalSyncOffsetClocks; + UInt32 csMaxVerticalSyncOffsetClocks; + UInt32 csMinVerticalPulseWidthClocks; + UInt32 csMaxVerticalPulseWidthClocks; + + + UInt32 csMinHorizontalBorderLeft; + UInt32 csMaxHorizontalBorderLeft; + UInt32 csMinHorizontalBorderRight; + UInt32 csMaxHorizontalBorderRight; + + UInt32 csMinVerticalBorderTop; + UInt32 csMaxVerticalBorderTop; + UInt32 csMinVerticalBorderBottom; + UInt32 csMaxVerticalBorderBottom; + + UInt32 csMaxNumLinks; /* number of links, if zero, assume link 1 */ + UInt32 csMinLink0PixelClock; /* min pixel clock for link 0 (kHz) */ + UInt32 csMaxLink0PixelClock; /* max pixel clock for link 0 (kHz) */ + UInt32 csMinLink1PixelClock; /* min pixel clock for link 1 (kHz) */ + UInt32 csMaxLink1PixelClock; /* max pixel clock for link 1 (kHz) */ + + UInt32 csReserved6; /* Reserved (Init to 0)*/ + UInt32 csReserved7; /* Reserved (Init to 0)*/ + UInt32 csReserved8; /* Reserved (Init to 0)*/ +}; +typedef struct VDDisplayTimingRangeRec VDDisplayTimingRangeRec; + +typedef VDDisplayTimingRangeRec * VDDisplayTimingRangePtr; + +enum { + /* csDisplayModeState*/ + kDMSModeReady = 0, /* Display Mode ID is configured and ready*/ + kDMSModeNotReady = 1, /* Display Mode ID is is being programmed*/ + kDMSModeFree = 2 /* Display Mode ID is not associated with a timing*/ +}; + + +/* Video driver Errors -10930 to -10959 */ +enum { + kTimingChangeRestrictedErr = -10930, + kVideoI2CReplyPendingErr = -10931, + kVideoI2CTransactionErr = -10932, + kVideoI2CBusyErr = -10933, + kVideoI2CTransactionTypeErr = -10934, + kVideoBufferSizeErr = -10935, + kVideoCannotMirrorErr = -10936 +}; + + +enum { + /* csTimingRangeSignalLevels*/ + kRangeSupportsSignal_0700_0300_Bit = 0, + kRangeSupportsSignal_0714_0286_Bit = 1, + kRangeSupportsSignal_1000_0400_Bit = 2, + kRangeSupportsSignal_0700_0000_Bit = 3, + kRangeSupportsSignal_0700_0300_Mask = (1 << kRangeSupportsSignal_0700_0300_Bit), + kRangeSupportsSignal_0714_0286_Mask = (1 << kRangeSupportsSignal_0714_0286_Bit), + kRangeSupportsSignal_1000_0400_Mask = (1 << kRangeSupportsSignal_1000_0400_Bit), + kRangeSupportsSignal_0700_0000_Mask = (1 << kRangeSupportsSignal_0700_0000_Bit) +}; + + +enum { + /* csSignalConfig*/ + kDigitalSignalBit = 0, /* Do not set. Mac OS does not currently support arbitrary digital timings*/ + kAnalogSetupExpectedBit = 1, /* Analog displays - display expects a blank-to-black setup or pedestal. See VESA signal standards.*/ + kInterlacedCEA861SyncModeBit = 2, + + kDigitalSignalMask = (1 << kDigitalSignalBit), + kAnalogSetupExpectedMask = (1 << kAnalogSetupExpectedBit), + kInterlacedCEA861SyncModeMask = (1 << kInterlacedCEA861SyncModeBit) +}; + + +enum { + /* csSignalLevels for analog*/ + kAnalogSignalLevel_0700_0300 = 0, + kAnalogSignalLevel_0714_0286 = 1, + kAnalogSignalLevel_1000_0400 = 2, + kAnalogSignalLevel_0700_0000 = 3 +}; + + +enum { + /* csTimingRangeSyncFlags*/ + kRangeSupportsSeperateSyncsBit = 0, + kRangeSupportsSyncOnGreenBit = 1, + kRangeSupportsCompositeSyncBit = 2, + kRangeSupportsVSyncSerrationBit = 3, + kRangeSupportsSeperateSyncsMask = (1 << kRangeSupportsSeperateSyncsBit), + kRangeSupportsSyncOnGreenMask = (1 << kRangeSupportsSyncOnGreenBit), + kRangeSupportsCompositeSyncMask = (1 << kRangeSupportsCompositeSyncBit), + kRangeSupportsVSyncSerrationMask = (1 << kRangeSupportsVSyncSerrationBit) +}; + + + +enum { + /* csHorizontalSyncConfig and csVerticalSyncConfig*/ + kSyncPositivePolarityBit = 0, /* Digital separate sync polarity for analog interfaces (0 => negative polarity)*/ + kSyncPositivePolarityMask = (1 << kSyncPositivePolarityBit) +}; + + + + +/* For timings with kDetailedTimingFormat.*/ + +struct VDDetailedTimingRec { + UInt32 csTimingSize; /* Init to sizeof(VDDetailedTimingRec)*/ + UInt32 csTimingType; /* Init to 0*/ + UInt32 csTimingVersion; /* Init to 0*/ + UInt32 csTimingReserved; /* Init to 0*/ + + DisplayModeID csDisplayModeID; /* Init to 0*/ + UInt32 csDisplayModeSeed; /* */ + UInt32 csDisplayModeState; /* Display Mode state*/ + UInt32 csDisplayModeAlias; /* Mode to use when programmed.*/ + + UInt32 csSignalConfig; + UInt32 csSignalLevels; + + UInt64 csPixelClock; /* Hz*/ + + UInt64 csMinPixelClock; /* Hz - With error what is slowest actual clock */ + UInt64 csMaxPixelClock; /* Hz - With error what is fasted actual clock */ + + + UInt32 csHorizontalActive; /* Pixels*/ + UInt32 csHorizontalBlanking; /* Pixels*/ + UInt32 csHorizontalSyncOffset; /* Pixels*/ + UInt32 csHorizontalSyncPulseWidth; /* Pixels*/ + + UInt32 csVerticalActive; /* Lines*/ + UInt32 csVerticalBlanking; /* Lines*/ + UInt32 csVerticalSyncOffset; /* Lines*/ + UInt32 csVerticalSyncPulseWidth; /* Lines*/ + + UInt32 csHorizontalBorderLeft; /* Pixels*/ + UInt32 csHorizontalBorderRight; /* Pixels*/ + UInt32 csVerticalBorderTop; /* Lines*/ + UInt32 csVerticalBorderBottom; /* Lines*/ + + UInt32 csHorizontalSyncConfig; + UInt32 csHorizontalSyncLevel; /* Future use (init to 0)*/ + UInt32 csVerticalSyncConfig; + UInt32 csVerticalSyncLevel; /* Future use (init to 0)*/ + + UInt32 csNumLinks; /* number of links, if 0 = assume link - 0 */ + + UInt32 csReserved2; /* Init to 0*/ + UInt32 csReserved3; /* Init to 0*/ + UInt32 csReserved4; /* Init to 0*/ + + UInt32 csReserved5; /* Init to 0*/ + UInt32 csReserved6; /* Init to 0*/ + UInt32 csReserved7; /* Init to 0*/ + UInt32 csReserved8; /* Init to 0*/ +}; +typedef struct VDDetailedTimingRec VDDetailedTimingRec; + +typedef VDDetailedTimingRec * VDDetailedTimingPtr; + +/* csScalerFeatures */ +enum { + kScaleStretchOnlyMask = (1<<0), /* True means the driver cannot add borders to avoid non-square pixels */ + kScaleCanUpSamplePixelsMask = (1<<1), /* True means timings with more active clocks than pixels (ie 640x480 pixels on a 1600x1200 timing) */ + kScaleCanDownSamplePixelsMask = (1<<2), /* True means timings with fewer active clocks than pixels (ie 1600x1200 pixels on a 640x480 timing) */ + kScaleCanScaleInterlacedMask = (1<<3), /* True means can scale an interlaced timing */ + kScaleCanSupportInsetMask = (1<<4), /* True means can scale a timing with insets */ + kScaleCanRotateMask = (1<<5), /* True means can rotate image */ + kScaleCanBorderInsetOnlyMask = (1<<6) /* True means can scale a timing with insets */ +}; + +/* csScalerFlags */ +enum { + kScaleStretchToFitMask = 0x00000001, /* True means the driver should avoid borders and allow non-square pixels */ + + kScaleRotateFlagsMask = 0x000000f0, + + kScaleSwapAxesMask = 0x00000010, + kScaleInvertXMask = 0x00000020, + kScaleInvertYMask = 0x00000040, + + kScaleRotate0Mask = 0x00000000, + kScaleRotate90Mask = kScaleSwapAxesMask | kScaleInvertXMask, + kScaleRotate180Mask = kScaleInvertXMask | kScaleInvertYMask, + kScaleRotate270Mask = kScaleSwapAxesMask | kScaleInvertYMask +}; + +typedef UInt32 VDClutBehavior; +typedef VDClutBehavior * VDClutBehaviorPtr; +enum { + kSetClutAtSetEntries = 0, /* SetEntries behavior is to update clut during SetEntries call*/ + kSetClutAtVBL = 1 /* SetEntries behavior is to upate clut at next vbl*/ +}; + + +struct VDCommunicationRec { + SInt32 csBusID; /* kVideoDefaultBus for single headed cards.*/ + UInt32 csCommFlags; /* Always zero*/ + UInt32 csMinReplyDelay; /* Minimum delay between send and reply transactions (units depend on csCommFlags)*/ + UInt32 csReserved2; /* Always zero*/ + + UInt32 csSendAddress; /* Usually I2C address (eg 0x6E)*/ + UInt32 csSendType; /* See kVideoSimpleI2CType etc.*/ + LogicalAddress csSendBuffer; /* Pointer to the send buffer*/ + ByteCount csSendSize; /* Number of bytes to send*/ + + UInt32 csReplyAddress; /* Address from which to read (eg 0x6F for kVideoDDCciReplyType I2C address)*/ + UInt32 csReplyType; /* See kVideoDDCciReplyType etc.*/ + LogicalAddress csReplyBuffer; /* Pointer to the reply buffer*/ + ByteCount csReplySize; /* Max bytes to reply (size of csReplyBuffer)*/ + + UInt32 csReserved3; + UInt32 csReserved4; + UInt32 csReserved5; /* Always zero*/ + UInt32 csReserved6; /* Always zero*/ +}; +typedef struct VDCommunicationRec VDCommunicationRec; + +typedef VDCommunicationRec * VDCommunicationPtr; + +struct VDCommunicationInfoRec { + SInt32 csBusID; /* kVideoDefaultBus for single headed cards. */ + UInt32 csBusType; /* See kVideoBusI2C etc.*/ + SInt32 csMinBus; /* Minimum bus (usually kVideoDefaultBus). Used to probe additional busses*/ + SInt32 csMaxBus; /* Max bus (usually kVideoDefaultBus). Used to probe additional busses*/ + + UInt32 csSupportedTypes; /* Bit field for first 32 supported transaction types. Eg. 0x07 => support for kVideoNoTransactionType, kVideoSimpleI2CType and kVideoDDCciReplyType.*/ + UInt32 csSupportedCommFlags; /* Return the flags csCommFlags understood by this driver. */ + UInt32 csReserved2; /* Always zero*/ + UInt32 csReserved3; /* Always zero*/ + + UInt32 csReserved4; /* Always zero*/ + UInt32 csReserved5; /* Always zero*/ + UInt32 csReserved6; /* Always zero*/ + UInt32 csReserved7; /* Always zero*/ +}; +typedef struct VDCommunicationInfoRec VDCommunicationInfoRec; + +typedef VDCommunicationInfoRec * VDCommunicationInfoPtr; + + +struct VDScalerRec { + UInt32 csScalerSize; /* Init to sizeof(VDScalerRec) */ + UInt32 csScalerVersion; /* Init to 0 */ + UInt32 csReserved1; /* Init to 0 */ + UInt32 csReserved2; /* Init to 0 */ + + DisplayModeID csDisplayModeID; /* Display Mode ID modified by this call. */ + UInt32 csDisplayModeSeed; /* */ + UInt32 csDisplayModeState; /* Display Mode state */ + UInt32 csReserved3; /* Init to 0 */ + + UInt32 csScalerFlags; /* Init to 0 */ + UInt32 csHorizontalPixels; /* Graphics system addressable pixels */ + UInt32 csVerticalPixels; /* Graphics system addressable lines */ + UInt32 csHorizontalInset; /* Border pixels for underscan */ + UInt32 csVerticalInset; /* Border lines for underscan */ + UInt32 csReserved6; /* Init to 0 */ + UInt32 csReserved7; /* Init to 0 */ + UInt32 csReserved8; /* Init to 0 */ +}; +typedef struct VDScalerRec VDScalerRec; +typedef VDScalerRec *VDScalerPtr; + +struct VDScalerInfoRec { + UInt32 csScalerInfoSize; /* Init to sizeof(VDScalerInfoRec) */ + UInt32 csScalerInfoVersion; /* Init to 0 */ + UInt32 csReserved1; /* Init to 0 */ + UInt32 csReserved2; /* Init to 0 */ + + UInt32 csScalerFeatures; /* Feature flags */ + UInt32 csMaxHorizontalPixels; /* limit to horizontal scaled pixels */ + UInt32 csMaxVerticalPixels; /* limit to vertical scaled pixels */ + UInt32 csReserved3; /* Init to 0 */ + + UInt32 csReserved4; /* Init to 0 */ + UInt32 csReserved5; /* Init to 0 */ + UInt32 csReserved6; /* Init to 0 */ + UInt32 csReserved7; /* Init to 0 */ +}; +typedef struct VDScalerInfoRec VDScalerInfoRec; +typedef VDScalerInfoRec *VDScalerInfoPtr; + +enum { + /* csMirrorFeatures*/ + kMirrorSameDepthOnlyMirrorMask = (1 << 0), /* Commonly true - Mirroring can only be done if the displays are the same bitdepth*/ + kMirrorSameSizeOnlyMirrorMask = (1 << 1), /* Commonly false - Mirroring can only be done if the displays are the same size*/ + kMirrorSameTimingOnlyMirrorMask = (1 << 2), /* Sometimes true - Mirroring can only be done if the displays are the same timing*/ + kMirrorCommonGammaMask = (1 << 3) /* Sometimes true - Only one gamma correction LUT.*/ +}; + +enum { + /* csMirrorSupportedFlags and csMirrorFlags*/ + kMirrorCanMirrorMask = (1 << 0), /* Set means we can HW mirrored right now (uses csMirrorEntryID)*/ + kMirrorAreMirroredMask = (1 << 1), /* Set means we are HW mirrored right now (uses csMirrorEntryID)*/ + kMirrorUnclippedMirrorMask = (1 << 2), /* Set means mirrored displays are not clipped to their intersection*/ + kMirrorHAlignCenterMirrorMask = (1 << 3), /* Set means mirrored displays can/should be centered horizontally*/ + kMirrorVAlignCenterMirrorMask = (1 << 4), /* Set means mirrored displays can/should be centered vertically*/ + kMirrorCanChangePixelFormatMask = (1 << 5), /* Set means mirrored the device should change the pixel format of mirrored displays to allow mirroring.*/ + kMirrorCanChangeTimingMask = (1 << 6), /* Set means mirrored the device should change the timing of mirrored displays to allow mirroring.*/ + kMirrorClippedMirrorMask = (1 << 7) /* Set means mirrored displays are clipped to their intersection (driver handles blacking and base address adjustment)*/ +}; + +struct VDMirrorRec { + UInt32 csMirrorSize; /* Init to sizeof(VDMirrorRec)*/ + UInt32 csMirrorVersion; /* Init to 0*/ + + RegEntryID csMirrorRequestID; /* Input RegEntryID to check for mirroring support and state*/ + RegEntryID csMirrorResultID; /* Output RegEntryID of the next mirrored device*/ + + UInt32 csMirrorFeatures; /* Output summary features of the driver*/ + UInt32 csMirrorSupportedFlags; /* Output configuration options supported by the driver*/ + UInt32 csMirrorFlags; /* Output configuration options active now*/ + UInt32 csReserved1; /* Init to 0*/ + + + UInt32 csReserved2; /* Init to 0*/ + UInt32 csReserved3; /* Init to 0*/ + UInt32 csReserved4; /* Init to 0*/ + UInt32 csReserved5; /* Init to 0*/ +}; +typedef struct VDMirrorRec VDMirrorRec; +typedef VDMirrorRec * VDMirrorPtr; + +struct VDConfigurationRec { + UInt32 csConfigFeature; /* input what feature to config - always input*/ + UInt32 csConfigSupport; /* output support value - always output*/ + uintptr_t csConfigValue; /* input/output feature value - input on Control(), output on Status()*/ + uintptr_t csReserved1; + uintptr_t csReserved2; +}; +typedef struct VDConfigurationRec VDConfigurationRec; +typedef VDConfigurationRec * VDConfigurationPtr; + +enum +{ + kDVIPowerSwitchFeature = (1 << 0), /* Used for csConfigFeature*/ + kDVIPowerSwitchSupportMask = (1 << 0), /* Read-only*/ + kDVIPowerSwitchActiveMask = (1 << 0), /* Read/write for csConfigValue*/ +}; + +struct VDConfigurationFeatureListRec +{ + OSType * csConfigFeatureList; + ItemCount csNumConfigFeatures; + uintptr_t csReserved1; + uintptr_t csReserved2; +}; +typedef struct VDConfigurationFeatureListRec VDConfigurationFeatureListRec; +typedef VDConfigurationFeatureListRec * VDConfigurationFeatureListRecPtr; + + +#ifndef __LP64__ +#pragma options align=reset +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* __IOMACOSVIDEO__ */ + Index: branches/azimutz/Cleancut/i386/include/IOKit/ndrvsupport/IONDRVFramebuffer.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/ndrvsupport/IONDRVFramebuffer.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/ndrvsupport/IONDRVFramebuffer.h (revision 885) @@ -0,0 +1,352 @@ +/* + * 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@ + */ +/* + * Copyright (c) 1997-1998 Apple Computer, Inc. + * + * + * HISTORY + * + * sdouglas 22 Oct 97 - first checked in. + * sdouglas 24 Jul 98 - start IOKit. + * sdouglas 15 Dec 98 - cpp. + * + */ + +#ifndef _IOKIT_IONDRVFRAMEBUFFER_H +#define _IOKIT_IONDRVFRAMEBUFFER_H + +#include <IOKit/graphics/IOFramebuffer.h> +#include <IOKit/ndrvsupport/IOMacOSVideo.h> +#include <IOKit/ndrvsupport/IONDRVSupport.h> + +#define kIONDRVDisableKey "AAPL,disable-ndrv" + +class IONDRVFramebuffer : public IOFramebuffer +{ + OSDeclareDefaultStructors(IONDRVFramebuffer) + +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; + +protected: + + IOService * nub; + class IONDRV * ndrv; + + // current configuration + IODisplayModeID currentDisplayMode; + IOIndex currentDepth; + IOIndex currentPage; + UInt8 __reservedE; + + IOPhysicalAddress physicalFramebuffer; + IODeviceMemory * vramRange; + + UInt8 gammaWidth; + UInt8 __reservedD; + UInt8 lastGrayMode; + VDClutBehavior lastClutSetting; + UInt8 __reservedC; + + bool consoleDevice; + UInt32 powerState; + UInt32 ndrvState; + SInt32 ndrvEnter; + OSArray * detailedTimings; + UInt32 detailedTimingsSeed; + UInt32 * detailedTimingsCurrent; + + IODeviceMemory * vramMemory; + + VDResolutionInfoRec cachedVDResolution; + + struct _VSLService * vslServices; + + UInt32 accessFlags; + unsigned int shouldDoI2CPower:1; + unsigned int online:1; + unsigned int avJackState:1; + unsigned int grayMode:1; + unsigned int platformSleep:1; + unsigned int forceReadEDID:1; + unsigned int supportsProbe:1; + unsigned int __reservedB:25; + + IOService * device; + + UInt32 __reservedA[29]; + +private: + struct IONDRVFramebufferPrivate * __private; + +public: + virtual IOReturn doDriverIO( UInt32 commandID, void * contents, + UInt32 commandCode, UInt32 commandKind ); +private: + OSMetaClassDeclareReservedUsed(IONDRVFramebuffer, 0); + + OSMetaClassDeclareReservedUnused(IONDRVFramebuffer, 1); + OSMetaClassDeclareReservedUnused(IONDRVFramebuffer, 2); + OSMetaClassDeclareReservedUnused(IONDRVFramebuffer, 3); + OSMetaClassDeclareReservedUnused(IONDRVFramebuffer, 4); + OSMetaClassDeclareReservedUnused(IONDRVFramebuffer, 5); + OSMetaClassDeclareReservedUnused(IONDRVFramebuffer, 6); + OSMetaClassDeclareReservedUnused(IONDRVFramebuffer, 7); + OSMetaClassDeclareReservedUnused(IONDRVFramebuffer, 8); + OSMetaClassDeclareReservedUnused(IONDRVFramebuffer, 9); + OSMetaClassDeclareReservedUnused(IONDRVFramebuffer, 10); + OSMetaClassDeclareReservedUnused(IONDRVFramebuffer, 11); + OSMetaClassDeclareReservedUnused(IONDRVFramebuffer, 12); + OSMetaClassDeclareReservedUnused(IONDRVFramebuffer, 13); + OSMetaClassDeclareReservedUnused(IONDRVFramebuffer, 14); + OSMetaClassDeclareReservedUnused(IONDRVFramebuffer, 15); + OSMetaClassDeclareReservedUnused(IONDRVFramebuffer, 16); + OSMetaClassDeclareReservedUnused(IONDRVFramebuffer, 17); + OSMetaClassDeclareReservedUnused(IONDRVFramebuffer, 18); + OSMetaClassDeclareReservedUnused(IONDRVFramebuffer, 19); + OSMetaClassDeclareReservedUnused(IONDRVFramebuffer, 20); + OSMetaClassDeclareReservedUnused(IONDRVFramebuffer, 21); + OSMetaClassDeclareReservedUnused(IONDRVFramebuffer, 22); + OSMetaClassDeclareReservedUnused(IONDRVFramebuffer, 23); + OSMetaClassDeclareReservedUnused(IONDRVFramebuffer, 24); + OSMetaClassDeclareReservedUnused(IONDRVFramebuffer, 25); + OSMetaClassDeclareReservedUnused(IONDRVFramebuffer, 26); + OSMetaClassDeclareReservedUnused(IONDRVFramebuffer, 27); + OSMetaClassDeclareReservedUnused(IONDRVFramebuffer, 28); + OSMetaClassDeclareReservedUnused(IONDRVFramebuffer, 29); + OSMetaClassDeclareReservedUnused(IONDRVFramebuffer, 30); + OSMetaClassDeclareReservedUnused(IONDRVFramebuffer, 31); + +private: + + void initForPM ( void ); + + virtual unsigned long maxCapabilityForDomainState( IOPMPowerFlags domainState ); + virtual unsigned long initialPowerStateForDomainState( IOPMPowerFlags domainState ); + virtual unsigned long powerStateForDomainState( IOPMPowerFlags domainState ); + + virtual IOReturn checkDriver( void ); + virtual UInt32 iterateAllModes( IODisplayModeID * displayModeIDs ); + virtual IOReturn getResInfoForMode( IODisplayModeID modeID, + IODisplayModeInformation * theInfo ); + virtual IOReturn getResInfoForArbMode( IODisplayModeID modeID, + IODisplayModeInformation * theInfo ); + IOReturn getResInfoForDetailed( IODisplayModeID modeID, + VDDetailedTimingRec * detailed, + IODisplayModeInformation * info ); + IOIndex mapDepthIndex( IODisplayModeID modeID, IOIndex depth, bool fromDepthMode ); + virtual IOReturn validateDisplayMode( + IODisplayModeID mode, IOOptionBits flags, + VDDetailedTimingRec ** detailed ); + virtual IOReturn setDetailedTiming( + IODisplayModeID mode, IOOptionBits options, + void * description, IOByteCount descripSize ); + virtual void getCurrentConfiguration( void ); + static const IOTVector * _undefinedSymbolHandler( void * self, + const char * libraryName, const char * symbolName ); + static bool _videoJackStateChangeHandler( void * target, void * ref, + IOService * newService, IONotifier * notifier ); + static void _avProbeAction( OSObject * p0, IOTimerEventSource * evtSrc ); + void displayI2CPower( bool enable ); + IOReturn ndrvSetPowerState( UInt32 newState ); + IOReturn ndrvUpdatePowerState( void ); + IOReturn ndrvSetDisplayPowerState( UInt32 newState ); + static IOReturn _probeAction( IONDRVFramebuffer * self, IOOptionBits options ); + bool searchOfflineMode( IODisplayModeID * offlineMode ); + IOReturn processConnectChange( uintptr_t * value ); + IOReturn setMirror( IONDRVFramebuffer * other ); + IOReturn setConnectionFlags( void ); + bool getOnlineState( void ); + IOReturn ndrvGetSetFeature( UInt32 feature, uintptr_t newValue, uintptr_t * currentValue ); + static IOReturn _doControl( IONDRVFramebuffer * self, UInt32 code, void * params ); + static IOReturn _doStatus( IONDRVFramebuffer * self, UInt32 code, void * params ); + static IOReturn extControl( OSObject * owner, void * code, void * params ); + static IOReturn extStatus( OSObject * owner, void * code, void * params ); + IOReturn createI2C( void ); + void setInfoProperties( void ); + +public: + virtual IOReturn doControl( UInt32 code, void * params ); + virtual IOReturn doStatus( UInt32 code, void * params ); + +public: + + virtual IOService * probe( IOService * provider, + SInt32 * score ); + + virtual bool start( IOService * provider ); + + virtual void stop( IOService * provider ); + + virtual void free( void ); + + virtual IOReturn setProperties( OSObject * properties ); + + virtual IOReturn requestProbe( IOOptionBits options ); + + virtual IOReturn enableController( void ); + + virtual IODeviceMemory * makeSubRange( IOPhysicalAddress start, + IOPhysicalLength length ); + virtual IODeviceMemory * getApertureRange( IOPixelAperture aperture ); + virtual IODeviceMemory * getVRAMRange( void ); + + virtual IODeviceMemory * findVRAM( void ); + + virtual bool isConsoleDevice( void ); + + virtual const IOTVector * undefinedSymbolHandler( const char * libraryName, + const char * symbolName ); + + virtual const char * getPixelFormats( void ); + + // Array of supported display modes + virtual IOItemCount getDisplayModeCount( void ); + virtual IOReturn getDisplayModes( IODisplayModeID * allDisplayModes ); + + // Info about a display mode + virtual IOReturn getInformationForDisplayMode( IODisplayModeID displayMode, + IODisplayModeInformation * info ); + + // Mask of pixel formats available in mode and depth + virtual UInt64 getPixelFormatsForDisplayMode( IODisplayModeID displayMode, + IOIndex depth ); + + virtual IOReturn getPixelInformation( + IODisplayModeID displayMode, IOIndex depth, + IOPixelAperture aperture, IOPixelInformation * pixelInfo ); + + // Framebuffer info + + // Current display mode and depth + virtual IOReturn getCurrentDisplayMode( IODisplayModeID * displayMode, + IOIndex * depth ); + + // Set display mode and depth + virtual IOReturn setDisplayMode( IODisplayModeID displayMode, + IOIndex depth ); + + // For pages + virtual IOReturn setApertureEnable( IOPixelAperture aperture, + IOOptionBits enable ); + + virtual IOReturn setStartupDisplayMode( IODisplayModeID displayMode, + IOIndex depth ); + virtual IOReturn getStartupDisplayMode( IODisplayModeID * displayMode, + IOIndex * depth ); + + //// CLUTs + + virtual IOReturn setCLUTWithEntries( IOColorEntry * colors, UInt32 index, + UInt32 numEntries, IOOptionBits options ); + + //// Gamma + + virtual IOReturn setGammaTable( UInt32 channelCount, UInt32 dataCount, + UInt32 dataWidth, void * data ); + + //// Display mode timing information + + virtual IOReturn getTimingInfoForDisplayMode( IODisplayModeID displayMode, + IOTimingInformation * info ); + + //// Detailed timing information + + virtual IOReturn validateDetailedTiming( + void * description, IOByteCount descripSize ); + + virtual IOReturn setDetailedTimings( OSArray * array ); + + //// Controller attributes + + virtual IOReturn setAttribute( IOSelect attribute, uintptr_t value ); + virtual IOReturn getAttribute( IOSelect attribute, uintptr_t * value ); + + //// Connections + + virtual IOItemCount getConnectionCount( void ); + + virtual IOReturn getAttributeForConnection( IOIndex connectIndex, + IOSelect attribute, uintptr_t * value ); + + virtual IOReturn setAttributeForConnection( IOIndex connectIndex, + IOSelect attribute, uintptr_t info ); + + // Apple sensing + + virtual IOReturn getAppleSense( IOIndex connectIndex, + UInt32 * senseType, + UInt32 * primary, + UInt32 * extended, + UInt32 * displayType ); + + virtual IOReturn connectFlags( IOIndex connectIndex, + IODisplayModeID displayMode, IOOptionBits * flags ); + + //// IOHighLevelDDCSense + + virtual bool hasDDCConnect( IOIndex connectIndex ); + virtual IOReturn getDDCBlock( IOIndex connectIndex, UInt32 blockNumber, + IOSelect blockType, IOOptionBits options, + UInt8 * data, IOByteCount * length ); + + //// Interrupts + + virtual IOReturn registerForInterruptType( IOSelect interruptType, + IOFBInterruptProc proc, OSObject * target, void * ref, + void ** interruptRef ); + virtual IOReturn unregisterInterrupt( void * interruptRef ); + virtual IOReturn setInterruptState( void * interruptRef, UInt32 state ); + + //// HW Cursors + + virtual IOReturn setCursorImage( void * cursorImage ); + virtual IOReturn setCursorState( SInt32 x, SInt32 y, bool visible ); + + //// I2C calls + + virtual IOReturn doI2CRequest( UInt32 bus, IOI2CBusTiming * timing, IOI2CRequest * request ); + + //// VSL calls + + static OSStatus VSLNewInterruptService( + void * entryID, + UInt32 serviceType, + _VSLService ** serviceID ); + static OSStatus VSLDisposeInterruptService( _VSLService * serviceID ); + static OSStatus VSLDoInterruptService( _VSLService * serviceID ); + static Boolean VSLPrepareCursorForHardwareCursor( + void * cursorRef, + IOHardwareCursorDescriptor * hwDesc, + IOHardwareCursorInfo * hwCursorInfo ); +}; + +#endif /* ! _IOKIT_IONDRVFRAMEBUFFER_H */ + + Index: branches/azimutz/Cleancut/i386/include/IOKit/IODeviceMemory.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/IODeviceMemory.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/IODeviceMemory.h (revision 885) @@ -0,0 +1,98 @@ +/* + * 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_IODEVICEMEMORY_H +#define _IOKIT_IODEVICEMEMORY_H + +#include <IOKit/IOMemoryDescriptor.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 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 address The physical address of the first byte in the memory. + @param withLength The length of memory. + @result Returns the created IODeviceMemory on success, to be released by the caller, or zero on failure. */ + + static 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 IODeviceMemory * withSubRange( + IODeviceMemory * of, + IOPhysicalAddress offset, + IOPhysicalLength length ); +}; + +#endif /* ! _IOKIT_IODEVICEMEMORY_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/IOInterleavedMemoryDescriptor.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/IOInterleavedMemoryDescriptor.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/IOInterleavedMemoryDescriptor.h (revision 885) @@ -0,0 +1,122 @@ +/* + * 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> + +/*! @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(); + +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 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 ); + +/*! @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); + +/*! @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); +}; + +#endif /* !_IOINTERLEAVEDMEMORYDESCRIPTOR_H */ Index: branches/azimutz/Cleancut/i386/include/IOKit/IOServicePM.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/IOServicePM.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/IOServicePM.h (revision 885) @@ -0,0 +1,42 @@ +/* + * 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_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 */ Index: branches/azimutz/Cleancut/i386/include/IOKit/i2c/IOI2CInterface.h =================================================================== --- branches/azimutz/Cleancut/i386/include/IOKit/i2c/IOI2CInterface.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/IOKit/i2c/IOI2CInterface.h (revision 885) @@ -0,0 +1,262 @@ +/* + * 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_IOI2CINTERFACE_H +#define _IOKIT_IOI2CINTERFACE_H + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +typedef struct IOI2CRequest IOI2CRequest; +typedef struct IOI2CBuffer IOI2CBuffer; + +typedef void (*IOI2CRequestCompletion) (IOI2CRequest * request); + +// IOI2CRequest.sendTransactionType, IOI2CRequest.replyTransactionType +enum { + kIOI2CNoTransactionType = 0, + kIOI2CSimpleTransactionType = 1, + kIOI2CDDCciReplyTransactionType = 2, + kIOI2CCombinedTransactionType = 3, + kIOI2CDisplayPortNativeTransactionType = 4 +}; + +// IOI2CRequest.commFlags +enum { + kIOI2CUseSubAddressCommFlag = 0x00000002 +}; + +/*! + * @struct IOI2CRequest + * @abstract A structure defining an I2C bus transaction. + * @discussion This structure is used to request an I2C transaction consisting of a send (write) to and reply (read) from a device, either of which is optional, to be carried out atomically on an I2C bus. + * @field __reservedA Set to zero. + * @field result The result of the transaction. Common errors are kIOReturnNoDevice if there is no device responding at the given address, kIOReturnUnsupportedMode if the type of transaction is unsupported on the requested bus. + * @field completion A completion routine to be executed when the request completes. If NULL is passed, the request is synchronous, otherwise it may execute asynchronously. + * @field commFlags Flags that modify the I2C transaction type. The following flags are defined:<br> + * kIOI2CUseSubAddressCommFlag Transaction includes a subaddress.<br> + * @field minReplyDelay Minimum delay as absolute time between send and reply transactions. + * @field sendAddress I2C address to write. + * @field sendSubAddress I2C subaddress to write. + * @field __reservedB Set to zero. + * @field sendTransactionType The following types of transaction are defined for the send part of the request:<br> + * kIOI2CNoTransactionType No send transaction to perform. <br> + * kIOI2CSimpleTransactionType Simple I2C message. <br> + * kIOI2CCombinedTransactionType Combined format I2C R/~W transaction. <br> + * @field sendBuffer Pointer to the send buffer. + * @field sendBytes Number of bytes to send. Set to actual bytes sent on completion of the request. + * @field replyAddress I2C Address from which to read. + * @field replySubAddress I2C Address from which to read. + * @field __reservedC Set to zero. + * @field replyTransactionType The following types of transaction are defined for the reply part of the request:<br> + * kIOI2CNoTransactionType No reply transaction to perform. <br> + * kIOI2CSimpleTransactionType Simple I2C message. <br> + * kIOI2CDDCciReplyTransactionType DDC/ci message (with embedded length). See VESA DDC/ci specification. <br> + * kIOI2CCombinedTransactionType Combined format I2C R/~W transaction. <br> + * @field replyBuffer Pointer to the reply buffer. + * @field replyBytes Max bytes to reply (size of replyBuffer). Set to actual bytes received on completion of the request. + * @field __reservedD Set to zero. + */ + +#pragma pack(push, 4) +struct IOI2CRequest +{ + IOOptionBits sendTransactionType; + IOOptionBits replyTransactionType; + uint32_t sendAddress; + uint32_t replyAddress; + uint8_t sendSubAddress; + uint8_t replySubAddress; + uint8_t __reservedA[2]; + + uint64_t minReplyDelay; + + IOReturn result; + IOOptionBits commFlags; + +#if defined(__LP64__) + uint32_t __padA; +#else + vm_address_t sendBuffer; +#endif + uint32_t sendBytes; + + uint32_t __reservedB[2]; + +#if defined(__LP64__) + uint32_t __padB; +#else + vm_address_t replyBuffer; +#endif + uint32_t replyBytes; + + IOI2CRequestCompletion completion; +#if !defined(__LP64__) + uint32_t __padC[5]; +#else + vm_address_t sendBuffer; + vm_address_t replyBuffer; +#endif + + uint32_t __reservedC[10]; +#ifdef __ppc__ + uint32_t __reservedD; +#endif +}; +#pragma pack(pop) + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#define kIOI2CInterfaceClassName "IOI2CInterface" + +#define kIOI2CInterfaceIDKey "IOI2CInterfaceID" +#define kIOI2CBusTypeKey "IOI2CBusType" +#define kIOI2CTransactionTypesKey "IOI2CTransactionTypes" +#define kIOI2CSupportedCommFlagsKey "IOI2CSupportedCommFlags" + +#define kIOFBI2CInterfaceInfoKey "IOFBI2CInterfaceInfo" +#define kIOFBI2CInterfaceIDsKey "IOFBI2CInterfaceIDs" + +// kIOI2CBusTypeKey values +enum { + kIOI2CBusTypeI2C = 1, + kIOI2CBusTypeDisplayPort = 2 +}; + +/*! + * @struct IOI2CBusTiming + * @abstract A structure defining low level timing for an I2C bus. + * @discussion This structure is used to specify timeouts and pulse widths for an I2C bus implementation. + * @field bitTimeout Maximum time a slave can delay (by pulling the clock line low) a single bit response. + * @field byteTimeout Maximum time a slave can delay (by pulling the clock line low) the first bit of a byte response. + * @field acknowledgeTimeout Maximum time to wait for a slave to respond with an ACK after writing a byte. + * @field startTimeout Maximum time to wait for a slave to respond after a start signal. + * @field riseFallTime Time to wait after any change in output signal. + * @field __reservedA Set to zero. + */ + +struct IOI2CBusTiming +{ + AbsoluteTime bitTimeout; + AbsoluteTime byteTimeout; + AbsoluteTime acknowledgeTimeout; + AbsoluteTime startTimeout; + AbsoluteTime holdTime; + AbsoluteTime riseFallTime; + UInt32 __reservedA[8]; +}; +typedef struct IOI2CBusTiming IOI2CBusTiming; + +#ifndef KERNEL + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +// options for IOFBCopyI2CInterfaceForBus() +enum { + kIOI2CBusNumberMask = 0x000000ff +}; + + +/*! @function IOFBGetI2CInterfaceCount + @abstract Returns a count of I2C interfaces available associated with an IOFramebuffer instance. + @discussion Returns a count of I2C interfaces available associated with an IOFramebuffer instance. + @param framebuffer The io_service_t of an IOFramebuffer instance. CoreGraphics will provide this for a CGDisplay with the CGDisplayIOServicePort() call. + @param count Interface count is returned. + @result An IOReturn code. */ + +IOReturn IOFBGetI2CInterfaceCount( io_service_t framebuffer, IOItemCount * count ); + +/*! @function IOFBCopyI2CInterfaceForBus + @abstract Returns an instance of an I2C bus interface, associated with an IOFramebuffer instance / bus index pair. + @discussion Some graphics devices will allow access to an I2C bus routed through a display connector in order to control external devices on that bus. This function returns an instance of an I2C bus interface, associated with an IOFramebuffer instance / bus index pair. The number of I2C buses is available from the IOFBGetI2CInterfaceCount() call. The interface may be used with the IOI2CInterfaceOpen/Close/SendRequest() calls to carry out I2C transactions on that bus. Not all graphics devices support this functionality. + @param bus The zero based index of the bus on the requested framebuffer. + @param interface The interface instance is returned. The caller should release this instance with IOObjectRelease(). + @result An IOReturn code. */ + +IOReturn IOFBCopyI2CInterfaceForBus( io_service_t framebuffer, IOOptionBits bus, io_service_t * interface ); + +typedef struct IOI2CConnect * IOI2CConnectRef; /* struct IOI2CConnect is opaque */ + +IOReturn IOI2CCopyInterfaceForID( CFTypeRef identifier, io_service_t * interface ); + +/*! @function IOI2CInterfaceOpen + @abstract Opens an instance of an I2C bus interface, allowing I2C requests to be made. + @discussion An instance of an I2C bus interface, obtained by IOFBCopyI2CInterfaceForBus, is opened with this function allowing I2C requests to be made. + @param interface An I2C bus interface (see IOFBCopyI2CInterfaceForBus). The interface may be released after this call is made. + @param options Pass kNilOptions. + @param connect The opaque IOI2CConnectRef is returned, for use with IOI2CSendRequest() and IOI2CInterfaceClose(). + @result An IOReturn code. */ + +IOReturn IOI2CInterfaceOpen( io_service_t interface, IOOptionBits options, + IOI2CConnectRef * connect ); + +/*! @function IOI2CInterfaceClose + @abstract Closes an IOI2CConnectRef. + @discussion Frees the resources associated with an IOI2CConnectRef. + @param connect The opaque IOI2CConnectRef returned by IOI2CInterfaceOpen(). + @param options Pass kNilOptions. + @result An IOReturn code. */ + +IOReturn IOI2CInterfaceClose( IOI2CConnectRef connect, IOOptionBits options ); + +/*! @function IOI2CSendRequest + @abstract Carries out the I2C transaction specified by an IOI2CRequest structure. + @discussion Frees the resources associated with an IOI2CConnectRef. + @param connect The opaque IOI2CConnectRef returned by IOI2CInterfaceOpen(). + @param options Pass kNilOptions. + @param request Pass a pointer to a IOI2CRequest structure describing the request. If an asynchronous request (with a non-NULL completion routine) the request structure must be valid for the life of the request. + @result An IOReturn code reflecting only the result of starting the transaction. If the result of IOI2CSendRequest() is kIOReturnSuccess, the I2C transaction result is returned in the result field of the request structure. */ + +IOReturn IOI2CSendRequest( IOI2CConnectRef connect, IOOptionBits options, + IOI2CRequest * request ); + +#else + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*! @class IOI2CInterface + @abstract The base class for an I2C bus interface. + @discussion The IOI2CInterface base class defines an I2C bus interface. Not useful for developers. */ + +class IOI2CInterface : public IOService +{ + OSDeclareDefaultStructors(IOI2CInterface) + +protected: + UInt64 fID; + +public: + IOReturn newUserClient( task_t owningTask, + void * security_id, + UInt32 type, + IOUserClient ** handler ); + + bool registerI2C( UInt64 id ); + + virtual IOReturn startIO( IOI2CRequest * request ) = 0; +}; + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#endif /* KERNEL */ + +#endif /* ! _IOKIT_IOI2CINTERFACE_H */ + Index: branches/azimutz/Cleancut/i386/include/hfs/hfs_encodings.h =================================================================== --- branches/azimutz/Cleancut/i386/include/hfs/hfs_encodings.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/hfs/hfs_encodings.h (revision 885) @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2000-2002, 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@ + */ +/* + * Copyright (c) 1997-2000 Apple Computer, Inc. All Rights Reserved + */ + +#ifndef _HFS_ENCODINGS_H_ +#define _HFS_ENCODINGS_H_ + +#include <sys/appleapiopts.h> + +#ifdef __APPLE_API_UNSTABLE + +#define CTL_HFS_NAMES { \ + { 0, 0 }, \ + { "encodingbias", CTLTYPE_INT }, \ +} + +/* + * HFS Filename Encoding Converters Interface + * + * Private Interface for adding hfs filename + * encoding converters. These are not needed + * for HFS Plus volumes (since they already + * have Unicode filenames). + * + * Used by HFS Encoding Converter Kernel Modules + * (like HFS_Japanese.kmod) to register their + * encoding conversion routines. + */ + +typedef int (* hfs_to_unicode_func_t)(const Str31 hfs_str, UniChar *uni_str, + u_int32_t maxCharLen, u_int32_t *usedCharLen); + +typedef int (* unicode_to_hfs_func_t)(UniChar *uni_str, u_int32_t unicodeChars, + Str31 hfs_str); + + +int hfs_addconverter(int kmod_id, u_int32_t encoding, + hfs_to_unicode_func_t get_unicode, + unicode_to_hfs_func_t get_hfsname); + +int hfs_remconverter(int kmod_id, u_int32_t encoding); + +#endif /* __APPLE_API_UNSTABLE */ + +#endif /* ! _HFS_ENCODINGS_H_ */ Index: branches/azimutz/Cleancut/i386/include/hfs/hfs_mount.h =================================================================== --- branches/azimutz/Cleancut/i386/include/hfs/hfs_mount.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/hfs/hfs_mount.h (revision 885) @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2000-2007 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) 1997-2002 Apple Computer, Inc. All Rights Reserved + * + */ + +#ifndef _HFS_MOUNT_H_ +#define _HFS_MOUNT_H_ + +#include <sys/appleapiopts.h> + +#include <sys/mount.h> +#include <sys/time.h> + +/* + * Arguments to mount HFS-based filesystems + */ + +#define OVERRIDE_UNKNOWN_PERMISSIONS 0 + +#define UNKNOWNUID ((uid_t)99) +#define UNKNOWNGID ((gid_t)99) +#define UNKNOWNPERMISSIONS (S_IRWXU | S_IROTH | S_IXOTH) /* 705 */ + +#ifdef __APPLE_API_UNSTABLE +struct hfs_mount_args { + char *fspec; /* block special device to mount */ + uid_t hfs_uid; /* uid that owns hfs files (standard HFS only) */ + gid_t hfs_gid; /* gid that owns hfs files (standard HFS only) */ + mode_t hfs_mask; /* mask to be applied for hfs perms (standard HFS only) */ + u_int32_t hfs_encoding; /* encoding for this volume (standard HFS only) */ + struct timezone hfs_timezone; /* user time zone info (standard HFS only) */ + int flags; /* mounting flags, see below */ + int journal_tbuffer_size; /* size in bytes of the journal transaction buffer */ + int journal_flags; /* flags to pass to journal_open/create */ + int journal_disable; /* don't use journaling (potentially dangerous) */ +}; + +#define HFSFSMNT_NOXONFILES 0x1 /* disable execute permissions for files */ +#define HFSFSMNT_WRAPPER 0x2 /* mount HFS wrapper (if it exists) */ +#define HFSFSMNT_EXTENDED_ARGS 0x4 /* indicates new fields after "flags" are valid */ + +/* + * Sysctl values for HFS + */ +#define HFS_ENCODINGBIAS 1 /* encoding matching CJK bias */ +#define HFS_EXTEND_FS 2 +#define HFS_ENCODINGHINT 3 /* guess encoding for string */ +#define HFS_ENABLE_JOURNALING 0x082969 +#define HFS_DISABLE_JOURNALING 0x031272 +#define HFS_GET_JOURNAL_INFO 0x6a6e6c69 +#define HFS_SET_PKG_EXTENSIONS 0x121031 +#define HFS_REPLAY_JOURNAL 0x6a6e6c72 + +#endif /* __APPLE_API_UNSTABLE */ + +#endif /* ! _HFS_MOUNT_H_ */ Index: branches/azimutz/Cleancut/i386/include/hfs/hfs_format.h =================================================================== --- branches/azimutz/Cleancut/i386/include/hfs/hfs_format.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/hfs/hfs_format.h (revision 885) @@ -0,0 +1,785 @@ +/* + * Copyright (c) 2000-2009 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 __HFS_FORMAT__ +#define __HFS_FORMAT__ + +#include <sys/types.h> + +/* + * hfs_format.c + * + * This file describes the on-disk format for HFS and HFS Plus volumes. + * The HFS Plus volume format is desciibed in detail in Apple Technote 1150. + * + * http://developer.apple.com/technotes/tn/tn1150.html + * + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* some on-disk hfs structures have 68K alignment (misaligned) */ + +/* Signatures used to differentiate between HFS and HFS Plus volumes */ +enum { + kHFSSigWord = 0x4244, /* 'BD' in ASCII */ + kHFSPlusSigWord = 0x482B, /* 'H+' in ASCII */ + kHFSXSigWord = 0x4858, /* 'HX' in ASCII */ + + kHFSPlusVersion = 0x0004, /* 'H+' volumes are version 4 only */ + kHFSXVersion = 0x0005, /* 'HX' volumes start with version 5 */ + + kHFSPlusMountVersion = 0x31302E30, /* '10.0' for Mac OS X */ + kHFSJMountVersion = 0x4846534a, /* 'HFSJ' for journaled HFS+ on OS X */ + kFSKMountVersion = 0x46534b21 /* 'FSK!' for failed journal replay */ +}; + + +/* + * Mac OS X has two special directories on HFS+ volumes for hardlinked files + * and hardlinked directories as well as for open-unlinked files. + * + * These directories and their contents are not exported from the filesystem + * under Mac OS X. + */ +#define HFSPLUSMETADATAFOLDER "\xE2\x90\x80\xE2\x90\x80\xE2\x90\x80\xE2\x90\x80HFS+ Private Data" +#define HFSPLUS_DIR_METADATA_FOLDER ".HFS+ Private Directory Data\xd" + +/* + * Files in the "HFS+ Private Data" folder have one of the following prefixes + * followed by a decimal number (no leading zeros) for the file ID. + * + * Note: Earlier version of Mac OS X used a 32 bit random number for the link + * ref number instead of the file id. + * + * e.g. iNode7182000 and temp3296 + */ +#define HFS_INODE_PREFIX "iNode" +#define HFS_DELETE_PREFIX "temp" + +/* + * Files in the ".HFS+ Private Directory Data" folder have the following + * prefix followed by a decimal number (no leading zeros) for the file ID. + * + * e.g. dir_555 + */ +#define HFS_DIRINODE_PREFIX "dir_" + +/* + * Hardlink inodes save the head of the link chain in + * an extended attribute named FIRST_LINK_XATTR_NAME. + * The attribute data is the decimal value in ASCII + * of the cnid for the first link in the chain. + * + * This extended attribute is private (i.e. its not + * exported in the getxattr/listxattr POSIX APIs). + */ +#define FIRST_LINK_XATTR_NAME "com.apple.system.hfs.firstlink" +#define FIRST_LINK_XATTR_REC_SIZE (sizeof(HFSPlusAttrData) - 2 + 12) + +/* + * The name space ID for generating an HFS volume UUID + * + * B3E20F39-F292-11D6-97A4-00306543ECAC + */ +#define HFS_UUID_NAMESPACE_ID "\xB3\xE2\x0F\x39\xF2\x92\x11\xD6\x97\xA4\x00\x30\x65\x43\xEC\xAC" + +/* + * Indirect link files (hard links) have the following type/creator. + */ +enum { + kHardLinkFileType = 0x686C6E6B, /* 'hlnk' */ + kHFSPlusCreator = 0x6866732B /* 'hfs+' */ +}; + + +/* + * File type and creator for symbolic links + */ +enum { + kSymLinkFileType = 0x736C6E6B, /* 'slnk' */ + kSymLinkCreator = 0x72686170 /* 'rhap' */ +}; + + +#ifndef _HFSUNISTR255_DEFINED_ +#define _HFSUNISTR255_DEFINED_ +/* Unicode strings are used for HFS Plus file and folder names */ +struct HFSUniStr255 { + u_int16_t length; /* number of unicode characters */ + u_int16_t unicode[255]; /* unicode characters */ +} __attribute__((aligned(2), packed)); +typedef struct HFSUniStr255 HFSUniStr255; +typedef const HFSUniStr255 *ConstHFSUniStr255Param; +#endif /* _HFSUNISTR255_DEFINED_ */ + +enum { + kHFSMaxVolumeNameChars = 27, + kHFSMaxFileNameChars = 31, + kHFSPlusMaxFileNameChars = 255 +}; + + +/* Extent overflow file data structures */ + +/* HFS Extent key */ +struct HFSExtentKey { + u_int8_t keyLength; /* length of key, excluding this field */ + u_int8_t forkType; /* 0 = data fork, FF = resource fork */ + u_int32_t fileID; /* file ID */ + u_int16_t startBlock; /* first file allocation block number in this extent */ +} __attribute__((aligned(2), packed)); +typedef struct HFSExtentKey HFSExtentKey; + +/* HFS Plus Extent key */ +struct HFSPlusExtentKey { + u_int16_t keyLength; /* length of key, excluding this field */ + u_int8_t forkType; /* 0 = data fork, FF = resource fork */ + u_int8_t pad; /* make the other fields align on 32-bit boundary */ + u_int32_t fileID; /* file ID */ + u_int32_t startBlock; /* first file allocation block number in this extent */ +} __attribute__((aligned(2), packed)); +typedef struct HFSPlusExtentKey HFSPlusExtentKey; + +/* Number of extent descriptors per extent record */ +enum { + kHFSExtentDensity = 3, + kHFSPlusExtentDensity = 8 +}; + +/* HFS extent descriptor */ +struct HFSExtentDescriptor { + u_int16_t startBlock; /* first allocation block */ + u_int16_t blockCount; /* number of allocation blocks */ +} __attribute__((aligned(2), packed)); +typedef struct HFSExtentDescriptor HFSExtentDescriptor; + +/* HFS Plus extent descriptor */ +struct HFSPlusExtentDescriptor { + u_int32_t startBlock; /* first allocation block */ + u_int32_t blockCount; /* number of allocation blocks */ +} __attribute__((aligned(2), packed)); +typedef struct HFSPlusExtentDescriptor HFSPlusExtentDescriptor; + +/* HFS extent record */ +typedef HFSExtentDescriptor HFSExtentRecord[3]; + +/* HFS Plus extent record */ +typedef HFSPlusExtentDescriptor HFSPlusExtentRecord[8]; + + +/* Finder information */ +struct FndrFileInfo { + u_int32_t fdType; /* file type */ + u_int32_t fdCreator; /* file creator */ + u_int16_t fdFlags; /* Finder flags */ + struct { + int16_t v; /* file's location */ + int16_t h; + } fdLocation; + int16_t opaque; +} __attribute__((aligned(2), packed)); +typedef struct FndrFileInfo FndrFileInfo; + +struct FndrDirInfo { + struct { /* folder's window rectangle */ + int16_t top; + int16_t left; + int16_t bottom; + int16_t right; + } frRect; + unsigned short frFlags; /* Finder flags */ + struct { + u_int16_t v; /* folder's location */ + u_int16_t h; + } frLocation; + int16_t opaque; +} __attribute__((aligned(2), packed)); +typedef struct FndrDirInfo FndrDirInfo; + +struct FndrOpaqueInfo { + int8_t opaque[16]; +} __attribute__((aligned(2), packed)); +typedef struct FndrOpaqueInfo FndrOpaqueInfo; + + +/* HFS Plus Fork data info - 80 bytes */ +struct HFSPlusForkData { + u_int64_t logicalSize; /* fork's logical size in bytes */ + u_int32_t clumpSize; /* fork's clump size in bytes */ + u_int32_t totalBlocks; /* total blocks used by this fork */ + HFSPlusExtentRecord extents; /* initial set of extents */ +} __attribute__((aligned(2), packed)); +typedef struct HFSPlusForkData HFSPlusForkData; + + +/* Mac OS X has 16 bytes worth of "BSD" info. + * + * Note: Mac OS 9 implementations and applications + * should preserve, but not change, this information. + */ +struct HFSPlusBSDInfo { + u_int32_t ownerID; /* user-id of owner or hard link chain previous link */ + u_int32_t groupID; /* group-id of owner or hard link chain next link */ + u_int8_t adminFlags; /* super-user changeable flags */ + u_int8_t ownerFlags; /* owner changeable flags */ + u_int16_t fileMode; /* file type and permission bits */ + union { + u_int32_t iNodeNum; /* indirect node number (hard links only) */ + u_int32_t linkCount; /* links that refer to this indirect node */ + u_int32_t rawDevice; /* special file device (FBLK and FCHR only) */ + } special; +} __attribute__((aligned(2), packed)); +typedef struct HFSPlusBSDInfo HFSPlusBSDInfo; + +/* + * Hardlink "links" resolve to an inode + * and the actual uid/gid comes from that + * inode. + * + * We repurpose the links's uid/gid fields + * for the hardlink link chain. The chain + * consists of a doubly linked list of file + * ids. + */ + +#define hl_firstLinkID reserved1 /* Valid only if HasLinkChain flag is set (indirect nodes only) */ + +#define hl_prevLinkID bsdInfo.ownerID /* Valid only if HasLinkChain flag is set */ +#define hl_nextLinkID bsdInfo.groupID /* Valid only if HasLinkChain flag is set */ + +#define hl_linkReference bsdInfo.special.iNodeNum +#define hl_linkCount bsdInfo.special.linkCount + + +/* Catalog file data structures */ + +enum { + kHFSRootParentID = 1, /* Parent ID of the root folder */ + kHFSRootFolderID = 2, /* Folder ID of the root folder */ + kHFSExtentsFileID = 3, /* File ID of the extents file */ + kHFSCatalogFileID = 4, /* File ID of the catalog file */ + kHFSBadBlockFileID = 5, /* File ID of the bad allocation block file */ + kHFSAllocationFileID = 6, /* File ID of the allocation file (HFS Plus only) */ + kHFSStartupFileID = 7, /* File ID of the startup file (HFS Plus only) */ + kHFSAttributesFileID = 8, /* File ID of the attribute file (HFS Plus only) */ + kHFSAttributeDataFileID = 13, /* Used in Mac OS X runtime for extent based attributes */ + /* kHFSAttributeDataFileID is never stored on disk. */ + kHFSRepairCatalogFileID = 14, /* Used when rebuilding Catalog B-tree */ + kHFSBogusExtentFileID = 15, /* Used for exchanging extents in extents file */ + kHFSFirstUserCatalogNodeID = 16 +}; + +/* HFS catalog key */ +struct HFSCatalogKey { + u_int8_t keyLength; /* key length (in bytes) */ + u_int8_t reserved; /* reserved (set to zero) */ + u_int32_t parentID; /* parent folder ID */ + u_int8_t nodeName[kHFSMaxFileNameChars + 1]; /* catalog node name */ +} __attribute__((aligned(2), packed)); +typedef struct HFSCatalogKey HFSCatalogKey; + +/* HFS Plus catalog key */ +struct HFSPlusCatalogKey { + u_int16_t keyLength; /* key length (in bytes) */ + u_int32_t parentID; /* parent folder ID */ + HFSUniStr255 nodeName; /* catalog node name */ +} __attribute__((aligned(2), packed)); +typedef struct HFSPlusCatalogKey HFSPlusCatalogKey; + +/* Catalog record types */ +enum { + /* HFS Catalog Records */ + kHFSFolderRecord = 0x0100, /* Folder record */ + kHFSFileRecord = 0x0200, /* File record */ + kHFSFolderThreadRecord = 0x0300, /* Folder thread record */ + kHFSFileThreadRecord = 0x0400, /* File thread record */ + + /* HFS Plus Catalog Records */ + kHFSPlusFolderRecord = 1, /* Folder record */ + kHFSPlusFileRecord = 2, /* File record */ + kHFSPlusFolderThreadRecord = 3, /* Folder thread record */ + kHFSPlusFileThreadRecord = 4 /* File thread record */ +}; + + +/* Catalog file record flags */ +enum { + kHFSFileLockedBit = 0x0000, /* file is locked and cannot be written to */ + kHFSFileLockedMask = 0x0001, + + kHFSThreadExistsBit = 0x0001, /* a file thread record exists for this file */ + kHFSThreadExistsMask = 0x0002, + + kHFSHasAttributesBit = 0x0002, /* object has extended attributes */ + kHFSHasAttributesMask = 0x0004, + + kHFSHasSecurityBit = 0x0003, /* object has security data (ACLs) */ + kHFSHasSecurityMask = 0x0008, + + kHFSHasFolderCountBit = 0x0004, /* only for HFSX, folder maintains a separate sub-folder count */ + kHFSHasFolderCountMask = 0x0010, /* (sum of folder records and directory hard links) */ + + kHFSHasLinkChainBit = 0x0005, /* has hardlink chain (inode or link) */ + kHFSHasLinkChainMask = 0x0020, + + kHFSHasChildLinkBit = 0x0006, /* folder has a child that's a dir link */ + kHFSHasChildLinkMask = 0x0040 +}; + + +/* HFS catalog folder record - 70 bytes */ +struct HFSCatalogFolder { + int16_t recordType; /* == kHFSFolderRecord */ + u_int16_t flags; /* folder flags */ + u_int16_t valence; /* folder valence */ + u_int32_t folderID; /* folder ID */ + u_int32_t createDate; /* date and time of creation */ + u_int32_t modifyDate; /* date and time of last modification */ + u_int32_t backupDate; /* date and time of last backup */ + FndrDirInfo userInfo; /* Finder information */ + FndrOpaqueInfo finderInfo; /* additional Finder information */ + u_int32_t reserved[4]; /* reserved - initialized as zero */ +} __attribute__((aligned(2), packed)); +typedef struct HFSCatalogFolder HFSCatalogFolder; + +/* HFS Plus catalog folder record - 88 bytes */ +struct HFSPlusCatalogFolder { + int16_t recordType; /* == kHFSPlusFolderRecord */ + u_int16_t flags; /* file flags */ + u_int32_t valence; /* folder's item count */ + u_int32_t folderID; /* folder ID */ + u_int32_t createDate; /* date and time of creation */ + u_int32_t contentModDate; /* date and time of last content modification */ + u_int32_t attributeModDate; /* date and time of last attribute modification */ + u_int32_t accessDate; /* date and time of last access (MacOS X only) */ + u_int32_t backupDate; /* date and time of last backup */ + HFSPlusBSDInfo bsdInfo; /* permissions (for MacOS X) */ + FndrDirInfo userInfo; /* Finder information */ + FndrOpaqueInfo finderInfo; /* additional Finder information */ + u_int32_t textEncoding; /* hint for name conversions */ + u_int32_t folderCount; /* number of enclosed folders, active when HasFolderCount is set */ +} __attribute__((aligned(2), packed)); +typedef struct HFSPlusCatalogFolder HFSPlusCatalogFolder; + +/* HFS catalog file record - 102 bytes */ +struct HFSCatalogFile { + int16_t recordType; /* == kHFSFileRecord */ + u_int8_t flags; /* file flags */ + int8_t fileType; /* file type (unused ?) */ + FndrFileInfo userInfo; /* Finder information */ + u_int32_t fileID; /* file ID */ + u_int16_t dataStartBlock; /* not used - set to zero */ + int32_t dataLogicalSize; /* logical EOF of data fork */ + int32_t dataPhysicalSize; /* physical EOF of data fork */ + u_int16_t rsrcStartBlock; /* not used - set to zero */ + int32_t rsrcLogicalSize; /* logical EOF of resource fork */ + int32_t rsrcPhysicalSize; /* physical EOF of resource fork */ + u_int32_t createDate; /* date and time of creation */ + u_int32_t modifyDate; /* date and time of last modification */ + u_int32_t backupDate; /* date and time of last backup */ + FndrOpaqueInfo finderInfo; /* additional Finder information */ + u_int16_t clumpSize; /* file clump size (not used) */ + HFSExtentRecord dataExtents; /* first data fork extent record */ + HFSExtentRecord rsrcExtents; /* first resource fork extent record */ + u_int32_t reserved; /* reserved - initialized as zero */ +} __attribute__((aligned(2), packed)); +typedef struct HFSCatalogFile HFSCatalogFile; + +/* HFS Plus catalog file record - 248 bytes */ +struct HFSPlusCatalogFile { + int16_t recordType; /* == kHFSPlusFileRecord */ + u_int16_t flags; /* file flags */ + u_int32_t reserved1; /* reserved - initialized as zero */ + u_int32_t fileID; /* file ID */ + u_int32_t createDate; /* date and time of creation */ + u_int32_t contentModDate; /* date and time of last content modification */ + u_int32_t attributeModDate; /* date and time of last attribute modification */ + u_int32_t accessDate; /* date and time of last access (MacOS X only) */ + u_int32_t backupDate; /* date and time of last backup */ + HFSPlusBSDInfo bsdInfo; /* permissions (for MacOS X) */ + FndrFileInfo userInfo; /* Finder information */ + FndrOpaqueInfo finderInfo; /* additional Finder information */ + u_int32_t textEncoding; /* hint for name conversions */ + u_int32_t reserved2; /* reserved - initialized as zero */ + + /* Note: these start on double long (64 bit) boundary */ + HFSPlusForkData dataFork; /* size and block data for data fork */ + HFSPlusForkData resourceFork; /* size and block data for resource fork */ +} __attribute__((aligned(2), packed)); +typedef struct HFSPlusCatalogFile HFSPlusCatalogFile; + +/* HFS catalog thread record - 46 bytes */ +struct HFSCatalogThread { + int16_t recordType; /* == kHFSFolderThreadRecord or kHFSFileThreadRecord */ + int32_t reserved[2]; /* reserved - initialized as zero */ + u_int32_t parentID; /* parent ID for this catalog node */ + u_int8_t nodeName[kHFSMaxFileNameChars + 1]; /* name of this catalog node */ +} __attribute__((aligned(2), packed)); +typedef struct HFSCatalogThread HFSCatalogThread; + +/* HFS Plus catalog thread record -- 264 bytes */ +struct HFSPlusCatalogThread { + int16_t recordType; /* == kHFSPlusFolderThreadRecord or kHFSPlusFileThreadRecord */ + int16_t reserved; /* reserved - initialized as zero */ + u_int32_t parentID; /* parent ID for this catalog node */ + HFSUniStr255 nodeName; /* name of this catalog node (variable length) */ +} __attribute__((aligned(2), packed)); +typedef struct HFSPlusCatalogThread HFSPlusCatalogThread; + +#ifdef __APPLE_API_UNSTABLE +/* + These are the types of records in the attribute B-tree. The values were + chosen so that they wouldn't conflict with the catalog record types. +*/ +enum { + kHFSPlusAttrInlineData = 0x10, /* attributes whose data fits in a b-tree node */ + kHFSPlusAttrForkData = 0x20, /* extent based attributes (data lives in extents) */ + kHFSPlusAttrExtents = 0x30 /* overflow extents for large attributes */ +}; + + +/* + HFSPlusAttrForkData + For larger attributes, whose value is stored in allocation blocks. + If the attribute has more than 8 extents, there will be additional + records (of type HFSPlusAttrExtents) for this attribute. +*/ +struct HFSPlusAttrForkData { + u_int32_t recordType; /* == kHFSPlusAttrForkData*/ + u_int32_t reserved; + HFSPlusForkData theFork; /* size and first extents of value*/ +} __attribute__((aligned(2), packed)); +typedef struct HFSPlusAttrForkData HFSPlusAttrForkData; + +/* + HFSPlusAttrExtents + This record contains information about overflow extents for large, + fragmented attributes. +*/ +struct HFSPlusAttrExtents { + u_int32_t recordType; /* == kHFSPlusAttrExtents*/ + u_int32_t reserved; + HFSPlusExtentRecord extents; /* additional extents*/ +} __attribute__((aligned(2), packed)); +typedef struct HFSPlusAttrExtents HFSPlusAttrExtents; + +/* + * Atrributes B-tree Data Record + * + * For small attributes, whose entire value is stored + * within a single B-tree record. + */ +struct HFSPlusAttrData { + u_int32_t recordType; /* == kHFSPlusAttrInlineData */ + u_int32_t reserved[2]; + u_int32_t attrSize; /* size of attribute data in bytes */ + u_int8_t attrData[2]; /* variable length */ +} __attribute__((aligned(2), packed)); +typedef struct HFSPlusAttrData HFSPlusAttrData; + + +/* HFSPlusAttrInlineData is obsolete use HFSPlusAttrData instead */ +struct HFSPlusAttrInlineData { + u_int32_t recordType; + u_int32_t reserved; + u_int32_t logicalSize; + u_int8_t userData[2]; +} __attribute__((aligned(2), packed)); +typedef struct HFSPlusAttrInlineData HFSPlusAttrInlineData; + + +/* A generic Attribute Record*/ +union HFSPlusAttrRecord { + u_int32_t recordType; + HFSPlusAttrInlineData inlineData; /* NOT USED */ + HFSPlusAttrData attrData; + HFSPlusAttrForkData forkData; + HFSPlusAttrExtents overflowExtents; +}; +typedef union HFSPlusAttrRecord HFSPlusAttrRecord; + +/* Attribute key */ +enum { kHFSMaxAttrNameLen = 127 }; +struct HFSPlusAttrKey { + u_int16_t keyLength; /* key length (in bytes) */ + u_int16_t pad; /* set to zero */ + u_int32_t fileID; /* file associated with attribute */ + u_int32_t startBlock; /* first allocation block number for extents */ + u_int16_t attrNameLen; /* number of unicode characters */ + u_int16_t attrName[kHFSMaxAttrNameLen]; /* attribute name (Unicode) */ +} __attribute__((aligned(2), packed)); +typedef struct HFSPlusAttrKey HFSPlusAttrKey; + +#define kHFSPlusAttrKeyMaximumLength (sizeof(HFSPlusAttrKey) - sizeof(u_int16_t)) +#define kHFSPlusAttrKeyMinimumLength (kHFSPlusAttrKeyMaximumLength - kHFSMaxAttrNameLen*sizeof(u_int16_t)) + +#endif /* __APPLE_API_UNSTABLE */ + + +/* Key and node lengths */ +enum { + kHFSPlusExtentKeyMaximumLength = sizeof(HFSPlusExtentKey) - sizeof(u_int16_t), + kHFSExtentKeyMaximumLength = sizeof(HFSExtentKey) - sizeof(u_int8_t), + kHFSPlusCatalogKeyMaximumLength = sizeof(HFSPlusCatalogKey) - sizeof(u_int16_t), + kHFSPlusCatalogKeyMinimumLength = kHFSPlusCatalogKeyMaximumLength - sizeof(HFSUniStr255) + sizeof(u_int16_t), + kHFSCatalogKeyMaximumLength = sizeof(HFSCatalogKey) - sizeof(u_int8_t), + kHFSCatalogKeyMinimumLength = kHFSCatalogKeyMaximumLength - (kHFSMaxFileNameChars + 1) + sizeof(u_int8_t), + kHFSPlusCatalogMinNodeSize = 4096, + kHFSPlusExtentMinNodeSize = 512, + kHFSPlusAttrMinNodeSize = 4096 +}; + +/* HFS and HFS Plus volume attribute bits */ +enum { + /* Bits 0-6 are reserved (always cleared by MountVol call) */ + kHFSVolumeHardwareLockBit = 7, /* volume is locked by hardware */ + kHFSVolumeUnmountedBit = 8, /* volume was successfully unmounted */ + kHFSVolumeSparedBlocksBit = 9, /* volume has bad blocks spared */ + kHFSVolumeNoCacheRequiredBit = 10, /* don't cache volume blocks (i.e. RAM or ROM disk) */ + kHFSBootVolumeInconsistentBit = 11, /* boot volume is inconsistent (System 7.6 and later) */ + kHFSCatalogNodeIDsReusedBit = 12, + kHFSVolumeJournaledBit = 13, /* this volume has a journal on it */ + kHFSVolumeInconsistentBit = 14, /* serious inconsistencies detected at runtime */ + kHFSVolumeSoftwareLockBit = 15, /* volume is locked by software */ + /* + * HFS only has 16 bits of attributes in the MDB, but HFS Plus has 32 bits. + * Therefore, bits 16-31 can only be used on HFS Plus. + */ + kHFSUnusedNodeFixBit = 31, /* Unused nodes in the Catalog B-tree have been zero-filled. See Radar #6947811. */ + + kHFSVolumeHardwareLockMask = 1 << kHFSVolumeHardwareLockBit, + kHFSVolumeUnmountedMask = 1 << kHFSVolumeUnmountedBit, + kHFSVolumeSparedBlocksMask = 1 << kHFSVolumeSparedBlocksBit, + kHFSVolumeNoCacheRequiredMask = 1 << kHFSVolumeNoCacheRequiredBit, + kHFSBootVolumeInconsistentMask = 1 << kHFSBootVolumeInconsistentBit, + kHFSCatalogNodeIDsReusedMask = 1 << kHFSCatalogNodeIDsReusedBit, + kHFSVolumeJournaledMask = 1 << kHFSVolumeJournaledBit, + kHFSVolumeInconsistentMask = 1 << kHFSVolumeInconsistentBit, + kHFSVolumeSoftwareLockMask = 1 << kHFSVolumeSoftwareLockBit, + kHFSUnusedNodeFixMask = 1 << kHFSUnusedNodeFixBit, + kHFSMDBAttributesMask = 0x8380 +}; + +enum { + kHFSUnusedNodesFixDate = 0xc5ef2480 /* March 25, 2009 */ +}; + +/* HFS Master Directory Block - 162 bytes */ +/* Stored at sector #2 (3rd sector) and second-to-last sector. */ +struct HFSMasterDirectoryBlock { + u_int16_t drSigWord; /* == kHFSSigWord */ + u_int32_t drCrDate; /* date and time of volume creation */ + u_int32_t drLsMod; /* date and time of last modification */ + u_int16_t drAtrb; /* volume attributes */ + u_int16_t drNmFls; /* number of files in root folder */ + u_int16_t drVBMSt; /* first block of volume bitmap */ + u_int16_t drAllocPtr; /* start of next allocation search */ + u_int16_t drNmAlBlks; /* number of allocation blocks in volume */ + u_int32_t drAlBlkSiz; /* size (in bytes) of allocation blocks */ + u_int32_t drClpSiz; /* default clump size */ + u_int16_t drAlBlSt; /* first allocation block in volume */ + u_int32_t drNxtCNID; /* next unused catalog node ID */ + u_int16_t drFreeBks; /* number of unused allocation blocks */ + u_int8_t drVN[kHFSMaxVolumeNameChars + 1]; /* volume name */ + u_int32_t drVolBkUp; /* date and time of last backup */ + u_int16_t drVSeqNum; /* volume backup sequence number */ + u_int32_t drWrCnt; /* volume write count */ + u_int32_t drXTClpSiz; /* clump size for extents overflow file */ + u_int32_t drCTClpSiz; /* clump size for catalog file */ + u_int16_t drNmRtDirs; /* number of directories in root folder */ + u_int32_t drFilCnt; /* number of files in volume */ + u_int32_t drDirCnt; /* number of directories in volume */ + u_int32_t drFndrInfo[8]; /* information used by the Finder */ + u_int16_t drEmbedSigWord; /* embedded volume signature (formerly drVCSize) */ + HFSExtentDescriptor drEmbedExtent; /* embedded volume location and size (formerly drVBMCSize and drCtlCSize) */ + u_int32_t drXTFlSize; /* size of extents overflow file */ + HFSExtentRecord drXTExtRec; /* extent record for extents overflow file */ + u_int32_t drCTFlSize; /* size of catalog file */ + HFSExtentRecord drCTExtRec; /* extent record for catalog file */ +} __attribute__((aligned(2), packed)); +typedef struct HFSMasterDirectoryBlock HFSMasterDirectoryBlock; + + +#ifdef __APPLE_API_UNSTABLE +#define SET_HFS_TEXT_ENCODING(hint) \ + (0x656e6300 | ((hint) & 0xff)) +#define GET_HFS_TEXT_ENCODING(hint) \ + (((hint) & 0xffffff00) == 0x656e6300 ? (hint) & 0x000000ff : 0xffffffffU) +#endif /* __APPLE_API_UNSTABLE */ + + +/* HFS Plus Volume Header - 512 bytes */ +/* Stored at sector #2 (3rd sector) and second-to-last sector. */ +struct HFSPlusVolumeHeader { + u_int16_t signature; /* == kHFSPlusSigWord */ + u_int16_t version; /* == kHFSPlusVersion */ + u_int32_t attributes; /* volume attributes */ + u_int32_t lastMountedVersion; /* implementation version which last mounted volume */ + u_int32_t journalInfoBlock; /* block addr of journal info (if volume is journaled, zero otherwise) */ + + u_int32_t createDate; /* date and time of volume creation */ + u_int32_t modifyDate; /* date and time of last modification */ + u_int32_t backupDate; /* date and time of last backup */ + u_int32_t checkedDate; /* date and time of last disk check */ + + u_int32_t fileCount; /* number of files in volume */ + u_int32_t folderCount; /* number of directories in volume */ + + u_int32_t blockSize; /* size (in bytes) of allocation blocks */ + u_int32_t totalBlocks; /* number of allocation blocks in volume (includes this header and VBM*/ + u_int32_t freeBlocks; /* number of unused allocation blocks */ + + u_int32_t nextAllocation; /* start of next allocation search */ + u_int32_t rsrcClumpSize; /* default resource fork clump size */ + u_int32_t dataClumpSize; /* default data fork clump size */ + u_int32_t nextCatalogID; /* next unused catalog node ID */ + + u_int32_t writeCount; /* volume write count */ + u_int64_t encodingsBitmap; /* which encodings have been use on this volume */ + + u_int8_t finderInfo[32]; /* information used by the Finder */ + + HFSPlusForkData allocationFile; /* allocation bitmap file */ + HFSPlusForkData extentsFile; /* extents B-tree file */ + HFSPlusForkData catalogFile; /* catalog B-tree file */ + HFSPlusForkData attributesFile; /* extended attributes B-tree file */ + HFSPlusForkData startupFile; /* boot file (secondary loader) */ +} __attribute__((aligned(2), packed)); +typedef struct HFSPlusVolumeHeader HFSPlusVolumeHeader; + + +/* B-tree structures */ + +enum BTreeKeyLimits{ + kMaxKeyLength = 520 +}; + +union BTreeKey{ + u_int8_t length8; + u_int16_t length16; + u_int8_t rawData [kMaxKeyLength+2]; +}; +typedef union BTreeKey BTreeKey; + +/* BTNodeDescriptor -- Every B-tree node starts with these fields. */ +struct BTNodeDescriptor { + u_int32_t fLink; /* next node at this level*/ + u_int32_t bLink; /* previous node at this level*/ + int8_t kind; /* kind of node (leaf, index, header, map)*/ + u_int8_t height; /* zero for header, map; child is one more than parent*/ + u_int16_t numRecords; /* number of records in this node*/ + u_int16_t reserved; /* reserved - initialized as zero */ +} __attribute__((aligned(2), packed)); +typedef struct BTNodeDescriptor BTNodeDescriptor; + +/* Constants for BTNodeDescriptor kind */ +enum { + kBTLeafNode = -1, + kBTIndexNode = 0, + kBTHeaderNode = 1, + kBTMapNode = 2 +}; + +/* BTHeaderRec -- The first record of a B-tree header node */ +struct BTHeaderRec { + u_int16_t treeDepth; /* maximum height (usually leaf nodes) */ + u_int32_t rootNode; /* node number of root node */ + u_int32_t leafRecords; /* number of leaf records in all leaf nodes */ + u_int32_t firstLeafNode; /* node number of first leaf node */ + u_int32_t lastLeafNode; /* node number of last leaf node */ + u_int16_t nodeSize; /* size of a node, in bytes */ + u_int16_t maxKeyLength; /* reserved */ + u_int32_t totalNodes; /* total number of nodes in tree */ + u_int32_t freeNodes; /* number of unused (free) nodes in tree */ + u_int16_t reserved1; /* unused */ + u_int32_t clumpSize; /* reserved */ + u_int8_t btreeType; /* reserved */ + u_int8_t keyCompareType; /* Key string Comparison Type */ + u_int32_t attributes; /* persistent attributes about the tree */ + u_int32_t reserved3[16]; /* reserved */ +} __attribute__((aligned(2), packed)); +typedef struct BTHeaderRec BTHeaderRec; + +/* Constants for BTHeaderRec attributes */ +enum { + kBTBadCloseMask = 0x00000001, /* reserved */ + kBTBigKeysMask = 0x00000002, /* key length field is 16 bits */ + kBTVariableIndexKeysMask = 0x00000004 /* keys in index nodes are variable length */ +}; + + +/* Catalog Key Name Comparison Type */ +enum { + kHFSCaseFolding = 0xCF, /* case folding (case-insensitive) */ + kHFSBinaryCompare = 0xBC /* binary compare (case-sensitive) */ +}; + + +/* JournalInfoBlock - Structure that describes where our journal lives */ + +// the original size of the reserved field in the JournalInfoBlock was +// 32*sizeof(u_int32_t). To keep the total size of the structure the +// same we subtract the size of new fields (currently: ext_jnl_uuid and +// machine_uuid). If you add additional fields, place them before the +// reserved field and subtract their size in this macro. +// +#define JIB_RESERVED_SIZE ((32*sizeof(u_int32_t)) - sizeof(uuid_string_t) - 48) + +typedef char uuid_string_t[37]; +struct JournalInfoBlock { + u_int32_t flags; + u_int32_t device_signature[8]; // signature used to locate our device. + u_int64_t offset; // byte offset to the journal on the device + u_int64_t size; // size in bytes of the journal + uuid_string_t ext_jnl_uuid; + char machine_serial_num[48]; + char reserved[JIB_RESERVED_SIZE]; +} __attribute__((aligned(2), packed)); +typedef struct JournalInfoBlock JournalInfoBlock; + +enum { + kJIJournalInFSMask = 0x00000001, + kJIJournalOnOtherDeviceMask = 0x00000002, + kJIJournalNeedInitMask = 0x00000004 +}; + +// +// This the content type uuid for "external journal" GPT +// partitions. Each instance of a partition also has a +// uuid that uniquely identifies that instance. +// +#define EXTJNL_CONTENT_TYPE_UUID "4A6F7572-6E61-11AA-AA11-00306543ECAC" + + +#ifdef __cplusplus +} +#endif + +#endif /* __HFS_FORMAT__ */ Index: branches/azimutz/Cleancut/i386/include/architecture/ppc/macro_help.h =================================================================== --- branches/azimutz/Cleancut/i386/include/architecture/ppc/macro_help.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/architecture/ppc/macro_help.h (revision 885) @@ -0,0 +1,59 @@ +/* + * Copyright (c) 1999 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@ + */ +/* + * Copyright (c) 1996 NeXT Software, Inc. + */ +/* + * Mach Operating System + * Copyright (c) 1989 Carnegie-Mellon University + * Copyright (c) 1988 Carnegie-Mellon University + * All rights reserved. The CMU software License Agreement specifies + * the terms and conditions for use and redistribution. + * + * File: architecture/ppc/macro_help.h + * + * Provide help in making lint-free macro routines + * + * HISTORY + * + * 29-Dec-96 Umesh Vaishampayan (umeshv@NeXT.com) + * Created from m98k version. + */ + +#ifndef _ARCH_PPC_MACRO_HELP_H_ +#define _ARCH_PPC_MACRO_HELP_H_ + +#ifndef MACRO_BEGIN +# define MACRO_BEGIN do { +#endif /* MACRO_BEGIN */ + +#ifndef MACRO_END +# define MACRO_END } while (0) +#endif /* MACRO_END */ + +#ifndef MACRO_RETURN +# define MACRO_RETURN if (1) return +#endif /* MACRO_RETURN */ + +#endif /* _ARCH_PPC_MACRO_HELP_H_ */ + Index: branches/azimutz/Cleancut/i386/include/architecture/ppc/math.h =================================================================== --- branches/azimutz/Cleancut/i386/include/architecture/ppc/math.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/architecture/ppc/math.h (revision 885) @@ -0,0 +1,883 @@ +/* + * Copyright (c) 2002 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@ + */ + +/******************************************************************************* +* * +* File: math.h * +* * +* Contains: typedefs, prototypes, and macros germane to C99 floating point.* +* * +*******************************************************************************/ +#ifndef __MATH__ +#define __MATH__ + +#include "sys/cdefs.h" /* For definition of __DARWIN_UNIX03 et al */ + +#if (!defined(__WANT_LONG_DOUBLE_FORMAT__)) +#if defined(__APPLE_CC__) && defined(__LONG_DOUBLE_128__) +#define __WANT_LONG_DOUBLE_FORMAT__ 128 +#else +#define __WANT_LONG_DOUBLE_FORMAT__ 64 +#endif +#endif + +#if ( __WANT_LONG_DOUBLE_FORMAT__ - 0L == 128L ) +#define __LIBMLDBL_COMPAT(sym) __asm("_" __STRING(sym) "$LDBL128") +#elif ( __WANT_LONG_DOUBLE_FORMAT__ - 0L == 64L ) +#define __LIBMLDBL_COMPAT(sym) /* NOTHING */ +#else +#define __LIBMLDBL_COMPAT(sym) /* NOTHING */ +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/****************************************************************************** +* Floating point data types * +******************************************************************************/ + +/* Define float_t and double_t per C standard, ISO/IEC 9899:1999 7.12 2, + taking advantage of GCC's __FLT_EVAL_METHOD__ (which a compiler may + define anytime and GCC does) that shadows FLT_EVAL_METHOD (which a compiler + must and may define only in float.h). +*/ +#if __FLT_EVAL_METHOD__ == 0 + typedef float float_t; + typedef double double_t; +#elif __FLT_EVAL_METHOD__ == 1 + typedef double float_t; + typedef double double_t; +#elif __FLT_EVAL_METHOD__ == 2 || __FLT_EVAL_METHOD__ == -1 + typedef long double float_t; + typedef long double double_t; +#else /* __FLT_EVAL_METHOD__ */ + #error "Unsupported value of __FLT_EVAL_METHOD__." +#endif /* __FLT_EVAL_METHOD__ */ + + +#if defined(__GNUC__) && ! defined( __XLC__ ) + #define HUGE_VAL __builtin_huge_val() + #define HUGE_VALF __builtin_huge_valf() + #define HUGE_VALL __builtin_huge_vall() + #define NAN __builtin_nanf("0x7fc00000") /* Constant expression, can be used as initializer. */ + #define __MATH_H_ALWAYS_INLINE__ __attribute__ ((always_inline)) +#else + #define HUGE_VAL 1e500 + #define HUGE_VALF 1e50f + #define HUGE_VALL 1e500L + #define NAN __nan( ) + #define __MATH_H_ALWAYS_INLINE__ +#endif + +#define INFINITY HUGE_VALF + +/****************************************************************************** +* Taxonomy of floating point data types * +******************************************************************************/ + +#define FP_NAN 1 +#define FP_INFINITE 2 +#define FP_ZERO 3 +#define FP_NORMAL 4 +#define FP_SUBNORMAL 5 +#define FP_SUPERNORMAL 6 + +/* fma() *function call* is more costly than equivalent (in-line) multiply and add operations */ +#undef FP_FAST_FMA +#undef FP_FAST_FMAF +#undef FP_FAST_FMAL + +/* The values returned by `ilogb' for 0 and NaN respectively. */ +#define FP_ILOGB0 (-2147483647) +#define FP_ILOGBNAN (2147483647) + +/* Bitmasks for the math_errhandling macro. */ +#define MATH_ERRNO 1 /* errno set by math functions. */ +#define MATH_ERREXCEPT 2 /* Exceptions raised by math functions. */ + +#define math_errhandling (__math_errhandling()) +extern unsigned int __math_errhandling ( void ); + +/******************************************************************************** +* * +* Inquiry macros * +* * +* fpclassify Returns one of the FP_Švalues. * +* isnormal Non-zero if and only if the argument x is normalized. * +* isfinite Non-zero if and only if the argument x is finite. * +* isnan Non-zero if and only if the argument x is a NaN. * +* signbit Non-zero if and only if the sign of the argument x is * +* negative. This includes, NaNs, infinities and zeros. * +* * +********************************************************************************/ + +#if (__WANT_LONG_DOUBLE_FORMAT__ - 0L == 128L) + #define fpclassify(x) \ + ( sizeof (x) == sizeof(float ) ? __fpclassifyf((float)x) \ + : sizeof (x) == sizeof(double) ? __fpclassifyd((double)x) \ + : __fpclassify ((long double)x)) + + extern int __fpclassifyf(float ); + extern int __fpclassifyd(double ); + extern int __fpclassify (long double); + + #if defined( __GNUC__ ) && ! defined( __XLC__ ) && 0 == __FINITE_MATH_ONLY__ + /* Yes, that's right. You only get the fast iswhatever() macros if you do NOT turn on -ffast-math. */ + /* These inline functions require the compiler to be compiling to standard in order to work. */ + /* -ffast-math, among other things, implies that NaNs don't happen. The compiler can in that case */ + /* optimize x != x to be false always, wheras it would be true for NaNs. That breaks __inline_isnan() */ + /* below. */ + + #define isnormal(x) \ + ( sizeof (x) == sizeof(float ) ? __inline_isnormalf((float)(x)) \ + : sizeof (x) == sizeof(double) ? __inline_isnormald((double)(x)) \ + : __inline_isnormal ((long double)(x))) + + #define isfinite(x) \ + ( sizeof (x) == sizeof(float ) ? __inline_isfinitef((float)(x)) \ + : sizeof (x) == sizeof(double) ? __inline_isfinited((double)(x)) \ + : __inline_isfinite ((long double)(x))) + + #define isinf(x) \ + ( sizeof (x) == sizeof(float ) ? __inline_isinff((float)(x)) \ + : sizeof (x) == sizeof(double) ? __inline_isinfd((double)(x)) \ + : __inline_isinf ((long double)(x))) + + #define isnan(x) \ + ( sizeof (x) == sizeof(float ) ? __inline_isnanf((float)(x)) \ + : sizeof (x) == sizeof(double) ? __inline_isnand((double)(x)) \ + : __inline_isnan ((long double)(x))) + + #define signbit(x) \ + ( sizeof (x) == sizeof(float ) ? __inline_signbitf((float)(x)) \ + : sizeof (x) == sizeof(double) ? __inline_signbitd((double)(x)) \ + : __inline_signbit((long double)(x))) + + /* Developers who are calling __isnan, __isnormal, __isinf, etc. and now encountering errors are calling private APIs */ + /* that are deprecated. Please use the official C99 sanctioned macros listed above instead. */ + + static __inline__ int __inline_isfinitef (float ) __MATH_H_ALWAYS_INLINE__; + static __inline__ int __inline_isfinited (double ) __MATH_H_ALWAYS_INLINE__; + static __inline__ int __inline_isfinite (long double) __MATH_H_ALWAYS_INLINE__; + static __inline__ int __inline_isinff (float ) __MATH_H_ALWAYS_INLINE__; + static __inline__ int __inline_isinfd (double ) __MATH_H_ALWAYS_INLINE__; + static __inline__ int __inline_isinf (long double) __MATH_H_ALWAYS_INLINE__; + static __inline__ int __inline_isnanf (float ) __MATH_H_ALWAYS_INLINE__; + static __inline__ int __inline_isnand (double ) __MATH_H_ALWAYS_INLINE__; + static __inline__ int __inline_isnan (long double) __MATH_H_ALWAYS_INLINE__; + static __inline__ int __inline_isnormalf (float ) __MATH_H_ALWAYS_INLINE__; + static __inline__ int __inline_isnormald (double ) __MATH_H_ALWAYS_INLINE__; + static __inline__ int __inline_isnormal (long double) __MATH_H_ALWAYS_INLINE__; + static __inline__ int __inline_signbitf (float ) __MATH_H_ALWAYS_INLINE__; + static __inline__ int __inline_signbitd (double ) __MATH_H_ALWAYS_INLINE__; + static __inline__ int __inline_signbit (long double) __MATH_H_ALWAYS_INLINE__; + + static __inline__ int __inline_isinff( float __x ) { return __builtin_fabsf(__x) == __builtin_inff(); } + static __inline__ int __inline_isinfd( double __x ) { return __builtin_fabs(__x) == __builtin_inf(); } + static __inline__ int __inline_isinf( long double __x ) { return __builtin_fabsl(__x) == __builtin_infl(); } + static __inline__ int __inline_isfinitef( float __x ) { return __x == __x && __builtin_fabsf(__x) != __builtin_inff(); } + static __inline__ int __inline_isfinited( double __x ) { return __x == __x && __builtin_fabs(__x) != __builtin_inf(); } + static __inline__ int __inline_isfinite( long double __x ) { return __x == __x && __builtin_fabsl(__x) != __builtin_infl(); } + static __inline__ int __inline_isnanf( float __x ) { return __x != __x; } + static __inline__ int __inline_isnand( double __x ) { return __x != __x; } + static __inline__ int __inline_isnan( long double __x ) { return __x != __x; } + static __inline__ int __inline_signbitf( float __x ) { union{ float __f; unsigned int __u; }__u; __u.__f = __x; return (int)(__u.__u >> 31); } + static __inline__ int __inline_signbitd( double __x ) { union{ double __f; unsigned long __u; }__u; __u.__f = __x; return (int)(__u.__u >> ( 8 * sizeof( __u.__u) - 1)); } + static __inline__ int __inline_signbit( long double __x ){ union{ long double __ld; unsigned long __p; }__u; __u.__ld = __x; return (int) (__u.__p >> ( 8 * sizeof( __u.__p) - 1)); } + static __inline__ int __inline_isnormalf( float __x ) { float fabsf = __builtin_fabsf(__x); if( __x != __x ) return 0; return fabsf < __builtin_inff() && fabsf >= __FLT_MIN__; } + static __inline__ int __inline_isnormald( double __x ) { double fabsf = __builtin_fabs(__x); if( __x != __x ) return 0; return fabsf < __builtin_inf() && fabsf >= __DBL_MIN__; } + static __inline__ int __inline_isnormal( long double __x ) { long double fabsf = __builtin_fabsl(__x); if( __x != __x ) return 0; return fabsf < __builtin_infl() && fabsf >= __LDBL_MIN__; } + + #else + + #define isnormal(x) \ + ( sizeof (x) == sizeof(float ) ? __isnormalf((float)(x)) \ + : sizeof (x) == sizeof(double) ? __isnormald((double)(x)) \ + : __isnormal ((long double)(x))) + + #define isfinite(x) \ + ( sizeof (x) == sizeof(float ) ? __isfinitef((float)(x)) \ + : sizeof (x) == sizeof(double) ? __isfinited((double)(x)) \ + : __isfinite ((long double)(x))) + + #define isinf(x) \ + ( sizeof (x) == sizeof(float ) ? __isinff((float)(x)) \ + : sizeof (x) == sizeof(double) ? __isinfd((double)(x)) \ + : __isinf ((long double)(x))) + + #define isnan(x) \ + ( sizeof (x) == sizeof(float ) ? __isnanf((float)(x)) \ + : sizeof (x) == sizeof(double) ? __isnand((double)(x)) \ + : __isnan ((long double)(x))) + + #define signbit(x) \ + ( sizeof (x) == sizeof(float ) ? __signbitf((float)(x)) \ + : sizeof (x) == sizeof(double) ? __signbitd((double)(x)) \ + : __signbitl((long double)(x))) + + + extern int __isnormalf (float ); + extern int __isnormald (double ); + extern int __isnormal (long double); + + extern int __isfinitef (float ); + extern int __isfinited (double ); + extern int __isfinite (long double); + + extern int __isinff (float ); + extern int __isinfd (double ); + extern int __isinf (long double); + + extern int __isnanf (float ); + extern int __isnand (double ); + extern int __isnan (long double); + + extern int __signbitf (float ); + extern int __signbitd (double ); + extern int __signbitl (long double); + + #endif + +#else + #define fpclassify(x) \ + ( sizeof (x) == sizeof(float ) ? __fpclassifyf((float)(x)) : __fpclassifyd((double)(x)) ) + + extern int __fpclassifyf(float ); + extern int __fpclassifyd(double ); + + #if defined( __GNUC__ ) && ! defined( __XLC__ ) && 0 == __FINITE_MATH_ONLY__ + /* Yes, that's right. You only get the fast iswhatever() macros if you do NOT turn on -ffast-math. */ + /* These inline functions require the compiler to be compiling to standard in order to work. */ + /* -ffast-math, among other things, implies that NaNs don't happen. The compiler can in that case */ + /* optimize x != x to be false always, wheras it would be true for NaNs. That breaks __inline_isnan() */ + /* below. */ + #define isnormal(x) \ + ( sizeof (x) == sizeof(float ) ? __inline_isnormalf((float)(x)) : __inline_isnormald((double)(x)) ) + + #define isfinite(x) \ + ( sizeof (x) == sizeof(float ) ? __inline_isfinitef((float)(x)) : __inline_isfinited((double)(x)) ) + + #define isinf(x) \ + ( sizeof (x) == sizeof(float ) ? __inline_isinff((float)(x)) : __inline_isinfd((double)(x)) ) + + #define isnan(x) \ + ( sizeof (x) == sizeof(float ) ? __inline_isnanf((float)(x)) : __inline_isnand((double)(x)) ) + + #define signbit(x) \ + ( sizeof (x) == sizeof(float ) ? __inline_signbitf((float)(x)) : __inline_signbitd((double)(x)) ) + + /* Developers who are calling __isnan, __isnormal, __isinf, etc. and now encountering errors are calling private APIs */ + /* that are deprecated. Please use the official C99 sanctioned macros listed above instead. */ + + static __inline__ int __inline_isfinitef (float ) __MATH_H_ALWAYS_INLINE__; + static __inline__ int __inline_isfinited (double ) __MATH_H_ALWAYS_INLINE__; + static __inline__ int __inline_isfinite (long double) __MATH_H_ALWAYS_INLINE__; + static __inline__ int __inline_isinff (float ) __MATH_H_ALWAYS_INLINE__; + static __inline__ int __inline_isinfd (double ) __MATH_H_ALWAYS_INLINE__; + static __inline__ int __inline_isinf (long double) __MATH_H_ALWAYS_INLINE__; + static __inline__ int __inline_isnanf (float ) __MATH_H_ALWAYS_INLINE__; + static __inline__ int __inline_isnand (double ) __MATH_H_ALWAYS_INLINE__; + static __inline__ int __inline_isnan (long double) __MATH_H_ALWAYS_INLINE__; + static __inline__ int __inline_isnormalf (float ) __MATH_H_ALWAYS_INLINE__; + static __inline__ int __inline_isnormald (double ) __MATH_H_ALWAYS_INLINE__; + static __inline__ int __inline_isnormal (long double) __MATH_H_ALWAYS_INLINE__; + static __inline__ int __inline_signbitf (float ) __MATH_H_ALWAYS_INLINE__; + static __inline__ int __inline_signbitd (double ) __MATH_H_ALWAYS_INLINE__; + static __inline__ int __inline_signbit (long double) __MATH_H_ALWAYS_INLINE__; + + static __inline__ int __inline_isinff( float __x ) { return __builtin_fabsf(__x) == __builtin_inff(); } + static __inline__ int __inline_isinfd( double __x ) { return __builtin_fabs(__x) == __builtin_inf(); } + static __inline__ int __inline_isinf( long double __x ) { return __builtin_fabsl(__x) == __builtin_infl(); } + static __inline__ int __inline_isfinitef( float __x ) { return __x == __x && __builtin_fabsf(__x) != __builtin_inff(); } + static __inline__ int __inline_isfinited( double __x ) { return __x == __x && __builtin_fabs(__x) != __builtin_inf(); } + static __inline__ int __inline_isfinite( long double __x ) { return __x == __x && __builtin_fabsl(__x) != __builtin_infl(); } + static __inline__ int __inline_isnanf( float __x ) { return __x != __x; } + static __inline__ int __inline_isnand( double __x ) { return __x != __x; } + static __inline__ int __inline_isnan( long double __x ) { return __x != __x; } + static __inline__ int __inline_signbitf( float __x ) { union{ float __f; unsigned int __u; }__u; __u.__f = __x; return (int)(__u.__u >> 31); } + static __inline__ int __inline_signbitd( double __x ) { union{ double __f; unsigned long __u; }__u; __u.__f = __x; return (int)(__u.__u >> ( 8 * sizeof( __u.__u) - 1)); } + static __inline__ int __inline_signbit( long double __x ){ union{ long double __ld; unsigned long __p; }__u; __u.__ld = __x; return (int) (__u.__p >> ( 8 * sizeof( __u.__p) - 1)); } + static __inline__ int __inline_isnormalf( float __x ) { float fabsf = __builtin_fabsf(__x); if( __x != __x ) return 0; return fabsf < __builtin_inff() && fabsf >= __FLT_MIN__; } + static __inline__ int __inline_isnormald( double __x ) { double fabsf = __builtin_fabs(__x); if( __x != __x ) return 0; return fabsf < __builtin_inf() && fabsf >= __DBL_MIN__; } + static __inline__ int __inline_isnormal( long double __x ) { long double fabsf = __builtin_fabsl(__x); if( __x != __x ) return 0; return fabsf < __builtin_infl() && fabsf >= __LDBL_MIN__; } + + #else + + #define isnormal(x) \ + ( sizeof (x) == sizeof(float ) ? __isnormalf((float)(x)) : __isnormald((double)(x)) ) + + #define isfinite(x) \ + ( sizeof (x) == sizeof(float ) ? __isfinitef((float)(x)) : __isfinited((double)(x)) ) + + #define isinf(x) \ + ( sizeof (x) == sizeof(float ) ? __isinff((float)(x)) : __isinfd((double)(x)) ) + + #define isnan(x) \ + ( sizeof (x) == sizeof(float ) ? __isnanf((float)(x)) : __isnand((double)(x)) ) + + #define signbit(x) \ + ( sizeof (x) == sizeof(float ) ? __signbitf((float)(x)) : __signbitd((double)(x)) ) + + + extern int __isnormalf (float ); + extern int __isnormald (double ); + + extern int __isfinitef (float ); + extern int __isfinited (double ); + + extern int __isinff (float ); + extern int __isinfd (double ); + + extern int __isnanf (float ); + extern int __isnand (double ); + + extern int __signbitf (float ); + extern int __signbitd (double ); + + #endif + +#endif /* __WANT_LONG_DOUBLE_FORMAT__ */ + + +/******************************************************************************** +* * +* Math Functions * +* * +********************************************************************************/ + +extern double acos( double ); +extern float acosf( float ); + +extern double asin( double ); +extern float asinf( float ); + +extern double atan( double ); +extern float atanf( float ); + +extern double atan2( double, double ); +extern float atan2f( float, float ); + +extern double cos( double ); +extern float cosf( float ); + +extern double sin( double ); +extern float sinf( float ); + +extern double tan( double ); +extern float tanf( float ); + +extern double acosh( double ); +extern float acoshf( float ); + +extern double asinh( double ); +extern float asinhf( float ); + +extern double atanh( double ); +extern float atanhf( float ); + +extern double cosh( double ); +extern float coshf( float ); + +extern double sinh( double ); +extern float sinhf( float ); + +extern double tanh( double ); +extern float tanhf( float ); + +extern double exp( double ); +extern float expf( float ); + +extern double exp2( double ); +extern float exp2f( float ); + +extern double expm1( double ); +extern float expm1f( float ); + +extern double log( double ); +extern float logf( float ); + +extern double log10( double ); +extern float log10f( float ); + +extern double log2( double ); +extern float log2f( float ); + +extern double log1p( double ); +extern float log1pf( float ); + +extern double logb( double ); +extern float logbf( float ); + +extern double modf( double, double * ); +extern float modff( float, float * ); + +extern double ldexp( double, int ); +extern float ldexpf( float, int ); + +extern double frexp( double, int * ); +extern float frexpf( float, int * ); + +extern int ilogb( double ); +extern int ilogbf( float ); + +extern double scalbn( double, int ); +extern float scalbnf( float, int ); + +extern double scalbln( double, long int ); +extern float scalblnf( float, long int ); + +extern double fabs( double ); +extern float fabsf( float ); + +extern double cbrt( double ); +extern float cbrtf( float ); + +extern double hypot( double, double ); +extern float hypotf( float, float ); + +extern double pow( double, double ); +extern float powf( float, float ); + +extern double sqrt( double ); +extern float sqrtf( float ); + +extern double erf( double ); +extern float erff( float ); + +extern double erfc( double ); +extern float erfcf( float ); + +extern double lgamma( double ); +extern float lgammaf( float ); + +extern double tgamma( double ); +extern float tgammaf( float ); + +extern double ceil( double ); +extern float ceilf( float ); + +extern double floor( double ); +extern float floorf( float ); + +extern double nearbyint( double ); +extern float nearbyintf( float ); + +extern double rint( double ); +extern float rintf( float ); + +extern long int lrint( double ); +extern long int lrintf( float ); + +extern double round( double ); +extern float roundf( float ); + +extern long int lround( double ); +extern long int lroundf( float ); + +#if ( defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L ) || ! defined( __STRICT_ANSI__ ) || ! defined( __GNUC__ ) + /* C90 doesn't know about long long. Make sure you are passing -std=c99 or -std=gnu99 or better if you need this. */ + extern long long int llrint( double ); + extern long long int llrintf( float ); + + extern long long int llround( double ); + extern long long int llroundf( float ); +#endif /*#if ( defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L ) || ! defined( __STRICT_ANSI__ ) || ! defined( __GNUC__ ) */ + +extern double trunc( double ); +extern float truncf( float ); + +extern double fmod( double, double ); +extern float fmodf( float, float ); + +extern double remainder( double, double ); +extern float remainderf( float, float ); + +extern double remquo( double, double, int * ); +extern float remquof( float, float, int * ); + +extern double copysign( double, double ); +extern float copysignf( float, float ); + +extern double nan( const char * ); +extern float nanf( const char * ); + +extern double nextafter( double, double ); +extern float nextafterf( float, float ); + + +extern double fdim( double, double ); +extern float fdimf( float, float ); + +extern double fmax( double, double ); +extern float fmaxf( float, float ); + +extern double fmin( double, double ); +extern float fminf( float, float ); + +extern double fma( double, double, double ); +extern float fmaf( float, float, float ); + +#if ( __WANT_LONG_DOUBLE_FORMAT__ - 0L > 0L ) +extern long double acosl( long double ) __LIBMLDBL_COMPAT(acosl); +extern long double asinl( long double ) __LIBMLDBL_COMPAT(asinl); +extern long double atanl( long double ) __LIBMLDBL_COMPAT(atanl); +extern long double atan2l( long double, long double ) __LIBMLDBL_COMPAT(atan2l); +extern long double cosl( long double ) __LIBMLDBL_COMPAT(cosl); +extern long double sinl( long double ) __LIBMLDBL_COMPAT(sinl); +extern long double tanl( long double ) __LIBMLDBL_COMPAT(tanl); +extern long double acoshl( long double ) __LIBMLDBL_COMPAT(acoshl); +extern long double asinhl( long double ) __LIBMLDBL_COMPAT(asinhl); +extern long double atanhl( long double ) __LIBMLDBL_COMPAT(atanhl); +extern long double coshl( long double ) __LIBMLDBL_COMPAT(coshl); +extern long double sinhl( long double ) __LIBMLDBL_COMPAT(sinhl); +extern long double tanhl( long double ) __LIBMLDBL_COMPAT(tanhl); +extern long double expl( long double ) __LIBMLDBL_COMPAT(expl); +extern long double exp2l( long double ) __LIBMLDBL_COMPAT(exp2l); +extern long double expm1l( long double ) __LIBMLDBL_COMPAT(expm1l); +extern long double logl( long double ) __LIBMLDBL_COMPAT(logl); +extern long double log10l( long double ) __LIBMLDBL_COMPAT(log10l); +extern long double log2l( long double ) __LIBMLDBL_COMPAT(log2l); +extern long double log1pl( long double ) __LIBMLDBL_COMPAT(log1pl); +extern long double logbl( long double ) __LIBMLDBL_COMPAT(logbl); +extern long double modfl( long double, long double * ) __LIBMLDBL_COMPAT(modfl); +extern long double ldexpl( long double, int ) __LIBMLDBL_COMPAT(ldexpl); +extern long double frexpl( long double, int * ) __LIBMLDBL_COMPAT(frexpl); +extern int ilogbl( long double ) __LIBMLDBL_COMPAT(ilogbl); +extern long double scalbnl( long double, int ) __LIBMLDBL_COMPAT(scalbnl); +extern long double scalblnl( long double, long int ) __LIBMLDBL_COMPAT(scalblnl); +extern long double fabsl( long double ) __LIBMLDBL_COMPAT(fabsl); +extern long double cbrtl( long double ) __LIBMLDBL_COMPAT(cbrtl); +extern long double hypotl( long double, long double ) __LIBMLDBL_COMPAT(hypotl); +extern long double powl( long double, long double ) __LIBMLDBL_COMPAT(powl); +extern long double sqrtl( long double ) __LIBMLDBL_COMPAT(sqrtl); +extern long double erfl( long double ) __LIBMLDBL_COMPAT(erfl); +extern long double erfcl( long double ) __LIBMLDBL_COMPAT(erfcl); +extern long double lgammal( long double ) __LIBMLDBL_COMPAT(lgammal); +extern long double tgammal( long double ) __LIBMLDBL_COMPAT(tgammal); +extern long double ceill( long double ) __LIBMLDBL_COMPAT(ceill); +extern long double floorl( long double ) __LIBMLDBL_COMPAT(floorl); +extern long double nearbyintl( long double ) __LIBMLDBL_COMPAT(nearbyintl); +extern long double rintl( long double ) __LIBMLDBL_COMPAT(rintl); +extern long int lrintl( long double ) __LIBMLDBL_COMPAT(lrintl); +extern long double roundl( long double ) __LIBMLDBL_COMPAT(roundl); +extern long int lroundl( long double ) __LIBMLDBL_COMPAT(lroundl); + +#if ( defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L ) || ! defined( __STRICT_ANSI__ ) || ! defined( __GNUC__ ) + /* C90 doesn't know about long long. Make sure you are passing -std=c99 or -std=gnu99 or better if you need this. */ + extern long long int llrintl( long double ) __LIBMLDBL_COMPAT(llrintl); + extern long long int llroundl( long double ) __LIBMLDBL_COMPAT(llroundl); +#endif /* #if ( defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L ) || ! defined( __STRICT_ANSI__ ) || ! defined( __GNUC__ ) */ + +extern long double truncl( long double ) __LIBMLDBL_COMPAT(truncl); +extern long double fmodl( long double, long double) __LIBMLDBL_COMPAT(fmodl); +extern long double remainderl( long double, long double ) __LIBMLDBL_COMPAT(remainderl); +extern long double remquol( long double, long double, int * ) __LIBMLDBL_COMPAT(remquol); +extern long double copysignl( long double, long double ) __LIBMLDBL_COMPAT(copysignl); +extern long double nanl( const char * ) __LIBMLDBL_COMPAT(nanl); +extern long double nextafterl( long double, long double ) __LIBMLDBL_COMPAT(nextafterl); +extern double nexttoward( double, long double ) __LIBMLDBL_COMPAT(nexttoward); +extern float nexttowardf( float, long double ) __LIBMLDBL_COMPAT(nexttowardf); +extern long double nexttowardl( long double, long double ) __LIBMLDBL_COMPAT(nexttowardl); +extern long double fdiml( long double, long double ) __LIBMLDBL_COMPAT(fdiml); +extern long double fmaxl( long double, long double ) __LIBMLDBL_COMPAT(fmaxl); +extern long double fminl( long double, long double ) __LIBMLDBL_COMPAT(fminl); +extern long double fmal( long double, long double, long double ) __LIBMLDBL_COMPAT(fmal); +#endif /* __WANT_LONG_DOUBLE_FORMAT__ */ + +#define isgreater(x, y) __builtin_isgreater ((x),(y)) +#define isgreaterequal(x, y) __builtin_isgreaterequal ((x),(y)) +#define isless(x, y) __builtin_isless ((x),(y)) +#define islessequal(x, y) __builtin_islessequal ((x),(y)) +#define islessgreater(x, y) __builtin_islessgreater ((x),(y)) +#define isunordered(x, y) __builtin_isunordered ((x),(y)) + +extern double __inf( void ); +extern float __inff( void ); +extern float __nan( void ); /* 10.3 (and later) must retain in ABI for backward compatability */ + +#if !defined(_ANSI_SOURCE) +extern double j0 ( double ); +extern double j1 ( double ); +extern double jn ( int, double ); + +extern double y0 ( double ); +extern double y1 ( double ); +extern double yn ( int, double ); + +/* + * Scalb Travellers' advisory: + * --------------------------- + * + * Reduction of Information advisory -- This advisory may constitute "too much information". Readers who are easily panicked + * or confused may be needlessly panicked or confused by this advisory. + * + * We are in the process of retiring the legacy scalb. IEEE-754 did not specify what the argument types should be + * for scalb. We guessed scalb(double, int) -- ints are faster to use here -- but our guess and what later standards + * standard eventually settled on did not agree. To be compliant with these standards, our scalb needs to be scalb(double, double). + * Unfortunately, we have a commitment to be binary compatible with old software compiled against scalb(double, int) + * for older operating systems, so the old symbol _scalb must live on in perpetuity in the __ppc__ binary interface to service + * this need. To deal with this problem, we have introduced a new binary symbol _scalb$UNIX2003 and did some magic below + * so that when you now compile against scalb() on a __ppc__ application, you get linked to _scalb$UNIX2003 instead. Thus, + * this constitutes a source level *** API CHANGE *** from scalb( double, int ) to scalb( double, double) on __ppc__ only + * that your source will need to contend with if you compile with this header. On __ppc__, all ints are exactly representable + * as doubles so from an arithmetic standpoint, this should cause no changes arithmetically from parameters of int type, but there + * remains the danger of triggering various compiler warnings that might balloon to more serious problems under -Werror. + * + * On __ppc64__, __i386__ and future archs, scalb has always been scalb( double, double) and will continue to be so. Thus, this change + * will make scalb on all platforms behave identically, with the same parameter types. The change will also eliminate GCC warnings about + * the math.h scalb declaration not matching the gcc4 builtin version. + * + * The intent is that you will "never know" that a change occurred, and your code should "just do the right thing" without modification. + * However, if you would like to sidestep any problems associated with this move, it is suggested that you use the C99 scalbn or scalbln + * or single/long double variants as appropriate instead. Their behavior and type is rigorously defined. There should be no hidden arithmetic + * "gotchas" if you simply replace all legacy calls to scalb with scalbn, since they essentially do the same thing. If you + * decide to take this step, you should exercise due diligence to make sure that scalbn is present in the oldest version of + * MacOS X that you support. Otherwise, your application may fail to load on older systems. C99 support was introduced in MacOS X.3.9. + * + * Use of the symbol _scalb$UNIX2003 should not in itself be construed to mean that scalb$UNIX2003 necessarily is UNIX 2003 compliant. + * UNIX is a registered trademark of The Open Group. + */ + +/* maps to _scalb$UNIX2003 on __ppc__ and _scalb elsewhere */ +#if defined( __ppc__ ) + #if defined( __GNUC__ ) && ! defined( __XLC__ ) && ( ! defined( __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) || __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__-0 >= 1040 ) + extern double scalb ( double, double ) __asm("_scalb$UNIX2003" ); + #else + extern double scalb ( double , int ); + #endif +#else + extern double scalb ( double, double ); +#endif + +#define M_E 2.71828182845904523536028747135266250 /* e */ +#define M_LOG2E 1.44269504088896340735992468100189214 /* log_2(e) */ +#define M_LOG10E 0.434294481903251827651128918916605082 /* log_10(e) */ +#define M_LN2 0.693147180559945309417232121458176568 /* log_e(2) */ +#define M_LN10 2.30258509299404568401799145468436421 /* log_e(10) */ +#define M_PI 3.14159265358979323846264338327950288 /* pi */ +#define M_PI_2 1.57079632679489661923132169163975144 /* pi/2 */ +#define M_PI_4 0.785398163397448309615660845819875721 /* pi/4 */ +#define M_1_PI 0.318309886183790671537767526745028724 /* 1/pi */ +#define M_2_PI 0.636619772367581343075535053490057448 /* 2/pi */ +#define M_2_SQRTPI 1.12837916709551257389615890312154517 /* 2/sqrt(pi) */ +#define M_SQRT2 1.41421356237309504880168872420969808 /* sqrt(2) */ +#define M_SQRT1_2 0.707106781186547524400844362104849039 /* 1/sqrt(2) */ + +#define MAXFLOAT ((float)3.40282346638528860e+38) +extern int signgam; + +#endif /* !defined(_ANSI_SOURCE) */ + +#if !defined(__NOEXTENSIONS__) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) +#define __WANT_EXTENSIONS__ +#endif + +#ifdef __WANT_EXTENSIONS__ + +#define FP_SNAN FP_NAN +#define FP_QNAN FP_NAN + +extern long int rinttol ( double ); + +extern long int roundtol ( double ); + +typedef struct __complex_s { + double Real; + double Imag; +} __complex_t; + +/* + * XOPEN/SVID + */ +#if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) + +#if (!defined(_XOPEN_SOURCE) || defined(_DARWIN_C_SOURCE)) +enum fdversion {_fdlibm_ieee = -1, _fdlibm_svid, _fdlibm_xopen, _fdlibm_posix}; /* Legacy fdlibm constructs */ +#define fdlibm_ieee _fdlibm_ieee +#define fdlibm_svid _fdlibm_svid +#define fdlibm_xopen _fdlibm_xopen +#define fdlibm_posix _fdlibm_posix + +#define _LIB_VERSION_TYPE enum fdversion +#define _LIB_VERSION _fdlib_version + +/* if global variable _LIB_VERSION is not desirable, one may + * change the following to be a constant by: + * #define _LIB_VERSION_TYPE const enum version + * In that case, after one initializes the value _LIB_VERSION (see + * s_lib_version.c) during compile time, it cannot be modified + * in the middle of a program + */ +extern _LIB_VERSION_TYPE _LIB_VERSION; + +#define _IEEE_ fdlibm_ieee +#define _SVID_ fdlibm_svid +#define _XOPEN_ fdlibm_xopen +#define _POSIX_ fdlibm_posix + +#if !defined(__cplusplus) +struct exception { + int type; + char *name; + double arg1; + double arg2; + double retval; +}; +#endif + +#define HUGE MAXFLOAT + +/* + * set X_TLOSS = pi*2**52, which is possibly defined in <values.h> + * (one may replace the following line by "#include <values.h>") + */ + +#define X_TLOSS 1.41484755040568800000e+16 + +#define DOMAIN 1 +#define SING 2 +#define OVERFLOW 3 +#define UNDERFLOW 4 +#define TLOSS 5 +#define PLOSS 6 + +#endif /* (!_XOPEN_SOURCE || _DARWIN_C_SOURCE) */ +#endif /* !_ANSI_SOURCE && (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + +#if !defined( __STRICT_ANSI__) && !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) + +extern int finite ( double ); + +extern double gamma ( double ); + +#if (!defined(_XOPEN_SOURCE) || defined(_DARWIN_C_SOURCE)) + +#if !defined(__cplusplus) +extern int matherr ( struct exception * ); +#endif + +/* + * IEEE Test Vector + */ +extern double significand ( double ); + +/* + * BSD math library entry points + */ +extern double drem ( double, double ); + +/* + * Reentrant version of gamma & lgamma; passes signgam back by reference + * as the second argument; user must allocate space for signgam. + */ +#ifdef _REENTRANT +extern double gamma_r ( double, int * ); +extern double lgamma_r ( double, int * ); +#endif /* _REENTRANT */ +#endif /* (!_XOPEN_SOURCE || _DARWIN_C_SOURCE) */ +#endif /* !_ANSI_SOURCE && (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + +#endif /* __WANT_EXTENSIONS__ */ + +/* + * The following replacements for libm's floor, floorf, ceil, and ceilf are activated + * when the flag "-ffast-math" is passed to the gcc compiler. These functions do not + * distinguish between -0.0 and 0.0, so are not IEC6509 compliant for argument -0.0. + */ +#if defined(__FAST_MATH__) && !defined(__cplusplus) + +#define __FSELS(e,t,f) (((e) >= 0.0f) ? (t) : (f)) +#define __FSEL(e,t,f) (((e) >= 0.0) ? (t) : (f)) + +static __inline__ float __fastmath_floorf( float f ) __attribute__((__always_inline__)); +static __inline__ float __fastmath_floorf( float f ) +{ + float b, c, d, e, g, h, t; + + c = __FSELS( f, -8388608.f, 8388608.f ); b = fabsf( f ); + d = f - c; e = b - 8388608.f; + __asm__("" : "+f" (d)); /* Tell compiler value of d cannot be optimized away. */ + d = d + c; + g = f - d; + h = __FSELS( g, 0.0f, 1.0f ); + t = d - h; + return __FSELS( e, f, t ); +} + +static __inline__ float __fastmath_ceilf( float f ) __attribute__((__always_inline__)); +static __inline__ float __fastmath_ceilf( float f ) +{ + float b, c, d, e, g, h, t; + + c = __FSELS( f, -8388608.f, 8388608.f ); b = fabsf( f ); + d = f - c; e = b - 8388608.f; + __asm__("" : "+f" (d)); /* Tell compiler value of d cannot be optimized away. */ + d = d + c; + g = d - f; + h = __FSELS( g, 0.0f, 1.0f ); + t = d + h; + return __FSELS( e, f, t ); +} + +static __inline__ double __fastmath_floor( double f ) __attribute__((__always_inline__)); +static __inline__ double __fastmath_floor( double f ) +{ + double b, c, d, e, g, h, t; + + c = __FSEL( f, -4503599627370496., 4503599627370496. ); b = fabs( f ); + d = f - c; e = b - 4503599627370496.; + __asm__("" : "+f" (d)); /* Tell compiler value of d cannot be optimized away. */ + d = d + c; + g = f - d; + h = __FSEL( g, 0.0, 1.0 ); + t = d - h; + return __FSEL( e, f, t ); +} + +static __inline__ double __fastmath_ceil( double f ) __attribute__((__always_inline__)); +static __inline__ double __fastmath_ceil( double f ) +{ + double b, c, d, e, g, h, t; + + c = __FSEL( f, -4503599627370496., 4503599627370496. ); b = fabs( f ); + d = f - c; e = b - 4503599627370496.; + __asm__("" : "+f" (d)); /* Tell compiler value of d cannot be optimized away. */ + d = d + c; + g = d - f; + h = __FSEL( g, 0.0, 1.0 ); + t = d + h; + return __FSEL( e, f, t ); +} + +#define floorf(x) __fastmath_floorf((x)) +#define ceilf(x) __fastmath_ceilf((x)) +#define floor(x) __fastmath_floor((x)) +#define ceil(x) __fastmath_ceil((x)) + +#endif /* __FAST_MATH__ && !__cplusplus */ + +#ifdef __cplusplus +} +#endif + +#endif /* __MATH__ */ Index: branches/azimutz/Cleancut/i386/include/architecture/ppc/pseudo_inst.h =================================================================== --- branches/azimutz/Cleancut/i386/include/architecture/ppc/pseudo_inst.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/architecture/ppc/pseudo_inst.h (revision 885) @@ -0,0 +1,447 @@ +/* + * Copyright (c) 1999 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@ + */ +/* Copyright (c) 1996 NeXT Software, Inc. All rights reserved. + * + * File: architecture/ppc/pseudo_inst.h + * Author: Mike DeMoney + * + * This header file defines assembler pseudo-instruction macros for + * for the ppc. + * + * NOTE: This is obviously only useful to include in assembly + * code source. + * + * ALSO NOTE: These macros don't attempt to be 64-bit compatable + * + * HISTORY + * 29-Dec-96 Umesh Vaishampayan (umeshv@NeXT.com) + * Ported from m98k. + * 05-Nov-92 Mike DeMoney (mike@next.com) + * Created. + */ + +#ifndef _ARCH_PPC_PSEUDO_INST_H_ +#define _ARCH_PPC_PSEUDO_INST_H_ + +#include <architecture/ppc/reg_help.h> +#include <architecture/ppc/asm_help.h> + +#ifdef __ASSEMBLER__ + +/* + * Pseudo instruction definitions + */ + +/* + * Macro package initialization + */ + .set __no_at,0 /* allow at by default */ + +/* + * .at_off -- disable use of at by macros + * .at_on -- enable use of at by macros + */ +.macro .at_off + .set __no_at,1 +.endmacro + +.macro .at_on + .set __no_at,0 +.endmacro + +/* + * li32 rD,IMMED + * + * Load 32-bit immediate into rD + * FIXME: Need a way to undefine built-in macro for this. + */ +.macro li32 // li32 rD,immed +.if $n != 2 + .abort "invalid operands of li32" +.endif +.abs __is_abs,$1 +.if !__is_abs + addis $0,0,hi16($1) + ori $0,$0,lo16($1) +.elseif $1 == 0 + addi $0,0,0 +.elseif ($1 & 0xffff) == 0 + addis $0,0,hi16($1) +.elseif ($1 & 0xffff8000) == 0 + addi $0,0,$1 +.elseif ($1 & 0xffff8000) == 0xffff8000 + addi $0,0,$1 +.else + addis $0,0,hi16($1) + ori $0,$0,lo16($1) +.endif +.endmacro + + +/* + * andi32. rD,rS1,IMMED + * + * Perform "andi." with (possibly) 32-bit immediate + */ +.macro andi32. // andi32. rD,rS1,IMMED +.if $n != 3 + .abort "invalid operands of andi." +.endif + .set __used_at,0 +.abs __is_abs,$2 +.if !__is_abs + .set __used_at,1 + li32 at,$2 + and. $0,$1,at +.elseif ($2 & 0xffff0000) == 0 + andi. $0,$1,$2 +.elseif ($2 & 0xffff) == 0 + andis. $0,$1,hi16($2) +.else + .set __used_at,1 + li32 at,$2 + and. $0,$1,at +.endif +.if __no_at & __used_at + .abort "Macro uses at while .no_at in effect" +.endif +.endmacro + +/* + * ori32 rD,rS1,IMMED + * + * Perform "ori" with (possibly) 32-bit immediate + */ +.macro ori32 // ori32 rD,rS1,IMMED +.if $n != 3 + .abort "invalid operands of ori" +.endif +.abs __is_abs,$2 +.if !__is_abs + oris $0,$1,hi16($2) + ori $0,$1,lo16($2) +.elseif ($2 & 0xffff0000) == 0 + ori $0,$1,$2 +.elseif ($2 & 0xffff) == 0 + oris $0,$1,hi16($2) +.else + oris $0,$1,hi16($2) + ori $0,$1,lo16($2) +.endif +.endmacro + +/* + * xori32 rD,rS1,IMMED + * + * Perform "xor" with (possibly) 32-bit immediate + */ +.macro xori32 // xori32 rD,rS1,IMMED +.if $n != 3 + .abort "invalid operands of xori" +.endif +.abs __is_abs,$2 +.if !__is_abs + xoris $0,$1,hi16($2) + xori $0,$1,lo16($2) +.elseif ($2 & 0xffff0000) == 0 + xori $0,$1,$2 +.elseif ($2 & 0xffff) == 0 + xoris $0,$1,hi16($2) +.else + xoris $0,$1,hi16($2) + xori $0,$1,lo16($2) +.endif +.endmacro + + +/* + * MEMREF_INST -- macros to memory referencing instructions + * "capable" of dealing with 32 bit offsets. + * + * NOTE: Because the assembler doesn't have any mechanism for easily + * parsing the d(rS) syntax of register-displacement form instructions, + * these instructions do NOT mirror the normal memory reference + * instructions. The following "transformation" is used: + * lbz rD,d(rS) + * becomes: + * lbz32 rD,rS,d + * I.e.: "32" is appended to the instruction name and the base register + * and displacement become the 2'nd and 3'rd comma-separated operands. + * + * The forms: + * lbz32 rD,d + * and: + * lbz32 rD,rS + * are also recognized and the missing operand is assumed 0. + * + * ALSO NOTE: r0 or zt should never be used as rS in these instructions. + * Use "0" as rS in this case. + */ +#define MEMREF_INST(op) \ +.macro op ## 32 @\ +.set __used_at,0 @\ +.if $n == 3 @\ + .greg __is_greg,$1 @\ + .abs __is_abs,$2 @\ + .if __is_abs @\ + .if ($2 & 0xffff8000) == 0 @\ + op $0,$2($1) @\ + .elseif ($2 & 0xffff8000) == 0xffff8000 @\ + op $0,$2($1) @\ + .else @\ + .if !__is_greg @\ + .set __used_at,1 @\ + lis at,ha16($2) @\ + op $0,lo16($2)(at) @\ + .else @\ + .set __used_at,1 @\ + lis at,ha16($2) @\ + add at,at,$1 @\ + op $0,lo16($2)(at) @\ + .endif @\ + .endif @\ + .else @\ + .if !__is_greg @\ + .set __used_at,1 @\ + lis at,ha16($2) @\ + op $0,lo16($2)(at) @\ + .else @\ + .set __used_at,1 @\ + lis at,ha16($2) @\ + add at,at,$1 @\ + op $0,lo16($2)(at) @\ + .endif @\ + .endif @\ +.elseif $n == 2 @\ + .greg __is_greg,$1 @\ + .if !__is_greg @\ + .abs __is_abs,$1 @\ + .if __is_abs @\ + .if ($1 & 0xffff8000) == 0 @\ + op $0,$1(0) @\ + .elseif ($1 & 0xffff8000) == 0xffff8000 @\ + op $0,$1(0) @\ + .else @\ + .set __used_at,1 @\ + lis at,ha16($1) @\ + op $0,lo16($1)(at) @\ + .endif @\ + .else @\ + .set __used_at,1 @\ + lis at,ha16($1) @\ + op $0,lo16($1)(at) @\ + .endif @\ + .else @\ + op $0,0($1) @\ + .endif @\ +.else @\ + .abort "Invalid operands of " #op "32" @\ +.endif @\ +.if __no_at & __used_at @\ + .abort "Macro uses at while .no_at in effect" @\ +.endif @\ +.endmacro + +MEMREF_INST(lbz) +MEMREF_INST(lhz) +MEMREF_INST(lha) +MEMREF_INST(lwz) +MEMREF_INST(lwa) +MEMREF_INST(ld) + +MEMREF_INST(stb) +MEMREF_INST(sth) +MEMREF_INST(stw) +MEMREF_INST(std) + +MEMREF_INST(lmw) +MEMREF_INST(lmd) +MEMREF_INST(stmw) +MEMREF_INST(stmd) + +/* + * ARITH_INST -- define 32-bit immediate forms of arithmetic + * instructions + * + * E.g. addi32 rD,rS,IMMED + */ +#define ARITH_INST(op, op3) \ +.macro op ## 32 @\ +.if $n != 3 @\ + .abort "invalid operands to " #op "32" @\ +.endif @\ +.abs __is_abs,$2 @\ +.if __is_abs @\ + .if ($2 & 0xffff8000) == 0 @\ + op $0,$1,$2 @\ + .elseif ($2 & 0xffff8000) == 0xffff8000 @\ + op $0,$1,$2 @\ + .elseif __no_at @\ + .abort "Macro uses at while .no_at in effect" @\ + .else @\ + li32 at,$2 @\ + op3 $0,$1,at @\ + .endif @\ +.elseif __no_at @\ + .abort "Macro uses at while .no_at in effect" @\ +.else @\ + li32 at,$2 @\ + op3 $0,$1,at @\ +.endif @\ +.endmacro + +ARITH_INST(addi, add) +ARITH_INST(subi, sub) +ARITH_INST(addic, addc) +ARITH_INST(subic, subc) +ARITH_INST(mulli, mull) + +/* + * COND_ARITH_INST -- define 32-bit immediate forms of arithmetic + * instructions that set bits in the condition register + * + * E.g. addic32. rD,rS,IMMED + */ +#define COND_ARITH_INST(name, op, op3) \ +.macro name @\ +.if $n != 3 @\ + .abort "invalid operands to " #name @\ +.endif @\ +.abs __is_abs,$2 @\ +.if __is_abs @\ + .if ($2 & 0xffff8000) == 0 @\ + op $0,$1,$2 @\ + .elseif ($2 & 0xffff8000) == 0xffff8000 @\ + op $0,$1,$2 @\ + .elseif __no_at @\ + .abort "Macro uses at while .no_at in effect" @\ + .else @\ + li32 at,$2 @\ + op3 $0,$1,at @\ + .endif @\ +.elseif __no_at @\ + .abort "Macro uses at while .no_at in effect" @\ +.else @\ + li32 at,$2 @\ + op3 $0,$1,at @\ +.endif @\ +.endmacro + +COND_ARITH_INST(addic32., addic., addc.) +COND_ARITH_INST(subic32., subic., subc.) + +/* + * CMPEX_INST -- define 32-bit immediate forms of extended compare + * instructions + * + * E.g. cmpwi32 cr3,rS,IMMED + * cmpwi32 rS,IMMED + */ +#define CMPEX_INST(op, op3) \ +.macro op ## 32 @\ +.if $n == 3 @\ + .abs __is_abs,$2 @\ + .if __is_abs @\ + .if ($2 & 0xffff8000) == 0 @\ + op $0,$1,$2 @\ + .elseif ($2 & 0xffff8000) == 0xffff8000 @\ + op $0,$1,$2 @\ + .elseif __no_at @\ + .abort "Macro uses at while .no_at in effect" @\ + .else @\ + li32 at,$2 @\ + op3 $0,$1,at @\ + .endif @\ + .elseif __no_at @\ + .abort "Macro uses at while .no_at in effect" @\ + .else @\ + li32 at,$2 @\ + op3 $0,$1,at @\ + .endif @\ +.elseif $n == 2 @\ + .abs __is_abs,$1 @\ + .if __is_abs @\ + .if ($1 & 0xffff8000) == 0 @\ + op $0,$1 @\ + .elseif ($1 & 0xffff8000) == 0xffff8000 @\ + op $0,$1 @\ + .elseif __no_at @\ + .abort "Macro uses at while .no_at in effect" @\ + .else @\ + li32 at,$1 @\ + op3 $0,at @\ + .endif @\ + .elseif __no_at @\ + .abort "Macro uses at while .no_at in effect" @\ + .else @\ + li32 at,$1 @\ + op3 $0,at @\ + .endif @\ +.else @\ + .abort "invalid operands to " #op "32" @\ +.endif @\ +.endmacro + +CMPEX_INST(cmpdi, cmpd) +CMPEX_INST(cmpwi, cmpw) +CMPEX_INST(cmpldi, cmpld) +CMPEX_INST(cmplwi, cmplw) + +/* + * CMP_INST -- define 32-bit immediate forms of standard compare + * instructions + * + * E.g. cmpi32 cr3,0,rS,IMMED + */ +#define CMP_INST(op, op3) \ +.macro op ## 32 @\ +.if $n == 4 @\ + .abs __is_abs,$3 @\ + .if __is_abs @\ + .if ($3 & 0xffff8000) == 0 @\ + op $0,$1,$2,$3 @\ + .elseif ($3 & 0xffff8000) == 0xffff8000 @\ + op $0,$1,$2,$3 @\ + .elseif __no_at @\ + .abort "Macro uses at while .no_at in effect" @\ + .else @\ + li32 at,$3 @\ + op3 $0,$1,$2,at @\ + .endif @\ + .elseif __no_at @\ + .abort "Macro uses at while .no_at in effect" @\ + .else @\ + li32 at,$3 @\ + op3 $0,$1,$2,at @\ + .endif @\ +.else @\ + .abort "invalid operands to " #op "32" @\ +.endif @\ +.endmacro + +CMP_INST(cmpi, cmp) +CMP_INST(cmpli, cmpl) + +#endif /* __ASSEMBLER__ */ + +#endif /* _ARCH_PPC_PSEUDO_INST_H_ */ Index: branches/azimutz/Cleancut/i386/include/architecture/ppc/cframe.h =================================================================== --- branches/azimutz/Cleancut/i386/include/architecture/ppc/cframe.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/architecture/ppc/cframe.h (revision 885) @@ -0,0 +1,62 @@ +/* + * Copyright (c) 1999-2004 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@ + */ +/* Copyright (c) 1991 NeXT Software, Inc. All rights reserved. + * + * File: architecture/ppc/cframe.h + * Author: Mike DeMoney, NeXT Software, Inc. + * + * This include file defines C calling sequence defines + * for ppc port. + * + * HISTORY + * 20-May-97 Umesh Vaishampayan (umeshv@apple.com) + * Added C_RED_ZONE. + * 29-Dec-96 Umesh Vaishampayan (umeshv@NeXT.com) + * Ported from m98k. + * 11-June-91 Mike DeMoney (mike@next.com) + * Created. + */ + +#ifndef _ARCH_PPC_CFRAME_H_ +#define _ARCH_PPC_CFRAME_H_ + +/* Note that these values are copies of the somewhat more authoritative + * values in <architecture/ppc/mode_independent_asm.h>. We do not + * include that file to avoid breaking legacy clients due to name + * collisions. + * + * Note also that C_ARGSAVE_LEN isn't well defined or useful in PPC. + * Most legacy uses of it are assuming it is the minimum stack frame + * size, which is what we define it to be. + */ +#if defined (__ppc64__) +#define C_ARGSAVE_LEN 64 /* "minimum arg save area" (but see above) */ +#define C_STACK_ALIGN 32 /* stack must be 32 byte aligned */ +#define C_RED_ZONE 320 /* 320 bytes to skip over saved registers */ +#else +#define C_ARGSAVE_LEN 32 /* "minimum arg save area" (but see above) */ +#define C_STACK_ALIGN 16 /* stack must be 16 byte aligned */ +#define C_RED_ZONE 224 /* 224 bytes to skip over saved registers */ +#endif + +#endif /* _ARCH_PPC_CFRAME_H_ */ Index: branches/azimutz/Cleancut/i386/include/architecture/ppc/alignment.h =================================================================== --- branches/azimutz/Cleancut/i386/include/architecture/ppc/alignment.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/architecture/ppc/alignment.h (revision 885) @@ -0,0 +1,79 @@ +/* + * Copyright (c) 1999 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@ + */ +/* + * Copyright (c) 1996 NeXT Software, Inc. + * + * File: architecture/ppc/alignment.h + + * Natural alignment of shorts and longs (for ppc) + * + * HISTORY + * + * 29-Dec-96 Umesh Vaishampayan (umeshv@NeXT.com) + * Ported from m98k. + * 2 Sept 1992 Brian Raymor at NeXT + * Moved over to architecture. + * 17 August 1992 Jack Greenfield at NeXT + * Created. + */ + +__inline__ static unsigned short +get_align_short(void *ivalue) +{ + unsigned short ovalue = ((unsigned char *) ivalue)[0]; + + ovalue <<= 8 * sizeof(unsigned char); + return ovalue + ((unsigned char *) ivalue)[1]; +} + +__inline__ static unsigned short +put_align_short(unsigned short ivalue, void *ovalue) +{ + unsigned short *tvalue = &ivalue; + + ((unsigned char *) ovalue)[0] = ((unsigned char *) tvalue)[0]; + ((unsigned char *) ovalue)[1] = ((unsigned char *) tvalue)[1]; + return ivalue; +} + +__inline__ static unsigned long +get_align_long(void *ivalue) +{ + unsigned long ovalue = get_align_short(ivalue); + + ovalue <<= 8 * sizeof(unsigned short); + return ovalue + get_align_short(((unsigned char *) ivalue) + sizeof(short)); +} + +__inline__ static unsigned long +put_align_long(unsigned long ivalue, void *ovalue) +{ + unsigned long *tvalue = &ivalue; + + ((unsigned char *) ovalue)[0] = ((unsigned char *) tvalue)[0]; + ((unsigned char *) ovalue)[1] = ((unsigned char *) tvalue)[1]; + ((unsigned char *) ovalue)[2] = ((unsigned char *) tvalue)[2]; + ((unsigned char *) ovalue)[3] = ((unsigned char *) tvalue)[3]; + return ivalue; +} + Index: branches/azimutz/Cleancut/i386/include/architecture/ppc/byte_order.h =================================================================== --- branches/azimutz/Cleancut/i386/include/architecture/ppc/byte_order.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/architecture/ppc/byte_order.h (revision 885) @@ -0,0 +1,28 @@ +/* + * Copyright (c) 1999-2002 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@ + */ + +/* + * Maintain source compatibility + */ + +#include <architecture/byte_order.h> Index: branches/azimutz/Cleancut/i386/include/architecture/ppc/fenv.h =================================================================== --- branches/azimutz/Cleancut/i386/include/architecture/ppc/fenv.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/architecture/ppc/fenv.h (revision 885) @@ -0,0 +1,179 @@ +/* + * Copyright (c) 2002 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@ + */ + +/******************************************************************************* +* * +* File: fenv.h * +* * +* Contains: typedefs and prototypes for C99 floating point environment. * +* * +*******************************************************************************/ + +#ifndef __FENV__ +#define __FENV__ + +#if defined( __i386__ ) || defined( __x86_64__ ) + #error Wrong arch. This is PowerPC only. +#endif + +#if defined(__GNUC__) && (__GNUC__ >= 4) +#pragma GCC fenv +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* + A collection of functions designed to provide access to the floating + point environment for numerical programming. It is modeled after + the floating-point requirements in C9X. + + The file <fenv.h> declares many functions in support of numerical + programming. Programs that test flags or run under + non-default modes must do so under the effect of an enabling + "fenv_access" pragma. +*/ + +/******************************************************************************** +* * +* fenv_t is a type for representing the entire floating-point * +* environment in a single object. * +* * +* fexcept_t is a type for representing the floating-point * +* exception flag state collectively. * +* * +********************************************************************************/ +typedef unsigned int fenv_t; +typedef unsigned int fexcept_t; + +/* Definitions of floating-point exception macros */ +#define FE_INEXACT 0x02000000 +#define FE_DIVBYZERO 0x04000000 +#define FE_UNDERFLOW 0x08000000 +#define FE_OVERFLOW 0x10000000 +#define FE_INVALID 0x20000000 +#define FE_ALL_EXCEPT 0x3E000000 + +/* Definitions of rounding direction macros */ +#define FE_TONEAREST 0x00000000 +#define FE_TOWARDZERO 0x00000001 +#define FE_UPWARD 0x00000002 +#define FE_DOWNWARD 0x00000003 + +/* default environment object */ +extern const fenv_t _FE_DFL_ENV; +#define FE_DFL_ENV &_FE_DFL_ENV /* pointer to default environment */ + +/******************************************************************************* +* The following functions provide access to the exception flags. The * +* "int" input argument can be constructed by bitwise ORs of the exception * +* macros: for example: FE_OVERFLOW | FE_INEXACT. * +*******************************************************************************/ + +/******************************************************************************* +* The function "feclearexcept" clears the supported exceptions represented * +* by its argument. * +*******************************************************************************/ + +extern int feclearexcept(int); + + +/******************************************************************************* +* The function "fegetexceptflag" stores a representation of the exception * +* flags indicated by its integer argument through the fexcept_t pointer * +* argument. * +*******************************************************************************/ + +extern int fegetexceptflag(fexcept_t *, int); + + +/******************************************************************************* +* The function "feraiseexcept" raises the supported exceptions * +* represented by its argument. * +*******************************************************************************/ + +extern int feraiseexcept(int); + + +/******************************************************************************* +* The function "fesetexceptflag" sets or clears the exception flags indicated * +* by the its integer argument according to the representation in the * +* object pointed to by the fexcept_t pointer argument. The value of the * +* object must have been set by a previous call to "fegetexceptflag". * +* This function does not raise exceptions; it just sets the state of * +* the flags. * +*******************************************************************************/ + +extern int fesetexceptflag(const fexcept_t *, int); + + +/******************************************************************************* +* The function "fetestexcept" determines which of the specified subset of * +* the exception flags are currently set. The integer argument specifies * +* the exception flags to be queried as a bitwise OR of the exception * +* macros. This function returns the bitwise OR of the exception macros * +* corresponding to the currently set exceptions included in "excepts". * +*******************************************************************************/ + +extern int fetestexcept(int); + + +/******************************************************************************* +* The following functions provide control of rounding direction modes. * +*******************************************************************************/ + +/******************************************************************************* +* The function "fegetround" returns the value of the rounding direction * +* macro which represents the current rounding direction. * +*******************************************************************************/ + +extern int fegetround(void); + + +/******************************************************************************* +* The function "fesetround" establishes the rounding direction represented * +* by its argument. It returns zero if and only if the argument matches * +* a rounding direction macro. If not, the rounding direction is not * +* changed. * +*******************************************************************************/ + +extern int fesetround(int); + + +/******************************************************************************* +* The following functions manage the floating-point environment, exception * +* flags and dynamic modes, as one entity. * +*******************************************************************************/ + +extern int fegetenv(fenv_t *); +extern int feholdexcept(fenv_t *); +extern int fesetenv(const fenv_t *); +extern int feupdateenv(const fenv_t *); + + +#ifdef __cplusplus +} +#endif + +#endif /* __FENV__ */ + Index: branches/azimutz/Cleancut/i386/include/architecture/ppc/basic_regs.h =================================================================== --- branches/azimutz/Cleancut/i386/include/architecture/ppc/basic_regs.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/architecture/ppc/basic_regs.h (revision 885) @@ -0,0 +1,301 @@ +/* + * Copyright (c) 1999 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@ + */ +/* Copyright (c) 1996 NeXT Software, Inc. All rights reserved. + * + * File: architecture/ppc/basic_regs.h + * Author: Doug Mitchell, NeXT Software, Inc. + * + * Basic ppc registers. + * + * HISTORY + * 22-May-97 Umesh Vaishampayan (umeshv@apple.com) + Updated to match MPCFPE32B/AD 1/97 REV. 1 + * 29-Dec-96 Umesh Vaishampayan (umeshv@NeXT.com) + * Ported from m98k. + * 05-Nov-92 Doug Mitchell at NeXT + * Created. + */ + +#ifndef _ARCH_PPC_BASIC_REGS_H_ +#define _ARCH_PPC_BASIC_REGS_H_ + +#include <architecture/ppc/reg_help.h> +#include <architecture/ppc/macro_help.h> + +#if !defined(__ASSEMBLER__) + +/* + * Number of General Purpose registers. + */ +#define PPC_NGP_REGS 32 + +/* + * Common half-word used in Machine State Register and in + * various exception frames. Defined as a macro because the compiler + * will align a struct to a word boundary when used inside another struct. + */ +#define MSR_BITS \ + unsigned ee:BIT_WIDTH(15), /* external intr enable */ \ + pr:BIT_WIDTH(14), /* problem state */ \ + fp:BIT_WIDTH(13), /* floating point avail */ \ + me:BIT_WIDTH(12), /* machine check enable */ \ + fe0:BIT_WIDTH(11), /* fp exception mode 0 */ \ + se:BIT_WIDTH(10), /* single step enable */ \ + be:BIT_WIDTH(9), /* branch trace enable */ \ + fe1:BIT_WIDTH(8), /* fp exception mode 0 */ \ + rsvd1:BIT_WIDTH(7), /* reserved */ \ + ip:BIT_WIDTH(6), /* interrupt prefix */ \ + ir:BIT_WIDTH(5), /* instruction relocate */ \ + dr:BIT_WIDTH(4), /* data relocate */ \ + rsvd2:BITS_WIDTH(3,2), /* reserved */ \ + ri:BIT_WIDTH(1), /* recoverable exception */ \ + le:BIT_WIDTH(0) /* Little-endian mode */ + +/* + * Machine state register. + * Read and written via get_msr() and set_msr() inlines, below. + */ +typedef struct { + unsigned rsvd3:BITS_WIDTH(31,19), // reserved + pow:BIT_WIDTH(18), // Power management enable + rsvd0: BIT_WIDTH(17), // reserved + ile: BIT_WIDTH(16); // exception little endian + + MSR_BITS; // see above +} msr_t; + +/* + * Data Storage Interrupt Status Register (DSISR) + */ +typedef struct { + unsigned dse:BIT_WIDTH(31); // direct-store error + unsigned tnf:BIT_WIDTH(30); // translation not found + unsigned :BITS_WIDTH(29,28); + unsigned pe:BIT_WIDTH(27); // protection error + unsigned dsr:BIT_WIDTH(26); // lwarx/stwcx to direct-store + unsigned rw:BIT_WIDTH(25); // 1 => store, 0 => load + unsigned :BITS_WIDTH(24,23); + unsigned dab:BIT_WIDTH(22); // data address bkpt (601) + unsigned ssf:BIT_WIDTH(21); // seg table search failed + unsigned :BITS_WIDTH(20,0); +} dsisr_t; + +/* + * Instruction Storage Interrupt Status Register (really SRR1) + */ +typedef struct { + unsigned :BIT_WIDTH(31); + unsigned tnf:BIT_WIDTH(30); // translation not found + unsigned :BIT_WIDTH(29); + unsigned dse:BIT_WIDTH(28); // direct-store fetch error + unsigned pe:BIT_WIDTH(27); // protection error + unsigned :BITS_WIDTH(26,22); + unsigned ssf:BIT_WIDTH(21); // seg table search failed + unsigned :BITS_WIDTH(20,16); + MSR_BITS; +} isisr_t; + +/* + * Alignment Interrupt Status Register (really DSISR) + * NOTE: bit numbers in field *names* are in IBM'ese (0 is MSB). + * FIXME: Yuck!!! Double Yuck!!! + */ +typedef struct { + unsigned :BITS_WIDTH(31,20); + unsigned ds3031:BITS_WIDTH(19,18);// bits 30:31 if DS form + unsigned :BIT_WIDTH(17); + unsigned x2930:BITS_WIDTH(16,15); // bits 29:30 if X form + unsigned x25:BIT_WIDTH(14); // bit 25 if X form or + // bit 5 if D or DS form + unsigned x2124:BITS_WIDTH(13,10); // bits 21:24 if X form or + // bits 1:4 if D or DS form + unsigned all615:BITS_WIDTH(9,0); // bits 6:15 of instr + MSR_BITS; +} aisr_t; + +/* + * Program Interrupt Status Register (really SRR1) + */ +typedef struct { + unsigned :BITS_WIDTH(31,21); + unsigned fpee:BIT_WIDTH(20); // floating pt enable exception + unsigned ill:BIT_WIDTH(19); // illegal instruction + unsigned priv:BIT_WIDTH(18); // privileged instruction + unsigned trap:BIT_WIDTH(17); // trap program interrupt + unsigned subseq:BIT_WIDTH(16); // 1 => SRR0 points to + // subsequent instruction + MSR_BITS; +} pisr_t; + +/* + * Condition register. May not be useful in C, let's see... + */ +typedef struct { + unsigned lt:BIT_WIDTH(31), // negative + gt:BIT_WIDTH(30), // positive + eq:BIT_WIDTH(29), // equal to zero + so:BIT_WIDTH(28), // summary overflow + fx:BIT_WIDTH(27), // floating point exception + fex:BIT_WIDTH(26), // fp enabled exception + vx:BIT_WIDTH(25), // fp invalid operation + // exception + ox:BIT_WIDTH(24), // fp overflow exception + rsvd:BITS_WIDTH(23,0); // reserved +} cr_t; + +/* + * Abstract values representing fe0:fe1. + * See get_fp_exc_mode(), below. + */ +typedef enum { + FEM_IGNORE_EXCEP, // ignore exceptions + FEM_IMPR_NONREC, // imprecise nonrecoverable + FEM_IMPR_RECOV, // imprecise recoverable + FEM_PRECISE +} fp_exc_mode_t; + + +/* + * Special purpose registers. + */ + +/* + * Processor version register (special purpose register pvr). + */ +typedef struct { + unsigned version:BITS_WIDTH(31,16), + revision:BITS_WIDTH(15,0); +} pvr_t; + +/* + * Fixed point exception register (special purpose register xer) + */ +typedef struct { + unsigned so:BIT_WIDTH(31), // summary overflow + ov:BIT_WIDTH(30), // overflow + ca:BIT_WIDTH(29), // carry + rsvd1:BITS_WIDTH(28,7), // reserved + byte_count:BITS_WIDTH(6,0); +} xer_t; + +/* + * Inlines and macros to manipulate the above registers. + */ + +/* + * Get/set machine state register. + */ +static __inline__ msr_t +get_msr() +{ + msr_t __msr_tmp; + __asm__ volatile ("mfmsr %0 /* mfmsr */" : "=r" (__msr_tmp)); + return __msr_tmp; +} + +static __inline__ void +set_msr(msr_t msr) +{ + __asm__ volatile ("mtmsr %0 /* mtmsr */ " : : "r" (msr)); +} + +/* + * Determine current fp_exc_mode_t given prog_mode. + */ +static __inline__ fp_exc_mode_t +get_fp_exc_mode(pmr_t pmr) +{ + if(pmr.fe0) + return pmr.fe1 ? FEM_PRECISE : FEM_IMPR_RECOV; + else + return pmr.fe1 ? FEM_IMPR_NONREC : FEM_IGNORE_EXCEP; +} + +/* + * Software definitions for special purpose registers. + * The same register is used as per_cpu data pointer and + * vector base register. This requires that the vector + * table be the first item in the per_cpu table. + */ +#define SR_EXCEPTION_TMP_LR sprg0 +#define SR_EXCEPTION_TMP_CR sprg1 +#define SR_EXCEPTION_TMP_AT sprg2 +#define SR_PER_CPU_DATA sprg3 +#define SR_VBR sprg3 + +/* + * Get/set special purpose registers. + * + * GET_SPR - get SPR by name. + * + * Example usage: + * + * { + * xer_t some_xer; + * + * some_xer = GET_SPR(xer_t, xer); + * ... + * } + * + * This is a strange one. We're creating a list of C expressions within + * a set of curlies; the last expression ("__spr_tmp;") is the return value + * of the statement created by the curlies. + * + */ + +#define GET_SPR(type, spr) \ +({ \ + unsigned __spr_tmp; \ + __asm__ volatile ("mfspr %0, " STRINGIFY(spr) : "=r" (__spr_tmp)); \ + *(type *)&__spr_tmp; \ +}) + +/* + * Example usage of SET_SPR: + * + * { + * xer_t some_xer; + * + * ...set up some_xer... + * SET_SPR(xer, some_xer); + * } + */ +#define SET_SPR(spr, val) \ +MACRO_BEGIN \ + __typeof__ (val) __spr_tmp = (val); \ + __asm__ volatile ("mtspr "STRINGIFY(spr) ", %0" : : "r" (__spr_tmp)); \ +MACRO_END + +/* + * Fully synchronize instruction stream. + */ +static __inline__ void +ppc_sync() +{ + __asm__ volatile ("sync /* sync */" : : ); +} + +#endif /* ! __ASSEMBLER__ */ + +#endif /* _ARCH_PPC_BASIC_REGS_H_ */ + Index: branches/azimutz/Cleancut/i386/include/architecture/ppc/mode_independent_asm.h =================================================================== --- branches/azimutz/Cleancut/i386/include/architecture/ppc/mode_independent_asm.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/architecture/ppc/mode_independent_asm.h (revision 885) @@ -0,0 +1,187 @@ +/* + * Copyright (c) 2004 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 _PPC_MODE_INDEPENDENT_ASM_H_ +#define _PPC_MODE_INDEPENDENT_ASM_H_ + + +/* This file facilitates writing mode-independent PPC assembler source, ie + * source which can be built both for 32-bit mode (__ppc__) and 64-bit + * mode (__ppc64__.) + * + * It defines constants such as the number of bytes in a GPR (GPR_BYTES), + * macros to address and call externals (MI_GET_ADDRESS), and a set of mode + * independent PPC assembler pseudo-mnemonics. + * + * The assembler mnemonics map to word operations when building for __ppc__, + * and to doubleword operations when building for __ppc64__. They use "g" to + * stand for either word or doubleword, depending on the target mode. + * + * Although there are certainly other things to be aware of when writing code + * targeted at both 32 and 64-bit mode, using these macros and psuedo-mnemonics + * is surprisingly helpful. + */ + +#if defined(__ppc64__) +#define MODE_CHOICE(x, y) y +#elif defined(__ppc__) +#define MODE_CHOICE(x, y) x +#else +#error undefined architecture +#endif + + +/* The mode-independent "g" mnemonics. */ + +#define cmpg MODE_CHOICE(cmpw, cmpd) +#define cmplg MODE_CHOICE(cmplw, cmpld) +#define cmpgi MODE_CHOICE(cmpwi, cmpdi) +#define cmplgi MODE_CHOICE(cmplwi, cmpldi) +#define srgi MODE_CHOICE(srwi, srdi) +#define srg MODE_CHOICE(srw, srd) +#define sragi MODE_CHOICE(srawi, sradi) +#define slgi MODE_CHOICE(slwi, sldi) +#define rotlgi MODE_CHOICE(rotlwi, rotldi) +#define clrrgi MODE_CHOICE(clrrwi, clrrdi) +#define cntlzg MODE_CHOICE(cntlzw, cntlzd) +#define lg MODE_CHOICE(lwz, ld) +#define stg MODE_CHOICE(stw, std) +#define lgx MODE_CHOICE(lwzx, ldx) +#define stgx MODE_CHOICE(stwx, stdx) +#define lgu MODE_CHOICE(lwzu, ldu) +#define stgu MODE_CHOICE(stwu, stdu) +#define lgux MODE_CHOICE(lwzux, ldux) +#define stgux MODE_CHOICE(stwux, stdux) +#define lgwa MODE_CHOICE(lwz, lwa) + +#define g_long MODE_CHOICE(long, quad) // usage is ".g_long" + + +/* Architectural constants. */ + +#define GPR_BYTES MODE_CHOICE(4,8) // size of a GPR in bytes +#define LOG2_GPR_BYTES MODE_CHOICE(2,3) // log2(GPR_BYTES) + + +/* Stack frame definitions. To keep things simple, we are limited + * to eight arguments and two locals. + */ +#define SF_CRSAVE MODE_CHOICE(4,8) +#define SF_RETURN MODE_CHOICE(8,16) +#define SF_ARG1 MODE_CHOICE(24,48) +#define SF_ARG2 MODE_CHOICE(28,56) +#define SF_ARG3 MODE_CHOICE(32,64) +#define SF_ARG4 MODE_CHOICE(36,72) +#define SF_ARG5 MODE_CHOICE(40,80) +#define SF_ARG6 MODE_CHOICE(44,88) +#define SF_ARG7 MODE_CHOICE(48,96) +#define SF_ARG8 MODE_CHOICE(52,104) +#define SF_LOCAL1 MODE_CHOICE(56,112) +#define SF_LOCAL2 MODE_CHOICE(60,120) +#define SF_SIZE MODE_CHOICE(64,128) + +#define SF_ALIGNMENT MODE_CHOICE(16,32) +#define SF_REDZONE MODE_CHOICE(224,320) + +#define SF_ROUND(x) (((x)+SF_ALIGNMENT-1)&(-SF_ALIGNMENT)) + +#define SF_MINSIZE MODE_CHOICE(64,128) + + +/* WARNING: some clients fall through this macro, so do not attempt + * to optimize by doing an ".align 5" in the macro. Do the 32-byte + * alignment in the .s file, before invoking the macro. + */ +#define MI_ENTRY_POINT(name) \ + .globl name @\ + .text @\ + .align 2 @\ +name: + +#define MI_PUSH_STACK_FRAME \ + mflr r0 @\ + stg r0,SF_RETURN(r1) @\ + stgu r1,-SF_SIZE(r1) + +#define MI_POP_STACK_FRAME_AND_RETURN \ + lg r0,SF_RETURN+SF_SIZE(r1) @\ + addi r1,r1,SF_SIZE @\ + mtlr r0 @\ + blr + + +/* MI_GET_ADDRESS(reg,var) is the basic primitive to address data or code. + * It works both in 32 and 64-bit mode, and with static and dynamic + * code generation. Note however that it can be invoked at most once per + * symbol, since it always creates a non_lazy_ptr in dynamic mode. + * Save the address for re-use, rather than invoking the macro again. + */ +#if defined(__DYNAMIC__) +#define MI_GET_ADDRESS(reg,var) \ + mflr r0 @\ + bcl 20,31,1f @\ +1: mflr reg @\ + mtlr r0 @\ + addis reg,reg,ha16(L ## var ## __non_lazy_ptr - 1b) @\ + lg reg,lo16(L ## var ## __non_lazy_ptr - 1b)(reg) @\ + .non_lazy_symbol_pointer @\ + .align LOG2_GPR_BYTES @\ + .indirect_symbol var @\ +L ## var ## __non_lazy_ptr: @\ + .g_long 0 @\ + .text @\ + .align 2 +#else /* ! __DYNAMIC__ */ +#define MI_GET_ADDRESS(reg,var) \ + lis reg,hi16(var) @\ + ori reg,reg,lo16(var) +#endif + + +/* MI_CALL_EXTERNAL(var) */ + +#if defined(__DYNAMIC__) +#define MI_CALL_EXTERNAL(var) \ + MI_GET_ADDRESS(r12,var) @\ + mtctr r12 @\ + bctrl +#else /* ! __DYNAMIC__ */ +#define MI_CALL_EXTERNAL(var) \ + bl var +#endif + + +/* MI_BRANCH_EXTERNAL(var) */ + +#if defined(__DYNAMIC__) +#define MI_BRANCH_EXTERNAL(var) \ + MI_GET_ADDRESS(r12,var) @\ + mtctr r12 @\ + bctr +#else /* ! __DYNAMIC__ */ +#define MI_BRANCH_EXTERNAL(var) \ + b var +#endif + + +#endif /* _PPC_MODE_INDEPENDENT_ASM_H_ */ Index: branches/azimutz/Cleancut/i386/include/architecture/ppc/fp_regs.h =================================================================== --- branches/azimutz/Cleancut/i386/include/architecture/ppc/fp_regs.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/architecture/ppc/fp_regs.h (revision 885) @@ -0,0 +1,148 @@ +/* + * Copyright (c) 1999 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@ + */ +/* Copyright (c) 1996 NeXT Software, Inc. All rights reserved. + * + * File: architecture/ppc/fp_regs.h + * Author: Doug Mitchell, NeXT Software, Inc. + * + * ppc floating point registers. + * + * HISTORY + * 29-Dec-96 Umesh Vaishampayan (umeshv@NeXT.com) + * Ported from m98k. + * 05-Nov-92 Doug Mitchell at NeXT + * Created. + */ + +#ifndef _ARCH_PPC_FP_REGS_H_ +#define _ARCH_PPC_FP_REGS_H_ + +#include <architecture/ppc/reg_help.h> + +#if !defined(__ASSEMBLER__) +/* + * Floating point status and control register. + * + * This struct is aligned to an 8-byte boundary because 64-bit + * load/store instructions (lfd/stfd) are used to access it. The + * FPSCR can only be read/written through other FP registers. + */ +typedef struct { + unsigned unused[1] __attribute__(( aligned(8) )); + unsigned fx:BIT_WIDTH(31), // exception summary + fex:BIT_WIDTH(30), // enabled exception summary + vx:BIT_WIDTH(29), // invalid op exception + // summary + ox:BIT_WIDTH(28), // overflow exception + ux:BIT_WIDTH(27), // underflow exception + zx:BIT_WIDTH(26), // divide by zero exception + xx:BIT_WIDTH(25), // inexact exception + vx_snan:BIT_WIDTH(24), // not a number exception + vx_isi:BIT_WIDTH(23), // exception + vx_idi:BIT_WIDTH(22), // exception + vx_zdz:BIT_WIDTH(21), // exception + vx_imz:BIT_WIDTH(20), // exception + vx_xvc:BIT_WIDTH(19), // exception + fr:BIT_WIDTH(18), // fraction rounded + fi:BIT_WIDTH(17), // fraction inexact + class:BIT_WIDTH(16), // class descriptor + fl:BIT_WIDTH(15), // negative + fg:BIT_WIDTH(14), // positive + fe:BIT_WIDTH(13), // equal or zero + fu:BIT_WIDTH(12), // not a number + rsvd1:BIT_WIDTH(11), // reserved + vx_soft:BIT_WIDTH(10), // software request exception + rsvd2:BIT_WIDTH(9), // reserved + vx_cvi:BIT_WIDTH(8), // invalid integer convert + // exception + ve:BIT_WIDTH(7), // invalid op exception enable + oe:BIT_WIDTH(6), // overflow exception enable + ue:BIT_WIDTH(5), // underflow exception enable + ze:BIT_WIDTH(4), // divide by zero exception + // enable + xe:BIT_WIDTH(3), // inexact exception enable + ni:BIT_WIDTH(2), // non-IEEE exception enable + rn:BITS_WIDTH(1,0); // rounding control +} ppc_fp_scr_t; + +/* + * Values for fp_scr_t.rn (rounding control). + */ +typedef enum { + RN_NEAREST = 0, + RN_TOWARD_ZERO = 1, + RN_TOWARD_PLUS = 2, + RN_TOWARD_MINUS = 3 +} ppc_fp_rn_t; + +/* + * ppc_fpf_t -- data types that MAY be in floating point register file + * Actual data types supported is implementation dependent + */ +typedef union { + float f; // 32 bit IEEE single + double d; // 64 bit IEEE double + + /* + * Insure compiler aligns struct appropriately + */ + unsigned x[2] __attribute__(( aligned(8) )); +} ppc_fpf_t; + +/* + * Number of FP registers. + */ +#define PPC_NFP_REGS 32 + +/* + * Read/write FPSCR. + * FIXME - these don't work, you need to go thru a fp register. + */ +typedef union { + double __dbl; + ppc_fp_scr_t __scr; +} __fp_un_t; + +static __inline__ ppc_fp_scr_t +get_fp_scr() +{ + __fp_un_t __fp_un; + + __asm__ volatile ("mffs. %0 /* mffs */" \ + : "=f" (__fp_un.__dbl)); + return (__fp_un.__scr); +} + +static __inline__ void +set_fp_scr(ppc_fp_scr_t fp_scr) +{ + __fp_un_t __fp_un; + + __fp_un.__scr = fp_scr; + __asm__ volatile ("mtfsf 0xff, %0; /* mtfsf */ " \ + : : "f" (__fp_un.__dbl)); +} + +#endif /* ! __ASSEMBLER__ */ + +#endif /* _ARCH_PPC_FP_REGS_H_ */ Index: branches/azimutz/Cleancut/i386/include/architecture/ppc/reg_help.h =================================================================== --- branches/azimutz/Cleancut/i386/include/architecture/ppc/reg_help.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/architecture/ppc/reg_help.h (revision 885) @@ -0,0 +1,225 @@ +/* + * Copyright (c) 1999 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@ + */ +/* Copyright (c) 1996 NeXT Software, Inc. All rights reserved. + * + * File: architecture/ppc/reg_help.h + * Author: Doug Mitchell, NeXT Computer, Inc. + * + * m98k-specific macros and inlines for defining machine registers. + * + * HISTORY + * 05-Nov-92 Doug Mitchell at NeXT + * Created. + * + * 29-Dec-96 Umesh Vaishampayan (umeshv@NeXT.com) + * Ported from m98k. Removed dependency on nrw directory. + * Merged code from architecture/nrw/reg_help.h. + * Moved Register Usage #defines from asm_help.h in here. + */ + +#ifndef _ARCH_PPC_REG_HELP_H_ +#define _ARCH_PPC_REG_HELP_H_ + +#if defined(__ASSEMBLER__) +/* + * GRF Register Usage Aliases + */ +#define zt r0 // architecturally 0 for mem refs only! + // real reg other inst, caller-saved +#define sp r1 // stack pointer, callee-saved +#define toc r2 // tbl of contents, callee-saved +#define a0 r3 // arg 0, return value 0, caller saved +#define a1 r4 // arg 1, return value 1, caller saved +#define a2 r5 // .... +#define a3 r6 +#define a4 r7 +#define a5 r8 +#define a6 r9 +#define a7 r10 // arg 7, return value 7, caller saved +#define ep r11 // environment ptr, caller saved +#define at r12 // assembler temp, caller saved +#define s17 r13 // callee-saved 17 +#define s16 r14 +#define s15 r15 +#define s14 r16 +#define s13 r17 +#define s12 r18 +#define s11 r19 +#define s10 r20 +#define s9 r21 +#define s8 r22 +#define s7 r23 +#define s6 r24 +#define s5 r25 +#define s4 r26 +#define s3 r27 +#define s2 r28 +#define s1 r29 // .... +#define s0 r30 // callee-saved 0 +#define fp r31 // frame-pointer, callee-saved + +/* + * Conversion of GRF aliases to register numbers + */ +#define GRF_ZT 0 // architecturally 0 for mem refs only! + // real reg other inst, caller-saved +#define GRF_SP 1 // stack pointer, callee-saved +#define GRF_TOC 2 // tbl of contents, callee-saved +#define GRF_A0 3 // arg 0, return value 0, caller saved +#define GRF_A1 4 // arg 1, return value 1, caller saved +#define GRF_A2 5 // .... +#define GRF_A3 6 +#define GRF_A4 7 +#define GRF_A5 8 +#define GRF_A6 9 +#define GRF_A7 10 // arg 7, return value 7, caller saved +#define GRF_EP 11 // environment ptr, caller saved +#define GRF_AT 12 // assembler temp, caller saved +#define GRF_S17 13 // callee-saved 17 +#define GRF_S16 14 +#define GRF_S15 15 +#define GRF_S14 16 +#define GRF_S13 17 +#define GRF_S12 18 +#define GRF_S11 19 +#define GRF_S10 20 +#define GRF_S9 21 +#define GRF_S8 22 +#define GRF_S7 23 +#define GRF_S6 24 +#define GRF_S5 25 +#define GRF_S4 26 +#define GRF_S3 27 +#define GRF_S2 28 +#define GRF_S1 29 // .... +#define GRF_S0 30 // callee-saved 0 +#define GRF_FP 31 // frame pointer, callee-saved + +/* + * FPF Register names + */ +#define ft0 f0 // scratch reg, caller-saved +#define fa0 f1 // fp arg 0, return 0, caller-saved +#define fa1 f2 // fp arg 1, caller-saved +#define fa2 f3 // fp arg 2, caller-saved +#define fa3 f4 +#define fa4 f5 +#define fa5 f6 +#define fa6 f7 +#define fa7 f8 +#define fa8 f9 +#define fa9 f10 +#define fa10 f11 +#define fa11 f12 +#define fa12 f13 // fp arg 12, caller-saved +#define fs17 f14 // callee-saved 17 +#define fs16 f15 +#define fs15 f16 +#define fs14 f17 +#define fs13 f18 +#define fs12 f19 +#define fs11 f20 +#define fs10 f21 +#define fs9 f22 +#define fs8 f23 +#define fs7 f24 +#define fs6 f25 +#define fs5 f26 +#define fs4 f27 +#define fs3 f28 +#define fs2 f29 +#define fs1 f30 +#define fs0 f31 // callee-saved 0 + +/* + * Conversion of FPF aliases to register numbers + */ +#define FPF_FT0 0 // scratch reg, caller-saved +#define FPF_FA0 1 // fp arg 0, return 0, caller-saved +#define FPF_FA1 2 // fp arg 1, caller-saved +#define FPF_FA2 3 // fp arg 2, caller-saved +#define FPF_FA3 4 +#define FPF_FA4 5 +#define FPF_FA5 6 +#define FPF_FA6 7 +#define FPF_FA7 8 +#define FPF_FA8 9 +#define FPF_FA9 10 +#define FPF_FA10 11 +#define FPF_FA11 12 +#define FPF_FA12 13 // fp arg 12, caller-saved +#define FPF_FS17 14 // callee-saved 17 +#define FPF_FS16 15 +#define FPF_FS15 16 +#define FPF_FS14 17 +#define FPF_FS13 18 +#define FPF_FS12 19 +#define FPF_FS11 20 +#define FPF_FS10 21 +#define FPF_FS9 22 +#define FPF_FS8 23 +#define FPF_FS7 24 +#define FPF_FS6 25 +#define FPF_FS5 26 +#define FPF_FS4 27 +#define FPF_FS3 28 +#define FPF_FS2 29 +#define FPF_FS1 30 +#define FPF_FS0 31 // callee-saved 0 + +#endif /* __ASSEMBLER__ */ + + +/* Bitfield definition aid */ +#define BITS_WIDTH(msb, lsb) ((msb)-(lsb)+1) +#define BIT_WIDTH(pos) (1) /* mostly to record the position */ + +/* Mask creation */ +#define MKMASK(width, offset) (((unsigned)-1)>>(32-(width))<<(offset)) +#define BITSMASK(msb, lsb) MKMASK(BITS_WIDTH(msb, lsb), lsb & 0x1f) +#define BITMASK(pos) MKMASK(BIT_WIDTH(pos), pos & 0x1f) + +/* Register addresses */ +#if __ASSEMBLER__ +# define REG_ADDR(type, addr) (addr) +#else /* ! __ASSEMBLER__ */ +# define REG_ADDR(type, addr) (*(volatile type *)(addr)) +#endif /* __ASSEMBLER__ */ + +/* Cast a register to be an unsigned */ +/* CAUTION : non naturally aligned foo can result into alignment traps + * use at own risk. + */ +#define CONTENTS(foo) (*(unsigned *) &(foo)) + +/* STRINGIFY -- perform all possible substitutions, then stringify */ +#define __STR(x) #x /* just a helper macro */ +#define STRINGIFY(x) __STR(x) + +/* + * Stack pointer must always be a multiple of 16 + */ +#define STACK_INCR 16 +#define ROUND_FRAME(x) ((((unsigned)(x)) + STACK_INCR - 1) & ~(STACK_INCR-1)) + +#endif /* _ARCH_PPC_REG_HELP_H_ */ Index: branches/azimutz/Cleancut/i386/include/architecture/ppc/asm_help.h =================================================================== --- branches/azimutz/Cleancut/i386/include/architecture/ppc/asm_help.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/architecture/ppc/asm_help.h (revision 885) @@ -0,0 +1,451 @@ +/* + * Copyright (c) 1999 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@ + */ +/* Copyright (c) 1996 NeXT Software, Inc. All rights reserved. + * + * File: architecture/ppc/asm_help.h + * Author: Mike DeMoney, NeXT Software, Inc. + * + * This header file defines macros useful when writing assembly code + * for the PowerPC processors. + * r12 is used as the tmp register / PICIFY base. + * + * HISTORY + * 20-May-97 Umesh Vaishampayan (umeshv@apple.com) + * Implemented Dynamic / PIC macros. + * + * 28-Dec-96 Umesh Vaishampayan (umeshv@NeXT.com) + * added ".align" directive to various macros to avoid alignment + * faults. Moved Register Usage #defines to reg_help.h as that's + * where they should have been in the first place. + * Added Dynamic / PIC macroes for routines which refernce external + * symbols. Not implemented fully as yet. + * + * 05-Nov-92 Mike DeMoney (mike@next.com) + * Created. + */ + +#ifndef _ARCH_PPC_ASM_HELP_H_ +#define _ARCH_PPC_ASM_HELP_H_ + +#include <architecture/ppc/reg_help.h> + +#ifdef __ASSEMBLER__ +/* + * ppc stack frames look like this after procedure prolog has + * been executed: + * + * Higher address: + * ......... + * +-------------------------------+ + * | caller's LR | + * +-------------------------------+ + * | caller's CR | + * +-------------------------------+ + * Caller's SP->| caller's caller's sp | ^^ Caller's Frame ^^ + * +===============================+ vv Called Rtn Frame vv + * | Save Area for | FPF 31 + * .......... + * | Caller's FPF's | FPF n + * +-------------------------------+ + * | Save Area for | GRF 31 + * .......... + * | Caller's GRF's | GRF n + * +-------------------------------+ + * | alignment pad | + * ............ + * | (if necessary) | + * +-------------------------------+ + * | Local | + * ........ + * | Variables | + * +-------------------------------+ + * SP + X -> | aN for FUTURE call | + * +-------------------------------+ + * .......... + * +-------------------------------+ + * SP + 28 -> | a1 for FUTURE call | + * +-------------------------------+ + * SP + 24 -> | a0 for FUTURE call | + * +-------------------------------+ + * SP + 20 -> | caller's TOC | + * +-------------------------------+ + * SP + 16 -> | reserved | + * +-------------------------------+ + * SP + 12 -> | reserved | + * +-------------------------------+ + * SP + 8 -> | LR callee-save for FUTURE call| + * +-------------------------------+ + * SP + 4 -> | CR callee-save for FUTURE call| + * +-------------------------------+ + * SP -> | caller's sp | + * +===============================+ + * Lower address: + * + * NOTE: All state with the exception of LR and CR are saved in the + * called routines frame. LR and CR are saved in the CALLER'S FRAME. + * + * ALSO NOTE: Args to the called routine are found in the caller's frame. + */ + +/* + * ARG(n) -- stack offset to n'th argument + * + * NOTE CAREFULLY! These macros start numbering arguments at 1 (NOT 0) + * The first argument is ARG(1). + * + * ALSO NOTE: This stack offset is only valid if using routine + * DOES NOT alter SP. + * + */ +#define ARG(n) ((((n) - 1) * 4) + 24) + +/* + * Macros for building stack frame according to C calling conventions. + * lr, cr, and sp are saved. + * + * NOTE WELL: localvarsize is in bytes, maxargsout is a count of words, + * grfsaved and fpfsaved is a count of registers. BE SURE TO COUNT + * BOTH FP (r31) AND sN REGISTERS IN THE COUNT OF GRF REGISTERS SAVED! + * This will be TWO more than the N of the highest sN register you + * save: s2 implies you are saving s2, s1, s0, and fp => grfsaved + * should be 4! + * + * FURTHER NOTE: These macros do NOT SAVE GRF or FPF registers. User + * must do that. GRF sN regs should be saved via + * stmw sN,SAVED_GRF_S(N)(sp) + * where N is the highest numbered s* register to be saved. E.g. if + * s0, s1, and s2 are to be saved use: + * stmw s2,SAVED_GRF_S(2)(sp) + * Note that this also saves fp. + * An individual saved grf can be loaded via: + * lwz s2,SAVED_GRF_S(2)(sp) + * Analogous stuff works for fpf's. + * + * NOTE: these simple routines will be replaced with more complicated + * ones once we know what the linker and gdb will require as for as + * register use masks and frame declarations. + * + * Warning: ROUND_TO_STACK is only to be used in assembly language; + * for C usage, use ROUND_FRAME() in reg_help.h. + */ +#define ROUND_TO_STACK(len) \ + (((len) + STACK_INCR - 1) / STACK_INCR * STACK_INCR) + +#define BUILD_FRAME(localvarsize, maxargsout, grfsaved, fpfsaved) \ + .set __argoutsize, ROUND_TO_STACK((maxargsout) * 4) @\ + .if __argoutsize < 32 @\ + .set __argoutsize,32 @\ + .endif @\ + .set __framesize, ROUND_TO_STACK( \ + 24 + __argoutsize + (localvarsize) \ + + 4*(grfsaved) + 8*(fpfsaved)) @\ + .set __grfbase,(__framesize - 4*(grfsaved) - 8*(fpfsaved)) @\ + .set __fpfbase,(__framesize - 8*(fpfsaved)) @\ + mflr r0 @\ + mfcr r12 @\ + stw r0,8(sp) @\ + stw r12,4(sp) @\ + stwu r1,-__framesize(r1) + +/* + * Macros for referencing data in stack frame. + * + * NOTE WELL: ARG's and VAR's start at 1, NOT 0. Why ??? (FIXME) + */ +#define LOCAL_VAR(n) (((n)-1)*4 + __argoutsize + 24) +#define SAVED_GRF_S(n) (__grfbase + ((grfsaved) - (n) - 2) * 4) +#define SAVED_FRF_FS(n) (__fpfbase + ((fpfsaved) - (n) - 1) * 4) +#define ARG_IN(n) (ARG(n) + __framesize) +#define ARG_OUT(n) (ARG(n) + 0) +#define SAVED_FP (__grfbase + ((grfsaved) - 1) * 4) +#define SAVED_LR (__framesize + 8) +#define SAVED_CR (__framesize + 4) + +/* + * Macros for unwinding stack frame. + * NOTE: GRF's and FPF's are NOT RESTORED. User must do this before + * using this macro. + */ +#define RETURN \ + .if __framesize @\ + lwz32 r0,r1,SAVED_LR @\ + lwz32 r12,r1,SAVED_CR @\ + addic sp,r1,__framesize @\ + mtlr r0 @\ + mtcrf 0xff,r12 @\ + blr @\ + .else @\ + blr @\ + .endif + + +/* + * Macros for declaring procedures + * + * Use of these macros allows ctags to have a predictable way + * to find various types of declarations. They also simplify + * inserting appropriate symbol table information. + * + * NOTE: these simple stubs will be replaced with more + * complicated versions once we know what the linker and gdb + * will require as far as register use masks and frame declarations. + * These macros may also be ifdef'ed in the future to contain profiling + * code. + * + * FIXME: Document what makes a leaf a LEAF and a handler a HANDLER. + * (E.g. leaf's have return pc in lr, NESTED's have rpc in offset off + * sp, handlers have rpc in exception frame which is found via exception + * link, etc etc.) + */ + +/* + * TEXT -- declare start of text segment + */ +#define TEXT \ + .text @\ + .align 2 + +/* + * LEAF -- declare global leaf procedure + * NOTE: Control SHOULD NOT FLOW into a LEAF! A LEAF should only + * be jumped to. (A leaf may do an align.) Use a LABEL() if you + * need control to flow into the label. + */ +#define LEAF(name) \ + .align 2 @\ + .globl name @\ +name: @\ + .set __framesize,0 + +/* + * X_LEAF -- declare alternate global label for leaf + */ +#define X_LEAF(name, value) \ + .globl name @\ + .set name,value + +/* + * P_LEAF -- declare private leaf procedure + */ +#define P_LEAF(name) \ + .align 2 @\ +name: @\ + .set __framesize,0 + +/* + * LABEL -- declare a global code label + * MUST be used (rather than LEAF, NESTED, etc) if control + * "flows into" the label. + */ +#define LABEL(name) \ + .align 2 @\ + .globl name @\ +name: + +/* + * NESTED -- declare procedure that invokes other procedures + */ +#define NESTED(name, localvarsize, maxargsout, grfsaved, fpfsaved)\ + .align 2 @\ + .globl name @\ +name: @\ + BUILD_FRAME(localvarsize, maxargsout, grfsaved, fpfsaved) + +/* + * X_NESTED -- declare alternate global label for nested proc + */ +#define X_NESTED(name, value) \ + .globl name @\ + .set name,value + +/* + * P_NESTED -- declare private nested procedure + */ +#define P_NESTED(name, localvarsize, maxargsout, grfsaved, fpfsaved)\ + .align 2 @\ +name: @\ + BUILD_FRAME(locavarsize, maxargsout, grfsaved, fpfsaved) + +/* + * HANDLER -- declare procedure with exception frame rather than + * standard C frame + */ +#define HANDLER(name) \ + .align 2 @\ + .globl name @\ +name: + +/* + * X_HANDLER -- declare alternate name for exception handler + * (Should appear immediately before a HANDLER declaration or + * another X_HANDLER declaration) + */ +#define X_HANDLER(name) \ + .align 2 @\ + .globl name @\ +name: + +/* + * P_HANDLER -- declare private handler + */ +#define P_HANDLER(name) \ + .align 2 @\ +name: + +/* + * END -- mark end of procedure + * FIXME: Unimplemented for now. + */ +#define END(name) + +/* + * BL -- call procedure (relative) + */ +#define BL(name) \ + bl name + +/* + * Storage definition macros + * The main purpose of these is to allow an easy handle for ctags + */ + +/* + * IMPORT -- import symbol + */ +#define IMPORT(name) \ + .reference name + +/* + * ABS -- declare global absolute symbol + */ +#define ABS(name, value) \ + .globl name @\ + .set name,value + +/* + * P_ABS -- declare private absolute symbol + */ +#define P_ABS(name, value) \ + .set name,value + +/* + * EXPORT -- declare global label for data + */ +#define EXPORT(name) \ + .align 2 @\ + .globl name @\ +name: + +/* + * BSS -- declare global zero'ed storage + */ +#define BSS(name,size) \ + .comm name,size + + +/* + * P_BSS -- declare private zero'ed storage + */ +#define P_BSS(name,size) \ + .lcomm name,size + +/* + * dynamic/PIC macros for routines which reference external symbols + */ +#if defined(__DYNAMIC__) +#define PICIFY_REG r12 + +/* Assume that the lr is saved before calling any of these macros */ +/* using PICIFY() */ + +#define PICIFY(var) \ + mflr r0 @\ + bcl 20,31,1f @\ +1: mflr PICIFY_REG @\ + mtlr r0 @\ + addis PICIFY_REG, PICIFY_REG, ha16(L ## var ## __non_lazy_ptr - 1b) @\ + lwz PICIFY_REG, lo16(L ## var ## __non_lazy_ptr - 1b)(PICIFY_REG) + +#define CALL_EXTERN_AGAIN(var) \ + PICIFY(var) @\ + mtctr PICIFY_REG @\ + mflr r0 @\ + stw r0,8(r1) @\ + stwu r1,-64(r1) @\ + bctrl @\ + addic r1,r1,64 @\ + lwz r0,8(r1) @\ + mtlr r0 + +#define NON_LAZY_STUB(var) \ + .non_lazy_symbol_pointer @\ + .align 2 @\ +L ## var ## __non_lazy_ptr: @\ + .indirect_symbol var @\ + .long 0 @\ + .text @\ + .align 2 + +#define BRANCH_EXTERN(var) \ + PICIFY(var) @\ + mtctr PICIFY_REG @\ + bctr @\ + NON_LAZY_STUB(var) + +#define CALL_EXTERN(var) \ + CALL_EXTERN_AGAIN(var) @\ + NON_LAZY_STUB(var) + +#define REG_TO_EXTERN(reg, var) \ + PICIFY(var) @\ + stw reg, 0(PICIFY_REG) @\ + NON_LAZY_STUB(var) + +#define EXTERN_TO_REG(reg, var) \ + PICIFY(var) @\ + lwz reg, 0(PICIFY_REG) @\ + NON_LAZY_STUB(var) + +#else /* ! __DYNAMIC__ */ +#define TMP_REG r12 +#define BRANCH_EXTERN(var) \ + b var + +#define CALL_EXTERN(var) \ + bl var + +#define CALL_EXTERN_AGAIN(var) \ + CALL_EXTERN(var) + +#define REG_TO_EXTERN(reg, var) \ + lis TMP_REG, ha16(var) @\ + stw reg, lo16(var)(TMP_REG) + +#define EXTERN_TO_REG(reg, var) \ + lis reg, ha16(var) @\ + lwz reg, lo16(var)(reg) + +#endif /* __DYNAMIC__ */ + +#endif /* __ASSEMBLER__ */ +#endif /* _ARCH_PPC_ASM_HELP_H_ */ Index: branches/azimutz/Cleancut/i386/include/architecture/alignment.h =================================================================== --- branches/azimutz/Cleancut/i386/include/architecture/alignment.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/architecture/alignment.h (revision 885) @@ -0,0 +1,47 @@ +/* + * Copyright (c) 1999, 2008 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@ + */ +/* + * Copyright (c) 1996 NeXT Software, Inc. + * + * Natural alignment of shorts and longs. + * + * HISTORY + * + * 2 Sept 1992 Brian Raymor at NeXT + * Moved over to architecture. + * 18 August 1992 Jack Greenfield at NeXT + * Created. + */ + + +#if defined (__ppc__) +#include "architecture/ppc/alignment.h" +#elif defined (__i386__) +#include "architecture/i386/alignment.h" +#elif defined (__arm__) +#include "architecture/arm/alignment.h" +#else +#error architecture not supported +#endif + + Index: branches/azimutz/Cleancut/i386/include/architecture/byte_order.h =================================================================== --- branches/azimutz/Cleancut/i386/include/architecture/byte_order.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/architecture/byte_order.h (revision 885) @@ -0,0 +1,381 @@ +/* + * Copyright (c) 1999-2008 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@ + */ +/* + * Copyright (c) 1992 NeXT Computer, Inc. + * + * Byte ordering conversion. + * + */ + +#ifndef _ARCHITECTURE_BYTE_ORDER_H_ +#define _ARCHITECTURE_BYTE_ORDER_H_ + +/* + * Please note that the byte ordering functions in this file are deprecated. + * A replacement API exists in libkern/OSByteOrder.h + */ + +#include <libkern/OSByteOrder.h> + +typedef unsigned long NXSwappedFloat; +typedef unsigned long long NXSwappedDouble; + +static __inline__ __attribute__((deprecated)) +unsigned short +NXSwapShort( + unsigned short inv +) +{ + return (unsigned short)OSSwapInt16((uint16_t)inv); +} + +static __inline__ __attribute__((deprecated)) +unsigned int +NXSwapInt( + unsigned int inv +) +{ + return (unsigned int)OSSwapInt32((uint32_t)inv); +} + +static __inline__ __attribute__((deprecated)) +unsigned long +NXSwapLong( + unsigned long inv +) +{ + return (unsigned long)OSSwapInt32((uint32_t)inv); +} + +static __inline__ __attribute__((deprecated)) +unsigned long long +NXSwapLongLong( + unsigned long long inv +) +{ + return (unsigned long long)OSSwapInt64((uint64_t)inv); +} + +static __inline__ __attribute__((deprecated)) +NXSwappedFloat +NXConvertHostFloatToSwapped(float x) +{ + union fconv { + float number; + NXSwappedFloat sf; + } u; + u.number = x; + return u.sf; +} + +static __inline__ __attribute__((deprecated)) +float +NXConvertSwappedFloatToHost(NXSwappedFloat x) +{ + union fconv { + float number; + NXSwappedFloat sf; + } u; + u.sf = x; + return u.number; +} + +static __inline__ __attribute__((deprecated)) +NXSwappedDouble +NXConvertHostDoubleToSwapped(double x) +{ + union dconv { + double number; + NXSwappedDouble sd; + } u; + u.number = x; + return u.sd; +} + +static __inline__ __attribute__((deprecated)) +double +NXConvertSwappedDoubleToHost(NXSwappedDouble x) +{ + union dconv { + double number; + NXSwappedDouble sd; + } u; + u.sd = x; + return u.number; +} + +static __inline__ __attribute__((deprecated)) +NXSwappedFloat +NXSwapFloat(NXSwappedFloat x) +{ + return (NXSwappedFloat)OSSwapInt32((uint32_t)x); +} + +static __inline__ __attribute__((deprecated)) +NXSwappedDouble +NXSwapDouble(NXSwappedDouble x) +{ + return (NXSwappedDouble)OSSwapInt64((uint64_t)x); +} + +/* + * Identify the byte order + * of the current host. + */ + +enum NXByteOrder { + NX_UnknownByteOrder, + NX_LittleEndian, + NX_BigEndian +}; + +static __inline__ +enum NXByteOrder +NXHostByteOrder(void) +{ +#if defined(__LITTLE_ENDIAN__) + return NX_LittleEndian; +#elif defined(__BIG_ENDIAN__) + return NX_BigEndian; +#else + return NX_UnknownByteOrder; +#endif +} + +static __inline__ __attribute__((deprecated)) +unsigned short +NXSwapBigShortToHost( + unsigned short x +) +{ + return (unsigned short)OSSwapBigToHostInt16((uint16_t)x); +} + +static __inline__ __attribute__((deprecated)) +unsigned int +NXSwapBigIntToHost( + unsigned int x +) +{ + return (unsigned int)OSSwapBigToHostInt32((uint32_t)x); +} + +static __inline__ __attribute__((deprecated)) +unsigned long +NXSwapBigLongToHost( + unsigned long x +) +{ + return (unsigned long)OSSwapBigToHostInt32((uint32_t)x); +} + +static __inline__ __attribute__((deprecated)) +unsigned long long +NXSwapBigLongLongToHost( + unsigned long long x +) +{ + return (unsigned long long)OSSwapBigToHostInt64((uint64_t)x); +} + +static __inline__ __attribute__((deprecated)) +double +NXSwapBigDoubleToHost( + NXSwappedDouble x +) +{ + return NXConvertSwappedDoubleToHost((NXSwappedDouble)OSSwapBigToHostInt64((uint64_t)x)); +} + +static __inline__ __attribute__((deprecated)) +float +NXSwapBigFloatToHost( + NXSwappedFloat x +) +{ + return NXConvertSwappedFloatToHost((NXSwappedFloat)OSSwapBigToHostInt32((uint32_t)x)); +} + +static __inline__ __attribute__((deprecated)) +unsigned short +NXSwapHostShortToBig( + unsigned short x +) +{ + return (unsigned short)OSSwapHostToBigInt16((uint16_t)x); +} + +static __inline__ __attribute__((deprecated)) +unsigned int +NXSwapHostIntToBig( + unsigned int x +) +{ + return (unsigned int)OSSwapHostToBigInt32((uint32_t)x); +} + +static __inline__ __attribute__((deprecated)) +unsigned long +NXSwapHostLongToBig( + unsigned long x +) +{ + return (unsigned long)OSSwapHostToBigInt32((uint32_t)x); +} + +static __inline__ __attribute__((deprecated)) +unsigned long long +NXSwapHostLongLongToBig( + unsigned long long x +) +{ + return (unsigned long long)OSSwapHostToBigInt64((uint64_t)x); +} + +static __inline__ __attribute__((deprecated)) +NXSwappedDouble +NXSwapHostDoubleToBig( + double x +) +{ + return (NXSwappedDouble)OSSwapHostToBigInt64((uint64_t)NXConvertHostDoubleToSwapped(x)); +} + +static __inline__ __attribute__((deprecated)) +NXSwappedFloat +NXSwapHostFloatToBig( + float x +) +{ + return (NXSwappedFloat)OSSwapHostToBigInt32((uint32_t)NXConvertHostFloatToSwapped(x)); +} + +static __inline__ __attribute__((deprecated)) +unsigned short +NXSwapLittleShortToHost( + unsigned short x +) +{ + return (unsigned short)OSSwapLittleToHostInt16((uint16_t)x); +} + +static __inline__ __attribute__((deprecated)) +unsigned int +NXSwapLittleIntToHost( + unsigned int x +) +{ + return (unsigned int)OSSwapLittleToHostInt32((uint32_t)x); +} + +static __inline__ __attribute__((deprecated)) +unsigned long +NXSwapLittleLongToHost( + unsigned long x +) +{ + return (unsigned long)OSSwapLittleToHostInt32((uint32_t)x); +} + +static __inline__ __attribute__((deprecated)) +unsigned long long +NXSwapLittleLongLongToHost( + unsigned long long x +) +{ + return (unsigned long long)OSSwapLittleToHostInt64((uint64_t)x); +} + +static __inline__ __attribute__((deprecated)) +double +NXSwapLittleDoubleToHost( + NXSwappedDouble x +) +{ + return NXConvertSwappedDoubleToHost((NXSwappedDouble)OSSwapLittleToHostInt64((uint64_t)x)); +} + +static __inline__ __attribute__((deprecated)) +float +NXSwapLittleFloatToHost( + NXSwappedFloat x +) +{ + return NXConvertSwappedFloatToHost((NXSwappedFloat)OSSwapLittleToHostInt32((uint32_t)x)); +} + +static __inline__ __attribute__((deprecated)) +unsigned short +NXSwapHostShortToLittle( + unsigned short x +) +{ + return (unsigned short)OSSwapHostToLittleInt16((uint16_t)x); +} + +static __inline__ __attribute__((deprecated)) +unsigned int +NXSwapHostIntToLittle( + unsigned int x +) +{ + return (unsigned int)OSSwapHostToLittleInt32((uint32_t)x); +} + +static __inline__ __attribute__((deprecated)) +unsigned long +NXSwapHostLongToLittle( + unsigned long x +) +{ + return (unsigned long)OSSwapHostToLittleInt32((uint32_t)x); +} + +static __inline__ __attribute__((deprecated)) +unsigned long long +NXSwapHostLongLongToLittle( + unsigned long long x +) +{ + return (unsigned long long)OSSwapHostToLittleInt64((uint64_t)x); +} + +static __inline__ __attribute__((deprecated)) +NXSwappedDouble +NXSwapHostDoubleToLittle( + double x +) +{ + return (NXSwappedDouble)OSSwapHostToLittleInt64((uint64_t)NXConvertHostDoubleToSwapped(x)); +} + +static __inline__ __attribute__((deprecated)) +NXSwappedFloat +NXSwapHostFloatToLittle( + float x +) +{ + return (NXSwappedFloat)OSSwapHostToLittleInt32((uint32_t)NXConvertHostFloatToSwapped(x)); +} + +#endif /* _ARCHITECTURE_BYTE_ORDER_H_ */ Index: branches/azimutz/Cleancut/i386/include/architecture/i386/math.h =================================================================== --- branches/azimutz/Cleancut/i386/include/architecture/i386/math.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/architecture/i386/math.h (revision 885) @@ -0,0 +1,642 @@ +/* + * Copyright (c) 2002 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@ + */ + +/******************************************************************************* +* * +* File: math.h * +* * +* Contains: typedefs, prototypes, and macros germane to C99 floating point.* +* * +*******************************************************************************/ +#ifndef __MATH__ +#define __MATH__ + +#include "sys/cdefs.h" /* For definition of __DARWIN_UNIX03 et al */ + +#ifdef __cplusplus +extern "C" { +#endif + +/****************************************************************************** +* Floating point data types * +******************************************************************************/ + +/* Define float_t and double_t per C standard, ISO/IEC 9899:1999 7.12 2, + taking advantage of GCC's __FLT_EVAL_METHOD__ (which a compiler may + define anytime and GCC does) that shadows FLT_EVAL_METHOD (which a compiler + must and may define only in float.h). +*/ +#if __FLT_EVAL_METHOD__ == 0 + typedef float float_t; + typedef double double_t; +#elif __FLT_EVAL_METHOD__ == 1 + typedef double float_t; + typedef double double_t; +#elif __FLT_EVAL_METHOD__ == 2 || __FLT_EVAL_METHOD__ == -1 + typedef long double float_t; + typedef long double double_t; +#else /* __FLT_EVAL_METHOD__ */ + #error "Unsupported value of __FLT_EVAL_METHOD__." +#endif /* __FLT_EVAL_METHOD__ */ + + +#if defined(__GNUC__) + #define HUGE_VAL __builtin_huge_val() + #define HUGE_VALF __builtin_huge_valf() + #define HUGE_VALL __builtin_huge_vall() + #define NAN __builtin_nanf("0x7fc00000") /* Constant expression, can be used as initializer. */ + #define __MATH_H_ALWAYS_INLINE__ __attribute__ ((always_inline)) +#else + #define HUGE_VAL 1e500 + #define HUGE_VALF 1e50f + #define HUGE_VALL 1e5000L + #define NAN __nan( ) + #define __MATH_H_ALWAYS_INLINE__ +#endif + +#define INFINITY HUGE_VALF + + +/****************************************************************************** +* Taxonomy of floating point data types * +******************************************************************************/ + +#define FP_NAN 1 +#define FP_INFINITE 2 +#define FP_ZERO 3 +#define FP_NORMAL 4 +#define FP_SUBNORMAL 5 +#define FP_SUPERNORMAL 6 /* meaningful only on PowerPC */ + +/* fma() *function call* is more costly than equivalent (in-line) multiply and add operations */ +/* For single and double precision, the cost isn't too bad, because we can fall back on higher */ +/* precision hardware, with the necessary range to handle infinite precision products. However, */ +/* expect the long double fma to be at least an order of magnitude slower than a simple multiply */ +/* and an add. */ +#undef FP_FAST_FMA +#undef FP_FAST_FMAF +#undef FP_FAST_FMAL + +/* The values returned by `ilogb' for 0 and NaN respectively. */ +#define FP_ILOGB0 (-2147483647 - 1) +#define FP_ILOGBNAN (-2147483647 - 1) + +/* Bitmasks for the math_errhandling macro. */ +#define MATH_ERRNO 1 /* errno set by math functions. */ +#define MATH_ERREXCEPT 2 /* Exceptions raised by math functions. */ + +#define math_errhandling (__math_errhandling()) +extern unsigned int __math_errhandling ( void ); + +/******************************************************************************** +* * +* Inquiry macros * +* * +* fpclassify Returns one of the FP_Švalues. * +* isnormal Non-zero if and only if the argument x is normalized. * +* isfinite Non-zero if and only if the argument x is finite. * +* isnan Non-zero if and only if the argument x is a NaN. * +* signbit Non-zero if and only if the sign of the argument x is * +* negative. This includes, NaNs, infinities and zeros. * +* * +********************************************************************************/ + +#define fpclassify(x) \ + ( sizeof (x) == sizeof(float ) ? __fpclassifyf((float)(x)) \ + : sizeof (x) == sizeof(double) ? __fpclassifyd((double)(x)) \ + : __fpclassify ((long double)(x))) + +extern int __fpclassifyf(float ); +extern int __fpclassifyd(double ); +extern int __fpclassify (long double); + +#if defined( __GNUC__ ) && 0 == __FINITE_MATH_ONLY__ + /* Yes, that's right. You only get the fast iswhatever() macros if you do NOT turn on -ffast-math. */ + /* These inline functions require the compiler to be compiling to standard in order to work. */ + /* -ffast-math, among other things, implies that NaNs don't happen. The compiler can in that case */ + /* optimize x != x to be false always, wheras it would be true for NaNs. That breaks __inline_isnan() */ + /* below. */ + #define isnormal(x) \ + ( sizeof (x) == sizeof(float ) ? __inline_isnormalf((float)(x)) \ + : sizeof (x) == sizeof(double) ? __inline_isnormald((double)(x)) \ + : __inline_isnormal ((long double)(x))) + + #define isfinite(x) \ + ( sizeof (x) == sizeof(float ) ? __inline_isfinitef((float)(x)) \ + : sizeof (x) == sizeof(double) ? __inline_isfinited((double)(x)) \ + : __inline_isfinite ((long double)(x))) + + #define isinf(x) \ + ( sizeof (x) == sizeof(float ) ? __inline_isinff((float)(x)) \ + : sizeof (x) == sizeof(double) ? __inline_isinfd((double)(x)) \ + : __inline_isinf ((long double)(x))) + + #define isnan(x) \ + ( sizeof (x) == sizeof(float ) ? __inline_isnanf((float)(x)) \ + : sizeof (x) == sizeof(double) ? __inline_isnand((double)(x)) \ + : __inline_isnan ((long double)(x))) + + #define signbit(x) \ + ( sizeof (x) == sizeof(float ) ? __inline_signbitf((float)(x)) \ + : sizeof (x) == sizeof(double) ? __inline_signbitd((double)(x)) \ + : __inline_signbit((long double)(x))) + + static __inline__ int __inline_isfinitef (float ) __MATH_H_ALWAYS_INLINE__; + static __inline__ int __inline_isfinited (double ) __MATH_H_ALWAYS_INLINE__; + static __inline__ int __inline_isfinite (long double) __MATH_H_ALWAYS_INLINE__; + static __inline__ int __inline_isinff (float ) __MATH_H_ALWAYS_INLINE__; + static __inline__ int __inline_isinfd (double ) __MATH_H_ALWAYS_INLINE__; + static __inline__ int __inline_isinf (long double) __MATH_H_ALWAYS_INLINE__; + static __inline__ int __inline_isnanf (float ) __MATH_H_ALWAYS_INLINE__; + static __inline__ int __inline_isnand (double ) __MATH_H_ALWAYS_INLINE__; + static __inline__ int __inline_isnan (long double) __MATH_H_ALWAYS_INLINE__; + static __inline__ int __inline_isnormalf (float ) __MATH_H_ALWAYS_INLINE__; + static __inline__ int __inline_isnormald (double ) __MATH_H_ALWAYS_INLINE__; + static __inline__ int __inline_isnormal (long double) __MATH_H_ALWAYS_INLINE__; + static __inline__ int __inline_signbitf (float ) __MATH_H_ALWAYS_INLINE__; + static __inline__ int __inline_signbitd (double ) __MATH_H_ALWAYS_INLINE__; + static __inline__ int __inline_signbit (long double) __MATH_H_ALWAYS_INLINE__; + + static __inline__ int __inline_isinff( float __x ) { return __builtin_fabsf(__x) == __builtin_inff(); } + static __inline__ int __inline_isinfd( double __x ) { return __builtin_fabs(__x) == __builtin_inf(); } + static __inline__ int __inline_isinf( long double __x ) { return __builtin_fabsl(__x) == __builtin_infl(); } + static __inline__ int __inline_isfinitef( float __x ) { return __x == __x && __builtin_fabsf(__x) != __builtin_inff(); } + static __inline__ int __inline_isfinited( double __x ) { return __x == __x && __builtin_fabs(__x) != __builtin_inf(); } + static __inline__ int __inline_isfinite( long double __x ) { return __x == __x && __builtin_fabsl(__x) != __builtin_infl(); } + static __inline__ int __inline_isnanf( float __x ) { return __x != __x; } + static __inline__ int __inline_isnand( double __x ) { return __x != __x; } + static __inline__ int __inline_isnan( long double __x ) { return __x != __x; } + static __inline__ int __inline_signbitf( float __x ) { union{ float __f; unsigned int __u; }__u; __u.__f = __x; return (int)(__u.__u >> 31); } + static __inline__ int __inline_signbitd( double __x ) { union{ double __f; unsigned int __u[2]; }__u; __u.__f = __x; return (int)(__u.__u[1] >> 31); } + static __inline__ int __inline_signbit( long double __x ){ union{ long double __ld; struct{ unsigned int __m[2]; short __sexp; }__p; }__u; __u.__ld = __x; return (int) (((unsigned short) __u.__p.__sexp) >> 15); } + static __inline__ int __inline_isnormalf( float __x ) { float fabsf = __builtin_fabsf(__x); if( __x != __x ) return 0; return fabsf < __builtin_inff() && fabsf >= __FLT_MIN__; } + static __inline__ int __inline_isnormald( double __x ) { double fabsf = __builtin_fabs(__x); if( __x != __x ) return 0; return fabsf < __builtin_inf() && fabsf >= __DBL_MIN__; } + static __inline__ int __inline_isnormal( long double __x ) { long double fabsf = __builtin_fabsl(__x); if( __x != __x ) return 0; return fabsf < __builtin_infl() && fabsf >= __LDBL_MIN__; } + +#else + + #define isnormal(x) \ + ( sizeof (x) == sizeof(float ) ? __isnormalf((float)(x)) \ + : sizeof (x) == sizeof(double) ? __isnormald((double)(x)) \ + : __isnormal ((long double)(x))) + + #define isfinite(x) \ + ( sizeof (x) == sizeof(float ) ? __isfinitef((float)(x)) \ + : sizeof (x) == sizeof(double) ? __isfinited((double)(x)) \ + : __isfinite ((long double)(x))) + + #define isinf(x) \ + ( sizeof (x) == sizeof(float ) ? __isinff((float)(x)) \ + : sizeof (x) == sizeof(double) ? __isinfd((double)(x)) \ + : __isinf ((long double)(x))) + + #define isnan(x) \ + ( sizeof (x) == sizeof(float ) ? __isnanf((float)(x)) \ + : sizeof (x) == sizeof(double) ? __isnand((double)(x)) \ + : __isnan ((long double)(x))) + + #define signbit(x) \ + ( sizeof (x) == sizeof(float ) ? __signbitf((float)(x)) \ + : sizeof (x) == sizeof(double) ? __signbitd((double)(x)) \ + : __signbitl((long double)(x))) + + + extern int __isnormalf (float ); + extern int __isnormald (double ); + extern int __isnormal (long double); + + extern int __isfinitef (float ); + extern int __isfinited (double ); + extern int __isfinite (long double); + + extern int __isinff (float ); + extern int __isinfd (double ); + extern int __isinf (long double); + + extern int __isnanf (float ); + extern int __isnand (double ); + extern int __isnan (long double); + + extern int __signbitf (float ); + extern int __signbitd (double ); + extern int __signbitl (long double); + +#endif + + + +/******************************************************************************** +* * +* Math Functions * +* * +********************************************************************************/ + +extern double acos( double ); +extern float acosf( float ); + +extern double asin( double ); +extern float asinf( float ); + +extern double atan( double ); +extern float atanf( float ); + +extern double atan2( double, double ); +extern float atan2f( float, float ); + +extern double cos( double ); +extern float cosf( float ); + +extern double sin( double ); +extern float sinf( float ); + +extern double tan( double ); +extern float tanf( float ); + +extern double acosh( double ); +extern float acoshf( float ); + +extern double asinh( double ); +extern float asinhf( float ); + +extern double atanh( double ); +extern float atanhf( float ); + +extern double cosh( double ); +extern float coshf( float ); + +extern double sinh( double ); +extern float sinhf( float ); + +extern double tanh( double ); +extern float tanhf( float ); + +extern double exp ( double ); +extern float expf ( float ); + +extern double exp2 ( double ); +extern float exp2f ( float ); + +extern double expm1 ( double ); +extern float expm1f ( float ); + +extern double log ( double ); +extern float logf ( float ); + +extern double log10 ( double ); +extern float log10f ( float ); + +extern double log2 ( double ); +extern float log2f ( float ); + +extern double log1p ( double ); +extern float log1pf ( float ); + +extern double logb ( double ); +extern float logbf ( float ); + +extern double modf ( double, double * ); +extern float modff ( float, float * ); + +extern double ldexp ( double, int ); +extern float ldexpf ( float, int ); + +extern double frexp ( double, int * ); +extern float frexpf ( float, int * ); + +extern int ilogb ( double ); +extern int ilogbf ( float ); + +extern double scalbn ( double, int ); +extern float scalbnf ( float, int ); + +extern double scalbln ( double, long int ); +extern float scalblnf ( float, long int ); + +extern double fabs( double ); +extern float fabsf( float ); + +extern double cbrt( double ); +extern float cbrtf( float ); + +extern double hypot ( double, double ); +extern float hypotf ( float, float ); + +extern double pow ( double, double ); +extern float powf ( float, float ); + +extern double sqrt( double ); +extern float sqrtf( float ); + +extern double erf( double ); +extern float erff( float ); + +extern double erfc( double ); +extern float erfcf( float ); + +/* lgamma and lgammaf are not thread-safe. The thread-safe variants + * lgamma_r and lgammaf_r are available on OS X 10.6 and later. + * + * To use the thread-safe variants, you must define the _REENTRANT symbol. + */ +extern double lgamma( double ); +extern float lgammaf( float ); + +extern double tgamma( double ); +extern float tgammaf( float ); + +extern double ceil ( double ); +extern float ceilf ( float ); + +extern double floor ( double ); +extern float floorf ( float ); + +extern double nearbyint ( double ); +extern float nearbyintf ( float ); + +extern double rint ( double ); +extern float rintf ( float ); + +extern long int lrint ( double ); +extern long int lrintf ( float ); + +extern double round ( double ); +extern float roundf ( float ); + +extern long int lround ( double ); +extern long int lroundf ( float ); + +#if ( defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L ) || ! defined( __STRICT_ANSI__ ) || ! defined( __GNUC__ ) + + /* long long is not part of C90. Make sure you are passing -std=c99 or -std=gnu99 or better if you need this. */ + extern long long int llrint ( double ); + extern long long int llrintf ( float ); + + extern long long int llround ( double ); + extern long long int llroundf ( float ); + +#endif /* #if ( defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L ) || ! defined( __STRICT_ANSI__ ) || ! defined( __GNUC__ ) */ + +extern double trunc ( double ); +extern float truncf ( float ); + +extern double fmod ( double, double ); +extern float fmodf ( float, float ); + +extern double remainder ( double, double ); +extern float remainderf ( float, float ); + +extern double remquo ( double, double, int * ); +extern float remquof ( float, float, int * ); + +extern double copysign ( double, double ); +extern float copysignf ( float, float ); + +extern double nan( const char * ); +extern float nanf( const char * ); + +extern double nextafter ( double, double ); +extern float nextafterf ( float, float ); + +extern double fdim ( double, double ); +extern float fdimf ( float, float ); + +extern double fmax ( double, double ); +extern float fmaxf ( float, float ); + +extern double fmin ( double, double ); +extern float fminf ( float, float ); + +extern double fma ( double, double, double ); +extern float fmaf ( float, float, float ); + +extern long double acosl(long double); +extern long double asinl(long double); +extern long double atanl(long double); +extern long double atan2l(long double, long double); +extern long double cosl(long double); +extern long double sinl(long double); +extern long double tanl(long double); +extern long double acoshl(long double); +extern long double asinhl(long double); +extern long double atanhl(long double); +extern long double coshl(long double); +extern long double sinhl(long double); +extern long double tanhl(long double); +extern long double expl(long double); +extern long double exp2l(long double); +extern long double expm1l(long double); +extern long double logl(long double); +extern long double log10l(long double); +extern long double log2l(long double); +extern long double log1pl(long double); +extern long double logbl(long double); +extern long double modfl(long double, long double *); +extern long double ldexpl(long double, int); +extern long double frexpl(long double, int *); +extern int ilogbl(long double); +extern long double scalbnl(long double, int); +extern long double scalblnl(long double, long int); +extern long double fabsl(long double); +extern long double cbrtl(long double); +extern long double hypotl(long double, long double); +extern long double powl(long double, long double); +extern long double sqrtl(long double); +extern long double erfl(long double); +extern long double erfcl(long double); + +/* lgammal is not thread-safe. + * The thread-safe variant lgammal_r is available on OS X 10.6 and later. + * + * To use the thread-safe variant, you must define the _REENTRANT symbol. + */ +extern long double lgammal(long double); + +extern long double tgammal(long double); +extern long double ceill(long double); +extern long double floorl(long double); +extern long double nearbyintl(long double); +extern long double rintl(long double); +extern long int lrintl(long double); +extern long double roundl(long double); +extern long int lroundl(long double); + +#if ( defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L ) || ! defined( __STRICT_ANSI__ ) || ! defined( __GNUC__ ) + /* long long is not part of C90. Make sure you are passing -std=c99 or -std=gnu99 or better if you need this. */ + extern long long int llrintl(long double); + extern long long int llroundl(long double); +#endif /* #if ( defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L ) || ! defined( __STRICT_ANSI__ ) || ! defined( __GNUC__ ) */ + +extern long double truncl(long double); +extern long double fmodl(long double, long double); +extern long double remainderl(long double, long double); +extern long double remquol(long double, long double, int *); +extern long double copysignl(long double, long double); +extern long double nanl(const char *); +extern long double nextafterl(long double, long double); +extern double nexttoward(double, long double); +extern float nexttowardf(float, long double); +extern long double nexttowardl(long double, long double); +extern long double fdiml(long double, long double); +extern long double fmaxl(long double, long double); +extern long double fminl(long double, long double); +extern long double fmal(long double, long double, long double); + +#define isgreater(x, y) __builtin_isgreater ((x),(y)) +#define isgreaterequal(x, y) __builtin_isgreaterequal ((x),(y)) +#define isless(x, y) __builtin_isless ((x),(y)) +#define islessequal(x, y) __builtin_islessequal ((x),(y)) +#define islessgreater(x, y) __builtin_islessgreater ((x),(y)) +#define isunordered(x, y) __builtin_isunordered ((x),(y)) + +extern double __inf( void ); +extern float __inff( void ); +extern long double __infl( void ); +extern float __nan( void ); /* 10.3 (and later) must retain in ABI for backward compatability */ + +#if !defined(_ANSI_SOURCE) +extern double j0 ( double ); + +extern double j1 ( double ); + +extern double jn ( int, double ); + +extern double y0 ( double ); + +extern double y1 ( double ); + +extern double yn ( int, double ); + +extern double scalb ( double, double ); + + +#define M_E 2.71828182845904523536028747135266250 /* e */ +#define M_LOG2E 1.44269504088896340735992468100189214 /* log 2e */ +#define M_LOG10E 0.434294481903251827651128918916605082 /* log 10e */ +#define M_LN2 0.693147180559945309417232121458176568 /* log e2 */ +#define M_LN10 2.30258509299404568401799145468436421 /* log e10 */ +#define M_PI 3.14159265358979323846264338327950288 /* pi */ +#define M_PI_2 1.57079632679489661923132169163975144 /* pi/2 */ +#define M_PI_4 0.785398163397448309615660845819875721 /* pi/4 */ +#define M_1_PI 0.318309886183790671537767526745028724 /* 1/pi */ +#define M_2_PI 0.636619772367581343075535053490057448 /* 2/pi */ +#define M_2_SQRTPI 1.12837916709551257389615890312154517 /* 2/sqrt(pi) */ +#define M_SQRT2 1.41421356237309504880168872420969808 /* sqrt(2) */ +#define M_SQRT1_2 0.707106781186547524400844362104849039 /* 1/sqrt(2) */ + +#define MAXFLOAT ((float)3.40282346638528860e+38) +extern int signgam; /* required for unix 2003 */ + + +#endif /* !defined(_ANSI_SOURCE) */ + +#if !defined(__NOEXTENSIONS__) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) +#define __WANT_EXTENSIONS__ +#endif + +#ifdef __WANT_EXTENSIONS__ + +#define FP_SNAN FP_NAN +#define FP_QNAN FP_NAN + +extern long int rinttol ( double ); /* Legacy API: please use C99 lrint() instead. */ + +extern long int roundtol ( double ); /* Legacy API: please use C99 lround() instead. */ + +/* + * XOPEN/SVID + */ +#if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) +#if (!defined(_XOPEN_SOURCE) || defined(_DARWIN_C_SOURCE)) +#if !defined(__cplusplus) +/* used by matherr below */ +struct exception { + int type; + char *name; + double arg1; + double arg2; + double retval; +}; +#endif + +#define HUGE MAXFLOAT + +/* + * set X_TLOSS = pi*2**52, which is possibly defined in <values.h> + * (one may replace the following line by "#include <values.h>") + */ + +#define X_TLOSS 1.41484755040568800000e+16 + +#define DOMAIN 1 +#define SING 2 +#define OVERFLOW 3 +#define UNDERFLOW 4 +#define TLOSS 5 +#define PLOSS 6 + +#endif /* (!_XOPEN_SOURCE || _DARWIN_C_SOURCE) */ +#endif /* !_ANSI_SOURCE && (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + +#if !defined( __STRICT_ANSI__) && !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) +extern int finite ( double ); /* Legacy API: please use C99 isfinite() instead. */ + +extern double gamma ( double ); /* Legacy API: please use C99 tgamma() instead. */ + +#if (!defined(_XOPEN_SOURCE) || defined(_DARWIN_C_SOURCE)) + +#if !defined(__cplusplus) +extern int matherr ( struct exception * ); +#endif + +/* + * IEEE Test Vector + */ +extern double significand ( double ); + +/* + * BSD math library entry points + */ +extern double drem ( double, double ); /* Legacy API: please use C99 remainder() instead. */ + +/* + * Reentrant version of lgamma; passes signgam back by reference + * as the second argument; user must allocate space for signgam. + */ + +#ifdef _REENTRANT + #include <AvailabilityMacros.h> + // Available on OS X 10.6 and later. + extern float lgammaf_r ( float, int * ) AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER; + extern double lgamma_r ( double, int * ) AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER; + extern long double lgammal_r ( long double, int * ) AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER; +#endif /* _REENTRANT */ + +#endif /* (!_XOPEN_SOURCE || _DARWIN_C_SOURCE) */ +#endif /* !_ANSI_SOURCE && (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + +#endif /* __WANT_EXTENSIONS__ */ + +#ifdef __cplusplus +} +#endif + +#endif /* __MATH__ */ Index: branches/azimutz/Cleancut/i386/include/architecture/i386/tss.h =================================================================== --- branches/azimutz/Cleancut/i386/include/architecture/i386/tss.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/architecture/i386/tss.h (revision 885) @@ -0,0 +1,120 @@ +/* + * Copyright (c) 1999 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@ + */ +/* + * Copyright (c) 1992 NeXT Computer, Inc. + * + * Intel386 Family: Task State Segment. + * + * HISTORY + * + * 29 March 1992 ? at NeXT + * Created. + */ + +#ifndef _ARCH_I386_TSS_H_ +#define _ARCH_I386_TSS_H_ + +#include <architecture/i386/sel.h> + +/* + * Task State segment. + */ + +typedef struct tss { + sel_t oldtss; + unsigned int :0; + unsigned int esp0; + sel_t ss0; + unsigned int :0; + unsigned int esp1; + sel_t ss1; + unsigned int :0; + unsigned int esp2; + sel_t ss2; + unsigned int :0; + unsigned int cr3; + unsigned int eip; + unsigned int eflags; + unsigned int eax; + unsigned int ecx; + unsigned int edx; + unsigned int ebx; + unsigned int esp; + unsigned int ebp; + unsigned int esi; + unsigned int edi; + sel_t es; + unsigned int :0; + sel_t cs; + unsigned int :0; + sel_t ss; + unsigned int :0; + sel_t ds; + unsigned int :0; + sel_t fs; + unsigned int :0; + sel_t gs; + unsigned int :0; + sel_t ldt; + unsigned int :0; + unsigned int t :1, + :15, + io_bmap :16; +} tss_t; + +#define TSS_SIZE(n) (sizeof (struct tss) + (n)) + +/* + * Task State segment descriptor. + */ + +typedef struct tss_desc { + unsigned short limit00; + unsigned short base00; + unsigned char base16; + unsigned char type :5, +#define DESC_TSS 0x09 + dpl :2, + present :1; + unsigned char limit16 :4, + :3, + granular:1; + unsigned char base24; +} tss_desc_t; + +/* + * Task gate descriptor. + */ + +typedef struct task_gate { + unsigned short :16; + sel_t tss; + unsigned int :8, + type :5, +#define DESC_TASK_GATE 0x05 + dpl :2, + present :1, + :0; +} task_gate_t; + +#endif /* _ARCH_I386_TSS_H_ */ Index: branches/azimutz/Cleancut/i386/include/architecture/i386/fpu.h =================================================================== --- branches/azimutz/Cleancut/i386/include/architecture/i386/fpu.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/architecture/i386/fpu.h (revision 885) @@ -0,0 +1,170 @@ +/* + * Copyright (c) 1999 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@ + */ +/* + * Copyright (c) 1992 NeXT Computer, Inc. + * + * Intel386 Family: Floating Point unit. + * + * HISTORY + * + * 5 October 1992 ? at NeXT + * Added names to previously unamed fields in the mantissa. + * + * 5 April 1992 ? at NeXT + * Created. + */ + +#ifndef _ARCH_I386_FPU_H_ +#define _ARCH_I386_FPU_H_ + +/* + * Data register. + */ + +typedef struct fp_data_reg { + unsigned short mant; + unsigned short mant1 :16, + mant2 :16, + mant3 :16; + unsigned short exp :15, + sign :1; +} fp_data_reg_t; + +/* + * Data register stack. + */ + +typedef struct fp_stack { + fp_data_reg_t ST[8]; +} fp_stack_t; + +/* + * Register stack tag word. + */ + +typedef struct fp_tag { + unsigned short tag0 :2, + tag1 :2, + tag2 :2, + tag3 :2, + tag4 :2, + tag5 :2, + tag6 :2, + tag7 :2; +#define FP_TAG_VALID 0 +#define FP_TAG_ZERO 1 +#define FP_TAG_SPEC 2 +#define FP_TAG_EMPTY 3 +} fp_tag_t; + +/* + * Status word. + */ + +typedef struct fp_status { + unsigned short invalid :1, + denorm :1, + zdiv :1, + ovrfl :1, + undfl :1, + precis :1, + stkflt :1, + errsumm :1, + c0 :1, + c1 :1, + c2 :1, + tos :3, + c3 :1, + busy :1; +} fp_status_t; + +/* + * Control word. + */ + +typedef struct fp_control { + unsigned short invalid :1, + denorm :1, + zdiv :1, + ovrfl :1, + undfl :1, + precis :1, + :2, + pc :2, +#define FP_PREC_24B 0 +#define FP_PREC_53B 2 +#define FP_PREC_64B 3 + rc :2, +#define FP_RND_NEAR 0 +#define FP_RND_DOWN 1 +#define FP_RND_UP 2 +#define FP_CHOP 3 + /*inf*/ :1, + :3; +} fp_control_t; + +#include <architecture/i386/sel.h> + +/* + * Floating point 'environment' + * used by FSTENV/FLDENV instructions. + */ + +typedef struct fp_env { + fp_control_t control; + unsigned short :16; + fp_status_t status; + unsigned short :16; + fp_tag_t tag; + unsigned short :16; + unsigned int ip; + sel_t cs; + unsigned short opcode; + unsigned int dp; + sel_t ds; + unsigned short :16; +} fp_env_t; + +/* + * Floating point state + * used by FSAVE/FRSTOR instructions. + */ + +/* + * To allow the the common idiom of: + * #define environ (*_NSGetEnviron()) + * to be used these fields were renamed. Old code that that does + * not use this idiom can use the old field names by defining + * _ARCHITECTURE_I386_FPU_FPSTATE_LEGACY_FIELD_NAMES_ . + */ +typedef struct fp_state { +#if _ARCHITECTURE_I386_FPU_FPSTATE_LEGACY_FIELD_NAMES_ + fp_env_t environ; + fp_stack_t stack; +#else + fp_env_t fp_environ; + fp_stack_t fp_stack; +#endif +} fp_state_t; + +#endif /* _ARCH_I386_FPU_H_ */ Index: branches/azimutz/Cleancut/i386/include/architecture/i386/frame.h =================================================================== --- branches/azimutz/Cleancut/i386/include/architecture/i386/frame.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/architecture/i386/frame.h (revision 885) @@ -0,0 +1,129 @@ +/* + * Copyright (c) 1999 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@ + */ +/* + * Copyright (c) 1992 NeXT Computer, Inc. + * + * Intel386 Family: Processor exception frame. + * + * HISTORY + * + * 31 August 1992 ? at NeXT + * Added v86 mode stuff. + * + * 8 June 1992 ? at NeXT + * Changed name of write field in err_code_t + * which collided with write() in shlib. + * + * 30 March 1992 ? at NeXT + * Created. + */ + +#ifndef _ARCH_I386_FRAME_H_ +#define _ARCH_I386_FRAME_H_ + +/* + * Format of the error code + * generated by the hardware + * for certain exceptions. + */ + +typedef union err_code { + struct err_code_normal { + unsigned int ext :1, + tbl :2, +#define ERR_GDT 0 +#define ERR_IDT 1 +#define ERR_LDT 2 + index :13, + :16; + } normal; + struct err_code_pgfault { + unsigned int prot :1, + wrtflt :1, + user :1, + :29; + } pgfault; +} err_code_t; + +#include <architecture/i386/sel.h> + +/* + * The actual hardware exception frame + * is variable in size. An error code is + * only pushed for certain exceptions. + * Previous stack information is only + * pushed for exceptions that cause a + * change in privilege level. The dpl + * field of the saved CS selector can be + * used to determine whether this is the + * case. If the interrupted task was + * executing in v86 mode, then the data + * segment registers are also present in + * the exception frame (in addition to + * previous stack information). This + * case can be determined by examining + * eflags. + */ + +typedef struct except_frame { + err_code_t err; + unsigned int eip; + sel_t cs; + unsigned int :0; + unsigned int eflags; + unsigned int esp; + sel_t ss; + unsigned int :0; + unsigned short v_es; + unsigned int :0; + unsigned short v_ds; + unsigned int :0; + unsigned short v_fs; + unsigned int :0; + unsigned short v_gs; + unsigned int :0; +} except_frame_t; + +/* + * Values in eflags. + */ + +#define EFL_CF 0x00001 +#define EFL_PF 0x00004 +#define EFL_AF 0x00010 +#define EFL_ZF 0x00040 +#define EFL_SF 0x00080 +#define EFL_TF 0x00100 +#define EFL_IF 0x00200 +#define EFL_DF 0x00400 +#define EFL_OF 0x00800 +#define EFL_IOPL 0x03000 +#define EFL_NT 0x04000 +#define EFL_RF 0x10000 +#define EFL_VM 0x20000 +#define EFL_AC 0x40000 + +#define EFL_CLR 0xfff88028 +#define EFL_SET 0x00000002 + +#endif /* _ARCH_I386_FRAME_H_ */ Index: branches/azimutz/Cleancut/i386/include/architecture/i386/alignment.h =================================================================== --- branches/azimutz/Cleancut/i386/include/architecture/i386/alignment.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/architecture/i386/alignment.h (revision 885) @@ -0,0 +1,69 @@ +/* + * Copyright (c) 1999 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@ + */ +/* + * Copyright (c) 1992 NeXT Computer, Inc. + * + * Natural alignment of shorts and longs (for i386) + * + * HISTORY + * + * 2 Sept 1992 Brian Raymor at NeXT + * Moved over to architecture. + * 18 August 1992 Jack Greenfield at NeXT + * Created. + */ + +#ifndef _ARCH_I386_ALIGNMENT_H_ +#define _ARCH_I386_ALIGNMENT_H_ + +/* + * NOP + */ +__inline__ static unsigned short +get_align_short(void *ivalue) +{ + return *((unsigned short *) ivalue); +} + +__inline__ static unsigned short +put_align_short(unsigned short ivalue, void *ovalue) +{ + return *((unsigned short *) ovalue) = ivalue; +} + +/* + * NOP + */ +__inline__ static unsigned long +get_align_long(void *ivalue) +{ + return *((unsigned long *) ivalue); +} + +__inline__ static unsigned long +put_align_long(unsigned long ivalue, void *ovalue) +{ + return *((unsigned long *) ovalue) = ivalue; +} + +#endif /* _ARCH_I386_ALIGNMENT_H_ */ Index: branches/azimutz/Cleancut/i386/include/architecture/i386/byte_order.h =================================================================== --- branches/azimutz/Cleancut/i386/include/architecture/i386/byte_order.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/architecture/i386/byte_order.h (revision 885) @@ -0,0 +1,33 @@ +/* + * Copyright (c) 1999-2002 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 _ARCH_I386_BYTE_ORDER_H_ +#define _ARCH_I386_BYTE_ORDER_H_ + +/* + * Maintain source compatibility + */ + +#include <architecture/byte_order.h> + +#endif /* _ARCH_I386_BYTE_ORDER_H_ */ Index: branches/azimutz/Cleancut/i386/include/architecture/i386/desc.h =================================================================== --- branches/azimutz/Cleancut/i386/include/architecture/i386/desc.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/architecture/i386/desc.h (revision 885) @@ -0,0 +1,150 @@ +/* + * Copyright (c) 1999 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@ + */ +/* + * Copyright (c) 1992 NeXT Computer, Inc. + * + * Intel386 Family: Segment descriptors. + * + * HISTORY + * + * 29 March 1992 ? at NeXT + * Created. + */ + +#ifndef _ARCH_I386_DESC_H_ +#define _ARCH_I386_DESC_H_ + +/* + * Code segment descriptor. + */ + +typedef struct code_desc { + unsigned short limit00; + unsigned short base00; + unsigned char base16; + unsigned char type :5, +#define DESC_CODE_EXEC 0x18 +#define DESC_CODE_READ 0x1a + dpl :2, + present :1; + unsigned char limit16 :4, + :2, + opsz :1, +#define DESC_CODE_16B 0 +#define DESC_CODE_32B 1 + granular:1; +#define DESC_GRAN_BYTE 0 +#define DESC_GRAN_PAGE 1 + unsigned char base24; +} code_desc_t; + +/* + * Data segment descriptor. + */ + +typedef struct data_desc { + unsigned short limit00; + unsigned short base00; + unsigned char base16; + unsigned char type :5, +#define DESC_DATA_RONLY 0x10 +#define DESC_DATA_WRITE 0x12 + dpl :2, + present :1; + unsigned char limit16 :4, + :2, + stksz :1, +#define DESC_DATA_16B 0 +#define DESC_DATA_32B 1 + granular:1; + unsigned char base24; +} data_desc_t; + +/* + * LDT segment descriptor. + */ + +typedef struct ldt_desc { + unsigned short limit00; + unsigned short base00; + unsigned char base16; + unsigned char type :5, +#define DESC_LDT 0x02 + :2, + present :1; + unsigned char limit16 :4, + :3, + granular:1; + unsigned char base24; +} ldt_desc_t; + +#include <architecture/i386/sel.h> + +/* + * Call gate descriptor. + */ + +typedef struct call_gate { + unsigned short offset00; + sel_t seg; + unsigned int argcnt :5, + :3, + type :5, +#define DESC_CALL_GATE 0x0c + dpl :2, + present :1, + offset16:16; +} call_gate_t; + +/* + * Trap gate descriptor. + */ + +typedef struct trap_gate { + unsigned short offset00; + sel_t seg; + unsigned int :8, + type :5, +#define DESC_TRAP_GATE 0x0f + dpl :2, + present :1, + offset16:16; +} trap_gate_t; + + +/* + * Interrupt gate descriptor. + */ + +typedef struct intr_gate { + unsigned short offset00; + sel_t seg; + unsigned int :8, + type :5, +#define DESC_INTR_GATE 0x0e + dpl :2, + present :1, + offset16:16; +} intr_gate_t; + +#endif /* _ARCH_I386_DESC_H_ */ Index: branches/azimutz/Cleancut/i386/include/architecture/i386/fenv.h =================================================================== --- branches/azimutz/Cleancut/i386/include/architecture/i386/fenv.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/architecture/i386/fenv.h (revision 885) @@ -0,0 +1,287 @@ +/* + * Copyright (c) 2002 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@ + */ + +/******************************************************************************* +* * +* File: fenv.h * +* * +* Contains: typedefs and prototypes for C99 floating point environment. * +* * +*******************************************************************************/ + +#ifndef __FENV__ +#define __FENV__ + +#if defined( __ppc__ ) || defined( __ppc64__ ) + #error Wrong arch. This is Intel only. +#endif + +#if defined(__GNUC__) && (__GNUC__ >= 4) +#pragma GCC fenv +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* + A collection of functions designed to provide access to the floating + point environment for numerical programming. It is compliant with + the floating-point requirements in C99. + + Earlier versions of fenv.h were merely "modeled after" C9X. Many of the functions + that formerly returned ints now return void to be standard compliant. + + Note: There are actually two physical floating point environments on x86. There + is the one described by the x87 floating point control and status words, which applies + primarily to calculations done with long double on MacOS X for Intel. There is the + MXCSR which applies primarily to calculations done with scalar float, scalar double + and SSE/SSE2/SSE3. The high level interface, which uses FE_ macros as int arguments + to configure the fexcep_t, returns and works with values that represents the logical + OR of these two sets of flags or masks. That is, if a flag or mask is set in either + environment, it will be set in fexcept_t when the state is read. Likewise, setting + the mask using a fexcep_t will set that mask on both environments. For this reason, + changing the value of the MXCSR state or floating point control/status word state on + your own will make the results of the functions declared in this header undefined. + See below for details about how and when. Exception: you may change the FZ, DAZ, DE + and DM bits in the MXCSR independent of this interface and retain defined behavior, + so long as you do not change the other bits. It is suggested that developers who wish + this level of control access the bits in the fenv_t directly. They are direct copies + of the hardware special purpose registers of similar name. Please consult appropriate + Intel documentation for the processor about the meaning of various bits in each register. + + The file <fenv.h> declares many functions in support of numerical + programming. Programs that test flags or run under + non-default modes must do so under the effect of an enabling + "fenv_access" pragma. +*/ + +/******************************************************************************** +* * +* fenv_t is a type for representing the entire floating-point * +* environment in a single object. * +* * +* fexcept_t is a type for representing the floating-point * +* exception flag state collectively. * +* * +********************************************************************************/ +typedef struct { + unsigned short __control; /* A direct copy of the floaing point control word */ + unsigned short __status; /* A direct copy of the floaing point status word */ + unsigned int __mxcsr; /* A direct copy of the MXCSR */ + char __reserved[8]; /* Reserved for future expansion. */ +} fenv_t; + +typedef unsigned short fexcept_t; + +/* Definitions of floating-point exception macros */ +#define FE_INEXACT 0x0020 +#define FE_UNDERFLOW 0x0010 +#define FE_OVERFLOW 0x0008 +#define FE_DIVBYZERO 0x0004 +#define FE_INVALID 0x0001 +#define FE_ALL_EXCEPT 0x003D + +/* Definitions of rounding direction macros */ +#define FE_TONEAREST 0x0000 +#define FE_DOWNWARD 0x0400 +#define FE_UPWARD 0x0800 +#define FE_TOWARDZERO 0x0C00 + +/* default environment object */ +extern const fenv_t _FE_DFL_ENV; +#define FE_DFL_ENV &_FE_DFL_ENV /* pointer to default environment */ + +/******************************************************************************* +* A environment object that sets to defualt settings and in addition sets the * +* FZ and DAZ bits in the MXCSR, which causes flush-to-zero behavior of * +* denormals. When using this environment, denormals encountered by XMM based * +* calculation (which normally should be all single and double precision scalar * +* floating point calculations, and all SSE/SSE2/SSE3 computation) will be * +* treated as zero. Calculation results that are denormals will also be * +* truncated to zero. This calculation mode is not IEEE-754 compliant, but may * +* prevent lengthy stalls that occur in code that encounters denormals. It is * +* suggested that you do not use this mode unless you have established that * +* denormals are causing trouble for your code. Please use wisely. * +* * +* CAUTION: The math library currently is not architected to do the right * +* thing in the face of DAZ + FZ mode. For example, ceil( +denormal) returns * +* +denormal rather than 1.0 in some versions of MacOS X. In some circumstances * +* this may lead to unexpected application behavior. Use at your own risk. * +* * +* It is not possible to disable denorm stalls on calculation using the x87 FPU.* +*******************************************************************************/ +extern const fenv_t _FE_DFL_DISABLE_SSE_DENORMS_ENV; +#define FE_DFL_DISABLE_SSE_DENORMS_ENV &_FE_DFL_DISABLE_SSE_DENORMS_ENV + +/******************************************************************************* +* The following functions provide high level access to the exception flags.* +* The "int" input argument can be constructed by bitwise ORs of the * +* exception macros: for example: FE_OVERFLOW | FE_INEXACT. * +*******************************************************************************/ + +/******************************************************************************* +* The function "feclearexcept" clears the supported floating point * +* exceptions represented by its argument. * +*******************************************************************************/ + +extern int feclearexcept(int /*excepts*/); + + +/******************************************************************************* +* The function "fegetexceptflag" stores a implementation-defined * +* representation of the states of the floating-point status flags indicated * +* by its integer argument excepts in the object pointed to by the argument, * +* flagp. * +*******************************************************************************/ + +extern int fegetexceptflag(fexcept_t * /*flagp*/, int /*excepts*/); + + +/******************************************************************************* +* The function "feraiseexcept" raises the supported floating-point * +* exceptions represented by its argument. The order in which these * +* floating-point exceptions are raised is unspecified. * +*******************************************************************************/ + +extern int feraiseexcept(int /*excepts*/); + + +/******************************************************************************* +* The function "fesetexceptflag" sets or clears the floating point status * +* flags indicated by the argument excepts to the states stored in the * +* object pointed to by flagp. The value of the *flagp shall have been set * +* by a previous call to fegetexceptflag whose second argument represented * +* at least those floating-point exceptions represented by the argument * +* excepts. This function does not raise floating-point exceptions; it just * +* sets the state of the flags. * +*******************************************************************************/ + +extern int fesetexceptflag(const fexcept_t * /*flagp*/, int /*excepts*/); + + +/******************************************************************************* +* The function "fetestexcept" determines which of the specified subset of * +* the floating-point exception flags are currently set. The excepts * +* argument specifies the floating-point status flags to be queried. This * +* function returns the value of the bitwise OR of the floating-point * +* exception macros corresponding to the currently set floating-point * +* exceptions included in excepts. * +* * +* On MacOS X for Intel, the result is the value of union of the * +* corresponding result from the x87 and SSE floating point states. * +*******************************************************************************/ + +extern int fetestexcept(int /*excepts*/); + + +/******************************************************************************* +* The following functions provide control of rounding direction modes. * +*******************************************************************************/ + +/******************************************************************************* +* The function "fegetround" returns the value of the rounding direction * +* macro which represents the current rounding direction, or a negative * +* if there is no such rounding direction macro or the current rounding * +* direction is not determinable. * +*******************************************************************************/ + +extern int fegetround(void); + + +/******************************************************************************* +* The function "fesetround" establishes the rounding direction represented * +* by its argument "round". If the argument is not equal to the value of a * +* rounding direction macro, the rounding direction is not changed. It * +* returns zero if and only if the argument is equal to a rounding * +* direction macro. * +*******************************************************************************/ + +extern int fesetround(int /*round*/); + + +/******************************************************************************* +* The following functions manage the floating-point environment, exception * +* flags and dynamic modes, as one entity. * +*******************************************************************************/ + +/******************************************************************************* +* The fegetenv function stores the current floating-point enviornment in * +* the object pointed to by envp. * +*******************************************************************************/ +extern int fegetenv(fenv_t * /*envp*/); + +/******************************************************************************* +* The feholdexcept function saves the current floating-point environment in * +* the object pointed to by envp, clears the floating-point status flags, * +* and then installs a non-stop (continue on floating-point exceptions) * +* mode, if available, for all floating-point exceptions. The feholdexcept * +* function returns zero if and only if non-stop floating-point exceptions * +* handling was successfully installed. * +*******************************************************************************/ +extern int feholdexcept(fenv_t * /*envp*/); + +/******************************************************************************* +* The fesetnv function establishes the floating-point environment * +* represented by the object pointed to by envp. The argument envp shall * +* point to an object set by a call to fegetenv or feholdexcept, or equal to * +* a floating-point environment macro -- we define only *FE_DFL_ENV and * +* FE_DISABLE_SSE_DENORMS_ENV -- to be C99 standard compliant and portable * +* to other architectures. Note that fesetnv merely installs the state of * +* the floating-point status flags represented through its argument, and * +* does not raise these floating-point exceptions. * +* * +* On MacOS X for Intel you may test and set the bits in *envp yourself, * +* provided that you conditionalize the code appropriately to preserve * +* portability and you follow the various strictures and suggestions * +* provided by Intel in appropriate processor documentation. Please be aware * +* that because there are two hardware locations for setting and reading * +* floating point environment, this function (and others like it) are not * +* atomic -- that is, for a brief period of time during the function call * +* your new environment will have been applied to one but not both of the * +* floating point engines (x87 and SSE). In addition, the behavior of some * +* higher level interfaces (fegetround) is undefined if the x87 and SSE * +* floating point units rounding modes are configured differently. Please * +* use common sense. * +*******************************************************************************/ +extern int fesetenv(const fenv_t * /*envp*/); + +/******************************************************************************* +* The feupdateenv function saves the currently raised floating-point * +* exceptions in its automatic storage, installs the floating-point * +* environment represented by the object pointed to by envp, and then raises * +* the saved floating-point exceptions. The argument envp shall point to an * +* object set by a call to feholdexcept or fegetenv or equal a * +* floating-point environment macro. * +* * +* Please see the description of feholdexcept for additional ways to create * +* a fenv_t object, which are valid only for MacOS X for Intel. * +*******************************************************************************/ +extern int feupdateenv(const fenv_t * /*envp*/); + + +#ifdef __cplusplus +} +#endif + +#endif /* __FENV__ */ + Index: branches/azimutz/Cleancut/i386/include/architecture/i386/sel.h =================================================================== --- branches/azimutz/Cleancut/i386/include/architecture/i386/sel.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/architecture/i386/sel.h (revision 885) @@ -0,0 +1,53 @@ +/* + * Copyright (c) 1999 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@ + */ +/* + * Copyright (c) 1992 NeXT Computer, Inc. + * + * Intel386 Family: Segment selector. + * + * HISTORY + * + * 29 March 1992 ? at NeXT + * Created. + */ + +#ifndef _ARCH_I386_SEL_H_ +#define _ARCH_I386_SEL_H_ + +/* + * Segment selector. + */ + +typedef struct sel { + unsigned short rpl :2, +#define KERN_PRIV 0 +#define USER_PRIV 3 + ti :1, +#define SEL_GDT 0 +#define SEL_LDT 1 + index :13; +} sel_t; + +#define NULL_SEL ((sel_t) { 0, 0, 0 } ) + +#endif /* _ARCH_I386_SEL_H_ */ Index: branches/azimutz/Cleancut/i386/include/architecture/i386/reg_help.h =================================================================== --- branches/azimutz/Cleancut/i386/include/architecture/i386/reg_help.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/architecture/i386/reg_help.h (revision 885) @@ -0,0 +1,105 @@ +/* + * Copyright (c) 1999 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@ + */ +/* Copyright (c) 1991 NeXT Computer, Inc. All rights reserved. + * + * File: architecture/i386/reg_help.h + * Author: Mike DeMoney, NeXT Computer, Inc. + * Modified for i386 by: Bruce Martin, NeXT Computer, Inc. + * + * This header file defines cpp macros useful for defining + * machine register and doing machine-level operations. + * + * HISTORY + * 10-Mar-92 Bruce Martin (bmartin@next.com) + * Adapted to i386 + * 23-Jan-91 Mike DeMoney (mike@next.com) + * Created. + */ + +#ifndef _ARCH_I386_REG_HELP_H_ +#define _ARCH_I386_REG_HELP_H_ + +/* Bitfield definition aid */ +#define BITS_WIDTH(msb, lsb) ((msb)-(lsb)+1) +#define BIT_WIDTH(pos) (1) /* mostly to record the position */ + +/* Mask creation */ +#define MKMASK(width, offset) (((unsigned)-1)>>(32-(width))<<(offset)) +#define BITSMASK(msb, lsb) MKMASK(BITS_WIDTH(msb, lsb), lsb & 0x1f) +#define BITMASK(pos) MKMASK(BIT_WIDTH(pos), pos & 0x1f) + +/* Register addresses */ +#if __ASSEMBLER__ +# define REG_ADDR(type, addr) (addr) +#else /* __ASSEMBLER__ */ +# define REG_ADDR(type, addr) (*(volatile type *)(addr)) +#endif /* __ASSEMBLER__ */ + +/* Cast a register to be an unsigned */ +#define CONTENTS(foo) (*(unsigned *) &(foo)) + +/* Stack pointer must always be a multiple of 4 */ +#define STACK_INCR 4 +#define ROUND_FRAME(x) ((((unsigned)(x)) + STACK_INCR - 1) & ~(STACK_INCR-1)) + +/* STRINGIFY -- perform all possible substitutions, then stringify */ +#define __STR(x) #x /* just a helper macro */ +#define STRINGIFY(x) __STR(x) + +/* + * REG_PAIR_DEF -- define a register pair + * Register pairs are appropriately aligned to allow access via + * ld.d and st.d. + * + * Usage: + * struct foo { + * REG_PAIR_DEF( + * bar_t *, barp, + * afu_t, afu + * ); + * }; + * + * Access to individual entries of the pair is via the REG_PAIR + * macro (below). + */ +#define REG_PAIR_DEF(type0, name0, type1, name1) \ + struct { \ + type0 name0 __attribute__(( aligned(8) )); \ + type1 name1; \ + } name0##_##name1 + +/* + * REG_PAIR -- Macro to define names for accessing individual registers + * of register pairs. + * + * Usage: + * arg0 is first element of pair + * arg1 is second element of pair + * arg2 is desired element of pair + * eg: + * #define foo_barp REG_PAIR(barp, afu, afu) + */ +#define REG_PAIR(name0, name1, the_name) \ + name0##_##name1.the_name + +#endif /* _ARCH_I386_REG_HELP_H_ */ Index: branches/azimutz/Cleancut/i386/include/architecture/i386/cpu.h =================================================================== --- branches/azimutz/Cleancut/i386/include/architecture/i386/cpu.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/architecture/i386/cpu.h (revision 885) @@ -0,0 +1,74 @@ +/* + * Copyright (c) 1999 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@ + */ +/* + * Copyright (c) 1992 NeXT Computer, Inc. + * + * Intel386 Family: Special processor registers. + * + * HISTORY + * + * 5 April 1992 ? at NeXT + * Created. + */ + +#ifndef _ARCH_I386_CPU_H_ +#define _ARCH_I386_CPU_H_ + +/* + * Control register 0 + */ + +typedef struct _cr0 { + unsigned int pe :1, + mp :1, + em :1, + ts :1, + :1, + ne :1, + :10, + wp :1, + :1, + am :1, + :10, + nw :1, + cd :1, + pg :1; +} cr0_t; + +/* + * Debugging register 6 + */ + +typedef struct _dr6 { + unsigned int b0 :1, + b1 :1, + b2 :1, + b3 :1, + :9, + bd :1, + bs :1, + bt :1, + :16; +} dr6_t; + +#endif /* _ARCH_I386_CPU_H_ */ Index: branches/azimutz/Cleancut/i386/include/architecture/i386/io.h =================================================================== --- branches/azimutz/Cleancut/i386/include/architecture/i386/io.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/architecture/i386/io.h (revision 885) @@ -0,0 +1,40 @@ +/* + * Copyright (c) 1999 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@ + */ +/* + * Copyright (c) 1992 NeXT Computer, Inc. + * + * Intel 386 Family: IO space defines. + * + * HISTORY + * + * 11 August 1992 ? at NeXT + * Created. + */ + +#ifndef _ARCH_I386_IO_H_ +#define _ARCH_I386_IO_H_ + +typedef unsigned short io_addr_t; +typedef unsigned short io_len_t; + +#endif /* _ARCH_I386_IO_H_ */ Index: branches/azimutz/Cleancut/i386/include/architecture/i386/pio.h =================================================================== --- branches/azimutz/Cleancut/i386/include/architecture/i386/pio.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/architecture/i386/pio.h (revision 885) @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2000-2005 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@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * Mach Operating System + * Copyright (c) 1991,1990 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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + */ +#ifndef _ARCH_I386_PIO_H_ +#define _ARCH_I386_PIO_H_ + +typedef unsigned short i386_ioport_t; + +#if defined(__GNUC__) +static __inline__ unsigned long inl( + i386_ioport_t port) +{ + unsigned long datum; + __asm__ volatile("inl %w1, %0" : "=a" (datum) : "Nd" (port)); + return(datum); +} + +static __inline__ unsigned short inw( + i386_ioport_t port) +{ + unsigned short datum; + __asm__ volatile("inw %w1, %w0" : "=a" (datum) : "Nd" (port)); + return(datum); +} + +static __inline__ unsigned char inb( + i386_ioport_t port) +{ + unsigned char datum; + __asm__ volatile("inb %w1, %b0" : "=a" (datum) : "Nd" (port)); + return(datum); +} + +static __inline__ void outl( + i386_ioport_t port, + unsigned long datum) +{ + __asm__ volatile("outl %0, %w1" : : "a" (datum), "Nd" (port)); +} + +static __inline__ void outw( + i386_ioport_t port, + unsigned short datum) +{ + __asm__ volatile("outw %w0, %w1" : : "a" (datum), "Nd" (port)); +} + +static __inline__ void outb( + i386_ioport_t port, + unsigned char datum) +{ + __asm__ volatile("outb %b0, %w1" : : "a" (datum), "Nd" (port)); +} +#endif /* defined(__GNUC__) */ +#endif /* _ARCH_I386_PIO_H_ */ Index: branches/azimutz/Cleancut/i386/include/architecture/i386/table.h =================================================================== --- branches/azimutz/Cleancut/i386/include/architecture/i386/table.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/architecture/i386/table.h (revision 885) @@ -0,0 +1,98 @@ +/* + * Copyright (c) 1999 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@ + */ +/* + * Copyright (c) 1992 NeXT Computer, Inc. + * + * Intel386 Family: Descriptor tables. + * + * HISTORY + * + * 30 March 1992 ? at NeXT + * Created. + */ + +#ifndef _ARCH_I386_TABLE_H_ +#define _ARCH_I386_TABLE_H_ + +#include <architecture/i386/desc.h> +#include <architecture/i386/tss.h> + +/* + * A totally generic descriptor + * table entry. + */ + +typedef union dt_entry { + code_desc_t code; + data_desc_t data; + ldt_desc_t ldt; + tss_desc_t task_state; + call_gate_t call_gate; + trap_gate_t trap_gate; + intr_gate_t intr_gate; + task_gate_t task_gate; +} dt_entry_t; + +#define DESC_TBL_MAX 8192 + +/* + * Global descriptor table. + */ + +typedef union gdt_entry { + code_desc_t code; + data_desc_t data; + ldt_desc_t ldt; + call_gate_t call_gate; + task_gate_t task_gate; + tss_desc_t task_state; +} gdt_entry_t; + +typedef gdt_entry_t gdt_t; + +/* + * Interrupt descriptor table. + */ + +typedef union idt_entry { + trap_gate_t trap_gate; + intr_gate_t intr_gate; + task_gate_t task_gate; +} idt_entry_t; + +typedef idt_entry_t idt_t; + +/* + * Local descriptor table. + */ + +typedef union ldt_entry { + code_desc_t code; + data_desc_t data; + call_gate_t call_gate; + task_gate_t task_gate; +} ldt_entry_t; + +typedef ldt_entry_t ldt_t; + +#endif /* _ARCH_I386_TABLE_H_ */ Index: branches/azimutz/Cleancut/i386/include/architecture/i386/asm_help.h =================================================================== --- branches/azimutz/Cleancut/i386/include/architecture/i386/asm_help.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/architecture/i386/asm_help.h (revision 885) @@ -0,0 +1,398 @@ +/* + * Copyright (c) 1999 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@ + */ +/* Copyright (c) 1991 NeXT Computer, Inc. All rights reserved. + * + * File: architecture/i386/asm_help.h + * Author: Mike DeMoney, NeXT Computer, Inc. + * Modified for i386 by: Bruce Martin, NeXT Computer, Inc. + * + * This header file defines macros useful when writing assembly code + * for the Intel i386 family processors. + * + * HISTORY + * 10-Mar-92 Bruce Martin (bmartin@next.com) + * Adapted to i386 + * 23-Jan-91 Mike DeMoney (mike@next.com) + * Created. + */ + +#ifndef _ARCH_I386_ASM_HELP_H_ +#define _ARCH_I386_ASM_HELP_H_ + +#include <architecture/i386/reg_help.h> + + +#ifdef __ASSEMBLER__ + +#define ALIGN \ + .align 2, 0x90 + +#define ROUND_TO_STACK(len) \ + (((len) + STACK_INCR - 1) / STACK_INCR * STACK_INCR) + +#ifdef notdef +#if defined(__i386__) +#define CALL_MCOUNT \ + pushl %ebp ;\ + movl %esp, %ebp ;\ + .data ;\ + 1: .long 0 ;\ + .text ;\ + lea 9b,%edx ;\ + call mcount ;\ + popl %ebp ; +#elif defined(__x86_64__) +#define CALL_MCOUNT \ + pushq %rbp ;\ + movq %rsp, %rbp ;\ + .data ;\ + 1: .quad 0 ;\ + .text ;\ + lea 9b,%r13 ;\ + call mcount ;\ + popq %rbp ; +#endif +#else +#define CALL_MCOUNT +#endif + +/* + * Prologue for functions that may call other functions. Saves + * registers and sets up a C frame. + */ +#if defined(__i386__) +#define NESTED_FUNCTION_PROLOGUE(localvarsize) \ + .set __framesize,ROUND_TO_STACK(localvarsize) ;\ + .set __nested_function, 1 ;\ + CALL_MCOUNT \ + .if __framesize ;\ + pushl %ebp ;\ + movl %esp, %ebp ;\ + subl $__framesize, %esp ;\ + .endif ;\ + pushl %edi ;\ + pushl %esi ;\ + pushl %ebx +#elif defined(__x86_64__) +#define NESTED_FUNCTION_PROLOGUE(localvarsize) \ + .set __framesize,ROUND_TO_STACK(localvarsize) ;\ + .set __nested_function, 1 ;\ + CALL_MCOUNT \ + .if __framesize ;\ + pushq %rbp ;\ + movq %rsp, %rbp ;\ + subq $__framesize, %rsp ;\ + .endif ; +#endif + +/* + * Prologue for functions that do not call other functions. Does not + * save registers (this is the functions responsibility). Does set + * up a C frame. + */ +#if defined(__i386__) +#define LEAF_FUNCTION_PROLOGUE(localvarsize) \ + .set __framesize,ROUND_TO_STACK(localvarsize) ;\ + .set __nested_function, 0 ;\ + CALL_MCOUNT \ + .if __framesize ;\ + pushl %ebp ;\ + movl %esp, %ebp ;\ + subl $__framesize, %esp ;\ + .endif +#elif defined(__x86_64__) +#define LEAF_FUNCTION_PROLOGUE(localvarsize) \ + .set __framesize,ROUND_TO_STACK(localvarsize) ;\ + .set __nested_function, 0 ;\ + CALL_MCOUNT \ + .if __framesize ;\ + pushq %rbp ;\ + movq %rsp, %rbp ;\ + subq $__framesize, %rsp ;\ + .endif +#endif + +/* + * Epilogue for any function. + * + * We assume that all Leaf functions will be responsible for saving any + * local registers they clobber. + */ +#if defined(__i386__) +#define FUNCTION_EPILOGUE \ + .if __nested_function ;\ + popl %ebx ;\ + popl %esi ;\ + popl %edi ;\ + .endif ;\ + .if __framesize ;\ + movl %ebp, %esp ;\ + popl %ebp ;\ + .endif ;\ + ret +#elif defined(__x86_64__) +#define FUNCTION_EPILOGUE \ + .if __framesize ;\ + movq %rbp, %rsp ;\ + popq %rbp ;\ + .endif ;\ + ret +#endif + +/* + * Macros for declaring procedures + * + * Use of these macros allows ctags to have a predictable way + * to find various types of declarations. They also simplify + * inserting appropriate symbol table information. + * + * NOTE: these simple stubs will be replaced with more + * complicated versions once we know what the linker and gdb + * will require as far as register use masks and frame declarations. + * These macros may also be ifdef'ed in the future to contain profiling + * code. + * + */ + +/* + * TEXT -- declare start of text segment + */ +#define TEXT \ + .text + +/* + * DATA -- declare start of data segment + */ +#define DATA \ + .data + +/* + * LEAF -- declare global leaf procedure + * NOTE: Control SHOULD NOT FLOW into a LEAF! A LEAF should only + * be jumped to. (A leaf may do an align.) Use a LABEL() if you + * need control to flow into the label. + */ +#define LEAF(name, localvarsize) \ + .globl name ;\ + ALIGN ;\ +name: ;\ + LEAF_FUNCTION_PROLOGUE(localvarsize) + +/* + * X_LEAF -- declare alternate global label for leaf + */ +#define X_LEAF(name, value) \ + .globl name ;\ + .set name,value + +/* + * P_LEAF -- declare private leaf procedure + */ +#define P_LEAF(name, localvarsize) \ + ALIGN ;\ +name: ;\ + LEAF_FUNCTION_PROLOGUE(localvarsize) + +/* + * LABEL -- declare a global code label + * MUST be used (rather than LEAF, NESTED, etc) if control + * "flows into" the label. + */ +#define LABEL(name) \ + .globl name ;\ +name: + +/* + * NESTED -- declare procedure that invokes other procedures + */ +#define NESTED(name, localvarsize) \ + .globl name ;\ + ALIGN ;\ +name: ;\ + NESTED_FUNCTION_PROLOGUE(localvarsize) + +/* + * X_NESTED -- declare alternate global label for nested proc + */ +#define X_NESTED(name, value) \ + .globl name ;\ + .set name,value + +/* + * P_NESTED -- declare private nested procedure + */ +#define P_NESTED(name, localvarsize) \ + ALIGN ;\ +name: ;\ + NESTED_FUNCTION_PROLOGUE(localvarsize) + +/* + * END -- mark end of procedure + */ +#define END(name) \ + FUNCTION_EPILOGUE + + +/* + * Storage definition macros + * The main purpose of these is to allow an easy handle for ctags + */ + +/* + * IMPORT -- import symbol + */ +#define IMPORT(name) \ + .reference name + +/* + * ABS -- declare global absolute symbol + */ +#define ABS(name, value) \ + .globl name ;\ + .set name,value + +/* + * P_ABS -- declare private absolute symbol + */ +#define P_ABS(name, value) \ + .set name,value + +/* + * EXPORT -- declare global label for data + */ +#define EXPORT(name) \ + .globl name ;\ +name: + +/* + * BSS -- declare global zero'ed storage + */ +#define BSS(name,size) \ + .comm name,size + + +/* + * P_BSS -- declare private zero'ed storage + */ +#define P_BSS(name,size) \ + .lcomm name,size + +/* + * dynamic/PIC macros for routines which reference external symbols + */ + +#if defined(__DYNAMIC__) +#if defined(__i386__) +#define PICIFY(var) \ + call 1f ; \ +1: ; \ + popl %edx ; \ + movl L ## var ## __non_lazy_ptr-1b(%edx),%edx +#elif defined(__x86_64__) +#define PICIFY(var) \ + movq var@GOTPCREL(%rip),%r11 +#endif + +#if defined(__i386__) +#define CALL_EXTERN_AGAIN(func) \ + PICIFY(func) ; \ + call *%edx +#elif defined(__x86_64__) +#define CALL_EXTERN_AGAIN(func) \ + call func +#endif + +#if defined(__i386__) +#define NON_LAZY_STUB(var) \ +.section __IMPORT,__pointers,non_lazy_symbol_pointers ; \ +L ## var ## __non_lazy_ptr: ; \ +.indirect_symbol var ; \ +.long 0 ; \ +.text +#elif defined(__x86_64__) +#define NON_LAZY_STUB(var) +#endif + +#define CALL_EXTERN(func) \ + CALL_EXTERN_AGAIN(func) ; \ + NON_LAZY_STUB(func) + +#if defined(__i386__) +#define BRANCH_EXTERN(func) \ + PICIFY(func) ; \ + jmp *%edx ; \ + NON_LAZY_STUB(func) +#elif defined(__x86_64__) +#define BRANCH_EXTERN(func) \ + jmp func +#endif + +#if defined(__i386__) +#define PUSH_EXTERN(var) \ + PICIFY(var) ; \ + movl (%edx),%edx ; \ + pushl %edx ; \ + NON_LAZY_STUB(var) +#endif + +#if defined(__i386__) +#define REG_TO_EXTERN(reg, var) \ + PICIFY(var) ; \ + movl reg, (%edx) ; \ + NON_LAZY_STUB(var) +#elif defined(__x86_64__) +#define REG_TO_EXTERN(reg, var) \ + PICIFY(var) ; \ + mov reg, (%r11) +#endif + +#if defined(__i386__) +#define EXTERN_TO_REG(var, reg) \ + call 1f ; \ +1: ; \ + popl %edx ; \ + movl L ## var ##__non_lazy_ptr-1b(%edx),reg ; \ + NON_LAZY_STUB(var) +#elif defined(__x86_64__) +#define EXTERN_TO_REG(var, reg) \ + PICIFY(var) ; \ + mov (%r11), reg +#endif + +#else +#define BRANCH_EXTERN(func) jmp func +#define PUSH_EXTERN(var) push var +#define CALL_EXTERN(func) call func +#define CALL_EXTERN_AGAIN(func) call func +#if defined(__i386__) +#define REG_TO_EXTERN(reg, var) mov reg, var +#define EXTERN_TO_REG(var, reg) mov $ ## var, reg +#elif defined(__x86_64__) +#define REG_TO_EXTERN(reg, var) mov reg, var ## (%rip) +#define EXTERN_TO_REG(var, reg) mov var ## (%rip), reg +#endif +#endif + +#endif /* __ASSEMBLER__ */ + +#endif /* _ARCH_I386_ASM_HELP_H_ */ Index: branches/azimutz/Cleancut/i386/include/secure/_stdio.h =================================================================== --- branches/azimutz/Cleancut/i386/include/secure/_stdio.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/secure/_stdio.h (revision 885) @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2007 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 _STDIO_H_ + #error error "Never use <secure/_stdio.h> directly; include <stdio.h> instead." +#endif + +#ifndef _SECURE__STDIO_H_ +#define _SECURE__STDIO_H_ + +#include <secure/_common.h> + +#if _USE_FORTIFY_LEVEL > 0 + +#undef sprintf +#undef vsprintf +#undef snprintf +#undef vsnprintf + +/* sprintf, vsprintf, snprintf, vsnprintf */ + +extern int __sprintf_chk (char * __restrict, int, size_t, + const char * __restrict, ...) + __DARWIN_LDBL_COMPAT (__sprintf_chk); + +#define sprintf(str, ...) \ + __builtin___sprintf_chk (str, 0, __darwin_obsz(str), __VA_ARGS__) + +extern int __snprintf_chk (char * __restrict, size_t, int, size_t, + const char * __restrict, ...) + __DARWIN_LDBL_COMPAT (__snprintf_chk); + +#define snprintf(str, len, ...) \ + __builtin___snprintf_chk (str, len, 0, __darwin_obsz(str), __VA_ARGS__) + +extern int __vsprintf_chk (char * __restrict, int, size_t, + const char * __restrict, va_list) + __DARWIN_LDBL_COMPAT (__vsprintf_chk); + +#define vsprintf(str, format, ap) \ + __builtin___vsprintf_chk (str, 0, __darwin_obsz(str), format, ap) + +extern int __vsnprintf_chk (char * __restrict, size_t, int, size_t, + const char * __restrict, va_list) + __DARWIN_LDBL_COMPAT (__vsnprintf_chk); + +#define vsnprintf(str, len, format, ap) \ + __builtin___vsnprintf_chk (str, len, 0, __darwin_obsz(str), format, ap) + + +#endif + +#endif Index: branches/azimutz/Cleancut/i386/include/secure/_common.h =================================================================== --- branches/azimutz/Cleancut/i386/include/secure/_common.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/secure/_common.h (revision 885) @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2007, 2008 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 _SECURE__COMMON_H_ +#define _SECURE__COMMON_H_ + +#undef _USE_FORTIFY_LEVEL +#if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 +# if _FORTIFY_SOURCE > 1 +# define _USE_FORTIFY_LEVEL 2 +# else +# define _USE_FORTIFY_LEVEL 1 +# endif +#else +# define _USE_FORTIFY_LEVEL 0 +#endif + +#define __darwin_obsz0(object) __builtin_object_size (object, 0) +#define __darwin_obsz(object) __builtin_object_size (object, _USE_FORTIFY_LEVEL > 1) + +#endif Index: branches/azimutz/Cleancut/i386/include/limits.h =================================================================== --- branches/azimutz/Cleancut/i386/include/limits.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/limits.h (revision 885) @@ -0,0 +1,144 @@ +/* + * Copyright (c) 2000 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@ + */ +/* $NetBSD: limits.h,v 1.8 1996/10/21 05:10:50 jtc Exp $ */ + +/* + * Copyright (c) 1988, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)limits.h 8.2 (Berkeley) 1/4/94 + */ + +#ifndef _LIMITS_H_ +#define _LIMITS_H_ + +#include <sys/cdefs.h> +#include <i386/limits.h> +#include <sys/syslimits.h> + +#if !defined(_ANSI_SOURCE) +#define _POSIX_AIO_LISTIO_MAX 2 +#define _POSIX_AIO_MAX 1 +#define _POSIX_DELAYTIMER_MAX 32 +#define _POSIX_HOST_NAME_MAX 255 +#define _POSIX_LOGIN_NAME_MAX 9 +#define _POSIX_MQ_OPEN_MAX 8 +#define _POSIX_MQ_PRIO_MAX 32 + +#define _POSIX_ARG_MAX 4096 +#define _POSIX_CHILD_MAX 25 +#define _POSIX_LINK_MAX 8 +#define _POSIX_MAX_CANON 255 +#define _POSIX_MAX_INPUT 255 +#define _POSIX_NAME_MAX 14 +#define _POSIX_NGROUPS_MAX 8 +#define _POSIX_OPEN_MAX 20 +#define _POSIX_PATH_MAX 256 +#define _POSIX_PIPE_BUF 512 +#define _POSIX_SSIZE_MAX 32767 +#define _POSIX_STREAM_MAX 8 +#define _POSIX_TZNAME_MAX 6 + +#define _POSIX_RE_DUP_MAX 255 +#define _POSIX_RTSIG_MAX 8 +#define _POSIX_SEM_NSEMS_MAX 256 +#define _POSIX_SEM_VALUE_MAX 32767 +#define _POSIX_SIGQUEUE_MAX 32 +#define _POSIX_SS_REPL_MAX 4 +#define _POSIX_SYMLINK_MAX 255 +#define _POSIX_SYMLOOP_MAX 8 +#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4 +#define _POSIX_THREAD_KEYS_MAX 128 +#define _POSIX_THREAD_THREADS_MAX 64 +#define _POSIX_TIMER_MAX 32 +#define _POSIX_TRACE_EVENT_NAME_MAX 30 +#define _POSIX_TRACE_NAME_MAX 8 +#define _POSIX_TRACE_SYS_MAX 8 +#define _POSIX_TRACE_USER_EVENT_MAX 32 +#define _POSIX_TTY_NAME_MAX 9 + +#define _POSIX2_BC_BASE_MAX 99 +#define _POSIX2_BC_DIM_MAX 2048 +#define _POSIX2_BC_SCALE_MAX 99 +#define _POSIX2_BC_STRING_MAX 1000 +#define _POSIX2_CHARCLASS_NAME_MAX 14 +#define _POSIX2_COLL_WEIGHTS_MAX 2 +#define _POSIX2_EQUIV_CLASS_MAX 2 +#define _POSIX2_EXPR_NEST_MAX 32 +#define _POSIX2_LINE_MAX 2048 +#define _POSIX2_RE_DUP_MAX 255 + +#define PTHREAD_STACK_MIN 8192 +#define PTHREAD_DESTRUCTOR_ITERATIONS 4 +#define PTHREAD_KEYS_MAX 512 + +#if (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) +#define PASS_MAX 128 +#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ + +#define NL_ARGMAX 9 +#define NL_LANGMAX 14 +#define NL_MSGMAX 32767 +#define NL_NMAX 1 +#define NL_SETMAX 255 +#define NL_TEXTMAX 2048 + +#define _XOPEN_IOV_MAX 16 +#define IOV_MAX 1024 +#define _XOPEN_NAME_MAX 255 +#define _XOPEN_PATH_MAX 1024 + +#endif /* _ANSI_SOURCE */ + +/* NZERO to be defined here. TBD. See also sys/param.h */ + +#endif /* !_LIMITS_H_ */ + Index: branches/azimutz/Cleancut/i386/include/_types.h =================================================================== --- branches/azimutz/Cleancut/i386/include/_types.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/_types.h (revision 885) @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2004, 2008, 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 __TYPES_H_ +#define __TYPES_H_ + +#include <sys/_types.h> + +#if __GNUC__ > 2 || __GNUC__ == 2 && __GNUC_MINOR__ >= 7 +#define __strfmonlike(fmtarg, firstvararg) \ + __attribute__((__format__ (__strfmon__, fmtarg, firstvararg))) +#define __strftimelike(fmtarg) \ + __attribute__((__format__ (__strftime__, fmtarg, 0))) +#else +#define __strfmonlike(fmtarg, firstvararg) +#define __strftimelike(fmtarg) +#endif + +typedef int __darwin_nl_item; +typedef int __darwin_wctrans_t; +#ifdef __LP64__ +typedef __uint32_t __darwin_wctype_t; +#else /* !__LP64__ */ +typedef unsigned long __darwin_wctype_t; +#endif /* __LP64__ */ + +#ifdef __WCHAR_MAX__ +#define __DARWIN_WCHAR_MAX __WCHAR_MAX__ +#else /* ! __WCHAR_MAX__ */ +#define __DARWIN_WCHAR_MAX 0x7fffffff +#endif /* __WCHAR_MAX__ */ + +#if __DARWIN_WCHAR_MAX > 0xffffU +#define __DARWIN_WCHAR_MIN (-0x7fffffff - 1) +#else +#define __DARWIN_WCHAR_MIN 0 +#endif +#define __DARWIN_WEOF ((__darwin_wint_t)-1) + +#ifndef _FORTIFY_SOURCE +# if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && ((__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__-0) < 1050) +# define _FORTIFY_SOURCE 0 +# else +# define _FORTIFY_SOURCE 2 /* on by default */ +# endif +#endif + +#endif /* __TYPES_H_ */ Index: branches/azimutz/Cleancut/i386/include/stdint.h =================================================================== --- branches/azimutz/Cleancut/i386/include/stdint.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/stdint.h (revision 885) @@ -0,0 +1,253 @@ +/* + * Copyright (c) 2000, 2001, 2003, 2004, 2008 Apple Computer, Inc. + * All rights reserved. + */ + +#ifndef _STDINT_H_ +#define _STDINT_H_ + +#if __LP64__ +#define __WORDSIZE 64 +#else +#define __WORDSIZE 32 +#endif + +/* from ISO/IEC 988:1999 spec */ + +/* 7.18.1.1 Exact-width integer types */ +#ifndef _INT8_T +#define _INT8_T +typedef signed char int8_t; +#endif /*_INT8_T */ + +#ifndef _INT16_T +#define _INT16_T +typedef short int16_t; +#endif /* _INT16_T */ + +#ifndef _INT32_T +#define _INT32_T +typedef int int32_t; +#endif /* _INT32_T */ + +#ifndef _INT64_T +#define _INT64_T +typedef long long int64_t; +#endif /* _INT64_T */ + +#ifndef _UINT8_T +#define _UINT8_T +typedef unsigned char uint8_t; +#endif /*_UINT8_T */ + +#ifndef _UINT16_T +#define _UINT16_T +typedef unsigned short uint16_t; +#endif /* _UINT16_T */ + +#ifndef _UINT32_T +#define _UINT32_T +typedef unsigned int uint32_t; +#endif /* _UINT32_T */ + +#ifndef _UINT64_T +#define _UINT64_T +typedef unsigned long long uint64_t; +#endif /* _UINT64_T */ + +/* 7.18.1.2 Minimum-width integer types */ +typedef int8_t int_least8_t; +typedef int16_t int_least16_t; +typedef int32_t int_least32_t; +typedef int64_t int_least64_t; +typedef uint8_t uint_least8_t; +typedef uint16_t uint_least16_t; +typedef uint32_t uint_least32_t; +typedef uint64_t uint_least64_t; + + +/* 7.18.1.3 Fastest-width integer types */ +typedef int8_t int_fast8_t; +typedef int16_t int_fast16_t; +typedef int32_t int_fast32_t; +typedef int64_t int_fast64_t; +typedef uint8_t uint_fast8_t; +typedef uint16_t uint_fast16_t; +typedef uint32_t uint_fast32_t; +typedef uint64_t uint_fast64_t; + + +/* 7.18.1.4 Integer types capable of holding object pointers */ + +#ifndef _INTPTR_T +#define _INTPTR_T +typedef long intptr_t; +#endif /* _INTPTR_T */ + +#ifndef _UINTPTR_T +#define _UINTPTR_T +typedef unsigned long uintptr_t; +#endif /* _UINTPTR_T */ + + +/* 7.18.1.5 Greatest-width integer types */ +#ifndef _INTMAX_T +#define _INTMAX_T +#ifdef __INTMAX_TYPE__ +typedef __INTMAX_TYPE__ intmax_t; +#else /* __INTMAX_TYPE__ */ +typedef long long intmax_t; +#endif /* __INTMAX_TYPE__ */ +#endif /* _INTMAX_T */ + +#ifndef _UINTMAX_T +#define _UINTMAX_T +#ifdef __UINTMAX_TYPE__ +typedef __UINTMAX_TYPE__ uintmax_t; +#else /* __UINTMAX_TYPE__ */ +typedef unsigned long long uintmax_t; +#endif /* __UINTMAX_TYPE__ */ +#endif /* _UINTMAX_T */ + +/* 7.18.2 Limits of specified-width integer types: + * These #defines specify the minimum and maximum limits + * of each of the types declared above. + */ + + +/* 7.18.2.1 Limits of exact-width integer types */ +#define INT8_MAX 127 +#define INT16_MAX 32767 +#define INT32_MAX 2147483647 +#define INT64_MAX 9223372036854775807LL + +#define INT8_MIN -128 +#define INT16_MIN -32768 + /* + Note: the literal "most negative int" cannot be written in C -- + the rules in the standard (section 6.4.4.1 in C99) will give it + an unsigned type, so INT32_MIN (and the most negative member of + any larger signed type) must be written via a constant expression. + */ +#define INT32_MIN (-INT32_MAX-1) +#define INT64_MIN (-INT64_MAX-1) + +#define UINT8_MAX 255 +#define UINT16_MAX 65535 +#define UINT32_MAX 4294967295U +#define UINT64_MAX 18446744073709551615ULL + +/* 7.18.2.2 Limits of minimum-width integer types */ +#define INT_LEAST8_MIN INT8_MIN +#define INT_LEAST16_MIN INT16_MIN +#define INT_LEAST32_MIN INT32_MIN +#define INT_LEAST64_MIN INT64_MIN + +#define INT_LEAST8_MAX INT8_MAX +#define INT_LEAST16_MAX INT16_MAX +#define INT_LEAST32_MAX INT32_MAX +#define INT_LEAST64_MAX INT64_MAX + +#define UINT_LEAST8_MAX UINT8_MAX +#define UINT_LEAST16_MAX UINT16_MAX +#define UINT_LEAST32_MAX UINT32_MAX +#define UINT_LEAST64_MAX UINT64_MAX + +/* 7.18.2.3 Limits of fastest minimum-width integer types */ +#define INT_FAST8_MIN INT8_MIN +#define INT_FAST16_MIN INT16_MIN +#define INT_FAST32_MIN INT32_MIN +#define INT_FAST64_MIN INT64_MIN + +#define INT_FAST8_MAX INT8_MAX +#define INT_FAST16_MAX INT16_MAX +#define INT_FAST32_MAX INT32_MAX +#define INT_FAST64_MAX INT64_MAX + +#define UINT_FAST8_MAX UINT8_MAX +#define UINT_FAST16_MAX UINT16_MAX +#define UINT_FAST32_MAX UINT32_MAX +#define UINT_FAST64_MAX UINT64_MAX + +/* 7.18.2.4 Limits of integer types capable of holding object pointers */ + +#if __WORDSIZE == 64 +#define INTPTR_MIN INT64_MIN +#define INTPTR_MAX INT64_MAX +#else +#define INTPTR_MIN INT32_MIN +#define INTPTR_MAX INT32_MAX +#endif + +#if __WORDSIZE == 64 +#define UINTPTR_MAX UINT64_MAX +#else +#define UINTPTR_MAX UINT32_MAX +#endif + +/* 7.18.2.5 Limits of greatest-width integer types */ +#define INTMAX_MIN INT64_MIN +#define INTMAX_MAX INT64_MAX + +#define UINTMAX_MAX UINT64_MAX + +/* 7.18.3 "Other" */ +#if __WORDSIZE == 64 +#define PTRDIFF_MIN INT64_MIN +#define PTRDIFF_MAX INT64_MAX +#else +#define PTRDIFF_MIN INT32_MIN +#define PTRDIFF_MAX INT32_MAX +#endif + +/* We have no sig_atomic_t yet, so no SIG_ATOMIC_{MIN,MAX}. + Should end up being {-127,127} or {0,255} ... or bigger. + My bet would be on one of {U}INT32_{MIN,MAX}. */ + +#if __WORDSIZE == 64 +#define SIZE_MAX UINT64_MAX +#else +#define SIZE_MAX UINT32_MAX +#endif + +#ifndef WCHAR_MAX +# ifdef __WCHAR_MAX__ +# define WCHAR_MAX __WCHAR_MAX__ +# else +# define WCHAR_MAX 0x7fffffff +# endif +#endif + +/* WCHAR_MIN should be 0 if wchar_t is an unsigned type and + (-WCHAR_MAX-1) if wchar_t is a signed type. Unfortunately, + it turns out that -fshort-wchar changes the signedness of + the type. */ +#ifndef WCHAR_MIN +# if WCHAR_MAX == 0xffff +# define WCHAR_MIN 0 +# else +# define WCHAR_MIN (-WCHAR_MAX-1) +# endif +#endif + +#define WINT_MIN INT32_MIN +#define WINT_MAX INT32_MAX + +#define SIG_ATOMIC_MIN INT32_MIN +#define SIG_ATOMIC_MAX INT32_MAX + +/* 7.18.4 Macros for integer constants */ +#define INT8_C(v) (v) +#define INT16_C(v) (v) +#define INT32_C(v) (v) +#define INT64_C(v) (v ## LL) + +#define UINT8_C(v) (v ## U) +#define UINT16_C(v) (v ## U) +#define UINT32_C(v) (v ## U) +#define UINT64_C(v) (v ## ULL) + +#define INTMAX_C(v) (v ## LL) +#define UINTMAX_C(v) (v ## ULL) + +#endif /* _STDINT_H_ */ Index: branches/azimutz/Cleancut/i386/include/float.h =================================================================== --- branches/azimutz/Cleancut/i386/include/float.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/float.h (revision 885) @@ -0,0 +1,281 @@ +/* This file exists soley to keep Metrowerks' compilers happy. The version + used by GCC can be found in /usr/lib/gcc, although it's + not very informative. */ + +#ifndef _FLOAT_H_ + +#if defined(__GNUC__) +#include_next <float.h> + +#elif defined(__MWERKS__) +#define _FLOAT_H_ + +/* APPLE LOCAL begin MW compatibility */ +/* Define various characteristics of floating-point types, if needed. */ +#ifndef __FLT_RADIX__ +#define __FLT_RADIX__ 2 +#endif +#ifndef __FLT_MANT_DIG__ +#define __FLT_MANT_DIG__ 24 +#endif +#ifndef __FLT_DIG__ +#define __FLT_DIG__ 6 +#endif +#ifndef __FLT_EPSILON__ +#define __FLT_EPSILON__ 1.19209290e-07F +#endif +#ifndef __FLT_MIN__ +#define __FLT_MIN__ 1.17549435e-38F +#endif +#ifndef __FLT_MAX__ +#define __FLT_MAX__ 3.40282347e+38F +#endif +#ifndef __FLT_MIN_EXP__ +#define __FLT_MIN_EXP__ (-125) +#endif +#ifndef __FLT_MIN_10_EXP__ +#define __FLT_MIN_10_EXP__ (-37) +#endif +#ifndef __FLT_MAX_EXP__ +#define __FLT_MAX_EXP__ 128 +#endif +#ifndef __FLT_MAX_10_EXP__ +#define __FLT_MAX_10_EXP__ 38 +#endif +#ifndef __DBL_MANT_DIG__ +#define __DBL_MANT_DIG__ 53 +#endif +#ifndef __DBL_DIG__ +#define __DBL_DIG__ 15 +#endif +#ifndef __DBL_EPSILON__ +#define __DBL_EPSILON__ 2.2204460492503131e-16 +#endif +#ifndef __DBL_MIN__ +#define __DBL_MIN__ 2.2250738585072014e-308 +#endif +#ifndef __DBL_MAX__ +#define __DBL_MAX__ 1.7976931348623157e+308 +#endif +#ifndef __DBL_MIN_EXP__ +#define __DBL_MIN_EXP__ (-1021) +#endif +#ifndef __DBL_MIN_10_EXP__ +#define __DBL_MIN_10_EXP__ (-307) +#endif +#ifndef __DBL_MAX_EXP__ +#define __DBL_MAX_EXP__ 1024 +#endif +#ifndef __DBL_MAX_10_EXP__ +#define __DBL_MAX_10_EXP__ 308 +#endif +#ifndef __LDBL_MANT_DIG__ +#define __LDBL_MANT_DIG__ 53 +#endif +#ifndef __LDBL_DIG__ +#define __LDBL_DIG__ 15 +#endif +#ifndef __LDBL_EPSILON__ +#define __LDBL_EPSILON__ 2.2204460492503131e-16 +#endif +#ifndef __LDBL_MIN__ +#define __LDBL_MIN__ 2.2250738585072014e-308 +#endif +#ifndef __LDBL_MAX__ +#define __LDBL_MAX__ 1.7976931348623157e+308 +#endif +#ifndef __LDBL_MIN_EXP__ +#define __LDBL_MIN_EXP__ (-1021) +#endif +#ifndef __LDBL_MIN_10_EXP__ +#define __LDBL_MIN_10_EXP__ (-307) +#endif +#ifndef __LDBL_MAX_EXP__ +#define __LDBL_MAX_EXP__ 1024 +#endif +#ifndef __LDBL_MAX_10_EXP__ +#define __LDBL_MAX_10_EXP__ 308 +#endif +/* APPLE LOCAl end MW compatibility */ + +/* Copyright (C) 2002 Free Software Foundation, Inc. + +This file is part of GNU CC. + +GNU CC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +/* As a special exception, if you include this header file into source + files compiled by GCC, this header file does not by itself cause + the resulting executable to be covered by the GNU General Public + License. This exception does not however invalidate any other + reasons why the executable file might be covered by the GNU General + Public License. */ + +/* + * ISO C Standard: 5.2.4.2.2 Characteristics of floating types <float.h> + */ + + +/* Radix of exponent representation, b. */ +#undef FLT_RADIX +#define FLT_RADIX __FLT_RADIX__ + +/* Number of base-FLT_RADIX digits in the significand, p. */ +#undef FLT_MANT_DIG +#undef DBL_MANT_DIG +#undef LDBL_MANT_DIG +#define FLT_MANT_DIG __FLT_MANT_DIG__ +#define DBL_MANT_DIG __DBL_MANT_DIG__ +#define LDBL_MANT_DIG __LDBL_MANT_DIG__ + +/* Number of decimal digits, q, such that any floating-point number with q + decimal digits can be rounded into a floating-point number with p radix b + digits and back again without change to the q decimal digits, + + p * log10(b) if b is a power of 10 + floor((p - 1) * log10(b)) otherwise +*/ +#undef FLT_DIG +#undef DBL_DIG +#undef LDBL_DIG +#define FLT_DIG __FLT_DIG__ +#define DBL_DIG __DBL_DIG__ +#define LDBL_DIG __LDBL_DIG__ + +/* Minimum int x such that FLT_RADIX**(x-1) is a normalized float, emin */ +#undef FLT_MIN_EXP +#undef DBL_MIN_EXP +#undef LDBL_MIN_EXP +#define FLT_MIN_EXP __FLT_MIN_EXP__ +#define DBL_MIN_EXP __DBL_MIN_EXP__ +#define LDBL_MIN_EXP __LDBL_MIN_EXP__ + +/* Minimum negative integer such that 10 raised to that power is in the + range of normalized floating-point numbers, + + ceil(log10(b) * (emin - 1)) +*/ +#undef FLT_MIN_10_EXP +#undef DBL_MIN_10_EXP +#undef LDBL_MIN_10_EXP +#define FLT_MIN_10_EXP __FLT_MIN_10_EXP__ +#define DBL_MIN_10_EXP __DBL_MIN_10_EXP__ +#define LDBL_MIN_10_EXP __LDBL_MIN_10_EXP__ + +/* Maximum int x such that FLT_RADIX**(x-1) is a representable float, emax. */ +#undef FLT_MAX_EXP +#undef DBL_MAX_EXP +#undef LDBL_MAX_EXP +#define FLT_MAX_EXP __FLT_MAX_EXP__ +#define DBL_MAX_EXP __DBL_MAX_EXP__ +#define LDBL_MAX_EXP __LDBL_MAX_EXP__ + +/* Maximum integer such that 10 raised to that power is in the range of + representable finite floating-point numbers, + + floor(log10((1 - b**-p) * b**emax)) +*/ +#undef FLT_MAX_10_EXP +#undef DBL_MAX_10_EXP +#undef LDBL_MAX_10_EXP +#define FLT_MAX_10_EXP __FLT_MAX_10_EXP__ +#define DBL_MAX_10_EXP __DBL_MAX_10_EXP__ +#define LDBL_MAX_10_EXP __LDBL_MAX_10_EXP__ + +/* Maximum representable finite floating-point number, + + (1 - b**-p) * b**emax +*/ +#undef FLT_MAX +#undef DBL_MAX +#undef LDBL_MAX +#define FLT_MAX __FLT_MAX__ +#define DBL_MAX __DBL_MAX__ +#define LDBL_MAX __LDBL_MAX__ + +/* The difference between 1 and the least value greater than 1 that is + representable in the given floating point type, b**1-p. */ +#undef FLT_EPSILON +#undef DBL_EPSILON +#undef LDBL_EPSILON +#define FLT_EPSILON __FLT_EPSILON__ +#define DBL_EPSILON __DBL_EPSILON__ +#define LDBL_EPSILON __LDBL_EPSILON__ + +/* Minimum normalized positive floating-point number, b**(emin - 1). */ +#undef FLT_MIN +#undef DBL_MIN +#undef LDBL_MIN +#define FLT_MIN __FLT_MIN__ +#define DBL_MIN __DBL_MIN__ +#define LDBL_MIN __LDBL_MIN__ + +/* Addition rounds to 0: zero, 1: nearest, 2: +inf, 3: -inf, -1: unknown. */ +/* ??? This is supposed to change with calls to fesetround in <fenv.h>. */ +#undef FLT_ROUNDS +#define FLT_ROUNDS 1 + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +/* The floating-point expression evaluation method. + -1 indeterminate + 0 evaluate all operations and constants just to the range and + precision of the type + 1 evaluate operations and constants of type float and double + to the range and precision of the double type, evaluate + long double operations and constants to the range and + precision of the long double type + 2 evaluate all operations and constants to the range and + precision of the long double type + + ??? This ought to change with the setting of the fp control word; + the value provided by the compiler assumes the widest setting. */ +#undef FLT_EVAL_METHOD +#define FLT_EVAL_METHOD __FLT_EVAL_METHOD__ + +/* Number of decimal digits, n, such that any floating-point number in the + widest supported floating type with pmax radix b digits can be rounded + to a floating-point number with n decimal digits and back again without + change to the value, + + pmax * log10(b) if b is a power of 10 + ceil(1 + pmax * log10(b)) otherwise +*/ +#undef DECIMAL_DIG +#define DECIMAL_DIG __DECIMAL_DIG__ + +#endif /* C99 */ + +#ifdef __cplusplus +extern "C" { +#endif +extern int __fegetfltrounds( void ); +#ifdef __cplusplus +} +#endif +#undef FLT_ROUNDS +#define FLT_ROUNDS (__fegetfltrounds ()) +/* End of GNU CC file */ + +/* APPLE LOCAL begin CW compatibility */ +/* CodeWarrior defines the following on its own. */ +#undef DECIMAL_DIG +/* APPLE LOCAL end CW compatibility */ + +#else +#error This file is only for Metrowerks compatibilty. +#endif + +#endif /* _FLOAT_H_ */ Index: branches/azimutz/Cleancut/i386/include/string.h =================================================================== --- branches/azimutz/Cleancut/i386/include/string.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/string.h (revision 885) @@ -0,0 +1,154 @@ +/* + * Copyright (c) 2000, 2007 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@ + */ +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)string.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _STRING_H_ +#define _STRING_H_ +#include <_types.h> + +#ifndef _SIZE_T +#define _SIZE_T +typedef __darwin_size_t size_t; +#endif + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) /* For swab */ +#ifndef _SSIZE_T +#define _SSIZE_T +typedef __darwin_ssize_t ssize_t; +#endif +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + +#ifndef NULL +#define NULL __DARWIN_NULL +#endif /* ! NULL */ + +#include <sys/cdefs.h> + +__BEGIN_DECLS +void *memchr(const void *, int, size_t); +int memcmp(const void *, const void *, size_t); +void *memcpy(void *, const void *, size_t); +void *memmove(void *, const void *, size_t); +void *memset(void *, int, size_t); +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +char *stpcpy(char *, const char *); +char *strcasestr(const char *, const char *); +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ +char *strcat(char *, const char *); +char *strchr(const char *, int); +int strcmp(const char *, const char *); +int strcoll(const char *, const char *); +char *strcpy(char *, const char *); +size_t strcspn(const char *, const char *); +//Begin-Libc +#ifndef LIBC_ALIAS_STRERROR +//End-Libc +char *strerror(int) __DARWIN_ALIAS(strerror); +//Begin-Libc +#else /* LIBC_ALIAS_STRERROR */ +char *strerror(int) LIBC_ALIAS(strerror); +#endif /* !LIBC_ALIAS_STRERROR */ +//End-Libc +int strerror_r(int, char *, size_t); +size_t strlen(const char *); +char *strncat(char *, const char *, size_t); +int strncmp(const char *, const char *, size_t); +char *strncpy(char *, const char *, size_t); +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +char *strnstr(const char *, const char *, size_t); +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ +char *strpbrk(const char *, const char *); +char *strrchr(const char *, int); +size_t strspn(const char *, const char *); +char *strstr(const char *, const char *); +char *strtok(char *, const char *); +size_t strxfrm(char *, const char *, size_t); + +/* Nonstandard routines */ +#ifndef _ANSI_SOURCE +void *memccpy(void *, const void *, int, size_t); +char *strtok_r(char *, const char *, char **); +char *strdup(const char *); +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +int bcmp(const void *, const void *, size_t); +void bcopy(const void *, void *, size_t); +void bzero(void *, size_t); +int ffs(int); +int ffsl(long); +int fls(int); +int flsl(long); +char *index(const char *, int); +void memset_pattern4(void *, const void *, size_t); +void memset_pattern8(void *, const void *, size_t); +void memset_pattern16(void *, const void *, size_t); +char *rindex(const char *, int); +int strcasecmp(const char *, const char *); +size_t strlcat(char *, const char *, size_t); +size_t strlcpy(char *, const char *, size_t); +void strmode(int, char *); +int strncasecmp(const char *, const char *, size_t); +char *strsep(char **, const char *); +char *strsignal(int sig); +void swab(const void * __restrict, void * __restrict, ssize_t); +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ +#endif /* !_ANSI_SOURCE */ +__END_DECLS + +#ifdef _USE_EXTENDED_LOCALES_ +#include <xlocale/_string.h> +#endif /* _USE_EXTENDED_LOCALES_ */ + +#endif /* _STRING_H_ */ Index: branches/azimutz/Cleancut/i386/include/_structs.h =================================================================== --- branches/azimutz/Cleancut/i386/include/_structs.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/_structs.h (revision 885) @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2004 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@ + */ + +#include <sys/_structs.h> + Index: branches/azimutz/Cleancut/i386/include/ufs/ufs/dir.h =================================================================== --- branches/azimutz/Cleancut/i386/include/ufs/ufs/dir.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/ufs/ufs/dir.h (revision 885) @@ -0,0 +1,190 @@ +/* + * Copyright (c) 2000-2008 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) 1995 NeXT Computer, Inc. All Rights Reserved */ +/* + * Copyright (c) 1982, 1986, 1989, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)dir.h 8.5 (Berkeley) 4/27/95 + */ + +#ifndef _DIR_H_ +#define _DIR_H_ + +#ifdef __APPLE_API_UNSTABLE +/* + * Theoretically, directories can be more than 2Gb in length, however, in + * practice this seems unlikely. So, we define the type doff_t as a 32-bit + * quantity to keep down the cost of doing lookup on a 32-bit machine. + */ +#define doff_t int32_t +#define MAXDIRSIZE (0x7fffffff) + +/* + * A directory consists of some number of blocks of DIRBLKSIZ + * bytes, where DIRBLKSIZ is chosen such that it can be transferred + * to disk in a single atomic operation (e.g. 512 bytes on most machines). + * + * Each DIRBLKSIZ byte block contains some number of directory entry + * structures, which are of variable length. Each directory entry has + * a struct direct at the front of it, containing its inode number, + * the length of the entry, and the length of the name contained in + * the entry. These are followed by the name padded to a 4 byte boundary + * with null bytes. All names are guaranteed null terminated. + * The maximum length of a name in a directory is UFSMAXNAMLEN. + * + * The macro DIRSIZ(fmt, dp) gives the amount of space required to represent + * a directory entry. Free space in a directory is represented by + * entries which have dp->d_reclen > DIRSIZ(fmt, dp). All DIRBLKSIZ bytes + * in a directory block are claimed by the directory entries. This + * usually results in the last entry in a directory having a large + * dp->d_reclen. When entries are deleted from a directory, the + * space is returned to the previous entry in the same directory + * block by increasing its dp->d_reclen. If the first entry of + * a directory block is free, then its dp->d_ino is set to 0. + * Entries other than the first in a directory do not normally have + * dp->d_ino set to 0. + */ +#ifdef __APPLE__ +#define DIRBLKSIZ 1024 +#else +#define DIRBLKSIZ DEV_BSIZE +#endif +#define UFSMAXNAMLEN 255 + +struct direct { + u_int32_t d_ino; /* inode number of entry */ + u_int16_t d_reclen; /* length of this record */ + u_int8_t d_type; /* file type, see below */ + u_int8_t d_namlen; /* length of string in d_name */ + char d_name[UFSMAXNAMLEN + 1];/* name with length <= UFSMAXNAMLEN */ +} __attribute__((packed,aligned(4))); + +/* + * File types + */ +#define DT_UNKNOWN 0 +#define DT_FIFO 1 +#define DT_CHR 2 +#define DT_DIR 4 +#define DT_BLK 6 +#define DT_REG 8 +#define DT_LNK 10 +#define DT_SOCK 12 +#define DT_WHT 14 + +/* + * Convert between stat structure types and directory types. + */ +#define IFTODT(mode) (((mode) & 0170000) >> 12) +#define DTTOIF(dirtype) ((dirtype) << 12) + +/* + * The DIRSIZ macro gives the minimum record length which will hold + * the directory entry. This requires the amount of space in struct direct + * without the d_name field, plus enough space for the name with a terminating + * null byte (dp->d_namlen+1), rounded up to a 4 byte boundary. + */ +#if (BYTE_ORDER == LITTLE_ENDIAN) +#define DIRSIZ(oldfmt, dp) \ + ((oldfmt) ? \ + ((sizeof(struct direct) - (UFSMAXNAMLEN+1)) + (((dp)->d_type+1 + 3) &~ 3)) : \ + ((sizeof(struct direct) - (UFSMAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3))) +#else +#define DIRSIZ(oldfmt, dp) \ + ((sizeof(struct direct) - (UFSMAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3)) +#endif +#define OLDDIRFMT 1 +#define NEWDIRFMT 0 + +/* + * Template for manipulating directories. Should use struct direct's, + * but the name field is UFSMAXNAMLEN - 1, and this just won't do. + */ +struct dirtemplate { + u_int32_t dot_ino; + int16_t dot_reclen; + u_int8_t dot_type; + u_int8_t dot_namlen; + char dot_name[4]; /* must be multiple of 4 */ + u_int32_t dotdot_ino; + int16_t dotdot_reclen; + u_int8_t dotdot_type; + u_int8_t dotdot_namlen; + char dotdot_name[4]; /* ditto */ +} __attribute__((packed,aligned(4))); + +/* + * This is the old format of directories, sanz type element. + */ +struct odirtemplate { + u_int32_t dot_ino; + int16_t dot_reclen; + u_int16_t dot_namlen; + char dot_name[4]; /* must be multiple of 4 */ + u_int32_t dotdot_ino; + int16_t dotdot_reclen; + u_int16_t dotdot_namlen; + char dotdot_name[4]; /* ditto */ +} __attribute__((packed,aligned(4))); + +#endif /* __APPLE_API_UNSTABLE */ +#endif /* !_DIR_H_ */ Index: branches/azimutz/Cleancut/i386/include/ufs/ufs/inode.h =================================================================== --- branches/azimutz/Cleancut/i386/include/ufs/ufs/inode.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/ufs/ufs/inode.h (revision 885) @@ -0,0 +1,160 @@ +/* + * Copyright (c) 2000-2008 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) 1995 NeXT Computer, Inc. All Rights Reserved */ +/* + * Copyright (c) 1982, 1989, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)inode.h 8.9 (Berkeley) 5/14/95 + */ +#ifndef _UFS_INDOE_H_ +#define _UFS_INDOE_H_ + +#include <sys/appleapiopts.h> + +#ifdef __APPLE_API_PRIVATE +#include <ufs/ufs/dir.h> +#include <ufs/ufs/dinode.h> +#include <sys/queue.h> +#include <sys/event.h> +#include <sys/lock.h> +#include <sys/quota.h> + +/* + * The inode is used to describe each active (or recently active) file in the + * UFS filesystem. It is composed of two types of information. The first part + * is the information that is needed only while the file is active (such as + * the identity of the file and linkage to speed its lookup). The second part + * is * the permanent meta-data associated with the file which is read in + * from the permanent dinode from long term storage when the file becomes + * active, and is put back when the file is no longer being used. + */ +struct inode { + LIST_ENTRY(inode) i_hash;/* Hash chain. */ + struct vnode *i_vnode;/* Vnode associated with this inode. */ + struct vnode *i_devvp;/* Vnode for block I/O. */ + u_int32_t i_flag; /* flags, see below */ + dev_t i_dev; /* Device associated with the inode. */ + ino_t i_number; /* The identity of the inode. */ + + union { /* Associated filesystem. */ + struct fs *fs; /* FFS */ + } inode_u; +#define i_fs inode_u.fs + + struct dquot *i_dquot[MAXQUOTAS]; /* Dquot structures. */ + u_quad_t i_modrev; /* Revision level for NFS lease. */ + void *i_lockf; /* DEPRECATED */ + + /* + * Side effects; used during directory lookup. + */ + int32_t i_count; /* Size of free slot in directory. */ + doff_t i_endoff; /* End of useful stuff in directory. */ + doff_t i_diroff; /* Offset in dir, where we found last entry. */ + doff_t i_offset; /* Offset of free space in directory. */ + ino_t i_ino; /* Inode number of found directory. */ + u_int32_t i_reclen; /* Size of found directory entry. */ + daddr_t i_lastr; /* last read... read-ahead */ + /* + * The on-disk dinode itself. + */ + struct dinode i_din; /* 128 bytes of the on-disk dinode. */ +}; + +#define i_atime i_din.di_atime +#define i_atimensec i_din.di_atimensec +#define i_blocks i_din.di_blocks +#define i_ctime i_din.di_ctime +#define i_ctimensec i_din.di_ctimensec +#define i_db i_din.di_db +#define i_flags i_din.di_flags +#define i_gen i_din.di_gen +#define i_gid i_din.di_gid +#define i_ib i_din.di_ib +#define i_mode i_din.di_mode +#define i_mtime i_din.di_mtime +#define i_mtimensec i_din.di_mtimensec +#define i_nlink i_din.di_nlink +#define i_rdev i_din.di_rdev +#define i_shortlink i_din.di_shortlink +#define i_size i_din.di_size +#define i_uid i_din.di_uid +#define i_spare i_din.di_spare +#define i_oldids i_din.di_u.oldids +#define i_inumber i_din.di_u.inumber + +/* These flags are kept in i_flag. */ +#define IN_ACCESS 0x0001 /* Access time update request. */ +#define IN_CHANGE 0x0002 /* Inode change time update request. */ +#define IN_UPDATE 0x0004 /* Modification time update request. */ +#define IN_MODIFIED 0x0008 /* Inode has been modified. */ +#define IN_RENAME 0x0010 /* Inode is being renamed. */ +#define IN_SHLOCK 0x0020 /* File has shared lock. */ +#define IN_EXLOCK 0x0040 /* File has exclusive lock. */ +#define IN_TRANSIT 0x0080 /* inode is getting recycled */ +#define IN_WTRANSIT 0x0100 /* waiting for inode getting recycled */ +#define IN_ALLOC 0x0200 /* being allocated */ +#define IN_WALLOC 0x0400 /* waiting for allocation to be done */ + + +#endif /* __APPLE_API_PRIVATE */ +#endif /* ! _UFS_INDOE_H_ */ Index: branches/azimutz/Cleancut/i386/include/ufs/ufs/ufsmount.h =================================================================== --- branches/azimutz/Cleancut/i386/include/ufs/ufs/ufsmount.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/ufs/ufs/ufsmount.h (revision 885) @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2000-2008 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) 1995 NeXT Computer, Inc. All Rights Reserved */ +/* + * Copyright (c) 1982, 1986, 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)ufsmount.h 8.6 (Berkeley) 3/30/95 + */ +#ifndef _UFS_UFSMOUNT_H_ +#define _UFS_UFSMOUNT_H_ + +#include <sys/appleapiopts.h> +#include <sys/quota.h> + +#ifdef __APPLE_API_UNSTABLE +/* + * Arguments to mount UFS-based filesystems + */ +struct ufs_args { + char *fspec; /* block special device to mount */ +}; +#endif /* __APPLE_API_UNSTABLE */ + +#ifdef __APPLE_API_OBSOLETE +#if MFS +/* + * Arguments to mount MFS + */ +struct mfs_args { + char *fspec; /* name to export for statfs */ + caddr_t base; /* base of file system in memory */ + uint32_t size; /* size of file system */ +}; +#endif /* MFS */ +#endif /* __APPLE_API_OBSOLETE */ + + +#endif /* ! _UFS_UFSMOUNT_H_ */ Index: branches/azimutz/Cleancut/i386/include/ufs/ufs/dinode.h =================================================================== --- branches/azimutz/Cleancut/i386/include/ufs/ufs/dinode.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/ufs/ufs/dinode.h (revision 885) @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2000-2008 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) 1995 NeXT Computer, Inc. All Rights Reserved */ +/* + * Copyright (c) 1982, 1989, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)dinode.h 8.9 (Berkeley) 3/29/95 + */ +#ifndef _UFS_DINODE_H_ +#define _UFS_DINODE_H_ + + +#ifdef __APPLE_API_UNSTABLE +/* + * The root inode is the root of the file system. Inode 0 can't be used for + * normal purposes and historically bad blocks were linked to inode 1, thus + * the root inode is 2. (Inode 1 is no longer used for this purpose, however + * numerous dump tapes make this assumption, so we are stuck with it). + */ +#define ROOTINO ((ino_t)2) + +/* + * The Whiteout inode# is a dummy non-zero inode number which will + * never be allocated to a real file. It is used as a place holder + * in the directory entry which has been tagged as a DT_W entry. + * See the comments about ROOTINO above. + */ +#define WINO ((ino_t)1) + +/* + * A dinode contains all the meta-data associated with a UFS file. + * This structure defines the on-disk format of a dinode. Since + * this structure describes an on-disk structure, all its fields + * are defined by types with precise widths. + */ + +#define NDADDR 12 /* Direct addresses in inode. */ +#define NIADDR 3 /* Indirect addresses in inode. */ + +typedef int32_t ufs_daddr_t; + +struct dinode { + u_int16_t di_mode; /* 0: IFMT, permissions; see below. */ + int16_t di_nlink; /* 2: File link count. */ + union { + u_int16_t oldids[2]; /* 4: Ffs: old user and group ids. */ + int32_t inumber; /* 4: Lfs: inode number. */ + } di_u; + u_int64_t di_size; /* 8: File byte count. */ + int32_t di_atime; /* 16: Last access time. */ + int32_t di_atimensec; /* 20: Last access time. */ + int32_t di_mtime; /* 24: Last modified time. */ + int32_t di_mtimensec; /* 28: Last modified time. */ + int32_t di_ctime; /* 32: Last inode change time. */ + int32_t di_ctimensec; /* 36: Last inode change time. */ + ufs_daddr_t di_db[NDADDR]; /* 40: Direct disk blocks. */ + ufs_daddr_t di_ib[NIADDR]; /* 88: Indirect disk blocks. */ + u_int32_t di_flags; /* 100: Status flags (chflags). */ + u_int32_t di_blocks; /* 104: Blocks actually held. */ + int32_t di_gen; /* 108: Generation number. */ + u_int32_t di_uid; /* 112: File owner. */ + u_int32_t di_gid; /* 116: File group. */ + int32_t di_spare[2]; /* 120: Reserved; currently unused */ +} __attribute__((packed,aligned(4))); + +/* + * The di_db fields may be overlaid with other information for + * file types that do not have associated disk storage. Block + * and character devices overlay the first data block with their + * dev_t value. Short symbolic links place their path in the + * di_db area. + */ +#define di_inumber di_u.inumber +#define di_ogid di_u.oldids[1] +#define di_ouid di_u.oldids[0] +#define di_rdev di_db[0] +#define di_shortlink di_db +#define MAXSYMLINKLEN ((NDADDR + NIADDR) * sizeof(ufs_daddr_t)) + +/* File permissions. */ +#define IEXEC 0000100 /* Executable. */ +#define IWRITE 0000200 /* Writeable. */ +#define IREAD 0000400 /* Readable. */ +#define ISVTX 0001000 /* Sticky bit. */ +#define ISGID 0002000 /* Set-gid. */ +#define ISUID 0004000 /* Set-uid. */ + +/* File types. */ +#define IFMT 0170000 /* Mask of file type. */ +#define IFIFO 0010000 /* Named pipe (fifo). */ +#define IFCHR 0020000 /* Character device. */ +#define IFDIR 0040000 /* Directory file. */ +#define IFBLK 0060000 /* Block device. */ +#define IFREG 0100000 /* Regular file. */ +#define IFLNK 0120000 /* Symbolic link. */ +#define IFSOCK 0140000 /* UNIX domain socket. */ +#define IFWHT 0160000 /* Whiteout. */ + +#endif /* __APPLE_API_UNSTABLE */ +#endif /* ! _UFS_DINODE_H_ */ Index: branches/azimutz/Cleancut/i386/include/ufs/ufs/ufs_extern.h =================================================================== --- branches/azimutz/Cleancut/i386/include/ufs/ufs/ufs_extern.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/ufs/ufs/ufs_extern.h (revision 885) @@ -0,0 +1,165 @@ +/* + * Copyright (c) 2000-2008 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) 1995 NeXT Computer, Inc. All Rights Reserved */ +/*- + * Copyright (c) 1991, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)ufs_extern.h 8.10 (Berkeley) 5/14/95 + */ +#ifndef _UFS_EXTERN_H_ +#define _UFS_EXTERN_H_ + +#include <sys/appleapiopts.h> + +#ifdef __APPLE_API_PRIVATE +struct buf; +struct direct; +struct disklabel; +struct flock; +struct inode; +struct mbuf; +struct mount; +struct nameidata; +struct proc; +#ifndef _KAUTH_CRED_T +#define _KAUTH_CRED_T +struct ucred; +typedef struct ucred *kauth_cred_t; +#endif /* !_KAUTH_CRED_T */ +struct ufs_args; +struct uio; +struct vnode_attr; +struct vfsconf; +struct vnode; + +__BEGIN_DECLS +int ufs_remove_internal(vnode_t, vnode_t, struct componentname *, int); +int ufs_access_internal(vnode_t, mode_t, kauth_cred_t); + +int ffs_read_internal(vnode_t, struct uio *, int, int); +int ffs_write_internal(vnode_t, struct uio *, int, kauth_cred_t); +int ffs_truncate_internal(vnode_t, off_t, int, kauth_cred_t); + +void diskerr + (struct buf *, char *, char *, int, int, struct disklabel *); +void disksort(struct buf *, struct buf *); +u_int dkcksum(struct disklabel *); +char *readdisklabel(dev_t, int (*)(), struct disklabel *); +int setdisklabel(struct disklabel *, struct disklabel *, u_int32_t); +int writedisklabel(dev_t, int (*)(), struct disklabel *); + +int ufs_access(struct vnop_access_args *); +int ufs_checkpath(struct inode *, struct inode *, kauth_cred_t); +int ufs_close(struct vnop_close_args *); +int ufs_create(struct vnop_create_args *); +void ufs_dirbad(struct inode *, doff_t, const char *); +int ufs_dirbadentry(struct vnode *, struct direct *, int); +int ufs_dirempty(struct inode *, ino_t, kauth_cred_t); +int ufs_direnter(struct inode *, struct vnode *,struct componentname *); +int ufs_dirremove(struct vnode *, struct componentname*); +int ufs_dirrewrite + (struct inode *, struct inode *, struct componentname *); +int ufs_getattr(struct vnop_getattr_args *); +int ufs_getlbns(struct vnode *, ufs_daddr_t, struct indir *, int *); +struct vnode * + ufs_ihashget(dev_t, ino_t); +void ufs_ihashinit(void); +void ufs_ihashins(struct inode *); +struct vnode * + ufs_ihashlookup(dev_t, ino_t); +void ufs_ihashrem(struct inode *); +int ufs_inactive(struct vnop_inactive_args *); +int ufs_init(struct vfsconf *); +int ufs_ioctl(struct vnop_ioctl_args *); +int ufs_link(struct vnop_link_args *); +int ufs_lookup(struct vnop_lookup_args *); +int ufs_makeinode(struct vnode_attr *, struct vnode *, struct vnode **, struct componentname *); +int ufs_mkdir(struct vnop_mkdir_args *); +int ufs_mknod(struct vnop_mknod_args *); +int ufs_mmap(struct vnop_mmap_args *); +int ufs_open(struct vnop_open_args *); +int ufs_pathconf(struct vnop_pathconf_args *); +int ufs_readdir(struct vnop_readdir_args *); +int ufs_readlink(struct vnop_readlink_args *); +int ufs_reclaim(struct vnode *, struct proc *); +int ufs_remove(struct vnop_remove_args *); +int ufs_rename(struct vnop_rename_args *); +#define ufs_revoke nop_revoke +int ufs_rmdir(struct vnop_rmdir_args *); +int ufs_root(struct mount *, struct vnode **, vfs_context_t); +int ufs_select(struct vnop_select_args *); +int ufs_setattr(struct vnop_setattr_args *); +int ufs_start(struct mount *, int, vfs_context_t); +int ufs_strategy(struct vnop_strategy_args *); +int ufs_symlink(struct vnop_symlink_args *); +int ufs_whiteout(struct vnop_whiteout_args *); +int ufsspec_close(struct vnop_close_args *); +int ufsspec_read(struct vnop_read_args *); +int ufsspec_write(struct vnop_write_args *); + +#if FIFO +int ufsfifo_read(struct vnop_read_args *); +int ufsfifo_write(struct vnop_write_args *); +int ufsfifo_close(struct vnop_close_args *); +#endif +int ufs_blktooff(struct vnop_blktooff_args *); +int ufs_blockmap(struct vnop_blockmap_args *); + +__END_DECLS + +#endif /* __APPLE_API_PRIVATE */ +#endif /* ! _UFS_EXTERN_H_ */ Index: branches/azimutz/Cleancut/i386/include/ufs/ffs/ffs_extern.h =================================================================== --- branches/azimutz/Cleancut/i386/include/ufs/ffs/ffs_extern.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/ufs/ffs/ffs_extern.h (revision 885) @@ -0,0 +1,162 @@ +/* + * Copyright (c) 2000-2008 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) 1995 NeXT Computer, Inc. All Rights Reserved */ + +/*- + * Copyright (c) 1991, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)ffs_extern.h 8.6 (Berkeley) 3/30/95 + */ +#ifndef __UFS_FFS_FFS_EXTERN_H__ +#define __UFS_FFS_FFS_EXTERN_H__ + +#include <sys/appleapiopts.h> + +#ifdef __APPLE_API_UNSTABLE +/* + * Sysctl values for the fast filesystem. + */ +#define FFS_CLUSTERREAD 1 /* cluster reading enabled */ +#define FFS_CLUSTERWRITE 2 /* cluster writing enabled */ +#define FFS_REALLOCBLKS 3 /* block reallocation enabled */ +#define FFS_ASYNCFREE 4 /* asynchronous block freeing enabled */ +#define FFS_MAXID 5 /* number of valid ffs ids */ + +#define FFS_NAMES { \ + { 0, 0 }, \ + { "doclusterread", CTLTYPE_INT }, \ + { "doclusterwrite", CTLTYPE_INT }, \ + { "doreallocblks", CTLTYPE_INT }, \ + { "doasyncfree", CTLTYPE_INT }, \ +} +#endif /* __APPLE_API_UNSTABLE */ + +struct buf; +struct fs; +struct inode; +struct mount; +struct nameidata; +struct proc; +struct vfsstatfs; +struct timeval; +#ifndef _KAUTH_CRED_T +#define _KAUTH_CRED_T +struct ucred; +typedef struct ucred *kauth_cred_t; +#endif /* !_KAUTH_CRED_T */ +struct uio; +struct vnode; +struct mbuf; +struct vfsconf; + +#ifdef __APPLE_API_PRIVATE +__BEGIN_DECLS +int ffs_fsync_internal(vnode_t, int); + +int ffs_blkatoff(vnode_t, off_t, char **, buf_t *); + +int ffs_alloc(struct inode *, + ufs_daddr_t, ufs_daddr_t, int, kauth_cred_t, ufs_daddr_t *); +int ffs_balloc(struct inode *, + ufs_daddr_t, int, kauth_cred_t, struct buf **, int, int *); +int ffs_blkalloc(struct inode *ip, ufs_daddr_t lbn,int size, + kauth_cred_t cred, int flags); +void ffs_blkfree(struct inode *, ufs_daddr_t, int32_t); +ufs_daddr_t ffs_blkpref(struct inode *, ufs_daddr_t, int, ufs_daddr_t *); +void ffs_clrblock(struct fs *, u_char *, ufs_daddr_t); +int ffs_fhtovp(struct mount *, int, unsigned char *, struct vnode **, vfs_context_t); +void ffs_fragacct(struct fs *, int, int32_t [], int); +int ffs_fsync(struct vnop_fsync_args *); +int ffs_init(struct vfsconf *); +int ffs_isblock(struct fs *, u_char *, ufs_daddr_t); +int ffs_mount(struct mount *, vnode_t , user_addr_t, vfs_context_t); +int ffs_mountfs(struct vnode *, struct mount *, vfs_context_t); +int ffs_mountroot(mount_t, vnode_t, vfs_context_t); +int ffs_read(struct vnop_read_args *); +int ffs_realloccg(struct inode *, + ufs_daddr_t, ufs_daddr_t, int, int, kauth_cred_t, struct buf **); +int ffs_reclaim(struct vnop_reclaim_args *); +void ffs_setblock(struct fs *, u_char *, ufs_daddr_t); +int ffs_vfs_getattr(struct mount *, struct vfs_attr *, vfs_context_t); +int ffs_vfs_setattr(struct mount *, struct vfs_attr *, vfs_context_t); +int ffs_sync(struct mount *, int, vfs_context_t); +int ffs_sysctl(int *, u_int, user_addr_t, size_t *, user_addr_t, size_t, vfs_context_t); +int ffs_unmount(struct mount *, int, vfs_context_t); +int ffs_update(struct vnode *, struct timeval *, struct timeval *, int); +int ffs_valloc(vnode_t dvp, mode_t mode, kauth_cred_t cred, vnode_t *vpp); +int ffs_vfree(struct vnode *vp, ino_t ino, int mode); +int ffs_vget(struct mount *, ino64_t, struct vnode **, vfs_context_t); +int ffs_vptofh(struct vnode *, int *, unsigned char *, vfs_context_t); +int ffs_write(struct vnop_write_args *); +int ffs_pagein(struct vnop_pagein_args *); +int ffs_pageout(struct vnop_pageout_args *); +int ffs_blktooff(struct vnop_blktooff_args *); +int ffs_offtoblk(struct vnop_offtoblk_args *); + +__END_DECLS + +extern int (**ffs_vnodeop_p)(void *); +extern int (**ffs_specop_p)(void *); +#if FIFO +extern int (**ffs_fifoop_p)(void *); +#define FFS_FIFOOPS ffs_fifoop_p +#else +#define FFS_FIFOOPS NULL +#endif + +#endif /* __APPLE_API_PRIVATE */ +#endif /* __UFS_FFS_FFS_EXTERN_H__ */ Index: branches/azimutz/Cleancut/i386/include/ufs/ffs/fs.h =================================================================== --- branches/azimutz/Cleancut/i386/include/ufs/ffs/fs.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/ufs/ffs/fs.h (revision 885) @@ -0,0 +1,591 @@ +/* + * Copyright (c) 2000-2008 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) 1995 NeXT Computer, Inc. All Rights Reserved */ +/* + * Copyright (c) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)fs.h 8.13 (Berkeley) 3/21/95 + */ +#ifndef _FFS_FS_H_ +#define _FFS_FS_H_ + +#ifdef __APPLE_API_UNSTABLE +/* + * Each disk drive contains some number of file systems. + * A file system consists of a number of cylinder groups. + * Each cylinder group has inodes and data. + * + * A file system is described by its super-block, which in turn + * describes the cylinder groups. The super-block is critical + * data and is replicated in each cylinder group to protect against + * catastrophic loss. This is done at `newfs' time and the critical + * super-block data does not change, so the copies need not be + * referenced further unless disaster strikes. + * + * For file system fs, the offsets of the various blocks of interest + * are given in the super block as: + * [fs->fs_sblkno] Super-block + * [fs->fs_cblkno] Cylinder group block + * [fs->fs_iblkno] Inode blocks + * [fs->fs_dblkno] Data blocks + * The beginning of cylinder group cg in fs, is given by + * the ``cgbase(fs, cg)'' macro. + * + * The first boot and super blocks are given in absolute disk addresses. + * The byte-offset forms are preferred, as they don't imply a sector size. + */ +#define BBSIZE 8192 +#define SBSIZE 8192 +#define BBOFF ((off_t)(0)) +#define SBOFF ((off_t)(BBOFF + BBSIZE)) +#define BBLOCK ((ufs_daddr_t)(0)) +#define SBLOCK ((ufs_daddr_t)(BBLOCK + BBSIZE / DEV_BSIZE)) + +/* + * Addresses stored in inodes are capable of addressing fragments + * of `blocks'. File system blocks of at most size MAXBSIZE can + * be optionally broken into 2, 4, or 8 pieces, each of which is + * addressible; these pieces may be DEV_BSIZE, or some multiple of + * a DEV_BSIZE unit. + * + * Large files consist of exclusively large data blocks. To avoid + * undue wasted disk space, the last data block of a small file may be + * allocated as only as many fragments of a large block as are + * necessary. The file system format retains only a single pointer + * to such a fragment, which is a piece of a single large block that + * has been divided. The size of such a fragment is determinable from + * information in the inode, using the ``blksize(fs, ip, lbn)'' macro. + * + * The file system records space availability at the fragment level; + * to determine block availability, aligned fragments are examined. + */ + +/* + * MINBSIZE is the smallest allowable block size. + * In order to insure that it is possible to create files of size + * 2^32 with only two levels of indirection, MINBSIZE is set to 4096. + * MINBSIZE must be big enough to hold a cylinder group block, + * thus changes to (struct cg) must keep its size within MINBSIZE. + * Note that super blocks are always of size SBSIZE, + * and that both SBSIZE and MAXBSIZE must be >= MINBSIZE. + */ +#define MINBSIZE 4096 + +/* + * The path name on which the file system is mounted is maintained + * in fs_fsmnt. MAXMNTLEN defines the amount of space allocated in + * the super block for this name. + */ +#define MAXMNTLEN 512 + +/* + * The limit on the amount of summary information per file system + * is defined by MAXCSBUFS. It is currently parameterized for a + * size of 128 bytes (2 million cylinder groups on machines with + * 32-bit pointers, and 1 million on 64-bit machines). One pointer + * is taken away to point to an array of cluster sizes that is + * computed as cylinder groups are inspected. + * There is a 128-byte region in the superblock reserved for in-core + * pointers to summary information. Originally this included an array + * of pointers to blocks of struct csum; now there are just three + * pointers and the remaining space is padded with fs_ocsp[]. + * + * NOCSPTRS determines the size of this padding. One pointer (fs_csp) + * is taken away to point to a contiguous array of struct csum for + * all cylinder groups; a second (fs_maxcluster) points to an array + * of cluster sizes that is computed as cylinder groups are inspected, + * and the third points to an array that tracks the creation of new + * directories. + */ +#define NOCSPTRS ((128 / sizeof(void *)) - 3) + +/* + * A summary of contiguous blocks of various sizes is maintained + * in each cylinder group. Normally this is set by the initial + * value of fs_maxcontig. To conserve space, a maximum summary size + * is set by FS_MAXCONTIG. + */ +#define FS_MAXCONTIG 16 + +/* + * MINFREE gives the minimum acceptable percentage of file system + * blocks which may be free. If the freelist drops below this level + * only the superuser may continue to allocate blocks. This may + * be set to 0 if no reserve of free blocks is deemed necessary, + * however throughput drops by fifty percent if the file system + * is run at between 95% and 100% full; thus the minimum default + * value of fs_minfree is 5%. However, to get good clustering + * performance, 10% is a better choice. hence we use 10% as our + * default value. With 10% free space, fragmentation is not a + * problem, so we choose to optimize for time. + */ +#define MINFREE 5 +#define DEFAULTOPT FS_OPTTIME + +/* Grigoriy Orlov <gluk@ptci.ru> has done some extensive work to fine + * tune the layout preferences for directories within a filesystem. + * His algorithm can be tuned by adjusting the following parameters + * which tell the system the average file size and the average number + * of files per directory. These defaults are well selected for typical + * filesystems, but may need to be tuned for odd cases like filesystems + * being used for squid caches or news spools. + */ +#define AVFILESIZ 16384 +#define AFPDIR 64 + +/* + * Per cylinder group information; summarized in blocks allocated + * from first cylinder group data blocks. These blocks have to be + * read in from fs_csaddr (size fs_cssize) in addition to the + * super block. + */ +struct csum { + int32_t cs_ndir; /* number of directories */ + int32_t cs_nbfree; /* number of free blocks */ + int32_t cs_nifree; /* number of free inodes */ + int32_t cs_nffree; /* number of free frags */ +}; + +/* + * Super block for an FFS file system. + */ +struct fs { + int32_t fs_firstfield; /* historic file system linked list, */ + int32_t fs_unused_1; /* used for incore super blocks */ + ufs_daddr_t fs_sblkno; /* addr of super-block in filesys */ + ufs_daddr_t fs_cblkno; /* offset of cyl-block in filesys */ + ufs_daddr_t fs_iblkno; /* offset of inode-blocks in filesys */ + ufs_daddr_t fs_dblkno; /* offset of first data after cg */ + int32_t fs_cgoffset; /* cylinder group offset in cylinder */ + int32_t fs_cgmask; /* used to calc mod fs_ntrak */ + u_int32_t fs_time; /* last time written */ + int32_t fs_size; /* number of blocks in fs */ + int32_t fs_dsize; /* number of data blocks in fs */ + int32_t fs_ncg; /* number of cylinder groups */ + int32_t fs_bsize; /* size of basic blocks in fs */ + int32_t fs_fsize; /* size of frag blocks in fs */ + int32_t fs_frag; /* number of frags in a block in fs */ +/* these are configuration parameters */ + int32_t fs_minfree; /* minimum percentage of free blocks */ + int32_t fs_rotdelay; /* num of ms for optimal next block */ + int32_t fs_rps; /* disk revolutions per second */ +/* these fields can be computed from the others */ + int32_t fs_bmask; /* ``blkoff'' calc of blk offsets */ + int32_t fs_fmask; /* ``fragoff'' calc of frag offsets */ + int32_t fs_bshift; /* ``lblkno'' calc of logical blkno */ + int32_t fs_fshift; /* ``numfrags'' calc number of frags */ +/* these are configuration parameters */ + int32_t fs_maxcontig; /* max number of contiguous blks */ + int32_t fs_maxbpg; /* max number of blks per cyl group */ +/* these fields can be computed from the others */ + int32_t fs_fragshift; /* block to frag shift */ + int32_t fs_fsbtodb; /* fsbtodb and dbtofsb shift constant */ + int32_t fs_sbsize; /* actual size of super block */ + int32_t fs_csmask; /* csum block offset (now unused) */ + int32_t fs_csshift; /* csum block number (now unused) */ + int32_t fs_nindir; /* value of NINDIR */ + int32_t fs_inopb; /* value of INOPB */ + int32_t fs_nspf; /* value of NSPF */ +/* yet another configuration parameter */ + int32_t fs_optim; /* optimization preference, see below */ +/* these fields are derived from the hardware */ + int32_t fs_npsect; /* # sectors/track including spares */ + int32_t fs_interleave; /* hardware sector interleave */ + int32_t fs_trackskew; /* sector 0 skew, per track */ + int32_t fs_headswitch; /* head switch time, usec */ + int32_t fs_trkseek; /* track-to-track seek, usec */ +/* sizes determined by number of cylinder groups and their sizes */ + ufs_daddr_t fs_csaddr; /* blk addr of cyl grp summary area */ + int32_t fs_cssize; /* size of cyl grp summary area */ + int32_t fs_cgsize; /* cylinder group size */ +/* these fields are derived from the hardware */ + int32_t fs_ntrak; /* tracks per cylinder */ + int32_t fs_nsect; /* sectors per track */ + int32_t fs_spc; /* sectors per cylinder */ +/* this comes from the disk driver partitioning */ + int32_t fs_ncyl; /* cylinders in file system */ +/* these fields can be computed from the others */ + int32_t fs_cpg; /* cylinders per group */ + int32_t fs_ipg; /* inodes per group */ + int32_t fs_fpg; /* blocks per group * fs_frag */ +/* this data must be re-computed after crashes */ + struct csum fs_cstotal; /* cylinder summary information */ +/* these fields are cleared at mount time */ + int8_t fs_fmod; /* super block modified flag */ + int8_t fs_clean; /* file system is clean flag */ + int8_t fs_ronly; /* mounted read-only flag */ + int8_t fs_flags; /* currently unused flag */ + u_char fs_fsmnt[MAXMNTLEN]; /* name mounted on */ +/* these fields retain the current block allocation info */ + int32_t fs_cgrotor; /* last cg searched */ + void *fs_ocsp[NOCSPTRS]; /* list of fs_cs info buffers */ + u_int8_t *fs_contigdirs; /* # of contiguously allocated dirs */ + struct csum *fs_csp; /* list of fs_cs info buffers */ + int32_t *fs_maxcluster; /* max cluster in each cyl group */ + int32_t fs_cpc; /* cyl per cycle in postbl */ + int16_t fs_opostbl[16][8]; /* old rotation block list head */ + int32_t fs_avgfilesize; /* expected average file size */ + int32_t fs_avgfpdir; /* expected # of files per directory */ + int32_t fs_sparecon[48]; /* reserved for future constants */ + int32_t fs_contigsumsize; /* size of cluster summary array */ + int32_t fs_maxsymlinklen; /* max length of an internal symlink */ + int32_t fs_inodefmt; /* format of on-disk inodes */ + u_int64_t fs_maxfilesize; /* maximum representable file size */ + int64_t fs_qbmask; /* ~fs_bmask for use with 64-bit size */ + int64_t fs_qfmask; /* ~fs_fmask for use with 64-bit size */ + int32_t fs_state; /* validate fs_clean field */ + int32_t fs_postblformat; /* format of positional layout tables */ + int32_t fs_nrpos; /* number of rotational positions */ + int32_t fs_postbloff; /* (u_int16) rotation block list head */ + int32_t fs_rotbloff; /* (u_int8) blocks for each rotation */ + int32_t fs_magic; /* magic number */ + u_int8_t fs_space[1]; /* list of blocks for each rotation */ +/* actually longer */ +} __attribute__((packed,aligned(4))); + +/* + * Filesystem identification + */ +#define FS_MAGIC 0x011954 /* the fast filesystem magic number */ +#define FS_OKAY 0x7c269d38 /* superblock checksum */ +#define FS_42INODEFMT -1 /* 4.2BSD inode format */ +#define FS_44INODEFMT 2 /* 4.4BSD inode format */ +/* + * Preference for optimization. + */ +#define FS_OPTTIME 0 /* minimize allocation time */ +#define FS_OPTSPACE 1 /* minimize disk fragmentation */ + +/* + * Rotational layout table format types + */ +#define FS_42POSTBLFMT -1 /* 4.2BSD rotational table format */ +#define FS_DYNAMICPOSTBLFMT 1 /* dynamic rotational table format */ +/* + * Macros for access to superblock array structures + */ +#define fs_postbl(fs, cylno) \ + (((fs)->fs_postblformat == FS_42POSTBLFMT) \ + ? ((fs)->fs_opostbl[cylno]) \ + : ((int16_t *)((u_int8_t *)(fs) + \ + (fs)->fs_postbloff) + (cylno) * (fs)->fs_nrpos)) +#define fs_rotbl(fs) \ + (((fs)->fs_postblformat == FS_42POSTBLFMT) \ + ? ((fs)->fs_space) \ + : ((u_int8_t *)((u_int8_t *)(fs) + (fs)->fs_rotbloff))) + +/* + * The size of a cylinder group is calculated by CGSIZE. The maximum size + * is limited by the fact that cylinder groups are at most one block. + * Its size is derived from the size of the maps maintained in the + * cylinder group and the (struct cg) size. + */ +#define CGSIZE(fs) \ + /* base cg */ (sizeof(struct cg) + sizeof(int32_t) + \ + /* blktot size */ (fs)->fs_cpg * sizeof(int32_t) + \ + /* blks size */ (fs)->fs_cpg * (fs)->fs_nrpos * sizeof(int16_t) + \ + /* inode map */ howmany((fs)->fs_ipg, NBBY) + \ + /* block map */ howmany((fs)->fs_cpg * (fs)->fs_spc / NSPF(fs), NBBY) +\ + /* if present */ ((fs)->fs_contigsumsize <= 0 ? 0 : \ + /* cluster sum */ (fs)->fs_contigsumsize * sizeof(int32_t) + \ + /* cluster map */ howmany((fs)->fs_cpg * (fs)->fs_spc / NSPB(fs), NBBY))) + +/* + * Convert cylinder group to base address of its global summary info. + * + * N.B. This macro assumes that sizeof(struct csum) is a power of two. + */ +#define fs_cs(fs, indx) fs_csp[indx] + +/* + * Cylinder group block for a file system. + */ +#define CG_MAGIC 0x090255 +struct cg { + int32_t cg_firstfield; /* historic cyl groups linked list */ + int32_t cg_magic; /* magic number */ + u_int32_t cg_time; /* time last written */ + int32_t cg_cgx; /* we are the cgx'th cylinder group */ + int16_t cg_ncyl; /* number of cyl's this cg */ + int16_t cg_niblk; /* number of inode blocks this cg */ + int32_t cg_ndblk; /* number of data blocks this cg */ + struct csum cg_cs; /* cylinder summary information */ + int32_t cg_rotor; /* position of last used block */ + int32_t cg_frotor; /* position of last used frag */ + int32_t cg_irotor; /* position of last used inode */ + int32_t cg_frsum[MAXFRAG]; /* counts of available frags */ + int32_t cg_btotoff; /* (int32) block totals per cylinder */ + int32_t cg_boff; /* (u_int16) free block positions */ + int32_t cg_iusedoff; /* (u_int8) used inode map */ + int32_t cg_freeoff; /* (u_int8) free block map */ + int32_t cg_nextfreeoff; /* (u_int8) next available space */ + int32_t cg_clustersumoff; /* (u_int32) counts of avail clusters */ + int32_t cg_clusteroff; /* (u_int8) free cluster map */ + int32_t cg_nclusterblks; /* number of clusters this cg */ + int32_t cg_sparecon[13]; /* reserved for future use */ + u_int8_t cg_space[1]; /* space for cylinder group maps */ +/* actually longer */ +} __attribute__((packed,aligned(4))); + +/* + * Macros for access to cylinder group array structures + */ +#define cg_blktot(cgp) \ + (((cgp)->cg_magic != CG_MAGIC) \ + ? (((struct ocg *)(cgp))->cg_btot) \ + : ((int32_t *)((u_int8_t *)(cgp) + (cgp)->cg_btotoff))) +#define cg_blks(fs, cgp, cylno) \ + (((cgp)->cg_magic != CG_MAGIC) \ + ? (((struct ocg *)(cgp))->cg_b[cylno]) \ + : ((int16_t *)((u_int8_t *)(cgp) + \ + (cgp)->cg_boff) + (cylno) * (fs)->fs_nrpos)) +#define cg_inosused(cgp) \ + (((cgp)->cg_magic != CG_MAGIC) \ + ? (((struct ocg *)(cgp))->cg_iused) \ + : ((u_int8_t *)((u_int8_t *)(cgp) + (cgp)->cg_iusedoff))) +#define cg_blksfree(cgp) \ + (((cgp)->cg_magic != CG_MAGIC) \ + ? (((struct ocg *)(cgp))->cg_free) \ + : ((u_int8_t *)((u_int8_t *)(cgp) + (cgp)->cg_freeoff))) +#define cg_chkmagic(cgp) \ + ((cgp)->cg_magic == CG_MAGIC || ((struct ocg *)(cgp))->cg_magic == CG_MAGIC) +#define cg_clustersfree(cgp) \ + ((u_int8_t *)((u_int8_t *)(cgp) + (cgp)->cg_clusteroff)) +#define cg_clustersum(cgp) \ + ((int32_t *)((u_int8_t *)(cgp) + (cgp)->cg_clustersumoff)) + +/* + * The following structure is defined + * for compatibility with old file systems. + */ +struct ocg { + int32_t cg_firstfield; /* historic linked list of cyl groups */ + int32_t cg_unused_1; /* used for incore cyl groups */ + u_int32_t cg_time; /* time last written */ + int32_t cg_cgx; /* we are the cgx'th cylinder group */ + int16_t cg_ncyl; /* number of cyl's this cg */ + int16_t cg_niblk; /* number of inode blocks this cg */ + int32_t cg_ndblk; /* number of data blocks this cg */ + struct csum cg_cs; /* cylinder summary information */ + int32_t cg_rotor; /* position of last used block */ + int32_t cg_frotor; /* position of last used frag */ + int32_t cg_irotor; /* position of last used inode */ + int32_t cg_frsum[8]; /* counts of available frags */ + int32_t cg_btot[32]; /* block totals per cylinder */ + int16_t cg_b[32][8]; /* positions of free blocks */ + u_int8_t cg_iused[256]; /* used inode map */ + int32_t cg_magic; /* magic number */ + u_int8_t cg_free[1]; /* free block map */ +/* actually longer */ +} __attribute__((packed,aligned(4))); + +/* + * Turn file system block numbers into disk block addresses. + * This maps file system blocks to device size blocks. + */ +#define fsbtodb(fs, b) ((b) << (fs)->fs_fsbtodb) +#define dbtofsb(fs, b) ((b) >> (fs)->fs_fsbtodb) + +/* + * Cylinder group macros to locate things in cylinder groups. + * They calc file system addresses of cylinder group data structures. + */ +#define cgbase(fs, c) ((ufs_daddr_t)((fs)->fs_fpg * (c))) +#define cgdmin(fs, c) (cgstart(fs, c) + (fs)->fs_dblkno) /* 1st data */ +#define cgimin(fs, c) (cgstart(fs, c) + (fs)->fs_iblkno) /* inode blk */ +#define cgsblock(fs, c) (cgstart(fs, c) + (fs)->fs_sblkno) /* super blk */ +#define cgtod(fs, c) (cgstart(fs, c) + (fs)->fs_cblkno) /* cg block */ +#define cgstart(fs, c) \ + (cgbase(fs, c) + (fs)->fs_cgoffset * ((c) & ~((fs)->fs_cgmask))) + +/* + * Macros for handling inode numbers: + * inode number to file system block offset. + * inode number to cylinder group number. + * inode number to file system block address. + */ +#define ino_to_cg(fs, x) ((x) / (fs)->fs_ipg) +#define ino_to_fsba(fs, x) \ + ((ufs_daddr_t)(cgimin(fs, ino_to_cg(fs, x)) + \ + (blkstofrags((fs), (((x) % (fs)->fs_ipg) / INOPB(fs)))))) +#define ino_to_fsbo(fs, x) ((x) % INOPB(fs)) + +/* + * Give cylinder group number for a file system block. + * Give cylinder group block number for a file system block. + */ +#define dtog(fs, d) ((d) / (fs)->fs_fpg) +#define dtogd(fs, d) ((d) % (fs)->fs_fpg) + +/* + * Extract the bits for a block from a map. + * Compute the cylinder and rotational position of a cyl block addr. + */ +#define blkmap(fs, map, loc) \ + (((map)[(loc) / NBBY] >> ((loc) % NBBY)) & (0xff >> (NBBY - (fs)->fs_frag))) +#define cbtocylno(fs, bno) \ + ((bno) * NSPF(fs) / (fs)->fs_spc) +#define cbtorpos(fs, bno) \ + (((bno) * NSPF(fs) % (fs)->fs_spc / (fs)->fs_nsect * (fs)->fs_trackskew + \ + (bno) * NSPF(fs) % (fs)->fs_spc % (fs)->fs_nsect * (fs)->fs_interleave) % \ + (fs)->fs_nsect * (fs)->fs_nrpos / (fs)->fs_npsect) + +/* + * The following macros optimize certain frequently calculated + * quantities by using shifts and masks in place of divisions + * modulos and multiplications. + */ +#define blkoff(fs, loc) /* calculates (loc % fs->fs_bsize) */ \ + ((loc) & (fs)->fs_qbmask) +#define fragoff(fs, loc) /* calculates (loc % fs->fs_fsize) */ \ + ((loc) & (fs)->fs_qfmask) +#define lblktosize(fs, blk) /* calculates (blk * fs->fs_bsize) */ \ + ((blk) << (fs)->fs_bshift) +#define lblkno(fs, loc) /* calculates (loc / fs->fs_bsize) */ \ + ((loc) >> (fs)->fs_bshift) +#define numfrags(fs, loc) /* calculates (loc / fs->fs_fsize) */ \ + ((loc) >> (fs)->fs_fshift) +#define blkroundup(fs, size) /* calculates roundup(size, fs->fs_bsize) */ \ + (((size) + (fs)->fs_qbmask) & (fs)->fs_bmask) +#define fragroundup(fs, size) /* calculates roundup(size, fs->fs_fsize) */ \ + (((size) + (fs)->fs_qfmask) & (fs)->fs_fmask) +#define fragstoblks(fs, frags) /* calculates (frags / fs->fs_frag) */ \ + ((frags) >> (fs)->fs_fragshift) +#define blkstofrags(fs, blks) /* calculates (blks * fs->fs_frag) */ \ + ((blks) << (fs)->fs_fragshift) +#define fragnum(fs, fsb) /* calculates (fsb % fs->fs_frag) */ \ + ((fsb) & ((fs)->fs_frag - 1)) +#define blknum(fs, fsb) /* calculates rounddown(fsb, fs->fs_frag) */ \ + ((fsb) &~ ((fs)->fs_frag - 1)) + +/* + * Determine the number of available frags given a + * percentage to hold in reserve. + */ +#define freespace(fs, percentreserved) \ + (blkstofrags((fs), (fs)->fs_cstotal.cs_nbfree) + \ + (fs)->fs_cstotal.cs_nffree - ((fs)->fs_dsize * (percentreserved) / 100)) + +/* + * Determining the size of a file block in the file system. + */ +#define blksize(fs, ip, lbn) \ + (((lbn) >= NDADDR || (ip)->i_size >= ((lbn) + 1) << (fs)->fs_bshift) \ + ? (fs)->fs_bsize \ + : (fragroundup(fs, blkoff(fs, (ip)->i_size)))) +#define dblksize(fs, dip, lbn) \ + (((lbn) >= NDADDR || (dip)->di_size >= ((lbn) + 1) << (fs)->fs_bshift) \ + ? (fs)->fs_bsize \ + : (fragroundup(fs, blkoff(fs, (dip)->di_size)))) + +/* + * Number of disk sectors per block/fragment; assumes DEV_BSIZE byte + * sector size. + */ +#define NSPB(fs) ((fs)->fs_nspf << (fs)->fs_fragshift) +#define NSPF(fs) ((fs)->fs_nspf) + +/* + * Number of inodes in a secondary storage block/fragment. + */ +#define INOPB(fs) ((fs)->fs_inopb) +#define INOPF(fs) ((fs)->fs_inopb >> (fs)->fs_fragshift) + +/* + * Number of indirects in a file system block. + */ +#define NINDIR(fs) ((fs)->fs_nindir) + +/* + * This macro controls whether the file system format is byte swapped or not. + * At NeXT, all little endian machines read and write big endian file systems. + */ +#define BIG_ENDIAN_FS (__LITTLE_ENDIAN__) + +#ifdef __APPLE_API_PRIVATE +extern int inside[], around[]; +extern u_char *fragtbl[]; +#endif /* __APPLE_API_PRIVATE */ + + +/* + * UFS Label: + * The purpose of this label is to name a UFS/FFS filesystem. The label + * is located at offset 7K (BBSIZE=8K - UFS_LABEL_SIZE=1K = 7K) of the + * partition. The first 7K is still available for boot blocks. + */ + +#define UFS_LABEL_MAGIC { 'L', 'A', 'B', 'L' } +#define UFS_LABEL_SIZE 1024 +#define UFS_LABEL_OFFSET (BBSIZE - UFS_LABEL_SIZE) /* top 1K */ +#define UFS_LABEL_VERSION 1 +#define UFS_MAX_LABEL_NAME 512 + +struct ufslabel { + u_int32_t ul_magic; + u_int16_t ul_checksum; /* checksum over entire label*/ + u_int32_t ul_version __attribute__((aligned(4))); /* label version */ + u_int32_t ul_time; /* creation time */ + u_int16_t ul_namelen; /* filesystem name length */ + u_char ul_name[UFS_MAX_LABEL_NAME]; /* filesystem name */ + u_int64_t ul_uuid __attribute__((aligned(4))); /* filesystem uuid */ + u_char ul_reserved[24];/* reserved for future use */ + u_char ul_unused[460]; /* pad out to 1K */ +} __attribute__((packed,aligned(4))); + +#endif /* __APPLE_API_UNSTABLE */ +#endif /* ! _FFS_FS_H_ */ Index: branches/azimutz/Cleancut/i386/include/stddef.h =================================================================== --- branches/azimutz/Cleancut/i386/include/stddef.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/stddef.h (revision 885) @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2000 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@ + */ +/* $OpenBSD: stddef.h,v 1.2 1997/09/21 10:45:52 niklas Exp $ */ +/* $NetBSD: stddef.h,v 1.4 1994/10/26 00:56:26 cgd Exp $ */ + +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)stddef.h 5.5 (Berkeley) 4/3/91 + */ + +#if !defined(__STDDEF_H__) + +#if !defined(__need_wchar_t) && !defined(__need_size_t) \ + && !defined(__need_ptrdiff_t) && !defined(__need_NULL) \ + && !defined(__need_wint_t) +#define __STDDEF_H__ +#endif /* none of __need_* defined */ + +#include <sys/_types.h> + +#if defined(__STDDEF_H__) || defined(__need_ptrdiff_t) +#ifndef _PTRDIFF_T +#define _PTRDIFF_T +typedef __darwin_ptrdiff_t ptrdiff_t; +#endif /* _PTRDIFF_T */ +#endif /* __STDDEF_H__ || __need_ptrdiff_t */ + +#if defined(__STDDEF_H__) || defined(__need_size_t) +#ifndef _SIZE_T +#define _SIZE_T +/* DO NOT REMOVE THIS COMMENT: fixincludes needs to see: + * _GCC_SIZE_T */ +typedef __darwin_size_t size_t; +#endif /* _SIZE_T */ +#endif /* __STDDEF_H__ || __need_size_t */ + +#if defined(__STDDEF_H__) || defined(__need_wchar_t) +#ifndef __cplusplus +#ifndef _WCHAR_T +#define _WCHAR_T +typedef __darwin_wchar_t wchar_t; +#endif /* _WCHAR_T */ +#endif /* __cplusplus */ +#endif /* __STDDEF_H__ || __need_wchar_t */ + +#if (defined(__STDDEF_H__) && !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))) \ + || defined(__need_wint_t) +#ifndef _WINT_T +#define _WINT_T +typedef __darwin_wint_t wint_t; +#endif /* _WINT_T */ +#endif /* __STDDEF_H__ && !_ANSI_SOURCE && (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) || __need_wchar_t */ + +#if defined(__STDDEF_H__) || defined(__need_NULL) +#ifndef NULL +#define NULL __DARWIN_NULL +#endif /* ! NULL */ +#endif /* __STDDEF_H__ || __need_NULL */ + +#ifdef __STDDEF_H__ +#if defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 5 || __GNUC__ > 3) +#ifndef __offsetof /* Deprecated: for source compatability only */ +#define __offsetof(type, field) __builtin_offsetof(type, field) +#endif +#define offsetof(type, field) __builtin_offsetof(type, field) +#else /* ! (gcc >= 3.5) */ +#ifndef __offsetof /* Deprecated: for source compatability only */ +#define __offsetof(type, field) ((size_t)(&((type *)0)->field)) +#endif +#define offsetof(type, field) ((size_t)(&((type *)0)->field)) +#endif /* (gcc >= 3.5) */ +#endif /* __STDDEF_H__ */ + +#endif /* __STDDEF_H__ */ + +#undef __need_ptrdiff_t +#undef __need_size_t +#undef __need_wchar_t +#undef __need_wint_t +#undef __need_NULL Index: branches/azimutz/Cleancut/i386/include/device/device_port.h =================================================================== --- branches/azimutz/Cleancut/i386/include/device/device_port.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/device/device_port.h (revision 885) @@ -0,0 +1,80 @@ +/* + * 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 Software.Distribution@CS.CMU.EDU + * 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_ */ Index: branches/azimutz/Cleancut/i386/include/device/device_types.h =================================================================== --- branches/azimutz/Cleancut/i386/include/device/device_types.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/device/device_types.h (revision 885) @@ -0,0 +1,141 @@ +/* + * 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 Software.Distribution@CS.CMU.EDU + * 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> + +/* + * 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_struct_inband_t[4096]; + +#if KERNEL +typedef uint64_t io_user_scalar_t; +typedef uint64_t io_user_reference_t; +typedef int io_scalar_inband_t[16]; +// must be the same type as OSAsyncReference +typedef natural_t io_async_ref_t[8]; +typedef io_user_scalar_t io_scalar_inband64_t[16]; +typedef io_user_reference_t io_async_ref64_t[8]; +#elif __LP64__ +typedef uint64_t io_user_scalar_t; +typedef uint64_t io_user_reference_t; +typedef io_user_scalar_t io_scalar_inband_t[16]; +typedef io_user_reference_t io_async_ref_t[8]; +typedef io_user_scalar_t io_scalar_inband64_t[16]; +typedef io_user_reference_t io_async_ref64_t[8]; +#else +typedef int io_user_scalar_t; +typedef natural_t io_user_reference_t; +typedef io_user_scalar_t io_scalar_inband_t[16]; +typedef io_user_reference_t io_async_ref_t[8]; +typedef uint64_t io_scalar_inband64_t[16]; +typedef uint64_t io_async_ref64_t[8]; +#endif // __LP64__ + +#ifdef MACH_KERNEL + +typedef struct IOObject * io_object_t; +typedef io_object_t io_connect_t; + +extern void iokit_remove_reference( io_object_t obj ); + +extern io_object_t iokit_lookup_object_port( ipc_port_t port ); +extern io_connect_t iokit_lookup_connect_port( ipc_port_t port ); + +extern ipc_port_t iokit_make_object_port( io_object_t obj ); +extern ipc_port_t iokit_make_connect_port( io_connect_t obj ); + +extern boolean_t iokit_notify( mach_msg_header_t *msg ); + +#else + +#ifndef __IOKIT_PORTS_DEFINED__ +#define __IOKIT_PORTS_DEFINED__ +typedef mach_port_t io_object_t; +#endif /* __IOKIT_PORTS_DEFINED__ */ + +#endif /* MACH_KERNEL */ + +#endif /* IOKIT */ + +#endif /* DEVICE_TYPES_H */ + Index: branches/azimutz/Cleancut/i386/include/runetype.h =================================================================== --- branches/azimutz/Cleancut/i386/include/runetype.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/runetype.h (revision 885) @@ -0,0 +1,136 @@ +/*- + * Copyright (c) 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Paul Borman at Krystal Technologies. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)runetype.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _RUNETYPE_H_ +#define _RUNETYPE_H_ + +#include <_types.h> + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) + +#ifndef _SIZE_T +#define _SIZE_T +typedef __darwin_size_t size_t; +#endif + +#ifndef _CT_RUNE_T +#define _CT_RUNE_T +typedef __darwin_ct_rune_t ct_rune_t; +#endif + +#ifndef _RUNE_T +#define _RUNE_T +typedef __darwin_rune_t rune_t; +#endif + +#ifndef __cplusplus +#ifndef _WCHAR_T +#define _WCHAR_T +typedef __darwin_wchar_t wchar_t; +#endif /* _WCHAR_T */ +#endif /* __cplusplus */ + +#ifndef _WINT_T +#define _WINT_T +typedef __darwin_wint_t wint_t; +#endif + +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + +#define _CACHED_RUNES (1 <<8 ) /* Must be a power of 2 */ +#define _CRMASK (~(_CACHED_RUNES - 1)) + +/* + * The lower 8 bits of runetype[] contain the digit value of the rune. + */ +typedef struct { + __darwin_rune_t __min; /* First rune of the range */ + __darwin_rune_t __max; /* Last rune (inclusive) of the range */ + __darwin_rune_t __map; /* What first maps to in maps */ + __uint32_t *__types; /* Array of types in range */ +} _RuneEntry; + +typedef struct { + int __nranges; /* Number of ranges stored */ + _RuneEntry *__ranges; /* Pointer to the ranges */ +} _RuneRange; + +typedef struct { + char __name[14]; /* CHARCLASS_NAME_MAX = 14 */ + __uint32_t __mask; /* charclass mask */ +} _RuneCharClass; + +typedef struct { + char __magic[8]; /* Magic saying what version we are */ + char __encoding[32]; /* ASCII name of this encoding */ + + __darwin_rune_t (*__sgetrune)(const char *, __darwin_size_t, char const **); + int (*__sputrune)(__darwin_rune_t, char *, __darwin_size_t, char **); + __darwin_rune_t __invalid_rune; + + __uint32_t __runetype[_CACHED_RUNES]; + __darwin_rune_t __maplower[_CACHED_RUNES]; + __darwin_rune_t __mapupper[_CACHED_RUNES]; + + /* + * The following are to deal with Runes larger than _CACHED_RUNES - 1. + * Their data is actually contiguous with this structure so as to make + * it easier to read/write from/to disk. + */ + _RuneRange __runetype_ext; + _RuneRange __maplower_ext; + _RuneRange __mapupper_ext; + + void *__variable; /* Data which depends on the encoding */ + int __variable_len; /* how long that data is */ + + /* + * extra fields to deal with arbitrary character classes + */ + int __ncharclasses; + _RuneCharClass *__charclasses; +} _RuneLocale; + +#define _RUNE_MAGIC_A "RuneMagA" /* Indicates version A of RuneLocale */ + +__BEGIN_DECLS +extern _RuneLocale _DefaultRuneLocale; +extern _RuneLocale *_CurrentRuneLocale; +__END_DECLS + +#endif /* !_RUNETYPE_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach-o/nlist.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach-o/nlist.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach-o/nlist.h (revision 885) @@ -0,0 +1,312 @@ +/* + * Copyright (c) 1999-2003 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 _MACHO_NLIST_H_ +#define _MACHO_NLIST_H_ +/* $NetBSD: nlist.h,v 1.5 1994/10/26 00:56:11 cgd Exp $ */ + +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)nlist.h 8.2 (Berkeley) 1/21/94 + */ +#include <stdint.h> + +/* + * Format of a symbol table entry of a Mach-O file for 32-bit architectures. + * Modified from the BSD format. The modifications from the original format + * were changing n_other (an unused field) to n_sect and the addition of the + * N_SECT type. These modifications are required to support symbols in a larger + * number of sections not just the three sections (text, data and bss) in a BSD + * file. + */ +struct nlist { + union { +#ifndef __LP64__ + char *n_name; /* for use when in-core */ +#endif + int32_t n_strx; /* index into the string table */ + } n_un; + uint8_t n_type; /* type flag, see below */ + uint8_t n_sect; /* section number or NO_SECT */ + int16_t n_desc; /* see <mach-o/stab.h> */ + uint32_t n_value; /* value of this symbol (or stab offset) */ +}; + +/* + * This is the symbol table entry structure for 64-bit architectures. + */ +struct nlist_64 { + union { + uint32_t n_strx; /* index into the string table */ + } n_un; + uint8_t n_type; /* type flag, see below */ + uint8_t n_sect; /* section number or NO_SECT */ + uint16_t n_desc; /* see <mach-o/stab.h> */ + uint64_t n_value; /* value of this symbol (or stab offset) */ +}; + +/* + * Symbols with a index into the string table of zero (n_un.n_strx == 0) are + * defined to have a null, "", name. Therefore all string indexes to non null + * names must not have a zero string index. This is bit historical information + * that has never been well documented. + */ + +/* + * The n_type field really contains four fields: + * unsigned char N_STAB:3, + * N_PEXT:1, + * N_TYPE:3, + * N_EXT:1; + * which are used via the following masks. + */ +#define N_STAB 0xe0 /* if any of these bits set, a symbolic debugging entry */ +#define N_PEXT 0x10 /* private external symbol bit */ +#define N_TYPE 0x0e /* mask for the type bits */ +#define N_EXT 0x01 /* external symbol bit, set for external symbols */ + +/* + * Only symbolic debugging entries have some of the N_STAB bits set and if any + * of these bits are set then it is a symbolic debugging entry (a stab). In + * which case then the values of the n_type field (the entire field) are given + * in <mach-o/stab.h> + */ + +/* + * Values for N_TYPE bits of the n_type field. + */ +#define N_UNDF 0x0 /* undefined, n_sect == NO_SECT */ +#define N_ABS 0x2 /* absolute, n_sect == NO_SECT */ +#define N_SECT 0xe /* defined in section number n_sect */ +#define N_PBUD 0xc /* prebound undefined (defined in a dylib) */ +#define N_INDR 0xa /* indirect */ + +/* + * If the type is N_INDR then the symbol is defined to be the same as another + * symbol. In this case the n_value field is an index into the string table + * of the other symbol's name. When the other symbol is defined then they both + * take on the defined type and value. + */ + +/* + * If the type is N_SECT then the n_sect field contains an ordinal of the + * section the symbol is defined in. The sections are numbered from 1 and + * refer to sections in order they appear in the load commands for the file + * they are in. This means the same ordinal may very well refer to different + * sections in different files. + * + * The n_value field for all symbol table entries (including N_STAB's) gets + * updated by the link editor based on the value of it's n_sect field and where + * the section n_sect references gets relocated. If the value of the n_sect + * field is NO_SECT then it's n_value field is not changed by the link editor. + */ +#define NO_SECT 0 /* symbol is not in any section */ +#define MAX_SECT 255 /* 1 thru 255 inclusive */ + +/* + * Common symbols are represented by undefined (N_UNDF) external (N_EXT) types + * who's values (n_value) are non-zero. In which case the value of the n_value + * field is the size (in bytes) of the common symbol. The n_sect field is set + * to NO_SECT. The alignment of a common symbol may be set as a power of 2 + * between 2^1 and 2^15 as part of the n_desc field using the macros below. If + * the alignment is not set (a value of zero) then natural alignment based on + * the size is used. + */ +#define GET_COMM_ALIGN(n_desc) (((n_desc) >> 8) & 0x0f) +#define SET_COMM_ALIGN(n_desc,align) \ + (n_desc) = (((n_desc) & 0xf0ff) | (((align) & 0x0f) << 8)) + +/* + * To support the lazy binding of undefined symbols in the dynamic link-editor, + * the undefined symbols in the symbol table (the nlist structures) are marked + * with the indication if the undefined reference is a lazy reference or + * non-lazy reference. If both a non-lazy reference and a lazy reference is + * made to the same symbol the non-lazy reference takes precedence. A reference + * is lazy only when all references to that symbol are made through a symbol + * pointer in a lazy symbol pointer section. + * + * The implementation of marking nlist structures in the symbol table for + * undefined symbols will be to use some of the bits of the n_desc field as a + * reference type. The mask REFERENCE_TYPE will be applied to the n_desc field + * of an nlist structure for an undefined symbol to determine the type of + * undefined reference (lazy or non-lazy). + * + * The constants for the REFERENCE FLAGS are propagated to the reference table + * in a shared library file. In that case the constant for a defined symbol, + * REFERENCE_FLAG_DEFINED, is also used. + */ +/* Reference type bits of the n_desc field of undefined symbols */ +#define REFERENCE_TYPE 0x7 +/* types of references */ +#define REFERENCE_FLAG_UNDEFINED_NON_LAZY 0 +#define REFERENCE_FLAG_UNDEFINED_LAZY 1 +#define REFERENCE_FLAG_DEFINED 2 +#define REFERENCE_FLAG_PRIVATE_DEFINED 3 +#define REFERENCE_FLAG_PRIVATE_UNDEFINED_NON_LAZY 4 +#define REFERENCE_FLAG_PRIVATE_UNDEFINED_LAZY 5 + +/* + * To simplify stripping of objects that use are used with the dynamic link + * editor, the static link editor marks the symbols defined an object that are + * referenced by a dynamicly bound object (dynamic shared libraries, bundles). + * With this marking strip knows not to strip these symbols. + */ +#define REFERENCED_DYNAMICALLY 0x0010 + +/* + * For images created by the static link editor with the -twolevel_namespace + * option in effect the flags field of the mach header is marked with + * MH_TWOLEVEL. And the binding of the undefined references of the image are + * determined by the static link editor. Which library an undefined symbol is + * bound to is recorded by the static linker in the high 8 bits of the n_desc + * field using the SET_LIBRARY_ORDINAL macro below. The ordinal recorded + * references the libraries listed in the Mach-O's LC_LOAD_DYLIB, + * LC_LOAD_WEAK_DYLIB, LC_REEXPORT_DYLIB, LC_LOAD_UPWARD_DYLIB, and + * LC_LAZY_LOAD_DYLIB, etc. load commands in the order they appear in the + * headers. The library ordinals start from 1. + * For a dynamic library that is built as a two-level namespace image the + * undefined references from module defined in another use the same nlist struct + * an in that case SELF_LIBRARY_ORDINAL is used as the library ordinal. For + * defined symbols in all images they also must have the library ordinal set to + * SELF_LIBRARY_ORDINAL. The EXECUTABLE_ORDINAL refers to the executable + * image for references from plugins that refer to the executable that loads + * them. + * + * The DYNAMIC_LOOKUP_ORDINAL is for undefined symbols in a two-level namespace + * image that are looked up by the dynamic linker with flat namespace semantics. + * This ordinal was added as a feature in Mac OS X 10.3 by reducing the + * value of MAX_LIBRARY_ORDINAL by one. So it is legal for existing binaries + * or binaries built with older tools to have 0xfe (254) dynamic libraries. In + * this case the ordinal value 0xfe (254) must be treated as a library ordinal + * for compatibility. + */ +#define GET_LIBRARY_ORDINAL(n_desc) (((n_desc) >> 8) & 0xff) +#define SET_LIBRARY_ORDINAL(n_desc,ordinal) \ + (n_desc) = (((n_desc) & 0x00ff) | (((ordinal) & 0xff) << 8)) +#define SELF_LIBRARY_ORDINAL 0x0 +#define MAX_LIBRARY_ORDINAL 0xfd +#define DYNAMIC_LOOKUP_ORDINAL 0xfe +#define EXECUTABLE_ORDINAL 0xff + +/* + * The bit 0x0020 of the n_desc field is used for two non-overlapping purposes + * and has two different symbolic names, N_NO_DEAD_STRIP and N_DESC_DISCARDED. + */ + +/* + * The N_NO_DEAD_STRIP bit of the n_desc field only ever appears in a + * relocatable .o file (MH_OBJECT filetype). And is used to indicate to the + * static link editor it is never to dead strip the symbol. + */ +#define N_NO_DEAD_STRIP 0x0020 /* symbol is not to be dead stripped */ + +/* + * The N_DESC_DISCARDED bit of the n_desc field never appears in linked image. + * But is used in very rare cases by the dynamic link editor to mark an in + * memory symbol as discared and longer used for linking. + */ +#define N_DESC_DISCARDED 0x0020 /* symbol is discarded */ + +/* + * The N_WEAK_REF bit of the n_desc field indicates to the dynamic linker that + * the undefined symbol is allowed to be missing and is to have the address of + * zero when missing. + */ +#define N_WEAK_REF 0x0040 /* symbol is weak referenced */ + +/* + * The N_WEAK_DEF bit of the n_desc field indicates to the static and dynamic + * linkers that the symbol definition is weak, allowing a non-weak symbol to + * also be used which causes the weak definition to be discared. Currently this + * is only supported for symbols in coalesed sections. + */ +#define N_WEAK_DEF 0x0080 /* coalesed symbol is a weak definition */ + +/* + * The N_REF_TO_WEAK bit of the n_desc field indicates to the dynamic linker + * that the undefined symbol should be resolved using flat namespace searching. + */ +#define N_REF_TO_WEAK 0x0080 /* reference to a weak symbol */ + +/* + * The N_ARM_THUMB_DEF bit of the n_desc field indicates that the symbol is + * a defintion of a Thumb function. + */ +#define N_ARM_THUMB_DEF 0x0008 /* symbol is a Thumb function (ARM) */ + +/* + * The N_SYMBOL_RESOLVER bit of the n_desc field indicates that the + * that the function is actually a resolver function and should + * be called to get the address of the real function to use. + * This bit is only available in .o files (MH_OBJECT filetype) + */ +#define N_SYMBOL_RESOLVER 0x0100 + +#ifndef __STRICT_BSD__ +#if __cplusplus +extern "C" { +#endif /* __cplusplus */ +/* + * The function nlist(3) from the C library. + */ +extern int nlist (const char *filename, struct nlist *list); +#if __cplusplus +} +#endif /* __cplusplus */ +#endif /* __STRICT_BSD__ */ + +#endif /* _MACHO_LIST_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach-o/stab.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach-o/stab.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach-o/stab.h (revision 885) @@ -0,0 +1,122 @@ +/* + * Copyright (c) 1999 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 _MACHO_STAB_H_ +#define _MACHO_STAB_H_ +/* $NetBSD: stab.h,v 1.4 1994/10/26 00:56:25 cgd Exp $ */ + +/*- + * Copyright (c) 1991 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)stab.h 5.2 (Berkeley) 4/4/91 + */ + +/* + * This file gives definitions supplementing <nlist.h> for permanent symbol + * table entries of Mach-O files. Modified from the BSD definitions. The + * modifications from the original definitions were changing what the values of + * what was the n_other field (an unused field) which is now the n_sect field. + * These modifications are required to support symbols in an arbitrary number of + * sections not just the three sections (text, data and bss) in a BSD file. + * The values of the defined constants have NOT been changed. + * + * These must have one of the N_STAB bits on. The n_value fields are subject + * to relocation according to the value of their n_sect field. So for types + * that refer to things in sections the n_sect field must be filled in with the + * proper section ordinal. For types that are not to have their n_value field + * relocatated the n_sect field must be NO_SECT. + */ + +/* + * Symbolic debugger symbols. The comments give the conventional use for + * + * .stabs "n_name", n_type, n_sect, n_desc, n_value + * + * where n_type is the defined constant and not listed in the comment. Other + * fields not listed are zero. n_sect is the section ordinal the entry is + * refering to. + */ +#define N_GSYM 0x20 /* global symbol: name,,NO_SECT,type,0 */ +#define N_FNAME 0x22 /* procedure name (f77 kludge): name,,NO_SECT,0,0 */ +#define N_FUN 0x24 /* procedure: name,,n_sect,linenumber,address */ +#define N_STSYM 0x26 /* static symbol: name,,n_sect,type,address */ +#define N_LCSYM 0x28 /* .lcomm symbol: name,,n_sect,type,address */ +#define N_BNSYM 0x2e /* begin nsect sym: 0,,n_sect,0,address */ +#define N_OPT 0x3c /* emitted with gcc2_compiled and in gcc source */ +#define N_RSYM 0x40 /* register sym: name,,NO_SECT,type,register */ +#define N_SLINE 0x44 /* src line: 0,,n_sect,linenumber,address */ +#define N_ENSYM 0x4e /* end nsect sym: 0,,n_sect,0,address */ +#define N_SSYM 0x60 /* structure elt: name,,NO_SECT,type,struct_offset */ +#define N_SO 0x64 /* source file name: name,,n_sect,0,address */ +#define N_OSO 0x66 /* object file name: name,,0,0,st_mtime */ +#define N_LSYM 0x80 /* local sym: name,,NO_SECT,type,offset */ +#define N_BINCL 0x82 /* include file beginning: name,,NO_SECT,0,sum */ +#define N_SOL 0x84 /* #included file name: name,,n_sect,0,address */ +#define N_PARAMS 0x86 /* compiler parameters: name,,NO_SECT,0,0 */ +#define N_VERSION 0x88 /* compiler version: name,,NO_SECT,0,0 */ +#define N_OLEVEL 0x8A /* compiler -O level: name,,NO_SECT,0,0 */ +#define N_PSYM 0xa0 /* parameter: name,,NO_SECT,type,offset */ +#define N_EINCL 0xa2 /* include file end: name,,NO_SECT,0,0 */ +#define N_ENTRY 0xa4 /* alternate entry: name,,n_sect,linenumber,address */ +#define N_LBRAC 0xc0 /* left bracket: 0,,NO_SECT,nesting level,address */ +#define N_EXCL 0xc2 /* deleted include file: name,,NO_SECT,0,sum */ +#define N_RBRAC 0xe0 /* right bracket: 0,,NO_SECT,nesting level,address */ +#define N_BCOMM 0xe2 /* begin common: name,,NO_SECT,0,0 */ +#define N_ECOMM 0xe4 /* end common: name,,n_sect,0,0 */ +#define N_ECOML 0xe8 /* end common (local name): 0,,n_sect,0,address */ +#define N_LENG 0xfe /* second stab entry with length information */ + +/* + * for the berkeley pascal compiler, pc(1): + */ +#define N_PC 0x30 /* global pascal symbol: name,,NO_SECT,subtype,line */ + +#endif /* _MACHO_STAB_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach-o/dyld.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach-o/dyld.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach-o/dyld.h (revision 885) @@ -0,0 +1,253 @@ +/* + * Copyright (c) 1999-2008 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 _MACH_O_DYLD_H_ +#define _MACH_O_DYLD_H_ + + +#include <stddef.h> +#include <stdint.h> +#include <stdbool.h> + +#include <mach-o/loader.h> +#include <Availability.h> + +#if __cplusplus +extern "C" { +#endif + +/* + * The following functions allow you to iterate through all loaded images. + * This is not a thread safe operation. Another thread can add or remove + * an image during the iteration. + * + * Many uses of these routines can be replace by a call to dladdr() which + * will return the mach_header and name of an image, given an address in + * the image. dladdr() is thread safe. + */ +extern uint32_t _dyld_image_count(void) __OSX_AVAILABLE_STARTING(__MAC_10_1, __IPHONE_2_0); +extern const struct mach_header* _dyld_get_image_header(uint32_t image_index) __OSX_AVAILABLE_STARTING(__MAC_10_1, __IPHONE_2_0); +extern intptr_t _dyld_get_image_vmaddr_slide(uint32_t image_index) __OSX_AVAILABLE_STARTING(__MAC_10_1, __IPHONE_2_0); +extern const char* _dyld_get_image_name(uint32_t image_index) __OSX_AVAILABLE_STARTING(__MAC_10_1, __IPHONE_2_0); + + +/* + * The following functions allow you to install callbacks which will be called + * by dyld whenever an image is loaded or unloaded. During a call to _dyld_register_func_for_add_image() + * the callback func is called for every existing image. Later, it is called as each new image + * is loaded and bound (but initializers not yet run). The callback registered with + * _dyld_register_func_for_remove_image() is called after any terminators in an image are run + * and before the image is un-memory-mapped. + */ +extern void _dyld_register_func_for_add_image(void (*func)(const struct mach_header* mh, intptr_t vmaddr_slide)) __OSX_AVAILABLE_STARTING(__MAC_10_1, __IPHONE_2_0); +extern void _dyld_register_func_for_remove_image(void (*func)(const struct mach_header* mh, intptr_t vmaddr_slide)) __OSX_AVAILABLE_STARTING(__MAC_10_1, __IPHONE_2_0); + + +/* + * NSVersionOfRunTimeLibrary() returns the current_version number of the currently dylib + * specifed by the libraryName. The libraryName parameter would be "bar" for /path/libbar.3.dylib and + * "Foo" for /path/Foo.framework/Versions/A/Foo. It returns -1 if no such library is loaded. + */ +extern int32_t NSVersionOfRunTimeLibrary(const char* libraryName) __OSX_AVAILABLE_STARTING(__MAC_10_1, __IPHONE_2_0); + + +/* + * NSVersionOfRunTimeLibrary() returns the current_version number that the main executable was linked + * against at build time. The libraryName parameter would be "bar" for /path/libbar.3.dylib and + * "Foo" for /path/Foo.framework/Versions/A/Foo. It returns -1 if the main executable did not link + * against the specified library. + */ +extern int32_t NSVersionOfLinkTimeLibrary(const char* libraryName) __OSX_AVAILABLE_STARTING(__MAC_10_1, __IPHONE_2_0); + + +/* + * _NSGetExecutablePath() copies the path of the main executable into the buffer. The bufsize parameter + * should initially be the size of the buffer. The function returns 0 if the path was successfully copied, + * and *bufsize is left unchanged. It returns -1 if the buffer is not large enough, and *bufsize is set + * to the size required. + * + * Note that _NSGetExecutablePath will return "a path" to the executable not a "real path" to the executable. + * That is the path may be a symbolic link and not the real file. With deep directories the total bufsize + * needed could be more than MAXPATHLEN. + */ +extern int _NSGetExecutablePath(char* buf, uint32_t* bufsize) __OSX_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_2_0); + + + +/* + * _dyld_moninit() is a private interface between dyld and libSystem. + */ +extern void _dyld_moninit(void (*monaddition)(char *lowpc, char *highpc)) __OSX_AVAILABLE_STARTING(__MAC_10_1, __IPHONE_2_0); + + + + + +/* + * The following dyld API's are deprecated as of Mac OS X 10.5. They are either + * no longer necessary or are superceeded by dlopen and friends in <dlfcn.h>. + * dlopen/dlsym/dlclose have been available since Mac OS X 10.3 and work with + * dylibs and bundles. + * + * NSAddImage -> dlopen + * NSLookupSymbolInImage -> dlsym + * NSCreateObjectFileImageFromFile -> dlopen + * NSDestroyObjectFileImage -> dlclose + * NSLinkModule -> not needed when dlopen used + * NSUnLinkModule -> not needed when dlclose used + * NSLookupSymbolInModule -> dlsym + * _dyld_image_containing_address -> dladdr + * NSLinkEditError -> dlerror + * + */ + +#ifndef ENUM_DYLD_BOOL +#define ENUM_DYLD_BOOL + #undef FALSE + #undef TRUE + enum DYLD_BOOL { FALSE, TRUE }; +#endif /* ENUM_DYLD_BOOL */ + + +/* Object file image API */ +typedef enum { + NSObjectFileImageFailure, /* for this a message is printed on stderr */ + NSObjectFileImageSuccess, + NSObjectFileImageInappropriateFile, + NSObjectFileImageArch, + NSObjectFileImageFormat, /* for this a message is printed on stderr */ + NSObjectFileImageAccess +} NSObjectFileImageReturnCode; + +typedef struct __NSObjectFileImage* NSObjectFileImage; + +/* NSObjectFileImage can only be used with MH_BUNDLE files */ +extern NSObjectFileImageReturnCode NSCreateObjectFileImageFromFile(const char* pathName, NSObjectFileImage *objectFileImage) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_5,__IPHONE_NA,__IPHONE_NA); +extern NSObjectFileImageReturnCode NSCreateObjectFileImageFromMemory(const void *address, size_t size, NSObjectFileImage *objectFileImage) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_5,__IPHONE_NA,__IPHONE_NA); +extern bool NSDestroyObjectFileImage(NSObjectFileImage objectFileImage) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_5,__IPHONE_NA,__IPHONE_NA); + +extern uint32_t NSSymbolDefinitionCountInObjectFileImage(NSObjectFileImage objectFileImage) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_5,__IPHONE_NA,__IPHONE_NA); +extern const char* NSSymbolDefinitionNameInObjectFileImage(NSObjectFileImage objectFileImage, uint32_t ordinal) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_5,__IPHONE_NA,__IPHONE_NA); +extern uint32_t NSSymbolReferenceCountInObjectFileImage(NSObjectFileImage objectFileImage) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_5,__IPHONE_NA,__IPHONE_NA); +extern const char* NSSymbolReferenceNameInObjectFileImage(NSObjectFileImage objectFileImage, uint32_t ordinal, bool *tentative_definition) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_5,__IPHONE_NA,__IPHONE_NA); +extern bool NSIsSymbolDefinedInObjectFileImage(NSObjectFileImage objectFileImage, const char* symbolName) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_4,__IPHONE_NA,__IPHONE_NA); +extern void* NSGetSectionDataInObjectFileImage(NSObjectFileImage objectFileImage, const char* segmentName, const char* sectionName, size_t *size) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_5,__IPHONE_NA,__IPHONE_NA); +extern bool NSHasModInitObjectFileImage(NSObjectFileImage objectFileImage) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3,__MAC_10_5,__IPHONE_NA,__IPHONE_NA); + +typedef struct __NSModule* NSModule; +extern const char* NSNameOfModule(NSModule m) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_5,__IPHONE_NA,__IPHONE_NA); +extern const char* NSLibraryNameForModule(NSModule m) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_5,__IPHONE_NA,__IPHONE_NA); + +extern NSModule NSLinkModule(NSObjectFileImage objectFileImage, const char* moduleName, uint32_t options) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_5,__IPHONE_NA,__IPHONE_NA); +#define NSLINKMODULE_OPTION_NONE 0x0 +#define NSLINKMODULE_OPTION_BINDNOW 0x1 +#define NSLINKMODULE_OPTION_PRIVATE 0x2 +#define NSLINKMODULE_OPTION_RETURN_ON_ERROR 0x4 +#define NSLINKMODULE_OPTION_DONT_CALL_MOD_INIT_ROUTINES 0x8 +#define NSLINKMODULE_OPTION_TRAILING_PHYS_NAME 0x10 + +extern bool NSUnLinkModule(NSModule module, uint32_t options) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_5,__IPHONE_NA,__IPHONE_NA); +#define NSUNLINKMODULE_OPTION_NONE 0x0 +#define NSUNLINKMODULE_OPTION_KEEP_MEMORY_MAPPED 0x1 +#define NSUNLINKMODULE_OPTION_RESET_LAZY_REFERENCES 0x2 + +/* symbol API */ +typedef struct __NSSymbol* NSSymbol; +extern bool NSIsSymbolNameDefined(const char* symbolName) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_4,__IPHONE_NA,__IPHONE_NA); +extern bool NSIsSymbolNameDefinedWithHint(const char* symbolName, const char* libraryNameHint) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_4,__IPHONE_NA,__IPHONE_NA); +extern bool NSIsSymbolNameDefinedInImage(const struct mach_header* image, const char* symbolName) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_4,__IPHONE_NA,__IPHONE_NA); +extern NSSymbol NSLookupAndBindSymbol(const char* symbolName) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_4,__IPHONE_NA,__IPHONE_NA); +extern NSSymbol NSLookupAndBindSymbolWithHint(const char* symbolName, const char* libraryNameHint) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_4,__IPHONE_NA,__IPHONE_NA); +extern NSSymbol NSLookupSymbolInModule(NSModule module, const char* symbolName) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_5,__IPHONE_NA,__IPHONE_NA); +extern NSSymbol NSLookupSymbolInImage(const struct mach_header* image, const char* symbolName, uint32_t options) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_5,__IPHONE_NA,__IPHONE_NA); +#define NSLOOKUPSYMBOLINIMAGE_OPTION_BIND 0x0 +#define NSLOOKUPSYMBOLINIMAGE_OPTION_BIND_NOW 0x1 +#define NSLOOKUPSYMBOLINIMAGE_OPTION_BIND_FULLY 0x2 +#define NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR 0x4 +extern const char* NSNameOfSymbol(NSSymbol symbol) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_5,__IPHONE_NA,__IPHONE_NA); +extern void * NSAddressOfSymbol(NSSymbol symbol) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_5,__IPHONE_NA,__IPHONE_NA); +extern NSModule NSModuleForSymbol(NSSymbol symbol) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_5,__IPHONE_NA,__IPHONE_NA); + +/* error handling API */ +typedef enum { + NSLinkEditFileAccessError, + NSLinkEditFileFormatError, + NSLinkEditMachResourceError, + NSLinkEditUnixResourceError, + NSLinkEditOtherError, + NSLinkEditWarningError, + NSLinkEditMultiplyDefinedError, + NSLinkEditUndefinedError +} NSLinkEditErrors; + +/* + * For the NSLinkEditErrors value NSLinkEditOtherError these are the values + * passed to the link edit error handler as the errorNumber (what would be an + * errno value for NSLinkEditUnixResourceError or a kern_return_t value for + * NSLinkEditMachResourceError). + */ +typedef enum { + NSOtherErrorRelocation, + NSOtherErrorLazyBind, + NSOtherErrorIndrLoop, + NSOtherErrorLazyInit, + NSOtherErrorInvalidArgs +} NSOtherErrorNumbers; + +extern void NSLinkEditError(NSLinkEditErrors *c, int *errorNumber, const char** fileName, const char** errorString) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_5,__IPHONE_NA,__IPHONE_NA); + +typedef struct { + void (*undefined)(const char* symbolName); + NSModule (*multiple)(NSSymbol s, NSModule oldModule, NSModule newModule); + void (*linkEdit)(NSLinkEditErrors errorClass, int errorNumber, + const char* fileName, const char* errorString); +} NSLinkEditErrorHandlers; + +extern void NSInstallLinkEditErrorHandlers(const NSLinkEditErrorHandlers *handlers) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_5,__IPHONE_NA,__IPHONE_NA); + +extern bool NSAddLibrary(const char* pathName) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_4,__IPHONE_NA,__IPHONE_NA); +extern bool NSAddLibraryWithSearching(const char* pathName) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_4,__IPHONE_NA,__IPHONE_NA); +extern const struct mach_header* NSAddImage(const char* image_name, uint32_t options) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_5,__IPHONE_NA,__IPHONE_NA); +#define NSADDIMAGE_OPTION_NONE 0x0 +#define NSADDIMAGE_OPTION_RETURN_ON_ERROR 0x1 +#define NSADDIMAGE_OPTION_WITH_SEARCHING 0x2 +#define NSADDIMAGE_OPTION_RETURN_ONLY_IF_LOADED 0x4 +#define NSADDIMAGE_OPTION_MATCH_FILENAME_BY_INSTALLNAME 0x8 + +extern bool _dyld_present(void) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_5,__IPHONE_NA,__IPHONE_NA); +extern bool _dyld_launched_prebound(void) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_5,__IPHONE_NA,__IPHONE_NA); +extern bool _dyld_all_twolevel_modules_prebound(void) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3,__MAC_10_5,__IPHONE_NA,__IPHONE_NA); +extern void _dyld_bind_objc_module(const void* objc_module) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_5,__IPHONE_NA,__IPHONE_NA); +extern bool _dyld_bind_fully_image_containing_address(const void* address) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_5,__IPHONE_NA,__IPHONE_NA); +extern bool _dyld_image_containing_address(const void* address) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3,__MAC_10_5,__IPHONE_NA,__IPHONE_NA); +extern void _dyld_lookup_and_bind(const char* symbol_name, void **address, NSModule* module) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_4,__IPHONE_NA,__IPHONE_NA); +extern void _dyld_lookup_and_bind_with_hint(const char* symbol_name, const char* library_name_hint, void** address, NSModule* module) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_4,__IPHONE_NA,__IPHONE_NA); +extern void _dyld_lookup_and_bind_fully(const char* symbol_name, void** address, NSModule* module) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_5,__IPHONE_NA,__IPHONE_NA); + +extern const struct mach_header* _dyld_get_image_header_containing_address(const void* address) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3,__MAC_10_5,__IPHONE_NA,__IPHONE_NA); + + +#if __cplusplus +} +#endif + +#endif /* _MACH_O_DYLD_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach-o/ppc/swap.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach-o/ppc/swap.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach-o/ppc/swap.h (revision 885) @@ -0,0 +1,36 @@ +/* + * Copyright (c) 1999 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@ + */ +#include <architecture/byte_order.h> +#include <mach/ppc/thread_status.h> + +extern void swap_ppc_thread_state_t( + ppc_thread_state_t *cpu, + enum NXByteOrder target_byte_sex); + +extern void swap_ppc_float_state_t( + ppc_float_state_t *fpu, + enum NXByteOrder target_byte_sex); + +extern void swap_ppc_exception_state_t( + ppc_exception_state_t *state, + enum NXByteOrder target_byte_sex); Index: branches/azimutz/Cleancut/i386/include/mach-o/ppc/reloc.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach-o/ppc/reloc.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach-o/ppc/reloc.h (revision 885) @@ -0,0 +1,65 @@ +/* + * Copyright (c) 1999 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@ + */ +/* + * Relocation types used in the ppc implementation. Relocation entries for + * things other than instructions use the same generic relocation as discribed + * above and their r_type is RELOC_VANILLA. The rest of the relocation types + * are for instructions. Since they are for instructions the r_address field + * indicates the 32 bit instruction that the relocation is to be preformed on. + * The fields r_pcrel and r_length are ignored for non-RELOC_VANILLA r_types + * except for PPC_RELOC_BR14. + * + * For PPC_RELOC_BR14 if the r_length is the unused value 3, then the branch was + * statically predicted setting or clearing the Y-bit based on the sign of the + * displacement or the opcode. If this is the case the static linker must flip + * the value of the Y-bit if the sign of the displacement changes for non-branch + * always conditions. + */ +enum reloc_type_ppc +{ + PPC_RELOC_VANILLA, /* generic relocation as discribed above */ + PPC_RELOC_PAIR, /* the second relocation entry of a pair */ + PPC_RELOC_BR14, /* 14 bit branch displacement (to a word address) */ + PPC_RELOC_BR24, /* 24 bit branch displacement (to a word address) */ + PPC_RELOC_HI16, /* a PAIR follows with the low half */ + PPC_RELOC_LO16, /* a PAIR follows with the high half */ + PPC_RELOC_HA16, /* Same as the RELOC_HI16 except the low 16 bits and the + * high 16 bits are added together with the low 16 bits + * sign extened first. This means if bit 15 of the low + * 16 bits is set the high 16 bits stored in the + * instruction will be adjusted. + */ + PPC_RELOC_LO14, /* Same as the LO16 except that the low 2 bits are not + * stored in the instruction and are always zero. This + * is used in double word load/store instructions. + */ + PPC_RELOC_SECTDIFF, /* a PAIR follows with subtract symbol value */ + PPC_RELOC_PB_LA_PTR,/* prebound lazy pointer */ + PPC_RELOC_HI16_SECTDIFF, /* section difference forms of above. a PAIR */ + PPC_RELOC_LO16_SECTDIFF, /* follows these with subtract symbol value */ + PPC_RELOC_HA16_SECTDIFF, + PPC_RELOC_JBSR, + PPC_RELOC_LO14_SECTDIFF, + PPC_RELOC_LOCAL_SECTDIFF /* like PPC_RELOC_SECTDIFF, but the symbol + referenced was local. */ +}; Index: branches/azimutz/Cleancut/i386/include/mach-o/getsect.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach-o/getsect.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach-o/getsect.h (revision 885) @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2004 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 _MACH_O_GETSECT_H_ +#define _MACH_O_GETSECT_H_ + +#include <stdint.h> +#include <mach-o/loader.h> + +#if __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* + * Runtime interfaces for Mach-O programs. For both 32-bit and 64-bit programs, + * where the sizes returned will be 32-bit or 64-bit based on the size of + * 'unsigned long'. + */ +extern char *getsectdata( + const char *segname, + const char *sectname, + unsigned long *size); + +extern char *getsectdatafromFramework( + const char *FrameworkName, + const char *segname, + const char *sectname, + unsigned long *size); + +extern unsigned long get_end(void); +extern unsigned long get_etext(void); +extern unsigned long get_edata(void); + +#ifndef __LP64__ +/* + * Runtime interfaces for 32-bit Mach-O programs. + */ +extern const struct section *getsectbyname( + const char *segname, + const char *sectname); + +extern uint8_t *getsectiondata( + const struct mach_header *mhp, + const char *segname, + const char *sectname, + unsigned long *size); + +extern const struct segment_command *getsegbyname( + const char *segname); + +extern uint8_t *getsegmentdata( + const struct mach_header *mhp, + const char *segname, + unsigned long *size); + +#else /* defined(__LP64__) */ +/* + * Runtime interfaces for 64-bit Mach-O programs. + */ +extern const struct section_64 *getsectbyname( + const char *segname, + const char *sectname); + +extern uint8_t *getsectiondata( + const struct mach_header_64 *mhp, + const char *segname, + const char *sectname, + unsigned long *size); + +extern const struct segment_command_64 *getsegbyname( + const char *segname); + +extern uint8_t *getsegmentdata( + const struct mach_header_64 *mhp, + const char *segname, + unsigned long *size); + +#endif /* defined(__LP64__) */ + +/* + * Interfaces for tools working with 32-bit Mach-O files. + */ +extern char *getsectdatafromheader( + const struct mach_header *mhp, + const char *segname, + const char *sectname, + uint32_t *size); + +extern const struct section *getsectbynamefromheader( + const struct mach_header *mhp, + const char *segname, + const char *sectname); + +/* + * Interfaces for tools working with 64-bit Mach-O files. + */ +extern char *getsectdatafromheader_64( + const struct mach_header_64 *mhp, + const char *segname, + const char *sectname, + uint64_t *size); + +extern const struct section_64 *getsectbynamefromheader_64( + const struct mach_header_64 *mhp, + const char *segname, + const char *sectname); + +#if __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _MACH_O_GETSECT_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach-o/i386/swap.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach-o/i386/swap.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach-o/i386/swap.h (revision 885) @@ -0,0 +1,96 @@ +/* + * Copyright (c) 1999 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@ + */ +#include <architecture/byte_order.h> +#include <mach/i386/thread_status.h> + +extern void swap_i386_thread_state( + i386_thread_state_t *cpu, + enum NXByteOrder target_byte_order); + +/* current i386 thread states */ +#if i386_THREAD_STATE == 1 +extern void swap_i386_float_state( + struct i386_float_state *fpu, + enum NXByteOrder target_byte_order); + +extern void swap_i386_exception_state( + i386_exception_state_t *exc, + enum NXByteOrder target_byte_order); +#endif /* i386_THREAD_STATE == 1 */ + +/* i386 thread states on older releases */ +#if i386_THREAD_STATE == -1 +extern void swap_i386_thread_fpstate( + i386_thread_fpstate_t *fpu, + enum NXByteOrder target_byte_order); + +extern void swap_i386_thread_exceptstate( + i386_thread_exceptstate_t *exc, + enum NXByteOrder target_byte_order); + +extern void swap_i386_thread_cthreadstate( + i386_thread_cthreadstate_t *user, + enum NXByteOrder target_byte_order); +#endif /* i386_THREAD_STATE == -1 */ + +#ifdef x86_THREAD_STATE64 +extern void swap_x86_thread_state64( + x86_thread_state64_t *cpu, + enum NXByteOrder target_byte_order); + +extern void swap_x86_state_hdr( + x86_state_hdr_t *hdr, + enum NXByteOrder target_byte_order); + +extern void swap_x86_float_state64( + x86_float_state64_t *fpu, + enum NXByteOrder target_byte_order); + +extern void swap_x86_exception_state64( + x86_exception_state64_t *exc, + enum NXByteOrder target_byte_order); + +extern void swap_x86_thread_state( + x86_thread_state_t *cpu, + enum NXByteOrder target_byte_order); + +extern void swap_x86_float_state( + x86_float_state_t *fpu, + enum NXByteOrder target_byte_order); + +extern void swap_x86_exception_state( + x86_exception_state_t *exc, + enum NXByteOrder target_byte_order); + +extern void swap_x86_debug_state32( + x86_debug_state32_t *debug, + enum NXByteOrder target_byte_order); + +extern void swap_x86_debug_state64( + x86_debug_state64_t *debug, + enum NXByteOrder target_byte_order); + +extern void swap_x86_debug_state( + x86_debug_state_t *debug, + enum NXByteOrder target_byte_order); +#endif /* x86_THREAD_STATE64 */ Index: branches/azimutz/Cleancut/i386/include/mach-o/reloc.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach-o/reloc.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach-o/reloc.h (revision 885) @@ -0,0 +1,203 @@ +/* + * Copyright (c) 1999 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@ + */ +/* $NetBSD: exec.h,v 1.6 1994/10/27 04:16:05 cgd Exp $ */ + +/* + * Copyright (c) 1993 Christopher G. Demetriou + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _MACHO_RELOC_H_ +#define _MACHO_RELOC_H_ +#include <stdint.h> + +/* + * Format of a relocation entry of a Mach-O file. Modified from the 4.3BSD + * format. The modifications from the original format were changing the value + * of the r_symbolnum field for "local" (r_extern == 0) relocation entries. + * This modification is required to support symbols in an arbitrary number of + * sections not just the three sections (text, data and bss) in a 4.3BSD file. + * Also the last 4 bits have had the r_type tag added to them. + */ +struct relocation_info { + int32_t r_address; /* offset in the section to what is being + relocated */ + uint32_t r_symbolnum:24, /* symbol index if r_extern == 1 or section + ordinal if r_extern == 0 */ + r_pcrel:1, /* was relocated pc relative already */ + r_length:2, /* 0=byte, 1=word, 2=long, 3=quad */ + r_extern:1, /* does not include value of sym referenced */ + r_type:4; /* if not 0, machine specific relocation type */ +}; +#define R_ABS 0 /* absolute relocation type for Mach-O files */ + +/* + * The r_address is not really the address as it's name indicates but an offset. + * In 4.3BSD a.out objects this offset is from the start of the "segment" for + * which relocation entry is for (text or data). For Mach-O object files it is + * also an offset but from the start of the "section" for which the relocation + * entry is for. See comments in <mach-o/loader.h> about the r_address feild + * in images for used with the dynamic linker. + * + * In 4.3BSD a.out objects if r_extern is zero then r_symbolnum is an ordinal + * for the segment the symbol being relocated is in. These ordinals are the + * symbol types N_TEXT, N_DATA, N_BSS or N_ABS. In Mach-O object files these + * ordinals refer to the sections in the object file in the order their section + * structures appear in the headers of the object file they are in. The first + * section has the ordinal 1, the second 2, and so on. This means that the + * same ordinal in two different object files could refer to two different + * sections. And further could have still different ordinals when combined + * by the link-editor. The value R_ABS is used for relocation entries for + * absolute symbols which need no further relocation. + */ + +/* + * For RISC machines some of the references are split across two instructions + * and the instruction does not contain the complete value of the reference. + * In these cases a second, or paired relocation entry, follows each of these + * relocation entries, using a PAIR r_type, which contains the other part of the + * reference not contained in the instruction. This other part is stored in the + * pair's r_address field. The exact number of bits of the other part of the + * reference store in the r_address field is dependent on the particular + * relocation type for the particular architecture. + */ + +/* + * To make scattered loading by the link editor work correctly "local" + * relocation entries can't be used when the item to be relocated is the value + * of a symbol plus an offset (where the resulting expresion is outside the + * block the link editor is moving, a blocks are divided at symbol addresses). + * In this case. where the item is a symbol value plus offset, the link editor + * needs to know more than just the section the symbol was defined. What is + * needed is the actual value of the symbol without the offset so it can do the + * relocation correctly based on where the value of the symbol got relocated to + * not the value of the expression (with the offset added to the symbol value). + * So for the NeXT 2.0 release no "local" relocation entries are ever used when + * there is a non-zero offset added to a symbol. The "external" and "local" + * relocation entries remain unchanged. + * + * The implemention is quite messy given the compatibility with the existing + * relocation entry format. The ASSUMPTION is that a section will never be + * bigger than 2**24 - 1 (0x00ffffff or 16,777,215) bytes. This assumption + * allows the r_address (which is really an offset) to fit in 24 bits and high + * bit of the r_address field in the relocation_info structure to indicate + * it is really a scattered_relocation_info structure. Since these are only + * used in places where "local" relocation entries are used and not where + * "external" relocation entries are used the r_extern field has been removed. + * + * For scattered loading to work on a RISC machine where some of the references + * are split across two instructions the link editor needs to be assured that + * each reference has a unique 32 bit reference (that more than one reference is + * NOT sharing the same high 16 bits for example) so it move each referenced + * item independent of each other. Some compilers guarantees this but the + * compilers don't so scattered loading can be done on those that do guarantee + * this. + */ +#if defined(__BIG_ENDIAN__) || defined(__LITTLE_ENDIAN__) +/* + * The reason for the ifdef's of __BIG_ENDIAN__ and __LITTLE_ENDIAN__ are that + * when stattered relocation entries were added the mistake of using a mask + * against a structure that is made up of bit fields was used. To make this + * design work this structure must be laid out in memory the same way so the + * mask can be applied can check the same bit each time (r_scattered). + */ +#endif /* defined(__BIG_ENDIAN__) || defined(__LITTLE_ENDIAN__) */ +#define R_SCATTERED 0x80000000 /* mask to be applied to the r_address field + of a relocation_info structure to tell that + is is really a scattered_relocation_info + stucture */ +struct scattered_relocation_info { +#ifdef __BIG_ENDIAN__ + uint32_t r_scattered:1, /* 1=scattered, 0=non-scattered (see above) */ + r_pcrel:1, /* was relocated pc relative already */ + r_length:2, /* 0=byte, 1=word, 2=long, 3=quad */ + r_type:4, /* if not 0, machine specific relocation type */ + r_address:24; /* offset in the section to what is being + relocated */ + int32_t r_value; /* the value the item to be relocated is + refering to (without any offset added) */ +#endif /* __BIG_ENDIAN__ */ +#ifdef __LITTLE_ENDIAN__ + uint32_t + r_address:24, /* offset in the section to what is being + relocated */ + r_type:4, /* if not 0, machine specific relocation type */ + r_length:2, /* 0=byte, 1=word, 2=long, 3=quad */ + r_pcrel:1, /* was relocated pc relative already */ + r_scattered:1; /* 1=scattered, 0=non-scattered (see above) */ + int32_t r_value; /* the value the item to be relocated is + refering to (without any offset added) */ +#endif /* __LITTLE_ENDIAN__ */ +}; + +/* + * Relocation types used in a generic implementation. Relocation entries for + * normal things use the generic relocation as discribed above and their r_type + * is GENERIC_RELOC_VANILLA (a value of zero). + * + * Another type of generic relocation, GENERIC_RELOC_SECTDIFF, is to support + * the difference of two symbols defined in different sections. That is the + * expression "symbol1 - symbol2 + constant" is a relocatable expression when + * both symbols are defined in some section. For this type of relocation the + * both relocations entries are scattered relocation entries. The value of + * symbol1 is stored in the first relocation entry's r_value field and the + * value of symbol2 is stored in the pair's r_value field. + * + * A special case for a prebound lazy pointer is needed to beable to set the + * value of the lazy pointer back to its non-prebound state. This is done + * using the GENERIC_RELOC_PB_LA_PTR r_type. This is a scattered relocation + * entry where the r_value feild is the value of the lazy pointer not prebound. + */ +enum reloc_type_generic +{ + GENERIC_RELOC_VANILLA, /* generic relocation as discribed above */ + GENERIC_RELOC_PAIR, /* Only follows a GENERIC_RELOC_SECTDIFF */ + GENERIC_RELOC_SECTDIFF, + GENERIC_RELOC_PB_LA_PTR, /* prebound lazy pointer */ + GENERIC_RELOC_LOCAL_SECTDIFF, + GENERIC_RELOC_TLV /* thread local variables */ +}; + +#endif /* _MACHO_RELOC_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach-o/loader.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach-o/loader.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach-o/loader.h (revision 885) @@ -0,0 +1,1402 @@ +/* + * Copyright (c) 1999-2010 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 _MACHO_LOADER_H_ +#define _MACHO_LOADER_H_ + +/* + * This file describes the format of mach object files. + */ +#include <stdint.h> + +/* + * <mach/machine.h> is needed here for the cpu_type_t and cpu_subtype_t types + * and contains the constants for the possible values of these types. + */ +#include <mach/machine.h> + +/* + * <mach/vm_prot.h> is needed here for the vm_prot_t type and contains the + * constants that are or'ed together for the possible values of this type. + */ +#include <mach/vm_prot.h> + +/* + * <machine/thread_status.h> is expected to define the flavors of the thread + * states and the structures of those flavors for each machine. + */ +#include <mach/machine/thread_status.h> +#include <architecture/byte_order.h> + +/* + * The 32-bit mach header appears at the very beginning of the object file for + * 32-bit architectures. + */ +struct mach_header { + uint32_t magic; /* mach magic number identifier */ + cpu_type_t cputype; /* cpu specifier */ + cpu_subtype_t cpusubtype; /* machine specifier */ + uint32_t filetype; /* type of file */ + uint32_t ncmds; /* number of load commands */ + uint32_t sizeofcmds; /* the size of all the load commands */ + uint32_t flags; /* flags */ +}; + +/* Constant for the magic field of the mach_header (32-bit architectures) */ +#define MH_MAGIC 0xfeedface /* the mach magic number */ +#define MH_CIGAM 0xcefaedfe /* NXSwapInt(MH_MAGIC) */ + +/* + * The 64-bit mach header appears at the very beginning of object files for + * 64-bit architectures. + */ +struct mach_header_64 { + uint32_t magic; /* mach magic number identifier */ + cpu_type_t cputype; /* cpu specifier */ + cpu_subtype_t cpusubtype; /* machine specifier */ + uint32_t filetype; /* type of file */ + uint32_t ncmds; /* number of load commands */ + uint32_t sizeofcmds; /* the size of all the load commands */ + uint32_t flags; /* flags */ + uint32_t reserved; /* reserved */ +}; + +/* Constant for the magic field of the mach_header_64 (64-bit architectures) */ +#define MH_MAGIC_64 0xfeedfacf /* the 64-bit mach magic number */ +#define MH_CIGAM_64 0xcffaedfe /* NXSwapInt(MH_MAGIC_64) */ + +/* + * The layout of the file depends on the filetype. For all but the MH_OBJECT + * file type the segments are padded out and aligned on a segment alignment + * boundary for efficient demand pageing. The MH_EXECUTE, MH_FVMLIB, MH_DYLIB, + * MH_DYLINKER and MH_BUNDLE file types also have the headers included as part + * of their first segment. + * + * The file type MH_OBJECT is a compact format intended as output of the + * assembler and input (and possibly output) of the link editor (the .o + * format). All sections are in one unnamed segment with no segment padding. + * This format is used as an executable format when the file is so small the + * segment padding greatly increases its size. + * + * The file type MH_PRELOAD is an executable format intended for things that + * are not executed under the kernel (proms, stand alones, kernels, etc). The + * format can be executed under the kernel but may demand paged it and not + * preload it before execution. + * + * A core file is in MH_CORE format and can be any in an arbritray legal + * Mach-O file. + * + * Constants for the filetype field of the mach_header + */ +#define MH_OBJECT 0x1 /* relocatable object file */ +#define MH_EXECUTE 0x2 /* demand paged executable file */ +#define MH_FVMLIB 0x3 /* fixed VM shared library file */ +#define MH_CORE 0x4 /* core file */ +#define MH_PRELOAD 0x5 /* preloaded executable file */ +#define MH_DYLIB 0x6 /* dynamically bound shared library */ +#define MH_DYLINKER 0x7 /* dynamic link editor */ +#define MH_BUNDLE 0x8 /* dynamically bound bundle file */ +#define MH_DYLIB_STUB 0x9 /* shared library stub for static */ + /* linking only, no section contents */ +#define MH_DSYM 0xa /* companion file with only debug */ + /* sections */ +#define MH_KEXT_BUNDLE 0xb /* x86_64 kexts */ + +/* Constants for the flags field of the mach_header */ +#define MH_NOUNDEFS 0x1 /* the object file has no undefined + references */ +#define MH_INCRLINK 0x2 /* the object file is the output of an + incremental link against a base file + and can't be link edited again */ +#define MH_DYLDLINK 0x4 /* the object file is input for the + dynamic linker and can't be staticly + link edited again */ +#define MH_BINDATLOAD 0x8 /* the object file's undefined + references are bound by the dynamic + linker when loaded. */ +#define MH_PREBOUND 0x10 /* the file has its dynamic undefined + references prebound. */ +#define MH_SPLIT_SEGS 0x20 /* the file has its read-only and + read-write segments split */ +#define MH_LAZY_INIT 0x40 /* the shared library init routine is + to be run lazily via catching memory + faults to its writeable segments + (obsolete) */ +#define MH_TWOLEVEL 0x80 /* the image is using two-level name + space bindings */ +#define MH_FORCE_FLAT 0x100 /* the executable is forcing all images + to use flat name space bindings */ +#define MH_NOMULTIDEFS 0x200 /* this umbrella guarantees no multiple + defintions of symbols in its + sub-images so the two-level namespace + hints can always be used. */ +#define MH_NOFIXPREBINDING 0x400 /* do not have dyld notify the + prebinding agent about this + executable */ +#define MH_PREBINDABLE 0x800 /* the binary is not prebound but can + have its prebinding redone. only used + when MH_PREBOUND is not set. */ +#define MH_ALLMODSBOUND 0x1000 /* indicates that this binary binds to + all two-level namespace modules of + its dependent libraries. only used + when MH_PREBINDABLE and MH_TWOLEVEL + are both set. */ +#define MH_SUBSECTIONS_VIA_SYMBOLS 0x2000/* safe to divide up the sections into + sub-sections via symbols for dead + code stripping */ +#define MH_CANONICAL 0x4000 /* the binary has been canonicalized + via the unprebind operation */ +#define MH_WEAK_DEFINES 0x8000 /* the final linked image contains + external weak symbols */ +#define MH_BINDS_TO_WEAK 0x10000 /* the final linked image uses + weak symbols */ + +#define MH_ALLOW_STACK_EXECUTION 0x20000/* When this bit is set, all stacks + in the task will be given stack + execution privilege. Only used in + MH_EXECUTE filetypes. */ +#define MH_ROOT_SAFE 0x40000 /* When this bit is set, the binary + declares it is safe for use in + processes with uid zero */ + +#define MH_SETUID_SAFE 0x80000 /* When this bit is set, the binary + declares it is safe for use in + processes when issetugid() is true */ + +#define MH_NO_REEXPORTED_DYLIBS 0x100000 /* When this bit is set on a dylib, + the static linker does not need to + examine dependent dylibs to see + if any are re-exported */ +#define MH_PIE 0x200000 /* When this bit is set, the OS will + load the main executable at a + random address. Only used in + MH_EXECUTE filetypes. */ +#define MH_DEAD_STRIPPABLE_DYLIB 0x400000 /* Only for use on dylibs. When + linking against a dylib that + has this bit set, the static linker + will automatically not create a + LC_LOAD_DYLIB load command to the + dylib if no symbols are being + referenced from the dylib. */ +#define MH_HAS_TLV_DESCRIPTORS 0x800000 /* Contains a section of type + S_THREAD_LOCAL_VARIABLES */ + +#define MH_NO_HEAP_EXECUTION 0x1000000 /* When this bit is set, the OS will + run the main executable with + a non-executable heap even on + platforms (e.g. i386) that don't + require it. Only used in MH_EXECUTE + filetypes. */ + +/* + * The load commands directly follow the mach_header. The total size of all + * of the commands is given by the sizeofcmds field in the mach_header. All + * load commands must have as their first two fields cmd and cmdsize. The cmd + * field is filled in with a constant for that command type. Each command type + * has a structure specifically for it. The cmdsize field is the size in bytes + * of the particular load command structure plus anything that follows it that + * is a part of the load command (i.e. section structures, strings, etc.). To + * advance to the next load command the cmdsize can be added to the offset or + * pointer of the current load command. The cmdsize for 32-bit architectures + * MUST be a multiple of 4 bytes and for 64-bit architectures MUST be a multiple + * of 8 bytes (these are forever the maximum alignment of any load commands). + * The padded bytes must be zero. All tables in the object file must also + * follow these rules so the file can be memory mapped. Otherwise the pointers + * to these tables will not work well or at all on some machines. With all + * padding zeroed like objects will compare byte for byte. + */ +struct load_command { + uint32_t cmd; /* type of load command */ + uint32_t cmdsize; /* total size of command in bytes */ +}; + +/* + * After MacOS X 10.1 when a new load command is added that is required to be + * understood by the dynamic linker for the image to execute properly the + * LC_REQ_DYLD bit will be or'ed into the load command constant. If the dynamic + * linker sees such a load command it it does not understand will issue a + * "unknown load command required for execution" error and refuse to use the + * image. Other load commands without this bit that are not understood will + * simply be ignored. + */ +#define LC_REQ_DYLD 0x80000000 + +/* Constants for the cmd field of all load commands, the type */ +#define LC_SEGMENT 0x1 /* segment of this file to be mapped */ +#define LC_SYMTAB 0x2 /* link-edit stab symbol table info */ +#define LC_SYMSEG 0x3 /* link-edit gdb symbol table info (obsolete) */ +#define LC_THREAD 0x4 /* thread */ +#define LC_UNIXTHREAD 0x5 /* unix thread (includes a stack) */ +#define LC_LOADFVMLIB 0x6 /* load a specified fixed VM shared library */ +#define LC_IDFVMLIB 0x7 /* fixed VM shared library identification */ +#define LC_IDENT 0x8 /* object identification info (obsolete) */ +#define LC_FVMFILE 0x9 /* fixed VM file inclusion (internal use) */ +#define LC_PREPAGE 0xa /* prepage command (internal use) */ +#define LC_DYSYMTAB 0xb /* dynamic link-edit symbol table info */ +#define LC_LOAD_DYLIB 0xc /* load a dynamically linked shared library */ +#define LC_ID_DYLIB 0xd /* dynamically linked shared lib ident */ +#define LC_LOAD_DYLINKER 0xe /* load a dynamic linker */ +#define LC_ID_DYLINKER 0xf /* dynamic linker identification */ +#define LC_PREBOUND_DYLIB 0x10 /* modules prebound for a dynamically */ + /* linked shared library */ +#define LC_ROUTINES 0x11 /* image routines */ +#define LC_SUB_FRAMEWORK 0x12 /* sub framework */ +#define LC_SUB_UMBRELLA 0x13 /* sub umbrella */ +#define LC_SUB_CLIENT 0x14 /* sub client */ +#define LC_SUB_LIBRARY 0x15 /* sub library */ +#define LC_TWOLEVEL_HINTS 0x16 /* two-level namespace lookup hints */ +#define LC_PREBIND_CKSUM 0x17 /* prebind checksum */ + +/* + * load a dynamically linked shared library that is allowed to be missing + * (all symbols are weak imported). + */ +#define LC_LOAD_WEAK_DYLIB (0x18 | LC_REQ_DYLD) + +#define LC_SEGMENT_64 0x19 /* 64-bit segment of this file to be + mapped */ +#define LC_ROUTINES_64 0x1a /* 64-bit image routines */ +#define LC_UUID 0x1b /* the uuid */ +#define LC_RPATH (0x1c | LC_REQ_DYLD) /* runpath additions */ +#define LC_CODE_SIGNATURE 0x1d /* local of code signature */ +#define LC_SEGMENT_SPLIT_INFO 0x1e /* local of info to split segments */ +#define LC_REEXPORT_DYLIB (0x1f | LC_REQ_DYLD) /* load and re-export dylib */ +#define LC_LAZY_LOAD_DYLIB 0x20 /* delay load of dylib until first use */ +#define LC_ENCRYPTION_INFO 0x21 /* encrypted segment information */ +#define LC_DYLD_INFO 0x22 /* compressed dyld information */ +#define LC_DYLD_INFO_ONLY (0x22|LC_REQ_DYLD) /* compressed dyld information only */ +#define LC_LOAD_UPWARD_DYLIB (0x23 | LC_REQ_DYLD) /* load upward dylib */ +#define LC_VERSION_MIN_MACOSX 0x24 /* build for MacOSX min OS version */ +#define LC_VERSION_MIN_IPHONEOS 0x25 /* build for iPhoneOS min OS version */ +#define LC_FUNCTION_STARTS 0x26 /* compressed table of function start addresses */ +#define LC_DYLD_ENVIRONMENT 0x27 /* string for dyld to treat + like environment variable */ + +/* + * A variable length string in a load command is represented by an lc_str + * union. The strings are stored just after the load command structure and + * the offset is from the start of the load command structure. The size + * of the string is reflected in the cmdsize field of the load command. + * Once again any padded bytes to bring the cmdsize field to a multiple + * of 4 bytes must be zero. + */ +union lc_str { + uint32_t offset; /* offset to the string */ +#ifndef __LP64__ + char *ptr; /* pointer to the string */ +#endif +}; + +/* + * The segment load command indicates that a part of this file is to be + * mapped into the task's address space. The size of this segment in memory, + * vmsize, maybe equal to or larger than the amount to map from this file, + * filesize. The file is mapped starting at fileoff to the beginning of + * the segment in memory, vmaddr. The rest of the memory of the segment, + * if any, is allocated zero fill on demand. The segment's maximum virtual + * memory protection and initial virtual memory protection are specified + * by the maxprot and initprot fields. If the segment has sections then the + * section structures directly follow the segment command and their size is + * reflected in cmdsize. + */ +struct segment_command { /* for 32-bit architectures */ + uint32_t cmd; /* LC_SEGMENT */ + uint32_t cmdsize; /* includes sizeof section structs */ + char segname[16]; /* segment name */ + uint32_t vmaddr; /* memory address of this segment */ + uint32_t vmsize; /* memory size of this segment */ + uint32_t fileoff; /* file offset of this segment */ + uint32_t filesize; /* amount to map from the file */ + vm_prot_t maxprot; /* maximum VM protection */ + vm_prot_t initprot; /* initial VM protection */ + uint32_t nsects; /* number of sections in segment */ + uint32_t flags; /* flags */ +}; + +/* + * The 64-bit segment load command indicates that a part of this file is to be + * mapped into a 64-bit task's address space. If the 64-bit segment has + * sections then section_64 structures directly follow the 64-bit segment + * command and their size is reflected in cmdsize. + */ +struct segment_command_64 { /* for 64-bit architectures */ + uint32_t cmd; /* LC_SEGMENT_64 */ + uint32_t cmdsize; /* includes sizeof section_64 structs */ + char segname[16]; /* segment name */ + uint64_t vmaddr; /* memory address of this segment */ + uint64_t vmsize; /* memory size of this segment */ + uint64_t fileoff; /* file offset of this segment */ + uint64_t filesize; /* amount to map from the file */ + vm_prot_t maxprot; /* maximum VM protection */ + vm_prot_t initprot; /* initial VM protection */ + uint32_t nsects; /* number of sections in segment */ + uint32_t flags; /* flags */ +}; + +/* Constants for the flags field of the segment_command */ +#define SG_HIGHVM 0x1 /* the file contents for this segment is for + the high part of the VM space, the low part + is zero filled (for stacks in core files) */ +#define SG_FVMLIB 0x2 /* this segment is the VM that is allocated by + a fixed VM library, for overlap checking in + the link editor */ +#define SG_NORELOC 0x4 /* this segment has nothing that was relocated + in it and nothing relocated to it, that is + it maybe safely replaced without relocation*/ +#define SG_PROTECTED_VERSION_1 0x8 /* This segment is protected. If the + segment starts at file offset 0, the + first page of the segment is not + protected. All other pages of the + segment are protected. */ + +/* + * A segment is made up of zero or more sections. Non-MH_OBJECT files have + * all of their segments with the proper sections in each, and padded to the + * specified segment alignment when produced by the link editor. The first + * segment of a MH_EXECUTE and MH_FVMLIB format file contains the mach_header + * and load commands of the object file before its first section. The zero + * fill sections are always last in their segment (in all formats). This + * allows the zeroed segment padding to be mapped into memory where zero fill + * sections might be. The gigabyte zero fill sections, those with the section + * type S_GB_ZEROFILL, can only be in a segment with sections of this type. + * These segments are then placed after all other segments. + * + * The MH_OBJECT format has all of its sections in one segment for + * compactness. There is no padding to a specified segment boundary and the + * mach_header and load commands are not part of the segment. + * + * Sections with the same section name, sectname, going into the same segment, + * segname, are combined by the link editor. The resulting section is aligned + * to the maximum alignment of the combined sections and is the new section's + * alignment. The combined sections are aligned to their original alignment in + * the combined section. Any padded bytes to get the specified alignment are + * zeroed. + * + * The format of the relocation entries referenced by the reloff and nreloc + * fields of the section structure for mach object files is described in the + * header file <reloc.h>. + */ +struct section { /* for 32-bit architectures */ + char sectname[16]; /* name of this section */ + char segname[16]; /* segment this section goes in */ + uint32_t addr; /* memory address of this section */ + uint32_t size; /* size in bytes of this section */ + uint32_t offset; /* file offset of this section */ + uint32_t align; /* section alignment (power of 2) */ + uint32_t reloff; /* file offset of relocation entries */ + uint32_t nreloc; /* number of relocation entries */ + uint32_t flags; /* flags (section type and attributes)*/ + uint32_t reserved1; /* reserved (for offset or index) */ + uint32_t reserved2; /* reserved (for count or sizeof) */ +}; + +struct section_64 { /* for 64-bit architectures */ + char sectname[16]; /* name of this section */ + char segname[16]; /* segment this section goes in */ + uint64_t addr; /* memory address of this section */ + uint64_t size; /* size in bytes of this section */ + uint32_t offset; /* file offset of this section */ + uint32_t align; /* section alignment (power of 2) */ + uint32_t reloff; /* file offset of relocation entries */ + uint32_t nreloc; /* number of relocation entries */ + uint32_t flags; /* flags (section type and attributes)*/ + uint32_t reserved1; /* reserved (for offset or index) */ + uint32_t reserved2; /* reserved (for count or sizeof) */ + uint32_t reserved3; /* reserved */ +}; + +/* + * The flags field of a section structure is separated into two parts a section + * type and section attributes. The section types are mutually exclusive (it + * can only have one type) but the section attributes are not (it may have more + * than one attribute). + */ +#define SECTION_TYPE 0x000000ff /* 256 section types */ +#define SECTION_ATTRIBUTES 0xffffff00 /* 24 section attributes */ + +/* Constants for the type of a section */ +#define S_REGULAR 0x0 /* regular section */ +#define S_ZEROFILL 0x1 /* zero fill on demand section */ +#define S_CSTRING_LITERALS 0x2 /* section with only literal C strings*/ +#define S_4BYTE_LITERALS 0x3 /* section with only 4 byte literals */ +#define S_8BYTE_LITERALS 0x4 /* section with only 8 byte literals */ +#define S_LITERAL_POINTERS 0x5 /* section with only pointers to */ + /* literals */ +/* + * For the two types of symbol pointers sections and the symbol stubs section + * they have indirect symbol table entries. For each of the entries in the + * section the indirect symbol table entries, in corresponding order in the + * indirect symbol table, start at the index stored in the reserved1 field + * of the section structure. Since the indirect symbol table entries + * correspond to the entries in the section the number of indirect symbol table + * entries is inferred from the size of the section divided by the size of the + * entries in the section. For symbol pointers sections the size of the entries + * in the section is 4 bytes and for symbol stubs sections the byte size of the + * stubs is stored in the reserved2 field of the section structure. + */ +#define S_NON_LAZY_SYMBOL_POINTERS 0x6 /* section with only non-lazy + symbol pointers */ +#define S_LAZY_SYMBOL_POINTERS 0x7 /* section with only lazy symbol + pointers */ +#define S_SYMBOL_STUBS 0x8 /* section with only symbol + stubs, byte size of stub in + the reserved2 field */ +#define S_MOD_INIT_FUNC_POINTERS 0x9 /* section with only function + pointers for initialization*/ +#define S_MOD_TERM_FUNC_POINTERS 0xa /* section with only function + pointers for termination */ +#define S_COALESCED 0xb /* section contains symbols that + are to be coalesced */ +#define S_GB_ZEROFILL 0xc /* zero fill on demand section + (that can be larger than 4 + gigabytes) */ +#define S_INTERPOSING 0xd /* section with only pairs of + function pointers for + interposing */ +#define S_16BYTE_LITERALS 0xe /* section with only 16 byte + literals */ +#define S_DTRACE_DOF 0xf /* section contains + DTrace Object Format */ +#define S_LAZY_DYLIB_SYMBOL_POINTERS 0x10 /* section with only lazy + symbol pointers to lazy + loaded dylibs */ +/* + * Section types to support thread local variables + */ +#define S_THREAD_LOCAL_REGULAR 0x11 /* template of initial + values for TLVs */ +#define S_THREAD_LOCAL_ZEROFILL 0x12 /* template of initial + values for TLVs */ +#define S_THREAD_LOCAL_VARIABLES 0x13 /* TLV descriptors */ +#define S_THREAD_LOCAL_VARIABLE_POINTERS 0x14 /* pointers to TLV + descriptors */ +#define S_THREAD_LOCAL_INIT_FUNCTION_POINTERS 0x15 /* functions to call + to initialize TLV + values */ + +/* + * Constants for the section attributes part of the flags field of a section + * structure. + */ +#define SECTION_ATTRIBUTES_USR 0xff000000 /* User setable attributes */ +#define S_ATTR_PURE_INSTRUCTIONS 0x80000000 /* section contains only true + machine instructions */ +#define S_ATTR_NO_TOC 0x40000000 /* section contains coalesced + symbols that are not to be + in a ranlib table of + contents */ +#define S_ATTR_STRIP_STATIC_SYMS 0x20000000 /* ok to strip static symbols + in this section in files + with the MH_DYLDLINK flag */ +#define S_ATTR_NO_DEAD_STRIP 0x10000000 /* no dead stripping */ +#define S_ATTR_LIVE_SUPPORT 0x08000000 /* blocks are live if they + reference live blocks */ +#define S_ATTR_SELF_MODIFYING_CODE 0x04000000 /* Used with i386 code stubs + written on by dyld */ +/* + * If a segment contains any sections marked with S_ATTR_DEBUG then all + * sections in that segment must have this attribute. No section other than + * a section marked with this attribute may reference the contents of this + * section. A section with this attribute may contain no symbols and must have + * a section type S_REGULAR. The static linker will not copy section contents + * from sections with this attribute into its output file. These sections + * generally contain DWARF debugging info. + */ +#define S_ATTR_DEBUG 0x02000000 /* a debug section */ +#define SECTION_ATTRIBUTES_SYS 0x00ffff00 /* system setable attributes */ +#define S_ATTR_SOME_INSTRUCTIONS 0x00000400 /* section contains some + machine instructions */ +#define S_ATTR_EXT_RELOC 0x00000200 /* section has external + relocation entries */ +#define S_ATTR_LOC_RELOC 0x00000100 /* section has local + relocation entries */ + + +/* + * The names of segments and sections in them are mostly meaningless to the + * link-editor. But there are few things to support traditional UNIX + * executables that require the link-editor and assembler to use some names + * agreed upon by convention. + * + * The initial protection of the "__TEXT" segment has write protection turned + * off (not writeable). + * + * The link-editor will allocate common symbols at the end of the "__common" + * section in the "__DATA" segment. It will create the section and segment + * if needed. + */ + +/* The currently known segment names and the section names in those segments */ + +#define SEG_PAGEZERO "__PAGEZERO" /* the pagezero segment which has no */ + /* protections and catches NULL */ + /* references for MH_EXECUTE files */ + + +#define SEG_TEXT "__TEXT" /* the tradition UNIX text segment */ +#define SECT_TEXT "__text" /* the real text part of the text */ + /* section no headers, and no padding */ +#define SECT_FVMLIB_INIT0 "__fvmlib_init0" /* the fvmlib initialization */ + /* section */ +#define SECT_FVMLIB_INIT1 "__fvmlib_init1" /* the section following the */ + /* fvmlib initialization */ + /* section */ + +#define SEG_DATA "__DATA" /* the tradition UNIX data segment */ +#define SECT_DATA "__data" /* the real initialized data section */ + /* no padding, no bss overlap */ +#define SECT_BSS "__bss" /* the real uninitialized data section*/ + /* no padding */ +#define SECT_COMMON "__common" /* the section common symbols are */ + /* allocated in by the link editor */ + +#define SEG_OBJC "__OBJC" /* objective-C runtime segment */ +#define SECT_OBJC_SYMBOLS "__symbol_table" /* symbol table */ +#define SECT_OBJC_MODULES "__module_info" /* module information */ +#define SECT_OBJC_STRINGS "__selector_strs" /* string table */ +#define SECT_OBJC_REFS "__selector_refs" /* string table */ + +#define SEG_ICON "__ICON" /* the icon segment */ +#define SECT_ICON_HEADER "__header" /* the icon headers */ +#define SECT_ICON_TIFF "__tiff" /* the icons in tiff format */ + +#define SEG_LINKEDIT "__LINKEDIT" /* the segment containing all structs */ + /* created and maintained by the link */ + /* editor. Created with -seglinkedit */ + /* option to ld(1) for MH_EXECUTE and */ + /* FVMLIB file types only */ + +#define SEG_UNIXSTACK "__UNIXSTACK" /* the unix stack segment */ + +#define SEG_IMPORT "__IMPORT" /* the segment for the self (dyld) */ + /* modifing code stubs that has read, */ + /* write and execute permissions */ + +/* + * Fixed virtual memory shared libraries are identified by two things. The + * target pathname (the name of the library as found for execution), and the + * minor version number. The address of where the headers are loaded is in + * header_addr. (THIS IS OBSOLETE and no longer supported). + */ +struct fvmlib { + union lc_str name; /* library's target pathname */ + uint32_t minor_version; /* library's minor version number */ + uint32_t header_addr; /* library's header address */ +}; + +/* + * A fixed virtual shared library (filetype == MH_FVMLIB in the mach header) + * contains a fvmlib_command (cmd == LC_IDFVMLIB) to identify the library. + * An object that uses a fixed virtual shared library also contains a + * fvmlib_command (cmd == LC_LOADFVMLIB) for each library it uses. + * (THIS IS OBSOLETE and no longer supported). + */ +struct fvmlib_command { + uint32_t cmd; /* LC_IDFVMLIB or LC_LOADFVMLIB */ + uint32_t cmdsize; /* includes pathname string */ + struct fvmlib fvmlib; /* the library identification */ +}; + +/* + * Dynamicly linked shared libraries are identified by two things. The + * pathname (the name of the library as found for execution), and the + * compatibility version number. The pathname must match and the compatibility + * number in the user of the library must be greater than or equal to the + * library being used. The time stamp is used to record the time a library was + * built and copied into user so it can be use to determined if the library used + * at runtime is exactly the same as used to built the program. + */ +struct dylib { + union lc_str name; /* library's path name */ + uint32_t timestamp; /* library's build time stamp */ + uint32_t current_version; /* library's current version number */ + uint32_t compatibility_version; /* library's compatibility vers number*/ +}; + +/* + * A dynamically linked shared library (filetype == MH_DYLIB in the mach header) + * contains a dylib_command (cmd == LC_ID_DYLIB) to identify the library. + * An object that uses a dynamically linked shared library also contains a + * dylib_command (cmd == LC_LOAD_DYLIB, LC_LOAD_WEAK_DYLIB, or + * LC_REEXPORT_DYLIB) for each library it uses. + */ +struct dylib_command { + uint32_t cmd; /* LC_ID_DYLIB, LC_LOAD_{,WEAK_}DYLIB, + LC_REEXPORT_DYLIB */ + uint32_t cmdsize; /* includes pathname string */ + struct dylib dylib; /* the library identification */ +}; + +/* + * A dynamically linked shared library may be a subframework of an umbrella + * framework. If so it will be linked with "-umbrella umbrella_name" where + * Where "umbrella_name" is the name of the umbrella framework. A subframework + * can only be linked against by its umbrella framework or other subframeworks + * that are part of the same umbrella framework. Otherwise the static link + * editor produces an error and states to link against the umbrella framework. + * The name of the umbrella framework for subframeworks is recorded in the + * following structure. + */ +struct sub_framework_command { + uint32_t cmd; /* LC_SUB_FRAMEWORK */ + uint32_t cmdsize; /* includes umbrella string */ + union lc_str umbrella; /* the umbrella framework name */ +}; + +/* + * For dynamically linked shared libraries that are subframework of an umbrella + * framework they can allow clients other than the umbrella framework or other + * subframeworks in the same umbrella framework. To do this the subframework + * is built with "-allowable_client client_name" and an LC_SUB_CLIENT load + * command is created for each -allowable_client flag. The client_name is + * usually a framework name. It can also be a name used for bundles clients + * where the bundle is built with "-client_name client_name". + */ +struct sub_client_command { + uint32_t cmd; /* LC_SUB_CLIENT */ + uint32_t cmdsize; /* includes client string */ + union lc_str client; /* the client name */ +}; + +/* + * A dynamically linked shared library may be a sub_umbrella of an umbrella + * framework. If so it will be linked with "-sub_umbrella umbrella_name" where + * Where "umbrella_name" is the name of the sub_umbrella framework. When + * staticly linking when -twolevel_namespace is in effect a twolevel namespace + * umbrella framework will only cause its subframeworks and those frameworks + * listed as sub_umbrella frameworks to be implicited linked in. Any other + * dependent dynamic libraries will not be linked it when -twolevel_namespace + * is in effect. The primary library recorded by the static linker when + * resolving a symbol in these libraries will be the umbrella framework. + * Zero or more sub_umbrella frameworks may be use by an umbrella framework. + * The name of a sub_umbrella framework is recorded in the following structure. + */ +struct sub_umbrella_command { + uint32_t cmd; /* LC_SUB_UMBRELLA */ + uint32_t cmdsize; /* includes sub_umbrella string */ + union lc_str sub_umbrella; /* the sub_umbrella framework name */ +}; + +/* + * A dynamically linked shared library may be a sub_library of another shared + * library. If so it will be linked with "-sub_library library_name" where + * Where "library_name" is the name of the sub_library shared library. When + * staticly linking when -twolevel_namespace is in effect a twolevel namespace + * shared library will only cause its subframeworks and those frameworks + * listed as sub_umbrella frameworks and libraries listed as sub_libraries to + * be implicited linked in. Any other dependent dynamic libraries will not be + * linked it when -twolevel_namespace is in effect. The primary library + * recorded by the static linker when resolving a symbol in these libraries + * will be the umbrella framework (or dynamic library). Zero or more sub_library + * shared libraries may be use by an umbrella framework or (or dynamic library). + * The name of a sub_library framework is recorded in the following structure. + * For example /usr/lib/libobjc_profile.A.dylib would be recorded as "libobjc". + */ +struct sub_library_command { + uint32_t cmd; /* LC_SUB_LIBRARY */ + uint32_t cmdsize; /* includes sub_library string */ + union lc_str sub_library; /* the sub_library name */ +}; + +/* + * A program (filetype == MH_EXECUTE) that is + * prebound to its dynamic libraries has one of these for each library that + * the static linker used in prebinding. It contains a bit vector for the + * modules in the library. The bits indicate which modules are bound (1) and + * which are not (0) from the library. The bit for module 0 is the low bit + * of the first byte. So the bit for the Nth module is: + * (linked_modules[N/8] >> N%8) & 1 + */ +struct prebound_dylib_command { + uint32_t cmd; /* LC_PREBOUND_DYLIB */ + uint32_t cmdsize; /* includes strings */ + union lc_str name; /* library's path name */ + uint32_t nmodules; /* number of modules in library */ + union lc_str linked_modules; /* bit vector of linked modules */ +}; + +/* + * A program that uses a dynamic linker contains a dylinker_command to identify + * the name of the dynamic linker (LC_LOAD_DYLINKER). And a dynamic linker + * contains a dylinker_command to identify the dynamic linker (LC_ID_DYLINKER). + * A file can have at most one of these. + * This struct is also used for the LC_DYLD_ENVIRONMENT load command and + * contains string for dyld to treat like environment variable. + */ +struct dylinker_command { + uint32_t cmd; /* LC_ID_DYLINKER, LC_LOAD_DYLINKER or + LC_DYLD_ENVIRONMENT */ + uint32_t cmdsize; /* includes pathname string */ + union lc_str name; /* dynamic linker's path name */ +}; + +/* + * Thread commands contain machine-specific data structures suitable for + * use in the thread state primitives. The machine specific data structures + * follow the struct thread_command as follows. + * Each flavor of machine specific data structure is preceded by an unsigned + * long constant for the flavor of that data structure, an uint32_t + * that is the count of longs of the size of the state data structure and then + * the state data structure follows. This triple may be repeated for many + * flavors. The constants for the flavors, counts and state data structure + * definitions are expected to be in the header file <machine/thread_status.h>. + * These machine specific data structures sizes must be multiples of + * 4 bytes The cmdsize reflects the total size of the thread_command + * and all of the sizes of the constants for the flavors, counts and state + * data structures. + * + * For executable objects that are unix processes there will be one + * thread_command (cmd == LC_UNIXTHREAD) created for it by the link-editor. + * This is the same as a LC_THREAD, except that a stack is automatically + * created (based on the shell's limit for the stack size). Command arguments + * and environment variables are copied onto that stack. + */ +struct thread_command { + uint32_t cmd; /* LC_THREAD or LC_UNIXTHREAD */ + uint32_t cmdsize; /* total size of this command */ + /* uint32_t flavor flavor of thread state */ + /* uint32_t count count of longs in thread state */ + /* struct XXX_thread_state state thread state for this flavor */ + /* ... */ +}; + +/* + * The routines command contains the address of the dynamic shared library + * initialization routine and an index into the module table for the module + * that defines the routine. Before any modules are used from the library the + * dynamic linker fully binds the module that defines the initialization routine + * and then calls it. This gets called before any module initialization + * routines (used for C++ static constructors) in the library. + */ +struct routines_command { /* for 32-bit architectures */ + uint32_t cmd; /* LC_ROUTINES */ + uint32_t cmdsize; /* total size of this command */ + uint32_t init_address; /* address of initialization routine */ + uint32_t init_module; /* index into the module table that */ + /* the init routine is defined in */ + uint32_t reserved1; + uint32_t reserved2; + uint32_t reserved3; + uint32_t reserved4; + uint32_t reserved5; + uint32_t reserved6; +}; + +/* + * The 64-bit routines command. Same use as above. + */ +struct routines_command_64 { /* for 64-bit architectures */ + uint32_t cmd; /* LC_ROUTINES_64 */ + uint32_t cmdsize; /* total size of this command */ + uint64_t init_address; /* address of initialization routine */ + uint64_t init_module; /* index into the module table that */ + /* the init routine is defined in */ + uint64_t reserved1; + uint64_t reserved2; + uint64_t reserved3; + uint64_t reserved4; + uint64_t reserved5; + uint64_t reserved6; +}; + +/* + * The symtab_command contains the offsets and sizes of the link-edit 4.3BSD + * "stab" style symbol table information as described in the header files + * <nlist.h> and <stab.h>. + */ +struct symtab_command { + uint32_t cmd; /* LC_SYMTAB */ + uint32_t cmdsize; /* sizeof(struct symtab_command) */ + uint32_t symoff; /* symbol table offset */ + uint32_t nsyms; /* number of symbol table entries */ + uint32_t stroff; /* string table offset */ + uint32_t strsize; /* string table size in bytes */ +}; + +/* + * This is the second set of the symbolic information which is used to support + * the data structures for the dynamically link editor. + * + * The original set of symbolic information in the symtab_command which contains + * the symbol and string tables must also be present when this load command is + * present. When this load command is present the symbol table is organized + * into three groups of symbols: + * local symbols (static and debugging symbols) - grouped by module + * defined external symbols - grouped by module (sorted by name if not lib) + * undefined external symbols (sorted by name if MH_BINDATLOAD is not set, + * and in order the were seen by the static + * linker if MH_BINDATLOAD is set) + * In this load command there are offsets and counts to each of the three groups + * of symbols. + * + * This load command contains a the offsets and sizes of the following new + * symbolic information tables: + * table of contents + * module table + * reference symbol table + * indirect symbol table + * The first three tables above (the table of contents, module table and + * reference symbol table) are only present if the file is a dynamically linked + * shared library. For executable and object modules, which are files + * containing only one module, the information that would be in these three + * tables is determined as follows: + * table of contents - the defined external symbols are sorted by name + * module table - the file contains only one module so everything in the + * file is part of the module. + * reference symbol table - is the defined and undefined external symbols + * + * For dynamically linked shared library files this load command also contains + * offsets and sizes to the pool of relocation entries for all sections + * separated into two groups: + * external relocation entries + * local relocation entries + * For executable and object modules the relocation entries continue to hang + * off the section structures. + */ +struct dysymtab_command { + uint32_t cmd; /* LC_DYSYMTAB */ + uint32_t cmdsize; /* sizeof(struct dysymtab_command) */ + + /* + * The symbols indicated by symoff and nsyms of the LC_SYMTAB load command + * are grouped into the following three groups: + * local symbols (further grouped by the module they are from) + * defined external symbols (further grouped by the module they are from) + * undefined symbols + * + * The local symbols are used only for debugging. The dynamic binding + * process may have to use them to indicate to the debugger the local + * symbols for a module that is being bound. + * + * The last two groups are used by the dynamic binding process to do the + * binding (indirectly through the module table and the reference symbol + * table when this is a dynamically linked shared library file). + */ + uint32_t ilocalsym; /* index to local symbols */ + uint32_t nlocalsym; /* number of local symbols */ + + uint32_t iextdefsym;/* index to externally defined symbols */ + uint32_t nextdefsym;/* number of externally defined symbols */ + + uint32_t iundefsym; /* index to undefined symbols */ + uint32_t nundefsym; /* number of undefined symbols */ + + /* + * For the for the dynamic binding process to find which module a symbol + * is defined in the table of contents is used (analogous to the ranlib + * structure in an archive) which maps defined external symbols to modules + * they are defined in. This exists only in a dynamically linked shared + * library file. For executable and object modules the defined external + * symbols are sorted by name and is use as the table of contents. + */ + uint32_t tocoff; /* file offset to table of contents */ + uint32_t ntoc; /* number of entries in table of contents */ + + /* + * To support dynamic binding of "modules" (whole object files) the symbol + * table must reflect the modules that the file was created from. This is + * done by having a module table that has indexes and counts into the merged + * tables for each module. The module structure that these two entries + * refer to is described below. This exists only in a dynamically linked + * shared library file. For executable and object modules the file only + * contains one module so everything in the file belongs to the module. + */ + uint32_t modtaboff; /* file offset to module table */ + uint32_t nmodtab; /* number of module table entries */ + + /* + * To support dynamic module binding the module structure for each module + * indicates the external references (defined and undefined) each module + * makes. For each module there is an offset and a count into the + * reference symbol table for the symbols that the module references. + * This exists only in a dynamically linked shared library file. For + * executable and object modules the defined external symbols and the + * undefined external symbols indicates the external references. + */ + uint32_t extrefsymoff; /* offset to referenced symbol table */ + uint32_t nextrefsyms; /* number of referenced symbol table entries */ + + /* + * The sections that contain "symbol pointers" and "routine stubs" have + * indexes and (implied counts based on the size of the section and fixed + * size of the entry) into the "indirect symbol" table for each pointer + * and stub. For every section of these two types the index into the + * indirect symbol table is stored in the section header in the field + * reserved1. An indirect symbol table entry is simply a 32bit index into + * the symbol table to the symbol that the pointer or stub is referring to. + * The indirect symbol table is ordered to match the entries in the section. + */ + uint32_t indirectsymoff; /* file offset to the indirect symbol table */ + uint32_t nindirectsyms; /* number of indirect symbol table entries */ + + /* + * To support relocating an individual module in a library file quickly the + * external relocation entries for each module in the library need to be + * accessed efficiently. Since the relocation entries can't be accessed + * through the section headers for a library file they are separated into + * groups of local and external entries further grouped by module. In this + * case the presents of this load command who's extreloff, nextrel, + * locreloff and nlocrel fields are non-zero indicates that the relocation + * entries of non-merged sections are not referenced through the section + * structures (and the reloff and nreloc fields in the section headers are + * set to zero). + * + * Since the relocation entries are not accessed through the section headers + * this requires the r_address field to be something other than a section + * offset to identify the item to be relocated. In this case r_address is + * set to the offset from the vmaddr of the first LC_SEGMENT command. + * For MH_SPLIT_SEGS images r_address is set to the the offset from the + * vmaddr of the first read-write LC_SEGMENT command. + * + * The relocation entries are grouped by module and the module table + * entries have indexes and counts into them for the group of external + * relocation entries for that the module. + * + * For sections that are merged across modules there must not be any + * remaining external relocation entries for them (for merged sections + * remaining relocation entries must be local). + */ + uint32_t extreloff; /* offset to external relocation entries */ + uint32_t nextrel; /* number of external relocation entries */ + + /* + * All the local relocation entries are grouped together (they are not + * grouped by their module since they are only used if the object is moved + * from it staticly link edited address). + */ + uint32_t locreloff; /* offset to local relocation entries */ + uint32_t nlocrel; /* number of local relocation entries */ + +}; + +/* + * An indirect symbol table entry is simply a 32bit index into the symbol table + * to the symbol that the pointer or stub is refering to. Unless it is for a + * non-lazy symbol pointer section for a defined symbol which strip(1) as + * removed. In which case it has the value INDIRECT_SYMBOL_LOCAL. If the + * symbol was also absolute INDIRECT_SYMBOL_ABS is or'ed with that. + */ +#define INDIRECT_SYMBOL_LOCAL 0x80000000 +#define INDIRECT_SYMBOL_ABS 0x40000000 + + +/* a table of contents entry */ +struct dylib_table_of_contents { + uint32_t symbol_index; /* the defined external symbol + (index into the symbol table) */ + uint32_t module_index; /* index into the module table this symbol + is defined in */ +}; + +/* a module table entry */ +struct dylib_module { + uint32_t module_name; /* the module name (index into string table) */ + + uint32_t iextdefsym; /* index into externally defined symbols */ + uint32_t nextdefsym; /* number of externally defined symbols */ + uint32_t irefsym; /* index into reference symbol table */ + uint32_t nrefsym; /* number of reference symbol table entries */ + uint32_t ilocalsym; /* index into symbols for local symbols */ + uint32_t nlocalsym; /* number of local symbols */ + + uint32_t iextrel; /* index into external relocation entries */ + uint32_t nextrel; /* number of external relocation entries */ + + uint32_t iinit_iterm; /* low 16 bits are the index into the init + section, high 16 bits are the index into + the term section */ + uint32_t ninit_nterm; /* low 16 bits are the number of init section + entries, high 16 bits are the number of + term section entries */ + + uint32_t /* for this module address of the start of */ + objc_module_info_addr; /* the (__OBJC,__module_info) section */ + uint32_t /* for this module size of */ + objc_module_info_size; /* the (__OBJC,__module_info) section */ +}; + +/* a 64-bit module table entry */ +struct dylib_module_64 { + uint32_t module_name; /* the module name (index into string table) */ + + uint32_t iextdefsym; /* index into externally defined symbols */ + uint32_t nextdefsym; /* number of externally defined symbols */ + uint32_t irefsym; /* index into reference symbol table */ + uint32_t nrefsym; /* number of reference symbol table entries */ + uint32_t ilocalsym; /* index into symbols for local symbols */ + uint32_t nlocalsym; /* number of local symbols */ + + uint32_t iextrel; /* index into external relocation entries */ + uint32_t nextrel; /* number of external relocation entries */ + + uint32_t iinit_iterm; /* low 16 bits are the index into the init + section, high 16 bits are the index into + the term section */ + uint32_t ninit_nterm; /* low 16 bits are the number of init section + entries, high 16 bits are the number of + term section entries */ + + uint32_t /* for this module size of */ + objc_module_info_size; /* the (__OBJC,__module_info) section */ + uint64_t /* for this module address of the start of */ + objc_module_info_addr; /* the (__OBJC,__module_info) section */ +}; + +/* + * The entries in the reference symbol table are used when loading the module + * (both by the static and dynamic link editors) and if the module is unloaded + * or replaced. Therefore all external symbols (defined and undefined) are + * listed in the module's reference table. The flags describe the type of + * reference that is being made. The constants for the flags are defined in + * <mach-o/nlist.h> as they are also used for symbol table entries. + */ +struct dylib_reference { + uint32_t isym:24, /* index into the symbol table */ + flags:8; /* flags to indicate the type of reference */ +}; + +/* + * The twolevel_hints_command contains the offset and number of hints in the + * two-level namespace lookup hints table. + */ +struct twolevel_hints_command { + uint32_t cmd; /* LC_TWOLEVEL_HINTS */ + uint32_t cmdsize; /* sizeof(struct twolevel_hints_command) */ + uint32_t offset; /* offset to the hint table */ + uint32_t nhints; /* number of hints in the hint table */ +}; + +/* + * The entries in the two-level namespace lookup hints table are twolevel_hint + * structs. These provide hints to the dynamic link editor where to start + * looking for an undefined symbol in a two-level namespace image. The + * isub_image field is an index into the sub-images (sub-frameworks and + * sub-umbrellas list) that made up the two-level image that the undefined + * symbol was found in when it was built by the static link editor. If + * isub-image is 0 the the symbol is expected to be defined in library and not + * in the sub-images. If isub-image is non-zero it is an index into the array + * of sub-images for the umbrella with the first index in the sub-images being + * 1. The array of sub-images is the ordered list of sub-images of the umbrella + * that would be searched for a symbol that has the umbrella recorded as its + * primary library. The table of contents index is an index into the + * library's table of contents. This is used as the starting point of the + * binary search or a directed linear search. + */ +struct twolevel_hint { + uint32_t + isub_image:8, /* index into the sub images */ + itoc:24; /* index into the table of contents */ +}; + +/* + * The prebind_cksum_command contains the value of the original check sum for + * prebound files or zero. When a prebound file is first created or modified + * for other than updating its prebinding information the value of the check sum + * is set to zero. When the file has it prebinding re-done and if the value of + * the check sum is zero the original check sum is calculated and stored in + * cksum field of this load command in the output file. If when the prebinding + * is re-done and the cksum field is non-zero it is left unchanged from the + * input file. + */ +struct prebind_cksum_command { + uint32_t cmd; /* LC_PREBIND_CKSUM */ + uint32_t cmdsize; /* sizeof(struct prebind_cksum_command) */ + uint32_t cksum; /* the check sum or zero */ +}; + +/* + * The uuid load command contains a single 128-bit unique random number that + * identifies an object produced by the static link editor. + */ +struct uuid_command { + uint32_t cmd; /* LC_UUID */ + uint32_t cmdsize; /* sizeof(struct uuid_command) */ + uint8_t uuid[16]; /* the 128-bit uuid */ +}; + +/* + * The rpath_command contains a path which at runtime should be added to + * the current run path used to find @rpath prefixed dylibs. + */ +struct rpath_command { + uint32_t cmd; /* LC_RPATH */ + uint32_t cmdsize; /* includes string */ + union lc_str path; /* path to add to run path */ +}; + +/* + * The linkedit_data_command contains the offsets and sizes of a blob + * of data in the __LINKEDIT segment. + */ +struct linkedit_data_command { + uint32_t cmd; /* LC_CODE_SIGNATURE, LC_SEGMENT_SPLIT_INFO, + or LC_FUNCTION_STARTS */ + uint32_t cmdsize; /* sizeof(struct linkedit_data_command) */ + uint32_t dataoff; /* file offset of data in __LINKEDIT segment */ + uint32_t datasize; /* file size of data in __LINKEDIT segment */ +}; + +/* + * The encryption_info_command contains the file offset and size of an + * of an encrypted segment. + */ +struct encryption_info_command { + uint32_t cmd; /* LC_ENCRYPTION_INFO */ + uint32_t cmdsize; /* sizeof(struct encryption_info_command) */ + uint32_t cryptoff; /* file offset of encrypted range */ + uint32_t cryptsize; /* file size of encrypted range */ + uint32_t cryptid; /* which enryption system, + 0 means not-encrypted yet */ +}; + +/* + * The version_min_command contains the min OS version on which this + * binary was built to run. + */ +struct version_min_command { + uint32_t cmd; /* LC_VERSION_MIN_MACOSX or + LC_VERSION_MIN_IPHONEOS */ + uint32_t cmdsize; /* sizeof(struct min_version_command) */ + uint32_t version; /* X.Y.Z is encoded in nibbles xxxx.yy.zz */ + uint32_t reserved; /* zero */ +}; + +/* + * The dyld_info_command contains the file offsets and sizes of + * the new compressed form of the information dyld needs to + * load the image. This information is used by dyld on Mac OS X + * 10.6 and later. All information pointed to by this command + * is encoded using byte streams, so no endian swapping is needed + * to interpret it. + */ +struct dyld_info_command { + uint32_t cmd; /* LC_DYLD_INFO or LC_DYLD_INFO_ONLY */ + uint32_t cmdsize; /* sizeof(struct dyld_info_command) */ + + /* + * Dyld rebases an image whenever dyld loads it at an address different + * from its preferred address. The rebase information is a stream + * of byte sized opcodes whose symbolic names start with REBASE_OPCODE_. + * Conceptually the rebase information is a table of tuples: + * <seg-index, seg-offset, type> + * The opcodes are a compressed way to encode the table by only + * encoding when a column changes. In addition simple patterns + * like "every n'th offset for m times" can be encoded in a few + * bytes. + */ + uint32_t rebase_off; /* file offset to rebase info */ + uint32_t rebase_size; /* size of rebase info */ + + /* + * Dyld binds an image during the loading process, if the image + * requires any pointers to be initialized to symbols in other images. + * The bind information is a stream of byte sized + * opcodes whose symbolic names start with BIND_OPCODE_. + * Conceptually the bind information is a table of tuples: + * <seg-index, seg-offset, type, symbol-library-ordinal, symbol-name, addend> + * The opcodes are a compressed way to encode the table by only + * encoding when a column changes. In addition simple patterns + * like for runs of pointers initialzed to the same value can be + * encoded in a few bytes. + */ + uint32_t bind_off; /* file offset to binding info */ + uint32_t bind_size; /* size of binding info */ + + /* + * Some C++ programs require dyld to unique symbols so that all + * images in the process use the same copy of some code/data. + * This step is done after binding. The content of the weak_bind + * info is an opcode stream like the bind_info. But it is sorted + * alphabetically by symbol name. This enable dyld to walk + * all images with weak binding information in order and look + * for collisions. If there are no collisions, dyld does + * no updating. That means that some fixups are also encoded + * in the bind_info. For instance, all calls to "operator new" + * are first bound to libstdc++.dylib using the information + * in bind_info. Then if some image overrides operator new + * that is detected when the weak_bind information is processed + * and the call to operator new is then rebound. + */ + uint32_t weak_bind_off; /* file offset to weak binding info */ + uint32_t weak_bind_size; /* size of weak binding info */ + + /* + * Some uses of external symbols do not need to be bound immediately. + * Instead they can be lazily bound on first use. The lazy_bind + * are contains a stream of BIND opcodes to bind all lazy symbols. + * Normal use is that dyld ignores the lazy_bind section when + * loading an image. Instead the static linker arranged for the + * lazy pointer to initially point to a helper function which + * pushes the offset into the lazy_bind area for the symbol + * needing to be bound, then jumps to dyld which simply adds + * the offset to lazy_bind_off to get the information on what + * to bind. + */ + uint32_t lazy_bind_off; /* file offset to lazy binding info */ + uint32_t lazy_bind_size; /* size of lazy binding infs */ + + /* + * The symbols exported by a dylib are encoded in a trie. This + * is a compact representation that factors out common prefixes. + * It also reduces LINKEDIT pages in RAM because it encodes all + * information (name, address, flags) in one small, contiguous range. + * The export area is a stream of nodes. The first node sequentially + * is the start node for the trie. + * + * Nodes for a symbol start with a uleb128 that is the length of + * the exported symbol information for the string so far. + * If there is no exported symbol, the node starts with a zero byte. + * If there is exported info, it follows the length. First is + * a uleb128 containing flags. Normally, it is followed by a + * uleb128 encoded offset which is location of the content named + * by the symbol from the mach_header for the image. If the flags + * is EXPORT_SYMBOL_FLAGS_REEXPORT, then following the flags is + * a uleb128 encoded library ordinal, then a zero terminated + * UTF8 string. If the string is zero length, then the symbol + * is re-export from the specified dylib with the same name. + * + * After the optional exported symbol information is a byte of + * how many edges (0-255) that this node has leaving it, + * followed by each edge. + * Each edge is a zero terminated UTF8 of the addition chars + * in the symbol, followed by a uleb128 offset for the node that + * edge points to. + * + */ + uint32_t export_off; /* file offset to lazy binding info */ + uint32_t export_size; /* size of lazy binding infs */ +}; + +/* + * The following are used to encode rebasing information + */ +#define REBASE_TYPE_POINTER 1 +#define REBASE_TYPE_TEXT_ABSOLUTE32 2 +#define REBASE_TYPE_TEXT_PCREL32 3 + +#define REBASE_OPCODE_MASK 0xF0 +#define REBASE_IMMEDIATE_MASK 0x0F +#define REBASE_OPCODE_DONE 0x00 +#define REBASE_OPCODE_SET_TYPE_IMM 0x10 +#define REBASE_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB 0x20 +#define REBASE_OPCODE_ADD_ADDR_ULEB 0x30 +#define REBASE_OPCODE_ADD_ADDR_IMM_SCALED 0x40 +#define REBASE_OPCODE_DO_REBASE_IMM_TIMES 0x50 +#define REBASE_OPCODE_DO_REBASE_ULEB_TIMES 0x60 +#define REBASE_OPCODE_DO_REBASE_ADD_ADDR_ULEB 0x70 +#define REBASE_OPCODE_DO_REBASE_ULEB_TIMES_SKIPPING_ULEB 0x80 + + +/* + * The following are used to encode binding information + */ +#define BIND_TYPE_POINTER 1 +#define BIND_TYPE_TEXT_ABSOLUTE32 2 +#define BIND_TYPE_TEXT_PCREL32 3 + +#define BIND_SPECIAL_DYLIB_SELF 0 +#define BIND_SPECIAL_DYLIB_MAIN_EXECUTABLE -1 +#define BIND_SPECIAL_DYLIB_FLAT_LOOKUP -2 + +#define BIND_SYMBOL_FLAGS_WEAK_IMPORT 0x1 +#define BIND_SYMBOL_FLAGS_NON_WEAK_DEFINITION 0x8 + +#define BIND_OPCODE_MASK 0xF0 +#define BIND_IMMEDIATE_MASK 0x0F +#define BIND_OPCODE_DONE 0x00 +#define BIND_OPCODE_SET_DYLIB_ORDINAL_IMM 0x10 +#define BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB 0x20 +#define BIND_OPCODE_SET_DYLIB_SPECIAL_IMM 0x30 +#define BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM 0x40 +#define BIND_OPCODE_SET_TYPE_IMM 0x50 +#define BIND_OPCODE_SET_ADDEND_SLEB 0x60 +#define BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB 0x70 +#define BIND_OPCODE_ADD_ADDR_ULEB 0x80 +#define BIND_OPCODE_DO_BIND 0x90 +#define BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB 0xA0 +#define BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED 0xB0 +#define BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB 0xC0 + + +/* + * The following are used on the flags byte of a terminal node + * in the export information. + */ +#define EXPORT_SYMBOL_FLAGS_KIND_MASK 0x03 +#define EXPORT_SYMBOL_FLAGS_KIND_REGULAR 0x00 +#define EXPORT_SYMBOL_FLAGS_KIND_THREAD_LOCAL 0x01 +#define EXPORT_SYMBOL_FLAGS_WEAK_DEFINITION 0x04 +#define EXPORT_SYMBOL_FLAGS_REEXPORT 0x08 +#define EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER 0x10 + +/* + * The symseg_command contains the offset and size of the GNU style + * symbol table information as described in the header file <symseg.h>. + * The symbol roots of the symbol segments must also be aligned properly + * in the file. So the requirement of keeping the offsets aligned to a + * multiple of a 4 bytes translates to the length field of the symbol + * roots also being a multiple of a long. Also the padding must again be + * zeroed. (THIS IS OBSOLETE and no longer supported). + */ +struct symseg_command { + uint32_t cmd; /* LC_SYMSEG */ + uint32_t cmdsize; /* sizeof(struct symseg_command) */ + uint32_t offset; /* symbol segment offset */ + uint32_t size; /* symbol segment size in bytes */ +}; + +/* + * The ident_command contains a free format string table following the + * ident_command structure. The strings are null terminated and the size of + * the command is padded out with zero bytes to a multiple of 4 bytes/ + * (THIS IS OBSOLETE and no longer supported). + */ +struct ident_command { + uint32_t cmd; /* LC_IDENT */ + uint32_t cmdsize; /* strings that follow this command */ +}; + +/* + * The fvmfile_command contains a reference to a file to be loaded at the + * specified virtual address. (Presently, this command is reserved for + * internal use. The kernel ignores this command when loading a program into + * memory). + */ +struct fvmfile_command { + uint32_t cmd; /* LC_FVMFILE */ + uint32_t cmdsize; /* includes pathname string */ + union lc_str name; /* files pathname */ + uint32_t header_addr; /* files virtual address */ +}; + +/* + * Sections of type S_THREAD_LOCAL_VARIABLES contain an array + * of tlv_descriptor structures. + */ +struct tlv_descriptor +{ + void* (*thunk)(struct tlv_descriptor*); + unsigned long key; + unsigned long offset; +}; + +#endif /* _MACHO_LOADER_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach-o/ranlib.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach-o/ranlib.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach-o/ranlib.h (revision 885) @@ -0,0 +1,67 @@ +/* + * Copyright (c) 1999 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@ + */ +/* ranlib.h 4.1 83/05/03 */ +#ifndef _MACH_O_RANLIB_H_ +#define _MACH_O_RANLIB_H_ + +#include <stdint.h> +#include <sys/types.h> /* off_t */ + +/* + * There are two known orders of table of contents for archives. The first is + * the order ranlib(1) originally produced and still produces without any + * options. This table of contents has the archive member name "__.SYMDEF" + * This order has the ranlib structures in the order the objects appear in the + * archive and the symbol names of those objects in the order of symbol table. + * The second know order is sorted by symbol name and is produced with the -s + * option to ranlib(1). This table of contents has the archive member name + * "__.SYMDEF SORTED" and many programs (notably the 1.0 version of ld(1) can't + * tell the difference between names because of the imbedded blank in the name + * and works with either table of contents). This second order is used by the + * post 1.0 link editor to produce faster linking. The original 1.0 version of + * ranlib(1) gets confused when it is run on a archive with the second type of + * table of contents because it and ar(1) which it uses use different ways to + * determined the member name (ar(1) treats all blanks in the name as + * significant and ranlib(1) only checks for the first one). + */ +#define SYMDEF "__.SYMDEF" +#define SYMDEF_SORTED "__.SYMDEF SORTED" + +/* + * Structure of the __.SYMDEF table of contents for an archive. + * __.SYMDEF begins with a long giving the size in bytes of the ranlib + * structures which immediately follow, and then continues with a string + * table consisting of a long giving the number of bytes of strings which + * follow and then the strings themselves. The ran_strx fields index the + * string table whose first byte is numbered 0. + */ +struct ranlib { + union { + uint32_t ran_strx; /* string table index of */ +#ifndef __LP64__ + char *ran_name; /* symbol defined by */ +#endif + } ran_un; + uint32_t ran_off; /* library member at this offset */ +}; +#endif /* _MACH_O_RANLIB_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach-o/x86_64/reloc.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach-o/x86_64/reloc.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach-o/x86_64/reloc.h (revision 885) @@ -0,0 +1,185 @@ +/* + * Copyright (c) 2006 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@ + */ +/* + * Relocations for x86_64 are a bit different than for other architectures in + * Mach-O: Scattered relocations are not used. Almost all relocations produced + * by the compiler are external relocations. An external relocation has the + * r_extern bit set to 1 and the r_symbolnum field contains the symbol table + * index of the target label. + * + * When the assembler is generating relocations, if the target label is a local + * label (begins with 'L'), then the previous non-local label in the same + * section is used as the target of the external relocation. An addend is used + * with the distance from that non-local label to the target label. Only when + * there is no previous non-local label in the section is an internal + * relocation used. + * + * The addend (i.e. the 4 in _foo+4) is encoded in the instruction (Mach-O does + * not have RELA relocations). For PC-relative relocations, the addend is + * stored directly in the instruction. This is different from other Mach-O + * architectures, which encode the addend minus the current section offset. + * + * The relocation types are: + * + * X86_64_RELOC_UNSIGNED // for absolute addresses + * X86_64_RELOC_SIGNED // for signed 32-bit displacement + * X86_64_RELOC_BRANCH // a CALL/JMP instruction with 32-bit displacement + * X86_64_RELOC_GOT_LOAD // a MOVQ load of a GOT entry + * X86_64_RELOC_GOT // other GOT references + * X86_64_RELOC_SUBTRACTOR // must be followed by a X86_64_RELOC_UNSIGNED + * + * The following are sample assembly instructions, followed by the relocation + * and section content they generate in an object file: + * + * call _foo + * r_type=X86_64_RELOC_BRANCH, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo + * E8 00 00 00 00 + * + * call _foo+4 + * r_type=X86_64_RELOC_BRANCH, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo + * E8 04 00 00 00 + * + * movq _foo@GOTPCREL(%rip), %rax + * r_type=X86_64_RELOC_GOT_LOAD, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo + * 48 8B 05 00 00 00 00 + * + * pushq _foo@GOTPCREL(%rip) + * r_type=X86_64_RELOC_GOT, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo + * FF 35 00 00 00 00 + * + * movl _foo(%rip), %eax + * r_type=X86_64_RELOC_SIGNED, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo + * 8B 05 00 00 00 00 + * + * movl _foo+4(%rip), %eax + * r_type=X86_64_RELOC_SIGNED, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo + * 8B 05 04 00 00 00 + * + * movb $0x12, _foo(%rip) + * r_type=X86_64_RELOC_SIGNED, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo + * C6 05 FF FF FF FF 12 + * + * movl $0x12345678, _foo(%rip) + * r_type=X86_64_RELOC_SIGNED, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo + * C7 05 FC FF FF FF 78 56 34 12 + * + * .quad _foo + * r_type=X86_64_RELOC_UNSIGNED, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_foo + * 00 00 00 00 00 00 00 00 + * + * .quad _foo+4 + * r_type=X86_64_RELOC_UNSIGNED, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_foo + * 04 00 00 00 00 00 00 00 + * + * .quad _foo - _bar + * r_type=X86_64_RELOC_SUBTRACTOR, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_bar + * r_type=X86_64_RELOC_UNSIGNED, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_foo + * 00 00 00 00 00 00 00 00 + * + * .quad _foo - _bar + 4 + * r_type=X86_64_RELOC_SUBTRACTOR, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_bar + * r_type=X86_64_RELOC_UNSIGNED, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_foo + * 04 00 00 00 00 00 00 00 + * + * .long _foo - _bar + * r_type=X86_64_RELOC_SUBTRACTOR, r_length=2, r_extern=1, r_pcrel=0, r_symbolnum=_bar + * r_type=X86_64_RELOC_UNSIGNED, r_length=2, r_extern=1, r_pcrel=0, r_symbolnum=_foo + * 00 00 00 00 + * + * lea L1(%rip), %rax + * r_type=X86_64_RELOC_SIGNED, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_prev + * 48 8d 05 12 00 00 00 + * // assumes _prev is the first non-local label 0x12 bytes before L1 + * + * lea L0(%rip), %rax + * r_type=X86_64_RELOC_SIGNED, r_length=2, r_extern=0, r_pcrel=1, r_symbolnum=3 + * 48 8d 05 56 00 00 00 + * // assumes L0 is in third section and there is no previous non-local label. + * // The rip-relative-offset of 0x00000056 is L0-address_of_next_instruction. + * // address_of_next_instruction is the address of the relocation + 4. + * + * add $6,L0(%rip) + * r_type=X86_64_RELOC_SIGNED_1, r_length=2, r_extern=0, r_pcrel=1, r_symbolnum=3 + * 83 05 18 00 00 00 06 + * // assumes L0 is in third section and there is no previous non-local label. + * // The rip-relative-offset of 0x00000018 is L0-address_of_next_instruction. + * // address_of_next_instruction is the address of the relocation + 4 + 1. + * // The +1 comes from SIGNED_1. This is used because the relocation is not + * // at the end of the instruction. + * + * .quad L1 + * r_type=X86_64_RELOC_UNSIGNED, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_prev + * 12 00 00 00 00 00 00 00 + * // assumes _prev is the first non-local label 0x12 bytes before L1 + * + * .quad L0 + * r_type=X86_64_RELOC_UNSIGNED, r_length=3, r_extern=0, r_pcrel=0, r_symbolnum=3 + * 56 00 00 00 00 00 00 00 + * // assumes L0 is in third section, has an address of 0x00000056 in .o + * // file, and there is no previous non-local label + * + * .quad _foo - . + * r_type=X86_64_RELOC_SUBTRACTOR, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_prev + * r_type=X86_64_RELOC_UNSIGNED, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_foo + * EE FF FF FF FF FF FF FF + * // assumes _prev is the first non-local label 0x12 bytes before this + * // .quad + * + * .quad _foo - L1 + * r_type=X86_64_RELOC_SUBTRACTOR, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_prev + * r_type=X86_64_RELOC_UNSIGNED, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_foo + * EE FF FF FF FF FF FF FF + * // assumes _prev is the first non-local label 0x12 bytes before L1 + * + * .quad L1 - _prev + * // No relocations. This is an assembly time constant. + * 12 00 00 00 00 00 00 00 + * // assumes _prev is the first non-local label 0x12 bytes before L1 + * + * + * + * In final linked images, there are only two valid relocation kinds: + * + * r_type=X86_64_RELOC_UNSIGNED, r_length=3, r_pcrel=0, r_extern=1, r_symbolnum=sym_index + * This tells dyld to add the address of a symbol to a pointer sized (8-byte) + * piece of data (i.e on disk the 8-byte piece of data contains the addend). The + * r_symbolnum contains the index into the symbol table of the target symbol. + * + * r_type=X86_64_RELOC_UNSIGNED, r_length=3, r_pcrel=0, r_extern=0, r_symbolnum=0 + * This tells dyld to adjust the pointer sized (8-byte) piece of data by the amount + * the containing image was loaded from its base address (e.g. slide). + * + */ +enum reloc_type_x86_64 +{ + X86_64_RELOC_UNSIGNED, // for absolute addresses + X86_64_RELOC_SIGNED, // for signed 32-bit displacement + X86_64_RELOC_BRANCH, // a CALL/JMP instruction with 32-bit displacement + X86_64_RELOC_GOT_LOAD, // a MOVQ load of a GOT entry + X86_64_RELOC_GOT, // other GOT references + X86_64_RELOC_SUBTRACTOR, // must be followed by a X86_64_RELOC_UNSIGNED + X86_64_RELOC_SIGNED_1, // for signed 32-bit displacement with a -1 addend + X86_64_RELOC_SIGNED_2, // for signed 32-bit displacement with a -2 addend + X86_64_RELOC_SIGNED_4, // for signed 32-bit displacement with a -4 addend + X86_64_RELOC_TLV, // for thread local variables +}; Index: branches/azimutz/Cleancut/i386/include/mach-o/fat.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach-o/fat.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach-o/fat.h (revision 885) @@ -0,0 +1,64 @@ +/* + * Copyright (c) 1999 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 _MACH_O_FAT_H_ +#define _MACH_O_FAT_H_ +/* + * This header file describes the structures of the file format for "fat" + * architecture specific file (wrapper design). At the begining of the file + * there is one fat_header structure followed by a number of fat_arch + * structures. For each architecture in the file, specified by a pair of + * cputype and cpusubtype, the fat_header describes the file offset, file + * size and alignment in the file of the architecture specific member. + * The padded bytes in the file to place each member on it's specific alignment + * are defined to be read as zeros and can be left as "holes" if the file system + * can support them as long as they read as zeros. + * + * All structures defined here are always written and read to/from disk + * in big-endian order. + */ + +/* + * <mach/machine.h> is needed here for the cpu_type_t and cpu_subtype_t types + * and contains the constants for the possible values of these types. + */ +#include <stdint.h> +#include <mach/machine.h> +#include <architecture/byte_order.h> + +#define FAT_MAGIC 0xcafebabe +#define FAT_CIGAM 0xbebafeca /* NXSwapLong(FAT_MAGIC) */ + +struct fat_header { + uint32_t magic; /* FAT_MAGIC */ + uint32_t nfat_arch; /* number of structs that follow */ +}; + +struct fat_arch { + cpu_type_t cputype; /* cpu specifier (int) */ + cpu_subtype_t cpusubtype; /* machine specifier (int) */ + uint32_t offset; /* file offset to this object file */ + uint32_t size; /* size of this object file */ + uint32_t align; /* alignment as a power of 2 */ +}; + +#endif /* _MACH_O_FAT_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach-o/swap.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach-o/swap.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach-o/swap.h (revision 885) @@ -0,0 +1,207 @@ +/* + * Copyright (c) 1999 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 _MACH_O_SWAP_H_ +#define _MACH_O_SWAP_H_ + +#include <stdint.h> +#include <architecture/byte_order.h> +#include <mach-o/fat.h> +#include <mach-o/loader.h> +#include <mach-o/nlist.h> +#include <mach-o/reloc.h> +#include <mach-o/ranlib.h> + +#if __cplusplus +extern "C" { +#endif /* __cplusplus */ + +extern void swap_fat_header( + struct fat_header *fat_header, + enum NXByteOrder target_byte_order); + +extern void swap_fat_arch( + struct fat_arch *fat_archs, + uint32_t nfat_arch, + enum NXByteOrder target_byte_order); + +extern void swap_mach_header( + struct mach_header *mh, + enum NXByteOrder target_byte_order); + +extern void swap_mach_header_64( + struct mach_header_64 *mh, + enum NXByteOrder target_byte_order); + +extern void swap_load_command( + struct load_command *lc, + enum NXByteOrder target_byte_order); + +extern void swap_segment_command( + struct segment_command *sg, + enum NXByteOrder target_byte_order); + +extern void swap_segment_command_64( + struct segment_command_64 *sg, + enum NXByteOrder target_byte_order); + +extern void swap_section( + struct section *s, + uint32_t nsects, + enum NXByteOrder target_byte_order); + +extern void swap_section_64( + struct section_64 *s, + uint32_t nsects, + enum NXByteOrder target_byte_order); + +extern void swap_symtab_command( + struct symtab_command *st, + enum NXByteOrder target_byte_order); + +extern void swap_dysymtab_command( + struct dysymtab_command *dyst, + enum NXByteOrder target_byte_sex); + +extern void swap_symseg_command( + struct symseg_command *ss, + enum NXByteOrder target_byte_order); + +extern void swap_fvmlib_command( + struct fvmlib_command *fl, + enum NXByteOrder target_byte_order); + +extern void swap_dylib_command( + struct dylib_command *dl, + enum NXByteOrder target_byte_sex); + +extern void swap_sub_framework_command( + struct sub_framework_command *sub, + enum NXByteOrder target_byte_sex); + +extern void swap_sub_umbrella_command( + struct sub_umbrella_command *usub, + enum NXByteOrder target_byte_sex); + +extern void swap_sub_library_command( + struct sub_library_command *lsub, + enum NXByteOrder target_byte_sex); + +extern void swap_sub_client_command( + struct sub_client_command *csub, + enum NXByteOrder target_byte_sex); + +extern void swap_prebound_dylib_command( + struct prebound_dylib_command *pbdylib, + enum NXByteOrder target_byte_sex); + +extern void swap_dylinker_command( + struct dylinker_command *dyld, + enum NXByteOrder target_byte_sex); + +extern void swap_fvmfile_command( + struct fvmfile_command *ff, + enum NXByteOrder target_byte_order); + +extern void swap_thread_command( + struct thread_command *ut, + enum NXByteOrder target_byte_order); + +extern void swap_ident_command( + struct ident_command *ident, + enum NXByteOrder target_byte_order); + +extern void swap_routines_command( + struct routines_command *r_cmd, + enum NXByteOrder target_byte_sex); + +extern void swap_routines_command_64( + struct routines_command_64 *r_cmd, + enum NXByteOrder target_byte_sex); + +extern void swap_twolevel_hints_command( + struct twolevel_hints_command *hints_cmd, + enum NXByteOrder target_byte_sex); + +extern void swap_prebind_cksum_command( + struct prebind_cksum_command *cksum_cmd, + enum NXByteOrder target_byte_sex); + +extern void swap_uuid_command( + struct uuid_command *uuid_cmd, + enum NXByteOrder target_byte_sex); + +extern void swap_twolevel_hint( + struct twolevel_hint *hints, + uint32_t nhints, + enum NXByteOrder target_byte_sex); + +extern void swap_nlist( + struct nlist *symbols, + uint32_t nsymbols, + enum NXByteOrder target_byte_order); + +extern void swap_nlist_64( + struct nlist_64 *symbols, + uint32_t nsymbols, + enum NXByteOrder target_byte_order); + +extern void swap_ranlib( + struct ranlib *ranlibs, + uint32_t nranlibs, + enum NXByteOrder target_byte_order); + +extern void swap_relocation_info( + struct relocation_info *relocs, + uint32_t nrelocs, + enum NXByteOrder target_byte_order); + +extern void swap_indirect_symbols( + uint32_t *indirect_symbols, + uint32_t nindirect_symbols, + enum NXByteOrder target_byte_sex); + +extern void swap_dylib_reference( + struct dylib_reference *refs, + uint32_t nrefs, + enum NXByteOrder target_byte_sex); + +extern void swap_dylib_module( + struct dylib_module *mods, + uint32_t nmods, + enum NXByteOrder target_byte_sex); + +extern void swap_dylib_module_64( + struct dylib_module_64 *mods, + uint32_t nmods, + enum NXByteOrder target_byte_sex); + +extern void swap_dylib_table_of_contents( + struct dylib_table_of_contents *tocs, + uint32_t ntocs, + enum NXByteOrder target_byte_sex); + +#if __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _MACH_O_SWAP_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach-o/ldsyms.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach-o/ldsyms.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach-o/ldsyms.h (revision 885) @@ -0,0 +1,133 @@ +/* + * Copyright (c) 1999 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 _MACHO_LDSYMS_H_ +#define _MACHO_LDSYMS_H_ + +#include <mach-o/loader.h> + +/* + * This file describes the link editor defined symbols. The semantics of a + * link editor symbol is that it is defined by the link editor only if it is + * referenced and it is an error for the user to define them (see the man page + * ld(1)). The standard UNIX link editor symbols: __end, __etext and __edata + * are not not supported by the Apple Mach-O link editor. These symbols are + * really not meaningful in a Mach-O object file and the link editor symbols + * that are supported (described here) replace them. In the case of the + * standard UNIX link editor symbols the program can use the symbol + * __mh_execute_header and walk the load commands of it's program to determine + * the ending (or beginning) of any section or segment in the program. Note + * that the compiler prepends an underbar to all external symbol names coded + * in a high level language. Thus in 'C' names are coded without an underbar + * and symbol names in the symbol table have an underbar. There are two cpp + * macros for each link editor defined name in this file. The macro with a + * leading underbar is the symbol name and the one without is the name as + * coded in 'C'. + */ + +/* + * The value of the link editor defined symbol _MH_EXECUTE_SYM is the address + * of the mach header in a Mach-O executable file type. It does not appear in + * any file type other than a MH_EXECUTE file type. The type of the symbol is + * absolute as the header is not part of any section. + */ +#define _MH_EXECUTE_SYM "__mh_execute_header" +#define MH_EXECUTE_SYM "_mh_execute_header" +extern const struct +#ifdef __LP64__ +mach_header_64 +#else +mach_header +#endif +_mh_execute_header; + +/* + * The value of the link editor defined symbol _MH_BUNDLE_SYM is the address + * of the mach header in a Mach-O bundle file type. It does not appear in + * any file type other than a MH_BUNDLE file type. The type of the symbol is + * an N_SECT symbol even thought the header is not part of any section. This + * symbol is private to the code in the bundle it is a part of. + */ +#define _MH_BUNDLE_SYM "__mh_bundle_header" +#define MH_BUNDLE_SYM "_mh_bundle_header" +extern const struct +#ifdef __LP64__ +mach_header_64 +#else +mach_header +#endif +_mh_bundle_header; + +/* + * The value of the link editor defined symbol _MH_DYLIB_SYM is the address + * of the mach header in a Mach-O dylib file type. It does not appear in + * any file type other than a MH_DYLIB file type. The type of the symbol is + * an N_SECT symbol even thought the header is not part of any section. This + * symbol is private to the code in the library it is a part of. + */ +#define _MH_DYLIB_SYM "__mh_dylib_header" +#define MH_DYLIB_SYM "_mh_dylib_header" +extern const struct +#ifdef __LP64__ +mach_header_64 +#else +mach_header +#endif +_mh_dylib_header; + +/* + * The value of the link editor defined symbol _MH_DYLINKER_SYM is the address + * of the mach header in a Mach-O dylinker file type. It does not appear in + * any file type other than a MH_DYLINKER file type. The type of the symbol is + * an N_SECT symbol even thought the header is not part of any section. This + * symbol is private to the code in the dynamic linker it is a part of. + */ +#define _MH_DYLINKER_SYM "__mh_dylinker_header" +#define MH_DYLINKER_SYM "_mh_dylinker_header" +extern const struct +#ifdef __LP64__ +mach_header_64 +#else +mach_header +#endif +_mh_dylinker_header; + +/* + * For the MH_PRELOAD file type the headers are not loaded as part of any + * segment so the link editor defines symbols defined for the beginning + * and ending of each segment and each section in each segment. The names for + * the symbols for a segment's beginning and end will have the form: + * __SEGNAME__begin and __SEGNAME__end where __SEGNAME is the name of the + * segment. The names for the symbols for a section's beginning and end will + * have the form: __SEGNAME__sectname__begin and __SEGNAME__sectname__end + * where __sectname is the name of the section and __SEGNAME is the segment it + * is in. + * + * The above symbols' types are those of the section they are referring to. + * This is true even for symbols who's values are end's of a section and + * that value is next address after that section and not really in that + * section. This results in these symbols having types referring to sections + * who's values are not in that section. + */ + +#endif /* _MACHO_LDSYMS_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach-o/arch.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach-o/arch.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach-o/arch.h (revision 885) @@ -0,0 +1,105 @@ +/* + * Copyright (c) 1999 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 _MACH_O_ARCH_H_ +#define _MACH_O_ARCH_H_ +/* + * Copyright (c) 1997 Apple Computer, Inc. + * + * Functions that deal with information about architectures. + * + */ + +#include <stdint.h> +#include <mach/machine.h> +#include <architecture/byte_order.h> + +/* The NXArchInfo structs contain the architectures symbolic name + * (such as "ppc"), its CPU type and CPU subtype as defined in + * mach/machine.h, the byte order for the architecture, and a + * describing string (such as "PowerPC"). + * There will both be entries for specific CPUs (such as ppc604e) as + * well as generic "family" entries (such as ppc). + */ +typedef struct { + const char *name; + cpu_type_t cputype; + cpu_subtype_t cpusubtype; + enum NXByteOrder byteorder; + const char *description; +} NXArchInfo; + +#if __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* NXGetAllArchInfos() returns a pointer to an array of all known + * NXArchInfo structures. The last NXArchInfo is marked by a NULL name. + */ +extern const NXArchInfo *NXGetAllArchInfos(void); + +/* NXGetLocalArchInfo() returns the NXArchInfo for the local host, or NULL + * if none is known. + */ +extern const NXArchInfo *NXGetLocalArchInfo(void); + +/* NXGetArchInfoFromName() and NXGetArchInfoFromCpuType() return the + * NXArchInfo from the architecture's name or cputype/cpusubtype + * combination. A cpusubtype of CPU_SUBTYPE_MULTIPLE can be used + * to request the most general NXArchInfo known for the given cputype. + * NULL is returned if no matching NXArchInfo can be found. + */ +extern const NXArchInfo *NXGetArchInfoFromName(const char *name); +extern const NXArchInfo *NXGetArchInfoFromCpuType(cpu_type_t cputype, + cpu_subtype_t cpusubtype); + +/* NXFindBestFatArch() is passed a cputype and cpusubtype and a set of + * fat_arch structs and selects the best one that matches (if any) and returns + * a pointer to that fat_arch struct (or NULL). The fat_arch structs must be + * in the host byte order and correct such that the fat_archs really points to + * enough memory for nfat_arch structs. It is possible that this routine could + * fail if new cputypes or cpusubtypes are added and an old version of this + * routine is used. But if there is an exact match between the cputype and + * cpusubtype and one of the fat_arch structs this routine will always succeed. + */ +extern struct fat_arch *NXFindBestFatArch(cpu_type_t cputype, + cpu_subtype_t cpusubtype, + struct fat_arch *fat_archs, + uint32_t nfat_archs); + +/* NXCombineCpuSubtypes() returns the resulting cpusubtype when combining two + * different cpusubtypes for the specified cputype. If the two cpusubtypes + * can't be combined (the specific subtypes are mutually exclusive) -1 is + * returned indicating it is an error to combine them. This can also fail and + * return -1 if new cputypes or cpusubtypes are added and an old version of + * this routine is used. But if the cpusubtypes are the same they can always + * be combined and this routine will return the cpusubtype pass in. + */ +extern cpu_subtype_t NXCombineCpuSubtypes(cpu_type_t cputype, + cpu_subtype_t cpusubtype1, + cpu_subtype_t cpusubtype2); + +#if __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _MACH_O_ARCH_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach-o/compact_unwind_encoding.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach-o/compact_unwind_encoding.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach-o/compact_unwind_encoding.h (revision 885) @@ -0,0 +1,224 @@ +/* -*- mode: C; c-basic-offset: 4; tab-width: 4 -*- + * + * Copyright (c) 2008-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 __COMPACT_UNWIND_ENCODING__ +#define __COMPACT_UNWIND_ENCODING__ + +#include <stdint.h> + + +// +// Each final linked mach-o image has an optional __TEXT, __unwind_info section. +// This section is much smaller and faster to use than the __eh_frame section. +// + + + +// +// Compilers usually emit standard Dwarf FDEs. The linker recognizes standard FDEs and +// synthesizes a matching compact_unwind_encoding_t and adds it to the __unwind_info table. +// It is also possible for the compiler to emit __unwind_info entries for functions that +// have different unwind requirements at different ranges in the function. +// +typedef uint32_t compact_unwind_encoding_t; + + + +// +// The __unwind_info section is laid out for an efficient two level lookup. +// The header of the section contains a coarse index that maps function address +// to the page (4096 byte block) containing the unwind info for that function. +// + +#define UNWIND_SECTION_VERSION 1 +struct unwind_info_section_header +{ + uint32_t version; // UNWIND_SECTION_VERSION + uint32_t commonEncodingsArraySectionOffset; + uint32_t commonEncodingsArrayCount; + uint32_t personalityArraySectionOffset; + uint32_t personalityArrayCount; + uint32_t indexSectionOffset; + uint32_t indexCount; + // compact_unwind_encoding_t[] + // uintptr_t personalities[] + // unwind_info_section_header_index_entry[] + // unwind_info_section_header_lsda_index_entry[] +}; + +struct unwind_info_section_header_index_entry +{ + uint32_t functionOffset; + uint32_t secondLevelPagesSectionOffset; // section offset to start of regular or compress page + uint32_t lsdaIndexArraySectionOffset; // section offset to start of lsda_index array for this range +}; + +struct unwind_info_section_header_lsda_index_entry +{ + uint32_t functionOffset; + uint32_t lsdaOffset; +}; + +// +// There are two kinds of second level index pages: regular and compressed. +// A compressed page can hold up to 1021 entries, but it cannot be used +// if too many different encoding types are used. The regular page holds +// 511 entries. +// + +struct unwind_info_regular_second_level_entry +{ + uint32_t functionOffset; + compact_unwind_encoding_t encoding; +}; + +#define UNWIND_SECOND_LEVEL_REGULAR 2 +struct unwind_info_regular_second_level_page_header +{ + uint32_t kind; // UNWIND_SECOND_LEVEL_REGULAR + uint16_t entryPageOffset; + uint16_t entryCount; + // entry array +}; + +#define UNWIND_SECOND_LEVEL_COMPRESSED 3 +struct unwind_info_compressed_second_level_page_header +{ + uint32_t kind; // UNWIND_SECOND_LEVEL_COMPRESSED + uint16_t entryPageOffset; + uint16_t entryCount; + uint16_t encodingsPageOffset; + uint16_t encodingsCount; + // 32-bit entry array + // encodings array +}; + +#define UNWIND_INFO_COMPRESSED_ENTRY_FUNC_OFFSET(entry) (entry & 0x00FFFFFF) +#define UNWIND_INFO_COMPRESSED_ENTRY_ENCODING_INDEX(entry) ((entry >> 24) & 0xFF) + + + +// architecture independent bits +enum { + UNWIND_IS_NOT_FUNCTION_START = 0x80000000, + UNWIND_HAS_LSDA = 0x40000000, + UNWIND_PERSONALITY_MASK = 0x30000000, +}; + + +// x86_64 +// +// 1-bit: start +// 1-bit: has lsda +// 2-bit: personality index +// +// 4-bits: 0=old, 1=rbp based, 2=stack-imm, 3=stack-ind, 4=dwarf +// rbp based: +// 15-bits (5*3-bits per reg) register permutation +// 8-bits for stack offset +// frameless: +// 8-bits stack size +// 3-bits stack adjust +// 3-bits register count +// 10-bits register permutation +// +enum { + UNWIND_X86_64_MODE_MASK = 0x0F000000, + UNWIND_X86_64_MODE_COMPATIBILITY = 0x00000000, + UNWIND_X86_64_MODE_RBP_FRAME = 0x01000000, + UNWIND_X86_64_MODE_STACK_IMMD = 0x02000000, + UNWIND_X86_64_MODE_STACK_IND = 0x03000000, + UNWIND_X86_64_MODE_DWARF = 0x04000000, + + UNWIND_X86_64_RBP_FRAME_REGISTERS = 0x00007FFF, + UNWIND_X86_64_RBP_FRAME_OFFSET = 0x00FF0000, + + UNWIND_X86_64_FRAMELESS_STACK_SIZE = 0x00FF0000, + UNWIND_X86_64_FRAMELESS_STACK_ADJUST = 0x0000E000, + UNWIND_X86_64_FRAMELESS_STACK_REG_COUNT = 0x00001C00, + UNWIND_X86_64_FRAMELESS_STACK_REG_PERMUTATION = 0x000003FF, + + UNWIND_X86_64_DWARF_SECTION_OFFSET = 0x03FFFFFF, +}; + +enum { + UNWIND_X86_64_REG_NONE = 0, + UNWIND_X86_64_REG_RBX = 1, + UNWIND_X86_64_REG_R12 = 2, + UNWIND_X86_64_REG_R13 = 3, + UNWIND_X86_64_REG_R14 = 4, + UNWIND_X86_64_REG_R15 = 5, + UNWIND_X86_64_REG_RBP = 6, +}; + + +// x86 +// +// 1-bit: start +// 1-bit: has lsda +// 2-bit: personality index +// +// 4-bits: 0=old, 1=ebp based, 2=stack-imm, 3=stack-ind, 4=dwarf +// ebp based: +// 15-bits (5*3-bits per reg) register permutation +// 8-bits for stack offset +// frameless: +// 8-bits stack size +// 3-bits stack adjust +// 3-bits register count +// 10-bits register permutation +// +enum { + UNWIND_X86_MODE_MASK = 0x0F000000, + UNWIND_X86_MODE_COMPATIBILITY = 0x00000000, + UNWIND_X86_MODE_EBP_FRAME = 0x01000000, + UNWIND_X86_MODE_STACK_IMMD = 0x02000000, + UNWIND_X86_MODE_STACK_IND = 0x03000000, + UNWIND_X86_MODE_DWARF = 0x04000000, + + UNWIND_X86_EBP_FRAME_REGISTERS = 0x00007FFF, + UNWIND_X86_EBP_FRAME_OFFSET = 0x00FF0000, + + UNWIND_X86_FRAMELESS_STACK_SIZE = 0x00FF0000, + UNWIND_X86_FRAMELESS_STACK_ADJUST = 0x0000E000, + UNWIND_X86_FRAMELESS_STACK_REG_COUNT = 0x00001C00, + UNWIND_X86_FRAMELESS_STACK_REG_PERMUTATION = 0x000003FF, + + UNWIND_X86_DWARF_SECTION_OFFSET = 0x03FFFFFF, +}; + +enum { + UNWIND_X86_REG_NONE = 0, + UNWIND_X86_REG_EBX = 1, + UNWIND_X86_REG_ECX = 2, + UNWIND_X86_REG_EDX = 3, + UNWIND_X86_REG_EDI = 4, + UNWIND_X86_REG_ESI = 5, + UNWIND_X86_REG_EBP = 6, +}; + + +#endif + Index: branches/azimutz/Cleancut/i386/include/mach-o/dyld_images.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach-o/dyld_images.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach-o/dyld_images.h (revision 885) @@ -0,0 +1,164 @@ +/* + * Copyright (c) 2006-2010 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 _DYLD_IMAGES_ +#define _DYLD_IMAGES_ + +#include <stdbool.h> +#include <unistd.h> +#include <mach/mach.h> + +#ifdef __cplusplus +extern "C" { +#endif + + +/* + * Beginning in Mac OS X 10.4, this is how gdb discovers which mach-o images are loaded in a process. + * + * gdb looks for the symbol "_dyld_all_image_infos" in dyld. It contains the fields below. + * + * For a snashot of what images are currently loaded, the infoArray fields contain a pointer + * to an array of all images. If infoArray is NULL, it means it is being modified, come back later. + * + * To be notified of changes, gdb sets a break point on the address pointed to by the notificationn + * field. The function it points to is called by dyld with an array of information about what images + * have been added (dyld_image_adding) or are about to be removed (dyld_image_removing). + * + * The notification is called after infoArray is updated. This means that if gdb attaches to a process + * and infoArray is NULL, gdb can set a break point on notification and let the proccess continue to + * run until the break point. Then gdb can inspect the full infoArray. + * + * The dyldVersion field always points to a C string that contains the dyld version. For instance, + * in dyld-127.3, dyldVersion would contain a pointer to "127.3". + * + * The errorMessage and terminationFlags fields are normally zero. If dyld terminates a process + * (for instance because a required dylib or symbol is missing), then the errorMessage field will + * be set to point to a C string message buffer containing the reason dyld terminate the process. + * The low bit of the terminationFlags will be set if dyld terminated the process before any user + * code ran, in which case there is no need for the crash log to contain the backtrace. + * + * When dyld terminates a process because some required dylib or symbol cannot be bound, in + * addition to the errorMessage field, it now sets the errorKind field and the corresponding + * fields: errorClientOfDylibPath, errorTargetDylibPath, errorSymbol. + * + */ + +enum dyld_image_mode { dyld_image_adding=0, dyld_image_removing=1 }; + +struct dyld_image_info { + const struct mach_header* imageLoadAddress; /* base address image is mapped into */ + const char* imageFilePath; /* path dyld used to load the image */ + uintptr_t imageFileModDate; /* time_t of image file */ + /* if stat().st_mtime of imageFilePath does not match imageFileModDate, */ + /* then file has been modified since dyld loaded it */ +}; + +struct dyld_uuid_info { + const struct mach_header* imageLoadAddress; /* base address image is mapped into */ + uuid_t imageUUID; /* UUID of image */ +}; + +typedef void (*dyld_image_notifier)(enum dyld_image_mode mode, uint32_t infoCount, const struct dyld_image_info info[]); + +/* for use in dyld_all_image_infos.errorKind field */ +enum { dyld_error_kind_none=0, + dyld_error_kind_dylib_missing=1, + dyld_error_kind_dylib_wrong_arch=2, + dyld_error_kind_dylib_version=3, + dyld_error_kind_symbol_missing=4 + }; + + +struct dyld_all_image_infos { + uint32_t version; /* 1 in Mac OS X 10.4 and 10.5 */ + uint32_t infoArrayCount; + const struct dyld_image_info* infoArray; + dyld_image_notifier notification; + bool processDetachedFromSharedRegion; + /* the following fields are only in version 2 (Mac OS X 10.6, iPhoneOS 2.0) and later */ + bool libSystemInitialized; + const struct mach_header* dyldImageLoadAddress; + /* the following field is only in version 3 (Mac OS X 10.6, iPhoneOS 3.0) and later */ + void* jitInfo; + /* the following fields are only in version 5 (Mac OS X 10.6, iPhoneOS 3.0) and later */ + const char* dyldVersion; + const char* errorMessage; + uintptr_t terminationFlags; + /* the following field is only in version 6 (Mac OS X 10.6, iPhoneOS 3.1) and later */ + void* coreSymbolicationShmPage; + /* the following field is only in version 7 (Mac OS X 10.6, iPhoneOS 3.1) and later */ + uintptr_t systemOrderFlag; + /* the following field is only in version 8 (Mac OS X 10.7, iPhoneOS 3.1) and later */ + uintptr_t uuidArrayCount; + const struct dyld_uuid_info* uuidArray; /* only images not in dyld shared cache */ + /* the following field is only in version 9 (Mac OS X 10.7, iOS 4.0) and later */ + struct dyld_all_image_infos* dyldAllImageInfosAddress; + /* the following field is only in version 10 (Mac OS X 10.7, iOS 4.2) and later */ + uintptr_t initialImageCount; + /* the following field is only in version 11 (Mac OS X 10.7, iOS 4.2) and later */ + uintptr_t errorKind; + const char* errorClientOfDylibPath; + const char* errorTargetDylibPath; + const char* errorSymbol; + /* the following field is only in version 12 (Mac OS X 10.7, iOS 4.3) and later */ + uintptr_t sharedCacheSlide; +}; +extern struct dyld_all_image_infos dyld_all_image_infos; + +/* + * Beginning in Mac OS X 10.6, rather than looking up the symbol "_dyld_all_image_infos" + * in dyld's symbol table, you can add DYLD_ALL_IMAGE_INFOS_OFFSET_OFFSET to the mach_header + * for dyld and read the 32-bit unsigned int at that location. Adding that value to dyld's + * mach_header address gets you the address of dyld_all_image_infos in dyld. + */ +#define DYLD_ALL_IMAGE_INFOS_OFFSET_OFFSET 0x1010 + + + +/* + * Beginning in Mac OS X 10.5, this is how gdb discovers where the shared cache is in a process. + * Images that are in the shared cache have their segments rearranged, so when using imageFilePath + * to load the file from disk, you have to know to adjust addresses based on how their segment + * was rearranged. + * + * gdb looks for the symbol "_dyld_shared_region_ranges" in dyld. + * + * It contains information the count of shared regions used by the process. The count is + * the number of start/length pairs. + */ +struct dyld_shared_cache_ranges { + uintptr_t sharedRegionsCount; /* how many ranges follow */ + struct { + uintptr_t start; + uintptr_t length; + } ranges[4]; /* max regions */ +}; +extern struct dyld_shared_cache_ranges dyld_shared_cache_ranges; + + + +#ifdef __cplusplus +} +#endif + +#endif /* _DYLD_IMAGES_ */ Index: branches/azimutz/Cleancut/i386/include/netinet/in_pcb.h =================================================================== --- branches/azimutz/Cleancut/i386/include/netinet/in_pcb.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/netinet/in_pcb.h (revision 885) @@ -0,0 +1,337 @@ +/* + * Copyright (c) 2000-2008 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) 1982, 1986, 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)in_pcb.h 8.1 (Berkeley) 6/10/93 + * $FreeBSD: src/sys/netinet/in_pcb.h,v 1.32.2.4 2001/08/13 16:26:17 ume Exp $ + */ +/* + * NOTICE: This file was modified by SPARTA, Inc. in 2007 to introduce + * support for mandatory and extensible security protections. This notice + * is included in support of clause 2.2 (b) of the Apple Public License, + * Version 2.0. + */ + +#ifndef _NETINET_IN_PCB_H_ +#define _NETINET_IN_PCB_H_ +#include <sys/appleapiopts.h> + +#include <sys/types.h> +#include <sys/queue.h> + +#include <netinet6/ipsec.h> /* for IPSEC */ + +typedef u_quad_t inp_gen_t; + +/* + * PCB with AF_INET6 null bind'ed laddr can receive AF_INET input packet. + * So, AF_INET6 null laddr is also used as AF_INET null laddr, + * by utilize following structure. (At last, same as INRIA) + */ +struct in_addr_4in6 { + u_int32_t ia46_pad32[3]; + struct in_addr ia46_addr4; +}; + + +/* + * The range of the generation count, as used in this implementation, + * is 9e19. We would have to create 300 billion connections per + * second for this number to roll over in a year. This seems sufficiently + * unlikely that we simply don't concern ourselves with that possibility. + */ + +/* + * Interface exported to userland by various protocols which use + * inpcbs. Hack alert -- only define if struct xsocket is in scope. + */ + +/* + * This is a copy of the inpcb as it shipped in Panther. This structure + * is filled out in a copy function. This allows the inpcb to change + * without breaking userland tools. + * + * CAUTION: Many fields may not be filled out. Fewer may be filled out + * in the future. Code defensively. + */ + +#pragma pack(4) + +#if defined(__LP64__) +struct _inpcb_list_entry { + u_int32_t le_next; + u_int32_t le_prev; +}; +#define _INPCB_PTR(x) u_int32_t +#define _INPCB_LIST_ENTRY(x) struct _inpcb_list_entry +#else +#define _INPCB_PTR(x) x +#define _INPCB_LIST_ENTRY(x) LIST_ENTRY(x) +#endif + +struct inpcbinfo; +struct inpcbport; +struct mbuf; +struct ip6_pktopts; +struct ip6_moptions; +struct icmp6_filter; +struct inpcbpolicy; + +struct inpcb { + _INPCB_LIST_ENTRY(inpcb) inp_hash; /* hash list */ + struct in_addr reserved1; /* APPLE reserved: inp_faddr defined in protcol indep. part */ + struct in_addr reserved2; /* APPLE reserved */ + u_short inp_fport; /* foreign port */ + u_short inp_lport; /* local port */ + _INPCB_LIST_ENTRY(inpcb) inp_list; /* list for all PCBs of this proto */ + _INPCB_PTR(caddr_t) inp_ppcb; /* pointer to per-protocol pcb */ + _INPCB_PTR(struct inpcbinfo *) inp_pcbinfo; /* PCB list info */ + _INPCB_PTR(void *) inp_socket; /* back pointer to socket */ + u_char nat_owner; /* Used to NAT TCP/UDP traffic */ + u_int32_t nat_cookie; /* Cookie stored and returned to NAT */ + _INPCB_LIST_ENTRY(inpcb) inp_portlist; /* list for this PCB's local port */ + _INPCB_PTR(struct inpcbport *) inp_phd; /* head of this list */ + inp_gen_t inp_gencnt; /* generation count of this instance */ + int inp_flags; /* generic IP/datagram flags */ + u_int32_t inp_flow; + + u_char inp_vflag; + + u_char inp_ip_ttl; /* time to live proto */ + u_char inp_ip_p; /* protocol proto */ + /* protocol dependent part */ + union { + /* foreign host table entry */ + struct in_addr_4in6 inp46_foreign; + struct in6_addr inp6_foreign; + } inp_dependfaddr; + union { + /* local host table entry */ + struct in_addr_4in6 inp46_local; + struct in6_addr inp6_local; + } inp_dependladdr; + union { + /* placeholder for routing entry */ + u_char inp4_route[20]; + u_char inp6_route[32]; + } inp_dependroute; + struct { + /* type of service proto */ + u_char inp4_ip_tos; + /* IP options */ + _INPCB_PTR(struct mbuf *) inp4_options; + /* IP multicast options */ + _INPCB_PTR(struct ip_moptions *) inp4_moptions; + } inp_depend4; + + struct { + /* IP options */ + _INPCB_PTR(struct mbuf *) inp6_options; + u_int8_t inp6_hlim; + u_int8_t unused_uint8_1; + ushort unused_uint16_1; + /* IP6 options for outgoing packets */ + _INPCB_PTR(struct ip6_pktopts *) inp6_outputopts; + /* IP multicast options */ + _INPCB_PTR(struct ip6_moptions *) inp6_moptions; + /* ICMPv6 code type filter */ + _INPCB_PTR(struct icmp6_filter *) inp6_icmp6filt; + /* IPV6_CHECKSUM setsockopt */ + int inp6_cksum; + u_short inp6_ifindex; + short inp6_hops; + } inp_depend6; + + int hash_element; /* Array index of pcb's hash list */ + _INPCB_PTR(caddr_t) inp_saved_ppcb; /* place to save pointer while cached */ + _INPCB_PTR(struct inpcbpolicy *) inp_sp; + u_int32_t reserved[3]; /* For future use */ +}; + +struct xinpcb { + u_int32_t xi_len; /* length of this structure */ + struct inpcb xi_inp; + struct xsocket xi_socket; + u_quad_t xi_alignment_hack; +}; + +#if !CONFIG_EMBEDDED + +struct inpcb64_list_entry { + u_int64_t le_next; + u_int64_t le_prev; +}; + +struct xinpcb64 { + u_int64_t xi_len; /* length of this structure */ + u_int64_t xi_inpp; + u_short inp_fport; /* foreign port */ + u_short inp_lport; /* local port */ + struct inpcb64_list_entry + inp_list; /* list for all PCBs of this proto */ + u_int64_t inp_ppcb; /* pointer to per-protocol pcb */ + u_int64_t inp_pcbinfo; /* PCB list info */ + struct inpcb64_list_entry + inp_portlist; /* list for this PCB's local port */ + u_int64_t inp_phd; /* head of this list */ + inp_gen_t inp_gencnt; /* generation count of this instance */ + int inp_flags; /* generic IP/datagram flags */ + u_int32_t inp_flow; + u_char inp_vflag; + u_char inp_ip_ttl; /* time to live */ + u_char inp_ip_p; /* protocol */ + union { /* foreign host table entry */ + struct in_addr_4in6 inp46_foreign; + struct in6_addr inp6_foreign; + } inp_dependfaddr; + union { /* local host table entry */ + struct in_addr_4in6 inp46_local; + struct in6_addr inp6_local; + } inp_dependladdr; + struct { + u_char inp4_ip_tos; /* type of service */ + } inp_depend4; + struct { + u_int8_t inp6_hlim; + int inp6_cksum; + u_short inp6_ifindex; + short inp6_hops; + } inp_depend6; + struct xsocket64 xi_socket; + u_quad_t xi_alignment_hack; +}; + +#endif /* !CONFIG_EMBEDDED */ + +struct xinpgen { + u_int32_t xig_len; /* length of this structure */ + u_int xig_count; /* number of PCBs at this time */ + inp_gen_t xig_gen; /* generation count at this time */ + so_gen_t xig_sogen; /* socket generation count at this time */ +}; + +#pragma pack() + +/* + * These defines are for use with the inpcb. + */ +#define INP_IPV4 0x1 +#define INP_IPV6 0x2 +#define inp_faddr inp_dependfaddr.inp46_foreign.ia46_addr4 +#define inp_laddr inp_dependladdr.inp46_local.ia46_addr4 +#define inp_route inp_dependroute.inp4_route +#define inp_ip_tos inp_depend4.inp4_ip_tos +#define inp_options inp_depend4.inp4_options +#define inp_moptions inp_depend4.inp4_moptions +#define in6p_faddr inp_dependfaddr.inp6_foreign +#define in6p_laddr inp_dependladdr.inp6_local +#define in6p_route inp_dependroute.inp6_route +#define in6p_ip6_hlim inp_depend6.inp6_hlim +#define in6p_hops inp_depend6.inp6_hops /* default hop limit */ +#define in6p_ip6_nxt inp_ip_p +#define in6p_flowinfo inp_flow +#define in6p_vflag inp_vflag +#define in6p_options inp_depend6.inp6_options +#define in6p_outputopts inp_depend6.inp6_outputopts +#define in6p_moptions inp_depend6.inp6_moptions +#define in6p_icmp6filt inp_depend6.inp6_icmp6filt +#define in6p_cksum inp_depend6.inp6_cksum +#define in6p_ifindex inp_depend6.inp6_ifindex +#define in6p_flags inp_flags /* for KAME src sync over BSD*'s */ +#define in6p_socket inp_socket /* for KAME src sync over BSD*'s */ +#define in6p_lport inp_lport /* for KAME src sync over BSD*'s */ +#define in6p_fport inp_fport /* for KAME src sync over BSD*'s */ +#define in6p_ppcb inp_ppcb /* for KAME src sync over BSD*'s */ +#define in6p_state inp_state +#define in6p_wantcnt inp_wantcnt + + +/* flags in inp_flags: */ +#define INP_RECVOPTS 0x01 /* receive incoming IP options */ +#define INP_RECVRETOPTS 0x02 /* receive IP options for reply */ +#define INP_RECVDSTADDR 0x04 /* receive IP dst address */ +#define INP_HDRINCL 0x08 /* user supplies entire IP header */ +#define INP_HIGHPORT 0x10 /* user wants "high" port binding */ +#define INP_LOWPORT 0x20 /* user wants "low" port binding */ +#define INP_ANONPORT 0x40 /* port chosen for user */ +#define INP_RECVIF 0x80 /* receive incoming interface */ +#define INP_MTUDISC 0x100 /* user can do MTU discovery */ +#ifdef __APPLE__ +#define INP_STRIPHDR 0x200 /* Strip headers in raw_ip, for OT support */ +#endif +#define INP_FAITH 0x400 /* accept FAITH'ed connections */ +#define INP_INADDR_ANY 0x800 /* local address wasn't specified */ + +#define INP_RECVTTL 0x1000 +#define INP_UDP_NOCKSUM 0x2000 /* Turn off outbound UDP checksum */ +#define INP_BOUND_IF 0x4000 /* bind socket to an ifindex */ + +#define IN6P_IPV6_V6ONLY 0x008000 /* restrict AF_INET6 socket for v6 */ + +#define IN6P_PKTINFO 0x010000 /* receive IP6 dst and I/F */ +#define IN6P_HOPLIMIT 0x020000 /* receive hoplimit */ +#define IN6P_HOPOPTS 0x040000 /* receive hop-by-hop options */ +#define IN6P_DSTOPTS 0x080000 /* receive dst options after rthdr */ +#define IN6P_RTHDR 0x100000 /* receive routing header */ +#define IN6P_RTHDRDSTOPTS 0x200000 /* receive dstoptions before rthdr */ +#define IN6P_TCLASS 0x400000 /* receive traffic class value */ +#define IN6P_AUTOFLOWLABEL 0x800000 /* attach flowlabel automatically */ +#define IN6P_BINDV6ONLY 0x10000000 /* do not grab IPv4 traffic */ + + +#endif /* !_NETINET_IN_PCB_H_ */ Index: branches/azimutz/Cleancut/i386/include/netinet/tcp_fsm.h =================================================================== --- branches/azimutz/Cleancut/i386/include/netinet/tcp_fsm.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/netinet/tcp_fsm.h (revision 885) @@ -0,0 +1,120 @@ +/* + * Copyright (c) 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) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)tcp_fsm.h 8.1 (Berkeley) 6/10/93 + * $FreeBSD: src/sys/netinet/tcp_fsm.h,v 1.14 1999/11/07 04:18:30 jlemon Exp $ + */ + +#ifndef _NETINET_TCP_FSM_H_ +#define _NETINET_TCP_FSM_H_ +#include <sys/appleapiopts.h> + +/* + * TCP FSM state definitions. + * Per RFC793, September, 1981. + */ + +#define TCP_NSTATES 11 + +#define TCPS_CLOSED 0 /* closed */ +#define TCPS_LISTEN 1 /* listening for connection */ +#define TCPS_SYN_SENT 2 /* active, have sent syn */ +#define TCPS_SYN_RECEIVED 3 /* have send and received syn */ +/* states < TCPS_ESTABLISHED are those where connections not established */ +#define TCPS_ESTABLISHED 4 /* established */ +#define TCPS_CLOSE_WAIT 5 /* rcvd fin, waiting for close */ +/* states > TCPS_CLOSE_WAIT are those where user has closed */ +#define TCPS_FIN_WAIT_1 6 /* have closed, sent fin */ +#define TCPS_CLOSING 7 /* closed xchd FIN; await FIN ACK */ +#define TCPS_LAST_ACK 8 /* had fin and close; await FIN ACK */ +/* states > TCPS_CLOSE_WAIT && < TCPS_FIN_WAIT_2 await ACK of FIN */ +#define TCPS_FIN_WAIT_2 9 /* have closed, fin is acked */ +#define TCPS_TIME_WAIT 10 /* in 2*msl quiet wait after close */ + +/* for KAME src sync over BSD*'s */ +#define TCP6_NSTATES TCP_NSTATES +#define TCP6S_CLOSED TCPS_CLOSED +#define TCP6S_LISTEN TCPS_LISTEN +#define TCP6S_SYN_SENT TCPS_SYN_SENT +#define TCP6S_SYN_RECEIVED TCPS_SYN_RECEIVED +#define TCP6S_ESTABLISHED TCPS_ESTABLISHED +#define TCP6S_CLOSE_WAIT TCPS_CLOSE_WAIT +#define TCP6S_FIN_WAIT_1 TCPS_FIN_WAIT_1 +#define TCP6S_CLOSING TCPS_CLOSING +#define TCP6S_LAST_ACK TCPS_LAST_ACK +#define TCP6S_FIN_WAIT_2 TCPS_FIN_WAIT_2 +#define TCP6S_TIME_WAIT TCPS_TIME_WAIT + +#define TCPS_HAVERCVDSYN(s) ((s) >= TCPS_SYN_RECEIVED) +#define TCPS_HAVEESTABLISHED(s) ((s) >= TCPS_ESTABLISHED) +#define TCPS_HAVERCVDFIN(s) ((s) >= TCPS_TIME_WAIT) + + +#if KPROF +#endif + +#ifdef TCPSTATES +char *tcpstates[] = { + "CLOSED", "LISTEN", "SYN_SENT", "SYN_RCVD", + "ESTABLISHED", "CLOSE_WAIT", "FIN_WAIT_1", "CLOSING", + "LAST_ACK", "FIN_WAIT_2", "TIME_WAIT" +}; +#endif + +#endif Index: branches/azimutz/Cleancut/i386/include/netinet/igmp.h =================================================================== --- branches/azimutz/Cleancut/i386/include/netinet/igmp.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/netinet/igmp.h (revision 885) @@ -0,0 +1,124 @@ +/* + * Copyright (c) 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) 1988 Stephen Deering. + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Stephen Deering of Stanford University. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)igmp.h 8.1 (Berkeley) 6/10/93 + * $FreeBSD: src/sys/netinet/igmp.h,v 1.10 1999/08/28 00:49:15 peter Exp $ + */ + +#ifndef _NETINET_IGMP_H_ +#define _NETINET_IGMP_H_ +#include <sys/appleapiopts.h> + +/* + * Internet Group Management Protocol (IGMP) definitions. + * + * Written by Steve Deering, Stanford, May 1988. + * + * MULTICAST Revision: 3.5.1.2 + */ + +/* + * IGMP packet format. + */ +struct igmp { + u_char igmp_type; /* version & type of IGMP message */ + u_char igmp_code; /* subtype for routing msgs */ + u_short igmp_cksum; /* IP-style checksum */ + struct in_addr igmp_group; /* group address being reported */ +}; /* (zero for queries) */ + +#define IGMP_MINLEN 8 + +/* + * Message types, including version number. + */ +#define IGMP_MEMBERSHIP_QUERY 0x11 /* membership query */ +#define IGMP_V1_MEMBERSHIP_REPORT 0x12 /* Ver. 1 membership report */ +#define IGMP_V2_MEMBERSHIP_REPORT 0x16 /* Ver. 2 membership report */ +#define IGMP_V2_LEAVE_GROUP 0x17 /* Leave-group message */ + +#define IGMP_DVMRP 0x13 /* DVMRP routing message */ +#define IGMP_PIM 0x14 /* PIM routing message */ + +#define IGMP_MTRACE_RESP 0x1e /* traceroute resp.(to sender)*/ +#define IGMP_MTRACE 0x1f /* mcast traceroute messages */ + +#define IGMP_MAX_HOST_REPORT_DELAY 10 /* max delay for response to */ + /* query (in seconds) according */ + /* to RFC1112 */ + + +#define IGMP_TIMER_SCALE 10 /* denotes that the igmp code field */ + /* specifies time in 10th of seconds*/ + +/* + * The following four defininitions are for backwards compatibility. + * They should be removed as soon as all applications are updated to + * use the new constant names. + */ +#define IGMP_HOST_MEMBERSHIP_QUERY IGMP_MEMBERSHIP_QUERY +#define IGMP_HOST_MEMBERSHIP_REPORT IGMP_V1_MEMBERSHIP_REPORT +#define IGMP_HOST_NEW_MEMBERSHIP_REPORT IGMP_V2_MEMBERSHIP_REPORT +#define IGMP_HOST_LEAVE_MESSAGE IGMP_V2_LEAVE_GROUP + +#endif /* _NETINET_IGMP_H_ */ Index: branches/azimutz/Cleancut/i386/include/netinet/tcp_var.h =================================================================== --- branches/azimutz/Cleancut/i386/include/netinet/tcp_var.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/netinet/tcp_var.h (revision 885) @@ -0,0 +1,413 @@ +/* + * Copyright (c) 2000-2008 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) 1982, 1986, 1993, 1994, 1995 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)tcp_var.h 8.4 (Berkeley) 5/24/95 + * $FreeBSD: src/sys/netinet/tcp_var.h,v 1.56.2.8 2001/08/22 00:59:13 silby Exp $ + */ + +#ifndef _NETINET_TCP_VAR_H_ +#define _NETINET_TCP_VAR_H_ +#include <sys/appleapiopts.h> +#include <sys/queue.h> +#include <netinet/in_pcb.h> +#include <netinet/tcp_timer.h> + +#if defined(__LP64__) +#define _TCPCB_PTR(x) u_int32_t +#define _TCPCB_LIST_HEAD(name, type) \ +struct name { \ + u_int32_t lh_first; \ +}; +#else +#define _TCPCB_PTR(x) x +#define _TCPCB_LIST_HEAD(name, type) LIST_HEAD(name, type) +#endif + +#define TCP_RETRANSHZ 10 /* tcp retrans timer (100ms) per hz */ + +struct tseg_qent; +_TCPCB_LIST_HEAD(tsegqe_head, tseg_qent); + +struct tcpcb { + struct tsegqe_head t_segq; + int t_dupacks; /* consecutive dup acks recd */ + u_int32_t unused; /* unused now: was t_template */ + + int t_timer[TCPT_NTIMERS]; /* tcp timers */ + + _TCPCB_PTR(struct inpcb *) t_inpcb; /* back pointer to internet pcb */ + int t_state; /* state of this connection */ + u_int t_flags; +#define TF_ACKNOW 0x00001 /* ack peer immediately */ +#define TF_DELACK 0x00002 /* ack, but try to delay it */ +#define TF_NODELAY 0x00004 /* don't delay packets to coalesce */ +#define TF_NOOPT 0x00008 /* don't use tcp options */ +#define TF_SENTFIN 0x00010 /* have sent FIN */ +#define TF_REQ_SCALE 0x00020 /* have/will request window scaling */ +#define TF_RCVD_SCALE 0x00040 /* other side has requested scaling */ +#define TF_REQ_TSTMP 0x00080 /* have/will request timestamps */ +#define TF_RCVD_TSTMP 0x00100 /* a timestamp was received in SYN */ +#define TF_SACK_PERMIT 0x00200 /* other side said I could SACK */ +#define TF_NEEDSYN 0x00400 /* send SYN (implicit state) */ +#define TF_NEEDFIN 0x00800 /* send FIN (implicit state) */ +#define TF_NOPUSH 0x01000 /* don't push */ +#define TF_REQ_CC 0x02000 /* have/will request CC */ +#define TF_RCVD_CC 0x04000 /* a CC was received in SYN */ +#define TF_SENDCCNEW 0x08000 /* send CCnew instead of CC in SYN */ +#define TF_MORETOCOME 0x10000 /* More data to be appended to sock */ +#define TF_LQ_OVERFLOW 0x20000 /* listen queue overflow */ +#define TF_RXWIN0SENT 0x40000 /* sent a receiver win 0 in response */ +#define TF_SLOWLINK 0x80000 /* route is a on a modem speed link */ + + int t_force; /* 1 if forcing out a byte */ + + tcp_seq snd_una; /* send unacknowledged */ + tcp_seq snd_max; /* highest sequence number sent; + * used to recognize retransmits + */ + tcp_seq snd_nxt; /* send next */ + tcp_seq snd_up; /* send urgent pointer */ + + tcp_seq snd_wl1; /* window update seg seq number */ + tcp_seq snd_wl2; /* window update seg ack number */ + tcp_seq iss; /* initial send sequence number */ + tcp_seq irs; /* initial receive sequence number */ + + tcp_seq rcv_nxt; /* receive next */ + tcp_seq rcv_adv; /* advertised window */ + u_int32_t rcv_wnd; /* receive window */ + tcp_seq rcv_up; /* receive urgent pointer */ + + u_int32_t snd_wnd; /* send window */ + u_int32_t snd_cwnd; /* congestion-controlled window */ + u_int32_t snd_ssthresh; /* snd_cwnd size threshold for + * for slow start exponential to + * linear switch + */ + u_int t_maxopd; /* mss plus options */ + + u_int32_t t_rcvtime; /* inactivity time */ + u_int32_t t_starttime; /* time connection was established */ + int t_rtttime; /* round trip time */ + tcp_seq t_rtseq; /* sequence number being timed */ + + int t_rxtcur; /* current retransmit value (ticks) */ + u_int t_maxseg; /* maximum segment size */ + int t_srtt; /* smoothed round-trip time */ + int t_rttvar; /* variance in round-trip time */ + + int t_rxtshift; /* log(2) of rexmt exp. backoff */ + u_int t_rttmin; /* minimum rtt allowed */ + u_int32_t t_rttupdated; /* number of times rtt sampled */ + u_int32_t max_sndwnd; /* largest window peer has offered */ + + int t_softerror; /* possible error not yet reported */ +/* out-of-band data */ + char t_oobflags; /* have some */ + char t_iobc; /* input character */ +#define TCPOOB_HAVEDATA 0x01 +#define TCPOOB_HADDATA 0x02 +/* RFC 1323 variables */ + u_char snd_scale; /* window scaling for send window */ + u_char rcv_scale; /* window scaling for recv window */ + u_char request_r_scale; /* pending window scaling */ + u_char requested_s_scale; + u_int32_t ts_recent; /* timestamp echo data */ + + u_int32_t ts_recent_age; /* when last updated */ + tcp_seq last_ack_sent; +/* RFC 1644 variables */ + tcp_cc cc_send; /* send connection count */ + tcp_cc cc_recv; /* receive connection count */ + tcp_seq snd_recover; /* for use in fast recovery */ +/* experimental */ + u_int32_t snd_cwnd_prev; /* cwnd prior to retransmit */ + u_int32_t snd_ssthresh_prev; /* ssthresh prior to retransmit */ + u_int32_t t_badrxtwin; /* window for retransmit recovery */ +}; + + +/* + * TCP statistics. + * Many of these should be kept per connection, + * but that's inconvenient at the moment. + */ +struct tcpstat { + u_int32_t tcps_connattempt; /* connections initiated */ + u_int32_t tcps_accepts; /* connections accepted */ + u_int32_t tcps_connects; /* connections established */ + u_int32_t tcps_drops; /* connections dropped */ + u_int32_t tcps_conndrops; /* embryonic connections dropped */ + u_int32_t tcps_closed; /* conn. closed (includes drops) */ + u_int32_t tcps_segstimed; /* segs where we tried to get rtt */ + u_int32_t tcps_rttupdated; /* times we succeeded */ + u_int32_t tcps_delack; /* delayed acks sent */ + u_int32_t tcps_timeoutdrop; /* conn. dropped in rxmt timeout */ + u_int32_t tcps_rexmttimeo; /* retransmit timeouts */ + u_int32_t tcps_persisttimeo; /* persist timeouts */ + u_int32_t tcps_keeptimeo; /* keepalive timeouts */ + u_int32_t tcps_keepprobe; /* keepalive probes sent */ + u_int32_t tcps_keepdrops; /* connections dropped in keepalive */ + + u_int32_t tcps_sndtotal; /* total packets sent */ + u_int32_t tcps_sndpack; /* data packets sent */ + u_int32_t tcps_sndbyte; /* data bytes sent */ + u_int32_t tcps_sndrexmitpack; /* data packets retransmitted */ + u_int32_t tcps_sndrexmitbyte; /* data bytes retransmitted */ + u_int32_t tcps_sndacks; /* ack-only packets sent */ + u_int32_t tcps_sndprobe; /* window probes sent */ + u_int32_t tcps_sndurg; /* packets sent with URG only */ + u_int32_t tcps_sndwinup; /* window update-only packets sent */ + u_int32_t tcps_sndctrl; /* control (SYN|FIN|RST) packets sent */ + + u_int32_t tcps_rcvtotal; /* total packets received */ + u_int32_t tcps_rcvpack; /* packets received in sequence */ + u_int32_t tcps_rcvbyte; /* bytes received in sequence */ + u_int32_t tcps_rcvbadsum; /* packets received with ccksum errs */ + u_int32_t tcps_rcvbadoff; /* packets received with bad offset */ + u_int32_t tcps_rcvmemdrop; /* packets dropped for lack of memory */ + u_int32_t tcps_rcvshort; /* packets received too short */ + u_int32_t tcps_rcvduppack; /* duplicate-only packets received */ + u_int32_t tcps_rcvdupbyte; /* duplicate-only bytes received */ + u_int32_t tcps_rcvpartduppack; /* packets with some duplicate data */ + u_int32_t tcps_rcvpartdupbyte; /* dup. bytes in part-dup. packets */ + u_int32_t tcps_rcvoopack; /* out-of-order packets received */ + u_int32_t tcps_rcvoobyte; /* out-of-order bytes received */ + u_int32_t tcps_rcvpackafterwin; /* packets with data after window */ + u_int32_t tcps_rcvbyteafterwin; /* bytes rcvd after window */ + u_int32_t tcps_rcvafterclose; /* packets rcvd after "close" */ + u_int32_t tcps_rcvwinprobe; /* rcvd window probe packets */ + u_int32_t tcps_rcvdupack; /* rcvd duplicate acks */ + u_int32_t tcps_rcvacktoomuch; /* rcvd acks for unsent data */ + u_int32_t tcps_rcvackpack; /* rcvd ack packets */ + u_int32_t tcps_rcvackbyte; /* bytes acked by rcvd acks */ + u_int32_t tcps_rcvwinupd; /* rcvd window update packets */ + u_int32_t tcps_pawsdrop; /* segments dropped due to PAWS */ + u_int32_t tcps_predack; /* times hdr predict ok for acks */ + u_int32_t tcps_preddat; /* times hdr predict ok for data pkts */ + u_int32_t tcps_pcbcachemiss; + u_int32_t tcps_cachedrtt; /* times cached RTT in route updated */ + u_int32_t tcps_cachedrttvar; /* times cached rttvar updated */ + u_int32_t tcps_cachedssthresh; /* times cached ssthresh updated */ + u_int32_t tcps_usedrtt; /* times RTT initialized from route */ + u_int32_t tcps_usedrttvar; /* times RTTVAR initialized from rt */ + u_int32_t tcps_usedssthresh; /* times ssthresh initialized from rt*/ + u_int32_t tcps_persistdrop; /* timeout in persist state */ + u_int32_t tcps_badsyn; /* bogus SYN, e.g. premature ACK */ + u_int32_t tcps_mturesent; /* resends due to MTU discovery */ + u_int32_t tcps_listendrop; /* listen queue overflows */ + + /* new stats from FreeBSD 5.4 sync up */ + u_int32_t tcps_minmssdrops; /* average minmss too low drops */ + u_int32_t tcps_sndrexmitbad; /* unnecessary packet retransmissions */ + u_int32_t tcps_badrst; /* ignored RSTs in the window */ + + u_int32_t tcps_sc_added; /* entry added to syncache */ + u_int32_t tcps_sc_retransmitted; /* syncache entry was retransmitted */ + u_int32_t tcps_sc_dupsyn; /* duplicate SYN packet */ + u_int32_t tcps_sc_dropped; /* could not reply to packet */ + u_int32_t tcps_sc_completed; /* successful extraction of entry */ + u_int32_t tcps_sc_bucketoverflow; /* syncache per-bucket limit hit */ + u_int32_t tcps_sc_cacheoverflow; /* syncache cache limit hit */ + u_int32_t tcps_sc_reset; /* RST removed entry from syncache */ + u_int32_t tcps_sc_stale; /* timed out or listen socket gone */ + u_int32_t tcps_sc_aborted; /* syncache entry aborted */ + u_int32_t tcps_sc_badack; /* removed due to bad ACK */ + u_int32_t tcps_sc_unreach; /* ICMP unreachable received */ + u_int32_t tcps_sc_zonefail; /* zalloc() failed */ + u_int32_t tcps_sc_sendcookie; /* SYN cookie sent */ + u_int32_t tcps_sc_recvcookie; /* SYN cookie received */ + + u_int32_t tcps_hc_added; /* entry added to hostcache */ + u_int32_t tcps_hc_bucketoverflow; /* hostcache per bucket limit hit */ + + /* SACK related stats */ + u_int32_t tcps_sack_recovery_episode; /* SACK recovery episodes */ + u_int32_t tcps_sack_rexmits; /* SACK rexmit segments */ + u_int32_t tcps_sack_rexmit_bytes; /* SACK rexmit bytes */ + u_int32_t tcps_sack_rcv_blocks; /* SACK blocks (options) received */ + u_int32_t tcps_sack_send_blocks; /* SACK blocks (options) sent */ + u_int32_t tcps_sack_sboverflow; /* SACK sendblock overflow */ + +#if TRAFFIC_MGT + u_int32_t tcps_bg_rcvtotal; /* total background packets received */ +#endif /* TRAFFIC_MGT */ +}; + +#pragma pack(4) + +/* + * TCB structure exported to user-land via sysctl(3). + * Evil hack: declare only if in_pcb.h and sys/socketvar.h have been + * included. Not all of our clients do. + */ + +struct xtcpcb { + u_int32_t xt_len; + struct inpcb xt_inp; + struct tcpcb xt_tp; + struct xsocket xt_socket; + u_quad_t xt_alignment_hack; +}; + +#if !CONFIG_EMBEDDED + +struct xtcpcb64 { + u_int32_t xt_len; + struct xinpcb64 xt_inpcb; + + u_int64_t t_segq; + int t_dupacks; /* consecutive dup acks recd */ + + int t_timer[TCPT_NTIMERS]; /* tcp timers */ + + int t_state; /* state of this connection */ + u_int t_flags; + + int t_force; /* 1 if forcing out a byte */ + + tcp_seq snd_una; /* send unacknowledged */ + tcp_seq snd_max; /* highest sequence number sent; + * used to recognize retransmits + */ + tcp_seq snd_nxt; /* send next */ + tcp_seq snd_up; /* send urgent pointer */ + + tcp_seq snd_wl1; /* window update seg seq number */ + tcp_seq snd_wl2; /* window update seg ack number */ + tcp_seq iss; /* initial send sequence number */ + tcp_seq irs; /* initial receive sequence number */ + + tcp_seq rcv_nxt; /* receive next */ + tcp_seq rcv_adv; /* advertised window */ + u_int32_t rcv_wnd; /* receive window */ + tcp_seq rcv_up; /* receive urgent pointer */ + + u_int32_t snd_wnd; /* send window */ + u_int32_t snd_cwnd; /* congestion-controlled window */ + u_int32_t snd_ssthresh; /* snd_cwnd size threshold for + * for slow start exponential to + * linear switch + */ + u_int t_maxopd; /* mss plus options */ + + u_int32_t t_rcvtime; /* inactivity time */ + u_int32_t t_starttime; /* time connection was established */ + int t_rtttime; /* round trip time */ + tcp_seq t_rtseq; /* sequence number being timed */ + + int t_rxtcur; /* current retransmit value (ticks) */ + u_int t_maxseg; /* maximum segment size */ + int t_srtt; /* smoothed round-trip time */ + int t_rttvar; /* variance in round-trip time */ + + int t_rxtshift; /* log(2) of rexmt exp. backoff */ + u_int t_rttmin; /* minimum rtt allowed */ + u_int32_t t_rttupdated; /* number of times rtt sampled */ + u_int32_t max_sndwnd; /* largest window peer has offered */ + + int t_softerror; /* possible error not yet reported */ +/* out-of-band data */ + char t_oobflags; /* have some */ + char t_iobc; /* input character */ +/* RFC 1323 variables */ + u_char snd_scale; /* window scaling for send window */ + u_char rcv_scale; /* window scaling for recv window */ + u_char request_r_scale; /* pending window scaling */ + u_char requested_s_scale; + u_int32_t ts_recent; /* timestamp echo data */ + + u_int32_t ts_recent_age; /* when last updated */ + tcp_seq last_ack_sent; +/* RFC 1644 variables */ + tcp_cc cc_send; /* send connection count */ + tcp_cc cc_recv; /* receive connection count */ + tcp_seq snd_recover; /* for use in fast recovery */ +/* experimental */ + u_int32_t snd_cwnd_prev; /* cwnd prior to retransmit */ + u_int32_t snd_ssthresh_prev; /* ssthresh prior to retransmit */ + u_int32_t t_badrxtwin; /* window for retransmit recovery */ + + u_quad_t xt_alignment_hack; +}; + +#endif /* !CONFIG_EMBEDDED */ + +#pragma pack() + +/* + * Names for TCP sysctl objects + */ +#define TCPCTL_DO_RFC1323 1 /* use RFC-1323 extensions */ +#define TCPCTL_DO_RFC1644 2 /* use RFC-1644 extensions */ +#define TCPCTL_MSSDFLT 3 /* MSS default */ +#define TCPCTL_STATS 4 /* statistics (read-only) */ +#define TCPCTL_RTTDFLT 5 /* default RTT estimate */ +#define TCPCTL_KEEPIDLE 6 /* keepalive idle timer */ +#define TCPCTL_KEEPINTVL 7 /* interval to send keepalives */ +#define TCPCTL_SENDSPACE 8 /* send buffer space */ +#define TCPCTL_RECVSPACE 9 /* receive buffer space */ +#define TCPCTL_KEEPINIT 10 /* timeout for establishing syn */ +#define TCPCTL_PCBLIST 11 /* list of all outstanding PCBs */ +#define TCPCTL_DELACKTIME 12 /* time before sending delayed ACK */ +#define TCPCTL_V6MSSDFLT 13 /* MSS default for IPv6 */ +#define TCPCTL_MAXID 14 + + +#endif /* _NETINET_TCP_VAR_H_ */ Index: branches/azimutz/Cleancut/i386/include/netinet/tcp_seq.h =================================================================== --- branches/azimutz/Cleancut/i386/include/netinet/tcp_seq.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/netinet/tcp_seq.h (revision 885) @@ -0,0 +1,97 @@ +/* + * Copyright (c) 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) 1982, 1986, 1993, 1995 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)tcp_seq.h 8.3 (Berkeley) 6/21/95 + * $FreeBSD: src/sys/netinet/tcp_seq.h,v 1.11.2.5 2001/08/22 00:59:12 silby Exp $ + */ + +#ifndef _NETINET_TCP_SEQ_H_ +#define _NETINET_TCP_SEQ_H_ +#include <sys/appleapiopts.h> +/* + * TCP sequence numbers are 32 bit integers operated + * on with modular arithmetic. These macros can be + * used to compare such integers. + */ +#define SEQ_LT(a,b) ((int)((a)-(b)) < 0) +#define SEQ_LEQ(a,b) ((int)((a)-(b)) <= 0) +#define SEQ_GT(a,b) ((int)((a)-(b)) > 0) +#define SEQ_GEQ(a,b) ((int)((a)-(b)) >= 0) + +#define SEQ_MIN(a, b) ((SEQ_LT(a, b)) ? (a) : (b)) +#define SEQ_MAX(a, b) ((SEQ_GT(a, b)) ? (a) : (b)) + +/* for modulo comparisons of timestamps */ +#define TSTMP_LT(a,b) ((int)((a)-(b)) < 0) +#define TSTMP_GEQ(a,b) ((int)((a)-(b)) >= 0) + +/* + * TCP connection counts are 32 bit integers operated + * on with modular arithmetic. These macros can be + * used to compare such integers. + */ +#define CC_LT(a,b) ((int)((a)-(b)) < 0) +#define CC_LEQ(a,b) ((int)((a)-(b)) <= 0) +#define CC_GT(a,b) ((int)((a)-(b)) > 0) +#define CC_GEQ(a,b) ((int)((a)-(b)) >= 0) + +/* Macro to increment a CC: skip 0 which has a special meaning */ +#define CC_INC(c) (++(c) == 0 ? ++(c) : (c)) + +#endif /* _NETINET_TCP_SEQ_H_ */ Index: branches/azimutz/Cleancut/i386/include/netinet/ip6.h =================================================================== --- branches/azimutz/Cleancut/i386/include/netinet/ip6.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/netinet/ip6.h (revision 885) @@ -0,0 +1,246 @@ +/* + * Copyright (c) 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@ + */ +/* $KAME: ip6.h,v 1.18 2001/03/29 05:34:30 itojun Exp $*/ + +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * Copyright (c) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)ip.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _NETINET_IP6_H_ +#define _NETINET_IP6_H_ +#include <sys/appleapiopts.h> + +/* + * Definition for internet protocol version 6. + * RFC 2460 + */ + +struct ip6_hdr { + union { + struct ip6_hdrctl { + u_int32_t ip6_un1_flow; /* 20 bits of flow-ID */ + u_int16_t ip6_un1_plen; /* payload length */ + u_int8_t ip6_un1_nxt; /* next header */ + u_int8_t ip6_un1_hlim; /* hop limit */ + } ip6_un1; + u_int8_t ip6_un2_vfc; /* 4 bits version, top 4 bits class */ + } ip6_ctlun; + struct in6_addr ip6_src; /* source address */ + struct in6_addr ip6_dst; /* destination address */ +} __attribute__((__packed__)); + +#define ip6_vfc ip6_ctlun.ip6_un2_vfc +#define ip6_flow ip6_ctlun.ip6_un1.ip6_un1_flow +#define ip6_plen ip6_ctlun.ip6_un1.ip6_un1_plen +#define ip6_nxt ip6_ctlun.ip6_un1.ip6_un1_nxt +#define ip6_hlim ip6_ctlun.ip6_un1.ip6_un1_hlim +#define ip6_hops ip6_ctlun.ip6_un1.ip6_un1_hlim + +#define IPV6_VERSION 0x60 +#define IPV6_VERSION_MASK 0xf0 + +#if BYTE_ORDER == BIG_ENDIAN +#define IPV6_FLOWINFO_MASK 0x0fffffff /* flow info (28 bits) */ +#define IPV6_FLOWLABEL_MASK 0x000fffff /* flow label (20 bits) */ +#else +#if BYTE_ORDER == LITTLE_ENDIAN +#define IPV6_FLOWINFO_MASK 0xffffff0f /* flow info (28 bits) */ +#define IPV6_FLOWLABEL_MASK 0xffff0f00 /* flow label (20 bits) */ +#endif /* LITTLE_ENDIAN */ +#endif +#if 1 +/* ECN bits proposed by Sally Floyd */ +#define IP6TOS_CE 0x01 /* congestion experienced */ +#define IP6TOS_ECT 0x02 /* ECN-capable transport */ +#endif + +/* + * Extension Headers + */ + +struct ip6_ext { + u_int8_t ip6e_nxt; + u_int8_t ip6e_len; +} __attribute__((__packed__)); + +/* Hop-by-Hop options header */ +/* XXX should we pad it to force alignment on an 8-byte boundary? */ +struct ip6_hbh { + u_int8_t ip6h_nxt; /* next header */ + u_int8_t ip6h_len; /* length in units of 8 octets */ + /* followed by options */ +} __attribute__((__packed__)); + +/* Destination options header */ +/* XXX should we pad it to force alignment on an 8-byte boundary? */ +struct ip6_dest { + u_int8_t ip6d_nxt; /* next header */ + u_int8_t ip6d_len; /* length in units of 8 octets */ + /* followed by options */ +} __attribute__((__packed__)); + +/* Option types and related macros */ +#define IP6OPT_PAD1 0x00 /* 00 0 00000 */ +#define IP6OPT_PADN 0x01 /* 00 0 00001 */ +#define IP6OPT_JUMBO 0xC2 /* 11 0 00010 = 194 */ +#define IP6OPT_NSAP_ADDR 0xC3 /* 11 0 00011 */ +#define IP6OPT_TUNNEL_LIMIT 0x04 /* 00 0 00100 */ +#define IP6OPT_RTALERT 0x05 /* 00 0 00101 (KAME definition) */ + +#define IP6OPT_RTALERT_LEN 4 +#define IP6OPT_RTALERT_MLD 0 /* Datagram contains an MLD message */ +#define IP6OPT_RTALERT_RSVP 1 /* Datagram contains an RSVP message */ +#define IP6OPT_RTALERT_ACTNET 2 /* contains an Active Networks msg */ +#define IP6OPT_MINLEN 2 + +#define IP6OPT_BINDING_UPDATE 0xc6 /* 11 0 00110 */ +#define IP6OPT_BINDING_ACK 0x07 /* 00 0 00111 */ +#define IP6OPT_BINDING_REQ 0x08 /* 00 0 01000 */ +#define IP6OPT_HOME_ADDRESS 0xc9 /* 11 0 01001 */ +#define IP6OPT_EID 0x8a /* 10 0 01010 */ + +#define IP6OPT_TYPE(o) ((o) & 0xC0) +#define IP6OPT_TYPE_SKIP 0x00 +#define IP6OPT_TYPE_DISCARD 0x40 +#define IP6OPT_TYPE_FORCEICMP 0x80 +#define IP6OPT_TYPE_ICMP 0xC0 + +#define IP6OPT_MUTABLE 0x20 + +#define IP6OPT_JUMBO_LEN 6 + +/* Routing header */ +struct ip6_rthdr { + u_int8_t ip6r_nxt; /* next header */ + u_int8_t ip6r_len; /* length in units of 8 octets */ + u_int8_t ip6r_type; /* routing type */ + u_int8_t ip6r_segleft; /* segments left */ + /* followed by routing type specific data */ +} __attribute__((__packed__)); + +/* Type 0 Routing header */ +struct ip6_rthdr0 { + u_int8_t ip6r0_nxt; /* next header */ + u_int8_t ip6r0_len; /* length in units of 8 octets */ + u_int8_t ip6r0_type; /* always zero */ + u_int8_t ip6r0_segleft; /* segments left */ + u_int8_t ip6r0_reserved; /* reserved field */ + u_int8_t ip6r0_slmap[3]; /* strict/loose bit map */ + struct in6_addr ip6r0_addr[1]; /* up to 23 addresses */ +} __attribute__((__packed__)); + +/* Fragment header */ +struct ip6_frag { + u_int8_t ip6f_nxt; /* next header */ + u_int8_t ip6f_reserved; /* reserved field */ + u_int16_t ip6f_offlg; /* offset, reserved, and flag */ + u_int32_t ip6f_ident; /* identification */ +} __attribute__((__packed__)); + +#if BYTE_ORDER == BIG_ENDIAN +#define IP6F_OFF_MASK 0xfff8 /* mask out offset from _offlg */ +#define IP6F_RESERVED_MASK 0x0006 /* reserved bits in ip6f_offlg */ +#define IP6F_MORE_FRAG 0x0001 /* more-fragments flag */ +#else /* BYTE_ORDER == LITTLE_ENDIAN */ +#define IP6F_OFF_MASK 0xf8ff /* mask out offset from _offlg */ +#define IP6F_RESERVED_MASK 0x0600 /* reserved bits in ip6f_offlg */ +#define IP6F_MORE_FRAG 0x0100 /* more-fragments flag */ +#endif /* BYTE_ORDER == LITTLE_ENDIAN */ + +/* + * Internet implementation parameters. + */ +#define IPV6_MAXHLIM 255 /* maximun hoplimit */ +#define IPV6_DEFHLIM 64 /* default hlim */ +#define IPV6_FRAGTTL 120 /* ttl for fragment packets, in slowtimo tick */ +#define IPV6_HLIMDEC 1 /* subtracted when forwaeding */ + +#define IPV6_MMTU 1280 /* minimal MTU and reassembly. 1024 + 256 */ +#define IPV6_MAXPACKET 65535 /* ip6 max packet size without Jumbo payload*/ + +#endif /* !_NETINET_IP6_H_ */ Index: branches/azimutz/Cleancut/i386/include/netinet/udp_var.h =================================================================== --- branches/azimutz/Cleancut/i386/include/netinet/udp_var.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/netinet/udp_var.h (revision 885) @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2008 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) 1982, 1986, 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)udp_var.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _NETINET_UDP_VAR_H_ +#define _NETINET_UDP_VAR_H_ +#include <sys/appleapiopts.h> + +#include <sys/sysctl.h> + +/* + * UDP kernel structures and variables. + */ +struct udpiphdr { + struct ipovly ui_i; /* overlaid ip structure */ + struct udphdr ui_u; /* udp header */ +}; +#define ui_x1 ui_i.ih_x1 +#define ui_pr ui_i.ih_pr +#define ui_len ui_i.ih_len +#define ui_src ui_i.ih_src +#define ui_dst ui_i.ih_dst +#define ui_sport ui_u.uh_sport +#define ui_dport ui_u.uh_dport +#define ui_ulen ui_u.uh_ulen +#define ui_sum ui_u.uh_sum +#define ui_next ui_i.ih_next +#define ui_prev ui_i.ih_prev + +struct udpstat { + /* input statistics: */ + u_int32_t udps_ipackets; /* total input packets */ + u_int32_t udps_hdrops; /* packet shorter than header */ + u_int32_t udps_badsum; /* checksum error */ + u_int32_t udps_badlen; /* data length larger than packet */ + u_int32_t udps_noport; /* no socket on port */ + u_int32_t udps_noportbcast; /* of above, arrived as broadcast */ + u_int32_t udps_fullsock; /* not delivered, input socket full */ + u_int32_t udpps_pcbcachemiss; /* input packets missing pcb cache */ + u_int32_t udpps_pcbhashmiss; /* input packets not for hashed pcb */ + /* output statistics: */ + u_int32_t udps_opackets; /* total output packets */ + u_int32_t udps_fastout; /* output packets on fast path */ +#ifndef __APPLE__ + u_int32_t udps_nosum; /* no checksum */ + /* of no socket on port, arrived as multicast */ + u_int32_t udps_noportmcast; +#endif +}; + +/* + * Names for UDP sysctl objects + */ +#define UDPCTL_CHECKSUM 1 /* checksum UDP packets */ +#define UDPCTL_STATS 2 /* statistics (read-only) */ +#define UDPCTL_MAXDGRAM 3 /* max datagram size */ +#define UDPCTL_RECVSPACE 4 /* default receive buffer space */ +#define UDPCTL_PCBLIST 5 /* list of PCBs for UDP sockets */ +#define UDPCTL_MAXID 6 + +#endif /* _NETINET_UDP_VAR_H_ */ Index: branches/azimutz/Cleancut/i386/include/netinet/icmp_var.h =================================================================== --- branches/azimutz/Cleancut/i386/include/netinet/icmp_var.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/netinet/icmp_var.h (revision 885) @@ -0,0 +1,98 @@ +/* + * Copyright (c) 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) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)icmp_var.h 8.1 (Berkeley) 6/10/93 + * $FreeBSD: src/sys/netinet/icmp_var.h,v 1.15.2.1 2001/02/24 21:35:18 bmilekic Exp $ + */ + +#ifndef _NETINET_ICMP_VAR_H_ +#define _NETINET_ICMP_VAR_H_ +#include <sys/appleapiopts.h> + +/* + * Variables related to this implementation + * of the internet control message protocol. + */ +struct icmpstat { +/* statistics related to icmp packets generated */ + u_int32_t icps_error; /* # of calls to icmp_error */ + u_int32_t icps_oldshort; /* no error 'cuz old ip too short */ + u_int32_t icps_oldicmp; /* no error 'cuz old was icmp */ + u_int32_t icps_outhist[ICMP_MAXTYPE + 1]; +/* statistics related to input messages processed */ + u_int32_t icps_badcode; /* icmp_code out of range */ + u_int32_t icps_tooshort; /* packet < ICMP_MINLEN */ + u_int32_t icps_checksum; /* bad checksum */ + u_int32_t icps_badlen; /* calculated bound mismatch */ + u_int32_t icps_reflect; /* number of responses */ + u_int32_t icps_inhist[ICMP_MAXTYPE + 1]; + u_int32_t icps_bmcastecho;/* b/mcast echo requests dropped */ + u_int32_t icps_bmcasttstamp; /* b/mcast tstamp requests dropped */ +}; + +/* + * Names for ICMP sysctl objects + */ +#define ICMPCTL_MASKREPL 1 /* allow replies to netmask requests */ +#define ICMPCTL_STATS 2 /* statistics (read-only) */ +#define ICMPCTL_ICMPLIM 3 +#define ICMPCTL_TIMESTAMP 4 /* allow replies to time stamp requests */ +#define ICMPCTL_MAXID 5 + +#endif /* _NETINET_ICMP_VAR_H_ */ Index: branches/azimutz/Cleancut/i386/include/netinet/ip_mroute.h =================================================================== --- branches/azimutz/Cleancut/i386/include/netinet/ip_mroute.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/netinet/ip_mroute.h (revision 885) @@ -0,0 +1,226 @@ +/* + * Copyright (c) 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) 1989 Stephen Deering. + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Stephen Deering of Stanford University. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)ip_mroute.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _NETINET_IP_MROUTE_H_ +#define _NETINET_IP_MROUTE_H_ +#include <sys/appleapiopts.h> + +/* + * Definitions for IP multicast forwarding. + * + * Written by David Waitzman, BBN Labs, August 1988. + * Modified by Steve Deering, Stanford, February 1989. + * Modified by Ajit Thyagarajan, PARC, August 1993. + * Modified by Ajit Thyagarajan, PARC, August 1994. + * + * MROUTING Revision: 3.3.1.3 + */ + + +/* + * Multicast Routing set/getsockopt commands. + */ +#define MRT_INIT 100 /* initialize forwarder */ +#define MRT_DONE 101 /* shut down forwarder */ +#define MRT_ADD_VIF 102 /* create virtual interface */ +#define MRT_DEL_VIF 103 /* delete virtual interface */ +#define MRT_ADD_MFC 104 /* insert forwarding cache entry */ +#define MRT_DEL_MFC 105 /* delete forwarding cache entry */ +#define MRT_VERSION 106 /* get kernel version number */ +#define MRT_ASSERT 107 /* enable PIM assert processing */ + + + +#ifndef CONFIG_MAXVIFS +#define CONFIG_MAXVIFS 32 /* 4635538 temp workaround */ +#endif + +#ifndef CONFIG_MFCTBLSIZ +#define CONFIG_MFCTBLSIZ 256 /* 4635538 temp workaround */ +#endif + +/* + * Types and macros for handling bitmaps with one bit per virtual interface. + */ +typedef u_int32_t vifbitmap_t; +typedef u_short vifi_t; /* type of a vif index */ +#define ALL_VIFS (vifi_t)-1 + +#define VIFM_SET(n, m) ((m) |= (1 << (n))) +#define VIFM_CLR(n, m) ((m) &= ~(1 << (n))) +#define VIFM_ISSET(n, m) ((m) & (1 << (n))) +#define VIFM_CLRALL(m) ((m) = 0x00000000) +#define VIFM_COPY(mfrom, mto) ((mto) = (mfrom)) +#define VIFM_SAME(m1, m2) ((m1) == (m2)) + + +/* + * Argument structure for MRT_ADD_VIF. + * (MRT_DEL_VIF takes a single vifi_t argument.) + */ +struct vifctl { + vifi_t vifc_vifi; /* the index of the vif to be added */ + u_char vifc_flags; /* VIFF_ flags defined below */ + u_char vifc_threshold; /* min ttl required to forward on vif */ + u_int vifc_rate_limit; /* max rate */ + struct in_addr vifc_lcl_addr; /* local interface address */ + struct in_addr vifc_rmt_addr; /* remote address (tunnels only) */ +}; + +#define VIFF_TUNNEL 0x1 /* vif represents a tunnel end-point */ +#define VIFF_SRCRT 0x2 /* tunnel uses IP source routing */ + +/* + * Argument structure for MRT_ADD_MFC and MRT_DEL_MFC + * (mfcc_tos to be added at a future point) + */ +struct mfcctl { + struct in_addr mfcc_origin; /* ip origin of mcasts */ + struct in_addr mfcc_mcastgrp; /* multicast group associated*/ + vifi_t mfcc_parent; /* incoming vif */ + u_char mfcc_ttls[CONFIG_MAXVIFS]; /* forwarding ttls on vifs */ +}; + +/* + * The kernel's multicast routing statistics. + */ +struct mrtstat { + u_int32_t mrts_mfc_lookups; /* # forw. cache hash table hits */ + u_int32_t mrts_mfc_misses; /* # forw. cache hash table misses */ + u_int32_t mrts_upcalls; /* # calls to mrouted */ + u_int32_t mrts_no_route; /* no route for packet's origin */ + u_int32_t mrts_bad_tunnel; /* malformed tunnel options */ + u_int32_t mrts_cant_tunnel; /* no room for tunnel options */ + u_int32_t mrts_wrong_if; /* arrived on wrong interface */ + u_int32_t mrts_upq_ovflw; /* upcall Q overflow */ + u_int32_t mrts_cache_cleanups; /* # entries with no upcalls */ + u_int32_t mrts_drop_sel; /* pkts dropped selectively */ + u_int32_t mrts_q_overflow; /* pkts dropped - Q overflow */ + u_int32_t mrts_pkt2large; /* pkts dropped - size > BKT SIZE */ + u_int32_t mrts_upq_sockfull; /* upcalls dropped - socket full */ +}; + +/* + * Argument structure used by mrouted to get src-grp pkt counts + */ +struct sioc_sg_req { + struct in_addr src; + struct in_addr grp; + u_int32_t pktcnt; + u_int32_t bytecnt; + u_int32_t wrong_if; +}; + +/* + * Argument structure used by mrouted to get vif pkt counts + */ +struct sioc_vif_req { + vifi_t vifi; /* vif number */ + u_int32_t icount; /* Input packet count on vif */ + u_int32_t ocount; /* Output packet count on vif */ + u_int32_t ibytes; /* Input byte count on vif */ + u_int32_t obytes; /* Output byte count on vif */ +}; + + +/* + * The kernel's multicast forwarding cache entry structure + * (A field for the type of service (mfc_tos) is to be added + * at a future point) + */ +struct mfc { + struct in_addr mfc_origin; /* IP origin of mcasts */ + struct in_addr mfc_mcastgrp; /* multicast group associated*/ + vifi_t mfc_parent; /* incoming vif */ + u_char mfc_ttls[CONFIG_MAXVIFS]; /* forwarding ttls on vifs */ + u_int32_t mfc_pkt_cnt; /* pkt count for src-grp */ + u_int32_t mfc_byte_cnt; /* byte count for src-grp */ + u_int32_t mfc_wrong_if; /* wrong if for src-grp */ + int mfc_expire; /* time to clean entry up */ + struct timeval mfc_last_assert; /* last time I sent an assert*/ + struct rtdetq *mfc_stall; /* q of packets awaiting mfc */ + struct mfc *mfc_next; /* next mfc entry */ +}; + +/* + * Struct used to communicate from kernel to multicast router + * note the convenient similarity to an IP packet + */ +struct igmpmsg { + u_int32_t unused1; + u_int32_t unused2; + u_char im_msgtype; /* what type of message */ +#define IGMPMSG_NOCACHE 1 +#define IGMPMSG_WRONGVIF 2 + u_char im_mbz; /* must be zero */ + u_char im_vif; /* vif rec'd on */ + u_char unused3; + struct in_addr im_src, im_dst; +}; + +#define MFCTBLSIZ CONFIG_MFCTBLSIZ + +#endif /* _NETINET_IP_MROUTE_H_ */ Index: branches/azimutz/Cleancut/i386/include/netinet/igmp_var.h =================================================================== --- branches/azimutz/Cleancut/i386/include/netinet/igmp_var.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/netinet/igmp_var.h (revision 885) @@ -0,0 +1,100 @@ +/* + * Copyright (c) 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) 1988 Stephen Deering. + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Stephen Deering of Stanford University. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * from: @(#)igmp_var.h 8.1 (Berkeley) 7/19/93 + */ + +#ifndef _NETINET_IGMP_VAR_H_ +#define _NETINET_IGMP_VAR_H_ +#include <sys/appleapiopts.h> + + +/* + * Internet Group Management Protocol (IGMP), + * implementation-specific definitions. + * + * Written by Steve Deering, Stanford, May 1988. + * + * MULTICAST Revision: 3.5.1.3 + */ + +struct igmpstat { + u_int igps_rcv_total; /* total IGMP messages received */ + u_int igps_rcv_tooshort; /* received with too few bytes */ + u_int igps_rcv_badsum; /* received with bad checksum */ + u_int igps_rcv_queries; /* received membership queries */ + u_int igps_rcv_badqueries; /* received invalid queries */ + u_int igps_rcv_reports; /* received membership reports */ + u_int igps_rcv_badreports; /* received invalid reports */ + u_int igps_rcv_ourreports; /* received reports for our groups */ + u_int igps_snd_reports; /* sent membership reports */ +}; + + +/* + * Names for IGMP sysctl objects + */ +#define IGMPCTL_STATS 1 /* statistics (read-only) */ +#define IGMPCTL_MAXID 2 + +#endif Index: branches/azimutz/Cleancut/i386/include/netinet/ip_fw.h =================================================================== --- branches/azimutz/Cleancut/i386/include/netinet/ip_fw.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/netinet/ip_fw.h (revision 885) @@ -0,0 +1,303 @@ +/* + * Copyright (c) 2008 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) 1993 Daniel Boulet + * Copyright (c) 1994 Ugen J.S.Antsilevich + * + * Redistribution and use in source forms, with and without modification, + * are permitted provided that this entire comment appears intact. + * + * Redistribution in binary form may occur without any restrictions. + * Obviously, it would be nice if you gave credit where credit is due + * but requiring it would be too onerous. + * + * This software is provided ``AS IS'' without any warranties of any kind. + * + */ + +#ifndef _IP_FW_H +#define _IP_FW_H + +#include <sys/appleapiopts.h> + +#ifdef IPFW2 +#include <netinet/ip_fw2.h> +#else /* !IPFW2, good old ipfw */ + +#include <sys/queue.h> +#include <sys/types.h> /* u_ types */ + +#define IP_FW_CURRENT_API_VERSION 20 /* Version of this API */ + + +/* + * This union structure identifies an interface, either explicitly + * by name or implicitly by IP address. The flags IP_FW_F_IIFNAME + * and IP_FW_F_OIFNAME say how to interpret this structure. An + * interface unit number of -1 matches any unit number, while an + * IP address of 0.0.0.0 indicates matches any interface. + * + * The receive and transmit interfaces are only compared against the + * the packet if the corresponding bit (IP_FW_F_IIFACE or IP_FW_F_OIFACE) + * is set. Note some packets lack a receive or transmit interface + * (in which case the missing "interface" never matches). + */ + +union ip_fw_if { + struct in_addr fu_via_ip; /* Specified by IP address */ + struct { /* Specified by interface name */ +#define FW_IFNLEN 10 /* need room ! was IFNAMSIZ */ + char name[FW_IFNLEN]; + short unit; /* -1 means match any unit */ + } fu_via_if; +}; + +/* + * Format of an IP firewall descriptor + * + * fw_src, fw_dst, fw_smsk, fw_dmsk are always stored in network byte order. + * fw_flg and fw_n*p are stored in host byte order (of course). + * Port numbers are stored in HOST byte order. + */ + +struct ip_fw { + u_int32_t version; /* Version of this structure. Should always be */ + /* set to IP_FW_CURRENT_API_VERSION by clients. */ + void *context; /* Context that is usable by user processes to */ + /* identify this rule. */ + u_int64_t fw_pcnt,fw_bcnt; /* Packet and byte counters */ + struct in_addr fw_src, fw_dst; /* Source and destination IP addr */ + struct in_addr fw_smsk, fw_dmsk; /* Mask for src and dest IP addr */ + u_short fw_number; /* Rule number */ + u_int fw_flg; /* Flags word */ +#define IP_FW_MAX_PORTS 10 /* A reasonable maximum */ + union { + u_short fw_pts[IP_FW_MAX_PORTS]; /* Array of port numbers to match */ +#define IP_FW_ICMPTYPES_MAX 128 +#define IP_FW_ICMPTYPES_DIM (IP_FW_ICMPTYPES_MAX / (sizeof(unsigned) * 8)) + unsigned fw_icmptypes[IP_FW_ICMPTYPES_DIM]; /* ICMP types bitmap */ + } fw_uar; + u_int fw_ipflg; /* IP flags word */ + u_char fw_ipopt,fw_ipnopt; /* IP options set/unset */ + u_char fw_tcpopt,fw_tcpnopt; /* TCP options set/unset */ + u_char fw_tcpf,fw_tcpnf; /* TCP flags set/unset */ + long timestamp; /* timestamp (tv_sec) of last match */ + union ip_fw_if fw_in_if, fw_out_if; /* Incoming and outgoing interfaces */ + union { + u_short fu_divert_port; /* Divert/tee port (options IPDIVERT) */ + u_short fu_pipe_nr; /* queue number (option DUMMYNET) */ + u_short fu_skipto_rule; /* SKIPTO command rule number */ + u_short fu_reject_code; /* REJECT response code */ + struct sockaddr_in fu_fwd_ip; + } fw_un; + u_char fw_prot; /* IP protocol */ + /* + * N'of src ports and # of dst ports in ports array (dst ports + * follow src ports; max of 10 ports in all; count of 0 means + * match all ports) + */ + u_char fw_nports; + void *pipe_ptr; /* flow_set ptr for dummynet pipe */ + void *next_rule_ptr ; /* next rule in case of match */ + uid_t fw_uid; /* uid to match */ + int fw_logamount; /* amount to log */ + u_int64_t fw_loghighest; /* highest number packet to log */ +}; + +/* + * extended ipfw structure... some fields in the original struct + * can be used to pass parameters up/down, namely pointers + * void *pipe_ptr + * void *next_rule_ptr + * some others can be used to pass parameters down, namely counters etc. + * u_int64_t fw_pcnt,fw_bcnt; + * long timestamp; + */ + +struct ip_fw_ext { /* extended structure */ + struct ip_fw rule; /* must be at offset 0 */ + long dont_match_prob; /* 0x7fffffff means 1.0, always fail */ + u_int dyn_type; /* type for dynamic rule */ +}; + +#define IP_FW_GETNSRCP(rule) ((rule)->fw_nports & 0x0f) +#define IP_FW_SETNSRCP(rule, n) do { \ + (rule)->fw_nports &= ~0x0f; \ + (rule)->fw_nports |= (n); \ + } while (0) +#define IP_FW_GETNDSTP(rule) ((rule)->fw_nports >> 4) +#define IP_FW_SETNDSTP(rule, n) do { \ + (rule)->fw_nports &= ~0xf0; \ + (rule)->fw_nports |= (n) << 4;\ + } while (0) + +#define fw_divert_port fw_un.fu_divert_port +#define fw_skipto_rule fw_un.fu_skipto_rule +#define fw_reject_code fw_un.fu_reject_code +#define fw_pipe_nr fw_un.fu_pipe_nr +#define fw_fwd_ip fw_un.fu_fwd_ip + +struct ip_fw_chain { + LIST_ENTRY(ip_fw_chain) next; + struct ip_fw *rule; +}; + +/* + * Flow mask/flow id for each queue. + */ +struct ipfw_flow_id { + u_int32_t dst_ip, src_ip ; + u_int16_t dst_port, src_port ; + u_int8_t proto ; + u_int8_t flags ; /* protocol-specific flags */ +} ; + +/* + * dynamic ipfw rule + */ +struct ipfw_dyn_rule { + struct ipfw_dyn_rule *next ; + + struct ipfw_flow_id id ; + struct ipfw_flow_id mask ; + struct ip_fw_chain *chain ; /* pointer to parent rule */ + u_int32_t type ; /* rule type */ + u_int32_t expire ; /* expire time */ + u_int64_t pcnt, bcnt; /* match counters */ + u_int32_t bucket ; /* which bucket in hash table */ + u_int32_t state ; /* state of this rule (typ. a */ + /* combination of TCP flags) */ +} ; + +/* + * Values for "flags" field . + */ +#define IP_FW_F_COMMAND 0x000000ff /* Mask for type of chain entry: */ +#define IP_FW_F_DENY 0x00000000 /* This is a deny rule */ +#define IP_FW_F_REJECT 0x00000001 /* Deny and send a response packet */ +#define IP_FW_F_ACCEPT 0x00000002 /* This is an accept rule */ +#define IP_FW_F_COUNT 0x00000003 /* This is a count rule */ +#define IP_FW_F_DIVERT 0x00000004 /* This is a divert rule */ +#define IP_FW_F_TEE 0x00000005 /* This is a tee rule */ +#define IP_FW_F_SKIPTO 0x00000006 /* This is a skipto rule */ +#define IP_FW_F_FWD 0x00000007 /* This is a "change forwarding address" rule */ +#define IP_FW_F_PIPE 0x00000008 /* This is a dummynet rule */ +#define IP_FW_F_QUEUE 0x00000009 /* This is a dummynet queue */ + +#define IP_FW_F_IN 0x00000100 /* Check inbound packets */ +#define IP_FW_F_OUT 0x00000200 /* Check outbound packets */ +#define IP_FW_F_IIFACE 0x00000400 /* Apply inbound interface test */ +#define IP_FW_F_OIFACE 0x00000800 /* Apply outbound interface test */ + +#define IP_FW_F_PRN 0x00001000 /* Print if this rule matches */ + +#define IP_FW_F_SRNG 0x00002000 /* The first two src ports are a min * + * and max range (stored in host byte * + * order). */ + +#define IP_FW_F_DRNG 0x00004000 /* The first two dst ports are a min * + * and max range (stored in host byte * + * order). */ + +#define IP_FW_F_FRAG 0x00008000 /* Fragment */ + +#define IP_FW_F_IIFNAME 0x00010000 /* In interface by name/unit (not IP) */ +#define IP_FW_F_OIFNAME 0x00020000 /* Out interface by name/unit (not IP) */ + +#define IP_FW_F_INVSRC 0x00040000 /* Invert sense of src check */ +#define IP_FW_F_INVDST 0x00080000 /* Invert sense of dst check */ + +#define IP_FW_F_ICMPBIT 0x00100000 /* ICMP type bitmap is valid */ + +#define IP_FW_F_UID 0x00200000 /* filter by uid */ + +#define IP_FW_F_RND_MATCH 0x00800000 /* probabilistic rule match */ +#define IP_FW_F_SMSK 0x01000000 /* src-port + mask */ +#define IP_FW_F_DMSK 0x02000000 /* dst-port + mask */ +#define IP_FW_BRIDGED 0x04000000 /* only match bridged packets */ +#define IP_FW_F_KEEP_S 0x08000000 /* keep state */ +#define IP_FW_F_CHECK_S 0x10000000 /* check state */ + +#define IP_FW_F_SME 0x20000000 /* source = me */ +#define IP_FW_F_DME 0x40000000 /* destination = me */ + +#define IP_FW_F_MASK 0x7FFFFFFF /* All possible flag bits mask */ + +/* + * Flags for the 'fw_ipflg' field, for comparing values of ip and its protocols. + */ +#define IP_FW_IF_TCPEST 0x00000020 /* established TCP connection */ +#define IP_FW_IF_TCPMSK 0x00000020 /* mask of all TCP values */ + +/* + * For backwards compatibility with rules specifying "via iface" but + * not restricted to only "in" or "out" packets, we define this combination + * of bits to represent this configuration. + */ + +#define IF_FW_F_VIAHACK (IP_FW_F_IN|IP_FW_F_OUT|IP_FW_F_IIFACE|IP_FW_F_OIFACE) + +/* + * Definitions for REJECT response codes. + * Values less than 256 correspond to ICMP unreachable codes. + */ +#define IP_FW_REJECT_RST 0x0100 /* TCP packets: send RST */ + +/* + * Definitions for IP option names. + */ +#define IP_FW_IPOPT_LSRR 0x01 +#define IP_FW_IPOPT_SSRR 0x02 +#define IP_FW_IPOPT_RR 0x04 +#define IP_FW_IPOPT_TS 0x08 + +/* + * Definitions for TCP option names. + */ +#define IP_FW_TCPOPT_MSS 0x01 +#define IP_FW_TCPOPT_WINDOW 0x02 +#define IP_FW_TCPOPT_SACK 0x04 +#define IP_FW_TCPOPT_TS 0x08 +#define IP_FW_TCPOPT_CC 0x10 + +/* + * Definitions for TCP flags. + */ +#define IP_FW_TCPF_FIN TH_FIN +#define IP_FW_TCPF_SYN TH_SYN +#define IP_FW_TCPF_RST TH_RST +#define IP_FW_TCPF_PSH TH_PUSH +#define IP_FW_TCPF_ACK TH_ACK +#define IP_FW_TCPF_URG TH_URG + +/* + * Main firewall chains definitions and global var's definitions. + */ + +#endif /* !IPFW2 */ +#endif /* _IP_FW_H */ Index: branches/azimutz/Cleancut/i386/include/netinet/in_systm.h =================================================================== --- branches/azimutz/Cleancut/i386/include/netinet/in_systm.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/netinet/in_systm.h (revision 885) @@ -0,0 +1,88 @@ +/* + * Copyright (c) 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) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)in_systm.h 8.1 (Berkeley) 6/10/93 + * $FreeBSD: src/sys/netinet/in_systm.h,v 1.9 1999/12/29 04:41:00 peter Exp $ + */ + +#ifndef _NETINET_IN_SYSTM_H_ +#define _NETINET_IN_SYSTM_H_ +#include <sys/appleapiopts.h> +#include <sys/_types.h> + +/* + * Miscellaneous internetwork + * definitions for kernel. + */ + +/* + * Network types. + * + * Internally the system keeps counters in the headers with the bytes + * swapped so that VAX instructions will work on them. It reverses + * the bytes before transmission at each protocol level. The n_ types + * represent the types with the bytes in ``high-ender'' order. + */ +typedef __uint16_t n_short; /* short as received from the net */ +typedef __uint32_t n_long; /* long as received from the net */ + +typedef __uint32_t n_time; /* ms since 00:00 GMT, byte rev */ + + +#endif Index: branches/azimutz/Cleancut/i386/include/netinet/in.h =================================================================== --- branches/azimutz/Cleancut/i386/include/netinet/in.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/netinet/in.h (revision 885) @@ -0,0 +1,524 @@ +/* + * Copyright (c) 2000-2008 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) 1982, 1986, 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)in.h 8.3 (Berkeley) 1/3/94 + * $FreeBSD: src/sys/netinet/in.h,v 1.48.2.2 2001/04/21 14:53:06 ume Exp $ + */ + +#ifndef _NETINET_IN_H_ +#define _NETINET_IN_H_ +#include <sys/appleapiopts.h> +#include <sys/_types.h> +#include <stdint.h> /* uint(8|16|32)_t */ + +#ifndef _IN_ADDR_T +#define _IN_ADDR_T +typedef __uint32_t in_addr_t; /* base type for internet address */ +#endif + +#ifndef _IN_PORT_T +#define _IN_PORT_T +typedef __uint16_t in_port_t; +#endif + +/* + * POSIX 1003.1-2003 + * "Inclusion of the <netinet/in.h> header may also make visible all + * symbols from <inttypes.h> and <sys/socket.h>". + */ +#include <sys/socket.h> + +/* + * The following two #includes insure htonl and family are defined + */ +#include <machine/endian.h> +#include <sys/_endian.h> + +/* + * Constants and structures defined by the internet system, + * Per RFC 790, September 1981, and numerous additions. + */ + +/* + * Protocols (RFC 1700) + */ +#define IPPROTO_IP 0 /* dummy for IP */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define IPPROTO_HOPOPTS 0 /* IP6 hop-by-hop options */ +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ +#define IPPROTO_ICMP 1 /* control message protocol */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define IPPROTO_IGMP 2 /* group mgmt protocol */ +#define IPPROTO_GGP 3 /* gateway^2 (deprecated) */ +#define IPPROTO_IPV4 4 /* IPv4 encapsulation */ +#define IPPROTO_IPIP IPPROTO_IPV4 /* for compatibility */ +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ +#define IPPROTO_TCP 6 /* tcp */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define IPPROTO_ST 7 /* Stream protocol II */ +#define IPPROTO_EGP 8 /* exterior gateway protocol */ +#define IPPROTO_PIGP 9 /* private interior gateway */ +#define IPPROTO_RCCMON 10 /* BBN RCC Monitoring */ +#define IPPROTO_NVPII 11 /* network voice protocol*/ +#define IPPROTO_PUP 12 /* pup */ +#define IPPROTO_ARGUS 13 /* Argus */ +#define IPPROTO_EMCON 14 /* EMCON */ +#define IPPROTO_XNET 15 /* Cross Net Debugger */ +#define IPPROTO_CHAOS 16 /* Chaos*/ +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ +#define IPPROTO_UDP 17 /* user datagram protocol */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define IPPROTO_MUX 18 /* Multiplexing */ +#define IPPROTO_MEAS 19 /* DCN Measurement Subsystems */ +#define IPPROTO_HMP 20 /* Host Monitoring */ +#define IPPROTO_PRM 21 /* Packet Radio Measurement */ +#define IPPROTO_IDP 22 /* xns idp */ +#define IPPROTO_TRUNK1 23 /* Trunk-1 */ +#define IPPROTO_TRUNK2 24 /* Trunk-2 */ +#define IPPROTO_LEAF1 25 /* Leaf-1 */ +#define IPPROTO_LEAF2 26 /* Leaf-2 */ +#define IPPROTO_RDP 27 /* Reliable Data */ +#define IPPROTO_IRTP 28 /* Reliable Transaction */ +#define IPPROTO_TP 29 /* tp-4 w/ class negotiation */ +#define IPPROTO_BLT 30 /* Bulk Data Transfer */ +#define IPPROTO_NSP 31 /* Network Services */ +#define IPPROTO_INP 32 /* Merit Internodal */ +#define IPPROTO_SEP 33 /* Sequential Exchange */ +#define IPPROTO_3PC 34 /* Third Party Connect */ +#define IPPROTO_IDPR 35 /* InterDomain Policy Routing */ +#define IPPROTO_XTP 36 /* XTP */ +#define IPPROTO_DDP 37 /* Datagram Delivery */ +#define IPPROTO_CMTP 38 /* Control Message Transport */ +#define IPPROTO_TPXX 39 /* TP++ Transport */ +#define IPPROTO_IL 40 /* IL transport protocol */ +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ +#define IPPROTO_IPV6 41 /* IP6 header */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define IPPROTO_SDRP 42 /* Source Demand Routing */ +#define IPPROTO_ROUTING 43 /* IP6 routing header */ +#define IPPROTO_FRAGMENT 44 /* IP6 fragmentation header */ +#define IPPROTO_IDRP 45 /* InterDomain Routing*/ +#define IPPROTO_RSVP 46 /* resource reservation */ +#define IPPROTO_GRE 47 /* General Routing Encap. */ +#define IPPROTO_MHRP 48 /* Mobile Host Routing */ +#define IPPROTO_BHA 49 /* BHA */ +#define IPPROTO_ESP 50 /* IP6 Encap Sec. Payload */ +#define IPPROTO_AH 51 /* IP6 Auth Header */ +#define IPPROTO_INLSP 52 /* Integ. Net Layer Security */ +#define IPPROTO_SWIPE 53 /* IP with encryption */ +#define IPPROTO_NHRP 54 /* Next Hop Resolution */ +/* 55-57: Unassigned */ +#define IPPROTO_ICMPV6 58 /* ICMP6 */ +#define IPPROTO_NONE 59 /* IP6 no next header */ +#define IPPROTO_DSTOPTS 60 /* IP6 destination option */ +#define IPPROTO_AHIP 61 /* any host internal protocol */ +#define IPPROTO_CFTP 62 /* CFTP */ +#define IPPROTO_HELLO 63 /* "hello" routing protocol */ +#define IPPROTO_SATEXPAK 64 /* SATNET/Backroom EXPAK */ +#define IPPROTO_KRYPTOLAN 65 /* Kryptolan */ +#define IPPROTO_RVD 66 /* Remote Virtual Disk */ +#define IPPROTO_IPPC 67 /* Pluribus Packet Core */ +#define IPPROTO_ADFS 68 /* Any distributed FS */ +#define IPPROTO_SATMON 69 /* Satnet Monitoring */ +#define IPPROTO_VISA 70 /* VISA Protocol */ +#define IPPROTO_IPCV 71 /* Packet Core Utility */ +#define IPPROTO_CPNX 72 /* Comp. Prot. Net. Executive */ +#define IPPROTO_CPHB 73 /* Comp. Prot. HeartBeat */ +#define IPPROTO_WSN 74 /* Wang Span Network */ +#define IPPROTO_PVP 75 /* Packet Video Protocol */ +#define IPPROTO_BRSATMON 76 /* BackRoom SATNET Monitoring */ +#define IPPROTO_ND 77 /* Sun net disk proto (temp.) */ +#define IPPROTO_WBMON 78 /* WIDEBAND Monitoring */ +#define IPPROTO_WBEXPAK 79 /* WIDEBAND EXPAK */ +#define IPPROTO_EON 80 /* ISO cnlp */ +#define IPPROTO_VMTP 81 /* VMTP */ +#define IPPROTO_SVMTP 82 /* Secure VMTP */ +#define IPPROTO_VINES 83 /* Banyon VINES */ +#define IPPROTO_TTP 84 /* TTP */ +#define IPPROTO_IGP 85 /* NSFNET-IGP */ +#define IPPROTO_DGP 86 /* dissimilar gateway prot. */ +#define IPPROTO_TCF 87 /* TCF */ +#define IPPROTO_IGRP 88 /* Cisco/GXS IGRP */ +#define IPPROTO_OSPFIGP 89 /* OSPFIGP */ +#define IPPROTO_SRPC 90 /* Strite RPC protocol */ +#define IPPROTO_LARP 91 /* Locus Address Resoloution */ +#define IPPROTO_MTP 92 /* Multicast Transport */ +#define IPPROTO_AX25 93 /* AX.25 Frames */ +#define IPPROTO_IPEIP 94 /* IP encapsulated in IP */ +#define IPPROTO_MICP 95 /* Mobile Int.ing control */ +#define IPPROTO_SCCSP 96 /* Semaphore Comm. security */ +#define IPPROTO_ETHERIP 97 /* Ethernet IP encapsulation */ +#define IPPROTO_ENCAP 98 /* encapsulation header */ +#define IPPROTO_APES 99 /* any private encr. scheme */ +#define IPPROTO_GMTP 100 /* GMTP*/ +#define IPPROTO_IPCOMP 108 /* payload compression (IPComp) */ +/* 101-254: Partly Unassigned */ +#define IPPROTO_PIM 103 /* Protocol Independent Mcast */ +#define IPPROTO_PGM 113 /* PGM */ +/* 255: Reserved */ +/* BSD Private, local use, namespace incursion */ +#define IPPROTO_DIVERT 254 /* divert pseudo-protocol */ +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ +#define IPPROTO_RAW 255 /* raw IP packet */ + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define IPPROTO_MAX 256 + +/* last return value of *_input(), meaning "all job for this pkt is done". */ +#define IPPROTO_DONE 257 +#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ + +/* + * Local port number conventions: + * + * When a user does a bind(2) or connect(2) with a port number of zero, + * a non-conflicting local port address is chosen. + * The default range is IPPORT_RESERVED through + * IPPORT_USERRESERVED, although that is settable by sysctl. + * + * A user may set the IPPROTO_IP option IP_PORTRANGE to change this + * default assignment range. + * + * The value IP_PORTRANGE_DEFAULT causes the default behavior. + * + * The value IP_PORTRANGE_HIGH changes the range of candidate port numbers + * into the "high" range. These are reserved for client outbound connections + * which do not want to be filtered by any firewalls. + * + * The value IP_PORTRANGE_LOW changes the range to the "low" are + * that is (by convention) restricted to privileged processes. This + * convention is based on "vouchsafe" principles only. It is only secure + * if you trust the remote host to restrict these ports. + * + * The default range of ports and the high range can be changed by + * sysctl(3). (net.inet.ip.port{hi,low}{first,last}_auto) + * + * Changing those values has bad security implications if you are + * using a a stateless firewall that is allowing packets outside of that + * range in order to allow transparent outgoing connections. + * + * Such a firewall configuration will generally depend on the use of these + * default values. If you change them, you may find your Security + * Administrator looking for you with a heavy object. + * + * For a slightly more orthodox text view on this: + * + * ftp://ftp.isi.edu/in-notes/iana/assignments/port-numbers + * + * port numbers are divided into three ranges: + * + * 0 - 1023 Well Known Ports + * 1024 - 49151 Registered Ports + * 49152 - 65535 Dynamic and/or Private Ports + * + */ + +#define __DARWIN_IPPORT_RESERVED 1024 + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +/* + * Ports < IPPORT_RESERVED are reserved for + * privileged processes (e.g. root). (IP_PORTRANGE_LOW) + * Ports > IPPORT_USERRESERVED are reserved + * for servers, not necessarily privileged. (IP_PORTRANGE_DEFAULT) + */ +#ifndef IPPORT_RESERVED +#define IPPORT_RESERVED __DARWIN_IPPORT_RESERVED +#endif +#define IPPORT_USERRESERVED 5000 + +/* + * Default local port range to use by setting IP_PORTRANGE_HIGH + */ +#define IPPORT_HIFIRSTAUTO 49152 +#define IPPORT_HILASTAUTO 65535 + +/* + * Scanning for a free reserved port return a value below IPPORT_RESERVED, + * but higher than IPPORT_RESERVEDSTART. Traditionally the start value was + * 512, but that conflicts with some well-known-services that firewalls may + * have a fit if we use. + */ +#define IPPORT_RESERVEDSTART 600 +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + +/* + * Internet address (a structure for historical reasons) + */ +struct in_addr { + in_addr_t s_addr; +}; + +/* + * Definitions of bits in internet address integers. + * On subnets, the decomposition of addresses to host and net parts + * is done according to subnet mask, not the masks here. + */ +#define INADDR_ANY (u_int32_t)0x00000000 +#define INADDR_BROADCAST (u_int32_t)0xffffffff /* must be masked */ + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define IN_CLASSA(i) (((u_int32_t)(i) & 0x80000000) == 0) +#define IN_CLASSA_NET 0xff000000 +#define IN_CLASSA_NSHIFT 24 +#define IN_CLASSA_HOST 0x00ffffff +#define IN_CLASSA_MAX 128 + +#define IN_CLASSB(i) (((u_int32_t)(i) & 0xc0000000) == 0x80000000) +#define IN_CLASSB_NET 0xffff0000 +#define IN_CLASSB_NSHIFT 16 +#define IN_CLASSB_HOST 0x0000ffff +#define IN_CLASSB_MAX 65536 + +#define IN_CLASSC(i) (((u_int32_t)(i) & 0xe0000000) == 0xc0000000) +#define IN_CLASSC_NET 0xffffff00 +#define IN_CLASSC_NSHIFT 8 +#define IN_CLASSC_HOST 0x000000ff + +#define IN_CLASSD(i) (((u_int32_t)(i) & 0xf0000000) == 0xe0000000) +#define IN_CLASSD_NET 0xf0000000 /* These ones aren't really */ +#define IN_CLASSD_NSHIFT 28 /* net and host fields, but */ +#define IN_CLASSD_HOST 0x0fffffff /* routing needn't know. */ +#define IN_MULTICAST(i) IN_CLASSD(i) + +#define IN_EXPERIMENTAL(i) (((u_int32_t)(i) & 0xf0000000) == 0xf0000000) +#define IN_BADCLASS(i) (((u_int32_t)(i) & 0xf0000000) == 0xf0000000) + +#define INADDR_LOOPBACK (u_int32_t)0x7f000001 +#define INADDR_NONE 0xffffffff /* -1 return */ + +#define INADDR_UNSPEC_GROUP (u_int32_t)0xe0000000 /* 224.0.0.0 */ +#define INADDR_ALLHOSTS_GROUP (u_int32_t)0xe0000001 /* 224.0.0.1 */ +#define INADDR_ALLRTRS_GROUP (u_int32_t)0xe0000002 /* 224.0.0.2 */ +#define INADDR_MAX_LOCAL_GROUP (u_int32_t)0xe00000ff /* 224.0.0.255 */ + +#ifdef __APPLE__ +#define IN_LINKLOCALNETNUM (u_int32_t)0xA9FE0000 /* 169.254.0.0 */ +#define IN_LINKLOCAL(i) (((u_int32_t)(i) & IN_CLASSB_NET) == IN_LINKLOCALNETNUM) +#endif + +#define IN_LOOPBACKNET 127 /* official! */ +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + +/* + * Socket address, internet style. + */ +struct sockaddr_in { + __uint8_t sin_len; + sa_family_t sin_family; + in_port_t sin_port; + struct in_addr sin_addr; + char sin_zero[8]; +}; + +#define INET_ADDRSTRLEN 16 + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +/* + * Structure used to describe IP options. + * Used to store options internally, to pass them to a process, + * or to restore options retrieved earlier. + * The ip_dst is used for the first-hop gateway when using a source route + * (this gets put into the header proper). + */ +struct ip_opts { + struct in_addr ip_dst; /* first hop, 0 w/o src rt */ + char ip_opts[40]; /* actually variable in size */ +}; + +/* + * Options for use with [gs]etsockopt at the IP level. + * First word of comment is data type; bool is stored in int. + */ +#define IP_OPTIONS 1 /* buf/ip_opts; set/get IP options */ +#define IP_HDRINCL 2 /* int; header is included with data */ +#define IP_TOS 3 /* int; IP type of service and preced. */ +#define IP_TTL 4 /* int; IP time to live */ +#define IP_RECVOPTS 5 /* bool; receive all IP opts w/dgram */ +#define IP_RECVRETOPTS 6 /* bool; receive IP opts for response */ +#define IP_RECVDSTADDR 7 /* bool; receive IP dst addr w/dgram */ +#define IP_RETOPTS 8 /* ip_opts; set/get IP options */ +#define IP_MULTICAST_IF 9 /* u_char; set/get IP multicast i/f */ +#define IP_MULTICAST_TTL 10 /* u_char; set/get IP multicast ttl */ +#define IP_MULTICAST_LOOP 11 /* u_char; set/get IP multicast loopback */ +#define IP_ADD_MEMBERSHIP 12 /* ip_mreq; add an IP group membership */ +#define IP_DROP_MEMBERSHIP 13 /* ip_mreq; drop an IP group membership */ +#define IP_MULTICAST_VIF 14 /* set/get IP mcast virt. iface */ +#define IP_RSVP_ON 15 /* enable RSVP in kernel */ +#define IP_RSVP_OFF 16 /* disable RSVP in kernel */ +#define IP_RSVP_VIF_ON 17 /* set RSVP per-vif socket */ +#define IP_RSVP_VIF_OFF 18 /* unset RSVP per-vif socket */ +#define IP_PORTRANGE 19 /* int; range to choose for unspec port */ +#define IP_RECVIF 20 /* bool; receive reception if w/dgram */ +/* for IPSEC */ +#define IP_IPSEC_POLICY 21 /* int; set/get security policy */ +#define IP_FAITH 22 /* bool; accept FAITH'ed connections */ +#ifdef __APPLE__ +#define IP_STRIPHDR 23 /* bool: drop receive of raw IP header */ +#endif +#define IP_RECVTTL 24 /* bool; receive reception TTL w/dgram */ +#define IP_BOUND_IF 25 /* set/get bound interface */ + + +#define IP_FW_ADD 40 /* add a firewall rule to chain */ +#define IP_FW_DEL 41 /* delete a firewall rule from chain */ +#define IP_FW_FLUSH 42 /* flush firewall rule chain */ +#define IP_FW_ZERO 43 /* clear single/all firewall counter(s) */ +#define IP_FW_GET 44 /* get entire firewall rule chain */ +#define IP_FW_RESETLOG 45 /* reset logging counters */ + +/* These older firewall socket option codes are maintained for backward compatibility. */ +#define IP_OLD_FW_ADD 50 /* add a firewall rule to chain */ +#define IP_OLD_FW_DEL 51 /* delete a firewall rule from chain */ +#define IP_OLD_FW_FLUSH 52 /* flush firewall rule chain */ +#define IP_OLD_FW_ZERO 53 /* clear single/all firewall counter(s) */ +#define IP_OLD_FW_GET 54 /* get entire firewall rule chain */ +#define IP_NAT__XXX 55 /* set/get NAT opts XXX Deprecated, do not use */ +#define IP_OLD_FW_RESETLOG 56 /* reset logging counters */ + +#define IP_DUMMYNET_CONFIGURE 60 /* add/configure a dummynet pipe */ +#define IP_DUMMYNET_DEL 61 /* delete a dummynet pipe from chain */ +#define IP_DUMMYNET_FLUSH 62 /* flush dummynet */ +#define IP_DUMMYNET_GET 64 /* get entire dummynet pipes */ + +#define IP_TRAFFIC_MGT_BACKGROUND 65 /* int*; get background IO flags; set background IO */ + + +/* Background socket configuration flags */ +#ifdef __APPLE_API_UNSTABLE +#define TRAFFIC_MGT_SO_BACKGROUND 0x0001 /* background socket */ +#define TRAFFIC_MGT_SO_BG_SUPPRESSED 0x0002 /* currently throttled */ +#define TRAFFIC_MGT_SO_BG_REGULATE 0x0004 /* traffic is regulated */ +#endif /* __APPLE_API_UNSTABLE */ + +/* + * Defaults and limits for options + */ +#define IP_DEFAULT_MULTICAST_TTL 1 /* normally limit m'casts to 1 hop */ +#define IP_DEFAULT_MULTICAST_LOOP 1 /* normally hear sends if a member */ +#define IP_MAX_MEMBERSHIPS 20 /* per socket */ + +/* + * Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP. + */ +struct ip_mreq { + struct in_addr imr_multiaddr; /* IP multicast address of group */ + struct in_addr imr_interface; /* local IP address of interface */ +}; + +/* + * Argument for IP_PORTRANGE: + * - which range to search when port is unspecified at bind() or connect() + */ +#define IP_PORTRANGE_DEFAULT 0 /* default range */ +#define IP_PORTRANGE_HIGH 1 /* "high" - request firewall bypass */ +#define IP_PORTRANGE_LOW 2 /* "low" - vouchsafe security */ + + +/* + * Definitions for inet sysctl operations. + * + * Third level is protocol number. + * Fourth level is desired variable within that protocol. + */ +#define IPPROTO_MAXID (IPPROTO_AH + 1) /* don't list to IPPROTO_MAX */ + + +/* + * Names for IP sysctl objects + */ +#define IPCTL_FORWARDING 1 /* act as router */ +#define IPCTL_SENDREDIRECTS 2 /* may send redirects when forwarding */ +#define IPCTL_DEFTTL 3 /* default TTL */ +#ifdef notyet +#define IPCTL_DEFMTU 4 /* default MTU */ +#endif +#define IPCTL_RTEXPIRE 5 /* cloned route expiration time */ +#define IPCTL_RTMINEXPIRE 6 /* min value for expiration time */ +#define IPCTL_RTMAXCACHE 7 /* trigger level for dynamic expire */ +#define IPCTL_SOURCEROUTE 8 /* may perform source routes */ +#define IPCTL_DIRECTEDBROADCAST 9 /* may re-broadcast received packets */ +#define IPCTL_INTRQMAXLEN 10 /* max length of netisr queue */ +#define IPCTL_INTRQDROPS 11 /* number of netisr q drops */ +#define IPCTL_STATS 12 /* ipstat structure */ +#define IPCTL_ACCEPTSOURCEROUTE 13 /* may accept source routed packets */ +#define IPCTL_FASTFORWARDING 14 /* use fast IP forwarding code */ +#define IPCTL_KEEPFAITH 15 /* FAITH IPv4->IPv6 translater ctl */ +#define IPCTL_GIF_TTL 16 /* default TTL for gif encap packet */ +#define IPCTL_MAXID 17 + + +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + + +/* INET6 stuff */ +#define __KAME_NETINET_IN_H_INCLUDED_ +#include <netinet6/in6.h> +#undef __KAME_NETINET_IN_H_INCLUDED_ + + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +__BEGIN_DECLS +int bindresvport(int, struct sockaddr_in *); +struct sockaddr; +int bindresvport_sa(int, struct sockaddr *); +__END_DECLS +#endif + +#endif /* _NETINET_IN_H_ */ Index: branches/azimutz/Cleancut/i386/include/netinet/ip.h =================================================================== --- branches/azimutz/Cleancut/i386/include/netinet/ip.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/netinet/ip.h (revision 885) @@ -0,0 +1,231 @@ +/* + * Copyright (c) 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) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)ip.h 8.2 (Berkeley) 6/1/94 + * $FreeBSD: src/sys/netinet/ip.h,v 1.17 1999/12/22 19:13:20 shin Exp $ + */ + +#ifndef _NETINET_IP_H_ +#define _NETINET_IP_H_ +#include <sys/appleapiopts.h> +#include <sys/types.h> /* XXX temporary hack to get u_ types */ +#include <netinet/in.h> +#include <netinet/in_systm.h> + + +/* + * Definitions for internet protocol version 4. + * Per RFC 791, September 1981. + */ +#define IPVERSION 4 + +/* + * Structure of an internet header, naked of options. + */ +struct ip { +#ifdef _IP_VHL + u_char ip_vhl; /* version << 4 | header length >> 2 */ +#else +#if BYTE_ORDER == LITTLE_ENDIAN + u_int ip_hl:4, /* header length */ + ip_v:4; /* version */ +#endif +#if BYTE_ORDER == BIG_ENDIAN + u_int ip_v:4, /* version */ + ip_hl:4; /* header length */ +#endif +#endif /* not _IP_VHL */ + u_char ip_tos; /* type of service */ + u_short ip_len; /* total length */ + u_short ip_id; /* identification */ + u_short ip_off; /* fragment offset field */ +#define IP_RF 0x8000 /* reserved fragment flag */ +#define IP_DF 0x4000 /* dont fragment flag */ +#define IP_MF 0x2000 /* more fragments flag */ +#define IP_OFFMASK 0x1fff /* mask for fragmenting bits */ + u_char ip_ttl; /* time to live */ + u_char ip_p; /* protocol */ + u_short ip_sum; /* checksum */ + struct in_addr ip_src,ip_dst; /* source and dest address */ +}; + +#ifdef _IP_VHL +#define IP_MAKE_VHL(v, hl) ((v) << 4 | (hl)) +#define IP_VHL_HL(vhl) ((vhl) & 0x0f) +#define IP_VHL_V(vhl) ((vhl) >> 4) +#define IP_VHL_BORING 0x45 +#endif + +#define IP_MAXPACKET 65535 /* maximum packet size */ + +/* + * Definitions for IP type of service (ip_tos) + */ +#define IPTOS_LOWDELAY 0x10 +#define IPTOS_THROUGHPUT 0x08 +#define IPTOS_RELIABILITY 0x04 +#define IPTOS_MINCOST 0x02 +#if 1 +/* ECN RFC3168 obsoletes RFC2481, and these will be deprecated soon. */ +#define IPTOS_CE 0x01 +#define IPTOS_ECT 0x02 +#endif + +/* + * ECN (Explicit Congestion Notification) codepoints in RFC3168 + * mapped to the lower 2 bits of the TOS field. + */ +#define IPTOS_ECN_NOTECT 0x00 /* not-ECT */ +#define IPTOS_ECN_ECT1 0x01 /* ECN-capable transport (1) */ +#define IPTOS_ECN_ECT0 0x02 /* ECN-capable transport (0) */ +#define IPTOS_ECN_CE 0x03 /* congestion experienced */ +#define IPTOS_ECN_MASK 0x03 /* ECN field mask */ + +/* + * Definitions for IP precedence (also in ip_tos) (hopefully unused) + */ +#define IPTOS_PREC_NETCONTROL 0xe0 +#define IPTOS_PREC_INTERNETCONTROL 0xc0 +#define IPTOS_PREC_CRITIC_ECP 0xa0 +#define IPTOS_PREC_FLASHOVERRIDE 0x80 +#define IPTOS_PREC_FLASH 0x60 +#define IPTOS_PREC_IMMEDIATE 0x40 +#define IPTOS_PREC_PRIORITY 0x20 +#define IPTOS_PREC_ROUTINE 0x00 + +/* + * Definitions for options. + */ +#define IPOPT_COPIED(o) ((o)&0x80) +#define IPOPT_CLASS(o) ((o)&0x60) +#define IPOPT_NUMBER(o) ((o)&0x1f) + +#define IPOPT_CONTROL 0x00 +#define IPOPT_RESERVED1 0x20 +#define IPOPT_DEBMEAS 0x40 +#define IPOPT_RESERVED2 0x60 + +#define IPOPT_EOL 0 /* end of option list */ +#define IPOPT_NOP 1 /* no operation */ + +#define IPOPT_RR 7 /* record packet route */ +#define IPOPT_TS 68 /* timestamp */ +#define IPOPT_SECURITY 130 /* provide s,c,h,tcc */ +#define IPOPT_LSRR 131 /* loose source route */ +#define IPOPT_SATID 136 /* satnet id */ +#define IPOPT_SSRR 137 /* strict source route */ +#define IPOPT_RA 148 /* router alert */ + +/* + * Offsets to fields in options other than EOL and NOP. + */ +#define IPOPT_OPTVAL 0 /* option ID */ +#define IPOPT_OLEN 1 /* option length */ +#define IPOPT_OFFSET 2 /* offset within option */ +#define IPOPT_MINOFF 4 /* min value of above */ + +/* + * Time stamp option structure. + */ +struct ip_timestamp { + u_char ipt_code; /* IPOPT_TS */ + u_char ipt_len; /* size of structure (variable) */ + u_char ipt_ptr; /* index of current entry */ +#if BYTE_ORDER == LITTLE_ENDIAN + u_int ipt_flg:4, /* flags, see below */ + ipt_oflw:4; /* overflow counter */ +#endif +#if BYTE_ORDER == BIG_ENDIAN + u_int ipt_oflw:4, /* overflow counter */ + ipt_flg:4; /* flags, see below */ +#endif + union ipt_timestamp { + n_long ipt_time[1]; + struct ipt_ta { + struct in_addr ipt_addr; + n_long ipt_time; + } ipt_ta[1]; + } ipt_timestamp; +}; + +/* flag bits for ipt_flg */ +#define IPOPT_TS_TSONLY 0 /* timestamps only */ +#define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */ +#define IPOPT_TS_PRESPEC 3 /* specified modules only */ + +/* bits for security (not byte swapped) */ +#define IPOPT_SECUR_UNCLASS 0x0000 +#define IPOPT_SECUR_CONFID 0xf135 +#define IPOPT_SECUR_EFTO 0x789a +#define IPOPT_SECUR_MMMM 0xbc4d +#define IPOPT_SECUR_RESTR 0xaf13 +#define IPOPT_SECUR_SECRET 0xd788 +#define IPOPT_SECUR_TOPSECRET 0x6bc5 + +/* + * Internet implementation parameters. + */ +#define MAXTTL 255 /* maximum time to live (seconds) */ +#define IPDEFTTL 64 /* default ttl, from RFC 1340 */ +#define IPFRAGTTL 60 /* time to live for frags, slowhz */ +#define IPTTLDEC 1 /* subtracted when forwarding */ + +#define IP_MSS 576 /* default maximum segment size */ + +#endif Index: branches/azimutz/Cleancut/i386/include/netinet/icmp6.h =================================================================== --- branches/azimutz/Cleancut/i386/include/netinet/icmp6.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/netinet/icmp6.h (revision 885) @@ -0,0 +1,620 @@ +/* + * Copyright (c) 2000,2008 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@ + */ +/* $KAME: icmp6.h,v 1.46 2001/04/27 15:09:48 itojun Exp $ */ + +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * Copyright (c) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)ip_icmp.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _NETINET_ICMP6_H_ +#define _NETINET_ICMP6_H_ +#include <sys/appleapiopts.h> + +#define ICMPV6_PLD_MAXLEN 1232 /* IPV6_MMTU - sizeof(struct ip6_hdr) + - sizeof(struct icmp6_hdr) */ + +struct icmp6_hdr { + u_int8_t icmp6_type; /* type field */ + u_int8_t icmp6_code; /* code field */ + u_int16_t icmp6_cksum; /* checksum field */ + union { + u_int32_t icmp6_un_data32[1]; /* type-specific field */ + u_int16_t icmp6_un_data16[2]; /* type-specific field */ + u_int8_t icmp6_un_data8[4]; /* type-specific field */ + } icmp6_dataun; +}; + +#define icmp6_data32 icmp6_dataun.icmp6_un_data32 +#define icmp6_data16 icmp6_dataun.icmp6_un_data16 +#define icmp6_data8 icmp6_dataun.icmp6_un_data8 +#define icmp6_pptr icmp6_data32[0] /* parameter prob */ +#define icmp6_mtu icmp6_data32[0] /* packet too big */ +#define icmp6_id icmp6_data16[0] /* echo request/reply */ +#define icmp6_seq icmp6_data16[1] /* echo request/reply */ +#define icmp6_maxdelay icmp6_data16[0] /* mcast group membership */ + +#define ICMP6_DST_UNREACH 1 /* dest unreachable, codes: */ +#define ICMP6_PACKET_TOO_BIG 2 /* packet too big */ +#define ICMP6_TIME_EXCEEDED 3 /* time exceeded, code: */ +#define ICMP6_PARAM_PROB 4 /* ip6 header bad */ + +#define ICMP6_ECHO_REQUEST 128 /* echo service */ +#define ICMP6_ECHO_REPLY 129 /* echo reply */ +#define ICMP6_MEMBERSHIP_QUERY 130 /* group membership query */ +#define MLD6_LISTENER_QUERY 130 /* multicast listener query */ +#define ICMP6_MEMBERSHIP_REPORT 131 /* group membership report */ +#define MLD6_LISTENER_REPORT 131 /* multicast listener report */ +#define ICMP6_MEMBERSHIP_REDUCTION 132 /* group membership termination */ +#define MLD6_LISTENER_DONE 132 /* multicast listener done */ + +#define MLD_LISTENER_QUERY MLD6_LISTENER_QUERY +#define MLD_LISTENER_REPORT MLD6_LISTENER_REPORT +#define MLD_LISTENER_DONE MLD6_LISTENER_DONE + +#define ND_ROUTER_SOLICIT 133 /* router solicitation */ +#define ND_ROUTER_ADVERT 134 /* router advertisment */ +#define ND_NEIGHBOR_SOLICIT 135 /* neighbor solicitation */ +#define ND_NEIGHBOR_ADVERT 136 /* neighbor advertisment */ +#define ND_REDIRECT 137 /* redirect */ + +#define ICMP6_ROUTER_RENUMBERING 138 /* router renumbering */ + +#define ICMP6_WRUREQUEST 139 /* who are you request */ +#define ICMP6_WRUREPLY 140 /* who are you reply */ +#define ICMP6_FQDN_QUERY 139 /* FQDN query */ +#define ICMP6_FQDN_REPLY 140 /* FQDN reply */ +#define ICMP6_NI_QUERY 139 /* node information request */ +#define ICMP6_NI_REPLY 140 /* node information reply */ + +/* The definitions below are experimental. TBA */ +#define MLD6_MTRACE_RESP 200 /* mtrace response(to sender) */ +#define MLD6_MTRACE 201 /* mtrace messages */ + +#define MLD_MTRACE_RESP MLD6_MTRACE_RESP +#define MLD_MTRACE MLD6_MTRACE + +#define ICMP6_HADISCOV_REQUEST 202 /* XXX To be defined */ +#define ICMP6_HADISCOV_REPLY 203 /* XXX To be defined */ + +#define ICMP6_MAXTYPE 203 + +#define ICMP6_DST_UNREACH_NOROUTE 0 /* no route to destination */ +#define ICMP6_DST_UNREACH_ADMIN 1 /* administratively prohibited */ +#define ICMP6_DST_UNREACH_NOTNEIGHBOR 2 /* not a neighbor(obsolete) */ +#define ICMP6_DST_UNREACH_BEYONDSCOPE 2 /* beyond scope of source address */ +#define ICMP6_DST_UNREACH_ADDR 3 /* address unreachable */ +#define ICMP6_DST_UNREACH_NOPORT 4 /* port unreachable */ + +#define ICMP6_TIME_EXCEED_TRANSIT 0 /* ttl==0 in transit */ +#define ICMP6_TIME_EXCEED_REASSEMBLY 1 /* ttl==0 in reass */ + +#define ICMP6_PARAMPROB_HEADER 0 /* erroneous header field */ +#define ICMP6_PARAMPROB_NEXTHEADER 1 /* unrecognized next header */ +#define ICMP6_PARAMPROB_OPTION 2 /* unrecognized option */ + +#define ICMP6_INFOMSG_MASK 0x80 /* all informational messages */ + +#define ICMP6_NI_SUBJ_IPV6 0 /* Query Subject is an IPv6 address */ +#define ICMP6_NI_SUBJ_FQDN 1 /* Query Subject is a Domain name */ +#define ICMP6_NI_SUBJ_IPV4 2 /* Query Subject is an IPv4 address */ + +#define ICMP6_NI_SUCCESS 0 /* node information successful reply */ +#define ICMP6_NI_REFUSED 1 /* node information request is refused */ +#define ICMP6_NI_UNKNOWN 2 /* unknown Qtype */ + +#define ICMP6_ROUTER_RENUMBERING_COMMAND 0 /* rr command */ +#define ICMP6_ROUTER_RENUMBERING_RESULT 1 /* rr result */ +#define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET 255 /* rr seq num reset */ + +/* Used in kernel only */ +#define ND_REDIRECT_ONLINK 0 /* redirect to an on-link node */ +#define ND_REDIRECT_ROUTER 1 /* redirect to a better router */ + +/* + * Multicast Listener Discovery + */ +struct mld6_hdr { + struct icmp6_hdr mld6_hdr; + struct in6_addr mld6_addr; /* multicast address */ +}; + +#define mld6_type mld6_hdr.icmp6_type +#define mld6_code mld6_hdr.icmp6_code +#define mld6_cksum mld6_hdr.icmp6_cksum +#define mld6_maxdelay mld6_hdr.icmp6_data16[0] +#define mld6_reserved mld6_hdr.icmp6_data16[1] + +/* + * Neighbor Discovery + */ + +struct nd_router_solicit { /* router solicitation */ + struct icmp6_hdr nd_rs_hdr; + /* could be followed by options */ +}; + +#define nd_rs_type nd_rs_hdr.icmp6_type +#define nd_rs_code nd_rs_hdr.icmp6_code +#define nd_rs_cksum nd_rs_hdr.icmp6_cksum +#define nd_rs_reserved nd_rs_hdr.icmp6_data32[0] + +struct nd_router_advert { /* router advertisement */ + struct icmp6_hdr nd_ra_hdr; + u_int32_t nd_ra_reachable; /* reachable time */ + u_int32_t nd_ra_retransmit; /* retransmit timer */ + /* could be followed by options */ +}; + +#define nd_ra_type nd_ra_hdr.icmp6_type +#define nd_ra_code nd_ra_hdr.icmp6_code +#define nd_ra_cksum nd_ra_hdr.icmp6_cksum +#define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0] +#define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1] +#define ND_RA_FLAG_MANAGED 0x80 +#define ND_RA_FLAG_OTHER 0x40 +#define ND_RA_FLAG_HA 0x20 + +/* + * Router preference values based on draft-draves-ipngwg-router-selection-01. + * These are non-standard definitions. + */ +#define ND_RA_FLAG_RTPREF_MASK 0x18 /* 00011000 */ + +#define ND_RA_FLAG_RTPREF_HIGH 0x08 /* 00001000 */ +#define ND_RA_FLAG_RTPREF_MEDIUM 0x00 /* 00000000 */ +#define ND_RA_FLAG_RTPREF_LOW 0x18 /* 00011000 */ +#define ND_RA_FLAG_RTPREF_RSV 0x10 /* 00010000 */ + +#define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1] + +struct nd_neighbor_solicit { /* neighbor solicitation */ + struct icmp6_hdr nd_ns_hdr; + struct in6_addr nd_ns_target; /*target address */ + /* could be followed by options */ +}; + +#define nd_ns_type nd_ns_hdr.icmp6_type +#define nd_ns_code nd_ns_hdr.icmp6_code +#define nd_ns_cksum nd_ns_hdr.icmp6_cksum +#define nd_ns_reserved nd_ns_hdr.icmp6_data32[0] + +struct nd_neighbor_advert { /* neighbor advertisement */ + struct icmp6_hdr nd_na_hdr; + struct in6_addr nd_na_target; /* target address */ + /* could be followed by options */ +}; + +#define nd_na_type nd_na_hdr.icmp6_type +#define nd_na_code nd_na_hdr.icmp6_code +#define nd_na_cksum nd_na_hdr.icmp6_cksum +#define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0] +#if BYTE_ORDER == BIG_ENDIAN +#define ND_NA_FLAG_ROUTER 0x80000000 +#define ND_NA_FLAG_SOLICITED 0x40000000 +#define ND_NA_FLAG_OVERRIDE 0x20000000 +#else +#if BYTE_ORDER == LITTLE_ENDIAN +#define ND_NA_FLAG_ROUTER 0x80 +#define ND_NA_FLAG_SOLICITED 0x40 +#define ND_NA_FLAG_OVERRIDE 0x20 +#endif +#endif + +struct nd_redirect { /* redirect */ + struct icmp6_hdr nd_rd_hdr; + struct in6_addr nd_rd_target; /* target address */ + struct in6_addr nd_rd_dst; /* destination address */ + /* could be followed by options */ +}; + +#define nd_rd_type nd_rd_hdr.icmp6_type +#define nd_rd_code nd_rd_hdr.icmp6_code +#define nd_rd_cksum nd_rd_hdr.icmp6_cksum +#define nd_rd_reserved nd_rd_hdr.icmp6_data32[0] + +struct nd_opt_hdr { /* Neighbor discovery option header */ + u_int8_t nd_opt_type; + u_int8_t nd_opt_len; + /* followed by option specific data*/ +}; + +#define ND_OPT_SOURCE_LINKADDR 1 +#define ND_OPT_TARGET_LINKADDR 2 +#define ND_OPT_PREFIX_INFORMATION 3 +#define ND_OPT_REDIRECTED_HEADER 4 +#define ND_OPT_MTU 5 + +#define ND_OPT_ROUTE_INFO 200 /* draft-ietf-ipngwg-router-preference, not officially assigned yet */ + +struct nd_opt_prefix_info { /* prefix information */ + u_int8_t nd_opt_pi_type; + u_int8_t nd_opt_pi_len; + u_int8_t nd_opt_pi_prefix_len; + u_int8_t nd_opt_pi_flags_reserved; + u_int32_t nd_opt_pi_valid_time; + u_int32_t nd_opt_pi_preferred_time; + u_int32_t nd_opt_pi_reserved2; + struct in6_addr nd_opt_pi_prefix; +}; + +#define ND_OPT_PI_FLAG_ONLINK 0x80 +#define ND_OPT_PI_FLAG_AUTO 0x40 + +struct nd_opt_rd_hdr { /* redirected header */ + u_int8_t nd_opt_rh_type; + u_int8_t nd_opt_rh_len; + u_int16_t nd_opt_rh_reserved1; + u_int32_t nd_opt_rh_reserved2; + /* followed by IP header and data */ +}; + +struct nd_opt_mtu { /* MTU option */ + u_int8_t nd_opt_mtu_type; + u_int8_t nd_opt_mtu_len; + u_int16_t nd_opt_mtu_reserved; + u_int32_t nd_opt_mtu_mtu; +}; + +struct nd_opt_route_info { /* route info */ + u_int8_t nd_opt_rti_type; + u_int8_t nd_opt_rti_len; + u_int8_t nd_opt_rti_prefixlen; + u_int8_t nd_opt_rti_flags; + u_int32_t nd_opt_rti_lifetime; + /* followed by prefix */ +}; + +/* + * icmp6 namelookup + */ + +struct icmp6_namelookup { + struct icmp6_hdr icmp6_nl_hdr; + u_int8_t icmp6_nl_nonce[8]; + int32_t icmp6_nl_ttl; +#if 0 + u_int8_t icmp6_nl_len; + u_int8_t icmp6_nl_name[3]; +#endif + /* could be followed by options */ +}; + +/* + * icmp6 node information + */ +struct icmp6_nodeinfo { + struct icmp6_hdr icmp6_ni_hdr; + u_int8_t icmp6_ni_nonce[8]; + /* could be followed by reply data */ +}; + +#define ni_type icmp6_ni_hdr.icmp6_type +#define ni_code icmp6_ni_hdr.icmp6_code +#define ni_cksum icmp6_ni_hdr.icmp6_cksum +#define ni_qtype icmp6_ni_hdr.icmp6_data16[0] +#define ni_flags icmp6_ni_hdr.icmp6_data16[1] + +#define NI_QTYPE_NOOP 0 /* NOOP */ +#define NI_QTYPE_SUPTYPES 1 /* Supported Qtypes */ +#define NI_QTYPE_FQDN 2 /* FQDN (draft 04) */ +#define NI_QTYPE_DNSNAME 2 /* DNS Name */ +#define NI_QTYPE_NODEADDR 3 /* Node Addresses */ +#define NI_QTYPE_IPV4ADDR 4 /* IPv4 Addresses */ + +#if BYTE_ORDER == BIG_ENDIAN +#define NI_SUPTYPE_FLAG_COMPRESS 0x1 +#define NI_FQDN_FLAG_VALIDTTL 0x1 +#elif BYTE_ORDER == LITTLE_ENDIAN +#define NI_SUPTYPE_FLAG_COMPRESS 0x0100 +#define NI_FQDN_FLAG_VALIDTTL 0x0100 +#endif + +#ifdef NAME_LOOKUPS_04 +#if BYTE_ORDER == BIG_ENDIAN +#define NI_NODEADDR_FLAG_LINKLOCAL 0x1 +#define NI_NODEADDR_FLAG_SITELOCAL 0x2 +#define NI_NODEADDR_FLAG_GLOBAL 0x4 +#define NI_NODEADDR_FLAG_ALL 0x8 +#define NI_NODEADDR_FLAG_TRUNCATE 0x10 +#define NI_NODEADDR_FLAG_ANYCAST 0x20 /* just experimental. not in spec */ +#elif BYTE_ORDER == LITTLE_ENDIAN +#define NI_NODEADDR_FLAG_LINKLOCAL 0x0100 +#define NI_NODEADDR_FLAG_SITELOCAL 0x0200 +#define NI_NODEADDR_FLAG_GLOBAL 0x0400 +#define NI_NODEADDR_FLAG_ALL 0x0800 +#define NI_NODEADDR_FLAG_TRUNCATE 0x1000 +#define NI_NODEADDR_FLAG_ANYCAST 0x2000 /* just experimental. not in spec */ +#endif +#else /* draft-ietf-ipngwg-icmp-name-lookups-05 (and later?) */ +#if BYTE_ORDER == BIG_ENDIAN +#define NI_NODEADDR_FLAG_TRUNCATE 0x1 +#define NI_NODEADDR_FLAG_ALL 0x2 +#define NI_NODEADDR_FLAG_COMPAT 0x4 +#define NI_NODEADDR_FLAG_LINKLOCAL 0x8 +#define NI_NODEADDR_FLAG_SITELOCAL 0x10 +#define NI_NODEADDR_FLAG_GLOBAL 0x20 +#define NI_NODEADDR_FLAG_ANYCAST 0x40 /* just experimental. not in spec */ +#elif BYTE_ORDER == LITTLE_ENDIAN +#define NI_NODEADDR_FLAG_TRUNCATE 0x0100 +#define NI_NODEADDR_FLAG_ALL 0x0200 +#define NI_NODEADDR_FLAG_COMPAT 0x0400 +#define NI_NODEADDR_FLAG_LINKLOCAL 0x0800 +#define NI_NODEADDR_FLAG_SITELOCAL 0x1000 +#define NI_NODEADDR_FLAG_GLOBAL 0x2000 +#define NI_NODEADDR_FLAG_ANYCAST 0x4000 /* just experimental. not in spec */ +#endif +#endif + +struct ni_reply_fqdn { + u_int32_t ni_fqdn_ttl; /* TTL */ + u_int8_t ni_fqdn_namelen; /* length in octets of the FQDN */ + u_int8_t ni_fqdn_name[3]; /* XXX: alignment */ +}; + +/* + * Router Renumbering. as router-renum-08.txt + */ +struct icmp6_router_renum { /* router renumbering header */ + struct icmp6_hdr rr_hdr; + u_int8_t rr_segnum; + u_int8_t rr_flags; + u_int16_t rr_maxdelay; + u_int32_t rr_reserved; +}; + +#define ICMP6_RR_FLAGS_TEST 0x80 +#define ICMP6_RR_FLAGS_REQRESULT 0x40 +#define ICMP6_RR_FLAGS_FORCEAPPLY 0x20 +#define ICMP6_RR_FLAGS_SPECSITE 0x10 +#define ICMP6_RR_FLAGS_PREVDONE 0x08 + +#define rr_type rr_hdr.icmp6_type +#define rr_code rr_hdr.icmp6_code +#define rr_cksum rr_hdr.icmp6_cksum +#define rr_seqnum rr_hdr.icmp6_data32[0] + +struct rr_pco_match { /* match prefix part */ + u_int8_t rpm_code; + u_int8_t rpm_len; + u_int8_t rpm_ordinal; + u_int8_t rpm_matchlen; + u_int8_t rpm_minlen; + u_int8_t rpm_maxlen; + u_int16_t rpm_reserved; + struct in6_addr rpm_prefix; +}; + +#define RPM_PCO_ADD 1 +#define RPM_PCO_CHANGE 2 +#define RPM_PCO_SETGLOBAL 3 +#define RPM_PCO_MAX 4 + +struct rr_pco_use { /* use prefix part */ + u_int8_t rpu_uselen; + u_int8_t rpu_keeplen; + u_int8_t rpu_ramask; + u_int8_t rpu_raflags; + u_int32_t rpu_vltime; + u_int32_t rpu_pltime; + u_int32_t rpu_flags; + struct in6_addr rpu_prefix; +}; +#define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x80 +#define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x40 + +#if BYTE_ORDER == BIG_ENDIAN +#define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80000000 +#define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40000000 +#elif BYTE_ORDER == LITTLE_ENDIAN +#define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80 +#define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40 +#endif + +struct rr_result { /* router renumbering result message */ + u_int16_t rrr_flags; + u_int8_t rrr_ordinal; + u_int8_t rrr_matchedlen; + u_int32_t rrr_ifid; + struct in6_addr rrr_prefix; +}; +#if BYTE_ORDER == BIG_ENDIAN +#define ICMP6_RR_RESULT_FLAGS_OOB 0x0002 +#define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0001 +#elif BYTE_ORDER == LITTLE_ENDIAN +#define ICMP6_RR_RESULT_FLAGS_OOB 0x0200 +#define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0100 +#endif + +/* + * icmp6 filter structures. + */ + +struct icmp6_filter { + u_int32_t icmp6_filt[8]; +}; + +#define ICMP6_FILTER_SETPASSALL(filterp) \ + memset(filterp, 0xff, sizeof(struct icmp6_filter)) +#define ICMP6_FILTER_SETBLOCKALL(filterp) \ + memset(filterp, 0x00, sizeof(struct icmp6_filter)) + +#define ICMP6_FILTER_SETPASS(type, filterp) \ + (((filterp)->icmp6_filt[(type) >> 5]) |= (1 << ((type) & 31))) +#define ICMP6_FILTER_SETBLOCK(type, filterp) \ + (((filterp)->icmp6_filt[(type) >> 5]) &= ~(1 << ((type) & 31))) +#define ICMP6_FILTER_WILLPASS(type, filterp) \ + ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) != 0) +#define ICMP6_FILTER_WILLBLOCK(type, filterp) \ + ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) == 0) + +/* + * Variables related to this implementation + * of the internet control message protocol version 6. + */ +struct icmp6errstat { + u_quad_t icp6errs_dst_unreach_noroute; + u_quad_t icp6errs_dst_unreach_admin; + u_quad_t icp6errs_dst_unreach_beyondscope; + u_quad_t icp6errs_dst_unreach_addr; + u_quad_t icp6errs_dst_unreach_noport; + u_quad_t icp6errs_packet_too_big; + u_quad_t icp6errs_time_exceed_transit; + u_quad_t icp6errs_time_exceed_reassembly; + u_quad_t icp6errs_paramprob_header; + u_quad_t icp6errs_paramprob_nextheader; + u_quad_t icp6errs_paramprob_option; + u_quad_t icp6errs_redirect; /* we regard redirect as an error here */ + u_quad_t icp6errs_unknown; +}; + +struct icmp6stat { +/* statistics related to icmp6 packets generated */ + u_quad_t icp6s_error; /* # of calls to icmp6_error */ + u_quad_t icp6s_canterror; /* no error 'cuz old was icmp */ + u_quad_t icp6s_toofreq; /* no error 'cuz rate limitation */ + u_quad_t icp6s_outhist[256]; +/* statistics related to input message processed */ + u_quad_t icp6s_badcode; /* icmp6_code out of range */ + u_quad_t icp6s_tooshort; /* packet < sizeof(struct icmp6_hdr) */ + u_quad_t icp6s_checksum; /* bad checksum */ + u_quad_t icp6s_badlen; /* calculated bound mismatch */ + u_quad_t icp6s_reflect; /* number of responses */ + u_quad_t icp6s_inhist[256]; + u_quad_t icp6s_nd_toomanyopt; /* too many ND options */ + struct icmp6errstat icp6s_outerrhist; +#define icp6s_odst_unreach_noroute \ + icp6s_outerrhist.icp6errs_dst_unreach_noroute +#define icp6s_odst_unreach_admin icp6s_outerrhist.icp6errs_dst_unreach_admin +#define icp6s_odst_unreach_beyondscope \ + icp6s_outerrhist.icp6errs_dst_unreach_beyondscope +#define icp6s_odst_unreach_addr icp6s_outerrhist.icp6errs_dst_unreach_addr +#define icp6s_odst_unreach_noport icp6s_outerrhist.icp6errs_dst_unreach_noport +#define icp6s_opacket_too_big icp6s_outerrhist.icp6errs_packet_too_big +#define icp6s_otime_exceed_transit \ + icp6s_outerrhist.icp6errs_time_exceed_transit +#define icp6s_otime_exceed_reassembly \ + icp6s_outerrhist.icp6errs_time_exceed_reassembly +#define icp6s_oparamprob_header icp6s_outerrhist.icp6errs_paramprob_header +#define icp6s_oparamprob_nextheader \ + icp6s_outerrhist.icp6errs_paramprob_nextheader +#define icp6s_oparamprob_option icp6s_outerrhist.icp6errs_paramprob_option +#define icp6s_oredirect icp6s_outerrhist.icp6errs_redirect +#define icp6s_ounknown icp6s_outerrhist.icp6errs_unknown + u_quad_t icp6s_pmtuchg; /* path MTU changes */ + u_quad_t icp6s_nd_badopt; /* bad ND options */ + u_quad_t icp6s_badns; /* bad neighbor solicitation */ + u_quad_t icp6s_badna; /* bad neighbor advertisement */ + u_quad_t icp6s_badrs; /* bad router advertisement */ + u_quad_t icp6s_badra; /* bad router advertisement */ + u_quad_t icp6s_badredirect; /* bad redirect message */ +}; + +/* + * Names for ICMP sysctl objects + */ +#define ICMPV6CTL_STATS 1 +#define ICMPV6CTL_REDIRACCEPT 2 /* accept/process redirects */ +#define ICMPV6CTL_REDIRTIMEOUT 3 /* redirect cache time */ +#define ICMPV6CTL_ND6_PRUNE 6 +#define ICMPV6CTL_ND6_DELAY 8 +#define ICMPV6CTL_ND6_UMAXTRIES 9 +#define ICMPV6CTL_ND6_MMAXTRIES 10 +#define ICMPV6CTL_ND6_USELOOPBACK 11 +/*#define ICMPV6CTL_ND6_PROXYALL 12 obsoleted, do not reuse here */ +#define ICMPV6CTL_NODEINFO 13 +#define ICMPV6CTL_ERRPPSLIMIT 14 /* ICMPv6 error pps limitation */ +#define ICMPV6CTL_ND6_MAXNUDHINT 15 +#define ICMPV6CTL_MTUDISC_HIWAT 16 +#define ICMPV6CTL_MTUDISC_LOWAT 17 +#define ICMPV6CTL_ND6_DEBUG 18 +#define ICMPV6CTL_ND6_DRLIST 19 +#define ICMPV6CTL_ND6_PRLIST 20 +#define ICMPV6CTL_MAXID 21 + + +#endif /* !_NETINET_ICMP6_H_ */ Index: branches/azimutz/Cleancut/i386/include/netinet/in_var.h =================================================================== --- branches/azimutz/Cleancut/i386/include/netinet/in_var.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/netinet/in_var.h (revision 885) @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2000-2008 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) 1985, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)in_var.h 8.2 (Berkeley) 1/9/95 + * $FreeBSD: src/sys/netinet/in_var.h,v 1.33.2.2 2001/07/17 10:50:01 ru Exp $ + */ + +#ifndef _NETINET_IN_VAR_H_ +#define _NETINET_IN_VAR_H_ +#include <sys/appleapiopts.h> + +#include <sys/queue.h> +#ifdef __APPLE__ +#include <sys/kern_event.h> +#endif + + +struct in_aliasreq { + char ifra_name[IFNAMSIZ]; /* if name, e.g. "en0" */ + struct sockaddr_in ifra_addr; + struct sockaddr_in ifra_broadaddr; +#define ifra_dstaddr ifra_broadaddr + struct sockaddr_in ifra_mask; + u_int32_t ifra_unused; /* not used: used to be 'dlt' */ +}; + +/* + * Event data, internet style. + */ +struct kev_in_data { + struct net_event_data link_data; + struct in_addr ia_addr; + u_int32_t ia_net; /* network number of interface */ + u_int32_t ia_netmask; /* mask of net part */ + u_int32_t ia_subnet; /* subnet number, including net */ + u_int32_t ia_subnetmask; /* mask of subnet part */ + struct in_addr ia_netbroadcast;/* to recognize net broadcasts */ + struct in_addr ia_dstaddr; +}; + +struct kev_in_collision { + struct net_event_data link_data; /* link colliding arp was received on */ + struct in_addr ia_ipaddr; /* IP address we and another node are using */ + u_char hw_len; /* length of hardware address */ + u_char hw_addr[0]; /* variable length hardware address */ +}; + +#ifdef __APPLE_API_PRIVATE +struct kev_in_portinuse { + u_int16_t port; /* conflicting port number in host order */ + u_int32_t req_pid; /* PID port requestor */ + u_int32_t reserved[2]; +}; +#endif + + +/* + * Define inet event subclass and specific inet events. + */ + +#define KEV_INET_SUBCLASS 1 + +#define KEV_INET_NEW_ADDR 1 +#define KEV_INET_CHANGED_ADDR 2 +#define KEV_INET_ADDR_DELETED 3 +#define KEV_INET_SIFDSTADDR 4 +#define KEV_INET_SIFBRDADDR 5 +#define KEV_INET_SIFNETMASK 6 +#define KEV_INET_ARPCOLLISION 7 /* use kev_in_collision */ + +#ifdef __APPLE_API_PRIVATE +#define KEV_INET_PORTINUSE 8 /* use ken_in_portinuse */ +#endif + + +/* INET6 stuff */ +#include <netinet6/in6_var.h> + +#endif /* _NETINET_IN_VAR_H_ */ Index: branches/azimutz/Cleancut/i386/include/netinet/tcpip.h =================================================================== --- branches/azimutz/Cleancut/i386/include/netinet/tcpip.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/netinet/tcpip.h (revision 885) @@ -0,0 +1,101 @@ +/* + * Copyright (c) 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) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)tcpip.h 8.1 (Berkeley) 6/10/93 + * $FreeBSD: src/sys/netinet/tcpip.h,v 1.8 1999/08/28 00:49:34 peter Exp $ + */ + +#ifndef _NETINET_TCPIP_H_ +#define _NETINET_TCPIP_H_ +#include <sys/appleapiopts.h> +#include <netinet/ip_var.h> +/* + * Tcp+ip header, after ip options removed. + */ +struct tcpiphdr { + struct ipovly ti_i; /* overlaid ip structure */ + struct tcphdr ti_t; /* tcp header */ +}; +#ifdef notyet +/* + * Tcp+ip header, after ip options removed but including TCP options. + */ +struct full_tcpiphdr { + struct ipovly ti_i; /* overlaid ip structure */ + struct tcphdr ti_t; /* tcp header */ + char ti_o[TCP_MAXOLEN]; /* space for tcp options */ +}; +#endif /* notyet */ +#define ti_x1 ti_i.ih_x1 +#define ti_pr ti_i.ih_pr +#define ti_len ti_i.ih_len +#define ti_src ti_i.ih_src +#define ti_dst ti_i.ih_dst +#define ti_sport ti_t.th_sport +#define ti_dport ti_t.th_dport +#define ti_seq ti_t.th_seq +#define ti_ack ti_t.th_ack +#define ti_x2 ti_t.th_x2 +#define ti_off ti_t.th_off +#define ti_flags ti_t.th_flags +#define ti_win ti_t.th_win +#define ti_sum ti_t.th_sum +#define ti_urp ti_t.th_urp + +#endif Index: branches/azimutz/Cleancut/i386/include/netinet/ip_icmp.h =================================================================== --- branches/azimutz/Cleancut/i386/include/netinet/ip_icmp.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/netinet/ip_icmp.h (revision 885) @@ -0,0 +1,231 @@ +/* + * Copyright (c) 2008 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) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)ip_icmp.h 8.1 (Berkeley) 6/10/93 + * $FreeBSD: src/sys/netinet/ip_icmp.h,v 1.16 1999/12/29 04:41:01 peter Exp $ + */ + +#ifndef _NETINET_IP_ICMP_H_ +#define _NETINET_IP_ICMP_H_ +#include <sys/appleapiopts.h> + +/* + * Interface Control Message Protocol Definitions. + * Per RFC 792, September 1981. + */ + +/* + * Internal of an ICMP Router Advertisement + */ +struct icmp_ra_addr { + u_int32_t ira_addr; + u_int32_t ira_preference; +}; + +/* + * Structure of an icmp header. + */ +struct icmp { + u_char icmp_type; /* type of message, see below */ + u_char icmp_code; /* type sub code */ + u_short icmp_cksum; /* ones complement cksum of struct */ + union { + u_char ih_pptr; /* ICMP_PARAMPROB */ + struct in_addr ih_gwaddr; /* ICMP_REDIRECT */ + struct ih_idseq { + n_short icd_id; + n_short icd_seq; + } ih_idseq; + int ih_void; + + /* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */ + struct ih_pmtu { + n_short ipm_void; + n_short ipm_nextmtu; + } ih_pmtu; + + struct ih_rtradv { + u_char irt_num_addrs; + u_char irt_wpa; + u_int16_t irt_lifetime; + } ih_rtradv; + } icmp_hun; +#define icmp_pptr icmp_hun.ih_pptr +#define icmp_gwaddr icmp_hun.ih_gwaddr +#define icmp_id icmp_hun.ih_idseq.icd_id +#define icmp_seq icmp_hun.ih_idseq.icd_seq +#define icmp_void icmp_hun.ih_void +#define icmp_pmvoid icmp_hun.ih_pmtu.ipm_void +#define icmp_nextmtu icmp_hun.ih_pmtu.ipm_nextmtu +#define icmp_num_addrs icmp_hun.ih_rtradv.irt_num_addrs +#define icmp_wpa icmp_hun.ih_rtradv.irt_wpa +#define icmp_lifetime icmp_hun.ih_rtradv.irt_lifetime + union { + struct id_ts { + n_time its_otime; + n_time its_rtime; + n_time its_ttime; + } id_ts; + struct id_ip { + struct ip idi_ip; + /* options and then 64 bits of data */ + } id_ip; + struct icmp_ra_addr id_radv; + u_int32_t id_mask; + char id_data[1]; + } icmp_dun; +#define icmp_otime icmp_dun.id_ts.its_otime +#define icmp_rtime icmp_dun.id_ts.its_rtime +#define icmp_ttime icmp_dun.id_ts.its_ttime +#define icmp_ip icmp_dun.id_ip.idi_ip +#define icmp_radv icmp_dun.id_radv +#define icmp_mask icmp_dun.id_mask +#define icmp_data icmp_dun.id_data +}; + +/* + * Lower bounds on packet lengths for various types. + * For the error advice packets must first insure that the + * packet is large enough to contain the returned ip header. + * Only then can we do the check to see if 64 bits of packet + * data have been returned, since we need to check the returned + * ip header length. + */ +#define ICMP_MINLEN 8 /* abs minimum */ +#define ICMP_TSLEN (8 + 3 * sizeof (n_time)) /* timestamp */ +#define ICMP_MASKLEN 12 /* address mask */ +#define ICMP_ADVLENMIN (8 + sizeof (struct ip) + 8) /* min */ +#ifndef _IP_VHL +#define ICMP_ADVLEN(p) (8 + ((p)->icmp_ip.ip_hl << 2) + 8) + /* N.B.: must separately check that ip_hl >= 5 */ +#else +#define ICMP_ADVLEN(p) (8 + (IP_VHL_HL((p)->icmp_ip.ip_vhl) << 2) + 8) + /* N.B.: must separately check that header length >= 5 */ +#endif + +/* + * Definition of type and code field values. + */ +#define ICMP_ECHOREPLY 0 /* echo reply */ +#define ICMP_UNREACH 3 /* dest unreachable, codes: */ +#define ICMP_UNREACH_NET 0 /* bad net */ +#define ICMP_UNREACH_HOST 1 /* bad host */ +#define ICMP_UNREACH_PROTOCOL 2 /* bad protocol */ +#define ICMP_UNREACH_PORT 3 /* bad port */ +#define ICMP_UNREACH_NEEDFRAG 4 /* IP_DF caused drop */ +#define ICMP_UNREACH_SRCFAIL 5 /* src route failed */ +#define ICMP_UNREACH_NET_UNKNOWN 6 /* unknown net */ +#define ICMP_UNREACH_HOST_UNKNOWN 7 /* unknown host */ +#define ICMP_UNREACH_ISOLATED 8 /* src host isolated */ +#define ICMP_UNREACH_NET_PROHIB 9 /* prohibited access */ +#define ICMP_UNREACH_HOST_PROHIB 10 /* ditto */ +#define ICMP_UNREACH_TOSNET 11 /* bad tos for net */ +#define ICMP_UNREACH_TOSHOST 12 /* bad tos for host */ +#define ICMP_UNREACH_FILTER_PROHIB 13 /* admin prohib */ +#define ICMP_UNREACH_HOST_PRECEDENCE 14 /* host prec vio. */ +#define ICMP_UNREACH_PRECEDENCE_CUTOFF 15 /* prec cutoff */ +#define ICMP_SOURCEQUENCH 4 /* packet lost, slow down */ +#define ICMP_REDIRECT 5 /* shorter route, codes: */ +#define ICMP_REDIRECT_NET 0 /* for network */ +#define ICMP_REDIRECT_HOST 1 /* for host */ +#define ICMP_REDIRECT_TOSNET 2 /* for tos and net */ +#define ICMP_REDIRECT_TOSHOST 3 /* for tos and host */ +#define ICMP_ALTHOSTADDR 6 /* alternate host address */ +#define ICMP_ECHO 8 /* echo service */ +#define ICMP_ROUTERADVERT 9 /* router advertisement */ +#define ICMP_ROUTERADVERT_NORMAL 0 /* normal advertisement */ +#define ICMP_ROUTERADVERT_NOROUTE_COMMON 16 /* selective routing */ +#define ICMP_ROUTERSOLICIT 10 /* router solicitation */ +#define ICMP_TIMXCEED 11 /* time exceeded, code: */ +#define ICMP_TIMXCEED_INTRANS 0 /* ttl==0 in transit */ +#define ICMP_TIMXCEED_REASS 1 /* ttl==0 in reass */ +#define ICMP_PARAMPROB 12 /* ip header bad */ +#define ICMP_PARAMPROB_ERRATPTR 0 /* error at param ptr */ +#define ICMP_PARAMPROB_OPTABSENT 1 /* req. opt. absent */ +#define ICMP_PARAMPROB_LENGTH 2 /* bad length */ +#define ICMP_TSTAMP 13 /* timestamp request */ +#define ICMP_TSTAMPREPLY 14 /* timestamp reply */ +#define ICMP_IREQ 15 /* information request */ +#define ICMP_IREQREPLY 16 /* information reply */ +#define ICMP_MASKREQ 17 /* address mask request */ +#define ICMP_MASKREPLY 18 /* address mask reply */ +#define ICMP_TRACEROUTE 30 /* traceroute */ +#define ICMP_DATACONVERR 31 /* data conversion error */ +#define ICMP_MOBILE_REDIRECT 32 /* mobile host redirect */ +#define ICMP_IPV6_WHEREAREYOU 33 /* IPv6 where-are-you */ +#define ICMP_IPV6_IAMHERE 34 /* IPv6 i-am-here */ +#define ICMP_MOBILE_REGREQUEST 35 /* mobile registration req */ +#define ICMP_MOBILE_REGREPLY 36 /* mobile registration reply */ +#define ICMP_SKIP 39 /* SKIP */ +#define ICMP_PHOTURIS 40 /* Photuris */ +#define ICMP_PHOTURIS_UNKNOWN_INDEX 1 /* unknown sec index */ +#define ICMP_PHOTURIS_AUTH_FAILED 2 /* auth failed */ +#define ICMP_PHOTURIS_DECRYPT_FAILED 3 /* decrypt failed */ + +#define ICMP_MAXTYPE 40 + +#define ICMP_INFOTYPE(type) \ + ((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \ + (type) == ICMP_ROUTERADVERT || (type) == ICMP_ROUTERSOLICIT || \ + (type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \ + (type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \ + (type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY) + + +#endif Index: branches/azimutz/Cleancut/i386/include/netinet/ip_var.h =================================================================== --- branches/azimutz/Cleancut/i386/include/netinet/ip_var.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/netinet/ip_var.h (revision 885) @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2000-2008 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) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)ip_var.h 8.2 (Berkeley) 1/9/95 + */ +/* + * NOTICE: This file was modified by SPARTA, Inc. in 2007 to introduce + * support for mandatory and extensible security protections. This notice + * is included in support of clause 2.2 (b) of the Apple Public License, + * Version 2.0. + */ + +#ifndef _NETINET_IP_VAR_H_ +#define _NETINET_IP_VAR_H_ +#include <sys/appleapiopts.h> + +/* + * Overlay for ip header used by other protocols (tcp, udp). + */ +struct ipovly { + u_char ih_x1[9]; /* (unused) */ + u_char ih_pr; /* protocol */ + u_short ih_len; /* protocol length */ + struct in_addr ih_src; /* source internet address */ + struct in_addr ih_dst; /* destination internet address */ +}; + +#define MAX_IPOPTLEN 40 + +struct ipstat { + u_int32_t ips_total; /* total packets received */ + u_int32_t ips_badsum; /* checksum bad */ + u_int32_t ips_tooshort; /* packet too short */ + u_int32_t ips_toosmall; /* not enough data */ + u_int32_t ips_badhlen; /* ip header length < data size */ + u_int32_t ips_badlen; /* ip length < ip header length */ + u_int32_t ips_fragments; /* fragments received */ + u_int32_t ips_fragdropped; /* frags dropped (dups, out of space) */ + u_int32_t ips_fragtimeout; /* fragments timed out */ + u_int32_t ips_forward; /* packets forwarded */ + u_int32_t ips_fastforward; /* packets fast forwarded */ + u_int32_t ips_cantforward; /* packets rcvd for unreachable dest */ + u_int32_t ips_redirectsent; /* packets forwarded on same net */ + u_int32_t ips_noproto; /* unknown or unsupported protocol */ + u_int32_t ips_delivered; /* datagrams delivered to upper level*/ + u_int32_t ips_localout; /* total ip packets generated here */ + u_int32_t ips_odropped; /* lost packets due to nobufs, etc. */ + u_int32_t ips_reassembled; /* total packets reassembled ok */ + u_int32_t ips_fragmented; /* datagrams successfully fragmented */ + u_int32_t ips_ofragments; /* output fragments created */ + u_int32_t ips_cantfrag; /* don't fragment flag was set, etc. */ + u_int32_t ips_badoptions; /* error in option processing */ + u_int32_t ips_noroute; /* packets discarded due to no route */ + u_int32_t ips_badvers; /* ip version != 4 */ + u_int32_t ips_rawout; /* total raw ip packets generated */ + u_int32_t ips_toolong; /* ip length > max ip packet size */ + u_int32_t ips_notmember; /* multicasts for unregistered grps */ + u_int32_t ips_nogif; /* no match gif found */ + u_int32_t ips_badaddr; /* invalid address on header */ +}; + +struct ip_linklocal_stat { + u_int32_t iplls_in_total; + u_int32_t iplls_in_badttl; + u_int32_t iplls_out_total; + u_int32_t iplls_out_badttl; +}; + +#endif /* !_NETINET_IP_VAR_H_ */ Index: branches/azimutz/Cleancut/i386/include/netinet/bootp.h =================================================================== --- branches/azimutz/Cleancut/i386/include/netinet/bootp.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/netinet/bootp.h (revision 885) @@ -0,0 +1,135 @@ +/* + * Copyright (c) 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@ + */ +/* + * Bootstrap Protocol (BOOTP). RFC 951. + */ +/* + * HISTORY + * + * 14 May 1992 ? at NeXT + * Added correct padding to struct nextvend. This is + * needed for the i386 due to alignment differences wrt + * the m68k. Also adjusted the size of the array fields + * because the NeXT vendor area was overflowing the bootp + * packet. + */ + +#include <netinet/udp.h> + +#define iaddr_t struct in_addr + +struct bootp { + u_char bp_op; /* packet opcode type */ +#define BOOTREQUEST 1 +#define BOOTREPLY 2 + u_char bp_htype; /* hardware addr type */ + u_char bp_hlen; /* hardware addr length */ + u_char bp_hops; /* gateway hops */ + u_int32_t bp_xid; /* transaction ID */ + u_short bp_secs; /* seconds since boot began */ + u_short bp_unused; + iaddr_t bp_ciaddr; /* client IP address */ + iaddr_t bp_yiaddr; /* 'your' IP address */ + iaddr_t bp_siaddr; /* server IP address */ + iaddr_t bp_giaddr; /* gateway IP address */ + u_char bp_chaddr[16]; /* client hardware address */ + u_char bp_sname[64]; /* server host name */ + u_char bp_file[128]; /* boot file name */ + u_char bp_vend[64]; /* vendor-specific area */ +}; + +/* + * UDP port numbers, server and client. + */ +#define IPPORT_BOOTPS 67 +#define IPPORT_BOOTPC 68 + +/* + * "vendor" data permitted for Stanford boot clients. + */ +struct vend { + u_char v_magic[4]; /* magic number */ + u_int32_t v_flags; /* flags/opcodes, etc. */ + u_char v_unused[56]; /* currently unused */ +}; +#define VM_STANFORD "STAN" /* v_magic for Stanford */ + +/* v_flags values */ +#define VF_PCBOOT 1 /* an IBMPC or Mac wants environment info */ +#define VF_HELP 2 /* help me, I'm not registered */ + +#define NVMAXTEXT 55 /* don't change this, it just fits RFC951 */ +struct nextvend { + u_char nv_magic[4]; /* Magic number for vendor specificity */ + u_char nv_version; /* NeXT protocol version */ + /* + * Round the beginning + * of the union to a 16 + * bit boundary due to + * struct/union alignment + * on the m68k. + */ + unsigned short :0; + union { + u_char NV0[58]; + struct { + u_char NV1_opcode; /* opcode - Version 1 */ + u_char NV1_xid; /* transcation id */ + u_char NV1_text[NVMAXTEXT]; /* text */ + u_char NV1_null; /* null terminator */ + } NV1; + } nv_U; +}; +#define nv_unused nv_U.NV0 +#define nv_opcode nv_U.NV1.NV1_opcode +#define nv_xid nv_U.NV1.NV1_xid +#define nv_text nv_U.NV1.NV1_text +#define nv_null nv_U.NV1.NV1_null + +/* Magic number */ +#define VM_NEXT "NeXT" /* v_magic for NeXT, Inc. */ + +/* Opcodes */ +#define BPOP_OK 0 +#define BPOP_QUERY 1 +#define BPOP_QUERY_NE 2 +#define BPOP_ERROR 3 + +struct bootp_packet { + struct ip bp_ip; + struct udphdr bp_udp; + struct bootp bp_bootp; +}; + +#define BOOTP_PKTSIZE (sizeof (struct bootp_packet)) + +/* backoffs must be masks */ +#define BOOTP_MIN_BACKOFF 0x7ff /* 2.048 sec */ +#define BOOTP_MAX_BACKOFF 0xffff /* 65.535 sec */ +#define BOOTP_RETRY 6 /* # retries */ + Index: branches/azimutz/Cleancut/i386/include/netinet/if_ether.h =================================================================== --- branches/azimutz/Cleancut/i386/include/netinet/if_ether.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/netinet/if_ether.h (revision 885) @@ -0,0 +1,144 @@ +/* + * Copyright (c) 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) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)if_ether.h 8.3 (Berkeley) 5/2/95 + * $FreeBSD: src/sys/netinet/if_ether.h,v 1.24 1999/12/29 04:40:58 peter Exp $ + */ + +#ifndef _NETINET_IF_ETHER_H_ +#define _NETINET_IF_ETHER_H_ +#include <sys/appleapiopts.h> + +#include <net/ethernet.h> + +#include <netinet/in.h> +#include <net/if_arp.h> +#define ea_byte ether_addr_octet + +/* + * Macro to map an IP multicast address to an Ethernet multicast address. + * The high-order 25 bits of the Ethernet address are statically assigned, + * and the low-order 23 bits are taken from the low end of the IP address. + */ +#define ETHER_MAP_IP_MULTICAST(ipaddr, enaddr) \ + /* struct in_addr *ipaddr; */ \ + /* u_char enaddr[ETHER_ADDR_LEN]; */ \ +{ \ + (enaddr)[0] = 0x01; \ + (enaddr)[1] = 0x00; \ + (enaddr)[2] = 0x5e; \ + (enaddr)[3] = ((const u_char *)ipaddr)[1] & 0x7f; \ + (enaddr)[4] = ((const u_char *)ipaddr)[2]; \ + (enaddr)[5] = ((const u_char *)ipaddr)[3]; \ +} +/* + * Macro to map an IP6 multicast address to an Ethernet multicast address. + * The high-order 16 bits of the Ethernet address are statically assigned, + * and the low-order 32 bits are taken from the low end of the IP6 address. + */ +#define ETHER_MAP_IPV6_MULTICAST(ip6addr, enaddr) \ +/* struct in6_addr *ip6addr; */ \ +/* u_char enaddr[ETHER_ADDR_LEN]; */ \ +{ \ + (enaddr)[0] = 0x33; \ + (enaddr)[1] = 0x33; \ + (enaddr)[2] = ((const u_char *)ip6addr)[12]; \ + (enaddr)[3] = ((const u_char *)ip6addr)[13]; \ + (enaddr)[4] = ((const u_char *)ip6addr)[14]; \ + (enaddr)[5] = ((const u_char *)ip6addr)[15]; \ +} + +/* + * Ethernet Address Resolution Protocol. + * + * See RFC 826 for protocol description. Structure below is adapted + * to resolving internet addresses. Field names used correspond to + * RFC 826. + */ +struct ether_arp { + struct arphdr ea_hdr; /* fixed-size header */ + u_char arp_sha[ETHER_ADDR_LEN]; /* sender hardware address */ + u_char arp_spa[4]; /* sender protocol address */ + u_char arp_tha[ETHER_ADDR_LEN]; /* target hardware address */ + u_char arp_tpa[4]; /* target protocol address */ +}; +#define arp_hrd ea_hdr.ar_hrd +#define arp_pro ea_hdr.ar_pro +#define arp_hln ea_hdr.ar_hln +#define arp_pln ea_hdr.ar_pln +#define arp_op ea_hdr.ar_op + +struct sockaddr_inarp { + u_char sin_len; + u_char sin_family; + u_short sin_port; + struct in_addr sin_addr; + struct in_addr sin_srcaddr; + u_short sin_tos; + u_short sin_other; +#define SIN_PROXY 1 +}; +/* + * IP and ethernet specific routing flags + */ +#define RTF_USETRAILERS RTF_PROTO1 /* use trailers */ +#define RTF_ANNOUNCE RTF_PROTO2 /* announce new arp entry */ + + +#endif /* _NETINET_IF_ETHER_H_ */ Index: branches/azimutz/Cleancut/i386/include/netinet/ip_fw2.h =================================================================== --- branches/azimutz/Cleancut/i386/include/netinet/ip_fw2.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/netinet/ip_fw2.h (revision 885) @@ -0,0 +1,462 @@ +/* + * Copyright (c) 2008 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) 2002 Luigi Rizzo, Universita` di Pisa + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: src/sys/netinet/ip_fw2.h,v 1.1.2.4 2003/07/17 06:03:39 luigi Exp $ + */ + +#ifndef _IPFW2_H +#define _IPFW2_H + +/* + * Define IP Firewall event subclass, and associated events. + */ + +/*! + @defined KEV_IPFW_SUBCLASS + @discussion The kernel event subclass for IP Firewall. +*/ +#define KEV_IPFW_SUBCLASS 1 + +/*! + @defined KEV_IPFW_ADD + @discussion The event code indicating a rule has been added. +*/ +#define KEV_IPFW_ADD 1 + +/*! + @defined KEV_IPFW_DEL + @discussion The event code indicating a rule has been removed. +*/ +#define KEV_IPFW_DEL 2 + +/*! + @defined KEV_IPFW_FLUSH + @discussion The event code indicating the rule set has been flushed. +*/ +#define KEV_IPFW_FLUSH 3 + +/*! + @defined KEV_IPFW_ENABLE + @discussion The event code indicating the enable flag has been changed +*/ +#define KEV_IPFW_ENABLE 4 + + + +/* + * The kernel representation of ipfw rules is made of a list of + * 'instructions' (for all practical purposes equivalent to BPF + * instructions), which specify which fields of the packet + * (or its metadata) should be analysed. + * + * Each instruction is stored in a structure which begins with + * "ipfw_insn", and can contain extra fields depending on the + * instruction type (listed below). + * Note that the code is written so that individual instructions + * have a size which is a multiple of 32 bits. This means that, if + * such structures contain pointers or other 64-bit entities, + * (there is just one instance now) they may end up unaligned on + * 64-bit architectures, so the must be handled with care. + * + * "enum ipfw_opcodes" are the opcodes supported. We can have up + * to 256 different opcodes. + */ + +enum ipfw_opcodes { /* arguments (4 byte each) */ + O_NOP, + + O_IP_SRC, /* u32 = IP */ + O_IP_SRC_MASK, /* ip = IP/mask */ + O_IP_SRC_ME, /* none */ + O_IP_SRC_SET, /* u32=base, arg1=len, bitmap */ + + O_IP_DST, /* u32 = IP */ + O_IP_DST_MASK, /* ip = IP/mask */ + O_IP_DST_ME, /* none */ + O_IP_DST_SET, /* u32=base, arg1=len, bitmap */ + + O_IP_SRCPORT, /* (n)port list:mask 4 byte ea */ + O_IP_DSTPORT, /* (n)port list:mask 4 byte ea */ + O_PROTO, /* arg1=protocol */ + + O_MACADDR2, /* 2 mac addr:mask */ + O_MAC_TYPE, /* same as srcport */ + + O_LAYER2, /* none */ + O_IN, /* none */ + O_FRAG, /* none */ + + O_RECV, /* none */ + O_XMIT, /* none */ + O_VIA, /* none */ + + O_IPOPT, /* arg1 = 2*u8 bitmap */ + O_IPLEN, /* arg1 = len */ + O_IPID, /* arg1 = id */ + + O_IPTOS, /* arg1 = id */ + O_IPPRECEDENCE, /* arg1 = precedence << 5 */ + O_IPTTL, /* arg1 = TTL */ + + O_IPVER, /* arg1 = version */ + O_UID, /* u32 = id */ + O_GID, /* u32 = id */ + O_ESTAB, /* none (tcp established) */ + O_TCPFLAGS, /* arg1 = 2*u8 bitmap */ + O_TCPWIN, /* arg1 = desired win */ + O_TCPSEQ, /* u32 = desired seq. */ + O_TCPACK, /* u32 = desired seq. */ + O_ICMPTYPE, /* u32 = icmp bitmap */ + O_TCPOPTS, /* arg1 = 2*u8 bitmap */ + + O_VERREVPATH, /* none */ + + O_PROBE_STATE, /* none */ + O_KEEP_STATE, /* none */ + O_LIMIT, /* ipfw_insn_limit */ + O_LIMIT_PARENT, /* dyn_type, not an opcode. */ + + /* + * These are really 'actions'. + */ + + O_LOG, /* ipfw_insn_log */ + O_PROB, /* u32 = match probability */ + + O_CHECK_STATE, /* none */ + O_ACCEPT, /* none */ + O_DENY, /* none */ + O_REJECT, /* arg1=icmp arg (same as deny) */ + O_COUNT, /* none */ + O_SKIPTO, /* arg1=next rule number */ + O_PIPE, /* arg1=pipe number */ + O_QUEUE, /* arg1=queue number */ + O_DIVERT, /* arg1=port number */ + O_TEE, /* arg1=port number */ + O_FORWARD_IP, /* fwd sockaddr */ + O_FORWARD_MAC, /* fwd mac */ + + /* + * More opcodes. + */ + O_IPSEC, /* has ipsec history */ + + O_LAST_OPCODE /* not an opcode! */ +}; + +/* + * Template for instructions. + * + * ipfw_insn is used for all instructions which require no operands, + * a single 16-bit value (arg1), or a couple of 8-bit values. + * + * For other instructions which require different/larger arguments + * we have derived structures, ipfw_insn_*. + * + * The size of the instruction (in 32-bit words) is in the low + * 6 bits of "len". The 2 remaining bits are used to implement + * NOT and OR on individual instructions. Given a type, you can + * compute the length to be put in "len" using F_INSN_SIZE(t) + * + * F_NOT negates the match result of the instruction. + * + * F_OR is used to build or blocks. By default, instructions + * are evaluated as part of a logical AND. An "or" block + * { X or Y or Z } contains F_OR set in all but the last + * instruction of the block. A match will cause the code + * to skip past the last instruction of the block. + * + * NOTA BENE: in a couple of places we assume that + * sizeof(ipfw_insn) == sizeof(u_int32_t) + * this needs to be fixed. + * + */ +typedef struct _ipfw_insn { /* template for instructions */ + enum ipfw_opcodes opcode:8; + u_int8_t len; /* numer of 32-byte words */ +#define F_NOT 0x80 +#define F_OR 0x40 +#define F_LEN_MASK 0x3f +#define F_LEN(cmd) ((cmd)->len & F_LEN_MASK) + + u_int16_t arg1; +} ipfw_insn; + +/* + * The F_INSN_SIZE(type) computes the size, in 4-byte words, of + * a given type. + */ +#define F_INSN_SIZE(t) ((sizeof (t))/sizeof(u_int32_t)) + +/* + * This is used to store an array of 16-bit entries (ports etc.) + */ +typedef struct _ipfw_insn_u16 { + ipfw_insn o; + u_int16_t ports[2]; /* there may be more */ +} ipfw_insn_u16; + +/* + * This is used to store an array of 32-bit entries + * (uid, single IPv4 addresses etc.) + */ +typedef struct _ipfw_insn_u32 { + ipfw_insn o; + u_int32_t d[1]; /* one or more */ +} ipfw_insn_u32; + +/* + * This is used to store IP addr-mask pairs. + */ +typedef struct _ipfw_insn_ip { + ipfw_insn o; + struct in_addr addr; + struct in_addr mask; +} ipfw_insn_ip; + +/* + * This is used to forward to a given address (ip). + */ +typedef struct _ipfw_insn_sa { + ipfw_insn o; + struct sockaddr_in sa; +} ipfw_insn_sa; + +/* + * This is used for MAC addr-mask pairs. + */ +typedef struct _ipfw_insn_mac { + ipfw_insn o; + u_char addr[12]; /* dst[6] + src[6] */ + u_char mask[12]; /* dst[6] + src[6] */ +} ipfw_insn_mac; + +/* + * This is used for interface match rules (recv xx, xmit xx). + */ +typedef struct _ipfw_insn_if { + ipfw_insn o; + union { + struct in_addr ip; + int32_t unit; + } p; + char name[IFNAMSIZ]; +} ipfw_insn_if; + +/* + * This is used for pipe and queue actions, which need to store + * a single pointer (which can have different size on different + * architectures. + * Note that, because of previous instructions, pipe_ptr might + * be unaligned in the overall structure, so it needs to be + * manipulated with care. + */ +typedef struct _ipfw_insn_pipe { + ipfw_insn o; + void *pipe_ptr; /* XXX */ +} ipfw_insn_pipe; + +/* + * This is used for limit rules. + */ +typedef struct _ipfw_insn_limit { + ipfw_insn o; + u_int8_t _pad; + u_int8_t limit_mask; /* combination of DYN_* below */ +#define DYN_SRC_ADDR 0x1 +#define DYN_SRC_PORT 0x2 +#define DYN_DST_ADDR 0x4 +#define DYN_DST_PORT 0x8 + + u_int16_t conn_limit; +} ipfw_insn_limit; + +/* + * This is used for log instructions. + */ +typedef struct _ipfw_insn_log { + ipfw_insn o; + u_int32_t max_log; /* how many do we log -- 0 = all */ + u_int32_t log_left; /* how many left to log */ +} ipfw_insn_log; + +/* Version of this API */ +#define IP_FW_VERSION_NONE 0 +#define IP_FW_VERSION_0 10 /* old ipfw */ +#define IP_FW_VERSION_1 20 /* ipfw in Jaguar/Panther */ +#define IP_FW_VERSION_2 30 /* ipfw2 */ +#define IP_FW_CURRENT_API_VERSION IP_FW_VERSION_2 + +/* + * Here we have the structure representing an ipfw rule. + * + * It starts with a general area (with link fields and counters) + * followed by an array of one or more instructions, which the code + * accesses as an array of 32-bit values. + * + * Given a rule pointer r: + * + * r->cmd is the start of the first instruction. + * ACTION_PTR(r) is the start of the first action (things to do + * once a rule matched). + * + * When assembling instruction, remember the following: + * + * + if a rule has a "keep-state" (or "limit") option, then the + * first instruction (at r->cmd) MUST BE an O_PROBE_STATE + * + if a rule has a "log" option, then the first action + * (at ACTION_PTR(r)) MUST be O_LOG + * + * NOTE: we use a simple linked list of rules because we never need + * to delete a rule without scanning the list. We do not use + * queue(3) macros for portability and readability. + */ + +struct ip_fw { + u_int32_t version; /* Version of this structure. MUST be set */ + /* by clients. Should always be */ + /* set to IP_FW_CURRENT_API_VERSION. */ + void *context; /* Context that is usable by user processes to */ + /* identify this rule. */ + struct ip_fw *next; /* linked list of rules */ + struct ip_fw *next_rule; /* ptr to next [skipto] rule */ + /* 'next_rule' is used to pass up 'set_disable' status */ + + u_int16_t act_ofs; /* offset of action in 32-bit units */ + u_int16_t cmd_len; /* # of 32-bit words in cmd */ + u_int16_t rulenum; /* rule number */ + u_int8_t set; /* rule set (0..31) */ + u_int32_t set_masks[2]; /* masks for manipulating sets atomically */ +#define RESVD_SET 31 /* set for default and persistent rules */ + u_int8_t _pad; /* padding */ + + /* These fields are present in all rules. */ + u_int64_t pcnt; /* Packet counter */ + u_int64_t bcnt; /* Byte counter */ + u_int32_t timestamp; /* tv_sec of last match */ + + u_int32_t reserved_1; /* reserved - set to 0 */ + u_int32_t reserved_2; /* reserved - set to 0 */ + + ipfw_insn cmd[1]; /* storage for commands */ +}; + +#define ACTION_PTR(rule) \ + (ipfw_insn *)( (u_int32_t *)((rule)->cmd) + ((rule)->act_ofs) ) + +#define RULESIZE(rule) (sizeof(struct ip_fw) + \ + ((struct ip_fw *)(rule))->cmd_len * 4 - 4) + +/* + * This structure is used as a flow mask and a flow id for various + * parts of the code. + */ +struct ipfw_flow_id { + u_int32_t dst_ip; + u_int32_t src_ip; + u_int16_t dst_port; + u_int16_t src_port; + u_int8_t proto; + u_int8_t flags; /* protocol-specific flags */ +}; + +/* + * Dynamic ipfw rule. + */ +typedef struct _ipfw_dyn_rule ipfw_dyn_rule; + +struct _ipfw_dyn_rule { + ipfw_dyn_rule *next; /* linked list of rules. */ + struct ip_fw *rule; /* pointer to rule */ + /* 'rule' is used to pass up the rule number (from the parent) */ + + ipfw_dyn_rule *parent; /* pointer to parent rule */ + u_int64_t pcnt; /* packet match counter */ + u_int64_t bcnt; /* byte match counter */ + struct ipfw_flow_id id; /* (masked) flow id */ + u_int32_t expire; /* expire time */ + u_int32_t bucket; /* which bucket in hash table */ + u_int32_t state; /* state of this rule (typically a + * combination of TCP flags) + */ + u_int32_t ack_fwd; /* most recent ACKs in forward */ + u_int32_t ack_rev; /* and reverse directions (used */ + /* to generate keepalives) */ + u_int16_t dyn_type; /* rule type */ + u_int16_t count; /* refcount */ +}; + +/* + * Definitions for IP option names. + */ +#define IP_FW_IPOPT_LSRR 0x01 +#define IP_FW_IPOPT_SSRR 0x02 +#define IP_FW_IPOPT_RR 0x04 +#define IP_FW_IPOPT_TS 0x08 + +/* + * Definitions for TCP option names. + */ +#define IP_FW_TCPOPT_MSS 0x01 +#define IP_FW_TCPOPT_WINDOW 0x02 +#define IP_FW_TCPOPT_SACK 0x04 +#define IP_FW_TCPOPT_TS 0x08 +#define IP_FW_TCPOPT_CC 0x10 + +#define ICMP_REJECT_RST 0x100 /* fake ICMP code (send a TCP RST) */ + +/* + * Main firewall chains definitions and global var's definitions. + */ + + +#endif /* _IPFW2_H */ Index: branches/azimutz/Cleancut/i386/include/netinet/tcp.h =================================================================== --- branches/azimutz/Cleancut/i386/include/netinet/tcp.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/netinet/tcp.h (revision 885) @@ -0,0 +1,207 @@ +/* + * 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@ + */ +/* + * Copyright (c) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)tcp.h 8.1 (Berkeley) 6/10/93 + * $FreeBSD: src/sys/netinet/tcp.h,v 1.13.2.3 2001/03/01 22:08:42 jlemon Exp $ + */ + +#ifndef _NETINET_TCP_H_ +#define _NETINET_TCP_H_ +#include <sys/appleapiopts.h> +#include <sys/_types.h> +#include <machine/endian.h> + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +typedef __uint32_t tcp_seq; +typedef __uint32_t tcp_cc; /* connection count per rfc1644 */ + +#define tcp6_seq tcp_seq /* for KAME src sync over BSD*'s */ +#define tcp6hdr tcphdr /* for KAME src sync over BSD*'s */ + +/* + * TCP header. + * Per RFC 793, September, 1981. + */ +struct tcphdr { + unsigned short th_sport; /* source port */ + unsigned short th_dport; /* destination port */ + tcp_seq th_seq; /* sequence number */ + tcp_seq th_ack; /* acknowledgement number */ +#if __DARWIN_BYTE_ORDER == __DARWIN_LITTLE_ENDIAN + unsigned int th_x2:4, /* (unused) */ + th_off:4; /* data offset */ +#endif +#if __DARWIN_BYTE_ORDER == __DARWIN_BIG_ENDIAN + unsigned int th_off:4, /* data offset */ + th_x2:4; /* (unused) */ +#endif + unsigned char th_flags; +#define TH_FIN 0x01 +#define TH_SYN 0x02 +#define TH_RST 0x04 +#define TH_PUSH 0x08 +#define TH_ACK 0x10 +#define TH_URG 0x20 +#define TH_ECE 0x40 +#define TH_CWR 0x80 +#define TH_FLAGS (TH_FIN|TH_SYN|TH_RST|TH_ACK|TH_URG|TH_ECE|TH_CWR) + + unsigned short th_win; /* window */ + unsigned short th_sum; /* checksum */ + unsigned short th_urp; /* urgent pointer */ +}; + +#define TCPOPT_EOL 0 +#define TCPOPT_NOP 1 +#define TCPOPT_MAXSEG 2 +#define TCPOLEN_MAXSEG 4 +#define TCPOPT_WINDOW 3 +#define TCPOLEN_WINDOW 3 +#define TCPOPT_SACK_PERMITTED 4 /* Experimental */ +#define TCPOLEN_SACK_PERMITTED 2 +#define TCPOPT_SACK 5 /* Experimental */ +#define TCPOLEN_SACK 8 /* len of sack block */ +#define TCPOPT_TIMESTAMP 8 +#define TCPOLEN_TIMESTAMP 10 +#define TCPOLEN_TSTAMP_APPA (TCPOLEN_TIMESTAMP+2) /* appendix A */ +#define TCPOPT_TSTAMP_HDR \ + (TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_TIMESTAMP<<8|TCPOLEN_TIMESTAMP) + +#define MAX_TCPOPTLEN 40 /* Absolute maximum TCP options len */ + +#define TCPOPT_CC 11 /* CC options: RFC-1644 */ +#define TCPOPT_CCNEW 12 +#define TCPOPT_CCECHO 13 +#define TCPOLEN_CC 6 +#define TCPOLEN_CC_APPA (TCPOLEN_CC+2) +#define TCPOPT_CC_HDR(ccopt) \ + (TCPOPT_NOP<<24|TCPOPT_NOP<<16|(ccopt)<<8|TCPOLEN_CC) +#define TCPOPT_SIGNATURE 19 /* Keyed MD5: RFC 2385 */ +#define TCPOLEN_SIGNATURE 18 + +/* Option definitions */ +#define TCPOPT_SACK_PERMIT_HDR \ +(TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_SACK_PERMITTED<<8|TCPOLEN_SACK_PERMITTED) +#define TCPOPT_SACK_HDR (TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_SACK<<8) +/* Miscellaneous constants */ +#define MAX_SACK_BLKS 6 /* Max # SACK blocks stored at sender side */ +#define TCP_MAX_SACK 3 /* MAX # SACKs sent in any segment */ + + +/* + * Default maximum segment size for TCP. + * With an IP MTU of 576, this is 536, + * but 512 is probably more convenient. + * This should be defined as MIN(512, IP_MSS - sizeof (struct tcpiphdr)). + */ +#define TCP_MSS 512 + +/* + * TCP_MINMSS is defined to be 216 which is fine for the smallest + * link MTU (256 bytes, SLIP interface) in the Internet. + * However it is very unlikely to come across such low MTU interfaces + * these days (anno dato 2004). + * Probably it can be set to 512 without ill effects. But we play safe. + * See tcp_subr.c tcp_minmss SYSCTL declaration for more comments. + * Setting this to "0" disables the minmss check. + */ +#define TCP_MINMSS 216 + +/* + * TCP_MINMSSOVERLOAD is defined to be 1000 which should cover any type + * of interactive TCP session. + * See tcp_subr.c tcp_minmssoverload SYSCTL declaration and tcp_input.c + * for more comments. + * Setting this to "0" disables the minmssoverload check. + */ +#define TCP_MINMSSOVERLOAD 1000 + +/* + * Default maximum segment size for TCP6. + * With an IP6 MSS of 1280, this is 1220, + * but 1024 is probably more convenient. (xxx kazu in doubt) + * This should be defined as MIN(1024, IP6_MSS - sizeof (struct tcpip6hdr)) + */ +#define TCP6_MSS 1024 + +#define TCP_MAXWIN 65535 /* largest value for (unscaled) window */ +#define TTCP_CLIENT_SND_WND 4096 /* dflt send window for T/TCP client */ + +#define TCP_MAX_WINSHIFT 14 /* maximum window shift */ + +#define TCP_MAXBURST 4 /* maximum segments in a burst */ + +#define TCP_MAXHLEN (0xf<<2) /* max length of header in bytes */ +#define TCP_MAXOLEN (TCP_MAXHLEN - sizeof(struct tcphdr)) + /* max space left for options */ +#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ + +/* + * User-settable options (used with setsockopt). + */ +#define TCP_NODELAY 0x01 /* don't delay send to coalesce packets */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define TCP_MAXSEG 0x02 /* set maximum segment size */ +#define TCP_NOPUSH 0x04 /* don't push last block of write */ +#define TCP_NOOPT 0x08 /* don't use TCP options */ +#define TCP_KEEPALIVE 0x10 /* idle time used when SO_KEEPALIVE is enabled */ +#define TCP_CONNECTIONTIMEOUT 0x20 /* connection timeout */ +#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ + +#endif Index: branches/azimutz/Cleancut/i386/include/netinet/tcp_timer.h =================================================================== --- branches/azimutz/Cleancut/i386/include/netinet/tcp_timer.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/netinet/tcp_timer.h (revision 885) @@ -0,0 +1,116 @@ +/* + * Copyright (c) 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) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)tcp_timer.h 8.1 (Berkeley) 6/10/93 + * $FreeBSD: src/sys/netinet/tcp_timer.h,v 1.18 1999/12/29 04:41:03 peter Exp $ + */ + +#ifndef _NETINET_TCP_TIMER_H_ +#define _NETINET_TCP_TIMER_H_ +#include <sys/appleapiopts.h> + +/* + * Definitions of the TCP timers. These timers are counted + * down PR_SLOWHZ times a second. + */ +#define TCPT_NTIMERS 4 + +#define TCPT_REXMT 0 /* retransmit */ +#define TCPT_PERSIST 1 /* retransmit persistence */ +#define TCPT_KEEP 2 /* keep alive */ +#define TCPT_2MSL 3 /* 2*msl quiet time timer */ + +/* + * The TCPT_REXMT timer is used to force retransmissions. + * The TCP has the TCPT_REXMT timer set whenever segments + * have been sent for which ACKs are expected but not yet + * received. If an ACK is received which advances tp->snd_una, + * then the retransmit timer is cleared (if there are no more + * outstanding segments) or reset to the base value (if there + * are more ACKs expected). Whenever the retransmit timer goes off, + * we retransmit one unacknowledged segment, and do a backoff + * on the retransmit timer. + * + * The TCPT_PERSIST timer is used to keep window size information + * flowing even if the window goes shut. If all previous transmissions + * have been acknowledged (so that there are no retransmissions in progress), + * and the window is too small to bother sending anything, then we start + * the TCPT_PERSIST timer. When it expires, if the window is nonzero, + * we go to transmit state. Otherwise, at intervals send a single byte + * into the peer's window to force him to update our window information. + * We do this at most as often as TCPT_PERSMIN time intervals, + * but no more frequently than the current estimate of round-trip + * packet time. The TCPT_PERSIST timer is cleared whenever we receive + * a window update from the peer. + * + * The TCPT_KEEP timer is used to keep connections alive. If an + * connection is idle (no segments received) for TCPTV_KEEP_INIT amount of time, + * but not yet established, then we drop the connection. Once the connection + * is established, if the connection is idle for TCPTV_KEEP_IDLE time + * (and keepalives have been enabled on the socket), we begin to probe + * the connection. We force the peer to send us a segment by sending: + * <SEQ=SND.UNA-1><ACK=RCV.NXT><CTL=ACK> + * This segment is (deliberately) outside the window, and should elicit + * an ack segment in response from the peer. If, despite the TCPT_KEEP + * initiated segments we cannot elicit a response from a peer in TCPT_MAXIDLE + * amount of time probing, then we drop the connection. + */ + +#endif /* !_NETINET_TCP_TIMER_H_ */ + Index: branches/azimutz/Cleancut/i386/include/netinet/udp.h =================================================================== --- branches/azimutz/Cleancut/i386/include/netinet/udp.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/netinet/udp.h (revision 885) @@ -0,0 +1,83 @@ +/* + * Copyright (c) 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) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)udp.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _NETINET_UDP_H_ +#define _NETINET_UDP_H_ +#include <sys/appleapiopts.h> +#include <sys/types.h> /* u_short */ + +/* + * Udp protocol header. + * Per RFC 768, September, 1981. + */ +struct udphdr { + u_short uh_sport; /* source port */ + u_short uh_dport; /* destination port */ + u_short uh_ulen; /* udp length */ + u_short uh_sum; /* udp checksum */ +}; + +/* + * User-settable options (used with setsockopt). + */ +#define UDP_NOCKSUM 0x01 /* don't checksum outbound payloads */ +#endif Index: branches/azimutz/Cleancut/i386/include/stdlib.h =================================================================== --- branches/azimutz/Cleancut/i386/include/stdlib.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/stdlib.h (revision 885) @@ -0,0 +1,320 @@ +/* + * Copyright (c) 2000, 2002 - 2008 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@ + */ +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)stdlib.h 8.5 (Berkeley) 5/19/95 + */ + +#ifndef _STDLIB_H_ +#define _STDLIB_H_ + +#include <sys/types.h> + +#ifndef _SIZE_T +#define _SIZE_T +/* DO NOT REMOVE THIS COMMENT: fixincludes needs to see: + * _GCC_SIZE_T */ +typedef __darwin_size_t size_t; +#endif + +#if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) +#ifndef _CT_RUNE_T +#define _CT_RUNE_T +typedef __darwin_ct_rune_t ct_rune_t; +#endif + +#ifndef _RUNE_T +#define _RUNE_T +typedef __darwin_rune_t rune_t; +#endif +#endif /* !_ANSI_SOURCE && (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + +#ifndef __cplusplus +#ifndef _WCHAR_T +#define _WCHAR_T +typedef __darwin_wchar_t wchar_t; +#endif /* _WCHAR_T */ +#endif /* __cplusplus */ + +typedef struct { + int quot; /* quotient */ + int rem; /* remainder */ +} div_t; + +typedef struct { + long quot; /* quotient */ + long rem; /* remainder */ +} ldiv_t; + +#if !__DARWIN_NO_LONG_LONG +typedef struct { + long long quot; + long long rem; +} lldiv_t; +#endif /* !__DARWIN_NO_LONG_LONG */ + +#ifndef NULL +#define NULL __DARWIN_NULL +#endif /* ! NULL */ + +#define EXIT_FAILURE 1 +#define EXIT_SUCCESS 0 + +#define RAND_MAX 0x7fffffff + +#ifdef _USE_EXTENDED_LOCALES_ +#include <_xlocale.h> +#endif /* _USE_EXTENDED_LOCALES_ */ + +#ifndef MB_CUR_MAX +#ifdef _USE_EXTENDED_LOCALES_ +#define MB_CUR_MAX (___mb_cur_max()) +#ifndef MB_CUR_MAX_L +#define MB_CUR_MAX_L(x) (___mb_cur_max_l(x)) +#endif /* !MB_CUR_MAX_L */ +#else /* !_USE_EXTENDED_LOCALES_ */ +extern int __mb_cur_max; +#define MB_CUR_MAX __mb_cur_max +#endif /* _USE_EXTENDED_LOCALES_ */ +#endif /* MB_CUR_MAX */ + +#if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) \ + && defined(_USE_EXTENDED_LOCALES_) && !defined(MB_CUR_MAX_L) +#define MB_CUR_MAX_L(x) (___mb_cur_max_l(x)) +#endif +//Begin-Libc +/* f must be a literal string */ +#define LIBC_ABORT(f,...) abort_report_np("%s:%s:%u: " f, __FILE__, __func__, __LINE__, ## __VA_ARGS__) +//End-Libc + +__BEGIN_DECLS +void abort(void) __dead2; +//Begin-Libc +__private_extern__ +void abort_report_np(const char *, ...) __dead2 __printflike(1, 2); +//End-Libc +int abs(int) __pure2; +int atexit(void (*)(void)); +double atof(const char *); +int atoi(const char *); +long atol(const char *); +#if !__DARWIN_NO_LONG_LONG +long long + atoll(const char *); +#endif /* !__DARWIN_NO_LONG_LONG */ +void *bsearch(const void *, const void *, size_t, + size_t, int (*)(const void *, const void *)); +void *calloc(size_t, size_t); +div_t div(int, int) __pure2; +void exit(int) __dead2; +void free(void *); +char *getenv(const char *); +long labs(long) __pure2; +ldiv_t ldiv(long, long) __pure2; +#if !__DARWIN_NO_LONG_LONG +long long + llabs(long long); +lldiv_t lldiv(long long, long long); +#endif /* !__DARWIN_NO_LONG_LONG */ +void *malloc(size_t); +int mblen(const char *, size_t); +size_t mbstowcs(wchar_t * __restrict , const char * __restrict, size_t); +int mbtowc(wchar_t * __restrict, const char * __restrict, size_t); +int posix_memalign(void **, size_t, size_t); +void qsort(void *, size_t, size_t, + int (*)(const void *, const void *)); +int rand(void); +void *realloc(void *, size_t); +void srand(unsigned); +double strtod(const char *, char **) __DARWIN_ALIAS(strtod); +float strtof(const char *, char **) __DARWIN_ALIAS(strtof); +long strtol(const char *, char **, int); +long double + strtold(const char *, char **) __DARWIN_LDBL_COMPAT(strtold); +#if !__DARWIN_NO_LONG_LONG +long long + strtoll(const char *, char **, int); +#endif /* !__DARWIN_NO_LONG_LONG */ +unsigned long + strtoul(const char *, char **, int); +#if !__DARWIN_NO_LONG_LONG +unsigned long long + strtoull(const char *, char **, int); +#endif /* !__DARWIN_NO_LONG_LONG */ +//Begin-Libc +#ifndef LIBC_ALIAS_SYSTEM +//End-Libc +int system(const char *) __DARWIN_ALIAS_C(system); +//Begin-Libc +#else /* LIBC_ALIAS_SYSTEM */ +int system(const char *) LIBC_ALIAS_C(system); +#endif /* !LIBC_ALIAS_SYSTEM */ +//End-Libc +size_t wcstombs(char * __restrict, const wchar_t * __restrict, size_t); +int wctomb(char *, wchar_t); + +#ifndef _ANSI_SOURCE +void _Exit(int) __dead2; +long a64l(const char *); +double drand48(void); +char *ecvt(double, int, int *__restrict, int *__restrict); /* LEGACY */ +double erand48(unsigned short[3]); +char *fcvt(double, int, int *__restrict, int *__restrict); /* LEGACY */ +char *gcvt(double, int, char *); /* LEGACY */ +int getsubopt(char **, char * const *, char **); +int grantpt(int); +#if __DARWIN_UNIX03 +char *initstate(unsigned, char *, size_t); /* no __DARWIN_ALIAS needed */ +#else /* !__DARWIN_UNIX03 */ +char *initstate(unsigned long, char *, long); +#endif /* __DARWIN_UNIX03 */ +long jrand48(unsigned short[3]); +char *l64a(long); +void lcong48(unsigned short[7]); +long lrand48(void); +char *mktemp(char *); +int mkstemp(char *); +long mrand48(void); +long nrand48(unsigned short[3]); +int posix_openpt(int); +char *ptsname(int); +//Begin-Libc +#ifndef LIBC_ALIAS_PUTENV +//End-Libc +int putenv(char *) __DARWIN_ALIAS(putenv); +//Begin-Libc +#else /* LIBC_ALIAS_PUTENV */ +int putenv(char *) LIBC_ALIAS(putenv); +#endif /* !LIBC_ALIAS_PUTENV */ +//End-Libc +long random(void); +int rand_r(unsigned *); +//Begin-Libc +#ifdef __LIBC__ +#ifndef LIBC_ALIAS_REALPATH +char *realpath(const char * __restrict, char * __restrict) __DARWIN_EXTSN(realpath); +#else /* LIBC_ALIAS_REALPATH */ +#ifdef VARIANT_DARWINEXTSN +char *realpath(const char * __restrict, char * __restrict) LIBC_EXTSN(realpath); +#else /* !VARIANT_DARWINEXTSN */ +char *realpath(const char * __restrict, char * __restrict) LIBC_ALIAS(realpath); +#endif /* VARIANT_DARWINEXTSN */ +#endif /* !LIBC_ALIAS_REALPATH */ +#else /* !__LIBC__ */ +//End-Libc +#if (__DARWIN_UNIX03 && !defined(_POSIX_C_SOURCE)) || defined(_DARWIN_C_SOURCE) || defined(_DARWIN_BETTER_REALPATH) +char *realpath(const char * __restrict, char * __restrict) __DARWIN_EXTSN(realpath); +#else /* (!__DARWIN_UNIX03 || _POSIX_C_SOURCE) && !_DARWIN_C_SOURCE && !_DARWIN_BETTER_REALPATH */ +char *realpath(const char * __restrict, char * __restrict) __DARWIN_ALIAS(realpath); +#endif /* (__DARWIN_UNIX03 && _POSIX_C_SOURCE) || _DARWIN_C_SOURCE || _DARWIN_BETTER_REALPATH */ +//Begin-Libc +#endif /* __LIBC__ */ +//End-Libc +unsigned short + *seed48(unsigned short[3]); +//Begin-Libc +#ifndef LIBC_ALIAS_SETENV +//End-Libc +int setenv(const char *, const char *, int) __DARWIN_ALIAS(setenv); +//Begin-Libc +#else /* LIBC_ALIAS_SETENV */ +int setenv(const char *, const char *, int) LIBC_ALIAS(setenv); +#endif /* !LIBC_ALIAS_SETENV */ +//End-Libc +#if __DARWIN_UNIX03 +//Begin-Libc +#ifndef LIBC_ALIAS_SETKEY +//End-Libc +void setkey(const char *) __DARWIN_ALIAS(setkey); +//Begin-Libc +#else /* LIBC_ALIAS_SETKEY */ +void setkey(const char *) LIBC_ALIAS(setkey); +#endif /* !LIBC_ALIAS_SETKEY */ +//End-Libc +#else /* !__DARWIN_UNIX03 */ +int setkey(const char *); +#endif /* __DARWIN_UNIX03 */ +char *setstate(const char *); +void srand48(long); +#if __DARWIN_UNIX03 +void srandom(unsigned); +#else /* !__DARWIN_UNIX03 */ +void srandom(unsigned long); +#endif /* __DARWIN_UNIX03 */ +int unlockpt(int); +#if __DARWIN_UNIX03 +//Begin-Libc +#ifndef LIBC_ALIAS_UNSETENV +//End-Libc +int unsetenv(const char *) __DARWIN_ALIAS(unsetenv); +//Begin-Libc +#else /* LIBC_ALIAS_UNSETENV */ +int unsetenv(const char *) LIBC_ALIAS(unsetenv); +#endif /* !LIBC_ALIAS_UNSETENV */ +//End-Libc +#else /* !__DARWIN_UNIX03 */ +void unsetenv(const char *); +#endif /* __DARWIN_UNIX03 */ +#endif /* !_ANSI_SOURCE */ + +/* Poison the following routines if -fshort-wchar is set */ +#if !defined(__cplusplus) && defined(__WCHAR_MAX__) && __WCHAR_MAX__ <= 0xffffU +#pragma GCC poison mbstowcs mbtowc wcstombs wctomb +#endif +__END_DECLS + +#ifdef _USE_EXTENDED_LOCALES_ +#include <xlocale/_stdlib.h> +#endif /* _USE_EXTENDED_LOCALES_ */ + +#endif /* _STDLIB_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/kmod.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/kmod.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/kmod.h (revision 885) @@ -0,0 +1,180 @@ +/* + * Copyright (c) 2000-2007 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@ + */ +/* + * NOTICE: This file was modified by SPARTA, Inc. in 2005 to introduce + * support for mandatory and extensible security protections. This notice + * is included in support of clause 2.2 (b) of the Apple Public License, + * Version 2.0. + */ + +#ifndef _MACH_KMOD_H_ +#define _MACH_KMOD_H_ + +#include <mach/kern_return.h> +#include <mach/mach_types.h> + +#include <sys/cdefs.h> + +__BEGIN_DECLS + +#if PRAGMA_MARK +#pragma mark Basic macros & typedefs +#endif +/*********************************************************************** +* Basic macros & typedefs +***********************************************************************/ +#define KMOD_MAX_NAME 64 + +#define KMOD_RETURN_SUCCESS KERN_SUCCESS +#define KMOD_RETURN_FAILURE KERN_FAILURE + +typedef int kmod_t; + +struct kmod_info; +typedef kern_return_t kmod_start_func_t(struct kmod_info * ki, void * data); +typedef kern_return_t kmod_stop_func_t(struct kmod_info * ki, void * data); + +#if PRAGMA_MARK +#pragma mark Structure definitions +#endif +/*********************************************************************** +* Structure definitions +* +* All structures must be #pragma pack(4). +***********************************************************************/ +#pragma pack(4) + +/* Run-time struct only; never saved to a file */ +typedef struct kmod_reference { + struct kmod_reference * next; + struct kmod_info * info; +} kmod_reference_t; + +/*********************************************************************** +* Warning: Any changes to the kmod_info structure affect the +* KMOD_..._DECL macros below. +***********************************************************************/ + +/* The kmod_info_t structure is only safe to use inside the running + * kernel. If you need to work with a kmod_info_t structure outside + * the kernel, please use the compatibility definitions below. + */ +typedef struct kmod_info { + struct kmod_info * next; + int32_t info_version; // version of this structure + uint32_t id; + char name[KMOD_MAX_NAME]; + char version[KMOD_MAX_NAME]; + int32_t reference_count; // # linkage refs to this + kmod_reference_t * reference_list; // who this refs (links on) + vm_address_t address; // starting address + vm_size_t size; // total size + vm_size_t hdr_size; // unwired hdr size + kmod_start_func_t * start; + kmod_stop_func_t * stop; +} kmod_info_t; + +/* A compatibility definition of kmod_info_t for 32-bit kexts. + */ +typedef struct kmod_info_32_v1 { + uint32_t next_addr; + int32_t info_version; + uint32_t id; + uint8_t name[KMOD_MAX_NAME]; + uint8_t version[KMOD_MAX_NAME]; + int32_t reference_count; + uint32_t reference_list_addr; + uint32_t address; + uint32_t size; + uint32_t hdr_size; + uint32_t start_addr; + uint32_t stop_addr; +} kmod_info_32_v1_t; + +/* A compatibility definition of kmod_info_t for 64-bit kexts. + */ +typedef struct kmod_info_64_v1 { + uint64_t next_addr; + int32_t info_version; + uint32_t id; + uint8_t name[KMOD_MAX_NAME]; + uint8_t version[KMOD_MAX_NAME]; + int32_t reference_count; + uint64_t reference_list_addr; + uint64_t address; + uint64_t size; + uint64_t hdr_size; + uint64_t start_addr; + uint64_t stop_addr; +} kmod_info_64_v1_t; + +#pragma pack() + +#if PRAGMA_MARK +#pragma mark Kmod structure declaration macros +#endif +/*********************************************************************** +* Kmod structure declaration macros +***********************************************************************/ +#define KMOD_INFO_NAME kmod_info +#define KMOD_INFO_VERSION 1 + +#define KMOD_DECL(name, version) \ + static kmod_start_func_t name ## _module_start; \ + static kmod_stop_func_t name ## _module_stop; \ + kmod_info_t KMOD_INFO_NAME = { 0, KMOD_INFO_VERSION, -1U, \ + { #name }, { version }, -1, 0, 0, 0, 0, \ + name ## _module_start, \ + name ## _module_stop }; + +#define KMOD_EXPLICIT_DECL(name, version, start, stop) \ + kmod_info_t KMOD_INFO_NAME = { 0, KMOD_INFO_VERSION, -1U, \ + { #name }, { version }, -1, 0, 0, 0, 0, \ + start, stop }; + +#if PRAGMA_MARK +#pragma mark Kernel private declarations +#endif +/*********************************************************************** +* Kernel private declarations. +***********************************************************************/ + + +#if PRAGMA_MARK +#pragma mark Obsolete kmod stuff +#endif +/*********************************************************************** +* These 3 should be dropped but they're referenced by MIG declarations. +***********************************************************************/ +typedef void * kmod_args_t; +typedef int kmod_control_flavor_t; +typedef kmod_info_t * kmod_info_array_t; + +__END_DECLS + +#endif /* _MACH_KMOD_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/clock.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/clock.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/clock.h (revision 885) @@ -0,0 +1,221 @@ +#ifndef _clock_user_ +#define _clock_user_ + +/* Module clock */ + +#include <string.h> +#include <mach/ndr.h> +#include <mach/boolean.h> +#include <mach/kern_return.h> +#include <mach/notify.h> +#include <mach/mach_types.h> +#include <mach/message.h> +#include <mach/mig_errors.h> +#include <mach/port.h> + +#ifdef AUTOTEST +#ifndef FUNCTION_PTR_T +#define FUNCTION_PTR_T +typedef void (*function_ptr_t)(mach_port_t, char *, mach_msg_type_number_t); +typedef struct { + char *name; + function_ptr_t function; +} function_table_entry; +typedef function_table_entry *function_table_t; +#endif /* FUNCTION_PTR_T */ +#endif /* AUTOTEST */ + +#ifndef clock_MSG_COUNT +#define clock_MSG_COUNT 3 +#endif /* clock_MSG_COUNT */ + +#include <mach/std_types.h> +#include <mach/mig.h> +#include <mach/mach_types.h> +#include <mach/mach_types.h> + +#ifdef __BeforeMigUserHeader +__BeforeMigUserHeader +#endif /* __BeforeMigUserHeader */ + +#include <sys/cdefs.h> +__BEGIN_DECLS + + +/* Routine clock_get_time */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t clock_get_time +( + clock_serv_t clock_serv, + mach_timespec_t *cur_time +); + +/* Routine clock_get_attributes */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t clock_get_attributes +( + clock_serv_t clock_serv, + clock_flavor_t flavor, + clock_attr_t clock_attr, + mach_msg_type_number_t *clock_attrCnt +); + +/* Routine clock_alarm */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t clock_alarm +( + clock_serv_t clock_serv, + alarm_type_t alarm_type, + mach_timespec_t alarm_time, + clock_reply_t alarm_port +); + +__END_DECLS + +/********************** Caution **************************/ +/* The following data types should be used to calculate */ +/* maximum message sizes only. The actual message may be */ +/* smaller, and the position of the arguments within the */ +/* message layout may vary from what is presented here. */ +/* For example, if any of the arguments are variable- */ +/* sized, and less than the maximum is sent, the data */ +/* will be packed tight in the actual message to reduce */ +/* the presence of holes. */ +/********************** Caution **************************/ + +/* typedefs for all requests */ + +#ifndef __Request__clock_subsystem__defined +#define __Request__clock_subsystem__defined + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__clock_get_time_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + clock_flavor_t flavor; + mach_msg_type_number_t clock_attrCnt; + } __Request__clock_get_attributes_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t alarm_port; + /* end of the kernel processed data */ + NDR_record_t NDR; + alarm_type_t alarm_type; + mach_timespec_t alarm_time; + } __Request__clock_alarm_t; +#ifdef __MigPackStructs +#pragma pack() +#endif +#endif /* !__Request__clock_subsystem__defined */ + +/* union of all requests */ + +#ifndef __RequestUnion__clock_subsystem__defined +#define __RequestUnion__clock_subsystem__defined +union __RequestUnion__clock_subsystem { + __Request__clock_get_time_t Request_clock_get_time; + __Request__clock_get_attributes_t Request_clock_get_attributes; + __Request__clock_alarm_t Request_clock_alarm; +}; +#endif /* !__RequestUnion__clock_subsystem__defined */ +/* typedefs for all replies */ + +#ifndef __Reply__clock_subsystem__defined +#define __Reply__clock_subsystem__defined + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_timespec_t cur_time; + } __Reply__clock_get_time_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_msg_type_number_t clock_attrCnt; + int clock_attr[1]; + } __Reply__clock_get_attributes_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__clock_alarm_t; +#ifdef __MigPackStructs +#pragma pack() +#endif +#endif /* !__Reply__clock_subsystem__defined */ + +/* union of all replies */ + +#ifndef __ReplyUnion__clock_subsystem__defined +#define __ReplyUnion__clock_subsystem__defined +union __ReplyUnion__clock_subsystem { + __Reply__clock_get_time_t Reply_clock_get_time; + __Reply__clock_get_attributes_t Reply_clock_get_attributes; + __Reply__clock_alarm_t Reply_clock_alarm; +}; +#endif /* !__RequestUnion__clock_subsystem__defined */ + +#ifndef subsystem_to_name_map_clock +#define subsystem_to_name_map_clock \ + { "clock_get_time", 1000 },\ + { "clock_get_attributes", 1001 },\ + { "clock_alarm", 1002 } +#endif + +#ifdef __AfterMigUserHeader +__AfterMigUserHeader +#endif /* __AfterMigUserHeader */ + +#endif /* _clock_user_ */ Index: branches/azimutz/Cleancut/i386/include/mach/task.defs =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/task.defs (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/task.defs (revision 885) @@ -0,0 +1,393 @@ +/* + * Copyright (c) 2000-2007 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@ + */ +/* + * @OSF_FREE_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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + */ +/* + * File: mach/mach_port.defs + * Author: Rich Draves + * + * Exported kernel calls. + */ + +subsystem +#if KERNEL_SERVER + KernelServer +#endif /* KERNEL_SERVER */ + task 3400; + +#include <mach/std_types.defs> +#include <mach/mach_types.defs> +/* + * Create a new task with an empty set of IPC rights, + * and having an address space constructed from the + * target task (or empty, if inherit_memory is FALSE). + */ +routine task_create( + target_task : task_t; + ledgers : ledger_array_t; + inherit_memory : boolean_t; + out child_task : task_t); + +/* + * Destroy the target task, causing all of its threads + * to be destroyed, all of its IPC rights to be deallocated, + * and all of its address space to be deallocated. + */ +routine task_terminate( + target_task : task_t); + +/* + * Returns the set of threads belonging to the target task. + */ +routine task_threads( + target_task : task_t; + out act_list : thread_act_array_t); + +/* + * Stash a handful of ports for the target task; child + * tasks inherit this stash at task_create time. + */ +routine mach_ports_register( + target_task : task_t; + init_port_set : mach_port_array_t = + ^array[] of mach_port_t); + +/* + * Retrieve the stashed ports for the target task. + */ +routine mach_ports_lookup( + target_task : task_t; + out init_port_set : mach_port_array_t = + ^array[] of mach_port_t); + +/* + * Returns information about the target task. + */ +routine task_info( + target_task : task_name_t; + flavor : task_flavor_t; + out task_info_out : task_info_t, CountInOut); + +/* + * Set task information. + */ +routine task_set_info( + target_task : task_t; + flavor : task_flavor_t; + task_info_in : task_info_t); + +/* + * Increment the suspend count for the target task. + * No threads within a task may run when the suspend + * count for that task is non-zero. + */ +routine task_suspend( + target_task : task_t); + + +/* + * Decrement the suspend count for the target task, + * if the count is currently non-zero. If the resulting + * suspend count is zero, then threads within the task + * that also have non-zero suspend counts may execute. + */ +routine task_resume( + target_task : task_t); + +/* + * Returns the current value of the selected special port + * associated with the target task. + */ +routine task_get_special_port( + task : task_t; + which_port : int; + out special_port : mach_port_t); + +/* + * Set one of the special ports associated with the + * target task. + */ +routine task_set_special_port( + task : task_t; + which_port : int; + special_port : mach_port_t); + +/* + * Create a new thread within the target task, returning + * the port representing the first thr_act in that new thread. The + * initial execution state of the thread is undefined. + */ +routine thread_create( + parent_task : task_t; + out child_act : thread_act_t); + +/* + * Create a new thread within the target task, returning + * the port representing that new thread. The new thread + * is not suspended; its initial execution state is given + * by flavor and new_state. Returns the port representing + * the new thread. + */ +routine thread_create_running( + parent_task : task_t; + flavor : thread_state_flavor_t; + new_state : thread_state_t; + out child_act : thread_act_t); + +/* + * Set an exception handler for a task on one or more exception types. + * These handlers are invoked for all threads in the task if there are + * no thread-specific exception handlers or those handlers returned an + * error. + */ +routine task_set_exception_ports( + task : task_t; + exception_mask : exception_mask_t; + new_port : mach_port_t; + behavior : exception_behavior_t; + new_flavor : thread_state_flavor_t); + + +/* + * Lookup some of the old exception handlers for a task + */ +routine task_get_exception_ports( + task : task_t; + exception_mask : exception_mask_t; + out masks : exception_mask_array_t; + out old_handlers : exception_handler_array_t, SameCount; + out old_behaviors : exception_behavior_array_t, SameCount; + out old_flavors : exception_flavor_array_t, SameCount); + + +/* + * Set an exception handler for a thread on one or more exception types. + * At the same time, return the previously defined exception handlers for + * those types. + */ +routine task_swap_exception_ports( + task : task_t; + exception_mask : exception_mask_t; + new_port : mach_port_t; + behavior : exception_behavior_t; + new_flavor : thread_state_flavor_t; + out masks : exception_mask_array_t; + out old_handlerss : exception_handler_array_t, SameCount; + out old_behaviors : exception_behavior_array_t, SameCount; + out old_flavors : exception_flavor_array_t, SameCount); + +/* + * Create and destroy lock_set and semaphore synchronizers on a + * per-task basis (i.e. the task owns them). + */ +routine lock_set_create( + task : task_t; + out new_lock_set : lock_set_t; + n_ulocks : int; + policy : int); + +routine lock_set_destroy( + task : task_t; + lock_set : lock_set_t); + +routine semaphore_create( + task : task_t; + out semaphore : semaphore_t; + policy : int; + value : int); + +routine semaphore_destroy( + task : task_t; + semaphore : semaphore_consume_ref_t); + +/* + * Set/get policy information for a task. + * (Approved Mac OS X microkernel interface) + */ + +routine task_policy_set( + task : task_t; + flavor : task_policy_flavor_t; + policy_info : task_policy_t); + +routine task_policy_get( + task : task_t; + flavor : task_policy_flavor_t; +out policy_info : task_policy_t, CountInOut; +inout get_default : boolean_t); + +/* + * Removed from the kernel. + */ +#if KERNEL_SERVER +skip; +#else +routine task_sample( + task : task_t; + reply : mach_port_make_send_t); +#endif + +/* + * JMM - Everything from here down is likely to go away soon + */ +/* + * OBSOLETE interface. + */ +routine task_policy( + task : task_t; + policy : policy_t; + base : policy_base_t; + set_limit : boolean_t; + change : boolean_t); + + +/* + * Establish a user-level handler for the specified + * system call. + */ +routine task_set_emulation( + target_port : task_t; + routine_entry_pt: vm_address_t; + routine_number : int); + +/* + * Get user-level handler entry points for all + * emulated system calls. + */ +routine task_get_emulation_vector( + task : task_t; + out vector_start : int; + out emulation_vector: emulation_vector_t); + +/* + * Establish user-level handlers for the specified + * system calls. Non-emulated system calls are specified + * with emulation_vector[i] == EML_ROUTINE_NULL. + */ +routine task_set_emulation_vector( + task : task_t; + vector_start : int; + emulation_vector: emulation_vector_t); + + +/* + * Establish restart pc for interrupted atomic sequences. + */ +routine task_set_ras_pc( + target_task : task_t; + basepc : vm_address_t; + boundspc : vm_address_t); + + +skip; /* was kernel_task_create() */ + +/* + * JMM - Want to eliminate processor_set so keep them at the end. + */ + +/* + * Assign task to processor set. + */ +routine task_assign( + task : task_t; + new_set : processor_set_t; + assign_threads : boolean_t); + +/* + * Assign task to default set. + */ +routine task_assign_default( + task : task_t; + assign_threads : boolean_t); + +/* + * Get current assignment for task. + */ +routine task_get_assignment( + task : task_t; + out assigned_set : processor_set_name_t); + +/* + * OBSOLETE interface. + */ +routine task_set_policy( + task : task_t; + pset : processor_set_t; + policy : policy_t; + base : policy_base_t; + limit : policy_limit_t; + change : boolean_t); + +/* + * Read the selected state which is to be installed on new + * threads in the task as they are created. + */ +routine task_get_state( + task : task_t; + flavor : thread_state_flavor_t; + out old_state : thread_state_t, CountInOut); + +/* + * Set the selected state information to be installed on + * all subsequently created threads in the task. + */ +routine task_set_state( + task : task_t; + flavor : thread_state_flavor_t; + new_state : thread_state_t); + + +/* vim: set ft=c : */ Index: branches/azimutz/Cleancut/i386/include/mach/ledger.defs =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/ledger.defs (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/ledger.defs (revision 885) @@ -0,0 +1,79 @@ +/* + * Copyright (c) 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@ + */ +/* + * @OSF_COPYRIGHT@ + */ + +subsystem +#if KERNEL_USER + KernelUser +#endif /* KERNEL_USER */ +#if KERNEL_SERVER + KernelServer +#endif /* KERNEL_SERVER */ + ledger 5000; + +#ifdef KERNEL_USER +userprefix r_; +#endif /* KERNEL_USER */ + +#include <mach/std_types.defs> +#include <mach/mach_types.defs> + +/* + * Create a subordinate ledger + */ +routine ledger_create( + parent_ledger : ledger_t; + ledger_ledger : ledger_t; + out new_ledger : ledger_t; + transfer : ledger_item_t); + +/* + * Destroy a ledger + */ +routine ledger_terminate( + ledger : ledger_t); + +/* + * Transfer resources from a parent ledger to a child + */ +routine ledger_transfer( + parent_ledger : ledger_t; + child_ledger : ledger_t; + transfer : ledger_item_t); + +/* + * Return the ledger limit and balance + */ +routine ledger_read( + ledger : ledger_t; + out balance : ledger_item_t; + out limit : ledger_item_t); + +/* vim: set ft=c : */ Index: branches/azimutz/Cleancut/i386/include/mach/thread_act.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/thread_act.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/thread_act.h (revision 885) @@ -0,0 +1,40 @@ +/* + * Copyright (c) 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@ + */ +#if defined(__i386__) +#include <mach/i386/thread_act.h> +#elif defined(__x86_64__) +#include <mach/x86_64/thread_act.h> +#elif defined(__ppc__) +#include <mach/ppc/thread_act.h> +#elif defined(__ppc64__) +#include <mach/ppc64/thread_act.h> +#elif defined(__arm__) +#include <mach/arm/thread_act.h> +#else +#error unknown architecture +#endif Index: branches/azimutz/Cleancut/i386/include/mach/mach_host.defs =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/mach_host.defs (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/mach_host.defs (revision 885) @@ -0,0 +1,257 @@ +/* + * Copyright (c) 2000-2009 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@ + */ +/* + * @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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + */ + +/* + * File: mach/mach_host.defs + * + * Abstract: + * Mach host operations support. Includes processor allocation and + * control. + */ + +#ifdef MACH_KERNEL +#include <advisory_pageout.h> +#endif /* MACH_KERNEL */ + +subsystem +#if KERNEL_SERVER + KernelServer +#endif /* KERNEL_SERVER */ + mach_host 200; + +/* + * Basic types + */ + +#include <mach/std_types.defs> +#include <mach/mach_types.defs> +#include <mach/clock_types.defs> +#include <mach_debug/mach_debug_types.defs> + +/* + * References to host objects are returned by: + * mach_host_self() - trap + */ + +/* + * Return information about this host. + */ +routine host_info( + host : host_t; + flavor : host_flavor_t; + out host_info_out : host_info_t, CountInOut); + +/* + * Get string describing current kernel version. + */ +routine host_kernel_version( + host : host_t; + out kernel_version : kernel_version_t); + +/* + * Get host page size + * (compatibility for running old libraries on new kernels - + * host_page_size() is now a library routine based on constants) + */ +routine _host_page_size( + host : host_t; + out out_page_size : vm_size_t); + +/* + * Allow pagers to create named entries that point to un-mapped + * abstract memory object. The named entries are generally mappable + * and can be subsetted through the mach_make_memory_entry call + */ +routine mach_memory_object_memory_entry( + host :host_t; + internal :boolean_t; + size :vm_size_t; + permission :vm_prot_t; + pager :memory_object_t; + out entry_handle :mach_port_move_send_t); + + +/* + * Get processor info for all the processors on this host. + * The returned data is an OOL array of processor info. + */ +routine host_processor_info( + host : host_t; + flavor : processor_flavor_t; + out out_processor_count : natural_t; + out out_processor_info : processor_info_array_t); + +/* + * Return host IO master access port + */ +routine host_get_io_master( + host : host_t; + out io_master : io_master_t); + +/* + * Get service port for a processor set. + * Available to all. + */ +routine host_get_clock_service( + host : host_t; + clock_id : clock_id_t; + out clock_serv : clock_serv_t); + +/* + * kernel module interface (obsolete as of SnowLeopard) + * see mach/kmod.h + */ +/* kmod_ MIG calls now return KERN_NOT_SUPPORTED on PPC/i386/x86_64. */ +routine kmod_get_info( + host : host_t; + out modules : kmod_args_t); + +/* + * Returns information about the memory allocation zones. + * Supported in all kernels.. + */ +routine host_zone_info( + host : host_t; + out names : zone_name_array_t, + Dealloc; + out info : zone_info_array_t, + Dealloc); + +/* + * Returns information about the global VP table. + * Only supported in MACH_VM_DEBUG kernels, + * otherwise returns KERN_FAILURE. + */ +routine host_virtual_physical_table_info( + host : host_t; + out info : hash_info_bucket_array_t, + Dealloc); + +/* + * Returns information about the global reverse hash table. + * This call is only valid on MACH_IPC_DEBUG kernels. + * Otherwise, KERN_FAILURE is returned. + */ +routine host_ipc_hash_info( + host : host_t; + out info : hash_info_bucket_array_t, + Dealloc); + +skip; /* was enable_bluebox */ +skip; /* was disable_bluebox */ + +/* + * JMM - Keep processor_set related items at the end for easy + * removal. + */ +/* + * Get default processor set for host. + */ +routine processor_set_default( + host : host_t; + out default_set : processor_set_name_t); + +/* + * Create new processor set. Returns real port for manipulations, + * and name port for obtaining information. + */ +routine processor_set_create( + host : host_t; + out new_set : processor_set_t; + out new_name : processor_set_name_t); + +/* + * Temporary interfaces for conversion to 64 bit data path + */ + +routine mach_memory_object_memory_entry_64( + host :host_t; + internal :boolean_t; + size :memory_object_size_t; + permission :vm_prot_t; + pager :memory_object_t; + out entry_handle :mach_port_move_send_t); + +/* + * Return statistics from this host. + */ +routine host_statistics( + host_priv : host_t; + flavor : host_flavor_t; + out host_info_out : host_info_t, CountInOut); + +routine host_request_notification( + host : host_t; + notify_type : host_flavor_t; + notify_port : mach_port_make_send_once_t); + +routine host_lockgroup_info( + host : host_t; + out lockgroup_info : lockgroup_info_array_t, + Dealloc); + +/* + * Return 64-bit statistics from this host. + */ +routine host_statistics64( + host_priv : host_t; + flavor : host_flavor_t; + out host_info64_out : host_info64_t, CountInOut); + + +/* vim: set ft=c : */ Index: branches/azimutz/Cleancut/i386/include/mach/policy.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/policy.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/policy.h (revision 885) @@ -0,0 +1,235 @@ +/* + * Copyright (c) 2000-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@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989,1988 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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + */ + +#ifndef _MACH_POLICY_H_ +#define _MACH_POLICY_H_ + +/* + * mach/policy.h + * + * Definitions for scheduing policy. + */ + +/* + * All interfaces defined here are obsolete. + */ + +#include <mach/boolean.h> +#include <mach/message.h> +#include <mach/vm_types.h> + +/* + * Old scheduling control interface + */ +typedef int policy_t; +typedef integer_t *policy_info_t; +typedef integer_t *policy_base_t; +typedef integer_t *policy_limit_t; + +/* + * Policy definitions. Policies should be powers of 2, + * but cannot be or'd together other than to test for a + * policy 'class'. + */ +#define POLICY_NULL 0 /* none */ +#define POLICY_TIMESHARE 1 /* timesharing */ +#define POLICY_RR 2 /* fixed round robin */ +#define POLICY_FIFO 4 /* fixed fifo */ + +#define __NEW_SCHEDULING_FRAMEWORK__ + +/* + * Check if policy is of 'class' fixed-priority. + */ +#define POLICYCLASS_FIXEDPRI (POLICY_RR | POLICY_FIFO) + +/* + * Check if policy is valid. + */ +#define invalid_policy(policy) \ + ((policy) != POLICY_TIMESHARE && \ + (policy) != POLICY_RR && \ + (policy) != POLICY_FIFO) + + +/* + * Types for TIMESHARE policy + */ +struct policy_timeshare_base { + integer_t base_priority; +}; +struct policy_timeshare_limit { + integer_t max_priority; +}; +struct policy_timeshare_info { + integer_t max_priority; + integer_t base_priority; + integer_t cur_priority; + boolean_t depressed; + integer_t depress_priority; +}; + +typedef struct policy_timeshare_base *policy_timeshare_base_t; +typedef struct policy_timeshare_limit *policy_timeshare_limit_t; +typedef struct policy_timeshare_info *policy_timeshare_info_t; + +typedef struct policy_timeshare_base policy_timeshare_base_data_t; +typedef struct policy_timeshare_limit policy_timeshare_limit_data_t; +typedef struct policy_timeshare_info policy_timeshare_info_data_t; + + +#define POLICY_TIMESHARE_BASE_COUNT ((mach_msg_type_number_t) \ + (sizeof(struct policy_timeshare_base)/sizeof(integer_t))) +#define POLICY_TIMESHARE_LIMIT_COUNT ((mach_msg_type_number_t) \ + (sizeof(struct policy_timeshare_limit)/sizeof(integer_t))) +#define POLICY_TIMESHARE_INFO_COUNT ((mach_msg_type_number_t) \ + (sizeof(struct policy_timeshare_info)/sizeof(integer_t))) + + +/* + * Types for the ROUND ROBIN (RR) policy + */ +struct policy_rr_base { + integer_t base_priority; + integer_t quantum; +}; +struct policy_rr_limit { + integer_t max_priority; +}; +struct policy_rr_info { + integer_t max_priority; + integer_t base_priority; + integer_t quantum; + boolean_t depressed; + integer_t depress_priority; +}; + +typedef struct policy_rr_base *policy_rr_base_t; +typedef struct policy_rr_limit *policy_rr_limit_t; +typedef struct policy_rr_info *policy_rr_info_t; + +typedef struct policy_rr_base policy_rr_base_data_t; +typedef struct policy_rr_limit policy_rr_limit_data_t; +typedef struct policy_rr_info policy_rr_info_data_t; + +#define POLICY_RR_BASE_COUNT ((mach_msg_type_number_t) \ + (sizeof(struct policy_rr_base)/sizeof(integer_t))) +#define POLICY_RR_LIMIT_COUNT ((mach_msg_type_number_t) \ + (sizeof(struct policy_rr_limit)/sizeof(integer_t))) +#define POLICY_RR_INFO_COUNT ((mach_msg_type_number_t) \ + (sizeof(struct policy_rr_info)/sizeof(integer_t))) + + +/* + * Types for the FIRST-IN-FIRST-OUT (FIFO) policy + */ +struct policy_fifo_base { + integer_t base_priority; +}; +struct policy_fifo_limit { + integer_t max_priority; +}; +struct policy_fifo_info { + integer_t max_priority; + integer_t base_priority; + boolean_t depressed; + integer_t depress_priority; +}; + +typedef struct policy_fifo_base *policy_fifo_base_t; +typedef struct policy_fifo_limit *policy_fifo_limit_t; +typedef struct policy_fifo_info *policy_fifo_info_t; + +typedef struct policy_fifo_base policy_fifo_base_data_t; +typedef struct policy_fifo_limit policy_fifo_limit_data_t; +typedef struct policy_fifo_info policy_fifo_info_data_t; + +#define POLICY_FIFO_BASE_COUNT ((mach_msg_type_number_t) \ + (sizeof(struct policy_fifo_base)/sizeof(integer_t))) +#define POLICY_FIFO_LIMIT_COUNT ((mach_msg_type_number_t) \ + (sizeof(struct policy_fifo_limit)/sizeof(integer_t))) +#define POLICY_FIFO_INFO_COUNT ((mach_msg_type_number_t) \ + (sizeof(struct policy_fifo_info)/sizeof(integer_t))) + +/* + * Aggregate policy types + */ + +struct policy_bases { + policy_timeshare_base_data_t ts; + policy_rr_base_data_t rr; + policy_fifo_base_data_t fifo; +}; + +struct policy_limits { + policy_timeshare_limit_data_t ts; + policy_rr_limit_data_t rr; + policy_fifo_limit_data_t fifo; +}; + +struct policy_infos { + policy_timeshare_info_data_t ts; + policy_rr_info_data_t rr; + policy_fifo_info_data_t fifo; +}; + +typedef struct policy_bases policy_base_data_t; +typedef struct policy_limits policy_limit_data_t; +typedef struct policy_infos policy_info_data_t; + +#endif /* _MACH_POLICY_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/security.defs =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/security.defs (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/security.defs (revision 885) @@ -0,0 +1,208 @@ + +/* -*- C++ -*- */ + +subsystem +#if KERNEL_SERVER + KernelServer +#endif KERNEL_SERVER + security 5200; + +#include <mach/std_types.defs> +#include <mach/mach_types.defs> + +type labelstr_t = c_string[*:512]; + +/** + @brief Retrieve a task label as a label handle + @param task Target's task port + @param label Returned label handle + + This call retrieves the label handle of the specified task. + + @return Standard MiG return values (0 for success) +*/ + +routine mach_get_task_label(task : ipc_space_t; + out label : mach_port_name_t); + +/** + @brief Retrieve a task label in textual form + @param task Target's task port + @param policies Comma-delimited list of policies to query + @param label Returned label text + + This call retrieves an externalized task label for the + specified task, with respect to the specified policies. + + @return Standard MiG return values (0 for success) +*/ + +routine mach_get_task_label_text(task : ipc_space_t; + policies : labelstr_t; + out label : labelstr_t); + +/** + @brief Retrieve a port label as a label handle + @param task Issuer's task port + @param port Port to query label from + @param label Returned label handle + + This call retrieves a new label handle for the specified port. + If the port represents a label handle, KERN_INVALID_ARGUMENT is + returned. + + @return Standard MiG return values (0 for success) +*/ + +routine mach_get_label(task : ipc_space_t; + port : mach_port_name_t; + out label : mach_port_name_t); + +/** + @brief Retrieve a port label in textual form + @param task Issuer's task port + @param name Port to query label from + @param policies Comma-delimited list of policies to query + @param label Returned label text + + This call retrieves an externalized port label for the specified port, + with respect to the specified policies. If the port represents a label + handle, the returned label text refers to the stored label and not the + access control label. + + @return Standard MiG return values (0 for success) +*/ + +routine mach_get_label_text(task : ipc_space_t; + name : mach_port_name_t; + policies : labelstr_t; + out label : labelstr_t); + +/** + @brief Relabel a port + @param task Task containing specified ports + @param name Port to relabel + @param label String representation of new label + + This call attempts to relabel the specified port to the + label specified. For label handles, it changes the access control + label and not the stored label. + + @return Standard MiG return values (0 for success) +*/ + +routine mach_set_port_label(task : ipc_space_t; + name : mach_port_name_t; + label : labelstr_t); + +/** + @brief Generic access control check + @param task Any task port + @param subj subject label in textual form + @param obj object label in textual form + @param serv Service or object class name + @param perm Permission, or method, within the specified service + + This function provides a general way for a user process to query + an arbitrary access control decision from the system's security policies. + Currently, there are no standards for the format of the service and + permission names. + + @return Standard MiG return values (0 for success) +*/ + +routine mac_check_service(task : ipc_space_t; + subject : labelstr_t; + object : labelstr_t; + service : labelstr_t; + perm : labelstr_t); + +/** + @brief Generic access control check + @param task Task containing specified ports (usually caller's) + @param subj subject label in textual form + @param obj port containing object label + @param serv Service or object class name + @param perm Permission, or method, within the specified service + + This function provides a general way for a user process to query + an arbitrary access control decision from the system's security policies. + Currently, there are no standards for the format of the service and + permission names. If the port is a label handle, the stored label is + used. Otherwise, its access control label is used. + + @return Standard MiG return values (0 for success) +*/ + +routine mac_port_check_service_obj(task : ipc_space_t; + subject : labelstr_t; + object : mach_port_name_t; + service : labelstr_t; + perm : labelstr_t); + +/** + @brief Generic access control check + @param task Task containing specified ports (usually caller's) + @param subj port containing subject label + @param obj port containing object label + @param serv Service or object class name + @param perm Permission, or method, within the specified service + + This function provides a general way for a user process to query + an arbitrary access control decision from the system's security policies. + Currently, there are no standards for the format of the service and + permission names. If any ports are label handles, the stored label is + used. Otherwise, the access control labels are used. + + @return Standard MiG return values (0 for success) +*/ + +routine mac_port_check_access(task : ipc_space_t; + subject : mach_port_name_t; + object : mach_port_name_t; + service : labelstr_t; + perm : labelstr_t); + +/** + @brief Create a new label handle + @param task Task to receive new ports (usually caller's) + @param name Returned label handle port + @param label String representation of new label + + Creates a new label handle, with the stored label defined by the + given text. Any task may create a label handle with any valid label, + not necessarily one that it has permission to access. A port right + for the new label handle is inserted into the specified task. + Posession of label handles should not imply any security properties. + + @return Standard MiG return values (0 for success) +*/ + +routine mac_label_new(task : ipc_space_t; + out name : mach_port_name_t; + label : labelstr_t); + +/** + @brief Request a computed label + @param task subj,obj,newlabel relative to this task (usually caller's) + @param subj port containing subject label + @param obj port containing object label + @param serv Service or object class name + @param newlabel Returned label handle port + + Ask the loaded policies to compute a label based on the two input labels + and the service name. There is currently no standard for the service name, + or even what the input labels represent (Subject and parent object are only + a suggestion). If any ports are label handles, the stored label is + used. Otherwise, the access control labels are used. A new label handle + is created to contain the computed label, and is stored into the + specified task. + + @return Standard MiG return values (0 for success) +*/ + +routine mac_request_label(task : ipc_space_t; + subject : mach_port_name_t; + object : mach_port_name_t; + service : labelstr_t; + out newlabel : mach_port_name_t); Index: branches/azimutz/Cleancut/i386/include/mach/clock_reply.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/clock_reply.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/clock_reply.h (revision 885) @@ -0,0 +1,136 @@ +#ifndef _clock_reply_user_ +#define _clock_reply_user_ + +/* Module clock_reply */ + +#include <string.h> +#include <mach/ndr.h> +#include <mach/boolean.h> +#include <mach/kern_return.h> +#include <mach/notify.h> +#include <mach/mach_types.h> +#include <mach/message.h> +#include <mach/mig_errors.h> +#include <mach/port.h> + +#ifdef AUTOTEST +#ifndef FUNCTION_PTR_T +#define FUNCTION_PTR_T +typedef void (*function_ptr_t)(mach_port_t, char *, mach_msg_type_number_t); +typedef struct { + char *name; + function_ptr_t function; +} function_table_entry; +typedef function_table_entry *function_table_t; +#endif /* FUNCTION_PTR_T */ +#endif /* AUTOTEST */ + +#ifndef clock_reply_MSG_COUNT +#define clock_reply_MSG_COUNT 1 +#endif /* clock_reply_MSG_COUNT */ + +#include <mach/std_types.h> +#include <mach/mig.h> +#include <mach/mach_types.h> + +#ifdef __BeforeMigUserHeader +__BeforeMigUserHeader +#endif /* __BeforeMigUserHeader */ + +#include <sys/cdefs.h> +__BEGIN_DECLS + + +/* SimpleRoutine clock_alarm_reply */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t clock_alarm_reply +( + clock_reply_t alarm_port, + mach_msg_type_name_t alarm_portPoly, + kern_return_t alarm_code, + alarm_type_t alarm_type, + mach_timespec_t alarm_time +); + +__END_DECLS + +/********************** Caution **************************/ +/* The following data types should be used to calculate */ +/* maximum message sizes only. The actual message may be */ +/* smaller, and the position of the arguments within the */ +/* message layout may vary from what is presented here. */ +/* For example, if any of the arguments are variable- */ +/* sized, and less than the maximum is sent, the data */ +/* will be packed tight in the actual message to reduce */ +/* the presence of holes. */ +/********************** Caution **************************/ + +/* typedefs for all requests */ + +#ifndef __Request__clock_reply_subsystem__defined +#define __Request__clock_reply_subsystem__defined + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t alarm_code; + alarm_type_t alarm_type; + mach_timespec_t alarm_time; + } __Request__clock_alarm_reply_t; +#ifdef __MigPackStructs +#pragma pack() +#endif +#endif /* !__Request__clock_reply_subsystem__defined */ + +/* union of all requests */ + +#ifndef __RequestUnion__clock_reply_subsystem__defined +#define __RequestUnion__clock_reply_subsystem__defined +union __RequestUnion__clock_reply_subsystem { + __Request__clock_alarm_reply_t Request_clock_alarm_reply; +}; +#endif /* !__RequestUnion__clock_reply_subsystem__defined */ +/* typedefs for all replies */ + +#ifndef __Reply__clock_reply_subsystem__defined +#define __Reply__clock_reply_subsystem__defined + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__clock_alarm_reply_t; +#ifdef __MigPackStructs +#pragma pack() +#endif +#endif /* !__Reply__clock_reply_subsystem__defined */ + +/* union of all replies */ + +#ifndef __ReplyUnion__clock_reply_subsystem__defined +#define __ReplyUnion__clock_reply_subsystem__defined +union __ReplyUnion__clock_reply_subsystem { + __Reply__clock_alarm_reply_t Reply_clock_alarm_reply; +}; +#endif /* !__RequestUnion__clock_reply_subsystem__defined */ + +#ifndef subsystem_to_name_map_clock_reply +#define subsystem_to_name_map_clock_reply \ + { "clock_alarm_reply", 3125107 } +#endif + +#ifdef __AfterMigUserHeader +__AfterMigUserHeader +#endif /* __AfterMigUserHeader */ + +#endif /* _clock_reply_user_ */ Index: branches/azimutz/Cleancut/i386/include/mach/vm_map.defs =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/vm_map.defs (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/vm_map.defs (revision 885) @@ -0,0 +1,475 @@ +/* + * 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_FREE_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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + */ +/* + * File: mach/vm_map.defs + * + * Exported (native-sized) kernel VM calls. + */ + +subsystem +#if KERNEL_SERVER + KernelServer +#endif /* KERNEL_SERVER */ + vm_map 3800; + +#include <mach/std_types.defs> +#include <mach/mach_types.defs> +#include <mach_debug/mach_debug_types.defs> + +/* + * Returns information about the contents of the virtual + * address space of the target task at the specified + * address. The returned protection, inheritance, sharing + * and memory object values apply to the entire range described + * by the address range returned; the memory object offset + * corresponds to the beginning of the address range. + * [If the specified address is not allocated, the next + * highest address range is described. If no addresses beyond + * the one specified are allocated, the call returns KERN_NO_SPACE.] + */ +routine vm_region( + target_task : vm_map_t; + inout address : vm_address_t; + out size : vm_size_t; + flavor : vm_region_flavor_t; + out info : vm_region_info_t, CountInOut; + out object_name : memory_object_name_t = + MACH_MSG_TYPE_MOVE_SEND + ctype: mach_port_t); + +/* + * Allocate zero-filled memory in the address space + * of the target task, either at the specified address, + * or wherever space can be found (if anywhere is TRUE), + * of the specified size. The address at which the + * allocation actually took place is returned. + */ +routine vm_allocate( + target_task : vm_task_entry_t; + inout address : vm_address_t; + size : vm_size_t; + flags : int); + +/* + * Deallocate the specified range from the virtual + * address space of the target task. + */ +routine vm_deallocate( + target_task : vm_task_entry_t; + address : vm_address_t; + size : vm_size_t); + +/* + * Set the current or maximum protection attribute + * for the specified range of the virtual address + * space of the target task. The current protection + * limits the memory access rights of threads within + * the task; the maximum protection limits the accesses + * that may be given in the current protection. + * Protections are specified as a set of {read, write, execute} + * *permissions*. + */ +routine vm_protect( + target_task : vm_task_entry_t; + address : vm_address_t; + size : vm_size_t; + set_maximum : boolean_t; + new_protection : vm_prot_t); + +/* + * Set the inheritance attribute for the specified range + * of the virtual address space of the target task. + * The inheritance value is one of {none, copy, share}, and + * specifies how the child address space should acquire + * this memory at the time of a task_create call. + */ +routine vm_inherit( + target_task : vm_task_entry_t; + address : vm_address_t; + size : vm_size_t; + new_inheritance : vm_inherit_t); + +/* + * Returns the contents of the specified range of the + * virtual address space of the target task. [The + * range must be aligned on a virtual page boundary, + * and must be a multiple of pages in extent. The + * protection on the specified range must permit reading.] + */ +routine vm_read( + target_task : vm_map_t; + address : vm_address_t; + size : vm_size_t; + out data : pointer_t); + +/* + * List corrollary to vm_read, returns mapped contents of specified + * ranges within target address space. + */ +routine vm_read_list( + target_task : vm_map_t; + inout data_list : vm_read_entry_t; + count : natural_t); + +/* + * Writes the contents of the specified range of the + * virtual address space of the target task. [The + * range must be aligned on a virtual page boundary, + * and must be a multiple of pages in extent. The + * protection on the specified range must permit writing.] + */ +routine vm_write( + target_task : vm_map_t; + address : vm_address_t; + data : pointer_t); + +/* + * Copy the contents of the source range of the virtual + * address space of the target task to the destination + * range in that same address space. [Both of the + * ranges must be aligned on a virtual page boundary, + * and must be multiples of pages in extent. The + * protection on the source range must permit reading, + * and the protection on the destination range must + * permit writing.] + */ +routine vm_copy( + target_task : vm_map_t; + source_address : vm_address_t; + size : vm_size_t; + dest_address : vm_address_t); + +/* + * Returns the contents of the specified range of the + * virtual address space of the target task. [There + * are no alignment restrictions, and the results will + * overwrite the area pointed to by data - which must + * already exist. The protection on the specified range + * must permit reading.] + */ +routine vm_read_overwrite( + target_task : vm_map_t; + address : vm_address_t; + size : vm_size_t; + data : vm_address_t; + out outsize : vm_size_t); + + +routine vm_msync( + target_task : vm_map_t; + address : vm_address_t; + size : vm_size_t; + sync_flags : vm_sync_t ); + +/* + * Set the paging behavior attribute for the specified range + * of the virtual address space of the target task. + * The behavior value is one of {default, random, forward + * sequential, reverse sequential} and indicates the expected + * page reference pattern for the specified range. + */ +routine vm_behavior_set( + target_task : vm_map_t; + address : vm_address_t; + size : vm_size_t; + new_behavior : vm_behavior_t); + + +/* + * Map a user-defined memory object into the virtual address + * space of the target task. If desired (anywhere is TRUE), + * the kernel will find a suitable address range of the + * specified size; else, the specific address will be allocated. + * + * The beginning address of the range will be aligned on a virtual + * page boundary, be at or beyond the address specified, and + * meet the mask requirements (bits turned on in the mask must not + * be turned on in the result); the size of the range, in bytes, + * will be rounded up to an integral number of virtual pages. + * + * The memory in the resulting range will be associated with the + * specified memory object, with the beginning of the memory range + * referring to the specified offset into the memory object. + * + * The mapping will take the current and maximum protections and + * the inheritance attributes specified; see the vm_protect and + * vm_inherit calls for a description of these attributes. + * + * If desired (copy is TRUE), the memory range will be filled + * with a copy of the data from the memory object; this copy will + * be private to this mapping in this target task. Otherwise, + * the memory in this mapping will be shared with other mappings + * of the same memory object at the same offset (in this task or + * in other tasks). [The Mach kernel only enforces shared memory + * consistency among mappings on one host with similar page alignments. + * The user-defined memory manager for this object is responsible + * for further consistency.] + */ +routine vm_map( + target_task : vm_task_entry_t; + inout address : vm_address_t; + size : vm_size_t; + mask : vm_address_t; + flags : int; + object : mem_entry_name_port_t; + offset : vm_offset_t; + copy : boolean_t; + cur_protection : vm_prot_t; + max_protection : vm_prot_t; + inheritance : vm_inherit_t); + +/* + * Set/Get special properties of memory associated + * to some virtual address range, such as cachability, + * migrability, replicability. Machine-dependent. + */ +routine vm_machine_attribute( + target_task : vm_map_t; + address : vm_address_t; + size : vm_size_t; + attribute : vm_machine_attribute_t; + inout value : vm_machine_attribute_val_t); + +/* + * Map portion of a task's address space. + */ +routine vm_remap( + target_task : vm_map_t; + inout target_address : vm_address_t; + size : vm_size_t; + mask : vm_address_t; + anywhere : boolean_t; + src_task : vm_map_t; + src_address : vm_address_t; + copy : boolean_t; + out cur_protection : vm_prot_t; + out max_protection : vm_prot_t; + inheritance : vm_inherit_t); + +/* + * Require that all future virtual memory allocation + * allocates wired memory. Setting must_wire to FALSE + * disables the wired future feature. + */ +routine task_wire( + target_task : vm_map_t; + must_wire : boolean_t); + + +/* + * Allow application level processes to create named entries which + * correspond to mapped portions of their address space. These named + * entries can then be manipulated, shared with other processes in + * other address spaces and ultimately mapped in ohter address spaces + */ + +routine mach_make_memory_entry( + target_task :vm_map_t; + inout size :vm_size_t; + offset :vm_offset_t; + permission :vm_prot_t; + out object_handle :mem_entry_name_port_move_send_t; + parent_entry :mem_entry_name_port_t); + +/* + * Give the caller information on the given location in a virtual + * address space. If a page is mapped return ref and dirty info. + */ +routine vm_map_page_query( + target_map :vm_map_t; + offset :vm_offset_t; + out disposition :integer_t; + out ref_count :integer_t); + +/* + * Returns information about a region of memory. + * Includes info about the chain of objects rooted at that region. + * Only available in MACH_VM_DEBUG compiled kernels, + * otherwise returns KERN_FAILURE. + */ +routine mach_vm_region_info( + task : vm_map_t; + address : vm_address_t; + out region : vm_info_region_t; + out objects : vm_info_object_array_t); + +routine vm_mapped_pages_info( + task : vm_map_t; + out pages : page_address_array_t); + +#if 0 +/* + * Allow application level processes to create named entries which + * are backed by sub-maps which describe regions of address space. + * These regions of space can have objects mapped into them and + * in turn, can be mapped into target address spaces + */ + +routine vm_region_object_create( + target_task :vm_map_t; + in size :vm_size_t; + out region_object :mach_port_move_send_t); +#else +skip; /* was vm_region_object_create */ +#endif + +/* + * A recursive form of vm_region which probes submaps withint the + * address space. + */ +routine vm_region_recurse( + target_task : vm_map_t; + inout address : vm_address_t; + out size : vm_size_t; + inout nesting_depth : natural_t; + out info : vm_region_recurse_info_t,CountInOut); + + +/* + * The routines below are temporary, meant for transitional use + * as their counterparts are moved from 32 to 64 bit data path + */ + + +routine vm_region_recurse_64( + target_task : vm_map_t; + inout address : vm_address_t; + out size : vm_size_t; + inout nesting_depth : natural_t; + out info : vm_region_recurse_info_t,CountInOut); + +routine mach_vm_region_info_64( + task : vm_map_t; + address : vm_address_t; + out region : vm_info_region_64_t; + out objects : vm_info_object_array_t); + +routine vm_region_64( + target_task : vm_map_t; + inout address : vm_address_t; + out size : vm_size_t; + flavor : vm_region_flavor_t; + out info : vm_region_info_t, CountInOut; + out object_name : memory_object_name_t = + MACH_MSG_TYPE_MOVE_SEND + ctype: mach_port_t); + +routine mach_make_memory_entry_64( + target_task :vm_map_t; + inout size :memory_object_size_t; + offset :memory_object_offset_t; + permission :vm_prot_t; + out object_handle :mach_port_move_send_t; + parent_entry :mem_entry_name_port_t); + + + +routine vm_map_64( + target_task : vm_task_entry_t; + inout address : vm_address_t; + size : vm_size_t; + mask : vm_address_t; + flags : int; + object : mem_entry_name_port_t; + offset : memory_object_offset_t; + copy : boolean_t; + cur_protection : vm_prot_t; + max_protection : vm_prot_t; + inheritance : vm_inherit_t); + +#if 0 +/* + * The UPL interfaces are not ready for user-level export. + */ +routine vm_map_get_upl( + target_task : vm_map_t; + address : vm_map_offset_t; + inout size : vm_size_t; + out upl : upl_t; + out page_info : upl_page_info_array_t, CountInOut; + inout flags : integer_t; + force_data_sync : integer_t); + +routine vm_upl_map( + target_task : vm_map_t; + upl : upl_t; + inout address : vm_address_t); + +routine vm_upl_unmap( + target_task : vm_map_t; + upl : upl_t); +#else +skip; /* was vm_map_get_upl */ +skip; /* was vm_upl_map */ +skip; /* was vm_upl_unmap */ +#endif + +/* + * Control behavior and investigate state of a "purgable" object in + * the virtual address space of the target task. A purgable object is + * created via a call to vm_allocate() with VM_FLAGS_PURGABLE + * specified. See the routine implementation for a complete + * definition of the routine. + */ +routine vm_purgable_control( + target_task : vm_map_t; + address : vm_address_t; + control : vm_purgable_t; + inout state : int); + +/* vim: set ft=c : */ Index: branches/azimutz/Cleancut/i386/include/mach/port_obj.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/port_obj.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/port_obj.h (revision 885) @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2003 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@ + */ + +/* + * Define a service to map from a kernel-generated port name + * to server-defined "type" and "value" data to be associated + * with the port. + */ + +#ifndef PORT_OBJ_H +#define PORT_OBJ_H + +#include <mach/port.h> + +struct port_obj_tentry { + void *pos_value; + int pos_type; +}; + +#include <sys/cdefs.h> + +__BEGIN_DECLS +extern void port_obj_init(int); +__END_DECLS + +extern struct port_obj_tentry *port_obj_table; +extern int port_obj_table_size; + +#ifndef PORT_OBJ_ASSERT + +#define port_set_obj_value_type(pname, value, type) \ +do { \ + int ndx; \ + \ + if (!port_obj_table) \ + port_obj_init(port_obj_table_size); \ + ndx = MACH_PORT_INDEX(pname); \ + port_obj_table[ndx].pos_value = (value); \ + port_obj_table[ndx].pos_type = (type); \ +} while (0) + +#define port_get_obj_value(pname) \ + (port_obj_table[MACH_PORT_INDEX(pname)].pos_value) + +#define port_get_obj_type(pname) \ + (port_obj_table[MACH_PORT_INDEX(pname)].pos_type) + +#else /* PORT_OBJ_ASSERT */ + +#define port_set_obj_value_type(pname, value, type) \ +do { \ + int ndx; \ + \ + if (!port_obj_table) \ + port_obj_init(port_obj_table_size); \ + ndx = MACH_PORT_INDEX(pname); \ + assert(ndx > 0); \ + assert(ndx < port_obj_table_size); \ + port_obj_table[ndx].pos_value = (value); \ + port_obj_table[ndx].pos_type = (type); \ +} while (0) + +#define port_get_obj_value(pname) \ + ((MACH_PORT_INDEX(pname) < (unsigned)port_obj_table_size) ? \ + port_obj_table[MACH_PORT_INDEX(pname)].pos_value : \ + (panic("port_get_obj_value: index too big"), (void *)-1)) + +#define port_get_obj_type(pname) \ + ((MACH_PORT_INDEX(pname) < (unsigned)port_obj_table_size) ? \ + port_obj_table[MACH_PORT_INDEX(pname)].pos_type : \ + (panic("port_get_obj_type: index too big"), -1)) + +#endif /* PORT_OBJ_ASSERT */ + +#endif /* PORT_OBJ_H */ Index: branches/azimutz/Cleancut/i386/include/mach/vm_map.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/vm_map.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/vm_map.h (revision 885) @@ -0,0 +1,1378 @@ +#ifndef _vm_map_user_ +#define _vm_map_user_ + +/* Module vm_map */ + +#include <string.h> +#include <mach/ndr.h> +#include <mach/boolean.h> +#include <mach/kern_return.h> +#include <mach/notify.h> +#include <mach/mach_types.h> +#include <mach/message.h> +#include <mach/mig_errors.h> +#include <mach/port.h> + +#ifdef AUTOTEST +#ifndef FUNCTION_PTR_T +#define FUNCTION_PTR_T +typedef void (*function_ptr_t)(mach_port_t, char *, mach_msg_type_number_t); +typedef struct { + char *name; + function_ptr_t function; +} function_table_entry; +typedef function_table_entry *function_table_t; +#endif /* FUNCTION_PTR_T */ +#endif /* AUTOTEST */ + +#ifndef vm_map_MSG_COUNT +#define vm_map_MSG_COUNT 31 +#endif /* vm_map_MSG_COUNT */ + +#include <mach/std_types.h> +#include <mach/mig.h> +#include <mach/mach_types.h> +#include <mach_debug/mach_debug_types.h> + +#ifdef __BeforeMigUserHeader +__BeforeMigUserHeader +#endif /* __BeforeMigUserHeader */ + +#include <sys/cdefs.h> +__BEGIN_DECLS + + +/* Routine vm_region */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t vm_region +( + vm_map_t target_task, + vm_address_t *address, + vm_size_t *size, + vm_region_flavor_t flavor, + vm_region_info_t info, + mach_msg_type_number_t *infoCnt, + mach_port_t *object_name +); + +/* Routine vm_allocate */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t vm_allocate +( + vm_map_t target_task, + vm_address_t *address, + vm_size_t size, + int flags +); + +/* Routine vm_deallocate */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t vm_deallocate +( + vm_map_t target_task, + vm_address_t address, + vm_size_t size +); + +/* Routine vm_protect */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t vm_protect +( + vm_map_t target_task, + vm_address_t address, + vm_size_t size, + boolean_t set_maximum, + vm_prot_t new_protection +); + +/* Routine vm_inherit */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t vm_inherit +( + vm_map_t target_task, + vm_address_t address, + vm_size_t size, + vm_inherit_t new_inheritance +); + +/* Routine vm_read */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t vm_read +( + vm_map_t target_task, + vm_address_t address, + vm_size_t size, + vm_offset_t *data, + mach_msg_type_number_t *dataCnt +); + +/* Routine vm_read_list */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t vm_read_list +( + vm_map_t target_task, + vm_read_entry_t data_list, + natural_t count +); + +/* Routine vm_write */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t vm_write +( + vm_map_t target_task, + vm_address_t address, + vm_offset_t data, + mach_msg_type_number_t dataCnt +); + +/* Routine vm_copy */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t vm_copy +( + vm_map_t target_task, + vm_address_t source_address, + vm_size_t size, + vm_address_t dest_address +); + +/* Routine vm_read_overwrite */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t vm_read_overwrite +( + vm_map_t target_task, + vm_address_t address, + vm_size_t size, + vm_address_t data, + vm_size_t *outsize +); + +/* Routine vm_msync */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t vm_msync +( + vm_map_t target_task, + vm_address_t address, + vm_size_t size, + vm_sync_t sync_flags +); + +/* Routine vm_behavior_set */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t vm_behavior_set +( + vm_map_t target_task, + vm_address_t address, + vm_size_t size, + vm_behavior_t new_behavior +); + +/* Routine vm_map */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t vm_map +( + vm_map_t target_task, + vm_address_t *address, + vm_size_t size, + vm_address_t mask, + int flags, + mem_entry_name_port_t object, + vm_offset_t offset, + boolean_t copy, + vm_prot_t cur_protection, + vm_prot_t max_protection, + vm_inherit_t inheritance +); + +/* Routine vm_machine_attribute */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t vm_machine_attribute +( + vm_map_t target_task, + vm_address_t address, + vm_size_t size, + vm_machine_attribute_t attribute, + vm_machine_attribute_val_t *value +); + +/* Routine vm_remap */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t vm_remap +( + vm_map_t target_task, + vm_address_t *target_address, + vm_size_t size, + vm_address_t mask, + boolean_t anywhere, + vm_map_t src_task, + vm_address_t src_address, + boolean_t copy, + vm_prot_t *cur_protection, + vm_prot_t *max_protection, + vm_inherit_t inheritance +); + +/* Routine task_wire */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_wire +( + vm_map_t target_task, + boolean_t must_wire +); + +/* Routine mach_make_memory_entry */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_make_memory_entry +( + vm_map_t target_task, + vm_size_t *size, + vm_offset_t offset, + vm_prot_t permission, + mem_entry_name_port_t *object_handle, + mem_entry_name_port_t parent_entry +); + +/* Routine vm_map_page_query */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t vm_map_page_query +( + vm_map_t target_map, + vm_offset_t offset, + integer_t *disposition, + integer_t *ref_count +); + +/* Routine mach_vm_region_info */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_vm_region_info +( + vm_map_t task, + vm_address_t address, + vm_info_region_t *region, + vm_info_object_array_t *objects, + mach_msg_type_number_t *objectsCnt +); + +/* Routine vm_mapped_pages_info */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t vm_mapped_pages_info +( + vm_map_t task, + page_address_array_t *pages, + mach_msg_type_number_t *pagesCnt +); + +/* Routine vm_region_recurse */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t vm_region_recurse +( + vm_map_t target_task, + vm_address_t *address, + vm_size_t *size, + natural_t *nesting_depth, + vm_region_recurse_info_t info, + mach_msg_type_number_t *infoCnt +); + +/* Routine vm_region_recurse_64 */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t vm_region_recurse_64 +( + vm_map_t target_task, + vm_address_t *address, + vm_size_t *size, + natural_t *nesting_depth, + vm_region_recurse_info_t info, + mach_msg_type_number_t *infoCnt +); + +/* Routine mach_vm_region_info_64 */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_vm_region_info_64 +( + vm_map_t task, + vm_address_t address, + vm_info_region_64_t *region, + vm_info_object_array_t *objects, + mach_msg_type_number_t *objectsCnt +); + +/* Routine vm_region_64 */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t vm_region_64 +( + vm_map_t target_task, + vm_address_t *address, + vm_size_t *size, + vm_region_flavor_t flavor, + vm_region_info_t info, + mach_msg_type_number_t *infoCnt, + mach_port_t *object_name +); + +/* Routine mach_make_memory_entry_64 */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_make_memory_entry_64 +( + vm_map_t target_task, + memory_object_size_t *size, + memory_object_offset_t offset, + vm_prot_t permission, + mach_port_t *object_handle, + mem_entry_name_port_t parent_entry +); + +/* Routine vm_map_64 */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t vm_map_64 +( + vm_map_t target_task, + vm_address_t *address, + vm_size_t size, + vm_address_t mask, + int flags, + mem_entry_name_port_t object, + memory_object_offset_t offset, + boolean_t copy, + vm_prot_t cur_protection, + vm_prot_t max_protection, + vm_inherit_t inheritance +); + +/* Routine vm_purgable_control */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t vm_purgable_control +( + vm_map_t target_task, + vm_address_t address, + vm_purgable_t control, + int *state +); + +__END_DECLS + +/********************** Caution **************************/ +/* The following data types should be used to calculate */ +/* maximum message sizes only. The actual message may be */ +/* smaller, and the position of the arguments within the */ +/* message layout may vary from what is presented here. */ +/* For example, if any of the arguments are variable- */ +/* sized, and less than the maximum is sent, the data */ +/* will be packed tight in the actual message to reduce */ +/* the presence of holes. */ +/********************** Caution **************************/ + +/* typedefs for all requests */ + +#ifndef __Request__vm_map_subsystem__defined +#define __Request__vm_map_subsystem__defined + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + vm_address_t address; + vm_region_flavor_t flavor; + mach_msg_type_number_t infoCnt; + } __Request__vm_region_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + vm_address_t address; + vm_size_t size; + int flags; + } __Request__vm_allocate_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + vm_address_t address; + vm_size_t size; + } __Request__vm_deallocate_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + vm_address_t address; + vm_size_t size; + boolean_t set_maximum; + vm_prot_t new_protection; + } __Request__vm_protect_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + vm_address_t address; + vm_size_t size; + vm_inherit_t new_inheritance; + } __Request__vm_inherit_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + vm_address_t address; + vm_size_t size; + } __Request__vm_read_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + vm_read_entry_t data_list; + natural_t count; + } __Request__vm_read_list_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_descriptor_t data; + /* end of the kernel processed data */ + NDR_record_t NDR; + vm_address_t address; + mach_msg_type_number_t dataCnt; + } __Request__vm_write_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + vm_address_t source_address; + vm_size_t size; + vm_address_t dest_address; + } __Request__vm_copy_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + vm_address_t address; + vm_size_t size; + vm_address_t data; + } __Request__vm_read_overwrite_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + vm_address_t address; + vm_size_t size; + vm_sync_t sync_flags; + } __Request__vm_msync_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + vm_address_t address; + vm_size_t size; + vm_behavior_t new_behavior; + } __Request__vm_behavior_set_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t object; + /* end of the kernel processed data */ + NDR_record_t NDR; + vm_address_t address; + vm_size_t size; + vm_address_t mask; + int flags; + vm_offset_t offset; + boolean_t copy; + vm_prot_t cur_protection; + vm_prot_t max_protection; + vm_inherit_t inheritance; + } __Request__vm_map_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + vm_address_t address; + vm_size_t size; + vm_machine_attribute_t attribute; + vm_machine_attribute_val_t value; + } __Request__vm_machine_attribute_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t src_task; + /* end of the kernel processed data */ + NDR_record_t NDR; + vm_address_t target_address; + vm_size_t size; + vm_address_t mask; + boolean_t anywhere; + vm_address_t src_address; + boolean_t copy; + vm_inherit_t inheritance; + } __Request__vm_remap_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + boolean_t must_wire; + } __Request__task_wire_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t parent_entry; + /* end of the kernel processed data */ + NDR_record_t NDR; + vm_size_t size; + vm_offset_t offset; + vm_prot_t permission; + } __Request__mach_make_memory_entry_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + vm_offset_t offset; + } __Request__vm_map_page_query_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + vm_address_t address; + } __Request__mach_vm_region_info_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__vm_mapped_pages_info_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + vm_address_t address; + natural_t nesting_depth; + mach_msg_type_number_t infoCnt; + } __Request__vm_region_recurse_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + vm_address_t address; + natural_t nesting_depth; + mach_msg_type_number_t infoCnt; + } __Request__vm_region_recurse_64_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + vm_address_t address; + } __Request__mach_vm_region_info_64_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + vm_address_t address; + vm_region_flavor_t flavor; + mach_msg_type_number_t infoCnt; + } __Request__vm_region_64_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t parent_entry; + /* end of the kernel processed data */ + NDR_record_t NDR; + memory_object_size_t size; + memory_object_offset_t offset; + vm_prot_t permission; + } __Request__mach_make_memory_entry_64_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t object; + /* end of the kernel processed data */ + NDR_record_t NDR; + vm_address_t address; + vm_size_t size; + vm_address_t mask; + int flags; + memory_object_offset_t offset; + boolean_t copy; + vm_prot_t cur_protection; + vm_prot_t max_protection; + vm_inherit_t inheritance; + } __Request__vm_map_64_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + vm_address_t address; + vm_purgable_t control; + int state; + } __Request__vm_purgable_control_t; +#ifdef __MigPackStructs +#pragma pack() +#endif +#endif /* !__Request__vm_map_subsystem__defined */ + +/* union of all requests */ + +#ifndef __RequestUnion__vm_map_subsystem__defined +#define __RequestUnion__vm_map_subsystem__defined +union __RequestUnion__vm_map_subsystem { + __Request__vm_region_t Request_vm_region; + __Request__vm_allocate_t Request_vm_allocate; + __Request__vm_deallocate_t Request_vm_deallocate; + __Request__vm_protect_t Request_vm_protect; + __Request__vm_inherit_t Request_vm_inherit; + __Request__vm_read_t Request_vm_read; + __Request__vm_read_list_t Request_vm_read_list; + __Request__vm_write_t Request_vm_write; + __Request__vm_copy_t Request_vm_copy; + __Request__vm_read_overwrite_t Request_vm_read_overwrite; + __Request__vm_msync_t Request_vm_msync; + __Request__vm_behavior_set_t Request_vm_behavior_set; + __Request__vm_map_t Request_vm_map; + __Request__vm_machine_attribute_t Request_vm_machine_attribute; + __Request__vm_remap_t Request_vm_remap; + __Request__task_wire_t Request_task_wire; + __Request__mach_make_memory_entry_t Request_mach_make_memory_entry; + __Request__vm_map_page_query_t Request_vm_map_page_query; + __Request__mach_vm_region_info_t Request_mach_vm_region_info; + __Request__vm_mapped_pages_info_t Request_vm_mapped_pages_info; + __Request__vm_region_recurse_t Request_vm_region_recurse; + __Request__vm_region_recurse_64_t Request_vm_region_recurse_64; + __Request__mach_vm_region_info_64_t Request_mach_vm_region_info_64; + __Request__vm_region_64_t Request_vm_region_64; + __Request__mach_make_memory_entry_64_t Request_mach_make_memory_entry_64; + __Request__vm_map_64_t Request_vm_map_64; + __Request__vm_purgable_control_t Request_vm_purgable_control; +}; +#endif /* !__RequestUnion__vm_map_subsystem__defined */ +/* typedefs for all replies */ + +#ifndef __Reply__vm_map_subsystem__defined +#define __Reply__vm_map_subsystem__defined + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t object_name; + /* end of the kernel processed data */ + NDR_record_t NDR; + vm_address_t address; + vm_size_t size; + mach_msg_type_number_t infoCnt; + int info[10]; + } __Reply__vm_region_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + vm_address_t address; + } __Reply__vm_allocate_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__vm_deallocate_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__vm_protect_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__vm_inherit_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_descriptor_t data; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t dataCnt; + } __Reply__vm_read_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + vm_read_entry_t data_list; + } __Reply__vm_read_list_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__vm_write_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__vm_copy_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + vm_size_t outsize; + } __Reply__vm_read_overwrite_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__vm_msync_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__vm_behavior_set_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + vm_address_t address; + } __Reply__vm_map_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + vm_machine_attribute_val_t value; + } __Reply__vm_machine_attribute_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + vm_address_t target_address; + vm_prot_t cur_protection; + vm_prot_t max_protection; + } __Reply__vm_remap_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_wire_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t object_handle; + /* end of the kernel processed data */ + NDR_record_t NDR; + vm_size_t size; + } __Reply__mach_make_memory_entry_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + integer_t disposition; + integer_t ref_count; + } __Reply__vm_map_page_query_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_descriptor_t objects; + /* end of the kernel processed data */ + NDR_record_t NDR; + vm_info_region_t region; + mach_msg_type_number_t objectsCnt; + } __Reply__mach_vm_region_info_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_descriptor_t pages; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t pagesCnt; + } __Reply__vm_mapped_pages_info_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + vm_address_t address; + vm_size_t size; + natural_t nesting_depth; + mach_msg_type_number_t infoCnt; + int info[19]; + } __Reply__vm_region_recurse_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + vm_address_t address; + vm_size_t size; + natural_t nesting_depth; + mach_msg_type_number_t infoCnt; + int info[19]; + } __Reply__vm_region_recurse_64_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_descriptor_t objects; + /* end of the kernel processed data */ + NDR_record_t NDR; + vm_info_region_64_t region; + mach_msg_type_number_t objectsCnt; + } __Reply__mach_vm_region_info_64_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t object_name; + /* end of the kernel processed data */ + NDR_record_t NDR; + vm_address_t address; + vm_size_t size; + mach_msg_type_number_t infoCnt; + int info[10]; + } __Reply__vm_region_64_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t object_handle; + /* end of the kernel processed data */ + NDR_record_t NDR; + memory_object_size_t size; + } __Reply__mach_make_memory_entry_64_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + vm_address_t address; + } __Reply__vm_map_64_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + int state; + } __Reply__vm_purgable_control_t; +#ifdef __MigPackStructs +#pragma pack() +#endif +#endif /* !__Reply__vm_map_subsystem__defined */ + +/* union of all replies */ + +#ifndef __ReplyUnion__vm_map_subsystem__defined +#define __ReplyUnion__vm_map_subsystem__defined +union __ReplyUnion__vm_map_subsystem { + __Reply__vm_region_t Reply_vm_region; + __Reply__vm_allocate_t Reply_vm_allocate; + __Reply__vm_deallocate_t Reply_vm_deallocate; + __Reply__vm_protect_t Reply_vm_protect; + __Reply__vm_inherit_t Reply_vm_inherit; + __Reply__vm_read_t Reply_vm_read; + __Reply__vm_read_list_t Reply_vm_read_list; + __Reply__vm_write_t Reply_vm_write; + __Reply__vm_copy_t Reply_vm_copy; + __Reply__vm_read_overwrite_t Reply_vm_read_overwrite; + __Reply__vm_msync_t Reply_vm_msync; + __Reply__vm_behavior_set_t Reply_vm_behavior_set; + __Reply__vm_map_t Reply_vm_map; + __Reply__vm_machine_attribute_t Reply_vm_machine_attribute; + __Reply__vm_remap_t Reply_vm_remap; + __Reply__task_wire_t Reply_task_wire; + __Reply__mach_make_memory_entry_t Reply_mach_make_memory_entry; + __Reply__vm_map_page_query_t Reply_vm_map_page_query; + __Reply__mach_vm_region_info_t Reply_mach_vm_region_info; + __Reply__vm_mapped_pages_info_t Reply_vm_mapped_pages_info; + __Reply__vm_region_recurse_t Reply_vm_region_recurse; + __Reply__vm_region_recurse_64_t Reply_vm_region_recurse_64; + __Reply__mach_vm_region_info_64_t Reply_mach_vm_region_info_64; + __Reply__vm_region_64_t Reply_vm_region_64; + __Reply__mach_make_memory_entry_64_t Reply_mach_make_memory_entry_64; + __Reply__vm_map_64_t Reply_vm_map_64; + __Reply__vm_purgable_control_t Reply_vm_purgable_control; +}; +#endif /* !__RequestUnion__vm_map_subsystem__defined */ + +#ifndef subsystem_to_name_map_vm_map +#define subsystem_to_name_map_vm_map \ + { "vm_region", 3800 },\ + { "vm_allocate", 3801 },\ + { "vm_deallocate", 3802 },\ + { "vm_protect", 3803 },\ + { "vm_inherit", 3804 },\ + { "vm_read", 3805 },\ + { "vm_read_list", 3806 },\ + { "vm_write", 3807 },\ + { "vm_copy", 3808 },\ + { "vm_read_overwrite", 3809 },\ + { "vm_msync", 3810 },\ + { "vm_behavior_set", 3811 },\ + { "vm_map", 3812 },\ + { "vm_machine_attribute", 3813 },\ + { "vm_remap", 3814 },\ + { "task_wire", 3815 },\ + { "mach_make_memory_entry", 3816 },\ + { "vm_map_page_query", 3817 },\ + { "mach_vm_region_info", 3818 },\ + { "vm_mapped_pages_info", 3819 },\ + { "vm_region_recurse", 3821 },\ + { "vm_region_recurse_64", 3822 },\ + { "mach_vm_region_info_64", 3823 },\ + { "vm_region_64", 3824 },\ + { "mach_make_memory_entry_64", 3825 },\ + { "vm_map_64", 3826 },\ + { "vm_purgable_control", 3830 } +#endif + +#ifdef __AfterMigUserHeader +__AfterMigUserHeader +#endif /* __AfterMigUserHeader */ + +#endif /* _vm_map_user_ */ Index: branches/azimutz/Cleancut/i386/include/mach/task_policy.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/task_policy.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/task_policy.h (revision 885) @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2000-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 _MACH_TASK_POLICY_H_ +#define _MACH_TASK_POLICY_H_ + +#include <mach/mach_types.h> + +/* + * These are the calls for accessing the policy parameters + * of a particular task. + * + * The extra 'get_default' parameter to the second call is + * IN/OUT as follows: + * 1) if asserted on the way in it indicates that the default + * values should be returned, not the ones currently set, in + * this case 'get_default' will always be asserted on return; + * 2) if unasserted on the way in, the current settings are + * desired and if still unasserted on return, then the info + * returned reflects the current settings, otherwise if + * 'get_default' returns asserted, it means that there are no + * current settings due to other parameters taking precedence, + * and the default ones are being returned instead. + */ + +typedef natural_t task_policy_flavor_t; +typedef integer_t *task_policy_t; + +/* +kern_return_t task_policy_set( + task_t task, + task_policy_flavor_t flavor, + task_policy_t policy_info, + mach_msg_type_number_t count); + +kern_return_t task_policy_get( + task_t task, + task_policy_flavor_t flavor, + task_policy_t policy_info, + mach_msg_type_number_t *count, + boolean_t *get_default); +*/ + +/* + * Defined flavors. + */ +/* + * TASK_CATEGORY_POLICY: + * + * This provides information to the kernel about the role + * of the task in the system. + * + * Parameters: + * + * role: Enumerated as follows: + * + * TASK_UNSPECIFIED is the default, since the role is not + * inherited from the parent. + * + * TASK_FOREGROUND_APPLICATION should be assigned when the + * task is a normal UI application in the foreground from + * the HI point of view. + * **N.B. There may be more than one of these at a given time. + * + * TASK_BACKGROUND_APPLICATION should be assigned when the + * task is a normal UI application in the background from + * the HI point of view. + * + * TASK_CONTROL_APPLICATION should be assigned to the unique + * UI application which implements the pop-up application dialog. + * There can only be one task at a time with this designation, + * which is assigned FCFS. + * + * TASK_GRAPHICS_SERVER should be assigned to the graphics + * management (window) server. There can only be one task at + * a time with this designation, which is assigned FCFS. + */ + +#define TASK_CATEGORY_POLICY 1 + +enum task_role { + TASK_RENICED = -1, + TASK_UNSPECIFIED = 0, + TASK_FOREGROUND_APPLICATION, + TASK_BACKGROUND_APPLICATION, + TASK_CONTROL_APPLICATION, + TASK_GRAPHICS_SERVER, + TASK_THROTTLE_APPLICATION, + TASK_DEFAULT_APPLICATION +}; + +typedef enum task_role task_role_t; + +struct task_category_policy { + task_role_t role; +}; + +typedef struct task_category_policy task_category_policy_data_t; +typedef struct task_category_policy *task_category_policy_t; + +#define TASK_CATEGORY_POLICY_COUNT ((mach_msg_type_number_t) \ + (sizeof (task_category_policy_data_t) / sizeof (integer_t))) + +#endif /* _MACH_TASK_POLICY_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/mach_traps.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/mach_traps.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/mach_traps.h (revision 885) @@ -0,0 +1,152 @@ +/* + * Copyright (c) 2000-2007 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@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989,1988,1987 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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + */ +/* + * Definitions of general Mach system traps. + * + * These are the definitions as seen from user-space. + * The kernel definitions are in <mach/syscall_sw.h>. + * Kernel RPC functions are defined in <mach/mach_interface.h>. + */ + +#ifndef _MACH_MACH_TRAPS_H_ +#define _MACH_MACH_TRAPS_H_ + +#include <stdint.h> + +#include <mach/std_types.h> +#include <mach/mach_types.h> +#include <mach/kern_return.h> +#include <mach/port.h> +#include <mach/vm_types.h> +#include <mach/clock_types.h> + +#include <machine/endian.h> + +#include <sys/cdefs.h> + +__BEGIN_DECLS + + + +extern kern_return_t macx_swapon( + uint64_t filename, + int flags, + int size, + int priority); + +extern kern_return_t macx_swapoff( + uint64_t filename, + int flags); + +extern kern_return_t macx_triggers( + int hi_water, + int low_water, + int flags, + mach_port_t alert_port); + +extern kern_return_t macx_backing_store_suspend( + boolean_t suspend); + +extern kern_return_t macx_backing_store_recovery( + int pid); + +extern boolean_t swtch_pri(int pri); + +extern boolean_t swtch(void); + +extern kern_return_t thread_switch( + mach_port_name_t thread_name, + int option, + mach_msg_timeout_t option_time); + +extern mach_port_name_t task_self_trap(void); + +/* + * Obsolete interfaces. + */ + +extern kern_return_t task_for_pid( + mach_port_name_t target_tport, + int pid, + mach_port_name_t *t); + +extern kern_return_t task_name_for_pid( + mach_port_name_t target_tport, + int pid, + mach_port_name_t *tn); + +extern kern_return_t pid_for_task( + mach_port_name_t t, + int *x); + +#if !defined(__LP64__) +/* these should go away altogether - so no 64 legacy please */ + +extern kern_return_t map_fd( + int fd, + vm_offset_t offset, + vm_offset_t *va, + boolean_t findspace, + vm_size_t size); + +#endif /* !defined(__LP64__) */ + + +__END_DECLS + +#endif /* _MACH_MACH_TRAPS_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/exception_types.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/exception_types.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/exception_types.h (revision 885) @@ -0,0 +1,181 @@ +/* + * Copyright (c) 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@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989,1988,1987 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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + */ + +#ifndef _MACH_EXCEPTION_TYPES_H_ +#define _MACH_EXCEPTION_TYPES_H_ + +#include <mach/machine/exception.h> + +/* + * Machine-independent exception definitions. + */ + +#define EXC_BAD_ACCESS 1 /* Could not access memory */ + /* Code contains kern_return_t describing error. */ + /* Subcode contains bad memory address. */ + +#define EXC_BAD_INSTRUCTION 2 /* Instruction failed */ + /* Illegal or undefined instruction or operand */ + +#define EXC_ARITHMETIC 3 /* Arithmetic exception */ + /* Exact nature of exception is in code field */ + +#define EXC_EMULATION 4 /* Emulation instruction */ + /* Emulation support instruction encountered */ + /* Details in code and subcode fields */ + +#define EXC_SOFTWARE 5 /* Software generated exception */ + /* Exact exception is in code field. */ + /* Codes 0 - 0xFFFF reserved to hardware */ + /* Codes 0x10000 - 0x1FFFF reserved for OS emulation (Unix) */ + +#define EXC_BREAKPOINT 6 /* Trace, breakpoint, etc. */ + /* Details in code field. */ + +#define EXC_SYSCALL 7 /* System calls. */ + +#define EXC_MACH_SYSCALL 8 /* Mach system calls. */ + +#define EXC_RPC_ALERT 9 /* RPC alert */ + +#define EXC_CRASH 10 /* Abnormal process exit */ + +/* + * Machine-independent exception behaviors + */ + +# define EXCEPTION_DEFAULT 1 +/* Send a catch_exception_raise message including the identity. + */ + +# define EXCEPTION_STATE 2 +/* Send a catch_exception_raise_state message including the + * thread state. + */ + +# define EXCEPTION_STATE_IDENTITY 3 +/* Send a catch_exception_raise_state_identity message including + * the thread identity and state. + */ + +#define MACH_EXCEPTION_CODES 0x80000000 +/* Send 64-bit code and subcode in the exception header */ + +/* + * Masks for exception definitions, above + * bit zero is unused, therefore 1 word = 31 exception types + */ + +#define EXC_MASK_BAD_ACCESS (1 << EXC_BAD_ACCESS) +#define EXC_MASK_BAD_INSTRUCTION (1 << EXC_BAD_INSTRUCTION) +#define EXC_MASK_ARITHMETIC (1 << EXC_ARITHMETIC) +#define EXC_MASK_EMULATION (1 << EXC_EMULATION) +#define EXC_MASK_SOFTWARE (1 << EXC_SOFTWARE) +#define EXC_MASK_BREAKPOINT (1 << EXC_BREAKPOINT) +#define EXC_MASK_SYSCALL (1 << EXC_SYSCALL) +#define EXC_MASK_MACH_SYSCALL (1 << EXC_MACH_SYSCALL) +#define EXC_MASK_RPC_ALERT (1 << EXC_RPC_ALERT) +#define EXC_MASK_CRASH (1 << EXC_CRASH) + +#define EXC_MASK_ALL (EXC_MASK_BAD_ACCESS | \ + EXC_MASK_BAD_INSTRUCTION | \ + EXC_MASK_ARITHMETIC | \ + EXC_MASK_EMULATION | \ + EXC_MASK_SOFTWARE | \ + EXC_MASK_BREAKPOINT | \ + EXC_MASK_SYSCALL | \ + EXC_MASK_MACH_SYSCALL | \ + EXC_MASK_RPC_ALERT | \ + EXC_MASK_MACHINE) + + +#define FIRST_EXCEPTION 1 /* ZERO is illegal */ + +/* + * Machine independent codes for EXC_SOFTWARE + * Codes 0x10000 - 0x1FFFF reserved for OS emulation (Unix) + * 0x10000 - 0x10002 in use for unix signals + */ +#define EXC_SOFT_SIGNAL 0x10003 /* Unix signal exceptions */ + +#ifndef ASSEMBLER + +#include <mach/port.h> +#include <mach/thread_status.h> +#include <mach/machine/vm_types.h> +/* + * Exported types + */ + +typedef int exception_type_t; +typedef integer_t exception_data_type_t; +typedef int64_t mach_exception_data_type_t; +typedef int exception_behavior_t; +typedef exception_data_type_t *exception_data_t; +typedef mach_exception_data_type_t *mach_exception_data_t; +typedef unsigned int exception_mask_t; +typedef exception_mask_t *exception_mask_array_t; +typedef exception_behavior_t *exception_behavior_array_t; +typedef thread_state_flavor_t *exception_flavor_array_t; +typedef mach_port_t *exception_port_array_t; +typedef mach_exception_data_type_t mach_exception_code_t; +typedef mach_exception_data_type_t mach_exception_subcode_t; + +#endif /* ASSEMBLER */ + +#endif /* _MACH_EXCEPTION_TYPES_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/memory_object_types.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/memory_object_types.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/memory_object_types.h (revision 885) @@ -0,0 +1,271 @@ +/* + * Copyright (c) 2000-2006 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,1988 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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + */ +/* + * File: memory_object.h + * Author: Michael Wayne Young + * + * External memory management interface definition. + */ + +#ifndef _MACH_MEMORY_OBJECT_TYPES_H_ +#define _MACH_MEMORY_OBJECT_TYPES_H_ + +/* + * User-visible types used in the external memory + * management interface: + */ + +#include <mach/port.h> +#include <mach/message.h> +#include <mach/vm_prot.h> +#include <mach/vm_sync.h> +#include <mach/vm_types.h> +#include <mach/machine/vm_types.h> + +#include <sys/cdefs.h> + +#define VM_64_BIT_DATA_OBJECTS + +typedef unsigned long long memory_object_offset_t; +typedef unsigned long long memory_object_size_t; +typedef natural_t memory_object_cluster_size_t; +typedef natural_t * memory_object_fault_info_t; + +typedef unsigned long long vm_object_id_t; + + +/* + * Temporary until real EMMI version gets re-implemented + */ + + +typedef mach_port_t memory_object_t; +typedef mach_port_t memory_object_control_t; + + +typedef memory_object_t *memory_object_array_t; + /* A memory object ... */ + /* Used by the kernel to retrieve */ + /* or store data */ + +typedef mach_port_t memory_object_name_t; + /* Used to describe the memory ... */ + /* object in vm_regions() calls */ + +typedef mach_port_t memory_object_default_t; + /* Registered with the host ... */ + /* for creating new internal objects */ + +#define MEMORY_OBJECT_NULL ((memory_object_t) 0) +#define MEMORY_OBJECT_CONTROL_NULL ((memory_object_control_t) 0) +#define MEMORY_OBJECT_NAME_NULL ((memory_object_name_t) 0) +#define MEMORY_OBJECT_DEFAULT_NULL ((memory_object_default_t) 0) + + +typedef int memory_object_copy_strategy_t; + /* How memory manager handles copy: */ +#define MEMORY_OBJECT_COPY_NONE 0 + /* ... No special support */ +#define MEMORY_OBJECT_COPY_CALL 1 + /* ... Make call on memory manager */ +#define MEMORY_OBJECT_COPY_DELAY 2 + /* ... Memory manager doesn't + * change data externally. + */ +#define MEMORY_OBJECT_COPY_TEMPORARY 3 + /* ... Memory manager doesn't + * change data externally, and + * doesn't need to see changes. + */ +#define MEMORY_OBJECT_COPY_SYMMETRIC 4 + /* ... Memory manager doesn't + * change data externally, + * doesn't need to see changes, + * and object will not be + * multiply mapped. + * + * XXX + * Not yet safe for non-kernel use. + */ + +#define MEMORY_OBJECT_COPY_INVALID 5 + /* ... An invalid copy strategy, + * for external objects which + * have not been initialized. + * Allows copy_strategy to be + * examined without also + * examining pager_ready and + * internal. + */ + +typedef int memory_object_return_t; + /* Which pages to return to manager + this time (lock_request) */ +#define MEMORY_OBJECT_RETURN_NONE 0 + /* ... don't return any. */ +#define MEMORY_OBJECT_RETURN_DIRTY 1 + /* ... only dirty pages. */ +#define MEMORY_OBJECT_RETURN_ALL 2 + /* ... dirty and precious pages. */ +#define MEMORY_OBJECT_RETURN_ANYTHING 3 + /* ... any resident page. */ + +/* + * Data lock request flags + */ + +#define MEMORY_OBJECT_DATA_FLUSH 0x1 +#define MEMORY_OBJECT_DATA_NO_CHANGE 0x2 +#define MEMORY_OBJECT_DATA_PURGE 0x4 +#define MEMORY_OBJECT_COPY_SYNC 0x8 +#define MEMORY_OBJECT_DATA_SYNC 0x10 +#define MEMORY_OBJECT_IO_SYNC 0x20 +#define MEMORY_OBJECT_DATA_FLUSH_ALL 0x40 + +/* + * Types for the memory object flavor interfaces + */ + +#define MEMORY_OBJECT_INFO_MAX (1024) +typedef int *memory_object_info_t; +typedef int memory_object_flavor_t; +typedef int memory_object_info_data_t[MEMORY_OBJECT_INFO_MAX]; + + +#define MEMORY_OBJECT_PERFORMANCE_INFO 11 +#define MEMORY_OBJECT_ATTRIBUTE_INFO 14 +#define MEMORY_OBJECT_BEHAVIOR_INFO 15 + + +struct memory_object_perf_info { + memory_object_cluster_size_t cluster_size; + boolean_t may_cache; +}; + +struct memory_object_attr_info { + memory_object_copy_strategy_t copy_strategy; + memory_object_cluster_size_t cluster_size; + boolean_t may_cache_object; + boolean_t temporary; +}; + +struct memory_object_behave_info { + memory_object_copy_strategy_t copy_strategy; + boolean_t temporary; + boolean_t invalidate; + boolean_t silent_overwrite; + boolean_t advisory_pageout; +}; + + +typedef struct memory_object_behave_info *memory_object_behave_info_t; +typedef struct memory_object_behave_info memory_object_behave_info_data_t; + +typedef struct memory_object_perf_info *memory_object_perf_info_t; +typedef struct memory_object_perf_info memory_object_perf_info_data_t; + +typedef struct memory_object_attr_info *memory_object_attr_info_t; +typedef struct memory_object_attr_info memory_object_attr_info_data_t; + +#define MEMORY_OBJECT_BEHAVE_INFO_COUNT ((mach_msg_type_number_t) \ + (sizeof(memory_object_behave_info_data_t)/sizeof(int))) +#define MEMORY_OBJECT_PERF_INFO_COUNT ((mach_msg_type_number_t) \ + (sizeof(memory_object_perf_info_data_t)/sizeof(int))) +#define MEMORY_OBJECT_ATTR_INFO_COUNT ((mach_msg_type_number_t) \ + (sizeof(memory_object_attr_info_data_t)/sizeof(int))) + +#define invalid_memory_object_flavor(f) \ + (f != MEMORY_OBJECT_ATTRIBUTE_INFO && \ + f != MEMORY_OBJECT_PERFORMANCE_INFO && \ + f != OLD_MEMORY_OBJECT_BEHAVIOR_INFO && \ + f != MEMORY_OBJECT_BEHAVIOR_INFO && \ + f != OLD_MEMORY_OBJECT_ATTRIBUTE_INFO) + + +/* + * Used to support options on memory_object_release_name call + */ +#define MEMORY_OBJECT_TERMINATE_IDLE 0x1 +#define MEMORY_OBJECT_RESPECT_CACHE 0x2 +#define MEMORY_OBJECT_RELEASE_NO_OP 0x4 + + +/* named entry processor mapping options */ +/* enumerated */ +#define MAP_MEM_NOOP 0 +#define MAP_MEM_COPYBACK 1 +#define MAP_MEM_IO 2 +#define MAP_MEM_WTHRU 3 +#define MAP_MEM_WCOMB 4 /* Write combining mode */ + /* aka store gather */ + +#define GET_MAP_MEM(flags) \ + ((((unsigned int)(flags)) >> 24) & 0xFF) + +#define SET_MAP_MEM(caching, flags) \ + ((flags) = ((((unsigned int)(caching)) << 24) \ + & 0xFF000000) | ((flags) & 0xFFFFFF)); + +/* leave room for vm_prot bits */ +#define MAP_MEM_ONLY 0x10000 /* change processor caching */ +#define MAP_MEM_NAMED_CREATE 0x20000 /* create extant object */ +#define MAP_MEM_PURGABLE 0x40000 /* create a purgable VM object */ +#define MAP_MEM_NAMED_REUSE 0x80000 /* reuse provided entry if identical */ + + +#endif /* _MACH_MEMORY_OBJECT_TYPES_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/ndr.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/ndr.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/ndr.h (revision 885) @@ -0,0 +1,207 @@ +/* + * Copyright (c) 2000-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@ + */ +/* + * @OSF_COPYRIGHT@ + */ + +#ifndef _MACH_NDR_H_ +#define _MACH_NDR_H_ + +#include <stdint.h> +#include <sys/cdefs.h> + +typedef struct { + unsigned char mig_vers; + unsigned char if_vers; + unsigned char reserved1; + unsigned char mig_encoding; + unsigned char int_rep; + unsigned char char_rep; + unsigned char float_rep; + unsigned char reserved2; +} NDR_record_t; + +/* + * MIG supported protocols for Network Data Representation + */ +#define NDR_PROTOCOL_2_0 0 + +/* + * NDR 2.0 format flag type definition and values. + */ +#define NDR_INT_BIG_ENDIAN 0 +#define NDR_INT_LITTLE_ENDIAN 1 +#define NDR_FLOAT_IEEE 0 +#define NDR_FLOAT_VAX 1 +#define NDR_FLOAT_CRAY 2 +#define NDR_FLOAT_IBM 3 +#define NDR_CHAR_ASCII 0 +#define NDR_CHAR_EBCDIC 1 + +extern NDR_record_t NDR_record; + +#if defined(BSMALL) +#define __NDR_convert__ 0 +#define __NDR_convert__int_rep__ 0 +#else +#ifndef __NDR_convert__ +#define __NDR_convert__ 1 +#endif /* __NDR_convert__ */ + +#ifndef __NDR_convert__int_rep__ +#define __NDR_convert__int_rep__ 1 +#endif /* __NDR_convert__int_rep__ */ + +#endif /* defined(BSMALL) */ + +#ifndef __NDR_convert__char_rep__ +#define __NDR_convert__char_rep__ 0 +#endif /* __NDR_convert__char_rep__ */ + +#ifndef __NDR_convert__float_rep__ +#define __NDR_convert__float_rep__ 0 +#endif /* __NDR_convert__float_rep__ */ + +#if __NDR_convert__ + +#define __NDR_convert__NOOP do ; while (0) +#define __NDR_convert__UNKNOWN(s) __NDR_convert__NOOP +#define __NDR_convert__SINGLE(a, f, r) do { r((a), (f)); } while (0) +#define __NDR_convert__ARRAY(a, f, c, r) \ + do { int __i__, __C__ = (c); \ + for (__i__ = 0; __i__ < __C__; __i__++) \ + r(&(a)[__i__], f); } while (0) +#define __NDR_convert__2DARRAY(a, f, s, c, r) \ + do { int __i__, __C__ = (c), __S__ = (s); \ + for (__i__ = 0; __i__ < __C__; __i__++) \ + r(&(a)[__i__ * __S__], f, __S__); } while (0) + +#if __NDR_convert__int_rep__ + +#include <libkern/OSByteOrder.h> + +#define __NDR_READSWAP_assign(a, rs) do { *(a) = rs(a); } while (0) + +#define __NDR_READSWAP__uint16_t(a) OSReadSwapInt16((void *)a, 0) +#define __NDR_READSWAP__int16_t(a) (int16_t)OSReadSwapInt16((void *)a, 0) +#define __NDR_READSWAP__uint32_t(a) OSReadSwapInt32((void *)a, 0) +#define __NDR_READSWAP__int32_t(a) (int32_t)OSReadSwapInt32((void *)a, 0) +#define __NDR_READSWAP__uint64_t(a) OSReadSwapInt64((void *)a, 0) +#define __NDR_READSWAP__int64_t(a) (int64_t)OSReadSwapInt64((void *)a, 0) + +__BEGIN_DECLS + +static __inline__ float __NDR_READSWAP__float(float *argp) { + union { + float sv; + uint32_t ull; + } result; + result.ull = __NDR_READSWAP__uint32_t((uint32_t *)argp); + return result.sv; +} + +static __inline__ double __NDR_READSWAP__double(double *argp) { + union { + double sv; + uint64_t ull; + } result; + result.ull = __NDR_READSWAP__uint64_t((uint64_t *)argp); + return result.sv; +} + +__END_DECLS + +#define __NDR_convert__int_rep__int16_t__defined +#define __NDR_convert__int_rep__int16_t(v,f) \ + __NDR_READSWAP_assign(v, __NDR_READSWAP__int16_t) + +#define __NDR_convert__int_rep__uint16_t__defined +#define __NDR_convert__int_rep__uint16_t(v,f) \ + __NDR_READSWAP_assign(v, __NDR_READSWAP__uint16_t) + +#define __NDR_convert__int_rep__int32_t__defined +#define __NDR_convert__int_rep__int32_t(v,f) \ + __NDR_READSWAP_assign(v, __NDR_READSWAP__int32_t) + +#define __NDR_convert__int_rep__uint32_t__defined +#define __NDR_convert__int_rep__uint32_t(v,f) \ + __NDR_READSWAP_assign(v, __NDR_READSWAP__uint32_t) + +#define __NDR_convert__int_rep__int64_t__defined +#define __NDR_convert__int_rep__int64_t(v,f) \ + __NDR_READSWAP_assign(v, __NDR_READSWAP__int64_t) + +#define __NDR_convert__int_rep__uint64_t__defined +#define __NDR_convert__int_rep__uint64_t(v,f) \ + __NDR_READSWAP_assign(v, __NDR_READSWAP__uint64_t) + +#define __NDR_convert__int_rep__float__defined +#define __NDR_convert__int_rep__float(v,f) \ + __NDR_READSWAP_assign(v, __NDR_READSWAP__float) + +#define __NDR_convert__int_rep__double__defined +#define __NDR_convert__int_rep__double(v,f) \ + __NDR_READSWAP_assign(v, __NDR_READSWAP__double) + +#define __NDR_convert__int_rep__boolean_t__defined +#define __NDR_convert__int_rep__boolean_t(v, f) \ + __NDR_convert__int_rep__int32_t(v,f) + +#define __NDR_convert__int_rep__kern_return_t__defined +#define __NDR_convert__int_rep__kern_return_t(v,f) \ + __NDR_convert__int_rep__int32_t(v,f) + +#define __NDR_convert__int_rep__mach_port_name_t__defined +#define __NDR_convert__int_rep__mach_port_name_t(v,f) \ + __NDR_convert__int_rep__uint32_t(v,f) + +#define __NDR_convert__int_rep__mach_msg_type_number_t__defined +#define __NDR_convert__int_rep__mach_msg_type_number_t(v,f) \ + __NDR_convert__int_rep__uint32_t(v,f) + +#endif /* __NDR_convert__int_rep__ */ + +#if __NDR_convert__char_rep__ + +#warning NDR character representation conversions not implemented yet! +#define __NDR_convert__char_rep__char(v,f) __NDR_convert__NOOP +#define __NDR_convert__char_rep__string(v,f,l) __NDR_convert__NOOP + +#endif /* __NDR_convert__char_rep__ */ + +#if __NDR_convert__float_rep__ + +#warning NDR floating point representation conversions not implemented yet! +#define __NDR_convert__float_rep__float(v,f) __NDR_convert__NOOP +#define __NDR_convert__float_rep__double(v,f) __NDR_convert__NOOP + +#endif /* __NDR_convert__float_rep__ */ + +#endif /* __NDR_convert__ */ + +#endif /* _MACH_NDR_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/message.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/message.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/message.h (revision 885) @@ -0,0 +1,783 @@ +/* + * Copyright (c) 2000-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@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989,1988,1987 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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + * NOTICE: This file was modified by McAfee Research in 2004 to introduce + * support for mandatory and extensible security protections. This notice + * is included in support of clause 2.2 (b) of the Apple Public License, + * Version 2.0. + * Copyright (c) 2005 SPARTA, Inc. + */ +/* + */ +/* + * File: mach/message.h + * + * Mach IPC message and primitive function definitions. + */ + +#ifndef _MACH_MESSAGE_H_ +#define _MACH_MESSAGE_H_ + +#include <stdint.h> +#include <mach/port.h> +#include <mach/boolean.h> +#include <mach/kern_return.h> +#include <mach/machine/vm_types.h> + +#include <sys/cdefs.h> + +/* + * The timeout mechanism uses mach_msg_timeout_t values, + * passed by value. The timeout units are milliseconds. + * It is controlled with the MACH_SEND_TIMEOUT + * and MACH_RCV_TIMEOUT options. + */ + +typedef natural_t mach_msg_timeout_t; + +/* + * The value to be used when there is no timeout. + * (No MACH_SEND_TIMEOUT/MACH_RCV_TIMEOUT option.) + */ + +#define MACH_MSG_TIMEOUT_NONE ((mach_msg_timeout_t) 0) + +/* + * The kernel uses MACH_MSGH_BITS_COMPLEX as a hint. If it isn't on, it + * assumes the body of the message doesn't contain port rights or OOL + * data. The field is set in received messages. A user task must + * use caution in interpreting the body of a message if the bit isn't + * on, because the mach_msg_type's in the body might "lie" about the + * contents. If the bit isn't on, but the mach_msg_types + * in the body specify rights or OOL data, the behavior is undefined. + * (Ie, an error may or may not be produced.) + * + * The value of MACH_MSGH_BITS_REMOTE determines the interpretation + * of the msgh_remote_port field. It is handled like a msgt_name. + * + * The value of MACH_MSGH_BITS_LOCAL determines the interpretation + * of the msgh_local_port field. It is handled like a msgt_name. + * + * MACH_MSGH_BITS() combines two MACH_MSG_TYPE_* values, for the remote + * and local fields, into a single value suitable for msgh_bits. + * + * MACH_MSGH_BITS_CIRCULAR should be zero; is is used internally. + * + * The unused bits should be zero and are reserved for the kernel + * or for future interface expansion. + */ + +#define MACH_MSGH_BITS_ZERO 0x00000000 +#define MACH_MSGH_BITS_REMOTE_MASK 0x000000ff +#define MACH_MSGH_BITS_LOCAL_MASK 0x0000ff00 +#define MACH_MSGH_BITS_COMPLEX 0x80000000U +#define MACH_MSGH_BITS_USER 0x8000ffffU + +#define MACH_MSGH_BITS_CIRCULAR 0x40000000 /* internal use only */ +#define MACH_MSGH_BITS_USED 0xc000ffffU + +#define MACH_MSGH_BITS_PORTS_MASK \ + (MACH_MSGH_BITS_REMOTE_MASK|MACH_MSGH_BITS_LOCAL_MASK) + +#define MACH_MSGH_BITS(remote, local) \ + ((remote) | ((local) << 8)) +#define MACH_MSGH_BITS_REMOTE(bits) \ + ((bits) & MACH_MSGH_BITS_REMOTE_MASK) +#define MACH_MSGH_BITS_LOCAL(bits) \ + (((bits) & MACH_MSGH_BITS_LOCAL_MASK) >> 8) +#define MACH_MSGH_BITS_PORTS(bits) \ + ((bits) & MACH_MSGH_BITS_PORTS_MASK) +#define MACH_MSGH_BITS_OTHER(bits) \ + ((bits) &~ MACH_MSGH_BITS_PORTS_MASK) + +/* + * Every message starts with a message header. + * Following the message header, if the message is complex, are a count + * of type descriptors and the type descriptors themselves + * (mach_msg_descriptor_t). The size of the message must be specified in + * bytes, and includes the message header, descriptor count, descriptors, + * and inline data. + * + * The msgh_remote_port field specifies the destination of the message. + * It must specify a valid send or send-once right for a port. + * + * The msgh_local_port field specifies a "reply port". Normally, + * This field carries a send-once right that the receiver will use + * to reply to the message. It may carry the values MACH_PORT_NULL, + * MACH_PORT_DEAD, a send-once right, or a send right. + * + * The msgh_seqno field carries a sequence number associated with the + * received-from port. A port's sequence number is incremented every + * time a message is received from it. In sent messages, the field's + * value is ignored. + * + * The msgh_id field is uninterpreted by the message primitives. + * It normally carries information specifying the format + * or meaning of the message. + */ + +typedef unsigned int mach_msg_bits_t; +typedef natural_t mach_msg_size_t; +typedef integer_t mach_msg_id_t; + + +#define MACH_MSG_SIZE_NULL (mach_msg_size_t *) 0 + +typedef unsigned int mach_msg_type_name_t; + +#define MACH_MSG_TYPE_MOVE_RECEIVE 16 /* Must hold receive rights */ +#define MACH_MSG_TYPE_MOVE_SEND 17 /* Must hold send rights */ +#define MACH_MSG_TYPE_MOVE_SEND_ONCE 18 /* Must hold sendonce rights */ +#define MACH_MSG_TYPE_COPY_SEND 19 /* Must hold send rights */ +#define MACH_MSG_TYPE_MAKE_SEND 20 /* Must hold receive rights */ +#define MACH_MSG_TYPE_MAKE_SEND_ONCE 21 /* Must hold receive rights */ +#define MACH_MSG_TYPE_COPY_RECEIVE 22 /* Must hold receive rights */ + +typedef unsigned int mach_msg_copy_options_t; + +#define MACH_MSG_PHYSICAL_COPY 0 +#define MACH_MSG_VIRTUAL_COPY 1 +#define MACH_MSG_ALLOCATE 2 +#define MACH_MSG_OVERWRITE 3 +#ifdef MACH_KERNEL +#define MACH_MSG_KALLOC_COPY_T 4 +#endif /* MACH_KERNEL */ + +/* + * In a complex mach message, the mach_msg_header_t is followed by + * a descriptor count, then an array of that number of descriptors + * (mach_msg_*_descriptor_t). The type field of mach_msg_type_descriptor_t + * (which any descriptor can be cast to) indicates the flavor of the + * descriptor. + * + * Note that in LP64, the various types of descriptors are no longer all + * the same size as mach_msg_descriptor_t, so the array cannot be indexed + * as expected. + */ + +typedef unsigned int mach_msg_descriptor_type_t; + +#define MACH_MSG_PORT_DESCRIPTOR 0 +#define MACH_MSG_OOL_DESCRIPTOR 1 +#define MACH_MSG_OOL_PORTS_DESCRIPTOR 2 +#define MACH_MSG_OOL_VOLATILE_DESCRIPTOR 3 + +#pragma pack(4) + +typedef struct +{ + natural_t pad1; + mach_msg_size_t pad2; + unsigned int pad3 : 24; + mach_msg_descriptor_type_t type : 8; +} mach_msg_type_descriptor_t; + +typedef struct +{ + mach_port_t name; +#if !(defined(KERNEL) && defined(__LP64__)) +// Pad to 8 bytes everywhere except the K64 kernel where mach_port_t is 8 bytes + mach_msg_size_t pad1; +#endif + unsigned int pad2 : 16; + mach_msg_type_name_t disposition : 8; + mach_msg_descriptor_type_t type : 8; +} mach_msg_port_descriptor_t; + +typedef struct +{ + uint32_t address; + mach_msg_size_t size; + boolean_t deallocate: 8; + mach_msg_copy_options_t copy: 8; + unsigned int pad1: 8; + mach_msg_descriptor_type_t type: 8; +} mach_msg_ool_descriptor32_t; + +typedef struct +{ + uint64_t address; + boolean_t deallocate: 8; + mach_msg_copy_options_t copy: 8; + unsigned int pad1: 8; + mach_msg_descriptor_type_t type: 8; + mach_msg_size_t size; +} mach_msg_ool_descriptor64_t; + +typedef struct +{ + void* address; +#if !defined(__LP64__) + mach_msg_size_t size; +#endif + boolean_t deallocate: 8; + mach_msg_copy_options_t copy: 8; + unsigned int pad1: 8; + mach_msg_descriptor_type_t type: 8; +#if defined(__LP64__) + mach_msg_size_t size; +#endif +#if defined(KERNEL) && !defined(__LP64__) + uint32_t pad_end; +#endif +} mach_msg_ool_descriptor_t; + +typedef struct +{ + uint32_t address; + mach_msg_size_t count; + boolean_t deallocate: 8; + mach_msg_copy_options_t copy: 8; + mach_msg_type_name_t disposition : 8; + mach_msg_descriptor_type_t type : 8; +} mach_msg_ool_ports_descriptor32_t; + +typedef struct +{ + uint64_t address; + boolean_t deallocate: 8; + mach_msg_copy_options_t copy: 8; + mach_msg_type_name_t disposition : 8; + mach_msg_descriptor_type_t type : 8; + mach_msg_size_t count; +} mach_msg_ool_ports_descriptor64_t; + +typedef struct +{ + void* address; +#if !defined(__LP64__) + mach_msg_size_t count; +#endif + boolean_t deallocate: 8; + mach_msg_copy_options_t copy: 8; + mach_msg_type_name_t disposition : 8; + mach_msg_descriptor_type_t type : 8; +#if defined(__LP64__) + mach_msg_size_t count; +#endif +#if defined(KERNEL) && !defined(__LP64__) + uint32_t pad_end; +#endif +} mach_msg_ool_ports_descriptor_t; + +/* + * LP64support - This union definition is not really + * appropriate in LP64 mode because not all descriptors + * are of the same size in that environment. + */ +#if defined(__LP64__) && defined(KERNEL) +typedef union +{ + mach_msg_port_descriptor_t port; + mach_msg_ool_descriptor32_t out_of_line; + mach_msg_ool_ports_descriptor32_t ool_ports; + mach_msg_type_descriptor_t type; +} mach_msg_descriptor_t; +#else +typedef union +{ + mach_msg_port_descriptor_t port; + mach_msg_ool_descriptor_t out_of_line; + mach_msg_ool_ports_descriptor_t ool_ports; + mach_msg_type_descriptor_t type; +} mach_msg_descriptor_t; +#endif + +typedef struct +{ + mach_msg_size_t msgh_descriptor_count; +} mach_msg_body_t; + +#define MACH_MSG_BODY_NULL (mach_msg_body_t *) 0 +#define MACH_MSG_DESCRIPTOR_NULL (mach_msg_descriptor_t *) 0 + +typedef struct +{ + mach_msg_bits_t msgh_bits; + mach_msg_size_t msgh_size; + mach_port_t msgh_remote_port; + mach_port_t msgh_local_port; + mach_msg_size_t msgh_reserved; + mach_msg_id_t msgh_id; +} mach_msg_header_t; + +#define MACH_MSG_NULL (mach_msg_header_t *) 0 + +typedef struct +{ + mach_msg_header_t header; + mach_msg_body_t body; +} mach_msg_base_t; + +typedef unsigned int mach_msg_trailer_type_t; + +#define MACH_MSG_TRAILER_FORMAT_0 0 + +typedef unsigned int mach_msg_trailer_size_t; + +typedef struct +{ + mach_msg_trailer_type_t msgh_trailer_type; + mach_msg_trailer_size_t msgh_trailer_size; +} mach_msg_trailer_t; + +typedef struct +{ + mach_msg_trailer_type_t msgh_trailer_type; + mach_msg_trailer_size_t msgh_trailer_size; + mach_port_seqno_t msgh_seqno; +} mach_msg_seqno_trailer_t; + +typedef struct +{ + unsigned int val[2]; +} security_token_t; + +typedef struct +{ + mach_msg_trailer_type_t msgh_trailer_type; + mach_msg_trailer_size_t msgh_trailer_size; + mach_port_seqno_t msgh_seqno; + security_token_t msgh_sender; +} mach_msg_security_trailer_t; + +/* + * The audit token is an opaque token which identifies + * Mach tasks and senders of Mach messages as subjects + * to the BSM audit system. Only the appropriate BSM + * library routines should be used to interpret the + * contents of the audit token as the representation + * of the subject identity within the token may change + * over time. + */ +typedef struct +{ + unsigned int val[8]; +} audit_token_t; + +typedef struct +{ + mach_msg_trailer_type_t msgh_trailer_type; + mach_msg_trailer_size_t msgh_trailer_size; + mach_port_seqno_t msgh_seqno; + security_token_t msgh_sender; + audit_token_t msgh_audit; +} mach_msg_audit_trailer_t; + +typedef struct +{ + mach_msg_trailer_type_t msgh_trailer_type; + mach_msg_trailer_size_t msgh_trailer_size; + mach_port_seqno_t msgh_seqno; + security_token_t msgh_sender; + audit_token_t msgh_audit; + mach_vm_address_t msgh_context; +} mach_msg_context_trailer_t; + + +typedef struct +{ + mach_port_name_t sender; +} msg_labels_t; + +/* + Trailer type to pass MAC policy label info as a mach message trailer. + +*/ + +typedef struct +{ + mach_msg_trailer_type_t msgh_trailer_type; + mach_msg_trailer_size_t msgh_trailer_size; + mach_port_seqno_t msgh_seqno; + security_token_t msgh_sender; + audit_token_t msgh_audit; + mach_vm_address_t msgh_context; + int msgh_ad; + msg_labels_t msgh_labels; +} mach_msg_mac_trailer_t; + +#define MACH_MSG_TRAILER_MINIMUM_SIZE sizeof(mach_msg_trailer_t) + +/* + * These values can change from release to release - but clearly + * code cannot request additional trailer elements one was not + * compiled to understand. Therefore, it is safe to use this + * constant when the same module specified the receive options. + * Otherwise, you run the risk that the options requested by + * another module may exceed the local modules notion of + * MAX_TRAILER_SIZE. + */ +typedef mach_msg_mac_trailer_t mach_msg_max_trailer_t; +#define MAX_TRAILER_SIZE ((mach_msg_size_t)sizeof(mach_msg_max_trailer_t)) + +/* + * Legacy requirements keep us from ever updating these defines (even + * when the format_0 trailers gain new option data fields in the future). + * Therefore, they shouldn't be used going forward. Instead, the sizes + * should be compared against the specific element size requested using + * REQUESTED_TRAILER_SIZE. + */ +typedef mach_msg_security_trailer_t mach_msg_format_0_trailer_t; + +/*typedef mach_msg_mac_trailer_t mach_msg_format_0_trailer_t; +*/ + +#define MACH_MSG_TRAILER_FORMAT_0_SIZE sizeof(mach_msg_format_0_trailer_t) + +#define KERNEL_SECURITY_TOKEN_VALUE { {0, 1} } +extern security_token_t KERNEL_SECURITY_TOKEN; + +#define KERNEL_AUDIT_TOKEN_VALUE { {0, 0, 0, 0, 0, 0, 0, 0} } +extern audit_token_t KERNEL_AUDIT_TOKEN; + +typedef integer_t mach_msg_options_t; + +typedef struct +{ + mach_msg_header_t header; +} mach_msg_empty_send_t; + +typedef struct +{ + mach_msg_header_t header; + mach_msg_trailer_t trailer; +} mach_msg_empty_rcv_t; + +typedef union +{ + mach_msg_empty_send_t send; + mach_msg_empty_rcv_t rcv; +} mach_msg_empty_t; + +#pragma pack() + +/* utility to round the message size - will become machine dependent */ +#define round_msg(x) (((mach_msg_size_t)(x) + sizeof (natural_t) - 1) & \ + ~(sizeof (natural_t) - 1)) + +/* + * There is no fixed upper bound to the size of Mach messages. + */ + +#define MACH_MSG_SIZE_MAX ((mach_msg_size_t) ~0) + +/* + * Compatibility definitions, for code written + * when there was a msgh_kind instead of msgh_seqno. + */ +#define MACH_MSGH_KIND_NORMAL 0x00000000 +#define MACH_MSGH_KIND_NOTIFICATION 0x00000001 +#define msgh_kind msgh_seqno +#define mach_msg_kind_t mach_port_seqno_t + +typedef natural_t mach_msg_type_size_t; +typedef natural_t mach_msg_type_number_t; + +/* + * Values received/carried in messages. Tells the receiver what + * sort of port right he now has. + * + * MACH_MSG_TYPE_PORT_NAME is used to transfer a port name + * which should remain uninterpreted by the kernel. (Port rights + * are not transferred, just the port name.) + */ + +#define MACH_MSG_TYPE_PORT_NONE 0 + +#define MACH_MSG_TYPE_PORT_NAME 15 +#define MACH_MSG_TYPE_PORT_RECEIVE MACH_MSG_TYPE_MOVE_RECEIVE +#define MACH_MSG_TYPE_PORT_SEND MACH_MSG_TYPE_MOVE_SEND +#define MACH_MSG_TYPE_PORT_SEND_ONCE MACH_MSG_TYPE_MOVE_SEND_ONCE + +#define MACH_MSG_TYPE_LAST 22 /* Last assigned */ + +/* + * A dummy value. Mostly used to indicate that the actual value + * will be filled in later, dynamically. + */ + +#define MACH_MSG_TYPE_POLYMORPHIC ((mach_msg_type_name_t) -1) + +/* + * Is a given item a port type? + */ + +#define MACH_MSG_TYPE_PORT_ANY(x) \ + (((x) >= MACH_MSG_TYPE_MOVE_RECEIVE) && \ + ((x) <= MACH_MSG_TYPE_MAKE_SEND_ONCE)) + +#define MACH_MSG_TYPE_PORT_ANY_SEND(x) \ + (((x) >= MACH_MSG_TYPE_MOVE_SEND) && \ + ((x) <= MACH_MSG_TYPE_MAKE_SEND_ONCE)) + +#define MACH_MSG_TYPE_PORT_ANY_RIGHT(x) \ + (((x) >= MACH_MSG_TYPE_MOVE_RECEIVE) && \ + ((x) <= MACH_MSG_TYPE_MOVE_SEND_ONCE)) + +typedef integer_t mach_msg_option_t; + +#define MACH_MSG_OPTION_NONE 0x00000000 + +#define MACH_SEND_MSG 0x00000001 +#define MACH_RCV_MSG 0x00000002 +#define MACH_RCV_LARGE 0x00000004 + +#define MACH_SEND_TIMEOUT 0x00000010 +#define MACH_SEND_INTERRUPT 0x00000040 /* libmach implements */ +#define MACH_SEND_CANCEL 0x00000080 +#define MACH_SEND_ALWAYS 0x00010000 /* internal use only */ +#define MACH_SEND_TRAILER 0x00020000 + +#define MACH_RCV_TIMEOUT 0x00000100 +#define MACH_RCV_NOTIFY 0x00000200 +#define MACH_RCV_INTERRUPT 0x00000400 /* libmach implements */ +#define MACH_RCV_OVERWRITE 0x00001000 + +/* + * NOTE: a 0x00------ RCV mask implies to ask for + * a MACH_MSG_TRAILER_FORMAT_0 with 0 Elements, + * which is equivalent to a mach_msg_trailer_t. + * + * XXXMAC: unlike the rest of the MACH_RCV_* flags, MACH_RCV_TRAILER_LABELS + * needs its own private bit since we only calculate its fields when absolutely + * required. + */ +#define MACH_RCV_TRAILER_NULL 0 +#define MACH_RCV_TRAILER_SEQNO 1 +#define MACH_RCV_TRAILER_SENDER 2 +#define MACH_RCV_TRAILER_AUDIT 3 +#define MACH_RCV_TRAILER_CTX 4 +#define MACH_RCV_TRAILER_AV 7 +#define MACH_RCV_TRAILER_LABELS 8 + +#define MACH_RCV_TRAILER_TYPE(x) (((x) & 0xf) << 28) +#define MACH_RCV_TRAILER_ELEMENTS(x) (((x) & 0xf) << 24) +#define MACH_RCV_TRAILER_MASK ((0xff << 24)) + +#define GET_RCV_ELEMENTS(y) (((y) >> 24) & 0xf) + +/* + * XXXMAC: note that in the case of MACH_RCV_TRAILER_LABELS, + * we just fall through to mach_msg_max_trailer_t. + * This is correct behavior since mach_msg_max_trailer_t is defined as + * mac_msg_mac_trailer_t which is used for the LABELS trailer. + * It also makes things work properly if MACH_RCV_TRAILER_LABELS is ORed + * with one of the other options. + */ +#define REQUESTED_TRAILER_SIZE(y) \ + ((mach_msg_trailer_size_t) \ + ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_NULL) ? \ + sizeof(mach_msg_trailer_t) : \ + ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_SEQNO) ? \ + sizeof(mach_msg_seqno_trailer_t) : \ + ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_SENDER) ? \ + sizeof(mach_msg_security_trailer_t) : \ + ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_AUDIT) ? \ + sizeof(mach_msg_audit_trailer_t) : \ + ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_CTX) ? \ + sizeof(mach_msg_context_trailer_t) : \ + ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_AV) ? \ + sizeof(mach_msg_mac_trailer_t) : \ + sizeof(mach_msg_max_trailer_t)))))))) + +/* + * Much code assumes that mach_msg_return_t == kern_return_t. + * This definition is useful for descriptive purposes. + * + * See <mach/error.h> for the format of error codes. + * IPC errors are system 4. Send errors are subsystem 0; + * receive errors are subsystem 1. The code field is always non-zero. + * The high bits of the code field communicate extra information + * for some error codes. MACH_MSG_MASK masks off these special bits. + */ + +typedef kern_return_t mach_msg_return_t; + +#define MACH_MSG_SUCCESS 0x00000000 + + +#define MACH_MSG_MASK 0x00003e00 + /* All special error code bits defined below. */ +#define MACH_MSG_IPC_SPACE 0x00002000 + /* No room in IPC name space for another capability name. */ +#define MACH_MSG_VM_SPACE 0x00001000 + /* No room in VM address space for out-of-line memory. */ +#define MACH_MSG_IPC_KERNEL 0x00000800 + /* Kernel resource shortage handling an IPC capability. */ +#define MACH_MSG_VM_KERNEL 0x00000400 + /* Kernel resource shortage handling out-of-line memory. */ + +#define MACH_SEND_IN_PROGRESS 0x10000001 + /* Thread is waiting to send. (Internal use only.) */ +#define MACH_SEND_INVALID_DATA 0x10000002 + /* Bogus in-line data. */ +#define MACH_SEND_INVALID_DEST 0x10000003 + /* Bogus destination port. */ +#define MACH_SEND_TIMED_OUT 0x10000004 + /* Message not sent before timeout expired. */ +#define MACH_SEND_INTERRUPTED 0x10000007 + /* Software interrupt. */ +#define MACH_SEND_MSG_TOO_SMALL 0x10000008 + /* Data doesn't contain a complete message. */ +#define MACH_SEND_INVALID_REPLY 0x10000009 + /* Bogus reply port. */ +#define MACH_SEND_INVALID_RIGHT 0x1000000a + /* Bogus port rights in the message body. */ +#define MACH_SEND_INVALID_NOTIFY 0x1000000b + /* Bogus notify port argument. */ +#define MACH_SEND_INVALID_MEMORY 0x1000000c + /* Invalid out-of-line memory pointer. */ +#define MACH_SEND_NO_BUFFER 0x1000000d + /* No message buffer is available. */ +#define MACH_SEND_TOO_LARGE 0x1000000e + /* Send is too large for port */ +#define MACH_SEND_INVALID_TYPE 0x1000000f + /* Invalid msg-type specification. */ +#define MACH_SEND_INVALID_HEADER 0x10000010 + /* A field in the header had a bad value. */ +#define MACH_SEND_INVALID_TRAILER 0x10000011 + /* The trailer to be sent does not match kernel format. */ +#define MACH_SEND_INVALID_RT_OOL_SIZE 0x10000015 + /* compatibility: no longer a returned error */ + +#define MACH_RCV_IN_PROGRESS 0x10004001 + /* Thread is waiting for receive. (Internal use only.) */ +#define MACH_RCV_INVALID_NAME 0x10004002 + /* Bogus name for receive port/port-set. */ +#define MACH_RCV_TIMED_OUT 0x10004003 + /* Didn't get a message within the timeout value. */ +#define MACH_RCV_TOO_LARGE 0x10004004 + /* Message buffer is not large enough for inline data. */ +#define MACH_RCV_INTERRUPTED 0x10004005 + /* Software interrupt. */ +#define MACH_RCV_PORT_CHANGED 0x10004006 + /* compatibility: no longer a returned error */ +#define MACH_RCV_INVALID_NOTIFY 0x10004007 + /* Bogus notify port argument. */ +#define MACH_RCV_INVALID_DATA 0x10004008 + /* Bogus message buffer for inline data. */ +#define MACH_RCV_PORT_DIED 0x10004009 + /* Port/set was sent away/died during receive. */ +#define MACH_RCV_IN_SET 0x1000400a + /* compatibility: no longer a returned error */ +#define MACH_RCV_HEADER_ERROR 0x1000400b + /* Error receiving message header. See special bits. */ +#define MACH_RCV_BODY_ERROR 0x1000400c + /* Error receiving message body. See special bits. */ +#define MACH_RCV_INVALID_TYPE 0x1000400d + /* Invalid msg-type specification in scatter list. */ +#define MACH_RCV_SCATTER_SMALL 0x1000400e + /* Out-of-line overwrite region is not large enough */ +#define MACH_RCV_INVALID_TRAILER 0x1000400f + /* trailer type or number of trailer elements not supported */ +#define MACH_RCV_IN_PROGRESS_TIMED 0x10004011 + /* Waiting for receive with timeout. (Internal use only.) */ + + +__BEGIN_DECLS + +/* + * Routine: mach_msg_overwrite + * Purpose: + * Send and/or receive a message. If the message operation + * is interrupted, and the user did not request an indication + * of that fact, then restart the appropriate parts of the + * operation silently (trap version does not restart). + * + * Distinct send and receive buffers may be specified. If + * no separate receive buffer is specified, the msg parameter + * will be used for both send and receive operations. + * + * In addition to a distinct receive buffer, that buffer may + * already contain scatter control information to direct the + * receiving of the message. + */ + +extern mach_msg_return_t mach_msg_overwrite( + mach_msg_header_t *msg, + mach_msg_option_t option, + mach_msg_size_t send_size, + mach_msg_size_t rcv_size, + mach_port_name_t rcv_name, + mach_msg_timeout_t timeout, + mach_port_name_t notify, + mach_msg_header_t *rcv_msg, + mach_msg_size_t rcv_limit); + + +/* + * Routine: mach_msg + * Purpose: + * Send and/or receive a message. If the message operation + * is interrupted, and the user did not request an indication + * of that fact, then restart the appropriate parts of the + * operation silently (trap version does not restart). + */ +extern mach_msg_return_t mach_msg( + mach_msg_header_t *msg, + mach_msg_option_t option, + mach_msg_size_t send_size, + mach_msg_size_t rcv_size, + mach_port_name_t rcv_name, + mach_msg_timeout_t timeout, + mach_port_name_t notify); + + +__END_DECLS + +#endif /* _MACH_MESSAGE_H_ */ + Index: branches/azimutz/Cleancut/i386/include/mach/vm_prot.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/vm_prot.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/vm_prot.h (revision 885) @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2000-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@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989,1988,1987 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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + */ +/* + * File: mach/vm_prot.h + * Author: Avadis Tevanian, Jr., Michael Wayne Young + * + * Virtual memory protection definitions. + * + */ + +#ifndef _MACH_VM_PROT_H_ +#define _MACH_VM_PROT_H_ + +/* + * Types defined: + * + * vm_prot_t VM protection values. + */ + +typedef int vm_prot_t; + +/* + * Protection values, defined as bits within the vm_prot_t type + */ + +#define VM_PROT_NONE ((vm_prot_t) 0x00) + +#define VM_PROT_READ ((vm_prot_t) 0x01) /* read permission */ +#define VM_PROT_WRITE ((vm_prot_t) 0x02) /* write permission */ +#define VM_PROT_EXECUTE ((vm_prot_t) 0x04) /* execute permission */ + +/* + * The default protection for newly-created virtual memory + */ + +#define VM_PROT_DEFAULT (VM_PROT_READ|VM_PROT_WRITE) + +/* + * The maximum privileges possible, for parameter checking. + */ + +#define VM_PROT_ALL (VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE) + +/* + * An invalid protection value. + * Used only by memory_object_lock_request to indicate no change + * to page locks. Using -1 here is a bad idea because it + * looks like VM_PROT_ALL and then some. + */ + +#define VM_PROT_NO_CHANGE ((vm_prot_t) 0x08) + +/* + * When a caller finds that he cannot obtain write permission on a + * mapped entry, the following flag can be used. The entry will + * be made "needs copy" effectively copying the object (using COW), + * and write permission will be added to the maximum protections + * for the associated entry. + */ + +#define VM_PROT_COPY ((vm_prot_t) 0x10) + + +/* + * Another invalid protection value. + * Used only by memory_object_data_request upon an object + * which has specified a copy_call copy strategy. It is used + * when the kernel wants a page belonging to a copy of the + * object, and is only asking the object as a result of + * following a shadow chain. This solves the race between pages + * being pushed up by the memory manager and the kernel + * walking down the shadow chain. + */ + +#define VM_PROT_WANTS_COPY ((vm_prot_t) 0x10) + + +/* + * The caller wants this memory region treated as if it had a valid + * code signature. + */ + +#define VM_PROT_TRUSTED ((vm_prot_t) 0x20) + + +#endif /* _MACH_VM_PROT_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/mach_interface.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/mach_interface.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/mach_interface.h (revision 885) @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2003 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) Apple Computer 1998 + * ALL Rights Reserved + */ +/* + * This file represents the interfaces that used to come + * from creating the user headers from the mach.defs file. + * Because mach.defs was decomposed, this file now just + * wraps up all the new interface headers generated from + * each of the new .defs resulting from that decomposition. + */ +#ifndef _MACH_INTERFACE_H_ +#define _MACH_INTERFACE_H_ + +#include <mach/clock_priv.h> +#include <mach/host_priv.h> +#include <mach/host_security.h> +#include <mach/ledger.h> +#include <mach/lock_set.h> +#include <mach/processor.h> +#include <mach/processor_set.h> +#include <mach/semaphore.h> +#include <mach/task.h> +#include <mach/thread_act.h> +#include <mach/vm_map.h> + +#endif /* _MACH_INTERFACE_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/thread_act.defs =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/thread_act.defs (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/thread_act.defs (revision 885) @@ -0,0 +1,323 @@ +/* + * Copyright (c) 2000-2007 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@ + */ +/* + * @OSF_FREE_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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + */ +/* + * File: mach/mach_port.defs + * Author: Rich Draves + * + * Exported kernel calls. + */ + +subsystem +#if KERNEL_SERVER + KernelServer +#endif /* KERNEL_SERVER */ + thread_act 3600; + +#include <mach/std_types.defs> +#include <mach/mach_types.defs> + +/* + * Destroy the target thread. + * + * JMM - For legacy reasons this consumes a reference to the + * target thread. This will have to change in the future because + * we want the interfaces to be able to be defined in more standard + * IDLs and transports, and most of them do not support the notion + * of reference ownership transfers (just sharing). + */ +routine thread_terminate( + target_act : thread_act_consume_ref_t); + + +/* + * Return the selected state information for the target + * thr_act. If the thr_act is currently executing, the results + * may be stale. [Flavor THREAD_STATE_FLAVOR_LIST provides a + * list of valid flavors for the target thread.] + */ +routine act_get_state( + target_act : thread_act_t; + flavor : int; + out old_state : thread_state_t, CountInOut); + +/* + * Set the selected state information for the target thread. + * If the thread is currently executing, the state change + * may be ill-defined. + */ +routine act_set_state( + target_act : thread_act_t; + flavor : int; + new_state : thread_state_t); + +/* + * Backward compatible old-style thread routines. + * These have different semantics than the new activation versions. + * + * Return the selected state information for the target + * thread. If the thread is currently executing, the results + * may be stale. [Flavor THREAD_STATE_FLAVOR_LIST provides a + * list of valid flavors for the target thr_act.] + */ +routine thread_get_state( + target_act : thread_act_t; + flavor : thread_state_flavor_t; + out old_state : thread_state_t, CountInOut); + +/* + * Set the selected state information for the target thread. + * If the thread is currently executing, the state change + * may be ill-defined. + */ +routine thread_set_state( + target_act : thread_act_t; + flavor : thread_state_flavor_t; + new_state : thread_state_t); + +/* + * Increment the suspend count for the target thread. + * Once this call has completed, the thread will not + * execute any further user or meta- instructions. + * Once suspended, a thread may not execute again until + * its suspend count is zero, and the suspend count + * for its task is also zero. + */ +routine thread_suspend( + target_act : thread_act_t); + +/* + * Decrement the suspend count for the target thread, + * if that count is not already zero. + */ +routine thread_resume( + target_act : thread_act_t); + +/* + * Cause any user or meta- instructions currently being + * executed by the target thread to be aborted. [Meta- + * instructions consist of the basic traps for IPC + * (e.g., msg_send, msg_receive) and self-identification + * (e.g., task_self, thread_self, thread_reply). Calls + * described by MiG interfaces are not meta-instructions + * themselves.] + */ +routine thread_abort( + target_act : thread_act_t); + +/* + * Cause any user or meta- instructions currently being + * executed by the target thread to be aborted so that + * they are transparently restartable. This call fails + * if the abort would result in a non-restartable condition. + * Retry is the caller's responsibility. [Meta- + * instructions consist of the basic traps for IPC + * (e.g., msg_send, msg_receive) and self-identification + * (e.g., task_self, thread_self, thread_reply). Calls + * described by MiG interfaces are not meta-instructions + * themselves.] + */ +routine thread_abort_safely( + target_act : thread_act_t); + + +routine thread_depress_abort( + thread : thread_act_t); + + +/* + * Returns the current value of the selected special port + * associated with the target thread. + */ +routine thread_get_special_port( + thr_act : thread_act_t; + which_port : int; + out special_port : mach_port_t); + +/* + * Set one of the special ports associated with the + * target thread. + */ +routine thread_set_special_port( + thr_act : thread_act_t; + which_port : int; + special_port : mach_port_t); + +/* + * Returns information about the target thread. + */ +routine thread_info( + target_act : thread_act_t; + flavor : thread_flavor_t; + out thread_info_out : thread_info_t, CountInOut); + +/* + * Set an exception handler for a thread on one or more exception types + */ +routine thread_set_exception_ports( + thread : thread_act_t; + exception_mask : exception_mask_t; + new_port : mach_port_t; + behavior : exception_behavior_t; + new_flavor : thread_state_flavor_t); + +/* + * Lookup some of the old exception handlers for a thread + */ +routine thread_get_exception_ports( + thread : thread_act_t; + exception_mask : exception_mask_t; + out masks : exception_mask_array_t; + out old_handlers : exception_handler_array_t, SameCount; + out old_behaviors : exception_behavior_array_t, SameCount; + out old_flavors : exception_flavor_array_t, SameCount); + +/* + * Set an exception handler for a thread on one or more exception types. + * At the same time, return the previously defined exception handlers for + * those types. + */ +routine thread_swap_exception_ports( + thread : thread_act_t; + exception_mask : exception_mask_t; + new_port : mach_port_t; + behavior : exception_behavior_t; + new_flavor : thread_state_flavor_t; + out masks : exception_mask_array_t; + out old_handlers : exception_handler_array_t, SameCount; + out old_behaviors : exception_behavior_array_t, SameCount; + out old_flavors : exception_flavor_array_t, SameCount); + +/* + * OBSOLETE interface. + */ +routine thread_policy( + thr_act : thread_act_t; + policy : policy_t; + base : policy_base_t; + set_limit : boolean_t); + +/* + * Set/get policy information for a thread. + * (Approved Mac OS X microkernel interface) + */ + +routine thread_policy_set( + thread : thread_act_t; + flavor : thread_policy_flavor_t; + policy_info : thread_policy_t); + +routine thread_policy_get( + thread : thread_act_t; + flavor : thread_policy_flavor_t; +out policy_info : thread_policy_t, CountInOut; +inout get_default : boolean_t); + +/* + * Removed from the kernel. + */ +#if KERNEL_SERVER +skip; +#else +routine thread_sample( + thread : thread_act_t; + reply : mach_port_make_send_t); +#endif + +/* + * ETAP has been removed from the kernel. + */ +#if KERNEL_SERVER +skip; +#else +routine etap_trace_thread( + target_act : thread_act_t; + trace_status : boolean_t); +#endif + +/* + * Assign thread to processor set. + */ +routine thread_assign( + thread : thread_act_t; + new_set : processor_set_t); + +/* + * Assign thread to default set. + */ +routine thread_assign_default( + thread : thread_act_t); + +/* + * Get current assignment for thread. + */ +routine thread_get_assignment( + thread : thread_act_t; + out assigned_set : processor_set_name_t); + + +/* + * OBSOLETE interface. + */ +routine thread_set_policy( + thr_act : thread_act_t; + pset : processor_set_t; + policy : policy_t; + base : policy_base_t; + limit : policy_limit_t); + +/* vim: set ft=c : */ Index: branches/azimutz/Cleancut/i386/include/mach/error.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/error.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/error.h (revision 885) @@ -0,0 +1,114 @@ +/* + * Copyright (c) 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@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989,1988,1987 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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + */ +/* + * File: mach/error.h + * Purpose: + * error module definitions + * + */ + +#ifndef _MACH_ERROR_H_ +#define _MACH_ERROR_H_ + +#include <mach/kern_return.h> + +/* + * error number layout as follows: + * + * hi lo + * | system(6) | subsystem(12) | code(14) | + */ + + +#define err_none (mach_error_t)0 +#define ERR_SUCCESS (mach_error_t)0 +#define ERR_ROUTINE_NIL (mach_error_fn_t)0 + + +#define err_system(x) (((x)&0x3f)<<26) +#define err_sub(x) (((x)&0xfff)<<14) + +#define err_get_system(err) (((err)>>26)&0x3f) +#define err_get_sub(err) (((err)>>14)&0xfff) +#define err_get_code(err) ((err)&0x3fff) + +#define system_emask (err_system(0x3f)) +#define sub_emask (err_sub(0xfff)) +#define code_emask (0x3fff) + + +/* major error systems */ +#define err_kern err_system(0x0) /* kernel */ +#define err_us err_system(0x1) /* user space library */ +#define err_server err_system(0x2) /* user space servers */ +#define err_ipc err_system(0x3) /* old ipc errors */ +#define err_mach_ipc err_system(0x4) /* mach-ipc errors */ +#define err_dipc err_system(0x7) /* distributed ipc */ +#define err_local err_system(0x3e) /* user defined errors */ +#define err_ipc_compat err_system(0x3f) /* (compatibility) mach-ipc errors */ + +#define err_max_system 0x3f + + +/* unix errors get lumped into one subsystem */ +#define unix_err(errno) (err_kern|err_sub(3)|errno) + +typedef kern_return_t mach_error_t; +typedef mach_error_t (* mach_error_fn_t)( void ); + +#endif /* _MACH_ERROR_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/task_special_ports.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/task_special_ports.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/task_special_ports.h (revision 885) @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2000-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@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989,1988,1987 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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + */ +/* + * File: mach/task_special_ports.h + * + * Defines codes for special_purpose task ports. These are NOT + * port identifiers - they are only used for the task_get_special_port + * and task_set_special_port routines. + * + */ + +#ifndef _MACH_TASK_SPECIAL_PORTS_H_ +#define _MACH_TASK_SPECIAL_PORTS_H_ + +typedef int task_special_port_t; + +#define TASK_KERNEL_PORT 1 /* Represents task to the outside + world.*/ + +#define TASK_HOST_PORT 2 /* The host (priv) port for task. */ + +#define TASK_NAME_PORT 3 /* the name (unpriv) port for task */ + +#define TASK_BOOTSTRAP_PORT 4 /* Bootstrap environment for task. */ + +/* + * Evolving and likely to change. + */ + +#define TASK_WIRED_LEDGER_PORT 5 /* Wired resource ledger for task. */ + +#define TASK_PAGED_LEDGER_PORT 6 /* Paged resource ledger for task. */ + +#define TASK_SEATBELT_PORT 7 /* Seatbelt compiler/DEM port for task. */ + +#define TASK_GSSD_PORT 8 /* GSSD port for security context */ + +#define TASK_ACCESS_PORT 9 /* Permission check for task_for_pid. */ + +#define task_get_wired_ledger_port(task, port) \ + (task_get_special_port((task), TASK_WIRED_LEDGER_PORT, (port))) + +#define task_set_wired_ledger_port(task, port) \ + (task_set_special_port((task), TASK_WIRED_LEDGER_PORT, (port))) + +#define task_get_paged_ledger_port(task, port) \ + (task_get_special_port((task), TASK_PAGED_LEDGER_PORT, (port))) + +#define task_set_paged_ledger_port(task, port) \ + (task_set_special_port((task), TASK_PAGED_LEDGER_PORT, (port))) + +/* + * Definitions for ease of use + */ + +#define task_get_kernel_port(task, port) \ + (task_get_special_port((task), TASK_KERNEL_PORT, (port))) + +#define task_set_kernel_port(task, port) \ + (task_set_special_port((task), TASK_KERNEL_PORT, (port))) + +#define task_get_host_port(task, port) \ + (task_get_special_port((task), TASK_HOST_PORT, (port))) + +#define task_set_host_port(task, port) \ + (task_set_special_port((task), TASK_HOST_PORT, (port))) + +#define task_get_bootstrap_port(task, port) \ + (task_get_special_port((task), TASK_BOOTSTRAP_PORT, (port))) + +#define task_set_bootstrap_port(task, port) \ + (task_set_special_port((task), TASK_BOOTSTRAP_PORT, (port))) + +#define task_get_gssd_port(task, port) \ + (task_get_special_port((task), TASK_GSSD_PORT, (port))) + +#define task_set_gssd_port(task, port) \ + (task_set_special_port((task), TASK_GSSD_PORT, (port))) + +#define task_get_task_access_port(task, port) \ + (task_get_special_port((task), TASK_ACCESS_PORT, (port))) + +#define task_set_task_access_port(task, port) \ + (task_set_special_port((task), TASK_ACCESS_PORT, (port))) + +#endif /* _MACH_TASK_SPECIAL_PORTS_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/sdt.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/sdt.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/sdt.h (revision 885) @@ -0,0 +1,32 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _MACH_SDT_H +#define _MACH_SDT_H + +#include <mach/machine/sdt.h> + +#endif /* _MACH_SDT_H */ Index: branches/azimutz/Cleancut/i386/include/mach/mach_init.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/mach_init.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/mach_init.h (revision 885) @@ -0,0 +1,130 @@ +/* + * Copyright (c) 1999 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@ + */ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989,1988,1987,1986 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 Software.Distribution@CS.CMU.EDU + * 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. + */ + +/* + * Items provided by the Mach environment initialization. + */ + +#ifndef _MACH_INIT_ +#define _MACH_INIT_ 1 + +#include <mach/mach_types.h> +#include <stdarg.h> + +#include <sys/cdefs.h> + +/* + * Kernel-related ports; how a task/thread controls itself + */ + +__BEGIN_DECLS +extern mach_port_t mach_task_self(void); +extern mach_port_t mach_host_self(void); +extern mach_port_t mach_thread_self(void); +extern kern_return_t host_page_size(host_t, vm_size_t *); + +extern mach_port_t mach_task_self_; +#define mach_task_self() mach_task_self_ +#define current_task() mach_task_self() + +__END_DECLS +#include <mach/mach_traps.h> +__BEGIN_DECLS + +/* + * Other important ports in the Mach user environment + */ + +extern mach_port_t bootstrap_port; +extern mach_port_t name_server_port; +extern mach_port_t environment_port; +extern mach_port_t service_port; + +/* + * Where these ports occur in the "mach_ports_register" + * collection... only servers or the runtime library need know. + */ + +#define NAME_SERVER_SLOT 0 +#define ENVIRONMENT_SLOT 1 +#define SERVICE_SLOT 2 + +#define MACH_PORTS_SLOTS_USED 3 + +/* + * Globally interesting numbers. + * These macros assume vm_page_size is a power-of-2. + */ + +extern vm_size_t vm_page_size; +extern vm_size_t vm_page_mask; +extern int vm_page_shift; + +#define trunc_page(x) ((x) & (~(vm_page_size - 1))) +#define round_page(x) trunc_page((x) + (vm_page_size - 1)) + +/* + * Page-size rounding macros for the fixed-width VM types. + */ +#define mach_vm_trunc_page(x) ((mach_vm_offset_t)(x) & ~((signed)PAGE_MASK)) +#define mach_vm_round_page(x) (((mach_vm_offset_t)(x) + PAGE_MASK) & ~((signed)PAGE_MASK)) + +/* + * fprintf_stderr uses vprintf_stderr_func to produce + * error messages, this can be overridden by a user + * application to point to a user-specified output function + */ +extern int (*vprintf_stderr_func)(const char *format, va_list ap); +__END_DECLS + +#endif /* _MACH_INIT_ */ Index: branches/azimutz/Cleancut/i386/include/mach/host_security.defs =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/host_security.defs (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/host_security.defs (revision 885) @@ -0,0 +1,101 @@ +/* + * Copyright (c) 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@ + */ +/* + * @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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + */ + +/* + * File: mach/host_security.defs + * + * Abstract: + * Mach host security operations support. + */ +subsystem +#if KERNEL_SERVER + KernelServer +#endif /* KERNEL_SERVER */ + host_security 600; + +/* + * Basic types + */ +#include <mach/std_types.defs> +#include <mach/mach_types.defs> + + +/* + * Create a new task with an explicit security token + */ +routine host_security_create_task_token( + host_security : host_security_t; + parent_task : task_t; + sec_token : security_token_t; + audit_token : audit_token_t; + host : host_t; + ledgers : ledger_array_t; + inherit_memory : boolean_t; + out child_task : task_t); + +/* + * Change a task's security token + */ +routine host_security_set_task_token( + host_security : host_security_t; + target_task : task_t; + sec_token : security_token_t; + audit_token : audit_token_t; + host : host_t); + +/* vim: set ft=c : */ Index: branches/azimutz/Cleancut/i386/include/mach/clock_reply.defs =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/clock_reply.defs (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/clock_reply.defs (revision 885) @@ -0,0 +1,56 @@ +/* + * Copyright (c) 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@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * File: clock_reply.defs + * Purpose: Kernel clock subsystem definitions. This + * file defines the clock reply interface. + */ + +subsystem +#if KERNEL_USER + KernelUser +#endif /* KERNEL_USER */ + clock_reply 3125107; /* Matches up with old value */ + +#include <mach/std_types.defs> +#include <mach/clock_types.defs> + + +/* + * Reply routine for clock_alarm. + */ +simpleroutine clock_alarm_reply( + alarm_port : clock_reply_t; + alarm_code : kern_return_t; + alarm_type : alarm_type_t; + alarm_time : mach_timespec_t); + +/* vim: set ft=c : */ Index: branches/azimutz/Cleancut/i386/include/mach/i386/processor_info.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/i386/processor_info.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/i386/processor_info.h (revision 885) @@ -0,0 +1,37 @@ +/* + * Copyright (c) 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@ + */ +/* + * File: mach/i386/processor_info.h + * + * Data structure definitions for i386 specific processor control + */ + +#ifndef _MACH_I386_PROCESSOR_INFO_H_ +#define _MACH_I386_PROCESSOR_INFO_H_ + +#endif /* _MACH_I386_PROCESSOR_INFO_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/i386/exception.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/i386/exception.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/i386/exception.h (revision 885) @@ -0,0 +1,135 @@ +/* + * Copyright (c) 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@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989,1988 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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + */ + +#ifndef _MACH_I386_EXCEPTION_H_ +#define _MACH_I386_EXCEPTION_H_ + +/* + * No machine dependent types for the 80386 + */ + +#define EXC_TYPES_COUNT 11 /* incl. illegal exception 0 */ + +/* + * Codes and subcodes for 80386 exceptions. + */ + +#define EXCEPTION_CODE_MAX 2 /* currently code and subcode */ + +/* + * EXC_BAD_INSTRUCTION + */ + +#define EXC_I386_INVOP 1 + +/* + * EXC_ARITHMETIC + */ + +#define EXC_I386_DIV 1 +#define EXC_I386_INTO 2 +#define EXC_I386_NOEXT 3 +#define EXC_I386_EXTOVR 4 +#define EXC_I386_EXTERR 5 +#define EXC_I386_EMERR 6 +#define EXC_I386_BOUND 7 +#define EXC_I386_SSEEXTERR 8 + +/* + * EXC_SOFTWARE + * Note: 0x10000-0x10003 in use for unix signal + */ + +/* + * EXC_BAD_ACCESS + */ + +/* + * EXC_BREAKPOINT + */ + +#define EXC_I386_SGL 1 +#define EXC_I386_BPT 2 + +#define EXC_I386_DIVERR 0 /* divide by 0 eprror */ +#define EXC_I386_SGLSTP 1 /* single step */ +#define EXC_I386_NMIFLT 2 /* NMI */ +#define EXC_I386_BPTFLT 3 /* breakpoint fault */ +#define EXC_I386_INTOFLT 4 /* INTO overflow fault */ +#define EXC_I386_BOUNDFLT 5 /* BOUND instruction fault */ +#define EXC_I386_INVOPFLT 6 /* invalid opcode fault */ +#define EXC_I386_NOEXTFLT 7 /* extension not available fault*/ +#define EXC_I386_DBLFLT 8 /* double fault */ +#define EXC_I386_EXTOVRFLT 9 /* extension overrun fault */ +#define EXC_I386_INVTSSFLT 10 /* invalid TSS fault */ +#define EXC_I386_SEGNPFLT 11 /* segment not present fault */ +#define EXC_I386_STKFLT 12 /* stack fault */ +#define EXC_I386_GPFLT 13 /* general protection fault */ +#define EXC_I386_PGFLT 14 /* page fault */ +#define EXC_I386_EXTERRFLT 16 /* extension error fault */ +#define EXC_I386_ALIGNFLT 17 /* Alignment fault */ +#define EXC_I386_ENDPERR 33 /* emulated extension error flt */ +#define EXC_I386_ENOEXTFLT 32 /* emulated ext not present */ + + +/* + * machine dependent exception masks + */ +#define EXC_MASK_MACHINE 0 + +#endif /* _MACH_I386_EXCEPTION_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/i386/kern_return.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/i386/kern_return.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/i386/kern_return.h (revision 885) @@ -0,0 +1,74 @@ +/* + * Copyright (c) 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@ + */ +/* + * @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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + */ + +/* + * File: kern_return.h + * Author: Avadis Tevanian, Jr., Michael Wayne Young + * Date: 1985 + * + * Machine-dependent kernel return definitions. + */ + +#ifndef _MACH_I386_KERN_RETURN_H_ +#define _MACH_I386_KERN_RETURN_H_ + +#ifndef ASSEMBLER +typedef int kern_return_t; +#endif /* ASSEMBLER */ + +#endif /* _MACH_I386_KERN_RETURN_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/i386/thread_act.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/i386/thread_act.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/i386/thread_act.h (revision 885) @@ -0,0 +1,1155 @@ +#ifndef _thread_act_user_ +#define _thread_act_user_ + +/* Module thread_act */ + +#include <string.h> +#include <mach/ndr.h> +#include <mach/boolean.h> +#include <mach/kern_return.h> +#include <mach/notify.h> +#include <mach/mach_types.h> +#include <mach/message.h> +#include <mach/mig_errors.h> +#include <mach/port.h> + +#ifdef AUTOTEST +#ifndef FUNCTION_PTR_T +#define FUNCTION_PTR_T +typedef void (*function_ptr_t)(mach_port_t, char *, mach_msg_type_number_t); +typedef struct { + char *name; + function_ptr_t function; +} function_table_entry; +typedef function_table_entry *function_table_t; +#endif /* FUNCTION_PTR_T */ +#endif /* AUTOTEST */ + +#ifndef thread_act_MSG_COUNT +#define thread_act_MSG_COUNT 25 +#endif /* thread_act_MSG_COUNT */ + +#include <mach/std_types.h> +#include <mach/mig.h> +#include <mach/mig.h> +#include <mach/mach_types.h> + +#ifdef __BeforeMigUserHeader +__BeforeMigUserHeader +#endif /* __BeforeMigUserHeader */ + +#include <sys/cdefs.h> +__BEGIN_DECLS + + +/* Routine thread_terminate */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_terminate +( + thread_act_t target_act +); + +/* Routine act_get_state */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t act_get_state +( + thread_act_t target_act, + int flavor, + thread_state_t old_state, + mach_msg_type_number_t *old_stateCnt +); + +/* Routine act_set_state */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t act_set_state +( + thread_act_t target_act, + int flavor, + thread_state_t new_state, + mach_msg_type_number_t new_stateCnt +); + +/* Routine thread_get_state */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_get_state +( + thread_act_t target_act, + thread_state_flavor_t flavor, + thread_state_t old_state, + mach_msg_type_number_t *old_stateCnt +); + +/* Routine thread_set_state */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_set_state +( + thread_act_t target_act, + thread_state_flavor_t flavor, + thread_state_t new_state, + mach_msg_type_number_t new_stateCnt +); + +/* Routine thread_suspend */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_suspend +( + thread_act_t target_act +); + +/* Routine thread_resume */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_resume +( + thread_act_t target_act +); + +/* Routine thread_abort */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_abort +( + thread_act_t target_act +); + +/* Routine thread_abort_safely */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_abort_safely +( + thread_act_t target_act +); + +/* Routine thread_depress_abort */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_depress_abort +( + thread_act_t thread +); + +/* Routine thread_get_special_port */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_get_special_port +( + thread_act_t thr_act, + int which_port, + mach_port_t *special_port +); + +/* Routine thread_set_special_port */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_set_special_port +( + thread_act_t thr_act, + int which_port, + mach_port_t special_port +); + +/* Routine thread_info */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_info +( + thread_act_t target_act, + thread_flavor_t flavor, + thread_info_t thread_info_out, + mach_msg_type_number_t *thread_info_outCnt +); + +/* Routine thread_set_exception_ports */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_set_exception_ports +( + thread_act_t thread, + exception_mask_t exception_mask, + mach_port_t new_port, + exception_behavior_t behavior, + thread_state_flavor_t new_flavor +); + +/* Routine thread_get_exception_ports */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_get_exception_ports +( + thread_act_t thread, + exception_mask_t exception_mask, + exception_mask_array_t masks, + mach_msg_type_number_t *masksCnt, + exception_handler_array_t old_handlers, + exception_behavior_array_t old_behaviors, + exception_flavor_array_t old_flavors +); + +/* Routine thread_swap_exception_ports */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_swap_exception_ports +( + thread_act_t thread, + exception_mask_t exception_mask, + mach_port_t new_port, + exception_behavior_t behavior, + thread_state_flavor_t new_flavor, + exception_mask_array_t masks, + mach_msg_type_number_t *masksCnt, + exception_handler_array_t old_handlers, + exception_behavior_array_t old_behaviors, + exception_flavor_array_t old_flavors +); + +/* Routine thread_policy */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_policy +( + thread_act_t thr_act, + policy_t policy, + policy_base_t base, + mach_msg_type_number_t baseCnt, + boolean_t set_limit +); + +/* Routine thread_policy_set */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_policy_set +( + thread_act_t thread, + thread_policy_flavor_t flavor, + thread_policy_t policy_info, + mach_msg_type_number_t policy_infoCnt +); + +/* Routine thread_policy_get */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_policy_get +( + thread_act_t thread, + thread_policy_flavor_t flavor, + thread_policy_t policy_info, + mach_msg_type_number_t *policy_infoCnt, + boolean_t *get_default +); + +/* Routine thread_sample */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_sample +( + thread_act_t thread, + mach_port_t reply +); + +/* Routine etap_trace_thread */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t etap_trace_thread +( + thread_act_t target_act, + boolean_t trace_status +); + +/* Routine thread_assign */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_assign +( + thread_act_t thread, + processor_set_t new_set +); + +/* Routine thread_assign_default */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_assign_default +( + thread_act_t thread +); + +/* Routine thread_get_assignment */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_get_assignment +( + thread_act_t thread, + processor_set_name_t *assigned_set +); + +/* Routine thread_set_policy */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_set_policy +( + thread_act_t thr_act, + processor_set_t pset, + policy_t policy, + policy_base_t base, + mach_msg_type_number_t baseCnt, + policy_limit_t limit, + mach_msg_type_number_t limitCnt +); + +__END_DECLS + +/********************** Caution **************************/ +/* The following data types should be used to calculate */ +/* maximum message sizes only. The actual message may be */ +/* smaller, and the position of the arguments within the */ +/* message layout may vary from what is presented here. */ +/* For example, if any of the arguments are variable- */ +/* sized, and less than the maximum is sent, the data */ +/* will be packed tight in the actual message to reduce */ +/* the presence of holes. */ +/********************** Caution **************************/ + +/* typedefs for all requests */ + +#ifndef __Request__thread_act_subsystem__defined +#define __Request__thread_act_subsystem__defined + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__thread_terminate_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + int flavor; + mach_msg_type_number_t old_stateCnt; + } __Request__act_get_state_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + int flavor; + mach_msg_type_number_t new_stateCnt; + natural_t new_state[144]; + } __Request__act_set_state_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + thread_state_flavor_t flavor; + mach_msg_type_number_t old_stateCnt; + } __Request__thread_get_state_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + thread_state_flavor_t flavor; + mach_msg_type_number_t new_stateCnt; + natural_t new_state[144]; + } __Request__thread_set_state_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__thread_suspend_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__thread_resume_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__thread_abort_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__thread_abort_safely_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__thread_depress_abort_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + int which_port; + } __Request__thread_get_special_port_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t special_port; + /* end of the kernel processed data */ + NDR_record_t NDR; + int which_port; + } __Request__thread_set_special_port_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + thread_flavor_t flavor; + mach_msg_type_number_t thread_info_outCnt; + } __Request__thread_info_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t new_port; + /* end of the kernel processed data */ + NDR_record_t NDR; + exception_mask_t exception_mask; + exception_behavior_t behavior; + thread_state_flavor_t new_flavor; + } __Request__thread_set_exception_ports_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + exception_mask_t exception_mask; + } __Request__thread_get_exception_ports_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t new_port; + /* end of the kernel processed data */ + NDR_record_t NDR; + exception_mask_t exception_mask; + exception_behavior_t behavior; + thread_state_flavor_t new_flavor; + } __Request__thread_swap_exception_ports_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + policy_t policy; + mach_msg_type_number_t baseCnt; + integer_t base[5]; + boolean_t set_limit; + } __Request__thread_policy_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + thread_policy_flavor_t flavor; + mach_msg_type_number_t policy_infoCnt; + integer_t policy_info[16]; + } __Request__thread_policy_set_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + thread_policy_flavor_t flavor; + mach_msg_type_number_t policy_infoCnt; + boolean_t get_default; + } __Request__thread_policy_get_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t reply; + /* end of the kernel processed data */ + } __Request__thread_sample_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + boolean_t trace_status; + } __Request__etap_trace_thread_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t new_set; + /* end of the kernel processed data */ + } __Request__thread_assign_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__thread_assign_default_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__thread_get_assignment_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t pset; + /* end of the kernel processed data */ + NDR_record_t NDR; + policy_t policy; + mach_msg_type_number_t baseCnt; + integer_t base[5]; + mach_msg_type_number_t limitCnt; + integer_t limit[1]; + } __Request__thread_set_policy_t; +#ifdef __MigPackStructs +#pragma pack() +#endif +#endif /* !__Request__thread_act_subsystem__defined */ + +/* union of all requests */ + +#ifndef __RequestUnion__thread_act_subsystem__defined +#define __RequestUnion__thread_act_subsystem__defined +union __RequestUnion__thread_act_subsystem { + __Request__thread_terminate_t Request_thread_terminate; + __Request__act_get_state_t Request_act_get_state; + __Request__act_set_state_t Request_act_set_state; + __Request__thread_get_state_t Request_thread_get_state; + __Request__thread_set_state_t Request_thread_set_state; + __Request__thread_suspend_t Request_thread_suspend; + __Request__thread_resume_t Request_thread_resume; + __Request__thread_abort_t Request_thread_abort; + __Request__thread_abort_safely_t Request_thread_abort_safely; + __Request__thread_depress_abort_t Request_thread_depress_abort; + __Request__thread_get_special_port_t Request_thread_get_special_port; + __Request__thread_set_special_port_t Request_thread_set_special_port; + __Request__thread_info_t Request_thread_info; + __Request__thread_set_exception_ports_t Request_thread_set_exception_ports; + __Request__thread_get_exception_ports_t Request_thread_get_exception_ports; + __Request__thread_swap_exception_ports_t Request_thread_swap_exception_ports; + __Request__thread_policy_t Request_thread_policy; + __Request__thread_policy_set_t Request_thread_policy_set; + __Request__thread_policy_get_t Request_thread_policy_get; + __Request__thread_sample_t Request_thread_sample; + __Request__etap_trace_thread_t Request_etap_trace_thread; + __Request__thread_assign_t Request_thread_assign; + __Request__thread_assign_default_t Request_thread_assign_default; + __Request__thread_get_assignment_t Request_thread_get_assignment; + __Request__thread_set_policy_t Request_thread_set_policy; +}; +#endif /* !__RequestUnion__thread_act_subsystem__defined */ +/* typedefs for all replies */ + +#ifndef __Reply__thread_act_subsystem__defined +#define __Reply__thread_act_subsystem__defined + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_terminate_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_msg_type_number_t old_stateCnt; + natural_t old_state[144]; + } __Reply__act_get_state_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__act_set_state_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_msg_type_number_t old_stateCnt; + natural_t old_state[144]; + } __Reply__thread_get_state_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_set_state_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_suspend_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_resume_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_abort_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_abort_safely_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_depress_abort_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t special_port; + /* end of the kernel processed data */ + } __Reply__thread_get_special_port_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_set_special_port_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_msg_type_number_t thread_info_outCnt; + integer_t thread_info_out[12]; + } __Reply__thread_info_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_set_exception_ports_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t old_handlers[32]; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t masksCnt; + exception_mask_t masks[32]; + exception_behavior_t old_behaviors[32]; + thread_state_flavor_t old_flavors[32]; + } __Reply__thread_get_exception_ports_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t old_handlers[32]; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t masksCnt; + exception_mask_t masks[32]; + exception_behavior_t old_behaviors[32]; + thread_state_flavor_t old_flavors[32]; + } __Reply__thread_swap_exception_ports_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_policy_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_policy_set_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_msg_type_number_t policy_infoCnt; + integer_t policy_info[16]; + boolean_t get_default; + } __Reply__thread_policy_get_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_sample_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__etap_trace_thread_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_assign_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_assign_default_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t assigned_set; + /* end of the kernel processed data */ + } __Reply__thread_get_assignment_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_set_policy_t; +#ifdef __MigPackStructs +#pragma pack() +#endif +#endif /* !__Reply__thread_act_subsystem__defined */ + +/* union of all replies */ + +#ifndef __ReplyUnion__thread_act_subsystem__defined +#define __ReplyUnion__thread_act_subsystem__defined +union __ReplyUnion__thread_act_subsystem { + __Reply__thread_terminate_t Reply_thread_terminate; + __Reply__act_get_state_t Reply_act_get_state; + __Reply__act_set_state_t Reply_act_set_state; + __Reply__thread_get_state_t Reply_thread_get_state; + __Reply__thread_set_state_t Reply_thread_set_state; + __Reply__thread_suspend_t Reply_thread_suspend; + __Reply__thread_resume_t Reply_thread_resume; + __Reply__thread_abort_t Reply_thread_abort; + __Reply__thread_abort_safely_t Reply_thread_abort_safely; + __Reply__thread_depress_abort_t Reply_thread_depress_abort; + __Reply__thread_get_special_port_t Reply_thread_get_special_port; + __Reply__thread_set_special_port_t Reply_thread_set_special_port; + __Reply__thread_info_t Reply_thread_info; + __Reply__thread_set_exception_ports_t Reply_thread_set_exception_ports; + __Reply__thread_get_exception_ports_t Reply_thread_get_exception_ports; + __Reply__thread_swap_exception_ports_t Reply_thread_swap_exception_ports; + __Reply__thread_policy_t Reply_thread_policy; + __Reply__thread_policy_set_t Reply_thread_policy_set; + __Reply__thread_policy_get_t Reply_thread_policy_get; + __Reply__thread_sample_t Reply_thread_sample; + __Reply__etap_trace_thread_t Reply_etap_trace_thread; + __Reply__thread_assign_t Reply_thread_assign; + __Reply__thread_assign_default_t Reply_thread_assign_default; + __Reply__thread_get_assignment_t Reply_thread_get_assignment; + __Reply__thread_set_policy_t Reply_thread_set_policy; +}; +#endif /* !__RequestUnion__thread_act_subsystem__defined */ + +#ifndef subsystem_to_name_map_thread_act +#define subsystem_to_name_map_thread_act \ + { "thread_terminate", 3600 },\ + { "act_get_state", 3601 },\ + { "act_set_state", 3602 },\ + { "thread_get_state", 3603 },\ + { "thread_set_state", 3604 },\ + { "thread_suspend", 3605 },\ + { "thread_resume", 3606 },\ + { "thread_abort", 3607 },\ + { "thread_abort_safely", 3608 },\ + { "thread_depress_abort", 3609 },\ + { "thread_get_special_port", 3610 },\ + { "thread_set_special_port", 3611 },\ + { "thread_info", 3612 },\ + { "thread_set_exception_ports", 3613 },\ + { "thread_get_exception_ports", 3614 },\ + { "thread_swap_exception_ports", 3615 },\ + { "thread_policy", 3616 },\ + { "thread_policy_set", 3617 },\ + { "thread_policy_get", 3618 },\ + { "thread_sample", 3619 },\ + { "etap_trace_thread", 3620 },\ + { "thread_assign", 3621 },\ + { "thread_assign_default", 3622 },\ + { "thread_get_assignment", 3623 },\ + { "thread_set_policy", 3624 } +#endif + +#ifdef __AfterMigUserHeader +__AfterMigUserHeader +#endif /* __AfterMigUserHeader */ + +#endif /* _thread_act_user_ */ Index: branches/azimutz/Cleancut/i386/include/mach/i386/ndr_def.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/i386/ndr_def.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/i386/ndr_def.h (revision 885) @@ -0,0 +1,45 @@ +/* + * Copyright (c) 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@ + */ +/* + * @OSF_COPYRIGHT@ + */ + +/* NDR record for Intel x86s */ + +#include <mach/ndr.h> + +NDR_record_t NDR_record = { + 0, /* mig_reserved */ + 0, /* mig_reserved */ + 0, /* mig_reserved */ + NDR_PROTOCOL_2_0, + NDR_INT_LITTLE_ENDIAN, + NDR_CHAR_ASCII, + NDR_FLOAT_IEEE, + 0, +}; Index: branches/azimutz/Cleancut/i386/include/mach/i386/fp_reg.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/i386/fp_reg.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/i386/fp_reg.h (revision 885) @@ -0,0 +1,141 @@ +/* + * Copyright (c) 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@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * Mach Operating System + * Copyright (c) 1992-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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + */ + +#ifndef _I386_FP_SAVE_H_ +#define _I386_FP_SAVE_H_ + + +/* note when allocating this data structure, it must be 16 byte aligned. */ +struct x86_fx_save { + unsigned short fx_control; /* control */ + unsigned short fx_status; /* status */ + unsigned char fx_tag; /* register tags */ + unsigned char fx_bbz1; /* better be zero when calling fxrtstor */ + unsigned short fx_opcode; + unsigned int fx_eip; /* eip instruction */ + unsigned short fx_cs; /* cs instruction */ + unsigned short fx_bbz2; /* better be zero when calling fxrtstor */ + unsigned int fx_dp; /* data address */ + unsigned short fx_ds; /* data segment */ + unsigned short fx_bbz3; /* better be zero when calling fxrtstor */ + unsigned int fx_MXCSR; + unsigned int fx_MXCSR_MASK; + unsigned short fx_reg_word[8][8]; /* STx/MMx registers */ + unsigned short fx_XMM_reg[8][16]; /* XMM0-XMM15 on 64 bit processors */ + /* XMM0-XMM7 on 32 bit processors... unused storage reserved */ + unsigned char fx_reserved[16*6]; /* reserved by intel for future expansion */ +}; + + +/* + * Control register + */ +#define FPC_IE 0x0001 /* enable invalid operation + exception */ +#define FPC_IM FPC_IE +#define FPC_DE 0x0002 /* enable denormalized operation + exception */ +#define FPC_DM FPC_DE +#define FPC_ZE 0x0004 /* enable zero-divide exception */ +#define FPC_ZM FPC_ZE +#define FPC_OE 0x0008 /* enable overflow exception */ +#define FPC_OM FPC_OE +#define FPC_UE 0x0010 /* enable underflow exception */ +#define FPC_PE 0x0020 /* enable precision exception */ +#define FPC_PC 0x0300 /* precision control: */ +#define FPC_PC_24 0x0000 /* 24 bits */ +#define FPC_PC_53 0x0200 /* 53 bits */ +#define FPC_PC_64 0x0300 /* 64 bits */ +#define FPC_RC 0x0c00 /* rounding control: */ +#define FPC_RC_RN 0x0000 /* round to nearest or even */ +#define FPC_RC_RD 0x0400 /* round down */ +#define FPC_RC_RU 0x0800 /* round up */ +#define FPC_RC_CHOP 0x0c00 /* chop */ +#define FPC_IC 0x1000 /* infinity control (obsolete) */ +#define FPC_IC_PROJ 0x0000 /* projective infinity */ +#define FPC_IC_AFF 0x1000 /* affine infinity (std) */ + +/* + * Status register + */ +#define FPS_IE 0x0001 /* invalid operation */ +#define FPS_DE 0x0002 /* denormalized operand */ +#define FPS_ZE 0x0004 /* divide by zero */ +#define FPS_OE 0x0008 /* overflow */ +#define FPS_UE 0x0010 /* underflow */ +#define FPS_PE 0x0020 /* precision */ +#define FPS_SF 0x0040 /* stack flag */ +#define FPS_ES 0x0080 /* error summary */ +#define FPS_C0 0x0100 /* condition code bit 0 */ +#define FPS_C1 0x0200 /* condition code bit 1 */ +#define FPS_C2 0x0400 /* condition code bit 2 */ +#define FPS_TOS 0x3800 /* top-of-stack pointer */ +#define FPS_TOS_SHIFT 11 +#define FPS_C3 0x4000 /* condition code bit 3 */ +#define FPS_BUSY 0x8000 /* FPU busy */ + +/* + * Kind of floating-point support provided by kernel. + */ +#define FP_NO 0 /* no floating point */ +#define FP_SOFT 1 /* software FP emulator */ +#define FP_287 2 /* 80287 */ +#define FP_387 3 /* 80387 or 80486 */ +#define FP_FXSR 4 /* Fast save/restore SIMD Extension */ + +#endif /* _I386_FP_SAVE_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/i386/task.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/i386/task.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/i386/task.h (revision 885) @@ -0,0 +1,1578 @@ +#ifndef _task_user_ +#define _task_user_ + +/* Module task */ + +#include <string.h> +#include <mach/ndr.h> +#include <mach/boolean.h> +#include <mach/kern_return.h> +#include <mach/notify.h> +#include <mach/mach_types.h> +#include <mach/message.h> +#include <mach/mig_errors.h> +#include <mach/port.h> + +#ifdef AUTOTEST +#ifndef FUNCTION_PTR_T +#define FUNCTION_PTR_T +typedef void (*function_ptr_t)(mach_port_t, char *, mach_msg_type_number_t); +typedef struct { + char *name; + function_ptr_t function; +} function_table_entry; +typedef function_table_entry *function_table_t; +#endif /* FUNCTION_PTR_T */ +#endif /* AUTOTEST */ + +#ifndef task_MSG_COUNT +#define task_MSG_COUNT 35 +#endif /* task_MSG_COUNT */ + +#include <mach/std_types.h> +#include <mach/mig.h> +#include <mach/mig.h> +#include <mach/mach_types.h> + +#ifdef __BeforeMigUserHeader +__BeforeMigUserHeader +#endif /* __BeforeMigUserHeader */ + +#include <sys/cdefs.h> +__BEGIN_DECLS + + +/* Routine task_create */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_create +( + task_t target_task, + ledger_array_t ledgers, + mach_msg_type_number_t ledgersCnt, + boolean_t inherit_memory, + task_t *child_task +); + +/* Routine task_terminate */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_terminate +( + task_t target_task +); + +/* Routine task_threads */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_threads +( + task_t target_task, + thread_act_array_t *act_list, + mach_msg_type_number_t *act_listCnt +); + +/* Routine mach_ports_register */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_ports_register +( + task_t target_task, + mach_port_array_t init_port_set, + mach_msg_type_number_t init_port_setCnt +); + +/* Routine mach_ports_lookup */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_ports_lookup +( + task_t target_task, + mach_port_array_t *init_port_set, + mach_msg_type_number_t *init_port_setCnt +); + +/* Routine task_info */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_info +( + task_name_t target_task, + task_flavor_t flavor, + task_info_t task_info_out, + mach_msg_type_number_t *task_info_outCnt +); + +/* Routine task_set_info */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_set_info +( + task_t target_task, + task_flavor_t flavor, + task_info_t task_info_in, + mach_msg_type_number_t task_info_inCnt +); + +/* Routine task_suspend */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_suspend +( + task_t target_task +); + +/* Routine task_resume */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_resume +( + task_t target_task +); + +/* Routine task_get_special_port */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_get_special_port +( + task_t task, + int which_port, + mach_port_t *special_port +); + +/* Routine task_set_special_port */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_set_special_port +( + task_t task, + int which_port, + mach_port_t special_port +); + +/* Routine thread_create */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_create +( + task_t parent_task, + thread_act_t *child_act +); + +/* Routine thread_create_running */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_create_running +( + task_t parent_task, + thread_state_flavor_t flavor, + thread_state_t new_state, + mach_msg_type_number_t new_stateCnt, + thread_act_t *child_act +); + +/* Routine task_set_exception_ports */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_set_exception_ports +( + task_t task, + exception_mask_t exception_mask, + mach_port_t new_port, + exception_behavior_t behavior, + thread_state_flavor_t new_flavor +); + +/* Routine task_get_exception_ports */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_get_exception_ports +( + task_t task, + exception_mask_t exception_mask, + exception_mask_array_t masks, + mach_msg_type_number_t *masksCnt, + exception_handler_array_t old_handlers, + exception_behavior_array_t old_behaviors, + exception_flavor_array_t old_flavors +); + +/* Routine task_swap_exception_ports */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_swap_exception_ports +( + task_t task, + exception_mask_t exception_mask, + mach_port_t new_port, + exception_behavior_t behavior, + thread_state_flavor_t new_flavor, + exception_mask_array_t masks, + mach_msg_type_number_t *masksCnt, + exception_handler_array_t old_handlerss, + exception_behavior_array_t old_behaviors, + exception_flavor_array_t old_flavors +); + +/* Routine lock_set_create */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t lock_set_create +( + task_t task, + lock_set_t *new_lock_set, + int n_ulocks, + int policy +); + +/* Routine lock_set_destroy */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t lock_set_destroy +( + task_t task, + lock_set_t lock_set +); + +/* Routine semaphore_create */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t semaphore_create +( + task_t task, + semaphore_t *semaphore, + int policy, + int value +); + +/* Routine semaphore_destroy */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t semaphore_destroy +( + task_t task, + semaphore_t semaphore +); + +/* Routine task_policy_set */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_policy_set +( + task_t task, + task_policy_flavor_t flavor, + task_policy_t policy_info, + mach_msg_type_number_t policy_infoCnt +); + +/* Routine task_policy_get */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_policy_get +( + task_t task, + task_policy_flavor_t flavor, + task_policy_t policy_info, + mach_msg_type_number_t *policy_infoCnt, + boolean_t *get_default +); + +/* Routine task_sample */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_sample +( + task_t task, + mach_port_t reply +); + +/* Routine task_policy */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_policy +( + task_t task, + policy_t policy, + policy_base_t base, + mach_msg_type_number_t baseCnt, + boolean_t set_limit, + boolean_t change +); + +/* Routine task_set_emulation */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_set_emulation +( + task_t target_port, + vm_address_t routine_entry_pt, + int routine_number +); + +/* Routine task_get_emulation_vector */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_get_emulation_vector +( + task_t task, + int *vector_start, + emulation_vector_t *emulation_vector, + mach_msg_type_number_t *emulation_vectorCnt +); + +/* Routine task_set_emulation_vector */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_set_emulation_vector +( + task_t task, + int vector_start, + emulation_vector_t emulation_vector, + mach_msg_type_number_t emulation_vectorCnt +); + +/* Routine task_set_ras_pc */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_set_ras_pc +( + task_t target_task, + vm_address_t basepc, + vm_address_t boundspc +); + +/* Routine task_assign */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_assign +( + task_t task, + processor_set_t new_set, + boolean_t assign_threads +); + +/* Routine task_assign_default */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_assign_default +( + task_t task, + boolean_t assign_threads +); + +/* Routine task_get_assignment */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_get_assignment +( + task_t task, + processor_set_name_t *assigned_set +); + +/* Routine task_set_policy */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_set_policy +( + task_t task, + processor_set_t pset, + policy_t policy, + policy_base_t base, + mach_msg_type_number_t baseCnt, + policy_limit_t limit, + mach_msg_type_number_t limitCnt, + boolean_t change +); + +/* Routine task_get_state */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_get_state +( + task_t task, + thread_state_flavor_t flavor, + thread_state_t old_state, + mach_msg_type_number_t *old_stateCnt +); + +/* Routine task_set_state */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_set_state +( + task_t task, + thread_state_flavor_t flavor, + thread_state_t new_state, + mach_msg_type_number_t new_stateCnt +); + +__END_DECLS + +/********************** Caution **************************/ +/* The following data types should be used to calculate */ +/* maximum message sizes only. The actual message may be */ +/* smaller, and the position of the arguments within the */ +/* message layout may vary from what is presented here. */ +/* For example, if any of the arguments are variable- */ +/* sized, and less than the maximum is sent, the data */ +/* will be packed tight in the actual message to reduce */ +/* the presence of holes. */ +/********************** Caution **************************/ + +/* typedefs for all requests */ + +#ifndef __Request__task_subsystem__defined +#define __Request__task_subsystem__defined + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_ports_descriptor_t ledgers; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t ledgersCnt; + boolean_t inherit_memory; + } __Request__task_create_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__task_terminate_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__task_threads_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_ports_descriptor_t init_port_set; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t init_port_setCnt; + } __Request__mach_ports_register_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__mach_ports_lookup_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + task_flavor_t flavor; + mach_msg_type_number_t task_info_outCnt; + } __Request__task_info_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + task_flavor_t flavor; + mach_msg_type_number_t task_info_inCnt; + integer_t task_info_in[10]; + } __Request__task_set_info_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__task_suspend_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__task_resume_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + int which_port; + } __Request__task_get_special_port_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t special_port; + /* end of the kernel processed data */ + NDR_record_t NDR; + int which_port; + } __Request__task_set_special_port_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__thread_create_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + thread_state_flavor_t flavor; + mach_msg_type_number_t new_stateCnt; + natural_t new_state[144]; + } __Request__thread_create_running_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t new_port; + /* end of the kernel processed data */ + NDR_record_t NDR; + exception_mask_t exception_mask; + exception_behavior_t behavior; + thread_state_flavor_t new_flavor; + } __Request__task_set_exception_ports_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + exception_mask_t exception_mask; + } __Request__task_get_exception_ports_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t new_port; + /* end of the kernel processed data */ + NDR_record_t NDR; + exception_mask_t exception_mask; + exception_behavior_t behavior; + thread_state_flavor_t new_flavor; + } __Request__task_swap_exception_ports_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + int n_ulocks; + int policy; + } __Request__lock_set_create_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t lock_set; + /* end of the kernel processed data */ + } __Request__lock_set_destroy_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + int policy; + int value; + } __Request__semaphore_create_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t semaphore; + /* end of the kernel processed data */ + } __Request__semaphore_destroy_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + task_policy_flavor_t flavor; + mach_msg_type_number_t policy_infoCnt; + integer_t policy_info[16]; + } __Request__task_policy_set_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + task_policy_flavor_t flavor; + mach_msg_type_number_t policy_infoCnt; + boolean_t get_default; + } __Request__task_policy_get_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t reply; + /* end of the kernel processed data */ + } __Request__task_sample_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + policy_t policy; + mach_msg_type_number_t baseCnt; + integer_t base[5]; + boolean_t set_limit; + boolean_t change; + } __Request__task_policy_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + vm_address_t routine_entry_pt; + int routine_number; + } __Request__task_set_emulation_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__task_get_emulation_vector_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_descriptor_t emulation_vector; + /* end of the kernel processed data */ + NDR_record_t NDR; + int vector_start; + mach_msg_type_number_t emulation_vectorCnt; + } __Request__task_set_emulation_vector_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + vm_address_t basepc; + vm_address_t boundspc; + } __Request__task_set_ras_pc_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t new_set; + /* end of the kernel processed data */ + NDR_record_t NDR; + boolean_t assign_threads; + } __Request__task_assign_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + boolean_t assign_threads; + } __Request__task_assign_default_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__task_get_assignment_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t pset; + /* end of the kernel processed data */ + NDR_record_t NDR; + policy_t policy; + mach_msg_type_number_t baseCnt; + integer_t base[5]; + mach_msg_type_number_t limitCnt; + integer_t limit[1]; + boolean_t change; + } __Request__task_set_policy_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + thread_state_flavor_t flavor; + mach_msg_type_number_t old_stateCnt; + } __Request__task_get_state_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + thread_state_flavor_t flavor; + mach_msg_type_number_t new_stateCnt; + natural_t new_state[144]; + } __Request__task_set_state_t; +#ifdef __MigPackStructs +#pragma pack() +#endif +#endif /* !__Request__task_subsystem__defined */ + +/* union of all requests */ + +#ifndef __RequestUnion__task_subsystem__defined +#define __RequestUnion__task_subsystem__defined +union __RequestUnion__task_subsystem { + __Request__task_create_t Request_task_create; + __Request__task_terminate_t Request_task_terminate; + __Request__task_threads_t Request_task_threads; + __Request__mach_ports_register_t Request_mach_ports_register; + __Request__mach_ports_lookup_t Request_mach_ports_lookup; + __Request__task_info_t Request_task_info; + __Request__task_set_info_t Request_task_set_info; + __Request__task_suspend_t Request_task_suspend; + __Request__task_resume_t Request_task_resume; + __Request__task_get_special_port_t Request_task_get_special_port; + __Request__task_set_special_port_t Request_task_set_special_port; + __Request__thread_create_t Request_thread_create; + __Request__thread_create_running_t Request_thread_create_running; + __Request__task_set_exception_ports_t Request_task_set_exception_ports; + __Request__task_get_exception_ports_t Request_task_get_exception_ports; + __Request__task_swap_exception_ports_t Request_task_swap_exception_ports; + __Request__lock_set_create_t Request_lock_set_create; + __Request__lock_set_destroy_t Request_lock_set_destroy; + __Request__semaphore_create_t Request_semaphore_create; + __Request__semaphore_destroy_t Request_semaphore_destroy; + __Request__task_policy_set_t Request_task_policy_set; + __Request__task_policy_get_t Request_task_policy_get; + __Request__task_sample_t Request_task_sample; + __Request__task_policy_t Request_task_policy; + __Request__task_set_emulation_t Request_task_set_emulation; + __Request__task_get_emulation_vector_t Request_task_get_emulation_vector; + __Request__task_set_emulation_vector_t Request_task_set_emulation_vector; + __Request__task_set_ras_pc_t Request_task_set_ras_pc; + __Request__task_assign_t Request_task_assign; + __Request__task_assign_default_t Request_task_assign_default; + __Request__task_get_assignment_t Request_task_get_assignment; + __Request__task_set_policy_t Request_task_set_policy; + __Request__task_get_state_t Request_task_get_state; + __Request__task_set_state_t Request_task_set_state; +}; +#endif /* !__RequestUnion__task_subsystem__defined */ +/* typedefs for all replies */ + +#ifndef __Reply__task_subsystem__defined +#define __Reply__task_subsystem__defined + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t child_task; + /* end of the kernel processed data */ + } __Reply__task_create_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_terminate_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_ports_descriptor_t act_list; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t act_listCnt; + } __Reply__task_threads_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__mach_ports_register_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_ports_descriptor_t init_port_set; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t init_port_setCnt; + } __Reply__mach_ports_lookup_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_msg_type_number_t task_info_outCnt; + integer_t task_info_out[10]; + } __Reply__task_info_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_set_info_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_suspend_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_resume_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t special_port; + /* end of the kernel processed data */ + } __Reply__task_get_special_port_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_set_special_port_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t child_act; + /* end of the kernel processed data */ + } __Reply__thread_create_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t child_act; + /* end of the kernel processed data */ + } __Reply__thread_create_running_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_set_exception_ports_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t old_handlers[32]; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t masksCnt; + exception_mask_t masks[32]; + exception_behavior_t old_behaviors[32]; + thread_state_flavor_t old_flavors[32]; + } __Reply__task_get_exception_ports_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t old_handlerss[32]; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t masksCnt; + exception_mask_t masks[32]; + exception_behavior_t old_behaviors[32]; + thread_state_flavor_t old_flavors[32]; + } __Reply__task_swap_exception_ports_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t new_lock_set; + /* end of the kernel processed data */ + } __Reply__lock_set_create_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__lock_set_destroy_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t semaphore; + /* end of the kernel processed data */ + } __Reply__semaphore_create_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__semaphore_destroy_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_policy_set_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_msg_type_number_t policy_infoCnt; + integer_t policy_info[16]; + boolean_t get_default; + } __Reply__task_policy_get_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_sample_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_policy_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_set_emulation_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_descriptor_t emulation_vector; + /* end of the kernel processed data */ + NDR_record_t NDR; + int vector_start; + mach_msg_type_number_t emulation_vectorCnt; + } __Reply__task_get_emulation_vector_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_set_emulation_vector_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_set_ras_pc_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_assign_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_assign_default_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t assigned_set; + /* end of the kernel processed data */ + } __Reply__task_get_assignment_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_set_policy_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_msg_type_number_t old_stateCnt; + natural_t old_state[144]; + } __Reply__task_get_state_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_set_state_t; +#ifdef __MigPackStructs +#pragma pack() +#endif +#endif /* !__Reply__task_subsystem__defined */ + +/* union of all replies */ + +#ifndef __ReplyUnion__task_subsystem__defined +#define __ReplyUnion__task_subsystem__defined +union __ReplyUnion__task_subsystem { + __Reply__task_create_t Reply_task_create; + __Reply__task_terminate_t Reply_task_terminate; + __Reply__task_threads_t Reply_task_threads; + __Reply__mach_ports_register_t Reply_mach_ports_register; + __Reply__mach_ports_lookup_t Reply_mach_ports_lookup; + __Reply__task_info_t Reply_task_info; + __Reply__task_set_info_t Reply_task_set_info; + __Reply__task_suspend_t Reply_task_suspend; + __Reply__task_resume_t Reply_task_resume; + __Reply__task_get_special_port_t Reply_task_get_special_port; + __Reply__task_set_special_port_t Reply_task_set_special_port; + __Reply__thread_create_t Reply_thread_create; + __Reply__thread_create_running_t Reply_thread_create_running; + __Reply__task_set_exception_ports_t Reply_task_set_exception_ports; + __Reply__task_get_exception_ports_t Reply_task_get_exception_ports; + __Reply__task_swap_exception_ports_t Reply_task_swap_exception_ports; + __Reply__lock_set_create_t Reply_lock_set_create; + __Reply__lock_set_destroy_t Reply_lock_set_destroy; + __Reply__semaphore_create_t Reply_semaphore_create; + __Reply__semaphore_destroy_t Reply_semaphore_destroy; + __Reply__task_policy_set_t Reply_task_policy_set; + __Reply__task_policy_get_t Reply_task_policy_get; + __Reply__task_sample_t Reply_task_sample; + __Reply__task_policy_t Reply_task_policy; + __Reply__task_set_emulation_t Reply_task_set_emulation; + __Reply__task_get_emulation_vector_t Reply_task_get_emulation_vector; + __Reply__task_set_emulation_vector_t Reply_task_set_emulation_vector; + __Reply__task_set_ras_pc_t Reply_task_set_ras_pc; + __Reply__task_assign_t Reply_task_assign; + __Reply__task_assign_default_t Reply_task_assign_default; + __Reply__task_get_assignment_t Reply_task_get_assignment; + __Reply__task_set_policy_t Reply_task_set_policy; + __Reply__task_get_state_t Reply_task_get_state; + __Reply__task_set_state_t Reply_task_set_state; +}; +#endif /* !__RequestUnion__task_subsystem__defined */ + +#ifndef subsystem_to_name_map_task +#define subsystem_to_name_map_task \ + { "task_create", 3400 },\ + { "task_terminate", 3401 },\ + { "task_threads", 3402 },\ + { "mach_ports_register", 3403 },\ + { "mach_ports_lookup", 3404 },\ + { "task_info", 3405 },\ + { "task_set_info", 3406 },\ + { "task_suspend", 3407 },\ + { "task_resume", 3408 },\ + { "task_get_special_port", 3409 },\ + { "task_set_special_port", 3410 },\ + { "thread_create", 3411 },\ + { "thread_create_running", 3412 },\ + { "task_set_exception_ports", 3413 },\ + { "task_get_exception_ports", 3414 },\ + { "task_swap_exception_ports", 3415 },\ + { "lock_set_create", 3416 },\ + { "lock_set_destroy", 3417 },\ + { "semaphore_create", 3418 },\ + { "semaphore_destroy", 3419 },\ + { "task_policy_set", 3420 },\ + { "task_policy_get", 3421 },\ + { "task_sample", 3422 },\ + { "task_policy", 3423 },\ + { "task_set_emulation", 3424 },\ + { "task_get_emulation_vector", 3425 },\ + { "task_set_emulation_vector", 3426 },\ + { "task_set_ras_pc", 3427 },\ + { "task_assign", 3429 },\ + { "task_assign_default", 3430 },\ + { "task_get_assignment", 3431 },\ + { "task_set_policy", 3432 },\ + { "task_get_state", 3433 },\ + { "task_set_state", 3434 } +#endif + +#ifdef __AfterMigUserHeader +__AfterMigUserHeader +#endif /* __AfterMigUserHeader */ + +#endif /* _task_user_ */ Index: branches/azimutz/Cleancut/i386/include/mach/i386/vm_param.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/i386/vm_param.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/i386/vm_param.h (revision 885) @@ -0,0 +1,157 @@ +/* + * Copyright (c) 2000-2006 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,1988 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 Software.Distribution@CS.CMU.EDU + * 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. + */ + +/* + * Copyright (c) 1994 The University of Utah and + * the Computer Systems Laboratory at the University of Utah (CSL). + * All rights reserved. + * + * Permission to use, copy, modify and distribute this software is hereby + * granted provided that (1) source code retains these copyright, permission, + * and disclaimer notices, and (2) redistributions including binaries + * reproduce the notices in supporting documentation, and (3) all advertising + * materials mentioning features or use of this software display the following + * acknowledgement: ``This product includes software developed by the + * Computer Systems Laboratory at the University of Utah.'' + * + * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS + * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF + * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * CSL requests users of this software to return to csl-dist@cs.utah.edu any + * improvements that they make and grant CSL redistribution rights. + * + */ + +/* + * File: vm_param.h + * Author: Avadis Tevanian, Jr. + * Date: 1985 + * + * I386 machine dependent virtual memory parameters. + * Most of the declarations are preceeded by I386_ (or i386_) + * which is OK because only I386 specific code will be using + * them. + */ + +#ifndef _MACH_I386_VM_PARAM_H_ +#define _MACH_I386_VM_PARAM_H_ + +#define BYTE_SIZE 8 /* byte size in bits */ + +#define I386_PGBYTES 4096 /* bytes per 80386 page */ +#define I386_PGSHIFT 12 /* bitshift for pages */ + +#define PAGE_SIZE I386_PGBYTES +#define PAGE_SHIFT I386_PGSHIFT +#define PAGE_MASK (PAGE_SIZE - 1) + +#define I386_LPGBYTES 2*1024*1024 /* bytes per large page */ +#define I386_LPGSHIFT 21 /* bitshift for large pages */ +#define I386_LPGMASK (I386_LPGBYTES-1) + +/* + * Convert bytes to pages and convert pages to bytes. + * No rounding is used. + */ + +#define i386_btop(x) ((ppnum_t)((x) >> I386_PGSHIFT)) +#define machine_btop(x) i386_btop(x) +#define i386_ptob(x) (((pmap_paddr_t)(x)) << I386_PGSHIFT) + +/* + * Round off or truncate to the nearest page. These will work + * for either addresses or counts. (i.e. 1 byte rounds to 1 page + * bytes. + */ + +#define i386_round_page(x) ((((pmap_paddr_t)(x)) + I386_PGBYTES - 1) & \ + ~(I386_PGBYTES-1)) +#define i386_trunc_page(x) (((pmap_paddr_t)(x)) & ~(I386_PGBYTES-1)) + + + +#define VM_MIN_ADDRESS64 ((user_addr_t) 0x0000000000000000ULL) +/* + * default top of user stack... it grows down from here + */ +#define VM_USRSTACK64 ((user_addr_t) 0x00007FFF5FC00000ULL) +#define VM_DYLD64 ((user_addr_t) 0x00007FFF5FC00000ULL) +#define VM_LIB64_SHR_DATA ((user_addr_t) 0x00007FFF60000000ULL) +#define VM_LIB64_SHR_TEXT ((user_addr_t) 0x00007FFF80000000ULL) +/* + * the end of the usable user address space , for now about 47 bits. + * the 64 bit commpage is past the end of this + */ +#define VM_MAX_PAGE_ADDRESS ((user_addr_t) 0x00007FFFFFE00000ULL) +/* + * canonical end of user address space for limits checking + */ +#define VM_MAX_USER_PAGE_ADDRESS ((user_addr_t)0x00007FFFFFFFF000ULL) + + +/* system-wide values */ +#define MACH_VM_MIN_ADDRESS ((mach_vm_offset_t) 0) +#define MACH_VM_MAX_ADDRESS ((mach_vm_offset_t) VM_MAX_PAGE_ADDRESS) + +/* process-relative values (all 32-bit legacy only for now) */ +#define VM_MIN_ADDRESS ((vm_offset_t) 0) +#define VM_USRSTACK32 ((vm_offset_t) 0xC0000000) +#define VM_MAX_ADDRESS ((vm_offset_t) 0xFFE00000) + + + +#endif /* _MACH_I386_VM_PARAM_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/i386/vm_types.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/i386/vm_types.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/i386/vm_types.h (revision 885) @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2000-2006 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,1988 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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + */ + +/* + * File: vm_types.h + * Author: Avadis Tevanian, Jr. + * Date: 1985 + * + * Header file for VM data types. I386 version. + */ + +#ifndef _MACH_I386_VM_TYPES_H_ +#define _MACH_I386_VM_TYPES_H_ + +#ifndef ASSEMBLER + +#include <i386/_types.h> +#include <mach/i386/vm_param.h> +#include <stdint.h> + +/* + * natural_t and integer_t are Mach's legacy types for machine- + * independent integer types (unsigned, and signed, respectively). + * Their original purpose was to define other types in a machine/ + * compiler independent way. + * + * They also had an implicit "same size as pointer" characteristic + * to them (i.e. Mach's traditional types are very ILP32 or ILP64 + * centric). We support x86 ABIs that do not follow either of + * these models (specifically LP64). Therefore, we had to make a + * choice between making these types scale with pointers or stay + * tied to integers. Because their use is predominantly tied to + * to the size of an integer, we are keeping that association and + * breaking free from pointer size guarantees. + * + * New use of these types is discouraged. + */ +typedef __darwin_natural_t natural_t; +typedef int integer_t; + +/* + * A vm_offset_t is a type-neutral pointer, + * e.g. an offset into a virtual memory space. + */ +#ifdef __LP64__ +typedef uintptr_t vm_offset_t; +#else /* __LP64__ */ +typedef natural_t vm_offset_t; +#endif /* __LP64__ */ + +/* + * A vm_size_t is the proper type for e.g. + * expressing the difference between two + * vm_offset_t entities. + */ +#ifdef __LP64__ +typedef uintptr_t vm_size_t; +#else /* __LP64__ */ +typedef natural_t vm_size_t; +#endif /* __LP64__ */ + +/* + * This new type is independent of a particular vm map's + * implementation size - and represents appropriate types + * for all possible maps. This is used for interfaces + * where the size of the map is not known - or we don't + * want to have to distinguish. + */ +typedef uint64_t mach_vm_address_t; +typedef uint64_t mach_vm_offset_t; +typedef uint64_t mach_vm_size_t; + +typedef uint64_t vm_map_offset_t; +typedef uint64_t vm_map_address_t; +typedef uint64_t vm_map_size_t; + + +#endif /* ASSEMBLER */ + +/* + * If composing messages by hand (please do not) + */ +#define MACH_MSG_TYPE_INTEGER_T MACH_MSG_TYPE_INTEGER_32 + +#endif /* _MACH_I386_VM_TYPES_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/i386/_structs.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/i386/_structs.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/i386/_structs.h (revision 885) @@ -0,0 +1,561 @@ +/* + * Copyright (c) 2004-2006 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@ + */ + +#ifndef _MACH_I386__STRUCTS_H_ +#define _MACH_I386__STRUCTS_H_ + +/* + * i386 is the structure that is exported to user threads for + * use in status/mutate calls. This structure should never change. + * + */ + +#if __DARWIN_UNIX03 +#define _STRUCT_X86_THREAD_STATE32 struct __darwin_i386_thread_state +_STRUCT_X86_THREAD_STATE32 +{ + unsigned int __eax; + unsigned int __ebx; + unsigned int __ecx; + unsigned int __edx; + unsigned int __edi; + unsigned int __esi; + unsigned int __ebp; + unsigned int __esp; + unsigned int __ss; + unsigned int __eflags; + unsigned int __eip; + unsigned int __cs; + unsigned int __ds; + unsigned int __es; + unsigned int __fs; + unsigned int __gs; +}; +#else /* !__DARWIN_UNIX03 */ +#define _STRUCT_X86_THREAD_STATE32 struct i386_thread_state +_STRUCT_X86_THREAD_STATE32 +{ + unsigned int eax; + unsigned int ebx; + unsigned int ecx; + unsigned int edx; + unsigned int edi; + unsigned int esi; + unsigned int ebp; + unsigned int esp; + unsigned int ss; + unsigned int eflags; + unsigned int eip; + unsigned int cs; + unsigned int ds; + unsigned int es; + unsigned int fs; + unsigned int gs; +}; +#endif /* !__DARWIN_UNIX03 */ + +/* This structure should be double-word aligned for performance */ + +#if __DARWIN_UNIX03 +#define _STRUCT_FP_CONTROL struct __darwin_fp_control +_STRUCT_FP_CONTROL +{ + unsigned short __invalid :1, + __denorm :1, + __zdiv :1, + __ovrfl :1, + __undfl :1, + __precis :1, + :2, + __pc :2, +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define FP_PREC_24B 0 +#define FP_PREC_53B 2 +#define FP_PREC_64B 3 +#endif /* !_POSIX_C_SOURCE || _DARWIN_C_SOURCE */ + __rc :2, +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define FP_RND_NEAR 0 +#define FP_RND_DOWN 1 +#define FP_RND_UP 2 +#define FP_CHOP 3 +#endif /* !_POSIX_C_SOURCE || _DARWIN_C_SOURCE */ + /*inf*/ :1, + :3; +}; +typedef _STRUCT_FP_CONTROL __darwin_fp_control_t; +#else /* !__DARWIN_UNIX03 */ +#define _STRUCT_FP_CONTROL struct fp_control +_STRUCT_FP_CONTROL +{ + unsigned short invalid :1, + denorm :1, + zdiv :1, + ovrfl :1, + undfl :1, + precis :1, + :2, + pc :2, +#define FP_PREC_24B 0 +#define FP_PREC_53B 2 +#define FP_PREC_64B 3 + rc :2, +#define FP_RND_NEAR 0 +#define FP_RND_DOWN 1 +#define FP_RND_UP 2 +#define FP_CHOP 3 + /*inf*/ :1, + :3; +}; +typedef _STRUCT_FP_CONTROL fp_control_t; +#endif /* !__DARWIN_UNIX03 */ + +/* + * Status word. + */ + +#if __DARWIN_UNIX03 +#define _STRUCT_FP_STATUS struct __darwin_fp_status +_STRUCT_FP_STATUS +{ + unsigned short __invalid :1, + __denorm :1, + __zdiv :1, + __ovrfl :1, + __undfl :1, + __precis :1, + __stkflt :1, + __errsumm :1, + __c0 :1, + __c1 :1, + __c2 :1, + __tos :3, + __c3 :1, + __busy :1; +}; +typedef _STRUCT_FP_STATUS __darwin_fp_status_t; +#else /* !__DARWIN_UNIX03 */ +#define _STRUCT_FP_STATUS struct fp_status +_STRUCT_FP_STATUS +{ + unsigned short invalid :1, + denorm :1, + zdiv :1, + ovrfl :1, + undfl :1, + precis :1, + stkflt :1, + errsumm :1, + c0 :1, + c1 :1, + c2 :1, + tos :3, + c3 :1, + busy :1; +}; +typedef _STRUCT_FP_STATUS fp_status_t; +#endif /* !__DARWIN_UNIX03 */ + +/* defn of 80bit x87 FPU or MMX register */ + +#if __DARWIN_UNIX03 +#define _STRUCT_MMST_REG struct __darwin_mmst_reg +_STRUCT_MMST_REG +{ + char __mmst_reg[10]; + char __mmst_rsrv[6]; +}; +#else /* !__DARWIN_UNIX03 */ +#define _STRUCT_MMST_REG struct mmst_reg +_STRUCT_MMST_REG +{ + char mmst_reg[10]; + char mmst_rsrv[6]; +}; +#endif /* !__DARWIN_UNIX03 */ + + +/* defn of 128 bit XMM regs */ + +#if __DARWIN_UNIX03 +#define _STRUCT_XMM_REG struct __darwin_xmm_reg +_STRUCT_XMM_REG +{ + char __xmm_reg[16]; +}; +#else /* !__DARWIN_UNIX03 */ +#define _STRUCT_XMM_REG struct xmm_reg +_STRUCT_XMM_REG +{ + char xmm_reg[16]; +}; +#endif /* !__DARWIN_UNIX03 */ + +/* + * Floating point state. + */ + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define FP_STATE_BYTES 512 /* number of chars worth of data from fpu_fcw */ +#endif /* !_POSIX_C_SOURCE || _DARWIN_C_SOURCE */ + +#if __DARWIN_UNIX03 +#define _STRUCT_X86_FLOAT_STATE32 struct __darwin_i386_float_state +_STRUCT_X86_FLOAT_STATE32 +{ + int __fpu_reserved[2]; + _STRUCT_FP_CONTROL __fpu_fcw; /* x87 FPU control word */ + _STRUCT_FP_STATUS __fpu_fsw; /* x87 FPU status word */ + __uint8_t __fpu_ftw; /* x87 FPU tag word */ + __uint8_t __fpu_rsrv1; /* reserved */ + __uint16_t __fpu_fop; /* x87 FPU Opcode */ + __uint32_t __fpu_ip; /* x87 FPU Instruction Pointer offset */ + __uint16_t __fpu_cs; /* x87 FPU Instruction Pointer Selector */ + __uint16_t __fpu_rsrv2; /* reserved */ + __uint32_t __fpu_dp; /* x87 FPU Instruction Operand(Data) Pointer offset */ + __uint16_t __fpu_ds; /* x87 FPU Instruction Operand(Data) Pointer Selector */ + __uint16_t __fpu_rsrv3; /* reserved */ + __uint32_t __fpu_mxcsr; /* MXCSR Register state */ + __uint32_t __fpu_mxcsrmask; /* MXCSR mask */ + _STRUCT_MMST_REG __fpu_stmm0; /* ST0/MM0 */ + _STRUCT_MMST_REG __fpu_stmm1; /* ST1/MM1 */ + _STRUCT_MMST_REG __fpu_stmm2; /* ST2/MM2 */ + _STRUCT_MMST_REG __fpu_stmm3; /* ST3/MM3 */ + _STRUCT_MMST_REG __fpu_stmm4; /* ST4/MM4 */ + _STRUCT_MMST_REG __fpu_stmm5; /* ST5/MM5 */ + _STRUCT_MMST_REG __fpu_stmm6; /* ST6/MM6 */ + _STRUCT_MMST_REG __fpu_stmm7; /* ST7/MM7 */ + _STRUCT_XMM_REG __fpu_xmm0; /* XMM 0 */ + _STRUCT_XMM_REG __fpu_xmm1; /* XMM 1 */ + _STRUCT_XMM_REG __fpu_xmm2; /* XMM 2 */ + _STRUCT_XMM_REG __fpu_xmm3; /* XMM 3 */ + _STRUCT_XMM_REG __fpu_xmm4; /* XMM 4 */ + _STRUCT_XMM_REG __fpu_xmm5; /* XMM 5 */ + _STRUCT_XMM_REG __fpu_xmm6; /* XMM 6 */ + _STRUCT_XMM_REG __fpu_xmm7; /* XMM 7 */ + char __fpu_rsrv4[14*16]; /* reserved */ + int __fpu_reserved1; +}; +#else /* !__DARWIN_UNIX03 */ +#define _STRUCT_X86_FLOAT_STATE32 struct i386_float_state +_STRUCT_X86_FLOAT_STATE32 +{ + int fpu_reserved[2]; + _STRUCT_FP_CONTROL fpu_fcw; /* x87 FPU control word */ + _STRUCT_FP_STATUS fpu_fsw; /* x87 FPU status word */ + __uint8_t fpu_ftw; /* x87 FPU tag word */ + __uint8_t fpu_rsrv1; /* reserved */ + __uint16_t fpu_fop; /* x87 FPU Opcode */ + __uint32_t fpu_ip; /* x87 FPU Instruction Pointer offset */ + __uint16_t fpu_cs; /* x87 FPU Instruction Pointer Selector */ + __uint16_t fpu_rsrv2; /* reserved */ + __uint32_t fpu_dp; /* x87 FPU Instruction Operand(Data) Pointer offset */ + __uint16_t fpu_ds; /* x87 FPU Instruction Operand(Data) Pointer Selector */ + __uint16_t fpu_rsrv3; /* reserved */ + __uint32_t fpu_mxcsr; /* MXCSR Register state */ + __uint32_t fpu_mxcsrmask; /* MXCSR mask */ + _STRUCT_MMST_REG fpu_stmm0; /* ST0/MM0 */ + _STRUCT_MMST_REG fpu_stmm1; /* ST1/MM1 */ + _STRUCT_MMST_REG fpu_stmm2; /* ST2/MM2 */ + _STRUCT_MMST_REG fpu_stmm3; /* ST3/MM3 */ + _STRUCT_MMST_REG fpu_stmm4; /* ST4/MM4 */ + _STRUCT_MMST_REG fpu_stmm5; /* ST5/MM5 */ + _STRUCT_MMST_REG fpu_stmm6; /* ST6/MM6 */ + _STRUCT_MMST_REG fpu_stmm7; /* ST7/MM7 */ + _STRUCT_XMM_REG fpu_xmm0; /* XMM 0 */ + _STRUCT_XMM_REG fpu_xmm1; /* XMM 1 */ + _STRUCT_XMM_REG fpu_xmm2; /* XMM 2 */ + _STRUCT_XMM_REG fpu_xmm3; /* XMM 3 */ + _STRUCT_XMM_REG fpu_xmm4; /* XMM 4 */ + _STRUCT_XMM_REG fpu_xmm5; /* XMM 5 */ + _STRUCT_XMM_REG fpu_xmm6; /* XMM 6 */ + _STRUCT_XMM_REG fpu_xmm7; /* XMM 7 */ + char fpu_rsrv4[14*16]; /* reserved */ + int fpu_reserved1; +}; +#endif /* !__DARWIN_UNIX03 */ + +#if __DARWIN_UNIX03 +#define _STRUCT_X86_EXCEPTION_STATE32 struct __darwin_i386_exception_state +_STRUCT_X86_EXCEPTION_STATE32 +{ + unsigned int __trapno; + unsigned int __err; + unsigned int __faultvaddr; +}; +#else /* !__DARWIN_UNIX03 */ +#define _STRUCT_X86_EXCEPTION_STATE32 struct i386_exception_state +_STRUCT_X86_EXCEPTION_STATE32 +{ + unsigned int trapno; + unsigned int err; + unsigned int faultvaddr; +}; +#endif /* !__DARWIN_UNIX03 */ + +#if __DARWIN_UNIX03 +#define _STRUCT_X86_DEBUG_STATE32 struct __darwin_x86_debug_state32 +_STRUCT_X86_DEBUG_STATE32 +{ + unsigned int __dr0; + unsigned int __dr1; + unsigned int __dr2; + unsigned int __dr3; + unsigned int __dr4; + unsigned int __dr5; + unsigned int __dr6; + unsigned int __dr7; +}; +#else /* !__DARWIN_UNIX03 */ +#define _STRUCT_X86_DEBUG_STATE32 struct x86_debug_state32 +_STRUCT_X86_DEBUG_STATE32 +{ + unsigned int dr0; + unsigned int dr1; + unsigned int dr2; + unsigned int dr3; + unsigned int dr4; + unsigned int dr5; + unsigned int dr6; + unsigned int dr7; +}; +#endif /* !__DARWIN_UNIX03 */ + +/* + * 64 bit versions of the above + */ + +#if __DARWIN_UNIX03 +#define _STRUCT_X86_THREAD_STATE64 struct __darwin_x86_thread_state64 +_STRUCT_X86_THREAD_STATE64 +{ + __uint64_t __rax; + __uint64_t __rbx; + __uint64_t __rcx; + __uint64_t __rdx; + __uint64_t __rdi; + __uint64_t __rsi; + __uint64_t __rbp; + __uint64_t __rsp; + __uint64_t __r8; + __uint64_t __r9; + __uint64_t __r10; + __uint64_t __r11; + __uint64_t __r12; + __uint64_t __r13; + __uint64_t __r14; + __uint64_t __r15; + __uint64_t __rip; + __uint64_t __rflags; + __uint64_t __cs; + __uint64_t __fs; + __uint64_t __gs; +}; +#else /* !__DARWIN_UNIX03 */ +#define _STRUCT_X86_THREAD_STATE64 struct x86_thread_state64 +_STRUCT_X86_THREAD_STATE64 +{ + __uint64_t rax; + __uint64_t rbx; + __uint64_t rcx; + __uint64_t rdx; + __uint64_t rdi; + __uint64_t rsi; + __uint64_t rbp; + __uint64_t rsp; + __uint64_t r8; + __uint64_t r9; + __uint64_t r10; + __uint64_t r11; + __uint64_t r12; + __uint64_t r13; + __uint64_t r14; + __uint64_t r15; + __uint64_t rip; + __uint64_t rflags; + __uint64_t cs; + __uint64_t fs; + __uint64_t gs; +}; +#endif /* !__DARWIN_UNIX03 */ + + +#if __DARWIN_UNIX03 +#define _STRUCT_X86_FLOAT_STATE64 struct __darwin_x86_float_state64 +_STRUCT_X86_FLOAT_STATE64 +{ + int __fpu_reserved[2]; + _STRUCT_FP_CONTROL __fpu_fcw; /* x87 FPU control word */ + _STRUCT_FP_STATUS __fpu_fsw; /* x87 FPU status word */ + __uint8_t __fpu_ftw; /* x87 FPU tag word */ + __uint8_t __fpu_rsrv1; /* reserved */ + __uint16_t __fpu_fop; /* x87 FPU Opcode */ + + /* x87 FPU Instruction Pointer */ + __uint32_t __fpu_ip; /* offset */ + __uint16_t __fpu_cs; /* Selector */ + + __uint16_t __fpu_rsrv2; /* reserved */ + + /* x87 FPU Instruction Operand(Data) Pointer */ + __uint32_t __fpu_dp; /* offset */ + __uint16_t __fpu_ds; /* Selector */ + + __uint16_t __fpu_rsrv3; /* reserved */ + __uint32_t __fpu_mxcsr; /* MXCSR Register state */ + __uint32_t __fpu_mxcsrmask; /* MXCSR mask */ + _STRUCT_MMST_REG __fpu_stmm0; /* ST0/MM0 */ + _STRUCT_MMST_REG __fpu_stmm1; /* ST1/MM1 */ + _STRUCT_MMST_REG __fpu_stmm2; /* ST2/MM2 */ + _STRUCT_MMST_REG __fpu_stmm3; /* ST3/MM3 */ + _STRUCT_MMST_REG __fpu_stmm4; /* ST4/MM4 */ + _STRUCT_MMST_REG __fpu_stmm5; /* ST5/MM5 */ + _STRUCT_MMST_REG __fpu_stmm6; /* ST6/MM6 */ + _STRUCT_MMST_REG __fpu_stmm7; /* ST7/MM7 */ + _STRUCT_XMM_REG __fpu_xmm0; /* XMM 0 */ + _STRUCT_XMM_REG __fpu_xmm1; /* XMM 1 */ + _STRUCT_XMM_REG __fpu_xmm2; /* XMM 2 */ + _STRUCT_XMM_REG __fpu_xmm3; /* XMM 3 */ + _STRUCT_XMM_REG __fpu_xmm4; /* XMM 4 */ + _STRUCT_XMM_REG __fpu_xmm5; /* XMM 5 */ + _STRUCT_XMM_REG __fpu_xmm6; /* XMM 6 */ + _STRUCT_XMM_REG __fpu_xmm7; /* XMM 7 */ + _STRUCT_XMM_REG __fpu_xmm8; /* XMM 8 */ + _STRUCT_XMM_REG __fpu_xmm9; /* XMM 9 */ + _STRUCT_XMM_REG __fpu_xmm10; /* XMM 10 */ + _STRUCT_XMM_REG __fpu_xmm11; /* XMM 11 */ + _STRUCT_XMM_REG __fpu_xmm12; /* XMM 12 */ + _STRUCT_XMM_REG __fpu_xmm13; /* XMM 13 */ + _STRUCT_XMM_REG __fpu_xmm14; /* XMM 14 */ + _STRUCT_XMM_REG __fpu_xmm15; /* XMM 15 */ + char __fpu_rsrv4[6*16]; /* reserved */ + int __fpu_reserved1; +}; +#else /* !__DARWIN_UNIX03 */ +#define _STRUCT_X86_FLOAT_STATE64 struct x86_float_state64 +_STRUCT_X86_FLOAT_STATE64 +{ + int fpu_reserved[2]; + _STRUCT_FP_CONTROL fpu_fcw; /* x87 FPU control word */ + _STRUCT_FP_STATUS fpu_fsw; /* x87 FPU status word */ + __uint8_t fpu_ftw; /* x87 FPU tag word */ + __uint8_t fpu_rsrv1; /* reserved */ + __uint16_t fpu_fop; /* x87 FPU Opcode */ + + /* x87 FPU Instruction Pointer */ + __uint32_t fpu_ip; /* offset */ + __uint16_t fpu_cs; /* Selector */ + + __uint16_t fpu_rsrv2; /* reserved */ + + /* x87 FPU Instruction Operand(Data) Pointer */ + __uint32_t fpu_dp; /* offset */ + __uint16_t fpu_ds; /* Selector */ + + __uint16_t fpu_rsrv3; /* reserved */ + __uint32_t fpu_mxcsr; /* MXCSR Register state */ + __uint32_t fpu_mxcsrmask; /* MXCSR mask */ + _STRUCT_MMST_REG fpu_stmm0; /* ST0/MM0 */ + _STRUCT_MMST_REG fpu_stmm1; /* ST1/MM1 */ + _STRUCT_MMST_REG fpu_stmm2; /* ST2/MM2 */ + _STRUCT_MMST_REG fpu_stmm3; /* ST3/MM3 */ + _STRUCT_MMST_REG fpu_stmm4; /* ST4/MM4 */ + _STRUCT_MMST_REG fpu_stmm5; /* ST5/MM5 */ + _STRUCT_MMST_REG fpu_stmm6; /* ST6/MM6 */ + _STRUCT_MMST_REG fpu_stmm7; /* ST7/MM7 */ + _STRUCT_XMM_REG fpu_xmm0; /* XMM 0 */ + _STRUCT_XMM_REG fpu_xmm1; /* XMM 1 */ + _STRUCT_XMM_REG fpu_xmm2; /* XMM 2 */ + _STRUCT_XMM_REG fpu_xmm3; /* XMM 3 */ + _STRUCT_XMM_REG fpu_xmm4; /* XMM 4 */ + _STRUCT_XMM_REG fpu_xmm5; /* XMM 5 */ + _STRUCT_XMM_REG fpu_xmm6; /* XMM 6 */ + _STRUCT_XMM_REG fpu_xmm7; /* XMM 7 */ + _STRUCT_XMM_REG fpu_xmm8; /* XMM 8 */ + _STRUCT_XMM_REG fpu_xmm9; /* XMM 9 */ + _STRUCT_XMM_REG fpu_xmm10; /* XMM 10 */ + _STRUCT_XMM_REG fpu_xmm11; /* XMM 11 */ + _STRUCT_XMM_REG fpu_xmm12; /* XMM 12 */ + _STRUCT_XMM_REG fpu_xmm13; /* XMM 13 */ + _STRUCT_XMM_REG fpu_xmm14; /* XMM 14 */ + _STRUCT_XMM_REG fpu_xmm15; /* XMM 15 */ + char fpu_rsrv4[6*16]; /* reserved */ + int fpu_reserved1; +}; +#endif /* !__DARWIN_UNIX03 */ + +#if __DARWIN_UNIX03 +#define _STRUCT_X86_EXCEPTION_STATE64 struct __darwin_x86_exception_state64 +_STRUCT_X86_EXCEPTION_STATE64 +{ + unsigned int __trapno; + unsigned int __err; + __uint64_t __faultvaddr; +}; +#else /* !__DARWIN_UNIX03 */ +#define _STRUCT_X86_EXCEPTION_STATE64 struct x86_exception_state64 +_STRUCT_X86_EXCEPTION_STATE64 +{ + unsigned int trapno; + unsigned int err; + __uint64_t faultvaddr; +}; +#endif /* !__DARWIN_UNIX03 */ + +#if __DARWIN_UNIX03 +#define _STRUCT_X86_DEBUG_STATE64 struct __darwin_x86_debug_state64 +_STRUCT_X86_DEBUG_STATE64 +{ + __uint64_t __dr0; + __uint64_t __dr1; + __uint64_t __dr2; + __uint64_t __dr3; + __uint64_t __dr4; + __uint64_t __dr5; + __uint64_t __dr6; + __uint64_t __dr7; +}; +#else /* !__DARWIN_UNIX03 */ +#define _STRUCT_X86_DEBUG_STATE64 struct x86_debug_state64 +_STRUCT_X86_DEBUG_STATE64 +{ + __uint64_t dr0; + __uint64_t dr1; + __uint64_t dr2; + __uint64_t dr3; + __uint64_t dr4; + __uint64_t dr5; + __uint64_t dr6; + __uint64_t dr7; +}; +#endif /* !__DARWIN_UNIX03 */ + +#endif /* _MACH_I386__STRUCTS_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/i386/thread_state.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/i386/thread_state.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/i386/thread_state.h (revision 885) @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2000-2006 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@ + */ + +#ifndef _MACH_I386_THREAD_STATE_H_ +#define _MACH_I386_THREAD_STATE_H_ + +/* Size of maximum exported thread state in words */ +#define I386_THREAD_STATE_MAX (144) /* Size of biggest state possible */ + +#if defined (__i386__) || defined(__x86_64__) +#define THREAD_STATE_MAX I386_THREAD_STATE_MAX +#endif + +#endif /* _MACH_I386_THREAD_STATE_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/i386/thread_status.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/i386/thread_status.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/i386/thread_status.h (revision 885) @@ -0,0 +1,297 @@ +/* + * Copyright (c) 2000-2006 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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + */ +/* + * File: thread_status.h + * Author: Avadis Tevanian, Jr. + * Date: 1985 + * + * This file contains the structure definitions for the thread + * state as applied to I386 processors. + */ + +#ifndef _MACH_I386_THREAD_STATUS_H_ +#define _MACH_I386_THREAD_STATUS_H_ + +#include <mach/i386/_structs.h> +#include <mach/message.h> +#include <mach/i386/fp_reg.h> +#include <mach/i386/thread_state.h> +#include <i386/eflags.h> + +/* + * the i386_xxxx form is kept for legacy purposes since these types + * are externally known... eventually they should be deprecated. + * our internal implementation has moved to the following naming convention + * + * x86_xxxx32 names are used to deal with 32 bit states + * x86_xxxx64 names are used to deal with 64 bit states + * x86_xxxx names are used to deal with either 32 or 64 bit states + * via a self-describing mechanism + */ + +/* + * these are the legacy names which should be deprecated in the future + * they are externally known which is the only reason we don't just get + * rid of them + */ +#define i386_THREAD_STATE 1 +#define i386_FLOAT_STATE 2 +#define i386_EXCEPTION_STATE 3 + +/* + * THREAD_STATE_FLAVOR_LIST 0 + * these are the supported flavors + */ +#define x86_THREAD_STATE32 1 +#define x86_FLOAT_STATE32 2 +#define x86_EXCEPTION_STATE32 3 +#define x86_THREAD_STATE64 4 +#define x86_FLOAT_STATE64 5 +#define x86_EXCEPTION_STATE64 6 +#define x86_THREAD_STATE 7 +#define x86_FLOAT_STATE 8 +#define x86_EXCEPTION_STATE 9 +#define x86_DEBUG_STATE32 10 +#define x86_DEBUG_STATE64 11 +#define x86_DEBUG_STATE 12 +#define THREAD_STATE_NONE 13 + +/* + * Largest state on this machine: + * (be sure mach/machine/thread_state.h matches!) + */ +#define THREAD_MACHINE_STATE_MAX THREAD_STATE_MAX + +/* + * VALID_THREAD_STATE_FLAVOR is a platform specific macro that when passed + * an exception flavor will return if that is a defined flavor for that + * platform. The macro must be manually updated to include all of the valid + * exception flavors as defined above. + */ +#define VALID_THREAD_STATE_FLAVOR(x) \ + ((x == x86_THREAD_STATE32) || \ + (x == x86_FLOAT_STATE32) || \ + (x == x86_EXCEPTION_STATE32) || \ + (x == x86_DEBUG_STATE32) || \ + (x == x86_THREAD_STATE64) || \ + (x == x86_FLOAT_STATE64) || \ + (x == x86_EXCEPTION_STATE64) || \ + (x == x86_DEBUG_STATE64) || \ + (x == x86_THREAD_STATE) || \ + (x == x86_FLOAT_STATE) || \ + (x == x86_EXCEPTION_STATE) || \ + (x == x86_DEBUG_STATE) || \ + (x == THREAD_STATE_NONE)) + +struct x86_state_hdr { + int flavor; + int count; +}; +typedef struct x86_state_hdr x86_state_hdr_t; + +/* + * Default segment register values. + */ + +#define USER_CODE_SELECTOR 0x0017 +#define USER_DATA_SELECTOR 0x001f +#define KERN_CODE_SELECTOR 0x0008 +#define KERN_DATA_SELECTOR 0x0010 + +/* + * to be deprecated in the future + */ +typedef _STRUCT_X86_THREAD_STATE32 i386_thread_state_t; +#define i386_THREAD_STATE_COUNT ((mach_msg_type_number_t) \ + ( sizeof (i386_thread_state_t) / sizeof (int) )) + +typedef _STRUCT_X86_THREAD_STATE32 x86_thread_state32_t; +#define x86_THREAD_STATE32_COUNT ((mach_msg_type_number_t) \ + ( sizeof (x86_thread_state32_t) / sizeof (int) )) + +/* + * to be deprecated in the future + */ +typedef _STRUCT_X86_FLOAT_STATE32 i386_float_state_t; +#define i386_FLOAT_STATE_COUNT ((mach_msg_type_number_t) \ + (sizeof(i386_float_state_t)/sizeof(unsigned int))) + +typedef _STRUCT_X86_FLOAT_STATE32 x86_float_state32_t; +#define x86_FLOAT_STATE32_COUNT ((mach_msg_type_number_t) \ + (sizeof(x86_float_state32_t)/sizeof(unsigned int))) + +/* + * to be deprecated in the future + */ +typedef _STRUCT_X86_EXCEPTION_STATE32 i386_exception_state_t; +#define i386_EXCEPTION_STATE_COUNT ((mach_msg_type_number_t) \ + ( sizeof (i386_exception_state_t) / sizeof (int) )) + +typedef _STRUCT_X86_EXCEPTION_STATE32 x86_exception_state32_t; +#define x86_EXCEPTION_STATE32_COUNT ((mach_msg_type_number_t) \ + ( sizeof (x86_exception_state32_t) / sizeof (int) )) + +#define I386_EXCEPTION_STATE_COUNT i386_EXCEPTION_STATE_COUNT + +typedef _STRUCT_X86_DEBUG_STATE32 x86_debug_state32_t; +#define x86_DEBUG_STATE32_COUNT ((mach_msg_type_number_t) \ + ( sizeof (x86_debug_state32_t) / sizeof (int) )) + +#define X86_DEBUG_STATE32_COUNT x86_DEBUG_STATE32_COUNT + +typedef _STRUCT_X86_THREAD_STATE64 x86_thread_state64_t; +#define x86_THREAD_STATE64_COUNT ((mach_msg_type_number_t) \ + ( sizeof (x86_thread_state64_t) / sizeof (int) )) + +typedef _STRUCT_X86_FLOAT_STATE64 x86_float_state64_t; +#define x86_FLOAT_STATE64_COUNT ((mach_msg_type_number_t) \ + (sizeof(x86_float_state64_t)/sizeof(unsigned int))) + +typedef _STRUCT_X86_EXCEPTION_STATE64 x86_exception_state64_t; +#define x86_EXCEPTION_STATE64_COUNT ((mach_msg_type_number_t) \ + ( sizeof (x86_exception_state64_t) / sizeof (int) )) + +#define X86_EXCEPTION_STATE64_COUNT x86_EXCEPTION_STATE64_COUNT + +typedef _STRUCT_X86_DEBUG_STATE64 x86_debug_state64_t; +#define x86_DEBUG_STATE64_COUNT ((mach_msg_type_number_t) \ + ( sizeof (x86_debug_state64_t) / sizeof (int) )) + +#define X86_DEBUG_STATE64_COUNT x86_DEBUG_STATE64_COUNT + +/* + * Combined thread, float and exception states + */ +struct x86_thread_state { + x86_state_hdr_t tsh; + union { + x86_thread_state32_t ts32; + x86_thread_state64_t ts64; + } uts; +}; + +struct x86_float_state { + x86_state_hdr_t fsh; + union { + x86_float_state32_t fs32; + x86_float_state64_t fs64; + } ufs; +}; + +struct x86_exception_state { + x86_state_hdr_t esh; + union { + x86_exception_state32_t es32; + x86_exception_state64_t es64; + } ues; +}; + +struct x86_debug_state { + x86_state_hdr_t dsh; + union { + x86_debug_state32_t ds32; + x86_debug_state64_t ds64; + } uds; +}; + +typedef struct x86_thread_state x86_thread_state_t; +#define x86_THREAD_STATE_COUNT ((mach_msg_type_number_t) \ + ( sizeof (x86_thread_state_t) / sizeof (int) )) + +typedef struct x86_float_state x86_float_state_t; +#define x86_FLOAT_STATE_COUNT ((mach_msg_type_number_t) \ + (sizeof(x86_float_state_t)/sizeof(unsigned int))) + +typedef struct x86_exception_state x86_exception_state_t; +#define x86_EXCEPTION_STATE_COUNT ((mach_msg_type_number_t) \ + (sizeof(x86_exception_state_t)/sizeof(unsigned int))) + +typedef struct x86_debug_state x86_debug_state_t; +#define x86_DEBUG_STATE_COUNT ((mach_msg_type_number_t) \ + (sizeof(x86_debug_state_t)/sizeof(unsigned int))) + +/* + * Machine-independent way for servers and Mach's exception mechanism to + * choose the most efficient state flavor for exception RPC's: + */ +#define MACHINE_THREAD_STATE x86_THREAD_STATE +#define MACHINE_THREAD_STATE_COUNT x86_THREAD_STATE_COUNT + +/* + * when reloading the segment registers on + * a return out of the kernel, we may take + * a GeneralProtection or SegmentNotPresent + * fault if one or more of the segment + * registers in the saved state was improperly + * specified via an x86_THREAD_STATE32 call + * the frame we push on top of the existing + * save area looks like this... we need to + * carry this as part of the save area + * in case we get hit so that we have a big + * enough stack + */ +struct x86_seg_load_fault32 { + unsigned int trapno; + unsigned int err; + unsigned int eip; + unsigned int cs; + unsigned int efl; +}; + + +#endif /* _MACH_I386_THREAD_STATUS_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/i386/boolean.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/i386/boolean.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/i386/boolean.h (revision 885) @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2000-2006 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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + */ + +/* + * File: boolean.h + * + * Boolean type, for I386. + */ + +#ifndef _MACH_I386_BOOLEAN_H_ +#define _MACH_I386_BOOLEAN_H_ + +#if defined(__x86_64__) && !defined(KERNEL) +typedef unsigned int boolean_t; +#else +typedef int boolean_t; +#endif + +#endif /* _MACH_I386_BOOLEAN_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/i386/asm.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/i386/asm.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/i386/asm.h (revision 885) @@ -0,0 +1,308 @@ +/* + * Copyright (c) 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@ + */ +/* + * @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 Software.Distribution@CS.CMU.EDU + * 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. + */ + +#ifndef _I386_ASM_H_ +#define _I386_ASM_H_ + +#ifdef _KERNEL +#include <gprof.h> +#endif /* _KERNEL */ + +#ifdef MACH_KERNEL +#include <mach_kdb.h> +#else /* !MACH_KERNEL */ +#define MACH_KDB 0 +#endif /* !MACH_KERNEL */ + + +#if defined(MACH_KERNEL) || defined(_KERNEL) +#include <gprof.h> +#endif /* MACH_KERNEL || _KERNEL */ + +#if defined(__i386__) + +#define S_PC (%esp) +#define S_ARG0 4(%esp) +#define S_ARG1 8(%esp) +#define S_ARG2 12(%esp) +#define S_ARG3 16(%esp) +#define S_ARG4 20(%esp) + +#define FRAME pushl %ebp; movl %esp, %ebp +#define EMARF leave + +#define B_LINK (%ebp) +#define B_PC 4(%ebp) +#define B_ARG0 8(%ebp) +#define B_ARG1 12(%ebp) +#define B_ARG2 16(%ebp) +#define B_ARG3 20(%ebp) + +#elif defined(__x86_64__) + +#define S_PC (%rsp) + +#define FRAME pushq %rbp; movq %rsp, %rbp +#define EMARF leave + +#define B_LINK (%rbp) +#define B_PC 8(%rbp) + +#else +#error unsupported architecture +#endif + +/* There is another definition of ALIGN for .c sources */ +#ifdef ASSEMBLER +#define ALIGN 4,0x90 +#endif /* ASSEMBLER */ + +#ifndef FALIGN +#define FALIGN ALIGN +#endif + +#define LB(x,n) n +#if __STDC__ +#ifndef __NO_UNDERSCORES__ +#define LCL(x) L ## x +#define EXT(x) _ ## x +#define LEXT(x) _ ## x ## : +#else +#define LCL(x) .L ## x +#define EXT(x) x +#define LEXT(x) x ## : +#endif +#define LBc(x,n) n ## : +#define LBb(x,n) n ## b +#define LBf(x,n) n ## f +#else /* __STDC__ */ +#ifndef __NO_UNDERSCORES__ +#define LCL(x) L/**/x +#define EXT(x) _/**/x +#define LEXT(x) _/**/x/**/: +#else /* __NO_UNDERSCORES__ */ +#define LCL(x) .L/**/x +#define EXT(x) x +#define LEXT(x) x/**/: +#endif /* __NO_UNDERSCORES__ */ +#define LBc(x,n) n/**/: +#define LBb(x,n) n/**/b +#define LBf(x,n) n/**/f +#endif /* __STDC__ */ + +#define SVC .byte 0x9a; .long 0; .word 0x7 + +#define RPC_SVC .byte 0x9a; .long 0; .word 0xf + +#define String .asciz +#define Value .word +#define Times(a,b) (a*b) +#define Divide(a,b) (a/b) + +#define INB inb %dx, %al +#define OUTB outb %al, %dx +#define INL inl %dx, %eax +#define OUTL outl %eax, %dx + +#define data16 .byte 0x66 +#define addr16 .byte 0x67 + +#if !GPROF +#define MCOUNT + +#elif defined(__SHARED__) +#define MCOUNT ; .data;\ + .align ALIGN;\ + LBc(x, 8) .long 0;\ + .text;\ + Gpush;\ + Gload;\ + leal Gotoff(LBb(x,8)),%edx;\ + Egaddr(%eax,_mcount_ptr);\ + Gpop;\ + call *(%eax); + +#else /* !GPROF, !__SHARED__ */ +#define MCOUNT ; call mcount; +#endif /* GPROF */ + +#ifdef __ELF__ +#define ELF_FUNC(x) .type x,@function +#define ELF_DATA(x) .type x,@object +#define ELF_SIZE(x,s) .size x,s +#else +#define ELF_FUNC(x) +#define ELF_DATA(x) +#define ELF_SIZE(x,s) +#endif + +#define Entry(x) .globl EXT(x); ELF_FUNC(EXT(x)); .align FALIGN; LEXT(x) +#define ENTRY(x) Entry(x) MCOUNT +#define ENTRY2(x,y) .globl EXT(x); .globl EXT(y); \ + ELF_FUNC(EXT(x)); ELF_FUNC(EXT(y)); \ + .align FALIGN; LEXT(x); LEXT(y) \ + MCOUNT +#if __STDC__ +#define ASENTRY(x) .globl x; .align FALIGN; x ## : ELF_FUNC(x) MCOUNT +#else +#define ASENTRY(x) .globl x; .align FALIGN; x: ELF_FUNC(x) MCOUNT +#endif /* __STDC__ */ + +#define DATA(x) .globl EXT(x); ELF_DATA(EXT(x)); .align ALIGN; LEXT(x) + +#define End(x) ELF_SIZE(x,.-x) +#define END(x) End(EXT(x)) +#define ENDDATA(x) END(x) +#define Enddata(x) End(x) + +/* + * ELF shared library accessor macros. + * Gpush saves the %ebx register used for the GOT address + * Gpop pops %ebx if we need a GOT + * Gload loads %ebx with the GOT address if shared libraries are used + * Gcall calls an external function. + * Gotoff allows you to reference local labels. + * Gotoff2 allows you to reference local labels with an index reg. + * Gotoff3 allows you to reference local labels with an index reg & size. + * Gaddr loads up a register with an address of an external item. + * Gstack is the number of bytes that Gpush pushes on the stack. + * + * Varients of the above with E or L prefixes do EXT(name) or LCL(name) + * respectively. + */ + +#ifndef __SHARED__ +#define Gpush +#define Gpop +#define Gload +#define Gcall(func) call func +#define Gotoff(lab) lab +#define Gotoff2(l,r) l(r) +#define Gotoff3(l,r,s) l(,r,s) +#define Gaddr(to,lab) movl $lab,to +#define Gcmp(lab,reg) cmpl $lab,reg +#define Gmemload(lab,reg) movl lab,reg +#define Gmemstore(reg,lab,tmp) movl reg,lab +#define Gstack 0 + +#else +#ifdef __ELF__ /* ELF shared libraries */ +#define Gpush pushl %ebx +#define Gpop popl %ebx +#define Gload call 9f; 9: popl %ebx; addl $_GLOBAL_OFFSET_TABLE_+[.-9b],%ebx +#define Gcall(func) call EXT(func)@PLT +#define Gotoff(lab) lab@GOTOFF(%ebx) +#define Gotoff2(l,r) l@GOTOFF(%ebx,r) +#define Gotoff3(l,r,s) l@GOTOFF(%ebx,r,s) +#define Gaddr(to,lab) movl lab@GOT(%ebx),to +#define Gcmp(lab,reg) cmpl reg,lab@GOT(%ebx) +#define Gmemload(lab,reg) movl lab@GOT(%ebx),reg; movl (reg),reg +#define Gmemstore(reg,lab,tmp) movl lab@GOT(%ebx),tmp; movl reg,(tmp) +#define Gstack 4 + +#else /* ROSE shared libraries */ +#define Gpush +#define Gpop +#define Gload +#define Gcall(func) call *9f; .data; .align ALIGN; 9: .long func; .text +#define Gotoff(lab) lab +#define Gotoff2(l,r) l(r) +#define Gotoff3(l,r,s) l(,r,s) +#define Gaddr(to,lab) movl 9f,to; .data; .align ALIGN; 9: .long lab; .text +#define Gcmp(lab,reg) cmpl reg,9f; .data; .align ALIGN; 9: .long lab; .text +#define Gmemload(lab,reg) movl 9f,reg; movl (reg),reg; .data; .align ALIGN; 9: .long lab; .text +#define Gmemstore(reg,lab,tmp) movl 9f,tmp; movl reg,(tmp); .data; .align ALIGN; 9: .long lab; .text +#define Gstack 0 +#endif /* __ELF__ */ +#endif /* __SHARED__ */ + +/* Egotoff is not provided, since external symbols should not use @GOTOFF + relocations. */ +#define Egcall(func) Gcall(EXT(func)) +#define Egaddr(to,lab) Gaddr(to,EXT(lab)) +#define Egcmp(lab,reg) Gcmp(EXT(lab),reg) +#define Egmemload(lab,reg) Gmemload(EXT(lab),reg) +#define Egmemstore(reg,lab,tmp) Gmemstore(reg,EXT(lab),tmp) + +#define Lgotoff(lab) Gotoff(LCL(lab)) +#define Lgotoff2(l,r) Gotoff2(LCL(l),r) +#define Lgotoff3(l,r,s) Gotoff3(LCL(l),r,s) +#define Lgcmp(lab,reg) Gcmp(LCL(lab),reg) +#define Lgmemload(lab,reg) movl Lgotoff(lab),reg +#define Lgmemstore(reg,lab,tmp) movl reg,Lgotoff(lab) + +#ifdef ASSEMBLER +#if MACH_KDB +#include <ddb/stab.h> +/* + * This pseudo-assembler line is added so that there will be at least + * one N_SO entry in the symbol stable to define the current file name. + */ +#endif /* MACH_KDB */ + +#else /* NOT ASSEMBLER */ + +/* These defines are here for .c files that wish to reference global symbols + * within __asm__ statements. + */ +#ifndef __NO_UNDERSCORES__ +#define CC_SYM_PREFIX "_" +#else +#define CC_SYM_PREFIX "" +#endif /* __NO_UNDERSCORES__ */ +#endif /* ASSEMBLER */ + +#endif /* _I386_ASM_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/i386/machine_types.defs =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/i386/machine_types.defs (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/i386/machine_types.defs (revision 885) @@ -0,0 +1,127 @@ +/* + * 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@ + */ + +/* + * Header file for basic, machine-dependent data types. i386 version. + */ + +#ifndef _MACHINE_VM_TYPES_DEFS_ +#define _MACHINE_VM_TYPES_DEFS_ 1 + +type short = int16_t; +type int = int32_t; +type unsigned = uint32_t; + +type float = MACH_MSG_TYPE_REAL_32; +type double = MACH_MSG_TYPE_REAL_64; + + +/* from ISO/IEC 988:1999 spec */ +/* 7.18.1.4 Integer types capable of hgolding object pointers */ +/* + * The [u]intptr_t types for the native + * integer type, e.g. 32 or 64 or.. whatever + * register size the machine has. They are + * used for entities that might be either + * [unsigned] integers or pointers, and for + * type-casting between the two. + * + * For instance, the IPC system represents + * a port in user space as an integer and + * in kernel space as a pointer. + */ +#if defined(__LP64__) +type uintptr_t = uint64_t; +type intptr_t = int64_t; +#else +type uintptr_t = uint32_t; +type intptr_t = int32_t; +#endif + +/* + * These are the legacy Mach types that are + * the [rough] equivalents of the standards above. + * They were defined in terms of int, not + * long int, so they remain separate. + */ +#if defined(__LP64__) +type register_t = int64_t; +#else +type register_t = int32_t; +#endif +type integer_t = int32_t; +type natural_t = uint32_t; + +/* + * These are the VM types that scale with the address + * space size of a given process. + */ + +#if defined(__LP64__) +type vm_address_t = uint64_t; +type vm_offset_t = uint64_t; +type vm_size_t = uint64_t; +#else +type vm_address_t = natural_t; +type vm_offset_t = natural_t; +type vm_size_t = natural_t; +#endif + +/* + * The mach_vm_xxx_t types are sized to hold the + * maximum pointer, offset, etc... supported on the + * platform. + */ +type mach_vm_address_t = uint64_t; +type mach_vm_offset_t = uint64_t; +type mach_vm_size_t = uint64_t; + +#if MACH_IPC_COMPAT +/* + * For the old IPC interface + */ +#define MSG_TYPE_PORT_NAME natural_t + +#endif /* MACH_IPC_COMPAT */ + +/* + * These are types used internal to Mach to implement the + * legacy 32-bit VM APIs published by the kernel. + */ +#define VM32_SUPPORT 1 + +type vm32_address_t = uint32_t; +type vm32_offset_t = uint32_t; +type vm32_size_t = uint32_t; + +#endif /* _MACHINE_VM_TYPES_DEFS_ */ + +/* vim: set ft=c : */ Index: branches/azimutz/Cleancut/i386/include/mach/i386/rpc.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/i386/rpc.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/i386/rpc.h (revision 885) @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2002,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@ + */ +/* + * @OSF_COPYRIGHT@ + */ + +#ifndef _MACH_I386_RPC_H_ +#define _MACH_I386_RPC_H_ + +#endif /* _MACH_I386_RPC_H_ */ + Index: branches/azimutz/Cleancut/i386/include/mach/i386/sdt_isa.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/i386/sdt_isa.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/i386/sdt_isa.h (revision 885) @@ -0,0 +1,412 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _MACH_I386_SDT_ISA_H +#define _MACH_I386_SDT_ISA_H + +/* + * Only define when testing. This makes the calls into actual calls to + * test functions. + */ +/* #define DTRACE_CALL_TEST */ + +#define DTRACE_STRINGIFY(s) #s +#define DTRACE_TOSTRING(s) DTRACE_STRINGIFY(s) +#define DTRACE_LABEL(p, n) \ + "__dtrace_probe$" DTRACE_TOSTRING(__LINE__) DTRACE_STRINGIFY(_##p##___##n) ":" "\n\t" + +#ifdef DTRACE_CALL_TEST + +#define DTRACE_CALL(p,n) \ + DTRACE_LABEL(p,n) \ + DTRACE_CALL_INSN(p,n) + +#else + +#define DTRACE_CALL(p,n) \ + DTRACE_LABEL(p,n) \ + DTRACE_NOPS + +#endif + +#ifdef __x86_64__ + +#define DTRACE_NOPS \ + "nop" "\n\t" \ + "nop" "\n\t" \ + "nop" "\n\t" + +#define DTRACE_CALL_INSN(p,n) \ + "call _dtracetest" DTRACE_STRINGIFY(_##p##_##n) "\n\t" + +#define ARG1_EXTENT 1 +#define ARGS2_EXTENT 2 +#define ARGS3_EXTENT 3 +#define ARGS4_EXTENT 4 +#define ARGS5_EXTENT 5 +#define ARGS6_EXTENT 6 +#define ARGS7_EXTENT 7 +#define ARGS8_EXTENT 8 +#define ARGS9_EXTENT 10 +#define ARGS10_EXTENT 10 + +#define DTRACE_CALL0ARGS(provider, name) \ + asm volatile ( \ + DTRACE_CALL(provider, name) \ + ); + +#define DTRACE_CALL1ARG(provider, name) \ + asm volatile ("movq\t0x0(%0),%%rdi" "\n\t" \ + DTRACE_CALL(provider, name) \ + : \ + : "r" (__dtrace_args) \ + : "memory", "rdi" \ + ); + +#define DTRACE_CALL2ARGS(provider, name) \ + asm volatile ("movq\t0x0(%0),%%rdi" "\n\t" \ + "movq\t0x8(%0),%%rsi" "\n\t" \ + DTRACE_CALL(provider, name) \ + : \ + : "r" (__dtrace_args) \ + : "memory", "rdi", "rsi" \ + ); + +#define DTRACE_CALL3ARGS(provider, name) \ + asm volatile ("movq\t0x0(%0),%%rdi" "\n\t" \ + "movq\t0x8(%0),%%rsi" "\n\t" \ + "movq\t0x10(%0),%%rdx" "\n\t" \ + DTRACE_CALL(provider, name) \ + : \ + : "r" (__dtrace_args) \ + : "memory", "rdi", "rsi", "rdx" \ + ); + +#define DTRACE_CALL4ARGS(provider, name) \ + asm volatile ("movq\t0x0(%0),%%rdi" "\n\t" \ + "movq\t0x8(%0),%%rsi" "\n\t" \ + "movq\t0x10(%0),%%rdx" "\n\t" \ + "movq\t0x18(%0),%%rcx" "\n\t" \ + DTRACE_CALL(provider, name) \ + : \ + : "r" (__dtrace_args) \ + : "memory", "rdi", "rsi", "rdx", "rcx" \ + ); + +#define DTRACE_CALL5ARGS(provider, name) \ + asm volatile ("movq\t0x0(%0),%%rdi" "\n\t" \ + "movq\t0x8(%0),%%rsi" "\n\t" \ + "movq\t0x10(%0),%%rdx" "\n\t" \ + "movq\t0x18(%0),%%rcx" "\n\t" \ + "movq\t0x20(%0),%%r8" "\n\t" \ + DTRACE_CALL(provider, name) \ + : \ + : "r" (__dtrace_args) \ + : "memory", "rdi", "rsi", "rdx", "rcx", "r8" \ + ); + +#define DTRACE_CALL6ARGS(provider, name) \ + asm volatile ("movq\t0x0(%0),%%rdi" "\n\t" \ + "movq\t0x8(%0),%%rsi" "\n\t" \ + "movq\t0x10(%0),%%rdx" "\n\t" \ + "movq\t0x18(%0),%%rcx" "\n\t" \ + "movq\t0x20(%0),%%r8" "\n\t" \ + "movq\t0x28(%0),%%r9" "\n\t" \ + DTRACE_CALL(provider, name) \ + : \ + : "r" (__dtrace_args) \ + : "memory", "rdi", "rsi", "rdx", "rcx", "r8", "r9" \ + ); + +#define DTRACE_CALL7ARGS(provider, name) \ + asm volatile ("subq\t$0x8,%%rsp" "\n\t" \ + "movq\t0x0(%0),%%rdi" "\n\t" \ + "movq\t0x8(%0),%%rsi" "\n\t" \ + "movq\t0x10(%0),%%rdx" "\n\t" \ + "movq\t0x18(%0),%%rcx" "\n\t" \ + "movq\t0x20(%0),%%r8" "\n\t" \ + "movq\t0x28(%0),%%r9" "\n\t" \ + "movq\t0x30(%0),%%rax" "\n\t" \ + "movq\t%%rax,0x0(%%rsp)" "\n\t" \ + DTRACE_CALL(provider, name) \ + "addq\t$0x8,%%rsp" "\n\t" \ + : \ + : "r" (__dtrace_args) \ + : "memory", "rdi", "rsi", "rdx", "rcx", "r8", "r9", "rax" \ + ); + +#endif // __x86_64__ + +#ifdef __i386__ + +#define DTRACE_NOPS \ + "nop" "\n\t" \ + "leal 0(%%esi), %%esi" "\n\t" + +#define DTRACE_CALL_INSN(p,n) \ + "call _dtracetest" DTRACE_STRINGIFY(_##p##_##n) "\n\t" + +#define ARG1_EXTENT 1 +#define ARGS2_EXTENT 2 +#define ARGS3_EXTENT 4 +#define ARGS4_EXTENT 4 +#define ARGS5_EXTENT 8 +#define ARGS6_EXTENT 8 +#define ARGS7_EXTENT 8 +#define ARGS8_EXTENT 8 +#define ARGS9_EXTENT 12 +#define ARGS10_EXTENT 12 + +/* + * Because this code is used in the kernel, we must not touch any floating point + * or specialized registers. This leaves the following registers: + * + * eax ; volatile, safe to use + * ebx ; PIC register, gcc error when used + * ecx ; volatile, safe to use + * edx ; volatile, safe to use + * esi ; non-volatile, otherwise safe to use + * edi ; non-volatile, otherwise safe to use + * + * Using any of the non volatile register causes a spill to stack which is almost + * certainly a net performance loss. Also, note that the array ref (__dtrace_args) + * consumes one free register. If all three of the volatile regs are used for load/store, + * the compiler will spill a register to hold the array ref. + * + * The end result is that we only pipeline two loads/stores at a time. Blech. + */ + +#define DTRACE_CALL0ARGS(provider, name) \ + asm volatile ( \ + DTRACE_CALL(provider, name) \ + "# eat trailing nl +tabfrom DTRACE_CALL" \ + : \ + : \ + ); + +#define DTRACE_CALL1ARG(provider, name) \ + asm volatile ("subl\t$0x10,%%esp" "\n\t" \ + "movl\t0x0(%0),%%eax" "\n\t" \ + "movl\t%%eax,0x0(%%esp)" "\n\t" \ + DTRACE_CALL(provider, name) \ + "addl\t$0x10,%%esp" \ + : \ + : "r" (__dtrace_args) \ + : "memory", "eax" \ + ); + +#define DTRACE_CALL2ARGS(provider, name) \ + asm volatile ("subl\t$0x10,%%esp" "\n\t" \ + "movl\t0x0(%0),%%eax" "\n\t" \ + "movl\t0x4(%0),%%edx" "\n\t" \ + "movl\t%%eax,0x0(%%esp)" "\n\t" \ + "movl\t%%edx,0x4(%%esp)" "\n\t" \ + DTRACE_CALL(provider, name) \ + "addl\t$0x10,%%esp" \ + : \ + : "r" (__dtrace_args) \ + : "memory", "eax", "edx" \ + ); + +#define DTRACE_CALL3ARGS(provider, name) \ + asm volatile ("subl\t$0x10,%%esp" "\n\t" \ + "movl\t0x0(%0),%%eax" "\n\t" \ + "movl\t0x4(%0),%%edx" "\n\t" \ + "movl\t%%eax,0x0(%%esp)" "\n\t" \ + "movl\t%%edx,0x4(%%esp)" "\n\t" \ + "movl\t0x8(%0),%%eax" "\n\t" \ + "movl\t%%eax,0x8(%%esp)" "\n\t" \ + DTRACE_CALL(provider, name) \ + "addl\t$0x10,%%esp" \ + : \ + : "r" (__dtrace_args) \ + : "memory", "eax", "edx" \ + ); + +#define DTRACE_CALL4ARGS(provider, name) \ + asm volatile ("subl\t$0x10,%%esp" "\n\t" \ + "movl\t0x0(%0),%%eax" "\n\t" \ + "movl\t0x4(%0),%%edx" "\n\t" \ + "movl\t%%eax,0x0(%%esp)" "\n\t" \ + "movl\t%%edx,0x4(%%esp)" "\n\t" \ + "movl\t0x8(%0),%%eax" "\n\t" \ + "movl\t0xC(%0),%%edx" "\n\t" \ + "movl\t%%eax,0x8(%%esp)" "\n\t" \ + "movl\t%%edx,0xC(%%esp)" "\n\t" \ + DTRACE_CALL(provider, name) \ + "addl\t$0x10,%%esp" \ + : \ + : "r" (__dtrace_args) \ + : "memory", "eax", "edx" \ + ); + +#define DTRACE_CALL5ARGS(provider, name) \ + asm volatile ("subl\t$0x20,%%esp" "\n\t" \ + "movl\t0x0(%0),%%eax" "\n\t" \ + "movl\t0x4(%0),%%edx" "\n\t" \ + "movl\t%%eax,0x0(%%esp)" "\n\t" \ + "movl\t%%edx,0x4(%%esp)" "\n\t" \ + "movl\t0x8(%0),%%eax" "\n\t" \ + "movl\t0xC(%0),%%edx" "\n\t" \ + "movl\t%%eax,0x8(%%esp)" "\n\t" \ + "movl\t%%edx,0xC(%%esp)" "\n\t" \ + "movl\t0x10(%0),%%eax" "\n\t" \ + "movl\t%%eax,0x10(%%esp)" "\n\t" \ + DTRACE_CALL(provider, name) \ + "addl\t$0x20,%%esp" \ + : \ + : "r" (__dtrace_args) \ + : "memory", "eax", "edx" \ + ); + +#define DTRACE_CALL6ARGS(provider, name) \ + asm volatile ("subl\t$0x20,%%esp" "\n\t" \ + "movl\t0x0(%0),%%eax" "\n\t" \ + "movl\t0x4(%0),%%edx" "\n\t" \ + "movl\t%%eax,0x0(%%esp)" "\n\t" \ + "movl\t%%edx,0x4(%%esp)" "\n\t" \ + "movl\t0x8(%0),%%eax" "\n\t" \ + "movl\t0xC(%0),%%edx" "\n\t" \ + "movl\t%%eax,0x8(%%esp)" "\n\t" \ + "movl\t%%edx,0xC(%%esp)" "\n\t" \ + "movl\t0x10(%0),%%eax" "\n\t" \ + "movl\t0x14(%0),%%edx" "\n\t" \ + "movl\t%%eax,0x10(%%esp)" "\n\t" \ + "movl\t%%edx,0x14(%%esp)" "\n\t" \ + DTRACE_CALL(provider, name) \ + "addl\t$0x20,%%esp" \ + : \ + : "r" (__dtrace_args) \ + : "memory", "eax", "edx" \ + ); + +#define DTRACE_CALL7ARGS(provider, name) \ + asm volatile ("subl\t$0x20,%%esp" "\n\t" \ + "movl\t0x0(%0),%%eax" "\n\t" \ + "movl\t0x4(%0),%%edx" "\n\t" \ + "movl\t%%eax,0x0(%%esp)" "\n\t" \ + "movl\t%%edx,0x4(%%esp)" "\n\t" \ + "movl\t0x8(%0),%%eax" "\n\t" \ + "movl\t0xC(%0),%%edx" "\n\t" \ + "movl\t%%eax,0x8(%%esp)" "\n\t" \ + "movl\t%%edx,0xC(%%esp)" "\n\t" \ + "movl\t0x10(%0),%%eax" "\n\t" \ + "movl\t0x14(%0),%%edx" "\n\t" \ + "movl\t%%eax,0x10(%%esp)" "\n\t" \ + "movl\t%%edx,0x14(%%esp)" "\n\t" \ + "movl\t0x18(%0),%%eax" "\n\t" \ + "movl\t%%eax,0x18(%%esp)" "\n\t" \ + DTRACE_CALL(provider, name) \ + "addl\t$0x20,%%esp" \ + : \ + : "r" (__dtrace_args) \ + : "memory", "eax", "edx" \ + ); + +#define DTRACE_CALL8ARGS(provider, name) \ + asm volatile ("subl\t$0x20,%%esp" "\n\t" \ + "movl\t0x0(%0),%%eax" "\n\t" \ + "movl\t0x4(%0),%%edx" "\n\t" \ + "movl\t%%eax,0x0(%%esp)" "\n\t" \ + "movl\t%%edx,0x4(%%esp)" "\n\t" \ + "movl\t0x8(%0),%%eax" "\n\t" \ + "movl\t0xC(%0),%%edx" "\n\t" \ + "movl\t%%eax,0x8(%%esp)" "\n\t" \ + "movl\t%%edx,0xC(%%esp)" "\n\t" \ + "movl\t0x10(%0),%%eax" "\n\t" \ + "movl\t0x14(%0),%%edx" "\n\t" \ + "movl\t%%eax,0x10(%%esp)" "\n\t" \ + "movl\t%%edx,0x14(%%esp)" "\n\t" \ + "movl\t0x18(%0),%%eax" "\n\t" \ + "movl\t0x1C(%0),%%edx" "\n\t" \ + "movl\t%%eax,0x18(%%esp)" "\n\t" \ + "movl\t%%edx,0x1C(%%esp)" "\n\t" \ + DTRACE_CALL(provider, name) \ + "addl\t$0x20,%%esp" \ + : \ + : "r" (__dtrace_args) \ + : "memory", "eax", "edx" \ + ); + +#define DTRACE_CALL9ARGS(provider, name) \ + asm volatile ("subl\t$0x30,%%esp" "\n\t" \ + "movl\t0x0(%0),%%eax" "\n\t" \ + "movl\t0x4(%0),%%edx" "\n\t" \ + "movl\t%%eax,0x0(%%esp)" "\n\t" \ + "movl\t%%edx,0x4(%%esp)" "\n\t" \ + "movl\t0x8(%0),%%eax" "\n\t" \ + "movl\t0xC(%0),%%edx" "\n\t" \ + "movl\t%%eax,0x8(%%esp)" "\n\t" \ + "movl\t%%edx,0xC(%%esp)" "\n\t" \ + "movl\t0x10(%0),%%eax" "\n\t" \ + "movl\t0x14(%0),%%edx" "\n\t" \ + "movl\t%%eax,0x10(%%esp)" "\n\t" \ + "movl\t%%edx,0x14(%%esp)" "\n\t" \ + "movl\t0x18(%0),%%eax" "\n\t" \ + "movl\t0x1C(%0),%%edx" "\n\t" \ + "movl\t%%eax,0x18(%%esp)" "\n\t" \ + "movl\t%%edx,0x1C(%%esp)" "\n\t" \ + "movl\t0x20(%0),%%eax" "\n\t" \ + "movl\t%%eax,0x20(%%esp)" "\n\t" \ + DTRACE_CALL(provider, name) \ + "addl\t$0x30,%%esp" \ + : \ + : "r" (__dtrace_args) \ + : "memory", "eax", "edx" \ + ); + +#define DTRACE_CALL10ARGS(provider, name) \ + asm volatile ("subl\t$0x30,%%esp" "\n\t" \ + "movl\t0x0(%0),%%eax" "\n\t" \ + "movl\t0x4(%0),%%edx" "\n\t" \ + "movl\t%%eax,0x0(%%esp)" "\n\t" \ + "movl\t%%edx,0x4(%%esp)" "\n\t" \ + "movl\t0x8(%0),%%eax" "\n\t" \ + "movl\t0xC(%0),%%edx" "\n\t" \ + "movl\t%%eax,0x8(%%esp)" "\n\t" \ + "movl\t%%edx,0xC(%%esp)" "\n\t" \ + "movl\t0x10(%0),%%eax" "\n\t" \ + "movl\t0x14(%0),%%edx" "\n\t" \ + "movl\t%%eax,0x10(%%esp)" "\n\t" \ + "movl\t%%edx,0x14(%%esp)" "\n\t" \ + "movl\t0x18(%0),%%eax" "\n\t" \ + "movl\t0x1C(%0),%%edx" "\n\t" \ + "movl\t%%eax,0x18(%%esp)" "\n\t" \ + "movl\t%%edx,0x1C(%%esp)" "\n\t" \ + "movl\t0x20(%0),%%eax" "\n\t" \ + "movl\t0x24(%0),%%edx" "\n\t" \ + "movl\t%%eax,0x20(%%esp)" "\n\t" \ + "movl\t%%edx,0x24(%%esp)" "\n\t" \ + DTRACE_CALL(provider, name) \ + "addl\t$0x30,%%esp" \ + : \ + : "r" (__dtrace_args) \ + : "memory", "eax", "edx" \ + ); + +#endif // __i386__ + +#endif /* _MACH_I386_SDT_ISA_H */ Index: branches/azimutz/Cleancut/i386/include/mach/host_special_ports.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/host_special_ports.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/host_special_ports.h (revision 885) @@ -0,0 +1,180 @@ +/* + * Copyright (c) 2003 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 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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + */ +/* + * File: mach/host_special_ports.h + * + * Defines codes for access to host-wide special ports. + */ + +#ifndef _MACH_HOST_SPECIAL_PORTS_H_ +#define _MACH_HOST_SPECIAL_PORTS_H_ + +/* + * Cannot be set or gotten from user space + */ +#define HOST_SECURITY_PORT 0 + +/* + * Always provided by kernel (cannot be set from user-space). + */ +#define HOST_PORT 1 +#define HOST_PRIV_PORT 2 +#define HOST_IO_MASTER_PORT 3 +#define HOST_MAX_SPECIAL_KERNEL_PORT 7 /* room to grow */ + +/* + * Not provided by kernel + */ +#define HOST_DYNAMIC_PAGER_PORT (1 + HOST_MAX_SPECIAL_KERNEL_PORT) +#define HOST_AUDIT_CONTROL_PORT (2 + HOST_MAX_SPECIAL_KERNEL_PORT) +#define HOST_USER_NOTIFICATION_PORT (3 + HOST_MAX_SPECIAL_KERNEL_PORT) +#define HOST_AUTOMOUNTD_PORT (4 + HOST_MAX_SPECIAL_KERNEL_PORT) +#define HOST_LOCKD_PORT (5 + HOST_MAX_SPECIAL_KERNEL_PORT) +#define HOST_SEATBELT_PORT (7 + HOST_MAX_SPECIAL_KERNEL_PORT) +#define HOST_KEXTD_PORT (8 + HOST_MAX_SPECIAL_KERNEL_PORT) +#define HOST_CHUD_PORT (9 + HOST_MAX_SPECIAL_KERNEL_PORT) +#define HOST_UNFREED_PORT (10 + HOST_MAX_SPECIAL_KERNEL_PORT) +#define HOST_AMFID_PORT (11 + HOST_MAX_SPECIAL_KERNEL_PORT) +#define HOST_MAX_SPECIAL_PORT (12 + HOST_MAX_SPECIAL_KERNEL_PORT) + /* room to grow here as well */ + +/* + * Special node identifier to always represent the local node. + */ +#define HOST_LOCAL_NODE -1 + +/* + * Definitions for ease of use. + * + * In the get call, the host parameter can be any host, but will generally + * be the local node host port. In the set call, the host must the per-node + * host port for the node being affected. + */ +#define host_get_host_port(host, port) \ + (host_get_special_port((host), \ + HOST_LOCAL_NODE, HOST_PORT, (port))) +#define host_set_host_port(host, port) (KERN_INVALID_ARGUMENT) + +#define host_get_host_priv_port(host, port) \ + (host_get_special_port((host), \ + HOST_LOCAL_NODE, HOST_PRIV_PORT, (port))) +#define host_set_host_priv_port(host, port) (KERN_INVALID_ARGUMENT) + +#define host_get_io_master_port(host, port) \ + (host_get_special_port((host), \ + HOST_LOCAL_NODE, HOST_IO_MASTER_PORT, (port))) +#define host_set_io_master_port(host, port) (KERN_INVALID_ARGUMENT) + +/* + * User-settable special ports. + */ +#define host_get_dynamic_pager_port(host, port) \ + (host_get_special_port((host), \ + HOST_LOCAL_NODE, HOST_DYNAMIC_PAGER_PORT, (port))) +#define host_set_dynamic_pager_port(host, port) \ + (host_set_special_port((host), HOST_DYNAMIC_PAGER_PORT, (port))) + +#define host_get_audit_control_port(host, port) \ + (host_get_special_port((host), \ + HOST_LOCAL_NODE, HOST_AUDIT_CONTROL_PORT, (port))) +#define host_set_audit_control_port(host, port) \ + (host_set_special_port((host), HOST_AUDIT_CONTROL_PORT, (port))) + +#define host_get_user_notification_port(host, port) \ + (host_get_special_port((host), \ + HOST_LOCAL_NODE, HOST_USER_NOTIFICATION_PORT, (port))) +#define host_set_user_notification_port(host, port) \ + (host_set_special_port((host), HOST_USER_NOTIFICATION_PORT, (port))) + +#define host_get_automountd_port(host, port) \ + (host_get_special_port((host), \ + HOST_LOCAL_NODE, HOST_AUTOMOUNTD_PORT, (port))) +#define host_set_automountd_port(host, port) \ + (host_set_special_port((host), HOST_AUTOMOUNTD_PORT, (port))) + +#define host_get_lockd_port(host, port) \ + (host_get_special_port((host), \ + HOST_LOCAL_NODE, HOST_LOCKD_PORT, (port))) +#define host_set_lockd_port(host, port) \ + (host_set_special_port((host), HOST_LOCKD_PORT, (port))) + +#define host_get_kextd_port(host, port) \ + (host_get_special_port((host), \ + HOST_LOCAL_NODE, HOST_KEXTD_PORT, (port))) +#define host_set_kextd_port(host, port) \ + (host_set_special_port((host), HOST_KEXTD_PORT, (port))) + +#define host_get_chud_port(host, port) \ + (host_get_special_port((host), \ + HOST_LOCAL_NODE, HOST_CHUD_PORT, (port))) +#define host_set_chud_port(host, port) \ + (host_set_special_port((host), HOST_CHUD_PORT, (port))) + +#define host_get_unfreed_port(host, port) \ + (host_get_special_port((host), \ + HOST_LOCAL_NODE, HOST_UNFREED_PORT, (port))) +#define host_set_unfreed_port(host, port) \ + (host_set_special_port((host), HOST_UNFREED_PORT, (port))) + +#define host_get_amfid_port(host, port) \ + (host_get_special_port((host), \ + HOST_LOCAL_NODE, HOST_AMFID_PORT, (port))) +#define host_set_amfid_port(host, port) \ + (host_set_special_port((host), HOST_AMFID_PORT, (port))) + +#endif /* _MACH_HOST_SPECIAL_PORTS_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/vm_inherit.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/vm_inherit.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/vm_inherit.h (revision 885) @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2000-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@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989,1988,1987 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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + */ +/* + * File: mach/vm_inherit.h + * Author: Avadis Tevanian, Jr., Michael Wayne Young + * + * Virtual memory map inheritance definitions. + * + */ + +#ifndef _MACH_VM_INHERIT_H_ +#define _MACH_VM_INHERIT_H_ + +/* + * Types defined: + * + * vm_inherit_t inheritance codes. + */ + +typedef unsigned int vm_inherit_t; /* might want to change this */ + +/* + * Enumeration of valid values for vm_inherit_t. + */ + +#define VM_INHERIT_SHARE ((vm_inherit_t) 0) /* share with child */ +#define VM_INHERIT_COPY ((vm_inherit_t) 1) /* copy into child */ +#define VM_INHERIT_NONE ((vm_inherit_t) 2) /* absent from child */ +#define VM_INHERIT_DONATE_COPY ((vm_inherit_t) 3) /* copy and delete */ + +#define VM_INHERIT_DEFAULT VM_INHERIT_COPY +#define VM_INHERIT_LAST_VALID VM_INHERIT_NONE + +#endif /* _MACH_VM_INHERIT_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/mig_errors.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/mig_errors.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/mig_errors.h (revision 885) @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2000-2007 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@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989,1988,1987 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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + */ +/* + * Mach Interface Generator errors + * + */ + +#ifndef _MACH_MIG_ERRORS_H_ +#define _MACH_MIG_ERRORS_H_ + +#include <mach/mig.h> +#include <mach/ndr.h> +#include <mach/message.h> +#include <mach/kern_return.h> + +#include <sys/cdefs.h> + +/* + * These error codes should be specified as system 4, subsytem 2. + * But alas backwards compatibility makes that impossible. + * The problem is old clients of new servers (eg, the kernel) + * which get strange large error codes when there is a Mig problem + * in the server. Unfortunately, the IPC system doesn't have + * the knowledge to convert the codes in this situation. + */ + +#define MIG_TYPE_ERROR -300 /* client type check failure */ +#define MIG_REPLY_MISMATCH -301 /* wrong reply message ID */ +#define MIG_REMOTE_ERROR -302 /* server detected error */ +#define MIG_BAD_ID -303 /* bad request message ID */ +#define MIG_BAD_ARGUMENTS -304 /* server type check failure */ +#define MIG_NO_REPLY -305 /* no reply should be send */ +#define MIG_EXCEPTION -306 /* server raised exception */ +#define MIG_ARRAY_TOO_LARGE -307 /* array not large enough */ +#define MIG_SERVER_DIED -308 /* server died */ +#define MIG_TRAILER_ERROR -309 /* trailer has an unknown format */ + +/* + * Whenever MIG detects an error, it sends back a generic + * mig_reply_error_t format message. Clients must accept + * these in addition to the expected reply message format. + */ +#pragma pack(4) +typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; +} mig_reply_error_t; +#pragma pack() + + +__BEGIN_DECLS + +#if !defined(__NDR_convert__mig_reply_error_t__defined) +#define __NDR_convert__mig_reply_error_t__defined + +static __inline__ void +__NDR_convert__mig_reply_error_t(__unused mig_reply_error_t *x) +{ +#if defined(__NDR_convert__int_rep__kern_return_t__defined) + if (x->NDR.int_rep != NDR_record.int_rep) + __NDR_convert__int_rep__kern_return_t(&x->RetCode, x->NDR.int_rep); +#endif /* __NDR_convert__int_rep__kern_return_t__defined */ +} +#endif /* !defined(__NDR_convert__mig_reply_error_t__defined) */ + +__END_DECLS + +#endif /* _MACH_MIG_ERRORS_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/mach.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/mach.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/mach.h (revision 885) @@ -0,0 +1,133 @@ +/* + * Copyright (c) 1999-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@ + */ +/* + * 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 Software.Distribution@CS.CMU.EDU + * 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. + */ + +/* + * Includes all the types that a normal user + * of Mach programs should need + */ + +#ifndef _MACH_H_ +#define _MACH_H_ + +#define __MACH30__ +#define MACH_IPC_FLAVOR UNTYPED + +#include <mach/std_types.h> +#include <mach/mach_types.h> +#include <mach/mach_interface.h> +#include <mach/mach_port.h> +#include <mach/mach_init.h> +#include <mach/mach_host.h> +#include <mach/thread_switch.h> + +#include <mach/rpc.h> /* for compatibility only */ +#include <mach/mig.h> + +#include <mach/mig_errors.h> +#include <mach/mach_error.h> + +#include <sys/cdefs.h> + +__BEGIN_DECLS +/* + * Standard prototypes + */ +extern void panic_init(mach_port_t); +extern void panic(const char *, ...); + +extern void safe_gets(char *, + char *, + int); + +extern void slot_name(cpu_type_t, + cpu_subtype_t, + char **, + char **); + +extern void mig_reply_setup(mach_msg_header_t *, + mach_msg_header_t *); + +extern void mach_msg_destroy(mach_msg_header_t *); + +extern mach_msg_return_t mach_msg_receive(mach_msg_header_t *); + +extern mach_msg_return_t mach_msg_send(mach_msg_header_t *); + +extern mach_msg_return_t mach_msg_server_once(boolean_t (*) + (mach_msg_header_t *, + mach_msg_header_t *), + mach_msg_size_t, + mach_port_t, + mach_msg_options_t); +extern mach_msg_return_t mach_msg_server(boolean_t (*) + (mach_msg_header_t *, + mach_msg_header_t *), + mach_msg_size_t, + mach_port_t, + mach_msg_options_t); + +/* + * Prototypes for compatibility + */ +extern kern_return_t clock_get_res(mach_port_t, + clock_res_t *); +extern kern_return_t clock_set_res(mach_port_t, + clock_res_t); + +extern kern_return_t clock_sleep(mach_port_t, + int, + mach_timespec_t, + mach_timespec_t *); +__END_DECLS + +#endif /* _MACH_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/mig.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/mig.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/mig.h (revision 885) @@ -0,0 +1,174 @@ +/* + * Copyright (c) 2000-2007 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@ + */ +/* + * @OSF_COPYRIGHT@ + */ + +/* + * Mach MIG Subsystem Interfaces + */ + +#ifndef _MACH_MIG_H_ +#define _MACH_MIG_H_ + +#include <stdint.h> +#include <mach/port.h> +#include <mach/message.h> +#include <mach/vm_types.h> + +#include <sys/cdefs.h> + +#if defined(MACH_KERNEL) + +#if defined(BSMALL_LATER) +/* Really small configurations don't need type checking */ +#define __MigTypeCheck 0 +#else +/* Turn MIG type checking on by default for kernel */ +#define __MigTypeCheck 1 +#endif +#define __MigKernelSpecificCode 1 +#define _MIG_KERNEL_SPECIFIC_CODE_ 1 + +/* Otherwise check legacy setting (temporary) */ +#elif defined(TypeCheck) + +#define __MigTypeCheck TypeCheck + +#elif !defined(__MigTypeCheck) + +/* otherwise, default MIG type checking on - except in small configurations */ +#if defined(BSMALL) +#define __MigTypeCheck 0 +#else +#define __MigTypeCheck 1 +#endif + +#endif /* !defined(__MigTypeCheck) */ + +/* + * Pack MIG message structs. + * This is an indicator of the need to view shared structs in a + * binary-compatible format - and MIG message structs are no different. + */ +#define __MigPackStructs 1 + +/* + * Definition for MIG-generated server stub routines. These routines + * unpack the request message, call the server procedure, and pack the + * reply message. + */ +typedef void (*mig_stub_routine_t) (mach_msg_header_t *InHeadP, + mach_msg_header_t *OutHeadP); + +typedef mig_stub_routine_t mig_routine_t; + +/* + * Definition for MIG-generated server routine. This routine takes a + * message, and returns the appropriate stub function for handling that + * message. + */ +typedef mig_routine_t (*mig_server_routine_t) (mach_msg_header_t *InHeadP); + +/* + * Generic definition for implementation routines. These routines do + * the real work associated with this request. This generic type is + * used for keeping the pointers in the subsystem array. + */ +typedef kern_return_t (*mig_impl_routine_t)(void); + +typedef mach_msg_type_descriptor_t routine_arg_descriptor; +typedef mach_msg_type_descriptor_t *routine_arg_descriptor_t; +typedef mach_msg_type_descriptor_t *mig_routine_arg_descriptor_t; + +#define MIG_ROUTINE_ARG_DESCRIPTOR_NULL ((mig_routine_arg_descriptor_t)0) + +struct routine_descriptor { + mig_impl_routine_t impl_routine; /* Server work func pointer */ + mig_stub_routine_t stub_routine; /* Unmarshalling func pointer */ + unsigned int argc; /* Number of argument words */ + unsigned int descr_count; /* Number complex descriptors */ + routine_arg_descriptor_t + arg_descr; /* pointer to descriptor array*/ + unsigned int max_reply_msg; /* Max size for reply msg */ +}; +typedef struct routine_descriptor *routine_descriptor_t; + +typedef struct routine_descriptor mig_routine_descriptor; +typedef mig_routine_descriptor *mig_routine_descriptor_t; + +#define MIG_ROUTINE_DESCRIPTOR_NULL ((mig_routine_descriptor_t)0) + +typedef struct mig_subsystem { + mig_server_routine_t server; /* pointer to demux routine */ + mach_msg_id_t start; /* Min routine number */ + mach_msg_id_t end; /* Max routine number + 1 */ + mach_msg_size_t maxsize; /* Max reply message size */ + vm_address_t reserved; /* reserved for MIG use */ + mig_routine_descriptor + routine[1]; /* Routine descriptor array */ +} *mig_subsystem_t; + +#define MIG_SUBSYSTEM_NULL ((mig_subsystem_t)0) + +typedef struct mig_symtab { + char *ms_routine_name; + int ms_routine_number; + void (*ms_routine)(void); /* Since the functions in the + * symbol table have unknown + * signatures, this is the best + * we can do... + */ +} mig_symtab_t; + + +__BEGIN_DECLS + +/* Client side reply port allocate */ +extern mach_port_t mig_get_reply_port(void); + +/* Client side reply port deallocate */ +extern void mig_dealloc_reply_port(mach_port_t reply_port); + +/* Client side reply port "deallocation" */ +extern void mig_put_reply_port(mach_port_t reply_port); + +/* Bounded string copy */ +extern int mig_strncpy(char *dest, const char *src, int len); + + +/* Allocate memory for out-of-line mig structures */ +extern void mig_allocate(vm_address_t *, vm_size_t); + +/* Deallocate memory used for out-of-line mig structures */ +extern void mig_deallocate(vm_address_t, vm_size_t); + + +__END_DECLS + +#endif /* _MACH_MIG_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/task_info.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/task_info.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/task_info.h (revision 885) @@ -0,0 +1,244 @@ +/* + * Copyright (c) 2000-2007 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@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989,1988,1987 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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + * Machine-independent task information structures and definitions. + * + * The definitions in this file are exported to the user. The kernel + * will translate its internal data structures to these structures + * as appropriate. + * + */ + +#ifndef _MACH_TASK_INFO_H_ +#define _MACH_TASK_INFO_H_ + +#include <mach/message.h> +#include <mach/machine/vm_types.h> +#include <mach/time_value.h> +#include <mach/policy.h> + +#include <sys/cdefs.h> + +/* + * Generic information structure to allow for expansion. + */ +typedef natural_t task_flavor_t; +typedef integer_t *task_info_t; /* varying array of int */ + +#define TASK_INFO_MAX (1024) /* maximum array size */ +typedef integer_t task_info_data_t[TASK_INFO_MAX]; + +/* + * Currently defined information structures. + */ + +#pragma pack(4) + +#define TASK_BASIC_INFO_32 4 /* basic information */ +#define TASK_BASIC2_INFO_32 6 + +struct task_basic_info_32 { + integer_t suspend_count; /* suspend count for task */ + natural_t virtual_size; /* virtual memory size (bytes) */ + natural_t resident_size; /* resident memory size (bytes) */ + time_value_t user_time; /* total user run time for + terminated threads */ + time_value_t system_time; /* total system run time for + terminated threads */ + policy_t policy; /* default policy for new threads */ +}; +typedef struct task_basic_info_32 task_basic_info_32_data_t; +typedef struct task_basic_info_32 *task_basic_info_32_t; +#define TASK_BASIC_INFO_32_COUNT \ + (sizeof(task_basic_info_32_data_t) / sizeof(natural_t)) + + +#define TASK_BASIC_INFO_64 5 /* 64-bit capable basic info */ + +struct task_basic_info_64 { + integer_t suspend_count; /* suspend count for task */ + mach_vm_size_t virtual_size; /* virtual memory size (bytes) */ + mach_vm_size_t resident_size; /* resident memory size (bytes) */ + time_value_t user_time; /* total user run time for + terminated threads */ + time_value_t system_time; /* total system run time for + terminated threads */ + policy_t policy; /* default policy for new threads */ +}; +typedef struct task_basic_info_64 task_basic_info_64_data_t; +typedef struct task_basic_info_64 *task_basic_info_64_t; +#define TASK_BASIC_INFO_64_COUNT \ + (sizeof(task_basic_info_64_data_t) / sizeof(natural_t)) + + +/* localized structure - cannot be safely passed between tasks of differing sizes */ + +struct task_basic_info { + integer_t suspend_count; /* suspend count for task */ + vm_size_t virtual_size; /* virtual memory size (bytes) */ + vm_size_t resident_size; /* resident memory size (bytes) */ + time_value_t user_time; /* total user run time for + terminated threads */ + time_value_t system_time; /* total system run time for + terminated threads */ + policy_t policy; /* default policy for new threads */ +}; + +typedef struct task_basic_info task_basic_info_data_t; +typedef struct task_basic_info *task_basic_info_t; +#define TASK_BASIC_INFO_COUNT \ + (sizeof(task_basic_info_data_t) / sizeof(natural_t)) +#if !defined(__LP64__) +#define TASK_BASIC_INFO TASK_BASIC_INFO_32 +#else +#define TASK_BASIC_INFO TASK_BASIC_INFO_64 +#endif + + + +#define TASK_EVENTS_INFO 2 /* various event counts */ + +struct task_events_info { + integer_t faults; /* number of page faults */ + integer_t pageins; /* number of actual pageins */ + integer_t cow_faults; /* number of copy-on-write faults */ + integer_t messages_sent; /* number of messages sent */ + integer_t messages_received; /* number of messages received */ + integer_t syscalls_mach; /* number of mach system calls */ + integer_t syscalls_unix; /* number of unix system calls */ + integer_t csw; /* number of context switches */ +}; +typedef struct task_events_info task_events_info_data_t; +typedef struct task_events_info *task_events_info_t; +#define TASK_EVENTS_INFO_COUNT ((mach_msg_type_number_t) \ + (sizeof(task_events_info_data_t) / sizeof(natural_t))) + +#define TASK_THREAD_TIMES_INFO 3 /* total times for live threads - + only accurate if suspended */ + +struct task_thread_times_info { + time_value_t user_time; /* total user run time for + live threads */ + time_value_t system_time; /* total system run time for + live threads */ +}; + +typedef struct task_thread_times_info task_thread_times_info_data_t; +typedef struct task_thread_times_info *task_thread_times_info_t; +#define TASK_THREAD_TIMES_INFO_COUNT ((mach_msg_type_number_t) \ + (sizeof(task_thread_times_info_data_t) / sizeof(natural_t))) + +#define TASK_ABSOLUTETIME_INFO 1 + +struct task_absolutetime_info { + uint64_t total_user; /* total time */ + uint64_t total_system; + uint64_t threads_user; /* existing threads only */ + uint64_t threads_system; +}; + +typedef struct task_absolutetime_info task_absolutetime_info_data_t; +typedef struct task_absolutetime_info *task_absolutetime_info_t; +#define TASK_ABSOLUTETIME_INFO_COUNT ((mach_msg_type_number_t) \ + (sizeof (task_absolutetime_info_data_t) / sizeof (natural_t))) + +#define TASK_SECURITY_TOKEN 13 +#define TASK_SECURITY_TOKEN_COUNT ((mach_msg_type_number_t) \ + (sizeof(security_token_t) / sizeof(natural_t))) + +#define TASK_AUDIT_TOKEN 15 +#define TASK_AUDIT_TOKEN_COUNT \ + (sizeof(audit_token_t) / sizeof(natural_t)) + + +#define TASK_AFFINITY_TAG_INFO 16 /* This is experimental. */ + +struct task_affinity_tag_info { + integer_t set_count; + integer_t min; + integer_t max; + integer_t task_count; +}; +typedef struct task_affinity_tag_info task_affinity_tag_info_data_t; +typedef struct task_affinity_tag_info *task_affinity_tag_info_t; +#define TASK_AFFINITY_TAG_INFO_COUNT \ + (sizeof(task_affinity_tag_info_data_t) / sizeof(natural_t)) + +#define TASK_DYLD_INFO 17 /* This is experimental. */ + +struct task_dyld_info { + mach_vm_address_t all_image_info_addr; + mach_vm_size_t all_image_info_size; +}; +typedef struct task_dyld_info task_dyld_info_data_t; +typedef struct task_dyld_info *task_dyld_info_t; +#define TASK_DYLD_INFO_COUNT \ + (sizeof(task_dyld_info_data_t) / sizeof(natural_t)) + +#pragma pack() + + +/* + * Obsolete interfaces. + */ + +#define TASK_SCHED_TIMESHARE_INFO 10 +#define TASK_SCHED_RR_INFO 11 +#define TASK_SCHED_FIFO_INFO 12 + +#define TASK_SCHED_INFO 14 + +#endif /* _MACH_TASK_INFO_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/task_access.defs =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/task_access.defs (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/task_access.defs (revision 885) @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2006 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@ + */ + +subsystem +#if KERNEL_USER + KernelUser +#endif /* KERN_USER */ + task_access 27000; + +#include <mach/std_types.defs> +#include <mach/mach_types.defs> + +/* + * Verify task_for_pid access for the given pid + * Access granted by return value (success/failure) + */ +routine check_task_access( + task_access_port : mach_port_t; + calling_pid : int32_t; + calling_gid : uint32_t; + target_pid : int32_t; + ServerAuditToken caller_cred : audit_token_t); + +/* + * Search for a code signature for unsigned executables + */ +routine find_code_signature( + task_access_port : mach_port_t; + new_pid : int32_t); + +/* vim: set ft=c : */ Index: branches/azimutz/Cleancut/i386/include/mach/host_priv.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/host_priv.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/host_priv.h (revision 885) @@ -0,0 +1,1269 @@ +#ifndef _host_priv_user_ +#define _host_priv_user_ + +/* Module host_priv */ + +#include <string.h> +#include <mach/ndr.h> +#include <mach/boolean.h> +#include <mach/kern_return.h> +#include <mach/notify.h> +#include <mach/mach_types.h> +#include <mach/message.h> +#include <mach/mig_errors.h> +#include <mach/port.h> + +#ifdef AUTOTEST +#ifndef FUNCTION_PTR_T +#define FUNCTION_PTR_T +typedef void (*function_ptr_t)(mach_port_t, char *, mach_msg_type_number_t); +typedef struct { + char *name; + function_ptr_t function; +} function_table_entry; +typedef function_table_entry *function_table_t; +#endif /* FUNCTION_PTR_T */ +#endif /* AUTOTEST */ + +#ifndef host_priv_MSG_COUNT +#define host_priv_MSG_COUNT 26 +#endif /* host_priv_MSG_COUNT */ + +#include <mach/std_types.h> +#include <mach/mig.h> +#include <mach/mach_types.h> +#include <mach/mach_types.h> +#include <mach_debug/mach_debug_types.h> + +#ifdef __BeforeMigUserHeader +__BeforeMigUserHeader +#endif /* __BeforeMigUserHeader */ + +#include <sys/cdefs.h> +__BEGIN_DECLS + + +/* Routine host_get_boot_info */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t host_get_boot_info +( + host_priv_t host_priv, + kernel_boot_info_t boot_info +); + +/* Routine host_reboot */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t host_reboot +( + host_priv_t host_priv, + int options +); + +/* Routine host_priv_statistics */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t host_priv_statistics +( + host_priv_t host_priv, + host_flavor_t flavor, + host_info_t host_info_out, + mach_msg_type_number_t *host_info_outCnt +); + +/* Routine host_default_memory_manager */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t host_default_memory_manager +( + host_priv_t host_priv, + memory_object_default_t *default_manager, + memory_object_cluster_size_t cluster_size +); + +/* Routine vm_wire */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t vm_wire +( + host_priv_t host_priv, + vm_map_t task, + vm_address_t address, + vm_size_t size, + vm_prot_t desired_access +); + +/* Routine thread_wire */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_wire +( + host_priv_t host_priv, + thread_act_t thread, + boolean_t wired +); + +/* Routine vm_allocate_cpm */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t vm_allocate_cpm +( + host_priv_t host_priv, + vm_map_t task, + vm_address_t *address, + vm_size_t size, + int flags +); + +/* Routine host_processors */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t host_processors +( + host_priv_t host_priv, + processor_array_t *out_processor_list, + mach_msg_type_number_t *out_processor_listCnt +); + +/* Routine host_get_clock_control */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t host_get_clock_control +( + host_priv_t host_priv, + clock_id_t clock_id, + clock_ctrl_t *clock_ctrl +); + +/* Routine kmod_create */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t kmod_create +( + host_priv_t host_priv, + vm_address_t info, + kmod_t *module +); + +/* Routine kmod_destroy */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t kmod_destroy +( + host_priv_t host_priv, + kmod_t module +); + +/* Routine kmod_control */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t kmod_control +( + host_priv_t host_priv, + kmod_t module, + kmod_control_flavor_t flavor, + kmod_args_t *data, + mach_msg_type_number_t *dataCnt +); + +/* Routine host_get_special_port */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t host_get_special_port +( + host_priv_t host_priv, + int node, + int which, + mach_port_t *port +); + +/* Routine host_set_special_port */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t host_set_special_port +( + host_priv_t host_priv, + int which, + mach_port_t port +); + +/* Routine host_set_exception_ports */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t host_set_exception_ports +( + host_priv_t host_priv, + exception_mask_t exception_mask, + mach_port_t new_port, + exception_behavior_t behavior, + thread_state_flavor_t new_flavor +); + +/* Routine host_get_exception_ports */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t host_get_exception_ports +( + host_priv_t host_priv, + exception_mask_t exception_mask, + exception_mask_array_t masks, + mach_msg_type_number_t *masksCnt, + exception_handler_array_t old_handlers, + exception_behavior_array_t old_behaviors, + exception_flavor_array_t old_flavors +); + +/* Routine host_swap_exception_ports */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t host_swap_exception_ports +( + host_priv_t host_priv, + exception_mask_t exception_mask, + mach_port_t new_port, + exception_behavior_t behavior, + thread_state_flavor_t new_flavor, + exception_mask_array_t masks, + mach_msg_type_number_t *masksCnt, + exception_handler_array_t old_handlerss, + exception_behavior_array_t old_behaviors, + exception_flavor_array_t old_flavors +); + +/* Routine host_load_symbol_table */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t host_load_symbol_table +( + host_priv_t host, + task_t task, + symtab_name_t name, + vm_offset_t symtab, + mach_msg_type_number_t symtabCnt +); + +/* Routine mach_vm_wire */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_vm_wire +( + host_priv_t host_priv, + vm_map_t task, + mach_vm_address_t address, + mach_vm_size_t size, + vm_prot_t desired_access +); + +/* Routine host_processor_sets */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t host_processor_sets +( + host_priv_t host_priv, + processor_set_name_array_t *processor_sets, + mach_msg_type_number_t *processor_setsCnt +); + +/* Routine host_processor_set_priv */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t host_processor_set_priv +( + host_priv_t host_priv, + processor_set_name_t set_name, + processor_set_t *set +); + +/* Routine set_dp_control_port */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t set_dp_control_port +( + host_priv_t host, + mach_port_t control_port +); + +/* Routine get_dp_control_port */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t get_dp_control_port +( + host_priv_t host, + mach_port_t *contorl_port +); + +/* Routine host_set_UNDServer */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t host_set_UNDServer +( + host_priv_t host, + UNDServerRef server +); + +/* Routine host_get_UNDServer */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t host_get_UNDServer +( + host_priv_t host, + UNDServerRef *server +); + +/* Routine kext_request */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t kext_request +( + host_priv_t host_priv, + uint32_t user_log_flags, + vm_offset_t request_data, + mach_msg_type_number_t request_dataCnt, + vm_offset_t *response_data, + mach_msg_type_number_t *response_dataCnt, + vm_offset_t *log_data, + mach_msg_type_number_t *log_dataCnt, + kern_return_t *op_result +); + +__END_DECLS + +/********************** Caution **************************/ +/* The following data types should be used to calculate */ +/* maximum message sizes only. The actual message may be */ +/* smaller, and the position of the arguments within the */ +/* message layout may vary from what is presented here. */ +/* For example, if any of the arguments are variable- */ +/* sized, and less than the maximum is sent, the data */ +/* will be packed tight in the actual message to reduce */ +/* the presence of holes. */ +/********************** Caution **************************/ + +/* typedefs for all requests */ + +#ifndef __Request__host_priv_subsystem__defined +#define __Request__host_priv_subsystem__defined + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__host_get_boot_info_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + int options; + } __Request__host_reboot_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + host_flavor_t flavor; + mach_msg_type_number_t host_info_outCnt; + } __Request__host_priv_statistics_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t default_manager; + /* end of the kernel processed data */ + NDR_record_t NDR; + memory_object_cluster_size_t cluster_size; + } __Request__host_default_memory_manager_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t task; + /* end of the kernel processed data */ + NDR_record_t NDR; + vm_address_t address; + vm_size_t size; + vm_prot_t desired_access; + } __Request__vm_wire_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t thread; + /* end of the kernel processed data */ + NDR_record_t NDR; + boolean_t wired; + } __Request__thread_wire_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t task; + /* end of the kernel processed data */ + NDR_record_t NDR; + vm_address_t address; + vm_size_t size; + int flags; + } __Request__vm_allocate_cpm_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__host_processors_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + clock_id_t clock_id; + } __Request__host_get_clock_control_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + vm_address_t info; + } __Request__kmod_create_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kmod_t module; + } __Request__kmod_destroy_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_descriptor_t data; + /* end of the kernel processed data */ + NDR_record_t NDR; + kmod_t module; + kmod_control_flavor_t flavor; + mach_msg_type_number_t dataCnt; + } __Request__kmod_control_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + int node; + int which; + } __Request__host_get_special_port_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t port; + /* end of the kernel processed data */ + NDR_record_t NDR; + int which; + } __Request__host_set_special_port_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t new_port; + /* end of the kernel processed data */ + NDR_record_t NDR; + exception_mask_t exception_mask; + exception_behavior_t behavior; + thread_state_flavor_t new_flavor; + } __Request__host_set_exception_ports_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + exception_mask_t exception_mask; + } __Request__host_get_exception_ports_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t new_port; + /* end of the kernel processed data */ + NDR_record_t NDR; + exception_mask_t exception_mask; + exception_behavior_t behavior; + thread_state_flavor_t new_flavor; + } __Request__host_swap_exception_ports_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t task; + mach_msg_ool_descriptor_t symtab; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t nameOffset; /* MiG doesn't use it */ + mach_msg_type_number_t nameCnt; + char name[32]; + mach_msg_type_number_t symtabCnt; + } __Request__host_load_symbol_table_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t task; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_vm_address_t address; + mach_vm_size_t size; + vm_prot_t desired_access; + } __Request__mach_vm_wire_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__host_processor_sets_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t set_name; + /* end of the kernel processed data */ + } __Request__host_processor_set_priv_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t control_port; + /* end of the kernel processed data */ + } __Request__set_dp_control_port_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__get_dp_control_port_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t server; + /* end of the kernel processed data */ + } __Request__host_set_UNDServer_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__host_get_UNDServer_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_descriptor_t request_data; + /* end of the kernel processed data */ + NDR_record_t NDR; + uint32_t user_log_flags; + mach_msg_type_number_t request_dataCnt; + } __Request__kext_request_t; +#ifdef __MigPackStructs +#pragma pack() +#endif +#endif /* !__Request__host_priv_subsystem__defined */ + +/* union of all requests */ + +#ifndef __RequestUnion__host_priv_subsystem__defined +#define __RequestUnion__host_priv_subsystem__defined +union __RequestUnion__host_priv_subsystem { + __Request__host_get_boot_info_t Request_host_get_boot_info; + __Request__host_reboot_t Request_host_reboot; + __Request__host_priv_statistics_t Request_host_priv_statistics; + __Request__host_default_memory_manager_t Request_host_default_memory_manager; + __Request__vm_wire_t Request_vm_wire; + __Request__thread_wire_t Request_thread_wire; + __Request__vm_allocate_cpm_t Request_vm_allocate_cpm; + __Request__host_processors_t Request_host_processors; + __Request__host_get_clock_control_t Request_host_get_clock_control; + __Request__kmod_create_t Request_kmod_create; + __Request__kmod_destroy_t Request_kmod_destroy; + __Request__kmod_control_t Request_kmod_control; + __Request__host_get_special_port_t Request_host_get_special_port; + __Request__host_set_special_port_t Request_host_set_special_port; + __Request__host_set_exception_ports_t Request_host_set_exception_ports; + __Request__host_get_exception_ports_t Request_host_get_exception_ports; + __Request__host_swap_exception_ports_t Request_host_swap_exception_ports; + __Request__host_load_symbol_table_t Request_host_load_symbol_table; + __Request__mach_vm_wire_t Request_mach_vm_wire; + __Request__host_processor_sets_t Request_host_processor_sets; + __Request__host_processor_set_priv_t Request_host_processor_set_priv; + __Request__set_dp_control_port_t Request_set_dp_control_port; + __Request__get_dp_control_port_t Request_get_dp_control_port; + __Request__host_set_UNDServer_t Request_host_set_UNDServer; + __Request__host_get_UNDServer_t Request_host_get_UNDServer; + __Request__kext_request_t Request_kext_request; +}; +#endif /* !__RequestUnion__host_priv_subsystem__defined */ +/* typedefs for all replies */ + +#ifndef __Reply__host_priv_subsystem__defined +#define __Reply__host_priv_subsystem__defined + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_msg_type_number_t boot_infoOffset; /* MiG doesn't use it */ + mach_msg_type_number_t boot_infoCnt; + char boot_info[4096]; + } __Reply__host_get_boot_info_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__host_reboot_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_msg_type_number_t host_info_outCnt; + integer_t host_info_out[15]; + } __Reply__host_priv_statistics_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t default_manager; + /* end of the kernel processed data */ + } __Reply__host_default_memory_manager_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__vm_wire_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_wire_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + vm_address_t address; + } __Reply__vm_allocate_cpm_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_ports_descriptor_t out_processor_list; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t out_processor_listCnt; + } __Reply__host_processors_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t clock_ctrl; + /* end of the kernel processed data */ + } __Reply__host_get_clock_control_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + kmod_t module; + } __Reply__kmod_create_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__kmod_destroy_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_descriptor_t data; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t dataCnt; + } __Reply__kmod_control_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t port; + /* end of the kernel processed data */ + } __Reply__host_get_special_port_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__host_set_special_port_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__host_set_exception_ports_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t old_handlers[32]; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t masksCnt; + exception_mask_t masks[32]; + exception_behavior_t old_behaviors[32]; + thread_state_flavor_t old_flavors[32]; + } __Reply__host_get_exception_ports_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t old_handlerss[32]; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t masksCnt; + exception_mask_t masks[32]; + exception_behavior_t old_behaviors[32]; + thread_state_flavor_t old_flavors[32]; + } __Reply__host_swap_exception_ports_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__host_load_symbol_table_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__mach_vm_wire_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_ports_descriptor_t processor_sets; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t processor_setsCnt; + } __Reply__host_processor_sets_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t set; + /* end of the kernel processed data */ + } __Reply__host_processor_set_priv_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__set_dp_control_port_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t contorl_port; + /* end of the kernel processed data */ + } __Reply__get_dp_control_port_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__host_set_UNDServer_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t server; + /* end of the kernel processed data */ + } __Reply__host_get_UNDServer_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_descriptor_t response_data; + mach_msg_ool_descriptor_t log_data; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t response_dataCnt; + mach_msg_type_number_t log_dataCnt; + kern_return_t op_result; + } __Reply__kext_request_t; +#ifdef __MigPackStructs +#pragma pack() +#endif +#endif /* !__Reply__host_priv_subsystem__defined */ + +/* union of all replies */ + +#ifndef __ReplyUnion__host_priv_subsystem__defined +#define __ReplyUnion__host_priv_subsystem__defined +union __ReplyUnion__host_priv_subsystem { + __Reply__host_get_boot_info_t Reply_host_get_boot_info; + __Reply__host_reboot_t Reply_host_reboot; + __Reply__host_priv_statistics_t Reply_host_priv_statistics; + __Reply__host_default_memory_manager_t Reply_host_default_memory_manager; + __Reply__vm_wire_t Reply_vm_wire; + __Reply__thread_wire_t Reply_thread_wire; + __Reply__vm_allocate_cpm_t Reply_vm_allocate_cpm; + __Reply__host_processors_t Reply_host_processors; + __Reply__host_get_clock_control_t Reply_host_get_clock_control; + __Reply__kmod_create_t Reply_kmod_create; + __Reply__kmod_destroy_t Reply_kmod_destroy; + __Reply__kmod_control_t Reply_kmod_control; + __Reply__host_get_special_port_t Reply_host_get_special_port; + __Reply__host_set_special_port_t Reply_host_set_special_port; + __Reply__host_set_exception_ports_t Reply_host_set_exception_ports; + __Reply__host_get_exception_ports_t Reply_host_get_exception_ports; + __Reply__host_swap_exception_ports_t Reply_host_swap_exception_ports; + __Reply__host_load_symbol_table_t Reply_host_load_symbol_table; + __Reply__mach_vm_wire_t Reply_mach_vm_wire; + __Reply__host_processor_sets_t Reply_host_processor_sets; + __Reply__host_processor_set_priv_t Reply_host_processor_set_priv; + __Reply__set_dp_control_port_t Reply_set_dp_control_port; + __Reply__get_dp_control_port_t Reply_get_dp_control_port; + __Reply__host_set_UNDServer_t Reply_host_set_UNDServer; + __Reply__host_get_UNDServer_t Reply_host_get_UNDServer; + __Reply__kext_request_t Reply_kext_request; +}; +#endif /* !__RequestUnion__host_priv_subsystem__defined */ + +#ifndef subsystem_to_name_map_host_priv +#define subsystem_to_name_map_host_priv \ + { "host_get_boot_info", 400 },\ + { "host_reboot", 401 },\ + { "host_priv_statistics", 402 },\ + { "host_default_memory_manager", 403 },\ + { "vm_wire", 404 },\ + { "thread_wire", 405 },\ + { "vm_allocate_cpm", 406 },\ + { "host_processors", 407 },\ + { "host_get_clock_control", 408 },\ + { "kmod_create", 409 },\ + { "kmod_destroy", 410 },\ + { "kmod_control", 411 },\ + { "host_get_special_port", 412 },\ + { "host_set_special_port", 413 },\ + { "host_set_exception_ports", 414 },\ + { "host_get_exception_ports", 415 },\ + { "host_swap_exception_ports", 416 },\ + { "host_load_symbol_table", 417 },\ + { "mach_vm_wire", 418 },\ + { "host_processor_sets", 419 },\ + { "host_processor_set_priv", 420 },\ + { "set_dp_control_port", 421 },\ + { "get_dp_control_port", 422 },\ + { "host_set_UNDServer", 423 },\ + { "host_get_UNDServer", 424 },\ + { "kext_request", 425 } +#endif + +#ifdef __AfterMigUserHeader +__AfterMigUserHeader +#endif /* __AfterMigUserHeader */ + +#endif /* _host_priv_user_ */ Index: branches/azimutz/Cleancut/i386/include/mach/bootstrap.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/bootstrap.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/bootstrap.h (revision 885) @@ -0,0 +1,34 @@ +/* + * Copyright (c) 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@ + */ +/* + * Mach bootstrap interfaces (obsolete: header included only for compatibility) + */ +#ifndef _MACH_BOOTSTRAP_H_ +#define _MACH_BOOTSTRAP_H_ + +#endif /* _MACH_BOOTSTRAP_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/machine/processor_info.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/machine/processor_info.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/machine/processor_info.h (revision 885) @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2000-2007 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 _MACH_MACHINE_PROCESSOR_INFO_H_ +#define _MACH_MACHINE_PROCESSOR_INFO_H_ + +#if defined (__ppc__) || defined (__ppc64__) +#include "mach/ppc/processor_info.h" +#elif defined (__i386__) || defined(__x86_64__) +#include "mach/i386/processor_info.h" +#elif defined (__arm__) +#include "mach/arm/processor_info.h" +#else +#error architecture not supported +#endif + +#endif /* _MACH_MACHINE_PROCESSOR_INFO_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/machine/sdt.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/machine/sdt.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/machine/sdt.h (revision 885) @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2007 Apple Inc. All rights reserved. + */ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _MACH_MACHINE_SYS_SDT_H +#define _MACH_MACHINE_SYS_SDT_H + +#include <mach/machine/sdt_isa.h> + + +#endif /* _MACH_MACHINE_SYS_SDT_H */ Index: branches/azimutz/Cleancut/i386/include/mach/machine/thread_status.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/machine/thread_status.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/machine/thread_status.h (revision 885) @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2000-2007 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 _MACH_MACHINE_THREAD_STATUS_H_ +#define _MACH_MACHINE_THREAD_STATUS_H_ + +#if defined (__ppc__) || defined (__ppc64__) +#include "mach/ppc/thread_status.h" +#elif defined (__i386__) || defined(__x86_64__) +#include "mach/i386/thread_status.h" +#elif defined (__arm__) +#include "mach/arm/thread_status.h" +#else +#error architecture not supported +#endif + +#endif /* _MACH_MACHINE_THREAD_STATUS_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/machine/exception.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/machine/exception.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/machine/exception.h (revision 885) @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2000-2007 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 _MACH_MACHINE_EXCEPTION_H_ +#define _MACH_MACHINE_EXCEPTION_H_ + +#if defined (__ppc__) || defined (__ppc64__) +#include "mach/ppc/exception.h" +#elif defined (__i386__) || defined(__x86_64__) +#include "mach/i386/exception.h" +#elif defined (__arm__) +#include "mach/arm/exception.h" +#else +#error architecture not supported +#endif + +#endif /* _MACH_MACHINE_EXCEPTION_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/machine/kern_return.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/machine/kern_return.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/machine/kern_return.h (revision 885) @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2000-2007 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 _MACH_MACHINE_KERN_RETURN_H_ +#define _MACH_MACHINE_KERN_RETURN_H_ + +#if defined (__ppc__) || defined (__ppc64__) +#include "mach/ppc/kern_return.h" +#elif defined (__i386__) || defined(__x86_64__) +#include "mach/i386/kern_return.h" +#elif defined (__arm__) +#include "mach/arm/kern_return.h" +#else +#error architecture not supported +#endif + +#endif /* _MACH_MACHINE_KERN_RETURN_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/machine/boolean.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/machine/boolean.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/machine/boolean.h (revision 885) @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2000-2007 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 _MACH_MACHINE_BOOLEAN_H_ +#define _MACH_MACHINE_BOOLEAN_H_ + +#if defined (__ppc__) || defined (__ppc64__) +#include "mach/ppc/boolean.h" +#elif defined (__i386__) || defined(__x86_64__) +#include "mach/i386/boolean.h" +#elif defined (__arm__) +#include "mach/arm/boolean.h" +#else +#error architecture not supported +#endif + +#endif /* _MACH_MACHINE_BOOLEAN_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/machine/asm.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/machine/asm.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/machine/asm.h (revision 885) @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2000-2007 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 _MACH_MACHINE_ASM_H +#define _MACH_MACHINE_ASM_H + +#if defined (__ppc__) || defined (__ppc64__) +#include "mach/ppc/asm.h" +#elif defined (__i386__) || defined(__x86_64__) +#include "mach/i386/asm.h" +#elif defined (__arm__) +#include "mach/arm/asm.h" +#else +#error architecture not supported +#endif + +#endif /* _MACH_MACHINE_ASM_H */ Index: branches/azimutz/Cleancut/i386/include/mach/machine/ndr_def.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/machine/ndr_def.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/machine/ndr_def.h (revision 885) @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2000-2007 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 _MACH_MACHINE_NDR_DEF_H +#define _MACH_MACHINE_NDR_DEF_H + +#if defined (__ppc__) || defined (__ppc64__) +#include "mach/ppc/ndr_def.h" +#elif defined (__i386__) || defined(__x86_64__) +#include "mach/i386/ndr_def.h" +#elif defined (__arm__) +#include "mach/arm/ndr_def.h" +#else +#error architecture not supported +#endif + +#endif /* _MACH_MACHINE_NDR_DEF_H */ Index: branches/azimutz/Cleancut/i386/include/mach/machine/machine_types.defs =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/machine/machine_types.defs (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/machine/machine_types.defs (revision 885) @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2000-2006 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 _MACH_MACHINE_MACHINE_TYPES_DEFS +#define _MACH_MACHINE_MACHINE_TYPES_DEFS + +#if defined (__ppc__) || defined (__ppc64__) +#include "mach/ppc/machine_types.defs" +#elif defined (__i386__) || defined(__x86_64__) +#include "mach/i386/machine_types.defs" +#elif defined (__arm__) +#include "mach/arm/machine_types.defs" +#else +#error architecture not supported +#endif + +#endif /* _MACH_MACHINE_THREAD_STATUS_H_ */ + +/* vim: set ft=c : */ Index: branches/azimutz/Cleancut/i386/include/mach/machine/vm_param.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/machine/vm_param.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/machine/vm_param.h (revision 885) @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2000-2007 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 _MACH_MACHINE_VM_PARAM_H_ +#define _MACH_MACHINE_VM_PARAM_H_ + +#if defined (__ppc__) || defined (__ppc64__) +#include "mach/ppc/vm_param.h" +#elif defined (__i386__) || defined(__x86_64__) +#include "mach/i386/vm_param.h" +#elif defined (__arm__) +#include "mach/arm/vm_param.h" +#else +#error architecture not supported +#endif + +#endif /* _MACH_MACHINE_VM_PARAM_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/machine/rpc.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/machine/rpc.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/machine/rpc.h (revision 885) @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2000-2007 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 _MACH_MACHINE_RPC_H_ +#define _MACH_MACHINE_RPC_H_ + +#if defined (__ppc__) || defined (__ppc64__) +#include "mach/ppc/rpc.h" +#elif defined (__i386__) || defined(__x86_64__) +#include "mach/i386/rpc.h" +#elif defined (__arm__) +#include "mach/arm/rpc.h" +#else +#error architecture not supported +#endif + +#endif /* _MACH_MACHINE_RPC_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/machine/sdt_isa.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/machine/sdt_isa.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/machine/sdt_isa.h (revision 885) @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2000-2007 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 _MACH_MACHINE_SDT_ISA_H_ +#define _MACH_MACHINE_SDT_ISA_H_ + +#if defined (__ppc__) || defined (__ppc64__) +#include <mach/ppc/sdt_isa.h> +#elif defined (__i386__) || defined(__x86_64__) +#include <mach/i386/sdt_isa.h> +#elif defined (__arm__) +#include <mach/arm/sdt_isa.h> +#else +#error architecture not supported +#endif + +#endif /* _BSD_MACHINE_SDT_ISA_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/machine/vm_types.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/machine/vm_types.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/machine/vm_types.h (revision 885) @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2000-2007 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 _MACH_MACHINE_VM_TYPES_H_ +#define _MACH_MACHINE_VM_TYPES_H_ + +#if defined (__ppc__) || defined(__ppc64__) +#include "mach/ppc/vm_types.h" +#elif defined (__i386__) || defined(__x86_64__) +#include "mach/i386/vm_types.h" +#elif defined (__arm__) +#include "mach/arm/vm_types.h" +#else +#error architecture not supported +#endif + +#endif /* _MACH_MACHINE_VM_TYPES_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/machine/thread_state.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/machine/thread_state.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/machine/thread_state.h (revision 885) @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2000-2007 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 _MACH_MACHINE_THREAD_STATE_H_ +#define _MACH_MACHINE_THREAD_STATE_H_ + +#if defined (__ppc__) || defined(__ppc64__) +#include "mach/ppc/thread_state.h" +#elif defined (__i386__) || defined(__x86_64__) +#include "mach/i386/thread_state.h" +#elif defined (__arm__) +#include "mach/arm/thread_state.h" +#else +#error architecture not supported +#endif + +#endif /* _MACH_MACHINE_THREAD_STATE_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/mach_error.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/mach_error.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/mach_error.h (revision 885) @@ -0,0 +1,93 @@ +/* + * Copyright (c) 1999 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@ + */ +/* + * 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 + * 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 Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie the + * rights to redistribute these changes. + */ + +/* + * File: mach_error.h + * Author: Douglas Orr, Carnegie Mellon University + * Date: Mar. 1988 + * + * Definitions of routines in mach_error.c + */ + +#ifndef _MACH_ERROR_ +#define _MACH_ERROR_ 1 + +#include <mach/error.h> + +#include <sys/cdefs.h> + +__BEGIN_DECLS +char *mach_error_string( +/* + * Returns a string appropriate to the error argument given + */ + mach_error_t error_value + ); + +void mach_error( +/* + * Prints an appropriate message on the standard error stream + */ + const char *str, + mach_error_t error_value + ); + +char *mach_error_type( +/* + * Returns a string with the error system, subsystem and code + */ + mach_error_t error_value + ); +__END_DECLS + +#endif /* _MACH_ERROR_ */ Index: branches/azimutz/Cleancut/i386/include/mach/vm_region.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/vm_region.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/vm_region.h (revision 885) @@ -0,0 +1,320 @@ +/* + * Copyright (c) 2000-2006 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@ + */ +/* + * File: mach/vm_region.h + * + * Define the attributes of a task's memory region + * + */ + +#ifndef _MACH_VM_REGION_H_ +#define _MACH_VM_REGION_H_ + +#include <mach/boolean.h> +#include <mach/vm_prot.h> +#include <mach/vm_inherit.h> +#include <mach/vm_behavior.h> +#include <mach/vm_types.h> +#include <mach/message.h> +#include <mach/machine/vm_param.h> +#include <mach/machine/vm_types.h> +#include <mach/memory_object_types.h> + +#include <sys/cdefs.h> + +#pragma pack(4) + +// LP64todo: all the current tools are 32bit, obviously never worked for 64b +// so probably should be a real 32b ID vs. ptr. +// Current users just check for equality +typedef uint32_t vm32_object_id_t; + +/* + * Types defined: + * + * vm_region_info_t memory region attributes + */ + +#define VM_REGION_INFO_MAX (1024) +typedef int *vm_region_info_t; +typedef int *vm_region_info_64_t; +typedef int *vm_region_recurse_info_t; +typedef int *vm_region_recurse_info_64_t; +typedef int vm_region_flavor_t; +typedef int vm_region_info_data_t[VM_REGION_INFO_MAX]; + +#define VM_REGION_BASIC_INFO_64 9 +struct vm_region_basic_info_64 { + vm_prot_t protection; + vm_prot_t max_protection; + vm_inherit_t inheritance; + boolean_t shared; + boolean_t reserved; + memory_object_offset_t offset; + vm_behavior_t behavior; + unsigned short user_wired_count; +}; +typedef struct vm_region_basic_info_64 *vm_region_basic_info_64_t; +typedef struct vm_region_basic_info_64 vm_region_basic_info_data_64_t; + +#define VM_REGION_BASIC_INFO_COUNT_64 ((mach_msg_type_number_t) \ + (sizeof(vm_region_basic_info_data_64_t)/sizeof(int))) + +/* + * Passing VM_REGION_BASIC_INFO to vm_region_64 + * automatically converts it to a VM_REGION_BASIC_INFO_64. + * Please use that explicitly instead. + */ +#define VM_REGION_BASIC_INFO 10 + +/* + * This is the legacy basic info structure. It is + * deprecated because it passes only a 32-bit memory object + * offset back - too small for many larger objects (e.g. files). + */ +struct vm_region_basic_info { + vm_prot_t protection; + vm_prot_t max_protection; + vm_inherit_t inheritance; + boolean_t shared; + boolean_t reserved; + uint32_t offset; /* too small for a real offset */ + vm_behavior_t behavior; + unsigned short user_wired_count; +}; + +typedef struct vm_region_basic_info *vm_region_basic_info_t; +typedef struct vm_region_basic_info vm_region_basic_info_data_t; + +#define VM_REGION_BASIC_INFO_COUNT ((mach_msg_type_number_t) \ + (sizeof(vm_region_basic_info_data_t)/sizeof(int))) + +#define VM_REGION_EXTENDED_INFO 11 + +#define SM_COW 1 +#define SM_PRIVATE 2 +#define SM_EMPTY 3 +#define SM_SHARED 4 +#define SM_TRUESHARED 5 +#define SM_PRIVATE_ALIASED 6 +#define SM_SHARED_ALIASED 7 + +/* + * For submap info, the SM flags above are overlayed when a submap + * is encountered. The field denotes whether or not machine level mapping + * information is being shared. PTE's etc. When such sharing is taking + * place the value returned is SM_TRUESHARED otherwise SM_PRIVATE is passed + * back. + */ + +struct vm_region_extended_info { + vm_prot_t protection; + unsigned int user_tag; + unsigned int pages_resident; + unsigned int pages_shared_now_private; + unsigned int pages_swapped_out; + unsigned int pages_dirtied; + unsigned int ref_count; + unsigned short shadow_depth; + unsigned char external_pager; + unsigned char share_mode; +}; + +typedef struct vm_region_extended_info *vm_region_extended_info_t; +typedef struct vm_region_extended_info vm_region_extended_info_data_t; + +#define VM_REGION_EXTENDED_INFO_COUNT ((mach_msg_type_number_t) \ + (sizeof(vm_region_extended_info_data_t)/sizeof(int))) + + +#define VM_REGION_TOP_INFO 12 + +struct vm_region_top_info { + unsigned int obj_id; + unsigned int ref_count; + unsigned int private_pages_resident; + unsigned int shared_pages_resident; + unsigned char share_mode; +}; + +typedef struct vm_region_top_info *vm_region_top_info_t; +typedef struct vm_region_top_info vm_region_top_info_data_t; + +#define VM_REGION_TOP_INFO_COUNT ((mach_msg_type_number_t) \ + (sizeof(vm_region_top_info_data_t)/sizeof(int))) + + + +/* + * vm_region_submap_info will return information on a submap or object. + * The user supplies a nesting level on the call. When a walk of the + * user's map is done and a submap is encountered, the nesting count is + * checked. If the nesting count is greater than 1 the submap is entered and + * the offset relative to the address in the base map is examined. If the + * nesting count is zero, the information on the submap is returned. + * The caller may thus learn about a submap and its contents by judicious + * choice of the base map address and nesting count. The nesting count + * allows penetration of recursively mapped submaps. If a submap is + * encountered as a mapped entry of another submap, the caller may bump + * the nesting count and call vm_region_recurse again on the target address + * range. The "is_submap" field tells the caller whether or not a submap + * has been encountered. + * + * Object only fields are filled in through a walking of the object shadow + * chain (where one is present), and a walking of the resident page queue. + * + */ + +struct vm_region_submap_info { + vm_prot_t protection; /* present access protection */ + vm_prot_t max_protection; /* max avail through vm_prot */ + vm_inherit_t inheritance;/* behavior of map/obj on fork */ + uint32_t offset; /* offset into object/map */ + unsigned int user_tag; /* user tag on map entry */ + unsigned int pages_resident; /* only valid for objects */ + unsigned int pages_shared_now_private; /* only for objects */ + unsigned int pages_swapped_out; /* only for objects */ + unsigned int pages_dirtied; /* only for objects */ + unsigned int ref_count; /* obj/map mappers, etc */ + unsigned short shadow_depth; /* only for obj */ + unsigned char external_pager; /* only for obj */ + unsigned char share_mode; /* see enumeration */ + boolean_t is_submap; /* submap vs obj */ + vm_behavior_t behavior; /* access behavior hint */ + vm32_object_id_t object_id; /* obj/map name, not a handle */ + unsigned short user_wired_count; +}; + +typedef struct vm_region_submap_info *vm_region_submap_info_t; +typedef struct vm_region_submap_info vm_region_submap_info_data_t; + +#define VM_REGION_SUBMAP_INFO_COUNT ((mach_msg_type_number_t) \ + (sizeof(vm_region_submap_info_data_t)/sizeof(int))) + +struct vm_region_submap_info_64 { + vm_prot_t protection; /* present access protection */ + vm_prot_t max_protection; /* max avail through vm_prot */ + vm_inherit_t inheritance;/* behavior of map/obj on fork */ + memory_object_offset_t offset; /* offset into object/map */ + unsigned int user_tag; /* user tag on map entry */ + unsigned int pages_resident; /* only valid for objects */ + unsigned int pages_shared_now_private; /* only for objects */ + unsigned int pages_swapped_out; /* only for objects */ + unsigned int pages_dirtied; /* only for objects */ + unsigned int ref_count; /* obj/map mappers, etc */ + unsigned short shadow_depth; /* only for obj */ + unsigned char external_pager; /* only for obj */ + unsigned char share_mode; /* see enumeration */ + boolean_t is_submap; /* submap vs obj */ + vm_behavior_t behavior; /* access behavior hint */ + vm32_object_id_t object_id; /* obj/map name, not a handle */ + unsigned short user_wired_count; +}; + +typedef struct vm_region_submap_info_64 *vm_region_submap_info_64_t; +typedef struct vm_region_submap_info_64 vm_region_submap_info_data_64_t; + +#define VM_REGION_SUBMAP_INFO_COUNT_64 ((mach_msg_type_number_t) \ + (sizeof(vm_region_submap_info_data_64_t)/sizeof(int))) + +struct vm_region_submap_short_info_64 { + vm_prot_t protection; /* present access protection */ + vm_prot_t max_protection; /* max avail through vm_prot */ + vm_inherit_t inheritance;/* behavior of map/obj on fork */ + memory_object_offset_t offset; /* offset into object/map */ + unsigned int user_tag; /* user tag on map entry */ + unsigned int ref_count; /* obj/map mappers, etc */ + unsigned short shadow_depth; /* only for obj */ + unsigned char external_pager; /* only for obj */ + unsigned char share_mode; /* see enumeration */ + boolean_t is_submap; /* submap vs obj */ + vm_behavior_t behavior; /* access behavior hint */ + vm32_object_id_t object_id; /* obj/map name, not a handle */ + unsigned short user_wired_count; +}; + +typedef struct vm_region_submap_short_info_64 *vm_region_submap_short_info_64_t; +typedef struct vm_region_submap_short_info_64 vm_region_submap_short_info_data_64_t; + +#define VM_REGION_SUBMAP_SHORT_INFO_COUNT_64 ((mach_msg_type_number_t) \ + (sizeof(vm_region_submap_short_info_data_64_t)/sizeof(int))) + + +struct mach_vm_read_entry { + mach_vm_address_t address; + mach_vm_size_t size; +}; + +struct vm_read_entry { + vm_address_t address; + vm_size_t size; +}; + +#if VM32_SUPPORT +struct vm32_read_entry { + vm32_address_t address; + vm32_size_t size; +}; +#endif + + +#define VM_MAP_ENTRY_MAX (256) + +typedef struct mach_vm_read_entry mach_vm_read_entry_t[VM_MAP_ENTRY_MAX]; +typedef struct vm_read_entry vm_read_entry_t[VM_MAP_ENTRY_MAX]; +#if VM32_SUPPORT +typedef struct vm32_read_entry vm32_read_entry_t[VM_MAP_ENTRY_MAX]; +#endif + +#pragma pack() + + +#define VM_PAGE_INFO_MAX +typedef int *vm_page_info_t; +typedef int vm_page_info_data_t[VM_PAGE_INFO_MAX]; +typedef int vm_page_info_flavor_t; + +#define VM_PAGE_INFO_BASIC 1 +struct vm_page_info_basic { + int disposition; + int ref_count; + vm_object_id_t object_id; + memory_object_offset_t offset; + int depth; +}; +typedef struct vm_page_info_basic *vm_page_info_basic_t; +typedef struct vm_page_info_basic vm_page_info_basic_data_t; + +#define VM_PAGE_INFO_BASIC_COUNT ((mach_msg_type_number_t) \ + (sizeof(vm_page_info_basic_data_t)/sizeof(int))) + + +#endif /*_MACH_VM_REGION_H_*/ Index: branches/azimutz/Cleancut/i386/include/mach/clock_priv.defs =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/clock_priv.defs (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/clock_priv.defs (revision 885) @@ -0,0 +1,69 @@ +/* + * Copyright (c) 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@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * File: mach/clock_priv.defs + * Purpose: Kernel clock subsystem definitions. This + * file defines the clock request interface. + */ + +subsystem +#if KERNEL_SERVER + KernelServer +#endif /* KERNEL_SERVER */ + clock_priv 1200; + +#include <mach/std_types.defs> +#include <mach/mach_types.defs> +#include <mach/clock_types.defs> + +/* + * References to clock_priv objects are returned by: + * host_get_clock_control(host_priv_t,...) - Priviledged subclass + */ + +/* + * Set the clock time. + * Privileged. + */ +routine clock_set_time( + clock_ctrl : clock_ctrl_t; + new_time : mach_timespec_t); + +/* + * Set clock attributes. + * Privileged. + */ +routine clock_set_attributes( + clock_ctrl : clock_ctrl_t; + in flavor : clock_flavor_t; + in clock_attr : clock_attr_t); + +/* vim: set ft=c : */ Index: branches/azimutz/Cleancut/i386/include/mach/mach_time.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/mach_time.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/mach_time.h (revision 885) @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2001-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 _MACH_MACH_TIME_H_ +#define _MACH_MACH_TIME_H_ + +#include <mach/mach_types.h> + +#include <sys/cdefs.h> + +struct mach_timebase_info { + uint32_t numer; + uint32_t denom; +}; + +typedef struct mach_timebase_info *mach_timebase_info_t; +typedef struct mach_timebase_info mach_timebase_info_data_t; + +__BEGIN_DECLS + +kern_return_t mach_timebase_info( + mach_timebase_info_t info); + +kern_return_t mach_wait_until( + uint64_t deadline); + + +uint64_t mach_absolute_time(void); +__END_DECLS + +#endif /* _MACH_MACH_TIME_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/mach_types.defs =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/mach_types.defs (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/mach_types.defs (revision 885) @@ -0,0 +1,474 @@ +/* + * Copyright (c) 2000-2009 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@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989,1988 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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + * NOTICE: This file was modified by McAfee Research in 2004 to introduce + * support for mandatory and extensible security protections. This notice + * is included in support of clause 2.2 (b) of the Apple Public License, + * Version 2.0. + */ +/* + */ +/* + * Mach kernel interface type declarations + */ + +#ifndef _MACH_MACH_TYPES_DEFS_ +#define _MACH_MACH_TYPES_DEFS_ + + +#include <mach/std_types.defs> + +type memory_object_offset_t = uint64_t; +type memory_object_size_t = uint64_t; +type memory_object_cluster_size_t = uint32_t; +type memory_object_fault_info_t = array[16] of integer_t; + + +type mach_port_status_t = struct[10] of integer_t; /* obsolete */ + + /* mach_port_info_t: can hold either a + * mach_port_status_t (9 ints) or a + * mach_port_limits_t (1 int). If new flavors of + * mach_port_{get,set}_attributes are added, the size of + * this array may have to be increased. (See mach/port.h) + */ +type mach_port_flavor_t = int; +type mach_port_info_t = array[*:10] of integer_t; + +type task_t = mach_port_t +#if KERNEL_SERVER + intran: task_t convert_port_to_task(mach_port_t) + outtran: mach_port_t convert_task_to_port(task_t) + destructor: task_deallocate(task_t) +#endif /* KERNEL_SERVER */ + ; + +type task_name_t = mach_port_t +#if KERNEL_SERVER + intran: task_name_t convert_port_to_task_name(mach_port_t) + outtran: mach_port_t convert_task_name_to_port(task_name_t) + destructor: task_name_deallocate(task_name_t) +#endif /* KERNEL_SERVER */ + ; + +type thread_t = mach_port_t +#if KERNEL_SERVER + intran: thread_t convert_port_to_thread(mach_port_t) + outtran: mach_port_t convert_thread_to_port(thread_t) + destructor: thread_deallocate(thread_t) +#endif /* KERNEL_SERVER */ + ; + +type thread_act_t = mach_port_t +#if KERNEL_SERVER + intran: thread_act_t convert_port_to_thread(mach_port_t) + outtran: mach_port_t convert_thread_to_port(thread_act_t) + destructor: thread_deallocate(thread_act_t) +#endif /* KERNEL_SERVER */ + ; + +type thread_act_consume_ref_t = mach_port_move_send_t + cusertype: thread_act_t +#if KERNEL_SERVER + intran: thread_act_t convert_port_to_thread(mach_port_t) + destructor: thread_deallocate(thread_act_t) +#endif /* KERNEL_SERVER */ + ; + + /* thread_state_t: This inline array can hold + * a machine-dependent amount of data, defined in + * mach/machine/???? (currently THREAD_STATE_MAX, + * in mach/thread_state.h) + */ +#include <mach/machine/thread_state.h> +type thread_state_flavor_t = int; +type thread_state_t = array[*:THREAD_STATE_MAX] of natural_t; + +type task_array_t = ^array[] of task_t; +type thread_array_t = ^array[] of thread_t; +type thread_act_array_t = ^array[] of thread_act_t; +type act_params_t = array[6] of int; + +type vm_map_t = mach_port_t +#if KERNEL_SERVER + intran: vm_map_t convert_port_to_map(mach_port_t) + destructor: vm_map_deallocate(vm_map_t) +#endif /* KERNEL_SERVER */ + ; + +type vm_task_entry_t = mach_port_t + cusertype: vm_map_t +#if KERNEL_SERVER + intran: vm_map_t convert_port_entry_to_map(mach_port_t) + destructor: vm_map_deallocate(vm_map_t) +#endif /* KERNEL_SERVER */ + ; + +type ipc_space_t = mach_port_t +#if KERNEL_SERVER + intran: ipc_space_t convert_port_to_space(mach_port_t) + destructor: space_deallocate(ipc_space_t) +#endif /* KERNEL_SERVER */ + ; + +type vm_prot_t = int; +type vm_inherit_t = int; +type vm_purgable_t = int; +type xxx_vm_statistics_data_t = struct[13] of integer_t; +type vm_behavior_t = int; +type vm_statistics_data_t = struct[15] of integer_t; +type vm_machine_attribute_t = int; +type vm_machine_attribute_val_t = int; +type vm_sync_t = int; + + /* thread_info_t: this inline array can hold any of: + * thread_basic_info_t (10 ints) + * policy_timeshare_info_t (5 ints) + * policy_fifo_info_t (4 ints) + * policy_rr_info_t (5 ints) + * if other thread_info flavors are added, this + * definition may need to be changed. (See + * mach/thread_info.h and mach/policy.h) */ +type thread_flavor_t = int; +type thread_info_t = array[*:12] of integer_t; + +type thread_policy_flavor_t = natural_t; +type thread_policy_t = array[*:16] of integer_t; + + /* task_info_t: this inline array can hold any of: + * task_basic_info_32_t (8 ints) + * task_basic_info_64_t (10 ints) + * task_events_info_t (8 ints) + * task_thread_times_info_t (4 ints) + * policy_timeshare_info_t (5 ints) + * policy_fifo_info_t (4 ints) + * policy_rr_info_t (5 ints) + * task security token (2 ints) + * task audit token (8 ints) + * If other task_info flavors are added, this + * definition may need to be changed. (See + * mach/task_info.h and mach/policy.h) */ +type task_flavor_t = int; +type task_info_t = array[*:10] of integer_t; + +type task_policy_flavor_t = natural_t; +type task_policy_t = array[*:16] of integer_t; + +type mem_entry_name_port_t = mach_port_t +#if KERNEL_SERVER + intran: mem_entry_name_port_t null_conversion(mach_port_t) + outtran: mach_port_t null_conversion(mem_entry_name_port_t) +#endif /* KERNEL_SERVER */ + ; + +type mem_entry_name_port_move_send_t = mach_port_move_send_t + cusertype: mem_entry_name_port_t +#if KERNEL_SERVER + intran: mem_entry_name_port_t null_conversion(mach_port_t) + outtran: mach_port_t null_conversion(mem_entry_name_port_t) +#endif /* KERNEL_SERVER */ + ; + +type memory_object_default_t = mach_port_t + ; + +type memory_object_t = mach_port_t + ; + + +type memory_object_control_t = mach_port_t + ; + +type memory_object_name_t = mach_port_t + ctype: mach_port_t + ; + + +type memory_object_copy_strategy_t = int; +type memory_object_return_t = int; + +type machine_info_data_t = struct[5] of integer_t; +type machine_slot_data_t = struct[8] of integer_t; + +type host_t = mach_port_t +#if KERNEL_SERVER + intran: host_t convert_port_to_host(mach_port_t) + outtran: mach_port_t convert_host_to_port(host_t) +#endif /* KERNEL_SERVER */ + ; + +type host_priv_t = mach_port_t +#if KERNEL_SERVER + intran: host_priv_t convert_port_to_host_priv(mach_port_t) +#endif /* KERNEL_SERVER */ + ; + +type host_security_t = mach_port_t +#if KERNEL_SERVER + intran: host_security_t convert_port_to_host_security(mach_port_t) +#endif /* KERNEL_SERVER */ + ; + + /* + * host_info_t: variable-sized inline array that can contain: + * + * host_basic_info_old_t (5 ints) + * host_basic_info_t (12 ints) + * host_sched_info_t (2 ints) + * kernel_resource_sizes_t (5 ints) + * host_load_info_t (6 ints) + * vm_statistics32_t (15 ints) + * + * If other host_info flavors are added, this definition may + * need to be changed. (See mach/{host_info,vm_statistics}.h) + */ +type host_flavor_t = int; +type host_info_t = array[*:15] of integer_t; + + + /* + * host_info64_t: variable-sized inline array that can contain: + * + * vm_statistics_t (6 ints and 9 longs) + */ +type host_info64_t = array[*:256] of integer_t; + +type processor_t = mach_port_t +#if KERNEL_SERVER + intran: processor_t convert_port_to_processor(mach_port_t) + outtran: mach_port_t convert_processor_to_port(processor_t) +#endif /* KERNEL_SERVER */ + ; + +type processor_array_t = ^array[] of processor_t; + + /* processor_info_t: variable-sized inline array that can + * contain: + * processor_basic_info_t: (5 ints) + * processor_cpu_load_info_t:(4 ints) + * processor_machine_info_t :(12 ints) + * If other processor_info flavors are added, this definition + * may need to be changed. (See mach/processor_info.h) */ +type processor_flavor_t = int; +type processor_info_t = array[*:12] of integer_t; +type processor_info_array_t = ^array[] of integer_t; + +type processor_set_t = mach_port_t +#if KERNEL_SERVER + intran: processor_set_t convert_port_to_pset(mach_port_t) + outtran: mach_port_t convert_pset_to_port(processor_set_t) + destructor: pset_deallocate(processor_set_t) +#endif /* KERNEL_SERVER */ + ; + +type processor_set_array_t = ^array[] of processor_set_t; + +type processor_set_name_t = mach_port_t +#if KERNEL_SERVER + intran: processor_set_name_t convert_port_to_pset_name(mach_port_t) + outtran: mach_port_t convert_pset_name_to_port(processor_set_name_t) + destructor: pset_deallocate(processor_set_name_t) +#endif /* KERNEL_SERVER */ + ; + +type processor_set_name_array_t = ^array[] of processor_set_name_t; + + /* processor_set_info_t: variable-size inline array + * that can hold: + * processor_set_basic_info (5 ints) + * processor_set_load_info (4 ints) + * policy_timeshare_base_t (1 int) + * policy_fifo_base_t (1 int) + * policy_rr_base_t (1 int) + * policy_timeshare_base_t (1 int) + * policy_fifo_base_t (1 int) + * policy_rr_base_t (1 int) + * policy_t (1 int) + * If other flavors are added, this definition may + * need to be changed. (see mach/processor.h) */ +type processor_set_flavor_t = int; +type processor_set_info_t = array[*:5] of integer_t; + +type bootstrap_t = mach_port_t; + +type kernel_version_t = c_string[*:512]; +type kernel_boot_info_t = c_string[*:4096]; + +type time_value_t = struct[2] of integer_t; + +type mach_port_qos_t = struct[2] of integer_t; + +type emulation_vector_t = ^array[] of vm_offset_t; + +type inline_existence_map_t = array[*:512] of char; + +type policy_t = int; + /* policy_info_t: variable-size inline array. Can hold: + * policy_timeshare_info_t (5 ints) + * policy_fifo_info_t (4 ints) + * policy_rr_info_t (5 ints) */ +type policy_base_t = array[*:5] of integer_t; +type policy_info_t = array[*:2] of integer_t; +type policy_limit_t = array[*:1] of integer_t; + +type ledger_t = mach_port_t +#if KERNEL_SERVER + intran: ledger_t convert_port_to_ledger(mach_port_t) + outtran: mach_port_t convert_ledger_to_port(ledger_t) +#endif /* KERNEL_SERVER */ + ; + +type ledger_array_t = ^array[] of ledger_t; +type ledger_item_t = integer_t; + +type security_token_t = struct[2] of uint32_t; +type audit_token_t = struct[8] of uint32_t; + +type msg_labels_t = mach_port_t; + + /* memory_object_info_t: variable-size inline array: + * memory_object_attr_info_t (5 ints) + * XXX actually it's 6 ints temporarily (object_ready!) + * memory_object_behave_info_t (4 ints) + * memory_object_perf_info_t (2 ints) + * old_memory_object_attr_info_t (3 ints) + * memory_object_norma_info_t (5 ints) + * If other flavors are added, this definition may + * need to be changed. (see mach/memory_object.h) */ +type memory_object_flavor_t = int; +type memory_object_info_t = array[*:6] of int; + + /* vm_region_info_t: variable-size inline array that can hold: + * vm_region_basic_info_t (8 ints) + * If other flavors are added, this definition may + * need to be changed. (see mach/vm_region.h) */ +type vm_region_flavor_t = int; +type vm_region_info_t = array[*:10] of int; +type vm_region_recurse_info_t = array[*:19] of int; + +type vm_page_info_flavor_t = int; +type vm_page_info_t = array[*:32] of int; + +type mach_vm_read_entry_t = array[512] of mach_vm_offset_t; +type vm_read_entry_t = array[512] of vm_offset_t; +#if VM32_SUPPORT +type vm32_read_entry_t = array[512] of vm32_offset_t; +#endif + +type exception_mask_t = int; +type exception_behavior_t = int; + +type exception_handler_t = mach_port_t; + +type exception_handler_array_t = + array[*:32] of exception_handler_t; + +type exception_behavior_array_t = + array[*:32] of exception_behavior_t; + +type exception_flavor_array_t = + array[*:32] of thread_state_flavor_t; + +type exception_mask_array_t = + array[*:32] of exception_mask_t; + +type semaphore_t = mach_port_t +#if KERNEL_SERVER + intran: semaphore_t convert_port_to_semaphore(mach_port_t) + outtran: mach_port_t convert_semaphore_to_port(semaphore_t) + destructor: semaphore_dereference(semaphore_t) +#endif /* KERNEL_SERVER */ + ; + +type semaphore_consume_ref_t = mach_port_move_send_t + cusertype: semaphore_t +#if KERNEL_SERVER + intran: semaphore_t convert_port_to_semaphore(mach_port_t) + outtran: mach_port_t convert_semaphore_to_port(semaphore_t) + destructor: semaphore_dereference(semaphore_t) +#endif /* KERNEL_SERVER */ + ; + +type lock_set_t = mach_port_t +#if KERNEL_SERVER + intran: lock_set_t convert_port_to_lock_set(mach_port_t) + outtran: mach_port_t convert_lock_set_to_port(lock_set_t) + destructor: lock_set_dereference(lock_set_t) +#endif /* KERNEL_SERVER */ + ; + +/* kernel module loader */ +type kmod_t = int; +type kmod_control_flavor_t = int; + +type kmod_args_t = ^array[] of MACH_MSG_TYPE_BYTE + ctype: kmod_args_t; + +type io_master_t = mach_port_t; +type UNDServerRef = mach_port_t; + +#if KERNEL_SERVER + +simport <kern/ipc_mig.h>; /* pick up kernel-specific MIG things */ + +#endif /* KERNEL_SERVER */ + +import <mach/mig.h>; +import <mach/mach_types.h>; + +#endif /* _MACH_MACH_TYPES_DEFS_ */ + +/* vim: set ft=c : */ Index: branches/azimutz/Cleancut/i386/include/mach/host_reboot.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/host_reboot.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/host_reboot.h (revision 885) @@ -0,0 +1,39 @@ +/* + * 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@ + */ + +#ifndef _MACH_HOST_REBOOT_ +#define _MACH_HOST_REBOOT_ + +#define HOST_REBOOT_HALT 0x0008 +#define HOST_REBOOT_UPSDELAY 0x0100 +#define HOST_REBOOT_DEBUGGER 0x1000 + +#endif /* _MACH_HOST_REBOOT_ */ Index: branches/azimutz/Cleancut/i386/include/mach/mach_param.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/mach_param.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/mach_param.h (revision 885) @@ -0,0 +1,73 @@ +/* + * Copyright (c) 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@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989,1988,1987 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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + */ +/* + * File: mach/mach_param.h + * Author: Avadis Tevanian, Jr., Michael Wayne Young + * Date: 1986 + * + * Mach system sizing parameters + */ + +#ifndef _MACH_MACH_PARAM_H_ +#define _MACH_MACH_PARAM_H_ + +/* Number of "registered" ports */ + +#define TASK_PORT_REGISTER_MAX 3 + +#endif /* _MACH_MACH_PARAM_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/time_value.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/time_value.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/time_value.h (revision 885) @@ -0,0 +1,96 @@ +/* + * Copyright (c) 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@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989,1988,1987 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 Software.Distribution@CS.CMU.EDU + * 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. + */ + +#ifndef _MACH_TIME_VALUE_H_ +#define _MACH_TIME_VALUE_H_ + +#include <mach/machine/vm_types.h> + +/* + * Time value returned by kernel. + */ + +struct time_value { + integer_t seconds; + integer_t microseconds; +}; + +typedef struct time_value time_value_t; + +/* + * Macros to manipulate time values. Assume that time values + * are normalized (microseconds <= 999999). + */ +#define TIME_MICROS_MAX (1000000) + +#define time_value_add_usec(val, micros) { \ + if (((val)->microseconds += (micros)) \ + >= TIME_MICROS_MAX) { \ + (val)->microseconds -= TIME_MICROS_MAX; \ + (val)->seconds++; \ + } \ +} + +#define time_value_add(result, addend) { \ + (result)->microseconds += (addend)->microseconds; \ + (result)->seconds += (addend)->seconds; \ + if ((result)->microseconds >= TIME_MICROS_MAX) { \ + (result)->microseconds -= TIME_MICROS_MAX; \ + (result)->seconds++; \ + } \ +} + +#endif /* _MACH_TIME_VALUE_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/processor_set.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/processor_set.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/processor_set.h (revision 885) @@ -0,0 +1,516 @@ +#ifndef _processor_set_user_ +#define _processor_set_user_ + +/* Module processor_set */ + +#include <string.h> +#include <mach/ndr.h> +#include <mach/boolean.h> +#include <mach/kern_return.h> +#include <mach/notify.h> +#include <mach/mach_types.h> +#include <mach/message.h> +#include <mach/mig_errors.h> +#include <mach/port.h> + +#ifdef AUTOTEST +#ifndef FUNCTION_PTR_T +#define FUNCTION_PTR_T +typedef void (*function_ptr_t)(mach_port_t, char *, mach_msg_type_number_t); +typedef struct { + char *name; + function_ptr_t function; +} function_table_entry; +typedef function_table_entry *function_table_t; +#endif /* FUNCTION_PTR_T */ +#endif /* AUTOTEST */ + +#ifndef processor_set_MSG_COUNT +#define processor_set_MSG_COUNT 10 +#endif /* processor_set_MSG_COUNT */ + +#include <mach/std_types.h> +#include <mach/mig.h> +#include <mach/mach_types.h> + +#ifdef __BeforeMigUserHeader +__BeforeMigUserHeader +#endif /* __BeforeMigUserHeader */ + +#include <sys/cdefs.h> +__BEGIN_DECLS + + +/* Routine processor_set_statistics */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t processor_set_statistics +( + processor_set_name_t pset, + processor_set_flavor_t flavor, + processor_set_info_t info_out, + mach_msg_type_number_t *info_outCnt +); + +/* Routine processor_set_destroy */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t processor_set_destroy +( + processor_set_t set +); + +/* Routine processor_set_max_priority */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t processor_set_max_priority +( + processor_set_t processor_set, + int max_priority, + boolean_t change_threads +); + +/* Routine processor_set_policy_enable */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t processor_set_policy_enable +( + processor_set_t processor_set, + int policy +); + +/* Routine processor_set_policy_disable */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t processor_set_policy_disable +( + processor_set_t processor_set, + int policy, + boolean_t change_threads +); + +/* Routine processor_set_tasks */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t processor_set_tasks +( + processor_set_t processor_set, + task_array_t *task_list, + mach_msg_type_number_t *task_listCnt +); + +/* Routine processor_set_threads */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t processor_set_threads +( + processor_set_t processor_set, + thread_act_array_t *thread_list, + mach_msg_type_number_t *thread_listCnt +); + +/* Routine processor_set_policy_control */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t processor_set_policy_control +( + processor_set_t pset, + processor_set_flavor_t flavor, + processor_set_info_t policy_info, + mach_msg_type_number_t policy_infoCnt, + boolean_t change +); + +/* Routine processor_set_stack_usage */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t processor_set_stack_usage +( + processor_set_t pset, + unsigned *ltotal, + vm_size_t *space, + vm_size_t *resident, + vm_size_t *maxusage, + vm_offset_t *maxstack +); + +/* Routine processor_set_info */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t processor_set_info +( + processor_set_name_t set_name, + int flavor, + host_t *host, + processor_set_info_t info_out, + mach_msg_type_number_t *info_outCnt +); + +__END_DECLS + +/********************** Caution **************************/ +/* The following data types should be used to calculate */ +/* maximum message sizes only. The actual message may be */ +/* smaller, and the position of the arguments within the */ +/* message layout may vary from what is presented here. */ +/* For example, if any of the arguments are variable- */ +/* sized, and less than the maximum is sent, the data */ +/* will be packed tight in the actual message to reduce */ +/* the presence of holes. */ +/********************** Caution **************************/ + +/* typedefs for all requests */ + +#ifndef __Request__processor_set_subsystem__defined +#define __Request__processor_set_subsystem__defined + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + processor_set_flavor_t flavor; + mach_msg_type_number_t info_outCnt; + } __Request__processor_set_statistics_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__processor_set_destroy_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + int max_priority; + boolean_t change_threads; + } __Request__processor_set_max_priority_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + int policy; + } __Request__processor_set_policy_enable_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + int policy; + boolean_t change_threads; + } __Request__processor_set_policy_disable_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__processor_set_tasks_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__processor_set_threads_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + processor_set_flavor_t flavor; + mach_msg_type_number_t policy_infoCnt; + integer_t policy_info[5]; + boolean_t change; + } __Request__processor_set_policy_control_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__processor_set_stack_usage_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + int flavor; + mach_msg_type_number_t info_outCnt; + } __Request__processor_set_info_t; +#ifdef __MigPackStructs +#pragma pack() +#endif +#endif /* !__Request__processor_set_subsystem__defined */ + +/* union of all requests */ + +#ifndef __RequestUnion__processor_set_subsystem__defined +#define __RequestUnion__processor_set_subsystem__defined +union __RequestUnion__processor_set_subsystem { + __Request__processor_set_statistics_t Request_processor_set_statistics; + __Request__processor_set_destroy_t Request_processor_set_destroy; + __Request__processor_set_max_priority_t Request_processor_set_max_priority; + __Request__processor_set_policy_enable_t Request_processor_set_policy_enable; + __Request__processor_set_policy_disable_t Request_processor_set_policy_disable; + __Request__processor_set_tasks_t Request_processor_set_tasks; + __Request__processor_set_threads_t Request_processor_set_threads; + __Request__processor_set_policy_control_t Request_processor_set_policy_control; + __Request__processor_set_stack_usage_t Request_processor_set_stack_usage; + __Request__processor_set_info_t Request_processor_set_info; +}; +#endif /* !__RequestUnion__processor_set_subsystem__defined */ +/* typedefs for all replies */ + +#ifndef __Reply__processor_set_subsystem__defined +#define __Reply__processor_set_subsystem__defined + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_msg_type_number_t info_outCnt; + integer_t info_out[5]; + } __Reply__processor_set_statistics_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__processor_set_destroy_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__processor_set_max_priority_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__processor_set_policy_enable_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__processor_set_policy_disable_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_ports_descriptor_t task_list; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t task_listCnt; + } __Reply__processor_set_tasks_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_ports_descriptor_t thread_list; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t thread_listCnt; + } __Reply__processor_set_threads_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__processor_set_policy_control_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + unsigned ltotal; + vm_size_t space; + vm_size_t resident; + vm_size_t maxusage; + vm_offset_t maxstack; + } __Reply__processor_set_stack_usage_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t host; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t info_outCnt; + integer_t info_out[5]; + } __Reply__processor_set_info_t; +#ifdef __MigPackStructs +#pragma pack() +#endif +#endif /* !__Reply__processor_set_subsystem__defined */ + +/* union of all replies */ + +#ifndef __ReplyUnion__processor_set_subsystem__defined +#define __ReplyUnion__processor_set_subsystem__defined +union __ReplyUnion__processor_set_subsystem { + __Reply__processor_set_statistics_t Reply_processor_set_statistics; + __Reply__processor_set_destroy_t Reply_processor_set_destroy; + __Reply__processor_set_max_priority_t Reply_processor_set_max_priority; + __Reply__processor_set_policy_enable_t Reply_processor_set_policy_enable; + __Reply__processor_set_policy_disable_t Reply_processor_set_policy_disable; + __Reply__processor_set_tasks_t Reply_processor_set_tasks; + __Reply__processor_set_threads_t Reply_processor_set_threads; + __Reply__processor_set_policy_control_t Reply_processor_set_policy_control; + __Reply__processor_set_stack_usage_t Reply_processor_set_stack_usage; + __Reply__processor_set_info_t Reply_processor_set_info; +}; +#endif /* !__RequestUnion__processor_set_subsystem__defined */ + +#ifndef subsystem_to_name_map_processor_set +#define subsystem_to_name_map_processor_set \ + { "processor_set_statistics", 4000 },\ + { "processor_set_destroy", 4001 },\ + { "processor_set_max_priority", 4002 },\ + { "processor_set_policy_enable", 4003 },\ + { "processor_set_policy_disable", 4004 },\ + { "processor_set_tasks", 4005 },\ + { "processor_set_threads", 4006 },\ + { "processor_set_policy_control", 4007 },\ + { "processor_set_stack_usage", 4008 },\ + { "processor_set_info", 4009 } +#endif + +#ifdef __AfterMigUserHeader +__AfterMigUserHeader +#endif /* __AfterMigUserHeader */ + +#endif /* _processor_set_user_ */ Index: branches/azimutz/Cleancut/i386/include/mach/processor_info.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/processor_info.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/processor_info.h (revision 885) @@ -0,0 +1,153 @@ +/* + * Copyright (c) 2000-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@ + */ +/* + * @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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + */ + +/* + * File: mach/processor_info.h + * Author: David L. Black + * Date: 1988 + * + * Data structure definitions for processor_info, processor_set_info + */ + +#ifndef _MACH_PROCESSOR_INFO_H_ +#define _MACH_PROCESSOR_INFO_H_ + +#include <mach/message.h> +#include <mach/machine.h> +#include <mach/machine/processor_info.h> + +/* + * Generic information structure to allow for expansion. + */ +typedef integer_t *processor_info_t; /* varying array of int. */ +typedef integer_t *processor_info_array_t; /* varying array of int */ + +#define PROCESSOR_INFO_MAX (1024) /* max array size */ +typedef integer_t processor_info_data_t[PROCESSOR_INFO_MAX]; + + +typedef integer_t *processor_set_info_t; /* varying array of int. */ + +#define PROCESSOR_SET_INFO_MAX (1024) /* max array size */ +typedef integer_t processor_set_info_data_t[PROCESSOR_SET_INFO_MAX]; + +/* + * Currently defined information. + */ +typedef int processor_flavor_t; +#define PROCESSOR_BASIC_INFO 1 /* basic information */ +#define PROCESSOR_CPU_LOAD_INFO 2 /* cpu load information */ +#define PROCESSOR_PM_REGS_INFO 0x10000001 /* performance monitor register info */ +#define PROCESSOR_TEMPERATURE 0x10000002 /* Processor core temperature */ + +struct processor_basic_info { + cpu_type_t cpu_type; /* type of cpu */ + cpu_subtype_t cpu_subtype; /* subtype of cpu */ + boolean_t running; /* is processor running */ + int slot_num; /* slot number */ + boolean_t is_master; /* is this the master processor */ +}; + +typedef struct processor_basic_info processor_basic_info_data_t; +typedef struct processor_basic_info *processor_basic_info_t; +#define PROCESSOR_BASIC_INFO_COUNT ((mach_msg_type_number_t) \ + (sizeof(processor_basic_info_data_t)/sizeof(natural_t))) + +struct processor_cpu_load_info { /* number of ticks while running... */ + unsigned int cpu_ticks[CPU_STATE_MAX]; /* ... in the given mode */ +}; + +typedef struct processor_cpu_load_info processor_cpu_load_info_data_t; +typedef struct processor_cpu_load_info *processor_cpu_load_info_t; +#define PROCESSOR_CPU_LOAD_INFO_COUNT ((mach_msg_type_number_t) \ + (sizeof(processor_cpu_load_info_data_t)/sizeof(natural_t))) + +/* + * Scaling factor for load_average, mach_factor. + */ +#define LOAD_SCALE 1000 + +typedef int processor_set_flavor_t; +#define PROCESSOR_SET_BASIC_INFO 5 /* basic information */ + +struct processor_set_basic_info { + int processor_count; /* How many processors */ + int default_policy; /* When others not enabled */ +}; + +typedef struct processor_set_basic_info processor_set_basic_info_data_t; +typedef struct processor_set_basic_info *processor_set_basic_info_t; +#define PROCESSOR_SET_BASIC_INFO_COUNT ((mach_msg_type_number_t) \ + (sizeof(processor_set_basic_info_data_t)/sizeof(natural_t))) + +#define PROCESSOR_SET_LOAD_INFO 4 /* scheduling statistics */ + +struct processor_set_load_info { + int task_count; /* How many tasks */ + int thread_count; /* How many threads */ + integer_t load_average; /* Scaled */ + integer_t mach_factor; /* Scaled */ +}; + +typedef struct processor_set_load_info processor_set_load_info_data_t; +typedef struct processor_set_load_info *processor_set_load_info_t; +#define PROCESSOR_SET_LOAD_INFO_COUNT ((mach_msg_type_number_t) \ + (sizeof(processor_set_load_info_data_t)/sizeof(natural_t))) + + +#endif /* _MACH_PROCESSOR_INFO_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/clock_priv.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/clock_priv.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/clock_priv.h (revision 885) @@ -0,0 +1,175 @@ +#ifndef _clock_priv_user_ +#define _clock_priv_user_ + +/* Module clock_priv */ + +#include <string.h> +#include <mach/ndr.h> +#include <mach/boolean.h> +#include <mach/kern_return.h> +#include <mach/notify.h> +#include <mach/mach_types.h> +#include <mach/message.h> +#include <mach/mig_errors.h> +#include <mach/port.h> + +#ifdef AUTOTEST +#ifndef FUNCTION_PTR_T +#define FUNCTION_PTR_T +typedef void (*function_ptr_t)(mach_port_t, char *, mach_msg_type_number_t); +typedef struct { + char *name; + function_ptr_t function; +} function_table_entry; +typedef function_table_entry *function_table_t; +#endif /* FUNCTION_PTR_T */ +#endif /* AUTOTEST */ + +#ifndef clock_priv_MSG_COUNT +#define clock_priv_MSG_COUNT 2 +#endif /* clock_priv_MSG_COUNT */ + +#include <mach/std_types.h> +#include <mach/mig.h> +#include <mach/mach_types.h> +#include <mach/mach_types.h> + +#ifdef __BeforeMigUserHeader +__BeforeMigUserHeader +#endif /* __BeforeMigUserHeader */ + +#include <sys/cdefs.h> +__BEGIN_DECLS + + +/* Routine clock_set_time */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t clock_set_time +( + clock_ctrl_t clock_ctrl, + mach_timespec_t new_time +); + +/* Routine clock_set_attributes */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t clock_set_attributes +( + clock_ctrl_t clock_ctrl, + clock_flavor_t flavor, + clock_attr_t clock_attr, + mach_msg_type_number_t clock_attrCnt +); + +__END_DECLS + +/********************** Caution **************************/ +/* The following data types should be used to calculate */ +/* maximum message sizes only. The actual message may be */ +/* smaller, and the position of the arguments within the */ +/* message layout may vary from what is presented here. */ +/* For example, if any of the arguments are variable- */ +/* sized, and less than the maximum is sent, the data */ +/* will be packed tight in the actual message to reduce */ +/* the presence of holes. */ +/********************** Caution **************************/ + +/* typedefs for all requests */ + +#ifndef __Request__clock_priv_subsystem__defined +#define __Request__clock_priv_subsystem__defined + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_timespec_t new_time; + } __Request__clock_set_time_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + clock_flavor_t flavor; + mach_msg_type_number_t clock_attrCnt; + int clock_attr[1]; + } __Request__clock_set_attributes_t; +#ifdef __MigPackStructs +#pragma pack() +#endif +#endif /* !__Request__clock_priv_subsystem__defined */ + +/* union of all requests */ + +#ifndef __RequestUnion__clock_priv_subsystem__defined +#define __RequestUnion__clock_priv_subsystem__defined +union __RequestUnion__clock_priv_subsystem { + __Request__clock_set_time_t Request_clock_set_time; + __Request__clock_set_attributes_t Request_clock_set_attributes; +}; +#endif /* !__RequestUnion__clock_priv_subsystem__defined */ +/* typedefs for all replies */ + +#ifndef __Reply__clock_priv_subsystem__defined +#define __Reply__clock_priv_subsystem__defined + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__clock_set_time_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__clock_set_attributes_t; +#ifdef __MigPackStructs +#pragma pack() +#endif +#endif /* !__Reply__clock_priv_subsystem__defined */ + +/* union of all replies */ + +#ifndef __ReplyUnion__clock_priv_subsystem__defined +#define __ReplyUnion__clock_priv_subsystem__defined +union __ReplyUnion__clock_priv_subsystem { + __Reply__clock_set_time_t Reply_clock_set_time; + __Reply__clock_set_attributes_t Reply_clock_set_attributes; +}; +#endif /* !__RequestUnion__clock_priv_subsystem__defined */ + +#ifndef subsystem_to_name_map_clock_priv +#define subsystem_to_name_map_clock_priv \ + { "clock_set_time", 1200 },\ + { "clock_set_attributes", 1201 } +#endif + +#ifdef __AfterMigUserHeader +__AfterMigUserHeader +#endif /* __AfterMigUserHeader */ + +#endif /* _clock_priv_user_ */ Index: branches/azimutz/Cleancut/i386/include/mach/vm_statistics.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/vm_statistics.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/vm_statistics.h (revision 885) @@ -0,0 +1,335 @@ +/* + * Copyright (c) 2000-2009 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@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989,1988,1987 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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + */ +/* + * File: mach/vm_statistics.h + * Author: Avadis Tevanian, Jr., Michael Wayne Young, David Golub + * + * Virtual memory statistics structure. + * + */ + +#ifndef _MACH_VM_STATISTICS_H_ +#define _MACH_VM_STATISTICS_H_ + +#include <mach/machine/vm_types.h> + + +/* + * vm_statistics + * + * History: + * rev0 - original structure. + * rev1 - added purgable info (purgable_count and purges). + * rev2 - added speculative_count. + * + * Note: you cannot add any new fields to this structure. Add them below in + * vm_statistics64. + */ + +struct vm_statistics { + natural_t free_count; /* # of pages free */ + natural_t active_count; /* # of pages active */ + natural_t inactive_count; /* # of pages inactive */ + natural_t wire_count; /* # of pages wired down */ + natural_t zero_fill_count; /* # of zero fill pages */ + natural_t reactivations; /* # of pages reactivated */ + natural_t pageins; /* # of pageins */ + natural_t pageouts; /* # of pageouts */ + natural_t faults; /* # of faults */ + natural_t cow_faults; /* # of copy-on-writes */ + natural_t lookups; /* object cache lookups */ + natural_t hits; /* object cache hits */ + + /* added for rev1 */ + natural_t purgeable_count; /* # of pages purgeable */ + natural_t purges; /* # of pages purged */ + + /* added for rev2 */ + /* + * NB: speculative pages are already accounted for in "free_count", + * so "speculative_count" is the number of "free" pages that are + * used to hold data that was read speculatively from disk but + * haven't actually been used by anyone so far. + */ + natural_t speculative_count; /* # of pages speculative */ +}; + +/* Used by all architectures */ +typedef struct vm_statistics *vm_statistics_t; +typedef struct vm_statistics vm_statistics_data_t; + +#if defined(__ppc__) /* On ppc, vm statistics are still 32-bit */ + +typedef struct vm_statistics *vm_statistics64_t; +typedef struct vm_statistics vm_statistics64_data_t; + +#define VM_STATISTICS_TRUNCATE_TO_32_BIT(value) value + +#else /* !(defined(__ppc__)) */ + +/* + * vm_statistics64 + * + * History: + * rev0 - original structure. + * rev1 - added purgable info (purgable_count and purges). + * rev2 - added speculative_count. + * ---- + * rev3 - changed name to vm_statistics64. + * changed some fields in structure to 64-bit on + * arm, i386 and x86_64 architectures. + * + */ + +struct vm_statistics64 { + natural_t free_count; /* # of pages free */ + natural_t active_count; /* # of pages active */ + natural_t inactive_count; /* # of pages inactive */ + natural_t wire_count; /* # of pages wired down */ + uint64_t zero_fill_count; /* # of zero fill pages */ + uint64_t reactivations; /* # of pages reactivated */ + uint64_t pageins; /* # of pageins */ + uint64_t pageouts; /* # of pageouts */ + uint64_t faults; /* # of faults */ + uint64_t cow_faults; /* # of copy-on-writes */ + uint64_t lookups; /* object cache lookups */ + uint64_t hits; /* object cache hits */ + + /* added for rev1 */ + uint64_t purges; /* # of pages purged */ + natural_t purgeable_count; /* # of pages purgeable */ + + /* added for rev2 */ + /* + * NB: speculative pages are already accounted for in "free_count", + * so "speculative_count" is the number of "free" pages that are + * used to hold data that was read speculatively from disk but + * haven't actually been used by anyone so far. + */ + natural_t speculative_count; /* # of pages speculative */ + +} +#ifdef __arm__ +__attribute__((aligned(8))) +#endif +; + +typedef struct vm_statistics64 *vm_statistics64_t; +typedef struct vm_statistics64 vm_statistics64_data_t; + +/* + * VM_STATISTICS_TRUNCATE_TO_32_BIT + * + * This is used by host_statistics() to truncate and peg the 64-bit in-kernel values from + * vm_statistics64 to the 32-bit values of the older structure above (vm_statistics). + */ +#define VM_STATISTICS_TRUNCATE_TO_32_BIT(value) ((uint32_t)(((value) > UINT32_MAX ) ? UINT32_MAX : (value))) + +#endif /* !(defined(__ppc__)) */ + + +/* included for the vm_map_page_query call */ + +#define VM_PAGE_QUERY_PAGE_PRESENT 0x1 +#define VM_PAGE_QUERY_PAGE_FICTITIOUS 0x2 +#define VM_PAGE_QUERY_PAGE_REF 0x4 +#define VM_PAGE_QUERY_PAGE_DIRTY 0x8 +#define VM_PAGE_QUERY_PAGE_PAGED_OUT 0x10 +#define VM_PAGE_QUERY_PAGE_COPIED 0x20 +#define VM_PAGE_QUERY_PAGE_SPECULATIVE 0x40 +#define VM_PAGE_QUERY_PAGE_EXTERNAL 0x80 +#define VM_PAGE_QUERY_PAGE_CS_VALIDATED 0x100 +#define VM_PAGE_QUERY_PAGE_CS_TAINTED 0x200 + + +/* + * VM allocation flags: + * + * VM_FLAGS_FIXED + * (really the absence of VM_FLAGS_ANYWHERE) + * Allocate new VM region at the specified virtual address, if possible. + * + * VM_FLAGS_ANYWHERE + * Allocate new VM region anywhere it would fit in the address space. + * + * VM_FLAGS_PURGABLE + * Create a purgable VM object for that new VM region. + * + * VM_FLAGS_NO_PMAP_CHECK + * (for DEBUG kernel config only, ignored for other configs) + * Do not check that there is no stale pmap mapping for the new VM region. + * This is useful for kernel memory allocations at bootstrap when building + * the initial kernel address space while some memory is already in use. + * + * VM_FLAGS_OVERWRITE + * The new VM region can replace existing VM regions if necessary + * (to be used in combination with VM_FLAGS_FIXED). + * + * VM_FLAGS_NO_CACHE + * Pages brought in to this VM region are placed on the speculative + * queue instead of the active queue. In other words, they are not + * cached so that they will be stolen first if memory runs low. + */ +#define VM_FLAGS_FIXED 0x0000 +#define VM_FLAGS_ANYWHERE 0x0001 +#define VM_FLAGS_PURGABLE 0x0002 +#define VM_FLAGS_NO_CACHE 0x0010 + +/* + * VM_FLAGS_SUPERPAGE_MASK + * 3 bits that specify whether large pages should be used instead of + * base pages (!=0), as well as the requested page size. + */ +#define VM_FLAGS_SUPERPAGE_MASK 0x70000 /* bits 0x10000, 0x20000, 0x40000 */ +#define VM_FLAGS_SUPERPAGE_SHIFT 16 + +#define SUPERPAGE_NONE 0 /* no superpages, if all bits are 0 */ +#define VM_FLAGS_SUPERPAGE_NONE (SUPERPAGE_NONE<<VM_FLAGS_SUPERPAGE_SHIFT) +#if defined(__x86_64__) || !defined(KERNEL) +#define SUPERPAGE_SIZE_2MB 1 +#define VM_FLAGS_SUPERPAGE_SIZE_2MB (SUPERPAGE_SIZE_2MB<<VM_FLAGS_SUPERPAGE_SHIFT) +#endif + +#define VM_FLAGS_ALIAS_MASK 0xFF000000 +#define VM_GET_FLAGS_ALIAS(flags, alias) \ + (alias) = ((flags) & VM_FLAGS_ALIAS_MASK) >> 24 +#define VM_SET_FLAGS_ALIAS(flags, alias) \ + (flags) = (((flags) & ~VM_FLAGS_ALIAS_MASK) | \ + (((alias) & ~VM_FLAGS_ALIAS_MASK) << 24)) + +/* These are the flags that we accept from user-space */ +#define VM_FLAGS_USER_ALLOCATE (VM_FLAGS_FIXED | \ + VM_FLAGS_ANYWHERE | \ + VM_FLAGS_PURGABLE | \ + VM_FLAGS_NO_CACHE | \ + VM_FLAGS_SUPERPAGE_MASK | \ + VM_FLAGS_ALIAS_MASK) +#define VM_FLAGS_USER_MAP VM_FLAGS_USER_ALLOCATE + +#define VM_MEMORY_MALLOC 1 +#define VM_MEMORY_MALLOC_SMALL 2 +#define VM_MEMORY_MALLOC_LARGE 3 +#define VM_MEMORY_MALLOC_HUGE 4 +#define VM_MEMORY_SBRK 5// uninteresting -- no one should call +#define VM_MEMORY_REALLOC 6 +#define VM_MEMORY_MALLOC_TINY 7 +#define VM_MEMORY_MALLOC_LARGE_REUSABLE 8 +#define VM_MEMORY_MALLOC_LARGE_REUSED 9 + +#define VM_MEMORY_ANALYSIS_TOOL 10 + +#define VM_MEMORY_MACH_MSG 20 +#define VM_MEMORY_IOKIT 21 +#define VM_MEMORY_STACK 30 +#define VM_MEMORY_GUARD 31 +#define VM_MEMORY_SHARED_PMAP 32 +/* memory containing a dylib */ +#define VM_MEMORY_DYLIB 33 +#define VM_MEMORY_OBJC_DISPATCHERS 34 + +// Placeholders for now -- as we analyze the libraries and find how they +// use memory, we can make these labels more specific. +#define VM_MEMORY_APPKIT 40 +#define VM_MEMORY_FOUNDATION 41 +#define VM_MEMORY_COREGRAPHICS 42 +#define VM_MEMORY_CARBON 43 +#define VM_MEMORY_JAVA 44 +#define VM_MEMORY_ATS 50 +#define VM_MEMORY_LAYERKIT 51 +#define VM_MEMORY_CGIMAGE 52 +#define VM_MEMORY_TCMALLOC 53 + +/* private raster data (i.e. layers, some images, QGL allocator) */ +#define VM_MEMORY_COREGRAPHICS_DATA 54 + +/* shared image and font caches */ +#define VM_MEMORY_COREGRAPHICS_SHARED 55 + +/* Memory used for virtual framebuffers, shadowing buffers, etc... */ +#define VM_MEMORY_COREGRAPHICS_FRAMEBUFFERS 56 + +/* Window backing stores, custom shadow data, and compressed backing stores */ +#define VM_MEMORY_COREGRAPHICS_BACKINGSTORES 57 + +/* catch-all for other uses, such as the read-only shared data page */ +#define VM_MEMORY_COREGRAPHICS_MISC VM_MEMORY_COREGRAPHICS + +/* memory allocated by the dynamic loader for itself */ +#define VM_MEMORY_DYLD 60 +/* malloc'd memory created by dyld */ +#define VM_MEMORY_DYLD_MALLOC 61 + +/* Used for sqlite page cache */ +#define VM_MEMORY_SQLITE 62 + +/* JavaScriptCore heaps */ +#define VM_MEMORY_JAVASCRIPT_CORE 63 +/* memory allocated for the JIT */ +#define VM_MEMORY_JAVASCRIPT_JIT_EXECUTABLE_ALLOCATOR 64 +#define VM_MEMORY_JAVASCRIPT_JIT_REGISTER_FILE 65 + +/* memory allocated for GLSL */ +#define VM_MEMORY_GLSL 66 + +/* Reserve 240-255 for application */ +#define VM_MEMORY_APPLICATION_SPECIFIC_1 240 +#define VM_MEMORY_APPLICATION_SPECIFIC_16 255 + +#define VM_MAKE_TAG(tag) ((tag) << 24) + +#endif /* _MACH_VM_STATISTICS_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/ppc/processor_info.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/ppc/processor_info.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/ppc/processor_info.h (revision 885) @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2000-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@ + */ + +/* + * File: mach/ppc/processor_info.h + * + * Data structure definitions for ppc specific processor control + */ + +#ifndef _MACH_PPC_PROCESSOR_INFO_H_ +#define _MACH_PPC_PROCESSOR_INFO_H_ + +#include <mach/machine.h> +#include <mach/message.h> + + +#endif /* _MACH_PPC_PROCESSOR_INFO_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/ppc/exception.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/ppc/exception.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/ppc/exception.h (revision 885) @@ -0,0 +1,119 @@ +/* + * Copyright (c) 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@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * Copyright (c) 1990, 1991, 1992, The University of Utah and + * the Center for Software Science at the University of Utah (CSS). + * All rights reserved. + * + * Permission to use, copy, modify and distribute this software is hereby + * granted provided that (1) source code retains these copyright, permission, + * and disclaimer notices, and (2) redistributions including binaries + * reproduce the notices in supporting documentation, and (3) all advertising + * materials mentioning features or use of this software display the following + * acknowledgement: ``This product includes software developed by the Center + * for Software Science at the University of Utah.'' + * + * THE UNIVERSITY OF UTAH AND CSS ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS + * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSS DISCLAIM ANY LIABILITY OF + * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * CSS requests users of this software to return to css-dist@cs.utah.edu any + * improvements that they make and grant CSS redistribution rights. + * + * Utah $Hdr: $ + */ + +#ifndef _MACH_PPC_EXCEPTION_H_ +#define _MACH_PPC_EXCEPTION_H_ + +#define EXC_TYPES_COUNT 11 /* incl. illegal exception 0 */ + +#define EXCEPTION_CODE_MAX 2 /* elements in vector (code+subcode) */ +/* + * EXC_BAD_INSTRUCTION + */ + +#define EXC_PPC_INVALID_SYSCALL 1 /* invalid syscall number */ +#define EXC_PPC_UNIPL_INST 2 /* unimplemented instruction */ +#define EXC_PPC_PRIVINST 3 /* priviledged instruction */ +#define EXC_PPC_PRIVREG 4 /* priviledged register */ +#define EXC_PPC_TRACE 5 /* trace/single-step */ +#define EXC_PPC_PERFMON 6 /* performance monitor */ + +/* + * EXC_BAD_ACCESS + * Note: do not conflict with kern_return_t values returned by vm_fault + */ + +#define EXC_PPC_VM_PROT_READ 0x101 /* error reading syscall args */ +#define EXC_PPC_BADSPACE 0x102 /* bad space referenced */ +#define EXC_PPC_UNALIGNED 0x103 /* unaligned data reference */ + +/* + * EXC_ARITHMETIC + */ + +#define EXC_PPC_OVERFLOW 1 /* integer overflow */ +#define EXC_PPC_ZERO_DIVIDE 2 /* integer divide by zero */ +#define EXC_PPC_FLT_INEXACT 3 /* IEEE inexact exception */ +#define EXC_PPC_FLT_ZERO_DIVIDE 4 /* IEEE zero divide */ +#define EXC_PPC_FLT_UNDERFLOW 5 /* IEEE floating underflow */ +#define EXC_PPC_FLT_OVERFLOW 6 /* IEEE floating overflow */ +#define EXC_PPC_FLT_NOT_A_NUMBER 7 /* IEEE not a number */ + +/* + * EXC_PPC_NOEMULATION should go away when we add software emulation + * for floating point. Right now we don't support this. + */ + +#define EXC_PPC_NOEMULATION 8 /* no floating point emulation */ +#define EXC_PPC_ALTIVECASSIST 9 /* Altivec Denorm Assist */ + +/* + * EXC_SOFTWARE + * Note: 0x10000-0x10003 in use for unix signal + */ +#define EXC_PPC_TRAP 1 /* Program trap */ +#define EXC_PPC_MIGRATE 0x10100 /* Time to bolt */ + + +/* + * EXC_BREAKPOINT + */ + +#define EXC_PPC_BREAKPOINT EXC_PPC_TRAP /* breakpoint trap */ + +/* + * machine dependent exception masks + */ +#define EXC_MASK_MACHINE 0 + +#endif /* _MACH_PPC_EXCEPTION_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/ppc/kern_return.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/ppc/kern_return.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/ppc/kern_return.h (revision 885) @@ -0,0 +1,74 @@ +/* + * Copyright (c) 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@ + */ +/* + * @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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + */ + +/* + * File: kern_return.h + * Author: Avadis Tevanian, Jr., Michael Wayne Young + * Date: 1985 + * + * Machine-dependent kernel return definitions. + */ + +#ifndef _MACH_PPC_KERN_RETURN_H_ +#define _MACH_PPC_KERN_RETURN_H_ + +#ifndef ASSEMBLER +typedef int kern_return_t; +#endif /* ASSEMBLER */ + +#endif /* _MACH_PPC_KERN_RETURN_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/ppc/thread_act.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/ppc/thread_act.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/ppc/thread_act.h (revision 885) @@ -0,0 +1,1155 @@ +#ifndef _thread_act_user_ +#define _thread_act_user_ + +/* Module thread_act */ + +#include <string.h> +#include <mach/ndr.h> +#include <mach/boolean.h> +#include <mach/kern_return.h> +#include <mach/notify.h> +#include <mach/mach_types.h> +#include <mach/message.h> +#include <mach/mig_errors.h> +#include <mach/port.h> + +#ifdef AUTOTEST +#ifndef FUNCTION_PTR_T +#define FUNCTION_PTR_T +typedef void (*function_ptr_t)(mach_port_t, char *, mach_msg_type_number_t); +typedef struct { + char *name; + function_ptr_t function; +} function_table_entry; +typedef function_table_entry *function_table_t; +#endif /* FUNCTION_PTR_T */ +#endif /* AUTOTEST */ + +#ifndef thread_act_MSG_COUNT +#define thread_act_MSG_COUNT 25 +#endif /* thread_act_MSG_COUNT */ + +#include <mach/std_types.h> +#include <mach/mig.h> +#include <mach/mig.h> +#include <mach/mach_types.h> + +#ifdef __BeforeMigUserHeader +__BeforeMigUserHeader +#endif /* __BeforeMigUserHeader */ + +#include <sys/cdefs.h> +__BEGIN_DECLS + + +/* Routine thread_terminate */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_terminate +( + thread_act_t target_act +); + +/* Routine act_get_state */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t act_get_state +( + thread_act_t target_act, + int flavor, + thread_state_t old_state, + mach_msg_type_number_t *old_stateCnt +); + +/* Routine act_set_state */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t act_set_state +( + thread_act_t target_act, + int flavor, + thread_state_t new_state, + mach_msg_type_number_t new_stateCnt +); + +/* Routine thread_get_state */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_get_state +( + thread_act_t target_act, + thread_state_flavor_t flavor, + thread_state_t old_state, + mach_msg_type_number_t *old_stateCnt +); + +/* Routine thread_set_state */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_set_state +( + thread_act_t target_act, + thread_state_flavor_t flavor, + thread_state_t new_state, + mach_msg_type_number_t new_stateCnt +); + +/* Routine thread_suspend */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_suspend +( + thread_act_t target_act +); + +/* Routine thread_resume */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_resume +( + thread_act_t target_act +); + +/* Routine thread_abort */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_abort +( + thread_act_t target_act +); + +/* Routine thread_abort_safely */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_abort_safely +( + thread_act_t target_act +); + +/* Routine thread_depress_abort */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_depress_abort +( + thread_act_t thread +); + +/* Routine thread_get_special_port */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_get_special_port +( + thread_act_t thr_act, + int which_port, + mach_port_t *special_port +); + +/* Routine thread_set_special_port */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_set_special_port +( + thread_act_t thr_act, + int which_port, + mach_port_t special_port +); + +/* Routine thread_info */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_info +( + thread_act_t target_act, + thread_flavor_t flavor, + thread_info_t thread_info_out, + mach_msg_type_number_t *thread_info_outCnt +); + +/* Routine thread_set_exception_ports */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_set_exception_ports +( + thread_act_t thread, + exception_mask_t exception_mask, + mach_port_t new_port, + exception_behavior_t behavior, + thread_state_flavor_t new_flavor +); + +/* Routine thread_get_exception_ports */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_get_exception_ports +( + thread_act_t thread, + exception_mask_t exception_mask, + exception_mask_array_t masks, + mach_msg_type_number_t *masksCnt, + exception_handler_array_t old_handlers, + exception_behavior_array_t old_behaviors, + exception_flavor_array_t old_flavors +); + +/* Routine thread_swap_exception_ports */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_swap_exception_ports +( + thread_act_t thread, + exception_mask_t exception_mask, + mach_port_t new_port, + exception_behavior_t behavior, + thread_state_flavor_t new_flavor, + exception_mask_array_t masks, + mach_msg_type_number_t *masksCnt, + exception_handler_array_t old_handlers, + exception_behavior_array_t old_behaviors, + exception_flavor_array_t old_flavors +); + +/* Routine thread_policy */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_policy +( + thread_act_t thr_act, + policy_t policy, + policy_base_t base, + mach_msg_type_number_t baseCnt, + boolean_t set_limit +); + +/* Routine thread_policy_set */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_policy_set +( + thread_act_t thread, + thread_policy_flavor_t flavor, + thread_policy_t policy_info, + mach_msg_type_number_t policy_infoCnt +); + +/* Routine thread_policy_get */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_policy_get +( + thread_act_t thread, + thread_policy_flavor_t flavor, + thread_policy_t policy_info, + mach_msg_type_number_t *policy_infoCnt, + boolean_t *get_default +); + +/* Routine thread_sample */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_sample +( + thread_act_t thread, + mach_port_t reply +); + +/* Routine etap_trace_thread */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t etap_trace_thread +( + thread_act_t target_act, + boolean_t trace_status +); + +/* Routine thread_assign */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_assign +( + thread_act_t thread, + processor_set_t new_set +); + +/* Routine thread_assign_default */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_assign_default +( + thread_act_t thread +); + +/* Routine thread_get_assignment */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_get_assignment +( + thread_act_t thread, + processor_set_name_t *assigned_set +); + +/* Routine thread_set_policy */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_set_policy +( + thread_act_t thr_act, + processor_set_t pset, + policy_t policy, + policy_base_t base, + mach_msg_type_number_t baseCnt, + policy_limit_t limit, + mach_msg_type_number_t limitCnt +); + +__END_DECLS + +/********************** Caution **************************/ +/* The following data types should be used to calculate */ +/* maximum message sizes only. The actual message may be */ +/* smaller, and the position of the arguments within the */ +/* message layout may vary from what is presented here. */ +/* For example, if any of the arguments are variable- */ +/* sized, and less than the maximum is sent, the data */ +/* will be packed tight in the actual message to reduce */ +/* the presence of holes. */ +/********************** Caution **************************/ + +/* typedefs for all requests */ + +#ifndef __Request__thread_act_subsystem__defined +#define __Request__thread_act_subsystem__defined + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__thread_terminate_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + int flavor; + mach_msg_type_number_t old_stateCnt; + } __Request__act_get_state_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + int flavor; + mach_msg_type_number_t new_stateCnt; + natural_t new_state[144]; + } __Request__act_set_state_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + thread_state_flavor_t flavor; + mach_msg_type_number_t old_stateCnt; + } __Request__thread_get_state_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + thread_state_flavor_t flavor; + mach_msg_type_number_t new_stateCnt; + natural_t new_state[144]; + } __Request__thread_set_state_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__thread_suspend_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__thread_resume_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__thread_abort_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__thread_abort_safely_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__thread_depress_abort_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + int which_port; + } __Request__thread_get_special_port_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t special_port; + /* end of the kernel processed data */ + NDR_record_t NDR; + int which_port; + } __Request__thread_set_special_port_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + thread_flavor_t flavor; + mach_msg_type_number_t thread_info_outCnt; + } __Request__thread_info_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t new_port; + /* end of the kernel processed data */ + NDR_record_t NDR; + exception_mask_t exception_mask; + exception_behavior_t behavior; + thread_state_flavor_t new_flavor; + } __Request__thread_set_exception_ports_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + exception_mask_t exception_mask; + } __Request__thread_get_exception_ports_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t new_port; + /* end of the kernel processed data */ + NDR_record_t NDR; + exception_mask_t exception_mask; + exception_behavior_t behavior; + thread_state_flavor_t new_flavor; + } __Request__thread_swap_exception_ports_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + policy_t policy; + mach_msg_type_number_t baseCnt; + integer_t base[5]; + boolean_t set_limit; + } __Request__thread_policy_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + thread_policy_flavor_t flavor; + mach_msg_type_number_t policy_infoCnt; + integer_t policy_info[16]; + } __Request__thread_policy_set_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + thread_policy_flavor_t flavor; + mach_msg_type_number_t policy_infoCnt; + boolean_t get_default; + } __Request__thread_policy_get_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t reply; + /* end of the kernel processed data */ + } __Request__thread_sample_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + boolean_t trace_status; + } __Request__etap_trace_thread_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t new_set; + /* end of the kernel processed data */ + } __Request__thread_assign_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__thread_assign_default_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__thread_get_assignment_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t pset; + /* end of the kernel processed data */ + NDR_record_t NDR; + policy_t policy; + mach_msg_type_number_t baseCnt; + integer_t base[5]; + mach_msg_type_number_t limitCnt; + integer_t limit[1]; + } __Request__thread_set_policy_t; +#ifdef __MigPackStructs +#pragma pack() +#endif +#endif /* !__Request__thread_act_subsystem__defined */ + +/* union of all requests */ + +#ifndef __RequestUnion__thread_act_subsystem__defined +#define __RequestUnion__thread_act_subsystem__defined +union __RequestUnion__thread_act_subsystem { + __Request__thread_terminate_t Request_thread_terminate; + __Request__act_get_state_t Request_act_get_state; + __Request__act_set_state_t Request_act_set_state; + __Request__thread_get_state_t Request_thread_get_state; + __Request__thread_set_state_t Request_thread_set_state; + __Request__thread_suspend_t Request_thread_suspend; + __Request__thread_resume_t Request_thread_resume; + __Request__thread_abort_t Request_thread_abort; + __Request__thread_abort_safely_t Request_thread_abort_safely; + __Request__thread_depress_abort_t Request_thread_depress_abort; + __Request__thread_get_special_port_t Request_thread_get_special_port; + __Request__thread_set_special_port_t Request_thread_set_special_port; + __Request__thread_info_t Request_thread_info; + __Request__thread_set_exception_ports_t Request_thread_set_exception_ports; + __Request__thread_get_exception_ports_t Request_thread_get_exception_ports; + __Request__thread_swap_exception_ports_t Request_thread_swap_exception_ports; + __Request__thread_policy_t Request_thread_policy; + __Request__thread_policy_set_t Request_thread_policy_set; + __Request__thread_policy_get_t Request_thread_policy_get; + __Request__thread_sample_t Request_thread_sample; + __Request__etap_trace_thread_t Request_etap_trace_thread; + __Request__thread_assign_t Request_thread_assign; + __Request__thread_assign_default_t Request_thread_assign_default; + __Request__thread_get_assignment_t Request_thread_get_assignment; + __Request__thread_set_policy_t Request_thread_set_policy; +}; +#endif /* !__RequestUnion__thread_act_subsystem__defined */ +/* typedefs for all replies */ + +#ifndef __Reply__thread_act_subsystem__defined +#define __Reply__thread_act_subsystem__defined + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_terminate_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_msg_type_number_t old_stateCnt; + natural_t old_state[144]; + } __Reply__act_get_state_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__act_set_state_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_msg_type_number_t old_stateCnt; + natural_t old_state[144]; + } __Reply__thread_get_state_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_set_state_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_suspend_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_resume_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_abort_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_abort_safely_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_depress_abort_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t special_port; + /* end of the kernel processed data */ + } __Reply__thread_get_special_port_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_set_special_port_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_msg_type_number_t thread_info_outCnt; + integer_t thread_info_out[12]; + } __Reply__thread_info_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_set_exception_ports_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t old_handlers[32]; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t masksCnt; + exception_mask_t masks[32]; + exception_behavior_t old_behaviors[32]; + thread_state_flavor_t old_flavors[32]; + } __Reply__thread_get_exception_ports_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t old_handlers[32]; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t masksCnt; + exception_mask_t masks[32]; + exception_behavior_t old_behaviors[32]; + thread_state_flavor_t old_flavors[32]; + } __Reply__thread_swap_exception_ports_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_policy_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_policy_set_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_msg_type_number_t policy_infoCnt; + integer_t policy_info[16]; + boolean_t get_default; + } __Reply__thread_policy_get_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_sample_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__etap_trace_thread_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_assign_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_assign_default_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t assigned_set; + /* end of the kernel processed data */ + } __Reply__thread_get_assignment_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_set_policy_t; +#ifdef __MigPackStructs +#pragma pack() +#endif +#endif /* !__Reply__thread_act_subsystem__defined */ + +/* union of all replies */ + +#ifndef __ReplyUnion__thread_act_subsystem__defined +#define __ReplyUnion__thread_act_subsystem__defined +union __ReplyUnion__thread_act_subsystem { + __Reply__thread_terminate_t Reply_thread_terminate; + __Reply__act_get_state_t Reply_act_get_state; + __Reply__act_set_state_t Reply_act_set_state; + __Reply__thread_get_state_t Reply_thread_get_state; + __Reply__thread_set_state_t Reply_thread_set_state; + __Reply__thread_suspend_t Reply_thread_suspend; + __Reply__thread_resume_t Reply_thread_resume; + __Reply__thread_abort_t Reply_thread_abort; + __Reply__thread_abort_safely_t Reply_thread_abort_safely; + __Reply__thread_depress_abort_t Reply_thread_depress_abort; + __Reply__thread_get_special_port_t Reply_thread_get_special_port; + __Reply__thread_set_special_port_t Reply_thread_set_special_port; + __Reply__thread_info_t Reply_thread_info; + __Reply__thread_set_exception_ports_t Reply_thread_set_exception_ports; + __Reply__thread_get_exception_ports_t Reply_thread_get_exception_ports; + __Reply__thread_swap_exception_ports_t Reply_thread_swap_exception_ports; + __Reply__thread_policy_t Reply_thread_policy; + __Reply__thread_policy_set_t Reply_thread_policy_set; + __Reply__thread_policy_get_t Reply_thread_policy_get; + __Reply__thread_sample_t Reply_thread_sample; + __Reply__etap_trace_thread_t Reply_etap_trace_thread; + __Reply__thread_assign_t Reply_thread_assign; + __Reply__thread_assign_default_t Reply_thread_assign_default; + __Reply__thread_get_assignment_t Reply_thread_get_assignment; + __Reply__thread_set_policy_t Reply_thread_set_policy; +}; +#endif /* !__RequestUnion__thread_act_subsystem__defined */ + +#ifndef subsystem_to_name_map_thread_act +#define subsystem_to_name_map_thread_act \ + { "thread_terminate", 3600 },\ + { "act_get_state", 3601 },\ + { "act_set_state", 3602 },\ + { "thread_get_state", 3603 },\ + { "thread_set_state", 3604 },\ + { "thread_suspend", 3605 },\ + { "thread_resume", 3606 },\ + { "thread_abort", 3607 },\ + { "thread_abort_safely", 3608 },\ + { "thread_depress_abort", 3609 },\ + { "thread_get_special_port", 3610 },\ + { "thread_set_special_port", 3611 },\ + { "thread_info", 3612 },\ + { "thread_set_exception_ports", 3613 },\ + { "thread_get_exception_ports", 3614 },\ + { "thread_swap_exception_ports", 3615 },\ + { "thread_policy", 3616 },\ + { "thread_policy_set", 3617 },\ + { "thread_policy_get", 3618 },\ + { "thread_sample", 3619 },\ + { "etap_trace_thread", 3620 },\ + { "thread_assign", 3621 },\ + { "thread_assign_default", 3622 },\ + { "thread_get_assignment", 3623 },\ + { "thread_set_policy", 3624 } +#endif + +#ifdef __AfterMigUserHeader +__AfterMigUserHeader +#endif /* __AfterMigUserHeader */ + +#endif /* _thread_act_user_ */ Index: branches/azimutz/Cleancut/i386/include/mach/ppc/ndr_def.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/ppc/ndr_def.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/ppc/ndr_def.h (revision 885) @@ -0,0 +1,43 @@ +/* + * Copyright (c) 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@ + */ +/* + * @OSF_COPYRIGHT@ + */ + +#include <mach/ndr.h> + +NDR_record_t NDR_record = { + 0, /* mig_reserved */ + 0, /* mig_reserved */ + 0, /* mig_reserved */ + NDR_PROTOCOL_2_0, + NDR_INT_BIG_ENDIAN, + NDR_CHAR_ASCII, + NDR_FLOAT_IEEE, + 0, +}; Index: branches/azimutz/Cleancut/i386/include/mach/ppc/task.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/ppc/task.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/ppc/task.h (revision 885) @@ -0,0 +1,1578 @@ +#ifndef _task_user_ +#define _task_user_ + +/* Module task */ + +#include <string.h> +#include <mach/ndr.h> +#include <mach/boolean.h> +#include <mach/kern_return.h> +#include <mach/notify.h> +#include <mach/mach_types.h> +#include <mach/message.h> +#include <mach/mig_errors.h> +#include <mach/port.h> + +#ifdef AUTOTEST +#ifndef FUNCTION_PTR_T +#define FUNCTION_PTR_T +typedef void (*function_ptr_t)(mach_port_t, char *, mach_msg_type_number_t); +typedef struct { + char *name; + function_ptr_t function; +} function_table_entry; +typedef function_table_entry *function_table_t; +#endif /* FUNCTION_PTR_T */ +#endif /* AUTOTEST */ + +#ifndef task_MSG_COUNT +#define task_MSG_COUNT 35 +#endif /* task_MSG_COUNT */ + +#include <mach/std_types.h> +#include <mach/mig.h> +#include <mach/mig.h> +#include <mach/mach_types.h> + +#ifdef __BeforeMigUserHeader +__BeforeMigUserHeader +#endif /* __BeforeMigUserHeader */ + +#include <sys/cdefs.h> +__BEGIN_DECLS + + +/* Routine task_create */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_create +( + task_t target_task, + ledger_array_t ledgers, + mach_msg_type_number_t ledgersCnt, + boolean_t inherit_memory, + task_t *child_task +); + +/* Routine task_terminate */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_terminate +( + task_t target_task +); + +/* Routine task_threads */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_threads +( + task_t target_task, + thread_act_array_t *act_list, + mach_msg_type_number_t *act_listCnt +); + +/* Routine mach_ports_register */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_ports_register +( + task_t target_task, + mach_port_array_t init_port_set, + mach_msg_type_number_t init_port_setCnt +); + +/* Routine mach_ports_lookup */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_ports_lookup +( + task_t target_task, + mach_port_array_t *init_port_set, + mach_msg_type_number_t *init_port_setCnt +); + +/* Routine task_info */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_info +( + task_name_t target_task, + task_flavor_t flavor, + task_info_t task_info_out, + mach_msg_type_number_t *task_info_outCnt +); + +/* Routine task_set_info */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_set_info +( + task_t target_task, + task_flavor_t flavor, + task_info_t task_info_in, + mach_msg_type_number_t task_info_inCnt +); + +/* Routine task_suspend */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_suspend +( + task_t target_task +); + +/* Routine task_resume */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_resume +( + task_t target_task +); + +/* Routine task_get_special_port */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_get_special_port +( + task_t task, + int which_port, + mach_port_t *special_port +); + +/* Routine task_set_special_port */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_set_special_port +( + task_t task, + int which_port, + mach_port_t special_port +); + +/* Routine thread_create */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_create +( + task_t parent_task, + thread_act_t *child_act +); + +/* Routine thread_create_running */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_create_running +( + task_t parent_task, + thread_state_flavor_t flavor, + thread_state_t new_state, + mach_msg_type_number_t new_stateCnt, + thread_act_t *child_act +); + +/* Routine task_set_exception_ports */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_set_exception_ports +( + task_t task, + exception_mask_t exception_mask, + mach_port_t new_port, + exception_behavior_t behavior, + thread_state_flavor_t new_flavor +); + +/* Routine task_get_exception_ports */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_get_exception_ports +( + task_t task, + exception_mask_t exception_mask, + exception_mask_array_t masks, + mach_msg_type_number_t *masksCnt, + exception_handler_array_t old_handlers, + exception_behavior_array_t old_behaviors, + exception_flavor_array_t old_flavors +); + +/* Routine task_swap_exception_ports */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_swap_exception_ports +( + task_t task, + exception_mask_t exception_mask, + mach_port_t new_port, + exception_behavior_t behavior, + thread_state_flavor_t new_flavor, + exception_mask_array_t masks, + mach_msg_type_number_t *masksCnt, + exception_handler_array_t old_handlerss, + exception_behavior_array_t old_behaviors, + exception_flavor_array_t old_flavors +); + +/* Routine lock_set_create */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t lock_set_create +( + task_t task, + lock_set_t *new_lock_set, + int n_ulocks, + int policy +); + +/* Routine lock_set_destroy */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t lock_set_destroy +( + task_t task, + lock_set_t lock_set +); + +/* Routine semaphore_create */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t semaphore_create +( + task_t task, + semaphore_t *semaphore, + int policy, + int value +); + +/* Routine semaphore_destroy */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t semaphore_destroy +( + task_t task, + semaphore_t semaphore +); + +/* Routine task_policy_set */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_policy_set +( + task_t task, + task_policy_flavor_t flavor, + task_policy_t policy_info, + mach_msg_type_number_t policy_infoCnt +); + +/* Routine task_policy_get */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_policy_get +( + task_t task, + task_policy_flavor_t flavor, + task_policy_t policy_info, + mach_msg_type_number_t *policy_infoCnt, + boolean_t *get_default +); + +/* Routine task_sample */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_sample +( + task_t task, + mach_port_t reply +); + +/* Routine task_policy */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_policy +( + task_t task, + policy_t policy, + policy_base_t base, + mach_msg_type_number_t baseCnt, + boolean_t set_limit, + boolean_t change +); + +/* Routine task_set_emulation */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_set_emulation +( + task_t target_port, + vm_address_t routine_entry_pt, + int routine_number +); + +/* Routine task_get_emulation_vector */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_get_emulation_vector +( + task_t task, + int *vector_start, + emulation_vector_t *emulation_vector, + mach_msg_type_number_t *emulation_vectorCnt +); + +/* Routine task_set_emulation_vector */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_set_emulation_vector +( + task_t task, + int vector_start, + emulation_vector_t emulation_vector, + mach_msg_type_number_t emulation_vectorCnt +); + +/* Routine task_set_ras_pc */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_set_ras_pc +( + task_t target_task, + vm_address_t basepc, + vm_address_t boundspc +); + +/* Routine task_assign */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_assign +( + task_t task, + processor_set_t new_set, + boolean_t assign_threads +); + +/* Routine task_assign_default */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_assign_default +( + task_t task, + boolean_t assign_threads +); + +/* Routine task_get_assignment */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_get_assignment +( + task_t task, + processor_set_name_t *assigned_set +); + +/* Routine task_set_policy */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_set_policy +( + task_t task, + processor_set_t pset, + policy_t policy, + policy_base_t base, + mach_msg_type_number_t baseCnt, + policy_limit_t limit, + mach_msg_type_number_t limitCnt, + boolean_t change +); + +/* Routine task_get_state */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_get_state +( + task_t task, + thread_state_flavor_t flavor, + thread_state_t old_state, + mach_msg_type_number_t *old_stateCnt +); + +/* Routine task_set_state */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_set_state +( + task_t task, + thread_state_flavor_t flavor, + thread_state_t new_state, + mach_msg_type_number_t new_stateCnt +); + +__END_DECLS + +/********************** Caution **************************/ +/* The following data types should be used to calculate */ +/* maximum message sizes only. The actual message may be */ +/* smaller, and the position of the arguments within the */ +/* message layout may vary from what is presented here. */ +/* For example, if any of the arguments are variable- */ +/* sized, and less than the maximum is sent, the data */ +/* will be packed tight in the actual message to reduce */ +/* the presence of holes. */ +/********************** Caution **************************/ + +/* typedefs for all requests */ + +#ifndef __Request__task_subsystem__defined +#define __Request__task_subsystem__defined + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_ports_descriptor_t ledgers; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t ledgersCnt; + boolean_t inherit_memory; + } __Request__task_create_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__task_terminate_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__task_threads_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_ports_descriptor_t init_port_set; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t init_port_setCnt; + } __Request__mach_ports_register_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__mach_ports_lookup_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + task_flavor_t flavor; + mach_msg_type_number_t task_info_outCnt; + } __Request__task_info_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + task_flavor_t flavor; + mach_msg_type_number_t task_info_inCnt; + integer_t task_info_in[10]; + } __Request__task_set_info_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__task_suspend_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__task_resume_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + int which_port; + } __Request__task_get_special_port_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t special_port; + /* end of the kernel processed data */ + NDR_record_t NDR; + int which_port; + } __Request__task_set_special_port_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__thread_create_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + thread_state_flavor_t flavor; + mach_msg_type_number_t new_stateCnt; + natural_t new_state[144]; + } __Request__thread_create_running_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t new_port; + /* end of the kernel processed data */ + NDR_record_t NDR; + exception_mask_t exception_mask; + exception_behavior_t behavior; + thread_state_flavor_t new_flavor; + } __Request__task_set_exception_ports_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + exception_mask_t exception_mask; + } __Request__task_get_exception_ports_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t new_port; + /* end of the kernel processed data */ + NDR_record_t NDR; + exception_mask_t exception_mask; + exception_behavior_t behavior; + thread_state_flavor_t new_flavor; + } __Request__task_swap_exception_ports_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + int n_ulocks; + int policy; + } __Request__lock_set_create_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t lock_set; + /* end of the kernel processed data */ + } __Request__lock_set_destroy_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + int policy; + int value; + } __Request__semaphore_create_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t semaphore; + /* end of the kernel processed data */ + } __Request__semaphore_destroy_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + task_policy_flavor_t flavor; + mach_msg_type_number_t policy_infoCnt; + integer_t policy_info[16]; + } __Request__task_policy_set_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + task_policy_flavor_t flavor; + mach_msg_type_number_t policy_infoCnt; + boolean_t get_default; + } __Request__task_policy_get_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t reply; + /* end of the kernel processed data */ + } __Request__task_sample_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + policy_t policy; + mach_msg_type_number_t baseCnt; + integer_t base[5]; + boolean_t set_limit; + boolean_t change; + } __Request__task_policy_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + vm_address_t routine_entry_pt; + int routine_number; + } __Request__task_set_emulation_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__task_get_emulation_vector_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_descriptor_t emulation_vector; + /* end of the kernel processed data */ + NDR_record_t NDR; + int vector_start; + mach_msg_type_number_t emulation_vectorCnt; + } __Request__task_set_emulation_vector_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + vm_address_t basepc; + vm_address_t boundspc; + } __Request__task_set_ras_pc_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t new_set; + /* end of the kernel processed data */ + NDR_record_t NDR; + boolean_t assign_threads; + } __Request__task_assign_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + boolean_t assign_threads; + } __Request__task_assign_default_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__task_get_assignment_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t pset; + /* end of the kernel processed data */ + NDR_record_t NDR; + policy_t policy; + mach_msg_type_number_t baseCnt; + integer_t base[5]; + mach_msg_type_number_t limitCnt; + integer_t limit[1]; + boolean_t change; + } __Request__task_set_policy_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + thread_state_flavor_t flavor; + mach_msg_type_number_t old_stateCnt; + } __Request__task_get_state_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + thread_state_flavor_t flavor; + mach_msg_type_number_t new_stateCnt; + natural_t new_state[144]; + } __Request__task_set_state_t; +#ifdef __MigPackStructs +#pragma pack() +#endif +#endif /* !__Request__task_subsystem__defined */ + +/* union of all requests */ + +#ifndef __RequestUnion__task_subsystem__defined +#define __RequestUnion__task_subsystem__defined +union __RequestUnion__task_subsystem { + __Request__task_create_t Request_task_create; + __Request__task_terminate_t Request_task_terminate; + __Request__task_threads_t Request_task_threads; + __Request__mach_ports_register_t Request_mach_ports_register; + __Request__mach_ports_lookup_t Request_mach_ports_lookup; + __Request__task_info_t Request_task_info; + __Request__task_set_info_t Request_task_set_info; + __Request__task_suspend_t Request_task_suspend; + __Request__task_resume_t Request_task_resume; + __Request__task_get_special_port_t Request_task_get_special_port; + __Request__task_set_special_port_t Request_task_set_special_port; + __Request__thread_create_t Request_thread_create; + __Request__thread_create_running_t Request_thread_create_running; + __Request__task_set_exception_ports_t Request_task_set_exception_ports; + __Request__task_get_exception_ports_t Request_task_get_exception_ports; + __Request__task_swap_exception_ports_t Request_task_swap_exception_ports; + __Request__lock_set_create_t Request_lock_set_create; + __Request__lock_set_destroy_t Request_lock_set_destroy; + __Request__semaphore_create_t Request_semaphore_create; + __Request__semaphore_destroy_t Request_semaphore_destroy; + __Request__task_policy_set_t Request_task_policy_set; + __Request__task_policy_get_t Request_task_policy_get; + __Request__task_sample_t Request_task_sample; + __Request__task_policy_t Request_task_policy; + __Request__task_set_emulation_t Request_task_set_emulation; + __Request__task_get_emulation_vector_t Request_task_get_emulation_vector; + __Request__task_set_emulation_vector_t Request_task_set_emulation_vector; + __Request__task_set_ras_pc_t Request_task_set_ras_pc; + __Request__task_assign_t Request_task_assign; + __Request__task_assign_default_t Request_task_assign_default; + __Request__task_get_assignment_t Request_task_get_assignment; + __Request__task_set_policy_t Request_task_set_policy; + __Request__task_get_state_t Request_task_get_state; + __Request__task_set_state_t Request_task_set_state; +}; +#endif /* !__RequestUnion__task_subsystem__defined */ +/* typedefs for all replies */ + +#ifndef __Reply__task_subsystem__defined +#define __Reply__task_subsystem__defined + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t child_task; + /* end of the kernel processed data */ + } __Reply__task_create_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_terminate_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_ports_descriptor_t act_list; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t act_listCnt; + } __Reply__task_threads_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__mach_ports_register_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_ports_descriptor_t init_port_set; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t init_port_setCnt; + } __Reply__mach_ports_lookup_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_msg_type_number_t task_info_outCnt; + integer_t task_info_out[10]; + } __Reply__task_info_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_set_info_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_suspend_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_resume_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t special_port; + /* end of the kernel processed data */ + } __Reply__task_get_special_port_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_set_special_port_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t child_act; + /* end of the kernel processed data */ + } __Reply__thread_create_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t child_act; + /* end of the kernel processed data */ + } __Reply__thread_create_running_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_set_exception_ports_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t old_handlers[32]; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t masksCnt; + exception_mask_t masks[32]; + exception_behavior_t old_behaviors[32]; + thread_state_flavor_t old_flavors[32]; + } __Reply__task_get_exception_ports_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t old_handlerss[32]; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t masksCnt; + exception_mask_t masks[32]; + exception_behavior_t old_behaviors[32]; + thread_state_flavor_t old_flavors[32]; + } __Reply__task_swap_exception_ports_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t new_lock_set; + /* end of the kernel processed data */ + } __Reply__lock_set_create_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__lock_set_destroy_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t semaphore; + /* end of the kernel processed data */ + } __Reply__semaphore_create_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__semaphore_destroy_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_policy_set_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_msg_type_number_t policy_infoCnt; + integer_t policy_info[16]; + boolean_t get_default; + } __Reply__task_policy_get_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_sample_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_policy_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_set_emulation_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_descriptor_t emulation_vector; + /* end of the kernel processed data */ + NDR_record_t NDR; + int vector_start; + mach_msg_type_number_t emulation_vectorCnt; + } __Reply__task_get_emulation_vector_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_set_emulation_vector_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_set_ras_pc_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_assign_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_assign_default_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t assigned_set; + /* end of the kernel processed data */ + } __Reply__task_get_assignment_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_set_policy_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_msg_type_number_t old_stateCnt; + natural_t old_state[144]; + } __Reply__task_get_state_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_set_state_t; +#ifdef __MigPackStructs +#pragma pack() +#endif +#endif /* !__Reply__task_subsystem__defined */ + +/* union of all replies */ + +#ifndef __ReplyUnion__task_subsystem__defined +#define __ReplyUnion__task_subsystem__defined +union __ReplyUnion__task_subsystem { + __Reply__task_create_t Reply_task_create; + __Reply__task_terminate_t Reply_task_terminate; + __Reply__task_threads_t Reply_task_threads; + __Reply__mach_ports_register_t Reply_mach_ports_register; + __Reply__mach_ports_lookup_t Reply_mach_ports_lookup; + __Reply__task_info_t Reply_task_info; + __Reply__task_set_info_t Reply_task_set_info; + __Reply__task_suspend_t Reply_task_suspend; + __Reply__task_resume_t Reply_task_resume; + __Reply__task_get_special_port_t Reply_task_get_special_port; + __Reply__task_set_special_port_t Reply_task_set_special_port; + __Reply__thread_create_t Reply_thread_create; + __Reply__thread_create_running_t Reply_thread_create_running; + __Reply__task_set_exception_ports_t Reply_task_set_exception_ports; + __Reply__task_get_exception_ports_t Reply_task_get_exception_ports; + __Reply__task_swap_exception_ports_t Reply_task_swap_exception_ports; + __Reply__lock_set_create_t Reply_lock_set_create; + __Reply__lock_set_destroy_t Reply_lock_set_destroy; + __Reply__semaphore_create_t Reply_semaphore_create; + __Reply__semaphore_destroy_t Reply_semaphore_destroy; + __Reply__task_policy_set_t Reply_task_policy_set; + __Reply__task_policy_get_t Reply_task_policy_get; + __Reply__task_sample_t Reply_task_sample; + __Reply__task_policy_t Reply_task_policy; + __Reply__task_set_emulation_t Reply_task_set_emulation; + __Reply__task_get_emulation_vector_t Reply_task_get_emulation_vector; + __Reply__task_set_emulation_vector_t Reply_task_set_emulation_vector; + __Reply__task_set_ras_pc_t Reply_task_set_ras_pc; + __Reply__task_assign_t Reply_task_assign; + __Reply__task_assign_default_t Reply_task_assign_default; + __Reply__task_get_assignment_t Reply_task_get_assignment; + __Reply__task_set_policy_t Reply_task_set_policy; + __Reply__task_get_state_t Reply_task_get_state; + __Reply__task_set_state_t Reply_task_set_state; +}; +#endif /* !__RequestUnion__task_subsystem__defined */ + +#ifndef subsystem_to_name_map_task +#define subsystem_to_name_map_task \ + { "task_create", 3400 },\ + { "task_terminate", 3401 },\ + { "task_threads", 3402 },\ + { "mach_ports_register", 3403 },\ + { "mach_ports_lookup", 3404 },\ + { "task_info", 3405 },\ + { "task_set_info", 3406 },\ + { "task_suspend", 3407 },\ + { "task_resume", 3408 },\ + { "task_get_special_port", 3409 },\ + { "task_set_special_port", 3410 },\ + { "thread_create", 3411 },\ + { "thread_create_running", 3412 },\ + { "task_set_exception_ports", 3413 },\ + { "task_get_exception_ports", 3414 },\ + { "task_swap_exception_ports", 3415 },\ + { "lock_set_create", 3416 },\ + { "lock_set_destroy", 3417 },\ + { "semaphore_create", 3418 },\ + { "semaphore_destroy", 3419 },\ + { "task_policy_set", 3420 },\ + { "task_policy_get", 3421 },\ + { "task_sample", 3422 },\ + { "task_policy", 3423 },\ + { "task_set_emulation", 3424 },\ + { "task_get_emulation_vector", 3425 },\ + { "task_set_emulation_vector", 3426 },\ + { "task_set_ras_pc", 3427 },\ + { "task_assign", 3429 },\ + { "task_assign_default", 3430 },\ + { "task_get_assignment", 3431 },\ + { "task_set_policy", 3432 },\ + { "task_get_state", 3433 },\ + { "task_set_state", 3434 } +#endif + +#ifdef __AfterMigUserHeader +__AfterMigUserHeader +#endif /* __AfterMigUserHeader */ + +#endif /* _task_user_ */ Index: branches/azimutz/Cleancut/i386/include/mach/ppc/vm_param.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/ppc/vm_param.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/ppc/vm_param.h (revision 885) @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2000-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@ + */ +/* + * @OSF_COPYRIGHT@ + */ + +#ifndef _MACH_PPC_VM_PARAM_H_ +#define _MACH_PPC_VM_PARAM_H_ + +/* + * These are the global definitions + */ + +#define BYTE_SIZE 8 /* byte size in bits */ + +#define PPC_PGBYTES 4096 /* bytes per ppc page */ +#define PPC_PGSHIFT 12 /* number of bits to shift for pages */ + +#define PAGE_SIZE PPC_PGBYTES +#define PAGE_SHIFT PPC_PGSHIFT +#define PAGE_MASK (PAGE_SIZE - 1) + +#if 0 +#define VM_MAX_PAGE_ADDRESS 0xFFFFFFFFFFFFF000ULL +#else +/* + * LP64todo - For now, we are limited to 51-bits of user addressing + */ +#define VM_MAX_PAGE_ADDRESS 0x0007FFFFFFFFF000ULL +#endif + +#define MACH_VM_MIN_ADDRESS ((mach_vm_offset_t) 0) +#define MACH_VM_MAX_ADDRESS ((mach_vm_offset_t) VM_MAX_PAGE_ADDRESS) + +/* + * These are the values relative to the local process. + */ +#if defined (__ppc64__) +/* + * LP64todo - We don't have the 64-bit address space layout yet. + * Use the 32-bit stack layout for now. + */ +#define VM_MIN_ADDRESS ((vm_offset_t) MACH_VM_MIN_ADDRESS) +#define VM_MAX_ADDRESS ((vm_offset_t) MACH_VM_MAX_ADDRESS) +#define USER_STACK_END ((vm_offset_t) 0x00000000ffff0000ULL) +#else +#define VM_MIN_ADDRESS ((vm_offset_t) 0) +#define VM_MAX_ADDRESS ((vm_offset_t) (VM_MAX_PAGE_ADDRESS & 0xFFFFFFFF)) +#define USER_STACK_END ((vm_offset_t) 0xffff0000U) +#endif /* defined(__ppc64__) */ + + +#endif /* _MACH_PPC_VM_PARAM_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/ppc/_structs.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/ppc/_structs.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/ppc/_structs.h (revision 885) @@ -0,0 +1,392 @@ +/* + * Copyright (c) 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@ + */ + +#ifndef _MACH_PPC__STRUCTS_H_ +#define _MACH_PPC__STRUCTS_H_ + +#include <sys/cdefs.h> + +/* + * ppc_thread_state is the structure that is exported to user threads for + * use in status/mutate calls. This structure should never change. + * + */ + +#if __DARWIN_UNIX03 +#define _STRUCT_PPC_THREAD_STATE struct __darwin_ppc_thread_state +_STRUCT_PPC_THREAD_STATE +{ + unsigned int __srr0; /* Instruction address register (PC) */ + unsigned int __srr1; /* Machine state register (supervisor) */ + unsigned int __r0; + unsigned int __r1; + unsigned int __r2; + unsigned int __r3; + unsigned int __r4; + unsigned int __r5; + unsigned int __r6; + unsigned int __r7; + unsigned int __r8; + unsigned int __r9; + unsigned int __r10; + unsigned int __r11; + unsigned int __r12; + unsigned int __r13; + unsigned int __r14; + unsigned int __r15; + unsigned int __r16; + unsigned int __r17; + unsigned int __r18; + unsigned int __r19; + unsigned int __r20; + unsigned int __r21; + unsigned int __r22; + unsigned int __r23; + unsigned int __r24; + unsigned int __r25; + unsigned int __r26; + unsigned int __r27; + unsigned int __r28; + unsigned int __r29; + unsigned int __r30; + unsigned int __r31; + + unsigned int __cr; /* Condition register */ + unsigned int __xer; /* User's integer exception register */ + unsigned int __lr; /* Link register */ + unsigned int __ctr; /* Count register */ + unsigned int __mq; /* MQ register (601 only) */ + + unsigned int __vrsave; /* Vector Save Register */ +}; +#else /* !__DARWIN_UNIX03 */ +#define _STRUCT_PPC_THREAD_STATE struct ppc_thread_state +_STRUCT_PPC_THREAD_STATE +{ + unsigned int srr0; /* Instruction address register (PC) */ + unsigned int srr1; /* Machine state register (supervisor) */ + unsigned int r0; + unsigned int r1; + unsigned int r2; + unsigned int r3; + unsigned int r4; + unsigned int r5; + unsigned int r6; + unsigned int r7; + unsigned int r8; + unsigned int r9; + unsigned int r10; + unsigned int r11; + unsigned int r12; + unsigned int r13; + unsigned int r14; + unsigned int r15; + unsigned int r16; + unsigned int r17; + unsigned int r18; + unsigned int r19; + unsigned int r20; + unsigned int r21; + unsigned int r22; + unsigned int r23; + unsigned int r24; + unsigned int r25; + unsigned int r26; + unsigned int r27; + unsigned int r28; + unsigned int r29; + unsigned int r30; + unsigned int r31; + + unsigned int cr; /* Condition register */ + unsigned int xer; /* User's integer exception register */ + unsigned int lr; /* Link register */ + unsigned int ctr; /* Count register */ + unsigned int mq; /* MQ register (601 only) */ + + unsigned int vrsave; /* Vector Save Register */ +}; +#endif /* __DARWIN_UNIX03 */ + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) + +#pragma pack(4) /* Make sure the structure stays as we defined it */ + +#if __DARWIN_UNIX03 +#define _STRUCT_PPC_THREAD_STATE64 struct __darwin_ppc_thread_state64 +_STRUCT_PPC_THREAD_STATE64 +{ + unsigned long long __srr0; /* Instruction address register (PC) */ + unsigned long long __srr1; /* Machine state register (supervisor) */ + unsigned long long __r0; + unsigned long long __r1; + unsigned long long __r2; + unsigned long long __r3; + unsigned long long __r4; + unsigned long long __r5; + unsigned long long __r6; + unsigned long long __r7; + unsigned long long __r8; + unsigned long long __r9; + unsigned long long __r10; + unsigned long long __r11; + unsigned long long __r12; + unsigned long long __r13; + unsigned long long __r14; + unsigned long long __r15; + unsigned long long __r16; + unsigned long long __r17; + unsigned long long __r18; + unsigned long long __r19; + unsigned long long __r20; + unsigned long long __r21; + unsigned long long __r22; + unsigned long long __r23; + unsigned long long __r24; + unsigned long long __r25; + unsigned long long __r26; + unsigned long long __r27; + unsigned long long __r28; + unsigned long long __r29; + unsigned long long __r30; + unsigned long long __r31; + + unsigned int __cr; /* Condition register */ + unsigned long long __xer; /* User's integer exception register */ + unsigned long long __lr; /* Link register */ + unsigned long long __ctr; /* Count register */ + + unsigned int __vrsave; /* Vector Save Register */ +}; +#else /* !__DARWIN_UNIX03 */ +#define _STRUCT_PPC_THREAD_STATE64 struct ppc_thread_state64 +_STRUCT_PPC_THREAD_STATE64 +{ + unsigned long long srr0; /* Instruction address register (PC) */ + unsigned long long srr1; /* Machine state register (supervisor) */ + unsigned long long r0; + unsigned long long r1; + unsigned long long r2; + unsigned long long r3; + unsigned long long r4; + unsigned long long r5; + unsigned long long r6; + unsigned long long r7; + unsigned long long r8; + unsigned long long r9; + unsigned long long r10; + unsigned long long r11; + unsigned long long r12; + unsigned long long r13; + unsigned long long r14; + unsigned long long r15; + unsigned long long r16; + unsigned long long r17; + unsigned long long r18; + unsigned long long r19; + unsigned long long r20; + unsigned long long r21; + unsigned long long r22; + unsigned long long r23; + unsigned long long r24; + unsigned long long r25; + unsigned long long r26; + unsigned long long r27; + unsigned long long r28; + unsigned long long r29; + unsigned long long r30; + unsigned long long r31; + + unsigned int cr; /* Condition register */ + unsigned long long xer; /* User's integer exception register */ + unsigned long long lr; /* Link register */ + unsigned long long ctr; /* Count register */ + + unsigned int vrsave; /* Vector Save Register */ +}; +#endif /* __DARWIN_UNIX03 */ + +#pragma pack() + +#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ + +/* This structure should be double-word aligned for performance */ + +#if __DARWIN_UNIX03 +#define _STRUCT_PPC_FLOAT_STATE struct __darwin_ppc_float_state +_STRUCT_PPC_FLOAT_STATE +{ + double __fpregs[32]; + + unsigned int __fpscr_pad; /* fpscr is 64 bits, 32 bits of rubbish */ + unsigned int __fpscr; /* floating point status register */ +}; +#else /* !__DARWIN_UNIX03 */ +#define _STRUCT_PPC_FLOAT_STATE struct ppc_float_state +_STRUCT_PPC_FLOAT_STATE +{ + double fpregs[32]; + + unsigned int fpscr_pad; /* fpscr is 64 bits, 32 bits of rubbish */ + unsigned int fpscr; /* floating point status register */ +}; +#endif /* __DARWIN_UNIX03 */ + +#pragma pack(4) /* Make sure the structure stays as we defined it */ + +#if __DARWIN_UNIX03 +#define _STRUCT_PPC_VECTOR_STATE struct __darwin_ppc_vector_state +_STRUCT_PPC_VECTOR_STATE +{ +#if defined(__LP64__) + unsigned int __save_vr[32][4]; + unsigned int __save_vscr[4]; +#else + unsigned long __save_vr[32][4]; + unsigned long __save_vscr[4]; +#endif + unsigned int __save_pad5[4]; + unsigned int __save_vrvalid; /* VRs that have been saved */ + unsigned int __save_pad6[7]; +}; +#else /* !__DARWIN_UNIX03 */ +#define _STRUCT_PPC_VECTOR_STATE struct ppc_vector_state +_STRUCT_PPC_VECTOR_STATE +{ +#if defined(__LP64__) + unsigned int save_vr[32][4]; + unsigned int save_vscr[4]; +#else + unsigned long save_vr[32][4]; + unsigned long save_vscr[4]; +#endif + unsigned int save_pad5[4]; + unsigned int save_vrvalid; /* VRs that have been saved */ + unsigned int save_pad6[7]; +}; +#endif /* __DARWIN_UNIX03 */ + +#pragma pack() + +/* + * ppc_exception_state + * + * This structure corresponds to some additional state of the user + * registers as saved in the PCB upon kernel entry. They are only + * available if an exception is passed out of the kernel, and even + * then not all are guaranteed to be updated. + * + * Some padding is included in this structure which allows space for + * servers to store temporary values if need be, to maintain binary + * compatiblity. + */ + +/* Exception state for 32-bit thread (on 32-bit processor) */ +/* Still available on 64-bit processors, but may fall short */ +/* of covering the full potential state (hi half available). */ + +#pragma pack(4) /* Make sure the structure stays as we defined it */ + +#if __DARWIN_UNIX03 +#define _STRUCT_PPC_EXCEPTION_STATE struct __darwin_ppc_exception_state +_STRUCT_PPC_EXCEPTION_STATE +{ +#if defined(__LP64__) + unsigned int __dar; /* Fault registers for coredump */ + unsigned int __dsisr; + unsigned int __exception; /* number of powerpc exception taken */ + unsigned int __pad0; /* align to 16 bytes */ + unsigned int __pad1[4]; /* space in PCB "just in case" */ +#else + unsigned long __dar; /* Fault registers for coredump */ + unsigned long __dsisr; + unsigned long __exception; /* number of powerpc exception taken */ + unsigned long __pad0; /* align to 16 bytes */ + unsigned long __pad1[4]; /* space in PCB "just in case" */ +#endif +}; +#else /* !__DARWIN_UNIX03 */ +#define _STRUCT_PPC_EXCEPTION_STATE struct ppc_exception_state +_STRUCT_PPC_EXCEPTION_STATE +{ +#if defined(__LP64__) + unsigned int dar; /* Fault registers for coredump */ + unsigned int dsisr; + unsigned int exception; /* number of powerpc exception taken */ + unsigned int pad0; /* align to 16 bytes */ + unsigned int pad1[4]; /* space in PCB "just in case" */ +#else + unsigned long dar; /* Fault registers for coredump */ + unsigned long dsisr; + unsigned long exception; /* number of powerpc exception taken */ + unsigned long pad0; /* align to 16 bytes */ + unsigned long pad1[4]; /* space in PCB "just in case" */ +#endif +}; +#endif /* __DARWIN_UNIX03 */ + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#if __DARWIN_UNIX03 +#define _STRUCT_PPC_EXCEPTION_STATE64 struct __darwin_ppc_exception_state64 +_STRUCT_PPC_EXCEPTION_STATE64 +{ + unsigned long long __dar; /* Fault registers for coredump */ +#if defined(__LP64__) + unsigned int __dsisr; + unsigned int __exception; /* number of powerpc exception taken */ + unsigned int __pad1[4]; /* space in PCB "just in case" */ +#else + unsigned long __dsisr; + unsigned long __exception; /* number of powerpc exception taken */ + unsigned long __pad1[4]; /* space in PCB "just in case" */ +#endif +}; +#else /* !__DARWIN_UNIX03 */ +#define _STRUCT_PPC_EXCEPTION_STATE64 struct ppc_exception_state64 +_STRUCT_PPC_EXCEPTION_STATE64 +{ + unsigned long long dar; /* Fault registers for coredump */ +#if defined(__LP64__) + unsigned int dsisr; + unsigned int exception; /* number of powerpc exception taken */ + unsigned int pad1[4]; /* space in PCB "just in case" */ +#else + unsigned long dsisr; + unsigned long exception; /* number of powerpc exception taken */ + unsigned long pad1[4]; /* space in PCB "just in case" */ +#endif +}; +#endif /* __DARWIN_UNIX03 */ +#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ + +#pragma pack() + +#endif /* _MACH_PPC__STRUCTS_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/ppc/vm_types.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/ppc/vm_types.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/ppc/vm_types.h (revision 885) @@ -0,0 +1,142 @@ +/* + * 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,1988 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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + */ + +/* + * File: vm_types.h + * Author: Avadis Tevanian, Jr. + * Date: 1985 + * + * Header file for VM data types. PPC version. + */ + +#ifndef _MACH_PPC_VM_TYPES_H_ +#define _MACH_PPC_VM_TYPES_H_ + +#ifndef ASSEMBLER + +#include <ppc/_types.h> +#include <mach/ppc/vm_param.h> +#include <stdint.h> + +/* + * natural_t and integer_t are Mach's legacy types for machine- + * independent integer types (unsigned, and signed, respectively). + * Their original purpose was to define other types in a machine/ + * compiler independent way. + * + * They also had an implicit "same size as pointer" characteristic + * to them (i.e. Mach's traditional types are very ILP32 or ILP64 + * centric). We support PowerPC ABIs that do not follow either of + * these models (specifically LP64). Therefore, we had to make a + * choice between making these types scale with pointers or stay + * tied to integers. Because their use is predominantly tied to + * to the size of an integer, we are keeping that association and + * breaking free from pointer size guarantees. + * + * New use of these types is discouraged. + */ +typedef __darwin_natural_t natural_t; +typedef int integer_t; + +#if defined(__ppc__) + +/* + * For 32-bit PowerPC ABIs, the scalable types were + * always based upon natural_t (unsigned int). + * Because of potential legacy issues with name mangling, + * we cannot use the stdint uintptr_t type. + */ +typedef natural_t vm_offset_t; +typedef natural_t vm_size_t; + +#else /* __ppc64__ */ + +/* + * For 64-bit PowerPC ABIs, we have no legacy name mangling + * issues, so we use the stdint types for scaling these + * types to the same size as a pointer. + */ +typedef uintptr_t vm_offset_t; +typedef uintptr_t vm_size_t; + +#endif + +/* + * This new type is independent of a particular vm map's + * implementation size - and represents appropriate types + * for all possible maps. This is used for interfaces + * where the size of the map is not known - or we don't + * want to have to distinguish. + */ +typedef uint64_t mach_vm_address_t; +typedef uint64_t mach_vm_offset_t; +typedef uint64_t mach_vm_size_t; + +typedef uint64_t vm_map_offset_t; +typedef uint64_t vm_map_address_t; +typedef uint64_t vm_map_size_t; + + +#endif /* ASSEMBLER */ + +/* + * If composing messages by hand (please do not) + */ +#define MACH_MSG_TYPE_INTEGER_T MACH_MSG_TYPE_INTEGER_32 + +#endif /* _MACH_PPC_VM_TYPES_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/ppc/thread_state.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/ppc/thread_state.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/ppc/thread_state.h (revision 885) @@ -0,0 +1,42 @@ +/* + * 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@ + */ + +#ifndef _MACH_PPC_THREAD_STATE_H_ +#define _MACH_PPC_THREAD_STATE_H_ + +/* Size of maximum exported thread state in words */ +#define PPC_THREAD_STATE_MAX (144) /* Size of biggest state possible */ + +#if defined (__ppc__) || defined (__ppc64__) +#define THREAD_STATE_MAX PPC_THREAD_STATE_MAX +#endif + +#endif /* _MACH_PPC_THREAD_STATE_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/ppc/thread_status.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/ppc/thread_status.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/ppc/thread_status.h (revision 885) @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2000-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@ + */ +/* + * @OSF_COPYRIGHT@ + */ + +#ifndef _MACH_PPC_THREAD_STATUS_H_ +#define _MACH_PPC_THREAD_STATUS_H_ + +#include <mach/ppc/_structs.h> +#include <mach/message.h> + +/* + * ppc_thread_state is the structure that is exported to user threads for + * use in status/mutate calls. This structure should never change. + * + */ + +#define PPC_THREAD_STATE 1 +#define PPC_FLOAT_STATE 2 +#define PPC_EXCEPTION_STATE 3 +#define PPC_VECTOR_STATE 4 +#define PPC_THREAD_STATE64 5 +#define PPC_EXCEPTION_STATE64 6 +#define THREAD_STATE_NONE 7 + +/* + * VALID_THREAD_STATE_FLAVOR is a platform specific macro that when passed + * an exception flavor will return whether that is a defined flavor for + * that platform. + * The macro must be manually updated to include all of the valid exception + * flavors as defined above. + */ +#define VALID_THREAD_STATE_FLAVOR(x) \ + ((x == PPC_THREAD_STATE) || \ + (x == PPC_FLOAT_STATE) || \ + (x == PPC_EXCEPTION_STATE) || \ + (x == PPC_VECTOR_STATE) || \ + (x == PPC_THREAD_STATE64) || \ + (x == PPC_EXCEPTION_STATE64) || \ + (x == THREAD_STATE_NONE)) + +typedef _STRUCT_PPC_THREAD_STATE ppc_thread_state_t; +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +typedef _STRUCT_PPC_THREAD_STATE64 ppc_thread_state64_t; +#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ +typedef _STRUCT_PPC_FLOAT_STATE ppc_float_state_t; +typedef _STRUCT_PPC_VECTOR_STATE ppc_vector_state_t; + +/* + * saved state structure + * + * This structure corresponds to the saved state. + * + */ + +#ifdef MACH__POSIX_C_SOURCE_PRIVATE + +#include <ppc/savearea.h> + +typedef struct savearea ppc_saved_state_t; + +#else /* MACH__POSIX_C_SOURCE_PRIVATE */ + +typedef struct ppc_thread_state ppc_saved_state_t; + +#endif /* MACH__POSIX_C_SOURCE_PRIVATE */ + +/* + * ppc_exception_state + * + * This structure corresponds to some additional state of the user + * registers as saved in the PCB upon kernel entry. They are only + * available if an exception is passed out of the kernel, and even + * then not all are guaranteed to be updated. + * + * Some padding is included in this structure which allows space for + * servers to store temporary values if need be, to maintain binary + * compatiblity. + */ + +/* Exception state for 32-bit thread (on 32-bit processor) */ +/* Still available on 64-bit processors, but may fall short */ +/* of covering the full potential state (hi half available). */ + +typedef _STRUCT_PPC_EXCEPTION_STATE ppc_exception_state_t; +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +typedef _STRUCT_PPC_EXCEPTION_STATE64 ppc_exception_state64_t; +#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ + +/* + * Save State Flags + */ + +#define PPC_THREAD_STATE_COUNT ((mach_msg_type_number_t) \ + (sizeof(ppc_thread_state_t) / sizeof(int))) + +#define PPC_THREAD_STATE64_COUNT ((mach_msg_type_number_t) \ + (sizeof(ppc_thread_state64_t) / sizeof(int))) + +#define PPC_EXCEPTION_STATE_COUNT ((mach_msg_type_number_t) \ + (sizeof(ppc_exception_state_t) / sizeof(int))) + +#define PPC_EXCEPTION_STATE64_COUNT ((mach_msg_type_number_t) \ + (sizeof(ppc_exception_state64_t) / sizeof(int))) + +#define PPC_FLOAT_STATE_COUNT ((mach_msg_type_number_t) \ + (sizeof(ppc_float_state_t) / sizeof(int))) + +#define PPC_VECTOR_STATE_COUNT ((mach_msg_type_number_t) \ + (sizeof(ppc_vector_state_t) / sizeof(int))) + +/* + * Machine-independent way for servers and Mach's exception mechanism to + * choose the most efficient state flavor for exception RPC's: + */ +#define MACHINE_THREAD_STATE PPC_THREAD_STATE +#define MACHINE_THREAD_STATE_COUNT PPC_THREAD_STATE_COUNT + +/* + * Largest state on this machine: + */ +#define THREAD_MACHINE_STATE_MAX THREAD_STATE_MAX + +#endif /* _MACH_PPC_THREAD_STATUS_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/ppc/boolean.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/ppc/boolean.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/ppc/boolean.h (revision 885) @@ -0,0 +1,74 @@ +/* + * 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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + */ + +/* + * File: boolean.h + * + * Boolean type, for ppc. + */ + +#ifndef _MACH_PPC_BOOLEAN_H_ +#define _MACH_PPC_BOOLEAN_H_ + +#if defined(__ppc64__) +typedef unsigned int boolean_t; +#else +typedef int boolean_t; +#endif + +#endif /* _MACH_PPC_BOOLEAN_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/ppc/asm.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/ppc/asm.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/ppc/asm.h (revision 885) @@ -0,0 +1,781 @@ +/* + * Copyright (c) 2000-2007 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@ + */ +#ifndef _PPC_ASM_H_ +#define _PPC_ASM_H_ + +#define __ASMNL__ @ +#define STRINGD .ascii + +#ifdef ASSEMBLER + + +#define br0 0 + +#define ARG0 r3 +#define ARG1 r4 +#define ARG2 r5 +#define ARG3 r6 +#define ARG4 r7 +#define ARG5 r8 +#define ARG6 r9 +#define ARG7 r10 + +#define tmp0 r0 /* Temporary GPR remapping (603e specific) */ +#define tmp1 r1 +#define tmp2 r2 +#define tmp3 r3 + +/* SPR registers */ + +#define mq 0 /* MQ register for 601 emulation */ +#define rtcu 4 /* RTCU - upper word of RTC for 601 emulation */ +#define rtcl 5 /* RTCL - lower word of RTC for 601 emulation */ +#define dsisr 18 +#define ppcDAR 19 +#define ppcdar 19 +#define dar 19 +#define SDR1 25 +#define sdr1 25 +#define srr0 26 +#define srr1 27 +#define vrsave 256 /* Vector Register save */ +#define sprg0 272 +#define sprg1 273 +#define sprg2 274 +#define sprg3 275 +#define scomc 276 +#define scomd 277 +#define pvr 287 + +#define IBAT0U 528 +#define IBAT0L 529 +#define IBAT1U 530 +#define IBAT1L 531 +#define IBAT2U 532 +#define IBAT2L 533 +#define IBAT3U 534 +#define IBAT3L 535 +#define ibat0u 528 +#define ibat0l 529 +#define ibat1u 530 +#define ibat1l 531 +#define ibat2u 532 +#define ibat2l 533 +#define ibat3u 534 +#define ibat3l 535 + +#define DBAT0U 536 +#define DBAT0L 537 +#define DBAT1U 538 +#define DBAT1L 539 +#define DBAT2U 540 +#define DBAT2L 541 +#define DBAT3U 542 +#define DBAT3L 543 +#define dbat0u 536 +#define dbat0l 537 +#define dbat1u 538 +#define dbat1l 539 +#define dbat2u 540 +#define dbat2l 541 +#define dbat3u 542 +#define dbat3l 543 + +#define ummcr2 928 /* Performance monitor control */ +#define upmc5 929 /* Performance monitor counter */ +#define upmc6 930 /* Performance monitor counter */ +#define ubamr 935 /* Performance monitor mask */ +#define ummcr0 936 /* Performance monitor control */ +#define upmc1 937 /* Performance monitor counter */ +#define upmc2 938 /* Performance monitor counter */ +#define usia 939 /* User sampled instruction address */ +#define ummcr1 940 /* Performance monitor control */ +#define upmc3 941 /* Performance monitor counter */ +#define upmc4 942 /* Performance monitor counter */ +#define usda 943 /* User sampled data address */ +#define mmcr2 944 /* Performance monitor control */ +#define pmc5 945 /* Performance monitor counter */ +#define pmc6 946 /* Performance monitor counter */ +#define bamr 951 /* Performance monitor mask */ +#define mmcr0 952 +#define pmc1 953 +#define pmc2 954 +#define sia 955 +#define mmcr1 956 +#define pmc3 957 +#define pmc4 958 +#define sda 959 /* Sampled data address */ +#define dmiss 976 /* ea that missed */ +#define trig0 976 +#define dcmp 977 /* compare value for the va that missed */ +#define trig1 977 +#define hash1 978 /* pointer to first hash pteg */ +#define trig2 978 +#define hash2 979 /* pointer to second hash pteg */ +#define imiss 980 /* ea that missed */ +#define tlbmiss 980 /* ea that missed */ +#define icmp 981 /* compare value for the va that missed */ +#define ptehi 981 /* compare value for the va that missed */ +#define rpa 982 /* required physical address register */ +#define ptelo 982 /* required physical address register */ +#define l3pdet 984 /* l3pdet */ + +#define HID0 1008 /* Checkstop and misc enables */ +#define hid0 1008 /* Checkstop and misc enables */ +#define HID1 1009 /* Clock configuration */ +#define hid1 1009 /* Clock configuration */ +#define HID2 1016 /* Other processor controls */ +#define hid2 1016 /* Other processor controls */ +#define iabr 1010 /* Instruction address breakpoint register */ +#define ictrl 1011 /* Instruction Cache Control */ +#define ldstdb 1012 /* Load/Store Debug */ +#define hid4 1012 /* Misc stuff */ +#define dabr 1013 /* Data address breakpoint register */ +#define msscr0 1014 /* Memory subsystem control */ +#define hid5 1014 /* Misc stuff */ +#define msscr1 1015 /* Memory subsystem debug */ +#define msssr0 1015 /* Memory Subsystem Status */ +#define ldstcr 1016 /* Load/Store Status/Control */ +#define l2cr2 1016 /* L2 Cache control 2 */ +#define l2cr 1017 /* L2 Cache control */ +#define l3cr 1018 /* L3 Cache control */ +#define ictc 1019 /* I-cache throttling control */ +#define thrm1 1020 /* Thermal management 1 */ +#define thrm2 1021 /* Thermal management 2 */ +#define thrm3 1022 /* Thermal management 3 */ +#define pir 1023 /* Processor ID Register */ + + +/* SPR registers (64-bit, PPC970 specific) */ + +#define scomc_gp 276 +#define scomd_gp 277 + +#define hsprg0 304 +#define hsprg1 305 +#define hdec 310 +#define hior 311 +#define rmor 312 +#define hrmor 313 +#define hsrr0 314 +#define hsrr1 315 +#define lpcr 318 +#define lpidr 319 + +#define ummcra_gp 770 +#define upmc1_gp 771 +#define upmc2_gp 772 +#define upmc3_gp 773 +#define upmc4_gp 774 +#define upmc5_gp 775 +#define upmc6_gp 776 +#define upmc7_gp 777 +#define upmc8_gp 778 +#define ummcr0_gp 779 +#define usiar_gp 780 +#define usdar_gp 781 +#define ummcr1_gp 782 +#define uimc_gp 783 + +#define mmcra_gp 786 +#define pmc1_gp 787 +#define pmc2_gp 788 +#define pmc3_gp 789 +#define pmc4_gp 790 +#define pmc5_gp 791 +#define pmc6_gp 792 +#define pmc7_gp 793 +#define pmc8_gp 794 +#define mmcr0_gp 795 +#define siar_gp 796 +#define sdar_gp 797 +#define mmcr1_gp 798 +#define imc_gp 799 + +#define trig0_gp 976 +#define trig1_gp 977 +#define trig2_gp 978 + +#define dabrx 1015 + +; hid0 bits +#define emcp 0 +#define emcpm 0x80000000 +#define dbp 1 +#define dbpm 0x40000000 +#define eba 2 +#define ebam 0x20000000 +#define ebd 3 +#define ebdm 0x10000000 +#define sbclk 4 +#define sbclkm 0x08000000 +#define eclk 6 +#define eclkm 0x02000000 +#define par 7 +#define parm 0x01000000 +#define sten 7 +#define stenm 0x01000000 +#define dnap 7 +#define dnapm 0x01000000 +#define doze 8 +#define dozem 0x00800000 +#define nap 9 +#define napm 0x00400000 +#define sleep 10 +#define sleepm 0x00200000 +#define dpm 11 +#define dpmm 0x00100000 +#define riseg 12 +#define risegm 0x00080000 +#define eiec 13 +#define eiecm 0x00040000 +#define mum 14 +#define mumm 0x00020000 +#define nhr 15 +#define nhrm 0x00010000 +#define ice 16 +#define icem 0x00008000 +#define dce 17 +#define dcem 0x00004000 +#define ilock 18 +#define ilockm 0x00002000 +#define dlock 19 +#define dlockm 0x00001000 +#define exttben 19 +#define icfi 20 +#define icfim 0x00000800 +#define dcfi 21 +#define dcfim 0x00000400 +#define spd 22 +#define spdm 0x00000200 +#define hdice 23 +#define hdicem 0x00000100 +#define sge 24 +#define sgem 0x00000080 +#define dcfa 25 +#define dcfam 0x00000040 +#define btic 26 +#define bticm 0x00000020 +#define lrstk 27 +#define lrstkm 0x00000010 +#define abe 28 +#define abem 0x00000008 +#define fold 28 +#define foldm 0x00000008 +#define bht 29 +#define bhtm 0x00000004 +#define nopdst 30 +#define nopdstm 0x00000002 +#define nopti 31 +#define noptim 0x00000001 + +; hid1 bits +#define hid1pcem 0xF8000000 +#define hid1prem 0x06000000 +#define hid1dfs0 8 +#define hid1dfs0m 0x00800000 +#define hid1dfs1 9 +#define hid1dfs1m 0x00400000 +#define hid1pi0 14 +#define hid1pi0m 0x00020000 +#define hid1FCPErr 14 +#define hid1ps 15 +#define hid1FCD0PErr 15 +#define hid1psm 0x00010000 +#define hid1pc0 0x0000F800 +#define hid1pr0 0x00000600 +#define hid1pc1 0x000000F8 +#define hid1pc0 0x0000F800 +#define hid1pr1 0x00000006 +#define hid1FCD1PErr 16 +#define hid1FIERATErr 17 + +; hid2 bits +#define hid2vmin 18 +#define hid2vminm 0x00002000 + +; msscr0 bits +#define shden 0 +#define shdenm 0x80000000 +#define shden3 1 +#define shdenm3 0x40000000 +#define l1intvs 2 +#define l1intve 4 +#define l1intvb 0x38000000 +#define l2intvs 5 +#define l2intve 7 +#define l2intvb 0x07000000 +#define dl1hwf 8 +#define dl1hwfm 0x00800000 +#define dbsiz 9 +#define dbsizm 0x00400000 +#define emode 10 +#define emodem 0x00200000 +#define abgd 11 +#define abgdm 0x00100000 +#define tfsts 24 +#define tfste 25 +#define tfstm 0x000000C0 +#define l2pfes 30 +#define l2pfee 31 +#define l2pfem 0x00000003 + +; msscr1 bits +#define cqd 15 +#define cqdm 0x00010000 +#define csqs 1 +#define csqe 2 +#define csqm 0x60000000 + +; msssr1 bits - 7450 +#define vgL2PARA 0 +#define vgL3PARA 1 +#define vgL2COQEL 2 +#define vgL3COQEL 3 +#define vgL2CTR 4 +#define vgL3CTR 5 +#define vgL2COQR 6 +#define vgL3COQR 7 +#define vgLMQ 8 +#define vgSMC 9 +#define vgSNP 10 +#define vgBIU 11 +#define vgSMCE 12 +#define vgL2TAG 13 +#define vgL2DAT 14 +#define vgL3TAG 15 +#define vgL3DAT 16 +#define vgAPE 17 +#define vgDPE 18 +#define vgTEA 19 + +; srr1 bits +#define icmck 1 +#define icmckm 0x40000000 +#define dcmck 2 +#define dcmckm 0x20000000 +#define l2mck 3 +#define l2mckm 0x10000000 +#define tlbmck 4 +#define tlbmckm 0x08000000 +#define brmck 5 +#define brmckm 0x04000000 +#define othmck 10 +#define othmckm 0x00200000 +#define l2dpmck 11 +#define l2dpmckm 0x00100000 +#define mcpmck 12 +#define mcpmckm 0x00080000 +#define teamck 13 +#define teamckm 0x00040000 +#define dpmck 14 +#define dpmckm 0x00020000 +#define apmck 15 +#define apmckm 0x00010000 + +#define mckIFUE 42 +#define mckLDST 43 +#define mckXCs 44 +#define mckXCe 45 +#define mckNoErr 0 +#define mckIFSLBPE 1 +#define mckIFTLBPE 2 +#define mckIFTLBUE 3 + +; dsisr bits +#define mckUEdfr 16 +#define mckUETwDfr 17 +#define mckL1DCPE 18 +#define mckL1DTPE 19 +#define mckDEPE 20 +#define mckTLBPE 21 +#define mckSLBPE 23 + +; Async MCK source +#define AsyMCKSrc 0x0226 +#define AsyMCKRSrc 0x0227 +#define AsyMCKext 0 +#define AsyMCKfir 1 +#define AsyMCKhri 2 +#define AsyMCKdbg 3 +#define AsyMCKncstp 4 + +; Core FIR +#define cFIR 0x0300 +#define cFIRrst 0x0310 +#define cFIRICachePE 0 +#define cFIRITagPE0 1 +#define cFIRITagPE1 2 +#define cFIRIEratPE 3 +#define cFIRIFUL2UE 4 +#define cFIRIFUCS 5 +#define cFIRDCachePE 6 +#define cFIRDTagPE 7 +#define cFIRDEratPE 8 +#define cFIRTLBPE 9 +#define cFIRSLBPE 10 +#define cFIRSL2UE 11 + +; Core Error Inject +#define CoreErrI 0x0350 +#define CoreIFU 0 +#define CoreLSU 1 +#define CoreRate0 2 +#define CoreRate1 3 +#define CoreOnce 0 +#define CoreSolid 2 +#define CorePulse 3 + +; L2 FIR +#define l2FIR 0x0400 +#define l2FIRrst 0x0410 + +; Bus FIR +#define busFIR 0x0A00 +#define busFIRrst 0x0A10 + +; HID4 +#define hid4RMCI 23 +#define hid4FAlgn 24 +#define hid4DisPF 25 +#define hid4ResPF 26 +#define hid4EnSPTW 27 +#define hid4L1DCFI 28 +#define hid4DisDERpg 31 +#define hid4DisDCTpg 36 +#define hid4DisDCpg 41 +#define hid4DisTLBpg 48 +#define hid4DisSLBpg 54 +#define hid4MckEIEna 55 + +; L2 cache control +#define l2e 0 +#define l2em 0x80000000 +#define l2pe 1 +#define l2pem 0x40000000 +#define l2siz 2 +#define l2sizf 3 +#define l2sizm 0x30000000 +#define l2clk 4 +#define l2clkf 6 +#define l2clkm 0x0E000000 +#define l2ram 7 +#define l2ramf 8 +#define l2ramm 0x01800000 +#define l2do 9 +#define l2dom 0x00400000 +#define l2i 10 +#define l2im 0x00200000 +#define l2ctl 11 +#define l2ctlm 0x00100000 +#define l2ionly 11 +#define l2ionlym 0x00100000 +#define l2wt 12 +#define l2wtm 0x00080000 +#define l2ts 13 +#define l2tsm 0x00040000 +#define l2oh 14 +#define l2ohf 15 +#define l2ohm 0x00030000 +#define l2donly 15 +#define l2donlym 0x00010000 +#define l2sl 16 +#define l2slm 0x00008000 +#define l2df 17 +#define l2dfm 0x00004000 +#define l2byp 18 +#define l2bypm 0x00002000 +#define l2fa 19 +#define l2fam 0x00001000 +#define l2hwf 20 +#define l2hwfm 0x00000800 +#define l2io 21 +#define l2iom 0x00000400 +#define l2clkstp 22 +#define l2clkstpm 0x00000200 +#define l2dro 23 +#define l2drom 0x00000100 +#define l2ctr 24 +#define l2ctrf 30 +#define l2ctrm 0x000000FE +#define l2ip 31 +#define l2ipm 0x00000001 + +; L3 cache control +#define l3e 0 +#define l3em 0x80000000 +#define l3pe 1 +#define l3pem 0x40000000 +#define l3siz 3 +#define l3sizm 0x10000000 +#define l3clken 4 +#define l3clkenm 0x08000000 +#define l3dx 5 +#define l3dxm 0x04000000 +#define l3clk 6 +#define l3clkf 8 +#define l3clkm 0x03800000 +#define l3io 9 +#define l3iom 0x00400000 +#define l3spo 13 +#define l3spom 0x00040000 +#define l3cksp 14 +#define l3ckspf 15 +#define l3ckspm 0x00030000 +#define l3psp 16 +#define l3pspf 18 +#define l3pspm 0x0000E000 +#define l3rep 19 +#define l3repm 0x00001000 +#define l3hwf 20 +#define l3hwfm 0x00000800 +#define l3i 21 +#define l3im 0x00000400 +#define l3rt 22 +#define l3rtf 23 +#define l3rtm 0x00000300 +#define l3dro 23 +#define l3drom 0x00000100 +#define l3cya 24 +#define l3cyam 0x00000080 +#define l3donly 25 +#define l3donlym 0x00000040 +#define l3dmem 29 +#define l3dmemm 0x00000004 +#define l3dmsiz 31 +#define l3dmsizm 0x00000001 + +#define thrmtin 0 +#define thrmtinm 0x80000000 +#define thrmtiv 1 +#define thrmtivm 0x40000000 +#define thrmthrs 2 +#define thrmthre 8 +#define thrmthrm 0x3F800000 +#define thrmtid 29 +#define thrmtidm 0x00000004 +#define thrmtie 30 +#define thrmtiem 0x00000002 +#define thrmv 31 +#define thrmvm 0x00000001 + +#define thrmsitvs 15 +#define thrmsitve 30 +#define thrmsitvm 0x0001FFFE +#define thrme 31 +#define thrmem 0x00000001 + +#define ictcfib 23 +#define ictcfie 30 +#define ictcfim 0x000001FE +#define ictce 31 +#define ictcem 0x00000001 + +#define slbESID 36 +#define slbKey 52 +#define slbIndex 52 +#define slbV 36 +#define slbVm 0x08000000 +#define slbCnt 64 + +/* + * Macros to access high and low word values of an address + */ + +#define HIGH_CADDR(x) ha16(x) +#define HIGH_ADDR(x) hi16(x) +#define LOW_ADDR(x) lo16(x) + +#endif /* ASSEMBLER */ + +#define cr0_lt 0 +#define cr0_gt 1 +#define cr0_eq 2 +#define cr0_so 3 +#define cr0_un 3 +#define cr1_lt 4 +#define cr1_gt 5 +#define cr1_eq 6 +#define cr1_so 7 +#define cr1_un 7 +#define cr2_lt 8 +#define cr2_gt 9 +#define cr2_eq 10 +#define cr2_so 11 +#define cr2_un 11 +#define cr3_lt 12 +#define cr3_gt 13 +#define cr3_eq 14 +#define cr3_so 15 +#define cr3_un 15 +#define cr4_lt 16 +#define cr4_gt 17 +#define cr4_eq 18 +#define cr4_so 19 +#define cr4_un 19 +#define cr5_lt 20 +#define cr5_gt 21 +#define cr5_eq 22 +#define cr5_so 23 +#define cr5_un 23 +#define cr6_lt 24 +#define cr6_gt 25 +#define cr6_eq 26 +#define cr6_so 27 +#define cr6_un 27 +#define cr7_lt 28 +#define cr7_gt 29 +#define cr7_eq 30 +#define cr7_so 31 +#define cr7_un 31 + +/* GUS Mode Register */ +#define GUSModeReg 0x0430 +#define GUSMdmapen 0x00008000 +#define GUSMstgtdis 0x00000080 +#define GUSMstgttim 0x00000038 +#define GUSMstgttoff 0x00000004 + +/* PowerTune */ +#define PowerTuneControlReg 0x0AA001 +#define PowerTuneStatusReg 0x408001 + +/* Code inject */ +// The following bits are always on in the MSR when injected code is executing +#define ijemon 0x00000010 +// The following bits are always off in the MSR when injected code it executing +#define ijemoff 0x0000C620 +#define ijemtrap ijemon|1 +// The following is the inject exit trap +#define ijtrap 0x0FFFC9C9 + +/* Misc */ +#define srr1clr 0x783F0000 + +/* Tags are placed before Immediately Following Code (IFC) for the debugger + * to be able to deduce where to find various registers when backtracing + * + * We only define the values as we use them, see SVR4 ABI PowerPc Supplement + * for more details (defined in ELF spec). + */ + +#define TAG_NO_FRAME_USED 0x00000000 + +/* (should use genassym to get these offsets) */ + +#define FM_BACKPTR 0 +#define FM_CR_SAVE 4 +#define FM_LR_SAVE 8 /* MacOSX is NOT following the ABI at the moment.. */ +#define FM_SIZE 64 /* minimum frame contents, backptr and LR save. Make sure it is quadaligned */ +#define FM_ARG0 56 +#define FM_ALIGN(l) ((l+15)&-16) +#define PK_SYSCALL_BEGIN 0x7000 + + +/* redzone is the area under the stack pointer which must be preserved + * when taking a trap, interrupt etc. + */ +#define FM_REDZONE 224 /* is ((32-14+1)*4) */ + +#define COPYIN_ARG0_OFFSET FM_ARG0 + +#ifdef MACH_KERNEL +#include <mach_kdb.h> +#else /* MACH_KERNEL */ +#define MACH_KDB 0 +#endif /* MACH_KERNEL */ + +#define BREAKPOINT_TRAP tw 4,r4,r4 + +/* There is another definition of ALIGN for .c sources */ +#ifndef __LANGUAGE_ASSEMBLY +#define ALIGN 4 +#endif /* __LANGUAGE_ASSEMBLY */ + +#ifndef FALIGN +#define FALIGN 4 /* Align functions on words for now. Cachelines is better */ +#endif + +#define LB(x,n) n +#if __STDC__ +#define LCL(x) L ## x +#define EXT(x) _ ## x +#define LEXT(x) _ ## x ## : +#define LBc(x,n) n ## : +#define LBb(x,n) n ## b +#define LBf(x,n) n ## f +#else /* __STDC__ */ +#define LCL(x) L/**/x +#define EXT(x) _/**/x +#define LEXT(x) _/**/x/**/: +#define LBc(x,n) n/**/: +#define LBb(x,n) n/**/b +#define LBf(x,n) n/**/f +#endif /* __STDC__ */ + +#define String .asciz +#define Value .word +#define Times(a,b) (a*b) +#define Divide(a,b) (a/b) + +#define data16 .byte 0x66 +#define addr16 .byte 0x67 + +#define MCOUNT + +#define ELF_FUNC(x) +#define ELF_DATA(x) +#define ELF_SIZE(x,s) + +#define Entry(x,tag) .text@.align FALIGN@ .globl EXT(x)@ LEXT(x) +#define ENTRY(x,tag) Entry(x,tag)@MCOUNT +#define ENTRY2(x,y,tag) .text@ .align FALIGN@ .globl EXT(x)@ .globl EXT(y)@ \ + LEXT(x)@ LEXT(y) @\ + MCOUNT +#if __STDC__ +#define ASENTRY(x) .globl x @ .align FALIGN; x ## @ MCOUNT +#else +#define ASENTRY(x) .globl x @ .align FALIGN; x @ MCOUNT +#endif /* __STDC__ */ +#define DATA(x) .globl EXT(x) @ .align ALIGN @ LEXT(x) + + +#define End(x) ELF_SIZE(x,.-x) +#define END(x) End(EXT(x)) +#define ENDDATA(x) END(x) +#define Enddata(x) End(x) + +/* These defines are here for .c files that wish to reference global symbols + * within __asm__ statements. + */ +#define CC_SYM_PREFIX "_" + +#endif /* _PPC_ASM_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/ppc/machine_types.defs =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/ppc/machine_types.defs (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/ppc/machine_types.defs (revision 885) @@ -0,0 +1,126 @@ +/* + * 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@ + */ + +/* + * Header file for basic, machine-dependent data types. + */ + +#ifndef _PPC_VM_TYPES_DEFS_ +#define _PPC_VM_TYPES_DEFS_ + +type short = int16_t; +type int = int32_t; +type unsigned = uint32_t; + +type float = MACH_MSG_TYPE_REAL_32; +type double = MACH_MSG_TYPE_REAL_64; + +/* from ISO/IEC 988:1999 spec */ +/* 7.18.1.4 Integer types capable of holding object pointers */ +/* + * The [u]intptr_t types for the native + * integer type, e.g. 32 or 64 or.. whatever + * register size the machine has. They are + * used for entities that might be either + * [unsigned] integers or pointers, and for + * type-casting between the two. + * + * For instance, the IPC system represents + * a port in user space as an integer and + * in kernel space as a pointer. + */ +#if defined(__ppc64__) +type uintptr_t = uint64_t; +type intptr_t = int64_t; +#else +type uintptr_t = uint32_t; +type intptr_t = int32_t; +#endif + +/* + * These are the legacy Mach types that are + * the [rough] equivalents of the standards above. + * They were defined in terms of int, not + * long int, so they remain separate. + */ +#if defined(__ppc64__) +type register_t = int64_t; +#else +type register_t = int32_t; +#endif +type integer_t = int32_t; +type natural_t = uint32_t; + +/* + * These are the VM types that scale with the address + * space size of a given process. + */ + +#if defined(__ppc64__) +type vm_address_t = uint64_t; +type vm_offset_t = uint64_t; +type vm_size_t = uint64_t; +#else +type vm_address_t = natural_t; +type vm_offset_t = natural_t; +type vm_size_t = natural_t; +#endif + +/* + * The mach_vm_xxx_t types are sized to hold the + * maximum pointer, offset, etc... supported on the + * platform. + */ +type mach_vm_address_t = uint64_t; +type mach_vm_offset_t = uint64_t; +type mach_vm_size_t = uint64_t; + +#if MACH_IPC_COMPAT +/* + * For the old IPC interface + */ +#define MSG_TYPE_PORT_NAME uint32_t + +#endif /* MACH_IPC_COMPAT */ + +/* + * These are types used internal to Mach to implement the + * legacy 32-bit VM APIs published by the kernel. + */ +#define VM32_SUPPORT 1 + +type vm32_address_t = uint32_t; +type vm32_offset_t = uint32_t; +type vm32_size_t = uint32_t; + +#endif /* _PPC_VM_TYPES_DEFS_ */ + +/* vim: set ft=c : */ Index: branches/azimutz/Cleancut/i386/include/mach/ppc/rpc.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/ppc/rpc.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/ppc/rpc.h (revision 885) @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2002,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@ + */ +/* + * @OSF_COPYRIGHT@ + */ + +#ifndef _MACH_PPC_RPC_H_ +#define _MACH_PPC_RPC_H_ + +#endif /* _MACH_PPC_RPC_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/ppc/sdt_isa.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/ppc/sdt_isa.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/ppc/sdt_isa.h (revision 885) @@ -0,0 +1,413 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _MACH_PPC_SDT_ISA_H +#define _MACH_PPC_SDT_ISA_H + +/* #pragma ident "@(#)sdt.h 1.7 05/06/08 SMI" */ + +/* + * Only define when testing. This makes the calls into actual calls to + * test functions. + */ +/* #define DTRACE_CALL_TEST */ + +#define DTRACE_STRINGIFY(s) #s +#define DTRACE_TOSTRING(s) DTRACE_STRINGIFY(s) + +#define DTRACE_LABEL(p, n) \ + "__dtrace_probe$" DTRACE_TOSTRING(__LINE__) DTRACE_STRINGIFY(_##p##___##n) ":" "\n\t" + +#ifdef DTRACE_CALL_TEST + +#define DTRACE_CALL(p,n) \ + DTRACE_LABEL(p,n) \ + DTRACE_CALL_INSN(p,n) + +#else /* !DTRACE_CALL_TEST */ + +#define DTRACE_CALL(p,n) \ + DTRACE_LABEL(p,n) \ + DTRACE_NOPS + +#endif /* !DTRACE_CALL_TEST */ + +#ifdef __ppc__ + +#define DTRACE_NOPS \ + "nop" "\n\t" + +#define DTRACE_CALL_INSN(p,n) \ + "bl _dtracetest" DTRACE_STRINGIFY(_##p##_##n) "\n\t" + +#define ARG1_EXTENT 1 +#define ARGS2_EXTENT 2 +#define ARGS3_EXTENT 3 +#define ARGS4_EXTENT 4 +#define ARGS5_EXTENT 5 +#define ARGS6_EXTENT 6 +#define ARGS7_EXTENT 7 +#define ARGS8_EXTENT 8 +#define ARGS9_EXTENT 9 +#define ARGS10_EXTENT 10 + +#define DTRACE_CALL0ARGS(provider, name) \ + asm volatile ( \ + DTRACE_CALL(provider, name) \ + "# eat trailing nl+tab from DTRACE_CALL" \ + : \ + : \ + ); + +#define DTRACE_CALL1ARG(provider, name) \ + asm volatile ("subi r1,r1,0x20" "\n\t" \ + "lwz r3,0x0(%0)" "\n\t" \ + DTRACE_CALL(provider, name) \ + "addi r1,r1,0x20" \ + : \ + : "b" (__dtrace_args) \ + : "memory", "r3" \ + ); + +#define DTRACE_CALL2ARGS(provider, name) \ + asm volatile ("subi r1,r1,0x20" "\n\t" \ + "lwz r3,0x0(%0)" "\n\t" \ + "lwz r4,0x4(%0)" "\n\t" \ + DTRACE_CALL(provider, name) \ + "addi r1,r1,0x20" \ + : \ + : "b" (__dtrace_args) \ + : "memory", "r3", "r4" \ + ); + +#define DTRACE_CALL3ARGS(provider, name) \ + asm volatile ("subi r1,r1,0x30" "\n\t" \ + "lwz r3,0x0(%0)" "\n\t" \ + "lwz r4,0x4(%0)" "\n\t" \ + "lwz r5,0x8(%0)" "\n\t" \ + DTRACE_CALL(provider, name) \ + "addi r1,r1,0x30" \ + : \ + : "b" (__dtrace_args) \ + : "memory", "r3", "r4", "r5" \ + ); + +#define DTRACE_CALL4ARGS(provider, name) \ + asm volatile ("subi r1,r1,0x30" "\n\t" \ + "lwz r3,0x0(%0)" "\n\t" \ + "lwz r4,0x4(%0)" "\n\t" \ + "lwz r5,0x8(%0)" "\n\t" \ + "lwz r6,0xc(%0)" "\n\t" \ + DTRACE_CALL(provider, name) \ + "addi r1,r1,0x30" \ + : \ + : "b" (__dtrace_args) \ + : "memory", "r3", "r4", "r5", "r6" \ + ); + +#define DTRACE_CALL5ARGS(provider, name) \ + asm volatile ("subi r1,r1,0x30" "\n\t" \ + "lwz r3,0x0(%0)" "\n\t" \ + "lwz r4,0x4(%0)" "\n\t" \ + "lwz r5,0x8(%0)" "\n\t" \ + "lwz r6,0xc(%0)" "\n\t" \ + "lwz r7,0x10(%0)" "\n\t" \ + DTRACE_CALL(provider, name) \ + "addi r1,r1,0x30" \ + : \ + : "b" (__dtrace_args) \ + : "memory", "r3", "r4", "r5", "r6", "r7" \ + ); + +#define DTRACE_CALL6ARGS(provider, name) \ + asm volatile ("subi r1,r1,0x30" "\n\t" \ + "lwz r3,0x0(%0)" "\n\t" \ + "lwz r4,0x4(%0)" "\n\t" \ + "lwz r5,0x8(%0)" "\n\t" \ + "lwz r6,0xc(%0)" "\n\t" \ + "lwz r7,0x10(%0)" "\n\t" \ + "lwz r8,0x14(%0)" "\n\t" \ + DTRACE_CALL(provider, name) \ + "addi r1,r1,0x30" \ + : \ + : "b" (__dtrace_args) \ + : "memory", "r3", "r4", "r5", "r6", "r7", "r8" \ + ); + +#define DTRACE_CALL7ARGS(provider, name) \ + asm volatile ("subi r1,r1,0x40" "\n\t" \ + "lwz r3,0x0(%0)" "\n\t" \ + "lwz r4,0x4(%0)" "\n\t" \ + "lwz r5,0x8(%0)" "\n\t" \ + "lwz r6,0xc(%0)" "\n\t" \ + "lwz r7,0x10(%0)" "\n\t" \ + "lwz r8,0x14(%0)" "\n\t" \ + "lwz r9,0x18(%0)" "\n\t" \ + DTRACE_CALL(provider, name) \ + "addi r1,r1,0x40" \ + : \ + : "b" (__dtrace_args) \ + : "memory", "r3", "r4", "r5", "r6", "r7", "r8", "r9" \ + ); + +#define DTRACE_CALL8ARGS(provider, name) \ + asm volatile ("subi r1,r1,0x40" "\n\t" \ + "lwz r3,0x0(%0)" "\n\t" \ + "lwz r4,0x4(%0)" "\n\t" \ + "lwz r5,0x8(%0)" "\n\t" \ + "lwz r6,0xc(%0)" "\n\t" \ + "lwz r7,0x10(%0)" "\n\t" \ + "lwz r8,0x14(%0)" "\n\t" \ + "lwz r9,0x18(%0)" "\n\t" \ + "lwz r10,0x1c(%0)" "\n\t" \ + DTRACE_CALL(provider, name) \ + "addi r1,r1,0x40" \ + : \ + : "b" (__dtrace_args) \ + : "memory", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10" \ + ); + +#define DTRACE_CALL9ARGS(provider, name) \ + asm volatile ("subi r1,r1,0x40" "\n\t" \ + "lwz r3,0x0(%0)" "\n\t" \ + "lwz r4,0x4(%0)" "\n\t" \ + "lwz r5,0x8(%0)" "\n\t" \ + "lwz r6,0xc(%0)" "\n\t" \ + "lwz r7,0x10(%0)" "\n\t" \ + "lwz r8,0x14(%0)" "\n\t" \ + "lwz r9,0x18(%0)" "\n\t" \ + "lwz r10,0x1c(%0)" "\n\t" \ + "lwz r11,0x20(%0)" "\n\t" \ + "stw r11,0x38(r1)" "\n\t" \ + DTRACE_CALL(provider, name) \ + "addi r1,r1,0x40" \ + : \ + : "b" (__dtrace_args) \ + : "memory", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11" \ + ); + +#define DTRACE_CALL10ARGS(provider, name) \ + asm volatile ("subi r1,r1,0x40" "\n\t" \ + "lwz r3,0x0(%0)" "\n\t" \ + "lwz r4,0x4(%0)" "\n\t" \ + "lwz r5,0x8(%0)" "\n\t" \ + "lwz r6,0xc(%0)" "\n\t" \ + "lwz r7,0x10(%0)" "\n\t" \ + "lwz r8,0x14(%0)" "\n\t" \ + "lwz r9,0x18(%0)" "\n\t" \ + "lwz r10,0x1c(%0)" "\n\t" \ + "lwz r11,0x20(%0)" "\n\t" \ + "lwz r12,0x24(%0)" "\n\t" \ + "stw r11,0x38(r1)" "\n\t" \ + "stw r12,0x3c(r1)" "\n\t" \ + DTRACE_CALL(provider, name) \ + "addi r1,r1,0x40" \ + : \ + : "b" (__dtrace_args) \ + : "memory", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12" \ + ); + +#endif // __ppc__ + +#ifdef __ppc64__ + +#define DTRACE_NOPS \ + "nop" "\n\t" + +#define DTRACE_CALL_INSN(p,n) \ + "bl _dtracetest" DTRACE_STRINGIFY(_##p##_##n) "\n\t" + +#define ARG1_EXTENT 1 +#define ARGS2_EXTENT 2 +#define ARGS3_EXTENT 3 +#define ARGS4_EXTENT 4 +#define ARGS5_EXTENT 5 +#define ARGS6_EXTENT 6 +#define ARGS7_EXTENT 7 +#define ARGS8_EXTENT 8 +#define ARGS9_EXTENT 9 +#define ARGS10_EXTENT 10 + +#define DTRACE_CALL0ARGS(provider, name) \ + asm volatile ("subi r1,r1,0x30" "\n\t" \ + DTRACE_CALL(provider, name) \ + "addi r1,r1,0x30" \ + : \ + : \ + : \ + ); + +#define DTRACE_CALL1ARG(provider, name) \ + asm volatile ("ld r3,0x0(%0)" "\n\t" \ + "subi r1,r1,0x38" "\n\t" \ + DTRACE_CALL(provider, name) \ + "addi r1,r1,0x38" \ + : \ + : "b" (__dtrace_args) \ + : "memory", "r3" \ + ); + +#define DTRACE_CALL2ARGS(provider, name) \ + asm volatile ("subi r1,r1,0x40" "\n\t" \ + "ld r3,0x0(%0)" "\n\t" \ + "ld r4,0x8(%0)" "\n\t" \ + DTRACE_CALL(provider, name) \ + "addi r1,r1,0x40" \ + : \ + : "b" (__dtrace_args) \ + : "memory", "r3", "r4" \ + ); + +#define DTRACE_CALL3ARGS(provider, name) \ + asm volatile ("subi r1,r1,0x48" "\n\t" \ + "ld r3,0x0(%0)" "\n\t" \ + "ld r4,0x8(%0)" "\n\t" \ + "ld r5,0x10(%0)" "\n\t" \ + DTRACE_CALL(provider, name) \ + "addi r1,r1,0x48" \ + : \ + : "b" (__dtrace_args) \ + : "memory", "r3", "r4", "r5" \ + ); + +#define DTRACE_CALL4ARGS(provider, name) \ + asm volatile ("subi r1,r1,0x50" "\n\t" \ + "ld r3,0x0(%0)" "\n\t" \ + "ld r4,0x8(%0)" "\n\t" \ + "ld r5,0x10(%0)" "\n\t" \ + "ld r6,0x18(%0)" "\n\t" \ + DTRACE_CALL(provider, name) \ + "addi r1,r1,0x50" \ + : \ + : "b" (__dtrace_args) \ + : "memory", "r3", "r4", "r5", "r6" \ + ); + +#define DTRACE_CALL5ARGS(provider, name) \ + asm volatile ("subi r1,r1,0x58" "\n\t" \ + "ld r3,0x0(%0)" "\n\t" \ + "ld r4,0x8(%0)" "\n\t" \ + "ld r5,0x10(%0)" "\n\t" \ + "ld r6,0x18(%0)" "\n\t" \ + "ld r7,0x20(%0)" "\n\t" \ + DTRACE_CALL(provider, name) \ + "addi r1,r1,0x58" \ + : \ + : "b" (__dtrace_args) \ + : "memory", "r3", "r4", "r5", "r6", "r7" \ + ); + +#define DTRACE_CALL6ARGS(provider, name) \ + asm volatile ("subi r1,r1,0x60" "\n\t" \ + "ld r3,0x0(%0)" "\n\t" \ + "ld r4,0x8(%0)" "\n\t" \ + "ld r5,0x10(%0)" "\n\t" \ + "ld r6,0x18(%0)" "\n\t" \ + "ld r7,0x20(%0)" "\n\t" \ + "ld r8,0x28(%0)" "\n\t" \ + DTRACE_CALL(provider, name) \ + "addi r1,r1,0x60" \ + : \ + : "b" (__dtrace_args) \ + : "memory", "r3", "r4", "r5", "r6", "r7", "r8" \ + ); + +#define DTRACE_CALL7ARGS(provider, name) \ + asm volatile ("subi r1,r1,0x68" "\n\t" \ + "ld r3,0x0(%0)" "\n\t" \ + "ld r4,0x8(%0)" "\n\t" \ + "ld r5,0x10(%0)" "\n\t" \ + "ld r6,0x18(%0)" "\n\t" \ + "ld r7,0x20(%0)" "\n\t" \ + "ld r8,0x28(%0)" "\n\t" \ + "ld r9,0x30(%0)" "\n\t" \ + DTRACE_CALL(provider, name) \ + "addi r1,r1,0x68" \ + : \ + : "b" (__dtrace_args) \ + : "memory", "r3", "r4", "r5", "r6", "r7", "r8", "r9" \ + ); + +#define DTRACE_CALL8ARGS(provider, name) \ + asm volatile ("subi r1,r1,0x70" "\n\t" \ + "ld r3,0x0(%0)" "\n\t" \ + "ld r4,0x8(%0)" "\n\t" \ + "ld r5,0x10(%0)" "\n\t" \ + "ld r6,0x18(%0)" "\n\t" \ + "ld r7,0x20(%0)" "\n\t" \ + "ld r8,0x28(%0)" "\n\t" \ + "ld r9,0x30(%0)" "\n\t" \ + "ld r10,0x38(%0)" "\n\t" \ + DTRACE_CALL(provider, name) \ + "addi r1,r1,0x70" \ + : \ + : "b" (__dtrace_args) \ + : "memory", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10" \ + ); + +#define DTRACE_CALL9ARGS(provider, name) \ + asm volatile ("subi r1,r1,0x78" "\n\t" \ + "ld r3,0x0(%0)" "\n\t" \ + "ld r4,0x8(%0)" "\n\t" \ + "ld r5,0x10(%0)" "\n\t" \ + "ld r6,0x18(%0)" "\n\t" \ + "ld r7,0x20(%0)" "\n\t" \ + "ld r8,0x28(%0)" "\n\t" \ + "ld r9,0x30(%0)" "\n\t" \ + "ld r10,0x38(%0)" "\n\t" \ + "ld r11,0x40(%0)" "\n\t" \ + "std r11,0x70(r1)" "\n\t" \ + DTRACE_CALL(provider, name) \ + "addi r1,r1,0x78" \ + : \ + : "b" (__dtrace_args) \ + : "memory", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11" \ + ); + +#define DTRACE_CALL10ARGS(provider, name) \ + asm volatile ("subi r1,r1,0x80" "\n\t" \ + "ld r3,0x0(%0)" "\n\t" \ + "ld r4,0x8(%0)" "\n\t" \ + "ld r5,0x10(%0)" "\n\t" \ + "ld r6,0x18(%0)" "\n\t" \ + "ld r7,0x20(%0)" "\n\t" \ + "ld r8,0x28(%0)" "\n\t" \ + "ld r9,0x30(%0)" "\n\t" \ + "ld r10,0x38(%0)" "\n\t" \ + "ld r11,0x40(%0)" "\n\t" \ + "ld r12,0x48(%0)" "\n\t" \ + "std r11,0x70(r1)" "\n\t" \ + "std r12,0x78(r1)" "\n\t" \ + DTRACE_CALL(provider, name) \ + "addi r1,r1,0x80" \ + : \ + : "b" (__dtrace_args) \ + : "memory", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12" \ + ); + +#endif // __ppc64__ + +#endif /* _MACH_PPC_SDT_ISA_H */ Index: branches/azimutz/Cleancut/i386/include/mach/lock_set.defs =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/lock_set.defs (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/lock_set.defs (revision 885) @@ -0,0 +1,79 @@ +/* + * Copyright (c) 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@ + */ +/* + * @OSF_COPYRIGHT@ + * + */ +/* + * File: mach/lock_set.defs + * Author: Joseph CaraDonna + * + * Exported kernel calls + * + */ + +subsystem +#if KERNEL_SERVER + KernelServer +#endif /* KERNEL_SERVER */ + lock_set 617000; + +#include <mach/std_types.defs> +#include <mach/mach_types.defs> + +/* + * a lock_set_t is created and destroyed through the task object. + * lock_set_create(task,&lock_set_t,...); + * lock_set_destroy(task,lock_set_t); + */ + +routine lock_acquire( + lock_set : lock_set_t; + lock_id : int); + +routine lock_release( + lock_set : lock_set_t; + lock_id : int); + +routine lock_try( + lock_set : lock_set_t; + lock_id : int); + +routine lock_make_stable( + lock_set : lock_set_t; + lock_id : int); + +routine lock_handoff( + lock_set : lock_set_t; + lock_id : int); + +routine lock_handoff_accept( + lock_set : lock_set_t; + lock_id : int); + +/* vim: set ft=c : */ Index: branches/azimutz/Cleancut/i386/include/mach/vm_param.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/vm_param.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/vm_param.h (revision 885) @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2000-2006 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,1988,1987 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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + */ +/* + * File: mach/vm_param.h + * Author: Avadis Tevanian, Jr., Michael Wayne Young + * Date: 1985 + * + * Machine independent virtual memory parameters. + * + */ + +#ifndef _MACH_VM_PARAM_H_ +#define _MACH_VM_PARAM_H_ + +#include <mach/machine/vm_param.h> + + +#endif /* _MACH_VM_PARAM_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/notify.defs =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/notify.defs (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/notify.defs (revision 885) @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2000-2003 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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + */ + +subsystem +#if KERNEL_USER + KernelUser +#endif + notify 64; + +#include <mach/std_types.defs> + +#if SEQNOS +serverprefix do_seqnos_; +serverdemux seqnos_notify_server; +#else /* !SEQNOS */ +serverprefix do_; +serverdemux notify_server; +#endif /* SEQNOS */ + +/* MACH_NOTIFY_FIRST: 0100 */ +skip; + +/* MACH_NOTIFY_PORT_DELETED: 0101 */ +simpleroutine mach_notify_port_deleted( + notify : mach_port_move_send_once_t; +#if SEQNOS + msgseqno seqno : mach_port_seqno_t; +#endif /* SEQNOS */ + name : mach_port_name_t); + +skip; /* was MACH_NOTIFY_MSG_ACCEPTED: 0102 */ + +skip; /* was NOTIFY_OWNERSHIP_RIGHTS: 0103 */ + +skip; /* was NOTIFY_RECEIVE_RIGHTS: 0104 */ + +/* MACH_NOTIFY_PORT_DESTROYED: 0105 */ +simpleroutine mach_notify_port_destroyed( + notify : mach_port_move_send_once_t; +#if SEQNOS + msgseqno seqno : mach_port_seqno_t; +#endif /* SEQNOS */ + rights : mach_port_move_receive_t); + +/* MACH_NOTIFY_NO_SENDERS: 0106 */ +simpleroutine mach_notify_no_senders( + notify : mach_port_move_send_once_t; +#if SEQNOS + msgseqno seqno : mach_port_seqno_t; +#endif /* SEQNOS */ + mscount : mach_port_mscount_t); + +/* MACH_NOTIFY_SEND_ONCE: 0107 */ +simpleroutine mach_notify_send_once( + notify : mach_port_move_send_once_t +#if SEQNOS +; msgseqno seqno : mach_port_seqno_t +#endif /* SEQNOS */ + ); + +/* MACH_NOTIFY_DEAD_NAME: 0110 */ +simpleroutine mach_notify_dead_name( + notify : mach_port_move_send_once_t; +#if SEQNOS + msgseqno seqno : mach_port_seqno_t; +#endif /* SEQNOS */ + name : mach_port_name_t); + +/* vim: set ft=c : */ Index: branches/azimutz/Cleancut/i386/include/mach/lock_set.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/lock_set.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/lock_set.h (revision 885) @@ -0,0 +1,326 @@ +#ifndef _lock_set_user_ +#define _lock_set_user_ + +/* Module lock_set */ + +#include <string.h> +#include <mach/ndr.h> +#include <mach/boolean.h> +#include <mach/kern_return.h> +#include <mach/notify.h> +#include <mach/mach_types.h> +#include <mach/message.h> +#include <mach/mig_errors.h> +#include <mach/port.h> + +#ifdef AUTOTEST +#ifndef FUNCTION_PTR_T +#define FUNCTION_PTR_T +typedef void (*function_ptr_t)(mach_port_t, char *, mach_msg_type_number_t); +typedef struct { + char *name; + function_ptr_t function; +} function_table_entry; +typedef function_table_entry *function_table_t; +#endif /* FUNCTION_PTR_T */ +#endif /* AUTOTEST */ + +#ifndef lock_set_MSG_COUNT +#define lock_set_MSG_COUNT 6 +#endif /* lock_set_MSG_COUNT */ + +#include <mach/std_types.h> +#include <mach/mig.h> +#include <mach/mach_types.h> + +#ifdef __BeforeMigUserHeader +__BeforeMigUserHeader +#endif /* __BeforeMigUserHeader */ + +#include <sys/cdefs.h> +__BEGIN_DECLS + + +/* Routine lock_acquire */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t lock_acquire +( + lock_set_t lock_set, + int lock_id +); + +/* Routine lock_release */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t lock_release +( + lock_set_t lock_set, + int lock_id +); + +/* Routine lock_try */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t lock_try +( + lock_set_t lock_set, + int lock_id +); + +/* Routine lock_make_stable */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t lock_make_stable +( + lock_set_t lock_set, + int lock_id +); + +/* Routine lock_handoff */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t lock_handoff +( + lock_set_t lock_set, + int lock_id +); + +/* Routine lock_handoff_accept */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t lock_handoff_accept +( + lock_set_t lock_set, + int lock_id +); + +__END_DECLS + +/********************** Caution **************************/ +/* The following data types should be used to calculate */ +/* maximum message sizes only. The actual message may be */ +/* smaller, and the position of the arguments within the */ +/* message layout may vary from what is presented here. */ +/* For example, if any of the arguments are variable- */ +/* sized, and less than the maximum is sent, the data */ +/* will be packed tight in the actual message to reduce */ +/* the presence of holes. */ +/********************** Caution **************************/ + +/* typedefs for all requests */ + +#ifndef __Request__lock_set_subsystem__defined +#define __Request__lock_set_subsystem__defined + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + int lock_id; + } __Request__lock_acquire_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + int lock_id; + } __Request__lock_release_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + int lock_id; + } __Request__lock_try_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + int lock_id; + } __Request__lock_make_stable_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + int lock_id; + } __Request__lock_handoff_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + int lock_id; + } __Request__lock_handoff_accept_t; +#ifdef __MigPackStructs +#pragma pack() +#endif +#endif /* !__Request__lock_set_subsystem__defined */ + +/* union of all requests */ + +#ifndef __RequestUnion__lock_set_subsystem__defined +#define __RequestUnion__lock_set_subsystem__defined +union __RequestUnion__lock_set_subsystem { + __Request__lock_acquire_t Request_lock_acquire; + __Request__lock_release_t Request_lock_release; + __Request__lock_try_t Request_lock_try; + __Request__lock_make_stable_t Request_lock_make_stable; + __Request__lock_handoff_t Request_lock_handoff; + __Request__lock_handoff_accept_t Request_lock_handoff_accept; +}; +#endif /* !__RequestUnion__lock_set_subsystem__defined */ +/* typedefs for all replies */ + +#ifndef __Reply__lock_set_subsystem__defined +#define __Reply__lock_set_subsystem__defined + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__lock_acquire_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__lock_release_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__lock_try_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__lock_make_stable_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__lock_handoff_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__lock_handoff_accept_t; +#ifdef __MigPackStructs +#pragma pack() +#endif +#endif /* !__Reply__lock_set_subsystem__defined */ + +/* union of all replies */ + +#ifndef __ReplyUnion__lock_set_subsystem__defined +#define __ReplyUnion__lock_set_subsystem__defined +union __ReplyUnion__lock_set_subsystem { + __Reply__lock_acquire_t Reply_lock_acquire; + __Reply__lock_release_t Reply_lock_release; + __Reply__lock_try_t Reply_lock_try; + __Reply__lock_make_stable_t Reply_lock_make_stable; + __Reply__lock_handoff_t Reply_lock_handoff; + __Reply__lock_handoff_accept_t Reply_lock_handoff_accept; +}; +#endif /* !__RequestUnion__lock_set_subsystem__defined */ + +#ifndef subsystem_to_name_map_lock_set +#define subsystem_to_name_map_lock_set \ + { "lock_acquire", 617000 },\ + { "lock_release", 617001 },\ + { "lock_try", 617002 },\ + { "lock_make_stable", 617003 },\ + { "lock_handoff", 617004 },\ + { "lock_handoff_accept", 617005 } +#endif + +#ifdef __AfterMigUserHeader +__AfterMigUserHeader +#endif /* __AfterMigUserHeader */ + +#endif /* _lock_set_user_ */ Index: branches/azimutz/Cleancut/i386/include/mach/vm_task.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/vm_task.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/vm_task.h (revision 885) @@ -0,0 +1,34 @@ +/* + * Copyright (c) 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@ + */ +/* +** This file contains compatibilty wrapper header for things that are +** generated from mach/vm_map.defs into mach/vm_map.h. +** +** This file will go away eventually - please switch. +*/ +#include <mach/vm_map.h> Index: branches/azimutz/Cleancut/i386/include/mach/host_security.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/host_security.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/host_security.h (revision 885) @@ -0,0 +1,197 @@ +#ifndef _host_security_user_ +#define _host_security_user_ + +/* Module host_security */ + +#include <string.h> +#include <mach/ndr.h> +#include <mach/boolean.h> +#include <mach/kern_return.h> +#include <mach/notify.h> +#include <mach/mach_types.h> +#include <mach/message.h> +#include <mach/mig_errors.h> +#include <mach/port.h> + +#ifdef AUTOTEST +#ifndef FUNCTION_PTR_T +#define FUNCTION_PTR_T +typedef void (*function_ptr_t)(mach_port_t, char *, mach_msg_type_number_t); +typedef struct { + char *name; + function_ptr_t function; +} function_table_entry; +typedef function_table_entry *function_table_t; +#endif /* FUNCTION_PTR_T */ +#endif /* AUTOTEST */ + +#ifndef host_security_MSG_COUNT +#define host_security_MSG_COUNT 2 +#endif /* host_security_MSG_COUNT */ + +#include <mach/std_types.h> +#include <mach/mig.h> +#include <mach/mach_types.h> + +#ifdef __BeforeMigUserHeader +__BeforeMigUserHeader +#endif /* __BeforeMigUserHeader */ + +#include <sys/cdefs.h> +__BEGIN_DECLS + + +/* Routine host_security_create_task_token */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t host_security_create_task_token +( + host_security_t host_security, + task_t parent_task, + security_token_t sec_token, + audit_token_t audit_token, + host_t host, + ledger_array_t ledgers, + mach_msg_type_number_t ledgersCnt, + boolean_t inherit_memory, + task_t *child_task +); + +/* Routine host_security_set_task_token */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t host_security_set_task_token +( + host_security_t host_security, + task_t target_task, + security_token_t sec_token, + audit_token_t audit_token, + host_t host +); + +__END_DECLS + +/********************** Caution **************************/ +/* The following data types should be used to calculate */ +/* maximum message sizes only. The actual message may be */ +/* smaller, and the position of the arguments within the */ +/* message layout may vary from what is presented here. */ +/* For example, if any of the arguments are variable- */ +/* sized, and less than the maximum is sent, the data */ +/* will be packed tight in the actual message to reduce */ +/* the presence of holes. */ +/********************** Caution **************************/ + +/* typedefs for all requests */ + +#ifndef __Request__host_security_subsystem__defined +#define __Request__host_security_subsystem__defined + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t parent_task; + mach_msg_port_descriptor_t host; + mach_msg_ool_ports_descriptor_t ledgers; + /* end of the kernel processed data */ + NDR_record_t NDR; + security_token_t sec_token; + audit_token_t audit_token; + mach_msg_type_number_t ledgersCnt; + boolean_t inherit_memory; + } __Request__host_security_create_task_token_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t target_task; + mach_msg_port_descriptor_t host; + /* end of the kernel processed data */ + NDR_record_t NDR; + security_token_t sec_token; + audit_token_t audit_token; + } __Request__host_security_set_task_token_t; +#ifdef __MigPackStructs +#pragma pack() +#endif +#endif /* !__Request__host_security_subsystem__defined */ + +/* union of all requests */ + +#ifndef __RequestUnion__host_security_subsystem__defined +#define __RequestUnion__host_security_subsystem__defined +union __RequestUnion__host_security_subsystem { + __Request__host_security_create_task_token_t Request_host_security_create_task_token; + __Request__host_security_set_task_token_t Request_host_security_set_task_token; +}; +#endif /* !__RequestUnion__host_security_subsystem__defined */ +/* typedefs for all replies */ + +#ifndef __Reply__host_security_subsystem__defined +#define __Reply__host_security_subsystem__defined + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t child_task; + /* end of the kernel processed data */ + } __Reply__host_security_create_task_token_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__host_security_set_task_token_t; +#ifdef __MigPackStructs +#pragma pack() +#endif +#endif /* !__Reply__host_security_subsystem__defined */ + +/* union of all replies */ + +#ifndef __ReplyUnion__host_security_subsystem__defined +#define __ReplyUnion__host_security_subsystem__defined +union __ReplyUnion__host_security_subsystem { + __Reply__host_security_create_task_token_t Reply_host_security_create_task_token; + __Reply__host_security_set_task_token_t Reply_host_security_set_task_token; +}; +#endif /* !__RequestUnion__host_security_subsystem__defined */ + +#ifndef subsystem_to_name_map_host_security +#define subsystem_to_name_map_host_security \ + { "host_security_create_task_token", 600 },\ + { "host_security_set_task_token", 601 } +#endif + +#ifdef __AfterMigUserHeader +__AfterMigUserHeader +#endif /* __AfterMigUserHeader */ + +#endif /* _host_security_user_ */ Index: branches/azimutz/Cleancut/i386/include/mach/machine.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/machine.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/machine.h (revision 885) @@ -0,0 +1,344 @@ +/* + * Copyright (c) 2000-2007 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@ + */ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989,1988,1987 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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* File: machine.h + * Author: Avadis Tevanian, Jr. + * Date: 1986 + * + * Machine independent machine abstraction. + */ + +#ifndef _MACH_MACHINE_H_ +#define _MACH_MACHINE_H_ + +#include <stdint.h> +#include <mach/machine/vm_types.h> +#include <mach/boolean.h> + +typedef integer_t cpu_type_t; +typedef integer_t cpu_subtype_t; +typedef integer_t cpu_threadtype_t; + +#define CPU_STATE_MAX 4 + +#define CPU_STATE_USER 0 +#define CPU_STATE_SYSTEM 1 +#define CPU_STATE_IDLE 2 +#define CPU_STATE_NICE 3 + + + +/* + * Capability bits used in the definition of cpu_type. + */ +#define CPU_ARCH_MASK 0xff000000 /* mask for architecture bits */ +#define CPU_ARCH_ABI64 0x01000000 /* 64 bit ABI */ + +/* + * Machine types known by all. + */ + +#define CPU_TYPE_ANY ((cpu_type_t) -1) + +#define CPU_TYPE_VAX ((cpu_type_t) 1) +/* skip ((cpu_type_t) 2) */ +/* skip ((cpu_type_t) 3) */ +/* skip ((cpu_type_t) 4) */ +/* skip ((cpu_type_t) 5) */ +#define CPU_TYPE_MC680x0 ((cpu_type_t) 6) +#define CPU_TYPE_X86 ((cpu_type_t) 7) +#define CPU_TYPE_I386 CPU_TYPE_X86 /* compatibility */ +#define CPU_TYPE_X86_64 (CPU_TYPE_X86 | CPU_ARCH_ABI64) + +/* skip CPU_TYPE_MIPS ((cpu_type_t) 8) */ +/* skip ((cpu_type_t) 9) */ +#define CPU_TYPE_MC98000 ((cpu_type_t) 10) +#define CPU_TYPE_HPPA ((cpu_type_t) 11) +#define CPU_TYPE_ARM ((cpu_type_t) 12) +#define CPU_TYPE_MC88000 ((cpu_type_t) 13) +#define CPU_TYPE_SPARC ((cpu_type_t) 14) +#define CPU_TYPE_I860 ((cpu_type_t) 15) +/* skip CPU_TYPE_ALPHA ((cpu_type_t) 16) */ +/* skip ((cpu_type_t) 17) */ +#define CPU_TYPE_POWERPC ((cpu_type_t) 18) +#define CPU_TYPE_POWERPC64 (CPU_TYPE_POWERPC | CPU_ARCH_ABI64) + +/* + * Machine subtypes (these are defined here, instead of in a machine + * dependent directory, so that any program can get all definitions + * regardless of where is it compiled). + */ + +/* + * Capability bits used in the definition of cpu_subtype. + */ +#define CPU_SUBTYPE_MASK 0xff000000 /* mask for feature flags */ +#define CPU_SUBTYPE_LIB64 0x80000000 /* 64 bit libraries */ + + +/* + * Object files that are hand-crafted to run on any + * implementation of an architecture are tagged with + * CPU_SUBTYPE_MULTIPLE. This functions essentially the same as + * the "ALL" subtype of an architecture except that it allows us + * to easily find object files that may need to be modified + * whenever a new implementation of an architecture comes out. + * + * It is the responsibility of the implementor to make sure the + * software handles unsupported implementations elegantly. + */ +#define CPU_SUBTYPE_MULTIPLE ((cpu_subtype_t) -1) +#define CPU_SUBTYPE_LITTLE_ENDIAN ((cpu_subtype_t) 0) +#define CPU_SUBTYPE_BIG_ENDIAN ((cpu_subtype_t) 1) + +/* + * Machine threadtypes. + * This is none - not defined - for most machine types/subtypes. + */ +#define CPU_THREADTYPE_NONE ((cpu_threadtype_t) 0) + +/* + * VAX subtypes (these do *not* necessary conform to the actual cpu + * ID assigned by DEC available via the SID register). + */ + +#define CPU_SUBTYPE_VAX_ALL ((cpu_subtype_t) 0) +#define CPU_SUBTYPE_VAX780 ((cpu_subtype_t) 1) +#define CPU_SUBTYPE_VAX785 ((cpu_subtype_t) 2) +#define CPU_SUBTYPE_VAX750 ((cpu_subtype_t) 3) +#define CPU_SUBTYPE_VAX730 ((cpu_subtype_t) 4) +#define CPU_SUBTYPE_UVAXI ((cpu_subtype_t) 5) +#define CPU_SUBTYPE_UVAXII ((cpu_subtype_t) 6) +#define CPU_SUBTYPE_VAX8200 ((cpu_subtype_t) 7) +#define CPU_SUBTYPE_VAX8500 ((cpu_subtype_t) 8) +#define CPU_SUBTYPE_VAX8600 ((cpu_subtype_t) 9) +#define CPU_SUBTYPE_VAX8650 ((cpu_subtype_t) 10) +#define CPU_SUBTYPE_VAX8800 ((cpu_subtype_t) 11) +#define CPU_SUBTYPE_UVAXIII ((cpu_subtype_t) 12) + +/* + * 680x0 subtypes + * + * The subtype definitions here are unusual for historical reasons. + * NeXT used to consider 68030 code as generic 68000 code. For + * backwards compatability: + * + * CPU_SUBTYPE_MC68030 symbol has been preserved for source code + * compatability. + * + * CPU_SUBTYPE_MC680x0_ALL has been defined to be the same + * subtype as CPU_SUBTYPE_MC68030 for binary comatability. + * + * CPU_SUBTYPE_MC68030_ONLY has been added to allow new object + * files to be tagged as containing 68030-specific instructions. + */ + +#define CPU_SUBTYPE_MC680x0_ALL ((cpu_subtype_t) 1) +#define CPU_SUBTYPE_MC68030 ((cpu_subtype_t) 1) /* compat */ +#define CPU_SUBTYPE_MC68040 ((cpu_subtype_t) 2) +#define CPU_SUBTYPE_MC68030_ONLY ((cpu_subtype_t) 3) + +/* + * I386 subtypes + */ + +#define CPU_SUBTYPE_INTEL(f, m) ((cpu_subtype_t) (f) + ((m) << 4)) + +#define CPU_SUBTYPE_I386_ALL CPU_SUBTYPE_INTEL(3, 0) +#define CPU_SUBTYPE_386 CPU_SUBTYPE_INTEL(3, 0) +#define CPU_SUBTYPE_486 CPU_SUBTYPE_INTEL(4, 0) +#define CPU_SUBTYPE_486SX CPU_SUBTYPE_INTEL(4, 8) // 8 << 4 = 128 +#define CPU_SUBTYPE_586 CPU_SUBTYPE_INTEL(5, 0) +#define CPU_SUBTYPE_PENT CPU_SUBTYPE_INTEL(5, 0) +#define CPU_SUBTYPE_PENTPRO CPU_SUBTYPE_INTEL(6, 1) +#define CPU_SUBTYPE_PENTII_M3 CPU_SUBTYPE_INTEL(6, 3) +#define CPU_SUBTYPE_PENTII_M5 CPU_SUBTYPE_INTEL(6, 5) +#define CPU_SUBTYPE_CELERON CPU_SUBTYPE_INTEL(7, 6) +#define CPU_SUBTYPE_CELERON_MOBILE CPU_SUBTYPE_INTEL(7, 7) +#define CPU_SUBTYPE_PENTIUM_3 CPU_SUBTYPE_INTEL(8, 0) +#define CPU_SUBTYPE_PENTIUM_3_M CPU_SUBTYPE_INTEL(8, 1) +#define CPU_SUBTYPE_PENTIUM_3_XEON CPU_SUBTYPE_INTEL(8, 2) +#define CPU_SUBTYPE_PENTIUM_M CPU_SUBTYPE_INTEL(9, 0) +#define CPU_SUBTYPE_PENTIUM_4 CPU_SUBTYPE_INTEL(10, 0) +#define CPU_SUBTYPE_PENTIUM_4_M CPU_SUBTYPE_INTEL(10, 1) +#define CPU_SUBTYPE_ITANIUM CPU_SUBTYPE_INTEL(11, 0) +#define CPU_SUBTYPE_ITANIUM_2 CPU_SUBTYPE_INTEL(11, 1) +#define CPU_SUBTYPE_XEON CPU_SUBTYPE_INTEL(12, 0) +#define CPU_SUBTYPE_XEON_MP CPU_SUBTYPE_INTEL(12, 1) + +#define CPU_SUBTYPE_INTEL_FAMILY(x) ((x) & 15) +#define CPU_SUBTYPE_INTEL_FAMILY_MAX 15 + +#define CPU_SUBTYPE_INTEL_MODEL(x) ((x) >> 4) +#define CPU_SUBTYPE_INTEL_MODEL_ALL 0 + +/* + * X86 subtypes. + */ + +#define CPU_SUBTYPE_X86_ALL ((cpu_subtype_t)3) +#define CPU_SUBTYPE_X86_64_ALL ((cpu_subtype_t)3) +#define CPU_SUBTYPE_X86_ARCH1 ((cpu_subtype_t)4) + + +#define CPU_THREADTYPE_INTEL_HTT ((cpu_threadtype_t) 1) + +/* + * Mips subtypes. + */ + +#define CPU_SUBTYPE_MIPS_ALL ((cpu_subtype_t) 0) +#define CPU_SUBTYPE_MIPS_R2300 ((cpu_subtype_t) 1) +#define CPU_SUBTYPE_MIPS_R2600 ((cpu_subtype_t) 2) +#define CPU_SUBTYPE_MIPS_R2800 ((cpu_subtype_t) 3) +#define CPU_SUBTYPE_MIPS_R2000a ((cpu_subtype_t) 4) /* pmax */ +#define CPU_SUBTYPE_MIPS_R2000 ((cpu_subtype_t) 5) +#define CPU_SUBTYPE_MIPS_R3000a ((cpu_subtype_t) 6) /* 3max */ +#define CPU_SUBTYPE_MIPS_R3000 ((cpu_subtype_t) 7) + +/* + * MC98000 (PowerPC) subtypes + */ +#define CPU_SUBTYPE_MC98000_ALL ((cpu_subtype_t) 0) +#define CPU_SUBTYPE_MC98601 ((cpu_subtype_t) 1) + +/* + * HPPA subtypes for Hewlett-Packard HP-PA family of + * risc processors. Port by NeXT to 700 series. + */ + +#define CPU_SUBTYPE_HPPA_ALL ((cpu_subtype_t) 0) +#define CPU_SUBTYPE_HPPA_7100 ((cpu_subtype_t) 0) /* compat */ +#define CPU_SUBTYPE_HPPA_7100LC ((cpu_subtype_t) 1) + +/* + * MC88000 subtypes. + */ +#define CPU_SUBTYPE_MC88000_ALL ((cpu_subtype_t) 0) +#define CPU_SUBTYPE_MC88100 ((cpu_subtype_t) 1) +#define CPU_SUBTYPE_MC88110 ((cpu_subtype_t) 2) + +/* + * SPARC subtypes + */ +#define CPU_SUBTYPE_SPARC_ALL ((cpu_subtype_t) 0) + +/* + * I860 subtypes + */ +#define CPU_SUBTYPE_I860_ALL ((cpu_subtype_t) 0) +#define CPU_SUBTYPE_I860_860 ((cpu_subtype_t) 1) + +/* + * PowerPC subtypes + */ +#define CPU_SUBTYPE_POWERPC_ALL ((cpu_subtype_t) 0) +#define CPU_SUBTYPE_POWERPC_601 ((cpu_subtype_t) 1) +#define CPU_SUBTYPE_POWERPC_602 ((cpu_subtype_t) 2) +#define CPU_SUBTYPE_POWERPC_603 ((cpu_subtype_t) 3) +#define CPU_SUBTYPE_POWERPC_603e ((cpu_subtype_t) 4) +#define CPU_SUBTYPE_POWERPC_603ev ((cpu_subtype_t) 5) +#define CPU_SUBTYPE_POWERPC_604 ((cpu_subtype_t) 6) +#define CPU_SUBTYPE_POWERPC_604e ((cpu_subtype_t) 7) +#define CPU_SUBTYPE_POWERPC_620 ((cpu_subtype_t) 8) +#define CPU_SUBTYPE_POWERPC_750 ((cpu_subtype_t) 9) +#define CPU_SUBTYPE_POWERPC_7400 ((cpu_subtype_t) 10) +#define CPU_SUBTYPE_POWERPC_7450 ((cpu_subtype_t) 11) +#define CPU_SUBTYPE_POWERPC_970 ((cpu_subtype_t) 100) + +/* + * ARM subtypes + */ +#define CPU_SUBTYPE_ARM_ALL ((cpu_subtype_t) 0) +#define CPU_SUBTYPE_ARM_V4T ((cpu_subtype_t) 5) +#define CPU_SUBTYPE_ARM_V6 ((cpu_subtype_t) 6) +#define CPU_SUBTYPE_ARM_V5TEJ ((cpu_subtype_t) 7) +#define CPU_SUBTYPE_ARM_XSCALE ((cpu_subtype_t) 8) +#define CPU_SUBTYPE_ARM_V7 ((cpu_subtype_t) 9) + +/* + * CPU families (sysctl hw.cpufamily) + * + * These are meant to identify the CPU's marketing name - an + * application can map these to (possibly) localized strings. + * NB: the encodings of the CPU families are intentionally arbitrary. + * There is no ordering, and you should never try to deduce whether + * or not some feature is available based on the family. + * Use feature flags (eg, hw.optional.altivec) to test for optional + * functionality. + */ +#define CPUFAMILY_UNKNOWN 0 +#define CPUFAMILY_POWERPC_G3 0xcee41549 +#define CPUFAMILY_POWERPC_G4 0x77c184ae +#define CPUFAMILY_POWERPC_G5 0xed76d8aa +#define CPUFAMILY_INTEL_6_13 0xaa33392b +#define CPUFAMILY_INTEL_YONAH 0x73d67300 +#define CPUFAMILY_INTEL_MEROM 0x426f69ef +#define CPUFAMILY_INTEL_PENRYN 0x78ea4fbc +#define CPUFAMILY_INTEL_NEHALEM 0x6b5a4cd2 +#define CPUFAMILY_INTEL_WESTMERE 0x573b5eec +#define CPUFAMILY_ARM_9 0xe73283ae +#define CPUFAMILY_ARM_11 0x8ff620d8 +#define CPUFAMILY_ARM_XSCALE 0x53b005f5 +#define CPUFAMILY_ARM_13 0x0cc90e64 + +/* The following synonyms are deprecated: */ +#define CPUFAMILY_INTEL_6_14 CPUFAMILY_INTEL_YONAH +#define CPUFAMILY_INTEL_6_15 CPUFAMILY_INTEL_MEROM +#define CPUFAMILY_INTEL_6_23 CPUFAMILY_INTEL_PENRYN +#define CPUFAMILY_INTEL_6_26 CPUFAMILY_INTEL_NEHALEM + +#define CPUFAMILY_INTEL_CORE CPUFAMILY_INTEL_YONAH +#define CPUFAMILY_INTEL_CORE2 CPUFAMILY_INTEL_MEROM + + +#endif /* _MACH_MACHINE_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/mach_host.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/mach_host.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/mach_host.h (revision 885) @@ -0,0 +1,873 @@ +#ifndef _mach_host_user_ +#define _mach_host_user_ + +/* Module mach_host */ + +#include <string.h> +#include <mach/ndr.h> +#include <mach/boolean.h> +#include <mach/kern_return.h> +#include <mach/notify.h> +#include <mach/mach_types.h> +#include <mach/message.h> +#include <mach/mig_errors.h> +#include <mach/port.h> + +#ifdef AUTOTEST +#ifndef FUNCTION_PTR_T +#define FUNCTION_PTR_T +typedef void (*function_ptr_t)(mach_port_t, char *, mach_msg_type_number_t); +typedef struct { + char *name; + function_ptr_t function; +} function_table_entry; +typedef function_table_entry *function_table_t; +#endif /* FUNCTION_PTR_T */ +#endif /* AUTOTEST */ + +#ifndef mach_host_MSG_COUNT +#define mach_host_MSG_COUNT 20 +#endif /* mach_host_MSG_COUNT */ + +#include <mach/std_types.h> +#include <mach/mig.h> +#include <mach/mach_types.h> +#include <mach/mach_types.h> +#include <mach_debug/mach_debug_types.h> +#include <mach/mach_init.h> + +#ifdef __BeforeMigUserHeader +__BeforeMigUserHeader +#endif /* __BeforeMigUserHeader */ + +#include <sys/cdefs.h> +__BEGIN_DECLS + + +/* Routine host_info */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t host_info +( + host_t host, + host_flavor_t flavor, + host_info_t host_info_out, + mach_msg_type_number_t *host_info_outCnt +); + +/* Routine host_kernel_version */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t host_kernel_version +( + host_t host, + kernel_version_t kernel_version +); + +/* Routine _host_page_size */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t _host_page_size +( + host_t host, + vm_size_t *out_page_size +); + +/* Routine mach_memory_object_memory_entry */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_memory_object_memory_entry +( + host_t host, + boolean_t internal, + vm_size_t size, + vm_prot_t permission, + memory_object_t pager, + mach_port_t *entry_handle +); + +/* Routine host_processor_info */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t host_processor_info +( + host_t host, + processor_flavor_t flavor, + natural_t *out_processor_count, + processor_info_array_t *out_processor_info, + mach_msg_type_number_t *out_processor_infoCnt +); + +/* Routine host_get_io_master */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t host_get_io_master +( + host_t host, + io_master_t *io_master +); + +/* Routine host_get_clock_service */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t host_get_clock_service +( + host_t host, + clock_id_t clock_id, + clock_serv_t *clock_serv +); + +/* Routine kmod_get_info */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t kmod_get_info +( + host_t host, + kmod_args_t *modules, + mach_msg_type_number_t *modulesCnt +); + +/* Routine host_zone_info */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t host_zone_info +( + host_t host, + zone_name_array_t *names, + mach_msg_type_number_t *namesCnt, + zone_info_array_t *info, + mach_msg_type_number_t *infoCnt +); + +/* Routine host_virtual_physical_table_info */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t host_virtual_physical_table_info +( + host_t host, + hash_info_bucket_array_t *info, + mach_msg_type_number_t *infoCnt +); + +/* Routine host_ipc_hash_info */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t host_ipc_hash_info +( + host_t host, + hash_info_bucket_array_t *info, + mach_msg_type_number_t *infoCnt +); + +/* Routine processor_set_default */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t processor_set_default +( + host_t host, + processor_set_name_t *default_set +); + +/* Routine processor_set_create */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t processor_set_create +( + host_t host, + processor_set_t *new_set, + processor_set_name_t *new_name +); + +/* Routine mach_memory_object_memory_entry_64 */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_memory_object_memory_entry_64 +( + host_t host, + boolean_t internal, + memory_object_size_t size, + vm_prot_t permission, + memory_object_t pager, + mach_port_t *entry_handle +); + +/* Routine host_statistics */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t host_statistics +( + host_t host_priv, + host_flavor_t flavor, + host_info_t host_info_out, + mach_msg_type_number_t *host_info_outCnt +); + +/* Routine host_request_notification */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t host_request_notification +( + host_t host, + host_flavor_t notify_type, + mach_port_t notify_port +); + +/* Routine host_lockgroup_info */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t host_lockgroup_info +( + host_t host, + lockgroup_info_array_t *lockgroup_info, + mach_msg_type_number_t *lockgroup_infoCnt +); + +/* Routine host_statistics64 */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t host_statistics64 +( + host_t host_priv, + host_flavor_t flavor, + host_info64_t host_info64_out, + mach_msg_type_number_t *host_info64_outCnt +); + +__END_DECLS + +/********************** Caution **************************/ +/* The following data types should be used to calculate */ +/* maximum message sizes only. The actual message may be */ +/* smaller, and the position of the arguments within the */ +/* message layout may vary from what is presented here. */ +/* For example, if any of the arguments are variable- */ +/* sized, and less than the maximum is sent, the data */ +/* will be packed tight in the actual message to reduce */ +/* the presence of holes. */ +/********************** Caution **************************/ + +/* typedefs for all requests */ + +#ifndef __Request__mach_host_subsystem__defined +#define __Request__mach_host_subsystem__defined + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + host_flavor_t flavor; + mach_msg_type_number_t host_info_outCnt; + } __Request__host_info_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__host_kernel_version_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request___host_page_size_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t pager; + /* end of the kernel processed data */ + NDR_record_t NDR; + boolean_t internal; + vm_size_t size; + vm_prot_t permission; + } __Request__mach_memory_object_memory_entry_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + processor_flavor_t flavor; + } __Request__host_processor_info_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__host_get_io_master_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + clock_id_t clock_id; + } __Request__host_get_clock_service_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__kmod_get_info_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__host_zone_info_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__host_virtual_physical_table_info_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__host_ipc_hash_info_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__processor_set_default_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__processor_set_create_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t pager; + /* end of the kernel processed data */ + NDR_record_t NDR; + boolean_t internal; + memory_object_size_t size; + vm_prot_t permission; + } __Request__mach_memory_object_memory_entry_64_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + host_flavor_t flavor; + mach_msg_type_number_t host_info_outCnt; + } __Request__host_statistics_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t notify_port; + /* end of the kernel processed data */ + NDR_record_t NDR; + host_flavor_t notify_type; + } __Request__host_request_notification_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__host_lockgroup_info_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + host_flavor_t flavor; + mach_msg_type_number_t host_info64_outCnt; + } __Request__host_statistics64_t; +#ifdef __MigPackStructs +#pragma pack() +#endif +#endif /* !__Request__mach_host_subsystem__defined */ + +/* union of all requests */ + +#ifndef __RequestUnion__mach_host_subsystem__defined +#define __RequestUnion__mach_host_subsystem__defined +union __RequestUnion__mach_host_subsystem { + __Request__host_info_t Request_host_info; + __Request__host_kernel_version_t Request_host_kernel_version; + __Request___host_page_size_t Request__host_page_size; + __Request__mach_memory_object_memory_entry_t Request_mach_memory_object_memory_entry; + __Request__host_processor_info_t Request_host_processor_info; + __Request__host_get_io_master_t Request_host_get_io_master; + __Request__host_get_clock_service_t Request_host_get_clock_service; + __Request__kmod_get_info_t Request_kmod_get_info; + __Request__host_zone_info_t Request_host_zone_info; + __Request__host_virtual_physical_table_info_t Request_host_virtual_physical_table_info; + __Request__host_ipc_hash_info_t Request_host_ipc_hash_info; + __Request__processor_set_default_t Request_processor_set_default; + __Request__processor_set_create_t Request_processor_set_create; + __Request__mach_memory_object_memory_entry_64_t Request_mach_memory_object_memory_entry_64; + __Request__host_statistics_t Request_host_statistics; + __Request__host_request_notification_t Request_host_request_notification; + __Request__host_lockgroup_info_t Request_host_lockgroup_info; + __Request__host_statistics64_t Request_host_statistics64; +}; +#endif /* !__RequestUnion__mach_host_subsystem__defined */ +/* typedefs for all replies */ + +#ifndef __Reply__mach_host_subsystem__defined +#define __Reply__mach_host_subsystem__defined + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_msg_type_number_t host_info_outCnt; + integer_t host_info_out[15]; + } __Reply__host_info_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_msg_type_number_t kernel_versionOffset; /* MiG doesn't use it */ + mach_msg_type_number_t kernel_versionCnt; + char kernel_version[512]; + } __Reply__host_kernel_version_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + vm_size_t out_page_size; + } __Reply___host_page_size_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t entry_handle; + /* end of the kernel processed data */ + } __Reply__mach_memory_object_memory_entry_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_descriptor_t out_processor_info; + /* end of the kernel processed data */ + NDR_record_t NDR; + natural_t out_processor_count; + mach_msg_type_number_t out_processor_infoCnt; + } __Reply__host_processor_info_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t io_master; + /* end of the kernel processed data */ + } __Reply__host_get_io_master_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t clock_serv; + /* end of the kernel processed data */ + } __Reply__host_get_clock_service_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_descriptor_t modules; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t modulesCnt; + } __Reply__kmod_get_info_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_descriptor_t names; + mach_msg_ool_descriptor_t info; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t namesCnt; + mach_msg_type_number_t infoCnt; + } __Reply__host_zone_info_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_descriptor_t info; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t infoCnt; + } __Reply__host_virtual_physical_table_info_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_descriptor_t info; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t infoCnt; + } __Reply__host_ipc_hash_info_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t default_set; + /* end of the kernel processed data */ + } __Reply__processor_set_default_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t new_set; + mach_msg_port_descriptor_t new_name; + /* end of the kernel processed data */ + } __Reply__processor_set_create_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t entry_handle; + /* end of the kernel processed data */ + } __Reply__mach_memory_object_memory_entry_64_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_msg_type_number_t host_info_outCnt; + integer_t host_info_out[15]; + } __Reply__host_statistics_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__host_request_notification_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_descriptor_t lockgroup_info; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t lockgroup_infoCnt; + } __Reply__host_lockgroup_info_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_msg_type_number_t host_info64_outCnt; + integer_t host_info64_out[256]; + } __Reply__host_statistics64_t; +#ifdef __MigPackStructs +#pragma pack() +#endif +#endif /* !__Reply__mach_host_subsystem__defined */ + +/* union of all replies */ + +#ifndef __ReplyUnion__mach_host_subsystem__defined +#define __ReplyUnion__mach_host_subsystem__defined +union __ReplyUnion__mach_host_subsystem { + __Reply__host_info_t Reply_host_info; + __Reply__host_kernel_version_t Reply_host_kernel_version; + __Reply___host_page_size_t Reply__host_page_size; + __Reply__mach_memory_object_memory_entry_t Reply_mach_memory_object_memory_entry; + __Reply__host_processor_info_t Reply_host_processor_info; + __Reply__host_get_io_master_t Reply_host_get_io_master; + __Reply__host_get_clock_service_t Reply_host_get_clock_service; + __Reply__kmod_get_info_t Reply_kmod_get_info; + __Reply__host_zone_info_t Reply_host_zone_info; + __Reply__host_virtual_physical_table_info_t Reply_host_virtual_physical_table_info; + __Reply__host_ipc_hash_info_t Reply_host_ipc_hash_info; + __Reply__processor_set_default_t Reply_processor_set_default; + __Reply__processor_set_create_t Reply_processor_set_create; + __Reply__mach_memory_object_memory_entry_64_t Reply_mach_memory_object_memory_entry_64; + __Reply__host_statistics_t Reply_host_statistics; + __Reply__host_request_notification_t Reply_host_request_notification; + __Reply__host_lockgroup_info_t Reply_host_lockgroup_info; + __Reply__host_statistics64_t Reply_host_statistics64; +}; +#endif /* !__RequestUnion__mach_host_subsystem__defined */ + +#ifndef subsystem_to_name_map_mach_host +#define subsystem_to_name_map_mach_host \ + { "host_info", 200 },\ + { "host_kernel_version", 201 },\ + { "_host_page_size", 202 },\ + { "mach_memory_object_memory_entry", 203 },\ + { "host_processor_info", 204 },\ + { "host_get_io_master", 205 },\ + { "host_get_clock_service", 206 },\ + { "kmod_get_info", 207 },\ + { "host_zone_info", 208 },\ + { "host_virtual_physical_table_info", 209 },\ + { "host_ipc_hash_info", 210 },\ + { "processor_set_default", 213 },\ + { "processor_set_create", 214 },\ + { "mach_memory_object_memory_entry_64", 215 },\ + { "host_statistics", 216 },\ + { "host_request_notification", 217 },\ + { "host_lockgroup_info", 218 },\ + { "host_statistics64", 219 } +#endif + +#ifdef __AfterMigUserHeader +__AfterMigUserHeader +#endif /* __AfterMigUserHeader */ + +#endif /* _mach_host_user_ */ Index: branches/azimutz/Cleancut/i386/include/mach/mach_port.defs =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/mach_port.defs (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/mach_port.defs (revision 885) @@ -0,0 +1,492 @@ +/* + * 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_FREE_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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + */ +/* + * File: mach/mach_port.defs + * Author: Rich Draves + * + * Exported kernel calls. + */ + +subsystem +#if KERNEL_SERVER + KernelServer +#endif /* KERNEL_SERVER */ + mach_port 3200; + +#include <mach/std_types.defs> +#include <mach/mach_types.defs> +#include <mach_debug/mach_debug_types.defs> + +/* + * Returns the set of port and port set names + * to which the target task has access, along with + * the type (set or port) for each name. + */ + +routine mach_port_names( + task : ipc_space_t; + out names : mach_port_name_array_t; + out types : mach_port_type_array_t); + +/* + * Returns the type (set or port) for the port name + * within the target task. Also indicates whether + * there is a dead-name request for the name. + */ + +routine mach_port_type( + task : ipc_space_t; + name : mach_port_name_t; + out ptype : mach_port_type_t); + +/* + * Changes the name by which a port (or port set) is known to + * the target task. The new name can't be in use. The + * old name becomes available for recycling. + */ + +routine mach_port_rename( + task : ipc_space_t; + old_name : mach_port_name_t; + new_name : mach_port_name_t); + +/* + * Allocates the specified kind of object, with the given name. + * The right must be one of + * MACH_PORT_RIGHT_RECEIVE + * MACH_PORT_RIGHT_PORT_SET + * MACH_PORT_RIGHT_DEAD_NAME + * New port sets are empty. New ports don't have any + * send/send-once rights or queued messages. The make-send + * count is zero and their queue limit is MACH_PORT_QLIMIT_DEFAULT. + * New sets, ports, and dead names have one user reference. + */ + +routine mach_port_allocate_name( + task : ipc_space_t; + right : mach_port_right_t; + name : mach_port_name_t); + +/* + * Allocates the specified kind of object. + * The right must be one of + * MACH_PORT_RIGHT_RECEIVE + * MACH_PORT_RIGHT_PORT_SET + * MACH_PORT_RIGHT_DEAD_NAME + * Like port_allocate_name, but the kernel picks a name. + * It can use any name not associated with a right. + */ + +routine mach_port_allocate( + task : ipc_space_t; + right : mach_port_right_t; + out name : mach_port_name_t); + +/* + * Destroys all rights associated with the name and makes it + * available for recycling immediately. The name can be a + * port (possibly with multiple user refs), a port set, or + * a dead name (again, with multiple user refs). + */ + +routine mach_port_destroy( + task : ipc_space_t; + name : mach_port_name_t); + +/* + * Releases one send/send-once/dead-name user ref. + * Just like mach_port_mod_refs -1, but deduces the + * correct type of right. This allows a user task + * to release a ref for a port without worrying + * about whether the port has died or not. + */ + +routine mach_port_deallocate( + task : ipc_space_t; + name : mach_port_name_t); + +/* + * A port set always has one user ref. + * A send-once right always has one user ref. + * A dead name always has one or more user refs. + * A send right always has one or more user refs. + * A receive right always has one user ref. + * The right must be one of + * MACH_PORT_RIGHT_RECEIVE + * MACH_PORT_RIGHT_PORT_SET + * MACH_PORT_RIGHT_DEAD_NAME + * MACH_PORT_RIGHT_SEND + * MACH_PORT_RIGHT_SEND_ONCE + */ + +routine mach_port_get_refs( + task : ipc_space_t; + name : mach_port_name_t; + right : mach_port_right_t; + out refs : mach_port_urefs_t); + +/* + * The delta is a signed change to the task's + * user ref count for the right. Only dead names + * and send rights can have a positive delta. + * The resulting user ref count can't be negative. + * If it is zero, the right is deallocated. + * If the name isn't a composite right, it becomes + * available for recycling. The right must be one of + * MACH_PORT_RIGHT_RECEIVE + * MACH_PORT_RIGHT_PORT_SET + * MACH_PORT_RIGHT_DEAD_NAME + * MACH_PORT_RIGHT_SEND + * MACH_PORT_RIGHT_SEND_ONCE + */ + +routine mach_port_mod_refs( + task : ipc_space_t; + name : mach_port_name_t; + right : mach_port_right_t; + delta : mach_port_delta_t); + +skip; + +/* + * Only valid for receive rights. + * Sets the make-send count for the port. + */ +routine mach_port_set_mscount( + task : ipc_space_t; + name : mach_port_name_t; + mscount : mach_port_mscount_t); + +/* + * Only valid for port sets. Returns a list of + * the members. + */ + +routine mach_port_get_set_status( + task : ipc_space_t; + name : mach_port_name_t; + out members : mach_port_name_array_t); + +/* + * Puts the member port (the task must have receive rights) + * into the after port set. If the port is already a member + * of any set(s), it is atomically removed from those sets as + * part of this operation. (If after is MACH_PORT_NULL, the + * port is still removed from all current sets). + */ + +routine mach_port_move_member( + task : ipc_space_t; + member : mach_port_name_t; + after : mach_port_name_t); + +/* + * Requests a notification from the kernel. The request + * must supply the send-once right which is used for + * the notification. If a send-once right was previously + * registered, it is returned. The msg_id must be one of + * MACH_NOTIFY_PORT_DESTROYED (receive rights) + * MACH_NOTIFY_DEAD_NAME (send/receive/send-once rights) + * MACH_NOTIFY_NO_SENDERS (receive rights) + * + * The sync value specifies whether a notification should + * get sent immediately, if appropriate. The exact meaning + * depends on the notification: + * MACH_NOTIFY_PORT_DESTROYED: must be zero. + * MACH_NOTIFY_DEAD_NAME: if non-zero, then name can be dead, + * and the notification gets sent immediately. + * If zero, then name can't be dead. + * MACH_NOTIFY_NO_SENDERS: the notification gets sent + * immediately if the current mscount is greater + * than or equal to the sync value and there are no + * extant send rights. + */ + +routine mach_port_request_notification( + task : ipc_space_t; + name : mach_port_name_t; + msgid : mach_msg_id_t; + sync : mach_port_mscount_t; + notify : mach_port_send_once_t; + out previous : mach_port_move_send_once_t); + +/* + * Inserts the specified rights into the target task, + * using the specified name. If inserting send/receive + * rights and the task already has send/receive rights + * for the port, then the names must agree. In any case, + * the task gains a user ref for the port. + */ + +routine mach_port_insert_right( + task : ipc_space_t; + name : mach_port_name_t; + poly : mach_port_poly_t); + +/* + * Returns the specified right for the named port + * in the target task, extracting that right from + * the target task. The target task loses a user + * ref and the name may be available for recycling. + * msgt_name must be one of + * MACH_MSG_TYPE_MOVE_RECEIVE + * MACH_MSG_TYPE_COPY_SEND + * MACH_MSG_TYPE_MAKE_SEND + * MACH_MSG_TYPE_MOVE_SEND + * MACH_MSG_TYPE_MAKE_SEND_ONCE + * MACH_MSG_TYPE_MOVE_SEND_ONCE + */ + +routine mach_port_extract_right( + task : ipc_space_t; + name : mach_port_name_t; + msgt_name : mach_msg_type_name_t; + out poly : mach_port_poly_t); + +/* + * Only valid for receive rights. + * Sets the sequence number for the port. + */ + +routine mach_port_set_seqno( + task : ipc_space_t; + name : mach_port_name_t; + seqno : mach_port_seqno_t); + +/* + * Returns information about a port. + */ + +routine mach_port_get_attributes( + task : ipc_space_t; + name : mach_port_name_t; + flavor : mach_port_flavor_t; + out port_info_out : mach_port_info_t, CountInOut); + +/* + * Set attributes of a port + */ + +routine mach_port_set_attributes( + task : ipc_space_t; + name : mach_port_name_t; + flavor : mach_port_flavor_t; + port_info : mach_port_info_t); + + +/* + * Allocates the specified kind of object, qos version. + * The right must be + * MACH_PORT_RIGHT_RECEIVE + * Like port_allocate_name, but the kernel picks a name. + * It can use any name not associated with a right. + */ + +routine mach_port_allocate_qos( + task : ipc_space_t; + right : mach_port_right_t; + inout qos : mach_port_qos_t; + out name : mach_port_name_t); + + +/* + * Generic interface to allocation various kinds of ports. + * Should never be called directly by users (at least not + * unless they are exceedingly masochistic). + */ + +routine mach_port_allocate_full( + task : ipc_space_t; + right : mach_port_right_t; + proto : mach_port_t; + inout qos : mach_port_qos_t; + inout name : mach_port_name_t); + + +/* + * Pre-expand task port name space. + */ +routine task_set_port_space( + task : ipc_space_t; + table_entries : int); + + +/* + * Returns the exact number of extant send rights + * for the given receive right. + * This call is only valid on MACH_IPC_DEBUG kernels. + * Otherwise, KERN_FAILURE is returned. + */ +routine mach_port_get_srights( + task : ipc_space_t; + name : mach_port_name_t; + out srights : mach_port_rights_t); + + +/* + * Returns information about an IPC space. + * This call is only valid on MACH_IPC_DEBUG kernels. + * Otherwise, KERN_FAILURE is returned. + */ +routine mach_port_space_info( + task : ipc_space_t; + out space_info : ipc_info_space_t; + out table_info : ipc_info_name_array_t; + out tree_info : ipc_info_tree_name_array_t); + +/* + * Returns information about the dead-name requests + * registered with the named receive right. + * This call is only valid on MACH_IPC_DEBUG kernels. + * Otherwise, KERN_FAILURE is returned. + */ +routine mach_port_dnrequest_info( + task : ipc_space_t; + name : mach_port_name_t; + out dnr_total : unsigned; /* total size of table */ + out dnr_used : unsigned); /* amount used */ + +/* + * Return the type and address of the kernel object + * that the given send/receive right represents. + * This call is only valid on MACH_IPC_DEBUG kernels. + * Otherwise, KERN_FAILURE is returned. + * + * This interface is DEPRECATED in favor of the new + * mach_port_kernel_object64() call (see below). + */ +routine mach_port_kernel_object( + task : ipc_space_t; + name : mach_port_name_t; + out object_type : unsigned; + out object_addr : unsigned); + + +/* + * Inserts the specified rights into the portset identified + * by the <task, pset> pair. The results of passing in the + * Poly argument via the supplied disposition must yield a + * receive right. + * + * If the <task,pset> pair does not represent a valid portset + * KERN_INVALID_RIGHT is returned. + * + * If the passed in name argument does not represent a receive + * right, KERN_INVALID_CAPABILITY will be returned. + * + * If the port represented by the receive right is already in + * the portset, KERN_ALREADY_IN_SET is returned. + */ +routine mach_port_insert_member( + task : ipc_space_t; + name : mach_port_name_t; + pset : mach_port_name_t); + +/* + * Extracts the specified right from the named portset + * in the target task. + * the target task. The target task loses a user + * ref and the name may be available for recycling. + * msgt_name must be one of + * MACH_MSG_TYPE_MOVE_RECEIVE + * MACH_MSG_TYPE_COPY_SEND + * MACH_MSG_TYPE_MAKE_SEND + * MACH_MSG_TYPE_MOVE_SEND + * MACH_MSG_TYPE_MAKE_SEND_ONCE + * MACH_MSG_TYPE_MOVE_SEND_ONCE + */ + +routine mach_port_extract_member( + task : ipc_space_t; + name : mach_port_name_t; + pset : mach_port_name_t); + +/* + * Only valid for receive rights. + * Gets the context pointer for the port. + */ + +routine mach_port_get_context( + task : ipc_space_t; + name : mach_port_name_t; + out context : mach_vm_address_t); + +/* + * Only valid for receive rights. + * Sets the context pointer for the port. + */ + +routine mach_port_set_context( + task : ipc_space_t; + name : mach_port_name_t; + context : mach_vm_address_t); + +/* + * Return the type and address of the kernel object + * that the given send/receive right represents. + * This call is only valid on MACH_IPC_DEBUG kernels. + * Otherwise, KERN_FAILURE is returned. + */ +routine mach_port_kobject( + task : ipc_space_t; + name : mach_port_name_t; + out object_type : natural_t; + out object_addr : mach_vm_address_t); + + +/* vim: set ft=c : */ Index: branches/azimutz/Cleancut/i386/include/mach/exc.defs =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/exc.defs (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/exc.defs (revision 885) @@ -0,0 +1,119 @@ +/* + * Copyright (c) 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@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989,1988,1987 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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + */ +/* + * Abstract: + * MiG definitions file for Mach exception interface. + */ + +subsystem +#if KERNEL_USER + KernelUser +#endif + exc 2401; + +#include <mach/std_types.defs> +#include <mach/mach_types.defs> + +ServerPrefix catch_; + +type exception_data_t = array[*:2] of integer_t; +type exception_type_t = int; + +routine exception_raise( +#if KERNEL_USER + exception_port : mach_port_move_send_t; + thread : mach_port_move_send_t; + task : mach_port_move_send_t; +#else /* KERNEL_USER */ + exception_port : mach_port_t; + thread : mach_port_t; + task : mach_port_t; +#endif /* KERNEL_USER */ + exception : exception_type_t; + code : exception_data_t + ); + +routine exception_raise_state( +#if KERNEL_USER + exception_port : mach_port_move_send_t; +#else /* KERNEL_USER */ + exception_port : mach_port_t; +#endif /* KERNEL_USER */ + exception : exception_type_t; + code : exception_data_t, const; + inout flavor : int; + old_state : thread_state_t, const; + out new_state : thread_state_t); + +routine exception_raise_state_identity( +#if KERNEL_USER + exception_port : mach_port_move_send_t; + thread : mach_port_move_send_t; + task : mach_port_move_send_t; +#else /* KERNEL_USER */ + exception_port : mach_port_t; + thread : mach_port_t; + task : mach_port_t; +#endif /* KERNEL_USER */ + exception : exception_type_t; + code : exception_data_t; + inout flavor : int; + old_state : thread_state_t; + out new_state : thread_state_t); + +/* vim: set ft=c : */ Index: branches/azimutz/Cleancut/i386/include/mach/processor.defs =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/processor.defs (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/processor.defs (revision 885) @@ -0,0 +1,128 @@ +/* + * Copyright (c) 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@ + */ +/* + * @OSF_FREE_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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + */ +/* + * File: mach/mach_port.defs + * Author: Rich Draves + * + * Exported kernel calls. + */ + +subsystem +#if KERNEL_SERVER + KernelServer +#endif /* KERNEL_SERVER */ + processor 3000; + +#include <mach/std_types.defs> +#include <mach/mach_types.defs> + +/* + * References to processor objects are returned by: + * host_processors(host_priv_t,...); + * +/* + * Start processor. + */ +routine processor_start( + processor : processor_t); + +/* + * Exit processor -- may not be restartable. + */ + +routine processor_exit( + processor : processor_t); + +/* + * Return information about this processor. + */ +routine processor_info( + processor : processor_t; + flavor : processor_flavor_t; + out host : host_t; + out processor_info_out: processor_info_t, CountInOut); + + +/* + * Do something machine-dependent to processor. + */ +routine processor_control( + processor : processor_t; + processor_cmd : processor_info_t); + +/* + * JMM - Keep processor_set related stuff at the end because + * they likely will be removed. + */ + +/* + * Assign processor to processor set. + */ +routine processor_assign( + processor : processor_t; + new_set : processor_set_t; + wait : boolean_t); + +/* + * Get current assignment for processor. + */ +routine processor_get_assignment( + processor : processor_t; + out assigned_set : processor_set_name_t); + +/* vim: set ft=c : */ Index: branches/azimutz/Cleancut/i386/include/mach/host_notify_reply.defs =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/host_notify_reply.defs (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/host_notify_reply.defs (revision 885) @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2003 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@ + */ + +subsystem +#if KERNEL_USER + KernelUser +#endif /* KERN_USER */ + host_notify_reply 950; + +#include <mach/std_types.defs> + +simpleroutine host_calendar_changed( + notify_port : mach_port_move_send_once_t); + +/* vim: set ft=c : */ Index: branches/azimutz/Cleancut/i386/include/mach/mach_vm.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/mach_vm.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/mach_vm.h (revision 885) @@ -0,0 +1,1032 @@ +#ifndef _mach_vm_user_ +#define _mach_vm_user_ + +/* Module mach_vm */ + +#include <string.h> +#include <mach/ndr.h> +#include <mach/boolean.h> +#include <mach/kern_return.h> +#include <mach/notify.h> +#include <mach/mach_types.h> +#include <mach/message.h> +#include <mach/mig_errors.h> +#include <mach/port.h> + +#ifdef AUTOTEST +#ifndef FUNCTION_PTR_T +#define FUNCTION_PTR_T +typedef void (*function_ptr_t)(mach_port_t, char *, mach_msg_type_number_t); +typedef struct { + char *name; + function_ptr_t function; +} function_table_entry; +typedef function_table_entry *function_table_t; +#endif /* FUNCTION_PTR_T */ +#endif /* AUTOTEST */ + +#ifndef mach_vm_MSG_COUNT +#define mach_vm_MSG_COUNT 20 +#endif /* mach_vm_MSG_COUNT */ + +#include <mach/std_types.h> +#include <mach/mig.h> +#include <mach/mach_types.h> +#include <mach_debug/mach_debug_types.h> + +#ifdef __BeforeMigUserHeader +__BeforeMigUserHeader +#endif /* __BeforeMigUserHeader */ + +#include <sys/cdefs.h> +__BEGIN_DECLS + + +/* Routine mach_vm_allocate */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_vm_allocate +( + vm_map_t target, + mach_vm_address_t *address, + mach_vm_size_t size, + int flags +); + +/* Routine mach_vm_deallocate */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_vm_deallocate +( + vm_map_t target, + mach_vm_address_t address, + mach_vm_size_t size +); + +/* Routine mach_vm_protect */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_vm_protect +( + vm_map_t target_task, + mach_vm_address_t address, + mach_vm_size_t size, + boolean_t set_maximum, + vm_prot_t new_protection +); + +/* Routine mach_vm_inherit */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_vm_inherit +( + vm_map_t target_task, + mach_vm_address_t address, + mach_vm_size_t size, + vm_inherit_t new_inheritance +); + +/* Routine mach_vm_read */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_vm_read +( + vm_map_t target_task, + mach_vm_address_t address, + mach_vm_size_t size, + vm_offset_t *data, + mach_msg_type_number_t *dataCnt +); + +/* Routine mach_vm_read_list */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_vm_read_list +( + vm_map_t target_task, + mach_vm_read_entry_t data_list, + natural_t count +); + +/* Routine mach_vm_write */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_vm_write +( + vm_map_t target_task, + mach_vm_address_t address, + vm_offset_t data, + mach_msg_type_number_t dataCnt +); + +/* Routine mach_vm_copy */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_vm_copy +( + vm_map_t target_task, + mach_vm_address_t source_address, + mach_vm_size_t size, + mach_vm_address_t dest_address +); + +/* Routine mach_vm_read_overwrite */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_vm_read_overwrite +( + vm_map_t target_task, + mach_vm_address_t address, + mach_vm_size_t size, + mach_vm_address_t data, + mach_vm_size_t *outsize +); + +/* Routine mach_vm_msync */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_vm_msync +( + vm_map_t target_task, + mach_vm_address_t address, + mach_vm_size_t size, + vm_sync_t sync_flags +); + +/* Routine mach_vm_behavior_set */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_vm_behavior_set +( + vm_map_t target_task, + mach_vm_address_t address, + mach_vm_size_t size, + vm_behavior_t new_behavior +); + +/* Routine mach_vm_map */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_vm_map +( + vm_map_t target_task, + mach_vm_address_t *address, + mach_vm_size_t size, + mach_vm_offset_t mask, + int flags, + mem_entry_name_port_t object, + memory_object_offset_t offset, + boolean_t copy, + vm_prot_t cur_protection, + vm_prot_t max_protection, + vm_inherit_t inheritance +); + +/* Routine mach_vm_machine_attribute */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_vm_machine_attribute +( + vm_map_t target_task, + mach_vm_address_t address, + mach_vm_size_t size, + vm_machine_attribute_t attribute, + vm_machine_attribute_val_t *value +); + +/* Routine mach_vm_remap */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_vm_remap +( + vm_map_t target_task, + mach_vm_address_t *target_address, + mach_vm_size_t size, + mach_vm_offset_t mask, + boolean_t anywhere, + vm_map_t src_task, + mach_vm_address_t src_address, + boolean_t copy, + vm_prot_t *cur_protection, + vm_prot_t *max_protection, + vm_inherit_t inheritance +); + +/* Routine mach_vm_page_query */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_vm_page_query +( + vm_map_t target_map, + mach_vm_offset_t offset, + integer_t *disposition, + integer_t *ref_count +); + +/* Routine mach_vm_region_recurse */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_vm_region_recurse +( + vm_map_t target_task, + mach_vm_address_t *address, + mach_vm_size_t *size, + natural_t *nesting_depth, + vm_region_recurse_info_t info, + mach_msg_type_number_t *infoCnt +); + +/* Routine mach_vm_region */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_vm_region +( + vm_map_t target_task, + mach_vm_address_t *address, + mach_vm_size_t *size, + vm_region_flavor_t flavor, + vm_region_info_t info, + mach_msg_type_number_t *infoCnt, + mach_port_t *object_name +); + +/* Routine _mach_make_memory_entry */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t _mach_make_memory_entry +( + vm_map_t target_task, + memory_object_size_t *size, + memory_object_offset_t offset, + vm_prot_t permission, + mem_entry_name_port_t *object_handle, + mem_entry_name_port_t parent_handle +); + +/* Routine mach_vm_purgable_control */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_vm_purgable_control +( + vm_map_t target_task, + mach_vm_address_t address, + vm_purgable_t control, + int *state +); + +/* Routine mach_vm_page_info */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_vm_page_info +( + vm_map_t target_task, + mach_vm_address_t address, + vm_page_info_flavor_t flavor, + vm_page_info_t info, + mach_msg_type_number_t *infoCnt +); + +__END_DECLS + +/********************** Caution **************************/ +/* The following data types should be used to calculate */ +/* maximum message sizes only. The actual message may be */ +/* smaller, and the position of the arguments within the */ +/* message layout may vary from what is presented here. */ +/* For example, if any of the arguments are variable- */ +/* sized, and less than the maximum is sent, the data */ +/* will be packed tight in the actual message to reduce */ +/* the presence of holes. */ +/********************** Caution **************************/ + +/* typedefs for all requests */ + +#ifndef __Request__mach_vm_subsystem__defined +#define __Request__mach_vm_subsystem__defined + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_vm_address_t address; + mach_vm_size_t size; + int flags; + } __Request__mach_vm_allocate_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_vm_address_t address; + mach_vm_size_t size; + } __Request__mach_vm_deallocate_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_vm_address_t address; + mach_vm_size_t size; + boolean_t set_maximum; + vm_prot_t new_protection; + } __Request__mach_vm_protect_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_vm_address_t address; + mach_vm_size_t size; + vm_inherit_t new_inheritance; + } __Request__mach_vm_inherit_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_vm_address_t address; + mach_vm_size_t size; + } __Request__mach_vm_read_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_vm_read_entry_t data_list; + natural_t count; + } __Request__mach_vm_read_list_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_descriptor_t data; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_vm_address_t address; + mach_msg_type_number_t dataCnt; + } __Request__mach_vm_write_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_vm_address_t source_address; + mach_vm_size_t size; + mach_vm_address_t dest_address; + } __Request__mach_vm_copy_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_vm_address_t address; + mach_vm_size_t size; + mach_vm_address_t data; + } __Request__mach_vm_read_overwrite_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_vm_address_t address; + mach_vm_size_t size; + vm_sync_t sync_flags; + } __Request__mach_vm_msync_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_vm_address_t address; + mach_vm_size_t size; + vm_behavior_t new_behavior; + } __Request__mach_vm_behavior_set_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t object; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_vm_address_t address; + mach_vm_size_t size; + mach_vm_offset_t mask; + int flags; + memory_object_offset_t offset; + boolean_t copy; + vm_prot_t cur_protection; + vm_prot_t max_protection; + vm_inherit_t inheritance; + } __Request__mach_vm_map_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_vm_address_t address; + mach_vm_size_t size; + vm_machine_attribute_t attribute; + vm_machine_attribute_val_t value; + } __Request__mach_vm_machine_attribute_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t src_task; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_vm_address_t target_address; + mach_vm_size_t size; + mach_vm_offset_t mask; + boolean_t anywhere; + mach_vm_address_t src_address; + boolean_t copy; + vm_inherit_t inheritance; + } __Request__mach_vm_remap_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_vm_offset_t offset; + } __Request__mach_vm_page_query_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_vm_address_t address; + natural_t nesting_depth; + mach_msg_type_number_t infoCnt; + } __Request__mach_vm_region_recurse_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_vm_address_t address; + vm_region_flavor_t flavor; + mach_msg_type_number_t infoCnt; + } __Request__mach_vm_region_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t parent_handle; + /* end of the kernel processed data */ + NDR_record_t NDR; + memory_object_size_t size; + memory_object_offset_t offset; + vm_prot_t permission; + } __Request___mach_make_memory_entry_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_vm_address_t address; + vm_purgable_t control; + int state; + } __Request__mach_vm_purgable_control_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_vm_address_t address; + vm_page_info_flavor_t flavor; + mach_msg_type_number_t infoCnt; + } __Request__mach_vm_page_info_t; +#ifdef __MigPackStructs +#pragma pack() +#endif +#endif /* !__Request__mach_vm_subsystem__defined */ + +/* union of all requests */ + +#ifndef __RequestUnion__mach_vm_subsystem__defined +#define __RequestUnion__mach_vm_subsystem__defined +union __RequestUnion__mach_vm_subsystem { + __Request__mach_vm_allocate_t Request_mach_vm_allocate; + __Request__mach_vm_deallocate_t Request_mach_vm_deallocate; + __Request__mach_vm_protect_t Request_mach_vm_protect; + __Request__mach_vm_inherit_t Request_mach_vm_inherit; + __Request__mach_vm_read_t Request_mach_vm_read; + __Request__mach_vm_read_list_t Request_mach_vm_read_list; + __Request__mach_vm_write_t Request_mach_vm_write; + __Request__mach_vm_copy_t Request_mach_vm_copy; + __Request__mach_vm_read_overwrite_t Request_mach_vm_read_overwrite; + __Request__mach_vm_msync_t Request_mach_vm_msync; + __Request__mach_vm_behavior_set_t Request_mach_vm_behavior_set; + __Request__mach_vm_map_t Request_mach_vm_map; + __Request__mach_vm_machine_attribute_t Request_mach_vm_machine_attribute; + __Request__mach_vm_remap_t Request_mach_vm_remap; + __Request__mach_vm_page_query_t Request_mach_vm_page_query; + __Request__mach_vm_region_recurse_t Request_mach_vm_region_recurse; + __Request__mach_vm_region_t Request_mach_vm_region; + __Request___mach_make_memory_entry_t Request__mach_make_memory_entry; + __Request__mach_vm_purgable_control_t Request_mach_vm_purgable_control; + __Request__mach_vm_page_info_t Request_mach_vm_page_info; +}; +#endif /* !__RequestUnion__mach_vm_subsystem__defined */ +/* typedefs for all replies */ + +#ifndef __Reply__mach_vm_subsystem__defined +#define __Reply__mach_vm_subsystem__defined + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_vm_address_t address; + } __Reply__mach_vm_allocate_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__mach_vm_deallocate_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__mach_vm_protect_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__mach_vm_inherit_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_descriptor_t data; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t dataCnt; + } __Reply__mach_vm_read_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_vm_read_entry_t data_list; + } __Reply__mach_vm_read_list_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__mach_vm_write_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__mach_vm_copy_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_vm_size_t outsize; + } __Reply__mach_vm_read_overwrite_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__mach_vm_msync_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__mach_vm_behavior_set_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_vm_address_t address; + } __Reply__mach_vm_map_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + vm_machine_attribute_val_t value; + } __Reply__mach_vm_machine_attribute_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_vm_address_t target_address; + vm_prot_t cur_protection; + vm_prot_t max_protection; + } __Reply__mach_vm_remap_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + integer_t disposition; + integer_t ref_count; + } __Reply__mach_vm_page_query_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_vm_address_t address; + mach_vm_size_t size; + natural_t nesting_depth; + mach_msg_type_number_t infoCnt; + int info[19]; + } __Reply__mach_vm_region_recurse_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t object_name; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_vm_address_t address; + mach_vm_size_t size; + mach_msg_type_number_t infoCnt; + int info[10]; + } __Reply__mach_vm_region_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t object_handle; + /* end of the kernel processed data */ + NDR_record_t NDR; + memory_object_size_t size; + } __Reply___mach_make_memory_entry_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + int state; + } __Reply__mach_vm_purgable_control_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_msg_type_number_t infoCnt; + int info[32]; + } __Reply__mach_vm_page_info_t; +#ifdef __MigPackStructs +#pragma pack() +#endif +#endif /* !__Reply__mach_vm_subsystem__defined */ + +/* union of all replies */ + +#ifndef __ReplyUnion__mach_vm_subsystem__defined +#define __ReplyUnion__mach_vm_subsystem__defined +union __ReplyUnion__mach_vm_subsystem { + __Reply__mach_vm_allocate_t Reply_mach_vm_allocate; + __Reply__mach_vm_deallocate_t Reply_mach_vm_deallocate; + __Reply__mach_vm_protect_t Reply_mach_vm_protect; + __Reply__mach_vm_inherit_t Reply_mach_vm_inherit; + __Reply__mach_vm_read_t Reply_mach_vm_read; + __Reply__mach_vm_read_list_t Reply_mach_vm_read_list; + __Reply__mach_vm_write_t Reply_mach_vm_write; + __Reply__mach_vm_copy_t Reply_mach_vm_copy; + __Reply__mach_vm_read_overwrite_t Reply_mach_vm_read_overwrite; + __Reply__mach_vm_msync_t Reply_mach_vm_msync; + __Reply__mach_vm_behavior_set_t Reply_mach_vm_behavior_set; + __Reply__mach_vm_map_t Reply_mach_vm_map; + __Reply__mach_vm_machine_attribute_t Reply_mach_vm_machine_attribute; + __Reply__mach_vm_remap_t Reply_mach_vm_remap; + __Reply__mach_vm_page_query_t Reply_mach_vm_page_query; + __Reply__mach_vm_region_recurse_t Reply_mach_vm_region_recurse; + __Reply__mach_vm_region_t Reply_mach_vm_region; + __Reply___mach_make_memory_entry_t Reply__mach_make_memory_entry; + __Reply__mach_vm_purgable_control_t Reply_mach_vm_purgable_control; + __Reply__mach_vm_page_info_t Reply_mach_vm_page_info; +}; +#endif /* !__RequestUnion__mach_vm_subsystem__defined */ + +#ifndef subsystem_to_name_map_mach_vm +#define subsystem_to_name_map_mach_vm \ + { "mach_vm_allocate", 4800 },\ + { "mach_vm_deallocate", 4801 },\ + { "mach_vm_protect", 4802 },\ + { "mach_vm_inherit", 4803 },\ + { "mach_vm_read", 4804 },\ + { "mach_vm_read_list", 4805 },\ + { "mach_vm_write", 4806 },\ + { "mach_vm_copy", 4807 },\ + { "mach_vm_read_overwrite", 4808 },\ + { "mach_vm_msync", 4809 },\ + { "mach_vm_behavior_set", 4810 },\ + { "mach_vm_map", 4811 },\ + { "mach_vm_machine_attribute", 4812 },\ + { "mach_vm_remap", 4813 },\ + { "mach_vm_page_query", 4814 },\ + { "mach_vm_region_recurse", 4815 },\ + { "mach_vm_region", 4816 },\ + { "_mach_make_memory_entry", 4817 },\ + { "mach_vm_purgable_control", 4818 },\ + { "mach_vm_page_info", 4819 } +#endif + +#ifdef __AfterMigUserHeader +__AfterMigUserHeader +#endif /* __AfterMigUserHeader */ + +#endif /* _mach_vm_user_ */ Index: branches/azimutz/Cleancut/i386/include/mach/thread_status.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/thread_status.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/thread_status.h (revision 885) @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2000-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@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989,1988 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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + */ +/* + * File: mach/thread_status.h + * Author: Avadis Tevanian, Jr. + * + * This file contains the structure definitions for the user-visible + * thread state. This thread state is examined with the thread_get_state + * kernel call and may be changed with the thread_set_state kernel call. + * + */ + +#ifndef _MACH_THREAD_STATUS_H_ +#define _MACH_THREAD_STATUS_H_ + +/* + * The actual structure that comprises the thread state is defined + * in the machine dependent module. + */ +#include <mach/machine/vm_types.h> +#include <mach/machine/thread_status.h> +#include <mach/machine/thread_state.h> + +/* + * Generic definition for machine-dependent thread status. + */ + +typedef natural_t *thread_state_t; /* Variable-length array */ + +/* THREAD_STATE_MAX is now defined in <mach/machine/thread_state.h> */ +typedef natural_t thread_state_data_t[THREAD_STATE_MAX]; + +#define THREAD_STATE_FLAVOR_LIST 0 /* List of valid flavors */ +#define THREAD_STATE_FLAVOR_LIST_NEW 128 + +typedef int thread_state_flavor_t; +typedef thread_state_flavor_t *thread_state_flavor_array_t; + +#endif /* _MACH_THREAD_STATUS_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/std_types.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/std_types.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/std_types.h (revision 885) @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2002,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@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989,1988 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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + */ +/* + * Mach standard external interface type definitions. + * + */ + +#ifndef _MACH_STD_TYPES_H_ +#define _MACH_STD_TYPES_H_ + +#include <stdint.h> +#include <mach/boolean.h> +#include <mach/kern_return.h> +#include <mach/port.h> +#include <mach/vm_types.h> + +#endif /* _MACH_STD_TYPES_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/vm_sync.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/vm_sync.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/vm_sync.h (revision 885) @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2000-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@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989,1988,1987 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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + * File: mach/vm_sync.h + * + * Virtual memory synchronisation definitions. + * + */ + +#ifndef _MACH_VM_SYNC_H_ +#define _MACH_VM_SYNC_H_ + +typedef unsigned vm_sync_t; + +/* + * Synchronization flags, defined as bits within the vm_sync_t type + */ + +#define VM_SYNC_ASYNCHRONOUS ((vm_sync_t) 0x01) +#define VM_SYNC_SYNCHRONOUS ((vm_sync_t) 0x02) +#define VM_SYNC_INVALIDATE ((vm_sync_t) 0x04) +#define VM_SYNC_KILLPAGES ((vm_sync_t) 0x08) +#define VM_SYNC_DEACTIVATE ((vm_sync_t) 0x10) +#define VM_SYNC_CONTIGUOUS ((vm_sync_t) 0x20) +#define VM_SYNC_REUSABLEPAGES ((vm_sync_t) 0x40) + +#endif /* _MACH_VM_SYNC_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/processor.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/processor.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/processor.h (revision 885) @@ -0,0 +1,336 @@ +#ifndef _processor_user_ +#define _processor_user_ + +/* Module processor */ + +#include <string.h> +#include <mach/ndr.h> +#include <mach/boolean.h> +#include <mach/kern_return.h> +#include <mach/notify.h> +#include <mach/mach_types.h> +#include <mach/message.h> +#include <mach/mig_errors.h> +#include <mach/port.h> + +#ifdef AUTOTEST +#ifndef FUNCTION_PTR_T +#define FUNCTION_PTR_T +typedef void (*function_ptr_t)(mach_port_t, char *, mach_msg_type_number_t); +typedef struct { + char *name; + function_ptr_t function; +} function_table_entry; +typedef function_table_entry *function_table_t; +#endif /* FUNCTION_PTR_T */ +#endif /* AUTOTEST */ + +#ifndef processor_MSG_COUNT +#define processor_MSG_COUNT 6 +#endif /* processor_MSG_COUNT */ + +#include <mach/std_types.h> +#include <mach/mig.h> +#include <mach/mach_types.h> + +#ifdef __BeforeMigUserHeader +__BeforeMigUserHeader +#endif /* __BeforeMigUserHeader */ + +#include <sys/cdefs.h> +__BEGIN_DECLS + + +/* Routine processor_start */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t processor_start +( + processor_t processor +); + +/* Routine processor_exit */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t processor_exit +( + processor_t processor +); + +/* Routine processor_info */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t processor_info +( + processor_t processor, + processor_flavor_t flavor, + host_t *host, + processor_info_t processor_info_out, + mach_msg_type_number_t *processor_info_outCnt +); + +/* Routine processor_control */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t processor_control +( + processor_t processor, + processor_info_t processor_cmd, + mach_msg_type_number_t processor_cmdCnt +); + +/* Routine processor_assign */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t processor_assign +( + processor_t processor, + processor_set_t new_set, + boolean_t wait +); + +/* Routine processor_get_assignment */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t processor_get_assignment +( + processor_t processor, + processor_set_name_t *assigned_set +); + +__END_DECLS + +/********************** Caution **************************/ +/* The following data types should be used to calculate */ +/* maximum message sizes only. The actual message may be */ +/* smaller, and the position of the arguments within the */ +/* message layout may vary from what is presented here. */ +/* For example, if any of the arguments are variable- */ +/* sized, and less than the maximum is sent, the data */ +/* will be packed tight in the actual message to reduce */ +/* the presence of holes. */ +/********************** Caution **************************/ + +/* typedefs for all requests */ + +#ifndef __Request__processor_subsystem__defined +#define __Request__processor_subsystem__defined + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__processor_start_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__processor_exit_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + processor_flavor_t flavor; + mach_msg_type_number_t processor_info_outCnt; + } __Request__processor_info_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_msg_type_number_t processor_cmdCnt; + integer_t processor_cmd[12]; + } __Request__processor_control_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t new_set; + /* end of the kernel processed data */ + NDR_record_t NDR; + boolean_t wait; + } __Request__processor_assign_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__processor_get_assignment_t; +#ifdef __MigPackStructs +#pragma pack() +#endif +#endif /* !__Request__processor_subsystem__defined */ + +/* union of all requests */ + +#ifndef __RequestUnion__processor_subsystem__defined +#define __RequestUnion__processor_subsystem__defined +union __RequestUnion__processor_subsystem { + __Request__processor_start_t Request_processor_start; + __Request__processor_exit_t Request_processor_exit; + __Request__processor_info_t Request_processor_info; + __Request__processor_control_t Request_processor_control; + __Request__processor_assign_t Request_processor_assign; + __Request__processor_get_assignment_t Request_processor_get_assignment; +}; +#endif /* !__RequestUnion__processor_subsystem__defined */ +/* typedefs for all replies */ + +#ifndef __Reply__processor_subsystem__defined +#define __Reply__processor_subsystem__defined + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__processor_start_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__processor_exit_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t host; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t processor_info_outCnt; + integer_t processor_info_out[12]; + } __Reply__processor_info_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__processor_control_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__processor_assign_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t assigned_set; + /* end of the kernel processed data */ + } __Reply__processor_get_assignment_t; +#ifdef __MigPackStructs +#pragma pack() +#endif +#endif /* !__Reply__processor_subsystem__defined */ + +/* union of all replies */ + +#ifndef __ReplyUnion__processor_subsystem__defined +#define __ReplyUnion__processor_subsystem__defined +union __ReplyUnion__processor_subsystem { + __Reply__processor_start_t Reply_processor_start; + __Reply__processor_exit_t Reply_processor_exit; + __Reply__processor_info_t Reply_processor_info; + __Reply__processor_control_t Reply_processor_control; + __Reply__processor_assign_t Reply_processor_assign; + __Reply__processor_get_assignment_t Reply_processor_get_assignment; +}; +#endif /* !__RequestUnion__processor_subsystem__defined */ + +#ifndef subsystem_to_name_map_processor +#define subsystem_to_name_map_processor \ + { "processor_start", 3000 },\ + { "processor_exit", 3001 },\ + { "processor_info", 3002 },\ + { "processor_control", 3003 },\ + { "processor_assign", 3004 },\ + { "processor_get_assignment", 3005 } +#endif + +#ifdef __AfterMigUserHeader +__AfterMigUserHeader +#endif /* __AfterMigUserHeader */ + +#endif /* _processor_user_ */ Index: branches/azimutz/Cleancut/i386/include/mach/exc.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/exc.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/exc.h (revision 885) @@ -0,0 +1,257 @@ +#ifndef _exc_user_ +#define _exc_user_ + +/* Module exc */ + +#include <string.h> +#include <mach/ndr.h> +#include <mach/boolean.h> +#include <mach/kern_return.h> +#include <mach/notify.h> +#include <mach/mach_types.h> +#include <mach/message.h> +#include <mach/mig_errors.h> +#include <mach/port.h> + +#ifdef AUTOTEST +#ifndef FUNCTION_PTR_T +#define FUNCTION_PTR_T +typedef void (*function_ptr_t)(mach_port_t, char *, mach_msg_type_number_t); +typedef struct { + char *name; + function_ptr_t function; +} function_table_entry; +typedef function_table_entry *function_table_t; +#endif /* FUNCTION_PTR_T */ +#endif /* AUTOTEST */ + +#ifndef exc_MSG_COUNT +#define exc_MSG_COUNT 3 +#endif /* exc_MSG_COUNT */ + +#include <mach/std_types.h> +#include <mach/mig.h> +#include <mach/mach_types.h> + +#ifdef __BeforeMigUserHeader +__BeforeMigUserHeader +#endif /* __BeforeMigUserHeader */ + +#include <sys/cdefs.h> +__BEGIN_DECLS + + +/* Routine exception_raise */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t exception_raise +( + mach_port_t exception_port, + mach_port_t thread, + mach_port_t task, + exception_type_t exception, + exception_data_t code, + mach_msg_type_number_t codeCnt +); + +/* Routine exception_raise_state */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t exception_raise_state +( + mach_port_t exception_port, + exception_type_t exception, + const exception_data_t code, + mach_msg_type_number_t codeCnt, + int *flavor, + const thread_state_t old_state, + mach_msg_type_number_t old_stateCnt, + thread_state_t new_state, + mach_msg_type_number_t *new_stateCnt +); + +/* Routine exception_raise_state_identity */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t exception_raise_state_identity +( + mach_port_t exception_port, + mach_port_t thread, + mach_port_t task, + exception_type_t exception, + exception_data_t code, + mach_msg_type_number_t codeCnt, + int *flavor, + thread_state_t old_state, + mach_msg_type_number_t old_stateCnt, + thread_state_t new_state, + mach_msg_type_number_t *new_stateCnt +); + +__END_DECLS + +/********************** Caution **************************/ +/* The following data types should be used to calculate */ +/* maximum message sizes only. The actual message may be */ +/* smaller, and the position of the arguments within the */ +/* message layout may vary from what is presented here. */ +/* For example, if any of the arguments are variable- */ +/* sized, and less than the maximum is sent, the data */ +/* will be packed tight in the actual message to reduce */ +/* the presence of holes. */ +/********************** Caution **************************/ + +/* typedefs for all requests */ + +#ifndef __Request__exc_subsystem__defined +#define __Request__exc_subsystem__defined + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t thread; + mach_msg_port_descriptor_t task; + /* end of the kernel processed data */ + NDR_record_t NDR; + exception_type_t exception; + mach_msg_type_number_t codeCnt; + integer_t code[2]; + } __Request__exception_raise_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + exception_type_t exception; + mach_msg_type_number_t codeCnt; + integer_t code[2]; + int flavor; + mach_msg_type_number_t old_stateCnt; + natural_t old_state[144]; + } __Request__exception_raise_state_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t thread; + mach_msg_port_descriptor_t task; + /* end of the kernel processed data */ + NDR_record_t NDR; + exception_type_t exception; + mach_msg_type_number_t codeCnt; + integer_t code[2]; + int flavor; + mach_msg_type_number_t old_stateCnt; + natural_t old_state[144]; + } __Request__exception_raise_state_identity_t; +#ifdef __MigPackStructs +#pragma pack() +#endif +#endif /* !__Request__exc_subsystem__defined */ + +/* union of all requests */ + +#ifndef __RequestUnion__exc_subsystem__defined +#define __RequestUnion__exc_subsystem__defined +union __RequestUnion__exc_subsystem { + __Request__exception_raise_t Request_exception_raise; + __Request__exception_raise_state_t Request_exception_raise_state; + __Request__exception_raise_state_identity_t Request_exception_raise_state_identity; +}; +#endif /* !__RequestUnion__exc_subsystem__defined */ +/* typedefs for all replies */ + +#ifndef __Reply__exc_subsystem__defined +#define __Reply__exc_subsystem__defined + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__exception_raise_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + int flavor; + mach_msg_type_number_t new_stateCnt; + natural_t new_state[144]; + } __Reply__exception_raise_state_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + int flavor; + mach_msg_type_number_t new_stateCnt; + natural_t new_state[144]; + } __Reply__exception_raise_state_identity_t; +#ifdef __MigPackStructs +#pragma pack() +#endif +#endif /* !__Reply__exc_subsystem__defined */ + +/* union of all replies */ + +#ifndef __ReplyUnion__exc_subsystem__defined +#define __ReplyUnion__exc_subsystem__defined +union __ReplyUnion__exc_subsystem { + __Reply__exception_raise_t Reply_exception_raise; + __Reply__exception_raise_state_t Reply_exception_raise_state; + __Reply__exception_raise_state_identity_t Reply_exception_raise_state_identity; +}; +#endif /* !__RequestUnion__exc_subsystem__defined */ + +#ifndef subsystem_to_name_map_exc +#define subsystem_to_name_map_exc \ + { "exception_raise", 2401 },\ + { "exception_raise_state", 2402 },\ + { "exception_raise_state_identity", 2403 } +#endif + +#ifdef __AfterMigUserHeader +__AfterMigUserHeader +#endif /* __AfterMigUserHeader */ + +#endif /* _exc_user_ */ Index: branches/azimutz/Cleancut/i386/include/mach/thread_info.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/thread_info.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/thread_info.h (revision 885) @@ -0,0 +1,154 @@ +/* + * Copyright (c) 2000-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@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989,1988,1987 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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + */ +/* + * File: mach/thread_info + * + * Thread information structure and definitions. + * + * The defintions in this file are exported to the user. The kernel + * will translate its internal data structures to these structures + * as appropriate. + * + */ + +#ifndef _MACH_THREAD_INFO_H_ +#define _MACH_THREAD_INFO_H_ + +#include <mach/boolean.h> +#include <mach/policy.h> +#include <mach/time_value.h> +#include <mach/message.h> +#include <mach/machine/vm_types.h> + +/* + * Generic information structure to allow for expansion. + */ +typedef natural_t thread_flavor_t; +typedef integer_t *thread_info_t; /* varying array of int */ + +#define THREAD_INFO_MAX (1024) /* maximum array size */ +typedef integer_t thread_info_data_t[THREAD_INFO_MAX]; + +/* + * Currently defined information. + */ +#define THREAD_BASIC_INFO 3 /* basic information */ + +struct thread_basic_info { + time_value_t user_time; /* user run time */ + time_value_t system_time; /* system run time */ + integer_t cpu_usage; /* scaled cpu usage percentage */ + policy_t policy; /* scheduling policy in effect */ + integer_t run_state; /* run state (see below) */ + integer_t flags; /* various flags (see below) */ + integer_t suspend_count; /* suspend count for thread */ + integer_t sleep_time; /* number of seconds that thread + has been sleeping */ +}; + +typedef struct thread_basic_info thread_basic_info_data_t; +typedef struct thread_basic_info *thread_basic_info_t; +#define THREAD_BASIC_INFO_COUNT ((mach_msg_type_number_t) \ + (sizeof(thread_basic_info_data_t) / sizeof(natural_t))) + +#define THREAD_IDENTIFIER_INFO 4 /* thread id and other information */ + +struct thread_identifier_info { + uint64_t thread_id; /* system-wide unique 64-bit thread id */ + uint64_t thread_handle; /* handle to be used by libproc */ + uint64_t dispatch_qaddr; /* libdispatch queue address */ +}; + +typedef struct thread_identifier_info thread_identifier_info_data_t; +typedef struct thread_identifier_info *thread_identifier_info_t; +#define THREAD_IDENTIFIER_INFO_COUNT ((mach_msg_type_number_t) \ + (sizeof(thread_identifier_info_data_t) / sizeof(natural_t))) + +/* + * Scale factor for usage field. + */ + +#define TH_USAGE_SCALE 1000 + +/* + * Thread run states (state field). + */ + +#define TH_STATE_RUNNING 1 /* thread is running normally */ +#define TH_STATE_STOPPED 2 /* thread is stopped */ +#define TH_STATE_WAITING 3 /* thread is waiting normally */ +#define TH_STATE_UNINTERRUPTIBLE 4 /* thread is in an uninterruptible + wait */ +#define TH_STATE_HALTED 5 /* thread is halted at a + clean point */ + +/* + * Thread flags (flags field). + */ +#define TH_FLAGS_SWAPPED 0x1 /* thread is swapped out */ +#define TH_FLAGS_IDLE 0x2 /* thread is an idle thread */ + +/* + * Obsolete interfaces. + */ + +#define THREAD_SCHED_TIMESHARE_INFO 10 +#define THREAD_SCHED_RR_INFO 11 +#define THREAD_SCHED_FIFO_INFO 12 + +#endif /* _MACH_THREAD_INFO_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/semaphore.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/semaphore.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/semaphore.h (revision 885) @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2000-2008 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 _MACH_SEMAPHORE_H_ +#define _MACH_SEMAPHORE_H_ + +#include <mach/port.h> +#include <mach/mach_types.h> +#include <mach/kern_return.h> +#include <mach/sync_policy.h> + +/* + * Forward Declarations + * + * The semaphore creation and deallocation routines are + * defined with the Mach task APIs in <mach/task.h>. + * + * kern_return_t semaphore_create(task_t task, + * semaphore_t *new_semaphore, + * sync_policy_t policy, + * int value); + * + * kern_return_t semaphore_destroy(task_t task, + * semaphore_t semaphore); + */ + +#include <sys/cdefs.h> +__BEGIN_DECLS + +extern kern_return_t semaphore_signal (semaphore_t semaphore); +extern kern_return_t semaphore_signal_all (semaphore_t semaphore); + +extern kern_return_t semaphore_wait (semaphore_t semaphore); + + +extern kern_return_t semaphore_timedwait (semaphore_t semaphore, + mach_timespec_t wait_time); + +extern kern_return_t semaphore_timedwait_signal(semaphore_t wait_semaphore, + semaphore_t signal_semaphore, + mach_timespec_t wait_time); + +extern kern_return_t semaphore_wait_signal (semaphore_t wait_semaphore, + semaphore_t signal_semaphore); + +extern kern_return_t semaphore_signal_thread (semaphore_t semaphore, + thread_t thread); + + +__END_DECLS + + +#endif /* _MACH_SEMAPHORE_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/port.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/port.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/port.h (revision 885) @@ -0,0 +1,319 @@ +/* + * Copyright (c) 2000-2006 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,1988,1987 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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + * NOTICE: This file was modified by McAfee Research in 2004 to introduce + * support for mandatory and extensible security protections. This notice + * is included in support of clause 2.2 (b) of the Apple Public License, + * Version 2.0. + */ +/* + */ +/* + * File: mach/port.h + * + * Definition of a Mach port + * + * Mach ports are the endpoints to Mach-implemented communications + * channels (usually uni-directional message queues, but other types + * also exist). + * + * Unique collections of these endpoints are maintained for each + * Mach task. Each Mach port in the task's collection is given a + * [task-local] name to identify it - and the the various "rights" + * held by the task for that specific endpoint. + * + * This header defines the types used to identify these Mach ports + * and the various rights associated with them. For more info see: + * + * <mach/mach_port.h> - manipulation of port rights in a given space + * <mach/message.h> - message queue [and port right passing] mechanism + * + */ + +#ifndef _MACH_PORT_H_ +#define _MACH_PORT_H_ + +#include <sys/cdefs.h> +#include <stdint.h> +#include <mach/boolean.h> +#include <mach/machine/vm_types.h> + +/* + * mach_port_name_t - the local identity for a Mach port + * + * The name is Mach port namespace specific. It is used to + * identify the rights held for that port by the task whose + * namespace is implied [or specifically provided]. + * + * Use of this type usually implies just a name - no rights. + * See mach_port_t for a type that implies a "named right." + * + */ + +typedef natural_t mach_port_name_t; +typedef mach_port_name_t *mach_port_name_array_t; + + +/* + * mach_port_t - a named port right + * + * In user-space, "rights" are represented by the name of the + * right in the Mach port namespace. Even so, this type is + * presented as a unique one to more clearly denote the presence + * of a right coming along with the name. + * + * Often, various rights for a port held in a single name space + * will coalesce and are, therefore, be identified by a single name + * [this is the case for send and receive rights]. But not + * always [send-once rights currently get a unique name for + * each right]. + * + */ + +#ifndef _MACH_PORT_T +#define _MACH_PORT_T +typedef mach_port_name_t mach_port_t; +#endif + + +typedef mach_port_t *mach_port_array_t; + +/* + * MACH_PORT_NULL is a legal value that can be carried in messages. + * It indicates the absence of any port or port rights. (A port + * argument keeps the message from being "simple", even if the + * value is MACH_PORT_NULL.) The value MACH_PORT_DEAD is also a legal + * value that can be carried in messages. It indicates + * that a port right was present, but it died. + */ + +#define MACH_PORT_NULL 0 /* intentional loose typing */ +#define MACH_PORT_DEAD ((mach_port_name_t) ~0) +#define MACH_PORT_VALID(name) \ + (((name) != MACH_PORT_NULL) && \ + ((name) != MACH_PORT_DEAD)) + + +/* + * For kernel-selected [assigned] port names, the name is + * comprised of two parts: a generation number and an index. + * This approach keeps the exact same name from being generated + * and reused too quickly [to catch right/reference counting bugs]. + * The dividing line between the constituent parts is exposed so + * that efficient "mach_port_name_t to data structure pointer" + * conversion implementation can be made. But it is possible + * for user-level code to assign their own names to Mach ports. + * These are not required to participate in this algorithm. So + * care should be taken before "assuming" this model. + * + */ + +#ifndef NO_PORT_GEN + +#define MACH_PORT_INDEX(name) ((name) >> 8) +#define MACH_PORT_GEN(name) (((name) & 0xff) << 24) +#define MACH_PORT_MAKE(index, gen) \ + (((index) << 8) | (gen) >> 24) + +#else /* NO_PORT_GEN */ + +#define MACH_PORT_INDEX(name) (name) +#define MACH_PORT_GEN(name) (0) +#define MACH_PORT_MAKE(index, gen) (index) + +#endif /* NO_PORT_GEN */ + + +/* + * These are the different rights a task may have for a port. + * The MACH_PORT_RIGHT_* definitions are used as arguments + * to mach_port_allocate, mach_port_get_refs, etc, to specify + * a particular right to act upon. The mach_port_names and + * mach_port_type calls return bitmasks using the MACH_PORT_TYPE_* + * definitions. This is because a single name may denote + * multiple rights. + */ + +typedef natural_t mach_port_right_t; + +#define MACH_PORT_RIGHT_SEND ((mach_port_right_t) 0) +#define MACH_PORT_RIGHT_RECEIVE ((mach_port_right_t) 1) +#define MACH_PORT_RIGHT_SEND_ONCE ((mach_port_right_t) 2) +#define MACH_PORT_RIGHT_PORT_SET ((mach_port_right_t) 3) +#define MACH_PORT_RIGHT_DEAD_NAME ((mach_port_right_t) 4) +#define MACH_PORT_RIGHT_LABELH ((mach_port_right_t) 5) +#define MACH_PORT_RIGHT_NUMBER ((mach_port_right_t) 6) + +typedef natural_t mach_port_type_t; +typedef mach_port_type_t *mach_port_type_array_t; + +#define MACH_PORT_TYPE(right) \ + ((mach_port_type_t)(((mach_port_type_t) 1) \ + << ((right) + ((mach_port_right_t) 16)))) +#define MACH_PORT_TYPE_NONE ((mach_port_type_t) 0L) +#define MACH_PORT_TYPE_SEND MACH_PORT_TYPE(MACH_PORT_RIGHT_SEND) +#define MACH_PORT_TYPE_RECEIVE MACH_PORT_TYPE(MACH_PORT_RIGHT_RECEIVE) +#define MACH_PORT_TYPE_SEND_ONCE MACH_PORT_TYPE(MACH_PORT_RIGHT_SEND_ONCE) +#define MACH_PORT_TYPE_PORT_SET MACH_PORT_TYPE(MACH_PORT_RIGHT_PORT_SET) +#define MACH_PORT_TYPE_DEAD_NAME MACH_PORT_TYPE(MACH_PORT_RIGHT_DEAD_NAME) +#define MACH_PORT_TYPE_LABELH MACH_PORT_TYPE(MACH_PORT_RIGHT_LABELH) + +/* Convenient combinations. */ + +#define MACH_PORT_TYPE_SEND_RECEIVE \ + (MACH_PORT_TYPE_SEND|MACH_PORT_TYPE_RECEIVE) +#define MACH_PORT_TYPE_SEND_RIGHTS \ + (MACH_PORT_TYPE_SEND|MACH_PORT_TYPE_SEND_ONCE) +#define MACH_PORT_TYPE_PORT_RIGHTS \ + (MACH_PORT_TYPE_SEND_RIGHTS|MACH_PORT_TYPE_RECEIVE) +#define MACH_PORT_TYPE_PORT_OR_DEAD \ + (MACH_PORT_TYPE_PORT_RIGHTS|MACH_PORT_TYPE_DEAD_NAME) +#define MACH_PORT_TYPE_ALL_RIGHTS \ + (MACH_PORT_TYPE_PORT_OR_DEAD|MACH_PORT_TYPE_PORT_SET) + +/* Dummy type bits that mach_port_type/mach_port_names can return. */ + +#define MACH_PORT_TYPE_DNREQUEST 0x80000000 + +/* User-references for capabilities. */ + +typedef natural_t mach_port_urefs_t; +typedef integer_t mach_port_delta_t; /* change in urefs */ + +/* Attributes of ports. (See mach_port_get_receive_status.) */ + +typedef natural_t mach_port_seqno_t; /* sequence number */ +typedef natural_t mach_port_mscount_t; /* make-send count */ +typedef natural_t mach_port_msgcount_t; /* number of msgs */ +typedef natural_t mach_port_rights_t; /* number of rights */ + +/* + * Are there outstanding send rights for a given port? + */ +#define MACH_PORT_SRIGHTS_NONE 0 /* no srights */ +#define MACH_PORT_SRIGHTS_PRESENT 1 /* srights */ +typedef unsigned int mach_port_srights_t; /* status of send rights */ + +typedef struct mach_port_status { + mach_port_rights_t mps_pset; /* count of containing port sets */ + mach_port_seqno_t mps_seqno; /* sequence number */ + mach_port_mscount_t mps_mscount; /* make-send count */ + mach_port_msgcount_t mps_qlimit; /* queue limit */ + mach_port_msgcount_t mps_msgcount; /* number in the queue */ + mach_port_rights_t mps_sorights; /* how many send-once rights */ + boolean_t mps_srights; /* do send rights exist? */ + boolean_t mps_pdrequest; /* port-deleted requested? */ + boolean_t mps_nsrequest; /* no-senders requested? */ + natural_t mps_flags; /* port flags */ +} mach_port_status_t; + +/* System-wide values for setting queue limits on a port */ +#define MACH_PORT_QLIMIT_ZERO ((mach_port_msgcount_t) 0) +#define MACH_PORT_QLIMIT_BASIC ((mach_port_msgcount_t) 5) +#define MACH_PORT_QLIMIT_SMALL ((mach_port_msgcount_t) 16) +#define MACH_PORT_QLIMIT_LARGE ((mach_port_msgcount_t) 1024) +#define MACH_PORT_QLIMIT_KERNEL ((mach_port_msgcount_t) 65536) +#define MACH_PORT_QLIMIT_MIN MACH_PORT_QLIMIT_ZERO +#define MACH_PORT_QLIMIT_DEFAULT MACH_PORT_QLIMIT_BASIC +#define MACH_PORT_QLIMIT_MAX MACH_PORT_QLIMIT_LARGE + +typedef struct mach_port_limits { + mach_port_msgcount_t mpl_qlimit; /* number of msgs */ +} mach_port_limits_t; + +typedef integer_t *mach_port_info_t; /* varying array of natural_t */ + +/* Flavors for mach_port_get/set_attributes() */ +typedef int mach_port_flavor_t; +#define MACH_PORT_LIMITS_INFO 1 /* uses mach_port_status_t */ +#define MACH_PORT_RECEIVE_STATUS 2 /* uses mach_port_limits_t */ +#define MACH_PORT_DNREQUESTS_SIZE 3 /* info is int */ + +#define MACH_PORT_LIMITS_INFO_COUNT ((natural_t) \ + (sizeof(mach_port_limits_t)/sizeof(natural_t))) +#define MACH_PORT_RECEIVE_STATUS_COUNT ((natural_t) \ + (sizeof(mach_port_status_t)/sizeof(natural_t))) +#define MACH_PORT_DNREQUESTS_SIZE_COUNT 1 + +/* + * Structure used to pass information about port allocation requests. + * Must be padded to 64-bits total length. + */ +typedef struct mach_port_qos { + unsigned int name:1; /* name given */ + unsigned int prealloc:1; /* prealloced message */ + boolean_t pad1:30; + natural_t len; +} mach_port_qos_t; + +#if !__DARWIN_UNIX03 && !defined(_NO_PORT_T_FROM_MACH) +/* + * Mach 3.0 renamed everything to have mach_ in front of it. + * These types and macros are provided for backward compatibility + * but are deprecated. + */ +typedef mach_port_t port_t; +typedef mach_port_name_t port_name_t; +typedef mach_port_name_t *port_name_array_t; + +#define PORT_NULL ((port_t) 0) +#define PORT_DEAD ((port_t) ~0) +#define PORT_VALID(name) \ + ((port_t)(name) != PORT_NULL && (port_t)(name) != PORT_DEAD) + +#endif /* !__DARWIN_UNIX03 && !_NO_PORT_T_FROM_MACH */ + +#endif /* _MACH_PORT_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/processor_set.defs =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/processor_set.defs (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/processor_set.defs (revision 885) @@ -0,0 +1,161 @@ +/* + * Copyright (c) 2000-2006 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_FREE_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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + */ +/* + * File: mach/mach_port.defs + * Author: Rich Draves + * + * Exported kernel calls. + */ + +subsystem +#if KERNEL_SERVER + KernelServer +#endif /* KERNEL_SERVER */ + processor_set 4000; + +#include <mach/std_types.defs> +#include <mach/mach_types.defs> + +/* + * Return scheduling statistics for a processor set. + */ +routine processor_set_statistics( + pset : processor_set_name_t; + flavor : processor_set_flavor_t; + out info_out : processor_set_info_t, CountInOut); + + +/* + * Destroy processor set. + */ +routine processor_set_destroy( + set : processor_set_t); + + +/* + * Set max priority for processor_set. + */ +routine processor_set_max_priority( + processor_set : processor_set_t; + max_priority : int; + change_threads : boolean_t); + +/* + * Enable policy for processor set + */ +routine processor_set_policy_enable( + processor_set : processor_set_t; + policy : int); + +/* + * Disable policy for processor set + */ +routine processor_set_policy_disable( + processor_set : processor_set_t; + policy : int; + change_threads : boolean_t); + +/* + * List all tasks in processor set. + */ +routine processor_set_tasks( + processor_set : processor_set_t; + out task_list : task_array_t); + +/* + * List all threads in processor set. + */ +routine processor_set_threads( + processor_set : processor_set_t; + out thread_list : thread_act_array_t); + +/* + * Controls the scheduling attributes governing the processor set. + * Allows control of enabled policies, and per-policy base and limit + * priorities. + */ +routine processor_set_policy_control( + pset : processor_set_t; + flavor : processor_set_flavor_t; + policy_info : processor_set_info_t; + change : boolean_t); + + +/* + * Debug Info + * This call is only valid on MACH_DEBUG kernels. + * Otherwise, KERN_FAILURE is returned. + */ +routine processor_set_stack_usage( + pset : processor_set_t; + out ltotal : unsigned; + out space : vm_size_t; + out resident : vm_size_t; + out maxusage : vm_size_t; + out maxstack : vm_offset_t); + +/* + * Get information about processor set. + */ +routine processor_set_info( + set_name : processor_set_name_t; + flavor : int; + out host : host_t; + out info_out : processor_set_info_t, CountInOut); + +/* vim: set ft=c : */ Index: branches/azimutz/Cleancut/i386/include/mach/rpc.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/rpc.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/rpc.h (revision 885) @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2002,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@ + */ +/* + * @OSF_COPYRIGHT@ + */ + +/* + * Mach RPC Subsystem Interfaces + */ + +#ifndef _MACH_RPC_H_ +#define _MACH_RPC_H_ + +#include <mach/boolean.h> +#include <mach/kern_return.h> +#include <mach/port.h> +#include <mach/vm_types.h> + +#include <mach/mig.h> +#include <mach/mig_errors.h> +#include <mach/machine/rpc.h> +#include <mach/thread_status.h> + +/* + * These are the types for RPC-specific variants of the MIG routine + * descriptor and subsystem data types. + * + * THIS IS ONLY FOR COMPATIBILITY. WE WILL NOT BE IMPLEMENTING THIS. + */ + +/* + * Basic mach rpc types. + */ +typedef unsigned int routine_arg_type; +typedef unsigned int routine_arg_offset; +typedef unsigned int routine_arg_size; + +/* + * Definitions for a signature's argument and routine descriptor's. + */ +struct rpc_routine_arg_descriptor { + routine_arg_type type; /* Port, Array, etc. */ + routine_arg_size size; /* element size in bytes */ + routine_arg_size count; /* number of elements */ + routine_arg_offset offset; /* Offset in list of routine args */ +}; +typedef struct rpc_routine_arg_descriptor *rpc_routine_arg_descriptor_t; + +struct rpc_routine_descriptor { + mig_impl_routine_t impl_routine; /* Server work func pointer */ + mig_stub_routine_t stub_routine; /* Unmarshalling func pointer */ + unsigned int argc; /* Number of argument words */ + unsigned int descr_count; /* Number of complex argument */ + /* descriptors */ + rpc_routine_arg_descriptor_t + arg_descr; /* Pointer to beginning of */ + /* the arg_descr array */ + unsigned int max_reply_msg; /* Max size for reply msg */ +}; +typedef struct rpc_routine_descriptor *rpc_routine_descriptor_t; + +#define RPC_DESCR_SIZE(x) ((x)->descr_count * \ + sizeof(struct rpc_routine_arg_descriptor)) + +struct rpc_signature { + struct rpc_routine_descriptor rd; + struct rpc_routine_arg_descriptor rad[1]; +}; + +#define RPC_SIGBUF_SIZE 8 + +/* + * A subsystem describes a set of server routines that can be invoked by + * mach_rpc() on the ports that are registered with the subsystem. For + * each routine, the routine number is given, along with the + * address of the implementation function in the server and a + * description of the arguments of the routine (it's "signature"). + * + * This structure definition is only a template for what is really a + * variable-length structure (generated by MIG for each subsystem). + * The actual structures do not always have one entry in the routine + * array, and also have a varying number of entries in the arg_descr + * array. Each routine has an array of zero or more arg descriptors + * one for each complex arg. These arrays are all catenated together + * to form the arg_descr field of the subsystem struct. The + * arg_descr field of each routine entry points to a unique sub-sequence + * within this catenated array. The goal is to keep everything + * contiguous. + */ +struct rpc_subsystem { + void *reserved; /* Reserved for system use */ + + mach_msg_id_t start; /* Min routine number */ + mach_msg_id_t end; /* Max routine number + 1 */ + unsigned int maxsize; /* Max mach_msg size */ + vm_address_t base_addr; /* Address of this struct in user */ + + struct rpc_routine_descriptor /* Array of routine descriptors */ + routine[1 /* Actually, (start-end+1) */ + ]; + + struct rpc_routine_arg_descriptor + arg_descriptor[1 /* Actually, the sum of the descr_ */ + ]; /* count fields for all routines */ +}; +typedef struct rpc_subsystem *rpc_subsystem_t; + +#define RPC_SUBSYSTEM_NULL ((rpc_subsystem_t) 0) + +#endif /* _MACH_RPC_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/shared_memory_server.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/shared_memory_server.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/shared_memory_server.h (revision 885) @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2000-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@ + */ +/* + * + * File: mach/shared_memory_server.h + * + * protos and struct definitions for shared library + * server and interface + */ + +/* + * XXX + * + * NOTE: this file is deprecated and will be removed in the near future. + * Any project that includes this file should be changed to: + * 1. use <mach/shared_region.h> instead of this file, + * 2. handle the new shared regions, now available on more platforms + */ + +#ifndef _MACH_SHARED_MEMORY_SERVER_H_ +#define _MACH_SHARED_MEMORY_SERVER_H_ + +#warning "<mach/shared_memory_server.h> is deprecated. Please use <mach/shared_region.h> instead." + +#include <sys/cdefs.h> +#include <mach/vm_prot.h> +#include <mach/vm_types.h> +#include <mach/mach_types.h> + +#define VM_PROT_COW 0x8 /* must not interfere with normal prot assignments */ +#define VM_PROT_ZF 0x10 /* must not interfere with normal prot assignments */ + +#ifdef __arm__ +#define GLOBAL_SHARED_TEXT_SEGMENT 0x30000000U +#define GLOBAL_SHARED_DATA_SEGMENT 0x38000000U +#define GLOBAL_SHARED_SEGMENT_MASK 0xF8000000U + +#define SHARED_TEXT_REGION_SIZE 0x08000000 +#define SHARED_DATA_REGION_SIZE 0x08000000 +#else +#define GLOBAL_SHARED_TEXT_SEGMENT 0x90000000U +#define GLOBAL_SHARED_DATA_SEGMENT 0xA0000000U +#define GLOBAL_SHARED_SEGMENT_MASK 0xF0000000U + +#define SHARED_TEXT_REGION_SIZE 0x10000000 +#define SHARED_DATA_REGION_SIZE 0x10000000 +#endif + +#if !defined(__LP64__) + +#define SHARED_LIBRARY_SERVER_SUPPORTED + +#define SHARED_ALTERNATE_LOAD_BASE 0x09000000 + +/* + * Note: the two masks below are useful because the assumption is + * made that these shared regions will always be mapped on natural boundaries + * i.e. if the size is 0x10000000 the object can be mapped at + * 0x20000000, or 0x30000000, but not 0x1000000 + */ +#ifdef __arm__ +#define SHARED_TEXT_REGION_MASK 0x07FFFFFF +#define SHARED_DATA_REGION_MASK 0x07FFFFFF +#else +#define SHARED_TEXT_REGION_MASK 0x0FFFFFFF +#define SHARED_DATA_REGION_MASK 0x0FFFFFFF +#endif + + +/* flags field aliases for copyin_shared_file and load_shared_file */ + +/* IN */ +#define ALTERNATE_LOAD_SITE 0x1 +#define NEW_LOCAL_SHARED_REGIONS 0x2 +#define QUERY_IS_SYSTEM_REGION 0x4 + +/* OUT */ +#define SF_PREV_LOADED 0x1 +#define SYSTEM_REGION_BACKED 0x2 + + +struct sf_mapping { + vm_offset_t mapping_offset; + vm_size_t size; + vm_offset_t file_offset; + vm_prot_t protection; /* read/write/execute/COW/ZF */ + vm_offset_t cksum; +}; +typedef struct sf_mapping sf_mapping_t; + +#endif /* !defined(__LP64__) */ + +/* + * All shared_region_* declarations are a private interface + * between dyld and the kernel. + * + */ +struct shared_file_mapping_np { + mach_vm_address_t sfm_address; + mach_vm_size_t sfm_size; + mach_vm_offset_t sfm_file_offset; + vm_prot_t sfm_max_prot; + vm_prot_t sfm_init_prot; +}; + +struct shared_region_range_np { + mach_vm_address_t srr_address; + mach_vm_size_t srr_size; +}; + + +__BEGIN_DECLS +int shared_region_map_file_np(int fd, + uint32_t mappingCount, + const struct shared_file_mapping_np *mappings, + int64_t *slide_p); +int shared_region_make_private_np(uint32_t rangeCount, + const struct shared_region_range_np *ranges); +__END_DECLS + + +#endif /* _MACH_SHARED_MEMORY_SERVER_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/host_info.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/host_info.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/host_info.h (revision 885) @@ -0,0 +1,218 @@ +/* + * Copyright (c) 2000-2009 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@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989,1988 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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + */ + +/* + * File: mach/host_info.h + * + * Definitions for host_info call. + */ + +#ifndef _MACH_HOST_INFO_H_ +#define _MACH_HOST_INFO_H_ + +#include <mach/message.h> +#include <mach/vm_statistics.h> +#include <mach/machine.h> +#include <mach/machine/vm_types.h> +#include <mach/time_value.h> + +#include <sys/cdefs.h> + +/* + * Generic information structure to allow for expansion. + */ +typedef integer_t *host_info_t; /* varying array of int. */ +typedef integer_t *host_info64_t; /* varying array of int. */ + +#define HOST_INFO_MAX (1024) /* max array size */ +typedef integer_t host_info_data_t[HOST_INFO_MAX]; + +#define KERNEL_VERSION_MAX (512) +typedef char kernel_version_t[KERNEL_VERSION_MAX]; + +#define KERNEL_BOOT_INFO_MAX (4096) +typedef char kernel_boot_info_t[KERNEL_BOOT_INFO_MAX]; + +/* + * Currently defined information. + */ +/* host_info() */ +typedef integer_t host_flavor_t; +#define HOST_BASIC_INFO 1 /* basic info */ +#define HOST_SCHED_INFO 3 /* scheduling info */ +#define HOST_RESOURCE_SIZES 4 /* kernel struct sizes */ +#define HOST_PRIORITY_INFO 5 /* priority information */ +#define HOST_SEMAPHORE_TRAPS 7 /* Has semaphore traps */ +#define HOST_MACH_MSG_TRAP 8 /* Has mach_msg_trap */ + + +#pragma pack(4) + +struct host_basic_info { + integer_t max_cpus; /* max number of CPUs possible */ + integer_t avail_cpus; /* number of CPUs now available */ + natural_t memory_size; /* size of memory in bytes, capped at 2 GB */ + cpu_type_t cpu_type; /* cpu type */ + cpu_subtype_t cpu_subtype; /* cpu subtype */ + cpu_threadtype_t cpu_threadtype; /* cpu threadtype */ + integer_t physical_cpu; /* number of physical CPUs now available */ + integer_t physical_cpu_max; /* max number of physical CPUs possible */ + integer_t logical_cpu; /* number of logical cpu now available */ + integer_t logical_cpu_max; /* max number of physical CPUs possible */ + uint64_t max_mem; /* actual size of physical memory */ +}; + +#pragma pack() + +typedef struct host_basic_info host_basic_info_data_t; +typedef struct host_basic_info *host_basic_info_t; +#define HOST_BASIC_INFO_COUNT ((mach_msg_type_number_t) \ + (sizeof(host_basic_info_data_t)/sizeof(integer_t))) + +struct host_sched_info { + integer_t min_timeout; /* minimum timeout in milliseconds */ + integer_t min_quantum; /* minimum quantum in milliseconds */ +}; + +typedef struct host_sched_info host_sched_info_data_t; +typedef struct host_sched_info *host_sched_info_t; +#define HOST_SCHED_INFO_COUNT ((mach_msg_type_number_t) \ + (sizeof(host_sched_info_data_t)/sizeof(integer_t))) + +struct kernel_resource_sizes { + natural_t task; + natural_t thread; + natural_t port; + natural_t memory_region; + natural_t memory_object; +}; + +typedef struct kernel_resource_sizes kernel_resource_sizes_data_t; +typedef struct kernel_resource_sizes *kernel_resource_sizes_t; +#define HOST_RESOURCE_SIZES_COUNT ((mach_msg_type_number_t) \ + (sizeof(kernel_resource_sizes_data_t)/sizeof(integer_t))) + +struct host_priority_info { + integer_t kernel_priority; + integer_t system_priority; + integer_t server_priority; + integer_t user_priority; + integer_t depress_priority; + integer_t idle_priority; + integer_t minimum_priority; + integer_t maximum_priority; +}; + +typedef struct host_priority_info host_priority_info_data_t; +typedef struct host_priority_info *host_priority_info_t; +#define HOST_PRIORITY_INFO_COUNT ((mach_msg_type_number_t) \ + (sizeof(host_priority_info_data_t)/sizeof(integer_t))) + +/* host_statistics() */ +#define HOST_LOAD_INFO 1 /* System loading stats */ +#define HOST_VM_INFO 2 /* Virtual memory stats */ +#define HOST_CPU_LOAD_INFO 3 /* CPU load stats */ + +/* host_statistics64() */ +#define HOST_VM_INFO64 4 /* 64-bit virtual memory stats */ + + +struct host_load_info { + integer_t avenrun[3]; /* scaled by LOAD_SCALE */ + integer_t mach_factor[3]; /* scaled by LOAD_SCALE */ +}; + +typedef struct host_load_info host_load_info_data_t; +typedef struct host_load_info *host_load_info_t; +#define HOST_LOAD_INFO_COUNT ((mach_msg_type_number_t) \ + (sizeof(host_load_info_data_t)/sizeof(integer_t))) + +/* in <mach/vm_statistics.h> */ +/* vm_statistics64 */ +#define HOST_VM_INFO64_COUNT ((mach_msg_type_number_t) \ + (sizeof(vm_statistics64_data_t)/sizeof(integer_t))) + +/* size of the latest version of the structure */ +#define HOST_VM_INFO64_LATEST_COUNT HOST_VM_INFO64_COUNT + + +/* vm_statistics */ +#define HOST_VM_INFO_COUNT ((mach_msg_type_number_t) \ + (sizeof(vm_statistics_data_t)/sizeof(integer_t))) + +/* size of the latest version of the structure */ +#define HOST_VM_INFO_LATEST_COUNT HOST_VM_INFO_COUNT +#define HOST_VM_INFO_REV2_COUNT HOST_VM_INFO_LATEST_COUNT +/* previous versions: adjust the size according to what was added each time */ +#define HOST_VM_INFO_REV1_COUNT /* added "speculative_count" (1 int) */ \ + ((mach_msg_type_number_t) \ + (HOST_VM_INFO_REV2_COUNT - 1)) +#define HOST_VM_INFO_REV0_COUNT /* added "purgable" info (2 ints) */ \ + ((mach_msg_type_number_t) \ + (HOST_VM_INFO_REV1_COUNT - 2)) + +struct host_cpu_load_info { /* number of ticks while running... */ + natural_t cpu_ticks[CPU_STATE_MAX]; /* ... in the given mode */ +}; + +typedef struct host_cpu_load_info host_cpu_load_info_data_t; +typedef struct host_cpu_load_info *host_cpu_load_info_t; +#define HOST_CPU_LOAD_INFO_COUNT ((mach_msg_type_number_t) \ + (sizeof (host_cpu_load_info_data_t) / sizeof (integer_t))) + +#endif /* _MACH_HOST_INFO_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/sync_policy.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/sync_policy.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/sync_policy.h (revision 885) @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2000-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@ + */ +/* + * @OSF_COPYRIGHT@ + */ + +#ifndef _MACH_SYNC_POLICY_H_ +#define _MACH_SYNC_POLICY_H_ + +typedef int sync_policy_t; + +/* + * These options define the wait ordering of the synchronizers + */ +#define SYNC_POLICY_FIFO 0x0 +#define SYNC_POLICY_FIXED_PRIORITY 0x1 +#define SYNC_POLICY_REVERSED 0x2 +#define SYNC_POLICY_ORDER_MASK 0x3 +#define SYNC_POLICY_LIFO (SYNC_POLICY_FIFO|SYNC_POLICY_REVERSED) + + +#define SYNC_POLICY_MAX 0x7 + +#endif /* _MACH_SYNC_POLICY_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/mach_types.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/mach_types.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/mach_types.h (revision 885) @@ -0,0 +1,230 @@ +/* + * 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,1988 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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + */ +/* + * NOTICE: This file was modified by SPARTA, Inc. in 2005 to introduce + * support for mandatory and extensible security protections. This notice + * is included in support of clause 2.2 (b) of the Apple Public License, + * Version 2.0. + */ +/* + * File: mach/mach_types.h + * Author: Avadis Tevanian, Jr., Michael Wayne Young + * Date: 1986 + * + * Mach external interface definitions. + * + */ + +#ifndef _MACH_MACH_TYPES_H_ +#define _MACH_MACH_TYPES_H_ + +#include <stdint.h> + +#include <sys/cdefs.h> + +#include <mach/host_info.h> +#include <mach/host_notify.h> +#include <mach/host_special_ports.h> +#include <mach/machine.h> +#include <mach/machine/vm_types.h> +#include <mach/memory_object_types.h> +#include <mach/message.h> +#include <mach/exception_types.h> +#include <mach/port.h> +#include <mach/processor_info.h> +#include <mach/task_info.h> +#include <mach/task_policy.h> +#include <mach/task_special_ports.h> +#include <mach/thread_info.h> +#include <mach/thread_policy.h> +#include <mach/thread_special_ports.h> +#include <mach/thread_status.h> +#include <mach/time_value.h> +#include <mach/clock_types.h> +#include <mach/vm_attributes.h> +#include <mach/vm_inherit.h> +#include <mach/vm_purgable.h> +#include <mach/vm_behavior.h> +#include <mach/vm_prot.h> +#include <mach/vm_statistics.h> +#include <mach/vm_sync.h> +#include <mach/vm_types.h> +#include <mach/vm_region.h> +#include <mach/kmod.h> + + +/* + * If we are not in the kernel, then these will all be represented by + * ports at user-space. + */ +typedef mach_port_t task_t; +typedef mach_port_t task_name_t; +typedef mach_port_t thread_t; +typedef mach_port_t thread_act_t; +typedef mach_port_t ipc_space_t; +typedef mach_port_t host_t; +typedef mach_port_t host_priv_t; +typedef mach_port_t host_security_t; +typedef mach_port_t processor_t; +typedef mach_port_t processor_set_t; +typedef mach_port_t processor_set_control_t; +typedef mach_port_t semaphore_t; +typedef mach_port_t lock_set_t; +typedef mach_port_t ledger_t; +typedef mach_port_t alarm_t; +typedef mach_port_t clock_serv_t; +typedef mach_port_t clock_ctrl_t; + + +/* + * These aren't really unique types. They are just called + * out as unique types at one point in history. So we list + * them here for compatibility. + */ +typedef processor_set_t processor_set_name_t; + +/* + * These types are just hard-coded as ports + */ +typedef mach_port_t clock_reply_t; +typedef mach_port_t bootstrap_t; +typedef mach_port_t mem_entry_name_port_t; +typedef mach_port_t exception_handler_t; +typedef exception_handler_t *exception_handler_array_t; +typedef mach_port_t vm_task_entry_t; +typedef mach_port_t io_master_t; +typedef mach_port_t UNDServerRef; + +/* + * Mig doesn't translate the components of an array. + * For example, Mig won't use the thread_t translations + * to translate a thread_array_t argument. So, these definitions + * are not completely accurate at the moment for other kernel + * components. + */ +typedef task_t *task_array_t; +typedef thread_t *thread_array_t; +typedef processor_set_t *processor_set_array_t; +typedef processor_set_t *processor_set_name_array_t; +typedef processor_t *processor_array_t; +typedef thread_act_t *thread_act_array_t; +typedef ledger_t *ledger_array_t; + +/* + * However the real mach_types got declared, we also have to declare + * types with "port" in the name for compatability with the way OSF + * had declared the user interfaces at one point. Someday these should + * go away. + */ +typedef task_t task_port_t; +typedef task_array_t task_port_array_t; +typedef thread_t thread_port_t; +typedef thread_array_t thread_port_array_t; +typedef ipc_space_t ipc_space_port_t; +typedef host_t host_name_t; +typedef host_t host_name_port_t; +typedef processor_set_t processor_set_port_t; +typedef processor_set_t processor_set_name_port_t; +typedef processor_set_array_t processor_set_name_port_array_t; +typedef processor_set_t processor_set_control_port_t; +typedef processor_t processor_port_t; +typedef processor_array_t processor_port_array_t; +typedef thread_act_t thread_act_port_t; +typedef thread_act_array_t thread_act_port_array_t; +typedef semaphore_t semaphore_port_t; +typedef lock_set_t lock_set_port_t; +typedef ledger_t ledger_port_t; +typedef ledger_array_t ledger_port_array_t; +typedef alarm_t alarm_port_t; +typedef clock_serv_t clock_serv_port_t; +typedef clock_ctrl_t clock_ctrl_port_t; +typedef exception_handler_t exception_port_t; +typedef exception_handler_array_t exception_port_arrary_t; + + +#define TASK_NULL ((task_t) 0) +#define TASK_NAME_NULL ((task_name_t) 0) +#define THREAD_NULL ((thread_t) 0) +#define THR_ACT_NULL ((thread_act_t) 0) +#define IPC_SPACE_NULL ((ipc_space_t) 0) +#define HOST_NULL ((host_t) 0) +#define HOST_PRIV_NULL ((host_priv_t)0) +#define HOST_SECURITY_NULL ((host_security_t)0) +#define PROCESSOR_SET_NULL ((processor_set_t) 0) +#define PROCESSOR_NULL ((processor_t) 0) +#define SEMAPHORE_NULL ((semaphore_t) 0) +#define LOCK_SET_NULL ((lock_set_t) 0) +#define LEDGER_NULL ((ledger_t) 0) +#define ALARM_NULL ((alarm_t) 0) +#define CLOCK_NULL ((clock_t) 0) +#define UND_SERVER_NULL ((UNDServerRef) 0) + +typedef natural_t ledger_item_t; +#define LEDGER_ITEM_INFINITY ((ledger_item_t) (~0)) + +typedef mach_vm_offset_t *emulation_vector_t; +typedef char *user_subsystem_t; + +typedef char *labelstr_t; +/* + * Backwards compatibility, for those programs written + * before mach/{std,mach}_types.{defs,h} were set up. + */ +#include <mach/std_types.h> + +#endif /* _MACH_MACH_TYPES_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/exception.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/exception.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/exception.h (revision 885) @@ -0,0 +1,62 @@ +/* + * Copyright (c) 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@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989,1988,1987 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 Software.Distribution@CS.CMU.EDU + * 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. + */ + +#ifndef _MACH_EXCEPTION_H_ +#define _MACH_EXCEPTION_H_ + +#include <mach/exception_types.h> + +#endif /* _MACH_EXCEPTION_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/kern_return.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/kern_return.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/kern_return.h (revision 885) @@ -0,0 +1,322 @@ +/* + * Copyright (c) 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@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989,1988,1987 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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + */ +/* + * File: h/kern_return.h + * Author: Avadis Tevanian, Jr. + * Date: 1985 + * + * Kernel return codes. + * + */ + +#ifndef _MACH_KERN_RETURN_H_ +#define _MACH_KERN_RETURN_H_ + +#include <mach/machine/kern_return.h> + +#define KERN_SUCCESS 0 + +#define KERN_INVALID_ADDRESS 1 + /* Specified address is not currently valid. + */ + +#define KERN_PROTECTION_FAILURE 2 + /* Specified memory is valid, but does not permit the + * required forms of access. + */ + +#define KERN_NO_SPACE 3 + /* The address range specified is already in use, or + * no address range of the size specified could be + * found. + */ + +#define KERN_INVALID_ARGUMENT 4 + /* The function requested was not applicable to this + * type of argument, or an argument is invalid + */ + +#define KERN_FAILURE 5 + /* The function could not be performed. A catch-all. + */ + +#define KERN_RESOURCE_SHORTAGE 6 + /* A system resource could not be allocated to fulfill + * this request. This failure may not be permanent. + */ + +#define KERN_NOT_RECEIVER 7 + /* The task in question does not hold receive rights + * for the port argument. + */ + +#define KERN_NO_ACCESS 8 + /* Bogus access restriction. + */ + +#define KERN_MEMORY_FAILURE 9 + /* During a page fault, the target address refers to a + * memory object that has been destroyed. This + * failure is permanent. + */ + +#define KERN_MEMORY_ERROR 10 + /* During a page fault, the memory object indicated + * that the data could not be returned. This failure + * may be temporary; future attempts to access this + * same data may succeed, as defined by the memory + * object. + */ + +#define KERN_ALREADY_IN_SET 11 + /* The receive right is already a member of the portset. + */ + +#define KERN_NOT_IN_SET 12 + /* The receive right is not a member of a port set. + */ + +#define KERN_NAME_EXISTS 13 + /* The name already denotes a right in the task. + */ + +#define KERN_ABORTED 14 + /* The operation was aborted. Ipc code will + * catch this and reflect it as a message error. + */ + +#define KERN_INVALID_NAME 15 + /* The name doesn't denote a right in the task. + */ + +#define KERN_INVALID_TASK 16 + /* Target task isn't an active task. + */ + +#define KERN_INVALID_RIGHT 17 + /* The name denotes a right, but not an appropriate right. + */ + +#define KERN_INVALID_VALUE 18 + /* A blatant range error. + */ + +#define KERN_UREFS_OVERFLOW 19 + /* Operation would overflow limit on user-references. + */ + +#define KERN_INVALID_CAPABILITY 20 + /* The supplied (port) capability is improper. + */ + +#define KERN_RIGHT_EXISTS 21 + /* The task already has send or receive rights + * for the port under another name. + */ + +#define KERN_INVALID_HOST 22 + /* Target host isn't actually a host. + */ + +#define KERN_MEMORY_PRESENT 23 + /* An attempt was made to supply "precious" data + * for memory that is already present in a + * memory object. + */ + +#define KERN_MEMORY_DATA_MOVED 24 + /* A page was requested of a memory manager via + * memory_object_data_request for an object using + * a MEMORY_OBJECT_COPY_CALL strategy, with the + * VM_PROT_WANTS_COPY flag being used to specify + * that the page desired is for a copy of the + * object, and the memory manager has detected + * the page was pushed into a copy of the object + * while the kernel was walking the shadow chain + * from the copy to the object. This error code + * is delivered via memory_object_data_error + * and is handled by the kernel (it forces the + * kernel to restart the fault). It will not be + * seen by users. + */ + +#define KERN_MEMORY_RESTART_COPY 25 + /* A strategic copy was attempted of an object + * upon which a quicker copy is now possible. + * The caller should retry the copy using + * vm_object_copy_quickly. This error code + * is seen only by the kernel. + */ + +#define KERN_INVALID_PROCESSOR_SET 26 + /* An argument applied to assert processor set privilege + * was not a processor set control port. + */ + +#define KERN_POLICY_LIMIT 27 + /* The specified scheduling attributes exceed the thread's + * limits. + */ + +#define KERN_INVALID_POLICY 28 + /* The specified scheduling policy is not currently + * enabled for the processor set. + */ + +#define KERN_INVALID_OBJECT 29 + /* The external memory manager failed to initialize the + * memory object. + */ + +#define KERN_ALREADY_WAITING 30 + /* A thread is attempting to wait for an event for which + * there is already a waiting thread. + */ + +#define KERN_DEFAULT_SET 31 + /* An attempt was made to destroy the default processor + * set. + */ + +#define KERN_EXCEPTION_PROTECTED 32 + /* An attempt was made to fetch an exception port that is + * protected, or to abort a thread while processing a + * protected exception. + */ + +#define KERN_INVALID_LEDGER 33 + /* A ledger was required but not supplied. + */ + +#define KERN_INVALID_MEMORY_CONTROL 34 + /* The port was not a memory cache control port. + */ + +#define KERN_INVALID_SECURITY 35 + /* An argument supplied to assert security privilege + * was not a host security port. + */ + +#define KERN_NOT_DEPRESSED 36 + /* thread_depress_abort was called on a thread which + * was not currently depressed. + */ + +#define KERN_TERMINATED 37 + /* Object has been terminated and is no longer available + */ + +#define KERN_LOCK_SET_DESTROYED 38 + /* Lock set has been destroyed and is no longer available. + */ + +#define KERN_LOCK_UNSTABLE 39 + /* The thread holding the lock terminated before releasing + * the lock + */ + +#define KERN_LOCK_OWNED 40 + /* The lock is already owned by another thread + */ + +#define KERN_LOCK_OWNED_SELF 41 + /* The lock is already owned by the calling thread + */ + +#define KERN_SEMAPHORE_DESTROYED 42 + /* Semaphore has been destroyed and is no longer available. + */ + +#define KERN_RPC_SERVER_TERMINATED 43 + /* Return from RPC indicating the target server was + * terminated before it successfully replied + */ + +#define KERN_RPC_TERMINATE_ORPHAN 44 + /* Terminate an orphaned activation. + */ + +#define KERN_RPC_CONTINUE_ORPHAN 45 + /* Allow an orphaned activation to continue executing. + */ + +#define KERN_NOT_SUPPORTED 46 + /* Empty thread activation (No thread linked to it) + */ + +#define KERN_NODE_DOWN 47 + /* Remote node down or inaccessible. + */ + +#define KERN_NOT_WAITING 48 + /* A signalled thread was not actually waiting. */ + +#define KERN_OPERATION_TIMED_OUT 49 + /* Some thread-oriented operation (semaphore_wait) timed out + */ + +#define KERN_CODESIGN_ERROR 50 + /* During a page fault, indicates that the page was rejected + * as a result of a signature check. + */ + +#define KERN_RETURN_MAX 0x100 + /* Maximum return value allowable + */ + +#endif /* _MACH_KERN_RETURN_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/thread_special_ports.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/thread_special_ports.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/thread_special_ports.h (revision 885) @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2000-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@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989,1988,1987 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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + */ +/* + * File: mach/thread_special_ports.h + * + * Defines codes for special_purpose thread ports. These are NOT + * port identifiers - they are only used for the thread_get_special_port + * and thread_set_special_port routines. + * + */ + +#ifndef _MACH_THREAD_SPECIAL_PORTS_H_ +#define _MACH_THREAD_SPECIAL_PORTS_H_ + +#define THREAD_KERNEL_PORT 1 /* Represents the thread to the outside + world.*/ + +/* + * Definitions for ease of use + */ + +#define thread_get_kernel_port(thread, port) \ + (thread_get_special_port((thread), THREAD_KERNEL_PORT, (port))) + +#define thread_set_kernel_port(thread, port) \ + (thread_set_special_port((thread), THREAD_KERNEL_PORT, (port))) + +#endif /* _MACH_THREAD_SPECIAL_PORTS_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/mach_exc.defs =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/mach_exc.defs (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/mach_exc.defs (revision 885) @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2006 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,1988,1987 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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + */ +/* + * Abstract: + * MiG definitions file for Mach exception interface. + */ + +subsystem +#if KERNEL_USER + KernelUser +#endif + mach_exc 2405; + +#include <mach/std_types.defs> +#include <mach/mach_types.defs> + +ServerPrefix catch_; + +type mach_exception_data_t = array[*:2] of int64_t; +type exception_type_t = int; + +routine mach_exception_raise( +#if KERNEL_USER + exception_port : mach_port_move_send_t; + thread : mach_port_move_send_t; + task : mach_port_move_send_t; +#else /* KERNEL_USER */ + exception_port : mach_port_t; + thread : mach_port_t; + task : mach_port_t; +#endif /* KERNEL_USER */ + exception : exception_type_t; + code : mach_exception_data_t + ); + +routine mach_exception_raise_state( +#if KERNEL_USER + exception_port : mach_port_move_send_t; +#else /* KERNEL_USER */ + exception_port : mach_port_t; +#endif /* KERNEL_USER */ + exception : exception_type_t; + code : mach_exception_data_t, const; + inout flavor : int; + old_state : thread_state_t, const; + out new_state : thread_state_t); + +routine mach_exception_raise_state_identity( +#if KERNEL_USER + exception_port : mach_port_move_send_t; + thread : mach_port_move_send_t; + task : mach_port_move_send_t; +#else /* KERNEL_USER */ + exception_port : mach_port_t; + thread : mach_port_t; + task : mach_port_t; +#endif /* KERNEL_USER */ + exception : exception_type_t; + code : mach_exception_data_t; + inout flavor : int; + old_state : thread_state_t; + out new_state : thread_state_t); + +/* vim: set ft=c : */ Index: branches/azimutz/Cleancut/i386/include/mach/vm_behavior.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/vm_behavior.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/vm_behavior.h (revision 885) @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2000-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@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * File: mach/vm_behavior.h + * + * Virtual memory map behavior definitions. + * + */ + +#ifndef _MACH_VM_BEHAVIOR_H_ +#define _MACH_VM_BEHAVIOR_H_ + +/* + * Types defined: + * + * vm_behavior_t behavior codes. + */ + +typedef int vm_behavior_t; + +/* + * Enumeration of valid values for vm_behavior_t. + * These describe expected page reference behavior for + * for a given range of virtual memory. For implementation + * details see vm/vm_fault.c + */ + + +/* + * The following behaviors affect the memory region's future behavior + * and are stored in the VM map entry data structure. + */ +#define VM_BEHAVIOR_DEFAULT ((vm_behavior_t) 0) /* default */ +#define VM_BEHAVIOR_RANDOM ((vm_behavior_t) 1) /* random */ +#define VM_BEHAVIOR_SEQUENTIAL ((vm_behavior_t) 2) /* forward sequential */ +#define VM_BEHAVIOR_RSEQNTL ((vm_behavior_t) 3) /* reverse sequential */ + +/* + * The following "behaviors" affect the memory region only at the time of the + * call and are not stored in the VM map entry. + */ +#define VM_BEHAVIOR_WILLNEED ((vm_behavior_t) 4) /* will need in near future */ +#define VM_BEHAVIOR_DONTNEED ((vm_behavior_t) 5) /* dont need in near future */ +#define VM_BEHAVIOR_FREE ((vm_behavior_t) 6) /* free memory without write-back */ +#define VM_BEHAVIOR_ZERO_WIRED_PAGES ((vm_behavior_t) 7) /* zero out the wired pages of an entry if it is being deleted without unwiring them first */ +#define VM_BEHAVIOR_REUSABLE ((vm_behavior_t) 8) +#define VM_BEHAVIOR_REUSE ((vm_behavior_t) 9) +#define VM_BEHAVIOR_CAN_REUSE ((vm_behavior_t) 10) + +#endif /*_MACH_VM_BEHAVIOR_H_*/ Index: branches/azimutz/Cleancut/i386/include/mach/ledger.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/ledger.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/ledger.h (revision 885) @@ -0,0 +1,259 @@ +#ifndef _ledger_user_ +#define _ledger_user_ + +/* Module ledger */ + +#include <string.h> +#include <mach/ndr.h> +#include <mach/boolean.h> +#include <mach/kern_return.h> +#include <mach/notify.h> +#include <mach/mach_types.h> +#include <mach/message.h> +#include <mach/mig_errors.h> +#include <mach/port.h> + +#ifdef AUTOTEST +#ifndef FUNCTION_PTR_T +#define FUNCTION_PTR_T +typedef void (*function_ptr_t)(mach_port_t, char *, mach_msg_type_number_t); +typedef struct { + char *name; + function_ptr_t function; +} function_table_entry; +typedef function_table_entry *function_table_t; +#endif /* FUNCTION_PTR_T */ +#endif /* AUTOTEST */ + +#ifndef ledger_MSG_COUNT +#define ledger_MSG_COUNT 4 +#endif /* ledger_MSG_COUNT */ + +#include <mach/std_types.h> +#include <mach/mig.h> +#include <mach/mach_types.h> + +#ifdef __BeforeMigUserHeader +__BeforeMigUserHeader +#endif /* __BeforeMigUserHeader */ + +#include <sys/cdefs.h> +__BEGIN_DECLS + + +/* Routine ledger_create */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t ledger_create +( + ledger_t parent_ledger, + ledger_t ledger_ledger, + ledger_t *new_ledger, + ledger_item_t transfer +); + +/* Routine ledger_terminate */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t ledger_terminate +( + ledger_t ledger +); + +/* Routine ledger_transfer */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t ledger_transfer +( + ledger_t parent_ledger, + ledger_t child_ledger, + ledger_item_t transfer +); + +/* Routine ledger_read */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t ledger_read +( + ledger_t ledger, + ledger_item_t *balance, + ledger_item_t *limit +); + +__END_DECLS + +/********************** Caution **************************/ +/* The following data types should be used to calculate */ +/* maximum message sizes only. The actual message may be */ +/* smaller, and the position of the arguments within the */ +/* message layout may vary from what is presented here. */ +/* For example, if any of the arguments are variable- */ +/* sized, and less than the maximum is sent, the data */ +/* will be packed tight in the actual message to reduce */ +/* the presence of holes. */ +/********************** Caution **************************/ + +/* typedefs for all requests */ + +#ifndef __Request__ledger_subsystem__defined +#define __Request__ledger_subsystem__defined + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t ledger_ledger; + /* end of the kernel processed data */ + NDR_record_t NDR; + ledger_item_t transfer; + } __Request__ledger_create_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__ledger_terminate_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t child_ledger; + /* end of the kernel processed data */ + NDR_record_t NDR; + ledger_item_t transfer; + } __Request__ledger_transfer_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__ledger_read_t; +#ifdef __MigPackStructs +#pragma pack() +#endif +#endif /* !__Request__ledger_subsystem__defined */ + +/* union of all requests */ + +#ifndef __RequestUnion__ledger_subsystem__defined +#define __RequestUnion__ledger_subsystem__defined +union __RequestUnion__ledger_subsystem { + __Request__ledger_create_t Request_ledger_create; + __Request__ledger_terminate_t Request_ledger_terminate; + __Request__ledger_transfer_t Request_ledger_transfer; + __Request__ledger_read_t Request_ledger_read; +}; +#endif /* !__RequestUnion__ledger_subsystem__defined */ +/* typedefs for all replies */ + +#ifndef __Reply__ledger_subsystem__defined +#define __Reply__ledger_subsystem__defined + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t new_ledger; + /* end of the kernel processed data */ + } __Reply__ledger_create_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__ledger_terminate_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__ledger_transfer_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + ledger_item_t balance; + ledger_item_t limit; + } __Reply__ledger_read_t; +#ifdef __MigPackStructs +#pragma pack() +#endif +#endif /* !__Reply__ledger_subsystem__defined */ + +/* union of all replies */ + +#ifndef __ReplyUnion__ledger_subsystem__defined +#define __ReplyUnion__ledger_subsystem__defined +union __ReplyUnion__ledger_subsystem { + __Reply__ledger_create_t Reply_ledger_create; + __Reply__ledger_terminate_t Reply_ledger_terminate; + __Reply__ledger_transfer_t Reply_ledger_transfer; + __Reply__ledger_read_t Reply_ledger_read; +}; +#endif /* !__RequestUnion__ledger_subsystem__defined */ + +#ifndef subsystem_to_name_map_ledger +#define subsystem_to_name_map_ledger \ + { "ledger_create", 5000 },\ + { "ledger_terminate", 5001 },\ + { "ledger_transfer", 5002 },\ + { "ledger_read", 5003 } +#endif + +#ifdef __AfterMigUserHeader +__AfterMigUserHeader +#endif /* __AfterMigUserHeader */ + +#endif /* _ledger_user_ */ Index: branches/azimutz/Cleancut/i386/include/mach/task.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/task.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/task.h (revision 885) @@ -0,0 +1,40 @@ +/* + * Copyright (c) 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@ + */ +#if defined(__i386__) +#include <mach/i386/task.h> +#elif defined(__x86_64__) +#include <mach/x86_64/task.h> +#elif defined(__ppc__) +#include <mach/ppc/task.h> +#elif defined(__ppc64__) +#include <mach/ppc64/task.h> +#elif defined(__arm__) +#include <mach/arm/task.h> +#else +#error unknown architecture +#endif Index: branches/azimutz/Cleancut/i386/include/mach/vm_purgable.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/vm_purgable.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/vm_purgable.h (revision 885) @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2003-2007 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@ + */ + +/* + * Virtual memory map purgeable object definitions. + * Objects that will be needed in the future (forward cached objects) should be queued LIFO. + * Objects that have been used and are cached for reuse (backward cached) should be queued FIFO. + * Every user of purgeable memory is entitled to using the highest volatile group (7). + * Only if a client wants some of its objects to definitely be purged earlier, it can put those in + * another group. This could be used to make all FIFO objects (in the lower group) go away before + * any LIFO objects (in the higher group) go away. + * Objects that should not get any chance to stay around can be marked as "obsolete". They will + * be emptied before any other objects or pages are reclaimed. Obsolete objects are not emptied + * in any particular order. + * 'purgeable' is recognized as the correct spelling. For historical reasons, definitions + * in this file are spelled 'purgable'. + */ + +#ifndef _MACH_VM_PURGABLE_H_ +#define _MACH_VM_PURGABLE_H_ + +/* + * Types defined: + * + * vm_purgable_t purgeable object control codes. + */ + +typedef int vm_purgable_t; + +/* + * Enumeration of valid values for vm_purgable_t. + */ +#define VM_PURGABLE_SET_STATE ((vm_purgable_t) 0) /* set state of purgeable object */ +#define VM_PURGABLE_GET_STATE ((vm_purgable_t) 1) /* get state of purgeable object */ +#define VM_PURGABLE_PURGE_ALL ((vm_purgable_t) 2) /* purge all volatile objects now */ + +#define VM_PURGABLE_DEBUG_SHIFT 12 +#define VM_PURGABLE_DEBUG_MASK (0x3 << VM_PURGABLE_DEBUG_SHIFT) +#define VM_PURGABLE_DEBUG_EMPTY (0x1 << VM_PURGABLE_DEBUG_SHIFT) +#define VM_PURGABLE_DEBUG_FAULT (0x2 << VM_PURGABLE_DEBUG_SHIFT) + +/* + * Volatile memory ordering groups (group zero objects are purged before group 1, etc... + * It is implementation dependent as to whether these groups are global or per-address space. + * (for the moment, they are global). + */ +#define VM_VOLATILE_GROUP_SHIFT 8 +#define VM_VOLATILE_GROUP_MASK (7 << VM_VOLATILE_GROUP_SHIFT) +#define VM_VOLATILE_GROUP_DEFAULT VM_VOLATILE_GROUP_7 + +#define VM_VOLATILE_GROUP_0 (0 << VM_VOLATILE_GROUP_SHIFT) +#define VM_VOLATILE_GROUP_1 (1 << VM_VOLATILE_GROUP_SHIFT) +#define VM_VOLATILE_GROUP_2 (2 << VM_VOLATILE_GROUP_SHIFT) +#define VM_VOLATILE_GROUP_3 (3 << VM_VOLATILE_GROUP_SHIFT) +#define VM_VOLATILE_GROUP_4 (4 << VM_VOLATILE_GROUP_SHIFT) +#define VM_VOLATILE_GROUP_5 (5 << VM_VOLATILE_GROUP_SHIFT) +#define VM_VOLATILE_GROUP_6 (6 << VM_VOLATILE_GROUP_SHIFT) +#define VM_VOLATILE_GROUP_7 (7 << VM_VOLATILE_GROUP_SHIFT) + +/* + * Purgeable behavior + * Within the same group, FIFO objects will be emptied before objects that are added later. + * LIFO objects will be emptied after objects that are added later. + * - Input only, not returned on state queries. + */ +#define VM_PURGABLE_BEHAVIOR_SHIFT 6 +#define VM_PURGABLE_BEHAVIOR_MASK (1 << VM_PURGABLE_BEHAVIOR_SHIFT) +#define VM_PURGABLE_BEHAVIOR_FIFO (0 << VM_PURGABLE_BEHAVIOR_SHIFT) +#define VM_PURGABLE_BEHAVIOR_LIFO (1 << VM_PURGABLE_BEHAVIOR_SHIFT) + +/* + * Obsolete object. + * Disregard volatile group, and put object into obsolete queue instead, so it is the next object + * to be purged. + * - Input only, not returned on state queries. + */ +#define VM_PURGABLE_ORDERING_SHIFT 5 +#define VM_PURGABLE_ORDERING_MASK (1 << VM_PURGABLE_ORDERING_SHIFT) +#define VM_PURGABLE_ORDERING_OBSOLETE (1 << VM_PURGABLE_ORDERING_SHIFT) +#define VM_PURGABLE_ORDERING_NORMAL (0 << VM_PURGABLE_ORDERING_SHIFT) + + +/* + * Obsolete parameter - do not use + */ +#define VM_VOLATILE_ORDER_SHIFT 4 +#define VM_VOLATILE_ORDER_MASK (1 << VM_VOLATILE_ORDER_SHIFT) +#define VM_VOLATILE_MAKE_FIRST_IN_GROUP (1 << VM_VOLATILE_ORDER_SHIFT) +#define VM_VOLATILE_MAKE_LAST_IN_GROUP (0 << VM_VOLATILE_ORDER_SHIFT) + +/* + * Valid states of a purgeable object. + */ +#define VM_PURGABLE_STATE_MIN 0 /* minimum purgeable object state value */ +#define VM_PURGABLE_STATE_MAX 3 /* maximum purgeable object state value */ +#define VM_PURGABLE_STATE_MASK 3 /* mask to separate state from group */ + +#define VM_PURGABLE_NONVOLATILE 0 /* purgeable object is non-volatile */ +#define VM_PURGABLE_VOLATILE 1 /* purgeable object is volatile */ +#define VM_PURGABLE_EMPTY 2 /* purgeable object is volatile and empty */ +#define VM_PURGABLE_DENY 3 /* (mark) object not purgeable */ + +#define VM_PURGABLE_ALL_MASKS (VM_PURGABLE_STATE_MASK | \ + VM_VOLATILE_ORDER_MASK | \ + VM_PURGABLE_ORDERING_MASK | \ + VM_PURGABLE_BEHAVIOR_MASK | \ + VM_VOLATILE_GROUP_MASK | \ + VM_PURGABLE_DEBUG_MASK) +#endif /* _MACH_VM_PURGABLE_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/mach_vm.defs =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/mach_vm.defs (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/mach_vm.defs (revision 885) @@ -0,0 +1,480 @@ +/* + * Copyright (c) 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_FREE_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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + */ +/* + * File: mach/mach_vm.defs + * + * Exported kernel VM calls (for any task on the platform). + */ + +subsystem +#if KERNEL_SERVER + KernelServer +#endif /* KERNEL_SERVER */ +#if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) + mach_vm +#else + vm_map_lp64_local +#endif + 4800; + +#include <mach/std_types.defs> +#include <mach/mach_types.defs> +#include <mach_debug/mach_debug_types.defs> + +/* + * Allocate zero-filled memory in the address space + * of the target task, either at the specified address, + * or wherever space can be found (controlled by flags), + * of the specified size. The address at which the + * allocation actually took place is returned. + */ +#if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) +routine mach_vm_allocate( +#else +routine vm_allocate( +#endif + target : vm_task_entry_t; + inout address : mach_vm_address_t; + size : mach_vm_size_t; + flags : int); + +/* + * Deallocate the specified range from the virtual + * address space of the target virtual memory map. + */ +#if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) +routine mach_vm_deallocate( +#else +routine vm_deallocate( +#endif + target : vm_task_entry_t; + address : mach_vm_address_t; + size : mach_vm_size_t); + +/* + * Set the current or maximum protection attribute + * for the specified range of the virtual address + * space of the target virtual memory map. The current + * protection limits the memory access rights of threads + * within the map; the maximum protection limits the accesses + * that may be given in the current protection. + * Protections are specified as a set of {read, write, execute} + * *permissions*. + */ +#if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) +routine mach_vm_protect( +#else +routine vm_protect( +#endif + target_task : vm_task_entry_t; + address : mach_vm_address_t; + size : mach_vm_size_t; + set_maximum : boolean_t; + new_protection : vm_prot_t); + +/* + * Set the inheritance attribute for the specified range + * of the virtual address space of the target address space. + * The inheritance value is one of {none, copy, share}, and + * specifies how the child address space should acquire + * this memory at the time of a task_create call. + */ +#if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) +routine mach_vm_inherit( +#else +routine vm_inherit( +#endif + target_task : vm_task_entry_t; + address : mach_vm_address_t; + size : mach_vm_size_t; + new_inheritance : vm_inherit_t); + +/* + * Returns the contents of the specified range of the + * virtual address space of the target task. [The + * range must be aligned on a virtual page boundary, + * and must be a multiple of pages in extent. The + * protection on the specified range must permit reading.] + */ +#if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) +routine mach_vm_read( +#else +routine vm_read( +#endif + target_task : vm_map_t; + address : mach_vm_address_t; + size : mach_vm_size_t; + out data : pointer_t); + +/* + * List corrollary to vm_read, returns mapped contents of specified + * ranges within target address space. + */ +#if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) +routine mach_vm_read_list( +#else +routine vm_read_list( +#endif + target_task : vm_map_t; + inout data_list : mach_vm_read_entry_t; + count : natural_t); + +/* + * Writes the contents of the specified range of the + * virtual address space of the target task. [The + * range must be aligned on a virtual page boundary, + * and must be a multiple of pages in extent. The + * protection on the specified range must permit writing.] + */ +#if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) +routine mach_vm_write( +#else +routine vm_write( +#endif + target_task : vm_map_t; + address : mach_vm_address_t; + data : pointer_t); + +/* + * Copy the contents of the source range of the virtual + * address space of the target task to the destination + * range in that same address space. [Both of the + * ranges must be aligned on a virtual page boundary, + * and must be multiples of pages in extent. The + * protection on the source range must permit reading, + * and the protection on the destination range must + * permit writing.] + */ +#if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) +routine mach_vm_copy( +#else +routine vm_copy( +#endif + target_task : vm_map_t; + source_address : mach_vm_address_t; + size : mach_vm_size_t; + dest_address : mach_vm_address_t); + +/* + * Returns the contents of the specified range of the + * virtual address space of the target task. [There + * are no alignment restrictions, and the results will + * overwrite the area pointed to by data - which must + * already exist. The protection on the specified range + * must permit reading.] + */ +#if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) +routine mach_vm_read_overwrite( +#else +routine vm_read_overwrite( +#endif + target_task : vm_map_t; + address : mach_vm_address_t; + size : mach_vm_size_t; + data : mach_vm_address_t; + out outsize : mach_vm_size_t); + + +#if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) +routine mach_vm_msync( +#else +routine vm_msync( +#endif + target_task : vm_map_t; + address : mach_vm_address_t; + size : mach_vm_size_t; + sync_flags : vm_sync_t ); + +/* + * Set the paging behavior attribute for the specified range + * of the virtual address space of the target task. + * The behavior value is one of {default, random, forward + * sequential, reverse sequential} and indicates the expected + * page reference pattern for the specified range. + */ +#if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) +routine mach_vm_behavior_set( +#else +routine vm_behavior_set( +#endif + target_task : vm_map_t; + address : mach_vm_address_t; + size : mach_vm_size_t; + new_behavior : vm_behavior_t); + + +/* + * Map a user-supplie memory object into the virtual address + * space of the target task. If desired (anywhere is TRUE), + * the kernel will find a suitable address range of the + * specified size; else, the specific address will be allocated. + * + * The beginning address of the range will be aligned on a virtual + * page boundary, be at or beyond the address specified, and + * meet the mask requirements (bits turned on in the mask must not + * be turned on in the result); the size of the range, in bytes, + * will be rounded up to an integral number of virtual pages. + * + * The memory in the resulting range will be associated with the + * specified memory object, with the beginning of the memory range + * referring to the specified offset into the memory object. + * + * The mapping will take the current and maximum protections and + * the inheritance attributes specified; see the vm_protect and + * vm_inherit calls for a description of these attributes. + * + * If desired (copy is TRUE), the memory range will be filled + * with a copy of the data from the memory object; this copy will + * be private to this mapping in this target task. Otherwise, + * the memory in this mapping will be shared with other mappings + * of the same memory object at the same offset (in this task or + * in other tasks). [The Mach kernel only enforces shared memory + * consistency among mappings on one host with similar page alignments. + * The user-defined memory manager for this object is responsible + * for further consistency.] + */ +#if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) +routine mach_vm_map( +#else +routine vm_map( +#endif + target_task : vm_task_entry_t; + inout address : mach_vm_address_t; + size : mach_vm_size_t; + mask : mach_vm_offset_t; + flags : int; + object : mem_entry_name_port_t; + offset : memory_object_offset_t; + copy : boolean_t; + cur_protection : vm_prot_t; + max_protection : vm_prot_t; + inheritance : vm_inherit_t); + +/* + * Set/Get special properties of memory associated + * to some virtual address range, such as cachability, + * migrability, replicability. Machine-dependent. + */ +#if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) +routine mach_vm_machine_attribute( +#else +routine vm_machine_attribute( +#endif + target_task : vm_map_t; + address : mach_vm_address_t; + size : mach_vm_size_t; + attribute : vm_machine_attribute_t; + inout value : vm_machine_attribute_val_t); + +/* + * Map portion of a task's address space. + */ +#if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) +routine mach_vm_remap( +#else +routine vm_remap( +#endif + target_task : vm_map_t; + inout target_address : mach_vm_address_t; + size : mach_vm_size_t; + mask : mach_vm_offset_t; + anywhere : boolean_t; + src_task : vm_map_t; + src_address : mach_vm_address_t; + copy : boolean_t; + out cur_protection : vm_prot_t; + out max_protection : vm_prot_t; + inheritance : vm_inherit_t); + +/* + * Give the caller information on the given location in a virtual + * address space. If a page is mapped return ref and dirty info. + */ +#if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) +routine mach_vm_page_query( +#else +routine vm_map_page_query( +#endif + target_map :vm_map_t; + offset :mach_vm_offset_t; + out disposition :integer_t; + out ref_count :integer_t); + + +#if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) +routine mach_vm_region_recurse( +#else +routine vm_region_recurse_64( +#endif + target_task : vm_map_t; + inout address : mach_vm_address_t; + out size : mach_vm_size_t; + inout nesting_depth : natural_t; + out info : vm_region_recurse_info_t,CountInOut); + +/* + * Returns information about the contents of the virtual + * address space of the target task at the specified + * address. The returned protection, inheritance, sharing + * and memory object values apply to the entire range described + * by the address range returned; the memory object offset + * corresponds to the beginning of the address range. + * [If the specified address is not allocated, the next + * highest address range is described. If no addresses beyond + * the one specified are allocated, the call returns KERN_NO_SPACE.] + */ +#if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) +routine mach_vm_region( +#else +routine vm_region_64( +#endif + target_task : vm_map_t; + inout address : mach_vm_address_t; + out size : mach_vm_size_t; + flavor : vm_region_flavor_t; + out info : vm_region_info_t, CountInOut; + out object_name : memory_object_name_t = + MACH_MSG_TYPE_MOVE_SEND + ctype: mach_port_t); + +/* + * Allow application level processes to create named entries which + * correspond to mapped portions of their address space. These named + * entries can then be manipulated, shared with other processes in + * other address spaces and ultimately mapped in ohter address spaces + * + * THIS INTERFACE IS STILL EVOLVING. + */ +#if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) +#if !defined(__LP64__) || KERNEL_SERVER || XNU_KERNEL_PRIVATE || LIBSYSCALL_INTERFACE +routine _mach_make_memory_entry( +#else +routine mach_make_memory_entry( +#endif +#else +routine mach_make_memory_entry_64( +#endif + target_task :vm_map_t; + inout size :memory_object_size_t; + offset :memory_object_offset_t; + permission :vm_prot_t; + out object_handle :mem_entry_name_port_move_send_t; + parent_handle :mem_entry_name_port_t); + +/* + * Control behavior and investigate state of a "purgable" object in + * the virtual address space of the target task. A purgable object is + * created via a call to mach_vm_allocate() with VM_FLAGS_PURGABLE + * specified. See the routine implementation for a complete + * definition of the routine. + */ +#if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) +routine mach_vm_purgable_control( +#else +routine vm_purgable_control( +#endif + target_task : vm_map_t; + address : mach_vm_address_t; + control : vm_purgable_t; + inout state : int); + + +#if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) +routine mach_vm_page_info( + target_task : vm_map_t; + address : mach_vm_address_t; + flavor : vm_page_info_flavor_t; + out info : vm_page_info_t, CountInOut); +#else +skip; +#endif + +/****************************** Legacy section ***************************/ +/* The following definitions are exist to provide compatibility with */ +/* the legacy APIs. They are no different. We just need to produce */ +/* the user-level stub interface for them. */ +/****************************** Legacy section ***************************/ + + +/* + * These interfaces just aren't supported in the new (wide) model: + * + * mach_vm_region_info() - + * vm_map_pages_info() - + * no user-level replacement for these MACH_DEBUG interfaces + * vm_map_get_upl() - + * no user-level replacement at the moment + * vm_region_info() - + * use mach_vm_region_info() or vm_region_info_64() + * vm_region_recurse() - + * use mach_vm_region_recurse() or vm_region_recurse_64() + */ + +/* + * The following legacy interfaces are provides as macro wrappers to the new + * interfaces. You should strive to use the new ones instead: + * + * vm_map() - + * use mach_vm_map() or vm_map_64() + * vm_region() - + * use mach_vm_region() or vm_region_64() + * mach_make_memory_entry() - + * use mach_vm_make_memory_entry() or mach_make_memory_entry_64() + */ + +/* vim: set ft=c : */ Index: branches/azimutz/Cleancut/i386/include/mach/host_notify.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/host_notify.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/host_notify.h (revision 885) @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2003 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 _MACH_HOST_NOTIFY_H_ +#define _MACH_HOST_NOTIFY_H_ + +#define HOST_NOTIFY_CALENDAR_CHANGE 0 +#define HOST_NOTIFY_TYPE_MAX 0 + +#define HOST_CALENDAR_CHANGED_REPLYID 950 + +#endif /* _MACH_HOST_NOTIFY_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/audit_triggers.defs =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/audit_triggers.defs (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/audit_triggers.defs (revision 885) @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2004-2008, Apple Inc. All rights reserved. + * + * @APPLE_BSD_LICENSE_HEADER_START@ + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * @APPLE_BSD_LICENSE_HEADER_END@ +*/ + +/* + * Interface definition for the audit logging facility. + */ + +subsystem +#if KERNEL_USER + KernelUser +#endif /* KERNEL_USER */ + audit_triggers 123; + +#include <mach/std_types.defs> +#include <mach/mach_types.defs> + +simpleroutine audit_triggers( + audit_port : mach_port_t; + in flags : int); + Index: branches/azimutz/Cleancut/i386/include/mach/vm_types.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/vm_types.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/vm_types.h (revision 885) @@ -0,0 +1,93 @@ +/* + * 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@ + * + */ +#ifndef _MACH_VM_TYPES_H_ +#define _MACH_VM_TYPES_H_ + +#include <mach/port.h> +#include <mach/machine/vm_types.h> + +#include <stdint.h> + +typedef vm_offset_t pointer_t; +typedef vm_offset_t vm_address_t; + +/* + * We use addr64_t for 64-bit addresses that are used on both + * 32 and 64-bit machines. On PPC, they are passed and returned as + * two adjacent 32-bit GPRs. We use addr64_t in places where + * common code must be useable both on 32 and 64-bit machines. + */ +typedef uint64_t addr64_t; /* Basic effective address */ + +/* + * We use reg64_t for addresses that are 32 bits on a 32-bit + * machine, and 64 bits on a 64-bit machine, but are always + * passed and returned in a single GPR on PPC. This type + * cannot be used in generic 32-bit c, since on a 64-bit + * machine the upper half of the register will be ignored + * by the c compiler in 32-bit mode. In c, we can only use the + * type in prototypes of functions that are written in and called + * from assembly language. This type is basically a comment. + */ +typedef uint32_t reg64_t; + +/* + * To minimize the use of 64-bit fields, we keep some physical + * addresses (that are page aligned) as 32-bit page numbers. + * This limits the physical address space to 16TB of RAM. + */ +typedef uint32_t ppnum_t; /* Physical page number */ +#define PPNUM_MAX UINT32_MAX + + + +typedef mach_port_t vm_map_t; + + +#define VM_MAP_NULL ((vm_map_t) 0) + +/* + * Evolving definitions, likely to change. + */ + +typedef uint64_t vm_object_offset_t; +typedef uint64_t vm_object_size_t; + + +typedef mach_port_t upl_t; +typedef mach_port_t vm_named_entry_t; + + +#define UPL_NULL ((upl_t) 0) +#define VM_NAMED_ENTRY_NULL ((vm_named_entry_t) 0) + +#endif /* _MACH_VM_TYPES_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/host_priv.defs =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/host_priv.defs (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/host_priv.defs (revision 885) @@ -0,0 +1,380 @@ +/* + * Copyright (c) 2000-2004 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@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989,1988 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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + */ + +/* + * Matchmaker definitions file for Mach kernel interface. + */ +subsystem +#if KERNEL_USER + KernelUser +#endif /* KERNEL_USER */ +#if KERNEL_SERVER + KernelServer +#endif /* KERNEL_SERVER */ + host_priv 400; + +#ifdef KERNEL_USER +userprefix r_; +#endif /* KERNEL_USER */ + +#include <mach/std_types.defs> +#include <mach/mach_types.defs> +#include <mach/clock_types.defs> +#include <mach_debug/mach_debug_types.defs> + +/* + * Get boot configuration information from kernel. + */ +routine host_get_boot_info( + host_priv : host_priv_t; + out boot_info : kernel_boot_info_t); + +/* + * Reboot this host. + * Only available to privileged users. + */ +routine host_reboot( + host_priv : host_priv_t; + options : int); + + +/* + * Return privileged statistics from this host. + */ +routine host_priv_statistics( + host_priv : host_priv_t; + flavor : host_flavor_t; + out host_info_out : host_info_t, CountInOut); + +/* + * Sets the default memory manager, the port to which + * newly-created temporary memory objects are delivered. + * [See (memory_object_default)memory_object_create.] + * Also sets the default cluster size used for pagein/pageout + * to this port. + * The old memory manager port is returned. + */ +routine host_default_memory_manager( + host_priv : host_priv_t; + inout default_manager : memory_object_default_t = + MACH_MSG_TYPE_MAKE_SEND; + cluster_size : memory_object_cluster_size_t); + + +/* + * Specify that the range of the virtual address space + * of the target task must not cause page faults for + * the indicated accesses. + * + * [ To unwire the pages, specify VM_PROT_NONE. ] + */ +routine vm_wire( + host_priv : host_priv_t; + task : vm_map_t; + address : vm_address_t; + size : vm_size_t; + desired_access : vm_prot_t); + +/* + * Specify that the target thread must always be able + * to run and to allocate memory. + */ +routine thread_wire( + host_priv : host_priv_t; + thread : thread_act_t; + wired : boolean_t); + +/* + * Allocate zero-filled, wired, contiguous physical memory + * in the address space of the target task, either at the + * specified address, or wherever space can be found (if + * anywhere is TRUE), of the specified size. The address + * at which the allocation actually took place is returned. + * All pages will be entered into the task's pmap immediately, + * with VM_PROT_ALL. + * + * In addition to all the failure modes of its cousin, + * vm_allocate, this call may also fail if insufficient + * contiguous memory exists to satisfy the request. + * + * Memory obtained from this call should be freed the + * normal way, via vm_deallocate. + * + * N.B. This is an EXPERIMENTAL interface! + */ +routine vm_allocate_cpm( + host_priv : host_priv_t; + task : vm_map_t; + inout address : vm_address_t; + size : vm_size_t; + flags : int); + +/* + * Get list of processors on this host. + */ +routine host_processors( + host_priv : host_priv_t; + out out_processor_list : processor_array_t); + + +/* + * Get control port for a system-wide clock. + * Privileged. + */ +routine host_get_clock_control( + host_priv : host_priv_t; + clock_id : clock_id_t; + out clock_ctrl : clock_ctrl_t); + + +/* + * kernel module interface (obsolete as of SnowLeopard) + * see mach/kmod.h + */ +/* kmod_ MIG calls now return KERN_NOT_SUPPORTED on PPC/i386/x86_64. */ +routine kmod_create( + host_priv : host_priv_t; + info : vm_address_t; + out module : kmod_t); + +routine kmod_destroy( + host_priv : host_priv_t; + module : kmod_t); + +routine kmod_control( + host_priv : host_priv_t; + module : kmod_t; + flavor : kmod_control_flavor_t; + inout data : kmod_args_t); + +/* + * Get a given special port for a given node. + * Special ports are defined in host_special_ports.h; + * examples include the master device port. + * There are a limited number of slots available for system servers. + */ +routine host_get_special_port( + host_priv : host_priv_t; + node : int; + which : int; + out port : mach_port_t); + +/* + * Set a given special port for the local node. + * See host_get_special_port. + */ +routine host_set_special_port( + host_priv : host_priv_t; + which : int; + port : mach_port_t); + +/* + * Set an exception handler for a host on one or more exception types. + * These handlers are invoked for all threads on the host if there are + * no task or thread-specific exception handlers or those handlers returned + * an error. + */ +routine host_set_exception_ports( + host_priv : host_priv_t; + exception_mask : exception_mask_t; + new_port : mach_port_t; + behavior : exception_behavior_t; + new_flavor : thread_state_flavor_t); + + +/* + * Lookup some of the old exception handlers for a host + */ +routine host_get_exception_ports( + host_priv : host_priv_t; + exception_mask : exception_mask_t; + out masks : exception_mask_array_t; + out old_handlers : exception_handler_array_t, SameCount; + out old_behaviors : exception_behavior_array_t, SameCount; + out old_flavors : exception_flavor_array_t, SameCount); + + +/* + * Set an exception handler for a host on one or more exception types. + * At the same time, return the previously defined exception handlers for + * those types. + */ +routine host_swap_exception_ports( + host_priv : host_priv_t; + exception_mask : exception_mask_t; + new_port : mach_port_t; + behavior : exception_behavior_t; + new_flavor : thread_state_flavor_t; + out masks : exception_mask_array_t; + out old_handlerss : exception_handler_array_t, SameCount; + out old_behaviors : exception_behavior_array_t, SameCount; + out old_flavors : exception_flavor_array_t, SameCount); + +/* + * Loads a symbol table for an external file into the kernel debugger. + * The symbol table data is an array of characters. It is assumed that + * the caller and the kernel debugger agree on its format. + * This call is only supported in MACH_DEBUG and MACH_KDB kernels, + * otherwise KERN_FAILURE is returned. + */ +routine host_load_symbol_table( + host : host_priv_t; + task : task_t; + name : symtab_name_t; + symtab : pointer_t); + +/* + * Specify that the range of the virtual address space + * of the target task must not cause page faults for + * the indicated accesses. + * + * [ To unwire the pages, specify VM_PROT_NONE. ] + */ +routine mach_vm_wire( + host_priv : host_priv_t; + task : vm_map_t; + address : mach_vm_address_t; + size : mach_vm_size_t; + desired_access : vm_prot_t); + +/* + * JMM - Keep all processor_set related items at the end for easy + * removal. + */ +/* + * List all processor sets on host. + */ +routine host_processor_sets( + host_priv : host_priv_t; + out processor_sets : processor_set_name_array_t); + +/* + * Get control port for a processor set. + */ +routine host_processor_set_priv( + host_priv : host_priv_t; + set_name : processor_set_name_t; + out set : processor_set_t); + +/************************** Warning *************************************/ +/* The following routines are going away in a future release */ +/* use the appropriate variant of host_set_special_port instead */ +/************************************************************************/ + +/* + * Set the dynamic_pager control port. Other entities + * can request a send right to this port to talk with + * the dynamic_pager utility, setting behavioral parameters + * within the dynamic pager and getting low/high backing store + * resource notifications. + */ +routine set_dp_control_port( + host : host_priv_t; + in control_port : mach_port_t); + +/* + * Get the dynamic_pager control port. This port + * allows the holder to talk directly with the dynamic + * pager utility. + */ +routine get_dp_control_port( + host : host_priv_t; + out contorl_port :mach_port_t); + +/* + * Set the UserNotification daemon access port for this host. + * If this value is already set, the kernel will discard its + * reference to the previously registered port. + */ +routine host_set_UNDServer( + host : host_priv_t; + in server : UNDServerRef); + +/* + * Get the UserNotification daemon access port for this host. + * This can then be used to communicate with that daemon, which + * in turn communicates with the User through whatever means + * available (pop-up-menus for GUI systems, text for non-GUI, etc..). + * + * Access to this port is restricted to privileged clients because + * it is a special purpose port intended for kernel clients. User + * level clients should go directly to the CFUserNotifcation services. + */ +routine host_get_UNDServer( + host : host_priv_t; + out server : UNDServerRef); + +/* + * Perform an operation with a kernel extension, on the kext loading system, + * or request information about loaded kexts or the state of the kext loading + * system. + * Active operations (load, unload, disable/enable) require host_priv/root access. + * Info retrieval does not. + * + * WARNING: THIS ROUTINE IS PRIVATE TO THE KEXT-MANAGEMENT STACK AND IS + * SUBJECT TO CHANGE AT ANY TIME. + */ +routine kext_request( + host_priv : host_priv_t; + in user_log_flags : uint32_t; + in request_data : pointer_t; + out response_data : pointer_t; + out log_data : pointer_t; + out op_result : kern_return_t); + +/* vim: set ft=c : */ Index: branches/azimutz/Cleancut/i386/include/mach/notify.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/notify.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/notify.h (revision 885) @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2000-2003 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,1988,1987 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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + */ +/* + * File: mach/notify.h + * + * Kernel notification message definitions. + */ + +#ifndef _MACH_NOTIFY_H_ +#define _MACH_NOTIFY_H_ + +#include <mach/port.h> +#include <mach/message.h> +#include <mach/ndr.h> + +/* + * An alternative specification of the notification interface + * may be found in mach/notify.defs. + */ + +#define MACH_NOTIFY_FIRST 0100 +#define MACH_NOTIFY_PORT_DELETED (MACH_NOTIFY_FIRST + 001 ) + /* A send or send-once right was deleted. */ +#define MACH_NOTIFY_PORT_DESTROYED (MACH_NOTIFY_FIRST + 005) + /* A receive right was (would have been) deallocated */ +#define MACH_NOTIFY_NO_SENDERS (MACH_NOTIFY_FIRST + 006) + /* Receive right has no extant send rights */ +#define MACH_NOTIFY_SEND_ONCE (MACH_NOTIFY_FIRST + 007) + /* An extant send-once right died */ +#define MACH_NOTIFY_DEAD_NAME (MACH_NOTIFY_FIRST + 010) + /* Send or send-once right died, leaving a dead-name */ +#define MACH_NOTIFY_LAST (MACH_NOTIFY_FIRST + 015) + +typedef mach_port_t notify_port_t; + +/* + * Hard-coded message structures for receiving Mach port notification + * messages. However, they are not actual large enough to receive + * the largest trailers current exported by Mach IPC (so they cannot + * be used for space allocations in situations using these new larger + * trailers). Instead, the MIG-generated server routines (and + * related prototypes should be used). + */ +typedef struct { + mach_msg_header_t not_header; + NDR_record_t NDR; + mach_port_name_t not_port;/* MACH_MSG_TYPE_PORT_NAME */ + mach_msg_format_0_trailer_t trailer; +} mach_port_deleted_notification_t; + +typedef struct { + mach_msg_header_t not_header; + mach_msg_body_t not_body; + mach_msg_port_descriptor_t not_port;/* MACH_MSG_TYPE_PORT_RECEIVE */ + mach_msg_format_0_trailer_t trailer; +} mach_port_destroyed_notification_t; + +typedef struct { + mach_msg_header_t not_header; + NDR_record_t NDR; + mach_msg_type_number_t not_count; + mach_msg_format_0_trailer_t trailer; +} mach_no_senders_notification_t; + +typedef struct { + mach_msg_header_t not_header; + mach_msg_format_0_trailer_t trailer; +} mach_send_once_notification_t; + +typedef struct { + mach_msg_header_t not_header; + NDR_record_t NDR; + mach_port_name_t not_port;/* MACH_MSG_TYPE_PORT_NAME */ + mach_msg_format_0_trailer_t trailer; +} mach_dead_name_notification_t; + +#endif /* _MACH_NOTIFY_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/std_types.defs =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/std_types.defs (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/std_types.defs (revision 885) @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2002,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@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989,1988 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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + */ +/* + * Mach kernel standard interface type declarations + */ + +#ifndef _MACH_STD_TYPES_DEFS_ +#define _MACH_STD_TYPES_DEFS_ + +/* from ISO/IEC 988:1999 spec */ +/* 7.18.1.1 Exact-width integer types */ + +type int8_t = MACH_MSG_TYPE_INTEGER_8; +type uint8_t = MACH_MSG_TYPE_INTEGER_8; +type int16_t = MACH_MSG_TYPE_INTEGER_16; +type uint16_t = MACH_MSG_TYPE_INTEGER_16; +type int32_t = MACH_MSG_TYPE_INTEGER_32; +type uint32_t = MACH_MSG_TYPE_INTEGER_32; +type int64_t = MACH_MSG_TYPE_INTEGER_64; +type uint64_t = MACH_MSG_TYPE_INTEGER_64; + +/* + * Legacy fixed-length Mach types which should + * be replaced with the Standard types from above. + */ +type int32 = int32_t; +type unsigned32 = uint32_t; +type int64 = int64_t; +type unsigned64 = uint64_t; + +/* + * Other fixed length Mach types. + */ +type char = MACH_MSG_TYPE_CHAR; +type boolean_t = MACH_MSG_TYPE_BOOLEAN; + +#include <mach/machine/machine_types.defs> + +type kern_return_t = int; + +type pointer_t = ^array[] of MACH_MSG_TYPE_BYTE + ctype: vm_offset_t; + + +type mach_port_t = MACH_MSG_TYPE_COPY_SEND; +type mach_port_array_t = array[] of mach_port_t; + +type mach_port_name_t = MACH_MSG_TYPE_PORT_NAME; +type mach_port_name_array_t = array[] of mach_port_name_t; + +type mach_port_right_t = natural_t; + +type mach_port_type_t = natural_t; +type mach_port_type_array_t = array[] of mach_port_type_t; + +type mach_port_urefs_t = natural_t; +type mach_port_delta_t = integer_t; +type mach_port_seqno_t = natural_t; +type mach_port_mscount_t = unsigned; +type mach_port_msgcount_t = unsigned; +type mach_port_rights_t = unsigned; +type mach_msg_id_t = integer_t; +type mach_msg_size_t = natural_t; +type mach_msg_type_name_t = unsigned; +type mach_msg_options_t = integer_t; + +type mach_port_move_receive_t = MACH_MSG_TYPE_MOVE_RECEIVE + ctype: mach_port_t; +type mach_port_copy_send_t = MACH_MSG_TYPE_COPY_SEND + ctype: mach_port_t; +type mach_port_make_send_t = MACH_MSG_TYPE_MAKE_SEND + ctype: mach_port_t; +type mach_port_move_send_t = MACH_MSG_TYPE_MOVE_SEND + ctype: mach_port_t; +type mach_port_make_send_once_t = MACH_MSG_TYPE_MAKE_SEND_ONCE + ctype: mach_port_t; +type mach_port_move_send_once_t = MACH_MSG_TYPE_MOVE_SEND_ONCE + ctype: mach_port_t; + +type mach_port_receive_t = MACH_MSG_TYPE_PORT_RECEIVE + ctype: mach_port_t; +type mach_port_send_t = MACH_MSG_TYPE_PORT_SEND + ctype: mach_port_t; +type mach_port_send_once_t = MACH_MSG_TYPE_PORT_SEND_ONCE + ctype: mach_port_t; + +type mach_port_poly_t = polymorphic + ctype: mach_port_t; + +import <mach/std_types.h>; +import <mach/mig.h>; + +#endif /* _MACH_STD_TYPES_DEFS_ */ + +/* vim: set ft=c : */ Index: branches/azimutz/Cleancut/i386/include/mach/x86_64/thread_act.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/x86_64/thread_act.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/x86_64/thread_act.h (revision 885) @@ -0,0 +1,1155 @@ +#ifndef _thread_act_user_ +#define _thread_act_user_ + +/* Module thread_act */ + +#include <string.h> +#include <mach/ndr.h> +#include <mach/boolean.h> +#include <mach/kern_return.h> +#include <mach/notify.h> +#include <mach/mach_types.h> +#include <mach/message.h> +#include <mach/mig_errors.h> +#include <mach/port.h> + +#ifdef AUTOTEST +#ifndef FUNCTION_PTR_T +#define FUNCTION_PTR_T +typedef void (*function_ptr_t)(mach_port_t, char *, mach_msg_type_number_t); +typedef struct { + char *name; + function_ptr_t function; +} function_table_entry; +typedef function_table_entry *function_table_t; +#endif /* FUNCTION_PTR_T */ +#endif /* AUTOTEST */ + +#ifndef thread_act_MSG_COUNT +#define thread_act_MSG_COUNT 25 +#endif /* thread_act_MSG_COUNT */ + +#include <mach/std_types.h> +#include <mach/mig.h> +#include <mach/mig.h> +#include <mach/mach_types.h> + +#ifdef __BeforeMigUserHeader +__BeforeMigUserHeader +#endif /* __BeforeMigUserHeader */ + +#include <sys/cdefs.h> +__BEGIN_DECLS + + +/* Routine thread_terminate */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_terminate +( + thread_act_t target_act +); + +/* Routine act_get_state */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t act_get_state +( + thread_act_t target_act, + int flavor, + thread_state_t old_state, + mach_msg_type_number_t *old_stateCnt +); + +/* Routine act_set_state */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t act_set_state +( + thread_act_t target_act, + int flavor, + thread_state_t new_state, + mach_msg_type_number_t new_stateCnt +); + +/* Routine thread_get_state */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_get_state +( + thread_act_t target_act, + thread_state_flavor_t flavor, + thread_state_t old_state, + mach_msg_type_number_t *old_stateCnt +); + +/* Routine thread_set_state */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_set_state +( + thread_act_t target_act, + thread_state_flavor_t flavor, + thread_state_t new_state, + mach_msg_type_number_t new_stateCnt +); + +/* Routine thread_suspend */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_suspend +( + thread_act_t target_act +); + +/* Routine thread_resume */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_resume +( + thread_act_t target_act +); + +/* Routine thread_abort */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_abort +( + thread_act_t target_act +); + +/* Routine thread_abort_safely */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_abort_safely +( + thread_act_t target_act +); + +/* Routine thread_depress_abort */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_depress_abort +( + thread_act_t thread +); + +/* Routine thread_get_special_port */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_get_special_port +( + thread_act_t thr_act, + int which_port, + mach_port_t *special_port +); + +/* Routine thread_set_special_port */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_set_special_port +( + thread_act_t thr_act, + int which_port, + mach_port_t special_port +); + +/* Routine thread_info */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_info +( + thread_act_t target_act, + thread_flavor_t flavor, + thread_info_t thread_info_out, + mach_msg_type_number_t *thread_info_outCnt +); + +/* Routine thread_set_exception_ports */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_set_exception_ports +( + thread_act_t thread, + exception_mask_t exception_mask, + mach_port_t new_port, + exception_behavior_t behavior, + thread_state_flavor_t new_flavor +); + +/* Routine thread_get_exception_ports */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_get_exception_ports +( + thread_act_t thread, + exception_mask_t exception_mask, + exception_mask_array_t masks, + mach_msg_type_number_t *masksCnt, + exception_handler_array_t old_handlers, + exception_behavior_array_t old_behaviors, + exception_flavor_array_t old_flavors +); + +/* Routine thread_swap_exception_ports */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_swap_exception_ports +( + thread_act_t thread, + exception_mask_t exception_mask, + mach_port_t new_port, + exception_behavior_t behavior, + thread_state_flavor_t new_flavor, + exception_mask_array_t masks, + mach_msg_type_number_t *masksCnt, + exception_handler_array_t old_handlers, + exception_behavior_array_t old_behaviors, + exception_flavor_array_t old_flavors +); + +/* Routine thread_policy */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_policy +( + thread_act_t thr_act, + policy_t policy, + policy_base_t base, + mach_msg_type_number_t baseCnt, + boolean_t set_limit +); + +/* Routine thread_policy_set */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_policy_set +( + thread_act_t thread, + thread_policy_flavor_t flavor, + thread_policy_t policy_info, + mach_msg_type_number_t policy_infoCnt +); + +/* Routine thread_policy_get */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_policy_get +( + thread_act_t thread, + thread_policy_flavor_t flavor, + thread_policy_t policy_info, + mach_msg_type_number_t *policy_infoCnt, + boolean_t *get_default +); + +/* Routine thread_sample */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_sample +( + thread_act_t thread, + mach_port_t reply +); + +/* Routine etap_trace_thread */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t etap_trace_thread +( + thread_act_t target_act, + boolean_t trace_status +); + +/* Routine thread_assign */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_assign +( + thread_act_t thread, + processor_set_t new_set +); + +/* Routine thread_assign_default */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_assign_default +( + thread_act_t thread +); + +/* Routine thread_get_assignment */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_get_assignment +( + thread_act_t thread, + processor_set_name_t *assigned_set +); + +/* Routine thread_set_policy */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_set_policy +( + thread_act_t thr_act, + processor_set_t pset, + policy_t policy, + policy_base_t base, + mach_msg_type_number_t baseCnt, + policy_limit_t limit, + mach_msg_type_number_t limitCnt +); + +__END_DECLS + +/********************** Caution **************************/ +/* The following data types should be used to calculate */ +/* maximum message sizes only. The actual message may be */ +/* smaller, and the position of the arguments within the */ +/* message layout may vary from what is presented here. */ +/* For example, if any of the arguments are variable- */ +/* sized, and less than the maximum is sent, the data */ +/* will be packed tight in the actual message to reduce */ +/* the presence of holes. */ +/********************** Caution **************************/ + +/* typedefs for all requests */ + +#ifndef __Request__thread_act_subsystem__defined +#define __Request__thread_act_subsystem__defined + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__thread_terminate_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + int flavor; + mach_msg_type_number_t old_stateCnt; + } __Request__act_get_state_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + int flavor; + mach_msg_type_number_t new_stateCnt; + natural_t new_state[144]; + } __Request__act_set_state_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + thread_state_flavor_t flavor; + mach_msg_type_number_t old_stateCnt; + } __Request__thread_get_state_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + thread_state_flavor_t flavor; + mach_msg_type_number_t new_stateCnt; + natural_t new_state[144]; + } __Request__thread_set_state_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__thread_suspend_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__thread_resume_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__thread_abort_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__thread_abort_safely_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__thread_depress_abort_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + int which_port; + } __Request__thread_get_special_port_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t special_port; + /* end of the kernel processed data */ + NDR_record_t NDR; + int which_port; + } __Request__thread_set_special_port_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + thread_flavor_t flavor; + mach_msg_type_number_t thread_info_outCnt; + } __Request__thread_info_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t new_port; + /* end of the kernel processed data */ + NDR_record_t NDR; + exception_mask_t exception_mask; + exception_behavior_t behavior; + thread_state_flavor_t new_flavor; + } __Request__thread_set_exception_ports_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + exception_mask_t exception_mask; + } __Request__thread_get_exception_ports_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t new_port; + /* end of the kernel processed data */ + NDR_record_t NDR; + exception_mask_t exception_mask; + exception_behavior_t behavior; + thread_state_flavor_t new_flavor; + } __Request__thread_swap_exception_ports_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + policy_t policy; + mach_msg_type_number_t baseCnt; + integer_t base[5]; + boolean_t set_limit; + } __Request__thread_policy_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + thread_policy_flavor_t flavor; + mach_msg_type_number_t policy_infoCnt; + integer_t policy_info[16]; + } __Request__thread_policy_set_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + thread_policy_flavor_t flavor; + mach_msg_type_number_t policy_infoCnt; + boolean_t get_default; + } __Request__thread_policy_get_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t reply; + /* end of the kernel processed data */ + } __Request__thread_sample_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + boolean_t trace_status; + } __Request__etap_trace_thread_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t new_set; + /* end of the kernel processed data */ + } __Request__thread_assign_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__thread_assign_default_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__thread_get_assignment_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t pset; + /* end of the kernel processed data */ + NDR_record_t NDR; + policy_t policy; + mach_msg_type_number_t baseCnt; + integer_t base[5]; + mach_msg_type_number_t limitCnt; + integer_t limit[1]; + } __Request__thread_set_policy_t; +#ifdef __MigPackStructs +#pragma pack() +#endif +#endif /* !__Request__thread_act_subsystem__defined */ + +/* union of all requests */ + +#ifndef __RequestUnion__thread_act_subsystem__defined +#define __RequestUnion__thread_act_subsystem__defined +union __RequestUnion__thread_act_subsystem { + __Request__thread_terminate_t Request_thread_terminate; + __Request__act_get_state_t Request_act_get_state; + __Request__act_set_state_t Request_act_set_state; + __Request__thread_get_state_t Request_thread_get_state; + __Request__thread_set_state_t Request_thread_set_state; + __Request__thread_suspend_t Request_thread_suspend; + __Request__thread_resume_t Request_thread_resume; + __Request__thread_abort_t Request_thread_abort; + __Request__thread_abort_safely_t Request_thread_abort_safely; + __Request__thread_depress_abort_t Request_thread_depress_abort; + __Request__thread_get_special_port_t Request_thread_get_special_port; + __Request__thread_set_special_port_t Request_thread_set_special_port; + __Request__thread_info_t Request_thread_info; + __Request__thread_set_exception_ports_t Request_thread_set_exception_ports; + __Request__thread_get_exception_ports_t Request_thread_get_exception_ports; + __Request__thread_swap_exception_ports_t Request_thread_swap_exception_ports; + __Request__thread_policy_t Request_thread_policy; + __Request__thread_policy_set_t Request_thread_policy_set; + __Request__thread_policy_get_t Request_thread_policy_get; + __Request__thread_sample_t Request_thread_sample; + __Request__etap_trace_thread_t Request_etap_trace_thread; + __Request__thread_assign_t Request_thread_assign; + __Request__thread_assign_default_t Request_thread_assign_default; + __Request__thread_get_assignment_t Request_thread_get_assignment; + __Request__thread_set_policy_t Request_thread_set_policy; +}; +#endif /* !__RequestUnion__thread_act_subsystem__defined */ +/* typedefs for all replies */ + +#ifndef __Reply__thread_act_subsystem__defined +#define __Reply__thread_act_subsystem__defined + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_terminate_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_msg_type_number_t old_stateCnt; + natural_t old_state[144]; + } __Reply__act_get_state_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__act_set_state_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_msg_type_number_t old_stateCnt; + natural_t old_state[144]; + } __Reply__thread_get_state_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_set_state_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_suspend_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_resume_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_abort_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_abort_safely_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_depress_abort_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t special_port; + /* end of the kernel processed data */ + } __Reply__thread_get_special_port_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_set_special_port_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_msg_type_number_t thread_info_outCnt; + integer_t thread_info_out[12]; + } __Reply__thread_info_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_set_exception_ports_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t old_handlers[32]; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t masksCnt; + exception_mask_t masks[32]; + exception_behavior_t old_behaviors[32]; + thread_state_flavor_t old_flavors[32]; + } __Reply__thread_get_exception_ports_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t old_handlers[32]; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t masksCnt; + exception_mask_t masks[32]; + exception_behavior_t old_behaviors[32]; + thread_state_flavor_t old_flavors[32]; + } __Reply__thread_swap_exception_ports_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_policy_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_policy_set_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_msg_type_number_t policy_infoCnt; + integer_t policy_info[16]; + boolean_t get_default; + } __Reply__thread_policy_get_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_sample_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__etap_trace_thread_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_assign_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_assign_default_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t assigned_set; + /* end of the kernel processed data */ + } __Reply__thread_get_assignment_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_set_policy_t; +#ifdef __MigPackStructs +#pragma pack() +#endif +#endif /* !__Reply__thread_act_subsystem__defined */ + +/* union of all replies */ + +#ifndef __ReplyUnion__thread_act_subsystem__defined +#define __ReplyUnion__thread_act_subsystem__defined +union __ReplyUnion__thread_act_subsystem { + __Reply__thread_terminate_t Reply_thread_terminate; + __Reply__act_get_state_t Reply_act_get_state; + __Reply__act_set_state_t Reply_act_set_state; + __Reply__thread_get_state_t Reply_thread_get_state; + __Reply__thread_set_state_t Reply_thread_set_state; + __Reply__thread_suspend_t Reply_thread_suspend; + __Reply__thread_resume_t Reply_thread_resume; + __Reply__thread_abort_t Reply_thread_abort; + __Reply__thread_abort_safely_t Reply_thread_abort_safely; + __Reply__thread_depress_abort_t Reply_thread_depress_abort; + __Reply__thread_get_special_port_t Reply_thread_get_special_port; + __Reply__thread_set_special_port_t Reply_thread_set_special_port; + __Reply__thread_info_t Reply_thread_info; + __Reply__thread_set_exception_ports_t Reply_thread_set_exception_ports; + __Reply__thread_get_exception_ports_t Reply_thread_get_exception_ports; + __Reply__thread_swap_exception_ports_t Reply_thread_swap_exception_ports; + __Reply__thread_policy_t Reply_thread_policy; + __Reply__thread_policy_set_t Reply_thread_policy_set; + __Reply__thread_policy_get_t Reply_thread_policy_get; + __Reply__thread_sample_t Reply_thread_sample; + __Reply__etap_trace_thread_t Reply_etap_trace_thread; + __Reply__thread_assign_t Reply_thread_assign; + __Reply__thread_assign_default_t Reply_thread_assign_default; + __Reply__thread_get_assignment_t Reply_thread_get_assignment; + __Reply__thread_set_policy_t Reply_thread_set_policy; +}; +#endif /* !__RequestUnion__thread_act_subsystem__defined */ + +#ifndef subsystem_to_name_map_thread_act +#define subsystem_to_name_map_thread_act \ + { "thread_terminate", 3600 },\ + { "act_get_state", 3601 },\ + { "act_set_state", 3602 },\ + { "thread_get_state", 3603 },\ + { "thread_set_state", 3604 },\ + { "thread_suspend", 3605 },\ + { "thread_resume", 3606 },\ + { "thread_abort", 3607 },\ + { "thread_abort_safely", 3608 },\ + { "thread_depress_abort", 3609 },\ + { "thread_get_special_port", 3610 },\ + { "thread_set_special_port", 3611 },\ + { "thread_info", 3612 },\ + { "thread_set_exception_ports", 3613 },\ + { "thread_get_exception_ports", 3614 },\ + { "thread_swap_exception_ports", 3615 },\ + { "thread_policy", 3616 },\ + { "thread_policy_set", 3617 },\ + { "thread_policy_get", 3618 },\ + { "thread_sample", 3619 },\ + { "etap_trace_thread", 3620 },\ + { "thread_assign", 3621 },\ + { "thread_assign_default", 3622 },\ + { "thread_get_assignment", 3623 },\ + { "thread_set_policy", 3624 } +#endif + +#ifdef __AfterMigUserHeader +__AfterMigUserHeader +#endif /* __AfterMigUserHeader */ + +#endif /* _thread_act_user_ */ Index: branches/azimutz/Cleancut/i386/include/mach/x86_64/task.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/x86_64/task.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/x86_64/task.h (revision 885) @@ -0,0 +1,1578 @@ +#ifndef _task_user_ +#define _task_user_ + +/* Module task */ + +#include <string.h> +#include <mach/ndr.h> +#include <mach/boolean.h> +#include <mach/kern_return.h> +#include <mach/notify.h> +#include <mach/mach_types.h> +#include <mach/message.h> +#include <mach/mig_errors.h> +#include <mach/port.h> + +#ifdef AUTOTEST +#ifndef FUNCTION_PTR_T +#define FUNCTION_PTR_T +typedef void (*function_ptr_t)(mach_port_t, char *, mach_msg_type_number_t); +typedef struct { + char *name; + function_ptr_t function; +} function_table_entry; +typedef function_table_entry *function_table_t; +#endif /* FUNCTION_PTR_T */ +#endif /* AUTOTEST */ + +#ifndef task_MSG_COUNT +#define task_MSG_COUNT 35 +#endif /* task_MSG_COUNT */ + +#include <mach/std_types.h> +#include <mach/mig.h> +#include <mach/mig.h> +#include <mach/mach_types.h> + +#ifdef __BeforeMigUserHeader +__BeforeMigUserHeader +#endif /* __BeforeMigUserHeader */ + +#include <sys/cdefs.h> +__BEGIN_DECLS + + +/* Routine task_create */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_create +( + task_t target_task, + ledger_array_t ledgers, + mach_msg_type_number_t ledgersCnt, + boolean_t inherit_memory, + task_t *child_task +); + +/* Routine task_terminate */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_terminate +( + task_t target_task +); + +/* Routine task_threads */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_threads +( + task_t target_task, + thread_act_array_t *act_list, + mach_msg_type_number_t *act_listCnt +); + +/* Routine mach_ports_register */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_ports_register +( + task_t target_task, + mach_port_array_t init_port_set, + mach_msg_type_number_t init_port_setCnt +); + +/* Routine mach_ports_lookup */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_ports_lookup +( + task_t target_task, + mach_port_array_t *init_port_set, + mach_msg_type_number_t *init_port_setCnt +); + +/* Routine task_info */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_info +( + task_name_t target_task, + task_flavor_t flavor, + task_info_t task_info_out, + mach_msg_type_number_t *task_info_outCnt +); + +/* Routine task_set_info */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_set_info +( + task_t target_task, + task_flavor_t flavor, + task_info_t task_info_in, + mach_msg_type_number_t task_info_inCnt +); + +/* Routine task_suspend */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_suspend +( + task_t target_task +); + +/* Routine task_resume */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_resume +( + task_t target_task +); + +/* Routine task_get_special_port */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_get_special_port +( + task_t task, + int which_port, + mach_port_t *special_port +); + +/* Routine task_set_special_port */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_set_special_port +( + task_t task, + int which_port, + mach_port_t special_port +); + +/* Routine thread_create */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_create +( + task_t parent_task, + thread_act_t *child_act +); + +/* Routine thread_create_running */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_create_running +( + task_t parent_task, + thread_state_flavor_t flavor, + thread_state_t new_state, + mach_msg_type_number_t new_stateCnt, + thread_act_t *child_act +); + +/* Routine task_set_exception_ports */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_set_exception_ports +( + task_t task, + exception_mask_t exception_mask, + mach_port_t new_port, + exception_behavior_t behavior, + thread_state_flavor_t new_flavor +); + +/* Routine task_get_exception_ports */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_get_exception_ports +( + task_t task, + exception_mask_t exception_mask, + exception_mask_array_t masks, + mach_msg_type_number_t *masksCnt, + exception_handler_array_t old_handlers, + exception_behavior_array_t old_behaviors, + exception_flavor_array_t old_flavors +); + +/* Routine task_swap_exception_ports */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_swap_exception_ports +( + task_t task, + exception_mask_t exception_mask, + mach_port_t new_port, + exception_behavior_t behavior, + thread_state_flavor_t new_flavor, + exception_mask_array_t masks, + mach_msg_type_number_t *masksCnt, + exception_handler_array_t old_handlerss, + exception_behavior_array_t old_behaviors, + exception_flavor_array_t old_flavors +); + +/* Routine lock_set_create */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t lock_set_create +( + task_t task, + lock_set_t *new_lock_set, + int n_ulocks, + int policy +); + +/* Routine lock_set_destroy */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t lock_set_destroy +( + task_t task, + lock_set_t lock_set +); + +/* Routine semaphore_create */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t semaphore_create +( + task_t task, + semaphore_t *semaphore, + int policy, + int value +); + +/* Routine semaphore_destroy */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t semaphore_destroy +( + task_t task, + semaphore_t semaphore +); + +/* Routine task_policy_set */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_policy_set +( + task_t task, + task_policy_flavor_t flavor, + task_policy_t policy_info, + mach_msg_type_number_t policy_infoCnt +); + +/* Routine task_policy_get */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_policy_get +( + task_t task, + task_policy_flavor_t flavor, + task_policy_t policy_info, + mach_msg_type_number_t *policy_infoCnt, + boolean_t *get_default +); + +/* Routine task_sample */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_sample +( + task_t task, + mach_port_t reply +); + +/* Routine task_policy */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_policy +( + task_t task, + policy_t policy, + policy_base_t base, + mach_msg_type_number_t baseCnt, + boolean_t set_limit, + boolean_t change +); + +/* Routine task_set_emulation */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_set_emulation +( + task_t target_port, + vm_address_t routine_entry_pt, + int routine_number +); + +/* Routine task_get_emulation_vector */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_get_emulation_vector +( + task_t task, + int *vector_start, + emulation_vector_t *emulation_vector, + mach_msg_type_number_t *emulation_vectorCnt +); + +/* Routine task_set_emulation_vector */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_set_emulation_vector +( + task_t task, + int vector_start, + emulation_vector_t emulation_vector, + mach_msg_type_number_t emulation_vectorCnt +); + +/* Routine task_set_ras_pc */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_set_ras_pc +( + task_t target_task, + vm_address_t basepc, + vm_address_t boundspc +); + +/* Routine task_assign */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_assign +( + task_t task, + processor_set_t new_set, + boolean_t assign_threads +); + +/* Routine task_assign_default */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_assign_default +( + task_t task, + boolean_t assign_threads +); + +/* Routine task_get_assignment */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_get_assignment +( + task_t task, + processor_set_name_t *assigned_set +); + +/* Routine task_set_policy */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_set_policy +( + task_t task, + processor_set_t pset, + policy_t policy, + policy_base_t base, + mach_msg_type_number_t baseCnt, + policy_limit_t limit, + mach_msg_type_number_t limitCnt, + boolean_t change +); + +/* Routine task_get_state */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_get_state +( + task_t task, + thread_state_flavor_t flavor, + thread_state_t old_state, + mach_msg_type_number_t *old_stateCnt +); + +/* Routine task_set_state */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_set_state +( + task_t task, + thread_state_flavor_t flavor, + thread_state_t new_state, + mach_msg_type_number_t new_stateCnt +); + +__END_DECLS + +/********************** Caution **************************/ +/* The following data types should be used to calculate */ +/* maximum message sizes only. The actual message may be */ +/* smaller, and the position of the arguments within the */ +/* message layout may vary from what is presented here. */ +/* For example, if any of the arguments are variable- */ +/* sized, and less than the maximum is sent, the data */ +/* will be packed tight in the actual message to reduce */ +/* the presence of holes. */ +/********************** Caution **************************/ + +/* typedefs for all requests */ + +#ifndef __Request__task_subsystem__defined +#define __Request__task_subsystem__defined + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_ports_descriptor_t ledgers; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t ledgersCnt; + boolean_t inherit_memory; + } __Request__task_create_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__task_terminate_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__task_threads_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_ports_descriptor_t init_port_set; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t init_port_setCnt; + } __Request__mach_ports_register_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__mach_ports_lookup_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + task_flavor_t flavor; + mach_msg_type_number_t task_info_outCnt; + } __Request__task_info_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + task_flavor_t flavor; + mach_msg_type_number_t task_info_inCnt; + integer_t task_info_in[10]; + } __Request__task_set_info_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__task_suspend_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__task_resume_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + int which_port; + } __Request__task_get_special_port_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t special_port; + /* end of the kernel processed data */ + NDR_record_t NDR; + int which_port; + } __Request__task_set_special_port_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__thread_create_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + thread_state_flavor_t flavor; + mach_msg_type_number_t new_stateCnt; + natural_t new_state[144]; + } __Request__thread_create_running_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t new_port; + /* end of the kernel processed data */ + NDR_record_t NDR; + exception_mask_t exception_mask; + exception_behavior_t behavior; + thread_state_flavor_t new_flavor; + } __Request__task_set_exception_ports_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + exception_mask_t exception_mask; + } __Request__task_get_exception_ports_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t new_port; + /* end of the kernel processed data */ + NDR_record_t NDR; + exception_mask_t exception_mask; + exception_behavior_t behavior; + thread_state_flavor_t new_flavor; + } __Request__task_swap_exception_ports_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + int n_ulocks; + int policy; + } __Request__lock_set_create_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t lock_set; + /* end of the kernel processed data */ + } __Request__lock_set_destroy_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + int policy; + int value; + } __Request__semaphore_create_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t semaphore; + /* end of the kernel processed data */ + } __Request__semaphore_destroy_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + task_policy_flavor_t flavor; + mach_msg_type_number_t policy_infoCnt; + integer_t policy_info[16]; + } __Request__task_policy_set_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + task_policy_flavor_t flavor; + mach_msg_type_number_t policy_infoCnt; + boolean_t get_default; + } __Request__task_policy_get_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t reply; + /* end of the kernel processed data */ + } __Request__task_sample_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + policy_t policy; + mach_msg_type_number_t baseCnt; + integer_t base[5]; + boolean_t set_limit; + boolean_t change; + } __Request__task_policy_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + vm_address_t routine_entry_pt; + int routine_number; + } __Request__task_set_emulation_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__task_get_emulation_vector_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_descriptor_t emulation_vector; + /* end of the kernel processed data */ + NDR_record_t NDR; + int vector_start; + mach_msg_type_number_t emulation_vectorCnt; + } __Request__task_set_emulation_vector_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + vm_address_t basepc; + vm_address_t boundspc; + } __Request__task_set_ras_pc_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t new_set; + /* end of the kernel processed data */ + NDR_record_t NDR; + boolean_t assign_threads; + } __Request__task_assign_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + boolean_t assign_threads; + } __Request__task_assign_default_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__task_get_assignment_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t pset; + /* end of the kernel processed data */ + NDR_record_t NDR; + policy_t policy; + mach_msg_type_number_t baseCnt; + integer_t base[5]; + mach_msg_type_number_t limitCnt; + integer_t limit[1]; + boolean_t change; + } __Request__task_set_policy_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + thread_state_flavor_t flavor; + mach_msg_type_number_t old_stateCnt; + } __Request__task_get_state_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + thread_state_flavor_t flavor; + mach_msg_type_number_t new_stateCnt; + natural_t new_state[144]; + } __Request__task_set_state_t; +#ifdef __MigPackStructs +#pragma pack() +#endif +#endif /* !__Request__task_subsystem__defined */ + +/* union of all requests */ + +#ifndef __RequestUnion__task_subsystem__defined +#define __RequestUnion__task_subsystem__defined +union __RequestUnion__task_subsystem { + __Request__task_create_t Request_task_create; + __Request__task_terminate_t Request_task_terminate; + __Request__task_threads_t Request_task_threads; + __Request__mach_ports_register_t Request_mach_ports_register; + __Request__mach_ports_lookup_t Request_mach_ports_lookup; + __Request__task_info_t Request_task_info; + __Request__task_set_info_t Request_task_set_info; + __Request__task_suspend_t Request_task_suspend; + __Request__task_resume_t Request_task_resume; + __Request__task_get_special_port_t Request_task_get_special_port; + __Request__task_set_special_port_t Request_task_set_special_port; + __Request__thread_create_t Request_thread_create; + __Request__thread_create_running_t Request_thread_create_running; + __Request__task_set_exception_ports_t Request_task_set_exception_ports; + __Request__task_get_exception_ports_t Request_task_get_exception_ports; + __Request__task_swap_exception_ports_t Request_task_swap_exception_ports; + __Request__lock_set_create_t Request_lock_set_create; + __Request__lock_set_destroy_t Request_lock_set_destroy; + __Request__semaphore_create_t Request_semaphore_create; + __Request__semaphore_destroy_t Request_semaphore_destroy; + __Request__task_policy_set_t Request_task_policy_set; + __Request__task_policy_get_t Request_task_policy_get; + __Request__task_sample_t Request_task_sample; + __Request__task_policy_t Request_task_policy; + __Request__task_set_emulation_t Request_task_set_emulation; + __Request__task_get_emulation_vector_t Request_task_get_emulation_vector; + __Request__task_set_emulation_vector_t Request_task_set_emulation_vector; + __Request__task_set_ras_pc_t Request_task_set_ras_pc; + __Request__task_assign_t Request_task_assign; + __Request__task_assign_default_t Request_task_assign_default; + __Request__task_get_assignment_t Request_task_get_assignment; + __Request__task_set_policy_t Request_task_set_policy; + __Request__task_get_state_t Request_task_get_state; + __Request__task_set_state_t Request_task_set_state; +}; +#endif /* !__RequestUnion__task_subsystem__defined */ +/* typedefs for all replies */ + +#ifndef __Reply__task_subsystem__defined +#define __Reply__task_subsystem__defined + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t child_task; + /* end of the kernel processed data */ + } __Reply__task_create_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_terminate_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_ports_descriptor_t act_list; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t act_listCnt; + } __Reply__task_threads_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__mach_ports_register_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_ports_descriptor_t init_port_set; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t init_port_setCnt; + } __Reply__mach_ports_lookup_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_msg_type_number_t task_info_outCnt; + integer_t task_info_out[10]; + } __Reply__task_info_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_set_info_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_suspend_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_resume_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t special_port; + /* end of the kernel processed data */ + } __Reply__task_get_special_port_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_set_special_port_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t child_act; + /* end of the kernel processed data */ + } __Reply__thread_create_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t child_act; + /* end of the kernel processed data */ + } __Reply__thread_create_running_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_set_exception_ports_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t old_handlers[32]; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t masksCnt; + exception_mask_t masks[32]; + exception_behavior_t old_behaviors[32]; + thread_state_flavor_t old_flavors[32]; + } __Reply__task_get_exception_ports_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t old_handlerss[32]; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t masksCnt; + exception_mask_t masks[32]; + exception_behavior_t old_behaviors[32]; + thread_state_flavor_t old_flavors[32]; + } __Reply__task_swap_exception_ports_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t new_lock_set; + /* end of the kernel processed data */ + } __Reply__lock_set_create_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__lock_set_destroy_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t semaphore; + /* end of the kernel processed data */ + } __Reply__semaphore_create_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__semaphore_destroy_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_policy_set_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_msg_type_number_t policy_infoCnt; + integer_t policy_info[16]; + boolean_t get_default; + } __Reply__task_policy_get_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_sample_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_policy_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_set_emulation_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_descriptor_t emulation_vector; + /* end of the kernel processed data */ + NDR_record_t NDR; + int vector_start; + mach_msg_type_number_t emulation_vectorCnt; + } __Reply__task_get_emulation_vector_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_set_emulation_vector_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_set_ras_pc_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_assign_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_assign_default_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t assigned_set; + /* end of the kernel processed data */ + } __Reply__task_get_assignment_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_set_policy_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_msg_type_number_t old_stateCnt; + natural_t old_state[144]; + } __Reply__task_get_state_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_set_state_t; +#ifdef __MigPackStructs +#pragma pack() +#endif +#endif /* !__Reply__task_subsystem__defined */ + +/* union of all replies */ + +#ifndef __ReplyUnion__task_subsystem__defined +#define __ReplyUnion__task_subsystem__defined +union __ReplyUnion__task_subsystem { + __Reply__task_create_t Reply_task_create; + __Reply__task_terminate_t Reply_task_terminate; + __Reply__task_threads_t Reply_task_threads; + __Reply__mach_ports_register_t Reply_mach_ports_register; + __Reply__mach_ports_lookup_t Reply_mach_ports_lookup; + __Reply__task_info_t Reply_task_info; + __Reply__task_set_info_t Reply_task_set_info; + __Reply__task_suspend_t Reply_task_suspend; + __Reply__task_resume_t Reply_task_resume; + __Reply__task_get_special_port_t Reply_task_get_special_port; + __Reply__task_set_special_port_t Reply_task_set_special_port; + __Reply__thread_create_t Reply_thread_create; + __Reply__thread_create_running_t Reply_thread_create_running; + __Reply__task_set_exception_ports_t Reply_task_set_exception_ports; + __Reply__task_get_exception_ports_t Reply_task_get_exception_ports; + __Reply__task_swap_exception_ports_t Reply_task_swap_exception_ports; + __Reply__lock_set_create_t Reply_lock_set_create; + __Reply__lock_set_destroy_t Reply_lock_set_destroy; + __Reply__semaphore_create_t Reply_semaphore_create; + __Reply__semaphore_destroy_t Reply_semaphore_destroy; + __Reply__task_policy_set_t Reply_task_policy_set; + __Reply__task_policy_get_t Reply_task_policy_get; + __Reply__task_sample_t Reply_task_sample; + __Reply__task_policy_t Reply_task_policy; + __Reply__task_set_emulation_t Reply_task_set_emulation; + __Reply__task_get_emulation_vector_t Reply_task_get_emulation_vector; + __Reply__task_set_emulation_vector_t Reply_task_set_emulation_vector; + __Reply__task_set_ras_pc_t Reply_task_set_ras_pc; + __Reply__task_assign_t Reply_task_assign; + __Reply__task_assign_default_t Reply_task_assign_default; + __Reply__task_get_assignment_t Reply_task_get_assignment; + __Reply__task_set_policy_t Reply_task_set_policy; + __Reply__task_get_state_t Reply_task_get_state; + __Reply__task_set_state_t Reply_task_set_state; +}; +#endif /* !__RequestUnion__task_subsystem__defined */ + +#ifndef subsystem_to_name_map_task +#define subsystem_to_name_map_task \ + { "task_create", 3400 },\ + { "task_terminate", 3401 },\ + { "task_threads", 3402 },\ + { "mach_ports_register", 3403 },\ + { "mach_ports_lookup", 3404 },\ + { "task_info", 3405 },\ + { "task_set_info", 3406 },\ + { "task_suspend", 3407 },\ + { "task_resume", 3408 },\ + { "task_get_special_port", 3409 },\ + { "task_set_special_port", 3410 },\ + { "thread_create", 3411 },\ + { "thread_create_running", 3412 },\ + { "task_set_exception_ports", 3413 },\ + { "task_get_exception_ports", 3414 },\ + { "task_swap_exception_ports", 3415 },\ + { "lock_set_create", 3416 },\ + { "lock_set_destroy", 3417 },\ + { "semaphore_create", 3418 },\ + { "semaphore_destroy", 3419 },\ + { "task_policy_set", 3420 },\ + { "task_policy_get", 3421 },\ + { "task_sample", 3422 },\ + { "task_policy", 3423 },\ + { "task_set_emulation", 3424 },\ + { "task_get_emulation_vector", 3425 },\ + { "task_set_emulation_vector", 3426 },\ + { "task_set_ras_pc", 3427 },\ + { "task_assign", 3429 },\ + { "task_assign_default", 3430 },\ + { "task_get_assignment", 3431 },\ + { "task_set_policy", 3432 },\ + { "task_get_state", 3433 },\ + { "task_set_state", 3434 } +#endif + +#ifdef __AfterMigUserHeader +__AfterMigUserHeader +#endif /* __AfterMigUserHeader */ + +#endif /* _task_user_ */ Index: branches/azimutz/Cleancut/i386/include/mach/clock_types.defs =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/clock_types.defs (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/clock_types.defs (revision 885) @@ -0,0 +1,73 @@ +/* + * Copyright (c) 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@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * File: clock_types.defs + * Purpose: + * Clock kernel interface type declarations + */ + +#ifndef _MACH_CLOCK_TYPES_DEFS_ +#define _MACH_CLOCK_TYPES_DEFS_ + +#include <mach/std_types.defs> + +type clock_serv_t = mach_port_t + cusertype: clock_serv_t +#if KERNEL_SERVER + intran: clock_serv_t convert_port_to_clock(mach_port_t) + outtran: mach_port_t convert_clock_to_port(clock_serv_t) +#endif /* KERNEL_SERVER */ + ; + +type clock_ctrl_t = mach_port_t + cusertype: clock_ctrl_t +#if KERNEL_SERVER + intran: clock_ctrl_t convert_port_to_clock_ctrl(mach_port_t) + outtran: mach_port_t convert_clock_ctrl_to_port(clock_ctrl_t) +#endif /* KERNEL_SERVER */ + ; + +type clock_reply_t = polymorphic|MACH_MSG_TYPE_MAKE_SEND_ONCE; + +type clock_flavor_t = int; +type clock_attr_t = array[*:1] of int; +type mach_timespec_t = struct[2] of int; +type time_t = int; +type sleep_type_t = int; +type alarm_type_t = int; +type clock_res_t = int; +type clock_id_t = int; + +import <mach/mach_types.h>; + +#endif /* _MACH_CLOCK_TYPES_DEFS_ */ + +/* vim: set ft=c : */ Index: branches/azimutz/Cleancut/i386/include/mach/shared_region.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/shared_region.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/shared_region.h (revision 885) @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2007 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@ + */ +/* + * + * File: mach/shared_region.h + * + * protos and struct definitions for shared region + */ + +#ifndef _MACH_SHARED_REGION_H_ +#define _MACH_SHARED_REGION_H_ + +#include <sys/cdefs.h> +#include <mach/vm_prot.h> +#include <mach/vm_types.h> +#include <mach/mach_types.h> + +#define SHARED_REGION_BASE_I386 0x90000000ULL +#define SHARED_REGION_SIZE_I386 0x20000000ULL +#define SHARED_REGION_NESTING_BASE_I386 0x90000000ULL +#define SHARED_REGION_NESTING_SIZE_I386 0x20000000ULL +#define SHARED_REGION_NESTING_MIN_I386 0x00200000ULL +#define SHARED_REGION_NESTING_MAX_I386 0xFFE00000ULL + +#define SHARED_REGION_BASE_X86_64 0x00007FFF70000000ULL +#define SHARED_REGION_SIZE_X86_64 0x000000008FE00000ULL +#define SHARED_REGION_NESTING_BASE_X86_64 0x00007FFF80000000ULL +#define SHARED_REGION_NESTING_SIZE_X86_64 0x0000000040000000ULL +#define SHARED_REGION_NESTING_MIN_X86_64 0x0000000000200000ULL +#define SHARED_REGION_NESTING_MAX_X86_64 0xFFFFFFFFFFE00000ULL + +#define SHARED_REGION_BASE_PPC 0x90000000ULL +#define SHARED_REGION_SIZE_PPC 0x20000000ULL +#define SHARED_REGION_NESTING_BASE_PPC 0x90000000ULL +#define SHARED_REGION_NESTING_SIZE_PPC 0x10000000ULL +#define SHARED_REGION_NESTING_MIN_PPC 0x10000000ULL +#define SHARED_REGION_NESTING_MAX_PPC 0x10000000ULL + +#define SHARED_REGION_BASE_PPC64 0x00007FFF60000000ULL +#define SHARED_REGION_SIZE_PPC64 0x00000000A0000000ULL +#define SHARED_REGION_NESTING_BASE_PPC64 0x00007FFF60000000ULL +#define SHARED_REGION_NESTING_SIZE_PPC64 0x00000000A0000000ULL +#define SHARED_REGION_NESTING_MIN_PPC64 0x0000000010000000ULL +#define SHARED_REGION_NESTING_MAX_PPC64 0x0000000010000000ULL + +#define SHARED_REGION_BASE_ARM 0x30000000ULL +#define SHARED_REGION_SIZE_ARM 0x10000000ULL +#define SHARED_REGION_NESTING_BASE_ARM 0x30000000ULL +#define SHARED_REGION_NESTING_SIZE_ARM 0x08000000ULL +#define SHARED_REGION_NESTING_MIN_ARM ? +#define SHARED_REGION_NESTING_MAX_ARM ? + +#if defined(__i386__) +#define SHARED_REGION_BASE SHARED_REGION_BASE_I386 +#define SHARED_REGION_SIZE SHARED_REGION_SIZE_I386 +#define SHARED_REGION_NESTING_BASE SHARED_REGION_NESTING_BASE_I386 +#define SHARED_REGION_NESTING_SIZE SHARED_REGION_NESTING_SIZE_I386 +#define SHARED_REGION_NESTING_MIN SHARED_REGION_NESTING_MIN_I386 +#define SHARED_REGION_NESTING_MAX SHARED_REGION_NESTING_MAX_I386 +#elif defined(__x86_64__) +#define SHARED_REGION_BASE SHARED_REGION_BASE_X86_64 +#define SHARED_REGION_SIZE SHARED_REGION_SIZE_X86_64 +#define SHARED_REGION_NESTING_BASE SHARED_REGION_NESTING_BASE_X86_64 +#define SHARED_REGION_NESTING_SIZE SHARED_REGION_NESTING_SIZE_X86_64 +#define SHARED_REGION_NESTING_MIN SHARED_REGION_NESTING_MIN_X86_64 +#define SHARED_REGION_NESTING_MAX SHARED_REGION_NESTING_MAX_X86_64 +#elif defined(__ppc__) +#define SHARED_REGION_BASE SHARED_REGION_BASE_PPC +#define SHARED_REGION_SIZE SHARED_REGION_SIZE_PPC +#define SHARED_REGION_NESTING_BASE SHARED_REGION_NESTING_BASE_PPC +#define SHARED_REGION_NESTING_SIZE SHARED_REGION_NESTING_SIZE_PPC +#define SHARED_REGION_NESTING_MIN SHARED_REGION_NESTING_MIN_PPC +#define SHARED_REGION_NESTING_MAX SHARED_REGION_NESTING_MAX_PPC +#elif defined(__ppc64__) +#define SHARED_REGION_BASE SHARED_REGION_BASE_PPC64 +#define SHARED_REGION_SIZE SHARED_REGION_SIZE_PPC64 +#define SHARED_REGION_NESTING_BASE SHARED_REGION_NESTING_BASE_PPC64 +#define SHARED_REGION_NESTING_SIZE SHARED_REGION_NESTING_SIZE_PPC64 +#define SHARED_REGION_NESTING_MIN SHARED_REGION_NESTING_MIN_PPC64 +#define SHARED_REGION_NESTING_MAX SHARED_REGION_NESTING_MAX_PPC64 +#elif defined(__arm__) +#define SHARED_REGION_BASE SHARED_REGION_BASE_ARM +#define SHARED_REGION_SIZE SHARED_REGION_SIZE_ARM +#define SHARED_REGION_NESTING_BASE SHARED_REGION_NESTING_BASE_ARM +#define SHARED_REGION_NESTING_SIZE SHARED_REGION_NESTING_SIZE_ARM +#define SHARED_REGION_NESTING_MIN SHARED_REGION_NESTING_MIN_ARM +#define SHARED_REGION_NESTING_MAX SHARED_REGION_NESTING_MAX_ARM +#endif + +/* + * All shared_region_* declarations are a private interface + * between dyld and the kernel. + * + */ +struct shared_file_mapping_np { + mach_vm_address_t sfm_address; + mach_vm_size_t sfm_size; + mach_vm_offset_t sfm_file_offset; + vm_prot_t sfm_max_prot; + vm_prot_t sfm_init_prot; +}; +#define VM_PROT_COW 0x8 /* must not interfere with normal prot assignments */ +#define VM_PROT_ZF 0x10 /* must not interfere with normal prot assignments */ + + +__BEGIN_DECLS +int shared_region_check_np(uint64_t *startaddress); +int shared_region_map_np(int fd, + uint32_t mappingCount, + const struct shared_file_mapping_np *mappings); +__END_DECLS + + +#endif /* _MACH_SHARED_REGION_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/mach_port.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/mach_port.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/mach_port.h (revision 885) @@ -0,0 +1,1383 @@ +#ifndef _mach_port_user_ +#define _mach_port_user_ + +/* Module mach_port */ + +#include <string.h> +#include <mach/ndr.h> +#include <mach/boolean.h> +#include <mach/kern_return.h> +#include <mach/notify.h> +#include <mach/mach_types.h> +#include <mach/message.h> +#include <mach/mig_errors.h> +#include <mach/port.h> + +#ifdef AUTOTEST +#ifndef FUNCTION_PTR_T +#define FUNCTION_PTR_T +typedef void (*function_ptr_t)(mach_port_t, char *, mach_msg_type_number_t); +typedef struct { + char *name; + function_ptr_t function; +} function_table_entry; +typedef function_table_entry *function_table_t; +#endif /* FUNCTION_PTR_T */ +#endif /* AUTOTEST */ + +#ifndef mach_port_MSG_COUNT +#define mach_port_MSG_COUNT 31 +#endif /* mach_port_MSG_COUNT */ + +#include <mach/std_types.h> +#include <mach/mig.h> +#include <mach/mach_types.h> +#include <mach_debug/mach_debug_types.h> + +#ifdef __BeforeMigUserHeader +__BeforeMigUserHeader +#endif /* __BeforeMigUserHeader */ + +#include <sys/cdefs.h> +__BEGIN_DECLS + + +/* Routine mach_port_names */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_names +( + ipc_space_t task, + mach_port_name_array_t *names, + mach_msg_type_number_t *namesCnt, + mach_port_type_array_t *types, + mach_msg_type_number_t *typesCnt +); + +/* Routine mach_port_type */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_type +( + ipc_space_t task, + mach_port_name_t name, + mach_port_type_t *ptype +); + +/* Routine mach_port_rename */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_rename +( + ipc_space_t task, + mach_port_name_t old_name, + mach_port_name_t new_name +); + +/* Routine mach_port_allocate_name */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_allocate_name +( + ipc_space_t task, + mach_port_right_t right, + mach_port_name_t name +); + +/* Routine mach_port_allocate */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_allocate +( + ipc_space_t task, + mach_port_right_t right, + mach_port_name_t *name +); + +/* Routine mach_port_destroy */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_destroy +( + ipc_space_t task, + mach_port_name_t name +); + +/* Routine mach_port_deallocate */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_deallocate +( + ipc_space_t task, + mach_port_name_t name +); + +/* Routine mach_port_get_refs */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_get_refs +( + ipc_space_t task, + mach_port_name_t name, + mach_port_right_t right, + mach_port_urefs_t *refs +); + +/* Routine mach_port_mod_refs */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_mod_refs +( + ipc_space_t task, + mach_port_name_t name, + mach_port_right_t right, + mach_port_delta_t delta +); + +/* Routine mach_port_set_mscount */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_set_mscount +( + ipc_space_t task, + mach_port_name_t name, + mach_port_mscount_t mscount +); + +/* Routine mach_port_get_set_status */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_get_set_status +( + ipc_space_t task, + mach_port_name_t name, + mach_port_name_array_t *members, + mach_msg_type_number_t *membersCnt +); + +/* Routine mach_port_move_member */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_move_member +( + ipc_space_t task, + mach_port_name_t member, + mach_port_name_t after +); + +/* Routine mach_port_request_notification */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_request_notification +( + ipc_space_t task, + mach_port_name_t name, + mach_msg_id_t msgid, + mach_port_mscount_t sync, + mach_port_t notify, + mach_msg_type_name_t notifyPoly, + mach_port_t *previous +); + +/* Routine mach_port_insert_right */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_insert_right +( + ipc_space_t task, + mach_port_name_t name, + mach_port_t poly, + mach_msg_type_name_t polyPoly +); + +/* Routine mach_port_extract_right */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_extract_right +( + ipc_space_t task, + mach_port_name_t name, + mach_msg_type_name_t msgt_name, + mach_port_t *poly, + mach_msg_type_name_t *polyPoly +); + +/* Routine mach_port_set_seqno */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_set_seqno +( + ipc_space_t task, + mach_port_name_t name, + mach_port_seqno_t seqno +); + +/* Routine mach_port_get_attributes */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_get_attributes +( + ipc_space_t task, + mach_port_name_t name, + mach_port_flavor_t flavor, + mach_port_info_t port_info_out, + mach_msg_type_number_t *port_info_outCnt +); + +/* Routine mach_port_set_attributes */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_set_attributes +( + ipc_space_t task, + mach_port_name_t name, + mach_port_flavor_t flavor, + mach_port_info_t port_info, + mach_msg_type_number_t port_infoCnt +); + +/* Routine mach_port_allocate_qos */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_allocate_qos +( + ipc_space_t task, + mach_port_right_t right, + mach_port_qos_t *qos, + mach_port_name_t *name +); + +/* Routine mach_port_allocate_full */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_allocate_full +( + ipc_space_t task, + mach_port_right_t right, + mach_port_t proto, + mach_port_qos_t *qos, + mach_port_name_t *name +); + +/* Routine task_set_port_space */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_set_port_space +( + ipc_space_t task, + int table_entries +); + +/* Routine mach_port_get_srights */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_get_srights +( + ipc_space_t task, + mach_port_name_t name, + mach_port_rights_t *srights +); + +/* Routine mach_port_space_info */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_space_info +( + ipc_space_t task, + ipc_info_space_t *space_info, + ipc_info_name_array_t *table_info, + mach_msg_type_number_t *table_infoCnt, + ipc_info_tree_name_array_t *tree_info, + mach_msg_type_number_t *tree_infoCnt +); + +/* Routine mach_port_dnrequest_info */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_dnrequest_info +( + ipc_space_t task, + mach_port_name_t name, + unsigned *dnr_total, + unsigned *dnr_used +); + +/* Routine mach_port_kernel_object */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_kernel_object +( + ipc_space_t task, + mach_port_name_t name, + unsigned *object_type, + unsigned *object_addr +); + +/* Routine mach_port_insert_member */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_insert_member +( + ipc_space_t task, + mach_port_name_t name, + mach_port_name_t pset +); + +/* Routine mach_port_extract_member */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_extract_member +( + ipc_space_t task, + mach_port_name_t name, + mach_port_name_t pset +); + +/* Routine mach_port_get_context */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_get_context +( + ipc_space_t task, + mach_port_name_t name, + mach_vm_address_t *context +); + +/* Routine mach_port_set_context */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_set_context +( + ipc_space_t task, + mach_port_name_t name, + mach_vm_address_t context +); + +/* Routine mach_port_kobject */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_kobject +( + ipc_space_t task, + mach_port_name_t name, + natural_t *object_type, + mach_vm_address_t *object_addr +); + +__END_DECLS + +/********************** Caution **************************/ +/* The following data types should be used to calculate */ +/* maximum message sizes only. The actual message may be */ +/* smaller, and the position of the arguments within the */ +/* message layout may vary from what is presented here. */ +/* For example, if any of the arguments are variable- */ +/* sized, and less than the maximum is sent, the data */ +/* will be packed tight in the actual message to reduce */ +/* the presence of holes. */ +/********************** Caution **************************/ + +/* typedefs for all requests */ + +#ifndef __Request__mach_port_subsystem__defined +#define __Request__mach_port_subsystem__defined + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__mach_port_names_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_name_t name; + } __Request__mach_port_type_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_name_t old_name; + mach_port_name_t new_name; + } __Request__mach_port_rename_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_right_t right; + mach_port_name_t name; + } __Request__mach_port_allocate_name_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_right_t right; + } __Request__mach_port_allocate_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_name_t name; + } __Request__mach_port_destroy_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_name_t name; + } __Request__mach_port_deallocate_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_name_t name; + mach_port_right_t right; + } __Request__mach_port_get_refs_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_name_t name; + mach_port_right_t right; + mach_port_delta_t delta; + } __Request__mach_port_mod_refs_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_name_t name; + mach_port_mscount_t mscount; + } __Request__mach_port_set_mscount_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_name_t name; + } __Request__mach_port_get_set_status_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_name_t member; + mach_port_name_t after; + } __Request__mach_port_move_member_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t notify; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_port_name_t name; + mach_msg_id_t msgid; + mach_port_mscount_t sync; + } __Request__mach_port_request_notification_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t poly; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_port_name_t name; + } __Request__mach_port_insert_right_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_name_t name; + mach_msg_type_name_t msgt_name; + } __Request__mach_port_extract_right_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_name_t name; + mach_port_seqno_t seqno; + } __Request__mach_port_set_seqno_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_name_t name; + mach_port_flavor_t flavor; + mach_msg_type_number_t port_info_outCnt; + } __Request__mach_port_get_attributes_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_name_t name; + mach_port_flavor_t flavor; + mach_msg_type_number_t port_infoCnt; + integer_t port_info[10]; + } __Request__mach_port_set_attributes_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_right_t right; + mach_port_qos_t qos; + } __Request__mach_port_allocate_qos_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t proto; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_port_right_t right; + mach_port_qos_t qos; + mach_port_name_t name; + } __Request__mach_port_allocate_full_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + int table_entries; + } __Request__task_set_port_space_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_name_t name; + } __Request__mach_port_get_srights_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__mach_port_space_info_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_name_t name; + } __Request__mach_port_dnrequest_info_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_name_t name; + } __Request__mach_port_kernel_object_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_name_t name; + mach_port_name_t pset; + } __Request__mach_port_insert_member_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_name_t name; + mach_port_name_t pset; + } __Request__mach_port_extract_member_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_name_t name; + } __Request__mach_port_get_context_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_name_t name; + mach_vm_address_t context; + } __Request__mach_port_set_context_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_name_t name; + } __Request__mach_port_kobject_t; +#ifdef __MigPackStructs +#pragma pack() +#endif +#endif /* !__Request__mach_port_subsystem__defined */ + +/* union of all requests */ + +#ifndef __RequestUnion__mach_port_subsystem__defined +#define __RequestUnion__mach_port_subsystem__defined +union __RequestUnion__mach_port_subsystem { + __Request__mach_port_names_t Request_mach_port_names; + __Request__mach_port_type_t Request_mach_port_type; + __Request__mach_port_rename_t Request_mach_port_rename; + __Request__mach_port_allocate_name_t Request_mach_port_allocate_name; + __Request__mach_port_allocate_t Request_mach_port_allocate; + __Request__mach_port_destroy_t Request_mach_port_destroy; + __Request__mach_port_deallocate_t Request_mach_port_deallocate; + __Request__mach_port_get_refs_t Request_mach_port_get_refs; + __Request__mach_port_mod_refs_t Request_mach_port_mod_refs; + __Request__mach_port_set_mscount_t Request_mach_port_set_mscount; + __Request__mach_port_get_set_status_t Request_mach_port_get_set_status; + __Request__mach_port_move_member_t Request_mach_port_move_member; + __Request__mach_port_request_notification_t Request_mach_port_request_notification; + __Request__mach_port_insert_right_t Request_mach_port_insert_right; + __Request__mach_port_extract_right_t Request_mach_port_extract_right; + __Request__mach_port_set_seqno_t Request_mach_port_set_seqno; + __Request__mach_port_get_attributes_t Request_mach_port_get_attributes; + __Request__mach_port_set_attributes_t Request_mach_port_set_attributes; + __Request__mach_port_allocate_qos_t Request_mach_port_allocate_qos; + __Request__mach_port_allocate_full_t Request_mach_port_allocate_full; + __Request__task_set_port_space_t Request_task_set_port_space; + __Request__mach_port_get_srights_t Request_mach_port_get_srights; + __Request__mach_port_space_info_t Request_mach_port_space_info; + __Request__mach_port_dnrequest_info_t Request_mach_port_dnrequest_info; + __Request__mach_port_kernel_object_t Request_mach_port_kernel_object; + __Request__mach_port_insert_member_t Request_mach_port_insert_member; + __Request__mach_port_extract_member_t Request_mach_port_extract_member; + __Request__mach_port_get_context_t Request_mach_port_get_context; + __Request__mach_port_set_context_t Request_mach_port_set_context; + __Request__mach_port_kobject_t Request_mach_port_kobject; +}; +#endif /* !__RequestUnion__mach_port_subsystem__defined */ +/* typedefs for all replies */ + +#ifndef __Reply__mach_port_subsystem__defined +#define __Reply__mach_port_subsystem__defined + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_descriptor_t names; + mach_msg_ool_descriptor_t types; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t namesCnt; + mach_msg_type_number_t typesCnt; + } __Reply__mach_port_names_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_port_type_t ptype; + } __Reply__mach_port_type_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__mach_port_rename_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__mach_port_allocate_name_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_port_name_t name; + } __Reply__mach_port_allocate_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__mach_port_destroy_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__mach_port_deallocate_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_port_urefs_t refs; + } __Reply__mach_port_get_refs_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__mach_port_mod_refs_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__mach_port_set_mscount_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_descriptor_t members; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t membersCnt; + } __Reply__mach_port_get_set_status_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__mach_port_move_member_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t previous; + /* end of the kernel processed data */ + } __Reply__mach_port_request_notification_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__mach_port_insert_right_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t poly; + /* end of the kernel processed data */ + } __Reply__mach_port_extract_right_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__mach_port_set_seqno_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_msg_type_number_t port_info_outCnt; + integer_t port_info_out[10]; + } __Reply__mach_port_get_attributes_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__mach_port_set_attributes_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_port_qos_t qos; + mach_port_name_t name; + } __Reply__mach_port_allocate_qos_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_port_qos_t qos; + mach_port_name_t name; + } __Reply__mach_port_allocate_full_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_set_port_space_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_port_rights_t srights; + } __Reply__mach_port_get_srights_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_descriptor_t table_info; + mach_msg_ool_descriptor_t tree_info; + /* end of the kernel processed data */ + NDR_record_t NDR; + ipc_info_space_t space_info; + mach_msg_type_number_t table_infoCnt; + mach_msg_type_number_t tree_infoCnt; + } __Reply__mach_port_space_info_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + unsigned dnr_total; + unsigned dnr_used; + } __Reply__mach_port_dnrequest_info_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + unsigned object_type; + unsigned object_addr; + } __Reply__mach_port_kernel_object_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__mach_port_insert_member_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__mach_port_extract_member_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_vm_address_t context; + } __Reply__mach_port_get_context_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__mach_port_set_context_t; +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + natural_t object_type; + mach_vm_address_t object_addr; + } __Reply__mach_port_kobject_t; +#ifdef __MigPackStructs +#pragma pack() +#endif +#endif /* !__Reply__mach_port_subsystem__defined */ + +/* union of all replies */ + +#ifndef __ReplyUnion__mach_port_subsystem__defined +#define __ReplyUnion__mach_port_subsystem__defined +union __ReplyUnion__mach_port_subsystem { + __Reply__mach_port_names_t Reply_mach_port_names; + __Reply__mach_port_type_t Reply_mach_port_type; + __Reply__mach_port_rename_t Reply_mach_port_rename; + __Reply__mach_port_allocate_name_t Reply_mach_port_allocate_name; + __Reply__mach_port_allocate_t Reply_mach_port_allocate; + __Reply__mach_port_destroy_t Reply_mach_port_destroy; + __Reply__mach_port_deallocate_t Reply_mach_port_deallocate; + __Reply__mach_port_get_refs_t Reply_mach_port_get_refs; + __Reply__mach_port_mod_refs_t Reply_mach_port_mod_refs; + __Reply__mach_port_set_mscount_t Reply_mach_port_set_mscount; + __Reply__mach_port_get_set_status_t Reply_mach_port_get_set_status; + __Reply__mach_port_move_member_t Reply_mach_port_move_member; + __Reply__mach_port_request_notification_t Reply_mach_port_request_notification; + __Reply__mach_port_insert_right_t Reply_mach_port_insert_right; + __Reply__mach_port_extract_right_t Reply_mach_port_extract_right; + __Reply__mach_port_set_seqno_t Reply_mach_port_set_seqno; + __Reply__mach_port_get_attributes_t Reply_mach_port_get_attributes; + __Reply__mach_port_set_attributes_t Reply_mach_port_set_attributes; + __Reply__mach_port_allocate_qos_t Reply_mach_port_allocate_qos; + __Reply__mach_port_allocate_full_t Reply_mach_port_allocate_full; + __Reply__task_set_port_space_t Reply_task_set_port_space; + __Reply__mach_port_get_srights_t Reply_mach_port_get_srights; + __Reply__mach_port_space_info_t Reply_mach_port_space_info; + __Reply__mach_port_dnrequest_info_t Reply_mach_port_dnrequest_info; + __Reply__mach_port_kernel_object_t Reply_mach_port_kernel_object; + __Reply__mach_port_insert_member_t Reply_mach_port_insert_member; + __Reply__mach_port_extract_member_t Reply_mach_port_extract_member; + __Reply__mach_port_get_context_t Reply_mach_port_get_context; + __Reply__mach_port_set_context_t Reply_mach_port_set_context; + __Reply__mach_port_kobject_t Reply_mach_port_kobject; +}; +#endif /* !__RequestUnion__mach_port_subsystem__defined */ + +#ifndef subsystem_to_name_map_mach_port +#define subsystem_to_name_map_mach_port \ + { "mach_port_names", 3200 },\ + { "mach_port_type", 3201 },\ + { "mach_port_rename", 3202 },\ + { "mach_port_allocate_name", 3203 },\ + { "mach_port_allocate", 3204 },\ + { "mach_port_destroy", 3205 },\ + { "mach_port_deallocate", 3206 },\ + { "mach_port_get_refs", 3207 },\ + { "mach_port_mod_refs", 3208 },\ + { "mach_port_set_mscount", 3210 },\ + { "mach_port_get_set_status", 3211 },\ + { "mach_port_move_member", 3212 },\ + { "mach_port_request_notification", 3213 },\ + { "mach_port_insert_right", 3214 },\ + { "mach_port_extract_right", 3215 },\ + { "mach_port_set_seqno", 3216 },\ + { "mach_port_get_attributes", 3217 },\ + { "mach_port_set_attributes", 3218 },\ + { "mach_port_allocate_qos", 3219 },\ + { "mach_port_allocate_full", 3220 },\ + { "task_set_port_space", 3221 },\ + { "mach_port_get_srights", 3222 },\ + { "mach_port_space_info", 3223 },\ + { "mach_port_dnrequest_info", 3224 },\ + { "mach_port_kernel_object", 3225 },\ + { "mach_port_insert_member", 3226 },\ + { "mach_port_extract_member", 3227 },\ + { "mach_port_get_context", 3228 },\ + { "mach_port_set_context", 3229 },\ + { "mach_port_kobject", 3230 } +#endif + +#ifdef __AfterMigUserHeader +__AfterMigUserHeader +#endif /* __AfterMigUserHeader */ + +#endif /* _mach_port_user_ */ Index: branches/azimutz/Cleancut/i386/include/mach/sync.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/sync.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/sync.h (revision 885) @@ -0,0 +1,35 @@ +/* + * Copyright (c) 1999 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@ + */ +/* +** This file contains compatibilty wrapper header for things that used +** to be generated from mach/sync.defs. Now that code is split into two +** different interface generator files, so include the two resulting +** headers here. +*/ +#include <mach/semaphore.h> +#include <mach/lock_set.h> Index: branches/azimutz/Cleancut/i386/include/mach/clock_types.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/clock_types.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/clock_types.h (revision 885) @@ -0,0 +1,126 @@ +/* + * Copyright (c) 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@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * File: clock_types.h + * Purpose: Clock facility header definitions. These + * definitons are needed by both kernel and + * user-level software. + */ + +/* + * All interfaces defined here are obsolete. + */ + +#ifndef _MACH_CLOCK_TYPES_H_ +#define _MACH_CLOCK_TYPES_H_ + +#include <stdint.h> +#include <mach/time_value.h> + +/* + * Type definitions. + */ +typedef int alarm_type_t; /* alarm time type */ +typedef int sleep_type_t; /* sleep time type */ +typedef int clock_id_t; /* clock identification type */ +typedef int clock_flavor_t; /* clock flavor type */ +typedef int *clock_attr_t; /* clock attribute type */ +typedef int clock_res_t; /* clock resolution type */ + +/* + * Normal time specification used by the kernel clock facility. + */ +struct mach_timespec { + unsigned int tv_sec; /* seconds */ + clock_res_t tv_nsec; /* nanoseconds */ +}; +typedef struct mach_timespec mach_timespec_t; + +/* + * Reserved clock id values for default clocks. + */ +#define SYSTEM_CLOCK 0 +#define CALENDAR_CLOCK 1 + +#define REALTIME_CLOCK 0 + +/* + * Attribute names. + */ +#define CLOCK_GET_TIME_RES 1 /* get_time call resolution */ +/* 2 * was map_time call resolution */ +#define CLOCK_ALARM_CURRES 3 /* current alarm resolution */ +#define CLOCK_ALARM_MINRES 4 /* minimum alarm resolution */ +#define CLOCK_ALARM_MAXRES 5 /* maximum alarm resolution */ + +#define NSEC_PER_USEC 1000 /* nanoseconds per microsecond */ +#define USEC_PER_SEC 1000000 /* microseconds per second */ +#define NSEC_PER_SEC 1000000000 /* nanoseconds per second */ + +#define BAD_MACH_TIMESPEC(t) \ + ((t)->tv_nsec < 0 || (t)->tv_nsec >= NSEC_PER_SEC) + +/* t1 <=> t2, also (t1 - t2) in nsec with max of +- 1 sec */ +#define CMP_MACH_TIMESPEC(t1, t2) \ + ((t1)->tv_sec > (t2)->tv_sec ? +NSEC_PER_SEC : \ + ((t1)->tv_sec < (t2)->tv_sec ? -NSEC_PER_SEC : \ + (t1)->tv_nsec - (t2)->tv_nsec)) + +/* t1 += t2 */ +#define ADD_MACH_TIMESPEC(t1, t2) \ + do { \ + if (((t1)->tv_nsec += (t2)->tv_nsec) >= NSEC_PER_SEC) { \ + (t1)->tv_nsec -= NSEC_PER_SEC; \ + (t1)->tv_sec += 1; \ + } \ + (t1)->tv_sec += (t2)->tv_sec; \ + } while (0) + +/* t1 -= t2 */ +#define SUB_MACH_TIMESPEC(t1, t2) \ + do { \ + if (((t1)->tv_nsec -= (t2)->tv_nsec) < 0) { \ + (t1)->tv_nsec += NSEC_PER_SEC; \ + (t1)->tv_sec -= 1; \ + } \ + (t1)->tv_sec -= (t2)->tv_sec; \ + } while (0) + +/* + * Alarm parameter defines. + */ +#define ALRMTYPE 0xff /* type (8-bit field) */ +#define TIME_ABSOLUTE 0x00 /* absolute time */ +#define TIME_RELATIVE 0x01 /* relative time */ + +#define BAD_ALRMTYPE(t) (((t) &~ TIME_RELATIVE) != 0) + +#endif /* _MACH_CLOCK_TYPES_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/boolean.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/boolean.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/boolean.h (revision 885) @@ -0,0 +1,88 @@ +/* + * Copyright (c) 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@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989,1988,1987 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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + */ +/* + * File: mach/boolean.h + * + * Boolean data type. + * + */ + +#ifndef _MACH_BOOLEAN_H_ +#define _MACH_BOOLEAN_H_ + +/* + * Pick up "boolean_t" type definition + */ + +#ifndef ASSEMBLER +#include <mach/machine/boolean.h> +#endif /* ASSEMBLER */ + +/* + * Define TRUE and FALSE if not defined. + */ + +#ifndef TRUE +#define TRUE 1 +#endif /* TRUE */ + +#ifndef FALSE +#define FALSE 0 +#endif /* FALSE */ + +#endif /* _MACH_BOOLEAN_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/task_ledger.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/task_ledger.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/task_ledger.h (revision 885) @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2000-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@ + */ +/* + * @OSF_COPYRIGHT@ + */ + +#ifndef _MACH_TASK_LEDGER_H_ +#define _MACH_TASK_LEDGER_H_ + +/* + * Evolving and likely to change. + */ + +/* + * Definitions for task ledger line items + */ +#define ITEM_THREADS 0 /* number of threads */ +#define ITEM_TASKS 1 /* number of tasks */ + +#define ITEM_VM 2 /* virtual space (bytes)*/ + +#define LEDGER_N_ITEMS 3 /* Total line items */ + +#define LEDGER_UNLIMITED 0 /* ignored item.maximum */ + +#endif /* _MACH_TASK_LEDGER_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/mach_syscalls.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/mach_syscalls.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/mach_syscalls.h (revision 885) @@ -0,0 +1,37 @@ +/* + * 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@ + */ + +#ifndef _MACH_MACH_SYSCALLS_H_ +#define _MACH_MACH_SYSCALLS_H_ + +#include <mach/mach_traps.h> + +#endif /* _MACH_MACH_SYSCALLS_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/clock.defs =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/clock.defs (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/clock.defs (revision 885) @@ -0,0 +1,81 @@ +/* + * Copyright (c) 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@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * File: mach/clock.defs + * Purpose: Kernel clock subsystem definitions. This + * file defines the clock request interface. + */ + +subsystem +#if KERNEL_SERVER + KernelServer +#endif /* KERNEL_SERVER */ + clock 1000; + +#include <mach/std_types.defs> +#include <mach/mach_types.defs> +#include <mach/clock_types.defs> + +/* + * References to clock objects are returned by: + * host_get_clock_service(host_t,...) + * host_get_clock_control(host_priv_t,...) - Priviledged subclass + */ + +/* + * Get the clock time. + * Available to all. + */ +routine clock_get_time( + clock_serv : clock_serv_t; + out cur_time : mach_timespec_t); + +/* + * Get clock attributes. + * Available to all. + */ +routine clock_get_attributes( + clock_serv : clock_serv_t; + in flavor : clock_flavor_t; + out clock_attr : clock_attr_t, CountInOut); + +/* + * Setup a clock alarm. + * Available to all. + */ +routine clock_alarm( + clock_serv : clock_serv_t; + alarm_type : alarm_type_t; + alarm_time : mach_timespec_t; + alarm_port : clock_reply_t = + MACH_MSG_TYPE_MAKE_SEND_ONCE|polymorphic); + +/* vim: set ft=c : */ Index: branches/azimutz/Cleancut/i386/include/mach/thread_policy.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/thread_policy.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/thread_policy.h (revision 885) @@ -0,0 +1,218 @@ +/* + * Copyright (c) 2000-2007 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 _MACH_THREAD_POLICY_H_ +#define _MACH_THREAD_POLICY_H_ + +#include <mach/mach_types.h> + +/* + * These are the calls for accessing the policy parameters + * of a particular thread. + * + * The extra 'get_default' parameter to the second call is + * IN/OUT as follows: + * 1) if asserted on the way in it indicates that the default + * values should be returned, not the ones currently set, in + * this case 'get_default' will always be asserted on return; + * 2) if unasserted on the way in, the current settings are + * desired and if still unasserted on return, then the info + * returned reflects the current settings, otherwise if + * 'get_default' returns asserted, it means that there are no + * current settings due to other parameters taking precedence, + * and the default ones are being returned instead. + */ + +typedef natural_t thread_policy_flavor_t; +typedef integer_t *thread_policy_t; + +/* +kern_return_t thread_policy_set( + thread_t thread, + thread_policy_flavor_t flavor, + thread_policy_t policy_info, + mach_msg_type_number_t count); + +kern_return_t thread_policy_get( + thread_t thread, + thread_policy_flavor_t flavor, + thread_policy_t policy_info, + mach_msg_type_number_t *count, + boolean_t *get_default); +*/ + +/* + * Defined flavors. + */ +/* + * THREAD_STANDARD_POLICY: + * + * This is the standard (fair) scheduling mode, assigned to new + * threads. The thread will be given processor time in a manner + * which apportions approximately equal share to long running + * computations. + * + * Parameters: + * [none] + */ + +#define THREAD_STANDARD_POLICY 1 + +struct thread_standard_policy { + natural_t no_data; +}; + +typedef struct thread_standard_policy thread_standard_policy_data_t; +typedef struct thread_standard_policy *thread_standard_policy_t; + +#define THREAD_STANDARD_POLICY_COUNT 0 + +/* + * THREAD_EXTENDED_POLICY: + * + * Extended form of THREAD_STANDARD_POLICY, which supplies a + * hint indicating whether this is a long running computation. + * + * Parameters: + * + * timeshare: TRUE (the default) results in identical scheduling + * behavior as THREAD_STANDARD_POLICY. + */ + +#define THREAD_EXTENDED_POLICY 1 + +struct thread_extended_policy { + boolean_t timeshare; +}; + +typedef struct thread_extended_policy thread_extended_policy_data_t; +typedef struct thread_extended_policy *thread_extended_policy_t; + +#define THREAD_EXTENDED_POLICY_COUNT ((mach_msg_type_number_t) \ + (sizeof (thread_extended_policy_data_t) / sizeof (integer_t))) + +/* + * THREAD_TIME_CONSTRAINT_POLICY: + * + * This scheduling mode is for threads which have real time + * constraints on their execution. + * + * Parameters: + * + * period: This is the nominal amount of time between separate + * processing arrivals, specified in absolute time units. A + * value of 0 indicates that there is no inherent periodicity in + * the computation. + * + * computation: This is the nominal amount of computation + * time needed during a separate processing arrival, specified + * in absolute time units. + * + * constraint: This is the maximum amount of real time that + * may elapse from the start of a separate processing arrival + * to the end of computation for logically correct functioning, + * specified in absolute time units. Must be (>= computation). + * Note that latency = (constraint - computation). + * + * preemptible: This indicates that the computation may be + * interrupted, subject to the constraint specified above. + */ + +#define THREAD_TIME_CONSTRAINT_POLICY 2 + +struct thread_time_constraint_policy { + uint32_t period; + uint32_t computation; + uint32_t constraint; + boolean_t preemptible; +}; + +typedef struct thread_time_constraint_policy \ + thread_time_constraint_policy_data_t; +typedef struct thread_time_constraint_policy \ + *thread_time_constraint_policy_t; + +#define THREAD_TIME_CONSTRAINT_POLICY_COUNT ((mach_msg_type_number_t) \ + (sizeof (thread_time_constraint_policy_data_t) / sizeof (integer_t))) + +/* + * THREAD_PRECEDENCE_POLICY: + * + * This may be used to indicate the relative value of the + * computation compared to the other threads in the task. + * + * Parameters: + * + * importance: The importance is specified as a signed value. + */ + +#define THREAD_PRECEDENCE_POLICY 3 + +struct thread_precedence_policy { + integer_t importance; +}; + +typedef struct thread_precedence_policy thread_precedence_policy_data_t; +typedef struct thread_precedence_policy *thread_precedence_policy_t; + +#define THREAD_PRECEDENCE_POLICY_COUNT ((mach_msg_type_number_t) \ + (sizeof (thread_precedence_policy_data_t) / sizeof (integer_t))) + +/* + * THREAD_AFFINITY_POLICY: + * + * This policy is experimental. + * This may be used to express affinity relationships + * between threads in the task. Threads with the same affinity tag will + * be scheduled to share an L2 cache if possible. That is, affinity tags + * are a hint to the scheduler for thread placement. + * + * The namespace of affinity tags is generally local to one task. However, + * a child task created after the assignment of affinity tags by its parent + * will share that namespace. In particular, a family of forked processes + * may be created with a shared affinity namespace. + * + * Parameters: + * tag: The affinity set identifier. + */ + +#define THREAD_AFFINITY_POLICY 4 + +struct thread_affinity_policy { + integer_t affinity_tag; +}; + +#define THREAD_AFFINITY_TAG_NULL 0 + +typedef struct thread_affinity_policy thread_affinity_policy_data_t; +typedef struct thread_affinity_policy *thread_affinity_policy_t; + +#define THREAD_AFFINITY_POLICY_COUNT ((mach_msg_type_number_t) \ + (sizeof (thread_affinity_policy_data_t) / sizeof (integer_t))) + +#endif /* _MACH_THREAD_POLICY_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/thread_switch.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/thread_switch.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/thread_switch.h (revision 885) @@ -0,0 +1,77 @@ +/* + * 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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + */ + +#ifndef _MACH_THREAD_SWITCH_H_ +#define _MACH_THREAD_SWITCH_H_ + +#include <mach/mach_types.h> +#include <mach/kern_return.h> +#include <mach/message.h> +#include <mach/mach_traps.h> + +/* + * Constant definitions for thread_switch trap. + */ + +#define SWITCH_OPTION_NONE 0 +#define SWITCH_OPTION_DEPRESS 1 +#define SWITCH_OPTION_WAIT 2 + +#define valid_switch_option(opt) (0 <= (opt) && (opt) <= 2) + +#endif /* _MACH_THREAD_SWITCH_H_ */ Index: branches/azimutz/Cleancut/i386/include/mach/vm_attributes.h =================================================================== --- branches/azimutz/Cleancut/i386/include/mach/vm_attributes.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/mach/vm_attributes.h (revision 885) @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2000-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@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989,1988,1987 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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + */ +/* + * File: mach/vm_attributes.h + * Author: Alessandro Forin + * + * Virtual memory attributes definitions. + * + * These definitions are in addition to the machine-independent + * ones (e.g. protection), and are only selectively supported + * on specific machine architectures. + * + */ + +#ifndef _MACH_VM_ATTRIBUTES_H_ +#define _MACH_VM_ATTRIBUTES_H_ + +/* + * Types of machine-dependent attributes + */ +typedef unsigned int vm_machine_attribute_t; + +#define MATTR_CACHE 1 /* cachability */ +#define MATTR_MIGRATE 2 /* migrability */ +#define MATTR_REPLICATE 4 /* replicability */ + +/* + * Values for the above, e.g. operations on attribute + */ +typedef int vm_machine_attribute_val_t; + +#define MATTR_VAL_OFF 0 /* (generic) turn attribute off */ +#define MATTR_VAL_ON 1 /* (generic) turn attribute on */ +#define MATTR_VAL_GET 2 /* (generic) return current value */ + +#define MATTR_VAL_CACHE_FLUSH 6 /* flush from all caches */ +#define MATTR_VAL_DCACHE_FLUSH 7 /* flush from data caches */ +#define MATTR_VAL_ICACHE_FLUSH 8 /* flush from instruction caches */ +#define MATTR_VAL_CACHE_SYNC 9 /* sync I+D caches */ +#define MATTR_VAL_CACHE_SYNC 9 /* sync I+D caches */ + +#define MATTR_VAL_GET_INFO 10 /* get page info (stats) */ + +#endif /* _MACH_VM_ATTRIBUTES_H_ */ Index: branches/azimutz/Cleancut/i386/include/stdio.h =================================================================== --- branches/azimutz/Cleancut/i386/include/stdio.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/stdio.h (revision 885) @@ -0,0 +1,503 @@ +/* + * Copyright (c) 2000, 2005, 2007, 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@ + */ +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)stdio.h 8.5 (Berkeley) 4/29/95 + */ + +#ifndef _STDIO_H_ +#define _STDIO_H_ + +#include <_types.h> + +#ifndef _VA_LIST +#define _VA_LIST +/* DO NOT REMOVE THIS COMMENT: fixincludes needs to see: + * __gnuc_va_list and include <stdarg.h> */ +typedef __darwin_va_list va_list; +#endif + +#ifndef _OFF_T +#define _OFF_T +typedef __darwin_off_t off_t; +#endif + +#ifndef _SIZE_T +#define _SIZE_T +typedef __darwin_size_t size_t; +#endif + +#ifndef NULL +#define NULL __DARWIN_NULL +#endif /* ! NULL */ + +typedef __darwin_off_t fpos_t; + +#define _FSTDIO /* Define for new stdio with functions. */ + +/* + * NB: to fit things in six character monocase externals, the stdio + * code uses the prefix `__s' for stdio objects, typically followed + * by a three-character attempt at a mnemonic. + */ + +/* stdio buffers */ +struct __sbuf { + unsigned char *_base; + int _size; +}; + +/* hold a buncha junk that would grow the ABI */ +struct __sFILEX; + +/* + * stdio state variables. + * + * The following always hold: + * + * if (_flags&(__SLBF|__SWR)) == (__SLBF|__SWR), + * _lbfsize is -_bf._size, else _lbfsize is 0 + * if _flags&__SRD, _w is 0 + * if _flags&__SWR, _r is 0 + * + * This ensures that the getc and putc macros (or inline functions) never + * try to write or read from a file that is in `read' or `write' mode. + * (Moreover, they can, and do, automatically switch from read mode to + * write mode, and back, on "r+" and "w+" files.) + * + * _lbfsize is used only to make the inline line-buffered output stream + * code as compact as possible. + * + * _ub, _up, and _ur are used when ungetc() pushes back more characters + * than fit in the current _bf, or when ungetc() pushes back a character + * that does not match the previous one in _bf. When this happens, + * _ub._base becomes non-nil (i.e., a stream has ungetc() data iff + * _ub._base!=NULL) and _up and _ur save the current values of _p and _r. + * + * NB: see WARNING above before changing the layout of this structure! + */ +typedef struct __sFILE { + unsigned char *_p; /* current position in (some) buffer */ + int _r; /* read space left for getc() */ + int _w; /* write space left for putc() */ + short _flags; /* flags, below; this FILE is free if 0 */ + short _file; /* fileno, if Unix descriptor, else -1 */ + struct __sbuf _bf; /* the buffer (at least 1 byte, if !NULL) */ + int _lbfsize; /* 0 or -_bf._size, for inline putc */ + + /* operations */ + void *_cookie; /* cookie passed to io functions */ + int (*_close)(void *); + int (*_read) (void *, char *, int); + fpos_t (*_seek) (void *, fpos_t, int); + int (*_write)(void *, const char *, int); + + /* separate buffer for long sequences of ungetc() */ + struct __sbuf _ub; /* ungetc buffer */ + struct __sFILEX *_extra; /* additions to FILE to not break ABI */ + int _ur; /* saved _r when _r is counting ungetc data */ + + /* tricks to meet minimum requirements even when malloc() fails */ + unsigned char _ubuf[3]; /* guarantee an ungetc() buffer */ + unsigned char _nbuf[1]; /* guarantee a getc() buffer */ + + /* separate buffer for fgetln() when line crosses buffer boundary */ + struct __sbuf _lb; /* buffer for fgetln() */ + + /* Unix stdio files get aligned to block boundaries on fseek() */ + int _blksize; /* stat.st_blksize (may be != _bf._size) */ + fpos_t _offset; /* current lseek offset (see WARNING) */ +} FILE; + +__BEGIN_DECLS +#if __DARWIN_UNIX03 +extern FILE *__stdinp; +extern FILE *__stdoutp; +extern FILE *__stderrp; +#else /* !__DARWIN_UNIX03 */ +extern FILE __sF[]; +#endif /* __DARWIN_UNIX03 */ +__END_DECLS + +#define __SLBF 0x0001 /* line buffered */ +#define __SNBF 0x0002 /* unbuffered */ +#define __SRD 0x0004 /* OK to read */ +#define __SWR 0x0008 /* OK to write */ + /* RD and WR are never simultaneously asserted */ +#define __SRW 0x0010 /* open for reading & writing */ +#define __SEOF 0x0020 /* found EOF */ +#define __SERR 0x0040 /* found error */ +#define __SMBF 0x0080 /* _buf is from malloc */ +#define __SAPP 0x0100 /* fdopen()ed in append mode */ +#define __SSTR 0x0200 /* this is an sprintf/snprintf string */ +#define __SOPT 0x0400 /* do fseek() optimisation */ +#define __SNPT 0x0800 /* do not do fseek() optimisation */ +#define __SOFF 0x1000 /* set iff _offset is in fact correct */ +#define __SMOD 0x2000 /* true => fgetln modified _p text */ +#define __SALC 0x4000 /* allocate string space dynamically */ +#define __SIGN 0x8000 /* ignore this file in _fwalk */ + +/* + * The following three definitions are for ANSI C, which took them + * from System V, which brilliantly took internal interface macros and + * made them official arguments to setvbuf(), without renaming them. + * Hence, these ugly _IOxxx names are *supposed* to appear in user code. + * + * Although numbered as their counterparts above, the implementation + * does not rely on this. + */ +#define _IOFBF 0 /* setvbuf should set fully buffered */ +#define _IOLBF 1 /* setvbuf should set line buffered */ +#define _IONBF 2 /* setvbuf should set unbuffered */ + +#define BUFSIZ 1024 /* size of buffer used by setbuf */ +#define EOF (-1) + +/* + * FOPEN_MAX is a minimum maximum, and is the number of streams that + * stdio can provide without attempting to allocate further resources + * (which could fail). Do not use this for anything. + */ + /* must be == _POSIX_STREAM_MAX <limits.h> */ +#define FOPEN_MAX 20 /* must be <= OPEN_MAX <sys/syslimits.h> */ +#define FILENAME_MAX 1024 /* must be <= PATH_MAX <sys/syslimits.h> */ + +/* System V/ANSI C; this is the wrong way to do this, do *not* use these. */ +#ifndef _ANSI_SOURCE +#define P_tmpdir "/var/tmp/" +#endif +#define L_tmpnam 1024 /* XXX must be == PATH_MAX */ +#define TMP_MAX 308915776 + +#ifndef SEEK_SET +#define SEEK_SET 0 /* set file offset to offset */ +#endif +#ifndef SEEK_CUR +#define SEEK_CUR 1 /* set file offset to current plus offset */ +#endif +#ifndef SEEK_END +#define SEEK_END 2 /* set file offset to EOF plus offset */ +#endif + +#if __DARWIN_UNIX03 +#define stdin __stdinp +#define stdout __stdoutp +#define stderr __stderrp +#else /* !__DARWIN_UNIX03 */ +#define stdin (&__sF[0]) +#define stdout (&__sF[1]) +#define stderr (&__sF[2]) +#endif /* __DARWIN_UNIX03 */ + +/* + * Functions defined in ANSI C standard. + */ +__BEGIN_DECLS +void clearerr(FILE *); +int fclose(FILE *); +int feof(FILE *); +int ferror(FILE *); +int fflush(FILE *); +int fgetc(FILE *); +int fgetpos(FILE * __restrict, fpos_t *); +char *fgets(char * __restrict, int, FILE *); +#if defined(__DARWIN_10_6_AND_LATER) && (defined(_DARWIN_UNLIMITED_STREAMS) || defined(_DARWIN_C_SOURCE)) +FILE *fopen(const char * __restrict, const char * __restrict) __DARWIN_EXTSN(fopen); +#else /* < 10.6 || !_DARWIN_UNLIMITED_STREAMS && !_DARWIN_C_SOURCE */ +//Begin-Libc +#ifndef LIBC_ALIAS_FOPEN +//End-Libc +FILE *fopen(const char * __restrict, const char * __restrict) __DARWIN_10_6_AND_LATER_ALIAS(__DARWIN_ALIAS(fopen)); +//Begin-Libc +#else /* LIBC_ALIAS_FOPEN */ +FILE *fopen(const char * __restrict, const char * __restrict) LIBC_ALIAS(fopen); +#endif /* !LIBC_ALIAS_FOPEN */ +//End-Libc +#endif /* >= 10.6 &&_(DARWIN_UNLIMITED_STREAMS || _DARWIN_C_SOURCE) */ +int fprintf(FILE * __restrict, const char * __restrict, ...) __DARWIN_LDBL_COMPAT(fprintf); +int fputc(int, FILE *); +//Begin-Libc +#ifndef LIBC_ALIAS_FPUTS +//End-Libc +int fputs(const char * __restrict, FILE * __restrict) __DARWIN_ALIAS(fputs); +//Begin-Libc +#else /* LIBC_ALIAS_FPUTS */ +int fputs(const char * __restrict, FILE * __restrict) LIBC_ALIAS(fputs); +#endif /* !LIBC_ALIAS_FPUTS */ +//End-Libc +size_t fread(void * __restrict, size_t, size_t, FILE * __restrict); +//Begin-Libc +#ifndef LIBC_ALIAS_FREOPEN +//End-Libc +FILE *freopen(const char * __restrict, const char * __restrict, + FILE * __restrict) __DARWIN_ALIAS(freopen); +//Begin-Libc +#else /* LIBC_ALIAS_FREOPEN */ +FILE *freopen(const char * __restrict, const char * __restrict, + FILE * __restrict) LIBC_ALIAS(freopen); +#endif /* !LIBC_ALIAS_FREOPEN */ +//End-Libc +int fscanf(FILE * __restrict, const char * __restrict, ...) __DARWIN_LDBL_COMPAT(fscanf); +int fseek(FILE *, long, int); +int fsetpos(FILE *, const fpos_t *); +long ftell(FILE *); +//Begin-Libc +#ifndef LIBC_ALIAS_FWRITE +//End-Libc +size_t fwrite(const void * __restrict, size_t, size_t, FILE * __restrict) __DARWIN_ALIAS(fwrite); +//Begin-Libc +#else /* LIBC_ALIAS_FWRITE */ +size_t fwrite(const void * __restrict, size_t, size_t, FILE * __restrict) LIBC_ALIAS(fwrite); +#endif /* !LIBC_ALIAS_FWRITE */ +//End-Libc +int getc(FILE *); +int getchar(void); +char *gets(char *); +#if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) +extern __const int sys_nerr; /* perror(3) external variables */ +extern __const char *__const sys_errlist[]; +#endif +void perror(const char *); +int printf(const char * __restrict, ...) __DARWIN_LDBL_COMPAT(printf); +int putc(int, FILE *); +int putchar(int); +int puts(const char *); +int remove(const char *); +int rename (const char *, const char *); +void rewind(FILE *); +int scanf(const char * __restrict, ...) __DARWIN_LDBL_COMPAT(scanf); +void setbuf(FILE * __restrict, char * __restrict); +int setvbuf(FILE * __restrict, char * __restrict, int, size_t); +int sprintf(char * __restrict, const char * __restrict, ...) __DARWIN_LDBL_COMPAT(sprintf); +int sscanf(const char * __restrict, const char * __restrict, ...) __DARWIN_LDBL_COMPAT(sscanf); +FILE *tmpfile(void); +char *tmpnam(char *); +int ungetc(int, FILE *); +int vfprintf(FILE * __restrict, const char * __restrict, va_list) __DARWIN_LDBL_COMPAT(vfprintf); +int vprintf(const char * __restrict, va_list) __DARWIN_LDBL_COMPAT(vprintf); +int vsprintf(char * __restrict, const char * __restrict, va_list) __DARWIN_LDBL_COMPAT(vsprintf); +#if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) +int asprintf(char **, const char *, ...) __DARWIN_LDBL_COMPAT(asprintf); +int vasprintf(char **, const char *, va_list) __DARWIN_LDBL_COMPAT(vasprintf); +#endif +__END_DECLS + +/* + * Functions defined in POSIX 1003.1. + */ +#ifndef _ANSI_SOURCE +#define L_ctermid 1024 /* size for ctermid(); PATH_MAX */ + +__BEGIN_DECLS +char *ctermid(char *); +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +char *ctermid_r(char *); +#endif /* not POSIX */ +#if defined(__DARWIN_10_6_AND_LATER) && (defined(_DARWIN_UNLIMITED_STREAMS) || defined(_DARWIN_C_SOURCE)) +FILE *fdopen(int, const char *) __DARWIN_EXTSN(fdopen); +#else /* < 10.6 || !_DARWIN_UNLIMITED_STREAMS && !_DARWIN_C_SOURCE */ +//Begin-Libc +#ifndef LIBC_ALIAS_FDOPEN +//End-Libc +FILE *fdopen(int, const char *) __DARWIN_10_6_AND_LATER_ALIAS(__DARWIN_ALIAS(fdopen)); +//Begin-Libc +#else /* LIBC_ALIAS_FDOPEN */ +FILE *fdopen(int, const char *) LIBC_ALIAS(fdopen); +#endif /* !LIBC_ALIAS_FDOPEN */ +//End-Libc +#endif /* >= 10.6 &&_(DARWIN_UNLIMITED_STREAMS || _DARWIN_C_SOURCE) */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +char *fgetln(FILE *, size_t *); +#endif /* not POSIX */ +int fileno(FILE *); +void flockfile(FILE *); +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +__const char + *fmtcheck(const char *, const char *); +int fpurge(FILE *); +#endif /* not POSIX */ +int fseeko(FILE *, off_t, int); +off_t ftello(FILE *); +int ftrylockfile(FILE *); +void funlockfile(FILE *); +int getc_unlocked(FILE *); +int getchar_unlocked(void); +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +int getw(FILE *); +#endif /* not POSIX */ +int pclose(FILE *); +#if defined(__DARWIN_10_6_AND_LATER) && (defined(_DARWIN_UNLIMITED_STREAMS) || defined(_DARWIN_C_SOURCE)) +FILE *popen(const char *, const char *) __DARWIN_EXTSN(popen); +#else /* < 10.6 || !_DARWIN_UNLIMITED_STREAMS && !_DARWIN_C_SOURCE */ +//Begin-Libc +#ifndef LIBC_ALIAS_POPEN +//End-Libc +FILE *popen(const char *, const char *) __DARWIN_10_6_AND_LATER_ALIAS(__DARWIN_ALIAS(popen)); +//Begin-Libc +#else /* LIBC_ALIAS_POPEN */ +FILE *popen(const char *, const char *) LIBC_ALIAS(popen); +#endif /* !LIBC_ALIAS_POPEN */ +//End-Libc +#endif /* >= 10.6 &&_(DARWIN_UNLIMITED_STREAMS || _DARWIN_C_SOURCE) */ +int putc_unlocked(int, FILE *); +int putchar_unlocked(int); +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +int putw(int, FILE *); +void setbuffer(FILE *, char *, int); +int setlinebuf(FILE *); +#endif /* not POSIX */ +int snprintf(char * __restrict, size_t, const char * __restrict, ...) __DARWIN_LDBL_COMPAT(snprintf); +//Begin-Libc +#ifndef LIBC_ALIAS_TEMPNAM +//End-Libc +char *tempnam(const char *, const char *) __DARWIN_ALIAS(tempnam); +//Begin-Libc +#else /* LIBC_ALIAS_TEMPNAM */ +char *tempnam(const char *, const char *) LIBC_ALIAS(tempnam); +#endif /* !LIBC_ALIAS_TEMPNAM */ +//End-Libc +int vfscanf(FILE * __restrict, const char * __restrict, va_list) __DARWIN_LDBL_COMPAT(vfscanf); +int vscanf(const char * __restrict, va_list) __DARWIN_LDBL_COMPAT(vscanf); +int vsnprintf(char * __restrict, size_t, const char * __restrict, va_list) __DARWIN_LDBL_COMPAT(vsnprintf); +int vsscanf(const char * __restrict, const char * __restrict, va_list) __DARWIN_LDBL_COMPAT(vsscanf); +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +FILE *zopen(const char *, const char *, int); +#endif /* not POSIX */ +__END_DECLS + +/* + * Stdio function-access interface. + */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +__BEGIN_DECLS +FILE *funopen(const void *, + int (*)(void *, char *, int), + int (*)(void *, const char *, int), + fpos_t (*)(void *, fpos_t, int), + int (*)(void *)); +__END_DECLS +#define fropen(cookie, fn) funopen(cookie, fn, 0, 0, 0) +#define fwopen(cookie, fn) funopen(cookie, 0, fn, 0, 0) +#endif /* not POSIX */ +#endif /* not ANSI */ + +/* + * Functions internal to the implementation. + */ +__BEGIN_DECLS +int __srget(FILE *); +int __svfscanf(FILE *, const char *, va_list) __DARWIN_LDBL_COMPAT(__svfscanf); +int __swbuf(int, FILE *); +__END_DECLS + +/* + * The __sfoo macros are here so that we can + * define function versions in the C library. + */ +#define __sgetc(p) (--(p)->_r < 0 ? __srget(p) : (int)(*(p)->_p++)) +#if defined(__GNUC__) && defined(__STDC__) +static __inline int __sputc(int _c, FILE *_p) { + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf(_c, _p)); +} +#else +/* + * This has been tuned to generate reasonable code on the vax using pcc. + */ +#define __sputc(c, p) \ + (--(p)->_w < 0 ? \ + (p)->_w >= (p)->_lbfsize ? \ + (*(p)->_p = (c)), *(p)->_p != '\n' ? \ + (int)*(p)->_p++ : \ + __swbuf('\n', p) : \ + __swbuf((int)(c), p) : \ + (*(p)->_p = (c), (int)*(p)->_p++)) +#endif + +#define __sfeof(p) (((p)->_flags & __SEOF) != 0) +#define __sferror(p) (((p)->_flags & __SERR) != 0) +#define __sclearerr(p) ((void)((p)->_flags &= ~(__SERR|__SEOF))) +#define __sfileno(p) ((p)->_file) + +#ifndef _ANSI_SOURCE +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define feof_unlocked(p) __sfeof(p) +#define ferror_unlocked(p) __sferror(p) +#define clearerr_unlocked(p) __sclearerr(p) +#define fileno_unlocked(p) __sfileno(p) +#endif /* not POSIX */ + +#ifndef lint +#define getc_unlocked(fp) __sgetc(fp) +#define putc_unlocked(x, fp) __sputc(x, fp) +#endif /* lint */ + +#define getchar_unlocked() getc_unlocked(stdin) +#define putchar_unlocked(x) putc_unlocked(x, stdout) +#endif /* not ANSI */ + +#ifdef _USE_EXTENDED_LOCALES_ +#include <xlocale/_stdio.h> +#endif /* _USE_EXTENDED_LOCALES_ */ + +#if defined (__GNUC__) && _FORTIFY_SOURCE > 0 && !defined (__cplusplus) +/* Security checking functions. */ +#include <secure/_stdio.h> +#endif + +#endif /* _STDIO_H_ */ Index: branches/azimutz/Cleancut/i386/include/math.h =================================================================== --- branches/azimutz/Cleancut/i386/include/math.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/math.h (revision 885) @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2002 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 __MATH_H__ +#define __MATH_H__ + +#if (defined(__ppc__) || defined(__ppc64__)) +#include "architecture/ppc/math.h" +#elif (defined (__i386__) || defined( __x86_64__ )) +#include "architecture/i386/math.h" +#elif defined(__arm__) +#include "architecture/arm/math.h" +#else +#error Unknown architecture +#endif + +#endif /* __MATH_H__ */ Index: branches/azimutz/Cleancut/i386/include/time.h =================================================================== --- branches/azimutz/Cleancut/i386/include/time.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/time.h (revision 885) @@ -0,0 +1,213 @@ +/* + * Copyright (c) 2000 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@ + */ +/* + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)time.h 8.3 (Berkeley) 1/21/94 + */ + +#ifndef _TIME_H_ +#define _TIME_H_ + +#include <_types.h> + +#define __need_struct_timespec +#include <_structs.h> + +#ifndef NULL +#define NULL __DARWIN_NULL +#endif /* ! NULL */ + +#ifndef _CLOCK_T +#define _CLOCK_T +typedef __darwin_clock_t clock_t; +#endif + +#ifndef _SIZE_T +#define _SIZE_T +typedef __darwin_size_t size_t; +#endif + +#ifndef _TIME_T +#define _TIME_T +typedef __darwin_time_t time_t; +#endif + +struct tm { + int tm_sec; /* seconds after the minute [0-60] */ + int tm_min; /* minutes after the hour [0-59] */ + int tm_hour; /* hours since midnight [0-23] */ + int tm_mday; /* day of the month [1-31] */ + int tm_mon; /* months since January [0-11] */ + int tm_year; /* years since 1900 */ + int tm_wday; /* days since Sunday [0-6] */ + int tm_yday; /* days since January 1 [0-365] */ + int tm_isdst; /* Daylight Savings Time flag */ + long tm_gmtoff; /* offset from CUT in seconds */ + char *tm_zone; /* timezone abbreviation */ +}; + +#if __DARWIN_UNIX03 +#define CLOCKS_PER_SEC 1000000 /* [XSI] */ +#else /* !__DARWIN_UNIX03 */ +#include <machine/_limits.h> /* Include file containing CLK_TCK. */ + +#define CLOCKS_PER_SEC (__DARWIN_CLK_TCK) +#endif /* __DARWIN_UNIX03 */ + +#ifndef _ANSI_SOURCE +extern char *tzname[]; +#endif + +extern int getdate_err; +#if __DARWIN_UNIX03 +//Begin-Libc +#ifndef LIBC_ALIAS_TIMEZONE +//End-Libc +extern long timezone __DARWIN_ALIAS(timezone); +//Begin-Libc +#else /* LIBC_ALIAS_TIMEZONE */ +extern long timezone LIBC_ALIAS(timezone); +#endif /* !LIBC_ALIAS_TIMEZONE */ +//End-Libc +#endif /* __DARWIN_UNIX03 */ +extern int daylight; + +__BEGIN_DECLS +char *asctime(const struct tm *); +//Begin-Libc +#ifndef LIBC_ALIAS_CLOCK +//End-Libc +clock_t clock(void) __DARWIN_ALIAS(clock); +//Begin-Libc +#else /* LIBC_ALIAS_CLOCK */ +clock_t clock(void) LIBC_ALIAS(clock); +#endif /* !LIBC_ALIAS_CLOCK */ +//End-Libc +char *ctime(const time_t *); +double difftime(time_t, time_t); +struct tm *getdate(const char *); +struct tm *gmtime(const time_t *); +struct tm *localtime(const time_t *); +//Begin-Libc +#ifndef LIBC_ALIAS_MKTIME +//End-Libc +time_t mktime(struct tm *) __DARWIN_ALIAS(mktime); +//Begin-Libc +#else /* LIBC_ALIAS_MKTIME */ +time_t mktime(struct tm *) LIBC_ALIAS(mktime); +#endif /* !LIBC_ALIAS_MKTIME */ +//End-Libc +//Begin-Libc +#ifndef LIBC_ALIAS_STRFTIME +//End-Libc +size_t strftime(char * __restrict, size_t, const char * __restrict, const struct tm * __restrict) __DARWIN_ALIAS(strftime); +//Begin-Libc +#else /* LIBC_ALIAS_STRFTIME */ +size_t strftime(char * __restrict, size_t, const char * __restrict, const struct tm * __restrict) LIBC_ALIAS(strftime); +#endif /* !LIBC_ALIAS_STRFTIME */ +//End-Libc +//Begin-Libc +#ifndef LIBC_ALIAS_STRPTIME +//End-Libc +char *strptime(const char * __restrict, const char * __restrict, struct tm * __restrict) __DARWIN_ALIAS(strptime); +//Begin-Libc +#else /* LIBC_ALIAS_STRPTIME */ +char *strptime(const char * __restrict, const char * __restrict, struct tm * __restrict) LIBC_ALIAS(strptime); +#endif /* !LIBC_ALIAS_STRPTIME */ +//End-Libc +time_t time(time_t *); + +#ifndef _ANSI_SOURCE +void tzset(void); +#endif /* not ANSI */ + +/* [TSF] Thread safe functions */ +char *asctime_r(const struct tm * __restrict, char * __restrict); +char *ctime_r(const time_t *, char *); +struct tm *gmtime_r(const time_t * __restrict, struct tm * __restrict); +struct tm *localtime_r(const time_t * __restrict, struct tm * __restrict); + +#if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) +time_t posix2time(time_t); +#if !__DARWIN_UNIX03 +char *timezone(int, int); +#endif /* !__DARWIN_UNIX03 */ +void tzsetwall(void); +time_t time2posix(time_t); +time_t timelocal(struct tm * const); +time_t timegm(struct tm * const); +#endif /* neither ANSI nor POSIX */ + +#if !defined(_ANSI_SOURCE) +//Begin-Libc +#ifndef LIBC_ALIAS_NANOSLEEP +//End-Libc +int nanosleep(const struct timespec *, struct timespec *) __DARWIN_ALIAS_C(nanosleep); +//Begin-Libc +#else /* LIBC_ALIAS_NANOSLEEP */ +int nanosleep(const struct timespec *, struct timespec *) LIBC_ALIAS_C(nanosleep); +#endif /* !LIBC_ALIAS_NANOSLEEP */ +//End-Libc +#endif +__END_DECLS + +#ifdef _USE_EXTENDED_LOCALES_ +#include <xlocale/_time.h> +#endif /* _USE_EXTENDED_LOCALES_ */ + +#endif /* !_TIME_H_ */ Index: branches/azimutz/Cleancut/i386/include/locale.h =================================================================== --- branches/azimutz/Cleancut/i386/include/locale.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/locale.h (revision 885) @@ -0,0 +1,56 @@ +/* + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)locale.h 8.1 (Berkeley) 6/2/93 + * $FreeBSD: /repoman/r/ncvs/src/include/locale.h,v 1.7 2002/10/09 09:19:27 tjr Exp $ + */ + +#ifndef _LOCALE_H_ +#define _LOCALE_H_ + +#include <_locale.h> + +#define LC_ALL 0 +#define LC_COLLATE 1 +#define LC_CTYPE 2 +#define LC_MONETARY 3 +#define LC_NUMERIC 4 +#define LC_TIME 5 +#define LC_MESSAGES 6 + +#define _LC_LAST 7 /* marks end */ + +__BEGIN_DECLS +char *setlocale(int, const char *); +__END_DECLS + +#endif /* _LOCALE_H_ */ Index: branches/azimutz/Cleancut/i386/include/libkern/crypto/sha1.h =================================================================== --- branches/azimutz/Cleancut/i386/include/libkern/crypto/sha1.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/libkern/crypto/sha1.h (revision 885) @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2000-2006 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 _CRYPTO_SHA1_H_ +#define _CRYPTO_SHA1_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#define SHA_DIGEST_LENGTH 20 +#define SHA1_RESULTLEN SHA_DIGEST_LENGTH + +typedef struct sha1_ctxt { + union { + u_int8_t b8[20]; + u_int32_t b32[5]; /* state (ABCDE) */ + } h; + union { + u_int8_t b8[8]; + u_int32_t b32[2]; + u_int64_t b64[1]; /* # of bits, modulo 2^64 (msb first) */ + } c; + union { + u_int8_t b8[64]; + u_int32_t b32[16]; /* input buffer */ + } m; + u_int8_t count; /* unused; for compatibility only */ +} SHA1_CTX; + +/* For compatibility with the other SHA-1 implementation. */ +#define sha1_init(c) SHA1Init(c) +#define sha1_loop(c, b, l) SHA1Update(c, b, l) +#define sha1_result(c, b) SHA1Final(b, c) + +extern void SHA1Init(SHA1_CTX *); +extern void SHA1Update(SHA1_CTX *, const void *, size_t); +extern void SHA1UpdateUsePhysicalAddress(SHA1_CTX *, const void *, size_t); +extern void SHA1Final(void *, SHA1_CTX *); + +#ifdef __cplusplus +} +#endif + +#endif /*_CRYPTO_SHA1_H_*/ Index: branches/azimutz/Cleancut/i386/include/libkern/crypto/md5.h =================================================================== --- branches/azimutz/Cleancut/i386/include/libkern/crypto/md5.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/libkern/crypto/md5.h (revision 885) @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2000-2006 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@ + */ + +/* + * MD5.H - header file for MD5.C + */ + +/* + * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All + * rights reserved. + * + * License to copy and use this software is granted provided that it + * is identified as the "RSA Data Security, Inc. MD5 Message-Digest + * Algorithm" in all material mentioning or referencing this software + * or this function. + * + * License is also granted to make and use derivative works provided + * that such works are identified as "derived from the RSA Data + * Security, Inc. MD5 Message-Digest Algorithm" in all material + * mentioning or referencing the derived work. + * + * RSA Data Security, Inc. makes no representations concerning either + * the merchantability of this software or the suitability of this + * software for any particular purpose. It is provided "as is" + * without express or implied warranty of any kind. + * + * These notices must be retained in any copies of any part of this + * documentation and/or software. + */ + +#ifndef _CRYPTO_MD5_H_ +#define _CRYPTO_MD5_H_ + +#include <sys/types.h> +#include <sys/cdefs.h> + +__BEGIN_DECLS + +#define MD5_DIGEST_LENGTH 16 + +/* MD5 context. */ +typedef struct { + u_int32_t state[4]; /* state (ABCD) */ + u_int32_t count[2]; /* number of bits, modulo 2^64 (lsb first) */ + unsigned char buffer[64]; /* input buffer */ +} MD5_CTX; + +extern void MD5Init(MD5_CTX *); +extern void MD5Update(MD5_CTX *, const void *, unsigned int); +extern void MD5Final(unsigned char [MD5_DIGEST_LENGTH], MD5_CTX *); + +__END_DECLS + +#endif /* _CRYPTO_MD5_H_ */ Index: branches/azimutz/Cleancut/i386/include/libkern/ppc/OSByteOrder.h =================================================================== --- branches/azimutz/Cleancut/i386/include/libkern/ppc/OSByteOrder.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/libkern/ppc/OSByteOrder.h (revision 885) @@ -0,0 +1,206 @@ +/* + * Copyright (c) 2000-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 _OS_OSBYTEORDERPPC_H +#define _OS_OSBYTEORDERPPC_H + +#include <stdint.h> + +#if !defined(OS_INLINE) +# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +# define OS_INLINE static inline +# elif defined(__MWERKS__) || defined(__cplusplus) +# define OS_INLINE static inline +# else +# define OS_INLINE static __inline__ +# endif +#endif + +/* Functions for byte reversed loads. */ + +OS_INLINE +uint16_t +OSReadSwapInt16( + const volatile void * base, + uintptr_t byteOffset +) +{ + uint16_t result; + volatile uint16_t *addr = (volatile uint16_t *)((uintptr_t)base + byteOffset); + +#if defined(__llvm__) + result = *addr; + result = ((result << 8) | (result >> 8)); +#else + __asm__ ("lhbrx %0, %2, %1" + : "=r" (result) + : "r" (base), "bO" (byteOffset), "m" (*addr)); +#endif + + return result; +} + +OS_INLINE +uint32_t +OSReadSwapInt32( + const volatile void * base, + uintptr_t byteOffset +) +{ + uint32_t result; + volatile uint32_t *addr = (volatile uint32_t *)((uintptr_t)base + byteOffset); + +#if defined(__llvm__) + result = __builtin_bswap32(*addr); +#else + __asm__ ("lwbrx %0, %2, %1" + : "=r" (result) + : "r" (base), "bO" (byteOffset), "m" (*addr)); +#endif + + return result; +} + +OS_INLINE +uint64_t +OSReadSwapInt64( + const volatile void * base, + uintptr_t byteOffset +) +{ + volatile uint64_t *addr = (volatile uint64_t *)((uintptr_t)base + byteOffset); + union { + uint64_t u64; + uint32_t u32[2]; + } u; + +#if defined(__llvm__) + u.u64 = __builtin_bswap64(*addr); +#else + __asm__ ("lwbrx %0, %3, %2\n\t" + "lwbrx %1, %4, %2" + : "=&r" (u.u32[1]), "=r" (u.u32[0]) + : "r" (base), "bO" (byteOffset), "b" (byteOffset + 4), "m" (*addr)); +#endif + + return u.u64; +} + +/* Functions for byte reversed stores. */ + +OS_INLINE +void +OSWriteSwapInt16( + volatile void * base, + uintptr_t byteOffset, + uint16_t data +) +{ + volatile uint16_t *addr = (volatile uint16_t *)((uintptr_t)base + byteOffset); + +#if defined(__llvm__) + *addr = ((data >> 8) | (data << 8)); +#else + __asm__ ("sthbrx %1, %3, %2" + : "=m" (*addr) + : "r" (data), "r" (base), "bO" (byteOffset)); +#endif +} + +OS_INLINE +void +OSWriteSwapInt32( + volatile void * base, + uintptr_t byteOffset, + uint32_t data +) +{ + volatile uint32_t *addr = (volatile uint32_t *)((uintptr_t)base + byteOffset); + +#if defined(__llvm__) + *addr = __builtin_bswap32(data); +#else + __asm__ ("stwbrx %1, %3, %2" + : "=m" (*addr) + : "r" (data), "r" (base), "bO" (byteOffset)); +#endif +} + +OS_INLINE +void +OSWriteSwapInt64( + volatile void * base, + uintptr_t byteOffset, + uint64_t data +) +{ + volatile uint64_t *addr = (volatile uint64_t *)((uintptr_t)base + byteOffset); + +#if defined(__llvm__) + *addr = __builtin_bswap64(data); +#else + uint32_t hi = (uint32_t)(data >> 32); + uint32_t lo = (uint32_t)(data & 0xffffffff); + + __asm__ ("stwbrx %1, %4, %3\n\t" + "stwbrx %2, %5, %3" + : "=m" (*addr) + : "r" (lo), "r" (hi), "r" (base), "bO" (byteOffset), "b" (byteOffset + 4)); +#endif +} + +/* Generic byte swapping functions. */ + +OS_INLINE +uint16_t +_OSSwapInt16( + uint16_t data +) +{ + return OSReadSwapInt16(&data, 0); +} + +OS_INLINE +uint32_t +_OSSwapInt32( + uint32_t data +) +{ + return OSReadSwapInt32(&data, 0); +} + +OS_INLINE +uint64_t +_OSSwapInt64( + uint64_t data +) +{ + return OSReadSwapInt64(&data, 0); +} + +#endif /* ! _OS_OSBYTEORDERPPC_H */ Index: branches/azimutz/Cleancut/i386/include/libkern/OSAtomic.h =================================================================== --- branches/azimutz/Cleancut/i386/include/libkern/OSAtomic.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/libkern/OSAtomic.h (revision 885) @@ -0,0 +1,209 @@ +/* + * Copyright (c) 2004-2006 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 _OSATOMIC_H_ +#define _OSATOMIC_H_ + +#include <stddef.h> +#include <sys/cdefs.h> +#include <stdint.h> +#include <stdbool.h> + +/* These are the preferred versions of the atomic and synchronization operations. + * Their implementation is customized at boot time for the platform, including + * late-breaking errata fixes as necessary. They are thread safe. + * + * WARNING: all addresses passed to these functions must be "naturally aligned", ie + * int32_t's must be 32-bit aligned (low 2 bits of address zero), and int64_t's + * must be 64-bit aligned (low 3 bits of address zero.) + * + * Note that some versions of the atomic functions incorporate memory barriers, + * and some do not. Barriers strictly order memory access on a weakly-ordered + * architecture such as PPC. All loads and stores executed in sequential program + * order before the barrier will complete before any load or store executed after + * the barrier. On a uniprocessor, the barrier operation is typically a nop. + * On a multiprocessor, the barrier can be quite expensive on some platforms, + * eg PPC. + * + * Most code will want to use the barrier functions to insure that memory shared + * between threads is properly synchronized. For example, if you want to initialize + * a shared data structure and then atomically increment a variable to indicate + * that the initialization is complete, then you must use OSAtomicIncrement32Barrier() + * to ensure that the stores to your data structure complete before the atomic add. + * Likewise, the consumer of that data structure must use OSAtomicDecrement32Barrier(), + * in order to ensure that their loads of the structure are not executed before + * the atomic decrement. On the other hand, if you are simply incrementing a global + * counter, then it is safe and potentially faster to use OSAtomicIncrement32(). + * + * If you are unsure which version to use, prefer the barrier variants as they are + * safer. + * + * The spinlock and queue operations always incorporate a barrier. + */ +__BEGIN_DECLS + + +/* Arithmetic functions. They return the new value. + */ +int32_t OSAtomicAdd32( int32_t __theAmount, volatile int32_t *__theValue ); +int32_t OSAtomicAdd32Barrier( int32_t __theAmount, volatile int32_t *__theValue ); + +__inline static +int32_t OSAtomicIncrement32( volatile int32_t *__theValue ) + { return OSAtomicAdd32( 1, __theValue); } +__inline static +int32_t OSAtomicIncrement32Barrier( volatile int32_t *__theValue ) + { return OSAtomicAdd32Barrier( 1, __theValue); } + +__inline static +int32_t OSAtomicDecrement32( volatile int32_t *__theValue ) + { return OSAtomicAdd32( -1, __theValue); } +__inline static +int32_t OSAtomicDecrement32Barrier( volatile int32_t *__theValue ) + { return OSAtomicAdd32Barrier( -1, __theValue); } + +#if defined(__ppc64__) || defined(__i386__) || defined(__x86_64__) || defined(__arm__) + +int64_t OSAtomicAdd64( int64_t __theAmount, volatile int64_t *__theValue ); +int64_t OSAtomicAdd64Barrier( int64_t __theAmount, volatile int64_t *__theValue ); + +__inline static +int64_t OSAtomicIncrement64( volatile int64_t *__theValue ) + { return OSAtomicAdd64( 1, __theValue); } +__inline static +int64_t OSAtomicIncrement64Barrier( volatile int64_t *__theValue ) + { return OSAtomicAdd64Barrier( 1, __theValue); } + +__inline static +int64_t OSAtomicDecrement64( volatile int64_t *__theValue ) + { return OSAtomicAdd64( -1, __theValue); } +__inline static +int64_t OSAtomicDecrement64Barrier( volatile int64_t *__theValue ) + { return OSAtomicAdd64Barrier( -1, __theValue); } + +#endif /* defined(__ppc64__) || defined(__i386__) || defined(__x86_64__) || defined(__arm__) */ + + +/* Boolean functions (and, or, xor.) These come in four versions for each operation: + * with and without barriers, and returning the old or new value of the operation. + * The "Orig" versions return the original value, ie before the operation, the non-Orig + * versions return the value after the operation. All are layered on top of + * compare-and-swap. + */ +int32_t OSAtomicOr32( uint32_t __theMask, volatile uint32_t *__theValue ); +int32_t OSAtomicOr32Barrier( uint32_t __theMask, volatile uint32_t *__theValue ); +int32_t OSAtomicOr32Orig( uint32_t __theMask, volatile uint32_t *__theValue ); +int32_t OSAtomicOr32OrigBarrier( uint32_t __theMask, volatile uint32_t *__theValue ); + +int32_t OSAtomicAnd32( uint32_t __theMask, volatile uint32_t *__theValue ); +int32_t OSAtomicAnd32Barrier( uint32_t __theMask, volatile uint32_t *__theValue ); +int32_t OSAtomicAnd32Orig( uint32_t __theMask, volatile uint32_t *__theValue ); +int32_t OSAtomicAnd32OrigBarrier( uint32_t __theMask, volatile uint32_t *__theValue ); + +int32_t OSAtomicXor32( uint32_t __theMask, volatile uint32_t *__theValue ); +int32_t OSAtomicXor32Barrier( uint32_t __theMask, volatile uint32_t *__theValue ); +int32_t OSAtomicXor32Orig( uint32_t __theMask, volatile uint32_t *__theValue ); +int32_t OSAtomicXor32OrigBarrier( uint32_t __theMask, volatile uint32_t *__theValue ); + + +/* Compare and swap. They return true if the swap occured. There are several versions, + * depending on data type and whether or not a barrier is used. + */ +bool OSAtomicCompareAndSwap32( int32_t __oldValue, int32_t __newValue, volatile int32_t *__theValue ); +bool OSAtomicCompareAndSwap32Barrier( int32_t __oldValue, int32_t __newValue, volatile int32_t *__theValue ); +bool OSAtomicCompareAndSwapPtr( void *__oldValue, void *__newValue, void * volatile *__theValue ); +bool OSAtomicCompareAndSwapPtrBarrier( void *__oldValue, void *__newValue, void * volatile *__theValue ); +bool OSAtomicCompareAndSwapInt( int __oldValue, int __newValue, volatile int *__theValue ); +bool OSAtomicCompareAndSwapIntBarrier( int __oldValue, int __newValue, volatile int *__theValue ); +bool OSAtomicCompareAndSwapLong( long __oldValue, long __newValue, volatile long *__theValue ); +bool OSAtomicCompareAndSwapLongBarrier( long __oldValue, long __newValue, volatile long *__theValue ); + +#if defined(__ppc64__) || defined(__i386__) || defined(__x86_64__) || defined(__arm__) + +bool OSAtomicCompareAndSwap64( int64_t __oldValue, int64_t __newValue, volatile int64_t *__theValue ); +bool OSAtomicCompareAndSwap64Barrier( int64_t __oldValue, int64_t __newValue, volatile int64_t *__theValue ); + +#endif /* defined(__ppc64__) || defined(__i386__) || defined(__x86_64__) || defined(__arm__) */ + + +/* Test and set. They return the original value of the bit, and operate on bit (0x80>>(n&7)) + * in byte ((char*)theAddress + (n>>3)). + */ +bool OSAtomicTestAndSet( uint32_t __n, volatile void *__theAddress ); +bool OSAtomicTestAndSetBarrier( uint32_t __n, volatile void *__theAddress ); +bool OSAtomicTestAndClear( uint32_t __n, volatile void *__theAddress ); +bool OSAtomicTestAndClearBarrier( uint32_t __n, volatile void *__theAddress ); + + +/* Spinlocks. These use memory barriers as required to synchronize access to shared + * memory protected by the lock. The lock operation spins, but employs various strategies + * to back off if the lock is held, making it immune to most priority-inversion livelocks. + * The try operation immediately returns false if the lock was held, true if it took the + * lock. The convention is that unlocked is zero, locked is nonzero. + */ +#define OS_SPINLOCK_INIT 0 + +typedef int32_t OSSpinLock; + +bool OSSpinLockTry( volatile OSSpinLock *__lock ); +void OSSpinLockLock( volatile OSSpinLock *__lock ); +void OSSpinLockUnlock( volatile OSSpinLock *__lock ); + + +/* Lockless atomic enqueue and dequeue. These routines manipulate singly + * linked LIFO lists. Ie, a dequeue will return the most recently enqueued + * element, or NULL if the list is empty. The "offset" parameter is the offset + * in bytes of the link field within the data structure being queued. The + * link field should be a pointer type. Memory barriers are incorporated as + * needed to permit thread-safe access to the queue element. + */ +#if defined(__x86_64__) + +typedef volatile struct { + void *opaque1; + long opaque2; +} OSQueueHead __attribute__ ((aligned (16))); + +#else + +typedef volatile struct { + void *opaque1; + long opaque2; +} OSQueueHead; + +#endif + +#define OS_ATOMIC_QUEUE_INIT { NULL, 0 } + +void OSAtomicEnqueue( OSQueueHead *__list, void *__new, size_t __offset); +void* OSAtomicDequeue( OSQueueHead *__list, size_t __offset); + + +/* Memory barrier. It is both a read and write barrier. + */ +void OSMemoryBarrier( void ); + + +__END_DECLS + +#endif /* _OSATOMIC_H_ */ Index: branches/azimutz/Cleancut/i386/include/libkern/machine/OSByteOrder.h =================================================================== --- branches/azimutz/Cleancut/i386/include/libkern/machine/OSByteOrder.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/libkern/machine/OSByteOrder.h (revision 885) @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2000-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 _OS_OSBYTEORDERMACHINE_H +#define _OS_OSBYTEORDERMACHINE_H + +#include <stdint.h> + +#if !defined(OS_INLINE) +# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +# define OS_INLINE static inline +# elif defined(__MWERKS__) || defined(__cplusplus) +# define OS_INLINE static inline +# else +# define OS_INLINE static __inline__ +# endif +#endif + +/* Generic byte swapping functions. */ + +OS_INLINE +uint16_t +_OSSwapInt16( + uint16_t data +) +{ + return OSSwapConstInt16(data); +} + +OS_INLINE +uint32_t +_OSSwapInt32( + uint32_t data +) +{ + return OSSwapConstInt32(data); +} + +OS_INLINE +uint64_t +_OSSwapInt64( + uint64_t data +) +{ + return OSSwapConstInt64(data); +} + +/* Functions for byte reversed loads. */ + +OS_INLINE +uint16_t +OSReadSwapInt16( + const volatile void * base, + uintptr_t byteOffset +) +{ + uint16_t data = *(volatile uint16_t *)((uintptr_t)base + byteOffset); + return _OSSwapInt16(data); +} + +OS_INLINE +uint32_t +OSReadSwapInt32( + const volatile void * base, + uintptr_t byteOffset +) +{ + uint32_t data = *(volatile uint32_t *)((uintptr_t)base + byteOffset); + return _OSSwapInt32(data); +} + +OS_INLINE +uint64_t +OSReadSwapInt64( + const volatile void * base, + uintptr_t byteOffset +) +{ + uint64_t data = *(volatile uint64_t *)((uintptr_t)base + byteOffset); + return _OSSwapInt64(data); +} + +/* Functions for byte reversed stores. */ + +OS_INLINE +void +OSWriteSwapInt16( + volatile void * base, + uintptr_t byteOffset, + uint16_t data +) +{ + *(volatile uint16_t *)((uintptr_t)base + byteOffset) = _OSSwapInt16(data); +} + +OS_INLINE +void +OSWriteSwapInt32( + volatile void * base, + uintptr_t byteOffset, + uint32_t data +) +{ + *(volatile uint32_t *)((uintptr_t)base + byteOffset) = _OSSwapInt32(data); +} + +OS_INLINE +void +OSWriteSwapInt64( + volatile void * base, + uintptr_t byteOffset, + uint64_t data +) +{ + *(volatile uint64_t *)((uintptr_t)base + byteOffset) = _OSSwapInt64(data); +} + +#endif /* ! _OS_OSBYTEORDERMACHINE_H */ Index: branches/azimutz/Cleancut/i386/include/libkern/_OSByteOrder.h =================================================================== --- branches/azimutz/Cleancut/i386/include/libkern/_OSByteOrder.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/libkern/_OSByteOrder.h (revision 885) @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2006 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 _OS__OSBYTEORDER_H +#define _OS__OSBYTEORDER_H + +/* + * This header is normally included from <libkern/OSByteOrder.h>. However, + * <sys/_endian.h> also includes this in the case of little-endian + * architectures, so that we can map OSByteOrder routines to the hton* and ntoh* + * macros. This results in the asymmetry below; we only include + * <libkern/arch/_OSByteOrder.h> for little-endian architectures. + */ + +//#include <sys/_types.h> + +/* Macros for swapping constant values in the preprocessing stage. */ +#define __DARWIN_OSSwapConstInt16(x) \ + ((__uint16_t)((((__uint16_t)(x) & 0xff00) >> 8) | \ + (((__uint16_t)(x) & 0x00ff) << 8))) + +#define __DARWIN_OSSwapConstInt32(x) \ + ((__uint32_t)((((__uint32_t)(x) & 0xff000000) >> 24) | \ + (((__uint32_t)(x) & 0x00ff0000) >> 8) | \ + (((__uint32_t)(x) & 0x0000ff00) << 8) | \ + (((__uint32_t)(x) & 0x000000ff) << 24))) + +#define __DARWIN_OSSwapConstInt64(x) \ + ((__uint64_t)((((__uint64_t)(x) & 0xff00000000000000ULL) >> 56) | \ + (((__uint64_t)(x) & 0x00ff000000000000ULL) >> 40) | \ + (((__uint64_t)(x) & 0x0000ff0000000000ULL) >> 24) | \ + (((__uint64_t)(x) & 0x000000ff00000000ULL) >> 8) | \ + (((__uint64_t)(x) & 0x00000000ff000000ULL) << 8) | \ + (((__uint64_t)(x) & 0x0000000000ff0000ULL) << 24) | \ + (((__uint64_t)(x) & 0x000000000000ff00ULL) << 40) | \ + (((__uint64_t)(x) & 0x00000000000000ffULL) << 56))) + +#if defined(__GNUC__) + +#if defined(__i386__) || defined(__x86_64__) +#include <libkern/i386/_OSByteOrder.h> +#endif + +#if defined(__arm__) +#include <libkern/arm/OSByteOrder.h> +#endif + + +#define __DARWIN_OSSwapInt16(x) \ + (__builtin_constant_p(x) ? __DARWIN_OSSwapConstInt16(x) : _OSSwapInt16(x)) + +#define __DARWIN_OSSwapInt32(x) \ + (__builtin_constant_p(x) ? __DARWIN_OSSwapConstInt32(x) : _OSSwapInt32(x)) + +#define __DARWIN_OSSwapInt64(x) \ + (__builtin_constant_p(x) ? __DARWIN_OSSwapConstInt64(x) : _OSSwapInt64(x)) + +#else /* ! __GNUC__ */ + +#if defined(__i386__) || defined(__x86_64__) + +#if !defined(__DARWIN_OS_INLINE) +# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +# define __DARWIN_OS_INLINE static inline +# elif defined(__MWERKS__) || defined(__cplusplus) +# define __DARWIN_OS_INLINE static inline +# else +# define __DARWIN_OS_INLINE static __inline__ +# endif +#endif + +__DARWIN_OS_INLINE +uint16_t +_OSSwapInt16( + uint16_t data +) +{ + return __DARWIN_OSSwapConstInt16(data); +} + +__DARWIN_OS_INLINE +uint32_t +_OSSwapInt32( + uint32_t data +) +{ + return __DARWIN_OSSwapConstInt32(data); +} + +__DARWIN_OS_INLINE +uint64_t +_OSSwapInt64( + uint64_t data +) +{ + return __DARWIN_OSSwapConstInt64(data); +} +#endif + +#define __DARWIN_OSSwapInt16(x) _OSSwapInt16(x) + +#define __DARWIN_OSSwapInt32(x) _OSSwapInt32(x) + +#define __DARWIN_OSSwapInt64(x) _OSSwapInt64(x) + +#endif /* __GNUC__ */ + +#endif /* ! _OS__OSBYTEORDER_H */ Index: branches/azimutz/Cleancut/i386/include/libkern/OSByteOrder.h =================================================================== --- branches/azimutz/Cleancut/i386/include/libkern/OSByteOrder.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/libkern/OSByteOrder.h (revision 885) @@ -0,0 +1,310 @@ +/* + * Copyright (c) 2000-2006 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 _OS_OSBYTEORDER_H +#define _OS_OSBYTEORDER_H + +#include <stdint.h> +#include <libkern/_OSByteOrder.h> + +/* Macros for swapping constant values in the preprocessing stage. */ +#define OSSwapConstInt16(x) __DARWIN_OSSwapConstInt16(x) +#define OSSwapConstInt32(x) __DARWIN_OSSwapConstInt32(x) +#define OSSwapConstInt64(x) __DARWIN_OSSwapConstInt64(x) + +#if defined(__GNUC__) + +#if (defined(__ppc__) || defined(__ppc64__)) +#include <libkern/ppc/OSByteOrder.h> +#elif (defined(__i386__) || defined(__x86_64__)) +#include <libkern/i386/OSByteOrder.h> +#elif defined(__arm__) +#include <libkern/arm/OSByteOrder.h> +#else +#include <libkern/machine/OSByteOrder.h> +#endif + +#else /* ! __GNUC__ */ + +#include <libkern/machine/OSByteOrder.h> + +#endif /* __GNUC__ */ + +#define OSSwapInt16(x) __DARWIN_OSSwapInt16(x) +#define OSSwapInt32(x) __DARWIN_OSSwapInt32(x) +#define OSSwapInt64(x) __DARWIN_OSSwapInt64(x) + +enum { + OSUnknownByteOrder, + OSLittleEndian, + OSBigEndian +}; + +OS_INLINE +int32_t +OSHostByteOrder(void) { +#if defined(__LITTLE_ENDIAN__) + return OSLittleEndian; +#elif defined(__BIG_ENDIAN__) + return OSBigEndian; +#else + return OSUnknownByteOrder; +#endif +} + +#define OSReadBigInt(x, y) OSReadBigInt32(x, y) +#define OSWriteBigInt(x, y, z) OSWriteBigInt32(x, y, z) +#define OSSwapBigToHostInt(x) OSSwapBigToHostInt32(x) +#define OSSwapHostToBigInt(x) OSSwapHostToBigInt32(x) +#define OSReadLittleInt(x, y) OSReadLittleInt32(x, y) +#define OSWriteLittleInt(x, y, z) OSWriteLittleInt32(x, y, z) +#define OSSwapHostToLittleInt(x) OSSwapHostToLittleInt32(x) +#define OSSwapLittleToHostInt(x) OSSwapLittleToHostInt32(x) + +/* Functions for loading native endian values. */ + +OS_INLINE +uint16_t +_OSReadInt16( + const volatile void * base, + uintptr_t byteOffset +) +{ + return *(volatile uint16_t *)((uintptr_t)base + byteOffset); +} + +OS_INLINE +uint32_t +_OSReadInt32( + const volatile void * base, + uintptr_t byteOffset +) +{ + return *(volatile uint32_t *)((uintptr_t)base + byteOffset); +} + +OS_INLINE +uint64_t +_OSReadInt64( + const volatile void * base, + uintptr_t byteOffset +) +{ + return *(volatile uint64_t *)((uintptr_t)base + byteOffset); +} + +/* Functions for storing native endian values. */ + +OS_INLINE +void +_OSWriteInt16( + volatile void * base, + uintptr_t byteOffset, + uint16_t data +) +{ + *(volatile uint16_t *)((uintptr_t)base + byteOffset) = data; +} + +OS_INLINE +void +_OSWriteInt32( + volatile void * base, + uintptr_t byteOffset, + uint32_t data +) +{ + *(volatile uint32_t *)((uintptr_t)base + byteOffset) = data; +} + +OS_INLINE +void +_OSWriteInt64( + volatile void * base, + uintptr_t byteOffset, + uint64_t data +) +{ + *(volatile uint64_t *)((uintptr_t)base + byteOffset) = data; +} + +#if defined(__BIG_ENDIAN__) + +/* Functions for loading big endian to host endianess. */ + +#define OSReadBigInt16(base, byteOffset) _OSReadInt16(base, byteOffset) +#define OSReadBigInt32(base, byteOffset) _OSReadInt32(base, byteOffset) +#define OSReadBigInt64(base, byteOffset) _OSReadInt64(base, byteOffset) + +/* Functions for storing host endianess to big endian. */ + +#define OSWriteBigInt16(base, byteOffset, data) _OSWriteInt16(base, byteOffset, data) +#define OSWriteBigInt32(base, byteOffset, data) _OSWriteInt32(base, byteOffset, data) +#define OSWriteBigInt64(base, byteOffset, data) _OSWriteInt64(base, byteOffset, data) + +/* Functions for loading little endian to host endianess. */ + +#define OSReadLittleInt16(base, byteOffset) OSReadSwapInt16(base, byteOffset) +#define OSReadLittleInt32(base, byteOffset) OSReadSwapInt32(base, byteOffset) +#define OSReadLittleInt64(base, byteOffset) OSReadSwapInt64(base, byteOffset) + +/* Functions for storing host endianess to little endian. */ + +#define OSWriteLittleInt16(base, byteOffset, data) OSWriteSwapInt16(base, byteOffset, data) +#define OSWriteLittleInt32(base, byteOffset, data) OSWriteSwapInt32(base, byteOffset, data) +#define OSWriteLittleInt64(base, byteOffset, data) OSWriteSwapInt64(base, byteOffset, data) + +/* Host endianess to big endian byte swapping macros for constants. */ + +#define OSSwapHostToBigConstInt16(x) ((uint16_t)(x)) +#define OSSwapHostToBigConstInt32(x) ((uint32_t)(x)) +#define OSSwapHostToBigConstInt64(x) ((uint64_t)(x)) + +/* Generic host endianess to big endian byte swapping functions. */ + +#define OSSwapHostToBigInt16(x) ((uint16_t)(x)) +#define OSSwapHostToBigInt32(x) ((uint32_t)(x)) +#define OSSwapHostToBigInt64(x) ((uint64_t)(x)) + +/* Host endianess to little endian byte swapping macros for constants. */ + +#define OSSwapHostToLittleConstInt16(x) OSSwapConstInt16(x) +#define OSSwapHostToLittleConstInt32(x) OSSwapConstInt32(x) +#define OSSwapHostToLittleConstInt64(x) OSSwapConstInt64(x) + +/* Generic host endianess to little endian byte swapping functions. */ + +#define OSSwapHostToLittleInt16(x) OSSwapInt16(x) +#define OSSwapHostToLittleInt32(x) OSSwapInt32(x) +#define OSSwapHostToLittleInt64(x) OSSwapInt64(x) + +/* Big endian to host endianess byte swapping macros for constants. */ + +#define OSSwapBigToHostConstInt16(x) ((uint16_t)(x)) +#define OSSwapBigToHostConstInt32(x) ((uint32_t)(x)) +#define OSSwapBigToHostConstInt64(x) ((uint64_t)(x)) + +/* Generic big endian to host endianess byte swapping functions. */ + +#define OSSwapBigToHostInt16(x) ((uint16_t)(x)) +#define OSSwapBigToHostInt32(x) ((uint32_t)(x)) +#define OSSwapBigToHostInt64(x) ((uint64_t)(x)) + +/* Little endian to host endianess byte swapping macros for constants. */ + +#define OSSwapLittleToHostConstInt16(x) OSSwapConstInt16(x) +#define OSSwapLittleToHostConstInt32(x) OSSwapConstInt32(x) +#define OSSwapLittleToHostConstInt64(x) OSSwapConstInt64(x) + +/* Generic little endian to host endianess byte swapping functions. */ + +#define OSSwapLittleToHostInt16(x) OSSwapInt16(x) +#define OSSwapLittleToHostInt32(x) OSSwapInt32(x) +#define OSSwapLittleToHostInt64(x) OSSwapInt64(x) + +#elif defined(__LITTLE_ENDIAN__) + +/* Functions for loading big endian to host endianess. */ + +#define OSReadBigInt16(base, byteOffset) OSReadSwapInt16(base, byteOffset) +#define OSReadBigInt32(base, byteOffset) OSReadSwapInt32(base, byteOffset) +#define OSReadBigInt64(base, byteOffset) OSReadSwapInt64(base, byteOffset) + +/* Functions for storing host endianess to big endian. */ + +#define OSWriteBigInt16(base, byteOffset, data) OSWriteSwapInt16(base, byteOffset, data) +#define OSWriteBigInt32(base, byteOffset, data) OSWriteSwapInt32(base, byteOffset, data) +#define OSWriteBigInt64(base, byteOffset, data) OSWriteSwapInt64(base, byteOffset, data) + +/* Functions for loading little endian to host endianess. */ + +#define OSReadLittleInt16(base, byteOffset) _OSReadInt16(base, byteOffset) +#define OSReadLittleInt32(base, byteOffset) _OSReadInt32(base, byteOffset) +#define OSReadLittleInt64(base, byteOffset) _OSReadInt64(base, byteOffset) + +/* Functions for storing host endianess to little endian. */ + +#define OSWriteLittleInt16(base, byteOffset, data) _OSWriteInt16(base, byteOffset, data) +#define OSWriteLittleInt32(base, byteOffset, data) _OSWriteInt32(base, byteOffset, data) +#define OSWriteLittleInt64(base, byteOffset, data) _OSWriteInt64(base, byteOffset, data) + +/* Host endianess to big endian byte swapping macros for constants. */ + +#define OSSwapHostToBigConstInt16(x) OSSwapConstInt16(x) +#define OSSwapHostToBigConstInt32(x) OSSwapConstInt32(x) +#define OSSwapHostToBigConstInt64(x) OSSwapConstInt64(x) + +/* Generic host endianess to big endian byte swapping functions. */ + +#define OSSwapHostToBigInt16(x) OSSwapInt16(x) +#define OSSwapHostToBigInt32(x) OSSwapInt32(x) +#define OSSwapHostToBigInt64(x) OSSwapInt64(x) + +/* Host endianess to little endian byte swapping macros for constants. */ + +#define OSSwapHostToLittleConstInt16(x) ((uint16_t)(x)) +#define OSSwapHostToLittleConstInt32(x) ((uint32_t)(x)) +#define OSSwapHostToLittleConstInt64(x) ((uint64_t)(x)) + +/* Generic host endianess to little endian byte swapping functions. */ + +#define OSSwapHostToLittleInt16(x) ((uint16_t)(x)) +#define OSSwapHostToLittleInt32(x) ((uint32_t)(x)) +#define OSSwapHostToLittleInt64(x) ((uint64_t)(x)) + +/* Big endian to host endianess byte swapping macros for constants. */ + +#define OSSwapBigToHostConstInt16(x) OSSwapConstInt16(x) +#define OSSwapBigToHostConstInt32(x) OSSwapConstInt32(x) +#define OSSwapBigToHostConstInt64(x) OSSwapConstInt64(x) + +/* Generic big endian to host endianess byte swapping functions. */ + +#define OSSwapBigToHostInt16(x) OSSwapInt16(x) +#define OSSwapBigToHostInt32(x) OSSwapInt32(x) +#define OSSwapBigToHostInt64(x) OSSwapInt64(x) + +/* Little endian to host endianess byte swapping macros for constants. */ + +#define OSSwapLittleToHostConstInt16(x) ((uint16_t)(x)) +#define OSSwapLittleToHostConstInt32(x) ((uint32_t)(x)) +#define OSSwapLittleToHostConstInt64(x) ((uint64_t)(x)) + +/* Generic little endian to host endianess byte swapping functions. */ + +#define OSSwapLittleToHostInt16(x) ((uint16_t)(x)) +#define OSSwapLittleToHostInt32(x) ((uint32_t)(x)) +#define OSSwapLittleToHostInt64(x) ((uint64_t)(x)) + +#else +#error Unknown endianess. +#endif + +#endif /* ! _OS_OSBYTEORDER_H */ + + Index: branches/azimutz/Cleancut/i386/include/libkern/OSReturn.h =================================================================== --- branches/azimutz/Cleancut/i386/include/libkern/OSReturn.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/libkern/OSReturn.h (revision 885) @@ -0,0 +1,198 @@ +/* + * Copyright (c) 2000 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 + * + */ + +/* + * Core OSReturn values. + */ + +#ifndef __LIBKERN_OSRETURN_H +#define __LIBKERN_OSRETURN_H + +#include <sys/cdefs.h> + +__BEGIN_DECLS + +#include <mach/error.h> + + +/*! + * @header + * + * Declares functions, basic return values, and other constants + * related to kernel extensions (kexts). + */ + +#if PRAGMA_MARK +#pragma mark Core OSReturn Values for Libkern +#endif +/********************************************************************* +* Core OSReturn Values for Libkern +*********************************************************************/ +/*! + * @group Core OSReturn Values for Libkern + * Some kext and I/O Kit functions can return these values, + * as well as other values of + * <code>kern_return_t</code>. + * + * Many of these return values represent internal errors + * in the Libkern C++ run-time typing information system + * based on @link //apple_ref/doc/class/OSMetaClass OSMetaClass@/link; + * you are unlikely to ever see them. + * + */ + + +/*! + * @typedef OSReturn + * @abstract The return type for many Libkern functions. + */ +typedef kern_return_t OSReturn; + +#ifndef sys_libkern +#define sys_libkern err_system(0x37) +#endif /* sys_libkern */ + +#define sub_libkern_common err_sub(0) +#define sub_libkern_metaclass err_sub(1) +#define sub_libkern_reserved err_sub(-1) + +#define libkern_common_err(return) (sys_libkern|sub_libkern_common|(return)) +#define libkern_metaclass_err(return) (sys_libkern|sub_libkern_metaclass|(return)) + +/* See OSKextLib.h for these + * #define sub_libkern_kext err_sub(2) + * #define libkern_kext_err(code) (sys_libkern|sub_libkern_kext|(code)) + */ + +/*! + * @define kOSReturnSuccess + * @abstract Operation successful. + * Equal to <code>@link //apple_ref/c/econst/KERN_SUCCESS + * KERN_SUCCESS@/link</code>. + */ +#define kOSReturnSuccess KERN_SUCCESS + +/*! + * @define kOSReturnError + * @abstract Unspecified Libkern error. + * <b>Not equal</b> to + * <code>@link //apple_ref/c/econst/KERN_FAILURE + * KERN_FAILURE@/link</code>. + */ +#define kOSReturnError libkern_common_err(1) + +/*! + * @define kOSMetaClassInternal + * @abstract Internal OSMetaClass run-time error. + */ +#define kOSMetaClassInternal libkern_metaclass_err(1) + +/*! + * @define kOSMetaClassHasInstances + * @abstract A kext cannot be unloaded because there are instances + * derived from Libkern C++ classes that it defines. + */ +#define kOSMetaClassHasInstances libkern_metaclass_err(2) + +/*! + * @define kOSMetaClassNoInit + * @abstract Internal error: The Libkern C++ class registration system + * was not properly initialized during kext loading. + */ +#define kOSMetaClassNoInit libkern_metaclass_err(3) +// OSMetaClass::preModLoad wasn't called, runtime internal error + +/*! + * @define kOSMetaClassNoTempData + * @abstract Internal error: An allocation failure occurred + * registering Libkern C++ classes during kext loading. + */ +#define kOSMetaClassNoTempData libkern_metaclass_err(4) +// Allocation failure internal data + +/*! + * @define kOSMetaClassNoDicts + * @abstract Internal error: An allocation failure occurred + * registering Libkern C++ classes during kext loading. + */ +#define kOSMetaClassNoDicts libkern_metaclass_err(5) +// Allocation failure for Metaclass internal dictionaries + +/*! + * @define kOSMetaClassNoKModSet + * @abstract Internal error: An allocation failure occurred + * registering Libkern C++ classes during kext loading. + */ +#define kOSMetaClassNoKModSet libkern_metaclass_err(6) +// Allocation failure for internal kmodule set + +/*! + * @define kOSMetaClassNoInsKModSet + * @abstract Internal error: An error occurred registering + * a specific Libkern C++ class during kext loading. + */ +#define kOSMetaClassNoInsKModSet libkern_metaclass_err(7) +// Can't insert the KMod set into the module dictionary + +/*! + * @define kOSMetaClassNoSuper + * @abstract Internal error: No superclass can be found + * for a specific Libkern C++ class during kext loading. + */ +#define kOSMetaClassNoSuper libkern_metaclass_err(8) + +/*! + * @define kOSMetaClassInstNoSuper + * @abstract Internal error: No superclass can be found when constructing + * an instance of a Libkern C++ class. + */ +#define kOSMetaClassInstNoSuper libkern_metaclass_err(9) + +/*! + * @define kOSMetaClassDuplicateClass + * @abstract A duplicate Libkern C++ classname was encountered + * during kext loading. + */ +#define kOSMetaClassDuplicateClass libkern_metaclass_err(10) + +/*! + * @define kOSMetaClassNoKext + * @abstract Internal error: The kext for a Libkern C++ class + * can't be found during kext loading. + */ +#define kOSMetaClassNoKext libkern_metaclass_err(11) + +__END_DECLS + +#endif /* ! __LIBKERN_OSRETURN_H */ Index: branches/azimutz/Cleancut/i386/include/libkern/i386/_OSByteOrder.h =================================================================== --- branches/azimutz/Cleancut/i386/include/libkern/i386/_OSByteOrder.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/libkern/i386/_OSByteOrder.h (revision 885) @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2006 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 _OS__OSBYTEORDERI386_H +#define _OS__OSBYTEORDERI386_H + +#if !defined(__DARWIN_OS_INLINE) +# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +# define __DARWIN_OS_INLINE static inline +# elif defined(__MWERKS__) || defined(__cplusplus) +# define __DARWIN_OS_INLINE static inline +# else +# define __DARWIN_OS_INLINE static __inline__ +# endif +#endif + +/* Generic byte swapping functions. */ + +__DARWIN_OS_INLINE +__uint16_t +_OSSwapInt16( + __uint16_t _data +) +{ + return ((_data << 8) | (_data >> 8)); +} + +__DARWIN_OS_INLINE +__uint32_t +_OSSwapInt32( + __uint32_t _data +) +{ +#if defined(__llvm__) + return __builtin_bswap32(_data); +#else + __asm__ ("bswap %0" : "+r" (_data)); + return _data; +#endif +} + +#if defined(__llvm__) +__DARWIN_OS_INLINE +__uint64_t +_OSSwapInt64( + __uint64_t _data +) +{ + return __builtin_bswap64(_data); +} + +#elif defined(__i386__) +__DARWIN_OS_INLINE +__uint64_t +_OSSwapInt64( + __uint64_t _data +) +{ + __asm__ ("bswap %%eax\n\t" + "bswap %%edx\n\t" + "xchgl %%eax, %%edx" + : "+A" (_data)); + return _data; +} +#elif defined(__x86_64__) +__DARWIN_OS_INLINE +__uint64_t +_OSSwapInt64( + __uint64_t _data +) +{ + __asm__ ("bswap %0" : "+r" (_data)); + return _data; +} +#else +#error Unknown architecture +#endif + +#endif /* ! _OS__OSBYTEORDERI386_H */ Index: branches/azimutz/Cleancut/i386/include/libkern/i386/OSByteOrder.h =================================================================== --- branches/azimutz/Cleancut/i386/include/libkern/i386/OSByteOrder.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/libkern/i386/OSByteOrder.h (revision 885) @@ -0,0 +1,115 @@ +/* + * Copyright (c) 1999-2006 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 _OS_OSBYTEORDERI386_H +#define _OS_OSBYTEORDERI386_H + +#include <stdint.h> +#include <libkern/i386/_OSByteOrder.h> + +#if !defined(OS_INLINE) +#define OS_INLINE __DARWIN_OS_INLINE +#endif + +/* Functions for byte reversed loads. */ + +OS_INLINE +uint16_t +OSReadSwapInt16( + const volatile void * base, + uintptr_t byteOffset +) +{ + uint16_t result; + + result = *(volatile uint16_t *)((uintptr_t)base + byteOffset); + return _OSSwapInt16(result); +} + +OS_INLINE +uint32_t +OSReadSwapInt32( + const volatile void * base, + uintptr_t byteOffset +) +{ + uint32_t result; + + result = *(volatile uint32_t *)((uintptr_t)base + byteOffset); + return _OSSwapInt32(result); +} + +OS_INLINE +uint64_t +OSReadSwapInt64( + const volatile void * base, + uintptr_t byteOffset +) +{ + uint64_t result; + + result = *(volatile uint64_t *)((uintptr_t)base + byteOffset); + return _OSSwapInt64(result); +} + +/* Functions for byte reversed stores. */ + +OS_INLINE +void +OSWriteSwapInt16( + volatile void * base, + uintptr_t byteOffset, + uint16_t data +) +{ + *(volatile uint16_t *)((uintptr_t)base + byteOffset) = _OSSwapInt16(data); +} + +OS_INLINE +void +OSWriteSwapInt32( + volatile void * base, + uintptr_t byteOffset, + uint32_t data +) +{ + *(volatile uint32_t *)((uintptr_t)base + byteOffset) = _OSSwapInt32(data); +} + +OS_INLINE +void +OSWriteSwapInt64( + volatile void * base, + uintptr_t byteOffset, + uint64_t data +) +{ + *(volatile uint64_t *)((uintptr_t)base + byteOffset) = _OSSwapInt64(data); +} + +#endif /* ! _OS_OSBYTEORDERI386_H */ Index: branches/azimutz/Cleancut/i386/include/libkern/OSKextLib.h =================================================================== --- branches/azimutz/Cleancut/i386/include/libkern/OSKextLib.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/libkern/OSKextLib.h (revision 885) @@ -0,0 +1,472 @@ +/* + * Copyright (c) 2008 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 _LIBKERN_OSKEXTLIB_H +#define _LIBKERN_OSKEXTLIB_H + +#include <sys/cdefs.h> +__BEGIN_DECLS + +#include <stdint.h> +#include <mach/kmod.h> +#include <mach/vm_types.h> + +#include <CoreFoundation/CoreFoundation.h> +#include <System/libkern/OSReturn.h> + +/*! + * @header + * + * Declares functions, basic return values, and other constants + * related to kernel extensions (kexts). + */ + +#if PRAGMA_MARK +#pragma mark - +/********************************************************************/ +#pragma mark OSReturn Values for Kernel Extensions +/********************************************************************/ +#endif +/*! + * @group OSReturn Values for Kernel Extensions + * Many kext-related functions return these values, + * as well as those defined under + * <code>@link //apple_ref/c/tdef/OSReturn OSReturn@/link</code> + * and other variants of <code>kern_return_t</code>. + */ + + +#define sub_libkern_kext err_sub(2) +#define libkern_kext_err(code) (sys_libkern|sub_libkern_kext|(code)) + + +/*! + * @define kOSKextReturnInternalError + * @abstract An internal error in the kext library. + * Contrast with <code>@link //apple_ref/c/econst/OSReturnError + * OSReturnError@/link</code>. + */ +#define kOSKextReturnInternalError libkern_kext_err(0x1) + +/*! + * @define kOSKextReturnNoMemory + * @abstract Memory allocation failed. + */ +#define kOSKextReturnNoMemory libkern_kext_err(0x2) + +/*! + * @define kOSKextReturnNoResources + * @abstract Some resource other than memory (such as available load tags) + * is exhausted. + */ +#define kOSKextReturnNoResources libkern_kext_err(0x3) + +/*! + * @define kOSKextReturnNotPrivileged + * @abstract The caller lacks privileges to perform the requested operation. + */ +#define kOSKextReturnNotPrivileged libkern_kext_err(0x4) + +/*! + * @define kOSKextReturnInvalidArgument + * @abstract Invalid argument. + */ +#define kOSKextReturnInvalidArgument libkern_kext_err(0x5) + +/*! + * @define kOSKextReturnNotFound + * @abstract Search item not found. + */ +#define kOSKextReturnNotFound libkern_kext_err(0x6) + +/*! + * @define kOSKextReturnBadData + * @abstract Malformed data (not used for XML). + */ +#define kOSKextReturnBadData libkern_kext_err(0x7) + +/*! + * @define kOSKextReturnSerialization + * @abstract Error converting or (un)serializing URL, string, or XML. + */ +#define kOSKextReturnSerialization libkern_kext_err(0x8) + +/*! + * @define kOSKextReturnUnsupported + * @abstract Operation is no longer or not yet supported. + */ +#define kOSKextReturnUnsupported libkern_kext_err(0x9) + +/*! + * @define kOSKextReturnDisabled + * @abstract Operation is currently disabled. + */ +#define kOSKextReturnDisabled libkern_kext_err(0xa) + +/*! + * @define kOSKextReturnNotAKext + * @abstract Bundle is not a kernel extension. + */ +#define kOSKextReturnNotAKext libkern_kext_err(0xb) + +/*! + * @define kOSKextReturnValidation + * @abstract Validation failures encountered; check diagnostics for details. + */ +#define kOSKextReturnValidation libkern_kext_err(0xc) + +/*! + * @define kOSKextReturnAuthentication + * @abstract Authetication failures encountered; check diagnostics for details. + */ +#define kOSKextReturnAuthentication libkern_kext_err(0xd) + +/*! + * @define kOSKextReturnDependencies + * @abstract Dependency resolution failures encountered; check diagnostics for details. + */ +#define kOSKextReturnDependencies libkern_kext_err(0xe) + +/*! + * @define kOSKextReturnArchNotFound + * @abstract Kext does not contain code for the requested architecture. + */ +#define kOSKextReturnArchNotFound libkern_kext_err(0xf) + +/*! + * @define kOSKextReturnCache + * @abstract An error occurred processing a system kext cache. + */ +#define kOSKextReturnCache libkern_kext_err(0x10) + +/*! + * @define kOSKextReturnDeferred + * @abstract Operation has been posted asynchronously to user space (kernel only). + */ +#define kOSKextReturnDeferred libkern_kext_err(0x11) + +/*! + * @define kOSKextReturnBootLevel + * @abstract Kext not loadable or operation not allowed at current boot level. + */ +#define kOSKextReturnBootLevel libkern_kext_err(0x12) + +/*! + * @define kOSKextReturnNotLoadable + * @abstract Kext cannot be loaded; check diagnostics for details. + */ +#define kOSKextReturnNotLoadable libkern_kext_err(0x13) + +/*! + * @define kOSKextReturnLoadedVersionDiffers + * @abstract A different version (or executable UUID, or executable by checksum) + * of the requested kext is already loaded. + */ +#define kOSKextReturnLoadedVersionDiffers libkern_kext_err(0x14) + +/*! + * @define kOSKextReturnDependencyLoadError + * @abstract A load error occurred on a dependency of the kext being loaded. + */ +#define kOSKextReturnDependencyLoadError libkern_kext_err(0x15) + +/*! + * @define kOSKextReturnLinkError + * @abstract A link failure occured with this kext or a dependency. + */ +#define kOSKextReturnLinkError libkern_kext_err(0x16) + +/*! + * @define kOSKextReturnStartStopError + * @abstract The kext start or stop routine returned an error. + */ +#define kOSKextReturnStartStopError libkern_kext_err(0x17) + +/*! + * @define kOSKextReturnInUse + * @abstract The kext is currently in use or has outstanding references, + * and cannot be unloaded. + */ +#define kOSKextReturnInUse libkern_kext_err(0x18) + +/*! + * @define kOSKextReturnTimeout + * @abstract A kext request has timed out. + */ +#define kOSKextReturnTimeout libkern_kext_err(0x19) + +/*! + * @define kOSKextReturnStopping + * @abstract The kext is in the process of stopping; requests cannot be made. + */ +#define kOSKextReturnStopping libkern_kext_err(0x1a) + +#if PRAGMA_MARK +#pragma mark - +/********************************************************************/ +#pragma mark Kext/OSBundle Property List Keys +/********************************************************************/ +#endif +/*! + * @group Kext Property List Keys + * These constants cover CFBundle properties defined for kernel extensions. + * Because they are used in the kernel, if you want to use one with + * CFBundle APIs you'll need to wrap it in a <code>CFSTR()</code> macro. + */ + + +/*! + * @define kOSBundleCompatibleVersionKey + * @abstract A string giving the backwards-compatible version of a library kext + * in extended Mac OS 'vers' format (####.##.##s{1-255} where 's' + * is a build stage 'd', 'a', 'b', 'f' or 'fc'). + */ +#define kOSBundleCompatibleVersionKey "OSBundleCompatibleVersion" + +/*! + * @define kOSBundleEnableKextLoggingKey + * @abstract Set to true to have the kernel kext logging spec applied + * to the kext. + * See <code>@link //apple_ref/c/econst/OSKextLogSpec + * OSKextLogSpec@/link</code>. + */ +#define kOSBundleEnableKextLoggingKey "OSBundleEnableKextLogging" + +/*! + * @define kOSBundleIsInterfaceKey + * @abstract A boolean value indicating whether the kext executable + * contains only symbol references. + */ +#define kOSBundleIsInterfaceKey "OSBundleIsInterface" + +/*! + * @define kOSBundleLibrariesKey + * @abstract A dictionary listing link dependencies for this kext. + * Keys are bundle identifiers, values are version strings. + */ +#define kOSBundleLibrariesKey "OSBundleLibraries" + +/*! + * @define kOSBundleRequiredKey + * @abstract A string indicating in which kinds of startup this kext + * may need to load during early startup (before + * <code>@link //apple_ref/doc/man/8/kextd kextcache(8)@/link</code>). + * @discussion + * The value is one of: + * <ul> + * <li>@link kOSBundleRequiredRoot "OSBundleRequiredRoot"@/link</li> + * <li>@link kOSBundleRequiredLocalRoot "OSBundleRequiredLocalRoot"@/link</li> + * <li>@link kOSBundleRequiredNetworkRoot "OSBundleRequiredNetworkRoot"@/link</li> + * <li>@link kOSBundleRequiredSafeBoot "OSBundleRequiredSafeBoot"@/link</li> + * <li>@link kOSBundleRequiredConsole "OSBundleRequiredConsole"@/link</li> + * </ul> + * + * Use this property judiciously. + * Every kext that declares a value other than "OSBundleRequiredSafeBoot" + * increases startup time, as the booter must read it into memory, + * or startup kext caches must include it. + */ +#define kOSBundleRequiredKey "OSBundleRequired" + +/*! + * @define kOSBundleAllowUserLoadKey + * @abstract A boolean value indicating whether + * <code>@link //apple_ref/doc/man/8/kextd kextcache(8)@/link</code> + * will honor a non-root process's request to load a kext. + * @discussion + * See <code>@link //apple_ref/doc/compositePage/c/func/KextManagerLoadKextWithURL + * KextManagerLoadKextWithURL@/link</code> + * and <code>@link //apple_ref/doc/compositePage/c/func/KextManagerLoadKextWithIdentifier + * KextManagerLoadKextWithIdentifier@/link</code>. + */ +#define kOSBundleAllowUserLoadKey "OSBundleAllowUserLoad" + +/*! + * @define kOSKernelResourceKey + * @abstract A boolean value indicating whether the kext represents a built-in + * component of the kernel. + */ +#define kOSKernelResourceKey "OSKernelResource" + +/*! + * @define kIOKitPersonalitiesKey + * @abstract A dictionary of dictionaries used in matching for I/O Kit drivers. + */ +#define kIOKitPersonalitiesKey "IOKitPersonalities" + +/* + * @define kIOPersonalityPublisherKey + * @abstract Used in personalities sent to the I/O Kit, + * contains the CFBundleIdentifier of the kext + * that the personality originated in. + */ +#define kIOPersonalityPublisherKey "IOPersonalityPublisher" + + +#if PRAGMA_MARK +/********************************************************************/ +#pragma mark Kext/OSBundle Property Deprecated Keys +/********************************************************************/ +#endif +/* + * @define kOSBundleDebugLevelKey + * @abstract + * Deprecated (used on some releases of Mac OS X prior to 10.6 Snow Leopard). + * Value is an integer from 1-6, corresponding to the verbose levels + * of kext tools on those releases. + * On 10.6 Snow Leopard, use <code>@link OSKextEnableKextLogging + * OSKextEnableKextLogging@/link</code>. + */ +#define kOSBundleDebugLevelKey "OSBundleDebugLevel" + +/*! + * @define kOSBundleSharedExecutableIdentifierKey + * @abstract Deprecated (used on some releases of Mac OS X + * prior to 10.6 Snow Leopard). + * Value is the bundle identifier of the pseudokext + * that contains an executable shared by this kext. + */ +#define kOSBundleSharedExecutableIdentifierKey "OSBundleSharedExecutableIdentifier" + + +#if PRAGMA_MARK +/********************************************************************/ +#pragma mark Kext/OSBundle Property List Values +/********************************************************************/ +#endif + +/*! + * @group Kext Property List Values + * These constants encompass established values + * for kernel extension bundle properties. + */ + +/*! +* @define kOSKextKernelIdentifier +* @abstract +* This is the CFBundleIdentifier user for the kernel itself. +*/ +#define kOSKextKernelIdentifier "__kernel__" + +/*! +* @define kOSBundleRequiredRoot +* @abstract +* This <code>@link kOSBundleRequiredKey OSBundleRequired@/link</code> +* value indicates that the kext may be needed to mount the root filesystem +* whether starting from a local or a network volume. +*/ +#define kOSBundleRequiredRoot "Root" + +/*! +* @define kOSBundleRequiredLocalRoot +* @abstract +* This <code>@link kOSBundleRequiredKey OSBundleRequired@/link</code> +* value indicates that the kext may be needed to mount the root filesystem +* when starting from a local disk. +*/ +#define kOSBundleRequiredLocalRoot "Local-Root" + +/*! +* @define kOSBundleRequiredNetworkRoot +* @abstract +* This <code>@link kOSBundleRequiredKey OSBundleRequired@/link</code> +* value indicates that the kext may be needed to mount the root filesystem +* when starting over a network connection. +*/ +#define kOSBundleRequiredNetworkRoot "Network-Root" + +/*! +* @define kOSBundleRequiredSafeBoot +* @abstract +* This <code>@link kOSBundleRequiredKey OSBundleRequired@/link</code> +* value indicates that the kext can be loaded during a safe startup. +* This value does not normally cause the kext to be read by the booter +* or included in startup kext caches. +*/ +#define kOSBundleRequiredSafeBoot "Safe Boot" + +/*! +* @define kOSBundleRequiredConsole +* @abstract +* This <code>@link kOSBundleRequiredKey OSBundleRequired@/link</code> +* value indicates that the kext may be needed for console access +* (specifically in a single-user startup when +* <code>@link //apple_ref/doc/man/8/kextd kextd(8)@/link</code>. +* does not run) +* and should be loaded during early startup. +*/ +#define kOSBundleRequiredConsole "Console" + + +#if PRAGMA_MARK +#pragma mark - +/********************************************************************/ +#pragma mark Kext Information +/********************************************************************/ +#endif +/*! + * @group Kext Information + * Types, constants, and macros providing a kext with information + * about itself. + */ + +/*! + * @typedef OSKextLoadTag + * + * @abstract + * A unique identifier assigned to a loaded instanace of a kext. + * + * @discussion + * If a kext is unloaded and later reloaded, the new instance + * has a different load tag. + * + * A kext can get its own load tag in the <code>kmod_info_t</code> + * structure passed into its module start routine, as the + * <code>id</code> field (cast to this type). + * You can use the load tag with the functions + * <code>@link OSKextRetainKextWithLoadTag + * OSKextRetainKextWithLoadTag@/link</code> and + * <code>@link OSKextReleaseKextWithLoadTag + * OSKextReleaseKextWithLoadTag@/link</code>. + */ +typedef uint32_t OSKextLoadTag; + +/*! + * @define kOSKextInvalidLoadTag + * + * @abstract + * A load tag value that will never be used for a loaded kext; + * indicates kext not found. + */ +#define kOSKextInvalidLoadTag ((OSKextLoadTag)(-1)) + + + +__END_DECLS + +#endif /* _LIBKERN_OSKEXTLIB_H */ Index: branches/azimutz/Cleancut/i386/include/libkern/OSCacheControl.h =================================================================== --- branches/azimutz/Cleancut/i386/include/libkern/OSCacheControl.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/libkern/OSCacheControl.h (revision 885) @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2006 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 _OS_CACHE_CONTROL_H_ +#define _OS_CACHE_CONTROL_H_ + +#include <stddef.h> +#include <sys/cdefs.h> +#include <stdint.h> + +__BEGIN_DECLS + + +/* Functions performed by sys_cache_control(): */ + +/* Prepare memory for execution. This should be called + * after writing machine instructions to memory, before + * executing them. It syncs the dcache and icache. + * On IA32 processors this function is a NOP, because + * no synchronization is required. + */ +#define kCacheFunctionPrepareForExecution 1 + +/* Flush data cache(s). This ensures that cached data + * makes it all the way out to DRAM, and then removes + * copies of the data from all processor caches. + * It can be useful when dealing with cache incoherent + * devices or DMA. + */ +#define kCacheFunctionFlushDcache 2 + + +/* perform one of the above cache functions: */ +int sys_cache_control( int function, void *start, size_t len); + +/* equivalent to sys_cache_control(kCacheFunctionPrepareForExecution): */ +void sys_icache_invalidate( void *start, size_t len); + +/* equivalent to sys_cache_control(kCacheFunctionFlushDcache): */ +void sys_dcache_flush( void *start, size_t len); + + +__END_DECLS + +#endif /* _OS_CACHE_CONTROL_H_ */ Index: branches/azimutz/Cleancut/i386/include/libkern/OSTypes.h =================================================================== --- branches/azimutz/Cleancut/i386/include/libkern/OSTypes.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/libkern/OSTypes.h (revision 885) @@ -0,0 +1,131 @@ +/* + * Copyright (c) 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_OSTYPES_H +#define _OS_OSTYPES_H + +#define OSTYPES_K64_REV 2 + +typedef unsigned int UInt; +typedef signed int SInt; + +#ifndef __MACTYPES__ /* CF MacTypes.h */ +#ifndef __TYPES__ /* guess... Mac Types.h */ + +typedef unsigned char UInt8; +typedef unsigned short UInt16; +#if __LP64__ +typedef unsigned int UInt32; +#else +typedef unsigned long UInt32; +#endif +typedef unsigned long long UInt64; +#if defined(__BIG_ENDIAN__) +typedef struct UnsignedWide { + UInt32 hi; + UInt32 lo; +} UnsignedWide; +#elif defined(__LITTLE_ENDIAN__) +typedef struct UnsignedWide { + UInt32 lo; + UInt32 hi; +} UnsignedWide; +#else +#error Unknown endianess. +#endif + +typedef signed char SInt8; +typedef signed short SInt16; +#if __LP64__ +typedef signed int SInt32; +#else +typedef signed long SInt32; +#endif +typedef signed long long SInt64; +#if defined(__BIG_ENDIAN__) +typedef struct wide { + SInt32 hi; + UInt32 lo; +} wide; +#elif defined(__LITTLE_ENDIAN__) +typedef struct wide { + UInt32 lo; + SInt32 hi; +} wide; +#else +#error Unknown endianess. +#endif + +typedef SInt32 OSStatus; + +#if defined(__LP64__) && defined(KERNEL) +#ifndef ABSOLUTETIME_SCALAR_TYPE +#define ABSOLUTETIME_SCALAR_TYPE 1 +#endif +typedef UInt64 AbsoluteTime; +#else +typedef UnsignedWide AbsoluteTime; +#endif + +typedef UInt32 OptionBits; + +#if defined(KERNEL) && defined(__LP64__) +/* + * Use intrinsic boolean types for the LP64 kernel, otherwise maintain + * source and binary backward compatibility. This attempts to resolve + * the "(x == true)" vs. "(x)" conditional issue. + */ +#ifdef __cplusplus +typedef bool Boolean; +#else /* !__cplusplus */ +#if defined(__STDC_VERSION__) && ((__STDC_VERSION__ - 199901L) > 0L) +/* only use this if we are sure we are using a c99 compiler */ +typedef _Bool Boolean; +#else /* !c99 */ +/* Fall back to previous definition unless c99 */ +typedef unsigned char Boolean; +#endif /* !c99 */ +#endif /* !__cplusplus */ +#else /* !(KERNEL && __LP64__) */ +typedef unsigned char Boolean; +#endif /* !(KERNEL && __LP64__) */ + +#endif /* __TYPES__ */ +#endif /* __MACTYPES__ */ + +#if !defined(OS_INLINE) +# define OS_INLINE static inline +#endif + +#endif /* _OS_OSTYPES_H */ Index: branches/azimutz/Cleancut/i386/include/libkern/OSDebug.h =================================================================== --- branches/azimutz/Cleancut/i386/include/libkern/OSDebug.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/libkern/OSDebug.h (revision 885) @@ -0,0 +1,66 @@ +/* + * Copyright (c) 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_OSDEBBUG_H +#define _OS_OSDEBBUG_H + +#include <sys/cdefs.h> +#include <mach/mach_types.h> + +__BEGIN_DECLS + +extern int log_leaks; + +/* Use kernel_debug() to log a backtrace */ +extern void trace_backtrace(unsigned int debugid, unsigned int debugid2, unsigned long size, unsigned long data); +/* Report a message with a 4 entry backtrace - very slow */ +extern void OSReportWithBacktrace(const char *str, ...); +extern unsigned OSBacktrace(void **bt, unsigned maxAddrs); + +/*! @function OSKernelStackRemaining + @abstract Returns bytes available below the current stack frame. + @discussion Returns bytes available below the current stack frame. Safe for interrupt or thread context. + @result Approximate byte count available. */ + +vm_offset_t OSKernelStackRemaining( void ); + +__END_DECLS + +#define TRACE_MACHLEAKS(a,b,c,d) \ +do { \ + if (log_leaks) \ + trace_backtrace(a,b,c,d); \ +} while(0) + +#endif /* !_OS_OSDEBBUG_H */ Index: branches/azimutz/Cleancut/i386/include/assert.h =================================================================== --- branches/azimutz/Cleancut/i386/include/assert.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/assert.h (revision 885) @@ -0,0 +1,92 @@ +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)assert.h 8.2 (Berkeley) 1/21/94 + * $FreeBSD: src/include/assert.h,v 1.4 2002/03/23 17:24:53 imp Exp $ + */ + +#include <sys/cdefs.h> +#ifdef __cplusplus +#include <stdlib.h> +#endif /* __cplusplus */ + +/* + * Unlike other ANSI header files, <assert.h> may usefully be included + * multiple times, with and without NDEBUG defined. + */ + +#undef assert +#undef __assert + +#ifdef NDEBUG +#define assert(e) ((void)0) +#else + +#ifndef __GNUC__ + +__BEGIN_DECLS +#ifndef __cplusplus +void abort(void) __dead2; +#endif /* !__cplusplus */ +int printf(const char * __restrict, ...); +__END_DECLS + +#define assert(e) \ + ((void) ((e) ? 0 : __assert (#e, __FILE__, __LINE__))) +#define __assert(e, file, line) \ + ((void)printf ("%s:%u: failed assertion `%s'\n", file, line, e), abort()) + +#else /* __GNUC__ */ + +__BEGIN_DECLS +void __assert_rtn(const char *, const char *, int, const char *) __dead2; +void __eprintf(const char *, const char *, unsigned, const char *) __dead2; +__END_DECLS + +#define __assert(e, file, line) \ + __eprintf ("%s:%u: failed assertion `%s'\n", file, line, e) + +#if __DARWIN_UNIX03 +#define assert(e) \ + (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0) +#else /* !__DARWIN_UNIX03 */ +#define assert(e) \ + (__builtin_expect(!(e), 0) ? __assert (#e, __FILE__, __LINE__) : (void)0) +#endif /* __DARWIN_UNIX03 */ + +#endif /* __GNUC__ */ +#endif /* NDEBUG */ Index: branches/azimutz/Cleancut/i386/include/setjmp.h =================================================================== --- branches/azimutz/Cleancut/i386/include/setjmp.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/setjmp.h (revision 885) @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2000 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 _BSD_SETJMP_H +#define _BSD_SETJMP_H + +#include <machine/setjmp.h> + +#endif /* _BSD_SETJMP_H */ Index: branches/azimutz/Cleancut/i386/include/i386/signal.h =================================================================== --- branches/azimutz/Cleancut/i386/include/i386/signal.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/i386/signal.h (revision 885) @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2000-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@ + */ +/* + * Copyright (c) 1992 NeXT Computer, Inc. + * + */ + +#ifndef _I386_SIGNAL_H_ +#define _I386_SIGNAL_H_ 1 + +#include <sys/cdefs.h> + +#ifndef _ANSI_SOURCE +typedef int sig_atomic_t; + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) + +#include <sys/appleapiopts.h> + +#ifdef __APPLE_API_OBSOLETE + +/* + * Information pushed on stack when a signal is delivered. + * This is used by the kernel to restore state following + * execution of the signal handler. It is also made available + * to the handler to allow it to properly restore state if + * a non-standard exit is performed. + */ +#define __need_struct_sigcontext +#include <i386/_structs.h> + +#endif /* __APPLE_API_OBSOLETE */ +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ +#endif /* ! _ANSI_SOURCE */ + +#endif /* _I386_SIGNAL_H_ */ + Index: branches/azimutz/Cleancut/i386/include/i386/endian.h =================================================================== --- branches/azimutz/Cleancut/i386/include/i386/endian.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/i386/endian.h (revision 885) @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2000-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@ + */ +/* + * Copyright 1995 NeXT Computer, Inc. All rights reserved. + */ +/* + * Copyright (c) 1987, 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)endian.h 8.1 (Berkeley) 6/11/93 + */ + +#ifndef _I386__ENDIAN_H_ +#define _I386__ENDIAN_H_ + +#include <sys/cdefs.h> +/* + * Define _NOQUAD if the compiler does NOT support 64-bit integers. + */ +/* #define _NOQUAD */ + +/* + * Define the order of 32-bit words in 64-bit words. + */ +#define _QUAD_HIGHWORD 1 +#define _QUAD_LOWWORD 0 + +/* + * Definitions for byte order, according to byte significance from low + * address to high. + */ +#define __DARWIN_LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ +#define __DARWIN_BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ +#define __DARWIN_PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */ + +#define __DARWIN_BYTE_ORDER __DARWIN_LITTLE_ENDIAN + +#if defined(KERNEL) || (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) + +#define LITTLE_ENDIAN __DARWIN_LITTLE_ENDIAN +#define BIG_ENDIAN __DARWIN_BIG_ENDIAN +#define PDP_ENDIAN __DARWIN_PDP_ENDIAN + +#define BYTE_ORDER __DARWIN_BYTE_ORDER + +#include <sys/_endian.h> + +#endif /* defined(KERNEL) || (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) */ +#endif /* !_I386__ENDIAN_H_ */ Index: branches/azimutz/Cleancut/i386/include/i386/_param.h =================================================================== --- branches/azimutz/Cleancut/i386/include/i386/_param.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/i386/_param.h (revision 885) @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2008 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 _I386__PARAM_H_ +#define _I386__PARAM_H_ + +#include <i386/_types.h> + +/* + * Round p (pointer or byte index) up to a correctly-aligned value for all + * data types (int, long, ...). The result is unsigned int and must be + * cast to any desired pointer type. + */ +#define __DARWIN_ALIGNBYTES (sizeof(__darwin_size_t) - 1) +#define __DARWIN_ALIGN(p) ((__darwin_size_t)((char *)(__darwin_size_t)(p) + __DARWIN_ALIGNBYTES) &~ __DARWIN_ALIGNBYTES) + +#define __DARWIN_ALIGNBYTES32 (sizeof(__uint32_t) - 1) +#define __DARWIN_ALIGN32(p) ((__darwin_size_t)((char *)(__darwin_size_t)(p) + __DARWIN_ALIGNBYTES32) &~ __DARWIN_ALIGNBYTES32) + + +#endif /* _I386__PARAM_H_ */ Index: branches/azimutz/Cleancut/i386/include/i386/_limits.h =================================================================== --- branches/azimutz/Cleancut/i386/include/i386/_limits.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/i386/_limits.h (revision 885) @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2004 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 _I386__LIMITS_H_ +#define _I386__LIMITS_H_ + +#define __DARWIN_CLK_TCK 100 /* ticks per second */ + +#endif /* _I386__LIMITS_H_ */ Index: branches/azimutz/Cleancut/i386/include/i386/fasttrap_isa.h =================================================================== --- branches/azimutz/Cleancut/i386/include/i386/fasttrap_isa.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/i386/fasttrap_isa.h (revision 885) @@ -0,0 +1,116 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _FASTTRAP_ISA_H +#define _FASTTRAP_ISA_H + +/* + * #pragma ident "@(#)fasttrap_isa.h 1.6 06/09/19 SMI" + */ + +#include <sys/types.h> +#include <stdint.h> + +#ifdef __cplusplus +extern "C" { +#endif + +#define FASTTRAP_MAX_INSTR_SIZE 15 + +#define FASTTRAP_INSTR 0xcc + +#define FASTTRAP_SUNWDTRACE_SIZE 64 + +typedef uint8_t fasttrap_instr_t; + +typedef struct fasttrap_machtp { + uint8_t ftmt_instr[FASTTRAP_MAX_INSTR_SIZE]; /* orig. instr. */ + uint8_t ftmt_size; /* instruction size */ +#if __sol64 || defined(__APPLE__) + uint8_t ftmt_ripmode; /* %rip-relative handling mode */ + uint8_t ftmt_modrm; /* saved modrm byte */ +#endif + uint8_t ftmt_type; /* emulation type */ + uint8_t ftmt_code; /* branch condition */ + uint8_t ftmt_base; /* branch base */ + uint8_t ftmt_index; /* branch index */ + uint8_t ftmt_scale; /* branch scale */ + uint8_t ftmt_segment; /* segment for memory accesses */ + user_addr_t ftmt_dest; /* destination of control flow */ +} fasttrap_machtp_t; + +#define ftt_instr ftt_mtp.ftmt_instr +#if __sol64 || defined(__APPLE__) +#define ftt_ripmode ftt_mtp.ftmt_ripmode +#define ftt_modrm ftt_mtp.ftmt_modrm +#endif +#define ftt_size ftt_mtp.ftmt_size +#define ftt_type ftt_mtp.ftmt_type +#define ftt_code ftt_mtp.ftmt_code +#define ftt_base ftt_mtp.ftmt_base +#define ftt_index ftt_mtp.ftmt_index +#define ftt_scale ftt_mtp.ftmt_scale +#define ftt_segment ftt_mtp.ftmt_segment +#define ftt_dest ftt_mtp.ftmt_dest + +#define FASTTRAP_T_COMMON 0x00 /* common case -- no emulation */ +#define FASTTRAP_T_JCC 0x01 /* near and far conditional jumps */ +#define FASTTRAP_T_LOOP 0x02 /* loop instructions */ +#define FASTTRAP_T_JCXZ 0x03 /* jump if %ecx/%rcx is zero */ +#define FASTTRAP_T_JMP 0x04 /* relative jump */ +#define FASTTRAP_T_CALL 0x05 /* near call (and link) */ +#define FASTTRAP_T_RET 0x06 /* ret */ +#define FASTTRAP_T_RET16 0x07 /* ret <imm16> */ + +/* + * For performance rather than correctness. + */ +#define FASTTRAP_T_PUSHL_EBP 0x10 /* pushl %ebp (for function entry) */ +#define FASTTRAP_T_NOP 0x11 /* nop */ + +#define FASTTRAP_RIP_1 0x1 +#define FASTTRAP_RIP_2 0x2 +#define FASTTRAP_RIP_X 0x4 + +/* + * Segment values. + */ +#define FASTTRAP_SEG_NONE 0 +#define FASTTRAP_SEG_CS 1 +#define FASTTRAP_SEG_DS 2 +#define FASTTRAP_SEG_ES 3 +#define FASTTRAP_SEG_FS 4 +#define FASTTRAP_SEG_GS 5 +#define FASTTRAP_SEG_SS 6 + +#define FASTTRAP_RETURN_AFRAMES 6 +#define FASTTRAP_ENTRY_AFRAMES 5 +#define FASTTRAP_OFFSET_AFRAMES 5 + +#ifdef __cplusplus +} +#endif + +#endif /* _FASTTRAP_ISA_H */ Index: branches/azimutz/Cleancut/i386/include/i386/param.h =================================================================== --- branches/azimutz/Cleancut/i386/include/i386/param.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/i386/param.h (revision 885) @@ -0,0 +1,169 @@ +/* + * Copyright (c) 2000-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@ + */ +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)param.h 8.1 (Berkeley) 4/4/95 + */ + +/* + * Machine dependent constants for Intel 386. + */ + +#ifndef _I386_PARAM_H_ +#define _I386_PARAM_H_ + +#include <i386/_param.h> + +/* + * Round p (pointer or byte index) up to a correctly-aligned value for all + * data types (int, long, ...). The result is unsigned int and must be + * cast to any desired pointer type. + */ +#define ALIGNBYTES __DARWIN_ALIGNBYTES +#define ALIGN(p) __DARWIN_ALIGN(p) + +#define NBPG 4096 /* bytes/page */ +#define PGOFSET (NBPG-1) /* byte offset into page */ +#define PGSHIFT 12 /* LOG2(NBPG) */ + +#define DEV_BSIZE 512 +#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ +#define BLKDEV_IOSIZE 2048 +#define MAXPHYS (128 * 1024) /* max raw I/O transfer size */ + +#define CLSIZE 1 +#define CLSIZELOG2 0 + +/* + * Constants related to network buffer management. + * MCLBYTES must be no larger than CLBYTES (the software page size), and, + * on machines that exchange pages of input or output buffers with mbuf + * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple + * of the hardware page size. + */ +#define MSIZE 256 /* size of an mbuf */ +#define MCLBYTES 2048 /* large enough for ether MTU */ +#define MCLSHIFT 11 +#define MCLOFSET (MCLBYTES - 1) +#ifndef NMBCLUSTERS +#ifdef GATEWAY +#define NMBCLUSTERS ((1024 * 1024) / MCLBYTES) /* cl map size: 1MB */ +#else +#define NMBCLUSTERS ((1024 * 512) / MCLBYTES) /* cl map size: 0.5MB */ +#endif +#endif + +/* + * Some macros for units conversion + */ +/* Core clicks (NeXT_page_size bytes) to segments and vice versa */ +#define ctos(x) (x) +#define stoc(x) (x) + +/* Core clicks (4096 bytes) to disk blocks */ +#define ctod(x) ((x)<<(PGSHIFT-DEV_BSHIFT)) +#define dtoc(x) ((x)>>(PGSHIFT-DEV_BSHIFT)) +#define dtob(x) ((x)<<DEV_BSHIFT) + +/* clicks to bytes */ +#define ctob(x) ((x)<<PGSHIFT) + +/* bytes to clicks */ +#define btoc(x) (((unsigned)(x)+(NBPG-1))>>PGSHIFT) + +#ifdef __APPLE__ +#define btodb(bytes, devBlockSize) \ + ((unsigned)(bytes) / devBlockSize) +#define dbtob(db, devBlockSize) \ + ((unsigned)(db) * devBlockSize) +#else +#define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ + ((unsigned)(bytes) >> DEV_BSHIFT) +#define dbtob(db) /* calculates (db * DEV_BSIZE) */ \ + ((unsigned)(db) << DEV_BSHIFT) +#endif + +/* + * Map a ``block device block'' to a file system block. + * This should be device dependent, and will be if we + * add an entry to cdevsw/bdevsw for that purpose. + * For now though just use DEV_BSIZE. + */ +#define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE)) + +/* + * Macros to decode (and encode) processor status word. + */ +#define STATUS_WORD(rpl, ipl) (((ipl) << 8) | (rpl)) +#define USERMODE(x) (((x) & 3) == 3) +#define BASEPRI(x) (((x) & (255 << 8)) == 0) + + +#if defined(KERNEL) || defined(STANDALONE) +#define DELAY(n) delay(n) + +#else /* defined(KERNEL) || defined(STANDALONE) */ +#define DELAY(n) { register int N = (n); while (--N > 0); } +#endif /* defined(KERNEL) || defined(STANDALONE) */ + +#endif /* _I386_PARAM_H_ */ Index: branches/azimutz/Cleancut/i386/include/i386/profile.h =================================================================== --- branches/azimutz/Cleancut/i386/include/i386/profile.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/i386/profile.h (revision 885) @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2000-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@ + */ +/* + * Copyright (c) 1997, Apple Computer, Inc. All rights reserved. + * + */ + +#ifndef _BSD_I386_PROFILE_H_ +#define _BSD_I386_PROFILE_H_ + +#include <sys/appleapiopts.h> + + +#endif /* _BSD_I386_PROFILE_H_ */ Index: branches/azimutz/Cleancut/i386/include/i386/eflags.h =================================================================== --- branches/azimutz/Cleancut/i386/include/i386/eflags.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/i386/eflags.h (revision 885) @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2000-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@ + */ +/* + * @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 Software.Distribution@CS.CMU.EDU + * 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. + */ +/* + */ + +#ifndef _I386_EFLAGS_H_ +#define _I386_EFLAGS_H_ + +/* + * i386 flags register + */ + +#ifndef EFL_CF +#define EFL_CF 0x00000001 /* carry */ +#define EFL_PF 0x00000004 /* parity of low 8 bits */ +#define EFL_AF 0x00000010 /* carry out of bit 3 */ +#define EFL_ZF 0x00000040 /* zero */ +#define EFL_SF 0x00000080 /* sign */ +#define EFL_TF 0x00000100 /* trace trap */ +#define EFL_IF 0x00000200 /* interrupt enable */ +#define EFL_DF 0x00000400 /* direction */ +#define EFL_OF 0x00000800 /* overflow */ +#define EFL_IOPL 0x00003000 /* IO privilege level: */ +#define EFL_IOPL_KERNEL 0x00000000 /* kernel */ +#define EFL_IOPL_USER 0x00003000 /* user */ +#define EFL_NT 0x00004000 /* nested task */ +#define EFL_RF 0x00010000 /* resume without tracing */ +#define EFL_VM 0x00020000 /* virtual 8086 mode */ +#define EFL_AC 0x00040000 /* alignment check */ +#define EFL_VIF 0x00080000 /* virtual interrupt flag */ +#define EFL_VIP 0x00100000 /* virtual interrupt pending */ +#define EFL_ID 0x00200000 /* cpuID instruction */ +#endif + +#define EFL_CLR 0xfff88028 +#define EFL_SET 0x00000002 + +#define EFL_USER_SET (EFL_IF) +#define EFL_USER_CLEAR (EFL_IOPL|EFL_NT|EFL_RF) + +#endif /* _I386_EFLAGS_H_ */ Index: branches/azimutz/Cleancut/i386/include/i386/limits.h =================================================================== --- branches/azimutz/Cleancut/i386/include/i386/limits.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/i386/limits.h (revision 885) @@ -0,0 +1,107 @@ +/* + * Copyright (c) 1988, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)limits.h 8.3 (Berkeley) 1/4/94 + */ + +#ifndef _I386_LIMITS_H_ +#define _I386_LIMITS_H_ + +#include <sys/cdefs.h> +#include <i386/_limits.h> + +#define CHAR_BIT 8 /* number of bits in a char */ +#define MB_LEN_MAX 6 /* Allow 31 bit UTF2 */ + +#if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) +#define CLK_TCK __DARWIN_CLK_TCK /* ticks per second */ +#endif /* !_ANSI_SOURCE && (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + +/* + * According to ANSI (section 2.2.4.2), the values below must be usable by + * #if preprocessing directives. Additionally, the expression must have the + * same type as would an expression that is an object of the corresponding + * type converted according to the integral promotions. The subtraction for + * INT_MIN and LONG_MIN is so the value is not unsigned; 2147483648 is an + * unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2). + * These numbers work for pcc as well. The UINT_MAX and ULONG_MAX values + * are written as hex so that GCC will be quiet about large integer constants. + */ +#define SCHAR_MAX 127 /* min value for a signed char */ +#define SCHAR_MIN (-128) /* max value for a signed char */ + +#define UCHAR_MAX 255 /* max value for an unsigned char */ +#define CHAR_MAX 127 /* max value for a char */ +#define CHAR_MIN (-128) /* min value for a char */ + +#define USHRT_MAX 65535 /* max value for an unsigned short */ +#define SHRT_MAX 32767 /* max value for a short */ +#define SHRT_MIN (-32768) /* min value for a short */ + +#define UINT_MAX 0xffffffff /* max value for an unsigned int */ +#define INT_MAX 2147483647 /* max value for an int */ +#define INT_MIN (-2147483647-1) /* min value for an int */ + +#ifdef __LP64__ +#define ULONG_MAX 0xffffffffffffffffUL /* max unsigned long */ +#define LONG_MAX 0x7fffffffffffffffL /* max signed long */ +#define LONG_MIN (-0x7fffffffffffffffL-1) /* min signed long */ +#else /* !__LP64__ */ +#define ULONG_MAX 0xffffffffUL /* max unsigned long */ +#define LONG_MAX 2147483647L /* max signed long */ +#define LONG_MIN (-2147483647L-1) /* min signed long */ +#endif /* __LP64__ */ + +#define ULLONG_MAX 0xffffffffffffffffULL /* max unsigned long long */ +#define LLONG_MAX 0x7fffffffffffffffLL /* max signed long long */ +#define LLONG_MIN (-0x7fffffffffffffffLL-1) /* min signed long long */ + +#if !defined(_ANSI_SOURCE) +#ifdef __LP64__ +#define LONG_BIT 64 +#else /* !__LP64__ */ +#define LONG_BIT 32 +#endif /* __LP64__ */ +#define SSIZE_MAX LONG_MAX /* max value for a ssize_t */ +#define WORD_BIT 32 + +#if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || defined(_DARWIN_C_SOURCE) +#define SIZE_T_MAX ULONG_MAX /* max value for a size_t */ + +#define UQUAD_MAX ULLONG_MAX +#define QUAD_MAX LLONG_MAX +#define QUAD_MIN LLONG_MIN + +#endif /* (!_POSIX_C_SOURCE && !_XOPEN_SOURCE) || _DARWIN_C_SOURCE */ +#endif /* !_ANSI_SOURCE */ + +#endif /* _I386_LIMITS_H_ */ Index: branches/azimutz/Cleancut/i386/include/i386/user_ldt.h =================================================================== --- branches/azimutz/Cleancut/i386/include/i386/user_ldt.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/i386/user_ldt.h (revision 885) @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2000-2008 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@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * Mach Operating System + * Copyright (c) 1991 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 Software.Distribution@CS.CMU.EDU + * 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. + */ + +/* + */ + +#ifndef _I386_USER_LDT_H_ +#define _I386_USER_LDT_H_ + +/* + * User LDT management. + * + * Each task may have its own LDT. + */ + +#define LDT_AUTO_ALLOC 0xffffffff + +#include <sys/cdefs.h> + +union ldt_entry; + +__BEGIN_DECLS +int i386_get_ldt(int, union ldt_entry *, int); +int i386_set_ldt(int, const union ldt_entry *, int); +__END_DECLS + +#endif /* _I386_USER_LDT_H_ */ Index: branches/azimutz/Cleancut/i386/include/i386/setjmp.h =================================================================== --- branches/azimutz/Cleancut/i386/include/i386/setjmp.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/i386/setjmp.h (revision 885) @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2000-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@ + */ +/* Copyright (c) 1992 NeXT Computer, Inc. All rights reserved. + * + * File: setjmp.h + * + * Declaration of setjmp routines and data structures. + */ +#ifndef _BSD_I386_SETJMP_H +#define _BSD_I386_SETJMP_H + +#include <sys/cdefs.h> + +#if defined(__x86_64__) +/* + * _JBLEN is number of ints required to save the following: + * rflags, rip, rbp, rsp, rbx, r12, r13, r14, r15... these are 8 bytes each + * mxcsr, fp control word, sigmask... these are 4 bytes each + * add 16 ints for future expansion needs... + */ +#define _JBLEN ((9 * 2) + 3 + 16) +typedef int jmp_buf[_JBLEN]; +typedef int sigjmp_buf[_JBLEN + 1]; + +#else + +/* + * _JBLEN is number of ints required to save the following: + * eax, ebx, ecx, edx, edi, esi, ebp, esp, ss, eflags, eip, + * cs, de, es, fs, gs == 16 ints + * onstack, mask = 2 ints + */ + +#define _JBLEN (18) +typedef int jmp_buf[_JBLEN]; +typedef int sigjmp_buf[_JBLEN + 1]; + +#endif + +__BEGIN_DECLS +int setjmp(jmp_buf); +void longjmp(jmp_buf, int); + +#ifndef _ANSI_SOURCE +int _setjmp(jmp_buf); +void _longjmp(jmp_buf, int); +int sigsetjmp(sigjmp_buf, int); +void siglongjmp(sigjmp_buf, int); +#endif /* _ANSI_SOURCE */ + +#if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) +void longjmperror(void); +#endif /* neither ANSI nor POSIX */ +__END_DECLS +#endif /* !_BSD_I386_SETJMP_H */ Index: branches/azimutz/Cleancut/i386/include/i386/_types.h =================================================================== --- branches/azimutz/Cleancut/i386/include/i386/_types.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/i386/_types.h (revision 885) @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2000-2003 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 _BSD_I386__TYPES_H_ +#define _BSD_I386__TYPES_H_ + +/* + * This header file contains integer types. It's intended to also contain + * flotaing point and other arithmetic types, as needed, later. + */ + +#ifdef __GNUC__ +typedef __signed char __int8_t; +#else /* !__GNUC__ */ +typedef char __int8_t; +#endif /* !__GNUC__ */ +typedef unsigned char __uint8_t; +typedef short __int16_t; +typedef unsigned short __uint16_t; +typedef int __int32_t; +typedef unsigned int __uint32_t; +typedef long long __int64_t; +typedef unsigned long long __uint64_t; + +typedef long __darwin_intptr_t; +typedef unsigned int __darwin_natural_t; + +/* + * The rune type below is declared to be an ``int'' instead of the more natural + * ``unsigned long'' or ``long''. Two things are happening here. It is not + * unsigned so that EOF (-1) can be naturally assigned to it and used. Also, + * it looks like 10646 will be a 31 bit standard. This means that if your + * ints cannot hold 32 bits, you will be in trouble. The reason an int was + * chosen over a long is that the is*() and to*() routines take ints (says + * ANSI C), but they use __darwin_ct_rune_t instead of int. By changing it + * here, you lose a bit of ANSI conformance, but your programs will still + * work. + * + * NOTE: rune_t is not covered by ANSI nor other standards, and should not + * be instantiated outside of lib/libc/locale. Use wchar_t. wchar_t and + * rune_t must be the same type. Also wint_t must be no narrower than + * wchar_t, and should also be able to hold all members of the largest + * character set plus one extra value (WEOF). wint_t must be at least 16 bits. + */ + +typedef int __darwin_ct_rune_t; /* ct_rune_t */ + +/* + * mbstate_t is an opaque object to keep conversion state, during multibyte + * stream conversions. The content must not be referenced by user programs. + */ +typedef union { + char __mbstate8[128]; + long long _mbstateL; /* for alignment */ +} __mbstate_t; + +typedef __mbstate_t __darwin_mbstate_t; /* mbstate_t */ + +#if defined(__GNUC__) && defined(__PTRDIFF_TYPE__) +typedef __PTRDIFF_TYPE__ __darwin_ptrdiff_t; /* ptr1 - ptr2 */ +#else +typedef int __darwin_ptrdiff_t; /* ptr1 - ptr2 */ +#endif /* __GNUC__ */ + +#if defined(__GNUC__) && defined(__SIZE_TYPE__) +typedef __SIZE_TYPE__ __darwin_size_t; /* sizeof() */ +#else +typedef unsigned long __darwin_size_t; /* sizeof() */ +#endif + +#if (__GNUC__ > 2) +typedef __builtin_va_list __darwin_va_list; /* va_list */ +#else +typedef void * __darwin_va_list; /* va_list */ +#endif + +#if defined(__GNUC__) && defined(__WCHAR_TYPE__) +typedef __WCHAR_TYPE__ __darwin_wchar_t; /* wchar_t */ +#else +typedef __darwin_ct_rune_t __darwin_wchar_t; /* wchar_t */ +#endif + +typedef __darwin_wchar_t __darwin_rune_t; /* rune_t */ + +#if defined(__GNUC__) && defined(__WINT_TYPE__) +typedef __WINT_TYPE__ __darwin_wint_t; /* wint_t */ +#else +typedef __darwin_ct_rune_t __darwin_wint_t; /* wint_t */ +#endif + +typedef unsigned long __darwin_clock_t; /* clock() */ +typedef __uint32_t __darwin_socklen_t; /* socklen_t (duh) */ +typedef long __darwin_ssize_t; /* byte count or error */ +typedef long __darwin_time_t; /* time() */ + +#endif /* _BSD_I386__TYPES_H_ */ Index: branches/azimutz/Cleancut/i386/include/i386/vmparam.h =================================================================== --- branches/azimutz/Cleancut/i386/include/i386/vmparam.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/i386/vmparam.h (revision 885) @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2000-2006 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 _BSD_I386_VMPARAM_H_ +#define _BSD_I386_VMPARAM_H_ 1 + +#include <sys/resource.h> + +/* Rosetta dependency on this address */ +#define USRSTACK VM_USRSTACK32 + +#define USRSTACK64 VM_USRSTACK64 + + +/* + * Virtual memory related constants, all in bytes + */ +#ifndef DFLDSIZ +#define DFLDSIZ (RLIM_INFINITY) /* initial data size limit */ +#endif +#ifndef MAXDSIZ +#define MAXDSIZ (RLIM_INFINITY) /* max data size */ +#endif +#ifndef DFLSSIZ +#define DFLSSIZ (8*1024*1024) /* initial stack size limit */ +#endif +#ifndef MAXSSIZ +#define MAXSSIZ (64*1024*1024) /* max stack size */ +#endif +#ifndef DFLCSIZ +#define DFLCSIZ (0) /* initial core size limit */ +#endif +#ifndef MAXCSIZ +#define MAXCSIZ (RLIM_INFINITY) /* max core size */ +#endif /* MAXCSIZ */ + +#endif /* _BSD_I386_VMPARAM_H_ */ Index: branches/azimutz/Cleancut/i386/include/i386/types.h =================================================================== --- branches/azimutz/Cleancut/i386/include/i386/types.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/i386/types.h (revision 885) @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2000-2008 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 1995 NeXT Computer, Inc. All rights reserved. + */ +/* + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)types.h 8.3 (Berkeley) 1/5/94 + */ + +#ifndef _MACHTYPES_H_ +#define _MACHTYPES_H_ + +#include <i386/types.h> + + +#ifndef __ASSEMBLER__ +#include <i386/_types.h> +#include <sys/cdefs.h> +/* + * Basic integral types. Omit the typedef if + * not possible for a machine/compiler combination. + */ +#ifndef _INT8_T +#define _INT8_T +typedef __signed char int8_t; +#endif +typedef unsigned char u_int8_t; +#ifndef _INT16_T +#define _INT16_T +typedef short int16_t; +#endif +typedef unsigned short u_int16_t; +#ifndef _INT32_T +#define _INT32_T +typedef int int32_t; +#endif +typedef unsigned int u_int32_t; +#ifndef _INT64_T +#define _INT64_T +typedef long long int64_t; +#endif +typedef unsigned long long u_int64_t; + +#if __LP64__ +typedef int64_t register_t; +#else +typedef int32_t register_t; +#endif + +#ifndef _INTPTR_T +#define _INTPTR_T +typedef __darwin_intptr_t intptr_t; +#endif +#ifndef _UINTPTR_T +#define _UINTPTR_T +typedef unsigned long uintptr_t; +#endif + +#if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) +/* These types are used for reserving the largest possible size. */ +typedef u_int64_t user_addr_t; +typedef u_int64_t user_size_t; +typedef int64_t user_ssize_t; +typedef int64_t user_long_t; +typedef u_int64_t user_ulong_t; +typedef int64_t user_time_t; +typedef int64_t user_off_t; +#define USER_ADDR_NULL ((user_addr_t) 0) +#define CAST_USER_ADDR_T(a_ptr) ((user_addr_t)((uintptr_t)(a_ptr))) + + +#endif /* !_ANSI_SOURCE && (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + +/* This defines the size of syscall arguments after copying into the kernel: */ +typedef u_int64_t syscall_arg_t; + +#ifndef __offsetof +#define __offsetof(type, field) ((size_t)(&((type *)0)->field)) +#endif + +#endif /* __ASSEMBLER__ */ +#endif /* _MACHTYPES_H_ */ Index: branches/azimutz/Cleancut/i386/include/i386/_structs.h =================================================================== --- branches/azimutz/Cleancut/i386/include/i386/_structs.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/i386/_structs.h (revision 885) @@ -0,0 +1,105 @@ +/* + * Copyright (c) 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@ + */ + +#include <sys/appleapiopts.h> + +#ifdef __need_mcontext_t +#ifndef __need_struct_mcontext +#define __need_struct_mcontext +#endif /* __need_struct_mcontext */ +#endif /* __need_mcontext_t */ + +#if defined(__need_struct_mcontext) +#include <mach/i386/_structs.h> +#endif /* __need_struct_mcontext */ + + +#ifdef __need_struct_mcontext +#undef __need_struct_mcontext + +#ifndef _STRUCT_MCONTEXT32 +#if __DARWIN_UNIX03 +#define _STRUCT_MCONTEXT32 struct __darwin_mcontext32 +_STRUCT_MCONTEXT32 +{ + _STRUCT_X86_EXCEPTION_STATE32 __es; + _STRUCT_X86_THREAD_STATE32 __ss; + _STRUCT_X86_FLOAT_STATE32 __fs; +}; +#else /* !__DARWIN_UNIX03 */ +#define _STRUCT_MCONTEXT32 struct mcontext32 +_STRUCT_MCONTEXT32 +{ + _STRUCT_X86_EXCEPTION_STATE32 es; + _STRUCT_X86_THREAD_STATE32 ss; + _STRUCT_X86_FLOAT_STATE32 fs; +}; +#endif /* __DARWIN_UNIX03 */ +#endif /* _STRUCT_MCONTEXT32 */ + +#ifndef _STRUCT_MCONTEXT64 +#if __DARWIN_UNIX03 +#define _STRUCT_MCONTEXT64 struct __darwin_mcontext64 +_STRUCT_MCONTEXT64 +{ + _STRUCT_X86_EXCEPTION_STATE64 __es; + _STRUCT_X86_THREAD_STATE64 __ss; + _STRUCT_X86_FLOAT_STATE64 __fs; +}; +#else /* !__DARWIN_UNIX03 */ +#define _STRUCT_MCONTEXT64 struct mcontext64 +_STRUCT_MCONTEXT64 +{ + _STRUCT_X86_EXCEPTION_STATE64 es; + _STRUCT_X86_THREAD_STATE64 ss; + _STRUCT_X86_FLOAT_STATE64 fs; +}; +#endif /* __DARWIN_UNIX03 */ +#endif /* _STRUCT_MCONTEXT64 */ +#endif /* __need_struct_mcontext */ + +#ifdef __need_mcontext_t +#undef __need_mcontext_t +#ifndef _MCONTEXT_T +#define _MCONTEXT_T +#if defined(__LP64__) +typedef _STRUCT_MCONTEXT64 *mcontext_t; +#define _STRUCT_MCONTEXT _STRUCT_MCONTEXT64 +#else +typedef _STRUCT_MCONTEXT32 *mcontext_t; +#define _STRUCT_MCONTEXT _STRUCT_MCONTEXT32 +#endif +#endif /* _MCONTEXT_T */ +#endif /* __need_mcontext_t */ + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#ifndef I386_MCONTEXT_SIZE +#define I386_MCONTEXT_SIZE sizeof(struct mcontext) +#endif /* I386_MCONTEXT_SIZE */ +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + Index: branches/azimutz/Cleancut/i386/include/unwind.h =================================================================== --- branches/azimutz/Cleancut/i386/include/unwind.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/unwind.h (revision 885) @@ -0,0 +1,241 @@ +/* Exception handling and frame unwind runtime interface routines. + Copyright (C) 2001, 2003, 2004, 2006 Free Software Foundation, Inc. + + This file is part of GCC. + + GCC is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + GCC is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. + + You should have received a copy of the GNU General Public License + along with GCC; see the file COPYING. If not, write to the Free + Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. */ + +/* As a special exception, if you include this header file into source + files compiled by GCC, this header file does not by itself cause + the resulting executable to be covered by the GNU General Public + License. This exception does not however invalidate any other + reasons why the executable file might be covered by the GNU General + Public License. */ + +/* This is derived from the C++ ABI for IA-64. Where we diverge + for cross-architecture compatibility are noted with "@@@". */ + +#ifndef _UNWIND_H +#define _UNWIND_H + +#ifndef HIDE_EXPORTS +#pragma GCC visibility push(default) +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* Level 1: Base ABI */ + +/* @@@ The IA-64 ABI uses uint64 throughout. Most places this is + inefficient for 32-bit and smaller machines. */ +typedef unsigned _Unwind_Word __attribute__((__mode__(__word__))); +typedef signed _Unwind_Sword __attribute__((__mode__(__word__))); +#if defined(__ia64__) && defined(__hpux__) +typedef unsigned _Unwind_Ptr __attribute__((__mode__(__word__))); +#else +typedef unsigned _Unwind_Ptr __attribute__((__mode__(__pointer__))); +#endif +typedef unsigned _Unwind_Internal_Ptr __attribute__((__mode__(__pointer__))); + +/* @@@ The IA-64 ABI uses a 64-bit word to identify the producer and + consumer of an exception. We'll go along with this for now even on + 32-bit machines. We'll need to provide some other option for + 16-bit machines and for machines with > 8 bits per byte. */ +typedef unsigned _Unwind_Exception_Class __attribute__((__mode__(__DI__))); + +/* The unwind interface uses reason codes in several contexts to + identify the reasons for failures or other actions. */ +typedef enum +{ + _URC_NO_REASON = 0, + _URC_FOREIGN_EXCEPTION_CAUGHT = 1, + _URC_FATAL_PHASE2_ERROR = 2, + _URC_FATAL_PHASE1_ERROR = 3, + _URC_NORMAL_STOP = 4, + _URC_END_OF_STACK = 5, + _URC_HANDLER_FOUND = 6, + _URC_INSTALL_CONTEXT = 7, + _URC_CONTINUE_UNWIND = 8 +} _Unwind_Reason_Code; + + +/* The unwind interface uses a pointer to an exception header object + as its representation of an exception being thrown. In general, the + full representation of an exception object is language- and + implementation-specific, but it will be prefixed by a header + understood by the unwind interface. */ + +struct _Unwind_Exception; + +typedef void (*_Unwind_Exception_Cleanup_Fn) (_Unwind_Reason_Code, + struct _Unwind_Exception *); + +struct _Unwind_Exception +{ + _Unwind_Exception_Class exception_class; + _Unwind_Exception_Cleanup_Fn exception_cleanup; + _Unwind_Word private_1; + _Unwind_Word private_2; + + /* @@@ The IA-64 ABI says that this structure must be double-word aligned. + Taking that literally does not make much sense generically. Instead we + provide the maximum alignment required by any type for the machine. */ +} __attribute__((__aligned__)); + + +/* The ACTIONS argument to the personality routine is a bitwise OR of one + or more of the following constants. */ +typedef int _Unwind_Action; + +#define _UA_SEARCH_PHASE 1 +#define _UA_CLEANUP_PHASE 2 +#define _UA_HANDLER_FRAME 4 +#define _UA_FORCE_UNWIND 8 +#define _UA_END_OF_STACK 16 + +/* This is an opaque type used to refer to a system-specific data + structure used by the system unwinder. This context is created and + destroyed by the system, and passed to the personality routine + during unwinding. */ +struct _Unwind_Context; + +/* Raise an exception, passing along the given exception object. */ +extern _Unwind_Reason_Code _Unwind_RaiseException (struct _Unwind_Exception *); + +/* Raise an exception for forced unwinding. */ + +typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn) + (int, _Unwind_Action, _Unwind_Exception_Class, + struct _Unwind_Exception *, struct _Unwind_Context *, void *); + +extern _Unwind_Reason_Code _Unwind_ForcedUnwind (struct _Unwind_Exception *, + _Unwind_Stop_Fn, + void *); + +/* Helper to invoke the exception_cleanup routine. */ +extern void _Unwind_DeleteException (struct _Unwind_Exception *); + +/* Resume propagation of an existing exception. This is used after + e.g. executing cleanup code, and not to implement rethrowing. */ +extern void _Unwind_Resume (struct _Unwind_Exception *); + +/* @@@ Resume propagation of an FORCE_UNWIND exception, or to rethrow + a normal exception that was handled. */ +extern _Unwind_Reason_Code _Unwind_Resume_or_Rethrow (struct _Unwind_Exception *); + +/* @@@ Use unwind data to perform a stack backtrace. The trace callback + is called for every stack frame in the call chain, but no cleanup + actions are performed. */ +typedef _Unwind_Reason_Code (*_Unwind_Trace_Fn) + (struct _Unwind_Context *, void *); + +extern _Unwind_Reason_Code _Unwind_Backtrace (_Unwind_Trace_Fn, void *); + +/* These functions are used for communicating information about the unwind + context (i.e. the unwind descriptors and the user register state) between + the unwind library and the personality routine and landing pad. Only + selected registers maybe manipulated. */ + +extern _Unwind_Word _Unwind_GetGR (struct _Unwind_Context *, int); +extern void _Unwind_SetGR (struct _Unwind_Context *, int, _Unwind_Word); + +extern _Unwind_Ptr _Unwind_GetIP (struct _Unwind_Context *); +extern _Unwind_Ptr _Unwind_GetIPInfo (struct _Unwind_Context *, int *); +extern void _Unwind_SetIP (struct _Unwind_Context *, _Unwind_Ptr); + +/* @@@ Retrieve the CFA of the given context. */ +extern _Unwind_Word _Unwind_GetCFA (struct _Unwind_Context *); + +extern void *_Unwind_GetLanguageSpecificData (struct _Unwind_Context *); + +extern _Unwind_Ptr _Unwind_GetRegionStart (struct _Unwind_Context *); + + +/* The personality routine is the function in the C++ (or other language) + runtime library which serves as an interface between the system unwind + library and language-specific exception handling semantics. It is + specific to the code fragment described by an unwind info block, and + it is always referenced via the pointer in the unwind info block, and + hence it has no ABI-specified name. + + Note that this implies that two different C++ implementations can + use different names, and have different contents in the language + specific data area. Moreover, that the language specific data + area contains no version info because name of the function invoked + provides more effective versioning by detecting at link time the + lack of code to handle the different data format. */ + +typedef _Unwind_Reason_Code (*_Unwind_Personality_Fn) + (int, _Unwind_Action, _Unwind_Exception_Class, + struct _Unwind_Exception *, struct _Unwind_Context *); + +/* @@@ The following alternate entry points are for setjmp/longjmp + based unwinding. */ + +struct SjLj_Function_Context; +extern void _Unwind_SjLj_Register (struct SjLj_Function_Context *); +extern void _Unwind_SjLj_Unregister (struct SjLj_Function_Context *); + +extern _Unwind_Reason_Code _Unwind_SjLj_RaiseException + (struct _Unwind_Exception *); +extern _Unwind_Reason_Code _Unwind_SjLj_ForcedUnwind + (struct _Unwind_Exception *, _Unwind_Stop_Fn, void *); +extern void _Unwind_SjLj_Resume (struct _Unwind_Exception *); +extern _Unwind_Reason_Code _Unwind_SjLj_Resume_or_Rethrow (struct _Unwind_Exception *); + +/* @@@ The following provide access to the base addresses for text + and data-relative addressing in the LDSA. In order to stay link + compatible with the standard ABI for IA-64, we inline these. */ + +#ifdef __ia64__ +#include <stdlib.h> + +static inline _Unwind_Ptr +_Unwind_GetDataRelBase (struct _Unwind_Context *_C) +{ + /* The GP is stored in R1. */ + return _Unwind_GetGR (_C, 1); +} + +static inline _Unwind_Ptr +_Unwind_GetTextRelBase (struct _Unwind_Context *_C __attribute__ ((__unused__))) +{ + abort (); + return 0; +} + +/* @@@ Retrieve the Backing Store Pointer of the given context. */ +extern _Unwind_Word _Unwind_GetBSP (struct _Unwind_Context *); +#else +extern _Unwind_Ptr _Unwind_GetDataRelBase (struct _Unwind_Context *); +extern _Unwind_Ptr _Unwind_GetTextRelBase (struct _Unwind_Context *); +#endif + +/* @@@ Given an address, return the entry point of the function that + contains it. */ +extern void * _Unwind_FindEnclosingFunction (void *pc); + +#ifdef __cplusplus +} +#endif + +#ifndef HIDE_EXPORTS +#pragma GCC visibility pop +#endif + +#endif /* unwind.h */ Index: branches/azimutz/Cleancut/i386/include/unistd.h =================================================================== --- branches/azimutz/Cleancut/i386/include/unistd.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/unistd.h (revision 885) @@ -0,0 +1,623 @@ +/* + * Copyright (c) 2000, 2002-2006, 2008, 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@ + */ +/*- + * Copyright (c) 1998-1999 Apple Computer, Inc. All Rights Reserved + * Copyright (c) 1991, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)unistd.h 8.12 (Berkeley) 4/27/95 + * + * Copyright (c) 1998 Apple Compter, Inc. + * All Rights Reserved + */ + +/* History: + 7/14/99 EKN at Apple fixed getdirentriesattr from getdirentryattr + 3/26/98 CHW at Apple added real interface to searchfs call + 3/5/98 CHW at Apple added hfs semantic system calls headers +*/ + +#ifndef _UNISTD_H_ +#define _UNISTD_H_ + +#include <_types.h> +#include <sys/unistd.h> + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#ifndef _DEV_T +#define _DEV_T +typedef __darwin_dev_t dev_t; +#endif +#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ + +#ifndef _GID_T +#define _GID_T +typedef __darwin_gid_t gid_t; +#endif + +#ifndef _INTPTR_T +#define _INTPTR_T +typedef __darwin_intptr_t intptr_t; +#endif + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#ifndef _MODE_T +#define _MODE_T +typedef __darwin_mode_t mode_t; +#endif +#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ + +#ifndef _OFF_T +#define _OFF_T +typedef __darwin_off_t off_t; +#endif + +#ifndef _PID_T +#define _PID_T +typedef __darwin_pid_t pid_t; +#endif + +#ifndef _SIZE_T +#define _SIZE_T +/* DO NOT REMOVE THIS COMMENT: fixincludes needs to see: + * _GCC_SIZE_T */ +typedef __darwin_size_t size_t; +#endif + +#ifndef _SSIZE_T +#define _SSIZE_T +typedef __darwin_ssize_t ssize_t; +#endif + +#ifndef _UID_T +#define _UID_T +typedef __darwin_uid_t uid_t; /* user id */ +#endif + +#ifndef _USECONDS_T +#define _USECONDS_T +typedef __darwin_useconds_t useconds_t; +#endif + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#ifndef _UUID_T +#define _UUID_T +typedef __darwin_uuid_t uuid_t; +#endif /* _UUID_T */ +#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ + +#define STDIN_FILENO 0 /* standard input file descriptor */ +#define STDOUT_FILENO 1 /* standard output file descriptor */ +#define STDERR_FILENO 2 /* standard error file descriptor */ + +#ifndef NULL +#define NULL __DARWIN_NULL +#endif /* ! NULL */ + +/* Version test macros */ +/* _POSIX_VERSION and _POSIX2_VERSION from sys/unistd.h */ +#define _XOPEN_VERSION 600 /* [XSI] */ +#define _XOPEN_XCU_VERSION 4 /* Older standard */ + + +/* Please keep this list in the same order as the applicable standard */ +#define _POSIX_ADVISORY_INFO (-1) /* [ADV] */ +#define _POSIX_ASYNCHRONOUS_IO (-1) /* [AIO] */ +#define _POSIX_BARRIERS (-1) /* [BAR] */ +#define _POSIX_CHOWN_RESTRICTED 200112L +#define _POSIX_CLOCK_SELECTION (-1) /* [CS] */ +#define _POSIX_CPUTIME (-1) /* [CPT] */ +#define _POSIX_FSYNC 200112L /* [FSC] */ +#define _POSIX_IPV6 200112L +#define _POSIX_JOB_CONTROL 200112L +#define _POSIX_MAPPED_FILES 200112L /* [MF] */ +#define _POSIX_MEMLOCK (-1) /* [ML] */ +#define _POSIX_MEMLOCK_RANGE (-1) /* [MR] */ +#define _POSIX_MEMORY_PROTECTION 200112L /* [MPR] */ +#define _POSIX_MESSAGE_PASSING (-1) /* [MSG] */ +#define _POSIX_MONOTONIC_CLOCK (-1) /* [MON] */ +#define _POSIX_NO_TRUNC 200112L +#define _POSIX_PRIORITIZED_IO (-1) /* [PIO] */ +#define _POSIX_PRIORITY_SCHEDULING (-1) /* [PS] */ +#define _POSIX_RAW_SOCKETS (-1) /* [RS] */ +#define _POSIX_READER_WRITER_LOCKS 200112L /* [THR] */ +#define _POSIX_REALTIME_SIGNALS (-1) /* [RTS] */ +#define _POSIX_REGEXP 200112L +#define _POSIX_SAVED_IDS 200112L /* XXX required */ +#define _POSIX_SEMAPHORES (-1) /* [SEM] */ +#define _POSIX_SHARED_MEMORY_OBJECTS (-1) /* [SHM] */ +#define _POSIX_SHELL 200112L +#define _POSIX_SPAWN (-1) /* [SPN] */ +#define _POSIX_SPIN_LOCKS (-1) /* [SPI] */ +#define _POSIX_SPORADIC_SERVER (-1) /* [SS] */ +#define _POSIX_SYNCHRONIZED_IO (-1) /* [SIO] */ +#define _POSIX_THREAD_ATTR_STACKADDR 200112L /* [TSA] */ +#define _POSIX_THREAD_ATTR_STACKSIZE 200112L /* [TSS] */ +#define _POSIX_THREAD_CPUTIME (-1) /* [TCT] */ +#define _POSIX_THREAD_PRIO_INHERIT (-1) /* [TPI] */ +#define _POSIX_THREAD_PRIO_PROTECT (-1) /* [TPP] */ +#define _POSIX_THREAD_PRIORITY_SCHEDULING (-1) /* [TPS] */ +#define _POSIX_THREAD_PROCESS_SHARED 200112L /* [TSH] */ +#define _POSIX_THREAD_SAFE_FUNCTIONS 200112L /* [TSF] */ +#define _POSIX_THREAD_SPORADIC_SERVER (-1) /* [TSP] */ +#define _POSIX_THREADS 200112L /* [THR] */ +#define _POSIX_TIMEOUTS (-1) /* [TMO] */ +#define _POSIX_TIMERS (-1) /* [TMR] */ +#define _POSIX_TRACE (-1) /* [TRC] */ +#define _POSIX_TRACE_EVENT_FILTER (-1) /* [TEF] */ +#define _POSIX_TRACE_INHERIT (-1) /* [TRI] */ +#define _POSIX_TRACE_LOG (-1) /* [TRL] */ +#define _POSIX_TYPED_MEMORY_OBJECTS (-1) /* [TYM] */ +#ifndef _POSIX_VDISABLE +#define _POSIX_VDISABLE 0xff /* same as sys/termios.h */ +#endif /* _POSIX_VDISABLE */ + +#define _POSIX2_C_BIND 200112L +#define _POSIX2_C_DEV 200112L /* c99 command */ +#define _POSIX2_CHAR_TERM 200112L +#define _POSIX2_FORT_DEV (-1) /* fort77 command */ +#define _POSIX2_FORT_RUN 200112L +#define _POSIX2_LOCALEDEF 200112L /* localedef command */ +#define _POSIX2_PBS (-1) +#define _POSIX2_PBS_ACCOUNTING (-1) +#define _POSIX2_PBS_CHECKPOINT (-1) +#define _POSIX2_PBS_LOCATE (-1) +#define _POSIX2_PBS_MESSAGE (-1) +#define _POSIX2_PBS_TRACK (-1) +#define _POSIX2_SW_DEV 200112L +#define _POSIX2_UPE 200112L /* XXXX no fc, newgrp, tabs */ + +#define _V6_ILP32_OFF32 (-1) +#define _V6_ILP32_OFFBIG (1) +#define _V6_LP64_OFF64 (-1) +#define _V6_LPBIG_OFFBIG (-1) + +#define _XBS5_ILP32_OFF32 _V6_ILP32_OFF32 /* legacy */ +#define _XBS5_ILP32_OFFBIG _V6_ILP32_OFFBIG /* legacy */ +#define _XBS5_LP64_OFF64 _V6_LP64_OFF64 /* legacy */ +#define _XBS5_LPBIG_OFFBIG _V6_LPBIG_OFFBIG /* legacy */ + +#define _XOPEN_CRYPT (1) +#define _XOPEN_ENH_I18N (1) /* XXX required */ +#define _XOPEN_LEGACY (-1) /* no ftime gcvt, wcswcs */ +#define _XOPEN_REALTIME (-1) /* no q'ed signals, mq_* */ +#define _XOPEN_REALTIME_THREADS (-1) /* no posix_spawn, et. al. */ +#define _XOPEN_SHM (1) +#define _XOPEN_STREAMS (-1) +#define _XOPEN_UNIX (1) + + +#define F_ULOCK 0 /* unlock locked section */ +#define F_LOCK 1 /* lock a section for exclusive use */ +#define F_TLOCK 2 /* test and lock a section for exclusive use */ +#define F_TEST 3 /* test a section for locks by other procs */ + +/* configurable system variables */ +#define _SC_ARG_MAX 1 +#define _SC_CHILD_MAX 2 +#define _SC_CLK_TCK 3 +#define _SC_NGROUPS_MAX 4 +#define _SC_OPEN_MAX 5 +#define _SC_JOB_CONTROL 6 +#define _SC_SAVED_IDS 7 +#define _SC_VERSION 8 +#define _SC_BC_BASE_MAX 9 +#define _SC_BC_DIM_MAX 10 +#define _SC_BC_SCALE_MAX 11 +#define _SC_BC_STRING_MAX 12 +#define _SC_COLL_WEIGHTS_MAX 13 +#define _SC_EXPR_NEST_MAX 14 +#define _SC_LINE_MAX 15 +#define _SC_RE_DUP_MAX 16 +#define _SC_2_VERSION 17 +#define _SC_2_C_BIND 18 +#define _SC_2_C_DEV 19 +#define _SC_2_CHAR_TERM 20 +#define _SC_2_FORT_DEV 21 +#define _SC_2_FORT_RUN 22 +#define _SC_2_LOCALEDEF 23 +#define _SC_2_SW_DEV 24 +#define _SC_2_UPE 25 +#define _SC_STREAM_MAX 26 +#define _SC_TZNAME_MAX 27 +#define _SC_ASYNCHRONOUS_IO 28 +#define _SC_PAGESIZE 29 +#define _SC_MEMLOCK 30 +#define _SC_MEMLOCK_RANGE 31 +#define _SC_MEMORY_PROTECTION 32 +#define _SC_MESSAGE_PASSING 33 +#define _SC_PRIORITIZED_IO 34 +#define _SC_PRIORITY_SCHEDULING 35 +#define _SC_REALTIME_SIGNALS 36 +#define _SC_SEMAPHORES 37 +#define _SC_FSYNC 38 +#define _SC_SHARED_MEMORY_OBJECTS 39 +#define _SC_SYNCHRONIZED_IO 40 +#define _SC_TIMERS 41 +#define _SC_AIO_LISTIO_MAX 42 +#define _SC_AIO_MAX 43 +#define _SC_AIO_PRIO_DELTA_MAX 44 +#define _SC_DELAYTIMER_MAX 45 +#define _SC_MQ_OPEN_MAX 46 +#define _SC_MAPPED_FILES 47 /* swap _SC_PAGESIZE vs. BSD */ +#define _SC_RTSIG_MAX 48 +#define _SC_SEM_NSEMS_MAX 49 +#define _SC_SEM_VALUE_MAX 50 +#define _SC_SIGQUEUE_MAX 51 +#define _SC_TIMER_MAX 52 +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define _SC_NPROCESSORS_CONF 57 +#define _SC_NPROCESSORS_ONLN 58 +#endif /* !_POSIX_C_SOURCE || _DARWIN_C_SOURCE */ +#define _SC_2_PBS 59 +#define _SC_2_PBS_ACCOUNTING 60 +#define _SC_2_PBS_CHECKPOINT 61 +#define _SC_2_PBS_LOCATE 62 +#define _SC_2_PBS_MESSAGE 63 +#define _SC_2_PBS_TRACK 64 +#define _SC_ADVISORY_INFO 65 +#define _SC_BARRIERS 66 +#define _SC_CLOCK_SELECTION 67 +#define _SC_CPUTIME 68 +#define _SC_FILE_LOCKING 69 +#define _SC_GETGR_R_SIZE_MAX 70 +#define _SC_GETPW_R_SIZE_MAX 71 +#define _SC_HOST_NAME_MAX 72 +#define _SC_LOGIN_NAME_MAX 73 +#define _SC_MONOTONIC_CLOCK 74 +#define _SC_MQ_PRIO_MAX 75 +#define _SC_READER_WRITER_LOCKS 76 +#define _SC_REGEXP 77 +#define _SC_SHELL 78 +#define _SC_SPAWN 79 +#define _SC_SPIN_LOCKS 80 +#define _SC_SPORADIC_SERVER 81 +#define _SC_THREAD_ATTR_STACKADDR 82 +#define _SC_THREAD_ATTR_STACKSIZE 83 +#define _SC_THREAD_CPUTIME 84 +#define _SC_THREAD_DESTRUCTOR_ITERATIONS 85 +#define _SC_THREAD_KEYS_MAX 86 +#define _SC_THREAD_PRIO_INHERIT 87 +#define _SC_THREAD_PRIO_PROTECT 88 +#define _SC_THREAD_PRIORITY_SCHEDULING 89 +#define _SC_THREAD_PROCESS_SHARED 90 +#define _SC_THREAD_SAFE_FUNCTIONS 91 +#define _SC_THREAD_SPORADIC_SERVER 92 +#define _SC_THREAD_STACK_MIN 93 +#define _SC_THREAD_THREADS_MAX 94 +#define _SC_TIMEOUTS 95 +#define _SC_THREADS 96 +#define _SC_TRACE 97 +#define _SC_TRACE_EVENT_FILTER 98 +#define _SC_TRACE_INHERIT 99 +#define _SC_TRACE_LOG 100 +#define _SC_TTY_NAME_MAX 101 +#define _SC_TYPED_MEMORY_OBJECTS 102 +#define _SC_V6_ILP32_OFF32 103 +#define _SC_V6_ILP32_OFFBIG 104 +#define _SC_V6_LP64_OFF64 105 +#define _SC_V6_LPBIG_OFFBIG 106 +#define _SC_IPV6 118 +#define _SC_RAW_SOCKETS 119 +#define _SC_SYMLOOP_MAX 120 +#define _SC_ATEXIT_MAX 107 +#define _SC_IOV_MAX 56 +#define _SC_PAGE_SIZE _SC_PAGESIZE +#define _SC_XOPEN_CRYPT 108 +#define _SC_XOPEN_ENH_I18N 109 +#define _SC_XOPEN_LEGACY 110 +#define _SC_XOPEN_REALTIME 111 +#define _SC_XOPEN_REALTIME_THREADS 112 +#define _SC_XOPEN_SHM 113 +#define _SC_XOPEN_STREAMS 114 +#define _SC_XOPEN_UNIX 115 +#define _SC_XOPEN_VERSION 116 +#define _SC_XOPEN_XCU_VERSION 121 +#define _SC_XBS5_ILP32_OFF32 122 +#define _SC_XBS5_ILP32_OFFBIG 123 +#define _SC_XBS5_LP64_OFF64 124 +#define _SC_XBS5_LPBIG_OFFBIG 125 +#define _SC_SS_REPL_MAX 126 +#define _SC_TRACE_EVENT_NAME_MAX 127 +#define _SC_TRACE_NAME_MAX 128 +#define _SC_TRACE_SYS_MAX 129 +#define _SC_TRACE_USER_EVENT_MAX 130 +#define _SC_PASS_MAX 131 + +#ifndef _CS_PATH /* XXX temporary #ifdef'ed for <sys/unistd.h> */ +#define _CS_PATH 1 +#endif +#define _CS_POSIX_V6_ILP32_OFF32_CFLAGS 2 +#define _CS_POSIX_V6_ILP32_OFF32_LDFLAGS 3 +#define _CS_POSIX_V6_ILP32_OFF32_LIBS 4 +#define _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS 5 +#define _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS 6 +#define _CS_POSIX_V6_ILP32_OFFBIG_LIBS 7 +#define _CS_POSIX_V6_LP64_OFF64_CFLAGS 8 +#define _CS_POSIX_V6_LP64_OFF64_LDFLAGS 9 +#define _CS_POSIX_V6_LP64_OFF64_LIBS 10 +#define _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS 11 +#define _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS 12 +#define _CS_POSIX_V6_LPBIG_OFFBIG_LIBS 13 +#define _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS 14 + +/* reserved for compatibility with Issue 5 */ +#define _CS_XBS5_ILP32_OFF32_CFLAGS 20 +#define _CS_XBS5_ILP32_OFF32_LDFLAGS 21 +#define _CS_XBS5_ILP32_OFF32_LIBS 22 +#define _CS_XBS5_ILP32_OFF32_LINTFLAGS 23 +#define _CS_XBS5_ILP32_OFFBIG_CFLAGS 24 +#define _CS_XBS5_ILP32_OFFBIG_LDFLAGS 25 +#define _CS_XBS5_ILP32_OFFBIG_LIBS 26 +#define _CS_XBS5_ILP32_OFFBIG_LINTFLAGS 27 +#define _CS_XBS5_LP64_OFF64_CFLAGS 28 +#define _CS_XBS5_LP64_OFF64_LDFLAGS 29 +#define _CS_XBS5_LP64_OFF64_LIBS 30 +#define _CS_XBS5_LP64_OFF64_LINTFLAGS 31 +#define _CS_XBS5_LPBIG_OFFBIG_CFLAGS 32 +#define _CS_XBS5_LPBIG_OFFBIG_LDFLAGS 33 +#define _CS_XBS5_LPBIG_OFFBIG_LIBS 34 +#define _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS 35 + +#define _CS_DARWIN_USER_DIR 65536 +#define _CS_DARWIN_USER_TEMP_DIR 65537 +#define _CS_DARWIN_USER_CACHE_DIR 65538 + +__BEGIN_DECLS + +void _exit(int) __dead2; +int access(const char *, int); +unsigned int + alarm(unsigned int); +int chdir(const char *); +int chown(const char *, uid_t, gid_t); +int close(int) __DARWIN_ALIAS_C(close); +size_t confstr(int, char *, size_t) __DARWIN_ALIAS(confstr); +char *crypt(const char *, const char *); +char *ctermid(char *); +int dup(int); +int dup2(int, int); +#if __DARWIN_UNIX03 +void encrypt(char *, int) __DARWIN_ALIAS(encrypt); +#else /* !__DARWIN_UNIX03 */ +int encrypt(char *, int); +#endif /* __DARWIN_UNIX03 */ +int execl(const char *, const char *, ...); +int execle(const char *, const char *, ...); +int execlp(const char *, const char *, ...); +int execv(const char *, char * const *); +int execve(const char *, char * const *, char * const *); +int execvp(const char *, char * const *); +int fchown(int, uid_t, gid_t); +int fchdir(int); +pid_t fork(void); +long fpathconf(int, int); +int fsync(int) __DARWIN_ALIAS_C(fsync); +int ftruncate(int, off_t); +char *getcwd(char *, size_t); +gid_t getegid(void); +uid_t geteuid(void); +gid_t getgid(void); +#if defined(_DARWIN_UNLIMITED_GETGROUPS) || defined(_DARWIN_C_SOURCE) +int getgroups(int, gid_t []) __DARWIN_EXTSN(getgroups); +#else /* !_DARWIN_UNLIMITED_GETGROUPS && !_DARWIN_C_SOURCE */ +int getgroups(int, gid_t []); +#endif /* _DARWIN_UNLIMITED_GETGROUPS || _DARWIN_C_SOURCE */ +long gethostid(void); +int gethostname(char *, size_t); +char *getlogin(void); +int getlogin_r(char *, size_t); +int getopt(int, char * const [], const char *) __DARWIN_ALIAS(getopt); +pid_t getpgid(pid_t); +pid_t getpgrp(void); +pid_t getpid(void); +pid_t getppid(void); +pid_t getsid(pid_t); +uid_t getuid(void); +char *getwd(char *); /* obsoleted by getcwd() */ +int isatty(int); +int lchown(const char *, uid_t, gid_t) __DARWIN_ALIAS(lchown); +int link(const char *, const char *); +int lockf(int, int, off_t) __DARWIN_ALIAS_C(lockf); +off_t lseek(int, off_t, int); +int nice(int) __DARWIN_ALIAS(nice); +long pathconf(const char *, int); +int pause(void) __DARWIN_ALIAS_C(pause); +int pipe(int [2]); +ssize_t pread(int, void *, size_t, off_t) __DARWIN_ALIAS_C(pread); +ssize_t pwrite(int, const void *, size_t, off_t) __DARWIN_ALIAS_C(pwrite); +ssize_t read(int, void *, size_t) __DARWIN_ALIAS_C(read); +ssize_t readlink(const char * __restrict, char * __restrict, size_t); +int rmdir(const char *); +int setegid(gid_t); +int seteuid(uid_t); +int setgid(gid_t); +int setpgid(pid_t, pid_t); +#if __DARWIN_UNIX03 +pid_t setpgrp(void) __DARWIN_ALIAS(setpgrp); +#else /* !__DARWIN_UNIX03 */ +int setpgrp(pid_t pid, pid_t pgrp); /* obsoleted by setpgid() */ +#endif /* __DARWIN_UNIX03 */ +int setregid(gid_t, gid_t) __DARWIN_ALIAS(setregid); +int setreuid(uid_t, uid_t) __DARWIN_ALIAS(setreuid); +pid_t setsid(void); +int setuid(uid_t); +unsigned int + sleep(unsigned int) __DARWIN_ALIAS_C(sleep); +void swab(const void * __restrict, void * __restrict, ssize_t); +int symlink(const char *, const char *); +void sync(void); +long sysconf(int); +pid_t tcgetpgrp(int); +int tcsetpgrp(int, pid_t); +int truncate(const char *, off_t); +char *ttyname(int); +#if __DARWIN_UNIX03 +int ttyname_r(int, char *, size_t) __DARWIN_ALIAS(ttyname_r); +#else /* !__DARWIN_UNIX03 */ +char *ttyname_r(int, char *, size_t); +#endif /* __DARWIN_UNIX03 */ +useconds_t + ualarm(useconds_t, useconds_t); +int unlink(const char *); +int usleep(useconds_t) __DARWIN_ALIAS_C(usleep); +pid_t vfork(void); +ssize_t write(int, const void *, size_t) __DARWIN_ALIAS_C(write); + +extern char *optarg; /* getopt(3) external variables */ +extern int optind, opterr, optopt; + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#include <sys/select.h> + +void _Exit(int) __dead2; +int accessx_np(const struct accessx_descriptor *, size_t, int *, uid_t); +int acct(const char *); +int add_profil(char *, size_t, unsigned long, unsigned int); +void *brk(const void *); +int chroot(const char *); +void endusershell(void); +int execvP(const char *, const char *, char * const *); +char *fflagstostr(unsigned long); +int getdtablesize(void); +int getdomainname(char *, int); +int getgrouplist(const char *, int, int *, int *); +int gethostuuid(uuid_t, const struct timespec *); +mode_t getmode(const void *, mode_t); +int getpagesize(void) __pure2; +char *getpass(const char *); +int getpeereid(int, uid_t *, gid_t *); +int getpgid(pid_t _pid); +int getsgroups_np(int *, uuid_t); +int getsid(pid_t _pid); +char *getusershell(void); +int getwgroups_np(int *, uuid_t); +int initgroups(const char *, int); +int iruserok(unsigned long, int, const char *, const char *); +int iruserok_sa(const void *, int, int, const char *, const char *); +int issetugid(void); +char *mkdtemp(char *); +int mknod(const char *, mode_t, dev_t); +int mkstemp(char *); +int mkstemps(char *, int); +char *mktemp(char *); +int nfssvc(int, void *); +int profil(char *, size_t, unsigned long, unsigned int); +int pthread_setugid_np(uid_t, gid_t); +int pthread_getugid_np( uid_t *, gid_t *); +int rcmd(char **, int, const char *, const char *, const char *, int *); +int rcmd_af(char **, int, const char *, const char *, const char *, int *, + int); +int reboot(int); +int revoke(const char *); +int rresvport(int *); +int rresvport_af(int *, int); +int ruserok(const char *, int, const char *, const char *); +void *sbrk(int); +int setdomainname(const char *, int); +int setgroups(int, const gid_t *); +void sethostid(long); +int sethostname(const char *, int); +#if __DARWIN_UNIX03 +void setkey(const char *) __DARWIN_ALIAS(setkey); +#else /* !__DARWIN_UNIX03 */ +int setkey(const char *); +#endif /* __DARWIN_UNIX03 */ +int setlogin(const char *); +void *setmode(const char *) __DARWIN_ALIAS(setmode); +int setrgid(gid_t); +int setruid(uid_t); +int setsgroups_np(int, const uuid_t); +void setusershell(void); +int setwgroups_np(int, const uuid_t); +int strtofflags(char **, unsigned long *, unsigned long *); +int swapon(const char *); +int syscall(int, ...); +int ttyslot(void); +int undelete(const char *); +int unwhiteout(const char *); +void *valloc(size_t); + +extern char *suboptarg; /* getsubopt(3) external variable */ +int getsubopt(char **, char * const *, char **); + +/* HFS & HFS Plus semantics system calls go here */ +#ifdef __LP64__ +int fgetattrlist(int,void*,void*,size_t,unsigned int); +int fsetattrlist(int,void*,void*,size_t,unsigned int); +int getattrlist(const char*,void*,void*,size_t,unsigned int) __DARWIN_ALIAS(getattrlist); +int setattrlist(const char*,void*,void*,size_t,unsigned int) __DARWIN_ALIAS(setattrlist); +int exchangedata(const char*,const char*,unsigned int); +int getdirentriesattr(int,void*,void*,size_t,unsigned int*,unsigned int*,unsigned int*,unsigned int); + +#else /* __LP64__ */ +int fgetattrlist(int,void*,void*,size_t,unsigned long); +int fsetattrlist(int,void*,void*,size_t,unsigned long); +int getattrlist(const char*,void*,void*,size_t,unsigned long) __DARWIN_ALIAS(getattrlist); +int setattrlist(const char*,void*,void*,size_t,unsigned long) __DARWIN_ALIAS(setattrlist); +int exchangedata(const char*,const char*,unsigned long); +int getdirentriesattr(int,void*,void*,size_t,unsigned long*,unsigned long*,unsigned long*,unsigned long); + +#endif /* __LP64__ */ + +struct fssearchblock; +struct searchstate; + +int searchfs(const char *, struct fssearchblock *, unsigned long *, unsigned int, unsigned int, struct searchstate *); +int fsctl(const char *,unsigned long,void*,unsigned int); +int ffsctl(int,unsigned long,void*,unsigned int); + +extern int optreset; + +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ +__END_DECLS + +#endif /* !_UNISTD_H_ */ Index: branches/azimutz/Cleancut/i386/include/netinet6/ip6_mroute.h =================================================================== --- branches/azimutz/Cleancut/i386/include/netinet6/ip6_mroute.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/netinet6/ip6_mroute.h (revision 885) @@ -0,0 +1,209 @@ +/* + * Copyright (c) 2008 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@ + */ + +/* $FreeBSD: src/sys/netinet6/ip6_mroute.h,v 1.2.2.2 2001/07/03 11:01:53 ume Exp $ */ +/* $KAME: ip6_mroute.h,v 1.17 2001/02/10 02:05:52 itojun Exp $ */ + +/* + * Copyright (C) 1998 WIDE Project. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* BSDI ip_mroute.h,v 2.5 1996/10/11 16:01:48 pjd Exp */ + +/* + * Definitions for IP multicast forwarding. + * + * Written by David Waitzman, BBN Labs, August 1988. + * Modified by Steve Deering, Stanford, February 1989. + * Modified by Ajit Thyagarajan, PARC, August 1993. + * Modified by Ajit Thyagarajan, PARC, August 1994. + * Modified by Ahmed Helmy, USC, September 1996. + * + * MROUTING Revision: 1.2 + */ + +#ifndef _NETINET6_IP6_MROUTE_H_ +#define _NETINET6_IP6_MROUTE_H_ +#include <sys/appleapiopts.h> + +/* + * Multicast Routing set/getsockopt commands. + */ +#define MRT6_DONE 101 /* shut down forwarder */ +#define MRT6_ADD_MIF 102 /* add multicast interface */ +#define MRT6_DEL_MIF 103 /* delete multicast interface */ +#define MRT6_ADD_MFC 104 /* insert forwarding cache entry */ +#define MRT6_DEL_MFC 105 /* delete forwarding cache entry */ +#define MRT6_PIM 107 /* enable pim code */ +#define MRT6_INIT 108 /* initialize forwarder (mrt6msg) */ + +#ifdef __APPLE__ +#define GET_TIME(t) getmicrotime(&t) +#endif + +/* + * Types and macros for handling bitmaps with one bit per multicast interface. + */ +typedef u_short mifi_t; /* type of a mif index */ +#define MAXMIFS 64 + +#ifndef IF_SETSIZE +#define IF_SETSIZE 256 +#endif + +typedef u_int32_t if_mask; +#define NIFBITS (sizeof(if_mask) * NBBY) /* bits per mask */ + +#ifndef howmany +#define howmany(x, y) ((((x) % (y)) == 0) ? ((x) / (y)) : (((x) / (y)) + 1)) +#endif + +typedef struct if_set { + if_mask ifs_bits[howmany(IF_SETSIZE, NIFBITS)]; +} if_set; + +#define IF_SET(n, p) ((p)->ifs_bits[(n)/NIFBITS] |= (1 << ((n) % NIFBITS))) +#define IF_CLR(n, p) ((p)->ifs_bits[(n)/NIFBITS] &= ~(1 << ((n) % NIFBITS))) +#define IF_ISSET(n, p) ((p)->ifs_bits[(n)/NIFBITS] & (1 << ((n) % NIFBITS))) +#define IF_COPY(f, t) bcopy(f, t, sizeof(*(f))) +#define IF_ZERO(p) bzero(p, sizeof(*(p))) + +/* + * Argument structure for MRT6_ADD_IF. + */ +struct mif6ctl { + mifi_t mif6c_mifi; /* the index of the mif to be added */ + u_char mif6c_flags; /* MIFF_ flags defined below */ + u_short mif6c_pifi; /* the index of the physical IF */ +#if notyet + u_int mif6c_rate_limit; /* max rate */ +#endif +}; + +#define MIFF_REGISTER 0x1 /* mif represents a register end-point */ + +/* + * Argument structure for MRT6_ADD_MFC and MRT6_DEL_MFC + */ +struct mf6cctl { + struct sockaddr_in6 mf6cc_origin; /* IPv6 origin of mcasts */ + struct sockaddr_in6 mf6cc_mcastgrp; /* multicast group associated */ + mifi_t mf6cc_parent; /* incoming ifindex */ + struct if_set mf6cc_ifset; /* set of forwarding ifs */ +}; + +/* + * The kernel's multicast routing statistics. + */ +struct mrt6stat { + u_quad_t mrt6s_mfc_lookups; /* # forw. cache hash table hits */ + u_quad_t mrt6s_mfc_misses; /* # forw. cache hash table misses */ + u_quad_t mrt6s_upcalls; /* # calls to mrouted */ + u_quad_t mrt6s_no_route; /* no route for packet's origin */ + u_quad_t mrt6s_bad_tunnel; /* malformed tunnel options */ + u_quad_t mrt6s_cant_tunnel; /* no room for tunnel options */ + u_quad_t mrt6s_wrong_if; /* arrived on wrong interface */ + u_quad_t mrt6s_upq_ovflw; /* upcall Q overflow */ + u_quad_t mrt6s_cache_cleanups; /* # entries with no upcalls */ + u_quad_t mrt6s_drop_sel; /* pkts dropped selectively */ + u_quad_t mrt6s_q_overflow; /* pkts dropped - Q overflow */ + u_quad_t mrt6s_pkt2large; /* pkts dropped - size > BKT SIZE */ + u_quad_t mrt6s_upq_sockfull; /* upcalls dropped - socket full */ +}; + + +/* + * Structure used to communicate from kernel to multicast router. + * We'll overlay the structure onto an MLD header (not an IPv6 header + * like igmpmsg{} used for IPv4 implementation). This is because this + * structure will be passed via an IPv6 raw socket, on which an application + * will only receive the payload i.e. the data after the IPv6 header and all + * the extension headers. (see Section 3 of draft-ietf-ipngwg-2292bis-01) + */ +struct mrt6msg { +#define MRT6MSG_NOCACHE 1 +#define MRT6MSG_WRONGMIF 2 +#define MRT6MSG_WHOLEPKT 3 /* used for user level encap*/ + u_char im6_mbz; /* must be zero */ + u_char im6_msgtype; /* what type of message */ + u_int16_t im6_mif; /* mif rec'd on */ + u_int32_t im6_pad; /* padding for 64bit arch */ + struct in6_addr im6_src, im6_dst; +}; + +/* + * Argument structure used by multicast routing daemon to get src-grp + * packet counts + */ +struct sioc_sg_req6 { + struct sockaddr_in6 src; + struct sockaddr_in6 grp; + u_quad_t pktcnt; + u_quad_t bytecnt; + u_quad_t wrong_if; +}; + +/* + * Argument structure used by mrouted to get mif pkt counts + */ +struct sioc_mif_req6 { + mifi_t mifi; /* mif number */ + u_quad_t icount; /* Input packet count on mif */ + u_quad_t ocount; /* Output packet count on mif */ + u_quad_t ibytes; /* Input byte count on mif */ + u_quad_t obytes; /* Output byte count on mif */ +}; + + + +#endif /* !_NETINET6_IP6_MROUTE_H_ */ Index: branches/azimutz/Cleancut/i386/include/netinet6/ip6_fw.h =================================================================== --- branches/azimutz/Cleancut/i386/include/netinet6/ip6_fw.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/netinet6/ip6_fw.h (revision 885) @@ -0,0 +1,255 @@ +/* + * Copyright (c) 2008 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) 1993 Daniel Boulet + * Copyright (c) 1994 Ugen J.S.Antsilevich + * + * Redistribution and use in source forms, with and without modification, + * are permitted provided that this entire comment appears intact. + * + * Redistribution in binary form may occur without any restrictions. + * Obviously, it would be nice if you gave credit where credit is due + * but requiring it would be too onerous. + * + * This software is provided ``AS IS'' without any warranties of any kind. + * + */ + +#ifndef _IP6_FW_H +#define _IP6_FW_H + +#include <sys/appleapiopts.h> + +/* + * Define IPv6 Firewall event subclass, and associated events. + */ + +/*! + @defined KEV_IP6FW_SUBCLASS + @discussion The kernel event subclass for IPv6 Firewall. +*/ +#define KEV_IP6FW_SUBCLASS 2 + +/*! + @defined KEV_IP6FW_ADD + @discussion The event code indicating a rule has been added. +*/ +#define KEV_IP6FW_ADD 1 + +/*! + @defined KEV_IP6FW_DEL + @discussion The event code indicating a rule has been removed. +*/ +#define KEV_IP6FW_DEL 2 + +/*! + @defined KEV_IP6FW_FLUSH + @discussion The event code indicating the rule set has been flushed. +*/ +#define KEV_IP6FW_FLUSH 3 + +/*! + @defined KEV_IP6FW_FLUSH + @discussion The event code indicating the enable flag has been changed +*/ +#define KEV_IP6FW_ENABLE 4 + + +#include <net/if.h> + +#define IPV6_FW_CURRENT_API_VERSION 20 /* Version of this API */ + + +/* + * This union structure identifies an interface, either explicitly + * by name or implicitly by IP address. The flags IP_FW_F_IIFNAME + * and IP_FW_F_OIFNAME say how to interpret this structure. An + * interface unit number of -1 matches any unit number, while an + * IP address of 0.0.0.0 indicates matches any interface. + * + * The receive and transmit interfaces are only compared against the + * the packet if the corresponding bit (IP_FW_F_IIFACE or IP_FW_F_OIFACE) + * is set. Note some packets lack a receive or transmit interface + * (in which case the missing "interface" never matches). + */ + +union ip6_fw_if { + struct in6_addr fu_via_ip6; /* Specified by IPv6 address */ + struct { /* Specified by interface name */ +#define IP6FW_IFNLEN IFNAMSIZ + char name[IP6FW_IFNLEN]; + short unit; /* -1 means match any unit */ + } fu_via_if; +}; + +/* + * Format of an IP firewall descriptor + * + * fw_src, fw_dst, fw_smsk, fw_dmsk are always stored in network byte order. + * fw_flg and fw_n*p are stored in host byte order (of course). + * Port numbers are stored in HOST byte order. + * Warning: setsockopt() will fail if sizeof(struct ip_fw) > MLEN (108) + */ + + +struct ip6_fw { + u_int32_t version; /* Version of this structure. Should always be */ + /* set to IP6_FW_CURRENT_API_VERSION by clients. */ + void *context; /* Context that is usable by user processes to */ + /* identify this rule. */ + u_int32_t fw_pcnt,fw_bcnt; /* Packet and byte counters */ + struct in6_addr fw_src, fw_dst; /* Source and destination IPv6 addr */ + struct in6_addr fw_smsk, fw_dmsk; /* Mask for src and dest IPv6 addr */ + u_short fw_number; /* Rule number */ + u_short fw_flg; /* Flags word */ +#define IPV6_FW_MAX_PORTS 10 /* A reasonable maximum */ + u_int fw_ipflg; /* IP flags word */ + u_short fw_pts[IPV6_FW_MAX_PORTS]; /* Array of port numbers to match */ + u_char fw_ip6opt,fw_ip6nopt; /* IPv6 options set/unset */ + u_char fw_tcpf,fw_tcpnf; /* TCP flags set/unset */ +#define IPV6_FW_ICMPTYPES_DIM (256 / (sizeof(unsigned) * 8)) + unsigned fw_icmp6types[IPV6_FW_ICMPTYPES_DIM]; /* ICMP types bitmap */ + long timestamp; /* timestamp (tv_sec) of last match */ + union ip6_fw_if fw_in_if, fw_out_if;/* Incoming and outgoing interfaces */ + union { + u_short fu_divert_port; /* Divert/tee port (options IP6DIVERT) */ + u_short fu_skipto_rule; /* SKIPTO command rule number */ + u_short fu_reject_code; /* REJECT response code */ + } fw_un; + u_char fw_prot; /* IPv6 protocol */ + u_char fw_nports; /* N'of src ports and # of dst ports */ + /* in ports array (dst ports follow */ + /* src ports; max of 10 ports in all; */ + /* count of 0 means match all ports) */ +}; + + +#define IPV6_FW_GETNSRCP(rule) ((rule)->fw_nports & 0x0f) +#define IPV6_FW_SETNSRCP(rule, n) do { \ + (rule)->fw_nports &= ~0x0f; \ + (rule)->fw_nports |= (n); \ + } while (0) +#define IPV6_FW_GETNDSTP(rule) ((rule)->fw_nports >> 4) +#define IPV6_FW_SETNDSTP(rule, n) do { \ + (rule)->fw_nports &= ~0xf0; \ + (rule)->fw_nports |= (n) << 4;\ + } while (0) + +#define fw_divert_port fw_un.fu_divert_port +#define fw_skipto_rule fw_un.fu_skipto_rule +#define fw_reject_code fw_un.fu_reject_code + +struct ip6_fw_chain { + LIST_ENTRY(ip6_fw_chain) chain; + struct ip6_fw *rule; +}; + +/* + * Values for "flags" field . + */ +#define IPV6_FW_F_IN 0x0001 /* Check inbound packets */ +#define IPV6_FW_F_OUT 0x0002 /* Check outbound packets */ +#define IPV6_FW_F_IIFACE 0x0004 /* Apply inbound interface test */ +#define IPV6_FW_F_OIFACE 0x0008 /* Apply outbound interface test */ + +#define IPV6_FW_F_COMMAND 0x0070 /* Mask for type of chain entry: */ +#define IPV6_FW_F_DENY 0x0000 /* This is a deny rule */ +#define IPV6_FW_F_REJECT 0x0010 /* Deny and send a response packet */ +#define IPV6_FW_F_ACCEPT 0x0020 /* This is an accept rule */ +#define IPV6_FW_F_COUNT 0x0030 /* This is a count rule */ +#define IPV6_FW_F_DIVERT 0x0040 /* This is a divert rule */ +#define IPV6_FW_F_TEE 0x0050 /* This is a tee rule */ +#define IPV6_FW_F_SKIPTO 0x0060 /* This is a skipto rule */ + +#define IPV6_FW_F_PRN 0x0080 /* Print if this rule matches */ + +#define IPV6_FW_F_SRNG 0x0100 /* The first two src ports are a min * + * and max range (stored in host byte * + * order). */ + +#define IPV6_FW_F_DRNG 0x0200 /* The first two dst ports are a min * + * and max range (stored in host byte * + * order). */ + +#define IPV6_FW_F_IIFNAME 0x0400 /* In interface by name/unit (not IP) */ +#define IPV6_FW_F_OIFNAME 0x0800 /* Out interface by name/unit (not IP) */ + +#define IPV6_FW_F_INVSRC 0x1000 /* Invert sense of src check */ +#define IPV6_FW_F_INVDST 0x2000 /* Invert sense of dst check */ + +#define IPV6_FW_F_FRAG 0x4000 /* Fragment */ + +#define IPV6_FW_F_ICMPBIT 0x8000 /* ICMP type bitmap is valid */ + +#define IPV6_FW_F_MASK 0xFFFF /* All possible flag bits mask */ + +/* + * Flags for the 'fw_ipflg' field, for comparing values of ip and its protocols. */ +#define IPV6_FW_IF_TCPEST 0x00000020 /* established TCP connection */ +#define IPV6_FW_IF_TCPMSK 0x00000020 /* mask of all TCP values */ + +/* + * For backwards compatibility with rules specifying "via iface" but + * not restricted to only "in" or "out" packets, we define this combination + * of bits to represent this configuration. + */ + +#define IF6_FW_F_VIAHACK (IPV6_FW_F_IN|IPV6_FW_F_OUT|IPV6_FW_F_IIFACE|IPV6_FW_F_OIFACE) + +/* + * Definitions for REJECT response codes. + * Values less than 256 correspond to ICMP unreachable codes. + */ +#define IPV6_FW_REJECT_RST 0x0100 /* TCP packets: send RST */ + +/* + * Definitions for IPv6 option names. + */ +#define IPV6_FW_IP6OPT_HOPOPT 0x01 +#define IPV6_FW_IP6OPT_ROUTE 0x02 +#define IPV6_FW_IP6OPT_FRAG 0x04 +#define IPV6_FW_IP6OPT_ESP 0x08 +#define IPV6_FW_IP6OPT_AH 0x10 +#define IPV6_FW_IP6OPT_NONXT 0x20 +#define IPV6_FW_IP6OPT_OPTS 0x40 + +/* + * Definitions for TCP flags. + */ +#define IPV6_FW_TCPF_FIN TH_FIN +#define IPV6_FW_TCPF_SYN TH_SYN +#define IPV6_FW_TCPF_RST TH_RST +#define IPV6_FW_TCPF_PSH TH_PUSH +#define IPV6_FW_TCPF_ACK TH_ACK +#define IPV6_FW_TCPF_URG TH_URG + +/* + * Main firewall chains definitions and global var's definitions. + */ + +#endif /* _IP6_FW_H */ Index: branches/azimutz/Cleancut/i386/include/netinet6/pim6.h =================================================================== --- branches/azimutz/Cleancut/i386/include/netinet6/pim6.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/netinet6/pim6.h (revision 885) @@ -0,0 +1,70 @@ +/* $FreeBSD: src/sys/netinet6/pim6.h,v 1.1.2.1 2000/07/15 07:14:36 kris Exp $ */ +/* $KAME: pim6.h,v 1.3 2000/03/25 07:23:58 sumikawa Exp $ */ + +/* + * Copyright (C) 1998 WIDE Project. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ +/* + * Protocol Independent Multicast (PIM) definitions + * + * Written by Ahmed Helmy, SGI, July 1996 + * + * MULTICAST + */ +#include <sys/appleapiopts.h> + +/* + * PIM packet header + */ +#define PIM_VERSION 2 +struct pim { +#if defined(BYTE_ORDER) && (BYTE_ORDER == LITTLE_ENDIAN) + u_char pim_type:4, /* the PIM message type, currently they are: + * Hello, Register, Register-Stop, Join/Prune, + * Bootstrap, Assert, Graft (PIM-DM only), + * Graft-Ack (PIM-DM only), C-RP-Adv + */ + pim_ver:4; /* PIM version number; 2 for PIMv2 */ +#else + u_char pim_ver:4, /* PIM version */ + pim_type:4; /* PIM type */ +#endif + u_char pim_rsv; /* Reserved */ + u_short pim_cksum; /* IP style check sum */ +}; + +#define PIM_MINLEN 8 /* The header min. length is 8 */ +#define PIM6_REG_MINLEN (PIM_MINLEN+40) /* Register message + inner IP6 header */ + +/* + * Message types + */ +#define PIM_REGISTER 1 /* PIM Register type is 1 */ + +/* second bit in reg_head is the null bit */ +#define PIM_NULL_REGISTER 0x40000000 Index: branches/azimutz/Cleancut/i386/include/netinet6/in6.h =================================================================== --- branches/azimutz/Cleancut/i386/include/netinet6/in6.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/netinet6/in6.h (revision 885) @@ -0,0 +1,513 @@ +/* + * Copyright (c) 2008 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@ + */ + +/* $FreeBSD: src/sys/netinet6/in6.h,v 1.7.2.4 2001/07/04 09:45:23 ume Exp $ */ +/* $KAME: in6.h,v 1.89 2001/05/27 13:28:35 itojun Exp $ */ + +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * Copyright (c) 1982, 1986, 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)in.h 8.3 (Berkeley) 1/3/94 + */ + +#ifndef __KAME_NETINET_IN_H_INCLUDED_ +#error "do not include netinet6/in6.h directly, include netinet/in.h. see RFC2553" +#endif + +#ifndef _NETINET6_IN6_H_ +#define _NETINET6_IN6_H_ +#include <sys/appleapiopts.h> +#include <sys/_types.h> + + +#ifndef _SA_FAMILY_T +#define _SA_FAMILY_T +typedef __uint8_t sa_family_t; +#endif + +/* + * Identification of the network protocol stack + * for *BSD-current/release: http://www.kame.net/dev/cvsweb.cgi/kame/COVERAGE + * has the table of implementation/integration differences. + */ +#define __KAME__ +#define __KAME_VERSION "20010528/apple-darwin" + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +/* + * Local port number conventions: + * + * Ports < IPPORT_RESERVED are reserved for privileged processes (e.g. root), + * unless a kernel is compiled with IPNOPRIVPORTS defined. + * + * When a user does a bind(2) or connect(2) with a port number of zero, + * a non-conflicting local port address is chosen. + * + * The default range is IPPORT_ANONMIN to IPPORT_ANONMAX, although + * that is settable by sysctl(3); net.inet.ip.anonportmin and + * net.inet.ip.anonportmax respectively. + * + * A user may set the IPPROTO_IP option IP_PORTRANGE to change this + * default assignment range. + * + * The value IP_PORTRANGE_DEFAULT causes the default behavior. + * + * The value IP_PORTRANGE_HIGH is the same as IP_PORTRANGE_DEFAULT, + * and exists only for FreeBSD compatibility purposes. + * + * The value IP_PORTRANGE_LOW changes the range to the "low" are + * that is (by convention) restricted to privileged processes. + * This convention is based on "vouchsafe" principles only. + * It is only secure if you trust the remote host to restrict these ports. + * The range is IPPORT_RESERVEDMIN to IPPORT_RESERVEDMAX. + */ + +#define IPV6PORT_RESERVED 1024 +#define IPV6PORT_ANONMIN 49152 +#define IPV6PORT_ANONMAX 65535 +#define IPV6PORT_RESERVEDMIN 600 +#define IPV6PORT_RESERVEDMAX (IPV6PORT_RESERVED-1) +#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ + +/* + * IPv6 address + */ +struct in6_addr { + union { + __uint8_t __u6_addr8[16]; + __uint16_t __u6_addr16[8]; + __uint32_t __u6_addr32[4]; + } __u6_addr; /* 128-bit IP6 address */ +}; + +#define s6_addr __u6_addr.__u6_addr8 + +#define INET6_ADDRSTRLEN 46 + +/* + * Socket address for IPv6 + */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define SIN6_LEN +#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ +struct sockaddr_in6 { + __uint8_t sin6_len; /* length of this struct(sa_family_t)*/ + sa_family_t sin6_family; /* AF_INET6 (sa_family_t) */ + in_port_t sin6_port; /* Transport layer port # (in_port_t)*/ + __uint32_t sin6_flowinfo; /* IP6 flow information */ + struct in6_addr sin6_addr; /* IP6 address */ + __uint32_t sin6_scope_id; /* scope zone index */ +}; + + + + +/* + * Definition of some useful macros to handle IP6 addresses + */ +#define IN6ADDR_ANY_INIT \ + {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}} +#define IN6ADDR_LOOPBACK_INIT \ + {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}} +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define IN6ADDR_NODELOCAL_ALLNODES_INIT \ + {{{ 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}} +#define IN6ADDR_LINKLOCAL_ALLNODES_INIT \ + {{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}} +#define IN6ADDR_LINKLOCAL_ALLROUTERS_INIT \ + {{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }}} +#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ + +extern const struct in6_addr in6addr_any; +extern const struct in6_addr in6addr_loopback; +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +extern const struct in6_addr in6addr_nodelocal_allnodes; +extern const struct in6_addr in6addr_linklocal_allnodes; +extern const struct in6_addr in6addr_linklocal_allrouters; +#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ + +/* + * Equality + * NOTE: Some of kernel programming environment (for example, openbsd/sparc) + * does not supply memcmp(). For userland memcmp() is preferred as it is + * in ANSI standard. + */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define IN6_ARE_ADDR_EQUAL(a, b) \ + (memcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) == 0) +#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ + + +/* + * Unspecified + */ +#define IN6_IS_ADDR_UNSPECIFIED(a) \ + ((*(const __uint32_t *)(const void *)(&(a)->s6_addr[0]) == 0) && \ + (*(const __uint32_t *)(const void *)(&(a)->s6_addr[4]) == 0) && \ + (*(const __uint32_t *)(const void *)(&(a)->s6_addr[8]) == 0) && \ + (*(const __uint32_t *)(const void *)(&(a)->s6_addr[12]) == 0)) + +/* + * Loopback + */ +#define IN6_IS_ADDR_LOOPBACK(a) \ + ((*(const __uint32_t *)(const void *)(&(a)->s6_addr[0]) == 0) && \ + (*(const __uint32_t *)(const void *)(&(a)->s6_addr[4]) == 0) && \ + (*(const __uint32_t *)(const void *)(&(a)->s6_addr[8]) == 0) && \ + (*(const __uint32_t *)(const void *)(&(a)->s6_addr[12]) == ntohl(1))) + +/* + * IPv4 compatible + */ +#define IN6_IS_ADDR_V4COMPAT(a) \ + ((*(const __uint32_t *)(const void *)(&(a)->s6_addr[0]) == 0) && \ + (*(const __uint32_t *)(const void *)(&(a)->s6_addr[4]) == 0) && \ + (*(const __uint32_t *)(const void *)(&(a)->s6_addr[8]) == 0) && \ + (*(const __uint32_t *)(const void *)(&(a)->s6_addr[12]) != 0) && \ + (*(const __uint32_t *)(const void *)(&(a)->s6_addr[12]) != ntohl(1))) + +/* + * Mapped + */ +#define IN6_IS_ADDR_V4MAPPED(a) \ + ((*(const __uint32_t *)(const void *)(&(a)->s6_addr[0]) == 0) && \ + (*(const __uint32_t *)(const void *)(&(a)->s6_addr[4]) == 0) && \ + (*(const __uint32_t *)(const void *)(&(a)->s6_addr[8]) == ntohl(0x0000ffff))) + +/* + * KAME Scope Values + */ + +#define __IPV6_ADDR_SCOPE_NODELOCAL 0x01 +#define __IPV6_ADDR_SCOPE_LINKLOCAL 0x02 +#define __IPV6_ADDR_SCOPE_SITELOCAL 0x05 +#define __IPV6_ADDR_SCOPE_ORGLOCAL 0x08 /* just used in this file */ +#define __IPV6_ADDR_SCOPE_GLOBAL 0x0e + +/* + * Unicast Scope + * Note that we must check topmost 10 bits only, not 16 bits (see RFC2373). + */ +#define IN6_IS_ADDR_LINKLOCAL(a) \ + (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80)) +#define IN6_IS_ADDR_SITELOCAL(a) \ + (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0)) + +/* + * Multicast + */ +#define IN6_IS_ADDR_MULTICAST(a) ((a)->s6_addr[0] == 0xff) + +#define __IPV6_ADDR_MC_SCOPE(a) ((a)->s6_addr[1] & 0x0f) + +/* + * Multicast Scope + */ +#define IN6_IS_ADDR_MC_NODELOCAL(a) \ + (IN6_IS_ADDR_MULTICAST(a) && \ + (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_NODELOCAL)) +#define IN6_IS_ADDR_MC_LINKLOCAL(a) \ + (IN6_IS_ADDR_MULTICAST(a) && \ + (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_LINKLOCAL)) +#define IN6_IS_ADDR_MC_SITELOCAL(a) \ + (IN6_IS_ADDR_MULTICAST(a) && \ + (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_SITELOCAL)) +#define IN6_IS_ADDR_MC_ORGLOCAL(a) \ + (IN6_IS_ADDR_MULTICAST(a) && \ + (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_ORGLOCAL)) +#define IN6_IS_ADDR_MC_GLOBAL(a) \ + (IN6_IS_ADDR_MULTICAST(a) && \ + (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_GLOBAL)) + + +/* + * IP6 route structure + */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ + +/* + * Options for use with [gs]etsockopt at the IPV6 level. + * First word of comment is data type; bool is stored in int. + */ +/* no hdrincl */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#if 0 /* the followings are relic in IPv4 and hence are disabled */ +#define IPV6_OPTIONS 1 /* buf/ip6_opts; set/get IP6 options */ +#define IPV6_RECVOPTS 5 /* bool; receive all IP6 opts w/dgram */ +#define IPV6_RECVRETOPTS 6 /* bool; receive IP6 opts for response */ +#define IPV6_RECVDSTADDR 7 /* bool; receive IP6 dst addr w/dgram */ +#define IPV6_RETOPTS 8 /* ip6_opts; set/get IP6 options */ +#endif /* 0 */ +#define IPV6_SOCKOPT_RESERVED1 3 /* reserved for future use */ +#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ +#define IPV6_UNICAST_HOPS 4 /* int; IP6 hops */ +#define IPV6_MULTICAST_IF 9 /* __uint8_t; set/get IP6 multicast i/f */ +#define IPV6_MULTICAST_HOPS 10 /* __uint8_t; set/get IP6 multicast hops */ +#define IPV6_MULTICAST_LOOP 11 /* __uint8_t; set/get IP6 mcast loopback */ +#define IPV6_JOIN_GROUP 12 /* ip6_mreq; join a group membership */ +#define IPV6_LEAVE_GROUP 13 /* ip6_mreq; leave a group membership */ + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define IPV6_PORTRANGE 14 /* int; range to choose for unspec port */ +#define ICMP6_FILTER 18 /* icmp6_filter; icmp6 filter */ +/* RFC2292 options */ +#define IPV6_PKTINFO 19 /* bool; send/recv if, src/dst addr */ +#define IPV6_HOPLIMIT 20 /* bool; hop limit */ +#define IPV6_NEXTHOP 21 /* bool; next hop addr */ +#define IPV6_HOPOPTS 22 /* bool; hop-by-hop option */ +#define IPV6_DSTOPTS 23 /* bool; destination option */ +#define IPV6_RTHDR 24 /* bool; routing header */ +#define IPV6_PKTOPTIONS 25 /* buf/cmsghdr; set/get IPv6 options */ + +#define IPV6_CHECKSUM 26 /* int; checksum offset for raw socket */ +#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ +#define IPV6_V6ONLY 27 /* bool; only bind INET6 at wildcard bind */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define IPV6_BINDV6ONLY IPV6_V6ONLY + + +#if 1 /*IPSEC*/ +#define IPV6_IPSEC_POLICY 28 /* struct; get/set security policy */ +#endif /* 1 */ +#define IPV6_FAITH 29 /* bool; accept FAITH'ed connections */ + +#if 1 /*IPV6FIREWALL*/ +#define IPV6_FW_ADD 30 /* add a firewall rule to chain */ +#define IPV6_FW_DEL 31 /* delete a firewall rule from chain */ +#define IPV6_FW_FLUSH 32 /* flush firewall rule chain */ +#define IPV6_FW_ZERO 33 /* clear single/all firewall counter(s) */ +#define IPV6_FW_GET 34 /* get entire firewall rule chain */ +#endif /* 1 */ + +#define IPV6_RECVTCLASS 35 /* bool; recv traffic class values */ +#define IPV6_TCLASS 36 /* int; send traffic class value */ + +/* to define items, should talk with KAME guys first, for *BSD compatibility */ + +#define IPV6_RTHDR_LOOSE 0 /* this hop need not be a neighbor. XXX old spec */ +#define IPV6_RTHDR_STRICT 1 /* this hop must be a neighbor. XXX old spec */ +#define IPV6_RTHDR_TYPE_0 0 /* IPv6 routing header type 0 */ + +/* + * Defaults and limits for options + */ +#define IPV6_DEFAULT_MULTICAST_HOPS 1 /* normally limit m'casts to 1 hop */ +#define IPV6_DEFAULT_MULTICAST_LOOP 1 /* normally hear sends if a member */ + +/* + * Argument structure for IPV6_JOIN_GROUP and IPV6_LEAVE_GROUP. + */ +struct ipv6_mreq { + struct in6_addr ipv6mr_multiaddr; + unsigned int ipv6mr_interface; +}; + +/* + * IPV6_PKTINFO: Packet information(RFC2292 sec 5) + */ +struct in6_pktinfo { + struct in6_addr ipi6_addr; /* src/dst IPv6 address */ + unsigned int ipi6_ifindex; /* send/recv interface index */ +}; + +/* + * Argument for IPV6_PORTRANGE: + * - which range to search when port is unspecified at bind() or connect() + */ +#define IPV6_PORTRANGE_DEFAULT 0 /* default range */ +#define IPV6_PORTRANGE_HIGH 1 /* "high" - request firewall bypass */ +#define IPV6_PORTRANGE_LOW 2 /* "low" - vouchsafe security */ + +/* + * Definitions for inet6 sysctl operations. + * + * Third level is protocol number. + * Fourth level is desired variable within that protocol. + */ +#define IPV6PROTO_MAXID (IPPROTO_PIM + 1) /* don't list to IPV6PROTO_MAX */ + +/* + * Names for IP sysctl objects + */ +#define IPV6CTL_FORWARDING 1 /* act as router */ +#define IPV6CTL_SENDREDIRECTS 2 /* may send redirects when forwarding*/ +#define IPV6CTL_DEFHLIM 3 /* default Hop-Limit */ +#ifdef notyet +#define IPV6CTL_DEFMTU 4 /* default MTU */ +#endif +#define IPV6CTL_FORWSRCRT 5 /* forward source-routed dgrams */ +#define IPV6CTL_STATS 6 /* stats */ +#define IPV6CTL_MRTSTATS 7 /* multicast forwarding stats */ +#define IPV6CTL_MRTPROTO 8 /* multicast routing protocol */ +#define IPV6CTL_MAXFRAGPACKETS 9 /* max packets reassembly queue */ +#define IPV6CTL_SOURCECHECK 10 /* verify source route and intf */ +#define IPV6CTL_SOURCECHECK_LOGINT 11 /* minimume logging interval */ +#define IPV6CTL_ACCEPT_RTADV 12 +#define IPV6CTL_KEEPFAITH 13 +#define IPV6CTL_LOG_INTERVAL 14 +#define IPV6CTL_HDRNESTLIMIT 15 +#define IPV6CTL_DAD_COUNT 16 +#define IPV6CTL_AUTO_FLOWLABEL 17 +#define IPV6CTL_DEFMCASTHLIM 18 +#define IPV6CTL_GIF_HLIM 19 /* default HLIM for gif encap packet */ +#define IPV6CTL_KAME_VERSION 20 +#define IPV6CTL_USE_DEPRECATED 21 /* use deprecated addr (RFC2462 5.5.4) */ +#define IPV6CTL_RR_PRUNE 22 /* walk timer for router renumbering */ +#if 0 /*obsolete*/ +#define IPV6CTL_MAPPED_ADDR 23 +#endif +#define IPV6CTL_V6ONLY 24 +#define IPV6CTL_RTEXPIRE 25 /* cloned route expiration time */ +#define IPV6CTL_RTMINEXPIRE 26 /* min value for expiration time */ +#define IPV6CTL_RTMAXCACHE 27 /* trigger level for dynamic expire */ + +#define IPV6CTL_USETEMPADDR 32 /* use temporary addresses (RFC3041) */ +#define IPV6CTL_TEMPPLTIME 33 /* preferred lifetime for tmpaddrs */ +#define IPV6CTL_TEMPVLTIME 34 /* valid lifetime for tmpaddrs */ +#define IPV6CTL_AUTO_LINKLOCAL 35 /* automatic link-local addr assign */ +#define IPV6CTL_RIP6STATS 36 /* raw_ip6 stats */ + +#define IPV6CTL_MAXFRAGS 41 /* max fragments */ + +#define IPV6CTL_NEIGHBORGCTHRESH 46 +#define IPV6CTL_MAXIFPREFIXES 47 +#define IPV6CTL_MAXIFDEFROUTERS 48 +#define IPV6CTL_MAXDYNROUTES 49 + +/* New entries should be added here from current IPV6CTL_MAXID value. */ +/* to define items, should talk with KAME guys first, for *BSD compatibility */ +#define IPV6CTL_MAXID 50 + + +__BEGIN_DECLS +struct cmsghdr; + +extern int inet6_option_space(int); +extern int inet6_option_init(void *, struct cmsghdr **, int); +extern int inet6_option_append(struct cmsghdr *, const __uint8_t *, + int, int); +extern __uint8_t *inet6_option_alloc(struct cmsghdr *, int, int, int); +extern int inet6_option_next(const struct cmsghdr *, __uint8_t **); +extern int inet6_option_find(const struct cmsghdr *, __uint8_t **, int); + +extern size_t inet6_rthdr_space(int, int); +extern struct cmsghdr *inet6_rthdr_init(void *, int); +extern int inet6_rthdr_add(struct cmsghdr *, const struct in6_addr *, + unsigned int); +extern int inet6_rthdr_lasthop(struct cmsghdr *, unsigned int); +#if 0 /* not implemented yet */ +extern int inet6_rthdr_reverse(const struct cmsghdr *, struct cmsghdr *); +#endif +extern int inet6_rthdr_segments(const struct cmsghdr *); +extern struct in6_addr *inet6_rthdr_getaddr(struct cmsghdr *, int); +extern int inet6_rthdr_getflags(const struct cmsghdr *, int); + +extern int inet6_opt_init(void *, size_t); +extern int inet6_opt_append(void *, size_t, int, __uint8_t, + size_t, __uint8_t, void **); +extern int inet6_opt_finish(void *, size_t, int); +extern int inet6_opt_set_val(void *, size_t, void *, int); + +extern int inet6_opt_next(void *, size_t, int, __uint8_t *, + size_t *, void **); +extern int inet6_opt_find(void *, size_t, int, __uint8_t, + size_t *, void **); +extern int inet6_opt_get_val(void *, size_t, void *, int); +extern size_t inet6_rth_space(int, int); +extern void *inet6_rth_init(void *, int, int, int); +extern int inet6_rth_add(void *, const struct in6_addr *); +extern int inet6_rth_reverse(const void *, void *); +extern int inet6_rth_segments(const void *); +extern struct in6_addr *inet6_rth_getaddr(const void *, int); +__END_DECLS +#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ +#endif /* !_NETINET6_IN6_H_ */ Index: branches/azimutz/Cleancut/i386/include/netinet6/ipsec.h =================================================================== --- branches/azimutz/Cleancut/i386/include/netinet6/ipsec.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/netinet6/ipsec.h (revision 885) @@ -0,0 +1,137 @@ +/* $FreeBSD: src/sys/netinet6/ipsec.h,v 1.4.2.2 2001/07/03 11:01:54 ume Exp $ */ +/* $KAME: ipsec.h,v 1.44 2001/03/23 08:08:47 itojun Exp $ */ + +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * IPsec controller part. + */ + +#ifndef _NETINET6_IPSEC_H_ +#define _NETINET6_IPSEC_H_ +#include <sys/cdefs.h> +#include <sys/appleapiopts.h> + +#include <net/pfkeyv2.h> + +/* according to IANA assignment, port 0x0000 and proto 0xff are reserved. */ +#define IPSEC_PORT_ANY 0 +#define IPSEC_ULPROTO_ANY 255 +#define IPSEC_PROTO_ANY 255 + +/* mode of security protocol */ +/* NOTE: DON'T use IPSEC_MODE_ANY at SPD. It's only use in SAD */ +#define IPSEC_MODE_ANY 0 /* i.e. wildcard. */ +#define IPSEC_MODE_TRANSPORT 1 +#define IPSEC_MODE_TUNNEL 2 + +/* + * Direction of security policy. + * NOTE: Since INVALID is used just as flag. + * The other are used for loop counter too. + */ +#define IPSEC_DIR_ANY 0 +#define IPSEC_DIR_INBOUND 1 +#define IPSEC_DIR_OUTBOUND 2 +#define IPSEC_DIR_MAX 3 +#define IPSEC_DIR_INVALID 4 + +/* Policy level */ +/* + * IPSEC, ENTRUST and BYPASS are allowed for setsockopt() in PCB, + * DISCARD, IPSEC and NONE are allowed for setkey() in SPD. + * DISCARD and NONE are allowed for system default. + */ +#define IPSEC_POLICY_DISCARD 0 /* discarding packet */ +#define IPSEC_POLICY_NONE 1 /* through IPsec engine */ +#define IPSEC_POLICY_IPSEC 2 /* do IPsec */ +#define IPSEC_POLICY_ENTRUST 3 /* consulting SPD if present. */ +#define IPSEC_POLICY_BYPASS 4 /* only for privileged socket. */ +#define IPSEC_POLICY_GENERATE 5 /* same as discard - IKE daemon can override with generated policy */ + +/* Security protocol level */ +#define IPSEC_LEVEL_DEFAULT 0 /* reference to system default */ +#define IPSEC_LEVEL_USE 1 /* use SA if present. */ +#define IPSEC_LEVEL_REQUIRE 2 /* require SA. */ +#define IPSEC_LEVEL_UNIQUE 3 /* unique SA. */ + +#define IPSEC_MANUAL_REQID_MAX 0x3fff + /* + * if security policy level == unique, this id + * indicate to a relative SA for use, else is + * zero. + * 1 - 0x3fff are reserved for manual keying. + * 0 are reserved for above reason. Others is + * for kernel use. + * Note that this id doesn't identify SA + * by only itself. + */ +#define IPSEC_REPLAYWSIZE 32 + +/* statistics for ipsec processing */ +struct ipsecstat { + u_quad_t in_success; /* succeeded inbound process */ + u_quad_t in_polvio; + /* security policy violation for inbound process */ + u_quad_t in_nosa; /* inbound SA is unavailable */ + u_quad_t in_inval; /* inbound processing failed due to EINVAL */ + u_quad_t in_nomem; /* inbound processing failed due to ENOBUFS */ + u_quad_t in_badspi; /* failed getting a SPI */ + u_quad_t in_ahreplay; /* AH replay check failed */ + u_quad_t in_espreplay; /* ESP replay check failed */ + u_quad_t in_ahauthsucc; /* AH authentication success */ + u_quad_t in_ahauthfail; /* AH authentication failure */ + u_quad_t in_espauthsucc; /* ESP authentication success */ + u_quad_t in_espauthfail; /* ESP authentication failure */ + u_quad_t in_esphist[256]; + u_quad_t in_ahhist[256]; + u_quad_t in_comphist[256]; + u_quad_t out_success; /* succeeded outbound process */ + u_quad_t out_polvio; + /* security policy violation for outbound process */ + u_quad_t out_nosa; /* outbound SA is unavailable */ + u_quad_t out_inval; /* outbound process failed due to EINVAL */ + u_quad_t out_nomem; /* inbound processing failed due to ENOBUFS */ + u_quad_t out_noroute; /* there is no route */ + u_quad_t out_esphist[256]; + u_quad_t out_ahhist[256]; + u_quad_t out_comphist[256]; +}; + + +__BEGIN_DECLS +extern caddr_t ipsec_set_policy(char *, int); +extern int ipsec_get_policylen(caddr_t); +extern char *ipsec_dump_policy(caddr_t, char *); + +extern const char *ipsec_strerror(void); +__END_DECLS + +#endif /* _NETINET6_IPSEC_H_ */ Index: branches/azimutz/Cleancut/i386/include/netinet6/in6_var.h =================================================================== --- branches/azimutz/Cleancut/i386/include/netinet6/in6_var.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/netinet6/in6_var.h (revision 885) @@ -0,0 +1,466 @@ +/* + * Copyright (c) 2009 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@ + */ + +/* $FreeBSD: src/sys/netinet6/in6_var.h,v 1.3.2.2 2001/07/03 11:01:52 ume Exp $ */ +/* $KAME: in6_var.h,v 1.56 2001/03/29 05:34:31 itojun Exp $ */ + +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * Copyright (c) 1985, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)in_var.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _NETINET6_IN6_VAR_H_ +#define _NETINET6_IN6_VAR_H_ +#include <sys/appleapiopts.h> + +#ifdef __APPLE__ +#include <sys/kern_event.h> +#endif + +/* + * pltime/vltime are just for future reference (required to implements 2 + * hour rule for hosts). they should never be modified by nd6_timeout or + * anywhere else. + * userland -> kernel: accept pltime/vltime + * kernel -> userland: throw up everything + * in kernel: modify preferred/expire only + */ +struct in6_addrlifetime { + time_t ia6t_expire; /* valid lifetime expiration time */ + time_t ia6t_preferred; /* preferred lifetime expiration time */ + u_int32_t ia6t_vltime; /* valid lifetime */ + u_int32_t ia6t_pltime; /* prefix lifetime */ +}; + + +/* + * IPv6 interface statistics, as defined in RFC2465 Ipv6IfStatsEntry (p12). + */ +struct in6_ifstat { + u_quad_t ifs6_in_receive; /* # of total input datagram */ + u_quad_t ifs6_in_hdrerr; /* # of datagrams with invalid hdr */ + u_quad_t ifs6_in_toobig; /* # of datagrams exceeded MTU */ + u_quad_t ifs6_in_noroute; /* # of datagrams with no route */ + u_quad_t ifs6_in_addrerr; /* # of datagrams with invalid dst */ + u_quad_t ifs6_in_protounknown; /* # of datagrams with unknown proto */ + /* NOTE: increment on final dst if */ + u_quad_t ifs6_in_truncated; /* # of truncated datagrams */ + u_quad_t ifs6_in_discard; /* # of discarded datagrams */ + /* NOTE: fragment timeout is not here */ + u_quad_t ifs6_in_deliver; /* # of datagrams delivered to ULP */ + /* NOTE: increment on final dst if */ + u_quad_t ifs6_out_forward; /* # of datagrams forwarded */ + /* NOTE: increment on outgoing if */ + u_quad_t ifs6_out_request; /* # of outgoing datagrams from ULP */ + /* NOTE: does not include forwrads */ + u_quad_t ifs6_out_discard; /* # of discarded datagrams */ + u_quad_t ifs6_out_fragok; /* # of datagrams fragmented */ + u_quad_t ifs6_out_fragfail; /* # of datagrams failed on fragment */ + u_quad_t ifs6_out_fragcreat; /* # of fragment datagrams */ + /* NOTE: this is # after fragment */ + u_quad_t ifs6_reass_reqd; /* # of incoming fragmented packets */ + /* NOTE: increment on final dst if */ + u_quad_t ifs6_reass_ok; /* # of reassembled packets */ + /* NOTE: this is # after reass */ + /* NOTE: increment on final dst if */ + u_quad_t ifs6_reass_fail; /* # of reass failures */ + /* NOTE: may not be packet count */ + /* NOTE: increment on final dst if */ + u_quad_t ifs6_in_mcast; /* # of inbound multicast datagrams */ + u_quad_t ifs6_out_mcast; /* # of outbound multicast datagrams */ +}; + +/* + * ICMPv6 interface statistics, as defined in RFC2466 Ipv6IfIcmpEntry. + * XXX: I'm not sure if this file is the right place for this structure... + */ +struct icmp6_ifstat { + /* + * Input statistics + */ + /* ipv6IfIcmpInMsgs, total # of input messages */ + u_quad_t ifs6_in_msg; + /* ipv6IfIcmpInErrors, # of input error messages */ + u_quad_t ifs6_in_error; + /* ipv6IfIcmpInDestUnreachs, # of input dest unreach errors */ + u_quad_t ifs6_in_dstunreach; + /* ipv6IfIcmpInAdminProhibs, # of input administratively prohibited errs */ + u_quad_t ifs6_in_adminprohib; + /* ipv6IfIcmpInTimeExcds, # of input time exceeded errors */ + u_quad_t ifs6_in_timeexceed; + /* ipv6IfIcmpInParmProblems, # of input parameter problem errors */ + u_quad_t ifs6_in_paramprob; + /* ipv6IfIcmpInPktTooBigs, # of input packet too big errors */ + u_quad_t ifs6_in_pkttoobig; + /* ipv6IfIcmpInEchos, # of input echo requests */ + u_quad_t ifs6_in_echo; + /* ipv6IfIcmpInEchoReplies, # of input echo replies */ + u_quad_t ifs6_in_echoreply; + /* ipv6IfIcmpInRouterSolicits, # of input router solicitations */ + u_quad_t ifs6_in_routersolicit; + /* ipv6IfIcmpInRouterAdvertisements, # of input router advertisements */ + u_quad_t ifs6_in_routeradvert; + /* ipv6IfIcmpInNeighborSolicits, # of input neighbor solicitations */ + u_quad_t ifs6_in_neighborsolicit; + /* ipv6IfIcmpInNeighborAdvertisements, # of input neighbor advertisements */ + u_quad_t ifs6_in_neighboradvert; + /* ipv6IfIcmpInRedirects, # of input redirects */ + u_quad_t ifs6_in_redirect; + /* ipv6IfIcmpInGroupMembQueries, # of input MLD queries */ + u_quad_t ifs6_in_mldquery; + /* ipv6IfIcmpInGroupMembResponses, # of input MLD reports */ + u_quad_t ifs6_in_mldreport; + /* ipv6IfIcmpInGroupMembReductions, # of input MLD done */ + u_quad_t ifs6_in_mlddone; + + /* + * Output statistics. We should solve unresolved routing problem... + */ + /* ipv6IfIcmpOutMsgs, total # of output messages */ + u_quad_t ifs6_out_msg; + /* ipv6IfIcmpOutErrors, # of output error messages */ + u_quad_t ifs6_out_error; + /* ipv6IfIcmpOutDestUnreachs, # of output dest unreach errors */ + u_quad_t ifs6_out_dstunreach; + /* ipv6IfIcmpOutAdminProhibs, # of output administratively prohibited errs */ + u_quad_t ifs6_out_adminprohib; + /* ipv6IfIcmpOutTimeExcds, # of output time exceeded errors */ + u_quad_t ifs6_out_timeexceed; + /* ipv6IfIcmpOutParmProblems, # of output parameter problem errors */ + u_quad_t ifs6_out_paramprob; + /* ipv6IfIcmpOutPktTooBigs, # of output packet too big errors */ + u_quad_t ifs6_out_pkttoobig; + /* ipv6IfIcmpOutEchos, # of output echo requests */ + u_quad_t ifs6_out_echo; + /* ipv6IfIcmpOutEchoReplies, # of output echo replies */ + u_quad_t ifs6_out_echoreply; + /* ipv6IfIcmpOutRouterSolicits, # of output router solicitations */ + u_quad_t ifs6_out_routersolicit; + /* ipv6IfIcmpOutRouterAdvertisements, # of output router advertisements */ + u_quad_t ifs6_out_routeradvert; + /* ipv6IfIcmpOutNeighborSolicits, # of output neighbor solicitations */ + u_quad_t ifs6_out_neighborsolicit; + /* ipv6IfIcmpOutNeighborAdvertisements, # of output neighbor advertisements */ + u_quad_t ifs6_out_neighboradvert; + /* ipv6IfIcmpOutRedirects, # of output redirects */ + u_quad_t ifs6_out_redirect; + /* ipv6IfIcmpOutGroupMembQueries, # of output MLD queries */ + u_quad_t ifs6_out_mldquery; + /* ipv6IfIcmpOutGroupMembResponses, # of output MLD reports */ + u_quad_t ifs6_out_mldreport; + /* ipv6IfIcmpOutGroupMembReductions, # of output MLD done */ + u_quad_t ifs6_out_mlddone; +}; + +struct in6_ifreq { + char ifr_name[IFNAMSIZ]; + union { + struct sockaddr_in6 ifru_addr; + struct sockaddr_in6 ifru_dstaddr; + short ifru_flags; + int ifru_flags6; + int ifru_metric; + caddr_t ifru_data; + struct in6_addrlifetime ifru_lifetime; + struct in6_ifstat ifru_stat; + struct icmp6_ifstat ifru_icmp6stat; + u_int32_t ifru_scope_id[16]; + } ifr_ifru; +}; + +struct in6_aliasreq { + char ifra_name[IFNAMSIZ]; + struct sockaddr_in6 ifra_addr; + struct sockaddr_in6 ifra_dstaddr; + struct sockaddr_in6 ifra_prefixmask; + int ifra_flags; + struct in6_addrlifetime ifra_lifetime; +}; + + +/* prefix type macro */ +#define IN6_PREFIX_ND 1 +#define IN6_PREFIX_RR 2 + +/* + * prefix related flags passed between kernel(NDP related part) and + * user land command(ifconfig) and daemon(rtadvd). + */ +struct in6_prflags { + struct prf_ra { + u_char onlink : 1; + u_char autonomous : 1; + u_char reserved : 6; + } prf_ra; + u_char prf_reserved1; + u_short prf_reserved2; + /* want to put this on 4byte offset */ + struct prf_rr { + u_char decrvalid : 1; + u_char decrprefd : 1; + u_char reserved : 6; + } prf_rr; + u_char prf_reserved3; + u_short prf_reserved4; +}; + +struct in6_prefixreq { + char ipr_name[IFNAMSIZ]; + u_char ipr_origin; + u_char ipr_plen; + u_int32_t ipr_vltime; + u_int32_t ipr_pltime; + struct in6_prflags ipr_flags; + struct sockaddr_in6 ipr_prefix; +}; + +#define PR_ORIG_RA 0 +#define PR_ORIG_RR 1 +#define PR_ORIG_STATIC 2 +#define PR_ORIG_KERNEL 3 + +#define ipr_raf_onlink ipr_flags.prf_ra.onlink +#define ipr_raf_auto ipr_flags.prf_ra.autonomous + +#define ipr_statef_onlink ipr_flags.prf_state.onlink + +#define ipr_rrf_decrvalid ipr_flags.prf_rr.decrvalid +#define ipr_rrf_decrprefd ipr_flags.prf_rr.decrprefd + +struct in6_rrenumreq { + char irr_name[IFNAMSIZ]; + u_char irr_origin; + u_char irr_m_len; /* match len for matchprefix */ + u_char irr_m_minlen; /* minlen for matching prefix */ + u_char irr_m_maxlen; /* maxlen for matching prefix */ + u_char irr_u_uselen; /* uselen for adding prefix */ + u_char irr_u_keeplen; /* keeplen from matching prefix */ + struct irr_raflagmask { + u_char onlink : 1; + u_char autonomous : 1; + u_char reserved : 6; + } irr_raflagmask; + u_int32_t irr_vltime; + u_int32_t irr_pltime; + struct in6_prflags irr_flags; + struct sockaddr_in6 irr_matchprefix; + struct sockaddr_in6 irr_useprefix; +}; + +#define irr_raf_mask_onlink irr_raflagmask.onlink +#define irr_raf_mask_auto irr_raflagmask.autonomous +#define irr_raf_mask_reserved irr_raflagmask.reserved + +#define irr_raf_onlink irr_flags.prf_ra.onlink +#define irr_raf_auto irr_flags.prf_ra.autonomous + +#define irr_statef_onlink irr_flags.prf_state.onlink + +#define irr_rrf irr_flags.prf_rr +#define irr_rrf_decrvalid irr_flags.prf_rr.decrvalid +#define irr_rrf_decrprefd irr_flags.prf_rr.decrprefd + + +/* + * Event data, internet6 style. + */ + +struct kev_in6_addrlifetime { + u_int32_t ia6t_expire; + u_int32_t ia6t_preferred; + u_int32_t ia6t_vltime; + u_int32_t ia6t_pltime; +}; + +struct kev_in6_data { + struct net_event_data link_data; + struct sockaddr_in6 ia_addr; /* interface address */ + struct sockaddr_in6 ia_net; /* network number of interface */ + struct sockaddr_in6 ia_dstaddr; /* space for destination addr */ + struct sockaddr_in6 ia_prefixmask; /* prefix mask */ + u_int32_t ia_plen; /* prefix length */ + u_int32_t ia6_flags; /* address flags from in6_ifaddr */ + struct kev_in6_addrlifetime ia_lifetime; /* address life info */ +}; + +/* + * Define inet6 event subclass and specific inet6 events. + */ + +#define KEV_INET6_SUBCLASS 6 /* inet6 subclass identifier */ + +#define KEV_INET6_NEW_USER_ADDR 1 /* Userland configured IPv6 address */ +#define KEV_INET6_CHANGED_ADDR 2 /* Address changed event (future) */ +#define KEV_INET6_ADDR_DELETED 3 /* IPv6 add. in ia_addr field was deleted */ +#define KEV_INET6_NEW_LL_ADDR 4 /* Autoconfigured linklocal address has appeared */ +#define KEV_INET6_NEW_RTADV_ADDR 5 /* Autoconf router advertised address has appeared */ +#define KEV_INET6_DEFROUTER 6 /* Default router dectected by kernel */ + + +#define IN6_ARE_MASKED_ADDR_EQUAL(d, a, m) ( \ + (((d)->s6_addr32[0] ^ (a)->s6_addr32[0]) & (m)->s6_addr32[0]) == 0 && \ + (((d)->s6_addr32[1] ^ (a)->s6_addr32[1]) & (m)->s6_addr32[1]) == 0 && \ + (((d)->s6_addr32[2] ^ (a)->s6_addr32[2]) & (m)->s6_addr32[2]) == 0 && \ + (((d)->s6_addr32[3] ^ (a)->s6_addr32[3]) & (m)->s6_addr32[3]) == 0 ) + +#define SIOCSIFADDR_IN6 _IOW('i', 12, struct in6_ifreq) +#define SIOCGIFADDR_IN6 _IOWR('i', 33, struct in6_ifreq) + +/* + * SIOCSxxx ioctls should be unused (see comments in in6.c), but + * we do not shift numbers for binary compatibility. + */ +#define SIOCSIFDSTADDR_IN6 _IOW('i', 14, struct in6_ifreq) +#define SIOCSIFNETMASK_IN6 _IOW('i', 22, struct in6_ifreq) + +#define SIOCGIFDSTADDR_IN6 _IOWR('i', 34, struct in6_ifreq) +#define SIOCGIFNETMASK_IN6 _IOWR('i', 37, struct in6_ifreq) + +#define SIOCDIFADDR_IN6 _IOW('i', 25, struct in6_ifreq) +#define SIOCAIFADDR_IN6 _IOW('i', 26, struct in6_aliasreq) + +#define SIOCSIFPHYADDR_IN6 _IOW('i', 62, struct in6_aliasreq) +#define SIOCGIFPSRCADDR_IN6 _IOWR('i', 63, struct in6_ifreq) +#define SIOCGIFPDSTADDR_IN6 _IOWR('i', 64, struct in6_ifreq) +#define SIOCGIFAFLAG_IN6 _IOWR('i', 73, struct in6_ifreq) +#define SIOCGDRLST_IN6 _IOWR('i', 74, struct in6_drlist) +#define SIOCGPRLST_IN6 _IOWR('i', 75, struct in6_prlist) +#define OSIOCGIFINFO_IN6 _IOWR('i', 108, struct in6_ondireq) +#define SIOCGIFINFO_IN6 _IOWR('i', 76, struct in6_ondireq) +#define SIOCSNDFLUSH_IN6 _IOWR('i', 77, struct in6_ifreq) +#define SIOCGNBRINFO_IN6 _IOWR('i', 78, struct in6_nbrinfo) +#define SIOCSPFXFLUSH_IN6 _IOWR('i', 79, struct in6_ifreq) +#define SIOCSRTRFLUSH_IN6 _IOWR('i', 80, struct in6_ifreq) + +#define SIOCGIFALIFETIME_IN6 _IOWR('i', 81, struct in6_ifreq) +#define SIOCSIFALIFETIME_IN6 _IOWR('i', 82, struct in6_ifreq) +#define SIOCGIFSTAT_IN6 _IOWR('i', 83, struct in6_ifreq) +#define SIOCGIFSTAT_ICMP6 _IOWR('i', 84, struct in6_ifreq) + +#define SIOCSDEFIFACE_IN6 _IOWR('i', 85, struct in6_ndifreq) +#define SIOCGDEFIFACE_IN6 _IOWR('i', 86, struct in6_ndifreq) + +#define SIOCSIFINFO_FLAGS _IOWR('i', 87, struct in6_ndireq) /* XXX */ + +#define SIOCSSCOPE6 _IOW('i', 88, struct in6_ifreq) +#define SIOCGSCOPE6 _IOWR('i', 89, struct in6_ifreq) +#define SIOCGSCOPE6DEF _IOWR('i', 90, struct in6_ifreq) + +#define SIOCSIFPREFIX_IN6 _IOW('i', 100, struct in6_prefixreq) /* set */ +#define SIOCGIFPREFIX_IN6 _IOWR('i', 101, struct in6_prefixreq) /* get */ +#define SIOCDIFPREFIX_IN6 _IOW('i', 102, struct in6_prefixreq) /* del */ +#define SIOCAIFPREFIX_IN6 _IOW('i', 103, struct in6_rrenumreq) /* add */ +#define SIOCCIFPREFIX_IN6 _IOW('i', 104, \ + struct in6_rrenumreq) /* change */ +#define SIOCSGIFPREFIX_IN6 _IOW('i', 105, \ + struct in6_rrenumreq) /* set global */ + +#define SIOCGETSGCNT_IN6 _IOWR('u', 28, \ + struct sioc_sg_req6) /* get s,g pkt cnt */ +#define SIOCGETMIFCNT_IN6 _IOWR('u', 107, \ + struct sioc_mif_req6) /* get pkt cnt per if */ + + +#define IN6_IFF_ANYCAST 0x01 /* anycast address */ +#define IN6_IFF_TENTATIVE 0x02 /* tentative address */ +#define IN6_IFF_DUPLICATED 0x04 /* DAD detected duplicate */ +#define IN6_IFF_DETACHED 0x08 /* may be detached from the link */ +#define IN6_IFF_DEPRECATED 0x10 /* deprecated address */ +#define IN6_IFF_NODAD 0x20 /* don't perform DAD on this address + * (used only at first SIOC* call) + */ +#define IN6_IFF_AUTOCONF 0x40 /* autoconfigurable address. */ +#define IN6_IFF_TEMPORARY 0x80 /* temporary (anonymous) address. */ +#define IN6_IFF_NOPFX 0x8000 /* skip kernel prefix management. + * XXX: this should be temporary. + */ + +/* do not input/output */ +#define IN6_IFF_NOTREADY (IN6_IFF_TENTATIVE|IN6_IFF_DUPLICATED) + + +#endif /* _NETINET6_IN6_VAR_H_ */ Index: branches/azimutz/Cleancut/i386/include/netinet6/esp.h =================================================================== --- branches/azimutz/Cleancut/i386/include/netinet6/esp.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/netinet6/esp.h (revision 885) @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2008 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@ + */ + +/* $FreeBSD: src/sys/netinet6/esp.h,v 1.2.2.2 2001/07/03 11:01:49 ume Exp $ */ +/* $KAME: esp.h,v 1.16 2000/10/18 21:28:00 itojun Exp $ */ + +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * RFC1827/2406 Encapsulated Security Payload. + */ + +#ifndef _NETINET6_ESP_H_ +#define _NETINET6_ESP_H_ +#include <sys/appleapiopts.h> + + +struct esp { + u_int32_t esp_spi; /* ESP */ + /*variable size, 32bit bound*/ /* Initialization Vector */ + /*variable size*/ /* Payload data */ + /*variable size*/ /* padding */ + /*8bit*/ /* pad size */ + /*8bit*/ /* next header */ + /*8bit*/ /* next header */ + /*variable size, 32bit bound*/ /* Authentication data (new IPsec) */ +}; + +struct newesp { + u_int32_t esp_spi; /* ESP */ + u_int32_t esp_seq; /* Sequence number */ + /*variable size*/ /* (IV and) Payload data */ + /*variable size*/ /* padding */ + /*8bit*/ /* pad size */ + /*8bit*/ /* next header */ + /*8bit*/ /* next header */ + /*variable size, 32bit bound*/ /* Authentication data */ +}; + +struct esptail { + u_int8_t esp_padlen; /* pad length */ + u_int8_t esp_nxt; /* Next header */ + /*variable size, 32bit bound*/ /* Authentication data (new IPsec)*/ +}; + + +#endif /* _NETINET6_ESP_H_ */ Index: branches/azimutz/Cleancut/i386/include/netinet6/ipcomp.h =================================================================== --- branches/azimutz/Cleancut/i386/include/netinet6/ipcomp.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/netinet6/ipcomp.h (revision 885) @@ -0,0 +1,57 @@ +/* $FreeBSD: src/sys/netinet6/ipcomp.h,v 1.1.2.2 2001/07/03 11:01:54 ume Exp $ */ +/* $KAME: ipcomp.h,v 1.8 2000/09/26 07:55:14 itojun Exp $ */ + +/* + * Copyright (C) 1999 WIDE Project. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * RFC2393 IP payload compression protocol (IPComp). + */ + +#ifndef _NETINET6_IPCOMP_H_ +#define _NETINET6_IPCOMP_H_ +#include <sys/appleapiopts.h> +#include <netinet6/ipsec.h> + +struct ipcomp { + u_int8_t comp_nxt; /* Next Header */ + u_int8_t comp_flags; /* reserved, must be zero */ + u_int16_t comp_cpi; /* Compression parameter index */ +}; + +/* well-known algorithm number (in CPI), from RFC2409 */ +#define IPCOMP_OUI 1 /* vendor specific */ +#define IPCOMP_DEFLATE 2 /* RFC2394 */ +#define IPCOMP_LZS 3 /* RFC2395 */ +#define IPCOMP_MAX 4 + +#define IPCOMP_CPI_NEGOTIATE_MIN 256 + + +#endif /* _NETINET6_IPCOMP_H_ */ Index: branches/azimutz/Cleancut/i386/include/netinet6/nd6.h =================================================================== --- branches/azimutz/Cleancut/i386/include/netinet6/nd6.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/netinet6/nd6.h (revision 885) @@ -0,0 +1,214 @@ +/* + * Copyright (c) 2009 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@ + */ + +/* $FreeBSD: src/sys/netinet6/nd6.h,v 1.2.2.3 2001/08/13 01:10:49 simokawa Exp $ */ +/* $KAME: nd6.h,v 1.55 2001/04/27 15:09:49 itojun Exp $ */ + +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _NETINET6_ND6_H_ +#define _NETINET6_ND6_H_ +#include <sys/appleapiopts.h> + +/* see net/route.h, or net/if_inarp.h */ +#ifndef RTF_ANNOUNCE +#define RTF_ANNOUNCE RTF_PROTO2 +#endif + +#include <sys/queue.h> + + +#define ND6_LLINFO_PURGE -3 +#define ND6_LLINFO_NOSTATE -2 +/* + * We don't need the WAITDELETE state any more, but we keep the definition + * in a comment line instead of removing it. This is necessary to avoid + * unintentionally reusing the value for another purpose, which might + * affect backward compatibility with old applications. + * (20000711 jinmei@kame.net) + */ +/* #define ND6_LLINFO_WAITDELETE -1 */ +#define ND6_LLINFO_INCOMPLETE 0 +#define ND6_LLINFO_REACHABLE 1 +#define ND6_LLINFO_STALE 2 +#define ND6_LLINFO_DELAY 3 +#define ND6_LLINFO_PROBE 4 + + +struct nd_ifinfo { + u_int32_t linkmtu; /* LinkMTU */ + u_int32_t maxmtu; /* Upper bound of LinkMTU */ + u_int32_t basereachable; /* BaseReachableTime */ + u_int32_t reachable; /* Reachable Time */ + u_int32_t retrans; /* Retrans Timer */ + u_int32_t flags; /* Flags */ + int recalctm; /* BaseReacable re-calculation timer */ + u_int8_t chlim; /* CurHopLimit */ + u_int8_t receivedra; + /* the following 3 members are for privacy extension for addrconf */ + u_int8_t randomseed0[8]; /* upper 64 bits of MD5 digest */ + u_int8_t randomseed1[8]; /* lower 64 bits (usually the EUI64 IFID) */ + u_int8_t randomid[8]; /* current random ID */ +}; + + +#define ND6_IFF_PERFORMNUD 0x1 + +struct in6_nbrinfo { + char ifname[IFNAMSIZ]; /* if name, e.g. "en0" */ + struct in6_addr addr; /* IPv6 address of the neighbor */ + long asked; /* number of queries already sent for this addr */ + int isrouter; /* if it acts as a router */ + int state; /* reachability state */ + int expire; /* lifetime for NDP state transition */ +}; + + +#define DRLSTSIZ 10 +#define PRLSTSIZ 10 + +struct in6_drlist { + char ifname[IFNAMSIZ]; + struct { + struct in6_addr rtaddr; + u_char flags; + u_short rtlifetime; + u_long expire; + u_short if_index; + } defrouter[DRLSTSIZ]; +}; + + +struct in6_defrouter { + struct sockaddr_in6 rtaddr; + u_char flags; + u_short rtlifetime; + u_long expire; + u_short if_index; +}; + + +struct in6_prlist { + char ifname[IFNAMSIZ]; + struct { + struct in6_addr prefix; + struct prf_ra raflags; + u_char prefixlen; + u_char origin; + u_long vltime; + u_long pltime; + u_long expire; + u_short if_index; + u_short advrtrs; /* number of advertisement routers */ + struct in6_addr advrtr[DRLSTSIZ]; /* XXX: explicit limit */ + } prefix[PRLSTSIZ]; +}; + + +struct in6_prefix { + struct sockaddr_in6 prefix; + struct prf_ra raflags; + u_char prefixlen; + u_char origin; + u_long vltime; + u_long pltime; + u_long expire; + u_int32_t flags; + int refcnt; + u_short if_index; + u_short advrtrs; /* number of advertisement routers */ + /* struct sockaddr_in6 advrtr[] */ +}; + + +struct in6_ondireq { + char ifname[IFNAMSIZ]; + struct { + u_int32_t linkmtu; /* LinkMTU */ + u_int32_t maxmtu; /* Upper bound of LinkMTU */ + u_int32_t basereachable; /* BaseReachableTime */ + u_int32_t reachable; /* Reachable Time */ + u_int32_t retrans; /* Retrans Timer */ + u_int32_t flags; /* Flags */ + int recalctm; /* BaseReacable re-calculation timer */ + u_int8_t chlim; /* CurHopLimit */ + u_int8_t receivedra; + } ndi; +}; + +struct in6_ndireq { + char ifname[IFNAMSIZ]; + struct nd_ifinfo ndi; +}; + +struct in6_ndifreq { + char ifname[IFNAMSIZ]; + u_long ifindex; +}; + + +/* Prefix status */ +#define NDPRF_ONLINK 0x1 +#define NDPRF_DETACHED 0x2 + +/* protocol constants */ +#define MAX_RTR_SOLICITATION_DELAY 1 /*1sec*/ +#define RTR_SOLICITATION_INTERVAL 4 /*4sec*/ +#define MAX_RTR_SOLICITATIONS 3 + +#define ND6_INFINITE_LIFETIME 0xffffffff + + +#endif /* _NETINET6_ND6_H_ */ Index: branches/azimutz/Cleancut/i386/include/netinet6/raw_ip6.h =================================================================== --- branches/azimutz/Cleancut/i386/include/netinet6/raw_ip6.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/netinet6/raw_ip6.h (revision 885) @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2008 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@ + */ + +/* $FreeBSD: src/sys/netinet6/raw_ip6.h,v 1.1.2.1 2001/07/03 11:01:55 ume Exp $ */ +/* $KAME: raw_ip6.h,v 1.2 2001/05/27 13:28:35 itojun Exp $ */ + +/* + * Copyright (C) 2001 WIDE Project. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _NETINET6_RAW_IP6_H_ +#define _NETINET6_RAW_IP6_H_ +#include <sys/appleapiopts.h> + +/* + * ICMPv6 stat is counted separately. see netinet/icmp6.h + */ +struct rip6stat { + u_quad_t rip6s_ipackets; /* total input packets */ + u_quad_t rip6s_isum; /* input checksum computations */ + u_quad_t rip6s_badsum; /* of above, checksum error */ + u_quad_t rip6s_nosock; /* no matching socket */ + u_quad_t rip6s_nosockmcast; /* of above, arrived as multicast */ + u_quad_t rip6s_fullsock; /* not delivered, input socket full */ + + u_quad_t rip6s_opackets; /* total output packets */ +}; + +#endif Index: branches/azimutz/Cleancut/i386/include/netinet6/ah.h =================================================================== --- branches/azimutz/Cleancut/i386/include/netinet6/ah.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/netinet6/ah.h (revision 885) @@ -0,0 +1,59 @@ +/* $FreeBSD: src/sys/netinet6/ah.h,v 1.3.2.2 2001/07/03 11:01:49 ume Exp $ */ +/* $KAME: ah.h,v 1.13 2000/10/18 21:28:00 itojun Exp $ */ + +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * RFC1826/2402 authentication header. + */ + +#ifndef _NETINET6_AH_H_ +#define _NETINET6_AH_H_ +#include <sys/appleapiopts.h> + +struct ah { + u_int8_t ah_nxt; /* Next Header */ + u_int8_t ah_len; /* Length of data, in 32bit */ + u_int16_t ah_reserve; /* Reserved for future use */ + u_int32_t ah_spi; /* Security parameter index */ + /* variable size, 32bit bound*/ /* Authentication data */ +}; + +struct newah { + u_int8_t ah_nxt; /* Next Header */ + u_int8_t ah_len; /* Length of data + 1, in 32bit */ + u_int16_t ah_reserve; /* Reserved for future use */ + u_int32_t ah_spi; /* Security parameter index */ + u_int32_t ah_seq; /* Sequence number field */ + /* variable size, 32bit bound*/ /* Authentication data */ +}; + + +#endif /* _NETINET6_AH_H_ */ Index: branches/azimutz/Cleancut/i386/include/stdbool.h =================================================================== --- branches/azimutz/Cleancut/i386/include/stdbool.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/stdbool.h (revision 885) @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2000 Jeroen Ruigrok van der Werven <asmodai@FreeBSD.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: src/include/stdbool.h,v 1.6 2002/08/16 07:33:14 alfred Exp $ + */ + +#ifndef _STDBOOL_H_ +#define _STDBOOL_H_ + +#define __bool_true_false_are_defined 1 + +#ifndef __cplusplus + +#define bool _Bool +#if __STDC_VERSION__ < 199901L && __GNUC__ < 3 +typedef int _Bool; +#endif + +#define false (bool)0 +#define true (bool)1 + +#endif /* !__cplusplus */ + +#endif /* !_STDBOOL_H_ */ Index: branches/azimutz/Cleancut/i386/include/signal.h =================================================================== --- branches/azimutz/Cleancut/i386/include/signal.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/signal.h (revision 885) @@ -0,0 +1,187 @@ +/* + * Copyright (c) 2000 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@ + */ +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)signal.h 8.3 (Berkeley) 3/30/94 + */ + +#ifndef _USER_SIGNAL_H +#define _USER_SIGNAL_H + +#include <sys/cdefs.h> +#include <_types.h> +#include <sys/signal.h> + +#ifndef _PTHREAD_T +typedef __darwin_pthread_t pthread_t; +#define _PTHREAD_T +#endif + +#if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) +extern __const char *__const sys_signame[NSIG]; +extern __const char *__const sys_siglist[NSIG]; +#endif + +__BEGIN_DECLS +int raise(int); +__END_DECLS + +#ifndef _ANSI_SOURCE +__BEGIN_DECLS +void (*bsd_signal(int, void (*)(int)))(int); +//Begin-Libc +#ifndef LIBC_ALIAS_KILL +//End-Libc +int kill(pid_t, int) __DARWIN_ALIAS(kill); +//Begin-Libc +#else /* LIBC_ALIAS_KILL */ +int kill(pid_t, int) LIBC_ALIAS(kill); +#endif /* !LIBC_ALIAS_KILL */ +//End-Libc +//Begin-Libc +#ifndef LIBC_ALIAS_KILLPG +//End-Libc +int killpg(pid_t, int) __DARWIN_ALIAS(killpg); +//Begin-Libc +#else /* LIBC_ALIAS_KILLPG */ +int killpg(pid_t, int) LIBC_ALIAS(killpg); +#endif /* !LIBC_ALIAS_KILLPG */ +//End-Libc +int pthread_kill(pthread_t, int); +//Begin-Libc +#ifndef LIBC_ALIAS_PTHREAD_SIGMASK +//End-Libc +int pthread_sigmask(int, const sigset_t *, sigset_t *) __DARWIN_ALIAS(pthread_sigmask); +//Begin-Libc +#else /* LIBC_ALIAS_PTHREAD_SIGMASK */ +int pthread_sigmask(int, const sigset_t *, sigset_t *) LIBC_ALIAS(pthread_sigmask); +#endif /* !LIBC_ALIAS_PTHREAD_SIGMASK */ +//End-Libc +int sigaction(int, const struct sigaction * __restrict, + struct sigaction * __restrict); +int sigaddset(sigset_t *, int); +//Begin-Libc +#ifndef LIBC_ALIAS_SIGALTSTACK +//End-Libc +int sigaltstack(const stack_t * __restrict, stack_t * __restrict) __DARWIN_ALIAS(sigaltstack); +//Begin-Libc +#else /* LIBC_ALIAS_SIGALTSTACK */ +int sigaltstack(const stack_t * __restrict, stack_t * __restrict) LIBC_ALIAS(sigaltstack); +#endif /* !LIBC_ALIAS_SIGALTSTACK */ +//End-Libc +int sigdelset(sigset_t *, int); +int sigemptyset(sigset_t *); +int sigfillset(sigset_t *); +int sighold(int); +int sigignore(int); +int siginterrupt(int, int); +int sigismember(const sigset_t *, int); +//Begin-Libc +#ifndef LIBC_ALIAS_SIGPAUSE +//End-Libc +int sigpause(int) __DARWIN_ALIAS_C(sigpause); +//Begin-Libc +#else /* LIBC_ALIAS_SIGPAUSE */ +int sigpause(int) LIBC_ALIAS_C(sigpause); +#endif /* !LIBC_ALIAS_SIGPAUSE */ +//End-Libc +int sigpending(sigset_t *); +int sigprocmask(int, const sigset_t * __restrict, sigset_t * __restrict); +int sigrelse(int); +void (*sigset(int, void (*)(int)))(int); +//Begin-Libc +#ifndef LIBC_ALIAS_SIGSUSPEND +//End-Libc +int sigsuspend(const sigset_t *) __DARWIN_ALIAS_C(sigsuspend); +//Begin-Libc +#else /* LIBC_ALIAS_SIGSUSPEND */ +int sigsuspend(const sigset_t *) LIBC_ALIAS_C(sigsuspend); +#endif /* !LIBC_ALIAS_SIGSUSPEND */ +//End-Libc +//Begin-Libc +#ifndef LIBC_ALIAS_SIGWAIT +//End-Libc +int sigwait(const sigset_t * __restrict, int * __restrict) __DARWIN_ALIAS_C(sigwait); +//Begin-Libc +#else /* LIBC_ALIAS_SIGWAIT */ +int sigwait(const sigset_t * __restrict, int * __restrict) LIBC_ALIAS_C(sigwait); +#endif /* !LIBC_ALIAS_SIGWAIT */ +//End-Libc +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +void psignal(unsigned int, const char *); +int sigblock(int); +int sigsetmask(int); +int sigvec(int, struct sigvec *, struct sigvec *); +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ +__END_DECLS + +/* List definitions after function declarations, or Reiser cpp gets upset. */ +#if defined(__i386__) || defined(__x86_64__) +/* The left shift operator on intel is modulo 32 */ +static __inline int +__sigbits(int __signo) +{ + return __signo > __DARWIN_NSIG ? 0 : (1 << (__signo - 1)); +} +#else /* !__i386__ && !__x86_64__ */ +#define __sigbits(signo) (1 << ((signo) - 1)) +#endif /* __i386__ || __x86_64__ */ + +#define sigaddset(set, signo) (*(set) |= __sigbits(signo), 0) +#define sigdelset(set, signo) (*(set) &= ~__sigbits(signo), 0) +#define sigismember(set, signo) ((*(set) & __sigbits(signo)) != 0) +#define sigemptyset(set) (*(set) = 0, 0) +#define sigfillset(set) (*(set) = ~(sigset_t)0, 0) +#endif /* !_ANSI_SOURCE */ + +#endif /* !_USER_SIGNAL_H */ Index: branches/azimutz/Cleancut/i386/include/machine/signal.h =================================================================== --- branches/azimutz/Cleancut/i386/include/machine/signal.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/machine/signal.h (revision 885) @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2000-2007 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 _BSD_MACHINE_SIGNAL_H_ +#define _BSD_MACHINE_SIGNAL_H_ + +#if defined (__ppc__) || defined (__ppc64__) +#include "ppc/signal.h" +#elif defined (__i386__) || defined(__x86_64__) +#include "i386/signal.h" +#elif defined (__arm__) +#include "arm/signal.h" +#else +#error architecture not supported +#endif + +#endif /* _BSD_MACHINE_SIGNAL_H_ */ Index: branches/azimutz/Cleancut/i386/include/machine/byte_order.h =================================================================== --- branches/azimutz/Cleancut/i386/include/machine/byte_order.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/machine/byte_order.h (revision 885) @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2000-2007 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) 1995 NeXT Computer, Inc. + */ + +#ifndef _BSD_MACHINE_BYTE_ORDER_H_ +#define _BSD_MACHINE_BYTE_ORDER_H_ + +#include <architecture/byte_order.h> + +#endif /* _BSD_MACHINE_BYTE_ORDER_H_ */ Index: branches/azimutz/Cleancut/i386/include/machine/endian.h =================================================================== --- branches/azimutz/Cleancut/i386/include/machine/endian.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/machine/endian.h (revision 885) @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2000-2007 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 1995 NeXT Computer, Inc. All rights reserved. + */ +#ifndef _BSD_MACHINE_ENDIAN_H_ +#define _BSD_MACHINE_ENDIAN_H_ + +#if defined (__ppc__) || defined(__ppc64__) +#include "ppc/endian.h" +#elif defined (__i386__) || defined(__x86_64__) +#include "i386/endian.h" +#elif defined (__arm__) +#include "arm/endian.h" +#else +#error architecture not supported +#endif + +#endif /* _BSD_MACHINE_ENDIAN_H_ */ Index: branches/azimutz/Cleancut/i386/include/machine/_param.h =================================================================== --- branches/azimutz/Cleancut/i386/include/machine/_param.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/machine/_param.h (revision 885) @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2004-2007 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@ + */ +#if defined (__ppc__) || defined (__ppc64__) +#include "ppc/_param.h" +#elif defined (__i386__) || defined (__x86_64__) +#include "i386/_param.h" +#elif defined (__arm__) +#include "arm/_param.h" +#else +#error architecture not supported +#endif Index: branches/azimutz/Cleancut/i386/include/machine/_limits.h =================================================================== --- branches/azimutz/Cleancut/i386/include/machine/_limits.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/machine/_limits.h (revision 885) @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2004-2007 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 _BSD_MACHINE__LIMITS_H_ +#define _BSD_MACHINE__LIMITS_H_ + +#if defined (__ppc__) || defined (__ppc64__) +#include "ppc/_limits.h" +#elif defined (__i386__) || defined(__x86_64__) +#include "i386/_limits.h" +#elif defined (__arm__) +#include "arm/_limits.h" +#else +#error architecture not supported +#endif + +#endif /* _BSD_MACHINE__LIMITS_H_ */ Index: branches/azimutz/Cleancut/i386/include/machine/fasttrap_isa.h =================================================================== --- branches/azimutz/Cleancut/i386/include/machine/fasttrap_isa.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/machine/fasttrap_isa.h (revision 885) @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2000-2007 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 _BSD_MACHINE_FASTTRAP_ISA_H_ +#define _BSD_MACHINE_FASTTRAP_ISA_H_ + +#if defined (__ppc__) || defined (__ppc64__) +#include "ppc/fasttrap_isa.h" +#elif defined (__i386__) || defined(__x86_64__) +#include "i386/fasttrap_isa.h" +#elif defined (__arm__) +#include "arm/fasttrap_isa.h" +#else +#error architecture not supported +#endif + +#endif /* _BSD_MACHINE_FASTTRAP_ISA_H_ */ Index: branches/azimutz/Cleancut/i386/include/machine/param.h =================================================================== --- branches/azimutz/Cleancut/i386/include/machine/param.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/machine/param.h (revision 885) @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2000-2007 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 1995 NeXT Computer, Inc. All rights reserved. + */ +#ifndef _BSD_MACHINE_PARAM_H_ +#define _BSD_MACHINE_PARAM_H_ + +#if defined (__ppc__) || defined (__ppc64__) +#include "ppc/param.h" +#elif defined (__i386__) || defined(__x86_64__) +#include "i386/param.h" +#elif defined (__arm__) +#include "arm/param.h" +#else +#error architecture not supported +#endif + +#endif /* _BSD_MACHINE_PARAM_H_ */ Index: branches/azimutz/Cleancut/i386/include/machine/profile.h =================================================================== --- branches/azimutz/Cleancut/i386/include/machine/profile.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/machine/profile.h (revision 885) @@ -0,0 +1,46 @@ +/* + * Copyright (c) 1997-2007 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@ + */ +/* + * History : + * 29-Sep-1997 Umesh Vaishampayan + * Created. + */ +#ifndef _BSD_MACHINE_PROFILE_H_ +#define _BSD_MACHINE_PROFILE_H_ + +#if defined (__ppc__) || defined (__ppc64__) +#include "ppc/profile.h" +#elif defined (__i386__) || defined(__x86_64__) +#include "i386/profile.h" +#elif defined (__arm__) +#include "arm/profile.h" +#else +#error architecture not supported +#endif + +#endif /* _BSD_MACHINE_PROFILE_H_ */ Index: branches/azimutz/Cleancut/i386/include/machine/limits.h =================================================================== --- branches/azimutz/Cleancut/i386/include/machine/limits.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/machine/limits.h (revision 885) @@ -0,0 +1,13 @@ +/* This is the `system' limits.h, independent of any particular + compiler. GCC provides its own limits.h which can be found in + /usr/lib/gcc, although it is not very informative. + This file is public domain. */ +#if defined (__ppc__) || defined (__ppc64__) +#include <ppc/limits.h> +#elif defined (__i386__) || defined(__x86_64__) +#include <i386/limits.h> +#elif defined (__arm__) +#include <arm/limits.h> +#else +#error architecture not supported +#endif Index: branches/azimutz/Cleancut/i386/include/machine/setjmp.h =================================================================== --- branches/azimutz/Cleancut/i386/include/machine/setjmp.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/machine/setjmp.h (revision 885) @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2000-2007 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) 1995 NeXT Computer, Inc. All Rights Reserved + */ +#ifndef _MACHINE_SETJMP_H_ +#define _MACHINE_SETJMP_H_ + +#if defined (__ppc__) || defined (__ppc64__) +#include "ppc/setjmp.h" +#elif defined (__i386__) || defined(__x86_64__) +#include "i386/setjmp.h" +#elif defined (__arm__) +#include "arm/setjmp.h" +#else +#error architecture not supported +#endif + +#endif /* _MACHINE_SETJMP_H_ */ Index: branches/azimutz/Cleancut/i386/include/machine/_types.h =================================================================== --- branches/azimutz/Cleancut/i386/include/machine/_types.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/machine/_types.h (revision 885) @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2003-2007 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 _BSD_MACHINE__TYPES_H_ +#define _BSD_MACHINE__TYPES_H_ + +#if defined (__ppc__) || defined (__ppc64__) +#include "ppc/_types.h" +#elif defined (__i386__) || defined(__x86_64__) +#include "i386/_types.h" +#elif defined (__arm__) +#include "arm/_types.h" +#else +#error architecture not supported +#endif + +#endif /* _BSD_MACHINE__TYPES_H_ */ Index: branches/azimutz/Cleancut/i386/include/machine/vmparam.h =================================================================== --- branches/azimutz/Cleancut/i386/include/machine/vmparam.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/machine/vmparam.h (revision 885) @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2000-2007 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 _BSD_MACHINE_VMPARAM_H_ +#define _BSD_MACHINE_VMPARAM_H_ + +#if defined (__ppc__) || defined (__ppc64__) +#include "ppc/vmparam.h" +#elif defined (__i386__) || defined(__x86_64__) +#include "i386/vmparam.h" +#elif defined (__arm__) +#include "arm/vmparam.h" +#else +#error architecture not supported +#endif + +#endif /* _BSD_MACHINE_VMPARAM_H_ */ Index: branches/azimutz/Cleancut/i386/include/machine/types.h =================================================================== --- branches/azimutz/Cleancut/i386/include/machine/types.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/machine/types.h (revision 885) @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2000-2007 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 1995 NeXT Computer, Inc. All rights reserved. + */ +#ifndef _BSD_MACHINE_TYPES_H_ +#define _BSD_MACHINE_TYPES_H_ + +#if defined (__ppc__) || defined (__ppc64__) +#include "ppc/types.h" +#elif defined (__i386__) || defined(__x86_64__) +#include "i386/types.h" +#elif defined (__arm__) +#include "arm/types.h" +#else +#error architecture not supported +#endif + +#endif /* _BSD_MACHINE_TYPES_H_ */ Index: branches/azimutz/Cleancut/i386/include/machine/_structs.h =================================================================== --- branches/azimutz/Cleancut/i386/include/machine/_structs.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/machine/_structs.h (revision 885) @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2004-2007 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@ + */ +#if defined (__ppc__) || defined (__ppc64__) +#include "ppc/_structs.h" +#elif defined (__i386__) || defined (__x86_64__) +#include "i386/_structs.h" +#elif defined (__arm__) +#include "arm/_structs.h" +#else +#error architecture not supported +#endif Index: branches/azimutz/Cleancut/i386/include/inttypes.h =================================================================== --- branches/azimutz/Cleancut/i386/include/inttypes.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/inttypes.h (revision 885) @@ -0,0 +1,321 @@ +/* + * Copyright (c) 2000, 2001, 2002, 2003, 2004 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@ + */ + +/* + * <inttypes.h> -- Standard C header, defined in ISO/IEC 9899:1999 + * (aka "C99"), section 7.8. This defines format string conversion + * specifiers suitable for use within arguments to fprintf and fscanf + * and their ilk. + */ + +/* "C++ implementations should define these macros only when + * __STDC_FORMAT_MACROS is defined before <inttypes.h> is included." + */ +#if (!defined(__cplusplus) || defined(__STDC_FORMAT_MACROS)) && !defined(__STDC_FORMAT_MACROS_DEFINED) +#define __STDC_FORMAT_MACROS_DEFINED + +# undef __PRI_8_LENGTH_MODIFIER__ +# undef __PRI_64_LENGTH_MODIFIER__ +# undef __SCN_64_LENGTH_MODIFIER__ + +# if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__-0 > 1020 +# define __PRI_8_LENGTH_MODIFIER__ "hh" +# define __PRI_64_LENGTH_MODIFIER__ "ll" +# define __SCN_64_LENGTH_MODIFIER__ "ll" +# else +/* These could be "hh", "ll", and "ll" respectively, but that doesn't work on + 10.2, and these do. Note that there's no way to use scanf to scan a + decimal into a 'char' argument on 10.2, so "hh" is used unconditionally + and programs that use it won't work on Jaguar. */ +# define __PRI_8_LENGTH_MODIFIER__ "" /* none */ +# define __PRI_64_LENGTH_MODIFIER__ "q" +# define __SCN_64_LENGTH_MODIFIER__ "q" +# endif +# define __PRI_MAX_LENGTH_MODIFIER__ "j" +# define __SCN_MAX_LENGTH_MODIFIER__ "j" + +# define PRId8 __PRI_8_LENGTH_MODIFIER__ "d" +# define PRIi8 __PRI_8_LENGTH_MODIFIER__ "i" +# define PRIo8 __PRI_8_LENGTH_MODIFIER__ "o" +# define PRIu8 __PRI_8_LENGTH_MODIFIER__ "u" +# define PRIx8 __PRI_8_LENGTH_MODIFIER__ "x" +# define PRIX8 __PRI_8_LENGTH_MODIFIER__ "X" + +# define PRId16 "hd" +# define PRIi16 "hi" +# define PRIo16 "ho" +# define PRIu16 "hu" +# define PRIx16 "hx" +# define PRIX16 "hX" + +# define PRId32 "d" +# define PRIi32 "i" +# define PRIo32 "o" +# define PRIu32 "u" +# define PRIx32 "x" +# define PRIX32 "X" + +# define PRId64 __PRI_64_LENGTH_MODIFIER__ "d" +# define PRIi64 __PRI_64_LENGTH_MODIFIER__ "i" +# define PRIo64 __PRI_64_LENGTH_MODIFIER__ "o" +# define PRIu64 __PRI_64_LENGTH_MODIFIER__ "u" +# define PRIx64 __PRI_64_LENGTH_MODIFIER__ "x" +# define PRIX64 __PRI_64_LENGTH_MODIFIER__ "X" + +# define PRIdLEAST8 PRId8 +# define PRIiLEAST8 PRIi8 +# define PRIoLEAST8 PRIo8 +# define PRIuLEAST8 PRIu8 +# define PRIxLEAST8 PRIx8 +# define PRIXLEAST8 PRIX8 + +# define PRIdLEAST16 PRId16 +# define PRIiLEAST16 PRIi16 +# define PRIoLEAST16 PRIo16 +# define PRIuLEAST16 PRIu16 +# define PRIxLEAST16 PRIx16 +# define PRIXLEAST16 PRIX16 + +# define PRIdLEAST32 PRId32 +# define PRIiLEAST32 PRIi32 +# define PRIoLEAST32 PRIo32 +# define PRIuLEAST32 PRIu32 +# define PRIxLEAST32 PRIx32 +# define PRIXLEAST32 PRIX32 + +# define PRIdLEAST64 PRId64 +# define PRIiLEAST64 PRIi64 +# define PRIoLEAST64 PRIo64 +# define PRIuLEAST64 PRIu64 +# define PRIxLEAST64 PRIx64 +# define PRIXLEAST64 PRIX64 + +# define PRIdFAST8 PRId8 +# define PRIiFAST8 PRIi8 +# define PRIoFAST8 PRIo8 +# define PRIuFAST8 PRIu8 +# define PRIxFAST8 PRIx8 +# define PRIXFAST8 PRIX8 + +# define PRIdFAST16 PRId16 +# define PRIiFAST16 PRIi16 +# define PRIoFAST16 PRIo16 +# define PRIuFAST16 PRIu16 +# define PRIxFAST16 PRIx16 +# define PRIXFAST16 PRIX16 + +# define PRIdFAST32 PRId32 +# define PRIiFAST32 PRIi32 +# define PRIoFAST32 PRIo32 +# define PRIuFAST32 PRIu32 +# define PRIxFAST32 PRIx32 +# define PRIXFAST32 PRIX32 + +# define PRIdFAST64 PRId64 +# define PRIiFAST64 PRIi64 +# define PRIoFAST64 PRIo64 +# define PRIuFAST64 PRIu64 +# define PRIxFAST64 PRIx64 +# define PRIXFAST64 PRIX64 + +/* int32_t is 'int', but intptr_t is 'long'. */ +# define PRIdPTR "ld" +# define PRIiPTR "li" +# define PRIoPTR "lo" +# define PRIuPTR "lu" +# define PRIxPTR "lx" +# define PRIXPTR "lX" + +# define PRIdMAX __PRI_MAX_LENGTH_MODIFIER__ "d" +# define PRIiMAX __PRI_MAX_LENGTH_MODIFIER__ "i" +# define PRIoMAX __PRI_MAX_LENGTH_MODIFIER__ "o" +# define PRIuMAX __PRI_MAX_LENGTH_MODIFIER__ "u" +# define PRIxMAX __PRI_MAX_LENGTH_MODIFIER__ "x" +# define PRIXMAX __PRI_MAX_LENGTH_MODIFIER__ "X" + +# if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__-0 > 1020 +# define SCNd8 __PRI_8_LENGTH_MODIFIER__ "d" +# define SCNi8 __PRI_8_LENGTH_MODIFIER__ "i" +# define SCNo8 __PRI_8_LENGTH_MODIFIER__ "o" +# define SCNu8 __PRI_8_LENGTH_MODIFIER__ "u" +# define SCNx8 __PRI_8_LENGTH_MODIFIER__ "x" +# else +# define SCNd8 "hhd" +# define SCNi8 "hhi" +# define SCNo8 "hho" +# define SCNu8 "hhu" +# define SCNx8 "hhx" +# endif + +# define SCNd16 "hd" +# define SCNi16 "hi" +# define SCNo16 "ho" +# define SCNu16 "hu" +# define SCNx16 "hx" + +# define SCNd32 "d" +# define SCNi32 "i" +# define SCNo32 "o" +# define SCNu32 "u" +# define SCNx32 "x" + +# define SCNd64 __SCN_64_LENGTH_MODIFIER__ "d" +# define SCNi64 __SCN_64_LENGTH_MODIFIER__ "i" +# define SCNo64 __SCN_64_LENGTH_MODIFIER__ "o" +# define SCNu64 __SCN_64_LENGTH_MODIFIER__ "u" +# define SCNx64 __SCN_64_LENGTH_MODIFIER__ "x" + +# define SCNdLEAST8 SCNd8 +# define SCNiLEAST8 SCNi8 +# define SCNoLEAST8 SCNo8 +# define SCNuLEAST8 SCNu8 +# define SCNxLEAST8 SCNx8 + +# define SCNdLEAST16 SCNd16 +# define SCNiLEAST16 SCNi16 +# define SCNoLEAST16 SCNo16 +# define SCNuLEAST16 SCNu16 +# define SCNxLEAST16 SCNx16 + +# define SCNdLEAST32 SCNd32 +# define SCNiLEAST32 SCNi32 +# define SCNoLEAST32 SCNo32 +# define SCNuLEAST32 SCNu32 +# define SCNxLEAST32 SCNx32 + +# define SCNdLEAST64 SCNd64 +# define SCNiLEAST64 SCNi64 +# define SCNoLEAST64 SCNo64 +# define SCNuLEAST64 SCNu64 +# define SCNxLEAST64 SCNx64 + +# define SCNdFAST8 SCNd8 +# define SCNiFAST8 SCNi8 +# define SCNoFAST8 SCNo8 +# define SCNuFAST8 SCNu8 +# define SCNxFAST8 SCNx8 + +# define SCNdFAST16 SCNd16 +# define SCNiFAST16 SCNi16 +# define SCNoFAST16 SCNo16 +# define SCNuFAST16 SCNu16 +# define SCNxFAST16 SCNx16 + +# define SCNdFAST32 SCNd32 +# define SCNiFAST32 SCNi32 +# define SCNoFAST32 SCNo32 +# define SCNuFAST32 SCNu32 +# define SCNxFAST32 SCNx32 + +# define SCNdFAST64 SCNd64 +# define SCNiFAST64 SCNi64 +# define SCNoFAST64 SCNo64 +# define SCNuFAST64 SCNu64 +# define SCNxFAST64 SCNx64 + +# define SCNdPTR "ld" +# define SCNiPTR "li" +# define SCNoPTR "lo" +# define SCNuPTR "lu" +# define SCNxPTR "lx" + +# define SCNdMAX __SCN_MAX_LENGTH_MODIFIER__ "d" +# define SCNiMAX __SCN_MAX_LENGTH_MODIFIER__ "i" +# define SCNoMAX __SCN_MAX_LENGTH_MODIFIER__ "o" +# define SCNuMAX __SCN_MAX_LENGTH_MODIFIER__ "u" +# define SCNxMAX __SCN_MAX_LENGTH_MODIFIER__ "x" + +#endif /* if C++, then __STDC_FORMAT_MACROS enables the above macros */ + +#if !defined(_INTTYPES_H_) +#define _INTTYPES_H_ + +#include <sys/cdefs.h> /* For __BEGIN_DECLS and __END_DECLS */ +#include <_types.h> /* For __darwin_wchar_t */ +#include <stdint.h> + +#if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) + /* Translator is not ISO/IEC 9899:1999-compliant. */ +# if !defined(restrict) +# define restrict +# define __RESTRICT_KEYWORD_DEFINED__ +# endif +#endif + +__BEGIN_DECLS + + /* 7.8.2.1 */ + extern intmax_t imaxabs(intmax_t j); + + /* 7.8.2.2 */ + typedef struct { + intmax_t quot; + intmax_t rem; + } imaxdiv_t; + + extern imaxdiv_t imaxdiv(intmax_t numer, intmax_t denom); + + /* 7.8.2.3 */ + extern intmax_t strtoimax(const char * restrict nptr, char ** restrict endptr, int base); + extern uintmax_t strtoumax(const char * restrict nptr, char ** restrict endptr, int base); + +#ifndef __cplusplus /* wchar_t is a built-in type in C++ */ +# ifndef _WCHAR_T +# define _WCHAR_T + typedef __darwin_wchar_t wchar_t; +# endif /* _WCHAR_T */ +#endif /* __cplusplus */ + + /* 7.8.2.4 */ + extern intmax_t wcstoimax(const wchar_t * restrict nptr, wchar_t ** restrict endptr, int base); + extern uintmax_t wcstoumax(const wchar_t * restrict nptr, wchar_t ** restrict endptr, int base); + +/* Poison the following routines if -fshort-wchar is set */ +#if !defined(__cplusplus) && defined(__WCHAR_MAX__) && __WCHAR_MAX__ <= 0xffffU +#pragma GCC poison wcstoimax wcstoumax +#endif + +__END_DECLS + +#ifdef _USE_EXTENDED_LOCALES_ +#include <xlocale/_inttypes.h> +#endif /* _USE_EXTENDED_LOCALES_ */ + +/* + No need to #undef the __*_{8,64}_LENGTH_MODIFIER__ macros; + in fact, you can't #undef them, because later uses of any of + their dependents will *not* then do the intended substitution. + Expansion of a #define like this one: + + #define x IDENT y + + uses the cpp value of IDENT at the location where x is *expanded*, + not where it is #defined. +*/ + +#if defined(__RESTRICT_KEYWORD_DEFINED__) +# undef restrict +# undef __RESTRICT_KEYWORD_DEFINED__ +#endif + +#endif /* !_INTTYPES_H_ */ Index: branches/azimutz/Cleancut/i386/include/stdarg.h =================================================================== --- branches/azimutz/Cleancut/i386/include/stdarg.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/stdarg.h (revision 885) @@ -0,0 +1,133 @@ +/* Copyright (C) 1989, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. + + This file is part of GCC. + + GCC is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + GCC is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GCC; see the file COPYING. If not, write to + the Free Software Foundation, 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* As a special exception, if you include this header file into source + files compiled by GCC, this header file does not by itself cause + the resulting executable to be covered by the GNU General Public + License. This exception does not however invalidate any other + reasons why the executable file might be covered by the GNU General + Public License. */ + +/* + * ISO C Standard: 7.15 Variable arguments <stdarg.h> + */ + +#ifndef _STDARG_H +#ifndef _ANSI_STDARG_H_ +#ifndef __need___va_list +#define _STDARG_H +#define _ANSI_STDARG_H_ +#endif /* not __need___va_list */ +#undef __need___va_list + +/* Define __gnuc_va_list. */ + +#ifndef __GNUC_VA_LIST +#define __GNUC_VA_LIST +typedef __builtin_va_list __gnuc_va_list; +#endif + +/* Define the standard macros for the user, + if this invocation was from the user program. */ +#ifdef _STDARG_H + +#define va_start(v,l) __builtin_va_start(v,l) +#define va_end(v) __builtin_va_end(v) +#define va_arg(v,l) __builtin_va_arg(v,l) +#if !defined(__STRICT_ANSI__) || __STDC_VERSION__ + 0 >= 199900L +#define va_copy(d,s) __builtin_va_copy(d,s) +#endif +#define __va_copy(d,s) __builtin_va_copy(d,s) + +/* Define va_list, if desired, from __gnuc_va_list. */ +/* We deliberately do not define va_list when called from + stdio.h, because ANSI C says that stdio.h is not supposed to define + va_list. stdio.h needs to have access to that data type, + but must not use that name. It should use the name __gnuc_va_list, + which is safe because it is reserved for the implementation. */ + +#ifdef _HIDDEN_VA_LIST /* On OSF1, this means varargs.h is "half-loaded". */ +#undef _VA_LIST +#endif + +#ifdef _BSD_VA_LIST +#undef _BSD_VA_LIST +#endif + +#if defined(__svr4__) || (defined(_SCO_DS) && !defined(__VA_LIST)) +/* SVR4.2 uses _VA_LIST for an internal alias for va_list, + so we must avoid testing it and setting it here. + SVR4 uses _VA_LIST as a flag in stdarg.h, but we should + have no conflict with that. */ +#ifndef _VA_LIST_ +#define _VA_LIST_ +#ifdef __i860__ +#ifndef _VA_LIST +#define _VA_LIST va_list +#endif +#endif /* __i860__ */ +typedef __gnuc_va_list va_list; +#ifdef _SCO_DS +#define __VA_LIST +#endif +#endif /* _VA_LIST_ */ +#else /* not __svr4__ || _SCO_DS */ + +/* The macro _VA_LIST_ is the same thing used by this file in Ultrix. + But on BSD NET2 we must not test or define or undef it. + (Note that the comments in NET 2's ansi.h + are incorrect for _VA_LIST_--see stdio.h!) */ +#if !defined (_VA_LIST_) || defined (__BSD_NET2__) || defined (____386BSD____) || defined (__bsdi__) || defined (__sequent__) || defined (__FreeBSD__) || defined(WINNT) +/* The macro _VA_LIST_DEFINED is used in Windows NT 3.5 */ +#ifndef _VA_LIST_DEFINED +/* The macro _VA_LIST is used in SCO Unix 3.2. */ +#ifndef _VA_LIST +/* The macro _VA_LIST_T_H is used in the Bull dpx2 */ +#ifndef _VA_LIST_T_H +/* The macro __va_list__ is used by BeOS. */ +#ifndef __va_list__ +typedef __gnuc_va_list va_list; +#endif /* not __va_list__ */ +#endif /* not _VA_LIST_T_H */ +#endif /* not _VA_LIST */ +#endif /* not _VA_LIST_DEFINED */ +#if !(defined (__BSD_NET2__) || defined (____386BSD____) || defined (__bsdi__) || defined (__sequent__) || defined (__FreeBSD__)) +#define _VA_LIST_ +#endif +#ifndef _VA_LIST +#define _VA_LIST +#endif +#ifndef _VA_LIST_DEFINED +#define _VA_LIST_DEFINED +#endif +#ifndef _VA_LIST_T_H +#define _VA_LIST_T_H +#endif +#ifndef __va_list__ +#define __va_list__ +#endif + +#endif /* not _VA_LIST_, except on certain systems */ + +#endif /* not __svr4__ */ + +#endif /* _STDARG_H */ + +#endif /* not _ANSI_STDARG_H_ */ +#endif /* not _STDARG_H */ Index: branches/azimutz/Cleancut/i386/include/ctype.h =================================================================== --- branches/azimutz/Cleancut/i386/include/ctype.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/ctype.h (revision 885) @@ -0,0 +1,438 @@ +/* + * Copyright (c) 2000, 2005, 2008 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@ + */ +/* + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * This code is derived from software contributed to Berkeley by + * Paul Borman at Krystal Technologies. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)ctype.h 8.4 (Berkeley) 1/21/94 + */ + +//Begin-Libc +//#include "xlocale_private.h" +//End-Libc +#ifndef _CTYPE_H_ +#define _CTYPE_H_ + +#include <runetype.h> + +#define _CTYPE_A 0x00000100L /* Alpha */ +#define _CTYPE_C 0x00000200L /* Control */ +#define _CTYPE_D 0x00000400L /* Digit */ +#define _CTYPE_G 0x00000800L /* Graph */ +#define _CTYPE_L 0x00001000L /* Lower */ +#define _CTYPE_P 0x00002000L /* Punct */ +#define _CTYPE_S 0x00004000L /* Space */ +#define _CTYPE_U 0x00008000L /* Upper */ +#define _CTYPE_X 0x00010000L /* X digit */ +#define _CTYPE_B 0x00020000L /* Blank */ +#define _CTYPE_R 0x00040000L /* Print */ +#define _CTYPE_I 0x00080000L /* Ideogram */ +#define _CTYPE_T 0x00100000L /* Special */ +#define _CTYPE_Q 0x00200000L /* Phonogram */ +#define _CTYPE_SW0 0x20000000L /* 0 width character */ +#define _CTYPE_SW1 0x40000000L /* 1 width character */ +#define _CTYPE_SW2 0x80000000L /* 2 width character */ +#define _CTYPE_SW3 0xc0000000L /* 3 width character */ +#define _CTYPE_SWM 0xe0000000L /* Mask for screen width data */ +#define _CTYPE_SWS 30 /* Bits to shift to get width */ + +#ifdef _NONSTD_SOURCE +/* + * Backward compatibility + */ +#define _A _CTYPE_A /* Alpha */ +#define _C _CTYPE_C /* Control */ +#define _D _CTYPE_D /* Digit */ +#define _G _CTYPE_G /* Graph */ +#define _L _CTYPE_L /* Lower */ +#define _P _CTYPE_P /* Punct */ +#define _S _CTYPE_S /* Space */ +#define _U _CTYPE_U /* Upper */ +#define _X _CTYPE_X /* X digit */ +#define _B _CTYPE_B /* Blank */ +#define _R _CTYPE_R /* Print */ +#define _I _CTYPE_I /* Ideogram */ +#define _T _CTYPE_T /* Special */ +#define _Q _CTYPE_Q /* Phonogram */ +#define _SW0 _CTYPE_SW0 /* 0 width character */ +#define _SW1 _CTYPE_SW1 /* 1 width character */ +#define _SW2 _CTYPE_SW2 /* 2 width character */ +#define _SW3 _CTYPE_SW3 /* 3 width character */ +#endif /* _NONSTD_SOURCE */ + +/* + * _EXTERNALIZE_CTYPE_INLINES_ is defined in locale/nomacros.c to tell us + * to generate code for extern versions of all intermediate inline functions. + */ +#ifdef _EXTERNALIZE_CTYPE_INLINES_ +#define _USE_CTYPE_INLINE_ +#define __DARWIN_CTYPE_static_inline +#else /* !_EXTERNALIZE_CTYPE_INLINES_ */ +#define __DARWIN_CTYPE_static_inline static __inline +#endif /* !_EXTERNALIZE_CTYPE_INLINES_ */ + +/* + * _EXTERNALIZE_CTYPE_INLINES_TOP_ is defined in locale/isctype.c to tell us + * to generate code for extern versions of all top-level inline functions. + */ +#ifdef _EXTERNALIZE_CTYPE_INLINES_TOP_ +#define _USE_CTYPE_INLINE_ +#define __DARWIN_CTYPE_TOP_static_inline +#else /* !_EXTERNALIZE_CTYPE_INLINES_TOP_ */ +#define __DARWIN_CTYPE_TOP_static_inline static __inline +#endif /* _EXTERNALIZE_CTYPE_INLINES_TOP_ */ + +/* + * Use inline functions if we are allowed to and the compiler supports them. + */ +#if !defined(_DONT_USE_CTYPE_INLINE_) && \ + (defined(_USE_CTYPE_INLINE_) || defined(__GNUC__) || defined(__cplusplus)) + +/* See comments in <machine/_type.h> about __darwin_ct_rune_t. */ +__BEGIN_DECLS +unsigned long ___runetype(__darwin_ct_rune_t); +__darwin_ct_rune_t ___tolower(__darwin_ct_rune_t); +__darwin_ct_rune_t ___toupper(__darwin_ct_rune_t); +__END_DECLS + +__DARWIN_CTYPE_TOP_static_inline int +isascii(int _c) +{ + return ((_c & ~0x7F) == 0); +} + +#ifdef USE_ASCII +__DARWIN_CTYPE_static_inline int +__maskrune(__darwin_ct_rune_t _c, unsigned long _f) +{ + return _DefaultRuneLocale.__runetype[_c & 0xff] & _f; +} +//Begin-Libc +#elif defined(__LIBC__) +__DARWIN_CTYPE_static_inline int +__maskrune(__darwin_ct_rune_t _c, unsigned long _f) +{ + return ((_c < 0 || _c >= _CACHED_RUNES) ? ___runetype(_c) : + __current_locale()->__lc_ctype->_CurrentRuneLocale.__runetype[_c]) & _f; +} +//End-Libc +#else /* !USE_ASCII */ +__BEGIN_DECLS +int __maskrune(__darwin_ct_rune_t, unsigned long); +__END_DECLS +#endif /* USE_ASCII */ + +__DARWIN_CTYPE_static_inline int +__istype(__darwin_ct_rune_t _c, unsigned long _f) +{ +#ifdef USE_ASCII + return !!(__maskrune(_c, _f)); +#else /* USE_ASCII */ + return (isascii(_c) ? !!(_DefaultRuneLocale.__runetype[_c] & _f) + : !!__maskrune(_c, _f)); +#endif /* USE_ASCII */ +} + +__DARWIN_CTYPE_static_inline __darwin_ct_rune_t +__isctype(__darwin_ct_rune_t _c, unsigned long _f) +{ +#ifdef USE_ASCII + return !!(__maskrune(_c, _f)); +#else /* USE_ASCII */ + return (_c < 0 || _c >= _CACHED_RUNES) ? 0 : + !!(_DefaultRuneLocale.__runetype[_c] & _f); +#endif /* USE_ASCII */ +} + +#ifdef USE_ASCII +__DARWIN_CTYPE_static_inline __darwin_ct_rune_t +__toupper(__darwin_ct_rune_t _c) +{ + return _DefaultRuneLocale.__mapupper[_c & 0xff]; +} + +__DARWIN_CTYPE_static_inline __darwin_ct_rune_t +__tolower(__darwin_ct_rune_t _c) +{ + return _DefaultRuneLocale.__maplower[_c & 0xff]; +} +//Begin-Libc +#elif defined(__LIBC__) +/* + * We can't do what we do for __toupper_l() (check for ASCII first, then call + * ___toupper_l() otherwise) because versions of ___toupper() before Tiger + * assume c >= _CACHED_RUNES. So we are stuck making __toupper() a routine + * to hide the extended locale details, outside of Libc. + */ +__DARWIN_CTYPE_static_inline __darwin_ct_rune_t +__toupper(__darwin_ct_rune_t _c) +{ + return (_c < 0 || _c >= _CACHED_RUNES) ? ___toupper(_c) : + __current_locale()->__lc_ctype->_CurrentRuneLocale.__mapupper[_c]; +} + +__DARWIN_CTYPE_static_inline __darwin_ct_rune_t +__tolower(__darwin_ct_rune_t _c) +{ + return (_c < 0 || _c >= _CACHED_RUNES) ? ___tolower(_c) : + __current_locale()->__lc_ctype->_CurrentRuneLocale.__maplower[_c]; +} +//End-Libc +#else /* !USE_ASCII */ +__BEGIN_DECLS +__darwin_ct_rune_t __toupper(__darwin_ct_rune_t); +__darwin_ct_rune_t __tolower(__darwin_ct_rune_t); +__END_DECLS +#endif /* USE_ASCII */ + +__DARWIN_CTYPE_static_inline int +__wcwidth(__darwin_ct_rune_t _c) +{ + unsigned int _x; + + if (_c == 0) + return (0); + _x = (unsigned int)__maskrune(_c, _CTYPE_SWM|_CTYPE_R); + if ((_x & _CTYPE_SWM) != 0) + return ((_x & _CTYPE_SWM) >> _CTYPE_SWS); + return ((_x & _CTYPE_R) != 0 ? 1 : -1); +} + +#ifndef _EXTERNALIZE_CTYPE_INLINES_ + +#define _tolower(c) __tolower(c) +#define _toupper(c) __toupper(c) + +__DARWIN_CTYPE_TOP_static_inline int +isalnum(int _c) +{ + return (__istype(_c, _CTYPE_A|_CTYPE_D)); +} + +__DARWIN_CTYPE_TOP_static_inline int +isalpha(int _c) +{ + return (__istype(_c, _CTYPE_A)); +} + +__DARWIN_CTYPE_TOP_static_inline int +isblank(int _c) +{ + return (__istype(_c, _CTYPE_B)); +} + +__DARWIN_CTYPE_TOP_static_inline int +iscntrl(int _c) +{ + return (__istype(_c, _CTYPE_C)); +} + +/* ANSI -- locale independent */ +__DARWIN_CTYPE_TOP_static_inline int +isdigit(int _c) +{ + return (__isctype(_c, _CTYPE_D)); +} + +__DARWIN_CTYPE_TOP_static_inline int +isgraph(int _c) +{ + return (__istype(_c, _CTYPE_G)); +} + +__DARWIN_CTYPE_TOP_static_inline int +islower(int _c) +{ + return (__istype(_c, _CTYPE_L)); +} + +__DARWIN_CTYPE_TOP_static_inline int +isprint(int _c) +{ + return (__istype(_c, _CTYPE_R)); +} + +__DARWIN_CTYPE_TOP_static_inline int +ispunct(int _c) +{ + return (__istype(_c, _CTYPE_P)); +} + +__DARWIN_CTYPE_TOP_static_inline int +isspace(int _c) +{ + return (__istype(_c, _CTYPE_S)); +} + +__DARWIN_CTYPE_TOP_static_inline int +isupper(int _c) +{ + return (__istype(_c, _CTYPE_U)); +} + +/* ANSI -- locale independent */ +__DARWIN_CTYPE_TOP_static_inline int +isxdigit(int _c) +{ + return (__isctype(_c, _CTYPE_X)); +} + +__DARWIN_CTYPE_TOP_static_inline int +toascii(int _c) +{ + return (_c & 0x7F); +} + +__DARWIN_CTYPE_TOP_static_inline int +tolower(int _c) +{ + return (__tolower(_c)); +} + +__DARWIN_CTYPE_TOP_static_inline int +toupper(int _c) +{ + return (__toupper(_c)); +} + +#if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) +__DARWIN_CTYPE_TOP_static_inline int +digittoint(int _c) +{ + return (__maskrune(_c, 0x0F)); +} + +__DARWIN_CTYPE_TOP_static_inline int +ishexnumber(int _c) +{ + return (__istype(_c, _CTYPE_X)); +} + +__DARWIN_CTYPE_TOP_static_inline int +isideogram(int _c) +{ + return (__istype(_c, _CTYPE_I)); +} + +__DARWIN_CTYPE_TOP_static_inline int +isnumber(int _c) +{ + return (__istype(_c, _CTYPE_D)); +} + +__DARWIN_CTYPE_TOP_static_inline int +isphonogram(int _c) +{ + return (__istype(_c, _CTYPE_Q)); +} + +__DARWIN_CTYPE_TOP_static_inline int +isrune(int _c) +{ + return (__istype(_c, 0xFFFFFFF0L)); +} + +__DARWIN_CTYPE_TOP_static_inline int +isspecial(int _c) +{ + return (__istype(_c, _CTYPE_T)); +} +#endif /* !_ANSI_SOURCE && (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ +#endif /* _EXTERNALIZE_CTYPE_INLINES_ */ + +#else /* not using inlines */ + +__BEGIN_DECLS +int isalnum(int); +int isalpha(int); +int isblank(int); +int iscntrl(int); +int isdigit(int); +int isgraph(int); +int islower(int); +int isprint(int); +int ispunct(int); +int isspace(int); +int isupper(int); +int isxdigit(int); +int tolower(int); +int toupper(int); +int isascii(int); +int toascii(int); + +#if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) +int _tolower(int); +int _toupper(int); +int digittoint(int); +int ishexnumber(int); +int isideogram(int); +int isnumber(int); +int isphonogram(int); +int isrune(int); +int isspecial(int); +#endif +__END_DECLS + +#endif /* using inlines */ + +#ifdef _USE_EXTENDED_LOCALES_ +#include <xlocale/_ctype.h> +#endif /* _USE_EXTENDED_LOCALES_ */ + +#endif /* !_CTYPE_H_ */ Index: branches/azimutz/Cleancut/i386/include/errno.h =================================================================== --- branches/azimutz/Cleancut/i386/include/errno.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/errno.h (revision 885) @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2000 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@ + */ +#include <sys/errno.h> + Index: branches/azimutz/Cleancut/i386/include/sys/disk.h =================================================================== --- branches/azimutz/Cleancut/i386/include/sys/disk.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/sys/disk.h (revision 885) @@ -0,0 +1,139 @@ +/* + * Copyright (c) 1998-2006 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 _SYS_DISK_H_ +#define _SYS_DISK_H_ + +#include <stdint.h> +//#include <sys/ioctl.h> + +/* + * Definitions + * + * ioctl description + * ------------------------------------- --------------------------------------- + * DKIOCEJECT eject media + * DKIOCSYNCHRONIZECACHE flush media + * + * DKIOCFORMAT format media + * DKIOCGETFORMATCAPACITIES get media's formattable capacities + * + * DKIOCGETBLOCKSIZE get media's block size + * DKIOCGETBLOCKCOUNT get media's block count + * DKIOCGETFIRMWAREPATH get media's firmware path + * + * DKIOCISFORMATTED is media formatted? + * DKIOCISWRITABLE is media writable? + * + * DKIOCREQUESTIDLE idle media + * DKIOCDISCARD delete unused data + * + * DKIOCGETMAXBLOCKCOUNTREAD get maximum block count for reads + * DKIOCGETMAXBLOCKCOUNTWRITE get maximum block count for writes + * DKIOCGETMAXBYTECOUNTREAD get maximum byte count for reads + * DKIOCGETMAXBYTECOUNTWRITE get maximum byte count for writes + * + * DKIOCGETMAXSEGMENTCOUNTREAD get maximum segment count for reads + * DKIOCGETMAXSEGMENTCOUNTWRITE get maximum segment count for writes + * DKIOCGETMAXSEGMENTBYTECOUNTREAD get maximum segment byte count for reads + * DKIOCGETMAXSEGMENTBYTECOUNTWRITE get maximum segment byte count for writes + * + * DKIOCGETMINSEGMENTALIGNMENTBYTECOUNT get minimum segment alignment in bytes + * DKIOCGETMAXSEGMENTADDRESSABLEBITCOUNT get maximum segment width in bits + * + * DKIOCGETPHYSICALBLOCKSIZE get device's block size + * DKIOCGETCOMMANDPOOLSIZE get device's queue depth + */ + +typedef struct +{ + uint64_t offset; + uint64_t length; + + uint8_t reserved0128[16]; /* reserved, clear to zero */ +} dk_discard_t; + +typedef struct +{ + char path[128]; +} dk_firmware_path_t; + +typedef struct +{ + uint64_t blockCount; + uint32_t blockSize; + + uint8_t reserved0096[4]; /* reserved, clear to zero */ +} dk_format_capacity_t; + +typedef struct +{ + dk_format_capacity_t * capacities; + uint32_t capacitiesCount; /* use zero to probe count */ + +#ifdef __LP64__ + uint8_t reserved0096[4]; /* reserved, clear to zero */ +#else /* !__LP64__ */ + uint8_t reserved0064[8]; /* reserved, clear to zero */ +#endif /* !__LP64__ */ +} dk_format_capacities_t; + +#define DKIOCEJECT _IO('d', 21) +#define DKIOCSYNCHRONIZECACHE _IO('d', 22) + +#define DKIOCFORMAT _IOW('d', 26, dk_format_capacity_t) +#define DKIOCGETFORMATCAPACITIES _IOWR('d', 26, dk_format_capacities_t) + +#define DKIOCGETBLOCKSIZE _IOR('d', 24, uint32_t) +#define DKIOCGETBLOCKCOUNT _IOR('d', 25, uint64_t) +#define DKIOCGETFIRMWAREPATH _IOR('d', 28, dk_firmware_path_t) + +#define DKIOCISFORMATTED _IOR('d', 23, uint32_t) +#define DKIOCISWRITABLE _IOR('d', 29, uint32_t) + +#define DKIOCREQUESTIDLE _IO('d', 30) +#define DKIOCDISCARD _IOW('d', 31, dk_discard_t) + +#define DKIOCGETMAXBLOCKCOUNTREAD _IOR('d', 64, uint64_t) +#define DKIOCGETMAXBLOCKCOUNTWRITE _IOR('d', 65, uint64_t) +#define DKIOCGETMAXBYTECOUNTREAD _IOR('d', 70, uint64_t) +#define DKIOCGETMAXBYTECOUNTWRITE _IOR('d', 71, uint64_t) + +#define DKIOCGETMAXSEGMENTCOUNTREAD _IOR('d', 66, uint64_t) +#define DKIOCGETMAXSEGMENTCOUNTWRITE _IOR('d', 67, uint64_t) +#define DKIOCGETMAXSEGMENTBYTECOUNTREAD _IOR('d', 68, uint64_t) +#define DKIOCGETMAXSEGMENTBYTECOUNTWRITE _IOR('d', 69, uint64_t) + +#define DKIOCGETMINSEGMENTALIGNMENTBYTECOUNT _IOR('d', 74, uint64_t) +#define DKIOCGETMAXSEGMENTADDRESSABLEBITCOUNT _IOR('d', 75, uint64_t) + +#define DKIOCGETPHYSICALBLOCKSIZE _IOR('d', 77, uint32_t) +#define DKIOCGETCOMMANDPOOLSIZE _IOR('d', 78, uint32_t) + + +#endif /* _SYS_DISK_H_ */ Index: branches/azimutz/Cleancut/i386/include/sys/reboot.h =================================================================== --- branches/azimutz/Cleancut/i386/include/sys/reboot.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/sys/reboot.h (revision 885) @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2000-2006 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) 1995 NeXT Computer, Inc. All Rights Reserved */ +/* + * Copyright (c) 1982, 1986, 1988, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)reboot.h 8.3 (Berkeley) 12/13/94 + */ + +#ifndef _SYS_REBOOT_H_ +#define _SYS_REBOOT_H_ + +/* + * Arguments to reboot system call. + */ + +#ifdef __APPLE_API_PRIVATE +#define RB_AUTOBOOT 0 /* flags for system auto-booting itself */ + +#define RB_ASKNAME 0x01 /* ask for file name to reboot from */ +#define RB_SINGLE 0x02 /* reboot to single user only */ +#define RB_NOSYNC 0x04 /* dont sync before reboot */ +#define RB_HALT 0x08 /* don't reboot, just halt */ +#define RB_INITNAME 0x10 /* name given for /etc/init */ +#define RB_DFLTROOT 0x20 /* use compiled-in rootdev */ +#define RB_ALTBOOT 0x40 /* use /boot.old vs /boot */ +#define RB_UNIPROC 0x80 /* don't start slaves */ +#define RB_SAFEBOOT 0x100 /* booting safe */ +#define RB_UPSDELAY 0x200 /* Delays restart by 5 minutes */ +#define RB_QUICK 0x400 /* quick and ungraceful reboot with file system caches flushed*/ +#define RB_PANIC 0 /* reboot due to panic */ +#define RB_BOOT 1 /* reboot due to boot() */ + +#endif /* __APPLE_API_PRIVATE */ + +#ifdef __APPLE_API_OBSOLETE +/* + * Constants for converting boot-style device number to type, + * adaptor (uba, mba, etc), unit number and partition number. + * Type (== major device number) is in the low byte + * for backward compatibility. Except for that of the "magic + * number", each mask applies to the shifted value. + * Format: + * (4) (4) (4) (4) (8) (8) + * -------------------------------- + * |MA | AD| CT| UN| PART | TYPE | + * -------------------------------- + */ +#define B_ADAPTORSHIFT 24 +#define B_ADAPTORMASK 0x0f +#define B_ADAPTOR(val) (((val) >> B_ADAPTORSHIFT) & B_ADAPTORMASK) +#define B_CONTROLLERSHIFT 20 +#define B_CONTROLLERMASK 0xf +#define B_CONTROLLER(val) (((val)>>B_CONTROLLERSHIFT) & B_CONTROLLERMASK) +#define B_UNITSHIFT 16 +#define B_UNITMASK 0xff +#define B_UNIT(val) (((val) >> B_UNITSHIFT) & B_UNITMASK) +#define B_PARTITIONSHIFT 8 +#define B_PARTITIONMASK 0xff +#define B_PARTITION(val) (((val) >> B_PARTITIONSHIFT) & B_PARTITIONMASK) +#define B_TYPESHIFT 0 +#define B_TYPEMASK 0xff +#define B_TYPE(val) (((val) >> B_TYPESHIFT) & B_TYPEMASK) +#define B_MAGICMASK 0xf0000000 +#define B_DEVMAGIC 0xa0000000 + +#define MAKEBOOTDEV(type, adaptor, controller, unit, partition) \ + (((type) << B_TYPESHIFT) | ((adaptor) << B_ADAPTORSHIFT) | \ + ((controller) << B_CONTROLLERSHIFT) | ((unit) << B_UNITSHIFT) | \ + ((partition) << B_PARTITIONSHIFT) | B_DEVMAGIC) + +#endif /* __APPLE_API_OBSOLETE */ + + +#endif /* _SYS_REBOOT_H_ */ Index: branches/azimutz/Cleancut/i386/include/sys/_endian.h =================================================================== --- branches/azimutz/Cleancut/i386/include/sys/_endian.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/sys/_endian.h (revision 885) @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2004, 2006 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) 1995 NeXT Computer, Inc. All rights reserved. + * Copyright (c) 2000-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@ + */ +/* + * Copyright (c) 1987, 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _SYS__ENDIAN_H_ +#define _SYS__ENDIAN_H_ + +#include <sys/cdefs.h> + +/* + * Macros for network/external number representation conversion. + */ + +#if defined(lint) + +__BEGIN_DECLS +__uint16_t ntohs(__uint16_t); +__uint16_t htons(__uint16_t); +__uint32_t ntohl(__uint32_t); +__uint32_t htonl(__uint32_t); +__END_DECLS + +#elif __DARWIN_BYTE_ORDER == __DARWIN_BIG_ENDIAN + +#define ntohl(x) ((__uint32_t)(x)) +#define ntohs(x) ((__uint16_t)(x)) +#define htonl(x) ((__uint32_t)(x)) +#define htons(x) ((__uint16_t)(x)) + +#if defined(KERNEL) || (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) +#define NTOHL(x) (x) +#define NTOHS(x) (x) +#define HTONL(x) (x) +#define HTONS(x) (x) +#endif /* defined(KERNEL) || (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) */ + +#else /* __DARWIN_BYTE_ORDER == __DARWIN_LITTLE_ENDIAN */ + +#include <libkern/_OSByteOrder.h> + +#define ntohs(x) __DARWIN_OSSwapInt16(x) +#define htons(x) __DARWIN_OSSwapInt16(x) + +#define ntohl(x) __DARWIN_OSSwapInt32(x) +#define htonl(x) __DARWIN_OSSwapInt32(x) + +#if defined(KERNEL) || (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) +#define NTOHL(x) (x) = ntohl((__uint32_t)x) +#define NTOHS(x) (x) = ntohs((__uint16_t)x) +#define HTONL(x) (x) = htonl((__uint32_t)x) +#define HTONS(x) (x) = htons((__uint16_t)x) +#endif /* defined(KERNEL) || (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) */ +#endif /* __DARWIN_BYTE_ORDER */ +#endif /* !_SYS__ENDIAN_H_ */ Index: branches/azimutz/Cleancut/i386/include/sys/time.h =================================================================== --- branches/azimutz/Cleancut/i386/include/sys/time.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/sys/time.h (revision 885) @@ -0,0 +1,221 @@ +/* + * Copyright (c) 2000-2006 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) 1995 NeXT Computer, Inc. All Rights Reserved */ +/* + * Copyright (c) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)time.h 8.2 (Berkeley) 7/10/94 + */ + +#ifndef _SYS_TIME_H_ +#define _SYS_TIME_H_ + +#include <sys/cdefs.h> +#include <sys/_types.h> + +/* + * [XSI] The fd_set type shall be defined as described in <sys/select.h>. + * The timespec structure shall be defined as described in <time.h> + */ +#define __need_fd_set +#define __need_struct_timespec +#define __need_struct_timeval +#include <sys/_structs.h> + +#ifndef _TIME_T +#define _TIME_T +typedef __darwin_time_t time_t; +#endif + +#ifndef _SUSECONDS_T +#define _SUSECONDS_T +typedef __darwin_suseconds_t suseconds_t; +#endif + +/* + * Structure used as a parameter by getitimer(2) and setitimer(2) system + * calls. + */ +struct itimerval { + struct timeval it_interval; /* timer interval */ + struct timeval it_value; /* current value */ +}; + +/* + * Names of the interval timers, and structure + * defining a timer setting. + */ +#define ITIMER_REAL 0 +#define ITIMER_VIRTUAL 1 +#define ITIMER_PROF 2 + +/* + * Select uses bit masks of file descriptors in longs. These macros + * manipulate such bit fields (the filesystem macros use chars). The + * extra protection here is to permit application redefinition above + * the default size. + */ +#ifndef FD_SETSIZE +#define FD_SETSIZE __DARWIN_FD_SETSIZE +#endif /* FD_SETSIZE */ +#ifndef FD_SET +#define FD_SET(n, p) __DARWIN_FD_SET(n, p) +#endif /* FD_SET */ +#ifndef FD_CLR +#define FD_CLR(n,p) __DARWIN_FD_CLR(n, p) +#endif /* FD_CLR */ +#ifndef FD_ISSET +#define FD_ISSET(n, p) __DARWIN_FD_ISSET(n, p) +#endif /* FD_ISSET */ +#ifndef FD_ZERO +#define FD_ZERO(p) __DARWIN_FD_ZERO(p) +#endif /* FD_ZERO */ + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) + +#ifndef FD_COPY +#define FD_COPY(f, t) __DARWIN_FD_COPY(f, t) +#endif /* FD_COPY */ + +#define TIMEVAL_TO_TIMESPEC(tv, ts) { \ + (ts)->tv_sec = (tv)->tv_sec; \ + (ts)->tv_nsec = (tv)->tv_usec * 1000; \ +} +#define TIMESPEC_TO_TIMEVAL(tv, ts) { \ + (tv)->tv_sec = (ts)->tv_sec; \ + (tv)->tv_usec = (ts)->tv_nsec / 1000; \ +} + +struct timezone { + int tz_minuteswest; /* minutes west of Greenwich */ + int tz_dsttime; /* type of dst correction */ +}; +#define DST_NONE 0 /* not on dst */ +#define DST_USA 1 /* USA style dst */ +#define DST_AUST 2 /* Australian style dst */ +#define DST_WET 3 /* Western European dst */ +#define DST_MET 4 /* Middle European dst */ +#define DST_EET 5 /* Eastern European dst */ +#define DST_CAN 6 /* Canada */ + +/* Operations on timevals. */ +#define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0 +#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec) +#define timercmp(tvp, uvp, cmp) \ + (((tvp)->tv_sec == (uvp)->tv_sec) ? \ + ((tvp)->tv_usec cmp (uvp)->tv_usec) : \ + ((tvp)->tv_sec cmp (uvp)->tv_sec)) +#define timeradd(tvp, uvp, vvp) \ + do { \ + (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \ + (vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \ + if ((vvp)->tv_usec >= 1000000) { \ + (vvp)->tv_sec++; \ + (vvp)->tv_usec -= 1000000; \ + } \ + } while (0) +#define timersub(tvp, uvp, vvp) \ + do { \ + (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \ + (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \ + if ((vvp)->tv_usec < 0) { \ + (vvp)->tv_sec--; \ + (vvp)->tv_usec += 1000000; \ + } \ + } while (0) + +#define timevalcmp(l, r, cmp) timercmp(l, r, cmp) /* freebsd */ + +/* + * Getkerninfo clock information structure + */ +struct clockinfo { + int hz; /* clock frequency */ + int tick; /* micro-seconds per hz tick */ + int tickadj; /* clock skew rate for adjtime() */ + int stathz; /* statistics clock frequency */ + int profhz; /* profiling clock frequency */ +}; +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#include <time.h> +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + +__BEGIN_DECLS + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +int adjtime(const struct timeval *, struct timeval *); +int futimes(int, const struct timeval *); +int lutimes(const char *, const struct timeval *); +int settimeofday(const struct timeval *, const struct timezone *); +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + +int getitimer(int, struct itimerval *); +int gettimeofday(struct timeval * __restrict, void * __restrict); + +#include <sys/_select.h> /* select() prototype */ + +int setitimer(int, const struct itimerval * __restrict, + struct itimerval * __restrict); +int utimes(const char *, const struct timeval *); + +__END_DECLS + + +#endif /* !_SYS_TIME_H_ */ Index: branches/azimutz/Cleancut/i386/include/sys/param.h =================================================================== --- branches/azimutz/Cleancut/i386/include/sys/param.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/sys/param.h (revision 885) @@ -0,0 +1,250 @@ +/* + * Copyright (c) 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) 1995, 1997 Apple Computer, Inc. All Rights Reserved */ +/*- + * Copyright (c) 1982, 1986, 1989, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)param.h 8.3 (Berkeley) 4/4/95 + */ + +#ifndef _SYS_PARAM_H_ +#define _SYS_PARAM_H_ + +#define BSD 199506 /* System version (year & month). */ +#define BSD4_3 1 +#define BSD4_4 1 + +#define NeXTBSD 1995064 /* NeXTBSD version (year, month, release) */ +#define NeXTBSD4_0 0 /* NeXTBSD 4.0 */ + +#ifndef NULL +#define NULL __DARWIN_NULL +#endif /* ! NULL */ + +#ifndef LOCORE +#include <sys/types.h> +#endif + +/* + * Machine-independent constants (some used in following include files). + * Redefined constants are from POSIX 1003.1 limits file. + * + * MAXCOMLEN should be >= sizeof(ac_comm) (see <acct.h>) + * MAXLOGNAME should be >= UT_NAMESIZE (see <utmp.h>) + */ +#include <sys/syslimits.h> + +#define MAXCOMLEN 16 /* max command name remembered */ +#define MAXINTERP 64 /* max interpreter file name length */ +#define MAXLOGNAME 255 /* max login name length */ +#define MAXUPRC CHILD_MAX /* max simultaneous processes */ +#define NCARGS ARG_MAX /* max bytes for an exec function */ +#define NGROUPS NGROUPS_MAX /* max number groups */ +#define NOFILE 256 /* default max open files per process */ +#define NOGROUP 65535 /* marker for empty group set member */ +#define MAXHOSTNAMELEN 256 /* max hostname size */ +#define MAXDOMNAMELEN 256 /* maximum domain name length */ + +/* Machine type dependent parameters. */ +#include <i386/param.h> + +/* More types and definitions used throughout the kernel. */ +#include <limits.h> + +/* + * Priorities. Note that with 32 run queues, differences less than 4 are + * insignificant. + */ +#define PSWP 0 +#define PVM 4 +#define PINOD 8 +#define PRIBIO 16 +#define PVFS 20 +#define PZERO 22 /* No longer magic, shouldn't be here. XXX */ +#define PSOCK 24 +#define PWAIT 32 +#define PLOCK 36 +#define PPAUSE 40 +#define PUSER 50 +#define MAXPRI 127 /* Priorities range from 0 through MAXPRI. */ + +#define PRIMASK 0x0ff +#define PCATCH 0x100 /* OR'd with pri for tsleep to check signals */ +#define PTTYBLOCK 0x200 /* for tty SIGTTOU and SIGTTIN blocking */ +#define PDROP 0x400 /* OR'd with pri to stop re-aquistion of mutex upon wakeup */ +#define PSPIN 0x800 /* OR'd with pri to require mutex in spin mode upon wakeup */ + +#define NBPW sizeof(int) /* number of bytes per word (integer) */ + +#define CMASK 022 /* default file mask: S_IWGRP|S_IWOTH */ +#define NODEV (dev_t)(-1) /* non-existent device */ + +/* + * Clustering of hardware pages on machines with ridiculously small + * page sizes is done here. The paging subsystem deals with units of + * CLSIZE pte's describing NBPG (from machine/param.h) pages each. + */ +#define CLBYTES (CLSIZE*NBPG) +#define CLOFSET (CLSIZE*NBPG-1) /* for clusters, like PGOFSET */ +#define claligned(x) ((((int)(x))&CLOFSET)==0) +#define CLOFF CLOFSET +#define CLSHIFT (PGSHIFT+CLSIZELOG2) + +#if CLSIZE==1 +#define clbase(i) (i) +#define clrnd(i) (i) +#else +/* Give the base virtual address (first of CLSIZE). */ +#define clbase(i) ((i) &~ (CLSIZE-1)) +/* Round a number of clicks up to a whole cluster. */ +#define clrnd(i) (((i) + (CLSIZE-1)) &~ (CLSIZE-1)) +#endif + +#define CBLOCK 64 /* Clist block size, must be a power of 2. */ +#define CBQSIZE (CBLOCK/NBBY) /* Quote bytes/cblock - can do better. */ + /* Data chars/clist. */ +#define CBSIZE (CBLOCK - sizeof(struct cblock *) - CBQSIZE) +#define CROUND (CBLOCK - 1) /* Clist rounding. */ + +/* + * File system parameters and macros. + * + * The file system is made out of blocks of at most MAXPHYS units, with + * smaller units (fragments) only in the last direct block. MAXBSIZE + * primarily determines the size of buffers in the buffer pool. It may be + * made larger than MAXPHYS without any effect on existing file systems; + * however making it smaller may make some file systems unmountable. + * We set this to track the value of (MAX_UPL_TRANSFER*PAGE_SIZE) from + * osfmk/mach/memory_object_types.h to bound it at the maximum UPL size. + */ +#define MAXBSIZE (256 * 4096) +#define MAXPHYSIO MAXPHYS +#define MAXFRAG 8 + +#define MAXPHYSIO_WIRED (16 * 1024 * 1024) + +/* + * MAXPATHLEN defines the longest permissable path length after expanding + * symbolic links. It is used to allocate a temporary buffer from the buffer + * pool in which to do the name expansion, hence should be a power of two, + * and must be less than or equal to MAXBSIZE. MAXSYMLINKS defines the + * maximum number of symbolic links that may be expanded in a path name. + * It should be set high enough to allow all legitimate uses, but halt + * infinite loops reasonably quickly. + */ +#define MAXPATHLEN PATH_MAX +#define MAXSYMLINKS 32 + +/* Bit map related macros. */ +#define setbit(a,i) (((char *)(a))[(i)/NBBY] |= 1<<((i)%NBBY)) +#define clrbit(a,i) (((char *)(a))[(i)/NBBY] &= ~(1<<((i)%NBBY))) +#define isset(a,i) (((char *)(a))[(i)/NBBY] & (1<<((i)%NBBY))) +#define isclr(a,i) ((((char *)(a))[(i)/NBBY] & (1<<((i)%NBBY))) == 0) + +/* Macros for counting and rounding. */ +#ifndef howmany +#define howmany(x, y) ((((x) % (y)) == 0) ? ((x) / (y)) : (((x) / (y)) + 1)) +#endif +#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) +#define powerof2(x) ((((x)-1)&(x))==0) + +/* Macros for min/max. */ +#ifndef MIN +#define MIN(a,b) (((a)<(b))?(a):(b)) +#endif /* MIN */ +#ifndef MAX +#define MAX(a,b) (((a)>(b))?(a):(b)) +#endif /* MAX */ + +/* + * Constants for setting the parameters of the kernel memory allocator. + * + * 2 ** MINBUCKET is the smallest unit of memory that will be + * allocated. It must be at least large enough to hold a pointer. + * + * Units of memory less or equal to MAXALLOCSAVE will permanently + * allocate physical memory; requests for these size pieces of + * memory are quite fast. Allocations greater than MAXALLOCSAVE must + * always allocate and free physical memory; requests for these + * size allocations should be done infrequently as they will be slow. + * + * Constraints: CLBYTES <= MAXALLOCSAVE <= 2 ** (MINBUCKET + 14), and + * MAXALLOCSIZE must be a power of two. + */ +#define MINBUCKET 4 /* 4 => min allocation of 16 bytes */ +#define MAXALLOCSAVE (2 * CLBYTES) + +/* + * Scale factor for scaled integers used to count %cpu time and load avgs. + * + * The number of CPU `tick's that map to a unique `%age' can be expressed + * by the formula (1 / (2 ^ (FSHIFT - 11))). The maximum load average that + * can be calculated (assuming 32 bits) can be closely approximated using + * the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15). + * + * For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age', + * FSHIFT must be at least 11; this gives us a maximum load avg of ~1024. + */ +#define FSHIFT 11 /* bits to right of fixed binary point */ +#define FSCALE (1<<FSHIFT) + +#endif /* _SYS_PARAM_H_ */ Index: branches/azimutz/Cleancut/i386/include/sys/syslimits.h =================================================================== --- branches/azimutz/Cleancut/i386/include/sys/syslimits.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/sys/syslimits.h (revision 885) @@ -0,0 +1,117 @@ +/* + * Copyright (c) 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@ + */ +/* $NetBSD: syslimits.h,v 1.15 1997/06/25 00:48:09 lukem Exp $ */ + +/* + * Copyright (c) 1988, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)syslimits.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _SYS_SYSLIMITS_H_ +#define _SYS_SYSLIMITS_H_ + +#include <sys/cdefs.h> + +#if !defined(_ANSI_SOURCE) +/* + * Note: CHILD_MAX *must* be less than hard_maxproc, which is set at + * compile time; you *cannot* set it higher than the hard limit!! + */ +#define ARG_MAX (256 * 1024) /* max bytes for an exec function */ +#define CHILD_MAX 266 /* max simultaneous processes */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define GID_MAX 2147483647U /* max value for a gid_t (2^31-2) */ +#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ +#define LINK_MAX 32767 /* max file link count */ +#define MAX_CANON 1024 /* max bytes in term canon input line */ +#define MAX_INPUT 1024 /* max bytes in terminal input */ +#define NAME_MAX 255 /* max bytes in a file name */ +#define NGROUPS_MAX 16 /* max supplemental group id's */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define UID_MAX 2147483647U /* max value for a uid_t (2^31-2) */ + +#define OPEN_MAX 10240 /* max open files per process - todo, make a config option? */ + +#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ +#define PATH_MAX 1024 /* max bytes in pathname */ +#define PIPE_BUF 512 /* max bytes for atomic pipe writes */ + +#define BC_BASE_MAX 99 /* max ibase/obase values in bc(1) */ +#define BC_DIM_MAX 2048 /* max array elements in bc(1) */ +#define BC_SCALE_MAX 99 /* max scale value in bc(1) */ +#define BC_STRING_MAX 1000 /* max const string length in bc(1) */ +#define CHARCLASS_NAME_MAX 14 /* max character class name size */ +#define COLL_WEIGHTS_MAX 2 /* max weights for order keyword */ +#define EQUIV_CLASS_MAX 2 +#define EXPR_NEST_MAX 32 /* max expressions nested in expr(1) */ +#define LINE_MAX 2048 /* max bytes in an input line */ +#define RE_DUP_MAX 255 /* max RE's in interval notation */ + +#if __DARWIN_UNIX03 +#define NZERO 20 /* default priority [XSI] */ + /* = ((PRIO_MAX - PRIO_MIN) / 2) + 1 */ + /* range: 0 - 39 [(2 * NZERO) - 1] */ + /* 0 is not actually used */ +#else /* !__DARWIN_UNIX03 */ +#define NZERO 0 /* default priority */ + /* range: -20 - 20 */ + /* (PRIO_MIN - PRIO_MAX) */ +#endif /* __DARWIN_UNIX03 */ +#endif /* !_ANSI_SOURCE */ + +#endif /* !_SYS_SYSLIMITS_H_ */ Index: branches/azimutz/Cleancut/i386/include/sys/appleapiopts.h =================================================================== --- branches/azimutz/Cleancut/i386/include/sys/appleapiopts.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/sys/appleapiopts.h (revision 885) @@ -0,0 +1,62 @@ +/* + * Copyright (c) 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@ + */ + +#ifndef __SYS_APPLEAPIOPTS_H__ +#define __SYS_APPLEAPIOPTS_H__ + + +#ifndef __APPLE_API_STANDARD +#define __APPLE_API_STANDARD +#endif /* __APPLE_API_STANDARD */ + +#ifndef __APPLE_API_STABLE +#define __APPLE_API_STABLE +#endif /* __APPLE_API_STABLE */ + +#ifndef __APPLE_API_STRICT_CONFORMANCE + +#ifndef __APPLE_API_EVOLVING +#define __APPLE_API_EVOLVING +#endif /* __APPLE_API_EVOLVING */ + +#ifndef __APPLE_API_UNSTABLE +#define __APPLE_API_UNSTABLE +#endif /* __APPLE_API_UNSTABLE */ + +#ifndef __APPLE_API_PRIVATE +#define __APPLE_API_PRIVATE +#endif /* __APPLE_API_PRIVATE */ + +#ifndef __APPLE_API_OBSOLETE +#define __APPLE_API_OBSOLETE +#endif /* __APPLE_API_OBSOLETE */ + +#endif /* __APPLE_API_STRICT_CONFORMANCE */ + +#endif /* __SYS_APPLEAPIOPTS_H__ */ + Index: branches/azimutz/Cleancut/i386/include/sys/_types.h =================================================================== --- branches/azimutz/Cleancut/i386/include/sys/_types.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/sys/_types.h (revision 885) @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2003-2007 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 _SYS__TYPES_H_ +#define _SYS__TYPES_H_ + +#include <sys/cdefs.h> +#include <machine/_types.h> + +/* + * Type definitions; takes common type definitions that must be used + * in multiple header files due to [XSI], removes them from the system + * space, and puts them in the implementation space. + */ + +#ifdef __cplusplus +#ifdef __GNUG__ +#define __DARWIN_NULL __null +#else /* ! __GNUG__ */ +#ifdef __LP64__ +#define __DARWIN_NULL (0L) +#else /* !__LP64__ */ +#define __DARWIN_NULL 0 +#endif /* __LP64__ */ +#endif /* __GNUG__ */ +#else /* ! __cplusplus */ +#define __DARWIN_NULL ((void *)0) +#endif /* __cplusplus */ + +typedef __int64_t __darwin_blkcnt_t; /* total blocks */ +typedef __int32_t __darwin_blksize_t; /* preferred block size */ +typedef __int32_t __darwin_dev_t; /* dev_t */ +typedef unsigned int __darwin_fsblkcnt_t; /* Used by statvfs and fstatvfs */ +typedef unsigned int __darwin_fsfilcnt_t; /* Used by statvfs and fstatvfs */ +typedef __uint32_t __darwin_gid_t; /* [???] process and group IDs */ +typedef __uint32_t __darwin_id_t; /* [XSI] pid_t, uid_t, or gid_t*/ +typedef __uint64_t __darwin_ino64_t; /* [???] Used for 64 bit inodes */ +#if __DARWIN_64_BIT_INO_T +typedef __darwin_ino64_t __darwin_ino_t; /* [???] Used for inodes */ +#else /* !__DARWIN_64_BIT_INO_T */ +typedef __uint32_t __darwin_ino_t; /* [???] Used for inodes */ +#endif /* __DARWIN_64_BIT_INO_T */ +typedef __darwin_natural_t __darwin_mach_port_name_t; /* Used by mach */ +typedef __darwin_mach_port_name_t __darwin_mach_port_t; /* Used by mach */ +typedef __uint16_t __darwin_mode_t; /* [???] Some file attributes */ +typedef __int64_t __darwin_off_t; /* [???] Used for file sizes */ +#ifndef _OFF_T +#define _OFF_T +typedef __darwin_off_t off_t; +#endif +typedef __int32_t __darwin_pid_t; /* [???] process and group IDs */ +typedef __uint32_t __darwin_sigset_t; /* [???] signal set */ +typedef __int32_t __darwin_suseconds_t; /* [???] microseconds */ +typedef __uint32_t __darwin_uid_t; /* [???] user IDs */ +typedef __uint32_t __darwin_useconds_t; /* [???] microseconds */ +typedef unsigned char __darwin_uuid_t[16]; +typedef char __darwin_uuid_string_t[37]; + +#endif /* _SYS__TYPES_H_ */ Index: branches/azimutz/Cleancut/i386/include/sys/types.h =================================================================== --- branches/azimutz/Cleancut/i386/include/sys/types.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/sys/types.h (revision 885) @@ -0,0 +1,239 @@ +/* + * Copyright (c) 2000-2008 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) 1995 NeXT Computer, Inc. All Rights Reserved */ +/* + * Copyright (c) 1982, 1986, 1991, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)types.h 8.4 (Berkeley) 1/21/94 + */ + +#ifndef _SYS_TYPES_H_ +#define _SYS_TYPES_H_ + +#ifndef __ASSEMBLER__ +#include <sys/cdefs.h> + +/* Machine type dependent parameters. */ +#include <machine/types.h> +#include <sys/_types.h> +#include <machine/endian.h> + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +typedef unsigned char u_char; +typedef unsigned short u_short; +typedef unsigned int u_int; +#ifndef _U_LONG +typedef unsigned long u_long; +#define _U_LONG +#endif +typedef unsigned short ushort; /* Sys V compatibility */ +typedef unsigned int uint; /* Sys V compatibility */ +#endif + +typedef u_int64_t u_quad_t; /* quads */ +typedef int64_t quad_t; +typedef quad_t * qaddr_t; + +typedef char * caddr_t; /* core address */ +typedef int32_t daddr_t; /* disk address */ + +typedef u_int32_t fixpt_t; /* fixed point number */ + + +#ifndef _IN_ADDR_T +#define _IN_ADDR_T +typedef __uint32_t in_addr_t; /* base type for internet address */ +#endif + +#ifndef _IN_PORT_T +#define _IN_PORT_T +typedef __uint16_t in_port_t; +#endif + + +#ifndef _KEY_T +#define _KEY_T +typedef __int32_t key_t; /* IPC key (for Sys V IPC) */ +#endif + +#ifndef _NLINK_T +typedef __uint16_t nlink_t; /* link count */ +#define _NLINK_T +#endif + +typedef int32_t segsz_t; /* segment size */ +typedef int32_t swblk_t; /* swap offset */ + + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +/* Major, minor numbers, dev_t's. */ +#if defined(__cplusplus) +/* + * These lowercase macros tend to match member functions in some C++ code, + * so for C++, we must use inline functions instead. + */ + +static inline __int32_t major(__uint32_t _x) +{ + return (__int32_t)(((__uint32_t)_x >> 24) & 0xff); +} + +static inline __int32_t minor(__uint32_t _x) +{ + return (__int32_t)((_x) & 0xffffff); +} +#else /* !__cplusplus */ + +#define major(x) ((int32_t)(((u_int32_t)(x) >> 24) & 0xff)) +#define minor(x) ((int32_t)((x) & 0xffffff)) + +#endif /* !__cplusplus */ +#endif /* !_POSIX_C_SOURCE */ + +#ifndef _CLOCK_T +#define _CLOCK_T +typedef __darwin_clock_t clock_t; +#endif + +#ifndef _SIZE_T +#define _SIZE_T +/* DO NOT REMOVE THIS COMMENT: fixincludes needs to see + * _GCC_SIZE_T */ +typedef __darwin_size_t size_t; +#endif + +#ifndef _SSIZE_T +#define _SSIZE_T +typedef __darwin_ssize_t ssize_t; +#endif + +#ifndef _TIME_T +#define _TIME_T +typedef __darwin_time_t time_t; +#endif + + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +/* + * This code is present here in order to maintain historical backward + * compatability, and is intended to be removed at some point in the + * future; please include <sys/select.h> instead. + */ +#define __need_fd_set +#include <sys/_structs.h> + +#define NBBY __DARWIN_NBBY /* bits in a byte */ +#define NFDBITS __DARWIN_NFDBITS /* bits per mask */ +#define howmany(x, y) __DARWIN_howmany(x, y) /* # y's == x bits? */ +typedef __int32_t fd_mask; + +/* + * Select uses bit masks of file descriptors in longs. These macros + * manipulate such bit fields (the filesystem macros use chars). The + * extra protection here is to permit application redefinition above + * the default size. + */ +#ifndef FD_SETSIZE +#define FD_SETSIZE __DARWIN_FD_SETSIZE +#endif /* FD_SETSIZE */ +#ifndef FD_SET +#define FD_SET(n, p) __DARWIN_FD_SET(n, p) +#endif /* FD_SET */ +#ifndef FD_CLR +#define FD_CLR(n, p) __DARWIN_FD_CLR(n, p) +#endif /* FD_CLR */ +#ifndef FD_ISSET +#define FD_ISSET(n, p) __DARWIN_FD_ISSET(n, p) +#endif /* FD_ISSET */ +#ifndef FD_ZERO +#define FD_ZERO(p) __DARWIN_FD_ZERO(p) +#endif /* FD_ZERO */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#ifndef FD_COPY +#define FD_COPY(f, t) __DARWIN_FD_COPY(f, t) +#endif /* FD_COPY */ +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + + +#if defined(__STDC__) && defined(KERNEL) +/* + * Forward structure declarations for function prototypes. We include the + * common structures that cross subsystem boundaries here; others are mostly + * used in the same place that the structure is defined. + */ +struct proc; +struct pgrp; +struct ucred; +struct rusage; +struct file; +struct buf; +struct tty; +struct uio; +#endif + +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ +#endif /* __ASSEMBLER__ */ + + + + +#endif /* !_SYS_TYPES_H_ */ Index: branches/azimutz/Cleancut/i386/include/sys/kernel_types.h =================================================================== --- branches/azimutz/Cleancut/i386/include/sys/kernel_types.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/sys/kernel_types.h (revision 885) @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2004-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 _KERN_SYS_KERNELTYPES_H_ +#define _KERN_SYS_KERNELTYPES_H_ + +#include <sys/cdefs.h> +#include <sys/types.h> +#include <stdint.h> + +#ifdef BSD_BUILD +/* Macros(?) to clear/set/test flags. */ +#define SET(t, f) (t) |= (f) +#define CLR(t, f) (t) &= ~(f) +#define ISSET(t, f) ((t) & (f)) +#endif + + +typedef int errno_t; +typedef int64_t daddr64_t; + +#ifndef BSD_BUILD +struct buf; +typedef struct buf * buf_t; + +struct file; +typedef struct file * file_t; + +#ifndef __LP64__ +struct ucred; +typedef struct ucred * ucred_t; +#endif + +struct mount; +typedef struct mount * mount_t; + +struct vnode; +typedef struct vnode * vnode_t; + +struct proc; +typedef struct proc * proc_t; + +struct uio; +typedef struct uio * uio_t; + +struct vfs_context; +typedef struct vfs_context * vfs_context_t; + +struct vfstable; +typedef struct vfstable * vfstable_t; + +struct __ifnet; +struct __mbuf; +struct __pkthdr; +struct __socket; +struct __sockopt; +struct __ifaddr; +struct __ifmultiaddr; +struct __ifnet_filter; +struct __rtentry; +struct __if_clone; + +typedef struct __ifnet* ifnet_t; +typedef struct __mbuf* mbuf_t; +typedef struct __pkthdr* pkthdr_t; +typedef struct __socket* socket_t; +typedef struct __sockopt* sockopt_t; +typedef struct __ifaddr* ifaddr_t; +typedef struct __ifmultiaddr* ifmultiaddr_t; +typedef struct __ifnet_filter* interface_filter_t; +typedef struct __rtentry* route_t; +typedef struct __if_clone* if_clone_t; + +#else /* BSD_BUILD */ + +typedef struct buf * buf_t; +typedef struct file * file_t; +#ifndef __LP64__ +typedef struct ucred * ucred_t; +#endif +typedef struct mount * mount_t; +typedef struct vnode * vnode_t; +typedef struct proc * proc_t; +typedef struct uio * uio_t; +typedef struct user_iovec * user_iovec_t; +typedef struct vfs_context * vfs_context_t; +typedef struct vfstable * vfstable_t; + + +#endif /* !BSD_BUILD */ + +#ifndef _KAUTH_GUID +#define _KAUTH_GUID +/* Apple-style globally unique identifier */ +typedef struct { +#define KAUTH_GUID_SIZE 16 /* 128-bit identifier */ + unsigned char g_guid[KAUTH_GUID_SIZE]; +} guid_t; +#define _GUID_T +#endif /* _KAUTH_GUID */ + +#ifndef _KAUTH_ACE +#define _KAUTH_ACE +struct kauth_ace; +typedef struct kauth_ace * kauth_ace_t; +#endif +#ifndef _KAUTH_ACL +#define _KAUTH_ACL +struct kauth_acl; +typedef struct kauth_acl * kauth_acl_t; +#endif +#ifndef _KAUTH_FILESEC +#define _KAUTH_FILESEC +struct kauth_filesec; +typedef struct kauth_filesec * kauth_filesec_t; +#endif + +#endif /* !_KERN_SYS_KERNELTYPES_H_ */ Index: branches/azimutz/Cleancut/i386/include/sys/unistd.h =================================================================== --- branches/azimutz/Cleancut/i386/include/sys/unistd.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/sys/unistd.h (revision 885) @@ -0,0 +1,181 @@ +/* + * Copyright (c) 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) 1995 NeXT Computer, Inc. All Rights Reserved */ +/* + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)unistd.h 8.2 (Berkeley) 1/7/94 + */ + +#ifndef _SYS_UNISTD_H_ +#define _SYS_UNISTD_H_ + +#include <sys/cdefs.h> + +/* + * Although we have saved user/group IDs, we do not use them in setuid + * as described in POSIX 1003.1, because the feature does not work for + * root. We use the saved IDs in seteuid/setegid, which are not currently + * part of the POSIX 1003.1 specification. + */ +#ifdef _NOT_AVAILABLE +#define _POSIX_SAVED_IDS /* saved set-user-ID and set-group-ID */ +#endif + +#define _POSIX_VERSION 200112L +#define _POSIX2_VERSION 200112L + +/* execution-time symbolic constants */ + /* may disable terminal special characters */ +#ifndef _POSIX_VDISABLE +#define _POSIX_VDISABLE ((unsigned char)'\377') +#endif + +#define _POSIX_THREAD_KEYS_MAX 128 + +/* access function */ +#define F_OK 0 /* test for existence of file */ +#define X_OK (1<<0) /* test for execute or search permission */ +#define W_OK (1<<1) /* test for write permission */ +#define R_OK (1<<2) /* test for read permission */ + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +/* + * Extended access functions. + * Note that we depend on these matching the definitions in sys/kauth.h, + * but with the bits shifted left by 8. + */ +#define _READ_OK (1<<9) /* read file data / read directory */ +#define _WRITE_OK (1<<10) /* write file data / add file to directory */ +#define _EXECUTE_OK (1<<11) /* execute file / search in directory*/ +#define _DELETE_OK (1<<12) /* delete file / delete directory */ +#define _APPEND_OK (1<<13) /* append to file / add subdirectory to directory */ +#define _RMFILE_OK (1<<14) /* - / remove file from directory */ +#define _RATTR_OK (1<<15) /* read basic attributes */ +#define _WATTR_OK (1<<16) /* write basic attributes */ +#define _REXT_OK (1<<17) /* read extended attributes */ +#define _WEXT_OK (1<<18) /* write extended attributes */ +#define _RPERM_OK (1<<19) /* read permissions */ +#define _WPERM_OK (1<<20) /* write permissions */ +#define _CHOWN_OK (1<<21) /* change ownership */ + +#define _ACCESS_EXTENDED_MASK (_READ_OK | _WRITE_OK | _EXECUTE_OK | \ + _DELETE_OK | _APPEND_OK | \ + _RMFILE_OK | _REXT_OK | \ + _WEXT_OK | _RATTR_OK | _WATTR_OK | _RPERM_OK | \ + _WPERM_OK | _CHOWN_OK) +#endif + +/* whence values for lseek(2) */ +#ifndef SEEK_SET +#define SEEK_SET 0 /* set file offset to offset */ +#define SEEK_CUR 1 /* set file offset to current plus offset */ +#define SEEK_END 2 /* set file offset to EOF plus offset */ +#endif /* !SEEK_SET */ + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +/* whence values for lseek(2); renamed by POSIX 1003.1 */ +#define L_SET SEEK_SET +#define L_INCR SEEK_CUR +#define L_XTND SEEK_END +#endif + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +struct accessx_descriptor { + unsigned int ad_name_offset; + int ad_flags; + int ad_pad[2]; +}; +#define ACCESSX_MAX_DESCRIPTORS 100 +#define ACCESSX_MAX_TABLESIZE (16 * 1024) +#endif + +/* configurable pathname variables */ +#define _PC_LINK_MAX 1 +#define _PC_MAX_CANON 2 +#define _PC_MAX_INPUT 3 +#define _PC_NAME_MAX 4 +#define _PC_PATH_MAX 5 +#define _PC_PIPE_BUF 6 +#define _PC_CHOWN_RESTRICTED 7 +#define _PC_NO_TRUNC 8 +#define _PC_VDISABLE 9 + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define _PC_NAME_CHARS_MAX 10 +#define _PC_CASE_SENSITIVE 11 +#define _PC_CASE_PRESERVING 12 +#define _PC_EXTENDED_SECURITY_NP 13 +#define _PC_AUTH_OPAQUE_NP 14 +#endif + +#define _PC_2_SYMLINKS 15 /* Symlink supported in directory */ +#define _PC_ALLOC_SIZE_MIN 16 /* Minimum storage actually allocated */ +#define _PC_ASYNC_IO 17 /* Async I/O [AIO] supported? */ +#define _PC_FILESIZEBITS 18 /* # of bits to represent file size */ +#define _PC_PRIO_IO 19 /* Priority I/O [PIO] supported? */ +#define _PC_REC_INCR_XFER_SIZE 20 /* Recommended increment for next two */ +#define _PC_REC_MAX_XFER_SIZE 21 /* Recommended max file transfer size */ +#define _PC_REC_MIN_XFER_SIZE 22 /* Recommended min file transfer size */ +#define _PC_REC_XFER_ALIGN 23 /* Recommended buffer alignment */ +#define _PC_SYMLINK_MAX 24 /* Max # of bytes in symlink name */ +#define _PC_SYNC_IO 25 /* Sync I/O [SIO] supported? */ + +/* configurable system strings */ +#define _CS_PATH 1 + +#endif /* !_SYS_UNISTD_H_ */ Index: branches/azimutz/Cleancut/i386/include/sys/_structs.h =================================================================== --- branches/azimutz/Cleancut/i386/include/sys/_structs.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/sys/_structs.h (revision 885) @@ -0,0 +1,236 @@ +/* + * Copyright (c) 2004-2006 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@ + */ + +#include <sys/cdefs.h> + +#ifdef __need_ucontext_t +#ifndef __need_struct_ucontext +#define __need_struct_ucontext +#endif /* __need_struct_ucontext */ +#endif /* __need_ucontext_t */ + +#ifdef __need_ucontext64_t +#ifndef __need_struct_ucontext64 +#define __need_struct_ucontext64 +#endif /* __need_struct_ucontext64 */ +#endif /* __need_ucontext64_t */ + +#ifdef __need_struct_ucontext +#ifndef __need_struct_mcontext +#define __need_struct_mcontext +#endif /* __need_struct_mcontext */ +#endif /* __need_struct_ucontext */ + +#ifdef __need_struct_ucontext64 +#ifndef __need_struct_mcontext64 +#define __need_struct_mcontext64 +#endif /* __need_struct_mcontext64 */ +#endif /* __need_struct_ucontext64 */ + +#if defined(__need_struct_mcontext) || defined(__need_struct_mcontext64) +#include <machine/_structs.h> +#endif /* __need_struct_mcontext || __need_struct_mcontext64 */ + +#if defined(__need_stack_t) || defined(__need_struct_ucontext) || defined(__need_struct_ucontext64) +#ifndef __need_struct_sigaltstack +#define __need_struct_sigaltstack +#endif /* __need_struct_sigaltstack */ +#endif /* __need_stack_t || __need_struct_ucontext || __need_struct_ucontext64 */ + +#ifdef __need_struct_sigaltstack +#undef __need_struct_sigaltstack +/* Structure used in sigaltstack call. */ +#ifndef _STRUCT_SIGALTSTACK +#if __DARWIN_UNIX03 +#define _STRUCT_SIGALTSTACK struct __darwin_sigaltstack +#else /* !__DARWIN_UNIX03 */ +#define _STRUCT_SIGALTSTACK struct sigaltstack +#endif /* __DARWIN_UNIX03 */ +_STRUCT_SIGALTSTACK +{ + void *ss_sp; /* signal stack base */ + __darwin_size_t ss_size; /* signal stack length */ + int ss_flags; /* SA_DISABLE and/or SA_ONSTACK */ +}; +#endif /* _STRUCT_SIGALTSTACK */ +#endif /* __need_struct_sigaltstack */ + +#ifdef __need_struct_timespec +#undef __need_struct_timespec +#ifndef _STRUCT_TIMESPEC +#define _STRUCT_TIMESPEC struct timespec +_STRUCT_TIMESPEC +{ + __darwin_time_t tv_sec; + long tv_nsec; +}; +#endif /* _STRUCT_TIMESPEC */ +#endif /* __need_struct_timespec */ + +#ifdef __need_struct_timeval +#undef __need_struct_timeval +#ifndef _STRUCT_TIMEVAL +#define _STRUCT_TIMEVAL struct timeval +_STRUCT_TIMEVAL +{ + __darwin_time_t tv_sec; /* seconds */ + __darwin_suseconds_t tv_usec; /* and microseconds */ +}; +#endif /* _STRUCT_TIMEVAL */ +#endif /* __need_struct_timeval */ + +#ifdef __need_struct_timeval32 +#undef __need_struct_timeval32 +#ifndef _STRUCT_TIMEVAL32 +#define _STRUCT_TIMEVAL32 struct timeval32 +_STRUCT_TIMEVAL32 +{ + __int32_t tv_sec; /* seconds */ + __int32_t tv_usec; /* and microseconds */ +}; +#endif /* _STRUCT_TIMEVAL32 */ +#endif /* __need_struct_timeval32 */ + +#ifdef __need_struct_ucontext +#undef __need_struct_ucontext +#ifndef _STRUCT_UCONTEXT +#if __DARWIN_UNIX03 +#define _STRUCT_UCONTEXT struct __darwin_ucontext +#else /* !__DARWIN_UNIX03 */ +#define _STRUCT_UCONTEXT struct ucontext +#endif /* __DARWIN_UNIX03 */ +_STRUCT_UCONTEXT +{ + int uc_onstack; + __darwin_sigset_t uc_sigmask; /* signal mask used by this context */ + _STRUCT_SIGALTSTACK uc_stack; /* stack used by this context */ + _STRUCT_UCONTEXT *uc_link; /* pointer to resuming context */ + __darwin_size_t uc_mcsize; /* size of the machine context passed in */ + _STRUCT_MCONTEXT *uc_mcontext; /* pointer to machine specific context */ +#ifdef _XOPEN_SOURCE + _STRUCT_MCONTEXT __mcontext_data; +#endif /* _XOPEN_SOURCE */ +}; +#endif /* _STRUCT_UCONTEXT */ +#endif /* __need_struct_ucontext */ + +#ifdef __need_struct_ucontext64 +#undef __need_struct_ucontext64 +#ifndef _STRUCT_UCONTEXT64 +#if __DARWIN_UNIX03 +#define _STRUCT_UCONTEXT64 struct __darwin_ucontext64 +#else /* !__DARWIN_UNIX03 */ +#define _STRUCT_UCONTEXT64 struct ucontext64 +#endif /* __DARWIN_UNIX03 */ +_STRUCT_UCONTEXT64 +{ + int uc_onstack; + __darwin_sigset_t uc_sigmask; /* signal mask used by this context */ + _STRUCT_SIGALTSTACK uc_stack; /* stack used by this context */ + _STRUCT_UCONTEXT64 *uc_link; /* pointer to resuming context */ + __darwin_size_t uc_mcsize; /* size of the machine context passed in */ + _STRUCT_MCONTEXT64 *uc_mcontext64; /* pointer to machine specific context */ +}; +#endif /* _STRUCT_UCONTEXT64 */ +#endif /* __need_struct_ucontext64 */ + + +#ifdef __need_fd_set +#undef __need_fd_set +#ifndef _FD_SET +#define _FD_SET +/* + * Select uses bit masks of file descriptors in longs. These macros + * manipulate such bit fields (the filesystem macros use chars). The + * extra protection here is to permit application redefinition above + * the default size. + */ +#ifdef FD_SETSIZE +#define __DARWIN_FD_SETSIZE FD_SETSIZE +#else /* !FD_SETSIZE */ +#define __DARWIN_FD_SETSIZE 1024 +#endif /* FD_SETSIZE */ +#define __DARWIN_NBBY 8 /* bits in a byte */ +#define __DARWIN_NFDBITS (sizeof(__int32_t) * __DARWIN_NBBY) /* bits per mask */ +#define __DARWIN_howmany(x, y) ((((x) % (y)) == 0) ? ((x) / (y)) : (((x) / (y)) + 1)) /* # y's == x bits? */ + +__BEGIN_DECLS +typedef struct fd_set { + __int32_t fds_bits[__DARWIN_howmany(__DARWIN_FD_SETSIZE, __DARWIN_NFDBITS)]; +} fd_set; +__END_DECLS + +/* This inline avoids argument side-effect issues with FD_ISSET() */ +static __inline int +__darwin_fd_isset(int _n, const struct fd_set *_p) +{ + return (_p->fds_bits[_n/__DARWIN_NFDBITS] & (1<<(_n % __DARWIN_NFDBITS))); +} + +#define __DARWIN_FD_SET(n, p) do { int __fd = (n); ((p)->fds_bits[__fd/__DARWIN_NFDBITS] |= (1<<(__fd % __DARWIN_NFDBITS))); } while(0) +#define __DARWIN_FD_CLR(n, p) do { int __fd = (n); ((p)->fds_bits[__fd/__DARWIN_NFDBITS] &= ~(1<<(__fd % __DARWIN_NFDBITS))); } while(0) +#define __DARWIN_FD_ISSET(n, p) __darwin_fd_isset((n), (p)) + +#if __GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ >= 3 +/* + * Use the built-in bzero function instead of the library version so that + * we do not pollute the namespace or introduce prototype warnings. + */ +#define __DARWIN_FD_ZERO(p) __builtin_bzero(p, sizeof(*(p))) +#else +#define __DARWIN_FD_ZERO(p) bzero(p, sizeof(*(p))) +#endif + +#define __DARWIN_FD_COPY(f, t) bcopy(f, t, sizeof(*(f))) +#endif /* _FD_SET */ +#endif /* __need_fd_set */ + +#ifdef __need_stack_t +#undef __need_stack_t +#ifndef _STACK_T +#define _STACK_T +typedef _STRUCT_SIGALTSTACK stack_t; /* [???] signal stack */ +#endif /* _STACK_T */ +#endif /* __need_stack_t */ + +#ifdef __need_ucontext_t +#undef __need_ucontext_t +/* user context */ +#ifndef _UCONTEXT_T +#define _UCONTEXT_T +typedef _STRUCT_UCONTEXT ucontext_t; /* [???] user context */ +#endif /* _UCONTEXT_T */ +#endif /* __need_ucontext_t */ + +#ifdef __need_ucontext64_t +#undef __need_ucontext64_t +#ifndef _UCONTEXT64_T +#define _UCONTEXT64_T +typedef _STRUCT_UCONTEXT64 ucontext64_t; /* [???] user context */ +#endif /* _UCONTEXT64_T */ +#endif /* __need_ucontext64_t */ Index: branches/azimutz/Cleancut/i386/include/sys/syscall.h =================================================================== --- branches/azimutz/Cleancut/i386/include/sys/syscall.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/sys/syscall.h (revision 885) @@ -0,0 +1,477 @@ +/* + * Copyright (c) 2004-2008 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@ + * + * + * System call switch table. + * + * DO NOT EDIT-- this file is automatically generated. + * created from /SourceCache/xnu/xnu-1504.7.4/bsd/kern/syscalls.master + */ + +#ifndef _SYS_SYSCALL_H_ +#define _SYS_SYSCALL_H_ + +#include <sys/appleapiopts.h> +#ifdef __APPLE_API_PRIVATE +#define SYS_syscall 0 +#define SYS_exit 1 +#define SYS_fork 2 +#define SYS_read 3 +#define SYS_write 4 +#define SYS_open 5 +#define SYS_close 6 +#define SYS_wait4 7 + /* 8 old creat */ +#define SYS_link 9 +#define SYS_unlink 10 + /* 11 old execv */ +#define SYS_chdir 12 +#define SYS_fchdir 13 +#define SYS_mknod 14 +#define SYS_chmod 15 +#define SYS_chown 16 + /* 17 old break */ +#define SYS_getfsstat 18 + /* 19 old lseek */ +#define SYS_getpid 20 + /* 21 old mount */ + /* 22 old umount */ +#define SYS_setuid 23 +#define SYS_getuid 24 +#define SYS_geteuid 25 +#define SYS_ptrace 26 +#define SYS_recvmsg 27 +#define SYS_sendmsg 28 +#define SYS_recvfrom 29 +#define SYS_accept 30 +#define SYS_getpeername 31 +#define SYS_getsockname 32 +#define SYS_access 33 +#define SYS_chflags 34 +#define SYS_fchflags 35 +#define SYS_sync 36 +#define SYS_kill 37 + /* 38 old stat */ +#define SYS_getppid 39 + /* 40 old lstat */ +#define SYS_dup 41 +#define SYS_pipe 42 +#define SYS_getegid 43 +#define SYS_profil 44 + /* 45 old ktrace */ +#define SYS_sigaction 46 +#define SYS_getgid 47 +#define SYS_sigprocmask 48 +#define SYS_getlogin 49 +#define SYS_setlogin 50 +#define SYS_acct 51 +#define SYS_sigpending 52 +#define SYS_sigaltstack 53 +#define SYS_ioctl 54 +#define SYS_reboot 55 +#define SYS_revoke 56 +#define SYS_symlink 57 +#define SYS_readlink 58 +#define SYS_execve 59 +#define SYS_umask 60 +#define SYS_chroot 61 + /* 62 old fstat */ + /* 63 used internally , reserved */ + /* 64 old getpagesize */ +#define SYS_msync 65 +#define SYS_vfork 66 + /* 67 old vread */ + /* 68 old vwrite */ + /* 69 old sbrk */ + /* 70 old sstk */ + /* 71 old mmap */ + /* 72 old vadvise */ +#define SYS_munmap 73 +#define SYS_mprotect 74 +#define SYS_madvise 75 + /* 76 old vhangup */ + /* 77 old vlimit */ +#define SYS_mincore 78 +#define SYS_getgroups 79 +#define SYS_setgroups 80 +#define SYS_getpgrp 81 +#define SYS_setpgid 82 +#define SYS_setitimer 83 + /* 84 old wait */ +#define SYS_swapon 85 +#define SYS_getitimer 86 + /* 87 old gethostname */ + /* 88 old sethostname */ +#define SYS_getdtablesize 89 +#define SYS_dup2 90 + /* 91 old getdopt */ +#define SYS_fcntl 92 +#define SYS_select 93 + /* 94 old setdopt */ +#define SYS_fsync 95 +#define SYS_setpriority 96 +#define SYS_socket 97 +#define SYS_connect 98 + /* 99 old accept */ +#define SYS_getpriority 100 + /* 101 old send */ + /* 102 old recv */ + /* 103 old sigreturn */ +#define SYS_bind 104 +#define SYS_setsockopt 105 +#define SYS_listen 106 + /* 107 old vtimes */ + /* 108 old sigvec */ + /* 109 old sigblock */ + /* 110 old sigsetmask */ +#define SYS_sigsuspend 111 + /* 112 old sigstack */ + /* 113 old recvmsg */ + /* 114 old sendmsg */ + /* 115 old vtrace */ +#define SYS_gettimeofday 116 +#define SYS_getrusage 117 +#define SYS_getsockopt 118 + /* 119 old resuba */ +#define SYS_readv 120 +#define SYS_writev 121 +#define SYS_settimeofday 122 +#define SYS_fchown 123 +#define SYS_fchmod 124 + /* 125 old recvfrom */ +#define SYS_setreuid 126 +#define SYS_setregid 127 +#define SYS_rename 128 + /* 129 old truncate */ + /* 130 old ftruncate */ +#define SYS_flock 131 +#define SYS_mkfifo 132 +#define SYS_sendto 133 +#define SYS_shutdown 134 +#define SYS_socketpair 135 +#define SYS_mkdir 136 +#define SYS_rmdir 137 +#define SYS_utimes 138 +#define SYS_futimes 139 +#define SYS_adjtime 140 + /* 141 old getpeername */ +#define SYS_gethostuuid 142 + /* 143 old sethostid */ + /* 144 old getrlimit */ + /* 145 old setrlimit */ + /* 146 old killpg */ +#define SYS_setsid 147 + /* 148 old setquota */ + /* 149 old qquota */ + /* 150 old getsockname */ +#define SYS_getpgid 151 +#define SYS_setprivexec 152 +#define SYS_pread 153 +#define SYS_pwrite 154 +#define SYS_nfssvc 155 + /* 156 old getdirentries */ +#define SYS_statfs 157 +#define SYS_fstatfs 158 +#define SYS_unmount 159 + /* 160 old async_daemon */ +#define SYS_getfh 161 + /* 162 old getdomainname */ + /* 163 old setdomainname */ + /* 164 */ +#define SYS_quotactl 165 + /* 166 old exportfs */ +#define SYS_mount 167 + /* 168 old ustat */ +#define SYS_csops 169 + /* 170 old table */ + /* 171 old wait3 */ + /* 172 old rpause */ +#define SYS_waitid 173 + /* 174 old getdents */ + /* 175 old gc_control */ +#define SYS_add_profil 176 + /* 177 */ + /* 178 */ + /* 179 */ +#define SYS_kdebug_trace 180 +#define SYS_setgid 181 +#define SYS_setegid 182 +#define SYS_seteuid 183 +#define SYS_sigreturn 184 +#define SYS_chud 185 + /* 186 */ +#define SYS_fdatasync 187 +#define SYS_stat 188 +#define SYS_fstat 189 +#define SYS_lstat 190 +#define SYS_pathconf 191 +#define SYS_fpathconf 192 + /* 193 */ +#define SYS_getrlimit 194 +#define SYS_setrlimit 195 +#define SYS_getdirentries 196 +#define SYS_mmap 197 + /* 198 __syscall */ +#define SYS_lseek 199 +#define SYS_truncate 200 +#define SYS_ftruncate 201 +#define SYS___sysctl 202 +#define SYS_mlock 203 +#define SYS_munlock 204 +#define SYS_undelete 205 +#define SYS_ATsocket 206 +#define SYS_ATgetmsg 207 +#define SYS_ATputmsg 208 +#define SYS_ATPsndreq 209 +#define SYS_ATPsndrsp 210 +#define SYS_ATPgetreq 211 +#define SYS_ATPgetrsp 212 + /* 213 Reserved for AppleTalk */ + /* 214 */ + /* 215 */ +#define SYS_mkcomplex 216 +#define SYS_statv 217 +#define SYS_lstatv 218 +#define SYS_fstatv 219 +#define SYS_getattrlist 220 +#define SYS_setattrlist 221 +#define SYS_getdirentriesattr 222 +#define SYS_exchangedata 223 + /* 224 old checkuseraccess / fsgetpath ( which moved to 427 ) */ +#define SYS_searchfs 225 +#define SYS_delete 226 +#define SYS_copyfile 227 +#define SYS_fgetattrlist 228 +#define SYS_fsetattrlist 229 +#define SYS_poll 230 +#define SYS_watchevent 231 +#define SYS_waitevent 232 +#define SYS_modwatch 233 +#define SYS_getxattr 234 +#define SYS_fgetxattr 235 +#define SYS_setxattr 236 +#define SYS_fsetxattr 237 +#define SYS_removexattr 238 +#define SYS_fremovexattr 239 +#define SYS_listxattr 240 +#define SYS_flistxattr 241 +#define SYS_fsctl 242 +#define SYS_initgroups 243 +#define SYS_posix_spawn 244 +#define SYS_ffsctl 245 + /* 246 */ +#define SYS_nfsclnt 247 +#define SYS_fhopen 248 + /* 249 */ +#define SYS_minherit 250 +#define SYS_semsys 251 +#define SYS_msgsys 252 +#define SYS_shmsys 253 +#define SYS_semctl 254 +#define SYS_semget 255 +#define SYS_semop 256 + /* 257 */ +#define SYS_msgctl 258 +#define SYS_msgget 259 +#define SYS_msgsnd 260 +#define SYS_msgrcv 261 +#define SYS_shmat 262 +#define SYS_shmctl 263 +#define SYS_shmdt 264 +#define SYS_shmget 265 +#define SYS_shm_open 266 +#define SYS_shm_unlink 267 +#define SYS_sem_open 268 +#define SYS_sem_close 269 +#define SYS_sem_unlink 270 +#define SYS_sem_wait 271 +#define SYS_sem_trywait 272 +#define SYS_sem_post 273 +#define SYS_sem_getvalue 274 +#define SYS_sem_init 275 +#define SYS_sem_destroy 276 +#define SYS_open_extended 277 +#define SYS_umask_extended 278 +#define SYS_stat_extended 279 +#define SYS_lstat_extended 280 +#define SYS_fstat_extended 281 +#define SYS_chmod_extended 282 +#define SYS_fchmod_extended 283 +#define SYS_access_extended 284 +#define SYS_settid 285 +#define SYS_gettid 286 +#define SYS_setsgroups 287 +#define SYS_getsgroups 288 +#define SYS_setwgroups 289 +#define SYS_getwgroups 290 +#define SYS_mkfifo_extended 291 +#define SYS_mkdir_extended 292 +#define SYS_identitysvc 293 +#define SYS_shared_region_check_np 294 +#define SYS_shared_region_map_np 295 +#define SYS_vm_pressure_monitor 296 +#define SYS_psynch_rw_longrdlock 297 +#define SYS_psynch_rw_yieldwrlock 298 +#define SYS_psynch_rw_downgrade 299 +#define SYS_psynch_rw_upgrade 300 +#define SYS_psynch_mutexwait 301 +#define SYS_psynch_mutexdrop 302 +#define SYS_psynch_cvbroad 303 +#define SYS_psynch_cvsignal 304 +#define SYS_psynch_cvwait 305 +#define SYS_psynch_rw_rdlock 306 +#define SYS_psynch_rw_wrlock 307 +#define SYS_psynch_rw_unlock 308 +#define SYS_psynch_rw_unlock2 309 +#define SYS_getsid 310 +#define SYS_settid_with_pid 311 + /* 312 old __pthread_cond_timedwait */ +#define SYS_aio_fsync 313 +#define SYS_aio_return 314 +#define SYS_aio_suspend 315 +#define SYS_aio_cancel 316 +#define SYS_aio_error 317 +#define SYS_aio_read 318 +#define SYS_aio_write 319 +#define SYS_lio_listio 320 + /* 321 old __pthread_cond_wait */ +#define SYS_iopolicysys 322 + /* 323 */ +#define SYS_mlockall 324 +#define SYS_munlockall 325 + /* 326 */ +#define SYS_issetugid 327 +#define SYS___pthread_kill 328 +#define SYS___pthread_sigmask 329 +#define SYS___sigwait 330 +#define SYS___disable_threadsignal 331 +#define SYS___pthread_markcancel 332 +#define SYS___pthread_canceled 333 +#define SYS___semwait_signal 334 + /* 335 old utrace */ +#define SYS_proc_info 336 +#define SYS_sendfile 337 +#define SYS_stat64 338 +#define SYS_fstat64 339 +#define SYS_lstat64 340 +#define SYS_stat64_extended 341 +#define SYS_lstat64_extended 342 +#define SYS_fstat64_extended 343 +#define SYS_getdirentries64 344 +#define SYS_statfs64 345 +#define SYS_fstatfs64 346 +#define SYS_getfsstat64 347 +#define SYS___pthread_chdir 348 +#define SYS___pthread_fchdir 349 +#define SYS_audit 350 +#define SYS_auditon 351 + /* 352 */ +#define SYS_getauid 353 +#define SYS_setauid 354 +#define SYS_getaudit 355 +#define SYS_setaudit 356 +#define SYS_getaudit_addr 357 +#define SYS_setaudit_addr 358 +#define SYS_auditctl 359 +#define SYS_bsdthread_create 360 +#define SYS_bsdthread_terminate 361 +#define SYS_kqueue 362 +#define SYS_kevent 363 +#define SYS_lchown 364 +#define SYS_stack_snapshot 365 +#define SYS_bsdthread_register 366 +#define SYS_workq_open 367 +#define SYS_workq_kernreturn 368 +#define SYS_kevent64 369 +#define SYS___old_semwait_signal 370 +#define SYS___old_semwait_signal_nocancel 371 +#define SYS_thread_selfid 372 + /* 373 */ + /* 374 */ + /* 375 */ + /* 376 */ + /* 377 */ + /* 378 */ + /* 379 */ +#define SYS___mac_execve 380 +#define SYS___mac_syscall 381 +#define SYS___mac_get_file 382 +#define SYS___mac_set_file 383 +#define SYS___mac_get_link 384 +#define SYS___mac_set_link 385 +#define SYS___mac_get_proc 386 +#define SYS___mac_set_proc 387 +#define SYS___mac_get_fd 388 +#define SYS___mac_set_fd 389 +#define SYS___mac_get_pid 390 +#define SYS___mac_get_lcid 391 +#define SYS___mac_get_lctx 392 +#define SYS___mac_set_lctx 393 +#define SYS_setlcid 394 +#define SYS_getlcid 395 +#define SYS_read_nocancel 396 +#define SYS_write_nocancel 397 +#define SYS_open_nocancel 398 +#define SYS_close_nocancel 399 +#define SYS_wait4_nocancel 400 +#define SYS_recvmsg_nocancel 401 +#define SYS_sendmsg_nocancel 402 +#define SYS_recvfrom_nocancel 403 +#define SYS_accept_nocancel 404 +#define SYS_msync_nocancel 405 +#define SYS_fcntl_nocancel 406 +#define SYS_select_nocancel 407 +#define SYS_fsync_nocancel 408 +#define SYS_connect_nocancel 409 +#define SYS_sigsuspend_nocancel 410 +#define SYS_readv_nocancel 411 +#define SYS_writev_nocancel 412 +#define SYS_sendto_nocancel 413 +#define SYS_pread_nocancel 414 +#define SYS_pwrite_nocancel 415 +#define SYS_waitid_nocancel 416 +#define SYS_poll_nocancel 417 +#define SYS_msgsnd_nocancel 418 +#define SYS_msgrcv_nocancel 419 +#define SYS_sem_wait_nocancel 420 +#define SYS_aio_suspend_nocancel 421 +#define SYS___sigwait_nocancel 422 +#define SYS___semwait_signal_nocancel 423 +#define SYS___mac_mount 424 +#define SYS___mac_get_mount 425 +#define SYS___mac_getfsstat 426 +#define SYS_fsgetpath 427 +#define SYS_audit_session_self 428 +#define SYS_audit_session_join 429 +#define SYS_pid_suspend 430 +#define SYS_pid_resume 431 +#define SYS_fileport_makeport 432 +#define SYS_fileport_makefd 433 +#define SYS_MAXSYSCALL 434 + +#endif /* __APPLE_API_PRIVATE */ +#endif /* !_SYS_SYSCALL_H_ */ Index: branches/azimutz/Cleancut/i386/include/sys/buf.h =================================================================== --- branches/azimutz/Cleancut/i386/include/sys/buf.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/sys/buf.h (revision 885) @@ -0,0 +1,859 @@ +/* + * Copyright (c) 2000-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@ + */ +/* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */ +/* + * Copyright (c) 1982, 1986, 1989, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)buf.h 8.9 (Berkeley) 3/30/95 + */ + +#ifndef _SYS_BUF_H_ +#define _SYS_BUF_H_ + +#include <sys/cdefs.h> +#include <sys/kernel_types.h> +#include <mach/memory_object_types.h> + + +#define B_WRITE 0x00000000 /* Write buffer (pseudo flag). */ +#define B_READ 0x00000001 /* Read buffer. */ +#define B_ASYNC 0x00000002 /* Start I/O, do not wait. */ +#define B_NOCACHE 0x00000004 /* Do not cache block after use. */ +#define B_DELWRI 0x00000008 /* Delay I/O until buffer reused. */ +#define B_LOCKED 0x00000010 /* Locked in core (not reusable). */ +#define B_PHYS 0x00000020 /* I/O to user memory. */ +#define B_CLUSTER 0x00000040 /* UPL based I/O generated by cluster layer */ +#define B_PAGEIO 0x00000080 /* Page in/out */ +#define B_META 0x00000100 /* buffer contains meta-data. */ +#define B_RAW 0x00000200 /* Set by physio for raw transfers. */ +#define B_FUA 0x00000400 /* Write-through disk cache(if supported) */ +#define B_PASSIVE 0x00000800 /* PASSIVE I/Os are ignored by THROTTLE I/O */ +#define B_IOSTREAMING 0x00001000 /* sequential access pattern detected */ +#define B_THROTTLED_IO 0x00002000 /* low priority I/O */ +/* + * make sure to check when adding flags that + * that the new flags don't overlap the definitions + * in buf_internal.h + */ + +__BEGIN_DECLS + +/*! + @function buf_markaged + @abstract Mark a buffer as "aged," i.e. as a good candidate to be discarded and reused after buf_brelse(). + @param bp Buffer to mark. + */ +void buf_markaged(buf_t); + +/*! + @function buf_markinvalid + @abstract Mark a buffer as not having valid data and being ready for immediate reuse after buf_brelse(). + @param bp Buffer to mark. + */ +void buf_markinvalid(buf_t); + +/*! + @function buf_markdelayed + @abstract Mark a buffer as a delayed write: mark it dirty without actually scheduling I/O. + @discussion Data will be flushed to disk at some later time, not with brelse(). A sync()/fsync() + or pressure necessitating reuse of the buffer will cause it to be written back to disk. + @param bp Buffer to mark. + */ +void buf_markdelayed(buf_t); + +/*! + @function buf_markeintr + @abstract Mark a buffer as having been interrupted during I/O. + @discussion Waiters for I/O to complete (buf_biowait()) will return with EINTR when woken up. + buf_markeintr does not itself do a wakeup. + @param bp Buffer to mark. + */ +void buf_markeintr(buf_t); + +/*! + @function buf_markfua + @abstract Mark a buffer for write through disk cache, if disk supports it. + @param bp Buffer to mark. + */ +void buf_markfua(buf_t); + +/*! + @function buf_fua + @abstract Check if a buffer is marked for write through disk caches. + @param bp Buffer to test. + @return Nonzero if buffer is marked for write-through, 0 if not. + */ +int buf_fua(buf_t); + +/*! + @function buf_valid + @abstract Check if a buffer contains valid data. + @param bp Buffer to test. + @return Nonzero if buffer has valid data, 0 if not. + */ +int buf_valid(buf_t); + +/*! + @function buf_fromcache + @abstract Check if a buffer's data was found in core. + @discussion Will return truth after a buf_getblk that finds a valid buffer in the cache or the relevant + data in core (but not in a buffer). + @param bp Buffer to test. + @return Nonzero if we got this buffer's data without doing I/O, 0 if not. + */ +int buf_fromcache(buf_t); + +/*! + @function buf_upl + @abstract Get the upl (Universal Page List) associated with a buffer. + @discussion Buffers allocated with buf_alloc() are not returned with a upl, and + traditional buffers only have a upl while an I/O is in progress. + @param bp Buffer whose upl to grab. + @return Buffer's upl if it has one, else NULL. + */ +void * buf_upl(buf_t); + +/*! + @function buf_uploffset + @abstract Get the offset into a UPL at which this buffer begins. + @discussion This function should only be called on iobufs, i.e. buffers allocated with buf_alloc(). + @param bp Buffer whose uploffset to grab. + @return Buffer's uploffset--does not check whether that value makes sense for this buffer. + */ +uint32_t buf_uploffset(buf_t); + + + +/*! + @function buf_proc + @abstract Get the process associated with this buffer. + @discussion buf_proc() will generally return NULL; a process is currently only associated with + a buffer in the event of a physio() call. + @param bp Buffer whose associated process to find. + @return Associated process, possibly NULL. + */ +proc_t buf_proc(buf_t); + +/*! + @function buf_dirtyoff + @abstract Get the starting offset of the dirty region associated with a buffer. + @discussion The dirty offset is zero unless someone explicitly calls buf_setdirtyoff() (which the kernel does not). + @param bp Buffer whose dirty offset to get. + @return Dirty offset (0 if not explicitly changed). + */ +uint32_t buf_dirtyoff(buf_t); + +/*! + @function buf_dirtyend + @abstract Get the ending offset of the dirty region associated with a buffer. + @discussion If the buffer's data was found incore and dirty, the dirty end is the size of the block; otherwise, unless + someone outside of xnu explicitly changes it by calling buf_setdirtyend(), it will be zero. + @param bp Buffer whose dirty end to get. + @return 0 if buffer is found clean; size of buffer if found dirty. Can be set to any value by callers of buf_setdirtyend(). + */ +uint32_t buf_dirtyend(buf_t); + +/*! + @function buf_setdirtyoff + @abstract Set the starting offset of the dirty region associated with a buffer. + @discussion This value is zero unless someone set it explicitly. + @param bp Buffer whose dirty end to set. + @return void. + */ +void buf_setdirtyoff(buf_t, uint32_t); + +/*! + @function buf_setdirtyend + @abstract Set the ending offset of the dirty region associated with a buffer. + @discussion If the buffer's data was found incore and dirty, the dirty end is the size of the block; otherwise, unless + someone outside of xnu explicitly changes it by calling buf_setdirtyend(), it will be zero. + @param bp Buffer whose dirty end to set. + @return void. + */ +void buf_setdirtyend(buf_t, uint32_t); + +/*! + @function buf_error + @abstract Get the error value associated with a buffer. + @discussion Errors are set with buf_seterror(). + @param bp Buffer whose error value to retrieve. + @return Error value, directly. + */ +errno_t buf_error(buf_t); + +/*! + @function buf_seterror + @abstract Set an error value on a buffer. + @param bp Buffer whose error value to set. + @return void. + */ +void buf_seterror(buf_t, errno_t); + +/*! + @function buf_setflags + @abstract Set flags on a buffer. + @discussion: buffer_flags |= flags + @param bp Buffer whose flags to set. + @param flags Flags to add to buffer's mask. B_LOCKED/B_NOCACHE/B_ASYNC/B_READ/B_WRITE/B_PAGEIO/B_FUA + @return void. + */ +void buf_setflags(buf_t, int32_t); + +/*! + @function buf_clearflags + @abstract Clear flags on a buffer. + @discussion: buffer_flags &= ~flags + @param bp Buffer whose flags to clear. + @param flags Flags to remove from buffer's mask. B_LOCKED/B_NOCACHE/B_ASYNC/B_READ/B_WRITE/B_PAGEIO/B_FUA + @return void. + */ +void buf_clearflags(buf_t, int32_t); + +/*! + @function buf_flags + @abstract Get flags set on a buffer. + @discussion Valid flags are B_LOCKED/B_NOCACHE/B_ASYNC/B_READ/B_WRITE/B_PAGEIO/B_FUA. + @param bp Buffer whose flags to grab. + @return flags. + */ +int32_t buf_flags(buf_t); + +/*! + @function buf_reset + @abstract Reset I/O flag state on a buffer. + @discussion Clears current flags on a buffer (internal and external) and allows some new flags to be set. + Used perhaps to prepare an iobuf for reuse. + @param bp Buffer whose flags to grab. + @param flags Flags to set on buffer: B_READ, B_WRITE, B_ASYNC, B_NOCACHE. + @return void. + */ +void buf_reset(buf_t, int32_t); + +/*! + @function buf_map + @abstract Get virtual mappings for buffer data. + @discussion For buffers created through buf_getblk() (i.e. traditional buffer cache usage), + buf_map() just returns the address at which data was mapped by but_getblk(). For a B_CLUSTER buffer, i.e. an iobuf + whose upl state is managed manually, there are two possibilities. If the buffer was created + with an underlying "real" buffer through cluster_bp(), the mapping of the "real" buffer is returned. + Otherwise, the buffer was created with buf_alloc() and buf_setupl() was subsequently called; buf_map() + will call ubc_upl_map() to get a mapping for the buffer's upl and return the start of that mapping + plus the buffer's upl offset (set in buf_setupl()). In the last case, buf_unmap() must later be called + to tear down the mapping. NOTE: buf_map() does not set the buffer data pointer; this must be done with buf_setdataptr(). + @param bp Buffer whose mapping to find or create. + @param io_addr Destination for mapping address. + @return 0 for success, ENOMEM if unable to map the buffer. + */ +errno_t buf_map(buf_t, caddr_t *); + +/*! + @function buf_unmap + @abstract Release mappings for buffer data. + @discussion For buffers created through buf_getblk() (i.e. traditional buffer cache usage), + buf_unmap() does nothing; buf_brelse() will take care of unmapping. For a B_CLUSTER buffer, i.e. an iobuf + whose upl state is managed manually, there are two possibilities. If the buffer was created + with an underlying "real" buffer through cluster_bp(), buf_unmap() does nothing; buf_brelse() on the + underlying buffer will tear down the mapping. Otherwise, the buffer was created with buf_alloc() and + buf_setupl() was subsequently called; buf_map() created the mapping. In this case, buf_unmap() will + unmap the buffer. + @param bp Buffer whose mapping to find or create. + @param io_addr Destination for mapping address. + @return 0 for success, EINVAL if unable to unmap buffer. + */ +errno_t buf_unmap(buf_t); + +/*! + @function buf_setdrvdata + @abstract Set driver-specific data on a buffer. + @param bp Buffer whose driver-data to set. + @param drvdata Opaque driver data. + @return void. + */ +void buf_setdrvdata(buf_t, void *); + +/*! + @function buf_setdrvdata + @abstract Get driver-specific data from a buffer. + @param bp Buffer whose driver data to get. + @return Opaque driver data. + */ +void * buf_drvdata(buf_t); + +/*! + @function buf_setfsprivate + @abstract Set filesystem-specific data on a buffer. + @param bp Buffer whose filesystem data to set. + @param fsprivate Opaque filesystem data. + @return void. + */ +void buf_setfsprivate(buf_t, void *); + +/*! + @function buf_fsprivate + @abstract Get filesystem-specific data from a buffer. + @param bp Buffer whose filesystem data to get. + @return Opaque filesystem data. + */ +void * buf_fsprivate(buf_t); + +/*! + @function buf_blkno + @abstract Get physical block number associated with a buffer, in the sense of VNOP_BLOCKMAP. + @discussion When a buffer's physical block number is the same is its logical block number, then the physical + block number is considered uninitialized. A physical block number of -1 indicates that there is no valid + physical mapping (e.g. the logical block is invalid or corresponds to a sparse region in a file). Physical + block number is normally set by the cluster layer or by buf_getblk(). + @param bp Buffer whose physical block number to get. + @return Block number. + */ +daddr64_t buf_blkno(buf_t); + +/*! + @function buf_lblkno + @abstract Get logical block number associated with a buffer. + @discussion Logical block number is set on traditionally-used buffers by an argument passed to buf_getblk(), + for example by buf_bread(). + @param bp Buffer whose logical block number to get. + @return Block number. + */ +daddr64_t buf_lblkno(buf_t); + +/*! + @function buf_setblkno + @abstract Set physical block number associated with a buffer. + @discussion Physical block number is generally set by the cluster layer or by buf_getblk(). + @param bp Buffer whose physical block number to set. + @param blkno Block number to set. + @return void. + */ +void buf_setblkno(buf_t, daddr64_t); + +/*! + @function buf_setlblkno + @abstract Set logical block number associated with a buffer. + @discussion Logical block number is set on traditionally-used buffers by an argument passed to buf_getblk(), + for example by buf_bread(). + @param bp Buffer whose logical block number to set. + @param lblkno Block number to set. + @return void. + */ +void buf_setlblkno(buf_t, daddr64_t); + +/*! + @function buf_count + @abstract Get count of valid bytes in a buffer. This may be less than the space allocated to the buffer. + @param bp Buffer whose byte count to get. + @return Byte count. + */ +uint32_t buf_count(buf_t); + +/*! + @function buf_size + @abstract Get size of data region allocated to a buffer. + @discussion May be larger than amount of valid data in buffer. + @param bp Buffer whose size to get. + @return Size. + */ +uint32_t buf_size(buf_t); + +/*! + @function buf_resid + @abstract Get a count of bytes which were not consumed by an I/O on a buffer. + @discussion Set when an I/O operations completes. + @param bp Buffer whose outstanding count to get. + @return Count of unwritten/unread bytes. + */ +uint32_t buf_resid(buf_t); + +/*! + @function buf_setcount + @abstract Set count of valid bytes in a buffer. This may be less than the space allocated to the buffer. + @param bp Buffer whose byte count to set. + @param bcount Count to set. + @return void. + */ +void buf_setcount(buf_t, uint32_t); + +/*! + @function buf_setsize + @abstract Set size of data region allocated to a buffer. + @discussion May be larger than amount of valid data in buffer. Should be used by + code which is manually providing storage for an iobuf, one allocated with buf_alloc(). + @param bp Buffer whose size to set. + @return void. + */ +void buf_setsize(buf_t, uint32_t); + +/*! + @function buf_setresid + @abstract Set a count of bytes outstanding for I/O in a buffer. + @discussion Set when an I/O operations completes. Examples: called by IOStorageFamily when I/O + completes, often called on an "original" buffer when using a manipulated buffer to perform I/O + on behalf of the first. + @param bp Buffer whose outstanding count to set. + @return Count of unwritten/unread bytes. + */ +void buf_setresid(buf_t, uint32_t); + +/*! + @function buf_setdataptr + @abstract Set the address at which a buffer's data will be stored. + @discussion In traditional buffer use, the data pointer will be set automatically. This routine is + useful with iobufs (allocated with buf_alloc()). + @param bp Buffer whose data pointer to set. + @param data Pointer to data region. + @return void. + */ +void buf_setdataptr(buf_t, uintptr_t); + +/*! + @function buf_dataptr + @abstract Get the address at which a buffer's data is stored; for iobufs, this must + be set with buf_setdataptr(). See buf_map(). + @param bp Buffer whose data pointer to retrieve. + @return Data pointer; NULL if unset. + */ +uintptr_t buf_dataptr(buf_t); + +/*! + @function buf_vnode + @abstract Get the vnode associated with a buffer. + @discussion Every buffer is associated with a file. Because there is an I/O in flight, + there is an iocount on this vnode; it is returned WITHOUT an extra iocount, and vnode_put() + need NOT be called. + @param bp Buffer whose vnode to retrieve. + @return Buffer's vnode. + */ +vnode_t buf_vnode(buf_t); + +/*! + @function buf_setvnode + @abstract Set the vnode associated with a buffer. + @discussion This call need not be used on traditional buffers; it is for use with iobufs. + @param bp Buffer whose vnode to set. + @param vp The vnode to attach to the buffer. + @return void. + */ +void buf_setvnode(buf_t, vnode_t); + +/*! + @function buf_setdevice + @abstract Set the device associated with a buffer. + @discussion A buffer's device is set in buf_strategy() (or in buf_getblk() if the file is a device). + It is also set on an iobuf if buf_alloc() is passed a device vnode. + @param bp Buffer whose device ID to set. + @param vp Device to set on the buffer. + @return 0 for success, EINVAL if vp is not a device file. + */ +errno_t buf_setdevice(buf_t, vnode_t); + +/*! + @function buf_strategy + @abstract Pass an I/O request for a buffer down to the device layer. + @discussion This is one of the most important routines in the buffer cache layer. For buffers obtained + through buf_getblk, it handles finding physical block numbers for the I/O (with VNOP_BLKTOOFF and + VNOP_BLOCKMAP), packaging the I/O into page-sized chunks, and initiating I/O on the disk by calling + the device's strategy routine. If a buffer's UPL has been set manually with buf_setupl(), it assumes + that the request is already correctly configured with a block number and a size divisible by page size + and will just call directly to the device. + @param devvp Device on which to perform I/O + @param ap vnop_strategy_args structure (most importantly, a buffer). + @return 0 for success, or errors from filesystem or device layers. + */ +errno_t buf_strategy(vnode_t, void *); + +/* + * Flags for buf_invalblkno() + */ +#define BUF_WAIT 0x01 + +/*! + @function buf_invalblkno + @abstract Invalidate a filesystem logical block in a file. + @discussion buf_invalblkno() tries to make the data for a given block in a file + invalid; if the buffer for that block is found in core and is not busy, we mark it + invalid and call buf_brelse() (see "flags" param for what happens if the buffer is busy). + buf_brelse(), noticing that it is invalid, will + will return the buffer to the empty-buffer list and tell the VM subsystem to abandon + the relevant pages. Data will not be written to backing store--it will be cast aside. + Note that this function will only work if the block in question has been + obtained with a buf_getblk(). If data has been read into core without using + traditional buffer cache routines, buf_invalblkno() will not be able to invalidate it--this + includes the use of iobufs. + @param bp Buffer whose block to invalidate. + @param lblkno Logical block number. + @param flags BUF_WAIT: wait for busy buffers to become unbusy and invalidate them then. Otherwise, + just return EBUSY for busy blocks. + @return 0 for success, EINVAL if vp is not a device file. + */ +errno_t buf_invalblkno(vnode_t, daddr64_t, int); + +/*! + @function buf_callback + @abstract Get the function set to be called when I/O on a buffer completes. + @discussion A function returned by buf_callback was originally set with buf_setcallback(). + @param bp Buffer whose callback to get. + @return 0 for success, or errors from filesystem or device layers. + */ +void * buf_callback(buf_t); + +/*! + @function buf_setcallback + @abstract Set a function to be called once when I/O on a buffer completes. + @discussion A one-shot callout set with buf_setcallback() will be called from buf_biodone() + when I/O completes. It will be passed the "transaction" argument as well as the buffer. + buf_setcallback() also marks the buffer as B_ASYNC. + @param bp Buffer whose callback to set. + @param callback function to use as callback. + @param transaction Additional argument to callback function. + @return 0; always succeeds. + */ +errno_t buf_setcallback(buf_t, void (*)(buf_t, void *), void *); + +/*! + @function buf_setupl + @abstract Set the UPL (Universal Page List), and offset therein, on a buffer. + @discussion buf_setupl() should only be called on buffers allocated with buf_alloc(). + A subsequent call to buf_map() will map the UPL and give back the address at which data + begins. After buf_setupl() is called, a buffer is marked B_CLUSTER; when this is the case, + buf_strategy() assumes that a buffer is correctly configured to be passed to the device + layer without modification. Passing a NULL upl will clear the upl and the B_CLUSTER flag on the + buffer. + @param bp Buffer whose upl to set. + @param upl UPL to set in the buffer. + @parma offset Offset within upl at which relevant data begin. + @return 0 for success, EINVAL if the buffer was not allocated with buf_alloc(). + */ +errno_t buf_setupl(buf_t, upl_t, uint32_t); + +/*! + @function buf_clone + @abstract Clone a buffer with a restricted range and an optional callback. + @discussion Generates a buffer which is identical to its "bp" argument except that + it spans a subset of the data of the original. The buffer to be cloned should + have been allocated with buf_alloc(). Checks its arguments to make sure + that the data subset is coherent. Optionally, adds a callback function and argument to it + to be called when I/O completes (as with buf_setcallback(), but B_ASYNC is not set). If the original buffer had + a upl set through buf_setupl(), this upl is copied to the new buffer; otherwise, the original's + data pointer is used raw. The buffer must be released with buf_free(). + @param bp Buffer to clone. + @param io_offset Offset, relative to start of data in original buffer, at which new buffer's data will begin. + @param io_size Size of buffer region in new buffer, in the sense of buf_count(). + @param iodone Callback to be called from buf_biodone() when I/O completes, in the sense of buf_setcallback(). + @param arg Argument to pass to iodone() callback. + @return NULL if io_offset/io_size combination is invalid for the buffer to be cloned; otherwise, the new buffer. + */ +buf_t buf_clone(buf_t, int, int, void (*)(buf_t, void *), void *); + +/*! + @function buf_alloc + @abstract Allocate an uninitialized buffer. + @discussion A buffer returned by buf_alloc() is marked as busy and as an iobuf; it has no storage set up and must be + set up using buf_setdataptr() or buf_setupl()/buf_map(). + @param vp vnode to associate with the buffer: optionally NULL. If vp is a device file, then + the buffer's associated device will be set. If vp is NULL, it can be set later with buf_setvnode(). + @return New buffer. + */ +buf_t buf_alloc(vnode_t); + +/*! + @function buf_free + @abstract Free a buffer that was allocated with buf_alloc(). + @discussion The storage (UPL, data pointer) associated with an iobuf must be freed manually. + @param bp The buffer to free. + @return void. + */ +void buf_free(buf_t); + +/* + * flags for buf_invalidateblks + */ +#define BUF_WRITE_DATA 0x0001 /* write data blocks first */ +#define BUF_SKIP_META 0x0002 /* skip over metadata blocks */ + +/*! + @function buf_invalidateblks + @abstract Invalidate all the blocks associated with a vnode. + @discussion This function does for all blocks associated with a vnode what buf_invalblkno does for one block. + Again, it will only be able to invalidate data which were populated with traditional buffer cache routines, + i.e. by buf_getblk() and callers thereof. Unlike buf_invalblkno(), it can be made to write dirty data to disk + rather than casting it aside. + @param bp The buffer whose data to invalidate. + @param flags BUF_WRITE_DATA: write dirty data to disk with VNOP_BWRITE() before kicking buffer cache entries out. + BUF_SKIP_META: do not invalidate metadata blocks. + @param slpflag Flags to pass to "msleep" while waiting to acquire busy buffers. + @param slptimeo Timeout in "hz" (1/100 second) to wait for a buffer to become unbusy before waking from sleep + and re-starting the scan. + @return 0 for success, error values from msleep(). + */ +int buf_invalidateblks(vnode_t, int, int, int); + +/* + * flags for buf_flushdirtyblks and buf_iterate + */ +#define BUF_SKIP_NONLOCKED 0x01 +#define BUF_SKIP_LOCKED 0x02 +#define BUF_SCAN_CLEAN 0x04 /* scan the clean buffers */ +#define BUF_SCAN_DIRTY 0x08 /* scan the dirty buffers */ +#define BUF_NOTIFY_BUSY 0x10 /* notify the caller about the busy pages during the scan */ + + +#define BUF_RETURNED 0 +#define BUF_RETURNED_DONE 1 +#define BUF_CLAIMED 2 +#define BUF_CLAIMED_DONE 3 +/*! + @function buf_flushdirtyblks + @abstract Write dirty file blocks to disk. + @param vp The vnode whose blocks to flush. + @param wait Wait for writes to complete before returning. + @param flags Can pass zero, meaning "flush all dirty buffers." + BUF_SKIP_NONLOCKED: Skip buffers which are not busy when we encounter them. + BUF_SKIP_LOCKED: Skip buffers which are busy when we encounter them. + @param msg String to pass to msleep(). + @return void. + */ +void buf_flushdirtyblks(vnode_t, int, int, const char *); + +/*! + @function buf_iterate + @abstract Perform some operation on all buffers associated with a vnode. + @param vp The vnode whose buffers to scan. + @param callout Function to call on each buffer. Should return one of: + BUF_RETURNED: buf_iterate() should call buf_brelse() on the buffer. + BUF_RETURNED_DONE: buf_iterate() should call buf_brelse() on the buffer and then stop iterating. + BUF_CLAIMED: buf_iterate() should continue iterating (and not call buf_brelse()). + BUF_CLAIMED_DONE: buf_iterate() should stop iterating (and not call buf_brelse()). + @param flag + BUF_SKIP_NONLOCKED: Skip buffers which are not busy when we encounter them. BUF_SKIP_LOCKED: Skip buffers which are busy when we encounter them. + BUF_SCAN_CLEAN: Call out on clean buffers. + BUF_SCAN_DIRTY: Call out on dirty buffers. + BUF_NOTIFY_BUSY: If a buffer cannot be acquired, pass a NULL buffer to callout; otherwise, + that buffer will be silently skipped. + @param arg Argument to pass to callout in addition to buffer. + @return void. + */ +void buf_iterate(vnode_t, int (*)(buf_t, void *), int, void *); + +/*! + @function buf_clear + @abstract Zero out the storage associated with a buffer. + @discussion Calls buf_map() to get the buffer's data address; for a B_CLUSTER + buffer (one which has had buf_setupl() called on it), it tries to map the buffer's + UPL into memory; should only be called once during the life cycle of an iobuf (one allocated + with buf_alloc()). + @param bp The buffer to zero out. + @return void. + */ +void buf_clear(buf_t); + +/*! + @function buf_bawrite + @abstract Start an asychronous write on a buffer. + @discussion Calls VNOP_BWRITE to start the process of propagating an asynchronous write down to the device layer. + Callers can wait for writes to complete at their discretion using buf_biowait(). When this function is called, + data should already have been written to the buffer's data region. + @param bp The buffer on which to initiate I/O. + @param throttle If "throttle" is nonzero and more than VNODE_ASYNC_THROTTLE writes are in progress on this file, + buf_bawrite() will block until the write count drops below VNODE_ASYNC_THROTTLE. If "throttle" is zero and the write + count is high, it will fail with EWOULDBLOCK; the caller can decide whether to make a blocking call or pursue + other opportunities. + @return EWOULDBLOCK if write count is high and "throttle" is zero; otherwise, errors from VNOP_BWRITE. + */ +errno_t buf_bawrite(buf_t); + +/*! + @function buf_bdwrite + @abstract Mark a buffer for delayed write. + @discussion Marks a buffer as waiting for delayed write and the current I/O as complete; data will be written to backing store + before the buffer is reused, but it will not be queued for I/O immediately. Note that for buffers allocated + with buf_alloc(), there are no such guarantees; you must take care of your own flushing to disk. If + the number of delayed writes pending on the system is greater than an internal limit and the caller has not + requested otherwise [see return_error] , buf_bdwrite() will unilaterally launch an asynchronous I/O with buf_bawrite() to keep the pile of + delayed writes from getting too large. + @param bp The buffer to mark for delayed write. + @param return_error If the number of pending delayed writes systemwide is larger than an internal limit, + return EAGAIN rather than doing an asynchronous write. + @return EAGAIN for return_error != 0 case, 0 for succeess, errors from buf_bawrite. + */ +errno_t buf_bdwrite(buf_t); + +/*! + @function buf_bwrite + @abstract Write a buffer's data to backing store. + @discussion Once the data in a buffer has been modified, buf_bwrite() starts sending it to disk by calling + VNOP_STRATEGY. Unless B_ASYNC has been set on the buffer (by buf_setflags() or otherwise), data will have + been written to disk when buf_bwrite() returns. See Bach (p 56). + @param bp The buffer to write to disk. + @return 0 for success; errors from buf_biowait(). + */ +errno_t buf_bwrite(buf_t); + +/*! + @function buf_biodone + @abstract Mark an I/O as completed. + @discussion buf_biodone() should be called by whosoever decides that an I/O on a buffer is complete; for example, + IOStorageFamily. It clears the dirty flag on a buffer and signals on the vnode that a write has completed + with vnode_writedone(). If a callout or filter has been set on the buffer, that function is called. In the case + of a callout, that function is expected to take care of cleaning up and freeing the buffer. + Otherwise, if the buffer is marked B_ASYNC (e.g. it was passed to buf_bawrite()), then buf_biodone() + considers itself justified in calling buf_brelse() to return it to free lists--no one is waiting for it. Finally, + waiters on the bp (e.g. in buf_biowait()) are woken up. + @param bp The buffer to mark as done with I/O. + @return void. + */ +void buf_biodone(buf_t); + +/*! + @function buf_biowait + @abstract Wait for I/O on a buffer to complete. + @discussion Waits for I/O on a buffer to finish, as marked by a buf_biodone() call. + @param bp The buffer to wait on. + @return 0 for a successful wait; nonzero the buffer has been marked as EINTR or had an error set on it. + */ +errno_t buf_biowait(buf_t); + +/*! + @function buf_brelse + @abstract Release any claim to a buffer, sending it back to free lists. + @discussion buf_brelse() cleans up buffer state and releases a buffer to the free lists. If the buffer + is not marked invalid and its pages are dirty (e.g. a delayed write was made), its data will be commited + to backing store. If it is marked invalid, its data will be discarded completely. + A valid, cacheable buffer will be put on a list and kept in the buffer hash so it + can be found again; otherwise, it will be dissociated from its vnode and treated as empty. Which list a valid + buffer is placed on depends on the use of buf_markaged(), whether it is metadata, and the B_LOCKED flag. A + B_LOCKED buffer will not be available for reuse by other files, though its data may be paged out. + Note that buf_brelse() is intended for use with traditionally allocated buffers. + @param bp The buffer to release. + @retrn void. + */ +void buf_brelse(buf_t); + +/*! + @function minphys + @abstract Adjust a buffer's count to be no more than maximum physical I/O transfer size for the host architecture. + @discussion physio() takes as a parameter a function to bound transfer sizes for each VNOP_STRATEGY() call. minphys() + is a default implementation. It calls buf_setcount() to make the buffer's count the min() of its current count + and the max I/O size for the host architecture. + @param bp The buffer whose byte count to modify. + @return New byte count. + */ +u_int minphys(buf_t bp); + +/* + * Flags for operation type in getblk() + */ +#define BLK_READ 0x01 /* buffer for read */ +#define BLK_WRITE 0x02 /* buffer for write */ +#define BLK_META 0x10 /* buffer for metadata */ +/* + * modifier for above flags... if set, getblk will only return + * a bp that is already valid... i.e. found in the cache + */ +#define BLK_ONLYVALID 0x80000000 + +/*! + @function buf_getblk + @abstract Traditional buffer cache routine to get a buffer corresponding to a logical block in a file. + @discussion buf_getblk() gets a buffer, not necessarily containing valid data, representing a block in a file. + A metadata buffer will be returned with its own zone-allocated storage, managed by the traditional buffer-cache + layer, whereas data buffers will be returned hooked into backing by the UBC (which in fact controls the caching of data). + buf_getblk() first looks for the buffer header in cache; if the buffer is in-core but busy, buf_getblk() will wait for it to become + unbusy, depending on the slpflag and slptimeo parameters. If the buffer is found unbusy and is a metadata buffer, + it must already contain valid data and will be returned directly; data buffers will have a UPL configured to + prepare for interaction with the underlying UBC. If the buffer is found in core, it will be marked as such + and buf_fromcache() will return truth. A buffer is allocated and initialized (but not filled with data) + if none is found in core. buf_bread(), buf_breadn(), buf_meta_bread(), and buf_meta_breadn() all + return buffers obtained with buf_getblk(). + @param vp File for which to get block. + @param blkno Logical block number. + @param size Size of block. + @param slpflag Flag to pass to msleep() while waiting for buffer to become unbusy. + @param slptimeo Time, in milliseconds, to wait for buffer to become unbusy. 0 means to wait indefinitely. + @param operation BLK_READ: want a read buffer. BLK_WRITE: want a write buffer. BLK_META: want a metadata buffer. BLK_ONLYVALID: + only return buffers which are found in core (do not allocate anew), and do not change buffer size. The last remark means + that if a given logical block is found in core with a different size than what is requested, the buffer size will not be modified. + @return Buffer found in core or newly allocated, either containing valid data or ready for I/O. + */ +buf_t buf_getblk(vnode_t, daddr64_t, int, int, int, int); + +/*! + @function buf_geteblk + @abstract Get a metadata buffer which is marked invalid and not associated with any vnode. + @discussion A buffer is returned with zone-allocated storage of the specified size, marked B_META and invalid. + It has no vnode and is not visible in the buffer hash. + @param size Size of buffer. + @return Always returns a new buffer. + */ +buf_t buf_geteblk(int); + + +__END_DECLS + + +/* Macros to clear/set/test flags. */ +#define SET(t, f) (t) |= (f) +#define CLR(t, f) (t) &= ~(f) +#define ISSET(t, f) ((t) & (f)) + + +#endif /* !_SYS_BUF_H_ */ Index: branches/azimutz/Cleancut/i386/include/sys/_select.h =================================================================== --- branches/azimutz/Cleancut/i386/include/sys/_select.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/sys/_select.h (revision 885) @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2005, 2007 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@ + */ + +/* + * This is called from sys/select.h and sys/time.h for the common prototype + * of select(). Setting _DARWIN_C_SOURCE or _DARWIN_UNLIMITED_SELECT uses + * the version of select() that does not place a limit on the first argument + * (nfds). In the UNIX conformance case, values of nfds greater than + * FD_SETSIZE will return an error of EINVAL. + */ +#ifndef _SYS__SELECT_H_ +#define _SYS__SELECT_H_ + +int select(int, fd_set * __restrict, fd_set * __restrict, + fd_set * __restrict, struct timeval * __restrict) +#if defined(_DARWIN_C_SOURCE) || defined(_DARWIN_UNLIMITED_SELECT) + __DARWIN_EXTSN_C(select) +#else /* !_DARWIN_C_SOURCE && !_DARWIN_UNLIMITED_SELECT */ +# if defined(__LP64__) && !__DARWIN_NON_CANCELABLE + __DARWIN_1050(select) +# else /* !__LP64__ || __DARWIN_NON_CANCELABLE */ + __DARWIN_ALIAS_C(select) +# endif /* __LP64__ && !__DARWIN_NON_CANCELABLE */ +#endif /* _DARWIN_C_SOURCE || _DARWIN_UNLIMITED_SELECT */ + ; + +#endif /* !_SYS__SELECT_H_ */ Index: branches/azimutz/Cleancut/i386/include/sys/select.h =================================================================== --- branches/azimutz/Cleancut/i386/include/sys/select.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/sys/select.h (revision 885) @@ -0,0 +1,157 @@ +/* + * Copyright (c) 2000-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@ + */ +/* + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)select.h 8.2 (Berkeley) 1/4/94 + */ + +#ifndef _SYS_SELECT_H_ +#define _SYS_SELECT_H_ + +#include <sys/appleapiopts.h> +#include <sys/cdefs.h> +#include <sys/_types.h> + +/* + * [XSI] The <sys/select.h> header shall define the fd_set type as a structure. + * The timespec structure shall be defined as described in <time.h> + * The <sys/select.h> header shall define the timeval structure. + */ +#define __need_fd_set +#define __need_struct_timespec +#define __need_struct_timeval +#include <sys/_structs.h> + +/* + * The time_t and suseconds_t types shall be defined as described in + * <sys/types.h> + * The sigset_t type shall be defined as described in <signal.h> + */ +#ifndef _TIME_T +#define _TIME_T +typedef __darwin_time_t time_t; +#endif + +#ifndef _SUSECONDS_T +#define _SUSECONDS_T +typedef __darwin_suseconds_t suseconds_t; +#endif + +#ifndef _SIGSET_T +#define _SIGSET_T +typedef __darwin_sigset_t sigset_t; +#endif + +/* + * [XSI] FD_CLR, FD_ISSET, FD_SET, FD_ZERO may be declared as a function, or + * defined as a macro, or both + * [XSI] FD_SETSIZE shall be defined as a macro + */ + +/* + * Select uses bit masks of file descriptors in longs. These macros + * manipulate such bit fields (the filesystem macros use chars). The + * extra protection here is to permit application redefinition above + * the default size. + */ +#ifndef FD_SETSIZE +#define FD_SETSIZE __DARWIN_FD_SETSIZE +#endif /* FD_SETSIZE */ +#ifndef FD_SET +#define FD_SET(n, p) __DARWIN_FD_SET(n, p) +#endif /* FD_SET */ +#ifndef FD_CLR +#define FD_CLR(n, p) __DARWIN_FD_CLR(n, p) +#endif /* FD_CLR */ +#ifndef FD_ISSET +#define FD_ISSET(n, p) __DARWIN_FD_ISSET(n, p) +#endif /* FD_ISSET */ +#ifndef FD_ZERO +#define FD_ZERO(p) __DARWIN_FD_ZERO(p) +#endif /* FD_ZERO */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#ifndef FD_COPY +#define FD_COPY(f, t) __DARWIN_FD_COPY(f, t) +#endif /* FD_COPY */ +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + + +__BEGIN_DECLS + +#ifndef __MWERKS__ +int pselect(int, fd_set * __restrict, fd_set * __restrict, + fd_set * __restrict, const struct timespec * __restrict, + const sigset_t * __restrict) +#if defined(_DARWIN_C_SOURCE) || defined(_DARWIN_UNLIMITED_SELECT) + __DARWIN_EXTSN_C(pselect) +#else /* !_DARWIN_C_SOURCE && !_DARWIN_UNLIMITED_SELECT */ +# if defined(__LP64__) && !__DARWIN_NON_CANCELABLE + __DARWIN_1050(pselect) +# else /* !__LP64__ || __DARWIN_NON_CANCELABLE */ + __DARWIN_ALIAS_C(pselect) +# endif /* __LP64__ && !__DARWIN_NON_CANCELABLE */ +#endif /* _DARWIN_C_SOURCE || _DARWIN_UNLIMITED_SELECT */ + ; +#endif /* __MWERKS__ */ + +#include <sys/_select.h> /* select() prototype */ + +__END_DECLS + + +#endif /* !_SYS_SELECT_H_ */ Index: branches/azimutz/Cleancut/i386/include/sys/cdefs.h =================================================================== --- branches/azimutz/Cleancut/i386/include/sys/cdefs.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/sys/cdefs.h (revision 885) @@ -0,0 +1,583 @@ +/* + * Copyright (c) 2000-2009 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 1995 NeXT Computer, Inc. All rights reserved. */ +/* + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Berkeley Software Design, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)cdefs.h 8.8 (Berkeley) 1/9/95 + */ + +#ifndef _CDEFS_H_ +#define _CDEFS_H_ + +#if defined(__cplusplus) +#define __BEGIN_DECLS extern "C" { +#define __END_DECLS } +#else +#define __BEGIN_DECLS +#define __END_DECLS +#endif + +/* + * The __CONCAT macro is used to concatenate parts of symbol names, e.g. + * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo. + * The __CONCAT macro is a bit tricky -- make sure you don't put spaces + * in between its arguments. __CONCAT can also concatenate double-quoted + * strings produced by the __STRING macro, but this only works with ANSI C. + */ +#if defined(__STDC__) || defined(__cplusplus) +#define __P(protos) protos /* full-blown ANSI C */ +#define __CONCAT(x,y) x ## y +#define __STRING(x) #x + +#define __const const /* define reserved names to standard */ +#define __signed signed +#define __volatile volatile +#if defined(__cplusplus) +#define __inline inline /* convert to C++ keyword */ +#else +#ifndef __GNUC__ +#define __inline /* delete GCC keyword */ +#endif /* !__GNUC__ */ +#endif /* !__cplusplus */ + +#else /* !(__STDC__ || __cplusplus) */ +#define __P(protos) () /* traditional C preprocessor */ +#define __CONCAT(x,y) x/**/y +#define __STRING(x) "x" + +#ifndef __GNUC__ +#define __const /* delete pseudo-ANSI C keywords */ +#define __inline +#define __signed +#define __volatile +#endif /* !__GNUC__ */ + +/* + * In non-ANSI C environments, new programs will want ANSI-only C keywords + * deleted from the program and old programs will want them left alone. + * When using a compiler other than gcc, programs using the ANSI C keywords + * const, inline etc. as normal identifiers should define -DNO_ANSI_KEYWORDS. + * When using "gcc -traditional", we assume that this is the intent; if + * __GNUC__ is defined but __STDC__ is not, we leave the new keywords alone. + */ +#ifndef NO_ANSI_KEYWORDS +#define const __const /* convert ANSI C keywords */ +#define inline __inline +#define signed __signed +#define volatile __volatile +#endif /* !NO_ANSI_KEYWORDS */ +#endif /* !(__STDC__ || __cplusplus) */ + +/* + * GCC1 and some versions of GCC2 declare dead (non-returning) and + * pure (no side effects) functions using "volatile" and "const"; + * unfortunately, these then cause warnings under "-ansi -pedantic". + * GCC2 uses a new, peculiar __attribute__((attrs)) style. All of + * these work for GNU C++ (modulo a slight glitch in the C++ grammar + * in the distribution version of 2.5.5). + */ +#if defined(__MWERKS__) && (__MWERKS__ > 0x2400) + /* newer Metrowerks compilers support __attribute__() */ +#elif __GNUC__ > 2 || __GNUC__ == 2 && __GNUC_MINOR__ >= 5 +#define __dead2 __attribute__((__noreturn__)) +#define __pure2 __attribute__((__const__)) +#if __GNUC__ == 2 && __GNUC_MINOR__ >= 5 && __GNUC_MINOR__ < 7 +#define __unused /* no attribute */ +#else +#define __unused __attribute__((__unused__)) +#endif +#else +#define __attribute__(x) /* delete __attribute__ if non-gcc or gcc1 */ +#if defined(__GNUC__) && !defined(__STRICT_ANSI__) +/* __dead and __pure are depreciated. Use __dead2 and __pure2 instead */ +#define __dead __volatile +#define __pure __const +#endif +#endif + +/* Delete pseudo-keywords wherever they are not available or needed. */ +#ifndef __dead +#define __dead +#define __pure +#endif +#ifndef __dead2 +#define __dead2 +#define __pure2 +#define __unused +#endif + +/* + * GCC 2.95 provides `__restrict' as an extension to C90 to support the + * C99-specific `restrict' type qualifier. We happen to use `__restrict' as + * a way to define the `restrict' type qualifier without disturbing older + * software that is unaware of C99 keywords. + */ +#if !(__GNUC__ == 2 && __GNUC_MINOR__ == 95) +#if __STDC_VERSION__ < 199901 +#define __restrict +#else +#define __restrict restrict +#endif +#endif + +/* + * Compiler-dependent macros to declare that functions take printf-like + * or scanf-like arguments. They are null except for versions of gcc + * that are known to support the features properly. Functions declared + * with these attributes will cause compilation warnings if there is a + * mismatch between the format string and subsequent function parameter + * types. + */ +#if __GNUC__ > 2 || __GNUC__ == 2 && __GNUC_MINOR__ >= 7 +#define __printflike(fmtarg, firstvararg) \ + __attribute__((__format__ (__printf__, fmtarg, firstvararg))) +#define __scanflike(fmtarg, firstvararg) \ + __attribute__((__format__ (__scanf__, fmtarg, firstvararg))) +#else +#define __printflike(fmtarg, firstvararg) +#define __scanflike(fmtarg, firstvararg) +#endif + +#define __IDSTRING(name,string) static const char name[] __unused = string + +#ifndef __COPYRIGHT +#define __COPYRIGHT(s) __IDSTRING(copyright,s) +#endif + +#ifndef __RCSID +#define __RCSID(s) __IDSTRING(rcsid,s) +#endif + +#ifndef __SCCSID +#define __SCCSID(s) __IDSTRING(sccsid,s) +#endif + +#ifndef __PROJECT_VERSION +#define __PROJECT_VERSION(s) __IDSTRING(project_version,s) +#endif + +/* + * COMPILATION ENVIRONMENTS + * + * DEFAULT By default newly complied code will get POSIX APIs plus + * Apple API extensions in scope. + * + * Most users will use this compilation environment to avoid + * behavioral differences between 32 and 64 bit code. + * + * LEGACY Defining _NONSTD_SOURCE will get pre-POSIX APIs plus Apple + * API extensions in scope. + * + * This is generally equivalent to the Tiger release compilation + * environment, except that it cannot be applied to 64 bit code; + * its use is discouraged. + * + * We expect this environment to be deprecated in the future. + * + * STRICT Defining _POSIX_C_SOURCE or _XOPEN_SOURCE restricts the + * available APIs to exactly the set of APIs defined by the + * corresponding standard, based on the value defined. + * + * A correct, portable definition for _POSIX_C_SOURCE is 200112L. + * A correct, portable definition for _XOPEN_SOURCE is 600L. + * + * Apple API extensions are not visible in this environment, + * which can cause Apple specific code to fail to compile, + * or behave incorrectly if prototypes are not in scope or + * warnings about missing prototypes are not enabled or ignored. + * + * In any compilation environment, for correct symbol resolution to occur, + * function prototypes must be in scope. It is recommended that all Apple + * tools users add either the "-Wall" or "-Wimplicit-function-declaration" + * compiler flags to their projects to be warned when a function is being + * used without a prototype in scope. + */ + +/* These settings are particular to each product. */ +/* Product: MacOSX */ +#define __DARWIN_ONLY_64_BIT_INO_T 0 +/* #undef __DARWIN_ONLY_UNIX_CONFORMANCE (automatically set for 64-bit) */ +#define __DARWIN_ONLY_VERS_1050 0 + +/* + * The __DARWIN_ALIAS macros are used to do symbol renaming; they allow + * legacy code to use the old symbol, thus maintaining binary compatibility + * while new code can use a standards compliant version of the same function. + * + * __DARWIN_ALIAS is used by itself if the function signature has not + * changed, it is used along with a #ifdef check for __DARWIN_UNIX03 + * if the signature has changed. Because the __LP64__ environment + * only supports UNIX03 semantics it causes __DARWIN_UNIX03 to be + * defined, but causes __DARWIN_ALIAS to do no symbol mangling. + * + * As a special case, when XCode is used to target a specific version of the + * OS, the manifest constant __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ + * will be defined by the compiler, with the digits representing major version + * time 100 + minor version times 10 (e.g. 10.5 := 1050). If we are targeting + * pre-10.5, and it is the default compilation environment, revert the + * compilation environment to pre-__DARWIN_UNIX03. + */ +#if !defined(__DARWIN_ONLY_UNIX_CONFORMANCE) +# if defined(__LP64__) +# define __DARWIN_ONLY_UNIX_CONFORMANCE 1 +# else /* !__LP64__ */ +# define __DARWIN_ONLY_UNIX_CONFORMANCE 0 +# endif /* __LP64__ */ +#endif /* !__DARWIN_ONLY_UNIX_CONFORMANCE */ + +#if !defined(__DARWIN_UNIX03) +# if __DARWIN_ONLY_UNIX_CONFORMANCE +# if defined(_NONSTD_SOURCE) +# error "Can't define _NONSTD_SOURCE when only UNIX conformance is available." +# endif /* _NONSTD_SOURCE */ +# define __DARWIN_UNIX03 1 +# elif defined(_DARWIN_C_SOURCE) || defined(_XOPEN_SOURCE) || defined(_POSIX_C_SOURCE) +# if defined(_NONSTD_SOURCE) +# error "Can't define both _NONSTD_SOURCE and any of _DARWIN_C_SOURCE, _XOPEN_SOURCE or _POSIX_C_SOURCE." +# endif /* _NONSTD_SOURCE */ +# define __DARWIN_UNIX03 1 +# elif defined(_NONSTD_SOURCE) +# define __DARWIN_UNIX03 0 +# else /* default */ +# if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && ((__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__-0) < 1050) +# define __DARWIN_UNIX03 0 +# else /* __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050 */ +# define __DARWIN_UNIX03 1 +# endif /* __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050 */ +# endif /* _DARWIN_C_SOURCE || _XOPEN_SOURCE || _POSIX_C_SOURCE || __LP64__ */ +#endif /* !__DARWIN_UNIX03 */ + +#if !defined(__DARWIN_64_BIT_INO_T) +# if defined(_DARWIN_USE_64_BIT_INODE) +# if defined(_DARWIN_NO_64_BIT_INODE) +# error "Can't define both _DARWIN_USE_64_BIT_INODE and _DARWIN_NO_64_BIT_INODE." +# endif /* _DARWIN_NO_64_BIT_INODE */ +# define __DARWIN_64_BIT_INO_T 1 +# elif defined(_DARWIN_NO_64_BIT_INODE) +# if __DARWIN_ONLY_64_BIT_INO_T +# error "Can't define _DARWIN_NO_64_BIT_INODE when only 64-bit inodes are available." +# endif /* __DARWIN_ONLY_64_BIT_INO_T */ +# define __DARWIN_64_BIT_INO_T 0 +# else /* default */ +# if __DARWIN_ONLY_64_BIT_INO_T +# define __DARWIN_64_BIT_INO_T 1 +# elif defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && ((__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__-0) < 1060) || __DARWIN_UNIX03 == 0 +# define __DARWIN_64_BIT_INO_T 0 +# else /* default */ +# define __DARWIN_64_BIT_INO_T 1 +# endif /* __DARWIN_ONLY_64_BIT_INO_T */ +# endif +#endif /* !__DARWIN_64_BIT_INO_T */ + +#if !defined(__DARWIN_VERS_1050) +# if __DARWIN_ONLY_VERS_1050 +# define __DARWIN_VERS_1050 1 +# elif defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && ((__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__-0) < 1050) || __DARWIN_UNIX03 == 0 +# define __DARWIN_VERS_1050 0 +# else /* default */ +# define __DARWIN_VERS_1050 1 +# endif +#endif /* !__DARWIN_VERS_1050 */ + +#if !defined(__DARWIN_NON_CANCELABLE) +# define __DARWIN_NON_CANCELABLE 0 +#endif /* !__DARWIN_NON_CANCELABLE */ + +/* + * symbol suffixes used for symbol versioning + */ +#if __DARWIN_UNIX03 +# if __DARWIN_ONLY_UNIX_CONFORMANCE +# define __DARWIN_SUF_UNIX03 /* nothing */ +# else /* !__DARWIN_ONLY_UNIX_CONFORMANCE */ +# define __DARWIN_SUF_UNIX03 "$UNIX2003" +# endif /* __DARWIN_ONLY_UNIX_CONFORMANCE */ + +# if __DARWIN_64_BIT_INO_T +# if __DARWIN_ONLY_64_BIT_INO_T +# define __DARWIN_SUF_64_BIT_INO_T /* nothing */ +# else /* !__DARWIN_ONLY_64_BIT_INO_T */ +# define __DARWIN_SUF_64_BIT_INO_T "$INODE64" +# endif /* __DARWIN_ONLY_64_BIT_INO_T */ +# else /* !__DARWIN_64_BIT_INO_T */ +# define __DARWIN_SUF_64_BIT_INO_T /* nothing */ +# endif /* __DARWIN_64_BIT_INO_T */ + +# if __DARWIN_VERS_1050 +# if __DARWIN_ONLY_VERS_1050 +# define __DARWIN_SUF_1050 /* nothing */ +# else /* !__DARWIN_ONLY_VERS_1050 */ +# define __DARWIN_SUF_1050 "$1050" +# endif /* __DARWIN_ONLY_VERS_1050 */ +# else /* !__DARWIN_VERS_1050 */ +# define __DARWIN_SUF_1050 /* nothing */ +# endif /* __DARWIN_VERS_1050 */ + +# if __DARWIN_NON_CANCELABLE +# define __DARWIN_SUF_NON_CANCELABLE "$NOCANCEL" +# else /* !__DARWIN_NON_CANCELABLE */ +# define __DARWIN_SUF_NON_CANCELABLE /* nothing */ +# endif /* __DARWIN_NON_CANCELABLE */ + +#else /* !__DARWIN_UNIX03 */ +# define __DARWIN_SUF_UNIX03 /* nothing */ +# define __DARWIN_SUF_64_BIT_INO_T /* nothing */ +# define __DARWIN_SUF_NON_CANCELABLE /* nothing */ +# define __DARWIN_SUF_1050 /* nothing */ +#endif /* __DARWIN_UNIX03 */ + +#define __DARWIN_SUF_EXTSN "$DARWIN_EXTSN" + +/* + * symbol versioning macros + */ +#define __DARWIN_ALIAS(sym) __asm("_" __STRING(sym) __DARWIN_SUF_UNIX03) +#define __DARWIN_ALIAS_C(sym) __asm("_" __STRING(sym) __DARWIN_SUF_NON_CANCELABLE __DARWIN_SUF_UNIX03) +#define __DARWIN_ALIAS_I(sym) __asm("_" __STRING(sym) __DARWIN_SUF_64_BIT_INO_T __DARWIN_SUF_UNIX03) +#define __DARWIN_INODE64(sym) __asm("_" __STRING(sym) __DARWIN_SUF_64_BIT_INO_T) + +#define __DARWIN_1050(sym) __asm("_" __STRING(sym) __DARWIN_SUF_1050) +#define __DARWIN_1050ALIAS(sym) __asm("_" __STRING(sym) __DARWIN_SUF_1050 __DARWIN_SUF_UNIX03) +#define __DARWIN_1050ALIAS_C(sym) __asm("_" __STRING(sym) __DARWIN_SUF_1050 __DARWIN_SUF_NON_CANCELABLE __DARWIN_SUF_UNIX03) +#define __DARWIN_1050ALIAS_I(sym) __asm("_" __STRING(sym) __DARWIN_SUF_1050 __DARWIN_SUF_64_BIT_INO_T __DARWIN_SUF_UNIX03) +#define __DARWIN_1050INODE64(sym) __asm("_" __STRING(sym) __DARWIN_SUF_1050 __DARWIN_SUF_64_BIT_INO_T) + +#define __DARWIN_EXTSN(sym) __asm("_" __STRING(sym) __DARWIN_SUF_EXTSN) +#define __DARWIN_EXTSN_C(sym) __asm("_" __STRING(sym) __DARWIN_SUF_EXTSN __DARWIN_SUF_NON_CANCELABLE) + +/* + * symbol release macros + */ +#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && ((__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__-0) < 1060) +#undef __DARWIN_10_6_AND_LATER +#define __DARWIN_10_6_AND_LATER_ALIAS(x) /* nothing */ +#else /* 10.6 and beyond */ +#define __DARWIN_10_6_AND_LATER +#define __DARWIN_10_6_AND_LATER_ALIAS(x) x +#endif + + +/* + * POSIX.1 requires that the macros we test be defined before any standard + * header file is included. This permits us to convert values for feature + * testing, as necessary, using only _POSIX_C_SOURCE. + * + * Here's a quick run-down of the versions: + * defined(_POSIX_SOURCE) 1003.1-1988 + * _POSIX_C_SOURCE == 1L 1003.1-1990 + * _POSIX_C_SOURCE == 2L 1003.2-1992 C Language Binding Option + * _POSIX_C_SOURCE == 199309L 1003.1b-1993 + * _POSIX_C_SOURCE == 199506L 1003.1c-1995, 1003.1i-1995, + * and the omnibus ISO/IEC 9945-1: 1996 + * _POSIX_C_SOURCE == 200112L 1003.1-2001 + * + * In addition, the X/Open Portability Guide, which is now the Single UNIX + * Specification, defines a feature-test macro which indicates the version of + * that specification, and which subsumes _POSIX_C_SOURCE. + */ + +/* Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1L. */ +#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 1L +#undef _POSIX_C_SOURCE +#define _POSIX_C_SOURCE 199009L +#endif + +/* Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2L. */ +#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 2L +#undef _POSIX_C_SOURCE +#define _POSIX_C_SOURCE 199209L +#endif + +/* Deal with various X/Open Portability Guides and Single UNIX Spec. */ +#ifdef _XOPEN_SOURCE +#if _XOPEN_SOURCE - 0L >= 600L +#undef _POSIX_C_SOURCE +#define _POSIX_C_SOURCE 200112L +#elif _XOPEN_SOURCE - 0L >= 500L +#undef _POSIX_C_SOURCE +#define _POSIX_C_SOURCE 199506L +#endif +#endif + +/* + * Deal with all versions of POSIX. The ordering relative to the tests above is + * important. + */ +#if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE) +#define _POSIX_C_SOURCE 198808L +#endif + +/* + * long long is not supported in c89 (__STRICT_ANSI__), but g++ -ansi and + * c99 still want long longs. While not perfect, we allow long longs for + * g++. + */ +#define __DARWIN_NO_LONG_LONG (defined(__STRICT_ANSI__) \ + && (__STDC_VERSION__-0 < 199901L) \ + && !defined(__GNUG__)) + +/* + * Long double compatibility macro allow selecting variant symbols based + * on the old (compatible) 64-bit long doubles, or the new 128-bit + * long doubles. This applies only to ppc; i386 already has long double + * support, while ppc64 doesn't have any backwards history. + */ +#if defined(__arm__) +# define __DARWIN_LDBL_COMPAT(x) /* nothing */ +# define __DARWIN_LDBL_COMPAT2(x) /* nothing */ +# define __DARWIN_LONG_DOUBLE_IS_DOUBLE 1 +#elif defined(__ppc__) +# if defined(__LDBL_MANT_DIG__) && defined(__DBL_MANT_DIG__) && \ + __LDBL_MANT_DIG__ > __DBL_MANT_DIG__ +# if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__-0 < 1040 +# define __DARWIN_LDBL_COMPAT(x) __asm("_" __STRING(x) "$LDBLStub") +# else +# define __DARWIN_LDBL_COMPAT(x) __asm("_" __STRING(x) "$LDBL128") +# endif +# define __DARWIN_LDBL_COMPAT2(x) __asm("_" __STRING(x) "$LDBL128") +# define __DARWIN_LONG_DOUBLE_IS_DOUBLE 0 +# else +# define __DARWIN_LDBL_COMPAT(x) /* nothing */ +# define __DARWIN_LDBL_COMPAT2(x) /* nothing */ +# define __DARWIN_LONG_DOUBLE_IS_DOUBLE 1 +# endif +#elif defined(__i386__) || defined(__ppc64__) || defined(__x86_64__) +# define __DARWIN_LDBL_COMPAT(x) /* nothing */ +# define __DARWIN_LDBL_COMPAT2(x) /* nothing */ +# define __DARWIN_LONG_DOUBLE_IS_DOUBLE 0 +#else +# error Unknown architecture +#endif + +/* + * Deprecation macro + */ +#if __GNUC__ >= 3 +#define __deprecated __attribute__((deprecated)) +#else +#define __deprecated /* nothing */ +#endif + +/***************************************** + * Public darwin-specific feature macros + *****************************************/ + +/* + * _DARWIN_FEATURE_64_BIT_INODE indicates that the ino_t type is 64-bit, and + * structures modified for 64-bit inodes (like struct stat) will be used. + */ +#if __DARWIN_64_BIT_INO_T +#define _DARWIN_FEATURE_64_BIT_INODE 1 +#endif + +/* + * _DARWIN_FEATURE_LONG_DOUBLE_IS_DOUBLE indicates when the long double type + * is the same as the double type (ppc and arm only) + */ +#if __DARWIN_LONG_DOUBLE_IS_DOUBLE +#define _DARWIN_FEATURE_LONG_DOUBLE_IS_DOUBLE 1 +#endif + +/* + * _DARWIN_FEATURE_64_ONLY_BIT_INODE indicates that the ino_t type may only + * be 64-bit; there is no support for 32-bit ino_t when this macro is defined + * (and non-zero). There is no struct stat64 either, as the regular + * struct stat will already be the 64-bit version. + */ +#if __DARWIN_ONLY_64_BIT_INO_T +#define _DARWIN_FEATURE_ONLY_64_BIT_INODE 1 +#endif + +/* + * _DARWIN_FEATURE_ONLY_VERS_1050 indicates that only those APIs updated + * in 10.5 exists; no pre-10.5 variants are available. + */ +#if __DARWIN_ONLY_VERS_1050 +#define _DARWIN_FEATURE_ONLY_VERS_1050 1 +#endif + +/* + * _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE indicates only UNIX conforming API + * are available (the legacy BSD APIs are not available) + */ +#if __DARWIN_ONLY_UNIX_CONFORMANCE +#define _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE 1 +#endif + +/* + * _DARWIN_FEATURE_UNIX_CONFORMANCE indicates whether UNIX conformance is on, + * and specifies the conformance level (3 is SUSv3) + */ +#if __DARWIN_UNIX03 +#define _DARWIN_FEATURE_UNIX_CONFORMANCE 3 +#endif + +/* + * This macro casts away the qualifier from the variable + * + * Note: use at your own risk, removing qualifiers can result in + * catastrophic run-time failures. + */ +#ifndef __CAST_AWAY_QUALIFIER +#define __CAST_AWAY_QUALIFIER(variable, qualifier, type) (type) ((char *)0 + ((qualifier char *)(variable) - (qualifier char *)0) ) +#endif + +#endif /* !_CDEFS_H_ */ Index: branches/azimutz/Cleancut/i386/include/sys/socket.h =================================================================== --- branches/azimutz/Cleancut/i386/include/sys/socket.h (revision 0) +++ branches/azimutz/Cleancut/i386/include/sys/socket.h (revision 885) @@ -0,0 +1,629 @@ +/* + * Copyright (c) 2000-2007 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 */ +/* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */ +/* + * Copyright (c) 1982, 1985, 1986, 1988, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)socket.h 8.4 (Berkeley) 2/21/94 + * $FreeBSD: src/sys/sys/socket.h,v 1.39.2.7 2001/07/03 11:02:01 ume Exp $ + */ +/* + * NOTICE: This file was modified by SPARTA, Inc. in 2005 to introduce + * support for mandatory and extensible security protections. This notice + * is included in support of clause 2.2 (b) of the Apple Public License, + * Version 2.0. + */ + +#ifndef _SYS_SOCKET_H_ +#define _SYS_SOCKET_H_ + +#include <sys/types.h> +#include <sys/cdefs.h> +#include <machine/_param.h> + +/* + * Definitions related to sockets: types, address families, options. + */ + +/* + * Data types. + */ +#ifndef _GID_T +typedef __darwin_gid_t gid_t; +#define _GID_T +#endif + +#ifndef _OFF_T +typedef __darwin_off_t off_t; +#define _OFF_T +#endif + +#ifndef _PID_T +typedef __darwin_pid_t pid_t; +#define _PID_T +#endif + +#ifndef _SA_FAMILY_T +#define _SA_FAMILY_T +typedef __uint8_t sa_family_t; +#endif + +#ifndef _SOCKLEN_T +#define _SOCKLEN_T +typedef __darwin_socklen_t socklen_t; +#endif + +/* XXX Not explicitly defined by POSIX, but function return types are */ +#ifndef _SIZE_T +#define _SIZE_T +typedef __darwin_size_t size_t; +#endif + +/* XXX Not explicitly defined by POSIX, but function return types are */ +#ifndef _SSIZE_T +#define _SSIZE_T +typedef __darwin_ssize_t ssize_t; +#endif + +/* + * [XSI] The iovec structure shall be defined as described in <sys/uio.h>. + */ +#ifndef _STRUCT_IOVEC +#define _STRUCT_IOVEC +struct iovec { + void * iov_base; /* [XSI] Base address of I/O memory region */ + size_t iov_len; /* [XSI] Size of region iov_base points to */ +}; +#endif + +/* + * Types + */ +#define SOCK_STREAM 1 /* stream socket */ +#define SOCK_DGRAM 2 /* datagram socket */ +#define SOCK_RAW 3 /* raw-protocol interface */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define SOCK_RDM 4 /* reliably-delivered message */ +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ +#define SOCK_SEQPACKET 5 /* sequenced packet stream */ + +/* + * Option flags per-socket. + */ +#define SO_DEBUG 0x0001 /* turn on debugging info recording */ +#define SO_ACCEPTCONN 0x0002 /* socket has had listen() */ +#define SO_REUSEADDR 0x0004 /* allow local address reuse */ +#define SO_KEEPALIVE 0x0008 /* keep connections alive */ +#define SO_DONTROUTE 0x0010 /* just use interface addresses */ +#define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */ +#define SO_LINGER 0x0080 /* linger on close if data present (in ticks) */ +#else +#define SO_LINGER 0x1080 /* linger on close if data present (in seconds) */ +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ +#define SO_OOBINLINE 0x0100 /* leave received OOB data in line */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define SO_REUSEPORT 0x0200 /* allow local address & port reuse */ +#define SO_TIMESTAMP 0x0400 /* timestamp received dgram traffic */ +#ifndef __APPLE__ +#define SO_ACCEPTFILTER 0x1000 /* there is an accept filter */ +#else +#define SO_DONTTRUNC 0x2000 /* APPLE: Retain unread data */ + /* (ATOMIC proto) */ +#define SO_WANTMORE 0x4000 /* APPLE: Give hint when more data ready */ +#define SO_WANTOOBFLAG 0x8000 /* APPLE: Want OOB in MSG_FLAG on receive */ +#endif +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + +/* + * Additional options, not kept in so_options. + */ +#define SO_SNDBUF 0x1001 /* send buffer size */ +#define SO_RCVBUF 0x1002 /* receive buffer size */ +#define SO_SNDLOWAT 0x1003 /* send low-water mark */ +#define SO_RCVLOWAT 0x1004 /* receive low-water mark */ +#define SO_SNDTIMEO 0x1005 /* send timeout */ +#define SO_RCVTIMEO 0x1006 /* receive timeout */ +#define SO_ERROR 0x1007 /* get error status and clear */ +#define SO_TYPE 0x1008 /* get socket type */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +/*efine SO_PRIVSTATE 0x1009 get/deny privileged state */ +#ifdef __APPLE__ +#define SO_NREAD 0x1020 /* APPLE: get 1st-packet byte count */ +#define SO_NKE 0x1021 /* APPLE: Install socket-level NKE */ +#define SO_NOSIGPIPE 0x1022 /* APPLE: No SIGPIPE on EPIPE */ +#define SO_NOADDRERR 0x1023 /* APPLE: Returns EADDRNOTAVAIL when src is not available anymore */ +#define SO_NWRITE 0x1024 /* APPLE: Get number of bytes currently in send socket buffer */ +#define SO_REUSESHAREUID 0x1025 /* APPLE: Allow reuse of port/socket by different userids */ +#ifdef __APPLE_API_PRIVATE +#define SO_NOTIFYCONFLICT 0x1026 /* APPLE: send notification if there is a bind on a port which is already in use */ +#define SO_UPCALLCLOSEWAIT 0x1027 /* APPLE: block on close until an upcall returns */ +#endif +#define SO_LINGER_SEC 0x1080 /* linger on close if data present (in seconds) */ +#define SO_RESTRICTIONS 0x1081 /* APPLE: deny inbound/outbound/both/flag set */ +#define SO_RESTRICT_DENYIN 0x00000001 /* flag for SO_RESTRICTIONS - deny inbound */ +#define SO_RESTRICT_DENYOUT 0x00000002 /* flag for SO_RESTRICTIONS - deny outbound */ +#define SO_RESTRICT_DENYSET 0x80000000 /* flag for SO_RESTRICTIONS - deny has been set */ +#define SO_RANDOMPORT 0x1082 /* APPLE: request local port randomization */ +#define SO_NP_EXTENSIONS 0x1083 /* To turn off some POSIX behavior */ +#endif +#define SO_LABEL 0x1010 /* socket's MAC label */ +#define SO_PEERLABEL 0x1011 /* socket's peer MAC label */ +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + +/* + * Structure used for manipulating linger option. + */ +struct linger { + int l_onoff; /* option on/off */ + int l_linger; /* linger time */ +}; + +#ifndef __APPLE__ +struct accept_filter_arg { + char af_name[16]; + char af_arg[256-16]; +}; +#endif + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#ifdef __APPLE__ + +/* + * Structure to control non-portable Sockets extension to POSIX + */ +struct so_np_extensions { + u_int32_t npx_flags; + u_int32_t npx_mask; +}; + +#define SONPX_SETOPTSHUT 0x000000001 /* flag for allowing setsockopt after shutdown */ + + + +#endif +#endif + +/* + * Level number for (get/set)sockopt() to apply to socket itself. + */ +#define SOL_SOCKET 0xffff /* options for socket level */ + + +/* + * Address families. + */ +#define AF_UNSPEC 0 /* unspecified */ +#define AF_UNIX 1 /* local to host (pipes) */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define AF_LOCAL AF_UNIX /* backward compatibility */ +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ +#define AF_INET 2 /* internetwork: UDP, TCP, etc. */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define AF_IMPLINK 3 /* arpanet imp addresses */ +#define AF_PUP 4 /* pup protocols: e.g. BSP */ +#define AF_CHAOS 5 /* mit CHAOS protocols */ +#define AF_NS 6 /* XEROX NS protocols */ +#define AF_ISO 7 /* ISO protocols */ +#define AF_OSI AF_ISO +#define AF_ECMA 8 /* European computer manufacturers */ +#define AF_DATAKIT 9 /* datakit protocols */ +#define AF_CCITT 10 /* CCITT protocols, X.25 etc */ +#define AF_SNA 11 /* IBM SNA */ +#define AF_DECnet 12 /* DECnet */ +#define AF_DLI 13 /* DEC Direct data link interface */ +#define AF_LAT 14 /* LAT */ +#define AF_HYLINK 15 /* NSC Hyperchannel */ +#define AF_APPLETALK 16 /* Apple Talk */ +#define AF_ROUTE 17 /* Internal Routing Protocol */ +#define AF_LINK 18 /* Link layer interface */ +#define pseudo_AF_XTP 19 /* eXpress Transfer Protocol (no AF) */ +#define AF_COIP 20 /* connection-oriented IP, aka ST II */ +#define AF_CNT 21 /* Computer Network Technology */ +#define pseudo_AF_RTIP 22 /* Help Identify RTIP packets */ +#define AF_IPX 23 /* Novell Internet Protocol */ +#define AF_SIP 24 /* Simple Internet Protocol */ +#define pseudo_AF_PIP 25 /* Help Identify PIP packets */ +#ifdef __APPLE__ +/*define pseudo_AF_BLUE 26 Identify packets for Blue Box - Not used */ +#define AF_NDRV 27 /* Network Driver 'raw' access */ +#endif +#define AF_ISDN 28 /* Integrated Services Digital Network*/ +#define AF_E164 AF_ISDN /* CCITT E.164 recommendation */ +#define pseudo_AF_KEY 29 /* Internal key-management function */ +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ +#define AF_INET6 30 /* IPv6 */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define AF_NATM 31 /* native ATM access */ +#ifdef __APPLE__ +#define AF_SYSTEM 32 /* Kernel event messages */ +#define AF_NETBIOS 33 /* NetBIOS */ +#define AF_PPP 34 /* PPP communication protocol */ +#else +#define AF_ATM 30 /* ATM */ +#endif +#define pseudo_AF_HDRCMPLT 35 /* Used by BPF to not rewrite headers + * in interface output routine + */ +#define AF_RESERVED_36 36 /* Reserved for internal usage */ + +#ifndef __APPLE__ +#define AF_NETGRAPH 32 /* Netgraph sockets */ +#endif +#define AF_IEEE80211 37 /* IEEE 802.11 protocol */ +#define AF_MAX 38 +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + +/* + * [XSI] Structure used by kernel to store most addresses. + */ +struct sockaddr { + __uint8_t sa_len; /* total length */ + sa_family_t sa_family; /* [XSI] address family */ + char sa_data[14]; /* [XSI] addr value (actually larger) */ +}; + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define SOCK_MAXADDRLEN 255 /* longest possible addresses */ + +/* + * Structure used by kernel to pass protocol + * information in raw sockets. + */ +struct sockproto { + __uint16_t sp_family; /* address family */ + __uint16_t sp_protocol; /* protocol */ +}; +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE)*/ + +/* + * RFC 2553: protocol-independent placeholder for socket addresses + */ +#define _SS_MAXSIZE 128 +#define _SS_ALIGNSIZE (sizeof(__int64_t)) +#define _SS_PAD1SIZE \ + (_SS_ALIGNSIZE - sizeof(__uint8_t) - sizeof(sa_family_t)) +#define _SS_PAD2SIZE \ + (_SS_MAXSIZE - sizeof(__uint8_t) - sizeof(sa_family_t) - \ + _SS_PAD1SIZE - _SS_ALIGNSIZE) + +/* + * [XSI] sockaddr_storage + */ +struct sockaddr_storage { + __uint8_t ss_len; /* address length */ + sa_family_t ss_family; /* [XSI] address family */ + char __ss_pad1[_SS_PAD1SIZE]; + __int64_t __ss_align; /* force structure storage alignment */ + char __ss_pad2[_SS_PAD2SIZE]; +}; + +/* + * Protocol families, same as address families for now. + */ +#define PF_UNSPEC AF_UNSPEC +#define PF_LOCAL AF_LOCAL +#define PF_UNIX PF_LOCAL /* backward compatibility */ +#define PF_INET AF_INET +#define PF_IMPLINK AF_IMPLINK +#define PF_PUP AF_PUP +#define PF_CHAOS AF_CHAOS +#define PF_NS AF_NS +#define PF_ISO AF_ISO +#define PF_OSI AF_ISO +#define PF_ECMA AF_ECMA +#define PF_DATAKIT AF_DATAKIT +#define PF_CCITT AF_CCITT +#define PF_SNA AF_SNA +#define PF_DECnet AF_DECnet +#define PF_DLI AF_DLI +#define PF_LAT AF_LAT +#define PF_HYLINK AF_HYLINK +#define PF_APPLETALK AF_APPLETALK +#define PF_ROUTE AF_ROUTE +#define PF_LINK AF_LINK +#define PF_XTP pseudo_AF_XTP /* really just proto family, no AF */ +#define PF_COIP AF_COIP +#define PF_CNT AF_CNT +#define PF_SIP AF_SIP +#define PF_IPX AF_IPX /* same format as AF_NS */ +#define PF_RTIP pseudo_AF_RTIP /* same format as AF_INET */ +#define PF_PIP pseudo_AF_PIP +#ifdef __APPLE__ +#define PF_NDRV AF_NDRV +#endif +#define PF_ISDN AF_ISDN +#define PF_KEY pseudo_AF_KEY +#define PF_INET6 AF_INET6 +#define PF_NATM AF_NATM +#ifdef __APPLE__ +#define PF_SYSTEM AF_SYSTEM +#define PF_NETBIOS AF_NETBIOS +#define PF_PPP AF_PPP +#define PF_RESERVED_36 AF_RESERVED_36 + +#else +#define PF_ATM AF_ATM +#define PF_NETGRAPH AF_NETGRAPH +#endif + +#define PF_MAX AF_MAX + +/* + * These do not have socket-layer support: + */ +#define PF_VLAN ((uint32_t)0x766c616e) /* 'vlan' */ +#define PF_BOND ((uint32_t)0x626f6e64) /* 'bond' */ + +/* + * Definitions for network related sysctl, CTL_NET. + * + * Second level is protocol family. + * Third level is protocol number. + * + * Further levels are defined by the individual families below. + */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define NET_MAXID AF_MAX +#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ + + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +/* + * PF_ROUTE - Routing table + * + * Three additional levels are defined: + * Fourth: address family, 0 is wildcard + * Fifth: type of info, defined below + * Sixth: flag(s) to mask with for NET_RT_FLAGS + */ +#define NET_RT_DUMP 1 /* dump; may limit to a.f. */ +#define NET_RT_FLAGS 2 /* by flags, e.g. RESOLVING */ +#define NET_RT_IFLIST 3 /* survey interface list */ +#define NET_RT_STAT 4 /* routing statistics */ +#define NET_RT_TRASH 5 /* routes not in table but not freed */ +#define NET_RT_IFLIST2 6 /* interface list with addresses */ +#define NET_RT_DUMP2 7 /* dump; may limit to a.f. */ +#define NET_RT_MAXID 8 +#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ + + +/* + * Maximum queue length specifiable by listen. + */ +#define SOMAXCONN 128 + +/* + * [XSI] Message header for recvmsg and sendmsg calls. + * Used value-result for recvmsg, value only for sendmsg. + */ +struct msghdr { + void *msg_name; /* [XSI] optional address */ + socklen_t msg_namelen; /* [XSI] size of address */ + struct iovec *msg_iov; /* [XSI] scatter/gather array */ + int msg_iovlen; /* [XSI] # elements in msg_iov */ + void *msg_control; /* [XSI] ancillary data, see below */ + socklen_t msg_controllen; /* [XSI] ancillary data buffer len */ + int msg_flags; /* [XSI] flags on received message */ +}; + + +#define MSG_OOB 0x1 /* process out-of-band data */ +#define MSG_PEEK 0x2 /* peek at incoming message */ +#define MSG_DONTROUTE 0x4 /* send without using routing tables */ +#define MSG_EOR 0x8 /* data completes record */ +#define MSG_TRUNC 0x10 /* data discarded before delivery */ +#define MSG_CTRUNC 0x20 /* control data lost before delivery */ +#define MSG_WAITALL 0x40 /* wait for full request or error */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define MSG_DONTWAIT 0x80 /* this message should be nonblocking */ +#define MSG_EOF 0x100 /* data completes connection */ +#ifdef __APPLE__ +#define MSG_WAITSTREAM 0x200 /* wait up to full request.. may return partial */ +#define MSG_FLUSH 0x400 /* Start of 'hold' seq; dump so_temp */ +#define MSG_HOLD 0x800 /* Hold frag in so_temp */ +#define MSG_SEND 0x1000 /* Send the packet in so_temp */ +#define MSG_HAVEMORE 0x2000 /* Data ready to be read */ +#define MSG_RCVMORE 0x4000 /* Data remains in current pkt */ +#endif +#define MSG_NEEDSA 0x10000 /* Fail receive if socket address cannot be allocated */ +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + +/* + * Header for ancillary data objects in msg_control buffer. + * Used for additional information with/about a datagram + * not expressible by flags. The format is a sequence + * of message elements headed by cmsghdr structures. + */ +struct cmsghdr { + socklen_t cmsg_len; /* [XSI] data byte count, including hdr */ + int cmsg_level; /* [XSI] originating protocol */ + int cmsg_type; /* [XSI] protocol-specific type */ +/* followed by unsigned char cmsg_data[]; */ +}; + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#ifndef __APPLE__ +/* + * While we may have more groups than this, the cmsgcred struct must + * be able to fit in an mbuf, and NGROUPS_MAX is too large to allow + * this. +*/ +#define CMGROUP_MAX 16 + +/* + * Credentials structure, used to verify the identity of a peer + * process that has sent us a message. This is allocated by the + * peer process but filled in by the kernel. This prevents the + * peer from lying about its identity. (Note that cmcred_groups[0] + * is the effective GID.) + */ +struct cmsgcred { + pid_t cmcred_pid; /* PID of sending process */ + uid_t cmcred_uid; /* real UID of sending process */ + uid_t cmcred_euid; /* effective UID of sending process */ + gid_t cmcred_gid; /* real GID of sending process */ + short cmcred_ngroups; /* number or groups */ + gid_t cmcred_groups[CMGROUP_MAX]; /* groups */ +}; +#endif +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + +/* given pointer to struct cmsghdr, return pointer to data */ +#define CMSG_DATA(cmsg) ((unsigned char *)(cmsg) + \ + __DARWIN_ALIGN32(sizeof(struct cmsghdr))) + +/* + * RFC 2292 requires to check msg_controllen, in case that the kernel returns + * an empty list for some reasons. + */ +#define CMSG_FIRSTHDR(mhdr) \ + ((mhdr)->msg_controllen >= sizeof(struct cmsghdr) ? \ + (struct cmsghdr *)(mhdr)->msg_control : \ + (struct cmsghdr *)0L) + + +/* + * Given pointer to struct cmsghdr, return pointer to next cmsghdr + * RFC 2292 says that CMSG_NXTHDR(mhdr, NULL) is equivalent to CMSG_FIRSTHDR(mhdr) + */ +#define CMSG_NXTHDR(mhdr, cmsg) \ + ((char *)(cmsg) == (char *)0L ? CMSG_FIRSTHDR(mhdr) : \ + ((((unsigned char *)(cmsg) + \ + __DARWIN_ALIGN32((__uint32_t)(cmsg)->cmsg_len) + \ + __DARWIN_ALIGN32(sizeof(struct cmsghdr))) > \ + ((unsigned char *)(mhdr)->msg_control + \ + (mhdr)->msg_controllen)) ? \ + (struct cmsghdr *)0L /* NULL */ : \ + (struct cmsghdr *)((unsigned char *)(cmsg) + \ + __DARWIN_ALIGN32((__uint32_t)(cmsg)->cmsg_len)))) + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +/* RFC 2292 additions */ +#define CMSG_SPACE(l) (__DARWIN_ALIGN32(sizeof(struct cmsghdr)) + __DARWIN_ALIGN32(l)) +#define CMSG_LEN(l) (__DARWIN_ALIGN32(sizeof(struct cmsghdr)) + (l)) + +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + +/* "Socket"-level control message types: */ +#define SCM_RIGHTS 0x01 /* access rights (array of int) */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define SCM_TIMESTAMP 0x02 /* timestamp (struct timeval) */ +#define SCM_CREDS 0x03 /* process creds (struct cmsgcred) */ + +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + +/* + * howto arguments for shutdown(2), specified by Posix.1g. + */ +#define SHUT_RD 0 /* shut down the reading side */ +#define SHUT_WR 1 /* shut down the writing side */ +#define SHUT_RDWR 2 /* shut down both sides */ + +#if !defined(_POSIX_C_SOURCE) +/* + * sendfile(2) header/trailer struct + */ +struct sf_hdtr { + struct iovec *headers; /* pointer to an array of header struct iovec's */ + int hdr_cnt; /* number of header iovec's */ + struct iovec *trailers; /* pointer to an array of trailer struct iovec's */ + int trl_cnt; /* number of trailer iovec's */ +}; + + +#endif /* !_POSIX_C_SOURCE */ + +__BEGIN_DECLS +int accept(int, struct sockaddr * __restrict, socklen_t * __restrict) + __DARWIN_ALIAS_C(accept); +int bind(int, const struct sockaddr *, socklen_t) __DARWIN_ALIAS(bind); +int connect(int, const struct sockaddr *, socklen_t) __DARWIN_ALIAS_C( connect); +int getpeername(int, struct sockaddr * __restrict, socklen_t * __restrict) + __DARWIN_ALIAS(getpeername); +int getsockname(int, struct sockaddr * __restrict, socklen_t * __restrict) + __DARWIN_ALIAS(getsockname); +int getsockopt(int, int, int, void * __restrict, socklen_t * __restrict); +int listen(int, int) __DARWIN_ALIAS(listen); +ssize_t recv(int, void *, size_t, int) __DARWIN_ALIAS_C(recv); +ssize_t recvfrom(int, void *, size_t, int, struct sockaddr * __restrict, + socklen_t * __restrict) __DARWIN_ALIAS_C(recvfrom); +ssize_t recvmsg(int, struct msghdr *, int) __DARWIN_ALIAS_C(recvmsg); +ssize_t send(int, const void *, size_t, int) __DARWIN_ALIAS_C(send); +ssize_t sendmsg(int, const struct msghdr *, int) __DARWIN_ALIAS_C(sendmsg); +ssize_t sendto(int, const void *, size_t, + int, const struct sockaddr *, socklen_t) __DARWIN_ALIAS_C(sendto); +int setsockopt(int, int, int, const void *, socklen_t); +int shutdown(int, int); +int sockatmark(int); +int socket(int, int, int); +int socketpair(int, int, int, int *) __DARWIN_ALIAS(socketpair); + +#if !defined(_POSIX_C_SOURCE) +int sendfile(int, int, off_t, off_t *, struct sf_hdtr *, int); +#endif /* !_POSIX_C_SOURCE */ + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +void pfctlinput(int, struct sockaddr *); +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ +__END_DECLS + + + +#endif /* !_SYS_SOCKET_H_ */ Index: branches/azimutz/Cleancut/i386/boot1/boot1.s =================================================================== --- branches/azimutz/Cleancut/i386/boot1/boot1.s (revision 884) +++ branches/azimutz/Cleancut/i386/boot1/boot1.s (revision 885) @@ -1,1477 +0,0 @@ -; Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved. -; -; @APPLE_LICENSE_HEADER_START@ -; -; Portions 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.apple.com/publicsource 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 OR NON- INFRINGEMENT. Please see the -; License for the specific language governing rights and limitations -; under the License. -; -; @APPLE_LICENSE_HEADER_END@ -; -; Partition Boot Loader: boot1h -; -; This program is designed to reside in sector 0+1 of an HFS+ partition. -; It expects that the MBR has left the drive number in DL -; and a pointer to the partition entry in SI. -; -; This version requires a BIOS with EBIOS (LBA) support. -; -; This code is written for the NASM assembler. -; nasm boot1.s -o boot1h - -; -; This version of boot1h tries to find a stage2 boot file in the root folder. -; -; NOTE: this is an experimental version with multiple extent support. -; -; Written by Tamás Kosárszky on 2008-04-14 -; - -; -; Set to 1 to enable obscure debug messages. -; -DEBUG EQU 0 - -; -; Set to 1 to enable unused code. -; -UNUSED EQU 0 - -; -; Set to 1 to enable verbose mode. -; -VERBOSE EQU 1 - -; -; Various constants. -; -NULL EQU 0 -CR EQU 0x0D -LF EQU 0x0A - -mallocStart EQU 0x1000 ; start address of local workspace area -maxSectorCount EQU 64 ; maximum sector count for readSectors -maxNodeSize EQU 16384 - -kSectorBytes EQU 512 ; sector size in bytes -kBootSignature EQU 0xAA55 ; boot sector signature - -kBoot1StackAddress EQU 0xFFF0 ; boot1 stack pointer -kBoot1LoadAddr EQU 0x7C00 ; boot1 load address -kBoot1RelocAddr EQU 0xE000 ; boot1 relocated address -kBoot1Sector1Addr EQU kBoot1RelocAddr + kSectorBytes ; boot1 load address for sector 1 -kHFSPlusBuffer EQU kBoot1Sector1Addr + kSectorBytes ; HFS+ Volume Header address - -kBoot2Sectors EQU (448 * 1024 - 512) / kSectorBytes ; max size of 'boot' file in sectors -kBoot2Segment EQU 0x2000 ; boot2 load segment -kBoot2Address EQU kSectorBytes ; boot2 load address - -; -; Format of fdisk partition entry. -; -; The symbol 'part_size' is automatically defined as an `EQU' -; giving the size of the structure. -; - struc part -.bootid resb 1 ; bootable or not -.head resb 1 ; starting head, sector, cylinder -.sect resb 1 ; -.cyl resb 1 ; -.type resb 1 ; partition type -.endhead resb 1 ; ending head, sector, cylinder -.endsect resb 1 ; -.endcyl resb 1 ; -.lba resd 1 ; starting lba -.sectors resd 1 ; size in sectors - endstruc - -;------------------------------------------------------------------------- -; HFS+ related structures and constants -; -kHFSPlusSignature EQU 'H+' ; HFS+ volume signature -kHFSPlusCaseSignature EQU 'HX' ; HFS+ volume case-sensitive signature -kHFSPlusCaseSigX EQU 'X' ; upper byte of HFS+ volume case-sensitive signature -kHFSPlusExtentDensity EQU 8 ; 8 extent descriptors / extent record - -; -; HFSUniStr255 -; - struc HFSUniStr255 -.length resw 1 -.unicode resw 255 - endstruc - -; -; HFSPlusExtentDescriptor -; - struc HFSPlusExtentDescriptor -.startBlock resd 1 -.blockCount resd 1 - endstruc - -; -; HFSPlusForkData -; - struc HFSPlusForkData -.logicalSize resq 1 -.clumpSize resd 1 -.totalBlocks resd 1 -.extents resb kHFSPlusExtentDensity * HFSPlusExtentDescriptor_size - endstruc - -; -; HFSPlusVolumeHeader -; - struc HFSPlusVolumeHeader -.signature resw 1 -.version resw 1 -.attributes resd 1 -.lastMountedVersion resd 1 -.journalInfoBlock resd 1 -.createDate resd 1 -.modifyDate resd 1 -.backupDate resd 1 -.checkedDate resd 1 -.fileCount resd 1 -.folderCount resd 1 -.blockSize resd 1 -.totalBlocks resd 1 -.freeBlocks resd 1 -.nextAllocation resd 1 -.rsrcClumpSize resd 1 -.dataClumpSize resd 1 -.nextCatalogID resd 1 -.writeCount resd 1 -.encodingsBitmap resq 1 -.finderInfo resd 8 -.allocationFile resb HFSPlusForkData_size -.extentsFile resb HFSPlusForkData_size -.catalogFile resb HFSPlusForkData_size -.attributesFile resb HFSPlusForkData_size -.startupFile resb HFSPlusForkData_size - endstruc - -; -; B-tree related structures and constants -; - -kBTIndexNode EQU 0 -kBTMaxRecordLength EQU 264 ; sizeof(kHFSPlusFileThreadRecord) -kHFSRootParentID EQU 1 ; Parent ID of the root folder -kHFSRootFolderID EQU 2 ; Folder ID of the root folder -kHFSExtentsFileID EQU 3 ; File ID of the extents overflow file -kHFSCatalogFileID EQU 4 ; File ID of the catalog file -kHFSPlusFileRecord EQU 0x200 -kForkTypeData EQU 0 -kForkTypeResource EQU 0xFF - -; -; BTNodeDescriptor -; - struc BTNodeDescriptor -.fLink resd 1 -.bLink resd 1 -.kind resb 1 -.height resb 1 -.numRecords resw 1 -.reserved resw 1 - endstruc - -; -; BTHeaderRec -; - struc BTHeaderRec -.treeDepth resw 1 -.rootNode resd 1 -.leafRecords resd 1 -.firstLeafNode resd 1 -.lastLeafNode resd 1 -.nodeSize resw 1 -.maxKeyLength resw 1 -.totalNodes resd 1 -.freeNodes resd 1 -.reserved1 resw 1 -.clumpSize resd 1 -.btreeType resb 1 -.keyCompareType resb 1 -.attributes resd 1 -.reserved3 resd 16 - endstruc - -; -; BTIndexRec -; - struc BTIndexRec -.childID resd 1 - endstruc - -; -; HFSPlusCatalogKey -; - struc HFSPlusCatalogKey -; -; won't use the keyLength field for easier addressing data inside this structure -; -;.keyLength resw 1 - -.parentID resd 1 -.nodeName resb HFSUniStr255_size - endstruc - -; -; HFSPlusExtentKey -; - struc HFSPlusExtentKey -; -; won't use the keyLength field for easier addressing data inside this structure -; -;.keyLength resw 1 - -.forkType resb 1 -.pad resb 1 -.fileID resd 1 -.startBlock resd 1 - endstruc - -; -; HFSPlusBSDInfo -; - struc HFSPlusBSDInfo -.ownerID resd 1 -.groupID resd 1 -.adminFlags resb 1 -.ownerFlags resb 1 -.fileMode resw 1 -.special resd 1 - endstruc - -; -; FileInfo -; - struc FileInfo -.fileType resd 1 -.fileCreator resd 1 -.finderFlags resw 1 -.location resw 2 -.reservedField resw 1 - endstruc - -; -; ExtendedFileInfo -; - struc ExtendedFileInfo -.reserved1 resw 4 -.extFinderFlags resw 1 -.reserved2 resw 1 -.putAwayFolderID resd 1 - endstruc - -; -; HFSPlusCatalogFile -; - struc HFSPlusCatalogFile -.recordType resw 1 -.flags resw 1 -.reserved1 resd 1 -.fileID resd 1 -.createDate resd 1 -.contentModDate resd 1 -.attributeModDate resd 1 -.accessDate resd 1 -.backupDate resd 1 -.permissions resb HFSPlusBSDInfo_size -.userInfo resb FileInfo_size -.finderInfo resb ExtendedFileInfo_size -.textEncoding resd 1 -.reserved2 resd 1 -.dataFork resb HFSPlusForkData_size -.resourceFork resb HFSPlusForkData_size - endstruc - -; -; Macros. -; -%macro jmpabs 1 - push WORD %1 - ret -%endmacro - -%macro DebugCharMacro 1 - pushad - mov al, %1 - call print_char - call getc - popad -%endmacro - -%macro PrintCharMacro 1 - pushad - mov al, %1 - call print_char - popad -%endmacro - -%macro PutCharMacro 1 - call print_char -%endmacro - -%macro PrintHexMacro 1 - call print_hex -%endmacro - -%macro PrintString 1 - mov si, %1 - call print_string -%endmacro - -%macro LogString 1 - mov di, %1 - call log_string -%endmacro - -%if DEBUG - %define DebugChar(x) DebugCharMacro x - %define PrintChar(x) PrintCharMacro x - %define PutChar(x) PutCharMacro - %define PrintHex(x) PrintHexMacro x -%else - %define DebugChar(x) - %define PrintChar(x) - %define PutChar(x) - %define PrintHex(x) -%endif - -;-------------------------------------------------------------------------- -; Start of text segment. - - SEGMENT .text - - ORG kBoot1RelocAddr - -;-------------------------------------------------------------------------- -; Boot code is loaded at 0:7C00h. -; -start: - ; - ; Set up the stack to grow down from kBoot1StackSegment:kBoot1StackAddress. - ; Interrupts should be off while the stack is being manipulated. - ; - cli ; interrupts off - xor ax, ax ; zero ax - mov ss, ax ; ss <- 0 - mov sp, kBoot1StackAddress ; sp <- top of stack - sti ; reenable interrupts - - mov ds, ax ; ds <- 0 - mov es, ax ; es <- 0 - - ; - ; Relocate boot1 code. - ; - push si - mov si, kBoot1LoadAddr ; si <- source - mov di, kBoot1RelocAddr ; di <- destination - cld ; auto-increment SI and/or DI registers - mov cx, kSectorBytes ; copy 256 words - rep movsb ; repeat string move (word) operation - pop si - - ; - ; Code relocated, jump to startReloc in relocated location. - ; - ; FIXME: Is there any way to instruct NASM to compile a near jump - ; using absolute address instead of relative displacement? - ; - jmpabs startReloc - -;-------------------------------------------------------------------------- -; Start execution from the relocated location. -; -startReloc: - - ; - ; Initializing global variables. - ; - mov eax, [si + part.lba] - mov [gPartLBA], eax ; save the current partition LBA offset - mov [gBIOSDriveNumber], dl ; save BIOS drive number - mov WORD [gMallocPtr], mallocStart ; set free space pointer - - ; - ; Loading upper 512 bytes of boot1h and HFS+ Volume Header. - ; - xor ecx, ecx ; sector 1 of current partition - inc ecx - mov al, 2 ; read 2 sectors: sector 1 of boot1h + HFS+ Volume Header - mov edx, kBoot1Sector1Addr - call readLBA - - ; - ; Initializing more global variables. - ; - mov eax, [kHFSPlusBuffer + HFSPlusVolumeHeader.blockSize] - bswap eax ; convert to little-endian - shr eax, 9 ; convert to sector unit - mov [gBlockSize], eax ; save blockSize as little-endian sector unit! - - ; - ; Looking for HFSPlus ('H+') or HFSPlus case-sensitive ('HX') signature. - ; - mov ax, [kHFSPlusBuffer + HFSPlusVolumeHeader.signature] - cmp ax, kHFSPlusCaseSignature - je findRootBoot - cmp ax, kHFSPlusSignature - jne error - -;-------------------------------------------------------------------------- -; Find stage2 boot file in a HFS+ Volume's root folder. -; -findRootBoot: - mov al, kHFSCatalogFileID - lea si, [searchCatalogKey] - lea di, [kHFSPlusBuffer + HFSPlusVolumeHeader.catalogFile + HFSPlusForkData.extents] - call lookUpBTree - jne error - - lea si, [bp + BTree.recordDataPtr] - mov si, [si] - cmp WORD [si], kHFSPlusFileRecord - jne error - -; EAX = Catalog File ID -; BX = read size in sectors -; ECX = file offset in sectors -; EDX = address of read buffer -; DI = address of HFSPlusForkData - - ; - ; Use the second big-endian double-word as the file length in HFSPlusForkData.logicalSize - ; - mov ebx, [si + HFSPlusCatalogFile.dataFork + HFSPlusForkData.logicalSize + 4] - bswap ebx ; convert file size to little-endian - add ebx, kSectorBytes - 1 ; adjust size before unit conversion - shr ebx, 9 ; convert file size to sector unit - cmp bx, kBoot2Sectors ; check if bigger than max stage2 size - ja error - mov eax, [si + HFSPlusCatalogFile.fileID] - bswap eax ; convert fileID to little-endian - xor ecx, ecx - mov edx, (kBoot2Segment << 4) + kBoot2Address - lea di, [si + HFSPlusCatalogFile.dataFork + HFSPlusForkData.extents] - call readExtent - -%if VERBOSE - LogString(root_str) -%endif - -boot2: - -%if DEBUG - DebugChar ('!') -%endif - -%if UNUSED - ; - ; Waiting for a key press. - ; - - mov ah, 0 - int 0x16 -%endif - - mov dl, [gBIOSDriveNumber] ; load BIOS drive number - jmp kBoot2Segment:kBoot2Address - -error: - -%if VERBOSE - LogString(error_str) -%endif - -hang: - hlt - jmp hang - -;-------------------------------------------------------------------------- -; readSectors - Reads more than 127 sectors using LBA addressing. -; -; Arguments: -; AX = number of 512-byte sectors to read (valid from 1-1280). -; EDX = pointer to where the sectors should be stored. -; ECX = sector offset in partition -; -; Returns: -; CF = 0 success -; 1 error -; -readSectors: - pushad - mov bx, ax - -.loop: - xor eax, eax ; EAX = 0 - mov al, bl ; assume we reached the last block. - cmp bx, maxSectorCount ; check if we really reached the last block - jb .readBlock ; yes, BX < MaxSectorCount - mov al, maxSectorCount ; no, read MaxSectorCount - -.readBlock: - call readLBA - sub bx, ax ; decrease remaning sectors with the read amount - jz .exit ; exit if no more sectors left to be loaded - add ecx, eax ; adjust LBA sector offset - shl ax, 9 ; convert sectors to bytes - add edx, eax ; adjust target memory location - jmp .loop ; read remaining sectors - -.exit: - popad - ret - -;-------------------------------------------------------------------------- -; readLBA - Read sectors from a partition using LBA addressing. -; -; Arguments: -; AL = number of 512-byte sectors to read (valid from 1-127). -; EDX = pointer to where the sectors should be stored. -; ECX = sector offset in partition -; [bios_drive_number] = drive number (0x80 + unit number) -; -; Returns: -; CF = 0 success -; 1 error -; -readLBA: - pushad ; save all registers - push es ; save ES - mov bp, sp ; save current SP - - ; - ; Convert EDX to segment:offset model and set ES:BX - ; - ; Some BIOSes do not like offset to be negative while reading - ; from hard drives. This usually leads to "boot1: error" when trying - ; to boot from hard drive, while booting normally from USB flash. - ; The routines, responsible for this are apparently different. - ; Thus we split linear address slightly differently for these - ; capricious BIOSes to make sure offset is always positive. - ; - - mov bx, dx ; save offset to BX - and bh, 0x0f ; keep low 12 bits - shr edx, 4 ; adjust linear address to segment base - xor dl, dl ; mask low 8 bits - mov es, dx ; save segment to ES - - ; - ; Create the Disk Address Packet structure for the - ; INT13/F42 (Extended Read Sectors) on the stack. - ; - - ; push DWORD 0 ; offset 12, upper 32-bit LBA - push ds ; For sake of saving memory, - push ds ; push DS register, which is 0. - - add ecx, [gPartLBA] ; offset 8, lower 32-bit LBA - push ecx - - push es ; offset 6, memory segment - - push bx ; offset 4, memory offset - - xor ah, ah ; offset 3, must be 0 - push ax ; offset 2, number of sectors - - push WORD 16 ; offset 0-1, packet size - - ; - ; INT13 Func 42 - Extended Read Sectors - ; - ; Arguments: - ; AH = 0x42 - ; [bios_drive_number] = drive number (0x80 + unit number) - ; DS:SI = pointer to Disk Address Packet - ; - ; Returns: - ; AH = return status (sucess is 0) - ; carry = 0 success - ; 1 error - ; - ; Packet offset 2 indicates the number of sectors read - ; successfully. - ; - mov dl, [gBIOSDriveNumber] ; load BIOS drive number - mov si, sp - mov ah, 0x42 - int 0x13 - - jc error - - ; - ; Issue a disk reset on error. - ; Should this be changed to Func 0xD to skip the diskette controller - ; reset? - ; -; xor ax, ax ; Func 0 -; int 0x13 ; INT 13 -; stc ; set carry to indicate error - -.exit: - mov sp, bp ; restore SP - pop es ; restore ES - popad - ret - -%if VERBOSE - -;-------------------------------------------------------------------------- -; Write a string with 'boot1: ' prefix to the console. -; -; Arguments: -; ES:DI pointer to a NULL terminated string. -; -; Clobber list: -; DI -; -log_string: - pushad - - push di - mov si, log_title_str - call print_string - - pop si - call print_string - - popad - - ret - -;------------------------------------------------------------------------- -; Write a string to the console. -; -; Arguments: -; DS:SI pointer to a NULL terminated string. -; -; Clobber list: -; AX, BX, SI -; -print_string: - mov bx, 1 ; BH=0, BL=1 (blue) - -.loop: - lodsb ; load a byte from DS:SI into AL - cmp al, 0 ; Is it a NULL? - je .exit ; yes, all done - mov ah, 0xE ; INT10 Func 0xE - int 0x10 ; display byte in tty mode - jmp .loop - -.exit: - ret - -%endif ; VERBOSE - -%if DEBUG - -;-------------------------------------------------------------------------- -; Write the 4-byte value to the console in hex. -; -; Arguments: -; EAX = Value to be displayed in hex. -; -print_hex: - pushad - mov cx, WORD 4 - bswap eax -.loop: - push ax - ror al, 4 - call print_nibble ; display upper nibble - pop ax - call print_nibble ; display lower nibble - ror eax, 8 - loop .loop - -%if UNUSED - mov al, 10 ; carriage return - call print_char - mov al, 13 - call print_char -%endif ; UNUSED - - popad - ret - -print_nibble: - and al, 0x0f - add al, '0' - cmp al, '9' - jna .print_ascii - add al, 'A' - '9' - 1 -.print_ascii: - call print_char - ret - -;-------------------------------------------------------------------------- -; getc - wait for a key press -; -getc: - pushad - mov ah, 0 - int 0x16 - popad - ret - -;-------------------------------------------------------------------------- -; Write a ASCII character to the console. -; -; Arguments: -; AL = ASCII character. -; -print_char: - pushad - mov bx, 1 ; BH=0, BL=1 (blue) - mov ah, 0x0e ; bios INT 10, Function 0xE - int 0x10 ; display byte in tty mode - popad - ret - -%endif ; DEBUG - -%if UNUSED - -;-------------------------------------------------------------------------- -; Convert null terminated string to HFSUniStr255 -; -; Arguments: -; DS:DX pointer to a NULL terminated string. -; ES:DI pointer to result. -; -ConvertStrToUni: - pushad ; save registers - push di ; save DI for unicode string length pointer - mov si, dx ; use SI as source string pointer - xor ax, ax ; AX = unicode character - mov cl, al ; CL = string length - -.loop: - stosw ; store unicode character (length 0 at first run) - lodsb ; load next character to AL - inc cl ; increment string length count - cmp al, NULL ; check for string terminator - jne .loop - - pop di ; restore unicode string length pointer - dec cl ; ignoring terminator from length count - mov [di], cl ; save string length - popad ; restore registers - ret - -%endif ; UNUSED - -;-------------------------------------------------------------------------- -; Convert big-endian HFSUniStr255 to little-endian -; -; Arguments: -; DS:SI = pointer to big-endian HFSUniStr255 -; ES:DI = pointer to result buffer -; -ConvertHFSUniStr255ToLE: - pushad - lodsw - xchg ah, al - stosw - cmp al, 0 - je .exit - mov cx, ax - -.loop: - lodsw - xchg ah, al ; convert AX to little-endian - - ; - ; When working with a case-sensitive HFS+ (HX) filesystem, we shouldn't change the case. - ; - cmp BYTE [kHFSPlusBuffer + HFSPlusVolumeHeader.signature + 1], kHFSPlusCaseSigX - je .keepcase - - or ax, ax - jne .convertToLE - dec ax ; NULL must be the strongest char - -.convertToLE: - cmp ah, 0 - ja .keepcase - cmp al, 'A' - jb .keepcase - cmp al, 'Z' - ja .keepcase - add al, 32 ; convert to lower-case - -.keepcase: - stosw - loop .loop - -.exit: - popad - ret - -;-------------------------------------------------------------------------- -; compare HFSPlusExtentKey structures -; -; Arguments: -; DS:SI = search key -; ES:DI = trial key -; -; Returns: -; [BTree.searchResult] = result -; FLAGS = relation between search and trial keys -; -compareHFSPlusExtentKeys: - pushad - - mov dl, 0 ; DL = result of comparison, DH = bestGuess - mov eax, [si + HFSPlusExtentKey.fileID] - cmp eax, [di + HFSPlusExtentKey.fileID] - jne .checkFlags - - cmp BYTE [si + HFSPlusExtentKey.forkType], kForkTypeData - jne .checkFlags - - mov eax, [si + HFSPlusExtentKey.startBlock] - cmp eax, [di + HFSPlusExtentKey.startBlock] - je compareHFSPlusCatalogKeys.exit - -.checkFlags: - ja compareHFSPlusCatalogKeys.searchKeyGreater ; search key > trial key - jb compareHFSPlusCatalogKeys.trialKeyGreater ; search key < trial key - -;-------------------------------------------------------------------------- -; Compare HFSPlusCatalogKey structures -; -; Arguments: -; DS:SI = search key -; ES:DI = trial key -; -; Returns: -; [BTree.searchResult] = result -; FLAGS = relation between search and trial keys -; -compareHFSPlusCatalogKeys: - pushad - xor dx, dx ; DL = result of comparison, DH = bestGuess - xchg si, di - lodsd - mov ecx, eax ; ECX = trial parentID - xchg si, di - lodsd ; EAX = search parentID - cmp eax, ecx - ja .searchKeyGreater ; search parentID > trial parentID - jb .trialKeyGreater ; search parentID < trial parentID - -.compareNodeName: ; search parentID = trial parentID - xchg si, di - lodsw - mov cx, ax ; CX = trial nodeName.length - xchg si, di - lodsw ; AX = search nodeName.length - cmp cl, 0 ; trial nodeName.length = 0? - je .searchKeyGreater - - cmp ax, cx - je .strCompare - ja .searchStrLonger - -.trialStrLonger: - dec dh - mov cx, ax - jmp .strCompare - -.searchStrLonger: - inc dh - -.strCompare: - repe cmpsw - ja .searchKeyGreater - jb .trialKeyGreater - mov dl, dh - jmp .exit - -.trialKeyGreater: - dec dl - jmp .exit - -.searchKeyGreater: - inc dl - -.exit: - mov [bp + BTree.searchResult], dl - cmp dl, 0 ; set flags to check relation between keys - - popad - ret - -;-------------------------------------------------------------------------- -; Allocate memory -; -; Arguments: -; CX = size of requested memory -; -; Returns: -; BP = start address of allocated memory -; -; Clobber list: -; CX -; -malloc: - push ax ; save AX - push di ; save DI - mov di, [gMallocPtr] ; start address of free space - push di ; save free space start address - inc di ; - inc di ; keep the first word untouched - dec cx ; for the last memory block pointer. - dec cx ; - mov al, NULL ; fill with zero - rep stosb ; repeat fill - mov [gMallocPtr], di ; adjust free space pointer - pop bp ; BP = start address of allocated memory - mov [di], bp ; set start address of allocated memory at next - ; allocation block's free space address. - pop di ; restore DI - pop ax ; restore AX - ret - -%if UNUSED - -;-------------------------------------------------------------------------- -; Free allocated memory -; -; Returns: -; BP = start address of previously allocated memory -; -free: - lea bp, [gMallocPtr] - mov bp, [bp] - mov [gMallocPtr], bp - ret - -%endif ; UNUSED - -;-------------------------------------------------------------------------- -; Static data. -; - -%if VERBOSE -root_str db '/boot', NULL -%endif - -;-------------------------------------------------------------------------- -; Pad the rest of the 512 byte sized sector with zeroes. The last -; two bytes is the mandatory boot sector signature. -; -; If the booter code becomes too large, then nasm will complain -; that the 'times' argument is negative. - -pad_table_and_sig: - times 510-($-$$) db 0 - dw kBootSignature - -; -; Sector 1 code area -; - -;-------------------------------------------------------------------------- -; lookUpBTree - initializes a new BTree instance and -; look up for HFSPlus Catalog File or Extent Overflow keys -; -; Arguments: -; AL = kHFSPlusFileID (Catalog or Extents Overflow) -; SI = address of searchKey -; DI = address of HFSPlusForkData.extents -; -; Returns: -; BP = address of BTree instance -; ECX = rootNode's logical offset in sectors -; -lookUpBTree: - mov cx, BTree_size ; allocate memory with BTree_size - call malloc ; BP = start address of allocated memory. - mov [bp + BTree.fileID], al ; save fileFileID - mov edx, [di] ; first extent of current file - call blockToSector ; ECX = converted to sector unit - mov al, 1 ; 1 sector is enough for - xor edx, edx ; reading current file's header. - lea dx, [bp + BTree.BTHeaderBuffer] ; load into BTreeHeaderBuffer - call readLBA ; read - mov ax, [bp + BTree.BTHeaderBuffer + BTNodeDescriptor_size + BTHeaderRec.nodeSize] - xchg ah, al ; convert to little-endian - mov [bp + BTree.nodeSize], ax ; save nodeSize - - ; - ; Always start the lookup process with the root node. - ; - mov edx, [bp + BTree.BTHeaderBuffer + BTNodeDescriptor_size + BTHeaderRec.rootNode] - -.readNode: - ; - ; Converting nodeID to sector unit - ; - mov ax, [bp + BTree.nodeSize] - shr ax, 9 ; convert nodeSize to sectors - mov bx, ax ; BX = read sector count - cwde - bswap edx ; convert node ID to little-endian - mul edx ; multiply with nodeSize converted to sector unit - mov ecx, eax ; ECX = file offset in BTree - - mov eax, [bp + BTree.fileID] - lea edx, [bp + BTree.nodeBuffer] - call readExtent - - ; - ; AX = lowerBound = 0 - ; - xor ax, ax - - ; - ; BX = upperBound = numRecords - 1 - ; - mov bx, [bp + BTree.nodeBuffer + BTNodeDescriptor.numRecords] - xchg bh, bl - dec bx - -.bsearch: - cmp ax, bx - ja .checkResult ; jump if lowerBound > upperBound - - mov cx, ax - add cx, bx - shr cx, 1 ; test index = (lowerBound + upperBound / 2) - - call getBTreeRecord - -%if UNUSED - pushad - jl .csearchLessThanTrial - jg .csearchGreaterThanTrial - PrintChar('=') - jmp .csearchCont -.csearchGreaterThanTrial: - PrintChar('>') - jmp .csearchCont -.csearchLessThanTrial: - PrintChar('<') -.csearchCont: - popad -%endif ; UNUSED - -.adjustBounds: - je .checkResult - jl .searchLessThanTrial - jg .searchGreaterThanTrial - jmp .bsearch - -.searchLessThanTrial: - mov bx, cx - dec bx ; upperBound = index - 1 - jmp .bsearch - -.searchGreaterThanTrial: - mov ax, cx - inc ax ; lowerBound = index + 1 - jmp .bsearch - -.checkResult: - cmp BYTE [bp + BTree.searchResult], 0 - jge .foundKey - - mov cx, bx - call getBTreeRecord - -.foundKey: - cmp BYTE [bp + BTree.nodeBuffer + BTNodeDescriptor.kind], kBTIndexNode - jne .exit - - lea bx, [bp + BTree.recordDataPtr] - mov bx, [bx] - mov edx, [bx] - jmp .readNode - -.exit: - cmp BYTE [bp + BTree.searchResult], 0 - ret - -;-------------------------------------------------------------------------- -; getBTreeRecord - read and compare BTree record -; -; Arguments: -; CX = record index -; SI = address of search key -; -; Returns: -; [BTree.searchResult] = result of key compare -; [BTree.recordDataPtr] = address of record data -; -getBTreeRecord: - pushad - push si ; save SI - lea di, [bp + BTree.nodeBuffer] ; DI = start of nodeBuffer - push di ; use later - mov ax, [bp + BTree.nodeSize] ; get nodeSize - add di, ax ; DI = beyond nodeBuffer - inc cx ; increment index - shl cx, 1 ; * 2 - sub di, cx ; DI = pointer to record - mov ax, [di] ; offset to record - xchg ah, al ; convert to little-endian - pop di ; start of nodeBuffer - add di, ax ; DI = address of record key - mov si, di ; save to SI - mov ax, [di] ; keyLength - xchg ah, al ; convert to little-endian - inc ax ; suppress keySize (2 bytes) - inc ax ; - add di, ax ; DI = address of record data - mov [bp + BTree.recordDataPtr], di ; save address of record data - lea di, [bp + BTree.trialKey] - push di ; save address of trialKey - lodsw ; suppress keySize (2 bytes) - ; - ; Don't need to compare as DWORD since all reserved CNIDs fits to a single byte - ; - cmp BYTE [bp + BTree.fileID], kHFSCatalogFileID - je .prepareTrialCatalogKey - -.prepareTrialExtentKey: - mov bx, compareHFSPlusExtentKeys - movsw ; copy forkType + pad - mov cx, 2 ; copy fileID + startBlock - -.extentLoop: - lodsd - bswap eax ; convert to little-endian - stosd - loop .extentLoop - jmp .exit - -.prepareTrialCatalogKey: - mov bx, compareHFSPlusCatalogKeys - lodsd - bswap eax ; convert ParentID to little-endian - stosd - call ConvertHFSUniStr255ToLE ; convert nodeName to little-endian - -.exit: - pop di ; restore address of trialKey - -%if UNUSED -; -; Print catalog trial key -; - pushad - mov si, di - lodsd - PrintChar('k') - PrintHex() - lodsw - cmp ax, 0 - je .printExit - mov cx, ax -.printLoop: - lodsw - call print_char - loop .printLoop -.printExit: - popad -; -; -; -%endif ; UNUSED - -%if UNUSED -; -; Print extent trial key -; - pushad - PrintChar('k') - mov si, di - xor eax, eax - lodsw - PrintHex() - lodsd - PrintHex() - lodsd - PrintHex() - popad -; -; -; -%endif ; UNUSED - - pop si ; restore SI - call bx ; call key compare proc - popad - ret - -;-------------------------------------------------------------------------- -; readExtent - read extents from a HFS+ file (multiple extent support) -; -; Arguments: -; EAX = Catalog File ID -; BX = read size in sectors -; ECX = file offset in sectors -; EDX = address of read buffer -; DI = address of HFSPlusForkData.extents -; -readExtent: - pushad - ; - ; Save Catalog File ID as part of a search HFSPlusExtentKey - ; for a possible Extents Overflow lookup. - ; - mov [bp + BTree.searchExtentKey + HFSPlusExtentKey.fileID], eax - mov [bp + BTree.readBufferPtr], edx - mov ax, bx - cwde - mov [bp + BTree.readSize], eax - mov ebx, ecx ; EBX = file offset - xor eax, eax - mov [bp + BTree.currentExtentOffs], eax - -.beginExtentBlock: - mov BYTE [bp + BTree.extentCount], 0 - -.extentSearch: - cmp BYTE [bp + BTree.extentCount], kHFSPlusExtentDensity - jb .continue - -.getNextExtentBlock: - push ebx - mov eax, [bp + BTree.currentExtentOffs] - - ; - ; Converting sector unit to HFS+ allocation block unit. - ; - xor edx, edx - div DWORD [gBlockSize] ; divide with blockSize - - ; - ; Preparing searchExtentKey's startBlock field. - ; - mov [bp + BTree.searchExtentKey + HFSPlusExtentKey.startBlock], eax - - mov al, kHFSExtentsFileID - lea si, [bp + BTree.searchExtentKey] - lea di, [kHFSPlusBuffer + HFSPlusVolumeHeader.extentsFile + HFSPlusForkData.extents] - call lookUpBTree - jnz NEAR .exit - - ; - ; BP points to the new workspace allocated by lookUpBTree. - ; - lea di, [bp + BTree.recordDataPtr] - mov di, [di] - - ; - ; Switch back to the previous workspace. - ; - lea bp, [gMallocPtr] - mov bp, [bp] - mov [gMallocPtr], bp - - pop ebx - jmp .beginExtentBlock - -.continue: - mov edx, [di + HFSPlusExtentDescriptor.blockCount] - call blockToSector ; ECX = converted current extent's blockCount to sectors - mov eax, [bp + BTree.currentExtentOffs] ; EAX = current extent's start offset (sector) - mov edx, eax - add edx, ecx ; EDX = next extent's start offset (sector) - cmp ebx, edx - mov [bp + BTree.currentExtentOffs], edx ; set currentExtentOffs as the next extent's start offset - jae .nextExtent ; jump to next extent if file offset > next extent's start offset - -.foundExtent: - mov edx, ebx - sub edx, eax ; EDX = relative offset within current extent - mov eax, edx ; will be used below to determine read size - mov esi, [bp + BTree.readSize] ; ESI = remaining sectors to be read - add edx, esi - cmp edx, ecx ; test if relative offset + readSize fits to this extent - jbe .read ; read all remaining sectors from this extent - -.splitRead: - sub ecx, eax ; read amount of sectors beginning at relative offset - mov esi, ecx ; of current extent up to the end of current extent - -.read: - mov edx, [di + HFSPlusExtentDescriptor.startBlock] - call blockToSector ; ECX = converted to sectors - add ecx, eax ; file offset converted to sectors - - push si - mov ax, si - mov edx, [bp + BTree.readBufferPtr] - call readSectors - pop si - - add ebx, esi - mov ax, si - cwde - shl ax, 9 ; convert SI (read sector count) to byte unit - add [bp + BTree.readBufferPtr], eax - sub [bp + BTree.readSize], esi - - jz .exit - -.nextExtent: - add di, kHFSPlusExtentDensity - inc BYTE [bp + BTree.extentCount] - jmp .extentSearch - -.exit: - popad - ret - -;-------------------------------------------------------------------------- -; Convert big-endian HFSPlus allocation block to sector unit -; -; Arguments: -; EDX = allocation block -; -; Returns: -; ECX = allocation block converted to sector unit -; -; Clobber list: -; EDX -; -blockToSector: - push eax - mov eax, [gBlockSize] - bswap edx ; convert allocation block to little-endian - mul edx ; multiply with block number - mov ecx, eax ; result in EAX - pop eax - ret - -%if UNUSED - -;-------------------------------------------------------------------------- -; Convert sector unit to HFSPlus allocation block unit -; -; Arguments: -; EDX = sector -; -; Returns: -; ECX = converted to allocation block unit -; -; Clobber list: -; EDX -; -sectorToBlock: - push eax - mov eax, edx - xor edx, edx - div DWORD [gBlockSize] ; divide with blockSize - mov ecx, eax ; result in EAX - pop eax - ret - -%endif ; UNUSED - -%if UNUSED - -;-------------------------------------------------------------------------- -; Convert big-endian BTree node ID to sector unit -; -; Arguments: -; EDX = node ID -; -; Returns: -; ECX = node ID converted to sector unit -; -; Clobber list: -; EDX -; -nodeToSector: - push eax - mov ax, [bp + BTree.nodeSize] - shr ax, 9 ; convert nodeSize to sectors - cwde - bswap edx ; convert node ID to little-endian - mul edx ; multiply with node ID - mov ecx, eax ; result in EAX - pop eax - ret - -%endif ; UNUSED - -;-------------------------------------------------------------------------- -; Static data. -; - -%if VERBOSE -log_title_str db CR, LF, 'boot1: ', NULL -error_str db 'error', NULL -%endif - -searchCatalogKey dd kHFSRootFolderID - dw searchCatKeyNameLen -searchCatKeyName dw 'b', 'o', 'o', 't' ; must be lower case -searchCatKeyNameLen EQU ($ - searchCatKeyName) / 2 - -;-------------------------------------------------------------------------- -; Pad the rest of the 512 byte sized sector with zeroes. The last -; two bytes is the mandatory boot sector signature. -; -pad_sector_1: - times 1022-($-$$) db 0 - dw kBootSignature - -; -; Local BTree variables -; - struc BTree -.mallocLink resw 1 ; pointer to previously allocated memory block -.fileID resd 1 ; will use as BYTE -.nodeSize resd 1 ; will use as WORD -.searchExtentKey resb HFSPlusExtentKey_size -.searchResult resb 1 -.trialKey resb kBTMaxRecordLength -.recordDataPtr resw 1 -.readBufferPtr resd 1 -.currentExtentOffs resd 1 -.readSize resd 1 -.extentCount resb 1 - ALIGNB 2 -.BTHeaderBuffer resb kSectorBytes -.nodeBuffer resb maxNodeSize - endstruc - -; -; Global variables -; - - ABSOLUTE kHFSPlusBuffer + HFSPlusVolumeHeader_size - -gPartLBA resd 1 -gBIOSDriveNumber resw 1 -gBlockSize resd 1 -gMallocPtr resw 1 - -; END Index: branches/azimutz/Cleancut/i386/boot1/boot1he.s =================================================================== --- branches/azimutz/Cleancut/i386/boot1/boot1he.s (revision 884) +++ branches/azimutz/Cleancut/i386/boot1/boot1he.s (revision 885) @@ -45,7 +45,7 @@ ; ; Set to 1 to enable obscure debug messages. ; -DEBUG EQU 1 +DEBUG EQU CONFIG_BOOT1_HFS_ACTIVE_DEBUG ; ; Set to 1 to enable unused code. @@ -55,7 +55,7 @@ ; ; Set to 1 to enable verbose mode. ; -VERBOSE EQU 1 +VERBOSE EQU CONFIG_BOOT1_HFS_ACTIVE_VERBOSE ; ; Various constants. @@ -1280,7 +1280,7 @@ .exit: pop di ; restore address of trialKey -;%if UNUSED +%if DEBUG ; ; Print catalog trial key ; @@ -1302,7 +1302,7 @@ ; ; ; -;%endif ; UNUSED +%endif ; DEBUG %if UNUSED ; Index: branches/azimutz/Cleancut/i386/boot1/Cconfig =================================================================== --- branches/azimutz/Cleancut/i386/boot1/Cconfig (revision 0) +++ branches/azimutz/Cleancut/i386/boot1/Cconfig (revision 885) @@ -0,0 +1,47 @@ +# +# boot1 +# +config BOOT1_HFS + bool "boot1 second stage booter" + default y + help + Say Y here if you want to compile the default boot1 + bootloader stage. + +config BOOT1_HFS_DEBUG + bool "debug support" + default n + depends on BOOT1_HFS + help + Say Y here if you want to compile in debug support. + +config BOOT1_HFS_VERBOSE + bool "verbose support" + default y + depends on BOOT1_HFS + help + Say Y here if you want to compile in verbose support. + +# +# boot1h +# +config BOOT1_HFS_ACTIVE + bool "boot1h second stage boater" + default y + help + Say Y here if you want to compile the default boot1 + bootloader stage. + +config BOOT1_HFS_ACTIVE_DEBUG + bool "debug support" + default n + depends on BOOT1_HFS_ACTIVE + help + Say Y here if you want to compile in debug support. + +config BOOT1_HFS_ACTIVE_VERBOSE + bool "verbose support" + default y + depends on BOOT1_HFS_ACTIVE + help + Say Y here if you want to compile in debug support. Index: branches/azimutz/Cleancut/i386/boot1/Makefile =================================================================== --- branches/azimutz/Cleancut/i386/boot1/Makefile (revision 884) +++ branches/azimutz/Cleancut/i386/boot1/Makefile (revision 885) @@ -1,37 +1,43 @@ +SRCROOT = $(shell pwd)/../../ +OBJROOT = $(SRCROOT)/obj/i386/boot1 +SYMROOT = $(SRCROOT)/sym/i386 +DSTROOT = $(SRCROOT)/dst/i386 +DOCROOT = $(SRCROOT)/doc +IMGROOT = $(SRCROOT)/sym/cache +IMGSKELROOT = $(SRCROOT)/imgskel +CDBOOT = ${IMGROOT}/usr/standalone/i386/cdboot +include ${SRCROOT}/Make.rules + DIR = boot1 -include ../MakePaths.dir -INSTALLDIR = $(DSTROOT)/usr/standalone/i386 -DIRS_NEEDED = $(OBJROOT) $(SYMROOT) +DIRS_NEEDED = $(SYMROOT) -#NASM = /Developer/usr/bin/nasm -NASM = $(shell which nasm) +VERS = `vers_string -f 5.0 | tr - .` +NEW_VERS = Darwin boot1h v$(VERS) -VERSIONED_FILES = boot1h -VERS = `vers_string -f 5.0 | tr - .` -NEW_VERS = Darwin boot1h v$(VERS) -ifneq "" "$(wildcard /bin/mkdirs)" - MKDIRS = /bin/mkdirs -else - MKDIRS = /bin/mkdir -p + +PROGRAMS = boot1hp boot1f32 + +ifeq (${CONFIG_BOOT1_HFS}, y) +PROGRAMS += boot1h endif -all embedtheme: $(DIRS_NEEDED) $(VERSIONED_FILES) +ifeq (${CONFIG_BOOT1_HFS_ACTIVE}, y) +PROGRAMS += boot1he +endif -boot1h: boot1.s Makefile - @echo "\t[NASM] boot1.s" - @$(NASM) boot1.s -o $(SYMROOT)/boot1h - @echo "\t[NASM] boot1hp.s" - @$(NASM) boot1hp.s -o $(SYMROOT)/boot1hp - @echo "\t[NASM] boot1he.s" - @$(NASM) boot1he.s -o $(SYMROOT)/boot1he - @echo "\t[NASM] boot1f32.s" - @$(NASM) boot1f32.s -o $(SYMROOT)/boot1f32 +PROGRAMS := $(addprefix $(SYMROOT)/, $(PROGRAMS)) + +all: $(DIRS_NEEDED) $(PROGRAMS) + + +$(PROGRAMS): $(SRCROOT)/autoconf.inc + @echo "\t[NASM] $(@F)" + @$(NASM) $(@F).s -o $@ + install_i386:: all $(INSTALLDIR) cp $(SYMROOT)/boot1h $(INSTALLDIR)/ cd $(INSTALLDIR); chmod u+w $(VERSIONED_FILES) - -include ../MakeInc.dir Index: branches/azimutz/Cleancut/i386/boot1/boot1h.s =================================================================== --- branches/azimutz/Cleancut/i386/boot1/boot1h.s (revision 0) +++ branches/azimutz/Cleancut/i386/boot1/boot1h.s (revision 885) @@ -0,0 +1,1477 @@ +; Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved. +; +; @APPLE_LICENSE_HEADER_START@ +; +; Portions 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.apple.com/publicsource 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 OR NON- INFRINGEMENT. Please see the +; License for the specific language governing rights and limitations +; under the License. +; +; @APPLE_LICENSE_HEADER_END@ +; +; Partition Boot Loader: boot1h +; +; This program is designed to reside in sector 0+1 of an HFS+ partition. +; It expects that the MBR has left the drive number in DL +; and a pointer to the partition entry in SI. +; +; This version requires a BIOS with EBIOS (LBA) support. +; +; This code is written for the NASM assembler. +; nasm boot1.s -o boot1h + +; +; This version of boot1h tries to find a stage2 boot file in the root folder. +; +; NOTE: this is an experimental version with multiple extent support. +; +; Written by Tamás Kosárszky on 2008-04-14 +; + +; +; Set to 1 to enable obscure debug messages. +; +DEBUG EQU CONFIG_BOOT1_HFS_DEBUG + +; +; Set to 1 to enable unused code. +; +UNUSED EQU 0 + +; +; Set to 1 to enable verbose mode. +; +VERBOSE EQU CONFIG_BOOT1_HFS_VERBOSE + +; +; Various constants. +; +NULL EQU 0 +CR EQU 0x0D +LF EQU 0x0A + +mallocStart EQU 0x1000 ; start address of local workspace area +maxSectorCount EQU 64 ; maximum sector count for readSectors +maxNodeSize EQU 16384 + +kSectorBytes EQU 512 ; sector size in bytes +kBootSignature EQU 0xAA55 ; boot sector signature + +kBoot1StackAddress EQU 0xFFF0 ; boot1 stack pointer +kBoot1LoadAddr EQU 0x7C00 ; boot1 load address +kBoot1RelocAddr EQU 0xE000 ; boot1 relocated address +kBoot1Sector1Addr EQU kBoot1RelocAddr + kSectorBytes ; boot1 load address for sector 1 +kHFSPlusBuffer EQU kBoot1Sector1Addr + kSectorBytes ; HFS+ Volume Header address + +kBoot2Sectors EQU (448 * 1024 - 512) / kSectorBytes ; max size of 'boot' file in sectors +kBoot2Segment EQU 0x2000 ; boot2 load segment +kBoot2Address EQU kSectorBytes ; boot2 load address + +; +; Format of fdisk partition entry. +; +; The symbol 'part_size' is automatically defined as an `EQU' +; giving the size of the structure. +; + struc part +.bootid resb 1 ; bootable or not +.head resb 1 ; starting head, sector, cylinder +.sect resb 1 ; +.cyl resb 1 ; +.type resb 1 ; partition type +.endhead resb 1 ; ending head, sector, cylinder +.endsect resb 1 ; +.endcyl resb 1 ; +.lba resd 1 ; starting lba +.sectors resd 1 ; size in sectors + endstruc + +;------------------------------------------------------------------------- +; HFS+ related structures and constants +; +kHFSPlusSignature EQU 'H+' ; HFS+ volume signature +kHFSPlusCaseSignature EQU 'HX' ; HFS+ volume case-sensitive signature +kHFSPlusCaseSigX EQU 'X' ; upper byte of HFS+ volume case-sensitive signature +kHFSPlusExtentDensity EQU 8 ; 8 extent descriptors / extent record + +; +; HFSUniStr255 +; + struc HFSUniStr255 +.length resw 1 +.unicode resw 255 + endstruc + +; +; HFSPlusExtentDescriptor +; + struc HFSPlusExtentDescriptor +.startBlock resd 1 +.blockCount resd 1 + endstruc + +; +; HFSPlusForkData +; + struc HFSPlusForkData +.logicalSize resq 1 +.clumpSize resd 1 +.totalBlocks resd 1 +.extents resb kHFSPlusExtentDensity * HFSPlusExtentDescriptor_size + endstruc + +; +; HFSPlusVolumeHeader +; + struc HFSPlusVolumeHeader +.signature resw 1 +.version resw 1 +.attributes resd 1 +.lastMountedVersion resd 1 +.journalInfoBlock resd 1 +.createDate resd 1 +.modifyDate resd 1 +.backupDate resd 1 +.checkedDate resd 1 +.fileCount resd 1 +.folderCount resd 1 +.blockSize resd 1 +.totalBlocks resd 1 +.freeBlocks resd 1 +.nextAllocation resd 1 +.rsrcClumpSize resd 1 +.dataClumpSize resd 1 +.nextCatalogID resd 1 +.writeCount resd 1 +.encodingsBitmap resq 1 +.finderInfo resd 8 +.allocationFile resb HFSPlusForkData_size +.extentsFile resb HFSPlusForkData_size +.catalogFile resb HFSPlusForkData_size +.attributesFile resb HFSPlusForkData_size +.startupFile resb HFSPlusForkData_size + endstruc + +; +; B-tree related structures and constants +; + +kBTIndexNode EQU 0 +kBTMaxRecordLength EQU 264 ; sizeof(kHFSPlusFileThreadRecord) +kHFSRootParentID EQU 1 ; Parent ID of the root folder +kHFSRootFolderID EQU 2 ; Folder ID of the root folder +kHFSExtentsFileID EQU 3 ; File ID of the extents overflow file +kHFSCatalogFileID EQU 4 ; File ID of the catalog file +kHFSPlusFileRecord EQU 0x200 +kForkTypeData EQU 0 +kForkTypeResource EQU 0xFF + +; +; BTNodeDescriptor +; + struc BTNodeDescriptor +.fLink resd 1 +.bLink resd 1 +.kind resb 1 +.height resb 1 +.numRecords resw 1 +.reserved resw 1 + endstruc + +; +; BTHeaderRec +; + struc BTHeaderRec +.treeDepth resw 1 +.rootNode resd 1 +.leafRecords resd 1 +.firstLeafNode resd 1 +.lastLeafNode resd 1 +.nodeSize resw 1 +.maxKeyLength resw 1 +.totalNodes resd 1 +.freeNodes resd 1 +.reserved1 resw 1 +.clumpSize resd 1 +.btreeType resb 1 +.keyCompareType resb 1 +.attributes resd 1 +.reserved3 resd 16 + endstruc + +; +; BTIndexRec +; + struc BTIndexRec +.childID resd 1 + endstruc + +; +; HFSPlusCatalogKey +; + struc HFSPlusCatalogKey +; +; won't use the keyLength field for easier addressing data inside this structure +; +;.keyLength resw 1 + +.parentID resd 1 +.nodeName resb HFSUniStr255_size + endstruc + +; +; HFSPlusExtentKey +; + struc HFSPlusExtentKey +; +; won't use the keyLength field for easier addressing data inside this structure +; +;.keyLength resw 1 + +.forkType resb 1 +.pad resb 1 +.fileID resd 1 +.startBlock resd 1 + endstruc + +; +; HFSPlusBSDInfo +; + struc HFSPlusBSDInfo +.ownerID resd 1 +.groupID resd 1 +.adminFlags resb 1 +.ownerFlags resb 1 +.fileMode resw 1 +.special resd 1 + endstruc + +; +; FileInfo +; + struc FileInfo +.fileType resd 1 +.fileCreator resd 1 +.finderFlags resw 1 +.location resw 2 +.reservedField resw 1 + endstruc + +; +; ExtendedFileInfo +; + struc ExtendedFileInfo +.reserved1 resw 4 +.extFinderFlags resw 1 +.reserved2 resw 1 +.putAwayFolderID resd 1 + endstruc + +; +; HFSPlusCatalogFile +; + struc HFSPlusCatalogFile +.recordType resw 1 +.flags resw 1 +.reserved1 resd 1 +.fileID resd 1 +.createDate resd 1 +.contentModDate resd 1 +.attributeModDate resd 1 +.accessDate resd 1 +.backupDate resd 1 +.permissions resb HFSPlusBSDInfo_size +.userInfo resb FileInfo_size +.finderInfo resb ExtendedFileInfo_size +.textEncoding resd 1 +.reserved2 resd 1 +.dataFork resb HFSPlusForkData_size +.resourceFork resb HFSPlusForkData_size + endstruc + +; +; Macros. +; +%macro jmpabs 1 + push WORD %1 + ret +%endmacro + +%macro DebugCharMacro 1 + pushad + mov al, %1 + call print_char + call getc + popad +%endmacro + +%macro PrintCharMacro 1 + pushad + mov al, %1 + call print_char + popad +%endmacro + +%macro PutCharMacro 1 + call print_char +%endmacro + +%macro PrintHexMacro 1 + call print_hex +%endmacro + +%macro PrintString 1 + mov si, %1 + call print_string +%endmacro + +%macro LogString 1 + mov di, %1 + call log_string +%endmacro + +%if DEBUG + %define DebugChar(x) DebugCharMacro x + %define PrintChar(x) PrintCharMacro x + %define PutChar(x) PutCharMacro + %define PrintHex(x) PrintHexMacro x +%else + %define DebugChar(x) + %define PrintChar(x) + %define PutChar(x) + %define PrintHex(x) +%endif + +;-------------------------------------------------------------------------- +; Start of text segment. + + SEGMENT .text + + ORG kBoot1RelocAddr + +;-------------------------------------------------------------------------- +; Boot code is loaded at 0:7C00h. +; +start: + ; + ; Set up the stack to grow down from kBoot1StackSegment:kBoot1StackAddress. + ; Interrupts should be off while the stack is being manipulated. + ; + cli ; interrupts off + xor ax, ax ; zero ax + mov ss, ax ; ss <- 0 + mov sp, kBoot1StackAddress ; sp <- top of stack + sti ; reenable interrupts + + mov ds, ax ; ds <- 0 + mov es, ax ; es <- 0 + + ; + ; Relocate boot1 code. + ; + push si + mov si, kBoot1LoadAddr ; si <- source + mov di, kBoot1RelocAddr ; di <- destination + cld ; auto-increment SI and/or DI registers + mov cx, kSectorBytes ; copy 256 words + rep movsb ; repeat string move (word) operation + pop si + + ; + ; Code relocated, jump to startReloc in relocated location. + ; + ; FIXME: Is there any way to instruct NASM to compile a near jump + ; using absolute address instead of relative displacement? + ; + jmpabs startReloc + +;-------------------------------------------------------------------------- +; Start execution from the relocated location. +; +startReloc: + + ; + ; Initializing global variables. + ; + mov eax, [si + part.lba] + mov [gPartLBA], eax ; save the current partition LBA offset + mov [gBIOSDriveNumber], dl ; save BIOS drive number + mov WORD [gMallocPtr], mallocStart ; set free space pointer + + ; + ; Loading upper 512 bytes of boot1h and HFS+ Volume Header. + ; + xor ecx, ecx ; sector 1 of current partition + inc ecx + mov al, 2 ; read 2 sectors: sector 1 of boot1h + HFS+ Volume Header + mov edx, kBoot1Sector1Addr + call readLBA + + ; + ; Initializing more global variables. + ; + mov eax, [kHFSPlusBuffer + HFSPlusVolumeHeader.blockSize] + bswap eax ; convert to little-endian + shr eax, 9 ; convert to sector unit + mov [gBlockSize], eax ; save blockSize as little-endian sector unit! + + ; + ; Looking for HFSPlus ('H+') or HFSPlus case-sensitive ('HX') signature. + ; + mov ax, [kHFSPlusBuffer + HFSPlusVolumeHeader.signature] + cmp ax, kHFSPlusCaseSignature + je findRootBoot + cmp ax, kHFSPlusSignature + jne error + +;-------------------------------------------------------------------------- +; Find stage2 boot file in a HFS+ Volume's root folder. +; +findRootBoot: + mov al, kHFSCatalogFileID + lea si, [searchCatalogKey] + lea di, [kHFSPlusBuffer + HFSPlusVolumeHeader.catalogFile + HFSPlusForkData.extents] + call lookUpBTree + jne error + + lea si, [bp + BTree.recordDataPtr] + mov si, [si] + cmp WORD [si], kHFSPlusFileRecord + jne error + +; EAX = Catalog File ID +; BX = read size in sectors +; ECX = file offset in sectors +; EDX = address of read buffer +; DI = address of HFSPlusForkData + + ; + ; Use the second big-endian double-word as the file length in HFSPlusForkData.logicalSize + ; + mov ebx, [si + HFSPlusCatalogFile.dataFork + HFSPlusForkData.logicalSize + 4] + bswap ebx ; convert file size to little-endian + add ebx, kSectorBytes - 1 ; adjust size before unit conversion + shr ebx, 9 ; convert file size to sector unit + cmp bx, kBoot2Sectors ; check if bigger than max stage2 size + ja error + mov eax, [si + HFSPlusCatalogFile.fileID] + bswap eax ; convert fileID to little-endian + xor ecx, ecx + mov edx, (kBoot2Segment << 4) + kBoot2Address + lea di, [si + HFSPlusCatalogFile.dataFork + HFSPlusForkData.extents] + call readExtent + +%if VERBOSE + LogString(root_str) +%endif + +boot2: + +%if DEBUG + DebugChar ('!') +%endif + +%if UNUSED + ; + ; Waiting for a key press. + ; + + mov ah, 0 + int 0x16 +%endif + + mov dl, [gBIOSDriveNumber] ; load BIOS drive number + jmp kBoot2Segment:kBoot2Address + +error: + +%if VERBOSE + LogString(error_str) +%endif + +hang: + hlt + jmp hang + +;-------------------------------------------------------------------------- +; readSectors - Reads more than 127 sectors using LBA addressing. +; +; Arguments: +; AX = number of 512-byte sectors to read (valid from 1-1280). +; EDX = pointer to where the sectors should be stored. +; ECX = sector offset in partition +; +; Returns: +; CF = 0 success +; 1 error +; +readSectors: + pushad + mov bx, ax + +.loop: + xor eax, eax ; EAX = 0 + mov al, bl ; assume we reached the last block. + cmp bx, maxSectorCount ; check if we really reached the last block + jb .readBlock ; yes, BX < MaxSectorCount + mov al, maxSectorCount ; no, read MaxSectorCount + +.readBlock: + call readLBA + sub bx, ax ; decrease remaning sectors with the read amount + jz .exit ; exit if no more sectors left to be loaded + add ecx, eax ; adjust LBA sector offset + shl ax, 9 ; convert sectors to bytes + add edx, eax ; adjust target memory location + jmp .loop ; read remaining sectors + +.exit: + popad + ret + +;-------------------------------------------------------------------------- +; readLBA - Read sectors from a partition using LBA addressing. +; +; Arguments: +; AL = number of 512-byte sectors to read (valid from 1-127). +; EDX = pointer to where the sectors should be stored. +; ECX = sector offset in partition +; [bios_drive_number] = drive number (0x80 + unit number) +; +; Returns: +; CF = 0 success +; 1 error +; +readLBA: + pushad ; save all registers + push es ; save ES + mov bp, sp ; save current SP + + ; + ; Convert EDX to segment:offset model and set ES:BX + ; + ; Some BIOSes do not like offset to be negative while reading + ; from hard drives. This usually leads to "boot1: error" when trying + ; to boot from hard drive, while booting normally from USB flash. + ; The routines, responsible for this are apparently different. + ; Thus we split linear address slightly differently for these + ; capricious BIOSes to make sure offset is always positive. + ; + + mov bx, dx ; save offset to BX + and bh, 0x0f ; keep low 12 bits + shr edx, 4 ; adjust linear address to segment base + xor dl, dl ; mask low 8 bits + mov es, dx ; save segment to ES + + ; + ; Create the Disk Address Packet structure for the + ; INT13/F42 (Extended Read Sectors) on the stack. + ; + + ; push DWORD 0 ; offset 12, upper 32-bit LBA + push ds ; For sake of saving memory, + push ds ; push DS register, which is 0. + + add ecx, [gPartLBA] ; offset 8, lower 32-bit LBA + push ecx + + push es ; offset 6, memory segment + + push bx ; offset 4, memory offset + + xor ah, ah ; offset 3, must be 0 + push ax ; offset 2, number of sectors + + push WORD 16 ; offset 0-1, packet size + + ; + ; INT13 Func 42 - Extended Read Sectors + ; + ; Arguments: + ; AH = 0x42 + ; [bios_drive_number] = drive number (0x80 + unit number) + ; DS:SI = pointer to Disk Address Packet + ; + ; Returns: + ; AH = return status (sucess is 0) + ; carry = 0 success + ; 1 error + ; + ; Packet offset 2 indicates the number of sectors read + ; successfully. + ; + mov dl, [gBIOSDriveNumber] ; load BIOS drive number + mov si, sp + mov ah, 0x42 + int 0x13 + + jc error + + ; + ; Issue a disk reset on error. + ; Should this be changed to Func 0xD to skip the diskette controller + ; reset? + ; +; xor ax, ax ; Func 0 +; int 0x13 ; INT 13 +; stc ; set carry to indicate error + +.exit: + mov sp, bp ; restore SP + pop es ; restore ES + popad + ret + +%if VERBOSE + +;-------------------------------------------------------------------------- +; Write a string with 'boot1: ' prefix to the console. +; +; Arguments: +; ES:DI pointer to a NULL terminated string. +; +; Clobber list: +; DI +; +log_string: + pushad + + push di + mov si, log_title_str + call print_string + + pop si + call print_string + + popad + + ret + +;------------------------------------------------------------------------- +; Write a string to the console. +; +; Arguments: +; DS:SI pointer to a NULL terminated string. +; +; Clobber list: +; AX, BX, SI +; +print_string: + mov bx, 1 ; BH=0, BL=1 (blue) + +.loop: + lodsb ; load a byte from DS:SI into AL + cmp al, 0 ; Is it a NULL? + je .exit ; yes, all done + mov ah, 0xE ; INT10 Func 0xE + int 0x10 ; display byte in tty mode + jmp .loop + +.exit: + ret + +%endif ; VERBOSE + +%if DEBUG + +;-------------------------------------------------------------------------- +; Write the 4-byte value to the console in hex. +; +; Arguments: +; EAX = Value to be displayed in hex. +; +print_hex: + pushad + mov cx, WORD 4 + bswap eax +.loop: + push ax + ror al, 4 + call print_nibble ; display upper nibble + pop ax + call print_nibble ; display lower nibble + ror eax, 8 + loop .loop + +%if UNUSED + mov al, 10 ; carriage return + call print_char + mov al, 13 + call print_char +%endif ; UNUSED + + popad + ret + +print_nibble: + and al, 0x0f + add al, '0' + cmp al, '9' + jna .print_ascii + add al, 'A' - '9' - 1 +.print_ascii: + call print_char + ret + +;-------------------------------------------------------------------------- +; getc - wait for a key press +; +getc: + pushad + mov ah, 0 + int 0x16 + popad + ret + +;-------------------------------------------------------------------------- +; Write a ASCII character to the console. +; +; Arguments: +; AL = ASCII character. +; +print_char: + pushad + mov bx, 1 ; BH=0, BL=1 (blue) + mov ah, 0x0e ; bios INT 10, Function 0xE + int 0x10 ; display byte in tty mode + popad + ret + +%endif ; DEBUG + +%if UNUSED + +;-------------------------------------------------------------------------- +; Convert null terminated string to HFSUniStr255 +; +; Arguments: +; DS:DX pointer to a NULL terminated string. +; ES:DI pointer to result. +; +ConvertStrToUni: + pushad ; save registers + push di ; save DI for unicode string length pointer + mov si, dx ; use SI as source string pointer + xor ax, ax ; AX = unicode character + mov cl, al ; CL = string length + +.loop: + stosw ; store unicode character (length 0 at first run) + lodsb ; load next character to AL + inc cl ; increment string length count + cmp al, NULL ; check for string terminator + jne .loop + + pop di ; restore unicode string length pointer + dec cl ; ignoring terminator from length count + mov [di], cl ; save string length + popad ; restore registers + ret + +%endif ; UNUSED + +;-------------------------------------------------------------------------- +; Convert big-endian HFSUniStr255 to little-endian +; +; Arguments: +; DS:SI = pointer to big-endian HFSUniStr255 +; ES:DI = pointer to result buffer +; +ConvertHFSUniStr255ToLE: + pushad + lodsw + xchg ah, al + stosw + cmp al, 0 + je .exit + mov cx, ax + +.loop: + lodsw + xchg ah, al ; convert AX to little-endian + + ; + ; When working with a case-sensitive HFS+ (HX) filesystem, we shouldn't change the case. + ; + cmp BYTE [kHFSPlusBuffer + HFSPlusVolumeHeader.signature + 1], kHFSPlusCaseSigX + je .keepcase + + or ax, ax + jne .convertToLE + dec ax ; NULL must be the strongest char + +.convertToLE: + cmp ah, 0 + ja .keepcase + cmp al, 'A' + jb .keepcase + cmp al, 'Z' + ja .keepcase + add al, 32 ; convert to lower-case + +.keepcase: + stosw + loop .loop + +.exit: + popad + ret + +;-------------------------------------------------------------------------- +; compare HFSPlusExtentKey structures +; +; Arguments: +; DS:SI = search key +; ES:DI = trial key +; +; Returns: +; [BTree.searchResult] = result +; FLAGS = relation between search and trial keys +; +compareHFSPlusExtentKeys: + pushad + + mov dl, 0 ; DL = result of comparison, DH = bestGuess + mov eax, [si + HFSPlusExtentKey.fileID] + cmp eax, [di + HFSPlusExtentKey.fileID] + jne .checkFlags + + cmp BYTE [si + HFSPlusExtentKey.forkType], kForkTypeData + jne .checkFlags + + mov eax, [si + HFSPlusExtentKey.startBlock] + cmp eax, [di + HFSPlusExtentKey.startBlock] + je compareHFSPlusCatalogKeys.exit + +.checkFlags: + ja compareHFSPlusCatalogKeys.searchKeyGreater ; search key > trial key + jb compareHFSPlusCatalogKeys.trialKeyGreater ; search key < trial key + +;-------------------------------------------------------------------------- +; Compare HFSPlusCatalogKey structures +; +; Arguments: +; DS:SI = search key +; ES:DI = trial key +; +; Returns: +; [BTree.searchResult] = result +; FLAGS = relation between search and trial keys +; +compareHFSPlusCatalogKeys: + pushad + xor dx, dx ; DL = result of comparison, DH = bestGuess + xchg si, di + lodsd + mov ecx, eax ; ECX = trial parentID + xchg si, di + lodsd ; EAX = search parentID + cmp eax, ecx + ja .searchKeyGreater ; search parentID > trial parentID + jb .trialKeyGreater ; search parentID < trial parentID + +.compareNodeName: ; search parentID = trial parentID + xchg si, di + lodsw + mov cx, ax ; CX = trial nodeName.length + xchg si, di + lodsw ; AX = search nodeName.length + cmp cl, 0 ; trial nodeName.length = 0? + je .searchKeyGreater + + cmp ax, cx + je .strCompare + ja .searchStrLonger + +.trialStrLonger: + dec dh + mov cx, ax + jmp .strCompare + +.searchStrLonger: + inc dh + +.strCompare: + repe cmpsw + ja .searchKeyGreater + jb .trialKeyGreater + mov dl, dh + jmp .exit + +.trialKeyGreater: + dec dl + jmp .exit + +.searchKeyGreater: + inc dl + +.exit: + mov [bp + BTree.searchResult], dl + cmp dl, 0 ; set flags to check relation between keys + + popad + ret + +;-------------------------------------------------------------------------- +; Allocate memory +; +; Arguments: +; CX = size of requested memory +; +; Returns: +; BP = start address of allocated memory +; +; Clobber list: +; CX +; +malloc: + push ax ; save AX + push di ; save DI + mov di, [gMallocPtr] ; start address of free space + push di ; save free space start address + inc di ; + inc di ; keep the first word untouched + dec cx ; for the last memory block pointer. + dec cx ; + mov al, NULL ; fill with zero + rep stosb ; repeat fill + mov [gMallocPtr], di ; adjust free space pointer + pop bp ; BP = start address of allocated memory + mov [di], bp ; set start address of allocated memory at next + ; allocation block's free space address. + pop di ; restore DI + pop ax ; restore AX + ret + +%if UNUSED + +;-------------------------------------------------------------------------- +; Free allocated memory +; +; Returns: +; BP = start address of previously allocated memory +; +free: + lea bp, [gMallocPtr] + mov bp, [bp] + mov [gMallocPtr], bp + ret + +%endif ; UNUSED + +;-------------------------------------------------------------------------- +; Static data. +; + +%if VERBOSE +root_str db '/boot', NULL +%endif + +;-------------------------------------------------------------------------- +; Pad the rest of the 512 byte sized sector with zeroes. The last +; two bytes is the mandatory boot sector signature. +; +; If the booter code becomes too large, then nasm will complain +; that the 'times' argument is negative. + +pad_table_and_sig: + times 510-($-$$) db 0 + dw kBootSignature + +; +; Sector 1 code area +; + +;-------------------------------------------------------------------------- +; lookUpBTree - initializes a new BTree instance and +; look up for HFSPlus Catalog File or Extent Overflow keys +; +; Arguments: +; AL = kHFSPlusFileID (Catalog or Extents Overflow) +; SI = address of searchKey +; DI = address of HFSPlusForkData.extents +; +; Returns: +; BP = address of BTree instance +; ECX = rootNode's logical offset in sectors +; +lookUpBTree: + mov cx, BTree_size ; allocate memory with BTree_size + call malloc ; BP = start address of allocated memory. + mov [bp + BTree.fileID], al ; save fileFileID + mov edx, [di] ; first extent of current file + call blockToSector ; ECX = converted to sector unit + mov al, 1 ; 1 sector is enough for + xor edx, edx ; reading current file's header. + lea dx, [bp + BTree.BTHeaderBuffer] ; load into BTreeHeaderBuffer + call readLBA ; read + mov ax, [bp + BTree.BTHeaderBuffer + BTNodeDescriptor_size + BTHeaderRec.nodeSize] + xchg ah, al ; convert to little-endian + mov [bp + BTree.nodeSize], ax ; save nodeSize + + ; + ; Always start the lookup process with the root node. + ; + mov edx, [bp + BTree.BTHeaderBuffer + BTNodeDescriptor_size + BTHeaderRec.rootNode] + +.readNode: + ; + ; Converting nodeID to sector unit + ; + mov ax, [bp + BTree.nodeSize] + shr ax, 9 ; convert nodeSize to sectors + mov bx, ax ; BX = read sector count + cwde + bswap edx ; convert node ID to little-endian + mul edx ; multiply with nodeSize converted to sector unit + mov ecx, eax ; ECX = file offset in BTree + + mov eax, [bp + BTree.fileID] + lea edx, [bp + BTree.nodeBuffer] + call readExtent + + ; + ; AX = lowerBound = 0 + ; + xor ax, ax + + ; + ; BX = upperBound = numRecords - 1 + ; + mov bx, [bp + BTree.nodeBuffer + BTNodeDescriptor.numRecords] + xchg bh, bl + dec bx + +.bsearch: + cmp ax, bx + ja .checkResult ; jump if lowerBound > upperBound + + mov cx, ax + add cx, bx + shr cx, 1 ; test index = (lowerBound + upperBound / 2) + + call getBTreeRecord + +%if UNUSED + pushad + jl .csearchLessThanTrial + jg .csearchGreaterThanTrial + PrintChar('=') + jmp .csearchCont +.csearchGreaterThanTrial: + PrintChar('>') + jmp .csearchCont +.csearchLessThanTrial: + PrintChar('<') +.csearchCont: + popad +%endif ; UNUSED + +.adjustBounds: + je .checkResult + jl .searchLessThanTrial + jg .searchGreaterThanTrial + jmp .bsearch + +.searchLessThanTrial: + mov bx, cx + dec bx ; upperBound = index - 1 + jmp .bsearch + +.searchGreaterThanTrial: + mov ax, cx + inc ax ; lowerBound = index + 1 + jmp .bsearch + +.checkResult: + cmp BYTE [bp + BTree.searchResult], 0 + jge .foundKey + + mov cx, bx + call getBTreeRecord + +.foundKey: + cmp BYTE [bp + BTree.nodeBuffer + BTNodeDescriptor.kind], kBTIndexNode + jne .exit + + lea bx, [bp + BTree.recordDataPtr] + mov bx, [bx] + mov edx, [bx] + jmp .readNode + +.exit: + cmp BYTE [bp + BTree.searchResult], 0 + ret + +;-------------------------------------------------------------------------- +; getBTreeRecord - read and compare BTree record +; +; Arguments: +; CX = record index +; SI = address of search key +; +; Returns: +; [BTree.searchResult] = result of key compare +; [BTree.recordDataPtr] = address of record data +; +getBTreeRecord: + pushad + push si ; save SI + lea di, [bp + BTree.nodeBuffer] ; DI = start of nodeBuffer + push di ; use later + mov ax, [bp + BTree.nodeSize] ; get nodeSize + add di, ax ; DI = beyond nodeBuffer + inc cx ; increment index + shl cx, 1 ; * 2 + sub di, cx ; DI = pointer to record + mov ax, [di] ; offset to record + xchg ah, al ; convert to little-endian + pop di ; start of nodeBuffer + add di, ax ; DI = address of record key + mov si, di ; save to SI + mov ax, [di] ; keyLength + xchg ah, al ; convert to little-endian + inc ax ; suppress keySize (2 bytes) + inc ax ; + add di, ax ; DI = address of record data + mov [bp + BTree.recordDataPtr], di ; save address of record data + lea di, [bp + BTree.trialKey] + push di ; save address of trialKey + lodsw ; suppress keySize (2 bytes) + ; + ; Don't need to compare as DWORD since all reserved CNIDs fits to a single byte + ; + cmp BYTE [bp + BTree.fileID], kHFSCatalogFileID + je .prepareTrialCatalogKey + +.prepareTrialExtentKey: + mov bx, compareHFSPlusExtentKeys + movsw ; copy forkType + pad + mov cx, 2 ; copy fileID + startBlock + +.extentLoop: + lodsd + bswap eax ; convert to little-endian + stosd + loop .extentLoop + jmp .exit + +.prepareTrialCatalogKey: + mov bx, compareHFSPlusCatalogKeys + lodsd + bswap eax ; convert ParentID to little-endian + stosd + call ConvertHFSUniStr255ToLE ; convert nodeName to little-endian + +.exit: + pop di ; restore address of trialKey + +%if UNUSED +; +; Print catalog trial key +; + pushad + mov si, di + lodsd + PrintChar('k') + PrintHex() + lodsw + cmp ax, 0 + je .printExit + mov cx, ax +.printLoop: + lodsw + call print_char + loop .printLoop +.printExit: + popad +; +; +; +%endif ; UNUSED + +%if UNUSED +; +; Print extent trial key +; + pushad + PrintChar('k') + mov si, di + xor eax, eax + lodsw + PrintHex() + lodsd + PrintHex() + lodsd + PrintHex() + popad +; +; +; +%endif ; UNUSED + + pop si ; restore SI + call bx ; call key compare proc + popad + ret + +;-------------------------------------------------------------------------- +; readExtent - read extents from a HFS+ file (multiple extent support) +; +; Arguments: +; EAX = Catalog File ID +; BX = read size in sectors +; ECX = file offset in sectors +; EDX = address of read buffer +; DI = address of HFSPlusForkData.extents +; +readExtent: + pushad + ; + ; Save Catalog File ID as part of a search HFSPlusExtentKey + ; for a possible Extents Overflow lookup. + ; + mov [bp + BTree.searchExtentKey + HFSPlusExtentKey.fileID], eax + mov [bp + BTree.readBufferPtr], edx + mov ax, bx + cwde + mov [bp + BTree.readSize], eax + mov ebx, ecx ; EBX = file offset + xor eax, eax + mov [bp + BTree.currentExtentOffs], eax + +.beginExtentBlock: + mov BYTE [bp + BTree.extentCount], 0 + +.extentSearch: + cmp BYTE [bp + BTree.extentCount], kHFSPlusExtentDensity + jb .continue + +.getNextExtentBlock: + push ebx + mov eax, [bp + BTree.currentExtentOffs] + + ; + ; Converting sector unit to HFS+ allocation block unit. + ; + xor edx, edx + div DWORD [gBlockSize] ; divide with blockSize + + ; + ; Preparing searchExtentKey's startBlock field. + ; + mov [bp + BTree.searchExtentKey + HFSPlusExtentKey.startBlock], eax + + mov al, kHFSExtentsFileID + lea si, [bp + BTree.searchExtentKey] + lea di, [kHFSPlusBuffer + HFSPlusVolumeHeader.extentsFile + HFSPlusForkData.extents] + call lookUpBTree + jnz NEAR .exit + + ; + ; BP points to the new workspace allocated by lookUpBTree. + ; + lea di, [bp + BTree.recordDataPtr] + mov di, [di] + + ; + ; Switch back to the previous workspace. + ; + lea bp, [gMallocPtr] + mov bp, [bp] + mov [gMallocPtr], bp + + pop ebx + jmp .beginExtentBlock + +.continue: + mov edx, [di + HFSPlusExtentDescriptor.blockCount] + call blockToSector ; ECX = converted current extent's blockCount to sectors + mov eax, [bp + BTree.currentExtentOffs] ; EAX = current extent's start offset (sector) + mov edx, eax + add edx, ecx ; EDX = next extent's start offset (sector) + cmp ebx, edx + mov [bp + BTree.currentExtentOffs], edx ; set currentExtentOffs as the next extent's start offset + jae .nextExtent ; jump to next extent if file offset > next extent's start offset + +.foundExtent: + mov edx, ebx + sub edx, eax ; EDX = relative offset within current extent + mov eax, edx ; will be used below to determine read size + mov esi, [bp + BTree.readSize] ; ESI = remaining sectors to be read + add edx, esi + cmp edx, ecx ; test if relative offset + readSize fits to this extent + jbe .read ; read all remaining sectors from this extent + +.splitRead: + sub ecx, eax ; read amount of sectors beginning at relative offset + mov esi, ecx ; of current extent up to the end of current extent + +.read: + mov edx, [di + HFSPlusExtentDescriptor.startBlock] + call blockToSector ; ECX = converted to sectors + add ecx, eax ; file offset converted to sectors + + push si + mov ax, si + mov edx, [bp + BTree.readBufferPtr] + call readSectors + pop si + + add ebx, esi + mov ax, si + cwde + shl ax, 9 ; convert SI (read sector count) to byte unit + add [bp + BTree.readBufferPtr], eax + sub [bp + BTree.readSize], esi + + jz .exit + +.nextExtent: + add di, kHFSPlusExtentDensity + inc BYTE [bp + BTree.extentCount] + jmp .extentSearch + +.exit: + popad + ret + +;-------------------------------------------------------------------------- +; Convert big-endian HFSPlus allocation block to sector unit +; +; Arguments: +; EDX = allocation block +; +; Returns: +; ECX = allocation block converted to sector unit +; +; Clobber list: +; EDX +; +blockToSector: + push eax + mov eax, [gBlockSize] + bswap edx ; convert allocation block to little-endian + mul edx ; multiply with block number + mov ecx, eax ; result in EAX + pop eax + ret + +%if UNUSED + +;-------------------------------------------------------------------------- +; Convert sector unit to HFSPlus allocation block unit +; +; Arguments: +; EDX = sector +; +; Returns: +; ECX = converted to allocation block unit +; +; Clobber list: +; EDX +; +sectorToBlock: + push eax + mov eax, edx + xor edx, edx + div DWORD [gBlockSize] ; divide with blockSize + mov ecx, eax ; result in EAX + pop eax + ret + +%endif ; UNUSED + +%if UNUSED + +;-------------------------------------------------------------------------- +; Convert big-endian BTree node ID to sector unit +; +; Arguments: +; EDX = node ID +; +; Returns: +; ECX = node ID converted to sector unit +; +; Clobber list: +; EDX +; +nodeToSector: + push eax + mov ax, [bp + BTree.nodeSize] + shr ax, 9 ; convert nodeSize to sectors + cwde + bswap edx ; convert node ID to little-endian + mul edx ; multiply with node ID + mov ecx, eax ; result in EAX + pop eax + ret + +%endif ; UNUSED + +;-------------------------------------------------------------------------- +; Static data. +; + +%if VERBOSE +log_title_str db CR, LF, 'boot1: ', NULL +error_str db 'error', NULL +%endif + +searchCatalogKey dd kHFSRootFolderID + dw searchCatKeyNameLen +searchCatKeyName dw 'b', 'o', 'o', 't' ; must be lower case +searchCatKeyNameLen EQU ($ - searchCatKeyName) / 2 + +;-------------------------------------------------------------------------- +; Pad the rest of the 512 byte sized sector with zeroes. The last +; two bytes is the mandatory boot sector signature. +; +pad_sector_1: + times 1022-($-$$) db 0 + dw kBootSignature + +; +; Local BTree variables +; + struc BTree +.mallocLink resw 1 ; pointer to previously allocated memory block +.fileID resd 1 ; will use as BYTE +.nodeSize resd 1 ; will use as WORD +.searchExtentKey resb HFSPlusExtentKey_size +.searchResult resb 1 +.trialKey resb kBTMaxRecordLength +.recordDataPtr resw 1 +.readBufferPtr resd 1 +.currentExtentOffs resd 1 +.readSize resd 1 +.extentCount resb 1 + ALIGNB 2 +.BTHeaderBuffer resb kSectorBytes +.nodeBuffer resb maxNodeSize + endstruc + +; +; Global variables +; + + ABSOLUTE kHFSPlusBuffer + HFSPlusVolumeHeader_size + +gPartLBA resd 1 +gBIOSDriveNumber resw 1 +gBlockSize resd 1 +gMallocPtr resw 1 + +; END Index: branches/azimutz/Cleancut/i386/boot2/picopng.c =================================================================== --- branches/azimutz/Cleancut/i386/boot2/picopng.c (revision 884) +++ branches/azimutz/Cleancut/i386/boot2/picopng.c (revision 885) @@ -17,6 +17,7 @@ // misrepresented as being the original software. // 3. This notice may not be removed or altered from any source distribution. +#include <sys/types.h> #include "libsa.h" #include "picopng.h" Index: branches/azimutz/Cleancut/i386/boot2/drivers.c =================================================================== --- branches/azimutz/Cleancut/i386/boot2/drivers.c (revision 884) +++ branches/azimutz/Cleancut/i386/boot2/drivers.c (revision 885) @@ -38,6 +38,7 @@ #include "bootstruct.h" #include "xml.h" #include "ramdisk.h" +#include "modules.h" //extern char gMacOSVersion[8]; @@ -393,6 +394,10 @@ length = LoadThinFatFile(fileSpec, (void **)&package); if (length < sizeof (DriversPackage)) return -1; + // call hook to notify modules that the mkext has been loaded + execute_hook("LoadDriverMKext", (void*)fileSpec, (void*)package, (void*) &length, NULL); + + // Verify the MKext. if (( GetPackageElement(signature1) != kDriverPackageSignature1) || ( GetPackageElement(signature2) != kDriverPackageSignature2) || Index: branches/azimutz/Cleancut/i386/boot2/prompt.c =================================================================== --- branches/azimutz/Cleancut/i386/boot2/prompt.c (revision 884) +++ branches/azimutz/Cleancut/i386/boot2/prompt.c (revision 885) @@ -26,7 +26,7 @@ * All rights reserved. */ -#include "vers.h" +#include <vers.h> char bootBanner[] = "\nDarwin/x86 boot v" I386BOOT_VERSION " - Chameleon v" I386BOOT_CHAMELEONVERSION " r" I386BOOT_CHAMELEONREVISION "\n" "Build date: " I386BOOT_BUILDDATE "\n" Index: branches/azimutz/Cleancut/i386/boot2/Makefile =================================================================== --- branches/azimutz/Cleancut/i386/boot2/Makefile (revision 884) +++ branches/azimutz/Cleancut/i386/boot2/Makefile (revision 885) @@ -1,3 +1,11 @@ +SRCROOT = $(shell pwd)/../../ +OBJROOT = $(SRCROOT)/obj/i386/boot2 +SYMROOT = $(SRCROOT)/sym/i386 +DSTROOT = $(SRCROOT)/dst/i386 +DOCROOT = $(SRCROOT)/doc +IMGROOT = $(SRCROOT)/sym/cache +IMGSKELROOT = $(SRCROOT)/imgskel +CDBOOT = ${IMGROOT}/usr/standalone/i386/cdboot # Makefile for i386 boot program # define FLOPPY and SMALL using DEFINES macro as necessary @@ -6,39 +14,30 @@ PNGOPTIONS = -rem cHRM -rem gAMA -rem iCCP -rem sRGB DIR = boot2 -include ../MakePaths.dir +include ${SRCROOT}/Make.rules OPTIM = -Os -Oz CFLAGS = $(RC_CFLAGS) $(OPTIM) $(MORECPP) -arch i386 -g -Wmost -Werror \ -fno-builtin -DSAIO_INTERNAL_USER -static $(OMIT_FRAME_POINTER_CFLAG) \ -mpreferred-stack-boundary=2 -fno-align-functions -fno-stack-protector \ - -march=pentium4 -msse2 -mfpmath=sse -msoft-float + -march=pentium4 -msse2 -mfpmath=sse -msoft-float -nostdinc -include $(SRCROOT)/autoconf.h +CPPFLAGS := $(CPPFLAGS) -nostdinc++ -include $(SRCROOT)/autoconf.h + DEFINES= CONFIG = hd SYMDIR = $(SYMROOT) LIBSADIR = ../libsa LIBSAIODIR = ../libsaio -UTILDIR = ../util -THEME = embed +THEME = $(CONFIG_EMBEDED_THEME) THEMEDIR = ../../artwork/themes/$(THEME) -INC = -I. -I.. -I$(SYMDIR) -I$(LIBSADIR) -I$(LIBSAIODIR) -I$(UTILDIR) -ifneq "" "$(wildcard /bin/mkdirs)" - MKDIRS = /bin/mkdirs -else - MKDIRS = /bin/mkdir -p -endif -AS = as -LD = gcc -# LIBS= -lc_static +INC = -I. -I$(SYMDIR) -I$(LIBSADIR) -I$(LIBSAIODIR) -I${SRCROOT}/i386/include + LIBS= -L$(SYMDIR) -lsaio -lsa -LIBDEP= $(SYMDIR)/libsaio.a $(SYMDIR)/libsa.a +LIBDEP= libsaio.a libsa.a OTHER_FILES = -INSTALLDIR = $(DSTROOT)/usr/standalone/i386 -VPATH = $(OBJROOT):$(SYMROOT) - # The ordering is important; # boot2.o must be first. OBJS = boot2.o boot.o graphics.o drivers.o prompt.o options.o lzss.o mboot.o \ @@ -46,12 +45,6 @@ # button.o browser.o scrollbar.o == NOTYET UTILDIR = ../util -SFILES = boot2.s -CFILES = boot.c graphics.c drivers.c prompt.c options.c mboot.c picopng.c modules.c -HFILES = boot.h appleClut8.h appleboot.h mboot.h multiboot.h picopng.h modules.h -OTHERFILES = Makefile -ALLSRC = $(FOREIGNSRC) $(FOREIGNBIN) $(SFILES) $(CFILES) \ - $(HFILES) $(OTHERFILES) DIRS_NEEDED = $(OBJROOT) $(SYMROOT) BOOT2ADDR = 20200 MAXBOOTSIZE = 458240 @@ -68,17 +61,27 @@ PATCH_ADDR = $(shell echo ${SYMBOL_ADDR}-${DATA_ADDR}+${DATA_OFFSET} | bc) -all: $(DIRS_NEEDED) boot -embedtheme: CFLAGS += -DEMBED_THEME -embedtheme: art.h all +all: $(DIRS_NEEDED) boot -boot: machOconv embedded.h $(OBJS) $(LIBDEP) +ifeq (${CONFIG_EMBED_THEME}, y) + +boot: $(SYMROOT)/art.h $(SYMROOT)/vers.h $(SYMROOT)/embedded.h $(addprefix $(OBJROOT)/, $(OBJS)) $(addprefix $(SYMROOT)/, $(LIBDEP)) + +else + +boot: $(SYMROOT)/vers.h $(SYMROOT)/embedded.h $(addprefix $(OBJROOT)/, $(OBJS)) $(addprefix $(SYMROOT)/, $(LIBDEP)) + + +endif + @echo "\t[LD] boot.sys" - @$(LD) -static -Wl,-preload -Wl,-segaddr,__INIT,$(BOOT2ADDR) \ + @$(CC) -static -Wl,-preload -Wl,-segaddr,__INIT,$(BOOT2ADDR) \ -nostdlib -arch i386 -Wl,-segalign,20 \ -o $(SYMROOT)/boot.sys $(filter %.o,$^) $(LIBS) -lcc_kext +ifeq (${CONFIG_MODULES}, y) + @cp $(SYMROOT)/boot.sys $(SYMROOT)/boot2.sys @# Generate the Symbols.dylib file @@ -86,7 +89,7 @@ @$(SYMROOT)/dyldsymboltool $(SYMROOT)/boot.sys $(SYMROOT)/${SYMBOLS_MODULE} @echo "\t[LD] boot.sys" - @$(LD) -static -Wl,-preload -Wl,-segaddr,__INIT,$(BOOT2ADDR) \ + @$(CC) -static -Wl,-preload -Wl,-segaddr,__INIT,$(BOOT2ADDR) \ -nostdlib -arch i386 -Wl,-segalign,20 \ -Wl,-sectcreate,__DATA,__Symbols,$(SYMROOT)/Symbols.dylib \ -o $(SYMROOT)/boot.sys $(filter %.o,$^) $(LIBS) -lcc_kext @@ -100,23 +103,27 @@ @${RM} $(SYMROOT)/boot.sys @echo "\t[LD] boot.sys" - @$(LD) -static -Wl,-preload -Wl,-segaddr,__INIT,$(BOOT2ADDR) \ + @$(CC) -static -Wl,-preload -Wl,-segaddr,__INIT,$(BOOT2ADDR) \ -nostdlib -arch i386 -Wl,-segalign,20 \ -Wl,-sectcreate,__DATA,__Symbols,$(SYMROOT)/Symbols.dylib \ -o $(SYMROOT)/boot.sys $(filter %.o,$^) $(LIBS) -lcc_kext - @ld -arch i386 \ + @$(LD) -arch i386 \ -undefined dynamic_lookup \ -dylib -read_only_relocs suppress \ -S -x -Z -dead_strip_dylibs \ -no_uuid \ + $(filter %.o,$^) $(LIBS) \ -final_output Symbols \ - $(filter %.o,$^) $(LIBS) \ -macosx_version_min 10.6 \ -o $(OBJROOT)/Symbols_LINKER_ONLY.dylib + + +endif + @make embed_symbols # this is done in a sub process after boot.sys exists so the strings are populated correctly @${RM} $(SYMROOT)/boot2.sys @@ -133,26 +140,26 @@ fi) -embed_symbols: machOconv +embed_symbols: +ifeq (${CONFIG_MODULES}, y) @echo ================= Embedding Symbols.dylib ================= @echo "\t[MACHOCONV] boot" @$(SYMROOT)/machOconv $(SYMROOT)/boot2.sys $(SYMROOT)/boot &> /dev/null @echo "\t******* Patching at $(PATCH_ADDR) ******" @stat -f%z $(SYMROOT)/boot | perl -ane "print pack('V',@F[0]);" | dd conv=notrunc of=${SYMROOT}/boot.sys bs=1 count=4 seek=$(PATCH_ADDR) &> /dev/null +endif @echo "\t[MACHOCONV] boot" @$(SYMROOT)/machOconv $(SYMROOT)/boot.sys $(SYMROOT)/boot - -prompt.o: vers.h -vers.h: +$(SYMROOT)/vers.h: @echo "#define I386BOOT_VERSION \"5.0.132\"" > $(SYMROOT)/vers.h @echo "#define I386BOOT_BUILDDATE \"`date \"+%Y-%m-%d %H:%M:%S\"`\"" >> $(SYMROOT)/vers.h @echo "#define I386BOOT_CHAMELEONVERSION \"`cat ../../version`\"" >> $(SYMROOT)/vers.h @echo "#define I386BOOT_CHAMELEONREVISION \"`svnversion -n | tr -d [:alpha:]`\"" >> $(SYMROOT)/vers.h -art.h: +$(SYMROOT)/art.h: @if [ "$(PNGCRUSH)" ]; then \ echo "optimizing art files ...\n$(PNGCRUSH) $(PNGOPTIONS) artwork/$(THEME)"; \ cd $(THEMEDIR) && find . -name '*.png' -exec $(PNGCRUSH) -q $(PNGOPTIONS) -d $(SYMROOT)/embed {} \;; \ @@ -178,14 +185,11 @@ @echo "#endif /* !__BOOT2_ART_H */" >> $(SYMROOT)/art.h ;\ -embedded.h: +$(SYMROOT)/embedded.h: @cd $(SYMROOT)/../../doc && xxd -i BootHelp.txt > $(SYMROOT)/embedded.h -install_i386:: all $(INSTALLDIR) - cp $(SYMROOT)/boot $(OTHER_FILES) $(INSTALLDIR) - cd $(INSTALLDIR); chmod u+w boot $(OTHER_FILES) -include ../MakeInc.dir +.PHONY: $(SYMROOT)/vers.h #dependencies -include $(OBJROOT)/Makedep Index: branches/azimutz/Cleancut/i386/boot2/modules.c =================================================================== --- branches/azimutz/Cleancut/i386/boot2/modules.c (revision 884) +++ branches/azimutz/Cleancut/i386/boot2/modules.c (revision 885) @@ -2,8 +2,9 @@ * Copyright 2010 Evan Lojewski. All rights reserved. * */ -#ifndef DEBUG_MODULES -#define DEBUG_MODULES 0 +#ifdef CONFIG_MODULES +#ifndef CONFIG_MODULE_DEBUG +#define CONFIG_MODULE_DEBUG 0 #endif #include "boot.h" @@ -11,7 +12,7 @@ #include "modules.h" -#if DEBUG_MODULES +#if CONFIG_MODULE_DEBUG #define DBG(x...) printf(x); #define DBGPAUSE() getc() #else @@ -162,7 +163,7 @@ (*module_start)(); // Start the module DBG("Module %s Loaded.\n", module); DBGPAUSE(); } -#if DEBUG_MODULES +#if CONFIG_MODULE_DEBUG else // The module does not have a valid start function. This may be a library. { printf("WARNING: Unable to start %s\n", module); @@ -272,7 +273,7 @@ } } -#if DEBUG_MODULES +#if CONFIG_MODULE_DEBUG verbose("Unable to locate symbol %s\n", name); getc(); #endif @@ -1087,7 +1088,7 @@ } -#if DEBUG_MODULES +#if CONFIG_MODULE_DEBUG //print_hook_list(); //getc(); #endif @@ -1115,7 +1116,7 @@ } -#if DEBUG_MODULES +#if CONFIG_MODULE_DEBUG void print_hook_list() { printf("---Hook Table---\n"); @@ -1138,3 +1139,21 @@ printf("ERROR: dyld_stub_binder was called, should have been take care of by the linker.\n"); getc(); } + +#else /* CONFIG_MODULES */ + +int init_module_system() +{ + return 0; +} + +void load_all_modules() +{ + +} + +int execute_hook(const char* name, void* arg1, void* arg2, void* arg3, void* arg4) +{ + return 0; +} +#endif \ No newline at end of file Index: branches/azimutz/Cleancut/i386/boot2/bmdecompress.c =================================================================== --- branches/azimutz/Cleancut/i386/boot2/bmdecompress.c (revision 884) +++ branches/azimutz/Cleancut/i386/boot2/bmdecompress.c (revision 885) @@ -21,11 +21,6 @@ */ #include "boot.h" -typedef uint8_t UInt8; -typedef uint16_t UInt16; -typedef int8_t SInt8; -typedef int16_t SInt16; - static void PreviewDecompress16(uint32_t * compressBuffer, uint32_t width, uint32_t height, uint32_t row, Index: branches/azimutz/Cleancut/i386/boot2/gui.c =================================================================== --- branches/azimutz/Cleancut/i386/boot2/gui.c (revision 884) +++ branches/azimutz/Cleancut/i386/boot2/gui.c (revision 885) @@ -16,7 +16,7 @@ #define THEME_NAME_DEFAULT "Default" static const char *theme_name = THEME_NAME_DEFAULT; -#ifdef EMBED_THEME +#ifdef CONFIG_EMBED_THEME #include "art.h" #endif @@ -181,7 +181,7 @@ return -1; } -#ifdef EMBED_THEME +#ifdef CONFIG_EMBED_THEME static int getEmbeddedImageIndexByName(const char *name) { int upperLimit = sizeof(embeddedImages) / sizeof(embeddedImages[0]) - 1; @@ -227,7 +227,7 @@ { char dirspec[256]; int i; -#ifdef EMBED_THEME +#ifdef CONFIG_EMBED_THEME int e; #endif uint16_t width; @@ -255,7 +255,7 @@ flipRB(images[i].image); return 0; } -#ifdef EMBED_THEME +#ifdef CONFIG_EMBED_THEME else if ((e = getEmbeddedImageIndexByName(image)) >= 0) { unsigned char *embed_data; @@ -286,7 +286,7 @@ } else { -#ifndef EMBED_THEME +#ifndef CONFIG_EMBED_THEME printf("ERROR: GUI: could not open '%s/%s.png'!\n", theme_name, image); sleep(2); #endif @@ -689,7 +689,7 @@ } sprintf(dirspec, "/Extra/Themes/%s/theme.plist", theme_name); if (loadConfigFile(dirspec, &bootInfo->themeConfig) != 0) { -#ifdef EMBED_THEME +#ifdef CONFIG_EMBED_THEME config_file_t *config; config = &bootInfo->themeConfig; @@ -1804,7 +1804,7 @@ } sprintf(dirspec, "/Extra/Themes/%s/boot.png", theme_name); if (loadPngImage(dirspec, &bootImageWidth, &bootImageHeight, &bootImageData) != 0) { -#ifdef EMBED_THEME +#ifdef CONFIG_EMBED_THEME if ((loadEmbeddedPngImage(__boot_png, __boot_png_len, &bootImageWidth, &bootImageHeight, &bootImageData)) != 0) #endif usePngImage = false; Index: branches/azimutz/Cleancut/i386/boot2/modules_support.s =================================================================== --- branches/azimutz/Cleancut/i386/boot2/modules_support.s (revision 884) +++ branches/azimutz/Cleancut/i386/boot2/modules_support.s (revision 885) @@ -1,3 +1,4 @@ +#ifdef CONFIG_MODULES #include <architecture/i386/asm_help.h> LABEL(dyld_stub_binder) @@ -4,4 +5,6 @@ jmp _dyld_stub_binder LABEL(dyld_void_start) - ret \ No newline at end of file + ret + +#endif \ No newline at end of file Index: branches/azimutz/Cleancut/i386/boot2/Cconfig =================================================================== --- branches/azimutz/Cleancut/i386/boot2/Cconfig (revision 0) +++ branches/azimutz/Cleancut/i386/boot2/Cconfig (revision 885) @@ -0,0 +1,29 @@ +config MODULES + bool "Module System" + default y + ---help--- + Say Y here if you want to enable to use of modules. + +config MODULE_DEBUG + bool "debug support" + default n + depends on MODULES + ---help--- + Say Y here if you want to enable debug mode for the + module system. + +source "i386/modules/Cconfig" + +config EMBED_THEME + bool "Embed Theme" + default n + ---help--- + Say Y here if you want compile in a default theme. + +config EMBEDED_THEME + string "Theme name" + default "embed" + depends on EMBED_THEME + ---help--- + Specify the name of the theme to compile in. + Index: branches/azimutz/Cleancut/i386/config/zconf.hash.c =================================================================== --- branches/azimutz/Cleancut/i386/config/zconf.hash.c (revision 0) +++ branches/azimutz/Cleancut/i386/config/zconf.hash.c (revision 885) @@ -0,0 +1,245 @@ +/* ANSI-C code produced by gperf version 3.0.3 */ +/* Command-line: gperf */ +/* Computed positions: -k'1,3' */ + +#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ + && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \ + && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \ + && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \ + && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \ + && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \ + && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \ + && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \ + && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \ + && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \ + && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \ + && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \ + && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \ + && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \ + && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \ + && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \ + && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \ + && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \ + && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \ + && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \ + && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \ + && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \ + && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126)) +/* The character set is not based on ISO-646. */ +#error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@gnu.org>." +#endif + +struct kconf_id; + +static struct kconf_id *kconf_id_lookup(register const char *str, register unsigned int len); +/* maximum key range = 50, duplicates = 0 */ + +#ifdef __GNUC__ +__inline +#else +#ifdef __cplusplus +inline +#endif +#endif +static unsigned int +kconf_id_hash (register const char *str, register unsigned int len) +{ + static unsigned char asso_values[] = + { + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 40, 5, + 0, 0, 5, 52, 0, 20, 52, 52, 10, 20, + 5, 0, 35, 52, 0, 30, 0, 15, 0, 52, + 15, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52 + }; + register int hval = len; + + switch (hval) + { + default: + hval += asso_values[(unsigned char)str[2]]; + /*FALLTHROUGH*/ + case 2: + case 1: + hval += asso_values[(unsigned char)str[0]]; + break; + } + return hval; +} + +struct kconf_id_strings_t + { + char kconf_id_strings_str2[sizeof("on")]; + char kconf_id_strings_str3[sizeof("env")]; + char kconf_id_strings_str5[sizeof("endif")]; + char kconf_id_strings_str6[sizeof("option")]; + char kconf_id_strings_str7[sizeof("endmenu")]; + char kconf_id_strings_str8[sizeof("optional")]; + char kconf_id_strings_str9[sizeof("endchoice")]; + char kconf_id_strings_str10[sizeof("range")]; + char kconf_id_strings_str11[sizeof("choice")]; + char kconf_id_strings_str12[sizeof("default")]; + char kconf_id_strings_str13[sizeof("def_bool")]; + char kconf_id_strings_str14[sizeof("help")]; + char kconf_id_strings_str16[sizeof("config")]; + char kconf_id_strings_str17[sizeof("def_tristate")]; + char kconf_id_strings_str18[sizeof("hex")]; + char kconf_id_strings_str19[sizeof("defconfig_list")]; + char kconf_id_strings_str22[sizeof("if")]; + char kconf_id_strings_str23[sizeof("int")]; + char kconf_id_strings_str27[sizeof("modules")]; + char kconf_id_strings_str28[sizeof("tristate")]; + char kconf_id_strings_str29[sizeof("menu")]; + char kconf_id_strings_str32[sizeof("comment")]; + char kconf_id_strings_str35[sizeof("menuconfig")]; + char kconf_id_strings_str36[sizeof("string")]; + char kconf_id_strings_str37[sizeof("visible")]; + char kconf_id_strings_str41[sizeof("prompt")]; + char kconf_id_strings_str42[sizeof("depends")]; + char kconf_id_strings_str44[sizeof("bool")]; + char kconf_id_strings_str46[sizeof("select")]; + char kconf_id_strings_str47[sizeof("boolean")]; + char kconf_id_strings_str48[sizeof("mainmenu")]; + char kconf_id_strings_str51[sizeof("source")]; + }; +static struct kconf_id_strings_t kconf_id_strings_contents = + { + "on", + "env", + "endif", + "option", + "endmenu", + "optional", + "endchoice", + "range", + "choice", + "default", + "def_bool", + "help", + "config", + "def_tristate", + "hex", + "defconfig_list", + "if", + "int", + "modules", + "tristate", + "menu", + "comment", + "menuconfig", + "string", + "visible", + "prompt", + "depends", + "bool", + "select", + "boolean", + "mainmenu", + "source" + }; +#define kconf_id_strings ((const char *) &kconf_id_strings_contents) +#ifdef __GNUC__ +__inline +#ifdef __GNUC_STDC_INLINE__ +__attribute__ ((__gnu_inline__)) +#endif +#endif +struct kconf_id * +kconf_id_lookup (register const char *str, register unsigned int len) +{ + enum + { + TOTAL_KEYWORDS = 32, + MIN_WORD_LENGTH = 2, + MAX_WORD_LENGTH = 14, + MIN_HASH_VALUE = 2, + MAX_HASH_VALUE = 51 + }; + + static struct kconf_id wordlist[] = + { + {-1}, {-1}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str2, T_ON, TF_PARAM}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str3, T_OPT_ENV, TF_OPTION}, + {-1}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str5, T_ENDIF, TF_COMMAND}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str6, T_OPTION, TF_COMMAND}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str7, T_ENDMENU, TF_COMMAND}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str8, T_OPTIONAL, TF_COMMAND}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str9, T_ENDCHOICE, TF_COMMAND}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str10, T_RANGE, TF_COMMAND}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str11, T_CHOICE, TF_COMMAND}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str12, T_DEFAULT, TF_COMMAND, S_UNKNOWN}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str13, T_DEFAULT, TF_COMMAND, S_BOOLEAN}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str14, T_HELP, TF_COMMAND}, + {-1}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str16, T_CONFIG, TF_COMMAND}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str17, T_DEFAULT, TF_COMMAND, S_TRISTATE}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str18, T_TYPE, TF_COMMAND, S_HEX}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str19, T_OPT_DEFCONFIG_LIST,TF_OPTION}, + {-1}, {-1}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str22, T_IF, TF_COMMAND|TF_PARAM}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str23, T_TYPE, TF_COMMAND, S_INT}, + {-1}, {-1}, {-1}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str27, T_OPT_MODULES, TF_OPTION}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str28, T_TYPE, TF_COMMAND, S_TRISTATE}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str29, T_MENU, TF_COMMAND}, + {-1}, {-1}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str32, T_COMMENT, TF_COMMAND}, + {-1}, {-1}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str35, T_MENUCONFIG, TF_COMMAND}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str36, T_TYPE, TF_COMMAND, S_STRING}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str37, T_VISIBLE, TF_COMMAND}, + {-1}, {-1}, {-1}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str41, T_PROMPT, TF_COMMAND}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str42, T_DEPENDS, TF_COMMAND}, + {-1}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str44, T_TYPE, TF_COMMAND, S_BOOLEAN}, + {-1}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str46, T_SELECT, TF_COMMAND}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str47, T_TYPE, TF_COMMAND, S_BOOLEAN}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str48, T_MAINMENU, TF_COMMAND}, + {-1}, {-1}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str51, T_SOURCE, TF_COMMAND} + }; + + if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) + { + register int key = kconf_id_hash (str, len); + + if (key <= MAX_HASH_VALUE && key >= 0) + { + register int o = wordlist[key].name; + if (o >= 0) + { + register const char *s = o + kconf_id_strings; + + if (*str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0') + return &wordlist[key]; + } + } + } + return 0; +} + Index: branches/azimutz/Cleancut/i386/config/lkc_proto.h =================================================================== --- branches/azimutz/Cleancut/i386/config/lkc_proto.h (revision 0) +++ branches/azimutz/Cleancut/i386/config/lkc_proto.h (revision 885) @@ -0,0 +1,53 @@ +#include <stdarg.h> + +/* confdata.c */ +P(conf_parse,void,(const char *name)); +P(conf_read,int,(const char *name)); +P(conf_read_simple,int,(const char *name, int)); +P(conf_write_defconfig,int,(const char *name)); +P(conf_write,int,(const char *name)); +P(conf_write_autoconf,int,(void)); +P(conf_get_changed,bool,(void)); +P(conf_set_changed_callback, void,(void (*fn)(void))); +P(conf_set_message_callback, void,(void (*fn)(const char *fmt, va_list ap))); + +/* menu.c */ +P(rootmenu,struct menu,); + +P(menu_is_visible, bool, (struct menu *menu)); +P(menu_has_prompt, bool, (struct menu *menu)); +P(menu_get_prompt,const char *,(struct menu *menu)); +P(menu_get_root_menu,struct menu *,(struct menu *menu)); +P(menu_get_parent_menu,struct menu *,(struct menu *menu)); +P(menu_has_help,bool,(struct menu *menu)); +P(menu_get_help,const char *,(struct menu *menu)); +P(get_symbol_str, void, (struct gstr *r, struct symbol *sym)); +P(get_relations_str, struct gstr, (struct symbol **sym_arr)); +P(menu_get_ext_help,void,(struct menu *menu, struct gstr *help)); + +/* symbol.c */ +P(symbol_hash,struct symbol *,[SYMBOL_HASHSIZE]); + +P(sym_lookup,struct symbol *,(const char *name, int flags)); +P(sym_find,struct symbol *,(const char *name)); +P(sym_expand_string_value,const char *,(const char *in)); +P(sym_re_search,struct symbol **,(const char *pattern)); +P(sym_type_name,const char *,(enum symbol_type type)); +P(sym_calc_value,void,(struct symbol *sym)); +P(sym_get_type,enum symbol_type,(struct symbol *sym)); +P(sym_tristate_within_range,bool,(struct symbol *sym,tristate tri)); +P(sym_set_tristate_value,bool,(struct symbol *sym,tristate tri)); +P(sym_toggle_tristate_value,tristate,(struct symbol *sym)); +P(sym_string_valid,bool,(struct symbol *sym, const char *newval)); +P(sym_string_within_range,bool,(struct symbol *sym, const char *str)); +P(sym_set_string_value,bool,(struct symbol *sym, const char *newval)); +P(sym_is_changable,bool,(struct symbol *sym)); +P(sym_get_choice_prop,struct property *,(struct symbol *sym)); +P(sym_get_default_prop,struct property *,(struct symbol *sym)); +P(sym_get_string_value,const char *,(struct symbol *sym)); + +P(prop_get_type_name,const char *,(enum prop_type type)); + +/* expr.c */ +P(expr_compare_type,int,(enum expr_type t1, enum expr_type t2)); +P(expr_print,void,(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken)); Index: branches/azimutz/Cleancut/i386/config/dialog.h =================================================================== --- branches/azimutz/Cleancut/i386/config/dialog.h (revision 0) +++ branches/azimutz/Cleancut/i386/config/dialog.h (revision 885) @@ -0,0 +1,230 @@ +/* + * dialog.h -- common declarations for all dialog modules + * + * AUTHOR: Savio Lam (lam836@cs.cuhk.hk) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include <sys/types.h> +#include <fcntl.h> +#include <unistd.h> +#include <ctype.h> +#include <stdlib.h> +#include <string.h> +#include <stdbool.h> + +#ifndef KBUILD_NO_NLS +# include <libintl.h> +#else +# define gettext(Msgid) ((const char *) (Msgid)) +#endif + +#ifdef __sun__ +#define CURS_MACROS +#endif +#include CURSES_LOC + +/* + * Colors in ncurses 1.9.9e do not work properly since foreground and + * background colors are OR'd rather than separately masked. This version + * of dialog was hacked to work with ncurses 1.9.9e, making it incompatible + * with standard curses. The simplest fix (to make this work with standard + * curses) uses the wbkgdset() function, not used in the original hack. + * Turn it off if we're building with 1.9.9e, since it just confuses things. + */ +#if defined(NCURSES_VERSION) && defined(_NEED_WRAP) && !defined(GCC_PRINTFLIKE) +#define OLD_NCURSES 1 +#undef wbkgdset +#define wbkgdset(w,p) /*nothing */ +#else +#define OLD_NCURSES 0 +#endif + +#define TR(params) _tracef params + +#define KEY_ESC 27 +#define TAB 9 +#define MAX_LEN 2048 +#define BUF_SIZE (10*1024) +#define MIN(x,y) (x < y ? x : y) +#define MAX(x,y) (x > y ? x : y) + +#ifndef ACS_ULCORNER +#define ACS_ULCORNER '+' +#endif +#ifndef ACS_LLCORNER +#define ACS_LLCORNER '+' +#endif +#ifndef ACS_URCORNER +#define ACS_URCORNER '+' +#endif +#ifndef ACS_LRCORNER +#define ACS_LRCORNER '+' +#endif +#ifndef ACS_HLINE +#define ACS_HLINE '-' +#endif +#ifndef ACS_VLINE +#define ACS_VLINE '|' +#endif +#ifndef ACS_LTEE +#define ACS_LTEE '+' +#endif +#ifndef ACS_RTEE +#define ACS_RTEE '+' +#endif +#ifndef ACS_UARROW +#define ACS_UARROW '^' +#endif +#ifndef ACS_DARROW +#define ACS_DARROW 'v' +#endif + +/* error return codes */ +#define ERRDISPLAYTOOSMALL (KEY_MAX + 1) + +/* + * Color definitions + */ +struct dialog_color { + chtype atr; /* Color attribute */ + int fg; /* foreground */ + int bg; /* background */ + int hl; /* highlight this item */ +}; + +struct dialog_info { + const char *backtitle; + struct dialog_color screen; + struct dialog_color shadow; + struct dialog_color dialog; + struct dialog_color title; + struct dialog_color border; + struct dialog_color button_active; + struct dialog_color button_inactive; + struct dialog_color button_key_active; + struct dialog_color button_key_inactive; + struct dialog_color button_label_active; + struct dialog_color button_label_inactive; + struct dialog_color inputbox; + struct dialog_color inputbox_border; + struct dialog_color searchbox; + struct dialog_color searchbox_title; + struct dialog_color searchbox_border; + struct dialog_color position_indicator; + struct dialog_color menubox; + struct dialog_color menubox_border; + struct dialog_color item; + struct dialog_color item_selected; + struct dialog_color tag; + struct dialog_color tag_selected; + struct dialog_color tag_key; + struct dialog_color tag_key_selected; + struct dialog_color check; + struct dialog_color check_selected; + struct dialog_color uarrow; + struct dialog_color darrow; +}; + +/* + * Global variables + */ +extern struct dialog_info dlg; +extern char dialog_input_result[]; + +/* + * Function prototypes + */ + +/* item list as used by checklist and menubox */ +void item_reset(void); +void item_make(const char *fmt, ...); +void item_add_str(const char *fmt, ...); +void item_set_tag(char tag); +void item_set_data(void *p); +void item_set_selected(int val); +int item_activate_selected(void); +void *item_data(void); +char item_tag(void); + +/* item list manipulation for lxdialog use */ +#define MAXITEMSTR 200 +struct dialog_item { + char str[MAXITEMSTR]; /* promtp displayed */ + char tag; + void *data; /* pointer to menu item - used by menubox+checklist */ + int selected; /* Set to 1 by dialog_*() function if selected. */ +}; + +/* list of lialog_items */ +struct dialog_list { + struct dialog_item node; + struct dialog_list *next; +}; + +extern struct dialog_list *item_cur; +extern struct dialog_list item_nil; +extern struct dialog_list *item_head; + +int item_count(void); +void item_set(int n); +int item_n(void); +const char *item_str(void); +int item_is_selected(void); +int item_is_tag(char tag); +#define item_foreach() \ + for (item_cur = item_head ? item_head: item_cur; \ + item_cur && (item_cur != &item_nil); item_cur = item_cur->next) + +/* generic key handlers */ +int on_key_esc(WINDOW *win); +int on_key_resize(void); + +int init_dialog(const char *backtitle); +void set_dialog_backtitle(const char *backtitle); +void end_dialog(int x, int y); +void attr_clear(WINDOW * win, int height, int width, chtype attr); +void dialog_clear(void); +void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x); +void print_button(WINDOW * win, const char *label, int y, int x, int selected); +void print_title(WINDOW *dialog, const char *title, int width); +void draw_box(WINDOW * win, int y, int x, int height, int width, chtype box, + chtype border); +void draw_shadow(WINDOW * win, int y, int x, int height, int width); + +int first_alpha(const char *string, const char *exempt); +int dialog_yesno(const char *title, const char *prompt, int height, int width); +int dialog_msgbox(const char *title, const char *prompt, int height, + int width, int pause); +int dialog_textbox(const char *title, const char *file, int height, int width); +int dialog_menu(const char *title, const char *prompt, + const void *selected, int *s_scroll); +int dialog_checklist(const char *title, const char *prompt, int height, + int width, int list_height); +extern char dialog_input_result[]; +int dialog_inputbox(const char *title, const char *prompt, int height, + int width, const char *init); + +/* + * This is the base for fictitious keys, which activate + * the buttons. + * + * Mouse-generated keys are the following: + * -- the first 32 are used as numbers, in addition to '0'-'9' + * -- the lowercase are used to signal mouse-enter events (M_EVENT + 'o') + * -- uppercase chars are used to invoke the button (M_EVENT + 'O') + */ +#define M_EVENT (KEY_MAX+1) Index: branches/azimutz/Cleancut/i386/config/menu.c =================================================================== --- branches/azimutz/Cleancut/i386/config/menu.c (revision 0) +++ branches/azimutz/Cleancut/i386/config/menu.c (revision 885) @@ -0,0 +1,608 @@ +/* + * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> + * Released under the terms of the GNU GPL v2.0. + */ +#include <stdlib.h> +#include <string.h> + +#define LKC_DIRECT_LINK +#include "lkc.h" + +static const char nohelp_text[] = N_( + "There is no help available for this option.\n"); + +struct menu rootmenu; +static struct menu **last_entry_ptr; + +struct file *file_list; +struct file *current_file; + +void menu_warn(struct menu *menu, const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + fprintf(stderr, "%s:%d:warning: ", menu->file->name, menu->lineno); + vfprintf(stderr, fmt, ap); + fprintf(stderr, "\n"); + va_end(ap); +} + +static void prop_warn(struct property *prop, const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + fprintf(stderr, "%s:%d:warning: ", prop->file->name, prop->lineno); + vfprintf(stderr, fmt, ap); + fprintf(stderr, "\n"); + va_end(ap); +} + +void _menu_init(void) +{ + current_entry = current_menu = &rootmenu; + last_entry_ptr = &rootmenu.list; +} + +void menu_add_entry(struct symbol *sym) +{ + struct menu *menu; + + menu = malloc(sizeof(*menu)); + memset(menu, 0, sizeof(*menu)); + menu->sym = sym; + menu->parent = current_menu; + menu->file = current_file; + menu->lineno = zconf_lineno(); + + *last_entry_ptr = menu; + last_entry_ptr = &menu->next; + current_entry = menu; + if (sym) + menu_add_symbol(P_SYMBOL, sym, NULL); +} + +void menu_end_entry(void) +{ +} + +struct menu *menu_add_menu(void) +{ + menu_end_entry(); + last_entry_ptr = ¤t_entry->list; + return current_menu = current_entry; +} + +void menu_end_menu(void) +{ + last_entry_ptr = ¤t_menu->next; + current_menu = current_menu->parent; +} + +static struct expr *menu_check_dep(struct expr *e) +{ + if (!e) + return e; + + switch (e->type) { + case E_NOT: + e->left.expr = menu_check_dep(e->left.expr); + break; + case E_OR: + case E_AND: + e->left.expr = menu_check_dep(e->left.expr); + e->right.expr = menu_check_dep(e->right.expr); + break; + case E_SYMBOL: + /* change 'm' into 'm' && MODULES */ + if (e->left.sym == &symbol_mod) + return expr_alloc_and(e, expr_alloc_symbol(modules_sym)); + break; + default: + break; + } + return e; +} + +void menu_add_dep(struct expr *dep) +{ + current_entry->dep = expr_alloc_and(current_entry->dep, menu_check_dep(dep)); +} + +void menu_set_type(int type) +{ + struct symbol *sym = current_entry->sym; + + if (sym->type == type) + return; + if (sym->type == S_UNKNOWN) { + sym->type = type; + return; + } + menu_warn(current_entry, "type of '%s' redefined from '%s' to '%s'", + sym->name ? sym->name : "<choice>", + sym_type_name(sym->type), sym_type_name(type)); +} + +struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *expr, struct expr *dep) +{ + struct property *prop = prop_alloc(type, current_entry->sym); + + prop->menu = current_entry; + prop->expr = expr; + prop->visible.expr = menu_check_dep(dep); + + if (prompt) { + if (isspace(*prompt)) { + prop_warn(prop, "leading whitespace ignored"); + while (isspace(*prompt)) + prompt++; + } + if (current_entry->prompt && current_entry != &rootmenu) + prop_warn(prop, "prompt redefined"); + + /* Apply all upper menus' visibilities to actual prompts. */ + if(type == P_PROMPT) { + struct menu *menu = current_entry; + + while ((menu = menu->parent) != NULL) { + if (!menu->visibility) + continue; + prop->visible.expr + = expr_alloc_and(prop->visible.expr, + menu->visibility); + } + } + + current_entry->prompt = prop; + } + prop->text = prompt; + + return prop; +} + +struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep) +{ + return menu_add_prop(type, prompt, NULL, dep); +} + +void menu_add_visibility(struct expr *expr) +{ + current_entry->visibility = expr_alloc_and(current_entry->visibility, + expr); +} + +void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep) +{ + menu_add_prop(type, NULL, expr, dep); +} + +void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep) +{ + menu_add_prop(type, NULL, expr_alloc_symbol(sym), dep); +} + +void menu_add_option(int token, char *arg) +{ + struct property *prop; + + switch (token) { + case T_OPT_MODULES: + prop = prop_alloc(P_DEFAULT, modules_sym); + prop->expr = expr_alloc_symbol(current_entry->sym); + break; + case T_OPT_DEFCONFIG_LIST: + if (!sym_defconfig_list) + sym_defconfig_list = current_entry->sym; + else if (sym_defconfig_list != current_entry->sym) + zconf_error("trying to redefine defconfig symbol"); + break; + case T_OPT_ENV: + //prop_add_env(arg); + break; + } +} + +static int menu_validate_number(struct symbol *sym, struct symbol *sym2) +{ + return sym2->type == S_INT || sym2->type == S_HEX || + (sym2->type == S_UNKNOWN && sym_string_valid(sym, sym2->name)); +} + +static void sym_check_prop(struct symbol *sym) +{ + struct property *prop; + struct symbol *sym2; + for (prop = sym->prop; prop; prop = prop->next) { + switch (prop->type) { + case P_DEFAULT: + if ((sym->type == S_STRING || sym->type == S_INT || sym->type == S_HEX) && + prop->expr->type != E_SYMBOL) + prop_warn(prop, + "default for config symbol '%s'" + " must be a single symbol", sym->name); + if (prop->expr->type != E_SYMBOL) + break; + sym2 = prop_get_symbol(prop); + if (sym->type == S_HEX || sym->type == S_INT) { + if (!menu_validate_number(sym, sym2)) + prop_warn(prop, + "'%s': number is invalid", + sym->name); + } + break; + case P_SELECT: + sym2 = prop_get_symbol(prop); + if (sym->type != S_BOOLEAN && sym->type != S_TRISTATE) + prop_warn(prop, + "config symbol '%s' uses select, but is " + "not boolean or tristate", sym->name); + else if (sym2->type != S_UNKNOWN && + sym2->type != S_BOOLEAN && + sym2->type != S_TRISTATE) + prop_warn(prop, + "'%s' has wrong type. 'select' only " + "accept arguments of boolean and " + "tristate type", sym2->name); + break; + case P_RANGE: + if (sym->type != S_INT && sym->type != S_HEX) + prop_warn(prop, "range is only allowed " + "for int or hex symbols"); + if (!menu_validate_number(sym, prop->expr->left.sym) || + !menu_validate_number(sym, prop->expr->right.sym)) + prop_warn(prop, "range is invalid"); + break; + default: + ; + } + } +} + +void menu_finalize(struct menu *parent) +{ + struct menu *menu, *last_menu; + struct symbol *sym; + struct property *prop; + struct expr *parentdep, *basedep, *dep, *dep2, **ep; + + sym = parent->sym; + if (parent->list) { + if (sym && sym_is_choice(sym)) { + if (sym->type == S_UNKNOWN) { + /* find the first choice value to find out choice type */ + current_entry = parent; + for (menu = parent->list; menu; menu = menu->next) { + if (menu->sym && menu->sym->type != S_UNKNOWN) { + menu_set_type(menu->sym->type); + break; + } + } + } + /* set the type of the remaining choice values */ + for (menu = parent->list; menu; menu = menu->next) { + current_entry = menu; + if (menu->sym && menu->sym->type == S_UNKNOWN) + menu_set_type(sym->type); + } + parentdep = expr_alloc_symbol(sym); + } else if (parent->prompt) + parentdep = parent->prompt->visible.expr; + else + parentdep = parent->dep; + + for (menu = parent->list; menu; menu = menu->next) { + basedep = expr_transform(menu->dep); + basedep = expr_alloc_and(expr_copy(parentdep), basedep); + basedep = expr_eliminate_dups(basedep); + menu->dep = basedep; + if (menu->sym) + prop = menu->sym->prop; + else + prop = menu->prompt; + for (; prop; prop = prop->next) { + if (prop->menu != menu) + continue; + dep = expr_transform(prop->visible.expr); + dep = expr_alloc_and(expr_copy(basedep), dep); + dep = expr_eliminate_dups(dep); + if (menu->sym && menu->sym->type != S_TRISTATE) + dep = expr_trans_bool(dep); + prop->visible.expr = dep; + if (prop->type == P_SELECT) { + struct symbol *es = prop_get_symbol(prop); + es->rev_dep.expr = expr_alloc_or(es->rev_dep.expr, + expr_alloc_and(expr_alloc_symbol(menu->sym), expr_copy(dep))); + } + } + } + for (menu = parent->list; menu; menu = menu->next) + menu_finalize(menu); + } else if (sym) { + basedep = parent->prompt ? parent->prompt->visible.expr : NULL; + basedep = expr_trans_compare(basedep, E_UNEQUAL, &symbol_no); + basedep = expr_eliminate_dups(expr_transform(basedep)); + last_menu = NULL; + for (menu = parent->next; menu; menu = menu->next) { + dep = menu->prompt ? menu->prompt->visible.expr : menu->dep; + if (!expr_contains_symbol(dep, sym)) + break; + if (expr_depends_symbol(dep, sym)) + goto next; + dep = expr_trans_compare(dep, E_UNEQUAL, &symbol_no); + dep = expr_eliminate_dups(expr_transform(dep)); + dep2 = expr_copy(basedep); + expr_eliminate_eq(&dep, &dep2); + expr_free(dep); + if (!expr_is_yes(dep2)) { + expr_free(dep2); + break; + } + expr_free(dep2); + next: + menu_finalize(menu); + menu->parent = parent; + last_menu = menu; + } + if (last_menu) { + parent->list = parent->next; + parent->next = last_menu->next; + last_menu->next = NULL; + } + + sym->dir_dep.expr = parent->dep; + } + for (menu = parent->list; menu; menu = menu->next) { + if (sym && sym_is_choice(sym) && + menu->sym && !sym_is_choice_value(menu->sym)) { + current_entry = menu; + menu->sym->flags |= SYMBOL_CHOICEVAL; + if (!menu->prompt) + menu_warn(menu, "choice value must have a prompt"); + for (prop = menu->sym->prop; prop; prop = prop->next) { + if (prop->type == P_DEFAULT) + prop_warn(prop, "defaults for choice " + "values not supported"); + if (prop->menu == menu) + continue; + if (prop->type == P_PROMPT && + prop->menu->parent->sym != sym) + prop_warn(prop, "choice value used outside its choice group"); + } + /* Non-tristate choice values of tristate choices must + * depend on the choice being set to Y. The choice + * values' dependencies were propagated to their + * properties above, so the change here must be re- + * propagated. + */ + if (sym->type == S_TRISTATE && menu->sym->type != S_TRISTATE) { + basedep = expr_alloc_comp(E_EQUAL, sym, &symbol_yes); + menu->dep = expr_alloc_and(basedep, menu->dep); + for (prop = menu->sym->prop; prop; prop = prop->next) { + if (prop->menu != menu) + continue; + prop->visible.expr = expr_alloc_and(expr_copy(basedep), + prop->visible.expr); + } + } + menu_add_symbol(P_CHOICE, sym, NULL); + prop = sym_get_choice_prop(sym); + for (ep = &prop->expr; *ep; ep = &(*ep)->left.expr) + ; + *ep = expr_alloc_one(E_LIST, NULL); + (*ep)->right.sym = menu->sym; + } + if (menu->list && (!menu->prompt || !menu->prompt->text)) { + for (last_menu = menu->list; ; last_menu = last_menu->next) { + last_menu->parent = parent; + if (!last_menu->next) + break; + } + last_menu->next = menu->next; + menu->next = menu->list; + menu->list = NULL; + } + } + + if (sym && !(sym->flags & SYMBOL_WARNED)) { + if (sym->type == S_UNKNOWN) + menu_warn(parent, "config symbol defined without type"); + + if (sym_is_choice(sym) && !parent->prompt) + menu_warn(parent, "choice must have a prompt"); + + /* Check properties connected to this symbol */ + sym_check_prop(sym); + sym->flags |= SYMBOL_WARNED; + } + + if (sym && !sym_is_optional(sym) && parent->prompt) { + sym->rev_dep.expr = expr_alloc_or(sym->rev_dep.expr, + expr_alloc_and(parent->prompt->visible.expr, + expr_alloc_symbol(&symbol_mod))); + } +} + +bool menu_has_prompt(struct menu *menu) +{ + if (!menu->prompt) + return false; + return true; +} + +bool menu_is_visible(struct menu *menu) +{ + struct menu *child; + struct symbol *sym; + tristate visible; + + if (!menu->prompt) + return false; + + if (menu->visibility) { + if (expr_calc_value(menu->visibility) == no) + return no; + } + + sym = menu->sym; + if (sym) { + sym_calc_value(sym); + visible = menu->prompt->visible.tri; + } else + visible = menu->prompt->visible.tri = expr_calc_value(menu->prompt->visible.expr); + + if (visible != no) + return true; + + if (!sym || sym_get_tristate_value(menu->sym) == no) + return false; + + for (child = menu->list; child; child = child->next) { + if (menu_is_visible(child)) { + if (sym) + sym->flags |= SYMBOL_DEF_USER; + return true; + } + } + + return false; +} + +const char *menu_get_prompt(struct menu *menu) +{ + if (menu->prompt) + return menu->prompt->text; + else if (menu->sym) + return menu->sym->name; + return NULL; +} + +struct menu *menu_get_root_menu(struct menu *menu) +{ + return &rootmenu; +} + +struct menu *menu_get_parent_menu(struct menu *menu) +{ + enum prop_type type; + + for (; menu != &rootmenu; menu = menu->parent) { + type = menu->prompt ? menu->prompt->type : 0; + if (type == P_MENU) + break; + } + return menu; +} + +bool menu_has_help(struct menu *menu) +{ + return menu->help != NULL; +} + +const char *menu_get_help(struct menu *menu) +{ + if (menu->help) + return menu->help; + else + return ""; +} + +static void get_prompt_str(struct gstr *r, struct property *prop) +{ + int i, j; + struct menu *submenu[8], *menu; + + str_printf(r, _("Prompt: %s\n"), _(prop->text)); + str_printf(r, _(" Defined at %s:%d\n"), prop->menu->file->name, + prop->menu->lineno); + if (!expr_is_yes(prop->visible.expr)) { + str_append(r, _(" Depends on: ")); + expr_gstr_print(prop->visible.expr, r); + str_append(r, "\n"); + } + menu = prop->menu->parent; + for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent) + submenu[i++] = menu; + if (i > 0) { + str_printf(r, _(" Location:\n")); + for (j = 4; --i >= 0; j += 2) { + menu = submenu[i]; + str_printf(r, "%*c-> %s", j, ' ', _(menu_get_prompt(menu))); + if (menu->sym) { + str_printf(r, " (%s [=%s])", menu->sym->name ? + menu->sym->name : _("<choice>"), + sym_get_string_value(menu->sym)); + } + str_append(r, "\n"); + } + } +} + +void get_symbol_str(struct gstr *r, struct symbol *sym) +{ + bool hit; + struct property *prop; + + if (sym && sym->name) { + str_printf(r, "Symbol: %s [=%s]\n", sym->name, + sym_get_string_value(sym)); + str_printf(r, "Type : %s\n", sym_type_name(sym->type)); + if (sym->type == S_INT || sym->type == S_HEX) { + prop = sym_get_range_prop(sym); + if (prop) { + str_printf(r, "Range : "); + expr_gstr_print(prop->expr, r); + str_append(r, "\n"); + } + } + } + for_all_prompts(sym, prop) + get_prompt_str(r, prop); + hit = false; + for_all_properties(sym, prop, P_SELECT) { + if (!hit) { + str_append(r, " Selects: "); + hit = true; + } else + str_printf(r, " && "); + expr_gstr_print(prop->expr, r); + } + if (hit) + str_append(r, "\n"); + if (sym->rev_dep.expr) { + str_append(r, _(" Selected by: ")); + expr_gstr_print(sym->rev_dep.expr, r); + str_append(r, "\n"); + } + str_append(r, "\n\n"); +} + +struct gstr get_relations_str(struct symbol **sym_arr) +{ + struct symbol *sym; + struct gstr res = str_new(); + int i; + + for (i = 0; sym_arr && (sym = sym_arr[i]); i++) + get_symbol_str(&res, sym); + if (!i) + str_append(&res, _("No matches found.\n")); + return res; +} + + +void menu_get_ext_help(struct menu *menu, struct gstr *help) +{ + struct symbol *sym = menu->sym; + + if (menu_has_help(menu)) { + if (sym->name) { + str_printf(help, "%s%s:\n\n", CONFIG_, sym->name); + str_append(help, _(menu_get_help(menu))); + str_append(help, "\n"); + } + } else { + str_append(help, nohelp_text); + } + if (sym) + get_symbol_str(help, sym); +} Index: branches/azimutz/Cleancut/i386/config/symbol.c =================================================================== --- branches/azimutz/Cleancut/i386/config/symbol.c (revision 0) +++ branches/azimutz/Cleancut/i386/config/symbol.c (revision 885) @@ -0,0 +1,1231 @@ +/* + * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> + * Released under the terms of the GNU GPL v2.0. + */ + +#include <ctype.h> +#include <stdlib.h> +#include <string.h> +#include <regex.h> +#include <sys/utsname.h> + +#define LKC_DIRECT_LINK +#include "lkc.h" + +struct symbol symbol_yes = { + .name = "y", + .curr = { "y", yes }, + .flags = SYMBOL_CONST|SYMBOL_VALID, +}, symbol_mod = { + .name = "m", + .curr = { "m", mod }, + .flags = SYMBOL_CONST|SYMBOL_VALID, +}, symbol_no = { + .name = "n", + .curr = { "n", no }, + .flags = SYMBOL_CONST|SYMBOL_VALID, +}, symbol_empty = { + .name = "", + .curr = { "", no }, + .flags = SYMBOL_VALID, +}; + +struct symbol *sym_defconfig_list; +struct symbol *modules_sym; +tristate modules_val; + +struct expr *sym_env_list; + +static void sym_add_default(struct symbol *sym, const char *def) +{ + struct property *prop = prop_alloc(P_DEFAULT, sym); + + prop->expr = expr_alloc_symbol(sym_lookup(def, SYMBOL_CONST)); +} + +void sym_init(void) +{ + struct symbol *sym; + struct utsname uts; + static bool inited = false; + + if (inited) + return; + inited = true; + + uname(&uts); + + sym = sym_lookup("UNAME_RELEASE", 0); + sym->type = S_STRING; + sym->flags |= SYMBOL_AUTO; + sym_add_default(sym, uts.release); +} + +enum symbol_type sym_get_type(struct symbol *sym) +{ + enum symbol_type type = sym->type; + + if (type == S_TRISTATE) { + if (sym_is_choice_value(sym) && sym->visible == yes) + type = S_BOOLEAN; + else if (modules_val == no) + type = S_BOOLEAN; + } + return type; +} + +const char *sym_type_name(enum symbol_type type) +{ + switch (type) { + case S_BOOLEAN: + return "boolean"; + case S_TRISTATE: + return "tristate"; + case S_INT: + return "integer"; + case S_HEX: + return "hex"; + case S_STRING: + return "string"; + case S_UNKNOWN: + return "unknown"; + case S_OTHER: + break; + } + return "???"; +} + +struct property *sym_get_choice_prop(struct symbol *sym) +{ + struct property *prop; + + for_all_choices(sym, prop) + return prop; + return NULL; +} + +struct property *sym_get_env_prop(struct symbol *sym) +{ + struct property *prop; + + for_all_properties(sym, prop, P_ENV) + return prop; + return NULL; +} + +struct property *sym_get_default_prop(struct symbol *sym) +{ + struct property *prop; + + for_all_defaults(sym, prop) { + prop->visible.tri = expr_calc_value(prop->visible.expr); + if (prop->visible.tri != no) + return prop; + } + return NULL; +} + +static struct property *sym_get_range_prop(struct symbol *sym) +{ + struct property *prop; + + for_all_properties(sym, prop, P_RANGE) { + prop->visible.tri = expr_calc_value(prop->visible.expr); + if (prop->visible.tri != no) + return prop; + } + return NULL; +} + +static int sym_get_range_val(struct symbol *sym, int base) +{ + sym_calc_value(sym); + switch (sym->type) { + case S_INT: + base = 10; + break; + case S_HEX: + base = 16; + break; + default: + break; + } + return strtol(sym->curr.val, NULL, base); +} + +static void sym_validate_range(struct symbol *sym) +{ + struct property *prop; + int base, val, val2; + char str[64]; + + switch (sym->type) { + case S_INT: + base = 10; + break; + case S_HEX: + base = 16; + break; + default: + return; + } + prop = sym_get_range_prop(sym); + if (!prop) + return; + val = strtol(sym->curr.val, NULL, base); + val2 = sym_get_range_val(prop->expr->left.sym, base); + if (val >= val2) { + val2 = sym_get_range_val(prop->expr->right.sym, base); + if (val <= val2) + return; + } + if (sym->type == S_INT) + sprintf(str, "%d", val2); + else + sprintf(str, "0x%x", val2); + sym->curr.val = strdup(str); +} + +static void sym_calc_visibility(struct symbol *sym) +{ + struct property *prop; + tristate tri; + + /* any prompt visible? */ + tri = no; + for_all_prompts(sym, prop) { + prop->visible.tri = expr_calc_value(prop->visible.expr); + tri = EXPR_OR(tri, prop->visible.tri); + } + if (tri == mod && (sym->type != S_TRISTATE || modules_val == no)) + tri = yes; + if (sym->visible != tri) { + sym->visible = tri; + sym_set_changed(sym); + } + if (sym_is_choice_value(sym)) + return; + /* defaulting to "yes" if no explicit "depends on" are given */ + tri = yes; + if (sym->dir_dep.expr) + tri = expr_calc_value(sym->dir_dep.expr); + if (tri == mod) + tri = yes; + if (sym->dir_dep.tri != tri) { + sym->dir_dep.tri = tri; + sym_set_changed(sym); + } + tri = no; + if (sym->rev_dep.expr) + tri = expr_calc_value(sym->rev_dep.expr); + if (tri == mod && sym_get_type(sym) == S_BOOLEAN) + tri = yes; + if (sym->rev_dep.tri != tri) { + sym->rev_dep.tri = tri; + sym_set_changed(sym); + } +} + +/* + * Find the default symbol for a choice. + * First try the default values for the choice symbol + * Next locate the first visible choice value + * Return NULL if none was found + */ +struct symbol *sym_choice_default(struct symbol *sym) +{ + struct symbol *def_sym; + struct property *prop; + struct expr *e; + + /* any of the defaults visible? */ + for_all_defaults(sym, prop) { + prop->visible.tri = expr_calc_value(prop->visible.expr); + if (prop->visible.tri == no) + continue; + def_sym = prop_get_symbol(prop); + if (def_sym->visible != no) + return def_sym; + } + + /* just get the first visible value */ + prop = sym_get_choice_prop(sym); + expr_list_for_each_sym(prop->expr, e, def_sym) + if (def_sym->visible != no) + return def_sym; + + /* failed to locate any defaults */ + return NULL; +} + +static struct symbol *sym_calc_choice(struct symbol *sym) +{ + struct symbol *def_sym; + struct property *prop; + struct expr *e; + + /* first calculate all choice values' visibilities */ + prop = sym_get_choice_prop(sym); + expr_list_for_each_sym(prop->expr, e, def_sym) + sym_calc_visibility(def_sym); + + /* is the user choice visible? */ + def_sym = sym->def[S_DEF_USER].val; + if (def_sym && def_sym->visible != no) + return def_sym; + + def_sym = sym_choice_default(sym); + + if (def_sym == NULL) + /* no choice? reset tristate value */ + sym->curr.tri = no; + + return def_sym; +} + +void sym_calc_value(struct symbol *sym) +{ + struct symbol_value newval, oldval; + struct property *prop; + struct expr *e; + + if (!sym) + return; + + if (sym->flags & SYMBOL_VALID) + return; + sym->flags |= SYMBOL_VALID; + + oldval = sym->curr; + + switch (sym->type) { + case S_INT: + case S_HEX: + case S_STRING: + newval = symbol_empty.curr; + break; + case S_BOOLEAN: + case S_TRISTATE: + newval = symbol_no.curr; + break; + default: + sym->curr.val = sym->name; + sym->curr.tri = no; + return; + } + if (!sym_is_choice_value(sym)) + sym->flags &= ~SYMBOL_WRITE; + + sym_calc_visibility(sym); + + /* set default if recursively called */ + sym->curr = newval; + + switch (sym_get_type(sym)) { + case S_BOOLEAN: + case S_TRISTATE: + if (sym_is_choice_value(sym) && sym->visible == yes) { + prop = sym_get_choice_prop(sym); + newval.tri = (prop_get_symbol(prop)->curr.val == sym) ? yes : no; + } else { + if (sym->visible != no) { + /* if the symbol is visible use the user value + * if available, otherwise try the default value + */ + sym->flags |= SYMBOL_WRITE; + if (sym_has_value(sym)) { + newval.tri = EXPR_AND(sym->def[S_DEF_USER].tri, + sym->visible); + goto calc_newval; + } + } + if (sym->rev_dep.tri != no) + sym->flags |= SYMBOL_WRITE; + if (!sym_is_choice(sym)) { + prop = sym_get_default_prop(sym); + if (prop) { + sym->flags |= SYMBOL_WRITE; + newval.tri = EXPR_AND(expr_calc_value(prop->expr), + prop->visible.tri); + } + } + calc_newval: + if (sym->dir_dep.tri == no && sym->rev_dep.tri != no) { + struct expr *e; + e = expr_simplify_unmet_dep(sym->rev_dep.expr, + sym->dir_dep.expr); + fprintf(stderr, "warning: ("); + expr_fprint(e, stderr); + fprintf(stderr, ") selects %s which has unmet direct dependencies (", + sym->name); + expr_fprint(sym->dir_dep.expr, stderr); + fprintf(stderr, ")\n"); + expr_free(e); + } + newval.tri = EXPR_OR(newval.tri, sym->rev_dep.tri); + } + if (newval.tri == mod && sym_get_type(sym) == S_BOOLEAN) + newval.tri = yes; + break; + case S_STRING: + case S_HEX: + case S_INT: + if (sym->visible != no) { + sym->flags |= SYMBOL_WRITE; + if (sym_has_value(sym)) { + newval.val = sym->def[S_DEF_USER].val; + break; + } + } + prop = sym_get_default_prop(sym); + if (prop) { + struct symbol *ds = prop_get_symbol(prop); + if (ds) { + sym->flags |= SYMBOL_WRITE; + sym_calc_value(ds); + newval.val = ds->curr.val; + } + } + break; + default: + ; + } + + sym->curr = newval; + if (sym_is_choice(sym) && newval.tri == yes) + sym->curr.val = sym_calc_choice(sym); + sym_validate_range(sym); + + if (memcmp(&oldval, &sym->curr, sizeof(oldval))) { + sym_set_changed(sym); + if (modules_sym == sym) { + sym_set_all_changed(); + modules_val = modules_sym->curr.tri; + } + } + + if (sym_is_choice(sym)) { + struct symbol *choice_sym; + + prop = sym_get_choice_prop(sym); + expr_list_for_each_sym(prop->expr, e, choice_sym) { + if ((sym->flags & SYMBOL_WRITE) && + choice_sym->visible != no) + choice_sym->flags |= SYMBOL_WRITE; + if (sym->flags & SYMBOL_CHANGED) + sym_set_changed(choice_sym); + } + } + + if (sym->flags & SYMBOL_AUTO) + sym->flags &= ~SYMBOL_WRITE; +} + +void sym_clear_all_valid(void) +{ + struct symbol *sym; + int i; + + for_all_symbols(i, sym) + sym->flags &= ~SYMBOL_VALID; + sym_add_change_count(1); + if (modules_sym) + sym_calc_value(modules_sym); +} + +void sym_set_changed(struct symbol *sym) +{ + struct property *prop; + + sym->flags |= SYMBOL_CHANGED; + for (prop = sym->prop; prop; prop = prop->next) { + if (prop->menu) + prop->menu->flags |= MENU_CHANGED; + } +} + +void sym_set_all_changed(void) +{ + struct symbol *sym; + int i; + + for_all_symbols(i, sym) + sym_set_changed(sym); +} + +bool sym_tristate_within_range(struct symbol *sym, tristate val) +{ + int type = sym_get_type(sym); + + if (sym->visible == no) + return false; + + if (type != S_BOOLEAN && type != S_TRISTATE) + return false; + + if (type == S_BOOLEAN && val == mod) + return false; + if (sym->visible <= sym->rev_dep.tri) + return false; + if (sym_is_choice_value(sym) && sym->visible == yes) + return val == yes; + return val >= sym->rev_dep.tri && val <= sym->visible; +} + +bool sym_set_tristate_value(struct symbol *sym, tristate val) +{ + tristate oldval = sym_get_tristate_value(sym); + + if (oldval != val && !sym_tristate_within_range(sym, val)) + return false; + + if (!(sym->flags & SYMBOL_DEF_USER)) { + sym->flags |= SYMBOL_DEF_USER; + sym_set_changed(sym); + } + /* + * setting a choice value also resets the new flag of the choice + * symbol and all other choice values. + */ + if (sym_is_choice_value(sym) && val == yes) { + struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym)); + struct property *prop; + struct expr *e; + + cs->def[S_DEF_USER].val = sym; + cs->flags |= SYMBOL_DEF_USER; + prop = sym_get_choice_prop(cs); + for (e = prop->expr; e; e = e->left.expr) { + if (e->right.sym->visible != no) + e->right.sym->flags |= SYMBOL_DEF_USER; + } + } + + sym->def[S_DEF_USER].tri = val; + if (oldval != val) + sym_clear_all_valid(); + + return true; +} + +tristate sym_toggle_tristate_value(struct symbol *sym) +{ + tristate oldval, newval; + + oldval = newval = sym_get_tristate_value(sym); + do { + switch (newval) { + case no: + newval = mod; + break; + case mod: + newval = yes; + break; + case yes: + newval = no; + break; + } + if (sym_set_tristate_value(sym, newval)) + break; + } while (oldval != newval); + return newval; +} + +bool sym_string_valid(struct symbol *sym, const char *str) +{ + signed char ch; + + switch (sym->type) { + case S_STRING: + return true; + case S_INT: + ch = *str++; + if (ch == '-') + ch = *str++; + if (!isdigit(ch)) + return false; + if (ch == '0' && *str != 0) + return false; + while ((ch = *str++)) { + if (!isdigit(ch)) + return false; + } + return true; + case S_HEX: + if (str[0] == '0' && (str[1] == 'x' || str[1] == 'X')) + str += 2; + ch = *str++; + do { + if (!isxdigit(ch)) + return false; + } while ((ch = *str++)); + return true; + case S_BOOLEAN: + case S_TRISTATE: + switch (str[0]) { + case 'y': case 'Y': + case 'm': case 'M': + case 'n': case 'N': + return true; + } + return false; + default: + return false; + } +} + +bool sym_string_within_range(struct symbol *sym, const char *str) +{ + struct property *prop; + int val; + + switch (sym->type) { + case S_STRING: + return sym_string_valid(sym, str); + case S_INT: + if (!sym_string_valid(sym, str)) + return false; + prop = sym_get_range_prop(sym); + if (!prop) + return true; + val = strtol(str, NULL, 10); + return val >= sym_get_range_val(prop->expr->left.sym, 10) && + val <= sym_get_range_val(prop->expr->right.sym, 10); + case S_HEX: + if (!sym_string_valid(sym, str)) + return false; + prop = sym_get_range_prop(sym); + if (!prop) + return true; + val = strtol(str, NULL, 16); + return val >= sym_get_range_val(prop->expr->left.sym, 16) && + val <= sym_get_range_val(prop->expr->right.sym, 16); + case S_BOOLEAN: + case S_TRISTATE: + switch (str[0]) { + case 'y': case 'Y': + return sym_tristate_within_range(sym, yes); + case 'm': case 'M': + return sym_tristate_within_range(sym, mod); + case 'n': case 'N': + return sym_tristate_within_range(sym, no); + } + return false; + default: + return false; + } +} + +bool sym_set_string_value(struct symbol *sym, const char *newval) +{ + const char *oldval; + char *val; + int size; + + switch (sym->type) { + case S_BOOLEAN: + case S_TRISTATE: + switch (newval[0]) { + case 'y': case 'Y': + return sym_set_tristate_value(sym, yes); + case 'm': case 'M': + return sym_set_tristate_value(sym, mod); + case 'n': case 'N': + return sym_set_tristate_value(sym, no); + } + return false; + default: + ; + } + + if (!sym_string_within_range(sym, newval)) + return false; + + if (!(sym->flags & SYMBOL_DEF_USER)) { + sym->flags |= SYMBOL_DEF_USER; + sym_set_changed(sym); + } + + oldval = sym->def[S_DEF_USER].val; + size = strlen(newval) + 1; + if (sym->type == S_HEX && (newval[0] != '0' || (newval[1] != 'x' && newval[1] != 'X'))) { + size += 2; + sym->def[S_DEF_USER].val = val = malloc(size); + *val++ = '0'; + *val++ = 'x'; + } else if (!oldval || strcmp(oldval, newval)) + sym->def[S_DEF_USER].val = val = malloc(size); + else + return true; + + strcpy(val, newval); + free((void *)oldval); + sym_clear_all_valid(); + + return true; +} + +/* + * Find the default value associated to a symbol. + * For tristate symbol handle the modules=n case + * in which case "m" becomes "y". + * If the symbol does not have any default then fallback + * to the fixed default values. + */ +const char *sym_get_string_default(struct symbol *sym) +{ + struct property *prop; + struct symbol *ds; + const char *str; + tristate val; + + sym_calc_visibility(sym); + sym_calc_value(modules_sym); + val = symbol_no.curr.tri; + str = symbol_empty.curr.val; + + /* If symbol has a default value look it up */ + prop = sym_get_default_prop(sym); + if (prop != NULL) { + switch (sym->type) { + case S_BOOLEAN: + case S_TRISTATE: + /* The visibility may limit the value from yes => mod */ + val = EXPR_AND(expr_calc_value(prop->expr), prop->visible.tri); + break; + default: + /* + * The following fails to handle the situation + * where a default value is further limited by + * the valid range. + */ + ds = prop_get_symbol(prop); + if (ds != NULL) { + sym_calc_value(ds); + str = (const char *)ds->curr.val; + } + } + } + + /* Handle select statements */ + val = EXPR_OR(val, sym->rev_dep.tri); + + /* transpose mod to yes if modules are not enabled */ + if (val == mod) + if (!sym_is_choice_value(sym) && modules_sym->curr.tri == no) + val = yes; + + /* transpose mod to yes if type is bool */ + if (sym->type == S_BOOLEAN && val == mod) + val = yes; + + switch (sym->type) { + case S_BOOLEAN: + case S_TRISTATE: + switch (val) { + case no: return "n"; + case mod: return "m"; + case yes: return "y"; + } + case S_INT: + case S_HEX: + return str; + case S_STRING: + return str; + case S_OTHER: + case S_UNKNOWN: + break; + } + return ""; +} + +const char *sym_get_string_value(struct symbol *sym) +{ + tristate val; + + switch (sym->type) { + case S_BOOLEAN: + case S_TRISTATE: + val = sym_get_tristate_value(sym); + switch (val) { + case no: + return "n"; + case mod: + return "m"; + case yes: + return "y"; + } + break; + default: + ; + } + return (const char *)sym->curr.val; +} + +bool sym_is_changable(struct symbol *sym) +{ + return sym->visible > sym->rev_dep.tri; +} + +static unsigned strhash(const char *s) +{ + /* fnv32 hash */ + unsigned hash = 2166136261U; + for (; *s; s++) + hash = (hash ^ *s) * 0x01000193; + return hash; +} + +struct symbol *sym_lookup(const char *name, int flags) +{ + struct symbol *symbol; + char *new_name; + int hash; + + if (name) { + if (name[0] && !name[1]) { + switch (name[0]) { + case 'y': return &symbol_yes; + case 'm': return &symbol_mod; + case 'n': return &symbol_no; + } + } + hash = strhash(name) % SYMBOL_HASHSIZE; + + for (symbol = symbol_hash[hash]; symbol; symbol = symbol->next) { + if (symbol->name && + !strcmp(symbol->name, name) && + (flags ? symbol->flags & flags + : !(symbol->flags & (SYMBOL_CONST|SYMBOL_CHOICE)))) + return symbol; + } + new_name = strdup(name); + } else { + new_name = NULL; + hash = 0; + } + + symbol = malloc(sizeof(*symbol)); + memset(symbol, 0, sizeof(*symbol)); + symbol->name = new_name; + symbol->type = S_UNKNOWN; + symbol->flags |= flags; + + symbol->next = symbol_hash[hash]; + symbol_hash[hash] = symbol; + + return symbol; +} + +struct symbol *sym_find(const char *name) +{ + struct symbol *symbol = NULL; + int hash = 0; + + if (!name) + return NULL; + + if (name[0] && !name[1]) { + switch (name[0]) { + case 'y': return &symbol_yes; + case 'm': return &symbol_mod; + case 'n': return &symbol_no; + } + } + hash = strhash(name) % SYMBOL_HASHSIZE; + + for (symbol = symbol_hash[hash]; symbol; symbol = symbol->next) { + if (symbol->name && + !strcmp(symbol->name, name) && + !(symbol->flags & SYMBOL_CONST)) + break; + } + + return symbol; +} + +/* + * Expand symbol's names embedded in the string given in argument. Symbols' + * name to be expanded shall be prefixed by a '$'. Unknown symbol expands to + * the empty string. + */ +const char *sym_expand_string_value(const char *in) +{ + const char *src; + char *res; + size_t reslen; + + reslen = strlen(in) + 1; + res = malloc(reslen); + res[0] = '\0'; + + while ((src = strchr(in, '$'))) { + char *p, name[SYMBOL_MAXLENGTH]; + const char *symval = ""; + struct symbol *sym; + size_t newlen; + + strncat(res, in, src - in); + src++; + + p = name; + while (isalnum(*src) || *src == '_') + *p++ = *src++; + *p = '\0'; + + sym = sym_find(name); + if (sym != NULL) { + sym_calc_value(sym); + symval = sym_get_string_value(sym); + } + + newlen = strlen(res) + strlen(symval) + strlen(src) + 1; + if (newlen > reslen) { + reslen = newlen; + res = realloc(res, reslen); + } + + strcat(res, symval); + in = src; + } + strcat(res, in); + + return res; +} + +struct symbol **sym_re_search(const char *pattern) +{ + struct symbol *sym, **sym_arr = NULL; + int i, cnt, size; + regex_t re; + + cnt = size = 0; + /* Skip if empty */ + if (strlen(pattern) == 0) + return NULL; + if (regcomp(&re, pattern, REG_EXTENDED|REG_NOSUB|REG_ICASE)) + return NULL; + + for_all_symbols(i, sym) { + if (sym->flags & SYMBOL_CONST || !sym->name) + continue; + if (regexec(&re, sym->name, 0, NULL, 0)) + continue; + if (cnt + 1 >= size) { + void *tmp = sym_arr; + size += 16; + sym_arr = realloc(sym_arr, size * sizeof(struct symbol *)); + if (!sym_arr) { + free(tmp); + return NULL; + } + } + sym_calc_value(sym); + sym_arr[cnt++] = sym; + } + if (sym_arr) + sym_arr[cnt] = NULL; + regfree(&re); + + return sym_arr; +} + +/* + * When we check for recursive dependencies we use a stack to save + * current state so we can print out relevant info to user. + * The entries are located on the call stack so no need to free memory. + * Note inser() remove() must always match to properly clear the stack. + */ +static struct dep_stack { + struct dep_stack *prev, *next; + struct symbol *sym; + struct property *prop; + struct expr *expr; +} *check_top; + +static void dep_stack_insert(struct dep_stack *stack, struct symbol *sym) +{ + memset(stack, 0, sizeof(*stack)); + if (check_top) + check_top->next = stack; + stack->prev = check_top; + stack->sym = sym; + check_top = stack; +} + +static void dep_stack_remove(void) +{ + check_top = check_top->prev; + if (check_top) + check_top->next = NULL; +} + +/* + * Called when we have detected a recursive dependency. + * check_top point to the top of the stact so we use + * the ->prev pointer to locate the bottom of the stack. + */ +static void sym_check_print_recursive(struct symbol *last_sym) +{ + struct dep_stack *stack; + struct symbol *sym, *next_sym; + struct menu *menu = NULL; + struct property *prop; + struct dep_stack cv_stack; + + if (sym_is_choice_value(last_sym)) { + dep_stack_insert(&cv_stack, last_sym); + last_sym = prop_get_symbol(sym_get_choice_prop(last_sym)); + } + + for (stack = check_top; stack != NULL; stack = stack->prev) + if (stack->sym == last_sym) + break; + if (!stack) { + fprintf(stderr, "unexpected recursive dependency error\n"); + return; + } + + for (; stack; stack = stack->next) { + sym = stack->sym; + next_sym = stack->next ? stack->next->sym : last_sym; + prop = stack->prop; + if (prop == NULL) + prop = stack->sym->prop; + + /* for choice values find the menu entry (used below) */ + if (sym_is_choice(sym) || sym_is_choice_value(sym)) { + for (prop = sym->prop; prop; prop = prop->next) { + menu = prop->menu; + if (prop->menu) + break; + } + } + if (stack->sym == last_sym) + fprintf(stderr, "%s:%d:error: recursive dependency detected!\n", + prop->file->name, prop->lineno); + if (stack->expr) { + fprintf(stderr, "%s:%d:\tsymbol %s %s value contains %s\n", + prop->file->name, prop->lineno, + sym->name ? sym->name : "<choice>", + prop_get_type_name(prop->type), + next_sym->name ? next_sym->name : "<choice>"); + } else if (stack->prop) { + fprintf(stderr, "%s:%d:\tsymbol %s depends on %s\n", + prop->file->name, prop->lineno, + sym->name ? sym->name : "<choice>", + next_sym->name ? next_sym->name : "<choice>"); + } else if (sym_is_choice(sym)) { + fprintf(stderr, "%s:%d:\tchoice %s contains symbol %s\n", + menu->file->name, menu->lineno, + sym->name ? sym->name : "<choice>", + next_sym->name ? next_sym->name : "<choice>"); + } else if (sym_is_choice_value(sym)) { + fprintf(stderr, "%s:%d:\tsymbol %s is part of choice %s\n", + menu->file->name, menu->lineno, + sym->name ? sym->name : "<choice>", + next_sym->name ? next_sym->name : "<choice>"); + } else { + fprintf(stderr, "%s:%d:\tsymbol %s is selected by %s\n", + prop->file->name, prop->lineno, + sym->name ? sym->name : "<choice>", + next_sym->name ? next_sym->name : "<choice>"); + } + } + + if (check_top == &cv_stack) + dep_stack_remove(); +} + +static struct symbol *sym_check_expr_deps(struct expr *e) +{ + struct symbol *sym; + + if (!e) + return NULL; + switch (e->type) { + case E_OR: + case E_AND: + sym = sym_check_expr_deps(e->left.expr); + if (sym) + return sym; + return sym_check_expr_deps(e->right.expr); + case E_NOT: + return sym_check_expr_deps(e->left.expr); + case E_EQUAL: + case E_UNEQUAL: + sym = sym_check_deps(e->left.sym); + if (sym) + return sym; + return sym_check_deps(e->right.sym); + case E_SYMBOL: + return sym_check_deps(e->left.sym); + default: + break; + } + printf("Oops! How to check %d?\n", e->type); + return NULL; +} + +/* return NULL when dependencies are OK */ +static struct symbol *sym_check_sym_deps(struct symbol *sym) +{ + struct symbol *sym2; + struct property *prop; + struct dep_stack stack; + + dep_stack_insert(&stack, sym); + + sym2 = sym_check_expr_deps(sym->rev_dep.expr); + if (sym2) + goto out; + + for (prop = sym->prop; prop; prop = prop->next) { + if (prop->type == P_CHOICE || prop->type == P_SELECT) + continue; + stack.prop = prop; + sym2 = sym_check_expr_deps(prop->visible.expr); + if (sym2) + break; + if (prop->type != P_DEFAULT || sym_is_choice(sym)) + continue; + stack.expr = prop->expr; + sym2 = sym_check_expr_deps(prop->expr); + if (sym2) + break; + stack.expr = NULL; + } + +out: + dep_stack_remove(); + + return sym2; +} + +static struct symbol *sym_check_choice_deps(struct symbol *choice) +{ + struct symbol *sym, *sym2; + struct property *prop; + struct expr *e; + struct dep_stack stack; + + dep_stack_insert(&stack, choice); + + prop = sym_get_choice_prop(choice); + expr_list_for_each_sym(prop->expr, e, sym) + sym->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED); + + choice->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED); + sym2 = sym_check_sym_deps(choice); + choice->flags &= ~SYMBOL_CHECK; + if (sym2) + goto out; + + expr_list_for_each_sym(prop->expr, e, sym) { + sym2 = sym_check_sym_deps(sym); + if (sym2) + break; + } +out: + expr_list_for_each_sym(prop->expr, e, sym) + sym->flags &= ~SYMBOL_CHECK; + + if (sym2 && sym_is_choice_value(sym2) && + prop_get_symbol(sym_get_choice_prop(sym2)) == choice) + sym2 = choice; + + dep_stack_remove(); + + return sym2; +} + +struct symbol *sym_check_deps(struct symbol *sym) +{ + struct symbol *sym2; + struct property *prop; + + if (sym->flags & SYMBOL_CHECK) { + sym_check_print_recursive(sym); + return sym; + } + if (sym->flags & SYMBOL_CHECKED) + return NULL; + + if (sym_is_choice_value(sym)) { + struct dep_stack stack; + + /* for choice groups start the check with main choice symbol */ + dep_stack_insert(&stack, sym); + prop = sym_get_choice_prop(sym); + sym2 = sym_check_deps(prop_get_symbol(prop)); + dep_stack_remove(); + } else if (sym_is_choice(sym)) { + sym2 = sym_check_choice_deps(sym); + } else { + sym->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED); + sym2 = sym_check_sym_deps(sym); + sym->flags &= ~SYMBOL_CHECK; + } + + if (sym2 && sym2 == sym) + sym2 = NULL; + + return sym2; +} + +struct property *prop_alloc(enum prop_type type, struct symbol *sym) +{ + struct property *prop; + struct property **propp; + + prop = malloc(sizeof(*prop)); + memset(prop, 0, sizeof(*prop)); + prop->type = type; + prop->sym = sym; + prop->file = current_file; + prop->lineno = zconf_lineno(); + + /* append property to the prop list of symbol */ + if (sym) { + for (propp = &sym->prop; *propp; propp = &(*propp)->next) + ; + *propp = prop; + } + + return prop; +} + +struct symbol *prop_get_symbol(struct property *prop) +{ + if (prop->expr && (prop->expr->type == E_SYMBOL || + prop->expr->type == E_LIST)) + return prop->expr->left.sym; + return NULL; +} + +const char *prop_get_type_name(enum prop_type type) +{ + switch (type) { + case P_PROMPT: + return "prompt"; + case P_ENV: + return "env"; + case P_COMMENT: + return "comment"; + case P_MENU: + return "menu"; + case P_DEFAULT: + return "default"; + case P_CHOICE: + return "choice"; + case P_SELECT: + return "select"; + case P_RANGE: + return "range"; + case P_SYMBOL: + return "symbol"; + case P_UNKNOWN: + break; + } + return "unknown"; +} Index: branches/azimutz/Cleancut/i386/config/lex.zconf.c =================================================================== --- branches/azimutz/Cleancut/i386/config/lex.zconf.c (revision 0) +++ branches/azimutz/Cleancut/i386/config/lex.zconf.c (revision 885) @@ -0,0 +1,2430 @@ + +#line 3 "scripts/kconfig/lex.zconf.c" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define yy_create_buffer zconf_create_buffer +#define yy_delete_buffer zconf_delete_buffer +#define yy_flex_debug zconf_flex_debug +#define yy_init_buffer zconf_init_buffer +#define yy_flush_buffer zconf_flush_buffer +#define yy_load_buffer_state zconf_load_buffer_state +#define yy_switch_to_buffer zconf_switch_to_buffer +#define yyin zconfin +#define yyleng zconfleng +#define yylex zconflex +#define yylineno zconflineno +#define yyout zconfout +#define yyrestart zconfrestart +#define yytext zconftext +#define yywrap zconfwrap +#define yyalloc zconfalloc +#define yyrealloc zconfrealloc +#define yyfree zconffree + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 35 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include <stdio.h> +#include <string.h> +#include <errno.h> +#include <stdlib.h> + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include <inttypes.h> +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! C99 */ + +#endif /* ! FLEXINT_H */ + +#ifdef __cplusplus + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +/* C99 requires __STDC__ to be defined as 1. */ +#if defined (__STDC__) + +#define YY_USE_CONST + +#endif /* defined (__STDC__) */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN (yy_start) = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START (((yy_start) - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE zconfrestart(zconfin ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else +#define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +extern int zconfleng; + +extern FILE *zconfin, *zconfout; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up zconftext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = (yy_hold_char); \ + YY_RESTORE_YY_MORE_OFFSET \ + (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up zconftext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, (yytext_ptr) ) + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + int yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via zconfrestart()), so that the user can continue scanning by + * just pointing zconfin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* Stack of input buffers. */ +static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ +static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ +static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ + ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ + : NULL) + +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] + +/* yy_hold_char holds the character lost when zconftext is formed. */ +static char yy_hold_char; +static int yy_n_chars; /* number of characters read into yy_ch_buf */ +int zconfleng; + +/* Points to current character in buffer. */ +static char *yy_c_buf_p = (char *) 0; +static int yy_init = 0; /* whether we need to initialize */ +static int yy_start = 0; /* start state number */ + +/* Flag which is used to allow zconfwrap()'s to do buffer switches + * instead of setting up a fresh zconfin. A bit of a hack ... + */ +static int yy_did_buffer_switch_on_eof; + +void zconfrestart (FILE *input_file ); +void zconf_switch_to_buffer (YY_BUFFER_STATE new_buffer ); +YY_BUFFER_STATE zconf_create_buffer (FILE *file,int size ); +void zconf_delete_buffer (YY_BUFFER_STATE b ); +void zconf_flush_buffer (YY_BUFFER_STATE b ); +void zconfpush_buffer_state (YY_BUFFER_STATE new_buffer ); +void zconfpop_buffer_state (void ); + +static void zconfensure_buffer_stack (void ); +static void zconf_load_buffer_state (void ); +static void zconf_init_buffer (YY_BUFFER_STATE b,FILE *file ); + +#define YY_FLUSH_BUFFER zconf_flush_buffer(YY_CURRENT_BUFFER ) + +YY_BUFFER_STATE zconf_scan_buffer (char *base,yy_size_t size ); +YY_BUFFER_STATE zconf_scan_string (yyconst char *yy_str ); +YY_BUFFER_STATE zconf_scan_bytes (yyconst char *bytes,int len ); + +void *zconfalloc (yy_size_t ); +void *zconfrealloc (void *,yy_size_t ); +void zconffree (void * ); + +#define yy_new_buffer zconf_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + zconfensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + zconf_create_buffer(zconfin,YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + zconfensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + zconf_create_buffer(zconfin,YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ + +#define zconfwrap(n) 1 +#define YY_SKIP_YYWRAP + +typedef unsigned char YY_CHAR; + +FILE *zconfin = (FILE *) 0, *zconfout = (FILE *) 0; + +typedef int yy_state_type; + +extern int zconflineno; + +int zconflineno = 1; + +extern char *zconftext; +#define yytext_ptr zconftext +static yyconst flex_int16_t yy_nxt[][17] = + { + { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0 + }, + + { + 11, 12, 13, 14, 12, 12, 15, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12 + }, + + { + 11, 12, 13, 14, 12, 12, 15, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12 + }, + + { + 11, 16, 16, 17, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 18, 16, 16, 16 + }, + + { + 11, 16, 16, 17, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 18, 16, 16, 16 + + }, + + { + 11, 19, 20, 21, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19 + }, + + { + 11, 19, 20, 21, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19 + }, + + { + 11, 22, 22, 23, 22, 24, 22, 22, 24, 22, + 22, 22, 22, 22, 22, 25, 22 + }, + + { + 11, 22, 22, 23, 22, 24, 22, 22, 24, 22, + 22, 22, 22, 22, 22, 25, 22 + }, + + { + 11, 26, 26, 27, 28, 29, 30, 31, 29, 32, + 33, 34, 35, 35, 36, 37, 38 + + }, + + { + 11, 26, 26, 27, 28, 29, 30, 31, 29, 32, + 33, 34, 35, 35, 36, 37, 38 + }, + + { + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11 + }, + + { + 11, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12 + }, + + { + 11, -13, 39, 40, -13, -13, 41, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13 + }, + + { + 11, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14 + + }, + + { + 11, 42, 42, 43, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42 + }, + + { + 11, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16 + }, + + { + 11, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17 + }, + + { + 11, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, 44, -18, -18, -18 + }, + + { + 11, 45, 45, -19, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45 + + }, + + { + 11, -20, 46, 47, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20 + }, + + { + 11, 48, -21, -21, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48 + }, + + { + 11, 49, 49, 50, 49, -22, 49, 49, -22, 49, + 49, 49, 49, 49, 49, -22, 49 + }, + + { + 11, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23 + }, + + { + 11, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24 + + }, + + { + 11, 51, 51, 52, 51, 51, 51, 51, 51, 51, + 51, 51, 51, 51, 51, 51, 51 + }, + + { + 11, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26 + }, + + { + 11, -27, -27, -27, -27, -27, -27, -27, -27, -27, + -27, -27, -27, -27, -27, -27, -27 + }, + + { + 11, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, 53, -28, -28 + }, + + { + 11, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29, -29 + + }, + + { + 11, 54, 54, -30, 54, 54, 54, 54, 54, 54, + 54, 54, 54, 54, 54, 54, 54 + }, + + { + 11, -31, -31, -31, -31, -31, -31, 55, -31, -31, + -31, -31, -31, -31, -31, -31, -31 + }, + + { + 11, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32 + }, + + { + 11, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33 + }, + + { + 11, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, 56, 57, 57, -34, -34, -34 + + }, + + { + 11, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, 57, 57, 57, -35, -35, -35 + }, + + { + 11, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36 + }, + + { + 11, -37, -37, 58, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37 + }, + + { + 11, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, 59 + }, + + { + 11, -39, 39, 40, -39, -39, 41, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39 + + }, + + { + 11, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40 + }, + + { + 11, 42, 42, 43, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42 + }, + + { + 11, 42, 42, 43, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42 + }, + + { + 11, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43 + }, + + { + 11, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, 44, -44, -44, -44 + + }, + + { + 11, 45, 45, -45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45 + }, + + { + 11, -46, 46, 47, -46, -46, -46, -46, -46, -46, + -46, -46, -46, -46, -46, -46, -46 + }, + + { + 11, 48, -47, -47, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48 + }, + + { + 11, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48 + }, + + { + 11, 49, 49, 50, 49, -49, 49, 49, -49, 49, + 49, 49, 49, 49, 49, -49, 49 + + }, + + { + 11, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50 + }, + + { + 11, -51, -51, 52, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51 + }, + + { + 11, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52 + }, + + { + 11, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53 + }, + + { + 11, 54, 54, -54, 54, 54, 54, 54, 54, 54, + 54, 54, 54, 54, 54, 54, 54 + + }, + + { + 11, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55 + }, + + { + 11, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, 60, 57, 57, -56, -56, -56 + }, + + { + 11, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, 57, 57, 57, -57, -57, -57 + }, + + { + 11, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58 + }, + + { + 11, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59 + + }, + + { + 11, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, 57, 57, 57, -60, -60, -60 + }, + + } ; + +static yy_state_type yy_get_previous_state (void ); +static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); +static int yy_get_next_buffer (void ); +static void yy_fatal_error (yyconst char msg[] ); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up zconftext. + */ +#define YY_DO_BEFORE_ACTION \ + (yytext_ptr) = yy_bp; \ + zconfleng = (size_t) (yy_cp - yy_bp); \ + (yy_hold_char) = *yy_cp; \ + *yy_cp = '\0'; \ + (yy_c_buf_p) = yy_cp; + +#define YY_NUM_RULES 33 +#define YY_END_OF_BUFFER 34 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static yyconst flex_int16_t yy_accept[61] = + { 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 34, 5, 4, 2, 3, 7, 8, 6, 32, 29, + 31, 24, 28, 27, 26, 22, 17, 13, 16, 20, + 22, 11, 12, 19, 19, 14, 22, 22, 4, 2, + 3, 3, 1, 6, 32, 29, 31, 30, 24, 23, + 26, 25, 15, 20, 9, 19, 19, 21, 10, 18 + } ; + +static yyconst flex_int32_t yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 4, 5, 6, 1, 1, 7, 8, 9, + 10, 1, 1, 1, 11, 12, 12, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 1, 1, 1, + 14, 1, 1, 1, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 1, 15, 1, 1, 13, 1, 13, 13, 13, 13, + + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 1, 16, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +extern int zconf_flex_debug; +int zconf_flex_debug = 0; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +char *zconftext; +#define YY_NO_INPUT 1 + +/* + * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> + * Released under the terms of the GNU GPL v2.0. + */ + +#include <limits.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +#define LKC_DIRECT_LINK +#include "lkc.h" + +#define START_STRSIZE 16 + +static struct { + struct file *file; + int lineno; +} current_pos; + +static char *text; +static int text_size, text_asize; + +struct buffer { + struct buffer *parent; + YY_BUFFER_STATE state; +}; + +struct buffer *current_buf; + +static int last_ts, first_ts; + +static void zconf_endhelp(void); +static void zconf_endfile(void); + +static void new_string(void) +{ + text = malloc(START_STRSIZE); + text_asize = START_STRSIZE; + text_size = 0; + *text = 0; +} + +static void append_string(const char *str, int size) +{ + int new_size = text_size + size + 1; + if (new_size > text_asize) { + new_size += START_STRSIZE - 1; + new_size &= -START_STRSIZE; + text = realloc(text, new_size); + text_asize = new_size; + } + memcpy(text + text_size, str, size); + text_size += size; + text[text_size] = 0; +} + +static void alloc_string(const char *str, int size) +{ + text = malloc(size + 1); + memcpy(text, str, size); + text[size] = 0; +} + +#define INITIAL 0 +#define COMMAND 1 +#define HELP 2 +#define STRING 3 +#define PARAM 4 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include <unistd.h> +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +static int yy_init_globals (void ); + +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int zconflex_destroy (void ); + +int zconfget_debug (void ); + +void zconfset_debug (int debug_flag ); + +YY_EXTRA_TYPE zconfget_extra (void ); + +void zconfset_extra (YY_EXTRA_TYPE user_defined ); + +FILE *zconfget_in (void ); + +void zconfset_in (FILE * in_str ); + +FILE *zconfget_out (void ); + +void zconfset_out (FILE * out_str ); + +int zconfget_leng (void ); + +char *zconfget_text (void ); + +int zconfget_lineno (void ); + +void zconfset_lineno (int line_number ); + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int zconfwrap (void ); +#else +extern int zconfwrap (void ); +#endif +#endif + + static void yyunput (int c,char *buf_ptr ); + +#ifndef yytext_ptr +static void yy_flex_strncpy (char *,yyconst char *,int ); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * ); +#endif + +#ifndef YY_NO_INPUT + +#ifdef __cplusplus +static int yyinput (void ); +#else +static int input (void ); +#endif + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else +#define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO do { if (fwrite( zconftext, zconfleng, 1, zconfout )) {} } while (0) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + errno=0; \ + while ( (result = read( fileno(zconfin), (char *) buf, max_size )) < 0 ) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(zconfin); \ + }\ +\ + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 + +extern int zconflex (void); + +#define YY_DECL int zconflex (void) +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after zconftext and zconfleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; + + int str = 0; + int ts, i; + + if ( !(yy_init) ) + { + (yy_init) = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! (yy_start) ) + (yy_start) = 1; /* first start state */ + + if ( ! zconfin ) + zconfin = stdin; + + if ( ! zconfout ) + zconfout = stdout; + + if ( ! YY_CURRENT_BUFFER ) { + zconfensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + zconf_create_buffer(zconfin,YY_BUF_SIZE ); + } + + zconf_load_buffer_state( ); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = (yy_c_buf_p); + + /* Support of zconftext. */ + *yy_cp = (yy_hold_char); + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = (yy_start); +yy_match: + while ( (yy_current_state = yy_nxt[yy_current_state][ yy_ec[YY_SC_TO_UI(*yy_cp)] ]) > 0 ) + ++yy_cp; + + yy_current_state = -yy_current_state; + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ +case 1: +/* rule 1 can match eol */ +case 2: +/* rule 2 can match eol */ +YY_RULE_SETUP +{ + current_file->lineno++; + return T_EOL; +} + YY_BREAK +case 3: +YY_RULE_SETUP + + YY_BREAK +case 4: +YY_RULE_SETUP +{ + BEGIN(COMMAND); +} + YY_BREAK +case 5: +YY_RULE_SETUP +{ + unput(zconftext[0]); + BEGIN(COMMAND); +} + YY_BREAK + +case 6: +YY_RULE_SETUP +{ + struct kconf_id *id = kconf_id_lookup(zconftext, zconfleng); + BEGIN(PARAM); + current_pos.file = current_file; + current_pos.lineno = current_file->lineno; + if (id && id->flags & TF_COMMAND) { + zconflval.id = id; + return id->token; + } + alloc_string(zconftext, zconfleng); + zconflval.string = text; + return T_WORD; + } + YY_BREAK +case 7: +YY_RULE_SETUP + + YY_BREAK +case 8: +/* rule 8 can match eol */ +YY_RULE_SETUP +{ + BEGIN(INITIAL); + current_file->lineno++; + return T_EOL; + } + YY_BREAK + +case 9: +YY_RULE_SETUP +return T_AND; + YY_BREAK +case 10: +YY_RULE_SETUP +return T_OR; + YY_BREAK +case 11: +YY_RULE_SETUP +return T_OPEN_PAREN; + YY_BREAK +case 12: +YY_RULE_SETUP +return T_CLOSE_PAREN; + YY_BREAK +case 13: +YY_RULE_SETUP +return T_NOT; + YY_BREAK +case 14: +YY_RULE_SETUP +return T_EQUAL; + YY_BREAK +case 15: +YY_RULE_SETUP +return T_UNEQUAL; + YY_BREAK +case 16: +YY_RULE_SETUP +{ + str = zconftext[0]; + new_string(); + BEGIN(STRING); + } + YY_BREAK +case 17: +/* rule 17 can match eol */ +YY_RULE_SETUP +BEGIN(INITIAL); current_file->lineno++; return T_EOL; + YY_BREAK +case 18: +YY_RULE_SETUP +/* ignore */ + YY_BREAK +case 19: +YY_RULE_SETUP +{ + struct kconf_id *id = kconf_id_lookup(zconftext, zconfleng); + if (id && id->flags & TF_PARAM) { + zconflval.id = id; + return id->token; + } + alloc_string(zconftext, zconfleng); + zconflval.string = text; + return T_WORD; + } + YY_BREAK +case 20: +YY_RULE_SETUP +/* comment */ + YY_BREAK +case 21: +/* rule 21 can match eol */ +YY_RULE_SETUP +current_file->lineno++; + YY_BREAK +case 22: +YY_RULE_SETUP + + YY_BREAK +case YY_STATE_EOF(PARAM): +{ + BEGIN(INITIAL); + } + YY_BREAK + +case 23: +/* rule 23 can match eol */ +*yy_cp = (yy_hold_char); /* undo effects of setting up zconftext */ +(yy_c_buf_p) = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up zconftext again */ +YY_RULE_SETUP +{ + append_string(zconftext, zconfleng); + zconflval.string = text; + return T_WORD_QUOTE; + } + YY_BREAK +case 24: +YY_RULE_SETUP +{ + append_string(zconftext, zconfleng); + } + YY_BREAK +case 25: +/* rule 25 can match eol */ +*yy_cp = (yy_hold_char); /* undo effects of setting up zconftext */ +(yy_c_buf_p) = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up zconftext again */ +YY_RULE_SETUP +{ + append_string(zconftext + 1, zconfleng - 1); + zconflval.string = text; + return T_WORD_QUOTE; + } + YY_BREAK +case 26: +YY_RULE_SETUP +{ + append_string(zconftext + 1, zconfleng - 1); + } + YY_BREAK +case 27: +YY_RULE_SETUP +{ + if (str == zconftext[0]) { + BEGIN(PARAM); + zconflval.string = text; + return T_WORD_QUOTE; + } else + append_string(zconftext, 1); + } + YY_BREAK +case 28: +/* rule 28 can match eol */ +YY_RULE_SETUP +{ + printf("%s:%d:warning: multi-line strings not supported\n", zconf_curname(), zconf_lineno()); + current_file->lineno++; + BEGIN(INITIAL); + return T_EOL; + } + YY_BREAK +case YY_STATE_EOF(STRING): +{ + BEGIN(INITIAL); + } + YY_BREAK + +case 29: +YY_RULE_SETUP +{ + ts = 0; + for (i = 0; i < zconfleng; i++) { + if (zconftext[i] == '\t') + ts = (ts & ~7) + 8; + else + ts++; + } + last_ts = ts; + if (first_ts) { + if (ts < first_ts) { + zconf_endhelp(); + return T_HELPTEXT; + } + ts -= first_ts; + while (ts > 8) { + append_string(" ", 8); + ts -= 8; + } + append_string(" ", ts); + } + } + YY_BREAK +case 30: +/* rule 30 can match eol */ +*yy_cp = (yy_hold_char); /* undo effects of setting up zconftext */ +(yy_c_buf_p) = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up zconftext again */ +YY_RULE_SETUP +{ + current_file->lineno++; + zconf_endhelp(); + return T_HELPTEXT; + } + YY_BREAK +case 31: +/* rule 31 can match eol */ +YY_RULE_SETUP +{ + current_file->lineno++; + append_string("\n", 1); + } + YY_BREAK +case 32: +YY_RULE_SETUP +{ + while (zconfleng) { + if ((zconftext[zconfleng-1] != ' ') && (zconftext[zconfleng-1] != '\t')) + break; + zconfleng--; + } + append_string(zconftext, zconfleng); + if (!first_ts) + first_ts = last_ts; + } + YY_BREAK +case YY_STATE_EOF(HELP): +{ + zconf_endhelp(); + return T_HELPTEXT; + } + YY_BREAK + +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(COMMAND): +{ + if (current_file) { + zconf_endfile(); + return T_EOL; + } + fclose(zconfin); + yyterminate(); +} + YY_BREAK +case 33: +YY_RULE_SETUP +YY_FATAL_ERROR( "flex scanner jammed" ); + YY_BREAK + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = (yy_hold_char); + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed zconfin at a new source and called + * zconflex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = zconfin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++(yy_c_buf_p); + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = (yy_c_buf_p); + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_END_OF_FILE: + { + (yy_did_buffer_switch_on_eof) = 0; + + if ( zconfwrap( ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * zconftext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = + (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + (yy_c_buf_p) = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ +} /* end of zconflex */ + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +static int yy_get_next_buffer (void) +{ + register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + register char *source = (yytext_ptr); + register int number_to_move, i; + int ret_val; + + if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; + + else + { + int num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER; + + int yy_c_buf_p_offset = + (int) ((yy_c_buf_p) - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + int new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + zconfrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + (yy_n_chars), (size_t) num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + if ( (yy_n_chars) == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + zconfrestart(zconfin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) zconfrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + } + + (yy_n_chars) += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; + + (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + static yy_state_type yy_get_previous_state (void) +{ + register yy_state_type yy_current_state; + register char *yy_cp; + + yy_current_state = (yy_start); + + for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) + { + yy_current_state = yy_nxt[yy_current_state][(*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1)]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) +{ + register int yy_is_jam; + + yy_current_state = yy_nxt[yy_current_state][1]; + yy_is_jam = (yy_current_state <= 0); + + return yy_is_jam ? 0 : yy_current_state; +} + + static void yyunput (int c, register char * yy_bp ) +{ + register char *yy_cp; + + yy_cp = (yy_c_buf_p); + + /* undo effects of setting up zconftext */ + *yy_cp = (yy_hold_char); + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register int number_to_move = (yy_n_chars) + 2; + register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; + register char *source = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; + + while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + (yytext_ptr) = yy_bp; + (yy_hold_char) = *yy_cp; + (yy_c_buf_p) = yy_cp; +} + +#ifndef YY_NO_INPUT +#ifdef __cplusplus + static int yyinput (void) +#else + static int input (void) +#endif + +{ + int c; + + *(yy_c_buf_p) = (yy_hold_char); + + if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + /* This was really a NUL. */ + *(yy_c_buf_p) = '\0'; + + else + { /* need more input */ + int offset = (yy_c_buf_p) - (yytext_ptr); + ++(yy_c_buf_p); + + switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + zconfrestart(zconfin ); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( zconfwrap( ) ) + return EOF; + + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = (yytext_ptr) + offset; + break; + } + } + } + + c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ + *(yy_c_buf_p) = '\0'; /* preserve zconftext */ + (yy_hold_char) = *++(yy_c_buf_p); + + return c; +} +#endif /* ifndef YY_NO_INPUT */ + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * + * @note This function does not reset the start condition to @c INITIAL . + */ + void zconfrestart (FILE * input_file ) +{ + + if ( ! YY_CURRENT_BUFFER ){ + zconfensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + zconf_create_buffer(zconfin,YY_BUF_SIZE ); + } + + zconf_init_buffer(YY_CURRENT_BUFFER,input_file ); + zconf_load_buffer_state( ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * + */ + void zconf_switch_to_buffer (YY_BUFFER_STATE new_buffer ) +{ + + /* TODO. We should be able to replace this entire function body + * with + * zconfpop_buffer_state(); + * zconfpush_buffer_state(new_buffer); + */ + zconfensure_buffer_stack (); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + zconf_load_buffer_state( ); + + /* We don't actually know whether we did this switch during + * EOF (zconfwrap()) processing, but the only time this flag + * is looked at is after zconfwrap() is called, so it's safe + * to go ahead and always set it. + */ + (yy_did_buffer_switch_on_eof) = 1; +} + +static void zconf_load_buffer_state (void) +{ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + zconfin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + (yy_hold_char) = *(yy_c_buf_p); +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * + * @return the allocated buffer state. + */ + YY_BUFFER_STATE zconf_create_buffer (FILE * file, int size ) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) zconfalloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in zconf_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) zconfalloc(b->yy_buf_size + 2 ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in zconf_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + zconf_init_buffer(b,file ); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with zconf_create_buffer() + * + */ + void zconf_delete_buffer (YY_BUFFER_STATE b ) +{ + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + zconffree((void *) b->yy_ch_buf ); + + zconffree((void *) b ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a zconfrestart() or at EOF. + */ + static void zconf_init_buffer (YY_BUFFER_STATE b, FILE * file ) + +{ + int oerrno = errno; + + zconf_flush_buffer(b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then zconf_init_buffer was _probably_ + * called from zconfrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = 0; + + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * + */ + void zconf_flush_buffer (YY_BUFFER_STATE b ) +{ + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + zconf_load_buffer_state( ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * + */ +void zconfpush_buffer_state (YY_BUFFER_STATE new_buffer ) +{ + if (new_buffer == NULL) + return; + + zconfensure_buffer_stack(); + + /* This block is copied from zconf_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + (yy_buffer_stack_top)++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from zconf_switch_to_buffer. */ + zconf_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * + */ +void zconfpop_buffer_state (void) +{ + if (!YY_CURRENT_BUFFER) + return; + + zconf_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + if ((yy_buffer_stack_top) > 0) + --(yy_buffer_stack_top); + + if (YY_CURRENT_BUFFER) { + zconf_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void zconfensure_buffer_stack (void) +{ + int num_to_alloc; + + if (!(yy_buffer_stack)) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; + (yy_buffer_stack) = (struct yy_buffer_state**)zconfalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in zconfensure_buffer_stack()" ); + + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + (yy_buffer_stack_max) = num_to_alloc; + (yy_buffer_stack_top) = 0; + return; + } + + if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + int grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = (yy_buffer_stack_max) + grow_size; + (yy_buffer_stack) = (struct yy_buffer_state**)zconfrealloc + ((yy_buffer_stack), + num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in zconfensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); + (yy_buffer_stack_max) = num_to_alloc; + } +} + +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE zconf_scan_buffer (char * base, yy_size_t size ) +{ + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return 0; + + b = (YY_BUFFER_STATE) zconfalloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in zconf_scan_buffer()" ); + + b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = 0; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + zconf_switch_to_buffer(b ); + + return b; +} + +/** Setup the input buffer state to scan a string. The next call to zconflex() will + * scan from a @e copy of @a str. + * @param yystr a NUL-terminated string to scan + * + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * zconf_scan_bytes() instead. + */ +YY_BUFFER_STATE zconf_scan_string (yyconst char * yystr ) +{ + + return zconf_scan_bytes(yystr,strlen(yystr) ); +} + +/** Setup the input buffer state to scan the given bytes. The next call to zconflex() will + * scan from a @e copy of @a bytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. + * + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE zconf_scan_bytes (yyconst char * yybytes, int _yybytes_len ) +{ + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = _yybytes_len + 2; + buf = (char *) zconfalloc(n ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in zconf_scan_bytes()" ); + + for ( i = 0; i < _yybytes_len; ++i ) + buf[i] = yybytes[i]; + + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + + b = zconf_scan_buffer(buf,n ); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in zconf_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +static void yy_fatal_error (yyconst char* msg ) +{ + (void) fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up zconftext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + zconftext[zconfleng] = (yy_hold_char); \ + (yy_c_buf_p) = zconftext + yyless_macro_arg; \ + (yy_hold_char) = *(yy_c_buf_p); \ + *(yy_c_buf_p) = '\0'; \ + zconfleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/** Get the current line number. + * + */ +int zconfget_lineno (void) +{ + + return zconflineno; +} + +/** Get the input stream. + * + */ +FILE *zconfget_in (void) +{ + return zconfin; +} + +/** Get the output stream. + * + */ +FILE *zconfget_out (void) +{ + return zconfout; +} + +/** Get the length of the current token. + * + */ +int zconfget_leng (void) +{ + return zconfleng; +} + +/** Get the current token. + * + */ + +char *zconfget_text (void) +{ + return zconftext; +} + +/** Set the current line number. + * @param line_number + * + */ +void zconfset_lineno (int line_number ) +{ + + zconflineno = line_number; +} + +/** Set the input stream. This does not discard the current + * input buffer. + * @param in_str A readable stream. + * + * @see zconf_switch_to_buffer + */ +void zconfset_in (FILE * in_str ) +{ + zconfin = in_str ; +} + +void zconfset_out (FILE * out_str ) +{ + zconfout = out_str ; +} + +int zconfget_debug (void) +{ + return zconf_flex_debug; +} + +void zconfset_debug (int bdebug ) +{ + zconf_flex_debug = bdebug ; +} + +static int yy_init_globals (void) +{ + /* Initialization is the same as for the non-reentrant scanner. + * This function is called from zconflex_destroy(), so don't allocate here. + */ + + (yy_buffer_stack) = 0; + (yy_buffer_stack_top) = 0; + (yy_buffer_stack_max) = 0; + (yy_c_buf_p) = (char *) 0; + (yy_init) = 0; + (yy_start) = 0; + +/* Defined in main.c */ +#ifdef YY_STDINIT + zconfin = stdin; + zconfout = stdout; +#else + zconfin = (FILE *) 0; + zconfout = (FILE *) 0; +#endif + + /* For future reference: Set errno on error, since we are called by + * zconflex_init() + */ + return 0; +} + +/* zconflex_destroy is for both reentrant and non-reentrant scanners. */ +int zconflex_destroy (void) +{ + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + zconf_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + zconfpop_buffer_state(); + } + + /* Destroy the stack itself. */ + zconffree((yy_buffer_stack) ); + (yy_buffer_stack) = NULL; + + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * zconflex() is called, initialization will occur. */ + yy_init_globals( ); + + return 0; +} + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +{ + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * s ) +{ + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *zconfalloc (yy_size_t size ) +{ + return (void *) malloc( size ); +} + +void *zconfrealloc (void * ptr, yy_size_t size ) +{ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); +} + +void zconffree (void * ptr ) +{ + free( (char *) ptr ); /* see zconfrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +void zconf_starthelp(void) +{ + new_string(); + last_ts = first_ts = 0; + BEGIN(HELP); +} + +static void zconf_endhelp(void) +{ + zconflval.string = text; + BEGIN(INITIAL); +} + +/* + * Try to open specified file with following names: + * ./name + * $(srctree)/name + * The latter is used when srctree is separate from objtree + * when compiling the kernel. + * Return NULL if file is not found. + */ +FILE *zconf_fopen(const char *name) +{ + char *env, fullname[PATH_MAX+1]; + FILE *f; + + f = fopen(name, "r"); + if (!f && name != NULL && name[0] != '/') { + env = getenv(SRCTREE); + if (env) { + sprintf(fullname, "%s/%s", env, name); + f = fopen(fullname, "r"); + } + } + return f; +} + +void zconf_initscan(const char *name) +{ + zconfin = zconf_fopen(name); + if (!zconfin) { + printf("can't find file %s\n", name); + exit(1); + } + + current_buf = malloc(sizeof(*current_buf)); + memset(current_buf, 0, sizeof(*current_buf)); + + current_file = file_lookup(name); + current_file->lineno = 1; + current_file->flags = FILE_BUSY; +} + +void zconf_nextfile(const char *name) +{ + struct file *file = file_lookup(name); + struct buffer *buf = malloc(sizeof(*buf)); + memset(buf, 0, sizeof(*buf)); + + current_buf->state = YY_CURRENT_BUFFER; + zconfin = zconf_fopen(file->name); + if (!zconfin) { + printf("%s:%d: can't open file \"%s\"\n", + zconf_curname(), zconf_lineno(), file->name); + exit(1); + } + zconf_switch_to_buffer(zconf_create_buffer(zconfin,YY_BUF_SIZE)); + buf->parent = current_buf; + current_buf = buf; + + if (file->flags & FILE_BUSY) { + printf("%s:%d: do not source '%s' from itself\n", + zconf_curname(), zconf_lineno(), name); + exit(1); + } + if (file->flags & FILE_SCANNED) { + printf("%s:%d: file '%s' is already sourced from '%s'\n", + zconf_curname(), zconf_lineno(), name, + file->parent->name); + exit(1); + } + file->flags |= FILE_BUSY; + file->lineno = 1; + file->parent = current_file; + current_file = file; +} + +static void zconf_endfile(void) +{ + struct buffer *parent; + + current_file->flags |= FILE_SCANNED; + current_file->flags &= ~FILE_BUSY; + current_file = current_file->parent; + + parent = current_buf->parent; + if (parent) { + fclose(zconfin); + zconf_delete_buffer(YY_CURRENT_BUFFER); + zconf_switch_to_buffer(parent->state); + } + free(current_buf); + current_buf = parent; +} + +int zconf_lineno(void) +{ + return current_pos.lineno; +} + +const char *zconf_curname(void) +{ + return current_pos.file ? current_pos.file->name : "<none>"; +} + Index: branches/azimutz/Cleancut/i386/config/cconfig.c =================================================================== --- branches/azimutz/Cleancut/i386/config/cconfig.c (revision 0) +++ branches/azimutz/Cleancut/i386/config/cconfig.c (revision 885) @@ -0,0 +1,866 @@ +/* + * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> + * Released under the terms of the GNU GPL v2.0. + * + * Introduced single menu mode (show all sub-menus in one large tree). + * 2002-11-06 Petr Baudis <pasky@ucw.cz> + * + * i18n, 2005, Arnaldo Carvalho de Melo <acme@conectiva.com.br> + */ + +#include <ctype.h> +#include <errno.h> +#include <fcntl.h> +#include <limits.h> +#include <stdarg.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <locale.h> + +#define LKC_DIRECT_LINK +#include "lkc.h" +#include "lxdialog/dialog.h" + +static const char mconf_readme[] = N_( + "Overview\n" + "--------\n" + "This interface let you select features and parameters for the build.\n" + "Features can either be built-in, modularized, or ignored. Parameters\n" + "must be entered in as decimal or hexadecimal numbers or text.\n" + "\n" + "Menu items beginning with following braces represent features that\n" + " [ ] can be built in or removed\n" + " < > can be built in, modularized or removed\n" + " { } can be built in or modularized (selected by other feature)\n" + " - - are selected by other feature,\n" + "while *, M or whitespace inside braces means to build in, build as\n" + "a module or to exclude the feature respectively.\n" + "\n" + "To change any of these features, highlight it with the cursor\n" + "keys and press <Y> to build it in, <M> to make it a module or\n" + "<N> to removed it. You may also press the <Space Bar> to cycle\n" + "through the available options (ie. Y->N->M->Y).\n" + "\n" + "Some additional keyboard hints:\n" + "\n" + "Menus\n" + "----------\n" + "o Use the Up/Down arrow keys (cursor keys) to highlight the item\n" + " you wish to change or submenu wish to select and press <Enter>.\n" + " Submenus are designated by \"--->\".\n" + "\n" + " Shortcut: Press the option's highlighted letter (hotkey).\n" + " Pressing a hotkey more than once will sequence\n" + " through all visible items which use that hotkey.\n" + "\n" + " You may also use the <PAGE UP> and <PAGE DOWN> keys to scroll\n" + " unseen options into view.\n" + "\n" + "o To exit a menu use the cursor keys to highlight the <Exit> button\n" + " and press <ENTER>.\n" + "\n" + " Shortcut: Press <ESC><ESC> or <E> or <X> if there is no hotkey\n" + " using those letters. You may press a single <ESC>, but\n" + " there is a delayed response which you may find annoying.\n" + "\n" + " Also, the <TAB> and cursor keys will cycle between <Select>,\n" + " <Exit> and <Help>.\n" + "\n" + "o To get help with an item, use the cursor keys to highlight <Help>\n" + " and press <ENTER>.\n" + "\n" + " Shortcut: Press <H> or <?>.\n" + "\n" + "o To toggle the display of hidden options, press <Z>.\n" + "\n" + "\n" + "Radiolists (Choice lists)\n" + "-----------\n" + "o Use the cursor keys to select the option you wish to set and press\n" + " <S> or the <SPACE BAR>.\n" + "\n" + " Shortcut: Press the first letter of the option you wish to set then\n" + " press <S> or <SPACE BAR>.\n" + "\n" + "o To see available help for the item, use the cursor keys to highlight\n" + " <Help> and Press <ENTER>.\n" + "\n" + " Shortcut: Press <H> or <?>.\n" + "\n" + " Also, the <TAB> and cursor keys will cycle between <Select> and\n" + " <Help>\n" + "\n" + "\n" + "Data Entry\n" + "-----------\n" + "o Enter the requested information and press <ENTER>\n" + " If you are entering hexadecimal values, it is not necessary to\n" + " add the '0x' prefix to the entry.\n" + "\n" + "o For help, use the <TAB> or cursor keys to highlight the help option\n" + " and press <ENTER>. You can try <TAB><H> as well.\n" + "\n" + "\n" + "Text Box (Help Window)\n" + "--------\n" + "o Use the cursor keys to scroll up/down/left/right. The VI editor\n" + " keys h,j,k,l function here as do <SPACE BAR> and <B> for those\n" + " who are familiar with less and lynx.\n" + "\n" + "o Press <E>, <X>, <Enter> or <Esc><Esc> to exit.\n" + "\n" + "\n" + "Alternate Configuration Files\n" + "-----------------------------\n" + "Menuconfig supports the use of alternate configuration files for\n" + "those who, for various reasons, find it necessary to switch\n" + "between different configurations.\n" + "\n" + "At the end of the main menu you will find two options. One is\n" + "for saving the current configuration to a file of your choosing.\n" + "The other option is for loading a previously saved alternate\n" + "configuration.\n" + "\n" + "Even if you don't use alternate configuration files, but you\n" + "find during a Menuconfig session that you have completely messed\n" + "up your settings, you may use the \"Load Alternate...\" option to\n" + "restore your previously saved settings from \".config\" without\n" + "restarting Menuconfig.\n" + "\n" + "Other information\n" + "-----------------\n" + "If you use Menuconfig in an XTERM window make sure you have your\n" + "$TERM variable set to point to a xterm definition which supports color.\n" + "Otherwise, Menuconfig will look rather bad. Menuconfig will not\n" + "display correctly in a RXVT window because rxvt displays only one\n" + "intensity of color, bright.\n" + "\n" + "Menuconfig will display larger menus on screens or xterms which are\n" + "set to display more than the standard 25 row by 80 column geometry.\n" + "In order for this to work, the \"stty size\" command must be able to\n" + "display the screen's current row and column geometry. I STRONGLY\n" + "RECOMMEND that you make sure you do NOT have the shell variables\n" + "LINES and COLUMNS exported into your environment. Some distributions\n" + "export those variables via /etc/profile. Some ncurses programs can\n" + "become confused when those variables (LINES & COLUMNS) don't reflect\n" + "the true screen size.\n" + "\n" + "Optional personality available\n" + "------------------------------\n" + "If you prefer to have all of the options listed in a single menu, rather\n" + "than the default multimenu hierarchy, run the menuconfig with\n" + "MENUCONFIG_MODE environment variable set to single_menu. Example:\n" + "\n" + "make MENUCONFIG_MODE=single_menu menuconfig\n" + "\n" + "<Enter> will then unroll the appropriate category, or enfold it if it\n" + "is already unrolled.\n" + "\n" + "Note that this mode can eventually be a little more CPU expensive\n" + "(especially with a larger number of unrolled categories) than the\n" + "default mode.\n" + "\n" + "Different color themes available\n" + "--------------------------------\n" + "It is possible to select different color themes using the variable\n" + "MENUCONFIG_COLOR. To select a theme use:\n" + "\n" + "make MENUCONFIG_COLOR=<theme> menuconfig\n" + "\n" + "Available themes are\n" + " mono => selects colors suitable for monochrome displays\n" + " blackbg => selects a color scheme with black background\n" + " classic => theme with blue background. The classic look\n" + " bluetitle => a LCD friendly version of classic. (default)\n" + "\n"), +menu_instructions[] = N_( + "Arrow keys navigate the menu. " + "<Enter> selects submenus --->. " + "Highlighted letters are hotkeys. " + "Pressing <Y> includes, <N> excludes, <M> modularizes features. " + "Press <Esc><Esc> to exit, <?> for Help, </> for Search. " + "Legend: [*] built-in [ ] excluded <M> module < > module capable"), +radiolist_instructions[] = N_( + "Use the arrow keys to navigate this window or " + "press the hotkey of the item you wish to select " + "followed by the <SPACE BAR>. " + "Press <?> for additional information about this option."), +inputbox_instructions_int[] = N_( + "Please enter a decimal value. " + "Fractions will not be accepted. " + "Use the <TAB> key to move from the input field to the buttons below it."), +inputbox_instructions_hex[] = N_( + "Please enter a hexadecimal value. " + "Use the <TAB> key to move from the input field to the buttons below it."), +inputbox_instructions_string[] = N_( + "Please enter a string value. " + "Use the <TAB> key to move from the input field to the buttons below it."), +setmod_text[] = N_( + "This feature depends on another which has been configured as a module.\n" + "As a result, this feature will be built as a module."), +load_config_text[] = N_( + "Enter the name of the configuration file you wish to load. " + "Accept the name shown to restore the configuration you " + "last retrieved. Leave blank to abort."), +load_config_help[] = N_( + "\n" + "For various reasons, one may wish to keep several different\n" + "configurations available on a single machine.\n" + "\n" + "If you have saved a previous configuration in a file other than the\n" + "default one, entering its name here will allow you to modify that\n" + "configuration.\n" + "\n" + "If you are uncertain, then you have probably never used alternate\n" + "configuration files. You should therefore leave this blank to abort.\n"), +save_config_text[] = N_( + "Enter a filename to which this configuration should be saved " + "as an alternate. Leave blank to abort."), +save_config_help[] = N_( + "\n" + "For various reasons, one may wish to keep different configurations\n" + "available on a single machine.\n" + "\n" + "Entering a file name here will allow you to later retrieve, modify\n" + "and use the current configuration as an alternate to whatever\n" + "configuration options you have selected at that time.\n" + "\n" + "If you are uncertain what all this means then you should probably\n" + "leave this blank.\n"), +search_help[] = N_( + "\n" + "Search for symbols and display their relations.\n" + "Regular expressions are allowed.\n" + "Example: search for \"^FOO\"\n" + "Result:\n" + "-----------------------------------------------------------------\n" + "Symbol: FOO [=m]\n" + "Prompt: Foo bus is used to drive the bar HW\n" + "Defined at drivers/pci/Kconfig:47\n" + "Depends on: X86_LOCAL_APIC && X86_IO_APIC || IA64\n" + "Location:\n" + " -> Bus options (PCI, PCMCIA, EISA, MCA, ISA)\n" + " -> PCI support (PCI [=y])\n" + " -> PCI access mode (<choice> [=y])\n" + "Selects: LIBCRC32\n" + "Selected by: BAR\n" + "-----------------------------------------------------------------\n" + "o The line 'Prompt:' shows the text used in the menu structure for\n" + " this symbol\n" + "o The 'Defined at' line tell at what file / line number the symbol\n" + " is defined\n" + "o The 'Depends on:' line tell what symbols needs to be defined for\n" + " this symbol to be visible in the menu (selectable)\n" + "o The 'Location:' lines tell where in the menu structure this symbol\n" + " is located\n" + " A location followed by a [=y] indicate that this is a selectable\n" + " menu item - and current value is displayed inside brackets.\n" + "o The 'Selects:' line tell what symbol will be automatically\n" + " selected if this symbol is selected (y or m)\n" + "o The 'Selected by' line tell what symbol has selected this symbol\n" + "\n" + "Only relevant lines are shown.\n" + "\n\n" + "Search examples:\n" + "Examples: USB => find all symbols containing USB\n" + " ^USB => find all symbols starting with USB\n" + " USB$ => find all symbols ending with USB\n" + "\n"); + +static int indent; +static struct menu *current_menu; +static int child_count; +static int single_menu_mode; +static int show_all_options; + +static void conf(struct menu *menu); +static void conf_choice(struct menu *menu); +static void conf_string(struct menu *menu); +static void conf_load(void); +static void conf_save(void); +static void show_textbox(const char *title, const char *text, int r, int c); +static void show_helptext(const char *title, const char *text); +static void show_help(struct menu *menu); + +static char filename[PATH_MAX+1]; +static void set_config_filename(const char *config_filename) +{ + static char menu_backtitle[PATH_MAX+128]; + int size; + + size = snprintf(menu_backtitle, sizeof(menu_backtitle), + "%s - %s", config_filename, rootmenu.prompt->text); + if (size >= sizeof(menu_backtitle)) + menu_backtitle[sizeof(menu_backtitle)-1] = '\0'; + set_dialog_backtitle(menu_backtitle); + + size = snprintf(filename, sizeof(filename), "%s", config_filename); + if (size >= sizeof(filename)) + filename[sizeof(filename)-1] = '\0'; +} + + +static void search_conf(void) +{ + struct symbol **sym_arr; + struct gstr res; + char *dialog_input; + int dres; +again: + dialog_clear(); + dres = dialog_inputbox(_("Search Configuration Parameter"), + _("Enter " CONFIG_ " (sub)string to search for " + "(with or without \"" CONFIG_ "\")"), + 10, 75, ""); + switch (dres) { + case 0: + break; + case 1: + show_helptext(_("Search Configuration"), search_help); + goto again; + default: + return; + } + + /* strip the prefix if necessary */ + dialog_input = dialog_input_result; + if (strncasecmp(dialog_input_result, CONFIG_, strlen(CONFIG_)) == 0) + dialog_input += strlen(CONFIG_); + + sym_arr = sym_re_search(dialog_input); + res = get_relations_str(sym_arr); + free(sym_arr); + show_textbox(_("Search Results"), str_get(&res), 0, 0); + str_free(&res); +} + +static void build_conf(struct menu *menu) +{ + struct symbol *sym; + struct property *prop; + struct menu *child; + int type, tmp, doint = 2; + tristate val; + char ch; + bool visible; + + /* + * note: menu_is_visible() has side effect that it will + * recalc the value of the symbol. + */ + visible = menu_is_visible(menu); + if (show_all_options && !menu_has_prompt(menu)) + return; + else if (!show_all_options && !visible) + return; + + sym = menu->sym; + prop = menu->prompt; + if (!sym) { + if (prop && menu != current_menu) { + const char *prompt = menu_get_prompt(menu); + switch (prop->type) { + case P_MENU: + child_count++; + prompt = _(prompt); + if (single_menu_mode) { + item_make("%s%*c%s", + menu->data ? "-->" : "++>", + indent + 1, ' ', prompt); + } else + item_make(" %*c%s --->", indent + 1, ' ', prompt); + + item_set_tag('m'); + item_set_data(menu); + if (single_menu_mode && menu->data) + goto conf_childs; + return; + case P_COMMENT: + if (prompt) { + child_count++; + item_make(" %*c*** %s ***", indent + 1, ' ', _(prompt)); + item_set_tag(':'); + item_set_data(menu); + } + break; + default: + if (prompt) { + child_count++; + item_make("---%*c%s", indent + 1, ' ', _(prompt)); + item_set_tag(':'); + item_set_data(menu); + } + } + } else + doint = 0; + goto conf_childs; + } + + type = sym_get_type(sym); + if (sym_is_choice(sym)) { + struct symbol *def_sym = sym_get_choice_value(sym); + struct menu *def_menu = NULL; + + child_count++; + for (child = menu->list; child; child = child->next) { + if (menu_is_visible(child) && child->sym == def_sym) + def_menu = child; + } + + val = sym_get_tristate_value(sym); + if (sym_is_changable(sym)) { + switch (type) { + case S_BOOLEAN: + item_make("[%c]", val == no ? ' ' : '*'); + break; + case S_TRISTATE: + switch (val) { + case yes: ch = '*'; break; + case mod: ch = 'M'; break; + default: ch = ' '; break; + } + item_make("<%c>", ch); + break; + } + item_set_tag('t'); + item_set_data(menu); + } else { + item_make(" "); + item_set_tag(def_menu ? 't' : ':'); + item_set_data(menu); + } + + item_add_str("%*c%s", indent + 1, ' ', _(menu_get_prompt(menu))); + if (val == yes) { + if (def_menu) { + item_add_str(" (%s)", _(menu_get_prompt(def_menu))); + item_add_str(" --->"); + if (def_menu->list) { + indent += 2; + build_conf(def_menu); + indent -= 2; + } + } + return; + } + } else { + if (menu == current_menu) { + item_make("---%*c%s", indent + 1, ' ', _(menu_get_prompt(menu))); + item_set_tag(':'); + item_set_data(menu); + goto conf_childs; + } + child_count++; + val = sym_get_tristate_value(sym); + if (sym_is_choice_value(sym) && val == yes) { + item_make(" "); + item_set_tag(':'); + item_set_data(menu); + } else { + switch (type) { + case S_BOOLEAN: + if (sym_is_changable(sym)) + item_make("[%c]", val == no ? ' ' : '*'); + else + item_make("-%c-", val == no ? ' ' : '*'); + item_set_tag('t'); + item_set_data(menu); + break; + case S_TRISTATE: + switch (val) { + case yes: ch = '*'; break; + case mod: ch = 'M'; break; + default: ch = ' '; break; + } + if (sym_is_changable(sym)) { + if (sym->rev_dep.tri == mod) + item_make("{%c}", ch); + else + item_make("<%c>", ch); + } else + item_make("-%c-", ch); + item_set_tag('t'); + item_set_data(menu); + break; + default: + tmp = 2 + strlen(sym_get_string_value(sym)); /* () = 2 */ + item_make("(%s)", sym_get_string_value(sym)); + tmp = indent - tmp + 4; + if (tmp < 0) + tmp = 0; + item_add_str("%*c%s%s", tmp, ' ', _(menu_get_prompt(menu)), + (sym_has_value(sym) || !sym_is_changable(sym)) ? + "" : _(" (NEW)")); + item_set_tag('s'); + item_set_data(menu); + goto conf_childs; + } + } + item_add_str("%*c%s%s", indent + 1, ' ', _(menu_get_prompt(menu)), + (sym_has_value(sym) || !sym_is_changable(sym)) ? + "" : _(" (NEW)")); + if (menu->prompt->type == P_MENU) { + item_add_str(" --->"); + return; + } + } + +conf_childs: + indent += doint; + for (child = menu->list; child; child = child->next) + build_conf(child); + indent -= doint; +} + +static void conf(struct menu *menu) +{ + struct menu *submenu; + const char *prompt = menu_get_prompt(menu); + struct symbol *sym; + struct menu *active_menu = NULL; + int res; + int s_scroll = 0; + + while (1) { + item_reset(); + current_menu = menu; + build_conf(menu); + if (!child_count) + break; + if (menu == &rootmenu) { + item_make("--- "); + item_set_tag(':'); + item_make(_(" Load an Alternate Configuration File")); + item_set_tag('L'); + item_make(_(" Save an Alternate Configuration File")); + item_set_tag('S'); + } + dialog_clear(); + res = dialog_menu(prompt ? _(prompt) : _("Main Menu"), + _(menu_instructions), + active_menu, &s_scroll); + if (res == 1 || res == KEY_ESC || res == -ERRDISPLAYTOOSMALL) + break; + if (!item_activate_selected()) + continue; + if (!item_tag()) + continue; + + submenu = item_data(); + active_menu = item_data(); + if (submenu) + sym = submenu->sym; + else + sym = NULL; + + switch (res) { + case 0: + switch (item_tag()) { + case 'm': + if (single_menu_mode) + submenu->data = (void *) (long) !submenu->data; + else + conf(submenu); + break; + case 't': + if (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes) + conf_choice(submenu); + else if (submenu->prompt->type == P_MENU) + conf(submenu); + break; + case 's': + conf_string(submenu); + break; + case 'L': + conf_load(); + break; + case 'S': + conf_save(); + break; + } + break; + case 2: + if (sym) + show_help(submenu); + else + show_helptext(_("README"), _(mconf_readme)); + break; + case 3: + if (item_is_tag('t')) { + if (sym_set_tristate_value(sym, yes)) + break; + if (sym_set_tristate_value(sym, mod)) + show_textbox(NULL, setmod_text, 6, 74); + } + break; + case 4: + if (item_is_tag('t')) + sym_set_tristate_value(sym, no); + break; + case 5: + if (item_is_tag('t')) + sym_set_tristate_value(sym, mod); + break; + case 6: + if (item_is_tag('t')) + sym_toggle_tristate_value(sym); + else if (item_is_tag('m')) + conf(submenu); + break; + case 7: + search_conf(); + break; + case 8: + show_all_options = !show_all_options; + break; + } + } +} + +static void show_textbox(const char *title, const char *text, int r, int c) +{ + dialog_clear(); + dialog_textbox(title, text, r, c); +} + +static void show_helptext(const char *title, const char *text) +{ + show_textbox(title, text, 0, 0); +} + +static void show_help(struct menu *menu) +{ + struct gstr help = str_new(); + + help.max_width = getmaxx(stdscr) - 10; + menu_get_ext_help(menu, &help); + + show_helptext(_(menu_get_prompt(menu)), str_get(&help)); + str_free(&help); +} + +static void conf_choice(struct menu *menu) +{ + const char *prompt = _(menu_get_prompt(menu)); + struct menu *child; + struct symbol *active; + + active = sym_get_choice_value(menu->sym); + while (1) { + int res; + int selected; + item_reset(); + + current_menu = menu; + for (child = menu->list; child; child = child->next) { + if (!menu_is_visible(child)) + continue; + if (child->sym) + item_make("%s", _(menu_get_prompt(child))); + else { + item_make("*** %s ***", _(menu_get_prompt(child))); + item_set_tag(':'); + } + item_set_data(child); + if (child->sym == active) + item_set_selected(1); + if (child->sym == sym_get_choice_value(menu->sym)) + item_set_tag('X'); + } + dialog_clear(); + res = dialog_checklist(prompt ? _(prompt) : _("Main Menu"), + _(radiolist_instructions), + 15, 70, 6); + selected = item_activate_selected(); + switch (res) { + case 0: + if (selected) { + child = item_data(); + if (!child->sym) + break; + + sym_set_tristate_value(child->sym, yes); + } + return; + case 1: + if (selected) { + child = item_data(); + show_help(child); + active = child->sym; + } else + show_help(menu); + break; + case KEY_ESC: + return; + case -ERRDISPLAYTOOSMALL: + return; + } + } +} + +static void conf_string(struct menu *menu) +{ + const char *prompt = menu_get_prompt(menu); + + while (1) { + int res; + const char *heading; + + switch (sym_get_type(menu->sym)) { + case S_INT: + heading = _(inputbox_instructions_int); + break; + case S_HEX: + heading = _(inputbox_instructions_hex); + break; + case S_STRING: + heading = _(inputbox_instructions_string); + break; + default: + heading = _("Internal mconf error!"); + } + dialog_clear(); + res = dialog_inputbox(prompt ? _(prompt) : _("Main Menu"), + heading, 10, 75, + sym_get_string_value(menu->sym)); + switch (res) { + case 0: + if (sym_set_string_value(menu->sym, dialog_input_result)) + return; + show_textbox(NULL, _("You have made an invalid entry."), 5, 43); + break; + case 1: + show_help(menu); + break; + case KEY_ESC: + return; + } + } +} + +static void conf_load(void) +{ + + while (1) { + int res; + dialog_clear(); + res = dialog_inputbox(NULL, load_config_text, + 11, 55, filename); + switch(res) { + case 0: + if (!dialog_input_result[0]) + return; + if (!conf_read(dialog_input_result)) { + set_config_filename(dialog_input_result); + sym_set_change_count(1); + return; + } + show_textbox(NULL, _("File does not exist!"), 5, 38); + break; + case 1: + show_helptext(_("Load Alternate Configuration"), load_config_help); + break; + case KEY_ESC: + return; + } + } +} + +static void conf_save(void) +{ + while (1) { + int res; + dialog_clear(); + res = dialog_inputbox(NULL, save_config_text, + 11, 55, filename); + switch(res) { + case 0: + if (!dialog_input_result[0]) + return; + if (!conf_write(dialog_input_result)) { + set_config_filename(dialog_input_result); + return; + } + show_textbox(NULL, _("Can't create file! Probably a nonexistent directory."), 5, 60); + break; + case 1: + show_helptext(_("Save Alternate Configuration"), save_config_help); + break; + case KEY_ESC: + return; + } + } + +} + +int main(int ac, char **av) +{ + int saved_x, saved_y; + char *mode; + int res; + + setlocale(LC_ALL, ""); + bindtextdomain(PACKAGE, LOCALEDIR); + textdomain(PACKAGE); + + conf_parse(av[1]); + conf_read(NULL); + + mode = getenv("MENUCONFIG_MODE"); + if (mode) { + if (!strcasecmp(mode, "single_menu")) + single_menu_mode = 1; + } + + initscr(); + + getyx(stdscr, saved_y, saved_x); + if (init_dialog(NULL)) { + fprintf(stderr, N_("Your display is too small to run Menuconfig!\n")); + fprintf(stderr, N_("It must be at least 19 lines by 80 columns.\n")); + return 1; + } + + set_config_filename(conf_get_configname()); + do { + conf(&rootmenu); + dialog_clear(); + if (conf_get_changed()) + res = dialog_yesno(NULL, + _("Do you wish to save your " + "new configuration?\n" + "<ESC><ESC> to continue."), + 6, 60); + else + res = -1; + } while (res == KEY_ESC); + end_dialog(saved_x, saved_y); + + switch (res) { + case 0: + if (conf_write(filename)) { + fprintf(stderr, _("\n\n" + "Error while writing of the configuration.\n" + "Your configuration changes were NOT saved." + "\n\n")); + return 1; + } + case -1: + printf(_("\n\n" + "*** End of the configuration.\n" + "*** Execute 'make' to start the build or try 'make help'." + "\n\n")); + break; + default: + fprintf(stderr, _("\n\n" + "Your configuration changes were NOT saved." + "\n\n")); + } + + // Output headers + files needed by the make system + conf_write_autoconf(); + + return 0; +} + Index: branches/azimutz/Cleancut/i386/config/inputbox.c =================================================================== --- branches/azimutz/Cleancut/i386/config/inputbox.c (revision 0) +++ branches/azimutz/Cleancut/i386/config/inputbox.c (revision 885) @@ -0,0 +1,238 @@ +/* + * inputbox.c -- implements the input box + * + * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) + * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "dialog.h" + +char dialog_input_result[MAX_LEN + 1]; + +/* + * Print the termination buttons + */ +static void print_buttons(WINDOW * dialog, int height, int width, int selected) +{ + int x = width / 2 - 11; + int y = height - 2; + + print_button(dialog, gettext(" Ok "), y, x, selected == 0); + print_button(dialog, gettext(" Help "), y, x + 14, selected == 1); + + wmove(dialog, y, x + 1 + 14 * selected); + wrefresh(dialog); +} + +/* + * Display a dialog box for inputing a string + */ +int dialog_inputbox(const char *title, const char *prompt, int height, int width, + const char *init) +{ + int i, x, y, box_y, box_x, box_width; + int input_x = 0, scroll = 0, key = 0, button = -1; + char *instr = dialog_input_result; + WINDOW *dialog; + + if (!init) + instr[0] = '\0'; + else + strcpy(instr, init); + +do_resize: + if (getmaxy(stdscr) <= (height - 2)) + return -ERRDISPLAYTOOSMALL; + if (getmaxx(stdscr) <= (width - 2)) + return -ERRDISPLAYTOOSMALL; + + /* center dialog box on screen */ + x = (COLS - width) / 2; + y = (LINES - height) / 2; + + draw_shadow(stdscr, y, x, height, width); + + dialog = newwin(height, width, y, x); + keypad(dialog, TRUE); + + draw_box(dialog, 0, 0, height, width, + dlg.dialog.atr, dlg.border.atr); + wattrset(dialog, dlg.border.atr); + mvwaddch(dialog, height - 3, 0, ACS_LTEE); + for (i = 0; i < width - 2; i++) + waddch(dialog, ACS_HLINE); + wattrset(dialog, dlg.dialog.atr); + waddch(dialog, ACS_RTEE); + + print_title(dialog, title, width); + + wattrset(dialog, dlg.dialog.atr); + print_autowrap(dialog, prompt, width - 2, 1, 3); + + /* Draw the input field box */ + box_width = width - 6; + getyx(dialog, y, x); + box_y = y + 2; + box_x = (width - box_width) / 2; + draw_box(dialog, y + 1, box_x - 1, 3, box_width + 2, + dlg.dialog.atr, dlg.border.atr); + + print_buttons(dialog, height, width, 0); + + /* Set up the initial value */ + wmove(dialog, box_y, box_x); + wattrset(dialog, dlg.inputbox.atr); + + input_x = strlen(instr); + + if (input_x >= box_width) { + scroll = input_x - box_width + 1; + input_x = box_width - 1; + for (i = 0; i < box_width - 1; i++) + waddch(dialog, instr[scroll + i]); + } else { + waddstr(dialog, instr); + } + + wmove(dialog, box_y, box_x + input_x); + + wrefresh(dialog); + + while (key != KEY_ESC) { + key = wgetch(dialog); + + if (button == -1) { /* Input box selected */ + switch (key) { + case TAB: + case KEY_UP: + case KEY_DOWN: + break; + case KEY_LEFT: + continue; + case KEY_RIGHT: + continue; + case KEY_BACKSPACE: + case 127: + if (input_x || scroll) { + wattrset(dialog, dlg.inputbox.atr); + if (!input_x) { + scroll = scroll < box_width - 1 ? 0 : scroll - (box_width - 1); + wmove(dialog, box_y, box_x); + for (i = 0; i < box_width; i++) + waddch(dialog, + instr[scroll + input_x + i] ? + instr[scroll + input_x + i] : ' '); + input_x = strlen(instr) - scroll; + } else + input_x--; + instr[scroll + input_x] = '\0'; + mvwaddch(dialog, box_y, input_x + box_x, ' '); + wmove(dialog, box_y, input_x + box_x); + wrefresh(dialog); + } + continue; + default: + if (key < 0x100 && isprint(key)) { + if (scroll + input_x < MAX_LEN) { + wattrset(dialog, dlg.inputbox.atr); + instr[scroll + input_x] = key; + instr[scroll + input_x + 1] = '\0'; + if (input_x == box_width - 1) { + scroll++; + wmove(dialog, box_y, box_x); + for (i = 0; i < box_width - 1; i++) + waddch(dialog, instr [scroll + i]); + } else { + wmove(dialog, box_y, input_x++ + box_x); + waddch(dialog, key); + } + wrefresh(dialog); + } else + flash(); /* Alarm user about overflow */ + continue; + } + } + } + switch (key) { + case 'O': + case 'o': + delwin(dialog); + return 0; + case 'H': + case 'h': + delwin(dialog); + return 1; + case KEY_UP: + case KEY_LEFT: + switch (button) { + case -1: + button = 1; /* Indicates "Help" button is selected */ + print_buttons(dialog, height, width, 1); + break; + case 0: + button = -1; /* Indicates input box is selected */ + print_buttons(dialog, height, width, 0); + wmove(dialog, box_y, box_x + input_x); + wrefresh(dialog); + break; + case 1: + button = 0; /* Indicates "OK" button is selected */ + print_buttons(dialog, height, width, 0); + break; + } + break; + case TAB: + case KEY_DOWN: + case KEY_RIGHT: + switch (button) { + case -1: + button = 0; /* Indicates "OK" button is selected */ + print_buttons(dialog, height, width, 0); + break; + case 0: + button = 1; /* Indicates "Help" button is selected */ + print_buttons(dialog, height, width, 1); + break; + case 1: + button = -1; /* Indicates input box is selected */ + print_buttons(dialog, height, width, 0); + wmove(dialog, box_y, box_x + input_x); + wrefresh(dialog); + break; + } + break; + case ' ': + case '\n': + delwin(dialog); + return (button == -1 ? 0 : button); + case 'X': + case 'x': + key = KEY_ESC; + break; + case KEY_ESC: + key = on_key_esc(dialog); + break; + case KEY_RESIZE: + delwin(dialog); + on_key_resize(); + goto do_resize; + } + } + + delwin(dialog); + return KEY_ESC; /* ESC pressed */ +} Index: branches/azimutz/Cleancut/i386/config/nconf.h =================================================================== --- branches/azimutz/Cleancut/i386/config/nconf.h (revision 0) +++ branches/azimutz/Cleancut/i386/config/nconf.h (revision 885) @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2008 Nir Tzachar <nir.tzachar@gmail.com? + * Released under the terms of the GNU GPL v2.0. + * + * Derived from menuconfig. + * + */ + +#include <ctype.h> +#include <errno.h> +#include <fcntl.h> +#include <limits.h> +#include <stdarg.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <locale.h> +#include <curses.h> +#include <menu.h> +#include <panel.h> +#include <form.h> + +#include <stdio.h> +#include <time.h> +#include <sys/time.h> + +#include "ncurses.h" + +#define max(a, b) ({\ + typeof(a) _a = a;\ + typeof(b) _b = b;\ + _a > _b ? _a : _b; }) + +#define min(a, b) ({\ + typeof(a) _a = a;\ + typeof(b) _b = b;\ + _a < _b ? _a : _b; }) + +typedef enum { + NORMAL = 1, + MAIN_HEADING, + MAIN_MENU_BOX, + MAIN_MENU_FORE, + MAIN_MENU_BACK, + MAIN_MENU_GREY, + MAIN_MENU_HEADING, + SCROLLWIN_TEXT, + SCROLLWIN_HEADING, + SCROLLWIN_BOX, + DIALOG_TEXT, + DIALOG_MENU_FORE, + DIALOG_MENU_BACK, + DIALOG_BOX, + INPUT_BOX, + INPUT_HEADING, + INPUT_TEXT, + INPUT_FIELD, + FUNCTION_TEXT, + FUNCTION_HIGHLIGHT, + ATTR_MAX +} attributes_t; +extern attributes_t attributes[]; + +typedef enum { + F_HELP = 1, + F_SYMBOL = 2, + F_INSTS = 3, + F_CONF = 4, + F_BACK = 5, + F_SAVE = 6, + F_LOAD = 7, + F_SEARCH = 8, + F_EXIT = 9, +} function_key; + +void set_colors(void); + +/* this changes the windows attributes !!! */ +void print_in_middle(WINDOW *win, + int starty, + int startx, + int width, + const char *string, + chtype color); +int get_line_length(const char *line); +int get_line_no(const char *text); +const char *get_line(const char *text, int line_no); +void fill_window(WINDOW *win, const char *text); +int btn_dialog(WINDOW *main_window, const char *msg, int btn_num, ...); +int dialog_inputbox(WINDOW *main_window, + const char *title, const char *prompt, + const char *init, char *result, int result_len); +void refresh_all_windows(WINDOW *main_window); +void show_scroll_win(WINDOW *main_window, + const char *title, + const char *text); Index: branches/azimutz/Cleancut/i386/config/checklist.c =================================================================== --- branches/azimutz/Cleancut/i386/config/checklist.c (revision 0) +++ branches/azimutz/Cleancut/i386/config/checklist.c (revision 885) @@ -0,0 +1,332 @@ +/* + * checklist.c -- implements the checklist box + * + * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) + * Stuart Herbert - S.Herbert@sheffield.ac.uk: radiolist extension + * Alessandro Rubini - rubini@ipvvis.unipv.it: merged the two + * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "dialog.h" + +static int list_width, check_x, item_x; + +/* + * Print list item + */ +static void print_item(WINDOW * win, int choice, int selected) +{ + int i; + char *list_item = malloc(list_width + 1); + + strncpy(list_item, item_str(), list_width - item_x); + list_item[list_width - item_x] = '\0'; + + /* Clear 'residue' of last item */ + wattrset(win, dlg.menubox.atr); + wmove(win, choice, 0); + for (i = 0; i < list_width; i++) + waddch(win, ' '); + + wmove(win, choice, check_x); + wattrset(win, selected ? dlg.check_selected.atr + : dlg.check.atr); + if (!item_is_tag(':')) + wprintw(win, "(%c)", item_is_tag('X') ? 'X' : ' '); + + wattrset(win, selected ? dlg.tag_selected.atr : dlg.tag.atr); + mvwaddch(win, choice, item_x, list_item[0]); + wattrset(win, selected ? dlg.item_selected.atr : dlg.item.atr); + waddstr(win, list_item + 1); + if (selected) { + wmove(win, choice, check_x + 1); + wrefresh(win); + } + free(list_item); +} + +/* + * Print the scroll indicators. + */ +static void print_arrows(WINDOW * win, int choice, int item_no, int scroll, + int y, int x, int height) +{ + wmove(win, y, x); + + if (scroll > 0) { + wattrset(win, dlg.uarrow.atr); + waddch(win, ACS_UARROW); + waddstr(win, "(-)"); + } else { + wattrset(win, dlg.menubox.atr); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + } + + y = y + height + 1; + wmove(win, y, x); + + if ((height < item_no) && (scroll + choice < item_no - 1)) { + wattrset(win, dlg.darrow.atr); + waddch(win, ACS_DARROW); + waddstr(win, "(+)"); + } else { + wattrset(win, dlg.menubox_border.atr); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + } +} + +/* + * Display the termination buttons + */ +static void print_buttons(WINDOW * dialog, int height, int width, int selected) +{ + int x = width / 2 - 11; + int y = height - 2; + + print_button(dialog, gettext("Select"), y, x, selected == 0); + print_button(dialog, gettext(" Help "), y, x + 14, selected == 1); + + wmove(dialog, y, x + 1 + 14 * selected); + wrefresh(dialog); +} + +/* + * Display a dialog box with a list of options that can be turned on or off + * in the style of radiolist (only one option turned on at a time). + */ +int dialog_checklist(const char *title, const char *prompt, int height, + int width, int list_height) +{ + int i, x, y, box_x, box_y; + int key = 0, button = 0, choice = 0, scroll = 0, max_choice; + WINDOW *dialog, *list; + + /* which item to highlight */ + item_foreach() { + if (item_is_tag('X')) + choice = item_n(); + if (item_is_selected()) { + choice = item_n(); + break; + } + } + +do_resize: + if (getmaxy(stdscr) < (height + 6)) + return -ERRDISPLAYTOOSMALL; + if (getmaxx(stdscr) < (width + 6)) + return -ERRDISPLAYTOOSMALL; + + max_choice = MIN(list_height, item_count()); + + /* center dialog box on screen */ + x = (COLS - width) / 2; + y = (LINES - height) / 2; + + draw_shadow(stdscr, y, x, height, width); + + dialog = newwin(height, width, y, x); + keypad(dialog, TRUE); + + draw_box(dialog, 0, 0, height, width, + dlg.dialog.atr, dlg.border.atr); + wattrset(dialog, dlg.border.atr); + mvwaddch(dialog, height - 3, 0, ACS_LTEE); + for (i = 0; i < width - 2; i++) + waddch(dialog, ACS_HLINE); + wattrset(dialog, dlg.dialog.atr); + waddch(dialog, ACS_RTEE); + + print_title(dialog, title, width); + + wattrset(dialog, dlg.dialog.atr); + print_autowrap(dialog, prompt, width - 2, 1, 3); + + list_width = width - 6; + box_y = height - list_height - 5; + box_x = (width - list_width) / 2 - 1; + + /* create new window for the list */ + list = subwin(dialog, list_height, list_width, y + box_y + 1, + x + box_x + 1); + + keypad(list, TRUE); + + /* draw a box around the list items */ + draw_box(dialog, box_y, box_x, list_height + 2, list_width + 2, + dlg.menubox_border.atr, dlg.menubox.atr); + + /* Find length of longest item in order to center checklist */ + check_x = 0; + item_foreach() + check_x = MAX(check_x, strlen(item_str()) + 4); + check_x = MIN(check_x, list_width); + + check_x = (list_width - check_x) / 2; + item_x = check_x + 4; + + if (choice >= list_height) { + scroll = choice - list_height + 1; + choice -= scroll; + } + + /* Print the list */ + for (i = 0; i < max_choice; i++) { + item_set(scroll + i); + print_item(list, i, i == choice); + } + + print_arrows(dialog, choice, item_count(), scroll, + box_y, box_x + check_x + 5, list_height); + + print_buttons(dialog, height, width, 0); + + wnoutrefresh(dialog); + wnoutrefresh(list); + doupdate(); + + while (key != KEY_ESC) { + key = wgetch(dialog); + + for (i = 0; i < max_choice; i++) { + item_set(i + scroll); + if (toupper(key) == toupper(item_str()[0])) + break; + } + + if (i < max_choice || key == KEY_UP || key == KEY_DOWN || + key == '+' || key == '-') { + if (key == KEY_UP || key == '-') { + if (!choice) { + if (!scroll) + continue; + /* Scroll list down */ + if (list_height > 1) { + /* De-highlight current first item */ + item_set(scroll); + print_item(list, 0, FALSE); + scrollok(list, TRUE); + wscrl(list, -1); + scrollok(list, FALSE); + } + scroll--; + item_set(scroll); + print_item(list, 0, TRUE); + print_arrows(dialog, choice, item_count(), + scroll, box_y, box_x + check_x + 5, list_height); + + wnoutrefresh(dialog); + wrefresh(list); + + continue; /* wait for another key press */ + } else + i = choice - 1; + } else if (key == KEY_DOWN || key == '+') { + if (choice == max_choice - 1) { + if (scroll + choice >= item_count() - 1) + continue; + /* Scroll list up */ + if (list_height > 1) { + /* De-highlight current last item before scrolling up */ + item_set(scroll + max_choice - 1); + print_item(list, + max_choice - 1, + FALSE); + scrollok(list, TRUE); + wscrl(list, 1); + scrollok(list, FALSE); + } + scroll++; + item_set(scroll + max_choice - 1); + print_item(list, max_choice - 1, TRUE); + + print_arrows(dialog, choice, item_count(), + scroll, box_y, box_x + check_x + 5, list_height); + + wnoutrefresh(dialog); + wrefresh(list); + + continue; /* wait for another key press */ + } else + i = choice + 1; + } + if (i != choice) { + /* De-highlight current item */ + item_set(scroll + choice); + print_item(list, choice, FALSE); + /* Highlight new item */ + choice = i; + item_set(scroll + choice); + print_item(list, choice, TRUE); + wnoutrefresh(dialog); + wrefresh(list); + } + continue; /* wait for another key press */ + } + switch (key) { + case 'H': + case 'h': + case '?': + button = 1; + /* fall-through */ + case 'S': + case 's': + case ' ': + case '\n': + item_foreach() + item_set_selected(0); + item_set(scroll + choice); + item_set_selected(1); + delwin(list); + delwin(dialog); + return button; + case TAB: + case KEY_LEFT: + case KEY_RIGHT: + button = ((key == KEY_LEFT ? --button : ++button) < 0) + ? 1 : (button > 1 ? 0 : button); + + print_buttons(dialog, height, width, button); + wrefresh(dialog); + break; + case 'X': + case 'x': + key = KEY_ESC; + break; + case KEY_ESC: + key = on_key_esc(dialog); + break; + case KEY_RESIZE: + delwin(list); + delwin(dialog); + on_key_resize(); + goto do_resize; + } + + /* Now, update everything... */ + doupdate(); + } + delwin(list); + delwin(dialog); + return key; /* ESC pressed */ +} Index: branches/azimutz/Cleancut/i386/config/util.c =================================================================== --- branches/azimutz/Cleancut/i386/config/util.c (revision 0) +++ branches/azimutz/Cleancut/i386/config/util.c (revision 885) @@ -0,0 +1,796 @@ +/* + * util.c + * + * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) + * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include <stdarg.h> + +#include "dialog.h" + +struct dialog_info dlg; + +static void set_mono_theme(void) +{ + dlg.screen.atr = A_NORMAL; + dlg.shadow.atr = A_NORMAL; + dlg.dialog.atr = A_NORMAL; + dlg.title.atr = A_BOLD; + dlg.border.atr = A_NORMAL; + dlg.button_active.atr = A_REVERSE; + dlg.button_inactive.atr = A_DIM; + dlg.button_key_active.atr = A_REVERSE; + dlg.button_key_inactive.atr = A_BOLD; + dlg.button_label_active.atr = A_REVERSE; + dlg.button_label_inactive.atr = A_NORMAL; + dlg.inputbox.atr = A_NORMAL; + dlg.inputbox_border.atr = A_NORMAL; + dlg.searchbox.atr = A_NORMAL; + dlg.searchbox_title.atr = A_BOLD; + dlg.searchbox_border.atr = A_NORMAL; + dlg.position_indicator.atr = A_BOLD; + dlg.menubox.atr = A_NORMAL; + dlg.menubox_border.atr = A_NORMAL; + dlg.item.atr = A_NORMAL; + dlg.item_selected.atr = A_REVERSE; + dlg.tag.atr = A_BOLD; + dlg.tag_selected.atr = A_REVERSE; + dlg.tag_key.atr = A_BOLD; + dlg.tag_key_selected.atr = A_REVERSE; + dlg.check.atr = A_BOLD; + dlg.check_selected.atr = A_REVERSE; + dlg.uarrow.atr = A_BOLD; + dlg.darrow.atr = A_BOLD; +} + +#define DLG_COLOR(dialog, f, b, h) \ +do { \ + dlg.dialog.fg = (f); \ + dlg.dialog.bg = (b); \ + dlg.dialog.hl = (h); \ +} while (0) + +static void set_classic_theme(void) +{ + DLG_COLOR(screen, COLOR_CYAN, COLOR_BLUE, true); + DLG_COLOR(shadow, COLOR_BLACK, COLOR_BLACK, true); + DLG_COLOR(dialog, COLOR_BLACK, COLOR_WHITE, false); + DLG_COLOR(title, COLOR_YELLOW, COLOR_WHITE, true); + DLG_COLOR(border, COLOR_WHITE, COLOR_WHITE, true); + DLG_COLOR(button_active, COLOR_WHITE, COLOR_BLUE, true); + DLG_COLOR(button_inactive, COLOR_BLACK, COLOR_WHITE, false); + DLG_COLOR(button_key_active, COLOR_WHITE, COLOR_BLUE, true); + DLG_COLOR(button_key_inactive, COLOR_RED, COLOR_WHITE, false); + DLG_COLOR(button_label_active, COLOR_YELLOW, COLOR_BLUE, true); + DLG_COLOR(button_label_inactive, COLOR_BLACK, COLOR_WHITE, true); + DLG_COLOR(inputbox, COLOR_BLACK, COLOR_WHITE, false); + DLG_COLOR(inputbox_border, COLOR_BLACK, COLOR_WHITE, false); + DLG_COLOR(searchbox, COLOR_BLACK, COLOR_WHITE, false); + DLG_COLOR(searchbox_title, COLOR_YELLOW, COLOR_WHITE, true); + DLG_COLOR(searchbox_border, COLOR_WHITE, COLOR_WHITE, true); + DLG_COLOR(position_indicator, COLOR_YELLOW, COLOR_WHITE, true); + DLG_COLOR(menubox, COLOR_BLACK, COLOR_WHITE, false); + DLG_COLOR(menubox_border, COLOR_WHITE, COLOR_WHITE, true); + DLG_COLOR(item, COLOR_BLACK, COLOR_WHITE, false); + DLG_COLOR(item_selected, COLOR_WHITE, COLOR_BLUE, true); + DLG_COLOR(tag, COLOR_YELLOW, COLOR_WHITE, true); + DLG_COLOR(tag_selected, COLOR_YELLOW, COLOR_BLUE, true); + DLG_COLOR(tag_key, COLOR_YELLOW, COLOR_WHITE, true); + DLG_COLOR(tag_key_selected, COLOR_YELLOW, COLOR_BLUE, true); + DLG_COLOR(check, COLOR_BLACK, COLOR_WHITE, false); + DLG_COLOR(check_selected, COLOR_WHITE, COLOR_BLUE, true); + DLG_COLOR(uarrow, COLOR_GREEN, COLOR_WHITE, true); + DLG_COLOR(darrow, COLOR_GREEN, COLOR_WHITE, true); +} + +static void set_blackbg_theme(void) +{ + DLG_COLOR(screen, COLOR_RED, COLOR_BLACK, true); + DLG_COLOR(shadow, COLOR_BLACK, COLOR_BLACK, false); + DLG_COLOR(dialog, COLOR_WHITE, COLOR_BLACK, false); + DLG_COLOR(title, COLOR_RED, COLOR_BLACK, false); + DLG_COLOR(border, COLOR_BLACK, COLOR_BLACK, true); + + DLG_COLOR(button_active, COLOR_YELLOW, COLOR_RED, false); + DLG_COLOR(button_inactive, COLOR_YELLOW, COLOR_BLACK, false); + DLG_COLOR(button_key_active, COLOR_YELLOW, COLOR_RED, true); + DLG_COLOR(button_key_inactive, COLOR_RED, COLOR_BLACK, false); + DLG_COLOR(button_label_active, COLOR_WHITE, COLOR_RED, false); + DLG_COLOR(button_label_inactive, COLOR_BLACK, COLOR_BLACK, true); + + DLG_COLOR(inputbox, COLOR_YELLOW, COLOR_BLACK, false); + DLG_COLOR(inputbox_border, COLOR_YELLOW, COLOR_BLACK, false); + + DLG_COLOR(searchbox, COLOR_YELLOW, COLOR_BLACK, false); + DLG_COLOR(searchbox_title, COLOR_YELLOW, COLOR_BLACK, true); + DLG_COLOR(searchbox_border, COLOR_BLACK, COLOR_BLACK, true); + + DLG_COLOR(position_indicator, COLOR_RED, COLOR_BLACK, false); + + DLG_COLOR(menubox, COLOR_YELLOW, COLOR_BLACK, false); + DLG_COLOR(menubox_border, COLOR_BLACK, COLOR_BLACK, true); + + DLG_COLOR(item, COLOR_WHITE, COLOR_BLACK, false); + DLG_COLOR(item_selected, COLOR_WHITE, COLOR_RED, false); + + DLG_COLOR(tag, COLOR_RED, COLOR_BLACK, false); + DLG_COLOR(tag_selected, COLOR_YELLOW, COLOR_RED, true); + DLG_COLOR(tag_key, COLOR_RED, COLOR_BLACK, false); + DLG_COLOR(tag_key_selected, COLOR_YELLOW, COLOR_RED, true); + + DLG_COLOR(check, COLOR_YELLOW, COLOR_BLACK, false); + DLG_COLOR(check_selected, COLOR_YELLOW, COLOR_RED, true); + + DLG_COLOR(uarrow, COLOR_RED, COLOR_BLACK, false); + DLG_COLOR(darrow, COLOR_RED, COLOR_BLACK, false); +} + +static void set_bluetitle_theme(void) +{ + set_classic_theme(); + DLG_COLOR(title, COLOR_BLUE, COLOR_WHITE, true); + DLG_COLOR(button_key_active, COLOR_YELLOW, COLOR_BLUE, true); + DLG_COLOR(button_label_active, COLOR_WHITE, COLOR_BLUE, true); + DLG_COLOR(searchbox_title, COLOR_BLUE, COLOR_WHITE, true); + DLG_COLOR(position_indicator, COLOR_BLUE, COLOR_WHITE, true); + DLG_COLOR(tag, COLOR_BLUE, COLOR_WHITE, true); + DLG_COLOR(tag_key, COLOR_BLUE, COLOR_WHITE, true); + +} + +/* + * Select color theme + */ +static int set_theme(const char *theme) +{ + int use_color = 1; + if (!theme) + set_bluetitle_theme(); + else if (strcmp(theme, "classic") == 0) + set_classic_theme(); + else if (strcmp(theme, "bluetitle") == 0) + set_bluetitle_theme(); + else if (strcmp(theme, "blackbg") == 0) + set_blackbg_theme(); + else if (strcmp(theme, "mono") == 0) + use_color = 0; + + return use_color; +} + +static void init_one_color(struct dialog_color *color) +{ + static int pair = 0; + + pair++; + init_pair(pair, color->fg, color->bg); + if (color->hl) + color->atr = A_BOLD | COLOR_PAIR(pair); + else + color->atr = COLOR_PAIR(pair); +} + +static void init_dialog_colors(void) +{ + init_one_color(&dlg.screen); + init_one_color(&dlg.shadow); + init_one_color(&dlg.dialog); + init_one_color(&dlg.title); + init_one_color(&dlg.border); + init_one_color(&dlg.button_active); + init_one_color(&dlg.button_inactive); + init_one_color(&dlg.button_key_active); + init_one_color(&dlg.button_key_inactive); + init_one_color(&dlg.button_label_active); + init_one_color(&dlg.button_label_inactive); + init_one_color(&dlg.inputbox); + init_one_color(&dlg.inputbox_border); + init_one_color(&dlg.searchbox); + init_one_color(&dlg.searchbox_title); + init_one_color(&dlg.searchbox_border); + init_one_color(&dlg.position_indicator); + init_one_color(&dlg.menubox); + init_one_color(&dlg.menubox_border); + init_one_color(&dlg.item); + init_one_color(&dlg.item_selected); + init_one_color(&dlg.tag); + init_one_color(&dlg.tag_selected); + init_one_color(&dlg.tag_key); + init_one_color(&dlg.tag_key_selected); + init_one_color(&dlg.check); + init_one_color(&dlg.check_selected); + init_one_color(&dlg.uarrow); + init_one_color(&dlg.darrow); +} + +/* + * Setup for color display + */ +static void color_setup(const char *theme) +{ + int use_color; + + use_color = set_theme(theme); + if (use_color && has_colors()) { + start_color(); + init_dialog_colors(); + } else + set_mono_theme(); +} + +/* + * Set window to attribute 'attr' + */ +void attr_clear(WINDOW * win, int height, int width, chtype attr) +{ + int i, j; + + wattrset(win, attr); + for (i = 0; i < height; i++) { + wmove(win, i, 0); + for (j = 0; j < width; j++) + waddch(win, ' '); + } + touchwin(win); +} + +void dialog_clear(void) +{ + attr_clear(stdscr, LINES, COLS, dlg.screen.atr); + /* Display background title if it exists ... - SLH */ + if (dlg.backtitle != NULL) { + int i; + + wattrset(stdscr, dlg.screen.atr); + mvwaddstr(stdscr, 0, 1, (char *)dlg.backtitle); + wmove(stdscr, 1, 1); + for (i = 1; i < COLS - 1; i++) + waddch(stdscr, ACS_HLINE); + } + wnoutrefresh(stdscr); +} + +/* + * Do some initialization for dialog + */ +int init_dialog(const char *backtitle) +{ + int height, width; + + initscr(); /* Init curses */ + getmaxyx(stdscr, height, width); + if (height < 19 || width < 80) { + endwin(); + return -ERRDISPLAYTOOSMALL; + } + + dlg.backtitle = backtitle; + color_setup(getenv("MENUCONFIG_COLOR")); + + keypad(stdscr, TRUE); + cbreak(); + noecho(); + dialog_clear(); + + return 0; +} + +void set_dialog_backtitle(const char *backtitle) +{ + dlg.backtitle = backtitle; +} + +/* + * End using dialog functions. + */ +void end_dialog(int x, int y) +{ + /* move cursor back to original position */ + move(y, x); + refresh(); + endwin(); +} + +/* Print the title of the dialog. Center the title and truncate + * tile if wider than dialog (- 2 chars). + **/ +void print_title(WINDOW *dialog, const char *title, int width) +{ + if (title) { + int tlen = MIN(width - 2, strlen(title)); + wattrset(dialog, dlg.title.atr); + mvwaddch(dialog, 0, (width - tlen) / 2 - 1, ' '); + mvwaddnstr(dialog, 0, (width - tlen)/2, title, tlen); + waddch(dialog, ' '); + } +} + +/* + * Print a string of text in a window, automatically wrap around to the + * next line if the string is too long to fit on one line. Newline + * characters '\n' are replaced by spaces. We start on a new line + * if there is no room for at least 4 nonblanks following a double-space. + */ +void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x) +{ + int newl, cur_x, cur_y; + int i, prompt_len, room, wlen; + char tempstr[MAX_LEN + 1], *word, *sp, *sp2; + + strcpy(tempstr, prompt); + + prompt_len = strlen(tempstr); + + /* + * Remove newlines + */ + for (i = 0; i < prompt_len; i++) { + if (tempstr[i] == '\n') + tempstr[i] = ' '; + } + + if (prompt_len <= width - x * 2) { /* If prompt is short */ + wmove(win, y, (width - prompt_len) / 2); + waddstr(win, tempstr); + } else { + cur_x = x; + cur_y = y; + newl = 1; + word = tempstr; + while (word && *word) { + sp = strchr(word, ' '); + if (sp) + *sp++ = 0; + + /* Wrap to next line if either the word does not fit, + or it is the first word of a new sentence, and it is + short, and the next word does not fit. */ + room = width - cur_x; + wlen = strlen(word); + if (wlen > room || + (newl && wlen < 4 && sp + && wlen + 1 + strlen(sp) > room + && (!(sp2 = strchr(sp, ' ')) + || wlen + 1 + (sp2 - sp) > room))) { + cur_y++; + cur_x = x; + } + wmove(win, cur_y, cur_x); + waddstr(win, word); + getyx(win, cur_y, cur_x); + cur_x++; + if (sp && *sp == ' ') { + cur_x++; /* double space */ + while (*++sp == ' ') ; + newl = 1; + } else + newl = 0; + word = sp; + } + } +} + +/* + * Print a button + */ +void print_button(WINDOW * win, const char *label, int y, int x, int selected) +{ + int i, temp; + + wmove(win, y, x); + wattrset(win, selected ? dlg.button_active.atr + : dlg.button_inactive.atr); + waddstr(win, "<"); + temp = strspn(label, " "); + label += temp; + wattrset(win, selected ? dlg.button_label_active.atr + : dlg.button_label_inactive.atr); + for (i = 0; i < temp; i++) + waddch(win, ' '); + wattrset(win, selected ? dlg.button_key_active.atr + : dlg.button_key_inactive.atr); + waddch(win, label[0]); + wattrset(win, selected ? dlg.button_label_active.atr + : dlg.button_label_inactive.atr); + waddstr(win, (char *)label + 1); + wattrset(win, selected ? dlg.button_active.atr + : dlg.button_inactive.atr); + waddstr(win, ">"); + wmove(win, y, x + temp + 1); +} + +/* + * Draw a rectangular box with line drawing characters + */ +void +draw_box(WINDOW * win, int y, int x, int height, int width, + chtype box, chtype border) +{ + int i, j; + + wattrset(win, 0); + for (i = 0; i < height; i++) { + wmove(win, y + i, x); + for (j = 0; j < width; j++) + if (!i && !j) + waddch(win, border | ACS_ULCORNER); + else if (i == height - 1 && !j) + waddch(win, border | ACS_LLCORNER); + else if (!i && j == width - 1) + waddch(win, box | ACS_URCORNER); + else if (i == height - 1 && j == width - 1) + waddch(win, box | ACS_LRCORNER); + else if (!i) + waddch(win, border | ACS_HLINE); + else if (i == height - 1) + waddch(win, box | ACS_HLINE); + else if (!j) + waddch(win, border | ACS_VLINE); + else if (j == width - 1) + waddch(win, box | ACS_VLINE); + else + waddch(win, box | ' '); + } +} + +/* + * Draw shadows along the right and bottom edge to give a more 3D look + * to the boxes + */ +void draw_shadow(WINDOW * win, int y, int x, int height, int width) +{ + int i; + + if (has_colors()) { /* Whether terminal supports color? */ + wattrset(win, dlg.shadow.atr); + wmove(win, y + height, x + 2); + for (i = 0; i < width; i++) + waddch(win, winch(win) & A_CHARTEXT); + for (i = y + 1; i < y + height + 1; i++) { + wmove(win, i, x + width); + waddch(win, winch(win) & A_CHARTEXT); + waddch(win, winch(win) & A_CHARTEXT); + } + wnoutrefresh(win); + } +} + +/* + * Return the position of the first alphabetic character in a string. + */ +int first_alpha(const char *string, const char *exempt) +{ + int i, in_paren = 0, c; + + for (i = 0; i < strlen(string); i++) { + c = tolower(string[i]); + + if (strchr("<[(", c)) + ++in_paren; + if (strchr(">])", c) && in_paren > 0) + --in_paren; + + if ((!in_paren) && isalpha(c) && strchr(exempt, c) == 0) + return i; + } + + return 0; +} + +/* + * ncurses uses ESC to detect escaped char sequences. This resutl in + * a small timeout before ESC is actually delivered to the application. + * lxdialog suggest <ESC> <ESC> which is correctly translated to two + * times esc. But then we need to ignore the second esc to avoid stepping + * out one menu too much. Filter away all escaped key sequences since + * keypad(FALSE) turn off ncurses support for escape sequences - and thats + * needed to make notimeout() do as expected. + */ +int on_key_esc(WINDOW *win) +{ + int key; + int key2; + int key3; + + nodelay(win, TRUE); + keypad(win, FALSE); + key = wgetch(win); + key2 = wgetch(win); + do { + key3 = wgetch(win); + } while (key3 != ERR); + nodelay(win, FALSE); + keypad(win, TRUE); + if (key == KEY_ESC && key2 == ERR) + return KEY_ESC; + else if (key != ERR && key != KEY_ESC && key2 == ERR) + ungetch(key); + + return -1; +} + +/* redraw screen in new size */ +int on_key_resize(void) +{ + dialog_clear(); + return KEY_RESIZE; +} + +struct dialog_list *item_cur; +struct dialog_list item_nil; +struct dialog_list *item_head; + +void item_reset(void) +{ + struct dialog_list *p, *next; + + for (p = item_head; p; p = next) { + next = p->next; + free(p); + } + item_head = NULL; + item_cur = &item_nil; +} + +void item_make(const char *fmt, ...) +{ + va_list ap; + struct dialog_list *p = malloc(sizeof(*p)); + + if (item_head) + item_cur->next = p; + else + item_head = p; + item_cur = p; + memset(p, 0, sizeof(*p)); + + va_start(ap, fmt); + vsnprintf(item_cur->node.str, sizeof(item_cur->node.str), fmt, ap); + va_end(ap); +} + +void item_add_str(const char *fmt, ...) +{ + va_list ap; + size_t avail; + + avail = sizeof(item_cur->node.str) - strlen(item_cur->node.str); + + va_start(ap, fmt); + vsnprintf(item_cur->node.str + strlen(item_cur->node.str), + avail, fmt, ap); + item_cur->node.str[sizeof(item_cur->node.str) - 1] = '\0'; + va_end(ap); +} + +void item_set_tag(char tag) +{ + item_cur->node.tag = tag; +} +void item_set_data(void *ptr) +{ + item_cur->node.data = ptr; +} + +void item_set_selected(int val) +{ + item_cur->node.selected = val; +} + +int item_activate_selected(void) +{ + item_foreach() + if (item_is_selected()) + return 1; + return 0; +} + +void *item_data(void) +{ + return item_cur->node.data; +} + +char item_tag(void) +{ + return item_cur->node.tag; +} + +int item_count(void) +{ + int n = 0; + struct dialog_list *p; + + for (p = item_head; p; p = p->next) + n++; + return n; +} + +void item_set(int n) +{ + int i = 0; + item_foreach() + if (i++ == n) + return; +} + +int item_n(void) +{ + int n = 0; + struct dialog_list *p; + + for (p = item_head; p; p = p->next) { + if (p == item_cur) + return n; + n++; + } + return 0; +} + +const char *item_str(void) +{ + return item_cur->node.str; +} + +int item_is_selected(void) +{ + return (item_cur->node.selected != 0); +} + +int item_is_tag(char tag) +{ + return (item_cur->node.tag == tag); +} + +/* + * Copyright (C) 2002-2005 Roman Zippel <zippel@linux-m68k.org> + * Copyright (C) 2002-2005 Sam Ravnborg <sam@ravnborg.org> + * + * Released under the terms of the GNU GPL v2.0. + */ + +//#include <string.h> +//#include "lkc.h" + +/* file already present in list? If not add it */ +struct file *file_lookup(const char *name) +{ + struct file *file; + const char *file_name = sym_expand_string_value(name); + + for (file = file_list; file; file = file->next) { + if (!strcmp(name, file->name)) { + free((void *)file_name); + return file; + } + } + + file = malloc(sizeof(*file)); + memset(file, 0, sizeof(*file)); + file->name = file_name; + file->next = file_list; + file_list = file; + return file; +} + +/* write a dependency file as used by kbuild to track dependencies */ +int file_write_dep(const char *name) +{ + struct symbol *sym, *env_sym; + struct expr *e; + struct file *file; + FILE *out; + + if (!name) + name = ".kconfig.d"; + out = fopen("..config.tmp", "w"); + if (!out) + return 1; + fprintf(out, "deps_config := \\\n"); + for (file = file_list; file; file = file->next) { + if (file->next) + fprintf(out, "\t%s \\\n", file->name); + else + fprintf(out, "\t%s\n", file->name); + } + fprintf(out, "\n%s: \\\n" + "\t$(deps_config)\n\n", conf_get_autoconfig_name()); + + expr_list_for_each_sym(sym_env_list, e, sym) { + struct property *prop; + const char *value; + + prop = sym_get_env_prop(sym); + env_sym = prop_get_symbol(prop); + if (!env_sym) + continue; + value = getenv(env_sym->name); + if (!value) + value = ""; + fprintf(out, "ifneq \"$(%s)\" \"%s\"\n", env_sym->name, value); + fprintf(out, "%s: FORCE\n", conf_get_autoconfig_name()); + fprintf(out, "endif\n"); + } + + fprintf(out, "\n$(deps_config): ;\n"); + fclose(out); + rename("..config.tmp", name); + return 0; +} + + +/* Allocate initial growable string */ +struct gstr str_new(void) +{ + struct gstr gs; + gs.s = malloc(sizeof(char) * 64); + gs.len = 64; + gs.max_width = 0; + strcpy(gs.s, "\0"); + return gs; +} + +/* Allocate and assign growable string */ +struct gstr str_assign(const char *s) +{ + struct gstr gs; + gs.s = strdup(s); + gs.len = strlen(s) + 1; + gs.max_width = 0; + return gs; +} + +/* Free storage for growable string */ +void str_free(struct gstr *gs) +{ + if (gs->s) + free(gs->s); + gs->s = NULL; + gs->len = 0; +} + +/* Append to growable string */ +void str_append(struct gstr *gs, const char *s) +{ + size_t l; + if (s) { + l = strlen(gs->s) + strlen(s) + 1; + if (l > gs->len) { + gs->s = realloc(gs->s, l); + gs->len = l; + } + strcat(gs->s, s); + } +} + +/* Append printf formatted string to growable string */ +void str_printf(struct gstr *gs, const char *fmt, ...) +{ + va_list ap; + char s[10000]; /* big enough... */ + va_start(ap, fmt); + vsnprintf(s, sizeof(s), fmt, ap); + str_append(gs, s); + va_end(ap); +} + +/* Retrieve value of growable string */ +const char *str_get(struct gstr *gs) +{ + return gs->s; +} + Index: branches/azimutz/Cleancut/i386/config/menubox.c =================================================================== --- branches/azimutz/Cleancut/i386/config/menubox.c (revision 0) +++ branches/azimutz/Cleancut/i386/config/menubox.c (revision 885) @@ -0,0 +1,434 @@ +/* + * menubox.c -- implements the menu box + * + * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) + * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcapw@cfw.com) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* + * Changes by Clifford Wolf (god@clifford.at) + * + * [ 1998-06-13 ] + * + * *) A bugfix for the Page-Down problem + * + * *) Formerly when I used Page Down and Page Up, the cursor would be set + * to the first position in the menu box. Now lxdialog is a bit + * smarter and works more like other menu systems (just have a look at + * it). + * + * *) Formerly if I selected something my scrolling would be broken because + * lxdialog is re-invoked by the Menuconfig shell script, can't + * remember the last scrolling position, and just sets it so that the + * cursor is at the bottom of the box. Now it writes the temporary file + * lxdialog.scrltmp which contains this information. The file is + * deleted by lxdialog if the user leaves a submenu or enters a new + * one, but it would be nice if Menuconfig could make another "rm -f" + * just to be sure. Just try it out - you will recognise a difference! + * + * [ 1998-06-14 ] + * + * *) Now lxdialog is crash-safe against broken "lxdialog.scrltmp" files + * and menus change their size on the fly. + * + * *) If for some reason the last scrolling position is not saved by + * lxdialog, it sets the scrolling so that the selected item is in the + * middle of the menu box, not at the bottom. + * + * 02 January 1999, Michael Elizabeth Chastain (mec@shout.net) + * Reset 'scroll' to 0 if the value from lxdialog.scrltmp is bogus. + * This fixes a bug in Menuconfig where using ' ' to descend into menus + * would leave mis-synchronized lxdialog.scrltmp files lying around, + * fscanf would read in 'scroll', and eventually that value would get used. + */ + +#include "dialog.h" + +static int menu_width, item_x; + +/* + * Print menu item + */ +static void do_print_item(WINDOW * win, const char *item, int line_y, + int selected, int hotkey) +{ + int j; + char *menu_item = malloc(menu_width + 1); + + strncpy(menu_item, item, menu_width - item_x); + menu_item[menu_width - item_x] = '\0'; + j = first_alpha(menu_item, "YyNnMmHh"); + + /* Clear 'residue' of last item */ + wattrset(win, dlg.menubox.atr); + wmove(win, line_y, 0); +#if OLD_NCURSES + { + int i; + for (i = 0; i < menu_width; i++) + waddch(win, ' '); + } +#else + wclrtoeol(win); +#endif + wattrset(win, selected ? dlg.item_selected.atr : dlg.item.atr); + mvwaddstr(win, line_y, item_x, menu_item); + if (hotkey) { + wattrset(win, selected ? dlg.tag_key_selected.atr + : dlg.tag_key.atr); + mvwaddch(win, line_y, item_x + j, menu_item[j]); + } + if (selected) { + wmove(win, line_y, item_x + 1); + } + free(menu_item); + wrefresh(win); +} + +#define print_item(index, choice, selected) \ +do { \ + item_set(index); \ + do_print_item(menu, item_str(), choice, selected, !item_is_tag(':')); \ +} while (0) + +/* + * Print the scroll indicators. + */ +static void print_arrows(WINDOW * win, int item_no, int scroll, int y, int x, + int height) +{ + int cur_y, cur_x; + + getyx(win, cur_y, cur_x); + + wmove(win, y, x); + + if (scroll > 0) { + wattrset(win, dlg.uarrow.atr); + waddch(win, ACS_UARROW); + waddstr(win, "(-)"); + } else { + wattrset(win, dlg.menubox.atr); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + } + + y = y + height + 1; + wmove(win, y, x); + wrefresh(win); + + if ((height < item_no) && (scroll + height < item_no)) { + wattrset(win, dlg.darrow.atr); + waddch(win, ACS_DARROW); + waddstr(win, "(+)"); + } else { + wattrset(win, dlg.menubox_border.atr); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + } + + wmove(win, cur_y, cur_x); + wrefresh(win); +} + +/* + * Display the termination buttons. + */ +static void print_buttons(WINDOW * win, int height, int width, int selected) +{ + int x = width / 2 - 16; + int y = height - 2; + + print_button(win, gettext("Select"), y, x, selected == 0); + print_button(win, gettext(" Exit "), y, x + 12, selected == 1); + print_button(win, gettext(" Help "), y, x + 24, selected == 2); + + wmove(win, y, x + 1 + 12 * selected); + wrefresh(win); +} + +/* scroll up n lines (n may be negative) */ +static void do_scroll(WINDOW *win, int *scroll, int n) +{ + /* Scroll menu up */ + scrollok(win, TRUE); + wscrl(win, n); + scrollok(win, FALSE); + *scroll = *scroll + n; + wrefresh(win); +} + +/* + * Display a menu for choosing among a number of options + */ +int dialog_menu(const char *title, const char *prompt, + const void *selected, int *s_scroll) +{ + int i, j, x, y, box_x, box_y; + int height, width, menu_height; + int key = 0, button = 0, scroll = 0, choice = 0; + int first_item = 0, max_choice; + WINDOW *dialog, *menu; + +do_resize: + height = getmaxy(stdscr); + width = getmaxx(stdscr); + if (height < 15 || width < 65) + return -ERRDISPLAYTOOSMALL; + + height -= 4; + width -= 5; + menu_height = height - 10; + + max_choice = MIN(menu_height, item_count()); + + /* center dialog box on screen */ + x = (COLS - width) / 2; + y = (LINES - height) / 2; + + draw_shadow(stdscr, y, x, height, width); + + dialog = newwin(height, width, y, x); + keypad(dialog, TRUE); + + draw_box(dialog, 0, 0, height, width, + dlg.dialog.atr, dlg.border.atr); + wattrset(dialog, dlg.border.atr); + mvwaddch(dialog, height - 3, 0, ACS_LTEE); + for (i = 0; i < width - 2; i++) + waddch(dialog, ACS_HLINE); + wattrset(dialog, dlg.dialog.atr); + wbkgdset(dialog, dlg.dialog.atr & A_COLOR); + waddch(dialog, ACS_RTEE); + + print_title(dialog, title, width); + + wattrset(dialog, dlg.dialog.atr); + print_autowrap(dialog, prompt, width - 2, 1, 3); + + menu_width = width - 6; + box_y = height - menu_height - 5; + box_x = (width - menu_width) / 2 - 1; + + /* create new window for the menu */ + menu = subwin(dialog, menu_height, menu_width, + y + box_y + 1, x + box_x + 1); + keypad(menu, TRUE); + + /* draw a box around the menu items */ + draw_box(dialog, box_y, box_x, menu_height + 2, menu_width + 2, + dlg.menubox_border.atr, dlg.menubox.atr); + + if (menu_width >= 80) + item_x = (menu_width - 70) / 2; + else + item_x = 4; + + /* Set choice to default item */ + item_foreach() + if (selected && (selected == item_data())) + choice = item_n(); + /* get the saved scroll info */ + scroll = *s_scroll; + if ((scroll <= choice) && (scroll + max_choice > choice) && + (scroll >= 0) && (scroll + max_choice <= item_count())) { + first_item = scroll; + choice = choice - scroll; + } else { + scroll = 0; + } + if ((choice >= max_choice)) { + if (choice >= item_count() - max_choice / 2) + scroll = first_item = item_count() - max_choice; + else + scroll = first_item = choice - max_choice / 2; + choice = choice - scroll; + } + + /* Print the menu */ + for (i = 0; i < max_choice; i++) { + print_item(first_item + i, i, i == choice); + } + + wnoutrefresh(menu); + + print_arrows(dialog, item_count(), scroll, + box_y, box_x + item_x + 1, menu_height); + + print_buttons(dialog, height, width, 0); + wmove(menu, choice, item_x + 1); + wrefresh(menu); + + while (key != KEY_ESC) { + key = wgetch(menu); + + if (key < 256 && isalpha(key)) + key = tolower(key); + + if (strchr("ynmh", key)) + i = max_choice; + else { + for (i = choice + 1; i < max_choice; i++) { + item_set(scroll + i); + j = first_alpha(item_str(), "YyNnMmHh"); + if (key == tolower(item_str()[j])) + break; + } + if (i == max_choice) + for (i = 0; i < max_choice; i++) { + item_set(scroll + i); + j = first_alpha(item_str(), "YyNnMmHh"); + if (key == tolower(item_str()[j])) + break; + } + } + + if (i < max_choice || + key == KEY_UP || key == KEY_DOWN || + key == '-' || key == '+' || + key == KEY_PPAGE || key == KEY_NPAGE) { + /* Remove highligt of current item */ + print_item(scroll + choice, choice, FALSE); + + if (key == KEY_UP || key == '-') { + if (choice < 2 && scroll) { + /* Scroll menu down */ + do_scroll(menu, &scroll, -1); + + print_item(scroll, 0, FALSE); + } else + choice = MAX(choice - 1, 0); + + } else if (key == KEY_DOWN || key == '+') { + print_item(scroll+choice, choice, FALSE); + + if ((choice > max_choice - 3) && + (scroll + max_choice < item_count())) { + /* Scroll menu up */ + do_scroll(menu, &scroll, 1); + + print_item(scroll+max_choice - 1, + max_choice - 1, FALSE); + } else + choice = MIN(choice + 1, max_choice - 1); + + } else if (key == KEY_PPAGE) { + scrollok(menu, TRUE); + for (i = 0; (i < max_choice); i++) { + if (scroll > 0) { + do_scroll(menu, &scroll, -1); + print_item(scroll, 0, FALSE); + } else { + if (choice > 0) + choice--; + } + } + + } else if (key == KEY_NPAGE) { + for (i = 0; (i < max_choice); i++) { + if (scroll + max_choice < item_count()) { + do_scroll(menu, &scroll, 1); + print_item(scroll+max_choice-1, + max_choice - 1, FALSE); + } else { + if (choice + 1 < max_choice) + choice++; + } + } + } else + choice = i; + + print_item(scroll + choice, choice, TRUE); + + print_arrows(dialog, item_count(), scroll, + box_y, box_x + item_x + 1, menu_height); + + wnoutrefresh(dialog); + wrefresh(menu); + + continue; /* wait for another key press */ + } + + switch (key) { + case KEY_LEFT: + case TAB: + case KEY_RIGHT: + button = ((key == KEY_LEFT ? --button : ++button) < 0) + ? 2 : (button > 2 ? 0 : button); + + print_buttons(dialog, height, width, button); + wrefresh(menu); + break; + case ' ': + case 's': + case 'y': + case 'n': + case 'm': + case '/': + case 'h': + case '?': + case 'z': + case '\n': + /* save scroll info */ + *s_scroll = scroll; + delwin(menu); + delwin(dialog); + item_set(scroll + choice); + item_set_selected(1); + switch (key) { + case 'h': + case '?': + return 2; + case 's': + case 'y': + return 3; + case 'n': + return 4; + case 'm': + return 5; + case ' ': + return 6; + case '/': + return 7; + case 'z': + return 8; + case '\n': + return button; + } + return 0; + case 'e': + case 'x': + key = KEY_ESC; + break; + case KEY_ESC: + key = on_key_esc(menu); + break; + case KEY_RESIZE: + on_key_resize(); + delwin(menu); + delwin(dialog); + goto do_resize; + } + } + delwin(menu); + delwin(dialog); + return key; /* ESC pressed */ +} Index: branches/azimutz/Cleancut/i386/config/expr.c =================================================================== --- branches/azimutz/Cleancut/i386/config/expr.c (revision 0) +++ branches/azimutz/Cleancut/i386/config/expr.c (revision 885) @@ -0,0 +1,1173 @@ +/* + * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> + * Released under the terms of the GNU GPL v2.0. + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#define LKC_DIRECT_LINK +#include "lkc.h" + +#define DEBUG_EXPR 0 + +struct expr *expr_alloc_symbol(struct symbol *sym) +{ + struct expr *e = malloc(sizeof(*e)); + memset(e, 0, sizeof(*e)); + e->type = E_SYMBOL; + e->left.sym = sym; + return e; +} + +struct expr *expr_alloc_one(enum expr_type type, struct expr *ce) +{ + struct expr *e = malloc(sizeof(*e)); + memset(e, 0, sizeof(*e)); + e->type = type; + e->left.expr = ce; + return e; +} + +struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e2) +{ + struct expr *e = malloc(sizeof(*e)); + memset(e, 0, sizeof(*e)); + e->type = type; + e->left.expr = e1; + e->right.expr = e2; + return e; +} + +struct expr *expr_alloc_comp(enum expr_type type, struct symbol *s1, struct symbol *s2) +{ + struct expr *e = malloc(sizeof(*e)); + memset(e, 0, sizeof(*e)); + e->type = type; + e->left.sym = s1; + e->right.sym = s2; + return e; +} + +struct expr *expr_alloc_and(struct expr *e1, struct expr *e2) +{ + if (!e1) + return e2; + return e2 ? expr_alloc_two(E_AND, e1, e2) : e1; +} + +struct expr *expr_alloc_or(struct expr *e1, struct expr *e2) +{ + if (!e1) + return e2; + return e2 ? expr_alloc_two(E_OR, e1, e2) : e1; +} + +struct expr *expr_copy(const struct expr *org) +{ + struct expr *e; + + if (!org) + return NULL; + + e = malloc(sizeof(*org)); + memcpy(e, org, sizeof(*org)); + switch (org->type) { + case E_SYMBOL: + e->left = org->left; + break; + case E_NOT: + e->left.expr = expr_copy(org->left.expr); + break; + case E_EQUAL: + case E_UNEQUAL: + e->left.sym = org->left.sym; + e->right.sym = org->right.sym; + break; + case E_AND: + case E_OR: + case E_LIST: + e->left.expr = expr_copy(org->left.expr); + e->right.expr = expr_copy(org->right.expr); + break; + default: + printf("can't copy type %d\n", e->type); + free(e); + e = NULL; + break; + } + + return e; +} + +void expr_free(struct expr *e) +{ + if (!e) + return; + + switch (e->type) { + case E_SYMBOL: + break; + case E_NOT: + expr_free(e->left.expr); + return; + case E_EQUAL: + case E_UNEQUAL: + break; + case E_OR: + case E_AND: + expr_free(e->left.expr); + expr_free(e->right.expr); + break; + default: + printf("how to free type %d?\n", e->type); + break; + } + free(e); +} + +static int trans_count; + +#define e1 (*ep1) +#define e2 (*ep2) + +static void __expr_eliminate_eq(enum expr_type type, struct expr **ep1, struct expr **ep2) +{ + if (e1->type == type) { + __expr_eliminate_eq(type, &e1->left.expr, &e2); + __expr_eliminate_eq(type, &e1->right.expr, &e2); + return; + } + if (e2->type == type) { + __expr_eliminate_eq(type, &e1, &e2->left.expr); + __expr_eliminate_eq(type, &e1, &e2->right.expr); + return; + } + if (e1->type == E_SYMBOL && e2->type == E_SYMBOL && + e1->left.sym == e2->left.sym && + (e1->left.sym == &symbol_yes || e1->left.sym == &symbol_no)) + return; + if (!expr_eq(e1, e2)) + return; + trans_count++; + expr_free(e1); expr_free(e2); + switch (type) { + case E_OR: + e1 = expr_alloc_symbol(&symbol_no); + e2 = expr_alloc_symbol(&symbol_no); + break; + case E_AND: + e1 = expr_alloc_symbol(&symbol_yes); + e2 = expr_alloc_symbol(&symbol_yes); + break; + default: + ; + } +} + +void expr_eliminate_eq(struct expr **ep1, struct expr **ep2) +{ + if (!e1 || !e2) + return; + switch (e1->type) { + case E_OR: + case E_AND: + __expr_eliminate_eq(e1->type, ep1, ep2); + default: + ; + } + if (e1->type != e2->type) switch (e2->type) { + case E_OR: + case E_AND: + __expr_eliminate_eq(e2->type, ep1, ep2); + default: + ; + } + e1 = expr_eliminate_yn(e1); + e2 = expr_eliminate_yn(e2); +} + +#undef e1 +#undef e2 + +int expr_eq(struct expr *e1, struct expr *e2) +{ + int res, old_count; + + if (e1->type != e2->type) + return 0; + switch (e1->type) { + case E_EQUAL: + case E_UNEQUAL: + return e1->left.sym == e2->left.sym && e1->right.sym == e2->right.sym; + case E_SYMBOL: + return e1->left.sym == e2->left.sym; + case E_NOT: + return expr_eq(e1->left.expr, e2->left.expr); + case E_AND: + case E_OR: + e1 = expr_copy(e1); + e2 = expr_copy(e2); + old_count = trans_count; + expr_eliminate_eq(&e1, &e2); + res = (e1->type == E_SYMBOL && e2->type == E_SYMBOL && + e1->left.sym == e2->left.sym); + expr_free(e1); + expr_free(e2); + trans_count = old_count; + return res; + case E_LIST: + case E_RANGE: + case E_NONE: + /* panic */; + } + + if (DEBUG_EXPR) { + expr_fprint(e1, stdout); + printf(" = "); + expr_fprint(e2, stdout); + printf(" ?\n"); + } + + return 0; +} + +struct expr *expr_eliminate_yn(struct expr *e) +{ + struct expr *tmp; + + if (e) switch (e->type) { + case E_AND: + e->left.expr = expr_eliminate_yn(e->left.expr); + e->right.expr = expr_eliminate_yn(e->right.expr); + if (e->left.expr->type == E_SYMBOL) { + if (e->left.expr->left.sym == &symbol_no) { + expr_free(e->left.expr); + expr_free(e->right.expr); + e->type = E_SYMBOL; + e->left.sym = &symbol_no; + e->right.expr = NULL; + return e; + } else if (e->left.expr->left.sym == &symbol_yes) { + free(e->left.expr); + tmp = e->right.expr; + *e = *(e->right.expr); + free(tmp); + return e; + } + } + if (e->right.expr->type == E_SYMBOL) { + if (e->right.expr->left.sym == &symbol_no) { + expr_free(e->left.expr); + expr_free(e->right.expr); + e->type = E_SYMBOL; + e->left.sym = &symbol_no; + e->right.expr = NULL; + return e; + } else if (e->right.expr->left.sym == &symbol_yes) { + free(e->right.expr); + tmp = e->left.expr; + *e = *(e->left.expr); + free(tmp); + return e; + } + } + break; + case E_OR: + e->left.expr = expr_eliminate_yn(e->left.expr); + e->right.expr = expr_eliminate_yn(e->right.expr); + if (e->left.expr->type == E_SYMBOL) { + if (e->left.expr->left.sym == &symbol_no) { + free(e->left.expr); + tmp = e->right.expr; + *e = *(e->right.expr); + free(tmp); + return e; + } else if (e->left.expr->left.sym == &symbol_yes) { + expr_free(e->left.expr); + expr_free(e->right.expr); + e->type = E_SYMBOL; + e->left.sym = &symbol_yes; + e->right.expr = NULL; + return e; + } + } + if (e->right.expr->type == E_SYMBOL) { + if (e->right.expr->left.sym == &symbol_no) { + free(e->right.expr); + tmp = e->left.expr; + *e = *(e->left.expr); + free(tmp); + return e; + } else if (e->right.expr->left.sym == &symbol_yes) { + expr_free(e->left.expr); + expr_free(e->right.expr); + e->type = E_SYMBOL; + e->left.sym = &symbol_yes; + e->right.expr = NULL; + return e; + } + } + break; + default: + ; + } + return e; +} + +/* + * bool FOO!=n => FOO + */ +struct expr *expr_trans_bool(struct expr *e) +{ + if (!e) + return NULL; + switch (e->type) { + case E_AND: + case E_OR: + case E_NOT: + e->left.expr = expr_trans_bool(e->left.expr); + e->right.expr = expr_trans_bool(e->right.expr); + break; + case E_UNEQUAL: + // FOO!=n -> FOO + if (e->left.sym->type == S_TRISTATE) { + if (e->right.sym == &symbol_no) { + e->type = E_SYMBOL; + e->right.sym = NULL; + } + } + break; + default: + ; + } + return e; +} + +/* + * e1 || e2 -> ? + */ +static struct expr *expr_join_or(struct expr *e1, struct expr *e2) +{ + struct expr *tmp; + struct symbol *sym1, *sym2; + + if (expr_eq(e1, e2)) + return expr_copy(e1); + if (e1->type != E_EQUAL && e1->type != E_UNEQUAL && e1->type != E_SYMBOL && e1->type != E_NOT) + return NULL; + if (e2->type != E_EQUAL && e2->type != E_UNEQUAL && e2->type != E_SYMBOL && e2->type != E_NOT) + return NULL; + if (e1->type == E_NOT) { + tmp = e1->left.expr; + if (tmp->type != E_EQUAL && tmp->type != E_UNEQUAL && tmp->type != E_SYMBOL) + return NULL; + sym1 = tmp->left.sym; + } else + sym1 = e1->left.sym; + if (e2->type == E_NOT) { + if (e2->left.expr->type != E_SYMBOL) + return NULL; + sym2 = e2->left.expr->left.sym; + } else + sym2 = e2->left.sym; + if (sym1 != sym2) + return NULL; + if (sym1->type != S_BOOLEAN && sym1->type != S_TRISTATE) + return NULL; + if (sym1->type == S_TRISTATE) { + if (e1->type == E_EQUAL && e2->type == E_EQUAL && + ((e1->right.sym == &symbol_yes && e2->right.sym == &symbol_mod) || + (e1->right.sym == &symbol_mod && e2->right.sym == &symbol_yes))) { + // (a='y') || (a='m') -> (a!='n') + return expr_alloc_comp(E_UNEQUAL, sym1, &symbol_no); + } + if (e1->type == E_EQUAL && e2->type == E_EQUAL && + ((e1->right.sym == &symbol_yes && e2->right.sym == &symbol_no) || + (e1->right.sym == &symbol_no && e2->right.sym == &symbol_yes))) { + // (a='y') || (a='n') -> (a!='m') + return expr_alloc_comp(E_UNEQUAL, sym1, &symbol_mod); + } + if (e1->type == E_EQUAL && e2->type == E_EQUAL && + ((e1->right.sym == &symbol_mod && e2->right.sym == &symbol_no) || + (e1->right.sym == &symbol_no && e2->right.sym == &symbol_mod))) { + // (a='m') || (a='n') -> (a!='y') + return expr_alloc_comp(E_UNEQUAL, sym1, &symbol_yes); + } + } + if (sym1->type == S_BOOLEAN && sym1 == sym2) { + if ((e1->type == E_NOT && e1->left.expr->type == E_SYMBOL && e2->type == E_SYMBOL) || + (e2->type == E_NOT && e2->left.expr->type == E_SYMBOL && e1->type == E_SYMBOL)) + return expr_alloc_symbol(&symbol_yes); + } + + if (DEBUG_EXPR) { + printf("optimize ("); + expr_fprint(e1, stdout); + printf(") || ("); + expr_fprint(e2, stdout); + printf(")?\n"); + } + return NULL; +} + +static struct expr *expr_join_and(struct expr *e1, struct expr *e2) +{ + struct expr *tmp; + struct symbol *sym1, *sym2; + + if (expr_eq(e1, e2)) + return expr_copy(e1); + if (e1->type != E_EQUAL && e1->type != E_UNEQUAL && e1->type != E_SYMBOL && e1->type != E_NOT) + return NULL; + if (e2->type != E_EQUAL && e2->type != E_UNEQUAL && e2->type != E_SYMBOL && e2->type != E_NOT) + return NULL; + if (e1->type == E_NOT) { + tmp = e1->left.expr; + if (tmp->type != E_EQUAL && tmp->type != E_UNEQUAL && tmp->type != E_SYMBOL) + return NULL; + sym1 = tmp->left.sym; + } else + sym1 = e1->left.sym; + if (e2->type == E_NOT) { + if (e2->left.expr->type != E_SYMBOL) + return NULL; + sym2 = e2->left.expr->left.sym; + } else + sym2 = e2->left.sym; + if (sym1 != sym2) + return NULL; + if (sym1->type != S_BOOLEAN && sym1->type != S_TRISTATE) + return NULL; + + if ((e1->type == E_SYMBOL && e2->type == E_EQUAL && e2->right.sym == &symbol_yes) || + (e2->type == E_SYMBOL && e1->type == E_EQUAL && e1->right.sym == &symbol_yes)) + // (a) && (a='y') -> (a='y') + return expr_alloc_comp(E_EQUAL, sym1, &symbol_yes); + + if ((e1->type == E_SYMBOL && e2->type == E_UNEQUAL && e2->right.sym == &symbol_no) || + (e2->type == E_SYMBOL && e1->type == E_UNEQUAL && e1->right.sym == &symbol_no)) + // (a) && (a!='n') -> (a) + return expr_alloc_symbol(sym1); + + if ((e1->type == E_SYMBOL && e2->type == E_UNEQUAL && e2->right.sym == &symbol_mod) || + (e2->type == E_SYMBOL && e1->type == E_UNEQUAL && e1->right.sym == &symbol_mod)) + // (a) && (a!='m') -> (a='y') + return expr_alloc_comp(E_EQUAL, sym1, &symbol_yes); + + if (sym1->type == S_TRISTATE) { + if (e1->type == E_EQUAL && e2->type == E_UNEQUAL) { + // (a='b') && (a!='c') -> 'b'='c' ? 'n' : a='b' + sym2 = e1->right.sym; + if ((e2->right.sym->flags & SYMBOL_CONST) && (sym2->flags & SYMBOL_CONST)) + return sym2 != e2->right.sym ? expr_alloc_comp(E_EQUAL, sym1, sym2) + : expr_alloc_symbol(&symbol_no); + } + if (e1->type == E_UNEQUAL && e2->type == E_EQUAL) { + // (a='b') && (a!='c') -> 'b'='c' ? 'n' : a='b' + sym2 = e2->right.sym; + if ((e1->right.sym->flags & SYMBOL_CONST) && (sym2->flags & SYMBOL_CONST)) + return sym2 != e1->right.sym ? expr_alloc_comp(E_EQUAL, sym1, sym2) + : expr_alloc_symbol(&symbol_no); + } + if (e1->type == E_UNEQUAL && e2->type == E_UNEQUAL && + ((e1->right.sym == &symbol_yes && e2->right.sym == &symbol_no) || + (e1->right.sym == &symbol_no && e2->right.sym == &symbol_yes))) + // (a!='y') && (a!='n') -> (a='m') + return expr_alloc_comp(E_EQUAL, sym1, &symbol_mod); + + if (e1->type == E_UNEQUAL && e2->type == E_UNEQUAL && + ((e1->right.sym == &symbol_yes && e2->right.sym == &symbol_mod) || + (e1->right.sym == &symbol_mod && e2->right.sym == &symbol_yes))) + // (a!='y') && (a!='m') -> (a='n') + return expr_alloc_comp(E_EQUAL, sym1, &symbol_no); + + if (e1->type == E_UNEQUAL && e2->type == E_UNEQUAL && + ((e1->right.sym == &symbol_mod && e2->right.sym == &symbol_no) || + (e1->right.sym == &symbol_no && e2->right.sym == &symbol_mod))) + // (a!='m') && (a!='n') -> (a='m') + return expr_alloc_comp(E_EQUAL, sym1, &symbol_yes); + + if ((e1->type == E_SYMBOL && e2->type == E_EQUAL && e2->right.sym == &symbol_mod) || + (e2->type == E_SYMBOL && e1->type == E_EQUAL && e1->right.sym == &symbol_mod) || + (e1->type == E_SYMBOL && e2->type == E_UNEQUAL && e2->right.sym == &symbol_yes) || + (e2->type == E_SYMBOL && e1->type == E_UNEQUAL && e1->right.sym == &symbol_yes)) + return NULL; + } + + if (DEBUG_EXPR) { + printf("optimize ("); + expr_fprint(e1, stdout); + printf(") && ("); + expr_fprint(e2, stdout); + printf(")?\n"); + } + return NULL; +} + +static void expr_eliminate_dups1(enum expr_type type, struct expr **ep1, struct expr **ep2) +{ +#define e1 (*ep1) +#define e2 (*ep2) + struct expr *tmp; + + if (e1->type == type) { + expr_eliminate_dups1(type, &e1->left.expr, &e2); + expr_eliminate_dups1(type, &e1->right.expr, &e2); + return; + } + if (e2->type == type) { + expr_eliminate_dups1(type, &e1, &e2->left.expr); + expr_eliminate_dups1(type, &e1, &e2->right.expr); + return; + } + if (e1 == e2) + return; + + switch (e1->type) { + case E_OR: case E_AND: + expr_eliminate_dups1(e1->type, &e1, &e1); + default: + ; + } + + switch (type) { + case E_OR: + tmp = expr_join_or(e1, e2); + if (tmp) { + expr_free(e1); expr_free(e2); + e1 = expr_alloc_symbol(&symbol_no); + e2 = tmp; + trans_count++; + } + break; + case E_AND: + tmp = expr_join_and(e1, e2); + if (tmp) { + expr_free(e1); expr_free(e2); + e1 = expr_alloc_symbol(&symbol_yes); + e2 = tmp; + trans_count++; + } + break; + default: + ; + } +#undef e1 +#undef e2 +} + +static void expr_eliminate_dups2(enum expr_type type, struct expr **ep1, struct expr **ep2) +{ +#define e1 (*ep1) +#define e2 (*ep2) + struct expr *tmp, *tmp1, *tmp2; + + if (e1->type == type) { + expr_eliminate_dups2(type, &e1->left.expr, &e2); + expr_eliminate_dups2(type, &e1->right.expr, &e2); + return; + } + if (e2->type == type) { + expr_eliminate_dups2(type, &e1, &e2->left.expr); + expr_eliminate_dups2(type, &e1, &e2->right.expr); + } + if (e1 == e2) + return; + + switch (e1->type) { + case E_OR: + expr_eliminate_dups2(e1->type, &e1, &e1); + // (FOO || BAR) && (!FOO && !BAR) -> n + tmp1 = expr_transform(expr_alloc_one(E_NOT, expr_copy(e1))); + tmp2 = expr_copy(e2); + tmp = expr_extract_eq_and(&tmp1, &tmp2); + if (expr_is_yes(tmp1)) { + expr_free(e1); + e1 = expr_alloc_symbol(&symbol_no); + trans_count++; + } + expr_free(tmp2); + expr_free(tmp1); + expr_free(tmp); + break; + case E_AND: + expr_eliminate_dups2(e1->type, &e1, &e1); + // (FOO && BAR) || (!FOO || !BAR) -> y + tmp1 = expr_transform(expr_alloc_one(E_NOT, expr_copy(e1))); + tmp2 = expr_copy(e2); + tmp = expr_extract_eq_or(&tmp1, &tmp2); + if (expr_is_no(tmp1)) { + expr_free(e1); + e1 = expr_alloc_symbol(&symbol_yes); + trans_count++; + } + expr_free(tmp2); + expr_free(tmp1); + expr_free(tmp); + break; + default: + ; + } +#undef e1 +#undef e2 +} + +struct expr *expr_eliminate_dups(struct expr *e) +{ + int oldcount; + if (!e) + return e; + + oldcount = trans_count; + while (1) { + trans_count = 0; + switch (e->type) { + case E_OR: case E_AND: + expr_eliminate_dups1(e->type, &e, &e); + expr_eliminate_dups2(e->type, &e, &e); + default: + ; + } + if (!trans_count) + break; + e = expr_eliminate_yn(e); + } + trans_count = oldcount; + return e; +} + +struct expr *expr_transform(struct expr *e) +{ + struct expr *tmp; + + if (!e) + return NULL; + switch (e->type) { + case E_EQUAL: + case E_UNEQUAL: + case E_SYMBOL: + case E_LIST: + break; + default: + e->left.expr = expr_transform(e->left.expr); + e->right.expr = expr_transform(e->right.expr); + } + + switch (e->type) { + case E_EQUAL: + if (e->left.sym->type != S_BOOLEAN) + break; + if (e->right.sym == &symbol_no) { + e->type = E_NOT; + e->left.expr = expr_alloc_symbol(e->left.sym); + e->right.sym = NULL; + break; + } + if (e->right.sym == &symbol_mod) { + printf("boolean symbol %s tested for 'm'? test forced to 'n'\n", e->left.sym->name); + e->type = E_SYMBOL; + e->left.sym = &symbol_no; + e->right.sym = NULL; + break; + } + if (e->right.sym == &symbol_yes) { + e->type = E_SYMBOL; + e->right.sym = NULL; + break; + } + break; + case E_UNEQUAL: + if (e->left.sym->type != S_BOOLEAN) + break; + if (e->right.sym == &symbol_no) { + e->type = E_SYMBOL; + e->right.sym = NULL; + break; + } + if (e->right.sym == &symbol_mod) { + printf("boolean symbol %s tested for 'm'? test forced to 'y'\n", e->left.sym->name); + e->type = E_SYMBOL; + e->left.sym = &symbol_yes; + e->right.sym = NULL; + break; + } + if (e->right.sym == &symbol_yes) { + e->type = E_NOT; + e->left.expr = expr_alloc_symbol(e->left.sym); + e->right.sym = NULL; + break; + } + break; + case E_NOT: + switch (e->left.expr->type) { + case E_NOT: + // !!a -> a + tmp = e->left.expr->left.expr; + free(e->left.expr); + free(e); + e = tmp; + e = expr_transform(e); + break; + case E_EQUAL: + case E_UNEQUAL: + // !a='x' -> a!='x' + tmp = e->left.expr; + free(e); + e = tmp; + e->type = e->type == E_EQUAL ? E_UNEQUAL : E_EQUAL; + break; + case E_OR: + // !(a || b) -> !a && !b + tmp = e->left.expr; + e->type = E_AND; + e->right.expr = expr_alloc_one(E_NOT, tmp->right.expr); + tmp->type = E_NOT; + tmp->right.expr = NULL; + e = expr_transform(e); + break; + case E_AND: + // !(a && b) -> !a || !b + tmp = e->left.expr; + e->type = E_OR; + e->right.expr = expr_alloc_one(E_NOT, tmp->right.expr); + tmp->type = E_NOT; + tmp->right.expr = NULL; + e = expr_transform(e); + break; + case E_SYMBOL: + if (e->left.expr->left.sym == &symbol_yes) { + // !'y' -> 'n' + tmp = e->left.expr; + free(e); + e = tmp; + e->type = E_SYMBOL; + e->left.sym = &symbol_no; + break; + } + if (e->left.expr->left.sym == &symbol_mod) { + // !'m' -> 'm' + tmp = e->left.expr; + free(e); + e = tmp; + e->type = E_SYMBOL; + e->left.sym = &symbol_mod; + break; + } + if (e->left.expr->left.sym == &symbol_no) { + // !'n' -> 'y' + tmp = e->left.expr; + free(e); + e = tmp; + e->type = E_SYMBOL; + e->left.sym = &symbol_yes; + break; + } + break; + default: + ; + } + break; + default: + ; + } + return e; +} + +int expr_contains_symbol(struct expr *dep, struct symbol *sym) +{ + if (!dep) + return 0; + + switch (dep->type) { + case E_AND: + case E_OR: + return expr_contains_symbol(dep->left.expr, sym) || + expr_contains_symbol(dep->right.expr, sym); + case E_SYMBOL: + return dep->left.sym == sym; + case E_EQUAL: + case E_UNEQUAL: + return dep->left.sym == sym || + dep->right.sym == sym; + case E_NOT: + return expr_contains_symbol(dep->left.expr, sym); + default: + ; + } + return 0; +} + +bool expr_depends_symbol(struct expr *dep, struct symbol *sym) +{ + if (!dep) + return false; + + switch (dep->type) { + case E_AND: + return expr_depends_symbol(dep->left.expr, sym) || + expr_depends_symbol(dep->right.expr, sym); + case E_SYMBOL: + return dep->left.sym == sym; + case E_EQUAL: + if (dep->left.sym == sym) { + if (dep->right.sym == &symbol_yes || dep->right.sym == &symbol_mod) + return true; + } + break; + case E_UNEQUAL: + if (dep->left.sym == sym) { + if (dep->right.sym == &symbol_no) + return true; + } + break; + default: + ; + } + return false; +} + +struct expr *expr_extract_eq_and(struct expr **ep1, struct expr **ep2) +{ + struct expr *tmp = NULL; + expr_extract_eq(E_AND, &tmp, ep1, ep2); + if (tmp) { + *ep1 = expr_eliminate_yn(*ep1); + *ep2 = expr_eliminate_yn(*ep2); + } + return tmp; +} + +struct expr *expr_extract_eq_or(struct expr **ep1, struct expr **ep2) +{ + struct expr *tmp = NULL; + expr_extract_eq(E_OR, &tmp, ep1, ep2); + if (tmp) { + *ep1 = expr_eliminate_yn(*ep1); + *ep2 = expr_eliminate_yn(*ep2); + } + return tmp; +} + +void expr_extract_eq(enum expr_type type, struct expr **ep, struct expr **ep1, struct expr **ep2) +{ +#define e1 (*ep1) +#define e2 (*ep2) + if (e1->type == type) { + expr_extract_eq(type, ep, &e1->left.expr, &e2); + expr_extract_eq(type, ep, &e1->right.expr, &e2); + return; + } + if (e2->type == type) { + expr_extract_eq(type, ep, ep1, &e2->left.expr); + expr_extract_eq(type, ep, ep1, &e2->right.expr); + return; + } + if (expr_eq(e1, e2)) { + *ep = *ep ? expr_alloc_two(type, *ep, e1) : e1; + expr_free(e2); + if (type == E_AND) { + e1 = expr_alloc_symbol(&symbol_yes); + e2 = expr_alloc_symbol(&symbol_yes); + } else if (type == E_OR) { + e1 = expr_alloc_symbol(&symbol_no); + e2 = expr_alloc_symbol(&symbol_no); + } + } +#undef e1 +#undef e2 +} + +struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym) +{ + struct expr *e1, *e2; + + if (!e) { + e = expr_alloc_symbol(sym); + if (type == E_UNEQUAL) + e = expr_alloc_one(E_NOT, e); + return e; + } + switch (e->type) { + case E_AND: + e1 = expr_trans_compare(e->left.expr, E_EQUAL, sym); + e2 = expr_trans_compare(e->right.expr, E_EQUAL, sym); + if (sym == &symbol_yes) + e = expr_alloc_two(E_AND, e1, e2); + if (sym == &symbol_no) + e = expr_alloc_two(E_OR, e1, e2); + if (type == E_UNEQUAL) + e = expr_alloc_one(E_NOT, e); + return e; + case E_OR: + e1 = expr_trans_compare(e->left.expr, E_EQUAL, sym); + e2 = expr_trans_compare(e->right.expr, E_EQUAL, sym); + if (sym == &symbol_yes) + e = expr_alloc_two(E_OR, e1, e2); + if (sym == &symbol_no) + e = expr_alloc_two(E_AND, e1, e2); + if (type == E_UNEQUAL) + e = expr_alloc_one(E_NOT, e); + return e; + case E_NOT: + return expr_trans_compare(e->left.expr, type == E_EQUAL ? E_UNEQUAL : E_EQUAL, sym); + case E_UNEQUAL: + case E_EQUAL: + if (type == E_EQUAL) { + if (sym == &symbol_yes) + return expr_copy(e); + if (sym == &symbol_mod) + return expr_alloc_symbol(&symbol_no); + if (sym == &symbol_no) + return expr_alloc_one(E_NOT, expr_copy(e)); + } else { + if (sym == &symbol_yes) + return expr_alloc_one(E_NOT, expr_copy(e)); + if (sym == &symbol_mod) + return expr_alloc_symbol(&symbol_yes); + if (sym == &symbol_no) + return expr_copy(e); + } + break; + case E_SYMBOL: + return expr_alloc_comp(type, e->left.sym, sym); + case E_LIST: + case E_RANGE: + case E_NONE: + /* panic */; + } + return NULL; +} + +tristate expr_calc_value(struct expr *e) +{ + tristate val1, val2; + const char *str1, *str2; + + if (!e) + return yes; + + switch (e->type) { + case E_SYMBOL: + sym_calc_value(e->left.sym); + return e->left.sym->curr.tri; + case E_AND: + val1 = expr_calc_value(e->left.expr); + val2 = expr_calc_value(e->right.expr); + return EXPR_AND(val1, val2); + case E_OR: + val1 = expr_calc_value(e->left.expr); + val2 = expr_calc_value(e->right.expr); + return EXPR_OR(val1, val2); + case E_NOT: + val1 = expr_calc_value(e->left.expr); + return EXPR_NOT(val1); + case E_EQUAL: + sym_calc_value(e->left.sym); + sym_calc_value(e->right.sym); + str1 = sym_get_string_value(e->left.sym); + str2 = sym_get_string_value(e->right.sym); + return !strcmp(str1, str2) ? yes : no; + case E_UNEQUAL: + sym_calc_value(e->left.sym); + sym_calc_value(e->right.sym); + str1 = sym_get_string_value(e->left.sym); + str2 = sym_get_string_value(e->right.sym); + return !strcmp(str1, str2) ? no : yes; + default: + printf("expr_calc_value: %d?\n", e->type); + return no; + } +} + +int expr_compare_type(enum expr_type t1, enum expr_type t2) +{ +#if 0 + return 1; +#else + if (t1 == t2) + return 0; + switch (t1) { + case E_EQUAL: + case E_UNEQUAL: + if (t2 == E_NOT) + return 1; + case E_NOT: + if (t2 == E_AND) + return 1; + case E_AND: + if (t2 == E_OR) + return 1; + case E_OR: + if (t2 == E_LIST) + return 1; + case E_LIST: + if (t2 == 0) + return 1; + default: + return -1; + } + printf("[%dgt%d?]", t1, t2); + return 0; +#endif +} + +static inline struct expr * +expr_get_leftmost_symbol(const struct expr *e) +{ + + if (e == NULL) + return NULL; + + while (e->type != E_SYMBOL) + e = e->left.expr; + + return expr_copy(e); +} + +/* + * Given expression `e1' and `e2', returns the leaf of the longest + * sub-expression of `e1' not containing 'e2. + */ +struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2) +{ + struct expr *ret; + + switch (e1->type) { + case E_OR: + return expr_alloc_and( + expr_simplify_unmet_dep(e1->left.expr, e2), + expr_simplify_unmet_dep(e1->right.expr, e2)); + case E_AND: { + struct expr *e; + e = expr_alloc_and(expr_copy(e1), expr_copy(e2)); + e = expr_eliminate_dups(e); + ret = (!expr_eq(e, e1)) ? e1 : NULL; + expr_free(e); + break; + } + default: + ret = e1; + break; + } + + return expr_get_leftmost_symbol(ret); +} + +void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken) +{ + if (!e) { + fn(data, NULL, "y"); + return; + } + + if (expr_compare_type(prevtoken, e->type) > 0) + fn(data, NULL, "("); + switch (e->type) { + case E_SYMBOL: + if (e->left.sym->name) + fn(data, e->left.sym, e->left.sym->name); + else + fn(data, NULL, "<choice>"); + break; + case E_NOT: + fn(data, NULL, "!"); + expr_print(e->left.expr, fn, data, E_NOT); + break; + case E_EQUAL: + if (e->left.sym->name) + fn(data, e->left.sym, e->left.sym->name); + else + fn(data, NULL, "<choice>"); + fn(data, NULL, "="); + fn(data, e->right.sym, e->right.sym->name); + break; + case E_UNEQUAL: + if (e->left.sym->name) + fn(data, e->left.sym, e->left.sym->name); + else + fn(data, NULL, "<choice>"); + fn(data, NULL, "!="); + fn(data, e->right.sym, e->right.sym->name); + break; + case E_OR: + expr_print(e->left.expr, fn, data, E_OR); + fn(data, NULL, " || "); + expr_print(e->right.expr, fn, data, E_OR); + break; + case E_AND: + expr_print(e->left.expr, fn, data, E_AND); + fn(data, NULL, " && "); + expr_print(e->right.expr, fn, data, E_AND); + break; + case E_LIST: + fn(data, e->right.sym, e->right.sym->name); + if (e->left.expr) { + fn(data, NULL, " ^ "); + expr_print(e->left.expr, fn, data, E_LIST); + } + break; + case E_RANGE: + fn(data, NULL, "["); + fn(data, e->left.sym, e->left.sym->name); + fn(data, NULL, " "); + fn(data, e->right.sym, e->right.sym->name); + fn(data, NULL, "]"); + break; + default: + { + char buf[32]; + sprintf(buf, "<unknown type %d>", e->type); + fn(data, NULL, buf); + break; + } + } + if (expr_compare_type(prevtoken, e->type) > 0) + fn(data, NULL, ")"); +} + +static void expr_print_file_helper(void *data, struct symbol *sym, const char *str) +{ + xfwrite(str, strlen(str), 1, data); +} + +void expr_fprint(struct expr *e, FILE *out) +{ + expr_print(e, expr_print_file_helper, out, E_NONE); +} + +static void expr_print_gstr_helper(void *data, struct symbol *sym, const char *str) +{ + struct gstr *gs = (struct gstr*)data; + const char *sym_str = NULL; + + if (sym) + sym_str = sym_get_string_value(sym); + + if (gs->max_width) { + unsigned extra_length = strlen(str); + const char *last_cr = strrchr(gs->s, '\n'); + unsigned last_line_length; + + if (sym_str) + extra_length += 4 + strlen(sym_str); + + if (!last_cr) + last_cr = gs->s; + + last_line_length = strlen(gs->s) - (last_cr - gs->s); + + if ((last_line_length + extra_length) > gs->max_width) + str_append(gs, "\\\n"); + } + + str_append(gs, str); + if (sym && sym->type != S_UNKNOWN) + str_printf(gs, " [=%s]", sym_str); +} + +void expr_gstr_print(struct expr *e, struct gstr *gs) +{ + expr_print(e, expr_print_gstr_helper, gs, E_NONE); +} Index: branches/azimutz/Cleancut/i386/config/lkc.h =================================================================== --- branches/azimutz/Cleancut/i386/config/lkc.h (revision 0) +++ branches/azimutz/Cleancut/i386/config/lkc.h (revision 885) @@ -0,0 +1,196 @@ +/* + * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> + * Released under the terms of the GNU GPL v2.0. + */ + +#ifndef LKC_H +#define LKC_H + +#include "expr.h" + +#ifndef KBUILD_NO_NLS +# include <libintl.h> +#else +static inline const char *gettext(const char *txt) { return txt; } +static inline void textdomain(const char *domainname) {} +static inline void bindtextdomain(const char *name, const char *dir) {} +static inline char *bind_textdomain_codeset(const char *dn, char *c) { return c; } +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef LKC_DIRECT_LINK +#define P(name,type,arg) extern type name arg +#else +#include "lkc_defs.h" +#define P(name,type,arg) extern type (*name ## _p) arg +#endif +#include "lkc_proto.h" +#undef P + +#define SRCTREE "srctree" + +#ifndef PACKAGE +#define PACKAGE "linux" +#endif + +#define LOCALEDIR "/usr/share/locale" + +#define _(text) gettext(text) +#define N_(text) (text) + +#ifndef CONFIG_ +#define CONFIG_ "CONFIG_" +#endif + +#define TF_COMMAND 0x0001 +#define TF_PARAM 0x0002 +#define TF_OPTION 0x0004 + +enum conf_def_mode { + def_default, + def_yes, + def_mod, + def_no, + def_random +}; + +#define T_OPT_MODULES 1 +#define T_OPT_DEFCONFIG_LIST 2 +#define T_OPT_ENV 3 + +struct kconf_id { + int name; + int token; + unsigned int flags; + enum symbol_type stype; +}; + +#ifdef YYDEBUG +extern int zconfdebug; +#endif + +int zconfparse(void); +void zconfdump(FILE *out); +void zconf_starthelp(void); +FILE *zconf_fopen(const char *name); +void zconf_initscan(const char *name); +void zconf_nextfile(const char *name); +int zconf_lineno(void); +const char *zconf_curname(void); + +/* conf.c */ +void xfgets(char *str, int size, FILE *in); + +/* confdata.c */ +const char *conf_get_configname(void); +const char *conf_get_autoconfig_name(void); +char *conf_get_default_confname(void); +void sym_set_change_count(int count); +void sym_add_change_count(int count); +void conf_set_all_new_symbols(enum conf_def_mode mode); + +/* confdata.c and expr.c */ +static inline void xfwrite(const void *str, size_t len, size_t count, FILE *out) +{ + if (fwrite(str, len, count, out) < count) + fprintf(stderr, "\nError in writing or end of file.\n"); +} + +/* kconfig_load.c */ +void kconfig_load(void); + +/* menu.c */ +void _menu_init(void); +void menu_warn(struct menu *menu, const char *fmt, ...); +struct menu *menu_add_menu(void); +void menu_end_menu(void); +void menu_add_entry(struct symbol *sym); +void menu_end_entry(void); +void menu_add_dep(struct expr *dep); +void menu_add_visibility(struct expr *dep); +struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *expr, struct expr *dep); +struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep); +void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep); +void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep); +void menu_add_option(int token, char *arg); +void menu_finalize(struct menu *parent); +void menu_set_type(int type); + +/* util.c */ +struct file *file_lookup(const char *name); +int file_write_dep(const char *name); + +struct gstr { + size_t len; + char *s; + /* + * when max_width is not zero long lines in string s (if any) get + * wrapped not to exceed the max_width value + */ + int max_width; +}; +struct gstr str_new(void); +struct gstr str_assign(const char *s); +void str_free(struct gstr *gs); +void str_append(struct gstr *gs, const char *s); +void str_printf(struct gstr *gs, const char *fmt, ...); +const char *str_get(struct gstr *gs); + +/* symbol.c */ +extern struct expr *sym_env_list; + +void sym_init(void); +void sym_clear_all_valid(void); +void sym_set_all_changed(void); +void sym_set_changed(struct symbol *sym); +struct symbol *sym_choice_default(struct symbol *sym); +const char *sym_get_string_default(struct symbol *sym); +struct symbol *sym_check_deps(struct symbol *sym); +struct property *prop_alloc(enum prop_type type, struct symbol *sym); +struct symbol *prop_get_symbol(struct property *prop); +struct property *sym_get_env_prop(struct symbol *sym); + +static inline tristate sym_get_tristate_value(struct symbol *sym) +{ + return sym->curr.tri; +} + + +static inline struct symbol *sym_get_choice_value(struct symbol *sym) +{ + return (struct symbol *)sym->curr.val; +} + +static inline bool sym_set_choice_value(struct symbol *ch, struct symbol *chval) +{ + return sym_set_tristate_value(chval, yes); +} + +static inline bool sym_is_choice(struct symbol *sym) +{ + return sym->flags & SYMBOL_CHOICE ? true : false; +} + +static inline bool sym_is_choice_value(struct symbol *sym) +{ + return sym->flags & SYMBOL_CHOICEVAL ? true : false; +} + +static inline bool sym_is_optional(struct symbol *sym) +{ + return sym->flags & SYMBOL_OPTIONAL ? true : false; +} + +static inline bool sym_has_value(struct symbol *sym) +{ + return sym->flags & SYMBOL_DEF_USER ? true : false; +} + +#ifdef __cplusplus +} +#endif + +#endif /* LKC_H */ Index: branches/azimutz/Cleancut/i386/config/confdata.c =================================================================== --- branches/azimutz/Cleancut/i386/config/confdata.c (revision 0) +++ branches/azimutz/Cleancut/i386/config/confdata.c (revision 885) @@ -0,0 +1,1078 @@ +/* + * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> + * Released under the terms of the GNU GPL v2.0. + */ + +#include <sys/stat.h> +#include <ctype.h> +#include <errno.h> +#include <fcntl.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> +#include <unistd.h> + +#define LKC_DIRECT_LINK +#include "lkc.h" + +static void conf_warning(const char *fmt, ...) + __attribute__ ((format (printf, 1, 2))); + +static void conf_message(const char *fmt, ...) + __attribute__ ((format (printf, 1, 2))); + +static const char *conf_filename; +static int conf_lineno, conf_warnings, conf_unsaved; + +const char conf_defname[] = "config/defconfig"; + +static void conf_warning(const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + fprintf(stderr, "%s:%d:warning: ", conf_filename, conf_lineno); + vfprintf(stderr, fmt, ap); + fprintf(stderr, "\n"); + va_end(ap); + conf_warnings++; +} + +static void conf_default_message_callback(const char *fmt, va_list ap) +{ + printf("#\n# "); + vprintf(fmt, ap); + printf("\n#\n"); +} + +static void (*conf_message_callback) (const char *fmt, va_list ap) = + conf_default_message_callback; +void conf_set_message_callback(void (*fn) (const char *fmt, va_list ap)) +{ + conf_message_callback = fn; +} + +static void conf_message(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + if (conf_message_callback) + conf_message_callback(fmt, ap); +} + +const char *conf_get_configname(void) +{ + char *name = getenv("KCONFIG_CONFIG"); + + return name ? name : ".config"; +} + +const char *conf_get_autoconfig_name(void) +{ + char *name = getenv("KCONFIG_AUTOCONFIG"); + + return name ? name : "auto.conf"; +} + +static char *conf_expand_value(const char *in) +{ + struct symbol *sym; + const char *src; + static char res_value[SYMBOL_MAXLENGTH]; + char *dst, name[SYMBOL_MAXLENGTH]; + + res_value[0] = 0; + dst = name; + while ((src = strchr(in, '$'))) { + strncat(res_value, in, src - in); + src++; + dst = name; + while (isalnum(*src) || *src == '_') + *dst++ = *src++; + *dst = 0; + sym = sym_lookup(name, 0); + sym_calc_value(sym); + strcat(res_value, sym_get_string_value(sym)); + in = src; + } + strcat(res_value, in); + + return res_value; +} + +char *conf_get_default_confname(void) +{ + struct stat buf; + static char fullname[PATH_MAX+1]; + char *env, *name; + + name = conf_expand_value(conf_defname); + env = getenv(SRCTREE); + if (env) { + sprintf(fullname, "%s/%s", env, name); + if (!stat(fullname, &buf)) + return fullname; + } + return name; +} + +static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p) +{ + char *p2; + + switch (sym->type) { + case S_TRISTATE: + if (p[0] == 'm') { + sym->def[def].tri = mod; + sym->flags |= def_flags; + break; + } + case S_BOOLEAN: + if (p[0] == 'y') { + sym->def[def].tri = yes; + sym->flags |= def_flags; + break; + } + if (p[0] == 'n') { + sym->def[def].tri = no; + sym->flags |= def_flags; + break; + } + conf_warning("symbol value '%s' invalid for %s", p, sym->name); + break; + case S_OTHER: + if (*p != '"') { + for (p2 = p; *p2 && !isspace(*p2); p2++) + ; + sym->type = S_STRING; + goto done; + } + case S_STRING: + if (*p++ != '"') + break; + for (p2 = p; (p2 = strpbrk(p2, "\"\\")); p2++) { + if (*p2 == '"') { + *p2 = 0; + break; + } + memmove(p2, p2 + 1, strlen(p2)); + } + if (!p2) { + conf_warning("invalid string found"); + return 1; + } + case S_INT: + case S_HEX: + done: + if (sym_string_valid(sym, p)) { + sym->def[def].val = strdup(p); + sym->flags |= def_flags; + } else { + conf_warning("symbol value '%s' invalid for %s", p, sym->name); + return 1; + } + break; + default: + ; + } + return 0; +} + +int conf_read_simple(const char *name, int def) +{ + FILE *in = NULL; + char line[1024]; + char *p, *p2; + struct symbol *sym; + int i, def_flags; + + if (name) { + in = zconf_fopen(name); + } else { + struct property *prop; + + name = conf_get_configname(); + in = zconf_fopen(name); + if (in) + goto load; + sym_add_change_count(1); + if (!sym_defconfig_list) { + if (modules_sym) + sym_calc_value(modules_sym); + return 1; + } + + for_all_defaults(sym_defconfig_list, prop) { + if (expr_calc_value(prop->visible.expr) == no || + prop->expr->type != E_SYMBOL) + continue; + name = conf_expand_value(prop->expr->left.sym->name); + in = zconf_fopen(name); + if (in) { + conf_message(_("using defaults found in %s"), + name); + goto load; + } + } + } + if (!in) + return 1; + +load: + conf_filename = name; + conf_lineno = 0; + conf_warnings = 0; + conf_unsaved = 0; + + def_flags = SYMBOL_DEF << def; + for_all_symbols(i, sym) { + sym->flags |= SYMBOL_CHANGED; + sym->flags &= ~(def_flags|SYMBOL_VALID); + if (sym_is_choice(sym)) + sym->flags |= def_flags; + switch (sym->type) { + case S_INT: + case S_HEX: + case S_STRING: + if (sym->def[def].val) + free(sym->def[def].val); + default: + sym->def[def].val = NULL; + sym->def[def].tri = no; + } + } + + while (fgets(line, sizeof(line), in)) { + conf_lineno++; + sym = NULL; + if (line[0] == '#') { + if (memcmp(line + 2, CONFIG_, strlen(CONFIG_))) + continue; + p = strchr(line + 2 + strlen(CONFIG_), ' '); + if (!p) + continue; + *p++ = 0; + if (strncmp(p, "is not set", 10)) + continue; + if (def == S_DEF_USER) { + sym = sym_find(line + 2 + strlen(CONFIG_)); + if (!sym) { + sym_add_change_count(1); + goto setsym; + } + } else { + sym = sym_lookup(line + 2 + strlen(CONFIG_), 0); + if (sym->type == S_UNKNOWN) + sym->type = S_BOOLEAN; + } + if (sym->flags & def_flags) { + conf_warning("override: reassigning to symbol %s", sym->name); + } + switch (sym->type) { + case S_BOOLEAN: + case S_TRISTATE: + sym->def[def].tri = no; + sym->flags |= def_flags; + break; + default: + ; + } + } else if (memcmp(line, CONFIG_, strlen(CONFIG_)) == 0) { + p = strchr(line + strlen(CONFIG_), '='); + if (!p) + continue; + *p++ = 0; + p2 = strchr(p, '\n'); + if (p2) { + *p2-- = 0; + if (*p2 == '\r') + *p2 = 0; + } + if (def == S_DEF_USER) { + sym = sym_find(line + strlen(CONFIG_)); + if (!sym) { + sym_add_change_count(1); + goto setsym; + } + } else { + sym = sym_lookup(line + strlen(CONFIG_), 0); + if (sym->type == S_UNKNOWN) + sym->type = S_OTHER; + } + if (sym->flags & def_flags) { + conf_warning("override: reassigning to symbol %s", sym->name); + } + if (conf_set_sym_val(sym, def, def_flags, p)) + continue; + } else { + if (line[0] != '\r' && line[0] != '\n') + conf_warning("unexpected data"); + continue; + } +setsym: + if (sym && sym_is_choice_value(sym)) { + struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym)); + switch (sym->def[def].tri) { + case no: + break; + case mod: + if (cs->def[def].tri == yes) { + conf_warning("%s creates inconsistent choice state", sym->name); + cs->flags &= ~def_flags; + } + break; + case yes: + if (cs->def[def].tri != no) + conf_warning("override: %s changes choice state", sym->name); + cs->def[def].val = sym; + break; + } + cs->def[def].tri = EXPR_OR(cs->def[def].tri, sym->def[def].tri); + } + } + fclose(in); + + if (modules_sym) + sym_calc_value(modules_sym); + return 0; +} + +int conf_read(const char *name) +{ + struct symbol *sym, *choice_sym; + struct property *prop; + struct expr *e; + int i, flags; + + sym_set_change_count(0); + + if (conf_read_simple(name, S_DEF_USER)) + return 1; + + for_all_symbols(i, sym) { + sym_calc_value(sym); + if (sym_is_choice(sym) || (sym->flags & SYMBOL_AUTO)) + goto sym_ok; + if (sym_has_value(sym) && (sym->flags & SYMBOL_WRITE)) { + /* check that calculated value agrees with saved value */ + switch (sym->type) { + case S_BOOLEAN: + case S_TRISTATE: + if (sym->def[S_DEF_USER].tri != sym_get_tristate_value(sym)) + break; + if (!sym_is_choice(sym)) + goto sym_ok; + default: + if (!strcmp(sym->curr.val, sym->def[S_DEF_USER].val)) + goto sym_ok; + break; + } + } else if (!sym_has_value(sym) && !(sym->flags & SYMBOL_WRITE)) + /* no previous value and not saved */ + goto sym_ok; + conf_unsaved++; + /* maybe print value in verbose mode... */ + sym_ok: + if (!sym_is_choice(sym)) + continue; + /* The choice symbol only has a set value (and thus is not new) + * if all its visible childs have values. + */ + prop = sym_get_choice_prop(sym); + flags = sym->flags; + expr_list_for_each_sym(prop->expr, e, choice_sym) + if (choice_sym->visible != no) + flags &= choice_sym->flags; + sym->flags &= flags | ~SYMBOL_DEF_USER; + } + + for_all_symbols(i, sym) { + if (sym_has_value(sym) && !sym_is_choice_value(sym)) { + /* Reset values of generates values, so they'll appear + * as new, if they should become visible, but that + * doesn't quite work if the Kconfig and the saved + * configuration disagree. + */ + if (sym->visible == no && !conf_unsaved) + sym->flags &= ~SYMBOL_DEF_USER; + switch (sym->type) { + case S_STRING: + case S_INT: + case S_HEX: + /* Reset a string value if it's out of range */ + if (sym_string_within_range(sym, sym->def[S_DEF_USER].val)) + break; + sym->flags &= ~(SYMBOL_VALID|SYMBOL_DEF_USER); + conf_unsaved++; + break; + default: + break; + } + } + } + + sym_add_change_count(conf_warnings || conf_unsaved); + + return 0; +} + +/* Write a S_STRING */ +static void conf_write_string(bool headerfile, const char *name, + const char *str, FILE *out) +{ + int l; + if (headerfile) + fprintf(out, "#define %s%s \"", CONFIG_, name); + else + fprintf(out, "%s%s=\"", CONFIG_, name); + + while (1) { + l = strcspn(str, "\"\\"); + if (l) { + xfwrite(str, l, 1, out); + str += l; + } + if (!*str) + break; + fprintf(out, "\\%c", *str++); + } + fputs("\"\n", out); +} + +static void conf_write_symbol(struct symbol *sym, FILE *out, bool write_no) +{ + const char *str; + + switch (sym->type) { + case S_BOOLEAN: + case S_TRISTATE: + switch (sym_get_tristate_value(sym)) { + case no: + if (write_no) + fprintf(out, "# %s%s is not set\n", + CONFIG_, sym->name); + break; + case mod: + fprintf(out, "%s%s=m\n", CONFIG_, sym->name); + break; + case yes: + fprintf(out, "%s%s=y\n", CONFIG_, sym->name); + break; + } + break; + case S_STRING: + conf_write_string(false, sym->name, sym_get_string_value(sym), out); + break; + case S_HEX: + case S_INT: + str = sym_get_string_value(sym); + fprintf(out, "%s%s=%s\n", CONFIG_, sym->name, str); + break; + case S_OTHER: + case S_UNKNOWN: + break; + } +} + +/* + * Write out a minimal config. + * All values that has default values are skipped as this is redundant. + */ +int conf_write_defconfig(const char *filename) +{ + struct symbol *sym; + struct menu *menu; + FILE *out; + + out = fopen(filename, "w"); + if (!out) + return 1; + + sym_clear_all_valid(); + + /* Traverse all menus to find all relevant symbols */ + menu = rootmenu.list; + + while (menu != NULL) + { + sym = menu->sym; + if (sym == NULL) { + if (!menu_is_visible(menu)) + goto next_menu; + } else if (!sym_is_choice(sym)) { + sym_calc_value(sym); + if (!(sym->flags & SYMBOL_WRITE)) + goto next_menu; + sym->flags &= ~SYMBOL_WRITE; + /* If we cannot change the symbol - skip */ + if (!sym_is_changable(sym)) + goto next_menu; + /* If symbol equals to default value - skip */ + if (strcmp(sym_get_string_value(sym), sym_get_string_default(sym)) == 0) + goto next_menu; + + /* + * If symbol is a choice value and equals to the + * default for a choice - skip. + * But only if value is bool and equal to "y" and + * choice is not "optional". + * (If choice is "optional" then all values can be "n") + */ + if (sym_is_choice_value(sym)) { + struct symbol *cs; + struct symbol *ds; + + cs = prop_get_symbol(sym_get_choice_prop(sym)); + ds = sym_choice_default(cs); + if (!sym_is_optional(cs) && sym == ds) { + if ((sym->type == S_BOOLEAN) && + sym_get_tristate_value(sym) == yes) + goto next_menu; + } + } + conf_write_symbol(sym, out, true); + } +next_menu: + if (menu->list != NULL) { + menu = menu->list; + } + else if (menu->next != NULL) { + menu = menu->next; + } else { + while ((menu = menu->parent)) { + if (menu->next != NULL) { + menu = menu->next; + break; + } + } + } + } + fclose(out); + return 0; +} + +int conf_write(const char *name) +{ + FILE *out; + struct symbol *sym; + struct menu *menu; + const char *basename; + const char *str; + char dirname[PATH_MAX+1], tmpname[PATH_MAX+1], newname[PATH_MAX+1]; + time_t now; + int use_timestamp = 1; + char *env; + + dirname[0] = 0; + if (name && name[0]) { + struct stat st; + char *slash; + + if (!stat(name, &st) && S_ISDIR(st.st_mode)) { + strcpy(dirname, name); + strcat(dirname, "/"); + basename = conf_get_configname(); + } else if ((slash = strrchr(name, '/'))) { + int size = slash - name + 1; + memcpy(dirname, name, size); + dirname[size] = 0; + if (slash[1]) + basename = slash + 1; + else + basename = conf_get_configname(); + } else + basename = name; + } else + basename = conf_get_configname(); + + sprintf(newname, "%s%s", dirname, basename); + env = getenv("KCONFIG_OVERWRITECONFIG"); + if (!env || !*env) { + sprintf(tmpname, "%s.tmpconfig.%d", dirname, (int)getpid()); + out = fopen(tmpname, "w"); + } else { + *tmpname = 0; + out = fopen(newname, "w"); + } + if (!out) + return 1; + + time(&now); + env = getenv("KCONFIG_NOTIMESTAMP"); + if (env && *env) + use_timestamp = 0; + + fprintf(out, _("#\n" + "# Automatically generated make config: don't edit\n" + "# %s\n" + "%s%s" + "#\n"), + rootmenu.prompt->text, + use_timestamp ? "# " : "", + use_timestamp ? ctime(&now) : ""); + + if (!conf_get_changed()) + sym_clear_all_valid(); + + menu = rootmenu.list; + while (menu) { + sym = menu->sym; + if (!sym) { + if (!menu_is_visible(menu)) + goto next; + str = menu_get_prompt(menu); + fprintf(out, "\n" + "#\n" + "# %s\n" + "#\n", str); + } else if (!(sym->flags & SYMBOL_CHOICE)) { + sym_calc_value(sym); + if (!(sym->flags & SYMBOL_WRITE)) + goto next; + sym->flags &= ~SYMBOL_WRITE; + /* Write config symbol to file */ + conf_write_symbol(sym, out, true); + } + +next: + if (menu->list) { + menu = menu->list; + continue; + } + if (menu->next) + menu = menu->next; + else while ((menu = menu->parent)) { + if (menu->next) { + menu = menu->next; + break; + } + } + } + fclose(out); + + if (*tmpname) { + strcat(dirname, basename); + strcat(dirname, ".old"); + rename(newname, dirname); + if (rename(tmpname, newname)) + return 1; + } + + conf_message(_("configuration written to %s"), newname); + + sym_set_change_count(0); + + return 0; +} +#if 0 + +static int conf_split_config(void) +{ + const char *name; + char path[PATH_MAX+1]; + char *s, *d, c; + struct symbol *sym; + struct stat sb; + int res, i, fd; + + name = conf_get_autoconfig_name(); + conf_read_simple(name, S_DEF_AUTO); + + //if (chdir("include/config")) + // return 1; + + res = 0; + for_all_symbols(i, sym) { + sym_calc_value(sym); + if ((sym->flags & SYMBOL_AUTO) || !sym->name) + continue; + if (sym->flags & SYMBOL_WRITE) { + if (sym->flags & SYMBOL_DEF_AUTO) { + /* + * symbol has old and new value, + * so compare them... + */ + switch (sym->type) { + case S_BOOLEAN: + case S_TRISTATE: + if (sym_get_tristate_value(sym) == + sym->def[S_DEF_AUTO].tri) + continue; + break; + case S_STRING: + case S_HEX: + case S_INT: + if (!strcmp(sym_get_string_value(sym), + sym->def[S_DEF_AUTO].val)) + continue; + break; + default: + break; + } + } else { + /* + * If there is no old value, only 'no' (unset) + * is allowed as new value. + */ + switch (sym->type) { + case S_BOOLEAN: + case S_TRISTATE: + if (sym_get_tristate_value(sym) == no) + continue; + break; + default: + break; + } + } + } else if (!(sym->flags & SYMBOL_DEF_AUTO)) + /* There is neither an old nor a new value. */ + continue; + /* else + * There is an old value, but no new value ('no' (unset) + * isn't saved in auto.conf, so the old value is always + * different from 'no'). + */ + + /* Replace all '_' and append ".h" */ + s = sym->name; + d = path; + while ((c = *s++)) { + c = tolower(c); + *d++ = (c == '_') ? '/' : c; + } + strcpy(d, ".h"); + + /* Assume directory path already exists. */ + fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644); + if (fd == -1) { + if (errno != ENOENT) { + res = 1; + break; + } + /* + * Create directory components, + * unless they exist already. + */ + d = path; + while ((d = strchr(d, '/'))) { + *d = 0; + if (stat(path, &sb) && mkdir(path, 0755)) { + res = 1; + goto out; + } + *d++ = '/'; + } + /* Try it again. */ + fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644); + if (fd == -1) { + res = 1; + break; + } + } + close(fd); + } +out: + if (chdir("../..")) + return 1; + + return res; +} +#endif +int conf_write_autoconf(void) +{ + struct symbol *sym; + const char *str; + const char *name; + FILE *out, *out_h, *out_inc; + time_t now; + int i; + + sym_clear_all_valid(); + + /*if (conf_split_config()) + { + printf("ERR: conf_split_config"); + return 1; + }*/ + + out = fopen(".tmpconfig", "w"); + if (!out) + { + printf("ERR: .tmpconfig"); + return 1; + } + + out_h = fopen(".tmpconfig.h", "w"); + if (!out_h) { + fclose(out); + return 1; + } + + out_inc = fopen(".tmpconfig.inc", "w"); + if (!out_h) { + fclose(out); + fclose(out_h); + return 1; + } + + + time(&now); + fprintf(out, "#\n" + "# Automatically generated make config: don't edit\n" + "# %s\n" + "# %s" + "#\n", + rootmenu.prompt->text, ctime(&now)); + + fprintf(out_h, "//\n" + "// Automatically generated make config: don't edit\n" + "// %s\n" + "// %s" + "// \n", + rootmenu.prompt->text, ctime(&now)); + + fprintf(out_inc, ";\n" + "; Automatically generated make config: don't edit\n" + "; %s\n" + "; %s" + ";\n", + rootmenu.prompt->text, ctime(&now)); + + + fprintf(out_h, "#define CONFIG_IS_BUILTIN 1\n"); + fprintf(out_h, "#define CONFIG_IS_MODULE 2\n"); + + + for_all_symbols(i, sym) { + sym_calc_value(sym); + if (!(sym->flags & SYMBOL_WRITE) || !sym->name) + continue; + + /* write symbol to config file */ + conf_write_symbol(sym, out, false); + + /* update autoconf and tristate files */ + switch (sym->type) { + case S_BOOLEAN: + case S_TRISTATE: + switch (sym_get_tristate_value(sym)) { + case no: + fprintf(out_inc, "%s%s EQU 0\n", + CONFIG_, sym->name); + + break; + case mod: + fprintf(out_inc, "%s%s EQU 1\n", + CONFIG_, sym->name); + fprintf(out_h, "#define %s%s CONFIG_IS_MODULE\n", + CONFIG_, sym->name); + + break; + case yes: + fprintf(out_inc, "%s%s EQU 1\n", + CONFIG_, sym->name); + fprintf(out_h, "#define %s%s CONFIG_IS_BUILTIN\n", + CONFIG_, sym->name); + break; + } + break; + case S_STRING: + conf_write_string(true, sym->name, sym_get_string_value(sym), out_h); + break; + case S_HEX: + str = sym_get_string_value(sym); + if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) { + fprintf(out_inc, "%s%s EQU 0x%s\n", + CONFIG_, sym->name, str); + fprintf(out_h, "#define %s%s 0x%s\n", + CONFIG_, sym->name, str); + break; + } + case S_INT: + str = sym_get_string_value(sym); + fprintf(out_inc, "%s%s EQU %s\n", + CONFIG_, sym->name, str); + fprintf(out_h, "#define %s%s %s\n", + CONFIG_, sym->name, str); + break; + default: + break; + } + } + fclose(out); + fclose(out_h); + + name = getenv("CCONFIG_AUTOHEADER"); + if (!name) name = "autoconf.h"; + if (rename(".tmpconfig.h", name)) + return 1; + + name = getenv("CCONFIG_AUTOINC"); + if (!name) name = "autoconf.inc"; + if (rename(".tmpconfig.inc", name)) + return 1; + + + name = conf_get_autoconfig_name(); + /* + * This must be the last step, kbuild has a dependency on auto.conf + * and this marks the successful completion of the previous steps. + */ + if (rename(".tmpconfig", name)) + { + printf("rename"); + return 1; + } + return 0; +} + +static int sym_change_count; +static void (*conf_changed_callback)(void); + +void sym_set_change_count(int count) +{ + int _sym_change_count = sym_change_count; + sym_change_count = count; + if (conf_changed_callback && + (bool)_sym_change_count != (bool)count) + conf_changed_callback(); +} + +void sym_add_change_count(int count) +{ + sym_set_change_count(count + sym_change_count); +} + +bool conf_get_changed(void) +{ + return sym_change_count; +} + +void conf_set_changed_callback(void (*fn)(void)) +{ + conf_changed_callback = fn; +} + +static void randomize_choice_values(struct symbol *csym) +{ + struct property *prop; + struct symbol *sym; + struct expr *e; + int cnt, def; + + /* + * If choice is mod then we may have more items selected + * and if no then no-one. + * In both cases stop. + */ + if (csym->curr.tri != yes) + return; + + prop = sym_get_choice_prop(csym); + + /* count entries in choice block */ + cnt = 0; + expr_list_for_each_sym(prop->expr, e, sym) + cnt++; + + /* + * find a random value and set it to yes, + * set the rest to no so we have only one set + */ + def = (rand() % cnt); + + cnt = 0; + expr_list_for_each_sym(prop->expr, e, sym) { + if (def == cnt++) { + sym->def[S_DEF_USER].tri = yes; + csym->def[S_DEF_USER].val = sym; + } + else { + sym->def[S_DEF_USER].tri = no; + } + } + csym->flags |= SYMBOL_DEF_USER; + /* clear VALID to get value calculated */ + csym->flags &= ~(SYMBOL_VALID); +} + +static void set_all_choice_values(struct symbol *csym) +{ + struct property *prop; + struct symbol *sym; + struct expr *e; + + prop = sym_get_choice_prop(csym); + + /* + * Set all non-assinged choice values to no + */ + expr_list_for_each_sym(prop->expr, e, sym) { + if (!sym_has_value(sym)) + sym->def[S_DEF_USER].tri = no; + } + csym->flags |= SYMBOL_DEF_USER; + /* clear VALID to get value calculated */ + csym->flags &= ~(SYMBOL_VALID); +} + +void conf_set_all_new_symbols(enum conf_def_mode mode) +{ + struct symbol *sym, *csym; + int i, cnt; + + for_all_symbols(i, sym) { + if (sym_has_value(sym)) + continue; + switch (sym_get_type(sym)) { + case S_BOOLEAN: + case S_TRISTATE: + switch (mode) { + case def_yes: + sym->def[S_DEF_USER].tri = yes; + break; + case def_mod: + sym->def[S_DEF_USER].tri = mod; + break; + case def_no: + sym->def[S_DEF_USER].tri = no; + break; + case def_random: + cnt = sym_get_type(sym) == S_TRISTATE ? 3 : 2; + sym->def[S_DEF_USER].tri = (tristate)(rand() % cnt); + break; + default: + continue; + } + if (!(sym_is_choice(sym) && mode == def_random)) + sym->flags |= SYMBOL_DEF_USER; + break; + default: + break; + } + + } + + sym_clear_all_valid(); + + /* + * We have different type of choice blocks. + * If curr.tri equals to mod then we can select several + * choice symbols in one block. + * In this case we do nothing. + * If curr.tri equals yes then only one symbol can be + * selected in a choice block and we set it to yes, + * and the rest to no. + */ + for_all_symbols(i, csym) { + if (sym_has_value(csym) || !sym_is_choice(csym)) + continue; + + sym_calc_value(csym); + if (mode == def_random) + randomize_choice_values(csym); + else + set_all_choice_values(csym); + } +} Index: branches/azimutz/Cleancut/i386/config/lxdialog/.gitignore =================================================================== --- branches/azimutz/Cleancut/i386/config/lxdialog/.gitignore (revision 0) +++ branches/azimutz/Cleancut/i386/config/lxdialog/.gitignore (revision 885) @@ -0,0 +1,4 @@ +# +# Generated files +# +lxdialog Index: branches/azimutz/Cleancut/i386/config/lxdialog/dialog.h =================================================================== --- branches/azimutz/Cleancut/i386/config/lxdialog/dialog.h (revision 0) +++ branches/azimutz/Cleancut/i386/config/lxdialog/dialog.h (revision 885) @@ -0,0 +1,230 @@ +/* + * dialog.h -- common declarations for all dialog modules + * + * AUTHOR: Savio Lam (lam836@cs.cuhk.hk) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include <sys/types.h> +#include <fcntl.h> +#include <unistd.h> +#include <ctype.h> +#include <stdlib.h> +#include <string.h> +#include <stdbool.h> + +#ifndef KBUILD_NO_NLS +# include <libintl.h> +#else +# define gettext(Msgid) ((const char *) (Msgid)) +#endif + +#ifdef __sun__ +#define CURS_MACROS +#endif +#include CURSES_LOC + +/* + * Colors in ncurses 1.9.9e do not work properly since foreground and + * background colors are OR'd rather than separately masked. This version + * of dialog was hacked to work with ncurses 1.9.9e, making it incompatible + * with standard curses. The simplest fix (to make this work with standard + * curses) uses the wbkgdset() function, not used in the original hack. + * Turn it off if we're building with 1.9.9e, since it just confuses things. + */ +#if defined(NCURSES_VERSION) && defined(_NEED_WRAP) && !defined(GCC_PRINTFLIKE) +#define OLD_NCURSES 1 +#undef wbkgdset +#define wbkgdset(w,p) /*nothing */ +#else +#define OLD_NCURSES 0 +#endif + +#define TR(params) _tracef params + +#define KEY_ESC 27 +#define TAB 9 +#define MAX_LEN 2048 +#define BUF_SIZE (10*1024) +#define MIN(x,y) (x < y ? x : y) +#define MAX(x,y) (x > y ? x : y) + +#ifndef ACS_ULCORNER +#define ACS_ULCORNER '+' +#endif +#ifndef ACS_LLCORNER +#define ACS_LLCORNER '+' +#endif +#ifndef ACS_URCORNER +#define ACS_URCORNER '+' +#endif +#ifndef ACS_LRCORNER +#define ACS_LRCORNER '+' +#endif +#ifndef ACS_HLINE +#define ACS_HLINE '-' +#endif +#ifndef ACS_VLINE +#define ACS_VLINE '|' +#endif +#ifndef ACS_LTEE +#define ACS_LTEE '+' +#endif +#ifndef ACS_RTEE +#define ACS_RTEE '+' +#endif +#ifndef ACS_UARROW +#define ACS_UARROW '^' +#endif +#ifndef ACS_DARROW +#define ACS_DARROW 'v' +#endif + +/* error return codes */ +#define ERRDISPLAYTOOSMALL (KEY_MAX + 1) + +/* + * Color definitions + */ +struct dialog_color { + chtype atr; /* Color attribute */ + int fg; /* foreground */ + int bg; /* background */ + int hl; /* highlight this item */ +}; + +struct dialog_info { + const char *backtitle; + struct dialog_color screen; + struct dialog_color shadow; + struct dialog_color dialog; + struct dialog_color title; + struct dialog_color border; + struct dialog_color button_active; + struct dialog_color button_inactive; + struct dialog_color button_key_active; + struct dialog_color button_key_inactive; + struct dialog_color button_label_active; + struct dialog_color button_label_inactive; + struct dialog_color inputbox; + struct dialog_color inputbox_border; + struct dialog_color searchbox; + struct dialog_color searchbox_title; + struct dialog_color searchbox_border; + struct dialog_color position_indicator; + struct dialog_color menubox; + struct dialog_color menubox_border; + struct dialog_color item; + struct dialog_color item_selected; + struct dialog_color tag; + struct dialog_color tag_selected; + struct dialog_color tag_key; + struct dialog_color tag_key_selected; + struct dialog_color check; + struct dialog_color check_selected; + struct dialog_color uarrow; + struct dialog_color darrow; +}; + +/* + * Global variables + */ +extern struct dialog_info dlg; +extern char dialog_input_result[]; + +/* + * Function prototypes + */ + +/* item list as used by checklist and menubox */ +void item_reset(void); +void item_make(const char *fmt, ...); +void item_add_str(const char *fmt, ...); +void item_set_tag(char tag); +void item_set_data(void *p); +void item_set_selected(int val); +int item_activate_selected(void); +void *item_data(void); +char item_tag(void); + +/* item list manipulation for lxdialog use */ +#define MAXITEMSTR 200 +struct dialog_item { + char str[MAXITEMSTR]; /* promtp displayed */ + char tag; + void *data; /* pointer to menu item - used by menubox+checklist */ + int selected; /* Set to 1 by dialog_*() function if selected. */ +}; + +/* list of lialog_items */ +struct dialog_list { + struct dialog_item node; + struct dialog_list *next; +}; + +extern struct dialog_list *item_cur; +extern struct dialog_list item_nil; +extern struct dialog_list *item_head; + +int item_count(void); +void item_set(int n); +int item_n(void); +const char *item_str(void); +int item_is_selected(void); +int item_is_tag(char tag); +#define item_foreach() \ + for (item_cur = item_head ? item_head: item_cur; \ + item_cur && (item_cur != &item_nil); item_cur = item_cur->next) + +/* generic key handlers */ +int on_key_esc(WINDOW *win); +int on_key_resize(void); + +int init_dialog(const char *backtitle); +void set_dialog_backtitle(const char *backtitle); +void end_dialog(int x, int y); +void attr_clear(WINDOW * win, int height, int width, chtype attr); +void dialog_clear(void); +void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x); +void print_button(WINDOW * win, const char *label, int y, int x, int selected); +void print_title(WINDOW *dialog, const char *title, int width); +void draw_box(WINDOW * win, int y, int x, int height, int width, chtype box, + chtype border); +void draw_shadow(WINDOW * win, int y, int x, int height, int width); + +int first_alpha(const char *string, const char *exempt); +int dialog_yesno(const char *title, const char *prompt, int height, int width); +int dialog_msgbox(const char *title, const char *prompt, int height, + int width, int pause); +int dialog_textbox(const char *title, const char *file, int height, int width); +int dialog_menu(const char *title, const char *prompt, + const void *selected, int *s_scroll); +int dialog_checklist(const char *title, const char *prompt, int height, + int width, int list_height); +extern char dialog_input_result[]; +int dialog_inputbox(const char *title, const char *prompt, int height, + int width, const char *init); + +/* + * This is the base for fictitious keys, which activate + * the buttons. + * + * Mouse-generated keys are the following: + * -- the first 32 are used as numbers, in addition to '0'-'9' + * -- the lowercase are used to signal mouse-enter events (M_EVENT + 'o') + * -- uppercase chars are used to invoke the button (M_EVENT + 'O') + */ +#define M_EVENT (KEY_MAX+1) Index: branches/azimutz/Cleancut/i386/config/lxdialog/check-lxdialog.sh =================================================================== --- branches/azimutz/Cleancut/i386/config/lxdialog/check-lxdialog.sh (revision 0) +++ branches/azimutz/Cleancut/i386/config/lxdialog/check-lxdialog.sh (revision 885) @@ -0,0 +1,84 @@ +#!/bin/sh +# Check ncurses compatibility + +# What library to link +ldflags() +{ + for ext in so a dylib ; do + for lib in ncursesw ncurses curses ; do + $cc -print-file-name=lib${lib}.${ext} | grep -q / + if [ $? -eq 0 ]; then + echo "-l${lib}" + exit + fi + done + done + exit 1 +} + +# Where is ncurses.h? +ccflags() +{ + if [ -f /usr/include/ncurses/ncurses.h ]; then + echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"' + elif [ -f /usr/include/ncurses/curses.h ]; then + echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses/curses.h>"' + elif [ -f /usr/include/ncursesw/curses.h ]; then + echo '-I/usr/include/ncursesw -DCURSES_LOC="<ncursesw/curses.h>"' + elif [ -f /usr/include/ncurses.h ]; then + echo '-DCURSES_LOC="<ncurses.h>"' + else + echo '-DCURSES_LOC="<curses.h>"' + fi +} + +# Temp file, try to clean up after us +tmp=.lxdialog.tmp +trap "rm -f $tmp" 0 1 2 3 15 + +# Check if we can link to ncurses +check() { + $cc -xc - -o $tmp 2>/dev/null <<'EOF' +#include CURSES_LOC +main() {} +EOF + if [ $? != 0 ]; then + echo " *** Unable to find the ncurses libraries or the" 1>&2 + echo " *** required header files." 1>&2 + echo " *** 'make menuconfig' requires the ncurses libraries." 1>&2 + echo " *** " 1>&2 + echo " *** Install ncurses (ncurses-devel) and try again." 1>&2 + echo " *** " 1>&2 + exit 1 + fi +} + +usage() { + printf "Usage: $0 [-check compiler options|-ccflags|-ldflags compiler options]\n" +} + +if [ $# -eq 0 ]; then + usage + exit 1 +fi + +cc="" +case "$1" in + "-check") + shift + cc="$@" + check + ;; + "-ccflags") + ccflags + ;; + "-ldflags") + shift + cc="$@" + ldflags + ;; + "*") + usage + exit 1 + ;; +esac Index: branches/azimutz/Cleancut/i386/config/lxdialog/inputbox.c =================================================================== --- branches/azimutz/Cleancut/i386/config/lxdialog/inputbox.c (revision 0) +++ branches/azimutz/Cleancut/i386/config/lxdialog/inputbox.c (revision 885) @@ -0,0 +1,238 @@ +/* + * inputbox.c -- implements the input box + * + * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) + * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "dialog.h" + +char dialog_input_result[MAX_LEN + 1]; + +/* + * Print the termination buttons + */ +static void print_buttons(WINDOW * dialog, int height, int width, int selected) +{ + int x = width / 2 - 11; + int y = height - 2; + + print_button(dialog, gettext(" Ok "), y, x, selected == 0); + print_button(dialog, gettext(" Help "), y, x + 14, selected == 1); + + wmove(dialog, y, x + 1 + 14 * selected); + wrefresh(dialog); +} + +/* + * Display a dialog box for inputing a string + */ +int dialog_inputbox(const char *title, const char *prompt, int height, int width, + const char *init) +{ + int i, x, y, box_y, box_x, box_width; + int input_x = 0, scroll = 0, key = 0, button = -1; + char *instr = dialog_input_result; + WINDOW *dialog; + + if (!init) + instr[0] = '\0'; + else + strcpy(instr, init); + +do_resize: + if (getmaxy(stdscr) <= (height - 2)) + return -ERRDISPLAYTOOSMALL; + if (getmaxx(stdscr) <= (width - 2)) + return -ERRDISPLAYTOOSMALL; + + /* center dialog box on screen */ + x = (COLS - width) / 2; + y = (LINES - height) / 2; + + draw_shadow(stdscr, y, x, height, width); + + dialog = newwin(height, width, y, x); + keypad(dialog, TRUE); + + draw_box(dialog, 0, 0, height, width, + dlg.dialog.atr, dlg.border.atr); + wattrset(dialog, dlg.border.atr); + mvwaddch(dialog, height - 3, 0, ACS_LTEE); + for (i = 0; i < width - 2; i++) + waddch(dialog, ACS_HLINE); + wattrset(dialog, dlg.dialog.atr); + waddch(dialog, ACS_RTEE); + + print_title(dialog, title, width); + + wattrset(dialog, dlg.dialog.atr); + print_autowrap(dialog, prompt, width - 2, 1, 3); + + /* Draw the input field box */ + box_width = width - 6; + getyx(dialog, y, x); + box_y = y + 2; + box_x = (width - box_width) / 2; + draw_box(dialog, y + 1, box_x - 1, 3, box_width + 2, + dlg.dialog.atr, dlg.border.atr); + + print_buttons(dialog, height, width, 0); + + /* Set up the initial value */ + wmove(dialog, box_y, box_x); + wattrset(dialog, dlg.inputbox.atr); + + input_x = strlen(instr); + + if (input_x >= box_width) { + scroll = input_x - box_width + 1; + input_x = box_width - 1; + for (i = 0; i < box_width - 1; i++) + waddch(dialog, instr[scroll + i]); + } else { + waddstr(dialog, instr); + } + + wmove(dialog, box_y, box_x + input_x); + + wrefresh(dialog); + + while (key != KEY_ESC) { + key = wgetch(dialog); + + if (button == -1) { /* Input box selected */ + switch (key) { + case TAB: + case KEY_UP: + case KEY_DOWN: + break; + case KEY_LEFT: + continue; + case KEY_RIGHT: + continue; + case KEY_BACKSPACE: + case 127: + if (input_x || scroll) { + wattrset(dialog, dlg.inputbox.atr); + if (!input_x) { + scroll = scroll < box_width - 1 ? 0 : scroll - (box_width - 1); + wmove(dialog, box_y, box_x); + for (i = 0; i < box_width; i++) + waddch(dialog, + instr[scroll + input_x + i] ? + instr[scroll + input_x + i] : ' '); + input_x = strlen(instr) - scroll; + } else + input_x--; + instr[scroll + input_x] = '\0'; + mvwaddch(dialog, box_y, input_x + box_x, ' '); + wmove(dialog, box_y, input_x + box_x); + wrefresh(dialog); + } + continue; + default: + if (key < 0x100 && isprint(key)) { + if (scroll + input_x < MAX_LEN) { + wattrset(dialog, dlg.inputbox.atr); + instr[scroll + input_x] = key; + instr[scroll + input_x + 1] = '\0'; + if (input_x == box_width - 1) { + scroll++; + wmove(dialog, box_y, box_x); + for (i = 0; i < box_width - 1; i++) + waddch(dialog, instr [scroll + i]); + } else { + wmove(dialog, box_y, input_x++ + box_x); + waddch(dialog, key); + } + wrefresh(dialog); + } else + flash(); /* Alarm user about overflow */ + continue; + } + } + } + switch (key) { + case 'O': + case 'o': + delwin(dialog); + return 0; + case 'H': + case 'h': + delwin(dialog); + return 1; + case KEY_UP: + case KEY_LEFT: + switch (button) { + case -1: + button = 1; /* Indicates "Help" button is selected */ + print_buttons(dialog, height, width, 1); + break; + case 0: + button = -1; /* Indicates input box is selected */ + print_buttons(dialog, height, width, 0); + wmove(dialog, box_y, box_x + input_x); + wrefresh(dialog); + break; + case 1: + button = 0; /* Indicates "OK" button is selected */ + print_buttons(dialog, height, width, 0); + break; + } + break; + case TAB: + case KEY_DOWN: + case KEY_RIGHT: + switch (button) { + case -1: + button = 0; /* Indicates "OK" button is selected */ + print_buttons(dialog, height, width, 0); + break; + case 0: + button = 1; /* Indicates "Help" button is selected */ + print_buttons(dialog, height, width, 1); + break; + case 1: + button = -1; /* Indicates input box is selected */ + print_buttons(dialog, height, width, 0); + wmove(dialog, box_y, box_x + input_x); + wrefresh(dialog); + break; + } + break; + case ' ': + case '\n': + delwin(dialog); + return (button == -1 ? 0 : button); + case 'X': + case 'x': + key = KEY_ESC; + break; + case KEY_ESC: + key = on_key_esc(dialog); + break; + case KEY_RESIZE: + delwin(dialog); + on_key_resize(); + goto do_resize; + } + } + + delwin(dialog); + return KEY_ESC; /* ESC pressed */ +} Index: branches/azimutz/Cleancut/i386/config/lxdialog/checklist.c =================================================================== --- branches/azimutz/Cleancut/i386/config/lxdialog/checklist.c (revision 0) +++ branches/azimutz/Cleancut/i386/config/lxdialog/checklist.c (revision 885) @@ -0,0 +1,332 @@ +/* + * checklist.c -- implements the checklist box + * + * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) + * Stuart Herbert - S.Herbert@sheffield.ac.uk: radiolist extension + * Alessandro Rubini - rubini@ipvvis.unipv.it: merged the two + * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "dialog.h" + +static int list_width, check_x, item_x; + +/* + * Print list item + */ +static void print_item(WINDOW * win, int choice, int selected) +{ + int i; + char *list_item = malloc(list_width + 1); + + strncpy(list_item, item_str(), list_width - item_x); + list_item[list_width - item_x] = '\0'; + + /* Clear 'residue' of last item */ + wattrset(win, dlg.menubox.atr); + wmove(win, choice, 0); + for (i = 0; i < list_width; i++) + waddch(win, ' '); + + wmove(win, choice, check_x); + wattrset(win, selected ? dlg.check_selected.atr + : dlg.check.atr); + if (!item_is_tag(':')) + wprintw(win, "(%c)", item_is_tag('X') ? 'X' : ' '); + + wattrset(win, selected ? dlg.tag_selected.atr : dlg.tag.atr); + mvwaddch(win, choice, item_x, list_item[0]); + wattrset(win, selected ? dlg.item_selected.atr : dlg.item.atr); + waddstr(win, list_item + 1); + if (selected) { + wmove(win, choice, check_x + 1); + wrefresh(win); + } + free(list_item); +} + +/* + * Print the scroll indicators. + */ +static void print_arrows(WINDOW * win, int choice, int item_no, int scroll, + int y, int x, int height) +{ + wmove(win, y, x); + + if (scroll > 0) { + wattrset(win, dlg.uarrow.atr); + waddch(win, ACS_UARROW); + waddstr(win, "(-)"); + } else { + wattrset(win, dlg.menubox.atr); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + } + + y = y + height + 1; + wmove(win, y, x); + + if ((height < item_no) && (scroll + choice < item_no - 1)) { + wattrset(win, dlg.darrow.atr); + waddch(win, ACS_DARROW); + waddstr(win, "(+)"); + } else { + wattrset(win, dlg.menubox_border.atr); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + } +} + +/* + * Display the termination buttons + */ +static void print_buttons(WINDOW * dialog, int height, int width, int selected) +{ + int x = width / 2 - 11; + int y = height - 2; + + print_button(dialog, gettext("Select"), y, x, selected == 0); + print_button(dialog, gettext(" Help "), y, x + 14, selected == 1); + + wmove(dialog, y, x + 1 + 14 * selected); + wrefresh(dialog); +} + +/* + * Display a dialog box with a list of options that can be turned on or off + * in the style of radiolist (only one option turned on at a time). + */ +int dialog_checklist(const char *title, const char *prompt, int height, + int width, int list_height) +{ + int i, x, y, box_x, box_y; + int key = 0, button = 0, choice = 0, scroll = 0, max_choice; + WINDOW *dialog, *list; + + /* which item to highlight */ + item_foreach() { + if (item_is_tag('X')) + choice = item_n(); + if (item_is_selected()) { + choice = item_n(); + break; + } + } + +do_resize: + if (getmaxy(stdscr) < (height + 6)) + return -ERRDISPLAYTOOSMALL; + if (getmaxx(stdscr) < (width + 6)) + return -ERRDISPLAYTOOSMALL; + + max_choice = MIN(list_height, item_count()); + + /* center dialog box on screen */ + x = (COLS - width) / 2; + y = (LINES - height) / 2; + + draw_shadow(stdscr, y, x, height, width); + + dialog = newwin(height, width, y, x); + keypad(dialog, TRUE); + + draw_box(dialog, 0, 0, height, width, + dlg.dialog.atr, dlg.border.atr); + wattrset(dialog, dlg.border.atr); + mvwaddch(dialog, height - 3, 0, ACS_LTEE); + for (i = 0; i < width - 2; i++) + waddch(dialog, ACS_HLINE); + wattrset(dialog, dlg.dialog.atr); + waddch(dialog, ACS_RTEE); + + print_title(dialog, title, width); + + wattrset(dialog, dlg.dialog.atr); + print_autowrap(dialog, prompt, width - 2, 1, 3); + + list_width = width - 6; + box_y = height - list_height - 5; + box_x = (width - list_width) / 2 - 1; + + /* create new window for the list */ + list = subwin(dialog, list_height, list_width, y + box_y + 1, + x + box_x + 1); + + keypad(list, TRUE); + + /* draw a box around the list items */ + draw_box(dialog, box_y, box_x, list_height + 2, list_width + 2, + dlg.menubox_border.atr, dlg.menubox.atr); + + /* Find length of longest item in order to center checklist */ + check_x = 0; + item_foreach() + check_x = MAX(check_x, strlen(item_str()) + 4); + check_x = MIN(check_x, list_width); + + check_x = (list_width - check_x) / 2; + item_x = check_x + 4; + + if (choice >= list_height) { + scroll = choice - list_height + 1; + choice -= scroll; + } + + /* Print the list */ + for (i = 0; i < max_choice; i++) { + item_set(scroll + i); + print_item(list, i, i == choice); + } + + print_arrows(dialog, choice, item_count(), scroll, + box_y, box_x + check_x + 5, list_height); + + print_buttons(dialog, height, width, 0); + + wnoutrefresh(dialog); + wnoutrefresh(list); + doupdate(); + + while (key != KEY_ESC) { + key = wgetch(dialog); + + for (i = 0; i < max_choice; i++) { + item_set(i + scroll); + if (toupper(key) == toupper(item_str()[0])) + break; + } + + if (i < max_choice || key == KEY_UP || key == KEY_DOWN || + key == '+' || key == '-') { + if (key == KEY_UP || key == '-') { + if (!choice) { + if (!scroll) + continue; + /* Scroll list down */ + if (list_height > 1) { + /* De-highlight current first item */ + item_set(scroll); + print_item(list, 0, FALSE); + scrollok(list, TRUE); + wscrl(list, -1); + scrollok(list, FALSE); + } + scroll--; + item_set(scroll); + print_item(list, 0, TRUE); + print_arrows(dialog, choice, item_count(), + scroll, box_y, box_x + check_x + 5, list_height); + + wnoutrefresh(dialog); + wrefresh(list); + + continue; /* wait for another key press */ + } else + i = choice - 1; + } else if (key == KEY_DOWN || key == '+') { + if (choice == max_choice - 1) { + if (scroll + choice >= item_count() - 1) + continue; + /* Scroll list up */ + if (list_height > 1) { + /* De-highlight current last item before scrolling up */ + item_set(scroll + max_choice - 1); + print_item(list, + max_choice - 1, + FALSE); + scrollok(list, TRUE); + wscrl(list, 1); + scrollok(list, FALSE); + } + scroll++; + item_set(scroll + max_choice - 1); + print_item(list, max_choice - 1, TRUE); + + print_arrows(dialog, choice, item_count(), + scroll, box_y, box_x + check_x + 5, list_height); + + wnoutrefresh(dialog); + wrefresh(list); + + continue; /* wait for another key press */ + } else + i = choice + 1; + } + if (i != choice) { + /* De-highlight current item */ + item_set(scroll + choice); + print_item(list, choice, FALSE); + /* Highlight new item */ + choice = i; + item_set(scroll + choice); + print_item(list, choice, TRUE); + wnoutrefresh(dialog); + wrefresh(list); + } + continue; /* wait for another key press */ + } + switch (key) { + case 'H': + case 'h': + case '?': + button = 1; + /* fall-through */ + case 'S': + case 's': + case ' ': + case '\n': + item_foreach() + item_set_selected(0); + item_set(scroll + choice); + item_set_selected(1); + delwin(list); + delwin(dialog); + return button; + case TAB: + case KEY_LEFT: + case KEY_RIGHT: + button = ((key == KEY_LEFT ? --button : ++button) < 0) + ? 1 : (button > 1 ? 0 : button); + + print_buttons(dialog, height, width, button); + wrefresh(dialog); + break; + case 'X': + case 'x': + key = KEY_ESC; + break; + case KEY_ESC: + key = on_key_esc(dialog); + break; + case KEY_RESIZE: + delwin(list); + delwin(dialog); + on_key_resize(); + goto do_resize; + } + + /* Now, update everything... */ + doupdate(); + } + delwin(list); + delwin(dialog); + return key; /* ESC pressed */ +} Index: branches/azimutz/Cleancut/i386/config/lxdialog/BIG.FAT.WARNING =================================================================== --- branches/azimutz/Cleancut/i386/config/lxdialog/BIG.FAT.WARNING (revision 0) +++ branches/azimutz/Cleancut/i386/config/lxdialog/BIG.FAT.WARNING (revision 885) @@ -0,0 +1,4 @@ +This is NOT the official version of dialog. This version has been +significantly modified from the original. It is for use by the Linux +kernel configuration script. Please do not bother Savio Lam with +questions about this program. Index: branches/azimutz/Cleancut/i386/config/lxdialog/menubox.c =================================================================== --- branches/azimutz/Cleancut/i386/config/lxdialog/menubox.c (revision 0) +++ branches/azimutz/Cleancut/i386/config/lxdialog/menubox.c (revision 885) @@ -0,0 +1,434 @@ +/* + * menubox.c -- implements the menu box + * + * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) + * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcapw@cfw.com) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* + * Changes by Clifford Wolf (god@clifford.at) + * + * [ 1998-06-13 ] + * + * *) A bugfix for the Page-Down problem + * + * *) Formerly when I used Page Down and Page Up, the cursor would be set + * to the first position in the menu box. Now lxdialog is a bit + * smarter and works more like other menu systems (just have a look at + * it). + * + * *) Formerly if I selected something my scrolling would be broken because + * lxdialog is re-invoked by the Menuconfig shell script, can't + * remember the last scrolling position, and just sets it so that the + * cursor is at the bottom of the box. Now it writes the temporary file + * lxdialog.scrltmp which contains this information. The file is + * deleted by lxdialog if the user leaves a submenu or enters a new + * one, but it would be nice if Menuconfig could make another "rm -f" + * just to be sure. Just try it out - you will recognise a difference! + * + * [ 1998-06-14 ] + * + * *) Now lxdialog is crash-safe against broken "lxdialog.scrltmp" files + * and menus change their size on the fly. + * + * *) If for some reason the last scrolling position is not saved by + * lxdialog, it sets the scrolling so that the selected item is in the + * middle of the menu box, not at the bottom. + * + * 02 January 1999, Michael Elizabeth Chastain (mec@shout.net) + * Reset 'scroll' to 0 if the value from lxdialog.scrltmp is bogus. + * This fixes a bug in Menuconfig where using ' ' to descend into menus + * would leave mis-synchronized lxdialog.scrltmp files lying around, + * fscanf would read in 'scroll', and eventually that value would get used. + */ + +#include "dialog.h" + +static int menu_width, item_x; + +/* + * Print menu item + */ +static void do_print_item(WINDOW * win, const char *item, int line_y, + int selected, int hotkey) +{ + int j; + char *menu_item = malloc(menu_width + 1); + + strncpy(menu_item, item, menu_width - item_x); + menu_item[menu_width - item_x] = '\0'; + j = first_alpha(menu_item, "YyNnMmHh"); + + /* Clear 'residue' of last item */ + wattrset(win, dlg.menubox.atr); + wmove(win, line_y, 0); +#if OLD_NCURSES + { + int i; + for (i = 0; i < menu_width; i++) + waddch(win, ' '); + } +#else + wclrtoeol(win); +#endif + wattrset(win, selected ? dlg.item_selected.atr : dlg.item.atr); + mvwaddstr(win, line_y, item_x, menu_item); + if (hotkey) { + wattrset(win, selected ? dlg.tag_key_selected.atr + : dlg.tag_key.atr); + mvwaddch(win, line_y, item_x + j, menu_item[j]); + } + if (selected) { + wmove(win, line_y, item_x + 1); + } + free(menu_item); + wrefresh(win); +} + +#define print_item(index, choice, selected) \ +do { \ + item_set(index); \ + do_print_item(menu, item_str(), choice, selected, !item_is_tag(':')); \ +} while (0) + +/* + * Print the scroll indicators. + */ +static void print_arrows(WINDOW * win, int item_no, int scroll, int y, int x, + int height) +{ + int cur_y, cur_x; + + getyx(win, cur_y, cur_x); + + wmove(win, y, x); + + if (scroll > 0) { + wattrset(win, dlg.uarrow.atr); + waddch(win, ACS_UARROW); + waddstr(win, "(-)"); + } else { + wattrset(win, dlg.menubox.atr); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + } + + y = y + height + 1; + wmove(win, y, x); + wrefresh(win); + + if ((height < item_no) && (scroll + height < item_no)) { + wattrset(win, dlg.darrow.atr); + waddch(win, ACS_DARROW); + waddstr(win, "(+)"); + } else { + wattrset(win, dlg.menubox_border.atr); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + } + + wmove(win, cur_y, cur_x); + wrefresh(win); +} + +/* + * Display the termination buttons. + */ +static void print_buttons(WINDOW * win, int height, int width, int selected) +{ + int x = width / 2 - 16; + int y = height - 2; + + print_button(win, gettext("Select"), y, x, selected == 0); + print_button(win, gettext(" Exit "), y, x + 12, selected == 1); + print_button(win, gettext(" Help "), y, x + 24, selected == 2); + + wmove(win, y, x + 1 + 12 * selected); + wrefresh(win); +} + +/* scroll up n lines (n may be negative) */ +static void do_scroll(WINDOW *win, int *scroll, int n) +{ + /* Scroll menu up */ + scrollok(win, TRUE); + wscrl(win, n); + scrollok(win, FALSE); + *scroll = *scroll + n; + wrefresh(win); +} + +/* + * Display a menu for choosing among a number of options + */ +int dialog_menu(const char *title, const char *prompt, + const void *selected, int *s_scroll) +{ + int i, j, x, y, box_x, box_y; + int height, width, menu_height; + int key = 0, button = 0, scroll = 0, choice = 0; + int first_item = 0, max_choice; + WINDOW *dialog, *menu; + +do_resize: + height = getmaxy(stdscr); + width = getmaxx(stdscr); + if (height < 15 || width < 65) + return -ERRDISPLAYTOOSMALL; + + height -= 4; + width -= 5; + menu_height = height - 10; + + max_choice = MIN(menu_height, item_count()); + + /* center dialog box on screen */ + x = (COLS - width) / 2; + y = (LINES - height) / 2; + + draw_shadow(stdscr, y, x, height, width); + + dialog = newwin(height, width, y, x); + keypad(dialog, TRUE); + + draw_box(dialog, 0, 0, height, width, + dlg.dialog.atr, dlg.border.atr); + wattrset(dialog, dlg.border.atr); + mvwaddch(dialog, height - 3, 0, ACS_LTEE); + for (i = 0; i < width - 2; i++) + waddch(dialog, ACS_HLINE); + wattrset(dialog, dlg.dialog.atr); + wbkgdset(dialog, dlg.dialog.atr & A_COLOR); + waddch(dialog, ACS_RTEE); + + print_title(dialog, title, width); + + wattrset(dialog, dlg.dialog.atr); + print_autowrap(dialog, prompt, width - 2, 1, 3); + + menu_width = width - 6; + box_y = height - menu_height - 5; + box_x = (width - menu_width) / 2 - 1; + + /* create new window for the menu */ + menu = subwin(dialog, menu_height, menu_width, + y + box_y + 1, x + box_x + 1); + keypad(menu, TRUE); + + /* draw a box around the menu items */ + draw_box(dialog, box_y, box_x, menu_height + 2, menu_width + 2, + dlg.menubox_border.atr, dlg.menubox.atr); + + if (menu_width >= 80) + item_x = (menu_width - 70) / 2; + else + item_x = 4; + + /* Set choice to default item */ + item_foreach() + if (selected && (selected == item_data())) + choice = item_n(); + /* get the saved scroll info */ + scroll = *s_scroll; + if ((scroll <= choice) && (scroll + max_choice > choice) && + (scroll >= 0) && (scroll + max_choice <= item_count())) { + first_item = scroll; + choice = choice - scroll; + } else { + scroll = 0; + } + if ((choice >= max_choice)) { + if (choice >= item_count() - max_choice / 2) + scroll = first_item = item_count() - max_choice; + else + scroll = first_item = choice - max_choice / 2; + choice = choice - scroll; + } + + /* Print the menu */ + for (i = 0; i < max_choice; i++) { + print_item(first_item + i, i, i == choice); + } + + wnoutrefresh(menu); + + print_arrows(dialog, item_count(), scroll, + box_y, box_x + item_x + 1, menu_height); + + print_buttons(dialog, height, width, 0); + wmove(menu, choice, item_x + 1); + wrefresh(menu); + + while (key != KEY_ESC) { + key = wgetch(menu); + + if (key < 256 && isalpha(key)) + key = tolower(key); + + if (strchr("ynmh", key)) + i = max_choice; + else { + for (i = choice + 1; i < max_choice; i++) { + item_set(scroll + i); + j = first_alpha(item_str(), "YyNnMmHh"); + if (key == tolower(item_str()[j])) + break; + } + if (i == max_choice) + for (i = 0; i < max_choice; i++) { + item_set(scroll + i); + j = first_alpha(item_str(), "YyNnMmHh"); + if (key == tolower(item_str()[j])) + break; + } + } + + if (i < max_choice || + key == KEY_UP || key == KEY_DOWN || + key == '-' || key == '+' || + key == KEY_PPAGE || key == KEY_NPAGE) { + /* Remove highligt of current item */ + print_item(scroll + choice, choice, FALSE); + + if (key == KEY_UP || key == '-') { + if (choice < 2 && scroll) { + /* Scroll menu down */ + do_scroll(menu, &scroll, -1); + + print_item(scroll, 0, FALSE); + } else + choice = MAX(choice - 1, 0); + + } else if (key == KEY_DOWN || key == '+') { + print_item(scroll+choice, choice, FALSE); + + if ((choice > max_choice - 3) && + (scroll + max_choice < item_count())) { + /* Scroll menu up */ + do_scroll(menu, &scroll, 1); + + print_item(scroll+max_choice - 1, + max_choice - 1, FALSE); + } else + choice = MIN(choice + 1, max_choice - 1); + + } else if (key == KEY_PPAGE) { + scrollok(menu, TRUE); + for (i = 0; (i < max_choice); i++) { + if (scroll > 0) { + do_scroll(menu, &scroll, -1); + print_item(scroll, 0, FALSE); + } else { + if (choice > 0) + choice--; + } + } + + } else if (key == KEY_NPAGE) { + for (i = 0; (i < max_choice); i++) { + if (scroll + max_choice < item_count()) { + do_scroll(menu, &scroll, 1); + print_item(scroll+max_choice-1, + max_choice - 1, FALSE); + } else { + if (choice + 1 < max_choice) + choice++; + } + } + } else + choice = i; + + print_item(scroll + choice, choice, TRUE); + + print_arrows(dialog, item_count(), scroll, + box_y, box_x + item_x + 1, menu_height); + + wnoutrefresh(dialog); + wrefresh(menu); + + continue; /* wait for another key press */ + } + + switch (key) { + case KEY_LEFT: + case TAB: + case KEY_RIGHT: + button = ((key == KEY_LEFT ? --button : ++button) < 0) + ? 2 : (button > 2 ? 0 : button); + + print_buttons(dialog, height, width, button); + wrefresh(menu); + break; + case ' ': + case 's': + case 'y': + case 'n': + case 'm': + case '/': + case 'h': + case '?': + case 'z': + case '\n': + /* save scroll info */ + *s_scroll = scroll; + delwin(menu); + delwin(dialog); + item_set(scroll + choice); + item_set_selected(1); + switch (key) { + case 'h': + case '?': + return 2; + case 's': + case 'y': + return 3; + case 'n': + return 4; + case 'm': + return 5; + case ' ': + return 6; + case '/': + return 7; + case 'z': + return 8; + case '\n': + return button; + } + return 0; + case 'e': + case 'x': + key = KEY_ESC; + break; + case KEY_ESC: + key = on_key_esc(menu); + break; + case KEY_RESIZE: + on_key_resize(); + delwin(menu); + delwin(dialog); + goto do_resize; + } + } + delwin(menu); + delwin(dialog); + return key; /* ESC pressed */ +} Index: branches/azimutz/Cleancut/i386/config/lxdialog/textbox.c =================================================================== --- branches/azimutz/Cleancut/i386/config/lxdialog/textbox.c (revision 0) +++ branches/azimutz/Cleancut/i386/config/lxdialog/textbox.c (revision 885) @@ -0,0 +1,391 @@ +/* + * textbox.c -- implements the text box + * + * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) + * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "dialog.h" + +static void back_lines(int n); +static void print_page(WINDOW * win, int height, int width); +static void print_line(WINDOW * win, int row, int width); +static char *get_line(void); +static void print_position(WINDOW * win); + +static int hscroll; +static int begin_reached, end_reached, page_length; +static const char *buf; +static const char *page; + +/* + * refresh window content + */ +static void refresh_text_box(WINDOW *dialog, WINDOW *box, int boxh, int boxw, + int cur_y, int cur_x) +{ + print_page(box, boxh, boxw); + print_position(dialog); + wmove(dialog, cur_y, cur_x); /* Restore cursor position */ + wrefresh(dialog); +} + + +/* + * Display text from a file in a dialog box. + */ +int dialog_textbox(const char *title, const char *tbuf, + int initial_height, int initial_width) +{ + int i, x, y, cur_x, cur_y, key = 0; + int height, width, boxh, boxw; + int passed_end; + WINDOW *dialog, *box; + + begin_reached = 1; + end_reached = 0; + page_length = 0; + hscroll = 0; + buf = tbuf; + page = buf; /* page is pointer to start of page to be displayed */ + +do_resize: + getmaxyx(stdscr, height, width); + if (height < 8 || width < 8) + return -ERRDISPLAYTOOSMALL; + if (initial_height != 0) + height = initial_height; + else + if (height > 4) + height -= 4; + else + height = 0; + if (initial_width != 0) + width = initial_width; + else + if (width > 5) + width -= 5; + else + width = 0; + + /* center dialog box on screen */ + x = (COLS - width) / 2; + y = (LINES - height) / 2; + + draw_shadow(stdscr, y, x, height, width); + + dialog = newwin(height, width, y, x); + keypad(dialog, TRUE); + + /* Create window for box region, used for scrolling text */ + boxh = height - 4; + boxw = width - 2; + box = subwin(dialog, boxh, boxw, y + 1, x + 1); + wattrset(box, dlg.dialog.atr); + wbkgdset(box, dlg.dialog.atr & A_COLOR); + + keypad(box, TRUE); + + /* register the new window, along with its borders */ + draw_box(dialog, 0, 0, height, width, + dlg.dialog.atr, dlg.border.atr); + + wattrset(dialog, dlg.border.atr); + mvwaddch(dialog, height - 3, 0, ACS_LTEE); + for (i = 0; i < width - 2; i++) + waddch(dialog, ACS_HLINE); + wattrset(dialog, dlg.dialog.atr); + wbkgdset(dialog, dlg.dialog.atr & A_COLOR); + waddch(dialog, ACS_RTEE); + + print_title(dialog, title, width); + + print_button(dialog, gettext(" Exit "), height - 2, width / 2 - 4, TRUE); + wnoutrefresh(dialog); + getyx(dialog, cur_y, cur_x); /* Save cursor position */ + + /* Print first page of text */ + attr_clear(box, boxh, boxw, dlg.dialog.atr); + refresh_text_box(dialog, box, boxh, boxw, cur_y, cur_x); + + while ((key != KEY_ESC) && (key != '\n')) { + key = wgetch(dialog); + switch (key) { + case 'E': /* Exit */ + case 'e': + case 'X': + case 'x': + delwin(box); + delwin(dialog); + return 0; + case 'g': /* First page */ + case KEY_HOME: + if (!begin_reached) { + begin_reached = 1; + page = buf; + refresh_text_box(dialog, box, boxh, boxw, + cur_y, cur_x); + } + break; + case 'G': /* Last page */ + case KEY_END: + + end_reached = 1; + /* point to last char in buf */ + page = buf + strlen(buf); + back_lines(boxh); + refresh_text_box(dialog, box, boxh, boxw, + cur_y, cur_x); + break; + case 'K': /* Previous line */ + case 'k': + case KEY_UP: + if (!begin_reached) { + back_lines(page_length + 1); + + /* We don't call print_page() here but use + * scrolling to ensure faster screen update. + * However, 'end_reached' and 'page_length' + * should still be updated, and 'page' should + * point to start of next page. This is done + * by calling get_line() in the following + * 'for' loop. */ + scrollok(box, TRUE); + wscrl(box, -1); /* Scroll box region down one line */ + scrollok(box, FALSE); + page_length = 0; + passed_end = 0; + for (i = 0; i < boxh; i++) { + if (!i) { + /* print first line of page */ + print_line(box, 0, boxw); + wnoutrefresh(box); + } else + /* Called to update 'end_reached' and 'page' */ + get_line(); + if (!passed_end) + page_length++; + if (end_reached && !passed_end) + passed_end = 1; + } + + print_position(dialog); + wmove(dialog, cur_y, cur_x); /* Restore cursor position */ + wrefresh(dialog); + } + break; + case 'B': /* Previous page */ + case 'b': + case KEY_PPAGE: + if (begin_reached) + break; + back_lines(page_length + boxh); + refresh_text_box(dialog, box, boxh, boxw, + cur_y, cur_x); + break; + case 'J': /* Next line */ + case 'j': + case KEY_DOWN: + if (!end_reached) { + begin_reached = 0; + scrollok(box, TRUE); + scroll(box); /* Scroll box region up one line */ + scrollok(box, FALSE); + print_line(box, boxh - 1, boxw); + wnoutrefresh(box); + print_position(dialog); + wmove(dialog, cur_y, cur_x); /* Restore cursor position */ + wrefresh(dialog); + } + break; + case KEY_NPAGE: /* Next page */ + case ' ': + if (end_reached) + break; + + begin_reached = 0; + refresh_text_box(dialog, box, boxh, boxw, + cur_y, cur_x); + break; + case '0': /* Beginning of line */ + case 'H': /* Scroll left */ + case 'h': + case KEY_LEFT: + if (hscroll <= 0) + break; + + if (key == '0') + hscroll = 0; + else + hscroll--; + /* Reprint current page to scroll horizontally */ + back_lines(page_length); + refresh_text_box(dialog, box, boxh, boxw, + cur_y, cur_x); + break; + case 'L': /* Scroll right */ + case 'l': + case KEY_RIGHT: + if (hscroll >= MAX_LEN) + break; + hscroll++; + /* Reprint current page to scroll horizontally */ + back_lines(page_length); + refresh_text_box(dialog, box, boxh, boxw, + cur_y, cur_x); + break; + case KEY_ESC: + key = on_key_esc(dialog); + break; + case KEY_RESIZE: + back_lines(height); + delwin(box); + delwin(dialog); + on_key_resize(); + goto do_resize; + } + } + delwin(box); + delwin(dialog); + return key; /* ESC pressed */ +} + +/* + * Go back 'n' lines in text. Called by dialog_textbox(). + * 'page' will be updated to point to the desired line in 'buf'. + */ +static void back_lines(int n) +{ + int i; + + begin_reached = 0; + /* Go back 'n' lines */ + for (i = 0; i < n; i++) { + if (*page == '\0') { + if (end_reached) { + end_reached = 0; + continue; + } + } + if (page == buf) { + begin_reached = 1; + return; + } + page--; + do { + if (page == buf) { + begin_reached = 1; + return; + } + page--; + } while (*page != '\n'); + page++; + } +} + +/* + * Print a new page of text. Called by dialog_textbox(). + */ +static void print_page(WINDOW * win, int height, int width) +{ + int i, passed_end = 0; + + page_length = 0; + for (i = 0; i < height; i++) { + print_line(win, i, width); + if (!passed_end) + page_length++; + if (end_reached && !passed_end) + passed_end = 1; + } + wnoutrefresh(win); +} + +/* + * Print a new line of text. Called by dialog_textbox() and print_page(). + */ +static void print_line(WINDOW * win, int row, int width) +{ + int y, x; + char *line; + + line = get_line(); + line += MIN(strlen(line), hscroll); /* Scroll horizontally */ + wmove(win, row, 0); /* move cursor to correct line */ + waddch(win, ' '); + waddnstr(win, line, MIN(strlen(line), width - 2)); + + getyx(win, y, x); + /* Clear 'residue' of previous line */ +#if OLD_NCURSES + { + int i; + for (i = 0; i < width - x; i++) + waddch(win, ' '); + } +#else + wclrtoeol(win); +#endif +} + +/* + * Return current line of text. Called by dialog_textbox() and print_line(). + * 'page' should point to start of current line before calling, and will be + * updated to point to start of next line. + */ +static char *get_line(void) +{ + int i = 0; + static char line[MAX_LEN + 1]; + + end_reached = 0; + while (*page != '\n') { + if (*page == '\0') { + if (!end_reached) { + end_reached = 1; + break; + } + } else if (i < MAX_LEN) + line[i++] = *(page++); + else { + /* Truncate lines longer than MAX_LEN characters */ + if (i == MAX_LEN) + line[i++] = '\0'; + page++; + } + } + if (i <= MAX_LEN) + line[i] = '\0'; + if (!end_reached) + page++; /* move pass '\n' */ + + return line; +} + +/* + * Print current position + */ +static void print_position(WINDOW * win) +{ + int percent; + + wattrset(win, dlg.position_indicator.atr); + wbkgdset(win, dlg.position_indicator.atr & A_COLOR); + percent = (page - buf) * 100 / strlen(buf); + wmove(win, getmaxy(win) - 3, getmaxx(win) - 9); + wprintw(win, "(%3d%%)", percent); +} Index: branches/azimutz/Cleancut/i386/config/lxdialog/util.c =================================================================== --- branches/azimutz/Cleancut/i386/config/lxdialog/util.c (revision 0) +++ branches/azimutz/Cleancut/i386/config/lxdialog/util.c (revision 885) @@ -0,0 +1,657 @@ +/* + * util.c + * + * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) + * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include <stdarg.h> + +#include "dialog.h" + +struct dialog_info dlg; + +static void set_mono_theme(void) +{ + dlg.screen.atr = A_NORMAL; + dlg.shadow.atr = A_NORMAL; + dlg.dialog.atr = A_NORMAL; + dlg.title.atr = A_BOLD; + dlg.border.atr = A_NORMAL; + dlg.button_active.atr = A_REVERSE; + dlg.button_inactive.atr = A_DIM; + dlg.button_key_active.atr = A_REVERSE; + dlg.button_key_inactive.atr = A_BOLD; + dlg.button_label_active.atr = A_REVERSE; + dlg.button_label_inactive.atr = A_NORMAL; + dlg.inputbox.atr = A_NORMAL; + dlg.inputbox_border.atr = A_NORMAL; + dlg.searchbox.atr = A_NORMAL; + dlg.searchbox_title.atr = A_BOLD; + dlg.searchbox_border.atr = A_NORMAL; + dlg.position_indicator.atr = A_BOLD; + dlg.menubox.atr = A_NORMAL; + dlg.menubox_border.atr = A_NORMAL; + dlg.item.atr = A_NORMAL; + dlg.item_selected.atr = A_REVERSE; + dlg.tag.atr = A_BOLD; + dlg.tag_selected.atr = A_REVERSE; + dlg.tag_key.atr = A_BOLD; + dlg.tag_key_selected.atr = A_REVERSE; + dlg.check.atr = A_BOLD; + dlg.check_selected.atr = A_REVERSE; + dlg.uarrow.atr = A_BOLD; + dlg.darrow.atr = A_BOLD; +} + +#define DLG_COLOR(dialog, f, b, h) \ +do { \ + dlg.dialog.fg = (f); \ + dlg.dialog.bg = (b); \ + dlg.dialog.hl = (h); \ +} while (0) + +static void set_classic_theme(void) +{ + DLG_COLOR(screen, COLOR_CYAN, COLOR_BLUE, true); + DLG_COLOR(shadow, COLOR_BLACK, COLOR_BLACK, true); + DLG_COLOR(dialog, COLOR_BLACK, COLOR_WHITE, false); + DLG_COLOR(title, COLOR_YELLOW, COLOR_WHITE, true); + DLG_COLOR(border, COLOR_WHITE, COLOR_WHITE, true); + DLG_COLOR(button_active, COLOR_WHITE, COLOR_BLUE, true); + DLG_COLOR(button_inactive, COLOR_BLACK, COLOR_WHITE, false); + DLG_COLOR(button_key_active, COLOR_WHITE, COLOR_BLUE, true); + DLG_COLOR(button_key_inactive, COLOR_RED, COLOR_WHITE, false); + DLG_COLOR(button_label_active, COLOR_YELLOW, COLOR_BLUE, true); + DLG_COLOR(button_label_inactive, COLOR_BLACK, COLOR_WHITE, true); + DLG_COLOR(inputbox, COLOR_BLACK, COLOR_WHITE, false); + DLG_COLOR(inputbox_border, COLOR_BLACK, COLOR_WHITE, false); + DLG_COLOR(searchbox, COLOR_BLACK, COLOR_WHITE, false); + DLG_COLOR(searchbox_title, COLOR_YELLOW, COLOR_WHITE, true); + DLG_COLOR(searchbox_border, COLOR_WHITE, COLOR_WHITE, true); + DLG_COLOR(position_indicator, COLOR_YELLOW, COLOR_WHITE, true); + DLG_COLOR(menubox, COLOR_BLACK, COLOR_WHITE, false); + DLG_COLOR(menubox_border, COLOR_WHITE, COLOR_WHITE, true); + DLG_COLOR(item, COLOR_BLACK, COLOR_WHITE, false); + DLG_COLOR(item_selected, COLOR_WHITE, COLOR_BLUE, true); + DLG_COLOR(tag, COLOR_YELLOW, COLOR_WHITE, true); + DLG_COLOR(tag_selected, COLOR_YELLOW, COLOR_BLUE, true); + DLG_COLOR(tag_key, COLOR_YELLOW, COLOR_WHITE, true); + DLG_COLOR(tag_key_selected, COLOR_YELLOW, COLOR_BLUE, true); + DLG_COLOR(check, COLOR_BLACK, COLOR_WHITE, false); + DLG_COLOR(check_selected, COLOR_WHITE, COLOR_BLUE, true); + DLG_COLOR(uarrow, COLOR_GREEN, COLOR_WHITE, true); + DLG_COLOR(darrow, COLOR_GREEN, COLOR_WHITE, true); +} + +static void set_blackbg_theme(void) +{ + DLG_COLOR(screen, COLOR_RED, COLOR_BLACK, true); + DLG_COLOR(shadow, COLOR_BLACK, COLOR_BLACK, false); + DLG_COLOR(dialog, COLOR_WHITE, COLOR_BLACK, false); + DLG_COLOR(title, COLOR_RED, COLOR_BLACK, false); + DLG_COLOR(border, COLOR_BLACK, COLOR_BLACK, true); + + DLG_COLOR(button_active, COLOR_YELLOW, COLOR_RED, false); + DLG_COLOR(button_inactive, COLOR_YELLOW, COLOR_BLACK, false); + DLG_COLOR(button_key_active, COLOR_YELLOW, COLOR_RED, true); + DLG_COLOR(button_key_inactive, COLOR_RED, COLOR_BLACK, false); + DLG_COLOR(button_label_active, COLOR_WHITE, COLOR_RED, false); + DLG_COLOR(button_label_inactive, COLOR_BLACK, COLOR_BLACK, true); + + DLG_COLOR(inputbox, COLOR_YELLOW, COLOR_BLACK, false); + DLG_COLOR(inputbox_border, COLOR_YELLOW, COLOR_BLACK, false); + + DLG_COLOR(searchbox, COLOR_YELLOW, COLOR_BLACK, false); + DLG_COLOR(searchbox_title, COLOR_YELLOW, COLOR_BLACK, true); + DLG_COLOR(searchbox_border, COLOR_BLACK, COLOR_BLACK, true); + + DLG_COLOR(position_indicator, COLOR_RED, COLOR_BLACK, false); + + DLG_COLOR(menubox, COLOR_YELLOW, COLOR_BLACK, false); + DLG_COLOR(menubox_border, COLOR_BLACK, COLOR_BLACK, true); + + DLG_COLOR(item, COLOR_WHITE, COLOR_BLACK, false); + DLG_COLOR(item_selected, COLOR_WHITE, COLOR_RED, false); + + DLG_COLOR(tag, COLOR_RED, COLOR_BLACK, false); + DLG_COLOR(tag_selected, COLOR_YELLOW, COLOR_RED, true); + DLG_COLOR(tag_key, COLOR_RED, COLOR_BLACK, false); + DLG_COLOR(tag_key_selected, COLOR_YELLOW, COLOR_RED, true); + + DLG_COLOR(check, COLOR_YELLOW, COLOR_BLACK, false); + DLG_COLOR(check_selected, COLOR_YELLOW, COLOR_RED, true); + + DLG_COLOR(uarrow, COLOR_RED, COLOR_BLACK, false); + DLG_COLOR(darrow, COLOR_RED, COLOR_BLACK, false); +} + +static void set_bluetitle_theme(void) +{ + set_classic_theme(); + DLG_COLOR(title, COLOR_BLUE, COLOR_WHITE, true); + DLG_COLOR(button_key_active, COLOR_YELLOW, COLOR_BLUE, true); + DLG_COLOR(button_label_active, COLOR_WHITE, COLOR_BLUE, true); + DLG_COLOR(searchbox_title, COLOR_BLUE, COLOR_WHITE, true); + DLG_COLOR(position_indicator, COLOR_BLUE, COLOR_WHITE, true); + DLG_COLOR(tag, COLOR_BLUE, COLOR_WHITE, true); + DLG_COLOR(tag_key, COLOR_BLUE, COLOR_WHITE, true); + +} + +/* + * Select color theme + */ +static int set_theme(const char *theme) +{ + int use_color = 1; + if (!theme) + set_bluetitle_theme(); + else if (strcmp(theme, "classic") == 0) + set_classic_theme(); + else if (strcmp(theme, "bluetitle") == 0) + set_bluetitle_theme(); + else if (strcmp(theme, "blackbg") == 0) + set_blackbg_theme(); + else if (strcmp(theme, "mono") == 0) + use_color = 0; + + return use_color; +} + +static void init_one_color(struct dialog_color *color) +{ + static int pair = 0; + + pair++; + init_pair(pair, color->fg, color->bg); + if (color->hl) + color->atr = A_BOLD | COLOR_PAIR(pair); + else + color->atr = COLOR_PAIR(pair); +} + +static void init_dialog_colors(void) +{ + init_one_color(&dlg.screen); + init_one_color(&dlg.shadow); + init_one_color(&dlg.dialog); + init_one_color(&dlg.title); + init_one_color(&dlg.border); + init_one_color(&dlg.button_active); + init_one_color(&dlg.button_inactive); + init_one_color(&dlg.button_key_active); + init_one_color(&dlg.button_key_inactive); + init_one_color(&dlg.button_label_active); + init_one_color(&dlg.button_label_inactive); + init_one_color(&dlg.inputbox); + init_one_color(&dlg.inputbox_border); + init_one_color(&dlg.searchbox); + init_one_color(&dlg.searchbox_title); + init_one_color(&dlg.searchbox_border); + init_one_color(&dlg.position_indicator); + init_one_color(&dlg.menubox); + init_one_color(&dlg.menubox_border); + init_one_color(&dlg.item); + init_one_color(&dlg.item_selected); + init_one_color(&dlg.tag); + init_one_color(&dlg.tag_selected); + init_one_color(&dlg.tag_key); + init_one_color(&dlg.tag_key_selected); + init_one_color(&dlg.check); + init_one_color(&dlg.check_selected); + init_one_color(&dlg.uarrow); + init_one_color(&dlg.darrow); +} + +/* + * Setup for color display + */ +static void color_setup(const char *theme) +{ + int use_color; + + use_color = set_theme(theme); + if (use_color && has_colors()) { + start_color(); + init_dialog_colors(); + } else + set_mono_theme(); +} + +/* + * Set window to attribute 'attr' + */ +void attr_clear(WINDOW * win, int height, int width, chtype attr) +{ + int i, j; + + wattrset(win, attr); + for (i = 0; i < height; i++) { + wmove(win, i, 0); + for (j = 0; j < width; j++) + waddch(win, ' '); + } + touchwin(win); +} + +void dialog_clear(void) +{ + attr_clear(stdscr, LINES, COLS, dlg.screen.atr); + /* Display background title if it exists ... - SLH */ + if (dlg.backtitle != NULL) { + int i; + + wattrset(stdscr, dlg.screen.atr); + mvwaddstr(stdscr, 0, 1, (char *)dlg.backtitle); + wmove(stdscr, 1, 1); + for (i = 1; i < COLS - 1; i++) + waddch(stdscr, ACS_HLINE); + } + wnoutrefresh(stdscr); +} + +/* + * Do some initialization for dialog + */ +int init_dialog(const char *backtitle) +{ + int height, width; + + initscr(); /* Init curses */ + getmaxyx(stdscr, height, width); + if (height < 19 || width < 80) { + endwin(); + return -ERRDISPLAYTOOSMALL; + } + + dlg.backtitle = backtitle; + color_setup(getenv("MENUCONFIG_COLOR")); + + keypad(stdscr, TRUE); + cbreak(); + noecho(); + dialog_clear(); + + return 0; +} + +void set_dialog_backtitle(const char *backtitle) +{ + dlg.backtitle = backtitle; +} + +/* + * End using dialog functions. + */ +void end_dialog(int x, int y) +{ + /* move cursor back to original position */ + move(y, x); + refresh(); + endwin(); +} + +/* Print the title of the dialog. Center the title and truncate + * tile if wider than dialog (- 2 chars). + **/ +void print_title(WINDOW *dialog, const char *title, int width) +{ + if (title) { + int tlen = MIN(width - 2, strlen(title)); + wattrset(dialog, dlg.title.atr); + mvwaddch(dialog, 0, (width - tlen) / 2 - 1, ' '); + mvwaddnstr(dialog, 0, (width - tlen)/2, title, tlen); + waddch(dialog, ' '); + } +} + +/* + * Print a string of text in a window, automatically wrap around to the + * next line if the string is too long to fit on one line. Newline + * characters '\n' are replaced by spaces. We start on a new line + * if there is no room for at least 4 nonblanks following a double-space. + */ +void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x) +{ + int newl, cur_x, cur_y; + int i, prompt_len, room, wlen; + char tempstr[MAX_LEN + 1], *word, *sp, *sp2; + + strcpy(tempstr, prompt); + + prompt_len = strlen(tempstr); + + /* + * Remove newlines + */ + for (i = 0; i < prompt_len; i++) { + if (tempstr[i] == '\n') + tempstr[i] = ' '; + } + + if (prompt_len <= width - x * 2) { /* If prompt is short */ + wmove(win, y, (width - prompt_len) / 2); + waddstr(win, tempstr); + } else { + cur_x = x; + cur_y = y; + newl = 1; + word = tempstr; + while (word && *word) { + sp = strchr(word, ' '); + if (sp) + *sp++ = 0; + + /* Wrap to next line if either the word does not fit, + or it is the first word of a new sentence, and it is + short, and the next word does not fit. */ + room = width - cur_x; + wlen = strlen(word); + if (wlen > room || + (newl && wlen < 4 && sp + && wlen + 1 + strlen(sp) > room + && (!(sp2 = strchr(sp, ' ')) + || wlen + 1 + (sp2 - sp) > room))) { + cur_y++; + cur_x = x; + } + wmove(win, cur_y, cur_x); + waddstr(win, word); + getyx(win, cur_y, cur_x); + cur_x++; + if (sp && *sp == ' ') { + cur_x++; /* double space */ + while (*++sp == ' ') ; + newl = 1; + } else + newl = 0; + word = sp; + } + } +} + +/* + * Print a button + */ +void print_button(WINDOW * win, const char *label, int y, int x, int selected) +{ + int i, temp; + + wmove(win, y, x); + wattrset(win, selected ? dlg.button_active.atr + : dlg.button_inactive.atr); + waddstr(win, "<"); + temp = strspn(label, " "); + label += temp; + wattrset(win, selected ? dlg.button_label_active.atr + : dlg.button_label_inactive.atr); + for (i = 0; i < temp; i++) + waddch(win, ' '); + wattrset(win, selected ? dlg.button_key_active.atr + : dlg.button_key_inactive.atr); + waddch(win, label[0]); + wattrset(win, selected ? dlg.button_label_active.atr + : dlg.button_label_inactive.atr); + waddstr(win, (char *)label + 1); + wattrset(win, selected ? dlg.button_active.atr + : dlg.button_inactive.atr); + waddstr(win, ">"); + wmove(win, y, x + temp + 1); +} + +/* + * Draw a rectangular box with line drawing characters + */ +void +draw_box(WINDOW * win, int y, int x, int height, int width, + chtype box, chtype border) +{ + int i, j; + + wattrset(win, 0); + for (i = 0; i < height; i++) { + wmove(win, y + i, x); + for (j = 0; j < width; j++) + if (!i && !j) + waddch(win, border | ACS_ULCORNER); + else if (i == height - 1 && !j) + waddch(win, border | ACS_LLCORNER); + else if (!i && j == width - 1) + waddch(win, box | ACS_URCORNER); + else if (i == height - 1 && j == width - 1) + waddch(win, box | ACS_LRCORNER); + else if (!i) + waddch(win, border | ACS_HLINE); + else if (i == height - 1) + waddch(win, box | ACS_HLINE); + else if (!j) + waddch(win, border | ACS_VLINE); + else if (j == width - 1) + waddch(win, box | ACS_VLINE); + else + waddch(win, box | ' '); + } +} + +/* + * Draw shadows along the right and bottom edge to give a more 3D look + * to the boxes + */ +void draw_shadow(WINDOW * win, int y, int x, int height, int width) +{ + int i; + + if (has_colors()) { /* Whether terminal supports color? */ + wattrset(win, dlg.shadow.atr); + wmove(win, y + height, x + 2); + for (i = 0; i < width; i++) + waddch(win, winch(win) & A_CHARTEXT); + for (i = y + 1; i < y + height + 1; i++) { + wmove(win, i, x + width); + waddch(win, winch(win) & A_CHARTEXT); + waddch(win, winch(win) & A_CHARTEXT); + } + wnoutrefresh(win); + } +} + +/* + * Return the position of the first alphabetic character in a string. + */ +int first_alpha(const char *string, const char *exempt) +{ + int i, in_paren = 0, c; + + for (i = 0; i < strlen(string); i++) { + c = tolower(string[i]); + + if (strchr("<[(", c)) + ++in_paren; + if (strchr(">])", c) && in_paren > 0) + --in_paren; + + if ((!in_paren) && isalpha(c) && strchr(exempt, c) == 0) + return i; + } + + return 0; +} + +/* + * ncurses uses ESC to detect escaped char sequences. This resutl in + * a small timeout before ESC is actually delivered to the application. + * lxdialog suggest <ESC> <ESC> which is correctly translated to two + * times esc. But then we need to ignore the second esc to avoid stepping + * out one menu too much. Filter away all escaped key sequences since + * keypad(FALSE) turn off ncurses support for escape sequences - and thats + * needed to make notimeout() do as expected. + */ +int on_key_esc(WINDOW *win) +{ + int key; + int key2; + int key3; + + nodelay(win, TRUE); + keypad(win, FALSE); + key = wgetch(win); + key2 = wgetch(win); + do { + key3 = wgetch(win); + } while (key3 != ERR); + nodelay(win, FALSE); + keypad(win, TRUE); + if (key == KEY_ESC && key2 == ERR) + return KEY_ESC; + else if (key != ERR && key != KEY_ESC && key2 == ERR) + ungetch(key); + + return -1; +} + +/* redraw screen in new size */ +int on_key_resize(void) +{ + dialog_clear(); + return KEY_RESIZE; +} + +struct dialog_list *item_cur; +struct dialog_list item_nil; +struct dialog_list *item_head; + +void item_reset(void) +{ + struct dialog_list *p, *next; + + for (p = item_head; p; p = next) { + next = p->next; + free(p); + } + item_head = NULL; + item_cur = &item_nil; +} + +void item_make(const char *fmt, ...) +{ + va_list ap; + struct dialog_list *p = malloc(sizeof(*p)); + + if (item_head) + item_cur->next = p; + else + item_head = p; + item_cur = p; + memset(p, 0, sizeof(*p)); + + va_start(ap, fmt); + vsnprintf(item_cur->node.str, sizeof(item_cur->node.str), fmt, ap); + va_end(ap); +} + +void item_add_str(const char *fmt, ...) +{ + va_list ap; + size_t avail; + + avail = sizeof(item_cur->node.str) - strlen(item_cur->node.str); + + va_start(ap, fmt); + vsnprintf(item_cur->node.str + strlen(item_cur->node.str), + avail, fmt, ap); + item_cur->node.str[sizeof(item_cur->node.str) - 1] = '\0'; + va_end(ap); +} + +void item_set_tag(char tag) +{ + item_cur->node.tag = tag; +} +void item_set_data(void *ptr) +{ + item_cur->node.data = ptr; +} + +void item_set_selected(int val) +{ + item_cur->node.selected = val; +} + +int item_activate_selected(void) +{ + item_foreach() + if (item_is_selected()) + return 1; + return 0; +} + +void *item_data(void) +{ + return item_cur->node.data; +} + +char item_tag(void) +{ + return item_cur->node.tag; +} + +int item_count(void) +{ + int n = 0; + struct dialog_list *p; + + for (p = item_head; p; p = p->next) + n++; + return n; +} + +void item_set(int n) +{ + int i = 0; + item_foreach() + if (i++ == n) + return; +} + +int item_n(void) +{ + int n = 0; + struct dialog_list *p; + + for (p = item_head; p; p = p->next) { + if (p == item_cur) + return n; + n++; + } + return 0; +} + +const char *item_str(void) +{ + return item_cur->node.str; +} + +int item_is_selected(void) +{ + return (item_cur->node.selected != 0); +} + +int item_is_tag(char tag) +{ + return (item_cur->node.tag == tag); +} Index: branches/azimutz/Cleancut/i386/config/lxdialog/yesno.c =================================================================== --- branches/azimutz/Cleancut/i386/config/lxdialog/yesno.c (revision 0) +++ branches/azimutz/Cleancut/i386/config/lxdialog/yesno.c (revision 885) @@ -0,0 +1,114 @@ +/* + * yesno.c -- implements the yes/no box + * + * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) + * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "dialog.h" + +/* + * Display termination buttons + */ +static void print_buttons(WINDOW * dialog, int height, int width, int selected) +{ + int x = width / 2 - 10; + int y = height - 2; + + print_button(dialog, gettext(" Yes "), y, x, selected == 0); + print_button(dialog, gettext(" No "), y, x + 13, selected == 1); + + wmove(dialog, y, x + 1 + 13 * selected); + wrefresh(dialog); +} + +/* + * Display a dialog box with two buttons - Yes and No + */ +int dialog_yesno(const char *title, const char *prompt, int height, int width) +{ + int i, x, y, key = 0, button = 0; + WINDOW *dialog; + +do_resize: + if (getmaxy(stdscr) < (height + 4)) + return -ERRDISPLAYTOOSMALL; + if (getmaxx(stdscr) < (width + 4)) + return -ERRDISPLAYTOOSMALL; + + /* center dialog box on screen */ + x = (COLS - width) / 2; + y = (LINES - height) / 2; + + draw_shadow(stdscr, y, x, height, width); + + dialog = newwin(height, width, y, x); + keypad(dialog, TRUE); + + draw_box(dialog, 0, 0, height, width, + dlg.dialog.atr, dlg.border.atr); + wattrset(dialog, dlg.border.atr); + mvwaddch(dialog, height - 3, 0, ACS_LTEE); + for (i = 0; i < width - 2; i++) + waddch(dialog, ACS_HLINE); + wattrset(dialog, dlg.dialog.atr); + waddch(dialog, ACS_RTEE); + + print_title(dialog, title, width); + + wattrset(dialog, dlg.dialog.atr); + print_autowrap(dialog, prompt, width - 2, 1, 3); + + print_buttons(dialog, height, width, 0); + + while (key != KEY_ESC) { + key = wgetch(dialog); + switch (key) { + case 'Y': + case 'y': + delwin(dialog); + return 0; + case 'N': + case 'n': + delwin(dialog); + return 1; + + case TAB: + case KEY_LEFT: + case KEY_RIGHT: + button = ((key == KEY_LEFT ? --button : ++button) < 0) ? 1 : (button > 1 ? 0 : button); + + print_buttons(dialog, height, width, button); + wrefresh(dialog); + break; + case ' ': + case '\n': + delwin(dialog); + return button; + case KEY_ESC: + key = on_key_esc(dialog); + break; + case KEY_RESIZE: + delwin(dialog); + on_key_resize(); + goto do_resize; + } + } + + delwin(dialog); + return key; /* ESC pressed */ +} Index: branches/azimutz/Cleancut/i386/config/expr.h =================================================================== --- branches/azimutz/Cleancut/i386/config/expr.h (revision 0) +++ branches/azimutz/Cleancut/i386/config/expr.h (revision 885) @@ -0,0 +1,231 @@ +/* + * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> + * Released under the terms of the GNU GPL v2.0. + */ + +#ifndef EXPR_H +#define EXPR_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdio.h> +#ifndef __cplusplus +#include <stdbool.h> +#endif + +struct file { + struct file *next; + struct file *parent; + const char *name; + int lineno; + int flags; +}; + +#define FILE_BUSY 0x0001 +#define FILE_SCANNED 0x0002 + +typedef enum tristate { + no, mod, yes +} tristate; + +enum expr_type { + E_NONE, E_OR, E_AND, E_NOT, E_EQUAL, E_UNEQUAL, E_LIST, E_SYMBOL, E_RANGE +}; + +union expr_data { + struct expr *expr; + struct symbol *sym; +}; + +struct expr { + enum expr_type type; + union expr_data left, right; +}; + +#define EXPR_OR(dep1, dep2) (((dep1)>(dep2))?(dep1):(dep2)) +#define EXPR_AND(dep1, dep2) (((dep1)<(dep2))?(dep1):(dep2)) +#define EXPR_NOT(dep) (2-(dep)) + +#define expr_list_for_each_sym(l, e, s) \ + for (e = (l); e && (s = e->right.sym); e = e->left.expr) + +struct expr_value { + struct expr *expr; + tristate tri; +}; + +struct symbol_value { + void *val; + tristate tri; +}; + +enum symbol_type { + S_UNKNOWN, S_BOOLEAN, S_TRISTATE, S_INT, S_HEX, S_STRING, S_OTHER +}; + +/* enum values are used as index to symbol.def[] */ +enum { + S_DEF_USER, /* main user value */ + S_DEF_AUTO, /* values read from auto.conf */ + S_DEF_DEF3, /* Reserved for UI usage */ + S_DEF_DEF4, /* Reserved for UI usage */ + S_DEF_COUNT +}; + +struct symbol { + struct symbol *next; + char *name; + enum symbol_type type; + struct symbol_value curr; + struct symbol_value def[S_DEF_COUNT]; + tristate visible; + int flags; + struct property *prop; + struct expr_value dir_dep; + struct expr_value rev_dep; +}; + +#define for_all_symbols(i, sym) for (i = 0; i < SYMBOL_HASHSIZE; i++) for (sym = symbol_hash[i]; sym; sym = sym->next) if (sym->type != S_OTHER) + +#define SYMBOL_CONST 0x0001 /* symbol is const */ +#define SYMBOL_CHECK 0x0008 /* used during dependency checking */ +#define SYMBOL_CHOICE 0x0010 /* start of a choice block (null name) */ +#define SYMBOL_CHOICEVAL 0x0020 /* used as a value in a choice block */ +#define SYMBOL_VALID 0x0080 /* set when symbol.curr is calculated */ +#define SYMBOL_OPTIONAL 0x0100 /* choice is optional - values can be 'n' */ +#define SYMBOL_WRITE 0x0200 /* ? */ +#define SYMBOL_CHANGED 0x0400 /* ? */ +#define SYMBOL_AUTO 0x1000 /* value from environment variable */ +#define SYMBOL_CHECKED 0x2000 /* used during dependency checking */ +#define SYMBOL_WARNED 0x8000 /* warning has been issued */ + +/* Set when symbol.def[] is used */ +#define SYMBOL_DEF 0x10000 /* First bit of SYMBOL_DEF */ +#define SYMBOL_DEF_USER 0x10000 /* symbol.def[S_DEF_USER] is valid */ +#define SYMBOL_DEF_AUTO 0x20000 /* symbol.def[S_DEF_AUTO] is valid */ +#define SYMBOL_DEF3 0x40000 /* symbol.def[S_DEF_3] is valid */ +#define SYMBOL_DEF4 0x80000 /* symbol.def[S_DEF_4] is valid */ + +#define SYMBOL_MAXLENGTH 256 +#define SYMBOL_HASHSIZE 9973 + +/* A property represent the config options that can be associated + * with a config "symbol". + * Sample: + * config FOO + * default y + * prompt "foo prompt" + * select BAR + * config BAZ + * int "BAZ Value" + * range 1..255 + */ +enum prop_type { + P_UNKNOWN, + P_PROMPT, /* prompt "foo prompt" or "BAZ Value" */ + P_COMMENT, /* text associated with a comment */ + P_MENU, /* prompt associated with a menuconfig option */ + P_DEFAULT, /* default y */ + P_CHOICE, /* choice value */ + P_SELECT, /* select BAR */ + P_RANGE, /* range 7..100 (for a symbol) */ + P_ENV, /* value from environment variable */ + P_SYMBOL, /* where a symbol is defined */ +}; + +struct property { + struct property *next; /* next property - null if last */ + struct symbol *sym; /* the symbol for which the property is associated */ + enum prop_type type; /* type of property */ + const char *text; /* the prompt value - P_PROMPT, P_MENU, P_COMMENT */ + struct expr_value visible; + struct expr *expr; /* the optional conditional part of the property */ + struct menu *menu; /* the menu the property are associated with + * valid for: P_SELECT, P_RANGE, P_CHOICE, + * P_PROMPT, P_DEFAULT, P_MENU, P_COMMENT */ + struct file *file; /* what file was this property defined */ + int lineno; /* what lineno was this property defined */ +}; + +#define for_all_properties(sym, st, tok) \ + for (st = sym->prop; st; st = st->next) \ + if (st->type == (tok)) +#define for_all_defaults(sym, st) for_all_properties(sym, st, P_DEFAULT) +#define for_all_choices(sym, st) for_all_properties(sym, st, P_CHOICE) +#define for_all_prompts(sym, st) \ + for (st = sym->prop; st; st = st->next) \ + if (st->text) + +struct menu { + struct menu *next; + struct menu *parent; + struct menu *list; + struct symbol *sym; + struct property *prompt; + struct expr *visibility; + struct expr *dep; + unsigned int flags; + char *help; + struct file *file; + int lineno; + void *data; +}; + +#define MENU_CHANGED 0x0001 +#define MENU_ROOT 0x0002 + +#ifndef SWIG + +extern struct file *file_list; +extern struct file *current_file; +struct file *lookup_file(const char *name); + +extern struct symbol symbol_yes, symbol_no, symbol_mod; +extern struct symbol *modules_sym; +extern struct symbol *sym_defconfig_list; +extern int cdebug; +struct expr *expr_alloc_symbol(struct symbol *sym); +struct expr *expr_alloc_one(enum expr_type type, struct expr *ce); +struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e2); +struct expr *expr_alloc_comp(enum expr_type type, struct symbol *s1, struct symbol *s2); +struct expr *expr_alloc_and(struct expr *e1, struct expr *e2); +struct expr *expr_alloc_or(struct expr *e1, struct expr *e2); +struct expr *expr_copy(const struct expr *org); +void expr_free(struct expr *e); +int expr_eq(struct expr *e1, struct expr *e2); +void expr_eliminate_eq(struct expr **ep1, struct expr **ep2); +tristate expr_calc_value(struct expr *e); +struct expr *expr_eliminate_yn(struct expr *e); +struct expr *expr_trans_bool(struct expr *e); +struct expr *expr_eliminate_dups(struct expr *e); +struct expr *expr_transform(struct expr *e); +int expr_contains_symbol(struct expr *dep, struct symbol *sym); +bool expr_depends_symbol(struct expr *dep, struct symbol *sym); +struct expr *expr_extract_eq_and(struct expr **ep1, struct expr **ep2); +struct expr *expr_extract_eq_or(struct expr **ep1, struct expr **ep2); +void expr_extract_eq(enum expr_type type, struct expr **ep, struct expr **ep1, struct expr **ep2); +struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym); +struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2); + +void expr_fprint(struct expr *e, FILE *out); +struct gstr; /* forward */ +void expr_gstr_print(struct expr *e, struct gstr *gs); + +static inline int expr_is_yes(struct expr *e) +{ + return !e || (e->type == E_SYMBOL && e->left.sym == &symbol_yes); +} + +static inline int expr_is_no(struct expr *e) +{ + return e && (e->type == E_SYMBOL && e->left.sym == &symbol_no); +} +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* EXPR_H */ Index: branches/azimutz/Cleancut/i386/config/zconf.tab.c =================================================================== --- branches/azimutz/Cleancut/i386/config/zconf.tab.c (revision 0) +++ branches/azimutz/Cleancut/i386/config/zconf.tab.c (revision 885) @@ -0,0 +1,2506 @@ + +/* A Bison parser, made by GNU Bison 2.4.1. */ + +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "2.4.1" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 0 + +/* Push parsers. */ +#define YYPUSH 0 + +/* Pull parsers. */ +#define YYPULL 1 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + +/* Substitute the variable and function names. */ +#define yyparse zconfparse +#define yylex zconflex +#define yyerror zconferror +#define yylval zconflval +#define yychar zconfchar +#define yydebug zconfdebug +#define yynerrs zconfnerrs + + +/* Copy the first part of user declarations. */ + + +/* + * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> + * Released under the terms of the GNU GPL v2.0. + */ + +#include <ctype.h> +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <stdbool.h> + +#define LKC_DIRECT_LINK +#include "lkc.h" + +#define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt) + +#define PRINTD 0x0001 +#define DEBUG_PARSE 0x0002 + +int cdebug = PRINTD; + +extern int zconflex(void); +static void zconfprint(const char *err, ...); +static void zconf_error(const char *err, ...); +static void zconferror(const char *err); +static bool zconf_endtoken(struct kconf_id *id, int starttoken, int endtoken); + +struct symbol *symbol_hash[SYMBOL_HASHSIZE]; + +static struct menu *current_menu, *current_entry; + +#define YYDEBUG 0 +#if YYDEBUG +#define YYERROR_VERBOSE +#endif + + + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + T_MAINMENU = 258, + T_MENU = 259, + T_ENDMENU = 260, + T_SOURCE = 261, + T_CHOICE = 262, + T_ENDCHOICE = 263, + T_COMMENT = 264, + T_CONFIG = 265, + T_MENUCONFIG = 266, + T_HELP = 267, + T_HELPTEXT = 268, + T_IF = 269, + T_ENDIF = 270, + T_DEPENDS = 271, + T_OPTIONAL = 272, + T_PROMPT = 273, + T_TYPE = 274, + T_DEFAULT = 275, + T_SELECT = 276, + T_RANGE = 277, + T_VISIBLE = 278, + T_OPTION = 279, + T_ON = 280, + T_WORD = 281, + T_WORD_QUOTE = 282, + T_UNEQUAL = 283, + T_CLOSE_PAREN = 284, + T_OPEN_PAREN = 285, + T_EOL = 286, + T_OR = 287, + T_AND = 288, + T_EQUAL = 289, + T_NOT = 290 + }; +#endif + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +{ + + + char *string; + struct file *file; + struct symbol *symbol; + struct expr *expr; + struct menu *menu; + struct kconf_id *id; + + + +} YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +#endif + + +/* Copy the second part of user declarations. */ + + +/* Include zconf.hash.c here so it can see the token constants. */ +#include "zconf.hash.c" + + + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include <stddef.h> /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if YYENABLE_NLS +# if ENABLE_NLS +# include <libintl.h> /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int yyi) +#else +static int +YYID (yyi) + int yyi; +#endif +{ + return yyi; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include <alloca.h> /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include <malloc.h> /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss_alloc; + YYSTYPE yyvs_alloc; +}; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) + +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 11 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 290 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 36 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 50 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 118 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 191 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 290 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint16 yyprhs[] = +{ + 0, 0, 3, 6, 8, 11, 13, 14, 17, 20, + 23, 26, 31, 36, 40, 42, 44, 46, 48, 50, + 52, 54, 56, 58, 60, 62, 64, 66, 68, 72, + 75, 79, 82, 86, 89, 90, 93, 96, 99, 102, + 105, 108, 112, 117, 122, 127, 133, 137, 138, 142, + 143, 146, 150, 153, 155, 159, 160, 163, 166, 169, + 172, 175, 180, 184, 187, 192, 193, 196, 200, 202, + 206, 207, 210, 213, 216, 220, 224, 228, 230, 234, + 235, 238, 241, 244, 248, 252, 255, 258, 261, 262, + 265, 268, 271, 276, 277, 280, 283, 286, 287, 290, + 292, 294, 297, 300, 303, 305, 308, 309, 312, 314, + 318, 322, 326, 329, 333, 337, 339, 341, 342 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int8 yyrhs[] = +{ + 37, 0, -1, 81, 38, -1, 38, -1, 63, 39, + -1, 39, -1, -1, 39, 41, -1, 39, 55, -1, + 39, 67, -1, 39, 80, -1, 39, 26, 1, 31, + -1, 39, 40, 1, 31, -1, 39, 1, 31, -1, + 16, -1, 18, -1, 19, -1, 21, -1, 17, -1, + 22, -1, 20, -1, 23, -1, 31, -1, 61, -1, + 71, -1, 44, -1, 46, -1, 69, -1, 26, 1, + 31, -1, 1, 31, -1, 10, 26, 31, -1, 43, + 47, -1, 11, 26, 31, -1, 45, 47, -1, -1, + 47, 48, -1, 47, 49, -1, 47, 75, -1, 47, + 73, -1, 47, 42, -1, 47, 31, -1, 19, 78, + 31, -1, 18, 79, 82, 31, -1, 20, 83, 82, + 31, -1, 21, 26, 82, 31, -1, 22, 84, 84, + 82, 31, -1, 24, 50, 31, -1, -1, 50, 26, + 51, -1, -1, 34, 79, -1, 7, 85, 31, -1, + 52, 56, -1, 80, -1, 53, 58, 54, -1, -1, + 56, 57, -1, 56, 75, -1, 56, 73, -1, 56, + 31, -1, 56, 42, -1, 18, 79, 82, 31, -1, + 19, 78, 31, -1, 17, 31, -1, 20, 26, 82, + 31, -1, -1, 58, 41, -1, 14, 83, 81, -1, + 80, -1, 59, 62, 60, -1, -1, 62, 41, -1, + 62, 67, -1, 62, 55, -1, 3, 79, 81, -1, + 4, 79, 31, -1, 64, 76, 74, -1, 80, -1, + 65, 68, 66, -1, -1, 68, 41, -1, 68, 67, + -1, 68, 55, -1, 6, 79, 31, -1, 9, 79, + 31, -1, 70, 74, -1, 12, 31, -1, 72, 13, + -1, -1, 74, 75, -1, 74, 31, -1, 74, 42, + -1, 16, 25, 83, 31, -1, -1, 76, 77, -1, + 76, 31, -1, 23, 82, -1, -1, 79, 82, -1, + 26, -1, 27, -1, 5, 31, -1, 8, 31, -1, + 15, 31, -1, 31, -1, 81, 31, -1, -1, 14, + 83, -1, 84, -1, 84, 34, 84, -1, 84, 28, + 84, -1, 30, 83, 29, -1, 35, 83, -1, 83, + 32, 83, -1, 83, 33, 83, -1, 26, -1, 27, + -1, -1, 26, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const yytype_uint16 yyrline[] = +{ + 0, 108, 108, 108, 110, 110, 112, 114, 115, 116, + 117, 118, 119, 123, 127, 127, 127, 127, 127, 127, + 127, 127, 131, 132, 133, 134, 135, 136, 140, 141, + 147, 155, 161, 169, 179, 181, 182, 183, 184, 185, + 186, 189, 197, 203, 213, 219, 225, 228, 230, 241, + 242, 247, 256, 261, 269, 272, 274, 275, 276, 277, + 278, 281, 287, 298, 304, 314, 316, 321, 329, 337, + 340, 342, 343, 344, 349, 356, 363, 368, 376, 379, + 381, 382, 383, 386, 394, 401, 408, 414, 421, 423, + 424, 425, 428, 436, 438, 439, 442, 449, 451, 456, + 457, 460, 461, 462, 466, 467, 470, 471, 474, 475, + 476, 477, 478, 479, 480, 483, 484, 487, 488 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "T_MAINMENU", "T_MENU", "T_ENDMENU", + "T_SOURCE", "T_CHOICE", "T_ENDCHOICE", "T_COMMENT", "T_CONFIG", + "T_MENUCONFIG", "T_HELP", "T_HELPTEXT", "T_IF", "T_ENDIF", "T_DEPENDS", + "T_OPTIONAL", "T_PROMPT", "T_TYPE", "T_DEFAULT", "T_SELECT", "T_RANGE", + "T_VISIBLE", "T_OPTION", "T_ON", "T_WORD", "T_WORD_QUOTE", "T_UNEQUAL", + "T_CLOSE_PAREN", "T_OPEN_PAREN", "T_EOL", "T_OR", "T_AND", "T_EQUAL", + "T_NOT", "$accept", "input", "start", "stmt_list", "option_name", + "common_stmt", "option_error", "config_entry_start", "config_stmt", + "menuconfig_entry_start", "menuconfig_stmt", "config_option_list", + "config_option", "symbol_option", "symbol_option_list", + "symbol_option_arg", "choice", "choice_entry", "choice_end", + "choice_stmt", "choice_option_list", "choice_option", "choice_block", + "if_entry", "if_end", "if_stmt", "if_block", "mainmenu_stmt", "menu", + "menu_entry", "menu_end", "menu_stmt", "menu_block", "source_stmt", + "comment", "comment_stmt", "help_start", "help", "depends_list", + "depends", "visibility_list", "visible", "prompt_stmt_opt", "prompt", + "end", "nl", "if_expr", "expr", "symbol", "word_opt", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, + 285, 286, 287, 288, 289, 290 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 36, 37, 37, 38, 38, 39, 39, 39, 39, + 39, 39, 39, 39, 40, 40, 40, 40, 40, 40, + 40, 40, 41, 41, 41, 41, 41, 41, 42, 42, + 43, 44, 45, 46, 47, 47, 47, 47, 47, 47, + 47, 48, 48, 48, 48, 48, 49, 50, 50, 51, + 51, 52, 53, 54, 55, 56, 56, 56, 56, 56, + 56, 57, 57, 57, 57, 58, 58, 59, 60, 61, + 62, 62, 62, 62, 63, 64, 65, 66, 67, 68, + 68, 68, 68, 69, 70, 71, 72, 73, 74, 74, + 74, 74, 75, 76, 76, 76, 77, 78, 78, 79, + 79, 80, 80, 80, 81, 81, 82, 82, 83, 83, + 83, 83, 83, 83, 83, 84, 84, 85, 85 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 2, 1, 2, 1, 0, 2, 2, 2, + 2, 4, 4, 3, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 3, 2, + 3, 2, 3, 2, 0, 2, 2, 2, 2, 2, + 2, 3, 4, 4, 4, 5, 3, 0, 3, 0, + 2, 3, 2, 1, 3, 0, 2, 2, 2, 2, + 2, 4, 3, 2, 4, 0, 2, 3, 1, 3, + 0, 2, 2, 2, 3, 3, 3, 1, 3, 0, + 2, 2, 2, 3, 3, 2, 2, 2, 0, 2, + 2, 2, 4, 0, 2, 2, 2, 0, 2, 1, + 1, 2, 2, 2, 1, 2, 0, 2, 1, 3, + 3, 3, 2, 3, 3, 1, 1, 0, 1 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 6, 0, 104, 0, 3, 0, 6, 6, 99, 100, + 0, 1, 0, 0, 0, 0, 117, 0, 0, 0, + 0, 0, 0, 14, 18, 15, 16, 20, 17, 19, + 21, 0, 22, 0, 7, 34, 25, 34, 26, 55, + 65, 8, 70, 23, 93, 79, 9, 27, 88, 24, + 10, 0, 105, 2, 74, 13, 0, 101, 0, 118, + 0, 102, 0, 0, 0, 115, 116, 0, 0, 0, + 108, 103, 0, 0, 0, 0, 0, 0, 0, 88, + 0, 0, 75, 83, 51, 84, 30, 32, 0, 112, + 0, 0, 67, 0, 0, 11, 12, 0, 0, 0, + 0, 97, 0, 0, 0, 47, 0, 40, 39, 35, + 36, 0, 38, 37, 0, 0, 97, 0, 59, 60, + 56, 58, 57, 66, 54, 53, 71, 73, 69, 72, + 68, 106, 95, 0, 94, 80, 82, 78, 81, 77, + 90, 91, 89, 111, 113, 114, 110, 109, 29, 86, + 0, 106, 0, 106, 106, 106, 0, 0, 0, 87, + 63, 106, 0, 106, 0, 96, 0, 0, 41, 98, + 0, 0, 106, 49, 46, 28, 0, 62, 0, 107, + 92, 42, 43, 44, 0, 0, 48, 61, 64, 45, + 50 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int16 yydefgoto[] = +{ + -1, 3, 4, 5, 33, 34, 108, 35, 36, 37, + 38, 74, 109, 110, 157, 186, 39, 40, 124, 41, + 76, 120, 77, 42, 128, 43, 78, 6, 44, 45, + 137, 46, 80, 47, 48, 49, 111, 112, 81, 113, + 79, 134, 152, 153, 50, 7, 165, 69, 70, 60 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -90 +static const yytype_int16 yypact[] = +{ + 4, 42, -90, 96, -90, 111, -90, 15, -90, -90, + 75, -90, 82, 42, 104, 42, 110, 107, 42, 115, + 125, -4, 121, -90, -90, -90, -90, -90, -90, -90, + -90, 162, -90, 163, -90, -90, -90, -90, -90, -90, + -90, -90, -90, -90, -90, -90, -90, -90, -90, -90, + -90, 139, -90, -90, 138, -90, 142, -90, 143, -90, + 152, -90, 164, 167, 168, -90, -90, -4, -4, 77, + -18, -90, 177, 185, 33, 71, 195, 247, 236, -2, + 236, 171, -90, -90, -90, -90, -90, -90, 41, -90, + -4, -4, 138, 97, 97, -90, -90, 186, 187, 194, + 42, 42, -4, 196, 97, -90, 219, -90, -90, -90, + -90, 210, -90, -90, 204, 42, 42, 199, -90, -90, + -90, -90, -90, -90, -90, -90, -90, -90, -90, -90, + -90, 222, -90, 223, -90, -90, -90, -90, -90, -90, + -90, -90, -90, -90, 215, -90, -90, -90, -90, -90, + -4, 222, 228, 222, -5, 222, 97, 35, 229, -90, + -90, 222, 232, 222, -4, -90, 135, 233, -90, -90, + 234, 235, 222, 240, -90, -90, 237, -90, 239, -13, + -90, -90, -90, -90, 244, 42, -90, -90, -90, -90, + -90 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int16 yypgoto[] = +{ + -90, -90, 269, 271, -90, 23, -70, -90, -90, -90, + -90, 243, -90, -90, -90, -90, -90, -90, -90, -48, + -90, -90, -90, -90, -90, -90, -90, -90, -90, -90, + -90, -20, -90, -90, -90, -90, -90, 206, 205, -68, + -90, -90, 169, -1, 27, -7, 118, -66, -89, -90 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -86 +static const yytype_int16 yytable[] = +{ + 10, 88, 89, 54, 146, 147, 119, 1, 122, 164, + 93, 141, 56, 142, 58, 156, 94, 62, 1, 90, + 91, 131, 65, 66, 144, 145, 67, 90, 91, 132, + 127, 68, 136, -31, 97, 2, 154, -31, -31, -31, + -31, -31, -31, -31, -31, 98, 52, -31, -31, 99, + -31, 100, 101, 102, 103, 104, -31, 105, 129, 106, + 138, 173, 92, 141, 107, 142, 174, 172, 8, 9, + 143, -33, 97, 90, 91, -33, -33, -33, -33, -33, + -33, -33, -33, 98, 166, -33, -33, 99, -33, 100, + 101, 102, 103, 104, -33, 105, 11, 106, 179, 151, + 123, 126, 107, 135, 125, 130, 2, 139, 2, 90, + 91, -5, 12, 55, 161, 13, 14, 15, 16, 17, + 18, 19, 20, 65, 66, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 57, 59, 31, 61, -4, + 12, 63, 32, 13, 14, 15, 16, 17, 18, 19, + 20, 64, 71, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 72, 73, 31, 180, 90, 91, 52, + 32, -85, 97, 82, 83, -85, -85, -85, -85, -85, + -85, -85, -85, 84, 190, -85, -85, 99, -85, -85, + -85, -85, -85, -85, -85, 85, 97, 106, 86, 87, + -52, -52, 140, -52, -52, -52, -52, 98, 95, -52, + -52, 99, 114, 115, 116, 117, 96, 148, 149, 150, + 158, 106, 155, 159, 97, 163, 118, -76, -76, -76, + -76, -76, -76, -76, -76, 160, 164, -76, -76, 99, + 13, 14, 15, 16, 17, 18, 19, 20, 91, 106, + 21, 22, 14, 15, 140, 17, 18, 19, 20, 168, + 175, 21, 22, 177, 181, 182, 183, 32, 187, 167, + 188, 169, 170, 171, 185, 189, 53, 51, 32, 176, + 75, 178, 121, 0, 133, 162, 0, 0, 0, 0, + 184 +}; + +static const yytype_int16 yycheck[] = +{ + 1, 67, 68, 10, 93, 94, 76, 3, 76, 14, + 28, 81, 13, 81, 15, 104, 34, 18, 3, 32, + 33, 23, 26, 27, 90, 91, 30, 32, 33, 31, + 78, 35, 80, 0, 1, 31, 102, 4, 5, 6, + 7, 8, 9, 10, 11, 12, 31, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 78, 26, + 80, 26, 69, 133, 31, 133, 31, 156, 26, 27, + 29, 0, 1, 32, 33, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 150, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24, 0, 26, 164, 100, + 77, 78, 31, 80, 77, 78, 31, 80, 31, 32, + 33, 0, 1, 31, 115, 4, 5, 6, 7, 8, + 9, 10, 11, 26, 27, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 31, 26, 26, 31, 0, + 1, 26, 31, 4, 5, 6, 7, 8, 9, 10, + 11, 26, 31, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 1, 1, 26, 31, 32, 33, 31, + 31, 0, 1, 31, 31, 4, 5, 6, 7, 8, + 9, 10, 11, 31, 185, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 31, 1, 26, 31, 31, + 5, 6, 31, 8, 9, 10, 11, 12, 31, 14, + 15, 16, 17, 18, 19, 20, 31, 31, 31, 25, + 1, 26, 26, 13, 1, 26, 31, 4, 5, 6, + 7, 8, 9, 10, 11, 31, 14, 14, 15, 16, + 4, 5, 6, 7, 8, 9, 10, 11, 33, 26, + 14, 15, 5, 6, 31, 8, 9, 10, 11, 31, + 31, 14, 15, 31, 31, 31, 31, 31, 31, 151, + 31, 153, 154, 155, 34, 31, 7, 6, 31, 161, + 37, 163, 76, -1, 79, 116, -1, -1, -1, -1, + 172 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 3, 31, 37, 38, 39, 63, 81, 26, 27, + 79, 0, 1, 4, 5, 6, 7, 8, 9, 10, + 11, 14, 15, 16, 17, 18, 19, 20, 21, 22, + 23, 26, 31, 40, 41, 43, 44, 45, 46, 52, + 53, 55, 59, 61, 64, 65, 67, 69, 70, 71, + 80, 39, 31, 38, 81, 31, 79, 31, 79, 26, + 85, 31, 79, 26, 26, 26, 27, 30, 35, 83, + 84, 31, 1, 1, 47, 47, 56, 58, 62, 76, + 68, 74, 31, 31, 31, 31, 31, 31, 83, 83, + 32, 33, 81, 28, 34, 31, 31, 1, 12, 16, + 18, 19, 20, 21, 22, 24, 26, 31, 42, 48, + 49, 72, 73, 75, 17, 18, 19, 20, 31, 42, + 57, 73, 75, 41, 54, 80, 41, 55, 60, 67, + 80, 23, 31, 74, 77, 41, 55, 66, 67, 80, + 31, 42, 75, 29, 83, 83, 84, 84, 31, 31, + 25, 79, 78, 79, 83, 26, 84, 50, 1, 13, + 31, 79, 78, 26, 14, 82, 83, 82, 31, 82, + 82, 82, 84, 26, 31, 31, 82, 31, 82, 83, + 31, 31, 31, 31, 82, 34, 51, 31, 31, 31, + 79 +}; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK (1); \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) + + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (YYLEX_PARAM) +#else +# define YYLEX yylex () +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include <stdio.h> /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; +#endif +{ + if (!yyvaluep) + return; +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) +#else +static void +yy_stack_print (yybottom, yytop) + yytype_int16 *yybottom; + yytype_int16 *yytop; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (; yybottom <= yytop; yybottom++) + { + int yybot = *yybottom; + YYFPRINTF (stderr, " %d", yybot); + } + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (YYID (0)) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_reduce_print (YYSTYPE *yyvsp, int yyrule) +#else +static void +yy_reduce_print (yyvsp, yyrule) + YYSTYPE *yyvsp; + int yyrule; +#endif +{ + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + YYFPRINTF (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + ); + YYFPRINTF (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, Rule); \ +} while (YYID (0)) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T +yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static char * +yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) +{ + int yyn = yypact[yystate]; + + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } +} +#endif /* YYERROR_VERBOSE */ + + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) +#else +static void +yydestruct (yymsg, yytype, yyvaluep) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; +#endif +{ + YYUSE (yyvaluep); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + case 53: /* "choice_entry" */ + + { + fprintf(stderr, "%s:%d: missing end statement for this entry\n", + (yyvaluep->menu)->file->name, (yyvaluep->menu)->lineno); + if (current_menu == (yyvaluep->menu)) + menu_end_menu(); +}; + + break; + case 59: /* "if_entry" */ + + { + fprintf(stderr, "%s:%d: missing end statement for this entry\n", + (yyvaluep->menu)->file->name, (yyvaluep->menu)->lineno); + if (current_menu == (yyvaluep->menu)) + menu_end_menu(); +}; + + break; + case 65: /* "menu_entry" */ + + { + fprintf(stderr, "%s:%d: missing end statement for this entry\n", + (yyvaluep->menu)->file->name, (yyvaluep->menu)->lineno); + if (current_menu == (yyvaluep->menu)) + menu_end_menu(); +}; + + break; + + default: + break; + } +} + +/* Prevent warnings from -Wmissing-prototypes. */ +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (void); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + +/* The lookahead symbol. */ +int yychar; + +/* The semantic value of the lookahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + + +/*-------------------------. +| yyparse or yypush_parse. | +`-------------------------*/ + +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void) +#else +int +yyparse () + +#endif +#endif +{ + + + int yystate; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + + /* The stacks and their tools: + `yyss': related to states. + `yyvs': related to semantic values. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs; + YYSTYPE *yyvsp; + + YYSIZE_T yystacksize; + + int yyn; + int yyresult; + /* Lookahead token as an internal (translated) token number. */ + int yytoken; + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + yytoken = 0; + yyss = yyssa; + yyvs = yyvsa; + yystacksize = YYINITDEPTH; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + if (yystate == YYFINAL) + YYACCEPT; + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + lookahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to lookahead token. */ + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the lookahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token. */ + yychar = YYEMPTY; + + yystate = yyn; + *++yyvsp = yylval; + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 10: + + { zconf_error("unexpected end statement"); ;} + break; + + case 11: + + { zconf_error("unknown statement \"%s\"", (yyvsp[(2) - (4)].string)); ;} + break; + + case 12: + + { + zconf_error("unexpected option \"%s\"", kconf_id_strings + (yyvsp[(2) - (4)].id)->name); +;} + break; + + case 13: + + { zconf_error("invalid statement"); ;} + break; + + case 28: + + { zconf_error("unknown option \"%s\"", (yyvsp[(1) - (3)].string)); ;} + break; + + case 29: + + { zconf_error("invalid option"); ;} + break; + + case 30: + + { + struct symbol *sym = sym_lookup((yyvsp[(2) - (3)].string), 0); + sym->flags |= SYMBOL_OPTIONAL; + menu_add_entry(sym); + printd(DEBUG_PARSE, "%s:%d:config %s\n", zconf_curname(), zconf_lineno(), (yyvsp[(2) - (3)].string)); +;} + break; + + case 31: + + { + menu_end_entry(); + printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 32: + + { + struct symbol *sym = sym_lookup((yyvsp[(2) - (3)].string), 0); + sym->flags |= SYMBOL_OPTIONAL; + menu_add_entry(sym); + printd(DEBUG_PARSE, "%s:%d:menuconfig %s\n", zconf_curname(), zconf_lineno(), (yyvsp[(2) - (3)].string)); +;} + break; + + case 33: + + { + if (current_entry->prompt) + current_entry->prompt->type = P_MENU; + else + zconfprint("warning: menuconfig statement without prompt"); + menu_end_entry(); + printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 41: + + { + menu_set_type((yyvsp[(1) - (3)].id)->stype); + printd(DEBUG_PARSE, "%s:%d:type(%u)\n", + zconf_curname(), zconf_lineno(), + (yyvsp[(1) - (3)].id)->stype); +;} + break; + + case 42: + + { + menu_add_prompt(P_PROMPT, (yyvsp[(2) - (4)].string), (yyvsp[(3) - (4)].expr)); + printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 43: + + { + menu_add_expr(P_DEFAULT, (yyvsp[(2) - (4)].expr), (yyvsp[(3) - (4)].expr)); + if ((yyvsp[(1) - (4)].id)->stype != S_UNKNOWN) + menu_set_type((yyvsp[(1) - (4)].id)->stype); + printd(DEBUG_PARSE, "%s:%d:default(%u)\n", + zconf_curname(), zconf_lineno(), + (yyvsp[(1) - (4)].id)->stype); +;} + break; + + case 44: + + { + menu_add_symbol(P_SELECT, sym_lookup((yyvsp[(2) - (4)].string), 0), (yyvsp[(3) - (4)].expr)); + printd(DEBUG_PARSE, "%s:%d:select\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 45: + + { + menu_add_expr(P_RANGE, expr_alloc_comp(E_RANGE,(yyvsp[(2) - (5)].symbol), (yyvsp[(3) - (5)].symbol)), (yyvsp[(4) - (5)].expr)); + printd(DEBUG_PARSE, "%s:%d:range\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 48: + + { + struct kconf_id *id = kconf_id_lookup((yyvsp[(2) - (3)].string), strlen((yyvsp[(2) - (3)].string))); + if (id && id->flags & TF_OPTION) + menu_add_option(id->token, (yyvsp[(3) - (3)].string)); + else + zconfprint("warning: ignoring unknown option %s", (yyvsp[(2) - (3)].string)); + free((yyvsp[(2) - (3)].string)); +;} + break; + + case 49: + + { (yyval.string) = NULL; ;} + break; + + case 50: + + { (yyval.string) = (yyvsp[(2) - (2)].string); ;} + break; + + case 51: + + { + struct symbol *sym = sym_lookup((yyvsp[(2) - (3)].string), SYMBOL_CHOICE); + sym->flags |= SYMBOL_AUTO; + menu_add_entry(sym); + menu_add_expr(P_CHOICE, NULL, NULL); + printd(DEBUG_PARSE, "%s:%d:choice\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 52: + + { + (yyval.menu) = menu_add_menu(); +;} + break; + + case 53: + + { + if (zconf_endtoken((yyvsp[(1) - (1)].id), T_CHOICE, T_ENDCHOICE)) { + menu_end_menu(); + printd(DEBUG_PARSE, "%s:%d:endchoice\n", zconf_curname(), zconf_lineno()); + } +;} + break; + + case 61: + + { + menu_add_prompt(P_PROMPT, (yyvsp[(2) - (4)].string), (yyvsp[(3) - (4)].expr)); + printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 62: + + { + if ((yyvsp[(1) - (3)].id)->stype == S_BOOLEAN || (yyvsp[(1) - (3)].id)->stype == S_TRISTATE) { + menu_set_type((yyvsp[(1) - (3)].id)->stype); + printd(DEBUG_PARSE, "%s:%d:type(%u)\n", + zconf_curname(), zconf_lineno(), + (yyvsp[(1) - (3)].id)->stype); + } else + YYERROR; +;} + break; + + case 63: + + { + current_entry->sym->flags |= SYMBOL_OPTIONAL; + printd(DEBUG_PARSE, "%s:%d:optional\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 64: + + { + if ((yyvsp[(1) - (4)].id)->stype == S_UNKNOWN) { + menu_add_symbol(P_DEFAULT, sym_lookup((yyvsp[(2) - (4)].string), 0), (yyvsp[(3) - (4)].expr)); + printd(DEBUG_PARSE, "%s:%d:default\n", + zconf_curname(), zconf_lineno()); + } else + YYERROR; +;} + break; + + case 67: + + { + printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno()); + menu_add_entry(NULL); + menu_add_dep((yyvsp[(2) - (3)].expr)); + (yyval.menu) = menu_add_menu(); +;} + break; + + case 68: + + { + if (zconf_endtoken((yyvsp[(1) - (1)].id), T_IF, T_ENDIF)) { + menu_end_menu(); + printd(DEBUG_PARSE, "%s:%d:endif\n", zconf_curname(), zconf_lineno()); + } +;} + break; + + case 74: + + { + menu_add_prompt(P_MENU, (yyvsp[(2) - (3)].string), NULL); +;} + break; + + case 75: + + { + menu_add_entry(NULL); + menu_add_prompt(P_MENU, (yyvsp[(2) - (3)].string), NULL); + printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 76: + + { + (yyval.menu) = menu_add_menu(); +;} + break; + + case 77: + + { + if (zconf_endtoken((yyvsp[(1) - (1)].id), T_MENU, T_ENDMENU)) { + menu_end_menu(); + printd(DEBUG_PARSE, "%s:%d:endmenu\n", zconf_curname(), zconf_lineno()); + } +;} + break; + + case 83: + + { + printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), (yyvsp[(2) - (3)].string)); + zconf_nextfile((yyvsp[(2) - (3)].string)); +;} + break; + + case 84: + + { + menu_add_entry(NULL); + menu_add_prompt(P_COMMENT, (yyvsp[(2) - (3)].string), NULL); + printd(DEBUG_PARSE, "%s:%d:comment\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 85: + + { + menu_end_entry(); +;} + break; + + case 86: + + { + printd(DEBUG_PARSE, "%s:%d:help\n", zconf_curname(), zconf_lineno()); + zconf_starthelp(); +;} + break; + + case 87: + + { + current_entry->help = (yyvsp[(2) - (2)].string); +;} + break; + + case 92: + + { + menu_add_dep((yyvsp[(3) - (4)].expr)); + printd(DEBUG_PARSE, "%s:%d:depends on\n", zconf_curname(), zconf_lineno()); +;} + break; + + case 96: + + { + menu_add_visibility((yyvsp[(2) - (2)].expr)); +;} + break; + + case 98: + + { + menu_add_prompt(P_PROMPT, (yyvsp[(1) - (2)].string), (yyvsp[(2) - (2)].expr)); +;} + break; + + case 101: + + { (yyval.id) = (yyvsp[(1) - (2)].id); ;} + break; + + case 102: + + { (yyval.id) = (yyvsp[(1) - (2)].id); ;} + break; + + case 103: + + { (yyval.id) = (yyvsp[(1) - (2)].id); ;} + break; + + case 106: + + { (yyval.expr) = NULL; ;} + break; + + case 107: + + { (yyval.expr) = (yyvsp[(2) - (2)].expr); ;} + break; + + case 108: + + { (yyval.expr) = expr_alloc_symbol((yyvsp[(1) - (1)].symbol)); ;} + break; + + case 109: + + { (yyval.expr) = expr_alloc_comp(E_EQUAL, (yyvsp[(1) - (3)].symbol), (yyvsp[(3) - (3)].symbol)); ;} + break; + + case 110: + + { (yyval.expr) = expr_alloc_comp(E_UNEQUAL, (yyvsp[(1) - (3)].symbol), (yyvsp[(3) - (3)].symbol)); ;} + break; + + case 111: + + { (yyval.expr) = (yyvsp[(2) - (3)].expr); ;} + break; + + case 112: + + { (yyval.expr) = expr_alloc_one(E_NOT, (yyvsp[(2) - (2)].expr)); ;} + break; + + case 113: + + { (yyval.expr) = expr_alloc_two(E_OR, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 114: + + { (yyval.expr) = expr_alloc_two(E_AND, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 115: + + { (yyval.symbol) = sym_lookup((yyvsp[(1) - (1)].string), 0); free((yyvsp[(1) - (1)].string)); ;} + break; + + case 116: + + { (yyval.symbol) = sym_lookup((yyvsp[(1) - (1)].string), SYMBOL_CONST); free((yyvsp[(1) - (1)].string)); ;} + break; + + case 117: + + { (yyval.string) = NULL; ;} + break; + + + + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (yymsg); + } + else + { + yyerror (YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse lookahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + *++yyvsp = yylval; + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#if !defined(yyoverflow) || YYERROR_VERBOSE +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); +} + + + + + +void conf_parse(const char *name) +{ + struct symbol *sym; + int i; + + zconf_initscan(name); + + sym_init(); + _menu_init(); + modules_sym = sym_lookup(NULL, 0); + modules_sym->type = S_BOOLEAN; + modules_sym->flags |= SYMBOL_AUTO; + rootmenu.prompt = menu_add_prompt(P_MENU, "Linux Kernel Configuration", NULL); + +#if YYDEBUG + if (getenv("ZCONF_DEBUG")) + zconfdebug = 1; +#endif + zconfparse(); + if (zconfnerrs) + exit(1); + if (!modules_sym->prop) { + struct property *prop; + + prop = prop_alloc(P_DEFAULT, modules_sym); + prop->expr = expr_alloc_symbol(sym_lookup("MODULES", 0)); + } + + rootmenu.prompt->text = _(rootmenu.prompt->text); + rootmenu.prompt->text = sym_expand_string_value(rootmenu.prompt->text); + + menu_finalize(&rootmenu); + for_all_symbols(i, sym) { + if (sym_check_deps(sym)) + zconfnerrs++; + } + if (zconfnerrs) + exit(1); + sym_set_change_count(1); +} + +static const char *zconf_tokenname(int token) +{ + switch (token) { + case T_MENU: return "menu"; + case T_ENDMENU: return "endmenu"; + case T_CHOICE: return "choice"; + case T_ENDCHOICE: return "endchoice"; + case T_IF: return "if"; + case T_ENDIF: return "endif"; + case T_DEPENDS: return "depends"; + case T_VISIBLE: return "visible"; + } + return "<token>"; +} + +static bool zconf_endtoken(struct kconf_id *id, int starttoken, int endtoken) +{ + if (id->token != endtoken) { + zconf_error("unexpected '%s' within %s block", + kconf_id_strings + id->name, zconf_tokenname(starttoken)); + zconfnerrs++; + return false; + } + if(0) { + //if (current_menu->file != current_file) { + zconf_error("'%s' in different file than '%s'", + kconf_id_strings + id->name, zconf_tokenname(starttoken)); + fprintf(stderr, "%s:%d: location of the '%s'\n", + current_menu->file->name, current_menu->lineno, + zconf_tokenname(starttoken)); + zconfnerrs++; + return false; + } + return true; +} + +static void zconfprint(const char *err, ...) +{ + va_list ap; + + fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno()); + va_start(ap, err); + vfprintf(stderr, err, ap); + va_end(ap); + fprintf(stderr, "\n"); +} + +static void zconf_error(const char *err, ...) +{ + va_list ap; + + zconfnerrs++; + fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno()); + va_start(ap, err); + vfprintf(stderr, err, ap); + va_end(ap); + fprintf(stderr, "\n"); +} + +static void zconferror(const char *err) +{ +#if YYDEBUG + fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err); +#endif +} + +static void print_quoted_string(FILE *out, const char *str) +{ + const char *p; + int len; + + putc('"', out); + while ((p = strchr(str, '"'))) { + len = p - str; + if (len) + fprintf(out, "%.*s", len, str); + fputs("\\\"", out); + str = p + 1; + } + fputs(str, out); + putc('"', out); +} + +static void print_symbol(FILE *out, struct menu *menu) +{ + struct symbol *sym = menu->sym; + struct property *prop; + + if (sym_is_choice(sym)) + fprintf(out, "\nchoice\n"); + else + fprintf(out, "\nconfig %s\n", sym->name); + switch (sym->type) { + case S_BOOLEAN: + fputs(" boolean\n", out); + break; + case S_TRISTATE: + fputs(" tristate\n", out); + break; + case S_STRING: + fputs(" string\n", out); + break; + case S_INT: + fputs(" integer\n", out); + break; + case S_HEX: + fputs(" hex\n", out); + break; + default: + fputs(" ???\n", out); + break; + } + for (prop = sym->prop; prop; prop = prop->next) { + if (prop->menu != menu) + continue; + switch (prop->type) { + case P_PROMPT: + fputs(" prompt ", out); + print_quoted_string(out, prop->text); + if (!expr_is_yes(prop->visible.expr)) { + fputs(" if ", out); + expr_fprint(prop->visible.expr, out); + } + fputc('\n', out); + break; + case P_DEFAULT: + fputs( " default ", out); + expr_fprint(prop->expr, out); + if (!expr_is_yes(prop->visible.expr)) { + fputs(" if ", out); + expr_fprint(prop->visible.expr, out); + } + fputc('\n', out); + break; + case P_CHOICE: + fputs(" #choice value\n", out); + break; + case P_SELECT: + fputs( " select ", out); + expr_fprint(prop->expr, out); + fputc('\n', out); + break; + case P_RANGE: + fputs( " range ", out); + expr_fprint(prop->expr, out); + fputc('\n', out); + break; + case P_MENU: + fputs( " menu ", out); + print_quoted_string(out, prop->text); + fputc('\n', out); + break; + default: + fprintf(out, " unknown prop %d!\n", prop->type); + break; + } + } + if (menu->help) { + int len = strlen(menu->help); + while (menu->help[--len] == '\n') + menu->help[len] = 0; + fprintf(out, " help\n%s\n", menu->help); + } +} + +void zconfdump(FILE *out) +{ + struct property *prop; + struct symbol *sym; + struct menu *menu; + + menu = rootmenu.list; + while (menu) { + if ((sym = menu->sym)) + print_symbol(out, menu); + else if ((prop = menu->prompt)) { + switch (prop->type) { + case P_COMMENT: + fputs("\ncomment ", out); + print_quoted_string(out, prop->text); + fputs("\n", out); + break; + case P_MENU: + fputs("\nmenu ", out); + print_quoted_string(out, prop->text); + fputs("\n", out); + break; + default: + ; + } + if (!expr_is_yes(prop->visible.expr)) { + fputs(" depends ", out); + expr_fprint(prop->visible.expr, out); + fputc('\n', out); + } + } + + if (menu->list) + menu = menu->list; + else if (menu->next) + menu = menu->next; + else while ((menu = menu->parent)) { + if (menu->prompt && menu->prompt->type == P_MENU) + fputs("\nendmenu\n", out); + if (menu->next) { + menu = menu->next; + break; + } + } + } +} + +#include "lex.zconf.c" +#include "util.c" +#include "confdata.c" +#include "expr.c" +#include "symbol.c" +#include "menu.c" + Index: branches/azimutz/Cleancut/i386/config/Makefile =================================================================== --- branches/azimutz/Cleancut/i386/config/Makefile (revision 0) +++ branches/azimutz/Cleancut/i386/config/Makefile (revision 885) @@ -0,0 +1,54 @@ +# +# Until I can remove the dependency on the appkit, +# we'll just keep the generated files in this directory +# and install them directly, rather than generating them again. +# +SRCROOT = $(shell pwd)/../../ +OBJROOT = $(SRCROOT)/obj/i386/config +SYMROOT = $(SRCROOT)/sym/i386 +DSTROOT = $(SRCROOT)/dst/i386 +DOCROOT = $(SRCROOT)/doc +IMGROOT = $(SRCROOT)/sym/cache +IMGSKELROOT = $(SRCROOT)/imgskel +CDBOOT = ${IMGROOT}/usr/standalone/i386/cdboot + +DIR = util +include ${SRCROOT}/Make.rules + + + +OBJECTS = cconfig.o32 cconfig.o64 zconf.tab.o32 zconf.tab.o64 yesno.o32 yesno.o64 textbox.o32 textbox.o64 menubox.o32 menubox.o64 checklist.o32 checklist.o64 inputbox.o32 inputbox.o64 + +DEFINES = -DKBUILD_NO_NLS -DCURSES_LOC=\<ncurses.h\> -DPATH_MAX=256 -DPACKAGE=\"chameleon\" +LDFLAGS = -lncurses -lmenu + + +PROGRAMS = cconfig + + + +SYMPROG = $(addprefix $(SYMROOT)/, $(PROGRAMS)) + +DIRS_NEEDED = $(OBJROOT) $(SYMROOT) + +all: $(DIRS_NEEDED) $(SYMPROG) + + + + +$(SYMPROG): $(addprefix $(OBJROOT)/, $(OBJECTS)) + @echo "\t[LD32] $(@F)_32" + @$(CC) $(CFLAGS) $(LDFLAGS) $(DEFINES) -arch i386 -o $(SYMROOT)/$(@F)_32 $(OBJROOT)/*.o32 + @echo "\t[LD64] $(@F)_64" + @$(CC) $(CFLAGS) $(LDFLAGS) $(DEFINES) -arch x86_64 -o $(SYMROOT)/$(@F)_64 $(OBJROOT)/*.o64 + @echo "\t[LIPO] $(@F)" + @lipo -create -arch i386 $(SYMROOT)/$(@F)_32 -arch x86_64 $(SYMROOT)/$(@F)_64 -output $(SYMROOT)/$(@F) + @$(RM) $(SYMROOT)/$(@F)_32 $(SYMROOT)/$(@F)_64 + +config: $(DIRS_NEEDED) $(SYMPROG) + @cd ${SRCROOT} && $(SYMPROG) $(SRCROOT)/Cconfig + +.PHONY: config + +#dependencies +-include $(OBJROOT)/Makedep \ No newline at end of file Index: branches/azimutz/Cleancut/i386/config/textbox.c =================================================================== --- branches/azimutz/Cleancut/i386/config/textbox.c (revision 0) +++ branches/azimutz/Cleancut/i386/config/textbox.c (revision 885) @@ -0,0 +1,391 @@ +/* + * textbox.c -- implements the text box + * + * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) + * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "dialog.h" + +static void back_lines(int n); +static void print_page(WINDOW * win, int height, int width); +static void print_line(WINDOW * win, int row, int width); +static char *get_line(void); +static void print_position(WINDOW * win); + +static int hscroll; +static int begin_reached, end_reached, page_length; +static const char *buf; +static const char *page; + +/* + * refresh window content + */ +static void refresh_text_box(WINDOW *dialog, WINDOW *box, int boxh, int boxw, + int cur_y, int cur_x) +{ + print_page(box, boxh, boxw); + print_position(dialog); + wmove(dialog, cur_y, cur_x); /* Restore cursor position */ + wrefresh(dialog); +} + + +/* + * Display text from a file in a dialog box. + */ +int dialog_textbox(const char *title, const char *tbuf, + int initial_height, int initial_width) +{ + int i, x, y, cur_x, cur_y, key = 0; + int height, width, boxh, boxw; + int passed_end; + WINDOW *dialog, *box; + + begin_reached = 1; + end_reached = 0; + page_length = 0; + hscroll = 0; + buf = tbuf; + page = buf; /* page is pointer to start of page to be displayed */ + +do_resize: + getmaxyx(stdscr, height, width); + if (height < 8 || width < 8) + return -ERRDISPLAYTOOSMALL; + if (initial_height != 0) + height = initial_height; + else + if (height > 4) + height -= 4; + else + height = 0; + if (initial_width != 0) + width = initial_width; + else + if (width > 5) + width -= 5; + else + width = 0; + + /* center dialog box on screen */ + x = (COLS - width) / 2; + y = (LINES - height) / 2; + + draw_shadow(stdscr, y, x, height, width); + + dialog = newwin(height, width, y, x); + keypad(dialog, TRUE); + + /* Create window for box region, used for scrolling text */ + boxh = height - 4; + boxw = width - 2; + box = subwin(dialog, boxh, boxw, y + 1, x + 1); + wattrset(box, dlg.dialog.atr); + wbkgdset(box, dlg.dialog.atr & A_COLOR); + + keypad(box, TRUE); + + /* register the new window, along with its borders */ + draw_box(dialog, 0, 0, height, width, + dlg.dialog.atr, dlg.border.atr); + + wattrset(dialog, dlg.border.atr); + mvwaddch(dialog, height - 3, 0, ACS_LTEE); + for (i = 0; i < width - 2; i++) + waddch(dialog, ACS_HLINE); + wattrset(dialog, dlg.dialog.atr); + wbkgdset(dialog, dlg.dialog.atr & A_COLOR); + waddch(dialog, ACS_RTEE); + + print_title(dialog, title, width); + + print_button(dialog, gettext(" Exit "), height - 2, width / 2 - 4, TRUE); + wnoutrefresh(dialog); + getyx(dialog, cur_y, cur_x); /* Save cursor position */ + + /* Print first page of text */ + attr_clear(box, boxh, boxw, dlg.dialog.atr); + refresh_text_box(dialog, box, boxh, boxw, cur_y, cur_x); + + while ((key != KEY_ESC) && (key != '\n')) { + key = wgetch(dialog); + switch (key) { + case 'E': /* Exit */ + case 'e': + case 'X': + case 'x': + delwin(box); + delwin(dialog); + return 0; + case 'g': /* First page */ + case KEY_HOME: + if (!begin_reached) { + begin_reached = 1; + page = buf; + refresh_text_box(dialog, box, boxh, boxw, + cur_y, cur_x); + } + break; + case 'G': /* Last page */ + case KEY_END: + + end_reached = 1; + /* point to last char in buf */ + page = buf + strlen(buf); + back_lines(boxh); + refresh_text_box(dialog, box, boxh, boxw, + cur_y, cur_x); + break; + case 'K': /* Previous line */ + case 'k': + case KEY_UP: + if (!begin_reached) { + back_lines(page_length + 1); + + /* We don't call print_page() here but use + * scrolling to ensure faster screen update. + * However, 'end_reached' and 'page_length' + * should still be updated, and 'page' should + * point to start of next page. This is done + * by calling get_line() in the following + * 'for' loop. */ + scrollok(box, TRUE); + wscrl(box, -1); /* Scroll box region down one line */ + scrollok(box, FALSE); + page_length = 0; + passed_end = 0; + for (i = 0; i < boxh; i++) { + if (!i) { + /* print first line of page */ + print_line(box, 0, boxw); + wnoutrefresh(box); + } else + /* Called to update 'end_reached' and 'page' */ + get_line(); + if (!passed_end) + page_length++; + if (end_reached && !passed_end) + passed_end = 1; + } + + print_position(dialog); + wmove(dialog, cur_y, cur_x); /* Restore cursor position */ + wrefresh(dialog); + } + break; + case 'B': /* Previous page */ + case 'b': + case KEY_PPAGE: + if (begin_reached) + break; + back_lines(page_length + boxh); + refresh_text_box(dialog, box, boxh, boxw, + cur_y, cur_x); + break; + case 'J': /* Next line */ + case 'j': + case KEY_DOWN: + if (!end_reached) { + begin_reached = 0; + scrollok(box, TRUE); + scroll(box); /* Scroll box region up one line */ + scrollok(box, FALSE); + print_line(box, boxh - 1, boxw); + wnoutrefresh(box); + print_position(dialog); + wmove(dialog, cur_y, cur_x); /* Restore cursor position */ + wrefresh(dialog); + } + break; + case KEY_NPAGE: /* Next page */ + case ' ': + if (end_reached) + break; + + begin_reached = 0; + refresh_text_box(dialog, box, boxh, boxw, + cur_y, cur_x); + break; + case '0': /* Beginning of line */ + case 'H': /* Scroll left */ + case 'h': + case KEY_LEFT: + if (hscroll <= 0) + break; + + if (key == '0') + hscroll = 0; + else + hscroll--; + /* Reprint current page to scroll horizontally */ + back_lines(page_length); + refresh_text_box(dialog, box, boxh, boxw, + cur_y, cur_x); + break; + case 'L': /* Scroll right */ + case 'l': + case KEY_RIGHT: + if (hscroll >= MAX_LEN) + break; + hscroll++; + /* Reprint current page to scroll horizontally */ + back_lines(page_length); + refresh_text_box(dialog, box, boxh, boxw, + cur_y, cur_x); + break; + case KEY_ESC: + key = on_key_esc(dialog); + break; + case KEY_RESIZE: + back_lines(height); + delwin(box); + delwin(dialog); + on_key_resize(); + goto do_resize; + } + } + delwin(box); + delwin(dialog); + return key; /* ESC pressed */ +} + +/* + * Go back 'n' lines in text. Called by dialog_textbox(). + * 'page' will be updated to point to the desired line in 'buf'. + */ +static void back_lines(int n) +{ + int i; + + begin_reached = 0; + /* Go back 'n' lines */ + for (i = 0; i < n; i++) { + if (*page == '\0') { + if (end_reached) { + end_reached = 0; + continue; + } + } + if (page == buf) { + begin_reached = 1; + return; + } + page--; + do { + if (page == buf) { + begin_reached = 1; + return; + } + page--; + } while (*page != '\n'); + page++; + } +} + +/* + * Print a new page of text. Called by dialog_textbox(). + */ +static void print_page(WINDOW * win, int height, int width) +{ + int i, passed_end = 0; + + page_length = 0; + for (i = 0; i < height; i++) { + print_line(win, i, width); + if (!passed_end) + page_length++; + if (end_reached && !passed_end) + passed_end = 1; + } + wnoutrefresh(win); +} + +/* + * Print a new line of text. Called by dialog_textbox() and print_page(). + */ +static void print_line(WINDOW * win, int row, int width) +{ + int y, x; + char *line; + + line = get_line(); + line += MIN(strlen(line), hscroll); /* Scroll horizontally */ + wmove(win, row, 0); /* move cursor to correct line */ + waddch(win, ' '); + waddnstr(win, line, MIN(strlen(line), width - 2)); + + getyx(win, y, x); + /* Clear 'residue' of previous line */ +#if OLD_NCURSES + { + int i; + for (i = 0; i < width - x; i++) + waddch(win, ' '); + } +#else + wclrtoeol(win); +#endif +} + +/* + * Return current line of text. Called by dialog_textbox() and print_line(). + * 'page' should point to start of current line before calling, and will be + * updated to point to start of next line. + */ +static char *get_line(void) +{ + int i = 0; + static char line[MAX_LEN + 1]; + + end_reached = 0; + while (*page != '\n') { + if (*page == '\0') { + if (!end_reached) { + end_reached = 1; + break; + } + } else if (i < MAX_LEN) + line[i++] = *(page++); + else { + /* Truncate lines longer than MAX_LEN characters */ + if (i == MAX_LEN) + line[i++] = '\0'; + page++; + } + } + if (i <= MAX_LEN) + line[i] = '\0'; + if (!end_reached) + page++; /* move pass '\n' */ + + return line; +} + +/* + * Print current position + */ +static void print_position(WINDOW * win) +{ + int percent; + + wattrset(win, dlg.position_indicator.atr); + wbkgdset(win, dlg.position_indicator.atr & A_COLOR); + percent = (page - buf) * 100 / strlen(buf); + wmove(win, getmaxy(win) - 3, getmaxx(win) - 9); + wprintw(win, "(%3d%%)", percent); +} Index: branches/azimutz/Cleancut/i386/config/yesno.c =================================================================== --- branches/azimutz/Cleancut/i386/config/yesno.c (revision 0) +++ branches/azimutz/Cleancut/i386/config/yesno.c (revision 885) @@ -0,0 +1,114 @@ +/* + * yesno.c -- implements the yes/no box + * + * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) + * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "dialog.h" + +/* + * Display termination buttons + */ +static void print_buttons(WINDOW * dialog, int height, int width, int selected) +{ + int x = width / 2 - 10; + int y = height - 2; + + print_button(dialog, gettext(" Yes "), y, x, selected == 0); + print_button(dialog, gettext(" No "), y, x + 13, selected == 1); + + wmove(dialog, y, x + 1 + 13 * selected); + wrefresh(dialog); +} + +/* + * Display a dialog box with two buttons - Yes and No + */ +int dialog_yesno(const char *title, const char *prompt, int height, int width) +{ + int i, x, y, key = 0, button = 0; + WINDOW *dialog; + +do_resize: + if (getmaxy(stdscr) < (height + 4)) + return -ERRDISPLAYTOOSMALL; + if (getmaxx(stdscr) < (width + 4)) + return -ERRDISPLAYTOOSMALL; + + /* center dialog box on screen */ + x = (COLS - width) / 2; + y = (LINES - height) / 2; + + draw_shadow(stdscr, y, x, height, width); + + dialog = newwin(height, width, y, x); + keypad(dialog, TRUE); + + draw_box(dialog, 0, 0, height, width, + dlg.dialog.atr, dlg.border.atr); + wattrset(dialog, dlg.border.atr); + mvwaddch(dialog, height - 3, 0, ACS_LTEE); + for (i = 0; i < width - 2; i++) + waddch(dialog, ACS_HLINE); + wattrset(dialog, dlg.dialog.atr); + waddch(dialog, ACS_RTEE); + + print_title(dialog, title, width); + + wattrset(dialog, dlg.dialog.atr); + print_autowrap(dialog, prompt, width - 2, 1, 3); + + print_buttons(dialog, height, width, 0); + + while (key != KEY_ESC) { + key = wgetch(dialog); + switch (key) { + case 'Y': + case 'y': + delwin(dialog); + return 0; + case 'N': + case 'n': + delwin(dialog); + return 1; + + case TAB: + case KEY_LEFT: + case KEY_RIGHT: + button = ((key == KEY_LEFT ? --button : ++button) < 0) ? 1 : (button > 1 ? 0 : button); + + print_buttons(dialog, height, width, button); + wrefresh(dialog); + break; + case ' ': + case '\n': + delwin(dialog); + return button; + case KEY_ESC: + key = on_key_esc(dialog); + break; + case KEY_RESIZE: + delwin(dialog); + on_key_resize(); + goto do_resize; + } + } + + delwin(dialog); + return key; /* ESC pressed */ +} Index: branches/azimutz/Cleancut/i386/Cconfig =================================================================== --- branches/azimutz/Cleancut/i386/Cconfig (revision 0) +++ branches/azimutz/Cleancut/i386/Cconfig (revision 885) @@ -0,0 +1,21 @@ +# +# Chameleon Utilities +# + +config OPTIMIZATION_LEVEL + string "Optimization Level" + default "-Oz" + ---help--- + Specify the level to compile chameleon with. + +source "i386/util/Cconfig" + +source "i386/boot0/Cconfig" + +source "i386/boot1/Cconfig" + +source "i386/boot2/Cconfig" + +source "i386/libsa/Cconfig" + +source "i386/libsaio/Cconfig" Index: branches/azimutz/Cleancut/i386/modules/Resolution/Cconfig =================================================================== --- branches/azimutz/Cleancut/i386/modules/Resolution/Cconfig (revision 0) +++ branches/azimutz/Cleancut/i386/modules/Resolution/Cconfig (revision 885) @@ -0,0 +1,10 @@ +# +# Chameleon Modules +# + +config RESOLUTION_MODULE + tristate "Resolution Module" + default m + ---help--- + Say Y here if you want to enable to use of this module. + Index: branches/azimutz/Cleancut/i386/modules/MakeInc.dir =================================================================== --- branches/azimutz/Cleancut/i386/modules/MakeInc.dir (revision 884) +++ branches/azimutz/Cleancut/i386/modules/MakeInc.dir (revision 885) @@ -1,21 +1,43 @@ -OBJROOT = ../../../obj/i386/modules/$(DIR) -SYMROOT = ../../../sym/i386/ -DSTROOT = ../../../dst/i386/ +SRCROOT = $(shell pwd)/../../../ +OBJROOT = $(SRCROOT)/obj/i386/modules/$(DIR) +SYMROOT = $(SRCROOT)/sym/i386/modules/ +DSTROOT = $(SRCROOT)/dst/i386 +DOCROOT = $(SRCROOT)/doc +IMGROOT = $(SRCROOT)/sym/cache +IMGSKELROOT = $(SRCROOT)/imgskel +CDBOOT = ${IMGROOT}/usr/standalone/i386/cdboot +include ${SRCROOT}/Make.rules + + UTILDIR = ../../util LIBSADIR = ../../libsa LIBSAIODIR = ../../libsaio BOOT2DIR = ../../boot2 +INC = -I$(SRCROOT)/i386/modules/include/ -Iinclude/ -I$(SRCROOT)/i386/modules/module_includes/ -I$(SRCROOT)/i386/libsaio/ -I$(SRCROOT)/i386/libsa/ -I$(SRCROOT)/i386/include/ -I$(SRCROOT)/i386/boot2/ +DEFINES := -D__KLIBC__ $(DEFINES) + +CFLAGS := $(CLFAGS) -nostdinc -Wmost -Werror \ + -fno-builtin -mpreferred-stack-boundary=2 \ + -fno-align-functions -fno-stack-protector \ + -march=pentium4 -msse2 -mfpmath=sse -msoft-float \ + -arch i386 -include $(SRCROOT)/autoconf.h + +CPPFLAGS := $(CPPFLAGS) -nostdinc++ -Wmost -Werror \ + -fno-builtin -mpreferred-stack-boundary=2 \ + -fno-align-functions -fno-stack-protector \ + -march=pentium4 -msse2 -mfpmath=sse -msoft-float \ + -arch i386 -include $(SRCROOT)/autoconf.h + MODULE_DEPENDENCIES := $(foreach x,$(MODULE_DEPENDENCIES),-weak_library $(SYMROOT)/modules/$(x).dylib) INSTALLDIR = $(DSTROOT)/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders/standalone -dylib: ${OBJROOT} ${MODULE_OBJS} dylib_final +dylib: ${SYMROOT}/modules/ ${OBJROOT} $(addprefix $(OBJROOT)/, ${MODULE_OBJS}) $(SYMROOT)/modules/$(MODULE_NAME).dylib -dylib_final: - @rm -rf $(SYMROOT)/$(MODULE_NAME).dylib #ensure module doesn't link with old version of self +$(SYMROOT)/modules/$(MODULE_NAME).dylib: @echo "\t[LD] $(MODULE_NAME).dylib" @ld -arch i386 \ @@ -36,26 +58,24 @@ @cp -rf include/* ../module_includes/ &> /dev/null || true -%.o: %.c - @echo "\t[CC] $<" - @$(CC) $(CPPFLAGS) $(CFLAGS) -I../include/ -Iinclude/ -I../module_includes/ -D__KLIBC__ $(DEFINES) -c "$<" $(INC) -o "$(OBJROOT)/$@" -%.o: %.cpp - @echo "\t[CPP] $<" - @$(CPP) $(CPPFLAGS) $(CFLAGS) -I../include/ -Iinclude/ -I../module_includes/ -D__KLIBC__ $(DEFINES) -c "$<" $(INC) -o "$(OBJROOT)/$@" - clean: + @echo "\t[RM] $(SYMROOT)/modules/$(MODULE_NAME).dylib" @echo "\t[RM] $(OBJROOT)" - @rm -rf ${OBJROOT} - @echo "\t[RM] $(SYMROOT)/modules/$(MODULE_NAME).dylib" + @echo "\t[RM] $(DSTROOT)" + @echo "\t[RM] $(SRCROOT)/revision" + @echo "\t[RM] $(SRCROOT)/i386/modules/module_includes" @rm -rf $(SYMROOT)/modules/$(MODULE_NAME).dylib &> /dev/null + @rm -rf $(OBJROOT) $(DSTROOT) $(SRCROOT)/revision $(SRCROOT)/i386/modules/module_includes + +${SYMROOT}/modules/: + @echo "\t[MKDIR] $@" + @$(MKDIRS) $@ -# dependencies +#dependencies #-include $(OBJROOT)/Makedep -include ../../MakeInc.dir - Index: branches/azimutz/Cleancut/i386/modules/NVIDIAGraphicsEnabler/Cconfig =================================================================== --- branches/azimutz/Cleancut/i386/modules/NVIDIAGraphicsEnabler/Cconfig (revision 0) +++ branches/azimutz/Cleancut/i386/modules/NVIDIAGraphicsEnabler/Cconfig (revision 885) @@ -0,0 +1,10 @@ +# +# Chameleon Modules +# + +config NVIDIAGRAPHICSENABLER_MODULE + tristate "NVIDIAGraphicsEnabler Module" + default m + ---help--- + Say Y here if you want to enable the use of this module. + Index: branches/azimutz/Cleancut/i386/modules/NVIDIAGraphicsEnabler/nvidia.c =================================================================== --- branches/azimutz/Cleancut/i386/modules/NVIDIAGraphicsEnabler/nvidia.c (revision 884) +++ branches/azimutz/Cleancut/i386/modules/NVIDIAGraphicsEnabler/nvidia.c (revision 885) @@ -48,6 +48,9 @@ * SOFTWARE. */ +#include "libsa.h" +#include "saio_internal.h" + #include "bootstruct.h" #include "pci.h" #include "platform.h" Index: branches/azimutz/Cleancut/i386/modules/klibc/Cconfig =================================================================== --- branches/azimutz/Cleancut/i386/modules/klibc/Cconfig (revision 0) +++ branches/azimutz/Cleancut/i386/modules/klibc/Cconfig (revision 885) @@ -0,0 +1,10 @@ +# +# Chameleon Modules +# + +config KLIBC_MODULE + tristate "klibc Module" + default m + ---help--- + Say Y here if you want to enable to use of this module. + Index: branches/azimutz/Cleancut/i386/modules/IntelGraphicsEnabler/gma.c =================================================================== --- branches/azimutz/Cleancut/i386/modules/IntelGraphicsEnabler/gma.c (revision 884) +++ branches/azimutz/Cleancut/i386/modules/IntelGraphicsEnabler/gma.c (revision 885) @@ -3,6 +3,9 @@ http://forum.voodooprojects.org/index.php/topic,1029.msg4427.html#msg4427 **/ +#include "libsa.h" +#include "saio_internal.h" + #include "bootstruct.h" #include "pci.h" #include "platform.h" @@ -21,24 +24,24 @@ uint8_t GMAX3100_vals[22][4] = { { 0x01,0x00,0x00,0x00 }, - { 0x01,0x00,0x00,0x00 }, - { 0x01,0x00,0x00,0x00 }, - { 0x00,0x00,0x00,0x08 }, + { 0x01,0x00,0x00,0x00 }, + { 0x01,0x00,0x00,0x00 }, + { 0x00,0x00,0x00,0x08 }, { 0x64,0x00,0x00,0x00 }, { 0x00,0x00,0x00,0x08 }, { 0x01,0x00,0x00,0x00 }, - { 0x20,0x00,0x00,0x00 }, - { 0x00,0x00,0x00,0x00 }, - { 0x01,0x00,0x00,0x00 }, - { 0x20,0x03,0x00,0x00 }, - { 0x00,0x00,0x00,0x00 }, - { 0x00,0x00,0x00,0x00 }, - { 0x00,0x00,0x00,0x00 }, - { 0x08,0x52,0x00,0x00 }, - { 0x00,0x00,0x00,0x00 }, - { 0x00,0x00,0x00,0x00 }, - { 0x01,0x00,0x00,0x00 }, - { 0x01,0x00,0x00,0x00 }, + { 0x20,0x00,0x00,0x00 }, + { 0x00,0x00,0x00,0x00 }, + { 0x01,0x00,0x00,0x00 }, + { 0x20,0x03,0x00,0x00 }, + { 0x00,0x00,0x00,0x00 }, + { 0x00,0x00,0x00,0x00 }, + { 0x00,0x00,0x00,0x00 }, + { 0x08,0x52,0x00,0x00 }, + { 0x00,0x00,0x00,0x00 }, + { 0x00,0x00,0x00,0x00 }, + { 0x01,0x00,0x00,0x00 }, + { 0x01,0x00,0x00,0x00 }, { 0x3B,0x00,0x00,0x00 }, { 0x00,0x00,0x00,0x00 } }; @@ -46,16 +49,16 @@ uint8_t reg_FALSE[] = { 0x00,0x00,0x00,0x00 }; static struct gma_gpu_t KnownGPUS[] = { - { 0x00000000, "Unknown" }, - { 0x808627A2, "Mobile GMA950" }, - { 0x808627AE, "Mobile GMA950" }, - { 0x808627A6, "Mobile GMA950" }, - { 0x80862772, "Desktop GMA950" }, //Azi: never worked with mine. - { 0x80862776, "Desktop GMA950" }, - { 0x80862A02, "GMAX3100" }, - { 0x80862A03, "GMAX3100" }, - { 0x80862A12, "GMAX3100" }, - { 0x80862A13, "GMAX3100" }, + { 0x00000000, "Unknown" }, + { 0x808627A2, "Mobile GMA950" }, + { 0x808627AE, "Mobile GMA950" }, + { 0x808627A6, "Mobile GMA950" }, + { 0x80862772, "Desktop GMA950" }, //Azi: never worked with mine. + { 0x80862776, "Desktop GMA950" }, + { 0x80862A02, "GMAX3100" }, + { 0x80862A03, "GMAX3100" }, + { 0x80862A12, "GMAX3100" }, + { 0x80862A13, "GMAX3100" } }; char *get_gma_model(uint32_t id) { Index: branches/azimutz/Cleancut/i386/modules/IntelGraphicsEnabler/Cconfig =================================================================== --- branches/azimutz/Cleancut/i386/modules/IntelGraphicsEnabler/Cconfig (revision 0) +++ branches/azimutz/Cleancut/i386/modules/IntelGraphicsEnabler/Cconfig (revision 885) @@ -0,0 +1,10 @@ +# +# Chameleon Modules +# + +config INTELGRAPHICSENABLER_MODULE + tristate "IntelGraphicsEnabler Module" + default m + ---help--- + Say Y here if you want to enable the use of this module. + Index: branches/azimutz/Cleancut/i386/modules/ATiGraphicsEnabler/Cconfig =================================================================== --- branches/azimutz/Cleancut/i386/modules/ATiGraphicsEnabler/Cconfig (revision 0) +++ branches/azimutz/Cleancut/i386/modules/ATiGraphicsEnabler/Cconfig (revision 885) @@ -0,0 +1,10 @@ +# +# Chameleon Modules +# + +config ATIGRAPHICSENABLER_MODULE + tristate "ATiGraphicsEnabler Module" + default m + ---help--- + Say Y here if you want to enable the use of this module. + Index: branches/azimutz/Cleancut/i386/modules/ATiGraphicsEnabler/Makefile =================================================================== --- branches/azimutz/Cleancut/i386/modules/ATiGraphicsEnabler/Makefile (revision 884) +++ branches/azimutz/Cleancut/i386/modules/ATiGraphicsEnabler/Makefile (revision 885) @@ -4,7 +4,7 @@ MODULE_START = _$(MODULE_NAME)_start MODULE_DEPENDENCIES = -DIR = Enabler/ATiGraphicsEnabler +DIR = ATiGraphicsEnabler MODULE_OBJS = ati.o ATiGraphicsEnabler.o Index: branches/azimutz/Cleancut/i386/modules/ATiGraphicsEnabler/ati.c =================================================================== --- branches/azimutz/Cleancut/i386/modules/ATiGraphicsEnabler/ati.c (revision 884) +++ branches/azimutz/Cleancut/i386/modules/ATiGraphicsEnabler/ati.c (revision 885) @@ -20,6 +20,9 @@ * Alternatively you can choose to comply with APSL */ +#include "libsa.h" +#include "saio_internal.h" + #include "bootstruct.h" #include "pci.h" #include "platform.h" Index: branches/azimutz/Cleancut/i386/modules/uClibc++/Cconfig =================================================================== --- branches/azimutz/Cleancut/i386/modules/uClibc++/Cconfig (revision 0) +++ branches/azimutz/Cleancut/i386/modules/uClibc++/Cconfig (revision 885) @@ -0,0 +1,11 @@ +# +# Chameleon Modules +# + +config UCLIBCXX_MODULE + tristate "uClibc++ Module" + default m + depends on KLIBC_MODULE + ---help--- + Say Y here if you want to enable to use of this module. + Index: branches/azimutz/Cleancut/i386/modules/Cconfig =================================================================== --- branches/azimutz/Cleancut/i386/modules/Cconfig (revision 0) +++ branches/azimutz/Cleancut/i386/modules/Cconfig (revision 885) @@ -0,0 +1,14 @@ +# +# Chameleon Modules +# + +menu "Modules" +source "i386/modules/Resolution/Cconfig" +source "i386/modules/klibc/Cconfig" +source "i386/modules/uClibc++/Cconfig" +source "i386/modules/HelloWorld/Cconfig" +source "i386/modules/AMDGraphicsEnabler/Cconfig" +source "i386/modules/ATiGraphicsEnabler/Cconfig" +source "i386/modules/IntelGraphicsEnabler/Cconfig" +source "i386/modules/NVIDIAGraphicsEnabler/Cconfig" +endmenu \ No newline at end of file Index: branches/azimutz/Cleancut/i386/modules/AMDGraphicsEnabler/Cconfig =================================================================== --- branches/azimutz/Cleancut/i386/modules/AMDGraphicsEnabler/Cconfig (revision 0) +++ branches/azimutz/Cleancut/i386/modules/AMDGraphicsEnabler/Cconfig (revision 885) @@ -0,0 +1,10 @@ +# +# Chameleon Modules +# + +config AMDGRAPHICSENABLER_MODULE + tristate "AMDGraphicsEnabler Module" + default m + ---help--- + Say Y here if you want to enable the use of this module. + Index: branches/azimutz/Cleancut/i386/modules/AMDGraphicsEnabler/ati.c =================================================================== --- branches/azimutz/Cleancut/i386/modules/AMDGraphicsEnabler/ati.c (revision 884) +++ branches/azimutz/Cleancut/i386/modules/AMDGraphicsEnabler/ati.c (revision 885) @@ -5,6 +5,9 @@ * */ +#include "libsa.h" +#include "saio_internal.h" + #include "bootstruct.h" #include "pci.h" #include "platform.h" @@ -456,7 +459,6 @@ { 0x9443, 0x00000000, CHIP_FAMILY_RV770, "ATI Radeon HD 4850 X2", kMotmot }, { 0x944C, 0x00000000, CHIP_FAMILY_RV770, "ATI Radeon HD 4800 Series", kMotmot }, { 0x944E, 0x00000000, CHIP_FAMILY_RV770, "ATI Radeon HD 4700 Series", kMotmot }, - { 0x944E, 0x00000000, CHIP_FAMILY_RV770, "ATI Radeon HD 4700 Series", kMotmot }, { 0x9450, 0x00000000, CHIP_FAMILY_RV770, "AMD FireStream 9270", kMotmot }, { 0x9452, 0x00000000, CHIP_FAMILY_RV770, "AMD FireStream 9250", kMotmot }, { 0x9460, 0x00000000, CHIP_FAMILY_RV770, "ATI Radeon HD 4800 Series", kMotmot }, Index: branches/azimutz/Cleancut/i386/modules/HelloWorld/Cconfig =================================================================== --- branches/azimutz/Cleancut/i386/modules/HelloWorld/Cconfig (revision 0) +++ branches/azimutz/Cleancut/i386/modules/HelloWorld/Cconfig (revision 885) @@ -0,0 +1,11 @@ +# +# Chameleon Modules +# + +config HELLOWORLD_MODULE + tristate "HelloWorld Module" + default n + depends on UCLIBCXX_MODULE + ---help--- + Say Y here if you want to enable to use of this module. + Index: branches/azimutz/Cleancut/i386/modules/Makefile =================================================================== --- branches/azimutz/Cleancut/i386/modules/Makefile (revision 884) +++ branches/azimutz/Cleancut/i386/modules/Makefile (revision 885) @@ -1,36 +1,29 @@ # Makefile for i386 modules +SRCROOT = $(shell pwd)/../../ +OBJROOT = $(SRCROOT)/obj/i386/modules/ +SYMROOT = $(SRCROOT)/sym/i386 +DSTROOT = $(SRCROOT)/dst/i386 +DOCROOT = $(SRCROOT)/doc +IMGROOT = $(SRCROOT)/sym/cache +IMGSKELROOT = $(SRCROOT)/imgskel +CDBOOT = ${IMGROOT}/usr/standalone/i386/cdboot +include ${SRCROOT}/Make.rules + # The order of building is important. SUBDIRS = klibc uClibc++ Resolution \ ATiGraphicsEnabler AMDGraphicsEnabler NVIDIAGraphicsEnabler IntelGraphicsEnabler -#SUBDIRS = klibc uClibc++ Resolution HelloWorld -CFLAGS= -O $(MORECPP) -arch i386 -g -static +CFLAGS= -O3 $(MORECPP) -arch i386 -g -static DEFINES= CONFIG = hd -LIBDIR = libsa -INC = -I. -I$(LIBDIR) -ifneq "" "$(wildcard /bin/mkdirs)" - MKDIRS = /bin/mkdirs -else - MKDIRS = /bin/mkdir -p -endif -AS = as -LD = ld +LIBSAIODIR = $(SRCROOT)/i386/libsaio +INC = -I$(LIBSAIODIR) -# -# these paths are only valid in subdirectories of this directory -# -OBJROOT=`pwd`/../../obj/i386/modules/ -SYMROOT=`pwd`/../../sym/i386/modules/ -DSTROOT=`pwd`/../../dst/i386/modules/ -SRCROOT=/tmp -VPATH = $(OBJROOT):$(SYMROOT) - - -all embedtheme optionrom tags debug install installhdrs: objroot_dirs +ifeq (${CONFIG_MODULES}, y) +all install: $(SYMROOT) $(OBJROOT) objroot_dirs @for i in ${SUBDIRS}; \ do \ echo ================= make $@ for $$i =================; \ @@ -45,12 +38,13 @@ "RC_CFLAGS=$(RC_CFLAGS)" $@ \ ) || exit $$?; \ done +else +all: +endif +.PHONY: objroot_dirs objroot_dirs: @rm -rf module_includes @mkdir module_includes @rm -rf "$(SYMROOT)/modules/" - @mkdir "$(SYMROOT)/modules/" - -installsrc: - tar cf - . | (cd ${SRCROOT}; tar xfBp -) + @mkdir "$(SYMROOT)/modules/" \ No newline at end of file Index: branches/azimutz/Cleancut/i386/cdboot/Makefile =================================================================== --- branches/azimutz/Cleancut/i386/cdboot/Makefile (revision 884) +++ branches/azimutz/Cleancut/i386/cdboot/Makefile (revision 885) @@ -1,15 +1,21 @@ - +SRCROOT = $(shell pwd)/../../ +OBJROOT = $(SRCROOT)/obj/i386/cdboot +SYMROOT = $(SRCROOT)/sym/i386 +DSTROOT = $(SRCROOT)/dst/i386 +DOCROOT = $(SRCROOT)/doc +IMGROOT = $(SRCROOT)/sym/cache +IMGSKELROOT = $(SRCROOT)/imgskel +CDBOOT = ${IMGROOT}/usr/standalone/i386/cdboot + DIR = cdboot -include ../MakePaths.dir +include ${SRCROOT}/Make.rules -NASM = $(shell which nasm) -#/Developer/usr/bin/nasm INSTALLDIR = $(DSTROOT)/usr/standalone/i386 DIRS_NEEDED = $(SYMROOT) -all embedtheme optionrom: $(DIRS_NEEDED) cdboot +all embedtheme optionrom: $(DIRS_NEEDED) $(SYMROOT)/cdboot -cdboot: cdboot.s $(SYMROOT)/boot Makefile $(NASM) +$(SYMROOT)/cdboot: @echo "\t[NASM] cdboot.s" @$(NASM) cdboot.s -o $(SYMROOT)/cdboot @dd if=$(SYMROOT)/boot of=$(SYMROOT)/cdboot conv=sync bs=2k seek=1 &> /dev/null @@ -19,10 +25,4 @@ | perl -ane "print pack('V',@F[0]);" \ | dd of=$(SYMROOT)/cdboot bs=1 count=4 seek=2044 conv=notrunc &> /dev/null -install_i386:: all $(INSTALLDIR) - cp $(SYMROOT)/cdboot $(INSTALLDIR) - cd $(INSTALLDIR); chmod u+w cdboot - -include ../MakeInc.dir - #dependencies Index: branches/azimutz/Cleancut/i386/libsa/Cconfig =================================================================== --- branches/azimutz/Cleancut/i386/libsa/Cconfig (revision 0) +++ branches/azimutz/Cleancut/i386/libsa/Cconfig (revision 885) @@ -0,0 +1 @@ + Index: branches/azimutz/Cleancut/i386/libsa/Makefile =================================================================== --- branches/azimutz/Cleancut/i386/libsa/Makefile (revision 884) +++ branches/azimutz/Cleancut/i386/libsa/Makefile (revision 885) @@ -1,64 +1,46 @@ +SRCROOT = $(shell pwd)/../../ +OBJROOT = $(SRCROOT)/obj/i386/libsa +SYMROOT = $(SRCROOT)/sym/i386 +DSTROOT = $(SRCROOT)/dst/i386 +DOCROOT = $(SRCROOT)/doc +IMGROOT = $(SRCROOT)/sym/cache +IMGSKELROOT = $(SRCROOT)/imgskel +CDBOOT = ${IMGROOT}/usr/standalone/i386/cdboot DIR = libsa -include ../MakePaths.dir +include ${SRCROOT}/Make.rules -UTILDIR = ../util LIBSAIODIR = ../libsaio -INSTALL_SA_DIR = $(DSTROOT)/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders/standalone -INSTALL_MD_DIR = $(DSTROOT)/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders/machdep/i386 -OPTIM = -Os -Oz -CFLAGS = $(RC_CFLAGS) $(OPTIM) $(MORECPP) -arch i386 -g -Wmost -Werror \ +CFLAGS := $(CFLAGS) $(RC_CFLAGS) $(MORECPP) -arch i386 \ -fno-builtin -static $(OMIT_FRAME_POINTER_CFLAG) \ -mpreferred-stack-boundary=2 -fno-align-functions -fno-stack-protector \ - -march=pentium4 -msse2 -mfpmath=sse -msoft-float + -march=pentium4 -msse2 -mfpmath=sse -msoft-float \ + -nostdinc -include $(SRCROOT)/autoconf.h + +CPPFLAGS := $(CPPFLAGS) -nostdinc++ -INC = -I. -I$(SYMROOT) -I$(UTILDIR) -I$(LIBSAIODIR) -ifneq "" "$(wildcard /bin/mkdirs)" - MKDIRS = /bin/mkdirs -else - MKDIRS = /bin/mkdir -p -endif -AS = as -LD = ld -# LIBS= -lc_static -LIBS= +INC = -I. -I$(SYMROOT) -I$(LIBSAIODIR) -I${SRCROOT}/i386/include -VPATH = $(OBJROOT):$(SYMROOT) - SA_OBJS = prf.o printf.o zalloc.o \ string.o strtol.o error.o \ setjmp.o qsort.o efi_tables.o -SFILES = setjmp.s -CFILES = prf.c printf.c zalloc.c \ - string.c strtol.c error.c \ - qsort.c efi_tables.c -HFILES = memory.h -EXPORTED_HFILES = libsa.h memory.h -INSTALLED_SA_HFILES = libsa.h -OTHERFILES = Makefile -ALLSRC = $(SFILES) $(CFILES) $(HFILES) $(OTHERFILES) LIBS = libsa.a +LIBS := $(addprefix $(SYMROOT)/, $(LIBS)) + DIRS_NEEDED = $(OBJROOT) $(SYMROOT) all embedtheme: $(DIRS_NEEDED) $(LIBS) -libsa.a: $(SA_OBJS) - @echo "\t[RM] $(SYMROOT)/$(@F)" - @rm -f $(SYMROOT)/$(@F) - @echo "\t[AR] $@" - @ar q $(SYMROOT)/$(@F) $^ &> /dev/null - @echo "\t[RANLIB] $@" - @ranlib $(SYMROOT)/$(@F) -$(INSTALL_SA_DIR) $(INSTALL_MD_DIR): - $(MKDIRS) $@ +$(LIBS): $(addprefix $(OBJROOT)/, $(SA_OBJS)) + @echo "\t[RM] $@" + @rm -f $@ + @echo "\t[AR] $(@F)" + @ar q $@ $^ &> /dev/null + @echo "\t[RANLIB] $(@F)" + @ranlib $@ -installhdrs:: $(INSTALL_SA_DIR) $(INSTALL_MD_DIR) - cp $(INSTALLED_SA_HFILES) $(INSTALL_SA_DIR) - -include ../MakeInc.dir - # dependencies -include $(OBJROOT)/Makedep Index: branches/azimutz/Cleancut/i386/Makefile =================================================================== --- branches/azimutz/Cleancut/i386/Makefile (revision 884) +++ branches/azimutz/Cleancut/i386/Makefile (revision 885) @@ -1,34 +1,27 @@ - # Makefile for i386 boot program # define FLOPPY and SMALL using DEFINES macro as necessary -CFLAGS = -O $(MORECPP) -arch i386 -g -static -DEFINES= -CONFIG = hd -LIBDIR = libsa -INC = -I. -I$(LIBDIR) -ifneq "" "$(wildcard /bin/mkdirs)" - MKDIRS = /bin/mkdirs -else - MKDIRS = /bin/mkdir -p -endif -AS = as -LD = ld - # # these paths are only valid in subdirectories of this directory # -OBJROOT=`pwd`/../../obj/i386 -SYMROOT=`pwd`/../../sym/i386 -DSTROOT=`pwd`/../../dst/i386 -SRCROOT=/tmp +SRCROOT = $(shell pwd)/../ +OBJROOT = $(SRCROOT)/obj/i386 +SYMROOT = $(SRCROOT)/sym/i386 +DSTROOT = $(SRCROOT)/dst/i386 +DOCROOT = $(SRCROOT)/doc +IMGROOT = $(SRCROOT)/sym/cache +IMGSKELROOT = $(SRCROOT)/imgskel +CDBOOT = ${IMGROOT}/usr/standalone/i386/cdboot +include ${SRCROOT}/Make.rules + + VPATH = $(OBJROOT):$(SYMROOT) # The order of building is important. -SUBDIRS = util libsa libsaio boot2 boot1 boot0 cdboot modules +SUBDIRS = util libsa libsaio boot0 boot1 boot2 cdboot modules -all embedtheme tags debug install installhdrs: +all: @for i in ${SUBDIRS}; \ do \ echo ================= make $@ for $$i =================; \ @@ -43,6 +36,22 @@ "RC_CFLAGS=$(RC_CFLAGS)" $@ \ ) || exit $$?; \ done + +config: + @for i in config; \ + do \ + echo ================= make $@ for $$i =================; \ + ( cd $$i; ${MAKE} \ + "OBJROOT=$(OBJROOT)/$$i" \ + "SYMROOT=$(SYMROOT)" \ + "DSTROOT=$(DSTROOT)" \ + "SRCROOT=$(SRCROOT)" \ + "RC_ARCHS=$(RC_ARCHS)" \ + "RC_KANJI=$(RC_KANJI)" \ + "JAPANESE=$(JAPANESE)" \ + "RC_CFLAGS=$(RC_CFLAGS)" $@ \ + ) || exit $$?; \ + done -installsrc: - tar cf - . | (cd ${SRCROOT}; tar xfBp -) + +.PHONY: config \ No newline at end of file Index: branches/azimutz/Cleancut/i386/util/Cconfig =================================================================== --- branches/azimutz/Cleancut/i386/util/Cconfig (revision 0) +++ branches/azimutz/Cleancut/i386/util/Cconfig (revision 885) @@ -0,0 +1,8 @@ +config BDMESG + bool "bdmesg utility" + default y + help + Say Y here if you want to compile the bdmesg utility. + bdmesg is used to dump any messages thrown during the + chameleon boot sequence. + When in doubt, say "Y". Index: branches/azimutz/Cleancut/i386/util/Makefile =================================================================== --- branches/azimutz/Cleancut/i386/util/Makefile (revision 884) +++ branches/azimutz/Cleancut/i386/util/Makefile (revision 885) @@ -3,62 +3,44 @@ # we'll just keep the generated files in this directory # and install them directly, rather than generating them again. # +SRCROOT = $(shell pwd)/../../ +OBJROOT = $(SRCROOT)/obj/i386 +SYMROOT = $(SRCROOT)/sym/i386 +DSTROOT = $(SRCROOT)/dst/i386 +DOCROOT = $(SRCROOT)/doc +IMGROOT = $(SRCROOT)/sym/cache +IMGSKELROOT = $(SRCROOT)/imgskel +CDBOOT = ${IMGROOT}/usr/standalone/i386/cdboot + DIR = util -include ../MakePaths.dir +include ${SRCROOT}/Make.rules -VPATH = $(OBJROOT):$(SYMROOT) +PROGRAMS = machOconv dyldsymboltool +OBJECTS = dyldsymboltool.o32 dyldsymboltool.o64 machOconv.o32 machOconv.o64 -INSTALLDIR = $(DSTROOT)/usr/standalone/i386 -LOCALBIN = $(DSTROOT)/usr/local/bin -OPTIM = -Os -Oz -CFLAGS = $(RC_CFLAGS) $(OPTIM) -Wmost -Werror -g -LDFLAGS = -CFILES = machOconv.c -ALLSRC = $(CFILES) $(MFILES) $(HFILES) $(EXPORT_HFILES) +ifeq (${CONFIG_BDMESG}, y) +PROGRAMS += bdmesg +OBJECTS += bdmesg.o32 bdmesg.o64 +endif -PROGRAMS = machOconv bdmesg dyldsymboltool +LDFLAGS := $(LDFALGS) -framework IOKit -framework CoreFoundation -mmacosx-version-min=10.5 -OUTFILES = $(PROGRAMS) +SYMPROG = $(addprefix $(SYMROOT)/, $(PROGRAMS)) -DIRS_NEEDED = $(OBJROOT) $(SYMROOT) $(LANGDIR) +DIRS_NEEDED = $(OBJROOT) $(SYMROOT) -all embedtheme: $(DIRS_NEEDED) $(PROGRAMS) +all: $(DIRS_NEEDED) $(SYMPROG) -dyldsymboltool: dyldsymboltool.o32 dyldsymboltool.o64 - @echo "\t[LD32] $@_32" +$(SYMPROG): $(addprefix $(OBJROOT)/, $(OBJECTS)) + @echo "\t[LD32] $(@F)_32" @$(CC) $(CFLAGS) $(LDFLAGS) $(DEFINES) -arch i386 -o $(SYMROOT)/$(@F)_32 $(OBJROOT)/$(@F).o32 - @echo "\t[LD64] $@_64" + @echo "\t[LD64] $(@F)_64" @$(CC) $(CFLAGS) $(LDFLAGS) $(DEFINES) -arch x86_64 -o $(SYMROOT)/$(@F)_64 $(OBJROOT)/$(@F).o64 - @echo "\t[LIPO] $@" + @echo "\t[LIPO] $(@F)" @lipo -create -arch i386 $(SYMROOT)/$(@F)_32 -arch x86_64 $(SYMROOT)/$(@F)_64 -output $(SYMROOT)/$(@F) @$(RM) $(SYMROOT)/$(@F)_32 $(SYMROOT)/$(@F)_64 - -machOconv: machOconv.o32 machOconv.o64 - @echo "\t[LD32] $@_32" - @$(CC) $(CFLAGS) $(LDFLAGS) $(DEFINES) -arch i386 -o $(SYMROOT)/$(@F)_32 $(OBJROOT)/$(@F).o32 - @echo "\t[LD64] $@_64" - @$(CC) $(CFLAGS) $(LDFLAGS) $(DEFINES) -arch x86_64 -o $(SYMROOT)/$(@F)_64 $(OBJROOT)/$(@F).o64 - @echo "\t[LIPO] $@" - @lipo -create -arch i386 $(SYMROOT)/$(@F)_32 -arch x86_64 $(SYMROOT)/$(@F)_64 -output $(SYMROOT)/$(@F) - @$(RM) $(SYMROOT)/$(@F)_32 $(SYMROOT)/$(@F)_64 - - -bdmesg: bdmesg.o32 bdmesg.o64 - @echo "\t[LD32] $@_32" - @$(CC) $(CFLAGS) $(LDFLAGS) -framework IOKit -framework CoreFoundation -mmacosx-version-min=10.5 \ - -arch i386 -o $(SYMROOT)/$(@F)_32 $(OBJROOT)/$(@F).o32 - @echo "\t[LD64] $@_64" - @$(CC) $(CFLAGS) $(LDFLAGS) -framework IOKit -framework CoreFoundation -mmacosx-version-min=10.5 \ - -arch x86_64 -o $(SYMROOT)/$(@F)_64 $(OBJROOT)/$(@F).o64 - @echo "\t[LIPO] $@" - @lipo -create -arch i386 $(SYMROOT)/$(@F)_32 -arch x86_64 $(SYMROOT)/$(@F)_64 -output $(SYMROOT)/$(@F) - @$(RM) $(SYMROOT)/$(@F)_32 $(SYMROOT)/$(@F)_64 - - -include ../MakeInc.dir - #dependencies -include $(OBJROOT)/Makedep \ No newline at end of file Index: branches/azimutz/Cleancut/TODO =================================================================== --- branches/azimutz/Cleancut/TODO (revision 884) +++ branches/azimutz/Cleancut/TODO (revision 885) @@ -1,5 +1,6 @@ TODO List for Chameleon Boot Loader ==================================== +- Setup makefile to use module config for determining which modules to compile in and which to compile as modules - Fix the module system when booting chameleon with multiboot. Cleanup the xcode 4 fix. - Integrate Prasys current work on options and quick shortcut modified version of 18seven Index: branches/azimutz/Cleancut/Make.rules =================================================================== --- branches/azimutz/Cleancut/Make.rules (revision 0) +++ branches/azimutz/Cleancut/Make.rules (revision 885) @@ -0,0 +1,125 @@ +-include $(SRCROOT)/auto.conf + +export USE_APPLE_PB_SUPPORT = all + + +ifneq "" "$(wildcard /bin/mkdirs)" + MKDIRS = /bin/mkdirs +else + MKDIRS = /bin/mkdir -p +endif +AS = as +LD = ld +CC = cc +CPP = g++ +PAX = /bin/pax +NASM = $(shell which nasm) -p $(SRCROOT)/autoconf.inc + + +# CFLAGS = -O $(MORECPP) -arch i386 -g +CFLAGS = $(CONFIG_OPTIMIZATION_LEVEL) $(MORECPP) -g -Wmost -Werror +CPPFLAGS = -fno-exceptions -fno-rtti +DEFINES= + +CONFIG = hd +#LIBDIR = libsa +#INC = -I. -I$(LIBDIR) + + + + +# +# Common makefile targets. +# +# Define these variables (if desired) in directory makefiles: +# DIRS_NEEDED +# INSTALLDIR +# SRCROOT +# + +# Toggle this as to whether you want a frame pointer (%ebp) to be used. It is +# invaluable for debugging the booter. For example using GDB attached to VMware. +# In fact, it's so invaluable that it's now the default. Not only that but the +# compiler seems to generate slightly smaller code and the real<->prot code +# clearly handles it appropriately so I have no idea why Apple omitted it. +#OMIT_FRAME_POINTER_CFLAG=-fomit-frame-pointer +OMIT_FRAME_POINTER_CFLAG= + + +$(OBJROOT)/%.o: %.c + @echo "\t[CC] $<" + @$(CC) $(CFLAGS) $(DEFINES) -c $(INC) $< -o $@ \ + -MD -dependency-file $(OBJROOT)/$*.d + @md -u $(OBJROOT)/Makedep -f -d $(OBJROOT)/$*.d + +$(OBJROOT)/%.o32: %.c + @echo "\t[CC32] $<" + @$(CC) $(CFLAGS) $(DEFINES) -c $(INC) -arch i386 $< -o $@ \ + -MD -dependency-file $(OBJROOT)/$*.d + @md -u $(OBJROOT)/Makedep -f -d $(OBJROOT)/$*.d + +$(OBJROOT)/%.o64: %.c + @echo "\t[CC64] $<" + @$(CC) $(CFLAGS) $(DEFINES) -c $(INC) -arch x86_64 $< -o $@ \ + -MD -dependency-file $(OBJROOT)/$*.d + @md -u $(OBJROOT)/Makedep -f -d $(OBJROOT)/$*.d + +$(OBJROOT)/%.o: %.m + @echo "\t[M] $<" + @$(CC) $(CFLAGS) $(DEFINES) -c $(INC) $< -o $@ \ + -MD -dependency-file $(OBJROOT)/$*.d + @md -u $(OBJROOT)/Makedep -f -d $(OBJROOT)/$*.d + +$(OBJROOT)/%.o: %.cpp + @echo "\t[CPP] $<" + @$(CPP) $(CPPFLAGS) $(CFLAGS) -c "$<" $(INC) -o $@ \ + -MD -dependency-file $(OBJROOT)/$*.d + @md -u $(OBJROOT)/Makedep -f -d $(OBJROOT)/$*.d + + +#$(OBJROOT)/.s.o: +# @echo "\t[AS] $<" +# @cc $(CPPFLAGS) -c $(INC) -arch i386 -o $(OBJROOT)/$(@F) $< + +# This breaks make, must use make all (FIXME) +$(OBJROOT)/boot2.o: + @echo "\t[AS] boot2.s" + @cc $(CPPFLAGS) -Wa,-n -c $(INC) -arch i386 -o $(OBJROOT)/$(@F) boot2.s \ + -MD -dependency-file $*.d + @md -u $(OBJROOT)/Makedep -f -d $*.d + + +$(OBJROOT)/%.o: %.s + @echo "\t[AS] $<" + @$(CC) $(CPPFLAGS) -c $(INC) -arch i386 -o $@ $< \ + -MD -dependency-file $*.d + @md -u $(OBJROOT)/Makedep -f -d $*.d + + + +# This breaks make, must use make all (FIXME) +$(DIRS_NEEDED) $(INSTALLDIR) $(OBJROOT) $(SYMROOT): + @echo "\t[MKDIR] $@" + @$(MKDIRS) $@ + +$(SRCROOT)/auto.conf $(SRCROOT)/autoconf.h $(SRCROOT)/.config: + @echo "\t[MAKE] config" + @cd $(SRCROOT) && make config + +.PHONY: clean +clean: + @echo "\t[RM] $(OBJROOT)" + @echo "\t[RM] $(SYMROOT)" + @echo "\t[RM] $(DSTROOT)" + @echo "\t[RM] $(SRCROOT)/revision" + @echo "\t[RM] $(SRCROOT)/i386/modules/module_includes" + @echo "\t[RM] $(SRCROOT)/auto.conf" + @echo "\t[RM] $(SRCROOT)/autoconf.h" + @echo "\t[RM] $(SRCROOT)/autoconf.inc" + + @rm -rf $(OBJROOT) $(SYMROOT) $(DSTROOT) $(SRCROOT)/revision \ + $(SRCROOT)/i386/modules/module_includes \ + $(SRCROOT)/auto.conf \ + $(SRCROOT)/autoconf.h \ + $(SRCROOT)/autoconf.inc + Index: branches/azimutz/Cleancut/CHANGES =================================================================== --- branches/azimutz/Cleancut/CHANGES (revision 884) +++ branches/azimutz/Cleancut/CHANGES (revision 885) @@ -1,4 +1,5 @@ -- Added the BOOT2_MAX_LENGTH constant in memory.h. This is now used in moot.c to relocate the correct number of bytes for boot2. +- New makefile + configuration system. +- Added the BOOT2_MAX_LENGTH constant in memory.h. This is now used in mboot.c to relocate the correct number of bytes for boot2. - Added new ATi/AMD Graphics Card Enabler. - Added new SMBIOS patcher. - Added module system. Index: branches/azimutz/Cleancut/Cconfig =================================================================== --- branches/azimutz/Cleancut/Cconfig (revision 0) +++ branches/azimutz/Cleancut/Cconfig (revision 885) @@ -0,0 +1,6 @@ +# +# Chameleon Configuration +# +mainmenu "Chameleon Configuration" + +source "i386/Cconfig" Index: branches/azimutz/Cleancut/Makefile =================================================================== --- branches/azimutz/Cleancut/Makefile (revision 884) +++ branches/azimutz/Cleancut/Makefile (revision 885) @@ -1,30 +1,17 @@ -export USE_APPLE_PB_SUPPORT = all - # Makefile for kernel booter +SRCROOT = $(shell pwd) +OBJROOT = $(SRCROOT)/obj +SYMROOT = $(SRCROOT)/sym +DSTROOT = $(SRCROOT)/dst +DOCROOT = $(SRCROOT)/doc +IMGROOT = $(SRCROOT)/sym/cache +IMGSKELROOT = $(SRCROOT)/imgskel +CDBOOT = ${IMGROOT}/usr/standalone/i386/cdboot -# CFLAGS = -O $(MORECPP) -arch i386 -g -DEFINES= -CONFIG = hd -LIBDIR = libsa -INC = -I. -I$(LIBDIR) -ifneq "" "$(wildcard /bin/mkdirs)" - MKDIRS = /bin/mkdirs -else - MKDIRS = /bin/mkdir -p -endif -AS = as -LD = ld -PAX = /bin/pax -OBJROOT = `pwd`/obj -SYMROOT = `pwd`/sym -DSTROOT = `pwd`/dst -SRCROOT = /tmp -DOCROOT = `pwd`/doc -IMGROOT = `pwd`/sym/cache -IMGSKELROOT = `pwd`/imgskel -CDBOOT = ${IMGROOT}/usr/standalone/i386/cdboot +include Make.rules + THEME = default VERSION = `cat version` @@ -38,15 +25,32 @@ ARCHLESS_RC_CFLAGS=`echo $(RC_CFLAGS) | sed 's/-arch [a-z0-9]*//g'` -VPATH = $(OBJROOT):$(SYMROOT) - GENERIC_SUBDIRS = # # Currently builds for i386 # +clean config: + @if [ -e ".svn" ]; then svnversion -n | tr -d [:alpha:] > revision; fi + @echo ================= make config for i386 =================; + @( OBJROOT=$(OBJROOT)/i386; \ + SYMROOT=$(SYMROOT)/i386; \ + DSTROOT=$(DSTROOT); \ + SRCROOT=$(SRCROOT); \ + cd i386; ${MAKE} \ + "OBJROOT=$$OBJROOT" \ + "SYMROOT=$$SYMROOT" \ + "DSTROOT=$$DSTROOT" \ + "SRCROOT=$$SRCROOT" \ + "RC_ARCHS=$$RC_ARCHS" \ + "TARGET=$$i" \ + "RC_KANJI=$(RC_KANJI)" \ + "JAPANESE=$(JAPANESE)" \ + "RC_CFLAGS=$$XCFLAGS" $@ \ + ) || exit $$?; \ + -all embedtheme tags debug install installhdrs: $(SYMROOT) $(OBJROOT) +all: $(SYMROOT) $(OBJROOT) $(SRCROOT)/auto.conf $(SRCROOT)/autoconf.h $(SRCROOT)/autoconf.inc $(SRCROOT)/.config @if [ -e ".svn" ]; then svnversion -n | tr -d [:alpha:] > revision; fi @if [ -z "$(RC_ARCHS)" ]; then \ RC_ARCHS="i386"; \ @@ -59,6 +63,7 @@ ( OBJROOT=$(OBJROOT)/$${i}; \ SYMROOT=$(SYMROOT)/$${i}; \ DSTROOT=$(DSTROOT); \ + SRCROOT=$(SRCROOT); \ XCFLAGS=$(ARCHLESS_RC_CFLAGS); \ GENSUBDIRS="$(GENERIC_SUBDIRS)"; \ for x in $$GENSUBDIRS; \ @@ -68,7 +73,6 @@ break; \ fi \ done; \ - echo "$$OBJROOT $$SYMROOT $$DSTROOT"; \ cd $$i; ${MAKE} \ "OBJROOT=$$OBJROOT" \ "SYMROOT=$$SYMROOT" \ @@ -85,45 +89,8 @@ fi; \ done -image: - @if [ -e "$(SYMROOT)" ]; then \ - rm -r -f ${IMGROOT}; \ - mkdir -p ${IMGROOT}/usr/standalone/i386; \ - if [ -e "$(IMGSKELROOT)" ]; then \ - cp -R -f "${IMGSKELROOT}"/* "${IMGROOT}"; \ - fi; \ - cp -f ${SYMROOT}/i386/cdboot ${CDBOOT}; \ - cp -f ${SYMROOT}/i386/boot ${IMGROOT}/usr/standalone/i386; \ - cp -f ${SYMROOT}/i386/boot0 ${IMGROOT}/usr/standalone/i386; \ - cp -f ${SYMROOT}/i386/boot1h ${IMGROOT}/usr/standalone/i386; \ - cp -f ${SYMROOT}/i386/boot1f32 ${IMGROOT}/usr/standalone/i386;\ - $(shell hdiutil makehybrid -iso -joliet -hfs -hfs-volume-name \ - ${CDLABEL} -eltorito-boot ${CDBOOT} -no-emul-boot -ov -o \ - "${ISOIMAGE}" ${IMGROOT} -quiet) \ - fi; -pkg installer: embedtheme - @if [ -e "$(SYMROOT)" ]; then \ - sudo `pwd`/package/buildpkg `pwd`/sym/package; \ - fi; -release: $(SYMROOT) - @if [ -e ".svn" ]; then svnversion -n | tr -d [:alpha:] > revision; fi - @if [ -e "$(SYMROOT)" ]; then \ - sudo `pwd`/package/buildpkg `pwd`/sym/package; \ - fi; - @tar -czf $(SYMROOT)/$(PRODUCT)-src.tar.gz ${EXCLUDE} . - @tar -cjf $(SYMROOT)/$(PRODUCT)-src.tar.bz2 ${EXCLUDE} . - -clean: - rm -rf sym obj dst revision i386/modules/module_includes - -#distclean: clean -# @rm -f $(SYMROOT)/$(PRODUCT)-src.* -# @rm -f $(SYMROOT)/$(PRODUCT).pkg - -installsrc: - gnutar cf - . | (cd ${SRCROOT}; gnutar xpf -) - -$(SYMROOT) $(OBJROOT) $(DSTROOT): - @$(MKDIRS) $@ +.PHONY: config +.PHONY: clean +.DEFAULT_GOAL := all Property changes on: branches/azimutz/Cleancut ___________________________________________________________________ Modified: svn:ignore - obj sym revision build + obj sym revision build .config .config.old auto.conf autoconf.h autoconf.inc Modified: svn:mergeinfo Merged /trunk:r839-884