Easy Harvard Referencing For Os X



Browse the latest free online courses from Harvard University, including 'CS50's Introduction to Game Development' and 'CS50's Web Programming with Python and JavaScript.'

The I/O Kit is a collection of system frameworks, libraries, tools, and other resources for creating device drivers in OS X. It is based on an object-oriented programming model implemented in a restricted form of C++ that omits features unsuitable for use within a multithreaded kernel. By modeling the hardware connected to an OS X system and abstracting common functionality for devices in particular categories, the I/O Kit streamlines the process of device-driver development.

  • Starting from 10.12, OS X was rebranded as 'macOS', with the OS itself also referencing all versions before 10.12 as 'macOS'. If someone is free and willing, please feel free to perform the page move and replace all instances of the old name in the article. Chenzw Talk 09:00, 9 October 2016 (UTC).
  • In addition, code reusability decreases the memory footprint of drivers; drivers ported from Mac OS 9, for example, have been up to 75% smaller in OS X. Design Principles of the I/O Kit. OS X is largely the product of two strains of operating-system technology: Mac OS 9 (and its predecessors) and BSD. Given this pedigree, one might have.

This chapter talks about the inherent capabilities of the I/O Kit (and of the drivers developed with it), about the decisions informing its design, and about the I/O Kit when considered as a product. It also offers some caveats and guidelines for those considering developing kernel software such as device drivers.

Before You Begin

You might have developed device drivers for other platforms—Mac OS 9, perhaps, or BSD or another flavor of UNIX. One thing you’ll discover reading this document is how different the approach is with the I/O Kit. Although writing drivers for OS X requires new ways of thinking and different ways of programming, you are amply rewarded for shifting to this new approach. The I/O Kit simplifies driver development and supports many categories of devices. Once you get the basics of the I/O Kit down, you’ll find it a relatively easy and efficient matter to create device drivers.

Before you attempt driver development with the I/O Kit, Apple highly recommends certain prerequisites. Because the framework uses an object-oriented programming model, which is implemented in a restricted subset of C++, it helps to know C++ or object-oriented concepts in general. Also, device drivers are not the same thing as applications because, being kernel-resident, they must abide by more restrictive rules. Knowledge of kernel programming is therefore very useful.

Indeed, programming in the kernel is discouraged except when it is absolutely necessary. Many alternatives for communicating with hardware and networks exist at higher levels of the system, including the “device interface” feature of the I/O Kit described in Controlling Devices From Outside the Kernel See Should You Program in the Kernel? for more on alternatives to kernel programming.

I/O Kit Features

From its inception, the fundamental goal for the I/O Kit has been to accommodate and augment native features and capabilities of OS X, particularly those of the kernel environment. As the driver model for OS X, the I/O Kit supports the following features:

  • Dynamic and automatic device configuration (plug-and-play)

  • Many new types of devices, including graphics acceleration and multimedia devices

  • Power management (for example, “sleep” mode)

  • The kernel’s enforcement of protected memory—separate address spaces for kernel and user programs

  • Preemptive multitasking

  • Symmetric multiprocessing

  • Common abstractions shared between types of devices

  • Enhanced development experience—new drivers should be easy to write

The I/O Kit supports these kernel features with its new model for device drivers and adds some additional features:

Easy
  • An object-oriented framework implementing common behavior shared among all drivers and types (families) of drivers

  • Many families for developers to build upon

  • Threading, communication, and>

Harvard

Using Static Constructors in an I/O Kit Driver

In OS X v10.4, GCC 4.0 is the default compiler for all new projects, including I/O Kit drivers. This section describes a particular difference between GCC 3.3 and GCC 4.0 that may affect the compatibility of your in-kernel driver between OS X v10.3.x and OS X v10.4.x. For more information on the differences between GCC 3.3 (the default compiler in OS X v10.3) and GCC 4.0, including porting guidance, see GCC Porting Guide.

