11d4b38e0Srsmaeda /* 21d4b38e0Srsmaeda * CDDL HEADER START 31d4b38e0Srsmaeda * 41d4b38e0Srsmaeda * The contents of this file are subject to the terms of the 51d4b38e0Srsmaeda * Common Development and Distribution License (the "License"). 61d4b38e0Srsmaeda * You may not use this file except in compliance with the License. 71d4b38e0Srsmaeda * 81d4b38e0Srsmaeda * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 91d4b38e0Srsmaeda * or http://www.opensolaris.org/os/licensing. 101d4b38e0Srsmaeda * See the License for the specific language governing permissions 111d4b38e0Srsmaeda * and limitations under the License. 121d4b38e0Srsmaeda * 131d4b38e0Srsmaeda * When distributing Covered Code, include this CDDL HEADER in each 141d4b38e0Srsmaeda * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 151d4b38e0Srsmaeda * If applicable, add the following below this CDDL HEADER, with the 161d4b38e0Srsmaeda * fields enclosed by brackets "[]" replaced with your own identifying 171d4b38e0Srsmaeda * information: Portions Copyright [yyyy] [name of copyright owner] 181d4b38e0Srsmaeda * 191d4b38e0Srsmaeda * CDDL HEADER END 201d4b38e0Srsmaeda */ 211d4b38e0Srsmaeda 221d4b38e0Srsmaeda /* 23*99c7e855SJames Marks - Sun Microsystems * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 241d4b38e0Srsmaeda * Use is subject to license terms. 251d4b38e0Srsmaeda */ 261d4b38e0Srsmaeda 271d4b38e0Srsmaeda #ifndef _SYS_DRCTL_H 281d4b38e0Srsmaeda #define _SYS_DRCTL_H 291d4b38e0Srsmaeda 301d4b38e0Srsmaeda #ifdef __cplusplus 311d4b38e0Srsmaeda extern "C" { 321d4b38e0Srsmaeda #endif 331d4b38e0Srsmaeda 341d4b38e0Srsmaeda 351d4b38e0Srsmaeda #define DRCTL_DEV "/devices/pseudo/drctl@0:drctl" 361d4b38e0Srsmaeda 371d4b38e0Srsmaeda typedef enum { 381d4b38e0Srsmaeda DRCTL_CPU_CONFIG_REQUEST = 1, 391d4b38e0Srsmaeda DRCTL_CPU_CONFIG_NOTIFY, 401d4b38e0Srsmaeda DRCTL_CPU_UNCONFIG_REQUEST, 411d4b38e0Srsmaeda DRCTL_CPU_UNCONFIG_NOTIFY, 421d4b38e0Srsmaeda DRCTL_MEM_CONFIG_REQUEST, 431d4b38e0Srsmaeda DRCTL_MEM_CONFIG_NOTIFY, 441d4b38e0Srsmaeda DRCTL_MEM_UNCONFIG_REQUEST, 451d4b38e0Srsmaeda DRCTL_MEM_UNCONFIG_NOTIFY, 461d4b38e0Srsmaeda DRCTL_IO_CONFIG_REQUEST, 471d4b38e0Srsmaeda DRCTL_IO_CONFIG_NOTIFY, 481d4b38e0Srsmaeda DRCTL_IO_UNCONFIG_REQUEST, 491d4b38e0Srsmaeda DRCTL_IO_UNCONFIG_NOTIFY 501d4b38e0Srsmaeda } drctl_cmds_t; 511d4b38e0Srsmaeda 521d4b38e0Srsmaeda /* 531d4b38e0Srsmaeda * Responses to/from the daemon for a reconfig request. 541d4b38e0Srsmaeda */ 551d4b38e0Srsmaeda typedef enum { 561d4b38e0Srsmaeda DRCTL_STATUS_INIT, /* to daemon */ 571d4b38e0Srsmaeda DRCTL_STATUS_ALLOW, /* from daemon */ 581d4b38e0Srsmaeda DRCTL_STATUS_DENY, /* from daemon */ 591d4b38e0Srsmaeda DRCTL_STATUS_CONFIG_SUCCESS, /* to daemon */ 601d4b38e0Srsmaeda DRCTL_STATUS_CONFIG_FAILURE /* to daemon */ 611d4b38e0Srsmaeda } drctl_status_t; 621d4b38e0Srsmaeda 631d4b38e0Srsmaeda /* 641d4b38e0Srsmaeda * Each resource descriptor consists of a common header 651d4b38e0Srsmaeda * followed by a resource-specific structure. 661d4b38e0Srsmaeda */ 671d4b38e0Srsmaeda 681d4b38e0Srsmaeda typedef struct drctl_rsrc_cpu { 691d4b38e0Srsmaeda int id; 701d4b38e0Srsmaeda } drctl_rsrc_cpu_t; 711d4b38e0Srsmaeda 721d4b38e0Srsmaeda typedef struct drctl_rsrc_memory { 731d4b38e0Srsmaeda uint64_t size; 741d4b38e0Srsmaeda uint64_t addr; 751d4b38e0Srsmaeda } drctl_rsrc_mem_t; 761d4b38e0Srsmaeda 771d4b38e0Srsmaeda typedef struct drctl_rsrc_dev { 781d4b38e0Srsmaeda char path[1]; 791d4b38e0Srsmaeda } drctl_rsrc_dev_t; 801d4b38e0Srsmaeda 811d4b38e0Srsmaeda typedef struct drctl_rsrc { 821d4b38e0Srsmaeda drctl_status_t status; 831d4b38e0Srsmaeda uint64_t offset; 841d4b38e0Srsmaeda union { 851d4b38e0Srsmaeda drctl_rsrc_cpu_t cpu; 861d4b38e0Srsmaeda drctl_rsrc_mem_t mem; 871d4b38e0Srsmaeda drctl_rsrc_dev_t dev; 881d4b38e0Srsmaeda } un; 891d4b38e0Srsmaeda } drctl_rsrc_t; 901d4b38e0Srsmaeda 911d4b38e0Srsmaeda #define res_cpu_id un.cpu.id 921d4b38e0Srsmaeda #define res_mem_size un.mem.size 931d4b38e0Srsmaeda #define res_mem_addr un.mem.addr 941d4b38e0Srsmaeda #define res_dev_path un.dev.path 951d4b38e0Srsmaeda 961d4b38e0Srsmaeda /* 97*99c7e855SJames Marks - Sun Microsystems * Response structure passed back by drctl to its clients 98*99c7e855SJames Marks - Sun Microsystems * (resource-specific DR modules). 99*99c7e855SJames Marks - Sun Microsystems */ 100*99c7e855SJames Marks - Sun Microsystems typedef enum { 101*99c7e855SJames Marks - Sun Microsystems DRCTL_RESP_ERR, 102*99c7e855SJames Marks - Sun Microsystems DRCTL_RESP_OK 103*99c7e855SJames Marks - Sun Microsystems } drctl_resp_type_t; 104*99c7e855SJames Marks - Sun Microsystems 105*99c7e855SJames Marks - Sun Microsystems typedef struct drctl_resp { 106*99c7e855SJames Marks - Sun Microsystems drctl_resp_type_t resp_type; 107*99c7e855SJames Marks - Sun Microsystems union { 108*99c7e855SJames Marks - Sun Microsystems char err_msg[1]; 109*99c7e855SJames Marks - Sun Microsystems drctl_rsrc_t resources[1]; 110*99c7e855SJames Marks - Sun Microsystems } un; 111*99c7e855SJames Marks - Sun Microsystems } drctl_resp_t; 112*99c7e855SJames Marks - Sun Microsystems 113*99c7e855SJames Marks - Sun Microsystems #define resp_err_msg un.err_msg 114*99c7e855SJames Marks - Sun Microsystems #define resp_resources un.resources 115*99c7e855SJames Marks - Sun Microsystems 116*99c7e855SJames Marks - Sun Microsystems /* 1171d4b38e0Srsmaeda * Message sent to DR daemon 1181d4b38e0Srsmaeda */ 1191d4b38e0Srsmaeda typedef struct drd_msg { 1201d4b38e0Srsmaeda uint_t cmd; 1211d4b38e0Srsmaeda uint_t count; 1221d4b38e0Srsmaeda int flags; 1231d4b38e0Srsmaeda drctl_rsrc_t data[1]; 1241d4b38e0Srsmaeda } drd_msg_t; 1251d4b38e0Srsmaeda 1261d4b38e0Srsmaeda typedef void *drctl_cookie_t; 1271d4b38e0Srsmaeda 1281d4b38e0Srsmaeda /* 1291d4b38e0Srsmaeda * DR RSMs (resource-specific modules) call these functions to 1301d4b38e0Srsmaeda * initialize or finalize a DR request. A request may include 1311d4b38e0Srsmaeda * multiple resources of the same type. The _init call returns 1321d4b38e0Srsmaeda * a cookie which must be supplied on by the corresponding 1331d4b38e0Srsmaeda * _fini call. 1341d4b38e0Srsmaeda */ 1351d4b38e0Srsmaeda extern int drctl_config_init(int, int, 136*99c7e855SJames Marks - Sun Microsystems drctl_rsrc_t *, int, drctl_resp_t **, size_t *, drctl_cookie_t); 1371d4b38e0Srsmaeda extern int drctl_config_fini(drctl_cookie_t, drctl_rsrc_t *, int); 1381d4b38e0Srsmaeda 1391d4b38e0Srsmaeda /* 1401d4b38e0Srsmaeda * Values for the 2nd arg (flags) of drctl_config_init 1411d4b38e0Srsmaeda */ 1421d4b38e0Srsmaeda #define DRCTL_FLAG_FORCE 1 1431d4b38e0Srsmaeda 1441d4b38e0Srsmaeda 1451d4b38e0Srsmaeda #ifdef __cplusplus 1461d4b38e0Srsmaeda } 1471d4b38e0Srsmaeda #endif 1481d4b38e0Srsmaeda 1491d4b38e0Srsmaeda #endif /* _SYS_DRCTL_H */ 150