Main Page | Modules | Data Structures | File List | Data Fields | Related Pages

ide_host_bus_device.c

00001 /***************************************************************************
00002  * CVSID: $Id: ide_host_bus_device.c,v 1.4 2004/04/12 20:11:51 joe Exp $
00003  *
00004  * PCI bus devices
00005  *
00006  * Copyright (C) 2003 David Zeuthen, <david@fubar.dk>
00007  *
00008  * Licensed under the Academic Free License version 2.0
00009  *
00010  * This program is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version.
00014  *
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License
00021  * along with this program; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023  *
00024  **************************************************************************/
00025 
00026 #ifdef HAVE_CONFIG_H
00027 #  include <config.h>
00028 #endif
00029 
00030 #include <ctype.h>
00031 #include <stdio.h>
00032 #include <stdlib.h>
00033 #include <string.h>
00034 #include <getopt.h>
00035 #include <assert.h>
00036 #include <unistd.h>
00037 #include <stdarg.h>
00038 
00039 #include "../logger.h"
00040 #include "../device_store.h"
00041 #include "bus_device.h"
00042 #include "common.h"
00043 
00052 static dbus_bool_t
00053 ide_host_device_accept (BusDeviceHandler *self, const char *path, 
00054             struct sysfs_device *device, dbus_bool_t is_probing)
00055 {
00056     int ide_host_number;
00057 
00058     if (sscanf (device->bus_id, "ide%d", &ide_host_number) != 1) {
00059         return FALSE;
00060     }
00061 
00062     return TRUE;
00063 }
00064 
00065 static char *
00066 ide_host_device_compute_udi (HalDevice *d, int append_num)
00067 {
00068     static char buf[256];
00069 
00070     if (append_num == -1)
00071         sprintf (buf, "/org/freedesktop/Hal/devices/ide_host_%d",
00072              hal_device_property_get_int (d, "ide_host.host_number"));
00073     else
00074         sprintf (buf, "/org/freedesktop/Hal/devices/ide_host_%d/%d",
00075              hal_device_property_get_int (d, "ide_host.host_number"),
00076              append_num);
00077 
00078     return buf;
00079 }
00080 
00081 static void 
00082 ide_host_device_pre_process (BusDeviceHandler *self,
00083                  HalDevice *d,
00084                  const char *sysfs_path,
00085                  struct sysfs_device *device)
00086 {
00087     int ide_host_number;
00088 
00089     sscanf (device->bus_id, "ide%d", &ide_host_number);
00090     hal_device_property_set_int (d, "ide_host.host_number", ide_host_number);
00091 
00092     /* guestimate product name */
00093     hal_device_property_set_string (d, "info.product", "IDE host controller");
00094 
00095     /* virtual device */
00096     hal_device_property_set_bool (d, "info.virtual", TRUE);
00097 }
00098 
00099 
00101 BusDeviceHandler ide_host_bus_handler = {
00102     bus_device_init,             
00103     bus_device_detection_done,   
00104     bus_device_shutdown,         
00105     bus_device_tick,             
00106     ide_host_device_accept,      
00107     bus_device_visit,            
00108     bus_device_removed,          
00109     ide_host_device_compute_udi, 
00110     ide_host_device_pre_process, 
00111     bus_device_got_udi,          
00112     "ide_host",                  
00113     "ide_host"                   
00114 };
00115 
00116 

Generated on Sat Apr 24 19:57:45 2004 for HAL by doxygen 1.3.6-20040222