If you perform static construction within a function in a C++ I/O Kit driver (or other KEXT) compiled with GCC 3.3 or earlier, be aware that the same KEXT compiled with GCC 4.0 will no longer load successfully. This is because GCC 4.0 is more strict about taking and releasing locks in the kernel environment. If you perform in-function static construction in your I/O Kit driver compiled with GCC 4.0, you will probably see the following error when you try to load it:

The solution to this problem is simple: move the static constructor to a global namespace. For example, suppose that your I/O Kit driver includes an in-function static construction, such as in the code shown below:

You can avoid loading errors by changing this code to avoid in-function static construction, as in the code shown below:

Note that you may be able to avoid the load errors associated with in-function static construction without changing your code if you compile your KEXT with GCC 4.0 using the -fno-threadsafe-statics compiler option, but this may lead to other problems. Specifically, unless you can guarantee thread safety in other ways, compiling your KEXT with this option may break your code.

The Parts of the I/O Kit

Physically and electronically, the I/O Kit is composed of many parts: frameworks and libraries, development and testing tools, and informational resources such as example projects, documentation, and header files. This section catalogs these parts and indicates where they are installed and how they can be accessed.

Frameworks and Libraries

The I/O Kit is based on three C++ libraries. All of them are packaged in frameworks, but only IOKit.framework is a true framework. The Kernel framework exists primarily to expose kernel header files, including those of libkern and IOKit. The code of these “libraries” is actually built into the kernel; however, drivers (when loaded) do link against the kernel as if it were a library.

Table 1-1 Frameworks and libraries of the I/O Kit

Framework or library

Description and location

Kernel/IOKit

The library used for developing kernel-resident device drivers. Headers location: Kernel.framework/Headers/IOKit

Kernel/libkern

The library containing classes useful for all development of kernel software. Headers location: Kernel.framework/Headers/libkern

IOKit

The framework used for developing device interfaces. Location: IOKit.framework

Applications and Tools

You use a handful of development applications to build, manage, debug, examine, and package device drivers. Table 1-2 lists the applications used in driver development; these applications are installed in /Developer/Applications.

Table 1-2 Applications used in driver development

Application

Description

Xcode

The primary development application for OS X. Xcode manages projects, provides a full-featured code editor, builds projects according to arbitrarily complex rules, provides a user interface for software configuration, and acts as a front end for debugging and documentation searches.

I/O Registry Explorer

Enables the graphical exploration of the contents and structure of the I/O Registry.

Package Maker

Creates an installation package for the Installer application; used for deployment of kernel extensions (including device drivers).

Table 1-3 describes the command-line tools used in developing device drivers with the I/O Kit; all tools are located in /usr/sbin/ or /sbin.

Note: You can view on-line documentation of these tools (called man pages in the UNIX world) by entering a command in the shell provided by the Terminal application. The command is man, and the main argument to the man command is the name of the tool for which you want to see documentation. For example, to see the man page for the kextload tool, enter the following line in Terminal:

man kextload

Table 1-3 Command-line tools used in driver development

Tool

Description and location

ioreg

Prints the contents of the I/O Registry (a command-line version of the I/O Registry Explorer application).

kextload

Loads a kernel extension (such as device driver) or generates a statically linked symbol file for remote debugging.

kextunload

Unloads a kernel extension (if possible).

kextstat

Prints statistics about currently loaded drivers and other kernel extensions.

iostat

Displays kernel I/O statistics on terminal, disk, and CPU operations.

ioclasscount

Displays instance count of a specified class.

ioalloccount

Displays some accounting of memory allocated by I/O Kit objects in the kernel.

kextcache

Compresses and archives kernel extensions (including drivers) so they can be automatically loaded into the kernel at boot time.

gcc

Apple’s version of the GNU C++ compiler; Xcode automatically invokes it with the correct set of flags for I/O Kit projects.

gdb

Apple’s version of the GNU debugger; Xcode automatically invokes it with the correct set of flags for I/O Kit projects.

Other I/O Kit Resources

Several informational resources are included with the I/O Kit “product,” particularly documentation and header files. Some of these resources are described in the preceding chapter, Introduction to I/O Kit Fundamentals

