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