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*02b4e56cSHaik Aftandilian * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 241d4b38e0Srsmaeda */ 251d4b38e0Srsmaeda 261d4b38e0Srsmaeda #ifndef _SYS_DRCTL_H 271d4b38e0Srsmaeda #define _SYS_DRCTL_H 281d4b38e0Srsmaeda 291d4b38e0Srsmaeda #ifdef __cplusplus 301d4b38e0Srsmaeda extern "C" { 311d4b38e0Srsmaeda #endif 321d4b38e0Srsmaeda 331d4b38e0Srsmaeda 341d4b38e0Srsmaeda #define DRCTL_DEV "/devices/pseudo/drctl@0:drctl" 351d4b38e0Srsmaeda 361d4b38e0Srsmaeda typedef enum { 371d4b38e0Srsmaeda DRCTL_CPU_CONFIG_REQUEST = 1, 381d4b38e0Srsmaeda DRCTL_CPU_CONFIG_NOTIFY, 391d4b38e0Srsmaeda DRCTL_CPU_UNCONFIG_REQUEST, 401d4b38e0Srsmaeda DRCTL_CPU_UNCONFIG_NOTIFY, 411d4b38e0Srsmaeda DRCTL_MEM_CONFIG_REQUEST, 421d4b38e0Srsmaeda DRCTL_MEM_CONFIG_NOTIFY, 431d4b38e0Srsmaeda DRCTL_MEM_UNCONFIG_REQUEST, 441d4b38e0Srsmaeda DRCTL_MEM_UNCONFIG_NOTIFY, 451d4b38e0Srsmaeda DRCTL_IO_CONFIG_REQUEST, 461d4b38e0Srsmaeda DRCTL_IO_CONFIG_NOTIFY, 471d4b38e0Srsmaeda DRCTL_IO_UNCONFIG_REQUEST, 48af4c679fSSean McEnroe DRCTL_IO_UNCONFIG_NOTIFY, 49af4c679fSSean McEnroe DRCTL_DRC_BLOCK 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 /* 9799c7e855SJames Marks - Sun Microsystems * Response structure passed back by drctl to its clients 9899c7e855SJames Marks - Sun Microsystems * (resource-specific DR modules). 9999c7e855SJames Marks - Sun Microsystems */ 10099c7e855SJames Marks - Sun Microsystems typedef enum { 10199c7e855SJames Marks - Sun Microsystems DRCTL_RESP_ERR, 10299c7e855SJames Marks - Sun Microsystems DRCTL_RESP_OK 10399c7e855SJames Marks - Sun Microsystems } drctl_resp_type_t; 10499c7e855SJames Marks - Sun Microsystems 10599c7e855SJames Marks - Sun Microsystems typedef struct drctl_resp { 10699c7e855SJames Marks - Sun Microsystems drctl_resp_type_t resp_type; 10799c7e855SJames Marks - Sun Microsystems union { 10899c7e855SJames Marks - Sun Microsystems char err_msg[1]; 10999c7e855SJames Marks - Sun Microsystems drctl_rsrc_t resources[1]; 11099c7e855SJames Marks - Sun Microsystems } un; 11199c7e855SJames Marks - Sun Microsystems } drctl_resp_t; 11299c7e855SJames Marks - Sun Microsystems 11399c7e855SJames Marks - Sun Microsystems #define resp_err_msg un.err_msg 11499c7e855SJames Marks - Sun Microsystems #define resp_resources un.resources 11599c7e855SJames Marks - Sun Microsystems 11699c7e855SJames 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, 13699c7e855SJames 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); 138af4c679fSSean McEnroe extern void drctl_block(void); 139*02b4e56cSHaik Aftandilian extern int drctl_tryblock(void); 140af4c679fSSean McEnroe extern void drctl_unblock(void); 1411d4b38e0Srsmaeda 1421d4b38e0Srsmaeda /* 1431d4b38e0Srsmaeda * Values for the 2nd arg (flags) of drctl_config_init 1441d4b38e0Srsmaeda */ 1451d4b38e0Srsmaeda #define DRCTL_FLAG_FORCE 1 1461d4b38e0Srsmaeda 1471d4b38e0Srsmaeda 1481d4b38e0Srsmaeda #ifdef __cplusplus 1491d4b38e0Srsmaeda } 1501d4b38e0Srsmaeda #endif 1511d4b38e0Srsmaeda 1521d4b38e0Srsmaeda #endif /* _SYS_DRCTL_H */ 153