The I/O Kit is part of the Darwin Open Source project. Apple maintains a website where you can find much information related to the I/O Kit and other Open Source projects managed by Apple. The following two locations are of particular interest:

  • Open Source Projects—http://developer.apple.com/darwin/projects/

    Here you can find links to the Darwin and Darwin Streaming projects, among other projects. Also featured are links to documentation and tools.

  • Mailing lists—http://developer.apple.com/darwin/mail.html

    This page features links that will put you on the Darwin-Development and DarwinOS-Users mailing lists, among others.

Should You Program in the Kernel?

If you are thinking of writing code for the kernel environment, think carefully. Programming in the kernel can be a difficult and dangerous task. And often there is a way to accomplish what you want to do without touching the kernel.

Software that resides in the kernel tends to be expensive. Kernel code is “wired” into physical memory and thus cannot be paged out by the virtual memory system. As more code is put into the kernel, less physical memory is available to user-space processes. Consequently, paging activity will probably intensify, thereby degrading system performance.

Kernel code is also inherently destabilizing, much more so than application code. The kernel environment is a single process, and this means that there is no memory protection between your driver and anything else in the kernel. Access memory in the wrong place and the entire system can grind to a halt, a victim of a kernel panic.

Moreover, because kernel code usually provides services to numerous user-space clients, any inefficiencies in the code can be propagated to those clients, thereby affecting the system globally.

Finally, kernel software is a real pain to write. There are subtleties to grapple with that are unknown in the realm of application development. And bugs in kernel code are harder to find than in user-space software.

With all this in mind, the message is clear. It is in everyone's best interest to put as little code as possible into the kernel. And any code that ends up in the kernel should be honed and rigorously tested.

When Code Should Reside in the Kernel

