Search
lxdream.org :: lxdream/src/drivers/osx_iokit.h
lxdream 0.9.1
released Jun 29
Download Now
filename src/drivers/osx_iokit.h
changeset 786:8f6ece92500e
prev736:a02d1475ccfd
author nkeynes
date Fri Jul 31 13:45:32 2009 +1000 (14 years ago)
permissions -rw-r--r--
last change Remove or change the level of a bunch of INFO messages that shouldn't really
be INFO level
file annotate diff log raw
nkeynes@720
     1
/**
nkeynes@729
     2
 * $Id$
nkeynes@720
     3
 *
nkeynes@720
     4
 * General OS X IOKit support (primarily for cdrom support)
nkeynes@720
     5
 *
nkeynes@720
     6
 * Copyright (c) 2008 Nathan Keynes.
nkeynes@720
     7
 *
nkeynes@720
     8
 * This program is free software; you can redistribute it and/or modify
nkeynes@720
     9
 * it under the terms of the GNU General Public License as published by
nkeynes@720
    10
 * the Free Software Foundation; either version 2 of the License, or
nkeynes@720
    11
 * (at your option) any later version.
nkeynes@720
    12
 *
nkeynes@720
    13
 * This program is distributed in the hope that it will be useful,
nkeynes@720
    14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
nkeynes@720
    15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
nkeynes@720
    16
 * GNU General Public License for more details.
nkeynes@720
    17
 */
nkeynes@720
    18
nkeynes@720
    19
#ifndef lxdream_osx_iokit_H
nkeynes@720
    20
#define lxdream_osx_iokit_H 1
nkeynes@720
    21
nkeynes@720
    22
#include <IOKit/IOKitLib.h>
nkeynes@720
    23
#include <IOKit/IOBSD.h>
nkeynes@720
    24
#include <IOKit/storage/IOStorageDeviceCharacteristics.h>
nkeynes@720
    25
#include <IOKit/storage/IOCDMediaBSDClient.h>
nkeynes@720
    26
#include "lxdream.h"
nkeynes@720
    27
#include "hook.h"
nkeynes@720
    28
nkeynes@720
    29
/**
nkeynes@720
    30
 * CD-ROM drive visitor. Returns FALSE to continue iterating, TRUE if the desired CD-ROM
nkeynes@720
    31
 * has been found. In the latter case, the io_object is returned from find_cdrom_device
nkeynes@720
    32
 * (and not freed)
nkeynes@720
    33
 */ 
nkeynes@720
    34
typedef gboolean (*find_drive_callback_t)( io_object_t object, char *vendor, char *product,
nkeynes@736
    35
        char *iopath, void *user_data );
nkeynes@720
    36
nkeynes@720
    37
/**
nkeynes@720
    38
 * Search for a CD or DVD drive (instance of IODVDServices or IOCompactDiscServices).
nkeynes@720
    39
 * The callback will be called repeatedly until either it returns TRUE, or all drives
nkeynes@720
    40
 * have been iterated over.
nkeynes@720
    41
 * 
nkeynes@720
    42
 * @return an IO registry entry for the matched drive, or 0 if no drives matched.
nkeynes@720
    43
 * 
nkeynes@720
    44
 * Note: Use of IOCompactDiscServices is somewhat tentative since I don't have a Mac
nkeynes@720
    45
 * with a CD-Rom drive.
nkeynes@720
    46
 */ 
nkeynes@720
    47
io_object_t find_cdrom_drive( find_drive_callback_t callback, void *user_data );
nkeynes@720
    48
nkeynes@720
    49
typedef struct osx_cdrom_drive *osx_cdrom_drive_t;
nkeynes@720
    50
nkeynes@720
    51
/**
nkeynes@720
    52
 * Construct an osx_cdrom_drive_t on the given device specification.
nkeynes@720
    53
 * @return a new osx_cdrom_drive_t, or NULL if the device name was invalid.
nkeynes@720
    54
 */
nkeynes@720
    55
nkeynes@720
    56
osx_cdrom_drive_t osx_cdrom_open_drive( const char *devname );
nkeynes@720
    57
nkeynes@720
    58
typedef void (*media_changed_callback_t)( osx_cdrom_drive_t drive, gboolean disc_present, void *user_data ); 
nkeynes@720
    59
nkeynes@720
    60
/**
nkeynes@720
    61
 * Set the media changed callback for the drive. (NULL == no callback)
nkeynes@720
    62
 */
nkeynes@720
    63
void osx_cdrom_set_media_changed_callback( osx_cdrom_drive_t drive, 
nkeynes@720
    64
                                           media_changed_callback_t callback, 
nkeynes@720
    65
                                           void *user_data );
nkeynes@720
    66
nkeynes@720
    67
/**
nkeynes@720
    68
 * Return a file handle for the cdrom drive (actually for the media).
nkeynes@720
    69
 * @return an open file handle, or -1 if there was no media present or
nkeynes@720
    70
 * the media could not be opened.
nkeynes@720
    71
 */
nkeynes@720
    72
int osx_cdrom_get_media_handle( osx_cdrom_drive_t drive );
nkeynes@720
    73
nkeynes@720
    74
void osx_cdrom_release_media_handle( osx_cdrom_drive_t drive );
nkeynes@720
    75
nkeynes@720
    76
/** Close on osx_cdrom_drive_t and release all associated resources.
nkeynes@720
    77
 */
nkeynes@720
    78
void osx_cdrom_close_drive( osx_cdrom_drive_t drive );
nkeynes@720
    79
nkeynes@786
    80
/**
nkeynes@786
    81
 * Install the notifications and handlers needed by the IOKit support layer.
nkeynes@786
    82
 * Must be called before trying to use any of the functions above.
nkeynes@786
    83
 */
nkeynes@786
    84
gboolean osx_register_iokit_notifications();
nkeynes@786
    85
/**
nkeynes@786
    86
 * Uninstall the notifications and handlers in the IOKit support layer
nkeynes@786
    87
 */
nkeynes@786
    88
void osx_unregister_iokit_notifications();
nkeynes@786
    89
nkeynes@720
    90
#endif /* !lxdream_osx_iokit_H */
.