1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #ifndef _SYS_SBP2_IMPL_H 28*7c478bd9Sstevel@tonic-gate #define _SYS_SBP2_IMPL_H 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate /* 33*7c478bd9Sstevel@tonic-gate * Serial Bus Protocol 2 (SBP-2) implementation 34*7c478bd9Sstevel@tonic-gate */ 35*7c478bd9Sstevel@tonic-gate 36*7c478bd9Sstevel@tonic-gate #include <sys/sbp2/common.h> 37*7c478bd9Sstevel@tonic-gate #include <sys/sbp2/bus.h> 38*7c478bd9Sstevel@tonic-gate #include <sys/sbp2/driver.h> 39*7c478bd9Sstevel@tonic-gate #include <sys/note.h> 40*7c478bd9Sstevel@tonic-gate 41*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 42*7c478bd9Sstevel@tonic-gate extern "C" { 43*7c478bd9Sstevel@tonic-gate #endif 44*7c478bd9Sstevel@tonic-gate 45*7c478bd9Sstevel@tonic-gate /* Config ROM parser internal structure */ 46*7c478bd9Sstevel@tonic-gate typedef struct sbp2_cfgrom_parse_arg { 47*7c478bd9Sstevel@tonic-gate sbp2_cfgrom_ent_t *pa_dir; /* directory to parse */ 48*7c478bd9Sstevel@tonic-gate sbp2_cfgrom_ent_t *pa_pdir; /* parent directory */ 49*7c478bd9Sstevel@tonic-gate sbp2_cfgrom_ent_t *pa_ref; /* referred entry */ 50*7c478bd9Sstevel@tonic-gate int pa_depth; /* current depth */ 51*7c478bd9Sstevel@tonic-gate } sbp2_cfgrom_parse_arg_t; 52*7c478bd9Sstevel@tonic-gate 53*7c478bd9Sstevel@tonic-gate typedef struct sbp2_cfgrom_ent_by_key { 54*7c478bd9Sstevel@tonic-gate uint8_t kt; 55*7c478bd9Sstevel@tonic-gate uint8_t kv; 56*7c478bd9Sstevel@tonic-gate int num; 57*7c478bd9Sstevel@tonic-gate sbp2_cfgrom_ent_t *ent; 58*7c478bd9Sstevel@tonic-gate int cnt; 59*7c478bd9Sstevel@tonic-gate } sbp2_cfgrom_ent_by_key_t; 60*7c478bd9Sstevel@tonic-gate 61*7c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("unique per call", { sbp2_cfgrom_ent_by_key 62*7c478bd9Sstevel@tonic-gate sbp2_cfgrom_parse_arg })) 63*7c478bd9Sstevel@tonic-gate 64*7c478bd9Sstevel@tonic-gate enum { 65*7c478bd9Sstevel@tonic-gate SBP2_CFGROM_MAX_DEPTH = 5, /* max directory depth */ 66*7c478bd9Sstevel@tonic-gate SBP2_CFGROM_GROW_INCR = 4, /* entry array growth increment */ 67*7c478bd9Sstevel@tonic-gate 68*7c478bd9Sstevel@tonic-gate SBP2_MOT_MIN = 500, /* minimum mgt ORB timeout, in ms */ 69*7c478bd9Sstevel@tonic-gate SBP2_MOT_DFLT = 2000, /* default mgt ORB timeout, in ms */ 70*7c478bd9Sstevel@tonic-gate SBP2_ORB_SIZE_MIN = 4, /* minimum ORB size, in bytes */ 71*7c478bd9Sstevel@tonic-gate SBP2_ORB_SIZE_DFLT = 32 /* default ORB size, in bytes */ 72*7c478bd9Sstevel@tonic-gate }; 73*7c478bd9Sstevel@tonic-gate 74*7c478bd9Sstevel@tonic-gate /* busops macros */ 75*7c478bd9Sstevel@tonic-gate #define SBP2_CSR_BASE(t) t->t_bus->sb_csr_base 76*7c478bd9Sstevel@tonic-gate #define SBP2_CFGROM_ADDR(t) t->t_bus->sb_cfgrom_addr 77*7c478bd9Sstevel@tonic-gate #define SBP2_GET_IBLOCK_COOKIE(t) \ 78*7c478bd9Sstevel@tonic-gate (t)->t_bus->sb_get_iblock_cookie((t)->t_bus_hdl) 79*7c478bd9Sstevel@tonic-gate #define SBP2_GET_NODE_ID(t) (t)->t_bus->sb_get_node_id((t)->t_bus_hdl) 80*7c478bd9Sstevel@tonic-gate #define SBP2_ALLOC_BUF(t, buf) (t)->t_bus->sb_alloc_buf((t)->t_bus_hdl, buf) 81*7c478bd9Sstevel@tonic-gate #define SBP2_FREE_BUF(t, buf) (t)->t_bus->sb_free_buf((t)->t_bus_hdl, buf) 82*7c478bd9Sstevel@tonic-gate #define SBP2_SYNC_BUF(t, buf, offset, length, type) \ 83*7c478bd9Sstevel@tonic-gate (t)->t_bus->sb_sync_buf((t)->t_bus_hdl, buf, offset, length, type) 84*7c478bd9Sstevel@tonic-gate #define SBP2_BUF_RD_DONE(t, buf, reqh, error) \ 85*7c478bd9Sstevel@tonic-gate (t)->t_bus->sb_buf_rd_done((t)->t_bus_hdl, buf, reqh, error) 86*7c478bd9Sstevel@tonic-gate #define SBP2_BUF_WR_DONE(t, buf, reqh, error) \ 87*7c478bd9Sstevel@tonic-gate (t)->t_bus->sb_buf_wr_done((t)->t_bus_hdl, buf, reqh, error) 88*7c478bd9Sstevel@tonic-gate #define SBP2_ALLOC_CMD(t, cmdp, f) \ 89*7c478bd9Sstevel@tonic-gate (t)->t_bus->sb_alloc_cmd((t)->t_bus_hdl, cmdp, f) 90*7c478bd9Sstevel@tonic-gate #define SBP2_FREE_CMD(t, cmd) \ 91*7c478bd9Sstevel@tonic-gate (t)->t_bus->sb_free_cmd((t)->t_bus_hdl, cmd) 92*7c478bd9Sstevel@tonic-gate #define SBP2_RQ(t, cmd, addr, q, berr) \ 93*7c478bd9Sstevel@tonic-gate (t)->t_bus->sb_rq((t)->t_bus_hdl, cmd, addr, q, berr) 94*7c478bd9Sstevel@tonic-gate #define SBP2_RB(t, cmd, addr, bp, len, berr) \ 95*7c478bd9Sstevel@tonic-gate (t)->t_bus->sb_rb((t)->t_bus_hdl, cmd, addr, bp, len, berr) 96*7c478bd9Sstevel@tonic-gate #define SBP2_WQ(t, cmd, addr, q, berr) \ 97*7c478bd9Sstevel@tonic-gate (t)->t_bus->sb_wq((t)->t_bus_hdl, cmd, addr, q, berr) 98*7c478bd9Sstevel@tonic-gate #define SBP2_WB(t, cmd, addr, bp, len, berr) \ 99*7c478bd9Sstevel@tonic-gate (t)->t_bus->sb_wb((t)->t_bus_hdl, cmd, addr, bp, len, berr) 100*7c478bd9Sstevel@tonic-gate 101*7c478bd9Sstevel@tonic-gate int sbp2_cfgrom_parse(sbp2_tgt_t *, sbp2_cfgrom_t *); 102*7c478bd9Sstevel@tonic-gate void sbp2_cfgrom_free(sbp2_tgt_t *, sbp2_cfgrom_t *); 103*7c478bd9Sstevel@tonic-gate 104*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 105*7c478bd9Sstevel@tonic-gate } 106*7c478bd9Sstevel@tonic-gate #endif 107*7c478bd9Sstevel@tonic-gate 108*7c478bd9Sstevel@tonic-gate #endif /* _SYS_SBP2_IMPL_H */ 109