⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 set_adapter.c

📁 HP PCI热插拔代码GUI HP内部珍贵资料!
💻 C
字号:
/* *    Compaq Hot Plug Controller Graphical User Interface  *    Copyright 2000, 2001 Compaq Computer Corporation *    All rights reserved. * *    This program is free software; you can redistribute it and/or modify *    it under the terms of the GNU General Public License as published by *    the Free Software Foundation; either version 2 of the License, or *    (at your option) any later version. * *    This program is distributed in the hope that it will be useful, *    but WITHOUT ANY WARRANTY; without even the implied warranty of *    MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or *    NON INFRINGEMENT.  See the GNU General Public License for more details. * *    You should have received a copy of the GNU General Public License *    along with this program; if not, write to the Free Software *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * *    Please send all questions or concerns to linuxhotplug@compaq.com */#include "commonheader.h"#include "callbacks.h"#include "interface.h"#include "refresh_table.h"#include "set_adapter.h"#include "tree.h"#include "build_tree.h"// since adding/removing a device is a slot-based operation, the ioctl call is placed in this functionvoid set_adapter_from_slot (int function, GtkCTree* tree, GtkCTreeNode* node, GtkWidget* table, GtkWidget* status_bar, pci_tree_node* user_data){	int rt = 0;	char msg[MAXLEN];	pci_tree_node* tmp_p_node;	GtkCList* clist = GTK_CLIST(tree);        if (selected_row != NOT_SELECTED)        {		sigset_t current, backup;		sigemptyset(&current);		sigaddset(&current, SIGIO);		sigprocmask(SIG_BLOCK, &current, &backup);		if (rt < 0) {			g_print ("Error blocking SIGIO\n");			return;		} 		else {			public_slot_info* slot = (public_slot_info*) user_data->node_info;			if ( (slot->is_hotpluggable && slot->power == 1 && function == ADD_ADAPTER) || 			     (slot->is_hotpluggable && slot->power == 0 && function == REMOVE_ADAPTER) ) {				if (function == ADD_ADAPTER)				        sprintf(msg, "Slot %d: The device is already on.", selected_row);				else				        sprintf(msg, "Slot %d: The device is already off.", selected_row);			       	gtk_statusbar_pop(GTK_STATUSBAR(status_bar), context_id);		                gtk_statusbar_push(GTK_STATUSBAR(status_bar), context_id, msg);				return;			}						if (function == ADD_ADAPTER) {				stuff.type_of_request = ADD_BOARD;			}			else {	                      	stuff.type_of_request = POWER_DOWN_BOARD;			}				        stuff.physical_slot = selected_row;			rt = ioctl(dev_hpc, GUI_BACK_DOOR, &stuff);     // rt = 0 is success						build_tree((GtkCTree*)clist);			gtk_ctree_select(tree, root_nodes[selected_row-1]);  // set focus on the appropriate parent			clist->focus_row = -1;				// remove errant focus 			gtk_widget_draw(GTK_WIDGET(clist), NULL);	// repaint 					refresh_table(table, node);				tmp_p_node = ctree_partner(tree, root_nodes[selected_row-1], slot_based);						if (tmp_p_node->type == 0) {				slot = (public_slot_info*) tmp_p_node->node_info;					if (slot->is_hotpluggable) {					if ( (rt == 0 && slot->power == 1 && function == ADD_ADAPTER) || 					     (rt == 0 && slot->power == 0 && function == REMOVE_ADAPTER) ) {						if (function == ADD_ADAPTER)							sprintf(msg, "Slot %d: The device has been powered on.", selected_row);						else							sprintf(msg, "Slot %d: The device has been powered off.", selected_row);						gtk_statusbar_pop(GTK_STATUSBAR(status_bar), context_id);						gtk_statusbar_push(GTK_STATUSBAR(status_bar), context_id, msg);					} 					else {						if (function == ADD_ADAPTER)							sprintf(msg, "Slot %d: Problems occurred while powering on the device.", selected_row);						else							sprintf(msg, "Slot %d: Problems occurred while powering off the device.", selected_row);						gtk_statusbar_pop(GTK_STATUSBAR(status_bar), context_id);						gtk_statusbar_push(GTK_STATUSBAR(status_bar), context_id, msg);					}				}			}		}			rt = sigprocmask(SIG_SETMASK, &backup, NULL); //restore mask		if (rt < 0) {			g_print ("Error unblocking SIGIO\n");		}         }}// obtain the slot node and re-direct to the slot-based functionvoid set_adapter_from_adapter (int function, GtkCTree* tree, GtkCTreeNode* node, GtkWidget* table, GtkWidget* status_bar, pci_tree_node* user_data){	GtkCTreeNode* parent_node;	pci_tree_node* data;		parent_node = get_parent(node);	data = (pci_tree_node*) gtk_ctree_node_get_row_data(tree, parent_node);		set_adapter_from_slot (function, tree, parent_node, table, status_bar, data);}// obtain the slot node and re-direct to the slot-based functionvoid set_adapter_from_function (int function, GtkCTree* tree, GtkCTreeNode* node, GtkWidget* table, GtkWidget* status_bar, pci_tree_node* user_data){	GtkCTreeNode* parent_node;	pci_tree_node* data;		parent_node = get_parent(node);	data = (pci_tree_node*) gtk_ctree_node_get_row_data(tree, parent_node);		set_adapter_from_slot (function, tree, parent_node, table, status_bar, data);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -