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

ide_bus_device.c

00001 /***************************************************************************
00002  * CVSID: $Id: ide_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 char *
00053 ide_device_compute_udi (HalDevice *d, int append_num)
00054 {
00055     static char buf[256];
00056 
00057     if (append_num == -1)
00058         sprintf (buf, "/org/freedesktop/Hal/devices/ide_%d_%d",
00059              hal_device_property_get_int (d, "ide.host"),
00060              hal_device_property_get_int (d, "ide.channel"));
00061     else
00062         sprintf (buf, "/org/freedesktop/Hal/devices/ide_%d_%d/%d",
00063              hal_device_property_get_int (d, "ide.host"),
00064              hal_device_property_get_int (d, "ide.channel"),
00065              append_num);
00066 
00067     return buf;
00068 }
00069 
00070 static void 
00071 ide_device_pre_process (BusDeviceHandler *self,
00072             HalDevice *d,
00073             const char *sysfs_path,
00074             struct sysfs_device *device)
00075 {
00076     int host, channel;
00077 
00078     sscanf (device->bus_id, "%d.%d", &host, &channel);
00079     hal_device_property_set_int (d, "ide.host", host);
00080     hal_device_property_set_int (d, "ide.channel", channel);
00081 
00082     if (channel == 0) {
00083         hal_device_property_set_string (d, "info.product",
00084                         "IDE device (master)");
00085     } else {
00086         hal_device_property_set_string (d, "info.product",
00087                         "IDE device (slave)");
00088     }
00089 
00090     hal_device_property_set_bool (d, "info.virtual", TRUE);
00091 }
00092 
00093 
00095 BusDeviceHandler ide_bus_handler = {
00096     bus_device_init,           
00097     bus_device_detection_done, 
00098     bus_device_shutdown,       
00099     bus_device_tick,           
00100     bus_device_accept,         
00101     bus_device_visit,          
00102     bus_device_removed,        
00103     ide_device_compute_udi,    
00104     ide_device_pre_process,    
00105     bus_device_got_udi,        
00106     "ide",                     
00107     "ide"                      
00108 };
00109 
00110 

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