1 /*- 2 * Copyright (c) 2006 IronPort Systems Inc. <ambrisko@ironport.com> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * 26 * $FreeBSD$ 27 */ 28 29 struct ipmi_get_info { 30 int kcs_mode; 31 int smic_mode; 32 uint64_t address; 33 int offset; 34 int io_mode; 35 }; 36 37 struct ipmi_softc { 38 device_t ipmi_dev; 39 device_t ipmi_smbios_dev; 40 struct cdev *ipmi_dev_t; 41 int ipmi_refcnt; 42 struct smbios_table_entry *ipmi_smbios; 43 struct ipmi_get_info ipmi_bios_info; 44 int ipmi_kcs_status_reg; 45 int ipmi_kcs_command_reg; 46 int ipmi_kcs_data_out_reg; 47 int ipmi_kcs_data_in_reg; 48 int ipmi_smic_data; 49 int ipmi_smic_ctl_sts; 50 int ipmi_smic_flags; 51 int ipmi_io_rid; 52 struct resource * ipmi_io_res; 53 int ipmi_mem_rid; 54 struct resource * ipmi_mem_res; 55 int ipmi_irq_rid; 56 struct resource * ipmi_irq_res; 57 void *ipmi_irq; 58 u_char ipmi_address; 59 u_char ipmi_lun; 60 int ipmi_busy; 61 struct selinfo ipmi_select; 62 int ipmi_timestamp; 63 int ipmi_requests; 64 struct callout_handle ipmi_timeout_handle; 65 TAILQ_HEAD(,ipmi_done_list) ipmi_done; 66 eventhandler_tag ipmi_ev_tag; 67 }; 68 69 struct ipmi_ipmb { 70 u_char foo; 71 }; 72 73 /* KCS status flags */ 74 #define KCS_STATUS_OBF 0x01 /* Data Out ready from BMC */ 75 #define KCS_STATUS_IBF 0x02 /* Data In from System */ 76 #define KCS_STATUS_SMS_ATN 0x04 /* Ready in RX queue */ 77 #define KCS_STATUS_C_D 0x08 /* Command/Data register write*/ 78 #define KCS_STATUS_OEM1 0x10 79 #define KCS_STATUS_OEM2 0x20 80 #define KCS_STATUS_S0 0x40 81 #define KCS_STATUS_S1 0x80 82 #define KCS_STATUS_STATE(x) ((x)>>6) 83 #define KCS_STATUS_STATE_IDLE 0x0 84 #define KCS_STATUS_STATE_READ 0x1 85 #define KCS_STATUS_STATE_WRITE 0x2 86 #define KCS_STATUS_STATE_ERROR 0x3 87 #define KCS_IFACE_STATUS_ABORT 0x01 88 #define KCS_IFACE_STATUS_ILLEGAL 0x02 89 #define KCS_IFACE_STATUS_LENGTH_ERR 0x06 90 91 /* KCD control codes */ 92 #define KCS_CONTROL_GET_STATUS_ABORT 0x60 93 #define KCS_CONTROL_WRITE_START 0x61 94 #define KCS_CONTROL_WRITE_END 0x62 95 #define KCS_DATA_IN_READ 0x68 96 97 /* SMIC status flags */ 98 #define SMIC_STATUS_BUSY 0x01 /* System set and BMC clears it */ 99 #define SMIC_STATUS_SMS_ATN 0x04 /* BMC has a message */ 100 #define SMIC_STATUS_EVT_ATN 0x08 /* Event has been RX */ 101 #define SMIC_STATUS_SMI 0x08 /* asserted SMI */ 102 #define SMIC_STATUS_TX_RDY 0x40 /* Ready to accept WRITE */ 103 #define SMIC_STATUS_RX_RDY 0x80 /* Ready to read */ 104 105 /* SMIC control codes */ 106 #define SMIC_CC_SMS_GET_STATUS 0x40 107 #define SMIC_CC_SMS_WR_START 0x41 108 #define SMIC_CC_SMS_WR_NEXT 0x42 109 #define SMIC_CC_SMS_WR_END 0x43 110 #define SMIC_CC_SMS_RD_START 0x44 111 #define SMIC_CC_SMS_RD_NEXT 0x45 112 #define SMIC_CC_SMS_RD_END 0x46 113 114 /* SMIC status codes */ 115 #define SMIC_SC_SMS_RDY 0xc0 116 #define SMIC_SC_SMS_WR_START 0xc1 117 #define SMIC_SC_SMS_WR_NEXT 0xc2 118 #define SMIC_SC_SMS_WR_END 0xc3 119 #define SMIC_SC_SMS_RD_START 0xc4 120 #define SMIC_SC_SMS_RD_NEXT 0xc5 121 #define SMIC_SC_SMS_RD_END 0xc6 122 123 #define RES(x) (x)->ipmi_io_res ? (x)->ipmi_io_res : (x)->ipmi_mem_res 124 #define INB(sc, x) bus_space_read_1(rman_get_bustag(RES(sc)), \ 125 rman_get_bushandle(RES(sc)), (x)) 126 #define OUTB(sc, x, value) bus_space_write_1(rman_get_bustag(RES(sc)), \ 127 rman_get_bushandle(RES(sc)), (x), value) 128 129 int ipmi_attach(device_t); 130 int ipmi_detach(device_t); 131 int ipmi_smbios_query(device_t); 132 int ipmi_smbios_probe(device_t); 133 int ipmi_read(device_t, u_char *, int); 134 void ipmi_intr(void *); 135 136 device_t ipmi_smbios_identify (driver_t *driver, device_t parent); 137 extern devclass_t ipmi_devclass; 138 extern int ipmi_attached; 139