A handful of situations warrant loading a driver or extension into the kernel environment:

  • The software is used by the kernel environment itself.

  • User-space programs will frequently use the software.

  • The software needs to respond directly to primary interrupts (those delivered by the CPU's interrupt controller).

If the software you are writing does not match any of these criteria, it probably doesn’t belong in the kernel. If your software is a driver for a disk, a network controller, or a keyboard, it should reside in the kernel. If it is an extension to the file system, it should live in the kernel. If, on the other hand, it is used only now and then by a single user-space program, it should be loaded by the program and reside within it. Drivers for printers and scanners fall into this latter category.

Easy Harvard Referencing For Os X 10.7

Alternatives to Kernel-Resident Code

Easy

Apple provides a number of technologies that might let you accomplish what you want to do and stay out of the kernel. First are the higher-level APIs that give you some hardware-level access. For example, Open Transport is a powerful resource for many networking capabilities, and Quartz Compositor enables you to do some fairly low-level things with the graphics subsystem.

Second, and just as important, is the device-interface technology of the I/O Kit framework. Through a plug-in architecture, this technology makes it possible for your application to interact with the kernel to access hardware. In addition, you can—with a little help from the I/O Kit—use POSIX APIs to access serial, storage, or network devices. See Controlling Devices From Outside the Kernel for a summary of device interfaces and see the documentAccessing Hardware From Applications for a full discussion of this technology.

Note: Objective-C does not provide device-level I/O services. However, in your Cocoa application, you can call the C APIs for device-level functionality that the I/O Kit and BSD provide. Note that you can view the man pages that document BSD and POSIX functions and tools at OS X Man Pages.

Easy Harvard Referencing For Os X

Copyright © 2001, 2014 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2014-04-09

Easy Harvard Referencing For Os X

About Continuous Integration in Xcode

In Xcode, continuous integration is the process of automating and streamlining the building, analyzing, testing, and archiving of your Mac and iOS apps, in order to ensure that they are always in a releasable state. In a continuous integration workflow, you write apps locally in Xcode on your development Mac and check them into a source code repository. You then send them to Xcode Server, a service provided by OS X Server, for processing. In Xcode on your development Mac, you set up bots that run on the server. These bots process your apps, using the source code in your repository, and report back the results. Each run of a bot is called an integration, and these runs occur regularly throughout the development life cycle of your app. See Figure 1-1.

The goal of continuous integration is to improve software quality, and there are a number of ways this is achieved:

  • Catching problems quickly, easily, and early. Bot integrations can be set up to run every time you commit a code change to your source code repository, on a specific schedule, or whenever you manually initiate them. This allows you to identify code problems throughout the development process, fix problems as they occur, and prevent smaller problems from cascading into larger ones.

  • Enhancing collaboration. In a continuous integration workflow, your entire team (or selected individuals) can create bots, trigger integrations, view activity, and download builds. If problems are introduced, the person whose code change caused the failure is notified automatically.

  • Broadening test coverage. When working locally, testing your app on multiple devices with multiple configurations is a manual and time intensive process. In a continuous integration workflow, it’s automatic and easy. Just plug multiple devices into the server or configure your workflow to use multiple simulators, configure your bots accordingly, and let the system do the work for you.

  • Generating build and test statistics over time. In a continuous integration workflow, all progress and failure is logged. At any given time, you can see where your app is in the development process and how it has matured over time.

Easy Harvard Referencing For Os X

At a Glance

Follow the steps outlined in this document to set up a continuous integration workflow using Xcode Server.

Install and Set Up Xcode Server

The first step in implementing a continuous integration workflow is to install OS X Server and configure Xcode Server to perform your integrations. Even if you’ve never set up a server before, you’ll find the process for setting up OS X Server and enabling Xcode Server to be quick and straightforward.

Relevant chapter

Connect Xcode Server to Source Code Repositories

In order for a bot to perform an integration of a project in Xcode Server, the bot must have access to the project’s source code. Xcode Server supports two popular source control systems: Git and Subversion. On your development Mac, you write the source code and push it to a source code repository. This repository can be hosted on a remote server (Git or Subversion) or in OS X Server (Git only). The bot pulls your latest source code whenever it performs an integration. See Figure 1-2.

Relevant chapter

Create and Run Bots

Bots are at the center of the Xcode Server automated workflow. Bots build and test your projects with the schemes you specify. Because Xcode Server can access the source code repositories of your projects, you can create and schedule bots to run periodically, on every source code commit, or manually. You can also configure bots to send email notification of the success or failure of their integrations. Xcode Server also allows your bots to conduct performance testing and initiate pre- and postintegration triggers.

Relevant chapter

Monitor and Manage Bots

Xcode Server provides detailed information about the status of its integrations through Xcode on your development Mac, a browser, and email notifications. In the Xcode report navigator on your development Mac, you can manage bots, view their test results, read integration logs, initiate or cancel integrations, and download product archives. Xcode Server also hosts a bots website, where you and members of your development team can use a web browser to view the status of bot integrations and download assets and products. Bots can also be set up to send email notifications when integrations succeed, fail, or generate warnings. See Figure 1-3.

Relevant chapters

Manage and Monitor Bots from the Report Navigator, Monitor Bots from a Web Browser

Prerequisites

Easy Harvard Referencing For Os X El Capitan

When setting up a continuous integration workflow, it’s a good idea to have an understanding of how to test and debug Xcode apps. For detailed information on testing and debugging, see Testing with Xcode, Debugging with Xcode, and Instruments User Guide.

See Also

The Xcode Server web API lets you extend the power of Xcode Server through integration with your own tools and processes. For reference documentation, see Xcode Server API Reference.

With OS X Server, small organizations and workgroups without an IT department can take full advantage of the benefits of a server. In addition to Xcode Server, OS X Server can provide other services to Mac, Windows, and UNIX computers, and to iOS devices such as iPhone, iPad, and iPod touch. You use the Server app to turn on the services you want to provide, customize service settings, and turn off services you don’t need. Services include Calendar, Contacts, DHCP, DNS, File Sharing, FTP, Mail, Messages, NetInstall, Open Directory, Profile Manager, Software Update, Time Machine, VPN, Websites, Wiki, and Xsan. For information about setting up and administering these services while running the Server app, choose Help > Server Help. An administration guide, OS X Server: Advanced Administration, is also available online.

Easy Harvard Referencing For Os X 10.10

Copyright © 2018 Apple Inc. All rights reserved. Terms of Use | Privacy Policy | Updated: 2016-09-13